@libxai/board 0.17.354 → 0.17.355
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -339,7 +339,7 @@
|
|
|
339
339
|
</Calendars>
|
|
340
340
|
<Tasks>${p}
|
|
341
341
|
</Tasks>
|
|
342
|
-
</Project>`,u=new Blob([i],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(u),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=fe.flattenTasks(e),a=t.filter(i=>i.startDate&&i.endDate);if(a.length===0)return [];let r=new Map,o=i=>{if(r.has(i.id))return;let u=i.startDate&&i.endDate?fe.calculateDuration(i.startDate,i.endDate):0,d=0;if(i.dependencies&&i.dependencies.length>0)for(let f of i.dependencies){let C=t.find(T=>T.id===f);if(C){o(C);let T=r.get(f)?.ef||0;d=Math.max(d,T);}}let g=d+u;r.set(i.id,{es:d,ef:g});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(i=>i.ef)),n=new Map,m=i=>{if(n.has(i.id))return;let u=i.startDate&&i.endDate?fe.calculateDuration(i.startDate,i.endDate):0,d=t.filter(C=>C.dependencies&&C.dependencies.includes(i.id)),g=s;if(d.length>0)for(let C of d){m(C);let T=n.get(C.id)?.ls||0;g=Math.min(g,T);}let f=g-u;n.set(i.id,{ls:f,lf:g});};a.forEach(m);let p=[];for(let i of a){let u=r.get(i.id),d=n.get(i.id);if(u&&d){let g=d.ls-u.es;Math.abs(g)<.01&&p.push(i.id);}}return p},calculateSlack:(e,t)=>{let a=fe.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(fe.calculateCriticalPath(e).includes(t))return 0;let o=fe.getDependentTasks(e,t);if(o.length===0){let m=fe.getLatestEndDate(e);if(!m)return null;let p=fe.calculateDuration(a.endDate,m);return Math.max(0,p)}let s=o.filter(m=>m.startDate).map(m=>m.startDate.getTime()).sort((m,p)=>m-p)[0];if(!s)return null;let n=fe.calculateDuration(a.endDate,new Date(s));return Math.max(0,n)},isOnCriticalPath:(e,t)=>fe.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=fe.findTaskById(e,t);if(!r||!r.endDate)return e;let o=fe.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let n of o){if(!n.startDate||!n.endDate)continue;let m=fe.calculateDuration(n.startDate,n.endDate),p;a!==void 0?(p=new Date(n.startDate),p.setDate(p.getDate()+a)):(p=new Date(r.endDate),p.setDate(p.getDate()+1));let i=fe.calculateEndDate(p,m),u=d=>d.map(g=>g.id===n.id?{...g,startDate:p,endDate:i}:g.subtasks?{...g,subtasks:u(g.subtasks)}:g);s=u(s),s=fe.autoScheduleDependents(s,n.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,n,m)=>{if(a===0)return [];let p=[],i=o.getTime(),u=1e3*60*60*24,d=fe.findTaskById(e,t);if(!d||!d.endDate)return [];let g=(f,C,T=new Set)=>{if(T.has(f))return;T.add(f);let c=fe.getDependentTasks(e,f);for(let b of c){if(!b.startDate||!b.endDate)continue;let v=r.findIndex(N=>N.id===b.id);if(v===-1)continue;let l=b.startDate.getTime(),y=(b.endDate.getTime()-l)/u,w=(l-i)/u*s,x=w+C*s,R=Math.max(y*s,s),A=m+v*n+12;p.push({taskId:b.id,taskName:b.name,originalX:w,previewX:x,width:R,y:A,rowIndex:v,daysDelta:C,color:b.color}),g(b.id,C,T);}};return g(t,a),p},splitTask:(e,t,a,r=3)=>{let o=fe.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 n=new Date(a);n.setDate(n.getDate()+r);let m=new Date(o.endDate);m.setDate(m.getDate()+r);let p=[{startDate:new Date(o.startDate),endDate:s},{startDate:n,endDate:m}],i=u=>u.map(d=>d.id===o.id?{...d,endDate:m,segments:p}:d.subtasks?{...d,subtasks:i(d.subtasks)}:d);return i(e)}};function Ln({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:n,templates:m,dependencyLineStyle:p="curved",onTaskClick:i,onTaskDblClick:u,onTaskContextMenu:d,onTaskDateChange:g,onDependencyCreate:f,onDependencyDelete:C}){let[c,b]=react.useState([]),[v,l]=react.useState(null),[k,y]=react.useState(null),D=react.useCallback(I=>{l(I);},[]),w=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),x=r==="day"?60:r==="week"?20:8,R=w*x*n,A=I=>{let B=new Date(Date.UTC(I.getFullYear(),I.getMonth(),I.getDate())),S=B.getUTCDay()||7;B.setUTCDate(B.getUTCDate()+4-S);let G=new Date(Date.UTC(B.getUTCFullYear(),0,1));return Math.ceil(((B.getTime()-G.getTime())/864e5+1)/7)},N=I=>{let B=I.getDay();return B===0||B===6},U=react.useCallback(I=>{let B=Math.round(I/(x*n)),S=new Date(o);return S.setDate(S.getDate()+B),S},[o,x,n]),$=react.useCallback((I,B)=>{if(B.startDate&&B.endDate)return;let S=I.currentTarget.ownerSVGElement;if(!S)return;let G=S.createSVGPoint();G.x=I.clientX,G.y=I.clientY;let K=G.matrixTransform(S.getScreenCTM()?.inverse()),z=U(K.x),se=new Date(z);se.setDate(se.getDate()+1),g?.(B,z,se);},[U,g]),_=react.useMemo(()=>{let I=K=>K.map(z=>{if(z.subtasks&&z.subtasks.length>0){let se=I(z.subtasks),ye=se.filter(Pe=>Pe.startDate&&Pe.endDate);if(ye.length>0){let Pe=ye.map(Ne=>Ne.startDate.getTime()),pe=ye.map(Ne=>Ne.endDate.getTime()),He=new Date(Math.min(...Pe)),Ie=new Date(Math.max(...pe));return {...z,subtasks:se,startDate:He,endDate:Ie}}return {...z,subtasks:se}}return z}),B=(K,z=[])=>{for(let se of K)z.push(se),se.subtasks&&se.subtasks.length>0&&(se.isExpanded===void 0||se.isExpanded)&&B(se.subtasks,z);return z},S=I(e);return B(S)},[e]),Q=react.useCallback(I=>{if(!I.startDate||!I.endDate)return {x:0,width:0};let B=I.startDate.getTime(),S=I.endDate.getTime(),G=o.getTime(),K=(B-G)/(1e3*60*60*24),z=(S-B)/(1e3*60*60*24),se=K*x*n,ye=Math.max(x*n,40),Pe=Math.max(z*x*n,ye);return {x:se,width:Pe}},[o,x,n]),Te=react.useMemo(()=>_.filter(I=>I.startDate&&I.endDate).map(I=>{let{x:B,width:S}=Q(I),K=_.findIndex(z=>z.id===I.id)*a+12;return {id:I.id,x:B,y:K,width:S,height:32}}),[_,Q]),$e=react.useCallback((I,B,S)=>{if(!S||B===0){b([]);return}let G=fe.calculateCascadePreview(e,I,B,_,o,x*n,a,48);b(G);},[e,_,o,x,n,a,48]),tt=react.useMemo(()=>{let I=[],B=new Date(o);for(;B<=s;){let K=(B.getTime()-o.getTime())/864e5*x*n;if(r==="day")I.push({date:new Date(B),label:B.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:K}),B.setDate(B.getDate()+1);else if(r==="week"){let z=A(B);I.push({date:new Date(B),label:`Week ${z}`,x:K}),B.setDate(B.getDate()+7);}else I.push({date:new Date(B),label:B.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:K}),B.setMonth(B.getMonth()+1);}return I},[o,s,r,x,n]),Oe=react.useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*x*n,[o,x,n]),Re=Math.max(_.length*a,552);return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary,overflow:"visible"},children:[jsxRuntime.jsx("div",{style:{position:"sticky",top:0,zIndex:10,backgroundColor:t.bgGrid,flexShrink:0,height:"48px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:jsxRuntime.jsxs("svg",{width:Math.max(R,1e3),height:47,style:{display:"block"},children:[jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(R,1e3),height:48,fill:t.bgGrid}),tt.map((I,B)=>jsxRuntime.jsxs("g",{children:[B>0&&jsxRuntime.jsx("line",{x1:I.x,y1:0,x2:I.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsxRuntime.jsx("text",{x:I.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:I.label})]},`header-${B}`)),Oe>=0&&Oe<=R&&jsxRuntime.jsx("circle",{cx:Oe,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(R,1e3),height:Re,style:{display:"block",flexShrink:0,overflow:"visible"},children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsx("filter",{id:"shadow",children:jsxRuntime.jsx("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2",floodOpacity:"0.1"})}),jsxRuntime.jsx("pattern",{id:"diagonal-stripes",width:"8",height:"8",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:jsxRuntime.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"8",stroke:t.border,strokeWidth:"2"})})]}),jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(R,1e3),height:Re,fill:t.bgPrimary}),tt.map((I,B)=>{let S=tt[B+1]?.x||R,G=N(I.date);return jsxRuntime.jsxs("g",{children:[G&&jsxRuntime.jsx("rect",{x:I.x,y:0,width:S-I.x,height:_.length*a,fill:t.bgWeekend,opacity:1}),B>0&&jsxRuntime.jsx("line",{x1:I.x,y1:0,x2:I.x,y2:_.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},B)}),_.map((I,B)=>{let S=I.startDate&&I.endDate;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:0,y:B*a,width:R,height:a,fill:B%2===0?t.bgPrimary:t.bgGrid,opacity:1,style:{pointerEvents:"none"}},`row-${I.id}`),!S&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:0,y:B*a,width:R,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:G=>$(G,I),onMouseEnter:G=>{G.currentTarget.setAttribute("fill",t.accentLight),G.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:G=>{G.currentTarget.setAttribute("fill","transparent"),G.currentTarget.setAttribute("opacity","1");}},`clickable-${I.id}`),jsxRuntime.jsx("text",{x:Oe>0?Oe:100,y:B*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-${I.id}`)]})]},`row-group-${I.id}`)}),_.map((I,B)=>!I.dependencies||I.dependencies.length===0||!I.startDate||!I.endDate?null:I.dependencies.map(S=>{let G=_.find(O=>O.id===S);if(!G||!G.startDate||!G.endDate)return null;let K=_.findIndex(O=>O.id===S),z=Q(G),se=Q(I),ye=z.x+z.width,Pe=K*a+28,pe=se.x,He=B*a+28,Ie=K*a+50,Ne,We=Math.min(K,B),gt=Math.max(K,B);if(We===gt)Ne=pe;else {let O=pe;for(let te=We+1;te<gt;te++){let de=_[te];if(de&&de.startDate&&de.endDate){let he=Q(de);O=Math.min(O,he.x);}}Ne=O-12,Ne<ye+8&&(Ne=ye+8);}return k&&k.x1===ye&&k.y1===Pe&&k.x2===pe&&k.y2===He?null:jsxRuntime.jsx(Pn,{x1:ye,y1:Pe,x2:pe,y2:He,verticalX:Ne,routeY:Ie,fromIndex:K,toIndex:B,rowHeight:a,theme:t,lineStyle:p},`dep-${S}-${I.id}`)})),_.map((I,B)=>{if(!I.startDate||!I.endDate)return null;let{x:S,width:G}=Q(I),K=B*a+12,z=I.subtasks&&I.subtasks.length>0&&!I.isMilestone;return I.isMilestone?jsxRuntime.jsx(An,{task:I,x:S+G/2,y:K+16,theme:t,onClick:i},I.id):z?jsxRuntime.jsxs("g",{onClick:()=>i?.(I),onContextMenu:se=>{se.preventDefault(),se.stopPropagation(),d?.(I,se);},style:{cursor:"default"},children:[jsxRuntime.jsx("rect",{x:S,y:K,width:G,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:S,y1:K,x2:S+G,y2:K,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:S,y1:K,x2:S,y2:K+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:S+G,y1:K,x2:S+G,y2:K+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:S,y1:K+32,x2:S+G,y2:K+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),G>60&&jsxRuntime.jsx("text",{x:S+12,y:K+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:I.name})]},I.id):jsxRuntime.jsx(Dn,{task:I,x:S,y:K,width:G,theme:t,dayWidth:x*n,startDate:o,templates:m,onClick:i,onDoubleClick:u,onContextMenu:d,onDateChange:g,onDependencyCreate:f,allTaskPositions:Te,onDragMove:$e,onHoverChange:D},I.id)}),_.map((I,B)=>!I.dependencies||I.dependencies.length===0||!I.startDate||!I.endDate?null:I.dependencies.map(S=>{let G=_.find(he=>he.id===S);if(!G||!G.startDate||!G.endDate)return null;let K=_.findIndex(he=>he.id===S),z=Q(G),se=Q(I),ye=z.x+z.width,Pe=K*a+28,pe=se.x,He=B*a+28,Ie=K*a+50,Ne=K===B,We,gt=Math.min(K,B),st=Math.max(K,B);if(gt===st)We=pe;else {let he=pe;for(let Me=gt+1;Me<st;Me++){let _e=_[Me];if(_e&&_e.startDate&&_e.endDate){let bt=Q(_e);he=Math.min(he,bt.x);}}We=he-12,We<ye+8&&(We=ye+8);}let O;if(Ne){let he=ye+20,Me=pe-15;O=`M ${he} ${Pe} L ${Me} ${He}`;}else O=`M ${We} ${Pe+10} L ${We} ${He-10}`;if(k&&k.x1===ye&&k.y1===Pe&&k.x2===pe&&k.y2===He)return null;let de=he=>{let Me=he.currentTarget.ownerSVGElement;if(!Me)return;let _e=Me.getBoundingClientRect(),bt=he.clientX-_e.left,Se=he.clientY-_e.top;y({x1:ye,y1:Pe,x2:pe,y2:He,verticalX:We,routeY:Ie,fromIndex:K,toIndex:B,onDelete:()=>C?.(I.id,S),lineStyle:p,mouseX:bt,mouseY:Se});};return jsxRuntime.jsx("path",{d:O,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:de,onMouseMove:de},`dep-hover-${S}-${I.id}`)})),c.map(I=>jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("rect",{x:I.previewX,y:I.y-48,width:I.width,height:32,rx:8,fill:I.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(I.daysDelta)>0&&jsxRuntime.jsx("text",{x:I.previewX+I.width/2,y:I.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:I.daysDelta>0?`+${I.daysDelta}d`:`${I.daysDelta}d`})]},`cascade-preview-${I.taskId}`)),k&&(()=>{let{x1:I,y1:B,x2:S,y2:G,verticalX:K,onDelete:z,lineStyle:se,mouseX:ye,mouseY:Pe}=k,pe=S-I,He=I+pe/2,Ie=5,Ne=K??S-12,We=Ie,gt=G-B,st=gt>0,O=Math.abs(gt)<5,te;if(se==="squared")te=`M ${I} ${B} L ${Ne} ${B} L ${Ne} ${G} L ${S} ${G}`;else if(O){let re=Math.min(Math.abs(pe)/3,30);te=`M ${I} ${B} C ${I+re} ${B}, ${S-re} ${G}, ${S} ${G}`;}else st?te=`M ${I} ${B} L ${Ne-We} ${B} Q ${Ne} ${B} ${Ne} ${B+We} L ${Ne} ${G-We} Q ${Ne} ${G} ${Ne+We} ${G} L ${S} ${G}`:te=`M ${I} ${B} L ${Ne-We} ${B} Q ${Ne} ${B} ${Ne} ${B-We} L ${Ne} ${G+We} Q ${Ne} ${G} ${Ne+We} ${G} L ${S} ${G}`;let de=5,he=S-de,Me=G-de*.5,_e=S-de,bt=G+de*.5,Se=t.dependency,Lt="#f87171",At="rgba(248, 113, 113, 0.15)",ct=He,Je=O?(B+G)/2:B,Ht=false;ye!==void 0&&Pe!==void 0&&(ct=Math.max(I+20,Math.min(Ne-10,ye)),Je=O?(B+G)/2:B);let sa=Math.floor(Je/a);if(sa>=0&&sa<_.length){let re=_[sa];if(re&&re.startDate&&re.endDate){let Vt=Q(re),ie=sa*a+12,E=ie+32,q=Vt.x-15,ue=Vt.x+Vt.width+50;ct>=q&&ct<=ue&&Je>=ie-5&&Je<=E+5&&(Ht=true);}}return jsxRuntime.jsxs("g",{onMouseLeave:()=>y(null),onMouseMove:re=>{let Vt=re.currentTarget.ownerSVGElement||re.currentTarget;if(!Vt)return;let ie=Vt.getBoundingClientRect(),E=re.clientX-ie.left,q=re.clientY-ie.top;y(ue=>ue?{...ue,mouseX:E,mouseY:q}:null);},children:[jsxRuntime.jsx("path",{d:te,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsxRuntime.jsx("path",{d:te,fill:"none",stroke:Se,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsxRuntime.jsx("path",{d:te,fill:"none",stroke:Se,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("path",{d:`M ${S} ${G} L ${he} ${Me} M ${S} ${G} L ${_e} ${bt}`,fill:"none",stroke:Se,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("circle",{cx:S,cy:G,r:4,fill:Se,opacity:.9,style:{pointerEvents:"none"}}),!Ht&&jsxRuntime.jsxs(framerMotion.motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:re=>{re.stopPropagation(),y(null),z();},style:{cursor:"pointer"},children:[jsxRuntime.jsx("circle",{cx:ct,cy:Je,r:9,fill:At,stroke:Lt,strokeWidth:1.5}),jsxRuntime.jsx("line",{x1:ct-3,y1:Je-3,x2:ct+3,y2:Je+3,stroke:Lt,strokeWidth:1.5,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:ct+3,y1:Je-3,x2:ct-3,y2:Je+3,stroke:Lt,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),Oe>=0&&Oe<=R&&jsxRuntime.jsx("line",{x1:Oe,y1:0,x2:Oe,y2:Re,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),v&&jsxRuntime.jsx(pc,{tooltipData:v,theme:t})]})]})}var u0=['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"'],fc=()=>jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),g0=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13"})}),f0=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M18 6L6 18M6 6L18 18"})}),h0=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M5 12h14"})}),b0=()=>jsxRuntime.jsx("div",{className:"flex gap-1 items-center",children:[0,1,2].map(e=>jsxRuntime.jsx(framerMotion.motion.div,{className:"w-2 h-2 rounded-full bg-current",animate:{scale:[1,1.2,1],opacity:[.5,1,.5]},transition:{duration:.8,repeat:1/0,delay:e*.15}},e))});function In({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:n,onDependencyCreate:m,onDependencyDelete:p}){let[i,u]=react.useState(false),[d,g]=react.useState(false),[f,C]=react.useState([]),[T,c]=react.useState(""),[b,v]=react.useState(false),[l,k]=react.useState(true),y=react.useRef(null),D=react.useRef(null),w=react.useRef(null),{enabled:x=true,placeholder:R='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:A="bottom-right",onCommand:N,suggestions:U=u0,maxHistory:$=50,persistHistory:_}=a,Q=_?.storageKey||"gantt-ai-history",Te=_?.maxMessages??5;react.useEffect(()=>{if(_?.enabled)try{let B=localStorage.getItem(Q);if(B){let G=JSON.parse(B).map(K=>({...K,timestamp:new Date(K.timestamp)}));C(G.slice(-Te));}}catch(B){console.warn("[GanttAIAssistant] Failed to load persisted history:",B);}},[_?.enabled,Q,Te]),react.useEffect(()=>{if(_?.enabled&&f.length>0)try{let B=f.filter(S=>!S.isLoading).slice(-Te);localStorage.setItem(Q,JSON.stringify(B));}catch(B){console.warn("[GanttAIAssistant] Failed to persist history:",B);}},[f,_?.enabled,Q,Te]),react.useEffect(()=>{D.current&&D.current.scrollIntoView({behavior:"smooth"});},[f]),react.useEffect(()=>{i&&!d&&y.current&&setTimeout(()=>y.current?.focus(),100);},[i,d]);let $e=react.useCallback(B=>{if(B.success)switch(B.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":B.taskId&&B.updates&&o?.(B.taskId,B.updates);break;case "create_task":B.newTask&&s?.(B.newTask);break;case "delete_task":B.taskId&&n?.(B.taskId);break;case "link_tasks":B.dependencyFrom&&B.dependencyTo&&m?.(B.dependencyFrom,B.dependencyTo);break;case "unlink_tasks":B.taskId&&B.dependencyFrom&&p?.(B.taskId,B.dependencyFrom);break}},[o,s,n,m,p]),tt=react.useCallback(async B=>{if(!B.trim()||b)return;let S={id:`user-${Date.now()}`,role:"user",content:B,timestamp:new Date};C(K=>[...K.slice(-($-1)),S]),c(""),k(false),v(true);let G={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};C(K=>[...K,G]);try{if(N){let K=await N(B,e);C(z=>{let se=z.filter(Pe=>!Pe.isLoading),ye={id:`assistant-${Date.now()}`,role:"assistant",content:K.message,timestamp:new Date,command:K};return [...se,ye]}),$e(K);}else C(K=>[...K.filter(se=>!se.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(K){C(z=>[...z.filter(ye=>!ye.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${K instanceof Error?K.message:"Unknown error"}`,timestamp:new Date}]);}finally{v(false);}},[b,$,N,e,$e]),Oe=B=>{B.preventDefault(),tt(T);},Re=B=>{c(B),y.current?.focus();};if(react.useEffect(()=>{let B=S=>{(S.metaKey||S.ctrlKey)&&S.key==="k"&&(S.preventDefault(),u(G=>!G),i||g(false)),S.key==="Escape"&&i&&u(false);};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[i]),react.useEffect(()=>{if(!i)return;let B=G=>{let K=G.target;w.current&&!w.current.contains(K)&&u(false);},S=setTimeout(()=>{document.addEventListener("mousedown",B);},100);return ()=>{clearTimeout(S),document.removeEventListener("mousedown",B);}},[i]),!x)return null;let I={"bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-right":"top-4 right-4","top-left":"top-4 left-4"};return jsxRuntime.jsxs(ft,{children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!i&&jsxRuntime.jsxs(framerMotion.motion.button,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},className:`fixed ${I[A]} z-[99999] flex items-center gap-2 px-4 py-3 rounded-full shadow-lg transition-colors`,style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"white",boxShadow:"0 4px 20px rgba(59, 130, 246, 0.4)"},onClick:()=>u(true),children:[jsxRuntime.jsx(fc,{}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),jsxRuntime.jsx("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono rounded bg-white/20",children:"\u2318K"})]})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:i&&jsxRuntime.jsxs(framerMotion.motion.div,{ref:w,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:d?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${I[A]} z-[99999] w-96 rounded-2xl overflow-hidden shadow-2xl flex flex-col`,style:{background:t.bgPrimary,border:`1px solid ${t.border}`,boxShadow:`0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px ${t.border}`},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-white",children:[jsxRuntime.jsx(fc,{}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{onClick:()=>g(B=>!B),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(h0,{})}),jsxRuntime.jsx("button",{onClick:()=>u(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(f0,{})})]})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!d&&jsxRuntime.jsxs(framerMotion.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"flex flex-col flex-1 min-h-0",children:[jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[f.length===0&&l&&jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("p",{className:"text-sm text-center",style:{color:t.textSecondary},children:"Try asking me to edit your Gantt chart:"}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:U.slice(0,4).map((B,S)=>jsxRuntime.jsx("button",{onClick:()=>Re(B),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:B.length>30?B.slice(0,30)+"...":B},S))})]}),f.map(B=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${B.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${B.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:B.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:B.role==="user"?"white":t.textPrimary},children:[B.isLoading?jsxRuntime.jsx(b0,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:B.content}),B.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:B.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:B.command.success?"#10B981":"#EF4444"},children:[B.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:B.command.type.replace(/_/g," ")})]})]})},B.id)),jsxRuntime.jsx("div",{ref:D})]}),jsxRuntime.jsxs("form",{onSubmit:Oe,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsxRuntime.jsx("input",{ref:y,type:"text",value:T,onChange:B=>c(B.target.value),placeholder:R,disabled:b,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsxRuntime.jsx("button",{type:"submit",disabled:!T.trim()||b,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:T.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:T.trim()?"white":t.textSecondary},children:jsxRuntime.jsx(g0,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function hc(e,t=50){let[a,r]=react.useState({past:[],present:e,future:[]}),o=react.useRef(false),s=react.useCallback((i,u=true)=>{r(d=>{let g=typeof i=="function"?i(d.present):i;if(o.current)return {...d,present:g};if(!u)return {...d,present:g};let f=[...d.past,d.present];return f.length>t&&f.shift(),{past:f,present:g,future:[]}});},[t]),n=react.useCallback(()=>{r(i=>{if(i.past.length===0)return i;let u=i.past[i.past.length-1],d=i.past.slice(0,i.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:u,future:[i.present,...i.future]}});},[]),m=react.useCallback(()=>{r(i=>{if(i.future.length===0)return i;let u=i.future[0],d=i.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...i.past,i.present],present:u,future:d}});},[]),p=react.useCallback(()=>{r(i=>({past:[],present:i.present,future:[]}));},[]);return {state:a.present,setState:s,undo:n,redo:m,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function bc({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){react.useEffect(()=>{if(!o)return;let s=n=>{let m=navigator.platform.toUpperCase().indexOf("MAC")>=0,p=m?n.metaKey:n.ctrlKey;if(p&&n.key==="z"&&!n.shiftKey&&a){n.preventDefault(),e();return}if(r){if(!m&&p&&n.key==="y"){n.preventDefault(),t();return}if(m&&p&&n.shiftKey&&n.key==="z"){n.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var k0={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${fe.formatDate(e.startDate)} - ${fe.formatDate(e.endDate)}`);let a=fe.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=>fe.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function yc(e){return {...k0,...e}}var E0=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},kc=react.forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:n="week",rowDensity:m="comfortable",showThemeSelector:p=true,showExportButton:i=true,availableUsers:u=[],templates:d,enableAutoCriticalPath:g=true,persistExpandedState:f,aiAssistant:C,locale:T="en",customTranslations:c,showCreateTaskButton:b=false,createTaskLabel:v,onCreateTask:l,taskFilter:k,onTaskFilterChange:y,onThemeChange:D,onTaskClick:w,onTaskDblClick:x,onTaskContextMenu:R,onTaskUpdate:A,onProgressChange:N,onTaskEdit:U,onTaskAddSubtask:$,onTaskMarkIncomplete:_,onTaskSetInProgress:Q,onDependencyCreate:Te,onDependencyDelete:$e,onBeforeTaskAdd:tt,onAfterTaskAdd:Oe,onBeforeTaskUpdate:Re,onAfterTaskUpdate:I,onBeforeTaskDelete:B,onAfterTaskDelete:S}=a,K=react.useContext(yn)?.theme,[z,se]=react.useState(K||s||"dark"),[ye,Pe]=react.useState(n),[pe,He]=react.useState(m),[Ie,Ne]=react.useState(1),[We,gt]=react.useState("all"),st=k??We,O=y??gt,[te,de]=react.useState(0),[he,Me]=react.useState(false),[_e,bt]=react.useState(null),[Se,Lt]=react.useState({isOpen:false,x:0,y:0,task:null}),[At,ct]=react.useState(null),[Je,Ht]=react.useState(null);react.useEffect(()=>{K&&K!==z&&se(K);},[K]),react.useEffect(()=>{s&&s!==z&&se(s);},[s]);let sa=react.useCallback(F=>{se(F),D?.(F);},[D]),{state:ae,setState:re,undo:Vt,redo:ie,canUndo:E,canRedo:q,clearHistory:ue}=hc(t,50),Fe=react.useCallback(()=>f?typeof f=="string"?f:"gantt-expanded-tasks":null,[f]),Ge=react.useRef(new Map),qe=react.useRef(false);if(!qe.current&&f){qe.current=true;let F=typeof f=="string"?f:"gantt-expanded-tasks";try{let L=localStorage.getItem(F);if(L){let j=JSON.parse(L);Array.isArray(j)&&(Ge.current=new Map(j));}}catch(L){console.warn("[GanttBoard] Error loading expanded state from localStorage:",L);}}let ze=react.useCallback(()=>{let F=Fe();if(F)try{let L=Array.from(Ge.current.entries());localStorage.setItem(F,JSON.stringify(L));}catch(L){console.warn("[GanttBoard] Error saving expanded state to localStorage:",L);}},[Fe]);react.useEffect(()=>{let F=L=>L.map(j=>{let oe=Ge.current.get(j.id),ge=oe!==void 0?{...j,isExpanded:oe}:j;return ge.subtasks?.length?{...ge,subtasks:F(ge.subtasks)}:ge});Ge.current.size>0?re(F(t)):re(t);},[t,re]);let nt=react.useRef(t),mt=react.useRef(true);react.useEffect(()=>{if(mt.current){mt.current=false,nt.current=ae;return}if(!r)return;let F=JSON.stringify(nt.current),L=JSON.stringify(ae);F!==L&&(nt.current=ae,r(ae));},[ae,r]);let V=react.useMemo(()=>ei(T,c),[T,c]),ee=react.useCallback(F=>[{id:"name",label:F.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:F.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:F.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:F.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:F.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:F.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:F.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:F.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Ee,Xe]=react.useState(()=>ee(V));react.useEffect(()=>{Xe(F=>F.map(L=>({...L,label:V.columns[L.id==="name"?"taskName":L.id]||L.label})));},[V]);let Ve=react.useMemo(()=>Ee.filter(L=>L.visible).reduce((L,j)=>L+j.width,0),[Ee]),W=react.useRef(Ee.filter(F=>F.visible).map(F=>F.id).join(","));react.useEffect(()=>{let F=Ee.filter(oe=>oe.visible),L=F.map(oe=>oe.id).join(","),j=W.current;if(L!==j){let oe=F.some(Ce=>Ce.id!=="name"),ge=j.includes(",");oe?!ge&&oe&&bt(null):bt(null),W.current=L;}},[Ee]);let le=60,Be=.6,Pt=react.useMemo(()=>{let L=Ve+le,j=typeof window<"u"?window.innerWidth*Be:800,oe=Math.max(L,j);return _e!==null?Math.max(200,Math.min(_e,oe)):Math.max(200,L)},[_e,Ve]),at=react.useRef(null),xa=react.useRef(null),fa=react.useRef(null),P=react.useMemo(()=>Ud(z),[z]),ve=react.useMemo(()=>({theme:P,themeName:z}),[P,z]),J=react.useMemo(()=>yc(d),[d]),Ae=react.useMemo(()=>{if(!g)return ae;let F=fe.calculateCriticalPath(ae),L=j=>j.map(oe=>({...oe,isCriticalPath:F.includes(oe.id),subtasks:oe.subtasks?L(oe.subtasks):void 0}));return L(ae)},[ae,g]),it=react.useMemo(()=>{if(st==="all")return Ae;let F=L=>{let j=[];for(let oe of L){let ge=oe.subtasks?.length?F(oe.subtasks):void 0,Ce=false;switch(st){case "incomplete":Ce=oe.progress<100;break;case "in_progress":Ce=oe.progress>0&&oe.progress<100;break;case "completed":Ce=oe.progress===100;break}(Ce||ge&&ge.length>0)&&j.push({...oe,subtasks:ge});}return j};return F(Ae)},[Ae,st]),ne=E0(pe);bc({undo:Vt,redo:ie,canUndo:E,canRedo:q,enabled:true}),react.useImperativeHandle(o,()=>({getTask:F=>fe.findTaskById(ae,F),addTask:(F,L)=>{re(j=>{if(!L)return [...j,{...F,level:0}];let oe=ge=>ge.map(Ce=>Ce.id===L?{...Ce,subtasks:[...Ce.subtasks||[],{...F,parentId:L,level:(Ce.level||0)+1}],isExpanded:true}:Ce.subtasks?{...Ce,subtasks:oe(Ce.subtasks)}:Ce);return oe(j)});},updateTask:(F,L)=>{re(j=>{let oe=ge=>ge.map(Ce=>Ce.id===F?{...Ce,...L}:Ce.subtasks?{...Ce,subtasks:oe(Ce.subtasks)}:Ce);return oe(j)});},deleteTask:F=>{re(L=>{let j=oe=>oe.filter(ge=>ge.id===F?false:(ge.subtasks&&(ge.subtasks=j(ge.subtasks)),true));return j(L)});},deleteTasks:F=>{re(L=>ci(L,F));},duplicateTask:F=>{re(L=>mi(L,[F]));},splitTask:(F,L,j=3)=>{re(oe=>fe.splitTask(oe,F,L,j));},calculateEndDate:fe.calculateEndDate,calculateDuration:fe.calculateDuration,validateDependency:(F,L)=>!fe.validateDependencies(ae,F,L),getAllTasks:()=>fe.flattenTasks(ae),getTasksByStatus:F=>fe.flattenTasks(ae).filter(L=>L.status===F),getTasksByParent:F=>F?fe.findTaskById(ae,F)?.subtasks||[]:ae.filter(j=>!j.parentId),getCriticalPath:()=>fe.flattenTasks(ae).filter(F=>F.isCriticalPath),indentTask:F=>{re(L=>ii(L,[F]));},outdentTask:F=>{re(L=>li(L,[F]));},moveTask:(F,L)=>{re(j=>di(j,[F],L));},createSubtask:async F=>{let{tasks:L,newTask:j}=gi(ae,F);if(tt){let oe=tt({...j,parentId:F});if((oe instanceof Promise?await oe:oe)===false)return}re(L),Oe&&Oe({...j,parentId:F});},scrollToTask:F=>{let j=fe.flattenTasks(ae).findIndex(oe=>oe.id===F);if(j!==-1&&at.current){let oe=j*ne;at.current.scrollTo({top:oe,behavior:"smooth"}),xa.current&&xa.current.scrollTo({top:oe,behavior:"smooth"});}},highlightTask:(F,L=2e3)=>{},expandTask:F=>{re(L=>{let j=oe=>oe.map(ge=>ge.id===F?{...ge,isExpanded:true}:ge.subtasks?{...ge,subtasks:j(ge.subtasks)}:ge);return j(L)});},collapseTask:F=>{re(L=>{let j=oe=>oe.map(ge=>ge.id===F?{...ge,isExpanded:false}:ge.subtasks?{...ge,subtasks:j(ge.subtasks)}:ge);return j(L)});},expandAll:()=>{re(F=>{let L=j=>j.map(oe=>({...oe,isExpanded:true,subtasks:oe.subtasks?L(oe.subtasks):void 0}));return L(F)});},collapseAll:()=>{re(F=>{let L=j=>j.map(oe=>({...oe,isExpanded:false,subtasks:oe.subtasks?L(oe.subtasks):void 0}));return L(F)});},undo:Vt,redo:ie,canUndo:()=>E,canRedo:()=>q,clearHistory:ue,exportToPNG:async()=>{if(!fa.current||!at.current||!xa.current)throw new Error("Gantt container not found");let F=fa.current,L=at.current.querySelector(".gantt-grid-scroll"),j=xa.current,oe=L?.scrollTop||0,ge=j.scrollTop,Ce=F.style.overflow,kt=F.style.height;try{let ea=L?.querySelector(".gantt-taskgrid-content"),ka=j.querySelector("svg"),wa=ea?.scrollHeight||L?.scrollHeight||600,Aa=ka?.getBoundingClientRect().height||j.scrollHeight,Br=(F.querySelector('[class*="h-12"]')?.offsetHeight||48)+Math.max(wa,Aa)+20;L&&(L.scrollTop=0),j.scrollTop=0,F.style.overflow="visible",F.style.height=`${Br}px`,await new Promise(kr=>setTimeout(kr,100));let xr=await xc__default.default(F,{backgroundColor:P.bgPrimary,scale:2,logging:!1,useCORS:!0,ignoreElements:kr=>{let ro=window.getComputedStyle(kr),Rr=parseInt(ro.zIndex,10);return !isNaN(Rr)&&Rr>=50||ro.position==="fixed"}});return new Promise((kr,ro)=>{xr.toBlob(Rr=>{Rr?kr(Rr):ro(new Error("Failed to create blob from canvas"));},"image/png");})}finally{F.style.overflow=Ce,F.style.height=kt,L&&(L.scrollTop=oe),j.scrollTop=ge;}},exportToPDF:async F=>{await fe.exportToPDF(ae,F);},exportToExcel:async F=>{await fe.exportToExcel(ae,F);},exportToJSON:()=>fe.exportToJSON(ae),exportToCSV:()=>fe.exportToCSV(ae),importFromJSON:F=>{let L=fe.importFromJSON(F);re(L);},getTasks:()=>ae,refresh:()=>{re(F=>[...F]);},clearAll:()=>{re([]);}}),[ae,Vt,ie,E,q,ue,P,ne]);let Ue=react.useCallback(F=>{Xe(L=>L.map(j=>j.id===F?{...j,visible:!j.visible}:j));},[]),Nt=react.useCallback((F,L)=>{Xe(j=>j.map(oe=>{if(oe.id!==F)return oe;let ge=oe.minWidth??100,Ce=oe.maxWidth??800,kt=Math.max(ge,Math.min(Ce,L));return {...oe,width:kt}}));},[]),Le=react.useCallback(F=>{re(L=>{let j=ui(L,F),oe=ge=>{for(let Ce of ge){if(Ce.id===F){Ge.current.set(F,Ce.isExpanded??true);return}Ce.subtasks?.length&&oe(Ce.subtasks);}};return oe(j),ze(),j}),a.onTaskToggleExpand?.(F);},[a,ze]),It=react.useCallback((F,L)=>{if(Re&&Re(F,L)===false)return;let oe=fe.findTaskById(ae,F)?.progress,ge=kt=>kt.map(ea=>ea.id===F?{...ea,...L}:ea.subtasks?{...ea,subtasks:ge(ea.subtasks)}:ea);re(ge(ae));let Ce=fe.findTaskById(ge(ae),F);Ce&&(A?.(Ce),I?.(Ce),L.progress!==void 0&&oe!==void 0&&L.progress!==oe&&N?.(F,oe,L.progress));},[ae,A,Re,I,N]),pt=react.useCallback(F=>{F.length!==0&&(re(L=>ii(L,F)),a.onTaskIndent?.(F[0]));},[a]),ha=react.useCallback(F=>{F.length!==0&&(re(L=>li(L,F)),a.onTaskOutdent?.(F[0]));},[a]),Wt=react.useCallback((F,L,j)=>{re(oe=>oc(oe,F,L,j)),a.onTaskReparent?.(F,L,j);},[a]),Ye=react.useCallback((F,L)=>{F.length!==0&&(re(j=>di(j,F,L)),a.onTaskMove?.(F[0],L));},[a]),Dt=react.useCallback(async F=>{let L=[];for(let j of F)B&&await Promise.resolve(B(j))===false||L.push(j);L.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(L):(re(j=>ci(j,L)),L.forEach(j=>a.onTaskDelete?.(j))),S&&L.forEach(j=>S(j)));},[a,B,S]),ca=react.useCallback(F=>{re(L=>mi(L,F)),F.forEach(L=>a.onTaskDuplicate?.(L));},[a]),yr=react.useCallback((F,L)=>{re(j=>{let{tasks:oe,newTask:ge}=rc(j,F,L);return tt&&tt(ge)===false?j:(a.onTaskCreate?.(ge.parentId,ge.position||0),Oe?.(ge),oe)});},[a,tt,Oe]),Um=react.useCallback((F,L)=>{re(j=>pi(j,F,L)),a.onTaskRename?.(F,L);},[a]),Zn=react.useCallback(F=>{re(L=>{let{tasks:j}=gi(L,F);return a.onTaskCreate?.(F,0),j});},[a]),Hm=react.useCallback((F,L,j)=>{let oe=F.startDate?Math.round((L.getTime()-F.startDate.getTime())/864e5):0,ge=ea=>ea.map(ka=>ka.id===F.id?{...ka,startDate:L,endDate:j,...F.segments&&{segments:F.segments}}:ka.subtasks?{...ka,subtasks:ge(ka.subtasks)}:ka),Ce=ge(ae);Ce=fe.autoScheduleDependents(Ce,F.id,oe),re(Ce);let kt={...F,startDate:L,endDate:j};A?.(kt);},[ae,A]),Wm=react.useCallback((F,L)=>{R?.(F,L),Lt({isOpen:true,x:L.clientX,y:L.clientY,task:F});},[R]),Gm=react.useCallback((F,L)=>{let j=fe.splitTask(ae,F.id,L);re(j),Lt({isOpen:false,x:0,y:0,task:null});},[ae]),hl=react.useCallback(F=>{let L=fe.findTaskById(ae,F.id)||F;x?.(L),U||ct(L);},[ae,x,U]),bl=react.useCallback((F,L,j)=>{let oe=new Map,ge=wa=>{wa.forEach(Aa=>{Aa.dependencies&&oe.set(Aa.id,Aa.dependencies),Aa.subtasks&&ge(Aa.subtasks);});};ge(j);let Ce=oe.get(L)||[];oe.set(L,[...Ce,F]);let kt=new Set,ea=new Set,ka=wa=>{if(!kt.has(wa)){kt.add(wa),ea.add(wa);let Aa=oe.get(wa)||[];for(let vr of Aa){if(!kt.has(vr)&&ka(vr))return true;if(ea.has(vr))return true}}return ea.delete(wa),false};return ka(L)},[]),yl=react.useCallback((F,L)=>{if(bl(F.id,L,ae)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
|
|
342
|
+
</Project>`,u=new Blob([i],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(u),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=fe.flattenTasks(e),a=t.filter(i=>i.startDate&&i.endDate);if(a.length===0)return [];let r=new Map,o=i=>{if(r.has(i.id))return;let u=i.startDate&&i.endDate?fe.calculateDuration(i.startDate,i.endDate):0,d=0;if(i.dependencies&&i.dependencies.length>0)for(let f of i.dependencies){let C=t.find(T=>T.id===f);if(C){o(C);let T=r.get(f)?.ef||0;d=Math.max(d,T);}}let g=d+u;r.set(i.id,{es:d,ef:g});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(i=>i.ef)),n=new Map,m=i=>{if(n.has(i.id))return;let u=i.startDate&&i.endDate?fe.calculateDuration(i.startDate,i.endDate):0,d=t.filter(C=>C.dependencies&&C.dependencies.includes(i.id)),g=s;if(d.length>0)for(let C of d){m(C);let T=n.get(C.id)?.ls||0;g=Math.min(g,T);}let f=g-u;n.set(i.id,{ls:f,lf:g});};a.forEach(m);let p=[];for(let i of a){let u=r.get(i.id),d=n.get(i.id);if(u&&d){let g=d.ls-u.es;Math.abs(g)<.01&&p.push(i.id);}}return p},calculateSlack:(e,t)=>{let a=fe.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(fe.calculateCriticalPath(e).includes(t))return 0;let o=fe.getDependentTasks(e,t);if(o.length===0){let m=fe.getLatestEndDate(e);if(!m)return null;let p=fe.calculateDuration(a.endDate,m);return Math.max(0,p)}let s=o.filter(m=>m.startDate).map(m=>m.startDate.getTime()).sort((m,p)=>m-p)[0];if(!s)return null;let n=fe.calculateDuration(a.endDate,new Date(s));return Math.max(0,n)},isOnCriticalPath:(e,t)=>fe.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=fe.findTaskById(e,t);if(!r||!r.endDate)return e;let o=fe.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let n of o){if(!n.startDate||!n.endDate)continue;let m=fe.calculateDuration(n.startDate,n.endDate),p;a!==void 0?(p=new Date(n.startDate),p.setDate(p.getDate()+a)):(p=new Date(r.endDate),p.setDate(p.getDate()+1));let i=fe.calculateEndDate(p,m),u=d=>d.map(g=>g.id===n.id?{...g,startDate:p,endDate:i}:g.subtasks?{...g,subtasks:u(g.subtasks)}:g);s=u(s),s=fe.autoScheduleDependents(s,n.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,n,m)=>{if(a===0)return [];let p=[],i=o.getTime(),u=1e3*60*60*24,d=fe.findTaskById(e,t);if(!d||!d.endDate)return [];let g=(f,C,T=new Set)=>{if(T.has(f))return;T.add(f);let c=fe.getDependentTasks(e,f);for(let b of c){if(!b.startDate||!b.endDate)continue;let v=r.findIndex(N=>N.id===b.id);if(v===-1)continue;let l=b.startDate.getTime(),y=(b.endDate.getTime()-l)/u,w=(l-i)/u*s,x=w+C*s,R=Math.max(y*s,s),A=m+v*n+12;p.push({taskId:b.id,taskName:b.name,originalX:w,previewX:x,width:R,y:A,rowIndex:v,daysDelta:C,color:b.color}),g(b.id,C,T);}};return g(t,a),p},splitTask:(e,t,a,r=3)=>{let o=fe.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 n=new Date(a);n.setDate(n.getDate()+r);let m=new Date(o.endDate);m.setDate(m.getDate()+r);let p=[{startDate:new Date(o.startDate),endDate:s},{startDate:n,endDate:m}],i=u=>u.map(d=>d.id===o.id?{...d,endDate:m,segments:p}:d.subtasks?{...d,subtasks:i(d.subtasks)}:d);return i(e)}};function Ln({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:n,templates:m,dependencyLineStyle:p="curved",onTaskClick:i,onTaskDblClick:u,onTaskContextMenu:d,onTaskDateChange:g,onDependencyCreate:f,onDependencyDelete:C}){let[c,b]=react.useState([]),[v,l]=react.useState(null),[k,y]=react.useState(null),D=react.useCallback(I=>{l(I);},[]),w=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),x=r==="day"?60:r==="week"?20:8,R=w*x*n,A=I=>{let B=new Date(Date.UTC(I.getFullYear(),I.getMonth(),I.getDate())),S=B.getUTCDay()||7;B.setUTCDate(B.getUTCDate()+4-S);let G=new Date(Date.UTC(B.getUTCFullYear(),0,1));return Math.ceil(((B.getTime()-G.getTime())/864e5+1)/7)},N=I=>{let B=I.getDay();return B===0||B===6},U=react.useCallback(I=>{let B=Math.round(I/(x*n)),S=new Date(o);return S.setDate(S.getDate()+B),S},[o,x,n]),$=react.useCallback((I,B)=>{if(B.startDate&&B.endDate)return;let S=I.currentTarget.ownerSVGElement;if(!S)return;let G=S.createSVGPoint();G.x=I.clientX,G.y=I.clientY;let K=G.matrixTransform(S.getScreenCTM()?.inverse()),z=U(K.x),se=new Date(z);se.setDate(se.getDate()+1),g?.(B,z,se);},[U,g]),_=react.useMemo(()=>{let I=K=>K.map(z=>{if(z.subtasks&&z.subtasks.length>0){let se=I(z.subtasks),ye=se.filter(Pe=>Pe.startDate&&Pe.endDate);if(ye.length>0){let Pe=ye.map(Ne=>Ne.startDate.getTime()),pe=ye.map(Ne=>Ne.endDate.getTime()),He=new Date(Math.min(...Pe)),Ie=new Date(Math.max(...pe));return {...z,subtasks:se,startDate:He,endDate:Ie}}return {...z,subtasks:se}}return z}),B=(K,z=[])=>{for(let se of K)z.push(se),se.subtasks&&se.subtasks.length>0&&(se.isExpanded===void 0||se.isExpanded)&&B(se.subtasks,z);return z},S=I(e);return B(S)},[e]),Q=react.useCallback(I=>{if(!I.startDate||!I.endDate)return {x:0,width:0};let B=I.startDate.getTime(),S=I.endDate.getTime(),G=o.getTime(),K=(B-G)/(1e3*60*60*24),z=(S-B)/(1e3*60*60*24),se=K*x*n,ye=Math.max(x*n,40),Pe=Math.max(z*x*n,ye);return {x:se,width:Pe}},[o,x,n]),Te=react.useMemo(()=>_.filter(I=>I.startDate&&I.endDate).map(I=>{let{x:B,width:S}=Q(I),K=_.findIndex(z=>z.id===I.id)*a+12;return {id:I.id,x:B,y:K,width:S,height:32}}),[_,Q]),$e=react.useCallback((I,B,S)=>{if(!S||B===0){b([]);return}let G=fe.calculateCascadePreview(e,I,B,_,o,x*n,a,48);b(G);},[e,_,o,x,n,a,48]),tt=react.useMemo(()=>{let I=[],B=new Date(o);for(;B<=s;){let K=(B.getTime()-o.getTime())/864e5*x*n;if(r==="day")I.push({date:new Date(B),label:B.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:K}),B.setDate(B.getDate()+1);else if(r==="week"){let z=A(B);I.push({date:new Date(B),label:`Week ${z}`,x:K}),B.setDate(B.getDate()+7);}else I.push({date:new Date(B),label:B.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:K}),B.setMonth(B.getMonth()+1);}return I},[o,s,r,x,n]),Oe=react.useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*x*n,[o,x,n]),Re=Math.max(_.length*a,552);return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary,overflow:"visible"},children:[jsxRuntime.jsx("div",{style:{position:"sticky",top:0,zIndex:10,backgroundColor:t.bgGrid,flexShrink:0,height:"48px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:jsxRuntime.jsxs("svg",{width:Math.max(R,1e3),height:47,style:{display:"block"},children:[jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(R,1e3),height:48,fill:t.bgGrid}),tt.map((I,B)=>jsxRuntime.jsxs("g",{children:[B>0&&jsxRuntime.jsx("line",{x1:I.x,y1:0,x2:I.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsxRuntime.jsx("text",{x:I.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:I.label})]},`header-${B}`)),Oe>=0&&Oe<=R&&jsxRuntime.jsx("circle",{cx:Oe,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(R,1e3),height:Re,style:{display:"block",flexShrink:0,overflow:"visible"},children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsx("filter",{id:"shadow",children:jsxRuntime.jsx("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2",floodOpacity:"0.1"})}),jsxRuntime.jsx("pattern",{id:"diagonal-stripes",width:"8",height:"8",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:jsxRuntime.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"8",stroke:t.border,strokeWidth:"2"})})]}),jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(R,1e3),height:Re,fill:t.bgPrimary}),tt.map((I,B)=>{let S=tt[B+1]?.x||R,G=N(I.date);return jsxRuntime.jsxs("g",{children:[G&&jsxRuntime.jsx("rect",{x:I.x,y:0,width:S-I.x,height:_.length*a,fill:t.bgWeekend,opacity:1}),B>0&&jsxRuntime.jsx("line",{x1:I.x,y1:0,x2:I.x,y2:_.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},B)}),_.map((I,B)=>{let S=I.startDate&&I.endDate;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:0,y:B*a,width:R,height:a,fill:B%2===0?t.bgPrimary:t.bgGrid,opacity:1,style:{pointerEvents:"none"}},`row-${I.id}`),!S&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:0,y:B*a,width:R,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:G=>$(G,I),onMouseEnter:G=>{G.currentTarget.setAttribute("fill",t.accentLight),G.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:G=>{G.currentTarget.setAttribute("fill","transparent"),G.currentTarget.setAttribute("opacity","1");}},`clickable-${I.id}`),jsxRuntime.jsx("text",{x:Oe>0?Oe:100,y:B*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-${I.id}`)]})]},`row-group-${I.id}`)}),_.map((I,B)=>!I.dependencies||I.dependencies.length===0||!I.startDate||!I.endDate?null:I.dependencies.map(S=>{let G=_.find(O=>O.id===S);if(!G||!G.startDate||!G.endDate)return null;let K=_.findIndex(O=>O.id===S),z=Q(G),se=Q(I),ye=z.x+z.width,Pe=K*a+28,pe=se.x,He=B*a+28,Ie=K*a+50,Ne,We=Math.min(K,B),gt=Math.max(K,B);if(We===gt)Ne=pe;else {let O=pe;for(let te=We+1;te<=gt;te++){let de=_[te];if(de&&de.startDate&&de.endDate){let he=Q(de);O=Math.min(O,he.x);}}Ne=O-12,Ne<ye+8&&(Ne=ye+8);}return k&&k.x1===ye&&k.y1===Pe&&k.x2===pe&&k.y2===He?null:jsxRuntime.jsx(Pn,{x1:ye,y1:Pe,x2:pe,y2:He,verticalX:Ne,routeY:Ie,fromIndex:K,toIndex:B,rowHeight:a,theme:t,lineStyle:p},`dep-${S}-${I.id}`)})),_.map((I,B)=>{if(!I.startDate||!I.endDate)return null;let{x:S,width:G}=Q(I),K=B*a+12,z=I.subtasks&&I.subtasks.length>0&&!I.isMilestone;return I.isMilestone?jsxRuntime.jsx(An,{task:I,x:S+G/2,y:K+16,theme:t,onClick:i},I.id):z?jsxRuntime.jsxs("g",{onClick:()=>i?.(I),onContextMenu:se=>{se.preventDefault(),se.stopPropagation(),d?.(I,se);},style:{cursor:"default"},children:[jsxRuntime.jsx("rect",{x:S,y:K,width:G,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:S,y1:K,x2:S+G,y2:K,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:S,y1:K,x2:S,y2:K+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:S+G,y1:K,x2:S+G,y2:K+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:S,y1:K+32,x2:S+G,y2:K+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),G>60&&jsxRuntime.jsx("text",{x:S+12,y:K+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:I.name})]},I.id):jsxRuntime.jsx(Dn,{task:I,x:S,y:K,width:G,theme:t,dayWidth:x*n,startDate:o,templates:m,onClick:i,onDoubleClick:u,onContextMenu:d,onDateChange:g,onDependencyCreate:f,allTaskPositions:Te,onDragMove:$e,onHoverChange:D},I.id)}),_.map((I,B)=>!I.dependencies||I.dependencies.length===0||!I.startDate||!I.endDate?null:I.dependencies.map(S=>{let G=_.find(he=>he.id===S);if(!G||!G.startDate||!G.endDate)return null;let K=_.findIndex(he=>he.id===S),z=Q(G),se=Q(I),ye=z.x+z.width,Pe=K*a+28,pe=se.x,He=B*a+28,Ie=K*a+50,Ne=K===B,We,gt=Math.min(K,B),st=Math.max(K,B);if(gt===st)We=pe;else {let he=pe;for(let Me=gt+1;Me<=st;Me++){let _e=_[Me];if(_e&&_e.startDate&&_e.endDate){let bt=Q(_e);he=Math.min(he,bt.x);}}We=he-12,We<ye+8&&(We=ye+8);}let O;if(Ne){let he=ye+20,Me=pe-15;O=`M ${he} ${Pe} L ${Me} ${He}`;}else O=`M ${We} ${Pe+10} L ${We} ${He-10}`;if(k&&k.x1===ye&&k.y1===Pe&&k.x2===pe&&k.y2===He)return null;let de=he=>{let Me=he.currentTarget.ownerSVGElement;if(!Me)return;let _e=Me.getBoundingClientRect(),bt=he.clientX-_e.left,Se=he.clientY-_e.top;y({x1:ye,y1:Pe,x2:pe,y2:He,verticalX:We,routeY:Ie,fromIndex:K,toIndex:B,onDelete:()=>C?.(I.id,S),lineStyle:p,mouseX:bt,mouseY:Se});};return jsxRuntime.jsx("path",{d:O,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:de,onMouseMove:de},`dep-hover-${S}-${I.id}`)})),c.map(I=>jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("rect",{x:I.previewX,y:I.y-48,width:I.width,height:32,rx:8,fill:I.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(I.daysDelta)>0&&jsxRuntime.jsx("text",{x:I.previewX+I.width/2,y:I.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:I.daysDelta>0?`+${I.daysDelta}d`:`${I.daysDelta}d`})]},`cascade-preview-${I.taskId}`)),k&&(()=>{let{x1:I,y1:B,x2:S,y2:G,verticalX:K,onDelete:z,lineStyle:se,mouseX:ye,mouseY:Pe}=k,pe=S-I,He=I+pe/2,Ie=5,Ne=K??S-12,We=Ie,gt=G-B,st=gt>0,O=Math.abs(gt)<5,te;if(se==="squared")te=`M ${I} ${B} L ${Ne} ${B} L ${Ne} ${G} L ${S} ${G}`;else if(O){let re=Math.min(Math.abs(pe)/3,30);te=`M ${I} ${B} C ${I+re} ${B}, ${S-re} ${G}, ${S} ${G}`;}else st?te=`M ${I} ${B} L ${Ne-We} ${B} Q ${Ne} ${B} ${Ne} ${B+We} L ${Ne} ${G-We} Q ${Ne} ${G} ${Ne+We} ${G} L ${S} ${G}`:te=`M ${I} ${B} L ${Ne-We} ${B} Q ${Ne} ${B} ${Ne} ${B-We} L ${Ne} ${G+We} Q ${Ne} ${G} ${Ne+We} ${G} L ${S} ${G}`;let de=5,he=S-de,Me=G-de*.5,_e=S-de,bt=G+de*.5,Se=t.dependency,Lt="#f87171",At="rgba(248, 113, 113, 0.15)",ct=He,Je=O?(B+G)/2:B,Ht=false;ye!==void 0&&Pe!==void 0&&(ct=Math.max(I+20,Math.min(Ne-10,ye)),Je=O?(B+G)/2:B);let sa=Math.floor(Je/a);if(sa>=0&&sa<_.length){let re=_[sa];if(re&&re.startDate&&re.endDate){let Vt=Q(re),ie=sa*a+12,E=ie+32,q=Vt.x-15,ue=Vt.x+Vt.width+50;ct>=q&&ct<=ue&&Je>=ie-5&&Je<=E+5&&(Ht=true);}}return jsxRuntime.jsxs("g",{onMouseLeave:()=>y(null),onMouseMove:re=>{let Vt=re.currentTarget.ownerSVGElement||re.currentTarget;if(!Vt)return;let ie=Vt.getBoundingClientRect(),E=re.clientX-ie.left,q=re.clientY-ie.top;y(ue=>ue?{...ue,mouseX:E,mouseY:q}:null);},children:[jsxRuntime.jsx("path",{d:te,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsxRuntime.jsx("path",{d:te,fill:"none",stroke:Se,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsxRuntime.jsx("path",{d:te,fill:"none",stroke:Se,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("path",{d:`M ${S} ${G} L ${he} ${Me} M ${S} ${G} L ${_e} ${bt}`,fill:"none",stroke:Se,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("circle",{cx:S,cy:G,r:4,fill:Se,opacity:.9,style:{pointerEvents:"none"}}),!Ht&&jsxRuntime.jsxs(framerMotion.motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:re=>{re.stopPropagation(),y(null),z();},style:{cursor:"pointer"},children:[jsxRuntime.jsx("circle",{cx:ct,cy:Je,r:9,fill:At,stroke:Lt,strokeWidth:1.5}),jsxRuntime.jsx("line",{x1:ct-3,y1:Je-3,x2:ct+3,y2:Je+3,stroke:Lt,strokeWidth:1.5,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:ct+3,y1:Je-3,x2:ct-3,y2:Je+3,stroke:Lt,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),Oe>=0&&Oe<=R&&jsxRuntime.jsx("line",{x1:Oe,y1:0,x2:Oe,y2:Re,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),v&&jsxRuntime.jsx(pc,{tooltipData:v,theme:t})]})]})}var u0=['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"'],fc=()=>jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),g0=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13"})}),f0=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M18 6L6 18M6 6L18 18"})}),h0=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M5 12h14"})}),b0=()=>jsxRuntime.jsx("div",{className:"flex gap-1 items-center",children:[0,1,2].map(e=>jsxRuntime.jsx(framerMotion.motion.div,{className:"w-2 h-2 rounded-full bg-current",animate:{scale:[1,1.2,1],opacity:[.5,1,.5]},transition:{duration:.8,repeat:1/0,delay:e*.15}},e))});function In({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:n,onDependencyCreate:m,onDependencyDelete:p}){let[i,u]=react.useState(false),[d,g]=react.useState(false),[f,C]=react.useState([]),[T,c]=react.useState(""),[b,v]=react.useState(false),[l,k]=react.useState(true),y=react.useRef(null),D=react.useRef(null),w=react.useRef(null),{enabled:x=true,placeholder:R='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:A="bottom-right",onCommand:N,suggestions:U=u0,maxHistory:$=50,persistHistory:_}=a,Q=_?.storageKey||"gantt-ai-history",Te=_?.maxMessages??5;react.useEffect(()=>{if(_?.enabled)try{let B=localStorage.getItem(Q);if(B){let G=JSON.parse(B).map(K=>({...K,timestamp:new Date(K.timestamp)}));C(G.slice(-Te));}}catch(B){console.warn("[GanttAIAssistant] Failed to load persisted history:",B);}},[_?.enabled,Q,Te]),react.useEffect(()=>{if(_?.enabled&&f.length>0)try{let B=f.filter(S=>!S.isLoading).slice(-Te);localStorage.setItem(Q,JSON.stringify(B));}catch(B){console.warn("[GanttAIAssistant] Failed to persist history:",B);}},[f,_?.enabled,Q,Te]),react.useEffect(()=>{D.current&&D.current.scrollIntoView({behavior:"smooth"});},[f]),react.useEffect(()=>{i&&!d&&y.current&&setTimeout(()=>y.current?.focus(),100);},[i,d]);let $e=react.useCallback(B=>{if(B.success)switch(B.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":B.taskId&&B.updates&&o?.(B.taskId,B.updates);break;case "create_task":B.newTask&&s?.(B.newTask);break;case "delete_task":B.taskId&&n?.(B.taskId);break;case "link_tasks":B.dependencyFrom&&B.dependencyTo&&m?.(B.dependencyFrom,B.dependencyTo);break;case "unlink_tasks":B.taskId&&B.dependencyFrom&&p?.(B.taskId,B.dependencyFrom);break}},[o,s,n,m,p]),tt=react.useCallback(async B=>{if(!B.trim()||b)return;let S={id:`user-${Date.now()}`,role:"user",content:B,timestamp:new Date};C(K=>[...K.slice(-($-1)),S]),c(""),k(false),v(true);let G={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};C(K=>[...K,G]);try{if(N){let K=await N(B,e);C(z=>{let se=z.filter(Pe=>!Pe.isLoading),ye={id:`assistant-${Date.now()}`,role:"assistant",content:K.message,timestamp:new Date,command:K};return [...se,ye]}),$e(K);}else C(K=>[...K.filter(se=>!se.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(K){C(z=>[...z.filter(ye=>!ye.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${K instanceof Error?K.message:"Unknown error"}`,timestamp:new Date}]);}finally{v(false);}},[b,$,N,e,$e]),Oe=B=>{B.preventDefault(),tt(T);},Re=B=>{c(B),y.current?.focus();};if(react.useEffect(()=>{let B=S=>{(S.metaKey||S.ctrlKey)&&S.key==="k"&&(S.preventDefault(),u(G=>!G),i||g(false)),S.key==="Escape"&&i&&u(false);};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[i]),react.useEffect(()=>{if(!i)return;let B=G=>{let K=G.target;w.current&&!w.current.contains(K)&&u(false);},S=setTimeout(()=>{document.addEventListener("mousedown",B);},100);return ()=>{clearTimeout(S),document.removeEventListener("mousedown",B);}},[i]),!x)return null;let I={"bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-right":"top-4 right-4","top-left":"top-4 left-4"};return jsxRuntime.jsxs(ft,{children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!i&&jsxRuntime.jsxs(framerMotion.motion.button,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},className:`fixed ${I[A]} z-[99999] flex items-center gap-2 px-4 py-3 rounded-full shadow-lg transition-colors`,style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"white",boxShadow:"0 4px 20px rgba(59, 130, 246, 0.4)"},onClick:()=>u(true),children:[jsxRuntime.jsx(fc,{}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),jsxRuntime.jsx("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono rounded bg-white/20",children:"\u2318K"})]})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:i&&jsxRuntime.jsxs(framerMotion.motion.div,{ref:w,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:d?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${I[A]} z-[99999] w-96 rounded-2xl overflow-hidden shadow-2xl flex flex-col`,style:{background:t.bgPrimary,border:`1px solid ${t.border}`,boxShadow:`0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px ${t.border}`},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-white",children:[jsxRuntime.jsx(fc,{}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{onClick:()=>g(B=>!B),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(h0,{})}),jsxRuntime.jsx("button",{onClick:()=>u(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(f0,{})})]})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!d&&jsxRuntime.jsxs(framerMotion.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"flex flex-col flex-1 min-h-0",children:[jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[f.length===0&&l&&jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("p",{className:"text-sm text-center",style:{color:t.textSecondary},children:"Try asking me to edit your Gantt chart:"}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:U.slice(0,4).map((B,S)=>jsxRuntime.jsx("button",{onClick:()=>Re(B),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:B.length>30?B.slice(0,30)+"...":B},S))})]}),f.map(B=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${B.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${B.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:B.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:B.role==="user"?"white":t.textPrimary},children:[B.isLoading?jsxRuntime.jsx(b0,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:B.content}),B.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:B.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:B.command.success?"#10B981":"#EF4444"},children:[B.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:B.command.type.replace(/_/g," ")})]})]})},B.id)),jsxRuntime.jsx("div",{ref:D})]}),jsxRuntime.jsxs("form",{onSubmit:Oe,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsxRuntime.jsx("input",{ref:y,type:"text",value:T,onChange:B=>c(B.target.value),placeholder:R,disabled:b,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsxRuntime.jsx("button",{type:"submit",disabled:!T.trim()||b,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:T.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:T.trim()?"white":t.textSecondary},children:jsxRuntime.jsx(g0,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function hc(e,t=50){let[a,r]=react.useState({past:[],present:e,future:[]}),o=react.useRef(false),s=react.useCallback((i,u=true)=>{r(d=>{let g=typeof i=="function"?i(d.present):i;if(o.current)return {...d,present:g};if(!u)return {...d,present:g};let f=[...d.past,d.present];return f.length>t&&f.shift(),{past:f,present:g,future:[]}});},[t]),n=react.useCallback(()=>{r(i=>{if(i.past.length===0)return i;let u=i.past[i.past.length-1],d=i.past.slice(0,i.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:u,future:[i.present,...i.future]}});},[]),m=react.useCallback(()=>{r(i=>{if(i.future.length===0)return i;let u=i.future[0],d=i.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...i.past,i.present],present:u,future:d}});},[]),p=react.useCallback(()=>{r(i=>({past:[],present:i.present,future:[]}));},[]);return {state:a.present,setState:s,undo:n,redo:m,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function bc({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){react.useEffect(()=>{if(!o)return;let s=n=>{let m=navigator.platform.toUpperCase().indexOf("MAC")>=0,p=m?n.metaKey:n.ctrlKey;if(p&&n.key==="z"&&!n.shiftKey&&a){n.preventDefault(),e();return}if(r){if(!m&&p&&n.key==="y"){n.preventDefault(),t();return}if(m&&p&&n.shiftKey&&n.key==="z"){n.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var k0={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${fe.formatDate(e.startDate)} - ${fe.formatDate(e.endDate)}`);let a=fe.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=>fe.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function yc(e){return {...k0,...e}}var E0=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},kc=react.forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:n="week",rowDensity:m="comfortable",showThemeSelector:p=true,showExportButton:i=true,availableUsers:u=[],templates:d,enableAutoCriticalPath:g=true,persistExpandedState:f,aiAssistant:C,locale:T="en",customTranslations:c,showCreateTaskButton:b=false,createTaskLabel:v,onCreateTask:l,taskFilter:k,onTaskFilterChange:y,onThemeChange:D,onTaskClick:w,onTaskDblClick:x,onTaskContextMenu:R,onTaskUpdate:A,onProgressChange:N,onTaskEdit:U,onTaskAddSubtask:$,onTaskMarkIncomplete:_,onTaskSetInProgress:Q,onDependencyCreate:Te,onDependencyDelete:$e,onBeforeTaskAdd:tt,onAfterTaskAdd:Oe,onBeforeTaskUpdate:Re,onAfterTaskUpdate:I,onBeforeTaskDelete:B,onAfterTaskDelete:S}=a,K=react.useContext(yn)?.theme,[z,se]=react.useState(K||s||"dark"),[ye,Pe]=react.useState(n),[pe,He]=react.useState(m),[Ie,Ne]=react.useState(1),[We,gt]=react.useState("all"),st=k??We,O=y??gt,[te,de]=react.useState(0),[he,Me]=react.useState(false),[_e,bt]=react.useState(null),[Se,Lt]=react.useState({isOpen:false,x:0,y:0,task:null}),[At,ct]=react.useState(null),[Je,Ht]=react.useState(null);react.useEffect(()=>{K&&K!==z&&se(K);},[K]),react.useEffect(()=>{s&&s!==z&&se(s);},[s]);let sa=react.useCallback(F=>{se(F),D?.(F);},[D]),{state:ae,setState:re,undo:Vt,redo:ie,canUndo:E,canRedo:q,clearHistory:ue}=hc(t,50),Fe=react.useCallback(()=>f?typeof f=="string"?f:"gantt-expanded-tasks":null,[f]),Ge=react.useRef(new Map),qe=react.useRef(false);if(!qe.current&&f){qe.current=true;let F=typeof f=="string"?f:"gantt-expanded-tasks";try{let L=localStorage.getItem(F);if(L){let j=JSON.parse(L);Array.isArray(j)&&(Ge.current=new Map(j));}}catch(L){console.warn("[GanttBoard] Error loading expanded state from localStorage:",L);}}let ze=react.useCallback(()=>{let F=Fe();if(F)try{let L=Array.from(Ge.current.entries());localStorage.setItem(F,JSON.stringify(L));}catch(L){console.warn("[GanttBoard] Error saving expanded state to localStorage:",L);}},[Fe]);react.useEffect(()=>{let F=L=>L.map(j=>{let oe=Ge.current.get(j.id),ge=oe!==void 0?{...j,isExpanded:oe}:j;return ge.subtasks?.length?{...ge,subtasks:F(ge.subtasks)}:ge});Ge.current.size>0?re(F(t)):re(t);},[t,re]);let nt=react.useRef(t),mt=react.useRef(true);react.useEffect(()=>{if(mt.current){mt.current=false,nt.current=ae;return}if(!r)return;let F=JSON.stringify(nt.current),L=JSON.stringify(ae);F!==L&&(nt.current=ae,r(ae));},[ae,r]);let V=react.useMemo(()=>ei(T,c),[T,c]),ee=react.useCallback(F=>[{id:"name",label:F.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:F.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:F.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:F.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:F.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:F.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:F.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:F.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Ee,Xe]=react.useState(()=>ee(V));react.useEffect(()=>{Xe(F=>F.map(L=>({...L,label:V.columns[L.id==="name"?"taskName":L.id]||L.label})));},[V]);let Ve=react.useMemo(()=>Ee.filter(L=>L.visible).reduce((L,j)=>L+j.width,0),[Ee]),W=react.useRef(Ee.filter(F=>F.visible).map(F=>F.id).join(","));react.useEffect(()=>{let F=Ee.filter(oe=>oe.visible),L=F.map(oe=>oe.id).join(","),j=W.current;if(L!==j){let oe=F.some(Ce=>Ce.id!=="name"),ge=j.includes(",");oe?!ge&&oe&&bt(null):bt(null),W.current=L;}},[Ee]);let le=60,Be=.6,Pt=react.useMemo(()=>{let L=Ve+le,j=typeof window<"u"?window.innerWidth*Be:800,oe=Math.max(L,j);return _e!==null?Math.max(200,Math.min(_e,oe)):Math.max(200,L)},[_e,Ve]),at=react.useRef(null),xa=react.useRef(null),fa=react.useRef(null),P=react.useMemo(()=>Ud(z),[z]),ve=react.useMemo(()=>({theme:P,themeName:z}),[P,z]),J=react.useMemo(()=>yc(d),[d]),Ae=react.useMemo(()=>{if(!g)return ae;let F=fe.calculateCriticalPath(ae),L=j=>j.map(oe=>({...oe,isCriticalPath:F.includes(oe.id),subtasks:oe.subtasks?L(oe.subtasks):void 0}));return L(ae)},[ae,g]),it=react.useMemo(()=>{if(st==="all")return Ae;let F=L=>{let j=[];for(let oe of L){let ge=oe.subtasks?.length?F(oe.subtasks):void 0,Ce=false;switch(st){case "incomplete":Ce=oe.progress<100;break;case "in_progress":Ce=oe.progress>0&&oe.progress<100;break;case "completed":Ce=oe.progress===100;break}(Ce||ge&&ge.length>0)&&j.push({...oe,subtasks:ge});}return j};return F(Ae)},[Ae,st]),ne=E0(pe);bc({undo:Vt,redo:ie,canUndo:E,canRedo:q,enabled:true}),react.useImperativeHandle(o,()=>({getTask:F=>fe.findTaskById(ae,F),addTask:(F,L)=>{re(j=>{if(!L)return [...j,{...F,level:0}];let oe=ge=>ge.map(Ce=>Ce.id===L?{...Ce,subtasks:[...Ce.subtasks||[],{...F,parentId:L,level:(Ce.level||0)+1}],isExpanded:true}:Ce.subtasks?{...Ce,subtasks:oe(Ce.subtasks)}:Ce);return oe(j)});},updateTask:(F,L)=>{re(j=>{let oe=ge=>ge.map(Ce=>Ce.id===F?{...Ce,...L}:Ce.subtasks?{...Ce,subtasks:oe(Ce.subtasks)}:Ce);return oe(j)});},deleteTask:F=>{re(L=>{let j=oe=>oe.filter(ge=>ge.id===F?false:(ge.subtasks&&(ge.subtasks=j(ge.subtasks)),true));return j(L)});},deleteTasks:F=>{re(L=>ci(L,F));},duplicateTask:F=>{re(L=>mi(L,[F]));},splitTask:(F,L,j=3)=>{re(oe=>fe.splitTask(oe,F,L,j));},calculateEndDate:fe.calculateEndDate,calculateDuration:fe.calculateDuration,validateDependency:(F,L)=>!fe.validateDependencies(ae,F,L),getAllTasks:()=>fe.flattenTasks(ae),getTasksByStatus:F=>fe.flattenTasks(ae).filter(L=>L.status===F),getTasksByParent:F=>F?fe.findTaskById(ae,F)?.subtasks||[]:ae.filter(j=>!j.parentId),getCriticalPath:()=>fe.flattenTasks(ae).filter(F=>F.isCriticalPath),indentTask:F=>{re(L=>ii(L,[F]));},outdentTask:F=>{re(L=>li(L,[F]));},moveTask:(F,L)=>{re(j=>di(j,[F],L));},createSubtask:async F=>{let{tasks:L,newTask:j}=gi(ae,F);if(tt){let oe=tt({...j,parentId:F});if((oe instanceof Promise?await oe:oe)===false)return}re(L),Oe&&Oe({...j,parentId:F});},scrollToTask:F=>{let j=fe.flattenTasks(ae).findIndex(oe=>oe.id===F);if(j!==-1&&at.current){let oe=j*ne;at.current.scrollTo({top:oe,behavior:"smooth"}),xa.current&&xa.current.scrollTo({top:oe,behavior:"smooth"});}},highlightTask:(F,L=2e3)=>{},expandTask:F=>{re(L=>{let j=oe=>oe.map(ge=>ge.id===F?{...ge,isExpanded:true}:ge.subtasks?{...ge,subtasks:j(ge.subtasks)}:ge);return j(L)});},collapseTask:F=>{re(L=>{let j=oe=>oe.map(ge=>ge.id===F?{...ge,isExpanded:false}:ge.subtasks?{...ge,subtasks:j(ge.subtasks)}:ge);return j(L)});},expandAll:()=>{re(F=>{let L=j=>j.map(oe=>({...oe,isExpanded:true,subtasks:oe.subtasks?L(oe.subtasks):void 0}));return L(F)});},collapseAll:()=>{re(F=>{let L=j=>j.map(oe=>({...oe,isExpanded:false,subtasks:oe.subtasks?L(oe.subtasks):void 0}));return L(F)});},undo:Vt,redo:ie,canUndo:()=>E,canRedo:()=>q,clearHistory:ue,exportToPNG:async()=>{if(!fa.current||!at.current||!xa.current)throw new Error("Gantt container not found");let F=fa.current,L=at.current.querySelector(".gantt-grid-scroll"),j=xa.current,oe=L?.scrollTop||0,ge=j.scrollTop,Ce=F.style.overflow,kt=F.style.height;try{let ea=L?.querySelector(".gantt-taskgrid-content"),ka=j.querySelector("svg"),wa=ea?.scrollHeight||L?.scrollHeight||600,Aa=ka?.getBoundingClientRect().height||j.scrollHeight,Br=(F.querySelector('[class*="h-12"]')?.offsetHeight||48)+Math.max(wa,Aa)+20;L&&(L.scrollTop=0),j.scrollTop=0,F.style.overflow="visible",F.style.height=`${Br}px`,await new Promise(kr=>setTimeout(kr,100));let xr=await xc__default.default(F,{backgroundColor:P.bgPrimary,scale:2,logging:!1,useCORS:!0,ignoreElements:kr=>{let ro=window.getComputedStyle(kr),Rr=parseInt(ro.zIndex,10);return !isNaN(Rr)&&Rr>=50||ro.position==="fixed"}});return new Promise((kr,ro)=>{xr.toBlob(Rr=>{Rr?kr(Rr):ro(new Error("Failed to create blob from canvas"));},"image/png");})}finally{F.style.overflow=Ce,F.style.height=kt,L&&(L.scrollTop=oe),j.scrollTop=ge;}},exportToPDF:async F=>{await fe.exportToPDF(ae,F);},exportToExcel:async F=>{await fe.exportToExcel(ae,F);},exportToJSON:()=>fe.exportToJSON(ae),exportToCSV:()=>fe.exportToCSV(ae),importFromJSON:F=>{let L=fe.importFromJSON(F);re(L);},getTasks:()=>ae,refresh:()=>{re(F=>[...F]);},clearAll:()=>{re([]);}}),[ae,Vt,ie,E,q,ue,P,ne]);let Ue=react.useCallback(F=>{Xe(L=>L.map(j=>j.id===F?{...j,visible:!j.visible}:j));},[]),Nt=react.useCallback((F,L)=>{Xe(j=>j.map(oe=>{if(oe.id!==F)return oe;let ge=oe.minWidth??100,Ce=oe.maxWidth??800,kt=Math.max(ge,Math.min(Ce,L));return {...oe,width:kt}}));},[]),Le=react.useCallback(F=>{re(L=>{let j=ui(L,F),oe=ge=>{for(let Ce of ge){if(Ce.id===F){Ge.current.set(F,Ce.isExpanded??true);return}Ce.subtasks?.length&&oe(Ce.subtasks);}};return oe(j),ze(),j}),a.onTaskToggleExpand?.(F);},[a,ze]),It=react.useCallback((F,L)=>{if(Re&&Re(F,L)===false)return;let oe=fe.findTaskById(ae,F)?.progress,ge=kt=>kt.map(ea=>ea.id===F?{...ea,...L}:ea.subtasks?{...ea,subtasks:ge(ea.subtasks)}:ea);re(ge(ae));let Ce=fe.findTaskById(ge(ae),F);Ce&&(A?.(Ce),I?.(Ce),L.progress!==void 0&&oe!==void 0&&L.progress!==oe&&N?.(F,oe,L.progress));},[ae,A,Re,I,N]),pt=react.useCallback(F=>{F.length!==0&&(re(L=>ii(L,F)),a.onTaskIndent?.(F[0]));},[a]),ha=react.useCallback(F=>{F.length!==0&&(re(L=>li(L,F)),a.onTaskOutdent?.(F[0]));},[a]),Wt=react.useCallback((F,L,j)=>{re(oe=>oc(oe,F,L,j)),a.onTaskReparent?.(F,L,j);},[a]),Ye=react.useCallback((F,L)=>{F.length!==0&&(re(j=>di(j,F,L)),a.onTaskMove?.(F[0],L));},[a]),Dt=react.useCallback(async F=>{let L=[];for(let j of F)B&&await Promise.resolve(B(j))===false||L.push(j);L.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(L):(re(j=>ci(j,L)),L.forEach(j=>a.onTaskDelete?.(j))),S&&L.forEach(j=>S(j)));},[a,B,S]),ca=react.useCallback(F=>{re(L=>mi(L,F)),F.forEach(L=>a.onTaskDuplicate?.(L));},[a]),yr=react.useCallback((F,L)=>{re(j=>{let{tasks:oe,newTask:ge}=rc(j,F,L);return tt&&tt(ge)===false?j:(a.onTaskCreate?.(ge.parentId,ge.position||0),Oe?.(ge),oe)});},[a,tt,Oe]),Um=react.useCallback((F,L)=>{re(j=>pi(j,F,L)),a.onTaskRename?.(F,L);},[a]),Zn=react.useCallback(F=>{re(L=>{let{tasks:j}=gi(L,F);return a.onTaskCreate?.(F,0),j});},[a]),Hm=react.useCallback((F,L,j)=>{let oe=F.startDate?Math.round((L.getTime()-F.startDate.getTime())/864e5):0,ge=ea=>ea.map(ka=>ka.id===F.id?{...ka,startDate:L,endDate:j,...F.segments&&{segments:F.segments}}:ka.subtasks?{...ka,subtasks:ge(ka.subtasks)}:ka),Ce=ge(ae);Ce=fe.autoScheduleDependents(Ce,F.id,oe),re(Ce);let kt={...F,startDate:L,endDate:j};A?.(kt);},[ae,A]),Wm=react.useCallback((F,L)=>{R?.(F,L),Lt({isOpen:true,x:L.clientX,y:L.clientY,task:F});},[R]),Gm=react.useCallback((F,L)=>{let j=fe.splitTask(ae,F.id,L);re(j),Lt({isOpen:false,x:0,y:0,task:null});},[ae]),hl=react.useCallback(F=>{let L=fe.findTaskById(ae,F.id)||F;x?.(L),U||ct(L);},[ae,x,U]),bl=react.useCallback((F,L,j)=>{let oe=new Map,ge=wa=>{wa.forEach(Aa=>{Aa.dependencies&&oe.set(Aa.id,Aa.dependencies),Aa.subtasks&&ge(Aa.subtasks);});};ge(j);let Ce=oe.get(L)||[];oe.set(L,[...Ce,F]);let kt=new Set,ea=new Set,ka=wa=>{if(!kt.has(wa)){kt.add(wa),ea.add(wa);let Aa=oe.get(wa)||[];for(let vr of Aa){if(!kt.has(vr)&&ka(vr))return true;if(ea.has(vr))return true}}return ea.delete(wa),false};return ka(L)},[]),yl=react.useCallback((F,L)=>{if(bl(F.id,L,ae)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
|
|
343
343
|
|
|
344
344
|
Task dependencies must flow in one direction only.`);return}let j=oe=>oe.map(ge=>{if(ge.id===L){let Ce=ge.dependencies||[];if(!Ce.includes(F.id))return {...ge,dependencies:[...Ce,F.id]}}return ge.subtasks?{...ge,subtasks:j(ge.subtasks)}:ge});re(j(ae)),Te?.(F.id,L);},[ae,Te,bl]),vl=react.useCallback((F,L)=>{let j=oe=>oe.map(ge=>{if(ge.id===F&&ge.dependencies){let Ce=ge.dependencies.filter(kt=>kt!==L);return {...ge,dependencies:Ce}}return ge.subtasks?{...ge,subtasks:j(ge.subtasks)}:ge});re(j(ae)),$e?.(F,L);},[ae,$e]),{startDate:_m,endDate:Vm}=react.useMemo(()=>{let F=ae.filter(Ce=>Ce.startDate&&Ce.endDate);if(F.length===0){let Ce=new Date,kt=new Date(Ce);kt.setDate(kt.getDate()-30);let ea=new Date(Ce);return ea.setDate(ea.getDate()+60),{startDate:kt,endDate:ea}}let L=F.flatMap(Ce=>[Ce.startDate,Ce.endDate]).filter(Ce=>Ce!==void 0),j=new Date(Math.min(...L.map(Ce=>Ce.getTime()))),oe=new Date(Math.max(...L.map(Ce=>Ce.getTime()))),ge=ye==="day"?7:ye==="week"?14:30;return j.setDate(j.getDate()-ge),oe.setDate(oe.getDate()+ge),{startDate:j,endDate:oe}},[ae,ye]),jm=react.useCallback(async()=>{if(!fa.current||!at.current||!xa.current)return;await new Promise(Br=>setTimeout(Br,200));let F=fa.current,L=at.current.querySelector(".gantt-grid-scroll"),j=xa.current,oe=L?.scrollTop||0,ge=L?.scrollLeft||0,Ce=j.scrollTop,kt=j.scrollLeft,ea=F.style.overflow,ka=F.style.height,wa=L?.style.overflow||"",Aa=j.style.overflow,vr=F.style.width,Jo=j.style.width;try{let Br=L?.querySelector(".gantt-taskgrid-content"),xr=j.querySelector("svg"),kr=xr?.getAttribute("height")?parseInt(xr.getAttribute("height"),10):xr?.getBoundingClientRect().height||0,ro=Br?.scrollHeight||L?.scrollHeight||600,Rr=Math.max(kr,j.scrollHeight),xl=xr?.getAttribute("width")?parseInt(xr.getAttribute("width"),10):xr?.getBoundingClientRect().width||j.scrollWidth,Qm=F.querySelector('[class*="h-12"]')?.offsetHeight||48,Qn=Math.max(ro,Rr,kr),es=Qm+Qn+50,ts=(L?.offsetWidth||300)+xl+10;L&&(L.scrollTop=0,L.scrollLeft=0),j.scrollTop=0,j.scrollLeft=0,F.style.overflow="visible",F.style.height=`${es}px`,F.style.width=`${ts}px`,L&&(L.style.overflow="visible",L.style.height=`${Qn+50}px`),j.style.overflow="visible",j.style.height=`${Qn+50}px`,j.style.width=`${xl+10}px`,await new Promise(rs=>setTimeout(rs,150));let ep=await xc__default.default(F,{backgroundColor:P.bgPrimary,scale:2,logging:!1,useCORS:!0,allowTaint:!0,width:ts,height:es,windowWidth:ts+100,windowHeight:es+100,scrollX:0,scrollY:0,ignoreElements:rs=>{let kl=window.getComputedStyle(rs),wl=parseInt(kl.zIndex,10);return !isNaN(wl)&&wl>=50||kl.position==="fixed"}}),as=document.createElement("a");as.download=`gantt-chart-${new Date().toISOString().slice(0,10)}.png`,as.href=ep.toDataURL("image/png"),as.click();}finally{F.style.overflow=ea,F.style.height=ka,F.style.width=vr,L&&(L.style.overflow=wa,L.style.height="",L.scrollTop=oe,L.scrollLeft=ge),j.style.overflow=Aa,j.style.height="",j.style.width=Jo,j.scrollTop=Ce,j.scrollLeft=kt;}},[P]),Km=react.useCallback(async()=>{await fe.exportToPDF(ae);},[ae]),Ym=react.useCallback(async()=>{await fe.exportToExcel(ae);},[ae]),qm=react.useCallback(()=>{let F=fe.exportToCSV(ae),L=new Blob([F],{type:"text/csv;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(L),j.download="gantt-chart.csv",j.click(),URL.revokeObjectURL(j.href);},[ae]),Xm=react.useCallback(()=>{let F=fe.exportToJSON(ae),L=new Blob([F],{type:"application/json;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(L),j.download="gantt-chart.json",j.click(),URL.revokeObjectURL(j.href);},[ae]),Jm=react.useCallback(()=>{fe.exportToMSProject(ae,"Gantt Project","project.xml");},[ae]),Zm=F=>{F.preventDefault(),Me(true);},ao=react.useRef(false);return react.useEffect(()=>{let F=xa.current,L=at.current?.querySelector(".gantt-grid-scroll");if(!F||!L)return;let j=()=>{if(ao.current)return;ao.current=true;let kt=F.scrollTop;de(kt),L.scrollTop=kt,requestAnimationFrame(()=>{ao.current=false;});},oe=()=>{if(ao.current)return;ao.current=true;let kt=L.scrollTop;de(kt),F.scrollTop=kt,requestAnimationFrame(()=>{ao.current=false;});},ge=kt=>{if(he&&L){let ka=L.parentElement?.getBoundingClientRect()?.left||0,wa=kt.clientX-ka,Aa=200,vr=Ve+le,Jo=window.innerWidth*Be,Br=Math.max(vr,Jo);wa>=Aa&&wa<=Br&&bt(wa);}},Ce=()=>{Me(false);};return F.addEventListener("scroll",j),L.addEventListener("scroll",oe),document.addEventListener("mousemove",ge),document.addEventListener("mouseup",Ce),()=>{F.removeEventListener("scroll",j),L.removeEventListener("scroll",oe),document.removeEventListener("mousemove",ge),document.removeEventListener("mouseup",Ce);}},[he,Ve]),jsxRuntime.jsx(ho.Provider,{value:V,children:jsxRuntime.jsx(ls.Provider,{value:ve,children:jsxRuntime.jsxs("div",{ref:fa,className:"flex flex-col h-full w-full",style:{backgroundColor:P.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsxRuntime.jsx(kn,{theme:P,timeScale:ye,onTimeScaleChange:Pe,zoom:Ie,onZoomChange:Ne,currentTheme:z,onThemeChange:sa,rowDensity:pe,onRowDensityChange:He,showThemeSelector:p,showCreateTaskButton:b,createTaskLabel:v,onCreateTask:l,taskFilter:st,onTaskFilterChange:O,onExportPNG:i?jm:void 0,onExportPDF:i?Km:void 0,onExportExcel:i?Ym:void 0,onExportCSV:i?qm:void 0,onExportJSON:i?Xm:void 0,onExportMSProject:i?Jm:void 0}),jsxRuntime.jsxs("div",{ref:at,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsxRuntime.jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:Pt,overflowX:"auto",overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:jsxRuntime.jsx(Nn,{tasks:it,theme:P,rowHeight:ne,availableUsers:u,templates:J,onTaskClick:w,onTaskDblClick:hl,onTaskContextMenu:R,onTaskToggle:Le,scrollTop:te,columns:Ee,onToggleColumn:Ue,onColumnResize:Nt,onTaskUpdate:It,onTaskIndent:pt,onTaskOutdent:ha,onTaskMove:Ye,onMultiTaskDelete:Dt,onTaskDuplicate:ca,onTaskCreate:yr,onTaskRename:Um,onCreateSubtask:Zn,onOpenTaskModal:w?F=>w(F):void 0,onDeleteRequest:(F,L)=>Ht({taskId:F,taskName:L}),onTaskReparent:Wt})}),jsxRuntime.jsx("div",{className:"flex-shrink-0 cursor-col-resize hover:bg-blue-500/50 transition-colors h-full",style:{width:1,backgroundColor:P.border,zIndex:15},onMouseDown:Zm}),jsxRuntime.jsx("div",{ref:xa,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsxRuntime.jsx(Ln,{tasks:it,theme:P,rowHeight:ne,timeScale:ye,startDate:_m,endDate:Vm,zoom:Ie,templates:J,dependencyLineStyle:a?.dependencyLineStyle,onTaskClick:w,onTaskDblClick:hl,onTaskContextMenu:Wm,onTaskDateChange:Hm,onDependencyCreate:yl,onDependencyDelete:vl})})]}),Se.task&&jsxRuntime.jsx(yo,{isOpen:Se.isOpen,x:Se.x,y:Se.y,theme:P,onClose:()=>Lt({isOpen:false,x:0,y:0,task:null}),items:(()=>{let F=Se.task;if(!F)return [];let L=fe.findTaskById(ae,F.id)||F;return L.subtasks&&L.subtasks.length>0?[{id:"addSubtask",label:V.contextMenu?.addSubtask||"Add Subtask",icon:zt.Add,onClick:()=>{$?$(L):Zn(L.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:V.contextMenu?.deleteTask||"Delete Task",icon:zt.Delete,onClick:()=>{Ht({taskId:L.id,taskName:L.name});}}]:[{id:"edit",label:V.contextMenu?.editTask||"Edit Task",icon:zt.Pencil,onClick:()=>{U?U(L):ct(L);}},{id:"addSubtask",label:V.contextMenu?.addSubtask||"Add Subtask",icon:zt.Add,onClick:()=>{$?$(L):Zn(L.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:V.contextMenu?.markIncomplete||"Mark Incomplete",icon:zt.MarkIncomplete,onClick:()=>{_?_(L):It(L.id,{status:"todo",progress:0});},disabled:L.status==="todo"},{id:"setInProgress",label:V.contextMenu?.setInProgress||"Set In Progress",icon:zt.SetInProgress,onClick:()=>{Q?Q(L):It(L.id,{status:"in-progress"});},disabled:L.status==="in-progress"},{id:"markComplete",label:V.contextMenu?.markComplete||"Mark Complete",icon:zt.MarkComplete,onClick:()=>{It(L.id,{status:"completed",progress:100});},disabled:L.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:V.contextMenu?.splitTask||"Split Task",icon:zt.Split,onClick:()=>{if(!L.startDate||!L.endDate){console.warn("Cannot split task without dates");return}let oe=L.startDate.getTime(),ge=L.endDate.getTime(),Ce=oe+(ge-oe)/2,kt=new Date(Ce);Gm(L,kt);},disabled:!L.startDate||!L.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:V.contextMenu?.deleteTask||"Delete Task",icon:zt.Delete,onClick:()=>{Ht({taskId:L.id,taskName:L.name});}}]})()}),jsxRuntime.jsx(Gr,{task:At,isOpen:!!At,onClose:()=>ct(null),onTaskUpdate:F=>{At&&(It(At.id,F),ct(null));},theme:z==="light"?"light":"dark",locale:T==="es"?"es":"en",availableUsers:u,availableTasks:t}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:Je&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[10000] flex items-center justify-center p-4",style:{backgroundColor:"rgba(0, 0, 0, 0.6)"},onClick:()=>Ht(null),children:jsxRuntime.jsxs(framerMotion.motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.2,ease:"easeOut"},onClick:F=>F.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:P.bgSecondary,border:`1px solid ${P.border}`},children:[jsxRuntime.jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${P.border}`},children:jsxRuntime.jsxs("div",{className:"flex items-start gap-3",children:[jsxRuntime.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"rgba(239, 68, 68, 0.2)"},children:jsxRuntime.jsx(lucideReact.AlertTriangle,{className:"w-5 h-5",style:{color:"#EF4444"}})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("h3",{className:"text-lg font-semibold",style:{color:P.textPrimary,fontFamily:"Inter, sans-serif"},children:[V.contextMenu?.deleteTask||"Delete Task","?"]}),jsxRuntime.jsx("p",{className:"text-sm mt-1",style:{color:P.textSecondary,fontFamily:"Inter, sans-serif"},children:T==="es"?"Esta acci\xF3n no se puede deshacer":"This action cannot be undone"})]})]})}),jsxRuntime.jsx("div",{className:"px-6 py-4",children:jsxRuntime.jsxs("p",{className:"text-sm leading-relaxed",style:{color:P.textSecondary,fontFamily:"Inter, sans-serif"},children:[T==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxRuntime.jsxs("span",{className:"font-semibold",style:{color:P.textPrimary},children:['"',Je.taskName,'"']}),"."]})}),jsxRuntime.jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:P.bgPrimary,borderTop:`1px solid ${P.border}`},children:[jsxRuntime.jsx("button",{onClick:()=>Ht(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:P.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:F=>{F.currentTarget.style.backgroundColor=P.hoverBg;},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="transparent";},children:T==="es"?"Cancelar":"Cancel"}),jsxRuntime.jsxs("button",{onClick:()=>{Dt([Je.taskId]),Ht(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:F=>{F.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="#EF4444";},children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"}),T==="es"?"Eliminar":"Delete"]})]})]})})}),C?.enabled&&jsxRuntime.jsx(In,{tasks:ae,theme:P,config:C,onTasksUpdate:re,onTaskUpdate:It,onTaskCreate:F=>{re(L=>[...L,F]);},onTaskDelete:F=>{Dt([F]);},onDependencyCreate:(F,L)=>{let j=fe.findTaskById(ae,F);j&&yl(j,L);},onDependencyDelete:vl})]})})})});var ki=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],wi=[{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 Tc({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:n=false,mode:m=a?"edit":"create",theme:p="dark",customStatuses:i=[],availableTags:u=[],onCreateTag:d,attachments:g=[],onUploadAttachments:f,onDeleteAttachment:C}){let T=[...ki,...i.filter(O=>!ki.some(te=>te.id===O.id))],c=Ze[p]||Ze.dark,[b,v]=react.useState(false),[l,k]=react.useState(false),[y,D]=react.useState(false),[w,x]=react.useState(false),[R,A]=react.useState({top:0,left:0}),[N,U]=react.useState(null),[$,_]=react.useState(new Date),[Q,Te]=react.useState({top:0,left:0}),[$e,tt]=react.useState(false),[Oe,Re]=react.useState([]),I=react.useRef(null),B=react.useRef(null),S=react.useRef(null),G=react.useRef(null),K=react.useRef(null),[z,se]=react.useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[ye,Pe]=react.useState({});react.useEffect(()=>{a?(se({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||[],tags:a.tags||[]}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&tt(true)):(se({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),tt(false),Re([]));},[a,e]),react.useEffect(()=>{let O=te=>{I.current&&!I.current.contains(te.target)&&v(false),B.current&&!B.current.contains(te.target)&&k(false),S.current&&!S.current.contains(te.target)&&D(false),G.current&&!G.current.contains(te.target)&&x(false);};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]);let pe=()=>{let O={};return z.name.trim()||(O.name="El nombre es requerido"),z.startDate&&z.endDate&&z.startDate>z.endDate&&(O.endDate="La fecha de fin debe ser posterior a la de inicio"),Pe(O),Object.keys(O).length===0},He=async O=>{if(O.preventDefault(),!!pe())try{let te=m==="create"&&Oe.length>0?{...z,pendingFiles:Oe}:z;await s(te),Re([]),t();}catch(te){console.error("Error submitting task:",te);}},Ie=(O,te)=>{se(de=>{let he={...de,[O]:te};if(O==="status"){let Me=te;Me==="todo"?he.progress=0:Me==="in-progress"?(de.progress===0||de.progress===100)&&(he.progress=50):Me==="completed"||Me==="closed"?he.progress=100:(Me==="in-review"||Me==="review")&&(he.progress=75);}if(O==="progress"){let Me=typeof te=="number"?te:parseInt(te,10);Me===100&&de.status!=="completed"?he.status="completed":Me>0&&Me<100&&de.status==="todo"?he.status="in-progress":Me===0&&de.status!=="todo"&&(he.status="todo");}return he}),ye[O]&&Pe(de=>{let he={...de};return delete he[O],he});},Ne=T.find(O=>O.id===z.status)??ki[0],We=wi.find(O=>O.id===z.priority)??wi[1],gt=sr.find(O=>O.value===z.color)??sr[0],st={backgroundColor:c.bgSecondary,border:`1px solid ${c.borderLight}`,color:c.textPrimary};return jsxRuntime.jsx(framerMotion.AnimatePresence,{children:e&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 z-50",onClick:t}),jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:jsxRuntime.jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl pointer-events-auto overflow-hidden","data-theme":p,style:{backgroundColor:c.bgPrimary,border:`1px solid ${c.border}`},onClick:O=>O.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${c.border}`},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Ne.color||c.accent}}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:c.textSecondary},children:m==="create"?"Nueva tarea":"Editar tarea"})]}),jsxRuntime.jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:c.textTertiary},onMouseEnter:O=>{O.currentTarget.style.backgroundColor=c.hoverBg,O.currentTarget.style.color=c.textPrimary;},onMouseLeave:O=>{O.currentTarget.style.backgroundColor="transparent",O.currentTarget.style.color=c.textTertiary;},disabled:n,children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:He,className:"max-h-[calc(100vh-200px)] overflow-y-auto",children:[jsxRuntime.jsxs("div",{className:"p-5 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("input",{type:"text",value:z.name,onChange:O=>Ie("name",O.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:c.textPrimary},placeholder:"Nombre de la tarea",disabled:n,autoFocus:true}),ye.name&&jsxRuntime.jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"w-3 h-3"}),ye.name]})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("textarea",{value:z.description||"",onChange:O=>Ie("description",O.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:c.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:n})}),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${c.borderLight}`}}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxRuntime.jsxs("div",{ref:I,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!n&&v(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...st,borderColor:Ne.color,backgroundColor:`${Ne.color}15`},disabled:n,children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:Ne.color}}),jsxRuntime.jsx("span",{style:{color:Ne.color},children:Ne.title}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:Ne.color}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:b&&jsxRuntime.jsx(framerMotion.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:c.bgPrimary,border:`1px solid ${c.border}`},children:T.map(O=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:c.textPrimary},onMouseEnter:te=>te.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:te=>te.currentTarget.style.backgroundColor="transparent",onClick:()=>{Ie("status",O.id),v(false);},children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:O.color}}),O.title,z.status===O.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:c.accent}})]},O.id))})})]}),jsxRuntime.jsxs("div",{ref:B,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!n&&k(!l),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:st,disabled:n,children:[jsxRuntime.jsx(lucideReact.Flag,{className:"w-3.5 h-3.5",style:{color:We.color}}),jsxRuntime.jsx("span",{children:We.label}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:c.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:l&&jsxRuntime.jsx(framerMotion.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:c.bgPrimary,border:`1px solid ${c.border}`},children:wi.map(O=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:c.textPrimary},onMouseEnter:te=>te.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:te=>te.currentTarget.style.backgroundColor="transparent",onClick:()=>{Ie("priority",O.id),k(false);},children:[jsxRuntime.jsx("span",{children:O.icon}),O.label,z.priority===O.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:c.accent}})]},O.id))})})]}),o.length>0&&jsxRuntime.jsxs("div",{ref:S,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!n&&D(!y),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:st,disabled:n,children:[z.assignees&&z.assignees.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex -space-x-1",children:z.assignees.slice(0,3).map((O,te)=>jsxRuntime.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] text-white font-medium border-2",style:{backgroundColor:O.color||c.accent,borderColor:c.bgSecondary},children:O.initials},te))}),z.assignees.length>3&&jsxRuntime.jsxs("span",{style:{color:c.textTertiary},children:["+",z.assignees.length-3]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Users,{className:"w-3.5 h-3.5",style:{color:c.textTertiary}}),jsxRuntime.jsx("span",{style:{color:c.textTertiary},children:"Asignar"})]}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:c.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:y&&jsxRuntime.jsx(framerMotion.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:c.bgPrimary,border:`1px solid ${c.border}`},children:o.map(O=>{let te=z.assignees?.some(de=>de.name===O.name);return jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:c.textPrimary},onMouseEnter:de=>de.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:de=>de.currentTarget.style.backgroundColor="transparent",onClick:()=>{let de=te?(z.assignees||[]).filter(he=>he.name!==O.name):[...z.assignees||[],{name:O.name,avatar:O.avatar,initials:O.name.split(" ").map(he=>he[0]).join("").toUpperCase().slice(0,2),color:c.accent}];Ie("assignees",de);},children:[jsxRuntime.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:c.accent},children:O.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"truncate flex-1 text-left",children:O.name}),jsxRuntime.jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:te&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5",style:{color:c.accent}})})]},O.id)})})})]}),jsxRuntime.jsxs("div",{ref:G,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{if(!n)if(w)x(false);else {if(G.current){let O=G.current.getBoundingClientRect(),te=window.innerHeight,de=120,Me=te-O.bottom<de?O.top-de-8:O.bottom+8;A({top:Me,left:O.left});}x(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:st,disabled:n,children:[jsxRuntime.jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:z.color}}),jsxRuntime.jsx("span",{children:gt.name}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:c.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:w&&jsxRuntime.jsxs(ft,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>x(false)}),jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"rounded-lg",style:{position:"fixed",top:`${R.top}px`,left:`${R.left}px`,zIndex:99999,backgroundColor:c.bgPrimary,border:`1px solid ${c.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick:O=>O.stopPropagation(),children:jsxRuntime.jsx("div",{style:{padding:"6px 8px"},children:jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 28px)",gap:"2px"},children:sr.slice(0,18).map(O=>{let te=z.color===O.value;return jsxRuntime.jsx("button",{type:"button",onClick:de=>{de.preventDefault(),de.stopPropagation(),Ie("color",O.value),x(false);},style:{width:"28px",height:"28px",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",border:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0},title:O.name,children:jsxRuntime.jsx("span",{style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:O.value,outline:te?`2px solid ${O.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},O.value)})})})})]})})]}),u.length>0||d?jsxRuntime.jsx(nr,{selectedTags:z.tags||[],availableTags:u,onChange:O=>Ie("tags",O),onCreateTag:d,theme:c,disabled:n}):null]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Calendar,{className:"w-4 h-4",style:{color:c.textTertiary}}),jsxRuntime.jsxs("div",{ref:K,className:"flex items-center gap-2 flex-1 relative",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!n&&!z.isMilestone)if(N==="start")U(null);else {if(K.current){let O=K.current.getBoundingClientRect(),te=window.innerHeight,de=320,Me=te-O.bottom<de?O.top-de-8:O.bottom+8;Te({top:Me,left:O.left});}U("start"),_(z.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...st,opacity:z.isMilestone?.5:1,cursor:z.isMilestone?"not-allowed":"pointer"},disabled:n||z.isMilestone,children:z.startDate?z.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsxRuntime.jsx("span",{style:{color:c.textTertiary},children:"\u2192"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!n&&!z.isMilestone)if(N==="end")U(null);else {if(K.current){let O=K.current.getBoundingClientRect(),te=window.innerHeight,de=320,Me=te-O.bottom<de?O.top-de-8:O.bottom+8;Te({top:Me,left:O.left});}U("end"),_(z.endDate||z.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...st,opacity:z.isMilestone?.5:1,cursor:z.isMilestone?"not-allowed":"pointer"},disabled:n||z.isMilestone,children:z.endDate?z.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:N&&jsxRuntime.jsxs(ft,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>U(null)}),jsxRuntime.jsxs(framerMotion.motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"rounded-xl shadow-2xl overflow-hidden flex",style:{position:"fixed",top:`${Q.top}px`,left:`${Q.left}px`,zIndex:99999,backgroundColor:c.bgPrimary,border:`1px solid ${c.border}`},onClick:O=>O.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${c.border}`},children:[(()=>{let O=new Date,te=new Date(O);te.setDate(O.getDate()+1);let de=new Date(O);de.setDate(O.getDate()+7);let he=new Date(O);return he.setDate(O.getDate()+14),[{label:"Hoy",date:O},{label:"Ma\xF1ana",date:te},{label:"Pr\xF3xima semana",date:de},{label:"2 semanas",date:he}].map((_e,bt)=>jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:c.textPrimary},onMouseEnter:Se=>Se.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:Se=>Se.currentTarget.style.backgroundColor="transparent",onClick:()=>{N==="start"?(Ie("startDate",_e.date),(!z.endDate||_e.date>z.endDate)&&Ie("endDate",_e.date),U("end")):(Ie("endDate",_e.date),(!z.startDate||_e.date<z.startDate)&&Ie("startDate",_e.date),U(null));},children:_e.label},bt))})(),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${c.border}`,margin:"0.5rem 0"}}),jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:O=>O.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:O=>O.currentTarget.style.backgroundColor="transparent",onClick:()=>{Ie("startDate",void 0),Ie("endDate",void 0),U(null);},children:"Borrar fechas"})]}),jsxRuntime.jsxs("div",{className:"p-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>_(new Date($.getFullYear(),$.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"w-4 h-4",style:{color:c.textSecondary}})}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:c.textPrimary},children:$.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>_(new Date($.getFullYear(),$.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4",style:{color:c.textSecondary}})})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((O,te)=>jsxRuntime.jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:c.textTertiary},children:O},te))}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let O=$.getFullYear(),te=$.getMonth(),de=new Date(O,te,1).getDay(),he=new Date(O,te+1,0).getDate(),Me=new Date,_e=[];for(let Se=de-1;Se>=0;Se--)_e.push({day:new Date(O,te,-Se).getDate(),date:new Date(O,te-1,new Date(O,te,-Se).getDate()),isCurrentMonth:false});for(let Se=1;Se<=he;Se++)_e.push({day:Se,date:new Date(O,te,Se),isCurrentMonth:true});let bt=42-_e.length;for(let Se=1;Se<=bt;Se++)_e.push({day:Se,date:new Date(O,te+1,Se),isCurrentMonth:false});return _e.map((Se,Lt)=>{let At=Se.date.toDateString()===Me.toDateString(),ct=z.startDate?.toDateString()===Se.date.toDateString(),Je=z.endDate?.toDateString()===Se.date.toDateString(),Ht=z.startDate&&z.endDate&&Se.date>=z.startDate&&Se.date<=z.endDate;return jsxRuntime.jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:Se.isCurrentMonth?ct||Je?"#FFF":c.textPrimary:c.textTertiary,backgroundColor:ct?"#3B82F6":Je?"#7C3AED":Ht?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:At&&!ct&&!Je?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{N==="start"?(Ie("startDate",Se.date),z.endDate&&Se.date>z.endDate&&Ie("endDate",Se.date),U("end")):(Ie("endDate",Se.date),z.startDate&&Se.date<z.startDate&&Ie("startDate",Se.date),U(null));},children:Se.day},Lt)})})()})]})]})]})})]}),ye.endDate&&jsxRuntime.jsx("span",{className:"text-xs text-red-400",children:ye.endDate})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-4 h-4",style:{color:c.textTertiary}}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsxRuntime.jsx("input",{type:"range",min:"0",max:"100",step:"5",value:z.progress,onChange:O=>Ie("progress",parseInt(O.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:c.bgSecondary,accentColor:z.progress<30?"#EF4444":z.progress<70?"#F59E0B":"#10B981"},disabled:n}),jsxRuntime.jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${z.progress<30?"#EF4444":z.progress<70?"#F59E0B":"#10B981"}20`,color:z.progress<30?"#EF4444":z.progress<70?"#F59E0B":"#10B981"},children:[z.progress,"%"]})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>tt(!$e),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:c.textTertiary},children:[jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-3 h-3 transition-transform ${$e?"rotate-180":""}`}),"Opciones avanzadas"]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:$e&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:jsxRuntime.jsxs("div",{className:"pt-3 space-y-3",children:[(f||g.length>0||m==="create")&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:c.textTertiary},children:jsxRuntime.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})}),jsxRuntime.jsxs("span",{className:"text-xs",style:{color:c.textTertiary},children:["Adjuntos ",m==="create"?Oe.length>0&&`(${Oe.length})`:g.length>0&&`(${g.length})`]})]}),m==="create"?jsxRuntime.jsx(dr,{cardId:"pending",attachments:Oe.map((O,te)=>({id:`pending-${te}`,cardId:"pending",name:O.name,size:O.size,type:O.type,url:URL.createObjectURL(O),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:O=>Re(te=>[...te,...O]),onDelete:O=>{let te=parseInt(O.replace("pending-",""),10);Re(de=>de.filter((he,Me)=>Me!==te));},maxSizeMB:10,maxFiles:20}):jsxRuntime.jsx(dr,{cardId:a?.id||"new",attachments:g,onUpload:f&&a?.id?O=>f(a.id,O):void 0,onDelete:C,maxSizeMB:10,maxFiles:20}),m==="create"&&Oe.length>0&&jsxRuntime.jsxs("p",{className:"text-xs mt-1",style:{color:c.textTertiary},children:[Oe.length," archivo(s) se subir\xE1n al crear la tarea"]})]}),jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-lg transition-colors hover:bg-white/5",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:z.isMilestone,onChange:O=>Ie("isMilestone",O.target.checked),className:"w-4 h-4 rounded",style:{accentColor:c.accent},disabled:n}),jsxRuntime.jsx(lucideReact.Milestone,{className:"w-4 h-4 text-yellow-500"}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:c.textPrimary},children:"Marcar como hito"})]}),r.length>0&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"flex items-center gap-2 text-xs mb-2",style:{color:c.textTertiary},children:[jsxRuntime.jsx(lucideReact.Link2,{className:"w-3.5 h-3.5"}),"Dependencias"]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-24 overflow-y-auto p-2 rounded-lg",style:{backgroundColor:c.bgSecondary},children:r.filter(O=>O.id!==a?.id).map(O=>{let te=z.dependencies?.includes(O.id);return jsxRuntime.jsx("button",{type:"button",onClick:()=>{let de=te?(z.dependencies||[]).filter(he=>he!==O.id):[...z.dependencies||[],O.id];Ie("dependencies",de);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:te?`${c.accent}30`:c.bgPrimary,color:te?c.accent:c.textSecondary,border:`1px solid ${te?c.accent:c.borderLight}`},disabled:n,children:O.name},O.id)})})]})]})})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${c.border}`},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:c.textSecondary},onMouseEnter:O=>O.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:O=>O.currentTarget.style.backgroundColor="transparent",disabled:n,children:"Cancelar"}),jsxRuntime.jsx("button",{type:"submit",disabled:n,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:c.accent,color:"#FFF"},onMouseEnter:O=>!n&&(O.currentTarget.style.opacity="0.9"),onMouseLeave:O=>!n&&(O.currentTarget.style.opacity="1"),children:n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:m==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var Nc=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
|
|
345
345
|
|