@libxai/board 0.17.34 → 0.17.35
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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -273,7 +273,7 @@
|
|
|
273
273
|
</Calendars>
|
|
274
274
|
<Tasks>${p}
|
|
275
275
|
</Tasks>
|
|
276
|
-
</Project>`,c=new Blob([n],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(c),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=V.flattenTasks(e),a=t.filter(n=>n.startDate&&n.endDate);if(a.length===0)return [];let r=new Map,o=n=>{if(r.has(n.id))return;let c=n.startDate&&n.endDate?V.calculateDuration(n.startDate,n.endDate):0,d=0;if(n.dependencies&&n.dependencies.length>0)for(let u of n.dependencies){let v=t.find(x=>x.id===u);if(v){o(v);let x=r.get(u)?.ef||0;d=Math.max(d,x);}}let i=d+c;r.set(n.id,{es:d,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(n=>n.ef)),l=new Map,m=n=>{if(l.has(n.id))return;let c=n.startDate&&n.endDate?V.calculateDuration(n.startDate,n.endDate):0,d=t.filter(v=>v.dependencies&&v.dependencies.includes(n.id)),i=s;if(d.length>0)for(let v of d){m(v);let x=l.get(v.id)?.ls||0;i=Math.min(i,x);}let u=i-c;l.set(n.id,{ls:u,lf:i});};a.forEach(m);let p=[];for(let n of a){let c=r.get(n.id),d=l.get(n.id);if(c&&d){let i=d.ls-c.es;Math.abs(i)<.01&&p.push(n.id);}}return p},calculateSlack:(e,t)=>{let a=V.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(V.calculateCriticalPath(e).includes(t))return 0;let o=V.getDependentTasks(e,t);if(o.length===0){let m=V.getLatestEndDate(e);if(!m)return null;let p=V.calculateDuration(a.endDate,m);return Math.max(0,p)}let s=o.filter(m=>m.startDate).map(m=>m.startDate.getTime()).sort((m,p)=>m-p)[0];if(!s)return null;let l=V.calculateDuration(a.endDate,new Date(s));return Math.max(0,l)},isOnCriticalPath:(e,t)=>V.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=V.findTaskById(e,t);if(!r||!r.endDate)return e;let o=V.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let l of o){if(!l.startDate||!l.endDate)continue;let m=V.calculateDuration(l.startDate,l.endDate),p;a!==void 0?(p=new Date(l.startDate),p.setDate(p.getDate()+a)):(p=new Date(r.endDate),p.setDate(p.getDate()+1));let n=V.calculateEndDate(p,m),c=d=>d.map(i=>i.id===l.id?{...i,startDate:p,endDate:n}:i.subtasks?{...i,subtasks:c(i.subtasks)}:i);s=c(s),s=V.autoScheduleDependents(s,l.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,l,m)=>{if(a===0)return [];let p=[],n=o.getTime(),c=1e3*60*60*24,d=V.findTaskById(e,t);if(!d||!d.endDate)return [];let i=(u,v,x=new Set)=>{if(x.has(u))return;x.add(u);let y=V.getDependentTasks(e,u);for(let h of y){if(!h.startDate||!h.endDate)continue;let f=r.findIndex(z=>z.id===h.id);if(f===-1)continue;let g=h.startDate.getTime(),T=(h.endDate.getTime()-g)/c,N=(g-n)/c*s,k=N+v*s,S=Math.max(T*s,s),w=m+f*l+12;p.push({taskId:h.id,taskName:h.name,originalX:N,previewX:k,width:S,y:w,rowIndex:f,daysDelta:v,color:h.color}),i(h.id,v,x);}};return i(t,a),p},splitTask:(e,t,a,r=3)=>{let o=V.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let l=new Date(a);l.setDate(l.getDate()+r);let m=new Date(o.endDate);m.setDate(m.getDate()+r);let p=[{startDate:new Date(o.startDate),endDate:s},{startDate:l,endDate:m}],n=c=>c.map(d=>d.id===o.id?{...d,endDate:m,segments:p}:d.subtasks?{...d,subtasks:n(d.subtasks)}:d);return n(e)}};function lo({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:l,templates:m,onTaskClick:p,onTaskDblClick:n,onTaskContextMenu:c,onTaskDateChange:d,onDependencyCreate:i,onDependencyDelete:u}){let[x,y]=react.useState([]),h=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),f=r==="day"?60:r==="week"?20:8,g=h*f*l,C=E=>{let G=new Date(Date.UTC(E.getFullYear(),E.getMonth(),E.getDate())),J=G.getUTCDay()||7;G.setUTCDate(G.getUTCDate()+4-J);let Z=new Date(Date.UTC(G.getUTCFullYear(),0,1));return Math.ceil(((G.getTime()-Z.getTime())/864e5+1)/7)},T=E=>{let G=E.getDay();return G===0||G===6},b=react.useCallback(E=>{let G=Math.round(E/(f*l)),J=new Date(o);return J.setDate(J.getDate()+G),J},[o,f,l]),N=react.useCallback((E,G)=>{if(G.startDate&&G.endDate)return;let J=E.currentTarget.ownerSVGElement;if(!J)return;let Z=J.createSVGPoint();Z.x=E.clientX,Z.y=E.clientY;let O=Z.matrixTransform(J.getScreenCTM()?.inverse()),ee=b(O.x),H=new Date(ee);H.setDate(H.getDate()+1),d?.(G,ee,H);},[b,d]),k=react.useMemo(()=>{let E=O=>O.map(ee=>{if(ee.subtasks&&ee.subtasks.length>0){let H=E(ee.subtasks),le=H.filter(M=>M.startDate&&M.endDate);if(le.length>0){let M=le.map(Je=>Je.startDate.getTime()),fe=le.map(Je=>Je.endDate.getTime()),oe=new Date(Math.min(...M)),qe=new Date(Math.max(...fe));return {...ee,subtasks:H,startDate:ee.startDate||oe,endDate:ee.endDate||qe}}return {...ee,subtasks:H}}return ee}),G=(O,ee=[])=>{for(let H of O)ee.push(H),H.subtasks&&H.subtasks.length>0&&(H.isExpanded===void 0||H.isExpanded)&&G(H.subtasks,ee);return ee},J=E(e);return G(J)},[e]),S=react.useCallback(E=>{if(!E.startDate||!E.endDate)return {x:0,width:0};let G=E.startDate.getTime(),J=E.endDate.getTime(),Z=o.getTime(),O=(G-Z)/(1e3*60*60*24),ee=(J-G)/(1e3*60*60*24),H=O*f*l,le=Math.max(f*l,40),M=Math.max(ee*f*l,le);return {x:H,width:M}},[o,f,l]),w=react.useMemo(()=>k.filter(E=>E.startDate&&E.endDate).map(E=>{let{x:G,width:J}=S(E),O=k.findIndex(ee=>ee.id===E.id)*a+12;return {id:E.id,x:G,y:O,width:J,height:32}}),[k,S]),z=react.useCallback((E,G,J)=>{if(!J||G===0){y([]);return}let Z=V.calculateCascadePreview(e,E,G,k,o,f*l,a,48);y(Z);},[e,k,o,f,l,a,48]),$=react.useMemo(()=>{let E=[],G=new Date(o);for(;G<=s;){let O=(G.getTime()-o.getTime())/864e5*f*l;if(r==="day")E.push({date:new Date(G),label:G.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:O}),G.setDate(G.getDate()+1);else if(r==="week"){let ee=C(G);E.push({date:new Date(G),label:`Week ${ee}`,x:O}),G.setDate(G.getDate()+7);}else E.push({date:new Date(G),label:G.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:O}),G.setMonth(G.getMonth()+1);}return E},[o,s,r,f,l]),F=react.useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*f*l,[o,f,l]),_=Math.max(k.length*a,552);return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary,overflow:"visible"},children:[jsxRuntime.jsx("div",{style:{position:"sticky",top:0,zIndex:10,backgroundColor:t.bgGrid,flexShrink:0,height:"48px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:jsxRuntime.jsxs("svg",{width:Math.max(g,1e3),height:47,style:{display:"block"},children:[jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(g,1e3),height:48,fill:t.bgGrid}),$.map((E,G)=>jsxRuntime.jsxs("g",{children:[G>0&&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-${G}`)),F>=0&&F<=g&&jsxRuntime.jsx("circle",{cx:F,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(g,1e3),height:_,style:{display:"block",flexShrink:0,overflow:"visible"},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(g,1e3),height:_,fill:t.bgPrimary}),$.map((E,G)=>{let J=$[G+1]?.x||g,Z=T(E.date);return jsxRuntime.jsxs("g",{children:[Z&&jsxRuntime.jsx("rect",{x:E.x,y:0,width:J-E.x,height:k.length*a,fill:t.bgWeekend,opacity:1}),G>0&&jsxRuntime.jsx("line",{x1:E.x,y1:0,x2:E.x,y2:k.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},G)}),F>=0&&F<=g&&jsxRuntime.jsx("line",{x1:F,y1:0,x2:F,y2:k.length*a,stroke:t.today,strokeWidth:2,opacity:1}),k.map((E,G)=>{let J=E.startDate&&E.endDate;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:0,y:G*a,width:g,height:a,fill:G%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${E.id}`),!J&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:0,y:G*a,width:g,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:Z=>N(Z,E),onMouseEnter:Z=>{Z.currentTarget.setAttribute("fill",t.accentLight),Z.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:Z=>{Z.currentTarget.setAttribute("fill","transparent"),Z.currentTarget.setAttribute("opacity","1");}},`clickable-${E.id}`),jsxRuntime.jsx("text",{x:F>0?F:100,y:G*a+a/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}`)}),k.map((E,G)=>!E.dependencies||E.dependencies.length===0||!E.startDate||!E.endDate?null:E.dependencies.map(J=>{let Z=k.find(le=>le.id===J);if(!Z||!Z.startDate||!Z.endDate)return null;let O=k.findIndex(le=>le.id===J),ee=S(Z),H=S(E);return jsxRuntime.jsx(ro,{x1:ee.x+ee.width,y1:O*a+a/2,x2:H.x,y2:G*a+a/2,theme:t,onDelete:()=>u?.(E.id,J)},`dep-${J}-${E.id}`)})),k.map((E,G)=>{if(!E.startDate||!E.endDate)return null;let{x:J,width:Z}=S(E),O=G*a+12,ee=E.subtasks&&E.subtasks.length>0&&!E.isMilestone;return E.isMilestone?jsxRuntime.jsx(no,{task:E,x:J+Z/2,y:O+16,theme:t,onClick:p},E.id):ee?jsxRuntime.jsxs("g",{onClick:()=>p?.(E),style:{cursor:"pointer"},children:[jsxRuntime.jsx("rect",{x:J,y:O,width:Z,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:J,y1:O,x2:J+Z,y2:O,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:J,y1:O,x2:J,y2:O+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:J+Z,y1:O,x2:J+Z,y2:O+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:J,y1:O+32,x2:J+Z,y2:O+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),Z>60&&jsxRuntime.jsx("text",{x:J+12,y:O+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(to,{task:E,x:J,y:O,width:Z,theme:t,dayWidth:f*l,startDate:o,templates:m,onClick:p,onDoubleClick:n,onContextMenu:c,onDateChange:d,onDependencyCreate:i,allTaskPositions:w,onDragMove:z},E.id)}),x.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 il=[{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 ll({value:e="#6366F1",onChange:t,disabled:a=false}){return jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:il.map(r=>{let o=e===r.value;return jsxRuntime.jsx(framerMotion.motion.button,{type:"button",onClick:()=>!a&&t(r.value),className:"relative rounded-full transition-all focus:outline-none focus:ring-2 focus:ring-offset-2",style:{width:"32px",height:"32px",backgroundColor:r.value,boxShadow:o?`0 0 0 2px #FFFFFF, 0 0 0 4px ${r.value}`:"0 1px 3px rgba(0, 0, 0, 0.12)",opacity:a?.5:1,cursor:a?"not-allowed":"pointer"},whileHover:a?{}:{scale:1.1},whileTap:a?{}:{scale:.95},title:r.name,disabled:a,children:o&&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})})},r.value)})}),e&&jsxRuntime.jsx("div",{className:"text-xs text-center font-medium",style:{color:e},children:il.find(r=>r.value===e)?.name||"Personalizado"})]})}function co({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:l=false,mode:m=a?"edit":"create",theme:p="dark"}){let n=De[p]||De.dark,c={backgroundColor:n.bgSecondary,border:`1px solid ${n.borderLight}`,color:n.textPrimary},d={color:n.textSecondary},[i,u]=react.useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),[v,x]=react.useState({});react.useEffect(()=>{u(a?{name:a.name,description:a.description||"",startDate:a.startDate,endDate:a.endDate,progress:a.progress,status:a.status||"todo",priority:a.priority||"medium",isMilestone:a.isMilestone||false,color:a.color||"#6366F1",assignees:a.assignees||[],dependencies:a.dependencies||[]}:{name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]});},[a,e]);let y=()=>{let g={};return i.name.trim()||(g.name="El nombre es requerido"),i.startDate&&i.endDate&&i.startDate>i.endDate&&(g.endDate="La fecha de fin debe ser posterior a la de inicio"),x(g),Object.keys(g).length===0},h=async g=>{if(g.preventDefault(),!!y())try{await s(i),t();}catch(C){console.error("Error submitting task:",C);}},f=(g,C)=>{u(T=>{let b={...T,[g]:C};if(g==="progress"){let N=typeof C=="number"?C:parseInt(C,10);N===100&&T.status!=="completed"?b.status="completed":N>0&&N<100&&T.status==="todo"?b.status="in-progress":N===0&&T.status==="in-progress"&&(b.status="todo");}return b}),v[g]&&x(T=>{let b={...T};return delete b[g],b});};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:n.bgPrimary,border:`1px solid ${n.border}`},onClick:g=>g.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderBottom:`1px solid ${n.border}`},children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold",style:{color:n.textPrimary},children:m==="create"?"Crear Nueva Tarea":"Editar Tarea"}),jsxRuntime.jsx("button",{onClick:t,className:"p-2 rounded-lg transition-colors",style:{color:n.textSecondary},onMouseEnter:g=>g.currentTarget.style.backgroundColor=n.hoverBg,onMouseLeave:g=>g.currentTarget.style.backgroundColor="transparent",disabled:l,children:jsxRuntime.jsx(lucideReact.X,{className:"w-5 h-5"})})]}),jsxRuntime.jsxs("form",{onSubmit:h,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:i.name,onChange:g=>f("name",g.target.value),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:c,onFocus:g=>g.currentTarget.style.borderColor=n.accent,onBlur:g=>g.currentTarget.style.borderColor=n.borderLight,placeholder:"Ej: Dise\xF1ar mockups de la aplicaci\xF3n",disabled:l}),v.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"}),v.name]})]}),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.FileText,{className:"w-4 h-4"}),"Descripci\xF3n"]}),jsxRuntime.jsx("textarea",{value:i.description||"",onChange:g=>f("description",g.target.value),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent resize-none",style:c,onFocus:g=>g.currentTarget.style.borderColor=n.accent,onBlur:g=>g.currentTarget.style.borderColor=n.borderLight,placeholder:"Describe los detalles de la tarea...",rows:3,disabled:l})]}),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:i.startDate?i.startDate.toISOString().split("T")[0]:"",onChange:g=>f("startDate",g.target.value?new Date(g.target.value):void 0),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:c,disabled:l||i.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:i.endDate?i.endDate.toISOString().split("T")[0]:"",onChange:g=>f("endDate",g.target.value?new Date(g.target.value):void 0),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:c,disabled:l||i.isMilestone}),v.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"}),v.endDate]})]})]}),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.CheckCircle2,{className:"w-4 h-4"}),"Estado"]}),jsxRuntime.jsxs("select",{value:i.status,onChange:g=>f("status",g.target.value),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:c,disabled:l,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-2 flex items-center gap-2",style:d,children:[jsxRuntime.jsx(lucideReact.Flag,{className:"w-4 h-4"}),"Prioridad"]}),jsxRuntime.jsxs("select",{value:i.priority||"medium",onChange:g=>f("priority",g.target.value),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:c,disabled:l,children:[jsxRuntime.jsx("option",{value:"low",children:"\u{1F7E2} Baja"}),jsxRuntime.jsx("option",{value:"medium",children:"\u{1F7E1} Media"}),jsxRuntime.jsx("option",{value:"high",children:"\u{1F7E0} Alta"}),jsxRuntime.jsx("option",{value:"urgent",children:"\u{1F534} Urgente"})]})]})]}),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(ll,{value:i.color,onChange:g=>f("color",g),disabled:l}),jsxRuntime.jsx("p",{className:"text-xs mt-2",style:{color:n.textTertiary},children:a?.parentId?"Esta subtarea hereda el color de su tarea padre":a?.subtasks&&a.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:i.progress<30?"#EF4444":i.progress<70?"#F59E0B":"#10B981",backgroundColor:i.progress<30?"rgba(239, 68, 68, 0.1)":i.progress<70?"rgba(245, 158, 11, 0.1)":"rgba(16, 185, 129, 0.1)"},children:[i.progress,"%"]})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("input",{type:"range",min:"0",max:"100",step:"5",value:i.progress,onChange:g=>f("progress",parseInt(g.target.value)),className:"w-full h-2 rounded-lg appearance-none cursor-pointer",style:{backgroundColor:n.bgSecondary,accentColor:i.progress<30?"#EF4444":i.progress<70?"#F59E0B":"#10B981"},disabled:l}),jsxRuntime.jsx("div",{className:"absolute top-0 left-0 h-2 rounded-lg pointer-events-none transition-all duration-300",style:{width:`${i.progress}%`,backgroundColor:i.progress<30?"rgba(239, 68, 68, 0.3)":i.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:n.textTertiary},children:"Accesos r\xE1pidos:"}),jsxRuntime.jsx("div",{className:"flex gap-1.5",children:[0,25,50,75,100].map(g=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>f("progress",g),disabled:l,className:"px-3 py-1 text-xs font-medium rounded-md transition-all duration-200 hover:scale-105 active:scale-95",style:{backgroundColor:i.progress===g?g<30?"#EF4444":g<70?"#F59E0B":"#10B981":n.bgSecondary,color:i.progress===g?"#FFFFFF":n.textSecondary,border:`1px solid ${i.progress===g?g<30?"#EF4444":g<70?"#F59E0B":"#10B981":n.borderLight}`},children:[g,"%"]},g))})]}),jsxRuntime.jsxs("div",{className:"flex justify-between text-xs mt-2",style:{color:n.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:n.bgSecondary,border:`1px solid ${n.borderLight}`},children:[jsxRuntime.jsx("input",{type:"checkbox",id:"isMilestone",checked:i.isMilestone,onChange:g=>f("isMilestone",g.target.checked),className:"w-4 h-4 rounded focus:ring-2",style:{accentColor:n.accent},disabled:l}),jsxRuntime.jsxs("label",{htmlFor:"isMilestone",className:"flex items-center gap-2 text-sm cursor-pointer",style:{color:n.textPrimary},children:[jsxRuntime.jsx(lucideReact.Milestone,{className:"w-4 h-4 text-yellow-500"}),"Marcar como Hito (Milestone)"]})]}),o.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:n.bgSecondary,border:`1px solid ${n.borderLight}`},children:o.map(g=>jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded",onMouseEnter:C=>C.currentTarget.style.backgroundColor=n.hoverBg,onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:i.assignees?.some(C=>C.name===g.name),onChange:C=>{let T=C.target.checked?[...i.assignees||[],{name:g.name,avatar:g.avatar,initials:g.name.split(" ").map(b=>b[0]).join("").toUpperCase().slice(0,2),color:n.accent}]:(i.assignees||[]).filter(b=>b.name!==g.name);f("assignees",T);},className:"w-4 h-4 rounded",style:{accentColor:n.accent},disabled:l}),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:n.accent},children:g.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:n.textPrimary},children:g.name})]})]},g.id))})]}),r.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:n.bgSecondary,border:`1px solid ${n.borderLight}`},children:r.filter(g=>g.id!==a?.id).map(g=>jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded",onMouseEnter:C=>C.currentTarget.style.backgroundColor=n.hoverBg,onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:i.dependencies?.includes(g.id),onChange:C=>{let T=C.target.checked?[...i.dependencies||[],g.id]:(i.dependencies||[]).filter(b=>b!==g.id);f("dependencies",T);},className:"w-4 h-4 rounded",style:{accentColor:n.accent},disabled:l}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:n.textPrimary},children:g.name})]},g.id))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4",style:{borderTop:`1px solid ${n.border}`,backgroundColor:n.bgPrimary},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:n.textSecondary},onMouseEnter:g=>{g.currentTarget.style.color=n.textPrimary,g.currentTarget.style.backgroundColor=n.hoverBg;},onMouseLeave:g=>{g.currentTarget.style.color=n.textSecondary,g.currentTarget.style.backgroundColor="transparent";},disabled:l,children:"Cancelar"}),jsxRuntime.jsx("button",{onClick:h,disabled:l,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:n.accent,color:"#FFFFFF"},onMouseEnter:g=>!l&&(g.currentTarget.style.backgroundColor=n.accentHover),onMouseLeave:g=>!l&&(g.currentTarget.style.backgroundColor=n.accent),children:l?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"}),m==="create"?"Crear Tarea":"Guardar Cambios"]})})]})]})})]})})}var _u=['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"'],fl=()=>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"})]}),Vu=()=>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"})}),ju=()=>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"})}),Ku=()=>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"})}),Yu=()=>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 po({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:l,onDependencyCreate:m,onDependencyDelete:p}){let[n,c]=react.useState(false),[d,i]=react.useState(false),[u,v]=react.useState([]),[x,y]=react.useState(""),[h,f]=react.useState(false),[g,C]=react.useState(true),T=react.useRef(null),b=react.useRef(null),N=react.useRef(null),{enabled:k=true,placeholder:S='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:w="bottom-right",onCommand:z,suggestions:$=_u,maxHistory:F=50}=a;react.useEffect(()=>{b.current&&b.current.scrollIntoView({behavior:"smooth"});},[u]),react.useEffect(()=>{n&&!d&&T.current&&setTimeout(()=>T.current?.focus(),100);},[n,d]);let _=react.useCallback(O=>{if(O.success)switch(O.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":O.taskId&&O.updates&&o?.(O.taskId,O.updates);break;case "create_task":O.newTask&&s?.(O.newTask);break;case "delete_task":O.taskId&&l?.(O.taskId);break;case "link_tasks":O.dependencyFrom&&O.dependencyTo&&m?.(O.dependencyFrom,O.dependencyTo);break;case "unlink_tasks":O.taskId&&O.dependencyFrom&&p?.(O.taskId,O.dependencyFrom);break}},[o,s,l,m,p]),E=react.useCallback(async O=>{if(!O.trim()||h)return;let ee={id:`user-${Date.now()}`,role:"user",content:O,timestamp:new Date};v(le=>[...le.slice(-(F-1)),ee]),y(""),C(false),f(true);let H={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};v(le=>[...le,H]);try{if(z){let le=await z(O,e);v(M=>{let fe=M.filter(qe=>!qe.isLoading),oe={id:`assistant-${Date.now()}`,role:"assistant",content:le.message,timestamp:new Date,command:le};return [...fe,oe]}),_(le);}else v(le=>[...le.filter(fe=>!fe.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(le){v(M=>[...M.filter(oe=>!oe.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${le instanceof Error?le.message:"Unknown error"}`,timestamp:new Date}]);}finally{f(false);}},[h,F,z,e,_]),G=O=>{O.preventDefault(),E(x);},J=O=>{y(O),T.current?.focus();};if(react.useEffect(()=>{let O=ee=>{(ee.metaKey||ee.ctrlKey)&&ee.key==="k"&&(ee.preventDefault(),c(H=>!H),n||i(false)),ee.key==="Escape"&&n&&c(false);};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[n]),!k)return null;let Z={"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(Ge,{children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!n&&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 ${Z[w]} 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:()=>c(true),children:[jsxRuntime.jsx(fl,{}),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:n&&jsxRuntime.jsxs(framerMotion.motion.div,{ref:N,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 ${Z[w]} 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(fl,{}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{onClick:()=>i(O=>!O),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(Ku,{})}),jsxRuntime.jsx("button",{onClick:()=>c(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(ju,{})})]})]}),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:[u.length===0&&g&&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:$.slice(0,4).map((O,ee)=>jsxRuntime.jsx("button",{onClick:()=>J(O),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:O.length>30?O.slice(0,30)+"...":O},ee))})]}),u.map(O=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${O.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${O.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:O.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:O.role==="user"?"white":t.textPrimary},children:[O.isLoading?jsxRuntime.jsx(Yu,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:O.content}),O.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:O.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:O.command.success?"#10B981":"#EF4444"},children:[O.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:O.command.type.replace(/_/g," ")})]})]})},O.id)),jsxRuntime.jsx("div",{ref:b})]}),jsxRuntime.jsxs("form",{onSubmit:G,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:T,type:"text",value:x,onChange:O=>y(O.target.value),placeholder:S,disabled:h,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsxRuntime.jsx("button",{type:"submit",disabled:!x.trim()||h,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:x.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:x.trim()?"white":t.textSecondary},children:jsxRuntime.jsx(Vu,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function bl(e,t=50){let[a,r]=react.useState({past:[],present:e,future:[]}),o=react.useRef(false),s=react.useCallback((n,c=true)=>{r(d=>{let i=typeof n=="function"?n(d.present):n;if(o.current)return {...d,present:i};if(!c)return {...d,present:i};let u=[...d.past,d.present];return u.length>t&&u.shift(),{past:u,present:i,future:[]}});},[t]),l=react.useCallback(()=>{r(n=>{if(n.past.length===0)return n;let c=n.past[n.past.length-1],d=n.past.slice(0,n.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:c,future:[n.present,...n.future]}});},[]),m=react.useCallback(()=>{r(n=>{if(n.future.length===0)return n;let c=n.future[0],d=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:c,future:d}});},[]),p=react.useCallback(()=>{r(n=>({past:[],present:n.present,future:[]}));},[]);return {state:a.present,setState:s,undo:l,redo:m,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function hl({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){react.useEffect(()=>{if(!o)return;let s=l=>{let m=navigator.platform.toUpperCase().indexOf("MAC")>=0,p=m?l.metaKey:l.ctrlKey;if(p&&l.key==="z"&&!l.shiftKey&&a){l.preventDefault(),e();return}if(r){if(!m&&p&&l.key==="y"){l.preventDefault(),t();return}if(m&&p&&l.shiftKey&&l.key==="z"){l.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var Zu={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${V.formatDate(e.startDate)} - ${V.formatDate(e.endDate)}`);let a=V.calculateDuration(e.startDate,e.endDate);t.push(`Duration: ${a} 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 a=e.assignees.map(r=>r.name).join(", ");t.push(`Assigned: ${a}`);}return e.dependencies&&e.dependencies.length>0&&t.push(`Dependencies: ${e.dependencies.length}`),t.join("<br/>")},taskLabel:e=>e.name,gridCell:(e,t,a)=>a,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=>V.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function vl(e){return {...Zu,...e}}var ng=e=>{switch(e){case "compact":return 40;case "comfortable":return 48;case "spacious":return 56;default:return 48}},kl=react.forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:l="week",rowDensity:m="comfortable",showThemeSelector:p=true,showExportButton:n=true,availableUsers:c=[],templates:d,enableAutoCriticalPath:i=true,aiAssistant:u,locale:v="en",customTranslations:x,showCreateTaskButton:y=false,createTaskLabel:h,onCreateTask:f,onThemeChange:g,onTaskClick:C,onTaskDblClick:T,onTaskContextMenu:b,onTaskUpdate:N,onProgressChange:k,onTaskEdit:S,onTaskAddSubtask:w,onTaskMarkIncomplete:z,onTaskSetInProgress:$,onDependencyCreate:F,onDependencyDelete:_,onBeforeTaskAdd:E,onAfterTaskAdd:G,onBeforeTaskUpdate:J,onAfterTaskUpdate:Z,onBeforeTaskDelete:O,onAfterTaskDelete:ee}=a,le=react.useContext(qr)?.theme,[M,fe]=react.useState(le||s||"dark"),[oe,qe]=react.useState(l),[Je,Ut]=react.useState(m),[xe,ut]=react.useState(1),[kt,ba]=react.useState(0),[ha,va]=react.useState(false),[ht,rt]=react.useState(null),[we,$t]=react.useState({isOpen:false,x:0,y:0,task:null}),[Kt,Rt]=react.useState(null),[Wt,Et]=react.useState(null);react.useEffect(()=>{le&&le!==M&&fe(le);},[le]),react.useEffect(()=>{s&&s!==M&&fe(s);},[s]);let W=react.useCallback(D=>{fe(D),g?.(D);},[g]),{state:L,setState:X,undo:de,redo:te,canUndo:Ht,canRedo:j,clearHistory:he}=bl(t,50);react.useEffect(()=>{X(t);},[t,X]);let ce=react.useRef(t),Te=react.useRef(true);react.useEffect(()=>{if(Te.current){Te.current=false,ce.current=L;return}if(!r)return;let D=JSON.stringify(ce.current),I=JSON.stringify(L);D!==I&&(ce.current=L,r(L));},[L,r]);let Se=react.useMemo(()=>xn(v,x),[v,x]),ne=react.useCallback(D=>[{id:"name",label:D.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:false},{id:"startDate",label:D.columns.startDate,width:110,visible:false,sortable:true},{id:"endDate",label:D.columns.endDate,width:110,visible:false,sortable:true},{id:"duration",label:D.columns.duration,width:80,visible:false,sortable:true},{id:"assignees",label:D.columns.assignees,width:120,visible:false,sortable:false},{id:"status",label:D.columns.status,width:80,visible:false,sortable:true},{id:"progress",label:D.columns.progress,width:120,visible:false,sortable:true},{id:"priority",label:D.columns.priority,width:90,visible:false,sortable:true}],[]),[Ie,ie]=react.useState(()=>ne(Se));react.useEffect(()=>{ie(D=>D.map(I=>({...I,label:Se.columns[I.id==="name"?"taskName":I.id]||I.label})));},[Se]);let gt=react.useMemo(()=>Ie.filter(D=>D.visible).reduce((D,I)=>D+I.width,0)+60,[Ie]),Nt=ht||gt,P=react.useRef(null),Q=react.useRef(null),Ne=react.useRef(null),Ee=react.useMemo(()=>Fi(M),[M]),na=react.useMemo(()=>({theme:Ee,themeName:M}),[Ee,M]),Ps=react.useMemo(()=>vl(d),[d]),Ms=react.useMemo(()=>{if(!i)return L;let D=V.calculateCriticalPath(L),I=U=>U.map(q=>({...q,isCriticalPath:D.includes(q.id),subtasks:q.subtasks?I(q.subtasks):void 0}));return I(L)},[L,i]),Ar=ng(Je);hl({undo:de,redo:te,canUndo:Ht,canRedo:j,enabled:true}),react.useImperativeHandle(o,()=>({getTask:D=>V.findTaskById(L,D),addTask:(D,I)=>{X(U=>{if(!I)return [...U,{...D,level:0}];let q=se=>se.map(me=>me.id===I?{...me,subtasks:[...me.subtasks||[],{...D,parentId:I,level:(me.level||0)+1}],isExpanded:true}:me.subtasks?{...me,subtasks:q(me.subtasks)}:me);return q(U)});},updateTask:(D,I)=>{X(U=>{let q=se=>se.map(me=>me.id===D?{...me,...I}:me.subtasks?{...me,subtasks:q(me.subtasks)}:me);return q(U)});},deleteTask:D=>{X(I=>{let U=q=>q.filter(se=>se.id===D?false:(se.subtasks&&(se.subtasks=U(se.subtasks)),true));return U(I)});},deleteTasks:D=>{X(I=>Sn(I,D));},duplicateTask:D=>{X(I=>En(I,[D]));},splitTask:(D,I,U=3)=>{X(q=>V.splitTask(q,D,I,U));},calculateEndDate:V.calculateEndDate,calculateDuration:V.calculateDuration,validateDependency:(D,I)=>!V.validateDependencies(L,D,I),getAllTasks:()=>V.flattenTasks(L),getTasksByStatus:D=>V.flattenTasks(L).filter(I=>I.status===D),getTasksByParent:D=>D?V.findTaskById(L,D)?.subtasks||[]:L.filter(U=>!U.parentId),getCriticalPath:()=>V.flattenTasks(L).filter(D=>D.isCriticalPath),indentTask:D=>{X(I=>Tn(I,[D]));},outdentTask:D=>{X(I=>Nn(I,[D]));},moveTask:(D,I)=>{X(U=>Dn(U,[D],I));},createSubtask:async D=>{let{tasks:I,newTask:U}=In(L,D);if(E){let q=E({...U,parentId:D});if((q instanceof Promise?await q:q)===false)return}X(I),G&&G({...U,parentId:D});},scrollToTask:D=>{let U=V.flattenTasks(L).findIndex(q=>q.id===D);if(U!==-1&&P.current){let q=U*Ar;P.current.scrollTo({top:q,behavior:"smooth"}),Q.current&&Q.current.scrollTo({top:q,behavior:"smooth"});}},highlightTask:(D,I=2e3)=>{},expandTask:D=>{X(I=>{let U=q=>q.map(se=>se.id===D?{...se,isExpanded:true}:se.subtasks?{...se,subtasks:U(se.subtasks)}:se);return U(I)});},collapseTask:D=>{X(I=>{let U=q=>q.map(se=>se.id===D?{...se,isExpanded:false}:se.subtasks?{...se,subtasks:U(se.subtasks)}:se);return U(I)});},expandAll:()=>{X(D=>{let I=U=>U.map(q=>({...q,isExpanded:true,subtasks:q.subtasks?I(q.subtasks):void 0}));return I(D)});},collapseAll:()=>{X(D=>{let I=U=>U.map(q=>({...q,isExpanded:false,subtasks:q.subtasks?I(q.subtasks):void 0}));return I(D)});},undo:de,redo:te,canUndo:()=>Ht,canRedo:()=>j,clearHistory:he,exportToPNG:async()=>{if(!Ne.current)throw new Error("Gantt container not found");let D=await xl__default.default(Ne.current,{backgroundColor:Ee.bgPrimary,scale:2});return new Promise((I,U)=>{D.toBlob(q=>{q?I(q):U(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async D=>{await V.exportToPDF(L,D);},exportToExcel:async D=>{await V.exportToExcel(L,D);},exportToJSON:()=>V.exportToJSON(L),exportToCSV:()=>V.exportToCSV(L),importFromJSON:D=>{let I=V.importFromJSON(D);X(I);},getTasks:()=>L,refresh:()=>{X(D=>[...D]);},clearAll:()=>{X([]);}}),[L,de,te,Ht,j,he,Ee,Ar]);let Ld=react.useCallback(D=>{ie(I=>I.map(U=>U.id===D?{...U,visible:!U.visible}:U));},[]),Ad=react.useCallback((D,I)=>{ie(U=>U.map(q=>{if(q.id!==D)return q;let se=q.minWidth??100,me=q.maxWidth??800,st=Math.max(se,Math.min(me,I));return {...q,width:st}}));},[]),Bd=react.useCallback(D=>{X(I=>Mn(I,D)),a.onTaskToggleExpand?.(D);},[a]),Va=react.useCallback((D,I)=>{if(J&&J(D,I)===false)return;let q=V.findTaskById(L,D)?.progress,se=st=>st.map(wt=>wt.id===D?{...wt,...I}:wt.subtasks?{...wt,subtasks:se(wt.subtasks)}:wt);X(se(L));let me=V.findTaskById(se(L),D);me&&(N?.(me),Z?.(me),I.progress!==void 0&&q!==void 0&&I.progress!==q&&k?.(D,q,I.progress));},[L,N,J,Z,k]),Rd=react.useCallback(D=>{D.length!==0&&(X(I=>Tn(I,D)),a.onTaskIndent?.(D[0]));},[a]),Od=react.useCallback(D=>{D.length!==0&&(X(I=>Nn(I,D)),a.onTaskOutdent?.(D[0]));},[a]),zd=react.useCallback((D,I)=>{D.length!==0&&(X(U=>Dn(U,D,I)),a.onTaskMove?.(D[0],I));},[a]),Po=react.useCallback(async D=>{let I=[];for(let U of D)O&&await Promise.resolve(O(U))===false||I.push(U);I.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(I):(X(U=>Sn(U,I)),I.forEach(U=>a.onTaskDelete?.(U))),ee&&I.forEach(U=>ee(U)));},[a,O,ee]),Gd=react.useCallback(D=>{X(I=>En(I,D)),D.forEach(I=>a.onTaskDuplicate?.(I));},[a]),Ud=react.useCallback((D,I)=>{X(U=>{let{tasks:q,newTask:se}=qi(U,D,I);return E&&E(se)===false?U:(a.onTaskCreate?.(se.parentId,se.position||0),G?.(se),q)});},[a,E,G]),$d=react.useCallback((D,I)=>{X(U=>Pn(U,D,I)),a.onTaskRename?.(D,I);},[a]),Is=react.useCallback(D=>{X(I=>{let{tasks:U}=In(I,D);return a.onTaskCreate?.(D,0),U});},[a]),Wd=react.useCallback((D,I,U)=>{let q=D.startDate?Math.round((I.getTime()-D.startDate.getTime())/864e5):0,se=wt=>wt.map(Yt=>Yt.id===D.id?{...Yt,startDate:I,endDate:U,...D.segments&&{segments:D.segments}}:Yt.subtasks?{...Yt,subtasks:se(Yt.subtasks)}:Yt),me=se(L);me=V.autoScheduleDependents(me,D.id,q),X(me);let st={...D,startDate:I,endDate:U};N?.(st);},[L,N]),Hd=react.useCallback((D,I)=>{b?.(D,I),$t({isOpen:true,x:I.clientX,y:I.clientY,task:D});},[b]),_d=react.useCallback((D,I)=>{let U=V.splitTask(L,D.id,I);X(U),$t({isOpen:false,x:0,y:0,task:null});},[L]),Fs=react.useCallback(D=>{T?.(D),S||Rt(D);},[T,S]),Ls=react.useCallback((D,I,U)=>{let q=new Map,se=Xt=>{Xt.forEach(ca=>{ca.dependencies&&q.set(ca.id,ca.dependencies),ca.subtasks&&se(ca.subtasks);});};se(U);let me=q.get(I)||[];q.set(I,[...me,D]);let st=new Set,wt=new Set,Yt=Xt=>{if(!st.has(Xt)){st.add(Xt),wt.add(Xt);let ca=q.get(Xt)||[];for(let cr of ca){if(!st.has(cr)&&Yt(cr))return true;if(wt.has(cr))return true}}return wt.delete(Xt),false};return Yt(I)},[]),As=react.useCallback((D,I)=>{if(Ls(D.id,I,L)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
|
|
276
|
+
</Project>`,c=new Blob([n],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(c),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=V.flattenTasks(e),a=t.filter(n=>n.startDate&&n.endDate);if(a.length===0)return [];let r=new Map,o=n=>{if(r.has(n.id))return;let c=n.startDate&&n.endDate?V.calculateDuration(n.startDate,n.endDate):0,d=0;if(n.dependencies&&n.dependencies.length>0)for(let u of n.dependencies){let v=t.find(x=>x.id===u);if(v){o(v);let x=r.get(u)?.ef||0;d=Math.max(d,x);}}let i=d+c;r.set(n.id,{es:d,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(n=>n.ef)),l=new Map,m=n=>{if(l.has(n.id))return;let c=n.startDate&&n.endDate?V.calculateDuration(n.startDate,n.endDate):0,d=t.filter(v=>v.dependencies&&v.dependencies.includes(n.id)),i=s;if(d.length>0)for(let v of d){m(v);let x=l.get(v.id)?.ls||0;i=Math.min(i,x);}let u=i-c;l.set(n.id,{ls:u,lf:i});};a.forEach(m);let p=[];for(let n of a){let c=r.get(n.id),d=l.get(n.id);if(c&&d){let i=d.ls-c.es;Math.abs(i)<.01&&p.push(n.id);}}return p},calculateSlack:(e,t)=>{let a=V.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(V.calculateCriticalPath(e).includes(t))return 0;let o=V.getDependentTasks(e,t);if(o.length===0){let m=V.getLatestEndDate(e);if(!m)return null;let p=V.calculateDuration(a.endDate,m);return Math.max(0,p)}let s=o.filter(m=>m.startDate).map(m=>m.startDate.getTime()).sort((m,p)=>m-p)[0];if(!s)return null;let l=V.calculateDuration(a.endDate,new Date(s));return Math.max(0,l)},isOnCriticalPath:(e,t)=>V.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=V.findTaskById(e,t);if(!r||!r.endDate)return e;let o=V.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let l of o){if(!l.startDate||!l.endDate)continue;let m=V.calculateDuration(l.startDate,l.endDate),p;a!==void 0?(p=new Date(l.startDate),p.setDate(p.getDate()+a)):(p=new Date(r.endDate),p.setDate(p.getDate()+1));let n=V.calculateEndDate(p,m),c=d=>d.map(i=>i.id===l.id?{...i,startDate:p,endDate:n}:i.subtasks?{...i,subtasks:c(i.subtasks)}:i);s=c(s),s=V.autoScheduleDependents(s,l.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,l,m)=>{if(a===0)return [];let p=[],n=o.getTime(),c=1e3*60*60*24,d=V.findTaskById(e,t);if(!d||!d.endDate)return [];let i=(u,v,x=new Set)=>{if(x.has(u))return;x.add(u);let y=V.getDependentTasks(e,u);for(let h of y){if(!h.startDate||!h.endDate)continue;let f=r.findIndex(z=>z.id===h.id);if(f===-1)continue;let g=h.startDate.getTime(),T=(h.endDate.getTime()-g)/c,N=(g-n)/c*s,k=N+v*s,S=Math.max(T*s,s),w=m+f*l+12;p.push({taskId:h.id,taskName:h.name,originalX:N,previewX:k,width:S,y:w,rowIndex:f,daysDelta:v,color:h.color}),i(h.id,v,x);}};return i(t,a),p},splitTask:(e,t,a,r=3)=>{let o=V.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let l=new Date(a);l.setDate(l.getDate()+r);let m=new Date(o.endDate);m.setDate(m.getDate()+r);let p=[{startDate:new Date(o.startDate),endDate:s},{startDate:l,endDate:m}],n=c=>c.map(d=>d.id===o.id?{...d,endDate:m,segments:p}:d.subtasks?{...d,subtasks:n(d.subtasks)}:d);return n(e)}};function lo({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:l,templates:m,onTaskClick:p,onTaskDblClick:n,onTaskContextMenu:c,onTaskDateChange:d,onDependencyCreate:i,onDependencyDelete:u}){let[x,y]=react.useState([]),h=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),f=r==="day"?60:r==="week"?20:8,g=h*f*l,C=E=>{let G=new Date(Date.UTC(E.getFullYear(),E.getMonth(),E.getDate())),J=G.getUTCDay()||7;G.setUTCDate(G.getUTCDate()+4-J);let Z=new Date(Date.UTC(G.getUTCFullYear(),0,1));return Math.ceil(((G.getTime()-Z.getTime())/864e5+1)/7)},T=E=>{let G=E.getDay();return G===0||G===6},b=react.useCallback(E=>{let G=Math.round(E/(f*l)),J=new Date(o);return J.setDate(J.getDate()+G),J},[o,f,l]),N=react.useCallback((E,G)=>{if(G.startDate&&G.endDate)return;let J=E.currentTarget.ownerSVGElement;if(!J)return;let Z=J.createSVGPoint();Z.x=E.clientX,Z.y=E.clientY;let O=Z.matrixTransform(J.getScreenCTM()?.inverse()),ee=b(O.x),H=new Date(ee);H.setDate(H.getDate()+1),d?.(G,ee,H);},[b,d]),k=react.useMemo(()=>{let E=O=>O.map(ee=>{if(ee.subtasks&&ee.subtasks.length>0){let H=E(ee.subtasks),le=H.filter(M=>M.startDate&&M.endDate);if(le.length>0){let M=le.map(Je=>Je.startDate.getTime()),fe=le.map(Je=>Je.endDate.getTime()),oe=new Date(Math.min(...M)),qe=new Date(Math.max(...fe));return {...ee,subtasks:H,startDate:ee.startDate||oe,endDate:ee.endDate||qe}}return {...ee,subtasks:H}}return ee}),G=(O,ee=[])=>{for(let H of O)ee.push(H),H.subtasks&&H.subtasks.length>0&&(H.isExpanded===void 0||H.isExpanded)&&G(H.subtasks,ee);return ee},J=E(e);return G(J)},[e]),S=react.useCallback(E=>{if(!E.startDate||!E.endDate)return {x:0,width:0};let G=E.startDate.getTime(),J=E.endDate.getTime(),Z=o.getTime(),O=(G-Z)/(1e3*60*60*24),ee=(J-G)/(1e3*60*60*24),H=O*f*l,le=Math.max(f*l,40),M=Math.max(ee*f*l,le);return {x:H,width:M}},[o,f,l]),w=react.useMemo(()=>k.filter(E=>E.startDate&&E.endDate).map(E=>{let{x:G,width:J}=S(E),O=k.findIndex(ee=>ee.id===E.id)*a+12;return {id:E.id,x:G,y:O,width:J,height:32}}),[k,S]),z=react.useCallback((E,G,J)=>{if(!J||G===0){y([]);return}let Z=V.calculateCascadePreview(e,E,G,k,o,f*l,a,48);y(Z);},[e,k,o,f,l,a,48]),$=react.useMemo(()=>{let E=[],G=new Date(o);for(;G<=s;){let O=(G.getTime()-o.getTime())/864e5*f*l;if(r==="day")E.push({date:new Date(G),label:G.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:O}),G.setDate(G.getDate()+1);else if(r==="week"){let ee=C(G);E.push({date:new Date(G),label:`Week ${ee}`,x:O}),G.setDate(G.getDate()+7);}else E.push({date:new Date(G),label:G.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:O}),G.setMonth(G.getMonth()+1);}return E},[o,s,r,f,l]),F=react.useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*f*l,[o,f,l]),_=Math.max(k.length*a,552);return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary,overflow:"visible"},children:[jsxRuntime.jsx("div",{style:{position:"sticky",top:0,zIndex:10,backgroundColor:t.bgGrid,flexShrink:0,height:"48px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:jsxRuntime.jsxs("svg",{width:Math.max(g,1e3),height:47,style:{display:"block"},children:[jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(g,1e3),height:48,fill:t.bgGrid}),$.map((E,G)=>jsxRuntime.jsxs("g",{children:[G>0&&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-${G}`)),F>=0&&F<=g&&jsxRuntime.jsx("circle",{cx:F,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(g,1e3),height:_,style:{display:"block",flexShrink:0,overflow:"visible"},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(g,1e3),height:_,fill:t.bgPrimary}),$.map((E,G)=>{let J=$[G+1]?.x||g,Z=T(E.date);return jsxRuntime.jsxs("g",{children:[Z&&jsxRuntime.jsx("rect",{x:E.x,y:0,width:J-E.x,height:k.length*a,fill:t.bgWeekend,opacity:1}),G>0&&jsxRuntime.jsx("line",{x1:E.x,y1:0,x2:E.x,y2:k.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},G)}),F>=0&&F<=g&&jsxRuntime.jsx("line",{x1:F,y1:0,x2:F,y2:k.length*a,stroke:t.today,strokeWidth:2,opacity:1}),k.map((E,G)=>{let J=E.startDate&&E.endDate;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:0,y:G*a,width:g,height:a,fill:G%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${E.id}`),!J&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:0,y:G*a,width:g,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:Z=>N(Z,E),onMouseEnter:Z=>{Z.currentTarget.setAttribute("fill",t.accentLight),Z.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:Z=>{Z.currentTarget.setAttribute("fill","transparent"),Z.currentTarget.setAttribute("opacity","1");}},`clickable-${E.id}`),jsxRuntime.jsx("text",{x:F>0?F:100,y:G*a+a/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}`)}),k.map((E,G)=>!E.dependencies||E.dependencies.length===0||!E.startDate||!E.endDate?null:E.dependencies.map(J=>{let Z=k.find(le=>le.id===J);if(!Z||!Z.startDate||!Z.endDate)return null;let O=k.findIndex(le=>le.id===J),ee=S(Z),H=S(E);return jsxRuntime.jsx(ro,{x1:ee.x+ee.width,y1:O*a+a/2,x2:H.x,y2:G*a+a/2,theme:t,onDelete:()=>u?.(E.id,J)},`dep-${J}-${E.id}`)})),k.map((E,G)=>{if(!E.startDate||!E.endDate)return null;let{x:J,width:Z}=S(E),O=G*a+12,ee=E.subtasks&&E.subtasks.length>0&&!E.isMilestone;return E.isMilestone?jsxRuntime.jsx(no,{task:E,x:J+Z/2,y:O+16,theme:t,onClick:p},E.id):ee?jsxRuntime.jsxs("g",{onClick:()=>p?.(E),style:{cursor:"pointer"},children:[jsxRuntime.jsx("rect",{x:J,y:O,width:Z,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:J,y1:O,x2:J+Z,y2:O,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:J,y1:O,x2:J,y2:O+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:J+Z,y1:O,x2:J+Z,y2:O+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:J,y1:O+32,x2:J+Z,y2:O+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),Z>60&&jsxRuntime.jsx("text",{x:J+12,y:O+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(to,{task:E,x:J,y:O,width:Z,theme:t,dayWidth:f*l,startDate:o,templates:m,onClick:p,onDoubleClick:n,onContextMenu:c,onDateChange:d,onDependencyCreate:i,allTaskPositions:w,onDragMove:z},E.id)}),x.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 il=[{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 ll({value:e="#6366F1",onChange:t,disabled:a=false}){return jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:il.map(r=>{let o=e===r.value;return jsxRuntime.jsx(framerMotion.motion.button,{type:"button",onClick:()=>!a&&t(r.value),className:"relative rounded-full transition-all focus:outline-none focus:ring-2 focus:ring-offset-2",style:{width:"32px",height:"32px",backgroundColor:r.value,boxShadow:o?`0 0 0 2px #FFFFFF, 0 0 0 4px ${r.value}`:"0 1px 3px rgba(0, 0, 0, 0.12)",opacity:a?.5:1,cursor:a?"not-allowed":"pointer"},whileHover:a?{}:{scale:1.1},whileTap:a?{}:{scale:.95},title:r.name,disabled:a,children:o&&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})})},r.value)})}),e&&jsxRuntime.jsx("div",{className:"text-xs text-center font-medium",style:{color:e},children:il.find(r=>r.value===e)?.name||"Personalizado"})]})}function co({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:l=false,mode:m=a?"edit":"create",theme:p="dark"}){let n=De[p]||De.dark,c={backgroundColor:n.bgSecondary,border:`1px solid ${n.borderLight}`,color:n.textPrimary},d={color:n.textSecondary},[i,u]=react.useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),[v,x]=react.useState({});react.useEffect(()=>{u(a?{name:a.name,description:a.description||"",startDate:a.startDate,endDate:a.endDate,progress:a.progress,status:a.status||"todo",priority:a.priority||"medium",isMilestone:a.isMilestone||false,color:a.color||"#6366F1",assignees:a.assignees||[],dependencies:a.dependencies||[]}:{name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]});},[a,e]);let y=()=>{let g={};return i.name.trim()||(g.name="El nombre es requerido"),i.startDate&&i.endDate&&i.startDate>i.endDate&&(g.endDate="La fecha de fin debe ser posterior a la de inicio"),x(g),Object.keys(g).length===0},h=async g=>{if(g.preventDefault(),!!y())try{await s(i),t();}catch(C){console.error("Error submitting task:",C);}},f=(g,C)=>{u(T=>{let b={...T,[g]:C};if(g==="progress"){let N=typeof C=="number"?C:parseInt(C,10);N===100&&T.status!=="completed"?b.status="completed":N>0&&N<100&&T.status==="todo"?b.status="in-progress":N===0&&T.status==="in-progress"&&(b.status="todo");}return b}),v[g]&&x(T=>{let b={...T};return delete b[g],b});};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:n.bgPrimary,border:`1px solid ${n.border}`},onClick:g=>g.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderBottom:`1px solid ${n.border}`},children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold",style:{color:n.textPrimary},children:m==="create"?"Crear Nueva Tarea":"Editar Tarea"}),jsxRuntime.jsx("button",{onClick:t,className:"p-2 rounded-lg transition-colors",style:{color:n.textSecondary},onMouseEnter:g=>g.currentTarget.style.backgroundColor=n.hoverBg,onMouseLeave:g=>g.currentTarget.style.backgroundColor="transparent",disabled:l,children:jsxRuntime.jsx(lucideReact.X,{className:"w-5 h-5"})})]}),jsxRuntime.jsxs("form",{onSubmit:h,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:i.name,onChange:g=>f("name",g.target.value),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:c,onFocus:g=>g.currentTarget.style.borderColor=n.accent,onBlur:g=>g.currentTarget.style.borderColor=n.borderLight,placeholder:"Ej: Dise\xF1ar mockups de la aplicaci\xF3n",disabled:l}),v.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"}),v.name]})]}),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.FileText,{className:"w-4 h-4"}),"Descripci\xF3n"]}),jsxRuntime.jsx("textarea",{value:i.description||"",onChange:g=>f("description",g.target.value),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent resize-none",style:c,onFocus:g=>g.currentTarget.style.borderColor=n.accent,onBlur:g=>g.currentTarget.style.borderColor=n.borderLight,placeholder:"Describe los detalles de la tarea...",rows:3,disabled:l})]}),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:i.startDate?i.startDate.toISOString().split("T")[0]:"",onChange:g=>f("startDate",g.target.value?new Date(g.target.value):void 0),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:c,disabled:l||i.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:i.endDate?i.endDate.toISOString().split("T")[0]:"",onChange:g=>f("endDate",g.target.value?new Date(g.target.value):void 0),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:c,disabled:l||i.isMilestone}),v.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"}),v.endDate]})]})]}),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.CheckCircle2,{className:"w-4 h-4"}),"Estado"]}),jsxRuntime.jsxs("select",{value:i.status,onChange:g=>f("status",g.target.value),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:c,disabled:l,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-2 flex items-center gap-2",style:d,children:[jsxRuntime.jsx(lucideReact.Flag,{className:"w-4 h-4"}),"Prioridad"]}),jsxRuntime.jsxs("select",{value:i.priority||"medium",onChange:g=>f("priority",g.target.value),className:"w-full px-4 py-2.5 rounded-lg focus:outline-none focus:ring-2 focus:border-transparent",style:c,disabled:l,children:[jsxRuntime.jsx("option",{value:"low",children:"\u{1F7E2} Baja"}),jsxRuntime.jsx("option",{value:"medium",children:"\u{1F7E1} Media"}),jsxRuntime.jsx("option",{value:"high",children:"\u{1F7E0} Alta"}),jsxRuntime.jsx("option",{value:"urgent",children:"\u{1F534} Urgente"})]})]})]}),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(ll,{value:i.color,onChange:g=>f("color",g),disabled:l}),jsxRuntime.jsx("p",{className:"text-xs mt-2",style:{color:n.textTertiary},children:a?.parentId?"Esta subtarea hereda el color de su tarea padre":a?.subtasks&&a.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:i.progress<30?"#EF4444":i.progress<70?"#F59E0B":"#10B981",backgroundColor:i.progress<30?"rgba(239, 68, 68, 0.1)":i.progress<70?"rgba(245, 158, 11, 0.1)":"rgba(16, 185, 129, 0.1)"},children:[i.progress,"%"]})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("input",{type:"range",min:"0",max:"100",step:"5",value:i.progress,onChange:g=>f("progress",parseInt(g.target.value)),className:"w-full h-2 rounded-lg appearance-none cursor-pointer",style:{backgroundColor:n.bgSecondary,accentColor:i.progress<30?"#EF4444":i.progress<70?"#F59E0B":"#10B981"},disabled:l}),jsxRuntime.jsx("div",{className:"absolute top-0 left-0 h-2 rounded-lg pointer-events-none transition-all duration-300",style:{width:`${i.progress}%`,backgroundColor:i.progress<30?"rgba(239, 68, 68, 0.3)":i.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:n.textTertiary},children:"Accesos r\xE1pidos:"}),jsxRuntime.jsx("div",{className:"flex gap-1.5",children:[0,25,50,75,100].map(g=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>f("progress",g),disabled:l,className:"px-3 py-1 text-xs font-medium rounded-md transition-all duration-200 hover:scale-105 active:scale-95",style:{backgroundColor:i.progress===g?g<30?"#EF4444":g<70?"#F59E0B":"#10B981":n.bgSecondary,color:i.progress===g?"#FFFFFF":n.textSecondary,border:`1px solid ${i.progress===g?g<30?"#EF4444":g<70?"#F59E0B":"#10B981":n.borderLight}`},children:[g,"%"]},g))})]}),jsxRuntime.jsxs("div",{className:"flex justify-between text-xs mt-2",style:{color:n.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:n.bgSecondary,border:`1px solid ${n.borderLight}`},children:[jsxRuntime.jsx("input",{type:"checkbox",id:"isMilestone",checked:i.isMilestone,onChange:g=>f("isMilestone",g.target.checked),className:"w-4 h-4 rounded focus:ring-2",style:{accentColor:n.accent},disabled:l}),jsxRuntime.jsxs("label",{htmlFor:"isMilestone",className:"flex items-center gap-2 text-sm cursor-pointer",style:{color:n.textPrimary},children:[jsxRuntime.jsx(lucideReact.Milestone,{className:"w-4 h-4 text-yellow-500"}),"Marcar como Hito (Milestone)"]})]}),o.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:n.bgSecondary,border:`1px solid ${n.borderLight}`},children:o.map(g=>jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded",onMouseEnter:C=>C.currentTarget.style.backgroundColor=n.hoverBg,onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:i.assignees?.some(C=>C.name===g.name),onChange:C=>{let T=C.target.checked?[...i.assignees||[],{id:g.id,name:g.name,avatar:g.avatar,initials:g.name.split(" ").map(b=>b[0]).join("").toUpperCase().slice(0,2),color:n.accent}]:(i.assignees||[]).filter(b=>b.name!==g.name);f("assignees",T);},className:"w-4 h-4 rounded",style:{accentColor:n.accent},disabled:l}),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:n.accent},children:g.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:n.textPrimary},children:g.name})]})]},g.id))})]}),r.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:n.bgSecondary,border:`1px solid ${n.borderLight}`},children:r.filter(g=>g.id!==a?.id).map(g=>jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded",onMouseEnter:C=>C.currentTarget.style.backgroundColor=n.hoverBg,onMouseLeave:C=>C.currentTarget.style.backgroundColor="transparent",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:i.dependencies?.includes(g.id),onChange:C=>{let T=C.target.checked?[...i.dependencies||[],g.id]:(i.dependencies||[]).filter(b=>b!==g.id);f("dependencies",T);},className:"w-4 h-4 rounded",style:{accentColor:n.accent},disabled:l}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:n.textPrimary},children:g.name})]},g.id))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4",style:{borderTop:`1px solid ${n.border}`,backgroundColor:n.bgPrimary},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:n.textSecondary},onMouseEnter:g=>{g.currentTarget.style.color=n.textPrimary,g.currentTarget.style.backgroundColor=n.hoverBg;},onMouseLeave:g=>{g.currentTarget.style.color=n.textSecondary,g.currentTarget.style.backgroundColor="transparent";},disabled:l,children:"Cancelar"}),jsxRuntime.jsx("button",{onClick:h,disabled:l,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:n.accent,color:"#FFFFFF"},onMouseEnter:g=>!l&&(g.currentTarget.style.backgroundColor=n.accentHover),onMouseLeave:g=>!l&&(g.currentTarget.style.backgroundColor=n.accent),children:l?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"}),m==="create"?"Crear Tarea":"Guardar Cambios"]})})]})]})})]})})}var _u=['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"'],fl=()=>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"})]}),Vu=()=>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"})}),ju=()=>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"})}),Ku=()=>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"})}),Yu=()=>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 po({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:l,onDependencyCreate:m,onDependencyDelete:p}){let[n,c]=react.useState(false),[d,i]=react.useState(false),[u,v]=react.useState([]),[x,y]=react.useState(""),[h,f]=react.useState(false),[g,C]=react.useState(true),T=react.useRef(null),b=react.useRef(null),N=react.useRef(null),{enabled:k=true,placeholder:S='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:w="bottom-right",onCommand:z,suggestions:$=_u,maxHistory:F=50}=a;react.useEffect(()=>{b.current&&b.current.scrollIntoView({behavior:"smooth"});},[u]),react.useEffect(()=>{n&&!d&&T.current&&setTimeout(()=>T.current?.focus(),100);},[n,d]);let _=react.useCallback(O=>{if(O.success)switch(O.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":O.taskId&&O.updates&&o?.(O.taskId,O.updates);break;case "create_task":O.newTask&&s?.(O.newTask);break;case "delete_task":O.taskId&&l?.(O.taskId);break;case "link_tasks":O.dependencyFrom&&O.dependencyTo&&m?.(O.dependencyFrom,O.dependencyTo);break;case "unlink_tasks":O.taskId&&O.dependencyFrom&&p?.(O.taskId,O.dependencyFrom);break}},[o,s,l,m,p]),E=react.useCallback(async O=>{if(!O.trim()||h)return;let ee={id:`user-${Date.now()}`,role:"user",content:O,timestamp:new Date};v(le=>[...le.slice(-(F-1)),ee]),y(""),C(false),f(true);let H={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};v(le=>[...le,H]);try{if(z){let le=await z(O,e);v(M=>{let fe=M.filter(qe=>!qe.isLoading),oe={id:`assistant-${Date.now()}`,role:"assistant",content:le.message,timestamp:new Date,command:le};return [...fe,oe]}),_(le);}else v(le=>[...le.filter(fe=>!fe.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(le){v(M=>[...M.filter(oe=>!oe.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${le instanceof Error?le.message:"Unknown error"}`,timestamp:new Date}]);}finally{f(false);}},[h,F,z,e,_]),G=O=>{O.preventDefault(),E(x);},J=O=>{y(O),T.current?.focus();};if(react.useEffect(()=>{let O=ee=>{(ee.metaKey||ee.ctrlKey)&&ee.key==="k"&&(ee.preventDefault(),c(H=>!H),n||i(false)),ee.key==="Escape"&&n&&c(false);};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[n]),!k)return null;let Z={"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(Ge,{children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!n&&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 ${Z[w]} 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:()=>c(true),children:[jsxRuntime.jsx(fl,{}),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:n&&jsxRuntime.jsxs(framerMotion.motion.div,{ref:N,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 ${Z[w]} 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(fl,{}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{onClick:()=>i(O=>!O),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(Ku,{})}),jsxRuntime.jsx("button",{onClick:()=>c(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(ju,{})})]})]}),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:[u.length===0&&g&&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:$.slice(0,4).map((O,ee)=>jsxRuntime.jsx("button",{onClick:()=>J(O),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:O.length>30?O.slice(0,30)+"...":O},ee))})]}),u.map(O=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${O.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${O.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:O.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:O.role==="user"?"white":t.textPrimary},children:[O.isLoading?jsxRuntime.jsx(Yu,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:O.content}),O.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:O.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:O.command.success?"#10B981":"#EF4444"},children:[O.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:O.command.type.replace(/_/g," ")})]})]})},O.id)),jsxRuntime.jsx("div",{ref:b})]}),jsxRuntime.jsxs("form",{onSubmit:G,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:T,type:"text",value:x,onChange:O=>y(O.target.value),placeholder:S,disabled:h,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsxRuntime.jsx("button",{type:"submit",disabled:!x.trim()||h,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:x.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:x.trim()?"white":t.textSecondary},children:jsxRuntime.jsx(Vu,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function bl(e,t=50){let[a,r]=react.useState({past:[],present:e,future:[]}),o=react.useRef(false),s=react.useCallback((n,c=true)=>{r(d=>{let i=typeof n=="function"?n(d.present):n;if(o.current)return {...d,present:i};if(!c)return {...d,present:i};let u=[...d.past,d.present];return u.length>t&&u.shift(),{past:u,present:i,future:[]}});},[t]),l=react.useCallback(()=>{r(n=>{if(n.past.length===0)return n;let c=n.past[n.past.length-1],d=n.past.slice(0,n.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:c,future:[n.present,...n.future]}});},[]),m=react.useCallback(()=>{r(n=>{if(n.future.length===0)return n;let c=n.future[0],d=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:c,future:d}});},[]),p=react.useCallback(()=>{r(n=>({past:[],present:n.present,future:[]}));},[]);return {state:a.present,setState:s,undo:l,redo:m,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function hl({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){react.useEffect(()=>{if(!o)return;let s=l=>{let m=navigator.platform.toUpperCase().indexOf("MAC")>=0,p=m?l.metaKey:l.ctrlKey;if(p&&l.key==="z"&&!l.shiftKey&&a){l.preventDefault(),e();return}if(r){if(!m&&p&&l.key==="y"){l.preventDefault(),t();return}if(m&&p&&l.shiftKey&&l.key==="z"){l.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var Zu={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${V.formatDate(e.startDate)} - ${V.formatDate(e.endDate)}`);let a=V.calculateDuration(e.startDate,e.endDate);t.push(`Duration: ${a} 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 a=e.assignees.map(r=>r.name).join(", ");t.push(`Assigned: ${a}`);}return e.dependencies&&e.dependencies.length>0&&t.push(`Dependencies: ${e.dependencies.length}`),t.join("<br/>")},taskLabel:e=>e.name,gridCell:(e,t,a)=>a,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=>V.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function vl(e){return {...Zu,...e}}var ng=e=>{switch(e){case "compact":return 40;case "comfortable":return 48;case "spacious":return 56;default:return 48}},kl=react.forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:l="week",rowDensity:m="comfortable",showThemeSelector:p=true,showExportButton:n=true,availableUsers:c=[],templates:d,enableAutoCriticalPath:i=true,aiAssistant:u,locale:v="en",customTranslations:x,showCreateTaskButton:y=false,createTaskLabel:h,onCreateTask:f,onThemeChange:g,onTaskClick:C,onTaskDblClick:T,onTaskContextMenu:b,onTaskUpdate:N,onProgressChange:k,onTaskEdit:S,onTaskAddSubtask:w,onTaskMarkIncomplete:z,onTaskSetInProgress:$,onDependencyCreate:F,onDependencyDelete:_,onBeforeTaskAdd:E,onAfterTaskAdd:G,onBeforeTaskUpdate:J,onAfterTaskUpdate:Z,onBeforeTaskDelete:O,onAfterTaskDelete:ee}=a,le=react.useContext(qr)?.theme,[M,fe]=react.useState(le||s||"dark"),[oe,qe]=react.useState(l),[Je,Ut]=react.useState(m),[xe,ut]=react.useState(1),[kt,ba]=react.useState(0),[ha,va]=react.useState(false),[ht,rt]=react.useState(null),[we,$t]=react.useState({isOpen:false,x:0,y:0,task:null}),[Kt,Rt]=react.useState(null),[Wt,Et]=react.useState(null);react.useEffect(()=>{le&&le!==M&&fe(le);},[le]),react.useEffect(()=>{s&&s!==M&&fe(s);},[s]);let W=react.useCallback(D=>{fe(D),g?.(D);},[g]),{state:L,setState:X,undo:de,redo:te,canUndo:Ht,canRedo:j,clearHistory:he}=bl(t,50);react.useEffect(()=>{X(t);},[t,X]);let ce=react.useRef(t),Te=react.useRef(true);react.useEffect(()=>{if(Te.current){Te.current=false,ce.current=L;return}if(!r)return;let D=JSON.stringify(ce.current),I=JSON.stringify(L);D!==I&&(ce.current=L,r(L));},[L,r]);let Se=react.useMemo(()=>xn(v,x),[v,x]),ne=react.useCallback(D=>[{id:"name",label:D.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:false},{id:"startDate",label:D.columns.startDate,width:110,visible:false,sortable:true},{id:"endDate",label:D.columns.endDate,width:110,visible:false,sortable:true},{id:"duration",label:D.columns.duration,width:80,visible:false,sortable:true},{id:"assignees",label:D.columns.assignees,width:120,visible:false,sortable:false},{id:"status",label:D.columns.status,width:80,visible:false,sortable:true},{id:"progress",label:D.columns.progress,width:120,visible:false,sortable:true},{id:"priority",label:D.columns.priority,width:90,visible:false,sortable:true}],[]),[Ie,ie]=react.useState(()=>ne(Se));react.useEffect(()=>{ie(D=>D.map(I=>({...I,label:Se.columns[I.id==="name"?"taskName":I.id]||I.label})));},[Se]);let gt=react.useMemo(()=>Ie.filter(D=>D.visible).reduce((D,I)=>D+I.width,0)+60,[Ie]),Nt=ht||gt,P=react.useRef(null),Q=react.useRef(null),Ne=react.useRef(null),Ee=react.useMemo(()=>Fi(M),[M]),na=react.useMemo(()=>({theme:Ee,themeName:M}),[Ee,M]),Ps=react.useMemo(()=>vl(d),[d]),Ms=react.useMemo(()=>{if(!i)return L;let D=V.calculateCriticalPath(L),I=U=>U.map(q=>({...q,isCriticalPath:D.includes(q.id),subtasks:q.subtasks?I(q.subtasks):void 0}));return I(L)},[L,i]),Ar=ng(Je);hl({undo:de,redo:te,canUndo:Ht,canRedo:j,enabled:true}),react.useImperativeHandle(o,()=>({getTask:D=>V.findTaskById(L,D),addTask:(D,I)=>{X(U=>{if(!I)return [...U,{...D,level:0}];let q=se=>se.map(me=>me.id===I?{...me,subtasks:[...me.subtasks||[],{...D,parentId:I,level:(me.level||0)+1}],isExpanded:true}:me.subtasks?{...me,subtasks:q(me.subtasks)}:me);return q(U)});},updateTask:(D,I)=>{X(U=>{let q=se=>se.map(me=>me.id===D?{...me,...I}:me.subtasks?{...me,subtasks:q(me.subtasks)}:me);return q(U)});},deleteTask:D=>{X(I=>{let U=q=>q.filter(se=>se.id===D?false:(se.subtasks&&(se.subtasks=U(se.subtasks)),true));return U(I)});},deleteTasks:D=>{X(I=>Sn(I,D));},duplicateTask:D=>{X(I=>En(I,[D]));},splitTask:(D,I,U=3)=>{X(q=>V.splitTask(q,D,I,U));},calculateEndDate:V.calculateEndDate,calculateDuration:V.calculateDuration,validateDependency:(D,I)=>!V.validateDependencies(L,D,I),getAllTasks:()=>V.flattenTasks(L),getTasksByStatus:D=>V.flattenTasks(L).filter(I=>I.status===D),getTasksByParent:D=>D?V.findTaskById(L,D)?.subtasks||[]:L.filter(U=>!U.parentId),getCriticalPath:()=>V.flattenTasks(L).filter(D=>D.isCriticalPath),indentTask:D=>{X(I=>Tn(I,[D]));},outdentTask:D=>{X(I=>Nn(I,[D]));},moveTask:(D,I)=>{X(U=>Dn(U,[D],I));},createSubtask:async D=>{let{tasks:I,newTask:U}=In(L,D);if(E){let q=E({...U,parentId:D});if((q instanceof Promise?await q:q)===false)return}X(I),G&&G({...U,parentId:D});},scrollToTask:D=>{let U=V.flattenTasks(L).findIndex(q=>q.id===D);if(U!==-1&&P.current){let q=U*Ar;P.current.scrollTo({top:q,behavior:"smooth"}),Q.current&&Q.current.scrollTo({top:q,behavior:"smooth"});}},highlightTask:(D,I=2e3)=>{},expandTask:D=>{X(I=>{let U=q=>q.map(se=>se.id===D?{...se,isExpanded:true}:se.subtasks?{...se,subtasks:U(se.subtasks)}:se);return U(I)});},collapseTask:D=>{X(I=>{let U=q=>q.map(se=>se.id===D?{...se,isExpanded:false}:se.subtasks?{...se,subtasks:U(se.subtasks)}:se);return U(I)});},expandAll:()=>{X(D=>{let I=U=>U.map(q=>({...q,isExpanded:true,subtasks:q.subtasks?I(q.subtasks):void 0}));return I(D)});},collapseAll:()=>{X(D=>{let I=U=>U.map(q=>({...q,isExpanded:false,subtasks:q.subtasks?I(q.subtasks):void 0}));return I(D)});},undo:de,redo:te,canUndo:()=>Ht,canRedo:()=>j,clearHistory:he,exportToPNG:async()=>{if(!Ne.current)throw new Error("Gantt container not found");let D=await xl__default.default(Ne.current,{backgroundColor:Ee.bgPrimary,scale:2});return new Promise((I,U)=>{D.toBlob(q=>{q?I(q):U(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async D=>{await V.exportToPDF(L,D);},exportToExcel:async D=>{await V.exportToExcel(L,D);},exportToJSON:()=>V.exportToJSON(L),exportToCSV:()=>V.exportToCSV(L),importFromJSON:D=>{let I=V.importFromJSON(D);X(I);},getTasks:()=>L,refresh:()=>{X(D=>[...D]);},clearAll:()=>{X([]);}}),[L,de,te,Ht,j,he,Ee,Ar]);let Ld=react.useCallback(D=>{ie(I=>I.map(U=>U.id===D?{...U,visible:!U.visible}:U));},[]),Ad=react.useCallback((D,I)=>{ie(U=>U.map(q=>{if(q.id!==D)return q;let se=q.minWidth??100,me=q.maxWidth??800,st=Math.max(se,Math.min(me,I));return {...q,width:st}}));},[]),Bd=react.useCallback(D=>{X(I=>Mn(I,D)),a.onTaskToggleExpand?.(D);},[a]),Va=react.useCallback((D,I)=>{if(J&&J(D,I)===false)return;let q=V.findTaskById(L,D)?.progress,se=st=>st.map(wt=>wt.id===D?{...wt,...I}:wt.subtasks?{...wt,subtasks:se(wt.subtasks)}:wt);X(se(L));let me=V.findTaskById(se(L),D);me&&(N?.(me),Z?.(me),I.progress!==void 0&&q!==void 0&&I.progress!==q&&k?.(D,q,I.progress));},[L,N,J,Z,k]),Rd=react.useCallback(D=>{D.length!==0&&(X(I=>Tn(I,D)),a.onTaskIndent?.(D[0]));},[a]),Od=react.useCallback(D=>{D.length!==0&&(X(I=>Nn(I,D)),a.onTaskOutdent?.(D[0]));},[a]),zd=react.useCallback((D,I)=>{D.length!==0&&(X(U=>Dn(U,D,I)),a.onTaskMove?.(D[0],I));},[a]),Po=react.useCallback(async D=>{let I=[];for(let U of D)O&&await Promise.resolve(O(U))===false||I.push(U);I.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(I):(X(U=>Sn(U,I)),I.forEach(U=>a.onTaskDelete?.(U))),ee&&I.forEach(U=>ee(U)));},[a,O,ee]),Gd=react.useCallback(D=>{X(I=>En(I,D)),D.forEach(I=>a.onTaskDuplicate?.(I));},[a]),Ud=react.useCallback((D,I)=>{X(U=>{let{tasks:q,newTask:se}=qi(U,D,I);return E&&E(se)===false?U:(a.onTaskCreate?.(se.parentId,se.position||0),G?.(se),q)});},[a,E,G]),$d=react.useCallback((D,I)=>{X(U=>Pn(U,D,I)),a.onTaskRename?.(D,I);},[a]),Is=react.useCallback(D=>{X(I=>{let{tasks:U}=In(I,D);return a.onTaskCreate?.(D,0),U});},[a]),Wd=react.useCallback((D,I,U)=>{let q=D.startDate?Math.round((I.getTime()-D.startDate.getTime())/864e5):0,se=wt=>wt.map(Yt=>Yt.id===D.id?{...Yt,startDate:I,endDate:U,...D.segments&&{segments:D.segments}}:Yt.subtasks?{...Yt,subtasks:se(Yt.subtasks)}:Yt),me=se(L);me=V.autoScheduleDependents(me,D.id,q),X(me);let st={...D,startDate:I,endDate:U};N?.(st);},[L,N]),Hd=react.useCallback((D,I)=>{b?.(D,I),$t({isOpen:true,x:I.clientX,y:I.clientY,task:D});},[b]),_d=react.useCallback((D,I)=>{let U=V.splitTask(L,D.id,I);X(U),$t({isOpen:false,x:0,y:0,task:null});},[L]),Fs=react.useCallback(D=>{T?.(D),S||Rt(D);},[T,S]),Ls=react.useCallback((D,I,U)=>{let q=new Map,se=Xt=>{Xt.forEach(ca=>{ca.dependencies&&q.set(ca.id,ca.dependencies),ca.subtasks&&se(ca.subtasks);});};se(U);let me=q.get(I)||[];q.set(I,[...me,D]);let st=new Set,wt=new Set,Yt=Xt=>{if(!st.has(Xt)){st.add(Xt),wt.add(Xt);let ca=q.get(Xt)||[];for(let cr of ca){if(!st.has(cr)&&Yt(cr))return true;if(wt.has(cr))return true}}return wt.delete(Xt),false};return Yt(I)},[]),As=react.useCallback((D,I)=>{if(Ls(D.id,I,L)){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 U=q=>q.map(se=>{if(se.id===I){let me=se.dependencies||[];if(!me.includes(D.id))return {...se,dependencies:[...me,D.id]}}return se.subtasks?{...se,subtasks:U(se.subtasks)}:se});X(U(L)),F?.(D.id,I);},[L,F,Ls]),Bs=react.useCallback((D,I)=>{let U=q=>q.map(se=>{if(se.id===D&&se.dependencies){let me=se.dependencies.filter(st=>st!==I);return {...se,dependencies:me}}return se.subtasks?{...se,subtasks:U(se.subtasks)}:se});X(U(L)),_?.(D,I);},[L,_]),{startDate:Vd,endDate:jd}=react.useMemo(()=>{let D=L.filter(me=>me.startDate&&me.endDate);if(D.length===0){let me=new Date,st=new Date(me);st.setDate(st.getDate()-30);let wt=new Date(me);return wt.setDate(wt.getDate()+60),{startDate:st,endDate:wt}}let I=D.flatMap(me=>[me.startDate,me.endDate]).filter(me=>me!==void 0),U=new Date(Math.min(...I.map(me=>me.getTime()))),q=new Date(Math.max(...I.map(me=>me.getTime()))),se=oe==="day"?7:oe==="week"?14:30;return U.setDate(U.getDate()-se),q.setDate(q.getDate()+se),{startDate:U,endDate:q}},[L,oe]),Kd=react.useCallback(async()=>{if(!Ne.current)return;let D=await xl__default.default(Ne.current,{backgroundColor:Ee.bgPrimary,scale:2}),I=document.createElement("a");I.download="gantt-chart.png",I.href=D.toDataURL("image/png"),I.click();},[Ee]),Yd=react.useCallback(async()=>{await V.exportToPDF(L);},[L]),Xd=react.useCallback(async()=>{await V.exportToExcel(L);},[L]),qd=react.useCallback(()=>{let D=V.exportToCSV(L),I=new Blob([D],{type:"text/csv;charset=utf-8;"}),U=document.createElement("a");U.href=URL.createObjectURL(I),U.download="gantt-chart.csv",U.click(),URL.revokeObjectURL(U.href);},[L]),Jd=react.useCallback(()=>{let D=V.exportToJSON(L),I=new Blob([D],{type:"application/json;charset=utf-8;"}),U=document.createElement("a");U.href=URL.createObjectURL(I),U.download="gantt-chart.json",U.click(),URL.revokeObjectURL(U.href);},[L]),Zd=react.useCallback(()=>{V.exportToMSProject(L,"Gantt Project","project.xml");},[L]),Qd=D=>{D.preventDefault(),va(true);};return react.useEffect(()=>{let D=Q.current,I=P.current;if(!D||!I)return;let U=I.querySelector(".gantt-taskgrid-content"),q=()=>{let st=D.scrollTop;ba(st),U&&(U.style.transform=`translateY(-${st}px)`);},se=st=>{if(ha&&I){let Yt=I.parentElement?.getBoundingClientRect()?.left||0,Xt=st.clientX-Yt,ca=200,cr=Math.min(window.innerWidth-300,800);Xt>=ca&&Xt<=cr&&rt(Xt);}},me=()=>{va(false);};return D.addEventListener("scroll",q),document.addEventListener("mousemove",se),document.addEventListener("mouseup",me),()=>{D.removeEventListener("scroll",q),document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",me);}},[ha]),jsxRuntime.jsx(rr.Provider,{value:Se,children:jsxRuntime.jsx(Ao.Provider,{value:na,children:jsxRuntime.jsxs("div",{ref:Ne,className:"flex flex-col h-full w-full",style:{backgroundColor:Ee.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsxRuntime.jsx(Zr,{theme:Ee,timeScale:oe,onTimeScaleChange:qe,zoom:xe,onZoomChange:ut,currentTheme:M,onThemeChange:W,rowDensity:Je,onRowDensityChange:Ut,showThemeSelector:p,showCreateTaskButton:y,createTaskLabel:h,onCreateTask:f,onExportPNG:n?Kd:void 0,onExportPDF:n?Yd:void 0,onExportExcel:n?Xd:void 0,onExportCSV:n?qd:void 0,onExportJSON:n?Jd:void 0,onExportMSProject:n?Zd:void 0}),jsxRuntime.jsxs("div",{ref:P,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsxRuntime.jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:Nt,overflow:"hidden"},children:jsxRuntime.jsx(eo,{tasks:Ms,theme:Ee,rowHeight:Ar,availableUsers:c,templates:Ps,onTaskClick:C,onTaskDblClick:Fs,onTaskContextMenu:b,onTaskToggle:Bd,scrollTop:kt,columns:Ie,onToggleColumn:Ld,onColumnResize:Ad,onTaskUpdate:Va,onTaskIndent:Rd,onTaskOutdent:Od,onTaskMove:zd,onMultiTaskDelete:Po,onTaskDuplicate:Gd,onTaskCreate:Ud,onTaskRename:$d,onCreateSubtask:Is,onOpenTaskModal:C?D=>C(D):void 0,onDeleteRequest:(D,I)=>Et({taskId:D,taskName:I})})}),jsxRuntime.jsx("div",{className:"flex-shrink-0 cursor-col-resize",style:{width:6,marginLeft:-3,zIndex:10},onMouseDown:Qd}),jsxRuntime.jsx("div",{ref:Q,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsxRuntime.jsx(lo,{tasks:Ms,theme:Ee,rowHeight:Ar,timeScale:oe,startDate:Vd,endDate:jd,zoom:xe,templates:Ps,onTaskClick:C,onTaskDblClick:Fs,onTaskContextMenu:Hd,onTaskDateChange:Wd,onDependencyCreate:As,onDependencyDelete:Bs})})]}),we.task&&jsxRuntime.jsx(or,{isOpen:we.isOpen,x:we.x,y:we.y,theme:Ee,onClose:()=>$t({isOpen:false,x:0,y:0,task:null}),items:[{id:"edit",label:Se.contextMenu?.editTask||"Edit Task",icon:dt.Pencil,onClick:()=>{we.task&&(S?S(we.task):Rt(we.task));}},{id:"addSubtask",label:Se.contextMenu?.addSubtask||"Add Subtask",icon:dt.Add,onClick:()=>{we.task&&(w?w(we.task):Is(we.task.id));}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:Se.contextMenu?.markIncomplete||"Mark Incomplete",icon:dt.MarkIncomplete,onClick:()=>{we.task&&(z?z(we.task):Va(we.task.id,{status:"todo",progress:0}));},disabled:we.task?.status==="todo"},{id:"setInProgress",label:Se.contextMenu?.setInProgress||"Set In Progress",icon:dt.SetInProgress,onClick:()=>{we.task&&($?$(we.task):Va(we.task.id,{status:"in-progress"}));},disabled:we.task?.status==="in-progress"},{id:"markComplete",label:Se.contextMenu?.markComplete||"Mark Complete",icon:dt.MarkComplete,onClick:()=>{we.task&&Va(we.task.id,{status:"completed",progress:100});},disabled:we.task?.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:Se.contextMenu?.splitTask||"Split Task",icon:dt.Split,onClick:()=>{if(!we.task?.startDate||!we.task?.endDate){console.warn("Cannot split task without dates");return}let D=we.task.startDate.getTime(),I=we.task.endDate.getTime(),U=D+(I-D)/2,q=new Date(U);_d(we.task,q);},disabled:!we.task?.startDate||!we.task?.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:Se.contextMenu?.deleteTask||"Delete Task",icon:dt.Delete,onClick:()=>{we.task&&Et({taskId:we.task.id,taskName:we.task.name});}}]}),Kt&&jsxRuntime.jsx(co,{isOpen:true,onClose:()=>Rt(null),task:Kt,onSubmit:D=>{Va(Kt.id,D),Rt(null);},mode:"edit",theme:M}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:Wt&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[10000] flex items-center justify-center p-4",style:{backgroundColor:"rgba(0, 0, 0, 0.6)"},onClick:()=>Et(null),children:jsxRuntime.jsxs(framerMotion.motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.2,ease:"easeOut"},onClick:D=>D.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:Ee.bgSecondary,border:`1px solid ${Ee.border}`},children:[jsxRuntime.jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${Ee.border}`},children:jsxRuntime.jsxs("div",{className:"flex items-start gap-3",children:[jsxRuntime.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"rgba(239, 68, 68, 0.2)"},children:jsxRuntime.jsx(lucideReact.AlertTriangle,{className:"w-5 h-5",style:{color:"#EF4444"}})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("h3",{className:"text-lg font-semibold",style:{color:Ee.textPrimary,fontFamily:"Inter, sans-serif"},children:[Se.contextMenu?.deleteTask||"Delete Task","?"]}),jsxRuntime.jsx("p",{className:"text-sm mt-1",style:{color:Ee.textSecondary,fontFamily:"Inter, sans-serif"},children:v==="es"?"Esta acci\xF3n no se puede deshacer":"This action cannot be undone"})]})]})}),jsxRuntime.jsx("div",{className:"px-6 py-4",children:jsxRuntime.jsxs("p",{className:"text-sm leading-relaxed",style:{color:Ee.textSecondary,fontFamily:"Inter, sans-serif"},children:[v==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxRuntime.jsxs("span",{className:"font-semibold",style:{color:Ee.textPrimary},children:['"',Wt.taskName,'"']}),"."]})}),jsxRuntime.jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:Ee.bgPrimary,borderTop:`1px solid ${Ee.border}`},children:[jsxRuntime.jsx("button",{onClick:()=>Et(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:Ee.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:D=>{D.currentTarget.style.backgroundColor=Ee.hoverBg;},onMouseLeave:D=>{D.currentTarget.style.backgroundColor="transparent";},children:v==="es"?"Cancelar":"Cancel"}),jsxRuntime.jsxs("button",{onClick:()=>{Po([Wt.taskId]),Et(null);},className:"px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:"#EF4444",fontFamily:"Inter, sans-serif"},onMouseEnter:D=>{D.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:D=>{D.currentTarget.style.backgroundColor="#EF4444";},children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"}),v==="es"?"Eliminar":"Delete"]})]})]})})}),u?.enabled&&jsxRuntime.jsx(po,{tasks:L,theme:Ee,config:u,onTasksUpdate:X,onTaskUpdate:Va,onTaskCreate:D=>{X(I=>[...I,D]);},onTaskDelete:D=>{Po([D]);},onDependencyCreate:(D,I)=>{let U=V.findTaskById(L,D);U&&As(U,I);},onDependencyDelete:Bs})]})})})});var wl=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
|
|
279
279
|
|