import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{O as t,k as n}from"./vendor-markdown-DngssFHR.js";import{c as r,l as i,u as a}from"./vendor-react-Cts2Wj-s.js";import{Q as o,X as s,rt as c}from"./vendor-mui-Ckcy4Lfd.js";import"./vendor-md-editor-DC6xr_29.js";import{p as l,v as u}from"./ui-BLXHSX1T.js";import{T as d,V as f,u as p}from"./index-JB73_g7R.js";import{i as m}from"./api-C88VCaJt.js";import{t as h}from"./attachments-BKCJWgDD.js";import{t as g}from"./TaskForm-5yPQ1uSc.js";var _=e(n(),1),v=t();function y(){let{projectId:e}=i(),t=r(),n=f(`tasks`),[y]=a(),[b,x]=(0,_.useState)([]),S={title:y.get(`title`)||void 0,status:y.get(`status`)||void 0,priority:y.get(`priority`)||void 0,assignee:y.get(`assignee`)||void 0,tags:y.get(`tags`)?.split(`,`).filter(Boolean)||void 0},C=y.get(`epicId`)||void 0;return(0,v.jsxs)(o,{children:[(0,v.jsx)(l,{breadcrumbs:[{label:`Tasks`,to:`/${e}/tasks`},{label:`Create`}],actions:(0,v.jsx)(s,{variant:`contained`,form:`task-form`,type:`submit`,disabled:!n,children:`Create`})}),!n&&(0,v.jsx)(c,{severity:`warning`,sx:{mb:2},children:`Read-only access — you cannot create tasks.`}),(0,v.jsx)(g,{defaults:S,onSubmit:async n=>{if(!e)return;let r=await p(e,n);C&&await m(e,C,r.id).catch(()=>{});for(let t of b)await d(e,r.id,t).catch(()=>{});t(`/${e}/tasks/${r.id}`)},onCancel:()=>t(`/${e}/tasks`),submitLabel:`Create`}),(0,v.jsx)(u,{title:`Attachments`,sx:{mt:3},children:(0,v.jsx)(h,{files:b,onAdd:e=>x(t=>[...t,...e]),onRemove:e=>x(t=>t.filter((t,n)=>n!==e))})})]})}export{y as default};