import{a as N,b as g,r as x,v as Q,j as e,c as m,N as O,E as M,Q as E}from"./index-CUDottTv.js";import{B as U}from"./badge-BOfEUuSW.js";import{S as V,B as R}from"./textarea-DAwdLdON.js";import{F as D}from"./folder-open-D-HQTMMw.js";import{D as q}from"./download-CwvkYJyJ.js";import{F as T}from"./file-text-h8kcLd2l.js";import{C as G}from"./circle-check-big-Dd6W5_do.js";import{E as I}from"./project-view-DnnhNMhS.js";import{T as K}from"./trash-2-C4Tvwfqn.js";import"./status-dot-C1nxHZIG.js";import"./tag-Czqgl1tA.js";import"./square-C1plLKPb.js";import"./play-Cx2BEZVZ.js";/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const $=N("CircleArrowRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const H=N("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Y=N("Kanban",[["path",{d:"M6 5v11",key:"mdvv1e"}],["path",{d:"M12 5v6",key:"14ar3b"}],["path",{d:"M18 5v14",key:"7ji314"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const B=N("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const L=N("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]),F=[{status:"todo",label:"Todo",dotColor:"bg-text-muted"},{status:"in_progress",label:"In Progress",dotColor:"bg-blue"},{status:"done",label:"Done",dotColor:"bg-green"}],J={low:"default",medium:"blue",high:"amber",urgent:"red"},W={claude_session:{icon:L,label:"Claude",variant:"purple"},github_issue:{icon:T,label:"GitHub",variant:"default"},file:{icon:T,label:"File",variant:"accent"}};function X({task:a,onDragStart:p,onDelete:l}){const o=W[a.source];return e.jsxs("div",{draggable:!0,onDragStart:d=>p(d,a.id),className:"bg-bg-surface border border-border-strong rounded-md p-2.5 cursor-grab active:cursor-grabbing transition-all hover:border-border-hover hover:bg-bg-elevated group",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[e.jsx(H,{size:12,className:"shrink-0 text-text-disabled opacity-0 group-hover:opacity-100 transition-opacity"}),e.jsx("span",{className:"text-[13px] font-medium text-text-primary leading-snug",children:a.title})]}),e.jsx("button",{type:"button",onClick:d=>{d.stopPropagation(),l(a.id)},className:"shrink-0 p-1 rounded text-text-disabled opacity-0 group-hover:opacity-100 hover:text-red hover:bg-red-muted transition-all cursor-pointer",children:e.jsx(K,{size:11})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx(U,{variant:J[a.priority],size:"sm",children:a.priority}),a.labels.map(d=>e.jsx("span",{className:"text-[9px] font-medium px-1.5 py-px rounded bg-bg-overlay text-text-muted",children:d},d)),o&&e.jsxs("span",{className:m("text-[9px] font-medium px-1.5 py-px rounded inline-flex items-center gap-1",a.source==="claude_session"?"bg-purple-muted text-purple":"bg-bg-overlay text-text-tertiary"),children:[e.jsx(o.icon,{size:9}),o.label]})]})]})}function P({status:a,label:p,dotColor:l,tasks:o,isDropTarget:d,onDragOver:u,onDragLeave:s,onDrop:b,onDragStart:i,onDelete:c,onQuickAdd:w}){const[j,y]=x.useState(""),C=()=>{const n=j.trim();n&&(w(n),y(""))};return e.jsxs("div",{onDragOver:u,onDragLeave:s,onDrop:b,className:m("flex-1 min-w-[280px] bg-bg-app border rounded-lg flex flex-col",d?"border-accent border-dashed":"border-border-default"),children:[e.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-3 border-b border-border-muted shrink-0",children:[e.jsx("span",{className:m("w-2 h-2 rounded-full shrink-0",l)}),e.jsx("span",{className:"text-[12px] font-semibold text-text-secondary flex-1",children:p}),e.jsx("span",{className:"text-[10px] font-semibold text-text-muted bg-bg-overlay px-1.5 py-px rounded-full",children:o.length})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2 flex flex-col gap-1.5",children:o.map(n=>e.jsx(X,{task:n,onDragStart:i,onDelete:c},n.id))}),e.jsx("div",{className:"p-2 shrink-0",children:e.jsx("input",{type:"text",value:j,onChange:n=>y(n.target.value),onKeyDown:n=>n.key==="Enter"&&C(),placeholder:"+ Add task...",className:"w-full h-8 px-2.5 bg-bg-surface border border-dashed border-border-strong rounded-md text-[12px] text-text-primary placeholder:text-text-disabled outline-none focus:border-accent-border focus:border-solid transition-colors"})})]})}const v={todo:{cls:"bg-bg-overlay text-text-tertiary",label:"Todo"},in_progress:{cls:"bg-blue-muted text-blue",label:"In Progress"},done:{cls:"bg-green-muted text-green",label:"Done"},backlog:{cls:"bg-bg-overlay text-text-muted",label:"Backlog"}};function Z({projectId:a}){var d,u;const[p]=x.useState([]),[l,o]=x.useState(null);return p.length===0?e.jsxs("div",{className:"flex-1 border border-border-strong rounded-lg overflow-hidden bg-bg-surface flex",children:[e.jsxs("div",{className:"w-[280px] shrink-0 bg-bg-app border-r border-border-muted flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-3.5 py-3 border-b border-border-muted shrink-0",children:[e.jsx("span",{className:"text-[12px] font-semibold text-text-secondary",children:"Project Files"}),e.jsx(O,{size:13,className:"text-text-muted"})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(T,{size:24,className:"text-text-disabled mx-auto mb-2"}),e.jsx("p",{className:"text-[12px] text-text-muted mb-1",children:"No task files found"}),e.jsxs("p",{className:"text-[10px] text-text-disabled",children:["Create files in ",e.jsx("code",{className:"px-1 py-0.5 bg-bg-overlay rounded text-[10px]",children:".claude/tasks/"})," or ",e.jsx("code",{className:"px-1 py-0.5 bg-bg-overlay rounded text-[10px]",children:".claude/features/"})]})]})}),e.jsxs("div",{className:"p-3 border-t border-border-muted bg-bg-app shrink-0",children:[e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{type:"text",placeholder:"Quick idea or task...",className:"flex-1 h-[34px] px-2.5 bg-bg-input border border-border-strong rounded-md text-[12px] text-text-primary placeholder:text-text-muted outline-none focus:border-accent-border"}),e.jsx(R,{variant:"primary",size:"sm",className:"shrink-0 h-[34px] px-2.5",children:e.jsx(L,{size:12})})]}),e.jsx("p",{className:"text-[10px] text-text-disabled mt-1.5 leading-relaxed",children:"Type a rough idea — Claude will create a structured .md file"})]})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(M,{icon:e.jsx(D,{size:28}),title:"Select a file",description:"Choose a task or feature file from the sidebar to preview its contents."})})]}):e.jsxs("div",{className:"flex-1 border border-border-strong rounded-lg overflow-hidden bg-bg-surface flex",children:[e.jsxs("div",{className:"w-[280px] shrink-0 bg-bg-app border-r border-border-muted flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-3.5 py-3 border-b border-border-muted shrink-0",children:[e.jsx("span",{className:"text-[12px] font-semibold text-text-secondary",children:"Project Files"}),e.jsx(O,{size:13,className:"text-text-muted"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[10px] font-semibold text-text-muted uppercase tracking-wider",children:[e.jsx(E,{size:11})," Tasks"]}),p.filter(s=>s.type==="task").map(s=>{var b,i;return e.jsxs("button",{onClick:()=>o(s),className:m("w-full flex items-start gap-2.5 px-2.5 py-2 rounded-md text-left transition-colors cursor-pointer border border-transparent",(l==null?void 0:l.path)===s.path?"bg-accent-muted border-accent-border":"hover:bg-bg-hover"),children:[e.jsx("div",{className:"w-8 h-8 rounded-md bg-blue-muted flex items-center justify-center shrink-0",children:e.jsx(E,{size:14,className:"text-blue"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-text-primary truncate",children:s.name}),e.jsxs("div",{className:"text-[10px] text-text-muted mt-0.5",children:[s.effort," · ",s.created]})]}),e.jsx("span",{className:m("text-[10px] font-semibold px-1.5 py-px rounded shrink-0",((b=v[s.status])==null?void 0:b.cls)||"bg-bg-overlay text-text-muted"),children:((i=v[s.status])==null?void 0:i.label)||s.status})]},s.path)}),e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 mt-2 text-[10px] font-semibold text-text-muted uppercase tracking-wider",children:[e.jsx(B,{size:11})," Features"]}),p.filter(s=>s.type==="feature").map(s=>{var b,i;return e.jsxs("button",{onClick:()=>o(s),className:m("w-full flex items-start gap-2.5 px-2.5 py-2 rounded-md text-left transition-colors cursor-pointer border border-transparent",(l==null?void 0:l.path)===s.path?"bg-accent-muted border-accent-border":"hover:bg-bg-hover"),children:[e.jsx("div",{className:"w-8 h-8 rounded-md bg-amber-muted flex items-center justify-center shrink-0",children:e.jsx(B,{size:14,className:"text-amber"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-text-primary truncate",children:s.name}),e.jsxs("div",{className:"text-[10px] text-text-muted mt-0.5",children:[s.effort," · ",s.created]})]}),e.jsx("span",{className:m("text-[10px] font-semibold px-1.5 py-px rounded shrink-0",((b=v[s.status])==null?void 0:b.cls)||"bg-bg-overlay text-text-muted"),children:((i=v[s.status])==null?void 0:i.label)||s.status})]},s.path)})]}),e.jsxs("div",{className:"p-3 border-t border-border-muted bg-bg-app shrink-0",children:[e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{type:"text",placeholder:"Quick idea or task...",className:"flex-1 h-[34px] px-2.5 bg-bg-input border border-border-strong rounded-md text-[12px] text-text-primary placeholder:text-text-muted outline-none focus:border-accent-border"}),e.jsx(R,{variant:"primary",size:"sm",className:"shrink-0 h-[34px] px-2.5",children:e.jsx(L,{size:12})})]}),e.jsx("p",{className:"text-[10px] text-text-disabled mt-1.5 leading-relaxed",children:"Type a rough idea — Claude will create a structured .md file"})]})]}),e.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5 border-b border-border-muted shrink-0",children:[e.jsx(T,{size:16,className:"text-text-muted"}),e.jsx("span",{className:"text-[14px] font-semibold text-text-primary flex-1",children:l.name}),e.jsxs("span",{className:m("text-[11px] font-medium px-2 py-0.5 rounded-full inline-flex items-center gap-1",(d=v[l.status])==null?void 0:d.cls),children:[e.jsx(G,{size:11}),((u=v[l.status])==null?void 0:u.label)||l.status]}),e.jsxs("button",{className:"text-[11px] font-medium text-text-tertiary bg-bg-elevated border border-border-default rounded-md px-2 py-1 inline-flex items-center gap-1 hover:border-border-hover hover:text-text-primary transition-colors cursor-pointer",children:[e.jsx(I,{size:11})," Open"]}),e.jsxs("button",{className:"text-[11px] font-medium text-text-tertiary bg-bg-elevated border border-border-default rounded-md px-2 py-1 inline-flex items-center gap-1 hover:border-border-hover hover:text-text-primary transition-colors cursor-pointer",children:[e.jsx($,{size:11})," Add to Board"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:e.jsxs("p",{className:"text-[13px] text-text-tertiary",children:["File preview will render markdown content from ",l.path]})})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(M,{icon:e.jsx(D,{size:28}),title:"Select a file",description:"Choose a task or feature file to preview."})})})]})}function me({projectId:a}){const p=g(t=>t.tasks),l=g(t=>t.tasksLoading),[o,d]=x.useState("board"),[u,s]=x.useState(""),[b,i]=x.useState(null);x.useEffect(()=>{g.getState().fetchTasks(a)},[a]);const c=x.useMemo(()=>p.filter(t=>t.projectId===a),[p,a]),w=x.useMemo(()=>{if(!u.trim())return c;const t=u.trim().toLowerCase();return c.filter(r=>r.title.toLowerCase().includes(t)||r.labels.some(h=>h.toLowerCase().includes(t)))},[c,u]),j=x.useCallback(t=>w.filter(r=>r.status===t).sort((r,h)=>r.sortOrder-h.sortOrder),[w]),y=(t,r)=>{t.dataTransfer.setData("text/plain",r),t.dataTransfer.effectAllowed="move"},C=async(t,r)=>{t.preventDefault(),i(null);const h=t.dataTransfer.getData("text/plain");if(!h)return;const k=j(r),S=k.length===0?0:k[k.length-1].sortOrder+1e3;await g.getState().reorderTask(h,r,S)},n=async t=>{await g.getState().deleteTask(t)},A=async(t,r="todo")=>{await g.getState().createTask({title:t,projectId:a,status:r,priority:"medium"})},_=x.useCallback(()=>{if(c.length===0)return;const t=["Title","Status","Priority","Labels","Created"],r=c.map(f=>[`"${f.title.replace(/"/g,'""')}"`,f.status,f.priority,`"${f.labels.join(", ")}"`,new Date(f.createdAt).toISOString()]),h=[t.join(","),...r.map(f=>f.join(","))].join(`
`),k=new Blob([h],{type:"text/csv"}),S=URL.createObjectURL(k),z=document.createElement("a");z.href=S,z.download=`tasks-${a}.csv`,z.click(),URL.revokeObjectURL(S),Q.track("export_csv",{projectId:a,taskCount:c.length})},[c,a]);return e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-border-default shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-0.5 bg-bg-surface border border-border-default rounded-md p-0.5",children:[e.jsxs("button",{onClick:()=>d("board"),className:m("h-[26px] px-2.5 rounded text-[12px] font-medium flex items-center gap-1.5 transition-colors cursor-pointer",o==="board"?"bg-bg-overlay text-text-primary":"text-text-muted hover:text-text-secondary"),children:[e.jsx(Y,{size:14})," Board"]}),e.jsxs("button",{onClick:()=>d("files"),className:m("h-[26px] px-2.5 rounded text-[12px] font-medium flex items-center gap-1.5 transition-colors cursor-pointer",o==="files"?"bg-bg-overlay text-text-primary":"text-text-muted hover:text-text-secondary"),children:[e.jsx(D,{size:14})," Files"]})]}),o==="board"&&e.jsx("div",{className:"w-56",children:e.jsx(V,{value:u,onChange:t=>s(t.target.value),placeholder:"Search tasks..."})}),e.jsx("div",{className:"flex items-center gap-2 ml-auto",children:c.length>0&&e.jsxs("button",{onClick:_,className:"h-[34px] px-3 text-[12px] font-medium text-text-tertiary bg-bg-surface border border-border-default rounded-md inline-flex items-center gap-1.5 hover:border-border-hover hover:text-text-primary transition-colors cursor-pointer",children:[e.jsx(q,{size:13})," Export CSV"]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-h-0 p-5",children:o==="board"?!l&&c.length===0?e.jsx("div",{className:"flex-1 flex flex-col",children:e.jsx("div",{className:"flex-1 flex gap-4",children:F.map(t=>e.jsx(P,{status:t.status,label:t.label,dotColor:t.dotColor,tasks:[],isDropTarget:!1,onDragOver:r=>{r.preventDefault(),i(t.status)},onDragLeave:()=>i(null),onDrop:r=>C(r,t.status),onDragStart:y,onDelete:n,onQuickAdd:r=>A(r,t.status)},t.status))})}):e.jsx("div",{className:"flex-1 flex gap-4",children:F.map(t=>e.jsx(P,{status:t.status,label:t.label,dotColor:t.dotColor,tasks:j(t.status),isDropTarget:b===t.status,onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move",i(t.status)},onDragLeave:()=>i(null),onDrop:r=>C(r,t.status),onDragStart:y,onDelete:n,onQuickAdd:r=>A(r,t.status)},t.status))}):e.jsx(Z,{projectId:a})})]})}export{me as TasksPage};
