import{d as b,ae as l,q as y,n as c,k as n,i as p,dy as C,u as S,j as u,o as V,C as d,P as m}from"./index-BBlvj0M_.js";import{u as k}from"./usePrefectApi-Boduij1X.js";import"./api-D3LJrWSC.js";import"./mapper-DWfgs_2K.js";const I={class:"flex items-center justify-center min-h-screen"},P={class:"w-full max-w-[400px] p-8 m-4 bg-surface-raised rounded-lg shadow-lg"},U=b({__name:"Unauthenticated",props:{redirect:{}},setup(f){const h=f,o=l(""),t=l(!1),s=l(""),a=S(),i=k(),v=async()=>{if(!t.value){t.value=!0,s.value="";try{localStorage.setItem("prefect-password",btoa(o.value)),i.admin.authCheck().then(r=>{r==401?(localStorage.removeItem("prefect-pasword"),m("Authentication failed.","error",{timeout:!1}),a.currentRoute.value.name!=="login"&&a.push({name:"login",query:{redirect:a.currentRoute.value.fullPath}})):i.health.isHealthy().then(e=>{e||m(`Can't connect to Server API at ${config.baseUrl}. Check that it's accessible from your machine.`,"error",{timeout:!1}),a.push(h.redirect||"/")})})}catch{localStorage.removeItem("prefect-password"),s.value="Invalid password"}finally{t.value=!1}}};return(r,e)=>{const g=u("p-heading"),_=u("p-text-input"),w=u("p-button");return V(),y("div",I,[c("div",P,[n(g,{tag:"h1",size:"lg",class:"mb-6 text-center text-default"},{default:p(()=>e[1]||(e[1]=[d(" Login ")])),_:1}),c("form",{onSubmit:C(v,["prevent"]),class:"flex flex-col gap-4"},[n(_,{modelValue:o.value,"onUpdate:modelValue":e[0]||(e[0]=x=>o.value=x),type:"password",placeholder:"admin:pass",error:s.value,autofocus:"",class:"w-full"},null,8,["modelValue","error"]),n(w,{type:"submit",loading:t.value,class:"w-full"},{default:p(()=>e[2]||(e[2]=[d(" Login ")])),_:1},8,["loading"])],32)])])}}});export{U as default};
//# sourceMappingURL=Unauthenticated-CHS9i2nT.js.map
