@libxai/board 1.5.93 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -365,7 +365,7 @@
|
|
|
365
365
|
}
|
|
366
366
|
`})]})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:i&&jsxRuntime.jsxs(framerMotion.motion.div,{ref:T,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 ${Pe[R]} z-[99999] w-96 rounded-2xl overflow-hidden flex flex-col`,style:{background:xe,backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)",border:`1px solid ${kt}`,boxShadow:xt},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:nt,borderBottom:`1px solid ${ze}`},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx("div",{style:{width:28,height:28,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:ct,border:`1px solid ${et}`,color:"#2E94FF"},children:jsxRuntime.jsx(Tm,{size:14})}),jsxRuntime.jsx("span",{style:{fontSize:12,fontWeight:600,fontFamily:"'JetBrains Mono', monospace",letterSpacing:"0.06em",textTransform:"uppercase",color:Ee},children:"AI Assistant"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5",children:[jsxRuntime.jsx("button",{onClick:()=>m(I=>!I),className:"p-1.5 rounded-lg transition-colors",style:{color:V},onMouseEnter:I=>{I.currentTarget.style.background=U,I.currentTarget.style.color=D;},onMouseLeave:I=>{I.currentTarget.style.background="transparent",I.currentTarget.style.color=V;},children:jsxRuntime.jsx($v,{})}),jsxRuntime.jsx("button",{onClick:()=>p(false),className:"p-1.5 rounded-lg transition-colors",style:{color:V},onMouseEnter:I=>{I.currentTarget.style.background=U,I.currentTarget.style.color=D;},onMouseLeave:I=>{I.currentTarget.style.background="transparent",I.currentTarget.style.color=V;},children:jsxRuntime.jsx(Rv,{})})]})]}),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:[g.length===0&&w&&jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("p",{className:"text-xs text-center",style:{color:ae,fontFamily:"'JetBrains Mono', monospace"},children:"Try asking me to edit your Gantt chart:"}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:ye.slice(0,4).map((I,ve)=>jsxRuntime.jsx("button",{onClick:()=>Oe(I),className:"text-xs px-3 py-1.5 rounded-full transition-all",style:{background:Ne,color:oe,border:`1px solid ${z}`},onMouseEnter:Z=>{Z.currentTarget.style.borderColor=Ge,Z.currentTarget.style.color="#2E94FF";},onMouseLeave:Z=>{Z.currentTarget.style.borderColor=z,Z.currentTarget.style.color=oe;},children:I.length>30?I.slice(0,30)+"...":I},ve))})]}),g.map(I=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${I.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${I.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:I.role==="user"?fe:$e,color:I.role==="user"?"#2E94FF":dt,border:I.role==="user"?`1px solid ${Ve}`:`1px solid ${Ue}`},children:[I.isLoading?jsxRuntime.jsx(Ov,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:I.content}),I.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:I.command.success?"rgba(16, 185, 129, 0.15)":"rgba(239, 68, 68, 0.15)",color:I.command.success?"#10B981":"#EF4444",border:`1px solid ${I.command.success?"rgba(16,185,129,0.2)":"rgba(239,68,68,0.2)"}`},children:[I.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:I.command.type.replace(/_/g," ")})]})]})},I.id)),jsxRuntime.jsx("div",{ref:Y})]}),jsxRuntime.jsxs("form",{onSubmit:I=>{if(A&&ut.length>0){I.preventDefault();return}Q(I);},className:"p-3 relative",style:{borderTop:`1px solid ${ot}`},children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:A&&ut.length>0&&jsxRuntime.jsx(framerMotion.motion.div,{ref:G,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:{duration:.12},className:"absolute bottom-full left-3 right-3 mb-1 rounded-lg overflow-hidden z-10",style:{background:gt,border:`1px solid ${Vt}`,boxShadow:ht,backdropFilter:"blur(12px)"},children:ut.map((I,ve)=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>Pt(I),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors",style:{background:ve===M?lt:"transparent",color:ne},onMouseEnter:()=>J(ve),children:[jsxRuntime.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-xs font-bold flex-shrink-0",style:{background:$,border:`1px solid ${_}`,color:"#2E94FF"},children:I.name.split(" ").map(Z=>Z[0]).join("").slice(0,2).toUpperCase()}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-sm font-medium truncate",children:I.name}),I.email&&jsxRuntime.jsx("div",{className:"text-xs truncate",style:{color:pe},children:I.email})]})]},I.id))})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:it,border:`1px solid ${mt}`},children:[jsxRuntime.jsx("input",{ref:H,type:"text",value:x,onChange:I=>St(I.target.value),onKeyDown:I=>{At(I);},placeholder:Le,disabled:f,className:"flex-1 bg-transparent text-sm outline-none",style:{color:Nt,fontFamily:"Inter, sans-serif"}}),jsxRuntime.jsx("button",{type:"submit",disabled:!x.trim()||f,className:"p-2 rounded-lg transition-all disabled:opacity-30",style:{background:x.trim()?$t:"transparent",color:x.trim()?"#2E94FF":Mt,border:x.trim()?`1px solid ${Et}`:"1px solid transparent"},children:jsxRuntime.jsx(Bv,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:Ft,fontFamily:"'JetBrains Mono', monospace"},children:"Enter to send \xB7 Esc to close"})]})]})})]})})]})}function Nm(e,t=50){let[a,r]=react.useState({past:[],present:e,future:[]}),o=react.useRef(false),s=react.useCallback((i,p=true)=>{r(d=>{let m=typeof i=="function"?i(d.present):i;if(o.current)return {...d,present:m};if(!p)return {...d,present:m};let g=[...d.past,d.present];return g.length>t&&g.shift(),{past:g,present:m,future:[]}});},[t]),n=react.useCallback(()=>{r(i=>{if(i.past.length===0)return i;let p=i.past[i.past.length-1],d=i.past.slice(0,i.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:p,future:[i.present,...i.future]}});},[]),l=react.useCallback(()=>{r(i=>{if(i.future.length===0)return i;let p=i.future[0],d=i.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...i.past,i.present],present:p,future:d}});},[]),c=react.useCallback(()=>{r(i=>({past:[],present:i.present,future:[]}));},[]);return {state:a.present,setState:s,undo:n,redo:l,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:c}}function Dm({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){react.useEffect(()=>{if(!o)return;let s=n=>{let l=navigator.platform.toUpperCase().indexOf("MAC")>=0,c=l?n.metaKey:n.ctrlKey;if(c&&n.key==="z"&&!n.shiftKey&&a){n.preventDefault(),e();return}if(r){if(!l&&c&&n.key==="y"){n.preventDefault(),t();return}if(l&&c&&n.shiftKey&&n.key==="z"){n.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var Wv={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${Se.formatDate(e.startDate)} - ${Se.formatDate(e.endDate)}`);let a=Se.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=>Se.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function Sm(e){return {...Wv,...e}}var Xv=e=>{switch(e){case "compact":return 36;case "comfortable":return 42;case "spacious":return 52;default:return 42}},Fm=react.forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:n="week",rowDensity:l="comfortable",showThemeSelector:c=true,showExportButton:i=true,onExportSuccess:p,projectName:d,availableUsers:m=[],templates:g,enableAutoCriticalPath:y=true,persistExpandedState:x,persistFilter:h,clearFiltersKey:f,aiAssistant:b,locale:w="en",customTranslations:C,showCreateTaskButton:S=false,createTaskLabel:E,onCreateTask:k,taskFilter:v,onTaskFilterChange:A,toolbarRightContent:L,showBaseline:M,viewMode:J,onViewModeChange:H,projectForecast:Y,onThemeChange:T,onTaskClick:G,onTaskDblClick:te,onTaskContextMenu:Le,onTaskUpdate:R,onDependentTasksScheduled:q,onProgressChange:ye,onTaskEdit:_e,onTaskAddSubtask:O,onTaskMarkIncomplete:ee,onTaskSetInProgress:le,onDependencyCreate:Ce,onDependencyDelete:we,onBeforeTaskAdd:Be,onAfterTaskAdd:He,onBeforeTaskUpdate:at,onAfterTaskUpdate:ue,onBeforeTaskDelete:je,onAfterTaskDelete:Xe,permissions:xe,onCopySnapshotLink:kt}=a,nt=react.useContext(ki)?.theme,[ze,ct]=react.useState(nt||s||"dark"),[et,Ee]=react.useState(n),[V,D]=react.useState(l),[U,ae]=react.useState(1),[Ne,z]=react.useState("all"),[oe,Ge]=react.useState(J||"execution"),fe=J??oe,Ve=react.useCallback(P=>{Ge(P),H?.(P);},[H]),$e=M??fe==="oracle",[Ue,dt]=react.useState(a.showCriticalPath!==false),[ot,it]=react.useState(a.showDependencies!==false),[mt,Nt]=react.useState(a.highlightWeekends!==false),$t=react.useCallback(P=>{dt(P),a.onShowCriticalPathChange?.(P);},[a.onShowCriticalPathChange]),Et=react.useCallback(P=>{it(P),a.onShowDependenciesChange?.(P);},[a.onShowDependenciesChange]),Mt=react.useCallback(P=>{Nt(P),a.onHighlightWeekendsChange?.(P);},[a.onHighlightWeekendsChange]);react.useEffect(()=>{a.onTimeScaleChange?.(et);},[et]),react.useEffect(()=>{a.onZoomChange?.(U);},[U]);let Ft=react.useRef(a.onDateRangeChange);Ft.current=a.onDateRangeChange;let gt=react.useCallback(()=>h?typeof h=="string"?h:"gantt-filter-state":null,[h]),[Vt,ht]=react.useState(()=>{if(!h)return "all";try{let P=typeof h=="string"?h:"gantt-filter-state",B=localStorage.getItem(P);if(B){let j=JSON.parse(B);if(j.taskFilter)return j.taskFilter}}catch(P){console.warn("[GanttBoard] Error loading filter state from localStorage:",P);}return "all"}),lt=v??Vt,ne=A??ht,[pe,$]=react.useState(()=>{if(!h)return false;try{let P=typeof h=="string"?h:"gantt-filter-state",B=localStorage.getItem(P);if(B){let j=JSON.parse(B);if(typeof j.hideCompleted=="boolean")return j.hideCompleted}}catch(P){console.warn("[GanttBoard] Error loading hideCompleted state from localStorage:",P);}return false});react.useEffect(()=>{let P=gt();if(P)try{let B={taskFilter:lt,hideCompleted:pe};localStorage.setItem(P,JSON.stringify(B));}catch(B){console.warn("[GanttBoard] Error saving filter state to localStorage:",B);}},[lt,pe,gt]);let _=react.useRef(f);react.useEffect(()=>{if(_.current!==f&&f!==void 0){ht("all"),$(false);let P=gt();if(P)try{localStorage.removeItem(P);}catch(B){console.warn("[GanttBoard] Error clearing filter state from localStorage:",B);}}_.current=f;},[f,gt]);let[De,Qe]=react.useState(0),[ut,St]=react.useState(false),[Pt,At]=react.useState(null),[Qt,oa]=react.useState({isOpen:false,x:0,y:0,task:null}),[Q,Oe]=react.useState(null),[Pe,I]=react.useState(null);react.useEffect(()=>{nt&&nt!==ze&&ct(nt);},[nt]),react.useEffect(()=>{s&&s!==ze&&ct(s);},[s]);let ve=react.useCallback(P=>{ct(P),T?.(P);},[T]),{state:Z,setState:N,undo:K,redo:Te,canUndo:Ae,canRedo:Ot,clearHistory:Tt}=Nm(t,50),Jt=react.useMemo(()=>{let P=(B,j=0)=>{let X=j;for(let he of B)he.subtasks?.length&&(X=Math.max(X,P(he.subtasks,j+1)));return X};return P(Z)+1},[Z]),Wa=react.useCallback(()=>x?typeof x=="string"?x:"gantt-expanded-tasks":null,[x]),ya=react.useRef(new Map),wa=react.useRef(false);if(!wa.current&&x){wa.current=true;let P=typeof x=="string"?x:"gantt-expanded-tasks";try{let B=localStorage.getItem(P);if(B){let j=JSON.parse(B);Array.isArray(j)&&(ya.current=new Map(j));}}catch(B){console.warn("[GanttBoard] Error loading expanded state from localStorage:",B);}}let dr=react.useCallback(()=>{let P=Wa();if(P)try{let B=Array.from(ya.current.entries());localStorage.setItem(P,JSON.stringify(B));}catch(B){console.warn("[GanttBoard] Error saving expanded state to localStorage:",B);}},[Wa]),Ar=react.useRef(0),Zn=react.useRef(Z);react.useEffect(()=>{Zn.current=Z;},[Z]);let Wr=react.useRef(false),F=react.useCallback(P=>{z(P),Ar.current+=1,N(B=>{let j=(he,Me=0)=>he.map(Ct=>{let st=P==="all"||Me<P-1;return Ct.subtasks?.length&&ya.current.set(Ct.id,st),{...Ct,isExpanded:st,subtasks:Ct.subtasks?j(Ct.subtasks,Me+1):void 0}}),X=j(B);return dr(),X});},[N,dr]);react.useEffect(()=>{if(Ar.current>0){Ar.current-=1;return}let P=j=>{let X=new Map;for(let he of j){let Me=he.id;X.get(Me)||X.set(Me,he);}return Array.from(X.values())},B=j=>j.map(X=>{let he=ya.current.get(X.id),Me=he!==void 0?{...X,isExpanded:he}:X;if(Me.subtasks?.length){let Ct=P(Me.subtasks);return {...Me,subtasks:B(Ct)}}return Me});if(ya.current.size>0)N(Or(B(t)));else {let j=X=>X.map(he=>he.subtasks?.length?{...he,subtasks:P(j(he.subtasks))}:he);N(Or(j(t)));}},[t,N]);let se=react.useRef(t),ge=react.useRef(true);react.useEffect(()=>{if(ge.current){ge.current=false,se.current=Z;return}if(Wr.current){Wr.current=false,se.current=Z;return}if(!r)return;let P=JSON.stringify(se.current),B=JSON.stringify(Z);P!==B&&(se.current=Z,r(Z));},[Z,r]);let ke=react.useMemo(()=>kd(w,C),[w,C]),Re=react.useCallback(P=>[{id:"name",label:P.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:P.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:P.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:P.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:P.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:P.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:P.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:P.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[tt,me]=react.useState(()=>Re(ke));react.useEffect(()=>{me(P=>P.map(B=>({...B,label:ke.columns[B.id==="name"?"taskName":B.id]||B.label})));},[ke]);let Ke=react.useMemo(()=>tt.filter(B=>B.visible).reduce((B,j)=>B+j.width,0),[tt]),Ze=react.useRef(tt.filter(P=>P.visible).map(P=>P.id).join(","));react.useEffect(()=>{let P=tt.filter(X=>X.visible),B=P.map(X=>X.id).join(","),j=Ze.current;if(B!==j){let X=P.some(Me=>Me.id!=="name"),he=j.includes(",");X?!he&&X&&At(null):At(null),Ze.current=B;}},[tt]);let yt=60,na=.6,jt=react.useMemo(()=>{let B=Ke+yt,j=typeof window<"u"?window.innerWidth*na:800,X=Math.max(B,j);return Pt!==null?Math.max(200,Math.min(Pt,X)):Math.max(200,B)},[Pt,Ke]),Ut=react.useRef(null),sa=react.useRef(null),_t=react.useRef(null),Ba=react.useRef(null),Dt=react.useMemo(()=>Gp(ze),[ze]),mr=react.useMemo(()=>({theme:Dt,themeName:ze}),[Dt,ze]),No=react.useMemo(()=>Sm(g),[g]),Vr=react.useMemo(()=>{if(!y)return Z;let P=Se.calculateCriticalPathFull(Z),B=j=>j.map(X=>{let he=P.get(X.id),Me=X.subtasks?B(X.subtasks):void 0,Ct=Me?.some(ka=>ka.isCriticalPath||ka.subtasks&&ka.subtasks.some(Zt=>Zt.isCriticalPath))||false,st=he?he.isCritical:Ct;return {...X,isCriticalPath:st,cpmData:he||void 0,subtasks:Me}});return B(Z)},[Z,y]),Do=react.useMemo(()=>Se.flattenTasks(Z).some(B=>B.dependencies&&B.dependencies.length>0),[Z]),fo=react.useMemo(()=>{let P=(B,j="")=>[...B].sort((he,Me)=>(he.position??0)-(Me.position??0)).map((he,Me)=>{let Ct=Me+1,st=j?`${j}.${Ct}`:`${Ct}.0`,ka=j?`${j}.${Ct}`:`${Ct}`;return {...he,wbsCode:st,subtasks:he.subtasks?.length?P(he.subtasks,ka):he.subtasks}});return P(Vr)},[Vr]),Xc=react.useMemo(()=>{if(lt==="all"&&!pe)return fo;let P=B=>{let j=[];for(let X of B){let he=X.subtasks?.length?P(X.subtasks):void 0,Me=false;if(pe)Me=X.progress<100;else switch(lt){case "all":Me=true;break;case "incomplete":Me=X.progress<100;break;case "in_progress":Me=X.progress>0&&X.progress<100;break;case "completed":Me=X.progress===100;break}(Me||he&&he.length>0)&&j.push({...X,subtasks:he});}return j};return P(fo)},[fo,lt,pe]),Gs=Xv(V);Dm({undo:K,redo:Te,canUndo:Ae,canRedo:Ot,enabled:true}),react.useImperativeHandle(o,()=>({getTask:P=>Se.findTaskById(Z,P),addTask:(P,B)=>{N(j=>{if(!B)return [...j,{...P,level:0}];let X=he=>he.map(Me=>Me.id===B?{...Me,subtasks:[...Me.subtasks||[],{...P,parentId:B,level:(Me.level||0)+1}],isExpanded:true}:Me.subtasks?{...Me,subtasks:X(Me.subtasks)}:Me);return X(j)});},updateTask:(P,B)=>{N(j=>{let X=he=>he.map(Me=>Me.id===P?{...Me,...B}:Me.subtasks?{...Me,subtasks:X(Me.subtasks)}:Me);return X(j)});},deleteTask:P=>{N(B=>{let j=X=>X.filter(he=>he.id===P?false:(he.subtasks&&(he.subtasks=j(he.subtasks)),true));return j(B)});},deleteTasks:P=>{N(B=>Pd(B,P));},duplicateTask:P=>{if(a.onTaskDuplicate){let B=Se.findTaskById(Z,P);B&&a.onTaskDuplicate(B);}else N(B=>ws(B,[P]).tasks);},splitTask:(P,B,j=3)=>{N(X=>Se.splitTask(X,P,B,j));},calculateEndDate:Se.calculateEndDate,calculateDuration:Se.calculateDuration,validateDependency:(P,B)=>!Se.validateDependencies(Z,P,B),getAllTasks:()=>Se.flattenTasks(Z),getTasksByStatus:P=>Se.flattenTasks(Z).filter(B=>B.status===P),getTasksByParent:P=>P?Se.findTaskById(Z,P)?.subtasks||[]:Z.filter(j=>!j.parentId),getCriticalPath:()=>Se.flattenTasks(Z).filter(P=>P.isCriticalPath),indentTask:P=>{N(B=>Or(Ed(B,[P])));},outdentTask:P=>{N(B=>Or(Md(B,[P])));},moveTask:(P,B)=>{N(j=>Fd(j,[P],B));},createSubtask:async P=>{let{tasks:B,newTask:j}=Id(Z,P);if(Be){let X=Be({...j,parentId:P});if((X instanceof Promise?await X:X)===false)return}N(Or(B)),He&&He({...j,parentId:P});},scrollToTask:P=>{let j=Se.flattenTasks(Z).findIndex(X=>X.id===P);if(j!==-1&&Ut.current){let X=j*Gs;Ut.current.scrollTo({top:X,behavior:"smooth"}),_t.current&&_t.current.scrollTo({top:X,behavior:"smooth"});}},highlightTask:(P,B=2e3)=>{},expandTask:P=>{N(B=>{let j=X=>X.map(he=>he.id===P?{...he,isExpanded:true}:he.subtasks?{...he,subtasks:j(he.subtasks)}:he);return j(B)});},collapseTask:P=>{N(B=>{let j=X=>X.map(he=>he.id===P?{...he,isExpanded:false}:he.subtasks?{...he,subtasks:j(he.subtasks)}:he);return j(B)});},expandAll:()=>{N(P=>{let B=j=>j.map(X=>({...X,isExpanded:true,subtasks:X.subtasks?B(X.subtasks):void 0}));return B(P)});},collapseAll:()=>{N(P=>{let B=j=>j.map(X=>({...X,isExpanded:false,subtasks:X.subtasks?B(X.subtasks):void 0}));return B(P)});},collapseToLevel:P=>{F(P);},undo:K,redo:Te,canUndo:()=>Ae,canRedo:()=>Ot,clearHistory:Tt,exportToPNG:async()=>{if(!Ba.current||!Ut.current||!_t.current)throw new Error("Gantt container not found");let P=Ba.current,B=Ut.current,j=sa.current||B.querySelector(".gantt-grid-scroll"),X=_t.current,he=j?.scrollTop||0,Me=X.scrollTop,Ct=P.style.overflow,st=P.style.height,ka=B.style.overflow;try{let Zt=j?.querySelector(".gantt-taskgrid-content"),fa=X.querySelector("svg"),lr=Zt?.scrollHeight||j?.scrollHeight||600,Sr=fa?.getBoundingClientRect().height||X.scrollHeight,Xo=(P.querySelector('[style*="z-index: 100"]')?.offsetHeight||48)+Math.max(lr,Sr)+20;j&&(j.scrollTop=0),X.scrollTop=0,P.style.overflow="visible",P.style.height=`${Xo}px`,B.style.overflow="visible",await new Promise(wn=>setTimeout(wn,100));let ro=await htmlToImage.toPng(P,{backgroundColor:Dt.bgPrimary,pixelRatio:2,filter:wn=>{if(!(wn instanceof Element))return !0;let js=window.getComputedStyle(wn),ts=parseInt(js.zIndex,10);return (isNaN(ts)||ts<50)&&js.position!=="fixed"}});return await(await fetch(ro)).blob()}finally{P.style.overflow=Ct,P.style.height=st,B.style.overflow=ka,j&&(j.scrollTop=he),X.scrollTop=Me;}},exportToPDF:async P=>{await Se.exportToPDF(Z,P);},exportToExcel:async P=>{await Se.exportToExcel(Z,P,fl.current);},exportToJSON:()=>Se.exportToJSON(Z),exportToCSV:()=>Se.exportToCSV(Z),importFromJSON:P=>{let B=Se.importFromJSON(P);N(B);},getTasks:()=>Z,refresh:()=>{N(P=>[...P]);},clearAll:()=>{N([]);}}),[Z,K,Te,Ae,Ot,Tt,Dt,Gs]);let df=react.useCallback(P=>{me(B=>B.map(j=>j.id===P?{...j,visible:!j.visible}:j));},[]),cf=react.useCallback((P,B)=>{me(j=>j.map(X=>{if(X.id!==P)return X;let he=X.minWidth??100,Me=X.maxWidth??800,Ct=Math.max(he,Math.min(Me,B));return {...X,width:Ct}}));},[]),uf=react.useCallback(P=>{N(B=>{let j=Ld(B,P),X=he=>{for(let Me of he){if(Me.id===P){ya.current.set(P,Me.isExpanded??true);return}Me.subtasks?.length&&X(Me.subtasks);}};return X(j),dr(),j}),a.onTaskToggleExpand?.(P);},[a,dr]),So=react.useCallback((P,B)=>{if(at&&at(P,B)===false)return;let X=Se.findTaskById(Z,P)?.progress,he=Ct=>Ct.map(st=>st.id===P?{...st,...B}:st.subtasks?{...st,subtasks:he(st.subtasks)}:st);N(he(Z));let Me=Se.findTaskById(he(Z),P);Me&&(R?.(Me),ue?.(Me),B.progress!==void 0&&X!==void 0&&B.progress!==X&&ye?.(P,X,B.progress));},[Z,R,at,ue,ye]),pf=react.useCallback(P=>{P.length!==0&&(Ar.current+=1,Wr.current=true,N(B=>Or(Ed(B,P))),a.onTaskIndent?.(P[0]));},[a]),mf=react.useCallback(P=>{P.length!==0&&(Ar.current+=1,Wr.current=true,N(B=>Or(Md(B,P))),a.onTaskOutdent?.(P[0]));},[a]),gf=react.useCallback((P,B,j)=>{Ar.current+=1,Wr.current=true,N(X=>Or(pm(X,P,B,j))),a.onTaskReparent?.(P,B,j);},[a]),ff=react.useCallback((P,B)=>{P.length!==0&&(Ar.current+=1,Wr.current=true,N(j=>Fd(j,P,B)),a.onTaskMove?.(P[0],B));},[a]),pl=react.useCallback(async P=>{let B=[];for(let j of P)je&&await Promise.resolve(je(j))===false||B.push(j);B.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(B):(N(j=>Or(Pd(j,B))),B.forEach(j=>a.onTaskDelete?.(j))),Xe&&B.forEach(j=>Xe(j)));},[a,je,Xe]),bf=react.useCallback(P=>{a.onTaskDuplicate?P.forEach(B=>{let j=Se.findTaskById(Z,B);j&&a.onTaskDuplicate(j);}):N(B=>ws(B,P).tasks);},[a,Z]),hf=react.useCallback((P,B)=>{N(j=>{let{tasks:X,newTask:he}=um(j,P,B);return Be&&Be(he)===false?j:(a.onTaskCreate?.(he.parentId,he.position||0),He?.(he),X)});},[a,Be,He]),yf=react.useCallback((P,B)=>{N(j=>Ad(j,P,B)),a.onTaskRename?.(P,B);},[a]),ml=react.useCallback(P=>{let{onTaskAddSubtask:B}=a;if(B){let j=On(Z,P);if(j){B(j);return}}N(j=>{let{tasks:X}=Id(j,P);return a.onTaskCreate?.(P,0),X});},[a,Z]),xf=react.useCallback((P,B)=>{let j=Math.max(0,Math.min(100,Math.round(B))),X={progress:j};j===100?X.status="completed":j>0?X.status="in-progress":X.status="todo",So(P.id,X);},[So]),vf=react.useCallback((P,B,j)=>{let X=!P.startDate&&!P.endDate,he=P.startDate?Math.round((B.getTime()-P.startDate.getTime())/(1e3*60*60*24)):0,Me=Zt=>Zt.map(fa=>fa.id===P.id?{...fa,startDate:B,endDate:j,...P.segments&&{segments:P.segments}}:fa.subtasks?{...fa,subtasks:Me(fa.subtasks)}:fa),Ct=Me(Z),st=Ct;Ct=Se.autoScheduleDependents(Ct,P.id,he),Ct=Or(Ct),N(Ct);let ka={...P,startDate:B,endDate:j};if(X&&a?.onTaskDateChange?a.onTaskDateChange(P,B,j):R?.(ka),q&&he!==0){let Zt=Se.flattenTasks(st),fa=Se.flattenTasks(Ct),lr=[];for(let Sr of fa){if(Sr.id===P.id)continue;let Eo=Zt.find(ro=>ro.id===Sr.id);if(!Eo)continue;let vn=Sr.startDate?.getTime()!==Eo.startDate?.getTime(),Xo=Sr.endDate?.getTime()!==Eo.endDate?.getTime();(vn||Xo)&&lr.push(Sr);}lr.length>0&&q(lr);}},[Z,R,q,a]),wf=react.useCallback((P,B)=>{Le?.(P,B),oa({isOpen:true,x:B.clientX,y:B.clientY,task:P});},[Le]),kf=react.useCallback((P,B)=>{let j=Se.splitTask(Z,P.id,B);N(j),oa({isOpen:false,x:0,y:0,task:null});},[Z]),Jc=react.useCallback(P=>{let B=Se.findTaskById(Z,P.id)||P;te?.(B),_e||Oe(B);},[Z,te,_e]),Qc=react.useCallback((P,B,j)=>{let X=new Map,he=Zt=>{Zt.forEach(fa=>{fa.dependencies&&X.set(fa.id,fa.dependencies),fa.subtasks&&he(fa.subtasks);});};he(j);let Me=X.get(B)||[];X.set(B,[...Me,P]);let Ct=new Set,st=new Set,ka=Zt=>{if(!Ct.has(Zt)){Ct.add(Zt),st.add(Zt);let fa=X.get(Zt)||[];for(let lr of fa){if(!Ct.has(lr)&&ka(lr))return true;if(st.has(lr))return true}}return st.delete(Zt),false};return ka(B)},[]),Zc=react.useCallback((P,B)=>{if(Qc(P.id,B,Zn.current)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
|
|
367
367
|
|
|
368
|
-
Task dependencies must flow in one direction only.`);return}let j=X=>X.map(he=>{if(he.id===B){let Me=he.dependencies||[];if(!Me.includes(P.id))return {...he,dependencies:[...Me,P.id]}}return he.subtasks?{...he,subtasks:j(he.subtasks)}:he});Ar.current+=1,N(X=>j(X)),Ce?.(P.id,B);},[Ce,Qc]),eu=react.useCallback((P,B)=>{let j=X=>X.map(he=>{if(he.id===P&&he.dependencies){let Me=he.dependencies.filter(Ct=>Ct!==B);return {...he,dependencies:Me}}return he.subtasks?{...he,subtasks:j(he.subtasks)}:he});Ar.current+=1,N(X=>j(X)),we?.(P,B);},[we]),{startDate:yn,endDate:gl}=react.useMemo(()=>{let P=Z.filter(Me=>Me.startDate&&Me.endDate);if(P.length===0){let Me=new Date,Ct=new Date(Me);Ct.setDate(Ct.getDate()-30);let st=new Date(Me);return st.setDate(st.getDate()+60),{startDate:Ct,endDate:st}}let B=P.flatMap(Me=>[Me.startDate,Me.endDate]).filter(Me=>Me!==void 0),j=new Date(Math.min(...B.map(Me=>Me.getTime()))),X=new Date(Math.max(...B.map(Me=>Me.getTime()))),he=et==="day"?7:et==="week"?14:30;return j.setDate(j.getDate()-he),X.setDate(X.getDate()+he),{startDate:j,endDate:X}},[Z,et]);react.useEffect(()=>{Ft.current?.(yn,gl);},[yn,gl]);let Cf=react.useCallback(async()=>{if(!Ba.current||!Ut.current||!_t.current)return;await new Promise(Xo=>setTimeout(Xo,200));let P=Ba.current,B=Ut.current,j=sa.current||B.querySelector(".gantt-grid-scroll"),X=_t.current,he=j?.scrollTop||0,Me=j?.scrollLeft||0,Ct=X.scrollTop,st=X.scrollLeft,ka=P.style.overflow,Zt=P.style.height,fa=j?.style.overflow||"",lr=X.style.overflow,Sr=B.style.overflow,Eo=P.style.width,vn=X.style.width;try{let Xo=j?.querySelector(".gantt-taskgrid-content"),ro=X.querySelector("svg"),hl=ro?.getAttribute("height")?parseInt(ro.getAttribute("height"),10):ro?.getBoundingClientRect().height||0,wn=Xo?.scrollHeight||j?.scrollHeight||600,js=Math.max(hl,X.scrollHeight),ts=ro?.getAttribute("width")?parseInt(ro.getAttribute("width"),10):ro?.getBoundingClientRect().width||X.scrollWidth,Pf=P.querySelector('[style*="z-index: 100"]')?.offsetHeight||48,yl=Math.max(wn,js,hl),ru=Pf+yl+50,ou=(j?.offsetWidth||B.offsetWidth||300)+ts+10;j&&(j.scrollTop=0,j.scrollLeft=0),X.scrollTop=0,X.scrollLeft=0,P.style.overflow="visible",P.style.height=`${ru}px`,P.style.width=`${ou}px`,B.style.overflow="visible",j&&(j.style.overflow="visible",j.style.height=`${yl+50}px`),X.style.overflow="visible",X.style.height=`${yl+50}px`,X.style.width=`${ts+10}px`,await new Promise(_s=>setTimeout(_s,150));let Af=await htmlToImage.toPng(P,{backgroundColor:Dt.bgPrimary,pixelRatio:2,width:ou,height:ru,skipFonts:!1,filter:_s=>{if(!(_s instanceof Element))return !0;let nu=window.getComputedStyle(_s),su=parseInt(nu.zIndex,10);return !(!isNaN(su)&&su>=50||nu.position==="fixed")}}),xl=document.createElement("a");xl.download=`gantt-chart-${new Date().toISOString().slice(0,10)}.png`,xl.href=Af,xl.click();}finally{P.style.overflow=ka,P.style.height=Zt,P.style.width=Eo,B.style.overflow=Sr,j&&(j.style.overflow=fa,j.style.height="",j.scrollTop=he,j.scrollLeft=Me),X.style.overflow=lr,X.style.height="",X.style.width=vn,X.scrollTop=Ct,X.scrollLeft=st;}p?.("png");},[Dt,p]),Tf=react.useCallback(async()=>{await Se.exportToPDF(Z),p?.("pdf");},[Z,p]),fl=react.useRef({rateMap:a.rateMap,defaultRate:a.defaultRate,projectName:d});fl.current={rateMap:a.rateMap,defaultRate:a.defaultRate,projectName:d};let Nf=react.useCallback(async()=>{let P=new Date,B=he=>String(he).padStart(2,"0"),j=`${P.getFullYear()}-${B(P.getMonth()+1)}-${B(P.getDate())}_${B(P.getHours())}${B(P.getMinutes())}`,X=d?d.replace(/[^a-zA-Z0-9áéíóúñÁÉÍÓÚÑ _-]/g,""):"Project";await Se.exportToExcel(Z,`${X}_${j}.xlsx`,fl.current),p?.("excel");},[Z,d,p]),Df=react.useCallback(()=>{let P=Se.exportToCSV(Z),B=new Blob([P],{type:"text/csv;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(B),j.download="gantt-chart.csv",j.click(),URL.revokeObjectURL(j.href),p?.("csv");},[Z,p]),Sf=react.useCallback(()=>{let P=Se.exportToJSON(Z),B=new Blob([P],{type:"application/json;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(B),j.download="gantt-chart.json",j.click(),URL.revokeObjectURL(j.href),p?.("json");},[Z,p]),Ef=react.useCallback(()=>{Se.exportToMSProject(Z,"Gantt Project","project.xml"),p?.("msproject");},[Z,p]),Mf=P=>{P.preventDefault(),St(true);},xn=react.useRef(false),[bl,tu]=react.useState(false),es=react.useRef({x:0,y:0,scrollLeft:0,scrollTop:0});react.useEffect(()=>{let P=_t.current,B=Ut.current?.querySelector(".gantt-grid-scroll");if(!P||!B)return;let j=()=>{if(xn.current)return;xn.current=true;let st=P.scrollTop;Qe(st),B.scrollTop=st,requestAnimationFrame(()=>{xn.current=false;});},X=()=>{if(xn.current)return;xn.current=true;let st=B.scrollTop;Qe(st),P.scrollTop=st,requestAnimationFrame(()=>{xn.current=false;});},he=st=>{if(ut&&B){let Zt=B.parentElement?.getBoundingClientRect()?.left||0,fa=st.clientX-Zt,lr=200,Sr=Ke+yt,Eo=window.innerWidth*na,vn=Math.max(Sr,Eo);fa>=lr&&fa<=vn&&At(fa);}if(bl&&P){let ka=st.clientX-es.current.x,Zt=st.clientY-es.current.y;P.scrollLeft=es.current.scrollLeft-ka,P.scrollTop=es.current.scrollTop-Zt;}},Me=()=>{St(false),tu(false);},Ct=st=>{if(st.button!==0)return;let ka=st.target;ka.closest("[data-task-bar]")||ka.closest("[data-dependency-line]")||ka.closest("button")||ka.closest('[role="button"]')||ka.tagName==="rect"&&ka.getAttribute("data-clickable")==="true"||(tu(true),es.current={x:st.clientX,y:st.clientY,scrollLeft:P.scrollLeft,scrollTop:P.scrollTop},st.preventDefault());};return P.addEventListener("scroll",j),B.addEventListener("scroll",X),P.addEventListener("mousedown",Ct),document.addEventListener("mousemove",he),document.addEventListener("mouseup",Me),()=>{P.removeEventListener("scroll",j),B.removeEventListener("scroll",X),P.removeEventListener("mousedown",Ct),document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",Me);}},[ut,bl,Ke]);let au=react.useRef(false),Ff=react.useRef(null);return react.useLayoutEffect(()=>{if(au.current||Z.length===0||!_t.current)return;au.current=true,Ff.current=yn;let P=_t.current,B=new Date,j=et==="day"?60:et==="week"?20:8,X=(B.getTime()-yn.getTime())/(1e3*60*60*24),he=P.clientWidth,Ct=X*j*U-he/2;X>=0&&he>0&&(P.scrollLeft=Math.max(0,Ct));},[Z.length,yn,et,U]),jsxRuntime.jsx(In.Provider,{value:ke,children:jsxRuntime.jsx(Tl.Provider,{value:mr,children:jsxRuntime.jsxs("div",{ref:Ba,className:"flex flex-col h-full w-full",style:{backgroundColor:Dt.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...Dt.dotGrid&&{backgroundImage:`radial-gradient(circle, ${Dt.dotGrid} 1px, transparent 1px)`,backgroundSize:"24px 24px"},...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsxRuntime.jsx("div",{style:{position:"relative",zIndex:100},children:jsxRuntime.jsx(Ti,{theme:Dt,timeScale:et,onTimeScaleChange:Ee,zoom:U,onZoomChange:ae,currentTheme:ze,onThemeChange:ve,rowDensity:V,onRowDensityChange:D,showThemeSelector:c,showCreateTaskButton:S&&xe?.canCreateTask!==false&&!xe?.canCreateSubtaskOnly,createTaskLabel:E,onCreateTask:k,taskFilter:lt,onTaskFilterChange:ne,hideCompleted:pe,onHideCompletedChange:$,toolbarRightContent:L,wbsLevel:Ne,onWbsLevelChange:F,maxWbsDepth:Jt,viewMode:fe,onViewModeChange:Ve,projectForecast:Y,onExportPNG:i?Cf:void 0,onExportPDF:i?Tf:void 0,onExportExcel:i?Nf:void 0,onExportCSV:i?Df:void 0,onExportJSON:i?Sf:void 0,onExportMSProject:i?Ef:void 0,showCriticalPath:Ue,onShowCriticalPathChange:$t,showDependencies:ot,onShowDependenciesChange:Et,highlightWeekends:mt,onHighlightWeekendsChange:Mt,showBaseline:$e,onShowBaselineChange:P=>{P&&fe!=="oracle"&&Ve("oracle"),!P&&fe==="oracle"&&Ve("execution");},onCopySnapshotLink:kt,hasDependencies:Do})}),jsxRuntime.jsxs("div",{ref:Ut,className:"flex-1 flex min-h-0",style:{position:"relative",zIndex:1,overflow:"clip",overflowClipMargin:"100px"},children:[jsxRuntime.jsx("div",{ref:sa,className:"gantt-grid-scroll flex-shrink-0",style:{width:jt,overflowX:"auto",overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:jsxRuntime.jsx(Si,{tasks:Xc,theme:Dt,rowHeight:Gs,availableUsers:m,templates:No,showCriticalPath:Ue,onTaskClick:G,onTaskDblClick:Jc,onTaskContextMenu:Le,onTaskToggle:uf,scrollTop:De,columns:tt,onToggleColumn:df,onColumnResize:cf,onTaskUpdate:So,onTaskIndent:pf,onTaskOutdent:mf,onTaskMove:ff,onMultiTaskDelete:pl,onTaskDuplicate:bf,onTaskCreate:hf,onTaskRename:yf,onCreateSubtask:ml,onOpenTaskModal:G?P=>G(P):void 0,onDeleteRequest:(P,B)=>I({taskId:P,taskName:B}),onTaskReparent:gf,scrollContainerRef:sa})}),jsxRuntime.jsx("div",{className:"flex-shrink-0 cursor-col-resize hover:bg-blue-500/50 transition-colors h-full",style:{width:1,backgroundColor:Dt.border,zIndex:15},onMouseDown:Mf}),jsxRuntime.jsx("div",{ref:_t,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",cursor:bl?"grabbing":"grab",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsxRuntime.jsx(Bi,{tasks:Xc,theme:Dt,rowHeight:Gs,timeScale:et,startDate:yn,endDate:gl,zoom:U,locale:w,templates:No,dependencyLineStyle:a?.dependencyLineStyle,showTaskBarLabels:a?.showTaskBarLabels!==false,onTaskClick:G,onTaskDblClick:Jc,onTaskContextMenu:wf,onTaskDateChange:vf,onTaskProgressDrag:xf,onDependencyCreate:Zc,onDependencyDelete:eu,showBaseline:$e,showCriticalPath:Ue,showDependencies:ot,highlightWeekends:mt,canEditTask:xe?.canEditTask})})]}),Qt.task&&jsxRuntime.jsx(Rn,{isOpen:Qt.isOpen,x:Qt.x,y:Qt.y,theme:Dt,onClose:()=>oa({isOpen:false,x:0,y:0,task:null}),items:(()=>{let P=Qt.task;if(!P)return [];let B=Se.findTaskById(Z,P.id)||P,j=B.subtasks&&B.subtasks.length>0,X=xe?.canCreateTask!==false,he=xe?.canDeleteTask!==false;if(j){let Zt=[],fa=xe?.canDuplicateTask!==false;return X&&Zt.push({id:"addSubtask",label:ke.contextMenu?.addSubtask||"Add Subtask",icon:ma.Add,onClick:()=>{O?O(B):ml(B.id);}}),fa&&Zt.push({id:"duplicate",label:ke.contextMenu?.duplicateTask||"Duplicate Task",icon:ma.Duplicate,onClick:()=>{a.onTaskDuplicate?a.onTaskDuplicate(B):N(lr=>ws(lr,[B.id]).tasks),oa({isOpen:false,x:0,y:0,task:null});}}),he&&(Zt.length>0&&Zt.push({id:"separator-delete",label:"",separator:true,onClick:()=>{}}),Zt.push({id:"delete",label:ke.contextMenu?.deleteTask||"Delete Task",icon:ma.Delete,onClick:()=>{I({taskId:B.id,taskName:B.name});}})),Zt}let Me=xe?.canUpdateTask!==false,Ct=xe?.canDuplicateTask!==false,st=[];return Me&&st.push({id:"edit",label:ke.contextMenu?.editTask||"Edit Task",icon:ma.Pencil,onClick:()=>{_e?_e(B):Oe(B);}}),X&&st.push({id:"addSubtask",label:ke.contextMenu?.addSubtask||"Add Subtask",icon:ma.Add,onClick:()=>{O?O(B):ml(B.id);}}),st.length>0&&Me&&st.push({id:"separator-status",label:"",separator:true,onClick:()=>{}}),Me&&(st.push({id:"markIncomplete",label:ke.contextMenu?.markIncomplete||"Mark Incomplete",icon:ma.MarkIncomplete,onClick:()=>{ee?ee(B):So(B.id,{status:"todo",progress:0});},disabled:B.status==="todo"}),st.push({id:"setInProgress",label:ke.contextMenu?.setInProgress||"Set In Progress",icon:ma.SetInProgress,onClick:()=>{le?le(B):So(B.id,{status:"in-progress"});},disabled:B.status==="in-progress"}),st.push({id:"markComplete",label:ke.contextMenu?.markComplete||"Mark Complete",icon:ma.MarkComplete,onClick:()=>{So(B.id,{status:"completed",progress:100});},disabled:B.status==="completed"})),(Ct||Me&&B.startDate&&B.endDate)&&st.length>0&&st.push({id:"separator-advanced",label:"",separator:true,onClick:()=>{}}),Ct&&st.push({id:"duplicate",label:ke.contextMenu?.duplicateTask||"Duplicate Task",icon:ma.Duplicate,onClick:()=>{a.onTaskDuplicate?a.onTaskDuplicate(B):N(Zt=>ws(Zt,[B.id]).tasks),oa({isOpen:false,x:0,y:0,task:null});}}),Me&&B.startDate&&B.endDate&&st.push({id:"split",label:ke.contextMenu?.splitTask||"Split Task",icon:ma.Split,onClick:()=>{let Zt=B.startDate.getTime(),fa=B.endDate.getTime(),lr=Zt+(fa-Zt)/2,Sr=new Date(lr);kf(B,Sr);}}),he&&(st.length>0&&st.push({id:"separator-delete",label:"",separator:true,onClick:()=>{}}),st.push({id:"delete",label:ke.contextMenu?.deleteTask||"Delete Task",icon:ma.Delete,onClick:()=>{I({taskId:B.id,taskName:B.name});}})),st})()}),jsxRuntime.jsx(yo,{task:Q,isOpen:!!Q,onClose:()=>Oe(null),onTaskUpdate:P=>{Q&&(So(Q.id,P),Oe(null));},theme:ze==="light"?"light":"dark",locale:w==="es"?"es":"en",availableUsers:m,availableTasks:t}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:Pe&&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:()=>I(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:P=>P.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:Dt.bgSecondary,border:`1px solid ${Dt.border}`},children:[jsxRuntime.jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${Dt.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:Dt.textPrimary,fontFamily:"Inter, sans-serif"},children:[ke.contextMenu?.deleteTask||"Delete Task","?"]}),jsxRuntime.jsx("p",{className:"text-sm mt-1",style:{color:Dt.textSecondary,fontFamily:"Inter, sans-serif"},children:w==="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:Dt.textSecondary,fontFamily:"Inter, sans-serif"},children:[w==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxRuntime.jsxs("span",{className:"font-semibold",style:{color:Dt.textPrimary},children:['"',Pe.taskName,'"']}),"."]})}),jsxRuntime.jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:Dt.bgPrimary,borderTop:`1px solid ${Dt.border}`},children:[jsxRuntime.jsx("button",{onClick:()=>I(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:Dt.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:P=>{P.currentTarget.style.backgroundColor=Dt.hoverBg;},onMouseLeave:P=>{P.currentTarget.style.backgroundColor="transparent";},children:w==="es"?"Cancelar":"Cancel"}),jsxRuntime.jsxs("button",{onClick:()=>{pl([Pe.taskId]),I(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:P=>{P.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:P=>{P.currentTarget.style.backgroundColor="#EF4444";},children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"}),w==="es"?"Eliminar":"Delete"]})]})]})})}),b?.enabled&&jsxRuntime.jsx(Oi,{tasks:Z,theme:Dt,config:b,onTasksUpdate:N,onTaskUpdate:So,onTaskCreate:P=>{N(B=>[...B,P]);},onTaskDelete:P=>{pl([P]);},onDependencyCreate:(P,B)=>{let j=Se.findTaskById(Z,P);j&&Zc(j,B);},onDependencyDelete:eu})]})})})});function i2(e){if(e<60)return `${e}m`;let t=Math.floor(e/60),a=e%60;return a===0?`${t}h`:`${t}h ${a}m`}function l2(e){if(!e||e.trim()==="")return null;let t=e.trim().toLowerCase(),a=t.match(/(\d+)h\s*(\d+)m/);if(a&&a[1]&&a[2]){let l=parseInt(a[1],10),c=parseInt(a[2],10);return l*60+c}let r=t.match(/(\d+)h/);if(r&&r[1])return parseInt(r[1],10)*60;let o=t.match(/(\d+)m/);if(o&&o[1])return parseInt(o[1],10);let s=t.match(/(\d+)d/);if(s&&s[1])return parseInt(s[1],10)*480;let n=t.match(/^(\d+)$/);return n&&n[1]?parseInt(n[1],10)*60:null}var $d=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],Od=[{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 Lm({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:n=false,mode:l=a?"edit":"create",theme:c="dark",customStatuses:i=[],availableTags:p=[],onCreateTag:d,attachments:m=[],onUploadAttachments:g,onDeleteAttachment:y,defaultStatus:x}){let h=[...$d,...i.filter(D=>!$d.some(U=>U.id===D.id))],f=ft[c]||ft.dark,[b,w]=react.useState(false),[C,S]=react.useState(false),[E,k]=react.useState(false),[v,A]=react.useState(false),[L,M]=react.useState({top:0,left:0}),[J,H]=react.useState(null),[Y,T]=react.useState(new Date),[G,te]=react.useState({top:0,left:0}),[Le,R]=react.useState(false),[q,ye]=react.useState([]),[_e,O]=react.useState(false),[ee,le]=react.useState(""),Ce=react.useRef(null),we=react.useRef(null),Be=react.useRef(null),He=react.useRef(null),at=react.useRef(null),[ue,je]=react.useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#2E94FF",assignees:[],dependencies:[],tags:[],parentId:null,location:"",equipment:""}),[Xe,xe]=react.useState({});react.useEffect(()=>{a?(je({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||"#2E94FF",assignees:a.assignees||[],dependencies:a.dependencies||[],tags:a.tags||[],parentId:a.parentId||null,location:a.location||"",equipment:a.equipment||""}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&R(true)):(je({name:"",description:"",progress:0,status:x||"todo",priority:"medium",isMilestone:false,color:"#2E94FF",assignees:[],dependencies:[],pendingFiles:[],tags:[],parentId:null,location:"",equipment:""}),R(false),ye([]));},[a,e,x]),react.useEffect(()=>{let D=U=>{Ce.current&&!Ce.current.contains(U.target)&&w(false),we.current&&!we.current.contains(U.target)&&S(false),Be.current&&!Be.current.contains(U.target)&&k(false),He.current&&!He.current.contains(U.target)&&A(false);};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);let kt=()=>{let D={};return ue.name.trim()||(D.name="El nombre es requerido"),ue.startDate&&ue.endDate&&ue.startDate>ue.endDate&&(D.endDate="La fecha de fin debe ser posterior a la de inicio"),xe(D),Object.keys(D).length===0},xt=async D=>{if(D.preventDefault(),!!kt())try{let U=l==="create"&&q.length>0?{...ue,pendingFiles:q}:ue;await s(U),ye([]),t();}catch(U){console.error("Error submitting task:",U);}},nt=(D,U)=>{je(ae=>{let Ne={...ae,[D]:U};if(D==="status"){let z=U;z==="todo"?Ne.progress=0:z==="in-progress"?(ae.progress===0||ae.progress===100)&&(Ne.progress=50):z==="completed"||z==="closed"?Ne.progress=100:(z==="in-review"||z==="review")&&(Ne.progress=75);}if(D==="progress"){let z=typeof U=="number"?U:parseInt(U,10);z===100&&ae.status!=="completed"?Ne.status="completed":z>0&&z<100&&ae.status==="todo"?Ne.status="in-progress":z===0&&ae.status!=="todo"&&(Ne.status="todo");}return Ne}),Xe[D]&&xe(ae=>{let Ne={...ae};return delete Ne[D],Ne});},ze=h.find(D=>D.id===ue.status)??$d[0],ct=Od.find(D=>D.id===ue.priority)??Od[1],et=an.find(D=>D.value===ue.color)??an[0],Ee=c==="dark",V={backgroundColor:Ee?"#1d1f27":f.bgSecondary,border:`1px solid ${Ee?"rgba(65,71,84,0.1)":f.borderLight}`,color:f.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 z-[9999]",style:{backgroundColor:Ee?"rgba(0, 0, 0, 0.85)":"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)"},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-[9999] flex items-center justify-center p-4 pointer-events-none",children:jsxRuntime.jsx("div",{className:"w-full max-w-[640px] rounded-xl pointer-events-auto flex flex-col","data-theme":c,style:{backgroundColor:Ee?"#0a0a0a":f.bgPrimary,border:`1px solid ${Ee?"rgba(65,71,84,0.1)":f.border}`,boxShadow:Ee?"0 8px 48px rgba(0, 0, 0, 0.8)":"0 8px 32px rgba(0, 0, 0, 0.12)",maxHeight:"90vh"},onClick:D=>D.stopPropagation(),children:jsxRuntime.jsxs("form",{onSubmit:xt,className:"flex flex-col overflow-hidden flex-1",style:{fontFamily:"'Inter', system-ui, sans-serif"},children:[jsxRuntime.jsxs("header",{className:"px-8 pt-8 pb-4 space-y-4 flex-shrink-0",children:[jsxRuntime.jsx("input",{type:"text",value:ue.name,onChange:D=>nt("name",D.target.value),className:"w-full bg-transparent border-none p-0 focus:outline-none focus:ring-0",style:{color:f.textPrimary,fontSize:30,fontWeight:700,fontFamily:"'Inter', system-ui, sans-serif"},placeholder:"Nombre de la tarea",disabled:n,autoFocus:true}),Xe.name&&jsxRuntime.jsxs("p",{className:"text-xs text-red-400 flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"w-3 h-3"}),Xe.name]}),jsxRuntime.jsx("textarea",{value:ue.description||"",onChange:D=>nt("description",D.target.value),className:"w-full bg-transparent border-none p-0 focus:outline-none focus:ring-0 resize-none task-form-description",style:{color:f.textPrimary,fontSize:16,fontFamily:"'Inter', system-ui, sans-serif","--placeholder-color":f.textTertiary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:n})]}),jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto px-8 py-4 space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxRuntime.jsxs("div",{ref:Ce,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!n&&w(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...V,borderColor:ze.color,backgroundColor:`${ze.color}15`},disabled:n,children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:ze.color}}),jsxRuntime.jsx("span",{style:{color:ze.color},children:ze.title}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:ze.color}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:b&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[140px] rounded-lg overflow-hidden",style:{backgroundColor:Ee?"#0a0a0a":f.bgPrimary,backdropFilter:Ee?"blur(16px)":void 0,border:`1px solid ${Ee?"#262626":f.border}`,boxShadow:Ee?"0 8px 24px rgba(0, 0, 0, 0.5)":"0 8px 24px rgba(0, 0, 0, 0.12)"},children:h.map(D=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:f.textPrimary},onMouseEnter:U=>U.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:U=>U.currentTarget.style.backgroundColor="transparent",onClick:()=>{nt("status",D.id),w(false);},children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:D.color}}),D.title,ue.status===D.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:f.accent}})]},D.id))})})]}),jsxRuntime.jsxs("div",{ref:we,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!n&&S(!C),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:n,children:[jsxRuntime.jsx(lucideReact.Flag,{className:"w-3.5 h-3.5",style:{color:ct.color}}),jsxRuntime.jsx("span",{children:ct.label}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:f.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:C&&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 overflow-hidden",style:{backgroundColor:Ee?"#0a0a0a":f.bgPrimary,backdropFilter:Ee?"blur(16px)":void 0,border:`1px solid ${Ee?"#262626":f.border}`,boxShadow:Ee?"0 8px 24px rgba(0, 0, 0, 0.5)":"0 8px 24px rgba(0, 0, 0, 0.12)"},children:Od.map(D=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:f.textPrimary},onMouseEnter:U=>U.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:U=>U.currentTarget.style.backgroundColor="transparent",onClick:()=>{nt("priority",D.id),S(false);},children:[jsxRuntime.jsx("span",{children:D.icon}),D.label,ue.priority===D.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:f.accent}})]},D.id))})})]}),o.length>0&&jsxRuntime.jsxs("div",{ref:Be,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!n&&k(!E),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:n,children:[ue.assignees&&ue.assignees.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex -space-x-1",children:ue.assignees.slice(0,3).map((D,U)=>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:D.color||f.accent,borderColor:f.bgSecondary},children:D.initials},U))}),ue.assignees.length>3&&jsxRuntime.jsxs("span",{style:{color:f.textTertiary},children:["+",ue.assignees.length-3]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Users,{className:"w-3.5 h-3.5",style:{color:f.textTertiary}}),jsxRuntime.jsx("span",{style:{color:f.textTertiary},children:"Asignar"})]}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:f.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:E&&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",style:{backgroundColor:Ee?"#0a0a0a":f.bgPrimary,backdropFilter:Ee?"blur(16px)":void 0,border:`1px solid ${Ee?"#262626":f.border}`,boxShadow:Ee?"0 8px 24px rgba(0, 0, 0, 0.5)":"0 8px 24px rgba(0, 0, 0, 0.12)"},children:o.map(D=>{let U=ue.assignees?.some(ae=>ae.name===D.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:f.textPrimary},onMouseEnter:ae=>ae.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:ae=>ae.currentTarget.style.backgroundColor="transparent",onClick:()=>{let ae=U?(ue.assignees||[]).filter(Ne=>Ne.name!==D.name):[...ue.assignees||[],{name:D.name,avatar:D.avatar,initials:D.name.split(" ").map(Ne=>Ne[0]).join("").toUpperCase().slice(0,2),color:f.accent}];nt("assignees",ae);},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:f.accent},children:D.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"truncate flex-1 text-left",children:D.name}),jsxRuntime.jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:U&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5",style:{color:f.accent}})})]},D.id)})})})]}),jsxRuntime.jsxs("div",{ref:He,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{if(!n)if(v)A(false);else {if(He.current){let D=He.current.getBoundingClientRect(),U=window.innerHeight,ae=120,z=U-D.bottom<ae?D.top-ae-8:D.bottom+8;M({top:z,left:D.left});}A(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:n,children:[jsxRuntime.jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:ue.color}}),jsxRuntime.jsx("span",{children:et.name}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:f.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:v&&jsxRuntime.jsxs(ea,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>A(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:`${L.top}px`,left:`${L.left}px`,zIndex:99999,backgroundColor:Ee?"#0a0a0a":f.bgPrimary,backdropFilter:Ee?"blur(16px)":void 0,border:`1px solid ${Ee?"#262626":f.border}`,boxShadow:Ee?"0 8px 24px rgba(0, 0, 0, 0.5)":"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick:D=>D.stopPropagation(),children:jsxRuntime.jsx("div",{style:{padding:"6px 8px"},children:jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 28px)",gap:"2px"},children:an.slice(0,18).map(D=>{let U=ue.color===D.value;return jsxRuntime.jsx("button",{type:"button",onClick:ae=>{ae.preventDefault(),ae.stopPropagation(),nt("color",D.value),A(false);},style:{width:"28px",height:"28px",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",border:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0},title:D.name,children:jsxRuntime.jsx("span",{style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:D.value,outline:U?`2px solid ${D.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},D.value)})})})})]})})]}),p.length>0||d?jsxRuntime.jsx(Ao,{selectedTags:ue.tags||[],availableTags:p,onChange:D=>nt("tags",D),onCreateTag:d,theme:f,disabled:n}):null]}),jsxRuntime.jsxs("section",{className:"grid grid-cols-1 md:grid-cols-2 gap-8 items-end",children:[jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("label",{style:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",textTransform:"uppercase",color:f.textTertiary,display:"block"},children:"Rango de Fechas"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",style:{backgroundColor:Ee?"#191b22":f.bgSecondary,borderRadius:8,border:`1px solid ${Ee?"rgba(65,71,84,0.05)":f.borderLight}`,padding:"10px 16px"},children:[jsxRuntime.jsx(lucideReact.Calendar,{className:"w-5 h-5",style:{color:"#007BFF"}}),jsxRuntime.jsxs("div",{ref:at,className:"flex items-center gap-2 flex-1 relative",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!n&&!ue.isMilestone)if(J==="start")H(null);else {if(at.current){let D=at.current.getBoundingClientRect();te({top:D.bottom+8,left:Math.max(16,D.left-40)});}H("start"),T(ue.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...V,opacity:ue.isMilestone?.5:1,cursor:ue.isMilestone?"not-allowed":"pointer"},disabled:n||ue.isMilestone,children:ue.startDate?ue.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsxRuntime.jsx("span",{style:{color:f.textTertiary},children:"\u2192"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!n&&!ue.isMilestone)if(J==="end")H(null);else {if(at.current){let D=at.current.getBoundingClientRect();te({top:D.bottom+8,left:Math.max(16,D.left-40)});}H("end"),T(ue.endDate||ue.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...V,opacity:ue.isMilestone?.5:1,cursor:ue.isMilestone?"not-allowed":"pointer"},disabled:n||ue.isMilestone,children:ue.endDate?ue.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:J&&jsxRuntime.jsxs(ea,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>H(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:`${G.top}px`,left:`${G.left}px`,zIndex:99999,backgroundColor:Ee?"#0a0a0a":f.bgPrimary,border:`1px solid ${Ee?"#262626":f.border}`,boxShadow:Ee?"0 8px 32px rgba(0, 0, 0, 0.6)":"0 8px 24px rgba(0, 0, 0, 0.12)"},onClick:D=>D.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${Ee?"#262626":f.border}`},children:[(()=>{let D=new Date,U=new Date(D);U.setDate(D.getDate()+1);let ae=new Date(D);ae.setDate(D.getDate()+7);let Ne=new Date(D);return Ne.setDate(D.getDate()+14),[{label:"Hoy",date:D},{label:"Ma\xF1ana",date:U},{label:"Pr\xF3xima semana",date:ae},{label:"2 semanas",date:Ne}].map((oe,Ge)=>jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:f.textPrimary},onMouseEnter:fe=>fe.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:fe=>fe.currentTarget.style.backgroundColor="transparent",onClick:()=>{J==="start"?(nt("startDate",oe.date),(!ue.endDate||oe.date>ue.endDate)&&nt("endDate",oe.date),H("end")):(nt("endDate",oe.date),(!ue.startDate||oe.date<ue.startDate)&&nt("startDate",oe.date),H(null));},children:oe.label},Ge))})(),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${f.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:D=>D.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:D=>D.currentTarget.style.backgroundColor="transparent",onClick:()=>{nt("startDate",void 0),nt("endDate",void 0),H(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:()=>T(new Date(Y.getFullYear(),Y.getMonth()-1)),className:"p-1 rounded",onMouseEnter:D=>D.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:D=>D.currentTarget.style.backgroundColor="transparent",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"w-4 h-4",style:{color:f.textSecondary}})}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:f.textPrimary,fontFamily:"JetBrains Mono, monospace"},children:Y.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>T(new Date(Y.getFullYear(),Y.getMonth()+1)),className:"p-1 rounded",onMouseEnter:D=>D.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:D=>D.currentTarget.style.backgroundColor="transparent",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4",style:{color:f.textSecondary}})})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((D,U)=>jsxRuntime.jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:f.textTertiary},children:D},U))}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let D=Y.getFullYear(),U=Y.getMonth(),ae=new Date(D,U,1).getDay(),Ne=new Date(D,U+1,0).getDate(),z=new Date,oe=[];for(let fe=ae-1;fe>=0;fe--)oe.push({day:new Date(D,U,-fe).getDate(),date:new Date(D,U-1,new Date(D,U,-fe).getDate()),isCurrentMonth:false});for(let fe=1;fe<=Ne;fe++)oe.push({day:fe,date:new Date(D,U,fe),isCurrentMonth:true});let Ge=42-oe.length;for(let fe=1;fe<=Ge;fe++)oe.push({day:fe,date:new Date(D,U+1,fe),isCurrentMonth:false});return oe.map((fe,Ve)=>{let $e=fe.date.toDateString()===z.toDateString(),Ue=ue.startDate?.toDateString()===fe.date.toDateString(),dt=ue.endDate?.toDateString()===fe.date.toDateString(),ot=ue.startDate&&ue.endDate&&fe.date>=ue.startDate&&fe.date<=ue.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:fe.isCurrentMonth?Ue||dt?"#FFF":f.textPrimary:f.textTertiary,backgroundColor:Ue?f.accent:dt?"#7C3AED":ot?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:$e&&!Ue&&!dt?`inset 0 0 0 1px ${f.accent}`:"none"},onClick:()=>{J==="start"?(nt("startDate",fe.date),ue.endDate&&fe.date>ue.endDate&&nt("endDate",fe.date),H("end")):(nt("endDate",fe.date),ue.startDate&&fe.date<ue.startDate&&nt("startDate",fe.date),H(null));},children:fe.day},Ve)})})()})]})]})]})})]}),Xe.endDate&&jsxRuntime.jsx("span",{className:"text-xs text-red-400",children:Xe.endDate})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("label",{style:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",textTransform:"uppercase",color:f.textTertiary},children:"Progreso Inicial"}),jsxRuntime.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#007BFF"},children:[ue.progress,"%"]})]}),jsxRuntime.jsx("div",{className:"h-2 w-full rounded-full overflow-hidden cursor-pointer",style:{backgroundColor:Ee?"#33343c":"#E5E7EB"},onClick:D=>{if(n)return;let U=D.currentTarget.getBoundingClientRect(),ae=Math.round((D.clientX-U.left)/U.width*100/5)*5;nt("progress",Math.max(0,Math.min(100,ae)));},children:jsxRuntime.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${ue.progress}%`,backgroundColor:"#007BFF"}})})]})]}),jsxRuntime.jsxs("div",{style:{borderTop:`1px solid ${Ee?"rgba(65,71,84,0.05)":f.borderLight}`,paddingTop:16},children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>R(!Le),className:"flex items-center gap-2 w-full py-2 transition-colors",style:{color:f.textPrimary},children:[jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-4 h-4 transition-transform ${Le?"":"-rotate-90"}`,style:{color:f.textTertiary}}),jsxRuntime.jsx("span",{style:{fontSize:16,fontWeight:700,fontFamily:"'Inter', system-ui, sans-serif"},children:"Opciones Avanzadas"})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:Le&&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("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:f.textTertiary},children:[jsxRuntime.jsx("path",{d:"M12 6v6l4 2"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),jsxRuntime.jsx("span",{className:"text-xs",style:{color:f.textTertiary},children:"Horas Estimadas"})]}),jsxRuntime.jsx("input",{type:"text",placeholder:"Ej: 8 (=8h), 2h 30m, 45m, 1d (1 d\xEDa = 8h)",value:ue.effortMinutes?i2(ue.effortMinutes):"",onChange:D=>{let U=l2(D.target.value);nt("effortMinutes",U);},className:"w-full px-3 py-2 rounded-lg text-sm transition-colors",style:{backgroundColor:f.bgSecondary,color:f.textPrimary,border:`1px solid ${f.borderLight}`}})]}),r.length>0&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:f.textTertiary},children:jsxRuntime.jsx("path",{d:"M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"})}),jsxRuntime.jsx("span",{className:"text-xs",style:{color:f.textTertiary},children:"Fase Padre"})]}),jsxRuntime.jsxs("select",{value:ue.parentId||"",onChange:D=>nt("parentId",D.target.value||null),className:"w-full px-3 py-2 rounded-lg text-sm transition-colors appearance-none cursor-pointer",style:{backgroundColor:f.bgSecondary,color:f.textPrimary,border:`1px solid ${f.borderLight}`},disabled:n,children:[jsxRuntime.jsx("option",{value:"",children:"\u2014 Sin fase padre (ra\xEDz) \u2014"}),r.filter(D=>D.id!==a?.id).map(D=>jsxRuntime.jsx("option",{value:D.id,children:D.name},D.id))]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsx("span",{style:{fontSize:14},children:"\u{1F4CD}"}),jsxRuntime.jsx("span",{className:"text-xs",style:{color:f.textTertiary},children:"Ubicaci\xF3n"})]}),jsxRuntime.jsx("input",{type:"text",placeholder:"Ej: Zona Norte, Piso 3",value:ue.location||"",onChange:D=>nt("location",D.target.value),className:"w-full px-3 py-2 rounded-lg text-sm transition-colors",style:{backgroundColor:f.bgSecondary,color:f.textPrimary,border:`1px solid ${f.borderLight}`},disabled:n})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsx("span",{style:{fontSize:14},children:"\u{1F527}"}),jsxRuntime.jsx("span",{className:"text-xs",style:{color:f.textTertiary},children:"Activo / Equipo"})]}),jsxRuntime.jsx("input",{type:"text",placeholder:"Ej: CMC-256",value:ue.equipment||"",onChange:D=>nt("equipment",D.target.value),className:"w-full px-3 py-2 rounded-lg text-sm transition-colors",style:{backgroundColor:f.bgSecondary,color:f.textPrimary,border:`1px solid ${f.borderLight}`},disabled:n})]})]}),(g||m.length>0||l==="create")&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:f.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:f.textTertiary},children:["Adjuntos ",l==="create"?q.length>0&&`(${q.length})`:m.length>0&&`(${m.length})`]})]}),l==="create"?jsxRuntime.jsx(lo,{cardId:"pending",attachments:q.map((D,U)=>({id:`pending-${U}`,cardId:"pending",name:D.name,size:D.size,type:D.type,url:URL.createObjectURL(D),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:D=>ye(U=>[...U,...D]),onDelete:D=>{let U=parseInt(D.replace("pending-",""),10);ye(ae=>ae.filter((Ne,z)=>z!==U));},maxSizeMB:10,maxFiles:20}):jsxRuntime.jsx(lo,{cardId:a?.id||"new",attachments:m,onUpload:g&&a?.id?D=>g(a.id,D):void 0,onDelete:y,maxSizeMB:10,maxFiles:20}),l==="create"&&q.length>0&&jsxRuntime.jsxs("p",{className:"text-xs mt-1",style:{color:f.textTertiary},children:[q.length," archivo(s) se subir\xE1n al crear la tarea"]})]}),jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-lg transition-colors",onMouseEnter:D=>D.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:D=>D.currentTarget.style.backgroundColor="transparent",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:ue.isMilestone,onChange:D=>nt("isMilestone",D.target.checked),className:"w-4 h-4 rounded",style:{accentColor:f.accent},disabled:n}),jsxRuntime.jsx(lucideReact.Milestone,{className:"w-4 h-4 text-yellow-500"}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:f.textPrimary},children:"Marcar como hito"})]}),r.length>0&&jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("label",{className:"flex items-center gap-2 text-xs mb-2",style:{color:f.textTertiary},children:[jsxRuntime.jsx(lucideReact.Link2,{className:"w-3.5 h-3.5"}),"Dependencias"]}),ue.dependencies&&ue.dependencies.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:ue.dependencies.map(D=>{let U=r.find(ae=>ae.id===D);return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",style:{backgroundColor:`${f.accent}20`,color:f.accent},children:[U?.name||D.slice(0,8),jsxRuntime.jsx("button",{type:"button",onClick:()=>{let ae=(ue.dependencies||[]).filter(Ne=>Ne!==D);nt("dependencies",ae);},className:"ml-0.5 rounded-full p-0.5 transition-colors hover:bg-white/20",disabled:n,children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]},D)})}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{O(!_e),le("");},className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-colors",style:{backgroundColor:f.bgSecondary,color:f.textSecondary},disabled:n,children:[jsxRuntime.jsx(lucideReact.Plus,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{children:"Agregar dependencia"})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:_e&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{O(false),le("");}}),jsxRuntime.jsxs(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 rounded-lg overflow-hidden min-w-[280px] max-h-[280px]",style:{backgroundColor:Ee?"#0a0a0a":f.bgPrimary,backdropFilter:Ee?"blur(16px)":void 0,border:`1px solid ${Ee?"#262626":f.border}`,boxShadow:Ee?"0 8px 24px rgba(0, 0, 0, 0.5)":"0 8px 24px rgba(0, 0, 0, 0.12)"},children:[jsxRuntime.jsx("div",{className:"p-2",style:{borderBottom:`1px solid ${f.border}`},children:jsxRuntime.jsx("input",{type:"text",value:ee,onChange:D=>le(D.target.value),placeholder:"Buscar tarea...",className:"w-full px-3 py-2 rounded-md text-xs outline-none",style:{backgroundColor:f.bgSecondary,color:f.textPrimary},autoFocus:true})}),jsxRuntime.jsxs("div",{className:"max-h-[200px] overflow-y-auto",children:[r.filter(D=>D.id!==a?.id).filter(D=>ee===""||D.name.toLowerCase().includes(ee.toLowerCase())).map(D=>{let U=ue.dependencies?.includes(D.id);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{let ae=ue.dependencies||[],Ne;U?Ne=ae.filter(z=>z!==D.id):Ne=[...ae,D.id],nt("dependencies",Ne);},className:"w-full flex items-center gap-3 px-3 py-2 text-xs transition-colors text-left",style:{backgroundColor:U?`${f.accent}10`:"transparent"},onMouseEnter:ae=>{U||(ae.currentTarget.style.backgroundColor=f.hoverBg);},onMouseLeave:ae=>{ae.currentTarget.style.backgroundColor=U?`${f.accent}10`:"transparent";},children:[jsxRuntime.jsx("div",{className:"w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0",style:{backgroundColor:U?f.accent:"transparent",borderColor:U?f.accent:f.borderLight},children:U&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3 h-3 text-white"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("span",{className:"block truncate",style:{color:f.textPrimary},children:D.name}),jsxRuntime.jsx("span",{className:"text-[10px]",style:{color:f.textTertiary},children:D.id.slice(0,8)})]})]},D.id)}),r.filter(D=>D.id!==a?.id).length===0&&jsxRuntime.jsx("div",{className:"px-3 py-4 text-xs text-center",style:{color:f.textTertiary},children:"No hay tareas disponibles"})]})]})]})})]})]})})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-6 px-8 py-5 flex-shrink-0",style:{borderTop:`1px solid ${Ee?"rgba(65,71,84,0.1)":f.border}`,backgroundColor:Ee?"rgba(25,27,34,0.2)":void 0},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-sm font-semibold transition-colors",style:{color:f.textTertiary},onMouseEnter:D=>D.currentTarget.style.color=f.textPrimary,onMouseLeave:D=>D.currentTarget.style.color=f.textTertiary,disabled:n,children:"Cancelar"}),jsxRuntime.jsx("button",{type:"submit",disabled:n,className:"px-8 py-3 font-bold rounded-lg transition-all flex items-center gap-2",style:{backgroundColor:"#007BFF",color:"#FFF",fontSize:14,fontFamily:"'Inter', system-ui, sans-serif",boxShadow:"0 4px 20px rgba(0, 123, 255, 0.2)"},onMouseEnter:D=>!n&&(D.currentTarget.style.filter="brightness(1.1)"),onMouseLeave:D=>!n&&(D.currentTarget.style.filter="brightness(1)"),children:n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:l==="create"?"Crear Tarea":"Guardar"})})]})]})})})]})})}var Im=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
|
|
368
|
+
Task dependencies must flow in one direction only.`);return}let j=X=>X.map(he=>{if(he.id===B){let Me=he.dependencies||[];if(!Me.includes(P.id))return {...he,dependencies:[...Me,P.id]}}return he.subtasks?{...he,subtasks:j(he.subtasks)}:he});Ar.current+=1,N(X=>j(X)),Ce?.(P.id,B);},[Ce,Qc]),eu=react.useCallback((P,B)=>{let j=X=>X.map(he=>{if(he.id===P&&he.dependencies){let Me=he.dependencies.filter(Ct=>Ct!==B);return {...he,dependencies:Me}}return he.subtasks?{...he,subtasks:j(he.subtasks)}:he});Ar.current+=1,N(X=>j(X)),we?.(P,B);},[we]),{startDate:yn,endDate:gl}=react.useMemo(()=>{let P=Z.filter(Me=>Me.startDate&&Me.endDate);if(P.length===0){let Me=new Date,Ct=new Date(Me);Ct.setDate(Ct.getDate()-30);let st=new Date(Me);return st.setDate(st.getDate()+60),{startDate:Ct,endDate:st}}let B=P.flatMap(Me=>[Me.startDate,Me.endDate]).filter(Me=>Me!==void 0),j=new Date(Math.min(...B.map(Me=>Me.getTime()))),X=new Date(Math.max(...B.map(Me=>Me.getTime()))),he=et==="day"?7:et==="week"?14:30;return j.setDate(j.getDate()-he),X.setDate(X.getDate()+he),{startDate:j,endDate:X}},[Z,et]);react.useEffect(()=>{Ft.current?.(yn,gl);},[yn,gl]);let Cf=react.useCallback(async()=>{if(!Ba.current||!Ut.current||!_t.current)return;await new Promise(Xo=>setTimeout(Xo,200));let P=Ba.current,B=Ut.current,j=sa.current||B.querySelector(".gantt-grid-scroll"),X=_t.current,he=j?.scrollTop||0,Me=j?.scrollLeft||0,Ct=X.scrollTop,st=X.scrollLeft,ka=P.style.overflow,Zt=P.style.height,fa=j?.style.overflow||"",lr=X.style.overflow,Sr=B.style.overflow,Eo=P.style.width,vn=X.style.width;try{let Xo=j?.querySelector(".gantt-taskgrid-content"),ro=X.querySelector("svg"),hl=ro?.getAttribute("height")?parseInt(ro.getAttribute("height"),10):ro?.getBoundingClientRect().height||0,wn=Xo?.scrollHeight||j?.scrollHeight||600,js=Math.max(hl,X.scrollHeight),ts=ro?.getAttribute("width")?parseInt(ro.getAttribute("width"),10):ro?.getBoundingClientRect().width||X.scrollWidth,Pf=P.querySelector('[style*="z-index: 100"]')?.offsetHeight||48,yl=Math.max(wn,js,hl),ru=Pf+yl+50,ou=(j?.offsetWidth||B.offsetWidth||300)+ts+10;j&&(j.scrollTop=0,j.scrollLeft=0),X.scrollTop=0,X.scrollLeft=0,P.style.overflow="visible",P.style.height=`${ru}px`,P.style.width=`${ou}px`,B.style.overflow="visible",j&&(j.style.overflow="visible",j.style.height=`${yl+50}px`),X.style.overflow="visible",X.style.height=`${yl+50}px`,X.style.width=`${ts+10}px`,await new Promise(_s=>setTimeout(_s,150));let Af=await htmlToImage.toPng(P,{backgroundColor:Dt.bgPrimary,pixelRatio:2,width:ou,height:ru,skipFonts:!1,filter:_s=>{if(!(_s instanceof Element))return !0;let nu=window.getComputedStyle(_s),su=parseInt(nu.zIndex,10);return !(!isNaN(su)&&su>=50||nu.position==="fixed")}}),xl=document.createElement("a");xl.download=`gantt-chart-${new Date().toISOString().slice(0,10)}.png`,xl.href=Af,xl.click();}finally{P.style.overflow=ka,P.style.height=Zt,P.style.width=Eo,B.style.overflow=Sr,j&&(j.style.overflow=fa,j.style.height="",j.scrollTop=he,j.scrollLeft=Me),X.style.overflow=lr,X.style.height="",X.style.width=vn,X.scrollTop=Ct,X.scrollLeft=st;}p?.("png");},[Dt,p]),Tf=react.useCallback(async()=>{await Se.exportToPDF(Z),p?.("pdf");},[Z,p]),fl=react.useRef({rateMap:a.rateMap,defaultRate:a.defaultRate,projectName:d});fl.current={rateMap:a.rateMap,defaultRate:a.defaultRate,projectName:d};let Nf=react.useCallback(async()=>{if(a.onExportExcel){await a.onExportExcel(),p?.("excel");return}let P=new Date,B=he=>String(he).padStart(2,"0"),j=`${P.getFullYear()}-${B(P.getMonth()+1)}-${B(P.getDate())}_${B(P.getHours())}${B(P.getMinutes())}`,X=d?d.replace(/[^a-zA-Z0-9áéíóúñÁÉÍÓÚÑ _-]/g,""):"Project";await Se.exportToExcel(Z,`${X}_${j}.xlsx`,fl.current),p?.("excel");},[Z,d,p,a.onExportExcel]),Df=react.useCallback(()=>{let P=Se.exportToCSV(Z),B=new Blob([P],{type:"text/csv;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(B),j.download="gantt-chart.csv",j.click(),URL.revokeObjectURL(j.href),p?.("csv");},[Z,p]),Sf=react.useCallback(()=>{let P=Se.exportToJSON(Z),B=new Blob([P],{type:"application/json;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(B),j.download="gantt-chart.json",j.click(),URL.revokeObjectURL(j.href),p?.("json");},[Z,p]),Ef=react.useCallback(()=>{Se.exportToMSProject(Z,"Gantt Project","project.xml"),p?.("msproject");},[Z,p]),Mf=P=>{P.preventDefault(),St(true);},xn=react.useRef(false),[bl,tu]=react.useState(false),es=react.useRef({x:0,y:0,scrollLeft:0,scrollTop:0});react.useEffect(()=>{let P=_t.current,B=Ut.current?.querySelector(".gantt-grid-scroll");if(!P||!B)return;let j=()=>{if(xn.current)return;xn.current=true;let st=P.scrollTop;Qe(st),B.scrollTop=st,requestAnimationFrame(()=>{xn.current=false;});},X=()=>{if(xn.current)return;xn.current=true;let st=B.scrollTop;Qe(st),P.scrollTop=st,requestAnimationFrame(()=>{xn.current=false;});},he=st=>{if(ut&&B){let Zt=B.parentElement?.getBoundingClientRect()?.left||0,fa=st.clientX-Zt,lr=200,Sr=Ke+yt,Eo=window.innerWidth*na,vn=Math.max(Sr,Eo);fa>=lr&&fa<=vn&&At(fa);}if(bl&&P){let ka=st.clientX-es.current.x,Zt=st.clientY-es.current.y;P.scrollLeft=es.current.scrollLeft-ka,P.scrollTop=es.current.scrollTop-Zt;}},Me=()=>{St(false),tu(false);},Ct=st=>{if(st.button!==0)return;let ka=st.target;ka.closest("[data-task-bar]")||ka.closest("[data-dependency-line]")||ka.closest("button")||ka.closest('[role="button"]')||ka.tagName==="rect"&&ka.getAttribute("data-clickable")==="true"||(tu(true),es.current={x:st.clientX,y:st.clientY,scrollLeft:P.scrollLeft,scrollTop:P.scrollTop},st.preventDefault());};return P.addEventListener("scroll",j),B.addEventListener("scroll",X),P.addEventListener("mousedown",Ct),document.addEventListener("mousemove",he),document.addEventListener("mouseup",Me),()=>{P.removeEventListener("scroll",j),B.removeEventListener("scroll",X),P.removeEventListener("mousedown",Ct),document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",Me);}},[ut,bl,Ke]);let au=react.useRef(false),Ff=react.useRef(null);return react.useLayoutEffect(()=>{if(au.current||Z.length===0||!_t.current)return;au.current=true,Ff.current=yn;let P=_t.current,B=new Date,j=et==="day"?60:et==="week"?20:8,X=(B.getTime()-yn.getTime())/(1e3*60*60*24),he=P.clientWidth,Ct=X*j*U-he/2;X>=0&&he>0&&(P.scrollLeft=Math.max(0,Ct));},[Z.length,yn,et,U]),jsxRuntime.jsx(In.Provider,{value:ke,children:jsxRuntime.jsx(Tl.Provider,{value:mr,children:jsxRuntime.jsxs("div",{ref:Ba,className:"flex flex-col h-full w-full",style:{backgroundColor:Dt.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...Dt.dotGrid&&{backgroundImage:`radial-gradient(circle, ${Dt.dotGrid} 1px, transparent 1px)`,backgroundSize:"24px 24px"},...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsxRuntime.jsx("div",{style:{position:"relative",zIndex:100},children:jsxRuntime.jsx(Ti,{theme:Dt,timeScale:et,onTimeScaleChange:Ee,zoom:U,onZoomChange:ae,currentTheme:ze,onThemeChange:ve,rowDensity:V,onRowDensityChange:D,showThemeSelector:c,showCreateTaskButton:S&&xe?.canCreateTask!==false&&!xe?.canCreateSubtaskOnly,createTaskLabel:E,onCreateTask:k,taskFilter:lt,onTaskFilterChange:ne,hideCompleted:pe,onHideCompletedChange:$,toolbarRightContent:L,wbsLevel:Ne,onWbsLevelChange:F,maxWbsDepth:Jt,viewMode:fe,onViewModeChange:Ve,projectForecast:Y,onExportPNG:i?Cf:void 0,onExportPDF:i?Tf:void 0,onExportExcel:i?Nf:void 0,onExportCSV:i?Df:void 0,onExportJSON:i?Sf:void 0,onExportMSProject:i?Ef:void 0,showCriticalPath:Ue,onShowCriticalPathChange:$t,showDependencies:ot,onShowDependenciesChange:Et,highlightWeekends:mt,onHighlightWeekendsChange:Mt,showBaseline:$e,onShowBaselineChange:P=>{P&&fe!=="oracle"&&Ve("oracle"),!P&&fe==="oracle"&&Ve("execution");},onCopySnapshotLink:kt,hasDependencies:Do})}),jsxRuntime.jsxs("div",{ref:Ut,className:"flex-1 flex min-h-0",style:{position:"relative",zIndex:1,overflow:"clip",overflowClipMargin:"100px"},children:[jsxRuntime.jsx("div",{ref:sa,className:"gantt-grid-scroll flex-shrink-0",style:{width:jt,overflowX:"auto",overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:jsxRuntime.jsx(Si,{tasks:Xc,theme:Dt,rowHeight:Gs,availableUsers:m,templates:No,showCriticalPath:Ue,onTaskClick:G,onTaskDblClick:Jc,onTaskContextMenu:Le,onTaskToggle:uf,scrollTop:De,columns:tt,onToggleColumn:df,onColumnResize:cf,onTaskUpdate:So,onTaskIndent:pf,onTaskOutdent:mf,onTaskMove:ff,onMultiTaskDelete:pl,onTaskDuplicate:bf,onTaskCreate:hf,onTaskRename:yf,onCreateSubtask:ml,onOpenTaskModal:G?P=>G(P):void 0,onDeleteRequest:(P,B)=>I({taskId:P,taskName:B}),onTaskReparent:gf,scrollContainerRef:sa})}),jsxRuntime.jsx("div",{className:"flex-shrink-0 cursor-col-resize hover:bg-blue-500/50 transition-colors h-full",style:{width:1,backgroundColor:Dt.border,zIndex:15},onMouseDown:Mf}),jsxRuntime.jsx("div",{ref:_t,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",cursor:bl?"grabbing":"grab",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsxRuntime.jsx(Bi,{tasks:Xc,theme:Dt,rowHeight:Gs,timeScale:et,startDate:yn,endDate:gl,zoom:U,locale:w,templates:No,dependencyLineStyle:a?.dependencyLineStyle,showTaskBarLabels:a?.showTaskBarLabels!==false,onTaskClick:G,onTaskDblClick:Jc,onTaskContextMenu:wf,onTaskDateChange:vf,onTaskProgressDrag:xf,onDependencyCreate:Zc,onDependencyDelete:eu,showBaseline:$e,showCriticalPath:Ue,showDependencies:ot,highlightWeekends:mt,canEditTask:xe?.canEditTask})})]}),Qt.task&&jsxRuntime.jsx(Rn,{isOpen:Qt.isOpen,x:Qt.x,y:Qt.y,theme:Dt,onClose:()=>oa({isOpen:false,x:0,y:0,task:null}),items:(()=>{let P=Qt.task;if(!P)return [];let B=Se.findTaskById(Z,P.id)||P,j=B.subtasks&&B.subtasks.length>0,X=xe?.canCreateTask!==false,he=xe?.canDeleteTask!==false;if(j){let Zt=[],fa=xe?.canDuplicateTask!==false;return X&&Zt.push({id:"addSubtask",label:ke.contextMenu?.addSubtask||"Add Subtask",icon:ma.Add,onClick:()=>{O?O(B):ml(B.id);}}),fa&&Zt.push({id:"duplicate",label:ke.contextMenu?.duplicateTask||"Duplicate Task",icon:ma.Duplicate,onClick:()=>{a.onTaskDuplicate?a.onTaskDuplicate(B):N(lr=>ws(lr,[B.id]).tasks),oa({isOpen:false,x:0,y:0,task:null});}}),he&&(Zt.length>0&&Zt.push({id:"separator-delete",label:"",separator:true,onClick:()=>{}}),Zt.push({id:"delete",label:ke.contextMenu?.deleteTask||"Delete Task",icon:ma.Delete,onClick:()=>{I({taskId:B.id,taskName:B.name});}})),Zt}let Me=xe?.canUpdateTask!==false,Ct=xe?.canDuplicateTask!==false,st=[];return Me&&st.push({id:"edit",label:ke.contextMenu?.editTask||"Edit Task",icon:ma.Pencil,onClick:()=>{_e?_e(B):Oe(B);}}),X&&st.push({id:"addSubtask",label:ke.contextMenu?.addSubtask||"Add Subtask",icon:ma.Add,onClick:()=>{O?O(B):ml(B.id);}}),st.length>0&&Me&&st.push({id:"separator-status",label:"",separator:true,onClick:()=>{}}),Me&&(st.push({id:"markIncomplete",label:ke.contextMenu?.markIncomplete||"Mark Incomplete",icon:ma.MarkIncomplete,onClick:()=>{ee?ee(B):So(B.id,{status:"todo",progress:0});},disabled:B.status==="todo"}),st.push({id:"setInProgress",label:ke.contextMenu?.setInProgress||"Set In Progress",icon:ma.SetInProgress,onClick:()=>{le?le(B):So(B.id,{status:"in-progress"});},disabled:B.status==="in-progress"}),st.push({id:"markComplete",label:ke.contextMenu?.markComplete||"Mark Complete",icon:ma.MarkComplete,onClick:()=>{So(B.id,{status:"completed",progress:100});},disabled:B.status==="completed"})),(Ct||Me&&B.startDate&&B.endDate)&&st.length>0&&st.push({id:"separator-advanced",label:"",separator:true,onClick:()=>{}}),Ct&&st.push({id:"duplicate",label:ke.contextMenu?.duplicateTask||"Duplicate Task",icon:ma.Duplicate,onClick:()=>{a.onTaskDuplicate?a.onTaskDuplicate(B):N(Zt=>ws(Zt,[B.id]).tasks),oa({isOpen:false,x:0,y:0,task:null});}}),Me&&B.startDate&&B.endDate&&st.push({id:"split",label:ke.contextMenu?.splitTask||"Split Task",icon:ma.Split,onClick:()=>{let Zt=B.startDate.getTime(),fa=B.endDate.getTime(),lr=Zt+(fa-Zt)/2,Sr=new Date(lr);kf(B,Sr);}}),he&&(st.length>0&&st.push({id:"separator-delete",label:"",separator:true,onClick:()=>{}}),st.push({id:"delete",label:ke.contextMenu?.deleteTask||"Delete Task",icon:ma.Delete,onClick:()=>{I({taskId:B.id,taskName:B.name});}})),st})()}),jsxRuntime.jsx(yo,{task:Q,isOpen:!!Q,onClose:()=>Oe(null),onTaskUpdate:P=>{Q&&(So(Q.id,P),Oe(null));},theme:ze==="light"?"light":"dark",locale:w==="es"?"es":"en",availableUsers:m,availableTasks:t}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:Pe&&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:()=>I(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:P=>P.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:Dt.bgSecondary,border:`1px solid ${Dt.border}`},children:[jsxRuntime.jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${Dt.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:Dt.textPrimary,fontFamily:"Inter, sans-serif"},children:[ke.contextMenu?.deleteTask||"Delete Task","?"]}),jsxRuntime.jsx("p",{className:"text-sm mt-1",style:{color:Dt.textSecondary,fontFamily:"Inter, sans-serif"},children:w==="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:Dt.textSecondary,fontFamily:"Inter, sans-serif"},children:[w==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxRuntime.jsxs("span",{className:"font-semibold",style:{color:Dt.textPrimary},children:['"',Pe.taskName,'"']}),"."]})}),jsxRuntime.jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:Dt.bgPrimary,borderTop:`1px solid ${Dt.border}`},children:[jsxRuntime.jsx("button",{onClick:()=>I(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:Dt.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:P=>{P.currentTarget.style.backgroundColor=Dt.hoverBg;},onMouseLeave:P=>{P.currentTarget.style.backgroundColor="transparent";},children:w==="es"?"Cancelar":"Cancel"}),jsxRuntime.jsxs("button",{onClick:()=>{pl([Pe.taskId]),I(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:P=>{P.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:P=>{P.currentTarget.style.backgroundColor="#EF4444";},children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"}),w==="es"?"Eliminar":"Delete"]})]})]})})}),b?.enabled&&jsxRuntime.jsx(Oi,{tasks:Z,theme:Dt,config:b,onTasksUpdate:N,onTaskUpdate:So,onTaskCreate:P=>{N(B=>[...B,P]);},onTaskDelete:P=>{pl([P]);},onDependencyCreate:(P,B)=>{let j=Se.findTaskById(Z,P);j&&Zc(j,B);},onDependencyDelete:eu})]})})})});function i2(e){if(e<60)return `${e}m`;let t=Math.floor(e/60),a=e%60;return a===0?`${t}h`:`${t}h ${a}m`}function l2(e){if(!e||e.trim()==="")return null;let t=e.trim().toLowerCase(),a=t.match(/(\d+)h\s*(\d+)m/);if(a&&a[1]&&a[2]){let l=parseInt(a[1],10),c=parseInt(a[2],10);return l*60+c}let r=t.match(/(\d+)h/);if(r&&r[1])return parseInt(r[1],10)*60;let o=t.match(/(\d+)m/);if(o&&o[1])return parseInt(o[1],10);let s=t.match(/(\d+)d/);if(s&&s[1])return parseInt(s[1],10)*480;let n=t.match(/^(\d+)$/);return n&&n[1]?parseInt(n[1],10)*60:null}var $d=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],Od=[{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 Lm({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:n=false,mode:l=a?"edit":"create",theme:c="dark",customStatuses:i=[],availableTags:p=[],onCreateTag:d,attachments:m=[],onUploadAttachments:g,onDeleteAttachment:y,defaultStatus:x}){let h=[...$d,...i.filter(D=>!$d.some(U=>U.id===D.id))],f=ft[c]||ft.dark,[b,w]=react.useState(false),[C,S]=react.useState(false),[E,k]=react.useState(false),[v,A]=react.useState(false),[L,M]=react.useState({top:0,left:0}),[J,H]=react.useState(null),[Y,T]=react.useState(new Date),[G,te]=react.useState({top:0,left:0}),[Le,R]=react.useState(false),[q,ye]=react.useState([]),[_e,O]=react.useState(false),[ee,le]=react.useState(""),Ce=react.useRef(null),we=react.useRef(null),Be=react.useRef(null),He=react.useRef(null),at=react.useRef(null),[ue,je]=react.useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#2E94FF",assignees:[],dependencies:[],tags:[],parentId:null,location:"",equipment:""}),[Xe,xe]=react.useState({});react.useEffect(()=>{a?(je({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||"#2E94FF",assignees:a.assignees||[],dependencies:a.dependencies||[],tags:a.tags||[],parentId:a.parentId||null,location:a.location||"",equipment:a.equipment||""}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&R(true)):(je({name:"",description:"",progress:0,status:x||"todo",priority:"medium",isMilestone:false,color:"#2E94FF",assignees:[],dependencies:[],pendingFiles:[],tags:[],parentId:null,location:"",equipment:""}),R(false),ye([]));},[a,e,x]),react.useEffect(()=>{let D=U=>{Ce.current&&!Ce.current.contains(U.target)&&w(false),we.current&&!we.current.contains(U.target)&&S(false),Be.current&&!Be.current.contains(U.target)&&k(false),He.current&&!He.current.contains(U.target)&&A(false);};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);let kt=()=>{let D={};return ue.name.trim()||(D.name="El nombre es requerido"),ue.startDate&&ue.endDate&&ue.startDate>ue.endDate&&(D.endDate="La fecha de fin debe ser posterior a la de inicio"),xe(D),Object.keys(D).length===0},xt=async D=>{if(D.preventDefault(),!!kt())try{let U=l==="create"&&q.length>0?{...ue,pendingFiles:q}:ue;await s(U),ye([]),t();}catch(U){console.error("Error submitting task:",U);}},nt=(D,U)=>{je(ae=>{let Ne={...ae,[D]:U};if(D==="status"){let z=U;z==="todo"?Ne.progress=0:z==="in-progress"?(ae.progress===0||ae.progress===100)&&(Ne.progress=50):z==="completed"||z==="closed"?Ne.progress=100:(z==="in-review"||z==="review")&&(Ne.progress=75);}if(D==="progress"){let z=typeof U=="number"?U:parseInt(U,10);z===100&&ae.status!=="completed"?Ne.status="completed":z>0&&z<100&&ae.status==="todo"?Ne.status="in-progress":z===0&&ae.status!=="todo"&&(Ne.status="todo");}return Ne}),Xe[D]&&xe(ae=>{let Ne={...ae};return delete Ne[D],Ne});},ze=h.find(D=>D.id===ue.status)??$d[0],ct=Od.find(D=>D.id===ue.priority)??Od[1],et=an.find(D=>D.value===ue.color)??an[0],Ee=c==="dark",V={backgroundColor:Ee?"#1d1f27":f.bgSecondary,border:`1px solid ${Ee?"rgba(65,71,84,0.1)":f.borderLight}`,color:f.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 z-[9999]",style:{backgroundColor:Ee?"rgba(0, 0, 0, 0.85)":"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)"},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-[9999] flex items-center justify-center p-4 pointer-events-none",children:jsxRuntime.jsx("div",{className:"w-full max-w-[640px] rounded-xl pointer-events-auto flex flex-col","data-theme":c,style:{backgroundColor:Ee?"#0a0a0a":f.bgPrimary,border:`1px solid ${Ee?"rgba(65,71,84,0.1)":f.border}`,boxShadow:Ee?"0 8px 48px rgba(0, 0, 0, 0.8)":"0 8px 32px rgba(0, 0, 0, 0.12)",maxHeight:"90vh"},onClick:D=>D.stopPropagation(),children:jsxRuntime.jsxs("form",{onSubmit:xt,className:"flex flex-col overflow-hidden flex-1",style:{fontFamily:"'Inter', system-ui, sans-serif"},children:[jsxRuntime.jsxs("header",{className:"px-8 pt-8 pb-4 space-y-4 flex-shrink-0",children:[jsxRuntime.jsx("input",{type:"text",value:ue.name,onChange:D=>nt("name",D.target.value),className:"w-full bg-transparent border-none p-0 focus:outline-none focus:ring-0",style:{color:f.textPrimary,fontSize:30,fontWeight:700,fontFamily:"'Inter', system-ui, sans-serif"},placeholder:"Nombre de la tarea",disabled:n,autoFocus:true}),Xe.name&&jsxRuntime.jsxs("p",{className:"text-xs text-red-400 flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"w-3 h-3"}),Xe.name]}),jsxRuntime.jsx("textarea",{value:ue.description||"",onChange:D=>nt("description",D.target.value),className:"w-full bg-transparent border-none p-0 focus:outline-none focus:ring-0 resize-none task-form-description",style:{color:f.textPrimary,fontSize:16,fontFamily:"'Inter', system-ui, sans-serif","--placeholder-color":f.textTertiary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:n})]}),jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto px-8 py-4 space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxRuntime.jsxs("div",{ref:Ce,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!n&&w(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...V,borderColor:ze.color,backgroundColor:`${ze.color}15`},disabled:n,children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:ze.color}}),jsxRuntime.jsx("span",{style:{color:ze.color},children:ze.title}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:ze.color}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:b&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[140px] rounded-lg overflow-hidden",style:{backgroundColor:Ee?"#0a0a0a":f.bgPrimary,backdropFilter:Ee?"blur(16px)":void 0,border:`1px solid ${Ee?"#262626":f.border}`,boxShadow:Ee?"0 8px 24px rgba(0, 0, 0, 0.5)":"0 8px 24px rgba(0, 0, 0, 0.12)"},children:h.map(D=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:f.textPrimary},onMouseEnter:U=>U.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:U=>U.currentTarget.style.backgroundColor="transparent",onClick:()=>{nt("status",D.id),w(false);},children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:D.color}}),D.title,ue.status===D.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:f.accent}})]},D.id))})})]}),jsxRuntime.jsxs("div",{ref:we,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!n&&S(!C),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:n,children:[jsxRuntime.jsx(lucideReact.Flag,{className:"w-3.5 h-3.5",style:{color:ct.color}}),jsxRuntime.jsx("span",{children:ct.label}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:f.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:C&&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 overflow-hidden",style:{backgroundColor:Ee?"#0a0a0a":f.bgPrimary,backdropFilter:Ee?"blur(16px)":void 0,border:`1px solid ${Ee?"#262626":f.border}`,boxShadow:Ee?"0 8px 24px rgba(0, 0, 0, 0.5)":"0 8px 24px rgba(0, 0, 0, 0.12)"},children:Od.map(D=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:f.textPrimary},onMouseEnter:U=>U.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:U=>U.currentTarget.style.backgroundColor="transparent",onClick:()=>{nt("priority",D.id),S(false);},children:[jsxRuntime.jsx("span",{children:D.icon}),D.label,ue.priority===D.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:f.accent}})]},D.id))})})]}),o.length>0&&jsxRuntime.jsxs("div",{ref:Be,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!n&&k(!E),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:n,children:[ue.assignees&&ue.assignees.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex -space-x-1",children:ue.assignees.slice(0,3).map((D,U)=>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:D.color||f.accent,borderColor:f.bgSecondary},children:D.initials},U))}),ue.assignees.length>3&&jsxRuntime.jsxs("span",{style:{color:f.textTertiary},children:["+",ue.assignees.length-3]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Users,{className:"w-3.5 h-3.5",style:{color:f.textTertiary}}),jsxRuntime.jsx("span",{style:{color:f.textTertiary},children:"Asignar"})]}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:f.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:E&&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",style:{backgroundColor:Ee?"#0a0a0a":f.bgPrimary,backdropFilter:Ee?"blur(16px)":void 0,border:`1px solid ${Ee?"#262626":f.border}`,boxShadow:Ee?"0 8px 24px rgba(0, 0, 0, 0.5)":"0 8px 24px rgba(0, 0, 0, 0.12)"},children:o.map(D=>{let U=ue.assignees?.some(ae=>ae.name===D.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:f.textPrimary},onMouseEnter:ae=>ae.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:ae=>ae.currentTarget.style.backgroundColor="transparent",onClick:()=>{let ae=U?(ue.assignees||[]).filter(Ne=>Ne.name!==D.name):[...ue.assignees||[],{name:D.name,avatar:D.avatar,initials:D.name.split(" ").map(Ne=>Ne[0]).join("").toUpperCase().slice(0,2),color:f.accent}];nt("assignees",ae);},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:f.accent},children:D.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"truncate flex-1 text-left",children:D.name}),jsxRuntime.jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:U&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5",style:{color:f.accent}})})]},D.id)})})})]}),jsxRuntime.jsxs("div",{ref:He,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{if(!n)if(v)A(false);else {if(He.current){let D=He.current.getBoundingClientRect(),U=window.innerHeight,ae=120,z=U-D.bottom<ae?D.top-ae-8:D.bottom+8;M({top:z,left:D.left});}A(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:n,children:[jsxRuntime.jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:ue.color}}),jsxRuntime.jsx("span",{children:et.name}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:f.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:v&&jsxRuntime.jsxs(ea,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>A(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:`${L.top}px`,left:`${L.left}px`,zIndex:99999,backgroundColor:Ee?"#0a0a0a":f.bgPrimary,backdropFilter:Ee?"blur(16px)":void 0,border:`1px solid ${Ee?"#262626":f.border}`,boxShadow:Ee?"0 8px 24px rgba(0, 0, 0, 0.5)":"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick:D=>D.stopPropagation(),children:jsxRuntime.jsx("div",{style:{padding:"6px 8px"},children:jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 28px)",gap:"2px"},children:an.slice(0,18).map(D=>{let U=ue.color===D.value;return jsxRuntime.jsx("button",{type:"button",onClick:ae=>{ae.preventDefault(),ae.stopPropagation(),nt("color",D.value),A(false);},style:{width:"28px",height:"28px",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",border:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0},title:D.name,children:jsxRuntime.jsx("span",{style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:D.value,outline:U?`2px solid ${D.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},D.value)})})})})]})})]}),p.length>0||d?jsxRuntime.jsx(Ao,{selectedTags:ue.tags||[],availableTags:p,onChange:D=>nt("tags",D),onCreateTag:d,theme:f,disabled:n}):null]}),jsxRuntime.jsxs("section",{className:"grid grid-cols-1 md:grid-cols-2 gap-8 items-end",children:[jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("label",{style:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",textTransform:"uppercase",color:f.textTertiary,display:"block"},children:"Rango de Fechas"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",style:{backgroundColor:Ee?"#191b22":f.bgSecondary,borderRadius:8,border:`1px solid ${Ee?"rgba(65,71,84,0.05)":f.borderLight}`,padding:"10px 16px"},children:[jsxRuntime.jsx(lucideReact.Calendar,{className:"w-5 h-5",style:{color:"#007BFF"}}),jsxRuntime.jsxs("div",{ref:at,className:"flex items-center gap-2 flex-1 relative",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!n&&!ue.isMilestone)if(J==="start")H(null);else {if(at.current){let D=at.current.getBoundingClientRect();te({top:D.bottom+8,left:Math.max(16,D.left-40)});}H("start"),T(ue.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...V,opacity:ue.isMilestone?.5:1,cursor:ue.isMilestone?"not-allowed":"pointer"},disabled:n||ue.isMilestone,children:ue.startDate?ue.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsxRuntime.jsx("span",{style:{color:f.textTertiary},children:"\u2192"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!n&&!ue.isMilestone)if(J==="end")H(null);else {if(at.current){let D=at.current.getBoundingClientRect();te({top:D.bottom+8,left:Math.max(16,D.left-40)});}H("end"),T(ue.endDate||ue.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...V,opacity:ue.isMilestone?.5:1,cursor:ue.isMilestone?"not-allowed":"pointer"},disabled:n||ue.isMilestone,children:ue.endDate?ue.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:J&&jsxRuntime.jsxs(ea,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>H(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:`${G.top}px`,left:`${G.left}px`,zIndex:99999,backgroundColor:Ee?"#0a0a0a":f.bgPrimary,border:`1px solid ${Ee?"#262626":f.border}`,boxShadow:Ee?"0 8px 32px rgba(0, 0, 0, 0.6)":"0 8px 24px rgba(0, 0, 0, 0.12)"},onClick:D=>D.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${Ee?"#262626":f.border}`},children:[(()=>{let D=new Date,U=new Date(D);U.setDate(D.getDate()+1);let ae=new Date(D);ae.setDate(D.getDate()+7);let Ne=new Date(D);return Ne.setDate(D.getDate()+14),[{label:"Hoy",date:D},{label:"Ma\xF1ana",date:U},{label:"Pr\xF3xima semana",date:ae},{label:"2 semanas",date:Ne}].map((oe,Ge)=>jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:f.textPrimary},onMouseEnter:fe=>fe.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:fe=>fe.currentTarget.style.backgroundColor="transparent",onClick:()=>{J==="start"?(nt("startDate",oe.date),(!ue.endDate||oe.date>ue.endDate)&&nt("endDate",oe.date),H("end")):(nt("endDate",oe.date),(!ue.startDate||oe.date<ue.startDate)&&nt("startDate",oe.date),H(null));},children:oe.label},Ge))})(),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${f.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:D=>D.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:D=>D.currentTarget.style.backgroundColor="transparent",onClick:()=>{nt("startDate",void 0),nt("endDate",void 0),H(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:()=>T(new Date(Y.getFullYear(),Y.getMonth()-1)),className:"p-1 rounded",onMouseEnter:D=>D.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:D=>D.currentTarget.style.backgroundColor="transparent",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"w-4 h-4",style:{color:f.textSecondary}})}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:f.textPrimary,fontFamily:"JetBrains Mono, monospace"},children:Y.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>T(new Date(Y.getFullYear(),Y.getMonth()+1)),className:"p-1 rounded",onMouseEnter:D=>D.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:D=>D.currentTarget.style.backgroundColor="transparent",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4",style:{color:f.textSecondary}})})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((D,U)=>jsxRuntime.jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:f.textTertiary},children:D},U))}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let D=Y.getFullYear(),U=Y.getMonth(),ae=new Date(D,U,1).getDay(),Ne=new Date(D,U+1,0).getDate(),z=new Date,oe=[];for(let fe=ae-1;fe>=0;fe--)oe.push({day:new Date(D,U,-fe).getDate(),date:new Date(D,U-1,new Date(D,U,-fe).getDate()),isCurrentMonth:false});for(let fe=1;fe<=Ne;fe++)oe.push({day:fe,date:new Date(D,U,fe),isCurrentMonth:true});let Ge=42-oe.length;for(let fe=1;fe<=Ge;fe++)oe.push({day:fe,date:new Date(D,U+1,fe),isCurrentMonth:false});return oe.map((fe,Ve)=>{let $e=fe.date.toDateString()===z.toDateString(),Ue=ue.startDate?.toDateString()===fe.date.toDateString(),dt=ue.endDate?.toDateString()===fe.date.toDateString(),ot=ue.startDate&&ue.endDate&&fe.date>=ue.startDate&&fe.date<=ue.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:fe.isCurrentMonth?Ue||dt?"#FFF":f.textPrimary:f.textTertiary,backgroundColor:Ue?f.accent:dt?"#7C3AED":ot?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:$e&&!Ue&&!dt?`inset 0 0 0 1px ${f.accent}`:"none"},onClick:()=>{J==="start"?(nt("startDate",fe.date),ue.endDate&&fe.date>ue.endDate&&nt("endDate",fe.date),H("end")):(nt("endDate",fe.date),ue.startDate&&fe.date<ue.startDate&&nt("startDate",fe.date),H(null));},children:fe.day},Ve)})})()})]})]})]})})]}),Xe.endDate&&jsxRuntime.jsx("span",{className:"text-xs text-red-400",children:Xe.endDate})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("label",{style:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",textTransform:"uppercase",color:f.textTertiary},children:"Progreso Inicial"}),jsxRuntime.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#007BFF"},children:[ue.progress,"%"]})]}),jsxRuntime.jsx("div",{className:"h-2 w-full rounded-full overflow-hidden cursor-pointer",style:{backgroundColor:Ee?"#33343c":"#E5E7EB"},onClick:D=>{if(n)return;let U=D.currentTarget.getBoundingClientRect(),ae=Math.round((D.clientX-U.left)/U.width*100/5)*5;nt("progress",Math.max(0,Math.min(100,ae)));},children:jsxRuntime.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${ue.progress}%`,backgroundColor:"#007BFF"}})})]})]}),jsxRuntime.jsxs("div",{style:{borderTop:`1px solid ${Ee?"rgba(65,71,84,0.05)":f.borderLight}`,paddingTop:16},children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>R(!Le),className:"flex items-center gap-2 w-full py-2 transition-colors",style:{color:f.textPrimary},children:[jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-4 h-4 transition-transform ${Le?"":"-rotate-90"}`,style:{color:f.textTertiary}}),jsxRuntime.jsx("span",{style:{fontSize:16,fontWeight:700,fontFamily:"'Inter', system-ui, sans-serif"},children:"Opciones Avanzadas"})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:Le&&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("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:f.textTertiary},children:[jsxRuntime.jsx("path",{d:"M12 6v6l4 2"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),jsxRuntime.jsx("span",{className:"text-xs",style:{color:f.textTertiary},children:"Horas Estimadas"})]}),jsxRuntime.jsx("input",{type:"text",placeholder:"Ej: 8 (=8h), 2h 30m, 45m, 1d (1 d\xEDa = 8h)",value:ue.effortMinutes?i2(ue.effortMinutes):"",onChange:D=>{let U=l2(D.target.value);nt("effortMinutes",U);},className:"w-full px-3 py-2 rounded-lg text-sm transition-colors",style:{backgroundColor:f.bgSecondary,color:f.textPrimary,border:`1px solid ${f.borderLight}`}})]}),r.length>0&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:f.textTertiary},children:jsxRuntime.jsx("path",{d:"M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"})}),jsxRuntime.jsx("span",{className:"text-xs",style:{color:f.textTertiary},children:"Fase Padre"})]}),jsxRuntime.jsxs("select",{value:ue.parentId||"",onChange:D=>nt("parentId",D.target.value||null),className:"w-full px-3 py-2 rounded-lg text-sm transition-colors appearance-none cursor-pointer",style:{backgroundColor:f.bgSecondary,color:f.textPrimary,border:`1px solid ${f.borderLight}`},disabled:n,children:[jsxRuntime.jsx("option",{value:"",children:"\u2014 Sin fase padre (ra\xEDz) \u2014"}),r.filter(D=>D.id!==a?.id).map(D=>jsxRuntime.jsx("option",{value:D.id,children:D.name},D.id))]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsx("span",{style:{fontSize:14},children:"\u{1F4CD}"}),jsxRuntime.jsx("span",{className:"text-xs",style:{color:f.textTertiary},children:"Ubicaci\xF3n"})]}),jsxRuntime.jsx("input",{type:"text",placeholder:"Ej: Zona Norte, Piso 3",value:ue.location||"",onChange:D=>nt("location",D.target.value),className:"w-full px-3 py-2 rounded-lg text-sm transition-colors",style:{backgroundColor:f.bgSecondary,color:f.textPrimary,border:`1px solid ${f.borderLight}`},disabled:n})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsx("span",{style:{fontSize:14},children:"\u{1F527}"}),jsxRuntime.jsx("span",{className:"text-xs",style:{color:f.textTertiary},children:"Activo / Equipo"})]}),jsxRuntime.jsx("input",{type:"text",placeholder:"Ej: CMC-256",value:ue.equipment||"",onChange:D=>nt("equipment",D.target.value),className:"w-full px-3 py-2 rounded-lg text-sm transition-colors",style:{backgroundColor:f.bgSecondary,color:f.textPrimary,border:`1px solid ${f.borderLight}`},disabled:n})]})]}),(g||m.length>0||l==="create")&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:f.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:f.textTertiary},children:["Adjuntos ",l==="create"?q.length>0&&`(${q.length})`:m.length>0&&`(${m.length})`]})]}),l==="create"?jsxRuntime.jsx(lo,{cardId:"pending",attachments:q.map((D,U)=>({id:`pending-${U}`,cardId:"pending",name:D.name,size:D.size,type:D.type,url:URL.createObjectURL(D),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:D=>ye(U=>[...U,...D]),onDelete:D=>{let U=parseInt(D.replace("pending-",""),10);ye(ae=>ae.filter((Ne,z)=>z!==U));},maxSizeMB:10,maxFiles:20}):jsxRuntime.jsx(lo,{cardId:a?.id||"new",attachments:m,onUpload:g&&a?.id?D=>g(a.id,D):void 0,onDelete:y,maxSizeMB:10,maxFiles:20}),l==="create"&&q.length>0&&jsxRuntime.jsxs("p",{className:"text-xs mt-1",style:{color:f.textTertiary},children:[q.length," archivo(s) se subir\xE1n al crear la tarea"]})]}),jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-lg transition-colors",onMouseEnter:D=>D.currentTarget.style.backgroundColor=f.hoverBg,onMouseLeave:D=>D.currentTarget.style.backgroundColor="transparent",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:ue.isMilestone,onChange:D=>nt("isMilestone",D.target.checked),className:"w-4 h-4 rounded",style:{accentColor:f.accent},disabled:n}),jsxRuntime.jsx(lucideReact.Milestone,{className:"w-4 h-4 text-yellow-500"}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:f.textPrimary},children:"Marcar como hito"})]}),r.length>0&&jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("label",{className:"flex items-center gap-2 text-xs mb-2",style:{color:f.textTertiary},children:[jsxRuntime.jsx(lucideReact.Link2,{className:"w-3.5 h-3.5"}),"Dependencias"]}),ue.dependencies&&ue.dependencies.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:ue.dependencies.map(D=>{let U=r.find(ae=>ae.id===D);return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",style:{backgroundColor:`${f.accent}20`,color:f.accent},children:[U?.name||D.slice(0,8),jsxRuntime.jsx("button",{type:"button",onClick:()=>{let ae=(ue.dependencies||[]).filter(Ne=>Ne!==D);nt("dependencies",ae);},className:"ml-0.5 rounded-full p-0.5 transition-colors hover:bg-white/20",disabled:n,children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]},D)})}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{O(!_e),le("");},className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-colors",style:{backgroundColor:f.bgSecondary,color:f.textSecondary},disabled:n,children:[jsxRuntime.jsx(lucideReact.Plus,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{children:"Agregar dependencia"})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:_e&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{O(false),le("");}}),jsxRuntime.jsxs(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 rounded-lg overflow-hidden min-w-[280px] max-h-[280px]",style:{backgroundColor:Ee?"#0a0a0a":f.bgPrimary,backdropFilter:Ee?"blur(16px)":void 0,border:`1px solid ${Ee?"#262626":f.border}`,boxShadow:Ee?"0 8px 24px rgba(0, 0, 0, 0.5)":"0 8px 24px rgba(0, 0, 0, 0.12)"},children:[jsxRuntime.jsx("div",{className:"p-2",style:{borderBottom:`1px solid ${f.border}`},children:jsxRuntime.jsx("input",{type:"text",value:ee,onChange:D=>le(D.target.value),placeholder:"Buscar tarea...",className:"w-full px-3 py-2 rounded-md text-xs outline-none",style:{backgroundColor:f.bgSecondary,color:f.textPrimary},autoFocus:true})}),jsxRuntime.jsxs("div",{className:"max-h-[200px] overflow-y-auto",children:[r.filter(D=>D.id!==a?.id).filter(D=>ee===""||D.name.toLowerCase().includes(ee.toLowerCase())).map(D=>{let U=ue.dependencies?.includes(D.id);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{let ae=ue.dependencies||[],Ne;U?Ne=ae.filter(z=>z!==D.id):Ne=[...ae,D.id],nt("dependencies",Ne);},className:"w-full flex items-center gap-3 px-3 py-2 text-xs transition-colors text-left",style:{backgroundColor:U?`${f.accent}10`:"transparent"},onMouseEnter:ae=>{U||(ae.currentTarget.style.backgroundColor=f.hoverBg);},onMouseLeave:ae=>{ae.currentTarget.style.backgroundColor=U?`${f.accent}10`:"transparent";},children:[jsxRuntime.jsx("div",{className:"w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0",style:{backgroundColor:U?f.accent:"transparent",borderColor:U?f.accent:f.borderLight},children:U&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3 h-3 text-white"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("span",{className:"block truncate",style:{color:f.textPrimary},children:D.name}),jsxRuntime.jsx("span",{className:"text-[10px]",style:{color:f.textTertiary},children:D.id.slice(0,8)})]})]},D.id)}),r.filter(D=>D.id!==a?.id).length===0&&jsxRuntime.jsx("div",{className:"px-3 py-4 text-xs text-center",style:{color:f.textTertiary},children:"No hay tareas disponibles"})]})]})]})})]})]})})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-6 px-8 py-5 flex-shrink-0",style:{borderTop:`1px solid ${Ee?"rgba(65,71,84,0.1)":f.border}`,backgroundColor:Ee?"rgba(25,27,34,0.2)":void 0},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-sm font-semibold transition-colors",style:{color:f.textTertiary},onMouseEnter:D=>D.currentTarget.style.color=f.textPrimary,onMouseLeave:D=>D.currentTarget.style.color=f.textTertiary,disabled:n,children:"Cancelar"}),jsxRuntime.jsx("button",{type:"submit",disabled:n,className:"px-8 py-3 font-bold rounded-lg transition-all flex items-center gap-2",style:{backgroundColor:"#007BFF",color:"#FFF",fontSize:14,fontFamily:"'Inter', system-ui, sans-serif",boxShadow:"0 4px 20px rgba(0, 123, 255, 0.2)"},onMouseEnter:D=>!n&&(D.currentTarget.style.filter="brightness(1.1)"),onMouseLeave:D=>!n&&(D.currentTarget.style.filter="brightness(1)"),children:n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:l==="create"?"Crear Tarea":"Guardar"})})]})]})})})]})})}var Im=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
|
|
369
369
|
|
|
370
370
|
AVAILABLE COMMANDS:
|
|
371
371
|
1. move_task - Move a task to a different date
|