1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["component-TransitionProgress.B2JrwmWu.js","esnext-vendor.DDpcaSqU.js","utilities-previous.Cnwy8G2v.js","app.DdDscdWN.js","assets/app.BuSMBobh.css","assets/previous.DjvIwnbB.css","assets/TransitionProgress.BAeLDej3.css","ShopPayCaptcha.D1P4QA8k.js","hydrate.BcfGVx0L.js","graphql-PaymentSessionMutation.C-nDEOnn.js","shared-permissions.B59tuyWB.js","hooks-useShopPayExternalAppContext.R6pnDxYu.js","assets/helpers.BduNPqpW.css"])))=>i.map(i=>d[i]); 2import{E as $,j as ge,y as Tt,G as Ie,l as Ee,A as D,h as P,T as Y,u as h,d as lt,r as ut,f as se,k as Ce,q as B,D as Lt,g as Ot,W as Je,S as X,i as ke,o as Me}from"./esnext-vendor.DDpcaSqU.js";import{aY as Nt,T as k,b6 as dt,a5 as ee,f$ as Rt,d0 as xt,bI as pt,bB as je,bF as Bt,W as ce,bA as ht,cQ as Ft,aA as x,g0 as Dt,bm as fe,g1 as Ut,g2 as wt,k as Vt,g3 as qt,cZ as Ht,g4 as zt,g5 as Gt,m as $t,_ as Wt,f1 as Te,aZ as Kt,fY as Yt,I as Jt,dR as jt,aU as Zt,g6 as Qt,g7 as Xt,g8 as en,g9 as tn,ga as nn,gb as Ze,gc as sn,gd as an,y as on,ge as rn,gf as Qe,bX as ve,bz as Se,gg as cn,f4 as Xe,fu as mt,aX as ln,gh as un}from"./utilities-previous.Cnwy8G2v.js";import{fP as et,a as dn,fQ as pn,fR as tt,fS as hn,fT as mn,bo as yn,e5 as Le,fU as gn,fV as fn,fW as vn,fX as yt,i as Ae,bC as nt,k as gt,fg as _e,e6 as w,fa as Sn,fY as st,I as _n,l as Pn,f1 as bn,q as ft,h as Cn,fZ as kn,f_ as An,f3 as In,d1 as En,e as Mn}from"./hydrate.BcfGVx0L.js";import{S as Tn,a as Ln,u as On}from"./payment-usePaymentExemptionReason.emSKnIpm.js";import{t as re,a as Pe,u as Nn,b as Rn,c as xn}from"./hooks-usePreselectSpi.DawjANz2.js";import{_ as vt}from"./app.DdDscdWN.js";import{g as Oe}from"./shop-pay-installments-monorail.B1-OWrOB.js";import{S as Ne}from"./helpers-isSwitchAccountBootRequest.C3tmXnb7.js";import{a as St,b as Bn,c as Fn,u as Dn}from"./hooks-useUpdateCheckoutAddress.C4NXzSJo.js";import{a as Un,S as wn,u as Vn}from"./models-ShopPayBuyerDetails.model.B8_PHLfa.js";import{u as qn}from"./hooks-useShopPayNewSignupLoginExperiment.DrmS3FLj.js";import{a as Hn}from"./Monorail-monorailMetric-wallets.D__Peh7l.js";import{u as zn}from"./hooks-useShopPayExternalAppContext.R6pnDxYu.js";import"./graphql-PaymentSessionMutation.C-nDEOnn.js";import"./shared-permissions.B59tuyWB.js";import"./helpers-derivations.K4r9DEFp.js";import"./redemption-promotions.8MPSgIef.js";import"./shop-pay-normalizeBuyerDetails.CDJVtFmS.js";const Gn={cashbackBanner:"COMPONENT_SHOP_CASH_CASHBACK_BANNER",minimumOrderValueBanner:"COMPONENT_SHOP_CAMPAIGN_MINIMUM_ORDER_VALUE_BANNER"};function $n(e){return e.__typename==="ShopCashCheckoutFlatAmountCashbackIncentive"}function Wn(e){return e.__typename==="ShopCashCheckoutCashbackIncentive"&&e.expectedAmount.amount>0}function at(e,[n,t]){return{type:e,rendered:!0,component:Gn[n],displayLabel:t.displayLabel}}function Kn(e){const t=e.reduce((r,l)=>!r||l[1].sequence>r[1].sequence?l:r,void 0)?.[1].snapshot;if(!t?.resolutionId)return;const o=e.filter(([,r])=>r.snapshot.resolutionId===t.resolutionId),s=o.find(([r])=>r==="cashbackBanner"),a=o.find(([r])=>r==="minimumOrderValueBanner"),i=t.incentives.find($n),c=[];if(i){const r=i.minimumOrderValueSatisfied?s:a;r&&c.push(at("INCENTIVE_TYPE_SHOP_CAMPAIGN_CASHBACK_OFFER",r))}if(s&&t.incentives.some(Wn)&&c.push(at("INCENTIVE_TYPE_SHOP_CASH_CASHBACK_PROMOTION",s)),c.length!==0)return{eventTypeName:"shopify.advertising.incentives.IncentivePresentedEvent",resolutionId:t.resolutionId,checkoutToken:t.checkoutToken,incentives:c}}class it extends Error{constructor(n){super("A non-Error value was thrown while recording a presentation",{cause:n}),this.name="IncentivePresentationUnknownError"}}class Yn{#n;#s;#a=new Map;#i;#o=0;#t=!1;#e=!1;constructor({emit:n,observability:t}){this.#n=n,this.#s=t}recordPresentation(n,t){return this.#e?()=>{}:this.#r(()=>t.resolutionId?(this.#o+=1,this.#a.set(n.component,{displayLabel:n.displayLabel,sequence:this.#o,snapshot:t}),this.#l(),()=>{}):()=>{})??(()=>{})}dispose(){this.#e||(this.#e=!0)}#l(){this.#t||(this.#t=!0,Promise.resolve().then(()=>{this.#r(()=>{this.#t=!1,this.#u()})}).catch(n=>this.#c(n)))}#u(){if(this.#e)return;const n=Kn([...this.#a.entries()]);if(!n)return;const t=JSON.stringify(n);t!==this.#i&&(this.#n(n),this.#i=t)}#r(n){try{return n()}catch(t){this.#c(t);return}}#c(n){let t;try{t=n instanceof Error?n:new it(n)}catch{t=new it(n)}try{this.#s.error(t,{severity:"warning"})}catch{}}}const Jn={id:"6ad2de4357fc9115d8c9c3d1f349fe7784cea96335888d8ec145d7a0bf08e79a",type:"query",name:"CheckoutCashbackIncentive",source:"query CheckoutCashbackIncentive($checkoutIdentifier:String!,$checkoutSourceId:ID,$shopifyShopId:ID!,$eligibleOrderTotal:MoneyInput!,$eligibleOrderSubtotal:MoneyInput!){shopCashCheckoutCashback(checkoutIdentifier:$checkoutIdentifier checkoutSourceId:$checkoutSourceId shopifyShopId:$shopifyShopId eligibleOrderTotal:$eligibleOrderTotal eligibleOrderSubtotal:$eligibleOrderSubtotal){resolutionId incentives{...on ShopCashCheckoutCashbackIncentive{campaignHandle ratePercentage maxApplicableOrderAmount{...MoneyFragment __typename}expectedAmount{...MoneyFragment __typename}remainingRewardLimit{...MoneyFragment __typename}displayName expiresAt __typename}...on ShopCashCheckoutFlatAmountCashbackIncentive{campaignHandle cashbackAmount{...MoneyFragment __typename}minimumOrderValue{...MoneyFragment __typename}minimumOrderValueSatisfied minimumOrderValueRemainder{...MoneyFragment __typename}__typename}__typename}expectedAmount{...MoneyFragment __typename}__typename}}fragment MoneyFragment on Money{value currency __typename}"},jn=1440*60*1e3,Zn=Nt(({checkout:e,graphql:n,shop:t,source:o},{cashbackState:s,eligibleOrderTotal:a,skip:i})=>{const c=$(()=>e.proposal.negotiated.fields.subtotalAfterMerchandiseDiscounts.value),r=$(()=>c.value?.amount),l=$(()=>c.value?.currencyCode),d=$(()=>a.value?.amount),p=$(()=>a.value?.currencyCode),u=$(()=>{const{checkoutSessionIdentifier:b,sourceId:f}=o;if(!(!b||!f)&&!(d.value===void 0||!p.value||r.value===void 0||!l.value))return{checkoutIdentifier:b,checkoutSourceId:f,eligibleOrderTotal:et({amount:d.value,currencyCode:p.value}),eligibleOrderSubtotal:et({amount:r.value,currencyCode:l.value}),shopifyShopId:t.id}}),m=$(()=>i.value||u.value===void 0),y=n.shopPayGraphql.query(Jn,{variables:()=>u.value,skip:()=>m.value});let g=r.peek();ge(function(){const f=r.value;m.value||g===f||(g=f,y.refetch({deduplicate:!0}))}),ge(function(){!s?.stale.value||m.value||(s.stale.value=!1,y.refetch({deduplicate:!0}))});const E=Tt(Date.now());let _=!1;return ge(function(){const f=y.data.value?.shopCashCheckoutCashback,C=E.value,T=Qn(f,_?C:void 0);if(!f||!T)return;const L=Date.parse(T);if(!Number.isFinite(L))return;const v=()=>{_=!0,E.value=Date.now(),u.peek()!==void 0&&Ie(()=>y.refetch())},I=L-Date.now();if(I<=0){v();return}if(I>jn)return;const O=setTimeout(v,I);return()=>{clearTimeout(O)}}),{cashback:$(()=>{const b=y.data.value?.shopCashCheckoutCashback,f=E.value,C=ts(b,f);return C&&s?{...C,state:s}:C}),error:y.error,loading:y.loading}});function Qn(e,n=Number.NEGATIVE_INFINITY){let t,o=Number.POSITIVE_INFINITY;for(const s of e?.incentives??[]){if(s?.__typename!=="ShopCashCheckoutCashbackIncentive"||!s.expiresAt)continue;const a=Date.parse(s.expiresAt);Number.isFinite(a)&&a>n&&a<o&&(t=s.expiresAt,o=a)}return t}function Xn(e){switch(e.__typename){case"ShopCashCheckoutCashbackIncentive":return{...e,ratePercentage:parseFloat(e.ratePercentage),maxApplicableOrderAmount:re(e.maxApplicableOrderAmount),expectedAmount:re(e.expectedAmount),remainingRewardLimit:Pe(e.remainingRewardLimit),displayName:e.displayName??null,expiresAt:e.expiresAt??null};case"ShopCashCheckoutFlatAmountCashbackIncentive":return{...e,cashbackAmount:re(e.cashbackAmount),minimumOrderValue:Pe(e.minimumOrderValue),minimumOrderValueRemainder:Pe(e.minimumOrderValueRemainder),ratePercentage:0};default:return}}function es(e){return e.__typename==="ShopCashCheckoutCashbackIncentive"?e.expectedAmount.amount:e.minimumOrderValueSatisfied?e.cashbackAmount.amount:0}
2function ts(e,n=Date.now()){if(!e)return;const t=[];let o,s,a=!1;for(const c of e.incentives??[]){if(c==null)continue;if(c.__typename==="ShopCashCheckoutCashbackIncentive"&&c.expiresAt&&Date.parse(c.expiresAt)<=n){a=!0;continue}const r=Xn(c);r&&(t.push(r),r.__typename==="ShopCashCheckoutFlatAmountCashbackIncentive"&&(o??=r),r.__typename==="ShopCashCheckoutCashbackIncentive"&&(s??=r))}if(a&&t.length===0)return;const i=re(e.expectedAmount);return{resolutionId:e.resolutionId,expectedAmount:a?{...i,amount:t.reduce((c,r)=>c+es(r),0)}:i,incentive:o??s,incentives:t}}function ns(e,n){return e?[null,je.ShopCashInvalidBillingAddress,je.ShopCashInvalidShippingAddress].includes(n):n==null}function ss({apiClientId:e,embedder:n,shopCashBalanceFlagEnabled:t}){const o=pn(e),s=Bt(n);return o||t||s}function as(e,n){if(!e?.incentive)return{};const t=e.incentive,o={campaignHandle:t.campaignHandle??void 0,cashbackPercent:t.ratePercentage??void 0,cashbackValue:e.expectedAmount.amount,cashbackValueCurrency:e.expectedAmount.currencyCode};return t.__typename==="ShopCashCheckoutFlatAmountCashbackIncentive"&&(o.minimumOrderValue=t.minimumOrderValue?.amount,o.eligibleOrderSubtotal=n),o}function ot(e){const n=e?.incentive?[e.incentive]:[];return e?.incentives??n}function is(e,n){const t=ot(n),o=Date.now();return ot(e).some(s=>{if(s.__typename!=="ShopCashCheckoutCashbackIncentive"||!s.expiresAt)return!1;const a=Date.parse(s.expiresAt);return!Number.isFinite(a)||a>o?!1:!t.some(i=>i.__typename==="ShopCashCheckoutCashbackIncentive"&&i.campaignHandle===s.campaignHandle&&i.expiresAt===s.expiresAt)})}function os(e={}){const{shop:n,shopPay:t,client:o,embed:s,i18n:a}=k(),{recordRewardEligibilityEvent:i}=Nn(),c=t.user.isUnauthenticatedSession.value,{value:r}=dt(),l=ee(),{value:d}=l.subtotalAfterMerchandiseDiscounts,{value:p}=l.shopCashBalance,{nonEligibleReason:u,serverConfirmed:m}=Rn().value,y=p?.status==="unavailable",g=m&&(ns(c,u)||y),E=o.unstable_getSerialization("apiClientId"),_=n.hasFlagEnabled(Rt),M=ss({apiClientId:E,embedder:s?.embedder,shopCashBalanceFlagEnabled:_}),b=g&&M,f=b&&Number(r?.amount)>0,C=xt(),T=Ee(!f),{cashback:L}=pt(Zn,{skip:T,eligibleOrderTotal:C,cashbackState:e.cashbackState}),v=L.value,I=D();P(()=>{const V=I.current;I.current=v,is(V,v)&&dn({content:a.translate("shop_cash.reward_expired_announcement"),role:"status"})},[v,a]);const O=b&&(v?.incentive?.__typename==="ShopCashCheckoutFlatAmountCashbackIncentive"&&v.incentive.cashbackAmount.amount>0&&v.incentive.minimumOrderValueSatisfied||v?.incentive?.__typename==="ShopCashCheckoutCashbackIncentive"&&v.expectedAmount.amount>0),F=!!(v&&(f||O)),q=v?.incentive?.ratePercentage,H=D();return P(()=>{if(!r?.amount)return;const V=as(v,d?.amount),N={isTransactionCashbackEligible:f,totalPrice:Number(r.amount),totalPriceCurrency:r.currencyCode,...V},A=JSON.stringify(N);A!==H.current&&(H.current=A,i(N))},[f,r,i,v,d]),P(()=>{t.shopCashExpectedEarnings.value=F?v?.expectedAmount:void 0},[t,F,v?.expectedAmount]),{cashback:v,isEarningCashback:F,cashbackRate:q}}function _t({children:e}){const{observability:n,userEvents:t,shop:o,source:s}=k(),a=tt({stale:!1}),{isEarningCashback:i,cashbackRate:c,cashback:r}=os({cashbackState:a}),l=tt({applying:!1}),d=Y(()=>new Yn({emit:m=>t.refineryEvent(hn(m,{shopId:o.id,checkoutSessionIdentifier:m.checkoutToken,customerId:void 0})),observability:n}),[n,t,o.id]);P(()=>()=>d.dispose(),[d]);const p=Y(()=>{const m=s.checkoutSessionIdentifier,y=r?.resolutionId;if(!m||!y)return;const g={checkoutToken:m,resolutionId:y,incentives:r?.incentives??[]};return{recordPresentation:E=>d.recordPresentation(E,g)}},[r?.incentives,r?.resolutionId,d,s.checkoutSessionIdentifier]);return h(Tn,{value:{redemption:l,cashback:r,cashbackState:a,isEarningCashback:i,cashbackRate:c,incentivePresentation:p},children:e})}function rs(){return vt(()=>import("./component-TransitionProgress.B2JrwmWu.js"),__vite__mapDeps([0,1,2,3,4,5,6]))}const rt=lt({displayName:"TransitionProgress",suspense:!1,load:()=>ut(rs),useError:mn("TransitionProgress")});function cs({errors:e,selectedShippingAddress:n}){const t=[...e.keys()].filter(i=>i!=="phone"),o=n!=null&&t.length>0&&t.every(i=>i==="firstName"),s=t.length>0&&!o,a=n?.valid===!1&&!o;return s||a}function ls(){const{checkout:e,shopPay:n,shop:{shippingCountries:t}}=k(),s=ce().shippingAddress.value,a=yn(s.countryCode,t),i=n.session.selectedShippingAddress.value,c=Y(()=>{const l=a(s);return cs({errors:l,selectedShippingAddress:i})},[a,s,i]),r=e.installments;P(()=>{us(r,c)},[r,c])}function us(e,n){e.unstable_setHasInvalidShippingAddress?.(n)}function ds(){return ls(),null}function ps(){const{userEvents:e,source:n,checkout:t,shop:o,shopPay:s,embed:a}=k(),i=Le(),c=t.installments.isCheckoutEligible.value,r=s.session.selectedPaymentMethod.value,l=ht(r),d=i!==null&&c&&s.session.isInstallmentsSelected.value&&l!=null,p=l!=null&&(l.supportsInstallmentsSplitPayLoan||l.supportsInstallmentsInterestLoan);P(()=>{d&&e.monorailEvent({schemaId:"shopify_pay_payment_page_installments/1.4",payload:{...Oe(n,t,o,{embedPlatform:a?.platform,shopAppSurface:s.app.c
2onfig.surface}),errorMessage:p?void 0:JSON.stringify(["selected_card_unsupported"]),eventType:Ne.CheckoutEligibility,success:p}})},[e,n,t,o,a?.platform,s.app.config.surface,d,p])}function hs(){const{userEvents:e,source:n,checkout:t,shop:o,shopPay:s,embed:a}=k(),c=Le()!==null,r=t.installments.isCheckoutEligible.value,l=se(()=>{if(t.installments.ineligibilityReasons.value.length!==0)return JSON.stringify(t.installments.ineligibilityReasons.value)});P(()=>{c&&e.monorailEvent({schemaId:"shopify_pay_payment_page_installments/1.4",payload:{...Oe(n,t,o,{embedPlatform:a?.platform,shopAppSurface:s.app.config.surface}),errorMessage:l.value,eventType:Ne.CheckoutEligibility,success:r}})},[l,c,r,e,n,t,o,a?.platform,s.app.config.surface])}function ms(){const{userEvents:e,source:n,checkout:t,shop:o,shopPay:s,embed:a}=k(),i=Le(),c=t.installments.isCheckoutEligible.value,r=i!==null,l=!s.user.installments.isRejected.value;P(()=>{!r||!c||e.monorailEvent({schemaId:"shopify_pay_payment_page_installments/1.4",payload:{...Oe(n,t,o,{embedPlatform:a?.platform,shopAppSurface:s.app.config.surface}),eventType:Ne.UserEligibility,success:l}})},[r,c,l,e,n,t,o,a?.platform,s.app.config.surface])}function ys(){ms(),hs(),ps()}function gs(){const{shopPay:e,checkout:n}=k(),t=e.user.creditCards;return se(()=>{const o=n.installments.paymentMethodMustSupportInterestBearingLoans.value;return t.value.filter(s=>s.expired?!1:!o||s.supportsInstallmentsInterestLoan)})}function Pt(){const{shopPay:e,checkout:n}=k(),t=gs(),o=Ft(),s=Ee(gn()),a=ce();return se(()=>{const i=e.session.isLoading.value,c=e.user.addresses.value.length>0,r=n.isShippingRequired.value&&(i||c),l=!i&&!c,d=!l&&t.value.length>0,p=!i&&!l&&!d&&!o.value,u=a.deliveryLines.value.some(m=>m.value.type==="SUBSCRIPTION");return{showShipping:r,showPayment:d,promptAddress:l,promptCreditCard:p,installments:s.value,hasSubscriptions:u}})}function fs(){const{userEvents:e,shop:n,source:t,checkout:o,shopPay:s}=k(),a=s.config.tracking.unique,i=s.user.shopAccountUuid;P(()=>{!i.value||!a||e.monorailEvent({schemaId:"shop_pay_session_tracking/2.0",payload:{...x(t,o,n),shopAppAccountUuid:i.value,uniqueToken:a}})},[e,t,o,n,i.value,a])}function vs(){const{shop:e,source:n,checkout:t,checkout:{extensibility:o},observability:s,userEvents:a,shopPay:i}=k(),c=t.installments.isSupported.value,r=ee(),l=Dt(),d=i.app.config,p=i.user.flow.value,u=i.user.addresses.value,m=i.user.creditCards.value,y=i.session.selectedShippingAddress.value,g=D(y),[E,_]=Ce(0),M=D(0),{value:b}=r.deliveryNext,f=fe("deliveryNext").value,C=i.session.showSessionRevalidator.value,T=r.shippingAddress,L=Ut(),v=i.user.shopAccountUuid,I=i.user.publicId.value,O=wt(b,"ONE_TIME_PURCHASE"),F=O?.status==="available",q=F&&l.value.enabledDeliveryMethods.includes("PICK_UP"),H=F&&l.value.enabledDeliveryMethods.includes("LOCAL"),V=F?l.value.enabledDeliveryMethods.length:0,N=F?O?.methods.find(({handle:S})=>O?.selectedDeliveryMethodHandle===S):null,{value:A}=dt(),{value:z}=r.discountLines,{value:U}=r.taxes,W=fe("taxes").value,{value:J}=r.duties,le=fe("duties").value,{hasSubscriptions:ae}=Pt().value,j=t.installments.config.value,kt=i.session.isLoading.value,K=c&&!t.installments.isUnavailable.value,ie=xn(),Re=U?.status==="available_total"?U.totalTax:null,At=t.proposal.facts.duty,It=fn(At,J),xe=Y(()=>z?.lines.reduce((S,R)=>{if(!Vt(R))return S;const G=R.amount?.amount;return G?S+G:S},0),[z]),Be=z?.lines.length||0,te=kt||W||le||f,{value:Et}=r.tipLines,Fe=Et?.[0],De=qt(d),Ue=n.type==="cartNext"?n.sourceId:"",{value:ue=[]}=r.allViolations,we=Ht(ue),Z=i.session.selectedPaymentMethod.value,de=ht(Z),Ve=Y(()=>vn(ue),[ue]),qe=o.ui.search().value.length>0,oe=i.user.installments.prequalifiedAmount.value,pe=i.user.installments.credential.value,He=yt()?.trackingVisit;P(()=>{te||(a.monorailEvent({schemaId:"shopify_pay_payment_page_checkout_state/5.8",payload:{...x(n,t,e),checkoutEligibleForLocalPickupBanner:(T||!1)&&q,merchantHasLocalPickup:q,checkoutHasSubscriptionProduct:ae,totalLineItemsPrice:L.value?.toString()||"",paymentDue:A?.amount?.toString()||"",currency:A?.currencyCode||"",installmentsAvailable:t.installments.isSupported.value,requiresVerification:C,checkoutEligibleForInstallments:K,checkoutEligibleForSplitPayInstallments:ne("SPLIT_PAY"),checkoutEligibleForInterestBearingInstallments:K&&zt(j?.availableLoanTypes),counter:E+1,merchantHasLocalDelivery:H,taxAmount:Re?.amount?.toString()||"",dutyAmount:It?.amount.toString()||"",numAppliedDiscounts:Be,discountAmount:xe?.toString()||"",numShippingOptions:V,shippingAmount:N?.cost?.amount?.toString()||"",tipAmount:Fe?.amount?.amount.toString()||"",shopAccountUuid:v.value,isFromShopApp:De,cartToken:Ue,merchandiseIssueType:we?Ve:"",trackingVisit:He,hasCheckoutExtension:qe,requiresShipping:t.isShippingRequired.value,flow:p}}),_(S=>S+1))},[c,K,L.value,q,H,A,a,n,t,e,T,v.value,Re,Be,xe,V,N,C,Fe,Ve,Ue,De,we,He,qe,t.isShippingRequired.value,p]),P(()=>{if(te)return;M.current++;const S=Gt(u)?.address,R=m.length;let G=0,Ye=0,me=0;m.forEach(ye=>{ye.funding==="credit"?G++:ye.funding==="debit"&&Ye++,ye.expired&&me
2++});const Mt=R>0&&R===me;a.monorailEvent({schemaId:"shopify_pay_payment_page_wallet_state/1.2",payload:{...x(n,t,e),shopAccountUuid:v.value,counter:M.current,numCreditCards:G,numDebitCards:Ye,numCards:R,numExpiredCards:me,isDefaultCardExpired:Mt,numShippingAddresses:u.length,defaultShippingAddressHasCompanyName:!!S?.company?.trim(),defaultShippingAddressHasAddress2:!!S?.address2?.trim(),defaultShippingAddressHasPhoneNumber:!!S?.phone?.trim(),installmentsPrequalifiedAmount:oe?.amount?.toString(),installmentsPrequalifiedCurrency:oe?.currencyCode,isPrequalifiedForInstallments:!!oe,installmentsAdditionalInformationRequired:!pe||pe.requiresAdditionalInformation}})},[te,M,u,m,v.value,a,n,t,e,oe,pe]);const ne=B(S=>!K||!j?.availableLoanTypes?!1:j.availableLoanTypes.includes(S),[K,j?.availableLoanTypes]),ze=t.installments.ineligibilityReasons,Ge=i.user.installments.isRejected.value,$e=Y(()=>{const S=ze.value;return Ge||!c?JSON.stringify(["user_rejected"]):S.length>0?JSON.stringify(S):""},[Ge,c,ze.value]);P(()=>{te||A&&!isNaN(A.amount)&&a.monorailEvent({schemaId:"shop_pay_installments_eligibility/2.1",payload:{...x(n,t,e),userId:I,checkoutEligible:K,splitPayEligible:ne("SPLIT_PAY"),interestBearingEligible:ne("INTEREST"),zeroPercentEligible:ne("ZERO_PERCENT"),paymentDue:A.amount,currency:A.currencyCode,ineligibilityReason:$e,spiPreselected:ie.value.spiPreselected,preselectionReason:ie.value.preselectionReason}})},[K,I,$e,ne,te,A,ie.value.spiPreselected,ie.value.preselectionReason,a,n,t,e]);const he=B(()=>{a.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...x(n,t,e),action:"credit_card_select"}})},[a,n,t,e]),We=B(()=>{a.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...x(n,t,e),action:"payment_method_ideal"}})},[a,n,t,e]);P(()=>{if(!Z){de&&(s.error(new Ss("Selected credit card and payment method misaligned"),{severity:"warning",metadata:{selectedCreditCard:{value:JSON.stringify(de)},selectedPaymentMethod:{value:JSON.stringify(Z)}}}),he());return}$t(Z)?he():Wt(Z)&&We()},[de,he,Z,We,s]);const Ke=B((S,R)=>{const G="isEphemeralAddress"in S&&S.isEphemeralAddress;a.monorailEvent({schemaId:"shopify_pay_payment_page_select_shipping_address/1.4",payload:{...x(n,t,e),previousAddressId:isNaN(Number(R?.id))?-1:Number(R?.id),previousAddressCountry:R?.address?.countryCode??"",currentAddressId:isNaN(Number(S.id))?-1:Number(S.id??-1),currentAddressCountry:S.address.countryCode??"",...R?.id&&isNaN(Number(R.id))?{previousAddressUuid:R.id}:{},...!G&&S.id&&isNaN(Number(S.id))?{currentAddressUuid:S.id}:{},ephemeral:G,previousAddressPreferred:R?.userPreferred,currentAddressPreferred:S.userPreferred}})},[a,n,t,e]);P(()=>{y&&g.current?.id!==y.id&&Ke(y,g.current),g.current=y},[y,Ke])}
2class Ss extends Error{constructor(){super(...arguments),this.name="MissingCreditCardOnPaymentMethod"}}const _s=lt({displayName:"ShopPayCaptcha",load:()=>ut(()=>vt(()=>import("./ShopPayCaptcha.D1P4QA8k.js").then(e=>e.S),__vite__mapDeps([7,1,8,2,3,4,5,9,10,11,12])))}),Ps="sYMP2",bs="aPplN",Cs="N5SeL",ks="fdTMm",As="ekZTm",Is="UmHzB",Es="JPhUL",Ms="_7k6aq",Ts="CmqN5",Ls="Evr2B",Q={Button:Ps,disabled:bs,borderRadiusBase:Cs,displayInlineBlock:ks,paddingInlineSmall400:As,paddingInlineSmall300:Is,paddingInlineBase:Es,paddingBlockSmall400:Ms,paddingBlockSmall300:Ts,paddingBlockBase:Ls},Os=Lt(function({children:n,displayInlineBlock:t=!1,borderRadiusBase:o=!1,paddingInline:s="small300",paddingBlock:a="small300",...i},c){return h("div",{className:Ot(Q.Button,o&&Q.borderRadiusBase,t&&Q.displayInlineBlock,i.disabled&&Q.disabled,Q[Je("paddingInline",s)],Q[Je("paddingBlock",a)]),children:h(Ae,{variant:"plain",ref:c,...i,children:n})})});function be({open:e,blocking:n,title:t,description:o,onClose:s,cta:a,onClickCta:i,secondaryAction:c,onPressSecondaryAction:r,cancel:l,onPressCancel:d}){const m=h(X,{children:[o,h(gt,{gap:"small-200",padding:"base none none none",children:[h(Ae,{inlineSize:"fill",variant:"primary",onClick:i,children:a}),c?h(Ae,{inlineSize:"fill",onClick:r,children:c}):null,l?h(Os,{borderRadiusBase:!0,inlineSize:"fill",onClick:d,paddingBlock:"base",children:l}):null]})]});return n?h(nt,{blocking:!0,open:e,heading:t,children:m}):h(nt,{open:e,heading:t,onHide:s,children:m})}const Ns={[w.Generic]:_e.PaymentErrorModalGeneric,[w.SignInFailed]:_e.PaymentErrorModalSignInFailed,[w.ContinueWithShopPay]:_e.PaymentErrorModalContinueWithShopPay};function Rs(){const{i18n:e,userEvents:n,source:t,checkout:o,shop:s,shop:{name:a},shopPay:i,router:c}=k(),r=c.currentUrl.value,{buyerIdentity:l}=ee(),[d,p]=Ce(!1),[u,m]=Ce(null),y=Ns[u?.type??w.Generic],{href:g,redirectToGuestCheckout:E}=Sn(y),_=B(()=>{i.session.unstable_setUnauthenticatedErrorModal(void 0)},[i.session]),M=B(()=>{n.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.1",payload:{...x(t,o,s),action:`${y}_close`}}),_()},[_,y,n,t,o,s]),b=B(()=>{if(!g){_();return}E()},[g,_,E]),f=B(async()=>{n.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.1",payload:{...x(t,o,s),action:"change_email"}}),_(),setTimeout(()=>{!!l.value?.customerProfile?i.session.unstable_updateVerificationTrigger({source:st.ErrorModalClearEmail}):window.dispatchEvent(new Event("shop_pay_verification_reset"))},0)},[l,_,n,t,o,s,i.session]),C=B(async()=>{n.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.1",payload:{...x(t,o,s),action:"continue_with_shop_pay"}}),_(),i.session.unstable_updateVerificationTrigger({source:st.ErrorModalContinue})},[_,n,t,o,s,i.session]),T=i.session.unauthenticatedErrorModal.value;P(()=>{if(!T){p(!1);return}m(T),p(!0)},[T]);const L=Y(()=>{switch(u?.type){case w.Generic:return e.translate("unauthenticated_modals.generic.title");case w.SignInFailed:return e.translate("unauthenticated_modals.sign_in_failed.title");case w.ContinueWithShopPay:return e.translate("unauthenticated_modals.continue_with_shop_pay.title");default:return""}},[u,e]);if(!u)return null;const I=Te(r.search)?h(gt,{direction:"inline",gap:"small-500",alignItems:"center",children:[e.translate("unauthenticated_modals.continue_with_shop_pay.cancel",{shopName:a}),h(_n,{type:"external",size:"small"})]}):e.translate("unauthenticated_modals.generic.cta");switch(u.type){case w.Generic:return h(be,{blocking:!0,open:d,onClose:M,title:L,description:e.translate("unauthenticated_modals.generic.description",{shopName:a}),cta:I,onClickCta:b});case w.SignInFailed:return h(be,{open:d,onClose:M,title:L,description:e.translate("unauthenticated_modals.sign_in_failed.description",{shopName:a}),cta:I,onClickCta:b});case w.ContinueWithShopPay:return h(be,{blocking:!0,open:d,onClose:M,title:L,description:e.translate("unauthenticated_modals.continue_with_shop_pay.description",{email:h(Pn,{type:"strong",children:u.email}),shopName:a}),cta:e.translate("unauthenticated_modals.continue_with_shop_pay.cta"),onClickCta:C,secondaryAction:e.translate("unauthenticated_modals.continue_with_shop_pay.secondary"),onPressSecondaryAction:f,cancel:I,onPressCancel:b});default:return null}}function xs(){const{checkout:e,router:n,shopPay:t}=k(),{currentDetour:o}=ft().value,s=Cn(),a=kn()&&!e.configuration.isUniversalCheckoutFinalizer&&!Te(n.currentUrl.value.search)&&!s&&!o,i=n.currentUrl.value.normalizedPath;return P(()=>()=>e.checkoutExit.cancelRedirectProgress(),[e.checkoutExit,i]),h(X,{children:[h(ke,{when:()=>a&&t.session.isInternalProgressing.value,children:h(rt.Preload,{})}),h(ke,{when:()=>a&&e.checkoutExit.progressPhase.value==="visible",children:h(rt,{})})]})}function Bs({children:e}){const{checkout:n,source:t,observability:o,userEvents:s,shop:a,shopPay:i}=k(),c=n.latestReceipt.value,{promptCreditCard:r}=Pt().value,l=n.installments.paymentMethodMustSupportInterestBearingLoans.value,d=i.user.isUnauthenticatedSession.value,p=D(null),u=p.current?.id||"no-failed-receipt";return P(()=>{c&&c.status==="failed"&&(p.current=c)},[c]),P(()=>{r&&l&&s.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...x(t,n,a),action:"new_debit_card_form"}})},[l,r,s,t,n,a]),ys(),vs(),fs(),bn({enabled:i.session.isLoading.value,onTimeout:m=>{o.counter({name:"shop_pay_root_loading_timeout",value:1}),o.log("shop_pay_root_loading_timeout","ShopPayRoot loading timeout",{timeout:m})}}),h(X,{children:[h(ds,{}),h(X,{children:[h(xs,{}),e,h(ke,{when:i.user.isUnauthenticatedUser,children:h(Rs,{})}),d&&h(_s,{})]},u)]})}function Fs(){const{shopPay:e}=k(),n=St(),t=e.session.initialization.value.status;P(()=>{t==="initialized"&&e.user.unstable_setApplePayAvailable(n.value)},[t,n.value,e])}const Ds={id:"8b0aa9c5a6b1f77d064216d93704ed01ecc60aca1a2317877fc6478cdfa553e8",type:"mutation",name:"CheckoutSessionUpdateSelections",source:"mutation CheckoutSessionUpdateSelections($checkoutContextInput:CheckoutContextInput!,$selectedPaymentMethodId:String,$selectedPaymentMethodOption:String){checkoutSessionUpdateSelections(checkoutContextInput:$checkoutContextInput selectedPaymentMethodId:$selectedPaymentMethodId selectedPaymentMethodOption:$selectedPaymentMethodOption){userErrors{message field __typename}__typename}}"};function Us(){const{shopPay:e,graphql:{shopPayGraphql:n},source:t,shop:o}=k(),s=Kt({source:t}),a=D(void 0),i=D(!1);!i.current&&e.session.initialization.peek().status==="initialized"&&(i.current=!0,a.current={selectedPaymentMethodOption:e.session.paymentMethodOption.peek(),userSelectedPaymentMethod:e.session.selectedPaymentMethod.peek()}),Me(()=>{if(e.session.isLoading.value)return;const c=e.session.selectedPaymentMethod.value,r={selectedPaymentMethodOption:e.session.paymentMethodOption.value,userSelectedPaymentMethod:c};
2if(!(Yt(a.current,r)||ws(r))){if(a.current===void 0){i.current=!0,a.current=r;return}n.mutate(Ds,{variables:{checkoutContextInput:{checkoutIdentifier:t.checkoutSessionIdentifier??"unknown",checkoutVersion:s,shopId:Jt(o.id),shopifyDomain:o.myshopifyDomain},selectedPaymentMethodId:r.userSelectedPaymentMethod?.id,selectedPaymentMethodOption:r.selectedPaymentMethodOption?.name}}),a.current=r}})}const ws=e=>Object.values(e).every(n=>!n);function Vs(e){return e.type==="customOnsite"?e.name:e.type}function ct(e){return[...e].map(Vs).sort().join("|")}function bt(){const{observability:e,userEvents:n,checkout:t,shop:o,shopPay:s,consentManager:a,checkout:{addressManager:{shipping:i}}}=k(),c=Ee(qn()),r=ft(),l=se(()=>r.value.currentDetour?.type==="shopPayLogin"),d=Un(),p=se(()=>d()),{data:u,loading:m}=pt(wn,{isOnShopPayLoginDetour:l,newSignupLoginVariant:c,simulatedBuyerDetails:p}),y=typeof window>"u",g=ce(),E=Ln(),_=ee(),M=On(),b=jt(),{updateCheckoutAddress:f}=Bn(),C=_.buyerIdentity.value?.customerProfile,T=g.shippingAddress.value,{value:L}=_.paymentMethods,v=Zt({managedByMarketsPro:_.managedByMarketsPro.value}),I=St(),{value:O}=Fn({isApplePayAvailable:I.value}),F=D(L?ct(O):void 0),q=Qt({paymentRequiredMethod:M.value,isIdealEnabledForShopPay:v}),H=B(N=>Xt(N,O),[O]);async function V(N){const A=i.value.immutableAddresses.value.filter(({id:J})=>J!==Ze),z=M.value,U=s.applyBuyerDetailsToCheckout(N,{checkout:t,observability:e,userEvents:n,shop:o,hydration:{negotiatedPaymentMethods:O,isApplePayAvailable:I.value,immutableAddresses:A,proposedShippingAddress:T,canUpdateDeliveryAddress:b.value,mustSelectProvidedAddress:_.mustSelectProvidedAddress.value??!1,paymentRequiredMethod:z,negotiatedCardUuid:an({proposedPaymentLines:g.paymentLines.value})},customerProfile:C,paymentExemptionReason:E.value,idealEnabledForShopPay:v});if(U.status==="card_vaulting_disabled")return;const{shippingAddress:W}=U.appliedAddresses;W&&!on(T,W)&&e.log("shipping_address_auto_applied","[useShopPayParts] Shop Pay hydration applied a new shipping address to the proposal",{address_id:U.hydrationResult.selectedShippingAddress?.id}),y||rn({consentManager:a,shop:o},N)}P(()=>{const N=s.session.initialization.peek(),A=u.value,z=N.status==="initialized"&&A===void 0;if(s.session.unstable_setLoading(z?!1:m.value),m.value)return;const U=s.session.unstable_receiveBuyerDetailsResult(A);U.status==="initialize"&&V(U.buyerDetails)},[m.value,u.value]),P(()=>{if(!u.value||u.value.status!=="success"||L===void 0)return;const N=H(u.value.paymentMethods),A=en(N,u.value.creditCards);if(!(u.value.creditCards.length>0||A.some(tn)))return;const W=ct(O);if(W===F.current)return;F.current=W,s.user.unstable_setApplePayAvailable(I.value),s.user.unstable_setPaymentMethodsFromBuyerDetails(A);const J=s.session.selectedPaymentMethod.value;if(!J)return;const le=nn({addressesForUI:u.value.addresses,immutableAddresses:i.value.immutableAddresses.value.filter(({id:j})=>j!==Ze),proposedShippingAddress:g.shippingAddress.value,mustSelectProvidedAddress:_.mustSelectProvidedAddress.value}),ae=sn({paymentMethod:J,billingAddressToSelect:le,shouldUseLpmBillingAddress:q});ae&&f({billingAddress:ae},!0)},[i,H,u.value,I.value,_.mustSelectProvidedAddress,L,O,g.shippingAddress,s.session,q,s.user,f]),y&&u.value&&u.value.status==="success"&&s.session.initialization.peek().status==="pending"&&V(u.value)}function Ct(){const{observability:e,shopPay:n}=k(),t=ee(),o=ce(),[,s]=Dn({allowPreselect:!1}),a=D(void 0);Me(()=>{const i=n.session.selectedPaymentMethod.value,c=t.paymentMethods.value,r=n.user.paymentMethods.value,l=n.session.promotedPaymentMethods.value;Ie(()=>{if(!i){const p=a.current;if(p===void 0||Qe(p.method,r)||Qe(p.method,l))return;const u=o.paymentLines.value,m=u.some(g=>ve(g.method)===p.primaryLineKey);if(a.current=void 0,!m)return;const y=u.filter(g=>Se(g)||!p.lineKeys.includes(ve(g.method)));y.length!==u.length&&(o.paymentLines.value=y);return}const d=cn({paymentMethod:i,negotiatedPaymentMethods:c,observability:e});if(d===void 0){a.current=void 0,o.paymentLines.value=o.paymentLines.value.filter(Se);return}d==="SHOP_PAY"&&An(o.paymentLines.value)!==void 0||(s(d),a.current={method:i,primaryLineKey:d,lineKeys:o.paymentLines.value.filter(p=>!Se(p)).map(p=>ve(p.method))})})})}const qs=["begin_page_load","first_meaningful_paint","page_loaded"];function Hs(){const{client:e,userEvents:n,source:t,checkout:o,shop:s,shopPay:a}=k(),i=D(new Set),c=B(f=>{i.current.has(f)||(i.current.add(f),n.monorailEvent({schemaId:"shopify_pay_payment_page_ready/2.1",payload:{...x(t,o,s),success:!0,status:f,clientTimestampMs:Date.now()}}))},[n,t,o,s]),r=B(f=>{for(const C of qs)if(c(C),C===f)return},[c]);Me(()=>{const f=a.session.isLoading.value,C=a.session.initialization.value.status==="initialized";Ie(()=>{r("begin_page_load"),f&&r("first_meaningful_paint"),C&&r("page_loaded")})});const l=t.type==="shopPayExternal",d=yt(),p=In(Hn.ShopifyPay,a.config.redirectSource,d?.trackingUnique,d?.trackingVisit),u=D(!1);P(()=>{!u.current&&!l&&(u.current=!0,p())},[p,l]);const m=En().value,y=l||m,g=zn(),E=l?g.analyticsTraceId.value:void 0,{checkoutSessionIdentifier:_="checkout_identifier_undefined"}=t,{redirectSource:M,tracking:b}=a.config;return P(()=>{if(!y)return;const T=window.location.pathname.split("/").pop()==="shoppay_login";Te()&&!T&&n.monorailEvent({schemaId:"shop_app_page_load/9.0",payload:{...x(t,o,s),platform:"web",locale:navigator.language,userToken:b.unique??e.cookies.get("_shopify_y")??"",webSessionToken:b.visit??e.cookies.get("_shopify_s")??"",pageType:"pay_payment_page",pageValue:_}}),n.monorailEvent({schemaId:"shopify_pay_page_load/2.6",payload:{...x(t,o,s),pageType:"payment_page",clientTimestampMs:Date.now(),redirectSource:M,analyticsTraceId:E}})},[_,e.cookies,n,t,o,s,M,y,E,b.unique,b.visit]),null}function zs({hasUnauthorizedError:e,isShopPayExternal:n,redirectSource:t}){return e&&t!==Xe.CheckoutAutomaticRedirect&&t!==Xe.CheckoutUniversalRedirect?{type:"login"}:n?{type:"externalDetour",route:e?"shopPayLogin":"terminalError",replace:e}:{type:"guestCheckout"}}function Gs({children:e}){const{observability:n,source:t,shopPay:{config:o,session:{initialization:s}}}=k(),{checkoutAsGuestUrl:a,redirectSource:i}=o,{detour:c}=Mn(),{replaceShopPayInHistory:r}=mt(),l=t.type==="shopPayExternal",d=s.value,p=d.status==="pending";Vn(p);const u=d.status==="failed",m=d.status==="failed"&&d.reason==="fetch"?d.errors:void 0,y=!!m?.some(g=>g.message===ln);if(P(()=>{u&&!y&&(n.counter({name:"shop_pay_failed_to_fetch_buyer_session_details",value:1}),n.log("shop_pay_provider_buyer_session_details_fetch_failed","Unexpected error fetching buyer session details",{errors:m}))},[u,y,m,n]),u){const g=zs({hasUnauthorizedError:y,isShopPayExternal:l,redirectSource:i});return g.type==="login"?(c("shopPayLogin",{routerOptions:{replace:!0}}),null):g.type==="externalDetour"?(n.leaveErrorBreadcrumb("shouldRedirect=true",{route:g.route}),c(g.route,{routerOptions:{replace:g.replace}}),null):(n.error(new un("Failed to fetch buyer session details. Redirecting to guest checkout"),{severity:"warning"}),n.log("shop_pay_provider_guest_checkout_redirected","[ShopPayProvider] Redirecting to guest checkout"),r(a),null)}return h(X,{children:e})}function pa({simulated:e,children:n}){Us();const{observability:t,shopPay:o}=k(),s=ee().buyerIdentity.value?.purchasingCompany,{replaceShopPayInHistory:a}=mt();return e?h(Ws,{children:n}):s?(t.log("shop_pay_shell_redirected","Shop Pay is not supported for B2B customers. Redirecting to guest checkout."),a(o.c
2onfig.checkoutAsGuestUrl),null):h(X,{children:[h(Hs,{}),h($s,{children:n})]})}function $s({children:e}){return bt(),Fs(),Ct(),h(Gs,{children:h(_t,{children:h(Bs,{children:e})})})}function Ws({children:e}){return bt(),Ct(),h(_t,{children:e})}export{pa as ShopPayCheckout};
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.