1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["component-PayPalExpressPaymentMethod.DJn-dors.js","esnext-vendor.DDpcaSqU.js","Choice.D9vYH2mX.js","hydrate.BcfGVx0L.js","utilities-previous.Cnwy8G2v.js","app.DdDscdWN.js","assets/app.BuSMBobh.css","assets/previous.DjvIwnbB.css","graphql-PaymentSessionMutation.C-nDEOnn.js","shared-permissions.B59tuyWB.js","hooks-useShopPayExternalAppContext.R6pnDxYu.js","assets/helpers.BduNPqpW.css","Checkbox.CdJzVizb.js","assets/Checkbox.SrYMuQu4.css","assets/Choice.DV6JSDrR.css","hooks-useShopPayProgressIntercepts.DJVsS6aH.js","cvv-cvvBridge.CLYVr7ZJ.js","assets/useShopPayProgressIntercepts.CIy8uDiZ.css","hooks-usePaypalRowEffects.BYZmcPeY.js","components-RedirectionNotice.module.CrRh0Cus.js","assets/RedirectionNotice.B8v_QGNW.css","useAddressMutationsWithNegotiation.BIr_RXis.js","amazon-pay-useAmazonPayPaymentLine.X7jqQiq6.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","helpers-installmentsNotSupportedForAddress.BnHLRwvm.js","Popover.ZkMcWGfE.js","assets/Popover.Bi1nHaU-.css","assets/useAddressMutationsWithNegotiation.BcTJoNaV.css","Section.J2ZFesxe.js","assets/Section.CU18S7Ap.css","shop-pay-installments-monorail.B1-OWrOB.js","ChangeCompanyLocationLink.DXURX0D_.js","BillingAddressForm.B1Xpg2b3.js","FormLayout.UkTBTXMZ.js","assets/FormLayout.CFj15lwv.css","PhoneField.rAEISard.js","hooks-useSuppressShopPayModalOnLoad.Cvo-K0z2.js","assets/PhoneField.uZEuHncj.css","utilities-stable-ref.dCtJn23l.js","assets/BillingAddressForm.BdwN7V1K.css","hooks-useGeneralPaymentErrorMessage.DLzmknw2.js","component-lazyBankPaymentMethod.Cp6A7LlR.js","WalletsSandbox-WalletSandbox.r7H6tjVA.js","hooks-useStableHostMethodsReferences.CidTc5Dm.js","assets/WalletSandbox.BoV0vp4z.css","assets/lazyBankPaymentMethod.Bunr75uw.css","component-lazyPaymentMethods.BflrObBP.js","assets/lazyPaymentMethods.1ZqBR0y1.css","assets/payment-selector-transitions.Wfh8Woqf.css"])))=>i.map(i=>d[i]); 2import{f as he,T as W,q as k,k as J,h as O,a as gt,u as n,S as G,e as we,A as K,o as bn,n as Dt,X as vr,x as br,i as Ee,Q as Cr,D as Sr,g as ze,W as Rs,N as rs,_ as Cn,l as Os,d as Ot,r as Vt,aA as Ar}from"./esnext-vendor.DDpcaSqU.js";import{W as re,T as A,bU as Sn,bm as et,ct as nt,bt as He,V as xe,e1 as ut,cP as zt,jF as Pr,jG as Mr,fY as Vs,bn as Ht,a2 as Er,a3 as Ir,a4 as Lr,hw as zs,a$ as Ne,bc as Hs,ep as kr,dw as An,jH as wr,cm as Nr,jI as is,aA as Pn,c3 as Tr,at as Dr,a5 as be,aU as Fr,aT as Br,jJ as xr,jK as Rr,bb as Or,gq as Us,bX as le,jL as Vr,jM as $s,a7 as mt,bk as Gs,Q as zr,S as Hr,x as Ws,h1 as Ur,jN as $r,dN as pt,jO as Gr,e as Wr,m as Ys,jP as Mn,gb as Yr,cA as En,bu as qs,bs as Ks,jj as js,af as Xs,jQ as qr,jR as Kr,jS as os,eJ as jr,cs as Js,jT as Xr,jU as Jr,dg as sn,ck as In,di as Zr,jV as Zs,bV as Qr,b3 as ei,dP as ti,jW as ni,K as si,i0 as De,U as Oe,jX as ai,I as un,jY as ri,an as Qs,f3 as ii,f4 as oi,bv as li,bj as Ft,aP as mn,jZ as di,j_ as ci,b5 as ui,bO as mi,j$ as pi,h3 as ls,bW as fi,dB as yi,b_ as hi,dE as gi}from"./utilities-previous.Cnwy8G2v.js";import{u as Ut,e as $t,_ as ea,bF as pn,k as F,aE as je,G as Ve,l as $,gI as Ln,h as _i,B as fe,bo as kn,bp as wn,da as vi,dm as bi,e5 as Nn,gM as Ci,X as Gt,aI as Si,aK as Ai,aL as ta,aG as Wt,b as ge,a0 as Pi,n as Yt,eb as na,c1 as Mi,hH as _t,f9 as Ei,i as Ge,eO as Tn,P as de,W as Re,C as Fe,F as Ii,cU as Li,i5 as ki,M as wi,I as Me,a as Ni,be as Ti,i6 as Dn,i7 as Di,z as sa,A as aa,d0 as $e,er as ra,d4 as ia,a1 as vt,i8 as oa,bV as qt,en as Fn,L as We,J as Fi,bQ as Bi,bR as xi,i9 as Ri,q as Oi,ac as la,ia as ds,ib as Vi,aa as zi,ic as da,id as Hi,ie as Ui,ig as $i,ih as Gi,a4 as Wi,t as Pe,cx as Yi,cy as an,a8 as qi,a7 as Bn,g9 as Ki,gT as xn,bd as Rn,ea as ji,a2 as Xi,bC as ca,gU as Ji,ed as Zi,ak as ua,w as On,N as Qi,eQ as eo,bm as to,aj as ma,fT as Vn,ii as cs,ij as no,ex as so,c$ as pa,ik as ao,il as ro,cT as io,by as fa,hv as oo,hw as us,im as zn,ec as lo,ee as co}from"./hydrate.BcfGVx0L.js";import{u as Ke,s as ms}from"./redemption-promotions.8MPSgIef.js";import{a as uo}from"./Section.J2ZFesxe.js";import{f as Hn,_ as bt}from"./app.DdDscdWN.js";import{C as Ce,a as Kt,_ as mo,b as po}from"./Choice.D9vYH2mX.js";import{I as qe}from"./shop-pay-installments-monorail.B1-OWrOB.js";import{S as fo,C as yo,A as ps,a as ho}from"./ChangeCompanyLocationLink.DXURX0D_.js";import{E as Ct,M as go,m as Un,F as _o,o as vo,H as bo,f as Co,p as Ie,I as ya,l as $n,k as Gn,J as ft,K as ha,L as jt,P as So,O as ga,Q as Xt,R as Ao,U as Po,W as Mo,X as Eo,D as yt,Y as Io,Z as Lo,_ as ko,N as dt,c as wo,n as No}from"./useAddressMutationsWithNegotiation.BIr_RXis.js";
2import{a as Wn,i as To}from"./payment-usePaymentExemptionReason.emSKnIpm.js";import{C as st}from"./Checkbox.CdJzVizb.js";import{u as Do,b as _a,A as va,B as Bt,c as Fo}from"./BillingAddressForm.B1Xpg2b3.js";import{b as Bo,a as Jt,O as St,W as Yn,u as xo,M as Ro}from"./hooks-useShopPayProgressIntercepts.DJVsS6aH.js";import{c as Oo}from"./cvv-cvvBridge.CLYVr7ZJ.js";import{R as At}from"./PaymentLine.HSjRrKhm.js";import{T as ba,g as Vo}from"./Theme-ThemeOverride.CSLUDabY.js";import{C as zo,a as Ho}from"./crypto-constants.Ca3tBkwm.js";import{b as fn,t as fs,S as xt,O as ys,c as Uo,s as $o}from"./helpers-installmentsNotSupportedForAddress.BnHLRwvm.js";import{d as Go,a as Wo,c as Ca,b as qn}from"./hooks-useGeneralPaymentErrorMessage.DLzmknw2.js";import{P as at,w as Rt}from"./PaymentIcon.-ypvsmSq.js";import{P as Yo}from"./PhoneField.rAEISard.js";import{u as Sa}from"./utilities-stable-ref.dCtJn23l.js";import{F as Kn,a as yn}from"./FormLayout.UkTBTXMZ.js";import{P as qo}from"./Popover.ZkMcWGfE.js";import{a as Aa,u as Ko,b as jo}from"./hooks-useUpdateCheckoutAddress.C4NXzSJo.js";import{f as Xo,a as Jo}from"./helpers-derivations.K4r9DEFp.js";function jn(){const{paymentLines:e}=re();return he(()=>{const s=e.value.find(a=>!!(a.method?.type==="direct"&&a.method?.creditCardLastFourDigits&&a.method?.brand));if(s)return s.method})}class Zo extends Error{constructor(){super(...arguments),this.name="EmptyPaymentLinesError"}}function Pa(){const{observability:e,shop:{paymentMethodAutoSelectionDisabled:t,paymentGateways:s}}=A(),a=Ut(),r=jn(),i=!t,o=Sn(),l=et("paymentMethods"),c=W(()=>s?.map(d=>d.name)??[],[s]);return k(d=>{const u=typeof s<"u"&&s.length>0,p=!l.value&&o.value.length>0;if(!u||!p)return;const g={hasSessionCard:!!r.value,paymentGateways:c,paymentMethodAutoSelectionDisabled:t,paymentRequired:a.value,stage:d};i&&e.error(new Zo(`Payment lines are unexpectedly empty during "${d}" stage. Negotiation was blocked.`),{severity:"error",metadata:{app:g}})},[i,o,r,l,e,c,s,t,a])}function yp(){const{i18n:e,observability:t}=A(),s=Ut(),r=re().paymentLines.value,[i,o]=J(!1),[l,c]=J(!1),{negotiate:d}=$t(),u=Pa(),p=k(async()=>{l||(c(!0),await d({force:!1,fieldsToResolve:["taxes","paymentMethods"],include:["paymentLines"],onComplete(){o(!0),c(!1)}}))},[d,l]);O(()=>{const m=r.find(v=>["paymentOnDelivery","manualPayment","customManualPayment"].includes(v.method.type));(r.find(v=>v.method.type==="offsite")||m)&&!i&&p()},[r,p,i]),ea({active:l}),nt(({parts:m,reason:g})=>{if(g!=="progression"&&g!=="completion"||!s.value)return{behavior:"allow"};const h=m.paymentLines.peek()[0];if(h===void 0)return u(g),{behavior:"block",reason:He.EmptyPaymentLines,errors:[{message:e.translate("field_errors.payment_gateway_missing"),target:pn}],perform:()=>{}};switch(h.method.type){case"giftCard":case"local":case"customOnsite":case"direct":case"offsite":case"redeemable":return{behavior:"allow"};case"deferred":{const y={method:{type:"deferred"}};return{behavior:"allow",perform(){Ke(m,y)}}}case"paymentOnDelivery":{const{additionalDetails:y,paymentInstructions:_,paymentMethodIdentifier:b,availablePresentmentCurrencies:S}=h.method,C={method:{type:"paymentOnDelivery",additionalDetails:y,paymentInstructions:_,paymentMethodIdentifier:b,availablePresentmentCurrencies:S}};return{behavior:"allow",perform(){Ke(m,C)}}}case"manualPayment":{const{id:y,name:_,additionalDetails:b,paymentInstructions:S,paymentMethodIdentifier:C,availablePresentmentCurrencies:P}=h.method,M={method:{id:y,type:"manualPayment",name:_,additionalDetails:b,paymentInstructions:S,paymentMethodIdentifier:C,availablePresentmentCurrencies:P}};return{behavior:"allow",perform(){Ke(m,M)}}}case"customManualPayment":{const{id:y,name:_,additionalDetails:b,paymentInstructions:S,paymentMethodIdentifier:C,availablePresentmentCurrencies:P}=h.method,M={method:{id:y,type:"customManualPayment",name:_,additionalDetails:b,paymentInstructions:S,paymentMethodIdentifier:C,availablePresentmentCurrencies:P}};return{behavior:"allow",perform(){Ke(m,M)}}}case"wallet":{if(h.method.name!=="PAYPAL_EXPRESS")return{behavior:"allow"};const{walletContent:y}=h.method;return{behavior:"allow",async perform({behavior:_}){if(_!=="allow")return;Ke(m,{method:{type:"wallet",name:"PAYPAL_EXPRESS",walletContent:y}})}}}case"walletsPlatformPaymentMethod":{const{name:y,walletParams:_}=h.method;return{behavior:"allow",perform(){Ke(m,{method:{type:"walletsPlatformPaymentMethod",name:y,walletParams:_}})}}}
2case xe.CreditCard:case xe.PayPal:case"bank":case"shopWallet":return{behavior:"allow"};case"noop":case"other":return t.log("payment_unexpected_payment_line_detected","Unexpected payment line",{type:h.method.type}),{behavior:"allow"};default:gt(h.method)}})}const Qo="network-selector-";function el(e){return`${Qo}${e.toLowerCase()}`}const tl="o0Dix",nl="fmZaX",hs={NetworkSelector:tl,NetworkSelectorPressable:nl};function sl({selectableBrands:e=[],activeBrand:t,onSelectBrand:s,viewTransitionKey:a,size:r}){const{i18n:i}=A(),o=(c,d)=>{const u=e.length-1;let p;switch(c.key){case"ArrowRight":case"ArrowDown":p=d===u?0:d+1;break;case"ArrowLeft":case"ArrowUp":p=d===0?u:d-1;break;case"Home":p=0;break;case"End":p=u;break;default:return}if(p<0)return;c.preventDefault();const m=c.currentTarget.parentElement?.children[p];m&&(m.focus(),s(e[p]))},l=(c,d)=>{c.preventDefault(),s(d)};return n("div",{className:hs.NetworkSelector,role:"radiogroup","aria-label":i.translate("payment.network_card_payment_options"),children:n(F,{direction:"inline",gap:"small-400",children:e.map((c,d)=>{const u=t===c,p=t?u:void 0,m=t?!p:void 0,g=u||!t&&d===0?0:-1,f={viewTransitionName:`vt-${a}-${c}`},v=el(c);return n("button",{id:v,"aria-label":ut(c),"aria-checked":u,role:"radio",className:hs.NetworkSelectorPressable,style:f,onClick:h=>l(h,c),onKeyDown:h=>o(h,d),tabIndex:g,type:"button",children:n(at,{type:c,size:r,disabled:m,active:p,accessibilityVisibility:"hidden"})},c)})})})}const al="mpn0m",rl="_6f3AR",il="KOEBK",hn={PaymentIcons:al,PaymentIcon:rl,morePaymentBrandsIcon:il};function gs({paymentBrands:e,activeIconDisplayed:t,activePaymentBrand:s,viewTransitionKey:a,size:r}){const{i18n:i}=A();return n(G,{children:e.map(o=>{const l=n(at,{type:o,size:r,disabled:t&&s!==o,active:s===o}),c=a?`vt-${a}-${o}`:void 0,u=c?n("span",{id:c,style:{viewTransitionName:c,display:"flex"},className:hn.PaymentIcon,children:l},o):n(G,{children:l},o);return o==="BOGUS"?n(je,{accessibilityLabel:i.translate("payment_gateway.bogus_label"),overlay:n(Ln,{children:i.translate("payment_gateway.bogus_label")}),children:u},o):u})})}function gn({paymentBrands:e,activePaymentBrand:t,viewTransitionKey:s,brandCountOverride:a,size:r,maxVisibleBrands:i,overflowIndicatorRef:o}){const l=e.filter(f=>zt(f)),c=Pr(l.length,i),{visiblePaymentBrands:d,hiddenPaymentBrands:u}=Mr(l,c),p=t?!!d.includes(t):!1,m=u.length>0||a,g=a?`+${a}`:`+${u.length}`;return n("div",{className:hn.PaymentIcons,children:n(F,{direction:"inline",gap:"small-400",alignItems:"center",children:[n(gs,{paymentBrands:d,activeIconDisplayed:p,activePaymentBrand:t,viewTransitionKey:s,size:r}),m&&n(je,{ref:o,accessibilityVisibility:"hidden",overlay:a?null:n(Ln,{id:"additional-payment-brand-icons",children:n(F,{direction:"inline",gap:"small-400",alignItems:"center",children:n(gs,{paymentBrands:u,activeIconDisplayed:p,activePaymentBrand:t,viewTransitionKey:s,size:r})})}),className:hn.morePaymentBrandsIcon,children:n(Ve,{justifyItems:"center",justifyContent:"center",alignItems:"center",alignContent:"center",children:n($,{size:"extraSmall",tone:"accent",children:g})})})]})})}const ol=6;function ll({animate:e,announceNetworkSelector:t,announceOverflowBrands:s,size:a,maxVisibleBrands:r,overflowIndicatorRef:i}){const{activePaymentBrand:o,binLength:l,paymentMethod:c,selectableBrands:d,selectedSavedCreditCardBrand:u,setSelectedNetwork:p}=Ct(),m=!!c?.supportsNetworkSelection;return c?n(dl,{animate:e,announceNetworkSelector:t,announceOverflowBrands:s,size:a,maxVisibleBrands:r,overflowIndicatorRef:i,activeBrand:o,availableBrands:c.paymentBrands,networkSelectionEnabled:m,onSelectBrand:p,savedCardBrand:u,selectableBrands:d,viewTransitionKey:c.paymentMethodIdentifier,binLength:l}):null}function dl({animate:e=!0,availableBrands:t,selectableBrands:s=[],activeBrand:a,savedCardBrand:r,onSelectBrand:i,viewTransitionKey:o,networkSelectionEnabled:l=!1,binLength:c,announceNetworkSelector:d=!1,announceOverflowBrands:u=!1,size:p,maxVisibleBrands:m,overflowIndicatorRef:g}){const{i18n:f}=A(),v=_i(),h=c>=ol||!!r,y=we([]),_=e&&!v,b=k(E=>{_?Hn(()=>y.value=E,["payment-icons"]):y.value=E},[y,_]);O(()=>{let E=[];h&&(r?E=[r]:s.length?E=s:a&&t.includes(a)&&(E=[a])),Vs(y.value,E)||b(E)},[h,a,t,r,s,y,b]);const S=t.filter(E=>y.value.length?y.value.includes(E):!0),C=a&&(!_||y.value.includes(a))?a:void 0,P=l&&y.value.length>1,M=y.value.length>0&&S[0]?[S[0]]:S;let I=M;P?I=[]:l&&(I=S);const N=u?Ht(f,I,void 0,m):"",D=N?`${f.translate("tooltip.additional_payment_methods")}: ${N}`:"",T=d&&P?f.translate("payment.network_card_payment_options"):D;return n(G,{children:[(d||u)&&n(fe,{accessibilityRole:"status",accessibilityVisibility:"exclusive",children:T}),l?n(G,{children:P?n(sl,{selectableBrands:s,activeBrand:a,onSelectBrand:i,viewTransitionKey:o,size:p}):n(gn,{activePaymentBrand:C,viewTransitionKey:o,paymentBrands:S,size:p,maxVisibleBrands:m,overflowIndicatorRef:g})}):n(gn,{activePaymentBrand:C,viewTransitionKey:o,paymentBrands:M,size:p,maxVisibleBrands:m,overflowIndicatorRef:g})]})}const Ma=1,_s=14;function cl(e){const t=we(Math.min(e,Ma)),s=K(null),a=K(null),r=K(null),i=K(null),o=K(null),l=K(null),c=K(null),d=k(()=>{const m=s.current,g=a.current,f=r.current,v=i.current;m===null||g===null||f===null||v===null||(t.value=ul(m,e,g,f,v))},[t,e]),u=k(m=>{const g=o.current;g&&c.current?.unobserve(g),o.current=m;const f=m?.parentElement;if(f){const v=getComputedStyle(f),h=parseFloat(v.fontSize)||_s;
2a.current=parseFloat(v.columnGap)||0,r.current=Rt.base.inlineSize/_s*h,i.current=m.getBoundingClientRect().width,c.current?.observe(m)}d()},[d]);return{ref:k(m=>{if(c.current?.disconnect(),c.current=null,l.current=m,!m)return;if(typeof ResizeObserver>"u"){t.value=e;return}const g=new ResizeObserver(f=>{for(const v of f){const h=v.target===o.current?v.target.getBoundingClientRect().width:v.contentBoxSize?.[0]?.inlineSize??v.contentRect.width;h<=0||(v.target===o.current?i.current=h:v.target===l.current&&(s.current=h))}d()});g.observe(m),o.current&&g.observe(o.current),c.current=g},[t,e,d]),overflowIndicatorRef:u,maxVisibleBrands:t}}function ul(e,t,s,a,r){return t*a+(t-1)*s<=e?t:Math.max(Ma,Math.floor((e-r)/(a+s)))}const ml=()=>{const e=Ut(),t=Er(),s=Ir("STORE_CREDIT"),a=Lr(),r=et("deliveryNext"),i=K(null),o=he(()=>({giftCard:t.value,storeCredit:s.value,redeemables:a.value,freeOrder:!e.value}));return bn(()=>{r.value||(i.current=o.value)}),he(()=>{const l=o.value;return r.value?i.current??l:l})};function pl(e,t){return e.current.value==="shopPay"?t:null}const fl=e=>({address:e,valid:!0,lastUsedAt:new Date().toISOString(),requiresVerification:!0,userPreferred:!1,id:"",uuid:""});function yl({addressErrors:e,billingAddressOption:t,billingAddressValue:s}){const{shopPay:a,checkout:r}=A(),{configuration:i}=r,o=Bo(),l=i.addressSettings.billingAddressSettings.value,c=kn(s?.countryCode,void 0,l),d=r.addressManager.billing.value,u=r.addressManager.shipping.value,p=a.session.selectedShippingAddress.value,m=wn().value,g=vi();return Jt("billingAddress",async()=>{if(t.value==="shipping"&&p?.id===d.selectedAddress.value?.id&&!m)return{success:!0};if(t.value!=="shipping"&&p?.id!==d.selectedAddress.value?.id)return{success:!0};if(a.user.flow.peek()!=="authenticated_user")return Oo({addressType:"billing",validate:()=>c(s,"billing"),setErrors:y=>{Dt(()=>{for(const[_,b]of y)e[_].value=b})}});!m&&t.value==="custom"&&a.session.unstable_updateSelectedBillingAddress(fl(s));const h=!m&&(!r.isShippingRequired.value||g.value)?await d.createAddress({address:s,addressErrorsOverride:e}):null;return!p?.id&&m&&await u.createAddress({address:s,addressErrorsOverride:e}),h===void 0?{success:!1,location:"intercept_billing_address_add_new",errors:Object.values(e).some(_=>_.value!==void 0)?[]:[o({offerGuestCheckout:!0})]}:{success:!0}}),null}const Ea=vr({});function hl({settings:e,children:t,additionalFieldGroups:s,addressSettings:a}){const{checkout:r,shopPay:i}=A(),{configuration:o}=r,c=br(Ea)?.addressErrors??r.validation.billingAddressErrors;Do(c);const{billingAddress:d,billingAddressOption:u,paymentLines:p}=re(),m=zs(),g=bi(),f=p.value[0]?.method?.type==="wallet",v=Nn(),h=i.session.isInstallmentsSelected.value,y=v!==null&&h&&r.installments.supportedCountryOptions.value.length>0?r.installments.supportedCountryOptions.value:m,_=Ci(r),b=d.value,{updateCountryCodeForSPIBillingAddress:S}=_a(d.fields.countryCode,y),C=v!==null;O(()=>{C&&h&&S()},[C,h,S]);const P=o.defaultPhoneNumber.value;return P&&_.isRequired("phone",{useMerchantSettings:!0})&&!b.phone&&(d.value={...b,phone:P}),n(Gt,{onSubmit:()=>{if(!g)return;document.getElementById(g.id)?.dispatchEvent(new Event("submit"))},children:[n(va,{id:"billingAddressForm",addressType:"billing",addressErrors:c,address:d,countries:y,settings:e,additionalFieldGroups:s,addressSettings:a??_,shouldSkipAddressValidation:f,children:t}),gl({identity:r.identity})&&n(yl,{addressErrors:c,billingAddressOption:u,billingAddressValue:b})]})}function gl({identity:e}){return e.current.value==="shopPay"}function Ia(){const{i18n:e}=A(),t=Si(),{billingAddressOption:s,billingAddress:a,shippingAddress:r}=re(),i=r.value,o=Ai(),{billing:l}=Ne();ta(),O(()=>()=>{l.value=!1},[l]);const c=k(({billing:p})=>{p.value=!0},[]),d=k(({billing:p})=>{p.value=!1},[]);return n(fe,{children:[n(Ee,{when:()=>t.value==="selector",children:n(st,{id:"billingAddressCheckbox",name:"billingAddress",checked:s.value==="shipping",onChange:p=>{p?(s.value="shipping",o()):(s.value="custom",u())},label:e.translate("payment.same_billing_address_checkbox_label")})}
2),n(Wt,{id:"billingAddressDetails",open:s.value!=="shipping",children:[n(ge,{blockSize:"large-300"}),n(Pi,{accessibilityRole:"group",accessibilityLabelledBy:"billingAddress",children:[n(Yt,{id:"billingAddress",level:2,children:e.translate("payment.billing_address_title")}),n(ge,{blockSize:"base"}),n(fo,{onValid:c,onInvalid:d,children:n(hl,{})})]})]})]});function u(){const p=Hs({zoneCode:void 0,countryCode:i.countryCode});a.value=p}}function _l({i18n:e,paymentMethodMustSupportInterestBearingLoans:t,supportedCountryOptions:s}){const a=s.map(r=>r.label).join(", ");return t?a?e.translate("installments.installments_debit_cards_supported_countries",{countries:a}):e.translate("installments.installments_valid_debit_cards_fallback"):a?e.translate("installments.installments_cards_supported_countries",{countries:a}):e.translate("installments.installments_valid_cards_fallback")}function Zt({id:e,editableAddress:t,addressType:s,countriesOverride:a,saveText:r,cancelText:i,onSave:o,onSuccess:l,onCancel:c,showSavedAddressSelector:d=!0,addressErrorsSignal:u,combineViolationAndValidationErrors:p=!0,addressSettings:m,showDefaultAddressCheckbox:g=!1,onAddressAutoComplete:f}){const[v,h]=J(!1),{i18n:y,checkout:_,shopPay:b}=A(),{createAddressParts:S}=Ne(),C=S.addressModalState.value,P=et("shippingAddress").value,M=et("billingAddress").value,I=s==="shipping",N=Nn(),D=kr(),T=zs(),E=a??(I?D:T),B=s==="billing",w=N!==null&&b.session.isInstallmentsSelected.value&&_.installments.supportedCountryOptions.value.length>0?_.installments.supportedCountryOptions.value:T,x=B&&N!==null&&b.session.isInstallmentsSelected.value,V=x?w:E,{updateCountryCodeForSPIBillingAddress:z}=_a(t.fields.countryCode,V),U=B?_.configuration.addressSettings.billingAddressSettings.value:_.configuration.addressSettings.nonBillingAddressSettings.value,Y=N?_l({i18n:y,paymentMethodMustSupportInterestBearingLoans:_.installments.paymentMethodMustSupportInterestBearingLoans.value,supportedCountryOptions:_.installments.supportedCountryOptions.value}):"",j=t.value,R=K({...j}),H=t.fields?.countryCode.value,X=m??U,q=kn(H,V,X),Z=na(H),ne=W(()=>An(),[]),ie=u??ne,ce=I?wr:Nr,{violations:L,clearViolations:Q}=Mi(ce);O(()=>{(s==="shipping"&&P||s==="billing"&&M)&&Q()},[Q,s,P,M]),O(()=>{if(C.status!=="editing")return;const oe=Z(s,Array.from(L)),ae=Array.from(oe).filter(([me])=>j[me]===R.current?.[me]);if(ae.length===0)return;const _e=q(j,s),ee=p?ae.concat(Array.from(_e)):Array.from(_e);Dt(()=>{for(const[me,ve]of ee)ie[me].value=ve})},[ie,C.status,s,p,j,q,L,Z]);const ue=K(()=>{for(const oe of Object.keys(ie))ie[oe].value=void 0});O(()=>{const oe=ue.current;return()=>oe()},[]),O(()=>{x&&z()},[x,z]);const pe=_.configuration.defaultPhoneNumber.value;O(()=>{if(!pe)return;X?.isRequired("phone",{useMerchantSettings:!0})&&!t.fields.phone.value&&(t.fields.phone.value=pe)},[pe,X,t.fields.phone]);const Le=async()=>{if(v)return;h(!0);const oe=q(j,s);if(oe.size){Dt(()=>{for(const[_e,ee]of oe)ie[_e].value=ee}),h(!1);return}await o?.(j)&&l?.(),h(!1)},Ae=n(G,{children:[g?n(st,{id:`${e??`${s}AddressForm`}_default_address`,name:"default_address",checked:C.setAsDefault==="default"||C.setAsDefault==="enabled",disabled:C.setAsDefault==="default",onChange:oe=>{S.addressModalState.value={...C,setAsDefault:oe?"enabled":"disabled"}},label:C.setAsDefault==="default"?n($,{color:"subdued",children:y.translate("address_management.address_form.default_address")}):y.translate("address_management.address_form.default_address")}):null,n(_t,{submitText:r??y.translate("address_management.address_form.save"),cancelText:i??y.translate("address_management.address_form.cancel"),loading:v,handleCancel:c})]});return n(Gt,{onSubmit:Le,children:[x?n(G,{children:[n($,{children:Y}),n(ge,{blockSize:"base"})]}):null,n(va,{id:e??`${s}AddressForm`,address:t,addressType:s,addressErrors:ie,showSavedAddressSelector:d,addressSettings:X,onAddressAutoComplete:f,countries:V,children:Ae})]})}function vl({explicitlyPreferred:e,onSetDefault:t}){const{i18n:s}=A(),a=e,r=!a&&t;return n(G,{children:[a&&n(G,{children:[n(ge,{blockSize:"small-400"}),n(Ei,{children:s.translate("payment.default")})]}),r&&n(Ge,{inlineSize:"fill",variant:"plain",onClick:t,accessibilityLabel:s.translate("shipping.address_default"),inlineAlignment:"start",textDecoration:"none",children:s.translate("shipping.address_default")})]})}const bl="bAwqP",Cl={Content:bl};function La({address:e,actions:t,nameLinePosition:s,addressDisplayName:a,explicitlyPreferred:r,onSetDefault:i,isImmutableAddress:o,isSelected:l,showPhone:c}){const{nameLine:d,primary:u,secondary:p}=Tn({address:e,nameLinePosition:s,addressDisplayName:a,showPhone:c});return n(Ve,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1fr) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"base",alignItems:"start",alignContent:"start",children:[n(F,{alignItems:"start",children:n("div",{className:Cl.Content,children:[s==="block"&&n(de,{children:d}),n(de,{children:n($,{type:"strong",children:u})}),n(de,{children:p}),!o&&n(vl,{explicitlyPreferred:r,onSetDefault:l?i:void 0})]})}),t]})}function Sl({state:e,description:t,error:s,onConfirm:a,onCancel:r}){const{i18n:i}=A();return n(G,{children:[s?n(F,{gap:"base",children:n(Re,{tone:"critical",errorType:Fe.PaymentError,children:s})}):null,n(de,{children:t}),n(ge,{blockSize:"base"}),n(_t,{submitText:i.translate("shipping.delete"),cancelText:i.translate("address_management.address_form.cancel"),loading:e==="deleting",handleSubmit:a,handleCancel:r,submitButtonAppearance:"critical"})]})}function Al({state:e,title:t,description:s,error:a,onConfirm:r,onCancel:i}){return n(St,{open:e==="active"||e==="deleting",heading:t,onHide:i,children:n(Sl,{state:e,description:s,error:a,onConfirm:r,onCancel:i})})}function Pl(e,t){return W(()=>{const s=new Map(e.map(o=>[o.id,o])),a=new Set(t.flatMap(({addressIds:o})=>[...o])),r=e.filter(({id:o})=>!a.has(o)),i=t.map(({title:o,addressIds:l})=>({title:o,addresses:Array.from(l).flatMap(c=>{const d=s.get(c);return d?[d]:[]})}));return{ungroupedImmutableAddresses:r,groupedImmutableAddresses:i}},[e,t])}const ka="addressSelector--",Ml=wi("AddressSelector");
2function wa({id:e,selectedId:t="",addressType:s="shipping",onChange:a,onEdit:r,onDelete:i,onSetDefault:o,addresses:l,addressesTitle:c,immutableAddresses:d=[],immutableAddressSections:u=[],getAddressDisplayName:p,selectedAddressDetails:m}){const g=Ii(e,Ml),{i18n:f}=A(),[v,h]=J("idle"),y=Li(),_=W(()=>l.filter(R=>!R.disabled),[l]),b=W(()=>l.filter(R=>R.disabled),[l]),S=s==="shipping",C=ki(s),P=k(R=>(r||i)&&R===t,[r,i,t]),[M,I]=J(C),N=W(()=>r?{accessibilityLabel:S?f.translate("shipping.address_edit"):f.translate("billing.address_edit"),onClick:r,label:S?f.translate("shipping.edit"):f.translate("billing.edit")}:void 0,[r,S,f]),D=k(()=>(I(C),h("active")),[C]),T=W(()=>i?{accessibilityLabel:S?f.translate("shipping.address_delete"):f.translate("billing.address_delete"),onClick:D,label:S?f.translate("shipping.delete"):f.translate("billing.delete"),destructive:!0}:void 0,[i,S,f,D]),E=t?Na(t,g):void 0,B=k(([R=""])=>{const H=El(R,g);H&&a(H)},[a,g]),{ungroupedImmutableAddresses:w,groupedImmutableAddresses:x}=Pl(d,u),V=l.length+d.length===1,z=S?f.translate("shipping.address_more"):f.translate("billing.address_more"),U=W(()=>[...N?[N]:[],...T?[T]:[]],[N,T]),Y=w.length>0&&l.length>0&&c,j=W(()=>E?[E]:[],[E]);return n(G,{children:[n(zo,{name:`${s}Address`,values:j,onChange:B,hideRadioControl:V,selectedContentBackground:m?"selected":void 0,children:[n(Nt,{addresses:w,formId:g,selectedId:t,isImmutable:!0,getAddressDisplayName:p,onSetDefault:o}),Y&&n(G,{children:[n(ge,{blockSize:"base"}),n($,{color:"subdued",children:c}),n(ge,{blockSize:"base"})]}),n(Nt,{addresses:_,formId:g,selectedId:t,shouldShowMoreOptionsButton:P,moreOptionsAccessibilityLabel:z,moreOptionsActions:U,getAddressDisplayName:p,onSetDefault:o,selectedAddressDetails:m}),n(Nt,{addresses:b,formId:g,selectedId:t,shouldShowMoreOptionsButton:P,moreOptionsAccessibilityLabel:z,moreOptionsActions:U,getAddressDisplayName:p,onSetDefault:o}),x.map(({title:R,addresses:H})=>n(Nt,{title:R,addresses:H,formId:g,selectedId:t,isImmutable:!0,selectedAddressDetails:m},R))]}),i&&n(Al,{state:v,title:S?f.translate("shipping.address_delete"):f.translate("billing.address_delete"),description:f.translate("address_management.confirm_address_deletion",{address:M}),onConfirm:async()=>{h("deleting"),await i(),y.current&&h("idle")},onCancel:()=>h("idle")})]})}function Na(e,t=""){return`${t}${ka}${e}`}function El(e,t=""){return e.replace(`${t}${ka}`,"")}function Nt({title:e,addresses:t,formId:s,selectedId:a,isImmutable:r=!1,shouldShowMoreOptionsButton:i,moreOptionsAccessibilityLabel:o,moreOptionsActions:l,getAddressDisplayName:c,onSetDefault:d,selectedAddressDetails:u}){const p=t.map(m=>n(Il,{addressId:m.id,address:m.address,choiceValue:Na(m.id,s),disabled:m.disabled,isImmutableAddress:r,showMoreOptionsButton:!!i?.(m.id),moreOptionsAccessibilityLabel:o,moreOptionsActions:l,addressDisplayName:c?.(m.id),explicitlyPreferred:m.default,onSetDefault:d,isSelected:a===m.id,details:a===m.id?u:void 0},m.id));return e?n(G,{children:[n(ge,{blockSize:"base"}),n($,{color:"subdued",children:e}),n(ge,{blockSize:"base"}),p]}):n(G,{children:p})}const Il=Cr(function({addressId:t,address:s,choiceValue:a,disabled:r=!1,isImmutableAddress:i=!1,showMoreOptionsButton:o=!1,moreOptionsAccessibilityLabel:l="",moreOptionsActions:c=[],addressDisplayName:d,explicitlyPreferred:u,onSetDefault:p,isSelected:m,details:g}){return n(Ve,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1fr)",gridTemplateRows:"minmax(0, 1fr)",alignItems:"start",alignContent:"start",children:n(Ce,{value:a,disabled:r,selectedContent:g,selectedContentPadding:g?"none":void 0,secondaryContent:o&&!i&&n(go,{accessibilityLabel:l,options:c}),children:n(Ve,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1fr)",gridTemplateRows:"minmax(0, 1fr)",alignItems:"center",alignContent:"center",children:n(F,{gap:"small-400",children:n(La,{nameLinePosition:"inline",address:s,addressDisplayName:d,explicitlyPreferred:u,isImmutableAddress:i,onSetDefault:p,isSelected:m,showPhone:!0})})})},t)},t)});function Ta(){const{shopPay:e,checkout:t}=A(),s=e.user.addresses,a=t.installments.config,r=e.session.isInstallmentsSelected;return he(()=>{const i=s.value,o=a.value,l=o!==void 0&&r.value,c=l&&o?i.filter(p=>!fn(p.address,o)):i,d=l&&o?i.filter(p=>fn(p.address,o)):[],u=[...c.map(p=>fs({address:p})),...d.map(p=>fs({address:p,isDisabled:()=>!0}))];return{validAddresses:c,disabledAddresses:d,addresses:u}})}function Ll({selectedAddress:e,setSelectedAddress:t}){const{checkout:s}=A(),a=Ta(),r=s.installments.config.value??null;return{setFirstSpiSupportedAddress:k(()=>{const{validAddresses:o}=a.value,[l]=o;if(!e||!r||!l)return;fn(e,r)&&t(l.id)},[a,r,e,t])}}function kl({addressType:e,addressCount:t,onPress:s}){const a=e==="shipping",{i18n:r}=A(),i=t>=is;return n(Ge,{variant:"plain",inlineSize:"fill",inlineAlignment:"start",onClick:s,disabled:i,children:n(F,{direction:"inline",gap:"small-100",alignItems:"center",children:[n(Me,{type:"plus",size:"base"}
2),n(F,{alignItems:"start",gap:"small-400",children:[n(de,{textAlign:"start",color:i?"subdued":void 0,children:a?r.translate("shipping.add_address"):r.translate("billing.add_address")}),i&&n(de,{textAlign:"start",type:"small",children:n($,{type:"strong",children:r.translate("address_management.address_form.max_address",{max_addresses:is})})})]})]})})}function wl({id:e,label:t,addressType:s,onAddAction:a}){const{i18n:r,userEvents:i,source:o,checkout:l,shop:c,shopPay:d}=A(),u=d.user.addresses.value,{selectAddress:p}=Un(s),m=l.addressManager[s].value.selectedAddress,g=K(m.peek()),[f,v]=J(!m.peek()),y=Nn()!==null&&d.session.isInstallmentsSelected.value,_=Ta(),{addresses:b,validAddresses:S}=_.value,{setFirstSpiSupportedAddress:C}=Ll({selectedAddress:m.value?.address,setSelectedAddress:p});O(()=>{!y||s!=="billing"||C()},[y,s,C,S]),O(()=>{const E=m.value,B=s==="billing"&&g.current&&!E;E||v(!0),g.current=E,B&&Ni({content:r.translate("general.choose_billing_address"),role:"status"})},[s,r,m.value]);const P=k(()=>{const E=s==="shipping"?"shipping_addresses":"billing_addresses";i.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...Pn(o,l,c),action:f?`${E}_collapse`:`${E}_expand`}}),v(B=>!B)},[i,o,l,c,s,f]),{nameLine:M,primary:I,secondary:N}=Tn({address:m.value?.address??{},nameLinePosition:"block"}),D=m.value?M:void 0,T=m.value?n(F,{children:[I&&n($,{children:I}),N&&n($,{children:N})]}):n(de,{children:r.translate("address_management.address_form.add_address")});return n(ba,{theme:{rollup:{inlinePadding:"none"}},children:n(At,{open:f,id:e,label:t,onToggle:P,primaryContent:D,secondaryContent:T,children:n(F,{gap:"small-200",children:[n(wa,{id:"billing_address_credit_card",addresses:b,addressType:"billing",onChange:E=>p(E,{source:"shop-pay-address-review-item"}),selectedId:m.value?.id}),n(fe,{padding:"none small-100",children:n(kl,{addressType:s,addressCount:u.length,onPress:a})})]})})})}function Nl({billingAddressInContext:e}){const{i18n:t,checkout:s}=A(),[a,r]=J(!1),i=_o(),o=s.configuration.addressSettings.billingAddressSettings.value,l=W(()=>({addressErrors:s.validation.billingAddressErrors,addressSettings:o}),[o,s.validation.billingAddressErrors]),c=l.addressErrors,{createAddress:d}=Un("billing"),u=k(p=>d({address:p,addressErrorsOverride:c}),[c,d]);return n(G,{children:[e?n(Ea.Provider,{value:l,children:n(Ia,{})}):n(fe,{border:"base",borderRadius:"base",padding:"none base",children:n(wl,{id:"payment_selector_billing_address",addressType:"billing",label:t.translate("payment_ux.bill_to"),onAddAction:()=>r(!0)})}),n(St,{open:a,heading:t.translate("address_management.address_form.add"),onHide:()=>r(!1),children:n(Zt,{addressType:"billing",addressErrorsSignal:c,editableAddress:i,onCancel:()=>r(!1),onSuccess:()=>r(!1),onSave:u,cancelText:t.translate("credit_card_form.go_back"),saveText:t.translate("edit_credit_card_modal.save_billing_address")})})]})}function Tl({identity:e,paymentLines:t,shop:s,isBareCardOnly:a}){return e.current.value!=="shopPay"||a?"inlineDirectMethod":!s.hasFlagEnabled(Tr)&&Dr(t,"APPLE_PAY")?"none":"footer"}function Dl({identity:e,billingAddressInContext:t,billingAddressVariant:s,customerAccountBillingAddressSection:a,businessCustomerBillingAddressSection:r}){return e.current.value==="shopPay"&&s==="footer"?n(Nl,{billingAddressInContext:t}):s!=="inlineDirectMethod"?null:e.current.value==="customerAccount"?a??null:e.current.value==="businessCustomer"?r??null:null}function Da({experienceType:e}){const{managedByMarketsPro:t}=be(),{value:s}=Sn({deferClientOnlyWalletsUntilHydrated:!0}),a=e==="bareCreditCardOnly",{paymentLines:r,billingAddress:i,shippingAddress:o,billingAddressOption:l}=re(),{shop:c,shopPay:d,checkout:u}=A(),p=Fr({managedByMarketsPro:t.value}),m=Aa(),g=u.installments.isSupported.value,v=!wn().value&&l.value==="shipping"&&u.isShippingRequired.value?o.value:i.value,h=Tl({identity:u.identity,paymentLines:r.value,shop:c,isBareCardOnly:a}),y=Br(d.app.config),_=d.session.isInstallmentsSelected.value;return{displayedPaymentMethods:W(()=>Xo(s??[],{identity:u.identity,installmentsSelected:g&&_,isApplePayAvailable:m.value,idealEnabled:p,isBareCardOnly:a,isShopAppLayout:y,shopAppVersion:d.app.config.version}),[s,u.identity,g,_,d.app.config.version,m.value,p,a,y]),renderAsBareCard:a,billingAddressVariant:h,selectedBillingAddress:v,isApplePayAvailable:m.value}}function Fl({shop:e,source:t,checkout:s},a){return s.configuration.layout.isOnePage.value?!1:xr({identitySource:s.identity.current.value,isOrderSession:Or(t),storeVaultEnabled:e.storeVaultEnabled,customerProfile:a.buyerIdentity.value?.customerProfile,hasCustomerStoredPaymentMethod:Rr({availablePaymentMethods:a.paymentMethods.value??[],paymentMethodHistory:a.paymentMethodHistory?.value??[]})})}function Bl(e){return e===2||e===3||e===4}const xl={2:28,3:17,4:11},Rl={2:18,3:13,4:18};function Ol(e,t){const s=xl[e],a=Rl[e];return t==="compact-narrow"||t==="compact"?a:t==="wide"?s:Math.min(s,a)}function Vl(e){const t=Fa(e);return{...t,eligibility:zl(e,t)}}function zl(e,t){const{renderFeatures:s}=e,a=s.tiles&&s.singleCreditCard?t:Fa({...e,renderFeatures:{...s,tiles:!0,singleCreditCard:!0}});return{tileEligible:a.mode==="tiles",fallbackReason:a.fallbackReason,tileIneligibility:a.metadata.tileIneligibility}}function Fa({renderFeatures:e,displayedPaymentMethods:t,tileContainerSize:s,getTileMetadata:a}){const r=t.length,{choiceListPresentation:i}=e,o={displayedPaymentMethodCount:r,tileEligibilityChecked:!1,tileIneligibility:[]};if(r===0)return{mode:"choiceList",choiceListPresentation:i,fallbackReason:"no_displayed_payment_methods",metadata:o};if(e.knownBuyerSharedSelector)return{mode:"knownBuyerShared",choiceListPresentation:i,metadata:o};const[l]=t;if(r===1&&l!==void 0&&e.singleCreditCard&&Us(l))return Hl(l)?{mode:"choiceList",choiceListPresentation:i,fallbackReason:"custom_payment_method_label",metadata:o}:{mode:"singlePaymentMethodCreditCard",choiceListPresentation:i,metadata:o};if(e.tiles&&Bl(r)){if(r===3&&(s===void 0||s==="compact-narrow"))return{mode:"choiceList",choiceListPresentation:i,fallbackReason:s===void 0?"tile_container_unmeasured":"tile_container_too_narrow",metadata:o};const c=Ul(t,r,s,a),d={displayedPaymentMethodCount:r,tileEligibilityChecked:!0,tileIneligibility:c}
2;return c.length===0?{mode:"tiles",choiceListPresentation:i,metadata:d}:{mode:"choiceList",choiceListPresentation:i,fallbackReason:"tile_ineligible_methods",metadata:d}}return{mode:"choiceList",choiceListPresentation:i,metadata:o}}function Hl(e){return!!e.displayName?.trim()}function Ul(e,t,s,a){const r=Ol(t,s);return e.flatMap(i=>{const o=le(i),l=Vr(i),c=a(i);if(!c)return[{key:o,methodName:l,reasons:["missing_tile_metadata"]}];const d=$l(c,r);return d.length>0?[{key:o,methodName:l,reasons:d}]:[]})}function $l(e,t){const s=[];return e.label.trim().length===0&&s.push("missing_label"),e.hasSubtitle&&s.push("subtitle_present"),e.label.length>t&&s.push("label_may_wrap"),e.iconCount<1&&s.push("missing_icon"),e.iconCount>1&&s.push("multiple_icons"),e.hasIncentiveBadge&&s.push("incentive_badge_present"),s}const Gl=3;function Ba(e,{i18n:t,identitySource:s,isOnePageCheckout:a,isVenmoCheckout:r=!1,forceDebitCardLabel:i=!1,tileSupportedCustomOnsitePaymentMethods:o}){switch(e.type){case"direct":return{label:$s({identitySource:s,i18n:t},e,{forceDebitCardLabel:i}),iconBrand:"generic",iconCount:1,hasSubtitle:!1,hasIncentiveBadge:!1};case"wallet":return Yl(e,t,r);case xe.PayPal:return xa(t,r);case"walletsPlatform":return ql(e,t,a);case"local":return jl(e.displayName??"",e.name);case"offsite":return Ra(e.name,e.paymentBrands);case"customOnsite":return Ti(e)||!o.has(e.paymentMethodIdentifier)?void 0:Xl(e.name,e.paymentBrands);case"bank":return Kl(e);case"paymentOnDelivery":case"manualPayment":case"customManualPayment":return vs(e.name);case"deferred":return vs(e.displayName??t.translate("payment_gateway.deferred_payment_label"));default:return}}function Wl(e,t){const s=Ba(e,t);if(s)return{label:s.label,hasSubtitle:s.hasSubtitle,iconCount:s.iconCount,hasIncentiveBadge:s.hasIncentiveBadge}}function Yl(e,t,s){switch(e.name){case"PAYPAL_EXPRESS":return xa(t,s);case"APPLE_PAY":return ht(t.translate("brand.apple_pay"),"apple_pay");case"SHOP_PAY":case"SHOPIFY_INSTALLMENTS":return{...ht(t.translate("payment_gateway.shop_pay.name"),"shop_pay"),hasSubtitle:e.name==="SHOPIFY_INSTALLMENTS"};case"GOOGLE_PAY":case"VENMO":return;default:return}}function ql(e,t,s){if(e.name===mt.AmazonPay)return s?void 0:ht(t.translate("brand.amazon_pay"),"amazon_pay")}function Kl(e){const t=e.availableInstruments[0]?.bankName;return t?{label:e.displayName??"",iconBrand:Vo(t),iconCount:1,hasSubtitle:!1,hasIncentiveBadge:!1}:{label:e.displayName??"",iconBrand:null,iconCount:Gl,hasSubtitle:!1,hasIncentiveBadge:!1}}function xa(e,t){return t?ht(e.translate("brand.venmo"),"venmo"):ht(e.translate("brand.paypal"),"paypal")}function ht(e,t){return{label:e,iconBrand:t,iconCount:1,hasSubtitle:!1,hasIncentiveBadge:!1}}function jl(e,t){const s=zt(t);return{label:e,iconBrand:s?t:null,iconCount:s?1:0,hasSubtitle:!1,hasIncentiveBadge:!1}}function Ra(e,t){const s=(t??[]).filter(zt);return{label:e,iconBrand:s[0]??null,iconCount:s.length,hasSubtitle:!1,hasIncentiveBadge:!1}}function Xl(e,t){const s=Ra(e,t);if(!s.iconBrand)return s;const a=s.iconBrand.replace(/[-_]/g," "),r=s.iconBrand.toUpperCase(),i=ut(r);return{...s,accessibilityLabel:`${e}, ${i===r?a:i}`}}function vs(e){return{label:e,iconBrand:null,iconCount:0,hasSubtitle:!1,hasIncentiveBadge:!1}}function Jl({identity:e}){return e.current.value}const Oa=new Set;function Va(e,t=Oa){const{showPaymentTiles:s,showSingleCreditCard:a}=Dn(),r=Di(),i=A(),{i18n:o,checkout:l}=i,c=be(),d=Fl(i,c),u=sa(),p=aa(u),m=Jl({identity:l.identity});return k((g,f,v)=>Vl({renderFeatures:{tiles:s,singleCreditCard:a,choiceListPresentation:r,knownBuyerSharedSelector:d},displayedPaymentMethods:e,tileContainerSize:g,getTileMetadata:h=>Wl(h,{i18n:o,identitySource:m,isOnePageCheckout:f,isVenmoCheckout:p,forceDebitCardLabel:v,tileSupportedCustomOnsitePaymentMethods:t})}),[e,s,a,r,d,o,m,p,t])}function hp(e,t,s=Oa){const a=Va(e,s),{checkout:r}=A(),i=r.configuration.layout.isOnePage,o=r.installments.paymentMethodMustSupportDebitCardOnly.value;return W(()=>a(t,i.value,o),[a,t,i.value,o])}const Zl="#",Ql=50;function gp({showHeading:e=!0}){const{i18n:t,checkout:{validation:s}}=A(),{purchaseOrderNumber:a}=re(),{poNumberError:r}=s,i=t.translate("payment.purchase_order_number.title");return n(uo,{condition:e,accessibilityLabel:t.translate("payment.purchase_order_number.title"),padding:"none",children:n(F,{gap:"small-200",children:[e&&n(Yt,{children:i}),n($e,{name:"poNumber",label:t.translate("payment.purchase_order_number.label"),value:a.value,onChange:o=>{a.value=o.trim()},prefix:Zl,autocomplete:"off",maxLength:Ql,error:r.value})]})})}function za({forceVaultingEligible:e=!1,blockNegotiations:t=!1,borderless:s=!1}={}){const a=be(),r=Gs(),i=ra(),o=we(void 0),{acceptPaymentVaulting:l,paymentLines:c}=re(),{i18n:d,shop:u}=A(),p=ia(),m=he(()=>p.value||e);function g(h){m.value&&(l.value=h),o.value=""}nt(({reason:h})=>
2(t&&h==="negotiation"||h!=="negotiation")&&m.value&&(a.paymentFlexibilityPaymentTermsTemplate.value&&!i.value||r.value)&&!l.value?{behavior:"block",reason:He.BlankVaultingAgreement,perform(){o.value=d.translate("field_errors.vaulting_agreement_blank")}}:h!=="completion"?{behavior:"allow"}:m.value?{behavior:"allow"}:{behavior:"allow",perform(){o.value=""}});const f=he(()=>c.value.some(h=>h.method.type==="bank")?d.translate("payment.business_customer_with_bank_account_vaulting_payment_label",{company:u.name}):a.buyerIdentity.value?.purchasingCompany?d.translate("payment.business_customer_vaulting_payment_label",{company:u.name}):d.translate("payment.vaulting_agreement_label",{company:u.name})),v=he(()=>m.value?l.value:void 0);return n(G,{children:n(F,{gap:"base",border:s?void 0:"base",borderRadius:s?void 0:"base",padding:s?void 0:"small-100",children:[n(Ee,{when:o,children:n(Re,{tone:"critical",errorType:Fe.PaymentError,children:o})}),n(st,{name:"vaulting_and_subscription_agreement",checked:v.value,onChange:h=>{g(h)},error:o.value?" ":void 0,label:f.value})]})})}function ed(e){switch(e){case"singlePaymentMethodCreditCard":return"bare_card";case"tiles":return"tiles";case"choiceList":return"list";case"knownBuyerShared":return"known_buyer_shared";default:return gt(e)}}function td(e){switch(e){case void 0:return"none";case"tile_ineligible_methods":return"ineligible_methods";case"tile_container_unmeasured":return"container_unmeasured";case"tile_container_too_narrow":return"container_too_narrow";case"no_displayed_payment_methods":return"no_methods";case"custom_payment_method_label":return"custom_label";default:return gt(e)}}function nd(e){const t=new Set,s=[];for(const{methodName:a,reasons:r}of e)for(const i of r)t.add(i),s.push(`tile_ineligible:${i}:${a}`);return[...Array.from(t,a=>`tile_ineligible_reason:${a}`),...s]}function bs(e,t){return[...e,`selector_mode:${ed(t.mode)}`,`fallback_reason:${td(t.eligibility.fallbackReason)}`,`tile_eligible:${t.eligibility.tileEligible}`,`method_count:${t.metadata.displayedPaymentMethodCount}`,...nd(t.eligibility.tileIneligibility)]}const sd="/cdn/shopifycloud/checkout-web/assets/c1/assets/payment.BidoBI-H.svg";function ad({error:e}){const{i18n:t}=A(),s=W(()=>{switch(e){case"configuration":return t.translate("payment.not_configured_error");case"technical":return t.translate("payment.technical_error");case"no_methods":return t.translate("payment.no_method_error");case"script":return t.translate("payment.no_working_method_error")}},[e,t]);return n(fe,{background:"subdued",borderRadius:"base",padding:"large-100",accessibilityRole:e==="script"?"alert":void 0,children:n(F,{gap:"small-200",alignItems:"center",children:[n(Ho,{children:n("img",{src:sd,alt:""})}),n(de,{color:"subdued",textAlign:"center",children:s})]})})}const Ha=zr("PaymentMethodsContext");function rd(){return Hr(Ha)}function id({children:e,billingAddressInContext:t,errorBannerInContext:s,isInModal:a,selectedPaymentMethod:r,billingAddressVariant:i,cardNickname:o,onCardNicknameChange:l}){const c=W(()=>({billingAddressInContext:t,errorBannerInContext:s,isInModal:a,selectedPaymentMethod:r,billingAddressVariant:i??"inlineDirectMethod",cardNickname:o,onCardNicknameChange:l}),[t,s,a,r,i,o,l]);return n(Ha.Provider,{value:c,children:e})}function Xn(){const{shop:e}=A(),{paymentMethods:t}=be(),{paymentLines:s}=re(),a=he(()=>vo(t.value)),r=he(()=>bo({paymentLines:s.value,storeVaultGuestCvvVerificationEnabled:e.storeVaultGuestCvvVerificationEnabled}));return he(()=>Co({hasBogusGateway:a.value,hasAmexCvvOnlyField:r.value}))}function Jn({handle:e}){const{validate:t,sdk:s,errors:a,loading:r}=Ie(),{vaultCardWithSelectedNetwork:i,setSelectedNetwork:o,detectedNetworks:l,selectedNetwork:c}=Ct(),d=k(u=>s.setErrors(u),[s]);return O(()=>(e.value={validate:t,vaultCardWithSelectedNetwork:i,setSelectedNetwork:o,setFieldErrors:d,hasSDKError:!!a.sdk,isSDKLoading:r,detectedNetworks:l,selectedNetwork:c},()=>{e.value=null}),[e,t,i,o,d,a.sdk,r,l,c]),null}const od=new Set(["name","number","verification_value","expiry","expiry_month","expiry_year","issue_date","issue_number"]);function ld(e){return od.has(e)}const dd=["number","expiry","verification_value","name"];async function cd(e,t){const s=await t(e.length);return new Map(e.map((a,r)=>
2{const i=s[r];if(i===void 0)throw new TypeError(`Missing payment session for shop ${a} at index ${r}`);return[a,i]}))}function ud(e,t){const{observability:s,shop:a,webMcp:r,checkout:{wallets:i}}=A(),{id:o}=a,l=Ws(a),c=Ut(),d=jn(),{validate:u,cardBrand:p}=Ie(),{vaultCardWithSelectedNetwork:m,vaultCardMultipleTimesWithSelectedNetwork:g}=Ct(),f=Pa(),v=Ur(),h=re();nt(({parts:y,reason:_})=>{const b=h.remotePaymentDetails.value,S=y.paymentLines.peek(),C=S[0],P=i.activeSession.value;if(_!=="progression"&&_!=="completion"||!c.value||!e||P)return _==="completion"&&P&&S.length===1&&C?.method.type==="direct"&&(s.leaveErrorBreadcrumb("[useDirectPaymentMethodCustomizations] activeSession is set and the first payment line is direct",{activeSession:P}),s.error(new $r("activeSession is set and the first payment line is direct. This will block checkout",{metadata:{conflictType:"DirectPaymentConflict",wallet:{active:P}}}))),{behavior:"allow"};if(C===void 0)return f(_),{behavior:"block",reason:He.EmptyPaymentLines,perform:()=>{}};if(C.method.type!=="direct")return{behavior:"allow"};const{acceptedSubscriptionTerms:M,paymentMethodIdentifier:I,paymentAttributes:N,alternative:D}=C.method,T=r?.getSubmittingAgenticToken();return d.value&&!T?{behavior:"allow",perform:()=>{}}:T||u(!1,t).isValid?{behavior:"allow",async perform({behavior:w}){if(w!=="allow")return;let x;if(T)x=T;else if(!b||b.size===0)x=await m();else{const V=[...v.value.length>0?[o]:[],...b.keys()],z=await cd(V,g);x=z.get(o)??null;const U=new Map(b);for(const[Y,j]of U)U.set(Y,{...j,sessionId:z.get(Y)});h.remotePaymentDetails.value=U}if(x){const z=y.paymentLines.peek().find(Y=>Y.method.type==="direct")?.method?.creditCardInstallments,U={method:{type:"direct",sessionId:x,acceptedSubscriptionTerms:M,paymentMethodIdentifier:I,paymentAttributes:N,alternative:D,...p&&{brand:ya(p)},...z!=null&&{creditCardInstallments:z}}};Ke(y,U,l)}}}:{behavior:"block",reason:He.CardFieldInputIsInvalid,perform:()=>{}}})}function md({open:e,onClose:t,heading:s,cardForm:a,sdkAvailable:r=!0,billingAddressSection:i,afterBillingAddress:o,beforeCardForm:l,error:c,onSave:d,loading:u,disabled:p,blocking:m,externalContent:g,createAddressForm:f,size:v,accessibilityLabel:h,dataTestIdForScrollableContent:y,submitText:_}){const{i18n:b}=A(),S=m?{blocking:!0,onHide:void 0}:{blocking:!1,onHide:t},C=f?.open??!1,P=n(_t,{submitText:_??b.translate("payment.card_form.save"),cancelText:b.translate("payment.card_form.cancel"),loading:r?u:!1,disabled:!r||p||u,handleSubmit:d,handleCancel:t}),M=n(Gt,{onSubmit:d,children:n(F,{gap:"base",children:[c&&n(fe,{padding:"none none base none",children:n(Re,{tone:"critical",errorType:Fe.PaymentError,children:c})}),l,a,r&&i,o]})});return n(G,{children:[g,n(St,{dataTestIdForScrollableContent:y,open:e,accessibilityLabel:h,heading:s,size:v,primaryAction:C?void 0:P,...S,children:[n(fe,{display:C?"none":"block",children:M}),C&&f?.content]})]})}function pd({onClick:e,textLabel:t}){const{rollup:{action:{tone:s}={}}={}}=vt();return n(Ge,{tone:s==="custom"?"custom":void 0,variant:"plain",textDecoration:"none",onClick:e,children:n(F,{direction:"inline",gap:"small-100",alignItems:"center",children:[n(Me,{type:"plus",size:"base"}),n($,{children:t})]})})}function fd({open:e,isEditing:t,address:s,addressType:a,onSave:r,onClose:i,id:o,saveText:l,cancelText:c,showSavedAddressSelector:d,combineViolationAndValidationErrors:u,addressErrorsSignal:p,addressSettings:m,modalSubtitle:g,showDefaultAddressCheckbox:f,errorBannerMessage:v}){const{i18n:h}=A(),y=a==="shipping",_=y?h.translate("address_management.address_form.add"):h.translate("billing.address_form.add_address"),b=y?h.translate("shipping.address_edit"):h.translate("billing.address_edit"),S=t?b:_,C=y?h.translate("address_management.address_form.save"):h.translate("billing.address_form.save"),P=y?h.translate("address_management.address_form.cancel"):h.translate("billing.address_form.cancel"),M=u===void 0?t:u,I=he(()=>v?.value??void 0);return n(St,{open:e,heading:S,onHide:i,children:[g?n(G,{children:[n(de,{color:"subdued",children:g}),n(ge,{blockSize:"base"})]}):null,n(F,{gap:"base",children:[n(Ee,{when:I,children:N=>n(Re,{tone:"critical",errorType:a==="shipping"?Fe.DeliveryError:Fe.PaymentError,children:n(de,{children:N})})}),s&&n(Zt,{id:o,editableAddress:s,addressType:a,saveText:l??C,cancelText:c??P,onSave:r,onSuccess:i,onCancel:i,showSavedAddressSelector:d,addressErrorsSignal:p,combineViolationAndValidationErrors:M,addressSettings:m,showDefaultAddressCheckbox:f})]})]})}function yd({id:e,addressType:t="shipping",onSave:s,onAddAction:a,showSavedAddressSelector:r=!0,addressErrorsSignal:i,errorBannerMessage:o,showNewAddressButton:l=!0,combineViolationAndValidationErrors:c,addressSettings:d,modalSubtitle:u,showDefaultAddressCheckbox:p=!1,hideAddressModal:m=!1}){const{i18n:g}=A(),{createAddressParts:f}=Ne(),v=f.addressModalState.value,h=t==="shipping",y=v.status==="editing",_=v.addressType===t&&(v.status==="editing"||v.status==="adding"),b=!m&&_,S=()=>{o&&(o.value=void 0),f.addressModalState.value={status:"idle",addressType:t,address:v.address,setAsDefault:"default"}},C=h?g.translate("shipping.add_address"):g.translate("billing.add_address");return n(G,{children:[l&&n(pd,{onClick:a,textLabel:C}),n(fd,{open:b,isEditing:y,address:v.address,addressType:t,onSave:s,onClose:S,id:e,showSavedAddressSelector:r,addressErrorsSignal:i,errorBannerMessage:o,c
2ombineViolationAndValidationErrors:c,addressSettings:d,modalSubtitle:u,showDefaultAddressCheckbox:p})]})}class Tt extends Error{constructor(t,s){super(t),this.name="InvalidSelectedAddressError",this.groupingHash="AddressEdit::InvalidSelectedAddressError",this.name="InvalidSelectedAddressError",this.groupingHash=s}}function Ua({addressType:e,addresses:t,immutableAddresses:s=[],immutableAddressSections:a=[],addressesTitle:r,selectedAddress:i,onSelectAddress:o,onCreateAddress:l=async()=>{},onUpdateAddress:c=async()=>{},onDeleteAddress:d=async()=>!1,onSetDefault:u=async()=>!1,addressErrorsSignal:p,canCreateAddress:m=!1,canUpdateAddress:g=!1,canDeleteAddress:f=!1,canSetDefaultAddress:v=!1,getAddressDisplayName:h,addressSettings:y,modalSubtitle:_,canChangeCompanyLocation:b=!1,createAddressFormId:S,errorBannerMessage:C,noticesSection:P="delivery",selectedAddressDetails:M,showNotices:I=!0,onBeforeSelectAddress:N,onBeforeCreateAddress:D,onBeforeUpdateAddress:T,onBeforeDeleteAddress:E,hideAddressModal:B=!1}){const{createAddressParts:w}=Ne(),{checkout:x,i18n:V,observability:z}=A(),{extendedAddressMode:U}=x.address,Y=e==="shipping"&&x.proposal.negotiated.fields.mustSelectProvidedAddress.value,{defaultShippingDetails:j}=x.configuration.addressSettings.nonBillingAddressSettings.value,R=j.country.code,H=W(()=>t.map(Cs),[t]),X=W(()=>s.map(Cs),[s]),q=W(()=>H.filter(ee=>!ee.disabled),[H]),[Z,ne]=J(0),ie=k(ee=>{const me=[...q,...X],ve=me.find(({id:ye})=>ye===ee);if(!ve){const ye=me.map(({id:ke})=>ke).join(",");z.error(new Tt(`Unexpected address id: '${ee}' not found in choices ${ye}`,"AddressEdit::handleChange::InvalidSelectedAddressError"));return}if(N){let ye=!1;N(ve,()=>{ye=!0,o(ve)}),ye||ne(ke=>ke+1)}else o(ve)},[q,X,o,N,z]),ce=k(()=>{if(!i)throw new Tt("Attempted to edit an address without a selected address","AddressEdit::handleEditAction::InvalidSelectedAddressError");w.addressModalState.value={status:"editing",address:pt(i.address,{extendedAddressMode:U}),addressType:e,addressId:i.id,setAsDefault:i.default?"default":"disabled"}},[i,e,w.addressModalState,U]),L=k(()=>{const ee=q?.[0],me=pt({firstName:ee?.address.firstName,lastName:ee?.address.lastName,countryCode:R??ee?.address.countryCode},{extendedAddressMode:U});w.addressModalState.value={status:"adding",address:me,addressType:e,setAsDefault:"disabled"}},[e,q,w.addressModalState,R,U]),Q=k(async()=>{if(!i)throw new Tt("Attempted to delete an address without a selected address","AddressEdit::handleDelete::InvalidSelectedAddressError");const ee=i.id;return E?E(ee,()=>d(ee)):d(ee)},[d,E,i]),ue=k(async ee=>{const me=w.addressModalState.value,ve=me.setAsDefault==="enabled";if(me.status==="adding"){const ye={address:ee,setDefault:ve};return D?D(ye,()=>l(ye)):l(ye)}if(me.status==="editing"){const ke={id:me.addressId,address:ee,setDefault:ve};return T?T(ke,()=>c(ke)):c(ke)}},[w.addressModalState,l,c,D,T]),pe=k(async()=>{if(!i)throw new Tt("Attempted to set a default address without a selected address","AddressEdit::handleSetDefault::InvalidSelectedAddressError");i.default||await u(i.id)},[u,i]),Le=f&&q.length>1,Ae=m||g,oe=w.addressModalState.value,ae=oe.status==="editing"&&H.some(({id:ee})=>ee===oe.addressId),_e=v&&(oe.status!=="editing"||ae);return n(F,{gap:"base",children:[I&&n(oa,{section:P}),Y?n(qt,{tone:"info",children:V.translate("address_management.must_use_address_banner")}):null,n(wa,{addressType:e,selectedId:i?.id,onChange:ie,onEdit:g?ce:void 0,getAddressDisplayName:h,addresses:H,addressesTitle:r,immutableAddresses:X,immutableAddressSections:a,onDelete:Le?Q:void 0,onSetDefault:v?pe:void 0,selectedAddressDetails:M},Z),b&&n(fe,{padding:"none small-100",children:n(yo,{showIcon:!0})}),Ae&&n(fe,{padding:"none small-100",children:n(yd,{id:S,addressType:e,onSave:ue,onAddAction:L,showNewAddressButton:m,showSavedAddressSelector:!1,addressErrorsSignal:p,errorBannerMessage:C,modalSubtitle:_,addressSettings:y,showDefaultAddressCheckbox:_e,hideAddressModal:B})})]})}function Cs(e){return{...e,id:e.id?e.id:Gr(e.address)}}function hd(e,t,s,a){return e==="billing"?s?t.find(r=>Wr(r.address,s,["phone","firstName"]))??null:null:a??null}const $a=e=>!e.firstName?.trim();function gd(e,t,s){const a=e.selectedPaymentMethod.value;if(!a||!Ys(a))return;const r=a.paymentAttributes.billingAddress.address;!$a(r)||!Mn(r,t)||e.selectPaymentMethod({...a,paymentAttributes:{...a.paymentAttributes,billingAddressValid:s,billingAddress:{...a.paymentAttributes.billingAddress,address:{...r,firstName:t.firstName}}}})}function _d(e,t,s){Dt(()=>{for(const a of e.paymentMethods.value){if(!Ys(a))continue;const{billingAddress:r}=a.paymentAttributes;!$a(r.address)||!Mn(r.address,t)||e.updateCreditCard(a.id,{billingAddressValid:s,billingAddress:{...r,address:{...r.address,firstName:t.firstName}}})}})}function Ss(e,t,s,a){gd(e,s,a),_d(t,s,a)}function vd({enabled:e,addressType:t,onPersistSuccess:s}){const{i18n:a,shopPay:r,observability:i,checkout:o}=A(),l=re(),{lastJourneyProgression:c,lastNegotiation:d}=Xs(),u=o.validation.missingFields.firstName.input,p=o.validation.missingFields.firstName.error,m=t==="billing"?qr:Kr;function g(b){const S=b.peek();if(!("violations"in S))return;const C=S.violations.filter(P=>!m.has(P.code));C.length!==S.violations.length&&(b.value={...S,violations:C})}function f(){p.value="";const b=t==="billing"?o.addressManager.billing.value:o.addressManager.shipping.value;b.errors.fields.firstName.value=void 0,g(c),g(d)}function v(b){const S=l.billingAddress.value;if(!S)return{success:!1,location:"first_name_no_address"};const C={...S,firstName:b};return l.billingAddress.value=C,f(),s?.(),{success:!0}}function h(b,S){const C={...b,address:{...b.address,firstName:S}};return t==="billing"?(r.session.unstable_updateSelectedBillingAddress(C),l.billingAddress.value=C.address):(r.session.unstable_updateSelectedShippingAddress(C),l.shippingAddress.value=C.address,y(C)),f(),s?.(),{success:!0}}function y(b){const S=r.session.selectedBillingAddress.value;!S||S.id!==b.id||Mn(S.address,b.address)&&(r.session.unstable_updateSelectedBillingAddress(b),l.billingAddress.value=b.address)}async function _(b,S,C){const P=C==="billing",M=P?o.addressManager.billing.value:o.addressManager.shipping.value,I={...b,address:{...b.address,firstName:S}},N=await M.updateAddress({id:b.id,address:I.address}),D=r.user.addresses.value.find(T=>T.id===b.id)??I;return N?(P?(l.billingAddress.value=N.address,Ss(r.session,r.user,D.address,D.valid)):(y(D),Ss(r.session,r.user,D.address,D.valid)),f(),s?.(),{success:!0}):(i.leaveErrorBreadcrumb("Shop Pay update address first name failed"),p.value=a.translate("field_errors.address_generic_error"),{success:!1,location:"first_name_update_failed"})}Jt("firstName",async()=>
2{if(!e)return{success:!0};const b=u.value.trim();if(!b)return p.value=a.translate("field_errors.address_first_name_blank"),{success:!1,location:"first_name_blank"};const S=hd(t,r.user.addresses.value,l.billingAddress.value,r.session.selectedShippingAddress.value);return S?r.user.addresses.value.some(P=>P.id===S.id)?_(S,b,t):h(S,b):t==="billing"?v(b):{success:!1,location:"first_name_no_address"}})}function bd({addressType:e="shipping",onPersistSuccess:t}={}){const{i18n:s,checkout:{validation:a},shopPay:r}=A(),{isMissingFirstName:i}=$n({addressType:e}),o=re(),l=he(()=>{const f=e==="billing"?r.session.selectedBillingAddress.value:r.session.selectedShippingAddress.value;return f?.id===Yr?f:f?.id??(e==="billing"?o.billingAddress.value:o.shippingAddress.value)}),c=a.missingFields.firstName.input,d=a.missingFields.firstName.error;vd({enabled:i,addressType:e,onPersistSuccess:t}),bn(()=>{if(l.value)return()=>{c.value="",d.value=""}});const u=k(f=>{if(!En(f))return s.translate("field_errors.address_first_name_blank")},[s]),p=qs(c,d,u);Ks(c,d,u);const m=d.value,g=js(m)?m.message:m;return n($e,{name:"firstName",label:s.translate("contact.first_name_label"),required:!0,autocomplete:"given-name",...p,error:p.error||g})}function Ga(e,t,s){return En(e)?s(e,t)?{isValid:!0}:{isValid:!1,reason:"phone_invalid"}:{isValid:!1,reason:"phone_blank"}}const Cd={id:"fb48dec1806e3e11b7375d723d9e47d5006dda9d3285b2f42dc9138fade9163b",type:"mutation",name:"AddPhone",source:"mutation AddPhone($phone:String!,$payAddressUuid:String){addPhone(phone:$phone,payAddressUuid:$payAddressUuid){userErrors{field message __typename}__typename}}"};function Sd(e,t,{enabled:s,addressType:a="shipping"}){const{i18n:r,graphql:{shopPayGraphql:i},shopPay:o,observability:l}=A(),c=re(),{formatPhoneNumber:d,validatePhoneNumber:u}=Sa(),m=(a==="billing"?c.billingAddress.value:c.shippingAddress.value)?.countryCode,g=W(()=>Md({graphql:i,observability:l}),[i,l]);Jt("phone",async()=>{if(!s)return{success:!0};const f=Ga(t.value,m,u);if(!f.isValid)return e.value=Pd(f.reason,r),{success:!1,location:f.reason};e.value=void 0;const v=d(t.value,m);if(!v)return e.value=r.translate("field_errors.shipping_line_phone_invalid"),{success:!1,location:"phone_format_failed"};const h=a==="billing"?o.session.selectedBillingAddress.value?.uuid:o.session.selectedShippingAddress.value?.uuid;return await g(v,h)?(o.user.unstable_setPhoneNumber(v),{success:!0}):(e.value=r.translate("field_errors.shipping_line_phone_invalid"),{success:!1,location:"add_phone_mutation_failed"})})}function Ad({addressType:e="shipping"}={}){const{i18n:t,checkout:{validation:s}}=A(),a=re(),{validatePhoneNumber:r}=Sa(),{isMissingPhone:i}=Gn({addressType:e}),l=(e==="billing"?a.billingAddress.value:a.shippingAddress.value)?.countryCode,c=s.missingFields.phone.input,d=s.missingFields.phone.error,u=s.missingFields.phone.isValid;Sd(d,c,{enabled:i,addressType:e}),bn(()=>{const h=Ga(c.value,l,r);u.value=h.isValid}),O(()=>()=>{u.value=!0,d.value=""},[u,d]);const p=k(h=>{if(!En(h))return t.translate("field_errors.phone_blank");if(!r(h??"",l))return t.translate("field_errors.shipping_line_phone_invalid")},[r,l,t]),{onInput:m,...g}=qs(c,d,p);Ks(c,d,p);const f=d.value,v=js(f)?f.message:f;return n(Yo,{name:"phone",countryCode:l??"",label:t.translate("contact.phone_label"),prefillCountryCode:!0,required:!0,autocomplete:e==="billing"?"billing tel-national":"shipping tel-national",...g,onInput:h=>{m?.(h),c.value=h??""},error:g.error||v})}function Pd(e,t){return e==="phone_blank"?t.translate("field_errors.phone_blank"):t.translate("field_errors.shipping_line_phone_invalid")}function Md({graphql:e,observability:t}){return async(s,a)=>{const{data:r,error:i}=await e.mutate(Cd,{variables:{phone:s,payAddressUuid:a}});return i||r==null||r.addPhone==null?(t.leaveErrorBreadcrumb("Shop Pay add phone mutation failed with a transport or null-response error"),!1):r.addPhone.userErrors?.length>0?(t.leaveErrorBreadcrumb("Shop Pay add phone mutation returned user errors",{userErrors:JSON.stringify(r.addPhone.userErrors)}),!1):!0}}function Ed({addressType:e="shipping",onFirstNamePersisted:t}={}){const{isMissingPhone:s}=Gn({addressType:e}),{isMissingFirstName:a}=$n({addressType:e});return!s&&!a?null:n(fe,{paddingInline:"base",paddingBlockStart:"small-200",paddingBlockEnd:"base",children:n(F,{direction:"block",gap:"base",children:[a&&n(bd,{addressType:e,onPersistSuccess:t}),s&&n(Ad,{addressType:e})]})})}function Wa({hideAddressModal:e}){const{checkout:t}=A(),s=t.addressManager.billing.value,a=Un("billing"),{isMissingPhone:r}=Gn({addressType:"billing"}),{isMissingFirstName:i}=$n({addressType:"billing"}),o=r||i,l=k(c=>a.selectAddress(c.id),[a]);return n(Ua,{addressType:"billing",addresses:s.addresses.value,immutableAddresses:s.immutableAddresses.value,immutableAddressSections:s.immutableAddressSections.value,addressesTitle:s.addressesTitle,selectedAddress:s.selectedAddress.value,onSelectAddress:l,onCreateAddress:a.createAddress,onUpdateAddress:a.updateAddress,onDeleteAddress:a.deleteAddress,getAddressDisplayName:s.getAddressDisplayName,addressErrorsSignal:s.errors.fields,canCreateAddress:s.canCreateAddress.value,canUpdateAddress:s.canUpdateAddress.value,canDeleteAddress:s.canDeleteAddress.value,canSetDefaultAddress:s.canSetDefaultAddress.value,onSetDefault:s.setDefaultAddress,errorBannerMessage:s.errors.banner,hideAddressModal:e,selectedAddressDetail
2s:o?n(Ed,{addressType:"billing"}):void 0})}function Id({hideAddressModal:e}){const{checkout:t}=A(),{isLoading:s,isValid:a}=t.addressManager.billing.value.suggestedAddress.value;return!a&&!s?n(Bt,{}):n(Wa,{hideAddressModal:e})}function Ya({hideAddressModal:e=!1}={}){const{checkout:t}=A();return Ld(t.identity.current.value)?t.addressManager.billing.value.isMissingValidSuggestedAddress.value?n(Bt,{}):t.identity.current.value==="shopPay"?n(Wa,{hideAddressModal:e}):n(Id,{hideAddressModal:e}):n(Bt,{})}function Ld(e){return e==="shopPay"||e==="businessCustomer"}async function kd({validateCardFields:e,vaultCard:t,paymentMethodIdentifier:s,getDue:a,parts:r,newCard:i,buyerHasActedSignal:o,negotiate:l,setLoading:c,beforeSubmit:d,openBilling:u,close:p,onAddressError:m,fixSubscriptionRedeemablePaymentAmount:g=!1}){o.value=!0,c(!0),await d?.();const{isValid:f}=e();if(!f){c(!1);return}let v;try{v=await t()}catch{c(!1);return}const h=r.paymentLines.value;if(v){const b={type:"direct",sessionId:v,paymentMethodIdentifier:s},S=h.filter(P=>P.method.type==="giftCard"||g&&P.method.type==="redeemable"),C=a();r.paymentLines.value=[{method:b},...C?[{method:b,due:C}]:[],...S]}function y(b){if(b.status!=="success"&&b.status!=="error")return;if(b.violations.some(C=>os.has(C.code)))return"address";if(b.errors.length!==0){for(const C of b.errors){if(os.has(C.code))return"address";if(jr.has(C.code))return"card"}return"other"}}const _=()=>{r.paymentLines.value=h};l({fieldsToResolve:["paymentMethods"],onComplete(b){switch(c(!1),b.status){case"success":case"error":{const S=y(b);if(S==="address"){_(),u(),m(b.violations);return}if(S==="card"){_();return}if(S==="other"){p();return}if(b.status==="success"){const C=wd(b);C&&(i.value=C.method),p()}break}case"invalid":{if(b.reasons.includes(He.BlankVaultingAgreement)){_();return}p();break}default:p();break}}})}function wd(e){return e.negotiated.paymentLines?.lines?.find(t=>t.method.type==="direct")}function Nd({open:e,onToggle:t}){const{i18n:s,checkout:a}=A(),{billingAddress:r}=re(),i=Fn(r.value),o=a.addressManager.billing.value.isMissingValidSuggestedAddress.value;return n(At,{id:"billingAddress",label:s.translate("payment.billing_address_title"),open:e||o,onToggle:o?void 0:t,primaryContent:o?void 0:i,children:n(F,{gap:"base",children:[n(oa,{section:"payment"}),n(Ya,{hideAddressModal:!0})]})})}const Td="H5k1u",Dd={CreateAddressButton:Td},Fd={rollup:{inlinePadding:"none"}};function Bd({addresses:e,selectedAddress:t,onSelectAddress:s,onAddAddress:a,canCreateAddress:r,canUpdateAddress:i,onUpdateAddress:o,open:l,onToggle:c,id:d,label:u,summary:p,errorAddress:m,onEditErrorAddress:g}){const{i18n:f}=A(),{nameLine:v,primary:h,secondary:y}=Tn({address:t?.address??{},nameLinePosition:"block"}),_=t?v:void 0,b=t?n(F,{children:[h&&n($,{children:h}),y&&n($,{children:y})]}):n(de,{children:f.translate("billing.address_form.add_address")}),S=m?.value,C=l||!!S;return n(ba,{theme:Fd,children:n(At,{id:d??"billingAddress",label:u??f.translate("payment.billing_address_title"),open:C,onToggle:()=>c(C),primaryContent:p??_,secondaryContent:p?void 0:b,children:[S&&g&&n(fe,{padding:"none none base none",children:n(xd,{onEdit:g})}),n(Ua,{addressType:"billing",noticesSection:"payment",addresses:e,selectedAddress:t,onSelectAddress:s,canUpdateAddress:i,onUpdateAddress:o,showNotices:!1,hideAddressModal:!0}),r&&n(je,{className:Dd.CreateAddressButton,inlineSize:"100%",padding:"base",onClick:a,children:n(F,{direction:"inline",gap:"small-100",alignItems:"center",children:[n(Me,{type:"plus",size:"base"}),n($,{children:f.translate("billing.add_address")})]})})]})})}function xd({onEdit:e}){const{i18n:t}=A();return n(Re,{errorType:Fe.PaymentError,tone:"critical",children:n($,{children:t.translate("address_management.invalid_billing_address_selected_with_update_link",{update_address_link:n(We,{tone:"monochrome",onClick:e,children:t.translate("address_management.billing_address_update")})})})})}function Rd({open:e,onToggle:t,onAddAddress:s,errorAddress:a,onEditErrorAddress:r}){const{checkout:i}=A(),o=i.addressManager.billing,l=o.value,c=k(d=>{a.value=void 0,o.value.selectAddress(d.id)},[o,a]);return n(Bd,{addresses:l.addresses.value,selectedAddress:l.selectedAddress.value,onSelectAddress:c,onAddAddress:s,canCreateAddress:l.canCreateAddress.value,canUpdateAddress:l.canUpdateAddress.value,onUpdateAddress:d=>l.updateAddress(d),open:e,onToggle:t,errorAddress:a,onEditErrorAddress:r})}const Od="cRSsz",Vd="WUohw",zd="bl714",Hd="GLY0v",ct={CardFieldWrapper:Od,isDisabled:Vd,"CardFieldWrapper-borderNone":"cssC4",isFocused:zd,hasError:Hd,"CardFieldWrapper-borderFull":"J1Wf0","CardFieldWrapper-borderBlockEnd":"_7rHVa"},qa=Sr(({hidden:e,border:t,error:s,focused:a,loading:r,children:i},o)=>{const l=Fi();return n("div",{"data-protected-input":!0,ref:o,hidden:e,className:ze(ct.CardFieldWrapper,Js({focusRing:"resting",colorLayer:s?"controlInvalid":"control"}),t&&ct[Rs("CardFieldWrapper-border",t)],{[ct.hasError]:!!s,[ct.isFocused]:a&&!l,[ct.isDisabled]:l}),"aria-busy":r||void 0,"aria-disabled":l||void 0,children:i})}),Ud="NM5yz",$d="kyKRO",Gd="GcTEr",rn={LoadingContainer:Ud,ready:$d,LoadingSlider:Gd};function Ka({ready:e}){const[t,s]=J(!0),a=()=>s(!1);return O(()=>{e||s(!0)},[e]),t?n("div",{className:ze(rn.LoadingContainer,{[rn.ready]:e}),onTransitionEnd:a,children:n("div",{className:rn.LoadingSlider})}):null}function ja({placeholder:e,label:t,name:s,initialValue:a,onChange:r,themeStyles:i,themeStylesVersion:o,onBlur:l=()=>{},empty:c}){const{filled:d,focusedField:u,sdk:p,loading:m}
2=Ie(),g=Bi(),f=xi(),v=Ri(),[h,y]=J(u===s),_=typeof a=="string"&&a.trim().length>0,b=Oi(),S=e??t;return O(function(){if(u===s){v("payment"),y(!0);const P=b.value.currentFocus.value;b.value.currentFocus.value="payment",P!=="payment"&&(g("sectionInteraction",{section:"payment",timestamp:new Date}),f({type:"section_interaction",section:"payment"}))}else h&&(l(),v("payment"),g("change",{element:{tagName:"INPUT",type:"text",label:s},section:"payment",timestamp:new Date}),y(!1))},[g,v,b,u,h,t,s,l,p,f]),O(function(){d[s]?(r(!1),p.setPlaceholderContent(s,""),v("payment")):r(!0)},[d,s,r,p,v]),O(function(){p.setTranslation(s,t)},[s,t,p]),O(function(){c?(p.setPlaceholderContent(s,S),p.setStyles({field:s,styles:{padding:i.padding.default}})):(p.setPlaceholderContent(s,""),p.setStyles({field:s,styles:{padding:i.padding.floating}}))},[c,S,s,i,o,p,m]),{hasInitialValue:_,isFilled:d[s]}}const Wd=26,As="--accessory-width";function Yd(e){const t=K(null),s=K(null);return O(()=>{const a=t.current,r=s.current,i=()=>{a?.style.removeProperty(As)};if(!e||!a||!r){i();return}const o=()=>{a.style.setProperty(As,`${r.offsetWidth+Wd}px`)};if(o(),typeof ResizeObserver>"u")return i;const l=new ResizeObserver(o);return l.observe(r),()=>{l.disconnect(),i()}},[e]),{wrapperRef:t,accessoryRef:s}}const qd="DCpNs",Kd="_4VRZE",on={CardField:qd,"CardField-hasAccessory":"_211UF",Accessory:Kd};
2function jd({accessory:e,border:t,error:s,focused:a,hidden:r,label:i,loading:o,name:l,placeholder:c,onChange:d,empty:u,themeStyles:p,themeStylesVersion:m}){const{i18n:g}=A(),{sdk:f}=Ie(),v=c??i,h=la({active:!!s}),{wrapperRef:y,accessoryRef:_}=Yd(!!e);return ja({placeholder:c,label:i,name:l,themeStyles:p,themeStylesVersion:m,onChange:d,empty:u}),n(qa,{ref:y,...{hidden:r,border:t,loading:o,error:s,focused:a},children:[n("div",{ref:h,className:ze(on.CardField,{[on["CardField-hasAccessory"]]:!!e}),id:l,"data-card-fields":l,"data-card-field-placeholder":v,"data-card-field-prefix":g.translate("payment.card_fields_container_prefix"),tabIndex:-1,onFocus:()=>{f.setFocus(l)}}),e&&n("div",{ref:_,className:on.Accessory,children:e}),n(Ka,{ready:!o})]})}const Xd="Uq6Ln",Jd="W16eS",Zd="lxxqW",Qd="z8T28",ec="KAqU2",tt={Wrapper:Xd,FieldContainer:Jd,ClearButton:Zd,Flex:Qd,CardField:ec,"CardField-hasAccessory":"_3fIVg"};function Te(e){const{error:t,label:s,name:a,initialValue:r}=e,{control:{border:i,labelPosition:o="inside"},textField:{border:l}}=vt(),c=l||i||"full",[d,u]=J(!r),p=k(g=>u(g),[]),m={...e,border:c,onChange:p,empty:d};return n("div",{className:ze(tt.Wrapper,da[o==="outside"?"labelOutside":"labelInside"],o==="inside"&&Js({colorLayer:t?"controlInvalid":"control"})),children:[o==="outside"&&n(ds,{variant:"outside",htmlFor:a,label:s}),n("div",{className:ze(tt.FieldContainer,o==="inside"&&!d&&Vi.floating),children:[o==="inside"&&n(ds,{variant:"inside",htmlFor:a,label:s}),a==="name"?n(tc,{...m,initialValue:r}):n(jd,{...m})]}),t&&n(zi,{controlID:a,children:t})]})}function tc({name:e,label:t,placeholder:s,error:a,loading:r,focused:i,hidden:o,border:l,initialValue:c,allowClear:d,onChange:u,empty:p,themeStyles:m,themeStylesVersion:g}){const{i18n:f}=A(),{setFilled:v,filled:h,sdk:y,touched:_}=Ie(),b=s??t,[S,C]=rs(()=>!0,!1),P={status:"empty"},[M,I]=rs((H,X)=>{switch(X.type){case"buyerModifiedField":return!S&&_.name&&C(),{status:"modified"};case"setInitialValue":return H.status==="modified"?H:X.value&&X.value.trim().length>0?(w(),{status:"prefilled",value:X.value}):{status:"empty"};case"prefillValueChanged":return H.status==="modified"?H:X.value&&X.value.trim().length>0?(x(X.value),{status:"prefilled",value:X.value}):(V(),{status:"empty"});case"clearField":return C(),V(),y.setFocus(e),{status:"modified"}}},P),N=k(()=>{I({type:"buyerModifiedField"})},[]),D=la({active:!!a}),T=k(H=>{i&&!H&&I({type:"buyerModifiedField"}),u(H)},[u,i]),{hasInitialValue:E,isFilled:B}=ja({placeholder:s,label:t,name:e,initialValue:c,themeStyles:m,themeStylesVersion:g,onChange:T,onBlur:N,empty:p}),w=k(()=>{v("name"),u(!1),y.setPlaceholderContent(e,""),y.setStyles({field:e,styles:{padding:m.padding.floating}})},[e,y,m,v,u]),x=k(H=>{y.setValue("name",H),y.setErrors({name:null}),w()},[y,w]),V=k(()=>{u(!0),y.clearField(e),y.setPlaceholderContent(e,b),y.setStyles({field:e,styles:{padding:m.padding.default}})},[u,y,b,e,m]),[z,U]=J(c);c!==z&&(I({type:"prefillValueChanged",value:c}),U(c)),M.status==="empty"&&E&&!h[e]&&I({type:"setInitialValue",value:c});const Y=k(()=>{I({type:"clearField"})},[]),j={hidden:o,border:l,loading:r,error:a,focused:i},R=B&&d&&!S;return n(qa,{...j,children:[n("div",{className:ze(tt.CardField,{[tt["CardField-hasAccessory"]]:R}),id:e,"data-card-fields":e,"data-card-field-placeholder":b,"data-card-field-prefix":f.translate("payment.card_fields_container_prefix"),"data-card-field-name-initial-value":c,ref:D,tabIndex:-1,onFocus:()=>{y.setFocus(e)}}),R&&n(nc,{onPress:Y}),n(Ka,{ready:!r})]})}function nc({onPress:e}){const{i18n:t}=A();return n("div",{className:tt.ClearButton,children:n("div",{className:tt.Flex,children:n(We,{accessibilityLabel:t.translate("payment.clear"),onClick:e,children:n(Me,{type:"x"})})})})}function sc({icon:e,children:t,controlLabel:s}){return n(je,{overlay:n(Ln,{children:t}),accessibilityLabel:s,children:n(Me,{type:e||"question"})})}const ac="1.35rem",Ps="1.1rem",rc="2.05rem",ic="0.55rem",oc={padding:{default:ft(`${ac} ${Ps}`),floating:ft(`${rc} ${Ps} ${ic}`)}};function lc(){const{control:{labelPosition:e="inside"},textField:t}=vt(),s=K(),a=K(oc),r=K(!1),[i,o]=J(0),l=W(()=>({padding:{get default(){return a.current.padding.default},get floating(){return a.current.padding.floating}}}),[]),c=k(d=>
2{if(d===null)return;d&&(s.current=d);const u=s.current;if(!u)return;const p=getComputedStyle(u),m=p.getPropertyValue("--empty-padding-block").trim(),g=p.getPropertyValue("--filled-padding-block-start").trim(),f=p.getPropertyValue("--filled-padding-block-end").trim(),v=p.getPropertyValue("--padding-inline").trim();if(!m||!g||!f||!v)return;const h={padding:{default:ft(`${m} ${v}`),floating:ft(`${g} ${v} ${f}`)}},y=h.padding.default!==a.current.padding.default||h.padding.floating!==a.current.padding.floating,_=r.current;r.current=!0,y&&(a.current=h,_&&o(b=>b+1))},[]);return O(()=>{const d=setTimeout(()=>c(),0);return()=>clearTimeout(d)},[e,t.typography?.size,c]),{themeStyles:l,themeStylesVersion:i,updateThemeStyles:c}}function Qe({errorMessageRef:e,fieldName:t,errorMessage:s,targetPath:a,shouldLog:r=!1}){const i=K(Hi()),{observability:o}=A();O(()=>{if(!(!s||s===e)&&(i.current({errorType:Fe.InputInvalid,value:"<redacted>",target:a,message:s,timestamp:new Date}),r)){const l={[t]:s};o.log("hosted_fields_payment_blocked","[Hosted Fields] Payment blocked due to validation errors",{cardFieldErrorLogs:l,origin:"inline"})}},[s,e,t,r,a,o])}const dc="CsSsR",cc={HostedFields:dc};function uc(){const{sdk:e}=Ie(),[t,s]=J(0),[a,r]=J();return O(()=>{(async()=>{const o=await e.getCardField("number");r(o?._iFrame)})()},[e,t]),O(()=>{const i=()=>{s(o=>o+1)};return a?.addEventListener("load",i),()=>{a?.removeEventListener("load",i)}},[a]),t}function ln(e){return e.replace(/^var\(|\)$/g,"")}const dn={background:ln(sn.color.default.control.background),text:ln(sn.color.default.control.text),textSubdued:ln(sn.color.default.control.textSubdued)},mc={base:"base",loose:"loose",xloose:"xLoose"},Ms=new Map([["title","capitalize"],["upper","uppercase"],["lower","lowercase"],["none","none"]]);function Xa({cardBrands:e,prefillCardholderName:t=!1,customHostedFields:s,cvvOnly:a=!1,isSelected:r,paymentMethodIdentifier:i,cardNumberAccessory:o}){const l=Ui(),{client:c,i18n:d,checkout:u,observability:p,shop:m,webMcp:g}=A(),f=c.enableAgenticCardEntry.value&&!!g&&m.hasFlagEnabled(Xr),v=o??n(Me,{type:"lock"}),h=u.latestReceipt.value,y=h?.id;let _=!1;if(h&&$i(h)){const se=h.failure;Gi(se)&&(_=!0)}const b=["ja","ja-jp"].includes(d.locale.toLowerCase()),S=t&&!b?l.value:void 0,C=K(null),{themeStyles:P,themeStylesVersion:M,updateThemeStyles:I}=lc(),N=e.includes("MAESTRO"),{loading:D,focusedField:T,cardBrand:E,sdk:B,errors:w,subscribe:x,unsubscribe:V,emptyFields:z,resetTouched:U}=Ie(),Y=E?ya(E):void 0,j=N&&Y==="MAESTRO",R=Go(),H=K({}),{negotiated:X}=u.proposal,q=c.unstable_getSerialization("shopifyIdentificationSignature"),Z=X.fields.checkoutCardsinkCallerIdentificationSignature?.value??q,{control:{labelPosition:ne="inside"},global:ie,textField:{typography:ce},typographyPrimary:L,typographySecondary:Q}=vt(),ue=Wi().customProperties.value,pe={extraSmall:ue.fontSize?.extraSmall??Pe.fontSize.extraSmall,small:ue.fontSize?.small??Pe.fontSize.small,base:ue.fontSize?.base??Pe.fontSize.base,medium:ue.fontSize?.medium??Pe.fontSize.medium,large:ue.fontSize?.large??Pe.fontSize.large,extraLarge:ue.fontSize?.extraLarge??Pe.fontSize.extraLarge,extraExtraLarge:ue.fontSize?.extraExtraLarge??Pe.fontSize.extraExtraLarge},Le=re().paymentLines.value,Ae=ce?.fonts,oe=Ae?{primary:L.fonts,secondary:Q.fonts}[Ae]:L.fonts,ae=Jr(oe)??Pe.fontFamily.base,_e=C.current&&getComputedStyle(C.current),ee=_e?.getPropertyValue(dn.text),me=_e?.getPropertyValue(dn.textSubdued),ye=_e?.getPropertyValue(dn.background)??Pe.color.global.controlBackground,ke=ee??Pe.color.global.controlText,Pt=me??Pe.color.global.controlTextSubdued,Mt=ft(pe[ce?.size??"base"]),rt=Pe.lineHeight.base,it=Pe.letterSpacing[mc[ce?.kerning??"base"]],Et=ce?.decoration??"none",It=ce?.letterCase??ie.typographyLetterCase,ot=It?Ms.get(It):Ms.get("none"),Xe=W(()=>({"background-color":ye,"placeholder-lightness":"22","placeholder-color":Pt,"font-family":ae,"font-size":Mt,"letter-spacing":it,"line-height":rt,color:ke,"text-decoration":Et,"text-transform":ot}),[ye,ae,Mt,it,rt,ke,Pt,Et,ot]),Je=W(()=>({transition:"padding .2s ease-out"}),[]),Lt=ze(cc.HostedFields,da[ne==="outside"?"labelOutside":"labelInside"]),kt=k(se=>{C.current=se,I(se)},[I]);function Qt(){return Y?Y==="AMEX"?d.translate("payment.card_verification_value_explanation_amex"):d.translate("payment.card_verification_value_explanation_other"):d.translate("payment.card_verification_value_explanation")}const te=W(()=>{const se=[];
2return L?.sourceBase&&L?.fonts&&se.push({name:L.fonts,source:L.sourceBase}),Q?.sourceBase&&Q?.fonts&&se.push({name:Q.fonts,source:Q.sourceBase}),se},[L,Q]),Se=W(()=>["name","number","expiry","verification_value","issue_date","issue_number"],[]),Ye=k(()=>{U(),Se.forEach(se=>{B.clearField(se)}),B.setErrors({})},[U,B,Se]);O(()=>{y&&_&&Ye()},[y,_,Ye]),Cn(()=>{let se,lt=!1;function Ze(_r){lt||!se||(lt=!0,p.histogram({name:"hosted_fields_loading_duration",value:performance.now()-se,attributes:{isTimeout:_r}}))}let Ue=!1;function wt(){Ue=!0}window.addEventListener("blur",wt,{once:!0});let nn;function hr(){nn=setTimeout(()=>{Ze(!0),p.counter({name:"hosted_fields_timeout",value:1,attributes:{buyerLeftBrowsingContext:Ue}}),p.log("hosted_fields_loading_timed_out","[HostedFields] Hosted fields timed out while loading.")},25e3)}async function gr(){C.current&&(x(),await B.setup(C.current,{agenticCardEntry:f,callerIdentificationSignature:Z,locale:d.locale,styles:{...Xe},translations:{name:d.translate("payment.name_on_card_placeholder"),number:d.translate("payment.card_number_placeholder"),expiry:d.translate("payment.card_expiry_placeholder"),verification_value:d.translate("payment.card_verification_value_placeholder"),issue_date:d.translate("payment.card_start_placeholder"),issue_number:d.translate("payment.card_issue_number_placeholder")},fonts:{local:te},errorMessages:{name:d.translate("field_errors.credit_card_name_invalid"),number:d.translate("field_errors.credit_card_number_invalid"),number_blank:d.translate("field_errors.credit_card_number_blank"),expiry:d.translate("field_errors.credit_card_expiry_invalid"),verification_value:d.translate("field_errors.credit_card_verification_value_blank"),issue_date:d.translate("payment.card_fields.errors.required.issue_date"),issue_number:d.translate("payment.card_fields.errors.required.issue_number")},validationSetting:"mixed"},()=>{se=performance.now(),hr()}),clearTimeout(nn),Ze(!1))}return gr(),()=>{window.removeEventListener("blur",wt),clearTimeout(nn)}},[C,x,B,f,Z,Xe,d,te,p]),O(()=>()=>{V(),z(),B.teardown()},[V,z,B]),O(()=>{D||(B.setStyles({styles:{...Je,...Xe}}),te.length&&B.loadFonts({local:te}))},[D,Je,Xe,B,te]),O(()=>{function se(Ue){return Ue?.number?Ue.number.origin==="server"?d.translate("field_errors.credit_card_number_invalid"):Ue.number.message:null}if(R?.paymentMethodIdentifier!==i)return;const Ze={name:R.name&&(!s||s.includes("name"))?d.translate("field_errors.credit_card_name_invalid"):null,number:se(R),expiry:R.expiry&&(!s||s.includes("expiry"))?d.translate("field_errors.credit_card_expiry_invalid"):null,verification_value:R.verificationValue&&(!s||s.includes("verification_value"))?d.translate("field_errors.credit_card_verification_value_blank"):null,issue_date:R.issueDate&&(!s||s.includes("issue_date"))?d.translate("payment.card_fields.errors.required.issue_date"):null,issue_number:R.issueNumber&&(!s||s.includes("issue_number"))?d.translate("payment.card_fields.errors.required.issue_number"):null};B.setErrors(Ze)},[B,d,R,i,s]),O(()=>{const{number:se,name:lt,expiry:Ze,verificationValue:Ue}=R;if(R?.number||R?.name||R?.expiry||R?.verificationValue){const wt={number:se?.message,name:lt?.message,expiry:Ze?.message,verification_value:Ue?.message};p.log("hosted_fields_payment_blocked","[Hosted Fields] Payment blocked due to validation errors",{cardFieldErrorLogs:wt,origin:"progression"})}},[R,p]),Qe({errorMessageRef:H.current.number,fieldName:"number",errorMessage:w.number,targetPath:"cart.paymentLines[0].card.number",shouldLog:!0}),Qe({errorMessageRef:H.current.expiry,fieldName:"expiry",errorMessage:w.expiry,targetPath:"cart.paymentLines[0].card.expiry",shouldLog:!0}),Qe({errorMessageRef:H.current.verification_value,fieldName:"verification_value",errorMessage:w.verification_value,targetPath:"cart.paymentLines[0].card.verificationValue",shouldLog:!0}),Qe({errorMessageRef:H.current.name,fieldName:"name",errorMessage:w.name,targetPath:"cart.paymentLines[0].card.name",shouldLog:!0}),Qe({errorMessageRef:H.current.issue_number,fieldName:"issue_number",errorMessage:w.issue_number,targetPath:"cart.paymentLines[0].card.issueNumber"}),Qe({errorMessageRef:H.current.issue_date,fieldName:"issue_date",errorMessage:w.issue_date,targetPath:"cart.paymentLines[0].card.issueDate"});const en=Le.some(se=>se.method.type==="direct");ea({active:(r??en)&&(D||!!w.sdk)});const Be=se=>s?!s.includes(se):!1,ns=n("div",{hidden:Be("expiry"),children:n(Te,{name:"expiry",label:d.translate("payment.card_expiry_label"),placeholder:d.translate("payment.card_expiry_placeholder"),loading:D,focused:T==="expiry",error:w.expiry,hidden:Be("expiry"),themeStyles:P,themeStylesVersion:M})}),ss=n("div",{hidden:Be("issue_date"),children:n(Te,{name:"issue_date",label:d.translate("payment.card_start_label"),placeholder:d.translate("payment.card_start_placeholder"),hidden:!j||Be("issue_date"),error:w.issue_date,themeStyles:P,themeStylesVersion:M})}),as=n("div",{hidden:Be("issue_number"),children:n(Te,{name:"issue_number",label:d.translate("payment.card_issue_number_label"),placeholder:d.translate("payment.card_issue_number_placeholder"),hidden:!j||Be("issue_number"),error:w.issue_number,themeStyles:P,themeStylesVersion:M})}),tn=n("div",{hidden:Be("verification_value"),children:n(Te,{name:"verification_value",label:d.translate("payment.card_verification_value_label"),placeholder:d.translate("payment.card_verification_value_placeholder"),loading:D,focused:T==="verification_value",error:w.verification_value,accessory:n(sc,{control
2Label:d.translate("tooltip.accessibility_label_context",{context:d.translate("payment.card_verification_value_label")}),children:Qt()}),hidden:Be("verification_value"),themeStyles:P,themeStylesVersion:M})});if(a)return n("div",{ref:kt,className:Lt,children:[tn,n(Te,{name:"name",hidden:!0,label:d.translate("payment.name_on_card_label"),themeStyles:P,themeStylesVersion:M}),n(Te,{name:"number",hidden:!0,label:d.translate("payment.card_number_label"),themeStyles:P,themeStylesVersion:M}),n(Te,{name:"expiry",hidden:!0,label:d.translate("payment.card_expiry_label"),themeStyles:P,themeStylesVersion:M}),n(Te,{name:"issue_date",hidden:!0,label:d.translate("payment.card_start_label"),themeStyles:P,themeStylesVersion:M}),n(Te,{name:"issue_number",hidden:!0,label:d.translate("payment.card_issue_number_label"),themeStyles:P,themeStylesVersion:M})]});const fr=s&&s.filter(se=>se==="expiry"||se==="verification_value").length<=1,yr=s&&s.filter(se=>se==="issue_date"||se==="issue_number").length<=1;return n("div",{ref:kt,className:Lt,children:n(Kn,{children:[n(Te,{name:"number",label:d.translate("payment.card_number_label"),placeholder:d.translate("payment.card_number_placeholder"),loading:D,focused:T==="number",error:w.number,accessory:v,themeStyles:P,themeStylesVersion:M}),fr?n(G,{children:[ns,tn]}):n(yn,{children:[ns,tn]}),n("div",{hidden:!j,children:yr?n(G,{children:[ss,as]}):n(yn,{children:[ss,as]})}),n("div",{hidden:Be("name"),children:n(Te,{name:"name",label:d.translate("payment.name_on_card_label"),placeholder:d.translate("payment.name_on_card_placeholder"),loading:D,focused:T==="name",error:w.name,initialValue:S,allowClear:t,hidden:Be("name"),themeStyles:P,themeStylesVersion:M})})]})})}function pc({open:e}={}){const{i18n:t}=A(),{selectedNetwork:s}=Ct();return n(Wt,{id:"network-selection-info-banner",duration:"fast",open:e??!!s,children:n($,{size:"small",color:"subdued",children:t.translate("payment.network_card_persistence_description")})})}const fc="1",yc="2",hc="3",gc="https://help.shopify.com/en/manual/checkout-settings/test-orders/payments-test-mode#test-payment-gateway";function _c(){const{i18n:e}=A();return n(qi,{children:n(F,{gap:"small-300",children:[n(Yt,{level:3,children:e.translate("payment.bogus_test_checkout.title")}),n(F,{gap:"small-400",children:[n(de,{children:e.translate("payment.bogus_test_checkout.intro")}),n(Yi,{gap:"small-400",children:[n(an,{children:e.translate("payment.bogus_test_checkout.approved_transaction",{card_number:n($,{type:"strong",children:fc})})}),n(an,{children:e.translate("payment.bogus_test_checkout.declined_transaction",{card_number:n($,{type:"strong",children:yc})})}),n(an,{children:e.translate("payment.bogus_test_checkout.gateway_failure",{card_number:n($,{type:"strong",children:hc})})})]}),n(de,{children:e.translate("payment.bogus_test_checkout.additional_instructions")})]}),n($,{color:"subdued",children:n(We,{href:gc,target:"_blank",tone:"monochrome",children:e.translate("payment.bogus_test_checkout.support_link")})})]})})}function vc(){const{checkout:e}=A(),{buyerIdentity:t,paymentMethods:s}=be(),{paymentLines:a}=re();return he(()=>{const r=e.addressManager.billing.value.suggestedAddress,i=t.value?.purchasingCompany,o=!!In(s.value).length,l=r.value.type,c=a.value.some(({method:d})=>d.type==="direct");return!i||o||!c?null:l?"selector":"form"})}function bc(){const{i18n:e,checkout:t}=A(),s=vc(),a=t.addressManager.billing.value,r=a.suggestedAddress.value,i=r.address,o=r.type,l=re().shippingAddress.value;ta();function c(){const m=Hs({countryCode:l.countryCode});a.addresses.value.some(f=>f.id===ys)?a.updateAddress({id:ys,address:m}):a.createAddress({address:m})}const d=a.selectedAddress.value?.id===xt,u=Fn(i),p=(()=>
2{if(o==="billing-fact")return e.translate("payment.use_order_billing_address_label");if(o==="billing")return e.translate("payment.use_location_billing_address_label");if(o==="shipping")return e.translate("payment.use_location_shipping_address_label")})();return n(fe,{children:[n(Ee,{when:()=>s.value==="selector",children:n(st,{id:"billingAddress",name:"billingAddress",checked:d,onChange:m=>{m&&i&&o?a.selectAddress(xt):c()},label:n(G,{children:[p,n(de,{color:"subdued",children:u})]})})}),n(Ee,{when:s,children:n(Wt,{id:"billingAddressDetails",open:o===null||!d,children:[n(ge,{blockSize:"large-300"}),n(Yt,{level:2,children:e.translate("payment.billing_address_title")}),n(ge,{blockSize:"base"}),n(Bt,{})]})})]})}const Cc=e=>n("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 60 60",...e,children:n("g",{fillRule:"evenodd",children:[n("path",{d:"M30 60C13.43 60 0 46.57 0 30S13.43 0 30 0s30 13.43 30 30-13.43 30-30 30m0-2c15.464 0 28-12.536 28-28S45.464 2 30 2 2 14.536 2 30s12.536 28 28 28"}),n("path",{fillRule:"nonzero",d:"M30.134 48.856a2.5 2.5 0 0 0 0-5 2.5 2.5 0 0 0 0 5"}),n("rect",{width:2,height:27,x:29,y:11,rx:1})]})}),Sc="e3sCv",Ac="hevoz",Es={Container:Sc,WarningIcon:Ac};function Pc(){const{errors:e,sdkLoadDiagnostics:t}=Ie(),{router:s,i18n:a,observability:r}=A();return O(()=>{if(e.sdk){const i=t?.errorCause;r.counter({name:"card_fields_sdk_load_error",value:1,attributes:{error:e.sdk,...typeof i=="string"?{error_cause:i}:{}}}),r.log("card_fields_sdk_load_failed","[CardFieldsSDKLoadError] An error occurred when attempting to load the Card Fields SDK.",{cause:e.sdk,...t?{diagnostics:t}:{}})}},[e.sdk,r,t]),n("div",{className:Es.Container,children:[n(Cc,{className:Es.WarningIcon}),n(F,{gap:"small-200",children:n(de,{children:n(Bn,{children:a.translate("payment.card_fields_unavailable_html",{count:1,current_url:s.currentUrl.value.toString()})})})})]})}const Mc=e=>n("svg",{xmlns:"http://www.w3.org/2000/svg",width:102,height:52,viewBox:"-270.8 371 102 52",...e,children:[n("path",{fill:"none",stroke:"inherit",strokeMiterlimit:10,strokeWidth:2,d:"M-182 404v16.8c0 .7-.4 1.2-1 1.2h-75.7c-.7 0-1.2-.6-1.2-1.2v-47.6c0-.7.6-1.2 1.2-1.2h75.7c.7 0 1 .6 1 1.2V395m-78-14h78m-17 18h27m-3.9-4.6 4.5 4.6-4.5 4.6"}),n("circle",{cx:-255.5,cy:376.5,r:1.5,fill:"inherit"}),n("circle",{cx:-250.5,cy:376.5,r:1.5,fill:"inherit"}),n("circle",{cx:-245.5,cy:376.5,r:1.5,fill:"inherit"})]}),Ec="_2wkMu",Ic="H55oQ",Is={Container:Ec,OffsiteIcon:Ic};function Lc(){const{i18n:e}=A();return n("div",{className:Is.Container,children:n(F,{gap:"large-200",children:[n(Mc,{className:Is.OffsiteIcon}),n(de,{children:e.translate("payment.no_js_credit_card_fields_redirect_hint")})]})})}const kc="_1yB1O",wc={cardDigitsWrapper:kc};function Nc({id:e,brand:t,displayLastDigits:s,details:a,onEdit:r,onDelete:i,requiresVerification:o}){const{i18n:l}=A(),{closeOverlay:c}=Ki(),d=ut(t),u=`${l.translate("payment.masked_digits_label",{last_digits:s})}`,p=`⢠${s}`,m=()=>{i&&i(e),c("actions-overlay")};return n(F,{gap:"small-500",children:[n(Ve,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(0, 1fr) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-300",alignItems:"center",alignContent:"center",children:[n(at,{type:t}),n(de,{children:n($,{type:"strong",children:[d," ",n("span",{className:wc.cardDigitsWrapper,children:o?p:u})]})}),n(Ve,{gridAutoFlow:"column",gridAutoColumns:"minmax(0, 1fr)",gridTemplateColumns:"minmax(0, 1fr)",gridTemplateRows:"minmax(0, 1fr)",children:[!r&&i?n(je,{onClick:m,accessibilityLabel:l.translate("payment.delete_credit_card_modal.title"),children:n(Me,{type:"delete",size:"small"})}):null,o?n(Me,{type:"alert-triangle",size:"small"}):null,r?n(je,{overlay:n(qo,{connector:"none",offset:10,id:"actions-overlay",children:n(Ve,{gridAutoRows:"minmax(0, 1fr)",gridAutoColumns:"minmax(0, 1fr)",gridTemplateColumns:"minmax(0, 1fr)",gridTemplateRows:"minmax(0, 1fr)",gap:"base",justifyContent:"start",justifyItems:"start",children:[r&&n(We,{textDecoration:"none",onClick:()=>{r(),c("actions-overlay")},children:l.translate("payment.saved_credit_card_actions.edit")}
2),i&&n(Ge,{variant:"plain",textDecoration:"none",tone:"critical",onClick:m,children:l.translate("payment.saved_credit_card_actions.delete")})]})}),children:n(Me,{type:"menu-vertical"})}):null]})]}),n(de,{children:n("bdi",{children:a})})]})}function _n(e){const t=A(),{details:s,onEdit:a,onDelete:r}=Tc(e,t);return n(Nc,{id:e.id,brand:e.brand,displayLastDigits:e.displayLastDigits,details:s,onEdit:a,onDelete:r,requiresVerification:e.requiresVerification})}function Tc(e,{checkout:t}){return t.identity.current.value==="businessCustomer"?{details:e.displayCardholderName,onEdit:void 0,onDelete:e.isVaultedCard?void 0:e.onDelete}:{details:e.displayAddress,onEdit:e.onEdit,onDelete:e.onDelete}}const Dc=["session_card"],Fc=()=>{};function Bc({cardDetails:e}){const{shippingAddress:t,billingAddress:s,billingAddressOption:a}=re(),r=Zr(),{getAccessibilityLabel:i}=ha(),o=i(e),l=a.value==="shipping"?t.value.address1:s.value.address1;return n(Kt,{values:Dc,onChange:Fc,variant:"grid",children:n(Ce,{id:"session_card",value:"session_card",accessibilityLabel:o,children:n(_n,{id:"session",isVaultedCard:!1,displayLastDigits:e.creditCardLastFourDigits,brand:e.brand,displayCardholderName:e.cardholderName,displayAddress:l,onDelete:()=>r()})},"session_card")})}function Ja({offsite:e,paymentMethod:t,sessionCard:s,isSelected:a,cardNumberAccessory:r}){const{errors:i}=Ie(),{i18n:o,shop:l,shopPay:c,checkout:d}=A(),u=t.paymentBrands?.includes("BOGUS")??!1,p=xn(t),{bankIdNumberSignal:m}=Ne(),g=d.configuration.layout.isOnePage.value,f=uc(),v=be().buyerIdentity.value?.purchasingCompany,h=jt().value,y=re(),_=Wo(y.directPaymentErrors),{errorBannerInContext:b,billingAddressInContext:S,billingAddressVariant:C,isInModal:P,cardNickname:M,onCardNicknameChange:I}=rd();O(()=>{let Y;return s?.creditCardFirstDigits&&(m.value?.replace(/\s/g,"")??"").length<s.creditCardFirstDigits.length&&(Y=s.creditCardFirstDigits,m.value=Y),()=>{Y!==void 0&&m.value===Y&&(m.value=void 0)}},[s?.creditCardFirstDigits,m]);const N=!h&&S&&C==="inlineDirectMethod",D=Rn("Checkout::PaymentMethod::HostedFields::RenderAfter",t?.uiExtension===void 0?[]:[t.uiExtension]),T=y.shippingAddress.value,E=W(()=>({paymentMethodIdentifier:t.paymentMethodIdentifier}),[t.paymentMethodIdentifier]);if(i.sdk)return n(Pc,{});if(e)return n(Lc,{});const B=b&&_?n(Re,{errorType:Fe.PaymentError,tone:"critical",children:o.translate("payment.generic_incorrect_card_info")}):null,w=s&&n(Bc,{cardDetails:s}),x=v&&g?n(bc,{}):n(Ia,{}),V=Rc({checkout:d,shop:l,shopPay:c},T),z=Oc({checkout:d},t),U=n("div",{hidden:!!s,children:[n(Xa,{cardBrands:t.paymentBrands??[],prefillCardholderName:V,isSelected:a,paymentMethodIdentifier:z,cardNumberAccessory:r},f),xc({identity:d.identity})&&n(pc,{})]});return n(F,{gap:"base",children:[B,u&&!s&&n(_c,{}),P&&I?n(Kn,{children:[U,n($e,{name:"cardNickname",label:o.translate("payment.card_nickname_label"),value:M??"",onChange:I,maxLength:Zs})]}):U,w,D.length>0&&a&&t.paymentMethodIdentifier&&n(So,{options:E,paymentMethodExtension:D}),p&&!P?n(ga,{paymentMethod:t,isSelected:a,canEditBin:!s}):null,N&&x]})}function xc({identity:e}){return e.current.value==="shopPay"}function Rc({checkout:e,shop:t,shopPay:s},a){return e.identity.current.value!=="shopPay"?t.sameBillingAndShippingAddress:!a?.firstName||!a?.lastName?!1:s.user.addresses.value.some(({address:r})=>r.firstName===a.firstName&&r.lastName===a.lastName)}function Oc({checkout:e},t){if(e.identity.current.value!=="shopPay")return t.paymentMethodIdentifier}function Vc({children:e,addCardModalOpen:t}){return O(()=>()=>{t.value=!1},[t]),n(G,{children:e})}function zc({paymentMethod:e,addCardModalOpen:t}){const{createAddressParts:s,buyerHasActedSignal:a}=Ne(),{i18n:r,checkout:i,shop:o}=A(),[l,c]=J(!1),d=Ca(),[u,p]=J(!1),m=we(void 0),g=re(),f=g.billingAddress.value,v=g.acceptPaymentVaulting,h=Fn(f),y=Qr(),_=ei(),b=be(),{value:S}=b.paymentFlexibilityPaymentTermsTemplate,{sdk:C,loading:P,validate:M,resetTouched:I}=Ie(),[N,D]=J(!1),T=ji().value,{negotiate:E}=$t(),B=Xt(),w=he(()=>!B.value),{rollup:{action:{tone:x}={}}={}}=vt(),V=i.addressManager.billing,z=V.value,U=be().buyerIdentity,Y=U.value?.purchasingCompany,j=!Y&&U.value?.customerProfile?.__typename==="CustomerProfile",R=z.errors.fields,H=na(f?.countryCode),X=k(te=>{H("billing_address",te).forEach((Ye,en)=>{R[en].value=Ye})},[R,H]),{value:q}=b.deferredTotal,Z=s.addressModalState.value,ne=we(void 0),ie=we(!1),ce=Z.addressType==="billing"&&(Z.status==="editing"||Z.status==="adding"),L=ne.value!=null||ce,Q=ce&&Z.status==="editing",ue=ie.value||Q?r.translate("edit_credit_card_modal.edit_address_title"):r.translate("billing.address_form.add_address"),pe=we(void 0),Le=k(async te=>V.value.createAddress({address:te}),[V]),Ae=k(async te=>{const Se=pe.value??(s.addressModalState.value.status==="editing"?s.addressModalState.value.addressId:void 0);return Se?await V.value.updateAddress({id:Se,address:te}):void 0},[V,pe,s.addressModalState]),oe=Q||ie.value&&j?Ae:Le,ae=k(async te=>{const Se=await oe(te);return Se&&j&&await E({fieldsToResolve:["paymentMethods"]}),Se},[oe,E,j]),_e=k(()=>{l&&L?(ne.value=void 0,ie.value=!1,pe.value=void 0,m.value=void 0,ce&&(s.addressModalState.value={status:"idle",addressType:"billing",setAsDefault:"default"})):N||(d(),I(),v.value=!1,c(!1),p(!1),s.addressModalState.value={status:"idle",addressType:"shipping",setAsDefault:"default"})},[l,L,ce,N,s.addressModalState,v,d,I,m,ne,ie,pe]),ee=()=>{Y||(g.billingAddressOption.value="custom"),p(te=>!te)},me=k(()=>{const te=z.addresses.value[0],Se=i.configuration.addressSettings.billingAddressSettings.value.defaultShippingDetails.country.code,Ye=pt({firstName:te?.address.firstName,lastName:te?.address.lastName,countryCode:Se??te?.address.countryCode},{extendedAddressMode:i.address.extendedAddressMode});ne.value=Ye},[z.addresses,i,ne]),ve=()=>{c(!0),t.value=!0,d(),I(),ne.value=void 0;const te=z.selectedAddress.value;j&&te&&(g.billingAddress.value=te.address,g.billingAddressOption.value="custom")},ye=Ws(o),ke=k(async()=>{await kd({validateCardFields:M,vaultCard:()=>C.vaultCard(),paymentMethodIdentifier:e.paymentMethodIdentifier,getDue:()=>ti(q,!!y.value,_.value,S?.type),parts:g,newCard:B,buyerHasActedSignal:a,negotiate:E,setLoading:D,fixSubscriptionRedeemablePaymentAmount:ye,openBilling:()=>p(!0),close:()=>{c(!1),p(!1)},onAddressError:te=>{if(j){const Se=V.value.selectedAddress.value;Se&&(m.value=Se,X(te))}else X&&X(te)}})},[B,a,M,e,E,C,q,y,_,g,X,S?.type,j,V,m,ye]),Pt=Os(Z),Mt=he(()=>Pt.value.addressType==="billing"?i.configuration.addressSettings.billingAddressSettings.value:i.configuration.addressSettings.nonBillingAddressSettings.value),rt=Z.addressType==="shipping",it=()=>{ne.value=void 0,ie.value=!1,pe.value=void 0,m.value=void 0,p(!1),ce&&(s.addressModalState.value={status:"idle",addressType:Z.addressType,setAsDefault:"default"})},Et=rt?r.translate("address_management.address_form.save"):r.translate("billing.address_form.save"),It=rt?r.translate("address_management.address_form.cancel"):r.translate("billing.address_form.cancel"),ot=Y&&Z.addressType==="shipping"?r.translate("shipping.address_form.one_time_address_subtitle"):"",Xe=L?ue:r.translate("payment.add_credit_card_modal.title"),Je=z.isMissingValidSuggestedAddress.value,Lt=Hc(i.identity),kt=j?n(Rd,{open:u,onToggle:ee,onAddAddress:me,errorAddress:m,onEditErrorAddress:()=>{const te=z.selectedAddress.value;te&&(ie.value=!0,pe.value=te.id,ne.value=pt(te.address,{extendedAddressMode:i.address.extendedAddressMode}))}}):Lt?n(Nd,{open:u,onToggle:ee}):n(At,{id:"billingAddress",label:r.translate("payment.billing_address_title"),open:u||Je,onToggle:Je?void 0:ee,primaryContent:Je?void 0:h,children:n(F,{gap:"base",children:n(Ya,{hideAddressModal:!0})})}),Qt=l&&L?{open:!0,content:n(G,{children:[ot&&n(fe,{padding:"base",children:n(de,{color:"subdued",children:ot})}),n(F,{gap:"base",children:n(Zt,{editableAddress:ne.value??Z.address,addressType:ne.value?"billing":Z.addressType,saveText:Et,cancelText:It,onSave:ae,onSuccess:it,onCancel:it,showSavedAddressSelector:ne.value!=null&&!ie.value||z.canCreateAddress.value,addressErrorsSignal:R,combineViolationAndValidationErrors:Q,addressSettings:Mt.value})})]})}:void 0;return n(F,{gap:"base",children:[n(Ee,{when:w,children:n(Ge,{tone:x==="custom"?"custom"
2:void 0,onClick:ve,variant:"plain",textDecoration:"none",children:n(F,{direction:"inline",gap:"small-400",alignItems:"center",justifyContent:"center",children:[n(Me,{type:"plus",size:"small"}),n($,{children:r.translate("payment.use_different_credit_card_label")})]})})}),n(md,{size:"large",open:l,onClose:_e,heading:Xe,cardForm:n(Vc,{addCardModalOpen:t,children:n(Ja,{paymentMethod:e})}),billingAddressSection:kt,afterBillingAddress:T?n(za,{forceVaultingEligible:!0,blockNegotiations:!0}):void 0,onSave:ke,loading:N||P,createAddressForm:Qt})]})}function Hc(e){return e.current.value==="businessCustomer"}function Uc({open:e,onCancel:t,onSave:s,card:a,billingAddress:r,isDefaultCard:i,onDefaultCardChange:o,error:l,addressErrorsSignal:c,initialShowAddressForm:d=!1}){const{i18n:u,checkout:p}=A(),m=Fo(),g=p.configuration.addressSettings.billingAddressSettings.value,{nickname:f}=a,[v,h]=J(!1),y=we(!1),_=we(f);O(()=>{e&&(y.value=d,_.value=f)},[e,f,y,_,d]);const b=async()=>{h(!0),await s(r,_.value)&&t(),h(!1)},S=async N=>await s(N,_.value)?{id:"edit-card-billing",address:N}:void 0,C=f!==void 0,P=o!==void 0,M=()=>n(G,{children:[l&&n(F,{gap:"base",padding:"base none",children:n(Re,{tone:"critical",errorType:Fe.PaymentError,children:l})}),P&&n(G,{children:[n(st,{id:"default",name:"default",checked:i??!1,onChange:o,label:u.translate("payment.edit_credit_card_modal.fields.default")}),n(ge,{blockSize:"small-200"})]}),n($,{children:u.translate("edit_credit_card_modal.edit_address_only_note")}),n(ge,{blockSize:"small-200"}),n(Gt,{disabled:!1,onSubmit:b,children:n(Kn,{children:[n($e,{name:"cardNumber",label:u.translate("payment.card_number_label"),readOnly:!0,value:`···· ···· ···· ${a.lastDigits}`,disabled:!0}),n(yn,{children:[n($e,{name:"expiryLabel",label:u.translate("payment.card_expiry_label"),readOnly:!0,value:ni(a.expiryMonth,a.expiryYear),disabled:!0}),n($e,{name:"cardVerification",label:u.translate("payment.card_verification_value_label"),readOnly:!0,value:"···",disabled:!0})]}),n($e,{name:"cardHolderName",label:u.translate("payment.name_on_card_label"),readOnly:!0,value:a.cardholderName||"············",disabled:!0}),C&&n($e,{name:"cardNickname",label:u.translate("payment.card_nickname_label"),value:_.value||"",onChange:N=>{_.value=N},maxLength:Zs})]})}),n(ge,{blockSize:"base"}),n(fe,{border:"base",borderRadius:"base",padding:"none base",children:n(At,{label:u.translate("payment_ux.bill_to"),primaryAction:n(Ge,{variant:"plain",accessibilityLabel:u.translate("edit_credit_card_modal.edit_button"),onClick:()=>{y.value=!0},children:n($,{children:u.translate("edit_credit_card_modal.edit_button")})}),primaryContent:n(La,{address:r,nameLinePosition:"block"})})})]}),I=n(_t,{submitText:u.translate("payment.card_form.save"),cancelText:u.translate("payment.card_form.cancel"),loading:v,disabled:v,handleSubmit:b,handleCancel:t});return n(St,{open:e,heading:y.value?u.translate("edit_credit_card_modal.edit_address_title"):u.translate("edit_credit_card_modal.edit_card_title"),onHide:t,primaryAction:y.value?void 0:I,children:n(Ee,{when:y,fallback:M(),children:n(Zt,{onCancel:()=>{y.value=!1},onSuccess:t,onSave:S,cancelText:u.translate("credit_card_form.go_back"),saveText:u.translate("edit_credit_card_modal.save_billing_address"),editableAddress:pt(r,{extendedAddressMode:p.address.extendedAddressMode}),addressType:"billing",countriesOverride:m.value,addressErrorsSignal:c,addressSettings:g})})})}async function $c({address:e,defaultPaymentMethod:t,token:s,onEditCardSubmit:a,negotiate:r}){const{token:i}=await a({defaultPaymentMethod:t,address:e,token:s});return i?new Promise(o=>{r({fieldsToResolve:["paymentMethods"],force:!0,onComplete(l){o(l.status==="success")}})}):!1}function Gc({paymentMethodId:e,cvvError:t}={}){const{i18n:s}=A(),{sdk:a,validate:r,loading:i}=Ie(),o=re(),l=t==="INCORRECT_CVC"?s.translate("payment_errors.incorrect_cvc"):null;return O(()=>(i||a.setErrors({verification_value:l}),()=>{a.setErrors({verification_value:null})}),[a,l,i]),nt(async({reason:c})=>{if(c!=="completion")return{behavior:"allow"};const{isValid:d}=r(!0);if(!d)return{behavior:"block",reason:He.CvvFieldIsInvalid};const u=await a.vaultCard(),p=o.paymentLines.peek();return o.paymentLines.value=p.map(m=>
2m.method.type!==xe.CreditCard||e&&m.method.token!==e?m:{...m,method:{...m.method,cvvSessionId:u}}),{behavior:"allow"}}),n(fe,{children:[n(ge,{blockSize:"base"}),n(Xi,{}),n(ge,{blockSize:"base"}),n(F,{gap:"small-300",children:[n(de,{color:"subdued",children:s.translate("payment.saved_credit_card_cvv_verification")}),n(Ve,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1.5fr) minmax(0, 1fr)",gridAutoColumns:"1fr",gridTemplateRows:"minmax(0, 1fr)",gap:"none",alignItems:"center",alignContent:"center",children:n(Xa,{cardBrands:[],prefillCardholderName:!1,cvvOnly:!0})})]})]})}function Wc(){const{i18n:e,checkout:{address:{extendedAddressMode:t}},graphql:{coreGraphql:s}}=A(),[a,r]=J("");return{onSubmit:async({address:l,defaultPaymentMethod:c,token:d})=>{if(!d)return{token:void 0};r("");const u=await Ao({graphql:s,address:l,extendedAddressMode:t,defaultPaymentMethod:c,token:d,genericError:e.translate("shipping.address_form.generic_error")});return u.error&&r(u.error),{token:u.token}},error:a,resetError:()=>r("")}}async function Yc({token:e,savedCreditCards:t,newCardValue:s,setSelected:a,deleteVaultedCreditCard:r,negotiate:i,onComplete:o}){if(t.length===1)a("direct");else{const c=t.find(d=>d.token!==e);if(c){const d=s?"direct":De(c);a(d)}}const{token:l}=await r(e);l&&await i({fieldsToResolve:["paymentMethods"],force:!0,onComplete(c){c.status==="success"&&o()}})}function qc(e){if(e.immutableAddresses.value.find(a=>a.id===xt)){e.selectAddress(xt);return}const s=e.suggestedAddress.value;s.address&&e.createAddress({address:s.address})}function Kc({billingAddress:e,billingAddressOption:t,shippingAddress:s}){const{countryCode:a,zoneCode:r}=e.value??{};e.value={...si(void 0,a,r),...s.value},t.value="shipping"}function jc({newCardSignal:e,savedCreditCards:t,setSelected:s,paymentLines:a,acceptPaymentVaulting:r,isBusinessCustomer:i,billingManager:o,billingAddress:l,billingAddressOption:c,shippingAddress:d,onComplete:u}){if(!e.value)return u?.(),!1;e.value=void 0,r.value=!1;const p=t[0];return p?(s(De(p)),o&&qc(o)):a.value=a.value.filter(m=>m.method.type!=="direct"),i||Kc({billingAddress:l,billingAddressOption:c,shippingAddress:d}),u?.(),!0}function Xc(){const{i18n:e,graphql:{coreGraphql:t}}=A(),[s,a]=J("");return{onSubmit:async o=>{if(!o)return{token:void 0};a("");const l=await Po({graphql:t,token:o,genericError:e.translate("customer_payment_methods.delete_customer_mandate.generic_error")});return l.error&&a(l.error),{token:l.token}},error:s,resetError:()=>a("")}}class Jc extends Error{constructor(){super(...arguments),this.name="DeleteCardModalError"}}function Zc({paymentToDelete:e,onClose:t,setSelected:s}){const{checkout:a,i18n:r,observability:i}=A(),o=a.addressManager.billing.value,{negotiate:l}=$t(),{paymentMethods:c,shippingAddress:d,buyerIdentity:u}=be(),p=In(c.value),m=Xt(),{acceptPaymentVaulting:g,billingAddress:f,billingAddressOption:v,paymentLines:h}=re(),[y,_]=J(!1),b=u.value?.purchasingCompany,{onSubmit:S,error:C,resetError:P}=Xc(),M=async()=>{_(!0);try{e?.token?await Yc({token:e.token,savedCreditCards:p,newCardValue:m.value,setSelected:s,deleteVaultedCreditCard:S,negotiate:l,onComplete:t}):e?.id===Oe?jc({newCardSignal:m,savedCreditCards:p,setSelected:s,paymentLines:h,acceptPaymentVaulting:g,isBusinessCustomer:!!b,billingManager:o,billingAddress:f,billingAddressOption:v,shippingAddress:d,onComplete:t}
2):i.error(new Jc("Delete pressed with no actionable paymentToDelete"))}finally{_(!1)}},I=()=>{t(),P()},N=C?n(F,{gap:"base",children:n(Re,{tone:"critical",errorType:Fe.PaymentError,children:C})}):null;return n(ca,{size:"base",open:!!e,heading:r.translate("payment.delete_credit_card_modal.title"),onHide:I,children:[n(F,{gap:"base",padding:"base none large-300 none",children:[N,n(de,{children:n($,{color:"subdued",children:r.translate("payment.delete_credit_card_modal.confirmation",{brandName:e?.brandLabel??"",lastDigits:e?.lastDigits??""})})})]}),n(_t,{submitText:r.translate("payment.delete_credit_card_modal.delete"),cancelText:r.translate("payment.delete_credit_card_modal.cancel"),submitButtonAppearance:"critical",handleSubmit:M,handleCancel:t,loading:y,disabled:y})]})}function Za({savedCreditCards:e,selected:t,setSelected:s,isSelected:a,isInModal:r,setSelectedSavedCreditCardBrand:i,addCardModalOpen:o,msiAvailable:l=!1}){const{userEvents:c,shop:{id:d,storeVaultEnabled:u,storeVaultGuestCvvVerificationEnabled:p},source:{checkoutSessionIdentifier:m}}=A(),g=Xt(),{bankIdNumberSignal:f,lastNegotiatedBinSignal:v}=Ne(),[h,y]=J(null),[_,b]=J(!1),{onSubmit:S,error:C,resetError:P}=Wc(),[M,I]=J(!1),N=W(()=>An(),[]),[D,T]=J(null),E=jt().value,B=o?.value??!1,w=re(),x=w.billingAddress.value,{getAccessibilityLabel:V}=ha(),z=L=>e.find(Q=>{const ue=L.split("-")[1];return Q.token===ue}),U=z(t),Y=g.value,j=a&&U?.requiresCvvConfirmation&&p&&!B&&!r,R=K(t);O(()=>{const L=R.current;if(R.current=t,i?.(U?.brand),t!==Oe){f.value=U?.firstDigits;return}if(E){const Q=Y?.creditCardFirstDigits;(!l||!ms(f.value,Q))&&(f.value=Q);return}L!==Oe&&(f.value=void 0)},[f,i,U,t,Y,E,l]),O(()=>{h&&I(h.defaultPaymentMethod)},[h]);const H=L=>{L===Oe&&T({id:L,lastDigits:g.value?.creditCardLastFourDigits??"",brandLabel:g.value?.brand?ut(g.value?.brand):""})},X=()=>{T(null)},{negotiate:q}=$t(),Z=k(L=>$c({address:L,defaultPaymentMethod:M,token:h?.token,onEditCardSubmit:S,negotiate:q}),[M,h,q,S]),ne=k(()=>{b(!1),P()},[P]),ie=L=>{const Q=z(L),ue=f.peek();let pe;L===Oe?pe=E?Y?.creditCardFirstDigits:void 0:pe=Q?.firstDigits,l&&L===Oe&&E&&ms(ue,pe)||(f.value=pe);const Ae=f.peek();l&&(w.paymentLines.value=Ji(w.paymentLines.value),v.value=Ae),q({force:!0,negotiationStage:"negotiation"}).catch(()=>{l&&v.peek()===Ae&&(v.value=void 0)}),s(L),Q&&Mo({userEvents:c,shopId:d,checkoutSessionIdentifier:m,card:Q})},ce={lastDigits:h?.displayLastDigits??"",expiryMonth:h?.expiryMonth??0,expiryYear:h?.expiryYear??0,cardholderName:h?.cardholderName??""};return n(Kt,{values:[t],onChange:L=>ie(L[0]??""),variant:"grid",children:[E&&n(Ee,{when:g,children:L=>n(Ce,{id:"direct",value:"direct",accessibilityLabel:V(L),children:L.brand&&L.creditCardLastFourDigits&&n(_n,{id:"direct",isVaultedCard:!1,brand:L.brand,displayLastDigits:L.creditCardLastFourDigits,displayCardholderName:L.cardholderName,displayAddress:x.address1,onDelete:H})},"direct")}),e.map(L=>{const Q=()=>{y(L),b(!0)},ue=()=>T({token:L?.token,lastDigits:L.displayLastDigits,brandLabel:L?.brand?ut(L?.brand):""});return n(Ce,{id:De(L),value:De(L),accessibilityLabel:V(L),children:n(_n,{id:De(L),isVaultedCard:!0,brand:L.brand,displayLastDigits:L.displayLastDigits,displayCardholderName:L.cardholderName||void 0,displayAddress:L.billingAddress.address1,requiresVerification:p&&L?.requiresCvvConfirmation,onEdit:u?Q:void 0,onDelete:u&&L.deletable?ue:void 0})},De(L))}),(E||u)&&n(G,{children:[n(Zc,{setSelected:s,paymentToDelete:D,onClose:X}),h&&n(Uc,{open:_,onCancel:ne,onSave:Z,card:ce,billingAddress:h.billingAddress,isDefaultCard:M,onDefaultCardChange:I,error:C,addressErrorsSignal:N})]}),j&&n(Gc,{})]})}function Qa({numExpired:e}){const{i18n:t}=A();return n(de,{type:"small",color:"subdued",children:t.translate("payment.expired_cards_info",{count:e})})}function Qc({savedCreditCards:e,selected:t,setSelected:s,isSelected:a,isModalOpen:r,onModalClose:i}){const{i18n:o}=A(),l=Eo(),[c,d]=J(t);O(()=>{d(t)},[t]);const u=()=>{i(),c&&s(c)},p="@media (inline-size >= small) fit-content, fill",m=n(Ge,{variant:"primary",inlineSize:p,onClick:u,children:o.translate("payment.saved_credit_cards_modal.done")}),g=n(Ge,{variant:"plain",inlineSize:p,onClick:i,children:o.translate("payment.saved_credit_cards_modal.cancel")});return n(ca,{open:r,heading:o.translate("payment.saved_credit_cards_modal.view_all_label"),onHide:i,primaryAction:m,secondaryActions:g,children:n(F,{gap:"small-300",children:[n(Za,{savedCreditCards:e,selected:c,setSelected:f=>d(f),isSelected:a,isInModal:!0}),n(ge,{blockSize:"small-500"}),n(Ee,{when:l,children:f=>n(Qa,{numExpired:f})})]})})}function eu({offsite:e=!1,paymentMethod:t,setSelected:s,isSelected:a,showExistingCreditCards:r=!0,setSelectedSavedCreditCardBrand:i,cardNumberAccessory:o}){const{i18n:l,checkout:{identity:c},userEvents:d,shop:{id:u},source:{checkoutSessionIdentifier:p}}=A(),m=xn(t),{paymentMethods:g}=be(),f=r?au({identity:c},g.value):[],v=f.length>0,h=Xt(),[y,_]=J(f),b=y?.length>4,[S,C]=J(!1),P=()=>C(!1),M=ai().value,I=M.length,N=I>0,{paymentLines:D}=re(),T=D.value,E=v?tu(T,y):Oe,B=E===Oe,w=q=>{s(q),_(Z=>su(q,Z))},x=jn(),V=r?x.value:void 0,z=jt().value,U=we(!1),{resetTouched:Y}=Ie(),j=Ca(),R=()=>{j(),Y()},H=q=>{s(q),R()},X=(q,Z)=>{const ne=L=>L.expired?{isHidden:!0,hiddenReason:"expired"}:Z>=4?{isHidden:!0,hiddenReason:"pagination"}:{isHidden:!1,hiddenReason:""},{isHidden:ie,hiddenReason:ce}=ne(q);d.monorailEvent({schemaId:"checkout_vaulted_payment_method_rendered/1.0",payload:{shopId:parseInt(un(u),10),checkoutSessionIdentifier:p||"",paymentMethodId:parseInt(un(q.id),10),paymentInstrumentAccessorId:-1,isSelectedByDefault:E===De(q),order:Z,cvvRequired:q.requiresCvvConfirmation||!1,isHidden:ie,hiddenReason:ce}})};return O(()=>{V?i(V.brand):!h.value&&!v&&i(void 0)},[i,V,h.value,v]),O(()=>
2{_(f),[...f,...M].forEach(X)},[JSON.stringify(f)]),n(F,{gap:"base",children:[v&&n(G,{children:[n(Za,{savedCreditCards:nu(y),selected:E,setSelected:H,isSelected:a,setSelectedSavedCreditCardBrand:i,addCardModalOpen:U,msiAvailable:m}),m&&(!B||h.value?.creditCardFirstDigits)&&n(ga,{paymentMethod:t,isSelected:a,canEditBin:!1}),n(F,{gap:"base",alignItems:"start",children:[b&&n(G,{children:[n(We,{onClick:()=>C(!0),children:n(F,{direction:"inline",gap:"small-200",alignItems:"center",children:[n(Me,{type:"arrow-up-right",size:"small"}),l.translate("payment.saved_credit_cards_modal.view_all_label")]})}),n(Qc,{savedCreditCards:y,selected:E,setSelected:w,isSelected:a,isModalOpen:S,onModalClose:P})]}),z?n(zc,{paymentMethod:t,addCardModalOpen:U}):n(st,{id:"selectDirectPaymentMethod",name:"selectDirectPaymentMethod",checked:B,onChange:q=>{R(),s(q?Oe:De(y[0]))},label:l.translate("payment.use_different_credit_card_label")})]})]}),z&&v?null:n(Wt,{id:"directPaymentMethodDetails",open:B,children:n(Ja,{offsite:e,paymentMethod:t,sessionCard:V,isSelected:a,cardNumberAccessory:o},E)}),N&&!b&&n(Qa,{numExpired:I})]})}function tu(e,t){const s=t.find(r=>r.defaultPaymentMethod),a=e.find(r=>[xe.CreditCard,"direct"].includes(r.method.type))?.method;return a?a.type===xe.CreditCard?De(a):a.type:De(s||t[0])}function nu(e){return e.slice(0,4)}function su(e,t){const[s,a]=e.split("-");let r;const i=t.filter(o=>(o.token===a&&(r=o),o.token!==a));return[r,...i]}function au({identity:e},t){return e.current.value==="shopPay"?[]:In(t)}const ru="YuaRt",iu="BqUj3",Ls={EndIcons:ru,EndIconsContent:iu};function Zn({setSelected:e,isSelected:t,paymentMethod:s,bare:a,iconPlacement:r="end",showExistingCreditCards:i=!0,disabled:o,details:l,selectedContentFooter:c}){const{i18n:d,checkout:u}=A(),{identity:p}=u,{bankIdNumber:m,filled:g,touched:f}=Ie(),{setSelectedSavedCreditCardBrand:v}=Ct(),{bankIdNumberSignal:h,directPaymentFieldsFilled:y}=Ne(),{variant:_}=Dn(),{paymentLines:b}=re(),C=xn(s)&&b.value.length>0&&b.value.every(q=>q.method.type===xe.CreditCard);O(()=>{C||(m||f.number)&&(h.value=m)},[m,h,f.number,C]),O(()=>{const q=(s.checkoutHostedFields??dd).filter(ld);return y.value=q.every(Z=>g[Z]),()=>{y.value=!1}},[y,g,s.checkoutHostedFields]);const P=u.installments.paymentMethodMustSupportDebitCardOnly.value,M=r==="cardNumber",I=r==="inline",N=r==="end",D=a===!0&&M,T=_!==ri.Control,{ref:E,overflowIndicatorRef:B,maxVisibleBrands:w}=cl(s.paymentBrands.filter(zt).length),x=n(ll,{animate:T,announceNetworkSelector:N,announceOverflowBrands:D,size:M||I?"small":void 0,maxVisibleBrands:N?w.value:void 0,overflowIndicatorRef:N?B:void 0}),V=n(G,{children:[n(ou,{isSelected:t,customHostedFields:s.checkoutHostedFields}),n(eu,{offsite:!1,paymentMethod:s,setSelected:e,isSelected:t,showExistingCreditCards:i,setSelectedSavedCreditCardBrand:v,cardNumberAccessory:M?x:void 0})]}),z=c?n(F,{gap:"base",children:[V,c]}):V;if(a)return z;const U=lu({identity:p,i18n:d},P,s),Y=Ht(d,s.paymentBrands,void 0,N?w.value:void 0),j=Y?`${U}, ${Y}`:U,R=n(at,{type:"generic",accessibilityVisibility:"hidden"}),X={end:n("div",{ref:E,className:Ls.EndIcons,children:n(F,{direction:"inline",gap:"none",alignItems:"center",justifyContent:"end",className:Ls.EndIconsContent,children:x})}),cardNumber:R,inline:void 0}[r];return n(G,{children:n(Ce,{value:le(s),disabled:o,details:l,secondaryContent:X,renderSelectedContentWhenCollapsed:!0,selectedContent:z,accessibilityLabel:j,children:I?n(F,{direction:"inline",gap:"small-200",alignItems:"center",children:[n($,{type:"strong",children:U}),x]}):n($,{type:"strong",children:U})})})}function ou({isSelected:e,customHostedFields:t}){return ud(e,t),null}function lu({identity:e,i18n:t},s,a){return $s({identitySource:e.current.value,i18n:t},a,{forceDebitCardLabel:s})}function du({method:e,onSelect:t,vaultHandle:s,blockFooter:a,selectedContentFooter:r}){const i=qn(),o=Xn(),l=le(e);return n(F,{gap:"base",children:[n(yt,{publishesCardNetworkDetection:!0,directPaymentMethodConfig:e,blurValidationEnabled:!0,blurValidationFieldDenylist:o.value,onSetFieldErrors:i,children:[n(Jn,{handle:s}),n(Zn,{id:l,paymentMethod:e,setSelected:t,isSelected:!0,bare:!0,selectedContentFooter:r})]}),a]})}function cu({inlinePaymentMethod:e=!1}){const{i18n:t}=A(),s=Zi({clearPii:!1});return n(fe,{padding:e?"none":"base",children:n(je,{onClick:s,inlineSize:"100%",children:n(F,{direction:"inline",gap:"small-200",alignItems:"center",children:[n($,{tone:"accent",children:t.translate("credit_card_form.more_payment_options")}),n(Me,{type:"arrow-up-right",size:"small",tone:"accent"})]})})})}function uu({identity:e,guestCheckoutPaymentMethodCount:t,inlinePaymentMethod:s=!1}){return e.current.value!=="shopPay"||t===0?null:n(cu,{inlinePaymentMethod:s})}
2function mu({id:e,displayName:t}){const{i18n:s}=A(),a=t??s.translate("payment_gateway.deferred_payment_label");return n(Ce,{value:e,accessibilityLabel:a,children:n($,{type:"strong",children:a})})}const pu=["BANCONTACT","IDEAL"];function er(e){return pu.includes(e)}function fu({name:e}){return er(e)?null:n(gn,{paymentBrands:[e]})}function yu({name:e,displayName:t}){return n(G,{children:er(e)?n(at,{type:e}):n($,{type:"strong",children:t})})}function hu({name:e,displayName:t}){return n(Ce,{value:e,secondaryContent:n(fu,{name:e}),accessibilityLabel:t,children:n(yu,{name:e,displayName:t})})}function gu({manualPaymentMethod:e}){const t=be().alternativePaymentCurrency,s=et("alternativePaymentCurrency"),{i18n:a}=A(),r=he(()=>{if(!s.value)return t.value});return n(F,{gap:"base",children:n(Bn,{children:n(Ee,{when:r,fallback:n(ua,{inlineSize:"base"}),children:i=>{const o={amount_due:n($,{type:"strong",children:a.formatCurrency(i.totalWithoutGiftCards.amount,{currency:i.totalWithoutGiftCards.currencyCode,form:"explicit"})})};return e?a.translate("payment.alternative_payment_currency_total_manual_payment_notice",o):a.translate("payment.alternative_payment_currency_total_notice",o)}})})})}function tr({additionalDetails:e,alignItems:t}){const s=be().alternativePaymentCurrency,{hasNegotiatedAlternativePaymentCurrencySignal:a}=Ne(),r=Qs(),i=he(()=>r.value&&a.value||!!s.value),o=e?.trim();return!o&&!i.value?null:n(F,{alignItems:t,gap:"large-100",children:[o?n(de,{children:n(Bn,{children:e})}):null,n(Ee,{when:i,children:n(gu,{manualPaymentMethod:!0})})]})}function _u({id:e,label:t,additionalDetails:s,showSelectedContent:a=!0}){return n(Ce,{value:e,selectedContent:a?n(tr,{additionalDetails:s}):void 0,accessibilityLabel:t,children:n($,{type:"strong",children:t})})}function vu({id:e,additionalDetails:t,name:s,showSelectedContent:a=!0}){const r=On();return n(Ce,{value:e,selectedContent:a?n(tr,{additionalDetails:t,alignItems:r?void 0:"center"}):void 0,accessibilityLabel:s,children:n($,{type:"strong",children:s})})}function bu({bare:e}){return e?null:n(Ce,{value:"PAYPAL_EXPRESS"})}const Qn=Ot({displayName:"PayPalExpressPaymentMethod",load:()=>Vt(()=>bt(()=>import("./component-PayPalExpressPaymentMethod.DJn-dors.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53]))),renderLoading:bu});function Cu(){const{i18n:e}=A(),t=e.translate("brand.apple_pay");return n(Ce,{value:"APPLE_PAY",secondaryContent:n(Yn,{wallet:"APPLE_PAY",size:"xxxsmall"}),accessibilityLabel:t,children:n($,{type:"strong",children:t})})}function Su(){const{checkout:e,router:t}=A(),{validation:{contactErrors:{emailInputError:s,phoneInputError:a}}}=e,{origin:r,prefix:i,searchParams:o}=t.currentUrl.value,{deliveryMethodsAddressErrors:l}=Ne(),{nextPage:c}=Qi(),{resetAddressErrors:d}=eo(l),u=to().current.token,p=e.configuration.renderContextToken.token.value;nt(async({parts:m,reason:g})=>{if(g==="completion"||g==="progression"&&c.id==="review"){const v=m.paymentLines.peek()[0]?.method,h=o.get("channel");if(v?.type==="wallet"&&v.name==="SHOPIFY_INSTALLMENTS"){const _=new URLSearchParams;_.set("payment","shop_pay"),_.set(ii,oi.ShopPayInstallmentsAsPaymentMethod),u&&_.set(li,u),h&&_.set("channel",h),p?_.set("rctx",p):_.delete("rctx");const b=`${r}${i}?${_.toString()}`;return{behavior:"block",reason:He.RedirectingToShopPay,perform(){s.value=void 0,a.value=void 0,d(),window.location.assign(b)}}}}return{behavior:"allow"}})}const Au="â¢";function ks({label:e,installmentsLabel:t,installments:s}){return Su(),n(Ce,{value:"SHOPIFY_INSTALLMENTS",secondaryContent:n(Yn,{wallet:"SHOP_PAY",size:"xxxsmall"}),accessibilityLabel:e,children:n(F,{direction:"@media (inline-size >= extraSmall) inline, block",gap:"small-400",children:[n($,{type:"strong",children:e}),s&&n(G,{children:[n(fe,{display:"@media (inline-size >= extraSmall) auto, none",children:n($,{color:"subdued",children:Au})}),n($,{color:"subdued",children:t})]})]})})}function nr({method:e,showSelectedContent:t=!0,bare:s=!1}){const{i18n:a}=A();switch(e.name){case"PAYPAL_EXPRESS":return n(Qn,{method:e,showSelectedContent:t,bare:s});case"APPLE_PAY":return s?null:n(Cu,{});case"SHOPIFY_INSTALLMENTS":{if(s)return null;const r=a.translate("payment_gateway.shop_pay.name"),i=a.translate("payment_gateway.shop_pay.installments_label");return n(ks,{label:r,installmentsLabel:i,installments:!0})}case"SHOP_PAY":{if(s)return null;const r=a.translate("payment_gateway.shop_pay.name");return n(ks,{label:r})}case"GOOGLE_PAY":return null;case"VENMO":return null;default:gt(e)}}const Pu="H3Xuw",Mu="ldo89",ws={Content:Pu,Redesigned:Mu};function Eu({children:e}){const t=On();return n("div",{className:ze(ws.Content,t&&ws.Redesigned),children:e})}function Iu({label:e,bare:t=!1}){const{descriptor:s,brand:a}=Io().value,r=On()||t,i=n(Eu,{children:n(F,{gap:"base",alignItems:r?"start":"center",children:n(F,{direction:"inline",gap:"base",children:[n(Lo,{brand:a,descriptor:s}),n(ko,{})]})})});return t?n(G,{children:[n(ps,{isSdkOnly:!0}),i]}):n(G,{children:[n(ps,{isSdkOnly:!0}),n(Ce,{value:mt.AmazonPay,selectedContent:i,secondaryContent:n(fe,{blockAlignment:"center",children:n(Yn,{wallet:mt.AmazonPay,size:"small"})}),accessibilityLabel:e,children:n($,{type:"strong",children:e})})]})}function sr({method:e,bare:t=!1}){const{i18n:s,checkout:a}=A(),r=a.configuration.layout.isOnePage.value;switch(e.name){case mt.AmazonPay:{const i=s.translate("brand.amazon_pay");return r?null:n(Iu,{label:i,bare:t})}case mt.BuyWithPrime:return null;default:return gt(e.name)}
2}const Lu={PAYPAL_EXPRESS:"paypal",APPLE_PAY:"apple_pay",GOOGLE_PAY:"google_pay",SHOP_PAY:"shop_pay",amazon_pay:"amazon_pay"};function _p(e){if("paymentBrands"in e&&Array.isArray(e.paymentBrands))return e.paymentBrands;if("name"in e&&e.name){const t=Lu[e.name];return t?[t]:[]}return[]}function es(e){return"name"in e?e.name:e.type}function ar(e,t){return!e||!t||e.length!==t.length?!1:e===t?!0:t.every((s,a)=>ku(s,e[a]))}function ku(e,t){return e===t?!0:!e||!t?!1:Vs(Ns(e),Ns(t))}function Ns(e){const t=es(e),{type:s,orderingIndex:a}=e;return{type:s,name:t,orderingIndex:a}}function wu({identity:e,methodCount:t}){return t!==1?!1:e.current.value==="shopPay"?mo:!0}function ts({value:e,label:t,accessibilityLabel:s=t,showIconPlaceholder:a=!1}){const{i18n:r}=A();return n(Ce,{value:e,accessibilityLabel:s,secondaryContent:n(G,{children:[a?n(ma,{inlineSize:Ft(Rt.base.inlineSize),blockSize:Ft(Rt.base.blockSize),contentDisplay:"block"}):null,n($,{accessibilityVisibility:"exclusive",children:r.translate("general.loading")})]}),children:n($,{type:"strong",children:t})})}function Nu({id:e,method:t}){const{i18n:s}=A();return n(ts,{value:e,label:t.displayName??s.translate("payment.bank_payment_method_label"),showIconPlaceholder:!0})}const rr=Ot({displayName:"BankPaymentMethod",useError:Vn("BankPaymentMethod"),load:()=>Vt(async()=>({default:(await bt(async()=>{const{BankPaymentMethod:e}=await import("./component-lazyBankPaymentMethod.Cp6A7LlR.js");return{BankPaymentMethod:e}},__vite__mapDeps([54,1,2,3,4,5,6,7,8,9,10,11,12,13,14,23,24,27,55,56,22,57,33,41,42,43,44,45,46,47,48,49,50,38,39,51,52,21,25,26,28,29,30,31,32,34,35,36,15,16,17,37,40,53,58]))).BankPaymentMethod})),renderLoading:({id:e,method:t,bare:s})=>s?null:n(Nu,{id:e,method:t})});function Tu({id:e,method:t,bare:s}){const{i18n:a}=A();if(!Rn("Checkout::PaymentMethod::Render",t.uiExtension===void 0?[]:[t.uiExtension]).length||s)return null;const i=Ht(a,t.paymentBrands),o=i?`${t.name}, ${i}`:t.name;return n(ts,{value:e,label:t.name,accessibilityLabel:o,showIconPlaceholder:!0})}const ir=Ot({displayName:"CustomOnsitePaymentMethod",useError:Vn("CustomOnsitePaymentMethod"),load:()=>Vt(async()=>({default:(await bt(async()=>{const{CustomOnsitePaymentMethod:e}=await import("./component-lazyPaymentMethods.BflrObBP.js");return{CustomOnsitePaymentMethod:e}},__vite__mapDeps([59,1,3,4,5,6,7,8,9,10,11,2,12,13,14,29,26,30,21,22,23,24,25,27,28,31,32,33,34,35,36,15,16,17,37,38,39,40,19,20,41,42,43,44,45,46,47,48,49,50,51,52,53,60]))).CustomOnsitePaymentMethod})),renderLoading:e=>n(Tu,{...e})});function Du({name:e,paymentBrands:t}){const{i18n:s}=A(),a=Ht(s,t),r=a?`${e}, ${a}`:e;return n(ts,{value:e,label:e,accessibilityLabel:r,showIconPlaceholder:!0})}const or=Ot({displayName:"OffsitePaymentMethod",useError:Vn("OffsitePaymentMethod"),load:()=>Vt(async()=>({default:(await bt(async()=>{const{OffsitePaymentMethod:e}=await import("./component-lazyPaymentMethods.BflrObBP.js");return{OffsitePaymentMethod:e}},__vite__mapDeps([59,1,3,4,5,6,7,8,9,10,11,2,12,13,14,29,26,30,21,22,23,24,25,27,28,31,32,33,34,35,36,15,16,17,37,38,39,40,19,20,41,42,43,44,45,46,47,48,49,50,51,52,53,60]))).OffsitePaymentMethod})),renderLoading:({name:e,paymentBrands:t,bare:s})=>s?null:n(Du,{name:e,paymentBrands:t})}),lr={offsite:or,customOnsite:ir,bank:rr};function dr(){const e=or.useLoadState(),t=ir.useLoadState(),s=rr.useLoadState();return k(a=>{switch(a.type){case"offsite":return e;case"customOnsite":return t;case"bank":return s;default:return}},[e,t,s])}const{offsite:Fu,customOnsite:Bu,bank:xu}=lr;function Ru({methods:e,selected:t,onSelect:s,renderAsBareCard:a,vaultHandle:r,blockFooter:i,choiceListName:o="basic",showSelectedContent:l=!0,showExistingCreditCards:c=!0,radioControlMethodCount:d,directMethodDisabled:u=!1,directMethodDetails:p,directMethodSelectedContentFooter:m}){const g=qn(),{checkout:{identity:f}}=A(),v=Xn(),h=W(()=>t?[t]:[],[t]),y=k(([_])=>{_&&s(_)},[s]);return n(Kt,{name:o,values:h,hideRadioControl:wu({identity:f,methodCount:d??e.length}),onChange:y,variant:a?"list":"block",blockFooter:i,children:e.map(_=>{const b=le(_),S=t===b;return _.type==="direct"?n(yt,{publishesCardNetworkDetection:!0,directPaymentMethodConfig:_,blurValidationEnabled:!0,blurValidationFieldDenylist:v.value,onSetFieldErrors:g,children:[S&&n(Jn,{handle:r}),n(Zn,{id:b,paymentMethod:_,setSelected:s,isSelected:S,bare:a,showExistingCreditCards:c,disabled:u,details:p,selectedContentFooter:S?m:void 0})]},b):_.type==="wallet"?n(yt,{blurValidationFieldDenylist:v.value,onSetFieldErrors:g,children:n(nr,{method:_,showSelectedContent:l})},b):_.type==="walletsPlatform"?n(sr,{method:_},b):_.type===xe.PayPal?n(Qn,{method:_,showSelectedContent:l}
2,b):_.type==="local"?n(hu,{name:_.name,displayName:_.displayName},b):_.type==="paymentOnDelivery"?n(vu,{id:_.type,additionalDetails:_.additionalDetails,name:_.name,showSelectedContent:l},b):_.type==="manualPayment"||_.type==="customManualPayment"?n(_u,{id:`${_.type}-${_.id}`,label:_.name,additionalDetails:_.additionalDetails,showSelectedContent:l},b):_.type==="offsite"?n(Fu,{name:_.name,paymentBrands:_.paymentBrands,showRedirectionNotice:_.showRedirectionNotice,showSelectedContent:l},b):_.type==="deferred"?n(mu,{id:_.type,displayName:_.displayName},b):_.type==="customOnsite"?n(Bu,{id:_.name,selected:l&&S,method:_,showSelectedContent:l},b):_.type==="bank"?n(xu,{id:b,method:_,setSelected:s,showSelectedContent:l},b):null})})}function Ou(){const{i18n:e}=A();return n(qt,{tone:"warning",children:e.translate("payment_errors.test_mode_enabled_only_test_cards")})}function Vu(){const{client:e}=A();return e.unstable_getSerialization("invoiceLoginType")}function cr(){const[e,t]=J(!0),s=Vu(),a=be().buyerIdentity.value?.purchasingCompany,{client:r,i18n:i}=A();function o(){t(!1)}const l=(()=>{const d=r.unstable_getSerialization("loginUrl")||"";switch(s){case no:return i.translate("payment_gateway.login_prompt.no_access.message",{logIn:n(We,{tone:"monochrome",href:d,children:i.translate("payment_gateway.login_prompt.no_access.link")})});case cs:case void 0:return null}return null})();return e&&s&&a&&l?n(qt,{onDismiss:o,tone:s===cs?"success":"info",children:l}):null}cr.displayName="OrderInvoiceLoginBanner";function zu({selectedPaymentMethod:e}){const{i18n:t}=A(),s=so(),a=Os(e),r=Gs(),i=be(),o=et("paymentFlexibilityPaymentTermsTemplate"),l=ra(),c=t.numberFormatter({style:"percent",minimumFractionDigits:0,maximumFractionDigits:2}),d=he(()=>{const u=i.paymentFlexibilityPaymentTermsTemplate.value,p=i.depositConfiguration.value,m=a.value==="deferred",g=a.value==="creditCards",f=u?.type==="FIXED",v=u?.type==="FULFILLMENT",h=u?.type==="RECEIPT",y=p?.percentage?c.format(p?.percentage/100):null;if(r.value)return f?t.translate("payment_gateway.draft_order_payment_due_later_terms",{translatedName:u.translatedName.toLocaleLowerCase()}):v?y?t.translate("payment_gateway.draft_order_deposit_due_on_fulfillment",{depositAmount:y}):t.translate("payment_gateway.draft_order_payment_due_on_fulfillment"):u==null?m?t.translate("payment_gateway.draft_order_payment_due_later_no_terms"):t.translate("payment_gateway.draft_order_payment_due_later_no_terms_payment_selected"):y?t.translate("payment_gateway.draft_order_deposit_due_later",{depositAmount:y,translatedName:u.translatedName}):t.translate("payment_gateway.draft_order_payment_due_later_terms",{translatedName:u.translatedName});if(u==null||l.value)return;if(v){if(y)return t.translate("payment_gateway.order_deposit_due_on_fulfillment",{depositAmount:y});if(g)return t.translate("payment_gateway.order_due_on_fulfillment_payment");if(m)return t.translate("payment_gateway.order_due_on_fulfillment_choose_later")}if(h)return y?t.translate("payment_gateway.order_deposit_due_on_receipt",{depositAmount:y}):t.translate("payment_gateway.order_due_on_receipt_choose_later");if(!u.dueDate)return;const _={translatedName:u.translatedName,dueDate:s(u.dueDate)};return g&&!y?f?t.translate("payment_gateway.fixed_direct_payment_terms",{dueDate:_.dueDate}):t.translate("payment_gateway.direct_payment_terms",_):f?y?t.translate("payment_gateway.order_deposit_due_on_fixed_date",{depositAmount:y,dueDate:_.dueDate}):t.translate("payment_gateway.fixed_payment_label",{dueDate:_.dueDate}):y?t.translate("payment_gateway.order_deposit_due_now",{depositAmount:y,..._}):t.translate("payment_gateway.generic_payment_terms",_)});return n(Ee,{when:d,children:n(qt,{tone:"info",children:n(Ee,{when:()=>!o.value,fallback:n(ua,{inlineSize:"large"}),children:d})})})}function Hu(){const{paymentErrors:e}=pa().value,t=n(ao,{errors:e,errorType:Fe.PaymentError});return e.length>0&&t}function Uu({selectedPaymentMethod:e}){const{shopPay:t,source:s}=A(),a=t.user.hasFlag(Uo);return n(G,{children:[n(Hu,{}),ro(s.type)&&n(cr,{}),a&&n(Ou,{}),n(zu,{selectedPaymentMethod:e})]})}const{inlineSize:$u,blockSize:Gu}=Rt.base;function Wu(e,t){if(e)return n(ma,{inlineSize:Ft($u),blockSize:Ft(Gu),contentDisplay:"block"});if(t)return n(at,{type:t})}function Yu({identity:e}){return e.current.value}function qu({methods:e,selected:t,onSelect:s,selectorShowsTiles:a,tileSupportedCustomOnsitePaymentMethods:r}){Cn(()=>
2{if(a)return a.value=!0,()=>{a.value=!1}},[a]);const{i18n:i,checkout:o}=A(),l=o.configuration.layout.isOnePage.value,c=dr(),d=sa(),u=aa(d),p=o.installments.paymentMethodMustSupportDebitCardOnly.value,m=W(()=>t?[t]:[],[t]),g=k(([f])=>{f&&s(f)},[s]);return n(Kt,{name:"payment-tiles",label:i.translate("payment.payment_method"),labelAccessibilityVisibility:"exclusive",variant:"grid-compact",values:m,onChange:g,children:e.flatMap(f=>{const v=le(f),h=Ba(f,{i18n:i,identitySource:Yu({identity:o.identity}),isOnePageCheckout:l,isVenmoCheckout:u,forceDebitCardLabel:p,tileSupportedCustomOnsitePaymentMethods:r});if(!h)return[];const y=c(f)==="loading",_=y?i.translate("general.loading"):void 0,b=h.accessibilityLabel&&_?`${h.accessibilityLabel}, ${_}`:h.accessibilityLabel;return n(Ce,{value:v,icon:Wu(y,h.iconBrand),accessibilityLabel:b,children:[n($,{type:"strong",children:h.label}),_&&!b?n($,{accessibilityVisibility:"exclusive",children:_}):null]},v)})})}const Ts={loaded:!1},vp={start:"payment-transition-extensions-enter-start",end:"payment-transition-extensions-enter-end"},bp="payment-transition-extensions-clip";function Ku(){return Ar(async()=>{typeof window>"u"||(await bt(()=>Promise.resolve({}),__vite__mapDeps([61])),Ts.loaded=!0)}),Ts}const ju="Yqd2o",Xu="_9Jwvk",Ju={PaymentSelector:ju,PaymentDetails:Xu};function Ds({children:e,variant:t}){return Ku(),n("div",{className:`${Ju[Rs("Payment",t)]} payment-transition-${t}`,children:e})}const Zu="fMWDI",Qu="_6d3Zy",Fs={HideOnEmpty:Zu,RenderedButHidden:Qu},{offsite:em,bank:tm,customOnsite:nm}=lr;function sm({methods:e,selected:t,onSelect:s,vaultHandle:a,directMethodSelectedContentFooter:r}){return n(G,{children:e.map(i=>{const o=le(i),l=o===t,c=!l&&i.type==="direct";return n("div",{className:ze(Fs.HideOnEmpty,c&&Fs.RenderedButHidden),hidden:!l&&!c,"data-collapsed":!l,"aria-hidden":c||void 0,children:n(fe,{paddingBlockEnd:"large-100",children:n(am,{method:i,isSelected:l,onSelect:s,vaultHandle:a,directMethodSelectedContentFooter:r})})},o)})})}function am({method:e,isSelected:t,onSelect:s,vaultHandle:a,directMethodSelectedContentFooter:r}){const i=qn(),o=Xn(),l=le(e);switch(e.type){case"direct":return n(yt,{publishesCardNetworkDetection:!0,directPaymentMethodConfig:e,blurValidationEnabled:!0,blurValidationFieldDenylist:o.value,onSetFieldErrors:i,children:[t&&n(Jn,{handle:a}),n(Zn,{id:l,paymentMethod:e,setSelected:s,isSelected:t,bare:!0,selectedContentFooter:t?r:void 0,iconPlacement:"cardNumber"})]});case"offsite":return n(em,{name:e.name,paymentBrands:e.paymentBrands,showRedirectionNotice:e.showRedirectionNotice,bare:!0});case"bank":return n(tm,{id:l,method:e,setSelected:s,bare:!0});case"customOnsite":return n(nm,{id:l,method:e,selected:t,bare:!0});case"wallet":return e.name!=="PAYPAL_EXPRESS"?null:n(yt,{blurValidationFieldDenylist:o.value,onSetFieldErrors:i,children:n(nr,{method:e,bare:!0})});case"walletsPlatform":return n(sr,{method:e,bare:!0});case xe.PayPal:return n(Qn,{method:e,bare:!0});default:return null}}function rm({availablePaymentMethods:e,previousAvailablePaymentMethods:t,identity:s,shopPay:a,isApplePayAvailable:r}){if(s.current.value!=="shopPay")return;const i=e.map(c=>le(c)),o=t?.map(c=>le(c));if(i.every(c=>o?.includes(c)))return;const l=a.user.paymentMethodHistory.value;if(l.length!==0)for(const c of l){if(!c.lastUsedAt)continue;const d=e.find(u=>!!(r&&c.paymentMethod==="APPLE_PAY"&&mn(u)||u.type==="customOnsite"&&c.paymentMethod==="CUSTOM_ONSITE"&&"paymentBrand"in c&&(u.paymentBrands?.map(m=>m.toLowerCase())??[]).includes(c.paymentBrand.toLowerCase())));if(d)return le(d)}}function im(e,t){const s=e.map(r=>le(r)),a=t?.map(r=>le(r));return!s.every(r=>a?.includes(r))}const om=new Set(["direct","offsite","customOnsite","manualPayment","customManualPayment","paymentOnDelivery","local","wallet","walletsPlatform","deferred","bank"]);function lm(e){return om.has(e)}function dm(e){const t=new URLSearchParams(e),s=t.get(di);if(!s||!lm(s))return;const a=t.get(ci);return{paymentMethod:s,paymentMethodIdentifier:a||void 0}}function cm(e,t){if(t.paymentMethodIdentifier){const a=e.find(r=>r.type===t.paymentMethod&&"paymentMethodIdentifier"in r&&r.paymentMethodIdentifier===t.paymentMethodIdentifier);if(a)return a}return e.find(a=>a.type===t.paymentMethod)}function um({identity:e}){switch(e.current.value){case"guest":return"guest_checkout";case"shopPay":return"shop_pay_payment_options";default:return e.current.value}}
2function ur(e){return e.type===xe.CreditCard?De(e):le(e)}function mm(e,t,s,a,r,i,o,l,c){i.forEach((d,u)=>{const p=ur(d),m=!l&&p===r,g=l&&p===r;e.monorailEvent({schemaId:"checkout_payment_method_rendered/1.1",payload:{shopId:parseInt(un(t),10),checkoutSessionIdentifier:o||"",paymentMethodIdentifier:"paymentMethodIdentifier"in d?d.paymentMethodIdentifier:void 0,buyerCountryCode:c,eventTriggerReason:a,iterationNumber:s,orderInTheList:u,displayName:es(d)||"",isAutoSelected:m,isBuyerSelected:g,isOrderedFirst:u===0,isOrderedLast:u===i.length-1}})})}function mr(e){return"displayName"in e&&e.displayName?e.displayName:"name"in e&&e.name?e.name:e.type}function pm({availableMethods:e,seen:t,userEvents:s,source:a,checkout:r,shop:i}){r.identity.current.value==="shopPay"&&e?.forEach(o=>{const l=le(o);t.has(l)||(t.add(l),s.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...Pn(a,r,i),action:"payment_method_rendered",paymentMethodName:mr(o)}}))})}function fm(){const{userEvents:e,shop:t,source:s}=A(),{buyerIdentity:a,shippingAddress:r}=be(),{id:i}=t,{checkoutSessionIdentifier:o}=s,l=r.value?.countryCode||a.value?.countryCode,c=K(0),d=K(""),u=K([]),p=K(!1);return k(({displayedPaymentMethods:m,selectedPaymentMethod:g,buyerHasActed:f})=>{const v=g?ur(g):"",h=!ar(u.current,m);h&&c.current++;let y;!p.current&&m.length>0?(y="initialRender",p.current=!0):h?y="paymentMethodsChanged":d.current!==v&&(y=f?"buyerSelectedPaymentMethod":"autoSelectedPaymentMethod"),y&&mm(e,i,c.current,y,v,m,o,f,l),u.current=m,d.current=v},[l,o,e,i])}function ym({displayedPaymentMethods:e,selectedPaymentMethod:t,buyerHasActed:s}){const a=fm();O(()=>{a({displayedPaymentMethods:e,selectedPaymentMethod:t,buyerHasActed:s})},[s,e,a,t])}function hm({displayedPaymentMethods:e,selected:t,setSelected:s,buyerHasActed:a}){const{shop:r,shopPay:i,userEvents:o,source:l,checkout:c,router:d}=A(),u=d.currentUrl.value,{paymentMethodAutoSelectionDisabled:p}=r,m=Aa(),g=Qs(),f=!!ui(c.proposal.proposed.paymentLines.value),v=e.find(C=>le(C)===t);ym({displayedPaymentMethods:e,selectedPaymentMethod:v,buyerHasActed:a});const h=K([]),y=K(),_=K(new Set),b=K(dm(u.search)),S=K(!1);O(()=>{pm({availableMethods:e,seen:_.current,userEvents:o,source:l,checkout:c,shop:r})},[e,o,l,c,r]),O(()=>{const[C]=e;!f&&c.identity.current.value==="shopPay"&&t==="SHOP_PAY"&&C!==void 0&&s(le(C))},[t,s,e,c.identity,f]),O(()=>{if(f){h.current=e,y.current=e;return}const[C]=e,P=!ar(h.current,e);if(!p&&C!==void 0){const M=!a&&!S.current&&b.current?cm(e,b.current):void 0;if(M){const I=le(M);S.current=!0,t!==I&&s(I,void 0,{rebuild:!0})}else if(b.current&&!S.current&&g.value&&(S.current=!0),i.user.paymentMethodHistory.value.length>0&&im(e,y.current)){const D=rm({availablePaymentMethods:e,previousAvailablePaymentMethods:y.current,identity:c.identity,shopPay:i,isApplePayAvailable:m.value});y.current=e,D?s(D):P&&!v&&s(le(C))}else P&&!v&&s(le(C))}h.current=e},[t,v,s,a,e,i,m.value,p,f,c.identity,i.user.paymentMethodHistory.value,g.value])}function gm(e,t,s){const a=K(t),r=K(null);if(a.current!==t){const i=a.current.some(o=>!t.includes(o));r.current=i?_m(e.current,s):null,a.current=t}Cn(()=>{const i=r.current;if(r.current=null,i===null||document.activeElement!==document.body)return;const o=pr(e.current,s);o.length!==0&&o[Math.min(i,o.length-1)]?.focus({preventScroll:!0})},[s,e,t])}function pr(e,t){return e?[...e.querySelectorAll('input[type="radio"]')].filter(s=>s.name===t):[]}function _m(e,t){const s=document.activeElement;if(!(s instanceof HTMLInputElement))return null;const a=pr(e,t).indexOf(s);return a===-1?null:a}const vm=new Set(["bank","customOnsite"]);function bm({displayedPaymentMethods:e,selected:t,loadStateForMethod:s}){const{checkout:a,i18n:r,observability:i}=A(),{wallets:o}=a,l=Wn();nt(({reason:c})=>{if(c!=="progression"&&c!=="completion")return{behavior:"allow"};if(To(l.value))return{behavior:"allow"};if(o.activeSession.value!==null)return{behavior:"allow"};const d=e.find(p=>le(p)===t);if(!d)return{behavior:"allow"};const u=s(d);return u==="failed"?(i.log("lazy_payment_method_submission_blocked",`Blocked ${c}: selected ${d.type} method's chunk failed to load`,{methodType:d.type,loadState:u}),{behavior:"block",reason:He.PaymentMethodUnavailable,errors:[{message:r.translate("payment.payment_method_unavailable_error"),target:pn}]}):u==="loading"&&vm.has(d.type)?(i.log("lazy_payment_method_submission_blocked",`Blocked ${c}: selected ${d.type} method's chunk is still loading`,{methodType:d.type,loadState:u}),{behavior:"block",reason:He.PaymentMethodLoading,errors:[{message:r.translate("payment.payment_method_loading_error"),target:pn}]}):{behavior:"allow"}}
2)}function Bs(e){return e==="choiceList"||e==="tiles"}function Cm({containerSize:e,enabled:t,methodCount:s,mode:a}){const{observability:r}=A(),i=K(t&&Bs(a)?{containerSize:e,methodCount:s,mode:a}:void 0);O(()=>{if(!t||!Bs(a)){i.current=void 0;return}const o={containerSize:e,methodCount:s,mode:a},l=i.current;if(i.current=o,!l||l.methodCount!==s||l.mode===a)return;const c=l.containerSize===void 0&&e!==void 0,d=l.containerSize!==void 0&&e!==void 0&&l.containerSize!==e;!c&&!d||r.counter({name:"payment_selector_mode_changed",value:1,attributes:{from_container_size:l.containerSize??"unmeasured",from_mode:l.mode,method_count:s,to_container_size:e,to_mode:a,transition_source:c?"initial_measurement":"resize"}})},[e,t,s,a,r])}const Sm=498,Am=380;function Pm(e){return e>=Sm?"wide":e>=Am?"compact":"compact-narrow"}function Mm(e){const t=we(void 0),s=K(null),a=K(e);a.current=e,O(()=>()=>{s.current?.disconnect(),s.current=null},[]);const r=k(o=>{const l=Pm(o),c=t.value;if(c===l)return;const d=()=>{t.value=l};c!==void 0&&(a.current?.(c,l)??!1)?Hn(d,["payment-selector-change"]):d()},[t]),i=k(o=>{if(s.current?.disconnect(),s.current=null,t.value=void 0,!o||typeof ResizeObserver>"u")return;const l=new ResizeObserver(([c])=>{c&&r(c.contentRect.width)});l.observe(o),s.current=l},[t,r]);return{containerSize:t,registerContainer:i}}function Em({displayedPaymentMethods:e,selectedBillingAddress:t,allowPreselect:s=!0}){const{observability:a,userEvents:r,source:i,checkout:o,shop:l}=A(),{buyerHasActedSignal:c}=Ne(),[d,u]=Ko({allowPreselect:s,displayedPaymentMethods:e}),{paymentErrors:p}=pa().value,m=Xs(),{updateCheckoutAddress:g}=jo(),f=k(async(v,h)=>{c.value=!0,u(v,h,{buyerInitiated:!0});const y=e.find(_=>le(_)===v);if(y){const _=y.type,b=es(y)||y.type,S="paymentBrands"in y&&y.paymentBrands?y.paymentBrands.slice().sort().join(","):"";a.counter({name:"payment_method_selected",value:1,attributes:{payment_method_type:_,payment_method_name:b,payment_brands:S,location:um({identity:o.identity}),is_mobile:mi()}}),o.identity.current.value==="shopPay"&&(r.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...Pn(i,o,l),action:"payment_method_selected",paymentMethodName:mr(y)}}),t&&pi(v.toUpperCase())&&g({billingAddress:t},!0))}p.length>0&&await m.negotiate({silenceViolations:["all"],negotiationStage:"negotiation"})},[c,u,p.length,m,e,a,r,t,g,i,o,l]);return{selected:d,setSelected:u,setSelectedByBuyer:f,buyerHasActed:c.value}}function Im(e,t){const s=new Set;for(const a of e)a.lastUsedAt&&"id"in a&&s.add(a.id.toLowerCase());for(const a of t)a.lastUsedAt&&(a.paymentBrand!=null&&s.add(a.paymentBrand.toLowerCase()),a.name!=null&&s.add(a.name.toLowerCase()));return s}function xs(e,t,s){const a=le(e).toLowerCase(),r="name"in e?e.name.toLowerCase():"";if(s.has(a)||ls(e)&&s.has("ideal")||mn(e)&&s.has("wallet-apple-pay")||e.type==="customOnsite"&&e.paymentBrands.some(i=>s.has(i.toLowerCase())))return!0;for(const i of t){const o=i.id.toLowerCase();if(o===a||o===r||i.name!=null&&i.name.toLowerCase()===a||i.paymentMethod==="IDEAL"&&ls(e)||i.paymentMethod==="APPLE_PAY"&&mn(e))return!0;if(e.type==="customOnsite"&&"paymentBrands"in i&&Array.isArray(i.paymentBrands)){const l=e.paymentBrands.map(c=>c.toLowerCase());if(i.paymentBrands.some(c=>l.includes(c.toLowerCase())))return!0}}return!1}function Lm(){const{shopPay:e}=A(),{showGuestCheckoutPaymentMethods:t}=e.visibility,{value:s}=Sn({deferClientOnlyWalletsUntilHydrated:!0}),{displayedPaymentMethods:a,renderAsBareCard:r,billingAddressVariant:i,selectedBillingAddress:o}=Da({experienceType:"list"}),l=e.session.promotedPaymentMethods.value,c=W(()=>Im(e.user.paymentMethods.value??[],e.user.paymentMethodHistory.value??[]),[e.user.paymentMethods.value,e.user.paymentMethodHistory.value]),d=W(()=>a.filter(f=>!xs(f,l,c)),[a,l,c]),u=W(()=>{if(!t)return[];const f=new Set(d);return(s??[]).filter(v=>!xs(v,l,c)).filter(v=>!f.has(v)).filter(v=>!fi(v))},[s,l,c,t,d]),p=W(()=>[...d,...u],[u,d]),m=l.some(f=>f.paymentMethod!=="CREDIT_CARD"),g=r||!!(d.length>0&&u.length===0&&!m&&d.every(f=>f.type==="direct"));return{shopPayPaymentMethods:d,guestCheckoutPaymentMethods:u,combinedPaymentMethods:p,renderAsBareCard:g,billingAddressVariant:i,selectedBillingAddress:o}}function km(e){const t=W(()=>e.filter(i=>i.type==="customOnsite"),[e]),s=W(()=>t.flatMap(({uiExtension:i})=>i?[i]:[]),[t]),a=Rn("Checkout::PaymentMethod::Render",s),r=W(()=>a.map(yi),[a]);return W(()=>{const i=r.some(o=>o.type==="local");return new Set(t.flatMap(o=>i||o.uiExtension!==void 0&&r.includes(o.uiExtension)?[o.paymentMethodIdentifier]:[]))},[t,r])}function Cp({errorBannerInContext:e,billingAddressInContext:t,vaultHandle:s,selectorShowsTiles:a,afterPaymentSelector:r,experienceType:i="list",renderVaultingAgreementInline:o}){const c=ml().value,d=Wn(),{checkout:u,i18n:p}=A(),m=u.configuration.layout.isOnePage.value,g=u.installments.paymentMethodMustSupportDebitC
2ardOnly.value,{displayedPaymentMethods:f,renderAsBareCard:v,billingAddressVariant:h,selectedBillingAddress:y}=Da({experienceType:i}),_=ho(),{guestCheckoutPaymentMethods:b}=Lm(),S=dr(),C=W(()=>f.filter(ae=>S(ae)!=="failed"),[f,S]),{selected:P,setSelected:M,setSelectedByBuyer:I,buyerHasActed:N}=Em({displayedPaymentMethods:C,selectedBillingAddress:y}),D=ia().value,T=jt().value,E=re().paymentLines,w=m&&!o&&D&&E.value.some(ae=>ae.method.type==="direct")?void 0:"large-100",[x=""]=hi(E.value);bm({displayedPaymentMethods:f,selected:x,loadStateForMethod:S}),hm({displayedPaymentMethods:C,selected:P,setSelected:M,buyerHasActed:N});const V=K(null),z=W(()=>C.map(le),[C]);gm(V,z,"basic");const U=we(null),Y=s??U,{showPaymentTiles:j}=Dn(),R=km(C),H=Va(C,R),{containerSize:X,registerContainer:q}=Mm((ae,_e)=>H(ae,m,g).mode!==H(_e,m,g).mode),Z=k((ae,_e)=>{const ee=C.map(le),me=ee.indexOf(ae),ve=ee.indexOf(P);if(me===-1||me===ve){I(ae,_e);return}const ye=ve===-1||me>ve?"payment-details-slide-end":"payment-details-slide-start";Hn(()=>{I(ae,_e)},[ye])},[C,P,I]),ne=W(()=>H(X.value,m,g),[H,X.value,m,g]);Cm({containerSize:X.value,enabled:j,methodCount:C.length,mode:ne.mode});const[ie]=C,ce=ne.mode==="singlePaymentMethodCreditCard"&&ie!==void 0&&Us(ie)?ie:void 0,L=uu({identity:u.identity,guestCheckoutPaymentMethodCount:b.length,inlinePaymentMethod:!!ce})??void 0,Q=o&&!T&&D?n(za,{borderless:!0}):void 0,ue=W(()=>C.map(ae=>"name"in ae?ae.name:ae.type),[C]),pe=P==="deferred"||P==="creditCards"?P:void 0,Le=pl(u.identity,d.value);if(Le)return n(qe,{impressionType:"payment",impressionFeatures:[Le],children:n(dt,{reason:Le,minimal:m})});if(c.freeOrder)return n(qe,{impressionType:"payment",impressionFeatures:["freeOrder"],children:n(dt,{reason:"freeOrder",minimal:m})});if(c.giftCard)return n(qe,{impressionType:"payment",impressionFeatures:["giftCard"],children:n(dt,{reason:"giftCard",minimal:m})});if(c.storeCredit)return n(qe,{impressionType:"payment",impressionFeatures:["storeCredit"],children:n(dt,{reason:"storeCredit",minimal:m})});if(c.redeemables)return n(qe,{impressionType:"payment",impressionFeatures:["redeemables"],children:n(dt,{reason:"redeemables",minimal:m})});if(_.value)return n(Ve,{background:"subdued",borderRadius:"base",paddingBlock:"large-500",placeItems:"center",children:n(de,{color:"subdued",textAlign:"center",children:p.translate("payment.loading")})});if(C.length===0)return n(qe,{impressionType:"payment",impressionFeatures:bs(ue,ne),children:n(ad,{error:f.length>0?"script":"no_methods"})});const Ae=Dl({identity:u.identity,billingAddressInContext:t,billingAddressVariant:h});let oe;if(ce)oe=n(fe,{paddingBlockEnd:w,children:n(du,{method:ce,onSelect:I,vaultHandle:Y,blockFooter:L,selectedContentFooter:Q})});else if(ne.mode==="tiles"){const ae=n(qu,{methods:C,selected:P,onSelect:Z,selectorShowsTiles:a,tileSupportedCustomOnsitePaymentMethods:R});oe=n(F,{gap:"large-100",children:[ne.choiceListPresentation==="redesigned"?n(po,{borderSelected:"large100",children:ae}):ae,n(Ds,{variant:"details",children:n(sm,{methods:C,selected:P,onSelect:Z,vaultHandle:Y,directMethodSelectedContentFooter:Q})}),L]})}else oe=n(fe,{paddingBlockEnd:w,ref:V,children:n(Ru,{methods:C,selected:P,onSelect:I,renderAsBareCard:v,vaultHandle:Y,blockFooter:L,directMethodSelectedContentFooter:Q})});return n(io,{target:"cart.paymentLines[0]",children:n(qe,{impressionType:"payment",impressionFeatures:bs(ue,ne),children:n(id,{errorBannerInContext:e,billingAddressInContext:t,selectedPaymentMethod:P,billingAddressVariant:h,children:n(F,{ref:q,gap:"base",children:[!v&&n(Uu,{selectedPaymentMethod:pe}),n(Ds,{variant:"selector",children:oe}),r,Ae]})})})})}const wm=null,Nm="/pay/account/installments";function Tm(e){return new URL(Nm,e).href}function Dm(e,t=wm){return t===null?!1:Jo(e,t)}function Fm(){const{i18n:e,environment:t,shopPay:s}=A(),a=fa(),{surface:r,version:i}=s.app.config,o=r!=="web";if(o&&!Dm(i))return n(G,{children:e.translate("payment_errors.duplicate_autopay_card_without_link")});const l=n(G,{children:[e.translate("payment_errors.duplicate_autopay_card_link")," ",n(Me,{type:"external",size:"small",display:"inline"})]});return n(G,{children:e.translate("payment_errors.duplicate_autopay_card",{update_payment_details_link:o?n(We,{onClick:()=>a.notify({open_upcoming_payments:!0}),children:l}):n(We,{href:Tm(t.services.shopServer.url),target:"_blank",children:l})})})}function Bm(e){const{i18n:t,observability:s,userEvents:a,source:r,checkout:{configuration:i},shop:o}=A(),l=W(()=>An(),[]),c=e||l;function d(u,p){$o({addressErrors:c,shopPayErrors:u,i18n:t,observability:s,userEvents:a,source:r,configuration:i,shop:o,addressContext:"billing",submittedAddress:p})}return[c,d]}const cn="Timed out while processing the 3DS challenge modal.";function xm(e){return{listenerType:"shop_pay_three_ds_listener",modalSourceType:e.modalSourceType,sourceHostCategory:zn(e.source),selectedPaymentMethod:e.selectedPaymentMethod,isInstallmentsSelected:e.isInstallmentsSelected,...e.buyerCountryCode?{buyerCountryCode:e.buyerCountryCode}:{},surface:e.surface}}const Rm=()=>{const e=K(!1),[t,s]=J(void 0),{observability:a}=A();return O(()=>{if(t)return window.addEventListener("message",t.messageListener),t.telemetryAttributes&&a.log("shop_pay_three_ds_listener_started","[ShopPay] 3DS postMessage listener started",t.telemetryAttributes),()=>window.removeEventListener("message",t.messageListener)},[t,a]),{listen:k(({onComplete:i,telemetryContext:o})=>{e.current=!1;
2const l=Date.now(),c=o?xm(o):void 0,d=(m,g)=>{if(!e.current){e.current=!0;try{g?.()}catch{}try{i(...m)}catch(f){a.error(new gi(`Error in 3DS onComplete handler: ${f}`,{groupingHash:"ShopPayError::ThreeDSecureOnComplete"}))}}},u=setTimeout(()=>{s(void 0),d([{errors:[{message:cn}]}],()=>{a.log("use_three_ds_listener_timed_out",cn),c&&a.log("shop_pay_three_ds_listener_timed_out",cn,{...c,elapsedTimeMs:Date.now()-l})})},oo);async function p({data:m,origin:g}){m.type===us&&(e.current||(s(void 0),clearTimeout(u),d([],()=>{c&&a.log("shop_pay_three_ds_listener_completed","[ShopPay] 3DS postMessage received",{...c,dataType:us,originHostCategory:zn(g),elapsedTimeMs:Date.now()-l})})))}s({messageListener:p,telemetryAttributes:c})},[a])}};function Om({onAddressValidationErrors:e,onSaveCardErrors:t,onDuplicateAutopayCard:s,onSaveCardBillingAddressErrors:a,onThreeDSUrlChange:r,validateCardFields:i,vaultCardWithSelectedNetwork:o}){const{shopPay:l,checkout:c,observability:d}=A(),u=Wn(),{paymentLines:p,billingAddressOption:m,shippingAddress:g,billingAddress:f}=re(),v=c.installments.paymentMethodMustSupportDebitCardOnly,h=wn(),y=c.isShippingRequired.value&&m.value==="shipping"&&!h.value?g.value:f.value,_=c.configuration.addressSettings.billingAddressSettings.value,b=kn(y?.countryCode,void 0,_),S=wo(),{listen:C}=Rm(),{creditCardDisabled:P}=xo(),M=l.user.flow.peek()==="authenticated_user",I=k(T=>P(T)?{success:!1,location:"intercept_card_not_good_for_installments"}:{success:!0},[P]),N=k(async({errors:T}={},E,B)=>{if(T||!y){t(),r(null),B({success:!1,location:"intercept_3ds_challenge_complete_error"});return}let w=null;try{const x=await S.completeCreditCardVerificationAndVault({verificationId:E,billingAddress:y,nickname:null,debitOnly:v.value});x.status==="success"?w=l.session.isInstallmentsSelected.value?I(x.creditCard):{success:!0}:x.status==="blocked_by_autopay"?(s(),w={success:!1,location:"intercept_credit_card_blocked_by_autopay"}):(t(x.errors),w={success:!1,location:"intercept_complete_credit_card_verification_failed"})}catch{t(),w={success:!1,location:"intercept_complete_credit_card_verification_error_caught"}}r(null),B(w)},[y,S,v,l.session.isInstallmentsSelected,I,s,t,r]),D=k(async(T,E)=>new Promise(B=>{C({onComplete:w=>N(w??{},T,B),telemetryContext:{buyerCountryCode:y?.countryCode,isInstallmentsSelected:l.session.isInstallmentsSelected.value,modalSourceType:"shop_pay_interceptor_three_ds_modal_url",selectedPaymentMethod:l.session.isInstallmentsSelected.value?"shop_pay_installments":"shop_pay",source:E,surface:"checkout-web"}})}),[N,C,y?.countryCode,l.session.isInstallmentsSelected]);return k(async()=>{try{if(u.value)return{success:!0};const[T]=p.value;if(!T)return{success:!1,location:"intercept_no_payment_lines"};if(T.method.type!=="direct")return{success:!0};if(!y)return{success:!1,location:"intercept_no_selected_billing_address"};const{isValid:E}=i(),B=b(y,"billing");if((m.value!=="shipping"||!c.isShippingRequired.value)&&e(B),!E)return{success:!1,location:"intercept_credit_card_not_valid"};if(B.size!==0)return{success:!1,location:"intercept_billing_address_has_errors"};if(!M)return{success:!0};const w=await o(),x=await S.addCreditCard({sessionId:w,billingAddress:y,nickname:null,debitOnly:v.value,isBlocking:!0});if(x.status==="success")return l.session.isInstallmentsSelected.value?I(x.creditCard):{success:!0};if(x.status==="requires_redirect"){const{redirectUrl:V,verificationId:z}=x.threeDSecureAuthenticationRequest;return l.session.isInstallmentsSelected.value&&d.log("shop_pay_installments_3ds_modal_url_set","[ShopPayPaymentMethodInterceptor] Shop Pay Installments 3DS modal URL set",{buyerCountryCode:y?.countryCode,isInstallmentsSelected:!0,modalSourceType:"shop_pay_interceptor_three_ds_modal_url",selectedPaymentMethod:"shop_pay_installments",sourceHostCategory:zn(V),surface:"checkout-web"}),r(V),D(z,V)}else return x.status==="blocked_by_autopay"?(s(),{success:!1,location:"intercept_credit_card_blocked_by_autopay"}):(t(x.errors),a(x.errors?.filter(V=>V.field[0]==="billingAddress"),y),{success:!1,location:"intercept_credit_card_not_saved"})}catch(T){if(T instanceof vn)return t(),{success:!1,location:"intercept_vault_handle_unavailable"};throw T}},[u,p,y,i,b,m,c.isShippingRequired,M,o,S,v,l.session.isInstallmentsSelected,D,I,d,s,t,a,e,r])}
2class vn extends Error{constructor(){super("Card fields functions are unavailable"),this.name="CardFieldsFunctionsUnavailableError"}}function Vm(){const[e,t]=J(null),s=fa(),{checkoutProtocolModalEventSignal:a}=Ne(),r=k(i=>{const o=i===null?"modal_close":"modal_open";a.value=o==="modal_open"?"redesign":"none",s.notify({checkout_ui:{type:o,payload:{duration:Ro}}}),t(i)},[s,a]);return[e,r]}function zm({vaultHandle:e}){const{checkout:{validation:t},i18n:s}=A(),{creditCardErrors:a,setCreditCardErrors:r,blockDuplicateAutopayCard:i}=No(),[o,l]=Bm(t.billingAddressErrors),[c,d]=Vm(),u=lo({source:c,logMessage:"[ShopPayPaymentMethodProgressionHost] Action required modal iframe loaded; this does not prove issuer challenge rendered",telemetryContext:{modalSourceType:"shop_pay_interceptor_three_ds_modal_url"}}),p=k(()=>{const f=e.value;if(!f)throw new vn;return f.validate()},[e]),m=k(async()=>{const f=e.value;if(!f)throw new vn;return f.vaultCardWithSelectedNetwork()},[e]);O(()=>{const f=e.value;f&&f.setFieldErrors(a.fieldErrors)},[a,e]);const g=Om({onAddressValidationErrors:f=>{for(const[v,h]of Array.from(f))o[v].value=h},onSaveCardErrors:r,onDuplicateAutopayCard:i,onSaveCardBillingAddressErrors:l,onThreeDSUrlChange:d,validateCardFields:p,vaultCardWithSelectedNetwork:m});return Jt("paymentMethod",g),n(G,{children:[n(co,{source:c,title:s.translate("processing.action_required"),onIframeLoad:u}),a.baseMessage&&n(Re,{tone:"critical",children:a.baseMessage}
2),a.blockedByDuplicateAutopayCard&&n(Re,{tone:"critical",children:n(Fm,{})})]})}function Sp({vaultHandle:e}){const{checkout:{identity:{current:t}}}=A();return t.value==="shopPay"?n(zm,{vaultHandle:e}):null}export{gu as A,hl as B,Eu as C,Fm as D,ym as E,Ku as F,vp as G,bp as H,_p as I,Jn as J,Zn as K,Al as L,Ed as M,sl as N,Xa as O,gn as P,Em as Q,bm as R,Su as S,ts as T,tr as U,za as V,Gc as W,Uc as X,qc as Y,Kc as Z,hp as a,ml as b,cl as c,dl as d,gp as e,bs as f,pl as g,Cp as h,yp as i,Sp as j,Ya as k,Ua as l,pd as m,Rm as n,ll as o,pc as p,Zt as q,Dl as r,kd as s,id as t,Da as u,Uu as v,Ru as w,md as x,Rd as y,Nd 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.