import{L as S}from"./CircularLoading.63d0a6e6.js";import{d as f,E as v,b as n,c as a,er as t,eA as b,aS as g,eF as w,eS as I,eu as h,eB as T,eC as $,t as y,bu as B,bh as C,e as p}from"./registerWidgets.6f5be576.js";import{t as E}from"./icons.b2622455.js";import{p as k}from"./passwordlessManager.1e2193ad.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new Error().stack;s&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[s]="3743249b-0dbc-4f31-8bd9-81cccb59f38a",o._sentryDebugIdIdentifier="sentry-dbid-3743249b-0dbc-4f31-8bd9-81cccb59f38a")}catch{}})();const A=o=>(T("data-v-1b435c3a"),o=o(),$(),o),V={class:"auth-info"},D={class:"auth-header"},K={class:"auth-label"},N=A(()=>t("div",{class:"description"},"To continue we need you to authenticate",-1)),P=["onKeyup"],R={key:0,class:"span-error"},L=A(()=>t("div",{class:"spacer"},null,-1)),M=f({__name:"AuthInfo",props:{invalid:{type:Boolean,default:!1},header:{type:String}},emits:["sendAuthInfo"],setup(o,{emit:s}){const e=v({email:""}),c=()=>{s("sendAuthInfo",e)};return(u,l)=>(n(),a("div",V,[t("div",D,[t("div",K,b(o.header),1),N]),g(t("input",{"onUpdate:modelValue":l[0]||(l[0]=r=>e.email=r),type:"email",placeholder:"Email address",class:"input email-input",onKeyup:I(c,["enter"])},null,40,P),[[w,e.email]]),o.invalid?(n(),a("span",R," Email invalid, please try again. ")):h("",!0),L,t("button",{class:"next-button",onClick:c}," Send a verification email ")]))}});const U=y(M,[["__scopeId","data-v-1b435c3a"]]),x=o=>(T("data-v-9316d802"),o=o(),$(),o),F={class:"auth-token"},j={class:"auth-label"},q=["onKeyup"],z={key:0,class:"span-error"},G={key:1,class:"span-error"},H=x(()=>t("div",{class:"spacer"},null,-1)),J={class:"button-icon",viewBox:"0 0 24 24"},O=["d"],Q=x(()=>t("div",{class:"footer"}," If you haven't received the verification code, try again or choose another email ",-1)),W=f({__name:"AuthToken",props:{expired:{type:Boolean},invalid:{type:Boolean},email:{}},emits:["sendToken","restartAuth","resendToken"],setup(o,{emit:s}){const e=v({token:""}),c=()=>{s("restartAuth")},u=()=>{s("resendToken")},l=()=>{s("sendToken",e.token)};return(r,i)=>(n(),a("div",F,[t("div",j," Check "+b(r.email)+"'s inbox and enter your verification code below ",1),g(t("input",{"onUpdate:modelValue":i[0]||(i[0]=d=>e.token=d),type:"text",placeholder:"Type your verification code",class:"input",onKeyup:I(l,["enter"])},null,40,q),[[w,e.token]]),r.expired?(n(),a("span",z," Token expired, try to resend it. ")):h("",!0),r.invalid?(n(),a("span",G," Token invalid, please try again or go back and alter you email address. ")):h("",!0),H,t("button",{class:"next-button",onClick:l},"Verify Email"),t("button",{class:"secondary-button back",onClick:c},[(n(),a("svg",J,[t("path",{d:B(E)},null,8,O)])),C(" Try Again ")]),t("button",{class:"secondary-button back",onClick:u}," Resend Email "),Q]))}});const X=y(W,[["__scopeId","data-v-9316d802"]]),Y={key:0,class:"form"},Z={class:"form-wrapper"},ee={class:"widget"},te={key:1,class:"form"},oe={class:"form-wrapper"},se={class:"widget"},ne={key:2,class:"form"},ae={class:"form-wrapper"},ie={class:"loading"},de=f({__name:"Passwordless",props:{header:{type:String,default:"Validate your email"}},emits:["done"],setup(o,{emit:s}){const e=v({stage:"collect-info",info:null,token:null,invalid:!1}),c=async i=>{e.info=i,e.stage="loading";const d=await k.authenticate(i.email);e.invalid=!!d,d?e.stage="collect-info":e.stage="collect-token"},u=async i=>{var d;if(!!((d=e.info)!=null&&d.email)){e.token=i,e.stage="loading";try{const _=await k.verify(e.info.email,e.token);if(!_)throw new Error("no user");s("done",_),e.stage="done"}catch{e.invalid=!0,e.stage="collect-token"}}},l=()=>{e.info&&c(e.info)},r=()=>{e.stage="collect-info",e.info=null,e.token=null,e.invalid=!1};return(i,d)=>{var _,m;return e.stage==="collect-info"?(n(),a("div",Y,[t("div",Z,[t("div",ee,[p(U,{invalid:e.invalid,header:o.header,onSendAuthInfo:c},null,8,["invalid","header"])])])])):e.stage==="collect-token"?(n(),a("div",te,[t("div",oe,[t("div",se,[p(X,{invalid:e.invalid,email:(m=(_=e.info)==null?void 0:_.email)!=null?m:"",onSendToken:u,onResendToken:l,onRestartAuth:r},null,8,["invalid","email"])])])])):(n(),a("div",ne,[t("div",ae,[t("div",ie,[p(S)])])]))}}});const ue=y(de,[["__scopeId","data-v-c7662bee"]]);export{ue as P};
//# sourceMappingURL=Passwordless.c72ce9bc.js.map
