PageSourceSearch

https://www.colormatrix3d.tw/cdn/shopifycloud/checkout-web/assets/…AddressMutationsWithNegotiation.qYbyFTyH.js

js colormatrix3d.tw collected 2026-09-27 01:34:26 UTC 84,449 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["PostPurchaseShouldRender.CiLW0m_5.js","esnext-vendor.B9Da21W6.js","addresses-is-address-empty.Bn2lNY_L.js","app.DbSrjjlA.js","assets/app.Sxsz5knT.css","assets/is-address-empty.DJksNKpk.css","extensions-rpc.BMPl-VrM.js","amazon-pay-useAmazonPayPaymentLine.Ju006AId.js","performance-index.mu6MOGR9.js","hooks-useReplaceShopPayInHistory.DPpLejwu.js","components-RedirectionNotice.module.CsVdFi0g.js","hydrate.DZ4YTm7p.js","graphql-PaymentSessionMutation.CAXCwUvV.js","hooks-useShopPayExternalAppContext.DWwMuRnz.js","assets/previous.owLoDmpy.css","assets/RedirectionNotice.B8v_QGNW.css","stopwatch.CfKlh48v.js","assets/stopwatch.BxwwfmsJ.css","component-Tips.CgwaBBTJ.js","Choice.DSKmQsTS.js","Checkbox.DQyvbr9E.js","assets/Checkbox.SrYMuQu4.css","assets/Choice.aPApdPe_.css","NumberField.C_TDDWmw.js","assets/NumberField.CRpcZnVJ.css","Section.BlBY023l.js","assets/Section.CU18S7Ap.css","assets/Tips.D3S9_XMm.css","component-MsiInstallmentsSelect.5CD0V5u_.js","PaymentIcon.CIva5Q4J.js","assets/PaymentIcon.gzvCNwz_.css","PaymentLine.ClzCacf5.js","localization-index.1YNaS8kx.js","assets/index.CFj15lwv.css","Theme-ThemeOverride.DZIcf8ya.js","assets/PaymentLine.D3bcP-mr.css","IncentiveBadge.DborNHa8.js","assets/IncentiveBadge.Dlnp55te.css","hooks-useUpdateCheckoutAddress.DUYbpduS.js","helpers-derivations.Dug6X2_v.js","redemption-promotions.DicFJEgz.js","shared-buyer-consent.B_gDyRCR.js","payment-usePaymentExemptionReason.B4VABxaE.js","shop-pay-normalizeBuyerDetails.CCnGCeBZ.js","hooks-useShopPayProgressIntercepts.C0rljcs-.js","cvv-cvvBridge.B-VIACTq.js","assets/useShopPayProgressIntercepts.CIy8uDiZ.css","proposal-delegated-payment-instrument.Gc2rhfd3.js","Popover.BScgzCsS.js","assets/Popover.Bi1nHaU-.css"])))=>i.map(i=>d[i]);
2import{_ as at,S as Ot}from"./app.DbSrjjlA.js";import{d as nt,u as m,f as B,S as $t,i as Fe,h as O,a as rt,k as X,q as S,y as D,o as k,ag as As,n as ks,T as J,x as it,A as oe,p as Kt,e as Es,G as ws,r as Is,_ as Ns,X as Ls,ae as Ds}from"./esnext-vendor.B9Da21W6.js";import{m as Xe,b as me,ah as Ye,B as Ee,Y as ot,$ as xs,z as Gt,bP as Yt,L as qt,fo as Ts,F as zt,fj as Rs,I as Ue,k as Z,P as Bs,gK as Fs,a5 as ft,gL as dt,ch as Us,gM as Ct,w as Vs,f as Ve,R as Os,fA as $s,U as Ks,gN as Gs,gO as Ys,W as Ht,A as Wt,gP as qs,G as qe,bo as Qt,l as ne,ax as jt,dN as zs,b5 as Hs,az as Ws,a as Xt,S as Qs,bM as js,fL as Xs,bj as Zs,bk as Js,bl as ea,gQ as ta,gR as lt,gS as vt,gT as sa,gU as bt,gV as gt,gW as Pt,gX as aa,_ as na,g1 as ra,j as ia,fD as oa}from"./hydrate.DZ4YTm7p.js";import{S as N,a4 as Y,T as ee,ae as Zt,dC as da,dO as la,gn as ce,gj as ca,m as z,hU as ua,hV as ze,Z as ma,$ as ha,X as pa,hW as ya,hX as fa,bU as ue,dB as Ca,hY as va,bH as ba,aB as Jt,gf as es,ge as ga,au as ts,q as Pa,hZ as _a,o as he,g8 as Sa,t as we,ch as ss,an as Oe,aX as ye,h0 as ct,h_ as as,ac as ut,H as Re,dN as Ma,bA as Aa,h$ as ka,U as H,i0 as Ne,i1 as Ea,V as pe,i2 as wa,i3 as _t,i4 as Ia,i5 as Na,bP as La,ag as ns,bB as Da,bv as $e,i6 as xa,i7 as Ta,a$ as Ra,i8 as mt,i9 as Ba,ia as rs,bR as is,w as Fa,ib as Ua,ic as Va,id as Oa,ie as $a,ig as Ka,e2 as Ga,e3 as os,bw as Ya,P as qa,Q as za,ih as Ha,v as Wa}from"./addresses-is-address-empty.Bn2lNY_L.js";import{u as Qa}from"./amazon-pay-useAmazonPayPaymentLine.Ju006AId.js";import{P as ds}from"./PaymentIcon.CIva5Q4J.js";import{a as ja}from"./PaymentLine.ClzCacf5.js";import{b as St,E as Xa}from"./IncentiveBadge.DborNHa8.js";import{a as Za,c as Ja,b as en,u as tn}from"./hooks-useUpdateCheckoutAddress.DUYbpduS.js";import{c as ls,u as sn}from"./payment-usePaymentExemptionReason.B4VABxaE.js";import{s as an,n as nn}from"./shop-pay-normalizeBuyerDetails.CCnGCeBZ.js";import{u as rn,i as on,S as dn,c as ln}from"./hooks-useShopPayProgressIntercepts.C0rljcs-.js";import{s as cn}from"./proposal-delegated-payment-instrument.Gc2rhfd3.js";import{a as cs,C as Ze}from"./Choice.DSKmQsTS.js";import{A as un}from"./shared-buyer-consent.B_gDyRCR.js";import{s as mn}from"./redemption-promotions.DicFJEgz.js";import{P as hn}from"./Popover.BScgzCsS.js";const di=nt({displayName:"PostPurchaseShouldRender",suspense:!1,load:()=>at(()=>import("./PostPurchaseShouldRender.CiLW0m_5.js").then(t=>t.P),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])
2)});function pn({renderInSection:t,hideHeading:e,headingLevel:s=2}){const{i18n:a,shop:{name:n,showTipPayments:r}}=N(),{tipLines:o}=Y(),{tipLines:d}=ee(),i=B(()=>{const u=o.value?.[0]??d.value[0];return r||!!(u&&u.amount.amount>0)}),l=a.translate("tips.description",{shop_name:n}),c=m(Ee,{paddingBlockEnd:"base",children:[!e&&m($t,{children:[m(Xe,{level:s,children:a.translate("tips.title")}),m(me,{blockSize:"base"})]}),m(Ye,{contentDisplay:"block",inlineSize:"100%",children:l}),m(Fe,{when:i,children:[m(me,{blockSize:"small-200"}),m(Ye,{contentDisplay:"block",inlineSize:"100%",children:a.translate("tips.custom_label")}),m(me,{blockSize:"small-100"}),m(Ye,{contentDisplay:"block",inlineSize:"33%",children:a.translate("tips.add_tip")})]})]});return t?m(ot,{accessibilityLabel:a.translate("tips.title"),children:c}):c}function yn(t){const{observability:e}=N();O(()=>{t&&e.error(t,{metadata:{tips:{component:"Tips",failure:"lazy_load"}}})},[t,e])}const li=nt({displayName:"Tips",renderLoading:t=>m(pn,{...t}),useError:yn,load:()=>at(()=>import("./component-Tips.CgwaBBTJ.js"),__vite__mapDeps([18,1,11,2,3,4,5,12,13,9,14,19,20,21,22,23,24,25,26,27]))}),fn=zt("AmazonPayChangePaymentLinkButton");function ci(){const{i18n:t,observability:e}=N(),{inMemoryAmazonPayParts:{sdkStatus:s}}=Zt(),a=B(()=>{const i=s.value;return i.status===xs.Available?i.sdk:void 0}),n=Qa(),r=Gt(void 0,fn),{hasError:o}=Yt(da),d=t.translate("vaulted.change_button");return n.value?m(Fe,{when:a,children:i=>m(qt,{onClick:()=>{try{const{checkout_session_id:c}=Ts(n.value.method.walletParams);i.Pay.changePaymentMethod({amazonCheckoutSessionId:c,isDeclined:o})}catch(c){e.error(new Cn(`Error on changing buyer payment method. Details: ${c}`,{cause:c}))}},id:r,children:d})}):null}class Cn extends Error{constructor(){super(...arguments),this.name="AmazonPayChangePaymentLinkError"}}const vn=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 ui({brand:t,descriptor:e}){const{hasError:s}=Rs(),a=t?.toLowerCase().replace(/\s+/g,"_")??"",n=vn.get(a)??"generic";return m(Z,{direction:"inline",children:[s&&m($t,{children:[m(Ue,{tone:"critical",type:"alert-circle"}),m(me,{display:"inline",inlineSize:"small-400"})]}),m(ja,{icon:m(ds,{type:n}),details:e})]})}function bn(){const{i18n:t}=N(),e=ee().purchaseOrderNumber.value;if(!e)return null;const s=`${t.translate("payment.purchase_order_number.title")} #${e}`;return m(Bs,{children:s})}const gn=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"})]}),Pn="agRve",_n="FiV0Z",Mt={NoPaymentRequiredWrapper:Pn,FreeTagIcon:_n};function mi({minimal:t,reason:e,vaulted:s}){const{i18n:a}=N(),r=Fs().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(Z,{gap:"base",children:[m(ft,{children:o(e)}),m(bn,{})]}):t?m(Xa,{children:m(St,{children:o(e)})}):m("div",{className:Mt.NoPaymentRequiredWrapper,children:m(Z,{gap:"large-200",alignItems:"center",children:[m(gn,{className:Mt.FreeTagIcon,focusable:"false","aria-hidden":"true"}),m(St,{children:m(ft,{children:o(e)})})]})})}class Sn extends Ot{constructor(){super(...arguments),this.name="AmazonPayMissingPaymentPreferencesError"}}function hi(){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 Sn("Amazon Pay wallet params missing payment preferences",{groupingHash:"AmazonPay::usePaymentDetails::AmazonPayMissingPaymentPreferencesError"});return o.paymentDescriptor.replace("****","•••• ").replace(/(\((.*?)\))/,"").trim()})();return{brand:(()=>
2{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 At={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}}"},Te=Object.freeze({name:null,number:null,verification_value:null,expiry:null,issue_date:null,issue_number:null});var us=(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))(us||{});const kt={baseMessage:null,fieldErrors:Te,blockedByDuplicateAutopayCard:!1};function pi(){const{i18n:t,observability:e}=N(),[s,a]=X(kt),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:Te,blockedByDupl
2icateAutopayCard:!1});return}const c={...Te};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:la});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:Te,blockedByDuplicateAutopayCard:!0})},[e]),d=S(()=>{a(kt)},[]),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 yi(t){return t.paymentMethod==="IDEAL"||t.paymentMethod==="CUSTOM_ONSITE"&&t.paymentBrands?.some(e=>e.toLowerCase()==="ideal")===!0}function fi(t){return t.paymentMethod==="APPLE_PAY"}function Ci(t){return t.paymentMethod==="CUSTOM_ONSITE"}function vi(t){return t.paymentMethod==="SHOP_PAY"}function bi(t){return t.paymentMethod==="SHOP_PAY_INSTALLMENTS"}function gi(t){return t.paymentMethod==="PAYPAL"}function Pi(t){return t.paymentMethod==="BANK"}function Je(t){return t.paymentMethod==="DEFERRED"}function _i(t){return t.paymentMethod==="OFFSITE"||t.paymentMethod==="MANUAL_PAYMENT"||t.paymentMethod==="CUSTOM_MANUAL_PAYMENT"||t.paymentMethod==="PAYMENT_ON_DELIVERY"}function Mn(t){return G(t)||!!t.lastUsedAt}function An(t){for(const e of t)if(!G(e)||!e.paymentAttributes.expired)return e;return t[0]}function kn({selected:t,paymentMethods:e,availablePaymentMethods:s}){return!!(ce(t,s)||G(t)&&e.some(({method:a})=>a.paymentMethod===t.paymentMethod&&a.id===t.id))}function En(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=ca(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 re={markBuyerHasActed:!1,updateSelectedCardBin:!1,selectedCardFirstDigits:void 0,preserveExistingBinPrefix:!1,claimMsiBin:!1,claimedMsiBin:void 0,shouldNegotiate:!1};function ms(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 Le(t){switch(t.paymentMethod){case"CREDIT_CARD":return{id:t.id,paymentMethod:"CREDIT_CARD",paymentAttributes:ms(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=>z(s)&&s.id===t.id);case"IDEAL":return t;case"CUSTOM_ONSITE":return t;case"APPLE_PAY":return t;case"OFFSITE":return t;case"MANUAL_PAYMENT":return t;case"CUSTOM_MANUAL_PAYMENT":return t;case"PAYMENT_ON_DELIVERY":return t;case"SHOP_PAY":case"SHOP_PAY_INSTALLMENTS":case"PAYPAL":case"BANK":case"DEFERRED":return;default:rt(t)}}
2class wn extends Error{constructor(){super(...arguments),this.name="EmptySessionIdError"}}class In extends Error{constructor(){super(...arguments),this.name="BuyerDetailsRefreshError"}}const Nn="credit_card_not_found";function Ln(t){return t.errors?.some(({message:e})=>e===Nn)??!1}class Dn{constructor(e){this.newCard=D(void 0),this.canSetCreditCardNickname=D(!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=D(r),this.shopPayAvailableUserStoredPaymentMethods=k(()=>{const c=this.availablePaymentMethods.value;return c.length?Pa(s.user.paymentMethods.value,c):[]}),this.availableUserStoredPaymentMethods=k(()=>this.shopPayAvailableUserStoredPaymentMethods.value.map(Le)),this.promotedMethods=k(()=>s.session.promotedPaymentMethods.value.map(Le)),this.selectedPaymentMethod=k(()=>{const c=s.session.selectedPaymentMethod.value;return c?Le(c):void 0}),this.selectedCreditCard=k(()=>{const c=s.session.selectedPaymentMethod.value;return c&&z(c)?ms(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,C=s.user.paymentMethodHistory.value,g=c.filter(z).map(I=>({method:I,isValidForCheckout:u.includes(I),isExpired:I.paymentAttributes.expired,isDisabled:o(I.paymentAttributes)})),M=a?[]:_a({negotiatedPaymentMethods:p,userStoredPaymentMethods:c,paymentMethodHistory:C,isApplePayAvailable:n}),b=[...g.sort((I,P)=>he(I.method,P.method)),...M.sort((I,P)=>he(I.method,P.method))];let f=-1,A="";for(const[I,P]of b.entries()){const x=P.method.lastUsedAt??"";x>A&&(A=x,f=I)}f>0&&b.unshift(...b.splice(f,1));const E=s.session.selectedPaymentMethod.value,L=new Set(h.map(I=>I.id));return b.filter(({method:I})=>
2z(I)||E&&!z(E)&&I.id===E.id||L.has(I.id)?!0:Sa(I))}),this.paymentMethods=k(()=>this.shopPayPaymentMethods.value.map(({method:c,...u})=>{const p=Le(c);return{...u,method:p,canEdit:z(c),canDelete:z(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=>G(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=we(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:ua,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:re};const d=et(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 ze(d,n.user.paymentMethods.value,ce(d,this.availablePaymentMethods.value))&&this.#e(d,a),await l,{status:"handled",effects:re}}const i=ce(d,this.availablePaymentMethods.value);return ze(d,n.user.paymentMethods.value,i)&&this.#e(d,s==="buyer"?{...a,buyerInitiated:!0}:a),(ma(d)||ha(d)||pa(d)||ya(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=fa(e,s.user.paymentMethods.value);return a&&(s.session.selectPaymentMethod(a),s.session.unstable_promotePaymentMethod(a)),{status:"handled",effects:{...re,selectByBuyerKey:ue(e)}}}getSavedCardActiveSubscriptionsLookup(e){const s=this.deps.shopPay.user.paymentMethods.value.filter(z).map(o=>o.paymentAttributes).find(o=>o.id===e.id);if(!s)return;const a={id:s.id,uuid:s.uuid,first:3},n=As(At,a),{shopPayGraphql:r}=this.deps;return{key:n,read(){return r.read(n)?.creditCardActiveSubscriptions?.nodes},async load(){const{data:o}=await r.staticQuery(At,{variables:a});return o?.creditCardActiveSubscriptions?.nodes??[]}}}async selectCreditCard({id:e}){const{shopPay:s}=this.deps,a=s.user.paymentMethods.value.filter(z).map(o=>o.paymentAttributes).find(o=>o.id===e);if(!a)return;const{updateCheckoutAddress:n,fallbackPhoneNumber:r}=this.deps;s.session.selectPaymentMethod({id:a.id,lastUsedAt:a.lastUsedAt,paymentMethod:"CREDIT_CARD",paymentAttributes:a}),this.clearShopPayPaymentLines(),await n({billingAddress:a.billingAddress.address,fallbackPhoneNumber:r})}async deleteCreditCard({id:e}){return this.deleteCreditCardById({id:e})}async updateCreditCard({id:e,billingAddress:s,nickname:a}){const{shopPay:n,updateCreditCard:r,checkoutContext:o,markShopCashStatesStale:d,observability:i}=this.deps,l=n.user.paymentMethods.value.filter(z).map(u=>u.paymentAttributes).find(u=>u.id===e);if(!l)return{status:"failed"};const c=await r(s,e,l.uuid,o,a);if(c.status==="success"&&c.creditCard){const{creditCard:u}=c;n.user.updateCreditCard(e,u),this.selectCreditCard({id:u.id}).catch(p=>{i.error(p)})}if(d(),c.status!=="success"){const u=Ca();return cn({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,C])=>[h,C.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 wn("ShopPayPaymentMethodManager: addCreditCard called with empty sessionId")),{status:"failed"};const c=await o(s,e,d,a),u=await this.handleNewCardResponse(c,n,r);return i(),u}async completeCreditCardVerificationAndVault({verificationId:e,billingAddress:s,nickname:a,debitOnly:n=!1,isBlocking:r=!1}){const{completeCreditCardVerification:o,markShopCashStatesStale:d}=this.deps,i=await o(s,e,a),l=await this.handleNewCardResponse(i,n,r);return d(),l}dispose(){}async deleteCreditCardById({id:e,uuid:s}){const{shopPay:a,deleteCreditCard:n,updateCheckoutAddress:r,emptyAddress:o,fallbackPhoneNumber:d,checkoutContext:i,markShopCashStatesStale:l}=this.deps,c=s??a.user.paymentMethods.value.filter(z).map(b=>b.paymentAttributes).find(b=>b.id===e)?.uuid;if(!c)return{status:"failed"};const u=a.session.selectedPaymentMethod.value,p=u&&z(u)?u.paymentAttributes.uuid:void 0,h=await n(e,c,i);if(h.status!=="success"&&!Ln(h))return{status:"failed"};const C=a.user.paymentMethods.value.filter(z).map(b=>b.paymentAttributes).filter(b=>b.uuid!==c);if(a.user.removeCreditCard(e),l(),p!==c)return{status:"success"};const g=va(C);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:E,isExpired:L})=>A&&!E&&!L&&Mn(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 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}=En(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:ba()}}),a.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...Jt(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:["",us.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 In("Failed to refresh Shop Pay buyer details")),!1}}async selectCreditCardAndSetPaymentLine({id:e}){const s=es(this.deps.proposedPaymentLines.value)!==void 0,a=this.selectCreditCard({id:e});if(s)return a;const{shopPay:n}=this.deps,r=n.session.selectedPaymentMethod.value;r&&z(r)&&r.paymentAttributes.id===e&&ze(r,n.user.paymentMethods.value,ce(r,this.availablePaymentMethods.value))&&this.#e(r),await a}#e(e,s){const{shopPay:a,setPaymentLine:n,observability:r}=this.deps;ks(()=>{a.session.selectPaymentMethod(e);const o=ga({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=>!ts([s],"SHOP_PAY"))}}function xn(){const t=Tn(),{newCardSignal:e,hasLoadedSignal:s}=Oe(),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 Tn(){const t=N().checkout.configuration.layout.isOnePage.value,{paymentMethods:e}=Y();return B(()=>t?!!ss(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},source:s}=N(),a=ye({source:s});return S(async(n,r,o,d,i=a)=>{const{data:l,error:c}=await e.mutate(Rn,{variables:{billingAddress:ct(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 as(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?ut(u.creditCard):void 0}},[a,t,e])}const Fn={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 Un(){const{checkout:{address:{extendedAddressMode:t}},graphql:{shopPayGraphql:e},source:s}=N(),a=ye({source:s});return S(async(n,r,o,d=a)=>{const{data:i,error:l}=await e.mutate(Fn,{variables:{verificationId:r,billingAddress:ct(n,t),origin:d,nickname:o}});if(l||i==null||i.creditCardCompleteVerificationAndVault==null)return{status:"failed"};const{creditCardCompleteVerificationAndVault:c}=i;return as(c.userErrors)?{status:"blocked_by_autopay"}:c.userErrors.length>0?{status:"failed",errors:c.userErrors}:{status:"success",creditCard:c.creditCard?ut(c.creditCard):void 0}},[a,t,e])}const Vn={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 On(){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(Vn,{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 $n(t,{checkoutVersion:e,checkoutIdentifier:s,shopifyDomain:a,shopId:n,redirectSource:r},{cache:o=!0}={}){return t.staticQuery(an,{variables:{checkoutContextInput:{checkoutVersion:e,checkoutIdentifier:s,shopifyDomain:a,shopId:n},shopifyDomain:a,redirectSource:r??void 0},cache:o})}function Kn(){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 $n(t,{checkoutVersion:o,checkoutIdentifier:r??"unknown",shopifyDomain:s,shopId:Re(a),redirectSource:d},{cache:!1});return l||i==null||i.checkoutSession==null||i.checkoutSession.user==null?{status:"failed"}:nn(i)},[r,o,d,a,s,t])}const Gn={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 Yn(){const{checkout:{address:{extendedAddressMode:t}},graphql:{shopPayGraphql:e},source:s}=N(),a=ye({source:s});return S(async(n,r,o,d,i,l=a)=>{const{data:c,error:u}=await e.mutate(Gn,{variables:{id:r,uuid:o,billingAddress:ct(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?ut(p.creditCard):void 0}},[a,t,e])}function qn(t){const{geolocation:e}=Us(),{shopPay:s,checkout:a}=N(),n=s.user.phoneNumber.value,r=s.user.addresses.value,o=a.configuration.addressSettings.nonBillingAddressSettings.value,d=r[0]?.address,i=o.defaultShippingDetails.country?.code??e.country.code;return J(()=>{const l={firstName:d?.firstName,lastName:d?.lastName,phone:n,countryCode:d?.countryCode||i,zoneCode:d?.zoneCode};return Ma(l,{extendedAddressMode:a.address.extendedAddressMode})},[a.address.extendedAddressMode,t,d,i,n])}const zn={id:"563e8a86083a6c9ad5bd44d3a4db471e3a9919052512d2745d267074d97420fd",type:"mutation",name:"DeleteVaultedCreditCard",source:""},Hn={id:"d1f468f7d6684d3133e47cef5cf1ef67ccd2bd916b53203708d85ac3175f1bd0",type:"mutation",name:"UpdateCustomerCreditCard",source:""};class Wn extends Error{constructor(e){super("Failed to update customer credit card payment method",e),this.name="UpdateCustomerCreditCardPaymentMethodError"}}class Qn extends Error{constructor(e){super("Failed to delete customer credit card payment method",e),this.name="DeleteCustomerCreditCardPaymentMethodError"}}async function jn({graphql:t,address:e,extendedAddressMode:s,defaultPaymentMethod:a,token:n,genericError:r}){if(!n)return{token:void 0};try{const{data:o,error:d}=await t.mutate(Hn,{variables:{customerCreditCardModificationInput:{token:n,defaultPaymentMethod:a,billingAddress:{streetAddress:Aa(e,{extendedAddressMode:s})}}}});if(!o?.modifyCustomerCreditCardPaymentMethod||d)throw new Wn({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 Xn({graphql:t,token:e,genericError:s}){if(!e)return{token:void 0};try{const{data:a,error:n}=await t.mutate(zn,{variables:{token:e}});if(!a?.deleteCustomerCreditCardPaymentMethod||n)throw new Qn({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 Zn({userEvents:t,shopId:e,checkoutSessionIdentifier:s,card:a}){t.monorailEvent({schemaId:"checkout_vaulted_payment_method_selected/1.0",payload:{shopId:parseInt(Re(e),10),checkoutSessionIdentifier:s||"",paymentMethodId:parseInt(Re(a.id),10),paymentInstrumentAccessorId:-1}})}class Jn extends Ot{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 hs({observability:t,managerName:e,methodName:s,identity:a,deployStage:n,isLocalDevelopment:r}
2){if(r||n!=="production"&&n!=="canary")return;const o=new Jn({managerName:e,methodName:s,identity:a,deployStage:n,isLocalDevelopment:r});t.error(o,{severity:"warning"})}const Et={status:"failed"};class De{constructor(e){this.disabledCardMethodsForInstallments=D([]),this.isEveryCardDisabled=D(!1),this.canSetCreditCardNickname=D(!1),this.addCreditCardStrategy="direct-session-payment-line",this.deps=e,this.usesCustomerAccountSelectionRule=e.identity==="customerAccount",this.newCard=e.newCard??D(void 0);const{proposal:s}=e,{proposed:a,negotiated:n}=s,{paymentMethods:r}=n.fields,o=n.fields.paymentMethodHistory??D([]);this.availablePaymentMethods=k(()=>r.value??[]),this.promotedMethods=e.paymentMethodPromotions.promoted,this.customerCreditCards=k(()=>Ea(this.availablePaymentMethods.value)),this.selectableCustomerCreditCards=k(()=>ss(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(()=>wa({paymentMethodHistory:o.value??[],availablePaymentMethods:e.displayablePaymentMethods?.value??this.availablePaymentMethods.value})),this.availableUserStoredPaymentMethods=k(()=>[...Be([He({card:this.newCard.value,billingAddress:a.billingAddress.value})]),...this.selectableCustomerCreditCards.value.map(i=>_t(i,{cvvVerificationEnabled:this.deps.storeVaultGuestCvvVerificationEnabled})),...this.selectablePaypalBillingAgreements.value.map(Ia),...nr(this.selectableCustomerBanks.value.map(Na),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=rr(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)&&!Je(h));return p||this.availableUserStoredPaymentMethods.value.find(Je)}),this.proposedSelectedPaymentMethod=k(()=>er(a.paymentLines.value,this.availableUserStoredPaymentMethods.value,this.availablePaymentMethods.value,He({card:this.newCard.value,billingAddress:a.billingAddress.value}))),this.selectedPaymentMethod=k(()=>this.proposedSelectedPaymentMethod.value??this.autoselectTarget.value),this.paymentMethods=k(()=>{const i=He({card:this.newCard.value,billingAddress:a.billingAddress.value}),l=[...Be([i]),...this.customerCreditCards.value.map(u=>_t(u,{cvvVerificationEnabled:this.deps.storeVaultGuestCvvVerificationEnabled}))].map(u=>({method:u,isValidForCheckout:!0,isExpired:u.paymentAttributes.expired,isDisabled:!1,...or({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 ir({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 G(i)?i.paymentAttributes:void 0}),this.cardPaymentMethods=k(()=>this.paymentMethods.value.filter(i=>G(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=we(this.availablePaymentMethods.value);if(!dt(i))return!1;const l=this.selectedCreditCard.value;return l?a.paymentLines.value.some(c=>
2l.id===H?c.method.type==="direct":c.method.type===pe.CreditCard&&c.method.token===l.id):!1});this.msi={binResolution:"client",selectedCardBin:k(()=>{const i=this.selectedCreditCard.value;if(i)return i.id===H?this.newCard.value?.creditCardFirstDigits:this.selectableCustomerCreditCards.value.find(l=>l.token===i.id)?.firstDigits}),clearInstallments:Ct,expandedVisible:d,collapsedVisible:d}}async promoteSelectedPaymentMethod(e){const s=ka(e,null);return s?(this.deps.paymentMethodPromotions.promote(s),this.selectPaymentMethod(s,"buyer")):{status:"handled",effects:{...re,selectByBuyerKey:ue(e)}}}canShowAsGuestCheckoutMethod(){return!1}async selectPaymentMethod(e,s="programmatic"){if(!e)return{status:"not-handled"};if(!G(e)){const n=ce(e,this.availablePaymentMethods.value);if(!n)return{status:"not-handled"};const r=ue(n);return s==="buyer"?{status:"handled",effects:{...re,selectByBuyerKey:r}}:(this.deps.setPaymentLine(r),{status:"handled",effects:re})}if(s==="buyer")return this.selectCreditCardByBuyer({paymentMethod:e});if(e.id===H)return this.deps.setPaymentLine(H),{status:"handled",effects:re};const a=this.selectableCustomerCreditCards.value.find(n=>n.token===e.paymentAttributes.id);return a?(this.deps.setPaymentLine(Ne(a)),{status:"handled",effects:re}):{status:"not-handled"}}async deleteCreditCard({id:e}){if(e===H){const{proposed:o}=this.deps.proposal;if(!this.newCard.value)return{status:"failed"};this.newCard.value=void 0,o.acceptPaymentVaulting.value=!1;const d=this.selectableCustomerCreditCards.value[0];if(d)this.deps.setPaymentLine(Ne(d));else{const i=this.autoselectTarget.value,l=i?ce(i,this.availablePaymentMethods.value):void 0;l?this.deps.setPaymentLine(ue(l)):o.paymentLines.value=o.paymentLines.value.filter(c=>c.method.type!=="direct")}return{status:"success",shouldResetSuggestedBillingAddress:!!d,shouldResetBillingAddressToShipping:this.deps.identity!=="businessCustomer"}}const s=this.selectedPaymentMethod.value,a=G(s)&&s.id===e,n=this.selectableCustomerCreditCards.value.find(o=>o.token!==e),r=await Xn({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(Ne(n)),{status:"success",shouldNegotiatePaymentMethods:!0}):{status:"failed",bannerError:r.error}}async updateCreditCard({id:e,billingAddress:s,defaultPaymentMethod:a=!1}){const n=await jn({graphql:this.deps.graphql,token:e,address:s,extendedAddressMode:this.deps.extendedAddressMode,defaultPaymentMethod:a,genericError:this.deps.i18n.translate("shipping.address_form.generic_error")});return n.token?{status:"success",shouldNegotiatePaymentMethods:!0}:{status:"failed",bannerError:n.error}}async addCreditCard(){return this.reportUnexpectedUse("addCreditCard"),Et}async completeCreditCardVerificationAndVault(){return this.reportUnexpectedUse("completeCreditCardVerificationAndVault"),Et}dispose(){}async selectCreditCardByBuyer({paymentMethod:e}){let s,a,n;if(e.id===H){const r=this.newCard.value;if(!r)return{status:"not-handled"};s=H,a=r,n=r.creditCardFirstDigits}else{const r=this.selectableCustomerCreditCards.value.find(o=>o.token===e.paymentAttributes.id);if(!r)return{status:"not-handled"};s=Ne(r),n=r.firstDigits,Zn({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=Ct(this.deps.proposal.proposed.paymentLines.value)),{status:"handled",effects:{...re,selectByBuyerKey:s,...a?{selectByBuyerPaymentMethod:a}:{},updateSelectedCardBin:!0,selectedCardFirstDigits:n,preserveExistingBinPrefix:e.id===H,claimMsiBin:this.deps.isMsiAvailable,claimedMsiBin:this.deps.isMsiAvailable?n:void 0,shouldNegotiate:!0}}}reportUnexpectedUse(e){hs({...this.deps,managerName:"CustomerPaymentMethodManager",methodName:e})}}function er(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(tr(r)){const d=e.filter(G).find(i=>i.id===r.method.token);if(d)return d;continue}if(sr(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=ar(r,e,s);if(o)return o}}function He({card:t,billingAddress:e}
2){if(!(!t?.brand||!t.creditCardLastFourDigits))return{id:H,paymentMethod:"CREDIT_CARD",paymentAttributes:{id:H,brand:t.brand,expired:!1,expiryMonth:0,expiryYear:0,lastDigits:t.creditCardLastFourDigits,name:t.cardholderName,billingAddress:{address:e??{}}},lastUsedAt:null}}function Be(t){return t.filter(e=>e!==void 0)}function tr(t){return t.method.type===pe.CreditCard}function sr(t){return t.method.type===pe.PayPal}function ar(t,e,s){const a=ue(t.method);return e.find(n=>{if(G(n))return!1;const r=ce(n,s);return r?a===ue(r):!1})}function nr(...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 rr(t){return t.reduce((e,s)=>s.lastUsedAt?e?.lastUsedAt?s.lastUsedAt>e.lastUsedAt?s:e:s:e,void 0)}function ir({cardItems:t,nonCardItems:e,autoselectTarget:s}){const a=t.find(({method:h})=>h.id===H),r=[...t.filter(({method:h})=>h.id!==H)].sort((h,C)=>he(h.method,C.method)),o=[...e].sort((h,C)=>he(h.method,C.method)),d=r.filter(wt),i=o.filter(wt),l=d.find(({method:h})=>G(h)&&h.paymentAttributes.defaultPaymentMethod),c=[d[0],i[0]].filter(h=>h!==void 0).sort((h,C)=>he(h.method,C.method))[0],p=(s?[...d,...i].find(({method:h})=>h.id===s.id&&h.paymentMethod===s.paymentMethod):void 0)??l??c;return p?[...Be([a]),p,...r.filter(h=>h!==p),...o.filter(h=>h!==p)]:[...Be([a]),...r,...o]}function wt(t){return t.isValidForCheckout&&!t.isExpired&&!t.isDisabled}function or({identity:t,storeVaultEnabled:e,card:s}){if(s.id===H)return dr;if(t==="businessCustomer")return We;const{paymentAttributes:a}=s;return e?a.expired?a.deletable?{canEdit:!1,canDelete:!0,canSetDefault:!1,isDefault:!!a.defaultPaymentMethod}:We:{canEdit:!0,canDelete:!!a.deletable,canSetDefault:!0,isDefault:!!a.defaultPaymentMethod}:We}const We={canEdit:!1,canDelete:!1,canSetDefault:!1,isDefault:!1},dr={canEdit:!1,canDelete:!0,canSetDefault:!1,isDefault:!1},xe={status:"failed"};class lr{constructor(e){this.availablePaymentMethods=D([]),this.availableUserStoredPaymentMethods=D([]),this.paymentMethods=D([]),this.selectedPaymentMethod=D(void 0),this.selectedPaymentMethodItem=D(void 0),this.selectedCreditCard=D(void 0),this.activeOrExpiredCardMethods=D([]),this.disabledCardMethodsForInstallments=D([]),this.isEveryCardDisabled=D(!1),this.isEveryCardExpired=D(!1),this.cardPaymentMethods=D([]),this.promotedMethods=D([]),this.msi={binResolution:"client",selectedCardBin:D(void 0),clearInstallments:s=>s,expandedVisible:D(!1),collapsedVisible:D(!1)},this.newCard=D(void 0),this.canSetCreditCardNickname=D(!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"),xe}async updateCreditCard(){return this.reportUnexpectedUse("updateCreditCard"),xe}async addCreditCard(){return this.reportUnexpectedUse("addCreditCard"),xe}async completeCreditCardVerificationAndVault(){return this.reportUnexpectedUse("completeCreditCardVerificationAndVault"),xe}dispose(){}reportUnexpectedUse(e){hs({...this.unexpectedUseOptions,managerName:"FallbackPaymentMethodManager",methodName:e})}}function Si({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(),C=Un(),g=On(),M=Kn(),b=Yn(),f=ye({source:e}),A=qn(),E=ee(),{paymentLines:L}=E,I=xn(),{buyerHasActedSignal:P,newCardSignal:x}=Oe(),U=it(ls),F=i.user.phoneNumber.value,R=Y(),T=Za(),_=i.session.isInstallmentsSelected.value,q=Ja({isApplePayAvailable:T.value}),se=La(),{creditCardDisabled:$}=rn(),W=sn(),{updateCheckoutAddress:ae}=en(),[,Q]=tn({allowPreselect:!1}),Ie=we(R.paymentMethods.value??[]),fe=dt(Ie),Ce=ns(),{eligibilityByCardId:ve}=Da(dn),be=S(()=>{U&&(U.cashbackState.stale.value=!0)},[U]),ge=J(()=>({checkoutIdentifier:e.checkoutSessionIdentifier??"",checkoutVersion:f,shopId:Re(n.id),shopifyDomain:n.myshopifyDomain}),[e.checkoutSessionIdentifier,n.id,n.myshopifyDomain,f]),K=J(()=>{const _e=()=>new Dn({shopPay:i,negotiatedPaymentMethods:R.paymentMethods,installmentsPaymentMethodSelected:_,isApplePayAvailable:T.value,filteredNegotiatedPaymentMethods:q.value,isCreditCardDisabled:$,setPaymentLine:Q,updateCheckoutAddress:ae,shippingRequired:a.isShippingRequired,i18n:r,observability:o,userEvents:d,source:e,checkout:a,shop:n,createCreditCard:h,deleteCreditCard:g,updateCreditCard:b,completeCreditCardVerification:C,refreshBuyerDetails:M,markShopCashStatesStale:be,shopPayGraphql:c,emptyAddress:A,proposedPaymentLines:L,checkoutContext:ge,fallbackPhoneNumber:F,paymentRequiredMethod:W.value,msiEligibilityByCardId:ve,hasSellingPlan:Ce});return u==="shopPay"?_e():u==="customerAccount"||u==="businessCustomer"?new De({proposal:a.proposal,newCard:I,displayablePaymentMethods:se,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 lr({observability:o,identity:u,deployStage:s.deployStage,isLocalDevelopment:p})},[u,s.deployStage,p,i,R.paymentMethods,_,T.value,q.value,se,$,fe,Q,ae,a,o,d,e,n,r,l,c,h,g,M,b,C,be,A,L,I,ge,F,W.value,ve,Ce]);O(()=>()=>K.dispose(),[K]);const Pe=K.selectedPaymentMethod.value,y=K.paymentMethods.value,v=K.availablePaymentMethods.value,w=K.availableUserStoredPaymentMethods.value,V=L.value.some(_e=>_e.method.type==="direct");O(()=>{if(!t||u!=="shopPay"||Pe&&kn({selected:Pe,paymentMethods:y,availablePaymentMethods:v})||V)return;const _e=y.filter(({isValidForCheckout:Me})=>Me).sort((Me,Ms)=>he(Me.method,Ms.method)).map(({method:Me})=>Me),Se=An(_e);Se&&G(Se)&&Se.paymentAttributes.expired&&d.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.1",payload:{...Jt(e,a,n),action:"final_payment_method_expired_after_merchant_filter"}});const yt=Se?et(Se,i.user.paymentMethods.value):void 0;yt?i.session.selectPaymentMethod(yt):i.session.clearPaymentMethod()},[t,v,w,a,u,d,y,Pe,n,i.session,i.user.paymentMethods.value,e,V]);const j=P.value,te=!!x.value,de=K instanceof De?K.autoselectTarget.value:void 0,le=K instanceof De?K.proposedSelectedPaymentMethod.value:void 0,ht=L.value[0],Ge=ht?.method.type,pt=on(ht);return O(()=>{t&&(u!=="customerAccount"&&u!=="businessCustomer"||j||K instanceof De&&de&&(te||pt||le&&le.paymentMethod===de.paymentMethod&&le.id===de.id||(Ge&&o.log("payment_method_manager_programmatic_selection_replaced_primary_line","Programmatic payment method selection replaced the proposed primary payment line",{replacedPaymentLineMethodT
2ype:Ge,replacingPaymentMethodType:de.paymentMethod}),K.selectPaymentMethod(de,"programmatic").catch(()=>{}))))},[t,u,j,te,K,de,le,pt,Ge,o]),K}function Mi(){const{shop:t,checkout:e,observability:s}=N(),a=e.wallets.activeSession.value,n=e.latestReceipt.value,{persistedPayPalSignal:r}=Zt(),o=e.identity.current.value==="payPal",d=n?.id,i=Vs().value,l=i!==void 0,c=$e(),u=r.value,{negotiate:p}=Ve(),h=Os(),C=Yt(new Set(xa))?.hasError&&d!==u?.receiptIdForClearedToken,g=$s("PAYPAL_EXPRESS").value?.merchantId?.trim(),M=i?.method.walletContent?.merchantId?.trim(),f=t.hasFlagEnabled(Ta)&&g&&M&&M!==g,A=u?.billingAgreementStatus&&Ra({checkout:e})&&u.billingAgreementStatus==="NOTREQUESTED"&&!i?.method.walletContent?.isVaultWithPurchaseOrder,E=i?.method.walletContent?.isVaultWithPurchaseOrder===!0&&c.value?.amount===0;O(()=>{function L(){const P={...r.value,receiptIdForClearedToken:C?d:void 0,newTokenRequiredDueToError:!0,billingAgreementStatus:void 0};r.value=P}function I(){let P;C?P="SubmitForCompletion Error":f?P="Gateway Mismatch":E?P="Zero Payment Due":P="Subscription Added",s.counter({name:"paypal_token_cleared",value:1,attributes:{clearReason:P}}),s.log("paypal_token_cleared","Clearing PayPal token due to error",{clearReason:P})}l&&((C||f||A||E)&&(I(),L()),(async()=>(E||C&&!o&&!a)&&(h(),await p({silenceViolations:["non-stock"]})))())},[C,l,f,d,s,r,A,E,o,h,p,a])}function cr(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 ps(t,e){return t.filter(s=>!ys(s,e))}function ur(t,e){return t.some(s=>ys(s,e))}function mr({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 ys(t,e){return mt(t)&&t.method.redemptionContent&&"storeCreditAccountId"in t.method.redemptionContent&&t.method.redemptionContent.storeCreditAccountId===e.id}function hr(t){const e=Y().paymentLines;return B(()=>{const s=t.value;return!s||!e.value?.lines?!1:ur(e.value.lines,s)})}function pr(){const{shop:{currencyCode:t}}=N(),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 Ai(){const t=Y().paymentLines;return B(()=>t.value?.lines.filter(e=>mt(e))||[])}const yr=new Set(["Image","Banner","s-image","s-banner"]);function fr({options:t,paymentMethodExtension:e}){const s=e[0]?.extension;if(!s)return null;const a=s.appId.split("/").pop(),n=a&&!un.includes(a);return m(Ks,{options:t,customizations:e,transformComponents:n?Cr:void 0})}const Cr=Gs(yr);function vr(){const t=Y().allViolations,e=B(()=>(t.value??[]).filter(a=>!!(Ys(a)||Ba(a)))),s=B(()=>{const[a]=e.value;return a?a.localizedMessage||a.nonLocalizedMessage:null});return m(Fe,{when:s,children:a=>m(Ht,{tone:"critical",errorType:Wt.DiscountError,children:a})})}function br({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:qs(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(qe,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1fr) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",children:[m(qe,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-300",alignItems:"center",alignContent:"center",children:[m(ds,{type:"gift-card"}),m(Qt,{children:[m(ne,{accessibilityVisibility:"hidden",children:o}),m(ne,{accessibilityVisibility:"exclusive",children:d})]})]}),m(qe,{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(jt,{onClick:()=>s(),accessibilityLabel:a.translate("general.remove_item",{label:d}),children:m(Ue,{type:"x",size:"small"})})]})]})})}const It="gift_card_option";function ki({afterAppliedRedeemablesChange:t,autoSelect:e=!1,showHeading:s=!0}){const{i18n:a}=N(),{paymentMethod:n,paymentLines:r,submit:o,remove:d,removeAll:i}=zs(),l=Hs("Checkout::GiftCard::Render",n?.uiExtension?[n?.uiExtension]:[]),{value:c}=$e(),u=c?.amount||0,[p,h]=X([]),[C,g]=X(!1),M=u===0&&r?.length===0,b=async P=>{h(P),P.length===0&&r.length>0&&(await i())?.status==="success"&&t?.()};O(()=>{M?h([]):(r?.length>0||e)&&h([It])},[e,r?.length,M]);const f=S(async(P,x)=>{const U=await o(P,x);
2return U?.status==="success"&&(g(!1),t?.()),U},[t,o]),A=J(()=>({paymentMethodIdentifier:n?.paymentMethodIdentifier??"",submitRedeemablePaymentLine:f}),[n?.paymentMethodIdentifier,f]),E=P=>{const{cost:x,method:U}=P;if(!x||U.redemptionSource!=="CUSTOM")return null;const F=U.redemptionContent?.redemptionAttributes.reduce((R,T)=>`${R},${T.key}:${T.value}`,"");return m(br,{maskedIdentifier:U.redemptionContent?.maskedIdentifier||"",amount:{amount:x.amount,currencyCode:x.currencyCode},remove:async()=>{(await d(U))?.status==="success"&&t?.()}},F)},L=()=>{if(u===0||!l.length||!n)return null;const P=m(fr,{paymentMethodExtension:l,options:A});return!r||r.length===0?P:C?m(Ee,{children:[m(me,{blockSize:"small-500"}),m(Z,{gap:"base",children:[m(Xe,{level:3,children:a.translate("payment.gift_card_wrapper.apply_another_gift_card_label")}),P]})]}):m(Ee,{children:[m(me,{blockSize:"small-500"}),m(qt,{textDecoration:"none",onClick:()=>g(!0),children:m(Z,{direction:"inline",alignItems:"center",gap:"small-400",children:[m(Ue,{type:"plus"}),m(ne,{children:a.translate("payment.gift_card_wrapper.apply_another_gift_card_label")})]})})]})},I=!!r?.length||!!l.length&&!!n;return m(Ws,{id:"3p-gift-card-field",open:I,duration:"slow",children:m(ot,{accessibilityLabel:a.translate("payment.gift_card_wrapper.heading"),children:m(Z,{gap:"base",children:[s&&m(Xe,{level:2,children:a.translate("payment.gift_card_wrapper.heading")}),m(cs,{name:"gift_card_option_list",values:p,multiple:!0,onChange:b,variant:"block",children:m(Ze,{value:It,disabled:M,selectedContent:m(Z,{gap:"base",children:[r?.length>0?m(Z,{gap:"small-300",children:r.map(E)}):null,m(vr,{}),L()]}),children:a.translate("payment.gift_card_wrapper.apply_gift_card_label")})})]})})})}const Ae="StoreCreditRedemptionCheckbox",Qe="StoreCreditSubscriptionRenewalsCheckbox";function Ke(t,e){return mt(t)&&t.method.redemptionContent&&"storeCreditAccountId"in t.method.redemptionContent&&t.method.redemptionContent.storeCreditAccountId===e.id}function gr(t,e){if(!(t.status!=="success"&&t.status!=="error"))return t.negotiated?.paymentLines?.lines.find(s=>Ke(s,e))?.cost}function Pr({paymentLines:t,storeCreditAccount:e,cost:s}){return t.map(a=>Ke(a,e)?{...a,cost:s}:a)}function Nt({amountDueAtCheckout:t,storeCreditAccount:e}){if(fs({amountDueAtCheckout:t,storeCreditAccount:e})&&t!=null)return{amount:Math.min(t.amount,e.balance.amount),currencyCode:t.currencyCode}}function fs({amountDueAtCheckout:t,storeCreditAccount:e}){return t==null||t.currencyCode===e.balance.currencyCode}function Lt({paymentLines:t,storeCreditAccount:e,cost:s}){let a=!1;const n=t.map(r=>{if(!Ke(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 Cs(t){const{negotiate:e}=Ve();return S(async()=>new Promise(s=>{e({include:["paymentLines"],silenceViolations:["non-store-credit"],runListenersOnError:!0,force:!0,onComplete(a){t.value=a.status==="success"?ie.Success:ie.Error,s(a)}})}),[e,t])}function _r(t,e){const s=ee(),a=Cs(e);return S(async()=>{if(!t)return e.value=ie.Error,Promise.resolve();e.value=ie.Loading;const n=ps(s.paymentLines.value,t);return s.paymentLines.value=n,a()},[t,e,s.paymentLines,a])}function Sr(t,e){const{i18n:s,shop:a}=N(),n=ee(),r=Cs(e),o=Y().paymentLines,d=$e(),i=rs(),l=ns(),c=is(),u=Y().paymentFlexibilityPaymentTermsTemplate,p=Fa(a),h=Y().isImmediateAmountReducedForRedeemables,C=S(()=>p&&Ua({hasSellingPlan:l.value,hasFixedSellingPlan:c.value,paymentTermsTemplateType:u.value?.type}),[p,l,c,u]),g=oe(!1);return Kt(()=>{if(!C())return;const M=d.value??i.value,b=n.paymentLines.value;if(!t||!g.current)return;const f=o.value?.lines.find(E=>Ke(E,t))?.cost;if(h?.value){if(f){const E=Lt({paymentLines:b,storeCreditAccount:t,cost:f});E!==b&&(n.paymentLines.value=E)}return}if(f&&f.amount>0){g.current=!1;return}const A=Lt({paymentLines:b,storeCreditAccount:t,cost:Nt({amountDueAtCheckout:M,storeCreditAccount:t})});
2A!==b&&(n.paymentLines.value=A)}),S(async()=>{if(!t)return e.value=ie.Error,Promise.resolve(null);e.value=ie.Loading;const M=ps(n.paymentLines.value,t),b=d.value??i.value,f=C(),A=f?Nt({amountDueAtCheckout:b,storeCreditAccount:t}):void 0;if(g.current=A!=null,f&&!fs({amountDueAtCheckout:b,storeCreditAccount:t}))return e.value=ie.Error,Xt({content:s.translate("store_credit_errors.generic_error")}),Promise.resolve(null);n.paymentLines.value=[...M,{method:{type:"redeemable",redemptionSource:"STORE_CREDIT",redemptionContent:{storeCreditAccountId:t.id}},...A&&{cost:A}}];const E=await r(),L=f&&gr(E,t);return L&&L.amount>0&&(g.current=!1,n.paymentLines.value=Pr({paymentLines:n.paymentLines.value,storeCreditAccount:t,cost:L})),E},[i,r,d,n.paymentLines,e,C,t,s])}function Mr(t){const e=rs(),s=Va();return B(()=>{if(s.value)return mr({firstOrderTotal:e.value,storeCreditAccount:t.value})})}function Ei({afterAppliedRedeemablesChange:t}){const{i18n:e,shop:s,webMcp:a}=N(),n=s.hasFlagEnabled(Oa),r=$e(),o=ee(),d=$a(),i=is(),l=pr(),c=hr(l),u=Es(ie.Init),p=cr(l),h=Mr(l),C=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")});Kt(()=>{(!p.value||!C.value||g.value)&&ws(()=>{o.useStoreCreditForSubscriptionRenewals.value&&(o.useStoreCreditForSubscriptionRenewals.value=!1)})});const b=Sr(l.value,u),f=_r(l.value,u),A=B(()=>u.value===ie.Loading),E=B(()=>A.value||g.value),L=B(()=>E.value||r.value?.amount===0&&!c.value),I=E,P=B(()=>{const $=[],W=C.value&&o.useStoreCreditForSubscriptionRenewals.value;return(c.value||W)&&$.push(Ae),W&&$.push(Qe),$}),x=S(async $=>{const W=n&&$.includes(Qe),ae=$.includes(Ae)||W;if(o.useStoreCreditForSubscriptionRenewals.value=W,ae!==c.peek()){if((ae?await b():await f())?.status!=="success"){o.useStoreCreditForSubscriptionRenewals.value=!1;return}t?.()}},[b,f,c,o.useStoreCreditForSubscriptionRenewals,n,t]),U=B(()=>p.value&&!!l.value),F=B(()=>P.value.includes(Ae)),R=S($=>x($?[...new Set([...P.peek(),Ae])]:[]),[P,x]);O(()=>a?.unstable_provideStoreCreditController({available:U,redeeming:F,applied:c,settling:A,hasGiftCard:d,hasFixedSellingPlan:i,paymentDue:r,setRedeeming:R}),[a,U,F,c,A,d,i,r,R]);const T=l.value;if(!U.value||!T)return null;const _=C.value?h.value:void 0,q=T.balance,se=M.value;return m(ot,{accessibilityLabel:e.translate("payment.store_credit.label"),children:m(cs,{name:"store_credit_redemption",values:P.value,multiple:!0,onChange:x,variant:"block",children:[m(Ze,{value:Ae,disabled:L.value,secondaryContent:m(ne,{type:"strong",children:e.formatCurrency(q.amount,{currency:q.currencyCode})}),details:se&&m(ne,{children:se}),children:m(Z,{direction:"inline",gap:"base",alignItems:"center",children:[m(ne,{children:e.translate("payment.store_credit.apply_label")}),m(Fe,{when:A,children:m(Qs,{})})]})}),_&&m(Ze,{value:Qe,disabled:I.value,details:m(Z,{gap:"small-500",children:[m(ne,{children:e.translate("payment.store_credit.remaining_for_subscription_charges_description",{amount:e.formatCurrency(_.amount,{currency:_.currencyCode})})}),se&&m(ne,{children:se})]}),children:m(ne,{children:e.translate("payment.store_credit.use_remaining_for_subscription_charges_label")})})]})})}function wi(){const{i18n:t}=N(),{hasViolations:e}=js(Ka);return e?m(Ht,{errorType:Wt.PaymentError,tone:"critical",children:t.translate("store_credit_errors.generic_error")}):null}const Ar="YVGTZ",kr="zyVks",Er="U4h7p",je={Row:Ar,Name:kr,Digits:Er};function Ii({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(Qt,{children:t})}),m("span",{className:je.Digits,children:e}),s]})}const wr=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 Ir(t){const e=wr.get(t.toLowerCase());if(e)return e;const s=t.toUpperCase();return Ga(s)?os(s):t}function Ni(t){return t?t.nickname&&t.nickname.trim().length>0?t.nickname:t.bank&&t.bank.trim().length>0?t.bank:Ir(t.brand):""}function Nr(){const{paymentLines:t}=ee();return B(()=>es(t.value))}function Lr({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 Dt({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 Xt({content:a})},[a,e]),m(ea,{id:t,name:"msiInstallments",label:s.translate("msi_installments.payment_plan_label"),value:e,disabled:e==="loading",onCh
2ange:()=>{},children:m(Js,{value:e,children:a})})}function Dr({paymentMethod:t,isSelected:e,canEditBin:s=!0,isVaultedContext:a=!1,id:n="msiInstallmentsSelect"}){const{bankIdNumberSignal:r,installmentMonthsSignal:o,lastNegotiatedBinSignal:d}=Oe(),{paymentLines:i}=ee(),l=Nr();O(()=>{o.value=l.value},[l.value,o]);const c=s&&!a,u=t.installmentPlans?.find(M=>M.type==="MSI"),p=u?.supportedInstallments??[],h=Ya(r.value),C=!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=Zs(i.value,void 0))},[l.value,e,u,h,c,p.length,i]);const g=Lr({isSelected:!!e,hasMsiPlan:!!u,isStale:C,binPrefix:h,canEditBin:c,supportedInstallmentsCount:p.length,isNegotiating:!1});return g==="hidden"?null:g==="prompt"?m(Dt,{id:n,variant:"prompt"}):m(Dt,{id:n,variant:"loading"})}const xt=nt({displayName:"MsiInstallmentsSelect",useError:Xs("MsiInstallmentsSelect"),load:()=>Is(async()=>({default:(await at(async()=>{const{MsiInstallmentsSelect:t}=await import("./component-MsiInstallmentsSelect.5CD0V5u_.js");return{MsiInstallmentsSelect:t}},__vite__mapDeps([28,1,11,2,3,4,5,12,13,9,14,7,29,30,31,32,33,34,35,36,19,20,21,22,37,38,39,40,41,42,43,44,45,46,47,48,49]))).MsiInstallmentsSelect})),renderLoading:t=>m(Dr,{...t})}),Tt=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=Tt.get(e.source);s instanceof Promise||(s=ta(e,!0),Tt.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<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 vt(`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 Rt(()=>{if(!this.sdk)throw new vt("The CardFields SDK has not been set up.");return e(this.sdk)},!!this.sdk,this.sdkQueue)}};ke.MAX_SETUP_ATTEMPTS=3;let tt=ke;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 vs=Ls(void 0),Bt={name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1};function xr({children:t,value:e,sdkScriptAttributes:s,blurValidationEnabled:a=!0,blurValidationFieldDenylist:n,onError:r,onSetFieldErrors:o,onLoadSuccess:d}){const i=J(()=>new tt,[]),[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=oe(),[C,g]=X(),[M,b]=X(),[f,A]=X({name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1}),[E,L]=X(""),[I,P]=X([]),[x,U]=X(Bt),F=oe(x);O(()=>{F.current=x},[x]);const R=oe(),T=S(y=>{h.current=y instanceof sa?y.diagnostics:void 0,p({sdk:y.message}),r?.(y),c(!1)},[r,p,c]),_=S(async y=>{try{return await y()}catch(v){if(v instanceof Error){let w=null;if(v.name===bt.name)w=new bt(v.message);else if(v.name===gt.name){const V="httpStatus"in v&&typeof v.httpStatus=="number"?v.httpStatus:void 0;w=new gt(v.message,V)}else v.name===Pt.hostedFieldsName&&(w=new Pt(v.message));if(w)return T(w),"";T(v)}throw v}},[T]),q=S(async(y,v={propagateErrors:!0})=>{const{sdk:w,...V}=y;await _(()=>i.setErrors(V)),p(j=>{const te={...j,...y};return v.propagateErrors&&o?.(te),te})},[i,o,_]),se=S((y,v)=>{const w={},V=R.current;v?(y||(!f?.expiry&&v.includes("expiry")&&(w.expiry=V?.expiry),!f?.number&&v.includes("number")&&(w.number=V?.number_blank),!f?.name&&v.includes("name")&&(w.name=V?.name)),(y||v.includes("verification_value"))&&!f?.verification_value&&(w.verification_value=V?.verification_value)):(y||(f?.expiry||(w.expiry=V?.expiry),f?.number||(w.number=V?.number_blank),f?.name||(w.name=V?.name)),f?.verification_value||(w.verification_value=V?.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]);O(()=>{async function y(){try{if(!s)throw new lt("Provider: hostedFieldsUrl must be provided");await i.load(s)}catch(v){v instanceof Error&&T(v)}}y()},[s,i,T]);const $=S(({cardType:y,bin:v,networks:w})=>{g(y),L(v),P(w)},[]),W=S(({targetName:y})=>{b(y)},[]),ae=S(async y=>{const{isValueValid:v,targetName:w,isValueEmpty:V}=y,j=R.current,te=F.current[w],de=!!n?.has(w);if(a&&!de&&j&&te){const le={[w]:v?null:j[w]};w==="number"&&V&&(le[w]=j.number_blank),await q(le,{propagateErrors:!1})}b(void 0)},[q,a,n]),Q=S(async y=>{const{targetName:v,isValueEmpty:w,isTab:V}=y;if(!V){A(te=>({...te,[v]:!w})),U(te=>({...te,[v]:!0}));const j={[v]:null};await q(j)}},[q]),Ie=S(y=>{A(v=>({...v,[y]:!0}))},[]),fe=Tr(),Ce=S(()=>{fe.current&&(A({name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1}),P([]))},[A,fe]),ve=S(()=>{_(()=>i.on("cardtype",$)),_(()=>i.on("focus",W)),_(()=>i.on("blur",ae)),_(()=>i.on("keyup",Q)),_(()=>i.on("change",Q)),_(()=>i.on("input",Q))},[_,i,$,W,ae,Q]),be=S(()=>{_(()=>
2i.off("cardtype",$)),_(()=>i.off("focus",W)),_(()=>i.off("blur",ae)),_(()=>i.off("keyup",Q)),_(()=>i.off("change",Q)),_(()=>i.off("input",Q))},[_,i,$,W,ae,Q]),ge=S(()=>{U(Bt)},[]),K=J(()=>({loadFonts:y=>_(()=>i.loadFonts(y)),setErrors:y=>q(y,{propagateErrors:!1}),setStyles:(...y)=>_(()=>i.setStyles(...y)),setFocus:(...y)=>_(()=>i.setFocus(...y)),setTooltip:(...y)=>_(()=>i.setTooltip(...y)),setTranslation:(...y)=>_(()=>i.setTranslation(...y)),setPlaceholderContent:(...y)=>_(()=>i.setPlaceholderContent(...y)),setValue:(y,v)=>_(()=>(typeof v=="string"&&v.trim().length>0&&A(w=>({...w,[y]:!0})),i.setValue(y,v))),setup:async(y,v,w=()=>{})=>{c(!0),await _(()=>i.setup(y,v,w)),d?.(),c(!1),R.current=v.errorMessages},teardown:()=>_(()=>i.teardown()),clearField:y=>_(()=>(A(v=>({...v,[y]:!1})),i.clearField(y))),vaultCard:(...y)=>_(()=>i.vaultCard(...y)),vaultCardMultipleTimes:(y,v)=>_(()=>i.vaultCardMultipleTimes(y,v)),getCardField:y=>i.getFieldFrame(y)}),[i,q,_,d]);O(()=>()=>{o?.({})},[o]);const Pe=J(()=>e??{sdk:K,errors:u,sdkLoadDiagnostics:h.current,cardBrand:C,bankIdNumber:E,networks:I,focusedField:M,filled:f,loading:l,validate:se,subscribe:ve,unsubscribe:be,resetTouched:ge,emptyFields:Ce,setFilled:Ie,touched:x},[K,C,E,I,u,f,M,l,e,se,ve,be,ge,Ce,Ie,x]);return m(vs.Provider,{value:Pe,children:t})}function Tr(){const t=oe(!0);return Ns(()=>()=>{t.current=!1},[]),t}const bs=()=>{const t=it(vs);if(t==null)throw new lt("No cardfields found in context");return t},st=6,gs=t=>t.toUpperCase(),Ft=t=>t.toLowerCase();function Rr(t){return!!t?.some(e=>e.type==="direct"&&e.paymentBrands.includes("BOGUS"))}function Li({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 Di(t){return t.replace(/([\d.]+)rem/g,(e,s)=>`${Number(s)*10/14}rem`)}function xi(){const{paymentMethods:t}=Y();return B(()=>{const e=t.value?.filter(s=>s.type===pe.CreditCard&&!!s.expired);return e?e.length:0})}function Ti(){const{i18n:t}=N();return{getAccessibilityLabel:s=>{const a=s.type==="direct"?s.creditCardLastFourDigits:s.displayLastDigits;return`${os(s.brand)} ${t.translate("payment.saved_credit_card_info")} ${a}`}}}function Ps(t){return t?t.map(e=>gs(e)):[]}function Fr({displayName:t,paymentBrands:e,paymentMethodIdentifier:s,selectableBrands:a,networkSelectionSupported:n}){const{bankIdNumber:r,networks:o,cardBrand:d}=bs(),{userEvents:i,source:{checkoutSessionIdentifier:l}}=N(),[c,u]=X(!1),[p,h]=X(""),C=J(()=>Ps(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:C.join(","),cardIsCobadged:C.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>=st&&C.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,C,a,r,i,l,n,p,c,u])}const _s=qa("CreditCardNetworkContext");function Ur({children:t,paymentMethod:e,publishesCardNetworkDetection:s=!1}){const{checkout:a,source:n,observability:r,userEvents:o}=N(),d=Ds(),i=e?ue(e):d,l=a.cardNetworkSelection.forMethod(i),{bankIdNumber:c,touched:u,...p}=bs(),{networks:h,sdk:C,filled:g}=p,M=J(()=>Ps(h),[h]),b=c?.replace(/\s/g,"").length??0,f=b>=st&&p.cardBrand?gs(p.cardBrand):void 0,A=J(()=>M.filter(F=>e?.paymentBrands.includes(F)),[M,e]),E=!!e?.supportsNetworkSelection;O(()=>{s&&l.setDetectedState({networkSelectionEnabled:E,availableNetworks:A,cardBrand:f,numberFilled:!!g.number,bankIdNumberLength:b})},[s,l,E,A,f,g.number,b]);const L=l.selectableBrands.value;Fr({displayName:e?.name,paymentBrands:e?.paymentBrands??[],paymentMethodIdentifier:e?.paymentMethodIdentifier??"",selectableBrands:L,networkSelectionSupported:e?.supportsNetworkSelection??!1});const I=S(F=>{const R=l.selectedSavedCreditCardBrand.value,T=typeof F=="function"?F(R):F;l.setSelectedSavedCreditCardBrand(T)},[l]),P=S(async()=>{const F=l.selectedNetwork.value,R=F?{selected_network:Ft(F)}:void 0,T=await C.vaultCard(R);return Ut(o,{checkoutSessionIdentifier:n.checkoutSessionIdentifier??"",selectedNetwork:R?.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:R?.selected_network}),T},[l,C,n,h,r,o]),x=S(async F=>{const R=l.selectedNetwork.value,T=R?{selected_network:Ft(R)}:void 0,_=await C.vaultCardMultipleTimes(F,T);return Ut(o,{checkoutSessionIdentifier:n.checkoutSessionIdentifier??"",selectedNetwork:T?.selected_network,detectedNetworks:h}),_},[l,C,o,n,h]),U=J(()=>({activePaymentBrand:l.activeBrand.value,binLength:l.bankIdNumberLength.value,paymentMethod:e,detectedNetworks:M,selectableBrands:L,selectedNetwork:l.selectedNetwork.value,selectedSavedCreditCardBrand:l.selectedSavedCreditCardBrand.value,setSelectedNetwork:l.setSelectedNetwork,setSelectedSavedCreditCardBrand:I,vaultCardWithSelectedNetwork:P,vaultCardMultipleTimesWithSelectedNetwork:x}),[l.activeBrand.value,l.bankIdNumberLength.value,l.setSelectedNetwork,l.selectedNetwork.value,l.selectedSavedCreditCardBrand.value,e,M,L,I,P,x]);return m(_s.Provider,{value:U,children:t})}function Ri(){return za(_s)}function Ut(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 Vr=["CardFieldsFetchFailureError"];function Or({children:t,publishesCardNetworkDetection:e,directPaymentMethodConfig:s,...a}){const n=oe(aa()),{value:r}=Y().paymentMethods,o=s??we(r??[]),{observability:d}=N(),i=S(l=>{if(Vr.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(xr,{...a,onError:i,sdkScriptAttributes:n.current,children:m(Ur,{paymentMethod:o,publishesCardNetworkDetection:e,children:t})})}function $r({enabled:t,selectedCardId:e}){const{checkout:{identity:s}}=N(),{paymentLines:a}=ee(),{negotiate:n}=Ve(),r=ln(),o=oe(void 0);O(()=>{if(s.current.value!=="shopPay")return;if(!t||!e){o.current=void 0,a.value=Ha(a.value);return}if(o.current===e)return;o.current=e;
2const i=ts(a.value,"SHOP_PAY")?.method.walletContent?.creditCardInstallments;a.value=Wa(a.value,r({msiEligibleCard:!0,creditCardInstallments:i})),n({include:[]}).catch(()=>{o.current=void 0})},[t,s.current.value,e])}function Bi(t){const{shopPay:e}=N(),{value:s}=Y().paymentMethods,{paymentLines:a}=ee(),{bankIdNumberSignal:n,installmentMonthsSignal:r}=Oe(),{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;$r({enabled:p&&!e.session.isLoading.value,selectedCardId:h});const C=oe(u);O(()=>{C.current&&!u&&(a.value=d(a.value),r.value=void 0),C.current=u},[u,d,a,r]);const g=oe(p);O(()=>{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;O(()=>{if(o!=="client")return;const L=n.peek();n.value=b===H&&mn(L,M)?L:M},[o,n,M,b]);const f=we(s??[]),A=f&&u?Vt({paymentMethod:f,binResolution:o,id:"msiInstallmentsSelect-expanded"}):void 0,E=f&&p?Kr(Vt({paymentMethod:f,binResolution:o,id:"msiInstallmentsSelect-summary"})):void 0;return{expandedSlot:A,collapsedSlot:E}}function Vt({paymentMethod:t,binResolution:e,id:s}){return e==="server"?m(xt,{paymentMethod:t,isSelected:!0,isVaultedContext:!0,id:s}):m(xt,{paymentMethod:t,isSelected:!0,canEditBin:!1,id:s})}function Kr(t){return m(Ee,{paddingInlineStart:"large-100",children:m(Or,{onSetFieldErrors:()=>{},children:t})})}function Ss({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 Fi({addressType:t="shipping"}={}){const{checkout:{validation:e},i18n:s,shopPay:a}=N(),n=Ss({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 Ui({addressType:t="shipping"}={}){const e=ee(),s=Ss({addressType:t}),a=t==="billing"?e.billingAddress.value:e.shippingAddress.value;return{isMissingFirstName:s(a.firstName)}}const Gr=zt("OverlayMoreOptionsButton");function Vi({accessibilityLabel:t,options:e,positionArea:s}){const a=na({base:!0,medium:!1}),{closeOverlay:n}=ra(),r=Gt(void 0,Gr);return e.length===0?null:m(jt,{accessibilityLabel:t,overlay:m(hn,{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(ia,{inlineSize:"fill",variant:"plain",onClick:()=>{c?.(),n(r)},href:l,accessibilityLabel:d,inlineAlignment:"start",textDecoration:"none",tone:i?"critical":void 0,children:o},u)})})}),children:m(Ue,{type:"menu-vertical",size:"small"})})}function Oi(t){const{checkout:{addressManager:e},observability:s}=N(),a=e[t].value,n=Yr(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 Yr(t){const e=oa(),{checkout:{identity:s,wallets:a}}=N(),n=it(ls),{negotiate:r}=Ve(),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{hr as $,Ci as A,_i as B,Je as C,Or as D,Ri as E,qn as F,ki as G,Br as H,gs as I,Di as J,Ti as K,Tn as L,Vi as M,mi as N,xt as O,fr as P,xn as Q,jn as R,wi as S,li as T,Xn as U,Ii as V,Zn as W,xi as X,hi as Y,ui as Z,ci as _,Nr as a,mr as a0,ie as a1,Sr as a2,_r as a3,Ae as a4,Qe as a5,bn as a6,Dn as a7,Ei as b,Si as c,Bi as d,di as e,Li as f,Lr as g,pr as h,cr as i,Ai as j,Fi as k,Ui as l,Oi as m,pi as n,Rr as o,bs as p,Ni as q,G as r,gi as s,vi as t,Mi as u,bi as v,Pi as w,yi as x,En as y,fi 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.