import{d as O,u as S,ai as A,Y as s,o as b,g as y,w as m,a,l,j as B,n as p,i as r,k as g,af as v,h as f,aZ as I,N as h,X as L,aM as U,ah as T,aN as $,_ as j}from"./CAAZGces.js";import{_ as D}from"./cgPYkJvY.js";import{N as P}from"./C-rnA_kk.js";const R={class:"flex flex-col gap-3"},X=["disabled"],Y={class:"text-input-wrapper"},Z=["disabled"],E={class:"textarea-wrapper"},F=["disabled"],J={class:"flex gap-2"},W=["disabled"],q=O({__name:"OrganizationCreateModal",setup(G,{expose:w}){const _=S(),{addNotification:z}=A(),i=s(""),d=s(""),u=s(""),x=s(!1),c=s(),t=s(!0);async function C(){var o;U();try{const e={name:i.value.trim(),description:u.value.trim(),slug:d.value.trim().replace(/ +/g,"")},n=await T("organization",{method:"POST",body:JSON.stringify(e),apiVersion:3});(o=c.value)==null||o.hide(),await _.push(`/organization/${n.slug}`)}catch(e){console.error(e),z({title:"An error occurred",text:e.data?e.data.description:e,type:"error"})}$()}function N(o){var e;i.value="",u.value="",(e=c.value)==null||e.show(o)}function k(){var o;(o=c.value)==null||o.hide()}function V(){x.value||(d.value=i.value.trim().toLowerCase().replaceAll(" ","-").replaceAll(/[^a-zA-Z0-9!@$()`.+,_"-]/g,"").replaceAll(/--+/gm,"-"))}function M(){x.value=!0}return w({show:N}),(o,e)=>(b(),y(l(P),{ref_key:"modal",ref:c,header:"Creating an organization"},{default:m(()=>[a("div",R,[t.value?(b(),y(l(D),{key:0,class:"max-w-[30rem]",type:"info",header:"Organization creation temporarily disabled",body:"Due to abuse, we've temporarily disabled the creation of new organizations. We're working hard to restore this feature, thank you for your patience."})):B("",!0),a("div",{class:p(["flex flex-col gap-2",{"opacity-50":t.value}])},[e[3]||(e[3]=a("label",{for:"name"},[a("span",{class:"text-lg font-semibold text-contrast"},[r(" Name "),a("span",{class:"text-brand-red"},"*")])],-1)),g(a("input",{id:"name","onUpdate:modelValue":e[0]||(e[0]=n=>i.value=n),type:"text",maxlength:"64",placeholder:"Enter organization name...",autocomplete:"off",disabled:t.value,onInput:V},null,40,X),[[v,i.value]])],2),a("div",{class:p(["flex flex-col gap-2",{"opacity-50":t.value}])},[e[5]||(e[5]=a("label",{for:"slug"},[a("span",{class:"text-lg font-semibold text-contrast"},[r(" URL "),a("span",{class:"text-brand-red"},"*")])],-1)),a("div",Y,[e[4]||(e[4]=a("div",{class:"text-input-wrapper__before"},"https://test.kalataka.ru/organization/",-1)),g(a("input",{id:"slug","onUpdate:modelValue":e[1]||(e[1]=n=>d.value=n),type:"text",maxlength:"64",autocomplete:"off",disabled:t.value,onInput:M},null,40,Z),[[v,d.value]])])],2),a("div",{class:p(["flex flex-col gap-2",{"opacity-50":t.value}])},[e[6]||(e[6]=a("label",{for:"additional-information",class:"flex flex-col gap-1"},[a("span",{class:"text-lg font-semibold text-contrast"},[r(" Summary "),a("span",{class:"text-brand-red"},"*")]),a("span",null,"A sentence or two that describes your organization.")],-1)),a("div",E,[g(a("textarea",{id:"additional-information","onUpdate:modelValue":e[2]||(e[2]=n=>u.value=n),disabled:t.value,maxlength:"256"},null,8,F),[[v,u.value]])])],2),a("p",{class:p(["m-0 max-w-[30rem]",{"opacity-50":t.value}])}," You will be the owner of this organization, but you can invite other members and transfer ownership at any time. ",2),a("div",J,[f(l(h),{color:"brand"},{default:m(()=>[a("button",{disabled:t.value,onClick:C},[f(l(I),{"aria-hidden":"true"}),e[7]||(e[7]=r(" Create organization "))],8,W)]),_:1}),f(l(h),null,{default:m(()=>[a("button",{onClick:k},[f(l(L),{"aria-hidden":"true"}),e[8]||(e[8]=r(" Cancel "))])]),_:1})])])]),_:1},512))}}),ee=j(q,[["__scopeId","data-v-9c828672"]]);export{ee as O};