@libxai/board 0.17.138 → 0.17.139

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.js CHANGED
@@ -273,7 +273,7 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
273
273
  </Calendars>
274
274
  <Tasks>${c}
275
275
  </Tasks>
276
- </Project>`,p=new Blob([n],{type:"application/xml;charset=utf-8;"}),l=document.createElement("a");l.href=URL.createObjectURL(p),l.download=a,l.click(),URL.revokeObjectURL(l.href);},calculateCriticalPath:e=>{let t=oe.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 p=n.startDate&&n.endDate?oe.calculateDuration(n.startDate,n.endDate):0,l=0;if(n.dependencies&&n.dependencies.length>0)for(let u of n.dependencies){let v=t.find(f=>f.id===u);if(v){o(v);let f=r.get(u)?.ef||0;l=Math.max(l,f);}}let i=l+p;r.set(n.id,{es:l,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(n=>n.ef)),d=new Map,m=n=>{if(d.has(n.id))return;let p=n.startDate&&n.endDate?oe.calculateDuration(n.startDate,n.endDate):0,l=t.filter(v=>v.dependencies&&v.dependencies.includes(n.id)),i=s;if(l.length>0)for(let v of l){m(v);let f=d.get(v.id)?.ls||0;i=Math.min(i,f);}let u=i-p;d.set(n.id,{ls:u,lf:i});};a.forEach(m);let c=[];for(let n of a){let p=r.get(n.id),l=d.get(n.id);if(p&&l){let i=l.ls-p.es;Math.abs(i)<.01&&c.push(n.id);}}return c},calculateSlack:(e,t)=>{let a=oe.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(oe.calculateCriticalPath(e).includes(t))return 0;let o=oe.getDependentTasks(e,t);if(o.length===0){let m=oe.getLatestEndDate(e);if(!m)return null;let c=oe.calculateDuration(a.endDate,m);return Math.max(0,c)}let s=o.filter(m=>m.startDate).map(m=>m.startDate.getTime()).sort((m,c)=>m-c)[0];if(!s)return null;let d=oe.calculateDuration(a.endDate,new Date(s));return Math.max(0,d)},isOnCriticalPath:(e,t)=>oe.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=oe.findTaskById(e,t);if(!r||!r.endDate)return e;let o=oe.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let d of o){if(!d.startDate||!d.endDate)continue;let m=oe.calculateDuration(d.startDate,d.endDate),c;a!==void 0?(c=new Date(d.startDate),c.setDate(c.getDate()+a)):(c=new Date(r.endDate),c.setDate(c.getDate()+1));let n=oe.calculateEndDate(c,m),p=l=>l.map(i=>i.id===d.id?{...i,startDate:c,endDate:n}:i.subtasks?{...i,subtasks:p(i.subtasks)}:i);s=p(s),s=oe.autoScheduleDependents(s,d.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,d,m)=>{if(a===0)return [];let c=[],n=o.getTime(),p=1e3*60*60*24,l=oe.findTaskById(e,t);if(!l||!l.endDate)return [];let i=(u,v,f=new Set)=>{if(f.has(u))return;f.add(u);let y=oe.getDependentTasks(e,u);for(let x of y){if(!x.startDate||!x.endDate)continue;let b=r.findIndex(U=>U.id===x.id);if(b===-1)continue;let g=x.startDate.getTime(),D=(x.endDate.getTime()-g)/p,A=(g-n)/p*s,C=A+v*s,L=Math.max(D*s,s),T=m+b*d+12;c.push({taskId:x.id,taskName:x.name,originalX:A,previewX:C,width:L,y:T,rowIndex:b,daysDelta:v,color:x.color}),i(x.id,v,f);}};return i(t,a),c},splitTask:(e,t,a,r=3)=>{let o=oe.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 d=new Date(a);d.setDate(d.getDate()+r);let m=new Date(o.endDate);m.setDate(m.getDate()+r);let c=[{startDate:new Date(o.startDate),endDate:s},{startDate:d,endDate:m}],n=p=>p.map(l=>l.id===o.id?{...l,endDate:m,segments:c}:l.subtasks?{...l,subtasks:n(l.subtasks)}:l);return n(e)}};function Ko({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:d,templates:m,onTaskClick:c,onTaskDblClick:n,onTaskContextMenu:p,onTaskDateChange:l,onDependencyCreate:i,onDependencyDelete:u}){let[f,y]=useState([]),[x,b]=useState(null),[g,w]=useState(null),D=useCallback(S=>{b(S);},[]),h=useCallback(S=>{w(S);},[]),A=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),C=r==="day"?60:r==="week"?20:8,L=A*C*d,T=S=>{let F=new Date(Date.UTC(S.getFullYear(),S.getMonth(),S.getDate())),M=F.getUTCDay()||7;F.setUTCDate(F.getUTCDate()+4-M);let V=new Date(Date.UTC(F.getUTCFullYear(),0,1));return Math.ceil(((F.getTime()-V.getTime())/864e5+1)/7)},U=S=>{let F=S.getDay();return F===0||F===6},G=useCallback(S=>{let F=Math.round(S/(C*d)),M=new Date(o);return M.setDate(M.getDate()+F),M},[o,C,d]),$=useCallback((S,F)=>{if(F.startDate&&F.endDate)return;let M=S.currentTarget.ownerSVGElement;if(!M)return;let V=M.createSVGPoint();V.x=S.clientX,V.y=S.clientY;let P=V.matrixTransform(M.getScreenCTM()?.inverse()),W=G(P.x),de=new Date(W);de.setDate(de.getDate()+1),l?.(F,W,de);},[G,l]),E=useMemo(()=>{let S=P=>P.map(W=>{if(W.subtasks&&W.subtasks.length>0){let de=S(W.subtasks),ae=de.filter(Ee=>Ee.startDate&&Ee.endDate);if(ae.length>0){let Ee=ae.map(at=>at.startDate.getTime()),le=ae.map(at=>at.endDate.getTime()),Ve=new Date(Math.min(...Ee)),he=new Date(Math.max(...le));return {...W,subtasks:de,startDate:Ve,endDate:he}}return {...W,subtasks:de}}return W}),F=(P,W=[])=>{for(let de of P)W.push(de),de.subtasks&&de.subtasks.length>0&&(de.isExpanded===void 0||de.isExpanded)&&F(de.subtasks,W);return W},M=S(e);return F(M)},[e]),X=useCallback(S=>{if(!S.startDate||!S.endDate)return {x:0,width:0};let F=S.startDate.getTime(),M=S.endDate.getTime(),V=o.getTime(),P=(F-V)/(1e3*60*60*24),W=(M-F)/(1e3*60*60*24),de=P*C*d,ae=Math.max(C*d,40),Ee=Math.max(W*C*d,ae);return {x:de,width:Ee}},[o,C,d]),fe=useMemo(()=>E.filter(S=>S.startDate&&S.endDate).map(S=>{let{x:F,width:M}=X(S),P=E.findIndex(W=>W.id===S.id)*a+12;return {id:S.id,x:F,y:P,width:M,height:32}}),[E,X]),Ce=useCallback((S,F,M)=>{if(!M||F===0){y([]);return}let V=oe.calculateCascadePreview(e,S,F,E,o,C*d,a,48);y(V);},[e,E,o,C,d,a,48]),Le=useMemo(()=>{let S=[],F=new Date(o);for(;F<=s;){let P=(F.getTime()-o.getTime())/864e5*C*d;if(r==="day")S.push({date:new Date(F),label:F.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:P}),F.setDate(F.getDate()+1);else if(r==="week"){let W=T(F);S.push({date:new Date(F),label:`Week ${W}`,x:P}),F.setDate(F.getDate()+7);}else S.push({date:new Date(F),label:F.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:P}),F.setMonth(F.getMonth()+1);}return S},[o,s,r,C,d]),Pe=useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*C*d,[o,C,d]),ce=Math.max(E.length*a,552);return jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary,overflow:"visible"},children:[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:jsxs("svg",{width:Math.max(L,1e3),height:47,style:{display:"block"},children:[jsx("rect",{x:0,y:0,width:Math.max(L,1e3),height:48,fill:t.bgGrid}),Le.map((S,F)=>jsxs("g",{children:[F>0&&jsx("line",{x1:S.x,y1:0,x2:S.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsx("text",{x:S.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:S.label})]},`header-${F}`)),Pe>=0&&Pe<=L&&jsx("circle",{cx:Pe,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxs("svg",{width:Math.max(L,1e3),height:ce,style:{display:"block",flexShrink:0,overflow:"visible"},children:[jsxs("defs",{children:[jsx("filter",{id:"shadow",children:jsx("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2",floodOpacity:"0.1"})}),jsx("pattern",{id:"diagonal-stripes",width:"8",height:"8",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:jsx("line",{x1:"0",y1:"0",x2:"0",y2:"8",stroke:t.border,strokeWidth:"2"})})]}),jsx("rect",{x:0,y:0,width:Math.max(L,1e3),height:ce,fill:t.bgPrimary}),Le.map((S,F)=>{let M=Le[F+1]?.x||L,V=U(S.date);return jsxs("g",{children:[V&&jsx("rect",{x:S.x,y:0,width:M-S.x,height:E.length*a,fill:t.bgWeekend,opacity:1}),F>0&&jsx("line",{x1:S.x,y1:0,x2:S.x,y2:E.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},F)}),Pe>=0&&Pe<=L&&jsx("line",{x1:Pe,y1:0,x2:Pe,y2:E.length*a,stroke:t.today,strokeWidth:2,opacity:1}),E.map((S,F)=>{let M=S.startDate&&S.endDate;return jsxs("g",{children:[jsx("rect",{x:0,y:F*a,width:L,height:a,fill:F%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${S.id}`),!M&&jsxs(Fragment,{children:[jsx("rect",{x:0,y:F*a,width:L,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:V=>$(V,S),onMouseEnter:V=>{V.currentTarget.setAttribute("fill",t.accentLight),V.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:V=>{V.currentTarget.setAttribute("fill","transparent"),V.currentTarget.setAttribute("opacity","1");}},`clickable-${S.id}`),jsx("text",{x:Pe>0?Pe:100,y:F*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-${S.id}`)]})]},`row-group-${S.id}`)}),E.map((S,F)=>!S.dependencies||S.dependencies.length===0||!S.startDate||!S.endDate?null:S.dependencies.map(M=>{let V=E.find(ae=>ae.id===M);if(!V||!V.startDate||!V.endDate)return null;let P=E.findIndex(ae=>ae.id===M),W=X(V),de=X(S);return jsx(Ho,{x1:W.x+W.width,y1:P*a+a/2,x2:de.x,y2:F*a+a/2,theme:t,onDelete:()=>u?.(S.id,M),onHoverChange:h},`dep-${M}-${S.id}`)})),E.map((S,F)=>{if(!S.startDate||!S.endDate)return null;let{x:M,width:V}=X(S),P=F*a+12,W=S.subtasks&&S.subtasks.length>0&&!S.isMilestone;return S.isMilestone?jsx(Vo,{task:S,x:M+V/2,y:P+16,theme:t,onClick:c},S.id):W?jsxs("g",{onClick:()=>c?.(S),onContextMenu:de=>{de.preventDefault(),de.stopPropagation(),p?.(S,de);},style:{cursor:"default"},children:[jsx("rect",{x:M,y:P,width:V,height:32,fill:t.primary,opacity:.25,rx:6}),jsx("line",{x1:M,y1:P,x2:M+V,y2:P,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:M,y1:P,x2:M,y2:P+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:M+V,y1:P,x2:M+V,y2:P+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:M,y1:P+32,x2:M+V,y2:P+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),V>60&&jsx("text",{x:M+12,y:P+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:S.name})]},S.id):jsx(zo,{task:S,x:M,y:P,width:V,theme:t,dayWidth:C*d,startDate:o,templates:m,onClick:c,onDoubleClick:n,onContextMenu:p,onDateChange:l,onDependencyCreate:i,allTaskPositions:fe,onDragMove:Ce,onHoverChange:D},S.id)}),f.map(S=>jsxs("g",{style:{pointerEvents:"none"},children:[jsx("rect",{x:S.previewX,y:S.y-48,width:S.width,height:32,rx:8,fill:S.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(S.daysDelta)>0&&jsx("text",{x:S.previewX+S.width/2,y:S.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:S.daysDelta>0?`+${S.daysDelta}d`:`${S.daysDelta}d`})]},`cascade-preview-${S.taskId}`)),g&&(()=>{let{x1:S,y1:F,x2:M,y2:V,onDelete:P}=g,W=M-S,de=V-F,ae=S+W/2,Ee=(F+V)/2,le=`M ${S} ${F} C ${ae} ${F}, ${ae} ${V}, ${M} ${V}`,Ve=6,he=Math.atan2(de,W),at=M-Ve*Math.cos(he-Math.PI/6),Et=V-Ve*Math.sin(he-Math.PI/6),gt=M-Ve*Math.cos(he+Math.PI/6),ft=V-Ve*Math.sin(he+Math.PI/6),rt=t.dependency;return jsxs("g",{style:{pointerEvents:"none"},children:[jsx("path",{d:le,fill:"none",stroke:rt,strokeWidth:3,strokeLinecap:"round",opacity:1}),jsx("path",{d:`M ${M} ${V} L ${at} ${Et} M ${M} ${V} L ${gt} ${ft}`,fill:"none",stroke:rt,strokeWidth:3,strokeLinecap:"round",opacity:1}),jsx("circle",{cx:M,cy:V,r:5,fill:rt}),jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:ot=>{ot.stopPropagation(),P();},style:{cursor:"pointer",pointerEvents:"auto"},children:[jsx("circle",{cx:ae,cy:Ee,r:10,fill:t.bgSecondary,stroke:t.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:ae-4,y1:Ee-4,x2:ae+4,y2:Ee+4,stroke:t.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:ae+4,y1:Ee-4,x2:ae-4,y2:Ee+4,stroke:t.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})})(),x&&jsx(sd,{tooltipData:x,theme:t})]})]})}var Yo=[{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:"Coral",value:"#F97316",light:"#FB923C"},{name:"Magenta",value:"#E11D48",light:"#FB7185"}];var Es=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],Ps=[{id:"low",label:"Baja",color:"#10B981",icon:"\u{1F7E2}"},{id:"medium",label:"Media",color:"#F59E0B",icon:"\u{1F7E1}"},{id:"high",label:"Alta",color:"#F97316",icon:"\u{1F7E0}"},{id:"urgent",label:"Urgente",color:"#EF4444",icon:"\u{1F534}"}];function Xo({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:d=false,mode:m=a?"edit":"create",theme:c="dark",customStatuses:n=[]}){let p=[...Es,...n.filter(P=>!Es.some(W=>W.id===P.id))],l=Oe[c]||Oe.dark,[i,u]=useState(false),[v,f]=useState(false),[y,x]=useState(false),[b,g]=useState(false),[w,D]=useState(null),[h,A]=useState(new Date),[C,L]=useState(false),T=useRef(null),U=useRef(null),G=useRef(null),$=useRef(null),[E,X$1]=useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),[fe,Ce]=useState({});useEffect(()=>{a?(X$1({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||[]}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&L(true)):(X$1({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),L(false));},[a,e]),useEffect(()=>{let P=W=>{T.current&&!T.current.contains(W.target)&&u(false),U.current&&!U.current.contains(W.target)&&f(false),G.current&&!G.current.contains(W.target)&&x(false),$.current&&!$.current.contains(W.target)&&g(false);};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[]);let Le=()=>{let P={};return E.name.trim()||(P.name="El nombre es requerido"),E.startDate&&E.endDate&&E.startDate>E.endDate&&(P.endDate="La fecha de fin debe ser posterior a la de inicio"),Ce(P),Object.keys(P).length===0},Pe=async P=>{if(P.preventDefault(),!!Le())try{await s(E),t();}catch(W){console.error("Error submitting task:",W);}},ce=(P,W)=>{X$1(de=>{let ae={...de,[P]:W};if(P==="status"){let Ee=W;Ee==="todo"?ae.progress=0:Ee==="in-progress"?(de.progress===0||de.progress===100)&&(ae.progress=50):Ee==="completed"||Ee==="closed"?ae.progress=100:(Ee==="in-review"||Ee==="review")&&(ae.progress=75);}if(P==="progress"){let Ee=typeof W=="number"?W:parseInt(W,10);Ee===100&&de.status!=="completed"?ae.status="completed":Ee>0&&Ee<100&&de.status==="todo"?ae.status="in-progress":Ee===0&&de.status!=="todo"&&(ae.status="todo");}return ae}),fe[P]&&Ce(de=>{let ae={...de};return delete ae[P],ae});},S=p.find(P=>P.id===E.status)??Es[0],F=Ps.find(P=>P.id===E.priority)??Ps[1],M=Yo.find(P=>P.value===E.color)??Yo[0],V={backgroundColor:l.bgSecondary,border:`1px solid ${l.borderLight}`,color:l.textPrimary};return jsx(AnimatePresence,{children:e&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 z-50",onClick:t}),jsx(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:.15,ease:[.4,0,.2,1]},className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl pointer-events-auto overflow-hidden",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},onClick:P=>P.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${l.border}`},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:S.color||l.accent}}),jsx("span",{className:"text-sm font-medium",style:{color:l.textSecondary},children:m==="create"?"Nueva tarea":"Editar tarea"})]}),jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:l.textTertiary},onMouseEnter:P=>{P.currentTarget.style.backgroundColor=l.hoverBg,P.currentTarget.style.color=l.textPrimary;},onMouseLeave:P=>{P.currentTarget.style.backgroundColor="transparent",P.currentTarget.style.color=l.textTertiary;},disabled:d,children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("form",{onSubmit:Pe,className:"max-h-[calc(100vh-200px)] overflow-y-auto",children:[jsxs("div",{className:"p-5 space-y-4",children:[jsxs("div",{children:[jsx("input",{type:"text",value:E.name,onChange:P=>ce("name",P.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:l.textPrimary},placeholder:"Nombre de la tarea",disabled:d,autoFocus:true}),fe.name&&jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsx(AlertCircle,{className:"w-3 h-3"}),fe.name]})]}),jsx("div",{children:jsx("textarea",{value:E.description||"",onChange:P=>ce("description",P.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:l.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:d})}),jsx("div",{style:{borderTop:`1px solid ${l.borderLight}`}}),jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxs("div",{ref:T,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!d&&u(!i),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...V,borderColor:S.color,backgroundColor:`${S.color}15`},disabled:d,children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:S.color}}),jsx("span",{style:{color:S.color},children:S.title}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:S.color}})]}),jsx(AnimatePresence,{children:i&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[140px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},children:p.map(P=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:W=>W.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:W=>W.currentTarget.style.backgroundColor="transparent",onClick:()=>{ce("status",P.id),u(false);},children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:P.color}}),P.title,E.status===P.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},P.id))})})]}),jsxs("div",{ref:U,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!d&&f(!v),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:d,children:[jsx(Flag,{className:"w-3.5 h-3.5",style:{color:F.color}}),jsx("span",{children:F.label}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsx(AnimatePresence,{children:v&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[130px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},children:Ps.map(P=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:W=>W.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:W=>W.currentTarget.style.backgroundColor="transparent",onClick:()=>{ce("priority",P.id),f(false);},children:[jsx("span",{children:P.icon}),P.label,E.priority===P.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},P.id))})})]}),o.length>0&&jsxs("div",{ref:G,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!d&&x(!y),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:d,children:[E.assignees&&E.assignees.length>0?jsxs(Fragment,{children:[jsx("div",{className:"flex -space-x-1",children:E.assignees.slice(0,3).map((P,W)=>jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] text-white font-medium border-2",style:{backgroundColor:P.color||l.accent,borderColor:l.bgSecondary},children:P.initials},W))}),E.assignees.length>3&&jsxs("span",{style:{color:l.textTertiary},children:["+",E.assignees.length-3]})]}):jsxs(Fragment,{children:[jsx(Users,{className:"w-3.5 h-3.5",style:{color:l.textTertiary}}),jsx("span",{style:{color:l.textTertiary},children:"Asignar"})]}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsx(AnimatePresence,{children:y&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[180px] max-h-[200px] overflow-y-auto rounded-lg shadow-xl",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},children:o.map(P=>{let W=E.assignees?.some(de=>de.name===P.name);return jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:de=>de.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:de=>de.currentTarget.style.backgroundColor="transparent",onClick:()=>{let de=W?(E.assignees||[]).filter(ae=>ae.name!==P.name):[...E.assignees||[],{name:P.name,avatar:P.avatar,initials:P.name.split(" ").map(ae=>ae[0]).join("").toUpperCase().slice(0,2),color:l.accent}];ce("assignees",de);},children:[jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs text-white font-medium",style:{backgroundColor:l.accent},children:P.name.charAt(0).toUpperCase()}),jsx("span",{className:"truncate flex-1",children:P.name}),W&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:l.accent}})]},P.id)})})})]}),jsxs("div",{ref:$,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!d&&g(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:d,children:[jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:E.color}}),jsx("span",{children:M.name}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsx(AnimatePresence,{children:b&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"absolute left-0 top-full mt-1.5 z-50 rounded-lg",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},children:jsx("div",{style:{padding:"14px 18px"},children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 16px)",gap:"14px"},children:Yo.slice(0,16).map(P=>{let W=E.color===P.value;return jsx(motion.button,{type:"button",onClick:()=>{ce("color",P.value),g(false);},style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:P.value,outline:W?`2px solid ${P.value}`:"none",outlineOffset:"3px",cursor:"pointer",border:"none"},whileHover:{scale:1.2},whileTap:{scale:.95},title:P.name},P.value)})})})})})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Calendar,{className:"w-4 h-4",style:{color:l.textTertiary}}),jsxs("div",{className:"flex items-center gap-2 flex-1 relative",children:[jsx("button",{type:"button",onClick:()=>{!d&&!E.isMilestone&&(D(w==="start"?null:"start"),A(E.startDate||new Date));},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...V,opacity:E.isMilestone?.5:1,cursor:E.isMilestone?"not-allowed":"pointer"},disabled:d||E.isMilestone,children:E.startDate?E.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsx("span",{style:{color:l.textTertiary},children:"\u2192"}),jsx("button",{type:"button",onClick:()=>{!d&&!E.isMilestone&&(D(w==="end"?null:"end"),A(E.endDate||E.startDate||new Date));},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...V,opacity:E.isMilestone?.5:1,cursor:E.isMilestone?"not-allowed":"pointer"},disabled:d||E.isMilestone,children:E.endDate?E.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsx(AnimatePresence,{children:w&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>D(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},onClick:P=>P.stopPropagation(),children:[jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${l.border}`},children:[(()=>{let P=new Date,W=new Date(P);W.setDate(P.getDate()+1);let de=new Date(P);de.setDate(P.getDate()+7);let ae=new Date(P);return ae.setDate(P.getDate()+14),[{label:"Hoy",date:P},{label:"Ma\xF1ana",date:W},{label:"Pr\xF3xima semana",date:de},{label:"2 semanas",date:ae}].map((le,Ve)=>jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:l.textPrimary},onMouseEnter:he=>he.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:he=>he.currentTarget.style.backgroundColor="transparent",onClick:()=>{w==="start"?(ce("startDate",le.date),(!E.endDate||le.date>E.endDate)&&ce("endDate",le.date),D("end")):(ce("endDate",le.date),(!E.startDate||le.date<E.startDate)&&ce("startDate",le.date),D(null));},children:le.label},Ve))})(),jsx("div",{style:{borderTop:`1px solid ${l.border}`,margin:"0.5rem 0"}}),jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:P=>P.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:P=>P.currentTarget.style.backgroundColor="transparent",onClick:()=>{ce("startDate",void 0),ce("endDate",void 0),D(null);},children:"Borrar fechas"})]}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("button",{type:"button",onClick:()=>A(new Date(h.getFullYear(),h.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-4 h-4",style:{color:l.textSecondary}})}),jsx("span",{className:"text-sm font-medium",style:{color:l.textPrimary},children:h.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>A(new Date(h.getFullYear(),h.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-4 h-4",style:{color:l.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((P,W)=>jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:l.textTertiary},children:P},W))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let P=h.getFullYear(),W=h.getMonth(),de=new Date(P,W,1).getDay(),ae=new Date(P,W+1,0).getDate(),Ee=new Date,le=[];for(let he=de-1;he>=0;he--)le.push({day:new Date(P,W,-he).getDate(),date:new Date(P,W-1,new Date(P,W,-he).getDate()),isCurrentMonth:false});for(let he=1;he<=ae;he++)le.push({day:he,date:new Date(P,W,he),isCurrentMonth:true});let Ve=42-le.length;for(let he=1;he<=Ve;he++)le.push({day:he,date:new Date(P,W+1,he),isCurrentMonth:false});return le.map((he,at)=>{let Et=he.date.toDateString()===Ee.toDateString(),gt=E.startDate?.toDateString()===he.date.toDateString(),ft=E.endDate?.toDateString()===he.date.toDateString(),rt=E.startDate&&E.endDate&&he.date>=E.startDate&&he.date<=E.endDate;return jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:he.isCurrentMonth?gt||ft?"#FFF":l.textPrimary:l.textTertiary,backgroundColor:gt?"#3B82F6":ft?"#7C3AED":rt?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:Et&&!gt&&!ft?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{w==="start"?(ce("startDate",he.date),E.endDate&&he.date>E.endDate&&ce("endDate",he.date),D("end")):(ce("endDate",he.date),E.startDate&&he.date<E.startDate&&ce("startDate",he.date),D(null));},children:he.day},at)})})()})]})]})]})})]}),fe.endDate&&jsx("span",{className:"text-xs text-red-400",children:fe.endDate})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:"w-4 h-4",style:{color:l.textTertiary}}),jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsx("input",{type:"range",min:"0",max:"100",step:"5",value:E.progress,onChange:P=>ce("progress",parseInt(P.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:l.bgSecondary,accentColor:E.progress<30?"#EF4444":E.progress<70?"#F59E0B":"#10B981"},disabled:d}),jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${E.progress<30?"#EF4444":E.progress<70?"#F59E0B":"#10B981"}20`,color:E.progress<30?"#EF4444":E.progress<70?"#F59E0B":"#10B981"},children:[E.progress,"%"]})]})]}),jsxs("div",{children:[jsxs("button",{type:"button",onClick:()=>L(!C),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:l.textTertiary},children:[jsx(ChevronDown,{className:`w-3 h-3 transition-transform ${C?"rotate-180":""}`}),"Opciones avanzadas"]}),jsx(AnimatePresence,{children:C&&jsx(motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:jsxs("div",{className:"pt-3 space-y-3",children:[jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-lg transition-colors hover:bg-white/5",children:[jsx("input",{type:"checkbox",checked:E.isMilestone,onChange:P=>ce("isMilestone",P.target.checked),className:"w-4 h-4 rounded",style:{accentColor:l.accent},disabled:d}),jsx(Milestone,{className:"w-4 h-4 text-yellow-500"}),jsx("span",{className:"text-sm",style:{color:l.textPrimary},children:"Marcar como hito"})]}),r.length>0&&jsxs("div",{children:[jsxs("label",{className:"flex items-center gap-2 text-xs mb-2",style:{color:l.textTertiary},children:[jsx(Link2,{className:"w-3.5 h-3.5"}),"Dependencias"]}),jsx("div",{className:"flex flex-wrap gap-1.5 max-h-24 overflow-y-auto p-2 rounded-lg",style:{backgroundColor:l.bgSecondary},children:r.filter(P=>P.id!==a?.id).map(P=>{let W=E.dependencies?.includes(P.id);return jsx("button",{type:"button",onClick:()=>{let de=W?(E.dependencies||[]).filter(ae=>ae!==P.id):[...E.dependencies||[],P.id];ce("dependencies",de);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:W?`${l.accent}30`:l.bgPrimary,color:W?l.accent:l.textSecondary,border:`1px solid ${W?l.accent:l.borderLight}`},disabled:d,children:P.name},P.id)})})]})]})})})]})]}),jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${l.border}`},children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:l.textSecondary},onMouseEnter:P=>P.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:P=>P.currentTarget.style.backgroundColor="transparent",disabled:d,children:"Cancelar"}),jsx("button",{type:"submit",disabled:d,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:l.accent,color:"#FFF"},onMouseEnter:P=>!d&&(P.currentTarget.style.opacity="0.9"),onMouseLeave:P=>!d&&(P.currentTarget.style.opacity="1"),children:d?jsxs(Fragment,{children:[jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsx(Fragment,{children:m==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var $g=['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"'],md=()=>jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[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"}),jsx("circle",{cx:"12",cy:"12",r:"4"})]}),Ug=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13"})}),zg=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M18 6L6 18M6 6L18 18"})}),Wg=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M5 12h14"})}),Gg=()=>jsx("div",{className:"flex gap-1 items-center",children:[0,1,2].map(e=>jsx(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 Jo({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:d,onDependencyCreate:m,onDependencyDelete:c}){let[n,p]=useState(false),[l,i]=useState(false),[u,v]=useState([]),[f,y]=useState(""),[x,b]=useState(false),[g,w]=useState(true),D=useRef(null),h=useRef(null),A=useRef(null),{enabled:C=true,placeholder:L='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:T="bottom-right",onCommand:U,suggestions:G=$g,maxHistory:$=50,persistHistory:E}=a,X=E?.storageKey||"gantt-ai-history",fe=E?.maxMessages??5;useEffect(()=>{if(E?.enabled)try{let F=localStorage.getItem(X);if(F){let V=JSON.parse(F).map(P=>({...P,timestamp:new Date(P.timestamp)}));v(V.slice(-fe));}}catch(F){console.warn("[GanttAIAssistant] Failed to load persisted history:",F);}},[E?.enabled,X,fe]),useEffect(()=>{if(E?.enabled&&u.length>0)try{let F=u.filter(M=>!M.isLoading).slice(-fe);localStorage.setItem(X,JSON.stringify(F));}catch(F){console.warn("[GanttAIAssistant] Failed to persist history:",F);}},[u,E?.enabled,X,fe]),useEffect(()=>{h.current&&h.current.scrollIntoView({behavior:"smooth"});},[u]),useEffect(()=>{n&&!l&&D.current&&setTimeout(()=>D.current?.focus(),100);},[n,l]);let Ce=useCallback(F=>{if(F.success)switch(F.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":F.taskId&&F.updates&&o?.(F.taskId,F.updates);break;case "create_task":F.newTask&&s?.(F.newTask);break;case "delete_task":F.taskId&&d?.(F.taskId);break;case "link_tasks":F.dependencyFrom&&F.dependencyTo&&m?.(F.dependencyFrom,F.dependencyTo);break;case "unlink_tasks":F.taskId&&F.dependencyFrom&&c?.(F.taskId,F.dependencyFrom);break}},[o,s,d,m,c]),Le=useCallback(async F=>{if(!F.trim()||x)return;let M={id:`user-${Date.now()}`,role:"user",content:F,timestamp:new Date};v(P=>[...P.slice(-($-1)),M]),y(""),w(false),b(true);let V={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};v(P=>[...P,V]);try{if(U){let P=await U(F,e);v(W=>{let de=W.filter(Ee=>!Ee.isLoading),ae={id:`assistant-${Date.now()}`,role:"assistant",content:P.message,timestamp:new Date,command:P};return [...de,ae]}),Ce(P);}else v(P=>[...P.filter(de=>!de.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(P){v(W=>[...W.filter(ae=>!ae.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${P instanceof Error?P.message:"Unknown error"}`,timestamp:new Date}]);}finally{b(false);}},[x,$,U,e,Ce]),Pe=F=>{F.preventDefault(),Le(f);},ce=F=>{y(F),D.current?.focus();};if(useEffect(()=>{let F=M=>{(M.metaKey||M.ctrlKey)&&M.key==="k"&&(M.preventDefault(),p(V=>!V),n||i(false)),M.key==="Escape"&&n&&p(false);};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[n]),useEffect(()=>{if(!n)return;let F=V=>{let P=V.target;A.current&&!A.current.contains(P)&&p(false);},M=setTimeout(()=>{document.addEventListener("mousedown",F);},100);return ()=>{clearTimeout(M),document.removeEventListener("mousedown",F);}},[n]),!C)return null;let S={"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 jsxs(Ye,{children:[jsx(AnimatePresence,{children:!n&&jsxs(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 ${S[T]} 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:()=>p(true),children:[jsx(md,{}),jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),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"})]})}),jsx(AnimatePresence,{children:n&&jsxs(motion.div,{ref:A,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:l?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${S[T]} 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:[jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},children:[jsxs("div",{className:"flex items-center gap-2 text-white",children:[jsx(md,{}),jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>i(F=>!F),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(Wg,{})}),jsx("button",{onClick:()=>p(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(zg,{})})]})]}),jsx(AnimatePresence,{children:!l&&jsxs(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:[jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[u.length===0&&g&&jsxs("div",{className:"space-y-3",children:[jsx("p",{className:"text-sm text-center",style:{color:t.textSecondary},children:"Try asking me to edit your Gantt chart:"}),jsx("div",{className:"flex flex-wrap gap-2",children:G.slice(0,4).map((F,M)=>jsx("button",{onClick:()=>ce(F),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:F.length>30?F.slice(0,30)+"...":F},M))})]}),u.map(F=>jsx(motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${F.role==="user"?"justify-end":"justify-start"}`,children:jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${F.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:F.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:F.role==="user"?"white":t.textPrimary},children:[F.isLoading?jsx(Gg,{}):jsx("p",{className:"text-sm whitespace-pre-wrap",children:F.content}),F.command&&jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:F.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:F.command.success?"#10B981":"#EF4444"},children:[F.command.success?"\u2713":"\u2717",jsx("span",{className:"capitalize",children:F.command.type.replace(/_/g," ")})]})]})},F.id)),jsx("div",{ref:h})]}),jsxs("form",{onSubmit:Pe,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsx("input",{ref:D,type:"text",value:f,onChange:F=>y(F.target.value),placeholder:L,disabled:x,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsx("button",{type:"submit",disabled:!f.trim()||x,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:f.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:f.trim()?"white":t.textSecondary},children:jsx(Ug,{})})]}),jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function pd(e,t=50){let[a,r]=useState({past:[],present:e,future:[]}),o=useRef(false),s=useCallback((n,p=true)=>{r(l=>{let i=typeof n=="function"?n(l.present):n;if(o.current)return {...l,present:i};if(!p)return {...l,present:i};let u=[...l.past,l.present];return u.length>t&&u.shift(),{past:u,present:i,future:[]}});},[t]),d=useCallback(()=>{r(n=>{if(n.past.length===0)return n;let p=n.past[n.past.length-1],l=n.past.slice(0,n.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:l,present:p,future:[n.present,...n.future]}});},[]),m=useCallback(()=>{r(n=>{if(n.future.length===0)return n;let p=n.future[0],l=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:p,future:l}});},[]),c=useCallback(()=>{r(n=>({past:[],present:n.present,future:[]}));},[]);return {state:a.present,setState:s,undo:d,redo:m,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:c}}function ud({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){useEffect(()=>{if(!o)return;let s=d=>{let m=navigator.platform.toUpperCase().indexOf("MAC")>=0,c=m?d.metaKey:d.ctrlKey;if(c&&d.key==="z"&&!d.shiftKey&&a){d.preventDefault(),e();return}if(r){if(!m&&c&&d.key==="y"){d.preventDefault(),t();return}if(m&&c&&d.shiftKey&&d.key==="z"){d.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var jg={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${oe.formatDate(e.startDate)} - ${oe.formatDate(e.endDate)}`);let a=oe.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=>oe.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function gd(e){return {...jg,...e}}var Qg=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},hd=forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:d="week",rowDensity:m="comfortable",showThemeSelector:c=true,showExportButton:n=true,availableUsers:p=[],templates:l,enableAutoCriticalPath:i=true,aiAssistant:u,locale:v="en",customTranslations:f,showCreateTaskButton:y=false,createTaskLabel:x,onCreateTask:b,onThemeChange:g,onTaskClick:w,onTaskDblClick:D,onTaskContextMenu:h,onTaskUpdate:A,onProgressChange:C,onTaskEdit:L,onTaskAddSubtask:T,onTaskMarkIncomplete:U,onTaskSetInProgress:G,onDependencyCreate:$,onDependencyDelete:E,onBeforeTaskAdd:X,onAfterTaskAdd:fe,onBeforeTaskUpdate:Ce,onAfterTaskUpdate:Le,onBeforeTaskDelete:Pe,onAfterTaskDelete:ce}=a,F=useContext(Lo)?.theme,[M,V]=useState(F||s||"dark"),[P,W]=useState(d),[de,ae]=useState(m),[Ee,le]=useState(1),[Ve,he]=useState(0),[at,Et]=useState(false),[gt,ft]=useState(null),[rt,ot]=useState({isOpen:false,x:0,y:0,task:null}),[ia,wt]=useState(null),[ct,Lt]=useState(null);useEffect(()=>{F&&F!==M&&V(F);},[F]),useEffect(()=>{s&&s!==M&&V(s);},[s]);let jt=useCallback(N=>{V(N),g?.(N);},[g]),{state:we,setState:O,undo:De,redo:ze,canUndo:Ue,canRedo:bt,clearHistory:J}=pd(t,50);useEffect(()=>{O(t);},[t,O]);let Q=useRef(t),xe=useRef(true);useEffect(()=>{if(xe.current){xe.current=false,Q.current=we;return}if(!r)return;let N=JSON.stringify(Q.current),z=JSON.stringify(we);N!==z&&(Q.current=we,r(we));},[we,r]);let ge=useMemo(()=>ps(v,f),[v,f]),ee=useCallback(N=>[{id:"name",label:N.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:N.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:N.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:N.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:N.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:N.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:N.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:N.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Te,be]=useState(()=>ee(ge));useEffect(()=>{be(N=>N.map(z=>({...z,label:ge.columns[z.id==="name"?"taskName":z.id]||z.label})));},[ge]);let ke=useMemo(()=>{let N=Te.filter(re=>re.visible),z=N.some(re=>re.id!=="name");return N.reduce((re,ye)=>re+ye.width,0)+(z?20:0)},[Te]);useEffect(()=>{gt!==null&&gt>ke&&(Te.filter(Y=>Y.visible).some(Y=>Y.id!=="name")||ft(null));},[Te,ke,gt]);let R=useMemo(()=>gt!==null?Math.max(280,gt,ke):Math.max(280,ke),[gt,ke]),H=useRef(null),q=useRef(null),se=useRef(null),ie=useMemo(()=>Ll(M),[M]),B=useMemo(()=>({theme:ie,themeName:M}),[ie,M]),K=useMemo(()=>gd(l),[l]),Ne=useMemo(()=>{if(!i)return we;let N=oe.calculateCriticalPath(we),z=Y=>Y.map(re=>({...re,isCriticalPath:N.includes(re.id),subtasks:re.subtasks?z(re.subtasks):void 0}));return z(we)},[we,i]),je=Qg(de);ud({undo:De,redo:ze,canUndo:Ue,canRedo:bt,enabled:true}),useImperativeHandle(o,()=>({getTask:N=>oe.findTaskById(we,N),addTask:(N,z)=>{O(Y=>{if(!z)return [...Y,{...N,level:0}];let re=ye=>ye.map(Se=>Se.id===z?{...Se,subtasks:[...Se.subtasks||[],{...N,parentId:z,level:(Se.level||0)+1}],isExpanded:true}:Se.subtasks?{...Se,subtasks:re(Se.subtasks)}:Se);return re(Y)});},updateTask:(N,z)=>{O(Y=>{let re=ye=>ye.map(Se=>Se.id===N?{...Se,...z}:Se.subtasks?{...Se,subtasks:re(Se.subtasks)}:Se);return re(Y)});},deleteTask:N=>{O(z=>{let Y=re=>re.filter(ye=>ye.id===N?false:(ye.subtasks&&(ye.subtasks=Y(ye.subtasks)),true));return Y(z)});},deleteTasks:N=>{O(z=>vs(z,N));},duplicateTask:N=>{O(z=>xs(z,[N]));},splitTask:(N,z,Y=3)=>{O(re=>oe.splitTask(re,N,z,Y));},calculateEndDate:oe.calculateEndDate,calculateDuration:oe.calculateDuration,validateDependency:(N,z)=>!oe.validateDependencies(we,N,z),getAllTasks:()=>oe.flattenTasks(we),getTasksByStatus:N=>oe.flattenTasks(we).filter(z=>z.status===N),getTasksByParent:N=>N?oe.findTaskById(we,N)?.subtasks||[]:we.filter(Y=>!Y.parentId),getCriticalPath:()=>oe.flattenTasks(we).filter(N=>N.isCriticalPath),indentTask:N=>{O(z=>bs(z,[N]));},outdentTask:N=>{O(z=>hs(z,[N]));},moveTask:(N,z)=>{O(Y=>ys(Y,[N],z));},createSubtask:async N=>{let{tasks:z,newTask:Y}=Cs(we,N);if(X){let re=X({...Y,parentId:N});if((re instanceof Promise?await re:re)===false)return}O(z),fe&&fe({...Y,parentId:N});},scrollToTask:N=>{let Y=oe.flattenTasks(we).findIndex(re=>re.id===N);if(Y!==-1&&H.current){let re=Y*je;H.current.scrollTo({top:re,behavior:"smooth"}),q.current&&q.current.scrollTo({top:re,behavior:"smooth"});}},highlightTask:(N,z=2e3)=>{},expandTask:N=>{O(z=>{let Y=re=>re.map(ye=>ye.id===N?{...ye,isExpanded:true}:ye.subtasks?{...ye,subtasks:Y(ye.subtasks)}:ye);return Y(z)});},collapseTask:N=>{O(z=>{let Y=re=>re.map(ye=>ye.id===N?{...ye,isExpanded:false}:ye.subtasks?{...ye,subtasks:Y(ye.subtasks)}:ye);return Y(z)});},expandAll:()=>{O(N=>{let z=Y=>Y.map(re=>({...re,isExpanded:true,subtasks:re.subtasks?z(re.subtasks):void 0}));return z(N)});},collapseAll:()=>{O(N=>{let z=Y=>Y.map(re=>({...re,isExpanded:false,subtasks:re.subtasks?z(re.subtasks):void 0}));return z(N)});},undo:De,redo:ze,canUndo:()=>Ue,canRedo:()=>bt,clearHistory:J,exportToPNG:async()=>{if(!se.current)throw new Error("Gantt container not found");let N=await bd(se.current,{backgroundColor:ie.bgPrimary,scale:2});return new Promise((z,Y)=>{N.toBlob(re=>{re?z(re):Y(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async N=>{await oe.exportToPDF(we,N);},exportToExcel:async N=>{await oe.exportToExcel(we,N);},exportToJSON:()=>oe.exportToJSON(we),exportToCSV:()=>oe.exportToCSV(we),importFromJSON:N=>{let z=oe.importFromJSON(N);O(z);},getTasks:()=>we,refresh:()=>{O(N=>[...N]);},clearAll:()=>{O([]);}}),[we,De,ze,Ue,bt,J,ie,je]);let Pt=useCallback(N=>{be(z=>z.map(Y=>Y.id===N?{...Y,visible:!Y.visible}:Y));},[]),Wr=useCallback((N,z)=>{be(Y=>Y.map(re=>{if(re.id!==N)return re;let ye=re.minWidth??100,Se=re.maxWidth??800,Ft=Math.max(ye,Math.min(Se,z));return {...re,width:Ft}}));},[]),Gr=useCallback(N=>{O(z=>ws(z,N)),a.onTaskToggleExpand?.(N);},[a]),Wa=useCallback((N,z)=>{if(Ce&&Ce(N,z)===false)return;let re=oe.findTaskById(we,N)?.progress,ye=Ft=>Ft.map(Bt=>Bt.id===N?{...Bt,...z}:Bt.subtasks?{...Bt,subtasks:ye(Bt.subtasks)}:Bt);O(ye(we));let Se=oe.findTaskById(ye(we),N);Se&&(A?.(Se),Le?.(Se),z.progress!==void 0&&re!==void 0&&z.progress!==re&&C?.(N,re,z.progress));},[we,A,Ce,Le,C]),yn=useCallback(N=>{N.length!==0&&(O(z=>bs(z,N)),a.onTaskIndent?.(N[0]));},[a]),me=useCallback(N=>{N.length!==0&&(O(z=>hs(z,N)),a.onTaskOutdent?.(N[0]));},[a]),mt=useCallback((N,z,Y)=>{O(re=>Ql(re,N,z,Y)),a.onTaskReparent?.(N,z,Y);},[a]),Ht=useCallback((N,z)=>{N.length!==0&&(O(Y=>ys(Y,N,z)),a.onTaskMove?.(N[0],z));},[a]),Ga=useCallback(async N=>{let z=[];for(let Y of N)Pe&&await Promise.resolve(Pe(Y))===false||z.push(Y);z.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(z):(O(Y=>vs(Y,z)),z.forEach(Y=>a.onTaskDelete?.(Y))),ce&&z.forEach(Y=>ce(Y)));},[a,Pe,ce]),bo=useCallback(N=>{O(z=>xs(z,N)),N.forEach(z=>a.onTaskDuplicate?.(z));},[a]),vr=useCallback((N,z)=>{O(Y=>{let{tasks:re,newTask:ye}=Zl(Y,N,z);return X&&X(ye)===false?Y:(a.onTaskCreate?.(ye.parentId,ye.position||0),fe?.(ye),re)});},[a,X,fe]),Ma=useCallback((N,z)=>{O(Y=>ks(Y,N,z)),a.onTaskRename?.(N,z);},[a]),Aa=useCallback(N=>{O(z=>{let{tasks:Y}=Cs(z,N);return a.onTaskCreate?.(N,0),Y});},[a]),Ct=useCallback((N,z,Y)=>{let re=N.startDate?Math.round((z.getTime()-N.startDate.getTime())/864e5):0,ye=Bt=>Bt.map(_t=>_t.id===N.id?{..._t,startDate:z,endDate:Y,...N.segments&&{segments:N.segments}}:_t.subtasks?{..._t,subtasks:ye(_t.subtasks)}:_t),Se=ye(we);Se=oe.autoScheduleDependents(Se,N.id,re),O(Se);let Ft={...N,startDate:z,endDate:Y};A?.(Ft);},[we,A]),vn=useCallback((N,z)=>{h?.(N,z),ot({isOpen:true,x:z.clientX,y:z.clientY,task:N});},[h]),xn=useCallback((N,z)=>{let Y=oe.splitTask(we,N.id,z);O(Y),ot({isOpen:false,x:0,y:0,task:null});},[we]),kn=useCallback(N=>{D?.(N),L||wt(N);},[D,L]),xr=useCallback((N,z,Y)=>{let re=new Map,ye=fa=>{fa.forEach(Ia=>{Ia.dependencies&&re.set(Ia.id,Ia.dependencies),Ia.subtasks&&ye(Ia.subtasks);});};ye(Y);let Se=re.get(z)||[];re.set(z,[...Se,N]);let Ft=new Set,Bt=new Set,_t=fa=>{if(!Ft.has(fa)){Ft.add(fa),Bt.add(fa);let Ia=re.get(fa)||[];for(let er of Ia){if(!Ft.has(er)&&_t(er))return true;if(Bt.has(er))return true}}return Bt.delete(fa),false};return _t(z)},[]),Ti=useCallback((N,z)=>{if(xr(N.id,z,we)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
276
+ </Project>`,p=new Blob([n],{type:"application/xml;charset=utf-8;"}),l=document.createElement("a");l.href=URL.createObjectURL(p),l.download=a,l.click(),URL.revokeObjectURL(l.href);},calculateCriticalPath:e=>{let t=oe.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 p=n.startDate&&n.endDate?oe.calculateDuration(n.startDate,n.endDate):0,l=0;if(n.dependencies&&n.dependencies.length>0)for(let u of n.dependencies){let v=t.find(f=>f.id===u);if(v){o(v);let f=r.get(u)?.ef||0;l=Math.max(l,f);}}let i=l+p;r.set(n.id,{es:l,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(n=>n.ef)),d=new Map,m=n=>{if(d.has(n.id))return;let p=n.startDate&&n.endDate?oe.calculateDuration(n.startDate,n.endDate):0,l=t.filter(v=>v.dependencies&&v.dependencies.includes(n.id)),i=s;if(l.length>0)for(let v of l){m(v);let f=d.get(v.id)?.ls||0;i=Math.min(i,f);}let u=i-p;d.set(n.id,{ls:u,lf:i});};a.forEach(m);let c=[];for(let n of a){let p=r.get(n.id),l=d.get(n.id);if(p&&l){let i=l.ls-p.es;Math.abs(i)<.01&&c.push(n.id);}}return c},calculateSlack:(e,t)=>{let a=oe.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(oe.calculateCriticalPath(e).includes(t))return 0;let o=oe.getDependentTasks(e,t);if(o.length===0){let m=oe.getLatestEndDate(e);if(!m)return null;let c=oe.calculateDuration(a.endDate,m);return Math.max(0,c)}let s=o.filter(m=>m.startDate).map(m=>m.startDate.getTime()).sort((m,c)=>m-c)[0];if(!s)return null;let d=oe.calculateDuration(a.endDate,new Date(s));return Math.max(0,d)},isOnCriticalPath:(e,t)=>oe.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=oe.findTaskById(e,t);if(!r||!r.endDate)return e;let o=oe.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let d of o){if(!d.startDate||!d.endDate)continue;let m=oe.calculateDuration(d.startDate,d.endDate),c;a!==void 0?(c=new Date(d.startDate),c.setDate(c.getDate()+a)):(c=new Date(r.endDate),c.setDate(c.getDate()+1));let n=oe.calculateEndDate(c,m),p=l=>l.map(i=>i.id===d.id?{...i,startDate:c,endDate:n}:i.subtasks?{...i,subtasks:p(i.subtasks)}:i);s=p(s),s=oe.autoScheduleDependents(s,d.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,d,m)=>{if(a===0)return [];let c=[],n=o.getTime(),p=1e3*60*60*24,l=oe.findTaskById(e,t);if(!l||!l.endDate)return [];let i=(u,v,f=new Set)=>{if(f.has(u))return;f.add(u);let y=oe.getDependentTasks(e,u);for(let x of y){if(!x.startDate||!x.endDate)continue;let b=r.findIndex(U=>U.id===x.id);if(b===-1)continue;let g=x.startDate.getTime(),D=(x.endDate.getTime()-g)/p,A=(g-n)/p*s,C=A+v*s,L=Math.max(D*s,s),T=m+b*d+12;c.push({taskId:x.id,taskName:x.name,originalX:A,previewX:C,width:L,y:T,rowIndex:b,daysDelta:v,color:x.color}),i(x.id,v,f);}};return i(t,a),c},splitTask:(e,t,a,r=3)=>{let o=oe.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 d=new Date(a);d.setDate(d.getDate()+r);let m=new Date(o.endDate);m.setDate(m.getDate()+r);let c=[{startDate:new Date(o.startDate),endDate:s},{startDate:d,endDate:m}],n=p=>p.map(l=>l.id===o.id?{...l,endDate:m,segments:c}:l.subtasks?{...l,subtasks:n(l.subtasks)}:l);return n(e)}};function Ko({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:d,templates:m,onTaskClick:c,onTaskDblClick:n,onTaskContextMenu:p,onTaskDateChange:l,onDependencyCreate:i,onDependencyDelete:u}){let[f,y]=useState([]),[x,b]=useState(null),[g,w]=useState(null),D=useCallback(S=>{b(S);},[]),h=useCallback(S=>{w(S);},[]),A=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),C=r==="day"?60:r==="week"?20:8,L=A*C*d,T=S=>{let F=new Date(Date.UTC(S.getFullYear(),S.getMonth(),S.getDate())),M=F.getUTCDay()||7;F.setUTCDate(F.getUTCDate()+4-M);let V=new Date(Date.UTC(F.getUTCFullYear(),0,1));return Math.ceil(((F.getTime()-V.getTime())/864e5+1)/7)},U=S=>{let F=S.getDay();return F===0||F===6},G=useCallback(S=>{let F=Math.round(S/(C*d)),M=new Date(o);return M.setDate(M.getDate()+F),M},[o,C,d]),$=useCallback((S,F)=>{if(F.startDate&&F.endDate)return;let M=S.currentTarget.ownerSVGElement;if(!M)return;let V=M.createSVGPoint();V.x=S.clientX,V.y=S.clientY;let P=V.matrixTransform(M.getScreenCTM()?.inverse()),W=G(P.x),de=new Date(W);de.setDate(de.getDate()+1),l?.(F,W,de);},[G,l]),E=useMemo(()=>{let S=P=>P.map(W=>{if(W.subtasks&&W.subtasks.length>0){let de=S(W.subtasks),ae=de.filter(Ee=>Ee.startDate&&Ee.endDate);if(ae.length>0){let Ee=ae.map(at=>at.startDate.getTime()),le=ae.map(at=>at.endDate.getTime()),Ve=new Date(Math.min(...Ee)),he=new Date(Math.max(...le));return {...W,subtasks:de,startDate:Ve,endDate:he}}return {...W,subtasks:de}}return W}),F=(P,W=[])=>{for(let de of P)W.push(de),de.subtasks&&de.subtasks.length>0&&(de.isExpanded===void 0||de.isExpanded)&&F(de.subtasks,W);return W},M=S(e);return F(M)},[e]),X=useCallback(S=>{if(!S.startDate||!S.endDate)return {x:0,width:0};let F=S.startDate.getTime(),M=S.endDate.getTime(),V=o.getTime(),P=(F-V)/(1e3*60*60*24),W=(M-F)/(1e3*60*60*24),de=P*C*d,ae=Math.max(C*d,40),Ee=Math.max(W*C*d,ae);return {x:de,width:Ee}},[o,C,d]),fe=useMemo(()=>E.filter(S=>S.startDate&&S.endDate).map(S=>{let{x:F,width:M}=X(S),P=E.findIndex(W=>W.id===S.id)*a+12;return {id:S.id,x:F,y:P,width:M,height:32}}),[E,X]),Ce=useCallback((S,F,M)=>{if(!M||F===0){y([]);return}let V=oe.calculateCascadePreview(e,S,F,E,o,C*d,a,48);y(V);},[e,E,o,C,d,a,48]),Le=useMemo(()=>{let S=[],F=new Date(o);for(;F<=s;){let P=(F.getTime()-o.getTime())/864e5*C*d;if(r==="day")S.push({date:new Date(F),label:F.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:P}),F.setDate(F.getDate()+1);else if(r==="week"){let W=T(F);S.push({date:new Date(F),label:`Week ${W}`,x:P}),F.setDate(F.getDate()+7);}else S.push({date:new Date(F),label:F.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:P}),F.setMonth(F.getMonth()+1);}return S},[o,s,r,C,d]),Pe=useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*C*d,[o,C,d]),ce=Math.max(E.length*a,552);return jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary,overflow:"visible"},children:[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:jsxs("svg",{width:Math.max(L,1e3),height:47,style:{display:"block"},children:[jsx("rect",{x:0,y:0,width:Math.max(L,1e3),height:48,fill:t.bgGrid}),Le.map((S,F)=>jsxs("g",{children:[F>0&&jsx("line",{x1:S.x,y1:0,x2:S.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsx("text",{x:S.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:S.label})]},`header-${F}`)),Pe>=0&&Pe<=L&&jsx("circle",{cx:Pe,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxs("svg",{width:Math.max(L,1e3),height:ce,style:{display:"block",flexShrink:0,overflow:"visible"},children:[jsxs("defs",{children:[jsx("filter",{id:"shadow",children:jsx("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2",floodOpacity:"0.1"})}),jsx("pattern",{id:"diagonal-stripes",width:"8",height:"8",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:jsx("line",{x1:"0",y1:"0",x2:"0",y2:"8",stroke:t.border,strokeWidth:"2"})})]}),jsx("rect",{x:0,y:0,width:Math.max(L,1e3),height:ce,fill:t.bgPrimary}),Le.map((S,F)=>{let M=Le[F+1]?.x||L,V=U(S.date);return jsxs("g",{children:[V&&jsx("rect",{x:S.x,y:0,width:M-S.x,height:E.length*a,fill:t.bgWeekend,opacity:1}),F>0&&jsx("line",{x1:S.x,y1:0,x2:S.x,y2:E.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},F)}),Pe>=0&&Pe<=L&&jsx("line",{x1:Pe,y1:0,x2:Pe,y2:E.length*a,stroke:t.today,strokeWidth:2,opacity:1}),E.map((S,F)=>{let M=S.startDate&&S.endDate;return jsxs("g",{children:[jsx("rect",{x:0,y:F*a,width:L,height:a,fill:F%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${S.id}`),!M&&jsxs(Fragment,{children:[jsx("rect",{x:0,y:F*a,width:L,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:V=>$(V,S),onMouseEnter:V=>{V.currentTarget.setAttribute("fill",t.accentLight),V.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:V=>{V.currentTarget.setAttribute("fill","transparent"),V.currentTarget.setAttribute("opacity","1");}},`clickable-${S.id}`),jsx("text",{x:Pe>0?Pe:100,y:F*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-${S.id}`)]})]},`row-group-${S.id}`)}),E.map((S,F)=>!S.dependencies||S.dependencies.length===0||!S.startDate||!S.endDate?null:S.dependencies.map(M=>{let V=E.find(ae=>ae.id===M);if(!V||!V.startDate||!V.endDate)return null;let P=E.findIndex(ae=>ae.id===M),W=X(V),de=X(S);return jsx(Ho,{x1:W.x+W.width,y1:P*a+a/2,x2:de.x,y2:F*a+a/2,theme:t,onDelete:()=>u?.(S.id,M),onHoverChange:h},`dep-${M}-${S.id}`)})),E.map((S,F)=>{if(!S.startDate||!S.endDate)return null;let{x:M,width:V}=X(S),P=F*a+12,W=S.subtasks&&S.subtasks.length>0&&!S.isMilestone;return S.isMilestone?jsx(Vo,{task:S,x:M+V/2,y:P+16,theme:t,onClick:c},S.id):W?jsxs("g",{onClick:()=>c?.(S),onContextMenu:de=>{de.preventDefault(),de.stopPropagation(),p?.(S,de);},style:{cursor:"default"},children:[jsx("rect",{x:M,y:P,width:V,height:32,fill:t.primary,opacity:.25,rx:6}),jsx("line",{x1:M,y1:P,x2:M+V,y2:P,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:M,y1:P,x2:M,y2:P+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:M+V,y1:P,x2:M+V,y2:P+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:M,y1:P+32,x2:M+V,y2:P+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),V>60&&jsx("text",{x:M+12,y:P+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:S.name})]},S.id):jsx(zo,{task:S,x:M,y:P,width:V,theme:t,dayWidth:C*d,startDate:o,templates:m,onClick:c,onDoubleClick:n,onContextMenu:p,onDateChange:l,onDependencyCreate:i,allTaskPositions:fe,onDragMove:Ce,onHoverChange:D},S.id)}),f.map(S=>jsxs("g",{style:{pointerEvents:"none"},children:[jsx("rect",{x:S.previewX,y:S.y-48,width:S.width,height:32,rx:8,fill:S.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(S.daysDelta)>0&&jsx("text",{x:S.previewX+S.width/2,y:S.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:S.daysDelta>0?`+${S.daysDelta}d`:`${S.daysDelta}d`})]},`cascade-preview-${S.taskId}`)),g&&(()=>{let{x1:S,y1:F,x2:M,y2:V,onDelete:P}=g,W=M-S,de=V-F,ae=S+W/2,Ee=(F+V)/2,le=`M ${S} ${F} C ${ae} ${F}, ${ae} ${V}, ${M} ${V}`,Ve=6,he=Math.atan2(de,W),at=M-Ve*Math.cos(he-Math.PI/6),Et=V-Ve*Math.sin(he-Math.PI/6),gt=M-Ve*Math.cos(he+Math.PI/6),ft=V-Ve*Math.sin(he+Math.PI/6),rt=t.dependency;return jsxs("g",{style:{pointerEvents:"none"},children:[jsx("path",{d:le,fill:"none",stroke:rt,strokeWidth:3,strokeLinecap:"round",opacity:1}),jsx("path",{d:`M ${M} ${V} L ${at} ${Et} M ${M} ${V} L ${gt} ${ft}`,fill:"none",stroke:rt,strokeWidth:3,strokeLinecap:"round",opacity:1}),jsx("circle",{cx:M,cy:V,r:5,fill:rt}),jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:ot=>{ot.stopPropagation(),P();},style:{cursor:"pointer",pointerEvents:"auto"},children:[jsx("circle",{cx:ae,cy:Ee,r:10,fill:t.bgSecondary,stroke:t.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:ae-4,y1:Ee-4,x2:ae+4,y2:Ee+4,stroke:t.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:ae+4,y1:Ee-4,x2:ae-4,y2:Ee+4,stroke:t.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})})(),x&&jsx(sd,{tooltipData:x,theme:t})]})]})}var Yo=[{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:"Coral",value:"#F97316",light:"#FB923C"},{name:"Magenta",value:"#E11D48",light:"#FB7185"}];var Es=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],Ps=[{id:"low",label:"Baja",color:"#10B981",icon:"\u{1F7E2}"},{id:"medium",label:"Media",color:"#F59E0B",icon:"\u{1F7E1}"},{id:"high",label:"Alta",color:"#F97316",icon:"\u{1F7E0}"},{id:"urgent",label:"Urgente",color:"#EF4444",icon:"\u{1F534}"}];function Xo({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:d=false,mode:m=a?"edit":"create",theme:c="dark",customStatuses:n=[]}){let p=[...Es,...n.filter(P=>!Es.some(W=>W.id===P.id))],l=Oe[c]||Oe.dark,[i,u]=useState(false),[v,f]=useState(false),[y,x]=useState(false),[b,g]=useState(false),[w,D]=useState(null),[h,A]=useState(new Date),[C,L]=useState(false),T=useRef(null),U=useRef(null),G=useRef(null),$=useRef(null),[E,X$1]=useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),[fe,Ce]=useState({});useEffect(()=>{a?(X$1({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||[]}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&L(true)):(X$1({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),L(false));},[a,e]),useEffect(()=>{let P=W=>{T.current&&!T.current.contains(W.target)&&u(false),U.current&&!U.current.contains(W.target)&&f(false),G.current&&!G.current.contains(W.target)&&x(false),$.current&&!$.current.contains(W.target)&&g(false);};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[]);let Le=()=>{let P={};return E.name.trim()||(P.name="El nombre es requerido"),E.startDate&&E.endDate&&E.startDate>E.endDate&&(P.endDate="La fecha de fin debe ser posterior a la de inicio"),Ce(P),Object.keys(P).length===0},Pe=async P=>{if(P.preventDefault(),!!Le())try{await s(E),t();}catch(W){console.error("Error submitting task:",W);}},ce=(P,W)=>{X$1(de=>{let ae={...de,[P]:W};if(P==="status"){let Ee=W;Ee==="todo"?ae.progress=0:Ee==="in-progress"?(de.progress===0||de.progress===100)&&(ae.progress=50):Ee==="completed"||Ee==="closed"?ae.progress=100:(Ee==="in-review"||Ee==="review")&&(ae.progress=75);}if(P==="progress"){let Ee=typeof W=="number"?W:parseInt(W,10);Ee===100&&de.status!=="completed"?ae.status="completed":Ee>0&&Ee<100&&de.status==="todo"?ae.status="in-progress":Ee===0&&de.status!=="todo"&&(ae.status="todo");}return ae}),fe[P]&&Ce(de=>{let ae={...de};return delete ae[P],ae});},S=p.find(P=>P.id===E.status)??Es[0],F=Ps.find(P=>P.id===E.priority)??Ps[1],M=Yo.find(P=>P.value===E.color)??Yo[0],V={backgroundColor:l.bgSecondary,border:`1px solid ${l.borderLight}`,color:l.textPrimary};return jsx(AnimatePresence,{children:e&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 z-50",onClick:t}),jsx(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:.15,ease:[.4,0,.2,1]},className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl pointer-events-auto overflow-hidden",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},onClick:P=>P.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${l.border}`},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:S.color||l.accent}}),jsx("span",{className:"text-sm font-medium",style:{color:l.textSecondary},children:m==="create"?"Nueva tarea":"Editar tarea"})]}),jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:l.textTertiary},onMouseEnter:P=>{P.currentTarget.style.backgroundColor=l.hoverBg,P.currentTarget.style.color=l.textPrimary;},onMouseLeave:P=>{P.currentTarget.style.backgroundColor="transparent",P.currentTarget.style.color=l.textTertiary;},disabled:d,children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("form",{onSubmit:Pe,className:"max-h-[calc(100vh-200px)] overflow-y-auto",children:[jsxs("div",{className:"p-5 space-y-4",children:[jsxs("div",{children:[jsx("input",{type:"text",value:E.name,onChange:P=>ce("name",P.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:l.textPrimary},placeholder:"Nombre de la tarea",disabled:d,autoFocus:true}),fe.name&&jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsx(AlertCircle,{className:"w-3 h-3"}),fe.name]})]}),jsx("div",{children:jsx("textarea",{value:E.description||"",onChange:P=>ce("description",P.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:l.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:d})}),jsx("div",{style:{borderTop:`1px solid ${l.borderLight}`}}),jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxs("div",{ref:T,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!d&&u(!i),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...V,borderColor:S.color,backgroundColor:`${S.color}15`},disabled:d,children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:S.color}}),jsx("span",{style:{color:S.color},children:S.title}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:S.color}})]}),jsx(AnimatePresence,{children:i&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[140px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},children:p.map(P=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:W=>W.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:W=>W.currentTarget.style.backgroundColor="transparent",onClick:()=>{ce("status",P.id),u(false);},children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:P.color}}),P.title,E.status===P.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},P.id))})})]}),jsxs("div",{ref:U,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!d&&f(!v),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:d,children:[jsx(Flag,{className:"w-3.5 h-3.5",style:{color:F.color}}),jsx("span",{children:F.label}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsx(AnimatePresence,{children:v&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[130px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},children:Ps.map(P=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:W=>W.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:W=>W.currentTarget.style.backgroundColor="transparent",onClick:()=>{ce("priority",P.id),f(false);},children:[jsx("span",{children:P.icon}),P.label,E.priority===P.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},P.id))})})]}),o.length>0&&jsxs("div",{ref:G,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!d&&x(!y),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:d,children:[E.assignees&&E.assignees.length>0?jsxs(Fragment,{children:[jsx("div",{className:"flex -space-x-1",children:E.assignees.slice(0,3).map((P,W)=>jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] text-white font-medium border-2",style:{backgroundColor:P.color||l.accent,borderColor:l.bgSecondary},children:P.initials},W))}),E.assignees.length>3&&jsxs("span",{style:{color:l.textTertiary},children:["+",E.assignees.length-3]})]}):jsxs(Fragment,{children:[jsx(Users,{className:"w-3.5 h-3.5",style:{color:l.textTertiary}}),jsx("span",{style:{color:l.textTertiary},children:"Asignar"})]}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsx(AnimatePresence,{children:y&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[180px] max-h-[200px] overflow-y-auto rounded-lg shadow-xl",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},children:o.map(P=>{let W=E.assignees?.some(de=>de.name===P.name);return jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:de=>de.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:de=>de.currentTarget.style.backgroundColor="transparent",onClick:()=>{let de=W?(E.assignees||[]).filter(ae=>ae.name!==P.name):[...E.assignees||[],{name:P.name,avatar:P.avatar,initials:P.name.split(" ").map(ae=>ae[0]).join("").toUpperCase().slice(0,2),color:l.accent}];ce("assignees",de);},children:[jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs text-white font-medium flex-shrink-0",style:{backgroundColor:l.accent},children:P.name.charAt(0).toUpperCase()}),jsx("span",{className:"truncate flex-1 text-left",children:P.name}),jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:W&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:l.accent}})})]},P.id)})})})]}),jsxs("div",{ref:$,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!d&&g(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:d,children:[jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:E.color}}),jsx("span",{children:M.name}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsx(AnimatePresence,{children:b&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"absolute left-0 top-full mt-1.5 z-50 rounded-lg",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},children:jsx("div",{style:{padding:"14px 18px"},children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 16px)",gap:"14px"},children:Yo.slice(0,16).map(P=>{let W=E.color===P.value;return jsx(motion.button,{type:"button",onClick:()=>{ce("color",P.value),g(false);},style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:P.value,outline:W?`2px solid ${P.value}`:"none",outlineOffset:"3px",cursor:"pointer",border:"none"},whileHover:{scale:1.2},whileTap:{scale:.95},title:P.name},P.value)})})})})})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Calendar,{className:"w-4 h-4",style:{color:l.textTertiary}}),jsxs("div",{className:"flex items-center gap-2 flex-1 relative",children:[jsx("button",{type:"button",onClick:()=>{!d&&!E.isMilestone&&(D(w==="start"?null:"start"),A(E.startDate||new Date));},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...V,opacity:E.isMilestone?.5:1,cursor:E.isMilestone?"not-allowed":"pointer"},disabled:d||E.isMilestone,children:E.startDate?E.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsx("span",{style:{color:l.textTertiary},children:"\u2192"}),jsx("button",{type:"button",onClick:()=>{!d&&!E.isMilestone&&(D(w==="end"?null:"end"),A(E.endDate||E.startDate||new Date));},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...V,opacity:E.isMilestone?.5:1,cursor:E.isMilestone?"not-allowed":"pointer"},disabled:d||E.isMilestone,children:E.endDate?E.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsx(AnimatePresence,{children:w&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>D(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},onClick:P=>P.stopPropagation(),children:[jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${l.border}`},children:[(()=>{let P=new Date,W=new Date(P);W.setDate(P.getDate()+1);let de=new Date(P);de.setDate(P.getDate()+7);let ae=new Date(P);return ae.setDate(P.getDate()+14),[{label:"Hoy",date:P},{label:"Ma\xF1ana",date:W},{label:"Pr\xF3xima semana",date:de},{label:"2 semanas",date:ae}].map((le,Ve)=>jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:l.textPrimary},onMouseEnter:he=>he.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:he=>he.currentTarget.style.backgroundColor="transparent",onClick:()=>{w==="start"?(ce("startDate",le.date),(!E.endDate||le.date>E.endDate)&&ce("endDate",le.date),D("end")):(ce("endDate",le.date),(!E.startDate||le.date<E.startDate)&&ce("startDate",le.date),D(null));},children:le.label},Ve))})(),jsx("div",{style:{borderTop:`1px solid ${l.border}`,margin:"0.5rem 0"}}),jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:P=>P.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:P=>P.currentTarget.style.backgroundColor="transparent",onClick:()=>{ce("startDate",void 0),ce("endDate",void 0),D(null);},children:"Borrar fechas"})]}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("button",{type:"button",onClick:()=>A(new Date(h.getFullYear(),h.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-4 h-4",style:{color:l.textSecondary}})}),jsx("span",{className:"text-sm font-medium",style:{color:l.textPrimary},children:h.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>A(new Date(h.getFullYear(),h.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-4 h-4",style:{color:l.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((P,W)=>jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:l.textTertiary},children:P},W))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let P=h.getFullYear(),W=h.getMonth(),de=new Date(P,W,1).getDay(),ae=new Date(P,W+1,0).getDate(),Ee=new Date,le=[];for(let he=de-1;he>=0;he--)le.push({day:new Date(P,W,-he).getDate(),date:new Date(P,W-1,new Date(P,W,-he).getDate()),isCurrentMonth:false});for(let he=1;he<=ae;he++)le.push({day:he,date:new Date(P,W,he),isCurrentMonth:true});let Ve=42-le.length;for(let he=1;he<=Ve;he++)le.push({day:he,date:new Date(P,W+1,he),isCurrentMonth:false});return le.map((he,at)=>{let Et=he.date.toDateString()===Ee.toDateString(),gt=E.startDate?.toDateString()===he.date.toDateString(),ft=E.endDate?.toDateString()===he.date.toDateString(),rt=E.startDate&&E.endDate&&he.date>=E.startDate&&he.date<=E.endDate;return jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:he.isCurrentMonth?gt||ft?"#FFF":l.textPrimary:l.textTertiary,backgroundColor:gt?"#3B82F6":ft?"#7C3AED":rt?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:Et&&!gt&&!ft?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{w==="start"?(ce("startDate",he.date),E.endDate&&he.date>E.endDate&&ce("endDate",he.date),D("end")):(ce("endDate",he.date),E.startDate&&he.date<E.startDate&&ce("startDate",he.date),D(null));},children:he.day},at)})})()})]})]})]})})]}),fe.endDate&&jsx("span",{className:"text-xs text-red-400",children:fe.endDate})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:"w-4 h-4",style:{color:l.textTertiary}}),jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsx("input",{type:"range",min:"0",max:"100",step:"5",value:E.progress,onChange:P=>ce("progress",parseInt(P.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:l.bgSecondary,accentColor:E.progress<30?"#EF4444":E.progress<70?"#F59E0B":"#10B981"},disabled:d}),jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${E.progress<30?"#EF4444":E.progress<70?"#F59E0B":"#10B981"}20`,color:E.progress<30?"#EF4444":E.progress<70?"#F59E0B":"#10B981"},children:[E.progress,"%"]})]})]}),jsxs("div",{children:[jsxs("button",{type:"button",onClick:()=>L(!C),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:l.textTertiary},children:[jsx(ChevronDown,{className:`w-3 h-3 transition-transform ${C?"rotate-180":""}`}),"Opciones avanzadas"]}),jsx(AnimatePresence,{children:C&&jsx(motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:jsxs("div",{className:"pt-3 space-y-3",children:[jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-lg transition-colors hover:bg-white/5",children:[jsx("input",{type:"checkbox",checked:E.isMilestone,onChange:P=>ce("isMilestone",P.target.checked),className:"w-4 h-4 rounded",style:{accentColor:l.accent},disabled:d}),jsx(Milestone,{className:"w-4 h-4 text-yellow-500"}),jsx("span",{className:"text-sm",style:{color:l.textPrimary},children:"Marcar como hito"})]}),r.length>0&&jsxs("div",{children:[jsxs("label",{className:"flex items-center gap-2 text-xs mb-2",style:{color:l.textTertiary},children:[jsx(Link2,{className:"w-3.5 h-3.5"}),"Dependencias"]}),jsx("div",{className:"flex flex-wrap gap-1.5 max-h-24 overflow-y-auto p-2 rounded-lg",style:{backgroundColor:l.bgSecondary},children:r.filter(P=>P.id!==a?.id).map(P=>{let W=E.dependencies?.includes(P.id);return jsx("button",{type:"button",onClick:()=>{let de=W?(E.dependencies||[]).filter(ae=>ae!==P.id):[...E.dependencies||[],P.id];ce("dependencies",de);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:W?`${l.accent}30`:l.bgPrimary,color:W?l.accent:l.textSecondary,border:`1px solid ${W?l.accent:l.borderLight}`},disabled:d,children:P.name},P.id)})})]})]})})})]})]}),jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${l.border}`},children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:l.textSecondary},onMouseEnter:P=>P.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:P=>P.currentTarget.style.backgroundColor="transparent",disabled:d,children:"Cancelar"}),jsx("button",{type:"submit",disabled:d,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:l.accent,color:"#FFF"},onMouseEnter:P=>!d&&(P.currentTarget.style.opacity="0.9"),onMouseLeave:P=>!d&&(P.currentTarget.style.opacity="1"),children:d?jsxs(Fragment,{children:[jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsx(Fragment,{children:m==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var $g=['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"'],md=()=>jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[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"}),jsx("circle",{cx:"12",cy:"12",r:"4"})]}),Ug=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13"})}),zg=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M18 6L6 18M6 6L18 18"})}),Wg=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M5 12h14"})}),Gg=()=>jsx("div",{className:"flex gap-1 items-center",children:[0,1,2].map(e=>jsx(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 Jo({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:d,onDependencyCreate:m,onDependencyDelete:c}){let[n,p]=useState(false),[l,i]=useState(false),[u,v]=useState([]),[f,y]=useState(""),[x,b]=useState(false),[g,w]=useState(true),D=useRef(null),h=useRef(null),A=useRef(null),{enabled:C=true,placeholder:L='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:T="bottom-right",onCommand:U,suggestions:G=$g,maxHistory:$=50,persistHistory:E}=a,X=E?.storageKey||"gantt-ai-history",fe=E?.maxMessages??5;useEffect(()=>{if(E?.enabled)try{let F=localStorage.getItem(X);if(F){let V=JSON.parse(F).map(P=>({...P,timestamp:new Date(P.timestamp)}));v(V.slice(-fe));}}catch(F){console.warn("[GanttAIAssistant] Failed to load persisted history:",F);}},[E?.enabled,X,fe]),useEffect(()=>{if(E?.enabled&&u.length>0)try{let F=u.filter(M=>!M.isLoading).slice(-fe);localStorage.setItem(X,JSON.stringify(F));}catch(F){console.warn("[GanttAIAssistant] Failed to persist history:",F);}},[u,E?.enabled,X,fe]),useEffect(()=>{h.current&&h.current.scrollIntoView({behavior:"smooth"});},[u]),useEffect(()=>{n&&!l&&D.current&&setTimeout(()=>D.current?.focus(),100);},[n,l]);let Ce=useCallback(F=>{if(F.success)switch(F.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":F.taskId&&F.updates&&o?.(F.taskId,F.updates);break;case "create_task":F.newTask&&s?.(F.newTask);break;case "delete_task":F.taskId&&d?.(F.taskId);break;case "link_tasks":F.dependencyFrom&&F.dependencyTo&&m?.(F.dependencyFrom,F.dependencyTo);break;case "unlink_tasks":F.taskId&&F.dependencyFrom&&c?.(F.taskId,F.dependencyFrom);break}},[o,s,d,m,c]),Le=useCallback(async F=>{if(!F.trim()||x)return;let M={id:`user-${Date.now()}`,role:"user",content:F,timestamp:new Date};v(P=>[...P.slice(-($-1)),M]),y(""),w(false),b(true);let V={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};v(P=>[...P,V]);try{if(U){let P=await U(F,e);v(W=>{let de=W.filter(Ee=>!Ee.isLoading),ae={id:`assistant-${Date.now()}`,role:"assistant",content:P.message,timestamp:new Date,command:P};return [...de,ae]}),Ce(P);}else v(P=>[...P.filter(de=>!de.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(P){v(W=>[...W.filter(ae=>!ae.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${P instanceof Error?P.message:"Unknown error"}`,timestamp:new Date}]);}finally{b(false);}},[x,$,U,e,Ce]),Pe=F=>{F.preventDefault(),Le(f);},ce=F=>{y(F),D.current?.focus();};if(useEffect(()=>{let F=M=>{(M.metaKey||M.ctrlKey)&&M.key==="k"&&(M.preventDefault(),p(V=>!V),n||i(false)),M.key==="Escape"&&n&&p(false);};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[n]),useEffect(()=>{if(!n)return;let F=V=>{let P=V.target;A.current&&!A.current.contains(P)&&p(false);},M=setTimeout(()=>{document.addEventListener("mousedown",F);},100);return ()=>{clearTimeout(M),document.removeEventListener("mousedown",F);}},[n]),!C)return null;let S={"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 jsxs(Ye,{children:[jsx(AnimatePresence,{children:!n&&jsxs(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 ${S[T]} 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:()=>p(true),children:[jsx(md,{}),jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),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"})]})}),jsx(AnimatePresence,{children:n&&jsxs(motion.div,{ref:A,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:l?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${S[T]} 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:[jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},children:[jsxs("div",{className:"flex items-center gap-2 text-white",children:[jsx(md,{}),jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>i(F=>!F),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(Wg,{})}),jsx("button",{onClick:()=>p(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(zg,{})})]})]}),jsx(AnimatePresence,{children:!l&&jsxs(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:[jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[u.length===0&&g&&jsxs("div",{className:"space-y-3",children:[jsx("p",{className:"text-sm text-center",style:{color:t.textSecondary},children:"Try asking me to edit your Gantt chart:"}),jsx("div",{className:"flex flex-wrap gap-2",children:G.slice(0,4).map((F,M)=>jsx("button",{onClick:()=>ce(F),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:F.length>30?F.slice(0,30)+"...":F},M))})]}),u.map(F=>jsx(motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${F.role==="user"?"justify-end":"justify-start"}`,children:jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${F.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:F.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:F.role==="user"?"white":t.textPrimary},children:[F.isLoading?jsx(Gg,{}):jsx("p",{className:"text-sm whitespace-pre-wrap",children:F.content}),F.command&&jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:F.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:F.command.success?"#10B981":"#EF4444"},children:[F.command.success?"\u2713":"\u2717",jsx("span",{className:"capitalize",children:F.command.type.replace(/_/g," ")})]})]})},F.id)),jsx("div",{ref:h})]}),jsxs("form",{onSubmit:Pe,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsx("input",{ref:D,type:"text",value:f,onChange:F=>y(F.target.value),placeholder:L,disabled:x,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsx("button",{type:"submit",disabled:!f.trim()||x,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:f.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:f.trim()?"white":t.textSecondary},children:jsx(Ug,{})})]}),jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function pd(e,t=50){let[a,r]=useState({past:[],present:e,future:[]}),o=useRef(false),s=useCallback((n,p=true)=>{r(l=>{let i=typeof n=="function"?n(l.present):n;if(o.current)return {...l,present:i};if(!p)return {...l,present:i};let u=[...l.past,l.present];return u.length>t&&u.shift(),{past:u,present:i,future:[]}});},[t]),d=useCallback(()=>{r(n=>{if(n.past.length===0)return n;let p=n.past[n.past.length-1],l=n.past.slice(0,n.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:l,present:p,future:[n.present,...n.future]}});},[]),m=useCallback(()=>{r(n=>{if(n.future.length===0)return n;let p=n.future[0],l=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:p,future:l}});},[]),c=useCallback(()=>{r(n=>({past:[],present:n.present,future:[]}));},[]);return {state:a.present,setState:s,undo:d,redo:m,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:c}}function ud({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){useEffect(()=>{if(!o)return;let s=d=>{let m=navigator.platform.toUpperCase().indexOf("MAC")>=0,c=m?d.metaKey:d.ctrlKey;if(c&&d.key==="z"&&!d.shiftKey&&a){d.preventDefault(),e();return}if(r){if(!m&&c&&d.key==="y"){d.preventDefault(),t();return}if(m&&c&&d.shiftKey&&d.key==="z"){d.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var jg={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${oe.formatDate(e.startDate)} - ${oe.formatDate(e.endDate)}`);let a=oe.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=>oe.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function gd(e){return {...jg,...e}}var Qg=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},hd=forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:d="week",rowDensity:m="comfortable",showThemeSelector:c=true,showExportButton:n=true,availableUsers:p=[],templates:l,enableAutoCriticalPath:i=true,aiAssistant:u,locale:v="en",customTranslations:f,showCreateTaskButton:y=false,createTaskLabel:x,onCreateTask:b,onThemeChange:g,onTaskClick:w,onTaskDblClick:D,onTaskContextMenu:h,onTaskUpdate:A,onProgressChange:C,onTaskEdit:L,onTaskAddSubtask:T,onTaskMarkIncomplete:U,onTaskSetInProgress:G,onDependencyCreate:$,onDependencyDelete:E,onBeforeTaskAdd:X,onAfterTaskAdd:fe,onBeforeTaskUpdate:Ce,onAfterTaskUpdate:Le,onBeforeTaskDelete:Pe,onAfterTaskDelete:ce}=a,F=useContext(Lo)?.theme,[M,V]=useState(F||s||"dark"),[P,W]=useState(d),[de,ae]=useState(m),[Ee,le]=useState(1),[Ve,he]=useState(0),[at,Et]=useState(false),[gt,ft]=useState(null),[rt,ot]=useState({isOpen:false,x:0,y:0,task:null}),[ia,wt]=useState(null),[ct,Lt]=useState(null);useEffect(()=>{F&&F!==M&&V(F);},[F]),useEffect(()=>{s&&s!==M&&V(s);},[s]);let jt=useCallback(N=>{V(N),g?.(N);},[g]),{state:we,setState:O,undo:De,redo:ze,canUndo:Ue,canRedo:bt,clearHistory:J}=pd(t,50);useEffect(()=>{O(t);},[t,O]);let Q=useRef(t),xe=useRef(true);useEffect(()=>{if(xe.current){xe.current=false,Q.current=we;return}if(!r)return;let N=JSON.stringify(Q.current),z=JSON.stringify(we);N!==z&&(Q.current=we,r(we));},[we,r]);let ge=useMemo(()=>ps(v,f),[v,f]),ee=useCallback(N=>[{id:"name",label:N.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:N.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:N.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:N.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:N.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:N.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:N.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:N.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Te,be]=useState(()=>ee(ge));useEffect(()=>{be(N=>N.map(z=>({...z,label:ge.columns[z.id==="name"?"taskName":z.id]||z.label})));},[ge]);let ke=useMemo(()=>{let N=Te.filter(re=>re.visible),z=N.some(re=>re.id!=="name");return N.reduce((re,ye)=>re+ye.width,0)+(z?20:0)},[Te]);useEffect(()=>{gt!==null&&gt>ke&&(Te.filter(Y=>Y.visible).some(Y=>Y.id!=="name")||ft(null));},[Te,ke,gt]);let R=useMemo(()=>gt!==null?Math.max(280,gt,ke):Math.max(280,ke),[gt,ke]),H=useRef(null),q=useRef(null),se=useRef(null),ie=useMemo(()=>Ll(M),[M]),B=useMemo(()=>({theme:ie,themeName:M}),[ie,M]),K=useMemo(()=>gd(l),[l]),Ne=useMemo(()=>{if(!i)return we;let N=oe.calculateCriticalPath(we),z=Y=>Y.map(re=>({...re,isCriticalPath:N.includes(re.id),subtasks:re.subtasks?z(re.subtasks):void 0}));return z(we)},[we,i]),je=Qg(de);ud({undo:De,redo:ze,canUndo:Ue,canRedo:bt,enabled:true}),useImperativeHandle(o,()=>({getTask:N=>oe.findTaskById(we,N),addTask:(N,z)=>{O(Y=>{if(!z)return [...Y,{...N,level:0}];let re=ye=>ye.map(Se=>Se.id===z?{...Se,subtasks:[...Se.subtasks||[],{...N,parentId:z,level:(Se.level||0)+1}],isExpanded:true}:Se.subtasks?{...Se,subtasks:re(Se.subtasks)}:Se);return re(Y)});},updateTask:(N,z)=>{O(Y=>{let re=ye=>ye.map(Se=>Se.id===N?{...Se,...z}:Se.subtasks?{...Se,subtasks:re(Se.subtasks)}:Se);return re(Y)});},deleteTask:N=>{O(z=>{let Y=re=>re.filter(ye=>ye.id===N?false:(ye.subtasks&&(ye.subtasks=Y(ye.subtasks)),true));return Y(z)});},deleteTasks:N=>{O(z=>vs(z,N));},duplicateTask:N=>{O(z=>xs(z,[N]));},splitTask:(N,z,Y=3)=>{O(re=>oe.splitTask(re,N,z,Y));},calculateEndDate:oe.calculateEndDate,calculateDuration:oe.calculateDuration,validateDependency:(N,z)=>!oe.validateDependencies(we,N,z),getAllTasks:()=>oe.flattenTasks(we),getTasksByStatus:N=>oe.flattenTasks(we).filter(z=>z.status===N),getTasksByParent:N=>N?oe.findTaskById(we,N)?.subtasks||[]:we.filter(Y=>!Y.parentId),getCriticalPath:()=>oe.flattenTasks(we).filter(N=>N.isCriticalPath),indentTask:N=>{O(z=>bs(z,[N]));},outdentTask:N=>{O(z=>hs(z,[N]));},moveTask:(N,z)=>{O(Y=>ys(Y,[N],z));},createSubtask:async N=>{let{tasks:z,newTask:Y}=Cs(we,N);if(X){let re=X({...Y,parentId:N});if((re instanceof Promise?await re:re)===false)return}O(z),fe&&fe({...Y,parentId:N});},scrollToTask:N=>{let Y=oe.flattenTasks(we).findIndex(re=>re.id===N);if(Y!==-1&&H.current){let re=Y*je;H.current.scrollTo({top:re,behavior:"smooth"}),q.current&&q.current.scrollTo({top:re,behavior:"smooth"});}},highlightTask:(N,z=2e3)=>{},expandTask:N=>{O(z=>{let Y=re=>re.map(ye=>ye.id===N?{...ye,isExpanded:true}:ye.subtasks?{...ye,subtasks:Y(ye.subtasks)}:ye);return Y(z)});},collapseTask:N=>{O(z=>{let Y=re=>re.map(ye=>ye.id===N?{...ye,isExpanded:false}:ye.subtasks?{...ye,subtasks:Y(ye.subtasks)}:ye);return Y(z)});},expandAll:()=>{O(N=>{let z=Y=>Y.map(re=>({...re,isExpanded:true,subtasks:re.subtasks?z(re.subtasks):void 0}));return z(N)});},collapseAll:()=>{O(N=>{let z=Y=>Y.map(re=>({...re,isExpanded:false,subtasks:re.subtasks?z(re.subtasks):void 0}));return z(N)});},undo:De,redo:ze,canUndo:()=>Ue,canRedo:()=>bt,clearHistory:J,exportToPNG:async()=>{if(!se.current)throw new Error("Gantt container not found");let N=await bd(se.current,{backgroundColor:ie.bgPrimary,scale:2});return new Promise((z,Y)=>{N.toBlob(re=>{re?z(re):Y(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async N=>{await oe.exportToPDF(we,N);},exportToExcel:async N=>{await oe.exportToExcel(we,N);},exportToJSON:()=>oe.exportToJSON(we),exportToCSV:()=>oe.exportToCSV(we),importFromJSON:N=>{let z=oe.importFromJSON(N);O(z);},getTasks:()=>we,refresh:()=>{O(N=>[...N]);},clearAll:()=>{O([]);}}),[we,De,ze,Ue,bt,J,ie,je]);let Pt=useCallback(N=>{be(z=>z.map(Y=>Y.id===N?{...Y,visible:!Y.visible}:Y));},[]),Wr=useCallback((N,z)=>{be(Y=>Y.map(re=>{if(re.id!==N)return re;let ye=re.minWidth??100,Se=re.maxWidth??800,Ft=Math.max(ye,Math.min(Se,z));return {...re,width:Ft}}));},[]),Gr=useCallback(N=>{O(z=>ws(z,N)),a.onTaskToggleExpand?.(N);},[a]),Wa=useCallback((N,z)=>{if(Ce&&Ce(N,z)===false)return;let re=oe.findTaskById(we,N)?.progress,ye=Ft=>Ft.map(Bt=>Bt.id===N?{...Bt,...z}:Bt.subtasks?{...Bt,subtasks:ye(Bt.subtasks)}:Bt);O(ye(we));let Se=oe.findTaskById(ye(we),N);Se&&(A?.(Se),Le?.(Se),z.progress!==void 0&&re!==void 0&&z.progress!==re&&C?.(N,re,z.progress));},[we,A,Ce,Le,C]),yn=useCallback(N=>{N.length!==0&&(O(z=>bs(z,N)),a.onTaskIndent?.(N[0]));},[a]),me=useCallback(N=>{N.length!==0&&(O(z=>hs(z,N)),a.onTaskOutdent?.(N[0]));},[a]),mt=useCallback((N,z,Y)=>{O(re=>Ql(re,N,z,Y)),a.onTaskReparent?.(N,z,Y);},[a]),Ht=useCallback((N,z)=>{N.length!==0&&(O(Y=>ys(Y,N,z)),a.onTaskMove?.(N[0],z));},[a]),Ga=useCallback(async N=>{let z=[];for(let Y of N)Pe&&await Promise.resolve(Pe(Y))===false||z.push(Y);z.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(z):(O(Y=>vs(Y,z)),z.forEach(Y=>a.onTaskDelete?.(Y))),ce&&z.forEach(Y=>ce(Y)));},[a,Pe,ce]),bo=useCallback(N=>{O(z=>xs(z,N)),N.forEach(z=>a.onTaskDuplicate?.(z));},[a]),vr=useCallback((N,z)=>{O(Y=>{let{tasks:re,newTask:ye}=Zl(Y,N,z);return X&&X(ye)===false?Y:(a.onTaskCreate?.(ye.parentId,ye.position||0),fe?.(ye),re)});},[a,X,fe]),Ma=useCallback((N,z)=>{O(Y=>ks(Y,N,z)),a.onTaskRename?.(N,z);},[a]),Aa=useCallback(N=>{O(z=>{let{tasks:Y}=Cs(z,N);return a.onTaskCreate?.(N,0),Y});},[a]),Ct=useCallback((N,z,Y)=>{let re=N.startDate?Math.round((z.getTime()-N.startDate.getTime())/864e5):0,ye=Bt=>Bt.map(_t=>_t.id===N.id?{..._t,startDate:z,endDate:Y,...N.segments&&{segments:N.segments}}:_t.subtasks?{..._t,subtasks:ye(_t.subtasks)}:_t),Se=ye(we);Se=oe.autoScheduleDependents(Se,N.id,re),O(Se);let Ft={...N,startDate:z,endDate:Y};A?.(Ft);},[we,A]),vn=useCallback((N,z)=>{h?.(N,z),ot({isOpen:true,x:z.clientX,y:z.clientY,task:N});},[h]),xn=useCallback((N,z)=>{let Y=oe.splitTask(we,N.id,z);O(Y),ot({isOpen:false,x:0,y:0,task:null});},[we]),kn=useCallback(N=>{D?.(N),L||wt(N);},[D,L]),xr=useCallback((N,z,Y)=>{let re=new Map,ye=fa=>{fa.forEach(Ia=>{Ia.dependencies&&re.set(Ia.id,Ia.dependencies),Ia.subtasks&&ye(Ia.subtasks);});};ye(Y);let Se=re.get(z)||[];re.set(z,[...Se,N]);let Ft=new Set,Bt=new Set,_t=fa=>{if(!Ft.has(fa)){Ft.add(fa),Bt.add(fa);let Ia=re.get(fa)||[];for(let er of Ia){if(!Ft.has(er)&&_t(er))return true;if(Bt.has(er))return true}}return Bt.delete(fa),false};return _t(z)},[]),Ti=useCallback((N,z)=>{if(xr(N.id,z,we)){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 Y=re=>re.map(ye=>{if(ye.id===z){let Se=ye.dependencies||[];if(!Se.includes(N.id))return {...ye,dependencies:[...Se,N.id]}}return ye.subtasks?{...ye,subtasks:Y(ye.subtasks)}:ye});O(Y(we)),$?.(N.id,z);},[we,$,xr]),Di=useCallback((N,z)=>{let Y=re=>re.map(ye=>{if(ye.id===N&&ye.dependencies){let Se=ye.dependencies.filter(Ft=>Ft!==z);return {...ye,dependencies:Se}}return ye.subtasks?{...ye,subtasks:Y(ye.subtasks)}:ye});O(Y(we)),E?.(N,z);},[we,E]),{startDate:Ac,endDate:Ic}=useMemo(()=>{let N=we.filter(Se=>Se.startDate&&Se.endDate);if(N.length===0){let Se=new Date,Ft=new Date(Se);Ft.setDate(Ft.getDate()-30);let Bt=new Date(Se);return Bt.setDate(Bt.getDate()+60),{startDate:Ft,endDate:Bt}}let z=N.flatMap(Se=>[Se.startDate,Se.endDate]).filter(Se=>Se!==void 0),Y=new Date(Math.min(...z.map(Se=>Se.getTime()))),re=new Date(Math.max(...z.map(Se=>Se.getTime()))),ye=P==="day"?7:P==="week"?14:30;return Y.setDate(Y.getDate()-ye),re.setDate(re.getDate()+ye),{startDate:Y,endDate:re}},[we,P]),Lc=useCallback(async()=>{if(!se.current)return;let N=await bd(se.current,{backgroundColor:ie.bgPrimary,scale:2}),z=document.createElement("a");z.download="gantt-chart.png",z.href=N.toDataURL("image/png"),z.click();},[ie]),Fc=useCallback(async()=>{await oe.exportToPDF(we);},[we]),Bc=useCallback(async()=>{await oe.exportToExcel(we);},[we]),Rc=useCallback(()=>{let N=oe.exportToCSV(we),z=new Blob([N],{type:"text/csv;charset=utf-8;"}),Y=document.createElement("a");Y.href=URL.createObjectURL(z),Y.download="gantt-chart.csv",Y.click(),URL.revokeObjectURL(Y.href);},[we]),Oc=useCallback(()=>{let N=oe.exportToJSON(we),z=new Blob([N],{type:"application/json;charset=utf-8;"}),Y=document.createElement("a");Y.href=URL.createObjectURL(z),Y.download="gantt-chart.json",Y.click(),URL.revokeObjectURL(Y.href);},[we]),$c=useCallback(()=>{oe.exportToMSProject(we,"Gantt Project","project.xml");},[we]),Uc=N=>{N.preventDefault(),Et(true);};return useEffect(()=>{let N=q.current,z=H.current;if(!N||!z)return;let Y=z.querySelector(".gantt-taskgrid-content"),re=()=>{let _t=N.scrollTop;he(_t),Y&&(Y.style.transform=`translateY(-${_t}px)`);},ye=_t=>{if(at&&z){let Ia=z.parentElement?.getBoundingClientRect()?.left||0,er=_t.clientX-Ia,zc=280,Wc=Math.min(window.innerWidth-300,800);er>=zc&&er<=Wc&&ft(er);}},Se=()=>{Et(false);},Ft=z.querySelector(".gantt-grid-scroll")||z,Bt=_t=>{let fa=_t;fa.deltaY!==0&&(N.scrollTop+=fa.deltaY,_t.preventDefault());};return N.addEventListener("scroll",re),Ft.addEventListener("wheel",Bt,{passive:false}),document.addEventListener("mousemove",ye),document.addEventListener("mouseup",Se),()=>{N.removeEventListener("scroll",re),Ft.removeEventListener("wheel",Bt),document.removeEventListener("mousemove",ye),document.removeEventListener("mouseup",Se);}},[at]),jsx(Ar.Provider,{value:ge,children:jsx(Nn.Provider,{value:B,children:jsxs("div",{ref:se,className:"flex flex-col h-full w-full",style:{backgroundColor:ie.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsx(Bo,{theme:ie,timeScale:P,onTimeScaleChange:W,zoom:Ee,onZoomChange:le,currentTheme:M,onThemeChange:jt,rowDensity:de,onRowDensityChange:ae,showThemeSelector:c,showCreateTaskButton:y,createTaskLabel:x,onCreateTask:b,onExportPNG:n?Lc:void 0,onExportPDF:n?Fc:void 0,onExportExcel:n?Bc:void 0,onExportCSV:n?Rc:void 0,onExportJSON:n?Oc:void 0,onExportMSProject:n?$c:void 0}),jsxs("div",{ref:H,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:R,overflow:"hidden"},children:jsx(Uo,{tasks:Ne,theme:ie,rowHeight:je,availableUsers:p,templates:K,onTaskClick:w,onTaskDblClick:kn,onTaskContextMenu:h,onTaskToggle:Gr,scrollTop:Ve,columns:Te,onToggleColumn:Pt,onColumnResize:Wr,onTaskUpdate:Wa,onTaskIndent:yn,onTaskOutdent:me,onTaskMove:Ht,onMultiTaskDelete:Ga,onTaskDuplicate:bo,onTaskCreate:vr,onTaskRename:Ma,onCreateSubtask:Aa,onOpenTaskModal:w?N=>w(N):void 0,onDeleteRequest:(N,z)=>Lt({taskId:N,taskName:z}),onTaskReparent:mt})}),jsx("div",{className:"flex-shrink-0 cursor-col-resize",style:{width:6,marginLeft:-3,zIndex:10},onMouseDown:Uc}),jsx("div",{ref:q,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsx(Ko,{tasks:Ne,theme:ie,rowHeight:je,timeScale:P,startDate:Ac,endDate:Ic,zoom:Ee,templates:K,onTaskClick:w,onTaskDblClick:kn,onTaskContextMenu:vn,onTaskDateChange:Ct,onDependencyCreate:Ti,onDependencyDelete:Di})})]}),rt.task&&jsx(Ir,{isOpen:rt.isOpen,x:rt.x,y:rt.y,theme:ie,onClose:()=>ot({isOpen:false,x:0,y:0,task:null}),items:(()=>{let N=rt.task;return N?N.subtasks&&N.subtasks.length>0?[{id:"addSubtask",label:ge.contextMenu?.addSubtask||"Add Subtask",icon:lt.Add,onClick:()=>{T?T(N):Aa(N.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:ge.contextMenu?.deleteTask||"Delete Task",icon:lt.Delete,onClick:()=>{Lt({taskId:N.id,taskName:N.name});}}]:[{id:"edit",label:ge.contextMenu?.editTask||"Edit Task",icon:lt.Pencil,onClick:()=>{L?L(N):wt(N);}},{id:"addSubtask",label:ge.contextMenu?.addSubtask||"Add Subtask",icon:lt.Add,onClick:()=>{T?T(N):Aa(N.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:ge.contextMenu?.markIncomplete||"Mark Incomplete",icon:lt.MarkIncomplete,onClick:()=>{U?U(N):Wa(N.id,{status:"todo",progress:0});},disabled:N.status==="todo"},{id:"setInProgress",label:ge.contextMenu?.setInProgress||"Set In Progress",icon:lt.SetInProgress,onClick:()=>{G?G(N):Wa(N.id,{status:"in-progress"});},disabled:N.status==="in-progress"},{id:"markComplete",label:ge.contextMenu?.markComplete||"Mark Complete",icon:lt.MarkComplete,onClick:()=>{Wa(N.id,{status:"completed",progress:100});},disabled:N.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:ge.contextMenu?.splitTask||"Split Task",icon:lt.Split,onClick:()=>{if(!N.startDate||!N.endDate){console.warn("Cannot split task without dates");return}let Y=N.startDate.getTime(),re=N.endDate.getTime(),ye=Y+(re-Y)/2,Se=new Date(ye);xn(N,Se);},disabled:!N.startDate||!N.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:ge.contextMenu?.deleteTask||"Delete Task",icon:lt.Delete,onClick:()=>{Lt({taskId:N.id,taskName:N.name});}}]:[]})()}),ia&&jsx(Xo,{isOpen:true,onClose:()=>wt(null),task:ia,onSubmit:N=>{Wa(ia.id,N),wt(null);},mode:"edit",theme:M}),jsx(AnimatePresence,{children:ct&&jsx(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:()=>Lt(null),children:jsxs(motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.2,ease:"easeOut"},onClick:N=>N.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:ie.bgSecondary,border:`1px solid ${ie.border}`},children:[jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${ie.border}`},children:jsxs("div",{className:"flex items-start gap-3",children:[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:jsx(AlertTriangle,{className:"w-5 h-5",style:{color:"#EF4444"}})}),jsxs("div",{className:"flex-1",children:[jsxs("h3",{className:"text-lg font-semibold",style:{color:ie.textPrimary,fontFamily:"Inter, sans-serif"},children:[ge.contextMenu?.deleteTask||"Delete Task","?"]}),jsx("p",{className:"text-sm mt-1",style:{color:ie.textSecondary,fontFamily:"Inter, sans-serif"},children:v==="es"?"Esta acci\xF3n no se puede deshacer":"This action cannot be undone"})]})]})}),jsx("div",{className:"px-6 py-4",children:jsxs("p",{className:"text-sm leading-relaxed",style:{color:ie.textSecondary,fontFamily:"Inter, sans-serif"},children:[v==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxs("span",{className:"font-semibold",style:{color:ie.textPrimary},children:['"',ct.taskName,'"']}),"."]})}),jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:ie.bgPrimary,borderTop:`1px solid ${ie.border}`},children:[jsx("button",{onClick:()=>Lt(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:ie.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:N=>{N.currentTarget.style.backgroundColor=ie.hoverBg;},onMouseLeave:N=>{N.currentTarget.style.backgroundColor="transparent";},children:v==="es"?"Cancelar":"Cancel"}),jsxs("button",{onClick:()=>{Ga([ct.taskId]),Lt(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:N=>{N.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:N=>{N.currentTarget.style.backgroundColor="#EF4444";},children:[jsx(Trash2,{className:"w-4 h-4"}),v==="es"?"Eliminar":"Delete"]})]})]})})}),u?.enabled&&jsx(Jo,{tasks:we,theme:ie,config:u,onTasksUpdate:O,onTaskUpdate:Wa,onTaskCreate:N=>{O(z=>[...z,N]);},onTaskDelete:N=>{Ga([N]);},onDependencyCreate:(N,z)=>{let Y=oe.findTaskById(we,N);Y&&Ti(Y,z);},onDependencyDelete:Di})]})})})});var yd=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
279
279