import"../chunks/DsnmJJEf.js";import{p as ve,t as x,g as t,a as b,b as _e,h as N,i as ge,o as xe,s,j as v,c as X,f as q,d as r,k as M,$ as be,r as a}from"../chunks/Dyk1ealw.js";import{e as Ne,s as d}from"../chunks/DEEYSJdk.js";import{i as he}from"../chunks/cYAxD0tk.js";import{h as Ee,s as J}from"../chunks/BGzpdNMV.js";import{s as Ae,t as Q,r as w}from"../chunks/CDBVw774.js";import{b as k}from"../chunks/CfwjHbh5.js";import{i as o}from"../chunks/CVq-Ik9t.js";import{g as ee}from"../chunks/BCu6PYO-.js";import{b as te}from"../chunks/DXU0JJLc.js";import{c as Pe}from"../chunks/BJI0Gzqt.js";import{B as re}from"../chunks/CqOTUmYS.js";import{S as Re}from"../chunks/LlHyE11H.js";import{c as Oe}from"../chunks/DfqTMdwm.js";import{D as $e}from"../chunks/BG_D_W2D.js";import{U as Ge}from"../chunks/CVSsPV09.js";import{L as Ue}from"../chunks/BkBShXgg.js";import{S as De}from"../chunks/lqkrpXLb.js";var ae=X("<!> ",1),Se=X('<div><div class="flex items-center gap-2"><!> <h1> </h1></div> <div class="flex items-center gap-2"><!> <!></div></div>'),ye=X('<div class="flex h-full flex-col"><!> <div class="flex-1 overflow-y-auto"><div class="mx-auto max-w-2xl px-6 py-6 space-y-4"><div><label for="groupname-input" class="mb-1 block text-sm font-medium text-foreground"> </label> <input id="groupname-input" type="text" class="h-10 w-full rounded-md border border-input bg-transparent px-3 text-sm shadow-sm placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring"/> <p class="mt-1 text-xs text-muted-foreground"> </p></div> <div><label for="readableName-input" class="mb-1 block text-sm font-medium text-foreground"> </label> <input id="readableName-input" type="text" class="h-10 w-full rounded-md border border-input bg-transparent px-3 text-sm shadow-sm placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring"/></div> <div><label for="description-input" class="mb-1 block text-sm font-medium text-foreground"> </label> <input id="description-input" type="text" class="h-10 w-full rounded-md border border-input bg-transparent px-3 text-sm shadow-sm placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring"/></div></div></div></div>');function qe(se,oe){ve(oe,!0);let u=N(""),h=N(""),E=N(""),p=N(!1);const A=M(()=>Oe("users")&&/^[a-zA-Z0-9_-]{1,200}$/.test(t(u)));async function z(){if(t(A)){v(p,!0);try{await Pe({groupname:t(u),readableName:t(h),description:t(E)}),Q.success(o.t("ADMIN_NEXT.GROUPS.GROUP_CREATED",{name:t(u)})),ee(`${te}/users/groups/${t(u)}`)}catch(e){const n=e&&typeof e=="object"&&"message"in e?e.message:o.t("ADMIN_NEXT.GROUPS.FAILED_TO_CREATE_GROUP");Q.error(n)}finally{v(p,!1)}}}function ie(e){(e.metaKey||e.ctrlKey)&&e.key==="s"&&(e.preventDefault(),t(A)&&!t(p)&&z())}var P=ye();Ee("fa2np5",e=>{ge(n=>{be.title=n??""},[()=>o.t("ADMIN_NEXT.GROUPS.NEW_GROUP_GRAV_ADMIN")])}),Ne("keydown",xe,ie);var C=r(P);Re(C,{children:(n,D)=>{let c=()=>(D?.()).scrolled;var m=Se(),S=r(m),F=r(S);{let l=M(()=>c()?16:20);Ge(F,{get size(){return t(l)},class:"text-muted-foreground"})}var y=s(F,2),me=r(y,!0);a(y),a(S);var V=s(S,2),Y=r(V);re(Y,{variant:"outline",size:"sm",onclick:()=>ee(`${te}/users/groups`),children:(l,Z)=>{var I=ae(),f=q(I);$e(f,{name:"chevron-back",size:14});var g=s(f);x(T=>d(g,` ${T??""}`),[()=>o.t("ADMIN_NEXT.GROUPS.BACK_TO_GROUPS")]),b(l,I)},$$slots:{default:!0}});var pe=s(Y,2);{let l=M(()=>!t(A)||t(p));re(pe,{size:"sm",get disabled(){return t(l)},onclick:z,children:(Z,I)=>{var f=ae(),g=q(f);{var T=i=>{Ue(i,{size:14,class:"animate-spin"})},ce=i=>{De(i,{size:14})};he(g,i=>{t(p)?i(T):i(ce,-1)})}var fe=s(g);x(i=>d(fe,` ${i??""}`),[()=>o.t("ADMIN_NEXT.GROUPS.CREATE")]),b(Z,f)},$$slots:{default:!0}})}a(V),a(m),x(l=>{J(m,1,`flex items-center justify-between px-6 transition-[padding] duration-200 ${c()?"py-2":"pt-6 pb-3"}`),J(y,1,`font-semibold tracking-tight text-foreground transition-[font-size] duration-200 ${c()?"text-sm":"text-xl"}`),d(me,l)},[()=>o.t("ADMIN_NEXT.GROUPS.NEW_GROUP")]),b(n,m)},$$slots:{default:!0}});var L=s(C,2),K=r(L),R=r(K),O=r(R),ne=r(O,!0);a(O);var _=s(O,2);w(_);var j=s(_,2),le=r(j,!0);a(j),a(R);var $=s(R,2),G=r($),de=r(G,!0);a(G);var B=s(G,2);w(B),a($);var H=s($,2),U=r(H),ue=r(U,!0);a(U);var W=s(U,2);w(W),a(H),a(K),a(L),a(P),x((e,n,D,c,m)=>{d(ne,e),Ae(_,"placeholder",n),d(le,D),d(de,c),d(ue,m)},[()=>o.t("ADMIN_NEXT.GROUPS.GROUP_NAME"),()=>o.t("ADMIN_NEXT.GROUPS.GROUP_NAME_PLACEHOLDER"),()=>o.t("ADMIN_NEXT.GROUPS.GROUP_NAME_HELP"),()=>o.t("ADMIN_NEXT.GROUPS.DISPLAY_NAME"),()=>o.t("ADMIN_NEXT.GROUPS.DESCRIPTION")]),k(_,()=>t(u),e=>v(u,e)),k(B,()=>t(h),e=>v(h,e)),k(W,()=>t(E),e=>v(E,e)),b(se,P),_e()}export{qe as component};
