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