import{_ as j,ai as I,q as L,u as k,Y as f,o as P,g as T,w as p,a,h as u,l as e,aq as h,i as _,t as n,k as x,af as b,X as B,N as y,aZ as D,v as S,aM as U,ah as A,aN as $}from"./XlhOY3QH.js";import{N as q}from"./fcaSiPlX.js";import{_ as R}from"./DnYDFRQI.js";import{c as X}from"./ClZP4Vnn.js";const Y={class:"min-w-md flex max-w-md flex-col gap-3"},E={class:"flex flex-col gap-2"},F={for:"name"},H={class:"text-lg font-semibold text-contrast"},O=["placeholder","disabled"],Z={class:"flex flex-col gap-2"},z={for:"additional-information",class:"flex flex-col gap-1"},G={class:"text-lg font-semibold text-contrast"},J={class:"textarea-wrapper"},K=["placeholder","disabled"],Q={class:"m-0"},W={class:"flex justify-end gap-2"},ee=["disabled"],te={__name:"CollectionCreateModal",props:{projectIds:{type:Array,default(){return[]}}},setup(g,{expose:v}){const{addNotification:w}=I(),{formatMessage:o}=L(),M=k(),l=S({title:{id:"create.collection.title",defaultMessage:"Creating a collection"},nameLabel:{id:"create.collection.name-label",defaultMessage:"Name"},namePlaceholder:{id:"create.collection.name-placeholder",defaultMessage:"Enter collection name..."},summaryLabel:{id:"create.collection.summary-label",defaultMessage:"Summary"},summaryDescription:{id:"create.collection.summary-description",defaultMessage:"A sentence or two that describes your collection."},summaryPlaceholder:{id:"create.collection.summary-placeholder",defaultMessage:"This is a collection of..."},collectionInfo:{id:"create.collection.collection-info",defaultMessage:"Your new collection will be created as a public collection with {count, plural, =0 {no projects} one {# project} other {# projects}}."},cancel:{id:"create.collection.cancel",defaultMessage:"Cancel"},createCollection:{id:"create.collection.create-collection",defaultMessage:"Create collection"},errorTitle:{id:"create.collection.error-title",defaultMessage:"An error occurred"}}),i=f(""),r=f(""),s=f(!1),m=f(),C=g;async function N(){var d;U();try{const t=await A("collection",{method:"POST",body:{name:i.value.trim(),description:r.value.trim()||void 0,projects:C.projectIds},apiVersion:3});await X(),m.value.hide(),await M.push(`/collection/${t.id}`)}catch(t){w({title:o(l.errorTitle),text:((d=t==null?void 0:t.data)==null?void 0:d.description)||(t==null?void 0:t.message)||t,type:"error"})}$()}function V(d){i.value="",r.value="",m.value.show(d)}return v({show:V}),(d,t)=>(P(),T(e(q),{ref_key:"modal",ref:m,header:e(o)(e(l).title)},{default:p(()=>[a("div",Y,[u(R,{modelValue:e(s),"onUpdate:modelValue":t[0]||(t[0]=c=>h(s)?s.value=c:null),type:"collection"},null,8,["modelValue"]),a("div",E,[a("label",F,[a("span",H,[_(n(e(o)(e(l).nameLabel))+" ",1),t[4]||(t[4]=a("span",{class:"text-brand-red"},"*",-1))])]),x(a("input",{id:"name","onUpdate:modelValue":t[1]||(t[1]=c=>h(i)?i.value=c:null),type:"text",maxlength:"64",placeholder:e(o)(e(l).namePlaceholder),autocomplete:"off",disabled:e(s)},null,8,O),[[b,e(i)]])]),a("div",Z,[a("label",z,[a("span",G,n(e(o)(e(l).summaryLabel)),1),a("span",null,n(e(o)(e(l).summaryDescription)),1)]),a("div",J,[x(a("textarea",{id:"additional-information","onUpdate:modelValue":t[2]||(t[2]=c=>h(r)?r.value=c:null),maxlength:"256",placeholder:e(o)(e(l).summaryPlaceholder),disabled:e(s)},null,8,K),[[b,e(r)]])])]),a("p",Q,n(e(o)(e(l).collectionInfo,{count:g.projectIds.length})),1),a("div",W,[u(e(y),{class:"w-24"},{default:p(()=>[a("button",{onClick:t[3]||(t[3]=c=>e(m).hide())},[u(e(B),{"aria-hidden":"true"}),_(" "+n(e(o)(e(l).cancel)),1)])]),_:1}),u(e(y),{color:"brand",class:"w-36"},{default:p(()=>[a("button",{disabled:e(s),onClick:N},[u(e(D),{"aria-hidden":"true"}),_(" "+n(e(o)(e(l).createCollection)),1)],8,ee)]),_:1})])])]),_:1},8,["header"]))}},ce=j(te,[["__scopeId","data-v-b60483df"]]);export{ce as C};