import"../chunks/DsnmJJEf.js";import{p as Ne,u as Te,t as p,a as m,b as he,i as Re,c as E,d as s,$ as Ie,r as o,s as d,g as r,k as W,l as De,e as q,f as w,j as v,n as we,h as S}from"../chunks/Dyk1ealw.js";import{d as Ae,a as ye,s as _,e as Me}from"../chunks/DEEYSJdk.js";import{i as N}from"../chunks/cYAxD0tk.js";import{h as Pe}from"../chunks/CaDw_BSN.js";import{h as Oe,s as ke}from"../chunks/BGzpdNMV.js";import{s as Q,r as Xe,t as T}from"../chunks/CDBVw774.js";import{b as Le}from"../chunks/CfwjHbh5.js";import{i as n}from"../chunks/CVq-Ik9t.js";import{g as Ce}from"../chunks/BCu6PYO-.js";import{b as Y}from"../chunks/DXU0JJLc.js";import{p as J}from"../chunks/BES_pAfq.js";import{r as Ge}from"../chunks/DibDeWsm.js";import{B as We}from"../chunks/CqOTUmYS.js";import{D as ze}from"../chunks/BG_D_W2D.js";import{B as Be,t as Z}from"../chunks/C7KHiE1N.js";import{p as z,P as Ke,e as $e}from"../chunks/D1dEN-Fp.js";import{S as je,M as Ue}from"../chunks/Bce1U4cK.js";import{L as Fe}from"../chunks/BkBShXgg.js";import{K as He}from"../chunks/B7KuJ1Jb.js";var Ve=E('<div class="px-6 py-5 text-center text-[0.8125rem] text-muted-foreground"> </div>'),qe=E('<p class="text-xs text-red-500"> </p>'),Qe=E("<!> ",1),Ye=E("<!> Reset password",1),Je=E('<form class="space-y-4 px-6 py-5" novalidate=""><!> <div class="space-y-1.5"><label for="confirm" class="text-[0.8125rem] font-medium text-foreground"> </label> <input id="confirm" type="password" autocomplete="new-password"/> <!></div> <!></form>'),Ze=E('<div class="flex min-h-screen items-center justify-center bg-background p-4"><button type="button" class="absolute top-4 right-4 inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground"><!></button> <div class="w-full max-w-sm"><div class="mb-8 flex flex-col items-center text-center"><div class="mb-4"><!></div> <h1 class="text-2xl font-semibold tracking-tight text-foreground"> </h1> <p class="mt-1 text-[0.8125rem] text-muted-foreground"><!></p></div> <div class="rounded-lg border border-border bg-card shadow-sm"><!> <div class="border-t border-border px-6 py-3"><a class="flex items-center justify-center gap-1.5 text-[0.75rem] font-medium text-muted-foreground transition-colors hover:text-foreground"><!> </a></div></div></div></div>');function xr(ee,re){Ne(re,!0);const A=W(()=>J.url.searchParams.get("user")??""),B=W(()=>J.url.searchParams.get("token")??"");let f=S(""),y=S(""),u=S(!1),M=S(!1),h=S(!1);Te(()=>{z.load().catch(()=>{})});const K=W(()=>!r(A)||!r(B));async function te(e){e.preventDefault(),v(M,!1),v(h,!1);const t=$e(r(f),z.current);if(!r(f)||!t.allRulesMet){v(M,!0);return}if(r(f)!==r(y)){v(h,!0);return}v(u,!0);try{await Ge(r(A),r(B),r(f)),T.success(n.t("ADMIN_NEXT.RESET.PASSWORD_RESET_SUCCESSFULLY_PLEASE_SIGN")),Ce(`${Y}/login`)}catch(a){if(a&&typeof a=="object"&&"status"in a){const i=a;i.status===429?T.error(i.message||"Too many attempts. Try again later."):i.status===422||i.status===400?T.error(i.message||"Invalid or expired reset link."):T.error(i.message||"Unable to reset password")}else T.error(n.t("ADMIN_NEXT.RESET.UNABLE_TO_CONNECT_TO_SERVER"))}finally{v(u,!1)}}var P=Ze();Oe("1rnsd0w",e=>{Re(t=>{Ie.title=t??""},[()=>n.t("ADMIN_NEXT.RESET.RESET_PASSWORD_GRAV_ADMIN")])});var g=s(P),ae=s(g);{var se=e=>{je(e,{size:16})},oe=e=>{Ue(e,{size:16})};N(ae,e=>{Z.isDark?e(se):e(oe,-1)})}o(g);var $=d(g,2),O=s($),k=s(O),ie=s(k);Be(ie,{size:"login"}),o(k);var X=d(k,2),ne=s(X,!0);o(X);var j=d(X,2),le=s(j);{var de=e=>{var t=De();p(a=>_(t,a),[()=>n.t("ADMIN_NEXT.RESET.INVALID_LINK")]),m(e,t)},me=e=>{var t=q(),a=w(t);Pe(a,()=>n.tHtml("ADMIN_NEXT.RESET.NEW_PASSWORD_FOR",{username:r(A)})),m(e,t)};N(le,e=>{r(K)?e(de):e(me,-1)})}o(j),o(O);var U=d(O,2),F=s(U);{var ve=e=>{var t=Ve(),a=s(t,!0);o(t),p(i=>_(a,i),[()=>n.t("ADMIN_NEXT.RESET.THIS_RESET_LINK_IS_MISSING_REQUIRED")]),m(e,t)},_e=e=>{var t=Je(),a=s(t);Ke(a,{id:"password",label:"New password",get policy(){return z.current},get disabled(){return r(u)},get invalid(){return r(M)},invalidMessage:"Password does not meet the required policy",get value(){return r(f)},set value(l){v(f,l,!0)}});var i=d(a,2),C=s(i),ue=s(C,!0);o(C);var b=d(C,2);Xe(b);var ce=d(b,2);{var pe=l=>{var R=qe(),I=s(R,!0);o(R),p(G=>_(I,G),[()=>n.t("ADMIN_NEXT.RESET.PASSWORDS_DO_NOT_MATCH")]),m(l,R)};N(ce,l=>{r(h)&&l(pe)})}o(i);var Ee=d(i,2);We(Ee,{type:"submit",class:"w-full",get disabled(){return r(u)},children:(l,R)=>{var I=q(),G=w(I);{var ge=c=>{var x=Qe(),D=w(x);Fe(D,{size:15,class:"animate-spin"});var xe=d(D);p(Se=>_(xe,` ${Se??""}`),[()=>n.t("ADMIN_NEXT.RESET.RESETTING")]),m(c,x)},be=c=>{var x=Ye(),D=w(x);He(D,{size:15}),we(),m(c,x)};N(G,c=>{r(u)?c(ge):c(be,-1)})}m(l,I)},$$slots:{default:!0}}),o(t),p(l=>{_(ue,l),ke(b,1,`flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-sm shadow-sm transition-all focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring
								${r(h)?"border-red-500 ring-1 ring-red-500/30 animate-[shake_0.3s_ease-in-out]":"border-input"}`),b.disabled=r(u)},[()=>n.t("ADMIN_NEXT.RESET.CONFIRM_PASSWORD")]),Me("submit",t,te),Le(b,()=>r(y),l=>v(y,l)),m(e,t)};N(F,e=>{r(K)?e(ve):e(_e,-1)})}var H=d(F,2),L=s(H),V=s(L);ze(V,{name:"arrow-back",size:12});var fe=d(V);o(L),o(H),o(U),o($),o(P),p((e,t,a)=>{Q(g,"aria-label",e),_(ne,t),Q(L,"href",`${Y??""}/login`),_(fe,` ${a??""}`)},[()=>n.t("ADMIN_NEXT.TOGGLE_DARK_MODE"),()=>n.t("ADMIN_NEXT.RESET.RESET_PASSWORD"),()=>n.t("ADMIN_NEXT.RESET.BACK_TO_SIGN_IN")]),ye("click",g,()=>Z.toggleColorMode()),m(ee,P),he()}Ae(["click"]);export{xr as component};
