import{u as j,b1 as D,p as o,j as n,M,Q as O,cy as v,e as c,T as S,d1 as y,d2 as f,F as g,r as k,ak as B}from"./bundle.CHKSNOJF.js";import{u as Q,a as w}from"./designs-64NZ6YEW.js";function E(s){const[a]=j(),{isAdmin:p,isOwner:C}=D(),x=w(),{actionVisibility:b=!0}=s,[m,r]=o.useState(!1),[u,i]=o.useState(null),[t,h]=o.useState(null),{data:d}=Q({enabled:m});o.useEffect(()=>{d&&i(d)},[d]);const P=()=>{u&&(g.processing(),h(null),k("POST",c("/api/v1/designs"),u).then(()=>{g.success("created_design"),B(["designs"]),i(null),r(!1)}).catch(e=>{e.response?.status===422&&(h(e.response.data),g.dismiss())}))};return n.jsxs(n.Fragment,{children:[n.jsxs(M,{title:a("new_design"),visible:m,onClose:r,overflowVisible:!0,children:[n.jsx(O,{label:a("name"),onValueChange:e=>i(l=>l&&{...l,name:e}),errorMessage:t?.errors.name}),n.jsx(v,{endpoint:c("/api/v1/designs?per_page=500&status=active"),onChange:e=>i(l=>e.resource&&{...e.resource,name:l?.name||""}),inputOptions:{label:s.inputLabel?.toString(),value:u?.id||null},entryOptions:{id:"id",label:"name",value:"id"},action:{label:a("new_design"),onClick:()=>r(!0),visible:b},sortBy:"name|asc",onDismiss:()=>i(null),disableWithQueryParameter:s.disableWithQueryParameter,errorMessage:t?.errors["design.header"]||t?.errors["design.body"]||t?.errors["design.footer"]||t?.errors["design.includes"]}),n.jsx(S,{onClick:P,children:a("save")})]}),n.jsx(v,{endpoint:c("/api/v1/designs?status=active"),onChange:e=>e.resource&&s.onChange(e.resource),inputOptions:{label:s.inputLabel?.toString(),value:s.value||null},entryOptions:{id:"id",label:"name",value:"id"},action:{label:a("new_design"),onClick:()=>r(!0),visible:b&&(p||C)&&(y()||f())},sortBy:"name|asc",onDismiss:s.onClearButtonClick,disableWithQueryParameter:s.disableWithQueryParameter,errorMessage:s.errorMessage,...!y()&&!f()&&{includeOnly:x,includeByLabel:!0}})]})}export{E as D};
