@libxai/board 0.14.3 → 0.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -273,7 +273,7 @@
273
273
  </Calendars>
274
274
  <Tasks>${l}
275
275
  </Tasks>
276
- </Project>`,u=new Blob([s],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(u),d.download=r,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=K.flattenTasks(e),r=t.filter(s=>s.startDate&&s.endDate);if(r.length===0)return [];let a=new Map,n=s=>{if(a.has(s.id))return;let u=s.startDate&&s.endDate?K.calculateDuration(s.startDate,s.endDate):0,d=0;if(s.dependencies&&s.dependencies.length>0)for(let m of s.dependencies){let x=t.find(b=>b.id===m);if(x){n(x);let b=a.get(m)?.ef||0;d=Math.max(d,b);}}let p=d+u;a.set(s.id,{es:d,ef:p});};r.forEach(n);let o=Math.max(...Array.from(a.values()).map(s=>s.ef)),i=new Map,c=s=>{if(i.has(s.id))return;let u=s.startDate&&s.endDate?K.calculateDuration(s.startDate,s.endDate):0,d=t.filter(x=>x.dependencies&&x.dependencies.includes(s.id)),p=o;if(d.length>0)for(let x of d){c(x);let b=i.get(x.id)?.ls||0;p=Math.min(p,b);}let m=p-u;i.set(s.id,{ls:m,lf:p});};r.forEach(c);let l=[];for(let s of r){let u=a.get(s.id),d=i.get(s.id);if(u&&d){let p=d.ls-u.es;Math.abs(p)<.01&&l.push(s.id);}}return l},calculateSlack:(e,t)=>{let r=K.findTaskById(e,t);if(!r||!r.startDate||!r.endDate)return null;if(K.calculateCriticalPath(e).includes(t))return 0;let n=K.getDependentTasks(e,t);if(n.length===0){let c=K.getLatestEndDate(e);if(!c)return null;let l=K.calculateDuration(r.endDate,c);return Math.max(0,l)}let o=n.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,l)=>c-l)[0];if(!o)return null;let i=K.calculateDuration(r.endDate,new Date(o));return Math.max(0,i)},isOnCriticalPath:(e,t)=>K.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,r)=>{let a=K.findTaskById(e,t);if(!a||!a.endDate)return e;let n=K.getDependentTasks(e,t);if(n.length===0)return e;let o=[...e];for(let i of n){if(!i.startDate||!i.endDate)continue;let c=K.calculateDuration(i.startDate,i.endDate),l;r!==void 0?(l=new Date(i.startDate),l.setDate(l.getDate()+r)):(l=new Date(a.endDate),l.setDate(l.getDate()+1));let s=K.calculateEndDate(l,c),u=d=>d.map(p=>p.id===i.id?{...p,startDate:l,endDate:s}:p.subtasks?{...p,subtasks:u(p.subtasks)}:p);o=u(o),o=K.autoScheduleDependents(o,i.id,r);}return o},calculateCascadePreview:(e,t,r,a,n,o,i,c)=>{if(r===0)return [];let l=[],s=n.getTime(),u=1e3*60*60*24,d=K.findTaskById(e,t);if(!d||!d.endDate)return [];let p=(m,x,b=new Set)=>{if(b.has(m))return;b.add(m);let v=K.getDependentTasks(e,m);for(let g of v){if(!g.startDate||!g.endDate)continue;let h=a.findIndex(_=>_.id===g.id);if(h===-1)continue;let f=g.startDate.getTime(),k=(g.endDate.getTime()-f)/u,C=(f-s)/u*o,T=C+x*o,D=Math.max(k*o,o),R=c+h*i+12;l.push({taskId:g.id,taskName:g.name,originalX:C,previewX:T,width:D,y:R,rowIndex:h,daysDelta:x,color:g.color}),p(g.id,x,b);}};return p(t,r),l},splitTask:(e,t,r,a=3)=>{let n=K.findTaskById(e,t);if(!n||!n.startDate||!n.endDate)return e;if(r<=n.startDate||r>=n.endDate)return console.warn("Split date must be between task start and end dates"),e;let o=new Date(r);o.setDate(o.getDate()-1);let i=new Date(r);i.setDate(i.getDate()+a);let c=new Date(n.endDate);c.setDate(c.getDate()+a);let l=[{startDate:new Date(n.startDate),endDate:o},{startDate:i,endDate:c}],s=u=>u.map(d=>d.id===n.id?{...d,endDate:c,segments:l}:d.subtasks?{...d,subtasks:s(d.subtasks)}:d);return s(e)}};function On({tasks:e,theme:t,rowHeight:r,timeScale:a,startDate:n,endDate:o,zoom:i,templates:c,onTaskClick:l,onTaskDblClick:s,onTaskContextMenu:u,onTaskDateChange:d,onDependencyCreate:p,onDependencyDelete:m}){let[b,v]=we.useState([]),g=Math.ceil((o.getTime()-n.getTime())/(1e3*60*60*24)),h=a==="day"?60:a==="week"?20:8,f=g*h*i,w=E=>{let B=new Date(Date.UTC(E.getFullYear(),E.getMonth(),E.getDate())),z=B.getUTCDay()||7;B.setUTCDate(B.getUTCDate()+4-z);let $=new Date(Date.UTC(B.getUTCFullYear(),0,1));return Math.ceil(((B.getTime()-$.getTime())/864e5+1)/7)},k=E=>{let B=E.getDay();return B===0||B===6},y=we.useCallback(E=>{let B=Math.round(E/(h*i)),z=new Date(n);return z.setDate(z.getDate()+B),z},[n,h,i]),C=we.useCallback((E,B)=>{if(B.startDate&&B.endDate)return;let z=E.currentTarget.ownerSVGElement;if(!z)return;let $=z.createSVGPoint();$.x=E.clientX,$.y=E.clientY;let A=$.matrixTransform(z.getScreenCTM()?.inverse()),te=y(A.x),X=new Date(te);X.setDate(X.getDate()+1),d?.(B,te,X);},[y,d]),T=we.useMemo(()=>{let E=A=>A.map(te=>{if(te.subtasks&&te.subtasks.length>0){let X=E(te.subtasks),fe=X.filter(P=>P.startDate&&P.endDate);if(fe.length>0){let P=fe.map(ct=>ct.startDate.getTime()),ge=fe.map(ct=>ct.endDate.getTime()),ae=new Date(Math.min(...P)),pt=new Date(Math.max(...ge));return {...te,subtasks:X,startDate:ae,endDate:pt}}return {...te,subtasks:X}}return te}),B=(A,te=[])=>{for(let X of A)te.push(X),X.subtasks&&X.subtasks.length>0&&(X.isExpanded===void 0||X.isExpanded)&&B(X.subtasks,te);return te},z=E(e);return B(z)},[e]),D=we.useCallback(E=>{if(!E.startDate||!E.endDate)return {x:0,width:0};let B=E.startDate.getTime(),z=E.endDate.getTime(),$=n.getTime(),A=(B-$)/(1e3*60*60*24),te=(z-B)/(1e3*60*60*24),X=A*h*i,fe=Math.max(h*i,40),P=Math.max(te*h*i,fe);return {x:X,width:P}},[n,h,i]),R=we.useMemo(()=>T.filter(E=>E.startDate&&E.endDate).map(E=>{let{x:B,width:z}=D(E),A=T.findIndex(te=>te.id===E.id)*r+12;return {id:E.id,x:B,y:A,width:z,height:32}}),[T,D]),_=we.useCallback((E,B,z)=>{if(!z||B===0){v([]);return}let $=K.calculateCascadePreview(e,E,B,T,n,h*i,r,48);v($);},[e,T,n,h,i,r,48]),G=we.useMemo(()=>{let E=[],B=new Date(n);for(;B<=o;){let A=(B.getTime()-n.getTime())/864e5*h*i;if(a==="day")E.push({date:new Date(B),label:B.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:A}),B.setDate(B.getDate()+1);else if(a==="week"){let te=w(B);E.push({date:new Date(B),label:`Week ${te}`,x:A}),B.setDate(B.getDate()+7);}else E.push({date:new Date(B),label:B.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:A}),B.setMonth(B.getMonth()+1);}return E},[n,o,a,h,i]),M=we.useMemo(()=>(new Date().getTime()-n.getTime())/(1e3*60*60*24)*h*i,[n,h,i]),O=Math.max(T.length*r,552);return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary},children:[jsxRuntime.jsx("div",{style:{position:"sticky",top:0,zIndex:10,backgroundColor:t.bgGrid,flexShrink:0,borderBottom:`1px solid ${t.border}`},children:jsxRuntime.jsxs("svg",{width:Math.max(f,1e3),height:48,style:{display:"block"},children:[jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(f,1e3),height:48,fill:t.bgGrid}),G.map((E,B)=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:E.x,y1:0,x2:E.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsxRuntime.jsx("text",{x:E.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:E.label})]},`header-${B}`)),M>=0&&M<=f&&jsxRuntime.jsx("circle",{cx:M,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(f,1e3),height:O,style:{display:"block",flexShrink:0},children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsx("filter",{id:"shadow",children:jsxRuntime.jsx("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2",floodOpacity:"0.1"})}),jsxRuntime.jsx("pattern",{id:"diagonal-stripes",width:"8",height:"8",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:jsxRuntime.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"8",stroke:t.border,strokeWidth:"2"})})]}),jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(f,1e3),height:O,fill:t.bgPrimary}),G.map((E,B)=>{let z=G[B+1]?.x||f,$=k(E.date);return jsxRuntime.jsxs("g",{children:[$&&jsxRuntime.jsx("rect",{x:E.x,y:0,width:z-E.x,height:T.length*r,fill:t.bgWeekend,opacity:1}),jsxRuntime.jsx("line",{x1:E.x,y1:0,x2:E.x,y2:T.length*r,stroke:t.border,strokeWidth:1,opacity:.1})]},B)}),M>=0&&M<=f&&jsxRuntime.jsx("line",{x1:M,y1:0,x2:M,y2:T.length*r,stroke:t.today,strokeWidth:2,opacity:1}),T.map((E,B)=>{let z=E.startDate&&E.endDate;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:0,y:B*r,width:f,height:r,fill:B%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${E.id}`),!z&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:0,y:B*r,width:f,height:r,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:$=>C($,E),onMouseEnter:$=>{$.currentTarget.setAttribute("fill",t.accentLight),$.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:$=>{$.currentTarget.setAttribute("fill","transparent"),$.currentTarget.setAttribute("opacity","1");}},`clickable-${E.id}`),jsxRuntime.jsx("text",{x:M>0?M:100,y:B*r+r/2,fill:t.textTertiary,fontSize:"12",fontFamily:"Inter, sans-serif",fontStyle:"italic",dominantBaseline:"middle",opacity:.4,style:{pointerEvents:"none",userSelect:"none"},children:"Click to set dates..."},`placeholder-${E.id}`)]})]},`row-group-${E.id}`)}),T.map((E,B)=>!E.dependencies||E.dependencies.length===0||!E.startDate||!E.endDate?null:E.dependencies.map(z=>{let $=T.find(fe=>fe.id===z);if(!$||!$.startDate||!$.endDate)return null;let A=T.findIndex(fe=>fe.id===z),te=D($),X=D(E);return jsxRuntime.jsx(Mn,{x1:te.x+te.width,y1:A*r+r/2,x2:X.x,y2:B*r+r/2,theme:t,onDelete:()=>m?.(E.id,z)},`dep-${z}-${E.id}`)})),T.map((E,B)=>{if(!E.startDate||!E.endDate)return null;let{x:z,width:$}=D(E),A=B*r+12,te=E.subtasks&&E.subtasks.length>0&&!E.isMilestone;return E.isMilestone?jsxRuntime.jsx(Ln,{task:E,x:z+$/2,y:A+16,theme:t,onClick:l},E.id):te?jsxRuntime.jsxs("g",{onClick:()=>l?.(E),style:{cursor:"pointer"},children:[jsxRuntime.jsx("rect",{x:z,y:A,width:$,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:z,y1:A,x2:z+$,y2:A,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:z,y1:A,x2:z,y2:A+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:z+$,y1:A,x2:z+$,y2:A+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:z,y1:A+32,x2:z+$,y2:A+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),$>60&&jsxRuntime.jsx("text",{x:z+12,y:A+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:E.name})]},E.id):jsxRuntime.jsx(Pn,{task:E,x:z,y:A,width:$,theme:t,dayWidth:h*i,startDate:n,templates:c,onClick:l,onDoubleClick:s,onContextMenu:u,onDateChange:d,onDependencyCreate:p,allTaskPositions:R,onDragMove:_},E.id)}),b.map(E=>jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("rect",{x:E.previewX,y:E.y-48,width:E.width,height:32,rx:8,fill:E.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(E.daysDelta)>0&&jsxRuntime.jsx("text",{x:E.previewX+E.width/2,y:E.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:E.daysDelta>0?`+${E.daysDelta}d`:`${E.daysDelta}d`})]},`cascade-preview-${E.taskId}`))]})]})}var Yl=[{name:"Azul",value:"#6366F1",light:"#818CF8"},{name:"P\xFArpura",value:"#A855F7",light:"#C084FC"},{name:"Rosa",value:"#EC4899",light:"#F472B6"},{name:"Rojo",value:"#EF4444",light:"#F87171"},{name:"Naranja",value:"#F59E0B",light:"#FBBF24"},{name:"Amarillo",value:"#EAB308",light:"#FACC15"},{name:"Lima",value:"#84CC16",light:"#A3E635"},{name:"Verde",value:"#10B981",light:"#34D399"},{name:"Esmeralda",value:"#059669",light:"#10B981"},{name:"Cyan",value:"#06B6D4",light:"#22D3EE"},{name:"Azul Cielo",value:"#0EA5E9",light:"#38BDF8"},{name:"\xCDndigo",value:"#4F46E5",light:"#6366F1"},{name:"Violeta",value:"#8B5CF6",light:"#A78BFA"},{name:"Fucsia",value:"#D946EF",light:"#E879F9"},{name:"Gris",value:"#6B7280",light:"#9CA3AF"},{name:"Piedra",value:"#78716C",light:"#A8A29E"}];function ql({value:e="#6366F1",onChange:t,disabled:r=false}){return jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:Yl.map(a=>{let n=e===a.value;return jsxRuntime.jsx(framerMotion.motion.button,{type:"button",onClick:()=>!r&&t(a.value),className:"relative rounded-full transition-all focus:outline-none focus:ring-2 focus:ring-offset-2",style:{width:"32px",height:"32px",backgroundColor:a.value,boxShadow:n?`0 0 0 2px #FFFFFF, 0 0 0 4px ${a.value}`:"0 1px 3px rgba(0, 0, 0, 0.12)",opacity:r?.5:1,cursor:r?"not-allowed":"pointer"},whileHover:r?{}:{scale:1.1},whileTap:r?{}:{scale:.95},title:a.name,disabled:r,children:n&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{scale:0},animate:{scale:1},className:"absolute inset-0 flex items-center justify-center",children:jsxRuntime.jsx(lucideReact.Check,{className:"w-4 h-4 text-white drop-shadow-md",strokeWidth:3})})},a.value)})}),e&&jsxRuntime.jsx("div",{className:"text-xs text-center font-medium",style:{color:e},children:Yl.find(a=>a.value===e)?.name||"Personalizado"})]})}function zn({isOpen:e,onClose:t,task:r,availableTasks:a=[],availableUsers:n=[],onSubmit:o,isLoading:i=false,mode:c=r?"edit":"create",theme:l="dark"}){let s=ke[l]||ke.dark,u={backgroundColor:s.bgSecondary,border:`1px solid ${s.borderLight}`,color:s.textPrimary},d={color:s.textSecondary},[p,m]=we.useState({name:"",progress:0,status:"todo",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),[x,b]=we.useState({});we.useEffect(()=>{m(r?{name:r.name,startDate:r.startDate,endDate:r.endDate,progress:r.progress,status:r.status||"todo",isMilestone:r.isMilestone||false,color:r.color||"#6366F1",assignees:r.assignees||[],dependencies:r.dependencies||[]}:{name:"",progress:0,status:"todo",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]});},[r,e]);let v=()=>{let f={};return p.name.trim()||(f.name="El nombre es requerido"),p.startDate&&p.endDate&&p.startDate>p.endDate&&(f.endDate="La fecha de fin debe ser posterior a la de inicio"),b(f),Object.keys(f).length===0},g=async f=>{if(f.preventDefault(),!!v())try{await o(p),t();}catch(w){console.error("Error submitting task:",w);}},h=(f,w)=>{m(k=>{let y={...k,[f]:w};if(f==="progress"){let C=typeof w=="number"?w:parseInt(w,10);C===100&&k.status!=="completed"?y.status="completed":C>0&&C<100&&k.status==="todo"?y.status="in-progress":C===0&&k.status==="in-progress"&&(y.status="todo");}return y}),x[f]&&b(k=>{let y={...k};return delete y[f],y});};return jsxRuntime.jsx(framerMotion.AnimatePresence,{children:e&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 z-50",onClick:t}),jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.2,ease:[.4,0,.2,1]},className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:jsxRuntime.jsxs("div",{className:"w-full max-w-2xl rounded-xl shadow-2xl pointer-events-auto overflow-hidden",style:{backgroundColor:s.bgPrimary,border:`1px solid ${s.border}`},onClick:f=>f.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderBottom:`1px solid ${s.border}`},children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold",style:{color:s.textPrimary},children:c==="create"?"Crear Nueva Tarea":"Editar Tarea"}),jsxRuntime.jsx("button",{onClick:t,className:"p-2 rounded-lg transition-colors",style:{color:s.textSecondary},onMouseEnter:f=>f.currentTarget.style.backgroundColor=s.hoverBg,onMouseLeave:f=>f.currentTarget.style.backgroundColor="transparent",disabled:i,children:jsxRuntime.jsx(lucideReact.X,{className:"w-5 h-5"})})]}),jsxRuntime.jsxs("form",{onSubmit:g,className:"p-6 space-y-6 max-h-[calc(100vh-200px)] overflow-y-auto",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-sm font-medium mb-2",style:d,children:"Nombre de la Tarea *"}),jsxRuntime.jsx("input",{type:"text",value:p.name,onChange:f=>h("name",f.target.value),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:u,onFocus:f=>f.currentTarget.style.borderColor=s.accent,onBlur:f=>f.currentTarget.style.borderColor=s.borderLight,placeholder:"Ej: Dise\xF1ar mockups de la aplicaci\xF3n",disabled:i}),x.name&&jsxRuntime.jsxs("p",{className:"mt-1 text-sm text-red-400 flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"w-4 h-4"}),x.name]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-sm font-medium mb-2 flex items-center gap-2",style:d,children:[jsxRuntime.jsx(lucideReact.Calendar,{className:"w-4 h-4"}),"Fecha de Inicio"]}),jsxRuntime.jsx("input",{type:"date",value:p.startDate?p.startDate.toISOString().split("T")[0]:"",onChange:f=>h("startDate",f.target.value?new Date(f.target.value):void 0),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:u,disabled:i||p.isMilestone})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-sm font-medium mb-2 flex items-center gap-2",style:d,children:[jsxRuntime.jsx(lucideReact.Calendar,{className:"w-4 h-4"}),"Fecha de Fin"]}),jsxRuntime.jsx("input",{type:"date",value:p.endDate?p.endDate.toISOString().split("T")[0]:"",onChange:f=>h("endDate",f.target.value?new Date(f.target.value):void 0),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:u,disabled:i||p.isMilestone}),x.endDate&&jsxRuntime.jsxs("p",{className:"mt-1 text-sm text-red-400 flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"w-4 h-4"}),x.endDate]})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-sm font-medium mb-2 flex items-center gap-2",style:d,children:[jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"w-4 h-4"}),"Estado"]}),jsxRuntime.jsxs("select",{value:p.status,onChange:f=>h("status",f.target.value),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:u,disabled:i,children:[jsxRuntime.jsx("option",{value:"todo",children:"Por Hacer"}),jsxRuntime.jsx("option",{value:"in-progress",children:"En Progreso"}),jsxRuntime.jsx("option",{value:"completed",children:"Completada"})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-sm font-medium mb-3 flex items-center gap-2",style:d,children:[jsxRuntime.jsx(lucideReact.Palette,{className:"w-4 h-4"}),"Color de la Tarea"]}),jsxRuntime.jsx(ql,{value:p.color,onChange:f=>h("color",f),disabled:i}),jsxRuntime.jsx("p",{className:"text-xs mt-2",style:{color:s.textTertiary},children:r?.parentId?"Esta subtarea hereda el color de su tarea padre":r?.subtasks&&r.subtasks.length>0?"Las subtareas heredar\xE1n este color con menor opacidad":"Elige un color para organizar visualmente tus tareas"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-sm font-medium mb-2 flex items-center justify-between",style:d,children:[jsxRuntime.jsxs("span",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-4 h-4"}),"Progreso"]}),jsxRuntime.jsxs("span",{className:"font-semibold px-2 py-0.5 rounded text-sm",style:{color:p.progress<30?"#EF4444":p.progress<70?"#F59E0B":"#10B981",backgroundColor:p.progress<30?"rgba(239, 68, 68, 0.1)":p.progress<70?"rgba(245, 158, 11, 0.1)":"rgba(16, 185, 129, 0.1)"},children:[p.progress,"%"]})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("input",{type:"range",min:"0",max:"100",step:"5",value:p.progress,onChange:f=>h("progress",parseInt(f.target.value)),className:"w-full h-2 rounded-lg appearance-none cursor-pointer",style:{backgroundColor:s.bgSecondary,accentColor:p.progress<30?"#EF4444":p.progress<70?"#F59E0B":"#10B981"},disabled:i}),jsxRuntime.jsx("div",{className:"absolute top-0 left-0 h-2 rounded-lg pointer-events-none transition-all duration-300",style:{width:`${p.progress}%`,backgroundColor:p.progress<30?"rgba(239, 68, 68, 0.3)":p.progress<70?"rgba(245, 158, 11, 0.3)":"rgba(16, 185, 129, 0.3)"}})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between mt-3 gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs",style:{color:s.textTertiary},children:"Accesos r\xE1pidos:"}),jsxRuntime.jsx("div",{className:"flex gap-1.5",children:[0,25,50,75,100].map(f=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>h("progress",f),disabled:i,className:"px-3 py-1 text-xs font-medium rounded-md transition-all duration-200 hover:scale-105 active:scale-95",style:{backgroundColor:p.progress===f?f<30?"#EF4444":f<70?"#F59E0B":"#10B981":s.bgSecondary,color:p.progress===f?"#FFFFFF":s.textSecondary,border:`1px solid ${p.progress===f?f<30?"#EF4444":f<70?"#F59E0B":"#10B981":s.borderLight}`},children:[f,"%"]},f))})]}),jsxRuntime.jsxs("div",{className:"flex justify-between text-xs mt-2",style:{color:s.textTertiary},children:[jsxRuntime.jsx("span",{children:"0%"}),jsxRuntime.jsx("span",{children:"25%"}),jsxRuntime.jsx("span",{children:"50%"}),jsxRuntime.jsx("span",{children:"75%"}),jsxRuntime.jsx("span",{children:"100%"})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 p-4 rounded-lg",style:{backgroundColor:s.bgSecondary,border:`1px solid ${s.borderLight}`},children:[jsxRuntime.jsx("input",{type:"checkbox",id:"isMilestone",checked:p.isMilestone,onChange:f=>h("isMilestone",f.target.checked),className:"w-4 h-4 rounded focus:ring-2",style:{accentColor:s.accent},disabled:i}),jsxRuntime.jsxs("label",{htmlFor:"isMilestone",className:"flex items-center gap-2 text-sm cursor-pointer",style:{color:s.textPrimary},children:[jsxRuntime.jsx(lucideReact.Milestone,{className:"w-4 h-4 text-yellow-500"}),"Marcar como Hito (Milestone)"]})]}),n.length>0&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-sm font-medium mb-2 flex items-center gap-2",style:d,children:[jsxRuntime.jsx(lucideReact.Users,{className:"w-4 h-4"}),"Asignar a"]}),jsxRuntime.jsx("div",{className:"space-y-2 max-h-32 overflow-y-auto p-3 rounded-lg",style:{backgroundColor:s.bgSecondary,border:`1px solid ${s.borderLight}`},children:n.map(f=>jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded",onMouseEnter:w=>w.currentTarget.style.backgroundColor=s.hoverBg,onMouseLeave:w=>w.currentTarget.style.backgroundColor="transparent",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:p.assignees?.some(w=>w.name===f.name),onChange:w=>{let k=w.target.checked?[...p.assignees||[],{name:f.name,avatar:f.avatar,initials:f.name.split(" ").map(y=>y[0]).join("").toUpperCase().slice(0,2),color:s.accent}]:(p.assignees||[]).filter(y=>y.name!==f.name);h("assignees",k);},className:"w-4 h-4 rounded",style:{accentColor:s.accent},disabled:i}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs text-white font-semibold",style:{backgroundColor:s.accent},children:f.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:s.textPrimary},children:f.name})]})]},f.id))})]}),a.length>0&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-sm font-medium mb-2 flex items-center gap-2",style:d,children:[jsxRuntime.jsx(lucideReact.Link2,{className:"w-4 h-4"}),"Dependencias"]}),jsxRuntime.jsx("div",{className:"space-y-2 max-h-32 overflow-y-auto p-3 rounded-lg",style:{backgroundColor:s.bgSecondary,border:`1px solid ${s.borderLight}`},children:a.filter(f=>f.id!==r?.id).map(f=>jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded",onMouseEnter:w=>w.currentTarget.style.backgroundColor=s.hoverBg,onMouseLeave:w=>w.currentTarget.style.backgroundColor="transparent",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:p.dependencies?.includes(f.id),onChange:w=>{let k=w.target.checked?[...p.dependencies||[],f.id]:(p.dependencies||[]).filter(y=>y!==f.id);h("dependencies",k);},className:"w-4 h-4 rounded",style:{accentColor:s.accent},disabled:i}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:s.textPrimary},children:f.name})]},f.id))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4",style:{borderTop:`1px solid ${s.border}`,backgroundColor:s.bgPrimary},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:s.textSecondary},onMouseEnter:f=>{f.currentTarget.style.color=s.textPrimary,f.currentTarget.style.backgroundColor=s.hoverBg;},onMouseLeave:f=>{f.currentTarget.style.color=s.textSecondary,f.currentTarget.style.backgroundColor="transparent";},disabled:i,children:"Cancelar"}),jsxRuntime.jsx("button",{onClick:g,disabled:i,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",style:{backgroundColor:s.accent,color:"#FFFFFF"},onMouseEnter:f=>!i&&(f.currentTarget.style.backgroundColor=s.accentHover),onMouseLeave:f=>!i&&(f.currentTarget.style.backgroundColor=s.accent),children:i?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"w-4 h-4"}),c==="create"?"Crear Tarea":"Guardar Cambios"]})})]})]})})]})})}var tg=['Move "Task Name" to next Monday','Extend "Task Name" by 3 days','Rename "Old Name" to "New Name"','Set "Task Name" progress to 50%','Link "Task A" to "Task B"','Create a new task called "New Task"','Delete "Task Name"','Assign John to "Task Name"'],rc=()=>jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),rg=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13"})}),ag=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M18 6L6 18M6 6L18 18"})}),ng=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M5 12h14"})}),og=()=>jsxRuntime.jsx("div",{className:"flex gap-1 items-center",children:[0,1,2].map(e=>jsxRuntime.jsx(framerMotion.motion.div,{className:"w-2 h-2 rounded-full bg-current",animate:{scale:[1,1.2,1],opacity:[.5,1,.5]},transition:{duration:.8,repeat:1/0,delay:e*.15}},e))});function $n({tasks:e,theme:t,config:r,onTasksUpdate:a,onTaskUpdate:n,onTaskCreate:o,onTaskDelete:i,onDependencyCreate:c,onDependencyDelete:l}){let[s,u]=we.useState(false),[d,p]=we.useState(false),[m,x]=we.useState([]),[b,v]=we.useState(""),[g,h]=we.useState(false),[f,w]=we.useState(true),k=we.useRef(null),y=we.useRef(null),C=we.useRef(null),{enabled:T=true,placeholder:D='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:R="bottom-right",onCommand:_,suggestions:G=tg,maxHistory:M=50}=r;we.useEffect(()=>{y.current&&y.current.scrollIntoView({behavior:"smooth"});},[m]),we.useEffect(()=>{s&&!d&&k.current&&setTimeout(()=>k.current?.focus(),100);},[s,d]);let O=we.useCallback(A=>{if(A.success)switch(A.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":A.taskId&&A.updates&&n?.(A.taskId,A.updates);break;case "create_task":A.newTask&&o?.(A.newTask);break;case "delete_task":A.taskId&&i?.(A.taskId);break;case "link_tasks":A.dependencyFrom&&A.dependencyTo&&c?.(A.dependencyFrom,A.dependencyTo);break;case "unlink_tasks":A.taskId&&A.dependencyFrom&&l?.(A.taskId,A.dependencyFrom);break}},[n,o,i,c,l]),E=we.useCallback(async A=>{if(!A.trim()||g)return;let te={id:`user-${Date.now()}`,role:"user",content:A,timestamp:new Date};x(fe=>[...fe.slice(-(M-1)),te]),v(""),w(false),h(true);let X={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};x(fe=>[...fe,X]);try{if(_){let fe=await _(A,e);x(P=>{let ge=P.filter(pt=>!pt.isLoading),ae={id:`assistant-${Date.now()}`,role:"assistant",content:fe.message,timestamp:new Date,command:fe};return [...ge,ae]}),O(fe);}else x(fe=>[...fe.filter(ge=>!ge.isLoading),{id:`assistant-${Date.now()}`,role:"assistant",content:"AI handler not configured. Please provide an onCommand handler in the aiAssistant config.",timestamp:new Date}]);}catch(fe){x(P=>[...P.filter(ae=>!ae.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${fe instanceof Error?fe.message:"Unknown error"}`,timestamp:new Date}]);}finally{h(false);}},[g,M,_,e,O]),B=A=>{A.preventDefault(),E(b);},z=A=>{v(A),k.current?.focus();};if(we.useEffect(()=>{let A=te=>{(te.metaKey||te.ctrlKey)&&te.key==="k"&&(te.preventDefault(),u(X=>!X),s||p(false)),te.key==="Escape"&&s&&u(false);};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[s]),!T)return null;let $={"bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-right":"top-4 right-4","top-left":"top-4 left-4"};return jsxRuntime.jsxs(Ke,{children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!s&&jsxRuntime.jsxs(framerMotion.motion.button,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},className:`fixed ${$[R]} z-[99999] flex items-center gap-2 px-4 py-3 rounded-full shadow-lg transition-colors`,style:{background:"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)",color:"white",boxShadow:"0 4px 20px rgba(99, 102, 241, 0.4)"},onClick:()=>u(true),children:[jsxRuntime.jsx(rc,{}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),jsxRuntime.jsx("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono rounded bg-white/20",children:"\u2318K"})]})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:s&&jsxRuntime.jsxs(framerMotion.motion.div,{ref:C,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:d?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${$[R]} z-[99999] w-96 rounded-2xl overflow-hidden shadow-2xl flex flex-col`,style:{background:t.bgPrimary,border:`1px solid ${t.border}`,boxShadow:`0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px ${t.border}`},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-white",children:[jsxRuntime.jsx(rc,{}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{onClick:()=>p(A=>!A),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(ng,{})}),jsxRuntime.jsx("button",{onClick:()=>u(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(ag,{})})]})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!d&&jsxRuntime.jsxs(framerMotion.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"flex flex-col flex-1 min-h-0",children:[jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[m.length===0&&f&&jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("p",{className:"text-sm text-center",style:{color:t.textSecondary},children:"Try asking me to edit your Gantt chart:"}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:G.slice(0,4).map((A,te)=>jsxRuntime.jsx("button",{onClick:()=>z(A),className:"text-xs px-3 py-1.5 rounded-full transition-colors",style:{background:t.bgSecondary,color:t.textSecondary,border:`1px solid ${t.border}`},children:A.length>30?A.slice(0,30)+"...":A},te))})]}),m.map(A=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${A.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${A.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:A.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:A.role==="user"?"white":t.textPrimary},children:[A.isLoading?jsxRuntime.jsx(og,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:A.content}),A.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:A.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:A.command.success?"#10B981":"#EF4444"},children:[A.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:A.command.type.replace(/_/g," ")})]})]})},A.id)),jsxRuntime.jsx("div",{ref:y})]}),jsxRuntime.jsxs("form",{onSubmit:B,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsxRuntime.jsx("input",{ref:k,type:"text",value:b,onChange:A=>v(A.target.value),placeholder:D,disabled:g,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsxRuntime.jsx("button",{type:"submit",disabled:!b.trim()||g,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:b.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:b.trim()?"white":t.textSecondary},children:jsxRuntime.jsx(rg,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function ac(e,t=50){let[r,a]=we.useState({past:[],present:e,future:[]}),n=we.useRef(false),o=we.useCallback((s,u=true)=>{a(d=>{let p=typeof s=="function"?s(d.present):s;if(n.current)return {...d,present:p};if(!u)return {...d,present:p};let m=[...d.past,d.present];return m.length>t&&m.shift(),{past:m,present:p,future:[]}});},[t]),i=we.useCallback(()=>{a(s=>{if(s.past.length===0)return s;let u=s.past[s.past.length-1],d=s.past.slice(0,s.past.length-1);return n.current=true,setTimeout(()=>{n.current=false;},0),{past:d,present:u,future:[s.present,...s.future]}});},[]),c=we.useCallback(()=>{a(s=>{if(s.future.length===0)return s;let u=s.future[0],d=s.future.slice(1);return n.current=true,setTimeout(()=>{n.current=false;},0),{past:[...s.past,s.present],present:u,future:d}});},[]),l=we.useCallback(()=>{a(s=>({past:[],present:s.present,future:[]}));},[]);return {state:r.present,setState:o,undo:i,redo:c,canUndo:r.past.length>0,canRedo:r.future.length>0,clearHistory:l}}function nc({undo:e,redo:t,canUndo:r,canRedo:a,enabled:n=true}){we.useEffect(()=>{if(!n)return;let o=i=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,l=c?i.metaKey:i.ctrlKey;if(l&&i.key==="z"&&!i.shiftKey&&r){i.preventDefault(),e();return}if(a){if(!c&&l&&i.key==="y"){i.preventDefault(),t();return}if(c&&l&&i.shiftKey&&i.key==="z"){i.preventDefault(),t();return}}};return window.addEventListener("keydown",o),()=>{window.removeEventListener("keydown",o);}},[e,t,r,a,n]);}var cg={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${K.formatDate(e.startDate)} - ${K.formatDate(e.endDate)}`);let r=K.calculateDuration(e.startDate,e.endDate);t.push(`Duration: ${r} days`);}if(e.progress!==void 0&&t.push(`Progress: ${e.progress}%`),e.status&&t.push(`Status: ${e.status}`),e.assignees&&e.assignees.length>0){let r=e.assignees.map(a=>a.name).join(", ");t.push(`Assigned: ${r}`);}return e.dependencies&&e.dependencies.length>0&&t.push(`Dependencies: ${e.dependencies.length}`),t.join("<br/>")},taskLabel:e=>e.name,gridCell:(e,t,r)=>r,taskClass:e=>{let t=[];return e.isCriticalPath&&t.push("critical-path"),e.status==="completed"?t.push("completed"):e.status==="in-progress"?t.push("in-progress"):e.status==="todo"&&t.push("todo"),e.isMilestone&&t.push("milestone"),t.join(" ")},milestoneContent:e=>`\u25C6 ${e.name}`,dateFormat:e=>K.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function oc(e){return {...cg,...e}}var fg=e=>{switch(e){case "compact":return 40;case "comfortable":return 48;case "spacious":return 56;default:return 48}},lc=we.forwardRef(function({tasks:t,config:r={},onTasksChange:a},n){let{theme:o,timeScale:i="week",rowDensity:c="comfortable",showThemeSelector:l=true,showExportButton:s=true,availableUsers:u=[],templates:d,enableAutoCriticalPath:p=true,aiAssistant:m,showCreateTaskButton:x=false,createTaskLabel:b,onCreateTask:v,onThemeChange:g,onTaskClick:h,onTaskDblClick:f,onTaskContextMenu:w,onTaskUpdate:k,onProgressChange:y,onDependencyCreate:C,onDependencyDelete:T,onBeforeTaskAdd:D,onAfterTaskAdd:R,onBeforeTaskUpdate:_,onAfterTaskUpdate:G}=r,O=we.useContext(Sn)?.theme,[E,B]=we.useState(O||o||"dark"),[z,$]=we.useState(i),[A,te]=we.useState(c),[X,fe]=we.useState(1),[P,ge]=we.useState(0),[ae,pt]=we.useState(false),[ct,Bt]=we.useState(null),[ie,mt]=we.useState({isOpen:false,x:0,y:0,task:null}),[vt,Ot]=we.useState(null);we.useEffect(()=>{O&&O!==E&&B(O);},[O]),we.useEffect(()=>{o&&o!==E&&B(o);},[o]);let ar=we.useCallback(N=>{B(N),g?.(N);},[g]),{state:ne,setState:se,undo:Qe,redo:Ht,canUndo:Vt,canRedo:ur,clearHistory:zt}=ac(t,50);we.useEffect(()=>{se(t);},[t,se]),we.useEffect(()=>{a&&a(ne);},[ne,a]);let[V,U]=we.useState([{id:"name",label:"TASK NAME",width:320,minWidth:180,maxWidth:800,visible:true,sortable:true,resizable:true},{id:"startDate",label:"Start Date",width:110,visible:false,sortable:true},{id:"endDate",label:"End Date",width:110,visible:false,sortable:true},{id:"duration",label:"Duration",width:80,visible:false,sortable:true},{id:"assignees",label:"Assignees",width:120,visible:false,sortable:false},{id:"status",label:"Status",width:80,visible:false,sortable:true},{id:"progress",label:"% Complete",width:120,visible:false,sortable:true}]),Se=we.useMemo(()=>V.filter(N=>N.visible).reduce((N,I)=>N+I.width,0)+60,[V]),ze=ct||Se,Ne=we.useRef(null),de=we.useRef(null),ue=we.useRef(null),Ve=we.useMemo(()=>Sl(E),[E]),le=we.useMemo(()=>({theme:Ve,themeName:E}),[Ve,E]),be=we.useMemo(()=>oc(d),[d]),j=we.useMemo(()=>{if(!p)return ne;let N=K.calculateCriticalPath(ne),I=W=>W.map(J=>({...J,isCriticalPath:N.includes(J.id),subtasks:J.subtasks?I(J.subtasks):void 0}));return I(ne)},[ne,p]),ye=fg(A);nc({undo:Qe,redo:Ht,canUndo:Vt,canRedo:ur,enabled:true}),we.useImperativeHandle(n,()=>({getTask:N=>K.findTaskById(ne,N),addTask:(N,I)=>{se(W=>{if(!I)return [...W,{...N,level:0}];let J=ee=>ee.map(oe=>oe.id===I?{...oe,subtasks:[...oe.subtasks||[],{...N,parentId:I,level:(oe.level||0)+1}],isExpanded:true}:oe.subtasks?{...oe,subtasks:J(oe.subtasks)}:oe);return J(W)});},updateTask:(N,I)=>{se(W=>{let J=ee=>ee.map(oe=>oe.id===N?{...oe,...I}:oe.subtasks?{...oe,subtasks:J(oe.subtasks)}:oe);return J(W)});},deleteTask:N=>{se(I=>{let W=J=>J.filter(ee=>ee.id===N?false:(ee.subtasks&&(ee.subtasks=W(ee.subtasks)),true));return W(I)});},deleteTasks:N=>{se(I=>En(I,N));},duplicateTask:N=>{se(I=>ts(I,[N]));},splitTask:(N,I,W=3)=>{se(J=>K.splitTask(J,N,I,W));},calculateEndDate:K.calculateEndDate,calculateDuration:K.calculateDuration,validateDependency:(N,I)=>!K.validateDependencies(ne,N,I),getAllTasks:()=>K.flattenTasks(ne),getTasksByStatus:N=>K.flattenTasks(ne).filter(I=>I.status===N),getTasksByParent:N=>N?K.findTaskById(ne,N)?.subtasks||[]:ne.filter(W=>!W.parentId),getCriticalPath:()=>K.flattenTasks(ne).filter(N=>N.isCriticalPath),indentTask:N=>{se(I=>Zo(I,[N]));},outdentTask:N=>{se(I=>Qo(I,[N]));},moveTask:(N,I)=>{se(W=>es(W,[N],I));},createSubtask:async N=>{let{tasks:I,newTask:W}=ns(ne,N);if(D){let J=D({...W,parentId:N});if((J instanceof Promise?await J:J)===false)return}se(I),R&&R({...W,parentId:N});},scrollToTask:N=>{let W=K.flattenTasks(ne).findIndex(J=>J.id===N);if(W!==-1&&Ne.current){let J=W*ye;Ne.current.scrollTo({top:J,behavior:"smooth"}),de.current&&de.current.scrollTo({top:J,behavior:"smooth"});}},highlightTask:(N,I=2e3)=>{},expandTask:N=>{se(I=>{let W=J=>J.map(ee=>ee.id===N?{...ee,isExpanded:true}:ee.subtasks?{...ee,subtasks:W(ee.subtasks)}:ee);return W(I)});},collapseTask:N=>{se(I=>{let W=J=>J.map(ee=>ee.id===N?{...ee,isExpanded:false}:ee.subtasks?{...ee,subtasks:W(ee.subtasks)}:ee);return W(I)});},expandAll:()=>{se(N=>{let I=W=>W.map(J=>({...J,isExpanded:true,subtasks:J.subtasks?I(J.subtasks):void 0}));return I(N)});},collapseAll:()=>{se(N=>{let I=W=>W.map(J=>({...J,isExpanded:false,subtasks:J.subtasks?I(J.subtasks):void 0}));return I(N)});},undo:Qe,redo:Ht,canUndo:()=>Vt,canRedo:()=>ur,clearHistory:zt,exportToPNG:async()=>{if(!ue.current)throw new Error("Gantt container not found");let N=await sc__default.default(ue.current,{backgroundColor:Ve.bgPrimary,scale:2});return new Promise((I,W)=>{N.toBlob(J=>{J?I(J):W(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async N=>{await K.exportToPDF(ne,N);},exportToExcel:async N=>{await K.exportToExcel(ne,N);},exportToJSON:()=>K.exportToJSON(ne),exportToCSV:()=>K.exportToCSV(ne),importFromJSON:N=>{let I=K.importFromJSON(N);se(I);},getTasks:()=>ne,refresh:()=>{se(N=>[...N]);},clearAll:()=>{se([]);}}),[ne,Qe,Ht,Vt,ur,zt,Ve,ye]);let S=we.useCallback(N=>{U(I=>I.map(W=>W.id===N?{...W,visible:!W.visible}:W));},[]),H=we.useCallback((N,I)=>{U(W=>W.map(J=>{if(J.id!==N)return J;let ee=J.minWidth??100,oe=J.maxWidth??800,et=Math.max(ee,Math.min(oe,I));return {...J,width:et}}));},[]),pe=we.useCallback(N=>{se(I=>as(I,N)),r.onTaskToggleExpand?.(N);},[r]),Ee=we.useCallback((N,I)=>{if(_&&_(N,I)===false)return;let J=K.findTaskById(ne,N)?.progress,ee=et=>et.map(nt=>nt.id===N?{...nt,...I}:nt.subtasks?{...nt,subtasks:ee(nt.subtasks)}:nt);se(ee(ne));let oe=K.findTaskById(ee(ne),N);oe&&(k?.(oe),G?.(oe),I.progress!==void 0&&J!==void 0&&I.progress!==J&&y?.(N,J,I.progress));},[ne,k,_,G,y]),Fe=we.useCallback(N=>{N.length!==0&&(se(I=>Zo(I,N)),r.onTaskIndent?.(N[0]));},[r]),We=we.useCallback(N=>{N.length!==0&&(se(I=>Qo(I,N)),r.onTaskOutdent?.(N[0]));},[r]),Mt=we.useCallback((N,I)=>{N.length!==0&&(se(W=>es(W,N,I)),r.onTaskMove?.(N[0],I));},[r]),$t=we.useCallback(N=>{r.onMultiTaskDelete?r.onMultiTaskDelete(N):(se(I=>En(I,N)),N.forEach(I=>r.onTaskDelete?.(I)));},[r]),qn=we.useCallback(N=>{se(I=>ts(I,N)),N.forEach(I=>r.onTaskDuplicate?.(I));},[r]),ga=we.useCallback((N,I)=>{se(W=>{let{tasks:J,newTask:ee}=Ol(W,N,I);return D&&D(ee)===false?W:(r.onTaskCreate?.(ee.parentId,ee.position||0),R?.(ee),J)});},[r,D,R]),ha=we.useCallback((N,I)=>{se(W=>rs(W,N,I)),r.onTaskRename?.(N,I);},[r]),ld=we.useCallback(N=>{se(I=>{let{tasks:W}=ns(I,N);return r.onTaskCreate?.(N,0),W});},[r]),cd=we.useCallback((N,I,W)=>{let J=N.startDate?Math.round((I.getTime()-N.startDate.getTime())/864e5):0,ee=nt=>nt.map(pr=>pr.id===N.id?{...pr,startDate:I,endDate:W,...N.segments&&{segments:N.segments}}:pr.subtasks?{...pr,subtasks:ee(pr.subtasks)}:pr),oe=ee(ne);oe=K.autoScheduleDependents(oe,N.id,J),se(oe);let et={...N,startDate:I,endDate:W};k?.(et);},[ne,k]),dd=we.useCallback((N,I)=>{w?.(N,I),mt({isOpen:true,x:I.clientX,y:I.clientY,task:N});},[w]),ud=we.useCallback((N,I)=>{let W=K.splitTask(ne,N.id,I);se(W),mt({isOpen:false,x:0,y:0,task:null});},[ne]),Hs=we.useCallback(N=>{f?.(N),Ot(N);},[f]),Vs=we.useCallback((N,I,W)=>{let J=new Map,ee=Lr=>{Lr.forEach(Fr=>{Fr.dependencies&&J.set(Fr.id,Fr.dependencies),Fr.subtasks&&ee(Fr.subtasks);});};ee(W);let oe=J.get(I)||[];J.set(I,[...oe,N]);let et=new Set,nt=new Set,pr=Lr=>{if(!et.has(Lr)){et.add(Lr),nt.add(Lr);let Fr=J.get(Lr)||[];for(let Xn of Fr){if(!et.has(Xn)&&pr(Xn))return true;if(nt.has(Xn))return true}}return nt.delete(Lr),false};return pr(I)},[]),Ks=we.useCallback((N,I)=>{if(Vs(N.id,I,ne)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
276
+ </Project>`,u=new Blob([s],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(u),d.download=r,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=K.flattenTasks(e),r=t.filter(s=>s.startDate&&s.endDate);if(r.length===0)return [];let a=new Map,n=s=>{if(a.has(s.id))return;let u=s.startDate&&s.endDate?K.calculateDuration(s.startDate,s.endDate):0,d=0;if(s.dependencies&&s.dependencies.length>0)for(let m of s.dependencies){let x=t.find(b=>b.id===m);if(x){n(x);let b=a.get(m)?.ef||0;d=Math.max(d,b);}}let p=d+u;a.set(s.id,{es:d,ef:p});};r.forEach(n);let o=Math.max(...Array.from(a.values()).map(s=>s.ef)),i=new Map,c=s=>{if(i.has(s.id))return;let u=s.startDate&&s.endDate?K.calculateDuration(s.startDate,s.endDate):0,d=t.filter(x=>x.dependencies&&x.dependencies.includes(s.id)),p=o;if(d.length>0)for(let x of d){c(x);let b=i.get(x.id)?.ls||0;p=Math.min(p,b);}let m=p-u;i.set(s.id,{ls:m,lf:p});};r.forEach(c);let l=[];for(let s of r){let u=a.get(s.id),d=i.get(s.id);if(u&&d){let p=d.ls-u.es;Math.abs(p)<.01&&l.push(s.id);}}return l},calculateSlack:(e,t)=>{let r=K.findTaskById(e,t);if(!r||!r.startDate||!r.endDate)return null;if(K.calculateCriticalPath(e).includes(t))return 0;let n=K.getDependentTasks(e,t);if(n.length===0){let c=K.getLatestEndDate(e);if(!c)return null;let l=K.calculateDuration(r.endDate,c);return Math.max(0,l)}let o=n.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,l)=>c-l)[0];if(!o)return null;let i=K.calculateDuration(r.endDate,new Date(o));return Math.max(0,i)},isOnCriticalPath:(e,t)=>K.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,r)=>{let a=K.findTaskById(e,t);if(!a||!a.endDate)return e;let n=K.getDependentTasks(e,t);if(n.length===0)return e;let o=[...e];for(let i of n){if(!i.startDate||!i.endDate)continue;let c=K.calculateDuration(i.startDate,i.endDate),l;r!==void 0?(l=new Date(i.startDate),l.setDate(l.getDate()+r)):(l=new Date(a.endDate),l.setDate(l.getDate()+1));let s=K.calculateEndDate(l,c),u=d=>d.map(p=>p.id===i.id?{...p,startDate:l,endDate:s}:p.subtasks?{...p,subtasks:u(p.subtasks)}:p);o=u(o),o=K.autoScheduleDependents(o,i.id,r);}return o},calculateCascadePreview:(e,t,r,a,n,o,i,c)=>{if(r===0)return [];let l=[],s=n.getTime(),u=1e3*60*60*24,d=K.findTaskById(e,t);if(!d||!d.endDate)return [];let p=(m,x,b=new Set)=>{if(b.has(m))return;b.add(m);let v=K.getDependentTasks(e,m);for(let g of v){if(!g.startDate||!g.endDate)continue;let h=a.findIndex(_=>_.id===g.id);if(h===-1)continue;let f=g.startDate.getTime(),k=(g.endDate.getTime()-f)/u,C=(f-s)/u*o,T=C+x*o,D=Math.max(k*o,o),R=c+h*i+12;l.push({taskId:g.id,taskName:g.name,originalX:C,previewX:T,width:D,y:R,rowIndex:h,daysDelta:x,color:g.color}),p(g.id,x,b);}};return p(t,r),l},splitTask:(e,t,r,a=3)=>{let n=K.findTaskById(e,t);if(!n||!n.startDate||!n.endDate)return e;if(r<=n.startDate||r>=n.endDate)return console.warn("Split date must be between task start and end dates"),e;let o=new Date(r);o.setDate(o.getDate()-1);let i=new Date(r);i.setDate(i.getDate()+a);let c=new Date(n.endDate);c.setDate(c.getDate()+a);let l=[{startDate:new Date(n.startDate),endDate:o},{startDate:i,endDate:c}],s=u=>u.map(d=>d.id===n.id?{...d,endDate:c,segments:l}:d.subtasks?{...d,subtasks:s(d.subtasks)}:d);return s(e)}};function On({tasks:e,theme:t,rowHeight:r,timeScale:a,startDate:n,endDate:o,zoom:i,templates:c,onTaskClick:l,onTaskDblClick:s,onTaskContextMenu:u,onTaskDateChange:d,onDependencyCreate:p,onDependencyDelete:m}){let[b,v]=we.useState([]),g=Math.ceil((o.getTime()-n.getTime())/(1e3*60*60*24)),h=a==="day"?60:a==="week"?20:8,f=g*h*i,w=E=>{let B=new Date(Date.UTC(E.getFullYear(),E.getMonth(),E.getDate())),z=B.getUTCDay()||7;B.setUTCDate(B.getUTCDate()+4-z);let $=new Date(Date.UTC(B.getUTCFullYear(),0,1));return Math.ceil(((B.getTime()-$.getTime())/864e5+1)/7)},k=E=>{let B=E.getDay();return B===0||B===6},y=we.useCallback(E=>{let B=Math.round(E/(h*i)),z=new Date(n);return z.setDate(z.getDate()+B),z},[n,h,i]),C=we.useCallback((E,B)=>{if(B.startDate&&B.endDate)return;let z=E.currentTarget.ownerSVGElement;if(!z)return;let $=z.createSVGPoint();$.x=E.clientX,$.y=E.clientY;let A=$.matrixTransform(z.getScreenCTM()?.inverse()),te=y(A.x),X=new Date(te);X.setDate(X.getDate()+1),d?.(B,te,X);},[y,d]),T=we.useMemo(()=>{let E=A=>A.map(te=>{if(te.subtasks&&te.subtasks.length>0){let X=E(te.subtasks),fe=X.filter(P=>P.startDate&&P.endDate);if(fe.length>0){let P=fe.map(ct=>ct.startDate.getTime()),ge=fe.map(ct=>ct.endDate.getTime()),ae=new Date(Math.min(...P)),pt=new Date(Math.max(...ge));return {...te,subtasks:X,startDate:ae,endDate:pt}}return {...te,subtasks:X}}return te}),B=(A,te=[])=>{for(let X of A)te.push(X),X.subtasks&&X.subtasks.length>0&&(X.isExpanded===void 0||X.isExpanded)&&B(X.subtasks,te);return te},z=E(e);return B(z)},[e]),D=we.useCallback(E=>{if(!E.startDate||!E.endDate)return {x:0,width:0};let B=E.startDate.getTime(),z=E.endDate.getTime(),$=n.getTime(),A=(B-$)/(1e3*60*60*24),te=(z-B)/(1e3*60*60*24),X=A*h*i,fe=Math.max(h*i,40),P=Math.max(te*h*i,fe);return {x:X,width:P}},[n,h,i]),R=we.useMemo(()=>T.filter(E=>E.startDate&&E.endDate).map(E=>{let{x:B,width:z}=D(E),A=T.findIndex(te=>te.id===E.id)*r+12;return {id:E.id,x:B,y:A,width:z,height:32}}),[T,D]),_=we.useCallback((E,B,z)=>{if(!z||B===0){v([]);return}let $=K.calculateCascadePreview(e,E,B,T,n,h*i,r,48);v($);},[e,T,n,h,i,r,48]),G=we.useMemo(()=>{let E=[],B=new Date(n);for(;B<=o;){let A=(B.getTime()-n.getTime())/864e5*h*i;if(a==="day")E.push({date:new Date(B),label:B.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:A}),B.setDate(B.getDate()+1);else if(a==="week"){let te=w(B);E.push({date:new Date(B),label:`Week ${te}`,x:A}),B.setDate(B.getDate()+7);}else E.push({date:new Date(B),label:B.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:A}),B.setMonth(B.getMonth()+1);}return E},[n,o,a,h,i]),M=we.useMemo(()=>(new Date().getTime()-n.getTime())/(1e3*60*60*24)*h*i,[n,h,i]),O=Math.max(T.length*r,552);return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary},children:[jsxRuntime.jsx("div",{style:{position:"sticky",top:0,zIndex:10,backgroundColor:t.bgGrid,flexShrink:0,borderBottom:`1px solid ${t.border}`},children:jsxRuntime.jsxs("svg",{width:Math.max(f,1e3),height:48,style:{display:"block"},children:[jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(f,1e3),height:48,fill:t.bgGrid}),G.map((E,B)=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:E.x,y1:0,x2:E.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsxRuntime.jsx("text",{x:E.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:E.label})]},`header-${B}`)),M>=0&&M<=f&&jsxRuntime.jsx("circle",{cx:M,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(f,1e3),height:O,style:{display:"block",flexShrink:0},children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsx("filter",{id:"shadow",children:jsxRuntime.jsx("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2",floodOpacity:"0.1"})}),jsxRuntime.jsx("pattern",{id:"diagonal-stripes",width:"8",height:"8",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:jsxRuntime.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"8",stroke:t.border,strokeWidth:"2"})})]}),jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(f,1e3),height:O,fill:t.bgPrimary}),G.map((E,B)=>{let z=G[B+1]?.x||f,$=k(E.date);return jsxRuntime.jsxs("g",{children:[$&&jsxRuntime.jsx("rect",{x:E.x,y:0,width:z-E.x,height:T.length*r,fill:t.bgWeekend,opacity:1}),jsxRuntime.jsx("line",{x1:E.x,y1:0,x2:E.x,y2:T.length*r,stroke:t.border,strokeWidth:1,opacity:.1})]},B)}),M>=0&&M<=f&&jsxRuntime.jsx("line",{x1:M,y1:0,x2:M,y2:T.length*r,stroke:t.today,strokeWidth:2,opacity:1}),T.map((E,B)=>{let z=E.startDate&&E.endDate;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:0,y:B*r,width:f,height:r,fill:B%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${E.id}`),!z&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:0,y:B*r,width:f,height:r,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:$=>C($,E),onMouseEnter:$=>{$.currentTarget.setAttribute("fill",t.accentLight),$.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:$=>{$.currentTarget.setAttribute("fill","transparent"),$.currentTarget.setAttribute("opacity","1");}},`clickable-${E.id}`),jsxRuntime.jsx("text",{x:M>0?M:100,y:B*r+r/2,fill:t.textTertiary,fontSize:"12",fontFamily:"Inter, sans-serif",fontStyle:"italic",dominantBaseline:"middle",opacity:.4,style:{pointerEvents:"none",userSelect:"none"},children:"Click to set dates..."},`placeholder-${E.id}`)]})]},`row-group-${E.id}`)}),T.map((E,B)=>!E.dependencies||E.dependencies.length===0||!E.startDate||!E.endDate?null:E.dependencies.map(z=>{let $=T.find(fe=>fe.id===z);if(!$||!$.startDate||!$.endDate)return null;let A=T.findIndex(fe=>fe.id===z),te=D($),X=D(E);return jsxRuntime.jsx(Mn,{x1:te.x+te.width,y1:A*r+r/2,x2:X.x,y2:B*r+r/2,theme:t,onDelete:()=>m?.(E.id,z)},`dep-${z}-${E.id}`)})),T.map((E,B)=>{if(!E.startDate||!E.endDate)return null;let{x:z,width:$}=D(E),A=B*r+12,te=E.subtasks&&E.subtasks.length>0&&!E.isMilestone;return E.isMilestone?jsxRuntime.jsx(Ln,{task:E,x:z+$/2,y:A+16,theme:t,onClick:l},E.id):te?jsxRuntime.jsxs("g",{onClick:()=>l?.(E),style:{cursor:"pointer"},children:[jsxRuntime.jsx("rect",{x:z,y:A,width:$,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:z,y1:A,x2:z+$,y2:A,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:z,y1:A,x2:z,y2:A+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:z+$,y1:A,x2:z+$,y2:A+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:z,y1:A+32,x2:z+$,y2:A+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),$>60&&jsxRuntime.jsx("text",{x:z+12,y:A+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:E.name})]},E.id):jsxRuntime.jsx(Pn,{task:E,x:z,y:A,width:$,theme:t,dayWidth:h*i,startDate:n,templates:c,onClick:l,onDoubleClick:s,onContextMenu:u,onDateChange:d,onDependencyCreate:p,allTaskPositions:R,onDragMove:_},E.id)}),b.map(E=>jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("rect",{x:E.previewX,y:E.y-48,width:E.width,height:32,rx:8,fill:E.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(E.daysDelta)>0&&jsxRuntime.jsx("text",{x:E.previewX+E.width/2,y:E.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:E.daysDelta>0?`+${E.daysDelta}d`:`${E.daysDelta}d`})]},`cascade-preview-${E.taskId}`))]})]})}var Yl=[{name:"Azul",value:"#6366F1",light:"#818CF8"},{name:"P\xFArpura",value:"#A855F7",light:"#C084FC"},{name:"Rosa",value:"#EC4899",light:"#F472B6"},{name:"Rojo",value:"#EF4444",light:"#F87171"},{name:"Naranja",value:"#F59E0B",light:"#FBBF24"},{name:"Amarillo",value:"#EAB308",light:"#FACC15"},{name:"Lima",value:"#84CC16",light:"#A3E635"},{name:"Verde",value:"#10B981",light:"#34D399"},{name:"Esmeralda",value:"#059669",light:"#10B981"},{name:"Cyan",value:"#06B6D4",light:"#22D3EE"},{name:"Azul Cielo",value:"#0EA5E9",light:"#38BDF8"},{name:"\xCDndigo",value:"#4F46E5",light:"#6366F1"},{name:"Violeta",value:"#8B5CF6",light:"#A78BFA"},{name:"Fucsia",value:"#D946EF",light:"#E879F9"},{name:"Gris",value:"#6B7280",light:"#9CA3AF"},{name:"Piedra",value:"#78716C",light:"#A8A29E"}];function ql({value:e="#6366F1",onChange:t,disabled:r=false}){return jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:Yl.map(a=>{let n=e===a.value;return jsxRuntime.jsx(framerMotion.motion.button,{type:"button",onClick:()=>!r&&t(a.value),className:"relative rounded-full transition-all focus:outline-none focus:ring-2 focus:ring-offset-2",style:{width:"32px",height:"32px",backgroundColor:a.value,boxShadow:n?`0 0 0 2px #FFFFFF, 0 0 0 4px ${a.value}`:"0 1px 3px rgba(0, 0, 0, 0.12)",opacity:r?.5:1,cursor:r?"not-allowed":"pointer"},whileHover:r?{}:{scale:1.1},whileTap:r?{}:{scale:.95},title:a.name,disabled:r,children:n&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{scale:0},animate:{scale:1},className:"absolute inset-0 flex items-center justify-center",children:jsxRuntime.jsx(lucideReact.Check,{className:"w-4 h-4 text-white drop-shadow-md",strokeWidth:3})})},a.value)})}),e&&jsxRuntime.jsx("div",{className:"text-xs text-center font-medium",style:{color:e},children:Yl.find(a=>a.value===e)?.name||"Personalizado"})]})}function zn({isOpen:e,onClose:t,task:r,availableTasks:a=[],availableUsers:n=[],onSubmit:o,isLoading:i=false,mode:c=r?"edit":"create",theme:l="dark"}){let s=ke[l]||ke.dark,u={backgroundColor:s.bgSecondary,border:`1px solid ${s.borderLight}`,color:s.textPrimary},d={color:s.textSecondary},[p,m]=we.useState({name:"",progress:0,status:"todo",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),[x,b]=we.useState({});we.useEffect(()=>{m(r?{name:r.name,startDate:r.startDate,endDate:r.endDate,progress:r.progress,status:r.status||"todo",isMilestone:r.isMilestone||false,color:r.color||"#6366F1",assignees:r.assignees||[],dependencies:r.dependencies||[]}:{name:"",progress:0,status:"todo",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]});},[r,e]);let v=()=>{let f={};return p.name.trim()||(f.name="El nombre es requerido"),p.startDate&&p.endDate&&p.startDate>p.endDate&&(f.endDate="La fecha de fin debe ser posterior a la de inicio"),b(f),Object.keys(f).length===0},g=async f=>{if(f.preventDefault(),!!v())try{await o(p),t();}catch(w){console.error("Error submitting task:",w);}},h=(f,w)=>{m(k=>{let y={...k,[f]:w};if(f==="progress"){let C=typeof w=="number"?w:parseInt(w,10);C===100&&k.status!=="completed"?y.status="completed":C>0&&C<100&&k.status==="todo"?y.status="in-progress":C===0&&k.status==="in-progress"&&(y.status="todo");}return y}),x[f]&&b(k=>{let y={...k};return delete y[f],y});};return jsxRuntime.jsx(framerMotion.AnimatePresence,{children:e&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 z-50",onClick:t}),jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.2,ease:[.4,0,.2,1]},className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:jsxRuntime.jsxs("div",{className:"w-full max-w-2xl rounded-xl shadow-2xl pointer-events-auto overflow-hidden",style:{backgroundColor:s.bgPrimary,border:`1px solid ${s.border}`},onClick:f=>f.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderBottom:`1px solid ${s.border}`},children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold",style:{color:s.textPrimary},children:c==="create"?"Crear Nueva Tarea":"Editar Tarea"}),jsxRuntime.jsx("button",{onClick:t,className:"p-2 rounded-lg transition-colors",style:{color:s.textSecondary},onMouseEnter:f=>f.currentTarget.style.backgroundColor=s.hoverBg,onMouseLeave:f=>f.currentTarget.style.backgroundColor="transparent",disabled:i,children:jsxRuntime.jsx(lucideReact.X,{className:"w-5 h-5"})})]}),jsxRuntime.jsxs("form",{onSubmit:g,className:"p-6 space-y-6 max-h-[calc(100vh-200px)] overflow-y-auto",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-sm font-medium mb-2",style:d,children:"Nombre de la Tarea *"}),jsxRuntime.jsx("input",{type:"text",value:p.name,onChange:f=>h("name",f.target.value),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:u,onFocus:f=>f.currentTarget.style.borderColor=s.accent,onBlur:f=>f.currentTarget.style.borderColor=s.borderLight,placeholder:"Ej: Dise\xF1ar mockups de la aplicaci\xF3n",disabled:i}),x.name&&jsxRuntime.jsxs("p",{className:"mt-1 text-sm text-red-400 flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"w-4 h-4"}),x.name]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-sm font-medium mb-2 flex items-center gap-2",style:d,children:[jsxRuntime.jsx(lucideReact.Calendar,{className:"w-4 h-4"}),"Fecha de Inicio"]}),jsxRuntime.jsx("input",{type:"date",value:p.startDate?p.startDate.toISOString().split("T")[0]:"",onChange:f=>h("startDate",f.target.value?new Date(f.target.value):void 0),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:u,disabled:i||p.isMilestone})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-sm font-medium mb-2 flex items-center gap-2",style:d,children:[jsxRuntime.jsx(lucideReact.Calendar,{className:"w-4 h-4"}),"Fecha de Fin"]}),jsxRuntime.jsx("input",{type:"date",value:p.endDate?p.endDate.toISOString().split("T")[0]:"",onChange:f=>h("endDate",f.target.value?new Date(f.target.value):void 0),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:u,disabled:i||p.isMilestone}),x.endDate&&jsxRuntime.jsxs("p",{className:"mt-1 text-sm text-red-400 flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"w-4 h-4"}),x.endDate]})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-sm font-medium mb-2 flex items-center gap-2",style:d,children:[jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"w-4 h-4"}),"Estado"]}),jsxRuntime.jsxs("select",{value:p.status,onChange:f=>h("status",f.target.value),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:u,disabled:i,children:[jsxRuntime.jsx("option",{value:"todo",children:"Por Hacer"}),jsxRuntime.jsx("option",{value:"in-progress",children:"En Progreso"}),jsxRuntime.jsx("option",{value:"completed",children:"Completada"})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-sm font-medium mb-3 flex items-center gap-2",style:d,children:[jsxRuntime.jsx(lucideReact.Palette,{className:"w-4 h-4"}),"Color de la Tarea"]}),jsxRuntime.jsx(ql,{value:p.color,onChange:f=>h("color",f),disabled:i}),jsxRuntime.jsx("p",{className:"text-xs mt-2",style:{color:s.textTertiary},children:r?.parentId?"Esta subtarea hereda el color de su tarea padre":r?.subtasks&&r.subtasks.length>0?"Las subtareas heredar\xE1n este color con menor opacidad":"Elige un color para organizar visualmente tus tareas"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-sm font-medium mb-2 flex items-center justify-between",style:d,children:[jsxRuntime.jsxs("span",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-4 h-4"}),"Progreso"]}),jsxRuntime.jsxs("span",{className:"font-semibold px-2 py-0.5 rounded text-sm",style:{color:p.progress<30?"#EF4444":p.progress<70?"#F59E0B":"#10B981",backgroundColor:p.progress<30?"rgba(239, 68, 68, 0.1)":p.progress<70?"rgba(245, 158, 11, 0.1)":"rgba(16, 185, 129, 0.1)"},children:[p.progress,"%"]})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("input",{type:"range",min:"0",max:"100",step:"5",value:p.progress,onChange:f=>h("progress",parseInt(f.target.value)),className:"w-full h-2 rounded-lg appearance-none cursor-pointer",style:{backgroundColor:s.bgSecondary,accentColor:p.progress<30?"#EF4444":p.progress<70?"#F59E0B":"#10B981"},disabled:i}),jsxRuntime.jsx("div",{className:"absolute top-0 left-0 h-2 rounded-lg pointer-events-none transition-all duration-300",style:{width:`${p.progress}%`,backgroundColor:p.progress<30?"rgba(239, 68, 68, 0.3)":p.progress<70?"rgba(245, 158, 11, 0.3)":"rgba(16, 185, 129, 0.3)"}})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between mt-3 gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs",style:{color:s.textTertiary},children:"Accesos r\xE1pidos:"}),jsxRuntime.jsx("div",{className:"flex gap-1.5",children:[0,25,50,75,100].map(f=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>h("progress",f),disabled:i,className:"px-3 py-1 text-xs font-medium rounded-md transition-all duration-200 hover:scale-105 active:scale-95",style:{backgroundColor:p.progress===f?f<30?"#EF4444":f<70?"#F59E0B":"#10B981":s.bgSecondary,color:p.progress===f?"#FFFFFF":s.textSecondary,border:`1px solid ${p.progress===f?f<30?"#EF4444":f<70?"#F59E0B":"#10B981":s.borderLight}`},children:[f,"%"]},f))})]}),jsxRuntime.jsxs("div",{className:"flex justify-between text-xs mt-2",style:{color:s.textTertiary},children:[jsxRuntime.jsx("span",{children:"0%"}),jsxRuntime.jsx("span",{children:"25%"}),jsxRuntime.jsx("span",{children:"50%"}),jsxRuntime.jsx("span",{children:"75%"}),jsxRuntime.jsx("span",{children:"100%"})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 p-4 rounded-lg",style:{backgroundColor:s.bgSecondary,border:`1px solid ${s.borderLight}`},children:[jsxRuntime.jsx("input",{type:"checkbox",id:"isMilestone",checked:p.isMilestone,onChange:f=>h("isMilestone",f.target.checked),className:"w-4 h-4 rounded focus:ring-2",style:{accentColor:s.accent},disabled:i}),jsxRuntime.jsxs("label",{htmlFor:"isMilestone",className:"flex items-center gap-2 text-sm cursor-pointer",style:{color:s.textPrimary},children:[jsxRuntime.jsx(lucideReact.Milestone,{className:"w-4 h-4 text-yellow-500"}),"Marcar como Hito (Milestone)"]})]}),n.length>0&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-sm font-medium mb-2 flex items-center gap-2",style:d,children:[jsxRuntime.jsx(lucideReact.Users,{className:"w-4 h-4"}),"Asignar a"]}),jsxRuntime.jsx("div",{className:"space-y-2 max-h-32 overflow-y-auto p-3 rounded-lg",style:{backgroundColor:s.bgSecondary,border:`1px solid ${s.borderLight}`},children:n.map(f=>jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded",onMouseEnter:w=>w.currentTarget.style.backgroundColor=s.hoverBg,onMouseLeave:w=>w.currentTarget.style.backgroundColor="transparent",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:p.assignees?.some(w=>w.name===f.name),onChange:w=>{let k=w.target.checked?[...p.assignees||[],{name:f.name,avatar:f.avatar,initials:f.name.split(" ").map(y=>y[0]).join("").toUpperCase().slice(0,2),color:s.accent}]:(p.assignees||[]).filter(y=>y.name!==f.name);h("assignees",k);},className:"w-4 h-4 rounded",style:{accentColor:s.accent},disabled:i}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs text-white font-semibold",style:{backgroundColor:s.accent},children:f.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:s.textPrimary},children:f.name})]})]},f.id))})]}),a.length>0&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-sm font-medium mb-2 flex items-center gap-2",style:d,children:[jsxRuntime.jsx(lucideReact.Link2,{className:"w-4 h-4"}),"Dependencias"]}),jsxRuntime.jsx("div",{className:"space-y-2 max-h-32 overflow-y-auto p-3 rounded-lg",style:{backgroundColor:s.bgSecondary,border:`1px solid ${s.borderLight}`},children:a.filter(f=>f.id!==r?.id).map(f=>jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded",onMouseEnter:w=>w.currentTarget.style.backgroundColor=s.hoverBg,onMouseLeave:w=>w.currentTarget.style.backgroundColor="transparent",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:p.dependencies?.includes(f.id),onChange:w=>{let k=w.target.checked?[...p.dependencies||[],f.id]:(p.dependencies||[]).filter(y=>y!==f.id);h("dependencies",k);},className:"w-4 h-4 rounded",style:{accentColor:s.accent},disabled:i}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:s.textPrimary},children:f.name})]},f.id))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4",style:{borderTop:`1px solid ${s.border}`,backgroundColor:s.bgPrimary},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:s.textSecondary},onMouseEnter:f=>{f.currentTarget.style.color=s.textPrimary,f.currentTarget.style.backgroundColor=s.hoverBg;},onMouseLeave:f=>{f.currentTarget.style.color=s.textSecondary,f.currentTarget.style.backgroundColor="transparent";},disabled:i,children:"Cancelar"}),jsxRuntime.jsx("button",{onClick:g,disabled:i,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",style:{backgroundColor:s.accent,color:"#FFFFFF"},onMouseEnter:f=>!i&&(f.currentTarget.style.backgroundColor=s.accentHover),onMouseLeave:f=>!i&&(f.currentTarget.style.backgroundColor=s.accent),children:i?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"w-4 h-4"}),c==="create"?"Crear Tarea":"Guardar Cambios"]})})]})]})})]})})}var tg=['Move "Task Name" to next Monday','Extend "Task Name" by 3 days','Rename "Old Name" to "New Name"','Set "Task Name" progress to 50%','Link "Task A" to "Task B"','Create a new task called "New Task"','Delete "Task Name"','Assign John to "Task Name"'],rc=()=>jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),rg=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13"})}),ag=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M18 6L6 18M6 6L18 18"})}),ng=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M5 12h14"})}),og=()=>jsxRuntime.jsx("div",{className:"flex gap-1 items-center",children:[0,1,2].map(e=>jsxRuntime.jsx(framerMotion.motion.div,{className:"w-2 h-2 rounded-full bg-current",animate:{scale:[1,1.2,1],opacity:[.5,1,.5]},transition:{duration:.8,repeat:1/0,delay:e*.15}},e))});function $n({tasks:e,theme:t,config:r,onTasksUpdate:a,onTaskUpdate:n,onTaskCreate:o,onTaskDelete:i,onDependencyCreate:c,onDependencyDelete:l}){let[s,u]=we.useState(false),[d,p]=we.useState(false),[m,x]=we.useState([]),[b,v]=we.useState(""),[g,h]=we.useState(false),[f,w]=we.useState(true),k=we.useRef(null),y=we.useRef(null),C=we.useRef(null),{enabled:T=true,placeholder:D='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:R="bottom-right",onCommand:_,suggestions:G=tg,maxHistory:M=50}=r;we.useEffect(()=>{y.current&&y.current.scrollIntoView({behavior:"smooth"});},[m]),we.useEffect(()=>{s&&!d&&k.current&&setTimeout(()=>k.current?.focus(),100);},[s,d]);let O=we.useCallback(A=>{if(A.success)switch(A.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":A.taskId&&A.updates&&n?.(A.taskId,A.updates);break;case "create_task":A.newTask&&o?.(A.newTask);break;case "delete_task":A.taskId&&i?.(A.taskId);break;case "link_tasks":A.dependencyFrom&&A.dependencyTo&&c?.(A.dependencyFrom,A.dependencyTo);break;case "unlink_tasks":A.taskId&&A.dependencyFrom&&l?.(A.taskId,A.dependencyFrom);break}},[n,o,i,c,l]),E=we.useCallback(async A=>{if(!A.trim()||g)return;let te={id:`user-${Date.now()}`,role:"user",content:A,timestamp:new Date};x(fe=>[...fe.slice(-(M-1)),te]),v(""),w(false),h(true);let X={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};x(fe=>[...fe,X]);try{if(_){let fe=await _(A,e);x(P=>{let ge=P.filter(pt=>!pt.isLoading),ae={id:`assistant-${Date.now()}`,role:"assistant",content:fe.message,timestamp:new Date,command:fe};return [...ge,ae]}),O(fe);}else x(fe=>[...fe.filter(ge=>!ge.isLoading),{id:`assistant-${Date.now()}`,role:"assistant",content:"AI handler not configured. Please provide an onCommand handler in the aiAssistant config.",timestamp:new Date}]);}catch(fe){x(P=>[...P.filter(ae=>!ae.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${fe instanceof Error?fe.message:"Unknown error"}`,timestamp:new Date}]);}finally{h(false);}},[g,M,_,e,O]),B=A=>{A.preventDefault(),E(b);},z=A=>{v(A),k.current?.focus();};if(we.useEffect(()=>{let A=te=>{(te.metaKey||te.ctrlKey)&&te.key==="k"&&(te.preventDefault(),u(X=>!X),s||p(false)),te.key==="Escape"&&s&&u(false);};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[s]),!T)return null;let $={"bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-right":"top-4 right-4","top-left":"top-4 left-4"};return jsxRuntime.jsxs(Ke,{children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!s&&jsxRuntime.jsxs(framerMotion.motion.button,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},className:`fixed ${$[R]} z-[99999] flex items-center gap-2 px-4 py-3 rounded-full shadow-lg transition-colors`,style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"white",boxShadow:"0 4px 20px rgba(59, 130, 246, 0.4)"},onClick:()=>u(true),children:[jsxRuntime.jsx(rc,{}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),jsxRuntime.jsx("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono rounded bg-white/20",children:"\u2318K"})]})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:s&&jsxRuntime.jsxs(framerMotion.motion.div,{ref:C,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:d?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${$[R]} z-[99999] w-96 rounded-2xl overflow-hidden shadow-2xl flex flex-col`,style:{background:t.bgPrimary,border:`1px solid ${t.border}`,boxShadow:`0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px ${t.border}`},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-white",children:[jsxRuntime.jsx(rc,{}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{onClick:()=>p(A=>!A),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(ng,{})}),jsxRuntime.jsx("button",{onClick:()=>u(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(ag,{})})]})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!d&&jsxRuntime.jsxs(framerMotion.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"flex flex-col flex-1 min-h-0",children:[jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[m.length===0&&f&&jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("p",{className:"text-sm text-center",style:{color:t.textSecondary},children:"Try asking me to edit your Gantt chart:"}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:G.slice(0,4).map((A,te)=>jsxRuntime.jsx("button",{onClick:()=>z(A),className:"text-xs px-3 py-1.5 rounded-full transition-colors",style:{background:t.bgSecondary,color:t.textSecondary,border:`1px solid ${t.border}`},children:A.length>30?A.slice(0,30)+"...":A},te))})]}),m.map(A=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${A.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${A.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:A.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:A.role==="user"?"white":t.textPrimary},children:[A.isLoading?jsxRuntime.jsx(og,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:A.content}),A.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:A.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:A.command.success?"#10B981":"#EF4444"},children:[A.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:A.command.type.replace(/_/g," ")})]})]})},A.id)),jsxRuntime.jsx("div",{ref:y})]}),jsxRuntime.jsxs("form",{onSubmit:B,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsxRuntime.jsx("input",{ref:k,type:"text",value:b,onChange:A=>v(A.target.value),placeholder:D,disabled:g,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsxRuntime.jsx("button",{type:"submit",disabled:!b.trim()||g,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:b.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:b.trim()?"white":t.textSecondary},children:jsxRuntime.jsx(rg,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function ac(e,t=50){let[r,a]=we.useState({past:[],present:e,future:[]}),n=we.useRef(false),o=we.useCallback((s,u=true)=>{a(d=>{let p=typeof s=="function"?s(d.present):s;if(n.current)return {...d,present:p};if(!u)return {...d,present:p};let m=[...d.past,d.present];return m.length>t&&m.shift(),{past:m,present:p,future:[]}});},[t]),i=we.useCallback(()=>{a(s=>{if(s.past.length===0)return s;let u=s.past[s.past.length-1],d=s.past.slice(0,s.past.length-1);return n.current=true,setTimeout(()=>{n.current=false;},0),{past:d,present:u,future:[s.present,...s.future]}});},[]),c=we.useCallback(()=>{a(s=>{if(s.future.length===0)return s;let u=s.future[0],d=s.future.slice(1);return n.current=true,setTimeout(()=>{n.current=false;},0),{past:[...s.past,s.present],present:u,future:d}});},[]),l=we.useCallback(()=>{a(s=>({past:[],present:s.present,future:[]}));},[]);return {state:r.present,setState:o,undo:i,redo:c,canUndo:r.past.length>0,canRedo:r.future.length>0,clearHistory:l}}function nc({undo:e,redo:t,canUndo:r,canRedo:a,enabled:n=true}){we.useEffect(()=>{if(!n)return;let o=i=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,l=c?i.metaKey:i.ctrlKey;if(l&&i.key==="z"&&!i.shiftKey&&r){i.preventDefault(),e();return}if(a){if(!c&&l&&i.key==="y"){i.preventDefault(),t();return}if(c&&l&&i.shiftKey&&i.key==="z"){i.preventDefault(),t();return}}};return window.addEventListener("keydown",o),()=>{window.removeEventListener("keydown",o);}},[e,t,r,a,n]);}var cg={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${K.formatDate(e.startDate)} - ${K.formatDate(e.endDate)}`);let r=K.calculateDuration(e.startDate,e.endDate);t.push(`Duration: ${r} days`);}if(e.progress!==void 0&&t.push(`Progress: ${e.progress}%`),e.status&&t.push(`Status: ${e.status}`),e.assignees&&e.assignees.length>0){let r=e.assignees.map(a=>a.name).join(", ");t.push(`Assigned: ${r}`);}return e.dependencies&&e.dependencies.length>0&&t.push(`Dependencies: ${e.dependencies.length}`),t.join("<br/>")},taskLabel:e=>e.name,gridCell:(e,t,r)=>r,taskClass:e=>{let t=[];return e.isCriticalPath&&t.push("critical-path"),e.status==="completed"?t.push("completed"):e.status==="in-progress"?t.push("in-progress"):e.status==="todo"&&t.push("todo"),e.isMilestone&&t.push("milestone"),t.join(" ")},milestoneContent:e=>`\u25C6 ${e.name}`,dateFormat:e=>K.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function oc(e){return {...cg,...e}}var fg=e=>{switch(e){case "compact":return 40;case "comfortable":return 48;case "spacious":return 56;default:return 48}},lc=we.forwardRef(function({tasks:t,config:r={},onTasksChange:a},n){let{theme:o,timeScale:i="week",rowDensity:c="comfortable",showThemeSelector:l=true,showExportButton:s=true,availableUsers:u=[],templates:d,enableAutoCriticalPath:p=true,aiAssistant:m,showCreateTaskButton:x=false,createTaskLabel:b,onCreateTask:v,onThemeChange:g,onTaskClick:h,onTaskDblClick:f,onTaskContextMenu:w,onTaskUpdate:k,onProgressChange:y,onDependencyCreate:C,onDependencyDelete:T,onBeforeTaskAdd:D,onAfterTaskAdd:R,onBeforeTaskUpdate:_,onAfterTaskUpdate:G}=r,O=we.useContext(Sn)?.theme,[E,B]=we.useState(O||o||"dark"),[z,$]=we.useState(i),[A,te]=we.useState(c),[X,fe]=we.useState(1),[P,ge]=we.useState(0),[ae,pt]=we.useState(false),[ct,Bt]=we.useState(null),[ie,mt]=we.useState({isOpen:false,x:0,y:0,task:null}),[vt,Ot]=we.useState(null);we.useEffect(()=>{O&&O!==E&&B(O);},[O]),we.useEffect(()=>{o&&o!==E&&B(o);},[o]);let ar=we.useCallback(N=>{B(N),g?.(N);},[g]),{state:ne,setState:se,undo:Qe,redo:Ht,canUndo:Vt,canRedo:ur,clearHistory:zt}=ac(t,50);we.useEffect(()=>{se(t);},[t,se]),we.useEffect(()=>{a&&a(ne);},[ne,a]);let[V,U]=we.useState([{id:"name",label:"TASK NAME",width:320,minWidth:180,maxWidth:800,visible:true,sortable:true,resizable:true},{id:"startDate",label:"Start Date",width:110,visible:false,sortable:true},{id:"endDate",label:"End Date",width:110,visible:false,sortable:true},{id:"duration",label:"Duration",width:80,visible:false,sortable:true},{id:"assignees",label:"Assignees",width:120,visible:false,sortable:false},{id:"status",label:"Status",width:80,visible:false,sortable:true},{id:"progress",label:"% Complete",width:120,visible:false,sortable:true}]),Se=we.useMemo(()=>V.filter(N=>N.visible).reduce((N,I)=>N+I.width,0)+60,[V]),ze=ct||Se,Ne=we.useRef(null),de=we.useRef(null),ue=we.useRef(null),Ve=we.useMemo(()=>Sl(E),[E]),le=we.useMemo(()=>({theme:Ve,themeName:E}),[Ve,E]),be=we.useMemo(()=>oc(d),[d]),j=we.useMemo(()=>{if(!p)return ne;let N=K.calculateCriticalPath(ne),I=W=>W.map(J=>({...J,isCriticalPath:N.includes(J.id),subtasks:J.subtasks?I(J.subtasks):void 0}));return I(ne)},[ne,p]),ye=fg(A);nc({undo:Qe,redo:Ht,canUndo:Vt,canRedo:ur,enabled:true}),we.useImperativeHandle(n,()=>({getTask:N=>K.findTaskById(ne,N),addTask:(N,I)=>{se(W=>{if(!I)return [...W,{...N,level:0}];let J=ee=>ee.map(oe=>oe.id===I?{...oe,subtasks:[...oe.subtasks||[],{...N,parentId:I,level:(oe.level||0)+1}],isExpanded:true}:oe.subtasks?{...oe,subtasks:J(oe.subtasks)}:oe);return J(W)});},updateTask:(N,I)=>{se(W=>{let J=ee=>ee.map(oe=>oe.id===N?{...oe,...I}:oe.subtasks?{...oe,subtasks:J(oe.subtasks)}:oe);return J(W)});},deleteTask:N=>{se(I=>{let W=J=>J.filter(ee=>ee.id===N?false:(ee.subtasks&&(ee.subtasks=W(ee.subtasks)),true));return W(I)});},deleteTasks:N=>{se(I=>En(I,N));},duplicateTask:N=>{se(I=>ts(I,[N]));},splitTask:(N,I,W=3)=>{se(J=>K.splitTask(J,N,I,W));},calculateEndDate:K.calculateEndDate,calculateDuration:K.calculateDuration,validateDependency:(N,I)=>!K.validateDependencies(ne,N,I),getAllTasks:()=>K.flattenTasks(ne),getTasksByStatus:N=>K.flattenTasks(ne).filter(I=>I.status===N),getTasksByParent:N=>N?K.findTaskById(ne,N)?.subtasks||[]:ne.filter(W=>!W.parentId),getCriticalPath:()=>K.flattenTasks(ne).filter(N=>N.isCriticalPath),indentTask:N=>{se(I=>Zo(I,[N]));},outdentTask:N=>{se(I=>Qo(I,[N]));},moveTask:(N,I)=>{se(W=>es(W,[N],I));},createSubtask:async N=>{let{tasks:I,newTask:W}=ns(ne,N);if(D){let J=D({...W,parentId:N});if((J instanceof Promise?await J:J)===false)return}se(I),R&&R({...W,parentId:N});},scrollToTask:N=>{let W=K.flattenTasks(ne).findIndex(J=>J.id===N);if(W!==-1&&Ne.current){let J=W*ye;Ne.current.scrollTo({top:J,behavior:"smooth"}),de.current&&de.current.scrollTo({top:J,behavior:"smooth"});}},highlightTask:(N,I=2e3)=>{},expandTask:N=>{se(I=>{let W=J=>J.map(ee=>ee.id===N?{...ee,isExpanded:true}:ee.subtasks?{...ee,subtasks:W(ee.subtasks)}:ee);return W(I)});},collapseTask:N=>{se(I=>{let W=J=>J.map(ee=>ee.id===N?{...ee,isExpanded:false}:ee.subtasks?{...ee,subtasks:W(ee.subtasks)}:ee);return W(I)});},expandAll:()=>{se(N=>{let I=W=>W.map(J=>({...J,isExpanded:true,subtasks:J.subtasks?I(J.subtasks):void 0}));return I(N)});},collapseAll:()=>{se(N=>{let I=W=>W.map(J=>({...J,isExpanded:false,subtasks:J.subtasks?I(J.subtasks):void 0}));return I(N)});},undo:Qe,redo:Ht,canUndo:()=>Vt,canRedo:()=>ur,clearHistory:zt,exportToPNG:async()=>{if(!ue.current)throw new Error("Gantt container not found");let N=await sc__default.default(ue.current,{backgroundColor:Ve.bgPrimary,scale:2});return new Promise((I,W)=>{N.toBlob(J=>{J?I(J):W(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async N=>{await K.exportToPDF(ne,N);},exportToExcel:async N=>{await K.exportToExcel(ne,N);},exportToJSON:()=>K.exportToJSON(ne),exportToCSV:()=>K.exportToCSV(ne),importFromJSON:N=>{let I=K.importFromJSON(N);se(I);},getTasks:()=>ne,refresh:()=>{se(N=>[...N]);},clearAll:()=>{se([]);}}),[ne,Qe,Ht,Vt,ur,zt,Ve,ye]);let S=we.useCallback(N=>{U(I=>I.map(W=>W.id===N?{...W,visible:!W.visible}:W));},[]),H=we.useCallback((N,I)=>{U(W=>W.map(J=>{if(J.id!==N)return J;let ee=J.minWidth??100,oe=J.maxWidth??800,et=Math.max(ee,Math.min(oe,I));return {...J,width:et}}));},[]),pe=we.useCallback(N=>{se(I=>as(I,N)),r.onTaskToggleExpand?.(N);},[r]),Ee=we.useCallback((N,I)=>{if(_&&_(N,I)===false)return;let J=K.findTaskById(ne,N)?.progress,ee=et=>et.map(nt=>nt.id===N?{...nt,...I}:nt.subtasks?{...nt,subtasks:ee(nt.subtasks)}:nt);se(ee(ne));let oe=K.findTaskById(ee(ne),N);oe&&(k?.(oe),G?.(oe),I.progress!==void 0&&J!==void 0&&I.progress!==J&&y?.(N,J,I.progress));},[ne,k,_,G,y]),Fe=we.useCallback(N=>{N.length!==0&&(se(I=>Zo(I,N)),r.onTaskIndent?.(N[0]));},[r]),We=we.useCallback(N=>{N.length!==0&&(se(I=>Qo(I,N)),r.onTaskOutdent?.(N[0]));},[r]),Mt=we.useCallback((N,I)=>{N.length!==0&&(se(W=>es(W,N,I)),r.onTaskMove?.(N[0],I));},[r]),$t=we.useCallback(N=>{r.onMultiTaskDelete?r.onMultiTaskDelete(N):(se(I=>En(I,N)),N.forEach(I=>r.onTaskDelete?.(I)));},[r]),qn=we.useCallback(N=>{se(I=>ts(I,N)),N.forEach(I=>r.onTaskDuplicate?.(I));},[r]),ga=we.useCallback((N,I)=>{se(W=>{let{tasks:J,newTask:ee}=Ol(W,N,I);return D&&D(ee)===false?W:(r.onTaskCreate?.(ee.parentId,ee.position||0),R?.(ee),J)});},[r,D,R]),ha=we.useCallback((N,I)=>{se(W=>rs(W,N,I)),r.onTaskRename?.(N,I);},[r]),ld=we.useCallback(N=>{se(I=>{let{tasks:W}=ns(I,N);return r.onTaskCreate?.(N,0),W});},[r]),cd=we.useCallback((N,I,W)=>{let J=N.startDate?Math.round((I.getTime()-N.startDate.getTime())/864e5):0,ee=nt=>nt.map(pr=>pr.id===N.id?{...pr,startDate:I,endDate:W,...N.segments&&{segments:N.segments}}:pr.subtasks?{...pr,subtasks:ee(pr.subtasks)}:pr),oe=ee(ne);oe=K.autoScheduleDependents(oe,N.id,J),se(oe);let et={...N,startDate:I,endDate:W};k?.(et);},[ne,k]),dd=we.useCallback((N,I)=>{w?.(N,I),mt({isOpen:true,x:I.clientX,y:I.clientY,task:N});},[w]),ud=we.useCallback((N,I)=>{let W=K.splitTask(ne,N.id,I);se(W),mt({isOpen:false,x:0,y:0,task:null});},[ne]),Hs=we.useCallback(N=>{f?.(N),Ot(N);},[f]),Vs=we.useCallback((N,I,W)=>{let J=new Map,ee=Lr=>{Lr.forEach(Fr=>{Fr.dependencies&&J.set(Fr.id,Fr.dependencies),Fr.subtasks&&ee(Fr.subtasks);});};ee(W);let oe=J.get(I)||[];J.set(I,[...oe,N]);let et=new Set,nt=new Set,pr=Lr=>{if(!et.has(Lr)){et.add(Lr),nt.add(Lr);let Fr=J.get(Lr)||[];for(let Xn of Fr){if(!et.has(Xn)&&pr(Xn))return true;if(nt.has(Xn))return true}}return nt.delete(Lr),false};return pr(I)},[]),Ks=we.useCallback((N,I)=>{if(Vs(N.id,I,ne)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
277
277
 
278
278
  Task dependencies must flow in one direction only.`);return}let W=J=>J.map(ee=>{if(ee.id===I){let oe=ee.dependencies||[];if(!oe.includes(N.id))return {...ee,dependencies:[...oe,N.id]}}return ee.subtasks?{...ee,subtasks:W(ee.subtasks)}:ee});se(W(ne)),C?.(N.id,I);},[ne,C,Vs]),js=we.useCallback((N,I)=>{let W=J=>J.map(ee=>{if(ee.id===N&&ee.dependencies){let oe=ee.dependencies.filter(et=>et!==I);return {...ee,dependencies:oe}}return ee.subtasks?{...ee,subtasks:W(ee.subtasks)}:ee});se(W(ne)),T?.(N,I);},[ne,T]),{startDate:pd,endDate:md}=we.useMemo(()=>{let N=ne.filter(oe=>oe.startDate&&oe.endDate);if(N.length===0){let oe=new Date,et=new Date(oe);et.setDate(et.getDate()-30);let nt=new Date(oe);return nt.setDate(nt.getDate()+60),{startDate:et,endDate:nt}}let I=N.flatMap(oe=>[oe.startDate,oe.endDate]).filter(oe=>oe!==void 0),W=new Date(Math.min(...I.map(oe=>oe.getTime()))),J=new Date(Math.max(...I.map(oe=>oe.getTime()))),ee=z==="day"?7:z==="week"?14:30;return W.setDate(W.getDate()-ee),J.setDate(J.getDate()+ee),{startDate:W,endDate:J}},[ne,z]),fd=we.useCallback(async()=>{if(!ue.current)return;let N=await sc__default.default(ue.current,{backgroundColor:Ve.bgPrimary,scale:2}),I=document.createElement("a");I.download="gantt-chart.png",I.href=N.toDataURL("image/png"),I.click();},[Ve]),gd=we.useCallback(async()=>{await K.exportToPDF(ne);},[ne]),hd=we.useCallback(async()=>{await K.exportToExcel(ne);},[ne]),vd=we.useCallback(()=>{let N=K.exportToCSV(ne),I=new Blob([N],{type:"text/csv;charset=utf-8;"}),W=document.createElement("a");W.href=URL.createObjectURL(I),W.download="gantt-chart.csv",W.click(),URL.revokeObjectURL(W.href);},[ne]),bd=we.useCallback(()=>{let N=K.exportToJSON(ne),I=new Blob([N],{type:"application/json;charset=utf-8;"}),W=document.createElement("a");W.href=URL.createObjectURL(I),W.download="gantt-chart.json",W.click(),URL.revokeObjectURL(W.href);},[ne]),yd=we.useCallback(()=>{K.exportToMSProject(ne,"Gantt Project","project.xml");},[ne]),xd=N=>{N.preventDefault(),pt(true);};return we.useEffect(()=>{let N=de.current,I=Ne.current;if(!N||!I)return;let W=I.querySelector(".gantt-taskgrid-content"),J=()=>{let et=N.scrollTop;ge(et),W&&(W.style.transform=`translateY(-${et}px)`);},ee=et=>{if(ae){let nt=et.clientX;nt>300&&nt<window.innerWidth-400&&Bt(nt);}},oe=()=>{pt(false);};return N.addEventListener("scroll",J),document.addEventListener("mousemove",ee),document.addEventListener("mouseup",oe),()=>{N.removeEventListener("scroll",J),document.removeEventListener("mousemove",ee),document.removeEventListener("mouseup",oe);}},[ae]),jsxRuntime.jsx(go.Provider,{value:le,children:jsxRuntime.jsxs("div",{ref:ue,className:"flex flex-col h-full w-full",style:{backgroundColor:Ve.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...r.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsxRuntime.jsx(Dn,{theme:Ve,timeScale:z,onTimeScaleChange:$,zoom:X,onZoomChange:fe,currentTheme:E,onThemeChange:ar,rowDensity:A,onRowDensityChange:te,showThemeSelector:l,showCreateTaskButton:x,createTaskLabel:b,onCreateTask:v,onExportPNG:s?fd:void 0,onExportPDF:s?gd:void 0,onExportExcel:s?hd:void 0,onExportCSV:s?vd:void 0,onExportJSON:s?bd:void 0,onExportMSProject:s?yd:void 0}),jsxRuntime.jsxs("div",{ref:Ne,className:"flex-1 flex min-h-0",style:{overflow:"hidden"},children:[jsxRuntime.jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:ze,overflow:"hidden"},children:jsxRuntime.jsx(Rn,{tasks:j,theme:Ve,rowHeight:ye,availableUsers:u,templates:be,onTaskClick:h,onTaskDblClick:Hs,onTaskContextMenu:w,onTaskToggle:pe,scrollTop:P,columns:V,onToggleColumn:S,onColumnResize:H,onTaskUpdate:Ee,onTaskIndent:Fe,onTaskOutdent:We,onTaskMove:Mt,onMultiTaskDelete:$t,onTaskDuplicate:qn,onTaskCreate:ga,onTaskRename:ha,onCreateSubtask:ld,onOpenTaskModal:h?N=>h(N):void 0})}),jsxRuntime.jsx("div",{className:"relative flex-shrink-0 cursor-col-resize group",style:{width:8,backgroundColor:ae?Ve.accent:Ve.border,transition:"background-color 0.2s"},onMouseDown:xd,children:jsxRuntime.jsx(framerMotion.motion.div,{className:"absolute inset-y-0 left-1/2 -translate-x-1/2",style:{width:2,backgroundColor:Ve.accent},initial:{opacity:0},animate:{opacity:ae?1:0},whileHover:{opacity:1}})}),jsxRuntime.jsx("div",{ref:de,className:"gantt-timeline-scroll flex-1 overflow-auto",style:{minHeight:0,...r.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsxRuntime.jsx(On,{tasks:j,theme:Ve,rowHeight:ye,timeScale:z,startDate:pd,endDate:md,zoom:X,templates:be,onTaskClick:h,onTaskDblClick:Hs,onTaskContextMenu:dd,onTaskDateChange:cd,onDependencyCreate:Ks,onDependencyDelete:js})})]}),ie.task&&jsxRuntime.jsx(ca,{isOpen:ie.isOpen,x:ie.x,y:ie.y,theme:Ve,onClose:()=>mt({isOpen:false,x:0,y:0,task:null}),items:[{id:"split",label:"Split Task",icon:Pt.Split,onClick:()=>{if(!ie.task?.startDate||!ie.task?.endDate){console.warn("Cannot split task without dates");return}let N=ie.task.startDate.getTime(),I=ie.task.endDate.getTime(),W=N+(I-N)/2,J=new Date(W);ud(ie.task,J);},disabled:!ie.task?.startDate||!ie.task?.endDate}]}),vt&&jsxRuntime.jsx(zn,{isOpen:true,onClose:()=>Ot(null),task:vt,onSubmit:N=>{Ee(vt.id,N),Ot(null);},mode:"edit",theme:E}),m?.enabled&&jsxRuntime.jsx($n,{tasks:ne,theme:Ve,config:m,onTasksUpdate:se,onTaskUpdate:Ee,onTaskCreate:N=>{se(I=>[...I,N]);},onTaskDelete:N=>{se(I=>En(I,[N]));},onDependencyCreate:(N,I)=>{let W=K.findTaskById(ne,N);W&&Ks(W,I);},onDependencyDelete:js})]})})});var cc=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
279
279