1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["7743efb2.BnGbb2ef.js","2c1ab0fe.D_oO1jU7.js","4c290a1e.D9lE9kmU.js","app.bDJ3v-8C.js","assets/app.BuSMBobh.css","assets/previous.BpuyvRSB.css","24fcbaf6.CptX_RFD.js","ac5a19ff.CrIDx928.js","9c384ce8.DwKM6HkH.js","60a453ce.BIyixFcg.js","ca5e9c49.BL-l7mUG.js","164ad2e3.DgUUtBtV.js","65f3d4da.8ZfwXSRH.js","0a7dffce.BMM606kb.js","bb728e1c.BObJOhlA.js","assets/stopwatch.Kyhz8KoT.css","d8ca7400.Bzt3t7NK.js","efa0389a.-R9eik6_.js","assets/Choice.B7lVAtpz.css","33d2e4fc.DflCtq5Y.js","assets/NumberField.CRpcZnVJ.css","dfca5da5.H1thSL3M.js","assets/Section.CU18S7Ap.css","assets/Tips.D3S9_XMm.css","82de4790.Dxwxuk9y.js","598fef4e.DSM2KxPW.js","assets/PaymentIcon.gzvCNwz_.css","e77f7fe0.B5ukwIHt.js","assets/PaymentLine.BGhbZYQP.css","a422df8c.CGT3eUwi.js","31cc568e.CsDC1k63.js","8599b02a.yKiXuwTF.js","assets/index.CIy8uDiZ.css","assets/EmptyState.BEvzDDvy.css","cc6ff67d.SUHuL0DO.js","08a3b809.CkE7TqUZ.js","e477f96c.dvrL9dgG.js","87bfafec.DaEgHDYY.js","e39bc11c.BNw-kv3c.js","bff2ff9b.DxpvVf7S.js","cf29e63b.CnWxVFH5.js"])))=>i.map(i=>d[i]); 2import{_ as e,S as t}from"./app.bDJ3v-8C.js";import{d as a,u as s,f as n,S as r,i,h as d,a as o,k as l,q as c,y as u,E as m,ag as h,n as p,T as y,x as f,A as v,o as C,e as b,G as g,r as _,_ as M,X as P,af as S}from"./2c1ab0fe.D_oO1jU7.js";import{H as k,b as A,ac as E,B as w,_ as I,as as x,C as L,bD as D,L as N,fD as B,J as T,fy as F,I as V,c as R,P as U,gW as O,a5 as $,gX as Y,ci as q,gY as j,w as G,h as z,X as K,fP as H,U as Q,gZ as W,g_ as X,W as Z,A as J,g$ as ee,y as te,bp as ae,n as se,an as ne,d0 as re,b7 as ie,aA as de,a as oe,S as le,bA as ce,eR as ue,bi as me,bj as he,bk as pe,h0 as ye,h1 as fe,h2 as ve,h3 as Ce,h4 as be,h5 as ge,h6 as _e,h7 as Me}from"./164ad2e3.DgUUtBtV.js";import{O as Pe,P as Se,Q as ke,a6 as Ae,cF as Ee,dy as we,go as Ie,gi as xe,k as Le,hE as De,hF as Ne,bL as Be,hG as Te,bs as Fe,hH as Ve,hI as Re,c1 as Ue,cE as Oe,hJ as $e,bC as Ye,ar as qe,g7 as je,X as Ge,m as ze,hK as Ke,l as He,g2 as Qe,q as We,T as Xe,aT as Ze,aR as Je,h3 as et,hL as tt,a4 as at,G as st,dx as nt,eL as rt,hM as it,U as dt,hN as ot,hO as lt,V as ct,hP as ut,hQ as mt,hR as ht,hS as pt,hT as yt,b_ as ft,a8 as vt,ce as Ct,bp as bt,hU as gt,hV as _t,aZ as Mt,hW as Pt,hX as St,hY as kt,aX as At,v as Et,hZ as wt,h_ as It,h$ as xt,i0 as Lt,i1 as Dt,ch as Nt,cj as Bt,bq as Tt,af as Ft,aM as Vt,i2 as Rt,u as Ut}from"./4c290a1e.D9lE9kmU.js";import{u as Ot}from"./ac5a19ff.CrIDx928.js";import{P as $t}from"./598fef4e.DSM2KxPW.js";import{a as Yt}from"./e77f7fe0.B5ukwIHt.js";import{b as qt,E as jt}from"./a422df8c.CGT3eUwi.js";import{a as Gt,c as zt,b as Kt,u as Ht}from"./cc6ff67d.SUHuL0DO.js";import{S as Qt,u as Wt}from"./87bfafec.DaEgHDYY.js";import{s as Xt,n as Zt}from"./e39bc11c.BNw-kv3c.js";import{a as Jt,i as ea,e as ta,d as aa}from"./31cc568e.CsDC1k63.js";import{g as sa}from"./bff2ff9b.DxpvVf7S.js";import{s as na}from"./cf29e63b.CnWxVFH5.js";import{a as ra,b as ia}from"./efa0389a.-R9eik6_.js";import{A as da,a as oa}from"./e477f96c.dvrL9dgG.js";const la=a({displayName:"PostPurchaseShouldRender",suspense:!1,load:()=>e((()=>import("./7743efb2.BnGbb2ef.js").then((e=>e.P))),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))});function ca({renderInSection:e,hideHeading:t,headingLevel:a=2}){const{i18n:d,shop:{name:o,showTipPayments:l}}=Pe(),{tipLines:c}=Se(),{tipLines:u}=ke(),m=n((()=>{const e=c.value?.[0]??u.value[0];return l||Boolean(e&&e.amount.amount>0)})),h=d.translate("tips.description",{shop_name:o}),p=s(w,{paddingBlockEnd:"base",children:[!t&&s(r,{children:[s(k,{level:a,children:d.translate("tips.title")}),s(A,{blockSize:"base"})]}),s(E,{contentDisplay:"block",inlineSize:"100%",children:h}),s(i,{when:m,children:[s(A,{blockSize:"small-200"}),s(E,{contentDisplay:"block",inlineSize:"100%",children:d.translate("tips.custom_label")}),s(A,{blockSize:"small-100"}),s(E,{contentDisplay:"block",inlineSize:"33%",children:d.translate("tips.add_tip")})]})]});return e?s(I,{accessibilityLabel:d.translate("tips.title"),children:p}):p}const ua=a({displayName:"Tips",renderLoading:e=>s(ca,{...e}),useError:function(e){const{observability:t}=Pe();d((()=>{e&&t.error(e,{metadata:{tips:{component:"Tips",failure:"lazy_load"}}})}),[e,t])},load:()=>e((()=>import("./d8ca7400.Bzt3t7NK.js")),__vite__mapDeps([16,1,11,2,3,4,5,12,9,13,14,15,17,18,19,20,21,22,23]))}),ma=T("AmazonPayChangePaymentLinkButton");function ha(){const{i18n:e,observability:t}=Pe(),{inMemoryAmazonPayParts:{sdkStatus:a}}=Ae(),r=n((()=>{const e=a.value;return e.status===x.Available?e.sdk:void 0})),d=Ot(),o=L(void 0,ma),{hasError:l}=D(Ee),c=e.translate("vaulted.change_button");return d.value?s(i,{when:r,children:e=>s(N,{onClick:()=>{try{const{checkout_session_id:t}=B(d.value.method.walletParams);e.Pay.changePaymentMethod({amazonCheckoutSessionId:t,isDeclined:l})}catch(a){t.error(new pa(`Error on changing buyer payment method. Details: ${a}`,{cause:a}))}},id:o,children:c})}):null}
2class pa extends Error{constructor(){super(...arguments),this.name="AmazonPayChangePaymentLinkError"}}const ya=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 fa({brand:e,descriptor:t}){const{hasError:a}=F(),n=e?.toLowerCase().replace(/\s+/g,"_")??"",i=ya.get(n)??"generic";return s(R,{direction:"inline",children:[a&&s(r,{children:[s(V,{tone:"critical",type:"alert-circle"}),s(A,{display:"inline",inlineSize:"small-400"})]}),s(Yt,{icon:s($t,{type:i}),details:t})]})}function va(){const{i18n:e}=Pe(),t=ke().purchaseOrderNumber.value;if(!t)return null;const a=`${e.translate("payment.purchase_order_number.title")} #${t}`;return s(U,{children:a})}const Ca=e=>s("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"66 -30 151 80",...e,children:[s("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"}),s("circle",{cx:157.2,cy:-2.9,r:3.5,fill:"inherit",stroke:"inherit",strokeWidth:2}),s("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"})]});function ba({minimal:e,reason:t,vaulted:a}){const{i18n:n}=Pe(),r=O().value.length,i=e=>{switch(e){case"giftCard":return n.translate("payment.order_covered_by_gift_cards_notice",{count:r});case"freeOrder":return n.translate("payment.free_order_notice_html");case"storeCredit":return n.translate("payment.order_covered_by_store_credit_notice");case"redeemables":return n.translate("payment.order_covered_by_redeemables_notice");case"deferred":return n.translate("payment_gateway.deferred_payment_label");default:o(e)}};return a?s(R,{gap:"base",children:[s($,{children:i(t)}),s(va,{})]}):e?s(jt,{children:s(qt,{children:i(t)})}):s("div",{className:"agRve",children:s(R,{gap:"large-200",alignItems:"center",children:[s(Ca,{className:"FiV0Z",focusable:"false","aria-hidden":"true"}),s(qt,{children:s($,{children:i(t)})})]})})}class ga extends t{constructor(){super(...arguments),this.name="AmazonPayMissingPaymentPreferencesError"}}function _a(){const e=ke().paymentLines;return n((()=>{const t=e.value,a=(()=>{const[e]=t.filter((e=>"walletsPlatformPaymentMethod"===e.method.type));if(!e)return"";const a=e.method.walletParams,s=a.payment_preferences?.[0];if(!s)throw new ga("Amazon Pay wallet params missing payment preferences",{groupingHash:"AmazonPay::usePaymentDetails::AmazonPayMissingPaymentPreferencesError"});return s.paymentDescriptor.replace("****","â¢â¢â¢â¢ ").replace(/(\((.*?)\))/,"").trim()})();return{brand:(()=>{if(!a)return;const e=a.match(/^(.+?)\s+â¢â¢â¢â¢/);if(!e)return a;const t=e[1];return void 0===t?a:t.trim()})(),descriptor:a}}))}const Ma={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}}"},Pa=Object.freeze({name:null,number:null,verification_value:null,expiry:null,issue_date:null,issue_number:null});var Sa=(e=>(e.FirstName="firstName",e.LastName="lastName",e.Number="number",e.Cvv="verificationValue",e.Month="month",e.Year="year",e.Base="base",e.DebitOnly="debitOnly",e))(Sa||{});
2const ka={baseMessage:null,fieldErrors:Pa,blockedByDuplicateAutopayCard:!1};function Aa(){const{i18n:e,observability:t}=Pe(),[a,s]=l(ka),n=c(((e,a)=>{t.counter({name:e,value:1,attributes:{errorField:a.field.join("-"),errorMessage:a.message}})}),[t]),r=c((t=>{if(!t||!t.length)return void s({baseMessage:e.translate("credit_card_form.generic_card_error"),fieldErrors:Pa,blockedByDuplicateAutopayCard:!1});const a={...Pa};let r=null;t.forEach((t=>{switch(n("save_credit_card_error",t),t.field?.[1]){case"firstName":return void(a.name=e.translate("field_errors.credit_card_name_billing_invalid"));case"lastName":return void(a.name=e.translate("field_errors.credit_card_name_invalid"));case"month":case"year":return void(a.expiry=e.translate("field_errors.credit_card_expiry_invalid"));case"number":return void(a.number=e.translate("field_errors.credit_card_number_invalid"));case"verificationValue":return void(a.verification_value=e.translate("payment.card_fields.errors.invalid.verification_value"));case"debitOnly":return void(r=e.translate("payment_errors.debit_only"));case"base":if("credit_card_is_expired"===t.message)return void(a.expiry=e.translate("payment_errors.card_has_expired"));if("failed_to_verify_credit_card"===t.message)return void(r=e.translate("payment.generic_incorrect_card_info"));if("three_d_secure_authentication_failed"===t.message)return void(r=e.translate("payment_errors.three_d_secure_failed_payment_method"));if("billing_address_missing"===t.message)return void(r=e.translate("payment_errors.payment_method_billing_address"))}"too_many_credit_cards"!==t.message?(r=e.translate("credit_card_form.generic_card_error"),n("save_credit_card_error_unhandled",t)):r=e.translate("credit_card_form.max_cards_reached",{max_cards:we})}
2)),s({baseMessage:r,fieldErrors:a,blockedByDuplicateAutopayCard:!1})}),[e,n]),i=c((()=>{t.counter({name:"save_credit_card_blocked_by_autopay",value:1}),s({baseMessage:null,fieldErrors:Pa,blockedByDuplicateAutopayCard:!0})}),[t]),d=c((()=>{s(ka)}),[]),o=c((e=>{t.counter({name:"save_credit_card_vaulting_failure",value:1,attributes:{reason:e}}),r("missing_billing_address"===e?[{field:["creditCard","base"],message:"billing_address_missing"}]:void 0)}),[t,r]);return{creditCardErrors:a,setCreditCardErrors:r,clearCreditCardErrors:d,failCardVaulting:o,blockDuplicateAutopayCard:i}}function Ea(e){return"CREDIT_CARD"===e?.paymentMethod}function wa(e){return"IDEAL"===e.paymentMethod||"CUSTOM_ONSITE"===e.paymentMethod&&!0===e.paymentBrands?.some((e=>"ideal"===e.toLowerCase()))}function Ia(e){return"APPLE_PAY"===e.paymentMethod}function xa(e){return"CUSTOM_ONSITE"===e.paymentMethod}function La(e){return"SHOP_PAY"===e.paymentMethod}function Da(e){return"SHOP_PAY_INSTALLMENTS"===e.paymentMethod}function Na(e){return"PAYPAL"===e.paymentMethod}function Ba(e){return"BANK"===e.paymentMethod}function Ta(e){return"DEFERRED"===e.paymentMethod}function Fa(e){return"OFFSITE"===e.paymentMethod||"MANUAL_PAYMENT"===e.paymentMethod||"CUSTOM_MANUAL_PAYMENT"===e.paymentMethod||"PAYMENT_ON_DELIVERY"===e.paymentMethod}function Va(e,t){let a=e.paymentMethod.toLowerCase(),s="";switch(e.paymentMethod){case"CREDIT_CARD":e.paymentAttributes?.brand&&(a=e.paymentAttributes.brand);break;case"CUSTOM_ONSITE":{const n=xe(t,{paymentBrands:e.paymentBrands,paymentMethodIdentifier:e.paymentMethodIdentifier});a=n?.name||"custom_onsite",s=e.paymentBrands?.slice().sort().join(",")??"";break}case"IDEAL":a="ideal";break;case"OFFSITE":a=e.name,s=e.paymentBrands?.slice().sort().join(",")??"";break;case"MANUAL_PAYMENT":case"CUSTOM_MANUAL_PAYMENT":case"PAYMENT_ON_DELIVERY":a=e.name;break;case"APPLE_PAY":a="apple_pay";break;case"SHOP_PAY":a="shop_pay";break;case"SHOP_PAY_INSTALLMENTS":a="shopify_installments";break;case"PAYPAL":a="paypal_express";break;case"BANK":a=e.displayName||"bank";break;case"DEFERRED":a="deferred";break;default:o(e)}return{paymentMethodName:a,paymentBrands:s}}const Ra={markBuyerHasActed:!1,updateSelectedCardBin:!1,selectedCardFirstDigits:void 0,preserveExistingBinPrefix:!1,claimMsiBin:!1,claimedMsiBin:void 0,shouldNegotiate:!1};function Ua(e){return{id:e.id,bank:e.bank,brand:e.brand,defaultPaymentMethod:e.preferred,expired:e.expired,expiryMonth:e.expiryMonth,expiryYear:e.expiryYear,lastDigits:e.lastDigits,lastUsedAt:e.lastUsedAt,name:e.name,nickname:e.nickname,billingAddress:e.billingAddress,cvvVerification:e.verified?void 0:{type:"session-token"}}}function Oa(e){switch(e.paymentMethod){case"CREDIT_CARD":return{id:e.id,paymentMethod:"CREDIT_CARD",paymentAttributes:Ua(e.paymentAttributes),lastUsedAt:e.lastUsedAt};case"IDEAL":case"CUSTOM_ONSITE":case"APPLE_PAY":case"OFFSITE":case"MANUAL_PAYMENT":case"CUSTOM_MANUAL_PAYMENT":case"PAYMENT_ON_DELIVERY":return e}}function $a(e,t){switch(e.paymentMethod){case"CREDIT_CARD":return t.find((t=>Le(t)&&t.id===e.id));case"IDEAL":case"CUSTOM_ONSITE":case"APPLE_PAY":case"OFFSITE":case"MANUAL_PAYMENT":case"CUSTOM_MANUAL_PAYMENT":case"PAYMENT_ON_DELIVERY":return e;case"SHOP_PAY":case"SHOP_PAY_INSTALLMENTS":case"PAYPAL":case"BANK":case"DEFERRED":return;default:o(e)}}class Ya extends Error{constructor(){super(...arguments),this.name="EmptySessionIdError"}}class qa extends Error{constructor(){super(...arguments),this.name="BuyerDetailsRefreshError"}}class ja{constructor(e){this.newCard=u(void 0),this.canSetCreditCardNickname=u(!0),this.addCreditCardStrategy="vault-and-select",this.deps=e;const{shopPay:t,installmentsPaymentMethodSelected:a,isApplePayAvailable:s,filteredNegotiatedPaymentMethods:n,isCreditCardDisabled:r,msiEligibilityByCardId:i,hasSellingPlan:d}=e;this.availablePaymentMethods=u(n),this.shopPayAvailableUserStoredPaymentMethods=m((()=>{const e=this.availablePaymentMethods.value;return e.length?ze(t.user.paymentMethods.value,e):[]})),this.availableUserStoredPaymentMethods=m((()=>this.shopPayAvailableUserStoredPaymentMethods.value.map(Oa))),this.promotedMethods=m((()=>t.session.promotedPaymentMethods.value.map(Oa))),this.selectedPaymentMethod=m((()=>{const e=t.session.selectedPaymentMethod.value;return e?Oa(e):void 0})),this.selectedCreditCard=m((()=>{const e=t.session.selectedPaymentMethod.value;return e&&Le(e)?Ua(e.paymentAttributes):void 0})),this.shopPayPaymentMethods=m((()=>
2{const e=t.user.paymentMethods.value,n=this.shopPayAvailableUserStoredPaymentMethods.value,i=this.availablePaymentMethods.value,d=t.session.promotedPaymentMethods.value,o=t.user.paymentMethodHistory.value,l=e.filter(Le).map((e=>({method:e,isValidForCheckout:n.includes(e),isExpired:e.paymentAttributes.expired,isDisabled:r(e.paymentAttributes)}))),c=a?[]:Ke({negotiatedPaymentMethods:i,userStoredPaymentMethods:e,paymentMethodHistory:o,isApplePayAvailable:s}),u=[...l.sort(((e,t)=>He(e.method,t.method))),...c.sort(((e,t)=>He(e.method,t.method)))];let m=-1,h="";for(const[t,a]of u.entries()){const e=a.method.lastUsedAt??"";e>h&&(h=e,m=t)}m>0&&u.unshift(...u.splice(m,1));const p=t.session.selectedPaymentMethod.value,y=new Set(d.map((e=>e.id)));return u.filter((({method:e})=>!!Le(e)||!(!p||Le(p)||e.id!==p.id)||!!y.has(e.id)||Qe(e)))})),this.paymentMethods=m((()=>this.shopPayPaymentMethods.value.map((({method:e,...t})=>({...t,method:Oa(e),canEdit:Le(e),canDelete:Le(e),canSetDefault:!1,isDefault:!1}))))),this.selectedPaymentMethodItem=m((()=>{const e=this.selectedPaymentMethod.value;if(e)return this.paymentMethods.value.find((({method:t})=>t.id===e.id&&t.paymentMethod===e.paymentMethod))})),this.cardPaymentMethods=m((()=>this.paymentMethods.value.filter((e=>Ea(e.method))))),this.activeOrExpiredCardMethods=m((()=>{const e=this.cardPaymentMethods.value,t=[];for(const s of e)a&&s.isDisabled||t.push(s);return t})),this.disabledCardMethodsForInstallments=m((()=>a?this.cardPaymentMethods.value.filter((e=>e.isDisabled)):[])),this.isEveryCardDisabled=m((()=>{const e=this.cardPaymentMethods.value;if(0===e.length)return!1;const t=new Set(this.disabledCardMethodsForInstallments.value.map((e=>e.method.id))),a=e.filter((e=>e.isExpired&&!t.has(e.method.id))).length;return e.length===t.size+a})),this.isEveryCardExpired=m((()=>{const e=this.cardPaymentMethods.value;if(0===e.length)return!1;const t=new Set(this.disabledCardMethodsForInstallments.value.map((e=>e.method.id))),a=e.filter((e=>!t.has(e.method.id)));return 0!==a.length&&a.every((e=>e.isExpired))}));const o=m((()=>{const e=We(this.availablePaymentMethods.value);if(!Y(e))return!1;const t=this.selectedCreditCard.value;return Boolean(t&&i.value[t.id])}));this.msi={binResolution:"server",selectedCardBin:m((()=>{})),clearInstallments:De,expandedVisible:m((()=>!!o.value&&"SHOPIFY_INSTALLMENTS"!==t.session.paymentMethodOption.value?.name)),collapsedVisible:m((()=>o.value&&!d.value))}}canShowAsGuestCheckoutMethod(e){const{shopPay:t}=this.deps;return t.visibility.showGuestCheckoutPaymentMethods&&!("wallet"===e.type&&("SHOP_PAY"===e.name||"SHOPIFY_INSTALLMENTS"===e.name))}async selectPaymentMethod(e,t="programmatic",a){const{shopPay:s,updateCheckoutAddress:n,shippingRequired:r}=this.deps;if(!e)return s.session.clearPaymentMethod(),{status:"handled",effects:Ra};const i=$a(e,s.user.paymentMethods.value);if(!i)return{status:"not-handled"};if("buyer"===t&&this.recordPaymentMethodSelected(e),Ea(e)){const t=this.selectCreditCard({id:e.paymentAttributes.id});return Ne(i,s.user.paymentMethods.value,Ie(i,this.availablePaymentMethods.value))&&this.#e(i,a),await t,{status:"handled",effects:Ra}}const d=Ie(i,this.availablePaymentMethods.value);return Ne(i,s.user.paymentMethods.value,d)&&this.#e(i,"buyer"===t?{...a,buyerInitiated:!0}:a),(Be(i)||Te(i)||Fe(i)||Ve(i))&&await n({billingAddress:s.session.selectedBillingAddress.value?.address,fallbackPhoneNumber:s.user.phoneNumber.value},r.value),{status:"handled",effects:Ra}}async promoteSelectedPaymentMethod(e){const{shopPay:t}=this.deps,a=Re(e,t.user.paymentMethods.value);return a&&(t.session.selectPaymentMethod(a),t.session.unstable_promotePaymentMethod(a)),{status:"handled",effects:{...Ra,selectByBuyerKey:Ue(e)}}}getSavedCardActiveSubscriptionsLookup(e){const t=this.deps.shopPay.user.paymentMethods.value.filter(Le).map((e=>e.paymentAttributes)).find((t=>t.id===e.id));if(!t)return;const a={id:t.id,uuid:t.uuid,first:3},s=h(Ma,a),{shopPayGraphql:n}=this.deps;return{key:s,read(){const e=n.read(s);return e?.creditCardActiveSubscriptions?.nodes},async load(){const{data:e}=await n.staticQuery(Ma,{variables:a});
2return e?.creditCardActiveSubscriptions?.nodes??[]}}}async selectCreditCard({id:e}){const{shopPay:t}=this.deps,a=t.user.paymentMethods.value.filter(Le).map((e=>e.paymentAttributes)).find((t=>t.id===e));if(!a)return;const{updateCheckoutAddress:s,fallbackPhoneNumber:n}=this.deps;t.session.selectPaymentMethod({id:a.id,lastUsedAt:a.lastUsedAt,paymentMethod:"CREDIT_CARD",paymentAttributes:a}),this.clearShopPayPaymentLines(),await s({billingAddress:a.billingAddress.address,fallbackPhoneNumber:n})}async deleteCreditCard({id:e}){return this.deleteCreditCardById({id:e})}async updateCreditCard({id:e,billingAddress:t,nickname:a}){const{shopPay:s,updateCreditCard:n,checkoutContext:r,markShopCashStatesStale:i,observability:d}=this.deps,o=s.user.paymentMethods.value.filter(Le).map((e=>e.paymentAttributes)).find((t=>t.id===e));if(!o)return{status:"failed"};const l=await n(t,e,o.uuid,r,a);if("success"===l.status&&l.creditCard){const{creditCard:t}=l;s.user.updateCreditCard(e,t),this.selectCreditCard({id:t.id}).catch((e=>{d.error(e)}))}if(i(),"success"!==l.status){const e=Oe();return na({addressErrors:e,shopPayErrors:l.errors,i18n:this.deps.i18n,observability:d,userEvents:this.deps.userEvents,source:this.deps.source,configuration:this.deps.checkout.configuration,shop:this.deps.shop,addressContext:"payment-method",submittedAddress:t}),{status:"failed",addressErrors:Object.fromEntries(Object.entries(e).map((([e,t])=>[e,t.value])))}}return{status:"success"}}async addCreditCard({sessionId:e,billingAddress:t,nickname:a,debitOnly:s=!1,isBlocking:n=!1}){const{createCreditCard:r,checkoutContext:i,markShopCashStatesStale:d,observability:o}=this.deps;if(""===e)return o.error(new Ya("ShopPayPaymentMethodManager: addCreditCard called with empty sessionId")),{status:"failed"};const l=await r(t,e,i,a),c=await this.handleNewCardResponse(l,s,n);return d(),c}async completeCreditCardVerificationAndVault({verificationId:e,billingAddress:t,nickname:a,debitOnly:s=!1,isBlocking:n=!1}){const{completeCreditCardVerification:r,markShopCashStatesStale:i}=this.deps,d=await r(t,e,a),o=await this.handleNewCardResponse(d,s,n);return i(),o}dispose(){}async deleteCreditCardById({id:e,uuid:t}){const{shopPay:a,deleteCreditCard:s,updateCheckoutAddress:n,emptyAddress:r,fallbackPhoneNumber:i,checkoutContext:d,markShopCashStatesStale:o}=this.deps,l=t??a.user.paymentMethods.value.filter(Le).map((e=>e.paymentAttributes)).find((t=>t.id===e))?.uuid;if(!l)return{status:"failed"};const c=a.session.selectedPaymentMethod.value,u=c&&Le(c)?c.paymentAttributes.uuid:void 0,m=await s(e,l,d);if("success"!==m.status&&!function(e){return e.errors?.some((({message:e})=>"credit_card_not_found"===e))??!1}(m))return{status:"failed"};const h=a.user.paymentMethods.value.filter(Le).map((e=>e.paymentAttributes)).filter((e=>e.uuid!==l));if(a.user.removeCreditCard(e),o(),u!==l)return{status:"success"};const p=$e(h);if(p)a.session.selectPaymentMethod({id:p.id,lastUsedAt:p.lastUsedAt,paymentMethod:"CREDIT_CARD",paymentAttributes:p}),this.clearShopPayPaymentLines();else{const e=this.paymentMethods.value.find((({method:e,isValidForCheckout:t,isDisabled:a,isExpired:s})=>t&&!a&&!s&&function(e){return Ea(e)||Boolean(e.lastUsedAt)}(e)))?.method;if(e){const t=$a(e,a.user.paymentMethods.value);t&&this.#e(t)}else a.session.clearPaymentMethod(),this.clearShopPayPaymentLines(),a.session.unstable_updateSelectedBillingAddress(a.session.selectedShippingAddress.value)}const y=p?p.billingAddress.address:a.session.selectedBillingAddress.value?.address;return await n({billingAddress:y??r.value,fallbackPhoneNumber:i}),{status:"success"}}recordPaymentMethodSelected(e){const{observability:t,userEvents:a,source:s,checkout:n,shop:r}=this.deps,i=e.paymentMethod.toLowerCase(),{paymentMethodName:d,paymentBrands:o}=Va(e,this.availablePaymentMethods.value);t.counter({name:"payment_method_selected",value:1,attributes:{payment_method_type:i,payment_method_name:d,payment_brands:o,location:"shop_pay_payment_selector",is_mobile:Ye()}}),a.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...qe(s,n,r),action:"payment_method_selected",paymentMethodName:d}})}async handleNewCardResponse(e,t,a){const{shopPay:s,markShopCashStatesStale:n}=this.deps;
2if("success"===e.status&&e.creditCard){if(t&&"debit"!==e.creditCard.funding)return await this.deleteCreditCardById({id:e.creditCard.id,uuid:e.creditCard.uuid}),{status:"failed",errors:[{field:["",Sa.DebitOnly],message:""}]};await this.refreshPaymentMethodsFromBuyerDetails()||s.user.addCreditCard(e.creditCard),a?await this.selectCreditCardAndSetPaymentLine({id:e.creditCard.id}):this.selectCreditCardAndSetPaymentLine({id:e.creditCard.id}).catch((e=>{this.deps.observability.error(e)})),n()}return e}async refreshPaymentMethodsFromBuyerDetails(){const{shopPay:e,refreshBuyerDetails:t,paymentRequiredMethod:a,observability:s}=this.deps;try{const s=await t();return"success"===s.status&&(e.updatePaymentMethodsFromBuyerDetails(s,{negotiatedPaymentMethods:this.availablePaymentMethods.value,paymentRequiredMethod:a}),!0)}catch(n){return s.error(n instanceof Error?n:new qa("Failed to refresh Shop Pay buyer details")),!1}}async selectCreditCardAndSetPaymentLine({id:e}){const t=void 0!==sa(this.deps.proposedPaymentLines.value),a=this.selectCreditCard({id:e});if(t)return a;const{shopPay:s}=this.deps,n=s.session.selectedPaymentMethod.value;n&&Le(n)&&n.paymentAttributes.id===e&&Ne(n,s.user.paymentMethods.value,Ie(n,this.availablePaymentMethods.value))&&this.#e(n),await a}#e(e,t){const{shopPay:a,setPaymentLine:s,observability:n}=this.deps;p((()=>{a.session.selectPaymentMethod(e);const r=je({paymentMethod:e,negotiatedPaymentMethods:this.availablePaymentMethods.value,observability:n});void 0!==r&&(t?s(r,void 0,t):s(r))}))}clearShopPayPaymentLines(){const{proposedPaymentLines:e}=this.deps;e.value=e.value.filter((e=>!Ge([e],"SHOP_PAY")))}}function Ga(){const e=za(),{newCardSignal:t,hasLoadedSignal:a}=Ze(),s=t.value,n=a.value,{value:r}=Se().paymentLines,i=r?.lines?.find((e=>"direct"===e.method.type));return e.value&&!n&&i&&(a.value=!0,!s&&i.method.paymentMethodIdentifier&&(t.value=i.method)),t}function za(){const e=Pe().checkout.configuration.layout.isOnePage.value,{paymentMethods:t}=Se();return n((()=>!!e&&Boolean(Xe(t.value).length)))}const Ka={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}"},Ha={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}"},Qa={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}}"};const Wa={id:"0e9fd59cad63a6cd040eec702de445aa95c0d9f613f732e94dce615a476c9d59",type:"mutation",name:"CreditCardUpdate",source:"mutation CreditCardUpdate($billingAddress:AddressInput!,$id:ID!,$uuid:String!,$origin:String!,$nickname:String,$checkoutContext:CheckoutContextInput!){creditCardUpdate(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 Xa(e){const{geolocation:t}=q(),{shopPay:a,checkout:s}=Pe(),n=a.user.phoneNumber.value,r=a.user.addresses.value,i=s.configuration.addressSettings.nonBillingAddressSettings.value,d=r[0]?.address,o=i.defaultShippingDetails.country?.code??t.country.code;return y((()=>nt({firstName:d?.firstName,lastName:d?.lastName,phone:n,countryCode:d?.countryCode||o,zoneCode:d?.zoneCode},{extendedAddressMode:s.address.extendedAddressMode})),[s.address.extendedAddressMode,e,d,o,n])}const Za={id:"563e8a86083a6c9ad5bd44d3a4db471e3a9919052512d2745d267074d97420fd",type:"mutation",name:"DeleteVaultedCreditCard",source:""},Ja={id:"d1f468f7d6684d3133e47cef5cf1ef67ccd2bd916b53203708d85ac3175f1bd0",type:"mutation",name:"UpdateCustomerCreditCard",source:""};class es extends Error{constructor(e){super("Failed to update customer credit card payment method",e),this.name="UpdateCustomerCreditCardPaymentMethodError"}}class ts extends Error{constructor(e){super("Failed to delete customer credit card payment method",e),this.name="DeleteCustomerCreditCardPaymentMethodError"}}async function as({graphql:e,address:t,extendedAddressMode:a,defaultPaymentMethod:s,token:n,genericError:r}){if(!n)return{token:void 0};try{const{data:i,error:d}=await e.mutate(Ja,{variables:{customerCreditCardModificationInput:{token:n,defaultPaymentMethod:s,billingAddress:{streetAddress:rt(t,{extendedAddressMode:a})}}}});if(!i?.modifyCustomerCreditCardPaymentMethod||d)throw new es({cause:d});const{result:o,errors:l}=i.modifyCustomerCreditCardPaymentMethod;return l.length||!o?{token:void 0,error:l[0]?.localizedMessage||r}:{token:o.token}}catch{return{token:void 0,error:r}}}async function ss({graphql:e,token:t,genericError:a}){if(!t)return{token:void 0};try{const{data:s,error:n}=await e.mutate(Za,{variables:{token:t}});if(!s?.deleteCustomerCreditCardPaymentMethod||n)throw new ts({cause:n});const{result:r,errors:i}=s.deleteCustomerCreditCardPaymentMethod;return i.length||!r?{token:void 0,error:i[0]?.localizedMessage||a}:{token:r.token}}catch{return{token:void 0,error:a}}}function ns({userEvents:e,shopId:t,checkoutSessionIdentifier:a,card:s}){e.monorailEvent({schemaId:"checkout_vaulted_payment_method_selected/1.0",payload:{shopId:parseInt(st(t),10),checkoutSessionIdentifier:a||"",paymentMethodId:parseInt(st(s.id),10),paymentInstrumentAccessorId:-1}})}class rs extends t{constructor({managerName:e,methodName:t,identity:a,deployStage:s,isLocalDevelopment:n}){super(`${e}.${t} was called unexpectedly`,{groupingHash:`PaymentMethodManagerUnexpectedMethodCall::${e}::${t}`,metadata:{paymentMethodManager:{managerName:e,methodName:t,identity:a,deployStage:s,isLocalDevelopment:n}}}),this.name="UnexpectedPaymentMethodManagerMethodCallError"}}function is({observability:e,managerName:t,methodName:a,identity:s,deployStage:n,isLocalDevelopment:r}){if(r||"production"!==n&&"canary"!==n)return;const i=new rs({managerName:t,methodName:a,identity:s,deployStage:n,isLocalDevelopment:r});e.error(i,{severity:"warning"})}const ds={status:"failed"};class os{constructor(e){this.disabledCardMethodsForInstallments=u([]),this.isEveryCardDisabled=u(!1),this.canSetCreditCardNickname=u(!1),this.addCreditCardStrategy="direct-session-payment-line",this.deps=e,this.usesCustomerAccountSelectionRule="customerAccount"===e.identity,this.newCard=e.newCard??u(void 0);const{proposal:t}=e,{proposed:a,negotiated:s}=t,{paymentMethods:n}=s.fields,r=s.fields.paymentMethodHistory??u([]);this.availablePaymentMethods=m((()=>n.value??[])),this.promotedMethods=e.paymentMethodPromotions.promoted,this.customerCreditCards=m((()=>lt(this.availablePaymentMethods.value))),this.selectableCustomerCreditCards=m((()=>Xe(this.availablePaymentMethods.value))),this.selectablePaypalBillingAgreements=m((()=>(e.displayablePaymentMethods?.value??this.availablePaymentMethods.value).filter((e=>e.type===ct.PayPal)))),this.selectableCustomerBanks=m((()=>this.availablePaymentMethods.value.filter((e=>"bank"===e.type&&e.availableInstruments.length>0)))),this.nonCardKnownPaymentMethods=m((()=>ut({paymentMethodHistory:r.value??[],availablePaymentMethods:e.displayablePaymentMethods?.value??this.availablePaymentMethods.value}))),this.availableUserStoredPaymentMethods=m((()=>[...cs([ls({card:this.newCard.value,billingAddress:a.billingAddress.value})]),...this.selectableCustomerCreditCards.value.map((e=>mt(e,{cvvVerificationEnabled:this.deps.storeVaultGuestCvvVerificationEnabled}))),...this.selectablePaypalBillingAgreements.value.map(ht),...ps(this.selectableCustomerBanks.value.map(pt),this.nonCardKnownPaymentMethods.value,this.promotedMethods.value)])),this.autoselectTarget=m((()=>{const e=this.selectableCustomerCreditCards.value.find((e=>e.defaultPaymentMethod)),t=e?this.availableUserStoredPaymentMethods.value.find((t=>t.id===e.token)):void 0,a=this.availableUserStoredPaymentMethods.value.reduce(((e,t)=>t.lastUsedAt?e?.lastUsedAt?t.lastUsedAt>e.lastUsedAt?t:e:t:e),void 0);if(this.usesCustomerAccountSelectionRule){const e=!a||Ea(a);if(this.deps.storeVaultEnabled&&e&&t)return t}else if(e)return t;if(a)return a;const s=this.selectableCustomerCreditCards.value[0];if(s)return this.availableUserStoredPaymentMethods.value.find((e=>e.id===s.token));return this.availableUserStoredPaymentMethods.value.find((e=>!Ea(e)&&!Ta(e)))||this.availableUserStoredPaymentMethods.value.find(Ta)})),this.proposedSelectedPaymentMethod=m((()=>function(e,t,a,s){const n=e.some((e=>"deferred"!==e.method.type&&"giftCard"!==e.method.type&&"redeemable"!==e.method.type));for(const r of e){if("direct"===r.method.type&&s)return s;if("deferred"===r.method.type){if(n)continue;const e=t.find(Ta);if(e)return e;continue}if(us(r)){const e=t.filter(Ea).find((e=>e.id===r.method.token));if(e)return e;continue}if(ms(r)){const e=t.find((e=>"PAYPAL"===e.paymentMethod&&"billing_agreement"===e.variant&&e.vaultedToken===r.method.token));if(e)return e;continue}const e=hs(r,t,a);if(e)return e}}(a.paymentLines.value,this.availableUserStoredPaymentMethods.value,this.availablePaymentMethods.value,ls({card:this.newCard.value,billingAddress:a.billingAddress.value})))),this.selectedPaymentMethod=m((()=>this.proposedSelectedPaymentMethod.value??this.autoselectTarget.value)),this.paymentMethods=m((()=>function({cardItems:e,nonCardItems:t,autoselectTarget:a}){const s=e.find((({method:e})=>e.id===dt)),n=[...e.filter((({method:e})=>e.id!==dt))].sort(((e,t)=>He(e.method,t.method))),r=[...t].sort(((e,t)=>He(e.method,t.method))),i=n.filter(ys),d=r.filter(ys),o=i.find((({method:e})=>Ea(e)&&e.paymentAttributes.defaultPaymentMethod)),l=[i[0],d[0]].filter((e=>void 0!==e)).sort(((e,t)=>
2He(e.method,t.method)))[0],c=(a?[...i,...d].find((({method:e})=>e.id===a.id&&e.paymentMethod===a.paymentMethod)):void 0)??o??l;return c?[...cs([s]),c,...n.filter((e=>e!==c)),...r.filter((e=>e!==c))]:[...cs([s]),...n,...r]}({cardItems:[...cs([ls({card:this.newCard.value,billingAddress:a.billingAddress.value})]),...this.customerCreditCards.value.map((e=>mt(e,{cvvVerificationEnabled:this.deps.storeVaultGuestCvvVerificationEnabled})))].map((e=>({method:e,isValidForCheckout:!0,isExpired:e.paymentAttributes.expired,isDisabled:!1,...fs({identity:this.deps.identity,storeVaultEnabled:this.deps.storeVaultEnabled,card:e})}))),nonCardItems:this.availableUserStoredPaymentMethods.value.filter((e=>!Ea(e))).map((e=>({method:e,isValidForCheckout:!0,isExpired:!1,isDisabled:!1,canEdit:!1,canDelete:!1,canSetDefault:!1,isDefault:!1}))),autoselectTarget:this.usesCustomerAccountSelectionRule?this.autoselectTarget.value:void 0}))),this.selectedPaymentMethodItem=m((()=>{const e=this.selectedPaymentMethod.value;if(e)return this.paymentMethods.value.find((({method:t})=>t.id===e.id&&t.paymentMethod===e.paymentMethod))})),this.selectedCreditCard=m((()=>{const e=this.selectedPaymentMethod.value;return Ea(e)?e.paymentAttributes:void 0})),this.cardPaymentMethods=m((()=>this.paymentMethods.value.filter((e=>Ea(e.method))))),this.activeOrExpiredCardMethods=this.cardPaymentMethods,this.isEveryCardExpired=m((()=>{const e=this.cardPaymentMethods.value;return e.length>0&&e.every((e=>e.isExpired))}));const i=m((()=>{const e=We(this.availablePaymentMethods.value);if(!Y(e))return!1;const t=this.selectedCreditCard.value;return!!t&&a.paymentLines.value.some((e=>t.id===dt?"direct"===e.method.type:e.method.type===ct.CreditCard&&e.method.token===t.id))}));this.msi={binResolution:"client",selectedCardBin:m((()=>{const e=this.selectedCreditCard.value;if(e)return e.id===dt?this.newCard.value?.creditCardFirstDigits:this.selectableCustomerCreditCards.value.find((t=>t.token===e.id))?.firstDigits})),clearInstallments:j,expandedVisible:i,collapsedVisible:i}}async promoteSelectedPaymentMethod(e){const t=it(e,null);return t?(this.deps.paymentMethodPromotions.promote(t),this.selectPaymentMethod(t,"buyer")):{status:"handled",effects:{...Ra,selectByBuyerKey:Ue(e)}}}canShowAsGuestCheckoutMethod(){return!1}async selectPaymentMethod(e,t="programmatic"){if(!e)return{status:"not-handled"};if(!Ea(e)){const a=Ie(e,this.availablePaymentMethods.value);if(!a)return{status:"not-handled"};const s=Ue(a);return"buyer"===t?{status:"handled",effects:{...Ra,selectByBuyerKey:s}}:(this.deps.setPaymentLine(s),{status:"handled",effects:Ra})}if("buyer"===t)return this.selectCreditCardByBuyer({paymentMethod:e});if(e.id===dt)return this.deps.setPaymentLine(dt),{status:"handled",effects:Ra};const a=this.selectableCustomerCreditCards.value.find((t=>t.token===e.paymentAttributes.id));return a?(this.deps.setPaymentLine(ot(a)),{status:"handled",effects:Ra}):{status:"not-handled"}}async deleteCreditCard({id:e}){if(e===dt){const{proposed:e}=this.deps.proposal;if(!this.newCard.value)return{status:"failed"};this.newCard.value=void 0,e.acceptPaymentVaulting.value=!1;const t=this.selectableCustomerCreditCards.value[0];if(t)this.deps.setPaymentLine(ot(t));else{const t=this.autoselectTarget.value,a=t?Ie(t,this.availablePaymentMethods.value):void 0;a?this.deps.setPaymentLine(Ue(a)):e.paymentLines.value=e.paymentLines.value.filter((e=>"direct"!==e.method.type))}return{status:"success",shouldResetSuggestedBillingAddress:Boolean(t),shouldResetBillingAddressToShipping:"businessCustomer"!==this.deps.identity}}const t=this.selectedPaymentMethod.value,a=Ea(t)&&t.id===e,s=this.selectableCustomerCreditCards.value.find((t=>t.token!==e)),n=await ss({graphql:this.deps.graphql,token:e,genericError:this.deps.i18n.translate("customer_payment_methods.delete_customer_mandate.generic_error")});return n.token?(a&&s&&this.deps.setPaymentLine(ot(s)),{status:"success",shouldNegotiatePaymentMethods:!0}):{status:"failed",bannerError:n.error}}async updateCreditCard({id:e,billingAddress:t,defaultPaymentMethod:a=!1}){const s=await as({graphql:this.deps.graphql,token:e,address:t,extendedAddressMode:this.deps.extendedAddressMode,defaultPaymentMethod:a,genericError:this.deps.i18n.translate("shipping.address_form.generic_error")});return s.token?{status:"success",shouldNegotiatePaymentMethods:!0}:{status:"failed",bannerError:s.error}}async addCreditCard(){return this.reportUnexpectedUse("addCreditCard"),ds}async completeCreditCardVerificationAndVault(){return this.reportUnexpectedUse("completeCreditCardVerificationAndVault"),ds}dispose(){}async selectCreditCardByBuyer({paymentMethod:e}){let t,a,s;if(e.id===dt){const e=this.newCard.value;if(!e)return{status:"not-handled"};
2t=dt,a=e,s=e.creditCardFirstDigits}else{const a=this.selectableCustomerCreditCards.value.find((t=>t.token===e.paymentAttributes.id));if(!a)return{status:"not-handled"};t=ot(a),s=a.firstDigits,ns({userEvents:this.deps.userEvents,shopId:this.deps.shopId,checkoutSessionIdentifier:this.deps.checkoutSessionIdentifier,card:a})}return this.deps.isMsiAvailable&&(this.deps.proposal.proposed.paymentLines.value=j(this.deps.proposal.proposed.paymentLines.value)),{status:"handled",effects:{...Ra,selectByBuyerKey:t,...a?{selectByBuyerPaymentMethod:a}:{},updateSelectedCardBin:!0,selectedCardFirstDigits:s,preserveExistingBinPrefix:e.id===dt,claimMsiBin:this.deps.isMsiAvailable,claimedMsiBin:this.deps.isMsiAvailable?s:void 0,shouldNegotiate:!0}}}reportUnexpectedUse(e){is({...this.deps,managerName:"CustomerPaymentMethodManager",methodName:e})}}function ls({card:e,billingAddress:t}){if(e?.brand&&e.creditCardLastFourDigits)return{id:dt,paymentMethod:"CREDIT_CARD",paymentAttributes:{id:dt,brand:e.brand,expired:!1,expiryMonth:0,expiryYear:0,lastDigits:e.creditCardLastFourDigits,name:e.cardholderName,billingAddress:{address:t??{}}},lastUsedAt:null}}function cs(e){return e.filter((e=>void 0!==e))}function us(e){return e.method.type===ct.CreditCard}function ms(e){return e.method.type===ct.PayPal}function hs(e,t,a){const s=Ue(e.method);return t.find((e=>{if(Ea(e))return!1;const t=Ie(e,a);return!!t&&s===Ue(t)}))}function ps(...e){const t=[],a=new Set;for(const s of e)for(const e of s){const s=`${e.paymentMethod}:${e.id}`;a.has(s)||(a.add(s),t.push(e))}return t}function ys(e){return e.isValidForCheckout&&!e.isExpired&&!e.isDisabled}function fs({identity:e,storeVaultEnabled:t,card:a}){if(a.id===dt)return Cs;if("businessCustomer"===e)return vs;const{paymentAttributes:s}=a;return t?s.expired?s.deletable?{canEdit:!1,canDelete:!0,canSetDefault:!1,isDefault:Boolean(s.defaultPaymentMethod)}:vs:{canEdit:!0,canDelete:Boolean(s.deletable),canSetDefault:!0,isDefault:Boolean(s.defaultPaymentMethod)}:vs}const vs={canEdit:!1,canDelete:!1,canSetDefault:!1,isDefault:!1},Cs={canEdit:!1,canDelete:!0,canSetDefault:!1,isDefault:!1},bs={status:"failed"};class gs{constructor(e){this.availablePaymentMethods=u([]),this.availableUserStoredPaymentMethods=u([]),this.paymentMethods=u([]),this.selectedPaymentMethod=u(void 0),this.selectedPaymentMethodItem=u(void 0),this.selectedCreditCard=u(void 0),this.activeOrExpiredCardMethods=u([]),this.disabledCardMethodsForInstallments=u([]),this.isEveryCardDisabled=u(!1),this.isEveryCardExpired=u(!1),this.cardPaymentMethods=u([]),this.promotedMethods=u([]),this.msi={binResolution:"client",selectedCardBin:u(void 0),clearInstallments:e=>e,expandedVisible:u(!1),collapsedVisible:u(!1)},this.newCard=u(void 0),this.canSetCreditCardNickname=u(!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"),bs}async updateCreditCard(){return this.reportUnexpectedUse("updateCreditCard"),bs}async addCreditCard(){return this.reportUnexpectedUse("addCreditCard"),bs}async completeCreditCardVerificationAndVault(){return this.reportUnexpectedUse("completeCreditCardVerificationAndVault"),bs}dispose(){}reportUnexpectedUse(e){is({...this.unexpectedUseOptions,managerName:"FallbackPaymentMethodManager",methodName:e})}}function _s({enableAutoSelect:e=!0}={}){const{source:t,environment:a,checkout:s,shop:n,i18n:r,observability:i,userEvents:o,shopPay:l,graphql:{coreGraphql:u,shopPayGraphql:m}}=Pe(),h=s.identity.current.value,p=n.hasFlagEnabled(yt),v=null!=a.devMode,C=function(){const{checkout:{address:{extendedAddressMode:e}},graphql:{shopPayGraphql:t},source:a}=Pe(),s=Je({source:a});return c((async(a,n,r,i,d=s)=>{const{data:o,error:l}=await t.mutate(Ka,{variables:{billingAddress:et(a,e),origin:d,sessionId:n,nickname:i,checkoutContext:r}}
2);if(l||null==o||null==o.creditCardCreate)return{status:"failed"};const{creditCardCreate:c}=o;return tt(c.userErrors)?{status:"blocked_by_autopay"}:c.userErrors.length>0?{status:"failed",errors:c.userErrors}:c.threeDSecureAuthenticationRequest?{status:"requires_redirect",threeDSecureAuthenticationRequest:c.threeDSecureAuthenticationRequest}:{status:"success",creditCard:c.creditCard?at(c.creditCard):void 0}}),[s,e,t])}(),b=function(){const{checkout:{address:{extendedAddressMode:e}},graphql:{shopPayGraphql:t},source:a}=Pe(),s=Je({source:a});return c((async(a,n,r,i=s)=>{const{data:d,error:o}=await t.mutate(Ha,{variables:{verificationId:n,billingAddress:et(a,e),origin:i,nickname:r}});if(o||null==d||null==d.creditCardCompleteVerificationAndVault)return{status:"failed"};const{creditCardCompleteVerificationAndVault:l}=d;return tt(l.userErrors)?{status:"blocked_by_autopay"}:l.userErrors.length>0?{status:"failed",errors:l.userErrors}:{status:"success",creditCard:l.creditCard?at(l.creditCard):void 0}}),[s,e,t])}(),g=function(){const{graphql:{shopPayGraphql:e},source:t}=Pe(),a=Je({source:t});return c((async(t,s,n,r=a)=>{const{data:i,error:d}=await e.mutate(Qa,{variables:{id:t,uuid:s,origin:r,checkoutContext:n}});if(d||null==i||null==i.creditCardDelete)return{status:"failed"};const{creditCardDelete:o}=i;return o.userErrors.length>0?{status:"failed",errors:o.userErrors}:{status:"success"}}),[a,e])}(),_=function(){const{graphql:{shopPayGraphql:e},source:t,shop:{myshopifyDomain:a,id:s},shopPay:{config:n}}=Pe(),{checkoutSessionIdentifier:r}=t,i=Je({source:t}),{redirectSource:d}=n;return c((async()=>{const{data:t,error:n}=await function(e,{checkoutVersion:t,checkoutIdentifier:a,shopifyDomain:s,shopId:n,redirectSource:r},{cache:i=!0}={}){return e.staticQuery(Xt,{variables:{checkoutContextInput:{checkoutVersion:t,checkoutIdentifier:a,shopifyDomain:s,shopId:n},shopifyDomain:s,redirectSource:r??void 0},cache:i})}(e,{checkoutVersion:i,checkoutIdentifier:r??"unknown",shopifyDomain:a,shopId:st(s),redirectSource:d},{cache:!1});return n||null==t||null==t.checkoutSession||null==t.checkoutSession.user?{status:"failed"}:Zt(t)}),[r,i,d,s,a,e])}(),M=function(){const{checkout:{address:{extendedAddressMode:e}},graphql:{shopPayGraphql:t},source:a}=Pe(),s=Je({source:a});return c((async(a,n,r,i,d,o=s)=>{const{data:l,error:c}=await t.mutate(Wa,{variables:{id:n,uuid:r,billingAddress:et(a,e),origin:o,nickname:d,checkoutContext:i}});
2if(c||!l?.creditCardUpdate)return{status:"failed"};const{creditCardUpdate:u}=l;return u.userErrors.length>0?{status:"failed",errors:u.userErrors}:{status:"success",creditCard:u.creditCard?at(u.creditCard):void 0}}),[s,e,t])}(),P=Je({source:t}),S=Xa(),k=ke(),{paymentLines:A}=k,E=Ga(),{buyerHasActedSignal:w,newCardSignal:I}=Ze(),x=f(Qt),L=l.user.phoneNumber.value,D=Se(),N=Gt(),B=l.session.isInstallmentsSelected.value,T=zt({isApplePayAvailable:N.value}),F=ft(),{creditCardDisabled:V}=Jt(),R=Wt(),{updateCheckoutAddress:U}=Kt(),[,O]=Ht({allowPreselect:!1}),$=We(D.paymentMethods.value??[]),q=Y($),j=vt(),{eligibilityByCardId:G}=Ct(ta),z=c((()=>{x&&(x.cashbackState.stale.value=!0)}),[x]),K=y((()=>({checkoutIdentifier:t.checkoutSessionIdentifier??"",checkoutVersion:P,shopId:st(n.id),shopifyDomain:n.myshopifyDomain})),[t.checkoutSessionIdentifier,n.id,n.myshopifyDomain,P]),H=y((()=>"shopPay"===h?new ja({shopPay:l,negotiatedPaymentMethods:D.paymentMethods,installmentsPaymentMethodSelected:B,isApplePayAvailable:N.value,filteredNegotiatedPaymentMethods:T.value,isCreditCardDisabled:V,setPaymentLine:O,updateCheckoutAddress:U,shippingRequired:s.isShippingRequired,i18n:r,observability:i,userEvents:o,source:t,checkout:s,shop:n,createCreditCard:C,deleteCreditCard:g,updateCreditCard:M,completeCreditCardVerification:b,refreshBuyerDetails:_,markShopCashStatesStale:z,shopPayGraphql:m,emptyAddress:S,proposedPaymentLines:A,checkoutContext:K,fallbackPhoneNumber:L,paymentRequiredMethod:R.value,msiEligibilityByCardId:G,hasSellingPlan:j}):"customerAccount"===h||"businessCustomer"===h?new os({proposal:s.proposal,newCard:E,displayablePaymentMethods:F,paymentMethodPromotions:s.paymentMethodPromotions,setPaymentLine:O,isMsiAvailable:q,shopId:n.id,checkoutSessionIdentifier:t.checkoutSessionIdentifier,storeVaultEnabled:n.storeVaultEnabled,storeVaultGuestCvvVerificationEnabled:n.storeVaultGuestCvvVerificationEnabled,graphql:u,extendedAddressMode:s.address.extendedAddressMode,i18n:r,observability:i,userEvents:o,identity:h,deployStage:a.deployStage,isLocalDevelopment:v}):new gs({observability:i,identity:h,deployStage:a.deployStage,isLocalDevelopment:v})),[h,a.deployStage,v,l,D.paymentMethods,B,N.value,T.value,F,V,q,O,U,s,i,o,t,n,r,u,m,C,g,_,M,b,z,S,A,E,K,L,R.value,G,j]);d((()=>()=>H.dispose()),[H]);const Q=H.selectedPaymentMethod.value,W=H.paymentMethods.value,X=H.availablePaymentMethods.value,Z=H.availableUserStoredPaymentMethods.value,J=A.value.some((e=>"direct"===e.method.type));d((()=>{if(!e)return;if("shopPay"!==h)return;if(Q&&function({selected:e,paymentMethods:t,availablePaymentMethods:a}){return Boolean(Ie(e,a)||Ea(e)&&t.some((({method:t})=>t.paymentMethod===e.paymentMethod&&t.id===e.id)))}({selected:Q,paymentMethods:W,availablePaymentMethods:X}))return;if(J)return;const a=W.filter((({isValidForCheckout:e})=>e)).sort(((e,t)=>He(e.method,t.method))).map((({method:e})=>e)),r=function(e){for(const t of e){if(!Ea(t))return t;if(!t.paymentAttributes.expired)return t}return e[0]}(a);r&&Ea(r)&&r.paymentAttributes.expired&&o.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.1",payload:{...qe(t,s,n),action:"final_payment_method_expired_after_merchant_filter"}});const d=r?$a(r,l.user.paymentMethods.value):void 0;if(d)l.session.selectPaymentMethod(d);else{const e=p?"unavailable":"explicit",s=l.session.clearPaymentMethod(e),n=l.user.creditCards.peek().length;s&&n>0&&i.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:t.checkoutSessionIdentifier,source_type:t.type,clear_reason:e,held_card_count:n,listed_method_count:W.length,valid_for_checkout_count:a.length,negotiated_direct_present:Boolean($)})}}),[e,X,Z,s,h,$,i,o,W,p,Q,n,l.session,l.user.creditCards,l.user.paymentMethods.value,t,J]);const ee=w.value,te=Boolean(I.value),ae=H instanceof os?H.autoselectTarget.value:void 0,se=H instanceof os?H.proposedSelectedPaymentMethod.value:void 0,ne=A.value[0],re=ne?.method.type,ie=ea(ne);return d((()=>{e&&("customerAccount"!==h&&"businessCustomer"!==h||ee||H instanceof os&&ae&&(te||ie||se&&se.paymentMethod===ae.paymentMethod&&se.id===ae.id||(re&&i.log("payment_method_manager_programmatic_selection_replaced_primary_line","Programmatic payment method selection replaced the proposed primary payment line",{replacedPaymentLineMethodT
2ype:re,replacingPaymentMethodType:ae.paymentMethod}),H.selectPaymentMethod(ae,"programmatic").catch((()=>{})))))}),[e,h,ee,te,H,ae,se,ie,re,i]),H}function Ms(){const{shop:e,checkout:t,observability:a}=Pe(),s=t.wallets.activeSession.value,n=t.latestReceipt.value,{persistedPayPalSignal:r}=Ae(),i="payPal"===t.identity.current.value,o=n?.id,l=G().value,c=void 0!==l,u=bt(),m=r.value,{negotiate:h}=z(),p=K(),y=D(new Set(gt))?.hasError&&o!==m?.receiptIdForClearedToken,f=H("PAYPAL_EXPRESS").value?.merchantId?.trim(),v=l?.method.walletContent?.merchantId?.trim(),C=e.hasFlagEnabled(_t)&&f&&v&&v!==f,b=m?.billingAgreementStatus&&Mt({checkout:t})&&"NOTREQUESTED"===m.billingAgreementStatus&&!l?.method.walletContent?.isVaultWithPurchaseOrder,g=!0===l?.method.walletContent?.isVaultWithPurchaseOrder&&0===u.value?.amount;d((()=>{c&&((y||C||b||g)&&(function(){let e;e=y?"SubmitForCompletion Error":C?"Gateway Mismatch":g?"Zero Payment Due":"Subscription Added",a.counter({name:"paypal_token_cleared",value:1,attributes:{clearReason:e}}),a.log("paypal_token_cleared","Clearing PayPal token due to error",{clearReason:e})}(),function(){const e={...r.value,receiptIdForClearedToken:y?o:void 0,newTokenRequiredDueToError:!0,billingAgreementStatus:void 0};r.value=e}()),(async()=>{(g||y&&!i&&!s)&&(p(),await h({silenceViolations:["non-stock"]}))})())}),[y,c,C,o,a,r,b,g,i,p,h,s])}function Ps(e){const t=Se().paymentMethods;return n((()=>{const a=e.value,s=Boolean(a?.balance?.amount),n=Boolean(t.value?.find((e=>"redeemable"===e.type&&"STORE_CREDIT"===e.redemptionSource)));return Boolean(s&&n)}))}var Ss=(e=>(e.Init="init",e.Loading="loading",e.Success="success",e.Error="error",e.Stale="stale",e))(Ss||{});function ks(e,t){return e.filter((e=>!ws(e,t)))}function As(e,t){return e.some((e=>ws(e,t)))}function Es({firstOrderTotal:e,storeCreditAccount:t,includeExhausted:a=!1}){if(!e||!t)return;if(e.currencyCode!==t.balance.currencyCode)return;const s=t.balance.amount-e.amount;return s<=0&&!a?void 0:{amount:Math.max(s,0),currencyCode:t.balance.currencyCode}}function ws(e,t){return Pt(e)&&e.method.redemptionContent&&"storeCreditAccountId"in e.method.redemptionContent&&e.method.redemptionContent.storeCreditAccountId===t.id}function Is(e){const t=Se().paymentLines;return n((()=>{const a=e.value;return!(!a||!t.value?.lines)&&As(t.value.lines,a)}))}function xs(){const{shop:{currencyCode:e}}=Pe(),t=Se().buyerIdentity;return n((()=>{const a=t.value,s=a?.presentmentCurrency||e;return("CustomerProfile"===a?.customerProfile?.__typename||"BusinessCustomerProfile"===a?.customerProfile?.__typename?a.customerProfile.storeCreditAccounts:[]).find((e=>e.balance.currencyCode===s))}))}function Ls(){const e=Se().paymentLines;return n((()=>e.value?.lines.filter((e=>Pt(e)))||[]))}function Ds({options:e,paymentMethodExtension:t}){const a=t[0]?.extension;if(!a)return null;const n=a.appId.split("/").pop(),r=n&&!da.includes(n);return s(Q,{options:e,customizations:t,transformComponents:r?Ns:void 0})}const Ns=W(new Set(["Image","Banner","s-image","s-banner"]));function Bs(){const e=Se().allViolations,t=n((()=>(e.value??[]).filter((e=>!!X(e)||!!St(e))))),a=n((()=>{const[e]=t.value;return e?e.localizedMessage||e.nonLocalizedMessage:null}));return s(i,{when:a,children:e=>s(Z,{tone:"critical",errorType:J.DiscountError,children:e})})}function Ts({amount:e,maskedIdentifier:t,remove:a}){const{i18n:n}=Pe(),r=n.formatCurrency(e.amount,{currency:e.currencyCode,form:"short"}),i=t.slice(-4).toUpperCase(),d=n.translate("payment.gift_card_wrapper.gift_card_label",{identifier:ee(i)}),o=n.translate("order_summary.gift_card_ending",{last_characters:i||""});return s(w,{borderRadius:"base",background:"base",border:"base",blockAlignment:"center",padding:"small-200",children:s(te,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1fr) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",children:[s(te,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-300",alignItems:"center",alignContent:"center",children:[s($t,{type:"gift-card"}),s(ae,{children:[s(se,{accessibilityVisibility:"hidden",children:d}),s(se,{accessibilityVisibility:"exclusive",children:o})]})]}),s(te,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-100",alignItems:"center",alignContent:"center",children:[s(se,{type:"strong",children:r}),s(ne,{onClick:()=>a(),accessibilityLabel:n.translate("general.remove_item",{label:o}),children:s(V,{type:"x",size:"small"})})]})]})})}const Fs="gift_card_option";function Vs({afterAppliedRedeemablesChange:e,autoSelect:t=!1,showHeading:a=!0}){const{i18n:n}=Pe(),{paymentMethod:r,paymentLines:i,submit:o,remove:u,removeAll:m}=re(),h=ie("Checkout::GiftCard::Render",r?.uiExtension?[r?.uiExtension]:[]),{value:p}=bt(),f=p?.amount||0,[v,C]=l([]),[b,g]=l(!1),_=0===f&&0===i?.length;d((()=>{_?C([]):(i?.length>0||t)&&C([Fs])}),[t,i?.length,_]);const M=c((async(t,a)=>{const s=await o(t,a);return"success"===s?.status&&(g(!1),e?.()),s}),[e,o]),P=y((()=>({paymentMethodIdentifier:r?.paymentMethodIdentifier??"",submitRedeemablePaymentLine:M})),[r?.paymentMethodIdentifier,M]),S=Boolean(i?.length)||Boolean(h.length)&&Boolean(r);return s(de,{id:"3p-gift-card-field",open:S,duration:"slow",children:s(I,{accessibilityLabel:n.translate("payment.gift_card_wrapper.heading"),children:s(R,{gap:"base",children:[a&&s(k,{level:2,children:n.translate("payment.gift_card_wrapper.heading")}),s(ra,{name:"gift_card_option_list",values:v,multiple:!0,onChange:async t=>{if(C(t),0===t.length&&i.length>0){const t=await m();"success"===t?.status&&e?.()}},variant:"block",children:s(ia,{value:Fs,disabled:_,selectedContent:s(R,{gap:"base",children:[i?.length>0?s(R,{gap:"small-300",children:i.map((t=>{const{cost:a,method:n}=t;if(!a||"CUSTOM"!==n.redemptionSource)return null;const r=n.redemptionContent?.redemptionAttributes.reduce(((e,t)=>`${e},${t.key}:${t.value}`),"");return s(Ts,{maskedIdentifier:n.redemptionContent?.maskedIdentifier||"",amount:{amount:a.amount,currencyCode:a.currencyCode},remove:async()=>{const t=await u(n);"success"===t?.status&&e?.()}},r)}))}
2):null,s(Bs,{}),(()=>{if(0===f||!h.length||!r)return null;const e=s(Ds,{paymentMethodExtension:h,options:P});return i&&0!==i.length?s(w,b?{children:[s(A,{blockSize:"small-500"}),s(R,{gap:"base",children:[s(k,{level:3,children:n.translate("payment.gift_card_wrapper.apply_another_gift_card_label")}),e]})]}:{children:[s(A,{blockSize:"small-500"}),s(N,{textDecoration:"none",onClick:()=>g(!0),children:s(R,{direction:"inline",alignItems:"center",gap:"small-400",children:[s(V,{type:"plus"}),s(se,{children:n.translate("payment.gift_card_wrapper.apply_another_gift_card_label")})]})})]}):e})()]}),children:n.translate("payment.gift_card_wrapper.apply_gift_card_label")})})]})})})}const Rs="StoreCreditRedemptionCheckbox",Us="StoreCreditSubscriptionRenewalsCheckbox";function Os(e,t){return Pt(e)&&e.method.redemptionContent&&"storeCreditAccountId"in e.method.redemptionContent&&e.method.redemptionContent.storeCreditAccountId===t.id}function $s({amountDueAtCheckout:e,storeCreditAccount:t}){if(Ys({amountDueAtCheckout:e,storeCreditAccount:t})&&null!=e)return{amount:Math.min(e.amount,t.balance.amount),currencyCode:e.currencyCode}}function Ys({amountDueAtCheckout:e,storeCreditAccount:t}){return null==e||e.currencyCode===t.balance.currencyCode}function qs({paymentLines:e,storeCreditAccount:t,cost:a}){let s=!1;const n=e.map((e=>{if(!Os(e,t))return e;if(null==a){if(null==e.cost)return e;const{cost:t,...a}=e;return s=!0,a}return e.cost?.amount===a.amount&&e.cost.currencyCode===a.currencyCode?e:(s=!0,{...e,cost:a})}));return s?n:e}function js(e,t,a){if("success"!==e.status&&"error"!==e.status)return!1;const s=e.negotiated?.paymentLines?.lines;return null==s?"success"===e.status:As(s,t)===a}function Gs(e){const{negotiate:t}=z();return c((async()=>new Promise((a=>{t({include:["paymentLines"],fieldsToResolve:["paymentLines"],silenceViolations:["non-store-credit"],runListenersOnError:!0,force:!0,onComplete(t){e.value="success"===t.status?Ss.Success:Ss.Error,a(t)}})}))),[t,e])}function zs(e,t){const a=ke(),s=Gs(t);return c((async()=>{if(!e)return t.value=Ss.Error,{result:null,landed:!1};t.value=Ss.Loading;const n=a.paymentLines.value,r=n.findIndex((t=>Os(t,e))),i=n[r];a.paymentLines.value=ks(n,e);const d=await s(),o=js(d,e,!1);if(i&&!o){const t=ks(a.paymentLines.value,e);a.paymentLines.value=[...t.slice(0,r),i,...t.slice(r)]}return{result:d,landed:o}}),[e,t,a.paymentLines,s])}function Ks(e,t){const{i18n:a,shop:s}=Pe(),n=ke(),r=Gs(t),i=Se().paymentLines,d=bt(),o=kt(),l=vt(),u=At(),m=Se().paymentFlexibilityPaymentTermsTemplate,h=Et(s),p=Se().isImmediateAmountReducedForRedeemables,y=c((()=>h&&wt({hasSellingPlan:l.value,hasFixedSellingPlan:u.value,paymentTermsTemplateType:m.value?.type})),[h,l,u,m]),f=v(!1);return C((()=>{if(!y())return;const t=d.value??o.value,a=n.paymentLines.value;if(!e||!f.current)return;const s=i.value?.lines.find((t=>Os(t,e)))?.cost;if(p?.value){if(s){const t=qs({paymentLines:a,storeCreditAccount:e,cost:s});t!==a&&(n.paymentLines.value=t)}return}if(s&&s.amount>0)return void(f.current=!1);const r=qs({paymentLines:a,storeCreditAccount:e,cost:$s({amountDueAtCheckout:t,storeCreditAccount:e})});r!==a&&(n.paymentLines.value=r)})),c((async()=>{if(!e)return t.value=Ss.Error,{result:null,landed:!1};t.value=Ss.Loading;const s=ks(n.paymentLines.value,e),i=d.value??o.value,l=y(),c=l?$s({amountDueAtCheckout:i,storeCreditAccount:e}):void 0;if(f.current=null!=c,l&&!Ys({amountDueAtCheckout:i,storeCreditAccount:e}))return t.value=Ss.Error,oe({content:a.translate("store_credit_errors.generic_error")}),{result:null,landed:!1};n.paymentLines.value=[...s,{method:{type:"redeemable",redemptionSource:"STORE_CREDIT",redemptionContent:{storeCreditAccountId:e.id}},...c&&{cost:c}}];const u=await r();if(!js(u,e,!0))return f.current=!1,n.paymentLines.value=ks(n.paymentLines.value,e),{result:u,landed:!1};const m=l&&function(e,t){if("success"===e.status||"error"===e.status)return e.negotiated?.paymentLines?.lines.find((e=>Os(e,t)))?.cost}(u,e);return m&&m.amount>0&&(f.current=!1,n.paymentLines.value=function({paymentLines:e,storeCreditAccount:t,cost:a}){return e.map((e=>Os(e,t)?{...e,cost:a}:e))}({paymentLines:n.paymentLines.value,storeCreditAccount:e,cost:m})),{result:u,landed:!0}}),[o,r,d,n.paymentLines,t,y,e,a])}function Hs({afterAppliedRedeemablesChange:e}){const{i18n:t,shop:a,webMcp:r}=Pe(),o=a.hasFlagEnabled(It),l=bt(),u=ke(),m=Lt(),h=At(),p=xs(),y=Is(p),f=b(Ss.Init),v=Ps(p),_=function(e){const{shop:t}=Pe(),a=t.hasFlagEnabled(It),s=kt(),r=xt();return n((()=>
2{if(r.value)return Es({firstOrderTotal:s.value,storeCreditAccount:e.value,includeExhausted:a})}))}(p),M=n((()=>o&&null!=_.value)),P=n((()=>m.value||h.value)),S=n((()=>m.value?t.translate("payment.store_credit.buying_gift_card"):h.value?t.translate("payment.store_credit.no_fixed_selling_plans"):void 0));C((()=>{(!v.value||!M.value||P.value)&&g((()=>{u.useStoreCreditForSubscriptionRenewals.value&&(u.useStoreCreditForSubscriptionRenewals.value=!1)}))}));const k=Ks(p.value,f),A=zs(p.value,f),E=n((()=>f.value===Ss.Loading)),w=n((()=>E.value||P.value)),x=n((()=>w.value||0===l.value?.amount&&!y.value)),L=w,D=n((()=>{const e=[],t=M.value&&u.useStoreCreditForSubscriptionRenewals.value;return(y.value||t)&&e.push(Rs),t&&e.push(Us),e})),N=c((async t=>{const a=y.peek(),s=t.includes(Rs),n=o&&!(a&&!s)&&t.includes(Us),r=s||n,i=u.useStoreCreditForSubscriptionRenewals.peek();if(u.useStoreCreditForSubscriptionRenewals.value=n,r!==a){const{landed:t}=r?await k():await A();if(!t)return void(u.useStoreCreditForSubscriptionRenewals.value=!r&&i);e?.()}}),[k,A,y,u.useStoreCreditForSubscriptionRenewals,o,e]),B=n((()=>v.value&&Boolean(p.value))),T=n((()=>D.value.includes(Rs))),F=c((e=>N(e?[...new Set([...D.peek(),Rs])]:[])),[D,N]);d((()=>r?.unstable_provideStoreCreditController({available:B,redeeming:T,applied:y,settling:E,hasGiftCard:m,hasFixedSellingPlan:h,paymentDue:l,setRedeeming:F})),[r,B,T,y,E,m,h,l,F]);const V=p.value;if(!B.value||!V)return null;const U=M.value?_.value:void 0,O=V.balance,$=S.value,Y=U&&U.amount>0?t.translate("payment.store_credit.remaining_for_subscription_charges_description",{amount:t.formatCurrency(U.amount,{currency:U.currencyCode})}):void 0;return s(I,{accessibilityLabel:t.translate("payment.store_credit.label"),children:s(ra,{name:"store_credit_redemption",values:D.value,multiple:!0,onChange:N,variant:"block",children:[s(ia,{value:Rs,disabled:x.value,secondaryContent:s(se,{type:"strong",children:t.formatCurrency(O.amount,{currency:O.currencyCode})}),details:$&&s(se,{children:$}),children:s(R,{direction:"inline",gap:"base",alignItems:"center",children:[s(se,{children:t.translate("payment.store_credit.apply_label")}),s(i,{when:E,children:s(le,{})})]})}),U&&s(ia,{value:Us,disabled:L.value,details:(Y||$)&&s(R,{gap:"small-500",children:[Y&&s(se,{children:Y}),$&&s(se,{children:$})]}),children:s(se,{children:t.translate("payment.store_credit.use_remaining_for_subscription_charges_label")})})]})})}function Qs(){const{i18n:e}=Pe(),{hasViolations:t}=ce(Dt);return t?s(Z,{errorType:J.PaymentError,tone:"critical",children:e.translate("store_credit_errors.generic_error")}):null}function Ws({name:e,digits:t,icon:a}){return s(R,{className:"YVGTZ",direction:"inline",columnGap:"none",rowGap:"small-200",alignItems:"center",inlineSize:"100%",children:[s("span",{className:"zyVks",children:s(ae,{children:e})}),s("span",{className:"U4h7p",children:t}),a]})}const Xs=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 Zs(e){return e?e.nickname&&e.nickname.trim().length>0?e.nickname:e.bank&&e.bank.trim().length>0?e.bank:function(e){const t=Xs.get(e.toLowerCase());if(t)return t;const a=e.toUpperCase();return Nt(a)?Bt(a):e}(e.brand):""}function Js(){const{paymentLines:e}=ke();return n((()=>sa(e.value)))}function en({isSelected:e,hasMsiPlan:t,isStale:a,binPrefix:s,canEditBin:n,supportedInstallmentsCount:r,isNegotiating:i}){if(!e||!t&&!a)return"hidden";if(s){if(s.length<8&&n)return"prompt"}else{if(n)return"prompt";if(0===r)return"hidden"}return i||a?"loading":"dropdown"}function tn({id:e,variant:t}){const{i18n:a}=Pe(),n="prompt"===t?a.translate("msi_installments.enter_card_details_prompt"):a.translate("msi_installments.loading_installments");return d((()=>{if("loading"===t)return oe({content:n})}),[n,t]),s(pe,{id:e,name:"msiInstallments",label:a.translate("msi_installments.payment_plan_label"),value:t,disabled:"loading"===t,onChange:()=>{},children:s(he,{value:t,children:n})})}function an({paymentMethod:e,isSelected:t,canEditBin:a=!0,isVaultedContext:n=!1,id:r="msiInstallmentsSelect"}){const{bankIdNumberSignal:i,installmentMonthsSignal:o,lastNegotiatedBinSignal:l}=Ze(),{paymentLines:c}=ke(),u=Js();d((()=>{o.value=u.value}),[u.value,o]);const m=a&&!n,h=e.installmentPlans?.find((e=>"MSI"===e.type)),p=h?.supportedInstallments??[],y=Tt(i.value),f=!n&&void 0!==y&&void 0!==l.value&&y!==l.value;d((()=>{u.value&&(!t||!h||!y&&!m&&0===p.length)&&(c.value=me(c.value,void 0))}),[u.value,t,h,y,m,p.length,c]);const v=en({isSelected:Boolean(t),hasMsiPlan:Boolean(h),isStale:f,binPrefix:y,canEditBin:m,supportedInstallmentsCount:p.length,isNegotiating:!1});return"hidden"===v?null:s(tn,"prompt"===v?{id:r,variant:"prompt"}:{id:r,variant:"loading"})}const sn=a({displayName:"MsiInstallmentsSelect",useError:ue("MsiInstallmentsSelect"),load:()=>_((async()=>({default:(await e((async()=>{const{MsiInstallmentsSelect:e}=await import("./82de4790.Dxwxuk9y.js");return{MsiInstallmentsSelect:e}}),__vite__mapDeps([24,1,11,2,3,4,5,12,9,13,14,15,7,25,26,27,28,29,17,18,30,31,32,33,34,35,36,37,38,39,40]))).MsiInstallmentsSelect}))),renderLoading:e=>s(an,{...e})}),nn=new Map,rn=class e{constructor(e=[],t=[],a,s=!1){this.sdkQueue=e,this.initQueue=t,this.sdk=a,this.scriptLoaded=s,this.setupGeneration=0,this.currentSetupId=0}async load(e){let t=nn.get(e.source);t instanceof Promise||(t=ye(e,!0),nn.set(e.source,t)),await t;const a=this.initQueue.pop();a?.(),this.initQueue=[],this.scriptLoaded=!0}async setup(t,a,s){return on((()=>
2{if(this.sdk)return;if(this.setupPromise&&this.setupForm===t)return this.setupPromise;const n=window.CardFields;if(!n)throw new fe("Attempted to init Cardfields before it is ready");const r=++this.currentSetupId;return this.setupForm=t,s(),this.setupPromise=(async()=>{try{for(let s=0;s<e.MAX_SETUP_ATTEMPTS;s++){const e=this.setupGeneration,s=await n.setup(t,a);if(r!==this.currentSetupId){try{s.teardown()}catch{}return}if(e===this.setupGeneration){this.sdk=s;for(const e of this.sdkQueue)await e();return void(this.sdkQueue=[])}try{s.teardown()}catch{}}throw new ve(`CardFields setup failed: ${e.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,t,a){return this.scheduleSDK((s=>a?s.on(a,e,t):s.on(e,t)))}off(e,t,a){return this.scheduleSDK((s=>a?s.off(a,e,t):s.off(e,t)))}setStyles({field:e,styles:t}){return e?this.scheduleSDK((a=>a.setStyles(e,t))):this.scheduleSDK((e=>e.setStyles(t)))}setFocus(e){return this.scheduleSDK((t=>t.setFocus(e)))}setTranslation(e,t){return this.scheduleSDK((a=>a.setTranslation(e,t)))}setPlaceholderContent(e,t){return this.scheduleSDK((a=>a.setPlaceholderContent(e,t)))}setValue(e,t){return this.scheduleSDK((a=>a.setValue(e,t)))}setTooltip(e,t){return this.scheduleSDK((a=>a.setTooltip(e,t)))}vaultCard(e){return this.scheduleSDK((t=>t.vaultCard(e)))}vaultCardMultipleTimes(e,t){return this.scheduleSDK((a=>a.vaultCardMultipleTimes(e,t)))}setErrors(e){return this.scheduleSDK((t=>t.setErrors(e)))}clearField(e){return this.scheduleSDK((t=>t.clearField(e)))}loadFonts(e){return this.scheduleSDK((t=>t.loadFonts(e)))}getFieldFrame(e){return this.scheduleSDK((t=>t._getFieldFrame(e)))}scheduleSDK(e){return on((()=>{if(!this.sdk)throw new ve("The CardFields SDK has not been set up.");return e(this.sdk)}),Boolean(this.sdk),this.sdkQueue)}};rn.MAX_SETUP_ATTEMPTS=3;let dn=rn;function on(e,t,a){if(t){const t=e();return t instanceof Promise?t:new Promise((e=>{e(t)}))}return new Promise(((t,s)=>{a.push((async()=>{try{const a=e();t(a instanceof Promise?await a:a)}catch(a){s(a)}}))}))}const ln=P(void 0),cn={name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1};function un({children:e,value:t,sdkScriptAttributes:a,blurValidationEnabled:n=!0,blurValidationFieldDenylist:r,onError:i,onSetFieldErrors:o,onLoadSuccess:u}){const m=y((()=>new dn),[]),[h,p]=l(!0),[f,C]=l({name:null,number:null,verification_value:null,expiry:null,issue_date:null,issue_number:null,sdk:null}),b=v(),[g,_]=l(),[P,S]=l(),[k,A]=l({name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1}),[E,w]=l(""),[I,x]=l([]),[L,D]=l(cn),N=v(L);d((()=>{N.current=L}),[L]);const B=v(),T=c((e=>{b.current=e instanceof Ce?e.diagnostics:void 0,C({sdk:e.message}),i?.(e),p(!1)}),[i,C,p]),F=c((async e=>{try{return await e()}catch(t){if(t instanceof Error){let e=null;if(t.name===be.name)e=new be(t.message);else if(t.name===ge.name){const a="httpStatus"in t&&"number"==typeof t.httpStatus?t.httpStatus:void 0;e=new ge(t.message,a)}else t.name===_e.hostedFieldsName&&(e=new _e(t.message));if(e)return T(e),"";T(t)}throw t}}),[T]),V=c((async(e,t={propagateErrors:!0})=>{const{sdk:a,...s}=e;await F((()=>m.setErrors(s))),C((a=>{const s={...a,...e};return t.propagateErrors&&o?.(s),s}))}),[m,o,F]),R=c(((e,t)=>{const a={},s=B.current;t?(e||(!k?.expiry&&t.includes("expiry")&&(a.expiry=s?.expiry),!k?.number&&t.includes("number")&&(a.number=s?.number_blank),!k?.name&&t.includes("name")&&(a.name=s?.name)),!e&&!t.includes("verification_value")||k?.verification_value||(a.verification_value=s?.verification_value)):(e||(k?.expiry||(a.expiry=s?.expiry),k?.number||(a.number=s?.number_blank),k?.name||(a.name=s?.name)),k?.verification_value||(a.verification_value=s?.verification_value));const n={...f,...a};return V(n),{isValid:!Object.values(n).some(Boolean)}}),[f,k?.expiry,k?.name,k?.number,k?.verification_value,V]);d((()=>{!async function(){try{if(!a)throw new fe("Provider: hostedFieldsUrl must be provided");await m.load(a)}catch(e){e instanceof Error&&T(e)}}()}),[a,m,T]);const U=c((({cardType:e,bin:t,networks:a})=>{_(e),w(t),x(a)}),[]),O=c((({targetName:e})=>{S(e)}),[]),$=c((async e=>{const{isValueValid:t,targetName:a,isValueEmpty:s}=e,i=B.current,d=N.current[a],o=Boolean(r?.has(a));if(n&&!o&&i&&d){const e={[a]:t?null:i[a]};"number"===a&&s&&(e[a]=i.number_blank),await V(e,{propagateErrors:!1})}S(void 0)}),[V,n,r]),Y=c((async e=>{const{targetName:t,isValueEmpty:a,isTab:s}=e;if(!s){A((e=>({...e,[t]:!a}))),D((e=>({...e,[t]:!0})));const e={[t]:null};await V(e)}}),[V]),q=c((e=>{A((t=>({...t,[e]:!0})))}),[]),j=function(){const e=v(!0);return M((()=>()=>{e.current=!1}),[]),e}(),G=c((()=>{j.current&&(A({name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1}),x([]))}),[A,j]),z=c((()=>{F((()=>m.on("cardtype",U))),F((()=>m.on("focus",O))),F((()=>m.on("blur",$))),F((()=>m.on("keyup",Y))),F((()=>m.on("change",Y))),F((()=>m.on("input",Y)))}),[F,m,U,O,$,Y]),K=c((()=>{F((()=>m.off("cardtype",U))),F((()=>m.off("focus",O))),F((()=>m.off("blur",$))),F((()=>m.off("keyup",Y))),F((()=>m.off("change",Y))),F((()=>m.off("input",Y)))}),[F,m,U,O,$,Y]),H=c((()=>{D(cn)}),[]),Q=y((()=>({loadFonts:e=>F((()=>m.loadFonts(e))),setErrors:e=>V(e,{propagateErrors:!1}),setStyles:(...e)=>F((()=>m.setStyles(...e))),setFocus:(...e)=>F((()=>m.setFocus(...e))),setTooltip:(...e)=>F((()=>m.setTooltip(...e))),setTranslation:(...e)=>F((()=>m.setTranslation(...e))),setPlaceholderContent:(...e)=>F((()=>m.setPlaceholderContent(...e))),setValue:(e,t)=>
2F((()=>("string"==typeof t&&t.trim().length>0&&A((t=>({...t,[e]:!0}))),m.setValue(e,t)))),setup:async(e,t,a=()=>{})=>{p(!0),await F((()=>m.setup(e,t,a))),u?.(),p(!1),B.current=t.errorMessages},teardown:()=>F((()=>m.teardown())),clearField:e=>F((()=>(A((t=>({...t,[e]:!1}))),m.clearField(e)))),vaultCard:(...e)=>F((()=>m.vaultCard(...e))),vaultCardMultipleTimes:(e,t)=>F((()=>m.vaultCardMultipleTimes(e,t))),getCardField:e=>m.getFieldFrame(e)})),[m,V,F,u]);d((()=>()=>{o?.({})}),[o]);const W=y((()=>t??{sdk:Q,errors:f,sdkLoadDiagnostics:b.current,cardBrand:g,bankIdNumber:E,networks:I,focusedField:P,filled:k,loading:h,validate:R,subscribe:z,unsubscribe:K,resetTouched:H,emptyFields:G,setFilled:q,touched:L}),[Q,g,E,I,f,k,P,h,t,R,z,K,H,G,q,L]);return s(ln.Provider,{value:W,children:e})}const mn=()=>{const e=f(ln);if(null==e)throw new fe("No cardfields found in context");return e},hn=e=>e.toUpperCase(),pn=e=>e.toLowerCase();function yn(e){return Boolean(e?.some((e=>"direct"===e.type&&e.paymentBrands.includes("BOGUS"))))}function fn({paymentMethods:e,hasBogusGateway:t=yn(e),paymentLines:a,storeVaultGuestCvvVerificationEnabled:s=!1,selectedCardRequiresProposalLineCvv:n=!1,selectedCardBrand:r,hasAmexCvvOnlyField:i=vn({paymentLines:a,storeVaultGuestCvvVerificationEnabled:s,selectedCardRequiresProposalLineCvv:n,selectedCardBrand:r})}){return t?new Set(["number"]):i?new Set(["verification_value"]):new Set}function vn({paymentLines:e,storeVaultGuestCvvVerificationEnabled:t=!1,selectedCardRequiresProposalLineCvv:a=!1,selectedCardBrand:s}){return Boolean(a&&"AMEX"===s?.toUpperCase()||t&&e?.some((({method:e})=>e.type===ct.CreditCard&&"AMEX"===e.brand)))}function Cn(e){return e.replace(/([\d.]+)rem/g,((e,t)=>10*Number(t)/14+"rem"))}function bn(){const{paymentMethods:e}=Se();return n((()=>{const t=e.value?.filter((e=>e.type===ct.CreditCard&&Boolean(e.expired)));return t?t.length:0}))}function gn(){const{i18n:e}=Pe();return{getAccessibilityLabel:t=>{const a="direct"===t.type?t.creditCardLastFourDigits:t.displayLastDigits;return`${Bt(t.brand)} ${e.translate("payment.saved_credit_card_info")} ${a}`}}}function _n(e){return e?e.map((e=>hn(e))):[]}const Mn=Ft("CreditCardNetworkContext");function Pn({children:e,paymentMethod:t,publishesCardNetworkDetection:a=!1}){const{checkout:n,source:r,observability:i,userEvents:o}=Pe(),u=S(),m=t?Ue(t):u,h=n.cardNetworkSelection.forMethod(m),{bankIdNumber:p,touched:f,...v}=mn(),{networks:C,sdk:b,filled:g}=v,_=y((()=>_n(C)),[C]),M=p?.replace(/\s/g,"").length??0,P=M>=6&&v.cardBrand?hn(v.cardBrand):void 0,k=y((()=>_.filter((e=>t?.paymentBrands.includes(e)))),[_,t]),A=Boolean(t?.supportsNetworkSelection);d((()=>{a&&h.setDetectedState({networkSelectionEnabled:A,availableNetworks:k,cardBrand:P,numberFilled:Boolean(g.number),bankIdNumberLength:M})}),[a,h,A,k,P,g.number,M]);const E=h.selectableBrands.value;!function({displayName:e,paymentBrands:t,paymentMethodIdentifier:a,selectableBrands:s,networkSelectionSupported:n}){const{bankIdNumber:r,networks:i,cardBrand:o}=mn(),{userEvents:c,source:{checkoutSessionIdentifier:u}}=Pe(),[m,h]=l(!1),[p,f]=l(""),v=y((()=>_n(i||(o&&(r?.length??0)>=6?[o]:void 0))),[i,o,r]);d((()=>{if(!r||0===r.length||!u)return;const i={checkoutToken:u,paymentMethodIdentifier:a,displayName:e||"",supportedBrands:t.join(","),detectedBrands:v.join(","),cardIsCobadged:v.length>1,shownBrands:s.join(","),networkSelectorShown:s.length>1&&n};m||(c.monorailEvent({schemaId:"checkout_credit_card_number_interaction/1.1",payload:{...i,eventName:"first_digit_entered"}}),h(!0)),r.length>=6&&v.length>0&&i.shownBrands!==p&&(f(i.shownBrands),c.monorailEvent({schemaId:"checkout_credit_card_number_interaction/1.1",payload:{...i,eventName:"brand_shown_to_buyer"}}))}),[a,e,t,v,s,r,c,u,n,p,m,h])}({displayName:t?.name,paymentBrands:t?.paymentBrands??[],paymentMethodIdentifier:t?.paymentMethodIdentifier??"",selectableBrands:E,networkSelectionSupported:t?.supportsNetworkSelection??!1});const w=c((e=>{const t=h.selectedSavedCreditCardBrand.value,a="function"==typeof e?e(t):e;h.setSelectedSavedCreditCardBrand(a)}),[h]),I=c((async()=>{const e=h.selectedNetwork.value,t=e?{selected_network:pn(e)}:void 0,a=await b.vaultCard(t);return kn(o,{checkoutSessionIdentifier:r.checkoutSessionIdentifier??"",selectedNetwork:t?.selected_network,detectedNetworks:C}),a||i.log("credit_card_network_context_no_session_id_returned","No session id returned when vaulting card with selected network",{selectedNetwork:t?.selected_network}),a}),[h,b,r,C,i,o]),x=c((async e=>{const t=h.selectedNetwork.value,a=t?{selected_network:pn(t)}:void 0,s=await b.vaultCardMultipleTimes(e,a);return kn(o,{checkoutSessionIdentifier:r.checkoutSessionIdentifier??"",selectedNetwork:a?.selected_network,detectedNetworks:C}),s}),[h,b,o,r,C]),L=y((()=>({activePaymentBrand:h.activeBrand.value,binLength:h.bankIdNumberLength.value,paymentMethod:t,detectedNetworks:_,selectableBrands:E,selectedNetwork:h.selectedNetwork.value,selectedSavedCreditCardBrand:h.selectedSavedCreditCardBrand.value,setSelectedNetwork:h.setSelectedNetwork,setSelectedSavedCreditCardBrand:w,vaultCardWithSelectedNetwork:I,vaultCardMultipleTimesWithSelectedNetwork:x})),[h.activeBrand.value,h.bankIdNumberLength.value,h.setSelectedNetwork,h.selectedNetwork.value,h.selectedSavedCreditCardBrand.value,t,_,E,w,I,x]);return s(Mn.Provider,{value:L,children:e})}function Sn(){return Vt(Mn)}function kn(e,{checkoutSessionIdentifier:t,selectedNetwork:a,detectedNetworks:s}){a&&e.monorailEvent({schemaId:"checkout_credit_card_network_selection/1.0",payload:{checkoutToken:t,selectedNetwork:a,supportedNetworks:s?.join(",")??""}})}const An=["CardFieldsFetchFailureError"];function En({children:e,publishesCardNetworkDetection:t,directPaymentMethodConfig:a,...n}){const r=v(Me()),{value:i}=Se().paymentMethods,d=a??We(i??[]),{observability:o}=Pe(),l=c((e=>{An.includes(e.name)?o.log("default_card_fields_provider_unactionable_error","Unactionable error in card fields provider",{error:e}):o.error(e)}),[o]);return s(un,{...n,onError:l,sdkScriptAttributes:r.current,children:s(Pn,{paymentMethod:d,publishesCardNetworkDetection:t,children:e})})}function wn(e){const{shopPay:t}=Pe(),{value:a}=Se().paymentMethods,{paymentLines:n}=ke(),{bankIdNumberSignal:r,installmentMonthsSignal:i}=Ze(),{binResolution:o,clearInstallments:l,selectedCardBin:c,expandedVisible:u,collapsedVisible:m}=e.msi,h=u.value,p=m.value,y="server"===o?e.selectedCreditCard.value?.id:void 0;!function({enabled:e,selectedCardId:t}){const{checkout:{identity:a}}=Pe(),{paymentLines:s}=ke(),{negotiate:n}=z(),r=aa(),i=v(void 0);d((()=>
2{if("shopPay"!==a.current.value)return;if(!e||!t)return i.current=void 0,void(s.value=Rt(s.value));if(i.current===t)return;i.current=t;const d=Ge(s.value,"SHOP_PAY"),o=d?.method.walletContent?.creditCardInstallments;s.value=Ut(s.value,r({msiEligibleCard:!0,creditCardInstallments:o})),n({include:[]}).catch((()=>{i.current=void 0}))}),[e,a.current.value,t])}({enabled:p&&!t.session.isLoading.value,selectedCardId:y});const f=v(h);d((()=>{f.current&&!h&&(n.value=l(n.value),i.value=void 0),f.current=h}),[h,l,n,i]);const C=v(p);d((()=>{C.current&&!p&&(n.value=l(n.value),i.value=void 0),C.current=p}),[p,l,n,i]);const b=c.value,g=e.selectedCreditCard.value?.id;d((()=>{if("client"!==o)return;const e=r.peek();r.value=g===dt&&oa(e,b)?e:b}),[o,r,b,g]);const _=We(a??[]);var M;return{expandedSlot:_&&h?In({paymentMethod:_,binResolution:o,id:"msiInstallmentsSelect-expanded"}):void 0,collapsedSlot:_&&p?(M=In({paymentMethod:_,binResolution:o,id:"msiInstallmentsSelect-summary"}),s(w,{paddingInlineStart:"large-100",children:s(En,{onSetFieldErrors:()=>{},children:M})})):void 0}}function In({paymentMethod:e,binResolution:t,id:a}){return s(sn,"server"===t?{paymentMethod:e,isSelected:!0,isVaultedContext:!0,id:a}:{paymentMethod:e,isSelected:!0,canEditBin:!1,id:a})}function xn(e,t,a){return!!e&&(0===a.size||[...t].some((e=>!a.has(e.code))))}export{Ks as $,Ta as A,Sn as B,Xa as C,En as D,vn as E,hn as F,Vs as G,Cn as H,gn as I,za as J,Ga as K,as as L,sn as M,ba as N,ss as O,Ds as P,ns as Q,bn as R,Qs as S,ua as T,_a as U,Ws as V,fa as W,ha as X,Is as Y,Es as Z,Ss as _,Js as a,zs as a0,Rs as a1,Us as a2,va as a3,ja as a4,xs as b,Ps as c,Ls as d,Hs as e,_s as f,en as g,wn as h,la as i,fn as j,Aa as k,yn as l,mn as m,Zs as n,Ea as o,Na as p,La as q,Da as r,Ba as s,xn as t,Ms as u,wa as v,Va as w,Ia as x,xa as y,Fa 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.