import{_ as j,ai as I,u as _,Y as c,o as k,g as M,w as u,a as t,i as p,k as f,af as m,l as a,aq as x,t as g,h as d,aY as V,N as v,X as B,aM as S,ah as A,aN as T}from"./v5WcX6fg.js";import{N as U}from"./TS9ft8Ya.js";import{c as Y}from"./B1wHd0jh.js";const D={class:"flex flex-col gap-3"},L={class:"flex flex-col gap-2"},P={class:"flex flex-col gap-2"},R={class:"textarea-wrapper"},X={class:"m-0 max-w-[30rem]"},$={class:"flex gap-2"},q={__name:"CollectionCreateModal",props:{projectIds:{type:Array,default(){return[]}}},setup(n,{expose:h}){const{addNotification:w}=I(),b=_(),o=c(""),l=c(""),i=c(),y=n;async function C(){var s;S();try{const e=await A("collection",{method:"POST",body:{name:o.value.trim(),description:l.value.trim()||void 0,projects:y.projectIds},apiVersion:3});await Y(),i.value.hide(),await b.push(`/collection/${e.id}`)}catch(e){w({title:"An error occurred",text:((s=e==null?void 0:e.data)==null?void 0:s.description)||(e==null?void 0:e.message)||e,type:"error"})}T()}function N(s){o.value="",l.value="",i.value.show(s)}return h({show:N}),(s,e)=>(k(),M(a(U),{ref_key:"modal",ref:i,header:"Creating a collection"},{default:u(()=>[t("div",D,[t("div",L,[e[3]||(e[3]=t("label",{for:"name"},[t("span",{class:"text-lg font-semibold text-contrast"},[p(" Name "),t("span",{class:"text-brand-red"},"*")])],-1)),f(t("input",{id:"name","onUpdate:modelValue":e[0]||(e[0]=r=>x(o)?o.value=r:null),type:"text",maxlength:"64",placeholder:"Enter collection name...",autocomplete:"off"},null,512),[[m,a(o)]])]),t("div",P,[e[4]||(e[4]=t("label",{for:"additional-information",class:"flex flex-col gap-1"},[t("span",{class:"text-lg font-semibold text-contrast"}," Summary "),t("span",null,"A sentence or two that describes your collection.")],-1)),t("div",R,[f(t("textarea",{id:"additional-information","onUpdate:modelValue":e[1]||(e[1]=r=>x(l)?l.value=r:null),maxlength:"256"},null,512),[[m,a(l)]])])]),t("p",X," Your new collection will be created as a public collection with "+g(n.projectIds.length>0?n.projectIds.length:"no")+" "+g(n.projectIds.length!==1?"projects":"project")+". ",1),t("div",$,[d(a(v),{color:"brand"},{default:u(()=>[t("button",{onClick:C},[d(a(V),{"aria-hidden":"true"}),e[5]||(e[5]=p(" Create collection "))])]),_:1}),d(a(v),null,{default:u(()=>[t("button",{onClick:e[2]||(e[2]=r=>a(i).hide())},[d(a(B),{"aria-hidden":"true"}),e[6]||(e[6]=p(" Cancel "))])]),_:1})])])]),_:1},512))}},z=j(q,[["__scopeId","data-v-d1e53fa1"]]);export{z as C};