PageSourceSearch

https://trykepos.com/cdn/shopifycloud/checkout-web/assets/c1/useAddressMutationsWithNegotiation.BIr_RXis.js

js trykepos.com collected 2026-09-28 23:57:57 UTC 84,920 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["PostPurchaseShouldRender.B2nmgbDo.js","esnext-vendor.DDpcaSqU.js","utilities-previous.Cnwy8G2v.js","app.DdDscdWN.js","assets/app.BuSMBobh.css","assets/previous.DjvIwnbB.css","extensions-rpc.RXK1z9Hb.js","amazon-pay-useAmazonPayPaymentLine.X7jqQiq6.js","performance-index.mu6MOGR9.js","shared-permissions.B59tuyWB.js","components-RedirectionNotice.module.CrRh0Cus.js","hydrate.BcfGVx0L.js","graphql-PaymentSessionMutation.C-nDEOnn.js","hooks-useShopPayExternalAppContext.R6pnDxYu.js","assets/helpers.BduNPqpW.css","assets/RedirectionNotice.B8v_QGNW.css","stopwatch.B56VZk5r.js","CalloutHeader.DC7jgv42.js","assets/CalloutHeader.BxwwfmsJ.css","component-Tips.COpDMT1b.js","Choice.D9vYH2mX.js","Checkbox.CdJzVizb.js","assets/Checkbox.SrYMuQu4.css","assets/Choice.DV6JSDrR.css","NumberField.9L3K4XMZ.js","assets/NumberField.CRpcZnVJ.css","Section.J2ZFesxe.js","assets/Section.CU18S7Ap.css","assets/Tips.D3S9_XMm.css","component-MsiInstallmentsSelect.CTVLe8c6.js","PaymentIcon.-ypvsmSq.js","assets/PaymentIcon.gzvCNwz_.css","PaymentLine.HSjRrKhm.js","localization-index.C3Jg94aR.js","Theme-ThemeOverride.CSLUDabY.js","assets/PaymentLine.D3bcP-mr.css","crypto-constants.Ca3tBkwm.js","assets/constants.Dlnp55te.css","hooks-useUpdateCheckoutAddress.C4NXzSJo.js","helpers-derivations.K4r9DEFp.js","redemption-promotions.8MPSgIef.js","payment-usePaymentExemptionReason.emSKnIpm.js","shop-pay-normalizeBuyerDetails.CDJVtFmS.js","helpers-isSwitchAccountBootRequest.C3tmXnb7.js","hooks-useShopPayProgressIntercepts.DJVsS6aH.js","cvv-cvvBridge.CLYVr7ZJ.js","assets/useShopPayProgressIntercepts.CIy8uDiZ.css","helpers-installmentsNotSupportedForAddress.BnHLRwvm.js","Popover.ZkMcWGfE.js","assets/Popover.Bi1nHaU-.css"])))=>i.map(i=>d[i]);
2import{_ as rt,S as Gt}from"./app.DdDscdWN.js";import{d as it,u as m,f as B,S as Yt,i as Ue,h as U,a as ot,k as j,q as S,y as L,E as I,ag as Es,n as ws,T as J,x as dt,A as de,o as qt,e as Is,G as Ns,r as Ls,_ as Ds,X as xs,ae as Ts}from"./esnext-vendor.DDpcaSqU.js";import{n as Je,b as ye,aj as ze,B as Ee,a0 as lt,ax as Rs,F as zt,bX as Ht,L as Wt,fx as Bs,M as Qt,fs as Fs,I as Ve,k as Z,P as Us,gS as Vs,a7 as bt,f_ as jt,gT as ct,cp as Os,gU as gt,z as $s,e as Oe,Z as Ks,fI as Gs,U as Ys,gV as qs,gW as zs,W as Xt,C as Zt,gX as Hs,G as He,bw as Jt,l as ne,aE as es,dS as Ws,bd as Qs,aG as js,a as ts,S as Xs,bU as Zs,fT as Js,br as ea,bs as ta,bt as sa,gY as aa,gZ as ut,g_ as Pt,g$ as na,h0 as _t,h1 as St,h2 as Mt,h3 as ra,a3 as ia,g9 as oa,i as da,fL as la}from"./hydrate.BcfGVx0L.js";import{T as N,a5 as Y,W as ee,ae as ss,dx as ca,dO as ua,gv as ce,gr as ma,m as z,hU as ha,hV as We,_ as pa,a0 as ya,Y as fa,hW as Ca,hX as va,bX as ue,dw as ba,hY as ga,bO as Pa,aA as as,gg as _a,at as ns,q as Sa,hZ as Ma,o as fe,g9 as Aa,u as we,ck as rs,a$ as $e,aZ as ve,h0 as mt,h_ as is,ac as ht,I as Be,dN as ka,bH as Ea,h$ as wa,U as H,i0 as Le,i1 as Ia,V as Ce,i2 as Na,i3 as At,i4 as La,i5 as Da,i6 as xa,bU as Ta,ah as os,bI as Ra,b6 as Ke,i7 as Ba,i8 as Fa,b8 as Ua,i9 as pt,ia as Va,ib as Oa,ic as ds,b3 as ls,x as $a,id as Ka,ie as Ga,ig as Ya,ih as qa,ii as za,e0 as Ha,e1 as cs,bD as Wa,Q as Qa,S as ja,ij as Xa,w as Za}from"./utilities-previous.Cnwy8G2v.js";import{u as Ja}from"./amazon-pay-useAmazonPayPaymentLine.X7jqQiq6.js";import{P as us}from"./PaymentIcon.-ypvsmSq.js";import{a as en}from"./PaymentLine.HSjRrKhm.js";import{b as kt,E as tn}from"./crypto-constants.Ca3tBkwm.js";import{a as sn,c as an,b as nn,u as rn}from"./hooks-useUpdateCheckoutAddress.C4NXzSJo.js";import{c as ms,u as on}from"./payment-usePaymentExemptionReason.emSKnIpm.js";import{s as dn,n as ln}from"./shop-pay-normalizeBuyerDetails.CDJVtFmS.js";import{u as cn,i as un,S as mn,c as hn}from"./hooks-useShopPayProgressIntercepts.DJVsS6aH.js";import{s as pn}from"./helpers-installmentsNotSupportedForAddress.BnHLRwvm.js";import{a as hs,C as et}from"./Choice.D9vYH2mX.js";import{s as yn}from"./redemption-promotions.8MPSgIef.js";import{P as fn}from"./Popover.ZkMcWGfE.js";const ci=it({displayName:"PostPurchaseShouldRender",suspense:!1,load:()=>rt(()=>import("./PostPurchaseShouldRender.B2nmgbDo.js").then(t=>t.P),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]))});function Cn({renderInSection:t,hideHeading:e,headingLevel:s=2}){const{i18n:a,shop:{name:n,showTipPayments:r}}=N(),{tipLines:o}=Y(),{tipLines:d}=ee(),i=B(()=>{const u=o.value?.[0]??d.value[0];return r||!!(u&&u.amount.amount>0)}),l=a.translate("tips.description",{shop_name:n}),c=m(Ee,{paddingBlockEnd:"base",children:[!e&&m(Yt,{children:[m(Je,{level:s,children:a.translate("tips.title")}),m(ye,{blockSize:"base"})]}),m(ze,{contentDisplay:"block",inlineSize:"100%",children:l}),m(Ue,{when:i,children:[m(ye,{blockSize:"small-200"}),m(ze,{contentDisplay:"block",inlineSize:"100%",children:a.translate("tips.custom_label")}),m(ye,{blockSize:"small-100"}),m(ze,{contentDisplay:"block",inlineSize:"33%",children:a.translate("tips.add_tip")})]})]});return t?m(lt,{accessibilityLabel:a.translate("tips.title"),children:c}):c}function vn(t){const{observability:e}=N();U(()=>{t&&e.error(t,{metadata:{tips:{component:"Tips",failure:"lazy_load"}}})},[t,e])}const ui=it({displayName:"Tips",renderLoading:t=>m(Cn,{...t}),useError:vn,load:()=>rt(()=>import("./component-Tips.COpDMT1b.js"),__vite__mapDeps([19,1,11,2,3,4,5,12,9,13,14,20,21,22,23,24,25,26,27,28]))}),bn=Qt("AmazonPayChangePaymentLinkButton");function mi(){const{i18n:t,observability:e}=N(),{inMemoryAmazonPayParts:{sdkStatus:s}}=ss(),a=B(()=>{const i=s.value;return i.status===Rs.Available?i.sdk:void 0}),n=Ja(),r=zt(void 0,bn),{hasError:o}=Ht(ca),d=t.translate("vaulted.change_button");return n.value?m(Ue,{when:a,children:i=>m(Wt,{onClick:()=>{try{const{checkout_session_id:c}=Bs(n.value.method.walletParams);i.Pay.changePaymentMethod({amazonCheckoutSessionId:c,isDeclined:o})}catch(c){e.error(new gn(`Error on changing buyer payment method. Details: ${c}`,{cause:c}))}},id:r,children:d})}):null}
2class gn extends Error{constructor(){super(...arguments),this.name="AmazonPayChangePaymentLinkError"}}const Pn=new Map([["american_express","american_express"],["amex","amex"],["bogus","bogus"],["cartes_bancaires","cartes_bancaires"],["dankort","dankort"],["diners_club","diners_club"],["discover","discover"],["elo","elo"],["forbrugsforeningen","forbrugsforeningen"],["hypercard","hypercard"],["interac","interac"],["jcb","jcb"],["laser","laser"],["maestro","maestro"],["mastercard","mastercard"],["rupay","rupay"],["unionpay","unionpay"],["visa","visa"],["visaelectron","visaelectron"]]);function hi({brand:t,descriptor:e}){const{hasError:s}=Fs(),a=t?.toLowerCase().replace(/\s+/g,"_")??"",n=Pn.get(a)??"generic";return m(Z,{direction:"inline",children:[s&&m(Yt,{children:[m(Ve,{tone:"critical",type:"alert-circle"}),m(ye,{display:"inline",inlineSize:"small-400"})]}),m(en,{icon:m(us,{type:n}),details:e})]})}function _n(){const{i18n:t}=N(),e=ee().purchaseOrderNumber.value;if(!e)return null;const s=`${t.translate("payment.purchase_order_number.title")} #${e}`;return m(Us,{children:s})}const Sn=t=>m("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"66 -30 151 80",...t,children:[m("path",{fill:"inherit",stroke:"inherit",strokeWidth:2,d:"M73.8-18.2c-4.4.8-7.3 4.9-6.5 9.3l7.6 43.3c.8 4.3 4.9 7.3 9.3 6.5l59.7-10.5c3.3-.6 7.4-3.3 9.1-6.1l14.4-22.5c2.4-3.7 1.5-8.9-2-11.6L144.2-26c-2.6-2-7.4-3.2-10.7-2.6 0-.1-59.7 10.4-59.7 10.4z"}),m("circle",{cx:157.2,cy:-2.9,r:3.5,fill:"inherit",stroke:"inherit",strokeWidth:2}),m("path",{fill:"inherit",stroke:"inherit",strokeWidth:2,d:"m95.9 9.1 11.5 7.4 18-24.5m31.8 5.1c23.3-7.1 31.6 22.2 57.5-13.1"})]}),Mn="agRve",An="FiV0Z",Et={NoPaymentRequiredWrapper:Mn,FreeTagIcon:An};function pi({minimal:t,reason:e,vaulted:s}){const{i18n:a}=N(),r=Vs().value.length,o=d=>{switch(d){case"giftCard":return a.translate("payment.order_covered_by_gift_cards_notice",{count:r});case"freeOrder":return a.translate("payment.free_order_notice_html");case"storeCredit":return a.translate("payment.order_covered_by_store_credit_notice");case"redeemables":return a.translate("payment.order_covered_by_redeemables_notice");case"deferred":return a.translate("payment_gateway.deferred_payment_label");default:ot(d)}};return s?m(Z,{gap:"base",children:[m(bt,{children:o(e)}),m(_n,{})]}):t?m(tn,{children:m(kt,{children:o(e)})}):m("div",{className:Et.NoPaymentRequiredWrapper,children:m(Z,{gap:"large-200",alignItems:"center",children:[m(Sn,{className:Et.FreeTagIcon,focusable:"false","aria-hidden":"true"}),m(kt,{children:m(bt,{children:o(e)})})]})})}class kn extends Gt{constructor(){super(...arguments),this.name="AmazonPayMissingPaymentPreferencesError"}}function yi(){const t=ee().paymentLines;return B(()=>{const e=t.value,s=(()=>{const[n]=e.filter(i=>i.method.type==="walletsPlatformPaymentMethod");if(!n)return"";const o=n.method.walletParams.payment_preferences?.[0];if(!o)throw new kn("Amazon Pay wallet params missing payment preferences",{groupingHash:"AmazonPay::usePaymentDetails::AmazonPayMissingPaymentPreferencesError"});return o.paymentDescriptor.replace("****","•••• ").replace(/(\((.*?)\))/,"").trim()})();return{brand:(()=>{if(!s)return;const n=s.match(/^(.+?)\s+••••/);if(!n)return s;const r=n[1];return r===void 0?s:r.trim()})(),descriptor:s}})}const wt={id:"2bcff8985dbaa04eadb413f088e89a17952466f58df58d4f1fd47003417e8f71",type:"query",name:"CreditCardActiveSubscriptions",source:"query CreditCardActiveSubscriptions($id:ID!,$uuid:String!,$first:Int){creditCardActiveSubscriptions(id:$id,uuid:$uuid,first:$first){pageInfo{hasNextPage __typename}nodes __typename}}"},Re=Object.freeze({name:null,number:null,verification_value:null,expiry:null,issue_date:null,issue_number:null});var ps=(t=>(t.FirstName="firstName",t.LastName="lastName",t.Number="number",t.Cvv="verificationValue",t.Month="month",t.Year="year",t.Base="base",t.DebitOnly="debitOnly",t))(ps||{});
2const It={baseMessage:null,fieldErrors:Re,blockedByDuplicateAutopayCard:!1};function fi(){const{i18n:t,observability:e}=N(),[s,a]=j(It),n=S((l,c)=>{e.counter({name:l,value:1,attributes:{errorField:c.field.join("-"),errorMessage:c.message}})},[e]),r=S(l=>{if(!l||!l.length){a({baseMessage:t.translate("credit_card_form.generic_card_error"),fieldErrors:Re,blockedByDuplicateAutopayCard:!1});return}const c={...Re};let u=null;l.forEach(p=>{switch(n("save_credit_card_error",p),p.field?.[1]){case"firstName":c.name=t.translate("field_errors.credit_card_name_billing_invalid");return;case"lastName":c.name=t.translate("field_errors.credit_card_name_invalid");return;case"month":case"year":c.expiry=t.translate("field_errors.credit_card_expiry_invalid");return;case"number":c.number=t.translate("field_errors.credit_card_number_invalid");return;case"verificationValue":c.verification_value=t.translate("payment.card_fields.errors.invalid.verification_value");return;case"debitOnly":u=t.translate("payment_errors.debit_only");return;case"base":if(p.message==="credit_card_is_expired"){c.expiry=t.translate("payment_errors.card_has_expired");return}else if(p.message==="failed_to_verify_credit_card"){u=t.translate("payment.generic_incorrect_card_info");return}else if(p.message==="three_d_secure_authentication_failed"){u=t.translate("payment_errors.three_d_secure_failed_payment_method");return}else if(p.message==="billing_address_missing"){u=t.translate("payment_errors.payment_method_billing_address");return}}if(p.message==="too_many_credit_cards"){u=t.translate("credit_card_form.max_cards_reached",{max_cards:ua});return}u=t.translate("credit_card_form.generic_card_error"),n("save_credit_card_error_unhandled",p)}
2),a({baseMessage:u,fieldErrors:c,blockedByDuplicateAutopayCard:!1})},[t,n]),o=S(()=>{e.counter({name:"save_credit_card_blocked_by_autopay",value:1}),a({baseMessage:null,fieldErrors:Re,blockedByDuplicateAutopayCard:!0})},[e]),d=S(()=>{a(It)},[]),i=S(l=>{e.counter({name:"save_credit_card_vaulting_failure",value:1,attributes:{reason:l}}),r(l==="missing_billing_address"?[{field:["creditCard","base"],message:"billing_address_missing"}]:void 0)},[e,r]);return{creditCardErrors:s,setCreditCardErrors:r,clearCreditCardErrors:d,failCardVaulting:i,blockDuplicateAutopayCard:o}}function G(t){return t?.paymentMethod==="CREDIT_CARD"}function Ci(t){return t.paymentMethod==="IDEAL"||t.paymentMethod==="CUSTOM_ONSITE"&&t.paymentBrands?.some(e=>e.toLowerCase()==="ideal")===!0}function vi(t){return t.paymentMethod==="APPLE_PAY"}function bi(t){return t.paymentMethod==="CUSTOM_ONSITE"}function gi(t){return t.paymentMethod==="SHOP_PAY"}function Pi(t){return t.paymentMethod==="SHOP_PAY_INSTALLMENTS"}function _i(t){return t.paymentMethod==="PAYPAL"}function Si(t){return t.paymentMethod==="BANK"}function tt(t){return t.paymentMethod==="DEFERRED"}function Mi(t){return t.paymentMethod==="OFFSITE"||t.paymentMethod==="MANUAL_PAYMENT"||t.paymentMethod==="CUSTOM_MANUAL_PAYMENT"||t.paymentMethod==="PAYMENT_ON_DELIVERY"}function En(t){return G(t)||!!t.lastUsedAt}function wn(t){for(const e of t)if(!G(e)||!e.paymentAttributes.expired)return e;return t[0]}function In({selected:t,paymentMethods:e,availablePaymentMethods:s}){return!!(ce(t,s)||G(t)&&e.some(({method:a})=>a.paymentMethod===t.paymentMethod&&a.id===t.id))}function Nn(t,e){let s=t.paymentMethod.toLowerCase(),a="";switch(t.paymentMethod){case"CREDIT_CARD":t.paymentAttributes?.brand&&(s=t.paymentAttributes.brand);break;case"CUSTOM_ONSITE":{s=ma(e,{paymentBrands:t.paymentBrands,paymentMethodIdentifier:t.paymentMethodIdentifier})?.name||"custom_onsite",a=t.paymentBrands?.slice().sort().join(",")??"";break}case"IDEAL":s="ideal";break;case"OFFSITE":s=t.name,a=t.paymentBrands?.slice().sort().join(",")??"";break;case"MANUAL_PAYMENT":case"CUSTOM_MANUAL_PAYMENT":case"PAYMENT_ON_DELIVERY":s=t.name;break;case"APPLE_PAY":s="apple_pay";break;case"SHOP_PAY":s="shop_pay";break;case"SHOP_PAY_INSTALLMENTS":s="shopify_installments";break;case"PAYPAL":s="paypal_express";break;case"BANK":s=t.displayName||"bank";break;case"DEFERRED":s="deferred";break;default:ot(t)}return{paymentMethodName:s,paymentBrands:a}}const re={markBuyerHasActed:!1,updateSelectedCardBin:!1,selectedCardFirstDigits:void 0,preserveExistingBinPrefix:!1,claimMsiBin:!1,claimedMsiBin:void 0,shouldNegotiate:!1};function ys(t){return{id:t.id,bank:t.bank,brand:t.brand,defaultPaymentMethod:t.preferred,expired:t.expired,expiryMonth:t.expiryMonth,expiryYear:t.expiryYear,lastDigits:t.lastDigits,lastUsedAt:t.lastUsedAt,name:t.name,nickname:t.nickname,billingAddress:t.billingAddress,cvvVerification:t.verified?void 0:{type:"session-token"}}}function De(t){switch(t.paymentMethod){case"CREDIT_CARD":return{id:t.id,paymentMethod:"CREDIT_CARD",paymentAttributes:ys(t.paymentAttributes),lastUsedAt:t.lastUsedAt};case"IDEAL":return t;case"CUSTOM_ONSITE":return t;case"APPLE_PAY":return t;case"OFFSITE":return t;case"MANUAL_PAYMENT":return t;case"CUSTOM_MANUAL_PAYMENT":return t;case"PAYMENT_ON_DELIVERY":return t}}function st(t,e){switch(t.paymentMethod){case"CREDIT_CARD":return e.find(s=>z(s)&&s.id===t.id);case"IDEAL":return t;case"CUSTOM_ONSITE":return t;case"APPLE_PAY":return t;case"OFFSITE":return t;case"MANUAL_PAYMENT":return t;case"CUSTOM_MANUAL_PAYMENT":return t;case"PAYMENT_ON_DELIVERY":return t;case"SHOP_PAY":case"SHOP_PAY_INSTALLMENTS":case"PAYPAL":case"BANK":case"DEFERRED":return;default:ot(t)}}
2class Ln extends Error{constructor(){super(...arguments),this.name="EmptySessionIdError"}}class Dn extends Error{constructor(){super(...arguments),this.name="BuyerDetailsRefreshError"}}const xn="credit_card_not_found";function Tn(t){return t.errors?.some(({message:e})=>e===xn)??!1}class Rn{constructor(e){this.newCard=L(void 0),this.canSetCreditCardNickname=L(!0),this.addCreditCardStrategy="vault-and-select",this.deps=e;const{shopPay:s,installmentsPaymentMethodSelected:a,isApplePayAvailable:n,filteredNegotiatedPaymentMethods:r,isCreditCardDisabled:o,msiEligibilityByCardId:d,hasSellingPlan:i}=e;this.availablePaymentMethods=L(r),this.shopPayAvailableUserStoredPaymentMethods=I(()=>{const c=this.availablePaymentMethods.value;return c.length?Sa(s.user.paymentMethods.value,c):[]}),this.availableUserStoredPaymentMethods=I(()=>this.shopPayAvailableUserStoredPaymentMethods.value.map(De)),this.promotedMethods=I(()=>s.session.promotedPaymentMethods.value.map(De)),this.selectedPaymentMethod=I(()=>{const c=s.session.selectedPaymentMethod.value;return c?De(c):void 0}),this.selectedCreditCard=I(()=>{const c=s.session.selectedPaymentMethod.value;return c&&z(c)?ys(c.paymentAttributes):void 0}),this.shopPayPaymentMethods=I(()=>{const c=s.user.paymentMethods.value,u=this.shopPayAvailableUserStoredPaymentMethods.value,p=this.availablePaymentMethods.value,h=s.session.promotedPaymentMethods.value,v=s.user.paymentMethodHistory.value,g=c.filter(z).map(E=>({method:E,isValidForCheckout:u.includes(E),isExpired:E.paymentAttributes.expired,isDisabled:o(E.paymentAttributes)})),M=a?[]:Ma({negotiatedPaymentMethods:p,userStoredPaymentMethods:c,paymentMethodHistory:v,isApplePayAvailable:n}),b=[...g.sort((E,P)=>fe(E.method,P.method)),...M.sort((E,P)=>fe(E.method,P.method))];let f=-1,A="";for(const[E,P]of b.entries()){const x=P.method.lastUsedAt??"";x>A&&(A=x,f=E)}f>0&&b.unshift(...b.splice(f,1));const k=s.session.selectedPaymentMethod.value,D=new Set(h.map(E=>E.id));return b.filter(({method:E})=>z(E)||k&&!z(k)&&E.id===k.id||D.has(E.id)?!0:Aa(E))}),this.paymentMethods=I(()=>this.shopPayPaymentMethods.value.map(({method:c,...u})=>{const p=De(c);return{...u,method:p,canEdit:z(c),canDelete:z(c),canSetDefault:!1,isDefault:!1}})),this.selectedPaymentMethodItem=I(()=>{const c=this.selectedPaymentMethod.value;if(c)return this.paymentMethods.value.find(({method:u})=>u.id===c.id&&u.paymentMethod===c.paymentMethod)}),this.cardPaymentMethods=I(()=>this.paymentMethods.value.filter(c=>G(c.method))),this.activeOrExpiredCardMethods=I(()=>{const c=this.cardPaymentMethods.value,u=[];for(const p of c)a&&p.isDisabled||u.push(p);return u}),this.disabledCardMethodsForInstallments=I(()=>a?this.cardPaymentMethods.value.filter(c=>c.isDisabled):[]),this.isEveryCardDisabled=I(()=>{const c=this.cardPaymentMethods.value;if(c.length===0)return!1;const u=new Set(this.disabledCardMethodsForInstallments.value.map(h=>h.method.id)),p=c.filter(h=>h.isExpired&&!u.has(h.method.id)).length;return c.length===u.size+p}),this.isEveryCardExpired=I(()=>{const c=this.cardPaymentMethods.value;if(c.length===0)return!1;const u=new Set(this.disabledCardMethodsForInstallments.value.map(h=>h.method.id)),p=c.filter(h=>!u.has(h.method.id));return p.length===0?!1:p.every(h=>h.isExpired)});const l=I(()=>{const c=we(this.availablePaymentMethods.value);if(!ct(c))return!1;const u=this.selectedCreditCard.value;return!!(u&&d.value[u.id])});this.msi={binResolution:"server",selectedCardBin:I(()=>{}),clearInstallments:ha,expandedVisible:I(()=>l.value?s.session.paymentMethodOption.value?.name!=="SHOPIFY_INSTALLMENTS":!1),collapsedVisible:I(()=>l.value&&!i.value)}}canShowAsGuestCheckoutMethod(e){const{shopPay:s}=this.deps;return s.visibility.showGuestCheckoutPaymentMethods&&!(e.type==="wallet"&&(e.name==="SHOP_PAY"||e.name==="SHOPIFY_INSTALLMENTS"))}async selectPaymentMethod(e,s="programmatic",a){const{shopPay:n,updateCheckoutAddress:r,shippingRequired:o}=this.deps;if(!e)return n.session.clearPaymentMethod(),{status:"handled",effects:re};const d=st(e,n.user.paymentMethods.value);if(!d)return{status:"not-handled"};if(s==="buyer"&&this.recordPaymentMethodSelected(e),G(e)){const l=this.selectCreditCard({id:e.paymentAttributes.id});return We(d,n.user.paymentMethods.value,ce(d,this.availablePaymentMethods.value))&&this.#e(d,a),await l,{status:"handled",effects:re}}const i=ce(d,this.availablePaymentMethods.value);return We(d,n.user.paymentMethods.value,i)&&this.#e(d,s==="buyer"?{...a,buyerInitiated:!0}
2:a),(pa(d)||ya(d)||fa(d)||Ca(d))&&await r({billingAddress:n.session.selectedBillingAddress.value?.address,fallbackPhoneNumber:n.user.phoneNumber.value},o.value),{status:"handled",effects:re}}async promoteSelectedPaymentMethod(e){const{shopPay:s}=this.deps,a=va(e,s.user.paymentMethods.value);return a&&(s.session.selectPaymentMethod(a),s.session.unstable_promotePaymentMethod(a)),{status:"handled",effects:{...re,selectByBuyerKey:ue(e)}}}getSavedCardActiveSubscriptionsLookup(e){const s=this.deps.shopPay.user.paymentMethods.value.filter(z).map(o=>o.paymentAttributes).find(o=>o.id===e.id);if(!s)return;const a={id:s.id,uuid:s.uuid,first:3},n=Es(wt,a),{shopPayGraphql:r}=this.deps;return{key:n,read(){return r.read(n)?.creditCardActiveSubscriptions?.nodes},async load(){const{data:o}=await r.staticQuery(wt,{variables:a});return o?.creditCardActiveSubscriptions?.nodes??[]}}}async selectCreditCard({id:e}){const{shopPay:s}=this.deps,a=s.user.paymentMethods.value.filter(z).map(o=>o.paymentAttributes).find(o=>o.id===e);if(!a)return;const{updateCheckoutAddress:n,fallbackPhoneNumber:r}=this.deps;s.session.selectPaymentMethod({id:a.id,lastUsedAt:a.lastUsedAt,paymentMethod:"CREDIT_CARD",paymentAttributes:a}),this.clearShopPayPaymentLines(),await n({billingAddress:a.billingAddress.address,fallbackPhoneNumber:r})}async deleteCreditCard({id:e}){return this.deleteCreditCardById({id:e})}async updateCreditCard({id:e,billingAddress:s,nickname:a}){const{shopPay:n,updateCreditCard:r,checkoutContext:o,markShopCashStatesStale:d,observability:i}=this.deps,l=n.user.paymentMethods.value.filter(z).map(u=>u.paymentAttributes).find(u=>u.id===e);if(!l)return{status:"failed"};const c=await r(s,e,l.uuid,o,a);if(c.status==="success"&&c.creditCard){const{creditCard:u}=c;n.user.updateCreditCard(e,u),this.selectCreditCard({id:u.id}).catch(p=>{i.error(p)})}if(d(),c.status!=="success"){const u=ba();return pn({addressErrors:u,shopPayErrors:c.errors,i18n:this.deps.i18n,observability:i,userEvents:this.deps.userEvents,source:this.deps.source,configuration:this.deps.checkout.configuration,shop:this.deps.shop,addressContext:"payment-method",submittedAddress:s}),{status:"failed",addressErrors:Object.fromEntries(Object.entries(u).map(([h,v])=>[h,v.value]))}}return{status:"success"}}async addCreditCard({sessionId:e,billingAddress:s,nickname:a,debitOnly:n=!1,isBlocking:r=!1}){const{createCreditCard:o,checkoutContext:d,markShopCashStatesStale:i,observability:l}=this.deps;if(e==="")return l.error(new Ln("ShopPayPaymentMethodManager: addCreditCard called with empty sessionId")),{status:"failed"};const c=await o(s,e,d,a),u=await this.handleNewCardResponse(c,n,r);return i(),u}async completeCreditCardVerificationAndVault({verificationId:e,billingAddress:s,nickname:a,debitOnly:n=!1,isBlocking:r=!1}){const{completeCreditCardVerification:o,markShopCashStatesStale:d}=this.deps,i=await o(s,e,a),l=await this.handleNewCardResponse(i,n,r);return d(),l}dispose(){}async deleteCreditCardById({id:e,uuid:s}){const{shopPay:a,deleteCreditCard:n,updateCheckoutAddress:r,emptyAddress:o,fallbackPhoneNumber:d,checkoutContext:i,markShopCashStatesStale:l}=this.deps,c=s??a.user.paymentMethods.value.filter(z).map(b=>b.paymentAttributes).find(b=>b.id===e)?.uuid;if(!c)return{status:"failed"};const u=a.session.selectedPaymentMethod.value,p=u&&z(u)?u.paymentAttributes.uuid:void 0,h=await n(e,c,i);if(h.status!=="success"&&!Tn(h))return{status:"failed"};const v=a.user.paymentMethods.value.filter(z).map(b=>b.paymentAttributes).filter(b=>b.uuid!==c);if(a.user.removeCreditCard(e),l(),p!==c)return{status:"success"};const g=ga(v);if(g)a.session.selectPaymentMethod({id:g.id,lastUsedAt:g.lastUsedAt,paymentMethod:"CREDIT_CARD",paymentAttributes:g}),this.clearShopPayPaymentLines();else{const b=this.paymentMethods.value.find(({method:f,isValidForCheckout:A,isDisabled:k,isExpired:D})=>A&&!k&&!D&&En(f))?.method;if(b){const f=st(b,a.user.paymentMethods.value);f&&this.#e(f)}else a.session.clearPaymentMethod(),this.clearShopPayPaymentLines(),a.session.unstable_updateSelectedBillingAddress(a.session.selectedShippingAddress.value)}const M=g?g.billingAddress.address:a.session.selectedBillingAddress.value?.address;return await r({billingAddress:M??o.value,fallbackPhoneNumber:d}),{status:"success"}}recordPaymentMethodSelected(e){const{observability:s,userEvents:a,source:n,checkout:r,shop:o}=this.deps,d=e.paymentMethod.toLowerCase(),{paymentMethodName:i,paymentBrands:l}=Nn(e,this.availablePaymentMethods.value);s.counter({name:"payment_method_selected",value:1,attributes:{payment_method_type:d,payment_method_name:i,payment_brands:l,location:"shop_pay_payment_selector",is_mobile:Pa()}}),a.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...as(n,r,o),action:"payment_method_selected",paymentMethodName:i}})}async handleNewCardResponse(e,s,a){const{shopPay:n,markShopCashStatesStale:r}=this.deps;
2if(e.status==="success"&&e.creditCard){if(s&&e.creditCard.funding!=="debit")return await this.deleteCreditCardById({id:e.creditCard.id,uuid:e.creditCard.uuid}),{status:"failed",errors:[{field:["",ps.DebitOnly],message:""}]};await this.refreshPaymentMethodsFromBuyerDetails()||n.user.addCreditCard(e.creditCard),a?await this.selectCreditCardAndSetPaymentLine({id:e.creditCard.id}):this.selectCreditCardAndSetPaymentLine({id:e.creditCard.id}).catch(d=>{this.deps.observability.error(d)}),r()}return e}async refreshPaymentMethodsFromBuyerDetails(){const{shopPay:e,refreshBuyerDetails:s,paymentRequiredMethod:a,observability:n}=this.deps;try{const r=await s();return r.status!=="success"?!1:(e.updatePaymentMethodsFromBuyerDetails(r,{negotiatedPaymentMethods:this.availablePaymentMethods.value,paymentRequiredMethod:a}),!0)}catch(r){return n.error(r instanceof Error?r:new Dn("Failed to refresh Shop Pay buyer details")),!1}}async selectCreditCardAndSetPaymentLine({id:e}){const s=jt(this.deps.proposedPaymentLines.value)!==void 0,a=this.selectCreditCard({id:e});if(s)return a;const{shopPay:n}=this.deps,r=n.session.selectedPaymentMethod.value;r&&z(r)&&r.paymentAttributes.id===e&&We(r,n.user.paymentMethods.value,ce(r,this.availablePaymentMethods.value))&&this.#e(r),await a}#e(e,s){const{shopPay:a,setPaymentLine:n,observability:r}=this.deps;ws(()=>{a.session.selectPaymentMethod(e);const o=_a({paymentMethod:e,negotiatedPaymentMethods:this.availablePaymentMethods.value,observability:r});o!==void 0&&(s?n(o,void 0,s):n(o))})}clearShopPayPaymentLines(){const{proposedPaymentLines:e}=this.deps;e.value=e.value.filter(s=>!ns([s],"SHOP_PAY"))}}function Bn(){const t=Fn(),{newCardSignal:e,hasLoadedSignal:s}=$e(),a=e.value,n=s.value,{value:r}=Y().paymentLines,o=r?.lines?.find(d=>d.method.type==="direct");return t.value&&!n&&o&&(s.value=!0,!a&&o.method.paymentMethodIdentifier&&(e.value=o.method)),e}function Fn(){const t=N().checkout.configuration.layout.isOnePage.value,{paymentMethods:e}=Y();return B(()=>t?!!rs(e.value).length:!1)}const Un={id:"3880e4a8c616318ac48c829cc40108d16984c1d3172697b99437ce6c20b93d90",type:"mutation",name:"CreditCardCreate",source:"mutation CreditCardCreate($billingAddress:AddressInput!,$origin:String!,$sessionId:ID!,$nickname:String,$checkoutContext:CheckoutContextInput!){credit
2CardCreate(billingAddress:$billingAddress origin:$origin sessionId:$sessionId nickname:$nickname checkoutContext:$checkoutContext){creditCard{...CreditCardFragment __typename}threeDSecureAuthenticationRequest{redirectUrl verificationId __typename}userErrors{field message __typename}__typename}}fragment CreditCardFragment on CreditCard{bank brand expired expiring expiryMonth expiryYear funding id uuid lastDigits lastUsedAt name nickname preferred supportsInstallmentsInterestLoan supportsInstallmentsSplitPayLoan installmentsInterestLoanNotSupportedReason installmentsSplitPayLoanNotSupportedReason verified billingAddressValid billingAddress{addressLineComponents{additionalInformation district streetName streetNumber subdistrict __typename}fields{key value __typename}__typename}__typename}"};function Vn(){const{checkout:{address:{extendedAddressMode:t}},graphql:{shopPayGraphql:e},source:s}=N(),a=ve({source:s});return S(async(n,r,o,d,i=a)=>{const{data:l,error:c}=await e.mutate(Un,{variables:{billingAddress:mt(n,t),origin:i,sessionId:r,nickname:d,checkoutContext:o}});if(c||l==null||l.creditCardCreate==null)return{status:"failed"};const{creditCardCreate:u}=l;return is(u.userErrors)?{status:"blocked_by_autopay"}:u.userErrors.length>0?{status:"failed",errors:u.userErrors}:u.threeDSecureAuthenticationRequest?{status:"requires_redirect",threeDSecureAuthenticationRequest:u.threeDSecureAuthenticationRequest}:{status:"success",creditCard:u.creditCard?ht(u.creditCard):void 0}},[a,t,e])}const On={id:"76ca67a0ff58d1f46e17614ed9f8bb5a075b761270a53c607c2dea3f863acf40",type:"mutation",name:"CreditCardCompleteVerificationAndVault",source:"mutation CreditCardCompleteVerificationAndVault($verificationId:ID!,$billingAddress:AddressInput!,$origin:String,$nickname:String){creditCardCompleteVerificationAndVault(verificationId:$verificationId billingAddress:$billingAddress origin:$origin nickname:$nickname){creditCard{...CreditCardFragment __typename}userErrors{field message __typename}__typename}}fragment CreditCardFragment on CreditCard{bank brand expired expiring expiryMonth expiryYear funding id uuid lastDigits lastUsedAt name nickname preferred supportsInstallmentsInterestLoan supportsInstallmentsSplitPayLoan installmentsInterestLoanNotSupportedReason installmentsSplitPayLoanNotSupportedReason verified billingAddressValid billingAddress{addressLineComponents{additionalInformation district streetName streetNumber subdistrict __typename}fields{key value __typename}__typename}__typename}"};function $n(){const{checkout:{address:{extendedAddressMode:t}},graphql:{shopPayGraphql:e},source:s}=N(),a=ve({source:s});return S(async(n,r,o,d=a)=>{const{data:i,error:l}=await e.mutate(On,{variables:{verificationId:r,billingAddress:mt(n,t),origin:d,nickname:o}});if(l||i==null||i.creditCardCompleteVerificationAndVault==null)return{status:"failed"};const{creditCardCompleteVerificationAndVault:c}=i;return is(c.userErrors)?{status:"blocked_by_autopay"}:c.userErrors.length>0?{status:"failed",errors:c.userErrors}:{status:"success",creditCard:c.creditCard?ht(c.creditCard):void 0}},[a,t,e])}const Kn={id:"d60ca8058fb85d0d4e3d3585e353d4317aa417ae9568973bb43da35ca94acce7",type:"mutation",name:"CreditCardDelete",source:"mutation CreditCardDelete($id:ID!,$origin:String!,$uuid:String!,$checkoutContext:CheckoutContextInput!){credit
2CardDelete(id:$id uuid:$uuid origin:$origin checkoutContext:$checkoutContext){userErrors{field message __typename}__typename}}"};function Gn(){const{graphql:{shopPayGraphql:t},source:e}=N(),s=ve({source:e});return S(async(a,n,r,o=s)=>{const{data:d,error:i}=await t.mutate(Kn,{variables:{id:a,uuid:n,origin:o,checkoutContext:r}});if(i||d==null||d.creditCardDelete==null)return{status:"failed"};const{creditCardDelete:l}=d;return l.userErrors.length>0?{status:"failed",errors:l.userErrors}:{status:"success"}},[s,t])}function Yn(t,{checkoutVersion:e,checkoutIdentifier:s,shopifyDomain:a,shopId:n,redirectSource:r},{cache:o=!0}={}){return t.staticQuery(dn,{variables:{checkoutContextInput:{checkoutVersion:e,checkoutIdentifier:s,shopifyDomain:a,shopId:n},shopifyDomain:a,redirectSource:r??void 0},cache:o})}function qn(){const{graphql:{shopPayGraphql:t},source:e,shop:{myshopifyDomain:s,id:a},shopPay:{config:n}}=N(),{checkoutSessionIdentifier:r}=e,o=ve({source:e}),{redirectSource:d}=n;return S(async()=>{const{data:i,error:l}=await Yn(t,{checkoutVersion:o,checkoutIdentifier:r??"unknown",shopifyDomain:s,shopId:Be(a),redirectSource:d},{cache:!1});return l||i==null||i.checkoutSession==null||i.checkoutSession.user==null?{status:"failed"}:ln(i)},[r,o,d,a,s,t])}const zn={id:"0e9fd59cad63a6cd040eec702de445aa95c0d9f613f732e94dce615a476c9d59",type:"mutation",name:"CreditCardUpdate",source:"mutation CreditCardUpdate($billingAddress:AddressInput!,$id:ID!,$uuid:String!,$origin:String!,$nickname:String,$checkoutContext:CheckoutContextInput!){credit
2CardUpdate(billingAddress:$billingAddress id:$id uuid:$uuid origin:$origin nickname:$nickname checkoutContext:$checkoutContext){userErrors{field message __typename}creditCard{...CreditCardFragment __typename}__typename}}fragment CreditCardFragment on CreditCard{bank brand expired expiring expiryMonth expiryYear funding id uuid lastDigits lastUsedAt name nickname preferred supportsInstallmentsInterestLoan supportsInstallmentsSplitPayLoan installmentsInterestLoanNotSupportedReason installmentsSplitPayLoanNotSupportedReason verified billingAddressValid billingAddress{addressLineComponents{additionalInformation district streetName streetNumber subdistrict __typename}fields{key value __typename}__typename}__typename}"};function Hn(){const{checkout:{address:{extendedAddressMode:t}},graphql:{shopPayGraphql:e},source:s}=N(),a=ve({source:s});return S(async(n,r,o,d,i,l=a)=>{const{data:c,error:u}=await e.mutate(zn,{variables:{id:r,uuid:o,billingAddress:mt(n,t),origin:l,nickname:i,checkoutContext:d}});if(u||!c?.creditCardUpdate)return{status:"failed"};const{creditCardUpdate:p}=c;return p.userErrors.length>0?{status:"failed",errors:p.userErrors}:{status:"success",creditCard:p.creditCard?ht(p.creditCard):void 0}},[a,t,e])}function Wn(t){const{geolocation:e}=Os(),{shopPay:s,checkout:a}=N(),n=s.user.phoneNumber.value,r=s.user.addresses.value,o=a.configuration.addressSettings.nonBillingAddressSettings.value,d=r[0]?.address,i=o.defaultShippingDetails.country?.code??e.country.code;return J(()=>{const l={firstName:d?.firstName,lastName:d?.lastName,phone:n,countryCode:d?.countryCode||i,zoneCode:d?.zoneCode};return ka(l,{extendedAddressMode:a.address.extendedAddressMode})},[a.address.extendedAddressMode,t,d,i,n])}const Qn={id:"563e8a86083a6c9ad5bd44d3a4db471e3a9919052512d2745d267074d97420fd",type:"mutation",name:"DeleteVaultedCreditCard",source:""},jn={id:"d1f468f7d6684d3133e47cef5cf1ef67ccd2bd916b53203708d85ac3175f1bd0",type:"mutation",name:"UpdateCustomerCreditCard",source:""};class Xn extends Error{constructor(e){super("Failed to update customer credit card payment method",e),this.name="UpdateCustomerCreditCardPaymentMethodError"}}class Zn extends Error{constructor(e){super("Failed to delete customer credit card payment method",e),this.name="DeleteCustomerCreditCardPaymentMethodError"}}async function Jn({graphql:t,address:e,extendedAddressMode:s,defaultPaymentMethod:a,token:n,genericError:r}){if(!n)return{token:void 0};try{const{data:o,error:d}=await t.mutate(jn,{variables:{customerCreditCardModificationInput:{token:n,defaultPaymentMethod:a,billingAddress:{streetAddress:Ea(e,{extendedAddressMode:s})}}}});if(!o?.modifyCustomerCreditCardPaymentMethod||d)throw new Xn({cause:d});const{result:i,errors:l}=o.modifyCustomerCreditCardPaymentMethod;return l.length||!i?{token:void 0,error:l[0]?.localizedMessage||r}:{token:i.token}}catch{return{token:void 0,error:r}}}async function er({graphql:t,token:e,genericError:s}){if(!e)return{token:void 0};try{const{data:a,error:n}=await t.mutate(Qn,{variables:{token:e}});if(!a?.deleteCustomerCreditCardPaymentMethod||n)throw new Zn({cause:n});const{result:r,errors:o}=a.deleteCustomerCreditCardPaymentMethod;return o.length||!r?{token:void 0,error:o[0]?.localizedMessage||s}:{token:r.token}}catch{return{token:void 0,error:s}}}function tr({userEvents:t,shopId:e,checkoutSessionIdentifier:s,card:a}){t.monorailEvent({schemaId:"checkout_vaulted_payment_method_selected/1.0",payload:{shopId:parseInt(Be(e),10),checkoutSessionIdentifier:s||"",paymentMethodId:parseInt(Be(a.id),10),paymentInstrumentAccessorId:-1}})}class sr extends Gt{constructor({managerName:e,methodName:s,identity:a,deployStage:n,isLocalDevelopment:r}){super(`${e}.${s} was called unexpectedly`,{groupingHash:`PaymentMethodManagerUnexpectedMethodCall::${e}::${s}`,metadata:{paymentMethodManager:{managerName:e,methodName:s,identity:a,deployStage:n,isLocalDevelopment:r}}}),this.name="UnexpectedPaymentMethodManagerMethodCallError"}}function fs({observability:t,managerName:e,methodName:s,identity:a,deployStage:n,isLocalDevelopment:r}
2){if(r||n!=="production"&&n!=="canary")return;const o=new sr({managerName:e,methodName:s,identity:a,deployStage:n,isLocalDevelopment:r});t.error(o,{severity:"warning"})}const Nt={status:"failed"};class xe{constructor(e){this.disabledCardMethodsForInstallments=L([]),this.isEveryCardDisabled=L(!1),this.canSetCreditCardNickname=L(!1),this.addCreditCardStrategy="direct-session-payment-line",this.deps=e,this.usesCustomerAccountSelectionRule=e.identity==="customerAccount",this.newCard=e.newCard??L(void 0);const{proposal:s}=e,{proposed:a,negotiated:n}=s,{paymentMethods:r}=n.fields,o=n.fields.paymentMethodHistory??L([]);this.availablePaymentMethods=I(()=>r.value??[]),this.promotedMethods=e.paymentMethodPromotions.promoted,this.customerCreditCards=I(()=>Ia(this.availablePaymentMethods.value)),this.selectableCustomerCreditCards=I(()=>rs(this.availablePaymentMethods.value)),this.selectablePaypalBillingAgreements=I(()=>(e.displayablePaymentMethods?.value??this.availablePaymentMethods.value).filter(i=>i.type===Ce.PayPal)),this.selectableCustomerBanks=I(()=>this.availablePaymentMethods.value.filter(i=>i.type==="bank"&&i.availableInstruments.length>0)),this.nonCardKnownPaymentMethods=I(()=>Na({paymentMethodHistory:o.value??[],availablePaymentMethods:e.displayablePaymentMethods?.value??this.availablePaymentMethods.value})),this.availableUserStoredPaymentMethods=I(()=>[...Fe([Qe({card:this.newCard.value,billingAddress:a.billingAddress.value})]),...this.selectableCustomerCreditCards.value.map(i=>At(i,{cvvVerificationEnabled:this.deps.storeVaultGuestCvvVerificationEnabled})),...this.selectablePaypalBillingAgreements.value.map(La),...or(this.selectableCustomerBanks.value.map(Da),this.nonCardKnownPaymentMethods.value,this.promotedMethods.value)]),this.autoselectTarget=I(()=>{const i=this.selectableCustomerCreditCards.value.find(h=>h.defaultPaymentMethod),l=i?this.availableUserStoredPaymentMethods.value.find(h=>h.id===i.token):void 0,c=dr(this.availableUserStoredPaymentMethods.value);if(this.usesCustomerAccountSelectionRule){const h=!c||G(c);if(this.deps.storeVaultEnabled&&h&&l)return l}else if(i)return l;if(c)return c;const u=this.selectableCustomerCreditCards.value[0];if(u)return this.availableUserStoredPaymentMethods.value.find(h=>h.id===u.token);const p=this.availableUserStoredPaymentMethods.value.find(h=>!G(h)&&!tt(h));return p||this.availableUserStoredPaymentMethods.value.find(tt)}),this.proposedSelectedPaymentMethod=I(()=>ar(a.paymentLines.value,this.availableUserStoredPaymentMethods.value,this.availablePaymentMethods.value,Qe({card:this.newCard.value,billingAddress:a.billingAddress.value}))),this.selectedPaymentMethod=I(()=>this.proposedSelectedPaymentMethod.value??this.autoselectTarget.value),this.paymentMethods=I(()=>{const i=Qe({card:this.newCard.value,billingAddress:a.billingAddress.value}),l=[...Fe([i]),...this.customerCreditCards.value.map(u=>At(u,{cvvVerificationEnabled:this.deps.storeVaultGuestCvvVerificationEnabled}))].map(u=>({method:u,isValidForCheckout:!0,isExpired:u.paymentAttributes.expired,isDisabled:!1,...cr({identity:this.deps.identity,storeVaultEnabled:this.deps.storeVaultEnabled,card:u})})),c=this.availableUserStoredPaymentMethods.value.filter(u=>!G(u)).map(u=>({method:u,isValidForCheckout:!0,isExpired:!1,isDisabled:!1,canEdit:!1,canDelete:!1,canSetDefault:!1,isDefault:!1}));return lr({cardItems:l,nonCardItems:c,autoselectTarget:this.usesCustomerAccountSelectionRule?this.autoselectTarget.value:void 0})}),this.selectedPaymentMethodItem=I(()=>{const i=this.selectedPaymentMethod.value;if(i)return this.paymentMethods.value.find(({method:l})=>l.id===i.id&&l.paymentMethod===i.paymentMethod)}),this.selectedCreditCard=I(()=>{const i=this.selectedPaymentMethod.value;return G(i)?i.paymentAttributes:void 0}),this.cardPaymentMethods=I(()=>this.paymentMethods.value.filter(i=>G(i.method))),this.activeOrExpiredCardMethods=this.cardPaymentMethods,this.isEveryCardExpired=I(()=>{const i=this.cardPaymentMethods.value;return i.length>0&&i.every(l=>l.isExpired)});const d=I(()=>{const i=we(this.availablePaymentMethods.value);if(!ct(i))return!1;const l=this.selectedCreditCard.value;return l?a.paymentLines.value.some(c=>
2l.id===H?c.method.type==="direct":c.method.type===Ce.CreditCard&&c.method.token===l.id):!1});this.msi={binResolution:"client",selectedCardBin:I(()=>{const i=this.selectedCreditCard.value;if(i)return i.id===H?this.newCard.value?.creditCardFirstDigits:this.selectableCustomerCreditCards.value.find(l=>l.token===i.id)?.firstDigits}),clearInstallments:gt,expandedVisible:d,collapsedVisible:d}}async promoteSelectedPaymentMethod(e){const s=wa(e,null);return s?(this.deps.paymentMethodPromotions.promote(s),this.selectPaymentMethod(s,"buyer")):{status:"handled",effects:{...re,selectByBuyerKey:ue(e)}}}canShowAsGuestCheckoutMethod(){return!1}async selectPaymentMethod(e,s="programmatic"){if(!e)return{status:"not-handled"};if(!G(e)){const n=ce(e,this.availablePaymentMethods.value);if(!n)return{status:"not-handled"};const r=ue(n);return s==="buyer"?{status:"handled",effects:{...re,selectByBuyerKey:r}}:(this.deps.setPaymentLine(r),{status:"handled",effects:re})}if(s==="buyer")return this.selectCreditCardByBuyer({paymentMethod:e});if(e.id===H)return this.deps.setPaymentLine(H),{status:"handled",effects:re};const a=this.selectableCustomerCreditCards.value.find(n=>n.token===e.paymentAttributes.id);return a?(this.deps.setPaymentLine(Le(a)),{status:"handled",effects:re}):{status:"not-handled"}}async deleteCreditCard({id:e}){if(e===H){const{proposed:o}=this.deps.proposal;if(!this.newCard.value)return{status:"failed"};this.newCard.value=void 0,o.acceptPaymentVaulting.value=!1;const d=this.selectableCustomerCreditCards.value[0];if(d)this.deps.setPaymentLine(Le(d));else{const i=this.autoselectTarget.value,l=i?ce(i,this.availablePaymentMethods.value):void 0;l?this.deps.setPaymentLine(ue(l)):o.paymentLines.value=o.paymentLines.value.filter(c=>c.method.type!=="direct")}return{status:"success",shouldResetSuggestedBillingAddress:!!d,shouldResetBillingAddressToShipping:this.deps.identity!=="businessCustomer"}}const s=this.selectedPaymentMethod.value,a=G(s)&&s.id===e,n=this.selectableCustomerCreditCards.value.find(o=>o.token!==e),r=await er({graphql:this.deps.graphql,token:e,genericError:this.deps.i18n.translate("customer_payment_methods.delete_customer_mandate.generic_error")});return r.token?(a&&n&&this.deps.setPaymentLine(Le(n)),{status:"success",shouldNegotiatePaymentMethods:!0}):{status:"failed",bannerError:r.error}}async updateCreditCard({id:e,billingAddress:s,defaultPaymentMethod:a=!1}){const n=await Jn({graphql:this.deps.graphql,token:e,address:s,extendedAddressMode:this.deps.extendedAddressMode,defaultPaymentMethod:a,genericError:this.deps.i18n.translate("shipping.address_form.generic_error")});return n.token?{status:"success",shouldNegotiatePaymentMethods:!0}:{status:"failed",bannerError:n.error}}async addCreditCard(){return this.reportUnexpectedUse("addCreditCard"),Nt}async completeCreditCardVerificationAndVault(){return this.reportUnexpectedUse("completeCreditCardVerificationAndVault"),Nt}dispose(){}async selectCreditCardByBuyer({paymentMethod:e}){let s,a,n;if(e.id===H){const r=this.newCard.value;if(!r)return{status:"not-handled"};s=H,a=r,n=r.creditCardFirstDigits}else{const r=this.selectableCustomerCreditCards.value.find(o=>o.token===e.paymentAttributes.id);if(!r)return{status:"not-handled"};s=Le(r),n=r.firstDigits,tr({userEvents:this.deps.userEvents,shopId:this.deps.shopI
2d,checkoutSessionIdentifier:this.deps.checkoutSessionIdentifier,card:r})}return this.deps.isMsiAvailable&&(this.deps.proposal.proposed.paymentLines.value=gt(this.deps.proposal.proposed.paymentLines.value)),{status:"handled",effects:{...re,selectByBuyerKey:s,...a?{selectByBuyerPaymentMethod:a}:{},updateSelectedCardBin:!0,selectedCardFirstDigits:n,preserveExistingBinPrefix:e.id===H,claimMsiBin:this.deps.isMsiAvailable,claimedMsiBin:this.deps.isMsiAvailable?n:void 0,shouldNegotiate:!0}}}reportUnexpectedUse(e){fs({...this.deps,managerName:"CustomerPaymentMethodManager",methodName:e})}}function ar(t,e,s,a){const n=t.some(r=>r.method.type!=="deferred"&&r.method.type!=="giftCard"&&r.method.type!=="redeemable");for(const r of t){if(r.method.type==="direct"&&a)return a;if(r.method.type==="deferred"){if(n)continue;const d=e.find(tt);if(d)return d;continue}if(nr(r)){const d=e.filter(G).find(i=>i.id===r.method.token);if(d)return d;continue}if(rr(r)){const d=e.find(i=>i.paymentMethod==="PAYPAL"&&i.variant==="billing_agreement"&&i.vaultedToken===r.method.token);if(d)return d;continue}const o=ir(r,e,s);if(o)return o}}function Qe({card:t,billingAddress:e}
2){if(!(!t?.brand||!t.creditCardLastFourDigits))return{id:H,paymentMethod:"CREDIT_CARD",paymentAttributes:{id:H,brand:t.brand,expired:!1,expiryMonth:0,expiryYear:0,lastDigits:t.creditCardLastFourDigits,name:t.cardholderName,billingAddress:{address:e??{}}},lastUsedAt:null}}function Fe(t){return t.filter(e=>e!==void 0)}function nr(t){return t.method.type===Ce.CreditCard}function rr(t){return t.method.type===Ce.PayPal}function ir(t,e,s){const a=ue(t.method);return e.find(n=>{if(G(n))return!1;const r=ce(n,s);return r?a===ue(r):!1})}function or(...t){const e=[],s=new Set;for(const a of t)for(const n of a){const r=`${n.paymentMethod}:${n.id}`;s.has(r)||(s.add(r),e.push(n))}return e}function dr(t){return t.reduce((e,s)=>s.lastUsedAt?e?.lastUsedAt?s.lastUsedAt>e.lastUsedAt?s:e:s:e,void 0)}function lr({cardItems:t,nonCardItems:e,autoselectTarget:s}){const a=t.find(({method:h})=>h.id===H),r=[...t.filter(({method:h})=>h.id!==H)].sort((h,v)=>fe(h.method,v.method)),o=[...e].sort((h,v)=>fe(h.method,v.method)),d=r.filter(Lt),i=o.filter(Lt),l=d.find(({method:h})=>G(h)&&h.paymentAttributes.defaultPaymentMethod),c=[d[0],i[0]].filter(h=>h!==void 0).sort((h,v)=>fe(h.method,v.method))[0],p=(s?[...d,...i].find(({method:h})=>h.id===s.id&&h.paymentMethod===s.paymentMethod):void 0)??l??c;return p?[...Fe([a]),p,...r.filter(h=>h!==p),...o.filter(h=>h!==p)]:[...Fe([a]),...r,...o]}function Lt(t){return t.isValidForCheckout&&!t.isExpired&&!t.isDisabled}function cr({identity:t,storeVaultEnabled:e,card:s}){if(s.id===H)return ur;if(t==="businessCustomer")return je;const{paymentAttributes:a}=s;return e?a.expired?a.deletable?{canEdit:!1,canDelete:!0,canSetDefault:!1,isDefault:!!a.defaultPaymentMethod}:je:{canEdit:!0,canDelete:!!a.deletable,canSetDefault:!0,isDefault:!!a.defaultPaymentMethod}:je}const je={canEdit:!1,canDelete:!1,canSetDefault:!1,isDefault:!1},ur={canEdit:!1,canDelete:!0,canSetDefault:!1,isDefault:!1},Te={status:"failed"};class mr{constructor(e){this.availablePaymentMethods=L([]),this.availableUserStoredPaymentMethods=L([]),this.paymentMethods=L([]),this.selectedPaymentMethod=L(void 0),this.selectedPaymentMethodItem=L(void 0),this.selectedCreditCard=L(void 0),this.activeOrExpiredCardMethods=L([]),this.disabledCardMethodsForInstallments=L([]),this.isEveryCardDisabled=L(!1),this.isEveryCardExpired=L(!1),this.cardPaymentMethods=L([]),this.promotedMethods=L([]),this.msi={binResolution:"client",selectedCardBin:L(void 0),clearInstallments:s=>s,expandedVisible:L(!1),collapsedVisible:L(!1)},this.newCard=L(void 0),this.canSetCreditCardNickname=L(!1),this.addCreditCardStrategy="vault-and-select",this.unexpectedUseOptions=e}canShowAsGuestCheckoutMethod(){return!1}async selectPaymentMethod(){return this.reportUnexpectedUse("selectPaymentMethod"),{status:"not-handled"}}async promoteSelectedPaymentMethod(){return this.reportUnexpectedUse("promoteSelectedPaymentMethod"),{status:"not-handled"}}async deleteCreditCard(){return this.reportUnexpectedUse("deleteCreditCard"),Te}async updateCreditCard(){return this.reportUnexpectedUse("updateCreditCard"),Te}async addCreditCard(){return this.reportUnexpectedUse("addCreditCard"),Te}async completeCreditCardVerificationAndVault(){return this.reportUnexpectedUse("completeCreditCardVerificationAndVault"),Te}dispose(){}reportUnexpectedUse(e){fs({...this.unexpectedUseOptions,managerName:"FallbackPaymentMethodManager",methodName:e})}}function Ai({enableAutoSelect:t=!0}={}){const{source:e,environment:s,checkout:a,shop:n,i18n:r,observability:o,userEvents:d,shopPay:i,graphql:{coreGraphql:l,shopPayGraphql:c}}=N(),u=a.identity.current.value,p=n.hasFlagEnabled(xa),h=s.devMode!=null,v=Vn(),g=$n(),M=Gn(),b=qn(),f=Hn(),A=ve({source:e}),k=Wn(),D=ee(),{paymentLines:E}=D,P=Bn(),{buyerHasActedSignal:x,newCardSignal:V}=$e(),R=dt(ms),F=i.user.phoneNumber.value,T=Y(),_=sn(),q=i.session.isInstallmentsSelected.value,se=an({isApplePayAvailable:_.value}),$=Ta(),{creditCardDisabled:W}=cn(),ae=on(),{updateCheckoutAddress:X}=nn(),[,me]=rn({allowPreselect:!1}),he=we(T.paymentMethods.value??[]),be=ct(he),ge=os(),{eligibilityByCardId:Pe}=Ra(mn),_e=S(()=>{R&&(R.cashbackState.stale.value=!0)},[R]),Se=J(()=>({checkoutIdentifier:e.checkoutSessionIdentifier??"",checkoutVersion:A,shopId:Be(n.id),shopifyDomain:n.myshopifyDomain}),[e.checkoutSessionIdentifier,n.id,n.myshopifyDomain,A]),K=J(()=>{const pe=()=>new Rn({shopPay:i,negotiatedPaymentMethods:T.paymentMethods,installmentsPaymentMethodSelected:q,isApplePayAvailable:_.value,filteredNegotiatedPaymentMethods:se.value,isCreditCardDisabled:W,setPaymentLine:me,updateCheckoutAddress:X,shippingRequired:a.isShippingRequired,i18n:r,observability:o,userEvents:d,source:e,checkout:a,shop:n,createCreditCard:v,deleteCreditCard:M,updateCreditCard:f,completeCreditCardVerification:g,refreshBuyerDetails:b,markShopCashStatesStale:_e,shopPayGraphql:c,emptyAddress:k,proposedPaymentLines:E,checkoutContext:Se,fallbackPhoneNumber:F,paymentRequiredMethod:ae.value,msiEligibilityByCardId:Pe,hasSellingPlan:ge});return u==="shopPay"?pe():u==="customerAccount"||u==="businessCustomer"?new xe({proposal:a.proposal,newCard:P,displayablePaymentMethods:$,paymentMethodPromotions:a.paymentMethodPromotions,setPaymentLine:me,isMsiAvailable:be,shopId:n.id,checkoutSessionIdentifier:e.checkoutSessionIdentifier,storeVaultEnabled:n.storeVaultEnabled,storeVaultGuestCvvVerificationEnabled:n.storeVaultGuestCvvVerificationEnabled,graphql:l,extendedAddressMode:a.address.extendedAddressMode,i18n:r,observability:o,userEvents:d,identity:u,deployStage:s.deployStage,isLocalDevelopment:h}):new mr({observability:o,identity:u,deployStage:s.deployStage,isLocalDevelopment:h})},[u,s.deployStage,h,i,T.paymentMethods,q,_.value,se.value,$,W,be,me,X,a,o,d,e,n,r,l,c,v,M,b,f,g,_e,k,E,P,
2Se,F,ae.value,Pe,ge]);U(()=>()=>K.dispose(),[K]);const y=K.selectedPaymentMethod.value,C=K.paymentMethods.value,w=K.availablePaymentMethods.value,O=K.availableUserStoredPaymentMethods.value,Q=E.value.some(pe=>pe.method.type==="direct");U(()=>{if(!t||u!=="shopPay"||y&&In({selected:y,paymentMethods:C,availablePaymentMethods:w})||Q)return;const pe=C.filter(({isValidForCheckout:le})=>le).sort((le,qe)=>fe(le.method,qe.method)).map(({method:le})=>le),Me=wn(pe);Me&&G(Me)&&Me.paymentAttributes.expired&&d.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.1",payload:{...as(e,a,n),action:"final_payment_method_expired_after_merchant_filter"}});const Ct=Me?st(Me,i.user.paymentMethods.value):void 0;if(Ct)i.session.selectPaymentMethod(Ct);else{const le=p?"unavailable":"explicit",qe=i.session.clearPaymentMethod(le),vt=i.user.creditCards.peek().length;qe&&vt>0&&o.log("shop_pay_payment_method_auto_cleared","[usePaymentMethodManager] No listed payment method was valid for checkout, so the Shop Pay selection was cleared",{checkout_session_identifier:e.checkoutSessionIdentifier,source_type:e.type,clear_reason:le,held_card_count:vt,listed_method_count:C.length,valid_for_checkout_count:pe.length,negotiated_direct_present:!!he})}},[t,w,O,a,u,he,o,d,C,p,y,n,i.session,i.user.creditCards,i.user.paymentMethods.value,e,Q]);const te=x.value,Ie=!!V.value,oe=K instanceof xe?K.autoselectTarget.value:void 0,Ne=K instanceof xe?K.proposedSelectedPaymentMethod.value:void 0,yt=E.value[0],Ye=yt?.method.type,ft=un(yt);return U(()=>{t&&(u!=="customerAccount"&&u!=="businessCustomer"||te||K instanceof xe&&oe&&(Ie||ft||Ne&&Ne.paymentMethod===oe.paymentMethod&&Ne.id===oe.id||(Ye&&o.log("payment_method_manager_programmatic_selection_replaced_primary_line","Programmatic payment method selection replaced the proposed primary payment line",{replacedPaymentLineMethodType:Ye,replacingPaymentMethodType:oe.paymentMethod}),K.selectPaymentMethod(oe,"programmatic").catch(()=>{}))))},[t,u,te,Ie,K,oe,Ne,ft,Ye,o]),K}function ki(){const{shop:t,checkout:e,observability:s}=N(),a=e.wallets.activeSession.value,n=e.latestReceipt.value,{persistedPayPalSignal:r}=ss(),o=e.identity.current.value==="payPal",d=n?.id,i=$s().value,l=i!==void 0,c=Ke(),u=r.value,{negotiate:p}=Oe(),h=Ks(),v=Ht(new Set(Ba))?.hasError&&d!==u?.receiptIdForClearedToken,g=Gs("PAYPAL_EXPRESS").value?.merchantId?.trim(),M=i?.method.walletContent?.merchantId?.trim(),f=t.hasFlagEnabled(Fa)&&g&&M&&M!==g,A=u?.billingAgreementStatus&&Ua({checkout:e})&&u.billingAgreementStatus==="NOTREQUESTED"&&!i?.method.walletContent?.isVaultWithPurchaseOrder,k=i?.method.walletContent?.isVaultWithPurchaseOrder===!0&&c.value?.amount===0;U(()=>{function D(){const P={...r.value,receiptIdForClearedToken:v?d:void 0,newTokenRequiredDueToError:!0,billingAgreementStatus:void 0};r.value=P}function E(){let P;v?P="SubmitForCompletion Error":f?P="Gateway Mismatch":k?P="Zero Payment Due":P="Subscription Added",s.counter({name:"paypal_token_cleared",value:1,attributes:{clearReason:P}}),s.log("paypal_token_cleared","Clearing PayPal token due to error",{clearReason:P})}l&&((v||f||A||k)&&(E(),D()),(async()=>(k||v&&!o&&!a)&&(h(),await p({silenceViolations:["non-stock"]})))())},[v,l,f,d,s,r,A,k,o,h,p,a])}function hr(t){const e=Y().paymentMethods;return B(()=>{const a=!!t.value?.balance?.amount,n=!!e.value?.find(r=>r.type==="redeemable"&&r.redemptionSource==="STORE_CREDIT");return!!(a&&n)})}var ie=(t=>(t.Init="init",t.Loading="loading",t.Success="success",t.Error="error",t.Stale="stale",t))(ie||{});function Cs(t,e){return t.filter(s=>!vs(s,e))}function pr(t,e){return t.some(s=>vs(s,e))}function yr({firstOrderTotal:t,storeCreditAccount:e}){if(!t||!e||t.currencyCode!==e.balance.currencyCode)return;const s=e.balance.amount-t.amount;if(!(s<=0))return{amount:s,currencyCode:e.balance.currencyCode}}function vs(t,e){return pt(t)&&t.method.redemptionContent&&"storeCreditAccountId"in t.method.redemptionContent&&t.method.redemptionContent.storeCreditAccountId===e.id}function fr(t){const e=Y().paymentLines;return B(()=>{const s=t.value;return!s||!e.value?.lines?!1:pr(e.value.lines,s)})}function Cr(){const{shop:{currencyCode:t}}=N(),s=Y().buyerIdentity;return B(()=>
2{const a=s.value,n=a?.presentmentCurrency||t;return(a?.customerProfile?.__typename==="CustomerProfile"||a?.customerProfile?.__typename==="BusinessCustomerProfile"?a.customerProfile.storeCreditAccounts:[]).find(o=>o.balance.currencyCode===n)})}function Ei(){const t=Y().paymentLines;return B(()=>t.value?.lines.filter(e=>pt(e))||[])}const vr=new Set(["Image","Banner","s-image","s-banner"]);function br({options:t,paymentMethodExtension:e}){const s=e[0]?.extension;if(!s)return null;const a=s.appId.split("/").pop(),n=a&&!Va.includes(a);return m(Ys,{options:t,customizations:e,transformComponents:n?gr:void 0})}const gr=qs(vr);function Pr(){const t=Y().allViolations,e=B(()=>(t.value??[]).filter(a=>!!(zs(a)||Oa(a)))),s=B(()=>{const[a]=e.value;return a?a.localizedMessage||a.nonLocalizedMessage:null});return m(Ue,{when:s,children:a=>m(Xt,{tone:"critical",errorType:Zt.DiscountError,children:a})})}function _r({amount:t,maskedIdentifier:e,remove:s}){const{i18n:a}=N(),n=a.formatCurrency(t.amount,{currency:t.currencyCode,form:"short"}),r=e.slice(-4).toUpperCase(),o=a.translate("payment.gift_card_wrapper.gift_card_label",{identifier:Hs(r)}),d=a.translate("order_summary.gift_card_ending",{last_characters:r||""});return m(Ee,{borderRadius:"base",background:"base",border:"base",blockAlignment:"center",padding:"small-200",children:m(He,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1fr) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",children:[m(He,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-300",alignItems:"center",alignContent:"center",children:[m(us,{type:"gift-card"}),m(Jt,{children:[m(ne,{accessibilityVisibility:"hidden",children:o}),m(ne,{accessibilityVisibility:"exclusive",children:d})]})]}),m(He,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-100",alignItems:"center",alignContent:"center",children:[m(ne,{type:"strong",children:n}),m(es,{onClick:()=>s(),accessibilityLabel:a.translate("general.remove_item",{label:d}),children:m(Ve,{type:"x",size:"small"})})]})]})})}const Dt="gift_card_option";function wi({afterAppliedRedeemablesChange:t,autoSelect:e=!1,showHeading:s=!0}){const{i18n:a}=N(),{paymentMethod:n,paymentLines:r,submit:o,remove:d,removeAll:i}=Ws(),l=Qs("Checkout::GiftCard::Render",n?.uiExtension?[n?.uiExtension]:[]),{value:c}=Ke(),u=c?.amount||0,[p,h]=j([]),[v,g]=j(!1),M=u===0&&r?.length===0,b=async P=>{h(P),P.length===0&&r.length>0&&(await i())?.status==="success"&&t?.()};U(()=>{M?h([]):(r?.length>0||e)&&h([Dt])},[e,r?.length,M]);const f=S(async(P,x)=>{const V=await o(P,x);return V?.status==="success"&&(g(!1),t?.()),V},[t,o]),A=J(()=>({paymentMethodIdentifier:n?.paymentMethodIdentifier??"",submitRedeemablePaymentLine:f}),[n?.paymentMethodIdentifier,f]),k=P=>{const{cost:x,method:V}=P;if(!x||V.redemptionSource!=="CUSTOM")return null;const R=V.redemptionContent?.redemptionAttributes.reduce((F,T)=>`${F},${T.key}:${T.value}`,"");return m(_r,{maskedIdentifier:V.redemptionContent?.maskedIdentifier||"",amount:{amount:x.amount,currencyCode:x.currencyCode},remove:async()=>{(await d(V))?.status==="success"&&t?.()}},R)},D=()=>{if(u===0||!l.length||!n)return null;const P=m(br,{paymentMethodExtension:l,options:A});return!r||r.length===0?P:v?m(Ee,{children:[m(ye,{blockSize:"small-500"}),m(Z,{gap:"base",children:[m(Je,{level:3,children:a.translate("payment.gift_card_wrapper.apply_another_gift_card_label")}),P]})]}):m(Ee,{children:[m(ye,{blockSize:"small-500"}),m(Wt,{textDecoration:"none",onClick:()=>g(!0),children:m(Z,{direction:"inline",alignItems:"center",gap:"small-400",children:[m(Ve,{type:"plus"}),m(ne,{children:a.translate("payment.gift_card_wrapper.apply_another_gift_card_label")})]})})]})},E=!!r?.length||!!l.length&&!!n;return m(js,{id:"3p-gift-card-field",open:E,duration:"slow",children:m(lt,{accessibilityLabel:a.translate("payment.gift_card_wrapper.heading"),children:m(Z,{gap:"base",children:[s&&m(Je,{level:2,children:a.translate("payment.gift_card_wrapper.heading")}),m(hs,{name:"gift_card_option_list",values:p,multiple:!0,onChange:b,variant:"block",children:m(et,{value:Dt,disabled:M,selectedContent:m(Z,{gap:"base",children:[r?.length>0?m(Z,{gap:"small-300",children:r.map(k)}):null,m(Pr,{}),D()]}),children:a.translate("payment.gift_card_wrapper.apply_gift_card_label")})})]})})})}const Ae="StoreCreditRedemptionCheckbox",Xe="StoreCreditSubscriptionRenewalsCheckbox";function Ge(t,e){return pt(t)&&t.method.redemptionContent&&"storeCreditAccountId"in t.method.redemptionContent&&t.method.redemptionContent.storeCreditAccountId===e.id}function Sr(t,e){if(!(t.status!=="success"&&t.status!=="error"))return t.negotiated?.paymentLines?.lines.find(s=>Ge(s,e))?.cost}function Mr({paymentLines:t,storeCreditAccount:e,cost:s}){return t.map(a=>Ge(a,e)?{...a,cost:s}:a)}function xt({amountDueAtCheckout:t,storeCreditAccount:e}){if(bs({amountDueAtCheckout:t,storeCreditAccount:e})&&t!=null)return{amount:Math.min(t.amount,e.balance.amount),currencyCode:t.currencyCode}}function bs({amountDueAtCheckout:t,storeCreditAccount:e}){return t==null||t.currencyCode===e.balance.currencyCode}function Tt({paymentLines:t,storeCreditAccount:e,cost:s}){let a=!1;const n=t.map(r=>{if(!Ge(r,e))return r;if(s==null){if(r.cost==null)return r;const{cost:o,...d}=r;return a=!0,d}return r.cost?.amount===s.amount&&r.cost.currencyCode===s.currencyCode?r:(a=!0,{...r,cost:s})});return a?n:t}function gs(t){const{negotiate:e}=Oe();return S(async()=>new Promise(s=>{e({include:["paymentLines"],silenceViolations:["non-store-credit"],runListenersOnError:!0,force:!0,onComplete(a){t.value=a.status==="success"?ie.Success:ie.Error,s(a)}})}),[e,t])}function Ar(t,e){const s=ee(),a=gs(e);return S(async()=>
2{if(!t)return e.value=ie.Error,Promise.resolve();e.value=ie.Loading;const n=Cs(s.paymentLines.value,t);return s.paymentLines.value=n,a()},[t,e,s.paymentLines,a])}function kr(t,e){const{i18n:s,shop:a}=N(),n=ee(),r=gs(e),o=Y().paymentLines,d=Ke(),i=ds(),l=os(),c=ls(),u=Y().paymentFlexibilityPaymentTermsTemplate,p=$a(a),h=Y().isImmediateAmountReducedForRedeemables,v=S(()=>p&&Ka({hasSellingPlan:l.value,hasFixedSellingPlan:c.value,paymentTermsTemplateType:u.value?.type}),[p,l,c,u]),g=de(!1);return qt(()=>{if(!v())return;const M=d.value??i.value,b=n.paymentLines.value;if(!t||!g.current)return;const f=o.value?.lines.find(k=>Ge(k,t))?.cost;if(h?.value){if(f){const k=Tt({paymentLines:b,storeCreditAccount:t,cost:f});k!==b&&(n.paymentLines.value=k)}return}if(f&&f.amount>0){g.current=!1;return}const A=Tt({paymentLines:b,storeCreditAccount:t,cost:xt({amountDueAtCheckout:M,storeCreditAccount:t})});A!==b&&(n.paymentLines.value=A)}),S(async()=>{if(!t)return e.value=ie.Error,Promise.resolve(null);e.value=ie.Loading;const M=Cs(n.paymentLines.value,t),b=d.value??i.value,f=v(),A=f?xt({amountDueAtCheckout:b,storeCreditAccount:t}):void 0;if(g.current=A!=null,f&&!bs({amountDueAtCheckout:b,storeCreditAccount:t}))return e.value=ie.Error,ts({content:s.translate("store_credit_errors.generic_error")}),Promise.resolve(null);n.paymentLines.value=[...M,{method:{type:"redeemable",redemptionSource:"STORE_CREDIT",redemptionContent:{storeCreditAccountId:t.id}},...A&&{cost:A}}];const k=await r(),D=f&&Sr(k,t);return D&&D.amount>0&&(g.current=!1,n.paymentLines.value=Mr({paymentLines:n.paymentLines.value,storeCreditAccount:t,cost:D})),k},[i,r,d,n.paymentLines,e,v,t,s])}function Er(t){const e=ds(),s=Ga();return B(()=>{if(s.value)return yr({firstOrderTotal:e.value,storeCreditAccount:t.value})})}function Ii({afterAppliedRedeemablesChange:t}){const{i18n:e,shop:s,webMcp:a}=N(),n=s.hasFlagEnabled(Ya),r=Ke(),o=ee(),d=qa(),i=ls(),l=Cr(),c=fr(l),u=Is(ie.Init),p=hr(l),h=Er(l),v=B(()=>n&&h.value!=null),g=B(()=>d.value||i.value),M=B(()=>{if(d.value)return e.translate("payment.store_credit.buying_gift_card");if(i.value)return e.translate("payment.store_credit.no_fixed_selling_plans")});qt(()=>{(!p.value||!v.value||g.value)&&Ns(()=>{o.useStoreCreditForSubscriptionRenewals.value&&(o.useStoreCreditForSubscriptionRenewals.value=!1)})});const b=kr(l.value,u),f=Ar(l.value,u),A=B(()=>u.value===ie.Loading),k=B(()=>A.value||g.value),D=B(()=>k.value||r.value?.amount===0&&!c.value),E=k,P=B(()=>{const $=[],W=v.value&&o.useStoreCreditForSubscriptionRenewals.value;return(c.value||W)&&$.push(Ae),W&&$.push(Xe),$}),x=S(async $=>{const W=n&&$.includes(Xe),ae=$.includes(Ae)||W;if(o.useStoreCreditForSubscriptionRenewals.value=W,ae!==c.peek()){if((ae?await b():await f())?.status!=="success"){o.useStoreCreditForSubscriptionRenewals.value=!1;return}t?.()}},[b,f,c,o.useStoreCreditForSubscriptionRenewals,n,t]),V=B(()=>p.value&&!!l.value),R=B(()=>P.value.includes(Ae)),F=S($=>x($?[...new Set([...P.peek(),Ae])]:[]),[P,x]);U(()=>a?.unstable_provideStoreCreditController({available:V,redeeming:R,applied:c,settling:A,hasGiftCard:d,hasFixedSellingPlan:i,paymentDue:r,setRedeeming:F}),[a,V,R,c,A,d,i,r,F]);const T=l.value;if(!V.value||!T)return null;const _=v.value?h.value:void 0,q=T.balance,se=M.value;return m(lt,{accessibilityLabel:e.translate("payment.store_credit.label"),children:m(hs,{name:"store_credit_redemption",values:P.value,multiple:!0,onChange:x,variant:"block",children:[m(et,{value:Ae,disabled:D.value,secondaryContent:m(ne,{type:"strong",children:e.formatCurrency(q.amount,{currency:q.currencyCode})}),details:se&&m(ne,{children:se}),children:m(Z,{direction:"inline",gap:"base",alignItems:"center",children:[m(ne,{children:e.translate("payment.store_credit.apply_label")}),m(Ue,{when:A,children:m(Xs,{})})]})}),_&&m(et,{value:Xe,disabled:E.value,details:m(Z,{gap:"small-500",children:[m(ne,{children:e.translate("payment.store_credit.remaining_for_subscription_charges_description",{amount:e.formatCurrency(_.amount,{currency:_.currencyCode})})}),se&&m(ne,{children:se})]}),children:m(ne,{children:e.translate("payment.store_credit.use_remaining_for_subscription_charges_label")})})]})})}function Ni(){const{i18n:t}=N(),{hasViolations:e}=Zs(za);return e?m(Xt,{errorType:Zt.PaymentError,tone:"critical",children:t.translate("store_credit_errors.generic_error")}):null}const wr="YVGTZ",Ir="zyVks",Nr="U4h7p",Ze={Row:wr,Name:Ir,Digits:Nr};function Li({name:t,digits:e,icon:s}){return m(Z,{className:Ze.Row,direction:"inline",columnGap:"none",rowGap:"small-200",alignItems:"center",inlineSize:"100%",children:[m("span",{className:Ze.Name,children:m(Jt,{children:t})}),m("span",{className:Ze.Digits,children:e}),s]})}const Lr=new Map([["american_express","American Express"],["cartes_bancaires","Cartes Bancaires"],["diners_club","Diners Club"],["discover","Discover"],["elo","Elo"],["jcb","JCB"],["master","Mastercard"],["masterdebit","Mastercard"],["unionpay","UnionPay"],["visa","Visa"],["visadebit","Visa"],["maestro","Maestro"]]);function Dr(t){const e=Lr.get(t.toLowerCase());if(e)return e;const s=t.toUpperCase();return Ha(s)?cs(s):t}function Di(t){return t?t.nickname&&t.nickname.trim().length>0?t.nickname:t.bank&&t.bank.trim().length>0?t.bank:Dr(t.brand):""}function xr(){const{paymentLines:t}=ee();return B(()=>jt(t.value))}function Tr({isSelected:t,hasMsiPlan:e,isStale:s,binPrefix:a,canEditBin:n,supportedInstallmentsCount:r,isNegotiating:o}){if(!t||!e&&!s)return"hidden";if(a){if(a.length<8&&n)return"prompt"}else{if(n)return"prompt";if(r===0)return"hidden"}return o||s?"loading":"dropdown"}function Rt({id:t,variant:e}){const{i18n:s}=N(),a=e==="prompt"?s.translate("msi_installments.enter_card_details_prompt"):s.translate("msi_installments.loading_installments");return U(()=>
2{if(e==="loading")return ts({content:a})},[a,e]),m(sa,{id:t,name:"msiInstallments",label:s.translate("msi_installments.payment_plan_label"),value:e,disabled:e==="loading",onChange:()=>{},children:m(ta,{value:e,children:a})})}function Rr({paymentMethod:t,isSelected:e,canEditBin:s=!0,isVaultedContext:a=!1,id:n="msiInstallmentsSelect"}){const{bankIdNumberSignal:r,installmentMonthsSignal:o,lastNegotiatedBinSignal:d}=$e(),{paymentLines:i}=ee(),l=xr();U(()=>{o.value=l.value},[l.value,o]);const c=s&&!a,u=t.installmentPlans?.find(M=>M.type==="MSI"),p=u?.supportedInstallments??[],h=Wa(r.value),v=!a&&h!==void 0&&d.value!==void 0&&h!==d.value;U(()=>{if(!l.value)return;(!e||!u||!h&&!c&&p.length===0)&&(i.value=ea(i.value,void 0))},[l.value,e,u,h,c,p.length,i]);const g=Tr({isSelected:!!e,hasMsiPlan:!!u,isStale:v,binPrefix:h,canEditBin:c,supportedInstallmentsCount:p.length,isNegotiating:!1});return g==="hidden"?null:g==="prompt"?m(Rt,{id:n,variant:"prompt"}):m(Rt,{id:n,variant:"loading"})}const Bt=it({displayName:"MsiInstallmentsSelect",useError:Js("MsiInstallmentsSelect"),load:()=>Ls(async()=>({default:(await rt(async()=>{const{MsiInstallmentsSelect:t}=await import("./component-MsiInstallmentsSelect.CTVLe8c6.js");return{MsiInstallmentsSelect:t}},__vite__mapDeps([29,1,11,2,3,4,5,12,9,13,14,7,30,31,32,33,34,35,36,20,21,22,23,37,38,39,40,41,42,43,44,45,46,47,48,49]))).MsiInstallmentsSelect})),renderLoading:t=>m(Rr,{...t})}),Ft=new Map,ke=class ke{constructor(e=[],s=[],a,n=!1){this.sdkQueue=e,this.initQueue=s,this.sdk=a,this.scriptLoaded=n,this.setupGeneration=0,this.currentSetupId=0}async load(e){let s=Ft.get(e.source);s instanceof Promise||(s=aa(e,!0),Ft.set(e.source,s)),await s,this.initQueue.pop()?.(),this.initQueue=[],this.scriptLoaded=!0}async setup(e,s,a){return Ut(()=>{if(this.sdk)return;if(this.setupPromise&&this.setupForm===e)return this.setupPromise;const n=window.CardFields;if(!n)throw new ut("Attempted to init Cardfields before it is ready");const r=++this.currentSetupId;return this.setupForm=e,a(),this.setupPromise=(async()=>{try{for(let o=0;o<ke.MAX_SETUP_ATTEMPTS;o++){const d=this.setupGeneration,i=await n.setup(e,s);if(r!==this.currentSetupId){try{i.teardown()}catch{}return}if(d!==this.setupGeneration){try{i.teardown()}catch{}continue}this.sdk=i;for(const l of this.sdkQueue)await l();this.sdkQueue=[];return}throw new Pt(`CardFields setup failed: ${ke.MAX_SETUP_ATTEMPTS} consecutive teardowns raced setup.`)}finally{this.currentSetupId===r&&(this.setupPromise=void 0,this.setupForm=void 0)}})(),this.setupPromise},this.scriptLoaded,this.initQueue)}async teardown(){this.setupGeneration++,this.setupPromise=void 0,this.setupForm=void 0,this.sdk?.teardown(),this.sdk=void 0,this.sdkQueue=[],this.initQueue=[]}on(e,s,a){return this.scheduleSDK(n=>a?n.on(a,e,s):n.on(e,s))}off(e,s,a){return this.scheduleSDK(n=>a?n.off(a,e,s):n.off(e,s))}setStyles({field:e,styles:s}){return e?this.scheduleSDK(a=>a.setStyles(e,s)):this.scheduleSDK(a=>a.setStyles(s))}setFocus(e){return this.scheduleSDK(s=>s.setFocus(e))}setTranslation(e,s){return this.scheduleSDK(a=>a.setTranslation(e,s))}setPlaceholderContent(e,s){return this.scheduleSDK(a=>a.setPlaceholderContent(e,s))}setValue(e,s){return this.scheduleSDK(a=>a.setValue(e,s))}setTooltip(e,s){return this.scheduleSDK(a=>a.setTooltip(e,s))}vaultCard(e){return this.scheduleSDK(s=>s.vaultCard(e))}vaultCardMultipleTimes(e,s){return this.scheduleSDK(a=>a.vaultCardMultipleTimes(e,s))}setErrors(e){return this.scheduleSDK(s=>s.setErrors(e))}clearField(e){return this.scheduleSDK(s=>s.clearField(e))}loadFonts(e){return this.scheduleSDK(s=>s.loadFonts(e))}getFieldFrame(e){return this.scheduleSDK(s=>s._getFieldFrame(e))}scheduleSDK(e){return Ut(()=>{if(!this.sdk)throw new Pt("The CardFields SDK has not been set up.");return e(this.sdk)},!!this.sdk,this.sdkQueue)}};ke.MAX_SETUP_ATTEMPTS=3;let at=ke;function Ut(t,e,s){if(e){const a=t();return a instanceof Promise?a:new Promise(n=>{n(a)})}return new Promise((a,n)=>{s.push(async()=>{try{const r=t();r instanceof Promise?a(await r):a(r)}catch(r){n(r)}})})}const Ps=xs(void 0),Vt={name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1};function Br({children:t,value:e,sdkScriptAttributes:s,blurValidationEnabled:a=!0,blurValidationFieldDenylist:n,onError:r,onSetFieldErrors:o,onLoadSuccess:d}){const i=J(()=>
2new at,[]),[l,c]=j(!0),[u,p]=j({name:null,number:null,verification_value:null,expiry:null,issue_date:null,issue_number:null,sdk:null}),h=de(),[v,g]=j(),[M,b]=j(),[f,A]=j({name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1}),[k,D]=j(""),[E,P]=j([]),[x,V]=j(Vt),R=de(x);U(()=>{R.current=x},[x]);const F=de(),T=S(y=>{h.current=y instanceof na?y.diagnostics:void 0,p({sdk:y.message}),r?.(y),c(!1)},[r,p,c]),_=S(async y=>{try{return await y()}catch(C){if(C instanceof Error){let w=null;if(C.name===_t.name)w=new _t(C.message);else if(C.name===St.name){const O="httpStatus"in C&&typeof C.httpStatus=="number"?C.httpStatus:void 0;w=new St(C.message,O)}else C.name===Mt.hostedFieldsName&&(w=new Mt(C.message));if(w)return T(w),"";T(C)}throw C}},[T]),q=S(async(y,C={propagateErrors:!0})=>{const{sdk:w,...O}=y;await _(()=>i.setErrors(O)),p(Q=>{const te={...Q,...y};return C.propagateErrors&&o?.(te),te})},[i,o,_]),se=S((y,C)=>{const w={},O=F.current;C?(y||(!f?.expiry&&C.includes("expiry")&&(w.expiry=O?.expiry),!f?.number&&C.includes("number")&&(w.number=O?.number_blank),!f?.name&&C.includes("name")&&(w.name=O?.name)),(y||C.includes("verification_value"))&&!f?.verification_value&&(w.verification_value=O?.verification_value)):(y||(f?.expiry||(w.expiry=O?.expiry),f?.number||(w.number=O?.number_blank),f?.name||(w.name=O?.name)),f?.verification_value||(w.verification_value=O?.verification_value));const Q={...u,...w};return q(Q),{isValid:!Object.values(Q).some(Boolean)}},[u,f?.expiry,f?.name,f?.number,f?.verification_value,q]);U(()=>{async function y(){try{if(!s)throw new ut("Provider: hostedFieldsUrl must be provided");await i.load(s)}catch(C){C instanceof Error&&T(C)}}y()},[s,i,T]);const $=S(({cardType:y,bin:C,networks:w})=>{g(y),D(C),P(w)},[]),W=S(({targetName:y})=>{b(y)},[]),ae=S(async y=>{const{isValueValid:C,targetName:w,isValueEmpty:O}=y,Q=F.current,te=R.current[w],Ie=!!n?.has(w);if(a&&!Ie&&Q&&te){const oe={[w]:C?null:Q[w]};w==="number"&&O&&(oe[w]=Q.number_blank),await q(oe,{propagateErrors:!1})}b(void 0)},[q,a,n]),X=S(async y=>{const{targetName:C,isValueEmpty:w,isTab:O}=y;if(!O){A(te=>({...te,[C]:!w})),V(te=>({...te,[C]:!0}));const Q={[C]:null};await q(Q)}},[q]),me=S(y=>{A(C=>({...C,[y]:!0}))},[]),he=Fr(),be=S(()=>{he.current&&(A({name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1}),P([]))},[A,he]),ge=S(()=>{_(()=>i.on("cardtype",$)),_(()=>i.on("focus",W)),_(()=>i.on("blur",ae)),_(()=>i.on("keyup",X)),_(()=>i.on("change",X)),_(()=>i.on("input",X))},[_,i,$,W,ae,X]),Pe=S(()=>{_(()=>i.off("cardtype",$)),_(()=>i.off("focus",W)),_(()=>i.off("blur",ae)),_(()=>i.off("keyup",X)),_(()=>i.off("change",X)),_(()=>i.off("input",X))},[_,i,$,W,ae,X]),_e=S(()=>{V(Vt)},[]),Se=J(()=>({loadFonts:y=>_(()=>i.loadFonts(y)),setErrors:y=>q(y,{propagateErrors:!1}),setStyles:(...y)=>_(()=>i.setStyles(...y)),setFocus:(...y)=>_(()=>i.setFocus(...y)),setTooltip:(...y)=>_(()=>i.setTooltip(...y)),setTranslation:(...y)=>_(()=>i.setTranslation(...y)),setPlaceholderContent:(...y)=>_(()=>i.setPlaceholderContent(...y)),setValue:(y,C)=>_(()=>(typeof C=="string"&&C.trim().length>0&&A(w=>({...w,[y]:!0})),i.setValue(y,C))),setup:async(y,C,w=()=>{})=>{c(!0),await _(()=>i.setup(y,C,w)),d?.(),c(!1),F.current=C.errorMessages},teardown:()=>_(()=>i.teardown()),clearField:y=>_(()=>(A(C=>({...C,[y]:!1})),i.clearField(y))),vaultCard:(...y)=>_(()=>i.vaultCard(...y)),vaultCardMultipleTimes:(y,C)=>_(()=>i.vaultCardMultipleTimes(y,C)),getCardField:y=>i.getFieldFrame(y)}),[i,q,_,d]);U(()=>()=>{o?.({})},[o]);const K=J(()=>e??{sdk:Se,errors:u,sdkLoadDiagnostics:h.current,cardBrand:v,bankIdNumber:k,networks:E,focusedField:M,filled:f,loading:l,validate:se,subscribe:ge,unsubscribe:Pe,resetTouched:_e,emptyFields:be,setFilled:me,touched:x},[Se,v,k,E,u,f,M,l,e,se,ge,Pe,_e,be,me,x]);return m(Ps.Provider,{value:K,children:t})}function Fr(){const t=de(!0);return Ds(()=>()=>{t.current=!1},[]),t}const _s=()=>{const t=dt(Ps);if(t==null)throw new ut("No cardfields found in context");return t},nt=6,Ss=t=>t.toUpperCase(),Ot=t=>t.toLowerCase();function Ur(t){return!!t?.some(e=>e.type==="direct"&&e.paymentBrands.includes("BOGUS"))}function xi({paymentMethods:t,hasBogusGateway:e=Ur(t),paymentLines:s,storeVaultGuestCvvVerificationEnabled:a=!1,selectedCardRequiresProposalLineCvv:n=!1,selectedCardBrand:r,hasAmexCvvOnlyField:o=Vr({paymentLines:s,storeVaultGuestCvvVerificationEnabled:a,selectedCardRequiresProposalLineCvv:n,selectedCardBrand:r})}){return e?new Set(["number"]):o?new Set(["verification_value"]):new Set}function Vr({paymentLines:t,storeVaultGuestCvvVerificationEnabled:e=!1,selectedCardRequiresProposalLineCvv:s=!1,selectedCardBrand:a}){return!!(s&&a?.toUpperCase()==="AMEX"||e&&t?.some(({method:n})=>
2n.type===Ce.CreditCard&&n.brand==="AMEX"))}function Ti(t){return t.replace(/([\d.]+)rem/g,(e,s)=>`${Number(s)*10/14}rem`)}function Ri(){const{paymentMethods:t}=Y();return B(()=>{const e=t.value?.filter(s=>s.type===Ce.CreditCard&&!!s.expired);return e?e.length:0})}function Bi(){const{i18n:t}=N();return{getAccessibilityLabel:s=>{const a=s.type==="direct"?s.creditCardLastFourDigits:s.displayLastDigits;return`${cs(s.brand)} ${t.translate("payment.saved_credit_card_info")} ${a}`}}}function Ms(t){return t?t.map(e=>Ss(e)):[]}function Or({displayName:t,paymentBrands:e,paymentMethodIdentifier:s,selectableBrands:a,networkSelectionSupported:n}){const{bankIdNumber:r,networks:o,cardBrand:d}=_s(),{userEvents:i,source:{checkoutSessionIdentifier:l}}=N(),[c,u]=j(!1),[p,h]=j(""),v=J(()=>Ms(o||(d&&(r?.length??0)>=nt?[d]:void 0)),[o,d,r]);U(()=>{if(!r||r.length===0||!l)return;const g={checkoutToken:l,paymentMethodIdentifier:s,displayName:t||"",supportedBrands:e.join(","),detectedBrands:v.join(","),cardIsCobadged:v.length>1,shownBrands:a.join(","),networkSelectorShown:a.length>1&&n};c||(i.monorailEvent({schemaId:"checkout_credit_card_number_interaction/1.1",payload:{...g,eventName:"first_digit_entered"}}),u(!0));const M=r.length>=nt&&v.length>0,b=g.shownBrands!==p;M&&b&&(h(g.shownBrands),i.monorailEvent({schemaId:"checkout_credit_card_number_interaction/1.1",payload:{...g,eventName:"brand_shown_to_buyer"}}))},[s,t,e,v,a,r,i,l,n,p,c,u])}const As=Qa("CreditCardNetworkContext");function $r({children:t,paymentMethod:e,publishesCardNetworkDetection:s=!1}){const{checkout:a,source:n,observability:r,userEvents:o}=N(),d=Ts(),i=e?ue(e):d,l=a.cardNetworkSelection.forMethod(i),{bankIdNumber:c,touched:u,...p}=_s(),{networks:h,sdk:v,filled:g}=p,M=J(()=>Ms(h),[h]),b=c?.replace(/\s/g,"").length??0,f=b>=nt&&p.cardBrand?Ss(p.cardBrand):void 0,A=J(()=>M.filter(R=>e?.paymentBrands.includes(R)),[M,e]),k=!!e?.supportsNetworkSelection;U(()=>{s&&l.setDetectedState({networkSelectionEnabled:k,availableNetworks:A,cardBrand:f,numberFilled:!!g.number,bankIdNumberLength:b})},[s,l,k,A,f,g.number,b]);const D=l.selectableBrands.value;Or({displayName:e?.name,paymentBrands:e?.paymentBrands??[],paymentMethodIdentifier:e?.paymentMethodIdentifier??"",selectableBrands:D,networkSelectionSupported:e?.supportsNetworkSelection??!1});const E=S(R=>{const F=l.selectedSavedCreditCardBrand.value,T=typeof R=="function"?R(F):R;l.setSelectedSavedCreditCardBrand(T)},[l]),P=S(async()=>{const R=l.selectedNetwork.value,F=R?{selected_network:Ot(R)}:void 0,T=await v.vaultCard(F);return $t(o,{checkoutSessionIdentifier:n.checkoutSessionIdentifier??"",selectedNetwork:F?.selected_network,detectedNetworks:h}),T||r.log("credit_card_network_context_no_session_id_returned","No session id returned when vaulting card with selected network",{selectedNetwork:F?.selected_network}),T},[l,v,n,h,r,o]),x=S(async R=>{const F=l.selectedNetwork.value,T=F?{selected_network:Ot(F)}:void 0,_=await v.vaultCardMultipleTimes(R,T);return $t(o,{checkoutSessionIdentifier:n.checkoutSessionIdentifier??"",selectedNetwork:T?.selected_network,detectedNetworks:h}),_},[l,v,o,n,h]),V=J(()=>({activePaymentBrand:l.activeBrand.value,binLength:l.bankIdNumberLength.value,paymentMethod:e,detectedNetworks:M,selectableBrands:D,selectedNetwork:l.selectedNetwork.value,selectedSavedCreditCardBrand:l.selectedSavedCreditCardBrand.value,setSelectedNetwork:l.setSelectedNetwork,setSelectedSavedCreditCardBrand:E,vaultCardWithSelectedNetwork:P,vaultCardMultipleTimesWithSelectedNetwork:x}),[l.activeBrand.value,l.bankIdNumberLength.value,l.setSelectedNetwork,l.selectedNetwork.value,l.selectedSavedCreditCardBrand.value,e,M,D,E,P,x]);return m(As.Provider,{value:V,children:t})}function Fi(){return ja(As)}function $t(t,{checkoutSessionIdentifier:e,selectedNetwork:s,detectedNetworks:a}){s&&t.monorailEvent({schemaId:"checkout_credit_card_network_selection/1.0",payload:{checkoutToken:e,selectedNetwork:s,supportedNetworks:a?.join(",")??""}})}const Kr=["CardFieldsFetchFailureError"];function Gr({children:t,publishesCardNetworkDetection:e,directPaymentMethodConfig:s,...a}){const n=de(ra()),{value:r}=Y().paymentMethods,o=s??we(r??[]),{observability:d}=N(),i=S(l=>{if(Kr.includes(l.name)){d.log("default_card_fields_provider_unactionable_error","Unactionable error in card fields provider",{error:l});return}d.error(l)},[d]);return m(Br,{...a,onError:i,sdkScriptAttributes:n.current,children:m($r,{paymentMethod:o,publishesCardNetworkDetection:e,children:t})})}function Yr({enabled:t,selectedCardId:e}){const{checkout:{identity:s}}=N(),{paymentLines:a}=ee(),{negotiate:n}=Oe(),r=hn(),o=de(void 0);U(()=>
2{if(s.current.value!=="shopPay")return;if(!t||!e){o.current=void 0,a.value=Xa(a.value);return}if(o.current===e)return;o.current=e;const i=ns(a.value,"SHOP_PAY")?.method.walletContent?.creditCardInstallments;a.value=Za(a.value,r({msiEligibleCard:!0,creditCardInstallments:i})),n({include:[]}).catch(()=>{o.current=void 0})},[t,s.current.value,e])}function Ui(t){const{shopPay:e}=N(),{value:s}=Y().paymentMethods,{paymentLines:a}=ee(),{bankIdNumberSignal:n,installmentMonthsSignal:r}=$e(),{binResolution:o,clearInstallments:d,selectedCardBin:i,expandedVisible:l,collapsedVisible:c}=t.msi,u=l.value,p=c.value,h=o==="server"?t.selectedCreditCard.value?.id:void 0;Yr({enabled:p&&!e.session.isLoading.value,selectedCardId:h});const v=de(u);U(()=>{v.current&&!u&&(a.value=d(a.value),r.value=void 0),v.current=u},[u,d,a,r]);const g=de(p);U(()=>{g.current&&!p&&(a.value=d(a.value),r.value=void 0),g.current=p},[p,d,a,r]);const M=i.value,b=t.selectedCreditCard.value?.id;U(()=>{if(o!=="client")return;const D=n.peek();n.value=b===H&&yn(D,M)?D:M},[o,n,M,b]);const f=we(s??[]),A=f&&u?Kt({paymentMethod:f,binResolution:o,id:"msiInstallmentsSelect-expanded"}):void 0,k=f&&p?qr(Kt({paymentMethod:f,binResolution:o,id:"msiInstallmentsSelect-summary"})):void 0;return{expandedSlot:A,collapsedSlot:k}}function Kt({paymentMethod:t,binResolution:e,id:s}){return e==="server"?m(Bt,{paymentMethod:t,isSelected:!0,isVaultedContext:!0,id:s}):m(Bt,{paymentMethod:t,isSelected:!0,canEditBin:!1,id:s})}function qr(t){return m(Ee,{paddingInlineStart:"large-100",children:m(Gr,{onSetFieldErrors:()=>{},children:t})})}function ks({addressType:t="shipping"}={}){const{checkout:e}=N();return S(a=>e.identity.current.value==="shopPay"&&!a?.trim()&&(t==="billing"?!e.isShippingRequired.value:!0),[e,t])}function Vi({addressType:t="shipping"}={}){const{checkout:{validation:e},i18n:s,shopPay:a}=N(),n=ks({addressType:t}),r=S(()=>{const d=e.missingFields.phone.isValid.value;if(!d){const i=e.missingFields.phone.input.value;e.missingFields.phone.error.value=i?s.translate("field_errors.shipping_line_phone_invalid"):s.translate("field_errors.phone_blank")}return d},[e,s]);return{isMissingPhone:a.user.hasFlow.value&&n(a?.user.phoneNumber.value),assertMissingPhone:r}}function Oi({addressType:t="shipping"}={}){const e=ee(),s=ks({addressType:t}),a=t==="billing"?e.billingAddress.value:e.shippingAddress.value;return{isMissingFirstName:s(a.firstName)}}const zr=Qt("OverlayMoreOptionsButton");function $i({accessibilityLabel:t,options:e,positionArea:s}){const a=ia({base:!0,medium:!1}),{closeOverlay:n}=oa(),r=zt(void 0,zr);return e.length===0?null:m(es,{accessibilityLabel:t,overlay:m(fn,{connector:a?"none":"arrow",id:r,padding:"none",positionArea:s,children:m(Z,{gap:"small-200",padding:"small-100 base",alignItems:"center",children:e.map(({label:o,accessibilityLabel:d,destructive:i,href:l,onClick:c})=>{const u=`${o}-${d}`;return m(da,{inlineSize:"fill",variant:"plain",onClick:()=>{c?.(),n(r)},href:l,accessibilityLabel:d,inlineAlignment:"start",textDecoration:"none",tone:i?"critical":void 0,children:o},u)})})}),children:m(Ve,{type:"menu-vertical",size:"small"})})}function Ki(t){const{checkout:{addressManager:e},observability:s}=N(),a=e[t].value,n=Hr(t);return J(()=>{function r(d,i){return async(...l)=>{const c=await d(...l);return c&&n(i)?.(),c}}return{selectAddress:r(t==="shipping"?(d,i)=>(s.log("shipping_address_select_invoked","[useAddressMutationsWithNegotiation] selectAddress invoked for a shipping address",{address_id:d,source:i?.source??"unknown"}),a.selectAddress(d)):d=>a.selectAddress(d),"select"),createAddress:r(a.createAddress,"create"),updateAddress:r(a.updateAddress,"update"),deleteAddress:r(a.deleteAddress,"delete")}},[a,n,s,t])}function Hr(t){const e=la(),{checkout:{identity:s,wallets:a}}=N(),n=dt(ms),{negotiate:r}=Oe(),o=s.current;return S(d=>{const i=o.value;if((i==="customerAccount"||i==="guest")&&t==="shipping")return e?()=>e.dispatch("addressReplaced"):()=>{a.activeSession.value||r({include:[],fieldsToResolve:["deliveryNext"],silenceViolations:["non-delivery-address"],runListenersOnError:!0})};if(i==="shopPay")return async()=>{const l=t==="shipping"?["shippingAddress"]:["billingAddress"];await r({include:l,silenceViolations:["non-stock"],fieldsToResolve:l}),n&&["create","update"].includes(d)&&(n.cashbackState.stale.value=!0)};if(t==="billing"&&i==="businessCustomer")return()=>{r({fieldsToResolve:["billingAddress"]})}},[o,t,e,n,r,a])}export{fr as $,bi as A,Mi as B,tt as C,Gr as D,Fi as E,Wn as F,wi as G,Vr as H,Ss as I,Ti as J,Bi as K,Fn as L,$i as M,pi as N,Bt as O,br as P,Bn as Q,Jn as R,Ni as S,ui as T,er as U,Li as V,tr as W,Ri as X,yi as Y,hi as Z,mi as _,xr as a,yr as a0,ie as a1,kr as a2,Ar as a3,Ae as a4,Xe as a5,_n as a6,Rn as a7,Ii as b,Ai as c,Ui as d,ci as e,xi as f,Tr as g,Cr as h,hr as i,Ei as j,Vi as k,Oi as l,Ki as m,fi as n,Ur as o,_s as p,Di as q,G as r,_i as s,gi as t,ki as u,Pi as v,Si as w,
2Ci as x,Nn as y,vi as z};

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.