PageSourceSearch

https://shop.open-city.org.uk/cdn/shopifycloud/checkout-web/assets…onent-ShopPayVerificationSwitch.V4dm7i6D.js

js open-city.org.uk collected 2026-09-24 09:22:50 UTC 23,779 bytes, 1 lines download raw bytes

1import{T as x,k as U,q as I,_ as ve,u as M,A as b,h as _,g as pe,V as Ne,S as ke}from"./esnext-vendor.D7ldIee_.js";import{N as Y,$ as de,f5 as De,f6 as ae,f7 as Ve,f8 as Ue,f3 as xe,ab as Pe,an as ce,f9 as _e,bf as Me,bm as Ce,fa as se,fb as ue,fc as le,fd as Re,dv as me,dx as Oe,eC as Fe,dj as Be,fe as He,aS as $e}from"./addresses-is-address-empty.-MuOhIyI.js";import{eu as O,b4 as Ge,F as ze,M as We,aT as Ke,aU as qe,eG as we,eH as Ie,eI as K,a1 as Ye}from"./hydrate.ByRIsqvd.js";import{c as ye}from"./stopwatch.wWgdKLTI.js";import{L as Je}from"./BillingAddressForm.DHpCPcqC.js";import{u as Qe}from"./hooks-useForceShopPayUrl.MIxsBkT_.js";import{a as be}from"./hooks-useSuppressShopPayModalOnLoad.CI5bzdLE.js";import{p as q,S as G,u as je,a as Xe,M as Le,A as X,b as Ze}from"./utilities-publishMessage.fqiR55Tb.js";import{a as et}from"./hooks-useUnauthenticatedErrorModal.CzvtLqeY.js";import{i as tt,a as re,u as fe,b as Ae,c as he,d as nt,A as ot,e as rt,r as st,S as it,M as at,I as ct,f as ut,R as dt,P as Se,g as V,h as lt,j as ft,k as ht}from"./useAuthorizeUrl-index.B4Pj7zGU.js";import"./app.A60-IfPs.js";import"./constants.DowbVE6J.js";import"./hooks-useReplaceShopPayInHistory.Cz4PqGkk.js";import"./components-RedirectionNotice.module.CqgkZHXB.js";import"./localization-index.DBksi22x.js";import"./PhoneField.BapDvZfY.js";import"./Popover.BNecjV8x.js";import"./hooks-useCanChangeCompanyLocation.Bk004VMP.js";import"./Choice.Dywz6_Fr.js";import"./Checkbox.Cby2hWUV.js";import"./models-ShopPayBuyerDetails.model.CahX79UU.js";import"./shop-pay-normalizeBuyerDetails.BcEhgoK7.js";import"./context-CheckoutSheetProtocolClient.CNLSBD5p.js";import"./dist-v4.EwEgHOG0.js";const pt=e=>{const{environment:n,i18n:{locale:t},shop:{myshopifyDomain:o},source:{checkoutSessionIdentifier:r},shopPay:h}=Y(),d=Qe(),s=de().buyerIdentity.value?.customerProfile,{redirectUrl:a,transactionParams:i,tokens:k}=h.config,p=k.iframe,u=De();return x(()=>{if(!r)throw new ae({groupingHash:"ShopPayCheckoutIdentifierMissingError::ULCFrame"});if(!u||!(p&&a))return;const y=new URLSearchParams({shopify_domain:o,checkout_token:r,origin:e,locale:t,iframe_token:p,redirect_url:a,transaction_params:i??"",shop_pay_new_signup_login_variant:u});for(const[S,l]of d.entries())y.set(S,l);e===O.C1InlineModal&&y.set(Ve,Ue.ShopPayAsPaymentMethod),s?.email&&y.set("fast_login","true");const f=y.toString(),g=new URL("/pay/transactions/new/email",n.services.payShopifyCom.url);return g.search=f,g.href},[e,o,r,t,p,a,i,u,d,s,n])};function mt(){const[e,n]=U(null),t=I(o=>{o!==null&&n(o.getBoundingClientRect())},[]);return[e,t]}function yt(e){const[n,t]=U(null),o=I(()=>{e!==null&&t(e.getBoundingClientRect())},[e]);return ve(()=>(o(),window.addEventListener("resize",o),window.addEventListener("scroll",o),()=>{window.removeEventListener("resize",o),window.removeEventListener("scroll",o)}),[o]),n}const ge=10;function St({x:e,y:n}){const t=window.devicePixelRatio||1;return{x:Math.round(e*t)/t||0,y:Math.round(n*t)/t||0}}function gt(e,n,t,o,{offset:r=0,arrowOffset:h=0}={}){let d={x:0,y:0},s={left:0,right:0},a=0;if(!n&&!t)return{offsets:d,spacing:a};if(!o){const{clientWidth:i,clientHeight:k}=document.documentElement;return d={x:i/2-n/2,y:k/2-t/2},{offsets:d,spacing:a}}switch(e){case"blockEnd":d={x:(document?.dir??"ltr")==="rtl"?o.left:o.right-n,y:o.bottom+r};break;case"inlineEnd":d={x:(document?.dir??"ltr")==="rtl"?o.left-n-r:o.right+r,y:o.top+o.height/2-h};break}return s=Et(d,n),s.right&&!s.left?(d.x+=s.right,a=-ge):!s.right&&s.left&&(d.x=0,a=ge),{offsets:d,spacing:a}}function Et(e,n){const t=document.documentElement.clientWidth,o=e.x+n;let r={left:0,right:0};return o>t&&(r={...r,right:t-o}),e.x<0&&(r={...r,left:-e.x}),r}const vt="qdHCv",kt={Popper:vt};function Pt({children:e,offset:n,arrowOffset:t,contentWidth:o,contentHeight:r,placement:h="inlineEnd",activator:d,open:s}){const a=yt(d??null),[i,k]=mt(),{offsets:p,spacing:u}=x(()=>s?gt(h,(o||i?.width)??0,(r||i?.height)??0,a,{offset:n,arrowOffset:t}):{offsets:{x:0,y:0},spacing:0},[n,t,h,i,a,s,o,r]),{x:m,y}=x(()=>s?St({x:p.x+u+(window.scrollX||window.pageXOffset),y:p.y+(window.scrollY||window.pageYOffset)}):{x:0,y:0},[p,u,s]),f=x(()=>s?(window.devicePixelRatio||1)<2?`translate(${m}px, ${y}px)`:`translate3d(${m}px, ${y}px, 0)`:"none",[s,m,y]);return M(Ge,{children:M("div",{className:kt.Popper,style:{...i&&{transform:f,MozTransform:f,WebkitTransform:f}},ref:k,"aria-hidden":!s,children:e})})}const _t="hgqpU",Mt="axmya",Ct="JHj7j",wt="hQvGd",It="PMbsk",bt="wA8HY",Lt="xnzQ4",F={Backdrop:_t,"Backdrop-visible":"LTbS5",BackdropLinearGradient:Mt,Popover:Ct,Content:wt,PopoverArrow:It,PopoverOpen:bt,"Popover-placementInlineEnd":"trTaz","Popover-placementBlockEnd":"KMvI7",Bumper:Lt},At=We("Popover");function Tt({children:e,activator:n,open:t,placement:o="inlineEnd",contentWidth:r,contentHeight:h,onClose:d}
1){const s=b(null),a=b(null),i=b(null),k=ze(void 0,At),p=xe(),u=I(()=>{n?.tagName==="BUTTON"&&(n?.setAttribute("aria-controls",k),n?.setAttribute("aria-expanded",String(t)))},[n,t,k]),m=I(l=>{d?.(l)},[d]),y=I(l=>{l.target instanceof Node&&!n?.contains(l.target)&&document.contains(l.target)&&!i.current?.contains(l.target)&&t&&m(l)},[m,n,t,i]),f=I(l=>{if(t)switch(l.key){case"Escape":case"Esc":m(),n?.focus();break}},[m,n,t]);_(()=>(document.addEventListener("click",y),()=>{document.removeEventListener("click",y)}),[y]),_(()=>(t&&document.addEventListener("keydown",f,!1),()=>{document.removeEventListener("keydown",f,!1)}),[t,f]),_(()=>{u()}),ve(()=>{t&&i.current?.focus({preventScroll:!0})},[t]);const g=l=>{const E=i.current;if(E){const C=l?Ke(E):qe(E);C?C.focus():E.focus()}},S=pe(F.Popover,F[Ne("Popover-placement",o)],t&&F.PopoverOpen,n&&F.PopoverArrow);return M(ke,{children:[M(Pt,{activator:n,placement:o,offset:15,arrowOffset:30,open:t,contentWidth:r,contentHeight:h,children:[t&&M("button",{className:F.Bumper,ref:s,"aria-hidden":"true",onFocus:()=>g(!1),type:"button"}),M("div",{className:S,id:k,ref:i,children:M("div",{className:F.Content,children:e})}),t&&M("button",{className:F.Bumper,ref:a,"aria-hidden":"true",onFocus:()=>g(!0),type:"button"})]}),M("div",{className:pe(F.Backdrop,t&&F["Backdrop-visible"],t&&p&&F.BackdropLinearGradient)})]})}var ie=(e=>(e.Normal="normal",e.CustomerAccount="customer_account",e.AccountsSameStore="accounts_same_store",e.AccountsCrossStore="accounts_cross_store",e))(ie||{});function Nt({email:e,skipVerifyOnLoad:n,iframeReady:t,iframeRef:o,dismissedModalKey:r,readyToDismiss:h,onReadyToDismiss:d,showPopover:s,showToggle:a,popoverActivator:i,open:k,automaticVerificationEnabled:p}){const u=de().buyerIdentity.value?.customerProfile,{inMemoryPayPalParts:{accountStatus:m}}=Pe(),{isDismissedGuestModal:y}=we(),{client:f,shopPay:g,source:S}=Y(),{checkoutProtocolModalEventSignal:l}=ce(),E=Ie(Me.ShopPayVerification,{scope:_e(S)}),C=Ce().current.token,P=b();_(()=>{if(!t){P.current=void 0;return}if(n.current){n.current=!1;return}const A=u&&f.cookies.get(r),H=e&&se(e),c=m.value.status==="connected",v=u&&Dt();if(!H){P.current=void 0;return}if(A||c||v)return;if(E.value===K.Verified){E.value=void 0;return}(p||k)&&P.current!==e&&(P.current=e,q(o?.current,{action:G.Create,email:e,flow:ie.Normal,disableAutoFocus:y()}))},[e,t,p,k]);function L(){if(!S.checkoutSessionIdentifier)throw new ae({groupingHash:"ShopPayCheckoutIdentifierMissingError::GuestCheckout"});if(!(u&&f.cookies.get(r))&&e&&se(e)){h||d(),C&&q(o?.current,{action:G.CheckoutQueueToken,queueToken:C}),g.setUserIdentified(escape(S.checkoutSessionIdentifier));const A=new URL(window.location.href);A.searchParams.delete(ue),history.replaceState(null,"",A.href),window.dispatchEvent(new Event("shop_pay_user_identified_cookie_set")),E.value=K.Pending,y()?a?.(!0):(s(!0,e),a?.(!1))}}function B(){h&&(E.value=K.Dismissed,u&&f.cookies.set(r,"true"),i?.current?.focus(),s(!1),a?.(!0))}function N(){le(),E.value=K.Verified,l.value="none"}return{onShow:L,onHidden:B,onLoggedIn:N}}function Dt(){const e=sessionStorage.getItem(Re);if(!e)return!1;const n=Number.parseInt(e,10);return isNaN(n)?!1:Date.now()<n}const Vt=[X.FraudGuard,X.InvalidPhone,X.LimitExceeded,X.PhoneBlocked];function Ut({email:e,onSetEmail:n,skipVerifyOnLoad:t,iframeReady:o,iframeRef:r,readyToDismiss:h,onReadyToDismiss:d,showPopover:s,popoverActivator:a,origin:i,open:k,automaticVerificationEnabled:p}){const{shopPay:u,source:{checkoutSessionIdentifier:m}}=Y(),{openModal:y}=et(),{exchangeSessionTokenForCookie:f}=je(),{extendBuyerIdentity:g}=Xe(),S=b(null),l=b(!1),E=b(),{checkoutProtocolModalEventSignal:C}=ce(),P=I(()=>{r.current&&q(r.current,{action:G.Create,email:"",flow:ie.Normal})},[r]);_(()=>{r.current&&o&&i===O.C1ModalShopPaySignIn&&(q(r.current,{action:G.AllowNoInitialEmail}),P(),q(r.current,{action:G.Ready}))},[o,r,i,P]),_(()=>{k&&(S.current=null)},[k]),_(()=>{l.current&&r.current&&o&&(l.current=!1,P())}),_(()=>{function c(){n&&(u.updateUserVerification({status:"none"}),n(""),a?.current?.focus()),l.current=!0}return window.addEventListener("shop_pay_verification_reset",c),()=>{window.removeEventListener("shop_pay_verification_reset",c)}},[a,s,n,r,u]),_(()=>{if(!o){E.current=void 0;return}if(t.current){t.current=!1;return}const c=e&&se(e),v=p||k;if(!(c&&i!==O.C1ModalShopPaySignIn&&!v))if(c&&i!==O.C1ModalShopPaySignIn){if(E.current===e)return;E.current=e,u.updateUserVerification({email:e,status:"loading"}),q(r?.current,{action:G.Create,email:e,flow:ie.Normal})}else i!==O.C1ModalShopPaySignIn&&(E.current=void 0,P(),u.updateUserVerification({status:"none"}))},[e,o,t,r,i,p,k,u,P,s]);function L(){if(!m)throw new ae({groupingHash:"ShopPayCheckoutIdentifierMissingError::S
1hopPayCheckout"});i===O.C1ModalShopPay&&e&&se(e)&&(h||d(),u.updateUserVerification({email:e,status:"found"}),s(!0,e))}function B(){if(i===O.C1ModalShopPay&&!h)return;const c=S.current;n!=null&&c!=null&&(c.status!=="found"||i===O.C1ModalShopPay||!e)&&(n(c.email??""),u.updateUserVerification(c),a?.current?.focus()),u.userVerification.value.status==="found"?y({type:me.ContinueWithShopPay,email:u.userVerification.value.email}):a?.current?.focus(),s(!1),S.current=null}function N(c,v,w){if(!(w&&w!==u.userVerification.value.email)&&(c===Le.ShopifyPayUserNotFound&&Vt.includes(v)&&(s(!1),y({type:me.Generic})),w)){const R=v===X.InvalidEmail;u.updateUserVerification({email:w,status:R?"invalid":"new"})}}function A(c,v){c?(S.current||u.userVerification.value.email!==c)&&(S.current={email:c,status:v?"found":"new"}):S.current={status:"none"}}async function H(c){le(),C.value="none",c&&(await f({token:c,origin:i}),g(),window.location.reload())}return{onShow:L,onHidden:B,onEmailChange:A,onError:N,onLoggedIn:H}}function xt(e){const{observability:n}=Y(),t=b(e),o=t.current,r=e===t.current?void 0:`Callback hook changed from ${t.current.name} to ${e.name} between renders.`;return _(()=>{r&&n.error(new Oe(`${r} Only the original hook is called.`,{groupingHash:"ShopPayError::OnlyOriginalHookCalled"}),{severity:"warning",errorClass:"ShopPay::ShopPayVerification::useStableHook"})},[r,n]),o}const Rt="B1y2m",Ot={VerificationIframe:Rt},Ft="shop-pay-verification-iframe",Ee=320,Bt=300,Ht=1e3;function $t({email:e,onSetEmail:n,open:t,popoverActivator:o,showPopover:r,showToggle:h,urlOrigin:d=O.C1Modal,updatedOrigin:s=d,onIframeLoaded:a,automaticVerificationEnabled:i=!0}){const k=Ye({base:"blockEnd",medium:"inlineEnd"}),[p,u]=U(!1),[m,y]=U(Bt),[f,g]=U(!1),{i18n:S,shopPay:l,shop:E,source:{checkoutSessionIdentifier:C}}=Y(),P=b(null),[L,B]=U(!1),{checkoutProtocolModalEventSignal:N}=ce(),A=Fe(e,He),H=`${C}-${e.replace(/[^a-zA-Z0-9]/g,"")}`,c=be().value,v=b(c),{onShow:w,onHidden:R,onError:z,onEmailChange:D,onLoggedIn:J}=xt(l.user.isUnauthenticatedUser.value?Ut:Nt)({email:A,onSetEmail:n,skipVerifyOnLoad:v,iframeReady:p,iframeRef:P,dismissedModalKey:H,readyToDismiss:f,onReadyToDismiss:()=>{setTimeout(()=>g(!0),Ht)},showPopover:r,showToggle:h,popoverActivator:o,origin:s,open:t,automaticVerificationEnabled:i});Ze({targetId:d,onReady:w,onClosed:te,onLoggedIn:J,onHidden:R,onError:ne,onResized:ee,onLoaded:()=>{u(!0),a()},onEmailChange:D}),_(()=>{q(P?.current,{action:G.OriginChanged,origin:s})},[s]),_(()=>{const T=t?G.Ready:G.Hidden;if(q(P?.current,{action:T}),N.value=t?"shopPayVerification":"none",P.current&&t&&P.current.focus(),!(!t||!E.hasFlagEnabled(Be)))return()=>{N.value="none"}},[N,t,E]);const $=pt(d);if(_(()=>()=>{u(!1)},[$]),!$)return null;const Z=t?o?.current:void 0;return M(Tt,{activator:Z,open:t,onClose:R,placement:k,contentWidth:Ee,contentHeight:m,children:M(Je,{active:L||!p,size:"large",children:M("iframe",{id:Ft,title:S.translate("verification.title"),ref:P,src:$,height:m,width:Ee,className:Ot.VerificationIframe,allow:"publickey-credentials-get *",referrerPolicy:"origin"},$)})});function ee(T){!isNaN(T)&&T&&y(T)}function te(){B(!0)}function ne(T,W,Q){z?.(T,W,Q),T===Le.ShopifyPayUserNotFound&&l.setUserIdentified(null);const oe=new URL(window.location.href);W===X.LimitExceeded?oe.searchParams.set(ue,"true"):oe.searchParams.delete(ue),history.replaceState(null,"",oe.href),window.dispatchEvent(new Event("shop_pay_user_identified_cookie_set"))}}function Gt(){if(!tt())return;const e="shop-pay-safari-unzoom",n=re.getElementById(e);if(n)return n.focus();const t=re.createElement("input");t.id=e,t.style.fontSize="16px",t.style.width="1px",t.style.height="1px",t.style.position="fixed",t.style.bottom="-1000px",t.style.right="-1000px",t.style.transform="translate(1000px, 1000px)",t.setAttribute("aria-hidden","true"),re.body.appendChild(t),t.focus({preventScroll:!0})}const zt=100;function Wt({emailInputSelector:e}){const[n,t]=U(),[o,r]=U();return _(()=>{function d(s){this.type==="password"?r(s.timeStamp):t(s.timeStamp)}if(e){const s=re.querySelector(e);if(s){s.addEventListener("input",d);const a=s.form?.querySelector('input[type="password"]');return a&&a instanceof HTMLInputElement&&a.addEventListener("input",d),()=>{s.removeEventListener("input",d),a&&a.removeEventListener("input",d)}}}},[e]),{isFilledWithPasswordManager:x(()=>n===void 0||o===void 0?!1:Math.abs(n-o)<zt,[n,o])}}function Kt({email:e,emailInputSelector:n,onGetEmailInput:t,hideChange:o,iframeRef:r,shouldListen:h=!0,shouldOpenOnMatch:d=!0}){const{loaded:s,modalVisible:a}=fe(),{leaveBreadcrumb:i,notify:k}=Ae(),{trackUserAction:p}=he(),{isFilledWithPasswordManager:u}=Wt({emailInputSelector:n}),m=b(null),[y,f]=U(),[g,S]=U(),[l,E]=U(),C=b(null),P=b(""),L=x(()=>new Set,[]),B=()=>P.current,N=I(async(c,v="",w="")=>{const R=nt(c);if(u&&!L.has("PASSWORD_MANAGER_AUTOFILL_DETECTED")&&(L.add("PASSWORD_MANAGER_AUTOFILL_DETECTED"),p({userAction:"PASSWORD_MANAGER_AUTOFILL_DETECTED"})),R&&!L.has("EMAIL_ENTERED")&&(L.add("EMAIL_ENTERED"),p({userAction:"EMAIL_ENTERED"})),i("email entered",{},"state"),!r.current||a||!s)return;const z=R?c:"";m.current&&!m.current?.signal.aborted&&m.current.abort(),m.current=ne
1w AbortController;try{const{open:D,postMessage:J,waitForMessage:$}=r.current;P.current=z,J({firstName:v,lastName:w,type:"namesubmitted"}),J({email:z,hideChange:o===void 0?z.length>0:o,type:"emailsubmitted"}),i("email submitted",{email:z?"redacted":""},"state");const Z=$("shop_user_matched",m.current.signal),ee=new Promise((te,ne)=>{const T=async()=>{try{const W=await $("error",m.current.signal);W.type==="error"&&W.code==="captcha_challenge"?te(void 0):await T()}catch(W){ne(W)}};T()});await Promise.race([Z,ee]),d&&(D("event_shop_user_matched"),C?.current?.blur(),Gt()),m.current.abort(),f(void 0)}catch(D){if(D instanceof ot&&D.name==="AbortSignalReceivedError")return;D instanceof Error&&k(new Error(`Error updating user info: ${D.name} - ${D.message}`))}},[o,r,u,i,s,a,k,d,p,L]),A=rt((c,v,w)=>{N(c,v,w)},200);_(()=>{y!==void 0&&s&&A(y,g,l)},[A,y,s,g,l]),_(()=>{if(!n&&!t)return;const c=n?re.querySelector(n):t?.();if(!c)return;C.current=c;const v=()=>{c&&f(c.value)};if(c?.value&&v(),!h){c?.removeEventListener("input",v);return}return c?.addEventListener("input",v),()=>{c?.removeEventListener("input",v)}},[n,t,h]),_(()=>{e!==void 0&&f(e)},[e]);const H=(c="",v="")=>{S(c),E(v)};return{getSubmittedEmail:B,updateEmailToPost:c=>f(c||""),updateNamesToPost:(c,v)=>H(c,v)}}function qt({iframeRef:e}){const{loaded:n}=fe();async function t(o){if(!e.current)return;const{postMessage:r,waitForMessage:h}=e.current;n||await h("loaded"),r(o)}return{postMessageAfterLoad:t}}function Yt(){const{analyticsData:e,produceMonorailEvent:n}=he();return{trackShopPayModalStateChange:I(({currentState:o,zoom:r})=>{const{analyticsTraceId:h,checkoutToken:d,checkoutVersion:s,shopPermanentDomain:a}=e,i={previousState:"",currentState:o,clientTimestampMs:new Date().getTime(),analyticsTraceId:h,checkoutToken:d||"",checkoutVersion:s||"",shopifyDomain:a||"",zoom:r};n({event:{payload:i,schemaId:"shopify_pay_modal_state_change/1.3"}})},[e,n])}}function Jt(e){const{checkoutToken:n,checkoutVersion:t,shopPermanentDomain:o}=e;return{checkoutVersion:t,checkoutToken:n,flow:"checkout_modal",shopPermanentDomain:o}}const Qt="e_7585671bd434a1fca2d05deff50a41ee",jt="treatment",Xt=({anchorTo:e,email:n,experiments:t,preventOverlayDismissOnClick:o,queueToken:r,totalDue:h,...d})=>{const{modalVisible:s}=fe(),a=b(null);Kt({email:n,iframeRef:a});const{postMessageAfterLoad:i}=qt({iframeRef:a}),{trackUserAction:k}=he(),{leaveBreadcrumb:p}=Ae();_(()=>{const l=new URL(Se).origin,E=C=>{if(C.origin===l&&C.data?.type==="completed"&&(p("oauth completed from popup",{},"state"),typeof V<"u"&&"parent"in V&&V.parent&&V.parent!==V)){p("forwarding completion to parent window",{},"state");const L=("ancestorOrigins"in V.location?V.location.ancestorOrigins:void 0)?.[0];L&&V.parent.postMessage({type:"completed",origin:Se},L)}};return V.addEventListener("message",E),()=>{V.removeEventListener("message",E)}},[p]);const u=x(()=>({open:async()=>{s||(a.current?.open("user_button_clicked"),k({userAction:"OPEN_CALLED"}),p("open called",{},"state"))}}),[s,k,p]);lt(u);const{trackShopPayModalStateChange:m}=Yt(),y=I(()=>{m({currentState:"loaded",zoom:`${V.visualViewport?.scale}`})},[m]),f=I(l=>{m({currentState:l?"shown":"hidden",zoom:`${V.visualViewport?.scale}`})},[m]);_(()=>{if(r||h){const l={totalDue:Number(h)||0,checkoutQueueToken:r||""};i({type:"checkoutcontextsubmitted",checkoutContext:l}),r&&i({type:"checkoutqueuetokensubmitted",checkoutQueueToken:r})}},[i,r,h]);const{authorizeUrl:g}=ft({analyticsContext:"loginWithShopCheckoutModal",avoidSdkSession:!0,clientId:"",disableSignUp:!0,flow:"checkout_modal",proxy:!0,redirectType:"iframe",responseType:"code",uxMode:"iframe",...d}),S=x(()=>{if(o)return!1;try{return t?JSON.parse(t)[Qt]!==jt:!0}catch{return!0}},[t,o]);return M(ht,{anchorTo:e,dismissable:S,keepModalOpen:!0,onLoaded:y,onModalVisibleChange:f,proxy:!0,ref:a,src:g,sandbox:!0,variant:"checkoutModal",scrolling:"no"})},Zt=()=>st(({element:e,...n})=>M(dt,{element:e,featureName:"ShopCheckoutModal",children:M(it,{children:M(at,{monorailProps:Jt(n),children:M(ct,{children:M(ut,{children:M(Xt,{...n})})})})})}),{methods:["open"],name:"shop-checkout-modal",props:{anchorTo:"string",checkoutRedirectUrl:"string",checkoutToken:"string",checkoutVersion:"string",email:"string",embed:"string",experiments:"string",preventOverlayDismissOnClick:"boolean",queueToken:"string",shopId:"number",shopPermanentDomain:"string",shopifyEsse
1ntial:"string",totalDue:"string",transactionParams:"string",storefrontDomain:"string"},shadow:"open"});function en({element:e}){return I(()=>{e?.current&&e.current?.focus&&e.current.focus()},[e])}const j=({shopCheckoutModal:e,eventName:n,eventListener:t})=>{_(()=>(e?.addEventListener(n,t),()=>e?.removeEventListener(n,t)),[t,n,e])};typeof window<"u"&&typeof customElements<"u"&&!customElements.get("shop-checkout-modal")&&Zt();function tn({email:e,open:n,popoverActivator:t,popoverAnchorSelector:o,showPopover:r,showToggle:h,onIframeLoaded:d,automaticVerificationEnabled:s=!0}){const a=t?.current,i=b(null),[k,p]=U(!1),u=b(!1),{client:m,shop:{myshopifyDomain:y,storefrontUrl:f},shopPay:g,source:S,checkout:{wallets:l}}=Y(),{redirectUrl:E,transactionParams:C}=g.config,P=de().buyerIdentity.value?.customerProfile,{inMemoryPayPalParts:{accountStatus:L}}=Pe(),{isDismissedGuestModal:B}=we(),N=Ce(),A=en({element:t}),H=x(()=>N.current.token,[N]),{value:c}=$e(),{checkoutProtocolModalEventSignal:v}=ce(),w=Ie(Me.ShopPayVerification,{scope:_e(S)}),R=`${S.checkoutSessionIdentifier}-${e.replace(/[^a-zA-Z0-9]/g,"")}`,z=be().value,D=b(z);_(()=>{if(D.current){D.current=!1,p(!1);return}const Q=B(),oe=P&&m.cookies.get(R),Te=L.value.status==="connected";if(Q||oe||Te){p(!1);return}if(w.value===K.Verified){w.value=void 0,p(!1);return}p(!0)},[e]);const J=I(()=>{le(),w.value=K.Verified,v.value="none"},[v,w]);j({shopCheckoutModal:i.current,eventName:"completed",eventListener:J});const $=I(()=>{if(!S.checkoutSessionIdentifier)throw new ae({groupingHash:"ShopPayCheckoutIdentifierMissingError::ShopJSVerification"});g.setUserIdentified(escape(S.checkoutSessionIdentifier)),window.dispatchEvent(new Event("shop_pay_user_identified_cookie_set")),w.value=K.Pending,r?.(!0,e),h?.(!1)},[S.checkoutSessionIdentifier,e,g,w,r,h]);j({shopCheckoutModal:i.current,eventName:"modalopened",eventListener:$});const Z=I(()=>{w.value=K.Dismissed,P&&m.cookies.set(R,"true"),r?.(!1),h?.(u.current),p(!1),A()},[P,R,w,r,h,A,m.cookies]);j({shopCheckoutModal:i.current,eventName:"modalclosed",eventListener:Z});const ee=I(()=>{u.current=!0},[]);j({shopCheckoutModal:i.current,eventName:"shopusermatched",eventListener:ee});const te=I(Q=>{u.current=!1,g.setUserIdentified(null),window.dispatchEvent(new Event("shop_pay_user_identified_cookie_set"))},[g]);j({shopCheckoutModal:i.current,eventName:"shopusernotmatched",eventListener:te}),j({shopCheckoutModal:i.current,eventName:"loaded",eventListener:d}),_(()=>{const Q=i.current;a&&n&&(Q?.open(),a.blur())},[a,e,n]),_(()=>{if(n)return v.value="shopPayVerification",()=>{v.value="none"}},[v,n]);const ne=n||s&&k?e:"";if(!E||l.activeSession.value)return null;const T=a?.id?`input#${on(a.id)}`:"";return M("shop-checkout-modal",{"anchor-to":o??T,"checkout-redirect-url":E,"checkout-token":S.checkoutSessionIdentifier,"checkout-version":"checkout_one",email:ne,"prevent-overlay-dismiss-on-click":!0,"queue-token":H||"","total-due":c?.amount?.toString()||"0",ref:i,"shop-permanent-domain":y,"transaction-params":C,"storefront-domain":f})}const nn=e=>M(ke,{children:M(tn,{...e})});function on(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):e}const Ln=({email:e,onSetEmail:n,open:t,popoverActivator:o,popoverAnchorSelector:r,showPopover:h,showToggle:d,urlOrigin:s=O.C1Modal,updatedOrigin:a=O.C1Modal})=>{const{shopPay:{user:{hasFlow:i}},embed:k,checkout:{identity:p},observability:u}=Y(),m=!k,y=p.current.value==="shopPay",f=x(()=>ye(),[]),g=x(()=>ye(),[]),S=b(!0),l=x(()=>({isC1:!0,shopJsVerification:!y}),[y]);_(()=>{se(e)&&(f.mark("start"),S.current=!0)},[f,e]),_(()=>{if(t&&S.current&&f.marks.start&&l){f.mark("open"),S.current=!1;const C=Math.round(f.marks.open-f.marks.start);u.histogram({name:"shop_pay_verification_time_to_interactive",value:C,attributes:l});const P=Math.round(f.marks.open-Math.max(f.marks.start,f.marks.loaded||0));u.histogram({name:"shop_pay_verification_time_to_interactive_after_load",value:P,attributes:l})}},[t,u,f,l]),_(()=>{g.mark("start")},[g]);const E=I(()=>{if(g.marks.start){g.mark("loaded"),f.mark("loaded");const C=Math.round(g.marks.loaded-g.marks.start);u.histogram({name:"shop_pay_verification_iframe_ready_duration",value:C,attributes:l})}},[g,f,u,l]);return y&&!i.value?null:y?M($t,{popoverActivator:o,email:e,onSetEmail:n,open:t,showPopover:h,showToggle:d,urlOrigin:s,updatedOrigin:a,onIframeLoaded:E,automaticVerificationEnabled:m}):M(nn,{popoverActivator:o,popoverAnchorSelector:r,email:e,open:t,showPopover:h,showToggle:d,onIframeLoaded:E,automaticVerificationEnabled:m})};export{Ln 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.