import{c,e as f,a as o,w as h,d as n,v as d,t as w,g as k,f as C,r,h as V,i as N,o as x,k as q}from"./index-Bodg7xX-.js";import{_ as A}from"./AdminSidebar-C3W8DF6y.js";import{u as P}from"./admins-Dq1-j8lI.js";import"./bmmg-logo-CDMybbK7.js";const S={class:"min-h-screen bg-ink flex flex-col md:flex-row"},U={class:"flex-1 p-6 md:p-10 max-w-xl"},B={key:0,class:"text-sm text-wine-deep bg-wine/20 border border-wine/40 rounded-lg px-3 py-2 text-cream"},R={class:"flex gap-3"},T=["disabled"],$={__name:"AdminNew",setup(D){const v=N(),g=P(),i=r(""),u=r(""),a=r(""),m=r(""),t=r(""),s=r(!1);async function y(){var p,e;if(t.value="",a.value.length<8){t.value="Password must be at least 8 characters.";return}if(a.value!==m.value){t.value="Passwords don't match.";return}s.value=!0;try{await g.createAdmin({name:i.value,email:u.value,password:a.value}),v.push({name:"admin-admins"})}catch(b){t.value=((e=(p=b.response)==null?void 0:p.data)==null?void 0:e.message)||"Could not create this admin."}finally{s.value=!1}}return(p,e)=>{const b=V("RouterLink");return x(),c("div",S,[f(A),o("main",U,[e[9]||(e[9]=o("h1",{class:"font-display text-2xl text-cream mb-1"},"Add admin",-1)),e[10]||(e[10]=o("p",{class:"text-muted text-sm mb-8"}," They'll be able to sign in immediately with the password you set here. ",-1)),o("form",{onSubmit:h(y,["prevent"]),class:"glass rounded-2xl p-6 space-y-4 shadow-soft"},[o("div",null,[e[4]||(e[4]=o("label",{class:"eyebrow block mb-2",for:"name"},"Name",-1)),n(o("input",{id:"name","onUpdate:modelValue":e[0]||(e[0]=l=>i.value=l),type:"text",required:"",class:"w-full bg-black/30 border border-hairline rounded-lg px-4 py-2.5 text-cream placeholder:text-muted/60 focus:border-gold/50 outline-none transition-colors"},null,512),[[d,i.value]])]),o("div",null,[e[5]||(e[5]=o("label",{class:"eyebrow block mb-2",for:"email"},"Email",-1)),n(o("input",{id:"email","onUpdate:modelValue":e[1]||(e[1]=l=>u.value=l),type:"email",required:"",autocomplete:"email",class:"w-full bg-black/30 border border-hairline rounded-lg px-4 py-2.5 text-cream placeholder:text-muted/60 focus:border-gold/50 outline-none transition-colors",placeholder:"them@bmmgrecords.com"},null,512),[[d,u.value]])]),o("div",null,[e[6]||(e[6]=o("label",{class:"eyebrow block mb-2",for:"password"},"Password",-1)),n(o("input",{id:"password","onUpdate:modelValue":e[2]||(e[2]=l=>a.value=l),type:"password",required:"",autocomplete:"new-password",class:"w-full bg-black/30 border border-hairline rounded-lg px-4 py-2.5 text-cream placeholder:text-muted/60 focus:border-gold/50 outline-none transition-colors",placeholder:"••••••••"},null,512),[[d,a.value]])]),o("div",null,[e[7]||(e[7]=o("label",{class:"eyebrow block mb-2",for:"confirm-password"},"Confirm password",-1)),n(o("input",{id:"confirm-password","onUpdate:modelValue":e[3]||(e[3]=l=>m.value=l),type:"password",required:"",autocomplete:"new-password",class:"w-full bg-black/30 border border-hairline rounded-lg px-4 py-2.5 text-cream placeholder:text-muted/60 focus:border-gold/50 outline-none transition-colors",placeholder:"••••••••"},null,512),[[d,m.value]])]),t.value?(x(),c("p",B,w(t.value),1)):k("",!0),o("div",R,[f(b,{to:{name:"admin-admins"},class:"px-5 py-2.5 rounded-lg border border-hairline text-cream text-sm hover:bg-white/[0.04] transition-colors"},{default:C(()=>[...e[8]||(e[8]=[q(" Cancel ",-1)])]),_:1}),o("button",{type:"submit",disabled:s.value,class:"flex-1 bg-gold hover:bg-gold-bright disabled:opacity-50 text-ink font-semibold rounded-lg py-2.5 transition-colors"},w(s.value?"Creating…":"Create admin"),9,T)])],32)])])}}};export{$ as default};
