const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["c0b4c58b.BDy-OuP4.js","2c1ab0fe.Dbn2KvkT.js","4b4bc88f.z1yoAwwH.js","app.CooG55fE.js","assets/app.CcGlIMpn.css","assets/wallet-prefilled-guest-return.BZwmSkmD.css","633ac094.BZgMP64u.js","24fcbaf6.B9Of6sC3.js","ca3e798e.BBho0lps.js","e77d135d.Dz0RetrO.js","3d539943.CHiZMBrZ.js","e03065ab.CTM9K0Hk.js","60a453ce.B80X1bY8.js","ca5e9c49.C4Dgo0WK.js","164ad2e3.FTBuhkTQ.js","69fae6d4.DwAzRqQZ.js","f67abd2c.nPTvXZJz.js","e12db40c.DF32J314.js","9dba8418.NidtnoQ4.js","assets/hydrate.noyuxvQL.css","5ef0d995.Br8DuiXF.js","82de4790.CpqHWkqk.js","ac5a19ff.la4o1mqh.js","598fef4e.CSEeJ9se.js","assets/PaymentIcon.gzvCNwz_.css","e77f7fe0.ByPUY0fc.js","22345fd4.DfRWVvfi.js","4b1c22b7.Tf9Z0cR8.js","assets/PaymentLine.DT05kVlY.css","a422df8c.Cf87EYCO.js","efa0389a.BBF5Yj3v.js","assets/Choice.CrYuHUmO.css","assets/EmptyState.BEvzDDvy.css","cc6ff67d.CxMx1fOJ.js","08a3b809.Ce8w6gv6.js","d25d1b95.DYvnxyL-.js","bf513f9c.B3u9Jber.js","e39bc11c.CPXDRKy_.js","7a8217fd.qHfhLK3T.js","c6b02d73.Ba1sudbg.js","assets/useShopPayProgressIntercepts.CIy8uDiZ.css","bfe75f31.CeEm_sIx.js","6a7f8a66.gvBR5eQy.js","33d2e4fc.2Yl3W9KZ.js","assets/NumberField.CRpcZnVJ.css","dae24aab.CVNnVl1k.js","assets/Tips.CxDIiA6F.css"])))=>i.map(i=>d[i]); import{_ as e,S as t}from"./app.CooG55fE.js";import{j as a,m as s,u as r,D as n,M as i,O as o,G as d,t as l,y as c,z as u,$ as m,n as h,v as p,E as y,h as f,F as v,T as b,q as C,p as g,N as _,k as M,i as P,am as S}from"./2c1ab0fe.Dbn2KvkT.js";import{aY as k,s as A,bS as w,L as E,fM as I,t as x,fI as D,a7 as L,d as N,S as B,f as T,gI as F,J as V,d$ as R,gJ as U,cP as O,gK as $,ad as Y,w as q,aq as j,fr as z,U as G,gL as K,gM as H,af as Q,ag as W,gN as X,Z as J,c5 as Z,k as ee,aV as te,b as ae,ds as se,bB as re,gO as ne,j as ie,H as oe,b1 as de,G as le,c as ce,bL as ue,bM as me,e$ as he,bW as pe,bX as ye,bY as fe,gP as ve,gQ as be,gR as Ce,gS as ge,gT as _e,gU as Me,gV as Pe,gW as Se,aJ as ke}from"./164ad2e3.FTBuhkTQ.js";import{d as Ae,a4 as we,cJ as Ee,W as Ie,dw as xe,fU as De,fN as Le,bS as Ne,hd as Be,he as Te,bW as Fe,hf as Ve,bv as Re,hg as Ue,hh as Oe,bI as $e,cI as Ye,hi as qe,bC as je,aK as ze,fJ as Ge,N as Ke,h8 as He,hj as Qe,h7 as We,fD as Xe,h9 as Je,Q as Ze,aF as et,gF as tt,hk as at,a2 as st,w as rt,c as nt,aa as it,hl as ot,h6 as dt,hm as lt,hn as ct,I as ut,ho as mt,hp as ht,hq as pt,hr as yt,dR as ft,bF as vt,a6 as bt,bg as Ct,aL as gt,hs as _t,ht as Mt,aR as Pt,hu as St,hv as kt,hw as At,hx as wt,aO as Et,hy as It,_ as xt,hz as Dt,hA as Lt,hB as Nt,hC as Bt,dN as Tt,dO as Ft,bq as Vt,al as Rt,u as Ut,hD as Ot,c$ as $t,br as Yt}from"./4b4bc88f.z1yoAwwH.js";import{u as qt,g as jt}from"./ac5a19ff.la4o1mqh.js";import{P as zt}from"./598fef4e.CSEeJ9se.js";import{a as Gt}from"./e77f7fe0.ByPUY0fc.js";import{b as Kt,E as Ht}from"./a422df8c.Cf87EYCO.js";import{a as Qt,c as Wt,b as Xt,u as Jt}from"./cc6ff67d.CxMx1fOJ.js";import{S as Zt,u as ea}from"./bf513f9c.B3u9Jber.js";import{s as ta,n as aa}from"./e39bc11c.CPXDRKy_.js";import{a as sa,i as ra,S as na,d as ia}from"./7a8217fd.qHfhLK3T.js";import{s as oa}from"./bfe75f31.CeEm_sIx.js";import{a as da,b as la}from"./efa0389a.BBF5Yj3v.js";import{s as ca}from"./d25d1b95.DYvnxyL-.js";const ua=a({displayName:"PostPurchaseShouldRender",suspense:!1,load:()=>e(()=>import("./c0b4c58b.BDy-OuP4.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]))}),ma=x("AmazonPayChangePaymentLinkButton");function ha(){const{i18n:e,observability:t}=Ae(),{inMemoryAmazonPayParts:{sdkStatus:a}}=we(),i=s(()=>{const e=a.value;return e.status===k.Available?e.sdk:void 0}),o=qt(),d=A(void 0,ma),{hasError:l}=w(Ee),c=e.translate("vaulted.change_button");return o.value?r(n,{when:i,children:e=>r(E,{onClick:()=>{t.counter({name:"wallet_change_link_clicked",value:1,attributes:{wallet:Ie.AmazonPay,link:"payment_method"}});try{const{checkout_session_id:t}=I(o.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:d,children:c})}):null}class 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}=D(),s=e?.toLowerCase().replace(/\s+/g,"_")??"",n=ya.get(s)??"generic";return r(B,{direction:"inline",children:[a&&r(i,{children:[r(L,{tone:"critical",type:"alert-circle"}),r(N,{display:"inline",inlineSize:"small-400"})]}),r(Gt,{icon:r(zt,{type:n}),details:t})]})}function va(){const{i18n:e,checkout:{negotiator:t}}=Ae(),a=t.parts.purchaseOrderNumber.value;if(!a)return null;const s=`${e.translate("payment.purchase_order_number.title")} #${a}`;return r(T,{children:s})}const ba=e=>r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"66 -30 151 80",...e,children:[r("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"}),r("circle",{cx:157.2,cy:-2.9,r:3.5,fill:"inherit",stroke:"inherit",strokeWidth:2}),r("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 Ca({minimal:e,reason:t,vaulted:a}){const{i18n:s}=Ae(),n=F().value.length,i=e=>{switch(e){case"giftCard":return s.translate("payment.order_covered_by_gift_cards_notice",{count:n});case"freeOrder":return s.translate("payment.free_order_notice_html");case"storeCredit":return s.translate("payment.order_covered_by_store_credit_notice");case"redeemables":return s.translate("payment.order_covered_by_redeemables_notice");case"deferred":return s.translate("payment_gateway.deferred_payment_label");default:o(e)}};return a?r(B,{gap:"base",children:[r(V,{children:i(t)}),r(va,{})]}):e?r(Ht,{children:r(Kt,{children:i(t)})}):r("div",{className:"agRve",children:r(B,{gap:"large-200",alignItems:"center",children:[r(ba,{className:"FiV0Z",focusable:"false","aria-hidden":"true"}),r(Kt,{children:r(V,{children:i(t)})})]})})}class ga extends t{constructor(){super(...arguments),this.name="AmazonPayMissingPaymentPreferencesError"}}function _a(){const{checkout:{negotiator:e}}=Ae(),t=e.parts.paymentLines;return s(()=>{const e=t.value,a=(()=>{const[t]=e.filter(e=>"walletsPlatformPaymentMethod"===e.method.type);if(!t)return"";const a=t.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||{});const ka={baseMessage:null,fieldErrors:Pa,blockedByDuplicateAutopayCard:!1};function Aa(){const{i18n:e,observability:t}=Ae(),a=R(),[s,r]=d(ka),n=l((e,a)=>{t.counter({name:e,value:1,attributes:{errorField:a.field.join("-"),errorMessage:a.message}})},[t]),i=l(t=>{if(!t||!t.length)return void r({baseMessage:e.translate("credit_card_form.generic_card_error"),fieldErrors:Pa,blockedByDuplicateAutopayCard:!1});const s={...Pa};let i=null;t.forEach(t=>{switch(n("save_credit_card_error",t),t.field?.[1]){case"firstName":return void(s.name=e.translate("field_errors.credit_card_name_billing_invalid"));case"lastName":return void(s.name=e.translate("field_errors.credit_card_name_invalid"));case"month":case"year":return void(s.expiry=e.translate("field_errors.credit_card_expiry_invalid"));case"number":return void(s.number=e.translate("field_errors.credit_card_number_invalid"));case"verificationValue":return void(s.verification_value=e.translate("payment.card_fields.errors.invalid.verification_value"));case"debitOnly":return void(i=a.translate("payment_errors.debit_only"));case"base":if("credit_card_is_expired"===t.message)return void(s.expiry=e.translate("payment_errors.card_has_expired"));if("failed_to_verify_credit_card"===t.message)return void(i=e.translate("payment.generic_incorrect_card_info"));if("three_d_secure_authentication_failed"===t.message)return void(i=e.translate("payment_errors.three_d_secure_failed_payment_method"));if("billing_address_missing"===t.message)return void(i=e.translate("payment_errors.payment_method_billing_address"))}"too_many_credit_cards"!==t.message?(i=e.translate("credit_card_form.generic_card_error"),n("save_credit_card_error_unhandled",t)):i=e.translate("credit_card_form.max_cards_reached",{max_cards:xe})}),r({baseMessage:i,fieldErrors:s,blockedByDuplicateAutopayCard:!1})},[e,a,n]),o=l(()=>{t.counter({name:"save_credit_card_blocked_by_autopay",value:1}),r({baseMessage:null,fieldErrors:Pa,blockedByDuplicateAutopayCard:!0})},[t]),c=l(()=>{r(ka)},[]),u=l(e=>{t.counter({name:"save_credit_card_vaulting_failure",value:1,attributes:{reason:e}}),i("missing_billing_address"===e?[{field:["creditCard","base"],message:"billing_address_missing"}]:void 0)},[t,i]);return{creditCardErrors:s,setCreditCardErrors:i,clearCreditCardErrors:c,failCardVaulting:u,blockDuplicateAutopayCard:o}}function wa(e){return"CREDIT_CARD"===e?.paymentMethod}function Ea(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 Da(e){return"SHOP_PAY"===e.paymentMethod}function La(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 r=Le(t,{paymentBrands:e.paymentBrands,paymentMethodIdentifier:e.paymentMethodIdentifier});a=r?.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=>Ne(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=c(void 0),this.canSetCreditCardNickname=c(!0),this.addCreditCardStrategy="vault-and-select",this.deps=e;const{shopPay:t,installmentsPaymentMethodSelected:a,isApplePayAvailable:s,filteredNegotiatedPaymentMethods:r,isCreditCardDisabled:n,msiEligibilityByCardId:i,hasSellingPlan:o}=e;this.availablePaymentMethods=c(r),this.shopPayAvailableUserStoredPaymentMethods=u(()=>{const e=this.availablePaymentMethods.value;return e.length?He(t.user.paymentMethods.value,e):[]}),this.availableUserStoredPaymentMethods=u(()=>this.shopPayAvailableUserStoredPaymentMethods.value.map(Oa)),this.promotedMethods=u(()=>t.session.promotedPaymentMethods.value.map(Oa)),this.selectedPaymentMethod=u(()=>{const e=t.session.selectedPaymentMethod.value;return e?Oa(e):void 0}),this.selectedCreditCard=u(()=>{const e=t.session.selectedPaymentMethod.value;return e&&Ne(e)?Ua(e.paymentAttributes):void 0}),this.shopPayPaymentMethods=u(()=>{const e=t.user.paymentMethods.value,r=this.shopPayAvailableUserStoredPaymentMethods.value,i=this.availablePaymentMethods.value,o=t.session.promotedPaymentMethods.value,d=t.user.paymentMethodHistory.value,l=e.filter(Ne).map(e=>({method:e,isValidForCheckout:r.includes(e),isExpired:e.paymentAttributes.expired,isDisabled:n(e.paymentAttributes)})),c=a?[]:Qe({negotiatedPaymentMethods:i,userStoredPaymentMethods:e,paymentMethodHistory:d,isApplePayAvailable:s}),u=[...l.sort((e,t)=>We(e.method,t.method)),...c.sort((e,t)=>We(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(o.map(e=>e.id));return u.filter(({method:e})=>!!Ne(e)||!(!p||Ne(p)||e.id!==p.id)||!!y.has(e.id)||Xe(e))}),this.paymentMethods=u(()=>this.shopPayPaymentMethods.value.map(({method:e,...t})=>({...t,method:Oa(e),canEdit:Ne(e),canDelete:Ne(e),canSetDefault:!1,isDefault:!1}))),this.selectedPaymentMethodItem=u(()=>{const e=this.selectedPaymentMethod.value;if(e)return this.paymentMethods.value.find(({method:t})=>t.id===e.id&&t.paymentMethod===e.paymentMethod)}),this.cardPaymentMethods=u(()=>this.paymentMethods.value.filter(e=>wa(e.method))),this.activeOrExpiredCardMethods=u(()=>{const e=this.cardPaymentMethods.value,t=[];for(const s of e)a&&s.isDisabled||t.push(s);return t}),this.disabledCardMethodsForInstallments=u(()=>a?this.cardPaymentMethods.value.filter(e=>e.isDisabled):[]),this.isEveryCardDisabled=u(()=>{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=u(()=>{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 d=u(()=>{const e=Je(this.availablePaymentMethods.value);if(!U(e))return!1;const t=this.selectedCreditCard.value;return Boolean(t&&i.value[t.id])});this.msi={binResolution:"server",selectedCardBin:u(()=>{}),clearInstallments:Be,expandedVisible:u(()=>!!d.value&&"SHOPIFY_INSTALLMENTS"!==t.session.paymentMethodOption.value?.name),collapsedVisible:u(()=>d.value&&!o.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:r,shippingRequired:n}=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),wa(e)){const t=this.selectCreditCard({id:e.paymentAttributes.id});return Te(i,s.user.paymentMethods.value,De(i,this.availablePaymentMethods.value))&&this.#e(i,a),await t,{status:"handled",effects:Ra}}const o=De(i,this.availablePaymentMethods.value);return Te(i,s.user.paymentMethods.value,o)&&this.#e(i,"buyer"===t?{...a,buyerInitiated:!0}:a),(Fe(i)||Ve(i)||Re(i)||Ue(i))&&await r({billingAddress:s.session.selectedBillingAddress.value?.address,fallbackPhoneNumber:s.user.phoneNumber.value},n.value),{status:"handled",effects:Ra}}async promoteSelectedPaymentMethod(e){const{shopPay:t}=this.deps,a=Oe(e,t.user.paymentMethods.value);return a&&(t.session.selectPaymentMethod(a),t.session.unstable_promotePaymentMethod(a)),{status:"handled",effects:{...Ra,selectByBuyerKey:$e(e)}}}getSavedCardActiveSubscriptionsLookup(e){const t=this.deps.shopPay.user.paymentMethods.value.filter(Ne).map(e=>e.paymentAttributes).find(t=>t.id===e.id);if(!t)return;const a={id:t.id,uuid:t.uuid,first:3},s=m(Ma,a),{shopPayGraphql:r}=this.deps;return{key:s,read(){const e=r.read(s);return e?.creditCardActiveSubscriptions?.nodes},async load(){const{data:e}=await r.staticQuery(Ma,{variables:a});return e?.creditCardActiveSubscriptions?.nodes??[]}}}async selectCreditCard({id:e}){const{shopPay:t}=this.deps,a=t.user.paymentMethods.value.filter(Ne).map(e=>e.paymentAttributes).find(t=>t.id===e);if(!a)return;const{updateCheckoutAddress:s,fallbackPhoneNumber:r}=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:r})}async deleteCreditCard({id:e}){return this.deleteCreditCardById({id:e})}async updateCreditCard({id:e,billingAddress:t,nickname:a}){const{shopPay:s,updateCreditCard:r,checkoutContext:n,markShopCashStatesStale:i,observability:o}=this.deps,d=s.user.paymentMethods.value.filter(Ne).map(e=>e.paymentAttributes).find(t=>t.id===e);if(!d)return{status:"failed"};const l=await r(t,e,d.uuid,n,a);if("success"===l.status&&l.creditCard){const{creditCard:t}=l;s.user.updateCreditCard(e,t),this.selectCreditCard({id:t.id}).catch(e=>{o.error(e)})}if(i(),"success"!==l.status){const e=Ye();return oa({addressErrors:e,shopPayErrors:l.errors,i18n:this.deps.i18n,observability:o,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:r=!1}){const{createCreditCard:n,checkoutContext:i,markShopCashStatesStale:o,observability:d}=this.deps;if(""===e)return d.error(new Ya("ShopPayPaymentMethodManager: addCreditCard called with empty sessionId")),{status:"failed"};const l=await n(t,e,i,a),c=await this.handleNewCardResponse(l,s,r);return o(),c}async completeCreditCardVerificationAndVault({verificationId:e,billingAddress:t,nickname:a,debitOnly:s=!1,isBlocking:r=!1}){const{completeCreditCardVerification:n,markShopCashStatesStale:i}=this.deps,o=await n(t,e,a),d=await this.handleNewCardResponse(o,s,r);return i(),d}dispose(){}async deleteCreditCardById({id:e,uuid:t}){const{shopPay:a,deleteCreditCard:s,updateCheckoutAddress:r,emptyAddress:n,fallbackPhoneNumber:i,checkoutContext:o,markShopCashStatesStale:d}=this.deps,l=t??a.user.paymentMethods.value.filter(Ne).map(e=>e.paymentAttributes).find(t=>t.id===e)?.uuid;if(!l)return{status:"failed"};const c=a.session.selectedPaymentMethod.value,u=c&&Ne(c)?c.paymentAttributes.uuid:void 0,m=await s(e,l,o);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(Ne).map(e=>e.paymentAttributes).filter(e=>e.uuid!==l);if(a.user.removeCreditCard(e),d(),u!==l)return{status:"success"};const p=qe(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 wa(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 r({billingAddress:y??n.value,fallbackPhoneNumber:i}),{status:"success"}}recordPaymentMethodSelected(e){const{client:t,observability:a,userEvents:s,source:r,checkout:n,shop:i}=this.deps,o=e.paymentMethod.toLowerCase(),{paymentMethodName:d,paymentBrands:l}=Va(e,this.availablePaymentMethods.value);a.counter({name:"payment_method_selected",value:1,attributes:{payment_method_type:o,payment_method_name:d,payment_brands:l,location:"shop_pay_payment_selector",is_mobile:je(t)}}),s.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...ze(r,n,i),action:"payment_method_selected",paymentMethodName:d}})}async handleNewCardResponse(e,t,a){const{shopPay:s,markShopCashStatesStale:r}=this.deps;if("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)}),r()}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(r){return s.error(r instanceof Error?r:new qa("Failed to refresh Shop Pay buyer details")),!1}}async selectCreditCardAndSetPaymentLine({id:e}){const t=void 0!==jt(this.deps.proposedPaymentLines.value),a=this.selectCreditCard({id:e});if(t)return a;const{shopPay:s}=this.deps,r=s.session.selectedPaymentMethod.value;r&&Ne(r)&&r.paymentAttributes.id===e&&Te(r,s.user.paymentMethods.value,De(r,this.availablePaymentMethods.value))&&this.#e(r),await a}#e(e,t){const{shopPay:a,setPaymentLine:s,observability:r}=this.deps;h(()=>{a.session.selectPaymentMethod(e);const n=Ge({paymentMethod:e,negotiatedPaymentMethods:this.availablePaymentMethods.value,observability:r});void 0!==n&&(t?s(n,void 0,t):s(n))})}clearShopPayPaymentLines(){const{proposedPaymentLines:e}=this.deps;e.value=e.value.filter(e=>!Ke([e],"SHOP_PAY"))}}function za(){const e=Ga(),{checkout:{negotiator:t}}=Ae(),{value:a}=t.current.fields.paymentLines,{newCardSignal:s,hasLoadedSignal:r}=t.context,n=s.value,i=r.value,o=a?.lines?.find(e=>"direct"===e.method.type);return e.value&&!i&&o&&(r.value=!0,!n&&o.method.paymentMethodIdentifier&&(s.value=o.method)),s}function Ga(){const{checkout:{configuration:e,negotiator:t}}=Ae(),a=e.layout.isOnePage.value,{paymentMethods:r}=t.current.fields;return s(()=>!!a&&Boolean(Ze(r.value).length))}const Ka={id:"3880e4a8c616318ac48c829cc40108d16984c1d3172697b99437ce6c20b93d90",type:"mutation",name:"CreditCardCreate",source:"mutation CreditCardCreate($billingAddress:AddressInput!,$origin:String!,$sessionId:ID!,$nickname:String,$checkoutContext:CheckoutContextInput!){creditCardCreate(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!){creditCardDelete(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}=O(),{shopPay:a,checkout:s}=Ae(),r=a.user.phoneNumber.value,n=a.user.addresses.value,i=s.configuration.addressSettings.nonBillingAddressSettings.value,o=n[0]?.address,d=i.defaultShippingDetails.country?.code??t.country.code;return p(()=>nt({firstName:o?.firstName,lastName:o?.lastName,phone:r,countryCode:o?.countryCode||d,zoneCode:o?.zoneCode},{extendedAddressMode:s.address.extendedAddressMode}),[s.address.extendedAddressMode,e,o,d,r])}const Ja={id:"563e8a86083a6c9ad5bd44d3a4db471e3a9919052512d2745d267074d97420fd",type:"mutation",name:"DeleteVaultedCreditCard",source:""},Za={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:r,genericError:n}){if(!r)return{token:void 0};try{const{data:i,error:o}=await e.mutate(Za,{variables:{customerCreditCardModificationInput:{token:r,defaultPaymentMethod:s,billingAddress:{streetAddress:it(t,{extendedAddressMode:a})}}}});if(!i?.modifyCustomerCreditCardPaymentMethod||o)throw new es({cause:o});const{result:d,errors:l}=i.modifyCustomerCreditCardPaymentMethod;return l.length||!d?{token:void 0,error:l[0]?.localizedMessage||n}:{token:d.token}}catch{return{token:void 0,error:n}}}async function ss({graphql:e,token:t,genericError:a}){if(!t)return{token:void 0};try{const{data:s,error:r}=await e.mutate(Ja,{variables:{token:t}});if(!s?.deleteCustomerCreditCardPaymentMethod||r)throw new ts({cause:r});const{result:n,errors:i}=s.deleteCustomerCreditCardPaymentMethod;return i.length||!n?{token:void 0,error:i[0]?.localizedMessage||a}:{token:n.token}}catch{return{token:void 0,error:a}}}function rs({userEvents:e,shopId:t,checkoutSessionIdentifier:a,card:s}){e.monorailEvent({schemaId:"checkout_vaulted_payment_method_selected/1.0",payload:{shopId:parseInt(rt(t),10),checkoutSessionIdentifier:a||"",paymentMethodId:parseInt(rt(s.id),10),paymentInstrumentAccessorId:-1}})}class ns extends t{constructor({managerName:e,methodName:t,identity:a,deployStage:s,isLocalDevelopment:r}){super(`${e}.${t} was called unexpectedly`,{groupingHash:`PaymentMethodManagerUnexpectedMethodCall::${e}::${t}`,metadata:{paymentMethodManager:{managerName:e,methodName:t,identity:a,deployStage:s,isLocalDevelopment:r}}}),this.name="UnexpectedPaymentMethodManagerMethodCallError"}}function is({observability:e,managerName:t,methodName:a,identity:s,deployStage:r,isLocalDevelopment:n}){if(n||"production"!==r&&"canary"!==r)return;const i=new ns({managerName:t,methodName:a,identity:s,deployStage:r,isLocalDevelopment:n});e.error(i,{severity:"warning"})}const os={status:"failed"};class ds{constructor(e){this.disabledCardMethodsForInstallments=c([]),this.isEveryCardDisabled=c(!1),this.canSetCreditCardNickname=c(!1),this.addCreditCardStrategy="direct-session-payment-line",this.deps=e,this.usesCustomerAccountSelectionRule="customerAccount"===e.identity,this.newCard=e.newCard??c(void 0);const{proposal:t}=e,{proposed:a,negotiated:s}=t,{paymentMethods:r}=s.fields,n=s.fields.paymentMethodHistory??c([]);this.availablePaymentMethods=u(()=>r.value??[]),this.promotedMethods=e.paymentMethodPromotions.promoted,this.customerCreditCards=u(()=>ct(this.availablePaymentMethods.value)),this.selectableCustomerCreditCards=u(()=>Ze(this.availablePaymentMethods.value)),this.selectablePaypalBillingAgreements=u(()=>(e.displayablePaymentMethods?.value??this.availablePaymentMethods.value).filter(e=>e.type===ut.PayPal)),this.selectableCustomerBanks=u(()=>this.availablePaymentMethods.value.filter(e=>"bank"===e.type&&e.availableInstruments.length>0)),this.nonCardKnownPaymentMethods=u(()=>mt({paymentMethodHistory:n.value??[],availablePaymentMethods:e.displayablePaymentMethods?.value??this.availablePaymentMethods.value})),this.availableUserStoredPaymentMethods=u(()=>[...cs([ls({card:this.newCard.value,billingAddress:a.billingAddress.value})]),...this.selectableCustomerCreditCards.value.map(e=>ht(e,{cvvVerificationEnabled:this.deps.storeVaultGuestCvvVerificationEnabled})),...this.selectablePaypalBillingAgreements.value.map(pt),...ps(this.selectableCustomerBanks.value.map(yt),this.nonCardKnownPaymentMethods.value,this.promotedMethods.value)]),this.autoselectTarget=u(()=>{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||wa(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=>!wa(e)&&!Ta(e))||this.availableUserStoredPaymentMethods.value.find(Ta)}),this.proposedSelectedPaymentMethod=u(()=>function(e,t,a,s){const r=e.some(e=>"deferred"!==e.method.type&&"giftCard"!==e.method.type&&"redeemable"!==e.method.type);for(const n of e){if("direct"===n.method.type&&s)return s;if("deferred"===n.method.type){if(r)continue;const e=t.find(Ta);if(e)return e;continue}if(us(n)){const e=t.filter(wa).find(e=>e.id===n.method.token);if(e)return e;continue}if(ms(n)){const e=t.find(e=>"PAYPAL"===e.paymentMethod&&"billing_agreement"===e.variant&&e.vaultedToken===n.method.token);if(e)return e;continue}const e=hs(n,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=u(()=>this.proposedSelectedPaymentMethod.value??this.autoselectTarget.value),this.paymentMethods=u(()=>function({cardItems:e,nonCardItems:t,autoselectTarget:a}){const s=e.find(({method:e})=>e.id===dt),r=[...e.filter(({method:e})=>e.id!==dt)].sort((e,t)=>We(e.method,t.method)),n=[...t].sort((e,t)=>We(e.method,t.method)),i=r.filter(ys),o=n.filter(ys),d=i.find(({method:e})=>wa(e)&&e.paymentAttributes.defaultPaymentMethod),l=[i[0],o[0]].filter(e=>void 0!==e).sort((e,t)=>We(e.method,t.method))[0],c=(a?[...i,...o].find(({method:e})=>e.id===a.id&&e.paymentMethod===a.paymentMethod):void 0)??d??l;return c?[...cs([s]),c,...r.filter(e=>e!==c),...n.filter(e=>e!==c)]:[...cs([s]),...r,...n]}({cardItems:[...cs([ls({card:this.newCard.value,billingAddress:a.billingAddress.value})]),...this.customerCreditCards.value.map(e=>ht(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=>!wa(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=u(()=>{const e=this.selectedPaymentMethod.value;if(e)return this.paymentMethods.value.find(({method:t})=>t.id===e.id&&t.paymentMethod===e.paymentMethod)}),this.selectedCreditCard=u(()=>{const e=this.selectedPaymentMethod.value;return wa(e)?e.paymentAttributes:void 0}),this.cardPaymentMethods=u(()=>this.paymentMethods.value.filter(e=>wa(e.method))),this.activeOrExpiredCardMethods=this.cardPaymentMethods,this.isEveryCardExpired=u(()=>{const e=this.cardPaymentMethods.value;return e.length>0&&e.every(e=>e.isExpired)});const i=u(()=>{const e=Je(this.availablePaymentMethods.value);if(!U(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===ut.CreditCard&&e.method.token===t.id)});this.msi={binResolution:"client",selectedCardBin:u(()=>{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:$,expandedVisible:i,collapsedVisible:i}}async promoteSelectedPaymentMethod(e){const t=ot(e,null);return t?(this.deps.paymentMethodPromotions.promote(t),this.selectPaymentMethod(t,"buyer")):{status:"handled",effects:{...Ra,selectByBuyerKey:$e(e)}}}canShowAsGuestCheckoutMethod(){return!1}async selectPaymentMethod(e,t="programmatic"){if(!e)return{status:"not-handled"};if(!wa(e)){const a=De(e,this.availablePaymentMethods.value);if(!a)return{status:"not-handled"};const s=$e(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(lt(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(lt(t));else{const t=this.autoselectTarget.value,a=t?De(t,this.availablePaymentMethods.value):void 0;a?this.deps.setPaymentLine($e(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=wa(t)&&t.id===e,s=this.selectableCustomerCreditCards.value.find(t=>t.token!==e),r=await ss({graphql:this.deps.graphql,token:e,genericError:this.deps.i18n.translate("customer_payment_methods.delete_customer_mandate.generic_error")});return r.token?(a&&s&&this.deps.setPaymentLine(lt(s)),{status:"success",shouldNegotiatePaymentMethods:!0}):{status:"failed",bannerError:r.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"),os}async completeCreditCardVerificationAndVault(){return this.reportUnexpectedUse("completeCreditCardVerificationAndVault"),os}dispose(){}async selectCreditCardByBuyer({paymentMethod:e}){let t,a,s;if(e.id===dt){const e=this.newCard.value;if(!e)return{status:"not-handled"};t=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=lt(a),s=a.firstDigits,rs({userEvents:this.deps.userEvents,shopId:this.deps.shopId,checkoutSessionIdentifier:this.deps.checkoutSessionIdentifier,card:a})}return this.deps.isMsiAvailable&&(this.deps.proposal.proposed.paymentLines.value=$(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===ut.CreditCard}function ms(e){return e.method.type===ut.PayPal}function hs(e,t,a){const s=$e(e.method);return t.find(e=>{if(wa(e))return!1;const t=De(e,a);return!!t&&s===$e(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 bs;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},bs={canEdit:!1,canDelete:!0,canSetDefault:!1,isDefault:!1},Cs={status:"failed"};class gs{constructor(e){this.availablePaymentMethods=c([]),this.availableUserStoredPaymentMethods=c([]),this.paymentMethods=c([]),this.selectedPaymentMethod=c(void 0),this.selectedPaymentMethodItem=c(void 0),this.selectedCreditCard=c(void 0),this.activeOrExpiredCardMethods=c([]),this.disabledCardMethodsForInstallments=c([]),this.isEveryCardDisabled=c(!1),this.isEveryCardExpired=c(!1),this.cardPaymentMethods=c([]),this.promotedMethods=c([]),this.msi={binResolution:"client",selectedCardBin:c(void 0),clearInstallments:e=>e,expandedVisible:c(!1),collapsedVisible:c(!1)},this.newCard=c(void 0),this.canSetCreditCardNickname=c(!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"),Cs}async updateCreditCard(){return this.reportUnexpectedUse("updateCreditCard"),Cs}async addCreditCard(){return this.reportUnexpectedUse("addCreditCard"),Cs}async completeCreditCardVerificationAndVault(){return this.reportUnexpectedUse("completeCreditCardVerificationAndVault"),Cs}dispose(){}reportUnexpectedUse(e){is({...this.unexpectedUseOptions,managerName:"FallbackPaymentMethodManager",methodName:e})}}function _s({enableAutoSelect:e=!0}={}){const{client:t,source:a,environment:s,checkout:r,shop:n,i18n:i,observability:o,userEvents:d,shopPay:c,graphql:{coreGraphql:u,shopPayGraphql:m}}=Ae(),h=r.identity.current.value,b=n.hasFlagEnabled(ft),C=null!=s.devMode,g=function(){const{checkout:{address:{extendedAddressMode:e}},graphql:{shopPayGraphql:t},source:a}=Ae(),s=et({source:a});return l(async(a,r,n,i,o=s)=>{const{data:d,error:l}=await t.mutate(Ka,{variables:{billingAddress:tt(a,e),origin:o,sessionId:r,nickname:i,checkoutContext:n}});if(l||null==d||null==d.creditCardCreate)return{status:"failed"};const{creditCardCreate:c}=d;return at(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?st(c.creditCard):void 0}},[s,e,t])}(),_=function(){const{checkout:{address:{extendedAddressMode:e}},graphql:{shopPayGraphql:t},source:a}=Ae(),s=et({source:a});return l(async(a,r,n,i=s)=>{const{data:o,error:d}=await t.mutate(Ha,{variables:{verificationId:r,billingAddress:tt(a,e),origin:i,nickname:n}});if(d||null==o||null==o.creditCardCompleteVerificationAndVault)return{status:"failed"};const{creditCardCompleteVerificationAndVault:l}=o;return at(l.userErrors)?{status:"blocked_by_autopay"}:l.userErrors.length>0?{status:"failed",errors:l.userErrors}:{status:"success",creditCard:l.creditCard?st(l.creditCard):void 0}},[s,e,t])}(),M=function(){const{graphql:{shopPayGraphql:e},source:t}=Ae(),a=et({source:t});return l(async(t,s,r,n=a)=>{const{data:i,error:o}=await e.mutate(Qa,{variables:{id:t,uuid:s,origin:n,checkoutContext:r}});if(o||null==i||null==i.creditCardDelete)return{status:"failed"};const{creditCardDelete:d}=i;return d.userErrors.length>0?{status:"failed",errors:d.userErrors}:{status:"success"}},[a,e])}(),P=function(){const{graphql:{shopPayGraphql:e},source:t,shop:{myshopifyDomain:a,id:s},shopPay:{config:r}}=Ae(),{checkoutSessionIdentifier:n}=t,i=et({source:t}),{redirectSource:o}=r;return l(async()=>{const{data:t,error:r}=await function(e,{checkoutVersion:t,checkoutIdentifier:a,shopifyDomain:s,shopId:r,redirectSource:n},{cache:i=!0}={}){return e.staticQuery(ta,{variables:{checkoutContextInput:{checkoutVersion:t,checkoutIdentifier:a,shopifyDomain:s,shopId:r},shopifyDomain:s,redirectSource:n??void 0},cache:i})}(e,{checkoutVersion:i,checkoutIdentifier:n??"unknown",shopifyDomain:a,shopId:rt(s),redirectSource:o},{cache:!1});return r||null==t||null==t.checkoutSession||null==t.checkoutSession.user?{status:"failed"}:aa(t)},[n,i,o,s,a,e])}(),S=function(){const{checkout:{address:{extendedAddressMode:e}},graphql:{shopPayGraphql:t},source:a}=Ae(),s=et({source:a});return l(async(a,r,n,i,o,d=s)=>{const{data:l,error:c}=await t.mutate(Wa,{variables:{id:r,uuid:n,billingAddress:tt(a,e),origin:d,nickname:o,checkoutContext:i}});if(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?st(u.creditCard):void 0}},[s,e,t])}(),k=et({source:a}),A=Xa(),{paymentLines:w}=r.negotiator.parts,E=za(),{buyerHasActedSignal:I,newCardSignal:x}=r.negotiator.context,D=y(Zt),L=c.user.phoneNumber.value,N=Qt(),B=c.session.isInstallmentsSelected.value,T=Wt({isApplePayAvailable:N.value}),F=vt(),{creditCardDisabled:V}=sa(),R=ea(),{updateCheckoutAddress:O}=Xt(),[,$]=Jt({allowPreselect:!1}),Y=Je(r.negotiator.current.fields.paymentMethods.value??[]),q=U(Y),j=bt(),{eligibilityByCardId:z}=Ct(na),G=l(()=>{D&&(D.cashbackState.stale.value=!0)},[D]),K=p(()=>({checkoutIdentifier:a.checkoutSessionIdentifier??"",checkoutVersion:k,shopId:rt(n.id),shopifyDomain:n.myshopifyDomain}),[a.checkoutSessionIdentifier,n.id,n.myshopifyDomain,k]),H=p(()=>"shopPay"===h?new ja({shopPay:c,negotiatedPaymentMethods:r.negotiator.current.fields.paymentMethods,installmentsPaymentMethodSelected:B,isApplePayAvailable:N.value,filteredNegotiatedPaymentMethods:T.value,isCreditCardDisabled:V,setPaymentLine:$,updateCheckoutAddress:O,shippingRequired:r.isShippingRequired,client:t,i18n:i,observability:o,userEvents:d,source:a,checkout:r,shop:n,createCreditCard:g,deleteCreditCard:M,updateCreditCard:S,completeCreditCardVerification:_,refreshBuyerDetails:P,markShopCashStatesStale:G,shopPayGraphql:m,emptyAddress:A,proposedPaymentLines:w,checkoutContext:K,fallbackPhoneNumber:L,paymentRequiredMethod:R.value,msiEligibilityByCardId:z,hasSellingPlan:j}):"customerAccount"===h||"businessCustomer"===h?new ds({proposal:r.proposal,newCard:E,displayablePaymentMethods:F,paymentMethodPromotions:r.paymentMethodPromotions,setPaymentLine:$,isMsiAvailable:q,shopId:n.id,checkoutSessionIdentifier:a.checkoutSessionIdentifier,storeVaultEnabled:n.storeVaultEnabled,storeVaultGuestCvvVerificationEnabled:n.storeVaultGuestCvvVerificationEnabled,graphql:u,extendedAddressMode:r.address.extendedAddressMode,i18n:i,observability:o,userEvents:d,identity:h,deployStage:s.deployStage,isLocalDevelopment:C}):new gs({observability:o,identity:h,deployStage:s.deployStage,isLocalDevelopment:C}),[h,s.deployStage,C,c,B,N.value,T.value,F,V,q,$,O,r,t,o,d,a,n,i,u,m,g,M,P,S,_,G,A,w,E,K,L,R.value,z,j]);f(()=>()=>H.dispose(),[H]);const Q=H.selectedPaymentMethod.value,W=H.paymentMethods.value,X=H.availablePaymentMethods.value,J=H.availableUserStoredPaymentMethods.value,Z=w.value.some(e=>"direct"===e.method.type);f(()=>{if(!e)return;if("shopPay"!==h)return;if(H.selectedPaymentMethod.peek()!==Q||H.paymentMethods.peek()!==W)return;if(Q&&function({selected:e,paymentMethods:t,availablePaymentMethods:a}){return Boolean(De(e,a)||wa(e)&&t.some(({method:t})=>t.paymentMethod===e.paymentMethod&&t.id===e.id))}({selected:Q,paymentMethods:W,availablePaymentMethods:X}))return;if(Z)return;const t=W.filter(({isValidForCheckout:e})=>e).sort((e,t)=>We(e.method,t.method)).map(({method:e})=>e),s=function(e){for(const t of e){if(!wa(t))return t;if(!t.paymentAttributes.expired)return t}return e[0]}(t);s&&wa(s)&&s.paymentAttributes.expired&&d.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.1",payload:{...ze(a,r,n),action:"final_payment_method_expired_after_merchant_filter"}});const i=s?$a(s,c.user.paymentMethods.value):void 0;if(i)c.session.selectPaymentMethod(i);else{const e=c.session.clearPaymentMethod("unavailable"),s=c.user.creditCards.peek().length;e&&s>0&&(o.log("shop_pay_payment_method_auto_cleared","[usePaymentMethodManager] No listed payment method was valid for checkout, so the Shop Pay selection was cleared",{checkout_session_identifier:a.checkoutSessionIdentifier,source_type:a.type,clear_reason:"unavailable",held_card_count:s,listed_method_count:W.length,valid_for_checkout_count:t.length,negotiated_direct_present:Boolean(Y)}),b&&o.counter({name:"shop_pay_payment_method_auto_cleared",value:1,attributes:{source_type:a.type,clear_reason:"unavailable",negotiated_direct_present:Boolean(Y)}}))}},[e,X,J,r,h,Y,o,d,H,W,b,Q,n,c.session,c.user.creditCards,c.user.paymentMethods.value,a,Z]);const ee=I.value,te=Boolean(x.value),ae=H instanceof ds?H.autoselectTarget.value:void 0,se=H instanceof ds?H.proposedSelectedPaymentMethod.value:void 0,re=w.value[0],ne=re?.method.type,ie=ra(re);return v(()=>{e&&("customerAccount"!==h&&"businessCustomer"!==h||ee||H instanceof ds&&ae&&(te||ie||se&&se.paymentMethod===ae.paymentMethod&&se.id===ae.id||(ne&&o.log("payment_method_manager_programmatic_selection_replaced_primary_line","Programmatic payment method selection replaced the proposed primary payment line",{replacedPaymentLineMethodType:ne,replacingPaymentMethodType:ae.paymentMethod}),H.selectPaymentMethod(ae,"programmatic").catch(()=>{}))))},[e,h,ee,te,H,ae,se,ie,ne,o]),H}function Ms(){const{shop:e,checkout:t,observability:a}=Ae(),s=t.wallets.activeSession.value,r=t.latestReceipt.value,{persistedPayPalSignal:n}=we(),i="payPal"===t.identity.current.value,o=r?.id,d=Y().value,l=void 0!==d,c=gt(),u=n.value,{negotiate:m}=q(),h=j(),p=w(new Set(_t))?.hasError&&o!==u?.receiptIdForClearedToken,y=z("PAYPAL_EXPRESS").value?.merchantId?.trim(),v=d?.method.walletContent?.merchantId?.trim(),b=e.hasFlagEnabled(Mt)&&y&&v&&v!==y,C=u?.billingAgreementStatus&&Pt({checkout:t})&&"NOTREQUESTED"===u.billingAgreementStatus&&!d?.method.walletContent?.isVaultWithPurchaseOrder,g=!0===d?.method.walletContent?.isVaultWithPurchaseOrder&&0===c.value?.amount;f(()=>{l&&((p||b||C||g)&&(function(){let e;e=p?"SubmitForCompletion Error":b?"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={...n.value,receiptIdForClearedToken:p?o:void 0,newTokenRequiredDueToError:!0,billingAgreementStatus:void 0};n.value=e}()),(async()=>{(g||p&&!i&&!s)&&(h(),await m({silenceViolations:["non-stock"]}))})())},[p,l,b,o,a,n,C,g,i,h,m,s])}function Ps(e){const{checkout:{negotiator:t}}=Ae(),a=t.current.fields.paymentMethods;return s(()=>{const t=e.value,s=Boolean(t?.balance?.amount),r=Boolean(a.value?.find(e=>"redeemable"===e.type&&"STORE_CREDIT"===e.redemptionSource));return Boolean(s&&r)})}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=>!Es(e,t))}function As(e,t){return e.some(e=>Es(e,t))}function ws({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 Es(e,t){return St(e)&&e.method.redemptionContent&&"storeCreditAccountId"in e.method.redemptionContent&&e.method.redemptionContent.storeCreditAccountId===t.id}function Is(e){const{checkout:{negotiator:t}}=Ae(),a=t.current.fields.paymentLines;return s(()=>{const t=e.value;return!(!t||!a.value?.lines)&&As(a.value.lines,t)})}function xs(){const{shop:{currencyCode:e},checkout:{negotiator:t}}=Ae(),{buyerIdentity:a}=t.current.fields;return s(()=>{const t=a.value,s=t?.presentmentCurrency||e;return("CustomerProfile"===t?.customerProfile?.__typename||"BusinessCustomerProfile"===t?.customerProfile?.__typename?t.customerProfile.storeCreditAccounts:[]).find(e=>e.balance.currencyCode===s)})}function Ds(){const{checkout:{negotiator:e}}=Ae(),t=e.current.fields.paymentLines;return s(()=>t.value?.lines.filter(e=>St(e))||[])}function Ls({options:e,paymentMethodExtension:t}){const a=t[0]?.extension;if(!a)return null;const s=a.appId.split("/").pop(),n=s&&!kt.includes(s);return r(G,{options:e,customizations:t,transformComponents:n?Ns:void 0})}const Ns=K(new Set(["Image","Banner","s-image","s-banner"]));function Bs(){const{checkout:{negotiator:e}}=Ae(),t=e.current.fields.allViolations,a=s(()=>(t.value??[]).filter(e=>!!H(e)||!!At(e))),i=s(()=>{const[e]=a.value;return e?e.localizedMessage||e.nonLocalizedMessage:null});return r(n,{when:i,children:e=>r(Q,{tone:"critical",errorType:W.DiscountError,children:e})})}function Ts({amount:e,maskedIdentifier:t,remove:a}){const{i18n:s}=Ae(),n=s.formatCurrency(e.amount,{currency:e.currencyCode,form:"short"}),i=t.slice(-4).toUpperCase(),o=s.translate("payment.gift_card_wrapper.gift_card_label",{identifier:X(i)}),d=s.translate("order_summary.gift_card_ending",{last_characters:i||""});return r(ae,{borderRadius:"base",background:"base",border:"base",blockAlignment:"center",padding:"small-200",children:r(J,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1fr) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",children:[r(J,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-300",alignItems:"center",alignContent:"center",children:[r(zt,{type:"gift-card"}),r(Z,{children:[r(ee,{accessibilityVisibility:"hidden",children:o}),r(ee,{accessibilityVisibility:"exclusive",children:d})]})]}),r(J,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-100",alignItems:"center",alignContent:"center",children:[r(ee,{type:"strong",children:n}),r(te,{onClick:()=>a(),accessibilityLabel:s.translate("general.remove_item",{label:d}),children:r(L,{type:"x",size:"small"})})]})]})})}const Fs="gift_card_option";function Vs({afterAppliedRedeemablesChange:e,autoSelect:t=!1,showHeading:a=!0}){const{i18n:s}=Ae(),{paymentMethod:n,paymentLines:i,submit:o,remove:c,removeAll:u}=se(),m=re("Checkout::GiftCard::Render",n?.uiExtension?[n?.uiExtension]:[]),{value:h}=gt(),y=h?.amount||0,[v,b]=d([]),[C,g]=d(!1),_=0===y&&0===i?.length;f(()=>{_?b([]):(i?.length>0||t)&&b([Fs])},[t,i?.length,_]);const M=l(async(t,a)=>{const s=await o(t,a);return s&&ne(s)&&(g(!1),e?.()),s},[e,o]),P=p(()=>({paymentMethodIdentifier:n?.paymentMethodIdentifier??"",submitRedeemablePaymentLine:M}),[n?.paymentMethodIdentifier,M]),S=Boolean(i?.length)||Boolean(m.length)&&Boolean(n);return r(de,{id:"3p-gift-card-field",open:S,duration:"slow",children:r(ie,{accessibilityLabel:s.translate("payment.gift_card_wrapper.heading"),children:r(B,{gap:"base",children:[a&&r(oe,{level:2,children:s.translate("payment.gift_card_wrapper.heading")}),r(da,{name:"gift_card_option_list",values:v,multiple:!0,onChange:async t=>{if(b(t),0===t.length&&i.length>0){const t=await u();t&&ne(t)&&e?.()}},variant:"block",children:r(la,{value:Fs,disabled:_,selectedContent:r(B,{gap:"base",children:[i?.length>0?r(B,{gap:"small-300",children:i.map(t=>{const{cost:a,method:s}=t;if(!a||"CUSTOM"!==s.redemptionSource)return null;const n=s.redemptionContent?.redemptionAttributes.reduce((e,t)=>`${e},${t.key}:${t.value}`,"");return r(Ts,{maskedIdentifier:s.redemptionContent?.maskedIdentifier||"",amount:{amount:a.amount,currencyCode:a.currencyCode},remove:async()=>{const t=await c(s);t&&ne(t)&&e?.()}},n)})}):null,r(Bs,{}),(()=>{if(0===y||!m.length||!n)return null;const e=r(Ls,{paymentMethodExtension:m,options:P});return i&&0!==i.length?r(ae,C?{children:[r(N,{blockSize:"small-500"}),r(B,{gap:"base",children:[r(oe,{level:3,children:s.translate("payment.gift_card_wrapper.apply_another_gift_card_label")}),e]})]}:{children:[r(N,{blockSize:"small-500"}),r(E,{textDecoration:"none",onClick:()=>g(!0),children:r(B,{direction:"inline",alignItems:"center",gap:"small-400",children:[r(L,{type:"plus"}),r(ee,{children:s.translate("payment.gift_card_wrapper.apply_another_gift_card_label")})]})})]}):e})()]}),children:s.translate("payment.gift_card_wrapper.apply_gift_card_label")})})]})})})}const Rs="StoreCreditRedemptionCheckbox",Us="StoreCreditSubscriptionRenewalsCheckbox";function Os(e,t){return St(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 r=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?r: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 zs(e){const{negotiate:t}=q();return l(async()=>new Promise(a=>{t({fieldsToResolve:["paymentLines"],silenceViolations:["non-store-credit",...xt(["paymentLines"])],runListenersOnError:!0,force:!0,onComplete(t){e.value="success"===t.status?Ss.Success:Ss.Error,a(t)}})}),[t,e])}function Gs(e,t){const{checkout:{negotiator:a}}=Ae(),s=zs(t);return l(async()=>{if(!e)return t.value=Ss.Error,{result:null,landed:!1};t.value=Ss.Loading;const r=a.parts.paymentLines.value,n=r.findIndex(t=>Os(t,e)),i=r[n];a.parts.paymentLines.value=ks(r,e);const o=await s(),d=js(o,e,!1);if(i&&!d){const t=ks(a.parts.paymentLines.value,e);a.parts.paymentLines.value=[...t.slice(0,n),i,...t.slice(n)]}return{result:o,landed:d}},[e,t,a.parts.paymentLines,s])}function Ks(e,t){const{i18n:a,checkout:{negotiator:s}}=Ae(),r=zs(t),n=s.current.fields.paymentLines,i=gt(),o=wt(),d=bt(),c=Et(),u=s.current.fields.paymentFlexibilityPaymentTermsTemplate,m=s.current.fields.isImmediateAmountReducedForRedeemables,h=l(()=>It({hasSellingPlan:d.value,hasFixedSellingPlan:c.value,paymentTermsTemplateType:u.value?.type}),[d,c,u]),p=b(!1);return C(()=>{if(!h())return;const t=i.value??o.value,a=s.parts.paymentLines.value;if(!e||!p.current)return;const r=n.value?.lines.find(t=>Os(t,e))?.cost;if(m?.value){if(r){const t=qs({paymentLines:a,storeCreditAccount:e,cost:r});t!==a&&(s.parts.paymentLines.value=t)}return}if(r&&r.amount>0)return void(p.current=!1);const d=qs({paymentLines:a,storeCreditAccount:e,cost:$s({amountDueAtCheckout:t,storeCreditAccount:e})});d!==a&&(s.parts.paymentLines.value=d)}),l(async()=>{if(!e)return t.value=Ss.Error,{result:null,landed:!1};t.value=Ss.Loading;const n=ks(s.parts.paymentLines.value,e),d=i.value??o.value,l=h(),c=l?$s({amountDueAtCheckout:d,storeCreditAccount:e}):void 0;if(p.current=null!=c,l&&!Ys({amountDueAtCheckout:d,storeCreditAccount:e}))return t.value=Ss.Error,le({content:a.translate("store_credit_errors.generic_error")}),{result:null,landed:!1};s.parts.paymentLines.value=[...n,{method:{type:"redeemable",redemptionSource:"STORE_CREDIT",redemptionContent:{storeCreditAccountId:e.id}},...c&&{cost:c}}];const u=await r();if(!js(u,e,!0))return p.current=!1,s.parts.paymentLines.value=ks(s.parts.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&&(p.current=!1,s.parts.paymentLines.value=function({paymentLines:e,storeCreditAccount:t,cost:a}){return e.map(e=>Os(e,t)?{...e,cost:a}:e)}({paymentLines:s.parts.paymentLines.value,storeCreditAccount:e,cost:m})),{result:u,landed:!0}},[o,r,i,s.parts.paymentLines,t,h,e,a])}function Hs({afterAppliedRedeemablesChange:e}){const{i18n:t,shop:a,webMcp:i,checkout:{negotiator:o}}=Ae(),d=a.hasFlagEnabled(Dt),c=gt(),u=Nt(),m=Et(),h=xs(),p=Is(h),y=g(Ss.Init),f=Ps(h),b=function(e){const{shop:t}=Ae(),a=t.hasFlagEnabled(Dt),r=wt(),n=Lt();return s(()=>{if(n.value)return ws({firstOrderTotal:r.value,storeCreditAccount:e.value,includeExhausted:a})})}(h),M=s(()=>d&&null!=b.value),P=s(()=>u.value||m.value),S=s(()=>u.value?t.translate("payment.store_credit.buying_gift_card"):m.value?t.translate("payment.store_credit.no_fixed_selling_plans"):void 0);C(()=>{(!f.value||!M.value||P.value)&&_(()=>{o.parts.useStoreCreditForSubscriptionRenewals.value&&(o.parts.useStoreCreditForSubscriptionRenewals.value=!1)})});const k=Ks(h.value,y),A=Gs(h.value,y),w=s(()=>y.value===Ss.Loading),E=s(()=>w.value||P.value),I=s(()=>E.value||0===c.value?.amount&&!p.value),x=E,D=s(()=>{const e=[],t=M.value&&o.parts.useStoreCreditForSubscriptionRenewals.value;return(p.value||t)&&e.push(Rs),t&&e.push(Us),e}),L=l(async t=>{const a=p.peek(),s=t.includes(Rs),r=d&&!(a&&!s)&&t.includes(Us),n=s||r,i=o.parts.useStoreCreditForSubscriptionRenewals.peek();if(o.parts.useStoreCreditForSubscriptionRenewals.value=r,n!==a){const{landed:t}=n?await k():await A();if(!t)return void(o.parts.useStoreCreditForSubscriptionRenewals.value=!n&&i);e?.()}},[k,A,p,o.parts.useStoreCreditForSubscriptionRenewals,d,e]),N=s(()=>f.value&&Boolean(h.value)),T=s(()=>D.value.includes(Rs)),F=l(e=>L(e?[...new Set([...D.peek(),Rs])]:[]),[D,L]);v(()=>i?.unstable_provideStoreCreditController({available:N,redeeming:T,applied:p,settling:w,hasGiftCard:u,hasFixedSellingPlan:m,paymentDue:c,setRedeeming:F}),[i,N,T,p,w,u,m,c,F]);const V=h.value;if(!N.value||!V)return null;const R=M.value?b.value:void 0,U=V.balance,O=S.value,$=R&&R.amount>0?t.translate("payment.store_credit.remaining_for_subscription_charges_description",{amount:t.formatCurrency(R.amount,{currency:R.currencyCode})}):void 0;return r(ie,{accessibilityLabel:t.translate("payment.store_credit.label"),children:r(da,{name:"store_credit_redemption",values:D.value,multiple:!0,onChange:L,variant:"block",children:[r(la,{value:Rs,disabled:I.value,secondaryContent:r(ee,{type:"strong",children:t.formatCurrency(U.amount,{currency:U.currencyCode})}),details:O&&r(ee,{children:O}),children:r(B,{direction:"inline",gap:"base",alignItems:"center",children:[r(ee,{children:t.translate("payment.store_credit.apply_label")}),r(n,{when:w,children:r(ce,{})})]})}),R&&r(la,{value:Us,disabled:x.value,details:($||O)&&r(B,{gap:"small-500",children:[$&&r(ee,{children:$}),O&&r(ee,{children:O})]}),children:r(ee,{children:t.translate("payment.store_credit.use_remaining_for_subscription_charges_label")})})]})})}function Qs(){const{i18n:e}=Ae();return ue(me(Bt)).value?r(Q,{errorType:W.PaymentError,tone:"critical",children:e.translate("store_credit_errors.generic_error")}):null}function Ws({name:e,digits:t,icon:a}){return r(B,{className:"YVGTZ",direction:"inline",columnGap:"none",rowGap:"small-200",alignItems:"center",inlineSize:"100%",children:[r("span",{className:"zyVks",children:r(Z,{children:e})}),r("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 Js(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 Tt(a)?Ft(a):e}(e.brand):""}function Zs(){const{checkout:{negotiator:e}}=Ae(),{paymentLines:t}=e.parts;return s(()=>jt(t.value))}function er({isSelected:e,hasMsiPlan:t,isStale:a,binPrefix:s,canEditBin:r,supportedInstallmentsCount:n,isNegotiating:i}){if(!e||!t&&!a)return"hidden";if(s){if(s.length<8&&r)return"prompt"}else{if(r)return"prompt";if(0===n)return"hidden"}return i||a?"loading":"dropdown"}function tr({id:e,variant:t}){const{i18n:a}=Ae(),s="prompt"===t?a.translate("msi_installments.enter_card_details_prompt"):a.translate("msi_installments.loading_installments");return f(()=>{if("loading"===t)return le({content:s})},[s,t]),r(fe,{id:e,name:"msiInstallments",label:a.translate("msi_installments.payment_plan_label"),value:t,disabled:"loading"===t,onChange:()=>{},children:r(ye,{value:t,children:s})})}function ar({paymentMethod:e,isSelected:t,canEditBin:a=!0,isVaultedContext:s=!1,id:n="msiInstallmentsSelect"}){const{checkout:{negotiator:i}}=Ae(),{bankIdNumberSignal:o,installmentMonthsSignal:d,lastNegotiatedBinSignal:l}=i.context,{paymentLines:c}=i.parts,u=Zs();f(()=>{d.value=u.value},[u.value,d]);const m=a&&!s,h=e.installmentPlans?.find(e=>"MSI"===e.type),p=h?.supportedInstallments??[],y=Vt(o.value),v=!s&&void 0!==y&&void 0!==l.value&&y!==l.value;f(()=>{u.value&&(!t||!h||!y&&!m&&0===p.length)&&(c.value=pe(c.value,void 0))},[u.value,t,h,y,m,p.length,c]);const b=er({isSelected:Boolean(t),hasMsiPlan:Boolean(h),isStale:v,binPrefix:y,canEditBin:m,supportedInstallmentsCount:p.length,isNegotiating:!1});return"hidden"===b?null:r(tr,"prompt"===b?{id:n,variant:"prompt"}:{id:n,variant:"loading"})}const sr=a({displayName:"MsiInstallmentsSelect",useError:he("MsiInstallmentsSelect"),load:()=>M(async()=>({default:(await e(async()=>{const{MsiInstallmentsSelect:e}=await(import("./82de4790.CpqHWkqk.js"));return{MsiInstallmentsSelect:e}},__vite__mapDeps([21,1,14,2,3,4,5,15,16,17,18,12,10,19,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41]))).MsiInstallmentsSelect})),renderLoading:e=>r(ar,{...e})}),rr=new Map,nr=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=rr.get(e.source);t instanceof Promise||(t=ve(e,!0),rr.set(e.source,t)),await t;const a=this.initQueue.pop();a?.(),this.initQueue=[],this.scriptLoaded=!0}async setup(t,a,s){return or(()=>{if(this.sdk)return;if(this.setupPromise&&this.setupForm===t)return this.setupPromise;const r=window.CardFields;if(!r)throw new be("Attempted to init Cardfields before it is ready");const n=++this.currentSetupId;return this.setupForm=t,s(),this.setupPromise=(async()=>{try{for(let s=0;sa?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 or(()=>{if(!this.sdk)throw new Ce("The CardFields SDK has not been set up.");return e(this.sdk)},Boolean(this.sdk),this.sdkQueue)}};nr.MAX_SETUP_ATTEMPTS=3;let ir=nr;function or(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 dr=P(void 0),lr={name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1};function cr({children:e,value:t,sdkScriptAttributes:a,blurValidationEnabled:s=!0,blurValidationFieldDenylist:n,onError:i,onSetFieldErrors:o,onLoadSuccess:c}){const u=p(()=>new ir,[]),[m,h]=d(!0),[y,C]=d({name:null,number:null,verification_value:null,expiry:null,issue_date:null,issue_number:null,sdk:null}),g=b(),[_,M]=d(),[P,S]=d(),[k,A]=d({name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1}),[w,E]=d(""),[I,x]=d([]),[D,L]=d(lr),N=b(D);f(()=>{N.current=D},[D]);const B=b(),T=l(e=>{g.current=e instanceof ge?e.diagnostics:void 0,C({sdk:e.message}),i?.(e),h(!1)},[i,C,h]),F=l(async e=>{try{return await e()}catch(t){if(t instanceof Error){let e=null;if(t.name===_e.name)e=new _e(t.message);else if(t.name===Me.name){const a="httpStatus"in t&&"number"==typeof t.httpStatus?t.httpStatus:void 0;e=new Me(t.message,a)}else t.name===Pe.hostedFieldsName&&(e=new Pe(t.message));if(e)return T(e),"";T(t)}throw t}},[T]),V=l(async(e,t={propagateErrors:!0})=>{const{sdk:a,...s}=e;await F(()=>u.setErrors(s)),C(a=>{const s={...a,...e};return t.propagateErrors&&o?.(s),s})},[u,o,F]),R=l((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 r={...y,...a};return V(r),{isValid:!Object.values(r).some(Boolean)}},[y,k?.expiry,k?.name,k?.number,k?.verification_value,V]);f(()=>{!async function(){try{if(!a)throw new be("Provider: hostedFieldsUrl must be provided");await u.load(a)}catch(e){e instanceof Error&&T(e)}}()},[a,u,T]);const U=l(({cardType:e,bin:t,networks:a})=>{M(e),E(t),x(a)},[]),O=l(({targetName:e})=>{S(e)},[]),$=l(async e=>{const{isValueValid:t,targetName:a,isValueEmpty:r}=e,i=B.current,o=N.current[a],d=Boolean(n?.has(a));if(s&&!d&&i&&o){const e={[a]:t?null:i[a]};"number"===a&&r&&(e[a]=i.number_blank),await V(e,{propagateErrors:!1})}S(void 0)},[V,s,n]),Y=l(async e=>{const{targetName:t,isValueEmpty:a,isTab:s}=e;if(!s){A(e=>({...e,[t]:!a})),L(e=>({...e,[t]:!0}));const e={[t]:null};await V(e)}},[V]),q=l(e=>{A(t=>({...t,[e]:!0}))},[]),j=function(){const e=b(!0);return v(()=>()=>{e.current=!1},[]),e}(),z=l(()=>{j.current&&(A({name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1}),x([]))},[A,j]),G=l(()=>{F(()=>u.on("cardtype",U)),F(()=>u.on("focus",O)),F(()=>u.on("blur",$)),F(()=>u.on("keyup",Y)),F(()=>u.on("change",Y)),F(()=>u.on("input",Y))},[F,u,U,O,$,Y]),K=l(()=>{F(()=>u.off("cardtype",U)),F(()=>u.off("focus",O)),F(()=>u.off("blur",$)),F(()=>u.off("keyup",Y)),F(()=>u.off("change",Y)),F(()=>u.off("input",Y))},[F,u,U,O,$,Y]),H=l(()=>{L(lr)},[]),Q=p(()=>({loadFonts:e=>F(()=>u.loadFonts(e)),setErrors:e=>V(e,{propagateErrors:!1}),setStyles:(...e)=>F(()=>u.setStyles(...e)),setFocus:(...e)=>F(()=>u.setFocus(...e)),setTooltip:(...e)=>F(()=>u.setTooltip(...e)),setTranslation:(...e)=>F(()=>u.setTranslation(...e)),setPlaceholderContent:(...e)=>F(()=>u.setPlaceholderContent(...e)),setValue:(e,t)=>F(()=>("string"==typeof t&&t.trim().length>0&&A(t=>({...t,[e]:!0})),u.setValue(e,t))),setup:async(e,t,a=()=>{})=>{h(!0),await F(()=>u.setup(e,t,a)),c?.(),h(!1),B.current=t.errorMessages},teardown:()=>F(()=>u.teardown()),clearField:e=>F(()=>(A(t=>({...t,[e]:!1})),u.clearField(e))),vaultCard:(...e)=>F(()=>u.vaultCard(...e)),vaultCardMultipleTimes:(e,t)=>F(()=>u.vaultCardMultipleTimes(e,t)),getCardField:e=>u.getFieldFrame(e)}),[u,V,F,c]);f(()=>()=>{o?.({})},[o]);const W=p(()=>t??{sdk:Q,errors:y,sdkLoadDiagnostics:g.current,cardBrand:_,bankIdNumber:w,networks:I,focusedField:P,filled:k,loading:m,validate:R,subscribe:G,unsubscribe:K,resetTouched:H,emptyFields:z,setFilled:q,touched:D},[Q,_,w,I,y,k,P,m,t,R,G,K,H,z,q,D]);return r(dr.Provider,{value:W,children:e})}const ur=()=>{const e=y(dr);if(null==e)throw new be("No cardfields found in context");return e},mr=e=>e.toUpperCase(),hr=e=>e.toLowerCase();function pr(e){return Boolean(e?.some(e=>"direct"===e.type&&e.paymentBrands.includes("BOGUS")))}function yr({paymentMethods:e,hasBogusGateway:t=pr(e),paymentLines:a,storeVaultGuestCvvVerificationEnabled:s=!1,selectedCardRequiresProposalLineCvv:r=!1,selectedCardBrand:n,hasAmexCvvOnlyField:i=fr({paymentLines:a,storeVaultGuestCvvVerificationEnabled:s,selectedCardRequiresProposalLineCvv:r,selectedCardBrand:n})}){return t?new Set(["number"]):i?new Set(["verification_value"]):new Set}function fr({paymentLines:e,storeVaultGuestCvvVerificationEnabled:t=!1,selectedCardRequiresProposalLineCvv:a=!1,selectedCardBrand:s}){return Boolean(a&&"AMEX"===s?.toUpperCase()||t&&e?.some(({method:e})=>e.type===ut.CreditCard&&"AMEX"===e.brand))}function vr(e){return e.replace(/([\d.]+)rem/g,(e,t)=>10*Number(t)/14+"rem")}function br(){const{checkout:{negotiator:e}}=Ae(),{paymentMethods:t}=e.current.fields;return s(()=>{const e=t.value?.filter(e=>e.type===ut.CreditCard&&Boolean(e.expired));return e?e.length:0})}function Cr(){const{i18n:e}=Ae();return{getAccessibilityLabel:t=>{const a="direct"===t.type?t.creditCardLastFourDigits:t.displayLastDigits;return`${Ft(t.brand)} ${e.translate("payment.saved_credit_card_info")} ${a}`}}}function gr(e){return e?e.map(e=>mr(e)):[]}const _r=Rt("CreditCardNetworkContext");function Mr({children:e,paymentMethod:t,publishesCardNetworkDetection:a=!1}){const{checkout:s,source:n,observability:i,userEvents:o}=Ae(),c=S(),u=t?$e(t):c,m=s.cardNetworkSelection.forMethod(u),{bankIdNumber:h,touched:y,...v}=ur(),{networks:b,sdk:C,filled:g}=v,_=p(()=>gr(b),[b]),M=h?.replace(/\s/g,"").length??0,P=M>=6&&v.cardBrand?mr(v.cardBrand):void 0,k=p(()=>_.filter(e=>t?.paymentBrands.includes(e)),[_,t]),A=Boolean(t?.supportsNetworkSelection);f(()=>{a&&m.setDetectedState({networkSelectionEnabled:A,availableNetworks:k,cardBrand:P,numberFilled:Boolean(g.number),bankIdNumberLength:M})},[a,m,A,k,P,g.number,M]);const w=m.selectableBrands.value;!function({displayName:e,paymentBrands:t,paymentMethodIdentifier:a,selectableBrands:s,networkSelectionSupported:r}){const{bankIdNumber:n,networks:i,cardBrand:o}=ur(),{userEvents:l,source:{checkoutSessionIdentifier:c}}=Ae(),[u,m]=d(!1),[h,y]=d(""),v=p(()=>gr(i||(o&&(n?.length??0)>=6?[o]:void 0)),[i,o,n]);f(()=>{if(!n||0===n.length||!c)return;const i={checkoutToken:c,paymentMethodIdentifier:a,displayName:e||"",supportedBrands:t.join(","),detectedBrands:v.join(","),cardIsCobadged:v.length>1,shownBrands:s.join(","),networkSelectorShown:s.length>1&&r};u||(l.monorailEvent({schemaId:"checkout_credit_card_number_interaction/1.1",payload:{...i,eventName:"first_digit_entered"}}),m(!0)),n.length>=6&&v.length>0&&i.shownBrands!==h&&(y(i.shownBrands),l.monorailEvent({schemaId:"checkout_credit_card_number_interaction/1.1",payload:{...i,eventName:"brand_shown_to_buyer"}}))},[a,e,t,v,s,n,l,c,r,h,u,m])}({displayName:t?.name,paymentBrands:t?.paymentBrands??[],paymentMethodIdentifier:t?.paymentMethodIdentifier??"",selectableBrands:w,networkSelectionSupported:t?.supportsNetworkSelection??!1});const E=l(e=>{const t=m.selectedSavedCreditCardBrand.value,a="function"==typeof e?e(t):e;m.setSelectedSavedCreditCardBrand(a)},[m]),I=l(async()=>{const e=m.selectedNetwork.value,t=e?{selected_network:hr(e)}:void 0,a=await C.vaultCard(t);return Sr(o,{checkoutSessionIdentifier:n.checkoutSessionIdentifier??"",selectedNetwork:t?.selected_network,detectedNetworks:b}),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},[m,C,n,b,i,o]),x=l(async e=>{const t=m.selectedNetwork.value,a=t?{selected_network:hr(t)}:void 0,s=await C.vaultCardMultipleTimes(e,a);return Sr(o,{checkoutSessionIdentifier:n.checkoutSessionIdentifier??"",selectedNetwork:a?.selected_network,detectedNetworks:b}),s},[m,C,o,n,b]),D=p(()=>({activePaymentBrand:m.activeBrand.value,binLength:m.bankIdNumberLength.value,paymentMethod:t,detectedNetworks:_,selectableBrands:w,selectedNetwork:m.selectedNetwork.value,selectedSavedCreditCardBrand:m.selectedSavedCreditCardBrand.value,setSelectedNetwork:m.setSelectedNetwork,setSelectedSavedCreditCardBrand:E,vaultCardWithSelectedNetwork:I,vaultCardMultipleTimesWithSelectedNetwork:x}),[m.activeBrand.value,m.bankIdNumberLength.value,m.setSelectedNetwork,m.selectedNetwork.value,m.selectedSavedCreditCardBrand.value,t,_,w,E,I,x]);return r(_r.Provider,{value:D,children:e})}function Pr(){return Ut(_r)}function Sr(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 kr=["CardFieldsFetchFailureError"];function Ar({children:e,publishesCardNetworkDetection:t,directPaymentMethodConfig:a,...s}){const n=b(Se()),{observability:i,checkout:{negotiator:o}}=Ae(),{value:d}=o.current.fields.paymentMethods,c=a??Je(d??[]),u=l(e=>{kr.includes(e.name)?i.log("default_card_fields_provider_unactionable_error","Unactionable error in card fields provider",{error:e}):i.error(e)},[i]);return r(cr,{...s,onError:u,sdkScriptAttributes:n.current,children:r(Mr,{paymentMethod:c,publishesCardNetworkDetection:t,children:e})})}function wr(e){const{shopPay:t,checkout:{negotiator:a}}=Ae(),{value:s}=a.current.fields.paymentMethods,{paymentLines:n}=a.parts,{bankIdNumberSignal:i,installmentMonthsSignal:o}=a.context,{binResolution:d,clearInstallments:l,selectedCardBin:c,expandedVisible:u,collapsedVisible:m}=e.msi,h=u.value,p=m.value,y="server"===d?e.selectedCreditCard.value?.id:void 0;!function({enabled:e,selectedCardId:t}){const{checkout:{identity:a,negotiator:s}}=Ae(),{paymentLines:r}=s.parts,{negotiate:n}=q(),i=ia(),o=b(void 0);f(()=>{if("shopPay"!==a.current.value)return;if(!e||!t)return o.current=void 0,void(r.value=Ot(r.value));if(o.current===t)return;o.current=t;const s=Ke(r.value,"SHOP_PAY"),d=s?.method.walletContent?.creditCardInstallments;r.value=$t(r.value,i({msiEligibleCard:!0,creditCardInstallments:d})),n({silenceViolations:[...Yt]}).catch(()=>{o.current=void 0})},[e,a.current.value,t])}({enabled:p&&!t.session.isLoading.value,selectedCardId:y});const v=b(h);f(()=>{v.current&&!h&&(n.value=l(n.value),o.value=void 0),v.current=h},[h,l,n,o]);const C=b(p);f(()=>{C.current&&!p&&(n.value=l(n.value),o.value=void 0),C.current=p},[p,l,n,o]);const g=c.value,_=e.selectedCreditCard.value?.id;f(()=>{if("client"!==d)return;const e=i.peek();i.value=_===dt&&ca(e,g)?e:g},[d,i,g,_]);const M=Je(s??[]);var P;return{expandedSlot:M&&h?Er({paymentMethod:M,binResolution:d,id:"msiInstallmentsSelect-expanded"}):void 0,collapsedSlot:M&&p?(P=Er({paymentMethod:M,binResolution:d,id:"msiInstallmentsSelect-summary"}),r(ae,{paddingInlineStart:"large-100",children:r(Ar,{onSetFieldErrors:()=>{},children:P})})):void 0}}function Er({paymentMethod:e,binResolution:t,id:a}){return r(sr,"server"===t?{paymentMethod:e,isSelected:!0,isVaultedContext:!0,id:a}:{paymentMethod:e,isSelected:!0,canEditBin:!1,id:a})}function Ir(e,t,a){return!!e&&(0===a.size||[...t].some(e=>!a.has(e.code)))}function xr({renderInSection:e,headingLevel:t=2}){const{i18n:a,shop:{name:i,showTipPayments:o},checkout:{negotiator:d}}=Ae(),{tipLines:l}=d.current.fields,{tipLines:c}=d.parts,u=s(()=>{const e=l.value?.[0]??c.value[0];return o||Boolean(e&&e.amount.amount>0)}),m=a.translate("tips.description",{shop_name:i}),h=r(ae,{paddingBlockEnd:"base",children:[r(oe,{level:t,children:a.translate("tips.title")}),r(N,{blockSize:"base"}),r(ke,{contentDisplay:"block",inlineSize:"100%",children:m}),r(n,{when:u,children:[r(N,{blockSize:"small-200"}),r(ke,{contentDisplay:"block",inlineSize:"100%",children:a.translate("tips.custom_label")}),r(N,{blockSize:"small-100"}),r(ke,{contentDisplay:"block",inlineSize:"33%",children:a.translate("tips.add_tip")})]})]});return e?r(ie,{accessibilityLabel:a.translate("tips.title"),children:h}):h}const Dr=a({displayName:"Tipping",renderLoading:e=>r(xr,{...e}),useError:function(e){const{observability:t}=Ae();f(()=>{e&&t.error(e,{metadata:{tips:{component:"Tips",failure:"lazy_load"}}})},[e,t])},load:()=>e(()=>import("./6a7f8a66.gvBR5eQy.js"),__vite__mapDeps([42,1,14,2,3,4,5,15,16,17,18,12,10,19,30,26,31,43,44,45,46]))});export{Ks as $,Ta as A,Pr as B,Xa as C,Ar as D,fr as E,mr as F,Vs as G,vr as H,Cr as I,Ga as J,za as K,as as L,sr as M,Ca as N,ss as O,Ls as P,rs as Q,br as R,Qs as S,Dr as T,_a as U,Ws as V,fa as W,ha as X,Is as Y,ws as Z,Ss as _,Zs as a,Gs as a0,Rs as a1,Us as a2,va as a3,ja as a4,Hs as b,_s as c,wr as d,ua as e,xs as f,er as g,Ps as h,Ds as i,yr as j,Aa as k,pr as l,ur as m,Js as n,wa as o,Na as p,Da as q,La as r,Ba as s,Ir as t,Ms as u,Ea as v,Va as w,Ia as x,xa as y,Fa as z};