PageSourceSearch

https://www.sifaana.com.tr/cdn/shopifycloud/checkout-web/assets/c1…AddressMutationsWithNegotiation.BpQ951no.js

js sifaana.com.tr collected 2026-09-29 16:05:46 UTC 85,645 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["PostPurchaseShouldRender.BlvsxSCz.js","esnext-vendor.7EcvH7tF.js","utilities-previous.DaWdZv41.js","app.Ct1TLWkJ.js","assets/app.BuSMBobh.css","assets/previous.DjvIwnbB.css","extensions-rpc.BIjPmoeN.js","amazon-pay-useAmazonPayPaymentLine.D7yPfUN6.js","performance-index.mu6MOGR9.js","shared-permissions.C4V3dAGa.js","components-RedirectionNotice.module.CYPkGrdi.js","hydrate.__QOXNN3.js","shared-negotiation-input-redeemable.BsA2r1RZ.js","hooks-useShopPayExternalAppContext.CTzvOb12.js","assets/helpers.BXOQj2oa.css","assets/RedirectionNotice.B8v_QGNW.css","component-Tips.B-gYjS4H.js","Choice.BebUeKaz.js","utilities-publishMessage.DNsouRpe.js","Checkbox.Cq3GQL_K.js","assets/Checkbox.SrYMuQu4.css","assets/Choice.DV6JSDrR.css","NumberField.DcK00p-a.js","assets/NumberField.CRpcZnVJ.css","Section.COlIloPz.js","assets/Section.CU18S7Ap.css","assets/Tips.D3S9_XMm.css","component-MsiInstallmentsSelect.C06wSwUp.js","PaymentIcon.uHdbCE3b.js","assets/PaymentIcon.gzvCNwz_.css","PaymentLine.DsTkddf6.js","localization-index.rdUcb1vZ.js","assets/index.CFj15lwv.css","Theme-ThemeOverride.DJ0NuWqg.js","assets/PaymentLine.D3bcP-mr.css","crypto-constants.BpobLnGP.js","assets/constants.Dlnp55te.css","hooks-useUpdateCheckoutAddress.BL5Yr4GQ.js","helpers-derivations.Rg3VPX07.js","graphql-PaymentSessionMutation.B3_YfTkY.js","payment-usePaymentExemptionReason.ChBwdFRd.js","redemption-constants.5qb5alFL.js","shop-pay-normalizeBuyerDetails.BAk0CUr4.js","redemption-promotions.DtPDNosX.js","hooks-useShopPayProgressIntercepts.BsOYj7XB.js","helpers-credit-card-disabled.Cac4kHb5.js","assets/useShopPayProgressIntercepts.CIy8uDiZ.css","helpers-setAddressErrors.B3hJ_U3b.js","Popover.B6N0nnm4.js","assets/Popover.Bi1nHaU-.css"])))=>i.map(i=>d[i]);
2import{_ as it,S as Yt}from"./app.Ct1TLWkJ.js";import{d as ot,u as m,f as B,S as qt,i as Oe,h as U,a as dt,k as X,q as S,y as N,E as I,ag as Ls,n as Ns,T as J,x as lt,A as ce,o as zt,e as Ds,G as xs,r as Ts,_ as Rs,X as Bs,ae as Fs}from"./esnext-vendor.7EcvH7tF.js";import{m as et,b as ve,ag as He,B as Ee,$ as ct,at as Us,C as Ht,bI as Wt,L as Qt,fs as Vs,J as jt,fn as Os,I as $e,k as Z,P as $s,gU as Ks,a5 as gt,gV as ut,ck as Gs,gW as Pt,w as Ys,f as Ke,Y as qs,fF as zs,U as Hs,gX as Ws,gY as Qs,W as Xt,A as Zt,gZ as js,y as We,br as Jt,l as ne,az as es,dM as Xs,b8 as Zs,aB as Js,a as ts,S as ea,bF as ta,fQ as sa,bk as aa,bl as na,bm as ra,g_ as ia,g$ as mt,h0 as _t,h1 as oa,h2 as St,h3 as Mt,h4 as At,h5 as da,a1 as la,g7 as ca,j as ua,fI as ma}from"./hydrate.__QOXNN3.js";import{Q as L,a2 as Y,S as ee,ac as ss,ds as ha,dJ as pa,gl as ye,gh as ya,l as H,hG as fa,hH as Qe,X as Ca,Z as va,T as ba,hI as ga,hJ as Pa,ca as fe,dr as _a,hK as Sa,bL as Ma,ax as as,ga as ns,g9 as Aa,aq as rs,o as ka,hL as Ea,m as be,g3 as wa,t as we,c4 as is,aY as Ge,aW as Pe,gQ as ht,hM as os,a9 as pt,H as Fe,dI as Ia,bE as La,hN as Na,U as W,hO as De,hP as Da,V as ge,hQ as xa,hR as kt,hS as Ta,hT as Ra,hU as Ba,c7 as Fa,ae as ds,bF as Ua,bw as Ye,hV as Va,hW as Oa,b3 as $a,hX as yt,hY as Ka,hZ as ls,b0 as cs,w as Ga,h_ as Ya,h$ as us,i0 as qa,i1 as za,i2 as Ha,dX as Wa,dY as ms,bx as Qa,O as ja,P as Xa,i3 as Za,v as Ja}from"./utilities-previous.DaWdZv41.js";import{u as en}from"./amazon-pay-useAmazonPayPaymentLine.D7yPfUN6.js";import{P as hs}from"./PaymentIcon.uHdbCE3b.js";import{a as tn}from"./PaymentLine.DsTkddf6.js";import{b as Et,E as sn}from"./crypto-constants.BpobLnGP.js";import{a as an,c as nn,b as rn,u as on}from"./hooks-useUpdateCheckoutAddress.BL5Yr4GQ.js";import{c as ps,u as dn}from"./payment-usePaymentExemptionReason.ChBwdFRd.js";import{s as ln,n as cn}from"./shop-pay-normalizeBuyerDetails.BAk0CUr4.js";import{u as un,i as mn,S as hn,c as pn}from"./hooks-useShopPayProgressIntercepts.BsOYj7XB.js";import{s as yn}from"./helpers-setAddressErrors.B3hJ_U3b.js";import{a as ys,C as tt}from"./Choice.BebUeKaz.js";import{A as fn,a as Cn}from"./graphql-PaymentSessionMutation.B3_YfTkY.js";import{P as vn}from"./Popover.B6N0nnm4.js";const ui=ot({displayName:"PostPurchaseShouldRender",suspense:!1,load:()=>it(()=>import("./PostPurchaseShouldRender.BlvsxSCz.js").then(t=>t.P),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))});function bn({renderInSection:t,hideHeading:e,headingLevel:s=2}){const{i18n:a,shop:{name:n,showTipPayments:r}}=L(),{tipLines:o}=Y(),{tipLines:d}=ee(),i=B(()=>{const u=o.value?.[0]??d.value[0];return r||!!(u&&u.amount.amount>0)}),l=a.translate("tips.description",{shop_name:n}),c=m(Ee,{paddingBlockEnd:"base",children:[!e&&m(qt,{children:[m(et,{level:s,children:a.translate("tips.title")}),m(ve,{blockSize:"base"})]}),m(He,{contentDisplay:"block",inlineSize:"100%",children:l}),m(Oe,{when:i,children:[m(ve,{blockSize:"small-200"}),m(He,{contentDisplay:"block",inlineSize:"100%",children:a.translate("tips.custom_label")}),m(ve,{blockSize:"small-100"}),m(He,{contentDisplay:"block",inlineSize:"33%",children:a.translate("tips.add_tip")})]})]});return t?m(ct,{accessibilityLabel:a.translate("tips.title"),children:c}):c}function gn(t){const{observability:e}=L();U(()=>{t&&e.error(t,{metadata:{tips:{component:"Tips",failure:"lazy_load"}}})},[t,e])}const mi=ot({displayName:"Tips",renderLoading:t=>m(bn,{...t}),useError:gn,load:()=>it(()=>import("./component-Tips.B-gYjS4H.js"),__vite__mapDeps([16,1,11,2,3,4,5,12,9,13,14,17,18,19,20,21,22,23,24,25,26]))}),Pn=jt("AmazonPayChangePaymentLinkButton");function hi(){const{i18n:t,observability:e}=L(),{inMemoryAmazonPayParts:{sdkStatus:s}}=ss(),a=B(()=>{const i=s.value;return i.status===Us.Available?i.sdk:void 0}),n=en(),r=Ht(void 0,Pn),{hasError:o}=Wt(ha),d=t.translate("vaulted.change_button");return n.value?m(Oe,{when:a,children:i=>m(Qt,{onClick:()=>{try{const{checkout_session_id:c}=Vs(n.value.method.walletParams);i.Pay.changePaymentMethod({amazonCheckoutSessionId:c,isDeclined:o})}catch(c){e.error(new _n(`Error on changing buyer payment method. Details: ${c}`,{cause:c}))}},id:r,children:d})}):null}
2class _n extends Error{constructor(){super(...arguments),this.name="AmazonPayChangePaymentLinkError"}}const Sn=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 pi({brand:t,descriptor:e}){const{hasError:s}=Os(),a=t?.toLowerCase().replace(/\s+/g,"_")??"",n=Sn.get(a)??"generic";return m(Z,{direction:"inline",children:[s&&m(qt,{children:[m($e,{tone:"critical",type:"alert-circle"}),m(ve,{display:"inline",inlineSize:"small-400"})]}),m(tn,{icon:m(hs,{type:n}),details:e})]})}function Mn(){const{i18n:t}=L(),e=ee().purchaseOrderNumber.value;if(!e)return null;const s=`${t.translate("payment.purchase_order_number.title")} #${e}`;return m($s,{children:s})}const An=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"})]}),kn="agRve",En="FiV0Z",wt={NoPaymentRequiredWrapper:kn,FreeTagIcon:En};function yi({minimal:t,reason:e,vaulted:s}){const{i18n:a}=L(),r=Ks().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:dt(d)}};return s?m(Z,{gap:"base",children:[m(gt,{children:o(e)}),m(Mn,{})]}):t?m(sn,{children:m(Et,{children:o(e)})}):m("div",{className:wt.NoPaymentRequiredWrapper,children:m(Z,{gap:"large-200",alignItems:"center",children:[m(An,{className:wt.FreeTagIcon,focusable:"false","aria-hidden":"true"}),m(Et,{children:m(gt,{children:o(e)})})]})})}class wn extends Yt{constructor(){super(...arguments),this.name="AmazonPayMissingPaymentPreferencesError"}}function fi(){const t=ee().paymentLines;return B(()=>{const e=t.value,s=(()=>{const[n]=e.filter(i=>i.method.type==="walletsPlatformPaymentMethod");if(!n)return"";const o=n.method.walletParams.payment_preferences?.[0];if(!o)throw new wn("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 It={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}}"},Be=Object.freeze({name:null,number:null,verification_value:null,expiry:null,issue_date:null,issue_number:null});var fs=(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))(fs||{});
2const Lt={baseMessage:null,fieldErrors:Be,blockedByDuplicateAutopayCard:!1};function Ci(){const{i18n:t,observability:e}=L(),[s,a]=X(Lt),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:Be,blockedByDuplicateAutopayCard:!1});return}const c={...Be};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:pa});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:Be,blockedByDuplicateAutopayCard:!0})},[e]),d=S(()=>{a(Lt)},[]),i=S(l=>{e.counter({name:"save_credit_card_vaulting_failure",value:1,attributes:{reason:l}}),r(l==="missing_billing_address"?[{field:["creditCard","base"],message:"billing_address_missing"}]:void 0)},[e,r]);return{creditCardErrors:s,setCreditCardErrors:r,clearCreditCardErrors:d,failCardVaulting:i,blockDuplicateAutopayCard:o}}function G(t){return t?.paymentMethod==="CREDIT_CARD"}function vi(t){return t.paymentMethod==="IDEAL"||t.paymentMethod==="CUSTOM_ONSITE"&&t.paymentBrands?.some(e=>e.toLowerCase()==="ideal")===!0}function bi(t){return t.paymentMethod==="APPLE_PAY"}function gi(t){return t.paymentMethod==="CUSTOM_ONSITE"}function Pi(t){return t.paymentMethod==="SHOP_PAY"}function _i(t){return t.paymentMethod==="SHOP_PAY_INSTALLMENTS"}function Si(t){return t.paymentMethod==="PAYPAL"}function Mi(t){return t.paymentMethod==="BANK"}function st(t){return t.paymentMethod==="DEFERRED"}function Ai(t){return t.paymentMethod==="OFFSITE"||t.paymentMethod==="MANUAL_PAYMENT"||t.paymentMethod==="CUSTOM_MANUAL_PAYMENT"||t.paymentMethod==="PAYMENT_ON_DELIVERY"}function In(t){return G(t)||!!t.lastUsedAt}function Ln(t){for(const e of t)if(!G(e)||!e.paymentAttributes.expired)return e;return t[0]}function Nn({selected:t,paymentMethods:e,availablePaymentMethods:s}){return!!(ye(t,s)||G(t)&&e.some(({method:a})=>a.paymentMethod===t.paymentMethod&&a.id===t.id))}function Dn(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=ya(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:dt(t)}return{paymentMethodName:s,paymentBrands:a}}const re={markBuyerHasActed:!1,updateSelectedCardBin:!1,selectedCardFirstDigits:void 0,preserveExistingBinPrefix:!1,claimMsiBin:!1,claimedMsiBin:void 0,shouldNegotiate:!1};function Cs(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 xe(t){switch(t.paymentMethod){case"CREDIT_CARD":return{id:t.id,paymentMethod:"CREDIT_CARD",paymentAttributes:Cs(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 at(t,e){switch(t.paymentMethod){case"CREDIT_CARD":return e.find(s=>H(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:dt(t)}}class xn extends Error{constructor(){super(...arguments),this.name="EmptySessionIdError"}}class Tn extends Error{constructor(){super(...arguments),this.name="BuyerDetailsRefreshError"}}const Rn="credit_card_not_found";function Bn(t){return t.errors?.some(({message:e})=>e===Rn)??!1}class Fn{constructor(e){this.newCard=N(void 0),this.canSetCreditCardNickname=N(!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=N(r),this.shopPayAvailableUserStoredPaymentMethods=I(()=>{const c=this.availablePaymentMethods.value;return c.length?ka(s.user.paymentMethods.value,c):[]}),this.availableUserStoredPaymentMethods=I(()=>this.shopPayAvailableUserStoredPaymentMethods.value.map(xe)),this.promotedMethods=I(()=>s.session.promotedPaymentMethods.value.map(xe)),this.selectedPaymentMethod=I(()=>{const c=s.session.selectedPaymentMethod.value;return c?xe(c):void 0}),this.selectedCreditCard=I(()=>{const c=s.session.selectedPaymentMethod.value;return c&&H(c)?Cs(c.paymentAttributes):void 0}),this.shopPayPaymentMethods=I(()=>{const c=s.user.paymentMethods.value,u=this.shopPayAvailableUserStoredPaymentMethods.value,p=this.availablePaymentMethods.value,h=s.session.promotedPaymentMethods.value,v=s.user.paymentMethodHistory.value,g=c.filter(H).map(E=>({method:E,isValidForCheckout:u.includes(E),isExpired:E.paymentAttributes.expired,isDisabled:o(E.paymentAttributes)})),M=a?[]:Ea({negotiatedPaymentMethods:p,userStoredPaymentMethods:c,paymentMethodHistory:v,isApplePayAvailable:n}),b=[...g.sort((E,_)=>be(E.method,_.method)),...M.sort((E,_)=>be(E.method,_.method))];let f=-1,A="";for(const[E,_]of b.entries()){const x=_.method.lastUsedAt??"";x>A&&(A=x,f=E)}f>0&&b.unshift(...b.splice(f,1));const k=s.session.selectedPaymentMethod.value,D=new Set(h.map(E=>E.id));
2return b.filter(({method:E})=>H(E)||k&&!H(k)&&E.id===k.id||D.has(E.id)?!0:wa(E))}),this.paymentMethods=I(()=>this.shopPayPaymentMethods.value.map(({method:c,...u})=>{const p=xe(c);return{...u,method:p,canEdit:H(c),canDelete:H(c),canSetDefault:!1,isDefault:!1}})),this.selectedPaymentMethodItem=I(()=>{const c=this.selectedPaymentMethod.value;if(c)return this.paymentMethods.value.find(({method:u})=>u.id===c.id&&u.paymentMethod===c.paymentMethod)}),this.cardPaymentMethods=I(()=>this.paymentMethods.value.filter(c=>G(c.method))),this.activeOrExpiredCardMethods=I(()=>{const c=this.cardPaymentMethods.value,u=[];for(const p of c)a&&p.isDisabled||u.push(p);return u}),this.disabledCardMethodsForInstallments=I(()=>a?this.cardPaymentMethods.value.filter(c=>c.isDisabled):[]),this.isEveryCardDisabled=I(()=>{const c=this.cardPaymentMethods.value;if(c.length===0)return!1;const u=new Set(this.disabledCardMethodsForInstallments.value.map(h=>h.method.id)),p=c.filter(h=>h.isExpired&&!u.has(h.method.id)).length;return c.length===u.size+p}),this.isEveryCardExpired=I(()=>{const c=this.cardPaymentMethods.value;if(c.length===0)return!1;const u=new Set(this.disabledCardMethodsForInstallments.value.map(h=>h.method.id)),p=c.filter(h=>!u.has(h.method.id));return p.length===0?!1:p.every(h=>h.isExpired)});const l=I(()=>{const c=we(this.availablePaymentMethods.value);if(!ut(c))return!1;const u=this.selectedCreditCard.value;return!!(u&&d.value[u.id])});this.msi={binResolution:"server",selectedCardBin:I(()=>{}),clearInstallments:fa,expandedVisible:I(()=>l.value?s.session.paymentMethodOption.value?.name!=="SHOPIFY_INSTALLMENTS":!1),collapsedVisible:I(()=>l.value&&!i.value)}}canShowAsGuestCheckoutMethod(e){const{shopPay:s}=this.deps;return s.visibility.showGuestCheckoutPaymentMethods&&!(e.type==="wallet"&&(e.name==="SHOP_PAY"||e.name==="SHOPIFY_INSTALLMENTS"))}async selectPaymentMethod(e,s="programmatic",a){const{shopPay:n,updateCheckoutAddress:r,shippingRequired:o}=this.deps;if(!e)return n.session.clearPaymentMethod(),{status:"handled",effects:re};const d=at(e,n.user.paymentMethods.value);if(!d)return{status:"not-handled"};if(s==="buyer"&&this.recordPaymentMethodSelected(e),G(e)){const l=this.selectCreditCard({id:e.paymentAttributes.id});return Qe(d,n.user.paymentMethods.value,ye(d,this.availablePaymentMethods.value))&&this.#e(d,a),await l,{status:"handled",effects:re}}const i=ye(d,this.availablePaymentMethods.value);return Qe(d,n.user.paymentMethods.value,i)&&this.#e(d,s==="buyer"?{...a,buyerInitiated:!0}:a),(Ca(d)||va(d)||ba(d)||ga(d))&&await r({billingAddress:n.session.selectedBillingAddress.value?.address,fallbackPhoneNumber:n.user.phoneNumber.value},o.value),{status:"handled",effects:re}}async promoteSelectedPaymentMethod(e){const{shopPay:s}=this.deps,a=Pa(e,s.user.paymentMethods.value);return a&&(s.session.selectPaymentMethod(a),s.session.unstable_promotePaymentMethod(a)),{status:"handled",effects:{...re,selectByBuyerKey:fe(e)}}}getSavedCardActiveSubscriptionsLookup(e){const s=this.deps.shopPay.user.paymentMethods.value.filter(H).map(o=>o.paymentAttributes).find(o=>o.id===e.id);if(!s)return;const a={id:s.id,uuid:s.uuid,first:3},n=Ls(It,a),{shopPayGraphql:r}=this.deps;return{key:n,read(){return r.read(n)?.creditCardActiveSubscriptions?.nodes},async load(){const{data:o}=await r.staticQuery(It,{variables:a});return o?.creditCardActiveSubscriptions?.nodes??[]}}}async selectCreditCard({id:e}){const{shopPay:s}=this.deps,a=s.user.paymentMethods.value.filter(H).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(H).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=_a();return yn({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 xn("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(H).map(b=>b.paymentAttributes).find(b=>b.id===e)?.uuid;if(!c)return{status:"failed"};const u=a.session.selectedPaymentMethod.value,p=u&&H(u)?u.paymentAttributes.uuid:void 0,h=await n(e,c,i);if(h.status!=="success"&&!Bn(h))return{status:"failed"};const v=a.user.paymentMethods.value.filter(H).map(b=>b.paymentAttributes).filter(b=>b.uuid!==c);if(a.user.removeCreditCard(e),l(),p!==c)return{status:"success"};const g=Sa(v);if(g)a.session.selectPaymentMethod({id:g.id,lastUsedAt:g.lastUsedAt,paymentMethod:"CREDIT_CARD",paymentAttributes:g}),this.clearShopPayPaymentLines();else{const b=this.paymentMethods.value.find(({method:f,isValidForCheckout:A,isDisabled:k,isExpired:D})=>A&&!k&&!D&&In(f))?.method;if(b){const f=at(b,a.user.paymentMethods.value);f&&this.#e(f)}else a.session.clearPaymentMethod(),this.clearShopPayPaymentLines(),a.session.unstable_updateSelectedBillingAddress(a.session.selectedShippingAddress.value)}const M=g?g.billingAddress.address:a.session.selectedBillingAddress.value?.address;return await r({billingAddress:M??o.value,fallbackPhoneNumber:d}),{status:"success"}}recordPaymentMethodSelected(e){const{observability:s,userEvents:a,source:n,checkout:r,shop:o}=this.deps,d=e.paymentMethod.toLowerCase(),{paymentMethodName:i,paymentBrands:l}=Dn(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:Ma()}}),a.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...as(n,r,o),action:"payment_method_selected",paymentMethodName:i}})}async handleNewCardResponse(e,s,a){const{shopPay:n,markShopCashStatesStale:r}=this.deps;
2if(e.status==="success"&&e.creditCard){if(s&&e.creditCard.funding!=="debit")return await this.deleteCreditCardById({id:e.creditCard.id,uuid:e.creditCard.uuid}),{status:"failed",errors:[{field:["",fs.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 Tn("Failed to refresh Shop Pay buyer details")),!1}}async selectCreditCardAndSetPaymentLine({id:e}){const s=ns(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&&H(r)&&r.paymentAttributes.id===e&&Qe(r,n.user.paymentMethods.value,ye(r,this.availablePaymentMethods.value))&&this.#e(r),await a}#e(e,s){const{shopPay:a,setPaymentLine:n,observability:r}=this.deps;Ns(()=>{a.session.selectPaymentMethod(e);const o=Aa({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=>!rs([s],"SHOP_PAY"))}}function Un(){const t=Vn(),{newCardSignal:e,hasLoadedSignal:s}=Ge(),a=e.value,n=s.value,{value:r}=Y().paymentLines,o=r?.lines?.find(d=>d.method.type==="direct");return t.value&&!n&&o&&(s.value=!0,!a&&o.method.paymentMethodIdentifier&&(e.value=o.method)),e}function Vn(){const t=L().checkout.configuration.layout.isOnePage.value,{paymentMethods:e}=Y();return B(()=>t?!!is(e.value).length:!1)}const On={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 $n(){const{checkout:{address:{extendedAddressMode:t}},graphql:{shopPayGraphql:e},source:s}=L(),a=Pe({source:s});return S(async(n,r,o,d,i=a)=>{const{data:l,error:c}=await e.mutate(On,{variables:{billingAddress:ht(n,t),origin:i,sessionId:r,nickname:d,checkoutContext:o}});if(c||l==null||l.creditCardCreate==null)return{status:"failed"};const{creditCardCreate:u}=l;return os(u.userErrors)?{status:"blocked_by_autopay"}:u.userErrors.length>0?{status:"failed",errors:u.userErrors}:u.threeDSecureAuthenticationRequest?{status:"requires_redirect",threeDSecureAuthenticationRequest:u.threeDSecureAuthenticationRequest}:{status:"success",creditCard:u.creditCard?pt(u.creditCard):void 0}},[a,t,e])}const Kn={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 Gn(){const{checkout:{address:{extendedAddressMode:t}},graphql:{shopPayGraphql:e},source:s}=L(),a=Pe({source:s});return S(async(n,r,o,d=a)=>{const{data:i,error:l}=await e.mutate(Kn,{variables:{verificationId:r,billingAddress:ht(n,t),origin:d,nickname:o}});if(l||i==null||i.creditCardCompleteVerificationAndVault==null)return{status:"failed"};const{creditCardCompleteVerificationAndVault:c}=i;return os(c.userErrors)?{status:"blocked_by_autopay"}:c.userErrors.length>0?{status:"failed",errors:c.userErrors}:{status:"success",creditCard:c.creditCard?pt(c.creditCard):void 0}},[a,t,e])}const Yn={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 qn(){const{graphql:{shopPayGraphql:t},source:e}=L(),s=Pe({source:e});return S(async(a,n,r,o=s)=>{const{data:d,error:i}=await t.mutate(Yn,{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 zn(t,{checkoutVersion:e,checkoutIdentifier:s,shopifyDomain:a,shopId:n,redirectSource:r},{cache:o=!0}={}){return t.staticQuery(ln,{variables:{checkoutContextInput:{checkoutVersion:e,checkoutIdentifier:s,shopifyDomain:a,shopId:n},shopifyDomain:a,redirectSource:r??void 0},cache:o})}function Hn(){const{graphql:{shopPayGraphql:t},source:e,shop:{myshopifyDomain:s,id:a},shopPay:{config:n}}=L(),{checkoutSessionIdentifier:r}=e,o=Pe({source:e}),{redirectSource:d}=n;return S(async()=>{const{data:i,error:l}=await zn(t,{checkoutVersion:o,checkoutIdentifier:r??"unknown",shopifyDomain:s,shopId:Fe(a),redirectSource:d},{cache:!1});return l||i==null||i.checkoutSession==null||i.checkoutSession.user==null?{status:"failed"}:cn(i)},[r,o,d,a,s,t])}const Wn={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},source:s}=L(),a=Pe({source:s});return S(async(n,r,o,d,i,l=a)=>{const{data:c,error:u}=await e.mutate(Wn,{variables:{id:r,uuid:o,billingAddress:ht(n,t),origin:l,nickname:i,checkoutContext:d}});if(u||!c?.creditCardUpdate)return{status:"failed"};const{creditCardUpdate:p}=c;return p.userErrors.length>0?{status:"failed",errors:p.userErrors}:{status:"success",creditCard:p.creditCard?pt(p.creditCard):void 0}},[a,t,e])}function jn(t){const{geolocation:e}=Gs(),{shopPay:s,checkout:a}=L(),n=s.user.phoneNumber.value,r=s.user.addresses.value,o=a.configuration.addressSettings.nonBillingAddressSettings.value,d=r[0]?.address,i=o.defaultShippingDetails.country?.code??e.country.code;return J(()=>{const l={firstName:d?.firstName,lastName:d?.lastName,phone:n,countryCode:d?.countryCode||i,zoneCode:d?.zoneCode};return Ia(l,{extendedAddressMode:a.address.extendedAddressMode})},[a.address.extendedAddressMode,t,d,i,n])}const Xn={id:"563e8a86083a6c9ad5bd44d3a4db471e3a9919052512d2745d267074d97420fd",type:"mutation",name:"DeleteVaultedCreditCard",source:""},Zn={id:"d1f468f7d6684d3133e47cef5cf1ef67ccd2bd916b53203708d85ac3175f1bd0",type:"mutation",name:"UpdateCustomerCreditCard",source:""};class Jn extends Error{constructor(e){super("Failed to update customer credit card payment method",e),this.name="UpdateCustomerCreditCardPaymentMethodError"}}class er extends Error{constructor(e){super("Failed to delete customer credit card payment method",e),this.name="DeleteCustomerCreditCardPaymentMethodError"}}async function tr({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(Zn,{variables:{customerCreditCardModificationInput:{token:n,defaultPaymentMethod:a,billingAddress:{streetAddress:La(e,{extendedAddressMode:s})}}}});if(!o?.modifyCustomerCreditCardPaymentMethod||d)throw new Jn({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 sr({graphql:t,token:e,genericError:s}){if(!e)return{token:void 0};try{const{data:a,error:n}=await t.mutate(Xn,{variables:{token:e}});if(!a?.deleteCustomerCreditCardPaymentMethod||n)throw new er({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 ar({userEvents:t,shopId:e,checkoutSessionIdentifier:s,card:a}){t.monorailEvent({schemaId:"checkout_vaulted_payment_method_selected/1.0",payload:{shopId:parseInt(Fe(e),10),checkoutSessionIdentifier:s||"",paymentMethodId:parseInt(Fe(a.id),10),paymentInstrumentAccessorId:-1}})}class nr extends Yt{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 vs({observability:t,managerName:e,methodName:s,identity:a,deployStage:n,isLocalDevelopment:r}
2){if(r||n!=="production"&&n!=="canary")return;const o=new nr({managerName:e,methodName:s,identity:a,deployStage:n,isLocalDevelopment:r});t.error(o,{severity:"warning"})}const Nt={status:"failed"};class Te{constructor(e){this.disabledCardMethodsForInstallments=N([]),this.isEveryCardDisabled=N(!1),this.canSetCreditCardNickname=N(!1),this.addCreditCardStrategy="direct-session-payment-line",this.deps=e,this.usesCustomerAccountSelectionRule=e.identity==="customerAccount",this.newCard=e.newCard??N(void 0);const{proposal:s}=e,{proposed:a,negotiated:n}=s,{paymentMethods:r}=n.fields,o=n.fields.paymentMethodHistory??N([]);this.availablePaymentMethods=I(()=>r.value??[]),this.promotedMethods=e.paymentMethodPromotions.promoted,this.customerCreditCards=I(()=>Da(this.availablePaymentMethods.value)),this.selectableCustomerCreditCards=I(()=>is(this.availablePaymentMethods.value)),this.selectablePaypalBillingAgreements=I(()=>(e.displayablePaymentMethods?.value??this.availablePaymentMethods.value).filter(i=>i.type===ge.PayPal)),this.selectableCustomerBanks=I(()=>this.availablePaymentMethods.value.filter(i=>i.type==="bank"&&i.availableInstruments.length>0)),this.nonCardKnownPaymentMethods=I(()=>xa({paymentMethodHistory:o.value??[],availablePaymentMethods:e.displayablePaymentMethods?.value??this.availablePaymentMethods.value})),this.availableUserStoredPaymentMethods=I(()=>[...Ue([je({card:this.newCard.value,billingAddress:a.billingAddress.value})]),...this.selectableCustomerCreditCards.value.map(i=>kt(i,{cvvVerificationEnabled:this.deps.storeVaultGuestCvvVerificationEnabled})),...this.selectablePaypalBillingAgreements.value.map(Ta),...lr(this.selectableCustomerBanks.value.map(Ra),this.nonCardKnownPaymentMethods.value,this.promotedMethods.value)]),this.autoselectTarget=I(()=>{const i=this.selectableCustomerCreditCards.value.find(h=>h.defaultPaymentMethod),l=i?this.availableUserStoredPaymentMethods.value.find(h=>h.id===i.token):void 0,c=cr(this.availableUserStoredPaymentMethods.value);if(this.usesCustomerAccountSelectionRule){const h=!c||G(c);if(this.deps.storeVaultEnabled&&h&&l)return l}else if(i)return l;if(c)return c;const u=this.selectableCustomerCreditCards.value[0];if(u)return this.availableUserStoredPaymentMethods.value.find(h=>h.id===u.token);const p=this.availableUserStoredPaymentMethods.value.find(h=>!G(h)&&!st(h));return p||this.availableUserStoredPaymentMethods.value.find(st)}),this.proposedSelectedPaymentMethod=I(()=>rr(a.paymentLines.value,this.availableUserStoredPaymentMethods.value,this.availablePaymentMethods.value,je({card:this.newCard.value,billingAddress:a.billingAddress.value}))),this.selectedPaymentMethod=I(()=>this.proposedSelectedPaymentMethod.value??this.autoselectTarget.value),this.paymentMethods=I(()=>{const i=je({card:this.newCard.value,billingAddress:a.billingAddress.value}),l=[...Ue([i]),...this.customerCreditCards.value.map(u=>kt(u,{cvvVerificationEnabled:this.deps.storeVaultGuestCvvVerificationEnabled}))].map(u=>({method:u,isValidForCheckout:!0,isExpired:u.paymentAttributes.expired,isDisabled:!1,...mr({identity:this.deps.identity,storeVaultEnabled:this.deps.storeVaultEnabled,card:u})})),c=this.availableUserStoredPaymentMethods.value.filter(u=>!G(u)).map(u=>({method:u,isValidForCheckout:!0,isExpired:!1,isDisabled:!1,canEdit:!1,canDelete:!1,canSetDefault:!1,isDefault:!1}));return ur({cardItems:l,nonCardItems:c,autoselectTarget:this.usesCustomerAccountSelectionRule?this.autoselectTarget.value:void 0})}),this.selectedPaymentMethodItem=I(()=>{const i=this.selectedPaymentMethod.value;if(i)return this.paymentMethods.value.find(({method:l})=>l.id===i.id&&l.paymentMethod===i.paymentMethod)}),this.selectedCreditCard=I(()=>{const i=this.selectedPaymentMethod.value;return G(i)?i.paymentAttributes:void 0}),this.cardPaymentMethods=I(()=>this.paymentMethods.value.filter(i=>G(i.method))),this.activeOrExpiredCardMethods=this.cardPaymentMethods,this.isEveryCardExpired=I(()=>{const i=this.cardPaymentMethods.value;return i.length>0&&i.every(l=>l.isExpired)});const d=I(()=>{const i=we(this.availablePaymentMethods.value);if(!ut(i))return!1;const l=this.selectedCreditCard.value;return l?a.paymentLines.value.some(c=>
2l.id===W?c.method.type==="direct":c.method.type===ge.CreditCard&&c.method.token===l.id):!1});this.msi={binResolution:"client",selectedCardBin:I(()=>{const i=this.selectedCreditCard.value;if(i)return i.id===W?this.newCard.value?.creditCardFirstDigits:this.selectableCustomerCreditCards.value.find(l=>l.token===i.id)?.firstDigits}),clearInstallments:Pt,expandedVisible:d,collapsedVisible:d}}async promoteSelectedPaymentMethod(e){const s=Na(e,null);return s?(this.deps.paymentMethodPromotions.promote(s),this.selectPaymentMethod(s,"buyer")):{status:"handled",effects:{...re,selectByBuyerKey:fe(e)}}}canShowAsGuestCheckoutMethod(){return!1}async selectPaymentMethod(e,s="programmatic"){if(!e)return{status:"not-handled"};if(!G(e)){const n=ye(e,this.availablePaymentMethods.value);if(!n)return{status:"not-handled"};const r=fe(n);return s==="buyer"?{status:"handled",effects:{...re,selectByBuyerKey:r}}:(this.deps.setPaymentLine(r),{status:"handled",effects:re})}if(s==="buyer")return this.selectCreditCardByBuyer({paymentMethod:e});if(e.id===W)return this.deps.setPaymentLine(W),{status:"handled",effects:re};const a=this.selectableCustomerCreditCards.value.find(n=>n.token===e.paymentAttributes.id);return a?(this.deps.setPaymentLine(De(a)),{status:"handled",effects:re}):{status:"not-handled"}}async deleteCreditCard({id:e}){if(e===W){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];
2if(d)this.deps.setPaymentLine(De(d));else{const i=this.autoselectTarget.value,l=i?ye(i,this.availablePaymentMethods.value):void 0;l?this.deps.setPaymentLine(fe(l)):o.paymentLines.value=o.paymentLines.value.filter(c=>c.method.type!=="direct")}return{status:"success",shouldResetSuggestedBillingAddress:!!d,shouldResetBillingAddressToShipping:this.deps.identity!=="businessCustomer"}}const s=this.selectedPaymentMethod.value,a=G(s)&&s.id===e,n=this.selectableCustomerCreditCards.value.find(o=>o.token!==e),r=await sr({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(De(n)),{status:"success",shouldNegotiatePaymentMethods:!0}):{status:"failed",bannerError:r.error}}async updateCreditCard({id:e,billingAddress:s,defaultPaymentMethod:a=!1}){const n=await tr({graphql:this.deps.graphql,token:e,address:s,extendedAddressMode:this.deps.extendedAddressMode,defaultPaymentMethod:a,genericError:this.deps.i18n.translate("shipping.address_form.generic_error")});return n.token?{status:"success",shouldNegotiatePaymentMethods:!0}:{status:"failed",bannerError:n.error}}async addCreditCard(){return this.reportUnexpectedUse("addCreditCard"),Nt}async completeCreditCardVerificationAndVault(){return this.reportUnexpectedUse("completeCreditCardVerificationAndVault"),Nt}dispose(){}async selectCreditCardByBuyer({paymentMethod:e}){let s,a,n;if(e.id===W){const r=this.newCard.value;if(!r)return{status:"not-handled"};s=W,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=De(r),n=r.firstDigits,ar({userEvents:this.deps.userEvents,shopId:this.deps.shopI
2d,checkoutSessionIdentifier:this.deps.checkoutSessionIdentifier,card:r})}return this.deps.isMsiAvailable&&(this.deps.proposal.proposed.paymentLines.value=Pt(this.deps.proposal.proposed.paymentLines.value)),{status:"handled",effects:{...re,selectByBuyerKey:s,...a?{selectByBuyerPaymentMethod:a}:{},updateSelectedCardBin:!0,selectedCardFirstDigits:n,preserveExistingBinPrefix:e.id===W,claimMsiBin:this.deps.isMsiAvailable,claimedMsiBin:this.deps.isMsiAvailable?n:void 0,shouldNegotiate:!0}}}reportUnexpectedUse(e){vs({...this.deps,managerName:"CustomerPaymentMethodManager",methodName:e})}}function rr(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(st);if(d)return d;continue}if(ir(r)){const d=e.filter(G).find(i=>i.id===r.method.token);if(d)return d;continue}if(or(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=dr(r,e,s);if(o)return o}}function je({card:t,billingAddress:e}
2){if(!(!t?.brand||!t.creditCardLastFourDigits))return{id:W,paymentMethod:"CREDIT_CARD",paymentAttributes:{id:W,brand:t.brand,expired:!1,expiryMonth:0,expiryYear:0,lastDigits:t.creditCardLastFourDigits,name:t.cardholderName,billingAddress:{address:e??{}}},lastUsedAt:null}}function Ue(t){return t.filter(e=>e!==void 0)}function ir(t){return t.method.type===ge.CreditCard}function or(t){return t.method.type===ge.PayPal}function dr(t,e,s){const a=fe(t.method);return e.find(n=>{if(G(n))return!1;const r=ye(n,s);return r?a===fe(r):!1})}function lr(...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 cr(t){return t.reduce((e,s)=>s.lastUsedAt?e?.lastUsedAt?s.lastUsedAt>e.lastUsedAt?s:e:s:e,void 0)}function ur({cardItems:t,nonCardItems:e,autoselectTarget:s}){const a=t.find(({method:h})=>h.id===W),r=[...t.filter(({method:h})=>h.id!==W)].sort((h,v)=>be(h.method,v.method)),o=[...e].sort((h,v)=>be(h.method,v.method)),d=r.filter(Dt),i=o.filter(Dt),l=d.find(({method:h})=>G(h)&&h.paymentAttributes.defaultPaymentMethod),c=[d[0],i[0]].filter(h=>h!==void 0).sort((h,v)=>be(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?[...Ue([a]),p,...r.filter(h=>h!==p),...o.filter(h=>h!==p)]:[...Ue([a]),...r,...o]}function Dt(t){return t.isValidForCheckout&&!t.isExpired&&!t.isDisabled}function mr({identity:t,storeVaultEnabled:e,card:s}){if(s.id===W)return hr;if(t==="businessCustomer")return Xe;const{paymentAttributes:a}=s;return e?a.expired?a.deletable?{canEdit:!1,canDelete:!0,canSetDefault:!1,isDefault:!!a.defaultPaymentMethod}:Xe:{canEdit:!0,canDelete:!!a.deletable,canSetDefault:!0,isDefault:!!a.defaultPaymentMethod}:Xe}const Xe={canEdit:!1,canDelete:!1,canSetDefault:!1,isDefault:!1},hr={canEdit:!1,canDelete:!0,canSetDefault:!1,isDefault:!1},Re={status:"failed"};class pr{constructor(e){this.availablePaymentMethods=N([]),this.availableUserStoredPaymentMethods=N([]),this.paymentMethods=N([]),this.selectedPaymentMethod=N(void 0),this.selectedPaymentMethodItem=N(void 0),this.selectedCreditCard=N(void 0),this.activeOrExpiredCardMethods=N([]),this.disabledCardMethodsForInstallments=N([]),this.isEveryCardDisabled=N(!1),this.isEveryCardExpired=N(!1),this.cardPaymentMethods=N([]),this.promotedMethods=N([]),this.msi={binResolution:"client",selectedCardBin:N(void 0),clearInstallments:s=>s,expandedVisible:N(!1),collapsedVisible:N(!1)},this.newCard=N(void 0),this.canSetCreditCardNickname=N(!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"),Re}async updateCreditCard(){return this.reportUnexpectedUse("updateCreditCard"),Re}async addCreditCard(){return this.reportUnexpectedUse("addCreditCard"),Re}async completeCreditCardVerificationAndVault(){return this.reportUnexpectedUse("completeCreditCardVerificationAndVault"),Re}dispose(){}reportUnexpectedUse(e){vs({...this.unexpectedUseOptions,managerName:"FallbackPaymentMethodManager",methodName:e})}}function ki({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}}=L(),u=a.identity.current.value,p=n.hasFlagEnabled(Ba),h=s.devMode!=null,v=$n(),g=Gn(),M=qn(),b=Hn(),f=Qn(),A=Pe({source:e}),k=jn(),D=ee(),{paymentLines:E}=D,_=Un(),{buyerHasActedSignal:x,newCardSignal:V}=Ge(),R=lt(ps),F=i.user.phoneNumber.value,T=Y(),P=an(),q=i.session.isInstallmentsSelected.value,te=nn({isApplePayAvailable:P.value}),se=Fa(),{creditCardDisabled:$}=un(),Q=dn(),{updateCheckoutAddress:z}=rn(),[,me]=on({allowPreselect:!1}),oe=we(T.paymentMethods.value??[]),de=ut(oe),he=ds(),{eligibilityByCardId:pe}=Ua(hn),_e=S(()=>{R&&(R.cashbackState.stale.value=!0)},[R]),Se=J(()=>({checkoutIdentifier:e.checkoutSessionIdentifier??"",checkoutVersion:A,shopId:Fe(n.id),shopifyDomain:n.myshopifyDomain}),[e.checkoutSessionIdentifier,n.id,n.myshopifyDomain,A]),K=J(()=>{const Ce=()=>new Fn({shopPay:i,negotiatedPaymentMethods:T.paymentMethods,installmentsPaymentMethodSelected:q,isApplePayAvailable:P.value,filteredNegotiatedPaymentMethods:te.value,isCreditCardDisabled:$,setPaymentLine:me,updateCheckoutAddress:z,shippingRequired:a.isShippingRequired,i18n:r,observability:o,userEvents:d,source:e,checkout:a,shop:n,createCreditCard:v,deleteCreditCard:M,updateCreditCard:f,completeCreditCardVerification:g,refreshBuyerDetails:b,markShopCashStatesStale:_e,shopPayGraphql:c,emptyAddress:k,proposedPaymentLines:E,checkoutContext:Se,fallbackPhoneNumber:F,paymentRequiredMethod:Q.value,msiEligibilityByCardId:pe,hasSellingPlan:he});return u==="shopPay"?Ce():u==="customerAccount"||u==="businessCustomer"?new Te({proposal:a.proposal,newCard:_,displayablePaymentMethods:se,paymentMethodPromotions:a.paymentMethodPromotions,setPaymentLine:me,isMsiAvailable:de,shopId:n.id,checkoutSessionIdentifier:e.checkoutSessionIdentifier,storeVaultEnabled:n.storeVaultEnabled,storeVaultGuestCvvVerificationEnabled:n.storeVaultGuestCvvVerificationEnabled,graphql:l,extendedAddressMode:a.address.extendedAddressMode,i18n:r,observability:o,userEvents:d,identity:u,deployStage:s.deployStage,isLocalDevelopment:h}):new pr({observability:o,identity:u,deployStage:s.deployStage,isLocalDevelopment:h})},[u,s.deployStage,h,i,T.paymentMethods,q,P.value,te.value,se,$,de,me,z,a,o,d,e,n,r,l,c,v,M,b,f,g,_e,k,E,_,Se,F,Q.value,pe,he]);U(()=>()=>K.dispose(),[K]);const y=K.selectedPaymentMethod.value,C=K.paymentMethods.value,w=K.availablePaymentMethods.value,O=K.availableUserStoredPaymentMethods.value,
2j=E.value.some(Ce=>Ce.method.type==="direct");U(()=>{if(!t||u!=="shopPay"||y&&Nn({selected:y,paymentMethods:C,availablePaymentMethods:w})||j)return;const Ce=C.filter(({isValidForCheckout:ue})=>ue).sort((ue,ze)=>be(ue.method,ze.method)).map(({method:ue})=>ue),Me=Ln(Ce);Me&&G(Me)&&Me.paymentAttributes.expired&&d.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.1",payload:{...as(e,a,n),action:"final_payment_method_expired_after_merchant_filter"}});const vt=Me?at(Me,i.user.paymentMethods.value):void 0;if(vt)i.session.selectPaymentMethod(vt);else{const ue=p?"unavailable":"explicit",ze=i.session.clearPaymentMethod(ue),bt=i.user.creditCards.peek().length;ze&&bt>0&&o.log("shop_pay_payment_method_auto_cleared","[usePaymentMethodManager] No listed payment method was valid for checkout, so the Shop Pay selection was cleared",{checkout_session_identifier:e.checkoutSessionIdentifier,source_type:e.type,clear_reason:ue,held_card_count:bt,listed_method_count:C.length,valid_for_checkout_count:Ce.length,negotiated_direct_present:!!oe})}},[t,w,O,a,u,oe,o,d,C,p,y,n,i.session,i.user.creditCards,i.user.paymentMethods.value,e,j]);const ae=x.value,Le=!!V.value,le=K instanceof Te?K.autoselectTarget.value:void 0,Ne=K instanceof Te?K.proposedSelectedPaymentMethod.value:void 0,ft=E.value[0],qe=ft?.method.type,Ct=mn(ft);return U(()=>{t&&(u!=="customerAccount"&&u!=="businessCustomer"||ae||K instanceof Te&&le&&(Le||Ct||Ne&&Ne.paymentMethod===le.paymentMethod&&Ne.id===le.id||(qe&&o.log("payment_method_manager_programmatic_selection_replaced_primary_line","Programmatic payment method selection replaced the proposed primary payment line",{replacedPaymentLineMethodType:qe,replacingPaymentMethodType:le.paymentMethod}),K.selectPaymentMethod(le,"programmatic").catch(()=>{}))))},[t,u,ae,Le,K,le,Ne,Ct,qe,o]),K}function Ei(){const{shop:t,checkout:e,observability:s}=L(),a=e.wallets.activeSession.value,n=e.latestReceipt.value,{persistedPayPalSignal:r}=ss(),o=e.identity.current.value==="payPal",d=n?.id,i=Ys().value,l=i!==void 0,c=Ye(),u=r.value,{negotiate:p}=Ke(),h=qs(),v=Wt(new Set(Va))?.hasError&&d!==u?.receiptIdForClearedToken,g=zs("PAYPAL_EXPRESS").value?.merchantId?.trim(),M=i?.method.walletContent?.merchantId?.trim(),f=t.hasFlagEnabled(Oa)&&g&&M&&M!==g,A=u?.billingAgreementStatus&&$a({checkout:e})&&u.billingAgreementStatus==="NOTREQUESTED"&&!i?.method.walletContent?.isVaultWithPurchaseOrder,k=i?.method.walletContent?.isVaultWithPurchaseOrder===!0&&c.value?.amount===0;U(()=>{function D(){const _={...r.value,receiptIdForClearedToken:v?d:void 0,newTokenRequiredDueToError:!0,billingAgreementStatus:void 0};r.value=_}function E(){let _;v?_="SubmitForCompletion Error":f?_="Gateway Mismatch":k?_="Zero Payment Due":_="Subscription Added",s.counter({name:"paypal_token_cleared",value:1,attributes:{clearReason:_}}),s.log("paypal_token_cleared","Clearing PayPal token due to error",{clearReason:_})}l&&((v||f||A||k)&&(E(),D()),(async()=>(k||v&&!o&&!a)&&(h(),await p({silenceViolations:["non-stock"]})))())},[v,l,f,d,s,r,A,k,o,h,p,a])}function yr(t){const e=Y().paymentMethods;return B(()=>{const a=!!t.value?.balance?.amount,n=!!e.value?.find(r=>r.type==="redeemable"&&r.redemptionSource==="STORE_CREDIT");return!!(a&&n)})}var ie=(t=>(t.Init="init",t.Loading="loading",t.Success="success",t.Error="error",t.Stale="stale",t))(ie||{});function Ve(t,e){return t.filter(s=>!gs(s,e))}function bs(t,e){return t.some(s=>gs(s,e))}function fr({firstOrderTotal:t,storeCreditAccount:e,includeExhausted:s=!1}){if(!t||!e||t.currencyCode!==e.balance.currencyCode)return;const a=e.balance.amount-t.amount;if(!(a<=0&&!s))return{amount:Math.max(a,0),currencyCode:e.balance.currencyCode}}function gs(t,e){return yt(t)&&t.method.redemptionContent&&"storeCreditAccountId"in t.method.redemptionContent&&t.method.redemptionContent.storeCreditAccountId===e.id}function Cr(t){const e=Y().paymentLines;return B(()=>{const s=t.value;return!s||!e.value?.lines?!1:bs(e.value.lines,s)})}function vr(){const{shop:{currencyCode:t}}=L(),s=Y().buyerIdentity;return B(()=>{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 wi(){const t=Y().paymentLines;return B(()=>t.value?.lines.filter(e=>yt(e))||[])}const br=new Set(["Image","Banner","s-image","s-banner"]);function gr({options:t,paymentMethodExtension:e}){const s=e[0]?.extension;if(!s)return null;const a=s.appId.split("/").pop(),n=a&&!fn.includes(a);return m(Hs,{options:t,customizations:e,transformComponents:n?Pr:void 0})}const Pr=Ws(br);function _r(){const t=Y().allViolations,e=B(()=>(t.value??[]).filter(a=>!!(Qs(a)||Ka(a)))),s=B(()=>{const[a]=e.value;return a?a.localizedMessage||a.nonLocalizedMessage:null});return m(Oe,{when:s,children:a=>m(Xt,{tone:"critical",errorType:Zt.DiscountError,children:a})})}function Sr({amount:t,maskedIdentifier:e,remove:s}){const{i18n:a}=L(),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:js(r)}),d=a.translate("order_summary.gift_card_ending",{last_characters:r||""});return m(Ee,{borderRadius:"base",background:"base",border:"base",blockAlignment:"center",padding:"small-200",children:m(We,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1fr) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",children:[m(We,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-300",alignItems:"center",alignContent:"center",children:[m(hs,{type:"gift-card"}),m(Jt,{children:[m(ne,{accessibilityVisibility:"hidden",children:o}),m(ne,{accessibilityVisibility:"exclusive",children:d})]})]}),m(We,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-100",alignItems:"center",alignContent:"center",children:[m(ne,{type:"strong",children:n}),m(es,{onClick:()=>s(),accessibilityLabel:a.translate("general.remove_item",{label:d}),children:m($e,{type:"x",size:"small"})})]})]})})}const xt="gift_card_option";function Ii({afterAppliedRedeemablesChange:t,autoSelect:e=!1,showHeading:s=!0}){const{i18n:a}=L(),{paymentMethod:n,paymentLines:r,submit:o,remove:d,removeAll:i}=Xs(),l=Zs("Checkout::GiftCard::Render",n?.uiExtension?[n?.uiExtension]:[]),{value:c}=Ye(),u=c?.amount||0,[p,h]=X([]),[v,g]=X(!1),M=u===0&&r?.length===0,b=async _=>{h(_),_.length===0&&r.length>0&&(await i())?.status==="success"&&t?.()};U(()=>{M?h([]):(r?.length>0||e)&&h([xt])},[e,r?.length,M]);const f=S(async(_,x)=>{const V=await o(_,x);
2return V?.status==="success"&&(g(!1),t?.()),V},[t,o]),A=J(()=>({paymentMethodIdentifier:n?.paymentMethodIdentifier??"",submitRedeemablePaymentLine:f}),[n?.paymentMethodIdentifier,f]),k=_=>{const{cost:x,method:V}=_;if(!x||V.redemptionSource!=="CUSTOM")return null;const R=V.redemptionContent?.redemptionAttributes.reduce((F,T)=>`${F},${T.key}:${T.value}`,"");return m(Sr,{maskedIdentifier:V.redemptionContent?.maskedIdentifier||"",amount:{amount:x.amount,currencyCode:x.currencyCode},remove:async()=>{(await d(V))?.status==="success"&&t?.()}},R)},D=()=>{if(u===0||!l.length||!n)return null;const _=m(gr,{paymentMethodExtension:l,options:A});return!r||r.length===0?_:v?m(Ee,{children:[m(ve,{blockSize:"small-500"}),m(Z,{gap:"base",children:[m(et,{level:3,children:a.translate("payment.gift_card_wrapper.apply_another_gift_card_label")}),_]})]}):m(Ee,{children:[m(ve,{blockSize:"small-500"}),m(Qt,{textDecoration:"none",onClick:()=>g(!0),children:m(Z,{direction:"inline",alignItems:"center",gap:"small-400",children:[m($e,{type:"plus"}),m(ne,{children:a.translate("payment.gift_card_wrapper.apply_another_gift_card_label")})]})})]})},E=!!r?.length||!!l.length&&!!n;return m(Js,{id:"3p-gift-card-field",open:E,duration:"slow",children:m(ct,{accessibilityLabel:a.translate("payment.gift_card_wrapper.heading"),children:m(Z,{gap:"base",children:[s&&m(et,{level:2,children:a.translate("payment.gift_card_wrapper.heading")}),m(ys,{name:"gift_card_option_list",values:p,multiple:!0,onChange:b,variant:"block",children:m(tt,{value:xt,disabled:M,selectedContent:m(Z,{gap:"base",children:[r?.length>0?m(Z,{gap:"small-300",children:r.map(k)}):null,m(_r,{}),D()]}),children:a.translate("payment.gift_card_wrapper.apply_gift_card_label")})})]})})})}const Ae="StoreCreditRedemptionCheckbox",Ze="StoreCreditSubscriptionRenewalsCheckbox";function Ie(t,e){return yt(t)&&t.method.redemptionContent&&"storeCreditAccountId"in t.method.redemptionContent&&t.method.redemptionContent.storeCreditAccountId===e.id}function Mr(t,e){if(!(t.status!=="success"&&t.status!=="error"))return t.negotiated?.paymentLines?.lines.find(s=>Ie(s,e))?.cost}function Ar({paymentLines:t,storeCreditAccount:e,cost:s}){return t.map(a=>Ie(a,e)?{...a,cost:s}:a)}function Tt({amountDueAtCheckout:t,storeCreditAccount:e}){if(Ps({amountDueAtCheckout:t,storeCreditAccount:e})&&t!=null)return{amount:Math.min(t.amount,e.balance.amount),currencyCode:t.currencyCode}}function Ps({amountDueAtCheckout:t,storeCreditAccount:e}){return t==null||t.currencyCode===e.balance.currencyCode}function Rt({paymentLines:t,storeCreditAccount:e,cost:s}){let a=!1;const n=t.map(r=>{if(!Ie(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 _s(t,e,s){if(t.status!=="success"&&t.status!=="error")return!1;const a=t.negotiated?.paymentLines?.lines;return a==null?t.status==="success":bs(a,e)===s}function Ss(t){const{negotiate:e}=Ke();return S(async()=>new Promise(s=>{e({include:["paymentLines"],fieldsToResolve:["paymentLines"],silenceViolations:["non-store-credit"],runListenersOnError:!0,force:!0,onComplete(a){t.value=a.status==="success"?ie.Success:ie.Error,s(a)}})}),[e,t])}function kr(t,e){const s=ee(),a=Ss(e);return S(async()=>{if(!t)return e.value=ie.Error,{result:null,landed:!1};e.value=ie.Loading;const n=s.paymentLines.value,r=n.findIndex(l=>Ie(l,t)),o=n[r];s.paymentLines.value=Ve(n,t);const d=await a(),i=_s(d,t,!1);if(o&&!i){const l=Ve(s.paymentLines.value,t);s.paymentLines.value=[...l.slice(0,r),o,...l.slice(r)]}return{result:d,landed:i}},[t,e,s.paymentLines,a])}function Er(t,e){const{i18n:s,shop:a}=L(),n=ee(),r=Ss(e),o=Y().paymentLines,d=Ye(),i=ls(),l=ds(),c=cs(),u=Y().paymentFlexibilityPaymentTermsTemplate,p=Ga(a),h=Y().isImmediateAmountReducedForRedeemables,v=S(()=>p&&Ya({hasSellingPlan:l.value,hasFixedSellingPlan:c.value,paymentTermsTemplateType:u.value?.type}),[p,l,c,u]),g=ce(!1);return zt(()=>{if(!v())return;const M=d.value??i.value,b=n.paymentLines.value;if(!t||!g.current)return;const f=o.value?.lines.find(k=>Ie(k,t))?.cost;if(h?.value){if(f){const k=Rt({paymentLines:b,storeCreditAccount:t,cost:f});k!==b&&(n.paymentLines.value=k)}return}if(f&&f.amount>0){g.current=!1;return}const A=Rt({paymentLines:b,storeCreditAccount:t,cost:Tt({amountDueAtCheckout:M,storeCreditAccount:t})});
2A!==b&&(n.paymentLines.value=A)}),S(async()=>{if(!t)return e.value=ie.Error,{result:null,landed:!1};e.value=ie.Loading;const M=Ve(n.paymentLines.value,t),b=d.value??i.value,f=v(),A=f?Tt({amountDueAtCheckout:b,storeCreditAccount:t}):void 0;if(g.current=A!=null,f&&!Ps({amountDueAtCheckout:b,storeCreditAccount:t}))return e.value=ie.Error,ts({content:s.translate("store_credit_errors.generic_error")}),{result:null,landed:!1};n.paymentLines.value=[...M,{method:{type:"redeemable",redemptionSource:"STORE_CREDIT",redemptionContent:{storeCreditAccountId:t.id}},...A&&{cost:A}}];const k=await r();if(!_s(k,t,!0))return g.current=!1,n.paymentLines.value=Ve(n.paymentLines.value,t),{result:k,landed:!1};const D=f&&Mr(k,t);return D&&D.amount>0&&(g.current=!1,n.paymentLines.value=Ar({paymentLines:n.paymentLines.value,storeCreditAccount:t,cost:D})),{result:k,landed:!0}},[i,r,d,n.paymentLines,e,v,t,s])}function wr(t){const{shop:e}=L(),s=e.hasFlagEnabled(us),a=ls(),n=qa();return B(()=>{if(n.value)return fr({firstOrderTotal:a.value,storeCreditAccount:t.value,includeExhausted:s})})}function Li({afterAppliedRedeemablesChange:t}){const{i18n:e,shop:s,webMcp:a}=L(),n=s.hasFlagEnabled(us),r=Ye(),o=ee(),d=za(),i=cs(),l=vr(),c=Cr(l),u=Ds(ie.Init),p=yr(l),h=wr(l),v=B(()=>n&&h.value!=null),g=B(()=>d.value||i.value),M=B(()=>{if(d.value)return e.translate("payment.store_credit.buying_gift_card");if(i.value)return e.translate("payment.store_credit.no_fixed_selling_plans")});zt(()=>{(!p.value||!v.value||g.value)&&xs(()=>{o.useStoreCreditForSubscriptionRenewals.value&&(o.useStoreCreditForSubscriptionRenewals.value=!1)})});const b=Er(l.value,u),f=kr(l.value,u),A=B(()=>u.value===ie.Loading),k=B(()=>A.value||g.value),D=B(()=>k.value||r.value?.amount===0&&!c.value),E=k,_=B(()=>{const $=[],Q=v.value&&o.useStoreCreditForSubscriptionRenewals.value;return(c.value||Q)&&$.push(Ae),Q&&$.push(Ze),$}),x=S(async $=>{const Q=c.peek(),z=$.includes(Ae),oe=n&&!(Q&&!z)&&$.includes(Ze),de=z||oe,he=o.useStoreCreditForSubscriptionRenewals.peek();if(o.useStoreCreditForSubscriptionRenewals.value=oe,de!==Q){const{landed:pe}=de?await b():await f();if(!pe){o.useStoreCreditForSubscriptionRenewals.value=de?!1:he;return}t?.()}},[b,f,c,o.useStoreCreditForSubscriptionRenewals,n,t]),V=B(()=>p.value&&!!l.value),R=B(()=>_.value.includes(Ae)),F=S($=>x($?[...new Set([..._.peek(),Ae])]:[]),[_,x]);U(()=>a?.unstable_provideStoreCreditController({available:V,redeeming:R,applied:c,settling:A,hasGiftCard:d,hasFixedSellingPlan:i,paymentDue:r,setRedeeming:F}),[a,V,R,c,A,d,i,r,F]);const T=l.value;if(!V.value||!T)return null;const P=v.value?h.value:void 0,q=T.balance,te=M.value,se=P&&P.amount>0?e.translate("payment.store_credit.remaining_for_subscription_charges_description",{amount:e.formatCurrency(P.amount,{currency:P.currencyCode})}):void 0;return m(ct,{accessibilityLabel:e.translate("payment.store_credit.label"),children:m(ys,{name:"store_credit_redemption",values:_.value,multiple:!0,onChange:x,variant:"block",children:[m(tt,{value:Ae,disabled:D.value,secondaryContent:m(ne,{type:"strong",children:e.formatCurrency(q.amount,{currency:q.currencyCode})}),details:te&&m(ne,{children:te}),children:m(Z,{direction:"inline",gap:"base",alignItems:"center",children:[m(ne,{children:e.translate("payment.store_credit.apply_label")}),m(Oe,{when:A,children:m(ea,{})})]})}),P&&m(tt,{value:Ze,disabled:E.value,details:(se||te)&&m(Z,{gap:"small-500",children:[se&&m(ne,{children:se}),te&&m(ne,{children:te})]}),children:m(ne,{children:e.translate("payment.store_credit.use_remaining_for_subscription_charges_label")})})]})})}function Ni(){const{i18n:t}=L(),{hasViolations:e}=ta(Ha);return e?m(Xt,{errorType:Zt.PaymentError,tone:"critical",children:t.translate("store_credit_errors.generic_error")}):null}const Ir="YVGTZ",Lr="zyVks",Nr="U4h7p",Je={Row:Ir,Name:Lr,Digits:Nr};function Di({name:t,digits:e,icon:s}){return m(Z,{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 Dr=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 xr(t){const e=Dr.get(t.toLowerCase());if(e)return e;const s=t.toUpperCase();return Wa(s)?ms(s):t}function xi(t){return t?t.nickname&&t.nickname.trim().length>0?t.nickname:t.bank&&t.bank.trim().length>0?t.bank:xr(t.brand):""}function Tr(){const{paymentLines:t}=ee();return B(()=>ns(t.value))}function Rr({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 Bt({id:t,variant:e}){const{i18n:s}=L(),a=e==="prompt"?s.translate("msi_installments.enter_card_details_prompt"):s.translate("msi_installments.loading_installments");return U(()=>
2{if(e==="loading")return ts({content:a})},[a,e]),m(ra,{id:t,name:"msiInstallments",label:s.translate("msi_installments.payment_plan_label"),value:e,disabled:e==="loading",onChange:()=>{},children:m(na,{value:e,children:a})})}function Br({paymentMethod:t,isSelected:e,canEditBin:s=!0,isVaultedContext:a=!1,id:n="msiInstallmentsSelect"}){const{bankIdNumberSignal:r,installmentMonthsSignal:o,lastNegotiatedBinSignal:d}=Ge(),{paymentLines:i}=ee(),l=Tr();U(()=>{o.value=l.value},[l.value,o]);const c=s&&!a,u=t.installmentPlans?.find(M=>M.type==="MSI"),p=u?.supportedInstallments??[],h=Qa(r.value),v=!a&&h!==void 0&&d.value!==void 0&&h!==d.value;U(()=>{if(!l.value)return;(!e||!u||!h&&!c&&p.length===0)&&(i.value=aa(i.value,void 0))},[l.value,e,u,h,c,p.length,i]);const g=Rr({isSelected:!!e,hasMsiPlan:!!u,isStale:v,binPrefix:h,canEditBin:c,supportedInstallmentsCount:p.length,isNegotiating:!1});return g==="hidden"?null:g==="prompt"?m(Bt,{id:n,variant:"prompt"}):m(Bt,{id:n,variant:"loading"})}const Ft=ot({displayName:"MsiInstallmentsSelect",useError:sa("MsiInstallmentsSelect"),load:()=>Ts(async()=>({default:(await it(async()=>{const{MsiInstallmentsSelect:t}=await import("./component-MsiInstallmentsSelect.C06wSwUp.js");return{MsiInstallmentsSelect:t}},__vite__mapDeps([27,1,11,2,3,4,5,12,9,13,14,7,28,29,30,18,31,32,33,34,35,17,19,20,21,36,37,38,39,40,41,42,43,44,45,46,47,48,49]))).MsiInstallmentsSelect})),renderLoading:t=>m(Br,{...t})}),Ut=new Map,ke=class ke{constructor(e=[],s=[],a,n=!1){this.sdkQueue=e,this.initQueue=s,this.sdk=a,this.scriptLoaded=n,this.setupGeneration=0,this.currentSetupId=0}async load(e){let s=Ut.get(e.source);s instanceof Promise||(s=ia(e,!0),Ut.set(e.source,s)),await s,this.initQueue.pop()?.(),this.initQueue=[],this.scriptLoaded=!0}async setup(e,s,a){return Vt(()=>{if(this.sdk)return;if(this.setupPromise&&this.setupForm===e)return this.setupPromise;const n=window.CardFields;if(!n)throw new mt("Attempted to init Cardfields before it is ready");const r=++this.currentSetupId;return this.setupForm=e,a(),this.setupPromise=(async()=>{try{for(let o=0;o<ke.MAX_SETUP_ATTEMPTS;o++){const d=this.setupGeneration,i=await n.setup(e,s);if(r!==this.currentSetupId){try{i.teardown()}catch{}return}if(d!==this.setupGeneration){try{i.teardown()}catch{}continue}this.sdk=i;for(const l of this.sdkQueue)await l();this.sdkQueue=[];return}throw new _t(`CardFields setup failed: ${ke.MAX_SETUP_ATTEMPTS} consecutive teardowns raced setup.`)}finally{this.currentSetupId===r&&(this.setupPromise=void 0,this.setupForm=void 0)}})(),this.setupPromise},this.scriptLoaded,this.initQueue)}async teardown(){this.setupGeneration++,this.setupPromise=void 0,this.setupForm=void 0,this.sdk?.teardown(),this.sdk=void 0,this.sdkQueue=[],this.initQueue=[]}on(e,s,a){return this.scheduleSDK(n=>a?n.on(a,e,s):n.on(e,s))}off(e,s,a){return this.scheduleSDK(n=>a?n.off(a,e,s):n.off(e,s))}setStyles({field:e,styles:s}){return e?this.scheduleSDK(a=>a.setStyles(e,s)):this.scheduleSDK(a=>a.setStyles(s))}setFocus(e){return this.scheduleSDK(s=>s.setFocus(e))}setTranslation(e,s){return this.scheduleSDK(a=>a.setTranslation(e,s))}setPlaceholderContent(e,s){return this.scheduleSDK(a=>a.setPlaceholderContent(e,s))}setValue(e,s){return this.scheduleSDK(a=>a.setValue(e,s))}setTooltip(e,s){return this.scheduleSDK(a=>a.setTooltip(e,s))}vaultCard(e){return this.scheduleSDK(s=>s.vaultCard(e))}vaultCardMultipleTimes(e,s){return this.scheduleSDK(a=>a.vaultCardMultipleTimes(e,s))}setErrors(e){return this.scheduleSDK(s=>s.setErrors(e))}clearField(e){return this.scheduleSDK(s=>s.clearField(e))}loadFonts(e){return this.scheduleSDK(s=>s.loadFonts(e))}getFieldFrame(e){return this.scheduleSDK(s=>s._getFieldFrame(e))}scheduleSDK(e){return Vt(()=>{if(!this.sdk)throw new _t("The CardFields SDK has not been set up.");return e(this.sdk)},!!this.sdk,this.sdkQueue)}};ke.MAX_SETUP_ATTEMPTS=3;let nt=ke;function Vt(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 Ms=Bs(void 0),Ot={name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1};function Fr({children:t,value:e,sdkScriptAttributes:s,blurValidationEnabled:a=!0,blurValidationFieldDenylist:n,onError:r,onSetFieldErrors:o,onLoadSuccess:d}){const i=J(()=>new nt,[]),[l,c]=X(!0),[u,p]=X({name:null,number:null,verification_value:null,expiry:null,issue_date:null,issue_number:null,sdk:null}),h=ce(),[v,g]=X(),[M,b]=X(),[f,A]=X({name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1}),[k,D]=X(""),[E,_]=X([]),[x,V]=X(Ot),R=ce(x);U(()=>{R.current=x},[x]);const F=ce(),T=S(y=>{h.current=y instanceof oa?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 w=null;if(C.name===St.name)w=new St(C.message);else if(C.name===Mt.name){const O="httpStatus"in C&&typeof C.httpStatus=="number"?C.httpStatus:void 0;w=new Mt(C.message,O)}else C.name===At.hostedFieldsName&&(w=new At(C.message));if(w)return T(w),"";T(C)}throw C}},[T]),q=S(async(y,C={propagateErrors:!0})=>{const{sdk:w,...O}=y;await P(()=>i.setErrors(O)),p(j=>{const ae={...j,...y};return C.propagateErrors&&o?.(ae),ae})},[i,o,P]),te=S((y,C)=>{const w={},O=F.current;C?(y||(!f?.expiry&&C.includes("expiry")&&(w.expiry=O?.expiry),!f?.number&&C.includes("number")&&(w.number=O?.number_blank),!f?.name&&C.includes("name")&&(w.name=O?.name)),(y||C.includes("verification_value"))&&!f?.verification_value&&(w.verification_value=O?.verification_value)):(y||(f?.expiry||(w.expiry=O?.expiry),f?.number||(w.number=O?.number_blank),f?.name||(w.name=O?.name)),f?.verification_value||(w.verification_value=O?.verification_value));const j={...u,...w};return q(j),{isValid:!Object.values(j).some(Boolean)}},[u,f?.expiry,f?.name,f?.number,f?.verification_value,q]);U(()=>{async function y(){try{if(!s)throw new mt("Provider: hostedFieldsUrl must be provided");await i.load(s)}catch(C){C instanceof Error&&T(C)}}y()},[s,i,T]);const se=S(({cardType:y,bin:C,networks:w})=>{g(y),D(C),_(w)},[]),$=S(({targetName:y})=>{b(y)},[]),Q=S(async y=>{const{isValueValid:C,targetName:w,isValueEmpty:O}=y,j=F.current,ae=R.current[w],Le=!!n?.has(w);if(a&&!Le&&j&&ae){const le={[w]:C?null:j[w]};w==="number"&&O&&(le[w]=j.number_blank),await q(le,{propagateErrors:!1})}b(void 0)},[q,a,n]),z=S(async y=>{const{targetName:C,isValueEmpty:w,isTab:O}=y;if(!O){A(ae=>({...ae,[C]:!w})),V(ae=>({...ae,[C]:!0}));const j={[C]:null};await q(j)}},[q]),me=S(y=>
2{A(C=>({...C,[y]:!0}))},[]),oe=Ur(),de=S(()=>{oe.current&&(A({name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1}),_([]))},[A,oe]),he=S(()=>{P(()=>i.on("cardtype",se)),P(()=>i.on("focus",$)),P(()=>i.on("blur",Q)),P(()=>i.on("keyup",z)),P(()=>i.on("change",z)),P(()=>i.on("input",z))},[P,i,se,$,Q,z]),pe=S(()=>{P(()=>i.off("cardtype",se)),P(()=>i.off("focus",$)),P(()=>i.off("blur",Q)),P(()=>i.off("keyup",z)),P(()=>i.off("change",z)),P(()=>i.off("input",z))},[P,i,se,$,Q,z]),_e=S(()=>{V(Ot)},[]),Se=J(()=>({loadFonts:y=>P(()=>i.loadFonts(y)),setErrors:y=>q(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(w=>({...w,[y]:!0})),i.setValue(y,C))),setup:async(y,C,w=()=>{})=>{c(!0),await P(()=>i.setup(y,C,w)),d?.(),c(!1),F.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,q,P,d]);U(()=>()=>{o?.({})},[o]);const K=J(()=>e??{sdk:Se,errors:u,sdkLoadDiagnostics:h.current,cardBrand:v,bankIdNumber:k,networks:E,focusedField:M,filled:f,loading:l,validate:te,subscribe:he,unsubscribe:pe,resetTouched:_e,emptyFields:de,setFilled:me,touched:x},[Se,v,k,E,u,f,M,l,e,te,he,pe,_e,de,me,x]);return m(Ms.Provider,{value:K,children:t})}function Ur(){const t=ce(!0);return Rs(()=>()=>{t.current=!1},[]),t}const As=()=>{const t=lt(Ms);if(t==null)throw new mt("No cardfields found in context");return t},rt=6,ks=t=>t.toUpperCase(),$t=t=>t.toLowerCase();function Vr(t){return!!t?.some(e=>e.type==="direct"&&e.paymentBrands.includes("BOGUS"))}function Ti({paymentMethods:t,hasBogusGateway:e=Vr(t),paymentLines:s,storeVaultGuestCvvVerificationEnabled:a=!1,selectedCardRequiresProposalLineCvv:n=!1,selectedCardBrand:r,hasAmexCvvOnlyField:o=Or({paymentLines:s,storeVaultGuestCvvVerificationEnabled:a,selectedCardRequiresProposalLineCvv:n,selectedCardBrand:r})}){return e?new Set(["number"]):o?new Set(["verification_value"]):new Set}function Or({paymentLines:t,storeVaultGuestCvvVerificationEnabled:e=!1,selectedCardRequiresProposalLineCvv:s=!1,selectedCardBrand:a}){return!!(s&&a?.toUpperCase()==="AMEX"||e&&t?.some(({method:n})=>n.type===ge.CreditCard&&n.brand==="AMEX"))}function Ri(t){return t.replace(/([\d.]+)rem/g,(e,s)=>`${Number(s)*10/14}rem`)}function Bi(){const{paymentMethods:t}=Y();return B(()=>{const e=t.value?.filter(s=>s.type===ge.CreditCard&&!!s.expired);return e?e.length:0})}function Fi(){const{i18n:t}=L();return{getAccessibilityLabel:s=>{const a=s.type==="direct"?s.creditCardLastFourDigits:s.displayLastDigits;return`${ms(s.brand)} ${t.translate("payment.saved_credit_card_info")} ${a}`}}}function Es(t){return t?t.map(e=>ks(e)):[]}function $r({displayName:t,paymentBrands:e,paymentMethodIdentifier:s,selectableBrands:a,networkSelectionSupported:n}){const{bankIdNumber:r,networks:o,cardBrand:d}=As(),{userEvents:i,source:{checkoutSessionIdentifier:l}}=L(),[c,u]=X(!1),[p,h]=X(""),v=J(()=>Es(o||(d&&(r?.length??0)>=rt?[d]:void 0)),[o,d,r]);U(()=>{if(!r||r.length===0||!l)return;const g={checkoutToken:l,paymentMethodIdentifier:s,displayName:t||"",supportedBrands:e.join(","),detectedBrands:v.join(","),cardIsCobadged:v.length>1,shownBrands:a.join(","),networkSelectorShown:a.length>1&&n};c||(i.monorailEvent({schemaId:"checkout_credit_card_number_interaction/1.1",payload:{...g,eventName:"first_digit_entered"}}),u(!0));const M=r.length>=rt&&v.length>0,b=g.shownBrands!==p;M&&b&&(h(g.shownBrands),i.monorailEvent({schemaId:"checkout_credit_card_number_interaction/1.1",payload:{...g,eventName:"brand_shown_to_buyer"}}))},[s,t,e,v,a,r,i,l,n,p,c,u])}const ws=ja("CreditCardNetworkContext");function Kr({children:t,paymentMethod:e,publishesCardNetworkDetection:s=!1}){const{checkout:a,source:n,observability:r,userEvents:o}=L(),d=Fs(),i=e?fe(e):d,l=a.cardNetworkSelection.forMethod(i),{bankIdNumber:c,touched:u,...p}=As(),{networks:h,sdk:v,filled:g}=p,M=J(()=>Es(h),[h]),b=c?.replace(/\s/g,"").length??0,f=b>=rt&&p.cardBrand?ks(p.cardBrand):void 0,A=J(()=>M.filter(R=>e?.paymentBrands.includes(R)),[M,e]),k=!!e?.supportsNetworkSelection;U(()=>{s&&l.setDetectedState({networkSelectionEnabled:k,availableNetworks:A,cardBrand:f,numberFilled:!!g.number,bankIdNumberLength:b})},[s,l,k,A,f,g.number,b]);const D=l.selectableBrands.value;$r({displayName:e?.name,paymentBrands:e?.paymentBrands??[],paymentMethodIdentifier:e?.paymentMethodIdentifier??"",selectableBrands:D,networkSelectionSupported:e?.supportsNetworkSelection??!1});const E=S(R=>{const F=l.selectedSavedCreditCardBrand.value,T=typeof R=="function"?R(F):R;l.setSelectedSavedCreditCardBrand(T)},[l]),_=S(async()=>{const R=l.selectedNetwork.value,F=R?{selected_network:$t(R)}:void 0,T=await v.vaultCard(F);return Kt(o,{checkoutSessionIdentifier:n.checkoutSessionIdentifier??"",selectedNetwork:
2F?.selected_network,detectedNetworks:h}),T||r.log("credit_card_network_context_no_session_id_returned","No session id returned when vaulting card with selected network",{selectedNetwork:F?.selected_network}),T},[l,v,n,h,r,o]),x=S(async R=>{const F=l.selectedNetwork.value,T=F?{selected_network:$t(F)}:void 0,P=await v.vaultCardMultipleTimes(R,T);return Kt(o,{checkoutSessionIdentifier:n.checkoutSessionIdentifier??"",selectedNetwork:T?.selected_network,detectedNetworks:h}),P},[l,v,o,n,h]),V=J(()=>({activePaymentBrand:l.activeBrand.value,binLength:l.bankIdNumberLength.value,paymentMethod:e,detectedNetworks:M,selectableBrands:D,selectedNetwork:l.selectedNetwork.value,selectedSavedCreditCardBrand:l.selectedSavedCreditCardBrand.value,setSelectedNetwork:l.setSelectedNetwork,setSelectedSavedCreditCardBrand:E,vaultCardWithSelectedNetwork:_,vaultCardMultipleTimesWithSelectedNetwork:x}),[l.activeBrand.value,l.bankIdNumberLength.value,l.setSelectedNetwork,l.selectedNetwork.value,l.selectedSavedCreditCardBrand.value,e,M,D,E,_,x]);return m(ws.Provider,{value:V,children:t})}function Ui(){return Xa(ws)}function Kt(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 Gr=["CardFieldsFetchFailureError"];function Yr({children:t,publishesCardNetworkDetection:e,directPaymentMethodConfig:s,...a}){const n=ce(da()),{value:r}=Y().paymentMethods,o=s??we(r??[]),{observability:d}=L(),i=S(l=>{if(Gr.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(Fr,{...a,onError:i,sdkScriptAttributes:n.current,children:m(Kr,{paymentMethod:o,publishesCardNetworkDetection:e,children:t})})}function qr({enabled:t,selectedCardId:e}){const{checkout:{identity:s}}=L(),{paymentLines:a}=ee(),{negotiate:n}=Ke(),r=pn(),o=ce(void 0);U(()=>{if(s.current.value!=="shopPay")return;if(!t||!e){o.current=void 0,a.value=Za(a.value);return}if(o.current===e)return;o.current=e;const i=rs(a.value,"SHOP_PAY")?.method.walletContent?.creditCardInstallments;a.value=Ja(a.value,r({msiEligibleCard:!0,creditCardInstallments:i})),n({include:[]}).catch(()=>{o.current=void 0})},[t,s.current.value,e])}function Vi(t){const{shopPay:e}=L(),{value:s}=Y().paymentMethods,{paymentLines:a}=ee(),{bankIdNumberSignal:n,installmentMonthsSignal:r}=Ge(),{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;qr({enabled:p&&!e.session.isLoading.value,selectedCardId:h});const v=ce(u);U(()=>{v.current&&!u&&(a.value=d(a.value),r.value=void 0),v.current=u},[u,d,a,r]);const g=ce(p);U(()=>{g.current&&!p&&(a.value=d(a.value),r.value=void 0),g.current=p},[p,d,a,r]);const M=i.value,b=t.selectedCreditCard.value?.id;U(()=>{if(o!=="client")return;const D=n.peek();n.value=b===W&&Cn(D,M)?D:M},[o,n,M,b]);const f=we(s??[]),A=f&&u?Gt({paymentMethod:f,binResolution:o,id:"msiInstallmentsSelect-expanded"}):void 0,k=f&&p?zr(Gt({paymentMethod:f,binResolution:o,id:"msiInstallmentsSelect-summary"})):void 0;return{expandedSlot:A,collapsedSlot:k}}function Gt({paymentMethod:t,binResolution:e,id:s}){return e==="server"?m(Ft,{paymentMethod:t,isSelected:!0,isVaultedContext:!0,id:s}):m(Ft,{paymentMethod:t,isSelected:!0,canEditBin:!1,id:s})}function zr(t){return m(Ee,{paddingInlineStart:"large-100",children:m(Yr,{onSetFieldErrors:()=>{},children:t})})}function Is({addressType:t="shipping"}={}){const{checkout:e}=L();return S(a=>e.identity.current.value==="shopPay"&&!a?.trim()&&(t==="billing"?!e.isShippingRequired.value:!0),[e,t])}function Oi({addressType:t="shipping"}={}){const{checkout:{validation:e},i18n:s,shopPay:a}=L(),n=Is({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 $i({addressType:t="shipping"}={}){const e=ee(),s=Is({addressType:t}),a=t==="billing"?e.billingAddress.value:e.shippingAddress.value;return{isMissingFirstName:s(a.firstName)}}const Hr=jt("OverlayMoreOptionsButton");function Ki({accessibilityLabel:t,options:e,positionArea:s}){const a=la({base:!0,medium:!1}),{closeOverlay:n}=ca(),r=Ht(void 0,Hr);return e.length===0?null:m(es,{accessibilityLabel:t,overlay:m(vn,{connector:a?"none":"arrow",id:r,padding:"none",positionArea:s,children:m(Z,{gap:"small-200",padding:"small-100 base",alignItems:"center",children:e.map(({label:o,accessibilityLabel:d,destructive:i,href:l,onClick:c})=>{const u=`${o}-${d}`;return m(ua,{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($e,{type:"menu-vertical",size:"small"})})}function Gi(t){const{checkout:{addressManager:e},observability:s}=L(),a=e[t].value,n=Wr(t);return J(()=>{function r(d,i){return async(...l)=>{const c=await d(...l);return c&&n(i)?.(),c}}return{selectAddress:r(t==="shipping"?(d,i)=>(s.log("shipping_address_select_invoked","[useAddressMutationsWithNegotiation] selectAddress invoked for a shipping address",{address_id:d,source:i?.source??"unknown"}),a.selectAddress(d)):d=>a.selectAddress(d),"select"),createAddress:r(a.createAddress,"create"),updateAddress:r(a.updateAddress,"update"),deleteAddress:r(a.deleteAddress,"delete")}},[a,n,s,t])}function Wr(t){const e=ma(),{checkout:{identity:s,wallets:a}}=L(),n=lt(ps),{negotiate:r}=Ke(),o=s.current;return S(d=>{const i=o.value;if((i==="customerAccount"||i==="guest")&&t==="shipping")return e?()=>e.dispatch("addressReplaced"):()=>{a.activeSession.value||r({include:[],fieldsToResolve:["deliveryNext"],silenceViolations:["non-delivery-address"],runListenersOnError:!0})};if(i==="shopPay")return async()=>{const l=t==="shipping"?["shippingAddress"]:["billingAddress"];await r({include:l,silenceViolations:["non-stock"],fieldsToResolve:l}),n&&["create","update"].includes(d)&&(n.cashbackState.stale.value=!0)};if(t==="billing"&&i==="businessCustomer")return()=>{r({fieldsToResolve:["billingAddress"]})}},[o,t,e,n,r,a])}export{Cr as $,gi as A,Ai as B,st as C,Yr as D,Ui as E,jn as F,Ii as G,Or as H,ks as I,Ri as J,Fi as K,Vn as L,Ki as M,yi as N,Ft as O,gr as P,Un as Q,tr as R,Ni as S,mi as T,sr as U,Di as V,ar as W,Bi as X,fi as Y,pi as Z,hi as _,Tr as a,fr as a0,ie as a1,Er as a2,kr as a3,Ae as a4,Ze as a5,Mn as a6,Fn as a7,Li as b,ki as c,Vi as d,ui as e,Ti as f,Rr as g,vr as h,yr as i,wi as j,Oi as k,$i as l,Gi as m,Ci as n,Vr as o,As as p,xi as q,G as r,Si as s,Pi as t,Ei as u,_i as v,Mi as w,vi as x,Dn as y,bi 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.