import{_ as n,B as o,y as t,ay as e,az as a,aD as c,aE as s,aL as i,aI as r,aG as u,Z as l,aJ as d,as as f,e as m,s as v,f as _,g as p,aK as w}from"./chunk.common_3e0b8cdf.esm.js";function b(){return n(this,void 0,void 0,(function*(){try{!function(){const n=t(),m=new e({elementName:"shop-login-button",flowVersion:a.SignUp,analyticsTraceId:n}),v=new WeakMap;let _=null;const p=c({onVisible:h,onFallback:n=>{n.addEventListener("focus",w,{once:!0}),m.trackShopPayLoginWithSdkErrorEvents({apiKey:"",errorCode:"fallback_to_focus_event",errorMessage:"Fallback to focus event for classic customer accounts"})}});function w(n){h(n.target)}function b(n,o){var t,e;const a=null===(t=n.elements.namedItem("checkout_url"))||void 0===t?void 0:t.value,c=null===(e=n.elements.namedItem("return_url"))||void 0===e?void 0:e.value,s=new URLSearchParams(Object.assign(Object.assign({analytics_trace_id:o},a&&{checkout_url:a}),c&&{return_url:c}));return`${window.location.origin}/account/redirect?${s.toString()}`}function h(t){var e;const c=t.form;if(!c)return void o.notify(new Error("Email form missing for classic customer accounts"));v.has(t)&&(o.notify(new Error("Input listener already exists for input")),null===(e=v.get(t))||void 0===e||e.destroy(),v.delete(t));const s=document.createElement("input");s.type="hidden",s.name="login_with_shop[analytics_trace_id]",s.value=n,c.appendChild(s),_||(_=function(n){const o=null===document.querySelector(u),t="true"===l(d),e=o&&!t,c=document.createElement("shop-login-button");c.setAttribute("client-id",""),c.setAttribute("action","default"),c.setAttribute("version","2"),c.setAttribute("flow-version",a.SignUp),c.setAttribute("analytics-context",f.ClassicCustomerAccounts),c.setAttribute("analytics-trace-id",n),c.setAttribute("hide-button","true"),c.setAttribute("email-verification-required","true"),c.setAttribute("disable-sign-up","true"),e&&c.setAttribute("auto-open","true");return document.body.appendChild(c),c}(n),m.trackClassicCustomerAccountsCreateAccountPageImpression(),_.addEventListener("completed",(()=>{const o=b(c,n);window.location.assign(o)}))),_.email=t.value,v.set(t,new r(t,(n=>{_.email=n})))}s({selector:i,onElementFound:n=>p.observe(n)})}()}catch(n){n instanceof Error&&o.notify(n)}}))}m()&&(v({bundle:"initCustomerAccountsSignUp",bundleLocale:"en"}),_(),p(),w("initCustomerAccountsSignUp",b));
//# sourceMappingURL=client.init-customer-accounts-sign-up_d505ac0f.en.esm.js.map
