@libxai/board 0.17.219 → 0.17.220
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 +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/styles.css +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -339,9 +339,9 @@
|
|
|
339
339
|
</Calendars>
|
|
340
340
|
<Tasks>${p}
|
|
341
341
|
</Tasks>
|
|
342
|
-
</Project>`,m=new Blob([n],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(m),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=le.flattenTasks(e),a=t.filter(n=>n.startDate&&n.endDate);if(a.length===0)return [];let r=new Map,o=n=>{if(r.has(n.id))return;let m=n.startDate&&n.endDate?le.calculateDuration(n.startDate,n.endDate):0,d=0;if(n.dependencies&&n.dependencies.length>0)for(let u of n.dependencies){let x=t.find(f=>f.id===u);if(x){o(x);let f=r.get(u)?.ef||0;d=Math.max(d,f);}}let i=d+m;r.set(n.id,{es:d,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(n=>n.ef)),l=new Map,c=n=>{if(l.has(n.id))return;let m=n.startDate&&n.endDate?le.calculateDuration(n.startDate,n.endDate):0,d=t.filter(x=>x.dependencies&&x.dependencies.includes(n.id)),i=s;if(d.length>0)for(let x of d){c(x);let f=l.get(x.id)?.ls||0;i=Math.min(i,f);}let u=i-m;l.set(n.id,{ls:u,lf:i});};a.forEach(c);let p=[];for(let n of a){let m=r.get(n.id),d=l.get(n.id);if(m&&d){let i=d.ls-m.es;Math.abs(i)<.01&&p.push(n.id);}}return p},calculateSlack:(e,t)=>{let a=le.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(le.calculateCriticalPath(e).includes(t))return 0;let o=le.getDependentTasks(e,t);if(o.length===0){let c=le.getLatestEndDate(e);if(!c)return null;let p=le.calculateDuration(a.endDate,c);return Math.max(0,p)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,p)=>c-p)[0];if(!s)return null;let l=le.calculateDuration(a.endDate,new Date(s));return Math.max(0,l)},isOnCriticalPath:(e,t)=>le.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=le.findTaskById(e,t);if(!r||!r.endDate)return e;let o=le.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let l of o){if(!l.startDate||!l.endDate)continue;let c=le.calculateDuration(l.startDate,l.endDate),p;a!==void 0?(p=new Date(l.startDate),p.setDate(p.getDate()+a)):(p=new Date(r.endDate),p.setDate(p.getDate()+1));let n=le.calculateEndDate(p,c),m=d=>d.map(i=>i.id===l.id?{...i,startDate:p,endDate:n}:i.subtasks?{...i,subtasks:m(i.subtasks)}:i);s=m(s),s=le.autoScheduleDependents(s,l.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,l,c)=>{if(a===0)return [];let p=[],n=o.getTime(),m=1e3*60*60*24,d=le.findTaskById(e,t);if(!d||!d.endDate)return [];let i=(u,x,f=new Set)=>{if(f.has(u))return;f.add(u);let g=le.getDependentTasks(e,u);for(let k of g){if(!k.startDate||!k.endDate)continue;let h=r.findIndex(w=>w.id===k.id);if(h===-1)continue;let b=k.startDate.getTime(),D=(k.endDate.getTime()-b)/m,A=(b-n)/m*s,v=A+x*s,B=Math.max(D*s,s),T=c+h*l+12;p.push({taskId:k.id,taskName:k.name,originalX:A,previewX:v,width:B,y:T,rowIndex:h,daysDelta:x,color:k.color}),i(k.id,x,f);}};return i(t,a),p},splitTask:(e,t,a,r=3)=>{let o=le.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let l=new Date(a);l.setDate(l.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let p=[{startDate:new Date(o.startDate),endDate:s},{startDate:l,endDate:c}],n=m=>m.map(d=>d.id===o.id?{...d,endDate:c,segments:p}:d.subtasks?{...d,subtasks:n(d.subtasks)}:d);return n(e)}};function ln({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:l,templates:c,onTaskClick:p,onTaskDblClick:n,onTaskContextMenu:m,onTaskDateChange:d,onDependencyCreate:i,onDependencyDelete:u}){let[f,g]=react.useState([]),[k,h]=react.useState(null),[b,y]=react.useState(null),D=react.useCallback($=>{h($);},[]),N=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),A=r==="day"?60:r==="week"?20:8,v=N*A*l,B=$=>{let F=new Date(Date.UTC($.getFullYear(),$.getMonth(),$.getDate())),W=F.getUTCDay()||7;F.setUTCDate(F.getUTCDate()+4-W);let E=new Date(Date.UTC(F.getUTCFullYear(),0,1));return Math.ceil(((F.getTime()-E.getTime())/864e5+1)/7)},T=$=>{let F=$.getDay();return F===0||F===6},w=react.useCallback($=>{let F=Math.round($/(A*l)),W=new Date(o);return W.setDate(W.getDate()+F),W},[o,A,l]),R=react.useCallback(($,F)=>{if(F.startDate&&F.endDate)return;let W=$.currentTarget.ownerSVGElement;if(!W)return;let E=W.createSVGPoint();E.x=$.clientX,E.y=$.clientY;let Y=E.matrixTransform(W.getScreenCTM()?.inverse()),J=w(Y.x),U=new Date(J);U.setDate(U.getDate()+1),d?.(F,J,U);},[w,d]),M=react.useMemo(()=>{let $=Y=>Y.map(J=>{if(J.subtasks&&J.subtasks.length>0){let U=$(J.subtasks),De=U.filter(ke=>ke.startDate&&ke.endDate);if(De.length>0){let ke=De.map(Pe=>Pe.startDate.getTime()),$e=De.map(Pe=>Pe.endDate.getTime()),he=new Date(Math.min(...ke)),et=new Date(Math.max(...$e));return {...J,subtasks:U,startDate:he,endDate:et}}return {...J,subtasks:U}}return J}),F=(Y,J=[])=>{for(let U of Y)J.push(U),U.subtasks&&U.subtasks.length>0&&(U.isExpanded===void 0||U.isExpanded)&&F(U.subtasks,J);return J},W=$(e);return F(W)},[e]),H=react.useCallback($=>{if(!$.startDate||!$.endDate)return {x:0,width:0};let F=$.startDate.getTime(),W=$.endDate.getTime(),E=o.getTime(),Y=(F-E)/(1e3*60*60*24),J=(W-F)/(1e3*60*60*24),U=Y*A*l,De=Math.max(A*l,40),ke=Math.max(J*A*l,De);return {x:U,width:ke}},[o,A,l]),X=react.useMemo(()=>M.filter($=>$.startDate&&$.endDate).map($=>{let{x:F,width:W}=H($),Y=M.findIndex(J=>J.id===$.id)*a+12;return {id:$.id,x:F,y:Y,width:W,height:32}}),[M,H]),fe=react.useCallback(($,F,W)=>{if(!W||F===0){g([]);return}let E=le.calculateCascadePreview(e,$,F,M,o,A*l,a,48);g(E);},[e,M,o,A,l,a,48]),xe=react.useMemo(()=>{let $=[],F=new Date(o);for(;F<=s;){let Y=(F.getTime()-o.getTime())/864e5*A*l;if(r==="day")$.push({date:new Date(F),label:F.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:Y}),F.setDate(F.getDate()+1);else if(r==="week"){let J=B(F);$.push({date:new Date(F),label:`Week ${J}`,x:Y}),F.setDate(F.getDate()+7);}else $.push({date:new Date(F),label:F.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:Y}),F.setMonth(F.getMonth()+1);}return $},[o,s,r,A,l]),Ae=react.useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*A*l,[o,A,l]),Be=Math.max(M.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(v,1e3),height:47,style:{display:"block"},children:[jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(v,1e3),height:48,fill:t.bgGrid}),xe.map(($,F)=>jsxRuntime.jsxs("g",{children:[F>0&&jsxRuntime.jsx("line",{x1:$.x,y1:0,x2:$.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsxRuntime.jsx("text",{x:$.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:$.label})]},`header-${F}`)),Ae>=0&&Ae<=v&&jsxRuntime.jsx("circle",{cx:Ae,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(v,1e3),height:Be,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(v,1e3),height:Be,fill:t.bgPrimary}),xe.map(($,F)=>{let W=xe[F+1]?.x||v,E=T($.date);return jsxRuntime.jsxs("g",{children:[E&&jsxRuntime.jsx("rect",{x:$.x,y:0,width:W-$.x,height:M.length*a,fill:t.bgWeekend,opacity:1}),F>0&&jsxRuntime.jsx("line",{x1:$.x,y1:0,x2:$.x,y2:M.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},F)}),M.map(($,F)=>{let W=$.startDate&&$.endDate;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:0,y:F*a,width:v,height:a,fill:F%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${$.id}`),!W&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:0,y:F*a,width:v,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:E=>R(E,$),onMouseEnter:E=>{E.currentTarget.setAttribute("fill",t.accentLight),E.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:E=>{E.currentTarget.setAttribute("fill","transparent"),E.currentTarget.setAttribute("opacity","1");}},`clickable-${$.id}`),jsxRuntime.jsx("text",{x:Ae>0?Ae:100,y:F*a+a/2,fill:t.textTertiary,fontSize:"12",fontFamily:"Inter, sans-serif",fontStyle:"italic",dominantBaseline:"middle",opacity:.4,style:{pointerEvents:"none",userSelect:"none"},children:"Click to set dates..."},`placeholder-${$.id}`)]})]},`row-group-${$.id}`)}),M.map(($,F)=>!$.dependencies||$.dependencies.length===0||!$.startDate||!$.endDate?null:$.dependencies.map(W=>{let E=M.find(De=>De.id===W);if(!E||!E.startDate||!E.endDate)return null;let Y=M.findIndex(De=>De.id===W),J=H(E),U=H($);return jsxRuntime.jsx(rn,{x1:J.x+J.width,y1:Y*a+a/2,x2:U.x,y2:F*a+a/2,theme:t},`dep-${W}-${$.id}`)})),M.map(($,F)=>{if(!$.startDate||!$.endDate)return null;let{x:W,width:E}=H($),Y=F*a+12,J=$.subtasks&&$.subtasks.length>0&&!$.isMilestone;return $.isMilestone?jsxRuntime.jsx(nn,{task:$,x:W+E/2,y:Y+16,theme:t,onClick:p},$.id):J?jsxRuntime.jsxs("g",{onClick:()=>p?.($),onContextMenu:U=>{U.preventDefault(),U.stopPropagation(),m?.($,U);},style:{cursor:"default"},children:[jsxRuntime.jsx("rect",{x:W,y:Y,width:E,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:W,y1:Y,x2:W+E,y2:Y,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:W,y1:Y,x2:W,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:W+E,y1:Y,x2:W+E,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:W,y1:Y+32,x2:W+E,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),E>60&&jsxRuntime.jsx("text",{x:W+12,y:Y+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:$.name})]},$.id):jsxRuntime.jsx(en,{task:$,x:W,y:Y,width:E,theme:t,dayWidth:A*l,startDate:o,templates:c,onClick:p,onDoubleClick:n,onContextMenu:m,onDateChange:d,onDependencyCreate:i,allTaskPositions:X,onDragMove:fe,onHoverChange:D},$.id)}),M.map(($,F)=>!$.dependencies||$.dependencies.length===0||!$.startDate||!$.endDate?null:$.dependencies.map(W=>{let E=M.find(de=>de.id===W);if(!E||!E.startDate||!E.endDate)return null;let Y=M.findIndex(de=>de.id===W),J=H(E),U=H($),De=J.x+J.width,ke=Y*a+a/2,$e=U.x,he=F*a+a/2,et=$e-De,Pe=De+et/2,Qe=de=>{let Ce=1-de,Ee=Ce*Ce,tt=Ee*Ce,mt=de*de,Ie=mt*de,I=tt*De+3*Ee*de*Pe+3*Ce*mt*Pe+Ie*$e,q=tt*ke+3*Ee*de*ke+3*Ce*mt*he+Ie*he;return {x:I,y:q}},ht=20,Dt=[];for(let de=0;de<=ht;de++){let Ce=.1+de/ht*.8;Dt.push(Qe(Ce));}let lt=Dt[0],z=`M ${lt.x} ${lt.y} `+Dt.slice(1).map(de=>`L ${de.x} ${de.y}`).join(" ");return b&&b.x1===De&&b.y1===ke&&b.x2===$e&&b.y2===he?null:jsxRuntime.jsx("path",{d:z,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:()=>{y({x1:De,y1:ke,x2:$e,y2:he,onDelete:()=>u?.($.id,W)});}},`dep-hover-${W}-${$.id}`)})),f.map($=>jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("rect",{x:$.previewX,y:$.y-48,width:$.width,height:32,rx:8,fill:$.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs($.daysDelta)>0&&jsxRuntime.jsx("text",{x:$.previewX+$.width/2,y:$.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:$.daysDelta>0?`+${$.daysDelta}d`:`${$.daysDelta}d`})]},`cascade-preview-${$.taskId}`)),b&&(()=>{let{x1:$,y1:F,x2:W,y2:E,onDelete:Y}=b,J=W-$,U=E-F,De=$+J/2,ke=(F+E)/2,$e=`M ${$} ${F} C ${De} ${F}, ${De} ${E}, ${W} ${E}`,he=6,et=Math.atan2(U,J),Pe=W-he*Math.cos(et-Math.PI/6),Qe=E-he*Math.sin(et-Math.PI/6),ht=W-he*Math.cos(et+Math.PI/6),Dt=E-he*Math.sin(et+Math.PI/6),lt=t.dependency,z="#f87171";return jsxRuntime.jsxs("g",{onMouseLeave:()=>y(null),children:[jsxRuntime.jsx("path",{d:$e,fill:"none",stroke:"transparent",strokeWidth:50,strokeLinecap:"round",style:{cursor:"pointer"}}),jsxRuntime.jsx("circle",{cx:De,cy:ke,r:25,fill:"transparent",style:{cursor:"pointer"}}),jsxRuntime.jsx("path",{d:$e,fill:"none",stroke:lt,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsxRuntime.jsx("path",{d:$e,fill:"none",stroke:lt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("path",{d:`M ${W} ${E} L ${Pe} ${Qe} M ${W} ${E} L ${ht} ${Dt}`,fill:"none",stroke:lt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("circle",{cx:W,cy:E,r:4,fill:lt,opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsxs(framerMotion.motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:de=>{de.stopPropagation(),y(null),Y();},style:{cursor:"pointer"},children:[jsxRuntime.jsx("circle",{cx:De,cy:ke,r:9,fill:"rgba(248, 113, 113, 0.15)",stroke:z,strokeWidth:1.5,style:{transition:"all 0.15s ease"}}),jsxRuntime.jsx("line",{x1:De-3,y1:ke-3,x2:De+3,y2:ke+3,stroke:z,strokeWidth:1.5,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:De+3,y1:ke-3,x2:De-3,y2:ke+3,stroke:z,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),Ae>=0&&Ae<=v&&jsxRuntime.jsx("line",{x1:Ae,y1:0,x2:Ae,y2:Be,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),k&&jsxRuntime.jsx(Sd,{tooltipData:k,theme:t})]})]})}var dn=[{name:"Azul",value:"#6366F1",light:"#818CF8"},{name:"P\xFArpura",value:"#A855F7",light:"#C084FC"},{name:"Rosa",value:"#EC4899",light:"#F472B6"},{name:"Rojo",value:"#EF4444",light:"#F87171"},{name:"Naranja",value:"#F59E0B",light:"#FBBF24"},{name:"Amarillo",value:"#EAB308",light:"#FACC15"},{name:"Lima",value:"#84CC16",light:"#A3E635"},{name:"Verde",value:"#10B981",light:"#34D399"},{name:"Esmeralda",value:"#059669",light:"#10B981"},{name:"Cyan",value:"#06B6D4",light:"#22D3EE"},{name:"Azul Cielo",value:"#0EA5E9",light:"#38BDF8"},{name:"\xCDndigo",value:"#4F46E5",light:"#6366F1"},{name:"Violeta",value:"#8B5CF6",light:"#A78BFA"},{name:"Fucsia",value:"#D946EF",light:"#E879F9"},{name:"Coral",value:"#F97316",light:"#FB923C"},{name:"Magenta",value:"#E11D48",light:"#FB7185"}];var Ws=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],Hs=[{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 cn({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:l=false,mode:c=a?"edit":"create",theme:p="dark",customStatuses:n=[],availableTags:m=[],onCreateTag:d,attachments:i=[],onUploadAttachments:u,onDeleteAttachment:x}){let f=[...Ws,...n.filter(z=>!Ws.some(oe=>oe.id===z.id))],g=Ge[p]||Ge.dark,[k,h]=react.useState(false),[b,y]=react.useState(false),[D,N]=react.useState(false),[A,v]=react.useState(false),[B,T]=react.useState({top:0,left:0}),[w,R]=react.useState(null),[M,H]=react.useState(new Date),[X,fe]=react.useState({top:0,left:0}),[xe,Ae]=react.useState(false),[Be,$]=react.useState([]),F=react.useRef(null),W=react.useRef(null),E=react.useRef(null),Y=react.useRef(null),J=react.useRef(null),[U,De]=react.useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[ke,$e]=react.useState({});react.useEffect(()=>{a?(De({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)&&Ae(true)):(De({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),Ae(false),$([]));},[a,e]),react.useEffect(()=>{let z=oe=>{F.current&&!F.current.contains(oe.target)&&h(false),W.current&&!W.current.contains(oe.target)&&y(false),E.current&&!E.current.contains(oe.target)&&N(false),Y.current&&!Y.current.contains(oe.target)&&v(false);};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]);let he=()=>{let z={};return U.name.trim()||(z.name="El nombre es requerido"),U.startDate&&U.endDate&&U.startDate>U.endDate&&(z.endDate="La fecha de fin debe ser posterior a la de inicio"),$e(z),Object.keys(z).length===0},et=async z=>{if(z.preventDefault(),!!he())try{let oe=c==="create"&&Be.length>0?{...U,pendingFiles:Be}:U;await s(oe),$([]),t();}catch(oe){console.error("Error submitting task:",oe);}},Pe=(z,oe)=>{De(de=>{let Ce={...de,[z]:oe};if(z==="status"){let Ee=oe;Ee==="todo"?Ce.progress=0:Ee==="in-progress"?(de.progress===0||de.progress===100)&&(Ce.progress=50):Ee==="completed"||Ee==="closed"?Ce.progress=100:(Ee==="in-review"||Ee==="review")&&(Ce.progress=75);}if(z==="progress"){let Ee=typeof oe=="number"?oe:parseInt(oe,10);Ee===100&&de.status!=="completed"?Ce.status="completed":Ee>0&&Ee<100&&de.status==="todo"?Ce.status="in-progress":Ee===0&&de.status!=="todo"&&(Ce.status="todo");}return Ce}),ke[z]&&$e(de=>{let Ce={...de};return delete Ce[z],Ce});},Qe=f.find(z=>z.id===U.status)??Ws[0],ht=Hs.find(z=>z.id===U.priority)??Hs[1],Dt=dn.find(z=>z.value===U.color)??dn[0],lt={backgroundColor:g.bgSecondary,border:`1px solid ${g.borderLight}`,color:g.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:g.bgPrimary,border:`1px solid ${g.border}`},onClick:z=>z.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${g.border}`},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Qe.color||g.accent}}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:g.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsxRuntime.jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:g.textTertiary},onMouseEnter:z=>{z.currentTarget.style.backgroundColor=g.hoverBg,z.currentTarget.style.color=g.textPrimary;},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="transparent",z.currentTarget.style.color=g.textTertiary;},disabled:l,children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:et,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:U.name,onChange:z=>Pe("name",z.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:g.textPrimary},placeholder:"Nombre de la tarea",disabled:l,autoFocus:true}),ke.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"}),ke.name]})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("textarea",{value:U.description||"",onChange:z=>Pe("description",z.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:g.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:l})}),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${g.borderLight}`}}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxRuntime.jsxs("div",{ref:F,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!l&&h(!k),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...lt,borderColor:Qe.color,backgroundColor:`${Qe.color}15`},disabled:l,children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:Qe.color}}),jsxRuntime.jsx("span",{style:{color:Qe.color},children:Qe.title}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:Qe.color}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:k&&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:g.bgPrimary,border:`1px solid ${g.border}`},children:f.map(z=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:oe=>oe.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:oe=>oe.currentTarget.style.backgroundColor="transparent",onClick:()=>{Pe("status",z.id),h(false);},children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:z.color}}),z.title,U.status===z.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:g.accent}})]},z.id))})})]}),jsxRuntime.jsxs("div",{ref:W,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!l&&y(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:lt,disabled:l,children:[jsxRuntime.jsx(lucideReact.Flag,{className:"w-3.5 h-3.5",style:{color:ht.color}}),jsxRuntime.jsx("span",{children:ht.label}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),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-[130px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},children:Hs.map(z=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:oe=>oe.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:oe=>oe.currentTarget.style.backgroundColor="transparent",onClick:()=>{Pe("priority",z.id),y(false);},children:[jsxRuntime.jsx("span",{children:z.icon}),z.label,U.priority===z.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:g.accent}})]},z.id))})})]}),o.length>0&&jsxRuntime.jsxs("div",{ref:E,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!l&&N(!D),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:lt,disabled:l,children:[U.assignees&&U.assignees.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex -space-x-1",children:U.assignees.slice(0,3).map((z,oe)=>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:z.color||g.accent,borderColor:g.bgSecondary},children:z.initials},oe))}),U.assignees.length>3&&jsxRuntime.jsxs("span",{style:{color:g.textTertiary},children:["+",U.assignees.length-3]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Users,{className:"w-3.5 h-3.5",style:{color:g.textTertiary}}),jsxRuntime.jsx("span",{style:{color:g.textTertiary},children:"Asignar"})]}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:D&&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:g.bgPrimary,border:`1px solid ${g.border}`},children:o.map(z=>{let oe=U.assignees?.some(de=>de.name===z.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:g.textPrimary},onMouseEnter:de=>de.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:de=>de.currentTarget.style.backgroundColor="transparent",onClick:()=>{let de=oe?(U.assignees||[]).filter(Ce=>Ce.name!==z.name):[...U.assignees||[],{name:z.name,avatar:z.avatar,initials:z.name.split(" ").map(Ce=>Ce[0]).join("").toUpperCase().slice(0,2),color:g.accent}];Pe("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:g.accent},children:z.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"truncate flex-1 text-left",children:z.name}),jsxRuntime.jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:oe&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5",style:{color:g.accent}})})]},z.id)})})})]}),jsxRuntime.jsxs("div",{ref:Y,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{if(!l)if(A)v(false);else {if(Y.current){let z=Y.current.getBoundingClientRect(),oe=window.innerHeight,de=120,Ee=oe-z.bottom<de?z.top-de-8:z.bottom+8;T({top:Ee,left:z.left});}v(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:lt,disabled:l,children:[jsxRuntime.jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:U.color}}),jsxRuntime.jsx("span",{children:Dt.name}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:A&&jsxRuntime.jsxs(at,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>v(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:`${B.top}px`,left:`${B.left}px`,zIndex:99999,backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick:z=>z.stopPropagation(),children:jsxRuntime.jsx("div",{style:{padding:"6px 8px"},children:jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 28px)",gap:"2px"},children:dn.slice(0,18).map(z=>{let oe=U.color===z.value;return jsxRuntime.jsx("button",{type:"button",onClick:de=>{de.preventDefault(),de.stopPropagation(),Pe("color",z.value),v(false);},style:{width:"28px",height:"28px",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",border:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0},title:z.name,children:jsxRuntime.jsx("span",{style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:z.value,outline:oe?`2px solid ${z.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},z.value)})})})})]})})]}),m.length>0||d?jsxRuntime.jsx(zr,{selectedTags:U.tags||[],availableTags:m,onChange:z=>Pe("tags",z),onCreateTag:d,theme:g,disabled:l}):null]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Calendar,{className:"w-4 h-4",style:{color:g.textTertiary}}),jsxRuntime.jsxs("div",{ref:J,className:"flex items-center gap-2 flex-1 relative",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!l&&!U.isMilestone)if(w==="start")R(null);else {if(J.current){let z=J.current.getBoundingClientRect(),oe=window.innerHeight,de=320,Ee=oe-z.bottom<de?z.top-de-8:z.bottom+8;fe({top:Ee,left:z.left});}R("start"),H(U.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...lt,opacity:U.isMilestone?.5:1,cursor:U.isMilestone?"not-allowed":"pointer"},disabled:l||U.isMilestone,children:U.startDate?U.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsxRuntime.jsx("span",{style:{color:g.textTertiary},children:"\u2192"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!l&&!U.isMilestone)if(w==="end")R(null);else {if(J.current){let z=J.current.getBoundingClientRect(),oe=window.innerHeight,de=320,Ee=oe-z.bottom<de?z.top-de-8:z.bottom+8;fe({top:Ee,left:z.left});}R("end"),H(U.endDate||U.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...lt,opacity:U.isMilestone?.5:1,cursor:U.isMilestone?"not-allowed":"pointer"},disabled:l||U.isMilestone,children:U.endDate?U.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:w&&jsxRuntime.jsxs(at,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>R(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:`${X.top}px`,left:`${X.left}px`,zIndex:99999,backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},onClick:z=>z.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${g.border}`},children:[(()=>{let z=new Date,oe=new Date(z);oe.setDate(z.getDate()+1);let de=new Date(z);de.setDate(z.getDate()+7);let Ce=new Date(z);return Ce.setDate(z.getDate()+14),[{label:"Hoy",date:z},{label:"Ma\xF1ana",date:oe},{label:"Pr\xF3xima semana",date:de},{label:"2 semanas",date:Ce}].map((tt,mt)=>jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:g.textPrimary},onMouseEnter:Ie=>Ie.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:Ie=>Ie.currentTarget.style.backgroundColor="transparent",onClick:()=>{w==="start"?(Pe("startDate",tt.date),(!U.endDate||tt.date>U.endDate)&&Pe("endDate",tt.date),R("end")):(Pe("endDate",tt.date),(!U.startDate||tt.date<U.startDate)&&Pe("startDate",tt.date),R(null));},children:tt.label},mt))})(),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${g.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:z=>z.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:z=>z.currentTarget.style.backgroundColor="transparent",onClick:()=>{Pe("startDate",void 0),Pe("endDate",void 0),R(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:()=>H(new Date(M.getFullYear(),M.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"w-4 h-4",style:{color:g.textSecondary}})}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:g.textPrimary},children:M.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>H(new Date(M.getFullYear(),M.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4",style:{color:g.textSecondary}})})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((z,oe)=>jsxRuntime.jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:g.textTertiary},children:z},oe))}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let z=M.getFullYear(),oe=M.getMonth(),de=new Date(z,oe,1).getDay(),Ce=new Date(z,oe+1,0).getDate(),Ee=new Date,tt=[];for(let Ie=de-1;Ie>=0;Ie--)tt.push({day:new Date(z,oe,-Ie).getDate(),date:new Date(z,oe-1,new Date(z,oe,-Ie).getDate()),isCurrentMonth:false});for(let Ie=1;Ie<=Ce;Ie++)tt.push({day:Ie,date:new Date(z,oe,Ie),isCurrentMonth:true});let mt=42-tt.length;for(let Ie=1;Ie<=mt;Ie++)tt.push({day:Ie,date:new Date(z,oe+1,Ie),isCurrentMonth:false});return tt.map((Ie,I)=>{let q=Ie.date.toDateString()===Ee.toDateString(),He=U.startDate?.toDateString()===Ie.date.toDateString(),Ue=U.endDate?.toDateString()===Ie.date.toDateString(),yt=U.startDate&&U.endDate&&Ie.date>=U.startDate&&Ie.date<=U.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:Ie.isCurrentMonth?He||Ue?"#FFF":g.textPrimary:g.textTertiary,backgroundColor:He?"#3B82F6":Ue?"#7C3AED":yt?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:q&&!He&&!Ue?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{w==="start"?(Pe("startDate",Ie.date),U.endDate&&Ie.date>U.endDate&&Pe("endDate",Ie.date),R("end")):(Pe("endDate",Ie.date),U.startDate&&Ie.date<U.startDate&&Pe("startDate",Ie.date),R(null));},children:Ie.day},I)})})()})]})]})]})})]}),ke.endDate&&jsxRuntime.jsx("span",{className:"text-xs text-red-400",children:ke.endDate})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-4 h-4",style:{color:g.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:U.progress,onChange:z=>Pe("progress",parseInt(z.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:g.bgSecondary,accentColor:U.progress<30?"#EF4444":U.progress<70?"#F59E0B":"#10B981"},disabled:l}),jsxRuntime.jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${U.progress<30?"#EF4444":U.progress<70?"#F59E0B":"#10B981"}20`,color:U.progress<30?"#EF4444":U.progress<70?"#F59E0B":"#10B981"},children:[U.progress,"%"]})]})]}),(u||i.length>0||c==="create")&&jsxRuntime.jsxs("div",{className:"pt-2",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:g.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:g.textTertiary},children:["Adjuntos ",c==="create"?Be.length>0&&`(${Be.length})`:i.length>0&&`(${i.length})`]})]}),c==="create"?jsxRuntime.jsx(Ua,{cardId:"pending",attachments:Be.map((z,oe)=>({id:`pending-${oe}`,cardId:"pending",name:z.name,size:z.size,type:z.type,url:URL.createObjectURL(z),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:z=>$(oe=>[...oe,...z]),onDelete:z=>{let oe=parseInt(z.replace("pending-",""),10);$(de=>de.filter((Ce,Ee)=>Ee!==oe));},maxSizeMB:10,maxFiles:20}):jsxRuntime.jsx(Ua,{cardId:a?.id||"new",attachments:i,onUpload:u&&a?.id?z=>u(a.id,z):void 0,onDelete:x,maxSizeMB:10,maxFiles:20}),c==="create"&&Be.length>0&&jsxRuntime.jsxs("p",{className:"text-xs mt-1",style:{color:g.textTertiary},children:[Be.length," archivo(s) se subir\xE1n al crear la tarea"]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>Ae(!xe),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:g.textTertiary},children:[jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-3 h-3 transition-transform ${xe?"rotate-180":""}`}),"Opciones avanzadas"]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:xe&&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:[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:U.isMilestone,onChange:z=>Pe("isMilestone",z.target.checked),className:"w-4 h-4 rounded",style:{accentColor:g.accent},disabled:l}),jsxRuntime.jsx(lucideReact.Milestone,{className:"w-4 h-4 text-yellow-500"}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:g.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:g.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:g.bgSecondary},children:r.filter(z=>z.id!==a?.id).map(z=>{let oe=U.dependencies?.includes(z.id);return jsxRuntime.jsx("button",{type:"button",onClick:()=>{let de=oe?(U.dependencies||[]).filter(Ce=>Ce!==z.id):[...U.dependencies||[],z.id];Pe("dependencies",de);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:oe?`${g.accent}30`:g.bgPrimary,color:oe?g.accent:g.textSecondary,border:`1px solid ${oe?g.accent:g.borderLight}`},disabled:l,children:z.name},z.id)})})]})]})})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${g.border}`},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:g.textSecondary},onMouseEnter:z=>z.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:z=>z.currentTarget.style.backgroundColor="transparent",disabled:l,children:"Cancelar"}),jsxRuntime.jsx("button",{type:"submit",disabled:l,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:g.accent,color:"#FFF"},onMouseEnter:z=>!l&&(z.currentTarget.style.opacity="0.9"),onMouseLeave:z=>!l&&(z.currentTarget.style.opacity="1"),children:l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:c==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var uf=['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"'],Id=()=>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"})]}),gf=()=>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"})}),ff=()=>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"})}),hf=()=>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"})}),bf=()=>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 pn({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:l,onDependencyCreate:c,onDependencyDelete:p}){let[n,m]=react.useState(false),[d,i]=react.useState(false),[u,x]=react.useState([]),[f,g]=react.useState(""),[k,h]=react.useState(false),[b,y]=react.useState(true),D=react.useRef(null),N=react.useRef(null),A=react.useRef(null),{enabled:v=true,placeholder:B='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:T="bottom-right",onCommand:w,suggestions:R=uf,maxHistory:M=50,persistHistory:H}=a,X=H?.storageKey||"gantt-ai-history",fe=H?.maxMessages??5;react.useEffect(()=>{if(H?.enabled)try{let W=localStorage.getItem(X);if(W){let Y=JSON.parse(W).map(J=>({...J,timestamp:new Date(J.timestamp)}));x(Y.slice(-fe));}}catch(W){console.warn("[GanttAIAssistant] Failed to load persisted history:",W);}},[H?.enabled,X,fe]),react.useEffect(()=>{if(H?.enabled&&u.length>0)try{let W=u.filter(E=>!E.isLoading).slice(-fe);localStorage.setItem(X,JSON.stringify(W));}catch(W){console.warn("[GanttAIAssistant] Failed to persist history:",W);}},[u,H?.enabled,X,fe]),react.useEffect(()=>{N.current&&N.current.scrollIntoView({behavior:"smooth"});},[u]),react.useEffect(()=>{n&&!d&&D.current&&setTimeout(()=>D.current?.focus(),100);},[n,d]);let xe=react.useCallback(W=>{if(W.success)switch(W.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":W.taskId&&W.updates&&o?.(W.taskId,W.updates);break;case "create_task":W.newTask&&s?.(W.newTask);break;case "delete_task":W.taskId&&l?.(W.taskId);break;case "link_tasks":W.dependencyFrom&&W.dependencyTo&&c?.(W.dependencyFrom,W.dependencyTo);break;case "unlink_tasks":W.taskId&&W.dependencyFrom&&p?.(W.taskId,W.dependencyFrom);break}},[o,s,l,c,p]),Ae=react.useCallback(async W=>{if(!W.trim()||k)return;let E={id:`user-${Date.now()}`,role:"user",content:W,timestamp:new Date};x(J=>[...J.slice(-(M-1)),E]),g(""),y(false),h(true);let Y={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};x(J=>[...J,Y]);try{if(w){let J=await w(W,e);x(U=>{let De=U.filter($e=>!$e.isLoading),ke={id:`assistant-${Date.now()}`,role:"assistant",content:J.message,timestamp:new Date,command:J};return [...De,ke]}),xe(J);}else x(J=>[...J.filter(De=>!De.isLoading),{id:`assistant-${Date.now()}`,role:"assistant",content:"AI handler not configured. Please provide an onCommand handler in the aiAssistant config.",timestamp:new Date}]);}catch(J){x(U=>[...U.filter(ke=>!ke.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${J instanceof Error?J.message:"Unknown error"}`,timestamp:new Date}]);}finally{h(false);}},[k,M,w,e,xe]),Be=W=>{W.preventDefault(),Ae(f);},$=W=>{g(W),D.current?.focus();};if(react.useEffect(()=>{let W=E=>{(E.metaKey||E.ctrlKey)&&E.key==="k"&&(E.preventDefault(),m(Y=>!Y),n||i(false)),E.key==="Escape"&&n&&m(false);};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[n]),react.useEffect(()=>{if(!n)return;let W=Y=>{let J=Y.target;A.current&&!A.current.contains(J)&&m(false);},E=setTimeout(()=>{document.addEventListener("mousedown",W);},100);return ()=>{clearTimeout(E),document.removeEventListener("mousedown",W);}},[n]),!v)return null;let F={"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(at,{children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!n&&jsxRuntime.jsxs(framerMotion.motion.button,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},className:`fixed ${F[T]} z-[99999] flex items-center gap-2 px-4 py-3 rounded-full shadow-lg transition-colors`,style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"white",boxShadow:"0 4px 20px rgba(59, 130, 246, 0.4)"},onClick:()=>m(true),children:[jsxRuntime.jsx(Id,{}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),jsxRuntime.jsx("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono rounded bg-white/20",children:"\u2318K"})]})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:n&&jsxRuntime.jsxs(framerMotion.motion.div,{ref:A,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 ${F[T]} z-[99999] w-96 rounded-2xl overflow-hidden shadow-2xl flex flex-col`,style:{background:t.bgPrimary,border:`1px solid ${t.border}`,boxShadow:`0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px ${t.border}`},children:[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(Id,{}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{onClick:()=>i(W=>!W),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(hf,{})}),jsxRuntime.jsx("button",{onClick:()=>m(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(ff,{})})]})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!d&&jsxRuntime.jsxs(framerMotion.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"flex flex-col flex-1 min-h-0",children:[jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[u.length===0&&b&&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:R.slice(0,4).map((W,E)=>jsxRuntime.jsx("button",{onClick:()=>$(W),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:W.length>30?W.slice(0,30)+"...":W},E))})]}),u.map(W=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${W.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${W.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:W.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:W.role==="user"?"white":t.textPrimary},children:[W.isLoading?jsxRuntime.jsx(bf,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:W.content}),W.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:W.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:W.command.success?"#10B981":"#EF4444"},children:[W.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:W.command.type.replace(/_/g," ")})]})]})},W.id)),jsxRuntime.jsx("div",{ref:N})]}),jsxRuntime.jsxs("form",{onSubmit:Be,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:D,type:"text",value:f,onChange:W=>g(W.target.value),placeholder:B,disabled:k,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsxRuntime.jsx("button",{type:"submit",disabled:!f.trim()||k,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:f.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:f.trim()?"white":t.textSecondary},children:jsxRuntime.jsx(gf,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function Ld(e,t=50){let[a,r]=react.useState({past:[],present:e,future:[]}),o=react.useRef(false),s=react.useCallback((n,m=true)=>{r(d=>{let i=typeof n=="function"?n(d.present):n;if(o.current)return {...d,present:i};if(!m)return {...d,present:i};let u=[...d.past,d.present];return u.length>t&&u.shift(),{past:u,present:i,future:[]}});},[t]),l=react.useCallback(()=>{r(n=>{if(n.past.length===0)return n;let m=n.past[n.past.length-1],d=n.past.slice(0,n.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:m,future:[n.present,...n.future]}});},[]),c=react.useCallback(()=>{r(n=>{if(n.future.length===0)return n;let m=n.future[0],d=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:m,future:d}});},[]),p=react.useCallback(()=>{r(n=>({past:[],present:n.present,future:[]}));},[]);return {state:a.present,setState:s,undo:l,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function Fd({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){react.useEffect(()=>{if(!o)return;let s=l=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,p=c?l.metaKey:l.ctrlKey;if(p&&l.key==="z"&&!l.shiftKey&&a){l.preventDefault(),e();return}if(r){if(!c&&p&&l.key==="y"){l.preventDefault(),t();return}if(c&&p&&l.shiftKey&&l.key==="z"){l.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var kf={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${le.formatDate(e.startDate)} - ${le.formatDate(e.endDate)}`);let a=le.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=>le.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function Bd(e){return {...kf,...e}}var Ef=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},zd=react.forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:l="week",rowDensity:c="comfortable",showThemeSelector:p=true,showExportButton:n=true,availableUsers:m=[],templates:d,enableAutoCriticalPath:i=true,persistExpandedState:u,aiAssistant:x,locale:f="en",customTranslations:g,showCreateTaskButton:k=false,createTaskLabel:h,onCreateTask:b,onThemeChange:y,onTaskClick:D,onTaskDblClick:N,onTaskContextMenu:A,onTaskUpdate:v,onProgressChange:B,onTaskEdit:T,onTaskAddSubtask:w,onTaskMarkIncomplete:R,onTaskSetInProgress:M,onDependencyCreate:H,onDependencyDelete:X,onBeforeTaskAdd:fe,onAfterTaskAdd:xe,onBeforeTaskUpdate:Ae,onAfterTaskUpdate:Be,onBeforeTaskDelete:$,onAfterTaskDelete:F}=a,E=react.useContext(Ko)?.theme,[Y,J]=react.useState(E||s||"dark"),[U,De]=react.useState(l),[ke,$e]=react.useState(c),[he,et]=react.useState(1),[Pe,Qe]=react.useState(0),[ht,Dt]=react.useState(false),[lt,z]=react.useState(null),[oe,de]=react.useState({isOpen:false,x:0,y:0,task:null}),[Ce,Ee]=react.useState(null),[tt,mt]=react.useState(null);react.useEffect(()=>{E&&E!==Y&&J(E);},[E]),react.useEffect(()=>{s&&s!==Y&&J(s);},[s]);let Ie=react.useCallback(S=>{J(S),y?.(S);},[y]),{state:I,setState:q,undo:He,redo:Ue,canUndo:yt,canRedo:Q,clearHistory:ae}=Ld(t,50),ve=react.useCallback(()=>u?typeof u=="string"?u:"gantt-expanded-tasks":null,[u]),Te=react.useRef(new Map),ne=react.useRef(false);if(!ne.current&&u){ne.current=true;let S=typeof u=="string"?u:"gantt-expanded-tasks";try{let P=localStorage.getItem(S);if(P){let j=JSON.parse(P);Array.isArray(j)&&(Te.current=new Map(j));}}catch(P){console.warn("[GanttBoard] Error loading expanded state from localStorage:",P);}}let Se=react.useCallback(()=>{let S=ve();if(S)try{let P=Array.from(Te.current.entries());localStorage.setItem(S,JSON.stringify(P));}catch(P){console.warn("[GanttBoard] Error saving expanded state to localStorage:",P);}},[ve]);react.useEffect(()=>{let S=P=>P.map(j=>{let ee=Te.current.get(j.id),pe=ee!==void 0?{...j,isExpanded:ee}:j;return pe.subtasks?.length?{...pe,subtasks:S(pe.subtasks)}:pe});Te.current.size>0?q(S(t)):q(t);},[t,q]);let be=react.useRef(t),Ne=react.useRef(true);react.useEffect(()=>{if(Ne.current){Ne.current=false,be.current=I;return}if(!r)return;let S=JSON.stringify(be.current),P=JSON.stringify(I);S!==P&&(be.current=I,r(I));},[I,r]);let ie=react.useMemo(()=>Ds(f,g),[f,g]),Fe=react.useCallback(S=>[{id:"name",label:S.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:S.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:S.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:S.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:S.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:S.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:S.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:S.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Me,Re]=react.useState(()=>Fe(ie));react.useEffect(()=>{Re(S=>S.map(P=>({...P,label:ie.columns[P.id==="name"?"taskName":P.id]||P.label})));},[ie]);let Nt=react.useMemo(()=>Me.filter(P=>P.visible).reduce((P,j)=>P+j.width,0),[Me]),V=react.useRef(Me.filter(S=>S.visible).map(S=>S.id).join(","));react.useEffect(()=>{let S=Me.filter(ee=>ee.visible),P=S.map(ee=>ee.id).join(","),j=V.current;if(P!==j){let ee=S.some(we=>we.id!=="name"),pe=j.includes(",");ee?!pe&&ee&&z(null):z(null),V.current=P;}},[Me]);let Z=60,nt=.6,ye=react.useMemo(()=>{let P=Nt+Z,j=typeof window<"u"?window.innerWidth*nt:800,ee=Math.max(P,j);return lt!==null?Math.max(200,Math.min(lt,ee)):Math.max(200,P)},[lt,Nt]),We=react.useRef(null),Xt=react.useRef(null),O=react.useRef(null),K=react.useMemo(()=>Ql(Y),[Y]),Ve=react.useMemo(()=>({theme:K,themeName:Y}),[K,Y]),qe=react.useMemo(()=>Bd(d),[d]),ea=react.useMemo(()=>{if(!i)return I;let S=le.calculateCriticalPath(I),P=j=>j.map(ee=>({...ee,isCriticalPath:S.includes(ee.id),subtasks:ee.subtasks?P(ee.subtasks):void 0}));return P(I)},[I,i]),Oa=Ef(ke);Fd({undo:He,redo:Ue,canUndo:yt,canRedo:Q,enabled:true}),react.useImperativeHandle(o,()=>({getTask:S=>le.findTaskById(I,S),addTask:(S,P)=>{q(j=>{if(!P)return [...j,{...S,level:0}];let ee=pe=>pe.map(we=>we.id===P?{...we,subtasks:[...we.subtasks||[],{...S,parentId:P,level:(we.level||0)+1}],isExpanded:true}:we.subtasks?{...we,subtasks:ee(we.subtasks)}:we);return ee(j)});},updateTask:(S,P)=>{q(j=>{let ee=pe=>pe.map(we=>we.id===S?{...we,...P}:we.subtasks?{...we,subtasks:ee(we.subtasks)}:we);return ee(j)});},deleteTask:S=>{q(P=>{let j=ee=>ee.filter(pe=>pe.id===S?false:(pe.subtasks&&(pe.subtasks=j(pe.subtasks)),true));return j(P)});},deleteTasks:S=>{q(P=>Is(P,S));},duplicateTask:S=>{q(P=>Ls(P,[S]));},splitTask:(S,P,j=3)=>{q(ee=>le.splitTask(ee,S,P,j));},calculateEndDate:le.calculateEndDate,calculateDuration:le.calculateDuration,validateDependency:(S,P)=>!le.validateDependencies(I,S,P),getAllTasks:()=>le.flattenTasks(I),getTasksByStatus:S=>le.flattenTasks(I).filter(P=>P.status===S),getTasksByParent:S=>S?le.findTaskById(I,S)?.subtasks||[]:I.filter(j=>!j.parentId),getCriticalPath:()=>le.flattenTasks(I).filter(S=>S.isCriticalPath),indentTask:S=>{q(P=>Ps(P,[S]));},outdentTask:S=>{q(P=>Ms(P,[S]));},moveTask:(S,P)=>{q(j=>As(j,[S],P));},createSubtask:async S=>{let{tasks:P,newTask:j}=Rs(I,S);if(fe){let ee=fe({...j,parentId:S});if((ee instanceof Promise?await ee:ee)===false)return}q(P),xe&&xe({...j,parentId:S});},scrollToTask:S=>{let j=le.flattenTasks(I).findIndex(ee=>ee.id===S);if(j!==-1&&We.current){let ee=j*Oa;We.current.scrollTo({top:ee,behavior:"smooth"}),Xt.current&&Xt.current.scrollTo({top:ee,behavior:"smooth"});}},highlightTask:(S,P=2e3)=>{},expandTask:S=>{q(P=>{let j=ee=>ee.map(pe=>pe.id===S?{...pe,isExpanded:true}:pe.subtasks?{...pe,subtasks:j(pe.subtasks)}:pe);return j(P)});},collapseTask:S=>{q(P=>{let j=ee=>ee.map(pe=>pe.id===S?{...pe,isExpanded:false}:pe.subtasks?{...pe,subtasks:j(pe.subtasks)}:pe);return j(P)});},expandAll:()=>{q(S=>{let P=j=>j.map(ee=>({...ee,isExpanded:true,subtasks:ee.subtasks?P(ee.subtasks):void 0}));return P(S)});},collapseAll:()=>{q(S=>{let P=j=>j.map(ee=>({...ee,isExpanded:false,subtasks:ee.subtasks?P(ee.subtasks):void 0}));return P(S)});},undo:He,redo:Ue,canUndo:()=>yt,canRedo:()=>Q,clearHistory:ae,exportToPNG:async()=>{if(!O.current)throw new Error("Gantt container not found");let S=await Od__default.default(O.current,{backgroundColor:K.bgPrimary,scale:2});return new Promise((P,j)=>{S.toBlob(ee=>{ee?P(ee):j(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async S=>{await le.exportToPDF(I,S);},exportToExcel:async S=>{await le.exportToExcel(I,S);},exportToJSON:()=>le.exportToJSON(I),exportToCSV:()=>le.exportToCSV(I),importFromJSON:S=>{let P=le.importFromJSON(S);q(P);},getTasks:()=>I,refresh:()=>{q(S=>[...S]);},clearAll:()=>{q([]);}}),[I,He,Ue,yt,Q,ae,K,Oa]);let qa=react.useCallback(S=>{Re(P=>P.map(j=>j.id===S?{...j,visible:!j.visible}:j));},[]),Jr=react.useCallback((S,P)=>{Re(j=>j.map(ee=>{if(ee.id!==S)return ee;let pe=ee.minWidth??100,we=ee.maxWidth??800,Ot=Math.max(pe,Math.min(we,P));return {...ee,width:Ot}}));},[]),ce=react.useCallback(S=>{q(P=>{let j=Bs(P,S),ee=pe=>{for(let we of pe){if(we.id===S){Te.current.set(S,we.isExpanded??true);return}we.subtasks?.length&&ee(we.subtasks);}};return ee(j),Se(),j}),a.onTaskToggleExpand?.(S);},[a,Se]),ut=react.useCallback((S,P)=>{if(Ae&&Ae(S,P)===false)return;let ee=le.findTaskById(I,S)?.progress,pe=Ot=>Ot.map(Gt=>Gt.id===S?{...Gt,...P}:Gt.subtasks?{...Gt,subtasks:pe(Gt.subtasks)}:Gt);q(pe(I));let we=le.findTaskById(pe(I),S);we&&(v?.(we),Be?.(we),P.progress!==void 0&&ee!==void 0&&P.progress!==ee&&B?.(S,ee,P.progress));},[I,v,Ae,Be,B]),Jt=react.useCallback(S=>{S.length!==0&&(q(P=>Ps(P,S)),a.onTaskIndent?.(S[0]));},[a]),Mr=react.useCallback(S=>{S.length!==0&&(q(P=>Ms(P,S)),a.onTaskOutdent?.(S[0]));},[a]),Eo=react.useCallback((S,P,j)=>{q(ee=>vd(ee,S,P,j)),a.onTaskReparent?.(S,P,j);},[a]),Ar=react.useCallback((S,P)=>{S.length!==0&&(q(j=>As(j,S,P)),a.onTaskMove?.(S[0],P));},[a]),Da=react.useCallback(async S=>{let P=[];for(let j of S)$&&await Promise.resolve($(j))===false||P.push(j);P.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(P):(q(j=>Is(j,P)),P.forEach(j=>a.onTaskDelete?.(j))),F&&P.forEach(j=>F(j)));},[a,$,F]),dr=react.useCallback(S=>{q(P=>Ls(P,S)),S.forEach(P=>a.onTaskDuplicate?.(P));},[a]),Bt=react.useCallback((S,P)=>{q(j=>{let{tasks:ee,newTask:pe}=yd(j,S,P);return fe&&fe(pe)===false?j:(a.onTaskCreate?.(pe.parentId,pe.position||0),xe?.(pe),ee)});},[a,fe,xe]),An=react.useCallback((S,P)=>{q(j=>Fs(j,S,P)),a.onTaskRename?.(S,P);},[a]),Zr=react.useCallback(S=>{q(P=>{let{tasks:j}=Rs(P,S);return a.onTaskCreate?.(S,0),j});},[a]),Oi=react.useCallback((S,P,j)=>{let ee=S.startDate?Math.round((P.getTime()-S.startDate.getTime())/864e5):0,pe=Gt=>Gt.map(Zt=>Zt.id===S.id?{...Zt,startDate:P,endDate:j,...S.segments&&{segments:S.segments}}:Zt.subtasks?{...Zt,subtasks:pe(Zt.subtasks)}:Zt),we=pe(I);we=le.autoScheduleDependents(we,S.id,ee),q(we);let Ot={...S,startDate:P,endDate:j};v?.(Ot);},[I,v]),Qr=react.useCallback((S,P)=>{A?.(S,P),de({isOpen:true,x:P.clientX,y:P.clientY,task:S});},[A]),Zc=react.useCallback((S,P)=>{let j=le.splitTask(I,S.id,P);q(j),de({isOpen:false,x:0,y:0,task:null});},[I]),zi=react.useCallback(S=>{let P=le.findTaskById(I,S.id)||S;N?.(P),T||Ee(P);},[I,N,T]),$i=react.useCallback((S,P,j)=>{let ee=new Map,pe=Na=>{Na.forEach(Ga=>{Ga.dependencies&&ee.set(Ga.id,Ga.dependencies),Ga.subtasks&&pe(Ga.subtasks);});};pe(j);let we=ee.get(P)||[];ee.set(P,[...we,S]);let Ot=new Set,Gt=new Set,Zt=Na=>{if(!Ot.has(Na)){Ot.add(Na),Gt.add(Na);let Ga=ee.get(Na)||[];for(let cr of Ga){if(!Ot.has(cr)&&Zt(cr))return true;if(Gt.has(cr))return true}}return Gt.delete(Na),false};return Zt(P)},[]),Ui=react.useCallback((S,P)=>{if($i(S.id,P,I)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
|
|
342
|
+
</Project>`,m=new Blob([n],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(m),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=le.flattenTasks(e),a=t.filter(n=>n.startDate&&n.endDate);if(a.length===0)return [];let r=new Map,o=n=>{if(r.has(n.id))return;let m=n.startDate&&n.endDate?le.calculateDuration(n.startDate,n.endDate):0,d=0;if(n.dependencies&&n.dependencies.length>0)for(let u of n.dependencies){let x=t.find(f=>f.id===u);if(x){o(x);let f=r.get(u)?.ef||0;d=Math.max(d,f);}}let i=d+m;r.set(n.id,{es:d,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(n=>n.ef)),l=new Map,c=n=>{if(l.has(n.id))return;let m=n.startDate&&n.endDate?le.calculateDuration(n.startDate,n.endDate):0,d=t.filter(x=>x.dependencies&&x.dependencies.includes(n.id)),i=s;if(d.length>0)for(let x of d){c(x);let f=l.get(x.id)?.ls||0;i=Math.min(i,f);}let u=i-m;l.set(n.id,{ls:u,lf:i});};a.forEach(c);let p=[];for(let n of a){let m=r.get(n.id),d=l.get(n.id);if(m&&d){let i=d.ls-m.es;Math.abs(i)<.01&&p.push(n.id);}}return p},calculateSlack:(e,t)=>{let a=le.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(le.calculateCriticalPath(e).includes(t))return 0;let o=le.getDependentTasks(e,t);if(o.length===0){let c=le.getLatestEndDate(e);if(!c)return null;let p=le.calculateDuration(a.endDate,c);return Math.max(0,p)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,p)=>c-p)[0];if(!s)return null;let l=le.calculateDuration(a.endDate,new Date(s));return Math.max(0,l)},isOnCriticalPath:(e,t)=>le.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=le.findTaskById(e,t);if(!r||!r.endDate)return e;let o=le.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let l of o){if(!l.startDate||!l.endDate)continue;let c=le.calculateDuration(l.startDate,l.endDate),p;a!==void 0?(p=new Date(l.startDate),p.setDate(p.getDate()+a)):(p=new Date(r.endDate),p.setDate(p.getDate()+1));let n=le.calculateEndDate(p,c),m=d=>d.map(i=>i.id===l.id?{...i,startDate:p,endDate:n}:i.subtasks?{...i,subtasks:m(i.subtasks)}:i);s=m(s),s=le.autoScheduleDependents(s,l.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,l,c)=>{if(a===0)return [];let p=[],n=o.getTime(),m=1e3*60*60*24,d=le.findTaskById(e,t);if(!d||!d.endDate)return [];let i=(u,x,f=new Set)=>{if(f.has(u))return;f.add(u);let g=le.getDependentTasks(e,u);for(let k of g){if(!k.startDate||!k.endDate)continue;let h=r.findIndex(w=>w.id===k.id);if(h===-1)continue;let b=k.startDate.getTime(),D=(k.endDate.getTime()-b)/m,A=(b-n)/m*s,v=A+x*s,B=Math.max(D*s,s),T=c+h*l+12;p.push({taskId:k.id,taskName:k.name,originalX:A,previewX:v,width:B,y:T,rowIndex:h,daysDelta:x,color:k.color}),i(k.id,x,f);}};return i(t,a),p},splitTask:(e,t,a,r=3)=>{let o=le.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let l=new Date(a);l.setDate(l.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let p=[{startDate:new Date(o.startDate),endDate:s},{startDate:l,endDate:c}],n=m=>m.map(d=>d.id===o.id?{...d,endDate:c,segments:p}:d.subtasks?{...d,subtasks:n(d.subtasks)}:d);return n(e)}};function ln({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:l,templates:c,onTaskClick:p,onTaskDblClick:n,onTaskContextMenu:m,onTaskDateChange:d,onDependencyCreate:i,onDependencyDelete:u}){let[f,g]=react.useState([]),[k,h]=react.useState(null),[b,y]=react.useState(null),D=react.useCallback($=>{h($);},[]),N=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),A=r==="day"?60:r==="week"?20:8,v=N*A*l,B=$=>{let F=new Date(Date.UTC($.getFullYear(),$.getMonth(),$.getDate())),W=F.getUTCDay()||7;F.setUTCDate(F.getUTCDate()+4-W);let E=new Date(Date.UTC(F.getUTCFullYear(),0,1));return Math.ceil(((F.getTime()-E.getTime())/864e5+1)/7)},T=$=>{let F=$.getDay();return F===0||F===6},w=react.useCallback($=>{let F=Math.round($/(A*l)),W=new Date(o);return W.setDate(W.getDate()+F),W},[o,A,l]),R=react.useCallback(($,F)=>{if(F.startDate&&F.endDate)return;let W=$.currentTarget.ownerSVGElement;if(!W)return;let E=W.createSVGPoint();E.x=$.clientX,E.y=$.clientY;let Y=E.matrixTransform(W.getScreenCTM()?.inverse()),J=w(Y.x),U=new Date(J);U.setDate(U.getDate()+1),d?.(F,J,U);},[w,d]),M=react.useMemo(()=>{let $=Y=>Y.map(J=>{if(J.subtasks&&J.subtasks.length>0){let U=$(J.subtasks),De=U.filter(ke=>ke.startDate&&ke.endDate);if(De.length>0){let ke=De.map(Pe=>Pe.startDate.getTime()),$e=De.map(Pe=>Pe.endDate.getTime()),he=new Date(Math.min(...ke)),et=new Date(Math.max(...$e));return {...J,subtasks:U,startDate:he,endDate:et}}return {...J,subtasks:U}}return J}),F=(Y,J=[])=>{for(let U of Y)J.push(U),U.subtasks&&U.subtasks.length>0&&(U.isExpanded===void 0||U.isExpanded)&&F(U.subtasks,J);return J},W=$(e);return F(W)},[e]),H=react.useCallback($=>{if(!$.startDate||!$.endDate)return {x:0,width:0};let F=$.startDate.getTime(),W=$.endDate.getTime(),E=o.getTime(),Y=(F-E)/(1e3*60*60*24),J=(W-F)/(1e3*60*60*24),U=Y*A*l,De=Math.max(A*l,40),ke=Math.max(J*A*l,De);return {x:U,width:ke}},[o,A,l]),X=react.useMemo(()=>M.filter($=>$.startDate&&$.endDate).map($=>{let{x:F,width:W}=H($),Y=M.findIndex(J=>J.id===$.id)*a+12;return {id:$.id,x:F,y:Y,width:W,height:32}}),[M,H]),fe=react.useCallback(($,F,W)=>{if(!W||F===0){g([]);return}let E=le.calculateCascadePreview(e,$,F,M,o,A*l,a,48);g(E);},[e,M,o,A,l,a,48]),xe=react.useMemo(()=>{let $=[],F=new Date(o);for(;F<=s;){let Y=(F.getTime()-o.getTime())/864e5*A*l;if(r==="day")$.push({date:new Date(F),label:F.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:Y}),F.setDate(F.getDate()+1);else if(r==="week"){let J=B(F);$.push({date:new Date(F),label:`Week ${J}`,x:Y}),F.setDate(F.getDate()+7);}else $.push({date:new Date(F),label:F.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:Y}),F.setMonth(F.getMonth()+1);}return $},[o,s,r,A,l]),Ae=react.useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*A*l,[o,A,l]),Be=Math.max(M.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(v,1e3),height:47,style:{display:"block"},children:[jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(v,1e3),height:48,fill:t.bgGrid}),xe.map(($,F)=>jsxRuntime.jsxs("g",{children:[F>0&&jsxRuntime.jsx("line",{x1:$.x,y1:0,x2:$.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsxRuntime.jsx("text",{x:$.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:$.label})]},`header-${F}`)),Ae>=0&&Ae<=v&&jsxRuntime.jsx("circle",{cx:Ae,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(v,1e3),height:Be,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(v,1e3),height:Be,fill:t.bgPrimary}),xe.map(($,F)=>{let W=xe[F+1]?.x||v,E=T($.date);return jsxRuntime.jsxs("g",{children:[E&&jsxRuntime.jsx("rect",{x:$.x,y:0,width:W-$.x,height:M.length*a,fill:t.bgWeekend,opacity:1}),F>0&&jsxRuntime.jsx("line",{x1:$.x,y1:0,x2:$.x,y2:M.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},F)}),M.map(($,F)=>{let W=$.startDate&&$.endDate;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:0,y:F*a,width:v,height:a,fill:F%2===0?t.bgPrimary:t.bgGrid,opacity:1,style:{pointerEvents:"none"}},`row-${$.id}`),!W&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:0,y:F*a,width:v,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:E=>R(E,$),onMouseEnter:E=>{E.currentTarget.setAttribute("fill",t.accentLight),E.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:E=>{E.currentTarget.setAttribute("fill","transparent"),E.currentTarget.setAttribute("opacity","1");}},`clickable-${$.id}`),jsxRuntime.jsx("text",{x:Ae>0?Ae:100,y:F*a+a/2,fill:t.textTertiary,fontSize:"12",fontFamily:"Inter, sans-serif",fontStyle:"italic",dominantBaseline:"middle",opacity:.4,style:{pointerEvents:"none",userSelect:"none"},children:"Click to set dates..."},`placeholder-${$.id}`)]})]},`row-group-${$.id}`)}),M.map(($,F)=>!$.dependencies||$.dependencies.length===0||!$.startDate||!$.endDate?null:$.dependencies.map(W=>{let E=M.find(De=>De.id===W);if(!E||!E.startDate||!E.endDate)return null;let Y=M.findIndex(De=>De.id===W),J=H(E),U=H($);return jsxRuntime.jsx(rn,{x1:J.x+J.width,y1:Y*a+a/2,x2:U.x,y2:F*a+a/2,theme:t},`dep-${W}-${$.id}`)})),M.map(($,F)=>{if(!$.startDate||!$.endDate)return null;let{x:W,width:E}=H($),Y=F*a+12,J=$.subtasks&&$.subtasks.length>0&&!$.isMilestone;return $.isMilestone?jsxRuntime.jsx(nn,{task:$,x:W+E/2,y:Y+16,theme:t,onClick:p},$.id):J?jsxRuntime.jsxs("g",{onClick:()=>p?.($),onContextMenu:U=>{U.preventDefault(),U.stopPropagation(),m?.($,U);},style:{cursor:"default"},children:[jsxRuntime.jsx("rect",{x:W,y:Y,width:E,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:W,y1:Y,x2:W+E,y2:Y,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:W,y1:Y,x2:W,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:W+E,y1:Y,x2:W+E,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:W,y1:Y+32,x2:W+E,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),E>60&&jsxRuntime.jsx("text",{x:W+12,y:Y+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:$.name})]},$.id):jsxRuntime.jsx(en,{task:$,x:W,y:Y,width:E,theme:t,dayWidth:A*l,startDate:o,templates:c,onClick:p,onDoubleClick:n,onContextMenu:m,onDateChange:d,onDependencyCreate:i,allTaskPositions:X,onDragMove:fe,onHoverChange:D},$.id)}),M.map(($,F)=>!$.dependencies||$.dependencies.length===0||!$.startDate||!$.endDate?null:$.dependencies.map(W=>{let E=M.find(de=>de.id===W);if(!E||!E.startDate||!E.endDate)return null;let Y=M.findIndex(de=>de.id===W),J=H(E),U=H($),De=J.x+J.width,ke=Y*a+a/2,$e=U.x,he=F*a+a/2,et=$e-De,Pe=De+et/2,Qe=de=>{let Ce=1-de,Ee=Ce*Ce,tt=Ee*Ce,mt=de*de,Ie=mt*de,I=tt*De+3*Ee*de*Pe+3*Ce*mt*Pe+Ie*$e,q=tt*ke+3*Ee*de*ke+3*Ce*mt*he+Ie*he;return {x:I,y:q}},ht=20,Dt=[];for(let de=0;de<=ht;de++){let Ce=.1+de/ht*.8;Dt.push(Qe(Ce));}let lt=Dt[0],z=`M ${lt.x} ${lt.y} `+Dt.slice(1).map(de=>`L ${de.x} ${de.y}`).join(" ");return b&&b.x1===De&&b.y1===ke&&b.x2===$e&&b.y2===he?null:jsxRuntime.jsx("path",{d:z,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:()=>{y({x1:De,y1:ke,x2:$e,y2:he,onDelete:()=>u?.($.id,W)});}},`dep-hover-${W}-${$.id}`)})),f.map($=>jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("rect",{x:$.previewX,y:$.y-48,width:$.width,height:32,rx:8,fill:$.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs($.daysDelta)>0&&jsxRuntime.jsx("text",{x:$.previewX+$.width/2,y:$.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:$.daysDelta>0?`+${$.daysDelta}d`:`${$.daysDelta}d`})]},`cascade-preview-${$.taskId}`)),b&&(()=>{let{x1:$,y1:F,x2:W,y2:E,onDelete:Y}=b,J=W-$,U=E-F,De=$+J/2,ke=(F+E)/2,$e=`M ${$} ${F} C ${De} ${F}, ${De} ${E}, ${W} ${E}`,he=6,et=Math.atan2(U,J),Pe=W-he*Math.cos(et-Math.PI/6),Qe=E-he*Math.sin(et-Math.PI/6),ht=W-he*Math.cos(et+Math.PI/6),Dt=E-he*Math.sin(et+Math.PI/6),lt=t.dependency,z="#f87171";return jsxRuntime.jsxs("g",{onMouseLeave:()=>y(null),children:[jsxRuntime.jsx("path",{d:$e,fill:"none",stroke:"transparent",strokeWidth:50,strokeLinecap:"round",style:{cursor:"pointer"}}),jsxRuntime.jsx("circle",{cx:De,cy:ke,r:25,fill:"transparent",style:{cursor:"pointer"}}),jsxRuntime.jsx("path",{d:$e,fill:"none",stroke:lt,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsxRuntime.jsx("path",{d:$e,fill:"none",stroke:lt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("path",{d:`M ${W} ${E} L ${Pe} ${Qe} M ${W} ${E} L ${ht} ${Dt}`,fill:"none",stroke:lt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("circle",{cx:W,cy:E,r:4,fill:lt,opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsxs(framerMotion.motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:de=>{de.stopPropagation(),y(null),Y();},style:{cursor:"pointer"},children:[jsxRuntime.jsx("circle",{cx:De,cy:ke,r:9,fill:"rgba(248, 113, 113, 0.15)",stroke:z,strokeWidth:1.5,style:{transition:"all 0.15s ease"}}),jsxRuntime.jsx("line",{x1:De-3,y1:ke-3,x2:De+3,y2:ke+3,stroke:z,strokeWidth:1.5,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:De+3,y1:ke-3,x2:De-3,y2:ke+3,stroke:z,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),Ae>=0&&Ae<=v&&jsxRuntime.jsx("line",{x1:Ae,y1:0,x2:Ae,y2:Be,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),k&&jsxRuntime.jsx(Sd,{tooltipData:k,theme:t})]})]})}var dn=[{name:"Azul",value:"#6366F1",light:"#818CF8"},{name:"P\xFArpura",value:"#A855F7",light:"#C084FC"},{name:"Rosa",value:"#EC4899",light:"#F472B6"},{name:"Rojo",value:"#EF4444",light:"#F87171"},{name:"Naranja",value:"#F59E0B",light:"#FBBF24"},{name:"Amarillo",value:"#EAB308",light:"#FACC15"},{name:"Lima",value:"#84CC16",light:"#A3E635"},{name:"Verde",value:"#10B981",light:"#34D399"},{name:"Esmeralda",value:"#059669",light:"#10B981"},{name:"Cyan",value:"#06B6D4",light:"#22D3EE"},{name:"Azul Cielo",value:"#0EA5E9",light:"#38BDF8"},{name:"\xCDndigo",value:"#4F46E5",light:"#6366F1"},{name:"Violeta",value:"#8B5CF6",light:"#A78BFA"},{name:"Fucsia",value:"#D946EF",light:"#E879F9"},{name:"Coral",value:"#F97316",light:"#FB923C"},{name:"Magenta",value:"#E11D48",light:"#FB7185"}];var Ws=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],Hs=[{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 cn({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:l=false,mode:c=a?"edit":"create",theme:p="dark",customStatuses:n=[],availableTags:m=[],onCreateTag:d,attachments:i=[],onUploadAttachments:u,onDeleteAttachment:x}){let f=[...Ws,...n.filter(z=>!Ws.some(oe=>oe.id===z.id))],g=Ge[p]||Ge.dark,[k,h]=react.useState(false),[b,y]=react.useState(false),[D,N]=react.useState(false),[A,v]=react.useState(false),[B,T]=react.useState({top:0,left:0}),[w,R]=react.useState(null),[M,H]=react.useState(new Date),[X,fe]=react.useState({top:0,left:0}),[xe,Ae]=react.useState(false),[Be,$]=react.useState([]),F=react.useRef(null),W=react.useRef(null),E=react.useRef(null),Y=react.useRef(null),J=react.useRef(null),[U,De]=react.useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[ke,$e]=react.useState({});react.useEffect(()=>{a?(De({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)&&Ae(true)):(De({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),Ae(false),$([]));},[a,e]),react.useEffect(()=>{let z=oe=>{F.current&&!F.current.contains(oe.target)&&h(false),W.current&&!W.current.contains(oe.target)&&y(false),E.current&&!E.current.contains(oe.target)&&N(false),Y.current&&!Y.current.contains(oe.target)&&v(false);};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]);let he=()=>{let z={};return U.name.trim()||(z.name="El nombre es requerido"),U.startDate&&U.endDate&&U.startDate>U.endDate&&(z.endDate="La fecha de fin debe ser posterior a la de inicio"),$e(z),Object.keys(z).length===0},et=async z=>{if(z.preventDefault(),!!he())try{let oe=c==="create"&&Be.length>0?{...U,pendingFiles:Be}:U;await s(oe),$([]),t();}catch(oe){console.error("Error submitting task:",oe);}},Pe=(z,oe)=>{De(de=>{let Ce={...de,[z]:oe};if(z==="status"){let Ee=oe;Ee==="todo"?Ce.progress=0:Ee==="in-progress"?(de.progress===0||de.progress===100)&&(Ce.progress=50):Ee==="completed"||Ee==="closed"?Ce.progress=100:(Ee==="in-review"||Ee==="review")&&(Ce.progress=75);}if(z==="progress"){let Ee=typeof oe=="number"?oe:parseInt(oe,10);Ee===100&&de.status!=="completed"?Ce.status="completed":Ee>0&&Ee<100&&de.status==="todo"?Ce.status="in-progress":Ee===0&&de.status!=="todo"&&(Ce.status="todo");}return Ce}),ke[z]&&$e(de=>{let Ce={...de};return delete Ce[z],Ce});},Qe=f.find(z=>z.id===U.status)??Ws[0],ht=Hs.find(z=>z.id===U.priority)??Hs[1],Dt=dn.find(z=>z.value===U.color)??dn[0],lt={backgroundColor:g.bgSecondary,border:`1px solid ${g.borderLight}`,color:g.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:g.bgPrimary,border:`1px solid ${g.border}`},onClick:z=>z.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${g.border}`},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Qe.color||g.accent}}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:g.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsxRuntime.jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:g.textTertiary},onMouseEnter:z=>{z.currentTarget.style.backgroundColor=g.hoverBg,z.currentTarget.style.color=g.textPrimary;},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="transparent",z.currentTarget.style.color=g.textTertiary;},disabled:l,children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:et,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:U.name,onChange:z=>Pe("name",z.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:g.textPrimary},placeholder:"Nombre de la tarea",disabled:l,autoFocus:true}),ke.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"}),ke.name]})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("textarea",{value:U.description||"",onChange:z=>Pe("description",z.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:g.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:l})}),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${g.borderLight}`}}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxRuntime.jsxs("div",{ref:F,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!l&&h(!k),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...lt,borderColor:Qe.color,backgroundColor:`${Qe.color}15`},disabled:l,children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:Qe.color}}),jsxRuntime.jsx("span",{style:{color:Qe.color},children:Qe.title}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:Qe.color}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:k&&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:g.bgPrimary,border:`1px solid ${g.border}`},children:f.map(z=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:oe=>oe.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:oe=>oe.currentTarget.style.backgroundColor="transparent",onClick:()=>{Pe("status",z.id),h(false);},children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:z.color}}),z.title,U.status===z.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:g.accent}})]},z.id))})})]}),jsxRuntime.jsxs("div",{ref:W,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!l&&y(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:lt,disabled:l,children:[jsxRuntime.jsx(lucideReact.Flag,{className:"w-3.5 h-3.5",style:{color:ht.color}}),jsxRuntime.jsx("span",{children:ht.label}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),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-[130px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},children:Hs.map(z=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:oe=>oe.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:oe=>oe.currentTarget.style.backgroundColor="transparent",onClick:()=>{Pe("priority",z.id),y(false);},children:[jsxRuntime.jsx("span",{children:z.icon}),z.label,U.priority===z.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:g.accent}})]},z.id))})})]}),o.length>0&&jsxRuntime.jsxs("div",{ref:E,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!l&&N(!D),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:lt,disabled:l,children:[U.assignees&&U.assignees.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex -space-x-1",children:U.assignees.slice(0,3).map((z,oe)=>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:z.color||g.accent,borderColor:g.bgSecondary},children:z.initials},oe))}),U.assignees.length>3&&jsxRuntime.jsxs("span",{style:{color:g.textTertiary},children:["+",U.assignees.length-3]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Users,{className:"w-3.5 h-3.5",style:{color:g.textTertiary}}),jsxRuntime.jsx("span",{style:{color:g.textTertiary},children:"Asignar"})]}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:D&&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:g.bgPrimary,border:`1px solid ${g.border}`},children:o.map(z=>{let oe=U.assignees?.some(de=>de.name===z.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:g.textPrimary},onMouseEnter:de=>de.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:de=>de.currentTarget.style.backgroundColor="transparent",onClick:()=>{let de=oe?(U.assignees||[]).filter(Ce=>Ce.name!==z.name):[...U.assignees||[],{name:z.name,avatar:z.avatar,initials:z.name.split(" ").map(Ce=>Ce[0]).join("").toUpperCase().slice(0,2),color:g.accent}];Pe("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:g.accent},children:z.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"truncate flex-1 text-left",children:z.name}),jsxRuntime.jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:oe&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5",style:{color:g.accent}})})]},z.id)})})})]}),jsxRuntime.jsxs("div",{ref:Y,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{if(!l)if(A)v(false);else {if(Y.current){let z=Y.current.getBoundingClientRect(),oe=window.innerHeight,de=120,Ee=oe-z.bottom<de?z.top-de-8:z.bottom+8;T({top:Ee,left:z.left});}v(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:lt,disabled:l,children:[jsxRuntime.jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:U.color}}),jsxRuntime.jsx("span",{children:Dt.name}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:A&&jsxRuntime.jsxs(at,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>v(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:`${B.top}px`,left:`${B.left}px`,zIndex:99999,backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick:z=>z.stopPropagation(),children:jsxRuntime.jsx("div",{style:{padding:"6px 8px"},children:jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 28px)",gap:"2px"},children:dn.slice(0,18).map(z=>{let oe=U.color===z.value;return jsxRuntime.jsx("button",{type:"button",onClick:de=>{de.preventDefault(),de.stopPropagation(),Pe("color",z.value),v(false);},style:{width:"28px",height:"28px",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",border:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0},title:z.name,children:jsxRuntime.jsx("span",{style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:z.value,outline:oe?`2px solid ${z.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},z.value)})})})})]})})]}),m.length>0||d?jsxRuntime.jsx(zr,{selectedTags:U.tags||[],availableTags:m,onChange:z=>Pe("tags",z),onCreateTag:d,theme:g,disabled:l}):null]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Calendar,{className:"w-4 h-4",style:{color:g.textTertiary}}),jsxRuntime.jsxs("div",{ref:J,className:"flex items-center gap-2 flex-1 relative",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!l&&!U.isMilestone)if(w==="start")R(null);else {if(J.current){let z=J.current.getBoundingClientRect(),oe=window.innerHeight,de=320,Ee=oe-z.bottom<de?z.top-de-8:z.bottom+8;fe({top:Ee,left:z.left});}R("start"),H(U.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...lt,opacity:U.isMilestone?.5:1,cursor:U.isMilestone?"not-allowed":"pointer"},disabled:l||U.isMilestone,children:U.startDate?U.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsxRuntime.jsx("span",{style:{color:g.textTertiary},children:"\u2192"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!l&&!U.isMilestone)if(w==="end")R(null);else {if(J.current){let z=J.current.getBoundingClientRect(),oe=window.innerHeight,de=320,Ee=oe-z.bottom<de?z.top-de-8:z.bottom+8;fe({top:Ee,left:z.left});}R("end"),H(U.endDate||U.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...lt,opacity:U.isMilestone?.5:1,cursor:U.isMilestone?"not-allowed":"pointer"},disabled:l||U.isMilestone,children:U.endDate?U.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:w&&jsxRuntime.jsxs(at,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>R(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:`${X.top}px`,left:`${X.left}px`,zIndex:99999,backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},onClick:z=>z.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${g.border}`},children:[(()=>{let z=new Date,oe=new Date(z);oe.setDate(z.getDate()+1);let de=new Date(z);de.setDate(z.getDate()+7);let Ce=new Date(z);return Ce.setDate(z.getDate()+14),[{label:"Hoy",date:z},{label:"Ma\xF1ana",date:oe},{label:"Pr\xF3xima semana",date:de},{label:"2 semanas",date:Ce}].map((tt,mt)=>jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:g.textPrimary},onMouseEnter:Ie=>Ie.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:Ie=>Ie.currentTarget.style.backgroundColor="transparent",onClick:()=>{w==="start"?(Pe("startDate",tt.date),(!U.endDate||tt.date>U.endDate)&&Pe("endDate",tt.date),R("end")):(Pe("endDate",tt.date),(!U.startDate||tt.date<U.startDate)&&Pe("startDate",tt.date),R(null));},children:tt.label},mt))})(),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${g.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:z=>z.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:z=>z.currentTarget.style.backgroundColor="transparent",onClick:()=>{Pe("startDate",void 0),Pe("endDate",void 0),R(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:()=>H(new Date(M.getFullYear(),M.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"w-4 h-4",style:{color:g.textSecondary}})}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:g.textPrimary},children:M.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>H(new Date(M.getFullYear(),M.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4",style:{color:g.textSecondary}})})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((z,oe)=>jsxRuntime.jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:g.textTertiary},children:z},oe))}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let z=M.getFullYear(),oe=M.getMonth(),de=new Date(z,oe,1).getDay(),Ce=new Date(z,oe+1,0).getDate(),Ee=new Date,tt=[];for(let Ie=de-1;Ie>=0;Ie--)tt.push({day:new Date(z,oe,-Ie).getDate(),date:new Date(z,oe-1,new Date(z,oe,-Ie).getDate()),isCurrentMonth:false});for(let Ie=1;Ie<=Ce;Ie++)tt.push({day:Ie,date:new Date(z,oe,Ie),isCurrentMonth:true});let mt=42-tt.length;for(let Ie=1;Ie<=mt;Ie++)tt.push({day:Ie,date:new Date(z,oe+1,Ie),isCurrentMonth:false});return tt.map((Ie,I)=>{let q=Ie.date.toDateString()===Ee.toDateString(),He=U.startDate?.toDateString()===Ie.date.toDateString(),Ue=U.endDate?.toDateString()===Ie.date.toDateString(),yt=U.startDate&&U.endDate&&Ie.date>=U.startDate&&Ie.date<=U.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:Ie.isCurrentMonth?He||Ue?"#FFF":g.textPrimary:g.textTertiary,backgroundColor:He?"#3B82F6":Ue?"#7C3AED":yt?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:q&&!He&&!Ue?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{w==="start"?(Pe("startDate",Ie.date),U.endDate&&Ie.date>U.endDate&&Pe("endDate",Ie.date),R("end")):(Pe("endDate",Ie.date),U.startDate&&Ie.date<U.startDate&&Pe("startDate",Ie.date),R(null));},children:Ie.day},I)})})()})]})]})]})})]}),ke.endDate&&jsxRuntime.jsx("span",{className:"text-xs text-red-400",children:ke.endDate})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-4 h-4",style:{color:g.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:U.progress,onChange:z=>Pe("progress",parseInt(z.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:g.bgSecondary,accentColor:U.progress<30?"#EF4444":U.progress<70?"#F59E0B":"#10B981"},disabled:l}),jsxRuntime.jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${U.progress<30?"#EF4444":U.progress<70?"#F59E0B":"#10B981"}20`,color:U.progress<30?"#EF4444":U.progress<70?"#F59E0B":"#10B981"},children:[U.progress,"%"]})]})]}),(u||i.length>0||c==="create")&&jsxRuntime.jsxs("div",{className:"pt-2",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:g.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:g.textTertiary},children:["Adjuntos ",c==="create"?Be.length>0&&`(${Be.length})`:i.length>0&&`(${i.length})`]})]}),c==="create"?jsxRuntime.jsx(Ua,{cardId:"pending",attachments:Be.map((z,oe)=>({id:`pending-${oe}`,cardId:"pending",name:z.name,size:z.size,type:z.type,url:URL.createObjectURL(z),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:z=>$(oe=>[...oe,...z]),onDelete:z=>{let oe=parseInt(z.replace("pending-",""),10);$(de=>de.filter((Ce,Ee)=>Ee!==oe));},maxSizeMB:10,maxFiles:20}):jsxRuntime.jsx(Ua,{cardId:a?.id||"new",attachments:i,onUpload:u&&a?.id?z=>u(a.id,z):void 0,onDelete:x,maxSizeMB:10,maxFiles:20}),c==="create"&&Be.length>0&&jsxRuntime.jsxs("p",{className:"text-xs mt-1",style:{color:g.textTertiary},children:[Be.length," archivo(s) se subir\xE1n al crear la tarea"]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>Ae(!xe),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:g.textTertiary},children:[jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-3 h-3 transition-transform ${xe?"rotate-180":""}`}),"Opciones avanzadas"]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:xe&&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:[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:U.isMilestone,onChange:z=>Pe("isMilestone",z.target.checked),className:"w-4 h-4 rounded",style:{accentColor:g.accent},disabled:l}),jsxRuntime.jsx(lucideReact.Milestone,{className:"w-4 h-4 text-yellow-500"}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:g.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:g.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:g.bgSecondary},children:r.filter(z=>z.id!==a?.id).map(z=>{let oe=U.dependencies?.includes(z.id);return jsxRuntime.jsx("button",{type:"button",onClick:()=>{let de=oe?(U.dependencies||[]).filter(Ce=>Ce!==z.id):[...U.dependencies||[],z.id];Pe("dependencies",de);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:oe?`${g.accent}30`:g.bgPrimary,color:oe?g.accent:g.textSecondary,border:`1px solid ${oe?g.accent:g.borderLight}`},disabled:l,children:z.name},z.id)})})]})]})})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${g.border}`},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:g.textSecondary},onMouseEnter:z=>z.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:z=>z.currentTarget.style.backgroundColor="transparent",disabled:l,children:"Cancelar"}),jsxRuntime.jsx("button",{type:"submit",disabled:l,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:g.accent,color:"#FFF"},onMouseEnter:z=>!l&&(z.currentTarget.style.opacity="0.9"),onMouseLeave:z=>!l&&(z.currentTarget.style.opacity="1"),children:l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:c==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var uf=['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"'],Id=()=>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"})]}),gf=()=>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"})}),ff=()=>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"})}),hf=()=>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"})}),bf=()=>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 pn({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:l,onDependencyCreate:c,onDependencyDelete:p}){let[n,m]=react.useState(false),[d,i]=react.useState(false),[u,x]=react.useState([]),[f,g]=react.useState(""),[k,h]=react.useState(false),[b,y]=react.useState(true),D=react.useRef(null),N=react.useRef(null),A=react.useRef(null),{enabled:v=true,placeholder:B='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:T="bottom-right",onCommand:w,suggestions:R=uf,maxHistory:M=50,persistHistory:H}=a,X=H?.storageKey||"gantt-ai-history",fe=H?.maxMessages??5;react.useEffect(()=>{if(H?.enabled)try{let W=localStorage.getItem(X);if(W){let Y=JSON.parse(W).map(J=>({...J,timestamp:new Date(J.timestamp)}));x(Y.slice(-fe));}}catch(W){console.warn("[GanttAIAssistant] Failed to load persisted history:",W);}},[H?.enabled,X,fe]),react.useEffect(()=>{if(H?.enabled&&u.length>0)try{let W=u.filter(E=>!E.isLoading).slice(-fe);localStorage.setItem(X,JSON.stringify(W));}catch(W){console.warn("[GanttAIAssistant] Failed to persist history:",W);}},[u,H?.enabled,X,fe]),react.useEffect(()=>{N.current&&N.current.scrollIntoView({behavior:"smooth"});},[u]),react.useEffect(()=>{n&&!d&&D.current&&setTimeout(()=>D.current?.focus(),100);},[n,d]);let xe=react.useCallback(W=>{if(W.success)switch(W.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":W.taskId&&W.updates&&o?.(W.taskId,W.updates);break;case "create_task":W.newTask&&s?.(W.newTask);break;case "delete_task":W.taskId&&l?.(W.taskId);break;case "link_tasks":W.dependencyFrom&&W.dependencyTo&&c?.(W.dependencyFrom,W.dependencyTo);break;case "unlink_tasks":W.taskId&&W.dependencyFrom&&p?.(W.taskId,W.dependencyFrom);break}},[o,s,l,c,p]),Ae=react.useCallback(async W=>{if(!W.trim()||k)return;let E={id:`user-${Date.now()}`,role:"user",content:W,timestamp:new Date};x(J=>[...J.slice(-(M-1)),E]),g(""),y(false),h(true);let Y={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};x(J=>[...J,Y]);try{if(w){let J=await w(W,e);x(U=>{let De=U.filter($e=>!$e.isLoading),ke={id:`assistant-${Date.now()}`,role:"assistant",content:J.message,timestamp:new Date,command:J};return [...De,ke]}),xe(J);}else x(J=>[...J.filter(De=>!De.isLoading),{id:`assistant-${Date.now()}`,role:"assistant",content:"AI handler not configured. Please provide an onCommand handler in the aiAssistant config.",timestamp:new Date}]);}catch(J){x(U=>[...U.filter(ke=>!ke.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${J instanceof Error?J.message:"Unknown error"}`,timestamp:new Date}]);}finally{h(false);}},[k,M,w,e,xe]),Be=W=>{W.preventDefault(),Ae(f);},$=W=>{g(W),D.current?.focus();};if(react.useEffect(()=>{let W=E=>{(E.metaKey||E.ctrlKey)&&E.key==="k"&&(E.preventDefault(),m(Y=>!Y),n||i(false)),E.key==="Escape"&&n&&m(false);};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[n]),react.useEffect(()=>{if(!n)return;let W=Y=>{let J=Y.target;A.current&&!A.current.contains(J)&&m(false);},E=setTimeout(()=>{document.addEventListener("mousedown",W);},100);return ()=>{clearTimeout(E),document.removeEventListener("mousedown",W);}},[n]),!v)return null;let F={"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(at,{children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!n&&jsxRuntime.jsxs(framerMotion.motion.button,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},className:`fixed ${F[T]} z-[99999] flex items-center gap-2 px-4 py-3 rounded-full shadow-lg transition-colors`,style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"white",boxShadow:"0 4px 20px rgba(59, 130, 246, 0.4)"},onClick:()=>m(true),children:[jsxRuntime.jsx(Id,{}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),jsxRuntime.jsx("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono rounded bg-white/20",children:"\u2318K"})]})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:n&&jsxRuntime.jsxs(framerMotion.motion.div,{ref:A,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 ${F[T]} z-[99999] w-96 rounded-2xl overflow-hidden shadow-2xl flex flex-col`,style:{background:t.bgPrimary,border:`1px solid ${t.border}`,boxShadow:`0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px ${t.border}`},children:[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(Id,{}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{onClick:()=>i(W=>!W),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(hf,{})}),jsxRuntime.jsx("button",{onClick:()=>m(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(ff,{})})]})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!d&&jsxRuntime.jsxs(framerMotion.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"flex flex-col flex-1 min-h-0",children:[jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[u.length===0&&b&&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:R.slice(0,4).map((W,E)=>jsxRuntime.jsx("button",{onClick:()=>$(W),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:W.length>30?W.slice(0,30)+"...":W},E))})]}),u.map(W=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${W.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${W.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:W.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:W.role==="user"?"white":t.textPrimary},children:[W.isLoading?jsxRuntime.jsx(bf,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:W.content}),W.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:W.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:W.command.success?"#10B981":"#EF4444"},children:[W.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:W.command.type.replace(/_/g," ")})]})]})},W.id)),jsxRuntime.jsx("div",{ref:N})]}),jsxRuntime.jsxs("form",{onSubmit:Be,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:D,type:"text",value:f,onChange:W=>g(W.target.value),placeholder:B,disabled:k,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsxRuntime.jsx("button",{type:"submit",disabled:!f.trim()||k,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:f.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:f.trim()?"white":t.textSecondary},children:jsxRuntime.jsx(gf,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function Ld(e,t=50){let[a,r]=react.useState({past:[],present:e,future:[]}),o=react.useRef(false),s=react.useCallback((n,m=true)=>{r(d=>{let i=typeof n=="function"?n(d.present):n;if(o.current)return {...d,present:i};if(!m)return {...d,present:i};let u=[...d.past,d.present];return u.length>t&&u.shift(),{past:u,present:i,future:[]}});},[t]),l=react.useCallback(()=>{r(n=>{if(n.past.length===0)return n;let m=n.past[n.past.length-1],d=n.past.slice(0,n.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:m,future:[n.present,...n.future]}});},[]),c=react.useCallback(()=>{r(n=>{if(n.future.length===0)return n;let m=n.future[0],d=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:m,future:d}});},[]),p=react.useCallback(()=>{r(n=>({past:[],present:n.present,future:[]}));},[]);return {state:a.present,setState:s,undo:l,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function Fd({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){react.useEffect(()=>{if(!o)return;let s=l=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,p=c?l.metaKey:l.ctrlKey;if(p&&l.key==="z"&&!l.shiftKey&&a){l.preventDefault(),e();return}if(r){if(!c&&p&&l.key==="y"){l.preventDefault(),t();return}if(c&&p&&l.shiftKey&&l.key==="z"){l.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var kf={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${le.formatDate(e.startDate)} - ${le.formatDate(e.endDate)}`);let a=le.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=>le.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function Bd(e){return {...kf,...e}}var Ef=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},zd=react.forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:l="week",rowDensity:c="comfortable",showThemeSelector:p=true,showExportButton:n=true,availableUsers:m=[],templates:d,enableAutoCriticalPath:i=true,persistExpandedState:u,aiAssistant:x,locale:f="en",customTranslations:g,showCreateTaskButton:k=false,createTaskLabel:h,onCreateTask:b,onThemeChange:y,onTaskClick:D,onTaskDblClick:N,onTaskContextMenu:A,onTaskUpdate:v,onProgressChange:B,onTaskEdit:T,onTaskAddSubtask:w,onTaskMarkIncomplete:R,onTaskSetInProgress:M,onDependencyCreate:H,onDependencyDelete:X,onBeforeTaskAdd:fe,onAfterTaskAdd:xe,onBeforeTaskUpdate:Ae,onAfterTaskUpdate:Be,onBeforeTaskDelete:$,onAfterTaskDelete:F}=a,E=react.useContext(Ko)?.theme,[Y,J]=react.useState(E||s||"dark"),[U,De]=react.useState(l),[ke,$e]=react.useState(c),[he,et]=react.useState(1),[Pe,Qe]=react.useState(0),[ht,Dt]=react.useState(false),[lt,z]=react.useState(null),[oe,de]=react.useState({isOpen:false,x:0,y:0,task:null}),[Ce,Ee]=react.useState(null),[tt,mt]=react.useState(null);react.useEffect(()=>{E&&E!==Y&&J(E);},[E]),react.useEffect(()=>{s&&s!==Y&&J(s);},[s]);let Ie=react.useCallback(S=>{J(S),y?.(S);},[y]),{state:I,setState:q,undo:He,redo:Ue,canUndo:yt,canRedo:Q,clearHistory:ae}=Ld(t,50),ve=react.useCallback(()=>u?typeof u=="string"?u:"gantt-expanded-tasks":null,[u]),Te=react.useRef(new Map),ne=react.useRef(false);if(!ne.current&&u){ne.current=true;let S=typeof u=="string"?u:"gantt-expanded-tasks";try{let P=localStorage.getItem(S);if(P){let j=JSON.parse(P);Array.isArray(j)&&(Te.current=new Map(j));}}catch(P){console.warn("[GanttBoard] Error loading expanded state from localStorage:",P);}}let Se=react.useCallback(()=>{let S=ve();if(S)try{let P=Array.from(Te.current.entries());localStorage.setItem(S,JSON.stringify(P));}catch(P){console.warn("[GanttBoard] Error saving expanded state to localStorage:",P);}},[ve]);react.useEffect(()=>{let S=P=>P.map(j=>{let ee=Te.current.get(j.id),pe=ee!==void 0?{...j,isExpanded:ee}:j;return pe.subtasks?.length?{...pe,subtasks:S(pe.subtasks)}:pe});Te.current.size>0?q(S(t)):q(t);},[t,q]);let be=react.useRef(t),Ne=react.useRef(true);react.useEffect(()=>{if(Ne.current){Ne.current=false,be.current=I;return}if(!r)return;let S=JSON.stringify(be.current),P=JSON.stringify(I);S!==P&&(be.current=I,r(I));},[I,r]);let ie=react.useMemo(()=>Ds(f,g),[f,g]),Fe=react.useCallback(S=>[{id:"name",label:S.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:S.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:S.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:S.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:S.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:S.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:S.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:S.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Me,Re]=react.useState(()=>Fe(ie));react.useEffect(()=>{Re(S=>S.map(P=>({...P,label:ie.columns[P.id==="name"?"taskName":P.id]||P.label})));},[ie]);let Nt=react.useMemo(()=>Me.filter(P=>P.visible).reduce((P,j)=>P+j.width,0),[Me]),V=react.useRef(Me.filter(S=>S.visible).map(S=>S.id).join(","));react.useEffect(()=>{let S=Me.filter(ee=>ee.visible),P=S.map(ee=>ee.id).join(","),j=V.current;if(P!==j){let ee=S.some(we=>we.id!=="name"),pe=j.includes(",");ee?!pe&&ee&&z(null):z(null),V.current=P;}},[Me]);let Z=60,nt=.6,ye=react.useMemo(()=>{let P=Nt+Z,j=typeof window<"u"?window.innerWidth*nt:800,ee=Math.max(P,j);return lt!==null?Math.max(200,Math.min(lt,ee)):Math.max(200,P)},[lt,Nt]),We=react.useRef(null),Xt=react.useRef(null),O=react.useRef(null),K=react.useMemo(()=>Ql(Y),[Y]),Ve=react.useMemo(()=>({theme:K,themeName:Y}),[K,Y]),qe=react.useMemo(()=>Bd(d),[d]),ea=react.useMemo(()=>{if(!i)return I;let S=le.calculateCriticalPath(I),P=j=>j.map(ee=>({...ee,isCriticalPath:S.includes(ee.id),subtasks:ee.subtasks?P(ee.subtasks):void 0}));return P(I)},[I,i]),Oa=Ef(ke);Fd({undo:He,redo:Ue,canUndo:yt,canRedo:Q,enabled:true}),react.useImperativeHandle(o,()=>({getTask:S=>le.findTaskById(I,S),addTask:(S,P)=>{q(j=>{if(!P)return [...j,{...S,level:0}];let ee=pe=>pe.map(we=>we.id===P?{...we,subtasks:[...we.subtasks||[],{...S,parentId:P,level:(we.level||0)+1}],isExpanded:true}:we.subtasks?{...we,subtasks:ee(we.subtasks)}:we);return ee(j)});},updateTask:(S,P)=>{q(j=>{let ee=pe=>pe.map(we=>we.id===S?{...we,...P}:we.subtasks?{...we,subtasks:ee(we.subtasks)}:we);return ee(j)});},deleteTask:S=>{q(P=>{let j=ee=>ee.filter(pe=>pe.id===S?false:(pe.subtasks&&(pe.subtasks=j(pe.subtasks)),true));return j(P)});},deleteTasks:S=>{q(P=>Is(P,S));},duplicateTask:S=>{q(P=>Ls(P,[S]));},splitTask:(S,P,j=3)=>{q(ee=>le.splitTask(ee,S,P,j));},calculateEndDate:le.calculateEndDate,calculateDuration:le.calculateDuration,validateDependency:(S,P)=>!le.validateDependencies(I,S,P),getAllTasks:()=>le.flattenTasks(I),getTasksByStatus:S=>le.flattenTasks(I).filter(P=>P.status===S),getTasksByParent:S=>S?le.findTaskById(I,S)?.subtasks||[]:I.filter(j=>!j.parentId),getCriticalPath:()=>le.flattenTasks(I).filter(S=>S.isCriticalPath),indentTask:S=>{q(P=>Ps(P,[S]));},outdentTask:S=>{q(P=>Ms(P,[S]));},moveTask:(S,P)=>{q(j=>As(j,[S],P));},createSubtask:async S=>{let{tasks:P,newTask:j}=Rs(I,S);if(fe){let ee=fe({...j,parentId:S});if((ee instanceof Promise?await ee:ee)===false)return}q(P),xe&&xe({...j,parentId:S});},scrollToTask:S=>{let j=le.flattenTasks(I).findIndex(ee=>ee.id===S);if(j!==-1&&We.current){let ee=j*Oa;We.current.scrollTo({top:ee,behavior:"smooth"}),Xt.current&&Xt.current.scrollTo({top:ee,behavior:"smooth"});}},highlightTask:(S,P=2e3)=>{},expandTask:S=>{q(P=>{let j=ee=>ee.map(pe=>pe.id===S?{...pe,isExpanded:true}:pe.subtasks?{...pe,subtasks:j(pe.subtasks)}:pe);return j(P)});},collapseTask:S=>{q(P=>{let j=ee=>ee.map(pe=>pe.id===S?{...pe,isExpanded:false}:pe.subtasks?{...pe,subtasks:j(pe.subtasks)}:pe);return j(P)});},expandAll:()=>{q(S=>{let P=j=>j.map(ee=>({...ee,isExpanded:true,subtasks:ee.subtasks?P(ee.subtasks):void 0}));return P(S)});},collapseAll:()=>{q(S=>{let P=j=>j.map(ee=>({...ee,isExpanded:false,subtasks:ee.subtasks?P(ee.subtasks):void 0}));return P(S)});},undo:He,redo:Ue,canUndo:()=>yt,canRedo:()=>Q,clearHistory:ae,exportToPNG:async()=>{if(!O.current)throw new Error("Gantt container not found");let S=await Od__default.default(O.current,{backgroundColor:K.bgPrimary,scale:2});return new Promise((P,j)=>{S.toBlob(ee=>{ee?P(ee):j(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async S=>{await le.exportToPDF(I,S);},exportToExcel:async S=>{await le.exportToExcel(I,S);},exportToJSON:()=>le.exportToJSON(I),exportToCSV:()=>le.exportToCSV(I),importFromJSON:S=>{let P=le.importFromJSON(S);q(P);},getTasks:()=>I,refresh:()=>{q(S=>[...S]);},clearAll:()=>{q([]);}}),[I,He,Ue,yt,Q,ae,K,Oa]);let qa=react.useCallback(S=>{Re(P=>P.map(j=>j.id===S?{...j,visible:!j.visible}:j));},[]),Jr=react.useCallback((S,P)=>{Re(j=>j.map(ee=>{if(ee.id!==S)return ee;let pe=ee.minWidth??100,we=ee.maxWidth??800,Ot=Math.max(pe,Math.min(we,P));return {...ee,width:Ot}}));},[]),ce=react.useCallback(S=>{q(P=>{let j=Bs(P,S),ee=pe=>{for(let we of pe){if(we.id===S){Te.current.set(S,we.isExpanded??true);return}we.subtasks?.length&&ee(we.subtasks);}};return ee(j),Se(),j}),a.onTaskToggleExpand?.(S);},[a,Se]),ut=react.useCallback((S,P)=>{if(Ae&&Ae(S,P)===false)return;let ee=le.findTaskById(I,S)?.progress,pe=Ot=>Ot.map(Gt=>Gt.id===S?{...Gt,...P}:Gt.subtasks?{...Gt,subtasks:pe(Gt.subtasks)}:Gt);q(pe(I));let we=le.findTaskById(pe(I),S);we&&(v?.(we),Be?.(we),P.progress!==void 0&&ee!==void 0&&P.progress!==ee&&B?.(S,ee,P.progress));},[I,v,Ae,Be,B]),Jt=react.useCallback(S=>{S.length!==0&&(q(P=>Ps(P,S)),a.onTaskIndent?.(S[0]));},[a]),Mr=react.useCallback(S=>{S.length!==0&&(q(P=>Ms(P,S)),a.onTaskOutdent?.(S[0]));},[a]),Eo=react.useCallback((S,P,j)=>{q(ee=>vd(ee,S,P,j)),a.onTaskReparent?.(S,P,j);},[a]),Ar=react.useCallback((S,P)=>{S.length!==0&&(q(j=>As(j,S,P)),a.onTaskMove?.(S[0],P));},[a]),Da=react.useCallback(async S=>{let P=[];for(let j of S)$&&await Promise.resolve($(j))===false||P.push(j);P.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(P):(q(j=>Is(j,P)),P.forEach(j=>a.onTaskDelete?.(j))),F&&P.forEach(j=>F(j)));},[a,$,F]),dr=react.useCallback(S=>{q(P=>Ls(P,S)),S.forEach(P=>a.onTaskDuplicate?.(P));},[a]),Bt=react.useCallback((S,P)=>{q(j=>{let{tasks:ee,newTask:pe}=yd(j,S,P);return fe&&fe(pe)===false?j:(a.onTaskCreate?.(pe.parentId,pe.position||0),xe?.(pe),ee)});},[a,fe,xe]),An=react.useCallback((S,P)=>{q(j=>Fs(j,S,P)),a.onTaskRename?.(S,P);},[a]),Zr=react.useCallback(S=>{q(P=>{let{tasks:j}=Rs(P,S);return a.onTaskCreate?.(S,0),j});},[a]),Oi=react.useCallback((S,P,j)=>{let ee=S.startDate?Math.round((P.getTime()-S.startDate.getTime())/864e5):0,pe=Gt=>Gt.map(Zt=>Zt.id===S.id?{...Zt,startDate:P,endDate:j,...S.segments&&{segments:S.segments}}:Zt.subtasks?{...Zt,subtasks:pe(Zt.subtasks)}:Zt),we=pe(I);we=le.autoScheduleDependents(we,S.id,ee),q(we);let Ot={...S,startDate:P,endDate:j};v?.(Ot);},[I,v]),Qr=react.useCallback((S,P)=>{A?.(S,P),de({isOpen:true,x:P.clientX,y:P.clientY,task:S});},[A]),Zc=react.useCallback((S,P)=>{let j=le.splitTask(I,S.id,P);q(j),de({isOpen:false,x:0,y:0,task:null});},[I]),zi=react.useCallback(S=>{let P=le.findTaskById(I,S.id)||S;N?.(P),T||Ee(P);},[I,N,T]),$i=react.useCallback((S,P,j)=>{let ee=new Map,pe=Na=>{Na.forEach(Ga=>{Ga.dependencies&&ee.set(Ga.id,Ga.dependencies),Ga.subtasks&&pe(Ga.subtasks);});};pe(j);let we=ee.get(P)||[];ee.set(P,[...we,S]);let Ot=new Set,Gt=new Set,Zt=Na=>{if(!Ot.has(Na)){Ot.add(Na),Gt.add(Na);let Ga=ee.get(Na)||[];for(let cr of Ga){if(!Ot.has(cr)&&Zt(cr))return true;if(Gt.has(cr))return true}}return Gt.delete(Na),false};return Zt(P)},[]),Ui=react.useCallback((S,P)=>{if($i(S.id,P,I)){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
|
-
Task dependencies must flow in one direction only.`);return}let j=ee=>ee.map(pe=>{if(pe.id===P){let we=pe.dependencies||[];if(!we.includes(S.id))return {...pe,dependencies:[...we,S.id]}}return pe.subtasks?{...pe,subtasks:j(pe.subtasks)}:pe});q(j(I)),H?.(S.id,P);},[I,H,$i]),Wi=react.useCallback((S,P)=>{let j=ee=>ee.map(pe=>{if(pe.id===S&&pe.dependencies){let we=pe.dependencies.filter(Ot=>Ot!==P);return {...pe,dependencies:we}}return pe.subtasks?{...pe,subtasks:j(pe.subtasks)}:pe});q(j(I)),X?.(S,P);},[I,X]),{startDate:Qc,endDate:ep}=react.useMemo(()=>{let S=I.filter(we=>we.startDate&&we.endDate);if(S.length===0){let we=new Date,Ot=new Date(we);Ot.setDate(Ot.getDate()-30);let Gt=new Date(we);return Gt.setDate(Gt.getDate()+60),{startDate:Ot,endDate:Gt}}let P=S.flatMap(we=>[we.startDate,we.endDate]).filter(we=>we!==void 0),j=new Date(Math.min(...P.map(we=>we.getTime()))),ee=new Date(Math.max(...P.map(we=>we.getTime()))),pe=U==="day"?7:U==="week"?14:30;return j.setDate(j.getDate()-pe),ee.setDate(ee.getDate()+pe),{startDate:j,endDate:ee}},[I,U]),tp=react.useCallback(async()=>{if(!O.current)return;let S=await Od__default.default(O.current,{backgroundColor:K.bgPrimary,scale:2}),P=document.createElement("a");P.download="gantt-chart.png",P.href=S.toDataURL("image/png"),P.click();},[K]),ap=react.useCallback(async()=>{await le.exportToPDF(I);},[I]),rp=react.useCallback(async()=>{await le.exportToExcel(I);},[I]),op=react.useCallback(()=>{let S=le.exportToCSV(I),P=new Blob([S],{type:"text/csv;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(P),j.download="gantt-chart.csv",j.click(),URL.revokeObjectURL(j.href);},[I]),np=react.useCallback(()=>{let S=le.exportToJSON(I),P=new Blob([S],{type:"application/json;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(P),j.download="gantt-chart.json",j.click(),URL.revokeObjectURL(j.href);},[I]),sp=react.useCallback(()=>{le.exportToMSProject(I,"Gantt Project","project.xml");},[I]),ip=S=>{S.preventDefault(),Dt(true);};return react.useEffect(()=>{let S=Xt.current,P=We.current;if(!S||!P)return;let j=P.querySelector(".gantt-taskgrid-content"),ee=()=>{let Zt=S.scrollTop;Qe(Zt),j&&(j.style.transform=`translateY(-${Zt}px)`);},pe=Zt=>{if(ht&&P){let Ga=P.parentElement?.getBoundingClientRect()?.left||0,cr=Zt.clientX-Ga,lp=200,dp=Nt+Z,cp=window.innerWidth*nt,pp=Math.max(dp,cp);cr>=lp&&cr<=pp&&z(cr);}},we=()=>{Dt(false);},Ot=P.querySelector(".gantt-grid-scroll")||P,Gt=Zt=>{let Na=Zt;Na.deltaY!==0&&(S.scrollTop+=Na.deltaY,Zt.preventDefault());};return S.addEventListener("scroll",ee),Ot.addEventListener("wheel",Gt,{passive:false}),document.addEventListener("mousemove",pe),document.addEventListener("mouseup",we),()=>{S.removeEventListener("scroll",ee),Ot.removeEventListener("wheel",Gt),document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",we);}},[ht]),jsxRuntime.jsx(Gr.Provider,{value:ie,children:jsxRuntime.jsx(Rn.Provider,{value:Ve,children:jsxRuntime.jsxs("div",{ref:O,className:"flex flex-col h-full w-full",style:{backgroundColor:K.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsxRuntime.jsx(qo,{theme:K,timeScale:U,onTimeScaleChange:De,zoom:he,onZoomChange:et,currentTheme:Y,onThemeChange:Ie,rowDensity:ke,onRowDensityChange:$e,showThemeSelector:p,showCreateTaskButton:k,createTaskLabel:h,onCreateTask:b,onExportPNG:n?tp:void 0,onExportPDF:n?ap:void 0,onExportExcel:n?rp:void 0,onExportCSV:n?op:void 0,onExportJSON:n?np:void 0,onExportMSProject:n?sp:void 0}),jsxRuntime.jsxs("div",{ref:We,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:ye,overflowX:"auto",overflowY:"hidden"},children:jsxRuntime.jsx(Qo,{tasks:ea,theme:K,rowHeight:Oa,availableUsers:m,templates:qe,onTaskClick:D,onTaskDblClick:zi,onTaskContextMenu:A,onTaskToggle:ce,scrollTop:Pe,columns:Me,onToggleColumn:qa,onColumnResize:Jr,onTaskUpdate:ut,onTaskIndent:Jt,onTaskOutdent:Mr,onTaskMove:Ar,onMultiTaskDelete:Da,onTaskDuplicate:dr,onTaskCreate:Bt,onTaskRename:An,onCreateSubtask:Zr,onOpenTaskModal:D?S=>D(S):void 0,onDeleteRequest:(S,P)=>mt({taskId:S,taskName:P}),onTaskReparent:Eo})}),jsxRuntime.jsx("div",{className:"flex-shrink-0 cursor-col-resize hover:bg-blue-500/30 transition-colors h-full",style:{width:2,backgroundColor:K.border,zIndex:15},onMouseDown:ip}),jsxRuntime.jsx("div",{ref:Xt,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsxRuntime.jsx(ln,{tasks:ea,theme:K,rowHeight:Oa,timeScale:U,startDate:Qc,endDate:ep,zoom:he,templates:qe,onTaskClick:D,onTaskDblClick:zi,onTaskContextMenu:Qr,onTaskDateChange:Oi,onDependencyCreate:Ui,onDependencyDelete:Wi})})]}),oe.task&&jsxRuntime.jsx(_r,{isOpen:oe.isOpen,x:oe.x,y:oe.y,theme:K,onClose:()=>de({isOpen:false,x:0,y:0,task:null}),items:(()=>{let S=oe.task;if(!S)return [];let P=le.findTaskById(I,S.id)||S;return P.subtasks&&P.subtasks.length>0?[{id:"addSubtask",label:ie.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{w?w(P):Zr(P.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:ie.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{mt({taskId:P.id,taskName:P.name});}}]:[{id:"edit",label:ie.contextMenu?.editTask||"Edit Task",icon:Ct.Pencil,onClick:()=>{T?T(P):Ee(P);}},{id:"addSubtask",label:ie.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{w?w(P):Zr(P.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:ie.contextMenu?.markIncomplete||"Mark Incomplete",icon:Ct.MarkIncomplete,onClick:()=>{R?R(P):ut(P.id,{status:"todo",progress:0});},disabled:P.status==="todo"},{id:"setInProgress",label:ie.contextMenu?.setInProgress||"Set In Progress",icon:Ct.SetInProgress,onClick:()=>{M?M(P):ut(P.id,{status:"in-progress"});},disabled:P.status==="in-progress"},{id:"markComplete",label:ie.contextMenu?.markComplete||"Mark Complete",icon:Ct.MarkComplete,onClick:()=>{ut(P.id,{status:"completed",progress:100});},disabled:P.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:ie.contextMenu?.splitTask||"Split Task",icon:Ct.Split,onClick:()=>{if(!P.startDate||!P.endDate){console.warn("Cannot split task without dates");return}let ee=P.startDate.getTime(),pe=P.endDate.getTime(),we=ee+(pe-ee)/2,Ot=new Date(we);Zc(P,Ot);},disabled:!P.startDate||!P.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:ie.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{mt({taskId:P.id,taskName:P.name});}}]})()}),Ce&&jsxRuntime.jsx(cn,{isOpen:true,onClose:()=>Ee(null),task:Ce,onSubmit:S=>{ut(Ce.id,S),Ee(null);},mode:"edit",theme:Y}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:tt&&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:()=>mt(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:S=>S.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:K.bgSecondary,border:`1px solid ${K.border}`},children:[jsxRuntime.jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${K.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:K.textPrimary,fontFamily:"Inter, sans-serif"},children:[ie.contextMenu?.deleteTask||"Delete Task","?"]}),jsxRuntime.jsx("p",{className:"text-sm mt-1",style:{color:K.textSecondary,fontFamily:"Inter, sans-serif"},children:f==="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:K.textSecondary,fontFamily:"Inter, sans-serif"},children:[f==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxRuntime.jsxs("span",{className:"font-semibold",style:{color:K.textPrimary},children:['"',tt.taskName,'"']}),"."]})}),jsxRuntime.jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:K.bgPrimary,borderTop:`1px solid ${K.border}`},children:[jsxRuntime.jsx("button",{onClick:()=>mt(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:K.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor=K.hoverBg;},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent";},children:f==="es"?"Cancelar":"Cancel"}),jsxRuntime.jsxs("button",{onClick:()=>{Da([tt.taskId]),mt(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:S=>{S.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="#EF4444";},children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"}),f==="es"?"Eliminar":"Delete"]})]})]})})}),x?.enabled&&jsxRuntime.jsx(pn,{tasks:I,theme:K,config:x,onTasksUpdate:q,onTaskUpdate:ut,onTaskCreate:S=>{q(P=>[...P,S]);},onTaskDelete:S=>{Da([S]);},onDependencyCreate:(S,P)=>{let j=le.findTaskById(I,S);j&&Ui(j,P);},onDependencyDelete:Wi})]})})})});var $d=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
|
|
344
|
+
Task dependencies must flow in one direction only.`);return}let j=ee=>ee.map(pe=>{if(pe.id===P){let we=pe.dependencies||[];if(!we.includes(S.id))return {...pe,dependencies:[...we,S.id]}}return pe.subtasks?{...pe,subtasks:j(pe.subtasks)}:pe});q(j(I)),H?.(S.id,P);},[I,H,$i]),Wi=react.useCallback((S,P)=>{let j=ee=>ee.map(pe=>{if(pe.id===S&&pe.dependencies){let we=pe.dependencies.filter(Ot=>Ot!==P);return {...pe,dependencies:we}}return pe.subtasks?{...pe,subtasks:j(pe.subtasks)}:pe});q(j(I)),X?.(S,P);},[I,X]),{startDate:Qc,endDate:ep}=react.useMemo(()=>{let S=I.filter(we=>we.startDate&&we.endDate);if(S.length===0){let we=new Date,Ot=new Date(we);Ot.setDate(Ot.getDate()-30);let Gt=new Date(we);return Gt.setDate(Gt.getDate()+60),{startDate:Ot,endDate:Gt}}let P=S.flatMap(we=>[we.startDate,we.endDate]).filter(we=>we!==void 0),j=new Date(Math.min(...P.map(we=>we.getTime()))),ee=new Date(Math.max(...P.map(we=>we.getTime()))),pe=U==="day"?7:U==="week"?14:30;return j.setDate(j.getDate()-pe),ee.setDate(ee.getDate()+pe),{startDate:j,endDate:ee}},[I,U]),tp=react.useCallback(async()=>{if(!O.current)return;let S=await Od__default.default(O.current,{backgroundColor:K.bgPrimary,scale:2}),P=document.createElement("a");P.download="gantt-chart.png",P.href=S.toDataURL("image/png"),P.click();},[K]),ap=react.useCallback(async()=>{await le.exportToPDF(I);},[I]),rp=react.useCallback(async()=>{await le.exportToExcel(I);},[I]),op=react.useCallback(()=>{let S=le.exportToCSV(I),P=new Blob([S],{type:"text/csv;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(P),j.download="gantt-chart.csv",j.click(),URL.revokeObjectURL(j.href);},[I]),np=react.useCallback(()=>{let S=le.exportToJSON(I),P=new Blob([S],{type:"application/json;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(P),j.download="gantt-chart.json",j.click(),URL.revokeObjectURL(j.href);},[I]),sp=react.useCallback(()=>{le.exportToMSProject(I,"Gantt Project","project.xml");},[I]),ip=S=>{S.preventDefault(),Dt(true);};return react.useEffect(()=>{let S=Xt.current,P=We.current;if(!S||!P)return;let j=P.querySelector(".gantt-taskgrid-content"),ee=()=>{let Zt=S.scrollTop;Qe(Zt),j&&(j.style.transform=`translateY(-${Zt}px)`);},pe=Zt=>{if(ht&&P){let Ga=P.parentElement?.getBoundingClientRect()?.left||0,cr=Zt.clientX-Ga,lp=200,dp=Nt+Z,cp=window.innerWidth*nt,pp=Math.max(dp,cp);cr>=lp&&cr<=pp&&z(cr);}},we=()=>{Dt(false);},Ot=P.querySelector(".gantt-grid-scroll")||P,Gt=Zt=>{let Na=Zt;Na.deltaY!==0&&(S.scrollTop+=Na.deltaY,Zt.preventDefault());};return S.addEventListener("scroll",ee),Ot.addEventListener("wheel",Gt,{passive:false}),document.addEventListener("mousemove",pe),document.addEventListener("mouseup",we),()=>{S.removeEventListener("scroll",ee),Ot.removeEventListener("wheel",Gt),document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",we);}},[ht]),jsxRuntime.jsx(Gr.Provider,{value:ie,children:jsxRuntime.jsx(Rn.Provider,{value:Ve,children:jsxRuntime.jsxs("div",{ref:O,className:"flex flex-col h-full w-full",style:{backgroundColor:K.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsxRuntime.jsx(qo,{theme:K,timeScale:U,onTimeScaleChange:De,zoom:he,onZoomChange:et,currentTheme:Y,onThemeChange:Ie,rowDensity:ke,onRowDensityChange:$e,showThemeSelector:p,showCreateTaskButton:k,createTaskLabel:h,onCreateTask:b,onExportPNG:n?tp:void 0,onExportPDF:n?ap:void 0,onExportExcel:n?rp:void 0,onExportCSV:n?op:void 0,onExportJSON:n?np:void 0,onExportMSProject:n?sp:void 0}),jsxRuntime.jsxs("div",{ref:We,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:ye,overflowX:"auto",overflowY:"hidden"},children:jsxRuntime.jsx(Qo,{tasks:ea,theme:K,rowHeight:Oa,availableUsers:m,templates:qe,onTaskClick:D,onTaskDblClick:zi,onTaskContextMenu:A,onTaskToggle:ce,scrollTop:Pe,columns:Me,onToggleColumn:qa,onColumnResize:Jr,onTaskUpdate:ut,onTaskIndent:Jt,onTaskOutdent:Mr,onTaskMove:Ar,onMultiTaskDelete:Da,onTaskDuplicate:dr,onTaskCreate:Bt,onTaskRename:An,onCreateSubtask:Zr,onOpenTaskModal:D?S=>D(S):void 0,onDeleteRequest:(S,P)=>mt({taskId:S,taskName:P}),onTaskReparent:Eo})}),jsxRuntime.jsx("div",{className:"flex-shrink-0 cursor-col-resize hover:bg-blue-500/50 transition-colors h-full",style:{width:1,backgroundColor:K.border,zIndex:15},onMouseDown:ip}),jsxRuntime.jsx("div",{ref:Xt,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsxRuntime.jsx(ln,{tasks:ea,theme:K,rowHeight:Oa,timeScale:U,startDate:Qc,endDate:ep,zoom:he,templates:qe,onTaskClick:D,onTaskDblClick:zi,onTaskContextMenu:Qr,onTaskDateChange:Oi,onDependencyCreate:Ui,onDependencyDelete:Wi})})]}),oe.task&&jsxRuntime.jsx(_r,{isOpen:oe.isOpen,x:oe.x,y:oe.y,theme:K,onClose:()=>de({isOpen:false,x:0,y:0,task:null}),items:(()=>{let S=oe.task;if(!S)return [];let P=le.findTaskById(I,S.id)||S;return P.subtasks&&P.subtasks.length>0?[{id:"addSubtask",label:ie.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{w?w(P):Zr(P.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:ie.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{mt({taskId:P.id,taskName:P.name});}}]:[{id:"edit",label:ie.contextMenu?.editTask||"Edit Task",icon:Ct.Pencil,onClick:()=>{T?T(P):Ee(P);}},{id:"addSubtask",label:ie.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{w?w(P):Zr(P.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:ie.contextMenu?.markIncomplete||"Mark Incomplete",icon:Ct.MarkIncomplete,onClick:()=>{R?R(P):ut(P.id,{status:"todo",progress:0});},disabled:P.status==="todo"},{id:"setInProgress",label:ie.contextMenu?.setInProgress||"Set In Progress",icon:Ct.SetInProgress,onClick:()=>{M?M(P):ut(P.id,{status:"in-progress"});},disabled:P.status==="in-progress"},{id:"markComplete",label:ie.contextMenu?.markComplete||"Mark Complete",icon:Ct.MarkComplete,onClick:()=>{ut(P.id,{status:"completed",progress:100});},disabled:P.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:ie.contextMenu?.splitTask||"Split Task",icon:Ct.Split,onClick:()=>{if(!P.startDate||!P.endDate){console.warn("Cannot split task without dates");return}let ee=P.startDate.getTime(),pe=P.endDate.getTime(),we=ee+(pe-ee)/2,Ot=new Date(we);Zc(P,Ot);},disabled:!P.startDate||!P.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:ie.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{mt({taskId:P.id,taskName:P.name});}}]})()}),Ce&&jsxRuntime.jsx(cn,{isOpen:true,onClose:()=>Ee(null),task:Ce,onSubmit:S=>{ut(Ce.id,S),Ee(null);},mode:"edit",theme:Y}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:tt&&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:()=>mt(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:S=>S.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:K.bgSecondary,border:`1px solid ${K.border}`},children:[jsxRuntime.jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${K.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:K.textPrimary,fontFamily:"Inter, sans-serif"},children:[ie.contextMenu?.deleteTask||"Delete Task","?"]}),jsxRuntime.jsx("p",{className:"text-sm mt-1",style:{color:K.textSecondary,fontFamily:"Inter, sans-serif"},children:f==="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:K.textSecondary,fontFamily:"Inter, sans-serif"},children:[f==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxRuntime.jsxs("span",{className:"font-semibold",style:{color:K.textPrimary},children:['"',tt.taskName,'"']}),"."]})}),jsxRuntime.jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:K.bgPrimary,borderTop:`1px solid ${K.border}`},children:[jsxRuntime.jsx("button",{onClick:()=>mt(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:K.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor=K.hoverBg;},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent";},children:f==="es"?"Cancelar":"Cancel"}),jsxRuntime.jsxs("button",{onClick:()=>{Da([tt.taskId]),mt(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:S=>{S.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="#EF4444";},children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"}),f==="es"?"Eliminar":"Delete"]})]})]})})}),x?.enabled&&jsxRuntime.jsx(pn,{tasks:I,theme:K,config:x,onTasksUpdate:q,onTaskUpdate:ut,onTaskCreate:S=>{q(P=>[...P,S]);},onTaskDelete:S=>{Da([S]);},onDependencyCreate:(S,P)=>{let j=le.findTaskById(I,S);j&&Ui(j,P);},onDependencyDelete:Wi})]})})})});var $d=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
|
|
345
345
|
|
|
346
346
|
AVAILABLE COMMANDS:
|
|
347
347
|
1. move_task - Move a task to a different date
|