1import{a as t}from"./BaseElement.wji90fuE.min.js";import{W as r}from"./WithApiClient.B8AOHZZP.min.js";import{t as a,h as e,s as n,x as i,T as s}from"./vendor-lit.2u3dzq2T.min.js";import"./fetchWithCache.BJ12kVQ7.min.js";import"./vendor.D2HIaoTS.min.js";Object.getOwnPropertyDescriptor;let o=class extends(r(t)){constructor(){super(...arguments),this.fetchCartWithGiftCardTask=new e(this,{task:async([t])=>{const{data:r}=await this.$api.client.storefront({body:{query:"\n mutation cartCreate($input: CartInput!) {\n cartCreate(input: $input) {\n cart {\n appliedGiftCards {\n amountUsed {\n amount\n currencyCode\n }\n\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\n",variables:{input:{giftCardCodes:[t]}}}}),a=r.cartCreate.userErrors,e=r.cartCreate.cart.appliedGiftCards;if(a.length>0)throw new Error(a[0].message);if(0===e.length)throw new Error("Gift card not found");return e[0]},autoRun:!1})}async handleSubmit(t){if(t.preventDefault(),this.fetchCartWithGiftCardTask.status===n.PENDING)return;const r=t.target,a=new FormData(r).get("code");a&&""!==a.trim()&&await this.fetchCartWithGiftCardTask.run([a.trim()])}get resultHTML(){if(this.fetchCartWithGiftCardTask.status===n.PENDING)return i`<p class="caption">Loading...</p>`;if(this.fetchCartWithGiftCardTask.status===n.ERROR)return i`<p class="caption p-xs text-u-error ring-u-error ring-1"> 2 ${this.fetchCartWithGiftCardTask.error.message} 3 </p>`;if(this.fetchCartWithGiftCardTask.status===n.COMPLETE&&this.fetchCartWithGiftCardTask.value){const t=this.fetchCartWithGiftCardTask.value;return i` 4 <span class="utility" 5 >Balance: ${t.balance.amount} 6 ${t.balance.currencyCode}</span 7 > 8 `}return s}render(){return i` 9 <slot @submit=${this.handleSubmit}></slot> 10 ${this.resultHTML} 11 `}};o=((t,r)=>{for(var a,e=r,n=t.length-1;n>=0;n--)(a=t[n])&&(e=a(e)||e);return e})([a("gift-card-balance")],o);export{o as GiftCardBalance};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.