import{_ as N}from"./3Em5llJ6.js";import{u as P,_ as T}from"./Cn5bykuR.js";import{e as M,p as me,O as pe,Q as J,R as ce,S as _e,T as ge,U as fe,V as $e,v as we,_ as ye,N as be,a as W,d as Q,b as ve}from"./AHiYuuv4.js";import{_ as F}from"./DNLPUXkS.js";import{u as G}from"./BZuZimqN.js";import{a as he,o as Ve,u as ke}from"./ArJcqVXA.js";import{u as qe}from"./Y9ipx7PE.js";import{c as R,l as S,a0 as I,r as O,E as y,P as V,u as e,L as u,N as c,V as b,Q as v,H as C,U as x,b as E,J as Z,Z as Y,O as z,R as j,k as B,F as L,a2 as Le,a7 as Ce,q as Se,a8 as Ue,z as Ie,I as xe,A as Be,a6 as Fe,a9 as Ae}from"./DEIzhR9A.js";import{_ as Re}from"./C5qvglTP.js";import{_ as Ne}from"./lm07vBh-.js";import{u as Pe}from"./nLZJejse.js";const Te="last_logged_in_user",K=()=>({firstName:"",email:""});async function H(){const p=M(),t=me(),{user:a,isLoggedIn:g,fetching:i}=await qe();return await p.runWithContext(()=>{const s=he(`${Te}-${t.value.shopId}`,K(),{serializer:{read:r=>r?JSON.parse(atob(r)):null,write:r=>btoa(JSON.stringify(r))}}),n=()=>{s.value=K()};return R(()=>g.value,r=>{var d,o;!r||(o=(d=a.value)==null?void 0:d.status)!=null&&o.isGuestCustomer||(s.value={firstName:a.value.firstName,email:a.value.email||""})}),{lastLoggedInUser:s,removeLastLoggedInUser:n,isLoggedIn:g,isFetching:i}})}const Ge=p=>new Date(p).toString()!=="Invalid Date",Oe=p=>/^(?=.*[!@#$%^&*])(?=.*[a-z])(?=.*[A-Z]).{8,70}$/.test(p)&&!p.includes(" "),De=p=>$e(p),ze=p=>{const t=we(p);if(!t)return!0;const a=new Date(t);if(!Ge(a))return!0;const g=new Date;return a.getTime()<g.getTime()},Me=p=>{if(!p)return!0;const t=/^[\p{Letter}\s'-.]+$/u.test(p),a=/['-.]{2,}/.test(p),g=!/^['-.].*|['.-]$/.test(p);return t&&g&&!a};function D(){const{$i18n:p}=M(),t=pe({t:p.t.bind(p),messagePath:({$validator:a})=>`validation.${J(a)}`,messageParams:({field:a,max:g,otherName:i,property:s,...n})=>({...n,property:s,field:p.t(`form_fields.${J(a||s)}`),max:g,otherField:i})});return{required:t(ce),email:t(_e),date:t(De),password:t(Oe),futureDate:t(ze),name:t(Me),sameAs:t(ge,{withArguments:!0}),maxLength:t(fe,{withArguments:!0})}}const Ee={class:"flex flex-col gap-6"},He={key:0},je={class:"text-right"},X=S({__name:"LoginForm",async setup(p){let t,a;const{login:g,isSubmitting:i}=([t,a]=I(()=>G("login")),t=await t,a(),t),{lastLoggedInUser:s}=([t,a]=I(()=>H()),t=await t,a(),t),n=D(),r=O({email:"",password:""}),m={email:{required:n.required,email:n.email},password:{required:n.required}},d=P(m,r);R(r,()=>{d.value.$touch()}),R(s,w=>{r.email=w.email});const o=async()=>{await d.value.$validate()&&await g(r)};return(w,l)=>{const _=N,h=T,$=ye,f=F;return y(),V("div",Ee,[e(d)?(y(),V("form",He,[u(h,{errors:e(d).email.$errors},{default:c(({isValid:k})=>[u(_,{modelValue:e(r).email,"onUpdate:modelValue":l[0]||(l[0]=q=>e(r).email=q),autocomplete:"username",label:w.$t("form_fields.email"),type:"email","has-errors":!k,required:"",readonly:e(i),"data-test-id":"login-email",onChange:l[1]||(l[1]=q=>e(d).email.$touch())},null,8,["modelValue","label","has-errors","readonly"])]),_:1},8,["errors"]),u(h,{errors:e(d).password.$errors},{default:c(({isValid:k})=>[u(_,{modelValue:e(r).password,"onUpdate:modelValue":l[2]||(l[2]=q=>e(r).password=q),autocomplete:"current-password",label:w.$t("form_fields.password"),type:"password","has-errors":!k,required:"",readonly:e(i),"data-test-id":"login-password",onChange:l[3]||(l[3]=q=>e(d).password.$touch())},null,8,["modelValue","label","has-errors","readonly"])]),_:1},8,["errors"]),b("div",je,[u($,{to:"/signin?forgotten-password=true",raw:"",class:"group relative text-sm text-gray-800 hover:text-black"},{default:c(()=>[b("span",null,v(w.$t("login_page.forgot_password.title")),1),l[5]||(l[5]=b("span",{class:"absolute inset-x-0 bottom-[-2px] h-px bg-gray-800 transition-all group-hover:inset-x-[-5px] group-hover:bg-black"},null,-1))]),_:1})]),u(f,{type:"primary",class:"mt-4 w-full",disabled:e(i),loading:e(i),"data-test-id":"login-submit",onClick:l[4]||(l[4]=k=>o())},{default:c(()=>[C(v(w.$t("sign_in")),1)]),_:1},8,["disabled","loading"])])):x("",!0)])}}}),Je={class:"mx-auto max-w-[33.75rem]"},Ke=["onClick"],ee=S({__name:"VerticalAccordion",props:{tabs:{},initialIndex:{default:0}},setup(p){const a=E(p.initialIndex),g=s=>{a.value=s},i=s=>({"border-black bg-secondary-100":a.value===s,"border-gray-600":a.value!==s,"border-b-0":a.value>s,"border-t-0":a.value<s,"cursor-pointer":a.value!==s});return(s,n)=>(y(),V("div",Je,[(y(!0),V(Z,null,Y(s.tabs,(r,m)=>(y(),V("div",{key:`accordion-tab-${m}`,class:z(["flex flex-col gap-3.5 border p-3.5 first:rounded-t last:rounded-b",i(m)]),onClick:d=>a.value=m},[b("div",{class:z(["text-sm",{"font-bold":e(a)===m}])},v(r),3),m===e(a)?j(s.$slots,m,{key:0,activateTab:g}):x("",!0)],10,Ke))),128))]))}}),We=S({__name:"WelcomeBackLoginForm",async setup(p){let t,a;const{lastLoggedInUser:g,removeLastLoggedInUser:i}=([t,a]=I(()=>H()),t=await t,a(),t),s=B(()=>g.value.firstName);return(n,r)=>{const m=X,d=ee;return e(g).email?(y(),L(d,{key:0,tabs:[n.$t("login_page.welcome_back.title",{username:e(s)})]},{0:c(()=>[u(m),b("button",{class:"group relative text-left text-sm text-gray-600 hover:text-black",onClick:r[0]||(r[0]=o=>e(i)())},[b("span",null,v(n.$t("login_page.welcome_back.not_user",{username:e(s)})),1)])]),_:1},8,["tabs"])):x("",!0)}}}),Qe=["value"],te=S({__name:"SalutationSelect",props:{modelValue:{type:String,required:!0,default:"f"}},emits:["update:modelValue"],setup(p,{emit:t}){const a=p,g=t,i=E(a.modelValue);R(i,r=>{g("update:modelValue",r)});const{$i18n:s}=M(),n=[{label:s.t("form_fields.female"),value:"f"},{label:s.t("form_fields.male"),value:"m"},{label:s.t("form_fields.divers"),value:"d"}];return(r,m)=>Le((y(),V("select",{"onUpdate:modelValue":m[0]||(m[0]=d=>Se(i)?i.value=d:null),class:"w-full rounded border-2 border-transparent bg-gray-200 p-3 text-sm font-bold placeholder:text-gray-500 focus:outline-none focus:ring-0"},[(y(),V(Z,null,Y(n,(d,o)=>b("option",{key:o,value:d.value},v(d.label),9,Qe)),64))],512)),[[Ce,e(i)]])}}),Ze={class:"mb-4 mt-2"},Ye=S({__name:"RegisterForm",async setup(p){let t,a;const{register:g,isSubmitting:i}=([t,a]=I(()=>G("sign_up")),t=await t,a(),t),s=D(),n=O({gender:"f",first_name:"",last_name:"",email:"",password:""}),r=async()=>{await m.value.$validate()&&await g(n)},m=P({first_name:{required:s.required,maxLength:s.maxLength(30)},last_name:{required:s.required,maxLength:s.maxLength(50)},email:{required:s.required,email:s.email},password:{required:s.required,password:s.password}},n);return(d,o)=>{const w=te,l=N,_=T,h=F;return y(),V("form",null,[b("div",Ze,[u(w,{modelValue:e(n).gender,"onUpdate:modelValue":o[0]||(o[0]=$=>e(n).gender=$)},null,8,["modelValue"])]),u(_,{errors:e(m).first_name.$errors},{default:c(({isValid:$})=>[u(l,{modelValue:e(n).first_name,"onUpdate:modelValue":o[1]||(o[1]=f=>e(n).first_name=f),autocomplete:"given-name",label:d.$t("form_fields.first_name"),"has-errors":!$,required:"",readonly:e(i),onChange:o[2]||(o[2]=f=>e(m).first_name.$touch())},null,8,["modelValue","label","has-errors","readonly"])]),_:1},8,["errors"]),u(_,{errors:e(m).last_name.$errors},{default:c(({isValid:$})=>[u(l,{modelValue:e(n).last_name,"onUpdate:modelValue":o[3]||(o[3]=f=>e(n).last_name=f),autocomplete:"family-name",label:d.$t("form_fields.last_name"),"has-errors":!$,required:"",readonly:e(i),onChange:o[4]||(o[4]=f=>e(m).last_name.$touch())},null,8,["modelValue","label","has-errors","readonly"])]),_:1},8,["errors"]),u(_,{errors:e(m).email.$errors},{default:c(({isValid:$})=>[u(l,{modelValue:e(n).email,"onUpdate:modelValue":o[5]||(o[5]=f=>e(n).email=f),autocomplete:"usernaasdme",label:d.$t("form_fields.email"),type:"email","has-errors":!$,required:"",readonly:e(i),onChange:o[6]||(o[6]=f=>e(m).email.$touch())},null,8,["modelValue","label","has-errors","readonly"])]),_:1},8,["errors"]),u(_,{errors:e(m).password.$errors},{default:c(({isValid:$})=>[u(l,{modelValue:e(n).password,"onUpdate:modelValue":o[7]||(o[7]=f=>e(n).password=f),autocomplete:"new-password",label:d.$t("form_fields.password"),type:"password","has-errors":!$,required:"",readonly:e(i),onChange:o[8]||(o[8]=f=>e(m).password.$touch())},null,8,["modelValue","label","has-errors","readonly"])]),_:1},8,["errors"]),u(h,{type:"primary",class:"mt-3 w-full",disabled:e(i),loading:e(i),onClick:r},{default:c(()=>[C(v(d.$t("login_page.sign_up.submit")),1)]),_:1},8,["disabled","loading"])])}}}),Xe={class:"mb-4 mt-2"},et=S({__name:"GuestLoginForm",async setup(p){let t,a;const{guestLogin:g,isSubmitting:i}=([t,a]=I(()=>G("guest_login")),t=await t,a(),t),s=D(),n=O({gender:"f",first_name:"",last_name:"",email:""}),r=P({first_name:{required:s.required,maxLength:s.maxLength(30)},last_name:{required:s.required,maxLength:s.maxLength(50)},email:{required:s.required,email:s.email}},n),m=async()=>{await r.value.$validate()&&await g(n)};return(d,o)=>{const w=te,l=N,_=T,h=F;return y(),V("form",null,[b("div",Xe,[u(w,{modelValue:e(n).gender,"onUpdate:modelValue":o[0]||(o[0]=$=>e(n).gender=$)},null,8,["modelValue"])]),u(_,{errors:e(r).email.$errors},{default:c(({isValid:$})=>[u(l,{modelValue:e(n).email,"onUpdate:modelValue":o[1]||(o[1]=f=>e(n).email=f),autocomplete:"username",label:d.$t("form_fields.email"),type:"email","has-errors":!$,required:"",readonly:e(i),onChange:o[2]||(o[2]=f=>e(r).email.$touch())},null,8,["modelValue","label","has-errors","readonly"])]),_:1},8,["errors"]),u(_,{errors:e(r).first_name.$errors},{default:c(({isValid:$})=>[u(l,{modelValue:e(n).first_name,"onUpdate:modelValue":o[3]||(o[3]=f=>e(n).first_name=f),autocomplete:"given-name",label:d.$t("form_fields.first_name"),"has-errors":!$,required:"",readonly:e(i),onChange:o[4]||(o[4]=f=>e(r).first_name.$touch())},null,8,["modelValue","label","has-errors","readonly"])]),_:1},8,["errors"]),u(_,{errors:e(r).last_name.$errors},{default:c(({isValid:$})=>[u(l,{modelValue:e(n).last_name,"onUpdate:modelValue":o[5]||(o[5]=f=>e(n).last_name=f),autocomplete:"family-name",label:d.$t("form_fields.last_name"),"has-errors":!$,required:"",readonly:e(i),onChange:o[6]||(o[6]=f=>e(r).last_name.$touch())},null,8,["modelValue","label","has-errors","readonly"])]),_:1},8,["errors"]),u(h,{type:"primary",class:"mt-3 w-full",disabled:e(i),loading:e(i),onClick:o[7]||(o[7]=$=>m())},{default:c(()=>[C(v(d.$t("login_page.guest_login.submit")),1)]),_:1},8,["disabled","loading"])])}}});function tt(){const p=be("is-modal-open",()=>!1),t=a=>{p.value=a};return{isOpen:Ue(p),toggle:t}}const oe=S({name:"AppModal",__name:"Modal",props:{hideCloseButton:{type:Boolean,default:!1},fullScreen:{type:Boolean,default:!1},closeOnOutside:{type:Boolean,default:!0}},emits:["close"],setup(p,{emit:t}){const a=p,g=t,i=E(),{isOpen:s,toggle:n}=tt(),r=()=>{g("close"),n(!1)};Ve(i,()=>a.closeOnOutside&&r());const m=o=>{o.key==="Escape"&&r()},d=(o=!1)=>{const w=ke("keyup",m);o&&w()};return Ie(()=>{n(!0),d()}),xe(()=>{n(!1),d(!0)}),(o,w)=>{const l=Be("IconCloseBold"),_=Re;return y(),L(Fe,{to:"body"},[u(_,null,{default:c(()=>[e(s)?(y(),V("div",{key:0,class:z(["fixed right-0 top-0 z-[100] flex w-full bg-black/50",o.fullScreen?"h-full":"min-h-screen"])},[b("div",{ref_key:"modalRef",ref:i,class:z(["relative m-auto size-full rounded-md bg-white p-8 md:w-[46.875rem]",{"!h-[95%] !w-[95%]":o.fullScreen}])},[j(o.$slots,"headline"),o.hideCloseButton?x("",!0):(y(),V("button",{key:0,"data-test-id":"close-button",class:"absolute right-6 top-6 z-50 cursor-pointer p-3",onClick:r},[u(l,{class:"size-5"})])),j(o.$slots,"default")],2)],2)):x("",!0)]),_:3})])}}}),ot={class:"mb-4 text-sm"},st={class:"flex flex-row-reverse justify-between"},at=S({__name:"ForgotPasswordForm",emits:["close:modal"],async setup(p){let t,a;const{forgotPassword:g,isSubmitting:i}=([t,a]=I(()=>G("forgot_password")),t=await t,a(),t),{lastLoggedInUser:s}=([t,a]=I(()=>H()),t=await t,a(),t),n=D(),r=E(!1),m=O({email:""}),d=async()=>{await w.value.$validate()&&(r.value=await g(m.email))};R(()=>s.value,l=>Object.assign(m.email,l.email));const o={required:n.required,email:n.email},w=P({email:o},m);return(l,_)=>{const h=W,$=N,f=T,k=F,q=oe;return y(),L(q,{onClose:_[3]||(_[3]=U=>l.$emit("close:modal"))},{headline:c(()=>[b("div",null,[u(h,{size:"xl",tag:"h2",class:"mb-4"},{default:c(()=>[C(v(l.$t("login_page.forgot_password.title")),1)]),_:1}),b("p",ot,v(l.$t("login_page.forgot_password.description")),1)])]),default:c(()=>[b("form",null,[u(f,{errors:e(w).email.$errors},{default:c(({isValid:U})=>[u($,{modelValue:e(m).email,"onUpdate:modelValue":_[0]||(_[0]=A=>e(m).email=A),autocomplete:"username",label:l.$t("form_fields.email"),type:"email","has-errors":!U,required:"",readonly:e(i)||e(r),onInput:e(w).email.$touch},null,8,["modelValue","label","has-errors","readonly","onInput"])]),_:1},8,["errors"]),b("div",st,[u(k,{type:"primary",disabled:e(i)||e(r),loading:e(i),onClick:_[1]||(_[1]=U=>d())},{default:c(()=>[C(v(l.$t("login_page.forgot_password.submit")),1)]),_:1},8,["disabled","loading"]),u(k,{type:"outline",disabled:e(i),loading:e(i),onClick:_[2]||(_[2]=U=>l.$emit("close:modal"))},{default:c(()=>[C(v(l.$t("login_page.forgot_password.cancel")),1)]),_:1},8,["disabled","loading"])])])]),_:1})}}}),nt={class:"flex flex-row-reverse justify-between"},rt=S({__name:"UpdatePasswordByHashForm",emits:["close:modal"],async setup(p){let t,a;const g=Q(),{resetPasswordByHash:i,isSubmitting:s}=([t,a]=I(()=>G("reset_password")),t=await t,a(),t),n=D(),r=O({password:""}),m={password:{required:n.required,password:n.password}},d=P(m,r),o=B(()=>{const l=g.query.hash;return(Array.isArray(l)?l[0]:l)??""}),w=async()=>{await d.value.$validate()&&await i({password:r.password,hash:o.value})};return(l,_)=>{const h=W,$=N,f=T,k=F,q=oe;return y(),L(q,{"hide-close-button":""},{headline:c(()=>[b("div",null,[u(h,{size:"xl",tag:"h2",class:"mb-4"},{default:c(()=>[C(v(l.$t("login_page.reset_password.title")),1)]),_:1})])]),default:c(()=>[b("form",null,[u(f,{errors:e(d).password.$errors},{default:c(({isValid:U})=>[u($,{modelValue:e(r).password,"onUpdate:modelValue":_[0]||(_[0]=A=>e(r).password=A),autocomplete:"current-password",label:l.$t("form_fields.new_password"),type:"password","has-errors":!U,required:"",readonly:e(s),onInput:e(d).password.$touch},null,8,["modelValue","label","has-errors","readonly","onInput"])]),_:1},8,["errors"]),b("div",nt,[u(k,{type:"primary",disabled:e(s),loading:e(s),onClick:w},{default:c(()=>[C(v(l.$t("login_page.reset_password.submit")),1)]),_:1},8,["disabled","loading"]),u(k,{type:"outline",disabled:e(s),loading:e(s),onClick:_[1]||(_[1]=U=>l.$emit("close:modal"))},{default:c(()=>[C(v(l.$t("login_page.reset_password.cancel")),1)]),_:1},8,["disabled","loading"])])])]),_:1})}}}),lt={key:0},bt=S({__name:"SignInForm",props:{showGuestLogin:{type:Boolean,default:!0}},async setup(p){let t,a;const g=p,{$i18n:i,$helpers:s}=M(),{lastLoggedInUser:n,isLoggedIn:r,isFetching:m}=([t,a]=I(()=>H()),t=await t,a(),t),d=Q(),o=B(()=>[i.t("login_page.login.title"),i.t("login_page.sign_up.title"),...g.showGuestLogin?[i.t("login_page.guest_login.title")]:[]]),w=B(()=>!!d.query["forgotten-password"]&&!d.query.hash),l=B(()=>d.query.register?1:0),_=B(()=>!!d.query.hash),{localizedNavigateTo:h}=Pe(),$=()=>h(s.route.routes.signin);return(f,k)=>{const q=We,U=X,A=Ye,se=et,ae=F,ne=ee,re=at,le=rt,ie=ve,de=Ne;return y(),L(de,null,{default:c(()=>[!e(r)&&!e(m)?(y(),V("div",lt,[e(n).email?(y(),L(q,{key:0,class:"my-10 px-2"})):(y(),L(ne,{key:1,class:"my-10 px-2","initial-index":e(l),tabs:e(o)},Ae({0:c(()=>[u(U)]),1:c(()=>[u(A)]),_:2},[p.showGuestLogin?{name:"2",fn:c(({activateTab:ue})=>[u(se),u(ae,{type:"tertiary",class:"w-full",onClick:it=>ue(1)},{default:c(()=>[C(v(f.$t("login_page.guest_login.cancel")),1)]),_:2},1032,["onClick"])]),key:"0"}:void 0]),1032,["initial-index","tabs"])),e(w)?(y(),L(re,{key:2,"onClose:modal":$})):x("",!0),e(_)?(y(),L(le,{key:3,"onClose:modal":$})):x("",!0)])):(y(),L(ie,{key:1,type:"custom",class:"mx-auto my-10 h-[336px] w-[524px]"}))]),_:1})}}});export{bt as _};