1import{u as l,i as Pe,T as B,S as Ee,q as R,h as O,e as j,o as Ke,f as $,A as Y,D as je,g as re,k as we,a as $e,_ as Ye,l as Je}from"./esnext-vendor.7EcvH7tF.js";import{ak as ae,Q as v,bC as J,fi as Qe,fj as ce,fk as Xe,fl as Ze,B as en,fm as Re,e$ as nn,fn as Q,a2 as le,fo as Ae,eW as ue,dd as K,eX as tn,ax as Se,fp as on,fq as sn,fr as rn,bF as an}from"./utilities-previous.BNOUhCqt.js";import{u as Ce,a as cn,S as ln}from"./models-ShopPayBuyerDetails.model.C8ab24Bz.js";import{u as Ie,U as un}from"./hooks-useShopPayNewSignupLoginExperiment.Cks6ggXa.js";import{L as Ue,B as q,f3 as dn,fa as mn,b as hn,bi as de,eL as Oe,f as De,fb as gn,fc as pn,fd as fn,eM as oe,a2 as _n,t as T,fe as yn,bo as He,aR as Sn,k as W,ag as x,eK as bn,bs as vn,N as Ln,O as kn,H as Pn,n as En}from"./hydrate.CvWSYK3c.js";import{i as X,a as wn}from"./redemption-promotions.BGj0zZCl.js";import{MobileOrderSummary as Rn}from"./component-MobileOrderSummary.BWejTkiU.js";import{c as te}from"./Section.DsxTs_3v.js";import{R as be,D as ie,d as An,e as Cn,u as In,a as Un,p as On,S as Dn,c as Hn}from"./utilities-publishMessage.BFG4jKHA.js";import{R as Bn,n as Fn,i as Mn,a as Tn,s as xn}from"./hooks-useShouldRevealCustomization.xDutk-8T.js";import{g as Nn}from"./ShippingMethodRateLabel.CL24HyOG.js";import{u as zn,S as qn}from"./Page.iFMNx-gv.js";import"./app.9pOKhaB_.js";import"./shop-pay-normalizeBuyerDetails.UNB2OauO.js";import"./shared-negotiation-input-redeemable.nWvx5Mgl.js";import"./shared-permissions.FyWsJaGm.js";import"./hooks-useShopPayExternalAppContext.DJNBHtP3.js";import"./TransitionHeight.BQH3tbCb.js";import"./styles-floating-layer.module.DAWBGW8s.js";function Vn({isShopPayExternal:e}){const n=ae();return e?null:l(Pe,{when:n,children:l(Gn,{})})}function Gn(){const{i18n:e}=v(),n=B(()=>{const o=document.referrer!=="",i=window.history&&window.history.length>1;return o||i},[]),t=()=>{window.history.back()};return n?l(q,{inlineAlignment:"center",children:l(Ue,{onClick:t,accessibilityLabel:e.translate("account_management.back"),textDecoration:"none",children:e.translate("account_management.back")})}):null}function Wn(){const{href:e,label:n,onClick:t}=dn(mn.Login);return l(Ee,{children:[l(hn,{blockSize:"large-100"}),l(q,{inlineAlignment:"center",children:l(Ue,{href:e,onClick:t,textDecoration:"none",children:n})})]})}const Kn=(e,n)=>e===n||Cn.includes(e),jn=e=>e&&typeof e=="object"&&e.type==="redirect_url_on_complete"&&e.postSignInUrl,$n=e=>e&&typeof e=="string"&&e.includes(ie);function Be({iframeOrigin:e,observability:n,onError:t,onLoaded:o,onLoggedIn:i,skip:r=!1}){const s=R(a=>{switch(a.action){case be.Loaded:return o?.();case be.Error:return t?.(a.message)}},[o,t]);O(()=>{if(r)return;const a=c=>{if(!Kn(c.origin,e))return;const{data:u}=c;if(jn(u))try{const m=new URL(u.postSignInUrl).searchParams.get("token");m&&i?.(m)}catch{t?.("shop_pay_embedded_login_url_parse_error"),n?.log("shop_pay_embedded_login_url_parse_error","Failed to parse redirect URL")}else if($n(u))try{const[d,...m]=u.split(ie);if(d!==An)return;const g=JSON.parse(m.join(ie));s(g)}catch{t?.("shop_pay_embedded_login_event_error"),n?.log("shop_pay_embedded_login_event_error","Failed to parse event")}};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[i,n,e,t,s,r])}var I=(e=>(e.Seamless="seamless",e.OAuth="oauth",e.OAuthWithEmbeddedContext="oauthWithEmbeddedContext",e.Embedded="embedded",e))(I||{});function Z(){const{shop:e,shopPay:n,embed:t,mobileCheckoutSdk:o}=v(),i=o.enabled||t?.isCheckoutKit();return J(t?.embedder)?"embedded":t?.isFlagshipPartner||Qe(n)?"seamless":ce(n)||i&&e.hasFlagEnabled(Xe)?"embedded":i&&e.hasFlagEnabled(Ze)?"oauthWithEmbeddedContext":i?"seamless":"oauth"}function Yn(){return en()}function me(e,n,t){return!!e?.isFlagshipPartner||t&&Re(n)}function Jn({customProperties:e}){return e?.color?.schemes?.scheme1?.base?.background}const Qn="(prefers-color-scheme: dark)";function Xn(){const e=j(!1);return Ke(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia(Qn);e.value=n.matches;const t=o=>{e.value=o.matches};if(typeof n.addEventListener=="function")return n.addEventListener("change",t),()=>n.removeEventListener("change",t)}),e}function Zn(){const{checkout:e}=v(),n=Xn();return $(()=>{const{customProperties:t,darkModeCustomProperties:o}=e.configuration.branding.theme,r=n.value&&o.value||t.value,s=Jn({customProperties:r});if(typeof document<"u"&&typeof window<"u"&&typeof window.getComputedStyle=="function"){const c=Nn(document.body);if(Bn.test(c))return c}return s})}const et="rgba(255, 255, 255, 1)";function Fe(){const e=Zn();return $(()=>{const n=Fn(e.value??et);
1return{isDark:Mn(n,"rgb(255, 255, 255)"),parentBackgroundColor:n}})}function Me(){const e=Fe();return Y(e.peek()).current}function he(e){const n=Y("");return!n.current&&nn(e)&&(n.current=e),n.current}const Te=(e="")=>{const{client:n,shopPay:t,environment:o,i18n:{locale:i},shop:r,source:{checkoutSessionIdentifier:s},embed:a,checkout:{proposal:{proposed:c}}}=v(),u=r.hasFlagEnabled(Q),d=me(a,t,u),m=he(c.email.value),g=u?m:c.email.value,_=X(n.initialRequest.url),b=le().buyerIdentity.value?.customerProfile,f=t.signup.skipAutomaticLoginAttempt.value,y=de({include:{shopId:!0}}),{parentBackgroundColor:k,isDark:E}=Me();return B(()=>{if(!s)return{origin:"c1_login",frameUrl:"",flow:"pay_checkout_login"};const{origin:p,flowVersion:L}=nt(t),P=new URLSearchParams(n.initialRequest.url.search),h=new URLSearchParams;h.set("locale",i),h.set("analytics_trace_id",e),h.set("origin",p),h.set("checkout_token",s),h.set("flow","pay_checkout_login"),h.set("flow_version",L??""),h.set("authentication_level","phone"),h.set("target_origin",window.location.origin),h.set("storefront_domain",r.domain),h.set("layout","full"),E&&h.set("theme","dark"),k&&h.set("parent_background_color",k),_&&(h.set("force_authentication","true"),h.set("prompt","login"));const w=P.get("login_hint");
1w?h.set("login_hint",w):d&&g&&!_&&!f?h.set("login_hint",g):!f&&b?.email&&h.set("login_hint",b.email);const U=P.get("shop_client_uuid")??a?.shopClientUuid??P.get("client_uuid");U&&h.set("client_uuid",U),y(h,P);const C=new URL("/accounts/login/embedded",o.services.shopServer.url);return C.search=h.toString(),{origin:p,frameUrl:C.href,flow:"pay_checkout_login"}},[e,E,k,s,n.initialRequest.url.search,b?.email,o.services.shopServer.url,_,i,a?.shopClientUuid,y,r.domain,g,t,f,d])};function nt(e){return ce(e)?{origin:Oe.PaymentRequest,flowVersion:"iframe"}:{origin:"c1_login",flowVersion:"iframe"}}function ge({analyticsTraceId:e,loginData:n}){const{progress:t}=De(),{shopPay:o,observability:i}=v(),{config:r,updateAccessToken:s}=o,{exchangeSessionTokenForCookie:a}=In(),{extendBuyerIdentity:c}=Un(),{checkoutAsGuestUrl:u}=r,{replaceShopPayInHistory:d}=Ae(),{flow:m,origin:g}=n;return R(async(_,b)=>{if(b)s(b);else if(_){const f=await a({token:_,origin:g,analytics_trace_id:e,flow:m});f.ok||(i.log("shop_pay_login_frame_session_token_exchange_failed","exchangeSessionTokenForCookie request failed",{status:f.status}),f.status>=500&&d(u))}await c(),o.signup.unstable_setSkipAutomaticLoginAttempt(!1),t("shop-pay-login-success")},[t,s,a,g,m,e,c,u,d,i,o.signup])}function tt({frameUrl:e,loginVariant:n,sdkLoginHintFlagEnabled:t,shopPaySdkCheckout:o}){const{checkout:i,client:r,observability:s}=v(),a=!!e,c=ot(e),u=!!i.proposal.proposed.email.value,d=new URLSearchParams(r.initialRequest.url.search).has("login_hint");O(()=>{a&&s.counter({name:"shop_pay_login_hint",value:1,attributes:{checkoutUrlHint:d,loginHintSent:c,loginVariant:n,proposedEmailAvailable:u,sdkLoginHintFlagEnabled:t,shopPaySdkCheckout:o}})},[d,a,c,n,s,u,t,o])}function ot(e){try{return new URL(e).searchParams.has("login_hint")}catch{return!1}}const it="_5Z70J",st="vUvXb",rt="K7GTB",at="WC8Ph",ct="oX06g",N={LoginIframe:it,LoginIframeHidden:st,ShopPayLoginFrameLoadingContainer:rt,ShopPayLoginFrameLoadingContainerLoading:at,ShopPayLoginFrameSkeleton:ct},lt=je(function({title:n,src:t,height:o,hidden:i=!1,onLoad:r,className:s,allow:a=ut()},c){return l("iframe",{ref:c,id:pn,title:n,src:t,onLoad:r,height:o,width:gn,className:re(N.LoginIframe,{[N.LoginIframeHidden]:i},s),"aria-hidden":i?!0:void 0,allow:a})});function ut(){return fn}function ee({hidden:e=!1,iframeLoaded:n=!1,loginData:t,onIframeLoad:o,renderListeners:i,serverDrivenAuth:r,serverRenderedIframe:s=!1}){const a=j(!1),{client:c,environment:u,i18n:d,observability:m,shop:g,shopPay:_}=v(),b=Y(null),f=Z(),{frameUrl:y}=t,k=!!y,E=!(n||a.value);Ce(E);const p=B(()=>{try{return new URL(y).origin}catch{return""}},[y]),L=Re(_);let P="empty";p===u.services.shopServer.url?P="shop_server":p===u.services.payShopifyCom.url?P="pay_shopify":p&&(P="merchant_storefront"),tt({frameUrl:y,loginVariant:f,sdkLoginHintFlagEnabled:g.hasFlagEnabled(Q),shopPaySdkCheckout:L});const h={serverDrivenAuth:r,hidden:e,shopPaySdkCheckout:L,serverRendered:c.initialRequest.isServerRendered,serverRenderedIframe:s,loginVariant:f};oe({enabled:k&&E,onTimeout:A=>{const S={timeout:A,...h,frameHostKind:P,documentReadyState:document.readyState};m.counter({name:"shop_pay_login_frame_load_timeout",value:1,exportImmediately:!0,attributes:S}),m.log("shop_pay_login_frame_load_timeout","Shop Pay login iframe never fired its load event",{...S,iframeOrigin:p},{exportImmediately:!0})}}),oe({enabled:!k,onTimeout:A=>{const S={timeout:A,...h,documentReadyState:document.readyState};m.counter({name:"shop_pay_login_frame_url_missing",value:1,exportImmediately:!0,attributes:S}),m.log("shop_pay_login_frame_url_missing","Shop Pay login frame never received a URL",S,{exportImmediately:!0})}});const w=r?370:250,[U,C]=we(w),D=R(A=>{C(A)},[]),F=R(()=>{a.value=!0,o?.()},[a,o]);return y?l(Ee,{children:[i?.({iframeOrigin:p,iframeRef:b,onResized:D}),l(lt,{ref:b,title:d.translate("verification.title"),src:y,onLoad:F,height:U,hidden:e})]}):null}function xe({iFrameRef:e,iframeOrigin:n,isEmbeddedShopPayTheme:t=!1}){const o=_n(),i=Fe(),r=t&&n?n:window.location.origin,s=R(()=>{if(!e.current?.contentWindow)return;
1const{isDark:c,parentBackgroundColor:u}=i.value,d={theme:c?"dark":"light",type:"theme"};u&&(d.parentBackgroundColor=u),e.current.contentWindow.postMessage(d,r)},[e,i,r]),a=R(()=>{if(!e.current?.contentWindow)return;const c=mt(o.customProperties.value);ht(c,o,t),e.current.contentWindow.postMessage({type:"style",style:gt(c)},r)},[e,o,r,t]);return{dispatchThemeMessage:s,dispatchStyleMessage:a,resolvedParentBackground:i}}const dt=e=>["borderRadius","control"].includes(e);function Ne(e,n){const t=Object.entries(e).flatMap(([o,i])=>typeof i=="object"&&!Array.isArray(i)&&i!=null?n[o]?Object.entries(Ne(i,n[o])):[]:n[o]!=null&&i!=null?[[n[o],i]]:[]);return Object.fromEntries(t)}function mt(e){const n=Object.fromEntries(Object.entries(e).filter(([t])=>dt(t)));return Ne(n,K)}function ht(e,n,t){const o=ue(),i=K.borderRadius.base,r=K.borderRadius.large,s=K.control.borderRadius,a=m=>o||!e[m],c=n.configuration.cornerRadius.base?`${n.configuration.cornerRadius.base}px`:T.borderRadius.base,u=n.configuration.primaryButton.cornerRadius;let d=T.borderRadius.base;u==="none"?d="0px":u&&(d=T.borderRadius[u]??T.borderRadius.base),a(i)&&(e[i]=c),t?e[r]=T.borderRadius.base:a(r)&&(e[r]=d),e[s]||(e[s]=T.borderRadius.base)}const gt=e=>Object.entries(e).map(([n,t])=>`${n}: ${t};`).join("");function ze({iframeRef:e,iframeOrigin:n,onLoggedIn:t}){const{checkout:o,observability:i}=v(),{isEmbeddedShopPayTheme:r}=o.configuration.branding,{dispatchThemeMessage:s,dispatchStyleMessage:a,resolvedParentBackground:c}=xe({iFrameRef:e,iframeOrigin:n,isEmbeddedShopPayTheme:r}),u=c.value,d=R(()=>{s(),a()},[s,a]);return O(()=>{s()},[s,u]),Be({iframeOrigin:n,observability:i,onLoaded:d,onLoggedIn:t}),null}function pt({analyticsTraceId:e,...n}){const t=Te(e),o=ge({analyticsTraceId:e,loginData:t});return l(ee,{...n,loginData:t,renderListeners:({iframeOrigin:i,iframeRef:r})=>l(ze,{iframeRef:r,iframeOrigin:i,onLoggedIn:o}),serverDrivenAuth:!0})}function ft(){const e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,n=>n.toString(36)).join("")}const pe="c1_login",fe="pay_checkout_login";function ve(){return{origin:pe,frameUrl:"",flow:fe}}function _t(e,{analyticsTraceId:n,checkoutSessionIdentifier:t,domain:o,locale:i,oAuthState:r,sourceId:s}){e.set("client_id",""),e.set("redirect_uri",`https://${o}/services/login_with_shop/callback`),e.set("scope","openid email profile"),e.set("response_type","code"),e.set("state",r),e.set("storefront_domain",o),e.set("locale",i),e.set("analytics_trace_id",n),e.set("origin",pe),e.set("checkout_token",t),e.set("checkout_source_id",s),e.set("flow",fe),e.set("target_origin",`https://${o}`),e.set("ux_mode","iframe"),e.set("layout","full")}function yt(e,n){return e.get("shop_client_uuid")??n??e.get("client_uuid")}function qe(e="",{includeEmbeddedContext:n=!1}={}){const{client:t,embed:o,shopPay:i,i18n:{locale:r},shop:s,source:{checkoutSessionIdentifier:a,sourceId:c},checkout:{proposal:{proposed:u}}}=v(),{config:d,signup:m}=i,g=s.hasFlagEnabled(Q),_=he(u.email.value),b=g?_:u.email.value,f=me(o,i,g),y=X(t.initialRequest.url),k=le().buyerIdentity.value?.customerProfile,E=yn(),p=m.skipAutomaticLoginAttempt.value,{redirectUrl:L}=d,P=de({include:{shopId:!0}}),{parentBackgroundColor:h,isDark:w}=Me(),U=n?P:void 0,C=n?o?.shopClientUuid:void 0,D=n?void 0:E,F=t.unstable_getSerialization("shopPayLoginOAuthState"),A=B(()=>F??ft(),[F]);return B(()=>{if(!a)return ve();const S=new URLSearchParams;_t(S,{analyticsTraceId:e,checkoutSessionIdentifier:a,domain:s.domain,locale:r,oAuthState:A,sourceId:c}),D!==void 0&&S.set("shop_id",String(D)),w&&S.set("theme","dark"),h&&S.set("parent_background_color",h),L&&S.set("checkout_redirect_url",L),y&&(S.set("force_authentication","true"),S.set("prompt","login")),d.transactionParams&&S.set("transaction_params",d.transactionParams);const z=new URLSearchParams(t.initialRequest.url.search),V=z.get("login_hint");V?S.set("login_hint",V):f&&b&&!y&&!p?S.set("login_hint",b):!p&&k?.email&&S.set("login_hint",k.email);const G=yt(z,C);G&&S.set("client_uuid",G),U?.(S,z);try{const M=new URL("/services/login_with_shop/authorize",`https://${s.domain}`);return M.search=S.toString(),{origin:pe,frameUrl:M.href,flow:fe}}catch{return ve()}},[d.transactionParams,e,U,a,t.initialRequest.url.search,f,k?.email,s.domain,C,y,b,w,h,r,D,L,p,A,c])}const Ve=(e="")=>qe(e,{includeEmbeddedContext:!0});function St({analyticsTraceId:e,...n}){const t=Ve(e),o=ge({analyticsTraceId:e,loginData:t});return l(ee,{...n,loginData:t,renderListeners:({iframeOrigin:i,iframeRef:r})=>l(ze,{iframeRef:r,iframeOrigin:i,onLoggedIn:o}),serverDrivenAuth:!0})}const Ge=(e="")=>qe(e);function bt({iframeRef:e}){const{checkout:n,environment:t,observability:o,router:i,source:r}=v(),{replaceShopPayInHistory:s}=Ae(),a=new URL(t.services.shopServer.url).origin,c=r.checkoutSessionIdentifier,u=Y(!1);return O(()=>{const d=({data:m,origin:g,source:_})=>
1{if(u.current||g!==a||!e.current?.contentWindow||_!==e.current.contentWindow||!m||typeof m!="object"||!("type"in m)||m.type!=="pay_guest_session_ready")return;const f=new URL(window.location.href);wn(f.pathname)&&(u.current=!0,o.counter({name:"guest_handoff_received",value:1,exportImmediately:!0,requiresKeepalive:!0}),o.log("guest_handoff_received","Shop Pay guest handoff received",{checkoutToken:c},{exportImmediately:!0,requiresKeepalive:!0}),f.pathname=i.resolve("/shoppay").pathname,n.unstable_setRedirectingExternally(!0),setTimeout(()=>s(f.toString()),0))};return window.addEventListener("message",d),()=>window.removeEventListener("message",d)},[n,c,e,o,s,i,a]),null}function vt({analyticsTraceId:e,hidden:n,iframeLoaded:t,onIframeLoad:o,serverRenderedIframe:i}){const r=Ge(e);return l(ee,{hidden:n,iframeLoaded:t,loginData:r,onIframeLoad:o,renderListeners:({iframeRef:s})=>l(bt,{iframeRef:s}),serverDrivenAuth:!0,serverRenderedIframe:i})}var se=(e=>(e.Partner="sdk_partner",e.Merchant="sdk_merchant",e))(se||{});const Lt="c1_login",We=(e="")=>{const{client:n,shopPay:t,embed:o,environment:i,i18n:{locale:r},observability:s,shop:a,source:{checkoutSessionIdentifier:c},mobileCheckoutSdk:u,checkout:{proposal:{proposed:d}}}=v(),m=a.hasFlagEnabled(Q),g=he(d.email.value),_=m?g:d.email.value,{config:b}=t,f=X(n.initialRequest.url),{transactionParams:y,tokens:k}=b,E=le().buyerIdentity.value?.customerProfile,p=He().value,L=Tn(),P=Ie(),h=i.services.payShopifyCom.url,w=n.unstable_getSerialization("shopClientUuid"),U=de({include:{shopId:!0}}),C=!!o?.isFlagshipPartner,D=me(o,t,m),F=o?.shopClientUuid,A=t.signup.skipAutomaticLoginAttempt.value;return B(()=>{if(!c)throw new tn({groupingHash:"ShopPayCheckoutIdentifierMissingError::LoginFrame"});const{origin:S,flowVersion:z,flow:V}=kt(t),G=z??(C?"iframe":void 0),M=new URLSearchParams(n.initialRequest.url.search),ne=Le(M,"shop_client_uuid")??F??Le(M,"client_uuid")??w;C&&!ne&&s.log("shop_pay_login_seamless_missing_client_uuid","[ShopPayLoginFrame] Embedded checkout missing shop_client_uuid for Login Seamless.");const H=new URLSearchParams({flow:V??"",locale:r,origin:S,isPointOfSale:String(p),transaction_params:y??"",flow_version:G??"",shopify_domain:a.myshopifyDomain,checkout_token:c,analytics_trace_id:e,shop_pay_button_variant:t.logoBrand,shop_pay_new_signup_login_variant:P});ne&&H.set("client_uuid",ne);const _e=M.get("login_hint");_e?H.set("login_hint",_e):D&&_&&!f&&!A&&H.set("login_hint",_),!A&&E?.email&&H.set("storefront_account_email",E.email),L&&H.set(xn,u.variant.isPartner()?se.Partner:se.Merchant),f||H.set("authorization",k.authorization??""),U(H,M);const ye=new URL("/pay/authentication/login-seamless",h);return ye.search=H.toString(),{origin:S,frameUrl:ye.href}},[e,U,n.initialRequest.url.search,k,c,E?.email,f,h,L,C,p,r,a.myshopifyDomain,u,F,_,w,t,P,D,A,s,y])};function Le(e,n){return e.get(n)||void 0}function kt(e){return ce(e)?{origin:Oe.PaymentRequest,flowVersion:e.flowVersion,flow:"payment_request"}:{origin:Lt,flowVersion:void 0,flow:void 0}}function Pt({iframeRef:e,iframeOrigin:n,onLoggedIn:t,onResized:o}){const{checkout:i,shopPay:r}=v(),{isEmbeddedShopPayTheme:s}=i.configuration.branding,{dispatchThemeMessage:a,dispatchStyleMessage:c,resolvedParentBackground:u}=xe({iFrameRef:e,iframeOrigin:n,isEmbeddedShopPayTheme:s}),d=u.value,m=R(()=>{On(e.current,{action:Dn.Ready}),e.current?.contentDocument?.body&&Sn(e.current.contentDocument.body)?.focus(),s&&(a(),c())},[a,c,e,s]);O(()=>{s&&a()},[a,s,d]);const g=R(_=>{r.signup.unstable_setHcaptchaToken(_)},[r.signup]);return Hn({onLoaded:m,onLoggedIn:t,onResized:o,onShareCaptchaToken:g}),null}function Et({analyticsTraceId:e,...n}){const t=We(e),o=ge({analyticsTraceId:e,loginData:t});return l(ee,{...n,loginData:t,renderListeners:({iframeOrigin:i,iframeRef:r,onResized:s})=>l(Pt,{iframeRef:r,iframeOrigin:i,onLoggedIn:o,onResized:s}),serverDrivenAuth:!1})}function wt({serverRenderedIframe:e,...n}){const{client:t}=v(),o=Z(),i=t.unstable_getSerialization("shopPayLoginAnalyticsTraceId"),r=B(()=>i??Yn(),[i]);switch(o){case I.OAuth:return l(vt,{...n,analyticsTraceId:r,serverRenderedIframe:e});case I.OAuthWithEmbeddedContext:return l(St,{...n,analyticsTraceId:r});case I.Embedded:return l(pt,{...n,analyticsTraceId:r});case I.Seamless:return l(Et,{...n,analyticsTraceId:r});default:return $e(o)}}function ke({className:e}){const{i18n:n}=v(),t=n.translate("general.loading");return l(q,{accessibilityRole:"status",accessibilityLabel:t,"aria-live":"polite",className:e,children:l(W,{blockSize:"100%",padding:"large-200",gap:"large-100",children:[l(W,{al
1ignItems:"center",gap:"large-100",children:[l(x,{delay:!1,contentDisplay:"block",inlineSize:"92px",blockSize:"32px"}),l(x,{delay:!1,contentDisplay:"block",inlineSize:"50%",blockSize:"16px"})]}),l(W,{gap:"small-400",children:l(x,{delay:!1,contentDisplay:"block",inlineSize:"100%",blockSize:"52px"})}),l(x,{delay:!1,contentDisplay:"block",inlineSize:"100%",blockSize:"52px"}),l(q,{paddingBlockStart:"large-200",children:l(W,{alignItems:"center",gap:"large-400",children:[l(x,{delay:!1,contentDisplay:"block",inlineSize:"34%",blockSize:"14px"}),l(x,{delay:!1,contentDisplay:"block",inlineSize:"100%",blockSize:"14px"})]})})]})})}function Rt({serverRenderedIframe:e=!1}={}){const{client:n,environment:t,observability:o}=v(),i=t.services.shopServer.url,r=n.unstable_legacyNavigationPerformance,s=ae(),a=j(!1),c=j(e&&!s.peek()),u=c.value,d=s.value||u,m=a.value,g=!m,_=r?.navigationStartTime??0,b=n.initialRequest.isServerRendered,f=R((p,L)=>{o.histogram({name:"shop_pay_login_form_visible_duration",value:Math.round(p-_),unit:"ms",attributes:{serverRendered:b,serverRenderedIframe:c.value,revealSource:L}})},[_,o,b,c]),y=R((p,L=performance.now())=>{a.value||(a.value=!0,f(L,p))},[a,f]),k=R(()=>{y("iframe_load")},[y]),E=R(()=>{y("login_message")},[y]);return Be({iframeOrigin:i,observability:o,onLoaded:E,skip:!d}),Ye(()=>{if(!u||!s.value)return;const p=()=>{y("page_load_fallback")};if(document.readyState==="complete"){p();return}return window.addEventListener("load",p,{once:!0}),()=>{window.removeEventListener("load",p)}},[s.value,u,y]),d?l("div",{className:re(N.ShopPayLoginFrameLoadingContainer,{[N.ShopPayLoginFrameLoadingContainerLoading]:g}),children:[g&&l(ke,{className:N.ShopPayLoginFrameSkeleton}),l(wt,{hidden:!m,iframeLoaded:a.value,onIframeLoad:k,serverRenderedIframe:u})]}):l(ke,{className:N.ShopPayLoginFrameSkeleton})}const At="UC_LOGIN_REQUIRED";function Ct(e,n){!e||!J(e.embedder)||e.client?.error({code:At,message:JSON.stringify(n),severity:"recoverable",timestamp:Date.now()})}function It(e=""){const n=We(e),t=Te(e),o=Ge(e),i=Ve(e),r={seamless:n,embedded:t,oauth:o,oauthWithEmbeddedContext:i},s=Z(),{serverDrivenAuth:a,variant:c}=Ut(s),{frameUrl:u,origin:d,flow:m}=r[c],g=B(()=>{try{return new URL(u).origin}catch{return""}},[u]);return{flow:m,iframeOrigin:g,serverDrivenAuth:a,source:d,iframeUrl:u,variant:c}}const Ut=e=>{switch(e){case I.OAuth:return{serverDrivenAuth:!0,variant:"oauth"};case I.OAuthWithEmbeddedContext:return{serverDrivenAuth:!0,variant:"oauthWithEmbeddedContext"};case I.Embedded:return{serverDrivenAuth:!0,variant:"embedded"};case I.Seamless:default:return{serverDrivenAuth:!1,variant:"seamless"}}};function Ot(){const e=ae(),{embed:n}=v();return J(n?.embedder)?l(Pe,{when:e,children:l(Dt,{})}):null}function Dt(){const{observability:e,source:n,embed:t,environment:o,url:i,shop:r}=v(),{iframeUrl:s,source:a}=It(),c=t?.client?.embedderHostname;return O(()=>{if(!J(t?.embedder)||!s||!c)return;const u=new URL(s);u.searchParams.set("target_origin",`https://${c}`),Ct(t,{loginUrl:u.href,exchangeUrl:new URL(i.shopPaySession(),o.services.shopServer.url).href,origin:a,shopifyDomain:r.myshopifyDomain,checkoutToken:n.
1checkoutSessionIdentifier??void 0}),e.counter({name:"universal_checkout_shop_pay_login_required_emitted",value:1})},[t,c,s,a,o.services.shopServer.url,i,r.myshopifyDomain,n.checkoutSessionIdentifier,e]),null}function Ht(){const{client:e,userEvents:n,source:t,checkout:o,shop:i,shopPay:r}=v(),{redirectSource:s,tracking:a}=r.config,{checkoutSessionIdentifier:c="checkout_identifier_undefined"}=t,u=bn(on.SHOP_PAY_LOGIN),d=He().value;zn({stage:qn.Complete,id:"ShopPayLogin"}),O(()=>{ue()&&n.monorailEvent({schemaId:"shop_app_page_load/9.0",payload:{...Se(t,o,i),platform:"web",locale:navigator.language,userToken:a.unique??e.cookies.get("_shopify_y")??"",webSessionToken:a.visit??e.cookies.get("_shopify_s")??"",pageType:"pay_checkout_login",pageValue:c}}),n.monorailEvent({schemaId:"shopify_pay_page_load/2.6",payload:{...Se(t,o,i),pageType:"checkout_login",clientTimestampMs:Date.now(),redirectSource:s}}),d&&n.monorailEvent({schemaId:"retail_shop_pay/2.0",payload:u})},[e.cookies,n,t,o,i,s,u,d,c,a.unique,a.visit])}const Bt="oSdnC",Ft={ShopPayLogin:Bt};function Mt(){Ht();const{client:e,router:n,shop:t,source:o,shopPay:i}=v(),r=o.type==="shopPayExternal",s=Z(),a=s===I.Seamless,c=n.currentUrl.value,d=c.href===e.initialRequest.url.href&&e.initialRequest.isServerRendered&&s===I.OAuth,{isAppLayout:m}=vn(),g=t.hasFlagEnabled(sn)&&!r&&!m&&!ue(c.search)&&!i.config.isReferral&&!c.searchParams.has(rn)&&e.unstable_getSerialization("shopPayConfig").has_remember_me_cookie===!0&&i.visibility.showCheckoutAsGuestFeature;return l("div",{children:[l(Ot,{}),l(te,{padding:"none",dividerDisplay:"@media (inline-size >= medium) none, auto",children:l(q,{padding:"@media (inline-size >= small) none none large-300 none, none",maxInlineSize:"@media (inline-size >= small) 425px, 432px",className:re(Ft.ShopPayLogin),children:l(te,{padding:"none",borderWidth:a?"@media (inline-size >= small) base, none":void 0,borderRadius:a?"@media (inline-size >= small) base, none":void 0,hideDivider:!0,children:l(Rt,{serverRenderedIframe:d})})})}),i.visibility.showUnauthedOrderSummary&&l(Ln,{section:"summary",children:l(kn,{section:"summary",children:l(Pn,{above:"small",children:l(te,{hideDivider:!0,padding:"none none large-200 none",children:l(Rn,{})})})})}),g?l(Wn,{}):l(Vn,{isShopPayExternal:r})]})}function oo(){const{client:e,observability:n,shopPay:t}=v(),{shouldUseAccessToken:o,user:i}=t,r=X(e.initialRequest.url),s=Ie(),a=s?un.includes(s):!1,c=Je(s),u=En(),d=$(()=>u.value.currentDetour?.type==="shopPayLogin"),m=cn(),g=$(()=>m()),_=t.accessToken.value,{refetch:b}=an(ln,{isOnShopPayLoginDetour:d,newSignupLoginVariant:c,simulatedBuyerDetails:g}),[f,y]=we(!1),k=o?!!_:!0,E=i.email.value,p=a&&!r||!!(f&&E&&k),L=s==null||p;Ce(L);const P=e.unstable_legacyNavigationPerformance,{progress:h}=De();return O(()=>{const w=t.session.initialization.peek();w.status==="failed"&&w.reason==="fetch"&&t.session.unstable_setInitialization({status:"pending"})},[t.session]),O(()=>{_&&(r||(b(),y(!0)))},[_,r,b]),O(()=>{p&&(P?.usable(),h("shop-pay-login-loader-complete"))},[p,P,h]),oe({enabled:L,onTimeout:w=>{n.counter({name:"shop_pay_login_loader_loading_timeout",value:1}),n.log("shop_pay_login_loader_loading_timeout","ShopPayLoginLoader loading timeout",{timeout:w,variant:s,isUnauthenticatedVariant:a})}}),L?null:l(Mt,{})}export{oo as default};
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.