1import{s as b}from"./BOm6r1lf.js";import{aN as l,aL as R,bd as z,c as T,A as V,C as E,dL as Y,ab as $,aM as D,l as K,h as X,m as Z,bj as J,v as I,cz as Q,ba as tt}from"./BZMsC0c1.js";import{u as et}from"./Dzhdnvy8.js";import{u as at}from"./CSYXMvwo.js";import{u as st}from"./CwK3oEcb.js";import{u as rt}from"./D6KuAobJ.js";import{u as ot}from"./D2hTVocH.js";import{u as nt}from"./DE9LN-y2.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"e9bbbf4da76b0a8af3b75a0d8204dbb1a3c005bc"}}catch{}})();try{(function(){var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="9ec574cd-d44c-47ab-9e3a-406ee5d86558",t._sentryDebugIdIdentifier="sentry-dbid-9ec574cd-d44c-47ab-9e3a-406ee5d86558")})()}catch{}function it(){return{login:l("oauthLogin"),register:l("oauthRegister"),guestLogin:l("oauthGuestLogin"),refreshToken:l("refreshAccessToken"),revokeToken:l("oauthRevokeToken"),forgetPassword:l("oauthForgetPassword"),resetPasswordByHash:l("updatePasswordByHash"),loginWithIDP:l("handleIDPLoginCallback")}}const ct="2023-11-29T23:00:00.000Z",ut=2e3,lt=2e4,ft="/club/club-account-creation",Mt="/loyalty_loader.mp4",dt=Date.parse(ct),ht=t=>typeof(t==null?void 0:t.cardId)=="string"&&t.cardId.trim().length>0,C=t=>{const e=t==null?void 0:t.createdAt;if(!e)return!1;const r=e instanceof Date?e.getTime():Date.parse(e);return Number.isFinite(r)&&r>=dt};function Rt(t){const{user:e}=R(),r=z(),o=T(()=>C(e.value)),u=T(()=>ht(t.member.value)),P=T(()=>o.value&&(t.status.value==="success"||t.status.value==="error")&&!u.value),f=V(!1),i=T(()=>o.value&&!u.value&&f.value);let d,h;const g=()=>{d&&(clearInterval(d),d=void 0),h&&(clearTimeout(h),h=void 0)},k=async()=>{if(u.value){g();return}if(t.status.value!=="pending")try{await t.refresh()}catch{}};return E(P,c=>{c&&(f.value=!0)},{immediate:!0}),E(i,c=>{if(!c){g();return}d||(d=globalThis.setInterval(k,ut)),h||(h=setTimeout(async()=>{g(),await $(r(ft))},lt))},{immediate:!0}),E(u,c=>{c&&(f.value=!1,g())}),E(o,c=>{c||(f.value=!1)}),Y(g),{hasCardId:u,isEligibleUser:o,showLoader:i}}const L=(t,e)=>{switch(t){case 400:return e.t("authentication.notification.error.generic.400");case 401:return e.t("authentication.notification.error.generic.401");case 403:return e.t("authentication.notification.error.generic.403");case 404:return e.t("authentication.notification.error.generic.404");case 406:return e.t("authentication.notification.error.generic.406");case 409:return e.t("authentication.notification.error.generic.409");case 422:return e.t("authentication.notification.error.generic.422");case 429:return e.t("authentication.notification.error.generic.429");case 500:return e.t("authentication.notification.error.generic.500");default:return e.t("authentication.notification.error.generic.500")}},gt=(t,e)=>t===409?e.t("authentication.notification.error.guest_login.409"):L(t,e),wt=(t,e)=>t===404?e.t("authentication.notification.error.forgot_password.404"):L(t,e),yt=(t,e)=>t===404?e.t("authentication.notification.error.reset_password.404"):L(t,e),pt=(t,e,r)=>{var o;return!(t instanceof D)||!((o=t.response)!=null&&o.status)?r.t("authentication.notification.error.generic.500"):e==="guest_login"?gt(t.response.status,r):e==="forgot_password"?wt(t.response.status,r):e==="reset_password"?yt(t.response.status,r):L(t.response.status,r)},bt=t=>typeof t=="string"&&t.length>0,_t=new Set([400,401,404]),mt=new Set(["No Session found","No access token present"]),vt=t=>{var e,r;return t instanceof D&&_t.has(((e=t.response)==null?void 0:e.status)??0)&&bt((r=t.data)==null?void 0:r.title)&&!mt.has(t.data.title)};function Dt(t="email"){const e=K(),r=X(),o=ot(),{trackAuthenticated:u,trackLogout:P,trackSessionMeta:f}=et(),i=it(),{localizedNavigateTo:d}=Z(),h=J("useAuthentication"),{refresh:g}=st(),{refresh:k,data:c}=at(),{user:p,refresh:F,customerType:N}=R(),{applyPromotions:U}=rt({basket:c}),{syncProfile:O}=nt(),S=async()=>{await Promise.all([F(),g(),k()]),await U()},B=async a=>{b("auth");try{await i.login(a),await _("login",e.t("toast.auth.login_success"))}catch(s){throw m(a.email,"login"),w(s,"login"),s}},H=async a=>{b("auth");try{await i.guestLogin(a),await _("guest_login",e.t("authentication.notification.success.guest_login"))}catch(s){throw m(a.email,"guest_login"),w(s,"guest_login"),s}},W=async(a,s)=>{b("auth");try{const n=s!=null&&s.newsletterOptIn?{...a,subscription:{has_subscribed_newsletter:!0}}:a;await i.register(n),await _("sign_up",e.t("authentication.notification.success.sign_up"),{newsletterOptIn:s==null?void 0:s.newsletterOptIn})}catch(n){throw m(a.email,"sign_up"),w(n,"sign_up"),n}},G=async a=>{b("auth");try{const s=await i.forgetPassword({email:a});if(s&&typeof s=="object"&&"success"in s&&s.success===!1)throw new Error("Forgot password request was not successful.");o.info(e.t("toast.account.action_done"),e.t("authentication.notification.success.forgot_password"))}catch(s){throw m(a,"forgot_password"),w(s,"forgot_password"),s}},x=async a=>{b("auth");try{await i.resetPasswordByHash(a),await _("reset_password",e.t("authentication.notification.success.reset_password"))}catch(s){throw w(s,"reset_password"),s}},j=async a=>{b("auth");const s=(a==null?void 0:a.redirectTo)??I.home.path,n=(a==null?void 0:a.silent)??!1,v=async()=>{tt("authGuard-user"),p.value&&(P(a==null?void 0:a.trackingContentName),await f())};try{try{await i.revokeToken()}catch(y){if(!vt(y))throw y;w(y,"logout")}await v(),n||o.success(e.t("toast.auth.logout_success"))}catch(y){throw w(y,"logout"),n||o.error(pt(y,"logout",e)),y}finally{await S(),s!==!1&&await A(s)}},_=async(a,s,n)=>{await S();const v=r.query.redirectUrl;if(!p.value){if(a==="sign_up"){o.info(e.t("toast.account.action_done"),e.t("authentication.notification.success.sign_up_unverified"));return}o.success(s),await M(v);return}a==="sign_up"&&O(p.value),await u({event:a,method:t,status:"successful",customer_id:p.value.id,customer_type:N.value,...a==="sign_up"?{newsletter:(n==null?void 0:n.newsletterOptIn)??void 0}:{},...a==="login"?{account_type:C(p.value)?"loyalty":"standard"}:{}},p.value.email),await f(),o.success(s),await M(v)},m=async(a,s)=>{await u({event:s,method:t,status:"error"},a)},w=(a,s)=>{Q(a,{tags:{"auth.event":s}}),h.error(`Error while ${s} was called.`,{error:a})},q=a=>
1a.startsWith("/")&&!a.startsWith("//"),A=async a=>{const s=q(a)?a:I.dashboard.path;return r.fullPath===s?window.location.reload():await d(s)},M=async a=>{if(a){await A(a);return}r.path.endsWith(I.login.path)&&await A(I.dashboard.path)};return{login:B,guestLogin:H,logout:j,register:W,forgotPassword:G,resetPasswordByHash:x}}export{Rt as a,Mt as l,pt as r,Dt as u};
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.