import{B as e,C as t,G as n,S as r,c as i,ft as a,j as o,l as s,m as c,o as l,p as u,r as d,s as f,u as p,x as ee}from"./runtime-core.esm-bundler-DTXUv7Wx.js";import{s as te}from"./runtime-dom.esm-bundler-CXLmyuFK.js";import{a as ne,o as re,t as ie}from"./vue-router-Cyqru1db.js";import{t as ae}from"./i18n-XDSWEyNo.js";import{r as oe}from"./products-BqW5PUnm.js";import{c as se,d as ce,f as m,i as h,p as g,r as _}from"./api-DlB23x7f.js";import{t as v}from"./Navbar-DV-_CpC6.js";import{t as y}from"./Button-D1Rp2Xe1.js";import{t as b}from"./CartDrawer-BdjtcjVt.js";import{t as x}from"./Footer-CjMyQsRh.js";import{t as S}from"./Input-B1vjqdSR.js";var C={class:`bg-cream text-ink min-h-svh`},w={class:`mx-auto w-full max-w-md px-6 py-14 sm:px-8 sm:py-20 md:py-24`},T={class:`flex flex-col gap-3 mb-8 text-center`},E={class:`eyebrow`},D={class:`font-display font-normal leading-[1.05] tracking-tight text-ink text-headline-md`},O={class:`text-[14px] text-muted`},k={key:1,class:`text-sm text-danger`,role:`alert`,"aria-live":`polite`},A={key:1,class:`rounded-md border border-line bg-paper p-6 md:p-8 flex flex-col gap-3 text-center`},j={class:`font-display text-xl text-brand`},M={class:`text-[14px] text-muted`},N={class:`mt-8 text-center text-[14px] text-muted`},P={__name:`LoginPage`,setup(P){let{t:F}=ae(),I=g(),L=ne(),R=re(),z=e(!1);function B(){z.value=!1,R.push(`/checkout`)}async function V(e){await se(e.id,1),z.value=!0}async function H({productId:e,quantity:t}){await m(e,t)}async function U(e){await ce(e)}let W=[{key:`nav.shop`,href:`/shop`},{key:`nav.bundles`,href:`/#bundles`},{key:`nav.revitalization`,href:`/#revitalize`},{key:`nav.about`,href:`/#about`}],G=e(``),K=e(``),q=e(!1),J=e(``),Y=e(!1),X=e(!1),le=l(()=>G.value?Y.value?!1:K.value.length<8:!0);async function ue(){J.value=``,q.value=!0;try{if(Y.value){await _({email:G.value}),X.value=!0;return}await h({email:G.value,password:K.value});let e=String(L.query.next||`/`);R.push(e)}catch(e){J.value=e?.message||F(`checkout.error.generic`)}finally{q.value=!1}}let Z=e(null),Q=null;function $(){let e=Z.value,t=e&&(e.$el||e);if(!t||typeof window>`u`)return;let n=Math.round(t.getBoundingClientRect().height);document.documentElement.style.setProperty(`--nav-h`,`${n}px`)}return r(()=>{if($(),typeof ResizeObserver<`u`&&Z.value){let e=Z.value.$el||Z.value;Q=new ResizeObserver($),Q.observe(e)}window.addEventListener(`resize`,$)}),ee(()=>{Q&&Q.disconnect(),typeof window<`u`&&window.removeEventListener(`resize`,$)}),(e,r)=>(t(),p(d,null,[c(v,{ref_key:`navRef`,ref:Z,variant:`cream`,layout:`standard`,items:W,"cart-count":n(I).count,products:n(oe),onCart:r[0]||=e=>z.value=!0,onSearch:V},null,8,[`cart-count`,`products`]),f(`main`,C,[f(`div`,w,[f(`header`,T,[f(`p`,E,a(n(F)(`auth.login.eyebrow`)),1),f(`h1`,D,a(Y.value?n(F)(`auth.reset.title`):n(F)(`auth.login.title`)),1),f(`p`,O,a(Y.value?n(F)(`auth.reset.sub`):n(F)(`auth.login.sub`)),1)]),X.value?(t(),p(`div`,A,[f(`h2`,j,a(n(F)(`auth.reset.sent.title`)),1),f(`p`,M,a(n(F)(`auth.reset.sent.body`)),1),f(`button`,{type:`button`,class:`text-[13px] text-brand hover:underline self-center mt-2`,onClick:r[4]||=e=>{Y.value=!1,X.value=!1}},a(n(F)(`auth.reset.back`)),1)])):(t(),p(`form`,{key:0,class:`flex flex-col gap-5 rounded-md border border-line bg-paper p-6 md:p-8`,novalidate:``,onSubmit:te(ue,[`prevent`])},[c(S,{modelValue:G.value,"onUpdate:modelValue":r[1]||=e=>G.value=e,label:n(F)(`checkout.field.email`),type:`email`,required:``,placeholder:n(F)(`checkout.placeholder.email`)},null,8,[`modelValue`,`label`,`placeholder`]),Y.value?s(``,!0):(t(),i(S,{key:0,modelValue:K.value,"onUpdate:modelValue":r[2]||=e=>K.value=e,label:n(F)(`checkout.field.password`),type:`password`,required:``},null,8,[`modelValue`,`label`])),J.value?(t(),p(`p`,k,a(J.value),1)):s(``,!0),c(y,{type:`submit`,variant:`primary`,size:`lg`,block:``,loading:q.value,disabled:le.value},{default:o(()=>[u(a(Y.value?n(F)(`auth.reset.cta`):n(F)(`auth.login.cta`)),1)]),_:1},8,[`loading`,`disabled`]),f(`button`,{type:`button`,class:`text-[13px] text-brand hover:underline self-start`,onClick:r[3]||=e=>Y.value=!Y.value},a(Y.value?n(F)(`auth.reset.back`):n(F)(`auth.login.forgot`)),1)],32)),f(`p`,N,[u(a(n(F)(`auth.login.newCustomer`))+` `,1),c(n(ie),{to:`/register`,class:`text-brand hover:underline`},{default:o(()=>[u(a(n(F)(`auth.login.cta.register`)),1)]),_:1})])])]),c(x),c(b,{modelValue:z.value,"onUpdate:modelValue":r[5]||=e=>z.value=e,items:n(I).items,subtotal:n(I).subtotal,count:n(I).count,onUpdateQuantity:H,onRemove:U,onCheckout:B},null,8,[`modelValue`,`items`,`subtotal`,`count`])],64))}};export{P as default};