(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[74520],{13504:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>c});var a=r(95155),s=r(5772),n=r(73321),i=r(12115),o=r(89239),d=r(81477),l=r(60529);function c(){let e=(0,n.useRouter)(),[t,r]=(0,i.useState)(!1),[c,u]=(0,i.useState)(!1),[f,p]=(0,i.useState)(""),[m,h]=(0,i.useState)(""),[g,x]=(0,i.useState)(""),[v,b]=(0,i.useState)(!1);(0,i.useEffect)(()=>{fetch("/api/auth/check").then(async t=>{t.ok?e.replace("/"):((await t.json().catch(()=>({}))).needsSetup&&r(!0),u(!0))}).catch(()=>{u(!0)})},[e]);let w=async r=>{if(r.preventDefault(),x(""),t){if(f.length<4)return void x("Password must be at least 4 characters");if(f!==m)return void x("Passwords do not match")}b(!0);try{let r=t?"/api/auth/setup":"/api/auth/login",a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:f})});if(a.ok)e.replace("/");else{let e=await a.json().catch(()=>({}));x(e.error||"Invalid password")}}catch{x("Connection failed")}finally{b(!1)}};return c?(0,a.jsx)("div",{className:"flex min-h-screen items-center justify-center p-4",children:(0,a.jsxs)(d.Zp,{className:"w-full max-w-sm",children:[(0,a.jsxs)(d.aR,{children:[(0,a.jsxs)(d.ZB,{className:"flex items-center gap-2",children:[(0,a.jsx)(s.default,{src:"/icon-192.png",alt:"",width:28,height:28,className:"dark:invert"}),"Cockpit"]}),(0,a.jsx)(d.BT,{children:t?"Set a password to secure your instance":"Enter your password to continue"})]}),(0,a.jsx)(d.Wu,{children:(0,a.jsxs)("form",{onSubmit:w,className:"space-y-4",children:[(0,a.jsx)(l.p,{type:"password",autoComplete:t?"new-password":"current-password",value:f,onChange:e=>p(e.target.value),placeholder:t?"Choose a password":"Password",required:!0}),t&&(0,a.jsx)(l.p,{type:"password",autoComplete:"new-password",value:m,onChange:e=>h(e.target.value),placeholder:"Confirm password",required:!0}),g&&(0,a.jsx)("p",{className:"text-sm text-destructive",children:g}),(0,a.jsx)(o.$,{type:"submit",className:"w-full",disabled:v,children:v?t?"Setting up...":"Logging in...":t?"Set password":"Login"})]})})]})}):null}},32098:(e,t,r)=>{Promise.resolve().then(r.bind(r,13504))},40980:(e,t,r)=>{"use strict";r.d(t,{cn:()=>n});var a=r(29722),s=r(622);function n(...e){return(0,s.QP)((0,a.$)(e))}},60529:(e,t,r)=>{"use strict";r.d(t,{p:()=>i});var a=r(95155),s=r(12115),n=r(40980);let i=s.forwardRef(({className:e,type:t,...r},s)=>(0,a.jsx)("input",{type:t,className:(0,n.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:s,...r}));i.displayName="Input"},81477:(e,t,r)=>{"use strict";r.d(t,{BT:()=>l,Wu:()=>c,ZB:()=>d,Zp:()=>i,aR:()=>o});var a=r(95155),s=r(12115),n=r(40980);let i=s.forwardRef(({className:e,...t},r)=>(0,a.jsx)("div",{ref:r,className:(0,n.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));i.displayName="Card";let o=s.forwardRef(({className:e,...t},r)=>(0,a.jsx)("div",{ref:r,className:(0,n.cn)("flex flex-col space-y-1.5 p-6",e),...t}));o.displayName="CardHeader";let d=s.forwardRef(({className:e,...t},r)=>(0,a.jsx)("div",{ref:r,className:(0,n.cn)("text-2xl font-semibold leading-none tracking-tight",e),...t}));d.displayName="CardTitle";let l=s.forwardRef(({className:e,...t},r)=>(0,a.jsx)("div",{ref:r,className:(0,n.cn)("text-sm text-muted-foreground",e),...t}));l.displayName="CardDescription";let c=s.forwardRef(({className:e,...t},r)=>(0,a.jsx)("div",{ref:r,className:(0,n.cn)("p-6 pt-0",e),...t}));c.displayName="CardContent"},89239:(e,t,r)=>{"use strict";r.d(t,{$:()=>l});var a=r(95155),s=r(54850),n=r(18460),i=r(12115),o=r(40980);let d=(0,n.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),l=i.forwardRef(({className:e,variant:t,size:r,asChild:n=!1,...i},l)=>{let c=n?s.DX:"button";return(0,a.jsx)(c,{className:(0,o.cn)(d({variant:t,size:r,className:e})),ref:l,...i})});l.displayName="Button"}},e=>{e.O(0,[989,28441,93794,77358],()=>e(e.s=32098)),_N_E=e.O()}]);