1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["c0b4c58b.BzZIU4xx.js","2c1ab0fe.Bywc2Brn.js","9dba8418.ogFVeXB5.js","app.DWJ9FfA1.js","assets/app.BuSMBobh.css","assets/paypal-express-utilities.BhV0n1qN.css","633ac094.BNs0QSnR.js","24fcbaf6.Bur2uRnB.js","ca3e798e.Dc9DtEXz.js","e77d135d.Dz0RetrO.js","60a453ce.CcyvSWbx.js","ca5e9c49.GLwCPRLK.js","164ad2e3.CZ86Jn5i.js","d0bb51ec.DFDQ8Mc_.js","f67abd2c.LtwWKIr5.js","e12db40c.B9ahJFAB.js","assets/hydrate.1qxw0_8N.css","5ef0d995.CYRqwtKM.js","2bac2c53.BWpgDRdR.js","d8ca7400.CQoQh8KD.js","efa0389a.DH9Ee_M-.js","22345fd4.gEtcWjYq.js","assets/Choice.B7lVAtpz.css","33d2e4fc.BePxI6ur.js","assets/NumberField.CRpcZnVJ.css","dae24aab.DshQXsWO.js","assets/Tips.D3S9_XMm.css","82de4790.Dbuzu6jz.js","ac5a19ff.BZSGZdnW.js","598fef4e.DSAd8e9l.js","assets/PaymentIcon.gzvCNwz_.css","e77f7fe0.Bb-t4Dg5.js","4b1c22b7.Ds2WGmWm.js","assets/PaymentLine.DT05kVlY.css","a422df8c.B9kUsb7g.js","assets/EmptyState.BEvzDDvy.css","cc6ff67d.b-RPC7-m.js","08a3b809.amBLe9xd.js","d25d1b95.BebpfFB8.js","bf513f9c.wW-N-9yS.js","e39bc11c.BD41VQ04.js","7a8217fd.D7XvILAP.js","8599b02a.BwMQ3GGP.js","assets/useShopPayProgressIntercepts.CIy8uDiZ.css","cf29e63b.B0ZvKJTY.js"])))=>i.map(i=>d[i]); 2import{_ as e,S as t}from"./app.DWJ9FfA1.js";import{i as a,u as s,k as r,S as n,w as i,h as o,G as d,z as l,q as c,y as u,I as m,a2 as h,n as p,T as y,x as f,g as v,p as b,o as C,L as g,j as _,_ as M,X as P,ak as S}from"./2c1ab0fe.Bywc2Brn.js";import{H as k,d as A,au as E,b as w,i as I,aM as x,t as L,bx as D,L as N,ft as B,v as T,fo as F,a1 as V,S as R,f as U,gC as O,I as $,gD as Y,cv as q,gE as j,a7 as G,s as z,ak as K,fD as H,U as Q,gF as W,gG as X,a9 as J,aa as Z,gH as ee,ab as te,bJ as ae,j as se,aK as re,da as ne,bl as ie,aT as oe,A as de,c as le,bT as ce,eR as ue,bB as me,bC as he,bD as pe,gI as ye,gJ as fe,gK as ve,gL as be,gM as Ce,gN as ge,gO as _e,gP as Me}from"./164ad2e3.CZ86Jn5i.js";import{c as Pe,a5 as Se,cE as ke,dl as Ae,fR as Ee,fL as we,bs as Ie,hn as xe,ho as Le,bw as De,hp as Ne,bg as Be,hq as Te,hr as Fe,bO as Ve,cD as Re,hs as Ue,bl as Oe,as as $e,fE as Ye,N as qe,hi as je,ht as Ge,hh as ze,fy as Ke,hj as He,T as Qe,aF as We,gi as Xe,hu as Je,a2 as Ze,v as et,dk as tt,a8 as at,hv as st,hg as rt,hw as nt,hx as it,K as ot,hy as dt,hz as lt,hA as ct,hB as ut,hC as mt,bL as ht,aa as pt,c1 as yt,aM as ft,hD as vt,hE as bt,aO as Ct,hF as gt,hG as _t,hH as Mt,hI as Pt,aK as St,dj as kt,hJ as At,Z as Et,hK as wt,hL as It,hM as xt,hN as Lt,d_ as Dt,d$ as Nt,bd as Bt,ai as Tt,u as Ft,hO as Vt,cy as Rt,be as Ut}from"./9dba8418.ogFVeXB5.js";import{u as Ot,g as $t}from"./ac5a19ff.BZSGZdnW.js";import{P as Yt}from"./598fef4e.DSAd8e9l.js";import{a as qt}from"./e77f7fe0.Bb-t4Dg5.js";import{b as jt,E as Gt}from"./a422df8c.B9kUsb7g.js";import{a as zt,c as Kt,b as Ht,u as Qt}from"./cc6ff67d.b-RPC7-m.js";import{S as Wt,u as Xt}from"./bf513f9c.wW-N-9yS.js";import{s as Jt,n as Zt}from"./e39bc11c.BD41VQ04.js";import{u as ea,i as ta,S as aa,c as sa}from"./7a8217fd.D7XvILAP.js";import{s as ra}from"./cf29e63b.B0ZvKJTY.js";import{a as na,b as ia}from"./efa0389a.DH9Ee_M-.js";import{s as oa}from"./d25d1b95.BebpfFB8.js";const da=a({displayName:"PostPurchaseShouldRender",suspense:!1,load:()=>e(()=>import("./c0b4c58b.BzZIU4xx.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]))});function la({renderInSection:e,hideHeading:t,headingLevel:a=2}){const{i18n:o,shop:{name:d,showTipPayments:l},checkout:{negotiator:c}}=Pe(),{tipLines:u}=c.current.fields,{tipLines:m}=c.parts,h=r(()=>{const e=u.value?.[0]??m.value[0];return l||Boolean(e&&e.amount.amount>0)}),p=o.translate("tips.description",{shop_name:d}),y=s(w,{paddingBlockEnd:"base",children:[!t&&s(n,{children:[s(k,{level:a,children:o.translate("tips.title")}),s(A,{blockSize:"base"})]}),s(E,{contentDisplay:"block",inlineSize:"100%",children:p}),s(i,{when:h,children:[s(A,{blockSize:"small-200"}),s(E,{contentDisplay:"block",inlineSize:"100%",children:o.translate("tips.custom_label")}),s(A,{blockSize:"small-100"}),s(E,{contentDisplay:"block",inlineSize:"33%",children:o.translate("tips.add_tip")})]})]});return e?s(I,{accessibilityLabel:o.translate("tips.title"),children:y}):y}const ca=a({displayName:"Tips",renderLoading:e=>s(la,{...e}),useError:function(e){const{observability:t}=Pe();o(()=>{e&&t.error(e,{metadata:{tips:{component:"Tips",failure:"lazy_load"}}})},[e,t])},load:()=>e(()=>import("./d8ca7400.CQoQh8KD.js"),__vite__mapDeps([19,1,12,2,3,4,5,13,14,10,15,16,20,21,22,23,24,25,26]))}),ua=T("AmazonPayChangePaymentLinkButton");function ma(){const{i18n:e,observability:t}=Pe(),{inMemoryAmazonPayParts:{sdkStatus:a}}=Se(),n=r(()=>{const e=a.value;return e.status===x.Available?e.sdk:void 0}),o=Ot(),d=L(void 0,ua),{hasError:l}=D(ke),c=e.translate("vaulted.change_button");return o.value?s(i,{when:n,children:e=>s(N,{onClick:()=>{try{const{checkout_session_id:t}=B(o.value.method.walletParams);e.Pay.changePaymentMethod({amazonCheckoutSessionId:t,isDeclined:l})}catch(a){t.error(new ha(`Error on changing buyer payment method. Details: ${a}`,{cause:a}))}},id:d,children:c})}):null}
2class ha extends Error{constructor(){super(...arguments),this.name="AmazonPayChangePaymentLinkError"}}const pa=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 ya({brand:e,descriptor:t}){const{hasError:a}=F(),r=e?.toLowerCase().replace(/\s+/g,"_")??"",i=pa.get(r)??"generic";return s(R,{direction:"inline",children:[a&&s(n,{children:[s(V,{tone:"critical",type:"alert-circle"}),s(A,{display:"inline",inlineSize:"small-400"})]}),s(qt,{icon:s(Yt,{type:i}),details:t})]})}function fa(){const{i18n:e,checkout:{negotiator:t}}=Pe(),a=t.parts.purchaseOrderNumber.value;if(!a)return null;const r=`${e.translate("payment.purchase_order_number.title")} #${a}`;return s(U,{children:r})}const va=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:r}=Pe(),n=O().value.length,i=e=>{switch(e){case"giftCard":return r.translate("payment.order_covered_by_gift_cards_notice",{count:n});case"freeOrder":return r.translate("payment.free_order_notice_html");case"storeCredit":return r.translate("payment.order_covered_by_store_credit_notice");case"redeemables":return r.translate("payment.order_covered_by_redeemables_notice");case"deferred":return r.translate("payment_gateway.deferred_payment_label");default:d(e)}};return a?s(R,{gap:"base",children:[s($,{children:i(t)}),s(fa,{})]}):e?s(Gt,{children:s(jt,{children:i(t)})}):s("div",{className:"agRve",children:s(R,{gap:"large-200",alignItems:"center",children:[s(va,{className:"FiV0Z",focusable:"false","aria-hidden":"true"}),s(jt,{children:s($,{children:i(t)})})]})})}class Ca extends t{constructor(){super(...arguments),this.name="AmazonPayMissingPaymentPreferencesError"}}function ga(){const{checkout:{negotiator:e}}=Pe(),t=e.parts.paymentLines;return r(()=>{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 Ca("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 _a={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}}"},Ma=Object.freeze({name:null,number:null,verification_value:null,expiry:null,issue_date:null,issue_number:null});var Pa=(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))(Pa||{});
2const Sa={baseMessage:null,fieldErrors:Ma,blockedByDuplicateAutopayCard:!1};function ka(){const{i18n:e,observability:t}=Pe(),[a,s]=l(Sa),r=c((e,a)=>{t.counter({name:e,value:1,attributes:{errorField:a.field.join("-"),errorMessage:a.message}})},[t]),n=c(t=>{if(!t||!t.length)return void s({baseMessage:e.translate("credit_card_form.generic_card_error"),fieldErrors:Ma,blockedByDuplicateAutopayCard:!1});const a={...Ma};let n=null;t.forEach(t=>{switch(r("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(n=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(n=e.translate("payment.generic_incorrect_card_info"));if("three_d_secure_authentication_failed"===t.message)return void(n=e.translate("payment_errors.three_d_secure_failed_payment_method"));if("billing_address_missing"===t.message)return void(n=e.translate("payment_errors.payment_method_billing_address"))}"too_many_credit_cards"!==t.message?(n=e.translate("credit_card_form.generic_card_error"),r("save_credit_card_error_unhandled",t)):n=e.translate("credit_card_form.max_cards_reached",{max_cards:Ae})}
2),s({baseMessage:n,fieldErrors:a,blockedByDuplicateAutopayCard:!1})},[e,r]),i=c(()=>{t.counter({name:"save_credit_card_blocked_by_autopay",value:1}),s({baseMessage:null,fieldErrors:Ma,blockedByDuplicateAutopayCard:!0})},[t]),o=c(()=>{s(Sa)},[]),d=c(e=>{t.counter({name:"save_credit_card_vaulting_failure",value:1,attributes:{reason:e}}),n("missing_billing_address"===e?[{field:["creditCard","base"],message:"billing_address_missing"}]:void 0)},[t,n]);return{creditCardErrors:a,setCreditCardErrors:n,clearCreditCardErrors:o,failCardVaulting:d,blockDuplicateAutopayCard:i}}function Aa(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 wa(e){return"APPLE_PAY"===e.paymentMethod}function Ia(e){return"CUSTOM_ONSITE"===e.paymentMethod}function xa(e){return"SHOP_PAY"===e.paymentMethod}function La(e){return"SHOP_PAY_INSTALLMENTS"===e.paymentMethod}function Da(e){return"PAYPAL"===e.paymentMethod}function Na(e){return"BANK"===e.paymentMethod}function Ba(e){return"DEFERRED"===e.paymentMethod}function Ta(e){return"OFFSITE"===e.paymentMethod||"MANUAL_PAYMENT"===e.paymentMethod||"CUSTOM_MANUAL_PAYMENT"===e.paymentMethod||"PAYMENT_ON_DELIVERY"===e.paymentMethod}function Fa(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=we(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:d(e)}return{paymentMethodName:a,paymentBrands:s}}const Va={markBuyerHasActed:!1,updateSelectedCardBin:!1,selectedCardFirstDigits:void 0,preserveExistingBinPrefix:!1,claimMsiBin:!1,claimedMsiBin:void 0,shouldNegotiate:!1};function Ra(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 Ua(e){switch(e.paymentMethod){case"CREDIT_CARD":return{id:e.id,paymentMethod:"CREDIT_CARD",paymentAttributes:Ra(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 Oa(e,t){switch(e.paymentMethod){case"CREDIT_CARD":return t.find(t=>Ie(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:d(e)}}class $a extends Error{constructor(){super(...arguments),this.name="EmptySessionIdError"}}class Ya extends Error{constructor(){super(...arguments),this.name="BuyerDetailsRefreshError"}}class qa{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:r,isCreditCardDisabled:n,msiEligibilityByCardId:i,hasSellingPlan:o}=e;this.availablePaymentMethods=u(r),this.shopPayAvailableUserStoredPaymentMethods=m(()=>{const e=this.availablePaymentMethods.value;return e.length?je(t.user.paymentMethods.value,e):[]}),this.availableUserStoredPaymentMethods=m(()=>this.shopPayAvailableUserStoredPaymentMethods.value.map(Ua)),this.promotedMethods=m(()=>t.session.promotedPaymentMethods.value.map(Ua)),this.selectedPaymentMethod=m(()=>{const e=t.session.selectedPaymentMethod.value;return e?Ua(e):void 0}),this.selectedCreditCard=m(()=>{const e=t.session.selectedPaymentMethod.value;return e&&Ie(e)?Ra(e.paymentAttributes):void 0}),this.shopPayPaymentMethods=m(()=>{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(Ie).map(e=>({method:e,isValidForCheckout:r.includes(e),isExpired:e.paymentAttributes.expired,isDisabled:n(e.paymentAttributes)})),c=a?[]:Ge({negotiatedPaymentMethods:i,userStoredPaymentMethods:e,paymentMethodHistory:d,isApplePayAvailable:s}),u=[...l.sort((e,t)=>
2ze(e.method,t.method)),...c.sort((e,t)=>ze(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})=>!!Ie(e)||!(!p||Ie(p)||e.id!==p.id)||!!y.has(e.id)||Ke(e))}),this.paymentMethods=m(()=>this.shopPayPaymentMethods.value.map(({method:e,...t})=>({...t,method:Ua(e),canEdit:Ie(e),canDelete:Ie(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=>Aa(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 d=m(()=>{const e=He(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:xe,expandedVisible:m(()=>!!d.value&&"SHOPIFY_INSTALLMENTS"!==t.session.paymentMethodOption.value?.name),collapsedVisible:m(()=>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:Va};const i=Oa(e,s.user.paymentMethods.value);if(!i)return{status:"not-handled"};if("buyer"===t&&this.recordPaymentMethodSelected(e),Aa(e)){const t=this.selectCreditCard({id:e.paymentAttributes.id});return Le(i,s.user.paymentMethods.value,Ee(i,this.availablePaymentMethods.value))&&this.#e(i,a),await t,{status:"handled",effects:Va}}const o=Ee(i,this.availablePaymentMethods.value);return Le(i,s.user.paymentMethods.value,o)&&this.#e(i,"buyer"===t?{...a,buyerInitiated:!0}:a),(De(i)||Ne(i)||Be(i)||Te(i))&&await r({billingAddress:s.session.selectedBillingAddress.value?.address,fallbackPhoneNumber:s.user.phoneNumber.value},n.value),{status:"handled",effects:Va}}async promoteSelectedPaymentMethod(e){const{shopPay:t}=this.deps,a=Fe(e,t.user.paymentMethods.value);return a&&(t.session.selectPaymentMethod(a),t.session.unstable_promotePaymentMethod(a)),{status:"handled",effects:{...Va,selectByBuyerKey:Ve(e)}}}getSavedCardActiveSubscriptionsLookup(e){const t=this.deps.shopPay.user.paymentMethods.value.filter(Ie).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(_a,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(_a,{variables:a});return e?.creditCardActiveSubscriptions?.nodes??[]}}}async selectCreditCard({id:e}){const{shopPay:t}=this.deps,a=t.user.paymentMethods.value.filter(Ie).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(Ie).map(e=>e.paymentAttributes).find(t=>
2t.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=Re();return ra({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 $a("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(Ie).map(e=>e.paymentAttributes).find(t=>t.id===e)?.uuid;if(!l)return{status:"failed"};const c=a.session.selectedPaymentMethod.value,u=c&&Ie(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(Ie).map(e=>e.paymentAttributes).filter(e=>e.uuid!==l);if(a.user.removeCreditCard(e),d(),u!==l)return{status:"success"};const p=Ue(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 Aa(e)||Boolean(e.lastUsedAt)}(e))?.method;if(e){const t=Oa(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{observability:t,userEvents:a,source:s,checkout:r,shop:n}=this.deps,i=e.paymentMethod.toLowerCase(),{paymentMethodName:o,paymentBrands:d}=Fa(e,this.availablePaymentMethods.value);t.counter({name:"payment_method_selected",value:1,attributes:{payment_method_type:i,payment_method_name:o,payment_brands:d,location:"shop_pay_payment_selector",is_mobile:Oe()}}),a.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...$e(s,r,n),action:"payment_method_selected",paymentMethodName:o}})}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:["",Pa.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 Ya("Failed to refresh Shop Pay buyer details")),!1}}async selectCreditCardAndSetPaymentLine({id:e}){const t=void 0!==$t(this.deps.proposedPaymentLines.value),a=this.selectCreditCard({id:e});if(t)return a;const{shopPay:s}=this.deps,r=s.session.selectedPaymentMethod.value;r&&Ie(r)&&r.paymentAttributes.id===e&&Le(r,s.user.paymentMethods.value,Ee(r,this.availablePaymentMethods.value))&&this.#e(r),await a}#e(e,t){const{shopPay:a,setPaymentLine:s,observability:r}=this.deps;p(()=>{a.session.selectPaymentMethod(e);const n=Ye({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=>!qe([e],"SHOP_PAY"))}}function ja(){const e=Ga(),{checkout:{negotiator:t}}=Pe(),{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}}=Pe(),a=e.layout.isOnePage.value,{paymentMethods:s}=t.current.fields;return r(()=>!!a&&Boolean(Qe(s.value).length))}const za={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}"},Ka={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}"},Ha={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 Qa={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 Wa(e){const{geolocation:t}=q(),{shopPay:a,checkout:s}=Pe(),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 y(()=>tt({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 Xa={id:"563e8a86083a6c9ad5bd44d3a4db471e3a9919052512d2745d267074d97420fd",type:"mutation",name:"DeleteVaultedCreditCard",source:""},Ja={id:"d1f468f7d6684d3133e47cef5cf1ef67ccd2bd916b53203708d85ac3175f1bd0",type:"mutation",name:"UpdateCustomerCreditCard",source:""};class Za extends Error{constructor(e){super("Failed to update customer credit card payment method",e),this.name="UpdateCustomerCreditCardPaymentMethodError"}}class es extends Error{constructor(e){super("Failed to delete customer credit card payment method",e),this.name="DeleteCustomerCreditCardPaymentMethodError"}}async function ts({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(Ja,{variables:{customerCreditCardModificationInput:{token:r,defaultPaymentMethod:s,billingAddress:{streetAddress:at
2(t,{extendedAddressMode:a})}}}});if(!i?.modifyCustomerCreditCardPaymentMethod||o)throw new Za({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 as({graphql:e,token:t,genericError:a}){if(!t)return{token:void 0};try{const{data:s,error:r}=await e.mutate(Xa,{variables:{token:t}});if(!s?.deleteCustomerCreditCardPaymentMethod||r)throw new es({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 ss({userEvents:e,shopId:t,checkoutSessionIdentifier:a,card:s}){e.monorailEvent({schemaId:"checkout_vaulted_payment_method_selected/1.0",payload:{shopId:parseInt(et(t),10),checkoutSessionIdentifier:a||"",paymentMethodId:parseInt(et(s.id),10),paymentInstrumentAccessorId:-1}})}class rs 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 ns({observability:e,managerName:t,methodName:a,identity:s,deployStage:r,isLocalDevelopment:n}){if(n||"production"!==r&&"canary"!==r)return;const i=new rs({managerName:t,methodName:a,identity:s,deployStage:r,isLocalDevelopment:n});e.error(i,{severity:"warning"})}const is={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:r}=s.fields,n=s.fields.paymentMethodHistory??u([]);this.availablePaymentMethods=m(()=>r.value??[]),this.promotedMethods=e.paymentMethodPromotions.promoted,this.customerCreditCards=m(()=>it(this.availablePaymentMethods.value)),this.selectableCustomerCreditCards=m(()=>Qe(this.availablePaymentMethods.value)),this.selectablePaypalBillingAgreements=m(()=>(e.displayablePaymentMethods?.value??this.availablePaymentMethods.value).filter(e=>e.type===ot.PayPal)),this.selectableCustomerBanks=m(()=>this.availablePaymentMethods.value.filter(e=>"bank"===e.type&&e.availableInstruments.length>0)),this.nonCardKnownPaymentMethods=m(()=>dt({paymentMethodHistory:n.value??[],availablePaymentMethods:e.displayablePaymentMethods?.value??this.availablePaymentMethods.value})),this.availableUserStoredPaymentMethods=m(()=>[...ls([ds({card:this.newCard.value,billingAddress:a.billingAddress.value})]),...this.selectableCustomerCreditCards.value.map(e=>lt(e,{cvvVerificationEnabled:this.deps.storeVaultGuestCvvVerificationEnabled})),...this.selectablePaypalBillingAgreements.value.map(ct),...hs(this.selectableCustomerBanks.value.map(ut),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||Aa(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=>!Aa(e)&&!Ba(e))||this.availableUserStoredPaymentMethods.value.find(Ba)}),this.proposedSelectedPaymentMethod=m(()=>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(Ba);if(e)return e;continue}if(cs(n)){const e=t.filter(Aa).find(e=>e.id===n.method.token);if(e)return e;continue}if(us(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=ms(n,t,a);if(e)return e}}(a.paymentLines.value,this.availableUserStoredPaymentMethods.value,this.availablePaymentMethods.value,ds({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===rt),r=[...e.filter(({method:e})=>e.id!==rt)].sort((e,t)=>
2ze(e.method,t.method)),n=[...t].sort((e,t)=>ze(e.method,t.method)),i=r.filter(ps),o=n.filter(ps),d=i.find(({method:e})=>Aa(e)&&e.paymentAttributes.defaultPaymentMethod),l=[i[0],o[0]].filter(e=>void 0!==e).sort((e,t)=>ze(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?[...ls([s]),c,...r.filter(e=>e!==c),...n.filter(e=>e!==c)]:[...ls([s]),...r,...n]}({cardItems:[...ls([ds({card:this.newCard.value,billingAddress:a.billingAddress.value})]),...this.customerCreditCards.value.map(e=>lt(e,{cvvVerificationEnabled:this.deps.storeVaultGuestCvvVerificationEnabled}))].map(e=>({method:e,isValidForCheckout:!0,isExpired:e.paymentAttributes.expired,isDisabled:!1,...ys({identity:this.deps.identity,storeVaultEnabled:this.deps.storeVaultEnabled,card:e})})),nonCardItems:this.availableUserStoredPaymentMethods.value.filter(e=>!Aa(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 Aa(e)?e.paymentAttributes:void 0}),this.cardPaymentMethods=m(()=>this.paymentMethods.value.filter(e=>Aa(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=He(this.availablePaymentMethods.value);if(!Y(e))return!1;const t=this.selectedCreditCard.value;return!!t&&a.paymentLines.value.some(e=>t.id===rt?"direct"===e.method.type:e.method.type===ot.CreditCard&&e.method.token===t.id)});this.msi={binResolution:"client",selectedCardBin:m(()=>{const e=this.selectedCreditCard.value;if(e)return e.id===rt?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=st(e,null);return t?(this.deps.paymentMethodPromotions.promote(t),this.selectPaymentMethod(t,"buyer")):{status:"handled",effects:{...Va,selectByBuyerKey:Ve(e)}}}canShowAsGuestCheckoutMethod(){return!1}async selectPaymentMethod(e,t="programmatic"){if(!e)return{status:"not-handled"};if(!Aa(e)){const a=Ee(e,this.availablePaymentMethods.value);if(!a)return{status:"not-handled"};const s=Ve(a);return"buyer"===t?{status:"handled",effects:{...Va,selectByBuyerKey:s}}:(this.deps.setPaymentLine(s),{status:"handled",effects:Va})}if("buyer"===t)return this.selectCreditCardByBuyer({paymentMethod:e});if(e.id===rt)return this.deps.setPaymentLine(rt),{status:"handled",effects:Va};const a=this.selectableCustomerCreditCards.value.find(t=>t.token===e.paymentAttributes.id);return a?(this.deps.setPaymentLine(nt(a)),{status:"handled",effects:Va}):{status:"not-handled"}}async deleteCreditCard({id:e}){if(e===rt){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(nt(t));else{const t=this.autoselectTarget.value,a=t?Ee(t,this.availablePaymentMethods.value):void 0;a?this.deps.setPaymentLine(Ve(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=Aa(t)&&t.id===e,s=this.selectableCustomerCreditCards.value.find(t=>t.token!==e),r=await as({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(nt(s)),{status:"success",shouldNegotiatePaymentMethods:!0}):{status:"failed",bannerError:r.error}}async updateCreditCard({id:e,billingAddress:t,defaultPaymentMethod:a=!1}){const s=await ts({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"),is}async completeCreditCardVerificationAndVault(){return this.reportUnexpectedUse("completeCreditCardVerificationAndVault"),is}dispose(){}async selectCreditCardByBuyer({paymentMethod:e}){let t,a,s;if(e.id===rt){const e=this.newCard.value;if(!e)return{status:"not-handled"};t=rt,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=nt(a),s=a.firstDigits,ss({userEvents:this.deps.userEvents,shopId:this.deps.shopI
2d,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:{...Va,selectByBuyerKey:t,...a?{selectByBuyerPaymentMethod:a}:{},updateSelectedCardBin:!0,selectedCardFirstDigits:s,preserveExistingBinPrefix:e.id===rt,claimMsiBin:this.deps.isMsiAvailable,claimedMsiBin:this.deps.isMsiAvailable?s:void 0,shouldNegotiate:!0}}}reportUnexpectedUse(e){ns({...this.deps,managerName:"CustomerPaymentMethodManager",methodName:e})}}function ds({card:e,billingAddress:t}){if(e?.brand&&e.creditCardLastFourDigits)return{id:rt,paymentMethod:"CREDIT_CARD",paymentAttributes:{id:rt,brand:e.brand,expired:!1,expiryMonth:0,expiryYear:0,lastDigits:e.creditCardLastFourDigits,name:e.cardholderName,billingAddress:{address:t??{}}},lastUsedAt:null}}function ls(e){return e.filter(e=>void 0!==e)}function cs(e){return e.method.type===ot.CreditCard}function us(e){return e.method.type===ot.PayPal}function ms(e,t,a){const s=Ve(e.method);return t.find(e=>{if(Aa(e))return!1;const t=Ee(e,a);return!!t&&s===Ve(t)})}function hs(...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 ps(e){return e.isValidForCheckout&&!e.isExpired&&!e.isDisabled}function ys({identity:e,storeVaultEnabled:t,card:a}){if(a.id===rt)return vs;if("businessCustomer"===e)return fs;const{paymentAttributes:s}=a;return t?s.expired?s.deletable?{canEdit:!1,canDelete:!0,canSetDefault:!1,isDefault:Boolean(s.defaultPaymentMethod)}:fs:{canEdit:!0,canDelete:Boolean(s.deletable),canSetDefault:!0,isDefault:Boolean(s.defaultPaymentMethod)}:fs}const fs={canEdit:!1,canDelete:!1,canSetDefault:!1,isDefault:!1},vs={canEdit:!1,canDelete:!0,canSetDefault:!1,isDefault:!1},bs={status:"failed"};class Cs{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){ns({...this.unexpectedUseOptions,managerName:"FallbackPaymentMethodManager",methodName:e})}}function gs({enableAutoSelect:e=!0}={}){const{source:t,environment:a,checkout:s,shop:r,i18n:n,observability:i,userEvents:d,shopPay:l,graphql:{coreGraphql:u,shopPayGraphql:m}}=Pe(),h=s.identity.current.value,p=r.hasFlagEnabled(mt),v=null!=a.devMode,b=function(){const{checkout:{address:{extendedAddressMode:e}},graphql:{shopPayGraphql:t},source:a}=Pe(),s=We({source:a});return c(async(a,r,n,i,o=s)=>{const{data:d,error:l}=await t.mutate(za,{variables:{billingAddress:Xe(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 Je(c.userErrors)?{status:"blocked_by_autopay"}:c.userErrors.length>0?{status:"failed",errors:c.userErrors}:c.threeDSecureAuthenticationRequest?{status:"requires_redirect",threeDSecureAuthenticationRequest:c.threeDSecureAuthenticationRequest}
2:{status:"success",creditCard:c.creditCard?Ze(c.creditCard):void 0}},[s,e,t])}(),C=function(){const{checkout:{address:{extendedAddressMode:e}},graphql:{shopPayGraphql:t},source:a}=Pe(),s=We({source:a});return c(async(a,r,n,i=s)=>{const{data:o,error:d}=await t.mutate(Ka,{variables:{verificationId:r,billingAddress:Xe(a,e),origin:i,nickname:n}});if(d||null==o||null==o.creditCardCompleteVerificationAndVault)return{status:"failed"};const{creditCardCompleteVerificationAndVault:l}=o;return Je(l.userErrors)?{status:"blocked_by_autopay"}:l.userErrors.length>0?{status:"failed",errors:l.userErrors}:{status:"success",creditCard:l.creditCard?Ze(l.creditCard):void 0}},[s,e,t])}(),g=function(){const{graphql:{shopPayGraphql:e},source:t}=Pe(),a=We({source:t});return c(async(t,s,r,n=a)=>{const{data:i,error:o}=await e.mutate(Ha,{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])}(),_=function(){const{graphql:{shopPayGraphql:e},source:t,shop:{myshopifyDomain:a,id:s},shopPay:{config:r}}=Pe(),{checkoutSessionIdentifier:n}=t,i=We({source:t}),{redirectSource:o}=r;return c(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(Jt,{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:et(s),redirectSource:o},{cache:!1});return r||null==t||null==t.checkoutSession||null==t.checkoutSession.user?{status:"failed"}:Zt(t)},[n,i,o,s,a,e])}(),M=function(){const{checkout:{address:{extendedAddressMode:e}},graphql:{shopPayGraphql:t},source:a}=Pe(),s=We({source:a});return c(async(a,r,n,i,o,d=s)=>{const{data:l,error:c}=await t.mutate(Qa,{variables:{id:r,uuid:n,billingAddress:Xe(a,e),origin:d,nickname:o,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?Ze(u.creditCard):void 0}},[s,e,t])}(),P=We({source:t}),S=Wa(),{paymentLines:k}=s.negotiator.parts,A=ja(),{buyerHasActedSignal:E,newCardSignal:w}=s.negotiator.context,I=f(Wt),x=l.user.phoneNumber.value,L=zt(),D=l.session.isInstallmentsSelected.value,N=Kt({isApplePayAvailable:L.value}),B=ht(),{creditCardDisabled:T}=ea(),F=Xt(),{updateCheckoutAddress:V}=Ht(),[,R]=Qt({allowPreselect:!1}),U=He(s.negotiator.current.fields.paymentMethods.value??[]),O=Y(U),$=pt(),{eligibilityByCardId:q}=yt(aa),j=c(()=>{I&&(I.cashbackState.stale.value=!0)},[I]),G=y(()=>({checkoutIdentifier:t.checkoutSessionIdentifier??"",checkoutVersion:P,shopId:et(r.id),shopifyDomain:r.myshopifyDomain}),[t.checkoutSessionIdentifier,r.id,r.myshopifyDomain,P]),z=y(()=>"shopPay"===h?new qa({shopPay:l,negotiatedPaymentMethods:s.negotiator.current.fields.paymentMethods,installmentsPaymentMethodSelected:D,isApplePayAvailable:L.value,filteredNegotiatedPaymentMethods:N.value,isCreditCardDisabled:T,setPaymentLine:R,updateCheckoutAddress:V,shippingRequired:s.isShippingRequired,i18n:n,observability:i,userEvents:d,source:t,checkout:s,shop:r,createCreditCard:b,deleteCreditCard:g,updateCreditCard:M,completeCreditCardVerification:C,refreshBuyerDetails:_,markShopCashStatesStale:j,shopPayGraphql:m,emptyAddress:S,proposedPaymentLines:k,checkoutContext:G,fallbackPhoneNumber:x,paymentRequiredMethod:F.value,msiEligibilityByCardId:q,hasSellingPlan:$}):"customerAccount"===h||"businessCustomer"===h?new os({proposal:s.proposal,newCard:A,displayablePaymentMethods:B,paymentMethodPromotions:s.paymentMethodPromotions,setPaymentLine:R,isMsiAvailable:O,shopId:r.id,checkoutSessionIdentifier:t.checkoutSessionIdentifier,storeVaultEnabled:r.storeVaultEnabled,storeVaultGuestCvvVerificationEnabled:r.storeVaultGuestCvvVerificationEnabled,graphql:u,extendedAddressMode:s.address.extendedAddressMode,i18n:n,observability:i,userEvents:d,identity:h,deployStage:a.deployStage,isLocalDevelopment:v}):new Cs({observability:i,identity:h,deployStage:a.deployStage,isLocalDevelopment:v}),[h,a.deployStage,v,l,D,L.value,N.value,B,T,O,R,V,s,i,d,t,r,n,u,m,b,g,_,M,C,j,S,k,A,G,x,F.value,q,$]);o(()=>()=>z.dispose(),[z]);const K=z.selectedPaymentMethod.value,H=z.paymentMethods.value,Q=z.availablePaymentMethods.value,W=z.availableUserStoredPaymentMethods.value,X=k.value.some(e=>"direct"===e.method.type);o(()=>{if(!e)return;if("shopPay"!==h)return;if(z.selectedPaymentMethod.peek()!==K||z.paymentMethods.peek()!==H)return;if(K&&function({selected:e,paymentMethods:t,availablePaymentMethods:a}){return Boolean(Ee(e,a)||Aa(e)&&t.some(({method:t})=>t.paymentMethod===e.paymentMethod&&t.id===e.id))}({selected:K,paymentMethods:H,availablePaymentMethods:Q}))return;if(X)return;const a=H.filter(({isValidForCheckout:e})=>e).sort((e,t)=>ze(e.method,t.method)).map(({method:e})=>e),n=function(e){for(const t of e){if(!Aa(t))return t;if(!t.paymentAttributes.expired)return t}return e[0]}(a);n&&Aa(n)&&n.paymentAttributes.expired&&d.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.1",payload:{...$e(t,s,r),action:"final_payment_method_expired_after_merchant_filter"}});const o=n?Oa(n,l.user.paymentMethods.value):void 0;if(o)l.session.selectPaymentMethod(o);else{const e=p?"unavailable":"explicit",s=l.session.clearPaymentMethod(e),r=l.user.creditCards.peek().length;s&&r>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:r,listed_method_count:H.length,valid_for_checkout_count:a.length,negotiated_direct_present:Boolean(U)})}},[e,Q,W,s,h,U,i,d,z,H,p,K,r,l.session,l.user.creditCards,l.user.paymentMethods.value,t,X]);const J=E.value,Z=Boolean(w.value),ee=z instanceof os?z.autoselectTarget.value:void 0,te=z instanceof os?z.proposedSelectedPaymentMethod.value:void 0,ae=k.value[0],se=ae?.method.type,re=ta(ae);return o(()=>{e&&("customerAccount"!==h&&"businessCustomer"!==h||J||z instanceof os&&ee&&(Z||re||te&&te.paymentMethod===ee.paymentMethod&&te.id===ee.i
2d||(se&&i.log("payment_method_manager_programmatic_selection_replaced_primary_line","Programmatic payment method selection replaced the proposed primary payment line",{replacedPaymentLineMethodType:se,replacingPaymentMethodType:ee.paymentMethod}),z.selectPaymentMethod(ee,"programmatic").catch(()=>{}))))},[e,h,J,Z,z,ee,te,re,se,i]),z}function _s(){const{shop:e,checkout:t,observability:a}=Pe(),s=t.wallets.activeSession.value,r=t.latestReceipt.value,{persistedPayPalSignal:n}=Se(),i="payPal"===t.identity.current.value,d=r?.id,l=G().value,c=void 0!==l,u=ft(),m=n.value,{negotiate:h}=z(),p=K(),y=D(new Set(vt))?.hasError&&d!==m?.receiptIdForClearedToken,f=H("PAYPAL_EXPRESS").value?.merchantId?.trim(),v=l?.method.walletContent?.merchantId?.trim(),b=e.hasFlagEnabled(bt)&&f&&v&&v!==f,C=m?.billingAgreementStatus&&Ct({checkout:t})&&"NOTREQUESTED"===m.billingAgreementStatus&&!l?.method.walletContent?.isVaultWithPurchaseOrder,g=!0===l?.method.walletContent?.isVaultWithPurchaseOrder&&0===u.value?.amount;o(()=>{c&&((y||b||C||g)&&(function(){let e;e=y?"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:y?d:void 0,newTokenRequiredDueToError:!0,billingAgreementStatus:void 0};n.value=e}()),(async()=>{(g||y&&!i&&!s)&&(p(),await h({silenceViolations:["non-stock"]}))})())},[y,c,b,d,a,n,C,g,i,p,h,s])}function Ms(e){const{checkout:{negotiator:t}}=Pe(),a=t.current.fields.paymentMethods;return r(()=>{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 Ps=(e=>(e.Init="init",e.Loading="loading",e.Success="success",e.Error="error",e.Stale="stale",e))(Ps||{});function Ss(e,t){return e.filter(e=>!Es(e,t))}function ks(e,t){return e.some(e=>Es(e,t))}function As({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 gt(e)&&e.method.redemptionContent&&"storeCreditAccountId"in e.method.redemptionContent&&e.method.redemptionContent.storeCreditAccountId===t.id}function ws(e){const{checkout:{negotiator:t}}=Pe(),a=t.current.fields.paymentLines;return r(()=>{const t=e.value;return!(!t||!a.value?.lines)&&ks(a.value.lines,t)})}function Is(){const{shop:{currencyCode:e},checkout:{negotiator:t}}=Pe(),{buyerIdentity:a}=t.current.fields;return r(()=>{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 xs(){const{checkout:{negotiator:e}}=Pe(),t=e.current.fields.paymentLines;return r(()=>t.value?.lines.filter(e=>gt(e))||[])}function Ls({options:e,paymentMethodExtension:t}){const a=t[0]?.extension;if(!a)return null;const r=a.appId.split("/").pop(),n=r&&!_t.includes(r);return s(Q,{options:e,customizations:t,transformComponents:n?Ds:void 0})}const Ds=W(new Set(["Image","Banner","s-image","s-banner"]));function Ns(){const{checkout:{negotiator:e}}=Pe(),t=e.current.fields.allViolations,a=r(()=>(t.value??[]).filter(e=>!!X(e)||!!Mt(e))),n=r(()=>{const[e]=a.value;return e?e.localizedMessage||e.nonLocalizedMessage:null});return s(i,{when:n,children:e=>s(J,{tone:"critical",errorType:Z.DiscountError,children:e})})}function Bs({amount:e,maskedIdentifier:t,remove:a}){const{i18n:r}=Pe(),n=r.formatCurrency(e.amount,{currency:e.currencyCode,form:"short"}),i=t.slice(-4).toUpperCase(),o=r.translate("payment.gift_card_wrapper.gift_card_label",{identifier:ee(i)}),d=r.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(Yt,{type:"gift-card"}),s(ae,{children:[s(se,{accessibilityVisibility:"hidden",children:o}),s(se,{accessibilityVisibility:"exclusive",children:d})]})]}),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:n}),s(re,{onClick:()=>a(),accessibilityLabel:r.translate("general.remove_item",{label:d}),children:s(V,{type:"x",size:"small"})})]})]})})}const Ts="gift_card_option";function Fs({afterAppliedRedeemablesChange:e,autoSelect:t=!1,showHeading:a=!0}){const{i18n:r}=Pe(),{paymentMethod:n,paymentLines:i,submit:d,remove:u,removeAll:m}=ne(),h=ie("Checkout::GiftCard::Render",n?.uiExtension?[n?.uiExtension]:[]),{value:p}=ft(),f=p?.amount||0,[v,b]=l([]),[C,g]=l(!1),_=0===f&&0===i?.length;o(()=>{_?b([]):(i?.length>0||t)&&b([Ts])},[t,i?.length,_]);const M=c(async(t,a)=>{const s=await d(t,a);return"success"===s?.status&&(g(!1),e?.()),s},[e,d]),P=y(()=>({paymentMethodIdentifier:n?.paymentMethodIdentifier??"",submitRedeemablePaymentLine:M}),[n?.paymentMethodIdentifier,M]),S=Boolean(i?.length)||Boolean(h.length)&&Boolean(n);return s(oe,{id:"3p-gift-card-field",open:S,duration:"slow",children:s(I,{accessibilityLabel:r.translate("payment.gift_card_wrapper.heading"),children:s(R,{gap:"base",children:[a&&s(k,{level:2,children:r.translate("payment.gift_card_wrapper.heading")}),s(na,{name:"gift_card_option_list",values:v,multiple:!0,onChange:async t=>{if(b(t),0===t.length&&i.length>0){const t=await m();"success"===t?.status&&e?.()}},variant:"block",children:s(ia,{value:Ts,disabled:_,selectedContent:s(R,{gap:"base",children:[i?.length>0?s(R,{gap:"small-300",children:i.map(t=>{const{cost:a,method:r}=t;if(!a||"CUSTOM"!==r.redemptionSource)return null;const n=r.redemptionContent?.redemptionAttributes.reduce((e,t)=>
2`${e},${t.key}:${t.value}`,"");return s(Bs,{maskedIdentifier:r.redemptionContent?.maskedIdentifier||"",amount:{amount:a.amount,currencyCode:a.currencyCode},remove:async()=>{const t=await u(r);"success"===t?.status&&e?.()}},n)})}):null,s(Ns,{}),(()=>{if(0===f||!h.length||!n)return null;const e=s(Ls,{paymentMethodExtension:h,options:P});return i&&0!==i.length?s(w,C?{children:[s(A,{blockSize:"small-500"}),s(R,{gap:"base",children:[s(k,{level:3,children:r.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:r.translate("payment.gift_card_wrapper.apply_another_gift_card_label")})]})})]}):e})()]}),children:r.translate("payment.gift_card_wrapper.apply_gift_card_label")})})]})})})}const Vs="StoreCreditRedemptionCheckbox",Rs="StoreCreditSubscriptionRenewalsCheckbox";function Us(e,t){return gt(e)&&e.method.redemptionContent&&"storeCreditAccountId"in e.method.redemptionContent&&e.method.redemptionContent.storeCreditAccountId===t.id}function Os({amountDueAtCheckout:e,storeCreditAccount:t}){if($s({amountDueAtCheckout:e,storeCreditAccount:t})&&null!=e)return{amount:Math.min(e.amount,t.balance.amount),currencyCode:e.currencyCode}}function $s({amountDueAtCheckout:e,storeCreditAccount:t}){return null==e||e.currencyCode===t.balance.currencyCode}function Ys({paymentLines:e,storeCreditAccount:t,cost:a}){let s=!1;const r=e.map(e=>{if(!Us(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 qs(e,t,a){if("success"!==e.status&&"error"!==e.status)return!1;const s=e.negotiated?.paymentLines?.lines;return null==s?"success"===e.status:ks(s,t)===a}function js(e){const{negotiate:t}=z();return c(async()=>new Promise(a=>{t({fieldsToResolve:["paymentLines"],legacyFiltering:{include:["paymentLines"],silenceViolations:["non-store-credit"]},silenceViolations:["non-store-credit",...Et(["paymentLines"])],runListenersOnError:!0,force:!0,onComplete(t){e.value="success"===t.status?Ps.Success:Ps.Error,a(t)}})}),[t,e])}function Gs(e,t){const{checkout:{negotiator:a}}=Pe(),s=js(t);return c(async()=>{if(!e)return t.value=Ps.Error,{result:null,landed:!1};t.value=Ps.Loading;const r=a.parts.paymentLines.value,n=r.findIndex(t=>Us(t,e)),i=r[n];a.parts.paymentLines.value=Ss(r,e);const o=await s(),d=qs(o,e,!1);if(i&&!d){const t=Ss(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 zs(e,t){const{i18n:a,shop:s,checkout:{negotiator:r}}=Pe(),n=js(t),i=r.current.fields.paymentLines,o=ft(),d=Pt(),l=pt(),u=St(),m=r.current.fields.paymentFlexibilityPaymentTermsTemplate,h=kt(s),p=r.current.fields.isImmediateAmountReducedForRedeemables,y=c(()=>h&&At({hasSellingPlan:l.value,hasFixedSellingPlan:u.value,paymentTermsTemplateType:m.value?.type}),[h,l,u,m]),f=v(!1);return b(()=>{if(!y())return;const t=o.value??d.value,a=r.parts.paymentLines.value;if(!e||!f.current)return;const s=i.value?.lines.find(t=>Us(t,e))?.cost;if(p?.value){if(s){const t=Ys({paymentLines:a,storeCreditAccount:e,cost:s});t!==a&&(r.parts.paymentLines.value=t)}return}if(s&&s.amount>0)return void(f.current=!1);const n=Ys({paymentLines:a,storeCreditAccount:e,cost:Os({amountDueAtCheckout:t,storeCreditAccount:e})});n!==a&&(r.parts.paymentLines.value=n)}),c(async()=>{if(!e)return t.value=Ps.Error,{result:null,landed:!1};t.value=Ps.Loading;const s=Ss(r.parts.paymentLines.value,e),i=o.value??d.value,l=y(),c=l?Os({amountDueAtCheckout:i,storeCreditAccount:e}):void 0;if(f.current=null!=c,l&&!$s({amountDueAtCheckout:i,storeCreditAccount:e}))return t.value=Ps.Error,de({content:a.translate("store_credit_errors.generic_error")}),{result:null,landed:!1};r.parts.paymentLines.value=[...s,{method:{type:"redeemable",redemptionSource:"STORE_CREDIT",redemptionContent:{storeCreditAccountId:e.id}},...c&&{cost:c}}];const u=await n();if(!qs(u,e,!0))return f.current=!1,r.parts.paymentLines.value=Ss(r.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=>Us(e,t))?.cost}(u,e);return m&&m.amount>0&&(f.current=!1,r.parts.paymentLines.value=function({paymentLines:e,storeCreditAccount:t,cost:a}){return e.map(e=>Us(e,t)?{...e,cost:a}:e)}({paymentLines:r.parts.paymentLines.value,storeCreditAccount:e,cost:m})),{result:u,landed:!0}},[d,n,o,r.parts.paymentLines,t,y,e,a])}function Ks({afterAppliedRedeemablesChange:e}){const{i18n:t,shop:a,webMcp:n,checkout:{negotiator:d}}=Pe(),l=a.hasFlagEnabled(wt),u=ft(),m=xt(),h=St(),p=Is(),y=ws(p),f=C(Ps.Init),v=Ms(p),_=function(e){const{shop:t}=Pe(),a=t.hasFlagEnabled(wt),s=Pt(),n=It();return r(()=>
2{if(n.value)return As({firstOrderTotal:s.value,storeCreditAccount:e.value,includeExhausted:a})})}(p),M=r(()=>l&&null!=_.value),P=r(()=>m.value||h.value),S=r(()=>m.value?t.translate("payment.store_credit.buying_gift_card"):h.value?t.translate("payment.store_credit.no_fixed_selling_plans"):void 0);b(()=>{(!v.value||!M.value||P.value)&&g(()=>{d.parts.useStoreCreditForSubscriptionRenewals.value&&(d.parts.useStoreCreditForSubscriptionRenewals.value=!1)})});const k=zs(p.value,f),A=Gs(p.value,f),E=r(()=>f.value===Ps.Loading),w=r(()=>E.value||P.value),x=r(()=>w.value||0===u.value?.amount&&!y.value),L=w,D=r(()=>{const e=[],t=M.value&&d.parts.useStoreCreditForSubscriptionRenewals.value;return(y.value||t)&&e.push(Vs),t&&e.push(Rs),e}),N=c(async t=>{const a=y.peek(),s=t.includes(Vs),r=l&&!(a&&!s)&&t.includes(Rs),n=s||r,i=d.parts.useStoreCreditForSubscriptionRenewals.peek();if(d.parts.useStoreCreditForSubscriptionRenewals.value=r,n!==a){const{landed:t}=n?await k():await A();if(!t)return void(d.parts.useStoreCreditForSubscriptionRenewals.value=!n&&i);e?.()}},[k,A,y,d.parts.useStoreCreditForSubscriptionRenewals,l,e]),B=r(()=>v.value&&Boolean(p.value)),T=r(()=>D.value.includes(Vs)),F=c(e=>N(e?[...new Set([...D.peek(),Vs])]:[]),[D,N]);o(()=>n?.unstable_provideStoreCreditController({available:B,redeeming:T,applied:y,settling:E,hasGiftCard:m,hasFixedSellingPlan:h,paymentDue:u,setRedeeming:F}),[n,B,T,y,E,m,h,u,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(na,{name:"store_credit_redemption",values:D.value,multiple:!0,onChange:N,variant:"block",children:[s(ia,{value:Vs,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:Rs,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 Hs(){const{i18n:e}=Pe(),{hasViolations:t}=ce(Lt);return t?s(J,{errorType:Z.PaymentError,tone:"critical",children:e.translate("store_credit_errors.generic_error")}):null}function Qs({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 Ws=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 Xs(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=Ws.get(e.toLowerCase());if(t)return t;const a=e.toUpperCase();return Dt(a)?Nt(a):e}(e.brand):""}function Js(){const{checkout:{negotiator:e}}=Pe(),{paymentLines:t}=e.parts;return r(()=>$t(t.value))}function Zs({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 er({id:e,variant:t}){const{i18n:a}=Pe(),r="prompt"===t?a.translate("msi_installments.enter_card_details_prompt"):a.translate("msi_installments.loading_installments");return o(()=>{if("loading"===t)return de({content:r})},[r,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:r})})}function tr({paymentMethod:e,isSelected:t,canEditBin:a=!0,isVaultedContext:r=!1,id:n="msiInstallmentsSelect"}){const{checkout:{negotiator:i}}=Pe(),{bankIdNumberSignal:d,installmentMonthsSignal:l,lastNegotiatedBinSignal:c}=i.context,{paymentLines:u}=i.parts,m=Js();o(()=>{l.value=m.value},[m.value,l]);const h=a&&!r,p=e.installmentPlans?.find(e=>"MSI"===e.type),y=p?.supportedInstallments??[],f=Bt(d.value),v=!r&&void 0!==f&&void 0!==c.value&&f!==c.value;o(()=>{m.value&&(!t||!p||!f&&!h&&0===y.length)&&(u.value=me(u.value,void 0))},[m.value,t,p,f,h,y.length,u]);const b=Zs({isSelected:Boolean(t),hasMsiPlan:Boolean(p),isStale:v,binPrefix:f,canEditBin:h,supportedInstallmentsCount:y.length,isNegotiating:!1});return"hidden"===b?null:s(er,"prompt"===b?{id:n,variant:"prompt"}:{id:n,variant:"loading"})}const ar=a({displayName:"MsiInstallmentsSelect",useError:ue("MsiInstallmentsSelect"),load:()=>_(async()=>({default:(await e(async()=>{const{MsiInstallmentsSelect:e}=await(import("./82de4790.Dbuzu6jz.js"));return{MsiInstallmentsSelect:e}},__vite__mapDeps([27,1,12,2,3,4,5,13,14,10,15,16,28,29,30,31,21,32,33,34,20,22,35,36,37,38,39,40,41,42,43,44]))).MsiInstallmentsSelect})),renderLoading:e=>s(tr,{...e})}),sr=new Map,rr=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=sr.get(e.source);t instanceof Promise||(t=ye(e,!0),sr.set(e.source,t)),await t;const a=this.initQueue.pop();a?.(),this.initQueue=[],this.scriptLoaded=!0}async setup(t,a,s){return ir(()=>{if(this.sdk)return;if(this.setupPromise&&this.setupForm===t)return this.setupPromise;const r=window.CardFields;if(!r)throw new fe("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;s<e.MAX_SETUP_ATTEMPTS;s++){const e=this.setupGeneration,s=await r.setup(t,a);if(n!==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===n&&(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 ir(()=>{if(!this.sdk)throw new ve("The CardFields SDK has not been set up.");return e(this.sdk)},Boolean(this.sdk),this.sdkQueue)}};rr.MAX_SETUP_ATTEMPTS=3;let nr=rr;function ir(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 or=P(void 0),dr={name:!1,number:!1,expiry:!1,verification_value:!1,issue_number:!1,issue_date:!1};function lr({children:e,value:t,sdkScriptAttributes:a,blurValidationEnabled:r=!0,blurValidationFieldDenylist:n,onError:i,onSetFieldErrors:d,onLoadSuccess:u}){const m=y(()=>new nr,[]),[h,p]=l(!0),[f,b]=l({name:null,number:null,verification_value:null,expiry:null,issue_date:null,issue_number:null,sdk:null}),C=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(dr),N=v(L);o(()=>{N.current=L},[L]);const B=v(),T=c(e=>{C.current=e instanceof be?e.diagnostics:void 0,b({sdk:e.message}),i?.(e),p(!1)},[i,b,p]),F=c(async e=>{try{return await e()}catch(t){if(t instanceof Error){let e=null;if(t.name===Ce.name)e=new Ce(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)}
2throw t}},[T]),V=c(async(e,t={propagateErrors:!0})=>{const{sdk:a,...s}=e;await F(()=>m.setErrors(s)),b(a=>{const s={...a,...e};return t.propagateErrors&&d?.(s),s})},[m,d,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 r={...f,...a};return V(r),{isValid:!Object.values(r).some(Boolean)}},[f,k?.expiry,k?.name,k?.number,k?.verification_value,V]);o(()=>{!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,o=N.current[a],d=Boolean(n?.has(a));if(r&&!d&&i&&o){const e={[a]:t?null:i[a]};"number"===a&&s&&(e[a]=i.number_blank),await V(e,{propagateErrors:!1})}S(void 0)},[V,r,n]),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(dr)},[]),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)=>F(()=>("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]);o(()=>()=>{d?.({})},[d]);const W=y(()=>t??{sdk:Q,errors:f,sdkLoadDiagnostics:C.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(or.Provider,{value:W,children:e})}const cr=()=>{const e=f(or);if(null==e)throw new fe("No cardfields found in context");return e},ur=e=>e.toUpperCase(),mr=e=>e.toLowerCase();function hr(e){return Boolean(e?.some(e=>"direct"===e.type&&e.paymentBrands.includes("BOGUS")))}function pr({paymentMethods:e,hasBogusGateway:t=hr(e),paymentLines:a,storeVaultGuestCvvVerificationEnabled:s=!1,selectedCardRequiresProposalLineCvv:r=!1,selectedCardBrand:n,hasAmexCvvOnlyField:i=yr({paymentLines:a,storeVaultGuestCvvVerificationEnabled:s,selectedCardRequiresProposalLineCvv:r,selectedCardBrand:n})}){return t?new Set(["number"]):i?new Set(["verification_value"]):new Set}function yr({paymentLines:e,storeVaultGuestCvvVerificationEnabled:t=!1,selectedCardRequiresProposalLineCvv:a=!1,selectedCardBrand:s}){return Boolean(a&&"AMEX"===s?.toUpperCase()||t&&e?.some(({method:e})=>e.type===ot.CreditCard&&"AMEX"===e.brand))}function fr(e){return e.replace(/([\d.]+)rem/g,(e,t)=>10*Number(t)/14+"rem")}function vr(){const{checkout:{negotiator:e}}=Pe(),{paymentMethods:t}=e.current.fields;return r(()=>{const e=t.value?.filter(e=>e.type===ot.CreditCard&&Boolean(e.expired));return e?e.length:0})}function br(){const{i18n:e}=Pe();return{getAccessibilityLabel:t=>{const a="direct"===t.type?t.creditCardLastFourDigits:t.displayLastDigits;return`${Nt(t.brand)} ${e.translate("payment.saved_credit_card_info")} ${a}`}}}function Cr(e){return e?e.map(e=>ur(e)):[]}const gr=Tt("CreditCardNetworkContext");function _r({children:e,paymentMethod:t,publishesCardNetworkDetection:a=!1}){const{checkout:r,source:n,observability:i,userEvents:d}=Pe(),u=S(),m=t?Ve(t):u,h=r.cardNetworkSelection.forMethod(m),{bankIdNumber:p,touched:f,...v}=cr(),{networks:b,sdk:C,filled:g}=v,_=y(()=>Cr(b),[b]),M=p?.replace(/\s/g,"").length??0,P=M>=6&&v.cardBrand?ur(v.cardBrand):void 0,k=y(()=>_.filter(e=>t?.paymentBrands.includes(e)),[_,t]),A=Boolean(t?.supportsNetworkSelection);o(()=>{a&&h.setDetectedState({networkSelectionEnabled:A,availableNetworks:k,cardBrand:P,numberFilled:Bo
2olean(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:r}){const{bankIdNumber:n,networks:i,cardBrand:d}=cr(),{userEvents:c,source:{checkoutSessionIdentifier:u}}=Pe(),[m,h]=l(!1),[p,f]=l(""),v=y(()=>Cr(i||(d&&(n?.length??0)>=6?[d]:void 0)),[i,d,n]);o(()=>{if(!n||0===n.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&&r};m||(c.monorailEvent({schemaId:"checkout_credit_card_number_interaction/1.1",payload:{...i,eventName:"first_digit_entered"}}),h(!0)),n.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,n,c,u,r,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:mr(e)}:void 0,a=await C.vaultCard(t);return Pr(d,{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},[h,C,n,b,i,d]),x=c(async e=>{const t=h.selectedNetwork.value,a=t?{selected_network:mr(t)}:void 0,s=await C.vaultCardMultipleTimes(e,a);return Pr(d,{checkoutSessionIdentifier:n.checkoutSessionIdentifier??"",selectedNetwork:a?.selected_network,detectedNetworks:b}),s},[h,C,d,n,b]),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(gr.Provider,{value:L,children:e})}function Mr(){return Ft(gr)}function Pr(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 Sr=["CardFieldsFetchFailureError"];function kr({children:e,publishesCardNetworkDetection:t,directPaymentMethodConfig:a,...r}){const n=v(Me()),{observability:i,checkout:{negotiator:o}}=Pe(),{value:d}=o.current.fields.paymentMethods,l=a??He(d??[]),u=c(e=>{Sr.includes(e.name)?i.log("default_card_fields_provider_unactionable_error","Unactionable error in card fields provider",{error:e}):i.error(e)},[i]);return s(lr,{...r,onError:u,sdkScriptAttributes:n.current,children:s(_r,{paymentMethod:l,publishesCardNetworkDetection:t,children:e})})}function Ar(e){const{shopPay:t,checkout:{negotiator:a}}=Pe(),{value:r}=a.current.fields.paymentMethods,{paymentLines:n}=a.parts,{bankIdNumberSignal:i,installmentMonthsSignal:d}=a.context,{binResolution:l,clearInstallments:c,selectedCardBin:u,expandedVisible:m,collapsedVisible:h}=e.msi,p=m.value,y=h.value,f="server"===l?e.selectedCreditCard.value?.id:void 0;!function({enabled:e,selectedCardId:t}){const{checkout:{identity:a,negotiator:s}}=Pe(),{paymentLines:r}=s.parts,{negotiate:n}=z(),i=sa(),d=v(void 0);o(()=>{if("shopPay"!==a.current.value)return;if(!e||!t)return d.current=void 0,void(r.value=Vt(r.value));if(d.current===t)return;d.current=t;const s=qe(r.value,"SHOP_PAY"),o=s?.method.walletContent?.credit
2CardInstallments;r.value=Rt(r.value,i({msiEligibleCard:!0,creditCardInstallments:o})),n({legacyFiltering:{include:[]},silenceViolations:[...Ut]}).catch(()=>{d.current=void 0})},[e,a.current.value,t])}({enabled:y&&!t.session.isLoading.value,selectedCardId:f});const b=v(p);o(()=>{b.current&&!p&&(n.value=c(n.value),d.value=void 0),b.current=p},[p,c,n,d]);const C=v(y);o(()=>{C.current&&!y&&(n.value=c(n.value),d.value=void 0),C.current=y},[y,c,n,d]);const g=u.value,_=e.selectedCreditCard.value?.id;o(()=>{if("client"!==l)return;const e=i.peek();i.value=_===rt&&oa(e,g)?e:g},[l,i,g,_]);const M=He(r??[]);var P;return{expandedSlot:M&&p?Er({paymentMethod:M,binResolution:l,id:"msiInstallmentsSelect-expanded"}):void 0,collapsedSlot:M&&y?(P=Er({paymentMethod:M,binResolution:l,id:"msiInstallmentsSelect-summary"}),s(w,{paddingInlineStart:"large-100",children:s(kr,{onSetFieldErrors:()=>{},children:P})})):void 0}}function Er({paymentMethod:e,binResolution:t,id:a}){return s(ar,"server"===t?{paymentMethod:e,isSelected:!0,isVaultedContext:!0,id:a}:{paymentMethod:e,isSelected:!0,canEditBin:!1,id:a})}function wr(e,t,a){return!!e&&(0===a.size||[...t].some(e=>!a.has(e.code)))}export{zs as $,Ba as A,Mr as B,Wa as C,kr as D,yr as E,ur as F,Fs as G,fr as H,br as I,Ga as J,ja as K,ts as L,ar as M,ba as N,as as O,Ls as P,ss as Q,vr as R,Hs as S,ca as T,ga as U,Qs as V,ya as W,ma as X,ws as Y,As as Z,Ps as _,Js as a,Gs as a0,Vs as a1,Rs as a2,fa as a3,qa as a4,Is as b,Ms as c,xs as d,Ks as e,gs as f,Zs as g,Ar as h,da as i,pr as j,ka as k,hr as l,cr as m,Xs as n,Aa as o,Da as p,xa as q,La as r,Na as s,wr as t,_s as u,Ea as v,Fa as w,wa as x,Ia as y,Ta 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.