@libxai/board 0.17.255 → 0.17.256

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,selectionStore,BoardStore}from'@libxai/core';export{Board as BoardModel,BoardStore,Card as CardModel,Column as ColumnModel,DependencyEngine,Store}from'@libxai/core';import {createContext,memo,useRef,useState,forwardRef,useContext,useEffect,useCallback,useMemo,useImperativeHandle,Component}from'react';import {useDroppable,useSensors,useSensor,PointerSensor,KeyboardSensor,DndContext,closestCorners,DragOverlay}from'@dnd-kit/core';import {useSortable,SortableContext,verticalListSortingStrategy,sortableKeyboardCoordinates}from'@dnd-kit/sortable';import {useVirtualizer}from'@tanstack/react-virtual';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsPDF}from'jspdf';import fc from'html2canvas';import {createPortal}from'react-dom';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {AnimatePresence,motion}from'framer-motion';import {CheckCircle2,PlayCircle,Circle,Scissors,Settings,Eye,EyeOff,ArrowDown,ArrowUp,ArrowUpDown,BarChart3,Link2,Minus,Plus,Trash2,Pencil,Edit3,AlertTriangle,Moon,Sun,Palette,ZoomOut,ZoomIn,Keyboard,ChevronRight,Image,FileText,File,Sparkles,Maximize2,MoreHorizontal,X,User,ChevronDown,Check,CalendarDays,Flag,Clock,Tag,Diamond,ListChecks,Upload,MessageSquare,Send,Rows3,FileImage,FileSpreadsheet,FileJson,FolderKanban,Download,Calendar,ChevronLeft,GripVertical,AlertCircle,CircleDot,Users,Milestone,List,Search}from'lucide-react';import {Command}from'cmdk';import Bu from'react-markdown';import Ru from'remark-gfm';import Ou from'rehype-sanitize';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Legend,Line,AreaChart,Area,PieChart,Pie,Cell,BarChart,Bar}from'recharts';var qo=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,a)=>(typeof require<"u"?require:t)[a]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Xo=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:a}=e;return "translate3d("+(t?Math.round(t):0)+"px, "+(a?Math.round(a):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:a}=e;return "scaleX("+t+") scaleY("+a+")"}},Transform:{toString(e){if(e)return [Xo.Translate.toString(e),Xo.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:a,easing:r}=e;return t+" "+a+"ms "+r}}});function h(...e){return twMerge(clsx(e))}function Jo(e,t){return e===null&&t===null?1e3:e===null&&t!==null?t/2:e!==null&&t===null?e+1e3:e!==null&&t!==null?(e+t)/2:1e3}function Ym(e){return Array.from({length:e},(t,a)=>(a+1)*1e3)}function Qn(e,t){return e.length===0?1e3:t===0?Jo(null,e[0].position):t>=e.length?Jo(e[e.length-1].position,null):Jo(e[t-1].position,e[t].position)}function hl(e,t=100){return e>t}var qm=e=>{if(e.message.includes("network")||e.message.includes("fetch"))return true;if("status"in e){let t=e.status;return t>=500||t===429}return false};function Xm(e,t,a,r){let o=t*Math.pow(a,e-1),s=o*.2*Math.random();return Math.min(o+s,r)}async function Zo(e,t={}){let{maxAttempts:a=3,initialDelay:r=1e3,backoffMultiplier:o=2,maxDelay:s=1e4,shouldRetry:n=qm,onRetry:c}=t,p,i=0;for(let u=1;u<=a;u++){i=u;try{return {data:await e(),attempts:i,success:!0}}catch(d){if(p=d,u===a||!n(p,u))return {error:p,attempts:i,success:false};let f=Xm(u,r,o,s);if(c)try{c(p,u,f);}catch(C){console.error("Error in retry callback:",C);}await new Promise(C=>setTimeout(C,f));}}return {error:p||new Error("Unknown error"),attempts:i,success:false}}function Jm(e,t=3){let a;for(let r=1;r<=t;r++)try{return {data:e(),success:!0}}catch(o){if(a=o,r===t)return {error:a,success:false}}return {error:a||new Error("Unknown error"),success:false}}function Zm(e,t={}){return async(...a)=>Zo(()=>e(...a),t)}var es=class{constructor(t=5,a=6e4){this.threshold=t;this.resetTimeout=a;this.failures=0;this.lastFailureTime=0;this.isOpen=false;}async execute(t){if(this.isOpen)if(Date.now()-this.lastFailureTime>=this.resetTimeout)this.reset();else throw new Error("Circuit breaker is open - too many failures");try{let a=await t();return this.onSuccess(),a}catch(a){throw this.onFailure(),a}}onSuccess(){this.failures=0,this.isOpen=false;}onFailure(){this.failures++,this.lastFailureTime=Date.now(),this.failures>=this.threshold&&(this.isOpen=true);}reset(){this.failures=0,this.isOpen=false;}getStatus(){return {failures:this.failures,isOpen:this.isOpen}}};var bl=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.NONE=4]="NONE",s))(bl||{}),Ir=class Ir{constructor(t={}){this.defaultLogHandler=t=>{let{timestamp:a,level:r,message:o,component:s,...n}=t,c=`[${a}] [${r}] [${s}]`,p=Object.keys(n).length>0;switch(r){case "DEBUG":console.debug(c,o,p?n:"");break;case "INFO":console.info(c,o,p?n:"");break;case "WARN":console.warn(c,o,p?n:"");break;case "ERROR":console.error(c,o,p?n:""),t.error?.stack&&console.error(t.error.stack);break}};let a=process.env.NODE_ENV==="development";this.options={minLevel:t.minLevel??(a?0:1),enabled:t.enabled??true,onLog:t.onLog??this.defaultLogHandler,enableTiming:t.enableTiming??true,componentName:t.componentName??"ASAKAA",...Ir.globalOptions};}static configure(t){Ir.globalOptions={...Ir.globalOptions,...t};}child(t){return new Ir({...this.options,componentName:`${this.options.componentName}:${t}`})}debug(t,a){this.log(0,t,a);}info(t,a){this.log(1,t,a);}warn(t,a){this.log(2,t,a);}error(t,a,r){this.log(3,t,{...r,error:a?{message:a.message,stack:a.stack,name:a.name}:void 0});}startTimer(t){return this.options.enableTiming?new Qo((a,r)=>{this.log(0,`${t} completed`,{...r,action:t,duration:a});},true):new Qo(()=>{},false)}log(t,a,r){if(!this.options.enabled||t<this.options.minLevel)return;let o={timestamp:new Date().toISOString(),level:bl[t],message:a,component:this.options.componentName,...r};this.options.onLog(o);}};Ir.globalOptions={};var ts=Ir,Qo=class{constructor(t,a){this.onEnd=t;this.enabled=a;this.startTime=a?performance.now():0;}end(t){if(!this.enabled)return 0;let a=Math.round(performance.now()-this.startTime);return this.onEnd(a,t),a}elapsed(){return this.enabled?Math.round(performance.now()-this.startTime):0}},yl=new ts;function ep(e,t){let a={board:{id:e.id,title:e.title,metadata:e.metadata,exportedAt:new Date().toISOString()},columns:e.columns,cards:e.cards,options:t};return JSON.stringify(a,null,2)}function tp(e,t){let a=["Card ID","Title","Description","Column","Priority","Labels","Assigned Users","Start Date","End Date","Created At","Updated At"],r=e.cards.map(s=>{let n=e.columns.find(c=>c.id===s.columnId);return [s.id,as(s.title),as(s.description||""),as(n?.title||""),s.priority||"",(s.labels||[]).join(";"),(s.assignedUserIds||[]).join(";"),s.startDate||"",s.endDate||"",s.createdAt||"",s.updatedAt||""]});return [a.join(","),...r.map(s=>s.join(","))].join(`
2
- `)}async function ap(e,t,a){let r=t;if(!r){let n=document.querySelector(".asakaa-board");n&&(r=n.parentElement||n);}if(r)try{let n=await fc(r,{backgroundColor:"#0a0a0a",scale:1.5,logging:!1,useCORS:!0,allowTaint:!0,windowWidth:r.scrollWidth,windowHeight:r.scrollHeight}),c=n.toDataURL("image/png"),p=297,i=210,u=n.width/n.height,d=p-20,g=d/u;g>i-20&&(g=i-20,d=g*u);let f=new jsPDF({orientation:"landscape",unit:"mm",format:"a4"});f.setFontSize(16),f.setTextColor(255,255,255),f.setFillColor(10,10,10),f.rect(0,0,p,15,"F"),f.text(e.title||"Kanban Board",10,10);let C=(p-d)/2;return f.addImage(c,"PNG",C,20,d,g),f}catch(n){console.error("Error capturing board:",n);}let o=new jsPDF,s=20;return o.setFontSize(20),o.text(e.title||"Kanban Board",20,s),s+=10,o.setFontSize(10),o.setTextColor(128,128,128),o.text(`Exported on ${new Date().toLocaleString()}`,20,s),s+=15,o.setTextColor(0,0,0),e.columns.forEach(n=>{let c=e.cards.filter(p=>p.columnId===n.id);s>250&&(o.addPage(),s=20),o.setFontSize(16),o.setFont("helvetica","bold"),o.text(n.title,20,s),s+=8,c.length===0?(o.setFontSize(10),o.setFont("helvetica","italic"),o.setTextColor(128,128,128),o.text("No cards in this column",20,s),o.setTextColor(0,0,0),s+=10):c.forEach(p=>{if(s>260&&(o.addPage(),s=20),o.setFontSize(12),o.setFont("helvetica","bold"),o.text(p.title,25,s),s+=6,p.description){o.setFontSize(9),o.setFont("helvetica","normal");let u=o.splitTextToSize(p.description,160);o.text(u,25,s),s+=u.length*5;}let i=[];if(p.priority&&i.push(`Priority: ${p.priority}`),p.labels&&p.labels.length>0&&i.push(`Labels: ${p.labels.join(", ")}`),p.assignedUserIds&&p.assignedUserIds.length>0&&i.push(`Assigned: ${p.assignedUserIds.length} user(s)`),p.startDate||p.endDate){let u=[];p.startDate&&u.push(`Start: ${p.startDate}`),p.endDate&&u.push(`End: ${p.endDate}`),i.push(u.join(" \u2192 "));}i.length>0&&(o.setFontSize(8),o.setTextColor(100,100,100),o.text(i.join(" \u2022 "),25,s),o.setTextColor(0,0,0),s+=5),s+=5;}),s+=5;}),o}function as(e){return e.includes(",")||e.includes('"')||e.includes(`
1
+ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,selectionStore,BoardStore}from'@libxai/core';export{Board as BoardModel,BoardStore,Card as CardModel,Column as ColumnModel,DependencyEngine,Store}from'@libxai/core';import {createContext,memo,useRef,useState,forwardRef,useContext,useEffect,useCallback,useMemo,useImperativeHandle,Component}from'react';import {useDroppable,useSensors,useSensor,PointerSensor,KeyboardSensor,DndContext,closestCorners,DragOverlay}from'@dnd-kit/core';import {useSortable,SortableContext,verticalListSortingStrategy,sortableKeyboardCoordinates}from'@dnd-kit/sortable';import {useVirtualizer}from'@tanstack/react-virtual';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsPDF}from'jspdf';import fc from'html2canvas';import {createPortal}from'react-dom';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {AnimatePresence,motion}from'framer-motion';import {CheckCircle2,PlayCircle,Circle,Scissors,Settings,Eye,EyeOff,ArrowDown,ArrowUp,ArrowUpDown,BarChart3,Link2,Minus,Plus,Trash2,Pencil,Edit3,AlertTriangle,Moon,Sun,Palette,ZoomOut,ZoomIn,Keyboard,ChevronRight,Image,FileText,File,Sparkles,Maximize2,MoreHorizontal,X,User,ChevronDown,Check,CalendarDays,Flag,Clock,Tag,Diamond,ListChecks,Upload,MessageSquare,Send,Rows3,FileImage,FileSpreadsheet,FileJson,FolderKanban,Download,Calendar,ChevronLeft,GripVertical,AlertCircle,CircleDot,Users,Milestone,List,Search}from'lucide-react';import {Command}from'cmdk';import Bu from'react-markdown';import Ru from'remark-gfm';import Ou from'rehype-sanitize';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Legend,Line,AreaChart,Area,PieChart,Pie,Cell,BarChart,Bar}from'recharts';var Zo=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,a)=>(typeof require<"u"?require:t)[a]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Qo=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:a}=e;return "translate3d("+(t?Math.round(t):0)+"px, "+(a?Math.round(a):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:a}=e;return "scaleX("+t+") scaleY("+a+")"}},Transform:{toString(e){if(e)return [Qo.Translate.toString(e),Qo.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:a,easing:r}=e;return t+" "+a+"ms "+r}}});function f(...e){return twMerge(clsx(e))}function en(e,t){return e===null&&t===null?1e3:e===null&&t!==null?t/2:e!==null&&t===null?e+1e3:e!==null&&t!==null?(e+t)/2:1e3}function Ym(e){return Array.from({length:e},(t,a)=>(a+1)*1e3)}function as(e,t){return e.length===0?1e3:t===0?en(null,e[0].position):t>=e.length?en(e[e.length-1].position,null):en(e[t-1].position,e[t].position)}function hl(e,t=100){return e>t}var qm=e=>{if(e.message.includes("network")||e.message.includes("fetch"))return true;if("status"in e){let t=e.status;return t>=500||t===429}return false};function Xm(e,t,a,r){let o=t*Math.pow(a,e-1),s=o*.2*Math.random();return Math.min(o+s,r)}async function tn(e,t={}){let{maxAttempts:a=3,initialDelay:r=1e3,backoffMultiplier:o=2,maxDelay:s=1e4,shouldRetry:n=qm,onRetry:c}=t,p,i=0;for(let u=1;u<=a;u++){i=u;try{return {data:await e(),attempts:i,success:!0}}catch(d){if(p=d,u===a||!n(p,u))return {error:p,attempts:i,success:false};let h=Xm(u,r,o,s);if(c)try{c(p,u,h);}catch(C){console.error("Error in retry callback:",C);}await new Promise(C=>setTimeout(C,h));}}return {error:p||new Error("Unknown error"),attempts:i,success:false}}function Jm(e,t=3){let a;for(let r=1;r<=t;r++)try{return {data:e(),success:!0}}catch(o){if(a=o,r===t)return {error:a,success:false}}return {error:a||new Error("Unknown error"),success:false}}function Zm(e,t={}){return async(...a)=>tn(()=>e(...a),t)}var rs=class{constructor(t=5,a=6e4){this.threshold=t;this.resetTimeout=a;this.failures=0;this.lastFailureTime=0;this.isOpen=false;}async execute(t){if(this.isOpen)if(Date.now()-this.lastFailureTime>=this.resetTimeout)this.reset();else throw new Error("Circuit breaker is open - too many failures");try{let a=await t();return this.onSuccess(),a}catch(a){throw this.onFailure(),a}}onSuccess(){this.failures=0,this.isOpen=false;}onFailure(){this.failures++,this.lastFailureTime=Date.now(),this.failures>=this.threshold&&(this.isOpen=true);}reset(){this.failures=0,this.isOpen=false;}getStatus(){return {failures:this.failures,isOpen:this.isOpen}}};var bl=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.NONE=4]="NONE",s))(bl||{}),Or=class Or{constructor(t={}){this.defaultLogHandler=t=>{let{timestamp:a,level:r,message:o,component:s,...n}=t,c=`[${a}] [${r}] [${s}]`,p=Object.keys(n).length>0;switch(r){case "DEBUG":console.debug(c,o,p?n:"");break;case "INFO":console.info(c,o,p?n:"");break;case "WARN":console.warn(c,o,p?n:"");break;case "ERROR":console.error(c,o,p?n:""),t.error?.stack&&console.error(t.error.stack);break}};let a=process.env.NODE_ENV==="development";this.options={minLevel:t.minLevel??(a?0:1),enabled:t.enabled??true,onLog:t.onLog??this.defaultLogHandler,enableTiming:t.enableTiming??true,componentName:t.componentName??"ASAKAA",...Or.globalOptions};}static configure(t){Or.globalOptions={...Or.globalOptions,...t};}child(t){return new Or({...this.options,componentName:`${this.options.componentName}:${t}`})}debug(t,a){this.log(0,t,a);}info(t,a){this.log(1,t,a);}warn(t,a){this.log(2,t,a);}error(t,a,r){this.log(3,t,{...r,error:a?{message:a.message,stack:a.stack,name:a.name}:void 0});}startTimer(t){return this.options.enableTiming?new an((a,r)=>{this.log(0,`${t} completed`,{...r,action:t,duration:a});},true):new an(()=>{},false)}log(t,a,r){if(!this.options.enabled||t<this.options.minLevel)return;let o={timestamp:new Date().toISOString(),level:bl[t],message:a,component:this.options.componentName,...r};this.options.onLog(o);}};Or.globalOptions={};var os=Or,an=class{constructor(t,a){this.onEnd=t;this.enabled=a;this.startTime=a?performance.now():0;}end(t){if(!this.enabled)return 0;let a=Math.round(performance.now()-this.startTime);return this.onEnd(a,t),a}elapsed(){return this.enabled?Math.round(performance.now()-this.startTime):0}},yl=new os;function ep(e,t){let a={board:{id:e.id,title:e.title,metadata:e.metadata,exportedAt:new Date().toISOString()},columns:e.columns,cards:e.cards,options:t};return JSON.stringify(a,null,2)}function tp(e,t){let a=["Card ID","Title","Description","Column","Priority","Labels","Assigned Users","Start Date","End Date","Created At","Updated At"],r=e.cards.map(s=>{let n=e.columns.find(c=>c.id===s.columnId);return [s.id,ns(s.title),ns(s.description||""),ns(n?.title||""),s.priority||"",(s.labels||[]).join(";"),(s.assignedUserIds||[]).join(";"),s.startDate||"",s.endDate||"",s.createdAt||"",s.updatedAt||""]});return [a.join(","),...r.map(s=>s.join(","))].join(`
2
+ `)}async function ap(e,t,a){let r=t;if(!r){let n=document.querySelector(".asakaa-board");n&&(r=n.parentElement||n);}if(r)try{let n=await fc(r,{backgroundColor:"#0a0a0a",scale:1.5,logging:!1,useCORS:!0,allowTaint:!0,windowWidth:r.scrollWidth,windowHeight:r.scrollHeight}),c=n.toDataURL("image/png"),p=297,i=210,u=n.width/n.height,d=p-20,g=d/u;g>i-20&&(g=i-20,d=g*u);let h=new jsPDF({orientation:"landscape",unit:"mm",format:"a4"});h.setFontSize(16),h.setTextColor(255,255,255),h.setFillColor(10,10,10),h.rect(0,0,p,15,"F"),h.text(e.title||"Kanban Board",10,10);let C=(p-d)/2;return h.addImage(c,"PNG",C,20,d,g),h}catch(n){console.error("Error capturing board:",n);}let o=new jsPDF,s=20;return o.setFontSize(20),o.text(e.title||"Kanban Board",20,s),s+=10,o.setFontSize(10),o.setTextColor(128,128,128),o.text(`Exported on ${new Date().toLocaleString()}`,20,s),s+=15,o.setTextColor(0,0,0),e.columns.forEach(n=>{let c=e.cards.filter(p=>p.columnId===n.id);s>250&&(o.addPage(),s=20),o.setFontSize(16),o.setFont("helvetica","bold"),o.text(n.title,20,s),s+=8,c.length===0?(o.setFontSize(10),o.setFont("helvetica","italic"),o.setTextColor(128,128,128),o.text("No cards in this column",20,s),o.setTextColor(0,0,0),s+=10):c.forEach(p=>{if(s>260&&(o.addPage(),s=20),o.setFontSize(12),o.setFont("helvetica","bold"),o.text(p.title,25,s),s+=6,p.description){o.setFontSize(9),o.setFont("helvetica","normal");let u=o.splitTextToSize(p.description,160);o.text(u,25,s),s+=u.length*5;}let i=[];if(p.priority&&i.push(`Priority: ${p.priority}`),p.labels&&p.labels.length>0&&i.push(`Labels: ${p.labels.join(", ")}`),p.assignedUserIds&&p.assignedUserIds.length>0&&i.push(`Assigned: ${p.assignedUserIds.length} user(s)`),p.startDate||p.endDate){let u=[];p.startDate&&u.push(`Start: ${p.startDate}`),p.endDate&&u.push(`End: ${p.endDate}`),i.push(u.join(" \u2192 "));}i.length>0&&(o.setFontSize(8),o.setTextColor(100,100,100),o.text(i.join(" \u2022 "),25,s),o.setTextColor(0,0,0),s+=5),s+=5;}),s+=5;}),o}function ns(e){return e.includes(",")||e.includes('"')||e.includes(`
3
3
  `)?`"${e.replace(/"/g,'""')}"`:e}async function xl(e,t,a,r){switch(t){case "json":return ep(e,r);case "csv":return tp(e);case "pdf":return await ap(e,a);default:throw new Error(`Unsupported export format: ${t}`)}}function kl(e,t,a){let r=`board-export-${new Date().getTime()}`;if(t==="pdf"&&typeof e=="object"&&e!==null&&"save"in e){let u=`${r}.pdf`;e.save(u);return}if(typeof e!="string")throw new Error("Invalid content type for non-PDF export");let s=`${r}.${{json:"json",csv:"csv",pdf:"pdf"}[t]}`,n={json:"application/json",csv:"text/csv",pdf:"application/pdf"},c=new Blob([e],{type:n[t]}),p=URL.createObjectURL(c),i=document.createElement("a");i.href=p,i.download=s,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(p);}function rp(e){try{let t=JSON.parse(e);if(!t.board||!t.columns||!t.cards)return {success:!1,errors:["Invalid JSON format: missing required fields (board, columns, cards)"]};let a={id:t.board.id,title:t.board.title,columns:t.columns,cards:t.cards,metadata:t.board.metadata};return {success:!0,cardsImported:a.cards.length,columnsImported:a.columns.length}}catch(t){return {success:false,errors:[`Failed to parse JSON: ${t instanceof Error?t.message:"Unknown error"}`]}}}function op(e){try{let t=e.trim().split(`
4
- `);if(t.length<1||!t[0])return {success:!1,errors:["CSV file is empty or invalid"]};let a=wl(t[0]),r=[],o=new Map,s=[];for(let n=1;n<t.length;n++)try{let c=wl(t[n]||"");if(c.length>a.length){s.push(`Line ${n+1}: Too many columns`);continue}if(a.length-c.length>3){s.push(`Line ${n+1}: Column count mismatch (expected ${a.length}, got ${c.length})`);continue}for(;c.length<a.length;)c.push("");let i={};a.forEach((f,C)=>{i[f]=c[C]||"";});let u=i.Column||"Unnamed";o.has(u)||o.set(u,{id:`col-${o.size+1}`,title:u,position:o.size+1,cardIds:[]});let d=o.get(u),g={id:i["Card ID"]||`card-${n}`,title:i.Title||"Untitled",description:i.Description?i.Description:void 0,columnId:d.id,position:d.cardIds.length+1,priority:i.Priority||void 0,labels:i.Labels?i.Labels.split(";").filter(Boolean):void 0,assignedUserIds:i["Assigned Users"]?i["Assigned Users"].split(";").filter(Boolean):void 0,startDate:i["Start Date"]?i["Start Date"]:void 0,endDate:i["End Date"]?i["End Date"]:void 0,createdAt:i["Created At"]?i["Created At"]:void 0,updatedAt:i["Updated At"]?i["Updated At"]:void 0};r.push(g),d.cardIds.push(g.id);}catch(c){s.push(`Line ${n+1}: ${c instanceof Error?c.message:"Unknown error"}`);}return r.length===0?{success:!1,errors:["No valid cards found in CSV",...s]}:{success:!0,cardsImported:r.length,columnsImported:o.size,errors:s.length>0?s:void 0}}catch(t){return {success:false,errors:[`Failed to parse CSV: ${t instanceof Error?t.message:"Unknown error"}`]}}}function wl(e){let t=[],a="",r=false;for(let o=0;o<e.length;o++){let s=e[o],n=e[o+1];s==='"'&&r&&n==='"'?(a+='"',o++):s==='"'?r=!r:s===","&&!r?(t.push(a),a=""):a+=s;}return t.push(a),t}function Cl(e,t){switch(t){case "json":return rp(e);case "csv":return op(e);default:return {success:false,errors:[`Unsupported import format: ${t}`]}}}function Tl(e){return new Promise((t,a)=>{let r=new FileReader;r.onload=o=>{o.target?.result?t(o.target.result):a(new Error("Failed to read file"));},r.onerror=()=>a(new Error("Failed to read file")),r.readAsText(e);})}var rs=createContext(null);function Nl(){return useContext(rs)}var Dl=createContext(null);function Sl({children:e,themeName:t}){return jsx(Dl.Provider,{value:{themeName:t},children:e})}function eo(){return useContext(Dl)}function ut({children:e,container:t}){let[a,r]=useState(false),o=Nl(),s=eo();if(useEffect(()=>(r(true),()=>r(false)),[]),!a)return null;let n=t||(typeof document<"u"?document.body:null);if(!n)return null;if(o){let{theme:c,themeName:p}=o,i={"--asakaa-color-background-primary":c.bgPrimary,"--asakaa-color-background-secondary":c.bgSecondary,"--asakaa-color-background-card":c.bgGrid,"--asakaa-color-background-hover":c.hoverBg,"--asakaa-color-text-primary":c.textPrimary,"--asakaa-color-text-secondary":c.textSecondary,"--asakaa-color-text-tertiary":c.textTertiary,"--asakaa-color-text-inverse":c.taskBarHandle||"#FFFFFF","--asakaa-color-border-default":c.border,"--asakaa-color-border-hover":c.borderLight,"--asakaa-color-border-subtle":c.borderLight,"--asakaa-color-interactive-primary":c.accent,"--asakaa-color-interactive-primaryHover":c.accentHover,"--asakaa-color-interactive-primaryBorder":`${c.accent}4D`,"--asakaa-color-interactive-primaryBackground":`${c.accent}1A`,"--asakaa-color-interactive-primaryBackgroundHover":`${c.accent}33`,"--asakaa-color-status-success":c.statusCompleted,"--asakaa-color-status-warning":c.milestone,"--asakaa-color-status-error":c.criticalPath,"--asakaa-color-danger":c.criticalPath,"--asakaa-color-danger-border":`${c.criticalPath}4D`,"--asakaa-color-danger-background":`${c.criticalPath}14`,"--asakaa-color-danger-backgroundHover":`${c.criticalPath}26`};return createPortal(jsx("div",{"data-theme":p,"data-gantt-portal":"true",style:i,children:e}),n)}return s?createPortal(jsx("div",{"data-theme":s.themeName,"data-kanban-portal":"true",children:e}),n):createPortal(e,n)}var Fl={URGENT:{label:"Urgent",color:"#E74C3C"},HIGH:{label:"High",color:"#E67E22"},MEDIUM:{label:"Normal",color:"#F1C40F"},LOW:{label:"Low",color:"#2ECC71"}},pp="#BDC3C7",up=({color:e})=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",fill:e,opacity:"0.9"}),jsx("circle",{cx:"8",cy:"8",r:"6",stroke:e,strokeWidth:"1.5",opacity:"0.3"})]});function Lr({priority:e,onChange:t,className:a}){let[r,o]=useState(false),[s,n]=useState({top:0,left:0}),c=useRef(null),p=useRef(null),i=()=>{if(!p.current)return;let f=p.current.getBoundingClientRect(),C=window.innerHeight,T=window.innerWidth,m=160,b=220,y=4,l=f.right-m;l<10&&(l=f.left),l+m>T-10&&(l=T-m-10);let w=C-f.bottom,v=f.top,S;w>=b+y?S=f.bottom+y:v>=b+y?S=f.top-b-y:S=w>=v?f.bottom+y:Math.max(10,f.top-b-y),n({top:S,left:l}),o(true);};useEffect(()=>{let f=C=>{c.current&&!c.current.contains(C.target)&&!p.current?.contains(C.target)&&o(false);};if(r)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[r]),useEffect(()=>{let f=C=>{C.key==="Escape"&&o(false);};if(r)return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[r]);let u=f=>{t(f),o(false);},d=e?Fl[e]:null,g=d?.color||pp;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:p,onClick:()=>r?o(false):i(),className:"flex items-center justify-center w-8 h-8 rounded-lg transition-all hover:bg-white/15 hover:scale-110 active:scale-95",style:{background:e?`${g}10`:"transparent",boxShadow:e?`0 0 0 2px ${g}30 inset`:"none"},title:d?.label||"Set priority",children:jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M3 2L3 14M3 2L13 6L3 8V2Z",stroke:g,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:g,fillOpacity:e?"0.6":"0.4"})})}),r&&jsx(ut,{children:jsxs("div",{ref:c,className:"priority-selector-menu",style:{position:"fixed",top:`${s.top}px`,left:`${s.left}px`,zIndex:99999,minWidth:"160px",maxHeight:"calc(100vh - 40px)",borderRadius:"8px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},children:[jsx("div",{className:"px-3 py-1.5 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.7))"},children:"Priority"})}),jsxs("div",{className:"py-1",children:[Object.entries(Fl).map(([f,C])=>jsxs("button",{onClick:()=>u(f),className:"w-full px-3 py-1.5 flex items-center gap-2 text-xs font-medium transition-all active:scale-[0.98] priority-option",style:{color:C.color,background:"transparent"},onMouseEnter:T=>{T.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:T=>{T.currentTarget.style.background="transparent";},children:[jsx(up,{color:C.color}),jsx("span",{className:"font-semibold text-sm",children:C.label}),e===f&&jsx("svg",{className:"ml-auto",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"#3B82F6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]},f)),jsx("div",{className:"mt-0.5 pt-0.5 border-t",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsxs("button",{onClick:()=>u(void 0),className:"w-full px-3 py-1.5 flex items-center gap-2 text-xs font-medium transition-all active:scale-[0.98]",style:{color:"var(--modal-v2-text-primary, #e5e5e5)",background:"transparent"},onMouseEnter:f=>{f.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:f=>{f.currentTarget.style.background="transparent";},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"#9CA3AF",strokeWidth:"1.5",strokeDasharray:"2 2",opacity:"0.6"})}),jsx("span",{className:"font-semibold text-sm",children:"Clear"}),!e&&jsx("svg",{className:"ml-auto",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"#3B82F6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})})]})]})})]})}var gp=[{label:"Today",days:0},{label:"Tomorrow",days:1},{label:"Next Week",days:7},{label:"2 Weeks",days:14},{label:"4 Weeks",days:28},{label:"8 Weeks",days:56}];function xo({startDate:e,endDate:t,onChange:a,className:r}){let[o,s]=useState(false),[n,c]=useState({top:0,left:0}),p=useRef(null),i=useRef(null),g=(eo()?.themeName||"dark")==="dark",f=()=>{if(!i.current)return;let l=i.current.getBoundingClientRect(),w=window.innerHeight,v=window.innerWidth,S=320,x=380,k=4,O=l.left;O+S>v-10&&(O=v-S-10),O<10&&(O=10);let A=w-l.bottom,N=l.top,H;A>=x+k?H=l.bottom+k:N>=x+k?H=l.top-x-k:H=A>=N?l.bottom+k:Math.max(10,l.top-x-k),c({top:H,left:O}),s(true);};useEffect(()=>{let l=w=>{p.current&&!p.current.contains(w.target)&&!i.current?.contains(w.target)&&s(false);};if(o)return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[o]),useEffect(()=>{let l=w=>{w.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[o]);let C=l=>{let w=new Date,v=O=>{let A=O.getFullYear(),N=String(O.getMonth()+1).padStart(2,"0"),H=String(O.getDate()).padStart(2,"0");return `${A}-${N}-${H}`},S=v(w),x=new Date(w);x.setDate(x.getDate()+l);let k=v(x);a(S,k),s(false);},T=()=>{if(!e||!t)return "Set date";let l=x=>{if(x instanceof Date)return x;if(typeof x!="string"||!x.match(/^\d{4}-\d{2}-\d{2}$/))return null;let k=x.split("-").map(Number);if(k.length!==3||k.some(H=>isNaN(H)))return null;let O=k[0],A=k[1],N=k[2];return O===void 0||A===void 0||N===void 0?null:new Date(O,A-1,N)},w=l(e),v=l(t);if(!w||!v||isNaN(w.getTime())||isNaN(v.getTime()))return "Set date";let S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return `${S[w.getMonth()]} ${w.getDate()} \u2013 ${S[v.getMonth()]} ${v.getDate()}`},m=e&&t,y=(()=>{if(!t)return false;let l=typeof t=="string"?new Date(t):t,w=new Date;return w.setHours(0,0,0,0),l<w})();return jsxs("div",{className:`relative ${r||""}`,children:[jsxs("button",{ref:i,onClick:()=>o?s(false):f(),className:`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-all hover:bg-white/5 ${y?"asakaa-date-overdue":"asakaa-date"}`,title:m?`${T()}`:"Set date range",children:[jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{x:"2",y:"3",width:"12",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M2 6H14",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M5 2V4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("path",{d:"M11 2V4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),e&&t&&jsx("span",{className:"whitespace-nowrap",children:T()})]}),o&&jsx(ut,{children:jsxs("div",{ref:p,className:"date-picker-menu rounded-xl shadow-2xl border min-w-[320px]",style:{position:"fixed",top:`${n.top}px`,left:`${n.left}px`,background:g?"#1A1D25":"#FFFFFF",border:`1px solid ${g?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.12)"}`,boxShadow:g?"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)":"0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.08)",zIndex:99999},children:[jsxs("div",{className:"p-4 border-b",style:{borderColor:g?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.08)"},children:[jsx("span",{className:"text-xs font-bold uppercase tracking-wider block mb-3",style:{color:g?"rgba(255, 255, 255, 0.85)":"rgba(0, 0, 0, 0.7)"},children:"Quick Select"}),jsx("div",{className:"grid grid-cols-2 gap-2",children:gp.map(l=>jsx("button",{onClick:()=>C(l.days),className:"px-3 py-2.5 rounded-lg text-xs font-semibold transition-all active:scale-95",style:{color:g?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",border:`1px solid ${g?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`,backgroundColor:g?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)"},onMouseEnter:w=>{w.currentTarget.style.backgroundColor=g?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.1)",w.currentTarget.style.border=`1px solid ${g?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.25)"}`;},onMouseLeave:w=>{w.currentTarget.style.backgroundColor=g?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",w.currentTarget.style.border=`1px solid ${g?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`;},children:l.label},l.label))})]}),jsxs("div",{className:"p-4",children:[jsx("span",{className:"text-xs font-bold uppercase tracking-wider block mb-3",style:{color:g?"rgba(255, 255, 255, 0.85)":"rgba(0, 0, 0, 0.7)"},children:"Custom Range"}),jsxs("div",{className:"space-y-3",children:[jsx("input",{type:"date",value:e||"",onChange:l=>a(l.target.value,t),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:g?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:g?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:g?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:g?"dark":"light"}}),jsx("input",{type:"date",value:t||"",onChange:l=>a(e,l.target.value),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:g?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:g?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:g?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:g?"dark":"light"}})]}),(e||t)&&jsx("button",{onClick:()=>{a(void 0,void 0),s(false);},className:"mt-4 w-full px-3 py-2.5 rounded-lg text-sm font-semibold transition-all active:scale-95 border",style:{color:"#ef4444",borderColor:"rgba(239, 68, 68, 0.3)",background:"rgba(239, 68, 68, 0.1)"},onMouseEnter:l=>{l.currentTarget.style.background="rgba(239, 68, 68, 0.2)";},onMouseLeave:l=>{l.currentTarget.style.background="rgba(239, 68, 68, 0.1)";},children:"Clear Dates"})]})]})})]})}function Rr({assignedUsers:e=[],availableUsers:t,onChange:a,className:r,maxVisibleAvatars:o=3}){let[s,n]=useState(false),[c,p]=useState(""),[i,u]=useState({top:0,left:0}),d=useRef(null),g=useRef(null),f=()=>{if(!g.current)return;let y=g.current.getBoundingClientRect(),l=window.innerHeight,w=window.innerWidth,v=300,S=380,x=4,k=y.right-v;k<10&&(k=y.left),k+v>w-10&&(k=w-v-10);let O=l-y.bottom,A=y.top,N;O>=S+x?N=y.bottom+x:A>=S+x?N=y.top-S-x:N=O>=A?y.bottom+x:Math.max(10,y.top-S-x),u({top:N,left:k}),n(true);};useEffect(()=>{let y=l=>{d.current&&!d.current.contains(l.target)&&!g.current?.contains(l.target)&&(n(false),p(""));};if(s)return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[s]),useEffect(()=>{let y=l=>{l.key==="Escape"&&(n(false),p(""));};if(s)return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[s]);let C=y=>{let l=e.some(w=>w.id===y.id);a(l?e.filter(w=>w.id!==y.id):[...e,y]);},T=t.filter(y=>y.name.toLowerCase().includes(c.toLowerCase())),m=e.slice(0,o),b=e.length-o;return jsxs("div",{className:`relative ${r||""}`,children:[jsx("button",{ref:g,onClick:()=>s?n(false):f(),className:"flex items-center gap-1 p-0.5 rounded transition-all hover:bg-white/10 hover:scale-105 active:scale-95",title:e.length>0?`${e.length} assigned`:"Assign users",children:e.length>0?jsxs("div",{className:"asakaa-avatar-group",children:[m.map(y=>jsx("div",{className:"asakaa-avatar",title:y.name,children:y.avatar?jsx("img",{src:y.avatar,alt:y.name,className:"asakaa-avatar-img"}):y.initials},y.id)),b>0&&jsxs("div",{className:"asakaa-avatar",children:["+",b]})]}):jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center transition-all",style:{background:"rgba(96, 165, 250, 0.15)",border:"1.5px solid rgba(96, 165, 250, 0.4)",color:"#60a5fa"},children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M8 8a3 3 0 100-6 3 3 0 000 6zM4 14c0-2.21 1.79-4 4-4s4 1.79 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("line",{x1:"13",y1:"5",x2:"13",y2:"9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("line",{x1:"11",y1:"7",x2:"15",y2:"7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})})}),s&&jsx(ut,{children:jsxs("div",{ref:d,className:"user-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${i.top}px`,left:`${i.left}px`,maxHeight:"calc(100vh - 40px)",overflow:"hidden",display:"flex",flexDirection:"column",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:[jsx("div",{className:"px-4 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-xs font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.8))"},children:"Assign Users"})}),jsx("div",{className:"px-3 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("input",{type:"text",value:c,onChange:y=>p(y.target.value),placeholder:"Search users...",className:"w-full px-3 py-2.5 rounded-lg text-sm border outline-none transition-all",style:{background:"var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))",borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.2))",color:"var(--modal-v2-text-primary, #ffffff)"},autoFocus:true})}),jsx("div",{className:"py-2 max-h-[300px] overflow-y-auto",children:T.length===0?jsx("div",{className:"px-4 py-3 text-sm text-center",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.6))"},children:"No users found"}):T.map(y=>{let l=e.some(w=>w.id===y.id);return jsxs("button",{onClick:()=>C(y),className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm transition-all active:scale-98",style:{background:"transparent"},onMouseEnter:w=>{w.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.1))";},onMouseLeave:w=>{w.currentTarget.style.background="transparent";},children:[jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-[11px] font-bold flex-shrink-0 shadow-sm",style:{backgroundColor:y.color,color:"#fff"},children:y.avatar?jsx("img",{src:y.avatar,alt:y.name,className:"w-full h-full rounded-full object-cover"}):y.initials}),jsx("span",{className:"font-semibold flex-1 text-left truncate",style:{color:"var(--modal-v2-text-primary, rgba(255, 255, 255, 0.95))"},children:y.name}),jsx("span",{className:"w-5 text-lg flex-shrink-0 text-right",style:{color:l?"#3b82f6":"transparent"},children:l?"\u2713":""})]},y.id)})}),e.length>0&&jsx("div",{className:"px-3 py-3 border-t border-white/10",children:jsx("button",{onClick:()=>{a([]),n(false);},className:"w-full px-3 py-2.5 rounded-lg text-sm font-semibold transition-all hover:bg-red-600/30 active:scale-95 border",style:{color:"#f87171",borderColor:"rgba(248, 113, 113, 0.3)",background:"rgba(248, 113, 113, 0.08)"},children:"Clear All"})})]})})]})}function en(e,t,a){let r=new Map;e.forEach(p=>{if(p.dependencies&&Array.isArray(p.dependencies)){let i=p.dependencies.map(u=>{if(typeof u=="string")return u;let d=u;return d.taskId||d.targetId||""}).filter(Boolean);r.set(p.id,i);}});let o=r.get(a)||[];r.set(a,[...o,t]);let s=new Set,n=new Set,c=p=>{if(!s.has(p)){s.add(p),n.add(p);let i=r.get(p)||[];for(let u of i){if(!s.has(u)&&c(u))return true;if(n.has(u))return true}}return n.delete(p),false};return c(a)}function wo({currentCardId:e,dependencies:t=[],availableTasks:a,onChange:r,className:o,validateCircular:s=true,onCircularDependencyError:n}){let[c,p]=useState(false),[i,u]=useState(""),[d,g]=useState(t.length>0),[f,C]=useState({top:0,left:0}),[T,m]=useState(null),b=useRef(null),y=useRef(null),l=()=>{if(!y.current)return;let k=y.current.getBoundingClientRect(),O=window.innerHeight,A=window.innerWidth,N=300,H=d?380:120,L=4,q=k.right-N;q<10&&(q=k.left),q+N>A-10&&(q=A-N-10);let ae=O-k.bottom,ke=k.top,Fe;ae>=H+L?Fe=k.bottom+L:ke>=H+L?Fe=k.top-H-L:Fe=ae>=ke?k.bottom+L:Math.max(10,k.top-H-L),C({top:Fe,left:q}),p(true);};useEffect(()=>{if(!c||!y.current)return;let k=y.current.getBoundingClientRect(),O=window.innerHeight,A=window.innerWidth,N=300,H=d?380:120,L=4,q=k.right-N;q<10&&(q=k.left),q+N>A-10&&(q=A-N-10);let ae=O-k.bottom,ke=k.top,Fe;ae>=H+L?Fe=k.bottom+L:ke>=H+L?Fe=k.top-H-L:Fe=ae>=ke?k.bottom+L:Math.max(10,k.top-H-L),C({top:Fe,left:q});},[d,c]),useEffect(()=>{let k=O=>{b.current&&!b.current.contains(O.target)&&!y.current?.contains(O.target)&&(p(false),u(""));};if(c)return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[c]),useEffect(()=>{let k=O=>{O.key==="Escape"&&(p(false),u(""));};if(c)return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[c]);let w=k=>{let O=t.includes(k),A=a.find(N=>N.id===k);if(m(null),O){let N=t.filter(H=>H!==k);r(N),N.length===0&&g(false);}else {if(s&&en(a,k,e)){let H=`Cannot add "${A?.title||k}" as dependency - would create circular reference`;m(H),n?.(k,A?.title||k),setTimeout(()=>m(null),3e3);return}r([...t,k]),g(true);}},v=()=>{let k=!d;g(k),k||r([]);},S=a.filter(k=>k.id!==e).filter(k=>k.title.toLowerCase().includes(i.toLowerCase())||k.id.toLowerCase().includes(i.toLowerCase())),x=t.length>0?"#3B82F6":"#BDC3C7";return jsxs("div",{className:`relative ${o||""}`,children:[jsxs("button",{ref:y,onClick:()=>c?p(false):l(),className:"flex items-center gap-1 px-2 py-1 rounded transition-all hover:bg-white/5",title:t.length>0?`${t.length} dependencies`:"Add dependencies",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M7 9L9 7M11.5 3.5L10 2C8.89543 0.89543 7.10457 0.89543 6 2C4.89543 3.10457 4.89543 4.89543 6 6L7.5 7.5M4.5 12.5L6 14C7.10457 15.1046 8.89543 15.1046 10 14C11.1046 12.8954 11.1046 11.1046 10 10L8.5 8.5",stroke:x,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),t.length>0&&jsx("span",{className:"text-xs font-medium",style:{color:x},children:t.length})]}),c&&jsx(ut,{children:jsxs("div",{ref:b,className:"dependencies-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${f.top}px`,left:`${f.left}px`,maxHeight:"calc(100vh - 40px)",overflow:"hidden",display:"flex",flexDirection:"column",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:[T&&jsxs("div",{className:"px-4 py-3 flex items-center gap-2",style:{background:"rgba(239, 68, 68, 0.15)",borderBottom:"1px solid rgba(239, 68, 68, 0.3)"},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M8 5V8M8 11H8.01M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8Z",stroke:"#ef4444",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"text-xs font-medium",style:{color:"#ef4444"},children:T})]}),jsx("div",{className:"px-4 py-2 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.05))"},children:jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.7))"},children:"Task Dependencies"})}),jsx("div",{className:"px-4 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.05))"},children:jsxs("label",{className:"flex items-center gap-2 cursor-pointer group",onClick:v,children:[jsx("div",{className:"w-4 h-4 rounded border-2 flex items-center justify-center transition-all",style:{background:d?"#3b82f6":"transparent",borderColor:d?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:d&&jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M2 6L5 9L10 3",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{className:"text-sm font-medium",style:{color:"var(--modal-v2-text-primary, rgba(255, 255, 255, 0.8))"},children:"Has dependencies"})]})}),d&&jsxs(Fragment,{children:[jsx("div",{className:"px-3 py-2 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.05))"},children:jsx("input",{type:"text",value:i,onChange:k=>u(k.target.value),placeholder:"Search by name or ID...",className:"w-full px-3 py-2 rounded-md text-xs border outline-none transition-all",style:{background:"var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))",borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))",color:"var(--modal-v2-text-primary, #ffffff)"},autoFocus:true})}),jsx("div",{className:"py-2 max-h-[280px] overflow-y-auto",children:S.length===0?jsx("div",{className:"px-4 py-3 text-xs text-center",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:"No tasks found"}):S.map(k=>{let O=t.includes(k.id);return jsxs("button",{onClick:()=>w(k.id),className:"w-full px-4 py-2 flex items-start gap-3 text-sm transition-colors",style:{background:"transparent"},onMouseEnter:A=>{A.currentTarget.style.background="var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))";},onMouseLeave:A=>{A.currentTarget.style.background="transparent";},children:[jsx("div",{className:"w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0 mt-0.5 transition-all",style:{background:O?"#3b82f6":"transparent",borderColor:O?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:O&&jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M2 6L5 9L10 3",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxs("div",{className:"flex-1 text-left",children:[jsx("div",{className:"font-medium",style:{color:"var(--modal-v2-text-primary, rgba(255, 255, 255, 0.9))"},children:k.title}),jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:k.id})]})]},k.id)})})]}),t.length>0&&jsx("div",{className:"px-3 py-2 border-t border-white/5",children:jsx("button",{onClick:()=>{r([]),g(false),p(false);},className:"w-full px-3 py-2 rounded-md text-xs font-medium transition-all hover:bg-red-600/20 border border-red-500/30",style:{color:"#E74C3C"},children:"Clear All Dependencies"})})]})})]})}var dr=memo(({card:e,render:t,onClick:a,isSelected:r,disableDrag:o,className:s,onUpdate:n,availableUsers:c=[],allCards:p=[]})=>{let{attributes:i,listeners:u,setNodeRef:d,transform:g,transition:f,isDragging:C}=useSortable({id:e.id,disabled:o,data:{type:"card",card:e}}),T={transform:Xo.Transform.toString(g),transition:f};if(t)return jsx("div",{ref:d,style:T,...i,...u,onClick:()=>a?.(e),children:t(e)});let m=c.filter(w=>e.assignedUserIds?.includes(w.id)),b=e.progress===100,y=(e.attachments||[]).filter(w=>w.type.startsWith("image/")),l={...T,...e.color&&{borderTopWidth:"3px",borderTopStyle:"solid",borderTopColor:e.color}};return jsxs("div",{ref:d,style:l,className:h("asakaa-card",C&&"asakaa-card-dragging",r&&"ring-2 ring-asakaa-accent-blue",s),...i,...u,onClick:w=>{w.target.closest(".priority-selector, .date-picker, .user-selector, .dependencies-selector")||a?.(e);},children:[e.coverImage&&jsx("div",{className:"asakaa-card-cover mb-3",children:jsx("img",{src:e.coverImage,alt:`Cover for ${e.title}`,className:"w-full h-32 object-cover rounded-md",loading:"lazy",onError:w=>{w.currentTarget.style.display="none";}})}),y.length>0&&!e.coverImage&&jsx("div",{className:"asakaa-card-attachments mb-3",children:y.length===1&&y[0]?jsx("img",{src:y[0].url,alt:y[0].name,className:"w-full h-32 object-cover rounded-md",loading:"lazy",decoding:"async",style:{imageRendering:"auto",WebkitBackfaceVisibility:"hidden",backfaceVisibility:"hidden",transform:"translateZ(0)"},onError:w=>{w.currentTarget.style.display="none";}}):jsx("div",{className:"grid grid-cols-2 gap-1",children:y.slice(0,4).map((w,v)=>jsxs("div",{className:"relative",children:[jsx("img",{src:w.url,alt:w.name,className:"w-full h-16 object-cover rounded",loading:"lazy",decoding:"async",style:{imageRendering:"auto",WebkitBackfaceVisibility:"hidden",backfaceVisibility:"hidden",transform:"translateZ(0)"},onError:S=>{S.currentTarget.style.display="none";}}),v===3&&y.length>4&&jsx("div",{className:"absolute inset-0 bg-black/60 rounded flex items-center justify-center",children:jsxs("span",{className:"text-white text-sm font-medium",children:["+",y.length-4]})})]},w.id))})}),jsx("h3",{className:"asakaa-card-title mb-2",style:{textDecoration:b?"line-through":"none",opacity:b?.6:1},children:e.title}),e.description&&jsx("p",{className:"asakaa-card-description mb-3",children:e.description}),jsxs("div",{className:"flex items-center gap-3 mb-3 pt-1",children:[jsx("div",{onClick:w=>w.stopPropagation(),className:"priority-selector",children:jsx(Lr,{priority:e.priority,onChange:w=>n?.(e.id,{priority:w})})}),jsx("div",{onClick:w=>w.stopPropagation(),className:"date-picker",children:jsx(xo,{startDate:e.startDate?typeof e.startDate=="string"?e.startDate:e.startDate.toISOString().split("T")[0]:void 0,endDate:e.endDate?typeof e.endDate=="string"?e.endDate:e.endDate.toISOString().split("T")[0]:void 0,onChange:(w,v)=>n?.(e.id,{startDate:w,endDate:v})})}),c.length>0&&jsx("div",{onClick:w=>w.stopPropagation(),className:"user-selector",children:jsx(Rr,{assignedUsers:m,availableUsers:c,onChange:w=>n?.(e.id,{assignedUserIds:w.map(v=>v.id)})})}),jsx("div",{onClick:w=>w.stopPropagation(),className:"dependencies-selector",children:jsx(wo,{currentCardId:e.id,dependencies:Array.isArray(e.dependencies)?e.dependencies.map(w=>typeof w=="string"?w:w.taskId):[],availableTasks:p,onChange:w=>n?.(e.id,{dependencies:w})})})]}),e.labels&&e.labels.length>0&&jsx("div",{className:"flex flex-wrap gap-1",children:e.labels.slice(0,3).map(w=>jsx("span",{className:"asakaa-label",children:w},w))}),typeof e.progress=="number"&&jsxs("div",{className:"mt-3 pt-2 border-t border-white/5",children:[jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsx("span",{className:"text-[10px] text-[#6B7280]",children:"Progreso"}),jsxs("span",{className:"text-[10px] font-medium",style:{color:"#3B82F6"},children:[Math.round(e.progress),"%"]})]}),jsx("div",{className:"h-1.5 rounded-full bg-white/5 overflow-hidden",children:jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,e.progress))}%`,backgroundColor:"#3B82F6"}})})]})]})},(e,t)=>e.card.id===t.card.id&&e.card.title===t.card.title&&e.card.description===t.card.description&&e.card.position===t.card.position&&e.card.columnId===t.card.columnId&&e.card.priority===t.card.priority&&e.card.color===t.card.color&&e.card.progress===t.card.progress&&e.card.startDate===t.card.startDate&&e.card.endDate===t.card.endDate&&e.isSelected===t.isSelected&&JSON.stringify(e.card.labels)===JSON.stringify(t.card.labels)&&JSON.stringify(e.card.assignedUserIds)===JSON.stringify(t.card.assignedUserIds)&&JSON.stringify(e.card.dependencies)===JSON.stringify(t.card.dependencies)&&JSON.stringify(e.card.attachments?.map(a=>a.id))===JSON.stringify(t.card.attachments?.map(a=>a.id)));dr.displayName="Card";var tn={todo:{label:"To Do",color:"#94a3b8",icon:"circle"},"in-progress":{label:"In Progress",color:"#60a5fa",icon:"circle-dot"},completed:{label:"Completed",color:"#34d399",icon:"check-circle"}},Wl=({icon:e,color:t})=>e==="circle"?jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("circle",{cx:"8",cy:"8",r:"6",stroke:t,strokeWidth:"1.5",fill:"none"})}):e==="circle-dot"?jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:t,strokeWidth:"1.5",fill:"none"}),jsx("circle",{cx:"8",cy:"8",r:"3",fill:t})]}):jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:t,strokeWidth:"1.5",fill:t,fillOpacity:"0.2"}),jsx("path",{d:"M5 8L7 10L11 6",stroke:t,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});function Gl({status:e="todo",onChange:t,className:a,customStatuses:r=[]}){let[o,s]=useState(false),[n,c]=useState({top:0,left:0}),p=useRef(null),i=useRef(null),u=[...Object.entries(tn).map(([m,b])=>({id:m,label:b.label,color:b.color,icon:b.icon})),...r.filter(m=>!Object.keys(tn).includes(m.id)).map(m=>({id:m.id,label:m.title,color:m.color||"#8B5CF6",icon:"circle-dot"}))],d=()=>{let m=tn[e];if(m)return {...m,id:e};let b=r.find(y=>y.id===e);return b?{id:b.id,label:b.title,color:b.color||"#8B5CF6",icon:"circle-dot"}:{...tn.todo,id:"todo"}},g=()=>{if(!i.current)return;let m=i.current.getBoundingClientRect(),b=window.innerHeight,y=window.innerWidth,l=180,w=280,v=4,S=m.right-l;S<10&&(S=m.left),S+l>y-10&&(S=y-l-10);let x=b-m.bottom,k=m.top,O;x>=w+v?O=m.bottom+v:k>=w+v?O=m.top-w-v:O=x>=k?m.bottom+v:Math.max(10,m.top-w-v),c({top:O,left:S}),s(true);};useEffect(()=>{let m=b=>{p.current&&!p.current.contains(b.target)&&!i.current?.contains(b.target)&&s(false);};if(o)return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[o]),useEffect(()=>{let m=b=>{b.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[o]);let f=m=>{t(m),s(false);},C=d(),T=C.color;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:i,onClick:()=>o?s(false):g(),className:"flex items-center justify-center w-8 h-8 rounded-lg transition-all hover:bg-white/15 hover:scale-110 active:scale-95",style:{background:`${T}10`,boxShadow:`0 0 0 2px ${T}30 inset`},title:C.label,children:jsx(Wl,{icon:C.icon,color:T})}),o&&jsx(ut,{children:jsxs("div",{ref:p,className:"status-selector-menu",style:{position:"fixed",top:`${n.top}px`,left:`${n.left}px`,zIndex:99999,minWidth:"180px",maxHeight:"calc(100vh - 40px)",overflowY:"auto",borderRadius:"8px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},children:[jsx("div",{className:"px-3 py-1.5 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.7))"},children:"Status"})}),jsx("div",{className:"py-1",children:u.map(m=>jsxs("button",{onClick:()=>f(m.id),className:"w-full px-3 py-2 flex items-center gap-2.5 text-sm font-medium transition-all active:scale-[0.98] status-option",style:{color:m.color,background:"transparent"},onMouseEnter:b=>{b.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:b=>{b.currentTarget.style.background="transparent";},children:[jsx(Wl,{icon:m.icon,color:m.color}),jsx("span",{className:"font-semibold",children:m.label}),e===m.id&&jsx("svg",{className:"ml-auto",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"#3B82F6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]},m.id))})]})})]})}function _l({columnTitle:e,onRename:t,onDelete:a,isDeletable:r=false,className:o}){let[s,n]=useState(false),[c,p]=useState(false),[i,u]=useState(e),[d,g]=useState({top:0,left:0}),f=useRef(null),C=useRef(null),T=useRef(null);useEffect(()=>{if(s&&C.current){let l=C.current.getBoundingClientRect();g({top:l.bottom+window.scrollY+8,left:l.left+window.scrollX});}},[s]),useEffect(()=>{let l=w=>{f.current&&!f.current.contains(w.target)&&!C.current?.contains(w.target)&&(n(false),p(false));};if(s)return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[s]),useEffect(()=>{let l=w=>{w.key==="Escape"&&(n(false),p(false),u(e));};if(s)return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[s,e]),useEffect(()=>{c&&T.current&&(T.current.focus(),T.current.select());},[c]);let m=()=>{p(true),u(e);},b=()=>{let l=i.trim();l&&l!==e&&t(l),p(false),n(false),u(e);},y=l=>{l.key==="Enter"?b():l.key==="Escape"&&(p(false),u(e));};return jsxs("div",{className:`relative ${o||""}`,children:[jsx("button",{ref:C,onClick:()=>n(!s),className:"opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-white/10",title:"Column options","aria-label":"Column menu",children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"3",r:"1.5",fill:"currentColor"}),jsx("circle",{cx:"8",cy:"8",r:"1.5",fill:"currentColor"}),jsx("circle",{cx:"8",cy:"13",r:"1.5",fill:"currentColor"})]})}),s&&jsx(ut,{children:jsx("div",{ref:f,className:"fixed rounded-xl shadow-2xl border min-w-[200px]",style:{top:`${d.top}px`,left:`${d.left}px`,background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:c?jsxs("div",{className:"p-3",children:[jsx("label",{className:"text-xs font-bold text-white/80 uppercase tracking-wider block mb-2",children:"Rename Column"}),jsx("input",{ref:T,type:"text",value:i,onChange:l=>u(l.target.value),onKeyDown:y,onBlur:b,className:"w-full px-3 py-2 rounded-lg text-sm bg-white/5 border border-white/20 text-white placeholder-white/50 outline-none focus:border-blue-500/50 transition-all",placeholder:"Column name",maxLength:50})]}):jsxs("div",{className:"py-1",children:[jsxs("button",{onClick:m,className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm text-white/90 hover:bg-white/10 transition-all",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M11.5 1.5L14.5 4.5L5 14H2V11L11.5 1.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"font-medium",children:"Rename"})]}),r&&a&&jsxs(Fragment,{children:[jsx("div",{className:"h-px bg-white/10 mx-2 my-1"}),jsxs("button",{onClick:()=>{a(),n(false);},className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm text-red-400 hover:bg-red-500/10 transition-all",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M2 4H14M5 4V2.5C5 2.22386 5.22386 2 5.5 2H10.5C10.7761 2 11 2.22386 11 2.5V4M12.5 4V13.5C12.5 13.7761 12.2761 14 12 14H4C3.72386 14 3.5 13.7761 3.5 13.5V4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M6.5 7V11M9.5 7V11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsx("span",{className:"font-medium",children:"Delete"})]})]})]})})})]})}var ro=memo(({column:e,cards:t,renderColumn:a,renderCard:r,renderHeader:o,renderEmptyState:s,onCardClick:n,onCardUpdate:c,availableUsers:p,allCards:i,enableVirtualization:u,cardHeight:d=120,isCollapsed:g,onToggleCollapse:f,onColumnRename:C,onColumnDelete:T,isDeletable:m=false,className:b})=>{let{setNodeRef:y,isOver:l}=useDroppable({id:e.id,data:{type:"column",column:e}}),w=useRef(null),v=u??hl(t.length),S=useVirtualizer({count:t.length,getScrollElement:()=>w.current,estimateSize:()=>d,enabled:v});if(a)return jsx("div",{ref:y,className:b,children:a(e,t)});let k=(()=>{if(!e.wipLimit)return {state:"none",percentage:0};let N=t.length/e.wipLimit*100;return t.length>e.wipLimit?{state:"exceeded",percentage:N}:N>=80?{state:"warning",percentage:N}:N>=60?{state:"approaching",percentage:N}:{state:"ok",percentage:N}})(),O=k.state==="exceeded",A=()=>"asakaa-column-count";return jsxs("div",{ref:y,className:h("asakaa-column",l&&"ring-2 ring-asakaa-accent-blue",O&&"ring-2 ring-asakaa-accent-red",b),children:[o?o(e,t.length):jsxs("div",{className:"asakaa-column-header group",children:[jsx("h2",{className:"asakaa-column-title",children:e.title}),jsxs("div",{className:"flex items-center gap-2",children:[jsxs("span",{className:h(A()),children:[t.length,e.wipLimit&&` / ${e.wipLimit}`]}),e.wipLimit&&k.state!=="none"&&jsxs("span",{className:"text-xs font-medium flex items-center",title:`${k.percentage.toFixed(0)}% capacity${e.wipLimitType==="hard"?" (Hard limit - blocks new cards)":" (Soft limit - shows warning)"}`,children:[k.state==="exceeded"&&jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"8",cy:"8",r:"7",fill:"#EF4444",opacity:"0.9"}),jsx("path",{d:"M5 5L11 11M11 5L5 11",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}),k.state==="warning"&&jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("path",{d:"M8 1L15 14H1L8 1Z",fill:"#F59E0B",opacity:"0.9"}),jsx("path",{d:"M8 6V9M8 11V11.5",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round"})]}),k.state==="approaching"&&jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M8 1L10 7H14L10 10L12 16L8 12L4 16L6 10L2 7H6L8 1Z",fill:"#FB923C",opacity:"0.9"})}),k.state==="ok"&&jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"8",cy:"8",r:"7",fill:"#10B981",opacity:"0.9"}),jsx("path",{d:"M5 8L7 10L11 6",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]}),(C||T)&&jsx(_l,{columnTitle:e.title,onRename:N=>C?.(e.id,N),onDelete:T?()=>T(e.id):void 0,isDeletable:m}),f&&jsx("button",{onClick:f,className:"text-asakaa-text-tertiary hover:text-asakaa-text-primary","aria-label":g?"Expand column":"Collapse column",children:g?"\u25B6":"\u25BC"})]})]}),!g&&jsx("div",{ref:w,className:"asakaa-column-cards",style:{maxHeight:v?"600px":void 0},children:jsx(SortableContext,{items:t.map(N=>N.id),strategy:verticalListSortingStrategy,children:t.length===0?s?s(e):jsx("div",{className:"asakaa-drop-zone asakaa-empty",children:jsx("p",{children:"Drop cards here"})}):v?jsx("div",{style:{height:`${S.getTotalSize()}px`,position:"relative"},children:S.getVirtualItems().map(N=>{let H=t[N.index];return H?jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${N.start}px)`},children:jsx(dr,{card:H,render:r,onClick:n,onUpdate:c,availableUsers:p,allCards:i})},H.id):null})}):t.map(N=>jsx(dr,{card:N,render:r,onClick:n,onUpdate:c,availableUsers:p,allCards:i},N.id))})})]})});ro.displayName="Column";function ls({title:e,onSave:t,className:a}){let[r,o]=useState(false),[s,n]=useState(e),c=useRef(null);useEffect(()=>{r&&c.current&&(c.current.focus(),c.current.select());},[r]);let p=()=>{let u=s.trim();u&&u!==e?t(u):n(e),o(false);},i=u=>{u.key==="Enter"?p():u.key==="Escape"&&(n(e),o(false));};return r?jsx("input",{ref:c,type:"text",value:s,onChange:u=>n(u.target.value),onBlur:p,onKeyDown:i,className:h("asakaa-column-title bg-transparent border-b-2 border-blue-500","outline-none px-1 -ml-1",a),maxLength:50}):jsx("h2",{className:h("asakaa-column-title cursor-pointer",a),onClick:()=>o(true),title:"Click to edit",children:e})}var nn=["#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#22C55E","#10B981","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899"];function ar({selectedTags:e,availableTags:t,onChange:a,onCreateTag:r,theme:o,disabled:s=false,compact:n=true}){let[c,p]=useState(false),[i,u]=useState(""),[d,g]=useState(false),[f,C]=useState(nn[10]||"#3B82F6"),[T,m]=useState({top:0,left:0}),b=useRef(null),y=useRef(null),l=useRef(null),w=useRef(null),v=t.filter(N=>N.name.toLowerCase().includes(i.toLowerCase())),S=t.some(N=>N.name.toLowerCase()===i.toLowerCase());useEffect(()=>{if(c&&y.current){let N=y.current.getBoundingClientRect();m({top:N.bottom+6,left:N.left});}},[c]),useEffect(()=>{let N=H=>{let L=H.target,q=b.current?.contains(L),ae=l.current?.contains(L);!q&&!ae&&(p(false),u(""),g(false));};if(c)return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[c]),useEffect(()=>{c&&w.current&&w.current.focus();},[c]);let x=N=>{let H=e.some(L=>L.id===N.id);a(H?e.filter(L=>L.id!==N.id):[...e,N]);},k=async()=>{if(!(!r||!i.trim())){g(true);try{let N=await r(i.trim(),f);N&&(a([...e,N]),u(""),C(nn[Math.floor(Math.random()*nn.length)]||"#3B82F6"));}finally{g(false);}}},O=(N,H)=>{H.stopPropagation(),a(e.filter(L=>L.id!==N));},A={backgroundColor:`${o.textTertiary}15`,border:`1px solid ${o.borderLight}`,color:o.textSecondary};return jsxs("div",{ref:b,className:"relative",children:[jsxs("button",{ref:y,type:"button",onClick:()=>!s&&p(!c),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:A,disabled:s,children:[jsx(Tag,{className:"w-3.5 h-3.5"}),e.length>0?jsxs("div",{className:"flex items-center gap-1",children:[e.slice(0,2).map(N=>jsx("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",style:{backgroundColor:`${N.color}20`,color:N.color},children:N.name},N.id)),e.length>2&&jsxs("span",{className:"text-xs",style:{color:o.textTertiary},children:["+",e.length-2]})]}):jsx("span",{children:"Agregar"}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:o.textTertiary}})]}),typeof document<"u"&&createPortal(jsx(AnimatePresence,{children:c&&jsxs(motion.div,{ref:l,initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"rounded-lg min-w-[240px]",style:{position:"fixed",top:T.top,left:T.left,zIndex:99999,backgroundColor:o.bgPrimary,border:`1px solid ${o.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},children:[jsx("div",{className:"p-2 border-b",style:{borderColor:o.border},children:jsx("input",{ref:w,type:"text",value:i,onChange:N=>u(N.target.value),placeholder:"Buscar o crear etiqueta...",className:"w-full px-3 py-1.5 text-sm rounded-md outline-none",style:{backgroundColor:o.bgSecondary,color:o.textPrimary,border:`1px solid ${o.borderLight}`},onKeyDown:N=>{N.key==="Enter"&&i.trim()&&!S&&r&&k();}})}),e.length>0&&jsxs("div",{className:"p-2 border-b",style:{borderColor:o.border},children:[jsx("p",{className:"text-xs mb-1.5",style:{color:o.textTertiary},children:"Seleccionadas"}),jsx("div",{className:"flex flex-wrap gap-1",children:e.map(N=>jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium cursor-pointer hover:opacity-80",style:{backgroundColor:`${N.color}20`,color:N.color},onClick:H=>O(N.id,H),children:[N.name,jsx(X,{className:"w-3 h-3"})]},N.id))})]}),jsx("div",{className:"max-h-[200px] overflow-y-auto p-1",children:v.length>0?v.map(N=>{let H=e.some(L=>L.id===N.id);return jsxs("button",{type:"button",onClick:()=>x(N),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors",style:{backgroundColor:H?`${N.color}15`:"transparent",color:o.textPrimary},onMouseEnter:L=>{H||(L.currentTarget.style.backgroundColor=o.hoverBg);},onMouseLeave:L=>{H||(L.currentTarget.style.backgroundColor="transparent");},children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:N.color}}),jsx("span",{className:"flex-1 text-left",children:N.name}),H&&jsx(Check,{className:"w-4 h-4",style:{color:N.color}})]},N.id)}):i.trim()?jsx("div",{className:"p-2 text-center text-sm",style:{color:o.textTertiary},children:"No se encontraron etiquetas"}):jsx("div",{className:"p-2 text-center text-sm",style:{color:o.textTertiary},children:"No hay etiquetas disponibles"})}),i.trim()&&!S&&r&&jsxs("div",{className:"p-2 border-t",style:{borderColor:o.border},children:[jsx("div",{className:"flex items-center gap-2 mb-2",children:jsx("p",{className:"text-xs",style:{color:o.textTertiary},children:"Crear nueva etiqueta"})}),jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:nn.map(N=>jsx("button",{type:"button",onClick:()=>C(N),className:"w-5 h-5 rounded-full transition-transform hover:scale-110",style:{backgroundColor:N,outline:f===N?`2px solid ${N}`:"none",outlineOffset:"2px"}},N))}),jsxs("button",{type:"button",onClick:k,disabled:d,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition-colors",style:{backgroundColor:f,color:"#FFFFFF",opacity:d?.7:1},children:[d?jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):jsx(Plus,{className:"w-4 h-4"}),'Crear "',i.trim(),'"']})]})]})}),document.body)]})}function cs({tag:e,onRemove:t,size:a="sm"}){return jsxs("span",{className:`inline-flex items-center gap-1 rounded-full font-medium ${a==="xs"?"px-1.5 py-0.5 text-[10px]":"px-2 py-0.5 text-xs"}`,style:{backgroundColor:`${e.color}20`,color:e.color},children:[e.name,t&&jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t();},className:"hover:opacity-70",children:jsx(X,{className:"w-3 h-3"})})]})}function Yl({tags:e,maxVisible:t=3,size:a="sm"}){if(!e||e.length===0)return null;let r=e.slice(0,t),o=e.length-t;return jsxs("div",{className:"flex flex-wrap gap-1",children:[r.map(s=>jsx(cs,{tag:s,size:a},s.id)),o>0&&jsxs("span",{className:`inline-flex items-center rounded-full font-medium ${a==="xs"?"px-1.5 py-0.5 text-[10px]":"px-2 py-0.5 text-xs"}`,style:{backgroundColor:"rgba(100,100,100,0.2)",color:"#9CA3AF"},children:["+",o]})]})}var rr=[{name:"Azul",value:"#6366F1",light:"#818CF8"},{name:"P\xFArpura",value:"#A855F7",light:"#C084FC"},{name:"Rosa",value:"#EC4899",light:"#F472B6"},{name:"Rojo",value:"#EF4444",light:"#F87171"},{name:"Naranja",value:"#F59E0B",light:"#FBBF24"},{name:"Amarillo",value:"#EAB308",light:"#FACC15"},{name:"Lima",value:"#84CC16",light:"#A3E635"},{name:"Verde",value:"#10B981",light:"#34D399"},{name:"Esmeralda",value:"#059669",light:"#10B981"},{name:"Cyan",value:"#06B6D4",light:"#22D3EE"},{name:"Azul Cielo",value:"#0EA5E9",light:"#38BDF8"},{name:"\xCDndigo",value:"#4F46E5",light:"#6366F1"},{name:"Violeta",value:"#8B5CF6",light:"#A78BFA"},{name:"Fucsia",value:"#D946EF",light:"#E879F9"},{name:"Coral",value:"#F97316",light:"#FB923C"},{name:"Magenta",value:"#E11D48",light:"#FB7185"}];function Ql(e,t=[]){if("title"in e&&!("name"in e)){let a=e,r=(a.assignedUserIds||[]).map(o=>{let s=t.find(n=>n.id===o);return s||null}).filter(o=>o!==null);return {id:a.id,name:a.title,startDate:a.startDate?new Date(a.startDate):void 0,endDate:a.endDate?new Date(a.endDate):void 0,progress:a.progress||0,status:a.columnId,priority:a.priority?.toLowerCase(),assignees:r,dependencies:Array.isArray(a.dependencies)?a.dependencies.map(o=>typeof o=="string"?o:o.taskId):[],tags:a.tags,subtasks:a.subtasks?.map(o=>({id:o.id,name:o.title,progress:o.completed?100:0,startDate:new Date,endDate:new Date})),color:a.color,description:a.description}}return e}function eu(e,t){return {...t,title:e.name,startDate:e.startDate,endDate:e.endDate,progress:e.progress,priority:e.priority?.toUpperCase(),tags:e.tags,description:e.description,color:e.color,columnId:e.status,assignedUserIds:t.assignedUserIds}}function Ur({task:e,isOpen:t,onClose:a,onTaskUpdate:r,onCardUpdate:o,theme:s="dark",locale:n="es",availableUsers:c=[],availableTags:p=[],onCreateTag:i,attachments:u=[],onUploadAttachments:d,onDeleteAttachment:g,availableTasks:f=[],comments:C=[],onAddComment:T,currentUser:m}){let b=s==="dark",y={textTertiary:b?"#6B7280":"#9CA3AF",textSecondary:b?"#9CA3AF":"#6B7280",textPrimary:b?"#FFFFFF":"#111827",borderLight:b?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",border:b?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",bgPrimary:b?"#1A1D25":"#FFFFFF",bgSecondary:b?"#0F1117":"#F9FAFB",hoverBg:b?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},l=e&&"title"in e&&!("name"in e),w=e,[v,S]=useState(e?Ql(e,c):null),[x,k]=useState(false),[O,A]=useState(false),[N,H]=useState(false),[L,q]=useState(null),[ae,ke]=useState(new Date),[Fe,Ve]=useState(false),[Je,$]=useState(false),[B,W]=useState(""),[D,Y]=useState(false),[J,R]=useState(false),[ce,we]=useState(false),[Ie,me]=useState(""),He=useRef(null),[Le,Ye]=useState(""),pt=useRef(null),[bt,it]=useState(""),[z,oe]=useState(false);useEffect(()=>{if(e){let E=Ql(e,c);S(E),me(E.description||""),Ye(E.name||"");}},[e?.id,c]),useEffect(()=>()=>{He.current&&clearTimeout(He.current),pt.current&&clearTimeout(pt.current);},[]);let ne=useCallback(E=>{S(E),l&&o&&w?o(eu(E,w)):r&&r(E);},[l,w,o,r]),xe=useCallback(()=>{k(false),A(false),H(false),q(null),$(false),W(""),Y(false);},[]),Ne=useCallback((E,Z)=>{if(!v)return;let be={...v,[E]:Z};ne(be);},[v,ne]),at=useCallback(E=>{me(E),He.current&&clearTimeout(He.current),He.current=setTimeout(()=>{if(v){let Z={...v,description:E};ne(Z);}},800);},[v,ne]),ft=useCallback(E=>{Ye(E),pt.current&&clearTimeout(pt.current),pt.current=setTimeout(()=>{if(v&&E.trim()){let Z={...v,name:E.trim()};ne(Z);}},800);},[v,ne]),Be=useCallback(async()=>{if(!(!v||!bt.trim()||!T)){oe(true);try{await T(v.id,bt.trim()),it("");}finally{oe(false);}}},[v,bt,T]),he=useCallback(E=>{let Z=typeof E=="string"?new Date(E):E,Te=new Date().getTime()-Z.getTime(),qe=Math.floor(Te/6e4),We=Math.floor(Te/36e5),Ee=Math.floor(Te/864e5);return qe<1?n==="es"?"Ahora":"Just now":qe<60?n==="es"?`Hace ${qe} min`:`${qe}m ago`:We<24?n==="es"?`Hace ${We}h`:`${We}h ago`:Ee<7?n==="es"?`Hace ${Ee}d`:`${Ee}d ago`:Z.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})},[n]),Pe=useCallback(E=>{if(!v)return;let Z=v.progress||0;E==="completed"?Z=100:E==="in-progress"&&Z===0?Z=10:E==="todo"&&(Z=0);let be={...v,status:E,progress:Z};ne(be),k(false);},[v,ne]),Mt=useCallback((E,Z)=>{if(!v)return;let be={...v,startDate:E,endDate:Z};ne(be);},[v,ne]),ht=useCallback(()=>{let E=ae.getFullYear(),Z=ae.getMonth(),be=new Date(E,Z,1),qe=new Date(E,Z+1,0).getDate(),We=be.getDay(),Ee=[],rt=new Date(E,Z,0).getDate();for(let V=We-1;V>=0;V--)Ee.push({date:new Date(E,Z-1,rt-V),isCurrentMonth:false});for(let V=1;V<=qe;V++)Ee.push({date:new Date(E,Z,V),isCurrentMonth:true});let st=42-Ee.length;for(let V=1;V<=st;V++)Ee.push({date:new Date(E,Z+1,V),isCurrentMonth:false});return Ee},[ae]),oa=useCallback(async E=>{if(E.preventDefault(),E.stopPropagation(),R(false),!v||!d)return;let Z=Array.from(E.dataTransfer.files);if(Z.length!==0){we(true);try{await d(v.id,Z);}finally{we(false);}}},[v,d]),ma=useCallback(async E=>{if(!v||!d||!E.target.files)return;let Z=Array.from(E.target.files);if(Z.length!==0){we(true);try{await d(v.id,Z);}finally{we(false);}E.target.value="";}},[v,d]),Ue=useCallback(E=>{E.preventDefault(),E.stopPropagation(),R(true);},[]),Oe=useCallback(E=>{E.preventDefault(),E.stopPropagation(),R(false);},[]),na=useCallback(E=>E<1024?`${E} B`:E<1024*1024?`${(E/1024).toFixed(1)} KB`:`${(E/(1024*1024)).toFixed(1)} MB`,[]),ge=useCallback(E=>E.startsWith("image/")?Image:E.includes("pdf")||E.includes("document")?FileText:File,[]);return !t||!v?null:jsx(AnimatePresence,{children:t&&v&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:a,className:"fixed inset-0 bg-black/50 z-40"}),jsxs(motion.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},className:h("fixed inset-4 md:inset-8 lg:inset-12 rounded-xl shadow-2xl z-50 flex overflow-hidden",b?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[jsxs("div",{className:h("px-6 py-3 border-b flex items-center gap-3",b?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:h("w-4 h-4",b?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:h("text-xs px-2 py-0.5 rounded",b?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[n==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:h("text-xs font-mono",b?"text-[#6B7280]":"text-gray-400"),children:v.id.slice(0,8)}),jsxs("button",{className:h("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-colors",b?"bg-purple-500/20 text-purple-400 hover:bg-purple-500/30":"bg-purple-100 text-purple-700 hover:bg-purple-200"),children:[jsx(Sparkles,{className:"w-3 h-3"}),"Ask AI"]})]}),jsx("div",{className:"flex-1"}),jsx("button",{className:h("p-1.5 rounded transition-colors",b?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Maximize2,{className:"w-4 h-4"})}),jsx("button",{className:h("p-1.5 rounded transition-colors",b?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(MoreHorizontal,{className:"w-5 h-5"})}),jsx("button",{onClick:a,className:h("p-1.5 rounded transition-colors",b?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(X,{className:"w-5 h-5"})})]}),jsx("div",{className:"px-6 py-4",children:jsxs("div",{className:"flex items-start gap-3",children:[jsx("button",{onClick:()=>{let E=v.progress===100?0:100,be={...v,progress:E,status:E===100?"completed":"todo"};ne(be);},className:h("mt-2 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors flex-shrink-0",v.progress===100?"bg-green-500 border-green-500":b?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:v.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("input",{type:"text",value:Le,onChange:E=>ft(E.target.value),placeholder:n==="es"?"Nombre de la tarea...":"Task name...",className:h("text-xl font-semibold flex-1 bg-transparent outline-none border-none px-0 py-0","focus:ring-0 focus:outline-none",v.progress===100?"line-through text-[#6B7280]":b?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400")})]})}),jsxs("div",{className:"px-6 pb-6 flex-1 overflow-y-auto overflow-x-visible",children:[jsxs("div",{className:"grid grid-cols-2 gap-x-12 gap-y-5",children:[jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CheckCircle2,{className:h("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{xe(),k(!x);},className:h("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",v.progress===100||v.status==="completed"?"bg-green-500/20 text-green-400":v.progress&&v.progress>0||v.status==="in-progress"?"bg-blue-500/20 text-blue-400":b?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:v.progress===100||v.status==="completed"?n==="es"?"COMPLETADO":"DONE":v.progress&&v.progress>0||v.status==="in-progress"?n==="es"?"EN PROGRESO":"IN PROGRESS":n==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:x&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>k(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:h("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",b?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"todo",label:n==="es"?"Por hacer":"To Do",color:"bg-gray-400"},{id:"in-progress",label:n==="es"?"En progreso":"In Progress",color:"bg-blue-500"},{id:"completed",label:n==="es"?"Completado":"Done",color:"bg-green-500"}].map(E=>jsxs("button",{onClick:()=>Pe(E.id),className:h("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",b?"hover:bg-white/5":"hover:bg-gray-50",v.status===E.id&&(b?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:h("w-2 h-2 rounded-full",E.color)}),jsx("span",{className:b?"text-white":"text-gray-900",children:E.label})]},E.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(User,{className:h("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{xe(),H(!N);},className:h("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",b?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[v.assignees&&v.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[v.assignees.slice(0,3).map((E,Z)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:E.color||"#8B5CF6"},title:E.name,children:E.initials||E.name.slice(0,2).toUpperCase()},Z)),v.assignees.length>3&&jsxs("span",{className:h("text-xs",b?"text-[#6B7280]":"text-gray-400"),children:["+",v.assignees.length-3]})]}):jsx("span",{className:h("text-sm",b?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Agregar":"Add"}),jsx(ChevronDown,{className:h("w-3 h-3",b?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:N&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>H(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:h("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[200px] max-h-[280px] overflow-y-auto",b?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:c.length>0?c.map(E=>{let Z=v.assignees?.some(be=>be.name===E.name);return jsxs("button",{onClick:()=>{let be=v.assignees||[],Te;Z?Te=be.filter(qe=>qe.name!==E.name):Te=[...be,E],Ne("assignees",Te);},className:h("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",b?"hover:bg-white/5":"hover:bg-gray-50",Z&&(b?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:E.color||"#8B5CF6"},children:E.initials||E.name.slice(0,2).toUpperCase()}),jsx("span",{className:h("flex-1",b?"text-white":"text-gray-900"),children:E.name}),Z&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},E.name)}):jsx("div",{className:h("px-3 py-4 text-sm text-center",b?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"No hay usuarios disponibles":"No users available"})})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CalendarDays,{className:h("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{q(L?null:"start"),ke(v.startDate||new Date);},className:h("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",b?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[v.startDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Inicio":"Start"),jsx("span",{className:h("mx-1",b?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),v.endDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Fin":"End")]}),jsx(AnimatePresence,{children:L&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>q(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:h("absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",b?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:E=>E.stopPropagation(),children:[jsxs("div",{className:h("w-44 py-2 border-r",b?"border-white/10":"border-gray-200"),children:[(()=>{let E=new Date,Z=new Date(E);Z.setDate(E.getDate()+1);let be=new Date(E);be.setDate(E.getDate()+((6-E.getDay()+7)%7||7));let Te=new Date(E);Te.setDate(E.getDate()+((1-E.getDay()+7)%7||7));let qe=new Date(E);qe.setDate(E.getDate()+(6-E.getDay()+7)%7+7);let We=new Date(E);We.setDate(E.getDate()+14);let Ee=new Date(E);return Ee.setDate(E.getDate()+28),[{label:n==="es"?"Hoy":"Today",date:E,display:E.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Ma\xF1ana":"Tomorrow",date:Z,display:Z.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Este fin de semana":"This weekend",date:be,display:n==="es"?"s\xE1b.":"sat."},{label:n==="es"?"Pr\xF3xima semana":"Next week",date:Te,display:n==="es"?"lun.":"mon."},{label:n==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:qe,display:qe.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"2 semanas":"2 weeks",date:We,display:We.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:Ee,display:Ee.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((st,V)=>jsxs("button",{className:h("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",b?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if(L==="start"){let re=v.endDate&&st.date>v.endDate?st.date:v.endDate;Mt(st.date,re),q("end");}else {let re=v.startDate&&st.date<v.startDate?st.date:v.startDate;Mt(re,st.date),q(null);}},children:[jsx("span",{children:st.label}),jsx("span",{className:h("text-xs",b?"text-[#6B7280]":"text-gray-400"),children:st.display})]},V))})(),jsx("div",{className:h("border-t mt-2 pt-2",b?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{Mt(void 0,void 0),q(null);},className:h("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",b?"hover:bg-white/5 text-red-400":"hover:bg-gray-50 text-red-500"),children:[jsx("span",{children:n==="es"?"Quitar fechas":"Clear dates"}),jsx(X,{className:"w-4 h-4 opacity-50"})]})})]}),jsxs("div",{className:"p-4",children:[jsx("div",{className:h("text-xs mb-3 px-2 py-1 rounded",b?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:L==="start"?n==="es"?"\u{1F4C5} Selecciona fecha de inicio":"\u{1F4C5} Select start date":n==="es"?"\u{1F4C5} Selecciona fecha de fin":"\u{1F4C5} Select end date"}),jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsx("span",{className:h("font-medium",b?"text-white":"text-gray-900"),children:ae.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>ke(new Date),className:h("p-1 rounded text-sm transition-colors",b?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>ke(new Date(ae.getFullYear(),ae.getMonth()-1)),className:h("p-1 rounded",b?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),jsx("button",{onClick:()=>ke(new Date(ae.getFullYear(),ae.getMonth()+1)),className:h("p-1 rounded",b?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:(n==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(E=>jsx("div",{className:h("w-8 h-8 flex items-center justify-center text-xs",b?"text-[#6B7280]":"text-gray-400"),children:E},E))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:ht().map((E,Z)=>{let be=E.date.toDateString()===new Date().toDateString(),Te=v.startDate?.toDateString()===E.date.toDateString(),qe=v.endDate?.toDateString()===E.date.toDateString(),We=Te||qe,Ee=v.startDate&&v.endDate&&E.date>=v.startDate&&E.date<=v.endDate;return jsx("button",{onClick:()=>{let rt=new Date(E.date);if(L==="start"){let st=v.endDate&&rt>v.endDate?rt:v.endDate;Mt(rt,st),q("end");}else {let st=v.startDate&&rt<v.startDate?rt:v.startDate;Mt(st,rt),q(null);}},className:h("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!E.isCurrentMonth&&(b?"text-[#4B5563]":"text-gray-300"),E.isCurrentMonth&&(b?"text-white":"text-gray-900"),be&&"ring-2 ring-[#3B82F6]",Te&&"bg-[#3B82F6] text-white",qe&&!Te&&"bg-[#7C3AED] text-white",Ee&&!We&&(b?"bg-[#7C3AED]/20":"bg-purple-100"),!We&&(b?"hover:bg-white/10":"hover:bg-gray-100")),children:E.date.getDate()},Z)})})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:h("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{xe(),A(!O);},className:h("text-xs px-2 py-1 rounded font-medium transition-all hover:ring-2 hover:ring-white/20",v.priority==="high"||v.priority==="urgent"?"bg-red-500/20 text-red-400":v.priority==="medium"?"bg-yellow-500/20 text-yellow-400":v.priority==="low"?"bg-green-500/20 text-green-400":b?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:v.priority?v.priority==="high"||v.priority==="urgent"?n==="es"?"Alta":"High":v.priority==="medium"?n==="es"?"Media":"Medium":n==="es"?"Baja":"Low":n==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:O&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>A(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:h("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",b?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"urgent",label:n==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:n==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:n==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:n==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:n==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(E=>jsxs("button",{onClick:()=>{Ne("priority",E.id),A(false);},className:h("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",b?"hover:bg-white/5":"hover:bg-gray-50",v.priority===E.id&&(b?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:h("w-2 h-2 rounded-full",E.color)}),jsx("span",{className:b?"text-white":"text-gray-900",children:E.label})]},E.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:h("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:h("text-sm",b?"text-white":"text-gray-900"),children:v.startDate&&v.endDate?`${Math.ceil((v.endDate.getTime()-v.startDate.getTime())/(1e3*60*60*24))} ${n==="es"?"d\xEDas":"days"}`:n==="es"?"Sin definir":"Not set"})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:h("w-4 h-4 rounded-full border-2",b?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:h("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[Fe?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:v.progress||0,onChange:E=>{let Z=parseInt(E.target.value),be=v.status;Z===100?be="completed":Z>0?be="in-progress":be="todo";let Te={...v,progress:Z,status:be};ne(Te);},onBlur:()=>Ve(false),className:h("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",b?"bg-white/10":"bg-gray-200","[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[#3B82F6] [&::-webkit-slider-thumb]:cursor-pointer"),autoFocus:true}):jsx("button",{onClick:()=>Ve(true),className:h("flex-1 h-2 rounded-full overflow-hidden max-w-[120px] cursor-pointer hover:ring-2 hover:ring-white/20 transition-all",b?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:h("h-full rounded-full transition-all",v.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${v.progress||0}%`}})}),jsxs("span",{className:h("text-sm font-medium min-w-[40px]",b?"text-white":"text-gray-900"),children:[v.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:h("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Etiquetas":"Tags"}),jsx(ar,{selectedTags:v.tags||[],availableTags:p,onChange:E=>{Ne("tags",E);},onCreateTag:i,theme:y})]}),jsxs("div",{className:"flex items-start gap-3 relative",children:[jsx(Link2,{className:h("w-4 h-4 mt-1.5",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24 mt-1",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[v.dependencies&&v.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:v.dependencies.map(E=>{let Z=f.find(be=>be.id===E);return jsxs("span",{className:h("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",b?"bg-blue-500/20 text-blue-400":"bg-blue-100 text-blue-700"),children:[Z?.name||E.slice(0,8),jsx("button",{onClick:()=>{let be=(v.dependencies||[]).filter(Te=>Te!==E);Ne("dependencies",be);},className:h("ml-0.5 hover:bg-white/20 rounded-full p-0.5 transition-colors"),children:jsx(X,{className:"w-3 h-3"})})]},E)})}),jsxs("button",{onClick:()=>{xe(),$(!Je);},className:h("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",b?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{className:h("text-sm",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:Je&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{$(false),W("");}}),jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:h("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[280px] max-h-[320px]",b?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[jsx("div",{className:h("p-2 border-b",b?"border-white/10":"border-gray-200"),children:jsx("input",{type:"text",value:B,onChange:E=>W(E.target.value),placeholder:n==="es"?"Buscar tarea...":"Search task...",className:h("w-full px-3 py-2 rounded-md text-sm outline-none",b?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400"),autoFocus:true})}),jsx("div",{className:"max-h-[240px] overflow-y-auto",children:f.length>0?f.filter(E=>E.id!==v.id).filter(E=>B===""||E.name.toLowerCase().includes(B.toLowerCase())).map(E=>{let Z=v.dependencies?.includes(E.id);return jsxs("button",{onClick:()=>{let be=v.dependencies||[],Te;Z?Te=be.filter(qe=>qe!==E.id):Te=[...be,E.id],Ne("dependencies",Te);},className:h("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",b?"hover:bg-white/5":"hover:bg-gray-50",Z&&(b?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:h("w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0",Z?"bg-blue-500 border-blue-500":b?"border-white/30":"border-gray-300"),children:Z&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("span",{className:h("block truncate",b?"text-white":"text-gray-900"),children:E.name}),jsx("span",{className:h("text-xs",b?"text-[#6B7280]":"text-gray-400"),children:E.id.slice(0,8)})]})]},E.id)}):jsx("div",{className:h("px-3 py-4 text-sm text-center",b?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"No hay tareas disponibles":"No tasks available"})})]})]})})]})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Palette,{className:h("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:"Color"}),jsxs("button",{onClick:()=>{xe(),Y(!D);},className:h("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",b?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx("div",{className:"w-4 h-4 rounded-full",style:{backgroundColor:v.color||"#6366F1"}}),jsx("span",{className:h("text-sm",b?"text-white":"text-gray-900"),children:rr.find(E=>E.value===v.color)?.name||(n==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:h("w-3 h-3",b?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:D&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Y(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:h("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden p-3",b?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:jsx("div",{className:"grid grid-cols-6 gap-1.5",children:rr.map(E=>{let Z=v.color===E.value;return jsx("button",{onClick:()=>{Ne("color",E.value),Y(false);},className:h("w-7 h-7 rounded-full flex items-center justify-center transition-all",Z&&"ring-2 ring-offset-2",b?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:E.value,outlineColor:Z?E.value:void 0},title:E.name,children:Z&&jsx(Check,{className:"w-3.5 h-3.5 text-white"})},E.value)})})})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Diamond,{className:h("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Hito":"Milestone"}),jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:v.isMilestone||false,onChange:E=>Ne("isMilestone",E.target.checked),className:h("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",v.isMilestone?"bg-purple-500 border-purple-500":b?"border-white/30 bg-transparent":"border-gray-300 bg-transparent","checked:bg-purple-500 checked:border-purple-500")}),jsx("span",{className:h("text-sm",b?"text-white":"text-gray-900"),children:n==="es"?"Marcar como hito":"Mark as milestone"})]})]})]}),jsxs("div",{className:h("mt-6 pt-4 border-t",b?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2 mb-3",children:[jsx(FileText,{className:h("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("h3",{className:h("text-sm font-semibold",b?"text-white":"text-gray-900"),children:n==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:Ie,onChange:E=>at(E.target.value),placeholder:n==="es"?"Agregar descripci\xF3n...":"Add description...",className:h("w-full min-h-[100px] px-3 py-2 rounded-lg text-sm resize-none outline-none transition-colors",b?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400 focus:bg-gray-200")}),jsxs("button",{className:h("flex items-center gap-2 text-sm mt-2 transition-colors",b?"text-purple-400 hover:text-purple-300":"text-purple-600 hover:text-purple-700"),children:[jsx(Sparkles,{className:"w-4 h-4"}),n==="es"?"Escribe con IA":"Write with AI"]})]}),jsxs("div",{className:h("mt-6 pt-4 border-t",b?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:h("text-sm font-semibold mb-3",b?"text-white":"text-gray-900"),children:n==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:h("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",b?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),n==="es"?"Crea un campo en esta lista":"Create a field in this list"]})]}),jsxs("div",{className:h("mt-6 pt-4 border-t",b?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:h("text-sm font-semibold mb-3",b?"text-white":"text-gray-900"),children:n==="es"?"Subtareas":"Subtasks"}),v.subtasks&&v.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:v.subtasks.map(E=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:h("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",E.progress===100?"bg-green-500 border-green-500":b?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:E.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:h("text-sm",E.progress===100?"line-through text-[#6B7280]":b?"text-white":"text-gray-900"),children:E.name})]},E.id))}),jsxs("button",{className:h("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",b?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),n==="es"?"Agregar subtarea":"Add subtask"]})]}),jsxs("div",{className:h("mt-6 pt-4 border-t",b?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("h3",{className:h("text-sm font-semibold",b?"text-white":"text-gray-900"),children:n==="es"?"Listas de control":"Checklists"}),jsx("button",{className:h("p-1 rounded transition-colors",b?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Plus,{className:"w-4 h-4"})})]}),jsxs("button",{className:h("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",b?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(ListChecks,{className:"w-4 h-4"}),n==="es"?"Crear lista de control":"Create checklist"]})]}),jsxs("div",{className:h("mt-6 pt-4 border-t",b?"border-white/10":"border-gray-200"),children:[jsxs("h3",{className:h("text-sm font-semibold mb-3",b?"text-white":"text-gray-900"),children:[n==="es"?"Adjuntos":"Attachments",u.length>0&&jsxs("span",{className:h("ml-2 text-xs font-normal",b?"text-[#6B7280]":"text-gray-400"),children:["(",u.length,")"]})]}),u.length>0&&jsx("div",{className:"space-y-2 mb-4",children:u.map(E=>{let Z=ge(E.type),be=E.type.startsWith("image/");return jsxs("div",{className:h("flex items-center gap-3 p-2 rounded-lg group transition-colors",b?"bg-white/5 hover:bg-white/10":"bg-gray-50 hover:bg-gray-100"),children:[be&&E.thumbnailUrl?jsx("img",{src:E.thumbnailUrl,alt:E.name,className:"w-10 h-10 rounded object-cover"}):jsx("div",{className:h("w-10 h-10 rounded flex items-center justify-center",b?"bg-white/10":"bg-gray-200"),children:jsx(Z,{className:h("w-5 h-5",b?"text-[#9CA3AF]":"text-gray-500")})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("a",{href:E.url,target:"_blank",rel:"noopener noreferrer",className:h("text-sm font-medium truncate block hover:underline",b?"text-white":"text-gray-900"),children:E.name}),jsx("p",{className:h("text-xs",b?"text-[#6B7280]":"text-gray-400"),children:na(E.size)})]}),g&&jsx("button",{onClick:()=>g(E.id),className:h("p-1.5 rounded opacity-0 group-hover:opacity-100 transition-all",b?"hover:bg-red-500/20 text-red-400":"hover:bg-red-100 text-red-500"),title:n==="es"?"Eliminar":"Delete",children:jsx(Trash2,{className:"w-4 h-4"})})]},E.id)})}),jsxs("div",{onDragOver:Ue,onDragLeave:Oe,onDrop:oa,className:h("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",J?b?"border-blue-500 bg-blue-500/10":"border-blue-400 bg-blue-50":b?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300",ce&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:ma,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!d||ce}),ce?jsxs(Fragment,{children:[jsx("div",{className:"w-6 h-6 mx-auto mb-2 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"}),jsx("p",{className:h("text-sm",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Subiendo...":"Uploading..."})]}):jsxs(Fragment,{children:[jsx(Upload,{className:h("w-6 h-6 mx-auto mb-2",J?"text-blue-500":b?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:h("text-sm",b?"text-[#9CA3AF]":"text-gray-500"),children:J?n==="es"?"Suelta los archivos aqu\xED":"Drop files here":n==="es"?jsxs(Fragment,{children:["Suelta tus archivos aqu\xED o ",jsx("span",{className:"underline",children:"haz clic para subir"})]}):jsxs(Fragment,{children:["Drop your files here or ",jsx("span",{className:"underline",children:"click to upload"})]})}),!d&&jsx("p",{className:h("text-xs mt-1",b?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Upload no disponible":"Upload not available"})]})]})]})]})]}),jsxs("div",{className:h("w-80 border-l flex flex-col",b?"border-white/10 bg-[#0F1117]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:h("px-4 py-3 border-b",b?"border-white/10":"border-gray-200"),children:jsxs("h3",{className:h("text-sm font-semibold",b?"text-white":"text-gray-900"),children:[n==="es"?"Actividad":"Activity",C.length>0&&jsxs("span",{className:h("ml-2 text-xs font-normal",b?"text-[#6B7280]":"text-gray-400"),children:["(",C.length,")"]})]})}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:C.length>0?jsx("div",{className:"space-y-4",children:C.map(E=>jsxs("div",{className:"flex gap-3",children:[jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:E.user?.color||"#8B5CF6"},children:E.user?.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2 mb-1",children:[jsx("span",{className:h("text-sm font-medium",b?"text-white":"text-gray-900"),children:E.user?.name||(n==="es"?"Usuario":"User")}),jsx("span",{className:h("text-xs",b?"text-[#6B7280]":"text-gray-400"),children:he(E.createdAt)})]}),jsx("p",{className:h("text-sm break-words",b?"text-[#9CA3AF]":"text-gray-600"),children:E.content})]})]},E.id))}):jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[jsx(MessageSquare,{className:h("w-10 h-10 mb-3",b?"text-[#3B4252]":"text-gray-300")}),jsx("p",{className:h("text-sm",b?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"Sin actividad reciente":"No recent activity"})]})}),jsx("div",{className:h("p-4 border-t",b?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-start gap-2",children:[m&&jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:m.color||"#8B5CF6"},children:m.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:h("flex-1 flex items-center gap-2 px-3 py-2 rounded-lg",b?"bg-white/5":"bg-white border border-gray-200"),children:[jsx("input",{type:"text",value:bt,onChange:E=>it(E.target.value),onKeyDown:E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),Be());},placeholder:n==="es"?"Escribe un comentario...":"Write a comment...",disabled:z||!T,className:h("flex-1 bg-transparent text-sm outline-none",b?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400",(z||!T)&&"opacity-50")}),jsx("button",{onClick:Be,disabled:z||!bt.trim()||!T,className:h("p-1.5 rounded transition-colors",bt.trim()&&T?"bg-blue-500 text-white hover:bg-blue-600":b?"text-[#6B7280]":"text-gray-400",z&&"opacity-50 cursor-not-allowed"),children:z?jsx("div",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):jsx(Send,{className:"w-4 h-4"})})]})]})})]})]})]})})}function fs(){let[e,t]=useState(()=>dragStore.getState());useEffect(()=>dragStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{dragStore.setState(r);},[]);return [e,a]}function wr({board:e,callbacks:t,onCardClick:a,renderProps:r,config:o,availableUsers:s=[],className:n,style:c,isLoading:p,error:i,children:u,availableTags:d=[],onCreateTag:g,attachmentsByCard:f,onUploadAttachments:C,onDeleteAttachment:T,comments:m,onAddComment:b,currentUser:y,onTaskOpen:l}){let[w,v]=fs(),[S,x]=useState(null),k=o?.theme||"dark",O=k==="dark"||k==="neutral",A=O?"dark":"",N=useCallback((D,Y)=>{t.onCardUpdate?.(D,Y);},[t]),H=useCallback((D,Y)=>{t.onColumnUpdate?.(D,{title:Y});},[t]),L=useCallback(D=>{t.onColumnDelete?.(D);},[t]),q=["todo","in-progress","completed"],ae=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),ke=useMemo(()=>{let D=new Map;return e.columns.forEach(Y=>{let J=Y.cardIds.map(R=>e.cards.find(ce=>ce.id===R)).filter(R=>R!==void 0).sort((R,ce)=>R.position-ce.position);D.set(Y.id,J);}),D},[e.cards,e.columns]),Fe=useMemo(()=>e.cards.map(D=>({id:D.id,name:D.title,startDate:D.startDate?new Date(D.startDate):void 0,endDate:D.endDate?new Date(D.endDate):void 0,progress:D.progress||0,status:D.columnId,priority:D.priority?.toLowerCase(),dependencies:Array.isArray(D.dependencies)?D.dependencies.map(Y=>typeof Y=="string"?Y:Y.taskId):[]})),[e.cards]),Ve=useCallback(D=>{let{active:Y}=D,J=e.cards.find(R=>R.id===Y.id);J&&v({isDragging:true,draggedCardId:J.id,sourceColumnId:J.columnId,targetColumnId:J.columnId});},[e.cards,v]),Je=useCallback(D=>{let{active:Y,over:J}=D;if(!J||!e.cards.find(we=>we.id===Y.id))return;let ce=null;J.data.current?.type==="column"?ce=J.id:J.data.current?.type==="card"&&(ce=e.cards.find(Ie=>Ie.id===J.id)?.columnId||null),ce&&ce!==w.targetColumnId&&v({...w,targetColumnId:ce});},[e.cards,w,v]),$=useCallback(async D=>{let{active:Y,over:J}=D;if(v({isDragging:false,draggedCardId:null,sourceColumnId:null,targetColumnId:null}),!J)return;let R=e.cards.find(me=>me.id===Y.id);if(!R)return;let ce,we;if(J.data.current?.type==="column"){ce=J.id;let me=ke.get(ce)||[];we=Qn(me,0);}else {let me=e.cards.find(Ye=>Ye.id===J.id);if(!me)return;ce=me.columnId;let He=ke.get(ce)||[],Le=He.findIndex(Ye=>Ye.id===J.id);we=Qn(He,Le);}let Ie=e.columns.find(me=>me.id===ce);if(Ie&&Ie.wipLimit&&Ie.wipLimitType==="hard"){let me=ke.get(ce)||[];if(R.columnId!==ce&&me.length>=Ie.wipLimit){t.onWipLimitExceeded?.(Ie,R);return}}(R.columnId!==ce||R.position!==we)&&await t.onCardMove?.(R.id,ce,we);},[e.cards,e.columns,ke,t,v]),B=useCallback(D=>{x(D),a?.(D),l?.(D.id);},[a,l]),W=useCallback(D=>{t.onCardUpdate?.(D.id,D),x(D);},[t]);return p?jsx("div",{className:h("asakaa-board",A,n),style:c,children:jsx(pu,{columnCount:3})}):i?jsx("div",{className:h("asakaa-board",A,n),style:c,children:jsx("div",{className:"flex items-center justify-center w-full h-64",children:jsxs("div",{className:"text-center",children:[jsx("p",{className:"text-asakaa-accent-red text-lg font-semibold mb-2",children:"Error loading board"}),jsx("p",{className:"text-asakaa-text-secondary text-sm",children:typeof i=="string"?i:i.message})]})})}):jsxs(Sl,{themeName:k,children:[jsxs(DndContext,{sensors:ae,collisionDetection:closestCorners,onDragStart:Ve,onDragOver:Je,onDragEnd:$,children:[jsxs("div",{className:h("asakaa-board",A,n),style:c,"data-theme":k,children:[e.columns.sort((D,Y)=>D.position-Y.position).map(D=>{let Y=ke.get(D.id)||[],J=!q.includes(D.id);return jsx(ro,{column:D,cards:Y,renderCard:r?.renderCard,renderColumn:r?.renderColumn,renderHeader:r?.renderColumnHeader,renderEmptyState:r?.renderEmptyState,onCardClick:B,onCardUpdate:N,onColumnRename:H,onColumnDelete:L,isDeletable:J,availableUsers:s,allCards:e.cards,enableVirtualization:o?.enableVirtualization,cardHeight:o?.cardHeight},D.id)}),u]}),jsx(DragOverlay,{children:w.draggedCardId?jsx(dr,{card:e.cards.find(D=>D.id===w.draggedCardId),render:r?.renderCardOverlay||r?.renderCard,disableDrag:true,className:"opacity-90 rotate-3 shadow-2xl"}):null})]}),jsx(Ur,{task:S,isOpen:!!S,onClose:()=>x(null),onCardUpdate:W,theme:O?"dark":"light",locale:o?.locale==="es"?"es":"en",availableUsers:s,availableTags:d,onCreateTag:g,attachments:S?f?.get(S.id)||[]:[],onUploadAttachments:C,onDeleteAttachment:T,availableTasks:Fe,comments:m,onAddComment:b,currentUser:y})]})}function pu({columnCount:e}){return jsx(Fragment,{children:Array.from({length:e}).map((t,a)=>jsxs("div",{className:"asakaa-column",children:[jsx("div",{className:"asakaa-skeleton h-8 mb-3"}),jsxs("div",{className:"flex flex-col gap-2",children:[jsx("div",{className:"asakaa-skeleton h-24"}),jsx("div",{className:"asakaa-skeleton h-32"}),jsx("div",{className:"asakaa-skeleton h-28"})]})]},a))})}var bu={bgGrid:"#0F1117",bgSecondary:"#1A1D25",border:"rgba(255, 255, 255, 0.1)",borderLight:"rgba(255, 255, 255, 0.05)",textPrimary:"#E5E7EB",textSecondary:"#9CA3AF",textTertiary:"#6B7280",accent:"#3B82F6",accentLight:"rgba(59, 130, 246, 0.15)",hoverBg:"rgba(255, 255, 255, 0.05)"},yu={bgGrid:"#FFFFFF",bgSecondary:"#F9FAFB",border:"rgba(0, 0, 0, 0.1)",borderLight:"rgba(0, 0, 0, 0.05)",textPrimary:"#111827",textSecondary:"#6B7280",textTertiary:"#9CA3AF",accent:"#3B82F6",accentLight:"rgba(59, 130, 246, 0.1)",hoverBg:"rgba(0, 0, 0, 0.05)"},vu={newTask:"Nueva Tarea",selectColumn:"Seleccionar columna",export:"Exportar",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"},xu={newTask:"New Task",selectColumn:"Select column",export:"Export",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"};function ku({columns:e,onSelect:t,theme:a,t:r,createTaskLabel:o}){let[s,n]=useState(false),c=useRef(null);useEffect(()=>{let i=u=>{c.current&&!c.current.contains(u.target)&&n(false);};return s&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[s]);let p=i=>{t(i),n(false);};return jsxs("div",{ref:c,className:"relative",children:[jsxs(motion.button,{onClick:()=>n(!s),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#FFFFFF",fontFamily:"Inter, sans-serif",fontWeight:500,boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"},whileHover:{scale:1.02,boxShadow:"0 4px 12px rgba(59, 130, 246, 0.4)"},whileTap:{scale:.98},children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{children:o||r.newTask}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:s?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:s&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute right-0 mt-2 w-48 rounded-lg overflow-hidden z-50",style:{backgroundColor:a.bgSecondary,border:`1px solid ${a.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsxs("div",{className:"py-1",children:[jsx("div",{className:"px-3 py-2 text-[10px] uppercase tracking-wider",style:{color:a.textTertiary},children:r.selectColumn}),e.sort((i,u)=>i.position-u.position).map((i,u)=>jsxs(motion.button,{onClick:()=>p(i.id),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:u<e.length-1?`1px solid ${a.borderLight}`:"none"},whileHover:{backgroundColor:a.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:u*.03},children:[jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:i.color||a.accent}}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:a.textPrimary},children:i.title}),jsxs("div",{className:"text-[10px] truncate",style:{color:a.textTertiary},children:[i.cardIds.length," ",i.cardIds.length===1?"tarea":"tareas"]})]})]},i.id))]})})})]})}function wu({theme:e,t,onExportCSV:a,onExportJSON:r,onExportExcel:o}){let[s,n]=useState(false),[c,p]=useState(null),i=useRef(null);if(useEffect(()=>{let f=C=>{i.current&&!i.current.contains(C.target)&&n(false);};return s&&document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[s]),!(a||r||o))return null;let d=[{id:"csv",label:t.exportCSV,description:"Comma-separated",icon:jsx(FileText,{className:"w-4 h-4"}),handler:a},{id:"json",label:t.exportJSON,description:"Data",icon:jsx(FileJson,{className:"w-4 h-4"}),handler:r},{id:"excel",label:t.exportExcel,description:"Spreadsheet",icon:jsx(FileSpreadsheet,{className:"w-4 h-4"}),handler:o}].filter(f=>f.handler),g=async(f,C)=>{if(C){p(f);try{await C();}catch(T){console.error(`Export ${f} failed:`,T);}finally{p(null),n(false);}}};return jsxs("div",{ref:i,className:"relative",children:[jsxs(motion.button,{onClick:()=>n(!s),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:s?e.accent:e.bgSecondary,border:`1px solid ${s?e.accent:e.borderLight}`,color:s?"#FFFFFF":e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{scale:1.02,backgroundColor:e.accent,color:"#FFFFFF"},whileTap:{scale:.98},children:[jsx(Download,{className:"w-3.5 h-3.5"}),jsx("span",{children:t.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:s?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:s&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute right-0 mt-2 w-44 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:d.map((f,C)=>jsxs(motion.button,{onClick:()=>g(f.id,f.handler),disabled:c!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:C<d.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:C*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:c===f.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):f.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:f.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:f.description})]})]},f.id))})})})]})}function Cu({onClick:e,label:t}){return jsxs(motion.button,{onClick:e,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#FFFFFF",fontFamily:"Inter, sans-serif",fontWeight:500,boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"},whileHover:{scale:1.02,boxShadow:"0 4px 12px rgba(59, 130, 246, 0.4)"},whileTap:{scale:.98},children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{children:t})]})}function bs({columns:e,onCreateTask:t,createTaskLabel:a,theme:r="dark",locale:o="es",useColumnSelector:s=false,onExportCSV:n,onExportJSON:c,onExportExcel:p,translations:i}){let u=r==="dark"?bu:yu,d={...o==="es"?vu:xu,...i},g=n||c||p;return jsx("div",{className:"h-12 px-4 flex items-center justify-end border-b sticky top-0 z-10",style:{backgroundColor:u.bgGrid,borderColor:u.border},children:jsxs("div",{className:"flex items-center gap-3",children:[g&&jsxs(Fragment,{children:[jsx(wu,{theme:u,t:d,onExportCSV:n,onExportJSON:c,onExportExcel:p}),t&&jsx("div",{className:"w-px h-6",style:{backgroundColor:u.borderLight}})]}),t&&(s?jsx(ku,{columns:e,onSelect:t,theme:u,t:d,createTaskLabel:a}):jsx(Cu,{onClick:()=>t(),label:a||d.newTask}))]})})}function vs({onAddColumn:e,className:t,placeholder:a="Nombre de la columna...",buttonLabel:r="Agregar Columna",disabled:o=false}){let[s,n]=useState(false),[c,p]=useState(""),i=useCallback(()=>{let g=c.trim();g&&(e(g),p(""),n(false));},[c,e]),u=useCallback(g=>{g.key==="Enter"?(g.preventDefault(),i()):g.key==="Escape"&&(p(""),n(false));},[i]),d=useCallback(()=>{setTimeout(()=>{c.trim()||n(false);},150);},[c]);return s?jsx("div",{className:h("asakaa-add-column asakaa-add-column--editing",t),children:jsxs("div",{className:"asakaa-add-column__input-wrapper",children:[jsx("input",{type:"text",value:c,onChange:g=>p(g.target.value),onKeyDown:u,onBlur:d,placeholder:a,autoFocus:true,className:"asakaa-add-column__input"}),jsxs("div",{className:"asakaa-add-column__actions",children:[jsx("button",{onClick:i,disabled:!c.trim(),className:"asakaa-add-column__submit",type:"button",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}),jsx("button",{onClick:()=>{p(""),n(false);},className:"asakaa-add-column__cancel",type:"button",children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})}):jsx("div",{className:h("asakaa-add-column",t),children:jsxs("button",{onClick:()=>n(true),disabled:o,className:"asakaa-add-column__button",type:"button",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),r]})})}function xs({columnId:e,onAddCard:t,availableUsers:a=[],className:r,placeholder:o,buttonLabel:s,disabled:n=false,theme:c="dark",locale:p="es"}){let[i,u]=useState(false),[d,g]=useState(false),[f,C]=useState(""),[T,m]=useState([]),[b,y]=useState(""),[l,w]=useState(""),[v,S]=useState(""),[x,k]=useState(false),[O,A]=useState(false),[N,H]=useState(false),L=useRef(null),q=useRef(null),ae={placeholder:o||(p==="es"?"Nombre de la tarea...":"Task Name..."),buttonLabel:s||(p==="es"?"Agregar Tarea":"Add Task"),save:p==="es"?"Guardar":"Save",addAssignee:p==="es"?"Agregar asignado":"Add assignee",addDates:p==="es"?"Agregar fechas":"Add dates",addPriority:p==="es"?"Agregar prioridad":"Add priority",startDate:p==="es"?"Inicio":"Start",endDate:p==="es"?"Fin":"End",low:p==="es"?"Baja":"Low",medium:p==="es"?"Media":"Medium",high:p==="es"?"Alta":"High",urgent:p==="es"?"Urgente":"Urgent"},ke=useCallback(()=>{C(""),m([]),y(""),w(""),S(""),k(false),A(false),H(false),u(false);},[]);useEffect(()=>{i&&L.current&&L.current.focus();},[i]),useEffect(()=>{if(!i)return;let B=W=>{q.current&&!q.current.contains(W.target)&&(f.trim()||ke());};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[i,f,ke]);let Fe=useCallback(async()=>{let B=f.trim();if(!(!B||d)){g(true);try{await t({name:B,columnId:e,assigneeIds:T.length>0?T:void 0,startDate:b?new Date(b):void 0,endDate:l?new Date(l):void 0,priority:v||void 0}),C(""),m([]),y(""),w(""),S(""),k(!1),A(!1),H(!1),L.current?.focus();}catch(W){console.error("Error creating card:",W);}finally{g(false);}}},[f,e,T,b,l,v,t,d]),Ve=useCallback(B=>{B.key==="Enter"&&!B.shiftKey?(B.preventDefault(),Fe()):B.key==="Escape"&&ke();},[Fe,ke]),Je=useCallback(B=>{m(W=>W.includes(B)?W.filter(D=>D!==B):[...W,B]);},[]),$=c==="dark";return i?jsxs("div",{ref:q,className:h("rounded-lg overflow-hidden shadow-lg",$?"bg-[#1e1e2e]":"bg-white",r),style:{border:"2px solid #10b981"},children:[jsxs("div",{className:"p-3",children:[jsx("input",{ref:L,type:"text",value:f,onChange:B=>C(B.target.value),onKeyDown:Ve,placeholder:ae.placeholder,disabled:d,className:h("w-full px-0 py-1 text-sm font-medium border-0 bg-transparent focus:outline-none focus:ring-0",$?"text-gray-100 placeholder-gray-500":"text-gray-800 placeholder-gray-400")}),jsxs("div",{className:"flex items-center gap-1 mt-3",children:[a.length>0&&jsxs("button",{onClick:()=>k(!x),className:h("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",x||T.length>0?"bg-emerald-500/20 text-emerald-400":$?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:ae.addAssignee,children:[jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),T.length>0&&jsx("span",{className:"ml-0.5",children:T.length})]}),jsx("button",{onClick:()=>A(!O),className:h("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",O||b||l?"bg-blue-500/20 text-blue-400":$?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:ae.addDates,children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})}),jsx("button",{onClick:()=>H(!N),className:h("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",N||v?v==="urgent"?"bg-red-500/20 text-red-400":v==="high"?"bg-orange-500/20 text-orange-400":v==="medium"?"bg-yellow-500/20 text-yellow-400":v==="low"?"bg-green-500/20 text-green-400":"bg-orange-500/20 text-orange-400":$?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:ae.addPriority,children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"}),jsx("line",{x1:"4",y1:"22",x2:"4",y2:"15"})]})}),jsx("div",{className:"flex-1"}),jsx("button",{onClick:Fe,disabled:!f.trim()||d,className:h("px-3 py-1.5 rounded-md text-xs font-medium text-white transition-all","bg-emerald-500 hover:bg-emerald-600","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-emerald-500"),type:"button",children:d?jsx("div",{className:"w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin"}):ae.save})]})]}),x&&a.length>0&&jsx("div",{className:h("px-3 pb-3 pt-0","border-t",$?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex flex-wrap gap-1.5 pt-3",children:a.map(B=>jsxs("button",{onClick:()=>Je(B.id),className:h("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs transition-all",T.includes(B.id)?"bg-emerald-500 text-white":$?"bg-[#2a2a3e] text-gray-300 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-700 hover:bg-gray-200"),type:"button",children:[B.avatar?jsx("img",{src:B.avatar,alt:B.name,className:"w-4 h-4 rounded-full"}):jsx("div",{className:h("w-4 h-4 rounded-full flex items-center justify-center text-[10px] font-medium",T.includes(B.id)?"bg-emerald-600 text-white":"bg-emerald-500 text-white"),children:B.name.charAt(0).toUpperCase()}),jsx("span",{children:B.name.split(" ")[0]})]},B.id))})}),O&&jsx("div",{className:h("px-3 pb-3 pt-0","border-t",$?"border-[#3a3a4e]":"border-gray-200"),children:jsxs("div",{className:"grid grid-cols-2 gap-2 pt-3",children:[jsxs("div",{children:[jsx("label",{className:h("block text-[10px] uppercase tracking-wide mb-1",$?"text-gray-500":"text-gray-400"),children:ae.startDate}),jsx("input",{type:"date",value:b,onChange:B=>y(B.target.value),className:h("w-full px-2 py-1.5 rounded text-xs border",$?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]}),jsxs("div",{children:[jsx("label",{className:h("block text-[10px] uppercase tracking-wide mb-1",$?"text-gray-500":"text-gray-400"),children:ae.endDate}),jsx("input",{type:"date",value:l,onChange:B=>w(B.target.value),className:h("w-full px-2 py-1.5 rounded text-xs border",$?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]})]})}),N&&jsx("div",{className:h("px-3 pb-3 pt-0","border-t",$?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex gap-1.5 pt-3",children:["low","medium","high","urgent"].map(B=>jsx("button",{onClick:()=>S(v===B?"":B),className:h("flex-1 px-2 py-1.5 rounded text-xs font-medium transition-all",v===B?`${{low:"bg-green-500",medium:"bg-yellow-500",high:"bg-orange-500",urgent:"bg-red-500"}[B]} text-white`:$?"bg-[#2a2a3e] text-gray-400 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-600 hover:bg-gray-200"),type:"button",children:ae[B]},B))})})]}):jsxs("button",{onClick:()=>u(true),disabled:n,className:h("w-full flex items-center gap-2 px-3 py-2 rounded-lg transition-all duration-200","text-emerald-500 hover:text-emerald-400",$?"hover:bg-[#2a2a3e]":"hover:bg-gray-100",n&&"opacity-50 cursor-not-allowed",r),type:"button",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),jsx("span",{className:"text-sm font-medium",children:ae.buttonLabel})]})}var Do=class extends BaseViewAdapter{constructor(a={}){super();this.id="kanban";this.name="Kanban Board";this.version="1.0.0";this.description="";this.icon="";this.supportedExports=["json","csv","pdf","png"];this.root=null;this.description="Interactive Kanban board with drag & drop, filters, and real-time updates",this.icon="\u{1F4CB}",this.kanbanConfig=a,this.options={animations:a.viewOptions?.animations??true,virtualScrolling:a.viewOptions?.virtualScrolling??false,theme:a.viewOptions?.theme??"dark",readonly:a.viewOptions?.readonly??false};}mount(a,r){this.isMounted()&&(console.warn("[KanbanViewAdapter] Already mounted, unmounting first"),this.unmount()),this.container=a,this.data=r,this.root=createRoot(a),this.render(),this.emit("view:mounted",{viewId:this.id,timestamp:Date.now()});}unmount(){this.isMounted()&&(this.emit("view:unmounted",{viewId:this.id,timestamp:Date.now()}),this.root&&(this.root.unmount(),this.root=null),this.container&&(this.container.innerHTML="",this.container=null),this.data=null);}update(a){if(!this.isMounted()){console.warn("[KanbanViewAdapter] Not mounted, cannot update");return}this.data=a,this.render(),this.emit("view:updated",{viewId:this.id,data:a});}configure(a){this.options={...this.options,...a},this.isMounted()&&this.render();}async export(a){if(!this.data)throw new Error("No data to export");switch(a){case "json":return JSON.stringify(this.data,null,2);case "csv":return this.exportToCSV();case "pdf":return this.exportToPDF();case "png":return this.exportToPNG();default:throw new Error(`Unsupported export format: ${a}`)}}render(){if(!this.root||!this.data)return;let a={id:this.data.board?.id||"board-1",title:this.data.board?.title||"Untitled Board",columns:this.data.columns,cards:this.data.cards};this.root.render(jsx(wr,{board:a,callbacks:this.kanbanConfig.callbacks||{},onCardClick:this.kanbanConfig.onCardClick,renderProps:this.kanbanConfig.renderProps,config:this.kanbanConfig.config,availableUsers:this.kanbanConfig.availableUsers,className:this.kanbanConfig.className,style:this.kanbanConfig.style}));}exportToCSV(){if(!this.data)return "";let a=[["Card ID","Title","Column","Description","Labels","Assignees","Due Date","Position"]];return this.data.cards.forEach(r=>{let o=this.data.columns.find(s=>s.id===r.columnId);a.push([r.id,r.title,o?.title||"",r.description||"",r.labels?.join(", ")||"",r.assignedUserIds?.join(", ")||r.assigneeId||"",r.dueDate?.toString()||"",r.position.toString()]);}),a.map(r=>r.map(o=>`"${o}"`).join(",")).join(`
5
- `)}async exportToPDF(){throw new Error("PDF export not yet implemented in ViewAdapter")}async exportToPNG(){if(!this.container)throw new Error("View not mounted");let r=await(await import('html2canvas')).default(this.container,{backgroundColor:this.options.theme==="dark"?"#1a1a1a":"#ffffff",scale:2});return new Promise((o,s)=>{r.toBlob(n=>{n?o(n):s(new Error("Failed to create PNG blob"));},"image/png");})}};function md(e={}){return new Do(e)}var no=class extends Component{constructor(a){super(a);this.resetError=()=>{this.setState({hasError:false,error:null,errorInfo:null});};this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(a){return {hasError:true,error:a}}componentDidCatch(a,r){let{onError:o,componentName:s}=this.props;if(process.env.NODE_ENV==="development"&&(console.error(`Error in ${s||"Component"}:`,a),console.error("Error Info:",r)),this.setState({errorInfo:r}),o)try{o(a,r);}catch(n){console.error("Error in error handler:",n);}}render(){let{hasError:a,error:r}=this.state,{children:o,fallback:s,componentName:n}=this.props;return a&&r?s?s(r,this.resetError):jsx("div",{className:"p-6 rounded-lg border",style:{background:"linear-gradient(135deg, #2d1b1b 0%, #1a1a1a 100%)",borderColor:"rgba(239, 68, 68, 0.3)"},children:jsxs("div",{className:"flex items-start gap-3",children:[jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"#EF4444",strokeWidth:"2"}),jsx("path",{d:"M12 8V12",stroke:"#EF4444",strokeWidth:"2",strokeLinecap:"round"}),jsx("circle",{cx:"12",cy:"16",r:"1",fill:"#EF4444"})]}),jsxs("div",{className:"flex-1",children:[jsx("h3",{className:"text-lg font-semibold text-red-400 mb-1",children:n?`Error in ${n}`:"Something went wrong"}),jsx("p",{className:"text-sm text-white/70 mb-3",children:r.message||"An unexpected error occurred"}),process.env.NODE_ENV==="development"&&jsxs("details",{className:"mb-3",children:[jsx("summary",{className:"text-xs text-white/50 cursor-pointer hover:text-white/70 mb-2",children:"Error Details (Development Only)"}),jsx("pre",{className:"text-xs text-white/60 bg-black/30 p-3 rounded overflow-auto max-h-48",children:r.stack})]}),jsx("button",{onClick:this.resetError,className:"px-4 py-2 rounded-lg text-sm font-medium transition-all hover:bg-red-600/20 border border-red-500/30",style:{color:"#EF4444"},children:"Try Again"})]})]})}):o}};function ks(e,t){let a=r=>jsx(no,{...t,children:jsx(e,{...r})});return a.displayName=`withErrorBoundary(${e.displayName||e.name||"Component"})`,a}function Cs({board:e,onCreateCard:t,onNavigateToCard:a,onSearch:r,onChangePriority:o,onAssignUser:s,onGeneratePlan:n,onPredictRisks:c,onOpenAIUsage:p,shortcut:i="k",className:u=""}){let[d,g]=useState(false),[f,C]=useState(""),[T,m]=useState("home"),[b,y]=useState(""),[l,w]=useState("");useEffect(()=>{let k=O=>{(O.metaKey||O.ctrlKey)&&O.key===i&&(O.preventDefault(),g(A=>!A)),O.key==="Escape"&&(g(false),m("home"),C(""));};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[i]),useEffect(()=>{d||(m("home"),C(""),y(""),w(""));},[d]);let v=useCallback(()=>{g(false);},[]),S=useCallback(k=>{let[O,A]=k.split(":");switch(O){case "create-card":m("create-card");break;case "create-card-in":y(A||"");break;case "navigate":A?(a?.(A),v()):m("navigate");break;case "search":r?.(f),v();break;case "priority":m("priority");break;case "set-priority":l&&A&&(o?.(l,A),v());break;case "assign":m("assign");break;case "assign-user":l&&A&&(s?.(l,A),v());break;case "ai":m("ai");break;case "ai-generate-plan":n?.(),v();break;case "ai-predict-risks":c?.(),v();break;case "ai-usage":p?.(),v();break;case "back":m("home");break;}},[f,l,t,a,r,o,s,n,c,p,v]),x=useCallback(()=>{b&&f.trim()&&(t?.(b,f.trim()),v());},[b,f,t,v]);return d?jsx(ut,{children:jsx("div",{className:"command-palette-overlay",onClick:v,children:jsx("div",{className:`command-palette ${u}`,onClick:k=>k.stopPropagation(),children:jsxs(Command,{value:f,onValueChange:C,label:"Command Menu",children:[jsxs("div",{className:"command-palette-header",children:[jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"11",cy:"11",r:"8"}),jsx("path",{d:"m21 21-4.35-4.35"})]}),jsx(Command.Input,{placeholder:T==="create-card"&&b?"Type card title and press Enter...":T==="create-card"?"Select a column first...":"Type a command or search...",className:"command-palette-input",onKeyDown:k=>{k.key==="Enter"&&T==="create-card"&&b&&x();}}),jsxs("div",{className:"command-palette-shortcut",children:[jsx("kbd",{children:navigator.platform.includes("Mac")?"\u2318":"Ctrl"}),jsx("kbd",{children:"K"})]})]}),jsxs(Command.List,{className:"command-palette-list",children:[jsx(Command.Empty,{className:"command-palette-empty",children:"No results found."}),T==="home"&&jsxs(Fragment,{children:[jsxs(Command.Group,{heading:"Actions",className:"command-palette-group",children:[jsxs(Command.Item,{value:"create-card",onSelect:S,className:"command-palette-item",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsx("path",{d:"M12 8v8m-4-4h8"})]}),jsx("span",{children:"Create Card"}),jsx("div",{className:"command-palette-item-shortcut",children:"C"})]}),jsxs(Command.Item,{value:"navigate",onSelect:S,className:"command-palette-item",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 16 16 12 12 8"}),jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),jsx("span",{children:"Navigate to Card"}),jsx("div",{className:"command-palette-item-shortcut",children:"G"})]}),jsxs(Command.Item,{value:"search",onSelect:S,className:"command-palette-item",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"11",cy:"11",r:"8"}),jsx("path",{d:"m21 21-4.35-4.35"})]}),jsx("span",{children:"Search Cards"}),jsx("div",{className:"command-palette-item-shortcut",children:"/"})]})]}),jsx(Command.Group,{heading:"AI Features",className:"command-palette-group",children:jsxs(Command.Item,{value:"ai",onSelect:S,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),jsx("span",{children:"AI Commands"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]})}),jsx(Command.Group,{heading:"Cards",className:"command-palette-group",children:e.cards.slice(0,5).map(k=>jsxs(Command.Item,{value:`navigate:${k.id}`,onSelect:S,className:"command-palette-item",children:[jsx("div",{className:"command-palette-item-dot",style:{background:k.priority==="URGENT"?"#EF4444":k.priority==="HIGH"?"#F59E0B":k.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:k.title}),k.labels&&k.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:k.labels.slice(0,2).map(O=>jsx("span",{className:"command-palette-item-label",children:O},O))})]},k.id))})]}),T==="create-card"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:S,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),jsx("span",{children:"Back"})]}),jsx(Command.Group,{heading:"Select Column",className:"command-palette-group",children:e.columns.map(k=>jsxs(Command.Item,{value:`create-card-in:${k.id}`,onSelect:S,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("rect",{x:"3",y:"3",width:"7",height:"18",rx:"1"})}),jsx("span",{children:k.title}),jsxs("div",{className:"command-palette-item-count",children:[k.cardIds.length," cards"]})]},k.id))})]}),T==="navigate"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:S,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),jsx("span",{children:"Back"})]}),jsx(Command.Group,{heading:"All Cards",className:"command-palette-group",children:e.cards.map(k=>{let O=e.columns.find(A=>A.id===k.columnId);return jsxs(Command.Item,{value:`navigate:${k.id}`,onSelect:S,className:"command-palette-item",keywords:[k.title,k.description||"",...k.labels||[]],children:[jsx("div",{className:"command-palette-item-dot",style:{background:k.priority==="URGENT"?"#EF4444":k.priority==="HIGH"?"#F59E0B":k.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsxs("div",{className:"command-palette-item-content",children:[jsx("div",{children:k.title}),jsx("div",{className:"command-palette-item-meta",children:O?.title})]}),k.labels&&k.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:k.labels.slice(0,2).map(A=>jsx("span",{className:"command-palette-item-label",children:A},A))})]},k.id)})})]}),T==="ai"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:S,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),jsx("span",{children:"Back"})]}),jsxs(Command.Group,{heading:"AI Features",className:"command-palette-group",children:[jsxs(Command.Item,{value:"ai-generate-plan",onSelect:S,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),jsx("span",{children:"Generate Project Plan"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]}),jsxs(Command.Item,{value:"ai-predict-risks",onSelect:S,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),jsx("span",{children:"Predict Risks"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]}),jsxs(Command.Item,{value:"ai-usage",onSelect:S,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"12",y1:"1",x2:"12",y2:"23"}),jsx("path",{d:"M17 5H9.5a3.5 3.5 0 000 7h5a3.5 3.5 0 010 7H6"})]}),jsx("span",{children:"AI Usage & Costs"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]})]})]})]}),jsxs("div",{className:"command-palette-footer",children:[jsxs("div",{className:"command-palette-footer-hint",children:[jsx("kbd",{children:"\u2191"}),jsx("kbd",{children:"\u2193"}),jsx("span",{children:"Navigate"})]}),jsxs("div",{className:"command-palette-footer-hint",children:[jsx("kbd",{children:"Enter"}),jsx("span",{children:"Select"})]}),jsxs("div",{className:"command-palette-footer-hint",children:[jsx("kbd",{children:"Esc"}),jsx("span",{children:"Close"})]})]})]})})})}):null}function gd(e,t,a,r,o){let s=document.getElementById("attachment-lightbox-native");s&&s.remove();let n=document.createElement("div");n.id="attachment-lightbox-native",n.className="attachment-lightbox",n.style.cssText=`
4
+ `);if(t.length<1||!t[0])return {success:!1,errors:["CSV file is empty or invalid"]};let a=wl(t[0]),r=[],o=new Map,s=[];for(let n=1;n<t.length;n++)try{let c=wl(t[n]||"");if(c.length>a.length){s.push(`Line ${n+1}: Too many columns`);continue}if(a.length-c.length>3){s.push(`Line ${n+1}: Column count mismatch (expected ${a.length}, got ${c.length})`);continue}for(;c.length<a.length;)c.push("");let i={};a.forEach((h,C)=>{i[h]=c[C]||"";});let u=i.Column||"Unnamed";o.has(u)||o.set(u,{id:`col-${o.size+1}`,title:u,position:o.size+1,cardIds:[]});let d=o.get(u),g={id:i["Card ID"]||`card-${n}`,title:i.Title||"Untitled",description:i.Description?i.Description:void 0,columnId:d.id,position:d.cardIds.length+1,priority:i.Priority||void 0,labels:i.Labels?i.Labels.split(";").filter(Boolean):void 0,assignedUserIds:i["Assigned Users"]?i["Assigned Users"].split(";").filter(Boolean):void 0,startDate:i["Start Date"]?i["Start Date"]:void 0,endDate:i["End Date"]?i["End Date"]:void 0,createdAt:i["Created At"]?i["Created At"]:void 0,updatedAt:i["Updated At"]?i["Updated At"]:void 0};r.push(g),d.cardIds.push(g.id);}catch(c){s.push(`Line ${n+1}: ${c instanceof Error?c.message:"Unknown error"}`);}return r.length===0?{success:!1,errors:["No valid cards found in CSV",...s]}:{success:!0,cardsImported:r.length,columnsImported:o.size,errors:s.length>0?s:void 0}}catch(t){return {success:false,errors:[`Failed to parse CSV: ${t instanceof Error?t.message:"Unknown error"}`]}}}function wl(e){let t=[],a="",r=false;for(let o=0;o<e.length;o++){let s=e[o],n=e[o+1];s==='"'&&r&&n==='"'?(a+='"',o++):s==='"'?r=!r:s===","&&!r?(t.push(a),a=""):a+=s;}return t.push(a),t}function Cl(e,t){switch(t){case "json":return rp(e);case "csv":return op(e);default:return {success:false,errors:[`Unsupported import format: ${t}`]}}}function Tl(e){return new Promise((t,a)=>{let r=new FileReader;r.onload=o=>{o.target?.result?t(o.target.result):a(new Error("Failed to read file"));},r.onerror=()=>a(new Error("Failed to read file")),r.readAsText(e);})}var ss=createContext(null);function Nl(){return useContext(ss)}var Dl=createContext(null);function Sl({children:e,themeName:t}){return jsx(Dl.Provider,{value:{themeName:t},children:e})}function oo(){return useContext(Dl)}function gt({children:e,container:t}){let[a,r]=useState(false),o=Nl(),s=oo();if(useEffect(()=>(r(true),()=>r(false)),[]),!a)return null;let n=t||(typeof document<"u"?document.body:null);if(!n)return null;if(o){let{theme:c,themeName:p}=o,i={"--asakaa-color-background-primary":c.bgPrimary,"--asakaa-color-background-secondary":c.bgSecondary,"--asakaa-color-background-card":c.bgGrid,"--asakaa-color-background-hover":c.hoverBg,"--asakaa-color-text-primary":c.textPrimary,"--asakaa-color-text-secondary":c.textSecondary,"--asakaa-color-text-tertiary":c.textTertiary,"--asakaa-color-text-inverse":c.taskBarHandle||"#FFFFFF","--asakaa-color-border-default":c.border,"--asakaa-color-border-hover":c.borderLight,"--asakaa-color-border-subtle":c.borderLight,"--asakaa-color-interactive-primary":c.accent,"--asakaa-color-interactive-primaryHover":c.accentHover,"--asakaa-color-interactive-primaryBorder":`${c.accent}4D`,"--asakaa-color-interactive-primaryBackground":`${c.accent}1A`,"--asakaa-color-interactive-primaryBackgroundHover":`${c.accent}33`,"--asakaa-color-status-success":c.statusCompleted,"--asakaa-color-status-warning":c.milestone,"--asakaa-color-status-error":c.criticalPath,"--asakaa-color-danger":c.criticalPath,"--asakaa-color-danger-border":`${c.criticalPath}4D`,"--asakaa-color-danger-background":`${c.criticalPath}14`,"--asakaa-color-danger-backgroundHover":`${c.criticalPath}26`};return createPortal(jsx("div",{"data-theme":p,"data-gantt-portal":"true",style:i,children:e}),n)}return s?createPortal(jsx("div",{"data-theme":s.themeName,"data-kanban-portal":"true",children:e}),n):createPortal(e,n)}var Fl={URGENT:{label:"Urgent",color:"#E74C3C"},HIGH:{label:"High",color:"#E67E22"},MEDIUM:{label:"Normal",color:"#F1C40F"},LOW:{label:"Low",color:"#2ECC71"}},pp="#BDC3C7",up=({color:e})=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",fill:e,opacity:"0.9"}),jsx("circle",{cx:"8",cy:"8",r:"6",stroke:e,strokeWidth:"1.5",opacity:"0.3"})]});function zr({priority:e,onChange:t,className:a}){let[r,o]=useState(false),[s,n]=useState({top:0,left:0}),c=useRef(null),p=useRef(null),i=()=>{if(!p.current)return;let h=p.current.getBoundingClientRect(),C=window.innerHeight,T=window.innerWidth,m=160,b=220,y=4,l=h.right-m;l<10&&(l=h.left),l+m>T-10&&(l=T-m-10);let w=C-h.bottom,v=h.top,P;w>=b+y?P=h.bottom+y:v>=b+y?P=h.top-b-y:P=w>=v?h.bottom+y:Math.max(10,h.top-b-y),n({top:P,left:l}),o(true);};useEffect(()=>{let h=C=>{c.current&&!c.current.contains(C.target)&&!p.current?.contains(C.target)&&o(false);};if(r)return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[r]),useEffect(()=>{let h=C=>{C.key==="Escape"&&o(false);};if(r)return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[r]);let u=h=>{t(h),o(false);},d=e?Fl[e]:null,g=d?.color||pp;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:p,onClick:()=>r?o(false):i(),className:"flex items-center justify-center w-8 h-8 rounded-lg transition-all hover:bg-white/15 hover:scale-110 active:scale-95",style:{background:e?`${g}10`:"transparent",boxShadow:e?`0 0 0 2px ${g}30 inset`:"none"},title:d?.label||"Set priority",children:jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M3 2L3 14M3 2L13 6L3 8V2Z",stroke:g,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:g,fillOpacity:e?"0.6":"0.4"})})}),r&&jsx(gt,{children:jsxs("div",{ref:c,className:"priority-selector-menu",style:{position:"fixed",top:`${s.top}px`,left:`${s.left}px`,zIndex:99999,minWidth:"160px",maxHeight:"calc(100vh - 40px)",borderRadius:"8px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},children:[jsx("div",{className:"px-3 py-1.5 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.7))"},children:"Priority"})}),jsxs("div",{className:"py-1",children:[Object.entries(Fl).map(([h,C])=>jsxs("button",{onClick:()=>u(h),className:"w-full px-3 py-1.5 flex items-center gap-2 text-xs font-medium transition-all active:scale-[0.98] priority-option",style:{color:C.color,background:"transparent"},onMouseEnter:T=>{T.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:T=>{T.currentTarget.style.background="transparent";},children:[jsx(up,{color:C.color}),jsx("span",{className:"font-semibold text-sm",children:C.label}),e===h&&jsx("svg",{className:"ml-auto",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"#3B82F6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]},h)),jsx("div",{className:"mt-0.5 pt-0.5 border-t",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsxs("button",{onClick:()=>u(void 0),className:"w-full px-3 py-1.5 flex items-center gap-2 text-xs font-medium transition-all active:scale-[0.98]",style:{color:"var(--modal-v2-text-primary, #e5e5e5)",background:"transparent"},onMouseEnter:h=>{h.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:h=>{h.currentTarget.style.background="transparent";},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"#9CA3AF",strokeWidth:"1.5",strokeDasharray:"2 2",opacity:"0.6"})}),jsx("span",{className:"font-semibold text-sm",children:"Clear"}),!e&&jsx("svg",{className:"ml-auto",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"#3B82F6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})})]})]})})]})}var gp=[{label:"Today",days:0},{label:"Tomorrow",days:1},{label:"Next Week",days:7},{label:"2 Weeks",days:14},{label:"4 Weeks",days:28},{label:"8 Weeks",days:56}];function Co({startDate:e,endDate:t,onChange:a,className:r}){let[o,s]=useState(false),[n,c]=useState({top:0,left:0}),p=useRef(null),i=useRef(null),g=(oo()?.themeName||"dark")==="dark",h=()=>{if(!i.current)return;let l=i.current.getBoundingClientRect(),w=window.innerHeight,v=window.innerWidth,P=320,x=380,k=4,O=l.left;O+P>v-10&&(O=v-P-10),O<10&&(O=10);let M=w-l.bottom,N=l.top,H;M>=x+k?H=l.bottom+k:N>=x+k?H=l.top-x-k:H=M>=N?l.bottom+k:Math.max(10,l.top-x-k),c({top:H,left:O}),s(true);};useEffect(()=>{let l=w=>{p.current&&!p.current.contains(w.target)&&!i.current?.contains(w.target)&&s(false);};if(o)return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[o]),useEffect(()=>{let l=w=>{w.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[o]);let C=l=>{let w=new Date,v=O=>{let M=O.getFullYear(),N=String(O.getMonth()+1).padStart(2,"0"),H=String(O.getDate()).padStart(2,"0");return `${M}-${N}-${H}`},P=v(w),x=new Date(w);x.setDate(x.getDate()+l);let k=v(x);a(P,k),s(false);},T=()=>{if(!e||!t)return "Set date";let l=x=>{if(x instanceof Date)return x;if(typeof x!="string"||!x.match(/^\d{4}-\d{2}-\d{2}$/))return null;let k=x.split("-").map(Number);if(k.length!==3||k.some(H=>isNaN(H)))return null;let O=k[0],M=k[1],N=k[2];return O===void 0||M===void 0||N===void 0?null:new Date(O,M-1,N)},w=l(e),v=l(t);if(!w||!v||isNaN(w.getTime())||isNaN(v.getTime()))return "Set date";let P=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return `${P[w.getMonth()]} ${w.getDate()} \u2013 ${P[v.getMonth()]} ${v.getDate()}`},m=e&&t,y=(()=>{if(!t)return false;let l=typeof t=="string"?new Date(t):t,w=new Date;return w.setHours(0,0,0,0),l<w})();return jsxs("div",{className:`relative ${r||""}`,children:[jsxs("button",{ref:i,onClick:()=>o?s(false):h(),className:`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-all hover:bg-white/5 ${y?"asakaa-date-overdue":"asakaa-date"}`,title:m?`${T()}`:"Set date range",children:[jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{x:"2",y:"3",width:"12",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M2 6H14",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M5 2V4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("path",{d:"M11 2V4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),e&&t&&jsx("span",{className:"whitespace-nowrap",children:T()})]}),o&&jsx(gt,{children:jsxs("div",{ref:p,className:"date-picker-menu rounded-xl shadow-2xl border min-w-[320px]",style:{position:"fixed",top:`${n.top}px`,left:`${n.left}px`,background:g?"#1A1D25":"#FFFFFF",border:`1px solid ${g?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.12)"}`,boxShadow:g?"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)":"0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.08)",zIndex:99999},children:[jsxs("div",{className:"p-4 border-b",style:{borderColor:g?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.08)"},children:[jsx("span",{className:"text-xs font-bold uppercase tracking-wider block mb-3",style:{color:g?"rgba(255, 255, 255, 0.85)":"rgba(0, 0, 0, 0.7)"},children:"Quick Select"}),jsx("div",{className:"grid grid-cols-2 gap-2",children:gp.map(l=>jsx("button",{onClick:()=>C(l.days),className:"px-3 py-2.5 rounded-lg text-xs font-semibold transition-all active:scale-95",style:{color:g?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",border:`1px solid ${g?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`,backgroundColor:g?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)"},onMouseEnter:w=>{w.currentTarget.style.backgroundColor=g?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.1)",w.currentTarget.style.border=`1px solid ${g?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.25)"}`;},onMouseLeave:w=>{w.currentTarget.style.backgroundColor=g?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",w.currentTarget.style.border=`1px solid ${g?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`;},children:l.label},l.label))})]}),jsxs("div",{className:"p-4",children:[jsx("span",{className:"text-xs font-bold uppercase tracking-wider block mb-3",style:{color:g?"rgba(255, 255, 255, 0.85)":"rgba(0, 0, 0, 0.7)"},children:"Custom Range"}),jsxs("div",{className:"space-y-3",children:[jsx("input",{type:"date",value:e||"",onChange:l=>a(l.target.value,t),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:g?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:g?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:g?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:g?"dark":"light"}}),jsx("input",{type:"date",value:t||"",onChange:l=>a(e,l.target.value),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:g?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:g?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:g?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:g?"dark":"light"}})]}),(e||t)&&jsx("button",{onClick:()=>{a(void 0,void 0),s(false);},className:"mt-4 w-full px-3 py-2.5 rounded-lg text-sm font-semibold transition-all active:scale-95 border",style:{color:"#ef4444",borderColor:"rgba(239, 68, 68, 0.3)",background:"rgba(239, 68, 68, 0.1)"},onMouseEnter:l=>{l.currentTarget.style.background="rgba(239, 68, 68, 0.2)";},onMouseLeave:l=>{l.currentTarget.style.background="rgba(239, 68, 68, 0.1)";},children:"Clear Dates"})]})]})})]})}function $r({assignedUsers:e=[],availableUsers:t,onChange:a,className:r,maxVisibleAvatars:o=3}){let[s,n]=useState(false),[c,p]=useState(""),[i,u]=useState({top:0,left:0}),d=useRef(null),g=useRef(null),h=()=>{if(!g.current)return;let y=g.current.getBoundingClientRect(),l=window.innerHeight,w=window.innerWidth,v=300,P=380,x=4,k=y.right-v;k<10&&(k=y.left),k+v>w-10&&(k=w-v-10);let O=l-y.bottom,M=y.top,N;O>=P+x?N=y.bottom+x:M>=P+x?N=y.top-P-x:N=O>=M?y.bottom+x:Math.max(10,y.top-P-x),u({top:N,left:k}),n(true);};useEffect(()=>{let y=l=>{d.current&&!d.current.contains(l.target)&&!g.current?.contains(l.target)&&(n(false),p(""));};if(s)return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[s]),useEffect(()=>{let y=l=>{l.key==="Escape"&&(n(false),p(""));};if(s)return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[s]);let C=y=>{let l=e.some(w=>w.id===y.id);a(l?e.filter(w=>w.id!==y.id):[...e,y]);},T=t.filter(y=>y.name.toLowerCase().includes(c.toLowerCase())),m=e.slice(0,o),b=e.length-o;return jsxs("div",{className:`relative ${r||""}`,children:[jsx("button",{ref:g,onClick:()=>s?n(false):h(),className:"flex items-center gap-1 p-0.5 rounded transition-all hover:bg-white/10 hover:scale-105 active:scale-95",title:e.length>0?`${e.length} assigned`:"Assign users",children:e.length>0?jsxs("div",{className:"asakaa-avatar-group",children:[m.map(y=>jsx("div",{className:"asakaa-avatar",title:y.name,children:y.avatar?jsx("img",{src:y.avatar,alt:y.name,className:"asakaa-avatar-img"}):y.initials},y.id)),b>0&&jsxs("div",{className:"asakaa-avatar",children:["+",b]})]}):jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center transition-all",style:{background:"rgba(96, 165, 250, 0.15)",border:"1.5px solid rgba(96, 165, 250, 0.4)",color:"#60a5fa"},children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M8 8a3 3 0 100-6 3 3 0 000 6zM4 14c0-2.21 1.79-4 4-4s4 1.79 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("line",{x1:"13",y1:"5",x2:"13",y2:"9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("line",{x1:"11",y1:"7",x2:"15",y2:"7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})})}),s&&jsx(gt,{children:jsxs("div",{ref:d,className:"user-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${i.top}px`,left:`${i.left}px`,maxHeight:"calc(100vh - 40px)",overflow:"hidden",display:"flex",flexDirection:"column",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:[jsx("div",{className:"px-4 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-xs font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.8))"},children:"Assign Users"})}),jsx("div",{className:"px-3 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("input",{type:"text",value:c,onChange:y=>p(y.target.value),placeholder:"Search users...",className:"w-full px-3 py-2.5 rounded-lg text-sm border outline-none transition-all",style:{background:"var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))",borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.2))",color:"var(--modal-v2-text-primary, #ffffff)"},autoFocus:true})}),jsx("div",{className:"py-2 max-h-[300px] overflow-y-auto",children:T.length===0?jsx("div",{className:"px-4 py-3 text-sm text-center",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.6))"},children:"No users found"}):T.map(y=>{let l=e.some(w=>w.id===y.id);return jsxs("button",{onClick:()=>C(y),className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm transition-all active:scale-98",style:{background:"transparent"},onMouseEnter:w=>{w.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.1))";},onMouseLeave:w=>{w.currentTarget.style.background="transparent";},children:[jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-[11px] font-bold flex-shrink-0 shadow-sm",style:{backgroundColor:y.color,color:"#fff"},children:y.avatar?jsx("img",{src:y.avatar,alt:y.name,className:"w-full h-full rounded-full object-cover"}):y.initials}),jsx("span",{className:"font-semibold flex-1 text-left truncate",style:{color:"var(--modal-v2-text-primary, rgba(255, 255, 255, 0.95))"},children:y.name}),jsx("span",{className:"w-5 text-lg flex-shrink-0 text-right",style:{color:l?"#3b82f6":"transparent"},children:l?"\u2713":""})]},y.id)})}),e.length>0&&jsx("div",{className:"px-3 py-3 border-t border-white/10",children:jsx("button",{onClick:()=>{a([]),n(false);},className:"w-full px-3 py-2.5 rounded-lg text-sm font-semibold transition-all hover:bg-red-600/30 active:scale-95 border",style:{color:"#f87171",borderColor:"rgba(248, 113, 113, 0.3)",background:"rgba(248, 113, 113, 0.08)"},children:"Clear All"})})]})})]})}function rn(e,t,a){let r=new Map;e.forEach(p=>{if(p.dependencies&&Array.isArray(p.dependencies)){let i=p.dependencies.map(u=>{if(typeof u=="string")return u;let d=u;return d.taskId||d.targetId||""}).filter(Boolean);r.set(p.id,i);}});let o=r.get(a)||[];r.set(a,[...o,t]);let s=new Set,n=new Set,c=p=>{if(!s.has(p)){s.add(p),n.add(p);let i=r.get(p)||[];for(let u of i){if(!s.has(u)&&c(u))return true;if(n.has(u))return true}}return n.delete(p),false};return c(a)}function No({currentCardId:e,dependencies:t=[],availableTasks:a,onChange:r,className:o,validateCircular:s=true,onCircularDependencyError:n}){let[c,p]=useState(false),[i,u]=useState(""),[d,g]=useState(t.length>0),[h,C]=useState({top:0,left:0}),[T,m]=useState(null),b=useRef(null),y=useRef(null),l=()=>{if(!y.current)return;let k=y.current.getBoundingClientRect(),O=window.innerHeight,M=window.innerWidth,N=300,H=d?380:120,L=4,Y=k.right-N;Y<10&&(Y=k.left),Y+N>M-10&&(Y=M-N-10);let ae=O-k.bottom,ke=k.top,Pe;ae>=H+L?Pe=k.bottom+L:ke>=H+L?Pe=k.top-H-L:Pe=ae>=ke?k.bottom+L:Math.max(10,k.top-H-L),C({top:Pe,left:Y}),p(true);};useEffect(()=>{if(!c||!y.current)return;let k=y.current.getBoundingClientRect(),O=window.innerHeight,M=window.innerWidth,N=300,H=d?380:120,L=4,Y=k.right-N;Y<10&&(Y=k.left),Y+N>M-10&&(Y=M-N-10);let ae=O-k.bottom,ke=k.top,Pe;ae>=H+L?Pe=k.bottom+L:ke>=H+L?Pe=k.top-H-L:Pe=ae>=ke?k.bottom+L:Math.max(10,k.top-H-L),C({top:Pe,left:Y});},[d,c]),useEffect(()=>{let k=O=>{b.current&&!b.current.contains(O.target)&&!y.current?.contains(O.target)&&(p(false),u(""));};if(c)return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[c]),useEffect(()=>{let k=O=>{O.key==="Escape"&&(p(false),u(""));};if(c)return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[c]);let w=k=>{let O=t.includes(k),M=a.find(N=>N.id===k);if(m(null),O){let N=t.filter(H=>H!==k);r(N),N.length===0&&g(false);}else {if(s&&rn(a,k,e)){let H=`Cannot add "${M?.title||k}" as dependency - would create circular reference`;m(H),n?.(k,M?.title||k),setTimeout(()=>m(null),3e3);return}r([...t,k]),g(true);}},v=()=>{let k=!d;g(k),k||r([]);},P=a.filter(k=>k.id!==e).filter(k=>k.title.toLowerCase().includes(i.toLowerCase())||k.id.toLowerCase().includes(i.toLowerCase())),x=t.length>0?"#3B82F6":"#BDC3C7";return jsxs("div",{className:`relative ${o||""}`,children:[jsxs("button",{ref:y,onClick:()=>c?p(false):l(),className:"flex items-center gap-1 px-2 py-1 rounded transition-all hover:bg-white/5",title:t.length>0?`${t.length} dependencies`:"Add dependencies",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M7 9L9 7M11.5 3.5L10 2C8.89543 0.89543 7.10457 0.89543 6 2C4.89543 3.10457 4.89543 4.89543 6 6L7.5 7.5M4.5 12.5L6 14C7.10457 15.1046 8.89543 15.1046 10 14C11.1046 12.8954 11.1046 11.1046 10 10L8.5 8.5",stroke:x,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),t.length>0&&jsx("span",{className:"text-xs font-medium",style:{color:x},children:t.length})]}),c&&jsx(gt,{children:jsxs("div",{ref:b,className:"dependencies-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${h.top}px`,left:`${h.left}px`,maxHeight:"calc(100vh - 40px)",overflow:"hidden",display:"flex",flexDirection:"column",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:[T&&jsxs("div",{className:"px-4 py-3 flex items-center gap-2",style:{background:"rgba(239, 68, 68, 0.15)",borderBottom:"1px solid rgba(239, 68, 68, 0.3)"},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M8 5V8M8 11H8.01M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8Z",stroke:"#ef4444",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"text-xs font-medium",style:{color:"#ef4444"},children:T})]}),jsx("div",{className:"px-4 py-2 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.05))"},children:jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.7))"},children:"Task Dependencies"})}),jsx("div",{className:"px-4 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.05))"},children:jsxs("label",{className:"flex items-center gap-2 cursor-pointer group",onClick:v,children:[jsx("div",{className:"w-4 h-4 rounded border-2 flex items-center justify-center transition-all",style:{background:d?"#3b82f6":"transparent",borderColor:d?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:d&&jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M2 6L5 9L10 3",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{className:"text-sm font-medium",style:{color:"var(--modal-v2-text-primary, rgba(255, 255, 255, 0.8))"},children:"Has dependencies"})]})}),d&&jsxs(Fragment,{children:[jsx("div",{className:"px-3 py-2 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.05))"},children:jsx("input",{type:"text",value:i,onChange:k=>u(k.target.value),placeholder:"Search by name or ID...",className:"w-full px-3 py-2 rounded-md text-xs border outline-none transition-all",style:{background:"var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))",borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))",color:"var(--modal-v2-text-primary, #ffffff)"},autoFocus:true})}),jsx("div",{className:"py-2 max-h-[280px] overflow-y-auto",children:P.length===0?jsx("div",{className:"px-4 py-3 text-xs text-center",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:"No tasks found"}):P.map(k=>{let O=t.includes(k.id);return jsxs("button",{onClick:()=>w(k.id),className:"w-full px-4 py-2 flex items-start gap-3 text-sm transition-colors",style:{background:"transparent"},onMouseEnter:M=>{M.currentTarget.style.background="var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))";},onMouseLeave:M=>{M.currentTarget.style.background="transparent";},children:[jsx("div",{className:"w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0 mt-0.5 transition-all",style:{background:O?"#3b82f6":"transparent",borderColor:O?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:O&&jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M2 6L5 9L10 3",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxs("div",{className:"flex-1 text-left",children:[jsx("div",{className:"font-medium",style:{color:"var(--modal-v2-text-primary, rgba(255, 255, 255, 0.9))"},children:k.title}),jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:k.id})]})]},k.id)})})]}),t.length>0&&jsx("div",{className:"px-3 py-2 border-t border-white/5",children:jsx("button",{onClick:()=>{r([]),g(false),p(false);},className:"w-full px-3 py-2 rounded-md text-xs font-medium transition-all hover:bg-red-600/20 border border-red-500/30",style:{color:"#E74C3C"},children:"Clear All Dependencies"})})]})})]})}var ur=memo(({card:e,render:t,onClick:a,isSelected:r,disableDrag:o,className:s,onUpdate:n,availableUsers:c=[],allCards:p=[]})=>{let{attributes:i,listeners:u,setNodeRef:d,transform:g,transition:h,isDragging:C}=useSortable({id:e.id,disabled:o,data:{type:"card",card:e}}),T={transform:Qo.Transform.toString(g),transition:h};if(t)return jsx("div",{ref:d,style:T,...i,...u,onClick:()=>a?.(e),children:t(e)});let m=c.filter(w=>e.assignedUserIds?.includes(w.id)),b=e.progress===100,y=(e.attachments||[]).filter(w=>w.type.startsWith("image/")),l={...T,...e.color&&{borderTopWidth:"3px",borderTopStyle:"solid",borderTopColor:e.color}};return jsxs("div",{ref:d,style:l,className:f("asakaa-card",C&&"asakaa-card-dragging",r&&"ring-2 ring-asakaa-accent-blue",s),...i,...u,onClick:w=>{w.target.closest(".priority-selector, .date-picker, .user-selector, .dependencies-selector")||a?.(e);},children:[e.coverImage&&jsx("div",{className:"asakaa-card-cover mb-3",children:jsx("img",{src:e.coverImage,alt:`Cover for ${e.title}`,className:"w-full h-32 object-cover rounded-md",loading:"lazy",onError:w=>{w.currentTarget.style.display="none";}})}),y.length>0&&!e.coverImage&&jsx("div",{className:"asakaa-card-attachments mb-3",children:y.length===1&&y[0]?jsx("img",{src:y[0].url,alt:y[0].name,className:"w-full h-32 object-cover rounded-md",loading:"lazy",decoding:"async",style:{imageRendering:"auto",WebkitBackfaceVisibility:"hidden",backfaceVisibility:"hidden",transform:"translateZ(0)"},onError:w=>{w.currentTarget.style.display="none";}}):jsx("div",{className:"grid grid-cols-2 gap-1",children:y.slice(0,4).map((w,v)=>jsxs("div",{className:"relative",children:[jsx("img",{src:w.url,alt:w.name,className:"w-full h-16 object-cover rounded",loading:"lazy",decoding:"async",style:{imageRendering:"auto",WebkitBackfaceVisibility:"hidden",backfaceVisibility:"hidden",transform:"translateZ(0)"},onError:P=>{P.currentTarget.style.display="none";}}),v===3&&y.length>4&&jsx("div",{className:"absolute inset-0 bg-black/60 rounded flex items-center justify-center",children:jsxs("span",{className:"text-white text-sm font-medium",children:["+",y.length-4]})})]},w.id))})}),jsx("h3",{className:"asakaa-card-title mb-2",style:{textDecoration:b?"line-through":"none",opacity:b?.6:1},children:e.title}),e.description&&jsx("p",{className:"asakaa-card-description mb-3",children:e.description}),jsxs("div",{className:"flex items-center gap-3 mb-3 pt-1",children:[jsx("div",{onClick:w=>w.stopPropagation(),className:"priority-selector",children:jsx(zr,{priority:e.priority,onChange:w=>n?.(e.id,{priority:w})})}),jsx("div",{onClick:w=>w.stopPropagation(),className:"date-picker",children:jsx(Co,{startDate:e.startDate?typeof e.startDate=="string"?e.startDate:e.startDate.toISOString().split("T")[0]:void 0,endDate:e.endDate?typeof e.endDate=="string"?e.endDate:e.endDate.toISOString().split("T")[0]:void 0,onChange:(w,v)=>n?.(e.id,{startDate:w,endDate:v})})}),c.length>0&&jsx("div",{onClick:w=>w.stopPropagation(),className:"user-selector",children:jsx($r,{assignedUsers:m,availableUsers:c,onChange:w=>n?.(e.id,{assignedUserIds:w.map(v=>v.id)})})}),jsx("div",{onClick:w=>w.stopPropagation(),className:"dependencies-selector",children:jsx(No,{currentCardId:e.id,dependencies:Array.isArray(e.dependencies)?e.dependencies.map(w=>typeof w=="string"?w:w.taskId):[],availableTasks:p,onChange:w=>n?.(e.id,{dependencies:w})})})]}),e.labels&&e.labels.length>0&&jsx("div",{className:"flex flex-wrap gap-1",children:e.labels.slice(0,3).map(w=>jsx("span",{className:"asakaa-label",children:w},w))}),typeof e.progress=="number"&&jsxs("div",{className:"mt-3 pt-2 border-t border-white/5",children:[jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsx("span",{className:"text-[10px] text-[#6B7280]",children:"Progreso"}),jsxs("span",{className:"text-[10px] font-medium",style:{color:"#3B82F6"},children:[Math.round(e.progress),"%"]})]}),jsx("div",{className:"h-1.5 rounded-full bg-white/5 overflow-hidden",children:jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,e.progress))}%`,backgroundColor:"#3B82F6"}})})]})]})},(e,t)=>e.card.id===t.card.id&&e.card.title===t.card.title&&e.card.description===t.card.description&&e.card.position===t.card.position&&e.card.columnId===t.card.columnId&&e.card.priority===t.card.priority&&e.card.color===t.card.color&&e.card.progress===t.card.progress&&e.card.startDate===t.card.startDate&&e.card.endDate===t.card.endDate&&e.isSelected===t.isSelected&&JSON.stringify(e.card.labels)===JSON.stringify(t.card.labels)&&JSON.stringify(e.card.assignedUserIds)===JSON.stringify(t.card.assignedUserIds)&&JSON.stringify(e.card.dependencies)===JSON.stringify(t.card.dependencies)&&JSON.stringify(e.card.attachments?.map(a=>a.id))===JSON.stringify(t.card.attachments?.map(a=>a.id)));ur.displayName="Card";var on={todo:{label:"To Do",color:"#94a3b8",icon:"circle"},"in-progress":{label:"In Progress",color:"#60a5fa",icon:"circle-dot"},completed:{label:"Completed",color:"#34d399",icon:"check-circle"}},Wl=({icon:e,color:t})=>e==="circle"?jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("circle",{cx:"8",cy:"8",r:"6",stroke:t,strokeWidth:"1.5",fill:"none"})}):e==="circle-dot"?jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:t,strokeWidth:"1.5",fill:"none"}),jsx("circle",{cx:"8",cy:"8",r:"3",fill:t})]}):jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:t,strokeWidth:"1.5",fill:t,fillOpacity:"0.2"}),jsx("path",{d:"M5 8L7 10L11 6",stroke:t,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});function Gl({status:e="todo",onChange:t,className:a,customStatuses:r=[]}){let[o,s]=useState(false),[n,c]=useState({top:0,left:0}),p=useRef(null),i=useRef(null),u=[...Object.entries(on).map(([m,b])=>({id:m,label:b.label,color:b.color,icon:b.icon})),...r.filter(m=>!Object.keys(on).includes(m.id)).map(m=>({id:m.id,label:m.title,color:m.color||"#8B5CF6",icon:"circle-dot"}))],d=()=>{let m=on[e];if(m)return {...m,id:e};let b=r.find(y=>y.id===e);return b?{id:b.id,label:b.title,color:b.color||"#8B5CF6",icon:"circle-dot"}:{...on.todo,id:"todo"}},g=()=>{if(!i.current)return;let m=i.current.getBoundingClientRect(),b=window.innerHeight,y=window.innerWidth,l=180,w=280,v=4,P=m.right-l;P<10&&(P=m.left),P+l>y-10&&(P=y-l-10);let x=b-m.bottom,k=m.top,O;x>=w+v?O=m.bottom+v:k>=w+v?O=m.top-w-v:O=x>=k?m.bottom+v:Math.max(10,m.top-w-v),c({top:O,left:P}),s(true);};useEffect(()=>{let m=b=>{p.current&&!p.current.contains(b.target)&&!i.current?.contains(b.target)&&s(false);};if(o)return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[o]),useEffect(()=>{let m=b=>{b.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[o]);let h=m=>{t(m),s(false);},C=d(),T=C.color;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:i,onClick:()=>o?s(false):g(),className:"flex items-center justify-center w-8 h-8 rounded-lg transition-all hover:bg-white/15 hover:scale-110 active:scale-95",style:{background:`${T}10`,boxShadow:`0 0 0 2px ${T}30 inset`},title:C.label,children:jsx(Wl,{icon:C.icon,color:T})}),o&&jsx(gt,{children:jsxs("div",{ref:p,className:"status-selector-menu",style:{position:"fixed",top:`${n.top}px`,left:`${n.left}px`,zIndex:99999,minWidth:"180px",maxHeight:"calc(100vh - 40px)",overflowY:"auto",borderRadius:"8px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},children:[jsx("div",{className:"px-3 py-1.5 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.7))"},children:"Status"})}),jsx("div",{className:"py-1",children:u.map(m=>jsxs("button",{onClick:()=>h(m.id),className:"w-full px-3 py-2 flex items-center gap-2.5 text-sm font-medium transition-all active:scale-[0.98] status-option",style:{color:m.color,background:"transparent"},onMouseEnter:b=>{b.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:b=>{b.currentTarget.style.background="transparent";},children:[jsx(Wl,{icon:m.icon,color:m.color}),jsx("span",{className:"font-semibold",children:m.label}),e===m.id&&jsx("svg",{className:"ml-auto",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"#3B82F6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]},m.id))})]})})]})}function _l({columnTitle:e,onRename:t,onDelete:a,isDeletable:r=false,className:o}){let[s,n]=useState(false),[c,p]=useState(false),[i,u]=useState(e),[d,g]=useState({top:0,left:0}),h=useRef(null),C=useRef(null),T=useRef(null);useEffect(()=>{if(s&&C.current){let l=C.current.getBoundingClientRect();g({top:l.bottom+window.scrollY+8,left:l.left+window.scrollX});}},[s]),useEffect(()=>{let l=w=>{h.current&&!h.current.contains(w.target)&&!C.current?.contains(w.target)&&(n(false),p(false));};if(s)return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[s]),useEffect(()=>{let l=w=>{w.key==="Escape"&&(n(false),p(false),u(e));};if(s)return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[s,e]),useEffect(()=>{c&&T.current&&(T.current.focus(),T.current.select());},[c]);let m=()=>{p(true),u(e);},b=()=>{let l=i.trim();l&&l!==e&&t(l),p(false),n(false),u(e);},y=l=>{l.key==="Enter"?b():l.key==="Escape"&&(p(false),u(e));};return jsxs("div",{className:`relative ${o||""}`,children:[jsx("button",{ref:C,onClick:()=>n(!s),className:"opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-white/10",title:"Column options","aria-label":"Column menu",children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"3",r:"1.5",fill:"currentColor"}),jsx("circle",{cx:"8",cy:"8",r:"1.5",fill:"currentColor"}),jsx("circle",{cx:"8",cy:"13",r:"1.5",fill:"currentColor"})]})}),s&&jsx(gt,{children:jsx("div",{ref:h,className:"fixed rounded-xl shadow-2xl border min-w-[200px]",style:{top:`${d.top}px`,left:`${d.left}px`,background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:c?jsxs("div",{className:"p-3",children:[jsx("label",{className:"text-xs font-bold text-white/80 uppercase tracking-wider block mb-2",children:"Rename Column"}),jsx("input",{ref:T,type:"text",value:i,onChange:l=>u(l.target.value),onKeyDown:y,onBlur:b,className:"w-full px-3 py-2 rounded-lg text-sm bg-white/5 border border-white/20 text-white placeholder-white/50 outline-none focus:border-blue-500/50 transition-all",placeholder:"Column name",maxLength:50})]}):jsxs("div",{className:"py-1",children:[jsxs("button",{onClick:m,className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm text-white/90 hover:bg-white/10 transition-all",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M11.5 1.5L14.5 4.5L5 14H2V11L11.5 1.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"font-medium",children:"Rename"})]}),r&&a&&jsxs(Fragment,{children:[jsx("div",{className:"h-px bg-white/10 mx-2 my-1"}),jsxs("button",{onClick:()=>{a(),n(false);},className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm text-red-400 hover:bg-red-500/10 transition-all",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M2 4H14M5 4V2.5C5 2.22386 5.22386 2 5.5 2H10.5C10.7761 2 11 2.22386 11 2.5V4M12.5 4V13.5C12.5 13.7761 12.2761 14 12 14H4C3.72386 14 3.5 13.7761 3.5 13.5V4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M6.5 7V11M9.5 7V11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsx("span",{className:"font-medium",children:"Delete"})]})]})]})})})]})}var io=memo(({column:e,cards:t,renderColumn:a,renderCard:r,renderHeader:o,renderEmptyState:s,onCardClick:n,onCardUpdate:c,availableUsers:p,allCards:i,enableVirtualization:u,cardHeight:d=120,isCollapsed:g,onToggleCollapse:h,onColumnRename:C,onColumnDelete:T,isDeletable:m=false,className:b})=>{let{setNodeRef:y,isOver:l}=useDroppable({id:e.id,data:{type:"column",column:e}}),w=useRef(null),v=u??hl(t.length),P=useVirtualizer({count:t.length,getScrollElement:()=>w.current,estimateSize:()=>d,enabled:v});if(a)return jsx("div",{ref:y,className:b,children:a(e,t)});let k=(()=>{if(!e.wipLimit)return {state:"none",percentage:0};let N=t.length/e.wipLimit*100;return t.length>e.wipLimit?{state:"exceeded",percentage:N}:N>=80?{state:"warning",percentage:N}:N>=60?{state:"approaching",percentage:N}:{state:"ok",percentage:N}})(),O=k.state==="exceeded",M=()=>"asakaa-column-count";return jsxs("div",{ref:y,className:f("asakaa-column",l&&"ring-2 ring-asakaa-accent-blue",O&&"ring-2 ring-asakaa-accent-red",b),children:[o?o(e,t.length):jsxs("div",{className:"asakaa-column-header group",children:[jsx("h2",{className:"asakaa-column-title",children:e.title}),jsxs("div",{className:"flex items-center gap-2",children:[jsxs("span",{className:f(M()),children:[t.length,e.wipLimit&&` / ${e.wipLimit}`]}),e.wipLimit&&k.state!=="none"&&jsxs("span",{className:"text-xs font-medium flex items-center",title:`${k.percentage.toFixed(0)}% capacity${e.wipLimitType==="hard"?" (Hard limit - blocks new cards)":" (Soft limit - shows warning)"}`,children:[k.state==="exceeded"&&jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"8",cy:"8",r:"7",fill:"#EF4444",opacity:"0.9"}),jsx("path",{d:"M5 5L11 11M11 5L5 11",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}),k.state==="warning"&&jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("path",{d:"M8 1L15 14H1L8 1Z",fill:"#F59E0B",opacity:"0.9"}),jsx("path",{d:"M8 6V9M8 11V11.5",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round"})]}),k.state==="approaching"&&jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M8 1L10 7H14L10 10L12 16L8 12L4 16L6 10L2 7H6L8 1Z",fill:"#FB923C",opacity:"0.9"})}),k.state==="ok"&&jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"8",cy:"8",r:"7",fill:"#10B981",opacity:"0.9"}),jsx("path",{d:"M5 8L7 10L11 6",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]}),(C||T)&&jsx(_l,{columnTitle:e.title,onRename:N=>C?.(e.id,N),onDelete:T?()=>T(e.id):void 0,isDeletable:m}),h&&jsx("button",{onClick:h,className:"text-asakaa-text-tertiary hover:text-asakaa-text-primary","aria-label":g?"Expand column":"Collapse column",children:g?"\u25B6":"\u25BC"})]})]}),!g&&jsx("div",{ref:w,className:"asakaa-column-cards",style:{maxHeight:v?"600px":void 0},children:jsx(SortableContext,{items:t.map(N=>N.id),strategy:verticalListSortingStrategy,children:t.length===0?s?s(e):jsx("div",{className:"asakaa-drop-zone asakaa-empty",children:jsx("p",{children:"Drop cards here"})}):v?jsx("div",{style:{height:`${P.getTotalSize()}px`,position:"relative"},children:P.getVirtualItems().map(N=>{let H=t[N.index];return H?jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${N.start}px)`},children:jsx(ur,{card:H,render:r,onClick:n,onUpdate:c,availableUsers:p,allCards:i})},H.id):null})}):t.map(N=>jsx(ur,{card:N,render:r,onClick:n,onUpdate:c,availableUsers:p,allCards:i},N.id))})})]})});io.displayName="Column";function ms({title:e,onSave:t,className:a}){let[r,o]=useState(false),[s,n]=useState(e),c=useRef(null);useEffect(()=>{r&&c.current&&(c.current.focus(),c.current.select());},[r]);let p=()=>{let u=s.trim();u&&u!==e?t(u):n(e),o(false);},i=u=>{u.key==="Enter"?p():u.key==="Escape"&&(n(e),o(false));};return r?jsx("input",{ref:c,type:"text",value:s,onChange:u=>n(u.target.value),onBlur:p,onKeyDown:i,className:f("asakaa-column-title bg-transparent border-b-2 border-blue-500","outline-none px-1 -ml-1",a),maxLength:50}):jsx("h2",{className:f("asakaa-column-title cursor-pointer",a),onClick:()=>o(true),title:"Click to edit",children:e})}var dn=["#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#22C55E","#10B981","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899"];function nr({selectedTags:e,availableTags:t,onChange:a,onCreateTag:r,theme:o,disabled:s=false,compact:n=true}){let[c,p]=useState(false),[i,u]=useState(""),[d,g]=useState(false),[h,C]=useState(dn[10]||"#3B82F6"),[T,m]=useState({top:0,left:0}),b=useRef(null),y=useRef(null),l=useRef(null),w=useRef(null),v=t.filter(N=>N.name.toLowerCase().includes(i.toLowerCase())),P=t.some(N=>N.name.toLowerCase()===i.toLowerCase());useEffect(()=>{if(c&&y.current){let N=y.current.getBoundingClientRect();m({top:N.bottom+6,left:N.left});}},[c]),useEffect(()=>{let N=H=>{let L=H.target,Y=b.current?.contains(L),ae=l.current?.contains(L);!Y&&!ae&&(p(false),u(""),g(false));};if(c)return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[c]),useEffect(()=>{c&&w.current&&w.current.focus();},[c]);let x=N=>{let H=e.some(L=>L.id===N.id);a(H?e.filter(L=>L.id!==N.id):[...e,N]);},k=async()=>{if(!(!r||!i.trim())){g(true);try{let N=await r(i.trim(),h);N&&(a([...e,N]),u(""),C(dn[Math.floor(Math.random()*dn.length)]||"#3B82F6"));}finally{g(false);}}},O=(N,H)=>{H.stopPropagation(),a(e.filter(L=>L.id!==N));},M={backgroundColor:`${o.textTertiary}15`,border:`1px solid ${o.borderLight}`,color:o.textSecondary};return jsxs("div",{ref:b,className:"relative",children:[jsxs("button",{ref:y,type:"button",onClick:()=>!s&&p(!c),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:M,disabled:s,children:[jsx(Tag,{className:"w-3.5 h-3.5"}),e.length>0?jsxs("div",{className:"flex items-center gap-1",children:[e.slice(0,2).map(N=>jsx("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",style:{backgroundColor:`${N.color}20`,color:N.color},children:N.name},N.id)),e.length>2&&jsxs("span",{className:"text-xs",style:{color:o.textTertiary},children:["+",e.length-2]})]}):jsx("span",{children:"Agregar"}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:o.textTertiary}})]}),typeof document<"u"&&createPortal(jsx(AnimatePresence,{children:c&&jsxs(motion.div,{ref:l,initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"rounded-lg min-w-[240px]",style:{position:"fixed",top:T.top,left:T.left,zIndex:99999,backgroundColor:o.bgPrimary,border:`1px solid ${o.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},children:[jsx("div",{className:"p-2 border-b",style:{borderColor:o.border},children:jsx("input",{ref:w,type:"text",value:i,onChange:N=>u(N.target.value),placeholder:"Buscar o crear etiqueta...",className:"w-full px-3 py-1.5 text-sm rounded-md outline-none",style:{backgroundColor:o.bgSecondary,color:o.textPrimary,border:`1px solid ${o.borderLight}`},onKeyDown:N=>{N.key==="Enter"&&i.trim()&&!P&&r&&k();}})}),e.length>0&&jsxs("div",{className:"p-2 border-b",style:{borderColor:o.border},children:[jsx("p",{className:"text-xs mb-1.5",style:{color:o.textTertiary},children:"Seleccionadas"}),jsx("div",{className:"flex flex-wrap gap-1",children:e.map(N=>jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium cursor-pointer hover:opacity-80",style:{backgroundColor:`${N.color}20`,color:N.color},onClick:H=>O(N.id,H),children:[N.name,jsx(X,{className:"w-3 h-3"})]},N.id))})]}),jsx("div",{className:"max-h-[200px] overflow-y-auto p-1",children:v.length>0?v.map(N=>{let H=e.some(L=>L.id===N.id);return jsxs("button",{type:"button",onClick:()=>x(N),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors",style:{backgroundColor:H?`${N.color}15`:"transparent",color:o.textPrimary},onMouseEnter:L=>{H||(L.currentTarget.style.backgroundColor=o.hoverBg);},onMouseLeave:L=>{H||(L.currentTarget.style.backgroundColor="transparent");},children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:N.color}}),jsx("span",{className:"flex-1 text-left",children:N.name}),H&&jsx(Check,{className:"w-4 h-4",style:{color:N.color}})]},N.id)}):i.trim()?jsx("div",{className:"p-2 text-center text-sm",style:{color:o.textTertiary},children:"No se encontraron etiquetas"}):jsx("div",{className:"p-2 text-center text-sm",style:{color:o.textTertiary},children:"No hay etiquetas disponibles"})}),i.trim()&&!P&&r&&jsxs("div",{className:"p-2 border-t",style:{borderColor:o.border},children:[jsx("div",{className:"flex items-center gap-2 mb-2",children:jsx("p",{className:"text-xs",style:{color:o.textTertiary},children:"Crear nueva etiqueta"})}),jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:dn.map(N=>jsx("button",{type:"button",onClick:()=>C(N),className:"w-5 h-5 rounded-full transition-transform hover:scale-110",style:{backgroundColor:N,outline:h===N?`2px solid ${N}`:"none",outlineOffset:"2px"}},N))}),jsxs("button",{type:"button",onClick:k,disabled:d,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition-colors",style:{backgroundColor:h,color:"#FFFFFF",opacity:d?.7:1},children:[d?jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):jsx(Plus,{className:"w-4 h-4"}),'Crear "',i.trim(),'"']})]})]})}),document.body)]})}function us({tag:e,onRemove:t,size:a="sm"}){return jsxs("span",{className:`inline-flex items-center gap-1 rounded-full font-medium ${a==="xs"?"px-1.5 py-0.5 text-[10px]":"px-2 py-0.5 text-xs"}`,style:{backgroundColor:`${e.color}20`,color:e.color},children:[e.name,t&&jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t();},className:"hover:opacity-70",children:jsx(X,{className:"w-3 h-3"})})]})}function Yl({tags:e,maxVisible:t=3,size:a="sm"}){if(!e||e.length===0)return null;let r=e.slice(0,t),o=e.length-t;return jsxs("div",{className:"flex flex-wrap gap-1",children:[r.map(s=>jsx(us,{tag:s,size:a},s.id)),o>0&&jsxs("span",{className:`inline-flex items-center rounded-full font-medium ${a==="xs"?"px-1.5 py-0.5 text-[10px]":"px-2 py-0.5 text-xs"}`,style:{backgroundColor:"rgba(100,100,100,0.2)",color:"#9CA3AF"},children:["+",o]})]})}var sr=[{name:"Azul",value:"#6366F1",light:"#818CF8"},{name:"P\xFArpura",value:"#A855F7",light:"#C084FC"},{name:"Rosa",value:"#EC4899",light:"#F472B6"},{name:"Rojo",value:"#EF4444",light:"#F87171"},{name:"Naranja",value:"#F59E0B",light:"#FBBF24"},{name:"Amarillo",value:"#EAB308",light:"#FACC15"},{name:"Lima",value:"#84CC16",light:"#A3E635"},{name:"Verde",value:"#10B981",light:"#34D399"},{name:"Esmeralda",value:"#059669",light:"#10B981"},{name:"Cyan",value:"#06B6D4",light:"#22D3EE"},{name:"Azul Cielo",value:"#0EA5E9",light:"#38BDF8"},{name:"\xCDndigo",value:"#4F46E5",light:"#6366F1"},{name:"Violeta",value:"#8B5CF6",light:"#A78BFA"},{name:"Fucsia",value:"#D946EF",light:"#E879F9"},{name:"Coral",value:"#F97316",light:"#FB923C"},{name:"Magenta",value:"#E11D48",light:"#FB7185"}];function Ql(e,t=[]){if("title"in e&&!("name"in e)){let a=e,r=(a.assignedUserIds||[]).map(o=>{let s=t.find(n=>n.id===o);return s||null}).filter(o=>o!==null);return {id:a.id,name:a.title,startDate:a.startDate?new Date(a.startDate):void 0,endDate:a.endDate?new Date(a.endDate):void 0,progress:a.progress||0,status:a.columnId,priority:a.priority?.toLowerCase(),assignees:r,dependencies:Array.isArray(a.dependencies)?a.dependencies.map(o=>typeof o=="string"?o:o.taskId):[],tags:a.tags,subtasks:a.subtasks?.map(o=>({id:o.id,name:o.title,progress:o.completed?100:0,startDate:new Date,endDate:new Date})),color:a.color,description:a.description}}return e}function eu(e,t){return {...t,title:e.name,startDate:e.startDate,endDate:e.endDate,progress:e.progress,priority:e.priority?.toUpperCase(),tags:e.tags,description:e.description,color:e.color,columnId:e.status,assignedUserIds:t.assignedUserIds}}function Gr({task:e,isOpen:t,onClose:a,onTaskUpdate:r,onCardUpdate:o,theme:s="dark",locale:n="es",availableUsers:c=[],availableTags:p=[],onCreateTag:i,attachments:u=[],onUploadAttachments:d,onDeleteAttachment:g,availableTasks:h=[],comments:C=[],onAddComment:T,currentUser:m}){let b=s==="dark",y={textTertiary:b?"#6B7280":"#9CA3AF",textSecondary:b?"#9CA3AF":"#6B7280",textPrimary:b?"#FFFFFF":"#111827",borderLight:b?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",border:b?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",bgPrimary:b?"#1A1D25":"#FFFFFF",bgSecondary:b?"#0F1117":"#F9FAFB",hoverBg:b?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},l=e&&"title"in e&&!("name"in e),w=e,[v,P]=useState(e?Ql(e,c):null),[x,k]=useState(false),[O,M]=useState(false),[N,H]=useState(false),[L,Y]=useState(null),[ae,ke]=useState(new Date),[Pe,Ve]=useState(false),[Je,$]=useState(false),[B,W]=useState(""),[D,j]=useState(false),[J,R]=useState(false),[de,we]=useState(false),[Me,ce]=useState(""),We=useRef(null),[Fe,Ye]=useState(""),ut=useRef(null),[yt,nt]=useState(""),[z,re]=useState(false);useEffect(()=>{if(e){let S=Ql(e,c);P(S),ce(S.description||""),Ye(S.name||"");}},[e?.id,c]),useEffect(()=>()=>{We.current&&clearTimeout(We.current),ut.current&&clearTimeout(ut.current);},[]);let oe=useCallback(S=>{P(S),l&&o&&w?o(eu(S,w)):r&&r(S);},[l,w,o,r]),xe=useCallback(()=>{k(false),M(false),H(false),Y(null),$(false),W(""),j(false);},[]),Ne=useCallback((S,Z)=>{if(!v)return;let ge={...v,[S]:Z};oe(ge);},[v,oe]),tt=useCallback(S=>{ce(S),We.current&&clearTimeout(We.current),We.current=setTimeout(()=>{if(v){let Z={...v,description:S};oe(Z);}},800);},[v,oe]),ht=useCallback(S=>{Ye(S),ut.current&&clearTimeout(ut.current),ut.current=setTimeout(()=>{if(v&&S.trim()){let Z={...v,name:S.trim()};oe(Z);}},800);},[v,oe]),Ie=useCallback(async()=>{if(!(!v||!yt.trim()||!T)){re(true);try{await T(v.id,yt.trim()),nt("");}finally{re(false);}}},[v,yt,T]),be=useCallback(S=>{let Z=typeof S=="string"?new Date(S):S,Te=new Date().getTime()-Z.getTime(),qe=Math.floor(Te/6e4),Ge=Math.floor(Te/36e5),Re=Math.floor(Te/864e5);return qe<1?n==="es"?"Ahora":"Just now":qe<60?n==="es"?`Hace ${qe} min`:`${qe}m ago`:Ge<24?n==="es"?`Hace ${Ge}h`:`${Ge}h ago`:Re<7?n==="es"?`Hace ${Re}d`:`${Re}d ago`:Z.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})},[n]),Se=useCallback(S=>{if(!v)return;let Z=v.progress||0;S==="completed"?Z=100:S==="in-progress"&&Z===0?Z=10:S==="todo"&&(Z=0);let ge={...v,status:S,progress:Z};oe(ge),k(false);},[v,oe]),Ft=useCallback((S,Z)=>{if(!v)return;let ge={...v,startDate:S,endDate:Z};oe(ge);},[v,oe]),bt=useCallback(()=>{let S=ae.getFullYear(),Z=ae.getMonth(),ge=new Date(S,Z,1),qe=new Date(S,Z+1,0).getDate(),Ge=ge.getDay(),Re=[],at=new Date(S,Z,0).getDate();for(let K=Ge-1;K>=0;K--)Re.push({date:new Date(S,Z-1,at-K),isCurrentMonth:false});for(let K=1;K<=qe;K++)Re.push({date:new Date(S,Z,K),isCurrentMonth:true});let lt=42-Re.length;for(let K=1;K<=lt;K++)Re.push({date:new Date(S,Z+1,K),isCurrentMonth:false});return Re},[ae]),sa=useCallback(async S=>{if(S.preventDefault(),S.stopPropagation(),R(false),!v||!d)return;let Z=Array.from(S.dataTransfer.files);if(Z.length!==0){we(true);try{await d(v.id,Z);}finally{we(false);}}},[v,d]),ua=useCallback(async S=>{if(!v||!d||!S.target.files)return;let Z=Array.from(S.target.files);if(Z.length!==0){we(true);try{await d(v.id,Z);}finally{we(false);}S.target.value="";}},[v,d]),$e=useCallback(S=>{S.preventDefault(),S.stopPropagation(),R(true);},[]),Ue=useCallback(S=>{S.preventDefault(),S.stopPropagation(),R(false);},[]),ia=useCallback(S=>S<1024?`${S} B`:S<1024*1024?`${(S/1024).toFixed(1)} KB`:`${(S/(1024*1024)).toFixed(1)} MB`,[]),ue=useCallback(S=>S.startsWith("image/")?Image:S.includes("pdf")||S.includes("document")?FileText:File,[]);return !t||!v?null:jsx(AnimatePresence,{children:t&&v&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:a,className:"fixed inset-0 bg-black/50 z-40"}),jsxs(motion.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},className:f("fixed inset-4 md:inset-8 lg:inset-12 rounded-xl shadow-2xl z-50 flex overflow-hidden",b?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[jsxs("div",{className:f("px-6 py-3 border-b flex items-center gap-3",b?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:f("w-4 h-4",b?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:f("text-xs px-2 py-0.5 rounded",b?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[n==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:f("text-xs font-mono",b?"text-[#6B7280]":"text-gray-400"),children:v.id.slice(0,8)}),jsxs("button",{className:f("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-colors",b?"bg-purple-500/20 text-purple-400 hover:bg-purple-500/30":"bg-purple-100 text-purple-700 hover:bg-purple-200"),children:[jsx(Sparkles,{className:"w-3 h-3"}),"Ask AI"]})]}),jsx("div",{className:"flex-1"}),jsx("button",{className:f("p-1.5 rounded transition-colors",b?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Maximize2,{className:"w-4 h-4"})}),jsx("button",{className:f("p-1.5 rounded transition-colors",b?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(MoreHorizontal,{className:"w-5 h-5"})}),jsx("button",{onClick:a,className:f("p-1.5 rounded transition-colors",b?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(X,{className:"w-5 h-5"})})]}),jsx("div",{className:"px-6 py-4",children:jsxs("div",{className:"flex items-start gap-3",children:[jsx("button",{onClick:()=>{let S=v.progress===100?0:100,ge={...v,progress:S,status:S===100?"completed":"todo"};oe(ge);},className:f("mt-2 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors flex-shrink-0",v.progress===100?"bg-green-500 border-green-500":b?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:v.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("input",{type:"text",value:Fe,onChange:S=>ht(S.target.value),placeholder:n==="es"?"Nombre de la tarea...":"Task name...",className:f("text-xl font-semibold flex-1 bg-transparent outline-none border-none px-0 py-0","focus:ring-0 focus:outline-none",v.progress===100?"line-through text-[#6B7280]":b?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400")})]})}),jsxs("div",{className:"px-6 pb-6 flex-1 overflow-y-auto overflow-x-visible",children:[jsxs("div",{className:"grid grid-cols-2 gap-x-12 gap-y-5",children:[jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CheckCircle2,{className:f("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{xe(),k(!x);},className:f("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",v.progress===100||v.status==="completed"?"bg-green-500/20 text-green-400":v.progress&&v.progress>0||v.status==="in-progress"?"bg-blue-500/20 text-blue-400":b?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:v.progress===100||v.status==="completed"?n==="es"?"COMPLETADO":"DONE":v.progress&&v.progress>0||v.status==="in-progress"?n==="es"?"EN PROGRESO":"IN PROGRESS":n==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:x&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>k(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:f("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",b?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"todo",label:n==="es"?"Por hacer":"To Do",color:"bg-gray-400"},{id:"in-progress",label:n==="es"?"En progreso":"In Progress",color:"bg-blue-500"},{id:"completed",label:n==="es"?"Completado":"Done",color:"bg-green-500"}].map(S=>jsxs("button",{onClick:()=>Se(S.id),className:f("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",b?"hover:bg-white/5":"hover:bg-gray-50",v.status===S.id&&(b?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:f("w-2 h-2 rounded-full",S.color)}),jsx("span",{className:b?"text-white":"text-gray-900",children:S.label})]},S.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(User,{className:f("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{xe(),H(!N);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",b?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[v.assignees&&v.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[v.assignees.slice(0,3).map((S,Z)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:S.color||"#8B5CF6"},title:S.name,children:S.initials||S.name.slice(0,2).toUpperCase()},Z)),v.assignees.length>3&&jsxs("span",{className:f("text-xs",b?"text-[#6B7280]":"text-gray-400"),children:["+",v.assignees.length-3]})]}):jsx("span",{className:f("text-sm",b?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Agregar":"Add"}),jsx(ChevronDown,{className:f("w-3 h-3",b?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:N&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>H(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:f("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[200px] max-h-[280px] overflow-y-auto",b?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:c.length>0?c.map(S=>{let Z=v.assignees?.some(ge=>ge.name===S.name);return jsxs("button",{onClick:()=>{let ge=v.assignees||[],Te;Z?Te=ge.filter(qe=>qe.name!==S.name):Te=[...ge,S],Ne("assignees",Te);},className:f("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",b?"hover:bg-white/5":"hover:bg-gray-50",Z&&(b?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:S.color||"#8B5CF6"},children:S.initials||S.name.slice(0,2).toUpperCase()}),jsx("span",{className:f("flex-1",b?"text-white":"text-gray-900"),children:S.name}),Z&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},S.name)}):jsx("div",{className:f("px-3 py-4 text-sm text-center",b?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"No hay usuarios disponibles":"No users available"})})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CalendarDays,{className:f("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{Y(L?null:"start"),ke(v.startDate||new Date);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",b?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[v.startDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Inicio":"Start"),jsx("span",{className:f("mx-1",b?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),v.endDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Fin":"End")]}),jsx(AnimatePresence,{children:L&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Y(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:f("absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",b?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:S=>S.stopPropagation(),children:[jsxs("div",{className:f("w-44 py-2 border-r",b?"border-white/10":"border-gray-200"),children:[(()=>{let S=new Date,Z=new Date(S);Z.setDate(S.getDate()+1);let ge=new Date(S);ge.setDate(S.getDate()+((6-S.getDay()+7)%7||7));let Te=new Date(S);Te.setDate(S.getDate()+((1-S.getDay()+7)%7||7));let qe=new Date(S);qe.setDate(S.getDate()+(6-S.getDay()+7)%7+7);let Ge=new Date(S);Ge.setDate(S.getDate()+14);let Re=new Date(S);return Re.setDate(S.getDate()+28),[{label:n==="es"?"Hoy":"Today",date:S,display:S.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Ma\xF1ana":"Tomorrow",date:Z,display:Z.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Este fin de semana":"This weekend",date:ge,display:n==="es"?"s\xE1b.":"sat."},{label:n==="es"?"Pr\xF3xima semana":"Next week",date:Te,display:n==="es"?"lun.":"mon."},{label:n==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:qe,display:qe.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"2 semanas":"2 weeks",date:Ge,display:Ge.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:Re,display:Re.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((lt,K)=>jsxs("button",{className:f("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",b?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if(L==="start"){let te=v.endDate&&lt.date>v.endDate?lt.date:v.endDate;Ft(lt.date,te),Y("end");}else {let te=v.startDate&&lt.date<v.startDate?lt.date:v.startDate;Ft(te,lt.date),Y(null);}},children:[jsx("span",{children:lt.label}),jsx("span",{className:f("text-xs",b?"text-[#6B7280]":"text-gray-400"),children:lt.display})]},K))})(),jsx("div",{className:f("border-t mt-2 pt-2",b?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{Ft(void 0,void 0),Y(null);},className:f("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",b?"hover:bg-white/5 text-red-400":"hover:bg-gray-50 text-red-500"),children:[jsx("span",{children:n==="es"?"Quitar fechas":"Clear dates"}),jsx(X,{className:"w-4 h-4 opacity-50"})]})})]}),jsxs("div",{className:"p-4",children:[jsx("div",{className:f("text-xs mb-3 px-2 py-1 rounded",b?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:L==="start"?n==="es"?"\u{1F4C5} Selecciona fecha de inicio":"\u{1F4C5} Select start date":n==="es"?"\u{1F4C5} Selecciona fecha de fin":"\u{1F4C5} Select end date"}),jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsx("span",{className:f("font-medium",b?"text-white":"text-gray-900"),children:ae.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>ke(new Date),className:f("p-1 rounded text-sm transition-colors",b?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>ke(new Date(ae.getFullYear(),ae.getMonth()-1)),className:f("p-1 rounded",b?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),jsx("button",{onClick:()=>ke(new Date(ae.getFullYear(),ae.getMonth()+1)),className:f("p-1 rounded",b?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:(n==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(S=>jsx("div",{className:f("w-8 h-8 flex items-center justify-center text-xs",b?"text-[#6B7280]":"text-gray-400"),children:S},S))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:bt().map((S,Z)=>{let ge=S.date.toDateString()===new Date().toDateString(),Te=v.startDate?.toDateString()===S.date.toDateString(),qe=v.endDate?.toDateString()===S.date.toDateString(),Ge=Te||qe,Re=v.startDate&&v.endDate&&S.date>=v.startDate&&S.date<=v.endDate;return jsx("button",{onClick:()=>{let at=new Date(S.date);if(L==="start"){let lt=v.endDate&&at>v.endDate?at:v.endDate;Ft(at,lt),Y("end");}else {let lt=v.startDate&&at<v.startDate?at:v.startDate;Ft(lt,at),Y(null);}},className:f("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!S.isCurrentMonth&&(b?"text-[#4B5563]":"text-gray-300"),S.isCurrentMonth&&(b?"text-white":"text-gray-900"),ge&&"ring-2 ring-[#3B82F6]",Te&&"bg-[#3B82F6] text-white",qe&&!Te&&"bg-[#7C3AED] text-white",Re&&!Ge&&(b?"bg-[#7C3AED]/20":"bg-purple-100"),!Ge&&(b?"hover:bg-white/10":"hover:bg-gray-100")),children:S.date.getDate()},Z)})})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:f("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{xe(),M(!O);},className:f("text-xs px-2 py-1 rounded font-medium transition-all hover:ring-2 hover:ring-white/20",v.priority==="high"||v.priority==="urgent"?"bg-red-500/20 text-red-400":v.priority==="medium"?"bg-yellow-500/20 text-yellow-400":v.priority==="low"?"bg-green-500/20 text-green-400":b?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:v.priority?v.priority==="high"||v.priority==="urgent"?n==="es"?"Alta":"High":v.priority==="medium"?n==="es"?"Media":"Medium":n==="es"?"Baja":"Low":n==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:O&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>M(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:f("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",b?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"urgent",label:n==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:n==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:n==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:n==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:n==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(S=>jsxs("button",{onClick:()=>{Ne("priority",S.id),M(false);},className:f("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",b?"hover:bg-white/5":"hover:bg-gray-50",v.priority===S.id&&(b?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:f("w-2 h-2 rounded-full",S.color)}),jsx("span",{className:b?"text-white":"text-gray-900",children:S.label})]},S.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:f("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:f("text-sm",b?"text-white":"text-gray-900"),children:v.startDate&&v.endDate?`${Math.ceil((v.endDate.getTime()-v.startDate.getTime())/(1e3*60*60*24))} ${n==="es"?"d\xEDas":"days"}`:n==="es"?"Sin definir":"Not set"})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:f("w-4 h-4 rounded-full border-2",b?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:f("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[Pe?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:v.progress||0,onChange:S=>{let Z=parseInt(S.target.value),ge=v.status;Z===100?ge="completed":Z>0?ge="in-progress":ge="todo";let Te={...v,progress:Z,status:ge};oe(Te);},onBlur:()=>Ve(false),className:f("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",b?"bg-white/10":"bg-gray-200","[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[#3B82F6] [&::-webkit-slider-thumb]:cursor-pointer"),autoFocus:true}):jsx("button",{onClick:()=>Ve(true),className:f("flex-1 h-2 rounded-full overflow-hidden max-w-[120px] cursor-pointer hover:ring-2 hover:ring-white/20 transition-all",b?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:f("h-full rounded-full transition-all",v.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${v.progress||0}%`}})}),jsxs("span",{className:f("text-sm font-medium min-w-[40px]",b?"text-white":"text-gray-900"),children:[v.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:f("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Etiquetas":"Tags"}),jsx(nr,{selectedTags:v.tags||[],availableTags:p,onChange:S=>{Ne("tags",S);},onCreateTag:i,theme:y})]}),jsxs("div",{className:"flex items-start gap-3 relative",children:[jsx(Link2,{className:f("w-4 h-4 mt-1.5",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24 mt-1",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[v.dependencies&&v.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:v.dependencies.map(S=>{let Z=h.find(ge=>ge.id===S);return jsxs("span",{className:f("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",b?"bg-blue-500/20 text-blue-400":"bg-blue-100 text-blue-700"),children:[Z?.name||S.slice(0,8),jsx("button",{onClick:()=>{let ge=(v.dependencies||[]).filter(Te=>Te!==S);Ne("dependencies",ge);},className:f("ml-0.5 hover:bg-white/20 rounded-full p-0.5 transition-colors"),children:jsx(X,{className:"w-3 h-3"})})]},S)})}),jsxs("button",{onClick:()=>{xe(),$(!Je);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",b?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{className:f("text-sm",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:Je&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{$(false),W("");}}),jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:f("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[280px] max-h-[320px]",b?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[jsx("div",{className:f("p-2 border-b",b?"border-white/10":"border-gray-200"),children:jsx("input",{type:"text",value:B,onChange:S=>W(S.target.value),placeholder:n==="es"?"Buscar tarea...":"Search task...",className:f("w-full px-3 py-2 rounded-md text-sm outline-none",b?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400"),autoFocus:true})}),jsx("div",{className:"max-h-[240px] overflow-y-auto",children:h.length>0?h.filter(S=>S.id!==v.id).filter(S=>B===""||S.name.toLowerCase().includes(B.toLowerCase())).map(S=>{let Z=v.dependencies?.includes(S.id);return jsxs("button",{onClick:()=>{let ge=v.dependencies||[],Te;Z?Te=ge.filter(qe=>qe!==S.id):Te=[...ge,S.id],Ne("dependencies",Te);},className:f("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",b?"hover:bg-white/5":"hover:bg-gray-50",Z&&(b?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:f("w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0",Z?"bg-blue-500 border-blue-500":b?"border-white/30":"border-gray-300"),children:Z&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("span",{className:f("block truncate",b?"text-white":"text-gray-900"),children:S.name}),jsx("span",{className:f("text-xs",b?"text-[#6B7280]":"text-gray-400"),children:S.id.slice(0,8)})]})]},S.id)}):jsx("div",{className:f("px-3 py-4 text-sm text-center",b?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"No hay tareas disponibles":"No tasks available"})})]})]})})]})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Palette,{className:f("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:"Color"}),jsxs("button",{onClick:()=>{xe(),j(!D);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",b?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx("div",{className:"w-4 h-4 rounded-full",style:{backgroundColor:v.color||"#6366F1"}}),jsx("span",{className:f("text-sm",b?"text-white":"text-gray-900"),children:sr.find(S=>S.value===v.color)?.name||(n==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:f("w-3 h-3",b?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:D&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>j(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:f("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden p-3",b?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:jsx("div",{className:"grid grid-cols-6 gap-1.5",children:sr.map(S=>{let Z=v.color===S.value;return jsx("button",{onClick:()=>{Ne("color",S.value),j(false);},className:f("w-7 h-7 rounded-full flex items-center justify-center transition-all",Z&&"ring-2 ring-offset-2",b?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:S.value,outlineColor:Z?S.value:void 0},title:S.name,children:Z&&jsx(Check,{className:"w-3.5 h-3.5 text-white"})},S.value)})})})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Diamond,{className:f("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Hito":"Milestone"}),jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:v.isMilestone||false,onChange:S=>Ne("isMilestone",S.target.checked),className:f("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",v.isMilestone?"bg-purple-500 border-purple-500":b?"border-white/30 bg-transparent":"border-gray-300 bg-transparent","checked:bg-purple-500 checked:border-purple-500")}),jsx("span",{className:f("text-sm",b?"text-white":"text-gray-900"),children:n==="es"?"Marcar como hito":"Mark as milestone"})]})]})]}),jsxs("div",{className:f("mt-6 pt-4 border-t",b?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2 mb-3",children:[jsx(FileText,{className:f("w-4 h-4",b?"text-[#6B7280]":"text-gray-400")}),jsx("h3",{className:f("text-sm font-semibold",b?"text-white":"text-gray-900"),children:n==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:Me,onChange:S=>tt(S.target.value),placeholder:n==="es"?"Agregar descripci\xF3n...":"Add description...",className:f("w-full min-h-[100px] px-3 py-2 rounded-lg text-sm resize-none outline-none transition-colors",b?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400 focus:bg-gray-200")}),jsxs("button",{className:f("flex items-center gap-2 text-sm mt-2 transition-colors",b?"text-purple-400 hover:text-purple-300":"text-purple-600 hover:text-purple-700"),children:[jsx(Sparkles,{className:"w-4 h-4"}),n==="es"?"Escribe con IA":"Write with AI"]})]}),jsxs("div",{className:f("mt-6 pt-4 border-t",b?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:f("text-sm font-semibold mb-3",b?"text-white":"text-gray-900"),children:n==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:f("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",b?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),n==="es"?"Crea un campo en esta lista":"Create a field in this list"]})]}),jsxs("div",{className:f("mt-6 pt-4 border-t",b?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:f("text-sm font-semibold mb-3",b?"text-white":"text-gray-900"),children:n==="es"?"Subtareas":"Subtasks"}),v.subtasks&&v.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:v.subtasks.map(S=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:f("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",S.progress===100?"bg-green-500 border-green-500":b?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:S.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:f("text-sm",S.progress===100?"line-through text-[#6B7280]":b?"text-white":"text-gray-900"),children:S.name})]},S.id))}),jsxs("button",{className:f("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",b?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),n==="es"?"Agregar subtarea":"Add subtask"]})]}),jsxs("div",{className:f("mt-6 pt-4 border-t",b?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("h3",{className:f("text-sm font-semibold",b?"text-white":"text-gray-900"),children:n==="es"?"Listas de control":"Checklists"}),jsx("button",{className:f("p-1 rounded transition-colors",b?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Plus,{className:"w-4 h-4"})})]}),jsxs("button",{className:f("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",b?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(ListChecks,{className:"w-4 h-4"}),n==="es"?"Crear lista de control":"Create checklist"]})]}),jsxs("div",{className:f("mt-6 pt-4 border-t",b?"border-white/10":"border-gray-200"),children:[jsxs("h3",{className:f("text-sm font-semibold mb-3",b?"text-white":"text-gray-900"),children:[n==="es"?"Adjuntos":"Attachments",u.length>0&&jsxs("span",{className:f("ml-2 text-xs font-normal",b?"text-[#6B7280]":"text-gray-400"),children:["(",u.length,")"]})]}),u.length>0&&jsx("div",{className:"space-y-2 mb-4",children:u.map(S=>{let Z=ue(S.type),ge=S.type.startsWith("image/");return jsxs("div",{className:f("flex items-center gap-3 p-2 rounded-lg group transition-colors",b?"bg-white/5 hover:bg-white/10":"bg-gray-50 hover:bg-gray-100"),children:[ge&&S.thumbnailUrl?jsx("img",{src:S.thumbnailUrl,alt:S.name,className:"w-10 h-10 rounded object-cover"}):jsx("div",{className:f("w-10 h-10 rounded flex items-center justify-center",b?"bg-white/10":"bg-gray-200"),children:jsx(Z,{className:f("w-5 h-5",b?"text-[#9CA3AF]":"text-gray-500")})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",className:f("text-sm font-medium truncate block hover:underline",b?"text-white":"text-gray-900"),children:S.name}),jsx("p",{className:f("text-xs",b?"text-[#6B7280]":"text-gray-400"),children:ia(S.size)})]}),g&&jsx("button",{onClick:()=>g(S.id),className:f("p-1.5 rounded opacity-0 group-hover:opacity-100 transition-all",b?"hover:bg-red-500/20 text-red-400":"hover:bg-red-100 text-red-500"),title:n==="es"?"Eliminar":"Delete",children:jsx(Trash2,{className:"w-4 h-4"})})]},S.id)})}),jsxs("div",{onDragOver:$e,onDragLeave:Ue,onDrop:sa,className:f("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",J?b?"border-blue-500 bg-blue-500/10":"border-blue-400 bg-blue-50":b?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300",de&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:ua,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!d||de}),de?jsxs(Fragment,{children:[jsx("div",{className:"w-6 h-6 mx-auto mb-2 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"}),jsx("p",{className:f("text-sm",b?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Subiendo...":"Uploading..."})]}):jsxs(Fragment,{children:[jsx(Upload,{className:f("w-6 h-6 mx-auto mb-2",J?"text-blue-500":b?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:f("text-sm",b?"text-[#9CA3AF]":"text-gray-500"),children:J?n==="es"?"Suelta los archivos aqu\xED":"Drop files here":n==="es"?jsxs(Fragment,{children:["Suelta tus archivos aqu\xED o ",jsx("span",{className:"underline",children:"haz clic para subir"})]}):jsxs(Fragment,{children:["Drop your files here or ",jsx("span",{className:"underline",children:"click to upload"})]})}),!d&&jsx("p",{className:f("text-xs mt-1",b?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Upload no disponible":"Upload not available"})]})]})]})]})]}),jsxs("div",{className:f("w-80 border-l flex flex-col",b?"border-white/10 bg-[#0F1117]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:f("px-4 py-3 border-b",b?"border-white/10":"border-gray-200"),children:jsxs("h3",{className:f("text-sm font-semibold",b?"text-white":"text-gray-900"),children:[n==="es"?"Actividad":"Activity",C.length>0&&jsxs("span",{className:f("ml-2 text-xs font-normal",b?"text-[#6B7280]":"text-gray-400"),children:["(",C.length,")"]})]})}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:C.length>0?jsx("div",{className:"space-y-4",children:C.map(S=>jsxs("div",{className:"flex gap-3",children:[jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:S.user?.color||"#8B5CF6"},children:S.user?.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2 mb-1",children:[jsx("span",{className:f("text-sm font-medium",b?"text-white":"text-gray-900"),children:S.user?.name||(n==="es"?"Usuario":"User")}),jsx("span",{className:f("text-xs",b?"text-[#6B7280]":"text-gray-400"),children:be(S.createdAt)})]}),jsx("p",{className:f("text-sm break-words",b?"text-[#9CA3AF]":"text-gray-600"),children:S.content})]})]},S.id))}):jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[jsx(MessageSquare,{className:f("w-10 h-10 mb-3",b?"text-[#3B4252]":"text-gray-300")}),jsx("p",{className:f("text-sm",b?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"Sin actividad reciente":"No recent activity"})]})}),jsx("div",{className:f("p-4 border-t",b?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-start gap-2",children:[m&&jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:m.color||"#8B5CF6"},children:m.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:f("flex-1 flex items-center gap-2 px-3 py-2 rounded-lg",b?"bg-white/5":"bg-white border border-gray-200"),children:[jsx("input",{type:"text",value:yt,onChange:S=>nt(S.target.value),onKeyDown:S=>{S.key==="Enter"&&!S.shiftKey&&(S.preventDefault(),Ie());},placeholder:n==="es"?"Escribe un comentario...":"Write a comment...",disabled:z||!T,className:f("flex-1 bg-transparent text-sm outline-none",b?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400",(z||!T)&&"opacity-50")}),jsx("button",{onClick:Ie,disabled:z||!yt.trim()||!T,className:f("p-1.5 rounded transition-colors",yt.trim()&&T?"bg-blue-500 text-white hover:bg-blue-600":b?"text-[#6B7280]":"text-gray-400",z&&"opacity-50 cursor-not-allowed"),children:z?jsx("div",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):jsx(Send,{className:"w-4 h-4"})})]})]})})]})]})]})})}function ys(){let[e,t]=useState(()=>dragStore.getState());useEffect(()=>dragStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{dragStore.setState(r);},[]);return [e,a]}function Dr({board:e,callbacks:t,onCardClick:a,renderProps:r,config:o,availableUsers:s=[],className:n,style:c,isLoading:p,error:i,children:u,availableTags:d=[],onCreateTag:g,attachmentsByCard:h,onUploadAttachments:C,onDeleteAttachment:T,comments:m,onAddComment:b,currentUser:y,onTaskOpen:l}){let[w,v]=ys(),[P,x]=useState(null),k=o?.theme||"dark",O=k==="dark"||k==="neutral",M=O?"dark":"",N=useCallback((D,j)=>{t.onCardUpdate?.(D,j);},[t]),H=useCallback((D,j)=>{t.onColumnUpdate?.(D,{title:j});},[t]),L=useCallback(D=>{t.onColumnDelete?.(D);},[t]),Y=["todo","in-progress","completed"],ae=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),ke=useMemo(()=>{let D=new Map;return e.columns.forEach(j=>{let J=j.cardIds.map(R=>e.cards.find(de=>de.id===R)).filter(R=>R!==void 0).sort((R,de)=>R.position-de.position);D.set(j.id,J);}),D},[e.cards,e.columns]),Pe=useMemo(()=>e.cards.map(D=>({id:D.id,name:D.title,startDate:D.startDate?new Date(D.startDate):void 0,endDate:D.endDate?new Date(D.endDate):void 0,progress:D.progress||0,status:D.columnId,priority:D.priority?.toLowerCase(),dependencies:Array.isArray(D.dependencies)?D.dependencies.map(j=>typeof j=="string"?j:j.taskId):[]})),[e.cards]),Ve=useCallback(D=>{let{active:j}=D,J=e.cards.find(R=>R.id===j.id);J&&v({isDragging:true,draggedCardId:J.id,sourceColumnId:J.columnId,targetColumnId:J.columnId});},[e.cards,v]),Je=useCallback(D=>{let{active:j,over:J}=D;if(!J||!e.cards.find(we=>we.id===j.id))return;let de=null;J.data.current?.type==="column"?de=J.id:J.data.current?.type==="card"&&(de=e.cards.find(Me=>Me.id===J.id)?.columnId||null),de&&de!==w.targetColumnId&&v({...w,targetColumnId:de});},[e.cards,w,v]),$=useCallback(async D=>{let{active:j,over:J}=D;if(v({isDragging:false,draggedCardId:null,sourceColumnId:null,targetColumnId:null}),!J)return;let R=e.cards.find(ce=>ce.id===j.id);if(!R)return;let de,we;if(J.data.current?.type==="column"){de=J.id;let ce=ke.get(de)||[];we=as(ce,0);}else {let ce=e.cards.find(Ye=>Ye.id===J.id);if(!ce)return;de=ce.columnId;let We=ke.get(de)||[],Fe=We.findIndex(Ye=>Ye.id===J.id);we=as(We,Fe);}let Me=e.columns.find(ce=>ce.id===de);if(Me&&Me.wipLimit&&Me.wipLimitType==="hard"){let ce=ke.get(de)||[];if(R.columnId!==de&&ce.length>=Me.wipLimit){t.onWipLimitExceeded?.(Me,R);return}}(R.columnId!==de||R.position!==we)&&await t.onCardMove?.(R.id,de,we);},[e.cards,e.columns,ke,t,v]),B=useCallback(D=>{x(D),a?.(D),l?.(D.id);},[a,l]),W=useCallback(D=>{t.onCardUpdate?.(D.id,D),x(D);},[t]);return p?jsx("div",{className:f("asakaa-board",M,n),style:c,children:jsx(pu,{columnCount:3})}):i?jsx("div",{className:f("asakaa-board",M,n),style:c,children:jsx("div",{className:"flex items-center justify-center w-full h-64",children:jsxs("div",{className:"text-center",children:[jsx("p",{className:"text-asakaa-accent-red text-lg font-semibold mb-2",children:"Error loading board"}),jsx("p",{className:"text-asakaa-text-secondary text-sm",children:typeof i=="string"?i:i.message})]})})}):jsxs(Sl,{themeName:k,children:[jsxs(DndContext,{sensors:ae,collisionDetection:closestCorners,onDragStart:Ve,onDragOver:Je,onDragEnd:$,children:[jsxs("div",{className:f("asakaa-board",M,n),style:c,"data-theme":k,children:[e.columns.sort((D,j)=>D.position-j.position).map(D=>{let j=ke.get(D.id)||[],J=!Y.includes(D.id);return jsx(io,{column:D,cards:j,renderCard:r?.renderCard,renderColumn:r?.renderColumn,renderHeader:r?.renderColumnHeader,renderEmptyState:r?.renderEmptyState,onCardClick:B,onCardUpdate:N,onColumnRename:H,onColumnDelete:L,isDeletable:J,availableUsers:s,allCards:e.cards,enableVirtualization:o?.enableVirtualization,cardHeight:o?.cardHeight},D.id)}),u]}),jsx(DragOverlay,{children:w.draggedCardId?jsx(ur,{card:e.cards.find(D=>D.id===w.draggedCardId),render:r?.renderCardOverlay||r?.renderCard,disableDrag:true,className:"opacity-90 rotate-3 shadow-2xl"}):null})]}),jsx(Gr,{task:P,isOpen:!!P,onClose:()=>x(null),onCardUpdate:W,theme:O?"dark":"light",locale:o?.locale==="es"?"es":"en",availableUsers:s,availableTags:d,onCreateTag:g,attachments:P?h?.get(P.id)||[]:[],onUploadAttachments:C,onDeleteAttachment:T,availableTasks:Pe,comments:m,onAddComment:b,currentUser:y})]})}function pu({columnCount:e}){return jsx(Fragment,{children:Array.from({length:e}).map((t,a)=>jsxs("div",{className:"asakaa-column",children:[jsx("div",{className:"asakaa-skeleton h-8 mb-3"}),jsxs("div",{className:"flex flex-col gap-2",children:[jsx("div",{className:"asakaa-skeleton h-24"}),jsx("div",{className:"asakaa-skeleton h-32"}),jsx("div",{className:"asakaa-skeleton h-28"})]})]},a))})}var bu={bgGrid:"#0F1117",bgSecondary:"#1A1D25",border:"rgba(255, 255, 255, 0.1)",borderLight:"rgba(255, 255, 255, 0.05)",textPrimary:"#E5E7EB",textSecondary:"#9CA3AF",textTertiary:"#6B7280",accent:"#3B82F6",accentLight:"rgba(59, 130, 246, 0.15)",hoverBg:"rgba(255, 255, 255, 0.05)"},yu={bgGrid:"#FFFFFF",bgSecondary:"#F9FAFB",border:"rgba(0, 0, 0, 0.1)",borderLight:"rgba(0, 0, 0, 0.05)",textPrimary:"#111827",textSecondary:"#6B7280",textTertiary:"#9CA3AF",accent:"#3B82F6",accentLight:"rgba(59, 130, 246, 0.1)",hoverBg:"rgba(0, 0, 0, 0.05)"},vu={newTask:"Nueva Tarea",selectColumn:"Seleccionar columna",export:"Exportar",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"},xu={newTask:"New Task",selectColumn:"Select column",export:"Export",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"};function ku({columns:e,onSelect:t,theme:a,t:r,createTaskLabel:o}){let[s,n]=useState(false),c=useRef(null);useEffect(()=>{let i=u=>{c.current&&!c.current.contains(u.target)&&n(false);};return s&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[s]);let p=i=>{t(i),n(false);};return jsxs("div",{ref:c,className:"relative",children:[jsxs(motion.button,{onClick:()=>n(!s),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#FFFFFF",fontFamily:"Inter, sans-serif",fontWeight:500,boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"},whileHover:{scale:1.02,boxShadow:"0 4px 12px rgba(59, 130, 246, 0.4)"},whileTap:{scale:.98},children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{children:o||r.newTask}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:s?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:s&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute right-0 mt-2 w-48 rounded-lg overflow-hidden z-50",style:{backgroundColor:a.bgSecondary,border:`1px solid ${a.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsxs("div",{className:"py-1",children:[jsx("div",{className:"px-3 py-2 text-[10px] uppercase tracking-wider",style:{color:a.textTertiary},children:r.selectColumn}),e.sort((i,u)=>i.position-u.position).map((i,u)=>jsxs(motion.button,{onClick:()=>p(i.id),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:u<e.length-1?`1px solid ${a.borderLight}`:"none"},whileHover:{backgroundColor:a.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:u*.03},children:[jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:i.color||a.accent}}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:a.textPrimary},children:i.title}),jsxs("div",{className:"text-[10px] truncate",style:{color:a.textTertiary},children:[i.cardIds.length," ",i.cardIds.length===1?"tarea":"tareas"]})]})]},i.id))]})})})]})}function wu({theme:e,t,onExportCSV:a,onExportJSON:r,onExportExcel:o}){let[s,n]=useState(false),[c,p]=useState(null),i=useRef(null);if(useEffect(()=>{let h=C=>{i.current&&!i.current.contains(C.target)&&n(false);};return s&&document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s]),!(a||r||o))return null;let d=[{id:"csv",label:t.exportCSV,description:"Comma-separated",icon:jsx(FileText,{className:"w-4 h-4"}),handler:a},{id:"json",label:t.exportJSON,description:"Data",icon:jsx(FileJson,{className:"w-4 h-4"}),handler:r},{id:"excel",label:t.exportExcel,description:"Spreadsheet",icon:jsx(FileSpreadsheet,{className:"w-4 h-4"}),handler:o}].filter(h=>h.handler),g=async(h,C)=>{if(C){p(h);try{await C();}catch(T){console.error(`Export ${h} failed:`,T);}finally{p(null),n(false);}}};return jsxs("div",{ref:i,className:"relative",children:[jsxs(motion.button,{onClick:()=>n(!s),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:s?e.accent:e.bgSecondary,border:`1px solid ${s?e.accent:e.borderLight}`,color:s?"#FFFFFF":e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{scale:1.02,backgroundColor:e.accent,color:"#FFFFFF"},whileTap:{scale:.98},children:[jsx(Download,{className:"w-3.5 h-3.5"}),jsx("span",{children:t.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:s?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:s&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute right-0 mt-2 w-44 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:d.map((h,C)=>jsxs(motion.button,{onClick:()=>g(h.id,h.handler),disabled:c!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:C<d.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:C*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:c===h.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):h.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:h.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:h.description})]})]},h.id))})})})]})}function Cu({onClick:e,label:t}){return jsxs(motion.button,{onClick:e,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#FFFFFF",fontFamily:"Inter, sans-serif",fontWeight:500,boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"},whileHover:{scale:1.02,boxShadow:"0 4px 12px rgba(59, 130, 246, 0.4)"},whileTap:{scale:.98},children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{children:t})]})}function xs({columns:e,onCreateTask:t,createTaskLabel:a,theme:r="dark",locale:o="es",useColumnSelector:s=false,onExportCSV:n,onExportJSON:c,onExportExcel:p,translations:i}){let u=r==="dark"?bu:yu,d={...o==="es"?vu:xu,...i},g=n||c||p;return jsx("div",{className:"h-12 px-4 flex items-center justify-end border-b sticky top-0 z-10",style:{backgroundColor:u.bgGrid,borderColor:u.border},children:jsxs("div",{className:"flex items-center gap-3",children:[g&&jsxs(Fragment,{children:[jsx(wu,{theme:u,t:d,onExportCSV:n,onExportJSON:c,onExportExcel:p}),t&&jsx("div",{className:"w-px h-6",style:{backgroundColor:u.borderLight}})]}),t&&(s?jsx(ku,{columns:e,onSelect:t,theme:u,t:d,createTaskLabel:a}):jsx(Cu,{onClick:()=>t(),label:a||d.newTask}))]})})}function ws({onAddColumn:e,className:t,placeholder:a="Nombre de la columna...",buttonLabel:r="Agregar Columna",disabled:o=false}){let[s,n]=useState(false),[c,p]=useState(""),i=useCallback(()=>{let g=c.trim();g&&(e(g),p(""),n(false));},[c,e]),u=useCallback(g=>{g.key==="Enter"?(g.preventDefault(),i()):g.key==="Escape"&&(p(""),n(false));},[i]),d=useCallback(()=>{setTimeout(()=>{c.trim()||n(false);},150);},[c]);return s?jsx("div",{className:f("asakaa-add-column asakaa-add-column--editing",t),children:jsxs("div",{className:"asakaa-add-column__input-wrapper",children:[jsx("input",{type:"text",value:c,onChange:g=>p(g.target.value),onKeyDown:u,onBlur:d,placeholder:a,autoFocus:true,className:"asakaa-add-column__input"}),jsxs("div",{className:"asakaa-add-column__actions",children:[jsx("button",{onClick:i,disabled:!c.trim(),className:"asakaa-add-column__submit",type:"button",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}),jsx("button",{onClick:()=>{p(""),n(false);},className:"asakaa-add-column__cancel",type:"button",children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})}):jsx("div",{className:f("asakaa-add-column",t),children:jsxs("button",{onClick:()=>n(true),disabled:o,className:"asakaa-add-column__button",type:"button",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),r]})})}function Cs({columnId:e,onAddCard:t,availableUsers:a=[],className:r,placeholder:o,buttonLabel:s,disabled:n=false,theme:c="dark",locale:p="es"}){let[i,u]=useState(false),[d,g]=useState(false),[h,C]=useState(""),[T,m]=useState([]),[b,y]=useState(""),[l,w]=useState(""),[v,P]=useState(""),[x,k]=useState(false),[O,M]=useState(false),[N,H]=useState(false),L=useRef(null),Y=useRef(null),ae={placeholder:o||(p==="es"?"Nombre de la tarea...":"Task Name..."),buttonLabel:s||(p==="es"?"Agregar Tarea":"Add Task"),save:p==="es"?"Guardar":"Save",addAssignee:p==="es"?"Agregar asignado":"Add assignee",addDates:p==="es"?"Agregar fechas":"Add dates",addPriority:p==="es"?"Agregar prioridad":"Add priority",startDate:p==="es"?"Inicio":"Start",endDate:p==="es"?"Fin":"End",low:p==="es"?"Baja":"Low",medium:p==="es"?"Media":"Medium",high:p==="es"?"Alta":"High",urgent:p==="es"?"Urgente":"Urgent"},ke=useCallback(()=>{C(""),m([]),y(""),w(""),P(""),k(false),M(false),H(false),u(false);},[]);useEffect(()=>{i&&L.current&&L.current.focus();},[i]),useEffect(()=>{if(!i)return;let B=W=>{Y.current&&!Y.current.contains(W.target)&&(h.trim()||ke());};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[i,h,ke]);let Pe=useCallback(async()=>{let B=h.trim();if(!(!B||d)){g(true);try{await t({name:B,columnId:e,assigneeIds:T.length>0?T:void 0,startDate:b?new Date(b):void 0,endDate:l?new Date(l):void 0,priority:v||void 0}),C(""),m([]),y(""),w(""),P(""),k(!1),M(!1),H(!1),L.current?.focus();}catch(W){console.error("Error creating card:",W);}finally{g(false);}}},[h,e,T,b,l,v,t,d]),Ve=useCallback(B=>{B.key==="Enter"&&!B.shiftKey?(B.preventDefault(),Pe()):B.key==="Escape"&&ke();},[Pe,ke]),Je=useCallback(B=>{m(W=>W.includes(B)?W.filter(D=>D!==B):[...W,B]);},[]),$=c==="dark";return i?jsxs("div",{ref:Y,className:f("rounded-lg overflow-hidden shadow-lg",$?"bg-[#1e1e2e]":"bg-white",r),style:{border:"2px solid #10b981"},children:[jsxs("div",{className:"p-3",children:[jsx("input",{ref:L,type:"text",value:h,onChange:B=>C(B.target.value),onKeyDown:Ve,placeholder:ae.placeholder,disabled:d,className:f("w-full px-0 py-1 text-sm font-medium border-0 bg-transparent focus:outline-none focus:ring-0",$?"text-gray-100 placeholder-gray-500":"text-gray-800 placeholder-gray-400")}),jsxs("div",{className:"flex items-center gap-1 mt-3",children:[a.length>0&&jsxs("button",{onClick:()=>k(!x),className:f("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",x||T.length>0?"bg-emerald-500/20 text-emerald-400":$?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:ae.addAssignee,children:[jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),T.length>0&&jsx("span",{className:"ml-0.5",children:T.length})]}),jsx("button",{onClick:()=>M(!O),className:f("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",O||b||l?"bg-blue-500/20 text-blue-400":$?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:ae.addDates,children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})}),jsx("button",{onClick:()=>H(!N),className:f("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",N||v?v==="urgent"?"bg-red-500/20 text-red-400":v==="high"?"bg-orange-500/20 text-orange-400":v==="medium"?"bg-yellow-500/20 text-yellow-400":v==="low"?"bg-green-500/20 text-green-400":"bg-orange-500/20 text-orange-400":$?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:ae.addPriority,children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"}),jsx("line",{x1:"4",y1:"22",x2:"4",y2:"15"})]})}),jsx("div",{className:"flex-1"}),jsx("button",{onClick:Pe,disabled:!h.trim()||d,className:f("px-3 py-1.5 rounded-md text-xs font-medium text-white transition-all","bg-emerald-500 hover:bg-emerald-600","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-emerald-500"),type:"button",children:d?jsx("div",{className:"w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin"}):ae.save})]})]}),x&&a.length>0&&jsx("div",{className:f("px-3 pb-3 pt-0","border-t",$?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex flex-wrap gap-1.5 pt-3",children:a.map(B=>jsxs("button",{onClick:()=>Je(B.id),className:f("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs transition-all",T.includes(B.id)?"bg-emerald-500 text-white":$?"bg-[#2a2a3e] text-gray-300 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-700 hover:bg-gray-200"),type:"button",children:[B.avatar?jsx("img",{src:B.avatar,alt:B.name,className:"w-4 h-4 rounded-full"}):jsx("div",{className:f("w-4 h-4 rounded-full flex items-center justify-center text-[10px] font-medium",T.includes(B.id)?"bg-emerald-600 text-white":"bg-emerald-500 text-white"),children:B.name.charAt(0).toUpperCase()}),jsx("span",{children:B.name.split(" ")[0]})]},B.id))})}),O&&jsx("div",{className:f("px-3 pb-3 pt-0","border-t",$?"border-[#3a3a4e]":"border-gray-200"),children:jsxs("div",{className:"grid grid-cols-2 gap-2 pt-3",children:[jsxs("div",{children:[jsx("label",{className:f("block text-[10px] uppercase tracking-wide mb-1",$?"text-gray-500":"text-gray-400"),children:ae.startDate}),jsx("input",{type:"date",value:b,onChange:B=>y(B.target.value),className:f("w-full px-2 py-1.5 rounded text-xs border",$?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]}),jsxs("div",{children:[jsx("label",{className:f("block text-[10px] uppercase tracking-wide mb-1",$?"text-gray-500":"text-gray-400"),children:ae.endDate}),jsx("input",{type:"date",value:l,onChange:B=>w(B.target.value),className:f("w-full px-2 py-1.5 rounded text-xs border",$?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]})]})}),N&&jsx("div",{className:f("px-3 pb-3 pt-0","border-t",$?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex gap-1.5 pt-3",children:["low","medium","high","urgent"].map(B=>jsx("button",{onClick:()=>P(v===B?"":B),className:f("flex-1 px-2 py-1.5 rounded text-xs font-medium transition-all",v===B?`${{low:"bg-green-500",medium:"bg-yellow-500",high:"bg-orange-500",urgent:"bg-red-500"}[B]} text-white`:$?"bg-[#2a2a3e] text-gray-400 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-600 hover:bg-gray-200"),type:"button",children:ae[B]},B))})})]}):jsxs("button",{onClick:()=>u(true),disabled:n,className:f("w-full flex items-center gap-2 px-3 py-2 rounded-lg transition-all duration-200","text-emerald-500 hover:text-emerald-400",$?"hover:bg-[#2a2a3e]":"hover:bg-gray-100",n&&"opacity-50 cursor-not-allowed",r),type:"button",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),jsx("span",{className:"text-sm font-medium",children:ae.buttonLabel})]})}var Po=class extends BaseViewAdapter{constructor(a={}){super();this.id="kanban";this.name="Kanban Board";this.version="1.0.0";this.description="";this.icon="";this.supportedExports=["json","csv","pdf","png"];this.root=null;this.description="Interactive Kanban board with drag & drop, filters, and real-time updates",this.icon="\u{1F4CB}",this.kanbanConfig=a,this.options={animations:a.viewOptions?.animations??true,virtualScrolling:a.viewOptions?.virtualScrolling??false,theme:a.viewOptions?.theme??"dark",readonly:a.viewOptions?.readonly??false};}mount(a,r){this.isMounted()&&(console.warn("[KanbanViewAdapter] Already mounted, unmounting first"),this.unmount()),this.container=a,this.data=r,this.root=createRoot(a),this.render(),this.emit("view:mounted",{viewId:this.id,timestamp:Date.now()});}unmount(){this.isMounted()&&(this.emit("view:unmounted",{viewId:this.id,timestamp:Date.now()}),this.root&&(this.root.unmount(),this.root=null),this.container&&(this.container.innerHTML="",this.container=null),this.data=null);}update(a){if(!this.isMounted()){console.warn("[KanbanViewAdapter] Not mounted, cannot update");return}this.data=a,this.render(),this.emit("view:updated",{viewId:this.id,data:a});}configure(a){this.options={...this.options,...a},this.isMounted()&&this.render();}async export(a){if(!this.data)throw new Error("No data to export");switch(a){case "json":return JSON.stringify(this.data,null,2);case "csv":return this.exportToCSV();case "pdf":return this.exportToPDF();case "png":return this.exportToPNG();default:throw new Error(`Unsupported export format: ${a}`)}}render(){if(!this.root||!this.data)return;let a={id:this.data.board?.id||"board-1",title:this.data.board?.title||"Untitled Board",columns:this.data.columns,cards:this.data.cards};this.root.render(jsx(Dr,{board:a,callbacks:this.kanbanConfig.callbacks||{},onCardClick:this.kanbanConfig.onCardClick,renderProps:this.kanbanConfig.renderProps,config:this.kanbanConfig.config,availableUsers:this.kanbanConfig.availableUsers,className:this.kanbanConfig.className,style:this.kanbanConfig.style}));}exportToCSV(){if(!this.data)return "";let a=[["Card ID","Title","Column","Description","Labels","Assignees","Due Date","Position"]];return this.data.cards.forEach(r=>{let o=this.data.columns.find(s=>s.id===r.columnId);a.push([r.id,r.title,o?.title||"",r.description||"",r.labels?.join(", ")||"",r.assignedUserIds?.join(", ")||r.assigneeId||"",r.dueDate?.toString()||"",r.position.toString()]);}),a.map(r=>r.map(o=>`"${o}"`).join(",")).join(`
5
+ `)}async exportToPDF(){throw new Error("PDF export not yet implemented in ViewAdapter")}async exportToPNG(){if(!this.container)throw new Error("View not mounted");let r=await(await import('html2canvas')).default(this.container,{backgroundColor:this.options.theme==="dark"?"#1a1a1a":"#ffffff",scale:2});return new Promise((o,s)=>{r.toBlob(n=>{n?o(n):s(new Error("Failed to create PNG blob"));},"image/png");})}};function md(e={}){return new Po(e)}var co=class extends Component{constructor(a){super(a);this.resetError=()=>{this.setState({hasError:false,error:null,errorInfo:null});};this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(a){return {hasError:true,error:a}}componentDidCatch(a,r){let{onError:o,componentName:s}=this.props;if(process.env.NODE_ENV==="development"&&(console.error(`Error in ${s||"Component"}:`,a),console.error("Error Info:",r)),this.setState({errorInfo:r}),o)try{o(a,r);}catch(n){console.error("Error in error handler:",n);}}render(){let{hasError:a,error:r}=this.state,{children:o,fallback:s,componentName:n}=this.props;return a&&r?s?s(r,this.resetError):jsx("div",{className:"p-6 rounded-lg border",style:{background:"linear-gradient(135deg, #2d1b1b 0%, #1a1a1a 100%)",borderColor:"rgba(239, 68, 68, 0.3)"},children:jsxs("div",{className:"flex items-start gap-3",children:[jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"#EF4444",strokeWidth:"2"}),jsx("path",{d:"M12 8V12",stroke:"#EF4444",strokeWidth:"2",strokeLinecap:"round"}),jsx("circle",{cx:"12",cy:"16",r:"1",fill:"#EF4444"})]}),jsxs("div",{className:"flex-1",children:[jsx("h3",{className:"text-lg font-semibold text-red-400 mb-1",children:n?`Error in ${n}`:"Something went wrong"}),jsx("p",{className:"text-sm text-white/70 mb-3",children:r.message||"An unexpected error occurred"}),process.env.NODE_ENV==="development"&&jsxs("details",{className:"mb-3",children:[jsx("summary",{className:"text-xs text-white/50 cursor-pointer hover:text-white/70 mb-2",children:"Error Details (Development Only)"}),jsx("pre",{className:"text-xs text-white/60 bg-black/30 p-3 rounded overflow-auto max-h-48",children:r.stack})]}),jsx("button",{onClick:this.resetError,className:"px-4 py-2 rounded-lg text-sm font-medium transition-all hover:bg-red-600/20 border border-red-500/30",style:{color:"#EF4444"},children:"Try Again"})]})]})}):o}};function Ts(e,t){let a=r=>jsx(co,{...t,children:jsx(e,{...r})});return a.displayName=`withErrorBoundary(${e.displayName||e.name||"Component"})`,a}function Ds({board:e,onCreateCard:t,onNavigateToCard:a,onSearch:r,onChangePriority:o,onAssignUser:s,onGeneratePlan:n,onPredictRisks:c,onOpenAIUsage:p,shortcut:i="k",className:u=""}){let[d,g]=useState(false),[h,C]=useState(""),[T,m]=useState("home"),[b,y]=useState(""),[l,w]=useState("");useEffect(()=>{let k=O=>{(O.metaKey||O.ctrlKey)&&O.key===i&&(O.preventDefault(),g(M=>!M)),O.key==="Escape"&&(g(false),m("home"),C(""));};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[i]),useEffect(()=>{d||(m("home"),C(""),y(""),w(""));},[d]);let v=useCallback(()=>{g(false);},[]),P=useCallback(k=>{let[O,M]=k.split(":");switch(O){case "create-card":m("create-card");break;case "create-card-in":y(M||"");break;case "navigate":M?(a?.(M),v()):m("navigate");break;case "search":r?.(h),v();break;case "priority":m("priority");break;case "set-priority":l&&M&&(o?.(l,M),v());break;case "assign":m("assign");break;case "assign-user":l&&M&&(s?.(l,M),v());break;case "ai":m("ai");break;case "ai-generate-plan":n?.(),v();break;case "ai-predict-risks":c?.(),v();break;case "ai-usage":p?.(),v();break;case "back":m("home");break;}},[h,l,t,a,r,o,s,n,c,p,v]),x=useCallback(()=>{b&&h.trim()&&(t?.(b,h.trim()),v());},[b,h,t,v]);return d?jsx(gt,{children:jsx("div",{className:"command-palette-overlay",onClick:v,children:jsx("div",{className:`command-palette ${u}`,onClick:k=>k.stopPropagation(),children:jsxs(Command,{value:h,onValueChange:C,label:"Command Menu",children:[jsxs("div",{className:"command-palette-header",children:[jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"11",cy:"11",r:"8"}),jsx("path",{d:"m21 21-4.35-4.35"})]}),jsx(Command.Input,{placeholder:T==="create-card"&&b?"Type card title and press Enter...":T==="create-card"?"Select a column first...":"Type a command or search...",className:"command-palette-input",onKeyDown:k=>{k.key==="Enter"&&T==="create-card"&&b&&x();}}),jsxs("div",{className:"command-palette-shortcut",children:[jsx("kbd",{children:navigator.platform.includes("Mac")?"\u2318":"Ctrl"}),jsx("kbd",{children:"K"})]})]}),jsxs(Command.List,{className:"command-palette-list",children:[jsx(Command.Empty,{className:"command-palette-empty",children:"No results found."}),T==="home"&&jsxs(Fragment,{children:[jsxs(Command.Group,{heading:"Actions",className:"command-palette-group",children:[jsxs(Command.Item,{value:"create-card",onSelect:P,className:"command-palette-item",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsx("path",{d:"M12 8v8m-4-4h8"})]}),jsx("span",{children:"Create Card"}),jsx("div",{className:"command-palette-item-shortcut",children:"C"})]}),jsxs(Command.Item,{value:"navigate",onSelect:P,className:"command-palette-item",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 16 16 12 12 8"}),jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),jsx("span",{children:"Navigate to Card"}),jsx("div",{className:"command-palette-item-shortcut",children:"G"})]}),jsxs(Command.Item,{value:"search",onSelect:P,className:"command-palette-item",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"11",cy:"11",r:"8"}),jsx("path",{d:"m21 21-4.35-4.35"})]}),jsx("span",{children:"Search Cards"}),jsx("div",{className:"command-palette-item-shortcut",children:"/"})]})]}),jsx(Command.Group,{heading:"AI Features",className:"command-palette-group",children:jsxs(Command.Item,{value:"ai",onSelect:P,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),jsx("span",{children:"AI Commands"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]})}),jsx(Command.Group,{heading:"Cards",className:"command-palette-group",children:e.cards.slice(0,5).map(k=>jsxs(Command.Item,{value:`navigate:${k.id}`,onSelect:P,className:"command-palette-item",children:[jsx("div",{className:"command-palette-item-dot",style:{background:k.priority==="URGENT"?"#EF4444":k.priority==="HIGH"?"#F59E0B":k.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:k.title}),k.labels&&k.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:k.labels.slice(0,2).map(O=>jsx("span",{className:"command-palette-item-label",children:O},O))})]},k.id))})]}),T==="create-card"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:P,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),jsx("span",{children:"Back"})]}),jsx(Command.Group,{heading:"Select Column",className:"command-palette-group",children:e.columns.map(k=>jsxs(Command.Item,{value:`create-card-in:${k.id}`,onSelect:P,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("rect",{x:"3",y:"3",width:"7",height:"18",rx:"1"})}),jsx("span",{children:k.title}),jsxs("div",{className:"command-palette-item-count",children:[k.cardIds.length," cards"]})]},k.id))})]}),T==="navigate"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:P,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),jsx("span",{children:"Back"})]}),jsx(Command.Group,{heading:"All Cards",className:"command-palette-group",children:e.cards.map(k=>{let O=e.columns.find(M=>M.id===k.columnId);return jsxs(Command.Item,{value:`navigate:${k.id}`,onSelect:P,className:"command-palette-item",keywords:[k.title,k.description||"",...k.labels||[]],children:[jsx("div",{className:"command-palette-item-dot",style:{background:k.priority==="URGENT"?"#EF4444":k.priority==="HIGH"?"#F59E0B":k.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsxs("div",{className:"command-palette-item-content",children:[jsx("div",{children:k.title}),jsx("div",{className:"command-palette-item-meta",children:O?.title})]}),k.labels&&k.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:k.labels.slice(0,2).map(M=>jsx("span",{className:"command-palette-item-label",children:M},M))})]},k.id)})})]}),T==="ai"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:P,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),jsx("span",{children:"Back"})]}),jsxs(Command.Group,{heading:"AI Features",className:"command-palette-group",children:[jsxs(Command.Item,{value:"ai-generate-plan",onSelect:P,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),jsx("span",{children:"Generate Project Plan"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]}),jsxs(Command.Item,{value:"ai-predict-risks",onSelect:P,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),jsx("span",{children:"Predict Risks"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]}),jsxs(Command.Item,{value:"ai-usage",onSelect:P,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"12",y1:"1",x2:"12",y2:"23"}),jsx("path",{d:"M17 5H9.5a3.5 3.5 0 000 7h5a3.5 3.5 0 010 7H6"})]}),jsx("span",{children:"AI Usage & Costs"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]})]})]})]}),jsxs("div",{className:"command-palette-footer",children:[jsxs("div",{className:"command-palette-footer-hint",children:[jsx("kbd",{children:"\u2191"}),jsx("kbd",{children:"\u2193"}),jsx("span",{children:"Navigate"})]}),jsxs("div",{className:"command-palette-footer-hint",children:[jsx("kbd",{children:"Enter"}),jsx("span",{children:"Select"})]}),jsxs("div",{className:"command-palette-footer-hint",children:[jsx("kbd",{children:"Esc"}),jsx("span",{children:"Close"})]})]})]})})})}):null}function gd(e,t,a,r,o){let s=document.getElementById("attachment-lightbox-native");s&&s.remove();let n=document.createElement("div");n.id="attachment-lightbox-native",n.className="attachment-lightbox",n.style.cssText=`
6
6
  position: fixed !important;
7
7
  inset: 0 !important;
8
8
  z-index: 2147483647 !important;
@@ -55,7 +55,7 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
55
55
  border: none !important;
56
56
  cursor: pointer !important;
57
57
  opacity: 0.5 !important;
58
- `,g.onmouseenter=()=>{g.style.opacity="1";},g.onmouseleave=()=>{g.style.opacity="0.5";},g.onclick=C=>{C.stopPropagation();let T=r>0?r-1:a.length-1;i(),o(T);};let f=document.createElement("button");f.className="attachment-lightbox-nav-area attachment-lightbox-nav-next",f.innerHTML='<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M9 18L15 12L9 6" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',f.style.cssText=`
58
+ `,g.onmouseenter=()=>{g.style.opacity="1";},g.onmouseleave=()=>{g.style.opacity="0.5";},g.onclick=C=>{C.stopPropagation();let T=r>0?r-1:a.length-1;i(),o(T);};let h=document.createElement("button");h.className="attachment-lightbox-nav-area attachment-lightbox-nav-next",h.innerHTML='<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M9 18L15 12L9 6" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',h.style.cssText=`
59
59
  position: absolute !important;
60
60
  right: 0 !important;
61
61
  top: 0 !important;
@@ -68,7 +68,7 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
68
68
  border: none !important;
69
69
  cursor: pointer !important;
70
70
  opacity: 0.5 !important;
71
- `,f.onmouseenter=()=>{f.style.opacity="1";},f.onmouseleave=()=>{f.style.opacity="0.5";},f.onclick=C=>{C.stopPropagation();let T=r<a.length-1?r+1:0;i(),o(T);},n.appendChild(d),n.appendChild(g),n.appendChild(f);}n.appendChild(c),n.appendChild(p),document.body.appendChild(n),setTimeout(()=>{p.style.transition="opacity 0.5s ease",p.style.opacity="0";},2e3);}function Pu(e){if(e===0)return "0 Bytes";let t=1024,a=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,r)*100)/100+" "+a[r]}function Mu(e){return e.startsWith("image/")?"\u{1F5BC}\uFE0F":e.startsWith("video/")?"\u{1F3A5}":e.startsWith("audio/")?"\u{1F3B5}":e.includes("pdf")?"\u{1F4C4}":e.includes("word")||e.includes("document")?"\u{1F4DD}":e.includes("sheet")||e.includes("excel")?"\u{1F4CA}":e.includes("presentation")||e.includes("powerpoint")?"\u{1F4FD}\uFE0F":e.includes("zip")||e.includes("rar")||e.includes("compressed")?"\u{1F5DC}\uFE0F":e.includes("text")?"\u{1F4C3}":"\u{1F4CE}"}function Ns(e){return e.startsWith("image/")}function sr({attachments:e=[],onUpload:t,onDelete:a,maxSizeMB:r=10,allowedTypes:o,maxFiles:s=10}){let[n,c]=useState(false),[p,i]=useState(false),[u,d]=useState(null),g=useRef(null),f=useRef(e);f.current=e;let C=useCallback((k,O)=>{O.preventDefault(),O.stopPropagation();let A=f.current.filter(L=>Ns(L.type)),N=A.findIndex(L=>L.id===k.id),H=L=>{let q=f.current.filter(ke=>Ns(ke.type)),ae=q[L];ae&&gd(ae.url,ae.name,q,L,H);};gd(k.url,k.name,A,N,H);},[]),T=useCallback(k=>{let O=[],A=[];return e.length+k.length>s?(A.push(`Maximum ${s} files allowed`),{valid:O,errors:A}):(k.forEach(N=>{if(N.size/1048576>r){A.push(`${N.name} is too large (max ${r}MB)`);return}if(o&&!o.some(L=>N.type.match(L))){A.push(`${N.name} has invalid file type`);return}O.push(N);}),{valid:O,errors:A})},[e.length,s,r,o]),m=useCallback(async k=>{let{valid:O,errors:A}=T(k);if(A.length>0){d(A.join(", ")),setTimeout(()=>d(null),5e3);return}if(O.length!==0){i(true),d(null);try{await t?.(O);}catch(N){d(N instanceof Error?N.message:"Upload failed"),setTimeout(()=>d(null),5e3);}finally{i(false);}}},[T,t]),b=useCallback(k=>{k.preventDefault(),k.stopPropagation(),c(true);},[]),y=useCallback(k=>{k.preventDefault(),k.stopPropagation(),c(false);},[]),l=useCallback(k=>{k.preventDefault(),k.stopPropagation();},[]),w=useCallback(k=>{k.preventDefault(),k.stopPropagation(),c(false);let O=Array.from(k.dataTransfer.files);m(O);},[m]),v=useCallback(k=>{let O=k.target.files?Array.from(k.target.files):[];m(O),g.current&&(g.current.value="");},[m]),S=useCallback(()=>{g.current?.click();},[]),x=useCallback(k=>{confirm("Are you sure you want to delete this attachment?")&&a?.(k);},[a]);return jsxs("div",{className:"attachment-uploader",children:[jsxs("div",{className:`attachment-dropzone ${n?"dragging":""} ${p?"uploading":""}`,onDragEnter:b,onDragLeave:y,onDragOver:l,onDrop:w,onClick:S,children:[jsx("input",{ref:g,type:"file",multiple:true,onChange:v,style:{display:"none"},accept:o?.join(",")}),jsx("div",{className:"attachment-dropzone-content",children:p?jsxs(Fragment,{children:[jsx("div",{className:"attachment-spinner"}),jsx("p",{className:"attachment-dropzone-text",children:"Uploading..."})]}):jsxs(Fragment,{children:[jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"attachment-dropzone-icon",children:[jsx("path",{d:"M21 15V19C21 19.5304 20.7893 20.0391 20.4142 20.4142C20.0391 20.7893 19.5304 21 19 21H5C4.46957 21 3.96086 20.7893 3.58579 20.4142C3.21071 20.0391 3 19.5304 3 19V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M17 8L12 3L7 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M12 3V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),jsx("p",{className:"attachment-dropzone-text",children:n?"Drop files here":"Drag & drop files here"}),jsx("p",{className:"attachment-dropzone-subtext",children:"or click to browse"}),jsxs("p",{className:"attachment-dropzone-info",children:["Max ",r,"MB \u2022 ",e.length,"/",s," files"]})]})})]}),u&&jsxs("div",{className:"attachment-error",children:[jsx("span",{className:"attachment-error-icon",children:"\u26A0\uFE0F"}),jsx("span",{className:"attachment-error-text",children:u})]}),e.length>0&&jsx("div",{className:"attachment-list",children:e.map(k=>jsxs("div",{className:"attachment-item",children:[jsx("div",{className:"attachment-preview",children:Ns(k.type)&&k.url?jsxs("button",{type:"button",className:"attachment-thumbnail-btn",onClick:O=>C(k,O),title:"Click to view full size",children:[jsx("img",{src:k.thumbnailUrl||k.url,alt:k.name,className:"attachment-thumbnail"}),jsx("div",{className:"attachment-thumbnail-overlay",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M9 21H3V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M21 3L14 10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M3 21L10 14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]}):jsx("div",{className:"attachment-icon",children:Mu(k.type)})}),jsxs("div",{className:"attachment-info",children:[jsx("a",{href:k.url,target:"_blank",rel:"noopener noreferrer",className:"attachment-name",title:k.name,children:k.name}),jsxs("div",{className:"attachment-meta",children:[jsx("span",{className:"attachment-size",children:Pu(k.size)}),jsx("span",{className:"attachment-separator",children:"\u2022"}),jsx("span",{className:"attachment-date",children:new Date(k.uploadedAt).toLocaleDateString()})]})]}),jsx("button",{onClick:()=>x(k.id),className:"attachment-delete",title:"Delete attachment",type:"button",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},k.id))})]})}function Ds({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:c=[],aiInsights:p=[],attachments:i=[],onAddComment:u,onDeleteComment:d,onUploadAttachments:g,onDeleteAttachment:f,onSuggestAssignee:C,onGenerateSubtasks:T,onEstimateEffort:m,currentUserId:b="user-1"}){let[y,l]=useState("details"),[w,v]=useState(false),[S,x]=useState({}),[k,O]=useState(""),[A,N]=useState(false),[H,L]=useState({});if(!t||!e)return null;let q=useCallback(()=>{v(false),x({}),l("details"),O(""),L({}),a();},[a]),ae=useCallback(()=>{r&&Object.keys(S).length>0&&(r(e.id,S),x({}),v(false));},[e.id,S,r]),ke=useCallback(()=>{o&&window.confirm("Are you sure you want to delete this card?")&&(o(e.id),q());},[e.id,o,q]),Fe=useCallback(()=>{u&&k.trim()&&(u(e.id,k.trim()),O(""));},[e.id,k,u]),Ve=useCallback(async()=>{if(C){N(true);try{let D=await C(e);L(Y=>({...Y,assignees:D}));}catch(D){console.error("Failed to suggest assignee:",D);}finally{N(false);}}},[e,C]),Je=useCallback(async()=>{if(T){N(true);try{let D=await T(e);L(Y=>({...Y,subtasks:D}));}catch(D){console.error("Failed to generate subtasks:",D);}finally{N(false);}}},[e,T]),$=useCallback(async()=>{if(m){N(true);try{let D=await m(e);L(Y=>({...Y,effort:D}));}catch(D){console.error("Failed to estimate effort:",D);}finally{N(false);}}},[e,m]),B={...e,...S},W=s.filter(D=>B.assignedUserIds?.includes(D.id));return jsx(ut,{children:jsx("div",{className:"card-detail-overlay",onClick:q,children:jsxs("div",{className:"card-detail-modal",onClick:D=>D.stopPropagation(),children:[jsxs("div",{className:"card-detail-header",children:[jsxs("div",{className:"card-detail-header-left",children:[jsx("div",{className:"card-detail-priority-dot",style:{background:B.priority==="URGENT"?"#EF4444":B.priority==="HIGH"?"#F59E0B":B.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),w?jsx("input",{type:"text",value:S.title??B.title,onChange:D=>x({...S,title:D.target.value}),className:"card-detail-title-input",placeholder:"Card title"}):jsx("h2",{className:"card-detail-title",children:B.title})]}),jsxs("div",{className:"card-detail-header-actions",children:[w?jsxs(Fragment,{children:[jsx("button",{onClick:ae,className:"card-detail-btn card-detail-btn-primary",children:"Save"}),jsx("button",{onClick:()=>{v(false),x({});},className:"card-detail-btn",children:"Cancel"})]}):jsxs("button",{onClick:()=>v(true),className:"card-detail-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]}),"Edit"]}),jsxs("button",{onClick:ke,className:"card-detail-btn card-detail-btn-danger",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})]}),"Delete"]}),jsx("button",{onClick:q,className:"card-detail-btn-close",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),jsxs("div",{className:"card-detail-tabs",children:[jsxs("button",{onClick:()=>l("details"),className:`card-detail-tab ${y==="details"?"active":""}`,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),jsx("polyline",{points:"10 9 9 9 8 9"})]}),"Details"]}),jsxs("button",{onClick:()=>l("comments"),className:`card-detail-tab ${y==="comments"?"active":""}`,children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),"Comments",n.length>0&&jsx("span",{className:"card-detail-tab-badge",children:n.length})]}),jsxs("button",{onClick:()=>l("activity"),className:`card-detail-tab ${y==="activity"?"active":""}`,children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})}),"Activity",c.length>0&&jsx("span",{className:"card-detail-tab-badge",children:c.length})]}),jsxs("button",{onClick:()=>l("attachments"),className:`card-detail-tab ${y==="attachments"?"active":""}`,children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children: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"})}),"Attachments",i.length>0&&jsx("span",{className:"card-detail-tab-badge",children:i.length})]}),jsxs("button",{onClick:()=>l("ai"),className:`card-detail-tab ${y==="ai"?"active":""}`,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),"AI Insights",jsx("span",{className:"card-detail-tab-badge card-detail-tab-badge-ai",children:"AI"})]})]}),jsxs("div",{className:"card-detail-content",children:[y==="details"&&jsxs("div",{className:"card-detail-details",children:[jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Description"}),w?jsx("textarea",{value:S.description??B.description??"",onChange:D=>x({...S,description:D.target.value}),className:"card-detail-textarea",placeholder:"Add a description...",rows:4}):jsx("p",{className:"card-detail-text",children:B.description||"No description"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Assigned To"}),w?jsx("select",{multiple:true,value:S.assignedUserIds??B.assignedUserIds??[],onChange:D=>{let Y=Array.from(D.target.selectedOptions,J=>J.value);x({...S,assignedUserIds:Y});},className:"card-detail-textarea",style:{height:"120px",padding:"8px 12px"},children:s.map(D=>jsx("option",{value:D.id,children:D.name},D.id))}):jsx("div",{className:"card-detail-users",children:W.length>0?W.map(D=>jsxs("div",{className:"card-detail-user",children:[jsx("div",{className:"card-detail-user-avatar",style:{background:D.color},children:D.initials}),jsx("span",{children:D.name})]},D.id)):jsx("span",{className:"card-detail-empty",children:"Unassigned"})})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Priority"}),w?jsxs("select",{value:S.priority??B.priority??"",onChange:D=>x({...S,priority:D.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"},children:[jsx("option",{value:"",children:"None"}),jsx("option",{value:"LOW",children:"LOW"}),jsx("option",{value:"MEDIUM",children:"MEDIUM"}),jsx("option",{value:"HIGH",children:"HIGH"}),jsx("option",{value:"URGENT",children:"URGENT"})]}):jsxs("div",{className:"card-detail-priority",children:[jsx("div",{className:"card-detail-priority-dot",style:{background:B.priority==="URGENT"?"#EF4444":B.priority==="HIGH"?"#F59E0B":B.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:B.priority||"None"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Labels"}),jsx("div",{className:"card-detail-labels",children:B.labels&&B.labels.length>0?B.labels.map(D=>jsx("span",{className:"card-detail-label-tag",children:D},D)):jsx("span",{className:"card-detail-empty",children:"No labels"})})]}),jsxs("div",{className:"card-detail-section-row",children:[jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Start Date"}),w?jsx("input",{type:"date",value:S.startDate?new Date(S.startDate).toISOString().split("T")[0]:B.startDate?new Date(B.startDate).toISOString().split("T")[0]:"",onChange:D=>x({...S,startDate:D.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:B.startDate?new Date(B.startDate).toLocaleDateString():"Not set"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"End Date"}),w?jsx("input",{type:"date",value:S.endDate?new Date(S.endDate).toISOString().split("T")[0]:B.endDate?new Date(B.endDate).toISOString().split("T")[0]:"",onChange:D=>x({...S,endDate:D.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:B.endDate?new Date(B.endDate).toLocaleDateString():"Not set"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Estimated Hours"}),w?jsx("input",{type:"number",min:"0",step:"0.5",value:S.estimatedTime??B.estimatedTime??"",onChange:D=>x({...S,estimatedTime:D.target.value?parseFloat(D.target.value):void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"},placeholder:"Enter hours"}):jsx("span",{className:"card-detail-text",children:B.estimatedTime||"Not estimated"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Dependencies"}),jsx("div",{className:"card-detail-dependencies",children:B.dependencies&&B.dependencies.length>0?B.dependencies.map(D=>{let Y=typeof D=="string"?D:D.taskId;return jsxs("span",{className:"card-detail-dependency",children:["Card #",Y.slice(-4)]},Y)}):jsx("span",{className:"card-detail-empty",children:"No dependencies"})})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Created"}),jsx("span",{className:"card-detail-text",children:B.createdAt?new Date(B.createdAt).toLocaleString():"Unknown"})]})]}),y==="comments"&&jsxs("div",{className:"card-detail-comments",children:[jsxs("div",{className:"card-detail-comment-form",children:[jsx("textarea",{value:k,onChange:D=>O(D.target.value),className:"card-detail-comment-textarea",placeholder:"Write a comment...",rows:3}),jsx("button",{onClick:Fe,disabled:!k.trim(),className:"card-detail-btn card-detail-btn-primary",children:"Add Comment"})]}),jsx("div",{className:"card-detail-comments-list",children:n.length>0?n.map(D=>{let Y=s.find(J=>J.id===D.authorId);return jsxs("div",{className:"card-detail-comment",children:[jsxs("div",{className:"card-detail-comment-header",children:[jsxs("div",{className:"card-detail-comment-author",children:[Y&&jsx("div",{className:"card-detail-user-avatar",style:{background:Y.color},children:Y.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-comment-author-name",children:Y?.name||"Unknown"}),jsx("div",{className:"card-detail-comment-time",children:new Date(D.createdAt).toLocaleString()})]})]}),d&&jsx("button",{onClick:()=>d(D.id),className:"card-detail-comment-delete",children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})]})})]}),jsx("p",{className:"card-detail-comment-content",children:D.content})]},D.id)}):jsxs("div",{className:"card-detail-empty-state",children:[jsx("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),jsx("p",{children:"No comments yet"}),jsx("span",{children:"Be the first to comment"})]})})]}),y==="activity"&&jsx("div",{className:"card-detail-activity",children:c.length>0?jsx("div",{className:"card-detail-activity-list",children:c.map(D=>{let Y=s.find(J=>J.id===D.userId);return jsxs("div",{className:"card-detail-activity-item",children:[jsxs("div",{className:"card-detail-activity-icon",children:[D.type.includes("CREATED")&&"\u2795",D.type.includes("UPDATED")&&"\u270F\uFE0F",D.type.includes("MOVED")&&"\u27A1\uFE0F",D.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",D.type.includes("COMMENT")&&"\u{1F4AC}",D.type.includes("ASSIGNED")&&"\u{1F464}",D.type.includes("PRIORITY")&&"\u{1F3AF}",D.type.includes("LABEL")&&"\u{1F3F7}\uFE0F",D.type.includes("ATTACHMENT")&&"\u{1F4CE}"]}),jsxs("div",{className:"card-detail-activity-content",children:[jsxs("div",{className:"card-detail-activity-text",children:[jsx("strong",{children:Y?.name||"Unknown"})," ",D.type.replace(/_/g," ").toLowerCase(),D.newValue&&jsxs("span",{className:"card-detail-activity-value",children:[" ","to ",jsx("strong",{children:D.newValue})]})]}),jsx("div",{className:"card-detail-activity-time",children:new Date(D.timestamp).toLocaleString()})]})]},D.id)})}):jsxs("div",{className:"card-detail-empty-state",children:[jsx("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})}),jsx("p",{children:"No activity yet"}),jsx("span",{children:"Activity will appear here"})]})}),y==="attachments"&&jsx("div",{className:"card-detail-attachments",children:jsx(sr,{cardId:e.id,attachments:i,onUpload:g?D=>g(e.id,D):void 0,onDelete:f,currentUserId:b,maxSizeMB:10,maxFiles:20})}),y==="ai"&&jsxs("div",{className:"card-detail-ai",children:[jsxs("div",{className:"card-detail-ai-actions",children:[jsx("h3",{className:"card-detail-ai-heading",children:"AI-Powered Suggestions"}),jsxs("button",{onClick:Ve,disabled:A||!C,className:"card-detail-ai-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),"Suggest Best Assignee"]}),jsxs("button",{onClick:Je,disabled:A||!T,className:"card-detail-ai-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"8",y1:"6",x2:"21",y2:"6"}),jsx("line",{x1:"8",y1:"12",x2:"21",y2:"12"}),jsx("line",{x1:"8",y1:"18",x2:"21",y2:"18"}),jsx("line",{x1:"3",y1:"6",x2:"3.01",y2:"6"}),jsx("line",{x1:"3",y1:"12",x2:"3.01",y2:"12"}),jsx("line",{x1:"3",y1:"18",x2:"3.01",y2:"18"})]}),"Generate Subtasks"]}),jsxs("button",{onClick:$,disabled:A||!m,className:"card-detail-ai-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Estimate Effort"]})]}),H.assignees&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Assignee Suggestions"}),H.assignees.map((D,Y)=>{let J=s.find(R=>R.id===D.userId);return jsxs("div",{className:"card-detail-ai-suggestion",children:[J&&jsx("div",{className:"card-detail-user-avatar",style:{background:J.color},children:J.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-ai-suggestion-name",children:J?.name}),jsx("div",{className:"card-detail-ai-suggestion-reason",children:D.reasoning}),jsxs("div",{className:"card-detail-ai-suggestion-confidence",children:["Confidence: ",(D.confidence*100).toFixed(0),"%"]})]})]},Y)})]}),H.subtasks&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Suggested Subtasks"}),H.subtasks.map((D,Y)=>jsxs("div",{className:"card-detail-ai-subtask",children:[jsx("div",{className:"card-detail-ai-subtask-title",children:D.title}),D.description&&jsx("div",{className:"card-detail-ai-subtask-desc",children:D.description}),D.estimatedTime&&jsxs("div",{className:"card-detail-ai-subtask-time",children:["Est: ",D.estimatedTime,"h"]})]},Y))]}),H.effort&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Effort Estimate"}),jsxs("div",{className:"card-detail-ai-effort",children:[jsxs("div",{className:"card-detail-ai-effort-hours",children:[H.effort.hours," hours"]}),jsxs("div",{className:"card-detail-ai-effort-confidence",children:["Confidence: ",(H.effort.confidence*100).toFixed(0),"%"]})]})]}),p.length>0&&jsxs("div",{className:"card-detail-ai-insights",children:[jsx("h4",{children:"AI Insights"}),p.map(D=>jsxs("div",{className:`card-detail-ai-insight card-detail-ai-insight-${D.severity.toLowerCase()}`,children:[jsxs("div",{className:"card-detail-ai-insight-header",children:[jsx("span",{className:"card-detail-ai-insight-title",children:D.title}),jsx("span",{className:"card-detail-ai-insight-severity",children:D.severity})]}),jsx("p",{className:"card-detail-ai-insight-desc",children:D.description}),D.suggestedAction&&jsxs("div",{className:"card-detail-ai-insight-action",children:["\u{1F4A1} ",D.suggestedAction]})]},D.id))]}),!H.assignees&&!H.subtasks&&!H.effort&&p.length===0&&jsxs("div",{className:"card-detail-empty-state",children:[jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),jsx("p",{children:"AI Suggestions"}),jsx("span",{children:"Click a button above to get AI-powered insights"})]})]})]})]})})})}function Eo({triggerRef:e,isOpen:t,onClose:a,children:r,width:o=200,estimatedHeight:s=300,className:n=""}){let[c,p]=useState({top:0,left:0}),i=useRef(null),u=useCallback(()=>{if(!e.current)return {top:0,left:0};let d=e.current.getBoundingClientRect(),g=window.innerHeight,f=window.innerWidth,C=4,T=d.left;T+o>f-10&&(T=f-o-10),T<10&&(T=10);let m=g-d.bottom,b=d.top,y;return m>=s+C?y=d.bottom+C:b>=s+C?y=d.top-s-C:m>=b?y=d.bottom+C:y=Math.max(10,d.top-s-C),{top:y,left:T}},[e,o,s]);return useEffect(()=>{t&&p(u());},[t,u]),useEffect(()=>{if(!t)return;let d=f=>{let C=f.target;i.current&&!i.current.contains(C)&&e.current&&!e.current.contains(C)&&a();},g=setTimeout(()=>{document.addEventListener("mousedown",d);},0);return ()=>{clearTimeout(g),document.removeEventListener("mousedown",d);}},[t,a,e]),useEffect(()=>{if(!t)return;let d=g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),a());};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,a]),t?jsx(ut,{children:jsx("div",{ref:i,className:`smart-popover ${n}`,style:{position:"fixed",top:`${c.top}px`,left:`${c.left}px`,width:`${o}px`,maxHeight:"calc(100vh - 40px)",overflowY:"auto",zIndex:99999,padding:"6px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",borderRadius:"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",animation:"popoverSlideIn 100ms ease-out"},children:r})}):null}var Qe={dark:{bgPrimary:"#1A1D21",bgSecondary:"#22262D",bgGrid:"#1E2126",bgWeekend:"rgba(59, 130, 246, 0.03)",border:"#334155",borderLight:"#2D3139",textPrimary:"#FFFFFF",textSecondary:"#CBD5E1",textTertiary:"#64748B",accent:"#3B82F6",accentHover:"#60A5FA",accentLight:"rgba(59, 130, 246, 0.12)",taskBarPrimary:"#3B82F6",taskBarProgress:"#2563EB",taskBarHandle:"#FFFFFF",dependency:"rgba(180, 185, 197, 0.25)",dependencyHover:"rgba(180, 185, 197, 0.45)",criticalPath:"#EF4444",criticalPathLight:"rgba(239, 68, 68, 0.12)",today:"#D21E24",todayLight:"rgba(210, 30, 36, 0.12)",milestone:"#F59E0B",milestoneLight:"rgba(245, 158, 11, 0.1)",statusTodo:"#64748B",statusInProgress:"#3B82F6",statusCompleted:"#10B981",hoverBg:"rgba(255, 255, 255, 0.06)",focusRing:"#3B82F6"},light:{bgPrimary:"#FFFFFF",bgSecondary:"#F8FAFC",bgGrid:"#F1F5F9",bgWeekend:"rgba(37, 99, 235, 0.03)",border:"#CBD5E1",borderLight:"#E2E8F0",textPrimary:"#0F172A",textSecondary:"#334155",textTertiary:"#64748B",accent:"#2563EB",accentHover:"#1D4ED8",accentLight:"rgba(37, 99, 235, 0.08)",taskBarPrimary:"#2563EB",taskBarProgress:"#1E40AF",taskBarHandle:"#FFFFFF",dependency:"rgba(75, 85, 99, 0.25)",dependencyHover:"rgba(75, 85, 99, 0.45)",criticalPath:"#DC2626",criticalPathLight:"rgba(220, 38, 38, 0.1)",today:"#D21E24",todayLight:"rgba(210, 30, 36, 0.1)",milestone:"#F59E0B",milestoneLight:"rgba(245, 158, 11, 0.08)",statusTodo:"#64748B",statusInProgress:"#2563EB",statusCompleted:"#059669",hoverBg:"rgba(0, 0, 0, 0.04)",focusRing:"#2563EB"},neutral:{bgPrimary:"#FAFAF9",bgSecondary:"#F5F5F4",bgGrid:"#EFEDEC",bgWeekend:"rgba(41, 37, 36, 0.02)",border:"#D6D3D1",borderLight:"#E7E5E4",textPrimary:"#0C0A09",textSecondary:"#44403C",textTertiary:"#78716C",accent:"#292524",accentHover:"#44403C",accentLight:"rgba(41, 37, 36, 0.08)",taskBarPrimary:"#292524",taskBarProgress:"#1C1917",taskBarHandle:"#FFFFFF",dependency:"rgba(87, 83, 78, 0.25)",dependencyHover:"rgba(87, 83, 78, 0.4)",criticalPath:"#44403C",criticalPathLight:"rgba(68, 64, 60, 0.08)",today:"#1C1917",todayLight:"rgba(28, 25, 23, 0.06)",milestone:"#57534E",milestoneLight:"rgba(87, 83, 78, 0.08)",statusTodo:"#78716C",statusInProgress:"#292524",statusCompleted:"#15803D",hoverBg:"rgba(0, 0, 0, 0.035)",focusRing:"#292524"}};var zu=["LOW","MEDIUM","HIGH","URGENT"],Uu=["todo","in-progress","review","done"];function Ps({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:c=[],onAddComment:p,onDeleteComment:i,currentUser:u,onAIGenerateDescription:d,onAICreateSubtasks:g,onAIFindSimilar:f,availableColumns:C=[],availableLabels:T=[],availableTags:m=[],onCreateTag:b,onUploadCoverImage:y,unsplashAccessKey:l,theme:w,onSubtasksChange:v,attachments:S=[],onUploadAttachments:x,onDeleteAttachment:k}){let O=eo(),A=w||O?.themeName||"dark",[N,H]=useState(e),[L,q]=useState(false),[ae,ke]=useState(e?.subtasks||[]),[Fe,Ve]=useState(false),[Je,$]=useState(""),[B,W]=useState(""),[D,Y]=useState("all"),[J,R]=useState(false),[ce,we]=useState(false),[Ie,me]=useState(false),[He,Le]=useState(false),[Ye,pt]=useState(false),[bt,it]=useState(false),z=useRef(null),oe=useRef(null),ne=useRef(null),xe=useRef(null),Ne=useRef(null),at=useRef(null),ft=useRef(null),Be=useRef(null),he=useRef(null),Pe=useRef(null),Mt=useRef(null),ht=useRef(null);useEffect(()=>{e&&!N?(H({...e}),ke(e.subtasks||[])):e&&N&&e.id!==N.id&&(H({...e}),ke(e.subtasks||[]));},[e,N]),useEffect(()=>{let G=ee=>{let Ae=ee.target;xe.current&&!xe.current.contains(Ae)&&R(false),Ne.current&&!Ne.current.contains(Ae)&&we(false),at.current&&!at.current.contains(Ae)&&me(false),ft.current&&!ft.current.contains(Ae)&&Le(false);};if(J||ce||Ie||He)return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[J,ce,Ie,He]),useEffect(()=>{if(!t)return;let G=ee=>{let Ae=ee.target,M=Ae.tagName==="INPUT"||Ae.tagName==="TEXTAREA"||Ae.isContentEditable;if(ee.key==="Escape"){ee.preventDefault(),J||ce||Ie||He||Ye||bt?(R(false),we(false),me(false),Le(false),pt(false),it(false)):M||a();return}if(M&&ee.key!=="Escape")return;let te=ee.metaKey||ee.ctrlKey;switch(ee.key.toLowerCase()){case "s":ee.preventDefault(),R(true);break;case "a":ee.preventDefault(),me(true);break;case "p":ee.preventDefault(),we(true);break;case "l":ee.preventDefault(),Le(true);break;case "d":te||(ee.preventDefault(),pt(true),setTimeout(()=>Be.current?.focus(),0));break;case "e":te||(ee.preventDefault(),it(true));break;case "i":ee.preventDefault(),q(true),setTimeout(()=>oe.current?.focus(),0);break;case "t":ee.preventDefault(),Ve(true);break;case "c":ee.preventDefault(),ne.current?.focus();break}};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[t,a,J,ce,Ie,He,Ye,bt]);let oa=useCallback(G=>{let ee=G.currentTarget.textContent?.trim()||"";if(N&&ee!==N.title){let Ae={...N,title:ee};H(Ae),r?.(N.id,{title:ee});}},[N,r]),ma=useCallback(G=>{G.key==="Enter"&&(G.preventDefault(),G.currentTarget.blur()),G.key==="Escape"&&(G.preventDefault(),G.currentTarget.textContent=N?.title||"",G.currentTarget.blur());},[N]),Ue=useCallback(()=>{N&&e&&N.description!==e.description&&r?.(N.id,{description:N.description}),q(false);},[N,e,r]),Oe=useCallback(G=>{if(N){let ee={...N,columnId:G};H(ee),r?.(N.id,{columnId:G}),R(false);}},[N,r]),na=useCallback(G=>{if(N){let ee={...N,priority:G};H(ee),r?.(N.id,{priority:G}),we(false);}},[N,r]),ge=useCallback(G=>{if(N){let ee=N.assignedUserIds||[],Ae=ee.includes(G)?ee.filter(te=>te!==G):[...ee,G],M={...N,assignedUserIds:Ae};H(M),r?.(N.id,{assignedUserIds:Ae});}},[N,r]),E=useCallback(G=>{if(N){let ee=N.labels||[],Ae=ee.includes(G)?ee.filter(te=>te!==G):[...ee,G],M={...N,labels:Ae};H(M),r?.(N.id,{labels:Ae});}},[N,r]),Z=useCallback(G=>{if(N){let ee={...N,tags:G};H(ee),r?.(N.id,{tags:G});}},[N,r]),be=useCallback(G=>{if(N){let ee=G.target.value,Ae={...N,endDate:ee};H(Ae),r?.(N.id,{endDate:ee}),pt(false);}},[N,r]),Te=useCallback(G=>{if(N){let ee={...N,estimatedTime:parseFloat(G)||0};H(ee),r?.(N.id,{estimatedTime:parseFloat(G)||0});}},[N,r]),qe=useCallback(()=>{if(Je.trim()&&N){let G={id:`subtask-${Date.now()}`,title:Je.trim(),completed:false,createdAt:new Date},ee=[...ae,G];ke(ee),$(""),Ve(false),v?.(N.id,ee);}},[Je,ae,N,v]),We=useCallback(G=>{let ee=ae.map(Ae=>Ae.id===G?{...Ae,completed:!Ae.completed,updatedAt:new Date}:Ae);ke(ee),N&&v?.(N.id,ee);},[ae,N,v]),Ee=useCallback(G=>{let ee=ae.filter(Ae=>Ae.id!==G);ke(ee),N&&v?.(N.id,ee);},[ae,N,v]),rt=useCallback(()=>{B.trim()&&N&&p&&(p(N.id,B.trim()),W(""));},[B,N,p]),st=useCallback(G=>{(G.metaKey||G.ctrlKey)&&G.key==="Enter"&&(G.preventDefault(),rt());},[rt]),V=G=>jsx(Bu,{remarkPlugins:[Ru],rehypePlugins:[Ou],components:{a:({node:ee,...Ae})=>jsx("a",{...Ae,target:"_blank",rel:"noopener noreferrer"})},children:G}),re=c.filter(G=>D==="comments"?G.type.includes("COMMENT"):D==="history"?!G.type.includes("COMMENT"):true);if(!t||!e)return null;let Me=N||e,Xe=s.filter(G=>Me.assignedUserIds?.includes(G.id)),$e=ae.filter(G=>G.completed).length;return jsx(ut,{children:jsx("div",{className:"modal-v2-backdrop",onClick:a,style:{position:"fixed",inset:"0",zIndex:9999,background:"rgba(0, 0, 0, 0.7)",display:"flex",alignItems:"center",justifyContent:"center"},children:jsxs("div",{className:"modal-v2-container",onClick:G=>G.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"modal-title","data-theme":A,children:[jsxs("header",{className:"modal-v2-header",children:[jsx("h1",{id:"modal-title",ref:z,className:"modal-v2-title",contentEditable:true,suppressContentEditableWarning:true,onBlur:oa,onKeyDown:ma,children:Me.title}),jsxs("p",{className:"modal-v2-ai-prompt",children:[jsx("span",{className:"modal-v2-ai-icon",children:"\u2728"}),"Ask AI to write a description, create subtasks, or find similar tasks"]}),jsx("button",{className:"modal-v2-close",onClick:a,"aria-label":"Close",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("section",{className:"modal-v2-metadata",children:[jsxs("div",{className:"modal-v2-field-wrapper",ref:xe,children:[jsxs("button",{ref:he,className:"modal-v2-field",onClick:()=>R(!J),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M12 6v6l4 2"})]}),jsx("span",{children:"Status"}),jsx("kbd",{className:"modal-v2-shortcut",children:"S"})]}),jsx("div",{className:"modal-v2-field-value",children:Me.columnId||"No status"})]}),jsx(Eo,{triggerRef:he,isOpen:J,onClose:()=>R(false),width:250,estimatedHeight:200,children:(C.length>0?C:Uu.map(G=>({id:G,title:G}))).map(G=>jsx("button",{className:`modal-v2-popover-item ${Me.columnId===G.id?"active":""}`,onClick:()=>Oe(G.id),children:G.title},G.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:at,children:[jsxs("button",{ref:Pe,className:"modal-v2-field",onClick:()=>me(!Ie),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),jsx("span",{children:"Assignees"}),jsx("kbd",{className:"modal-v2-shortcut",children:"A"})]}),jsx("div",{className:"modal-v2-field-value",children:Xe.length>0?jsx("div",{className:"modal-v2-avatars",children:Xe.map(G=>jsx("div",{className:"modal-v2-avatar",style:{background:G.color},title:G.name,children:G.initials},G.id))}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(Eo,{triggerRef:Pe,isOpen:Ie,onClose:()=>me(false),width:280,estimatedHeight:300,children:s.map(G=>jsxs("button",{className:`modal-v2-popover-item ${Me.assignedUserIds?.includes(G.id)?"active":""}`,onClick:()=>ge(G.id),children:[jsx("div",{className:"modal-v2-avatar-small",style:{background:G.color},children:G.initials}),G.name,Me.assignedUserIds?.includes(G.id)&&jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{marginLeft:"auto"},children:jsx("polyline",{points:"20 6 9 17 4 12"})})]},G.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:Ne,children:[jsxs("button",{ref:Mt,className:"modal-v2-field",onClick:()=>we(!ce),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),jsx("span",{children:"Priority"}),jsx("kbd",{className:"modal-v2-shortcut",children:"P"})]}),jsx("div",{className:"modal-v2-field-value",children:Me.priority||"None"})]}),jsxs(Eo,{triggerRef:Mt,isOpen:ce,onClose:()=>we(false),width:180,estimatedHeight:220,children:[zu.map(G=>jsx("button",{className:`modal-v2-popover-item priority-${G.toLowerCase()} ${Me.priority===G?"active":""}`,onClick:()=>na(G),children:G},G)),jsx("button",{className:"modal-v2-popover-item",onClick:()=>na(""),children:"None"})]})]}),m.length>0||b?jsx("div",{className:"modal-v2-field-wrapper",children:jsxs("div",{className:"modal-v2-field",style:{cursor:"default"},children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 01-2.83 0L2 12V2h10l8.59 8.59a2 2 0 010 2.82z"}),jsx("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]}),jsx("span",{children:"Etiquetas"})]}),jsx("div",{className:"modal-v2-field-value",children:jsx(ar,{selectedTags:Me.tags||[],availableTags:m,onChange:Z,onCreateTag:b,theme:Qe[A]||Qe.dark})})]})}):jsxs("div",{className:"modal-v2-field-wrapper",ref:ft,children:[jsxs("button",{ref:ht,className:"modal-v2-field",onClick:()=>Le(!He),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 01-2.83 0L2 12V2h10l8.59 8.59a2 2 0 010 2.82z"}),jsx("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]}),jsx("span",{children:"Labels"}),jsx("kbd",{className:"modal-v2-shortcut",children:"L"})]}),jsx("div",{className:"modal-v2-field-value",children:Me.labels&&Me.labels.length>0?jsx("span",{children:Me.labels.join(", ")}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(Eo,{triggerRef:ht,isOpen:He,onClose:()=>Le(false),width:220,estimatedHeight:200,children:(T.length>0?T:["Bug","Feature","Enhancement","Documentation"]).map(G=>jsxs("button",{className:`modal-v2-popover-item ${Me.labels?.includes(G)?"active":""}`,onClick:()=>E(G),children:[G,Me.labels?.includes(G)&&jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{marginLeft:"auto"},children:jsx("polyline",{points:"20 6 9 17 4 12"})})]},G))})]}),jsxs("button",{className:"modal-v2-field",onClick:()=>{pt(!Ye),setTimeout(()=>Be.current?.showPicker?.(),0);},children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),jsx("span",{children:"Due Date"}),jsx("kbd",{className:"modal-v2-shortcut",children:"D"})]}),jsx("div",{className:"modal-v2-field-value",children:Me.endDate?new Date(Me.endDate).toLocaleDateString():"Not set"}),jsx("input",{ref:Be,type:"date",value:typeof Me.endDate=="string"?Me.endDate.split("T")[0]:Me.endDate?(()=>{let G=new Date(Me.endDate),ee=G.getUTCFullYear(),Ae=String(G.getUTCMonth()+1).padStart(2,"0"),M=String(G.getUTCDate()).padStart(2,"0");return `${ee}-${Ae}-${M}`})():"",onChange:be,style:{position:"absolute",opacity:0,pointerEvents:"none"}})]}),jsxs("div",{className:"modal-v2-field-wrapper",children:[jsxs("button",{className:"modal-v2-field",onClick:()=>it(!bt),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx("span",{children:"Estimated Time"}),jsx("kbd",{className:"modal-v2-shortcut",children:"E"})]}),jsx("div",{className:"modal-v2-field-value",children:Me.estimatedTime?`${Me.estimatedTime}h`:"Not set"})]}),bt&&jsx("div",{className:"modal-v2-popover",children:jsx("input",{type:"number",min:"0",step:"0.5",placeholder:"Hours",value:Me.estimatedTime||"",onChange:G=>Te(G.target.value),className:"modal-v2-time-input",autoFocus:true,onBlur:()=>it(false)})})]})]}),jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),jsx("polyline",{points:"10 9 9 9 8 9"})]}),jsx("h2",{children:"Description"})]}),L?jsx("textarea",{className:"modal-v2-textarea",value:Me.description||"",onChange:G=>{if(N){let ee={...N,description:G.target.value};H(ee);}},onBlur:Ue,placeholder:"Add a detailed description...",autoFocus:true}):jsx("div",{className:"modal-v2-content",onClick:()=>q(true),children:Me.description?jsx("div",{className:"modal-v2-markdown",children:V(Me.description)}):jsxs("p",{className:"modal-v2-placeholder",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]}),"Add description..."]})})]}),jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M9 11l3 3L22 4"}),jsx("path",{d:"M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"})]}),jsx("h2",{children:"Subtasks"}),ae.length>0&&jsxs("span",{className:"modal-v2-count",children:[$e,"/",ae.length]}),jsxs("button",{className:"modal-v2-add-button",onClick:()=>Ve(true),children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add"]})]}),jsxs("div",{className:"modal-v2-subtasks",children:[ae.map(G=>jsxs("div",{className:`modal-v2-subtask ${G.completed?"completed":""}`,children:[jsx("button",{className:"modal-v2-subtask-checkbox",onClick:()=>We(G.id),children:G.completed?jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9 12l2 2 4-4",stroke:"white",strokeWidth:"2",fill:"none"})]}):jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("circle",{cx:"12",cy:"12",r:"10"})})}),jsx("span",{className:"modal-v2-subtask-title",children:G.title}),jsx("button",{className:"modal-v2-subtask-delete",onClick:()=>Ee(G.id),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})]})})]},G.id)),Fe&&jsx("div",{className:"modal-v2-subtask-input-row",children:jsx("input",{type:"text",placeholder:"Subtask title...",value:Je,onChange:G=>$(G.target.value),onKeyDown:G=>{G.key==="Enter"&&qe(),G.key==="Escape"&&(Ve(false),$(""));},onBlur:qe,autoFocus:true,className:"modal-v2-subtask-input"})})]})]}),(x||S.length>0)&&jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children: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"})}),jsx("h2",{children:"Attachments"}),S.length>0&&jsx("span",{className:"modal-v2-count",children:S.length})]}),jsx(sr,{cardId:Me.id,attachments:S,onUpload:x?G=>x(Me.id,G):void 0,onDelete:k,maxSizeMB:10,maxFiles:20})]}),jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),jsx("h2",{children:"Activity"}),jsxs("div",{className:"modal-v2-filters",children:[jsx("button",{className:`modal-v2-filter ${D==="all"?"active":""}`,onClick:()=>Y("all"),children:"All"}),jsx("button",{className:`modal-v2-filter ${D==="comments"?"active":""}`,onClick:()=>Y("comments"),children:"Comments"}),jsx("button",{className:`modal-v2-filter ${D==="history"?"active":""}`,onClick:()=>Y("history"),children:"History"})]})]}),jsxs("div",{className:"modal-v2-comment-input",children:[u&&jsx("div",{className:"modal-v2-avatar",style:{background:u.color},children:u.initials}),jsxs("div",{className:"modal-v2-comment-wrapper",children:[jsx("textarea",{ref:ne,className:"modal-v2-comment-textarea",placeholder:"Write a comment...",value:B,onChange:G=>W(G.target.value),onKeyDown:st,rows:1}),jsxs("div",{className:"modal-v2-comment-toolbar",children:[jsxs("div",{className:"modal-v2-toolbar-left",children:[jsx("button",{className:"modal-v2-toolbar-button",title:"Attach file",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children: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"})})}),jsx("button",{className:"modal-v2-toolbar-button",title:"Mention user",children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"4"}),jsx("path",{d:"M16 8v5a3 3 0 006 0v-1a10 10 0 10-3.92 7.94"})]})}),jsx("button",{className:"modal-v2-toolbar-button",title:"Add emoji",children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M8 14s1.5 2 4 2 4-2 4-2"}),jsx("line",{x1:"9",y1:"9",x2:"9.01",y2:"9"}),jsx("line",{x1:"15",y1:"9",x2:"15.01",y2:"9"})]})})]}),jsx("button",{className:"modal-v2-send-button",onClick:rt,disabled:!B.trim(),children:"Send"})]})]})]}),jsxs("div",{className:"modal-v2-timeline",children:[re.map(G=>{let ee=s.find(M=>M.id===G.userId);if(G.type.includes("COMMENT")){let M=n.find(te=>te.id===G.metadata?.commentId);return M?jsxs("div",{className:"modal-v2-activity-item comment-item",children:[ee&&jsx("div",{className:"modal-v2-avatar",style:{background:ee.color},children:ee.initials}),jsxs("div",{className:"modal-v2-activity-content",children:[jsxs("div",{className:"modal-v2-activity-header",children:[jsx("span",{className:"modal-v2-activity-user",children:ee?.name||"Unknown"}),jsx("span",{className:"modal-v2-activity-time",children:new Date(G.timestamp).toLocaleString()})]}),jsx("div",{className:"modal-v2-comment-body",children:M.content})]})]},G.id):null}return jsxs("div",{className:"modal-v2-activity-item history-item",children:[jsxs("div",{className:"modal-v2-history-icon",children:[G.type.includes("CREATED")&&"\u2795",G.type.includes("UPDATED")&&"\u270F\uFE0F",G.type.includes("MOVED")&&"\u27A1\uFE0F",G.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",G.type.includes("ASSIGNED")&&"\u{1F464}",G.type.includes("PRIORITY")&&"\u{1F3AF}",G.type.includes("LABEL")&&"\u{1F3F7}\uFE0F"]}),jsxs("div",{className:"modal-v2-activity-content",children:[jsxs("div",{className:"modal-v2-history-text",children:[jsx("span",{className:"modal-v2-activity-user",children:ee?.name||"Unknown"})," ",G.type.replace(/_/g," ").toLowerCase(),G.newValue&&jsxs(Fragment,{children:[" to ",jsx("strong",{children:G.newValue})]})]}),jsx("span",{className:"modal-v2-activity-time",children:new Date(G.timestamp).toLocaleString()})]})]},G.id)}),re.length===0&&jsxs("div",{className:"modal-v2-empty",children:[jsx("p",{children:"No activity yet"}),jsx("span",{children:"Activity will appear here"})]})]})]})]})})})}function Yu({active:e,payload:t}){return !e||!t||!t.length?null:jsxs("div",{className:"chart-tooltip",children:[jsx("p",{className:"chart-tooltip-label",children:t[0].payload.period}),t.map((a,r)=>jsxs("p",{className:"chart-tooltip-value",style:{color:a.color},children:[a.name,": ",jsx("strong",{children:a.value})," cards"]},r))]})}function As({data:e,title:t="Team Velocity",height:a=300,showAverage:r=true,showPlanned:o=true}){let s=e.map(n=>({...n,average:n.average??e.reduce((c,p)=>c+p.completed,0)/e.length}));return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:a,children:jsxs(LineChart,{data:s,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"period",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(Yu,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),jsx(Line,{type:"monotone",dataKey:"completed",stroke:"#10B981",strokeWidth:3,name:"Completed",dot:{fill:"#10B981",r:5},activeDot:{r:7}}),o&&jsx(Line,{type:"monotone",dataKey:"planned",stroke:"#3B82F6",strokeWidth:2,strokeDasharray:"5 5",name:"Planned",dot:{fill:"#3B82F6",r:4}}),r&&jsx(Line,{type:"monotone",dataKey:"average",stroke:"#F59E0B",strokeWidth:2,strokeDasharray:"3 3",name:"Average",dot:false})]})}),jsxs("div",{className:"chart-stats",children:[jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Total Completed"}),jsx("span",{className:"chart-stat-value",style:{color:"#10B981"},children:e.reduce((n,c)=>n+c.completed,0)})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Average Velocity"}),jsx("span",{className:"chart-stat-value",style:{color:"#F59E0B"},children:(e.reduce((n,c)=>n+c.completed,0)/e.length).toFixed(1)})]}),o&&e.some(n=>n.planned)&&jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Total Planned"}),jsx("span",{className:"chart-stat-value",style:{color:"#3B82F6"},children:e.reduce((n,c)=>n+(c.planned||0),0)})]})]})]})}function rg({active:e,payload:t}){return !e||!t||!t.length?null:jsxs("div",{className:"chart-tooltip",children:[jsx("p",{className:"chart-tooltip-label",children:t[0].payload.day}),t.map((a,r)=>jsxs("p",{className:"chart-tooltip-value",style:{color:a.color},children:[a.name,": ",jsx("strong",{children:a.value})," tasks"]},r))]})}function Fs({data:e,title:t="Sprint Burndown",height:a=300,totalTasks:r,useArea:o=false}){let s=r??(e[0]?.ideal||e[0]?.remaining||0),n=e[e.length-1]?.remaining||0,c=e[e.length-1]?.ideal||0,p=s>0?(s-n)/s*100:0,i=n<=c;return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:a,children:jsxs(o?AreaChart:LineChart,{data:e,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"day",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(rg,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),o?jsxs(Fragment,{children:[jsx(Area,{type:"monotone",dataKey:"ideal",stroke:"#F59E0B",fill:"rgba(245, 158, 11, 0.2)",strokeWidth:2,strokeDasharray:"5 5",name:"Ideal"}),jsx(Area,{type:"monotone",dataKey:"remaining",stroke:i?"#10B981":"#EF4444",fill:i?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",strokeWidth:3,name:"Remaining"})]}):jsxs(Fragment,{children:[jsx(Line,{type:"linear",dataKey:"ideal",stroke:"#F59E0B",strokeWidth:2,strokeDasharray:"5 5",name:"Ideal",dot:{fill:"#F59E0B",r:4}}),jsx(Line,{type:"monotone",dataKey:"remaining",stroke:i?"#10B981":"#EF4444",strokeWidth:3,name:"Remaining",dot:{fill:i?"#10B981":"#EF4444",r:5},activeDot:{r:7}})]})]})}),jsxs("div",{className:"chart-stats",children:[jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Progress"}),jsxs("span",{className:"chart-stat-value",style:{color:p>=50?"#10B981":"#F59E0B"},children:[p.toFixed(0),"%"]})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Remaining"}),jsx("span",{className:"chart-stat-value",style:{color:i?"#10B981":"#EF4444"},children:n})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Status"}),jsx("span",{className:"chart-stat-badge",style:{background:i?"rgba(16, 185, 129, 0.15)":"rgba(239, 68, 68, 0.15)",color:i?"#10B981":"#EF4444"},children:i?"\u2713 On Track":"\u26A0 Behind"})]})]})]})}var pg={URGENT:"#EF4444",HIGH:"#F59E0B",MEDIUM:"#3B82F6",LOW:"#10B981"},Cd=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899"];function ug({cx:e,cy:t,midAngle:a,innerRadius:r,outerRadius:o,percent:s}){let n=r+(o-r)*.5,c=e+n*Math.cos(-a*(Math.PI/180)),p=t+n*Math.sin(-a*(Math.PI/180));return s<.05?null:jsx("text",{x:c,y:p,fill:"white",textAnchor:c>e?"start":"end",dominantBaseline:"central",style:{fontSize:"12px",fontWeight:600},children:`${(s*100).toFixed(0)}%`})}function Td({active:e,payload:t}){if(!e||!t||!t.length)return null;let a=t[0].payload,r=t[0].payload.totalValue||0,o=r>0?(a.value/r*100).toFixed(1):"0";return jsxs("div",{className:"chart-tooltip",children:[jsx("p",{className:"chart-tooltip-label",children:a.name}),jsxs("p",{className:"chart-tooltip-value",style:{color:a.color||t[0].color},children:["Count: ",jsx("strong",{children:a.value})]}),jsxs("p",{className:"chart-tooltip-value",style:{color:"rgba(255, 255, 255, 0.7)"},children:["Percentage: ",jsxs("strong",{children:[o,"%"]})]})]})}function Is({data:e,title:t="Distribution",type:a="pie",height:r=300,showPercentages:o=true}){let s=e.reduce((p,i)=>p+i.value,0),n=e.map(p=>({...p,totalValue:s,color:p.color||pg[p.name]||Cd[e.indexOf(p)%Cd.length]})),c=n.map(p=>p.color);return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:r,children:a==="pie"?jsxs(PieChart,{children:[jsx(Pie,{data:n,cx:"50%",cy:"50%",labelLine:false,label:o?ug:false,outerRadius:r*.35,fill:"#8884d8",dataKey:"value",children:n.map((p,i)=>jsx(Cell,{fill:c[i]},`cell-${i}`))}),jsx(Tooltip,{content:jsx(Td,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"},formatter:(p,i)=>{let u=i.payload,d=s>0?(u.value/s*100).toFixed(0):"0";return `${p} (${u.value} - ${d}%)`}})]}):jsxs(BarChart,{data:n,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"name",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(Td,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),jsx(Bar,{dataKey:"value",name:"Count",radius:[8,8,0,0],children:n.map((p,i)=>jsx(Cell,{fill:c[i]},`cell-${i}`))})]})}),jsxs("div",{className:"chart-stats",children:[jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Total Cards"}),jsx("span",{className:"chart-stat-value",style:{color:"#3B82F6"},children:s})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Categories"}),jsx("span",{className:"chart-stat-value",style:{color:"#10B981"},children:e.length})]}),e.length>0&&jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Largest Category"}),jsx("span",{className:"chart-stat-value",style:{color:"#F59E0B"},children:e.reduce((p,i)=>i.value>p.value?i:p).name})]})]})]})}var pn=memo(({selectedCards:e,availableUsers:t=[],onClearSelection:a,callbacks:r,columns:o=[],availableLabels:s=[]})=>{let[n,c]=useState(false),[p,i]=useState(false),[u,d]=useState(false),[g,f]=useState(false);if(e.length===0)return null;let C=e.map(w=>w.id),T=w=>{r.onBulkUpdate?.(C,{priority:w}),c(false);},m=w=>{r.onBulkMove?.(C,w),i(false),a();},b=w=>{r.onBulkUpdate?.(C,{assignedUserIds:w}),d(false);},y=w=>{let v=new Set;e.forEach(x=>{x.labels?.forEach(k=>v.add(k));});let S=Array.from(new Set([...v,...w]));r.onBulkUpdate?.(C,{labels:S}),f(false);},l=()=>{confirm(`Delete ${e.length} card(s)? This cannot be undone.`)&&(r.onBulkDelete?.(C),a());};return jsx("div",{className:"asakaa-bulk-toolbar",children:jsxs("div",{className:"asakaa-bulk-toolbar-content",children:[jsxs("div",{className:"asakaa-bulk-toolbar-count",children:[e.length," card",e.length!==1?"s":""," selected"]}),jsxs("div",{className:"asakaa-bulk-toolbar-actions",children:[jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>c(!n),title:"Update priority",children:jsx("span",{className:"text-sm",children:"Priority"})}),n&&jsx("div",{className:"asakaa-bulk-menu",children:["LOW","MEDIUM","HIGH","URGENT"].map(w=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>T(w),children:[jsx("span",{className:h("asakaa-priority-dot",w==="LOW"&&"bg-asakaa-priority-low",w==="MEDIUM"&&"bg-asakaa-priority-medium",w==="HIGH"&&"bg-asakaa-priority-high",w==="URGENT"&&"bg-asakaa-priority-urgent")}),w]},w))})]}),o.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>i(!p),title:"Move to column",children:jsx("span",{className:"text-sm",children:"Move"})}),p&&jsx("div",{className:"asakaa-bulk-menu",children:o.map(w=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>m(w.id),children:w.title},w.id))})]}),t.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>d(!u),title:"Assign users",children:jsx("span",{className:"text-sm",children:"Assign"})}),u&&jsx("div",{className:"asakaa-bulk-menu",children:t.map(w=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>b([w.id]),children:[jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs font-medium",style:{backgroundColor:w.color},children:w.initials}),w.name]},w.id))})]}),s.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>f(!g),title:"Add labels",children:jsx("span",{className:"text-sm",children:"Labels"})}),g&&jsx("div",{className:"asakaa-bulk-menu",children:s.map(w=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>y([w]),children:w},w))})]}),jsx("button",{className:"asakaa-bulk-toolbar-button asakaa-bulk-toolbar-button-danger",onClick:l,title:"Delete selected cards",children:jsx("span",{className:"text-sm",children:"Delete"})}),jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:a,title:"Clear selection",children:jsx("span",{className:"text-sm",children:"\u2715"})})]})]})})});pn.displayName="BulkOperationsToolbar";function yg(e,t,a){if(t==="none")return [];let r=new Map;return e.forEach(o=>{let s,n,c,p,i;switch(t){case "assignee":let u=o.assignedUserIds||(o.assigneeId?[o.assigneeId]:[]);u.length>0?u.forEach(f=>{let C=a?.find(T=>T.id===f);n=`assignee-${f}`,c=C?.name||`User ${f}`,p=C?.color,i=C?.avatar,r.has(n)||r.set(n,{id:n,title:c,groupValue:f,cardIds:[],color:p,icon:i}),r.get(n).cardIds.push(o.id);}):(n="assignee-unassigned",c="Unassigned",p="#6b7280",i="\u{1F464}",r.has(n)||r.set(n,{id:n,title:c,groupValue:null,cardIds:[],color:p,icon:i}),r.get(n).cardIds.push(o.id));break;case "priority":s=o.priority||"NONE",n=`priority-${s}`;let g={URGENT:{title:"\u{1F534} Urgent",color:"#ef4444"},HIGH:{title:"\u{1F7E0} High",color:"#f97316"},MEDIUM:{title:"\u{1F7E1} Medium",color:"#eab308"},LOW:{title:"\u{1F7E2} Low",color:"#22c55e"},NONE:{title:"\u26AA No Priority",color:"#6b7280"}}[s];c=g.title,p=g.color,r.has(n)||r.set(n,{id:n,title:c,groupValue:s,cardIds:[],color:p}),r.get(n).cardIds.push(o.id);break;case "label":o.labels&&o.labels.length>0?o.labels.forEach(f=>{n=`label-${f}`,c=f,p="#6b7280",r.has(n)||r.set(n,{id:n,title:c,groupValue:f,cardIds:[],color:p}),r.get(n).cardIds.push(o.id);}):(n="label-none",c="No Labels",p="#6b7280",r.has(n)||r.set(n,{id:n,title:c,groupValue:null,cardIds:[],color:p}),r.get(n).cardIds.push(o.id));break}}),Array.from(r.values()).sort((o,s)=>o.title.localeCompare(s.title))}function Ls({board:e,swimlaneConfig:t,availableUsers:a,callbacks:r,className:o}){let[s,n]=useState(new Set),c=useMemo(()=>yg(e.cards,t.groupBy,a),[e.cards,t.groupBy,a]),p=useCallback(i=>{n(u=>{let d=new Set(u);return d.has(i)?d.delete(i):d.add(i),d});},[]);return t.groupBy==="none"||c.length===0?jsx(wr,{board:e,callbacks:r,availableUsers:a,className:o}):jsxs("div",{className:h("asakaa-swimlane-view",o),children:[c.map(i=>{let u=s.has(i.id),d=e.cards.filter(f=>i.cardIds.includes(f.id)),g={...e,cards:d};return jsxs("div",{className:"asakaa-swimlane mb-6 rounded-lg border border-white/10 overflow-hidden",children:[jsxs("div",{className:"asakaa-swimlane-header px-4 py-3 bg-white/5 backdrop-blur-sm flex items-center justify-between cursor-pointer hover:bg-white/10 transition-colors",onClick:()=>t.collapsible&&p(i.id),style:{borderLeft:i.color?`4px solid ${i.color}`:void 0},children:[jsxs("div",{className:"flex items-center gap-3",children:[i.icon&&jsx("span",{className:"text-2xl leading-none",children:i.icon}),jsx("h3",{className:"text-lg font-semibold",style:{color:i.color},children:i.title}),jsxs("span",{className:"text-sm text-white/50 font-medium",children:["(",i.cardIds.length," ",i.cardIds.length===1?"card":"cards",")"]})]}),t.collapsible&&jsx("button",{className:"text-white/50 hover:text-white transition-colors","aria-label":u?"Expand lane":"Collapse lane",children:u?"\u25B6":"\u25BC"})]}),!u&&jsx("div",{className:"asakaa-swimlane-content p-4",children:jsx(wr,{board:g,callbacks:r,availableUsers:a})})]},i.id)}),c.length===0&&jsxs("div",{className:"text-center py-12 text-white/50",children:[jsx("p",{className:"text-lg",children:"No cards to display"}),jsx("p",{className:"text-sm mt-2",children:"Cards will appear here when they match the grouping criteria"})]})]})}var Bs=[{value:"none",label:"No Grouping",icon:"\u{1F4CB}",description:"Standard Kanban board view"},{value:"assignee",label:"By Assignee",icon:"\u{1F465}",description:"Group cards by assigned user"},{value:"priority",label:"By Priority",icon:"\u{1F3AF}",description:"Group cards by priority level"},{value:"label",label:"By Label",icon:"\u{1F3F7}\uFE0F",description:"Group cards by label/tag"}];function Rs({value:e,onChange:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null),c=Bs.find(i=>i.value===e)||Bs[0];useEffect(()=>{function i(u){s.current&&!s.current.contains(u.target)&&n.current&&!n.current.contains(u.target)&&o(false);}if(r)return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let p=i=>{t(i),o(false);};return jsxs("div",{className:h("relative inline-block",a),children:[jsxs("button",{ref:n,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-white/10 hover:bg-white/15 border border-white/20 transition-all text-sm font-medium text-white/90",children:[jsx("span",{className:"text-base leading-none",children:c.icon}),jsx("span",{children:c.label}),jsx("svg",{className:h("w-4 h-4 transition-transform",r&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r&&jsxs("div",{ref:s,className:"absolute top-full left-0 mt-2 min-w-[280px] rounded-lg bg-gradient-to-br from-gray-900/95 to-gray-800/95 backdrop-blur-xl border border-white/20 shadow-2xl z-50 overflow-hidden",children:[jsx("div",{className:"px-3 py-2 border-b border-white/10",children:jsx("span",{className:"text-[10px] font-bold text-white/70 uppercase tracking-wider",children:"Group By"})}),jsx("div",{className:"py-1",children:Bs.map(i=>jsxs("button",{onClick:()=>p(i.value),className:h("w-full px-3 py-2 flex items-start gap-3 text-left transition-all hover:bg-white/10",e===i.value&&"bg-white/5"),children:[jsx("span",{className:"text-xl leading-none mt-0.5",children:i.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"font-semibold text-sm text-white",children:i.label}),e===i.value&&jsx("span",{className:"text-blue-400 text-xs",children:"\u2713"})]}),jsx("p",{className:"text-xs text-white/60 mt-0.5",children:i.description})]})]},i.value))})]})]})}var Po=[{keys:"ArrowUp",action:"navigate_up",description:"Navigate to card above"},{keys:"ArrowDown",action:"navigate_down",description:"Navigate to card below"},{keys:"ArrowLeft",action:"navigate_left",description:"Navigate to previous column"},{keys:"ArrowRight",action:"navigate_right",description:"Navigate to next column"},{keys:"Enter",action:"open_card",description:"Open selected card"},{keys:"Escape",action:"close_modal",description:"Close modal or dialog"},{keys:"Delete",action:"delete_card",description:"Delete selected card",modifiers:{shift:true}},{keys:"n",action:"new_card",description:"Create new card",modifiers:{ctrl:true}},{keys:"k",action:"search",description:"Open search/command palette",modifiers:{ctrl:true}},{keys:"s",action:"save",description:"Save changes",modifiers:{ctrl:true}},{keys:"z",action:"undo",description:"Undo last action",modifiers:{ctrl:true}},{keys:"y",action:"redo",description:"Redo last undone action",modifiers:{ctrl:true}},{keys:"a",action:"select_all",description:"Select all cards",modifiers:{ctrl:true}},{keys:"Escape",action:"deselect_all",description:"Deselect all cards"},{keys:"?",action:"show_shortcuts",description:"Show keyboard shortcuts help",modifiers:{shift:true}}];function kg(e,t){if(!(Array.isArray(t.keys)?t.keys:[t.keys]).some(i=>e.key===i||e.code===i))return false;let o=t.modifiers||{},s=o.ctrl?e.ctrlKey||e.metaKey:!e.ctrlKey&&!e.metaKey,n=o.shift?e.shiftKey:!e.shiftKey,c=o.alt?e.altKey:!e.altKey,p=o.meta?e.metaKey:true;return s&&n&&c&&p}function Pd(e={}){let{shortcuts:t=Po,enabled:a=true,preventDefault:r=true}=e,o=useRef(t),s=useRef(a);useEffect(()=>{o.current=t,s.current=a;},[t,a]);let n=useCallback(p=>{o.current=[...o.current,p];},[]),c=useCallback(p=>{o.current=o.current.filter(i=>i.action!==p);},[]);return useEffect(()=>{function p(i){if(!s.current)return;let u=i.target;if(!((u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.isContentEditable)&&i.key!=="Escape"&&!i.ctrlKey&&!i.metaKey)){for(let d of o.current)if(kg(i,d)){r&&i.preventDefault();let g=new CustomEvent("keyboard-action",{detail:d.action,bubbles:true,cancelable:true});window.dispatchEvent(g);break}}}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r]),{registerShortcut:n,unregisterShortcut:c,isEnabled:a}}function Cg(e){return {ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192",Enter:"\u21B5",Escape:"Esc",Delete:"Del"," ":"Space"}[e]||e.toUpperCase()}function Tg(e){let t=[],a=typeof navigator<"u"&&navigator.platform.includes("Mac");return e.modifiers?.ctrl&&t.push(a?"\u2318":"Ctrl"),e.modifiers?.shift&&t.push("Shift"),e.modifiers?.alt&&t.push(a?"\u2325":"Alt"),e.modifiers?.meta&&t.push("\u2318"),t.join(" + ")}function Ng(e){let t=Array.isArray(e.keys)?e.keys[0]:e.keys,a=Tg(e),r=t?Cg(t):"";return a?`${a} + ${r}`:r}function Dg(e){let t={Navigation:[],Actions:[],Editing:[],Selection:[]};return e.forEach(a=>{a.action.includes("navigate")?t.Navigation?.push(a):a.action.includes("select")?t.Selection?.push(a):["undo","redo","save"].includes(a.action)?t.Editing?.push(a):t.Actions?.push(a);}),t}function Os({shortcuts:e=Po,isOpen:t,onClose:a,className:r}){let[o,s]=useState(false);if(useEffect(()=>{s(true);},[]),useEffect(()=>{function c(p){p.key==="Escape"&&t&&a();}if(t)return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t,a]),!o||!t)return null;let n=Dg(e);return jsxs("div",{className:h("fixed inset-0 z-[9999] flex items-center justify-center",r),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:a}),jsxs("div",{className:"relative bg-gradient-to-br from-gray-900/95 to-gray-800/95 backdrop-blur-xl rounded-2xl border border-white/20 shadow-2xl max-w-3xl w-full mx-4 max-h-[80vh] overflow-hidden",children:[jsxs("div",{className:"px-6 py-5 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[jsx("span",{className:"text-3xl",children:"\u2328\uFE0F"}),"Keyboard Shortcuts"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Speed up your workflow with these shortcuts"})]}),jsx("button",{onClick:a,className:"text-white/50 hover:text-white transition-colors text-2xl leading-none p-2 hover:bg-white/10 rounded-lg","aria-label":"Close",children:"\xD7"})]}),jsx("div",{className:"px-6 py-6 overflow-y-auto max-h-[calc(80vh-120px)]",children:jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:Object.entries(n).map(([c,p])=>p.length===0?null:jsxs("div",{children:[jsxs("h3",{className:"text-lg font-semibold text-white/90 mb-4 flex items-center gap-2",children:[jsx("span",{className:"w-1 h-5 bg-blue-500 rounded-full"}),c]}),jsx("div",{className:"space-y-3",children:p.map(i=>jsxs("div",{className:"flex items-center justify-between gap-4 p-3 rounded-lg bg-white/5 hover:bg-white/10 transition-colors",children:[jsx("span",{className:"text-sm text-white/80",children:i.description}),jsx("kbd",{className:"px-3 py-1.5 bg-gradient-to-br from-gray-700 to-gray-800 border border-white/20 rounded-md text-xs font-mono text-white/90 shadow-lg whitespace-nowrap",children:Ng(i)})]},i.action))})]},c))})}),jsx("div",{className:"px-6 py-4 border-t border-white/10 bg-white/5",children:jsxs("p",{className:"text-xs text-white/50 text-center",children:["Press ",jsx("kbd",{className:"px-2 py-0.5 bg-white/10 rounded text-white/70",children:"?"})," to toggle this help panel"]})})]})]})}var zs=[{id:"bug-report",name:"Bug Report",description:"Report a bug or issue",icon:"\u{1F41B}",category:"Development",template:{title:"[BUG] ",description:`**Steps to reproduce:**
71
+ `,h.onmouseenter=()=>{h.style.opacity="1";},h.onmouseleave=()=>{h.style.opacity="0.5";},h.onclick=C=>{C.stopPropagation();let T=r<a.length-1?r+1:0;i(),o(T);},n.appendChild(d),n.appendChild(g),n.appendChild(h);}n.appendChild(c),n.appendChild(p),document.body.appendChild(n),setTimeout(()=>{p.style.transition="opacity 0.5s ease",p.style.opacity="0";},2e3);}function Pu(e){if(e===0)return "0 Bytes";let t=1024,a=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,r)*100)/100+" "+a[r]}function Mu(e){return e.startsWith("image/")?"\u{1F5BC}\uFE0F":e.startsWith("video/")?"\u{1F3A5}":e.startsWith("audio/")?"\u{1F3B5}":e.includes("pdf")?"\u{1F4C4}":e.includes("word")||e.includes("document")?"\u{1F4DD}":e.includes("sheet")||e.includes("excel")?"\u{1F4CA}":e.includes("presentation")||e.includes("powerpoint")?"\u{1F4FD}\uFE0F":e.includes("zip")||e.includes("rar")||e.includes("compressed")?"\u{1F5DC}\uFE0F":e.includes("text")?"\u{1F4C3}":"\u{1F4CE}"}function Es(e){return e.startsWith("image/")}function dr({attachments:e=[],onUpload:t,onDelete:a,maxSizeMB:r=10,allowedTypes:o,maxFiles:s=10}){let[n,c]=useState(false),[p,i]=useState(false),[u,d]=useState(null),g=useRef(null),h=useRef(e);h.current=e;let C=useCallback((k,O)=>{O.preventDefault(),O.stopPropagation();let M=h.current.filter(L=>Es(L.type)),N=M.findIndex(L=>L.id===k.id),H=L=>{let Y=h.current.filter(ke=>Es(ke.type)),ae=Y[L];ae&&gd(ae.url,ae.name,Y,L,H);};gd(k.url,k.name,M,N,H);},[]),T=useCallback(k=>{let O=[],M=[];return e.length+k.length>s?(M.push(`Maximum ${s} files allowed`),{valid:O,errors:M}):(k.forEach(N=>{if(N.size/1048576>r){M.push(`${N.name} is too large (max ${r}MB)`);return}if(o&&!o.some(L=>N.type.match(L))){M.push(`${N.name} has invalid file type`);return}O.push(N);}),{valid:O,errors:M})},[e.length,s,r,o]),m=useCallback(async k=>{let{valid:O,errors:M}=T(k);if(M.length>0){d(M.join(", ")),setTimeout(()=>d(null),5e3);return}if(O.length!==0){i(true),d(null);try{await t?.(O);}catch(N){d(N instanceof Error?N.message:"Upload failed"),setTimeout(()=>d(null),5e3);}finally{i(false);}}},[T,t]),b=useCallback(k=>{k.preventDefault(),k.stopPropagation(),c(true);},[]),y=useCallback(k=>{k.preventDefault(),k.stopPropagation(),c(false);},[]),l=useCallback(k=>{k.preventDefault(),k.stopPropagation();},[]),w=useCallback(k=>{k.preventDefault(),k.stopPropagation(),c(false);let O=Array.from(k.dataTransfer.files);m(O);},[m]),v=useCallback(k=>{let O=k.target.files?Array.from(k.target.files):[];m(O),g.current&&(g.current.value="");},[m]),P=useCallback(()=>{g.current?.click();},[]),x=useCallback(k=>{confirm("Are you sure you want to delete this attachment?")&&a?.(k);},[a]);return jsxs("div",{className:"attachment-uploader",children:[jsxs("div",{className:`attachment-dropzone ${n?"dragging":""} ${p?"uploading":""}`,onDragEnter:b,onDragLeave:y,onDragOver:l,onDrop:w,onClick:P,children:[jsx("input",{ref:g,type:"file",multiple:true,onChange:v,style:{display:"none"},accept:o?.join(",")}),jsx("div",{className:"attachment-dropzone-content",children:p?jsxs(Fragment,{children:[jsx("div",{className:"attachment-spinner"}),jsx("p",{className:"attachment-dropzone-text",children:"Uploading..."})]}):jsxs(Fragment,{children:[jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"attachment-dropzone-icon",children:[jsx("path",{d:"M21 15V19C21 19.5304 20.7893 20.0391 20.4142 20.4142C20.0391 20.7893 19.5304 21 19 21H5C4.46957 21 3.96086 20.7893 3.58579 20.4142C3.21071 20.0391 3 19.5304 3 19V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M17 8L12 3L7 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M12 3V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),jsx("p",{className:"attachment-dropzone-text",children:n?"Drop files here":"Drag & drop files here"}),jsx("p",{className:"attachment-dropzone-subtext",children:"or click to browse"}),jsxs("p",{className:"attachment-dropzone-info",children:["Max ",r,"MB \u2022 ",e.length,"/",s," files"]})]})})]}),u&&jsxs("div",{className:"attachment-error",children:[jsx("span",{className:"attachment-error-icon",children:"\u26A0\uFE0F"}),jsx("span",{className:"attachment-error-text",children:u})]}),e.length>0&&jsx("div",{className:"attachment-list",children:e.map(k=>jsxs("div",{className:"attachment-item",children:[jsx("div",{className:"attachment-preview",children:Es(k.type)&&k.url?jsxs("button",{type:"button",className:"attachment-thumbnail-btn",onClick:O=>C(k,O),title:"Click to view full size",children:[jsx("img",{src:k.thumbnailUrl||k.url,alt:k.name,className:"attachment-thumbnail"}),jsx("div",{className:"attachment-thumbnail-overlay",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M9 21H3V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M21 3L14 10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M3 21L10 14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]}):jsx("div",{className:"attachment-icon",children:Mu(k.type)})}),jsxs("div",{className:"attachment-info",children:[jsx("a",{href:k.url,target:"_blank",rel:"noopener noreferrer",className:"attachment-name",title:k.name,children:k.name}),jsxs("div",{className:"attachment-meta",children:[jsx("span",{className:"attachment-size",children:Pu(k.size)}),jsx("span",{className:"attachment-separator",children:"\u2022"}),jsx("span",{className:"attachment-date",children:new Date(k.uploadedAt).toLocaleDateString()})]})]}),jsx("button",{onClick:()=>x(k.id),className:"attachment-delete",title:"Delete attachment",type:"button",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},k.id))})]})}function Ps({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:c=[],aiInsights:p=[],attachments:i=[],onAddComment:u,onDeleteComment:d,onUploadAttachments:g,onDeleteAttachment:h,onSuggestAssignee:C,onGenerateSubtasks:T,onEstimateEffort:m,currentUserId:b="user-1"}){let[y,l]=useState("details"),[w,v]=useState(false),[P,x]=useState({}),[k,O]=useState(""),[M,N]=useState(false),[H,L]=useState({});if(!t||!e)return null;let Y=useCallback(()=>{v(false),x({}),l("details"),O(""),L({}),a();},[a]),ae=useCallback(()=>{r&&Object.keys(P).length>0&&(r(e.id,P),x({}),v(false));},[e.id,P,r]),ke=useCallback(()=>{o&&window.confirm("Are you sure you want to delete this card?")&&(o(e.id),Y());},[e.id,o,Y]),Pe=useCallback(()=>{u&&k.trim()&&(u(e.id,k.trim()),O(""));},[e.id,k,u]),Ve=useCallback(async()=>{if(C){N(true);try{let D=await C(e);L(j=>({...j,assignees:D}));}catch(D){console.error("Failed to suggest assignee:",D);}finally{N(false);}}},[e,C]),Je=useCallback(async()=>{if(T){N(true);try{let D=await T(e);L(j=>({...j,subtasks:D}));}catch(D){console.error("Failed to generate subtasks:",D);}finally{N(false);}}},[e,T]),$=useCallback(async()=>{if(m){N(true);try{let D=await m(e);L(j=>({...j,effort:D}));}catch(D){console.error("Failed to estimate effort:",D);}finally{N(false);}}},[e,m]),B={...e,...P},W=s.filter(D=>B.assignedUserIds?.includes(D.id));return jsx(gt,{children:jsx("div",{className:"card-detail-overlay",onClick:Y,children:jsxs("div",{className:"card-detail-modal",onClick:D=>D.stopPropagation(),children:[jsxs("div",{className:"card-detail-header",children:[jsxs("div",{className:"card-detail-header-left",children:[jsx("div",{className:"card-detail-priority-dot",style:{background:B.priority==="URGENT"?"#EF4444":B.priority==="HIGH"?"#F59E0B":B.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),w?jsx("input",{type:"text",value:P.title??B.title,onChange:D=>x({...P,title:D.target.value}),className:"card-detail-title-input",placeholder:"Card title"}):jsx("h2",{className:"card-detail-title",children:B.title})]}),jsxs("div",{className:"card-detail-header-actions",children:[w?jsxs(Fragment,{children:[jsx("button",{onClick:ae,className:"card-detail-btn card-detail-btn-primary",children:"Save"}),jsx("button",{onClick:()=>{v(false),x({});},className:"card-detail-btn",children:"Cancel"})]}):jsxs("button",{onClick:()=>v(true),className:"card-detail-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]}),"Edit"]}),jsxs("button",{onClick:ke,className:"card-detail-btn card-detail-btn-danger",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})]}),"Delete"]}),jsx("button",{onClick:Y,className:"card-detail-btn-close",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),jsxs("div",{className:"card-detail-tabs",children:[jsxs("button",{onClick:()=>l("details"),className:`card-detail-tab ${y==="details"?"active":""}`,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),jsx("polyline",{points:"10 9 9 9 8 9"})]}),"Details"]}),jsxs("button",{onClick:()=>l("comments"),className:`card-detail-tab ${y==="comments"?"active":""}`,children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),"Comments",n.length>0&&jsx("span",{className:"card-detail-tab-badge",children:n.length})]}),jsxs("button",{onClick:()=>l("activity"),className:`card-detail-tab ${y==="activity"?"active":""}`,children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})}),"Activity",c.length>0&&jsx("span",{className:"card-detail-tab-badge",children:c.length})]}),jsxs("button",{onClick:()=>l("attachments"),className:`card-detail-tab ${y==="attachments"?"active":""}`,children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children: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"})}),"Attachments",i.length>0&&jsx("span",{className:"card-detail-tab-badge",children:i.length})]}),jsxs("button",{onClick:()=>l("ai"),className:`card-detail-tab ${y==="ai"?"active":""}`,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),"AI Insights",jsx("span",{className:"card-detail-tab-badge card-detail-tab-badge-ai",children:"AI"})]})]}),jsxs("div",{className:"card-detail-content",children:[y==="details"&&jsxs("div",{className:"card-detail-details",children:[jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Description"}),w?jsx("textarea",{value:P.description??B.description??"",onChange:D=>x({...P,description:D.target.value}),className:"card-detail-textarea",placeholder:"Add a description...",rows:4}):jsx("p",{className:"card-detail-text",children:B.description||"No description"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Assigned To"}),w?jsx("select",{multiple:true,value:P.assignedUserIds??B.assignedUserIds??[],onChange:D=>{let j=Array.from(D.target.selectedOptions,J=>J.value);x({...P,assignedUserIds:j});},className:"card-detail-textarea",style:{height:"120px",padding:"8px 12px"},children:s.map(D=>jsx("option",{value:D.id,children:D.name},D.id))}):jsx("div",{className:"card-detail-users",children:W.length>0?W.map(D=>jsxs("div",{className:"card-detail-user",children:[jsx("div",{className:"card-detail-user-avatar",style:{background:D.color},children:D.initials}),jsx("span",{children:D.name})]},D.id)):jsx("span",{className:"card-detail-empty",children:"Unassigned"})})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Priority"}),w?jsxs("select",{value:P.priority??B.priority??"",onChange:D=>x({...P,priority:D.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"},children:[jsx("option",{value:"",children:"None"}),jsx("option",{value:"LOW",children:"LOW"}),jsx("option",{value:"MEDIUM",children:"MEDIUM"}),jsx("option",{value:"HIGH",children:"HIGH"}),jsx("option",{value:"URGENT",children:"URGENT"})]}):jsxs("div",{className:"card-detail-priority",children:[jsx("div",{className:"card-detail-priority-dot",style:{background:B.priority==="URGENT"?"#EF4444":B.priority==="HIGH"?"#F59E0B":B.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:B.priority||"None"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Labels"}),jsx("div",{className:"card-detail-labels",children:B.labels&&B.labels.length>0?B.labels.map(D=>jsx("span",{className:"card-detail-label-tag",children:D},D)):jsx("span",{className:"card-detail-empty",children:"No labels"})})]}),jsxs("div",{className:"card-detail-section-row",children:[jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Start Date"}),w?jsx("input",{type:"date",value:P.startDate?new Date(P.startDate).toISOString().split("T")[0]:B.startDate?new Date(B.startDate).toISOString().split("T")[0]:"",onChange:D=>x({...P,startDate:D.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:B.startDate?new Date(B.startDate).toLocaleDateString():"Not set"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"End Date"}),w?jsx("input",{type:"date",value:P.endDate?new Date(P.endDate).toISOString().split("T")[0]:B.endDate?new Date(B.endDate).toISOString().split("T")[0]:"",onChange:D=>x({...P,endDate:D.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:B.endDate?new Date(B.endDate).toLocaleDateString():"Not set"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Estimated Hours"}),w?jsx("input",{type:"number",min:"0",step:"0.5",value:P.estimatedTime??B.estimatedTime??"",onChange:D=>x({...P,estimatedTime:D.target.value?parseFloat(D.target.value):void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"},placeholder:"Enter hours"}):jsx("span",{className:"card-detail-text",children:B.estimatedTime||"Not estimated"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Dependencies"}),jsx("div",{className:"card-detail-dependencies",children:B.dependencies&&B.dependencies.length>0?B.dependencies.map(D=>{let j=typeof D=="string"?D:D.taskId;return jsxs("span",{className:"card-detail-dependency",children:["Card #",j.slice(-4)]},j)}):jsx("span",{className:"card-detail-empty",children:"No dependencies"})})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Created"}),jsx("span",{className:"card-detail-text",children:B.createdAt?new Date(B.createdAt).toLocaleString():"Unknown"})]})]}),y==="comments"&&jsxs("div",{className:"card-detail-comments",children:[jsxs("div",{className:"card-detail-comment-form",children:[jsx("textarea",{value:k,onChange:D=>O(D.target.value),className:"card-detail-comment-textarea",placeholder:"Write a comment...",rows:3}),jsx("button",{onClick:Pe,disabled:!k.trim(),className:"card-detail-btn card-detail-btn-primary",children:"Add Comment"})]}),jsx("div",{className:"card-detail-comments-list",children:n.length>0?n.map(D=>{let j=s.find(J=>J.id===D.authorId);return jsxs("div",{className:"card-detail-comment",children:[jsxs("div",{className:"card-detail-comment-header",children:[jsxs("div",{className:"card-detail-comment-author",children:[j&&jsx("div",{className:"card-detail-user-avatar",style:{background:j.color},children:j.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-comment-author-name",children:j?.name||"Unknown"}),jsx("div",{className:"card-detail-comment-time",children:new Date(D.createdAt).toLocaleString()})]})]}),d&&jsx("button",{onClick:()=>d(D.id),className:"card-detail-comment-delete",children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})]})})]}),jsx("p",{className:"card-detail-comment-content",children:D.content})]},D.id)}):jsxs("div",{className:"card-detail-empty-state",children:[jsx("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),jsx("p",{children:"No comments yet"}),jsx("span",{children:"Be the first to comment"})]})})]}),y==="activity"&&jsx("div",{className:"card-detail-activity",children:c.length>0?jsx("div",{className:"card-detail-activity-list",children:c.map(D=>{let j=s.find(J=>J.id===D.userId);return jsxs("div",{className:"card-detail-activity-item",children:[jsxs("div",{className:"card-detail-activity-icon",children:[D.type.includes("CREATED")&&"\u2795",D.type.includes("UPDATED")&&"\u270F\uFE0F",D.type.includes("MOVED")&&"\u27A1\uFE0F",D.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",D.type.includes("COMMENT")&&"\u{1F4AC}",D.type.includes("ASSIGNED")&&"\u{1F464}",D.type.includes("PRIORITY")&&"\u{1F3AF}",D.type.includes("LABEL")&&"\u{1F3F7}\uFE0F",D.type.includes("ATTACHMENT")&&"\u{1F4CE}"]}),jsxs("div",{className:"card-detail-activity-content",children:[jsxs("div",{className:"card-detail-activity-text",children:[jsx("strong",{children:j?.name||"Unknown"})," ",D.type.replace(/_/g," ").toLowerCase(),D.newValue&&jsxs("span",{className:"card-detail-activity-value",children:[" ","to ",jsx("strong",{children:D.newValue})]})]}),jsx("div",{className:"card-detail-activity-time",children:new Date(D.timestamp).toLocaleString()})]})]},D.id)})}):jsxs("div",{className:"card-detail-empty-state",children:[jsx("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})}),jsx("p",{children:"No activity yet"}),jsx("span",{children:"Activity will appear here"})]})}),y==="attachments"&&jsx("div",{className:"card-detail-attachments",children:jsx(dr,{cardId:e.id,attachments:i,onUpload:g?D=>g(e.id,D):void 0,onDelete:h,currentUserId:b,maxSizeMB:10,maxFiles:20})}),y==="ai"&&jsxs("div",{className:"card-detail-ai",children:[jsxs("div",{className:"card-detail-ai-actions",children:[jsx("h3",{className:"card-detail-ai-heading",children:"AI-Powered Suggestions"}),jsxs("button",{onClick:Ve,disabled:M||!C,className:"card-detail-ai-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),"Suggest Best Assignee"]}),jsxs("button",{onClick:Je,disabled:M||!T,className:"card-detail-ai-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"8",y1:"6",x2:"21",y2:"6"}),jsx("line",{x1:"8",y1:"12",x2:"21",y2:"12"}),jsx("line",{x1:"8",y1:"18",x2:"21",y2:"18"}),jsx("line",{x1:"3",y1:"6",x2:"3.01",y2:"6"}),jsx("line",{x1:"3",y1:"12",x2:"3.01",y2:"12"}),jsx("line",{x1:"3",y1:"18",x2:"3.01",y2:"18"})]}),"Generate Subtasks"]}),jsxs("button",{onClick:$,disabled:M||!m,className:"card-detail-ai-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Estimate Effort"]})]}),H.assignees&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Assignee Suggestions"}),H.assignees.map((D,j)=>{let J=s.find(R=>R.id===D.userId);return jsxs("div",{className:"card-detail-ai-suggestion",children:[J&&jsx("div",{className:"card-detail-user-avatar",style:{background:J.color},children:J.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-ai-suggestion-name",children:J?.name}),jsx("div",{className:"card-detail-ai-suggestion-reason",children:D.reasoning}),jsxs("div",{className:"card-detail-ai-suggestion-confidence",children:["Confidence: ",(D.confidence*100).toFixed(0),"%"]})]})]},j)})]}),H.subtasks&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Suggested Subtasks"}),H.subtasks.map((D,j)=>jsxs("div",{className:"card-detail-ai-subtask",children:[jsx("div",{className:"card-detail-ai-subtask-title",children:D.title}),D.description&&jsx("div",{className:"card-detail-ai-subtask-desc",children:D.description}),D.estimatedTime&&jsxs("div",{className:"card-detail-ai-subtask-time",children:["Est: ",D.estimatedTime,"h"]})]},j))]}),H.effort&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Effort Estimate"}),jsxs("div",{className:"card-detail-ai-effort",children:[jsxs("div",{className:"card-detail-ai-effort-hours",children:[H.effort.hours," hours"]}),jsxs("div",{className:"card-detail-ai-effort-confidence",children:["Confidence: ",(H.effort.confidence*100).toFixed(0),"%"]})]})]}),p.length>0&&jsxs("div",{className:"card-detail-ai-insights",children:[jsx("h4",{children:"AI Insights"}),p.map(D=>jsxs("div",{className:`card-detail-ai-insight card-detail-ai-insight-${D.severity.toLowerCase()}`,children:[jsxs("div",{className:"card-detail-ai-insight-header",children:[jsx("span",{className:"card-detail-ai-insight-title",children:D.title}),jsx("span",{className:"card-detail-ai-insight-severity",children:D.severity})]}),jsx("p",{className:"card-detail-ai-insight-desc",children:D.description}),D.suggestedAction&&jsxs("div",{className:"card-detail-ai-insight-action",children:["\u{1F4A1} ",D.suggestedAction]})]},D.id))]}),!H.assignees&&!H.subtasks&&!H.effort&&p.length===0&&jsxs("div",{className:"card-detail-empty-state",children:[jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),jsx("p",{children:"AI Suggestions"}),jsx("span",{children:"Click a button above to get AI-powered insights"})]})]})]})]})})})}function Ao({triggerRef:e,isOpen:t,onClose:a,children:r,width:o=200,estimatedHeight:s=300,className:n=""}){let[c,p]=useState({top:0,left:0}),i=useRef(null),u=useCallback(()=>{if(!e.current)return {top:0,left:0};let d=e.current.getBoundingClientRect(),g=window.innerHeight,h=window.innerWidth,C=4,T=d.left;T+o>h-10&&(T=h-o-10),T<10&&(T=10);let m=g-d.bottom,b=d.top,y;return m>=s+C?y=d.bottom+C:b>=s+C?y=d.top-s-C:m>=b?y=d.bottom+C:y=Math.max(10,d.top-s-C),{top:y,left:T}},[e,o,s]);return useEffect(()=>{t&&p(u());},[t,u]),useEffect(()=>{if(!t)return;let d=h=>{let C=h.target;i.current&&!i.current.contains(C)&&e.current&&!e.current.contains(C)&&a();},g=setTimeout(()=>{document.addEventListener("mousedown",d);},0);return ()=>{clearTimeout(g),document.removeEventListener("mousedown",d);}},[t,a,e]),useEffect(()=>{if(!t)return;let d=g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),a());};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,a]),t?jsx(gt,{children:jsx("div",{ref:i,className:`smart-popover ${n}`,style:{position:"fixed",top:`${c.top}px`,left:`${c.left}px`,width:`${o}px`,maxHeight:"calc(100vh - 40px)",overflowY:"auto",zIndex:99999,padding:"6px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",borderRadius:"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",animation:"popoverSlideIn 100ms ease-out"},children:r})}):null}var Ze={dark:{bgPrimary:"#1A1D21",bgSecondary:"#22262D",bgGrid:"#1E2126",bgWeekend:"rgba(59, 130, 246, 0.03)",border:"#334155",borderLight:"#2D3139",textPrimary:"#FFFFFF",textSecondary:"#CBD5E1",textTertiary:"#64748B",accent:"#3B82F6",accentHover:"#60A5FA",accentLight:"rgba(59, 130, 246, 0.12)",taskBarPrimary:"#3B82F6",taskBarProgress:"#2563EB",taskBarHandle:"#FFFFFF",dependency:"rgba(180, 185, 197, 0.25)",dependencyHover:"rgba(180, 185, 197, 0.45)",criticalPath:"#EF4444",criticalPathLight:"rgba(239, 68, 68, 0.12)",today:"#D21E24",todayLight:"rgba(210, 30, 36, 0.12)",milestone:"#F59E0B",milestoneLight:"rgba(245, 158, 11, 0.1)",statusTodo:"#64748B",statusInProgress:"#3B82F6",statusCompleted:"#10B981",hoverBg:"rgba(255, 255, 255, 0.06)",focusRing:"#3B82F6"},light:{bgPrimary:"#FFFFFF",bgSecondary:"#F8FAFC",bgGrid:"#F1F5F9",bgWeekend:"rgba(37, 99, 235, 0.03)",border:"#CBD5E1",borderLight:"#E2E8F0",textPrimary:"#0F172A",textSecondary:"#334155",textTertiary:"#64748B",accent:"#2563EB",accentHover:"#1D4ED8",accentLight:"rgba(37, 99, 235, 0.08)",taskBarPrimary:"#2563EB",taskBarProgress:"#1E40AF",taskBarHandle:"#FFFFFF",dependency:"rgba(75, 85, 99, 0.25)",dependencyHover:"rgba(75, 85, 99, 0.45)",criticalPath:"#DC2626",criticalPathLight:"rgba(220, 38, 38, 0.1)",today:"#D21E24",todayLight:"rgba(210, 30, 36, 0.1)",milestone:"#F59E0B",milestoneLight:"rgba(245, 158, 11, 0.08)",statusTodo:"#64748B",statusInProgress:"#2563EB",statusCompleted:"#059669",hoverBg:"rgba(0, 0, 0, 0.04)",focusRing:"#2563EB"},neutral:{bgPrimary:"#FAFAF9",bgSecondary:"#F5F5F4",bgGrid:"#EFEDEC",bgWeekend:"rgba(41, 37, 36, 0.02)",border:"#D6D3D1",borderLight:"#E7E5E4",textPrimary:"#0C0A09",textSecondary:"#44403C",textTertiary:"#78716C",accent:"#292524",accentHover:"#44403C",accentLight:"rgba(41, 37, 36, 0.08)",taskBarPrimary:"#292524",taskBarProgress:"#1C1917",taskBarHandle:"#FFFFFF",dependency:"rgba(87, 83, 78, 0.25)",dependencyHover:"rgba(87, 83, 78, 0.4)",criticalPath:"#44403C",criticalPathLight:"rgba(68, 64, 60, 0.08)",today:"#1C1917",todayLight:"rgba(28, 25, 23, 0.06)",milestone:"#57534E",milestoneLight:"rgba(87, 83, 78, 0.08)",statusTodo:"#78716C",statusInProgress:"#292524",statusCompleted:"#15803D",hoverBg:"rgba(0, 0, 0, 0.035)",focusRing:"#292524"}};var zu=["LOW","MEDIUM","HIGH","URGENT"],Uu=["todo","in-progress","review","done"];function Fs({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:c=[],onAddComment:p,onDeleteComment:i,currentUser:u,onAIGenerateDescription:d,onAICreateSubtasks:g,onAIFindSimilar:h,availableColumns:C=[],availableLabels:T=[],availableTags:m=[],onCreateTag:b,onUploadCoverImage:y,unsplashAccessKey:l,theme:w,onSubtasksChange:v,attachments:P=[],onUploadAttachments:x,onDeleteAttachment:k}){let O=oo(),M=w||O?.themeName||"dark",[N,H]=useState(e),[L,Y]=useState(false),[ae,ke]=useState(e?.subtasks||[]),[Pe,Ve]=useState(false),[Je,$]=useState(""),[B,W]=useState(""),[D,j]=useState("all"),[J,R]=useState(false),[de,we]=useState(false),[Me,ce]=useState(false),[We,Fe]=useState(false),[Ye,ut]=useState(false),[yt,nt]=useState(false),z=useRef(null),re=useRef(null),oe=useRef(null),xe=useRef(null),Ne=useRef(null),tt=useRef(null),ht=useRef(null),Ie=useRef(null),be=useRef(null),Se=useRef(null),Ft=useRef(null),bt=useRef(null);useEffect(()=>{e&&!N?(H({...e}),ke(e.subtasks||[])):e&&N&&e.id!==N.id&&(H({...e}),ke(e.subtasks||[]));},[e,N]),useEffect(()=>{let G=ee=>{let Be=ee.target;xe.current&&!xe.current.contains(Be)&&R(false),Ne.current&&!Ne.current.contains(Be)&&we(false),tt.current&&!tt.current.contains(Be)&&ce(false),ht.current&&!ht.current.contains(Be)&&Fe(false);};if(J||de||Me||We)return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[J,de,Me,We]),useEffect(()=>{if(!t)return;let G=ee=>{let Be=ee.target,Et=Be.tagName==="INPUT"||Be.tagName==="TEXTAREA"||Be.isContentEditable;if(ee.key==="Escape"){ee.preventDefault(),J||de||Me||We||Ye||yt?(R(false),we(false),ce(false),Fe(false),ut(false),nt(false)):Et||a();return}if(Et&&ee.key!=="Escape")return;let dt=ee.metaKey||ee.ctrlKey;switch(ee.key.toLowerCase()){case "s":ee.preventDefault(),R(true);break;case "a":ee.preventDefault(),ce(true);break;case "p":ee.preventDefault(),we(true);break;case "l":ee.preventDefault(),Fe(true);break;case "d":dt||(ee.preventDefault(),ut(true),setTimeout(()=>Ie.current?.focus(),0));break;case "e":dt||(ee.preventDefault(),nt(true));break;case "i":ee.preventDefault(),Y(true),setTimeout(()=>re.current?.focus(),0);break;case "t":ee.preventDefault(),Ve(true);break;case "c":ee.preventDefault(),oe.current?.focus();break}};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[t,a,J,de,Me,We,Ye,yt]);let sa=useCallback(G=>{let ee=G.currentTarget.textContent?.trim()||"";if(N&&ee!==N.title){let Be={...N,title:ee};H(Be),r?.(N.id,{title:ee});}},[N,r]),ua=useCallback(G=>{G.key==="Enter"&&(G.preventDefault(),G.currentTarget.blur()),G.key==="Escape"&&(G.preventDefault(),G.currentTarget.textContent=N?.title||"",G.currentTarget.blur());},[N]),$e=useCallback(()=>{N&&e&&N.description!==e.description&&r?.(N.id,{description:N.description}),Y(false);},[N,e,r]),Ue=useCallback(G=>{if(N){let ee={...N,columnId:G};H(ee),r?.(N.id,{columnId:G}),R(false);}},[N,r]),ia=useCallback(G=>{if(N){let ee={...N,priority:G};H(ee),r?.(N.id,{priority:G}),we(false);}},[N,r]),ue=useCallback(G=>{if(N){let ee=N.assignedUserIds||[],Be=ee.includes(G)?ee.filter(dt=>dt!==G):[...ee,G],Et={...N,assignedUserIds:Be};H(Et),r?.(N.id,{assignedUserIds:Be});}},[N,r]),S=useCallback(G=>{if(N){let ee=N.labels||[],Be=ee.includes(G)?ee.filter(dt=>dt!==G):[...ee,G],Et={...N,labels:Be};H(Et),r?.(N.id,{labels:Be});}},[N,r]),Z=useCallback(G=>{if(N){let ee={...N,tags:G};H(ee),r?.(N.id,{tags:G});}},[N,r]),ge=useCallback(G=>{if(N){let ee=G.target.value,Be={...N,endDate:ee};H(Be),r?.(N.id,{endDate:ee}),ut(false);}},[N,r]),Te=useCallback(G=>{if(N){let ee={...N,estimatedTime:parseFloat(G)||0};H(ee),r?.(N.id,{estimatedTime:parseFloat(G)||0});}},[N,r]),qe=useCallback(()=>{if(Je.trim()&&N){let G={id:`subtask-${Date.now()}`,title:Je.trim(),completed:false,createdAt:new Date},ee=[...ae,G];ke(ee),$(""),Ve(false),v?.(N.id,ee);}},[Je,ae,N,v]),Ge=useCallback(G=>{let ee=ae.map(Be=>Be.id===G?{...Be,completed:!Be.completed,updatedAt:new Date}:Be);ke(ee),N&&v?.(N.id,ee);},[ae,N,v]),Re=useCallback(G=>{let ee=ae.filter(Be=>Be.id!==G);ke(ee),N&&v?.(N.id,ee);},[ae,N,v]),at=useCallback(()=>{B.trim()&&N&&p&&(p(N.id,B.trim()),W(""));},[B,N,p]),lt=useCallback(G=>{(G.metaKey||G.ctrlKey)&&G.key==="Enter"&&(G.preventDefault(),at());},[at]),K=G=>jsx(Bu,{remarkPlugins:[Ru],rehypePlugins:[Ou],components:{a:({node:ee,...Be})=>jsx("a",{...Be,target:"_blank",rel:"noopener noreferrer"})},children:G}),te=c.filter(G=>D==="comments"?G.type.includes("COMMENT"):D==="history"?!G.type.includes("COMMENT"):true);if(!t||!e)return null;let Ee=N||e,He=s.filter(G=>Ee.assignedUserIds?.includes(G.id)),Oe=ae.filter(G=>G.completed).length;return jsx(gt,{children:jsx("div",{className:"modal-v2-backdrop",onClick:a,style:{position:"fixed",inset:"0",zIndex:9999,background:"rgba(0, 0, 0, 0.7)",display:"flex",alignItems:"center",justifyContent:"center"},children:jsxs("div",{className:"modal-v2-container",onClick:G=>G.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"modal-title","data-theme":M,children:[jsxs("header",{className:"modal-v2-header",children:[jsx("h1",{id:"modal-title",ref:z,className:"modal-v2-title",contentEditable:true,suppressContentEditableWarning:true,onBlur:sa,onKeyDown:ua,children:Ee.title}),jsxs("p",{className:"modal-v2-ai-prompt",children:[jsx("span",{className:"modal-v2-ai-icon",children:"\u2728"}),"Ask AI to write a description, create subtasks, or find similar tasks"]}),jsx("button",{className:"modal-v2-close",onClick:a,"aria-label":"Close",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("section",{className:"modal-v2-metadata",children:[jsxs("div",{className:"modal-v2-field-wrapper",ref:xe,children:[jsxs("button",{ref:be,className:"modal-v2-field",onClick:()=>R(!J),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M12 6v6l4 2"})]}),jsx("span",{children:"Status"}),jsx("kbd",{className:"modal-v2-shortcut",children:"S"})]}),jsx("div",{className:"modal-v2-field-value",children:Ee.columnId||"No status"})]}),jsx(Ao,{triggerRef:be,isOpen:J,onClose:()=>R(false),width:250,estimatedHeight:200,children:(C.length>0?C:Uu.map(G=>({id:G,title:G}))).map(G=>jsx("button",{className:`modal-v2-popover-item ${Ee.columnId===G.id?"active":""}`,onClick:()=>Ue(G.id),children:G.title},G.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:tt,children:[jsxs("button",{ref:Se,className:"modal-v2-field",onClick:()=>ce(!Me),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),jsx("span",{children:"Assignees"}),jsx("kbd",{className:"modal-v2-shortcut",children:"A"})]}),jsx("div",{className:"modal-v2-field-value",children:He.length>0?jsx("div",{className:"modal-v2-avatars",children:He.map(G=>jsx("div",{className:"modal-v2-avatar",style:{background:G.color},title:G.name,children:G.initials},G.id))}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(Ao,{triggerRef:Se,isOpen:Me,onClose:()=>ce(false),width:280,estimatedHeight:300,children:s.map(G=>jsxs("button",{className:`modal-v2-popover-item ${Ee.assignedUserIds?.includes(G.id)?"active":""}`,onClick:()=>ue(G.id),children:[jsx("div",{className:"modal-v2-avatar-small",style:{background:G.color},children:G.initials}),G.name,Ee.assignedUserIds?.includes(G.id)&&jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{marginLeft:"auto"},children:jsx("polyline",{points:"20 6 9 17 4 12"})})]},G.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:Ne,children:[jsxs("button",{ref:Ft,className:"modal-v2-field",onClick:()=>we(!de),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),jsx("span",{children:"Priority"}),jsx("kbd",{className:"modal-v2-shortcut",children:"P"})]}),jsx("div",{className:"modal-v2-field-value",children:Ee.priority||"None"})]}),jsxs(Ao,{triggerRef:Ft,isOpen:de,onClose:()=>we(false),width:180,estimatedHeight:220,children:[zu.map(G=>jsx("button",{className:`modal-v2-popover-item priority-${G.toLowerCase()} ${Ee.priority===G?"active":""}`,onClick:()=>ia(G),children:G},G)),jsx("button",{className:"modal-v2-popover-item",onClick:()=>ia(""),children:"None"})]})]}),m.length>0||b?jsx("div",{className:"modal-v2-field-wrapper",children:jsxs("div",{className:"modal-v2-field",style:{cursor:"default"},children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 01-2.83 0L2 12V2h10l8.59 8.59a2 2 0 010 2.82z"}),jsx("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]}),jsx("span",{children:"Etiquetas"})]}),jsx("div",{className:"modal-v2-field-value",children:jsx(nr,{selectedTags:Ee.tags||[],availableTags:m,onChange:Z,onCreateTag:b,theme:Ze[M]||Ze.dark})})]})}):jsxs("div",{className:"modal-v2-field-wrapper",ref:ht,children:[jsxs("button",{ref:bt,className:"modal-v2-field",onClick:()=>Fe(!We),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 01-2.83 0L2 12V2h10l8.59 8.59a2 2 0 010 2.82z"}),jsx("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]}),jsx("span",{children:"Labels"}),jsx("kbd",{className:"modal-v2-shortcut",children:"L"})]}),jsx("div",{className:"modal-v2-field-value",children:Ee.labels&&Ee.labels.length>0?jsx("span",{children:Ee.labels.join(", ")}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(Ao,{triggerRef:bt,isOpen:We,onClose:()=>Fe(false),width:220,estimatedHeight:200,children:(T.length>0?T:["Bug","Feature","Enhancement","Documentation"]).map(G=>jsxs("button",{className:`modal-v2-popover-item ${Ee.labels?.includes(G)?"active":""}`,onClick:()=>S(G),children:[G,Ee.labels?.includes(G)&&jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{marginLeft:"auto"},children:jsx("polyline",{points:"20 6 9 17 4 12"})})]},G))})]}),jsxs("button",{className:"modal-v2-field",onClick:()=>{ut(!Ye),setTimeout(()=>Ie.current?.showPicker?.(),0);},children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),jsx("span",{children:"Due Date"}),jsx("kbd",{className:"modal-v2-shortcut",children:"D"})]}),jsx("div",{className:"modal-v2-field-value",children:Ee.endDate?new Date(Ee.endDate).toLocaleDateString():"Not set"}),jsx("input",{ref:Ie,type:"date",value:typeof Ee.endDate=="string"?Ee.endDate.split("T")[0]:Ee.endDate?(()=>{let G=new Date(Ee.endDate),ee=G.getUTCFullYear(),Be=String(G.getUTCMonth()+1).padStart(2,"0"),Et=String(G.getUTCDate()).padStart(2,"0");return `${ee}-${Be}-${Et}`})():"",onChange:ge,style:{position:"absolute",opacity:0,pointerEvents:"none"}})]}),jsxs("div",{className:"modal-v2-field-wrapper",children:[jsxs("button",{className:"modal-v2-field",onClick:()=>nt(!yt),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx("span",{children:"Estimated Time"}),jsx("kbd",{className:"modal-v2-shortcut",children:"E"})]}),jsx("div",{className:"modal-v2-field-value",children:Ee.estimatedTime?`${Ee.estimatedTime}h`:"Not set"})]}),yt&&jsx("div",{className:"modal-v2-popover",children:jsx("input",{type:"number",min:"0",step:"0.5",placeholder:"Hours",value:Ee.estimatedTime||"",onChange:G=>Te(G.target.value),className:"modal-v2-time-input",autoFocus:true,onBlur:()=>nt(false)})})]})]}),jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),jsx("polyline",{points:"10 9 9 9 8 9"})]}),jsx("h2",{children:"Description"})]}),L?jsx("textarea",{className:"modal-v2-textarea",value:Ee.description||"",onChange:G=>{if(N){let ee={...N,description:G.target.value};H(ee);}},onBlur:$e,placeholder:"Add a detailed description...",autoFocus:true}):jsx("div",{className:"modal-v2-content",onClick:()=>Y(true),children:Ee.description?jsx("div",{className:"modal-v2-markdown",children:K(Ee.description)}):jsxs("p",{className:"modal-v2-placeholder",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]}),"Add description..."]})})]}),jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M9 11l3 3L22 4"}),jsx("path",{d:"M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"})]}),jsx("h2",{children:"Subtasks"}),ae.length>0&&jsxs("span",{className:"modal-v2-count",children:[Oe,"/",ae.length]}),jsxs("button",{className:"modal-v2-add-button",onClick:()=>Ve(true),children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add"]})]}),jsxs("div",{className:"modal-v2-subtasks",children:[ae.map(G=>jsxs("div",{className:`modal-v2-subtask ${G.completed?"completed":""}`,children:[jsx("button",{className:"modal-v2-subtask-checkbox",onClick:()=>Ge(G.id),children:G.completed?jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9 12l2 2 4-4",stroke:"white",strokeWidth:"2",fill:"none"})]}):jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("circle",{cx:"12",cy:"12",r:"10"})})}),jsx("span",{className:"modal-v2-subtask-title",children:G.title}),jsx("button",{className:"modal-v2-subtask-delete",onClick:()=>Re(G.id),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})]})})]},G.id)),Pe&&jsx("div",{className:"modal-v2-subtask-input-row",children:jsx("input",{type:"text",placeholder:"Subtask title...",value:Je,onChange:G=>$(G.target.value),onKeyDown:G=>{G.key==="Enter"&&qe(),G.key==="Escape"&&(Ve(false),$(""));},onBlur:qe,autoFocus:true,className:"modal-v2-subtask-input"})})]})]}),(x||P.length>0)&&jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children: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"})}),jsx("h2",{children:"Attachments"}),P.length>0&&jsx("span",{className:"modal-v2-count",children:P.length})]}),jsx(dr,{cardId:Ee.id,attachments:P,onUpload:x?G=>x(Ee.id,G):void 0,onDelete:k,maxSizeMB:10,maxFiles:20})]}),jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),jsx("h2",{children:"Activity"}),jsxs("div",{className:"modal-v2-filters",children:[jsx("button",{className:`modal-v2-filter ${D==="all"?"active":""}`,onClick:()=>j("all"),children:"All"}),jsx("button",{className:`modal-v2-filter ${D==="comments"?"active":""}`,onClick:()=>j("comments"),children:"Comments"}),jsx("button",{className:`modal-v2-filter ${D==="history"?"active":""}`,onClick:()=>j("history"),children:"History"})]})]}),jsxs("div",{className:"modal-v2-comment-input",children:[u&&jsx("div",{className:"modal-v2-avatar",style:{background:u.color},children:u.initials}),jsxs("div",{className:"modal-v2-comment-wrapper",children:[jsx("textarea",{ref:oe,className:"modal-v2-comment-textarea",placeholder:"Write a comment...",value:B,onChange:G=>W(G.target.value),onKeyDown:lt,rows:1}),jsxs("div",{className:"modal-v2-comment-toolbar",children:[jsxs("div",{className:"modal-v2-toolbar-left",children:[jsx("button",{className:"modal-v2-toolbar-button",title:"Attach file",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children: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"})})}),jsx("button",{className:"modal-v2-toolbar-button",title:"Mention user",children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"4"}),jsx("path",{d:"M16 8v5a3 3 0 006 0v-1a10 10 0 10-3.92 7.94"})]})}),jsx("button",{className:"modal-v2-toolbar-button",title:"Add emoji",children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M8 14s1.5 2 4 2 4-2 4-2"}),jsx("line",{x1:"9",y1:"9",x2:"9.01",y2:"9"}),jsx("line",{x1:"15",y1:"9",x2:"15.01",y2:"9"})]})})]}),jsx("button",{className:"modal-v2-send-button",onClick:at,disabled:!B.trim(),children:"Send"})]})]})]}),jsxs("div",{className:"modal-v2-timeline",children:[te.map(G=>{let ee=s.find(Et=>Et.id===G.userId);if(G.type.includes("COMMENT")){let Et=n.find(dt=>dt.id===G.metadata?.commentId);return Et?jsxs("div",{className:"modal-v2-activity-item comment-item",children:[ee&&jsx("div",{className:"modal-v2-avatar",style:{background:ee.color},children:ee.initials}),jsxs("div",{className:"modal-v2-activity-content",children:[jsxs("div",{className:"modal-v2-activity-header",children:[jsx("span",{className:"modal-v2-activity-user",children:ee?.name||"Unknown"}),jsx("span",{className:"modal-v2-activity-time",children:new Date(G.timestamp).toLocaleString()})]}),jsx("div",{className:"modal-v2-comment-body",children:Et.content})]})]},G.id):null}return jsxs("div",{className:"modal-v2-activity-item history-item",children:[jsxs("div",{className:"modal-v2-history-icon",children:[G.type.includes("CREATED")&&"\u2795",G.type.includes("UPDATED")&&"\u270F\uFE0F",G.type.includes("MOVED")&&"\u27A1\uFE0F",G.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",G.type.includes("ASSIGNED")&&"\u{1F464}",G.type.includes("PRIORITY")&&"\u{1F3AF}",G.type.includes("LABEL")&&"\u{1F3F7}\uFE0F"]}),jsxs("div",{className:"modal-v2-activity-content",children:[jsxs("div",{className:"modal-v2-history-text",children:[jsx("span",{className:"modal-v2-activity-user",children:ee?.name||"Unknown"})," ",G.type.replace(/_/g," ").toLowerCase(),G.newValue&&jsxs(Fragment,{children:[" to ",jsx("strong",{children:G.newValue})]})]}),jsx("span",{className:"modal-v2-activity-time",children:new Date(G.timestamp).toLocaleString()})]})]},G.id)}),te.length===0&&jsxs("div",{className:"modal-v2-empty",children:[jsx("p",{children:"No activity yet"}),jsx("span",{children:"Activity will appear here"})]})]})]})]})})})}function Yu({active:e,payload:t}){return !e||!t||!t.length?null:jsxs("div",{className:"chart-tooltip",children:[jsx("p",{className:"chart-tooltip-label",children:t[0].payload.period}),t.map((a,r)=>jsxs("p",{className:"chart-tooltip-value",style:{color:a.color},children:[a.name,": ",jsx("strong",{children:a.value})," cards"]},r))]})}function Ls({data:e,title:t="Team Velocity",height:a=300,showAverage:r=true,showPlanned:o=true}){let s=e.map(n=>({...n,average:n.average??e.reduce((c,p)=>c+p.completed,0)/e.length}));return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:a,children:jsxs(LineChart,{data:s,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"period",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(Yu,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),jsx(Line,{type:"monotone",dataKey:"completed",stroke:"#10B981",strokeWidth:3,name:"Completed",dot:{fill:"#10B981",r:5},activeDot:{r:7}}),o&&jsx(Line,{type:"monotone",dataKey:"planned",stroke:"#3B82F6",strokeWidth:2,strokeDasharray:"5 5",name:"Planned",dot:{fill:"#3B82F6",r:4}}),r&&jsx(Line,{type:"monotone",dataKey:"average",stroke:"#F59E0B",strokeWidth:2,strokeDasharray:"3 3",name:"Average",dot:false})]})}),jsxs("div",{className:"chart-stats",children:[jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Total Completed"}),jsx("span",{className:"chart-stat-value",style:{color:"#10B981"},children:e.reduce((n,c)=>n+c.completed,0)})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Average Velocity"}),jsx("span",{className:"chart-stat-value",style:{color:"#F59E0B"},children:(e.reduce((n,c)=>n+c.completed,0)/e.length).toFixed(1)})]}),o&&e.some(n=>n.planned)&&jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Total Planned"}),jsx("span",{className:"chart-stat-value",style:{color:"#3B82F6"},children:e.reduce((n,c)=>n+(c.planned||0),0)})]})]})]})}function rg({active:e,payload:t}){return !e||!t||!t.length?null:jsxs("div",{className:"chart-tooltip",children:[jsx("p",{className:"chart-tooltip-label",children:t[0].payload.day}),t.map((a,r)=>jsxs("p",{className:"chart-tooltip-value",style:{color:a.color},children:[a.name,": ",jsx("strong",{children:a.value})," tasks"]},r))]})}function Bs({data:e,title:t="Sprint Burndown",height:a=300,totalTasks:r,useArea:o=false}){let s=r??(e[0]?.ideal||e[0]?.remaining||0),n=e[e.length-1]?.remaining||0,c=e[e.length-1]?.ideal||0,p=s>0?(s-n)/s*100:0,i=n<=c;return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:a,children:jsxs(o?AreaChart:LineChart,{data:e,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"day",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(rg,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),o?jsxs(Fragment,{children:[jsx(Area,{type:"monotone",dataKey:"ideal",stroke:"#F59E0B",fill:"rgba(245, 158, 11, 0.2)",strokeWidth:2,strokeDasharray:"5 5",name:"Ideal"}),jsx(Area,{type:"monotone",dataKey:"remaining",stroke:i?"#10B981":"#EF4444",fill:i?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",strokeWidth:3,name:"Remaining"})]}):jsxs(Fragment,{children:[jsx(Line,{type:"linear",dataKey:"ideal",stroke:"#F59E0B",strokeWidth:2,strokeDasharray:"5 5",name:"Ideal",dot:{fill:"#F59E0B",r:4}}),jsx(Line,{type:"monotone",dataKey:"remaining",stroke:i?"#10B981":"#EF4444",strokeWidth:3,name:"Remaining",dot:{fill:i?"#10B981":"#EF4444",r:5},activeDot:{r:7}})]})]})}),jsxs("div",{className:"chart-stats",children:[jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Progress"}),jsxs("span",{className:"chart-stat-value",style:{color:p>=50?"#10B981":"#F59E0B"},children:[p.toFixed(0),"%"]})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Remaining"}),jsx("span",{className:"chart-stat-value",style:{color:i?"#10B981":"#EF4444"},children:n})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Status"}),jsx("span",{className:"chart-stat-badge",style:{background:i?"rgba(16, 185, 129, 0.15)":"rgba(239, 68, 68, 0.15)",color:i?"#10B981":"#EF4444"},children:i?"\u2713 On Track":"\u26A0 Behind"})]})]})]})}var pg={URGENT:"#EF4444",HIGH:"#F59E0B",MEDIUM:"#3B82F6",LOW:"#10B981"},Cd=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899"];function ug({cx:e,cy:t,midAngle:a,innerRadius:r,outerRadius:o,percent:s}){let n=r+(o-r)*.5,c=e+n*Math.cos(-a*(Math.PI/180)),p=t+n*Math.sin(-a*(Math.PI/180));return s<.05?null:jsx("text",{x:c,y:p,fill:"white",textAnchor:c>e?"start":"end",dominantBaseline:"central",style:{fontSize:"12px",fontWeight:600},children:`${(s*100).toFixed(0)}%`})}function Td({active:e,payload:t}){if(!e||!t||!t.length)return null;let a=t[0].payload,r=t[0].payload.totalValue||0,o=r>0?(a.value/r*100).toFixed(1):"0";return jsxs("div",{className:"chart-tooltip",children:[jsx("p",{className:"chart-tooltip-label",children:a.name}),jsxs("p",{className:"chart-tooltip-value",style:{color:a.color||t[0].color},children:["Count: ",jsx("strong",{children:a.value})]}),jsxs("p",{className:"chart-tooltip-value",style:{color:"rgba(255, 255, 255, 0.7)"},children:["Percentage: ",jsxs("strong",{children:[o,"%"]})]})]})}function Rs({data:e,title:t="Distribution",type:a="pie",height:r=300,showPercentages:o=true}){let s=e.reduce((p,i)=>p+i.value,0),n=e.map(p=>({...p,totalValue:s,color:p.color||pg[p.name]||Cd[e.indexOf(p)%Cd.length]})),c=n.map(p=>p.color);return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:r,children:a==="pie"?jsxs(PieChart,{children:[jsx(Pie,{data:n,cx:"50%",cy:"50%",labelLine:false,label:o?ug:false,outerRadius:r*.35,fill:"#8884d8",dataKey:"value",children:n.map((p,i)=>jsx(Cell,{fill:c[i]},`cell-${i}`))}),jsx(Tooltip,{content:jsx(Td,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"},formatter:(p,i)=>{let u=i.payload,d=s>0?(u.value/s*100).toFixed(0):"0";return `${p} (${u.value} - ${d}%)`}})]}):jsxs(BarChart,{data:n,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"name",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(Td,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),jsx(Bar,{dataKey:"value",name:"Count",radius:[8,8,0,0],children:n.map((p,i)=>jsx(Cell,{fill:c[i]},`cell-${i}`))})]})}),jsxs("div",{className:"chart-stats",children:[jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Total Cards"}),jsx("span",{className:"chart-stat-value",style:{color:"#3B82F6"},children:s})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Categories"}),jsx("span",{className:"chart-stat-value",style:{color:"#10B981"},children:e.length})]}),e.length>0&&jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Largest Category"}),jsx("span",{className:"chart-stat-value",style:{color:"#F59E0B"},children:e.reduce((p,i)=>i.value>p.value?i:p).name})]})]})]})}var fn=memo(({selectedCards:e,availableUsers:t=[],onClearSelection:a,callbacks:r,columns:o=[],availableLabels:s=[]})=>{let[n,c]=useState(false),[p,i]=useState(false),[u,d]=useState(false),[g,h]=useState(false);if(e.length===0)return null;let C=e.map(w=>w.id),T=w=>{r.onBulkUpdate?.(C,{priority:w}),c(false);},m=w=>{r.onBulkMove?.(C,w),i(false),a();},b=w=>{r.onBulkUpdate?.(C,{assignedUserIds:w}),d(false);},y=w=>{let v=new Set;e.forEach(x=>{x.labels?.forEach(k=>v.add(k));});let P=Array.from(new Set([...v,...w]));r.onBulkUpdate?.(C,{labels:P}),h(false);},l=()=>{confirm(`Delete ${e.length} card(s)? This cannot be undone.`)&&(r.onBulkDelete?.(C),a());};return jsx("div",{className:"asakaa-bulk-toolbar",children:jsxs("div",{className:"asakaa-bulk-toolbar-content",children:[jsxs("div",{className:"asakaa-bulk-toolbar-count",children:[e.length," card",e.length!==1?"s":""," selected"]}),jsxs("div",{className:"asakaa-bulk-toolbar-actions",children:[jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>c(!n),title:"Update priority",children:jsx("span",{className:"text-sm",children:"Priority"})}),n&&jsx("div",{className:"asakaa-bulk-menu",children:["LOW","MEDIUM","HIGH","URGENT"].map(w=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>T(w),children:[jsx("span",{className:f("asakaa-priority-dot",w==="LOW"&&"bg-asakaa-priority-low",w==="MEDIUM"&&"bg-asakaa-priority-medium",w==="HIGH"&&"bg-asakaa-priority-high",w==="URGENT"&&"bg-asakaa-priority-urgent")}),w]},w))})]}),o.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>i(!p),title:"Move to column",children:jsx("span",{className:"text-sm",children:"Move"})}),p&&jsx("div",{className:"asakaa-bulk-menu",children:o.map(w=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>m(w.id),children:w.title},w.id))})]}),t.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>d(!u),title:"Assign users",children:jsx("span",{className:"text-sm",children:"Assign"})}),u&&jsx("div",{className:"asakaa-bulk-menu",children:t.map(w=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>b([w.id]),children:[jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs font-medium",style:{backgroundColor:w.color},children:w.initials}),w.name]},w.id))})]}),s.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>h(!g),title:"Add labels",children:jsx("span",{className:"text-sm",children:"Labels"})}),g&&jsx("div",{className:"asakaa-bulk-menu",children:s.map(w=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>y([w]),children:w},w))})]}),jsx("button",{className:"asakaa-bulk-toolbar-button asakaa-bulk-toolbar-button-danger",onClick:l,title:"Delete selected cards",children:jsx("span",{className:"text-sm",children:"Delete"})}),jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:a,title:"Clear selection",children:jsx("span",{className:"text-sm",children:"\u2715"})})]})]})})});fn.displayName="BulkOperationsToolbar";function yg(e,t,a){if(t==="none")return [];let r=new Map;return e.forEach(o=>{let s,n,c,p,i;switch(t){case "assignee":let u=o.assignedUserIds||(o.assigneeId?[o.assigneeId]:[]);u.length>0?u.forEach(h=>{let C=a?.find(T=>T.id===h);n=`assignee-${h}`,c=C?.name||`User ${h}`,p=C?.color,i=C?.avatar,r.has(n)||r.set(n,{id:n,title:c,groupValue:h,cardIds:[],color:p,icon:i}),r.get(n).cardIds.push(o.id);}):(n="assignee-unassigned",c="Unassigned",p="#6b7280",i="\u{1F464}",r.has(n)||r.set(n,{id:n,title:c,groupValue:null,cardIds:[],color:p,icon:i}),r.get(n).cardIds.push(o.id));break;case "priority":s=o.priority||"NONE",n=`priority-${s}`;let g={URGENT:{title:"\u{1F534} Urgent",color:"#ef4444"},HIGH:{title:"\u{1F7E0} High",color:"#f97316"},MEDIUM:{title:"\u{1F7E1} Medium",color:"#eab308"},LOW:{title:"\u{1F7E2} Low",color:"#22c55e"},NONE:{title:"\u26AA No Priority",color:"#6b7280"}}[s];c=g.title,p=g.color,r.has(n)||r.set(n,{id:n,title:c,groupValue:s,cardIds:[],color:p}),r.get(n).cardIds.push(o.id);break;case "label":o.labels&&o.labels.length>0?o.labels.forEach(h=>{n=`label-${h}`,c=h,p="#6b7280",r.has(n)||r.set(n,{id:n,title:c,groupValue:h,cardIds:[],color:p}),r.get(n).cardIds.push(o.id);}):(n="label-none",c="No Labels",p="#6b7280",r.has(n)||r.set(n,{id:n,title:c,groupValue:null,cardIds:[],color:p}),r.get(n).cardIds.push(o.id));break}}),Array.from(r.values()).sort((o,s)=>o.title.localeCompare(s.title))}function Os({board:e,swimlaneConfig:t,availableUsers:a,callbacks:r,className:o}){let[s,n]=useState(new Set),c=useMemo(()=>yg(e.cards,t.groupBy,a),[e.cards,t.groupBy,a]),p=useCallback(i=>{n(u=>{let d=new Set(u);return d.has(i)?d.delete(i):d.add(i),d});},[]);return t.groupBy==="none"||c.length===0?jsx(Dr,{board:e,callbacks:r,availableUsers:a,className:o}):jsxs("div",{className:f("asakaa-swimlane-view",o),children:[c.map(i=>{let u=s.has(i.id),d=e.cards.filter(h=>i.cardIds.includes(h.id)),g={...e,cards:d};return jsxs("div",{className:"asakaa-swimlane mb-6 rounded-lg border border-white/10 overflow-hidden",children:[jsxs("div",{className:"asakaa-swimlane-header px-4 py-3 bg-white/5 backdrop-blur-sm flex items-center justify-between cursor-pointer hover:bg-white/10 transition-colors",onClick:()=>t.collapsible&&p(i.id),style:{borderLeft:i.color?`4px solid ${i.color}`:void 0},children:[jsxs("div",{className:"flex items-center gap-3",children:[i.icon&&jsx("span",{className:"text-2xl leading-none",children:i.icon}),jsx("h3",{className:"text-lg font-semibold",style:{color:i.color},children:i.title}),jsxs("span",{className:"text-sm text-white/50 font-medium",children:["(",i.cardIds.length," ",i.cardIds.length===1?"card":"cards",")"]})]}),t.collapsible&&jsx("button",{className:"text-white/50 hover:text-white transition-colors","aria-label":u?"Expand lane":"Collapse lane",children:u?"\u25B6":"\u25BC"})]}),!u&&jsx("div",{className:"asakaa-swimlane-content p-4",children:jsx(Dr,{board:g,callbacks:r,availableUsers:a})})]},i.id)}),c.length===0&&jsxs("div",{className:"text-center py-12 text-white/50",children:[jsx("p",{className:"text-lg",children:"No cards to display"}),jsx("p",{className:"text-sm mt-2",children:"Cards will appear here when they match the grouping criteria"})]})]})}var zs=[{value:"none",label:"No Grouping",icon:"\u{1F4CB}",description:"Standard Kanban board view"},{value:"assignee",label:"By Assignee",icon:"\u{1F465}",description:"Group cards by assigned user"},{value:"priority",label:"By Priority",icon:"\u{1F3AF}",description:"Group cards by priority level"},{value:"label",label:"By Label",icon:"\u{1F3F7}\uFE0F",description:"Group cards by label/tag"}];function Us({value:e,onChange:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null),c=zs.find(i=>i.value===e)||zs[0];useEffect(()=>{function i(u){s.current&&!s.current.contains(u.target)&&n.current&&!n.current.contains(u.target)&&o(false);}if(r)return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let p=i=>{t(i),o(false);};return jsxs("div",{className:f("relative inline-block",a),children:[jsxs("button",{ref:n,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-white/10 hover:bg-white/15 border border-white/20 transition-all text-sm font-medium text-white/90",children:[jsx("span",{className:"text-base leading-none",children:c.icon}),jsx("span",{children:c.label}),jsx("svg",{className:f("w-4 h-4 transition-transform",r&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r&&jsxs("div",{ref:s,className:"absolute top-full left-0 mt-2 min-w-[280px] rounded-lg bg-gradient-to-br from-gray-900/95 to-gray-800/95 backdrop-blur-xl border border-white/20 shadow-2xl z-50 overflow-hidden",children:[jsx("div",{className:"px-3 py-2 border-b border-white/10",children:jsx("span",{className:"text-[10px] font-bold text-white/70 uppercase tracking-wider",children:"Group By"})}),jsx("div",{className:"py-1",children:zs.map(i=>jsxs("button",{onClick:()=>p(i.value),className:f("w-full px-3 py-2 flex items-start gap-3 text-left transition-all hover:bg-white/10",e===i.value&&"bg-white/5"),children:[jsx("span",{className:"text-xl leading-none mt-0.5",children:i.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"font-semibold text-sm text-white",children:i.label}),e===i.value&&jsx("span",{className:"text-blue-400 text-xs",children:"\u2713"})]}),jsx("p",{className:"text-xs text-white/60 mt-0.5",children:i.description})]})]},i.value))})]})]})}var Fo=[{keys:"ArrowUp",action:"navigate_up",description:"Navigate to card above"},{keys:"ArrowDown",action:"navigate_down",description:"Navigate to card below"},{keys:"ArrowLeft",action:"navigate_left",description:"Navigate to previous column"},{keys:"ArrowRight",action:"navigate_right",description:"Navigate to next column"},{keys:"Enter",action:"open_card",description:"Open selected card"},{keys:"Escape",action:"close_modal",description:"Close modal or dialog"},{keys:"Delete",action:"delete_card",description:"Delete selected card",modifiers:{shift:true}},{keys:"n",action:"new_card",description:"Create new card",modifiers:{ctrl:true}},{keys:"k",action:"search",description:"Open search/command palette",modifiers:{ctrl:true}},{keys:"s",action:"save",description:"Save changes",modifiers:{ctrl:true}},{keys:"z",action:"undo",description:"Undo last action",modifiers:{ctrl:true}},{keys:"y",action:"redo",description:"Redo last undone action",modifiers:{ctrl:true}},{keys:"a",action:"select_all",description:"Select all cards",modifiers:{ctrl:true}},{keys:"Escape",action:"deselect_all",description:"Deselect all cards"},{keys:"?",action:"show_shortcuts",description:"Show keyboard shortcuts help",modifiers:{shift:true}}];function kg(e,t){if(!(Array.isArray(t.keys)?t.keys:[t.keys]).some(i=>e.key===i||e.code===i))return false;let o=t.modifiers||{},s=o.ctrl?e.ctrlKey||e.metaKey:!e.ctrlKey&&!e.metaKey,n=o.shift?e.shiftKey:!e.shiftKey,c=o.alt?e.altKey:!e.altKey,p=o.meta?e.metaKey:true;return s&&n&&c&&p}function Pd(e={}){let{shortcuts:t=Fo,enabled:a=true,preventDefault:r=true}=e,o=useRef(t),s=useRef(a);useEffect(()=>{o.current=t,s.current=a;},[t,a]);let n=useCallback(p=>{o.current=[...o.current,p];},[]),c=useCallback(p=>{o.current=o.current.filter(i=>i.action!==p);},[]);return useEffect(()=>{function p(i){if(!s.current)return;let u=i.target;if(!((u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.isContentEditable)&&i.key!=="Escape"&&!i.ctrlKey&&!i.metaKey)){for(let d of o.current)if(kg(i,d)){r&&i.preventDefault();let g=new CustomEvent("keyboard-action",{detail:d.action,bubbles:true,cancelable:true});window.dispatchEvent(g);break}}}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r]),{registerShortcut:n,unregisterShortcut:c,isEnabled:a}}function Cg(e){return {ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192",Enter:"\u21B5",Escape:"Esc",Delete:"Del"," ":"Space"}[e]||e.toUpperCase()}function Tg(e){let t=[],a=typeof navigator<"u"&&navigator.platform.includes("Mac");return e.modifiers?.ctrl&&t.push(a?"\u2318":"Ctrl"),e.modifiers?.shift&&t.push("Shift"),e.modifiers?.alt&&t.push(a?"\u2325":"Alt"),e.modifiers?.meta&&t.push("\u2318"),t.join(" + ")}function Ng(e){let t=Array.isArray(e.keys)?e.keys[0]:e.keys,a=Tg(e),r=t?Cg(t):"";return a?`${a} + ${r}`:r}function Dg(e){let t={Navigation:[],Actions:[],Editing:[],Selection:[]};return e.forEach(a=>{a.action.includes("navigate")?t.Navigation?.push(a):a.action.includes("select")?t.Selection?.push(a):["undo","redo","save"].includes(a.action)?t.Editing?.push(a):t.Actions?.push(a);}),t}function $s({shortcuts:e=Fo,isOpen:t,onClose:a,className:r}){let[o,s]=useState(false);if(useEffect(()=>{s(true);},[]),useEffect(()=>{function c(p){p.key==="Escape"&&t&&a();}if(t)return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t,a]),!o||!t)return null;let n=Dg(e);return jsxs("div",{className:f("fixed inset-0 z-[9999] flex items-center justify-center",r),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:a}),jsxs("div",{className:"relative bg-gradient-to-br from-gray-900/95 to-gray-800/95 backdrop-blur-xl rounded-2xl border border-white/20 shadow-2xl max-w-3xl w-full mx-4 max-h-[80vh] overflow-hidden",children:[jsxs("div",{className:"px-6 py-5 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[jsx("span",{className:"text-3xl",children:"\u2328\uFE0F"}),"Keyboard Shortcuts"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Speed up your workflow with these shortcuts"})]}),jsx("button",{onClick:a,className:"text-white/50 hover:text-white transition-colors text-2xl leading-none p-2 hover:bg-white/10 rounded-lg","aria-label":"Close",children:"\xD7"})]}),jsx("div",{className:"px-6 py-6 overflow-y-auto max-h-[calc(80vh-120px)]",children:jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:Object.entries(n).map(([c,p])=>p.length===0?null:jsxs("div",{children:[jsxs("h3",{className:"text-lg font-semibold text-white/90 mb-4 flex items-center gap-2",children:[jsx("span",{className:"w-1 h-5 bg-blue-500 rounded-full"}),c]}),jsx("div",{className:"space-y-3",children:p.map(i=>jsxs("div",{className:"flex items-center justify-between gap-4 p-3 rounded-lg bg-white/5 hover:bg-white/10 transition-colors",children:[jsx("span",{className:"text-sm text-white/80",children:i.description}),jsx("kbd",{className:"px-3 py-1.5 bg-gradient-to-br from-gray-700 to-gray-800 border border-white/20 rounded-md text-xs font-mono text-white/90 shadow-lg whitespace-nowrap",children:Ng(i)})]},i.action))})]},c))})}),jsx("div",{className:"px-6 py-4 border-t border-white/10 bg-white/5",children:jsxs("p",{className:"text-xs text-white/50 text-center",children:["Press ",jsx("kbd",{className:"px-2 py-0.5 bg-white/10 rounded text-white/70",children:"?"})," to toggle this help panel"]})})]})]})}var Hs=[{id:"bug-report",name:"Bug Report",description:"Report a bug or issue",icon:"\u{1F41B}",category:"Development",template:{title:"[BUG] ",description:`**Steps to reproduce:**
72
72
  1.
73
73
 
74
74
  **Expected behavior:**
@@ -108,8 +108,8 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
108
108
  1.
109
109
 
110
110
  **Action items:**
111
- - [ ] `,priority:"MEDIUM",labels:["meeting"]}}];function Us({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null);useEffect(()=>{function i(u){s.current&&!s.current.contains(u.target)&&n.current&&!n.current.contains(u.target)&&o(false);}if(r)return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let c=i=>{t(i),o(false);},p=e.reduce((i,u)=>{let d=u.category||"Other";return i[d]||(i[d]=[]),i[d].push(u),i},{});return jsxs("div",{className:h("relative inline-block",a),children:[jsxs("button",{ref:n,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg border transition-all text-sm font-medium shadow-lg",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-primary)"},onMouseEnter:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",i.currentTarget.style.borderColor="var(--theme-border-secondary)";},onMouseLeave:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",i.currentTarget.style.borderColor="var(--theme-border-primary)";},title:"Create from template",children:[jsx("span",{className:"text-base leading-none",children:"\u{1F4CB}"}),jsx("span",{children:"Templates"}),jsx("svg",{className:h("w-4 h-4 transition-transform",r&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r&&jsxs("div",{ref:s,className:"absolute top-full left-0 mt-2 min-w-[320px] max-w-[400px] rounded-xl backdrop-blur-xl border shadow-2xl z-50 overflow-hidden max-h-[500px] overflow-y-auto",style:{backgroundColor:"var(--theme-bg-primary)",borderColor:"var(--theme-border-primary)"},children:[jsxs("div",{className:"px-4 py-3 border-b sticky top-0 backdrop-blur-sm",style:{borderColor:"var(--theme-border-primary)",backgroundColor:"var(--theme-bg-secondary)"},children:[jsx("span",{className:"text-sm font-bold uppercase tracking-wider",style:{color:"var(--theme-text-primary)"},children:"Card Templates"}),jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:"Quick start with pre-configured cards"})]}),Object.entries(p).map(([i,u])=>jsxs("div",{className:"py-2",children:[jsx("div",{className:"px-4 py-2",children:jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"var(--theme-text-secondary)"},children:i})}),jsx("div",{children:u.map(d=>jsxs("button",{onClick:()=>c(d),className:"w-full px-4 py-3 flex items-start gap-3 text-left transition-all active:scale-[0.98]",style:{color:"var(--theme-text-primary)"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-2xl leading-none mt-0.5",children:d.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"font-semibold text-sm",style:{color:"var(--theme-text-primary)"},children:d.name}),d.description&&jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:d.description})]})]},d.id))})]},i)),e.length===0&&jsx("div",{className:"px-4 py-8 text-center",style:{color:"var(--theme-text-tertiary)"},children:jsx("p",{className:"text-sm",children:"No templates available"})})]})]})}function Hs({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[n,c]=useState("export"),[p,i]=useState("json"),[u,d]=useState(null),g=useRef(null);if(!t)return null;let f=async()=>{let T=o?.current||void 0,m=await xl(e,p,T);kl(m,p);},C=async T=>{let m=T.target.files?.[0];if(m){try{let b=await Tl(m),y=m.name.endsWith(".json")?"json":"csv",l=Cl(b,y);d(l),l.success&&r&&r(l,b);}catch(b){d({success:false,errors:[`Failed to read file: ${b instanceof Error?b.message:"Unknown error"}`]});}g.current&&(g.current.value="");}};return jsxs("div",{className:h("fixed inset-0 z-[9999] flex items-center justify-center",s),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:a}),jsxs("div",{className:"relative bg-gradient-to-br from-gray-900/95 to-gray-800/95 backdrop-blur-xl rounded-2xl border border-white/20 shadow-2xl max-w-2xl w-full mx-4",children:[jsxs("div",{className:"px-6 py-5 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[jsx("span",{className:"text-3xl",children:"\u{1F4E6}"}),"Export / Import"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Transfer your board data"})]}),jsx("button",{onClick:a,className:"text-white/50 hover:text-white transition-colors text-2xl leading-none p-2 hover:bg-white/10 rounded-lg","aria-label":"Close",children:"\xD7"})]}),jsxs("div",{className:"flex border-b border-white/10",children:[jsx("button",{onClick:()=>c("export"),className:h("flex-1 px-6 py-4 font-semibold transition-colors",n==="export"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Export"}),jsx("button",{onClick:()=>c("import"),className:h("flex-1 px-6 py-4 font-semibold transition-colors",n==="import"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Import"})]}),jsxs("div",{className:"p-6",children:[n==="export"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Select format"}),jsx("div",{className:"grid grid-cols-3 gap-3",children:["json","csv","pdf"].map(T=>jsxs("button",{onClick:()=>i(T),className:h("p-4 rounded-lg border-2 transition-all text-center",p===T?"border-blue-500 bg-blue-500/20 text-white":"border-white/20 hover:border-white/40 text-white/70 hover:text-white"),children:[jsxs("div",{className:"text-2xl mb-2",children:[T==="json"&&"\u{1F4C4}",T==="csv"&&"\u{1F4CA}",T==="pdf"&&"\u{1F4DD}"]}),jsx("div",{className:"font-semibold uppercase text-xs",children:T})]},T))})]}),jsxs("div",{className:"bg-white/5 rounded-lg p-4",children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:"Preview"}),jsxs("div",{className:"text-xs text-white/60",children:[jsxs("div",{children:["Board: ",jsx("span",{className:"text-white/90",children:e.title||"Untitled"})]}),jsxs("div",{children:["Columns: ",jsx("span",{className:"text-white/90",children:e.columns.length})]}),jsxs("div",{children:["Cards: ",jsx("span",{className:"text-white/90",children:e.cards.length})]})]})]}),jsx("button",{onClick:f,className:"w-full py-3 px-4 bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-500 hover:to-blue-600 text-white font-semibold rounded-lg transition-all shadow-lg shadow-blue-500/20",children:"Export Board"})]}),n==="import"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Upload file"}),jsx("input",{ref:g,type:"file",accept:".json,.csv",onChange:C,className:"hidden"}),jsxs("button",{onClick:()=>g.current?.click(),className:"w-full py-12 px-4 border-2 border-dashed border-white/30 hover:border-white/50 rounded-lg transition-colors text-white/70 hover:text-white",children:[jsx("div",{className:"text-5xl mb-3",children:"\u{1F4C1}"}),jsx("div",{className:"font-semibold mb-1",children:"Click to select file"}),jsx("div",{className:"text-xs text-white/50",children:"Supports JSON and CSV files"})]})]}),u&&jsxs("div",{className:h("p-4 rounded-lg",u.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:h("font-semibold mb-2",u.success?"text-green-400":"text-red-400"),children:u.success?"\u2713 Import Successful":"\u2717 Import Failed"}),u.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",u.cardsImported]}),jsxs("div",{children:["Columns imported: ",u.columnsImported]})]}),u.errors&&u.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:u.errors.map((T,m)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",T]},m))})]})]})]})]})]})}var Ag=["URGENT","HIGH","MEDIUM","LOW"],Fg=[{value:"none",label:"None"},{value:"created",label:"Date Created"},{value:"priority",label:"Priority"},{value:"dueDate",label:"Due Date"},{value:"title",label:"Title"},{value:"estimate",label:"Estimate"}],Ig=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function Ws({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:n,onFilterHighPriority:c,availableUsers:p=[],availableLabels:i=[],availableColumns:u=[],showQuickFilters:d=true,compact:g=false,groupBy:f="none",onGroupByChange:C}){let[T,m]=useState(true),b=useCallback(S=>{a({search:S.target.value});},[a]),y=useCallback(S=>{a({dateFilter:S.target.value});},[a]),l=useCallback(S=>{r({by:S.target.value});},[r]),w=useCallback(()=>{r({order:t.order==="asc"?"desc":"asc"});},[t.order,r]),v=e.search||e.dateFilter!=="all"||e.priorities.length>0||e.assignees.length>0||e.labels.length>0||t.by!=="none";return jsxs("div",{className:`filter-bar ${g?"filter-bar--compact":""} ${T?"filter-bar--collapsed":""}`,children:[jsxs("div",{className:"filter-bar__header",onClick:()=>m(!T),style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:T?"0":"12px",padding:"4px 6px",borderRadius:"6px",transition:"all 0.2s ease"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:T?"rotate(-90deg)":"rotate(0deg)",transition:"transform 0.2s",color:"var(--theme-text-secondary)"},children:jsx("polyline",{points:"6 9 12 15 18 9"})}),jsx("span",{className:"filter-bar__label",style:{fontWeight:500,fontSize:"0.875rem",color:"var(--theme-text-primary)"},children:"Filters & Grouping"}),v&&jsxs("span",{style:{color:"var(--theme-accent-primary)",fontSize:"0.75rem",fontWeight:600},children:["(",[e.search&&"search",e.dateFilter!=="all"&&"date",e.priorities.length>0&&"priority",e.assignees.length>0&&"assignee",e.labels.length>0&&"label",t.by!=="none"&&"sort"].filter(Boolean).length," active)"]})]}),!T&&jsxs("div",{className:"filter-bar__content",children:[d&&jsxs("div",{className:"filter-bar__quick",style:{marginBottom:"12px"},children:[jsx("span",{className:"filter-bar__label",children:"Quick:"}),s&&jsx("button",{onClick:s,className:"filter-bar__quick-btn",title:"Show only my tasks",children:"My Tasks"}),n&&jsx("button",{onClick:n,className:"filter-bar__quick-btn",title:"Show overdue tasks",children:"Overdue"}),c&&jsx("button",{onClick:c,className:"filter-bar__quick-btn",title:"Show high priority tasks",children:"High Priority"})]}),jsxs("div",{className:"filter-bar__main",children:[jsx("div",{className:"filter-bar__field",children:jsx("input",{type:"text",placeholder:"Search tasks...",value:e.search,onChange:b,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:y,className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Dates"}),jsx("option",{value:"overdue",children:"Overdue"}),jsx("option",{value:"today",children:"Today"}),jsx("option",{value:"this-week",children:"This Week"})]})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.priorities[0]||"all",onChange:S=>{let x=S.target.value;a({priorities:x==="all"?[]:[x]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),Ag.map(S=>jsx("option",{value:S,children:S},S))]})}),p.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:S=>{let x=S.target.value;a({assignees:x==="all"?[]:[x]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),p.map(S=>jsx("option",{value:S.id,children:S.name},S.id))]})}),i.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:S=>{let x=S.target.value;a({labels:x==="all"?[]:[x]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),i.map(S=>jsx("option",{value:S,children:S},S))]})}),jsxs("div",{className:"filter-bar__field filter-bar__sort",children:[jsx("span",{className:"filter-bar__label",style:{color:"var(--theme-text-secondary)"},children:"Sort:"}),jsx("select",{value:t.by,onChange:l,className:"filter-bar__select filter-bar__select--sm",children:Fg.map(S=>jsx("option",{value:S.value,children:S.label},S.value))}),t.by!=="none"&&jsx("button",{onClick:w,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),C&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:f,onChange:S=>C(S.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Ig.map(S=>jsx("option",{value:S.value,children:S.label},S.value))})}),v&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function Gs({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:n,onExportGanttPNG:c,onExportGanttCSV:p}){let[i,u]=useState(false),d=useRef(null);useEffect(()=>{let f=C=>{d.current&&!d.current.contains(C.target)&&u(false);};return i&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f);}},[i]);let g=f=>{f(),u(false);};return jsxs("div",{className:h("relative",r),ref:d,children:[jsxs("button",{onClick:()=>u(!i),className:"flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-all border",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-secondary)"},onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",f.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",f.currentTarget.style.color="var(--theme-text-secondary)";},"aria-label":"Configuration Menu","aria-expanded":i,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"3"}),jsx("path",{d:"M12 1v6m0 6v6M5.6 5.6l4.2 4.2m4.2 4.2l4.2 4.2M1 12h6m6 0h6M5.6 18.4l4.2-4.2m4.2-4.2l4.2-4.2"})]}),jsx("span",{children:"Config"})]}),i&&jsxs("div",{className:"absolute right-0 mt-2 w-48 rounded-lg border shadow-lg overflow-hidden z-50",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[o==="kanban"?jsxs("button",{onClick:()=>g(e),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})}),"Export"]}):jsxs(Fragment,{children:[jsxs("button",{onClick:()=>g(async()=>await s?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),jsx("polyline",{points:"10 9 9 9 8 9"})]}),"Export PDF"]}),jsxs("button",{onClick:()=>g(async()=>await n?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),"Export Excel"]}),jsxs("button",{onClick:()=>g(async()=>await c?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),jsx("polyline",{points:"21 15 16 10 5 21"})]}),"Export PNG"]}),jsxs("button",{onClick:()=>g(()=>p?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),jsx("line",{x1:"8",y1:"17",x2:"16",y2:"17"})]}),"Export CSV"]})]}),jsxs("button",{onClick:()=>g(t),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"5"}),jsx("path",{d:"M12 1v6m0 6v6m8.5-8.5L17 15M7 9L3.5 5.5M7 15l-3.5 3.5M20.5 5.5L17 9m3.5 11.5L17 17"})]}),"Themes"]}),jsxs("button",{onClick:()=>g(a),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h.01M12 12h.01M16 12h.01M7 16h10"})]}),"Shortcuts"]})]})]})}var _s={name:"dark",displayName:"Dark (Enhanced)",emoji:"\u{1F319}",colors:{bgPrimary:"#222326",bgSecondary:"#2A2B2F",bgTertiary:"#33343A",bgCard:"#2d2d2d",bgHover:"#353535",bgActive:"#404040",bgInput:"#2a2a2a",textPrimary:"#F4F5F8",textSecondary:"#AEB6C0",textTertiary:"#7A7F8A",textDisabled:"#606060",textInverse:"#1a1a1a",borderPrimary:"rgba(255, 255, 255, 0.1)",borderSecondary:"rgba(255, 255, 255, 0.05)",borderDefault:"#404040",borderHover:"#505050",borderSubtle:"#2a2a2a",accentPrimary:"#5E6AD2",accentHover:"#7780DD",interactivePrimary:"#0ea5e9",interactivePrimaryHover:"#0284c7",interactivePrimaryBorder:"rgba(14, 165, 233, 0.3)",interactivePrimaryBackground:"rgba(14, 165, 233, 0.1)",interactivePrimaryBackgroundHover:"rgba(14, 165, 233, 0.2)",success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6",danger:"#ef4444",dangerBorder:"rgba(239, 68, 68, 0.3)",dangerBackground:"rgba(239, 68, 68, 0.1)",dangerBackgroundHover:"rgba(239, 68, 68, 0.2)"},shadows:{sm:"0 1px 2px rgba(0, 0, 0, 0.3)",md:"0 4px 12px rgba(0, 0, 0, 0.4)",lg:"0 12px 32px rgba(0, 0, 0, 0.5)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},Vs={name:"light",displayName:"Light (Standard)",emoji:"\u2600\uFE0F",colors:{bgPrimary:"#FFFFFF",bgSecondary:"#F7F7F8",bgTertiary:"#EEEFF1",bgCard:"#ffffff",bgHover:"#f3f4f6",bgActive:"#e5e7eb",bgInput:"#f9fafb",textPrimary:"#1A1A1A",textSecondary:"#5A5A5A",textTertiary:"#8A8A8A",textDisabled:"#d1d5db",textInverse:"#ffffff",borderPrimary:"rgba(0, 0, 0, 0.1)",borderSecondary:"rgba(0, 0, 0, 0.05)",borderDefault:"#e5e7eb",borderHover:"#d1d5db",borderSubtle:"#f3f4f6",accentPrimary:"#5E6AD2",accentHover:"#4A56B8",interactivePrimary:"#0ea5e9",interactivePrimaryHover:"#0284c7",interactivePrimaryBorder:"rgba(14, 165, 233, 0.3)",interactivePrimaryBackground:"rgba(14, 165, 233, 0.08)",interactivePrimaryBackgroundHover:"rgba(14, 165, 233, 0.15)",success:"#059669",warning:"#D97706",error:"#DC2626",info:"#2563EB",danger:"#dc2626",dangerBorder:"rgba(220, 38, 38, 0.3)",dangerBackground:"rgba(220, 38, 38, 0.08)",dangerBackgroundHover:"rgba(220, 38, 38, 0.15)"},shadows:{sm:"0 1px 3px rgba(0, 0, 0, 0.12)",md:"0 4px 12px rgba(0, 0, 0, 0.15)",lg:"0 12px 32px rgba(0, 0, 0, 0.2)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},js={name:"neutral",emoji:"\u26AA",displayName:"Neutral (Zen)",colors:{bgPrimary:"#FAFAF9",bgSecondary:"#F5F5F4",bgTertiary:"#E7E5E4",bgCard:"#FEFEFE",bgHover:"#F0EFEE",bgActive:"#E7E5E4",bgInput:"#FAFAF9",textPrimary:"#1C1917",textSecondary:"#57534E",textTertiary:"#A8A29E",textDisabled:"#D6D3D1",textInverse:"#FAFAF9",borderPrimary:"#E7E5E4",borderSecondary:"#F0EFEE",borderDefault:"#E7E5E4",borderHover:"#D6D3D1",borderSubtle:"#F5F5F4",accentPrimary:"#292524",accentHover:"#44403C",interactivePrimary:"#292524",interactivePrimaryHover:"#44403C",interactivePrimaryBorder:"rgba(41, 37, 36, 0.3)",interactivePrimaryBackground:"rgba(41, 37, 36, 0.06)",interactivePrimaryBackgroundHover:"rgba(41, 37, 36, 0.12)",success:"#15803D",warning:"#CA8A04",error:"#B91C1C",info:"#1D4ED8",danger:"#B91C1C",dangerBorder:"rgba(185, 28, 28, 0.3)",dangerBackground:"rgba(185, 28, 28, 0.08)",dangerBackgroundHover:"rgba(185, 28, 28, 0.15)"},shadows:{sm:"0 1px 3px rgba(0, 0, 0, 0.1)",md:"0 4px 12px rgba(0, 0, 0, 0.12)",lg:"0 12px 32px rgba(0, 0, 0, 0.15)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},Wr={dark:_s,light:Vs,neutral:js},gn="dark";var fn=createContext(void 0),Gg="asakaa-theme";function Fd({children:e,defaultTheme:t=gn,storageKey:a=Gg}){let[r,o]=useState(()=>{if(typeof window<"u"){let c=localStorage.getItem(a);if(c&&(c==="dark"||c==="light"||c==="neutral"))return c}return t}),s=useCallback(c=>{o(c),typeof window<"u"&&localStorage.setItem(a,c);},[a]);useEffect(()=>{if(typeof window>"u")return;let c=document.documentElement,p=Wr[r];Object.entries(p.colors).forEach(([u,d])=>{d&&c.style.setProperty(`--theme-${_g(u)}`,d);}),Object.entries({bgPrimary:"--asakaa-color-background-primary",bgSecondary:"--asakaa-color-background-secondary",bgTertiary:"--asakaa-color-background-tertiary",bgCard:"--asakaa-color-background-card",bgHover:"--asakaa-color-background-hover",bgActive:"--asakaa-color-background-active",bgInput:"--asakaa-color-background-input",textPrimary:"--asakaa-color-text-primary",textSecondary:"--asakaa-color-text-secondary",textTertiary:"--asakaa-color-text-tertiary",textDisabled:"--asakaa-color-text-disabled",textInverse:"--asakaa-color-text-inverse",borderPrimary:"--asakaa-color-border-primary",borderSecondary:"--asakaa-color-border-secondary",borderDefault:"--asakaa-color-border-default",borderHover:"--asakaa-color-border-hover",borderSubtle:"--asakaa-color-border-subtle",accentPrimary:"--asakaa-color-accent-primary",accentHover:"--asakaa-color-accent-hover",interactivePrimary:"--asakaa-color-interactive-primary",interactivePrimaryHover:"--asakaa-color-interactive-primaryHover",interactivePrimaryBorder:"--asakaa-color-interactive-primaryBorder",interactivePrimaryBackground:"--asakaa-color-interactive-primaryBackground",interactivePrimaryBackgroundHover:"--asakaa-color-interactive-primaryBackgroundHover",success:"--asakaa-color-status-success",warning:"--asakaa-color-status-warning",error:"--asakaa-color-status-error",info:"--asakaa-color-status-info",danger:"--asakaa-color-danger",dangerBorder:"--asakaa-color-danger-border",dangerBackground:"--asakaa-color-danger-background",dangerBackgroundHover:"--asakaa-color-danger-backgroundHover"}).forEach(([u,d])=>{let g=p.colors[u];g&&c.style.setProperty(d,g);}),c.setAttribute("data-theme",r),c.classList.remove("theme-dark","theme-light","theme-neutral"),c.classList.add(`theme-${r}`);},[r]);let n={theme:r,setTheme:s,themes:Wr};return jsx(fn.Provider,{value:n,children:e})}function co(){let e=useContext(fn);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function _g(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Ks({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=co();return e?jsxs("div",{className:h("fixed inset-0 z-[9999] flex items-center justify-center",a),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),jsxs("div",{className:"relative rounded-2xl border shadow-2xl max-w-md w-full mx-4",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[jsxs("div",{className:"px-6 py-5 border-b flex items-center justify-between",style:{borderColor:"var(--theme-border-primary)"},children:[jsx("h2",{className:"text-2xl font-bold",style:{color:"var(--theme-text-primary)"},children:"Select Theme"}),jsx("button",{onClick:t,className:"text-2xl leading-none p-2 hover:bg-white/10 rounded-lg transition-colors",style:{color:"var(--theme-text-secondary)"},"aria-label":"Close",children:"\xD7"})]}),jsx("div",{className:"p-6 space-y-3",children:Object.entries(Wr).map(([s,n])=>jsxs("button",{onClick:()=>{o(s),t();},className:h("w-full p-4 rounded-lg border-2 transition-all flex items-center gap-4",r===s?"border-blue-500 bg-blue-500/20":"border-white/20 hover:border-white/40"),style:{backgroundColor:r===s?"var(--theme-accent-primary)20":"transparent"},children:[jsx("div",{className:"text-3xl",children:n.emoji}),jsxs("div",{className:"text-left flex-1",children:[jsx("div",{className:"font-semibold",style:{color:"var(--theme-text-primary)"},children:n.displayName}),jsxs("div",{className:"text-xs",style:{color:"var(--theme-text-secondary)"},children:[s==="dark"&&"Default dark theme with Linear-inspired colors",s==="light"&&"Clean light theme with high contrast",s==="neutral"&&"Monochrome zen theme"]})]}),r===s&&jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:jsx("path",{d:"M20 6L9 17l-5-5"})})]},s))})]})]}):null}function Id(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return Qe[e]||Qe.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,n)=>a.getPropertyValue(s).trim()||n;return {bgPrimary:r("--theme-bg-primary",Qe[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",Qe[e].bgSecondary),bgGrid:r("--theme-bg-card",Qe[e].bgGrid),bgWeekend:r("--theme-bg-hover",Qe[e].bgWeekend),border:r("--theme-border-primary",Qe[e].border),borderLight:r("--theme-border-subtle",Qe[e].borderLight),textPrimary:r("--theme-text-primary",Qe[e].textPrimary),textSecondary:r("--theme-text-secondary",Qe[e].textSecondary),textTertiary:r("--theme-text-tertiary",Qe[e].textTertiary),accent:r("--theme-accent-primary",Qe[e].accent),accentHover:r("--theme-accent-hover",Qe[e].accentHover),accentLight:r("--theme-accent-primary",Qe[e].accentLight),taskBarPrimary:r("--theme-accent-primary",Qe[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",Qe[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",Qe[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",Qe[e].dependency),dependencyHover:r("--theme-border-secondary",Qe[e].dependencyHover),criticalPath:r("--theme-error",Qe[e].criticalPath),criticalPathLight:r("--theme-error",Qe[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",Qe[e].today):e==="neutral"?r("--theme-text-primary",Qe[e].today):r("--theme-error",Qe[e].today),todayLight:e==="light"?r("--theme-accent-primary",Qe[e].todayLight):e==="neutral"?r("--theme-text-primary",Qe[e].todayLight):r("--theme-error",Qe[e].todayLight),milestone:r("--theme-warning",Qe[e].milestone),milestoneLight:r("--theme-warning",Qe[e].milestoneLight),statusTodo:r("--theme-text-tertiary",Qe[e].statusTodo),statusInProgress:r("--theme-accent-primary",Qe[e].statusInProgress),statusCompleted:r("--theme-success",Qe[e].statusCompleted),hoverBg:r("--theme-bg-hover",Qe[e].hoverBg),focusRing:r("--theme-accent-primary",Qe[e].focusRing)}}var hn={columns:{taskName:"TASK NAME",startDate:"Start Date",endDate:"End Date",duration:"Duration",assignees:"Assignees",status:"Status",progress:"% Complete",priority:"Priority"},toolbar:{today:"Today",day:"Day",week:"Week",month:"Month",export:"Export",exportPdf:"Export to PDF",exportPng:"Export to PNG",exportCsv:"Export to CSV",exportExcel:"Export to Excel",exportMsProject:"Export to MS Project",undo:"Undo",redo:"Redo",createTask:"New Task",density:"Row Density",compact:"Compact",normal:"Normal",spacious:"Spacious"},contextMenu:{editTask:"Edit Task",addSubtask:"Add Subtask",markIncomplete:"Mark Incomplete",setInProgress:"Set In Progress",markComplete:"Mark Complete",splitTask:"Split Task",deleteTask:"Delete Task"},actions:{edit:"Edit",delete:"Delete",duplicate:"Duplicate",addSubtask:"Add Subtask",indent:"Indent",outdent:"Outdent",moveUp:"Move Up",moveDown:"Move Down",splitTask:"Split Task",linkTasks:"Link Tasks",unlinkTasks:"Unlink Tasks"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},labels:{progress:"Progress",duration:"Duration",days:"days",day:"day",assigned:"Assigned",milestone:"Milestone",criticalPath:"Critical Path",subtask:"Subtask",task:"Task",noTasks:"No tasks yet",addTask:"Add task",newTask:"New Task",loading:"Loading...",error:"Error",today:"Today"},ai:{placeholder:'Ask AI to edit tasks... (e.g., "Move Design to next week")',thinking:"Thinking...",suggestions:{moveTask:'Move "Task Name" to next Monday',extendTask:'Extend "Task Name" by 3 days',renameTask:'Rename "Old Name" to "New Name"',setProgress:'Set "Task Name" progress to 50%',linkTasks:'Link "Task A" to "Task B"',createTask:'Create a new task called "New Task"',deleteTask:'Delete "Task Name"',assignTask:'Assign John to "Task Name"'},errors:{taskNotFound:"Task not found",invalidDate:"Invalid date",invalidDuration:"Invalid duration",invalidProgress:"Invalid progress value",unknownCommand:"Unknown command",processingError:"Error processing command"}},export:{projectName:"Gantt Project",ganttTasks:"Gantt Tasks",taskId:"Task ID",taskName:"Task Name",startDate:"Start Date",endDate:"End Date",isMilestone:"Is Milestone",parentId:"Parent ID",yes:"Yes",no:"No",noTasksToExport:"No tasks available to export"},dateFormat:{short:"MM/dd",medium:"MMM d",long:"MMMM d, yyyy"}},Ld={columns:{taskName:"NOMBRE DE TAREA",startDate:"Fecha Inicio",endDate:"Fecha Fin",duration:"Duraci\xF3n",assignees:"Asignados",status:"Estado",progress:"% Completado",priority:"Prioridad"},toolbar:{today:"Hoy",day:"D\xEDa",week:"Semana",month:"Mes",export:"Exportar",exportPdf:"Exportar a PDF",exportPng:"Exportar a PNG",exportCsv:"Exportar a CSV",exportExcel:"Exportar a Excel",exportMsProject:"Exportar a MS Project",undo:"Deshacer",redo:"Rehacer",createTask:"Nueva Tarea",density:"Densidad",compact:"Compacto",normal:"Normal",spacious:"Espacioso"},contextMenu:{editTask:"Editar Tarea",addSubtask:"Agregar Subtarea",markIncomplete:"Marcar Incompleta",setInProgress:"Marcar En Progreso",markComplete:"Marcar Completada",splitTask:"Dividir Tarea",deleteTask:"Eliminar Tarea"},actions:{edit:"Editar",delete:"Eliminar",duplicate:"Duplicar",addSubtask:"Agregar Subtarea",indent:"Aumentar Nivel",outdent:"Disminuir Nivel",moveUp:"Mover Arriba",moveDown:"Mover Abajo",splitTask:"Dividir Tarea",linkTasks:"Vincular Tareas",unlinkTasks:"Desvincular Tareas"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},labels:{progress:"Progreso",duration:"Duraci\xF3n",days:"d\xEDas",day:"d\xEDa",assigned:"Asignado",milestone:"Hito",criticalPath:"Ruta Cr\xEDtica",subtask:"Subtarea",task:"Tarea",noTasks:"Sin tareas a\xFAn",addTask:"Agregar tarea",newTask:"Nueva Tarea",loading:"Cargando...",error:"Error",today:"Hoy"},ai:{placeholder:'P\xEDdele a la IA que edite tareas... (ej: "Mover Dise\xF1o a la pr\xF3xima semana")',thinking:"Pensando...",suggestions:{moveTask:'Mover "Nombre de Tarea" al pr\xF3ximo lunes',extendTask:'Extender "Nombre de Tarea" por 3 d\xEDas',renameTask:'Renombrar "Nombre Anterior" a "Nombre Nuevo"',setProgress:'Establecer progreso de "Nombre de Tarea" al 50%',linkTasks:'Vincular "Tarea A" con "Tarea B"',createTask:'Crear una nueva tarea llamada "Nueva Tarea"',deleteTask:'Eliminar "Nombre de Tarea"',assignTask:'Asignar a Juan a "Nombre de Tarea"'},errors:{taskNotFound:"Tarea no encontrada",invalidDate:"Fecha inv\xE1lida",invalidDuration:"Duraci\xF3n inv\xE1lida",invalidProgress:"Valor de progreso inv\xE1lido",unknownCommand:"Comando desconocido",processingError:"Error procesando el comando"}},export:{projectName:"Proyecto Gantt",ganttTasks:"Tareas Gantt",taskId:"ID de Tarea",taskName:"Nombre de Tarea",startDate:"Fecha Inicio",endDate:"Fecha Fin",isMilestone:"Es Hito",parentId:"ID Padre",yes:"S\xED",no:"No",noTasksToExport:"No hay tareas disponibles para exportar"},dateFormat:{short:"dd/MM",medium:"d MMM",long:"d de MMMM de yyyy"}},Ys={en:hn,es:Ld};function Bd(e){return Ys[e]||Ys.en}function qs(e,t){let a=Bd(e);return t?{columns:{...a.columns,...t.columns},toolbar:{...a.toolbar,...t.toolbar},contextMenu:{...a.contextMenu,...t.contextMenu},actions:{...a.actions,...t.actions},status:{...a.status,...t.status},labels:{...a.labels,...t.labels},ai:{...a.ai,...t.ai,suggestions:{...a.ai.suggestions,...t.ai?.suggestions},errors:{...a.ai.errors,...t.ai?.errors}},export:{...a.export,...t.export},dateFormat:{...a.dateFormat,...t.dateFormat}}:a}var po=createContext(hn);function Mo(){return useContext(po)}function lf({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:n}){let[c,p]=useState(false),[i,u]=useState(null),d=useRef(null),g=Mo();if(useEffect(()=>{let m=b=>{d.current&&!d.current.contains(b.target)&&p(false);};return c&&document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[c]),!(t||a||r||o||s||n))return null;let C=[{id:"png",label:"PNG",description:"Image",icon:jsx(FileImage,{className:"w-4 h-4"}),handler:t},{id:"pdf",label:"PDF",description:"Document",icon:jsx(FileText,{className:"w-4 h-4"}),handler:a},{id:"excel",label:"Excel",description:"Spreadsheet",icon:jsx(FileSpreadsheet,{className:"w-4 h-4"}),handler:r},{id:"csv",label:"CSV",description:"Comma-separated",icon:jsx(FileText,{className:"w-4 h-4"}),handler:o},{id:"json",label:"JSON",description:"Data",icon:jsx(FileJson,{className:"w-4 h-4"}),handler:s},{id:"msproject",label:"MS Project",description:"XML",icon:jsx(FolderKanban,{className:"w-4 h-4"}),handler:n}].filter(m=>m.handler),T=async(m,b)=>{if(b){u(m);try{await b();}catch(y){console.error(`Export ${m} failed:`,y);}finally{u(null),p(false);}}};return jsxs("div",{ref:d,className:"relative",children:[jsxs(motion.button,{onClick:()=>p(!c),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:c?e.accent:e.bgSecondary,border:`1px solid ${c?e.accent:e.borderLight}`,color:c?"#FFFFFF":e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{scale:1.02,backgroundColor:e.accent,color:"#FFFFFF"},whileTap:{scale:.98},children:[jsx(Download,{className:"w-3.5 h-3.5"}),jsx("span",{children:g.toolbar.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:c?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:c&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute right-0 mt-2 w-48 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:C.map((m,b)=>jsxs(motion.button,{onClick:()=>T(m.id,m.handler),disabled:i!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:b<C.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:b*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:i===m.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):m.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:m.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:m.description})]})]},m.id))})})})]})}function df({options:e,value:t,onChange:a,theme:r,layoutId:o="activeSegment"}){return jsx("div",{className:"inline-flex p-1 rounded-lg relative",style:{backgroundColor:r.bgSecondary,border:`1px solid ${r.borderLight}`},children:e.map(s=>{let n=t===s.value;return jsxs(motion.button,{onClick:()=>a(s.value),className:"relative px-3 py-1.5 rounded-md text-xs transition-all flex items-center gap-1.5 min-w-[70px] justify-center",style:{color:n?r.textPrimary:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:n?600:500,zIndex:n?2:1},whileHover:{scale:1.02},whileTap:{scale:.98},children:[n&&jsx(motion.div,{layoutId:o,className:"absolute inset-0 rounded-md",style:{backgroundColor:r.accent,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},transition:{type:"spring",stiffness:400,damping:30}}),s.icon&&jsx("span",{className:"relative z-10",style:{color:n?"#FFFFFF":r.textTertiary},children:s.icon}),jsx("span",{className:"relative z-10",style:{color:n?"#FFFFFF":r.textTertiary},children:s.label})]},s.value)})})}function cf({options:e,value:t,onChange:a,theme:r}){return jsx("div",{className:"inline-flex items-center gap-1",children:e.map(o=>{let s=t===o.value;return jsxs(motion.button,{onClick:()=>a(o.value),className:"relative px-3 py-1.5 text-xs transition-all",style:{color:s?r.accent:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:s?600:500},whileHover:{color:s?r.accent:r.textSecondary},whileTap:{scale:.98},children:[jsx("span",{children:o.label}),s&&jsx(motion.div,{layoutId:"timeScaleUnderline",className:"absolute bottom-0 left-1 right-1 h-0.5 rounded-full",style:{backgroundColor:r.accent},transition:{type:"spring",stiffness:400,damping:30}})]},o.value)})})}function mf({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),n=Mo();useEffect(()=>{let i=u=>{s.current&&!s.current.contains(u.target)&&o(false);};return r&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let c=[{value:"compact",label:n.toolbar.compact||"Compact"},{value:"comfortable",label:n.toolbar.normal||"Normal"},{value:"spacious",label:n.toolbar.spacious||"Spacious"}],p=c.find(i=>i.value===t)?.label||"Normal";return jsxs("div",{ref:s,className:"relative",children:[jsx(motion.button,{onClick:()=>o(!r),className:"flex items-center justify-center p-2 rounded-lg transition-all",style:{backgroundColor:r?e.accentLight:e.bgSecondary,border:`1px solid ${r?e.accent:e.borderLight}`,color:r?e.accent:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.02},whileTap:{scale:.98},title:`${n.toolbar.density||"Density"}: ${p}`,children:jsx(Rows3,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute left-0 mt-2 w-36 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:c.map((i,u)=>{let d=t===i.value;return jsxs(motion.button,{onClick:()=>{a(i.value),o(false);},className:"w-full flex items-center justify-between px-3 py-2 text-left transition-all",style:{backgroundColor:d?e.accentLight:"transparent",borderBottom:u<c.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:u*.03},children:[jsx("span",{className:"text-xs",style:{color:d?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:d?600:500},children:i.label}),d&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},i.value)})})})})]})}function bn({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:n,rowDensity:c,onRowDensityChange:p,showThemeSelector:i=false,showCreateTaskButton:u=false,createTaskLabel:d,onCreateTask:g,onExportPNG:f,onExportPDF:C,onExportExcel:T,onExportCSV:m,onExportJSON:b,onExportMSProject:y}){let l=Mo(),w=f||C||T||m||b||y,v=[{value:"day",label:l.toolbar.day},{value:"week",label:l.toolbar.week},{value:"month",label:l.toolbar.month}],S=[{value:"dark",label:"Dark",icon:jsx(Moon,{className:"w-3.5 h-3.5"})},{value:"light",label:"Light",icon:jsx(Sun,{className:"w-3.5 h-3.5"})},{value:"neutral",label:"Zen",icon:jsx(Palette,{className:"w-3.5 h-3.5"})}];return jsxs("div",{className:"h-12 px-4 flex items-center justify-between border-b",style:{backgroundColor:e.bgGrid,borderColor:e.border},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx(cf,{options:v,value:t,onChange:x=>a(x),theme:e}),jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsxs("div",{className:"flex items-center gap-1",children:[jsx(motion.button,{onClick:()=>o(Math.max(.5,r-.1)),className:"p-1.5 rounded-md transition-all",style:{backgroundColor:"transparent",color:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(ZoomOut,{className:"w-3.5 h-3.5"})}),jsxs("div",{className:"px-2 py-0.5 rounded text-xs tabular-nums min-w-[42px] text-center",style:{color:e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},children:[Math.round(r*100),"%"]}),jsx(motion.button,{onClick:()=>o(Math.min(2,r+.1)),className:"p-1.5 rounded-md transition-all",style:{backgroundColor:"transparent",color:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(ZoomIn,{className:"w-3.5 h-3.5"})})]}),jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsx(mf,{theme:e,value:c,onChange:p})]}),jsxs("div",{className:"flex items-center gap-3",children:[u&&g&&jsxs(Fragment,{children:[jsxs(motion.button,{onClick:g,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#FFFFFF",fontFamily:"Inter, sans-serif",fontWeight:500,boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"},whileHover:{scale:1.02,boxShadow:"0 4px 12px rgba(59, 130, 246, 0.4)"},whileTap:{scale:.98},children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{children:d||l.toolbar.createTask})]}),(w||i)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),w&&jsxs(Fragment,{children:[jsx(lf,{theme:e,onExportPNG:f,onExportPDF:C,onExportExcel:T,onExportCSV:m,onExportJSON:b,onExportMSProject:y}),i&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),i&&jsx(df,{options:S,value:s,onChange:x=>n(x),theme:e})]})]})}function yn({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,n]=useState({x:0,y:0}),c=useRef(null),p=useRef(null);useEffect(()=>{if(!r)return;let u=d=>{c.current&&!c.current.contains(d.target)&&o(false);};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]);let i=e.filter(u=>u.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:p,onClick:()=>{if(!r&&p.current){let u=p.current.getBoundingClientRect();n({x:u.left,y:u.bottom+4});}o(!r);},className:"p-2 rounded-md transition-colors flex items-center gap-1",style:{backgroundColor:a.bgSecondary,border:`1px solid ${a.borderLight}`,color:a.textSecondary},whileHover:{backgroundColor:a.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(Plus,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(ut,{children:jsx(motion.div,{ref:c,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15},className:"column-manager-menu fixed min-w-[180px] rounded-lg shadow-xl z-[9999]",style:{left:`${s.x}px`,top:`${s.y}px`,backgroundColor:a.bgSecondary,border:`1px solid ${a.border}`},children:jsxs("div",{className:"py-1",children:[jsx("div",{className:"px-3 py-2 text-xs uppercase tracking-wider",style:{color:a.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600},children:"Add Column"}),i.map(u=>jsxs("button",{onClick:()=>{t(u.id);},className:"w-full px-3 py-2 text-left flex items-center justify-between transition-colors text-sm",style:{color:a.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif"},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=a.hoverBg;},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{children:u.label}),u.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},u.id))]})})})})]})}function uo({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let n=useRef(null),[c,p]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let u=200,d=r.length*36+8,g=8,f=window.innerWidth,C=window.innerHeight,T=t,m=a;t+u+g>f&&(T=t-u,T<g&&(T=g)),a+d+g>C&&(m=C-d-g,m<g&&(m=g)),p({x:T,y:m});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let u=g=>{n.current&&!n.current.contains(g.target)&&o();},d=g=>{g.key==="Escape"&&o();};return document.addEventListener("mousedown",u),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",d);}},[e,o]),!e)return null;let i=u=>u.startsWith("#")&&(u.length===7||u.length===4)?u:s.bgPrimary?.includes("1")||s.bgPrimary?.includes("2")||s.textPrimary?.toLowerCase().includes("fff")||s.textPrimary?.toLowerCase().includes("white")?"#1E2128":"#FFFFFF";return jsx(AnimatePresence,{children:jsx(motion.div,{ref:n,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed z-[9999] min-w-[200px] rounded-lg",style:{left:`${c.x}px`,top:`${c.y}px`,backgroundColor:i(s.bgSecondary),border:`1px solid ${s.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2)",backdropFilter:"none"},children:jsx("div",{className:"py-1",children:r.map(u=>jsxs("div",{children:[u.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{u.disabled||(u.onClick(),o());},disabled:u.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:u.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:u.disabled?"not-allowed":"pointer",opacity:u.disabled?.5:1},onMouseEnter:d=>{u.disabled||(d.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[u.icon&&jsx("span",{style:{color:s.textSecondary},children:u.icon}),jsx("span",{className:"flex-1",children:u.label}),u.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},u.id))})})})}var Bt={Edit:jsx(Edit3,{className:"w-4 h-4"}),Pencil:jsx(Pencil,{className:"w-4 h-4"}),Delete:jsx(Trash2,{className:"w-4 h-4"}),Add:jsx(Plus,{className:"w-4 h-4"}),AddSubtask:jsx(Plus,{className:"w-4 h-4"}),Remove:jsx(Minus,{className:"w-4 h-4"}),Link:jsx(Link2,{className:"w-4 h-4"}),Progress:jsx(BarChart3,{className:"w-4 h-4"}),Sort:jsx(ArrowUpDown,{className:"w-4 h-4"}),SortAsc:jsx(ArrowUp,{className:"w-4 h-4"}),SortDesc:jsx(ArrowDown,{className:"w-4 h-4"}),Hide:jsx(EyeOff,{className:"w-4 h-4"}),Show:jsx(Eye,{className:"w-4 h-4"}),Settings:jsx(Settings,{className:"w-4 h-4"}),Split:jsx(Scissors,{className:"w-4 h-4"}),MarkIncomplete:jsx(Circle,{className:"w-4 h-4"}),SetInProgress:jsx(PlayCircle,{className:"w-4 h-4"}),MarkComplete:jsx(CheckCircle2,{className:"w-4 h-4"})};function Yd({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:n,onTaskIndent:c,onTaskOutdent:p,onTaskRename:i,onTaskToggleExpand:u,onOpenTaskModal:d,enableKeyboard:g=true}){let f=useRef(false),C=useCallback(l=>{f.current=l;},[]),T=useCallback(l=>{let w=[],v=S=>{for(let x of S)w.push(x),x.subtasks&&x.subtasks.length>0&&x.isExpanded&&v(x.subtasks);};return v(l),w},[]),m=useCallback(()=>{let l=T(e);for(let w of l)if(t.has(w.id))return w;return null},[e,t,T]),b=useCallback((l,w)=>{let v=T(e);if(v.length===0)return;let S=m();if(!S){a(v[0].id,false);return}let x=v.findIndex(A=>A.id===S.id);if(x===-1)return;let k=l==="up"?x-1:x+1;if(k<0||k>=v.length)return;let O=v[k];a(O.id,w);},[e,m,T,a]),y=useCallback(l=>{if(!g)return;let w=l.target;if(w.tagName==="INPUT"||w.tagName==="TEXTAREA"||w.isContentEditable||f.current){l.key==="Escape"&&(w.blur(),f.current=false);return}let x=navigator.platform.toUpperCase().indexOf("MAC")>=0?l.metaKey:l.ctrlKey,k=Array.from(t),O=m();if(l.key==="ArrowUp"){l.preventDefault(),b("up",l.shiftKey);return}if(l.key==="ArrowDown"){l.preventDefault(),b("down",l.shiftKey);return}if(O&&(l.key==="ArrowRight"||l.key==="ArrowLeft")){O.subtasks&&O.subtasks.length>0&&(l.preventDefault(),(l.key==="ArrowRight"&&!O.isExpanded||l.key==="ArrowLeft"&&O.isExpanded)&&u(O.id));return}if(l.altKey&&(l.key==="ArrowUp"||l.key==="ArrowDown")){k.length>0&&(l.preventDefault(),n(k,l.key==="ArrowUp"?"up":"down"));return}if(l.key==="Tab"&&!l.shiftKey){k.length>0&&(l.preventDefault(),c(k));return}if(l.key==="Tab"&&l.shiftKey){k.length>0&&(l.preventDefault(),p(k));return}if(l.key==="Enter"&&!l.shiftKey&&!x){O&&(l.preventDefault(),r(O.id,"below"));return}if(l.key==="Enter"&&l.shiftKey&&!x){O&&(l.preventDefault(),r(O.id,"above"));return}if(l.key==="Enter"&&x){O&&(l.preventDefault(),d(O.id));return}if(l.key==="F2"){O&&(l.preventDefault(),i(O.id));return}if(l.key==="Delete"||l.key==="Backspace"&&x){k.length>0&&(l.preventDefault(),o(k));return}if(l.key==="d"&&x&&!l.shiftKey){k.length>0&&(l.preventDefault(),s(k));return}},[g,t,m,b,r,o,s,n,c,p,i,u,d]);return useEffect(()=>{if(g)return window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y);}},[g,y]),{setIsEditing:C}}function Xd(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(d=>{t(new Set([d])),r(d);},[]),s=useCallback(d=>{t(g=>{let f=new Set(g);return f.has(d)?f.delete(d):f.add(d),f}),r(d);},[]),n=useCallback((d,g)=>{if(!a){o(d);return}let f=g.indexOf(a),C=g.indexOf(d);if(f===-1||C===-1){o(d);return}let T=Math.min(f,C),m=Math.max(f,C),b=g.slice(T,m+1);t(new Set(b)),r(d);},[a,o]),c=useCallback((d,g,f,C)=>{C?n(d,g):f?s(d):o(d);},[o,s,n]),p=useCallback((d,g)=>{g?t(f=>{let C=new Set(f);return C.add(d),C}):o(d);},[o]),i=useCallback(()=>{t(new Set),r(null);},[]),u=useCallback(d=>e.has(d),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:n,handleTaskClick:c,handleKeyboardSelection:p,clearSelection:i,isTaskSelected:u}}function go(e){let t=[],a=(r,o,s=0)=>{for(let n=0;n<r.length;n++){let c={...r[n],parentId:o,level:s,position:n};t.push(c),c.subtasks&&c.subtasks.length>0&&c.isExpanded&&a(c.subtasks,c.id,s+1);}};return a(e),t}function Jd(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=Jd(a.subtasks,t);if(r)return r}}return null}function Zs(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=Zs(a.subtasks,t);if(r)return r}return null}function Qs(e,t){if(t.length===0)return e;let a=go(e),r=t[0],o=a.findIndex(d=>d.id===r);if(o<=0)return e;let s=a[o-1],n=(d,g)=>{let f=[];return {tasks:d.filter(T=>{if(g.has(T.id))return f.push(T),false;if(T.subtasks){let m=n(T.subtasks,g);T.subtasks=m.tasks,f.push(...m.removed);}return true}),removed:f}},c=(d,g,f)=>d.map(C=>C.id===g?{...C,subtasks:[...C.subtasks||[],...f],isExpanded:true}:C.subtasks?{...C,subtasks:c(C.subtasks,g,f)}:C),p=new Set(t),{tasks:i,removed:u}=n(e,p);return c(i,s.id,u)}function ei(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=Zs(a,r);if(!o)continue;let s=Zs(a,o.id),n=(i,u,d)=>{for(let g=0;g<i.length;g++){let f=i[g];if(f.id===u&&f.subtasks){let C=f.subtasks.findIndex(T=>T.id===d);if(C!==-1){let[T]=f.subtasks.splice(C,1);return T}}if(f.subtasks){let C=n(f.subtasks,u,d);if(C)return C}}return null},c=(i,u,d)=>{let g=i.findIndex(f=>f.id===u);if(g!==-1)return i.splice(g+1,0,d),i;for(let f of i)f.subtasks&&c(f.subtasks,u,d);return i},p=n(a,o.id,r);p&&(s&&s.subtasks?c(s.subtasks,o.id,p):c(a,o.id,p));}return a}function ti(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(n,c,p)=>{let i=n.findIndex(d=>d.id===c);if(i===-1){for(let d of n)if(d.subtasks&&s(d.subtasks,c,p))return true;return false}let u=p==="up"?i-1:i+1;return u<0||u>=n.length?false:([n[i],n[u]]=[n[u],n[i]],true)};return s(r,o,a),r}function ai(e,t){let a=new Set(t),r=o=>o.filter(s=>!a.has(s.id)).map(s=>s.subtasks?{...s,subtasks:r(s.subtasks)}:s);return r(e)}function ri(e,t){let a=[...e];for(let r of t){let o=n=>{let c=n.findIndex(u=>u.id===r);if(c===-1){for(let u of n)if(u.subtasks&&o(u.subtasks))return true;return false}let p=n[c],i={...p,id:`${p.id}-copy-${Date.now()}`,name:`${p.name} (Copy)`,subtasks:p.subtasks?s(p.subtasks):void 0};return n.splice(c+1,0,i),true},s=n=>n.map(c=>({...c,id:`${c.id}-copy-${Date.now()}`,subtasks:c.subtasks?s(c.subtasks):void 0}));o(a);}return a}function Zd(e,t,a){let r=[...e],o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let n={id:`task-${Date.now()}`,name:"New Task",progress:0,status:"todo",startDate:o,endDate:s,color:"#6366F1"},c=p=>{let i=p.findIndex(d=>d.id===t);if(i===-1){for(let d of p)if(d.subtasks&&c(d.subtasks))return true;return false}let u=a==="above"?i:i+1;return p.splice(u,0,n),true};return c(r),{tasks:r,newTask:n}}function oi(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:oi(r.subtasks,t,a)}:r)}function ni(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:ni(a.subtasks,t)}:a)}function si(e,t){let a=u=>{for(let d of u){if(d.id===t)return d;if(d.subtasks){let g=a(d.subtasks);if(g)return g}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let n=r?.startDate||o,c=r?.endDate||s,p={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(n),endDate:new Date(c),color:r?.color||"#3B82F6"},i=u=>u.map(d=>{if(d.id===t){let g=d.subtasks||[];return {...d,subtasks:[...g,p],isExpanded:true}}return d.subtasks?{...d,subtasks:i(d.subtasks)}:d});return {tasks:i(e),newTask:p}}function Qd(e,t,a,r){if(t===a)return e;let o=Jd(e,t);if(!o)return e;if(a){let c=(p,i)=>{if(!p.subtasks)return false;for(let u of p.subtasks)if(u.id===i||c(u,i))return true;return false};if(c(o,a))return e}let s=c=>c.filter(p=>p.id!==t).map(p=>p.subtasks&&p.subtasks.length>0?{...p,subtasks:s(p.subtasks)}:p),n=s(e);if(a===null){let c=r!==void 0?r:n.length;n.splice(c,0,{...o,parentId:void 0});}else {let c=p=>p.map(i=>{if(i.id===a){let u=i.subtasks||[],d=r!==void 0?r:u.length,g=[...u];return g.splice(d,0,{...o,parentId:a}),{...i,subtasks:g,isExpanded:true}}return i.subtasks&&i.subtasks.length>0?{...i,subtasks:c(i.subtasks)}:i});n=c(n);}return n}function kn({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:n,onTaskContextMenu:c,onTaskToggle:p,scrollTop:i,columns:u,onToggleColumn:d,onColumnResize:g,onTaskUpdate:f,onTaskIndent:C,onTaskOutdent:T,onTaskMove:m,onMultiTaskDelete:b,onTaskDuplicate:y,onTaskCreate:l,onTaskRename:w,onCreateSubtask:v,onOpenTaskModal:S,onDeleteRequest:x,onTaskReparent:k}){let O=useContext(po),[A,N]=useState(null),[H,L]=useState(null),[q,ae]=useState(""),ke=useRef(null),[Fe,Ve]=useState(null),[Je,$]=useState(0),[B,W]=useState(0),[D,Y]=useState({isOpen:false,x:0,y:0,type:"header"}),[J,R]=useState(null),[ce,we]=useState(null),[Ie,me]=useState(null),He=useRef(0),Le=5,Ye=useRef(false),[pt,bt]=useState(null),[it,z]=useState(false),[oe,ne]=useState(null),[xe,Ne]=useState(false),at=useRef(null);useEffect(()=>{function V(re){at.current&&!at.current.contains(re.target)&&Ne(false);}if(xe)return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[xe]),useEffect(()=>{H&&ke.current&&(ke.current.focus(),ke.current.select());},[H]),useEffect(()=>{if(!Fe)return;let V=Me=>{let Xe=Me.clientX-Je,$e=B+Xe;g?.(Fe,$e);},re=()=>{Ve(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",V),document.addEventListener("mouseup",re),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",V),document.removeEventListener("mouseup",re),document.body.style.cursor="",document.body.style.userSelect="";}},[Fe,Je,B,g]);let{selectedTaskIds:ft,handleTaskClick:Be,isTaskSelected:he}=Xd(),{setIsEditing:Pe}=Yd({tasks:e,selectedTaskIds:ft,onTaskSelect:(V,re)=>{let Xe=go(e).map($e=>$e.id);Be(V,Xe,re||false,false);},onTaskCreate:l||(()=>{}),onTaskDelete:b||(()=>{}),onTaskDuplicate:y||(()=>{}),onTaskMove:m||(()=>{}),onTaskIndent:C||(()=>{}),onTaskOutdent:T||(()=>{}),onTaskRename:V=>{let re=go(e).find(Me=>Me.id===V);re&&Oe(re);},onTaskToggleExpand:p||(()=>{}),onOpenTaskModal:V=>{let re=go(e).find(Me=>Me.id===V);re&&S&&S(re);},enableKeyboard:true}),Mt=(V,re=0)=>{let Me=[];for(let Xe of V)Me.push({task:Xe,level:re}),Xe.subtasks&&Xe.subtasks.length>0&&Xe.isExpanded&&Me.push(...Mt(Xe.subtasks,re+1));return Me},ht=Mt(e),oa=48,ma=Math.max(ht.length*a,600-oa),Ue=V=>!V.startDate||!V.endDate?"-":`${Math.ceil((V.endDate.getTime()-V.startDate.getTime())/(1e3*60*60*24))}d`,Oe=V=>{L(V.id),ae(V.name),Pe(true);},na=V=>{q.trim()&&q!==e.find(re=>re.id===V)?.name&&w?.(V,q.trim()),L(null),ae(""),Pe(false);},ge=()=>{L(null),ae(""),Pe(false);},E=(V,re)=>{re.stopPropagation(),v?.(V.id);},Z=(V,re)=>{re.preventDefault(),He.current=re.clientY,R(V),Ye.current=false,z(false),bt({x:re.clientX,y:re.clientY});},be=V=>{if(!J||(Math.abs(V.clientY-He.current)>Le&&!Ye.current&&(Ye.current=true,z(true)),bt({x:V.clientX,y:V.clientY}),!Ye.current))return;let Me=document.querySelectorAll("[data-task-row]"),Xe=null,$e=null;Me.forEach(G=>{let ee=G.getBoundingClientRect(),Ae=G.getAttribute("data-task-row");if(Ae&&Ae!==J&&V.clientY>=ee.top&&V.clientY<=ee.bottom){Xe=Ae;let M=V.clientY-ee.top,te=ee.height;M<te*.25?$e="above":M>te*.75?$e="below":$e="child";}}),we(Xe),me($e);},Te=()=>{if(Ye.current&&J&&ce&&Ie){if(Ie==="child")k?.(J,ce);else if(Ie==="above"||Ie==="below"){let V=(Xe,$e,G=null)=>{for(let ee of Xe){if(ee.id===$e)return G;if(ee.subtasks){let Ae=V(ee.subtasks,$e,ee.id);if(Ae!==void 0)return Ae}}},re=V(e,ce,null),Me=(Xe,$e)=>{let G=Xe.findIndex(ee=>ee.id===$e);return Ie==="below"?G+1:G};if(re===null){let Xe=Me(e,ce);k?.(J,null,Xe);}else {let Xe=ht.find($e=>$e.task.id===re)?.task;if(Xe?.subtasks){let $e=Me(Xe.subtasks,ce);k?.(J,re,$e);}}}}R(null),we(null),me(null),bt(null),Ye.current=false,z(false);};useEffect(()=>{if(J)return document.addEventListener("mousemove",be),document.addEventListener("mouseup",Te),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",be),document.removeEventListener("mouseup",Te),document.body.style.cursor="",document.body.style.userSelect="";}},[J,ce,Ie]);let qe=(V,re,Me)=>{switch(V.id){case "name":let Xe=H===re.id,$e=A===re.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${Me*20}px`},children:[k&&jsx("div",{className:"cursor-grab active:cursor-grabbing p-0.5 rounded hover:bg-white/10 transition-all flex-shrink-0",style:{color:t.textTertiary,opacity:$e?1:.3},onMouseDown:j=>Z(re.id,j),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),re.subtasks&&re.subtasks.length>0?jsx("button",{onClick:j=>{j.stopPropagation(),p?.(re.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:re.isExpanded?jsx(ChevronDown,{className:"w-4 h-4"}):jsx(ChevronRight,{className:"w-4 h-4"})}):jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:jsx("div",{className:"w-3 h-3 rounded-full border",style:{backgroundColor:re.color||"#3B82F6",opacity:re.parentId?.6:1,borderColor:re.isMilestone?t.accent:"transparent",borderWidth:re.isMilestone?"2px":"0px"},title:re.isMilestone?"Milestone":re.parentId?"Subtask":"Task"})}),Xe?jsx("input",{ref:ke,type:"text",value:q,onChange:j=>ae(j.target.value),onKeyDown:j=>{j.key==="Enter"?na(re.id):j.key==="Escape"&&ge();},onBlur:()=>na(re.id),className:"flex-1 px-2 py-1 rounded border outline-none",style:{backgroundColor:t.bgPrimary,borderColor:t.accent,color:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:"13px",fontWeight:500},onClick:j=>j.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:re.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:re.parentId?"13px":"14px",fontWeight:re.isMilestone?600:re.parentId?400:600,letterSpacing:re.parentId?"0":"-0.01em"},title:re.name,children:re.name}),$e&&!Xe&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:j=>j.stopPropagation(),children:[jsx("button",{onClick:j=>E(re,j),className:"p-1 rounded hover:bg-opacity-20 transition-colors",style:{color:t.textTertiary,backgroundColor:"transparent"},title:"Create subtask",children:jsx(Plus,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:j=>{j.stopPropagation(),Oe(re);},className:"p-1 rounded hover:bg-opacity-20 transition-colors",style:{color:t.textTertiary,backgroundColor:"transparent"},title:"Rename (F2)",children:jsx(Edit3,{className:"w-3.5 h-3.5"})})]})]})]});case "startDate":case "endDate":let ee=V.id==="startDate"?"startDate":"endDate",Ae=re[ee],M=oe?.taskId===re.id&&oe?.field===ee,te=j=>j?(typeof j=="string"?new Date(j):j).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):"-";return jsxs("div",{className:"flex items-center justify-center w-full relative",onClick:j=>j.stopPropagation(),children:[jsxs("button",{type:"button",className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors hover:bg-white/5",style:{color:t.textSecondary},onClick:j=>{if(M)ne(null);else {let _e=j.currentTarget.getBoundingClientRect();ne({taskId:re.id,field:ee,month:Ae?typeof Ae=="string"?new Date(Ae):Ae:new Date,position:{top:_e.bottom+4,left:_e.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:te(Ae)})]}),M&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>ne(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"fixed z-[9999] rounded-xl shadow-2xl overflow-visible flex",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,top:oe?.position.top,left:oe?.position.left},onClick:j=>j.stopPropagation(),children:[jsxs("div",{className:"w-36 py-2",style:{borderRight:`1px solid ${t.border}`},children:[(()=>{let j=new Date,_e=new Date(j);_e.setDate(j.getDate()+1);let De=new Date(j);De.setDate(j.getDate()+7);let ta=new Date(j);return ta.setDate(j.getDate()+14),[{label:"Hoy",date:j},{label:"Ma\xF1ana",date:_e},{label:"Pr\xF3xima semana",date:De},{label:"2 semanas",date:ta}].map((Yt,kt)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:ze=>ze.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:ze=>ze.currentTarget.style.backgroundColor="transparent",onClick:()=>{f?.(re.id,{[ee]:Yt.date}),ne(null);},children:Yt.label},kt))})(),jsx("div",{style:{borderTop:`1px solid ${t.border}`,margin:"0.25rem 0"}}),jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:j=>j.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:j=>j.currentTarget.style.backgroundColor="transparent",onClick:()=>{f?.(re.id,{[ee]:void 0}),ne(null);},children:"Borrar"})]}),jsxs("div",{className:"p-2",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("button",{type:"button",onClick:()=>ne(j=>j?{...j,month:new Date(j.month.getFullYear(),j.month.getMonth()-1)}:null),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-3.5 h-3.5",style:{color:t.textSecondary}})}),jsx("span",{className:"text-xs font-medium",style:{color:t.textPrimary},children:oe?.month.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>ne(j=>j?{...j,month:new Date(j.month.getFullYear(),j.month.getMonth()+1)}:null),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:t.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-0.5 mb-1",children:["D","L","M","M","J","V","S"].map((j,_e)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:j},_e))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let j=oe?.month||new Date,_e=j.getFullYear(),De=j.getMonth(),ta=new Date(_e,De,1).getDay(),sa=new Date(_e,De+1,0).getDate(),Yt=new Date,kt=[];for(let Ze=ta-1;Ze>=0;Ze--)kt.push({day:new Date(_e,De,-Ze).getDate(),date:new Date(_e,De-1,new Date(_e,De,-Ze).getDate()),isCurrentMonth:false});for(let Ze=1;Ze<=sa;Ze++)kt.push({day:Ze,date:new Date(_e,De,Ze),isCurrentMonth:true});let ze=42-kt.length;for(let Ze=1;Ze<=ze;Ze++)kt.push({day:Ze,date:new Date(_e,De+1,Ze),isCurrentMonth:false});return kt.map((Ze,jt)=>{let tr=Ze.date.toDateString()===Yt.toDateString(),vo=(Ae?typeof Ae=="string"?new Date(Ae):Ae:null)?.toDateString()===Ze.date.toDateString();return jsx("button",{type:"button",className:"w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",style:{color:Ze.isCurrentMonth?vo?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:vo?"#3B82F6":"transparent",boxShadow:tr&&!vo?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{f?.(re.id,{[ee]:Ze.date}),ne(null);},children:Ze.day},jt)})})()})]})]})]}),document.body)]});case "duration":return jsx("div",{className:"flex items-center justify-center w-full",children:jsx("span",{className:"text-xs tabular-nums",style:{color:t.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:600},children:Ue(re)})});case "assignees":let Re=r.filter(j=>re.assignees?.some(_e=>_e.name===j.name||_e.initials===j.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:j=>j.stopPropagation(),children:jsx(Rr,{assignedUsers:Re,availableUsers:r,onChange:j=>{let _e=j.map(De=>({id:De.id,name:De.name,initials:De.initials,color:De.color}));f?.(re.id,{assignees:_e.length>0?_e:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:j=>j.stopPropagation(),children:jsx(Gl,{status:re.status||"todo",onChange:j=>{f?.(re.id,{status:j,progress:j==="completed"?100:re.progress});}})});case "progress":return jsxs("div",{className:"flex items-center justify-center gap-2 w-full",children:[jsx("div",{className:"flex-1 h-1.5 rounded-full overflow-hidden max-w-[60px]",style:{backgroundColor:t.bgSecondary},children:jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${re.progress}%`,backgroundColor:re.progress===100?t.statusCompleted:t.accent}})}),jsxs("span",{className:"text-xs tabular-nums min-w-[35px] text-right",style:{color:t.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600},children:[re.progress,"%"]})]});case "priority":let lt={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},Et={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},se=lt[re.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:j=>j.stopPropagation(),children:jsx(Lr,{priority:se,onChange:j=>{j&&f?.(re.id,{priority:Et[j]||"medium"});}})});default:return null}},We=V=>[{id:"hide",label:"Hide Column",icon:Bt.Hide,onClick:()=>d(V),disabled:V==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:Bt.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:Bt.SortDesc,onClick:()=>{}}],Ee=V=>V.subtasks&&V.subtasks.length>0?[{id:"addSubtask",label:O?.contextMenu?.addSubtask||"Add Subtask",icon:Bt.Add,onClick:()=>{v?.(V.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:O?.contextMenu?.deleteTask||"Delete Task",icon:Bt.Delete,onClick:()=>{x?x(V.id,V.name):b?.([V.id]);}}]:[{id:"edit",label:O?.contextMenu?.editTask||"Edit Task",icon:Bt.Pencil,onClick:()=>{n?.(V);}},{id:"addSubtask",label:O?.contextMenu?.addSubtask||"Add Subtask",icon:Bt.Add,onClick:()=>{v?.(V.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:O?.contextMenu?.markIncomplete||"Mark Incomplete",icon:Bt.MarkIncomplete,onClick:()=>{f?.(V.id,{status:"todo",progress:0});},disabled:V.status==="todo"},{id:"setInProgress",label:O?.contextMenu?.setInProgress||"Set In Progress",icon:Bt.SetInProgress,onClick:()=>{f?.(V.id,{status:"in-progress"});},disabled:V.status==="in-progress"},{id:"markComplete",label:O?.contextMenu?.markComplete||"Mark Complete",icon:Bt.MarkComplete,onClick:()=>{f?.(V.id,{status:"completed",progress:100});},disabled:V.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:O?.contextMenu?.splitTask||"Split Task",icon:Bt.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:O?.contextMenu?.deleteTask||"Delete Task",icon:Bt.Delete,onClick:()=>{x?x(V.id,V.name):b?.([V.id]);}}],rt=u.filter(V=>V.visible),st=rt.reduce((V,re)=>V+re.width,0);return jsxs("div",{className:"h-full",style:{backgroundColor:t.bgPrimary,minWidth:st},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${oa}px`,paddingLeft:"3px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:[jsx("div",{className:"flex items-center flex-1 min-w-0",children:rt.map((V,re)=>{let Me=re===rt.length-1,Xe=V.id==="name";return jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${Xe?"":"justify-center"}`,style:{width:`${V.width}px`,minWidth:`${V.minWidth??(Xe?200:60)}px`,maxWidth:`${V.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:Me?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:$e=>{$e.preventDefault(),Y({isOpen:true,x:$e.clientX,y:$e.clientY,type:"header",columnId:V.id});},onMouseEnter:$e=>{$e.currentTarget.style.backgroundColor=t.hoverBg;},onMouseLeave:$e=>{$e.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:t.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,paddingRight:"0"},title:V.label,children:V.label}),V.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:Fe===V.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:$e=>{$e.preventDefault(),$e.stopPropagation(),Ve(V.id),$($e.clientX),W(V.width);},title:"Drag to resize column",children:jsx("div",{className:"absolute top-2 bottom-2 opacity-0 group-hover:opacity-100 transition-opacity",style:{left:"3px",width:"2px",backgroundColor:t.accent,borderRadius:"1px"}})})]},V.id)})}),jsxs("div",{className:"flex items-center gap-1 px-2",style:{position:"sticky",right:0,height:"100%",backgroundColor:t.bgGrid,zIndex:5},children:[jsx(yn,{columns:u,onToggleColumn:d,theme:t}),jsx("button",{onClick:()=>Ne(!xe),className:"p-1.5 rounded hover:bg-opacity-10 transition-colors",style:{color:t.textTertiary},title:"Keyboard shortcuts",children:jsx(Keyboard,{className:"w-4 h-4"})}),xe&&jsxs("div",{ref:at,className:"absolute top-full right-0 mt-2 p-4 rounded-lg shadow-2xl z-50 min-w-[400px]",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,color:t.textPrimary},onClick:V=>V.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b",style:{borderColor:t.border},children:[jsx("h3",{className:"font-semibold text-sm",style:{color:t.textPrimary},children:"Keyboard Shortcuts"}),jsx("button",{onClick:()=>Ne(false),className:"text-xs px-2 py-1 rounded hover:bg-opacity-10",style:{color:t.textTertiary},children:"Close"})]}),jsxs("div",{className:"space-y-3 text-xs",children:[jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Navigation"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move focus up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Select range"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Toggle selection"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Click"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Hierarchy"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Indent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Outdent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Expand/Collapse"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2192 / \u2190"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Editing"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task below"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task above"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Open task modal"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Rename task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"F2"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Actions"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move task up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Alt + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Delete task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Delete"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Duplicate task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + D"})]})]})]})]})]})]})]}),jsx("div",{className:"gantt-taskgrid-content",style:{minHeight:ma},children:ht.map(({task:V,level:re},Me)=>{let Xe=he(V.id),$e=ce===V.id,G=$e&&Ie==="above",ee=$e&&Ie==="below",Ae=$e&&Ie==="child",M={};return Ae&&(M.backgroundColor=`${t.accent}15`,M.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":V.id,className:`flex items-center cursor-pointer group ${J===V.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:Xe?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:Xe?t.accentLight:Ae?`${t.accent}15`:Me%2===0?t.bgPrimary:t.bgGrid,...M},onMouseEnter:()=>N(V.id),onMouseLeave:()=>N(null),onClick:te=>{let lt=go(e).map(j=>j.id),se=navigator.platform.toUpperCase().indexOf("MAC")>=0?te.metaKey:te.ctrlKey;Be(V.id,lt,se,te.shiftKey),s?.(V);},onDoubleClick:te=>{te.stopPropagation(),n?.(V);},onContextMenu:te=>{te.preventDefault(),Y({isOpen:true,x:te.clientX,y:te.clientY,type:"task",task:V}),c?.(V,te);},whileHover:{backgroundColor:Xe?t.accentLight:t.hoverBg},children:[G&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),ee&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),rt.map((te,Re)=>{let lt=Re===rt.length-1,Et=te.id==="name";return jsx("div",{className:`px-4 flex items-center ${Et?"justify-start":"justify-center"}`,style:{width:`${te.width}px`,minWidth:`${te.minWidth??(Et?200:60)}px`,maxWidth:`${te.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:lt?"none":`1px solid ${A===V.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:qe(te,V,Et?re:0)},`${V.id}-${te.id}`)})]},V.id)})}),jsx(uo,{isOpen:D.isOpen,x:D.x,y:D.y,items:D.type==="header"&&D.columnId?We(D.columnId):D.type==="task"&&D.task?Ee(D.task):[],onClose:()=>Y({...D,isOpen:false}),theme:t}),it&&pt&&J&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:pt.x+12,top:pt.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let V=ht.find(re=>re.task.id===J)?.task;return V?jsx("div",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{backgroundColor:"rgba(255, 255, 255, 0.08)",backdropFilter:"blur(4px)"},children:jsx("span",{className:"text-xs font-medium",style:{color:t.textSecondary,opacity:.9},children:V.name})}):null})()}),document.body)]})}function oc(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[n,c]=useState(e),[p,i]=useState(t),[u,d]=useState(null),[g,f]=useState(null),[C,T]=useState(null),[m,b]=useState(null),[y,l]=useState(0),[w,v]=useState(0),[S,x]=useState(null),[k,O]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:n,setGhostX:c,ghostWidth:p,setGhostWidth:i,connectionLine:u,setConnectionLine:d,hoveredTaskId:g,setHoveredTaskId:f,activeZone:C,setActiveZone:T,draggedSegmentIndex:m,setDraggedSegmentIndex:b,draggedSegmentStartX:y,setDraggedSegmentStartX:l,segmentDragOffsetX:w,setSegmentDragOffsetX:v,hoveredSegmentIndex:S,setHoveredSegmentIndex:x,isHovered:k,setIsHovered:O,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(q,ae)=>{r("none"),d(null),f(null),c(q),i(ae),v(0),b(null),l(0);}}}function wn({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:n,templates:c,onClick:p,onDoubleClick:i,onContextMenu:u,onDateChange:d,onDependencyCreate:g,allTaskPositions:f=[],onDragMove:C,onHoverChange:T}){let m=oc(t,r),b=useRef(null),{dragMode:y,setDragMode:l,dragOffset:w,setDragOffset:v,ghostX:S,setGhostX:x,ghostWidth:k,setGhostWidth:O,connectionLine:A,setConnectionLine:N,hoveredTaskId:H,setHoveredTaskId:L,activeZone:q,setActiveZone:ae,draggedSegmentIndex:ke,setDraggedSegmentIndex:Fe,draggedSegmentStartX:Ve,setDraggedSegmentStartX:Je,segmentDragOffsetX:$,setSegmentDragOffsetX:B,hoveredSegmentIndex:W,setHoveredSegmentIndex:D,isHovered:Y,setIsHovered:J,isDragging:R,isResizing:ce,isConnecting:we,resetDragState:Ie}=m,me=32,He=8,Le=e.endDate&&e.endDate<new Date&&e.progress<100,Ye=e.isCriticalPath,pt=o.name==="neutral"||o.today==="#1C1917",bt=e.status==="completed"||e.progress===100,it={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},oe=e.isCriticalPath||Le?"#DC2626":e.color?e.color:e.priority&&it[e.priority]?it[e.priority]:o.taskBarPrimary,xe=(ge=>ge>=80?20:ge>=60?15:ge>=50?12:10)(r),Ne=r<50,at=r<40;useEffect(()=>{if(T)if(Y&&!R&&!e.segments){let ge=a<100;T({task:e,x:t,y:a,width:r,height:me,showBelow:ge});}else T(null);},[Y,R,e,t,a,r,me,T]);let ft=ge=>ge.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Be=()=>{let ge=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${ge} day${ge!==1?"s":""}`},he=ge=>Math.round(ge/s)*s,Pe=ge=>{let E=Math.round(ge/s),Z=new Date(n);return Z.setDate(Z.getDate()+E),Z},Mt=(ge,E)=>{for(let Z of f){if(Z.id===e.id)continue;let be=5;if(ge>=Z.x-be&&ge<=Z.x+Z.width+be&&E>=Z.y-be&&E<=Z.y+Z.height+be)return Z.id}return null},ht=useCallback((ge,E,Z)=>{ge.preventDefault(),ge.stopPropagation();let be=b.current?.ownerSVGElement;if(!be)return;let Te=be.createSVGPoint();Te.x=ge.clientX,Te.y=ge.clientY;let qe=Te.matrixTransform(be.getScreenCTM()?.inverse()),We=Z!==void 0?Z:t,Ee=E;if(!Ee){let rt=qe.x-We;ge.shiftKey?(Ee="connect",N({x:t+r,y:a+me/2})):ge.ctrlKey||ge.metaKey?Ee="move":ge.altKey?Ee=rt<r/2?"resize-start":"resize-end":at?rt<r/2?Ee="move":Ee="resize-end":Ne?rt<=xe/2?Ee="resize-start":rt>=r-xe/2?Ee="resize-end":Ee="move":rt<=xe?Ee="resize-start":rt>=r-xe?Ee="resize-end":Ee="move";}l(Ee),J(false),ae(null),Ee==="move"?v(qe.x-We):Ee==="connect"?N({x:t+r,y:a+me/2}):v(0),x(We),O(r);},[t,r,a,me]),oa=useCallback(ge=>{if(y==="none")return;let E=b.current?.ownerSVGElement;if(!E)return;let Z=E.createSVGPoint();Z.x=ge.clientX,Z.y=ge.clientY;let be=Z.matrixTransform(E.getScreenCTM()?.inverse());if(y==="connect"){N({x:be.x,y:be.y});let Te=Mt(be.x,be.y);L(Te);}else if(y==="move"){let Te=be.x-w,qe=he(Te);x(qe),O(r);let We=Math.round((qe-t)/s);if(C?.(e.id,We,true),e.segments&&e.segments.length>0&&ke!==null){let Ee=qe-Ve;B(Ee);}}else if(y==="resize-start"){let Te=be.x,qe=he(Te),We=t+r-qe;We>=s&&(x(qe),O(We));}else if(y==="resize-end"){let Te=be.x,We=he(Te)-t;We>=s&&O(We);}},[y,t,r,s,w,e,he,ke,Ve,Mt,L,N,x,O,B,C]),ma=useCallback(()=>{if(y!=="none"){if(y==="connect")H&&g&&g(e,H),N(null),L(null);else {let ge=e.endDate.getTime()-e.startDate.getTime(),E,Z,be=true;if(y==="move"){if(E=Pe(S),Z=new Date(E.getTime()+ge),e.segments&&e.segments.length>0&&ke!==null){let Te=Math.round($/s),qe=e.segments.map((st,V)=>{if(V===ke){let re=new Date(st.startDate),Me=new Date(st.endDate);return re.setDate(re.getDate()+Te),Me.setDate(Me.getDate()+Te),{startDate:re,endDate:Me}}return st}),We=qe.flatMap(st=>[st.startDate,st.endDate]),Ee=new Date(Math.min(...We.map(st=>st.getTime()))),rt=new Date(Math.max(...We.map(st=>st.getTime())));d?.({...e,segments:qe},Ee,rt),Ie(t,r);return}}else y==="resize-start"?(E=Pe(S),Z=e.endDate,E>Z&&(console.warn("Invalid date range: start date must be before or equal to end date"),be=false)):y==="resize-end"?(E=e.startDate,Z=Pe(S+k),Z<E&&(console.warn("Invalid date range: end date must be after or equal to start date"),be=false)):be=false;be&&E&&Z&&(Z.getTime()<E.getTime()?console.warn("Invalid date range: end date cannot be before start date"):d?.(e,E,Z));}C?.(e.id,0,false),Ie(t,r);}},[y,S,k,e,d,H,g,t,r,s,Pe,$,ke,Ie,C]);useEffect(()=>{if(y==="none")return;let ge=Z=>{oa(Z);},E=()=>{ma();};return window.addEventListener("mousemove",ge),window.addEventListener("mouseup",E),()=>{window.removeEventListener("mousemove",ge),window.removeEventListener("mouseup",E);}},[y,oa,ma]);let Ue=R&&!we?S:t,Oe=R&&!we?k:r,na=c.taskClass(e);return jsxs("g",{ref:b,onMouseEnter:()=>!R&&J(true),onMouseLeave:()=>{R||(J(false),ae(null));},onClick:()=>!R&&p?.(e),onDoubleClick:ge=>{R||(ge.stopPropagation(),i?.(e));},onContextMenu:ge=>{ge.preventDefault(),u?.(e,ge);},children:[Y&&!R&&!Ne&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:xe,height:me,fill:q==="resize-start"?o.accent:"transparent",opacity:q==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>ae("resize-start"),onMouseDown:ge=>ht(ge,"resize-start")}),jsx("rect",{x:t+xe,y:a,width:r-xe*2,height:me,fill:q==="move"?o.accent:"transparent",opacity:q==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>ae("move"),onMouseDown:ge=>ht(ge,"move")}),jsx("rect",{x:t+r-xe,y:a,width:xe,height:me,fill:q==="resize-end"?o.accent:"transparent",opacity:q==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>ae("resize-end"),onMouseDown:ge=>ht(ge,"resize-end")})]}),Y&&!R&&at&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:me,fill:q==="move"?o.accent:"transparent",opacity:q==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>ae("move"),onMouseDown:ge=>ht(ge,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:me,fill:q==="resize-end"?o.accent:"transparent",opacity:q==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>ae("resize-end"),onMouseDown:ge=>ht(ge,"resize-end")}),Y&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+me-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),R&&!we&&!e.segments&&jsx(motion.rect,{x:S,y:a,width:k,height:me,rx:He,fill:o.accent,opacity:.5,stroke:o.accent,strokeWidth:2,strokeDasharray:"4 4",initial:{opacity:0},animate:{opacity:.6},transition:{duration:.15},style:{pointerEvents:"none"}}),!e.segments&&jsx(motion.rect,{x:Ue,y:a,width:Oe,height:me,rx:He,fill:oe,"data-task-class":na,initial:{opacity:0,scale:.95},animate:{opacity:R&&!we?.15:e.parentId?.6:Y?.9:.8,scale:Y&&!R?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:ge=>ht(ge),style:{cursor:R?we?"crosshair":ce?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:Ue,y:a,width:Oe*(e.progress/100),height:me,rx:He,fill:oe,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((ge,E)=>{let Z=(ge.startDate.getTime()-n.getTime())/864e5*s,Te=(ge.endDate.getTime()-n.getTime())/(1e3*60*60*24)*s-Z+s,qe=R&&y==="move"&&ke===E,We=W===E,Ee=qe?Z+$:Z;return jsxs("g",{onMouseEnter:()=>!R&&D(E),onMouseLeave:()=>!R&&D(null),children:[jsx(motion.rect,{x:Ee,y:a,width:Te,height:me,rx:He,fill:oe,initial:{opacity:0,scale:.95},animate:{opacity:qe||e.parentId?.6:We?.9:.8,scale:We&&!R?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:rt=>{rt.stopPropagation(),Fe(E),Je(Z),ht(rt,void 0,Z);},style:{cursor:R?we?"crosshair":ce?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:Ee,y:a,width:Te*(e.progress/100),height:me,rx:He,fill:oe,opacity:1,style:{pointerEvents:"none"}})]},`segment-${E}`)}),pt&&(Le||Ye)&&!e.segments&&jsxs(Fragment,{children:[Ye&&!Le&&jsx("rect",{x:Ue,y:a,width:Oe,height:me,rx:He,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),Le&&jsx("rect",{x:Ue,y:a,width:Oe,height:me,rx:He,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),Oe>60&&!e.segments&&(()=>{let ge=c.taskLabel(e),E=typeof ge=="string"?ge:e.name,Z=E.length>Math.floor(Oe/8)?`${E.substring(0,Math.floor(Oe/8))}...`:E;return jsx("text",{x:Ue+12,y:a+me/2,dominantBaseline:"middle",fill:bt?"rgba(255, 255, 255, 0.6)":"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none",textDecoration:bt?"line-through":"none"},children:Z})})(),Oe>100&&e.progress>0&&e.progress<100&&!R&&!e.segments&&jsxs("text",{x:Ue+Oe-12,y:a+me/2,dominantBaseline:"middle",textAnchor:"end",fill:"rgba(255, 255, 255, 0.9)",fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:[e.progress,"%"]}),e.status&&Oe>80&&!R&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:Ue+Oe-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:Ue+Oe-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(Y||ce)&&!we&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:Ne?Ue-15:Ue-10,y:a-5,width:Ne?25:20,height:me+10,fill:"transparent",onMouseDown:ge=>ht(ge,"resize-start"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ne?Ue-8:Ue-3,y:a+6,width:Ne?8:6,height:Ne?me-12:me-16,rx:3,fill:y==="resize-start"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:y==="resize-start"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]}),jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:Ue+Oe-10,y:a-5,width:Ne?25:20,height:me+10,fill:"transparent",onMouseDown:ge=>ht(ge,"resize-end"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ne?Ue+Oe:Ue+Oe-3,y:a+6,width:Ne?8:6,height:Ne?me-12:me-16,rx:3,fill:y==="resize-end"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:y==="resize-end"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]})]}),jsx(AnimatePresence,{children:Y&&!R&&!e.segments&&jsxs(motion.g,{style:{pointerEvents:"all"},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[jsx(motion.circle,{cx:t+r+8,cy:a+me/2,r:6,fill:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},exit:{scale:0},transition:{duration:.2,type:"spring",stiffness:400,damping:25},onMouseDown:ge=>{ge.stopPropagation(),ht(ge,"connect");},style:{cursor:"crosshair"}}),jsx("text",{x:t+r+20,y:a+me/2,dominantBaseline:"middle",fill:o.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:"Link"})]})}),we&&A&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+me/2,x2:A.x,y2:A.y,stroke:H?o.statusCompleted:o.accent,strokeWidth:H?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:H?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:A.x,cy:A.y,r:H?8:6,fill:H?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),H&&jsx(motion.text,{x:A.x+15,y:A.y,dominantBaseline:"middle",fill:o.statusCompleted,fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",initial:{opacity:0,x:A.x+10},animate:{opacity:1,x:A.x+15},transition:{duration:.2},children:"Connect"})]}),(Y||R)&&!we&&!e.segments&&jsx(motion.rect,{x:Ue-2,y:a-2,width:Oe+4,height:me+4,rx:He+2,fill:"none",stroke:R?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:R?.6:.4,initial:{opacity:0},animate:{opacity:R?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),ce&&jsxs(Fragment,{children:[jsx("line",{x1:S,y1:0,x2:S,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:S+k,y1:0,x2:S+k,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:Y&&!R&&!e.segments&&!T&&(()=>{let Z=a<100,be=Z?a+me+13:a-82-13,Te=Z?`M ${Ue+Oe/2-6} ${a+me+3} L ${Ue+Oe/2} ${a+me+13} L ${Ue+Oe/2+6} ${a+me+3}`:`M ${Ue+Oe/2-6} ${a-13} L ${Ue+Oe/2} ${a-3} L ${Ue+Oe/2+6} ${a-13}`,qe=be+22,We=be+40,Ee=be+55,rt=be+70,st=Z?be+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:Z?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:Z?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:Te,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:Ue+Oe/2-120,y:be,width:240,height:82,rx:8,fill:o.bgSecondary,stroke:o.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("text",{x:Ue+Oe/2,y:qe,textAnchor:"middle",fill:o.textPrimary,fontSize:"13",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>28?`${e.name.substring(0,28)}...`:e.name}),jsx("text",{x:Ue+Oe/2-110,y:We,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:Ue+Oe/2-70,y:We,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:ft(e.startDate)}),jsx("text",{x:Ue+Oe/2-110,y:Ee,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:Ue+Oe/2-70,y:Ee,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:ft(e.endDate)}),jsx("text",{x:Ue+Oe/2+10,y:We,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:Ue+Oe/2+65,y:We,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Be()}),jsx("text",{x:Ue+Oe/2+10,y:Ee,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:Ue+Oe/2+65,y:Ee,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.progress,"%"]}),e.assignees&&e.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:Ue+Oe/2-110,y:rt,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:Ue+Oe/2-50,y:rt,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(V=>V.name).join(", ").substring(0,30),e.assignees.map(V=>V.name).join(", ").length>30?"...":""]})]}),!Z&&jsx("text",{x:Ue+Oe/2,y:st,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:at?"Left: move \u2022 Right: resize":Ne?"Drag to move \u2022 Hold ALT + drag edge to resize":"Drag edges to resize \u2022 Drag center to move \u2022 Click \u26AB to link"})]})})()})]})}function ic({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:n,showBelow:c}=e,p=82,i=13,u=c?o+n+i:o-p-i,d=c?`M ${r+s/2-6} ${o+n+3} L ${r+s/2} ${o+n+13} L ${r+s/2+6} ${o+n+3}`:`M ${r+s/2-6} ${o-13} L ${r+s/2} ${o-3} L ${r+s/2+6} ${o-13}`,g=u+22,f=u+40,C=u+55,T=u+70,m=w=>w.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),b=()=>{if(!a.startDate||!a.endDate)return "N/A";let w=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${w} day${w!==1?"s":""}`};return jsx(AnimatePresence,{children:jsxs(motion.g,{initial:{opacity:0,y:c?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:c?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:u,width:240,height:p,rx:8,fill:t.bgSecondary,stroke:t.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("text",{x:r+s/2,y:g,textAnchor:"middle",fill:t.textPrimary,fontSize:"13",fontWeight:"600",fontFamily:"Inter, sans-serif",children:a.name.length>28?`${a.name.substring(0,28)}...`:a.name}),jsx("text",{x:r+s/2-110,y:f,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y:f,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?m(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y:C,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y:C,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?m(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y:f,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y:f,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:b()}),jsx("text",{x:r+s/2+10,y:C,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y:C,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.progress,"%"]}),a.assignees&&a.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:r+s/2-110,y:T,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:r+s/2-50,y:T,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.assignees.map(w=>w.name).join(", ").substring(0,30),a.assignees.map(w=>w.name).join(", ").length>30?"...":""]})]})]})})}function Nn({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,onHoverChange:n}){let[c,p]=useState(false),i=a-e,u=r-t,d=e+i/2,g=`M ${e} ${t} C ${d} ${t}, ${d} ${r}, ${a} ${r}`,f=6,C=Math.atan2(u,i),T=a-f*Math.cos(C-Math.PI/6),m=r-f*Math.sin(C-Math.PI/6),b=a-f*Math.cos(C+Math.PI/6),y=r-f*Math.sin(C+Math.PI/6),l=o.dependency;useEffect(()=>{n&&s&&n(c?{x1:e,y1:t,x2:a,y2:r,onDelete:s}:null);},[c,e,t,a,r,s,n]);let w=!s&&!n;return jsxs("g",{onMouseEnter:()=>!w&&p(true),onMouseLeave:()=>!w&&p(false),style:{pointerEvents:w?"none":"auto"},children:[!w&&jsx("path",{d:g,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx(motion.path,{d:g,fill:"none",stroke:l,strokeWidth:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:c&&n?0:c?1:.8,strokeWidth:c?2.5:2},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2},strokeWidth:{duration:.2}}}),jsx(motion.path,{d:`M ${a} ${r} L ${T} ${m} M ${a} ${r} L ${b} ${y}`,fill:"none",stroke:l,strokeWidth:2,strokeLinecap:"round",initial:{opacity:0,scale:.8},animate:{opacity:c&&n?0:c?1:.8,scale:c?1.1:1,strokeWidth:c?2.5:2},transition:{duration:.2}}),jsx(motion.circle,{cx:a,cy:r,r:3,fill:l,initial:{scale:0},animate:{scale:c&&n?0:c?1.3:1,opacity:c&&n?0:c?1:.8},transition:{scale:{delay:.3,duration:.15},opacity:{duration:.2}}}),c&&s&&!n&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:v=>{v.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:d,cy:(t+r)/2,r:10,fill:o.bgSecondary,stroke:o.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:d-4,y1:(t+r)/2-4,x2:d+4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:d+4,y1:(t+r)/2-4,x2:d-4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})}function Sn({task:e,x:t,y:a,theme:r,onClick:o}){let[s,n]=useState(false),c=16,p=i=>i.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{onMouseEnter:()=>n(true),onMouseLeave:()=>n(false),onClick:()=>o?.(e),style:{cursor:"pointer"},children:[e.isCriticalPath&&jsx(motion.circle,{cx:t,cy:a+16,r:c+4,fill:r.criticalPathLight,initial:{scale:0},animate:{scale:s?1.2:1},transition:{duration:.3}}),jsx(motion.rect,{x:t-c/2,y:a+16-c/2,width:c,height:c,fill:e.isCriticalPath?r.criticalPath:r.milestone,stroke:r.bgGrid,strokeWidth:2,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:0,rotate:0},animate:{scale:s?1.15:1,rotate:45},transition:{duration:.3,type:"spring",stiffness:300,damping:20}}),s&&jsx(motion.rect,{x:t-(c+4)/2,y:a+16-(c+4)/2,width:c+4,height:c+4,fill:"none",stroke:e.isCriticalPath?r.criticalPath:r.milestone,strokeWidth:2,opacity:.5,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:.8,opacity:0},animate:{scale:1,opacity:.5},transition:{duration:.2}}),jsx(AnimatePresence,{children:s&&jsxs(motion.g,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.2},children:[jsx("rect",{x:t-80,y:a-50,width:160,height:44,rx:8,fill:r.bgSecondary,stroke:r.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("path",{d:`M ${t-6} ${a-6} L ${t} ${a+4} L ${t+6} ${a-6}`,fill:r.bgSecondary,stroke:r.border,strokeWidth:1}),jsx("rect",{x:t-70,y:a-38,width:8,height:8,fill:e.isCriticalPath?r.criticalPath:r.milestone,transform:`rotate(45 ${t-66} ${a-34})`}),jsx("text",{x:t-55,y:a-32,fill:r.textPrimary,fontSize:"12",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>18?`${e.name.substring(0,18)}...`:e.name}),jsx("text",{x:t-55,y:a-18,fill:r.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",children:p(e.startDate)}),e.isCriticalPath&&jsxs("g",{children:[jsx("rect",{x:t+10,y:a-40,width:60,height:16,rx:4,fill:r.criticalPathLight}),jsx("text",{x:t+40,y:a-30,textAnchor:"middle",fill:r.criticalPath,fontSize:"9",fontWeight:"700",fontFamily:"Inter, sans-serif",letterSpacing:"0.5",children:"CRITICAL"})]})]})})]})}var pe={calculateEndDate:(e,t)=>{let a=new Date(e);return a.setDate(a.getDate()+t),a},calculateDuration:(e,t)=>{let a=t.getTime()-e.getTime();return Math.ceil(a/(1e3*60*60*24))},calculateWorkingDays:(e,t)=>{let a=0,r=new Date(e);for(;r<=t;){let o=r.getDay();o!==0&&o!==6&&a++,r.setDate(r.getDate()+1);}return a},addWorkingDays:(e,t)=>{let a=new Date(e),r=0;for(;r<t;){a.setDate(a.getDate()+1);let o=a.getDay();o!==0&&o!==6&&r++;}return a},isWeekend:e=>{let t=e.getDay();return t===0||t===6},validateDependencies:(e,t,a)=>{let r=new Map,o=i=>{i.forEach(u=>{u.dependencies&&r.set(u.id,u.dependencies),u.subtasks&&o(u.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let n=new Set,c=new Set,p=i=>{if(!n.has(i)){n.add(i),c.add(i);let u=r.get(i)||[];for(let d of u){if(!n.has(d)&&p(d))return true;if(c.has(d))return true}}return c.delete(i),false};return p(a)},flattenTasks:e=>{let t=[],a=r=>{r.forEach(o=>{t.push(o),o.subtasks&&o.subtasks.length>0&&a(o.subtasks);});};return a(e),t},findTaskById:(e,t)=>{for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=pe.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=pe.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=pe.findTaskById(e,o);if(s)a.unshift(s),o=s.parentId;else break}return a},exportToJSON:e=>JSON.stringify(e,null,2),importFromJSON:e=>{try{let t=JSON.parse(e);if(!Array.isArray(t))throw new Error("Invalid JSON: expected an array of tasks");return t.forEach((a,r)=>{if(!a.id||!a.name)throw new Error(`Invalid task at index ${r}: missing required fields (id, name)`)}),t}catch(t){throw new Error(`Failed to import tasks: ${t instanceof Error?t.message:"Unknown error"}`)}},exportToCSV:e=>{let t=pe.flattenTasks(e),r=[["ID","Name","Start Date","End Date","Progress","Status","Dependencies"].join(",")];return t.forEach(o=>{let s=[o.id,`"${o.name.replace(/"/g,'""')}"`,o.startDate?o.startDate.toISOString().split("T")[0]:"",o.endDate?o.endDate.toISOString().split("T")[0]:"",o.progress.toString(),o.status||"",o.dependencies?.join(";")||""];r.push(s.join(","));}),r.join(`
112
- `)},formatDate:e=>{let t=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return `${t}-${a}-${r}`},parseDate:e=>new Date(e),getTaskDateRange:e=>!e.startDate||!e.endDate?null:{start:e.startDate,end:e.endDate},getEarliestStartDate:e=>{let a=pe.flattenTasks(e).filter(r=>r.startDate);return a.length===0?null:new Date(Math.min(...a.map(r=>r.startDate.getTime())))},getLatestEndDate:e=>{let a=pe.flattenTasks(e).filter(r=>r.endDate);return a.length===0?null:new Date(Math.max(...a.map(r=>r.endDate.getTime())))},tasksOverlap:(e,t)=>!e.startDate||!e.endDate||!t.startDate||!t.endDate?false:e.startDate<=t.endDate&&t.startDate<=e.endDate,getDependentTasks:(e,t)=>pe.flattenTasks(e).filter(r=>r.dependencies&&r.dependencies.includes(t)),getDependencyTasks:(e,t)=>{let a=pe.findTaskById(e,t);return !a||!a.dependencies?[]:pe.flattenTasks(e).filter(o=>a.dependencies.includes(o.id))},filterByStatus:(e,t)=>pe.flattenTasks(e).filter(a=>a.status===t),filterByDateRange:(e,t,a)=>pe.flattenTasks(e).filter(r=>!r.startDate||!r.endDate?false:r.startDate<=a&&r.endDate>=t),sortByStartDate:(e,t=true)=>[...e].sort((a,r)=>{if(!a.startDate||!r.startDate)return 0;let o=a.startDate.getTime()-r.startDate.getTime();return t?o:-o}),sortByEndDate:(e,t=true)=>[...e].sort((a,r)=>{if(!a.endDate||!r.endDate)return 0;let o=a.endDate.getTime()-r.endDate.getTime();return t?o:-o}),sortByProgress:(e,t=true)=>[...e].sort((a,r)=>{let o=a.progress-r.progress;return t?o:-o}),calculateTotalProgress:e=>{let t=pe.flattenTasks(e);if(t.length===0)return 0;let a=t.reduce((r,o)=>r+o.progress,0);return Math.round(a/t.length)},getTaskByPath:(e,t)=>{let a=e,r;for(let o=0;o<t.length;o++){let s=t[o];if(!a||s===void 0||s>=a.length||(r=a[s],!r))return;o<t.length-1&&(a=r.subtasks||[]);}return r},cloneTask:(e,t)=>({...e,id:t||`${e.id}-copy`,subtasks:e.subtasks?.map(a=>pe.cloneTask(a))}),exportToPDF:async(e,t="gantt-chart.pdf")=>{try{if(!e||e.length===0){alert("No tasks available to export to PDF");return}let{jsPDF:a}=await import('jspdf'),{default:r}=await import('jspdf-autotable'),o=new a,s=pe.flattenTasks(e);if(s.length===0){alert("No tasks found to export");return}o.setFontSize(16),o.text("Gantt Chart - Task List",14,20);let n=[["Task Name","Start Date","End Date","Duration","Progress","Status"]],c=s.map(p=>{let i=p.startDate&&p.endDate?pe.calculateDuration(p.startDate,p.endDate):0;return [p.name,p.startDate?pe.formatDate(p.startDate):"N/A",p.endDate?pe.formatDate(p.endDate):"N/A",i>0?`${i} days`:"N/A",`${p.progress}%`,p.status||"N/A"]});r(o,{head:n,body:c,startY:30,styles:{fontSize:9,cellPadding:3},headStyles:{fillColor:[66,139,202],textColor:255,fontStyle:"bold"},alternateRowStyles:{fillColor:[245,245,245]},columnStyles:{0:{cellWidth:60},1:{cellWidth:30},2:{cellWidth:30},3:{cellWidth:25},4:{cellWidth:20},5:{cellWidth:25}}}),o.save(t);}catch(a){throw a}},exportToExcel:async(e,t="gantt-chart.xlsx")=>{let a=await import('xlsx'),o=pe.flattenTasks(e).map(p=>{let i=p.startDate&&p.endDate?pe.calculateDuration(p.startDate,p.endDate):0;return {"Task ID":p.id,"Task Name":p.name,"Start Date":p.startDate?pe.formatDate(p.startDate):"","End Date":p.endDate?pe.formatDate(p.endDate):"","Duration (days)":i>0?i:"","Progress (%)":p.progress,Status:p.status||"",Assignees:p.assignees?.map(u=>u.name).join(", ")||"",Dependencies:p.dependencies?.join(", ")||"","Is Milestone":p.isMilestone?"Yes":"No","Parent ID":p.parentId||"",Level:p.level||0}}),s=a.utils.json_to_sheet(o),n=[{wch:15},{wch:40},{wch:12},{wch:12},{wch:15},{wch:12},{wch:15},{wch:30},{wch:20},{wch:12},{wch:15},{wch:8}];s["!cols"]=n;let c=a.utils.book_new();a.utils.book_append_sheet(c,s,"Gantt Tasks"),a.writeFile(c,t);},exportToMSProject:(e,t="Gantt Project",a="project.xml")=>{let r=pe.flattenTasks(e),o=new Map;r.forEach((g,f)=>{o.set(g.id,f+1);});let s=g=>g.toISOString().replace("Z",""),n=pe.getEarliestStartDate(e)||new Date,c=pe.getLatestEndDate(e)||new Date,p=r.map((g,f)=>{let C=o.get(g.id),T=g.startDate&&g.endDate?pe.calculateDuration(g.startDate,g.endDate):0,m=(g.dependencies||[]).filter(b=>o.has(b)).map(b=>`
111
+ - [ ] `,priority:"MEDIUM",labels:["meeting"]}}];function Ws({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null);useEffect(()=>{function i(u){s.current&&!s.current.contains(u.target)&&n.current&&!n.current.contains(u.target)&&o(false);}if(r)return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let c=i=>{t(i),o(false);},p=e.reduce((i,u)=>{let d=u.category||"Other";return i[d]||(i[d]=[]),i[d].push(u),i},{});return jsxs("div",{className:f("relative inline-block",a),children:[jsxs("button",{ref:n,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg border transition-all text-sm font-medium shadow-lg",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-primary)"},onMouseEnter:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",i.currentTarget.style.borderColor="var(--theme-border-secondary)";},onMouseLeave:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",i.currentTarget.style.borderColor="var(--theme-border-primary)";},title:"Create from template",children:[jsx("span",{className:"text-base leading-none",children:"\u{1F4CB}"}),jsx("span",{children:"Templates"}),jsx("svg",{className:f("w-4 h-4 transition-transform",r&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r&&jsxs("div",{ref:s,className:"absolute top-full left-0 mt-2 min-w-[320px] max-w-[400px] rounded-xl backdrop-blur-xl border shadow-2xl z-50 overflow-hidden max-h-[500px] overflow-y-auto",style:{backgroundColor:"var(--theme-bg-primary)",borderColor:"var(--theme-border-primary)"},children:[jsxs("div",{className:"px-4 py-3 border-b sticky top-0 backdrop-blur-sm",style:{borderColor:"var(--theme-border-primary)",backgroundColor:"var(--theme-bg-secondary)"},children:[jsx("span",{className:"text-sm font-bold uppercase tracking-wider",style:{color:"var(--theme-text-primary)"},children:"Card Templates"}),jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:"Quick start with pre-configured cards"})]}),Object.entries(p).map(([i,u])=>jsxs("div",{className:"py-2",children:[jsx("div",{className:"px-4 py-2",children:jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"var(--theme-text-secondary)"},children:i})}),jsx("div",{children:u.map(d=>jsxs("button",{onClick:()=>c(d),className:"w-full px-4 py-3 flex items-start gap-3 text-left transition-all active:scale-[0.98]",style:{color:"var(--theme-text-primary)"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-2xl leading-none mt-0.5",children:d.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"font-semibold text-sm",style:{color:"var(--theme-text-primary)"},children:d.name}),d.description&&jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:d.description})]})]},d.id))})]},i)),e.length===0&&jsx("div",{className:"px-4 py-8 text-center",style:{color:"var(--theme-text-tertiary)"},children:jsx("p",{className:"text-sm",children:"No templates available"})})]})]})}function _s({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[n,c]=useState("export"),[p,i]=useState("json"),[u,d]=useState(null),g=useRef(null);if(!t)return null;let h=async()=>{let T=o?.current||void 0,m=await xl(e,p,T);kl(m,p);},C=async T=>{let m=T.target.files?.[0];if(m){try{let b=await Tl(m),y=m.name.endsWith(".json")?"json":"csv",l=Cl(b,y);d(l),l.success&&r&&r(l,b);}catch(b){d({success:false,errors:[`Failed to read file: ${b instanceof Error?b.message:"Unknown error"}`]});}g.current&&(g.current.value="");}};return jsxs("div",{className:f("fixed inset-0 z-[9999] flex items-center justify-center",s),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:a}),jsxs("div",{className:"relative bg-gradient-to-br from-gray-900/95 to-gray-800/95 backdrop-blur-xl rounded-2xl border border-white/20 shadow-2xl max-w-2xl w-full mx-4",children:[jsxs("div",{className:"px-6 py-5 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[jsx("span",{className:"text-3xl",children:"\u{1F4E6}"}),"Export / Import"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Transfer your board data"})]}),jsx("button",{onClick:a,className:"text-white/50 hover:text-white transition-colors text-2xl leading-none p-2 hover:bg-white/10 rounded-lg","aria-label":"Close",children:"\xD7"})]}),jsxs("div",{className:"flex border-b border-white/10",children:[jsx("button",{onClick:()=>c("export"),className:f("flex-1 px-6 py-4 font-semibold transition-colors",n==="export"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Export"}),jsx("button",{onClick:()=>c("import"),className:f("flex-1 px-6 py-4 font-semibold transition-colors",n==="import"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Import"})]}),jsxs("div",{className:"p-6",children:[n==="export"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Select format"}),jsx("div",{className:"grid grid-cols-3 gap-3",children:["json","csv","pdf"].map(T=>jsxs("button",{onClick:()=>i(T),className:f("p-4 rounded-lg border-2 transition-all text-center",p===T?"border-blue-500 bg-blue-500/20 text-white":"border-white/20 hover:border-white/40 text-white/70 hover:text-white"),children:[jsxs("div",{className:"text-2xl mb-2",children:[T==="json"&&"\u{1F4C4}",T==="csv"&&"\u{1F4CA}",T==="pdf"&&"\u{1F4DD}"]}),jsx("div",{className:"font-semibold uppercase text-xs",children:T})]},T))})]}),jsxs("div",{className:"bg-white/5 rounded-lg p-4",children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:"Preview"}),jsxs("div",{className:"text-xs text-white/60",children:[jsxs("div",{children:["Board: ",jsx("span",{className:"text-white/90",children:e.title||"Untitled"})]}),jsxs("div",{children:["Columns: ",jsx("span",{className:"text-white/90",children:e.columns.length})]}),jsxs("div",{children:["Cards: ",jsx("span",{className:"text-white/90",children:e.cards.length})]})]})]}),jsx("button",{onClick:h,className:"w-full py-3 px-4 bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-500 hover:to-blue-600 text-white font-semibold rounded-lg transition-all shadow-lg shadow-blue-500/20",children:"Export Board"})]}),n==="import"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Upload file"}),jsx("input",{ref:g,type:"file",accept:".json,.csv",onChange:C,className:"hidden"}),jsxs("button",{onClick:()=>g.current?.click(),className:"w-full py-12 px-4 border-2 border-dashed border-white/30 hover:border-white/50 rounded-lg transition-colors text-white/70 hover:text-white",children:[jsx("div",{className:"text-5xl mb-3",children:"\u{1F4C1}"}),jsx("div",{className:"font-semibold mb-1",children:"Click to select file"}),jsx("div",{className:"text-xs text-white/50",children:"Supports JSON and CSV files"})]})]}),u&&jsxs("div",{className:f("p-4 rounded-lg",u.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:f("font-semibold mb-2",u.success?"text-green-400":"text-red-400"),children:u.success?"\u2713 Import Successful":"\u2717 Import Failed"}),u.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",u.cardsImported]}),jsxs("div",{children:["Columns imported: ",u.columnsImported]})]}),u.errors&&u.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:u.errors.map((T,m)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",T]},m))})]})]})]})]})]})}var Ag=["URGENT","HIGH","MEDIUM","LOW"],Fg=[{value:"none",label:"None"},{value:"created",label:"Date Created"},{value:"priority",label:"Priority"},{value:"dueDate",label:"Due Date"},{value:"title",label:"Title"},{value:"estimate",label:"Estimate"}],Ig=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function Vs({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:n,onFilterHighPriority:c,availableUsers:p=[],availableLabels:i=[],availableColumns:u=[],showQuickFilters:d=true,compact:g=false,groupBy:h="none",onGroupByChange:C}){let[T,m]=useState(true),b=useCallback(P=>{a({search:P.target.value});},[a]),y=useCallback(P=>{a({dateFilter:P.target.value});},[a]),l=useCallback(P=>{r({by:P.target.value});},[r]),w=useCallback(()=>{r({order:t.order==="asc"?"desc":"asc"});},[t.order,r]),v=e.search||e.dateFilter!=="all"||e.priorities.length>0||e.assignees.length>0||e.labels.length>0||t.by!=="none";return jsxs("div",{className:`filter-bar ${g?"filter-bar--compact":""} ${T?"filter-bar--collapsed":""}`,children:[jsxs("div",{className:"filter-bar__header",onClick:()=>m(!T),style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:T?"0":"12px",padding:"4px 6px",borderRadius:"6px",transition:"all 0.2s ease"},onMouseEnter:P=>{P.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:P=>{P.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:T?"rotate(-90deg)":"rotate(0deg)",transition:"transform 0.2s",color:"var(--theme-text-secondary)"},children:jsx("polyline",{points:"6 9 12 15 18 9"})}),jsx("span",{className:"filter-bar__label",style:{fontWeight:500,fontSize:"0.875rem",color:"var(--theme-text-primary)"},children:"Filters & Grouping"}),v&&jsxs("span",{style:{color:"var(--theme-accent-primary)",fontSize:"0.75rem",fontWeight:600},children:["(",[e.search&&"search",e.dateFilter!=="all"&&"date",e.priorities.length>0&&"priority",e.assignees.length>0&&"assignee",e.labels.length>0&&"label",t.by!=="none"&&"sort"].filter(Boolean).length," active)"]})]}),!T&&jsxs("div",{className:"filter-bar__content",children:[d&&jsxs("div",{className:"filter-bar__quick",style:{marginBottom:"12px"},children:[jsx("span",{className:"filter-bar__label",children:"Quick:"}),s&&jsx("button",{onClick:s,className:"filter-bar__quick-btn",title:"Show only my tasks",children:"My Tasks"}),n&&jsx("button",{onClick:n,className:"filter-bar__quick-btn",title:"Show overdue tasks",children:"Overdue"}),c&&jsx("button",{onClick:c,className:"filter-bar__quick-btn",title:"Show high priority tasks",children:"High Priority"})]}),jsxs("div",{className:"filter-bar__main",children:[jsx("div",{className:"filter-bar__field",children:jsx("input",{type:"text",placeholder:"Search tasks...",value:e.search,onChange:b,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:y,className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Dates"}),jsx("option",{value:"overdue",children:"Overdue"}),jsx("option",{value:"today",children:"Today"}),jsx("option",{value:"this-week",children:"This Week"})]})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.priorities[0]||"all",onChange:P=>{let x=P.target.value;a({priorities:x==="all"?[]:[x]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),Ag.map(P=>jsx("option",{value:P,children:P},P))]})}),p.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:P=>{let x=P.target.value;a({assignees:x==="all"?[]:[x]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),p.map(P=>jsx("option",{value:P.id,children:P.name},P.id))]})}),i.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:P=>{let x=P.target.value;a({labels:x==="all"?[]:[x]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),i.map(P=>jsx("option",{value:P,children:P},P))]})}),jsxs("div",{className:"filter-bar__field filter-bar__sort",children:[jsx("span",{className:"filter-bar__label",style:{color:"var(--theme-text-secondary)"},children:"Sort:"}),jsx("select",{value:t.by,onChange:l,className:"filter-bar__select filter-bar__select--sm",children:Fg.map(P=>jsx("option",{value:P.value,children:P.label},P.value))}),t.by!=="none"&&jsx("button",{onClick:w,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),C&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:h,onChange:P=>C(P.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Ig.map(P=>jsx("option",{value:P.value,children:P.label},P.value))})}),v&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function js({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:n,onExportGanttPNG:c,onExportGanttCSV:p}){let[i,u]=useState(false),d=useRef(null);useEffect(()=>{let h=C=>{d.current&&!d.current.contains(C.target)&&u(false);};return i&&document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h);}},[i]);let g=h=>{h(),u(false);};return jsxs("div",{className:f("relative",r),ref:d,children:[jsxs("button",{onClick:()=>u(!i),className:"flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-all border",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-secondary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",h.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",h.currentTarget.style.color="var(--theme-text-secondary)";},"aria-label":"Configuration Menu","aria-expanded":i,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"3"}),jsx("path",{d:"M12 1v6m0 6v6M5.6 5.6l4.2 4.2m4.2 4.2l4.2 4.2M1 12h6m6 0h6M5.6 18.4l4.2-4.2m4.2-4.2l4.2-4.2"})]}),jsx("span",{children:"Config"})]}),i&&jsxs("div",{className:"absolute right-0 mt-2 w-48 rounded-lg border shadow-lg overflow-hidden z-50",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[o==="kanban"?jsxs("button",{onClick:()=>g(e),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})}),"Export"]}):jsxs(Fragment,{children:[jsxs("button",{onClick:()=>g(async()=>await s?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),jsx("polyline",{points:"10 9 9 9 8 9"})]}),"Export PDF"]}),jsxs("button",{onClick:()=>g(async()=>await n?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),"Export Excel"]}),jsxs("button",{onClick:()=>g(async()=>await c?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),jsx("polyline",{points:"21 15 16 10 5 21"})]}),"Export PNG"]}),jsxs("button",{onClick:()=>g(()=>p?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),jsx("line",{x1:"8",y1:"17",x2:"16",y2:"17"})]}),"Export CSV"]})]}),jsxs("button",{onClick:()=>g(t),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"5"}),jsx("path",{d:"M12 1v6m0 6v6m8.5-8.5L17 15M7 9L3.5 5.5M7 15l-3.5 3.5M20.5 5.5L17 9m3.5 11.5L17 17"})]}),"Themes"]}),jsxs("button",{onClick:()=>g(a),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h.01M12 12h.01M16 12h.01M7 16h10"})]}),"Shortcuts"]})]})]})}var Ks={name:"dark",displayName:"Dark (Enhanced)",emoji:"\u{1F319}",colors:{bgPrimary:"#222326",bgSecondary:"#2A2B2F",bgTertiary:"#33343A",bgCard:"#2d2d2d",bgHover:"#353535",bgActive:"#404040",bgInput:"#2a2a2a",textPrimary:"#F4F5F8",textSecondary:"#AEB6C0",textTertiary:"#7A7F8A",textDisabled:"#606060",textInverse:"#1a1a1a",borderPrimary:"rgba(255, 255, 255, 0.1)",borderSecondary:"rgba(255, 255, 255, 0.05)",borderDefault:"#404040",borderHover:"#505050",borderSubtle:"#2a2a2a",accentPrimary:"#5E6AD2",accentHover:"#7780DD",interactivePrimary:"#0ea5e9",interactivePrimaryHover:"#0284c7",interactivePrimaryBorder:"rgba(14, 165, 233, 0.3)",interactivePrimaryBackground:"rgba(14, 165, 233, 0.1)",interactivePrimaryBackgroundHover:"rgba(14, 165, 233, 0.2)",success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6",danger:"#ef4444",dangerBorder:"rgba(239, 68, 68, 0.3)",dangerBackground:"rgba(239, 68, 68, 0.1)",dangerBackgroundHover:"rgba(239, 68, 68, 0.2)"},shadows:{sm:"0 1px 2px rgba(0, 0, 0, 0.3)",md:"0 4px 12px rgba(0, 0, 0, 0.4)",lg:"0 12px 32px rgba(0, 0, 0, 0.5)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},Ys={name:"light",displayName:"Light (Standard)",emoji:"\u2600\uFE0F",colors:{bgPrimary:"#FFFFFF",bgSecondary:"#F7F7F8",bgTertiary:"#EEEFF1",bgCard:"#ffffff",bgHover:"#f3f4f6",bgActive:"#e5e7eb",bgInput:"#f9fafb",textPrimary:"#1A1A1A",textSecondary:"#5A5A5A",textTertiary:"#8A8A8A",textDisabled:"#d1d5db",textInverse:"#ffffff",borderPrimary:"rgba(0, 0, 0, 0.1)",borderSecondary:"rgba(0, 0, 0, 0.05)",borderDefault:"#e5e7eb",borderHover:"#d1d5db",borderSubtle:"#f3f4f6",accentPrimary:"#5E6AD2",accentHover:"#4A56B8",interactivePrimary:"#0ea5e9",interactivePrimaryHover:"#0284c7",interactivePrimaryBorder:"rgba(14, 165, 233, 0.3)",interactivePrimaryBackground:"rgba(14, 165, 233, 0.08)",interactivePrimaryBackgroundHover:"rgba(14, 165, 233, 0.15)",success:"#059669",warning:"#D97706",error:"#DC2626",info:"#2563EB",danger:"#dc2626",dangerBorder:"rgba(220, 38, 38, 0.3)",dangerBackground:"rgba(220, 38, 38, 0.08)",dangerBackgroundHover:"rgba(220, 38, 38, 0.15)"},shadows:{sm:"0 1px 3px rgba(0, 0, 0, 0.12)",md:"0 4px 12px rgba(0, 0, 0, 0.15)",lg:"0 12px 32px rgba(0, 0, 0, 0.2)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},qs={name:"neutral",emoji:"\u26AA",displayName:"Neutral (Zen)",colors:{bgPrimary:"#FAFAF9",bgSecondary:"#F5F5F4",bgTertiary:"#E7E5E4",bgCard:"#FEFEFE",bgHover:"#F0EFEE",bgActive:"#E7E5E4",bgInput:"#FAFAF9",textPrimary:"#1C1917",textSecondary:"#57534E",textTertiary:"#A8A29E",textDisabled:"#D6D3D1",textInverse:"#FAFAF9",borderPrimary:"#E7E5E4",borderSecondary:"#F0EFEE",borderDefault:"#E7E5E4",borderHover:"#D6D3D1",borderSubtle:"#F5F5F4",accentPrimary:"#292524",accentHover:"#44403C",interactivePrimary:"#292524",interactivePrimaryHover:"#44403C",interactivePrimaryBorder:"rgba(41, 37, 36, 0.3)",interactivePrimaryBackground:"rgba(41, 37, 36, 0.06)",interactivePrimaryBackgroundHover:"rgba(41, 37, 36, 0.12)",success:"#15803D",warning:"#CA8A04",error:"#B91C1C",info:"#1D4ED8",danger:"#B91C1C",dangerBorder:"rgba(185, 28, 28, 0.3)",dangerBackground:"rgba(185, 28, 28, 0.08)",dangerBackgroundHover:"rgba(185, 28, 28, 0.15)"},shadows:{sm:"0 1px 3px rgba(0, 0, 0, 0.1)",md:"0 4px 12px rgba(0, 0, 0, 0.12)",lg:"0 12px 32px rgba(0, 0, 0, 0.15)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},jr={dark:Ks,light:Ys,neutral:qs},bn="dark";var yn=createContext(void 0),Gg="asakaa-theme";function Fd({children:e,defaultTheme:t=bn,storageKey:a=Gg}){let[r,o]=useState(()=>{if(typeof window<"u"){let c=localStorage.getItem(a);if(c&&(c==="dark"||c==="light"||c==="neutral"))return c}return t}),s=useCallback(c=>{o(c),typeof window<"u"&&localStorage.setItem(a,c);},[a]);useEffect(()=>{if(typeof window>"u")return;let c=document.documentElement,p=jr[r];Object.entries(p.colors).forEach(([u,d])=>{d&&c.style.setProperty(`--theme-${_g(u)}`,d);}),Object.entries({bgPrimary:"--asakaa-color-background-primary",bgSecondary:"--asakaa-color-background-secondary",bgTertiary:"--asakaa-color-background-tertiary",bgCard:"--asakaa-color-background-card",bgHover:"--asakaa-color-background-hover",bgActive:"--asakaa-color-background-active",bgInput:"--asakaa-color-background-input",textPrimary:"--asakaa-color-text-primary",textSecondary:"--asakaa-color-text-secondary",textTertiary:"--asakaa-color-text-tertiary",textDisabled:"--asakaa-color-text-disabled",textInverse:"--asakaa-color-text-inverse",borderPrimary:"--asakaa-color-border-primary",borderSecondary:"--asakaa-color-border-secondary",borderDefault:"--asakaa-color-border-default",borderHover:"--asakaa-color-border-hover",borderSubtle:"--asakaa-color-border-subtle",accentPrimary:"--asakaa-color-accent-primary",accentHover:"--asakaa-color-accent-hover",interactivePrimary:"--asakaa-color-interactive-primary",interactivePrimaryHover:"--asakaa-color-interactive-primaryHover",interactivePrimaryBorder:"--asakaa-color-interactive-primaryBorder",interactivePrimaryBackground:"--asakaa-color-interactive-primaryBackground",interactivePrimaryBackgroundHover:"--asakaa-color-interactive-primaryBackgroundHover",success:"--asakaa-color-status-success",warning:"--asakaa-color-status-warning",error:"--asakaa-color-status-error",info:"--asakaa-color-status-info",danger:"--asakaa-color-danger",dangerBorder:"--asakaa-color-danger-border",dangerBackground:"--asakaa-color-danger-background",dangerBackgroundHover:"--asakaa-color-danger-backgroundHover"}).forEach(([u,d])=>{let g=p.colors[u];g&&c.style.setProperty(d,g);}),c.setAttribute("data-theme",r),c.classList.remove("theme-dark","theme-light","theme-neutral"),c.classList.add(`theme-${r}`);},[r]);let n={theme:r,setTheme:s,themes:jr};return jsx(yn.Provider,{value:n,children:e})}function go(){let e=useContext(yn);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function _g(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Xs({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=go();return e?jsxs("div",{className:f("fixed inset-0 z-[9999] flex items-center justify-center",a),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),jsxs("div",{className:"relative rounded-2xl border shadow-2xl max-w-md w-full mx-4",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[jsxs("div",{className:"px-6 py-5 border-b flex items-center justify-between",style:{borderColor:"var(--theme-border-primary)"},children:[jsx("h2",{className:"text-2xl font-bold",style:{color:"var(--theme-text-primary)"},children:"Select Theme"}),jsx("button",{onClick:t,className:"text-2xl leading-none p-2 hover:bg-white/10 rounded-lg transition-colors",style:{color:"var(--theme-text-secondary)"},"aria-label":"Close",children:"\xD7"})]}),jsx("div",{className:"p-6 space-y-3",children:Object.entries(jr).map(([s,n])=>jsxs("button",{onClick:()=>{o(s),t();},className:f("w-full p-4 rounded-lg border-2 transition-all flex items-center gap-4",r===s?"border-blue-500 bg-blue-500/20":"border-white/20 hover:border-white/40"),style:{backgroundColor:r===s?"var(--theme-accent-primary)20":"transparent"},children:[jsx("div",{className:"text-3xl",children:n.emoji}),jsxs("div",{className:"text-left flex-1",children:[jsx("div",{className:"font-semibold",style:{color:"var(--theme-text-primary)"},children:n.displayName}),jsxs("div",{className:"text-xs",style:{color:"var(--theme-text-secondary)"},children:[s==="dark"&&"Default dark theme with Linear-inspired colors",s==="light"&&"Clean light theme with high contrast",s==="neutral"&&"Monochrome zen theme"]})]}),r===s&&jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:jsx("path",{d:"M20 6L9 17l-5-5"})})]},s))})]})]}):null}function Id(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return Ze[e]||Ze.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,n)=>a.getPropertyValue(s).trim()||n;return {bgPrimary:r("--theme-bg-primary",Ze[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",Ze[e].bgSecondary),bgGrid:r("--theme-bg-card",Ze[e].bgGrid),bgWeekend:r("--theme-bg-hover",Ze[e].bgWeekend),border:r("--theme-border-primary",Ze[e].border),borderLight:r("--theme-border-subtle",Ze[e].borderLight),textPrimary:r("--theme-text-primary",Ze[e].textPrimary),textSecondary:r("--theme-text-secondary",Ze[e].textSecondary),textTertiary:r("--theme-text-tertiary",Ze[e].textTertiary),accent:r("--theme-accent-primary",Ze[e].accent),accentHover:r("--theme-accent-hover",Ze[e].accentHover),accentLight:r("--theme-accent-primary",Ze[e].accentLight),taskBarPrimary:r("--theme-accent-primary",Ze[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",Ze[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",Ze[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",Ze[e].dependency),dependencyHover:r("--theme-border-secondary",Ze[e].dependencyHover),criticalPath:r("--theme-error",Ze[e].criticalPath),criticalPathLight:r("--theme-error",Ze[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",Ze[e].today):e==="neutral"?r("--theme-text-primary",Ze[e].today):r("--theme-error",Ze[e].today),todayLight:e==="light"?r("--theme-accent-primary",Ze[e].todayLight):e==="neutral"?r("--theme-text-primary",Ze[e].todayLight):r("--theme-error",Ze[e].todayLight),milestone:r("--theme-warning",Ze[e].milestone),milestoneLight:r("--theme-warning",Ze[e].milestoneLight),statusTodo:r("--theme-text-tertiary",Ze[e].statusTodo),statusInProgress:r("--theme-accent-primary",Ze[e].statusInProgress),statusCompleted:r("--theme-success",Ze[e].statusCompleted),hoverBg:r("--theme-bg-hover",Ze[e].hoverBg),focusRing:r("--theme-accent-primary",Ze[e].focusRing)}}var vn={columns:{taskName:"TASK NAME",startDate:"Start Date",endDate:"End Date",duration:"Duration",assignees:"Assignees",status:"Status",progress:"% Complete",priority:"Priority"},toolbar:{today:"Today",day:"Day",week:"Week",month:"Month",export:"Export",exportPdf:"Export to PDF",exportPng:"Export to PNG",exportCsv:"Export to CSV",exportExcel:"Export to Excel",exportMsProject:"Export to MS Project",undo:"Undo",redo:"Redo",createTask:"New Task",density:"Row Density",compact:"Compact",normal:"Normal",spacious:"Spacious"},contextMenu:{editTask:"Edit Task",addSubtask:"Add Subtask",markIncomplete:"Mark Incomplete",setInProgress:"Set In Progress",markComplete:"Mark Complete",splitTask:"Split Task",deleteTask:"Delete Task"},actions:{edit:"Edit",delete:"Delete",duplicate:"Duplicate",addSubtask:"Add Subtask",indent:"Indent",outdent:"Outdent",moveUp:"Move Up",moveDown:"Move Down",splitTask:"Split Task",linkTasks:"Link Tasks",unlinkTasks:"Unlink Tasks"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},labels:{progress:"Progress",duration:"Duration",days:"days",day:"day",assigned:"Assigned",milestone:"Milestone",criticalPath:"Critical Path",subtask:"Subtask",task:"Task",noTasks:"No tasks yet",addTask:"Add task",newTask:"New Task",loading:"Loading...",error:"Error",today:"Today"},ai:{placeholder:'Ask AI to edit tasks... (e.g., "Move Design to next week")',thinking:"Thinking...",suggestions:{moveTask:'Move "Task Name" to next Monday',extendTask:'Extend "Task Name" by 3 days',renameTask:'Rename "Old Name" to "New Name"',setProgress:'Set "Task Name" progress to 50%',linkTasks:'Link "Task A" to "Task B"',createTask:'Create a new task called "New Task"',deleteTask:'Delete "Task Name"',assignTask:'Assign John to "Task Name"'},errors:{taskNotFound:"Task not found",invalidDate:"Invalid date",invalidDuration:"Invalid duration",invalidProgress:"Invalid progress value",unknownCommand:"Unknown command",processingError:"Error processing command"}},export:{projectName:"Gantt Project",ganttTasks:"Gantt Tasks",taskId:"Task ID",taskName:"Task Name",startDate:"Start Date",endDate:"End Date",isMilestone:"Is Milestone",parentId:"Parent ID",yes:"Yes",no:"No",noTasksToExport:"No tasks available to export"},dateFormat:{short:"MM/dd",medium:"MMM d",long:"MMMM d, yyyy"}},Ld={columns:{taskName:"NOMBRE DE TAREA",startDate:"Fecha Inicio",endDate:"Fecha Fin",duration:"Duraci\xF3n",assignees:"Asignados",status:"Estado",progress:"% Completado",priority:"Prioridad"},toolbar:{today:"Hoy",day:"D\xEDa",week:"Semana",month:"Mes",export:"Exportar",exportPdf:"Exportar a PDF",exportPng:"Exportar a PNG",exportCsv:"Exportar a CSV",exportExcel:"Exportar a Excel",exportMsProject:"Exportar a MS Project",undo:"Deshacer",redo:"Rehacer",createTask:"Nueva Tarea",density:"Densidad",compact:"Compacto",normal:"Normal",spacious:"Espacioso"},contextMenu:{editTask:"Editar Tarea",addSubtask:"Agregar Subtarea",markIncomplete:"Marcar Incompleta",setInProgress:"Marcar En Progreso",markComplete:"Marcar Completada",splitTask:"Dividir Tarea",deleteTask:"Eliminar Tarea"},actions:{edit:"Editar",delete:"Eliminar",duplicate:"Duplicar",addSubtask:"Agregar Subtarea",indent:"Aumentar Nivel",outdent:"Disminuir Nivel",moveUp:"Mover Arriba",moveDown:"Mover Abajo",splitTask:"Dividir Tarea",linkTasks:"Vincular Tareas",unlinkTasks:"Desvincular Tareas"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},labels:{progress:"Progreso",duration:"Duraci\xF3n",days:"d\xEDas",day:"d\xEDa",assigned:"Asignado",milestone:"Hito",criticalPath:"Ruta Cr\xEDtica",subtask:"Subtarea",task:"Tarea",noTasks:"Sin tareas a\xFAn",addTask:"Agregar tarea",newTask:"Nueva Tarea",loading:"Cargando...",error:"Error",today:"Hoy"},ai:{placeholder:'P\xEDdele a la IA que edite tareas... (ej: "Mover Dise\xF1o a la pr\xF3xima semana")',thinking:"Pensando...",suggestions:{moveTask:'Mover "Nombre de Tarea" al pr\xF3ximo lunes',extendTask:'Extender "Nombre de Tarea" por 3 d\xEDas',renameTask:'Renombrar "Nombre Anterior" a "Nombre Nuevo"',setProgress:'Establecer progreso de "Nombre de Tarea" al 50%',linkTasks:'Vincular "Tarea A" con "Tarea B"',createTask:'Crear una nueva tarea llamada "Nueva Tarea"',deleteTask:'Eliminar "Nombre de Tarea"',assignTask:'Asignar a Juan a "Nombre de Tarea"'},errors:{taskNotFound:"Tarea no encontrada",invalidDate:"Fecha inv\xE1lida",invalidDuration:"Duraci\xF3n inv\xE1lida",invalidProgress:"Valor de progreso inv\xE1lido",unknownCommand:"Comando desconocido",processingError:"Error procesando el comando"}},export:{projectName:"Proyecto Gantt",ganttTasks:"Tareas Gantt",taskId:"ID de Tarea",taskName:"Nombre de Tarea",startDate:"Fecha Inicio",endDate:"Fecha Fin",isMilestone:"Es Hito",parentId:"ID Padre",yes:"S\xED",no:"No",noTasksToExport:"No hay tareas disponibles para exportar"},dateFormat:{short:"dd/MM",medium:"d MMM",long:"d de MMMM de yyyy"}},Js={en:vn,es:Ld};function Bd(e){return Js[e]||Js.en}function Zs(e,t){let a=Bd(e);return t?{columns:{...a.columns,...t.columns},toolbar:{...a.toolbar,...t.toolbar},contextMenu:{...a.contextMenu,...t.contextMenu},actions:{...a.actions,...t.actions},status:{...a.status,...t.status},labels:{...a.labels,...t.labels},ai:{...a.ai,...t.ai,suggestions:{...a.ai.suggestions,...t.ai?.suggestions},errors:{...a.ai.errors,...t.ai?.errors}},export:{...a.export,...t.export},dateFormat:{...a.dateFormat,...t.dateFormat}}:a}var ho=createContext(vn);function Io(){return useContext(ho)}function lf({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:n}){let[c,p]=useState(false),[i,u]=useState(null),d=useRef(null),g=Io();if(useEffect(()=>{let m=b=>{d.current&&!d.current.contains(b.target)&&p(false);};return c&&document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[c]),!(t||a||r||o||s||n))return null;let C=[{id:"png",label:"PNG",description:"Image",icon:jsx(FileImage,{className:"w-4 h-4"}),handler:t},{id:"pdf",label:"PDF",description:"Document",icon:jsx(FileText,{className:"w-4 h-4"}),handler:a},{id:"excel",label:"Excel",description:"Spreadsheet",icon:jsx(FileSpreadsheet,{className:"w-4 h-4"}),handler:r},{id:"csv",label:"CSV",description:"Comma-separated",icon:jsx(FileText,{className:"w-4 h-4"}),handler:o},{id:"json",label:"JSON",description:"Data",icon:jsx(FileJson,{className:"w-4 h-4"}),handler:s},{id:"msproject",label:"MS Project",description:"XML",icon:jsx(FolderKanban,{className:"w-4 h-4"}),handler:n}].filter(m=>m.handler),T=async(m,b)=>{if(b){u(m);try{await b();}catch(y){console.error(`Export ${m} failed:`,y);}finally{u(null),p(false);}}};return jsxs("div",{ref:d,className:"relative",children:[jsxs(motion.button,{onClick:()=>p(!c),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:c?e.accent:e.bgSecondary,border:`1px solid ${c?e.accent:e.borderLight}`,color:c?"#FFFFFF":e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{scale:1.02,backgroundColor:e.accent,color:"#FFFFFF"},whileTap:{scale:.98},children:[jsx(Download,{className:"w-3.5 h-3.5"}),jsx("span",{children:g.toolbar.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:c?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:c&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute right-0 mt-2 w-48 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:C.map((m,b)=>jsxs(motion.button,{onClick:()=>T(m.id,m.handler),disabled:i!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:b<C.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:b*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:i===m.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):m.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:m.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:m.description})]})]},m.id))})})})]})}function df({options:e,value:t,onChange:a,theme:r,layoutId:o="activeSegment"}){return jsx("div",{className:"inline-flex p-1 rounded-lg relative",style:{backgroundColor:r.bgSecondary,border:`1px solid ${r.borderLight}`},children:e.map(s=>{let n=t===s.value;return jsxs(motion.button,{onClick:()=>a(s.value),className:"relative px-3 py-1.5 rounded-md text-xs transition-all flex items-center gap-1.5 min-w-[70px] justify-center",style:{color:n?r.textPrimary:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:n?600:500,zIndex:n?2:1},whileHover:{scale:1.02},whileTap:{scale:.98},children:[n&&jsx(motion.div,{layoutId:o,className:"absolute inset-0 rounded-md",style:{backgroundColor:r.accent,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},transition:{type:"spring",stiffness:400,damping:30}}),s.icon&&jsx("span",{className:"relative z-10",style:{color:n?"#FFFFFF":r.textTertiary},children:s.icon}),jsx("span",{className:"relative z-10",style:{color:n?"#FFFFFF":r.textTertiary},children:s.label})]},s.value)})})}function cf({options:e,value:t,onChange:a,theme:r}){return jsx("div",{className:"inline-flex items-center gap-1",children:e.map(o=>{let s=t===o.value;return jsxs(motion.button,{onClick:()=>a(o.value),className:"relative px-3 py-1.5 text-xs transition-all",style:{color:s?r.accent:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:s?600:500},whileHover:{color:s?r.accent:r.textSecondary},whileTap:{scale:.98},children:[jsx("span",{children:o.label}),s&&jsx(motion.div,{layoutId:"timeScaleUnderline",className:"absolute bottom-0 left-1 right-1 h-0.5 rounded-full",style:{backgroundColor:r.accent},transition:{type:"spring",stiffness:400,damping:30}})]},o.value)})})}function mf({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),n=Io();useEffect(()=>{let i=u=>{s.current&&!s.current.contains(u.target)&&o(false);};return r&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let c=[{value:"compact",label:n.toolbar.compact||"Compact"},{value:"comfortable",label:n.toolbar.normal||"Normal"},{value:"spacious",label:n.toolbar.spacious||"Spacious"}],p=c.find(i=>i.value===t)?.label||"Normal";return jsxs("div",{ref:s,className:"relative",children:[jsx(motion.button,{onClick:()=>o(!r),className:"flex items-center justify-center p-2 rounded-lg transition-all",style:{backgroundColor:r?e.accentLight:e.bgSecondary,border:`1px solid ${r?e.accent:e.borderLight}`,color:r?e.accent:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.02},whileTap:{scale:.98},title:`${n.toolbar.density||"Density"}: ${p}`,children:jsx(Rows3,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute left-0 mt-2 w-36 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:c.map((i,u)=>{let d=t===i.value;return jsxs(motion.button,{onClick:()=>{a(i.value),o(false);},className:"w-full flex items-center justify-between px-3 py-2 text-left transition-all",style:{backgroundColor:d?e.accentLight:"transparent",borderBottom:u<c.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:u*.03},children:[jsx("span",{className:"text-xs",style:{color:d?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:d?600:500},children:i.label}),d&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},i.value)})})})})]})}function xn({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:n,rowDensity:c,onRowDensityChange:p,showThemeSelector:i=false,showCreateTaskButton:u=false,createTaskLabel:d,onCreateTask:g,onExportPNG:h,onExportPDF:C,onExportExcel:T,onExportCSV:m,onExportJSON:b,onExportMSProject:y}){let l=Io(),w=h||C||T||m||b||y,v=[{value:"day",label:l.toolbar.day},{value:"week",label:l.toolbar.week},{value:"month",label:l.toolbar.month}],P=[{value:"dark",label:"Dark",icon:jsx(Moon,{className:"w-3.5 h-3.5"})},{value:"light",label:"Light",icon:jsx(Sun,{className:"w-3.5 h-3.5"})},{value:"neutral",label:"Zen",icon:jsx(Palette,{className:"w-3.5 h-3.5"})}];return jsxs("div",{className:"h-12 px-4 flex items-center justify-between border-b",style:{backgroundColor:e.bgGrid,borderColor:e.border},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx(cf,{options:v,value:t,onChange:x=>a(x),theme:e}),jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsxs("div",{className:"flex items-center gap-1",children:[jsx(motion.button,{onClick:()=>o(Math.max(.5,r-.1)),className:"p-1.5 rounded-md transition-all",style:{backgroundColor:"transparent",color:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(ZoomOut,{className:"w-3.5 h-3.5"})}),jsxs("div",{className:"px-2 py-0.5 rounded text-xs tabular-nums min-w-[42px] text-center",style:{color:e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},children:[Math.round(r*100),"%"]}),jsx(motion.button,{onClick:()=>o(Math.min(2,r+.1)),className:"p-1.5 rounded-md transition-all",style:{backgroundColor:"transparent",color:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(ZoomIn,{className:"w-3.5 h-3.5"})})]}),jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsx(mf,{theme:e,value:c,onChange:p})]}),jsxs("div",{className:"flex items-center gap-3",children:[u&&g&&jsxs(Fragment,{children:[jsxs(motion.button,{onClick:g,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#FFFFFF",fontFamily:"Inter, sans-serif",fontWeight:500,boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"},whileHover:{scale:1.02,boxShadow:"0 4px 12px rgba(59, 130, 246, 0.4)"},whileTap:{scale:.98},children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{children:d||l.toolbar.createTask})]}),(w||i)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),w&&jsxs(Fragment,{children:[jsx(lf,{theme:e,onExportPNG:h,onExportPDF:C,onExportExcel:T,onExportCSV:m,onExportJSON:b,onExportMSProject:y}),i&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),i&&jsx(df,{options:P,value:s,onChange:x=>n(x),theme:e})]})]})}function kn({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,n]=useState({x:0,y:0}),c=useRef(null),p=useRef(null);useEffect(()=>{if(!r)return;let u=d=>{c.current&&!c.current.contains(d.target)&&o(false);};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]);let i=e.filter(u=>u.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:p,onClick:()=>{if(!r&&p.current){let u=p.current.getBoundingClientRect();n({x:u.left,y:u.bottom+4});}o(!r);},className:"p-2 rounded-md transition-colors flex items-center gap-1",style:{backgroundColor:a.bgSecondary,border:`1px solid ${a.borderLight}`,color:a.textSecondary},whileHover:{backgroundColor:a.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(Plus,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(gt,{children:jsx(motion.div,{ref:c,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15},className:"column-manager-menu fixed min-w-[180px] rounded-lg shadow-xl z-[9999]",style:{left:`${s.x}px`,top:`${s.y}px`,backgroundColor:a.bgSecondary,border:`1px solid ${a.border}`},children:jsxs("div",{className:"py-1",children:[jsx("div",{className:"px-3 py-2 text-xs uppercase tracking-wider",style:{color:a.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600},children:"Add Column"}),i.map(u=>jsxs("button",{onClick:()=>{t(u.id);},className:"w-full px-3 py-2 text-left flex items-center justify-between transition-colors text-sm",style:{color:a.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif"},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=a.hoverBg;},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{children:u.label}),u.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},u.id))]})})})})]})}function bo({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let n=useRef(null),[c,p]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let u=200,d=r.length*36+8,g=8,h=window.innerWidth,C=window.innerHeight,T=t,m=a;t+u+g>h&&(T=t-u,T<g&&(T=g)),a+d+g>C&&(m=C-d-g,m<g&&(m=g)),p({x:T,y:m});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let u=g=>{n.current&&!n.current.contains(g.target)&&o();},d=g=>{g.key==="Escape"&&o();};return document.addEventListener("mousedown",u),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",d);}},[e,o]),!e)return null;let i=u=>u.startsWith("#")&&(u.length===7||u.length===4)?u:s.bgPrimary?.includes("1")||s.bgPrimary?.includes("2")||s.textPrimary?.toLowerCase().includes("fff")||s.textPrimary?.toLowerCase().includes("white")?"#1E2128":"#FFFFFF";return jsx(AnimatePresence,{children:jsx(motion.div,{ref:n,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed z-[9999] min-w-[200px] rounded-lg",style:{left:`${c.x}px`,top:`${c.y}px`,backgroundColor:i(s.bgSecondary),border:`1px solid ${s.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2)",backdropFilter:"none"},children:jsx("div",{className:"py-1",children:r.map(u=>jsxs("div",{children:[u.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{u.disabled||(u.onClick(),o());},disabled:u.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:u.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:u.disabled?"not-allowed":"pointer",opacity:u.disabled?.5:1},onMouseEnter:d=>{u.disabled||(d.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[u.icon&&jsx("span",{style:{color:s.textSecondary},children:u.icon}),jsx("span",{className:"flex-1",children:u.label}),u.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},u.id))})})})}var zt={Edit:jsx(Edit3,{className:"w-4 h-4"}),Pencil:jsx(Pencil,{className:"w-4 h-4"}),Delete:jsx(Trash2,{className:"w-4 h-4"}),Add:jsx(Plus,{className:"w-4 h-4"}),AddSubtask:jsx(Plus,{className:"w-4 h-4"}),Remove:jsx(Minus,{className:"w-4 h-4"}),Link:jsx(Link2,{className:"w-4 h-4"}),Progress:jsx(BarChart3,{className:"w-4 h-4"}),Sort:jsx(ArrowUpDown,{className:"w-4 h-4"}),SortAsc:jsx(ArrowUp,{className:"w-4 h-4"}),SortDesc:jsx(ArrowDown,{className:"w-4 h-4"}),Hide:jsx(EyeOff,{className:"w-4 h-4"}),Show:jsx(Eye,{className:"w-4 h-4"}),Settings:jsx(Settings,{className:"w-4 h-4"}),Split:jsx(Scissors,{className:"w-4 h-4"}),MarkIncomplete:jsx(Circle,{className:"w-4 h-4"}),SetInProgress:jsx(PlayCircle,{className:"w-4 h-4"}),MarkComplete:jsx(CheckCircle2,{className:"w-4 h-4"})};function Yd({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:n,onTaskIndent:c,onTaskOutdent:p,onTaskRename:i,onTaskToggleExpand:u,onOpenTaskModal:d,enableKeyboard:g=true}){let h=useRef(false),C=useCallback(l=>{h.current=l;},[]),T=useCallback(l=>{let w=[],v=P=>{for(let x of P)w.push(x),x.subtasks&&x.subtasks.length>0&&x.isExpanded&&v(x.subtasks);};return v(l),w},[]),m=useCallback(()=>{let l=T(e);for(let w of l)if(t.has(w.id))return w;return null},[e,t,T]),b=useCallback((l,w)=>{let v=T(e);if(v.length===0)return;let P=m();if(!P){a(v[0].id,false);return}let x=v.findIndex(M=>M.id===P.id);if(x===-1)return;let k=l==="up"?x-1:x+1;if(k<0||k>=v.length)return;let O=v[k];a(O.id,w);},[e,m,T,a]),y=useCallback(l=>{if(!g)return;let w=l.target;if(w.tagName==="INPUT"||w.tagName==="TEXTAREA"||w.isContentEditable||h.current){l.key==="Escape"&&(w.blur(),h.current=false);return}let x=navigator.platform.toUpperCase().indexOf("MAC")>=0?l.metaKey:l.ctrlKey,k=Array.from(t),O=m();if(l.key==="ArrowUp"){l.preventDefault(),b("up",l.shiftKey);return}if(l.key==="ArrowDown"){l.preventDefault(),b("down",l.shiftKey);return}if(O&&(l.key==="ArrowRight"||l.key==="ArrowLeft")){O.subtasks&&O.subtasks.length>0&&(l.preventDefault(),(l.key==="ArrowRight"&&!O.isExpanded||l.key==="ArrowLeft"&&O.isExpanded)&&u(O.id));return}if(l.altKey&&(l.key==="ArrowUp"||l.key==="ArrowDown")){k.length>0&&(l.preventDefault(),n(k,l.key==="ArrowUp"?"up":"down"));return}if(l.key==="Tab"&&!l.shiftKey){k.length>0&&(l.preventDefault(),c(k));return}if(l.key==="Tab"&&l.shiftKey){k.length>0&&(l.preventDefault(),p(k));return}if(l.key==="Enter"&&!l.shiftKey&&!x){O&&(l.preventDefault(),r(O.id,"below"));return}if(l.key==="Enter"&&l.shiftKey&&!x){O&&(l.preventDefault(),r(O.id,"above"));return}if(l.key==="Enter"&&x){O&&(l.preventDefault(),d(O.id));return}if(l.key==="F2"){O&&(l.preventDefault(),i(O.id));return}if(l.key==="Delete"||l.key==="Backspace"&&x){k.length>0&&(l.preventDefault(),o(k));return}if(l.key==="d"&&x&&!l.shiftKey){k.length>0&&(l.preventDefault(),s(k));return}},[g,t,m,b,r,o,s,n,c,p,i,u,d]);return useEffect(()=>{if(g)return window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y);}},[g,y]),{setIsEditing:C}}function Xd(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(d=>{t(new Set([d])),r(d);},[]),s=useCallback(d=>{t(g=>{let h=new Set(g);return h.has(d)?h.delete(d):h.add(d),h}),r(d);},[]),n=useCallback((d,g)=>{if(!a){o(d);return}let h=g.indexOf(a),C=g.indexOf(d);if(h===-1||C===-1){o(d);return}let T=Math.min(h,C),m=Math.max(h,C),b=g.slice(T,m+1);t(new Set(b)),r(d);},[a,o]),c=useCallback((d,g,h,C)=>{C?n(d,g):h?s(d):o(d);},[o,s,n]),p=useCallback((d,g)=>{g?t(h=>{let C=new Set(h);return C.add(d),C}):o(d);},[o]),i=useCallback(()=>{t(new Set),r(null);},[]),u=useCallback(d=>e.has(d),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:n,handleTaskClick:c,handleKeyboardSelection:p,clearSelection:i,isTaskSelected:u}}function yo(e){let t=[],a=(r,o,s=0)=>{for(let n=0;n<r.length;n++){let c={...r[n],parentId:o,level:s,position:n};t.push(c),c.subtasks&&c.subtasks.length>0&&c.isExpanded&&a(c.subtasks,c.id,s+1);}};return a(e),t}function Jd(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=Jd(a.subtasks,t);if(r)return r}}return null}function ti(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=ti(a.subtasks,t);if(r)return r}return null}function ai(e,t){if(t.length===0)return e;let a=yo(e),r=t[0],o=a.findIndex(d=>d.id===r);if(o<=0)return e;let s=a[o-1],n=(d,g)=>{let h=[];return {tasks:d.filter(T=>{if(g.has(T.id))return h.push(T),false;if(T.subtasks){let m=n(T.subtasks,g);T.subtasks=m.tasks,h.push(...m.removed);}return true}),removed:h}},c=(d,g,h)=>d.map(C=>C.id===g?{...C,subtasks:[...C.subtasks||[],...h],isExpanded:true}:C.subtasks?{...C,subtasks:c(C.subtasks,g,h)}:C),p=new Set(t),{tasks:i,removed:u}=n(e,p);return c(i,s.id,u)}function ri(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=ti(a,r);if(!o)continue;let s=ti(a,o.id),n=(i,u,d)=>{for(let g=0;g<i.length;g++){let h=i[g];if(h.id===u&&h.subtasks){let C=h.subtasks.findIndex(T=>T.id===d);if(C!==-1){let[T]=h.subtasks.splice(C,1);return T}}if(h.subtasks){let C=n(h.subtasks,u,d);if(C)return C}}return null},c=(i,u,d)=>{let g=i.findIndex(h=>h.id===u);if(g!==-1)return i.splice(g+1,0,d),i;for(let h of i)h.subtasks&&c(h.subtasks,u,d);return i},p=n(a,o.id,r);p&&(s&&s.subtasks?c(s.subtasks,o.id,p):c(a,o.id,p));}return a}function oi(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(n,c,p)=>{let i=n.findIndex(d=>d.id===c);if(i===-1){for(let d of n)if(d.subtasks&&s(d.subtasks,c,p))return true;return false}let u=p==="up"?i-1:i+1;return u<0||u>=n.length?false:([n[i],n[u]]=[n[u],n[i]],true)};return s(r,o,a),r}function ni(e,t){let a=new Set(t),r=o=>o.filter(s=>!a.has(s.id)).map(s=>s.subtasks?{...s,subtasks:r(s.subtasks)}:s);return r(e)}function si(e,t){let a=[...e];for(let r of t){let o=n=>{let c=n.findIndex(u=>u.id===r);if(c===-1){for(let u of n)if(u.subtasks&&o(u.subtasks))return true;return false}let p=n[c],i={...p,id:`${p.id}-copy-${Date.now()}`,name:`${p.name} (Copy)`,subtasks:p.subtasks?s(p.subtasks):void 0};return n.splice(c+1,0,i),true},s=n=>n.map(c=>({...c,id:`${c.id}-copy-${Date.now()}`,subtasks:c.subtasks?s(c.subtasks):void 0}));o(a);}return a}function Zd(e,t,a){let r=[...e],o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let n={id:`task-${Date.now()}`,name:"New Task",progress:0,status:"todo",startDate:o,endDate:s,color:"#6366F1"},c=p=>{let i=p.findIndex(d=>d.id===t);if(i===-1){for(let d of p)if(d.subtasks&&c(d.subtasks))return true;return false}let u=a==="above"?i:i+1;return p.splice(u,0,n),true};return c(r),{tasks:r,newTask:n}}function ii(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:ii(r.subtasks,t,a)}:r)}function li(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:li(a.subtasks,t)}:a)}function di(e,t){let a=u=>{for(let d of u){if(d.id===t)return d;if(d.subtasks){let g=a(d.subtasks);if(g)return g}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let n=r?.startDate||o,c=r?.endDate||s,p={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(n),endDate:new Date(c),color:r?.color||"#3B82F6"},i=u=>u.map(d=>{if(d.id===t){let g=d.subtasks||[];return {...d,subtasks:[...g,p],isExpanded:true}}return d.subtasks?{...d,subtasks:i(d.subtasks)}:d});return {tasks:i(e),newTask:p}}function Qd(e,t,a,r){if(t===a)return e;let o=Jd(e,t);if(!o)return e;if(a){let c=(p,i)=>{if(!p.subtasks)return false;for(let u of p.subtasks)if(u.id===i||c(u,i))return true;return false};if(c(o,a))return e}let s=c=>c.filter(p=>p.id!==t).map(p=>p.subtasks&&p.subtasks.length>0?{...p,subtasks:s(p.subtasks)}:p),n=s(e);if(a===null){let c=r!==void 0?r:n.length;n.splice(c,0,{...o,parentId:void 0});}else {let c=p=>p.map(i=>{if(i.id===a){let u=i.subtasks||[],d=r!==void 0?r:u.length,g=[...u];return g.splice(d,0,{...o,parentId:a}),{...i,subtasks:g,isExpanded:true}}return i.subtasks&&i.subtasks.length>0?{...i,subtasks:c(i.subtasks)}:i});n=c(n);}return n}function Tn({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:n,onTaskContextMenu:c,onTaskToggle:p,scrollTop:i,columns:u,onToggleColumn:d,onColumnResize:g,onTaskUpdate:h,onTaskIndent:C,onTaskOutdent:T,onTaskMove:m,onMultiTaskDelete:b,onTaskDuplicate:y,onTaskCreate:l,onTaskRename:w,onCreateSubtask:v,onOpenTaskModal:P,onDeleteRequest:x,onTaskReparent:k}){let O=useContext(ho),[M,N]=useState(null),[H,L]=useState(null),[Y,ae]=useState(""),ke=useRef(null),[Pe,Ve]=useState(null),[Je,$]=useState(0),[B,W]=useState(0),[D,j]=useState({isOpen:false,x:0,y:0,type:"header"}),[J,R]=useState(null),[de,we]=useState(null),[Me,ce]=useState(null),We=useRef(0),Fe=5,Ye=useRef(false),[ut,yt]=useState(null),[nt,z]=useState(false),[re,oe]=useState(null),[xe,Ne]=useState(false),tt=useRef(null);useEffect(()=>{function K(te){tt.current&&!tt.current.contains(te.target)&&Ne(false);}if(xe)return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[xe]),useEffect(()=>{H&&ke.current&&(ke.current.focus(),ke.current.select());},[H]),useEffect(()=>{if(!Pe)return;let K=Ee=>{let He=Ee.clientX-Je,Oe=B+He;g?.(Pe,Oe);},te=()=>{Ve(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",K),document.addEventListener("mouseup",te),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",K),document.removeEventListener("mouseup",te),document.body.style.cursor="",document.body.style.userSelect="";}},[Pe,Je,B,g]);let{selectedTaskIds:ht,handleTaskClick:Ie,isTaskSelected:be}=Xd(),{setIsEditing:Se}=Yd({tasks:e,selectedTaskIds:ht,onTaskSelect:(K,te)=>{let He=yo(e).map(Oe=>Oe.id);Ie(K,He,te||false,false);},onTaskCreate:l||(()=>{}),onTaskDelete:b||(()=>{}),onTaskDuplicate:y||(()=>{}),onTaskMove:m||(()=>{}),onTaskIndent:C||(()=>{}),onTaskOutdent:T||(()=>{}),onTaskRename:K=>{let te=yo(e).find(Ee=>Ee.id===K);te&&Ue(te);},onTaskToggleExpand:p||(()=>{}),onOpenTaskModal:K=>{let te=yo(e).find(Ee=>Ee.id===K);te&&P&&P(te);},enableKeyboard:true}),Ft=(K,te=0)=>{let Ee=[];for(let He of K)Ee.push({task:He,level:te}),He.subtasks&&He.subtasks.length>0&&He.isExpanded&&Ee.push(...Ft(He.subtasks,te+1));return Ee},bt=Ft(e),sa=48,ua=Math.max(bt.length*a,600-sa),$e=K=>!K.startDate||!K.endDate?"-":`${Math.ceil((K.endDate.getTime()-K.startDate.getTime())/(1e3*60*60*24))}d`,Ue=K=>{L(K.id),ae(K.name),Se(true);},ia=K=>{Y.trim()&&Y!==e.find(te=>te.id===K)?.name&&w?.(K,Y.trim()),L(null),ae(""),Se(false);},ue=()=>{L(null),ae(""),Se(false);},S=(K,te)=>{te.stopPropagation(),v?.(K.id);},Z=(K,te)=>{te.preventDefault(),We.current=te.clientY,R(K),Ye.current=false,z(false),yt({x:te.clientX,y:te.clientY});},ge=K=>{if(!J||(Math.abs(K.clientY-We.current)>Fe&&!Ye.current&&(Ye.current=true,z(true)),yt({x:K.clientX,y:K.clientY}),!Ye.current))return;let Ee=document.querySelectorAll("[data-task-row]"),He=null,Oe=null;Ee.forEach(G=>{let ee=G.getBoundingClientRect(),Be=G.getAttribute("data-task-row");if(Be&&Be!==J&&K.clientY>=ee.top&&K.clientY<=ee.bottom){He=Be;let Et=K.clientY-ee.top,dt=ee.height;Et<dt*.25?Oe="above":Et>dt*.75?Oe="below":Oe="child";}}),we(He),ce(Oe);},Te=()=>{if(Ye.current&&J&&de&&Me){if(Me==="child")k?.(J,de);else if(Me==="above"||Me==="below"){let K=(He,Oe,G=null)=>{for(let ee of He){if(ee.id===Oe)return G;if(ee.subtasks){let Be=K(ee.subtasks,Oe,ee.id);if(Be!==void 0)return Be}}},te=K(e,de,null),Ee=(He,Oe)=>{let G=He.findIndex(ee=>ee.id===Oe);return Me==="below"?G+1:G};if(te===null){let He=Ee(e,de);k?.(J,null,He);}else {let He=bt.find(Oe=>Oe.task.id===te)?.task;if(He?.subtasks){let Oe=Ee(He.subtasks,de);k?.(J,te,Oe);}}}}R(null),we(null),ce(null),yt(null),Ye.current=false,z(false);};useEffect(()=>{if(J)return document.addEventListener("mousemove",ge),document.addEventListener("mouseup",Te),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",ge),document.removeEventListener("mouseup",Te),document.body.style.cursor="",document.body.style.userSelect="";}},[J,de,Me]);let qe=(K,te,Ee)=>{switch(K.id){case "name":let He=H===te.id,Oe=M===te.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${Ee*20}px`},children:[k&&jsx("div",{className:"cursor-grab active:cursor-grabbing p-0.5 rounded hover:bg-white/10 transition-all flex-shrink-0",style:{color:t.textTertiary,opacity:Oe?1:.3},onMouseDown:q=>Z(te.id,q),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),te.subtasks&&te.subtasks.length>0?jsx("button",{onClick:q=>{q.stopPropagation(),p?.(te.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:te.isExpanded?jsx(ChevronDown,{className:"w-4 h-4"}):jsx(ChevronRight,{className:"w-4 h-4"})}):jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:jsx("div",{className:"w-3 h-3 rounded-full border",style:{backgroundColor:te.color||"#3B82F6",opacity:te.parentId?.6:1,borderColor:te.isMilestone?t.accent:"transparent",borderWidth:te.isMilestone?"2px":"0px"},title:te.isMilestone?"Milestone":te.parentId?"Subtask":"Task"})}),He?jsx("input",{ref:ke,type:"text",value:Y,onChange:q=>ae(q.target.value),onKeyDown:q=>{q.key==="Enter"?ia(te.id):q.key==="Escape"&&ue();},onBlur:()=>ia(te.id),className:"flex-1 px-2 py-1 rounded border outline-none",style:{backgroundColor:t.bgPrimary,borderColor:t.accent,color:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:"13px",fontWeight:500},onClick:q=>q.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:te.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:te.parentId?"13px":"14px",fontWeight:te.isMilestone?600:te.parentId?400:600,letterSpacing:te.parentId?"0":"-0.01em"},title:te.name,children:te.name}),Oe&&!He&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:q=>q.stopPropagation(),children:[jsx("button",{onClick:q=>S(te,q),className:"p-1 rounded hover:bg-opacity-20 transition-colors",style:{color:t.textTertiary,backgroundColor:"transparent"},title:"Create subtask",children:jsx(Plus,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:q=>{q.stopPropagation(),Ue(te);},className:"p-1 rounded hover:bg-opacity-20 transition-colors",style:{color:t.textTertiary,backgroundColor:"transparent"},title:"Rename (F2)",children:jsx(Edit3,{className:"w-3.5 h-3.5"})})]})]})]});case "startDate":case "endDate":let ee=K.id==="startDate"?"startDate":"endDate",Be=te[ee],Et=re?.taskId===te.id&&re?.field===ee,dt=q=>q?(typeof q=="string"?new Date(q):q).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):"-";return jsxs("div",{className:"flex items-center justify-center w-full relative",onClick:q=>q.stopPropagation(),children:[jsxs("button",{type:"button",className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors hover:bg-white/5",style:{color:t.textSecondary},onClick:q=>{if(Et)oe(null);else {let Le=q.currentTarget.getBoundingClientRect();oe({taskId:te.id,field:ee,month:Be?typeof Be=="string"?new Date(Be):Be:new Date,position:{top:Le.bottom+4,left:Le.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:dt(Be)})]}),Et&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>oe(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"fixed z-[9999] rounded-xl shadow-2xl overflow-visible flex",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,top:re?.position.top,left:re?.position.left},onClick:q=>q.stopPropagation(),children:[jsxs("div",{className:"w-36 py-2",style:{borderRight:`1px solid ${t.border}`},children:[(()=>{let q=new Date,Le=new Date(q);Le.setDate(q.getDate()+1);let ct=new Date(q);ct.setDate(q.getDate()+7);let ne=new Date(q);return ne.setDate(q.getDate()+14),[{label:"Hoy",date:q},{label:"Ma\xF1ana",date:Le},{label:"Pr\xF3xima semana",date:ct},{label:"2 semanas",date:ne}].map((xt,Ae)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:Qt=>Qt.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:Qt=>Qt.currentTarget.style.backgroundColor="transparent",onClick:()=>{h?.(te.id,{[ee]:xt.date}),oe(null);},children:xt.label},Ae))})(),jsx("div",{style:{borderTop:`1px solid ${t.border}`,margin:"0.25rem 0"}}),jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:q=>q.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:q=>q.currentTarget.style.backgroundColor="transparent",onClick:()=>{h?.(te.id,{[ee]:void 0}),oe(null);},children:"Borrar"})]}),jsxs("div",{className:"p-2",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("button",{type:"button",onClick:()=>oe(q=>q?{...q,month:new Date(q.month.getFullYear(),q.month.getMonth()-1)}:null),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-3.5 h-3.5",style:{color:t.textSecondary}})}),jsx("span",{className:"text-xs font-medium",style:{color:t.textPrimary},children:re?.month.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>oe(q=>q?{...q,month:new Date(q.month.getFullYear(),q.month.getMonth()+1)}:null),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:t.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-0.5 mb-1",children:["D","L","M","M","J","V","S"].map((q,Le)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:q},Le))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let q=re?.month||new Date,Le=q.getFullYear(),ct=q.getMonth(),ne=new Date(Le,ct,1).getDay(),ze=new Date(Le,ct+1,0).getDate(),xt=new Date,Ae=[];for(let mt=ne-1;mt>=0;mt--)Ae.push({day:new Date(Le,ct,-mt).getDate(),date:new Date(Le,ct-1,new Date(Le,ct,-mt).getDate()),isCurrentMonth:false});for(let mt=1;mt<=ze;mt++)Ae.push({day:mt,date:new Date(Le,ct,mt),isCurrentMonth:true});let Qt=42-Ae.length;for(let mt=1;mt<=Qt;mt++)Ae.push({day:mt,date:new Date(Le,ct+1,mt),isCurrentMonth:false});return Ae.map((mt,la)=>{let $t=mt.date.toDateString()===xt.toDateString(),Mt=(Be?typeof Be=="string"?new Date(Be):Be:null)?.toDateString()===mt.date.toDateString();return jsx("button",{type:"button",className:"w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",style:{color:mt.isCurrentMonth?Mt?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:Mt?"#3B82F6":"transparent",boxShadow:$t&&!Mt?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{h?.(te.id,{[ee]:mt.date}),oe(null);},children:mt.day},la)})})()})]})]})]}),document.body)]});case "duration":return jsx("div",{className:"flex items-center justify-center w-full",children:jsx("span",{className:"text-xs tabular-nums",style:{color:t.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:600},children:$e(te)})});case "assignees":let Ka=r.filter(q=>te.assignees?.some(Le=>Le.name===q.name||Le.initials===q.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:q=>q.stopPropagation(),children:jsx($r,{assignedUsers:Ka,availableUsers:r,onChange:q=>{let Le=q.map(ct=>({id:ct.id,name:ct.name,initials:ct.initials,color:ct.color}));h?.(te.id,{assignees:Le.length>0?Le:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:q=>q.stopPropagation(),children:jsx(Gl,{status:te.status||"todo",onChange:q=>{h?.(te.id,{status:q,progress:q==="completed"?100:te.progress});}})});case "progress":return jsxs("div",{className:"flex items-center justify-center gap-2 w-full",children:[jsx("div",{className:"flex-1 h-1.5 rounded-full overflow-hidden max-w-[60px]",style:{backgroundColor:t.bgSecondary},children:jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${te.progress}%`,backgroundColor:te.progress===100?t.statusCompleted:t.accent}})}),jsxs("span",{className:"text-xs tabular-nums min-w-[35px] text-right",style:{color:t.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600},children:[te.progress,"%"]})]});case "priority":let za={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},F={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},he=za[te.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:q=>q.stopPropagation(),children:jsx(zr,{priority:he,onChange:q=>{q&&h?.(te.id,{priority:F[q]||"medium"});}})});default:return null}},Ge=K=>[{id:"hide",label:"Hide Column",icon:zt.Hide,onClick:()=>d(K),disabled:K==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:zt.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:zt.SortDesc,onClick:()=>{}}],Re=K=>K.subtasks&&K.subtasks.length>0?[{id:"addSubtask",label:O?.contextMenu?.addSubtask||"Add Subtask",icon:zt.Add,onClick:()=>{v?.(K.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:O?.contextMenu?.deleteTask||"Delete Task",icon:zt.Delete,onClick:()=>{x?x(K.id,K.name):b?.([K.id]);}}]:[{id:"edit",label:O?.contextMenu?.editTask||"Edit Task",icon:zt.Pencil,onClick:()=>{n?.(K);}},{id:"addSubtask",label:O?.contextMenu?.addSubtask||"Add Subtask",icon:zt.Add,onClick:()=>{v?.(K.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:O?.contextMenu?.markIncomplete||"Mark Incomplete",icon:zt.MarkIncomplete,onClick:()=>{h?.(K.id,{status:"todo",progress:0});},disabled:K.status==="todo"},{id:"setInProgress",label:O?.contextMenu?.setInProgress||"Set In Progress",icon:zt.SetInProgress,onClick:()=>{h?.(K.id,{status:"in-progress"});},disabled:K.status==="in-progress"},{id:"markComplete",label:O?.contextMenu?.markComplete||"Mark Complete",icon:zt.MarkComplete,onClick:()=>{h?.(K.id,{status:"completed",progress:100});},disabled:K.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:O?.contextMenu?.splitTask||"Split Task",icon:zt.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:O?.contextMenu?.deleteTask||"Delete Task",icon:zt.Delete,onClick:()=>{x?x(K.id,K.name):b?.([K.id]);}}],at=u.filter(K=>K.visible),lt=at.reduce((K,te)=>K+te.width,0);return jsxs("div",{className:"h-full",style:{backgroundColor:t.bgPrimary,minWidth:lt},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${sa}px`,paddingLeft:"3px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:[jsx("div",{className:"flex items-center flex-1 min-w-0",children:at.map((K,te)=>{let Ee=te===at.length-1,He=K.id==="name";return jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${He?"":"justify-center"}`,style:{width:`${K.width}px`,minWidth:`${K.minWidth??(He?200:60)}px`,maxWidth:`${K.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:Ee?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:Oe=>{Oe.preventDefault(),j({isOpen:true,x:Oe.clientX,y:Oe.clientY,type:"header",columnId:K.id});},onMouseEnter:Oe=>{Oe.currentTarget.style.backgroundColor=t.hoverBg;},onMouseLeave:Oe=>{Oe.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:t.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,paddingRight:"0"},title:K.label,children:K.label}),K.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:Pe===K.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:Oe=>{Oe.preventDefault(),Oe.stopPropagation(),Ve(K.id),$(Oe.clientX),W(K.width);},title:"Drag to resize column",children:jsx("div",{className:"absolute top-2 bottom-2 opacity-0 group-hover:opacity-100 transition-opacity",style:{left:"3px",width:"2px",backgroundColor:t.accent,borderRadius:"1px"}})})]},K.id)})}),jsxs("div",{className:"flex items-center gap-1 px-2",style:{position:"sticky",right:0,height:"100%",backgroundColor:t.bgGrid,zIndex:5},children:[jsx(kn,{columns:u,onToggleColumn:d,theme:t}),jsx("button",{onClick:()=>Ne(!xe),className:"p-1.5 rounded hover:bg-opacity-10 transition-colors",style:{color:t.textTertiary},title:"Keyboard shortcuts",children:jsx(Keyboard,{className:"w-4 h-4"})}),xe&&jsxs("div",{ref:tt,className:"absolute top-full right-0 mt-2 p-4 rounded-lg shadow-2xl z-50 min-w-[400px]",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,color:t.textPrimary},onClick:K=>K.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b",style:{borderColor:t.border},children:[jsx("h3",{className:"font-semibold text-sm",style:{color:t.textPrimary},children:"Keyboard Shortcuts"}),jsx("button",{onClick:()=>Ne(false),className:"text-xs px-2 py-1 rounded hover:bg-opacity-10",style:{color:t.textTertiary},children:"Close"})]}),jsxs("div",{className:"space-y-3 text-xs",children:[jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Navigation"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move focus up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Select range"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Toggle selection"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Click"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Hierarchy"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Indent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Outdent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Expand/Collapse"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2192 / \u2190"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Editing"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task below"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task above"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Open task modal"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Rename task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"F2"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Actions"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move task up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Alt + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Delete task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Delete"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Duplicate task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + D"})]})]})]})]})]})]})]}),jsx("div",{className:"gantt-taskgrid-content",style:{minHeight:ua},children:bt.map(({task:K,level:te},Ee)=>{let He=be(K.id),Oe=de===K.id,G=Oe&&Me==="above",ee=Oe&&Me==="below",Be=Oe&&Me==="child",Et={};return Be&&(Et.backgroundColor=`${t.accent}15`,Et.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":K.id,className:`flex items-center cursor-pointer group ${J===K.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:He?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:He?t.accentLight:Be?`${t.accent}15`:Ee%2===0?t.bgPrimary:t.bgGrid,...Et},onMouseEnter:()=>N(K.id),onMouseLeave:()=>N(null),onClick:dt=>{let za=yo(e).map(q=>q.id),he=navigator.platform.toUpperCase().indexOf("MAC")>=0?dt.metaKey:dt.ctrlKey;Ie(K.id,za,he,dt.shiftKey),s?.(K);},onDoubleClick:dt=>{dt.stopPropagation(),n?.(K);},onContextMenu:dt=>{dt.preventDefault(),j({isOpen:true,x:dt.clientX,y:dt.clientY,type:"task",task:K}),c?.(K,dt);},whileHover:{backgroundColor:He?t.accentLight:t.hoverBg},children:[G&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),ee&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),at.map((dt,Ka)=>{let za=Ka===at.length-1,F=dt.id==="name";return jsx("div",{className:`px-4 flex items-center ${F?"justify-start":"justify-center"}`,style:{width:`${dt.width}px`,minWidth:`${dt.minWidth??(F?200:60)}px`,maxWidth:`${dt.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:za?"none":`1px solid ${M===K.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:qe(dt,K,F?te:0)},`${K.id}-${dt.id}`)})]},K.id)})}),jsx(bo,{isOpen:D.isOpen,x:D.x,y:D.y,items:D.type==="header"&&D.columnId?Ge(D.columnId):D.type==="task"&&D.task?Re(D.task):[],onClose:()=>j({...D,isOpen:false}),theme:t}),nt&&ut&&J&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:ut.x+12,top:ut.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let K=bt.find(te=>te.task.id===J)?.task;return K?jsx("div",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{backgroundColor:"rgba(255, 255, 255, 0.08)",backdropFilter:"blur(4px)"},children:jsx("span",{className:"text-xs font-medium",style:{color:t.textSecondary,opacity:.9},children:K.name})}):null})()}),document.body)]})}function oc(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[n,c]=useState(e),[p,i]=useState(t),[u,d]=useState(null),[g,h]=useState(null),[C,T]=useState(null),[m,b]=useState(null),[y,l]=useState(0),[w,v]=useState(0),[P,x]=useState(null),[k,O]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:n,setGhostX:c,ghostWidth:p,setGhostWidth:i,connectionLine:u,setConnectionLine:d,hoveredTaskId:g,setHoveredTaskId:h,activeZone:C,setActiveZone:T,draggedSegmentIndex:m,setDraggedSegmentIndex:b,draggedSegmentStartX:y,setDraggedSegmentStartX:l,segmentDragOffsetX:w,setSegmentDragOffsetX:v,hoveredSegmentIndex:P,setHoveredSegmentIndex:x,isHovered:k,setIsHovered:O,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(Y,ae)=>{r("none"),d(null),h(null),c(Y),i(ae),v(0),b(null),l(0);}}}function Nn({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:n,templates:c,onClick:p,onDoubleClick:i,onContextMenu:u,onDateChange:d,onDependencyCreate:g,allTaskPositions:h=[],onDragMove:C,onHoverChange:T}){let m=oc(t,r),b=useRef(null),{dragMode:y,setDragMode:l,dragOffset:w,setDragOffset:v,ghostX:P,setGhostX:x,ghostWidth:k,setGhostWidth:O,connectionLine:M,setConnectionLine:N,hoveredTaskId:H,setHoveredTaskId:L,activeZone:Y,setActiveZone:ae,draggedSegmentIndex:ke,setDraggedSegmentIndex:Pe,draggedSegmentStartX:Ve,setDraggedSegmentStartX:Je,segmentDragOffsetX:$,setSegmentDragOffsetX:B,hoveredSegmentIndex:W,setHoveredSegmentIndex:D,isHovered:j,setIsHovered:J,isDragging:R,isResizing:de,isConnecting:we,resetDragState:Me}=m,ce=32,We=8,Fe=e.endDate&&e.endDate<new Date&&e.progress<100,Ye=e.isCriticalPath,ut=o.name==="neutral"||o.today==="#1C1917",yt=e.status==="completed"||e.progress===100,nt={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},re=e.isCriticalPath||Fe?"#DC2626":e.color?e.color:e.priority&&nt[e.priority]?nt[e.priority]:o.taskBarPrimary,xe=(ue=>ue>=80?20:ue>=60?15:ue>=50?12:10)(r),Ne=r<50,tt=r<40;useEffect(()=>{if(T)if(j&&!R&&!e.segments){let ue=a<100;T({task:e,x:t,y:a,width:r,height:ce,showBelow:ue});}else T(null);},[j,R,e,t,a,r,ce,T]);let ht=ue=>ue.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Ie=()=>{let ue=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${ue} day${ue!==1?"s":""}`},be=ue=>Math.round(ue/s)*s,Se=ue=>{let S=Math.round(ue/s),Z=new Date(n);return Z.setDate(Z.getDate()+S),Z},Ft=(ue,S)=>{for(let Z of h){if(Z.id===e.id)continue;let ge=5;if(ue>=Z.x-ge&&ue<=Z.x+Z.width+ge&&S>=Z.y-ge&&S<=Z.y+Z.height+ge)return Z.id}return null},bt=useCallback((ue,S,Z)=>{ue.preventDefault(),ue.stopPropagation();let ge=b.current?.ownerSVGElement;if(!ge)return;let Te=ge.createSVGPoint();Te.x=ue.clientX,Te.y=ue.clientY;let qe=Te.matrixTransform(ge.getScreenCTM()?.inverse()),Ge=Z!==void 0?Z:t,Re=S;if(!Re){let at=qe.x-Ge;ue.shiftKey?(Re="connect",N({x:t+r,y:a+ce/2})):ue.ctrlKey||ue.metaKey?Re="move":ue.altKey?Re=at<r/2?"resize-start":"resize-end":tt?at<r/2?Re="move":Re="resize-end":Ne?at<=xe/2?Re="resize-start":at>=r-xe/2?Re="resize-end":Re="move":at<=xe?Re="resize-start":at>=r-xe?Re="resize-end":Re="move";}l(Re),J(false),ae(null),Re==="move"?v(qe.x-Ge):Re==="connect"?N({x:t+r,y:a+ce/2}):v(0),x(Ge),O(r);},[t,r,a,ce]),sa=useCallback(ue=>{if(y==="none")return;let S=b.current?.ownerSVGElement;if(!S)return;let Z=S.createSVGPoint();Z.x=ue.clientX,Z.y=ue.clientY;let ge=Z.matrixTransform(S.getScreenCTM()?.inverse());if(y==="connect"){N({x:ge.x,y:ge.y});let Te=Ft(ge.x,ge.y);L(Te);}else if(y==="move"){let Te=ge.x-w,qe=be(Te);x(qe),O(r);let Ge=Math.round((qe-t)/s);if(C?.(e.id,Ge,true),e.segments&&e.segments.length>0&&ke!==null){let Re=qe-Ve;B(Re);}}else if(y==="resize-start"){let Te=ge.x,qe=be(Te),Ge=t+r-qe;Ge>=s&&(x(qe),O(Ge));}else if(y==="resize-end"){let Te=ge.x,Ge=be(Te)-t;Ge>=s&&O(Ge);}},[y,t,r,s,w,e,be,ke,Ve,Ft,L,N,x,O,B,C]),ua=useCallback(()=>{if(y!=="none"){if(y==="connect")H&&g&&g(e,H),N(null),L(null);else {let ue=e.endDate.getTime()-e.startDate.getTime(),S,Z,ge=true;if(y==="move"){if(S=Se(P),Z=new Date(S.getTime()+ue),e.segments&&e.segments.length>0&&ke!==null){let Te=Math.round($/s),qe=e.segments.map((lt,K)=>{if(K===ke){let te=new Date(lt.startDate),Ee=new Date(lt.endDate);return te.setDate(te.getDate()+Te),Ee.setDate(Ee.getDate()+Te),{startDate:te,endDate:Ee}}return lt}),Ge=qe.flatMap(lt=>[lt.startDate,lt.endDate]),Re=new Date(Math.min(...Ge.map(lt=>lt.getTime()))),at=new Date(Math.max(...Ge.map(lt=>lt.getTime())));d?.({...e,segments:qe},Re,at),Me(t,r);return}}else y==="resize-start"?(S=Se(P),Z=e.endDate,S>Z&&(console.warn("Invalid date range: start date must be before or equal to end date"),ge=false)):y==="resize-end"?(S=e.startDate,Z=Se(P+k),Z<S&&(console.warn("Invalid date range: end date must be after or equal to start date"),ge=false)):ge=false;ge&&S&&Z&&(Z.getTime()<S.getTime()?console.warn("Invalid date range: end date cannot be before start date"):d?.(e,S,Z));}C?.(e.id,0,false),Me(t,r);}},[y,P,k,e,d,H,g,t,r,s,Se,$,ke,Me,C]);useEffect(()=>{if(y==="none")return;let ue=Z=>{sa(Z);},S=()=>{ua();};return window.addEventListener("mousemove",ue),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",ue),window.removeEventListener("mouseup",S);}},[y,sa,ua]);let $e=R&&!we?P:t,Ue=R&&!we?k:r,ia=c.taskClass(e);return jsxs("g",{ref:b,onMouseEnter:()=>!R&&J(true),onMouseLeave:()=>{R||(J(false),ae(null));},onClick:()=>!R&&p?.(e),onDoubleClick:ue=>{R||(ue.stopPropagation(),i?.(e));},onContextMenu:ue=>{ue.preventDefault(),u?.(e,ue);},children:[j&&!R&&!Ne&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:xe,height:ce,fill:Y==="resize-start"?o.accent:"transparent",opacity:Y==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>ae("resize-start"),onMouseDown:ue=>bt(ue,"resize-start")}),jsx("rect",{x:t+xe,y:a,width:r-xe*2,height:ce,fill:Y==="move"?o.accent:"transparent",opacity:Y==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>ae("move"),onMouseDown:ue=>bt(ue,"move")}),jsx("rect",{x:t+r-xe,y:a,width:xe,height:ce,fill:Y==="resize-end"?o.accent:"transparent",opacity:Y==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>ae("resize-end"),onMouseDown:ue=>bt(ue,"resize-end")})]}),j&&!R&&tt&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:ce,fill:Y==="move"?o.accent:"transparent",opacity:Y==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>ae("move"),onMouseDown:ue=>bt(ue,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:ce,fill:Y==="resize-end"?o.accent:"transparent",opacity:Y==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>ae("resize-end"),onMouseDown:ue=>bt(ue,"resize-end")}),j&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+ce-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),R&&!we&&!e.segments&&jsx(motion.rect,{x:P,y:a,width:k,height:ce,rx:We,fill:o.accent,opacity:.5,stroke:o.accent,strokeWidth:2,strokeDasharray:"4 4",initial:{opacity:0},animate:{opacity:.6},transition:{duration:.15},style:{pointerEvents:"none"}}),!e.segments&&jsx(motion.rect,{x:$e,y:a,width:Ue,height:ce,rx:We,fill:re,"data-task-class":ia,initial:{opacity:0,scale:.95},animate:{opacity:R&&!we?.15:e.parentId?.6:j?.9:.8,scale:j&&!R?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:ue=>bt(ue),style:{cursor:R?we?"crosshair":de?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:$e,y:a,width:Ue*(e.progress/100),height:ce,rx:We,fill:re,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((ue,S)=>{let Z=(ue.startDate.getTime()-n.getTime())/864e5*s,Te=(ue.endDate.getTime()-n.getTime())/(1e3*60*60*24)*s-Z+s,qe=R&&y==="move"&&ke===S,Ge=W===S,Re=qe?Z+$:Z;return jsxs("g",{onMouseEnter:()=>!R&&D(S),onMouseLeave:()=>!R&&D(null),children:[jsx(motion.rect,{x:Re,y:a,width:Te,height:ce,rx:We,fill:re,initial:{opacity:0,scale:.95},animate:{opacity:qe||e.parentId?.6:Ge?.9:.8,scale:Ge&&!R?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:at=>{at.stopPropagation(),Pe(S),Je(Z),bt(at,void 0,Z);},style:{cursor:R?we?"crosshair":de?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:Re,y:a,width:Te*(e.progress/100),height:ce,rx:We,fill:re,opacity:1,style:{pointerEvents:"none"}})]},`segment-${S}`)}),ut&&(Fe||Ye)&&!e.segments&&jsxs(Fragment,{children:[Ye&&!Fe&&jsx("rect",{x:$e,y:a,width:Ue,height:ce,rx:We,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),Fe&&jsx("rect",{x:$e,y:a,width:Ue,height:ce,rx:We,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),Ue>60&&!e.segments&&(()=>{let ue=c.taskLabel(e),S=typeof ue=="string"?ue:e.name,Z=S.length>Math.floor(Ue/8)?`${S.substring(0,Math.floor(Ue/8))}...`:S;return jsx("text",{x:$e+12,y:a+ce/2,dominantBaseline:"middle",fill:yt?"rgba(255, 255, 255, 0.6)":"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none",textDecoration:yt?"line-through":"none"},children:Z})})(),Ue>100&&e.progress>0&&e.progress<100&&!R&&!e.segments&&jsxs("text",{x:$e+Ue-12,y:a+ce/2,dominantBaseline:"middle",textAnchor:"end",fill:"rgba(255, 255, 255, 0.9)",fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:[e.progress,"%"]}),e.status&&Ue>80&&!R&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:$e+Ue-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:$e+Ue-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(j||de)&&!we&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:Ne?$e-15:$e-10,y:a-5,width:Ne?25:20,height:ce+10,fill:"transparent",onMouseDown:ue=>bt(ue,"resize-start"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ne?$e-8:$e-3,y:a+6,width:Ne?8:6,height:Ne?ce-12:ce-16,rx:3,fill:y==="resize-start"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:y==="resize-start"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]}),jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:$e+Ue-10,y:a-5,width:Ne?25:20,height:ce+10,fill:"transparent",onMouseDown:ue=>bt(ue,"resize-end"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ne?$e+Ue:$e+Ue-3,y:a+6,width:Ne?8:6,height:Ne?ce-12:ce-16,rx:3,fill:y==="resize-end"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:y==="resize-end"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]})]}),jsx(AnimatePresence,{children:j&&!R&&!e.segments&&jsxs(motion.g,{style:{pointerEvents:"all"},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[jsx(motion.circle,{cx:t+r+8,cy:a+ce/2,r:6,fill:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},exit:{scale:0},transition:{duration:.2,type:"spring",stiffness:400,damping:25},onMouseDown:ue=>{ue.stopPropagation(),bt(ue,"connect");},style:{cursor:"crosshair"}}),jsx("text",{x:t+r+20,y:a+ce/2,dominantBaseline:"middle",fill:o.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:"Link"})]})}),we&&M&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+ce/2,x2:M.x,y2:M.y,stroke:H?o.statusCompleted:o.accent,strokeWidth:H?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:H?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:M.x,cy:M.y,r:H?8:6,fill:H?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),H&&jsx(motion.text,{x:M.x+15,y:M.y,dominantBaseline:"middle",fill:o.statusCompleted,fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",initial:{opacity:0,x:M.x+10},animate:{opacity:1,x:M.x+15},transition:{duration:.2},children:"Connect"})]}),(j||R)&&!we&&!e.segments&&jsx(motion.rect,{x:$e-2,y:a-2,width:Ue+4,height:ce+4,rx:We+2,fill:"none",stroke:R?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:R?.6:.4,initial:{opacity:0},animate:{opacity:R?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),de&&jsxs(Fragment,{children:[jsx("line",{x1:P,y1:0,x2:P,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:P+k,y1:0,x2:P+k,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:j&&!R&&!e.segments&&!T&&(()=>{let Z=a<100,ge=Z?a+ce+13:a-82-13,Te=Z?`M ${$e+Ue/2-6} ${a+ce+3} L ${$e+Ue/2} ${a+ce+13} L ${$e+Ue/2+6} ${a+ce+3}`:`M ${$e+Ue/2-6} ${a-13} L ${$e+Ue/2} ${a-3} L ${$e+Ue/2+6} ${a-13}`,qe=ge+22,Ge=ge+40,Re=ge+55,at=ge+70,lt=Z?ge+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:Z?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:Z?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:Te,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:$e+Ue/2-120,y:ge,width:240,height:82,rx:8,fill:o.bgSecondary,stroke:o.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("text",{x:$e+Ue/2,y:qe,textAnchor:"middle",fill:o.textPrimary,fontSize:"13",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>28?`${e.name.substring(0,28)}...`:e.name}),jsx("text",{x:$e+Ue/2-110,y:Ge,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:$e+Ue/2-70,y:Ge,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:ht(e.startDate)}),jsx("text",{x:$e+Ue/2-110,y:Re,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:$e+Ue/2-70,y:Re,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:ht(e.endDate)}),jsx("text",{x:$e+Ue/2+10,y:Ge,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:$e+Ue/2+65,y:Ge,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Ie()}),jsx("text",{x:$e+Ue/2+10,y:Re,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:$e+Ue/2+65,y:Re,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.progress,"%"]}),e.assignees&&e.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:$e+Ue/2-110,y:at,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:$e+Ue/2-50,y:at,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(K=>K.name).join(", ").substring(0,30),e.assignees.map(K=>K.name).join(", ").length>30?"...":""]})]}),!Z&&jsx("text",{x:$e+Ue/2,y:lt,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:tt?"Left: move \u2022 Right: resize":Ne?"Drag to move \u2022 Hold ALT + drag edge to resize":"Drag edges to resize \u2022 Drag center to move \u2022 Click \u26AB to link"})]})})()})]})}function ic({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:n,showBelow:c}=e,p=82,i=13,u=c?o+n+i:o-p-i,d=c?`M ${r+s/2-6} ${o+n+3} L ${r+s/2} ${o+n+13} L ${r+s/2+6} ${o+n+3}`:`M ${r+s/2-6} ${o-13} L ${r+s/2} ${o-3} L ${r+s/2+6} ${o-13}`,g=u+22,h=u+40,C=u+55,T=u+70,m=w=>w.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),b=()=>{if(!a.startDate||!a.endDate)return "N/A";let w=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${w} day${w!==1?"s":""}`};return jsx(AnimatePresence,{children:jsxs(motion.g,{initial:{opacity:0,y:c?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:c?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:u,width:240,height:p,rx:8,fill:t.bgSecondary,stroke:t.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("text",{x:r+s/2,y:g,textAnchor:"middle",fill:t.textPrimary,fontSize:"13",fontWeight:"600",fontFamily:"Inter, sans-serif",children:a.name.length>28?`${a.name.substring(0,28)}...`:a.name}),jsx("text",{x:r+s/2-110,y:h,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y:h,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?m(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y:C,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y:C,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?m(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y:h,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y:h,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:b()}),jsx("text",{x:r+s/2+10,y:C,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y:C,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.progress,"%"]}),a.assignees&&a.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:r+s/2-110,y:T,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:r+s/2-50,y:T,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.assignees.map(w=>w.name).join(", ").substring(0,30),a.assignees.map(w=>w.name).join(", ").length>30?"...":""]})]})]})})}function En({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,onHoverChange:n}){let[c,p]=useState(false),i=a-e,u=r-t,d=e+i/2,g=`M ${e} ${t} C ${d} ${t}, ${d} ${r}, ${a} ${r}`,h=6,C=Math.atan2(u,i),T=a-h*Math.cos(C-Math.PI/6),m=r-h*Math.sin(C-Math.PI/6),b=a-h*Math.cos(C+Math.PI/6),y=r-h*Math.sin(C+Math.PI/6),l=o.dependency;useEffect(()=>{n&&s&&n(c?{x1:e,y1:t,x2:a,y2:r,onDelete:s}:null);},[c,e,t,a,r,s,n]);let w=!s&&!n;return jsxs("g",{onMouseEnter:()=>!w&&p(true),onMouseLeave:()=>!w&&p(false),style:{pointerEvents:w?"none":"auto"},children:[!w&&jsx("path",{d:g,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx(motion.path,{d:g,fill:"none",stroke:l,strokeWidth:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:c&&n?0:c?1:.8,strokeWidth:c?2.5:2},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2},strokeWidth:{duration:.2}}}),jsx(motion.path,{d:`M ${a} ${r} L ${T} ${m} M ${a} ${r} L ${b} ${y}`,fill:"none",stroke:l,strokeWidth:2,strokeLinecap:"round",initial:{opacity:0,scale:.8},animate:{opacity:c&&n?0:c?1:.8,scale:c?1.1:1,strokeWidth:c?2.5:2},transition:{duration:.2}}),jsx(motion.circle,{cx:a,cy:r,r:3,fill:l,initial:{scale:0},animate:{scale:c&&n?0:c?1.3:1,opacity:c&&n?0:c?1:.8},transition:{scale:{delay:.3,duration:.15},opacity:{duration:.2}}}),c&&s&&!n&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:v=>{v.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:d,cy:(t+r)/2,r:10,fill:o.bgSecondary,stroke:o.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:d-4,y1:(t+r)/2-4,x2:d+4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:d+4,y1:(t+r)/2-4,x2:d-4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})}function Mn({task:e,x:t,y:a,theme:r,onClick:o}){let[s,n]=useState(false),c=16,p=i=>i.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{onMouseEnter:()=>n(true),onMouseLeave:()=>n(false),onClick:()=>o?.(e),style:{cursor:"pointer"},children:[e.isCriticalPath&&jsx(motion.circle,{cx:t,cy:a+16,r:c+4,fill:r.criticalPathLight,initial:{scale:0},animate:{scale:s?1.2:1},transition:{duration:.3}}),jsx(motion.rect,{x:t-c/2,y:a+16-c/2,width:c,height:c,fill:e.isCriticalPath?r.criticalPath:r.milestone,stroke:r.bgGrid,strokeWidth:2,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:0,rotate:0},animate:{scale:s?1.15:1,rotate:45},transition:{duration:.3,type:"spring",stiffness:300,damping:20}}),s&&jsx(motion.rect,{x:t-(c+4)/2,y:a+16-(c+4)/2,width:c+4,height:c+4,fill:"none",stroke:e.isCriticalPath?r.criticalPath:r.milestone,strokeWidth:2,opacity:.5,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:.8,opacity:0},animate:{scale:1,opacity:.5},transition:{duration:.2}}),jsx(AnimatePresence,{children:s&&jsxs(motion.g,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.2},children:[jsx("rect",{x:t-80,y:a-50,width:160,height:44,rx:8,fill:r.bgSecondary,stroke:r.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("path",{d:`M ${t-6} ${a-6} L ${t} ${a+4} L ${t+6} ${a-6}`,fill:r.bgSecondary,stroke:r.border,strokeWidth:1}),jsx("rect",{x:t-70,y:a-38,width:8,height:8,fill:e.isCriticalPath?r.criticalPath:r.milestone,transform:`rotate(45 ${t-66} ${a-34})`}),jsx("text",{x:t-55,y:a-32,fill:r.textPrimary,fontSize:"12",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>18?`${e.name.substring(0,18)}...`:e.name}),jsx("text",{x:t-55,y:a-18,fill:r.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",children:p(e.startDate)}),e.isCriticalPath&&jsxs("g",{children:[jsx("rect",{x:t+10,y:a-40,width:60,height:16,rx:4,fill:r.criticalPathLight}),jsx("text",{x:t+40,y:a-30,textAnchor:"middle",fill:r.criticalPath,fontSize:"9",fontWeight:"700",fontFamily:"Inter, sans-serif",letterSpacing:"0.5",children:"CRITICAL"})]})]})})]})}var me={calculateEndDate:(e,t)=>{let a=new Date(e);return a.setDate(a.getDate()+t),a},calculateDuration:(e,t)=>{let a=t.getTime()-e.getTime();return Math.ceil(a/(1e3*60*60*24))},calculateWorkingDays:(e,t)=>{let a=0,r=new Date(e);for(;r<=t;){let o=r.getDay();o!==0&&o!==6&&a++,r.setDate(r.getDate()+1);}return a},addWorkingDays:(e,t)=>{let a=new Date(e),r=0;for(;r<t;){a.setDate(a.getDate()+1);let o=a.getDay();o!==0&&o!==6&&r++;}return a},isWeekend:e=>{let t=e.getDay();return t===0||t===6},validateDependencies:(e,t,a)=>{let r=new Map,o=i=>{i.forEach(u=>{u.dependencies&&r.set(u.id,u.dependencies),u.subtasks&&o(u.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let n=new Set,c=new Set,p=i=>{if(!n.has(i)){n.add(i),c.add(i);let u=r.get(i)||[];for(let d of u){if(!n.has(d)&&p(d))return true;if(c.has(d))return true}}return c.delete(i),false};return p(a)},flattenTasks:e=>{let t=[],a=r=>{r.forEach(o=>{t.push(o),o.subtasks&&o.subtasks.length>0&&a(o.subtasks);});};return a(e),t},findTaskById:(e,t)=>{for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=me.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=me.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=me.findTaskById(e,o);if(s)a.unshift(s),o=s.parentId;else break}return a},exportToJSON:e=>JSON.stringify(e,null,2),importFromJSON:e=>{try{let t=JSON.parse(e);if(!Array.isArray(t))throw new Error("Invalid JSON: expected an array of tasks");return t.forEach((a,r)=>{if(!a.id||!a.name)throw new Error(`Invalid task at index ${r}: missing required fields (id, name)`)}),t}catch(t){throw new Error(`Failed to import tasks: ${t instanceof Error?t.message:"Unknown error"}`)}},exportToCSV:e=>{let t=me.flattenTasks(e),r=[["ID","Name","Start Date","End Date","Progress","Status","Dependencies"].join(",")];return t.forEach(o=>{let s=[o.id,`"${o.name.replace(/"/g,'""')}"`,o.startDate?o.startDate.toISOString().split("T")[0]:"",o.endDate?o.endDate.toISOString().split("T")[0]:"",o.progress.toString(),o.status||"",o.dependencies?.join(";")||""];r.push(s.join(","));}),r.join(`
112
+ `)},formatDate:e=>{let t=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return `${t}-${a}-${r}`},parseDate:e=>new Date(e),getTaskDateRange:e=>!e.startDate||!e.endDate?null:{start:e.startDate,end:e.endDate},getEarliestStartDate:e=>{let a=me.flattenTasks(e).filter(r=>r.startDate);return a.length===0?null:new Date(Math.min(...a.map(r=>r.startDate.getTime())))},getLatestEndDate:e=>{let a=me.flattenTasks(e).filter(r=>r.endDate);return a.length===0?null:new Date(Math.max(...a.map(r=>r.endDate.getTime())))},tasksOverlap:(e,t)=>!e.startDate||!e.endDate||!t.startDate||!t.endDate?false:e.startDate<=t.endDate&&t.startDate<=e.endDate,getDependentTasks:(e,t)=>me.flattenTasks(e).filter(r=>r.dependencies&&r.dependencies.includes(t)),getDependencyTasks:(e,t)=>{let a=me.findTaskById(e,t);return !a||!a.dependencies?[]:me.flattenTasks(e).filter(o=>a.dependencies.includes(o.id))},filterByStatus:(e,t)=>me.flattenTasks(e).filter(a=>a.status===t),filterByDateRange:(e,t,a)=>me.flattenTasks(e).filter(r=>!r.startDate||!r.endDate?false:r.startDate<=a&&r.endDate>=t),sortByStartDate:(e,t=true)=>[...e].sort((a,r)=>{if(!a.startDate||!r.startDate)return 0;let o=a.startDate.getTime()-r.startDate.getTime();return t?o:-o}),sortByEndDate:(e,t=true)=>[...e].sort((a,r)=>{if(!a.endDate||!r.endDate)return 0;let o=a.endDate.getTime()-r.endDate.getTime();return t?o:-o}),sortByProgress:(e,t=true)=>[...e].sort((a,r)=>{let o=a.progress-r.progress;return t?o:-o}),calculateTotalProgress:e=>{let t=me.flattenTasks(e);if(t.length===0)return 0;let a=t.reduce((r,o)=>r+o.progress,0);return Math.round(a/t.length)},getTaskByPath:(e,t)=>{let a=e,r;for(let o=0;o<t.length;o++){let s=t[o];if(!a||s===void 0||s>=a.length||(r=a[s],!r))return;o<t.length-1&&(a=r.subtasks||[]);}return r},cloneTask:(e,t)=>({...e,id:t||`${e.id}-copy`,subtasks:e.subtasks?.map(a=>me.cloneTask(a))}),exportToPDF:async(e,t="gantt-chart.pdf")=>{try{if(!e||e.length===0){alert("No tasks available to export to PDF");return}let{jsPDF:a}=await import('jspdf'),{default:r}=await import('jspdf-autotable'),o=new a,s=me.flattenTasks(e);if(s.length===0){alert("No tasks found to export");return}o.setFontSize(16),o.text("Gantt Chart - Task List",14,20);let n=[["Task Name","Start Date","End Date","Duration","Progress","Status"]],c=s.map(p=>{let i=p.startDate&&p.endDate?me.calculateDuration(p.startDate,p.endDate):0;return [p.name,p.startDate?me.formatDate(p.startDate):"N/A",p.endDate?me.formatDate(p.endDate):"N/A",i>0?`${i} days`:"N/A",`${p.progress}%`,p.status||"N/A"]});r(o,{head:n,body:c,startY:30,styles:{fontSize:9,cellPadding:3},headStyles:{fillColor:[66,139,202],textColor:255,fontStyle:"bold"},alternateRowStyles:{fillColor:[245,245,245]},columnStyles:{0:{cellWidth:60},1:{cellWidth:30},2:{cellWidth:30},3:{cellWidth:25},4:{cellWidth:20},5:{cellWidth:25}}}),o.save(t);}catch(a){throw a}},exportToExcel:async(e,t="gantt-chart.xlsx")=>{let a=await import('xlsx'),o=me.flattenTasks(e).map(p=>{let i=p.startDate&&p.endDate?me.calculateDuration(p.startDate,p.endDate):0;return {"Task ID":p.id,"Task Name":p.name,"Start Date":p.startDate?me.formatDate(p.startDate):"","End Date":p.endDate?me.formatDate(p.endDate):"","Duration (days)":i>0?i:"","Progress (%)":p.progress,Status:p.status||"",Assignees:p.assignees?.map(u=>u.name).join(", ")||"",Dependencies:p.dependencies?.join(", ")||"","Is Milestone":p.isMilestone?"Yes":"No","Parent ID":p.parentId||"",Level:p.level||0}}),s=a.utils.json_to_sheet(o),n=[{wch:15},{wch:40},{wch:12},{wch:12},{wch:15},{wch:12},{wch:15},{wch:30},{wch:20},{wch:12},{wch:15},{wch:8}];s["!cols"]=n;let c=a.utils.book_new();a.utils.book_append_sheet(c,s,"Gantt Tasks"),a.writeFile(c,t);},exportToMSProject:(e,t="Gantt Project",a="project.xml")=>{let r=me.flattenTasks(e),o=new Map;r.forEach((g,h)=>{o.set(g.id,h+1);});let s=g=>g.toISOString().replace("Z",""),n=me.getEarliestStartDate(e)||new Date,c=me.getLatestEndDate(e)||new Date,p=r.map((g,h)=>{let C=o.get(g.id),T=g.startDate&&g.endDate?me.calculateDuration(g.startDate,g.endDate):0,m=(g.dependencies||[]).filter(b=>o.has(b)).map(b=>`
113
113
  <PredecessorLink>
114
114
  <PredecessorUID>${o.get(b)}</PredecessorUID>
115
115
  <Type>1</Type>
@@ -119,13 +119,13 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
119
119
  </PredecessorLink>`).join("");return `
120
120
  <Task>
121
121
  <UID>${C}</UID>
122
- <ID>${f+1}</ID>
122
+ <ID>${h+1}</ID>
123
123
  <Name>${g.name.replace(/[<>&'"]/g,b=>({"<":"&lt;",">":"&gt;","&":"&amp;","'":"&apos;",'"':"&quot;"})[b]||b)}</Name>
124
124
  <Type>0</Type>
125
125
  <IsNull>0</IsNull>
126
126
  <CreateDate>${s(new Date)}</CreateDate>
127
- <WBS>${f+1}</WBS>
128
- <OutlineNumber>${f+1}</OutlineNumber>
127
+ <WBS>${h+1}</WBS>
128
+ <OutlineNumber>${h+1}</OutlineNumber>
129
129
  <OutlineLevel>${g.level||0}</OutlineLevel>
130
130
  <Priority>500</Priority>
131
131
  <Start>${g.startDate?s(g.startDate):""}</Start>
@@ -339,9 +339,9 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
339
339
  </Calendars>
340
340
  <Tasks>${p}
341
341
  </Tasks>
342
- </Project>`,u=new Blob([i],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(u),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=pe.flattenTasks(e),a=t.filter(i=>i.startDate&&i.endDate);if(a.length===0)return [];let r=new Map,o=i=>{if(r.has(i.id))return;let u=i.startDate&&i.endDate?pe.calculateDuration(i.startDate,i.endDate):0,d=0;if(i.dependencies&&i.dependencies.length>0)for(let f of i.dependencies){let C=t.find(T=>T.id===f);if(C){o(C);let T=r.get(f)?.ef||0;d=Math.max(d,T);}}let g=d+u;r.set(i.id,{es:d,ef:g});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(i=>i.ef)),n=new Map,c=i=>{if(n.has(i.id))return;let u=i.startDate&&i.endDate?pe.calculateDuration(i.startDate,i.endDate):0,d=t.filter(C=>C.dependencies&&C.dependencies.includes(i.id)),g=s;if(d.length>0)for(let C of d){c(C);let T=n.get(C.id)?.ls||0;g=Math.min(g,T);}let f=g-u;n.set(i.id,{ls:f,lf:g});};a.forEach(c);let p=[];for(let i of a){let u=r.get(i.id),d=n.get(i.id);if(u&&d){let g=d.ls-u.es;Math.abs(g)<.01&&p.push(i.id);}}return p},calculateSlack:(e,t)=>{let a=pe.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(pe.calculateCriticalPath(e).includes(t))return 0;let o=pe.getDependentTasks(e,t);if(o.length===0){let c=pe.getLatestEndDate(e);if(!c)return null;let p=pe.calculateDuration(a.endDate,c);return Math.max(0,p)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,p)=>c-p)[0];if(!s)return null;let n=pe.calculateDuration(a.endDate,new Date(s));return Math.max(0,n)},isOnCriticalPath:(e,t)=>pe.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=pe.findTaskById(e,t);if(!r||!r.endDate)return e;let o=pe.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let n of o){if(!n.startDate||!n.endDate)continue;let c=pe.calculateDuration(n.startDate,n.endDate),p;a!==void 0?(p=new Date(n.startDate),p.setDate(p.getDate()+a)):(p=new Date(r.endDate),p.setDate(p.getDate()+1));let i=pe.calculateEndDate(p,c),u=d=>d.map(g=>g.id===n.id?{...g,startDate:p,endDate:i}:g.subtasks?{...g,subtasks:u(g.subtasks)}:g);s=u(s),s=pe.autoScheduleDependents(s,n.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,n,c)=>{if(a===0)return [];let p=[],i=o.getTime(),u=1e3*60*60*24,d=pe.findTaskById(e,t);if(!d||!d.endDate)return [];let g=(f,C,T=new Set)=>{if(T.has(f))return;T.add(f);let m=pe.getDependentTasks(e,f);for(let b of m){if(!b.startDate||!b.endDate)continue;let y=r.findIndex(N=>N.id===b.id);if(y===-1)continue;let l=b.startDate.getTime(),v=(b.endDate.getTime()-l)/u,x=(l-i)/u*s,k=x+C*s,O=Math.max(v*s,s),A=c+y*n+12;p.push({taskId:b.id,taskName:b.name,originalX:x,previewX:k,width:O,y:A,rowIndex:y,daysDelta:C,color:b.color}),g(b.id,C,T);}};return g(t,a),p},splitTask:(e,t,a,r=3)=>{let o=pe.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let n=new Date(a);n.setDate(n.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let p=[{startDate:new Date(o.startDate),endDate:s},{startDate:n,endDate:c}],i=u=>u.map(d=>d.id===o.id?{...d,endDate:c,segments:p}:d.subtasks?{...d,subtasks:i(d.subtasks)}:d);return i(e)}};function Pn({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:n,templates:c,onTaskClick:p,onTaskDblClick:i,onTaskContextMenu:u,onTaskDateChange:d,onDependencyCreate:g,onDependencyDelete:f}){let[T,m]=useState([]),[b,y]=useState(null),[l,w]=useState(null),v=useCallback($=>{y($);},[]),S=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),x=r==="day"?60:r==="week"?20:8,k=S*x*n,O=$=>{let B=new Date(Date.UTC($.getFullYear(),$.getMonth(),$.getDate())),W=B.getUTCDay()||7;B.setUTCDate(B.getUTCDate()+4-W);let D=new Date(Date.UTC(B.getUTCFullYear(),0,1));return Math.ceil(((B.getTime()-D.getTime())/864e5+1)/7)},A=$=>{let B=$.getDay();return B===0||B===6},N=useCallback($=>{let B=Math.round($/(x*n)),W=new Date(o);return W.setDate(W.getDate()+B),W},[o,x,n]),H=useCallback(($,B)=>{if(B.startDate&&B.endDate)return;let W=$.currentTarget.ownerSVGElement;if(!W)return;let D=W.createSVGPoint();D.x=$.clientX,D.y=$.clientY;let Y=D.matrixTransform(W.getScreenCTM()?.inverse()),J=N(Y.x),R=new Date(J);R.setDate(R.getDate()+1),d?.(B,J,R);},[N,d]),L=useMemo(()=>{let $=Y=>Y.map(J=>{if(J.subtasks&&J.subtasks.length>0){let R=$(J.subtasks),ce=R.filter(we=>we.startDate&&we.endDate);if(ce.length>0){let we=ce.map(Le=>Le.startDate.getTime()),Ie=ce.map(Le=>Le.endDate.getTime()),me=new Date(Math.min(...we)),He=new Date(Math.max(...Ie));return {...J,subtasks:R,startDate:me,endDate:He}}return {...J,subtasks:R}}return J}),B=(Y,J=[])=>{for(let R of Y)J.push(R),R.subtasks&&R.subtasks.length>0&&(R.isExpanded===void 0||R.isExpanded)&&B(R.subtasks,J);return J},W=$(e);return B(W)},[e]),q=useCallback($=>{if(!$.startDate||!$.endDate)return {x:0,width:0};let B=$.startDate.getTime(),W=$.endDate.getTime(),D=o.getTime(),Y=(B-D)/(1e3*60*60*24),J=(W-B)/(1e3*60*60*24),R=Y*x*n,ce=Math.max(x*n,40),we=Math.max(J*x*n,ce);return {x:R,width:we}},[o,x,n]),ae=useMemo(()=>L.filter($=>$.startDate&&$.endDate).map($=>{let{x:B,width:W}=q($),Y=L.findIndex(J=>J.id===$.id)*a+12;return {id:$.id,x:B,y:Y,width:W,height:32}}),[L,q]),ke=useCallback(($,B,W)=>{if(!W||B===0){m([]);return}let D=pe.calculateCascadePreview(e,$,B,L,o,x*n,a,48);m(D);},[e,L,o,x,n,a,48]),Fe=useMemo(()=>{let $=[],B=new Date(o);for(;B<=s;){let Y=(B.getTime()-o.getTime())/864e5*x*n;if(r==="day")$.push({date:new Date(B),label:B.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:Y}),B.setDate(B.getDate()+1);else if(r==="week"){let J=O(B);$.push({date:new Date(B),label:`Week ${J}`,x:Y}),B.setDate(B.getDate()+7);}else $.push({date:new Date(B),label:B.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:Y}),B.setMonth(B.getMonth()+1);}return $},[o,s,r,x,n]),Ve=useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*x*n,[o,x,n]),Je=Math.max(L.length*a,552);return jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary,overflow:"visible"},children:[jsx("div",{style:{position:"sticky",top:0,zIndex:10,backgroundColor:t.bgGrid,flexShrink:0,height:"48px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:jsxs("svg",{width:Math.max(k,1e3),height:47,style:{display:"block"},children:[jsx("rect",{x:0,y:0,width:Math.max(k,1e3),height:48,fill:t.bgGrid}),Fe.map(($,B)=>jsxs("g",{children:[B>0&&jsx("line",{x1:$.x,y1:0,x2:$.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsx("text",{x:$.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:$.label})]},`header-${B}`)),Ve>=0&&Ve<=k&&jsx("circle",{cx:Ve,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxs("svg",{width:Math.max(k,1e3),height:Je,style:{display:"block",flexShrink:0,overflow:"visible"},children:[jsxs("defs",{children:[jsx("filter",{id:"shadow",children:jsx("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2",floodOpacity:"0.1"})}),jsx("pattern",{id:"diagonal-stripes",width:"8",height:"8",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:jsx("line",{x1:"0",y1:"0",x2:"0",y2:"8",stroke:t.border,strokeWidth:"2"})})]}),jsx("rect",{x:0,y:0,width:Math.max(k,1e3),height:Je,fill:t.bgPrimary}),Fe.map(($,B)=>{let W=Fe[B+1]?.x||k,D=A($.date);return jsxs("g",{children:[D&&jsx("rect",{x:$.x,y:0,width:W-$.x,height:L.length*a,fill:t.bgWeekend,opacity:1}),B>0&&jsx("line",{x1:$.x,y1:0,x2:$.x,y2:L.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},B)}),L.map(($,B)=>{let W=$.startDate&&$.endDate;return jsxs("g",{children:[jsx("rect",{x:0,y:B*a,width:k,height:a,fill:B%2===0?t.bgPrimary:t.bgGrid,opacity:1,style:{pointerEvents:"none"}},`row-${$.id}`),!W&&jsxs(Fragment,{children:[jsx("rect",{x:0,y:B*a,width:k,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:D=>H(D,$),onMouseEnter:D=>{D.currentTarget.setAttribute("fill",t.accentLight),D.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:D=>{D.currentTarget.setAttribute("fill","transparent"),D.currentTarget.setAttribute("opacity","1");}},`clickable-${$.id}`),jsx("text",{x:Ve>0?Ve:100,y:B*a+a/2,fill:t.textTertiary,fontSize:"12",fontFamily:"Inter, sans-serif",fontStyle:"italic",dominantBaseline:"middle",opacity:.4,style:{pointerEvents:"none",userSelect:"none"},children:"Click to set dates..."},`placeholder-${$.id}`)]})]},`row-group-${$.id}`)}),L.map(($,B)=>!$.dependencies||$.dependencies.length===0||!$.startDate||!$.endDate?null:$.dependencies.map(W=>{let D=L.find(ce=>ce.id===W);if(!D||!D.startDate||!D.endDate)return null;let Y=L.findIndex(ce=>ce.id===W),J=q(D),R=q($);return jsx(Nn,{x1:J.x+J.width,y1:Y*a+a/2,x2:R.x,y2:B*a+a/2,theme:t},`dep-${W}-${$.id}`)})),L.map(($,B)=>{if(!$.startDate||!$.endDate)return null;let{x:W,width:D}=q($),Y=B*a+12,J=$.subtasks&&$.subtasks.length>0&&!$.isMilestone;return $.isMilestone?jsx(Sn,{task:$,x:W+D/2,y:Y+16,theme:t,onClick:p},$.id):J?jsxs("g",{onClick:()=>p?.($),onContextMenu:R=>{R.preventDefault(),R.stopPropagation(),u?.($,R);},style:{cursor:"default"},children:[jsx("rect",{x:W,y:Y,width:D,height:32,fill:t.primary,opacity:.25,rx:6}),jsx("line",{x1:W,y1:Y,x2:W+D,y2:Y,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W,y1:Y,x2:W,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W+D,y1:Y,x2:W+D,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W,y1:Y+32,x2:W+D,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),D>60&&jsx("text",{x:W+12,y:Y+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:$.name})]},$.id):jsx(wn,{task:$,x:W,y:Y,width:D,theme:t,dayWidth:x*n,startDate:o,templates:c,onClick:p,onDoubleClick:i,onContextMenu:u,onDateChange:d,onDependencyCreate:g,allTaskPositions:ae,onDragMove:ke,onHoverChange:v},$.id)}),L.map(($,B)=>!$.dependencies||$.dependencies.length===0||!$.startDate||!$.endDate?null:$.dependencies.map(W=>{let D=L.find(ne=>ne.id===W);if(!D||!D.startDate||!D.endDate)return null;let Y=L.findIndex(ne=>ne.id===W),J=q(D),R=q($),ce=J.x+J.width,we=Y*a+a/2,Ie=R.x,me=B*a+a/2,He=Ie-ce,Le=ce+He/2,Ye=ne=>{let xe=1-ne,Ne=xe*xe,at=Ne*xe,ft=ne*ne,Be=ft*ne,he=at*ce+3*Ne*ne*Le+3*xe*ft*Le+Be*Ie,Pe=at*we+3*Ne*ne*we+3*xe*ft*me+Be*me;return {x:he,y:Pe}},pt=20,bt=[];for(let ne=0;ne<=pt;ne++){let xe=.1+ne/pt*.8;bt.push(Ye(xe));}let it=bt[0],z=`M ${it.x} ${it.y} `+bt.slice(1).map(ne=>`L ${ne.x} ${ne.y}`).join(" ");return l&&l.x1===ce&&l.y1===we&&l.x2===Ie&&l.y2===me?null:jsx("path",{d:z,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:()=>{w({x1:ce,y1:we,x2:Ie,y2:me,onDelete:()=>f?.($.id,W)});}},`dep-hover-${W}-${$.id}`)})),T.map($=>jsxs("g",{style:{pointerEvents:"none"},children:[jsx("rect",{x:$.previewX,y:$.y-48,width:$.width,height:32,rx:8,fill:$.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs($.daysDelta)>0&&jsx("text",{x:$.previewX+$.width/2,y:$.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:$.daysDelta>0?`+${$.daysDelta}d`:`${$.daysDelta}d`})]},`cascade-preview-${$.taskId}`)),l&&(()=>{let{x1:$,y1:B,x2:W,y2:D,onDelete:Y}=l,J=W-$,R=D-B,ce=$+J/2,we=(B+D)/2,Ie=`M ${$} ${B} C ${ce} ${B}, ${ce} ${D}, ${W} ${D}`,me=6,He=Math.atan2(R,J),Le=W-me*Math.cos(He-Math.PI/6),Ye=D-me*Math.sin(He-Math.PI/6),pt=W-me*Math.cos(He+Math.PI/6),bt=D-me*Math.sin(He+Math.PI/6),it=t.dependency,z="#f87171";return jsxs("g",{onMouseLeave:()=>w(null),children:[jsx("path",{d:Ie,fill:"none",stroke:"transparent",strokeWidth:50,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx("circle",{cx:ce,cy:we,r:25,fill:"transparent",style:{cursor:"pointer"}}),jsx("path",{d:Ie,fill:"none",stroke:it,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsx("path",{d:Ie,fill:"none",stroke:it,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("path",{d:`M ${W} ${D} L ${Le} ${Ye} M ${W} ${D} L ${pt} ${bt}`,fill:"none",stroke:it,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("circle",{cx:W,cy:D,r:4,fill:it,opacity:.9,style:{pointerEvents:"none"}}),jsxs(motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:ne=>{ne.stopPropagation(),w(null),Y();},style:{cursor:"pointer"},children:[jsx("circle",{cx:ce,cy:we,r:9,fill:"rgba(248, 113, 113, 0.15)",stroke:z,strokeWidth:1.5,style:{transition:"all 0.15s ease"}}),jsx("line",{x1:ce-3,y1:we-3,x2:ce+3,y2:we+3,stroke:z,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:ce+3,y1:we-3,x2:ce-3,y2:we+3,stroke:z,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),Ve>=0&&Ve<=k&&jsx("line",{x1:Ve,y1:0,x2:Ve,y2:Je,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),b&&jsx(ic,{tooltipData:b,theme:t})]})]})}var o0=['Move "Task Name" to next Monday','Extend "Task Name" by 3 days','Rename "Old Name" to "New Name"','Set "Task Name" progress to 50%','Link "Task A" to "Task B"','Create a new task called "New Task"','Delete "Task Name"','Assign John to "Task Name"'],cc=()=>jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707"}),jsx("circle",{cx:"12",cy:"12",r:"4"})]}),n0=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13"})}),s0=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M18 6L6 18M6 6L18 18"})}),i0=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M5 12h14"})}),l0=()=>jsx("div",{className:"flex gap-1 items-center",children:[0,1,2].map(e=>jsx(motion.div,{className:"w-2 h-2 rounded-full bg-current",animate:{scale:[1,1.2,1],opacity:[.5,1,.5]},transition:{duration:.8,repeat:1/0,delay:e*.15}},e))});function Mn({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:n,onDependencyCreate:c,onDependencyDelete:p}){let[i,u]=useState(false),[d,g]=useState(false),[f,C]=useState([]),[T,m]=useState(""),[b,y]=useState(false),[l,w]=useState(true),v=useRef(null),S=useRef(null),x=useRef(null),{enabled:k=true,placeholder:O='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:A="bottom-right",onCommand:N,suggestions:H=o0,maxHistory:L=50,persistHistory:q}=a,ae=q?.storageKey||"gantt-ai-history",ke=q?.maxMessages??5;useEffect(()=>{if(q?.enabled)try{let W=localStorage.getItem(ae);if(W){let Y=JSON.parse(W).map(J=>({...J,timestamp:new Date(J.timestamp)}));C(Y.slice(-ke));}}catch(W){console.warn("[GanttAIAssistant] Failed to load persisted history:",W);}},[q?.enabled,ae,ke]),useEffect(()=>{if(q?.enabled&&f.length>0)try{let W=f.filter(D=>!D.isLoading).slice(-ke);localStorage.setItem(ae,JSON.stringify(W));}catch(W){console.warn("[GanttAIAssistant] Failed to persist history:",W);}},[f,q?.enabled,ae,ke]),useEffect(()=>{S.current&&S.current.scrollIntoView({behavior:"smooth"});},[f]),useEffect(()=>{i&&!d&&v.current&&setTimeout(()=>v.current?.focus(),100);},[i,d]);let Fe=useCallback(W=>{if(W.success)switch(W.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":W.taskId&&W.updates&&o?.(W.taskId,W.updates);break;case "create_task":W.newTask&&s?.(W.newTask);break;case "delete_task":W.taskId&&n?.(W.taskId);break;case "link_tasks":W.dependencyFrom&&W.dependencyTo&&c?.(W.dependencyFrom,W.dependencyTo);break;case "unlink_tasks":W.taskId&&W.dependencyFrom&&p?.(W.taskId,W.dependencyFrom);break}},[o,s,n,c,p]),Ve=useCallback(async W=>{if(!W.trim()||b)return;let D={id:`user-${Date.now()}`,role:"user",content:W,timestamp:new Date};C(J=>[...J.slice(-(L-1)),D]),m(""),w(false),y(true);let Y={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};C(J=>[...J,Y]);try{if(N){let J=await N(W,e);C(R=>{let ce=R.filter(Ie=>!Ie.isLoading),we={id:`assistant-${Date.now()}`,role:"assistant",content:J.message,timestamp:new Date,command:J};return [...ce,we]}),Fe(J);}else C(J=>[...J.filter(ce=>!ce.isLoading),{id:`assistant-${Date.now()}`,role:"assistant",content:"AI handler not configured. Please provide an onCommand handler in the aiAssistant config.",timestamp:new Date}]);}catch(J){C(R=>[...R.filter(we=>!we.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${J instanceof Error?J.message:"Unknown error"}`,timestamp:new Date}]);}finally{y(false);}},[b,L,N,e,Fe]),Je=W=>{W.preventDefault(),Ve(T);},$=W=>{m(W),v.current?.focus();};if(useEffect(()=>{let W=D=>{(D.metaKey||D.ctrlKey)&&D.key==="k"&&(D.preventDefault(),u(Y=>!Y),i||g(false)),D.key==="Escape"&&i&&u(false);};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[i]),useEffect(()=>{if(!i)return;let W=Y=>{let J=Y.target;x.current&&!x.current.contains(J)&&u(false);},D=setTimeout(()=>{document.addEventListener("mousedown",W);},100);return ()=>{clearTimeout(D),document.removeEventListener("mousedown",W);}},[i]),!k)return null;let B={"bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-right":"top-4 right-4","top-left":"top-4 left-4"};return jsxs(ut,{children:[jsx(AnimatePresence,{children:!i&&jsxs(motion.button,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},className:`fixed ${B[A]} z-[99999] flex items-center gap-2 px-4 py-3 rounded-full shadow-lg transition-colors`,style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"white",boxShadow:"0 4px 20px rgba(59, 130, 246, 0.4)"},onClick:()=>u(true),children:[jsx(cc,{}),jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),jsx("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono rounded bg-white/20",children:"\u2318K"})]})}),jsx(AnimatePresence,{children:i&&jsxs(motion.div,{ref:x,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 ${B[A]} z-[99999] w-96 rounded-2xl overflow-hidden shadow-2xl flex flex-col`,style:{background:t.bgPrimary,border:`1px solid ${t.border}`,boxShadow:`0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px ${t.border}`},children:[jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},children:[jsxs("div",{className:"flex items-center gap-2 text-white",children:[jsx(cc,{}),jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>g(W=>!W),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(i0,{})}),jsx("button",{onClick:()=>u(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(s0,{})})]})]}),jsx(AnimatePresence,{children:!d&&jsxs(motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"flex flex-col flex-1 min-h-0",children:[jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[f.length===0&&l&&jsxs("div",{className:"space-y-3",children:[jsx("p",{className:"text-sm text-center",style:{color:t.textSecondary},children:"Try asking me to edit your Gantt chart:"}),jsx("div",{className:"flex flex-wrap gap-2",children:H.slice(0,4).map((W,D)=>jsx("button",{onClick:()=>$(W),className:"text-xs px-3 py-1.5 rounded-full transition-colors",style:{background:t.bgSecondary,color:t.textSecondary,border:`1px solid ${t.border}`},children:W.length>30?W.slice(0,30)+"...":W},D))})]}),f.map(W=>jsx(motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${W.role==="user"?"justify-end":"justify-start"}`,children:jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${W.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:W.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:W.role==="user"?"white":t.textPrimary},children:[W.isLoading?jsx(l0,{}):jsx("p",{className:"text-sm whitespace-pre-wrap",children:W.content}),W.command&&jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:W.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:W.command.success?"#10B981":"#EF4444"},children:[W.command.success?"\u2713":"\u2717",jsx("span",{className:"capitalize",children:W.command.type.replace(/_/g," ")})]})]})},W.id)),jsx("div",{ref:S})]}),jsxs("form",{onSubmit:Je,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsx("input",{ref:v,type:"text",value:T,onChange:W=>m(W.target.value),placeholder:O,disabled:b,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsx("button",{type:"submit",disabled:!T.trim()||b,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:T.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:T.trim()?"white":t.textSecondary},children:jsx(n0,{})})]}),jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function mc(e,t=50){let[a,r]=useState({past:[],present:e,future:[]}),o=useRef(false),s=useCallback((i,u=true)=>{r(d=>{let g=typeof i=="function"?i(d.present):i;if(o.current)return {...d,present:g};if(!u)return {...d,present:g};let f=[...d.past,d.present];return f.length>t&&f.shift(),{past:f,present:g,future:[]}});},[t]),n=useCallback(()=>{r(i=>{if(i.past.length===0)return i;let u=i.past[i.past.length-1],d=i.past.slice(0,i.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:u,future:[i.present,...i.future]}});},[]),c=useCallback(()=>{r(i=>{if(i.future.length===0)return i;let u=i.future[0],d=i.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...i.past,i.present],present:u,future:d}});},[]),p=useCallback(()=>{r(i=>({past:[],present:i.present,future:[]}));},[]);return {state:a.present,setState:s,undo:n,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function pc({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){useEffect(()=>{if(!o)return;let s=n=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,p=c?n.metaKey:n.ctrlKey;if(p&&n.key==="z"&&!n.shiftKey&&a){n.preventDefault(),e();return}if(r){if(!c&&p&&n.key==="y"){n.preventDefault(),t();return}if(c&&p&&n.shiftKey&&n.key==="z"){n.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var p0={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${pe.formatDate(e.startDate)} - ${pe.formatDate(e.endDate)}`);let a=pe.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=>pe.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function uc(e){return {...p0,...e}}var v0=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},hc=forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:n="week",rowDensity:c="comfortable",showThemeSelector:p=true,showExportButton:i=true,availableUsers:u=[],templates:d,enableAutoCriticalPath:g=true,persistExpandedState:f,aiAssistant:C,locale:T="en",customTranslations:m,showCreateTaskButton:b=false,createTaskLabel:y,onCreateTask:l,onThemeChange:w,onTaskClick:v,onTaskDblClick:S,onTaskContextMenu:x,onTaskUpdate:k,onProgressChange:O,onTaskEdit:A,onTaskAddSubtask:N,onTaskMarkIncomplete:H,onTaskSetInProgress:L,onDependencyCreate:q,onDependencyDelete:ae,onBeforeTaskAdd:ke,onAfterTaskAdd:Fe,onBeforeTaskUpdate:Ve,onAfterTaskUpdate:Je,onBeforeTaskDelete:$,onAfterTaskDelete:B}=a,D=useContext(fn)?.theme,[Y,J]=useState(D||s||"dark"),[R,ce]=useState(n),[we,Ie]=useState(c),[me,He]=useState(1),[Le,Ye]=useState(0),[pt,bt]=useState(false),[it,z]=useState(null),[oe,ne]=useState({isOpen:false,x:0,y:0,task:null}),[xe,Ne]=useState(null),[at,ft]=useState(null);useEffect(()=>{D&&D!==Y&&J(D);},[D]),useEffect(()=>{s&&s!==Y&&J(s);},[s]);let Be=useCallback(F=>{J(F),w?.(F);},[w]),{state:he,setState:Pe,undo:Mt,redo:ht,canUndo:oa,canRedo:ma,clearHistory:Ue}=mc(t,50),Oe=useCallback(()=>f?typeof f=="string"?f:"gantt-expanded-tasks":null,[f]),na=useRef(new Map),ge=useRef(false);if(!ge.current&&f){ge.current=true;let F=typeof f=="string"?f:"gantt-expanded-tasks";try{let I=localStorage.getItem(F);if(I){let _=JSON.parse(I);Array.isArray(_)&&(na.current=new Map(_));}}catch(I){console.warn("[GanttBoard] Error loading expanded state from localStorage:",I);}}let E=useCallback(()=>{let F=Oe();if(F)try{let I=Array.from(na.current.entries());localStorage.setItem(F,JSON.stringify(I));}catch(I){console.warn("[GanttBoard] Error saving expanded state to localStorage:",I);}},[Oe]);useEffect(()=>{let F=I=>I.map(_=>{let ie=na.current.get(_.id),fe=ie!==void 0?{..._,isExpanded:ie}:_;return fe.subtasks?.length?{...fe,subtasks:F(fe.subtasks)}:fe});na.current.size>0?Pe(F(t)):Pe(t);},[t,Pe]);let Z=useRef(t),be=useRef(true);useEffect(()=>{if(be.current){be.current=false,Z.current=he;return}if(!r)return;let F=JSON.stringify(Z.current),I=JSON.stringify(he);F!==I&&(Z.current=he,r(he));},[he,r]);let Te=useMemo(()=>qs(T,m),[T,m]),qe=useCallback(F=>[{id:"name",label:F.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:F.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:F.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:F.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:F.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:F.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:F.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:F.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[We,Ee]=useState(()=>qe(Te));useEffect(()=>{Ee(F=>F.map(I=>({...I,label:Te.columns[I.id==="name"?"taskName":I.id]||I.label})));},[Te]);let rt=useMemo(()=>We.filter(I=>I.visible).reduce((I,_)=>I+_.width,0),[We]),st=useRef(We.filter(F=>F.visible).map(F=>F.id).join(","));useEffect(()=>{let F=We.filter(ie=>ie.visible),I=F.map(ie=>ie.id).join(","),_=st.current;if(I!==_){let ie=F.some(Se=>Se.id!=="name"),fe=_.includes(",");ie?!fe&&ie&&z(null):z(null),st.current=I;}},[We]);let V=60,re=.6,Me=useMemo(()=>{let I=rt+V,_=typeof window<"u"?window.innerWidth*re:800,ie=Math.max(I,_);return it!==null?Math.max(200,Math.min(it,ie)):Math.max(200,I)},[it,rt]),Xe=useRef(null),$e=useRef(null),G=useRef(null),ee=useMemo(()=>Id(Y),[Y]),Ae=useMemo(()=>({theme:ee,themeName:Y}),[ee,Y]),M=useMemo(()=>uc(d),[d]),te=useMemo(()=>{if(!g)return he;let F=pe.calculateCriticalPath(he),I=_=>_.map(ie=>({...ie,isCriticalPath:F.includes(ie.id),subtasks:ie.subtasks?I(ie.subtasks):void 0}));return I(he)},[he,g]),Re=v0(we);pc({undo:Mt,redo:ht,canUndo:oa,canRedo:ma,enabled:true}),useImperativeHandle(o,()=>({getTask:F=>pe.findTaskById(he,F),addTask:(F,I)=>{Pe(_=>{if(!I)return [..._,{...F,level:0}];let ie=fe=>fe.map(Se=>Se.id===I?{...Se,subtasks:[...Se.subtasks||[],{...F,parentId:I,level:(Se.level||0)+1}],isExpanded:true}:Se.subtasks?{...Se,subtasks:ie(Se.subtasks)}:Se);return ie(_)});},updateTask:(F,I)=>{Pe(_=>{let ie=fe=>fe.map(Se=>Se.id===F?{...Se,...I}:Se.subtasks?{...Se,subtasks:ie(Se.subtasks)}:Se);return ie(_)});},deleteTask:F=>{Pe(I=>{let _=ie=>ie.filter(fe=>fe.id===F?false:(fe.subtasks&&(fe.subtasks=_(fe.subtasks)),true));return _(I)});},deleteTasks:F=>{Pe(I=>ai(I,F));},duplicateTask:F=>{Pe(I=>ri(I,[F]));},splitTask:(F,I,_=3)=>{Pe(ie=>pe.splitTask(ie,F,I,_));},calculateEndDate:pe.calculateEndDate,calculateDuration:pe.calculateDuration,validateDependency:(F,I)=>!pe.validateDependencies(he,F,I),getAllTasks:()=>pe.flattenTasks(he),getTasksByStatus:F=>pe.flattenTasks(he).filter(I=>I.status===F),getTasksByParent:F=>F?pe.findTaskById(he,F)?.subtasks||[]:he.filter(_=>!_.parentId),getCriticalPath:()=>pe.flattenTasks(he).filter(F=>F.isCriticalPath),indentTask:F=>{Pe(I=>Qs(I,[F]));},outdentTask:F=>{Pe(I=>ei(I,[F]));},moveTask:(F,I)=>{Pe(_=>ti(_,[F],I));},createSubtask:async F=>{let{tasks:I,newTask:_}=si(he,F);if(ke){let ie=ke({..._,parentId:F});if((ie instanceof Promise?await ie:ie)===false)return}Pe(I),Fe&&Fe({..._,parentId:F});},scrollToTask:F=>{let _=pe.flattenTasks(he).findIndex(ie=>ie.id===F);if(_!==-1&&Xe.current){let ie=_*Re;Xe.current.scrollTo({top:ie,behavior:"smooth"}),$e.current&&$e.current.scrollTo({top:ie,behavior:"smooth"});}},highlightTask:(F,I=2e3)=>{},expandTask:F=>{Pe(I=>{let _=ie=>ie.map(fe=>fe.id===F?{...fe,isExpanded:true}:fe.subtasks?{...fe,subtasks:_(fe.subtasks)}:fe);return _(I)});},collapseTask:F=>{Pe(I=>{let _=ie=>ie.map(fe=>fe.id===F?{...fe,isExpanded:false}:fe.subtasks?{...fe,subtasks:_(fe.subtasks)}:fe);return _(I)});},expandAll:()=>{Pe(F=>{let I=_=>_.map(ie=>({...ie,isExpanded:true,subtasks:ie.subtasks?I(ie.subtasks):void 0}));return I(F)});},collapseAll:()=>{Pe(F=>{let I=_=>_.map(ie=>({...ie,isExpanded:false,subtasks:ie.subtasks?I(ie.subtasks):void 0}));return I(F)});},undo:Mt,redo:ht,canUndo:()=>oa,canRedo:()=>ma,clearHistory:Ue,exportToPNG:async()=>{if(!G.current||!Xe.current||!$e.current)throw new Error("Gantt container not found");let F=G.current,I=Xe.current.querySelector(".gantt-grid-scroll"),_=$e.current,ie=I?.scrollTop||0,fe=_.scrollTop,Se=F.style.overflow,wt=F.style.height;try{let qt=I?.querySelector(".gantt-taskgrid-content"),ha=_.querySelector("svg"),ba=qt?.scrollHeight||I?.scrollHeight||600,Sa=ha?.getBoundingClientRect().height||_.scrollHeight,Ar=(F.querySelector('[class*="h-12"]')?.offsetHeight||48)+Math.max(ba,Sa)+20;I&&(I.scrollTop=0),_.scrollTop=0,F.style.overflow="visible",F.style.height=`${Ar}px`,await new Promise(hr=>setTimeout(hr,100));let fr=await fc(F,{backgroundColor:ee.bgPrimary,scale:2,logging:!1,useCORS:!0,ignoreElements:hr=>{let Qr=window.getComputedStyle(hr),Fr=parseInt(Qr.zIndex,10);return !isNaN(Fr)&&Fr>=50||Qr.position==="fixed"}});return new Promise((hr,Qr)=>{fr.toBlob(Fr=>{Fr?hr(Fr):Qr(new Error("Failed to create blob from canvas"));},"image/png");})}finally{F.style.overflow=Se,F.style.height=wt,I&&(I.scrollTop=ie),_.scrollTop=fe;}},exportToPDF:async F=>{await pe.exportToPDF(he,F);},exportToExcel:async F=>{await pe.exportToExcel(he,F);},exportToJSON:()=>pe.exportToJSON(he),exportToCSV:()=>pe.exportToCSV(he),importFromJSON:F=>{let I=pe.importFromJSON(F);Pe(I);},getTasks:()=>he,refresh:()=>{Pe(F=>[...F]);},clearAll:()=>{Pe([]);}}),[he,Mt,ht,oa,ma,Ue,ee,Re]);let lt=useCallback(F=>{Ee(I=>I.map(_=>_.id===F?{..._,visible:!_.visible}:_));},[]),Et=useCallback((F,I)=>{Ee(_=>_.map(ie=>{if(ie.id!==F)return ie;let fe=ie.minWidth??100,Se=ie.maxWidth??800,wt=Math.max(fe,Math.min(Se,I));return {...ie,width:wt}}));},[]),se=useCallback(F=>{Pe(I=>{let _=ni(I,F),ie=fe=>{for(let Se of fe){if(Se.id===F){na.current.set(F,Se.isExpanded??true);return}Se.subtasks?.length&&ie(Se.subtasks);}};return ie(_),E(),_}),a.onTaskToggleExpand?.(F);},[a,E]),j=useCallback((F,I)=>{if(Ve&&Ve(F,I)===false)return;let ie=pe.findTaskById(he,F)?.progress,fe=wt=>wt.map(qt=>qt.id===F?{...qt,...I}:qt.subtasks?{...qt,subtasks:fe(qt.subtasks)}:qt);Pe(fe(he));let Se=pe.findTaskById(fe(he),F);Se&&(k?.(Se),Je?.(Se),I.progress!==void 0&&ie!==void 0&&I.progress!==ie&&O?.(F,ie,I.progress));},[he,k,Ve,Je,O]),_e=useCallback(F=>{F.length!==0&&(Pe(I=>Qs(I,F)),a.onTaskIndent?.(F[0]));},[a]),De=useCallback(F=>{F.length!==0&&(Pe(I=>ei(I,F)),a.onTaskOutdent?.(F[0]));},[a]),ta=useCallback((F,I,_)=>{Pe(ie=>Qd(ie,F,I,_)),a.onTaskReparent?.(F,I,_);},[a]),sa=useCallback((F,I)=>{F.length!==0&&(Pe(_=>ti(_,F,I)),a.onTaskMove?.(F[0],I));},[a]),Yt=useCallback(async F=>{let I=[];for(let _ of F)$&&await Promise.resolve($(_))===false||I.push(_);I.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(I):(Pe(_=>ai(_,I)),I.forEach(_=>a.onTaskDelete?.(_))),B&&I.forEach(_=>B(_)));},[a,$,B]),kt=useCallback(F=>{Pe(I=>ri(I,F)),F.forEach(I=>a.onTaskDuplicate?.(I));},[a]),ze=useCallback((F,I)=>{Pe(_=>{let{tasks:ie,newTask:fe}=Zd(_,F,I);return ke&&ke(fe)===false?_:(a.onTaskCreate?.(fe.parentId,fe.position||0),Fe?.(fe),ie)});},[a,ke,Fe]),Ze=useCallback((F,I)=>{Pe(_=>oi(_,F,I)),a.onTaskRename?.(F,I);},[a]),jt=useCallback(F=>{Pe(I=>{let{tasks:_}=si(I,F);return a.onTaskCreate?.(F,0),_});},[a]),tr=useCallback((F,I,_)=>{let ie=F.startDate?Math.round((I.getTime()-F.startDate.getTime())/864e5):0,fe=qt=>qt.map(ha=>ha.id===F.id?{...ha,startDate:I,endDate:_,...F.segments&&{segments:F.segments}}:ha.subtasks?{...ha,subtasks:fe(ha.subtasks)}:ha),Se=fe(he);Se=pe.autoScheduleDependents(Se,F.id,ie),Pe(Se);let wt={...F,startDate:I,endDate:_};k?.(wt);},[he,k]),ll=useCallback((F,I)=>{x?.(F,I),ne({isOpen:true,x:I.clientX,y:I.clientY,task:F});},[x]),vo=useCallback((F,I)=>{let _=pe.splitTask(he,F.id,I);Pe(_),ne({isOpen:false,x:0,y:0,task:null});},[he]),dl=useCallback(F=>{let I=pe.findTaskById(he,F.id)||F;S?.(I),A||Ne(I);},[he,S,A]),cl=useCallback((F,I,_)=>{let ie=new Map,fe=ba=>{ba.forEach(Sa=>{Sa.dependencies&&ie.set(Sa.id,Sa.dependencies),Sa.subtasks&&fe(Sa.subtasks);});};fe(_);let Se=ie.get(I)||[];ie.set(I,[...Se,F]);let wt=new Set,qt=new Set,ha=ba=>{if(!wt.has(ba)){wt.add(ba),qt.add(ba);let Sa=ie.get(ba)||[];for(let gr of Sa){if(!wt.has(gr)&&ha(gr))return true;if(qt.has(gr))return true}}return qt.delete(ba),false};return ha(I)},[]),ml=useCallback((F,I)=>{if(cl(F.id,I,he)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
342
+ </Project>`,u=new Blob([i],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(u),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=me.flattenTasks(e),a=t.filter(i=>i.startDate&&i.endDate);if(a.length===0)return [];let r=new Map,o=i=>{if(r.has(i.id))return;let u=i.startDate&&i.endDate?me.calculateDuration(i.startDate,i.endDate):0,d=0;if(i.dependencies&&i.dependencies.length>0)for(let h of i.dependencies){let C=t.find(T=>T.id===h);if(C){o(C);let T=r.get(h)?.ef||0;d=Math.max(d,T);}}let g=d+u;r.set(i.id,{es:d,ef:g});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(i=>i.ef)),n=new Map,c=i=>{if(n.has(i.id))return;let u=i.startDate&&i.endDate?me.calculateDuration(i.startDate,i.endDate):0,d=t.filter(C=>C.dependencies&&C.dependencies.includes(i.id)),g=s;if(d.length>0)for(let C of d){c(C);let T=n.get(C.id)?.ls||0;g=Math.min(g,T);}let h=g-u;n.set(i.id,{ls:h,lf:g});};a.forEach(c);let p=[];for(let i of a){let u=r.get(i.id),d=n.get(i.id);if(u&&d){let g=d.ls-u.es;Math.abs(g)<.01&&p.push(i.id);}}return p},calculateSlack:(e,t)=>{let a=me.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(me.calculateCriticalPath(e).includes(t))return 0;let o=me.getDependentTasks(e,t);if(o.length===0){let c=me.getLatestEndDate(e);if(!c)return null;let p=me.calculateDuration(a.endDate,c);return Math.max(0,p)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,p)=>c-p)[0];if(!s)return null;let n=me.calculateDuration(a.endDate,new Date(s));return Math.max(0,n)},isOnCriticalPath:(e,t)=>me.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=me.findTaskById(e,t);if(!r||!r.endDate)return e;let o=me.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let n of o){if(!n.startDate||!n.endDate)continue;let c=me.calculateDuration(n.startDate,n.endDate),p;a!==void 0?(p=new Date(n.startDate),p.setDate(p.getDate()+a)):(p=new Date(r.endDate),p.setDate(p.getDate()+1));let i=me.calculateEndDate(p,c),u=d=>d.map(g=>g.id===n.id?{...g,startDate:p,endDate:i}:g.subtasks?{...g,subtasks:u(g.subtasks)}:g);s=u(s),s=me.autoScheduleDependents(s,n.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,n,c)=>{if(a===0)return [];let p=[],i=o.getTime(),u=1e3*60*60*24,d=me.findTaskById(e,t);if(!d||!d.endDate)return [];let g=(h,C,T=new Set)=>{if(T.has(h))return;T.add(h);let m=me.getDependentTasks(e,h);for(let b of m){if(!b.startDate||!b.endDate)continue;let y=r.findIndex(N=>N.id===b.id);if(y===-1)continue;let l=b.startDate.getTime(),v=(b.endDate.getTime()-l)/u,x=(l-i)/u*s,k=x+C*s,O=Math.max(v*s,s),M=c+y*n+12;p.push({taskId:b.id,taskName:b.name,originalX:x,previewX:k,width:O,y:M,rowIndex:y,daysDelta:C,color:b.color}),g(b.id,C,T);}};return g(t,a),p},splitTask:(e,t,a,r=3)=>{let o=me.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let n=new Date(a);n.setDate(n.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let p=[{startDate:new Date(o.startDate),endDate:s},{startDate:n,endDate:c}],i=u=>u.map(d=>d.id===o.id?{...d,endDate:c,segments:p}:d.subtasks?{...d,subtasks:i(d.subtasks)}:d);return i(e)}};function Fn({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:n,templates:c,onTaskClick:p,onTaskDblClick:i,onTaskContextMenu:u,onTaskDateChange:d,onDependencyCreate:g,onDependencyDelete:h}){let[T,m]=useState([]),[b,y]=useState(null),[l,w]=useState(null),v=useCallback($=>{y($);},[]),P=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),x=r==="day"?60:r==="week"?20:8,k=P*x*n,O=$=>{let B=new Date(Date.UTC($.getFullYear(),$.getMonth(),$.getDate())),W=B.getUTCDay()||7;B.setUTCDate(B.getUTCDate()+4-W);let D=new Date(Date.UTC(B.getUTCFullYear(),0,1));return Math.ceil(((B.getTime()-D.getTime())/864e5+1)/7)},M=$=>{let B=$.getDay();return B===0||B===6},N=useCallback($=>{let B=Math.round($/(x*n)),W=new Date(o);return W.setDate(W.getDate()+B),W},[o,x,n]),H=useCallback(($,B)=>{if(B.startDate&&B.endDate)return;let W=$.currentTarget.ownerSVGElement;if(!W)return;let D=W.createSVGPoint();D.x=$.clientX,D.y=$.clientY;let j=D.matrixTransform(W.getScreenCTM()?.inverse()),J=N(j.x),R=new Date(J);R.setDate(R.getDate()+1),d?.(B,J,R);},[N,d]),L=useMemo(()=>{let $=j=>j.map(J=>{if(J.subtasks&&J.subtasks.length>0){let R=$(J.subtasks),de=R.filter(we=>we.startDate&&we.endDate);if(de.length>0){let we=de.map(Fe=>Fe.startDate.getTime()),Me=de.map(Fe=>Fe.endDate.getTime()),ce=new Date(Math.min(...we)),We=new Date(Math.max(...Me));return {...J,subtasks:R,startDate:ce,endDate:We}}return {...J,subtasks:R}}return J}),B=(j,J=[])=>{for(let R of j)J.push(R),R.subtasks&&R.subtasks.length>0&&(R.isExpanded===void 0||R.isExpanded)&&B(R.subtasks,J);return J},W=$(e);return B(W)},[e]),Y=useCallback($=>{if(!$.startDate||!$.endDate)return {x:0,width:0};let B=$.startDate.getTime(),W=$.endDate.getTime(),D=o.getTime(),j=(B-D)/(1e3*60*60*24),J=(W-B)/(1e3*60*60*24),R=j*x*n,de=Math.max(x*n,40),we=Math.max(J*x*n,de);return {x:R,width:we}},[o,x,n]),ae=useMemo(()=>L.filter($=>$.startDate&&$.endDate).map($=>{let{x:B,width:W}=Y($),j=L.findIndex(J=>J.id===$.id)*a+12;return {id:$.id,x:B,y:j,width:W,height:32}}),[L,Y]),ke=useCallback(($,B,W)=>{if(!W||B===0){m([]);return}let D=me.calculateCascadePreview(e,$,B,L,o,x*n,a,48);m(D);},[e,L,o,x,n,a,48]),Pe=useMemo(()=>{let $=[],B=new Date(o);for(;B<=s;){let j=(B.getTime()-o.getTime())/864e5*x*n;if(r==="day")$.push({date:new Date(B),label:B.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:j}),B.setDate(B.getDate()+1);else if(r==="week"){let J=O(B);$.push({date:new Date(B),label:`Week ${J}`,x:j}),B.setDate(B.getDate()+7);}else $.push({date:new Date(B),label:B.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:j}),B.setMonth(B.getMonth()+1);}return $},[o,s,r,x,n]),Ve=useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*x*n,[o,x,n]),Je=Math.max(L.length*a,552);return jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary,overflow:"visible"},children:[jsx("div",{style:{position:"sticky",top:0,zIndex:10,backgroundColor:t.bgGrid,flexShrink:0,height:"48px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:jsxs("svg",{width:Math.max(k,1e3),height:47,style:{display:"block"},children:[jsx("rect",{x:0,y:0,width:Math.max(k,1e3),height:48,fill:t.bgGrid}),Pe.map(($,B)=>jsxs("g",{children:[B>0&&jsx("line",{x1:$.x,y1:0,x2:$.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsx("text",{x:$.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:$.label})]},`header-${B}`)),Ve>=0&&Ve<=k&&jsx("circle",{cx:Ve,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxs("svg",{width:Math.max(k,1e3),height:Je,style:{display:"block",flexShrink:0,overflow:"visible"},children:[jsxs("defs",{children:[jsx("filter",{id:"shadow",children:jsx("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2",floodOpacity:"0.1"})}),jsx("pattern",{id:"diagonal-stripes",width:"8",height:"8",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:jsx("line",{x1:"0",y1:"0",x2:"0",y2:"8",stroke:t.border,strokeWidth:"2"})})]}),jsx("rect",{x:0,y:0,width:Math.max(k,1e3),height:Je,fill:t.bgPrimary}),Pe.map(($,B)=>{let W=Pe[B+1]?.x||k,D=M($.date);return jsxs("g",{children:[D&&jsx("rect",{x:$.x,y:0,width:W-$.x,height:L.length*a,fill:t.bgWeekend,opacity:1}),B>0&&jsx("line",{x1:$.x,y1:0,x2:$.x,y2:L.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},B)}),L.map(($,B)=>{let W=$.startDate&&$.endDate;return jsxs("g",{children:[jsx("rect",{x:0,y:B*a,width:k,height:a,fill:B%2===0?t.bgPrimary:t.bgGrid,opacity:1,style:{pointerEvents:"none"}},`row-${$.id}`),!W&&jsxs(Fragment,{children:[jsx("rect",{x:0,y:B*a,width:k,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:D=>H(D,$),onMouseEnter:D=>{D.currentTarget.setAttribute("fill",t.accentLight),D.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:D=>{D.currentTarget.setAttribute("fill","transparent"),D.currentTarget.setAttribute("opacity","1");}},`clickable-${$.id}`),jsx("text",{x:Ve>0?Ve:100,y:B*a+a/2,fill:t.textTertiary,fontSize:"12",fontFamily:"Inter, sans-serif",fontStyle:"italic",dominantBaseline:"middle",opacity:.4,style:{pointerEvents:"none",userSelect:"none"},children:"Click to set dates..."},`placeholder-${$.id}`)]})]},`row-group-${$.id}`)}),L.map(($,B)=>!$.dependencies||$.dependencies.length===0||!$.startDate||!$.endDate?null:$.dependencies.map(W=>{let D=L.find(de=>de.id===W);if(!D||!D.startDate||!D.endDate)return null;let j=L.findIndex(de=>de.id===W),J=Y(D),R=Y($);return jsx(En,{x1:J.x+J.width,y1:j*a+a/2,x2:R.x,y2:B*a+a/2,theme:t},`dep-${W}-${$.id}`)})),L.map(($,B)=>{if(!$.startDate||!$.endDate)return null;let{x:W,width:D}=Y($),j=B*a+12,J=$.subtasks&&$.subtasks.length>0&&!$.isMilestone;return $.isMilestone?jsx(Mn,{task:$,x:W+D/2,y:j+16,theme:t,onClick:p},$.id):J?jsxs("g",{onClick:()=>p?.($),onContextMenu:R=>{R.preventDefault(),R.stopPropagation(),u?.($,R);},style:{cursor:"default"},children:[jsx("rect",{x:W,y:j,width:D,height:32,fill:t.primary,opacity:.25,rx:6}),jsx("line",{x1:W,y1:j,x2:W+D,y2:j,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W,y1:j,x2:W,y2:j+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W+D,y1:j,x2:W+D,y2:j+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W,y1:j+32,x2:W+D,y2:j+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),D>60&&jsx("text",{x:W+12,y:j+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:$.name})]},$.id):jsx(Nn,{task:$,x:W,y:j,width:D,theme:t,dayWidth:x*n,startDate:o,templates:c,onClick:p,onDoubleClick:i,onContextMenu:u,onDateChange:d,onDependencyCreate:g,allTaskPositions:ae,onDragMove:ke,onHoverChange:v},$.id)}),L.map(($,B)=>!$.dependencies||$.dependencies.length===0||!$.startDate||!$.endDate?null:$.dependencies.map(W=>{let D=L.find(oe=>oe.id===W);if(!D||!D.startDate||!D.endDate)return null;let j=L.findIndex(oe=>oe.id===W),J=Y(D),R=Y($),de=J.x+J.width,we=j*a+a/2,Me=R.x,ce=B*a+a/2,We=Me-de,Fe=de+We/2,Ye=oe=>{let xe=1-oe,Ne=xe*xe,tt=Ne*xe,ht=oe*oe,Ie=ht*oe,be=tt*de+3*Ne*oe*Fe+3*xe*ht*Fe+Ie*Me,Se=tt*we+3*Ne*oe*we+3*xe*ht*ce+Ie*ce;return {x:be,y:Se}},ut=20,yt=[];for(let oe=0;oe<=ut;oe++){let xe=.1+oe/ut*.8;yt.push(Ye(xe));}let nt=yt[0],z=`M ${nt.x} ${nt.y} `+yt.slice(1).map(oe=>`L ${oe.x} ${oe.y}`).join(" ");return l&&l.x1===de&&l.y1===we&&l.x2===Me&&l.y2===ce?null:jsx("path",{d:z,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:()=>{w({x1:de,y1:we,x2:Me,y2:ce,onDelete:()=>h?.($.id,W)});}},`dep-hover-${W}-${$.id}`)})),T.map($=>jsxs("g",{style:{pointerEvents:"none"},children:[jsx("rect",{x:$.previewX,y:$.y-48,width:$.width,height:32,rx:8,fill:$.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs($.daysDelta)>0&&jsx("text",{x:$.previewX+$.width/2,y:$.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:$.daysDelta>0?`+${$.daysDelta}d`:`${$.daysDelta}d`})]},`cascade-preview-${$.taskId}`)),l&&(()=>{let{x1:$,y1:B,x2:W,y2:D,onDelete:j}=l,J=W-$,R=D-B,de=$+J/2,we=(B+D)/2,Me=`M ${$} ${B} C ${de} ${B}, ${de} ${D}, ${W} ${D}`,ce=6,We=Math.atan2(R,J),Fe=W-ce*Math.cos(We-Math.PI/6),Ye=D-ce*Math.sin(We-Math.PI/6),ut=W-ce*Math.cos(We+Math.PI/6),yt=D-ce*Math.sin(We+Math.PI/6),nt=t.dependency,z="#f87171";return jsxs("g",{onMouseLeave:()=>w(null),children:[jsx("path",{d:Me,fill:"none",stroke:"transparent",strokeWidth:50,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx("circle",{cx:de,cy:we,r:25,fill:"transparent",style:{cursor:"pointer"}}),jsx("path",{d:Me,fill:"none",stroke:nt,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsx("path",{d:Me,fill:"none",stroke:nt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("path",{d:`M ${W} ${D} L ${Fe} ${Ye} M ${W} ${D} L ${ut} ${yt}`,fill:"none",stroke:nt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("circle",{cx:W,cy:D,r:4,fill:nt,opacity:.9,style:{pointerEvents:"none"}}),jsxs(motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:oe=>{oe.stopPropagation(),w(null),j();},style:{cursor:"pointer"},children:[jsx("circle",{cx:de,cy:we,r:9,fill:"rgba(248, 113, 113, 0.15)",stroke:z,strokeWidth:1.5,style:{transition:"all 0.15s ease"}}),jsx("line",{x1:de-3,y1:we-3,x2:de+3,y2:we+3,stroke:z,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:de+3,y1:we-3,x2:de-3,y2:we+3,stroke:z,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),Ve>=0&&Ve<=k&&jsx("line",{x1:Ve,y1:0,x2:Ve,y2:Je,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),b&&jsx(ic,{tooltipData:b,theme:t})]})]})}var o0=['Move "Task Name" to next Monday','Extend "Task Name" by 3 days','Rename "Old Name" to "New Name"','Set "Task Name" progress to 50%','Link "Task A" to "Task B"','Create a new task called "New Task"','Delete "Task Name"','Assign John to "Task Name"'],cc=()=>jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707"}),jsx("circle",{cx:"12",cy:"12",r:"4"})]}),n0=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13"})}),s0=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M18 6L6 18M6 6L18 18"})}),i0=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M5 12h14"})}),l0=()=>jsx("div",{className:"flex gap-1 items-center",children:[0,1,2].map(e=>jsx(motion.div,{className:"w-2 h-2 rounded-full bg-current",animate:{scale:[1,1.2,1],opacity:[.5,1,.5]},transition:{duration:.8,repeat:1/0,delay:e*.15}},e))});function In({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:n,onDependencyCreate:c,onDependencyDelete:p}){let[i,u]=useState(false),[d,g]=useState(false),[h,C]=useState([]),[T,m]=useState(""),[b,y]=useState(false),[l,w]=useState(true),v=useRef(null),P=useRef(null),x=useRef(null),{enabled:k=true,placeholder:O='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:M="bottom-right",onCommand:N,suggestions:H=o0,maxHistory:L=50,persistHistory:Y}=a,ae=Y?.storageKey||"gantt-ai-history",ke=Y?.maxMessages??5;useEffect(()=>{if(Y?.enabled)try{let W=localStorage.getItem(ae);if(W){let j=JSON.parse(W).map(J=>({...J,timestamp:new Date(J.timestamp)}));C(j.slice(-ke));}}catch(W){console.warn("[GanttAIAssistant] Failed to load persisted history:",W);}},[Y?.enabled,ae,ke]),useEffect(()=>{if(Y?.enabled&&h.length>0)try{let W=h.filter(D=>!D.isLoading).slice(-ke);localStorage.setItem(ae,JSON.stringify(W));}catch(W){console.warn("[GanttAIAssistant] Failed to persist history:",W);}},[h,Y?.enabled,ae,ke]),useEffect(()=>{P.current&&P.current.scrollIntoView({behavior:"smooth"});},[h]),useEffect(()=>{i&&!d&&v.current&&setTimeout(()=>v.current?.focus(),100);},[i,d]);let Pe=useCallback(W=>{if(W.success)switch(W.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":W.taskId&&W.updates&&o?.(W.taskId,W.updates);break;case "create_task":W.newTask&&s?.(W.newTask);break;case "delete_task":W.taskId&&n?.(W.taskId);break;case "link_tasks":W.dependencyFrom&&W.dependencyTo&&c?.(W.dependencyFrom,W.dependencyTo);break;case "unlink_tasks":W.taskId&&W.dependencyFrom&&p?.(W.taskId,W.dependencyFrom);break}},[o,s,n,c,p]),Ve=useCallback(async W=>{if(!W.trim()||b)return;let D={id:`user-${Date.now()}`,role:"user",content:W,timestamp:new Date};C(J=>[...J.slice(-(L-1)),D]),m(""),w(false),y(true);let j={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};C(J=>[...J,j]);try{if(N){let J=await N(W,e);C(R=>{let de=R.filter(Me=>!Me.isLoading),we={id:`assistant-${Date.now()}`,role:"assistant",content:J.message,timestamp:new Date,command:J};return [...de,we]}),Pe(J);}else C(J=>[...J.filter(de=>!de.isLoading),{id:`assistant-${Date.now()}`,role:"assistant",content:"AI handler not configured. Please provide an onCommand handler in the aiAssistant config.",timestamp:new Date}]);}catch(J){C(R=>[...R.filter(we=>!we.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${J instanceof Error?J.message:"Unknown error"}`,timestamp:new Date}]);}finally{y(false);}},[b,L,N,e,Pe]),Je=W=>{W.preventDefault(),Ve(T);},$=W=>{m(W),v.current?.focus();};if(useEffect(()=>{let W=D=>{(D.metaKey||D.ctrlKey)&&D.key==="k"&&(D.preventDefault(),u(j=>!j),i||g(false)),D.key==="Escape"&&i&&u(false);};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[i]),useEffect(()=>{if(!i)return;let W=j=>{let J=j.target;x.current&&!x.current.contains(J)&&u(false);},D=setTimeout(()=>{document.addEventListener("mousedown",W);},100);return ()=>{clearTimeout(D),document.removeEventListener("mousedown",W);}},[i]),!k)return null;let B={"bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-right":"top-4 right-4","top-left":"top-4 left-4"};return jsxs(gt,{children:[jsx(AnimatePresence,{children:!i&&jsxs(motion.button,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},className:`fixed ${B[M]} z-[99999] flex items-center gap-2 px-4 py-3 rounded-full shadow-lg transition-colors`,style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"white",boxShadow:"0 4px 20px rgba(59, 130, 246, 0.4)"},onClick:()=>u(true),children:[jsx(cc,{}),jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),jsx("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono rounded bg-white/20",children:"\u2318K"})]})}),jsx(AnimatePresence,{children:i&&jsxs(motion.div,{ref:x,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 ${B[M]} z-[99999] w-96 rounded-2xl overflow-hidden shadow-2xl flex flex-col`,style:{background:t.bgPrimary,border:`1px solid ${t.border}`,boxShadow:`0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px ${t.border}`},children:[jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},children:[jsxs("div",{className:"flex items-center gap-2 text-white",children:[jsx(cc,{}),jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>g(W=>!W),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(i0,{})}),jsx("button",{onClick:()=>u(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(s0,{})})]})]}),jsx(AnimatePresence,{children:!d&&jsxs(motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"flex flex-col flex-1 min-h-0",children:[jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[h.length===0&&l&&jsxs("div",{className:"space-y-3",children:[jsx("p",{className:"text-sm text-center",style:{color:t.textSecondary},children:"Try asking me to edit your Gantt chart:"}),jsx("div",{className:"flex flex-wrap gap-2",children:H.slice(0,4).map((W,D)=>jsx("button",{onClick:()=>$(W),className:"text-xs px-3 py-1.5 rounded-full transition-colors",style:{background:t.bgSecondary,color:t.textSecondary,border:`1px solid ${t.border}`},children:W.length>30?W.slice(0,30)+"...":W},D))})]}),h.map(W=>jsx(motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${W.role==="user"?"justify-end":"justify-start"}`,children:jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${W.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:W.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:W.role==="user"?"white":t.textPrimary},children:[W.isLoading?jsx(l0,{}):jsx("p",{className:"text-sm whitespace-pre-wrap",children:W.content}),W.command&&jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:W.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:W.command.success?"#10B981":"#EF4444"},children:[W.command.success?"\u2713":"\u2717",jsx("span",{className:"capitalize",children:W.command.type.replace(/_/g," ")})]})]})},W.id)),jsx("div",{ref:P})]}),jsxs("form",{onSubmit:Je,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsx("input",{ref:v,type:"text",value:T,onChange:W=>m(W.target.value),placeholder:O,disabled:b,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsx("button",{type:"submit",disabled:!T.trim()||b,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:T.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:T.trim()?"white":t.textSecondary},children:jsx(n0,{})})]}),jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function mc(e,t=50){let[a,r]=useState({past:[],present:e,future:[]}),o=useRef(false),s=useCallback((i,u=true)=>{r(d=>{let g=typeof i=="function"?i(d.present):i;if(o.current)return {...d,present:g};if(!u)return {...d,present:g};let h=[...d.past,d.present];return h.length>t&&h.shift(),{past:h,present:g,future:[]}});},[t]),n=useCallback(()=>{r(i=>{if(i.past.length===0)return i;let u=i.past[i.past.length-1],d=i.past.slice(0,i.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:u,future:[i.present,...i.future]}});},[]),c=useCallback(()=>{r(i=>{if(i.future.length===0)return i;let u=i.future[0],d=i.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...i.past,i.present],present:u,future:d}});},[]),p=useCallback(()=>{r(i=>({past:[],present:i.present,future:[]}));},[]);return {state:a.present,setState:s,undo:n,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function pc({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){useEffect(()=>{if(!o)return;let s=n=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,p=c?n.metaKey:n.ctrlKey;if(p&&n.key==="z"&&!n.shiftKey&&a){n.preventDefault(),e();return}if(r){if(!c&&p&&n.key==="y"){n.preventDefault(),t();return}if(c&&p&&n.shiftKey&&n.key==="z"){n.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var p0={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${me.formatDate(e.startDate)} - ${me.formatDate(e.endDate)}`);let a=me.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=>me.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function uc(e){return {...p0,...e}}var v0=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},hc=forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:n="week",rowDensity:c="comfortable",showThemeSelector:p=true,showExportButton:i=true,availableUsers:u=[],templates:d,enableAutoCriticalPath:g=true,persistExpandedState:h,aiAssistant:C,locale:T="en",customTranslations:m,showCreateTaskButton:b=false,createTaskLabel:y,onCreateTask:l,onThemeChange:w,onTaskClick:v,onTaskDblClick:P,onTaskContextMenu:x,onTaskUpdate:k,onProgressChange:O,onTaskEdit:M,onTaskAddSubtask:N,onTaskMarkIncomplete:H,onTaskSetInProgress:L,onDependencyCreate:Y,onDependencyDelete:ae,onBeforeTaskAdd:ke,onAfterTaskAdd:Pe,onBeforeTaskUpdate:Ve,onAfterTaskUpdate:Je,onBeforeTaskDelete:$,onAfterTaskDelete:B}=a,D=useContext(yn)?.theme,[j,J]=useState(D||s||"dark"),[R,de]=useState(n),[we,Me]=useState(c),[ce,We]=useState(1),[Fe,Ye]=useState(0),[ut,yt]=useState(false),[nt,z]=useState(null),[re,oe]=useState({isOpen:false,x:0,y:0,task:null}),[xe,Ne]=useState(null),[tt,ht]=useState(null);useEffect(()=>{D&&D!==j&&J(D);},[D]),useEffect(()=>{s&&s!==j&&J(s);},[s]);let Ie=useCallback(A=>{J(A),w?.(A);},[w]),{state:be,setState:Se,undo:Ft,redo:bt,canUndo:sa,canRedo:ua,clearHistory:$e}=mc(t,50),Ue=useCallback(()=>h?typeof h=="string"?h:"gantt-expanded-tasks":null,[h]),ia=useRef(new Map),ue=useRef(false);if(!ue.current&&h){ue.current=true;let A=typeof h=="string"?h:"gantt-expanded-tasks";try{let I=localStorage.getItem(A);if(I){let _=JSON.parse(I);Array.isArray(_)&&(ia.current=new Map(_));}}catch(I){console.warn("[GanttBoard] Error loading expanded state from localStorage:",I);}}let S=useCallback(()=>{let A=Ue();if(A)try{let I=Array.from(ia.current.entries());localStorage.setItem(A,JSON.stringify(I));}catch(I){console.warn("[GanttBoard] Error saving expanded state to localStorage:",I);}},[Ue]);useEffect(()=>{let A=I=>I.map(_=>{let se=ia.current.get(_.id),fe=se!==void 0?{..._,isExpanded:se}:_;return fe.subtasks?.length?{...fe,subtasks:A(fe.subtasks)}:fe});ia.current.size>0?Se(A(t)):Se(t);},[t,Se]);let Z=useRef(t),ge=useRef(true);useEffect(()=>{if(ge.current){ge.current=false,Z.current=be;return}if(!r)return;let A=JSON.stringify(Z.current),I=JSON.stringify(be);A!==I&&(Z.current=be,r(be));},[be,r]);let Te=useMemo(()=>Zs(T,m),[T,m]),qe=useCallback(A=>[{id:"name",label:A.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:A.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:A.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:A.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:A.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:A.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:A.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:A.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Ge,Re]=useState(()=>qe(Te));useEffect(()=>{Re(A=>A.map(I=>({...I,label:Te.columns[I.id==="name"?"taskName":I.id]||I.label})));},[Te]);let at=useMemo(()=>Ge.filter(I=>I.visible).reduce((I,_)=>I+_.width,0),[Ge]),lt=useRef(Ge.filter(A=>A.visible).map(A=>A.id).join(","));useEffect(()=>{let A=Ge.filter(se=>se.visible),I=A.map(se=>se.id).join(","),_=lt.current;if(I!==_){let se=A.some(De=>De.id!=="name"),fe=_.includes(",");se?!fe&&se&&z(null):z(null),lt.current=I;}},[Ge]);let K=60,te=.6,Ee=useMemo(()=>{let I=at+K,_=typeof window<"u"?window.innerWidth*te:800,se=Math.max(I,_);return nt!==null?Math.max(200,Math.min(nt,se)):Math.max(200,I)},[nt,at]),He=useRef(null),Oe=useRef(null),G=useRef(null),ee=useMemo(()=>Id(j),[j]),Be=useMemo(()=>({theme:ee,themeName:j}),[ee,j]),Et=useMemo(()=>uc(d),[d]),dt=useMemo(()=>{if(!g)return be;let A=me.calculateCriticalPath(be),I=_=>_.map(se=>({...se,isCriticalPath:A.includes(se.id),subtasks:se.subtasks?I(se.subtasks):void 0}));return I(be)},[be,g]),Ka=v0(we);pc({undo:Ft,redo:bt,canUndo:sa,canRedo:ua,enabled:true}),useImperativeHandle(o,()=>({getTask:A=>me.findTaskById(be,A),addTask:(A,I)=>{Se(_=>{if(!I)return [..._,{...A,level:0}];let se=fe=>fe.map(De=>De.id===I?{...De,subtasks:[...De.subtasks||[],{...A,parentId:I,level:(De.level||0)+1}],isExpanded:true}:De.subtasks?{...De,subtasks:se(De.subtasks)}:De);return se(_)});},updateTask:(A,I)=>{Se(_=>{let se=fe=>fe.map(De=>De.id===A?{...De,...I}:De.subtasks?{...De,subtasks:se(De.subtasks)}:De);return se(_)});},deleteTask:A=>{Se(I=>{let _=se=>se.filter(fe=>fe.id===A?false:(fe.subtasks&&(fe.subtasks=_(fe.subtasks)),true));return _(I)});},deleteTasks:A=>{Se(I=>ni(I,A));},duplicateTask:A=>{Se(I=>si(I,[A]));},splitTask:(A,I,_=3)=>{Se(se=>me.splitTask(se,A,I,_));},calculateEndDate:me.calculateEndDate,calculateDuration:me.calculateDuration,validateDependency:(A,I)=>!me.validateDependencies(be,A,I),getAllTasks:()=>me.flattenTasks(be),getTasksByStatus:A=>me.flattenTasks(be).filter(I=>I.status===A),getTasksByParent:A=>A?me.findTaskById(be,A)?.subtasks||[]:be.filter(_=>!_.parentId),getCriticalPath:()=>me.flattenTasks(be).filter(A=>A.isCriticalPath),indentTask:A=>{Se(I=>ai(I,[A]));},outdentTask:A=>{Se(I=>ri(I,[A]));},moveTask:(A,I)=>{Se(_=>oi(_,[A],I));},createSubtask:async A=>{let{tasks:I,newTask:_}=di(be,A);if(ke){let se=ke({..._,parentId:A});if((se instanceof Promise?await se:se)===false)return}Se(I),Pe&&Pe({..._,parentId:A});},scrollToTask:A=>{let _=me.flattenTasks(be).findIndex(se=>se.id===A);if(_!==-1&&He.current){let se=_*Ka;He.current.scrollTo({top:se,behavior:"smooth"}),Oe.current&&Oe.current.scrollTo({top:se,behavior:"smooth"});}},highlightTask:(A,I=2e3)=>{},expandTask:A=>{Se(I=>{let _=se=>se.map(fe=>fe.id===A?{...fe,isExpanded:true}:fe.subtasks?{...fe,subtasks:_(fe.subtasks)}:fe);return _(I)});},collapseTask:A=>{Se(I=>{let _=se=>se.map(fe=>fe.id===A?{...fe,isExpanded:false}:fe.subtasks?{...fe,subtasks:_(fe.subtasks)}:fe);return _(I)});},expandAll:()=>{Se(A=>{let I=_=>_.map(se=>({...se,isExpanded:true,subtasks:se.subtasks?I(se.subtasks):void 0}));return I(A)});},collapseAll:()=>{Se(A=>{let I=_=>_.map(se=>({...se,isExpanded:false,subtasks:se.subtasks?I(se.subtasks):void 0}));return I(A)});},undo:Ft,redo:bt,canUndo:()=>sa,canRedo:()=>ua,clearHistory:$e,exportToPNG:async()=>{if(!G.current||!He.current||!Oe.current)throw new Error("Gantt container not found");let A=G.current,I=He.current.querySelector(".gantt-grid-scroll"),_=Oe.current,se=I?.scrollTop||0,fe=_.scrollTop,De=A.style.overflow,Ct=A.style.height;try{let Xt=I?.querySelector(".gantt-taskgrid-content"),ya=_.querySelector("svg"),va=Xt?.scrollHeight||I?.scrollHeight||600,Pa=ya?.getBoundingClientRect().height||_.scrollHeight,Br=(A.querySelector('[class*="h-12"]')?.offsetHeight||48)+Math.max(va,Pa)+20;I&&(I.scrollTop=0),_.scrollTop=0,A.style.overflow="visible",A.style.height=`${Br}px`,await new Promise(xr=>setTimeout(xr,100));let vr=await fc(A,{backgroundColor:ee.bgPrimary,scale:2,logging:!1,useCORS:!0,ignoreElements:xr=>{let ro=window.getComputedStyle(xr),Rr=parseInt(ro.zIndex,10);return !isNaN(Rr)&&Rr>=50||ro.position==="fixed"}});return new Promise((xr,ro)=>{vr.toBlob(Rr=>{Rr?xr(Rr):ro(new Error("Failed to create blob from canvas"));},"image/png");})}finally{A.style.overflow=De,A.style.height=Ct,I&&(I.scrollTop=se),_.scrollTop=fe;}},exportToPDF:async A=>{await me.exportToPDF(be,A);},exportToExcel:async A=>{await me.exportToExcel(be,A);},exportToJSON:()=>me.exportToJSON(be),exportToCSV:()=>me.exportToCSV(be),importFromJSON:A=>{let I=me.importFromJSON(A);Se(I);},getTasks:()=>be,refresh:()=>{Se(A=>[...A]);},clearAll:()=>{Se([]);}}),[be,Ft,bt,sa,ua,$e,ee,Ka]);let za=useCallback(A=>{Re(I=>I.map(_=>_.id===A?{..._,visible:!_.visible}:_));},[]),F=useCallback((A,I)=>{Re(_=>_.map(se=>{if(se.id!==A)return se;let fe=se.minWidth??100,De=se.maxWidth??800,Ct=Math.max(fe,Math.min(De,I));return {...se,width:Ct}}));},[]),he=useCallback(A=>{Se(I=>{let _=li(I,A),se=fe=>{for(let De of fe){if(De.id===A){ia.current.set(A,De.isExpanded??true);return}De.subtasks?.length&&se(De.subtasks);}};return se(_),S(),_}),a.onTaskToggleExpand?.(A);},[a,S]),q=useCallback((A,I)=>{if(Ve&&Ve(A,I)===false)return;let se=me.findTaskById(be,A)?.progress,fe=Ct=>Ct.map(Xt=>Xt.id===A?{...Xt,...I}:Xt.subtasks?{...Xt,subtasks:fe(Xt.subtasks)}:Xt);Se(fe(be));let De=me.findTaskById(fe(be),A);De&&(k?.(De),Je?.(De),I.progress!==void 0&&se!==void 0&&I.progress!==se&&O?.(A,se,I.progress));},[be,k,Ve,Je,O]),Le=useCallback(A=>{A.length!==0&&(Se(I=>ai(I,A)),a.onTaskIndent?.(A[0]));},[a]),ct=useCallback(A=>{A.length!==0&&(Se(I=>ri(I,A)),a.onTaskOutdent?.(A[0]));},[a]),ne=useCallback((A,I,_)=>{Se(se=>Qd(se,A,I,_)),a.onTaskReparent?.(A,I,_);},[a]),ze=useCallback((A,I)=>{A.length!==0&&(Se(_=>oi(_,A,I)),a.onTaskMove?.(A[0],I));},[a]),xt=useCallback(async A=>{let I=[];for(let _ of A)$&&await Promise.resolve($(_))===false||I.push(_);I.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(I):(Se(_=>ni(_,I)),I.forEach(_=>a.onTaskDelete?.(_))),B&&I.forEach(_=>B(_)));},[a,$,B]),Ae=useCallback(A=>{Se(I=>si(I,A)),A.forEach(I=>a.onTaskDuplicate?.(I));},[a]),Qt=useCallback((A,I)=>{Se(_=>{let{tasks:se,newTask:fe}=Zd(_,A,I);return ke&&ke(fe)===false?_:(a.onTaskCreate?.(fe.parentId,fe.position||0),Pe?.(fe),se)});},[a,ke,Pe]),mt=useCallback((A,I)=>{Se(_=>ii(_,A,I)),a.onTaskRename?.(A,I);},[a]),la=useCallback(A=>{Se(I=>{let{tasks:_}=di(I,A);return a.onTaskCreate?.(A,0),_});},[a]),$t=useCallback((A,I,_)=>{let se=A.startDate?Math.round((I.getTime()-A.startDate.getTime())/864e5):0,fe=Xt=>Xt.map(ya=>ya.id===A.id?{...ya,startDate:I,endDate:_,...A.segments&&{segments:A.segments}}:ya.subtasks?{...ya,subtasks:fe(ya.subtasks)}:ya),De=fe(be);De=me.autoScheduleDependents(De,A.id,se),Se(De);let Ct={...A,startDate:I,endDate:_};k?.(Ct);},[be,k]),Xe=useCallback((A,I)=>{x?.(A,I),oe({isOpen:true,x:I.clientX,y:I.clientY,task:A});},[x]),Mt=useCallback((A,I)=>{let _=me.splitTask(be,A.id,I);Se(_),oe({isOpen:false,x:0,y:0,task:null});},[be]),ra=useCallback(A=>{let I=me.findTaskById(be,A.id)||A;P?.(I),M||Ne(I);},[be,P,M]),pr=useCallback((A,I,_)=>{let se=new Map,fe=va=>{va.forEach(Pa=>{Pa.dependencies&&se.set(Pa.id,Pa.dependencies),Pa.subtasks&&fe(Pa.subtasks);});};fe(_);let De=se.get(I)||[];se.set(I,[...De,A]);let Ct=new Set,Xt=new Set,ya=va=>{if(!Ct.has(va)){Ct.add(va),Xt.add(va);let Pa=se.get(va)||[];for(let yr of Pa){if(!Ct.has(yr)&&ya(yr))return true;if(Xt.has(yr))return true}}return Xt.delete(va),false};return ya(I)},[]),ml=useCallback((A,I)=>{if(pr(A.id,I,be)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
343
343
 
344
- Task dependencies must flow in one direction only.`);return}let _=ie=>ie.map(fe=>{if(fe.id===I){let Se=fe.dependencies||[];if(!Se.includes(F.id))return {...fe,dependencies:[...Se,F.id]}}return fe.subtasks?{...fe,subtasks:_(fe.subtasks)}:fe});Pe(_(he)),q?.(F.id,I);},[he,q,cl]),pl=useCallback((F,I)=>{let _=ie=>ie.map(fe=>{if(fe.id===F&&fe.dependencies){let Se=fe.dependencies.filter(wt=>wt!==I);return {...fe,dependencies:Se}}return fe.subtasks?{...fe,subtasks:_(fe.subtasks)}:fe});Pe(_(he)),ae?.(F,I);},[he,ae]),{startDate:Bm,endDate:Rm}=useMemo(()=>{let F=he.filter(Se=>Se.startDate&&Se.endDate);if(F.length===0){let Se=new Date,wt=new Date(Se);wt.setDate(wt.getDate()-30);let qt=new Date(Se);return qt.setDate(qt.getDate()+60),{startDate:wt,endDate:qt}}let I=F.flatMap(Se=>[Se.startDate,Se.endDate]).filter(Se=>Se!==void 0),_=new Date(Math.min(...I.map(Se=>Se.getTime()))),ie=new Date(Math.max(...I.map(Se=>Se.getTime()))),fe=R==="day"?7:R==="week"?14:30;return _.setDate(_.getDate()-fe),ie.setDate(ie.getDate()+fe),{startDate:_,endDate:ie}},[he,R]),Om=useCallback(async()=>{if(!G.current||!Xe.current||!$e.current)return;await new Promise(Ar=>setTimeout(Ar,200));let F=G.current,I=Xe.current.querySelector(".gantt-grid-scroll"),_=$e.current,ie=I?.scrollTop||0,fe=I?.scrollLeft||0,Se=_.scrollTop,wt=_.scrollLeft,qt=F.style.overflow,ha=F.style.height,ba=I?.style.overflow||"",Sa=_.style.overflow,gr=F.style.width,Yo=_.style.width;try{let Ar=I?.querySelector(".gantt-taskgrid-content"),fr=_.querySelector("svg"),hr=fr?.getAttribute("height")?parseInt(fr.getAttribute("height"),10):fr?.getBoundingClientRect().height||0,Qr=Ar?.scrollHeight||I?.scrollHeight||600,Fr=Math.max(hr,_.scrollHeight),ul=fr?.getAttribute("width")?parseInt(fr.getAttribute("width"),10):fr?.getBoundingClientRect().width||_.scrollWidth,_m=F.querySelector('[class*="h-12"]')?.offsetHeight||48,Yn=Math.max(Qr,Fr,hr),qn=_m+Yn+50,Xn=(I?.offsetWidth||300)+ul+10;I&&(I.scrollTop=0,I.scrollLeft=0),_.scrollTop=0,_.scrollLeft=0,F.style.overflow="visible",F.style.height=`${qn}px`,F.style.width=`${Xn}px`,I&&(I.style.overflow="visible",I.style.height=`${Yn+50}px`),_.style.overflow="visible",_.style.height=`${Yn+50}px`,_.style.width=`${ul+10}px`,await new Promise(Zn=>setTimeout(Zn,150));let Vm=await fc(F,{backgroundColor:ee.bgPrimary,scale:2,logging:!1,useCORS:!0,allowTaint:!0,width:Xn,height:qn,windowWidth:Xn+100,windowHeight:qn+100,scrollX:0,scrollY:0,ignoreElements:Zn=>{let gl=window.getComputedStyle(Zn),fl=parseInt(gl.zIndex,10);return !isNaN(fl)&&fl>=50||gl.position==="fixed"}}),Jn=document.createElement("a");Jn.download=`gantt-chart-${new Date().toISOString().slice(0,10)}.png`,Jn.href=Vm.toDataURL("image/png"),Jn.click();}finally{F.style.overflow=qt,F.style.height=ha,F.style.width=gr,I&&(I.style.overflow=ba,I.style.height="",I.scrollTop=ie,I.scrollLeft=fe),_.style.overflow=Sa,_.style.height="",_.style.width=Yo,_.scrollTop=Se,_.scrollLeft=wt;}},[ee]),zm=useCallback(async()=>{await pe.exportToPDF(he);},[he]),Um=useCallback(async()=>{await pe.exportToExcel(he);},[he]),$m=useCallback(()=>{let F=pe.exportToCSV(he),I=new Blob([F],{type:"text/csv;charset=utf-8;"}),_=document.createElement("a");_.href=URL.createObjectURL(I),_.download="gantt-chart.csv",_.click(),URL.revokeObjectURL(_.href);},[he]),Hm=useCallback(()=>{let F=pe.exportToJSON(he),I=new Blob([F],{type:"application/json;charset=utf-8;"}),_=document.createElement("a");_.href=URL.createObjectURL(I),_.download="gantt-chart.json",_.click(),URL.revokeObjectURL(_.href);},[he]),Wm=useCallback(()=>{pe.exportToMSProject(he,"Gantt Project","project.xml");},[he]),Gm=F=>{F.preventDefault(),bt(true);},Zr=useRef(false);return useEffect(()=>{let F=$e.current,I=Xe.current?.querySelector(".gantt-grid-scroll");if(!F||!I)return;let _=()=>{if(Zr.current)return;Zr.current=true;let wt=F.scrollTop;Ye(wt),I.scrollTop=wt,requestAnimationFrame(()=>{Zr.current=false;});},ie=()=>{if(Zr.current)return;Zr.current=true;let wt=I.scrollTop;Ye(wt),F.scrollTop=wt,requestAnimationFrame(()=>{Zr.current=false;});},fe=wt=>{if(pt&&I){let ha=I.parentElement?.getBoundingClientRect()?.left||0,ba=wt.clientX-ha,Sa=200,gr=rt+V,Yo=window.innerWidth*re,Ar=Math.max(gr,Yo);ba>=Sa&&ba<=Ar&&z(ba);}},Se=()=>{bt(false);};return F.addEventListener("scroll",_),I.addEventListener("scroll",ie),document.addEventListener("mousemove",fe),document.addEventListener("mouseup",Se),()=>{F.removeEventListener("scroll",_),I.removeEventListener("scroll",ie),document.removeEventListener("mousemove",fe),document.removeEventListener("mouseup",Se);}},[pt,rt]),jsx(po.Provider,{value:Te,children:jsx(rs.Provider,{value:Ae,children:jsxs("div",{ref:G,className:"flex flex-col h-full w-full",style:{backgroundColor:ee.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsx(bn,{theme:ee,timeScale:R,onTimeScaleChange:ce,zoom:me,onZoomChange:He,currentTheme:Y,onThemeChange:Be,rowDensity:we,onRowDensityChange:Ie,showThemeSelector:p,showCreateTaskButton:b,createTaskLabel:y,onCreateTask:l,onExportPNG:i?Om:void 0,onExportPDF:i?zm:void 0,onExportExcel:i?Um:void 0,onExportCSV:i?$m:void 0,onExportJSON:i?Hm:void 0,onExportMSProject:i?Wm:void 0}),jsxs("div",{ref:Xe,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:Me,overflowX:"auto",overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:jsx(kn,{tasks:te,theme:ee,rowHeight:Re,availableUsers:u,templates:M,onTaskClick:v,onTaskDblClick:dl,onTaskContextMenu:x,onTaskToggle:se,scrollTop:Le,columns:We,onToggleColumn:lt,onColumnResize:Et,onTaskUpdate:j,onTaskIndent:_e,onTaskOutdent:De,onTaskMove:sa,onMultiTaskDelete:Yt,onTaskDuplicate:kt,onTaskCreate:ze,onTaskRename:Ze,onCreateSubtask:jt,onOpenTaskModal:v?F=>v(F):void 0,onDeleteRequest:(F,I)=>ft({taskId:F,taskName:I}),onTaskReparent:ta})}),jsx("div",{className:"flex-shrink-0 cursor-col-resize hover:bg-blue-500/50 transition-colors h-full",style:{width:1,backgroundColor:ee.border,zIndex:15},onMouseDown:Gm}),jsx("div",{ref:$e,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsx(Pn,{tasks:te,theme:ee,rowHeight:Re,timeScale:R,startDate:Bm,endDate:Rm,zoom:me,templates:M,onTaskClick:v,onTaskDblClick:dl,onTaskContextMenu:ll,onTaskDateChange:tr,onDependencyCreate:ml,onDependencyDelete:pl})})]}),oe.task&&jsx(uo,{isOpen:oe.isOpen,x:oe.x,y:oe.y,theme:ee,onClose:()=>ne({isOpen:false,x:0,y:0,task:null}),items:(()=>{let F=oe.task;if(!F)return [];let I=pe.findTaskById(he,F.id)||F;return I.subtasks&&I.subtasks.length>0?[{id:"addSubtask",label:Te.contextMenu?.addSubtask||"Add Subtask",icon:Bt.Add,onClick:()=>{N?N(I):jt(I.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:Te.contextMenu?.deleteTask||"Delete Task",icon:Bt.Delete,onClick:()=>{ft({taskId:I.id,taskName:I.name});}}]:[{id:"edit",label:Te.contextMenu?.editTask||"Edit Task",icon:Bt.Pencil,onClick:()=>{A?A(I):Ne(I);}},{id:"addSubtask",label:Te.contextMenu?.addSubtask||"Add Subtask",icon:Bt.Add,onClick:()=>{N?N(I):jt(I.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:Te.contextMenu?.markIncomplete||"Mark Incomplete",icon:Bt.MarkIncomplete,onClick:()=>{H?H(I):j(I.id,{status:"todo",progress:0});},disabled:I.status==="todo"},{id:"setInProgress",label:Te.contextMenu?.setInProgress||"Set In Progress",icon:Bt.SetInProgress,onClick:()=>{L?L(I):j(I.id,{status:"in-progress"});},disabled:I.status==="in-progress"},{id:"markComplete",label:Te.contextMenu?.markComplete||"Mark Complete",icon:Bt.MarkComplete,onClick:()=>{j(I.id,{status:"completed",progress:100});},disabled:I.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:Te.contextMenu?.splitTask||"Split Task",icon:Bt.Split,onClick:()=>{if(!I.startDate||!I.endDate){console.warn("Cannot split task without dates");return}let ie=I.startDate.getTime(),fe=I.endDate.getTime(),Se=ie+(fe-ie)/2,wt=new Date(Se);vo(I,wt);},disabled:!I.startDate||!I.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:Te.contextMenu?.deleteTask||"Delete Task",icon:Bt.Delete,onClick:()=>{ft({taskId:I.id,taskName:I.name});}}]})()}),jsx(Ur,{task:xe,isOpen:!!xe,onClose:()=>Ne(null),onTaskUpdate:F=>{xe&&(j(xe.id,F),Ne(null));},theme:Y==="light"?"light":"dark",locale:T==="es"?"es":"en",availableUsers:u,availableTasks:t}),jsx(AnimatePresence,{children:at&&jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[10000] flex items-center justify-center p-4",style:{backgroundColor:"rgba(0, 0, 0, 0.6)"},onClick:()=>ft(null),children:jsxs(motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.2,ease:"easeOut"},onClick:F=>F.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:ee.bgSecondary,border:`1px solid ${ee.border}`},children:[jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${ee.border}`},children:jsxs("div",{className:"flex items-start gap-3",children:[jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"rgba(239, 68, 68, 0.2)"},children:jsx(AlertTriangle,{className:"w-5 h-5",style:{color:"#EF4444"}})}),jsxs("div",{className:"flex-1",children:[jsxs("h3",{className:"text-lg font-semibold",style:{color:ee.textPrimary,fontFamily:"Inter, sans-serif"},children:[Te.contextMenu?.deleteTask||"Delete Task","?"]}),jsx("p",{className:"text-sm mt-1",style:{color:ee.textSecondary,fontFamily:"Inter, sans-serif"},children:T==="es"?"Esta acci\xF3n no se puede deshacer":"This action cannot be undone"})]})]})}),jsx("div",{className:"px-6 py-4",children:jsxs("p",{className:"text-sm leading-relaxed",style:{color:ee.textSecondary,fontFamily:"Inter, sans-serif"},children:[T==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxs("span",{className:"font-semibold",style:{color:ee.textPrimary},children:['"',at.taskName,'"']}),"."]})}),jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:ee.bgPrimary,borderTop:`1px solid ${ee.border}`},children:[jsx("button",{onClick:()=>ft(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:ee.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:F=>{F.currentTarget.style.backgroundColor=ee.hoverBg;},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="transparent";},children:T==="es"?"Cancelar":"Cancel"}),jsxs("button",{onClick:()=>{Yt([at.taskId]),ft(null);},className:"px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:"#EF4444",fontFamily:"Inter, sans-serif"},onMouseEnter:F=>{F.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="#EF4444";},children:[jsx(Trash2,{className:"w-4 h-4"}),T==="es"?"Eliminar":"Delete"]})]})]})})}),C?.enabled&&jsx(Mn,{tasks:he,theme:ee,config:C,onTasksUpdate:Pe,onTaskUpdate:j,onTaskCreate:F=>{Pe(I=>[...I,F]);},onTaskDelete:F=>{Yt([F]);},onDependencyCreate:(F,I)=>{let _=pe.findTaskById(he,F);_&&ml(_,I);},onDependencyDelete:pl})]})})})});var ui=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],gi=[{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 vc({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:n=false,mode:c=a?"edit":"create",theme:p="dark",customStatuses:i=[],availableTags:u=[],onCreateTag:d,attachments:g=[],onUploadAttachments:f,onDeleteAttachment:C}){let T=[...ui,...i.filter(z=>!ui.some(oe=>oe.id===z.id))],m=Qe[p]||Qe.dark,[b,y]=useState(false),[l,w]=useState(false),[v,S]=useState(false),[x,k]=useState(false),[O,A]=useState({top:0,left:0}),[N,H]=useState(null),[L,q]=useState(new Date),[ae,ke]=useState({top:0,left:0}),[Fe,Ve]=useState(false),[Je,$]=useState([]),B=useRef(null),W=useRef(null),D=useRef(null),Y=useRef(null),J=useRef(null),[R,ce]=useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[we,Ie]=useState({});useEffect(()=>{a?(ce({name:a.name,description:a.description||"",startDate:a.startDate,endDate:a.endDate,progress:a.progress,status:a.status||"todo",priority:a.priority||"medium",isMilestone:a.isMilestone||false,color:a.color||"#6366F1",assignees:a.assignees||[],dependencies:a.dependencies||[],tags:a.tags||[]}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&Ve(true)):(ce({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),Ve(false),$([]));},[a,e]),useEffect(()=>{let z=oe=>{B.current&&!B.current.contains(oe.target)&&y(false),W.current&&!W.current.contains(oe.target)&&w(false),D.current&&!D.current.contains(oe.target)&&S(false),Y.current&&!Y.current.contains(oe.target)&&k(false);};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]);let me=()=>{let z={};return R.name.trim()||(z.name="El nombre es requerido"),R.startDate&&R.endDate&&R.startDate>R.endDate&&(z.endDate="La fecha de fin debe ser posterior a la de inicio"),Ie(z),Object.keys(z).length===0},He=async z=>{if(z.preventDefault(),!!me())try{let oe=c==="create"&&Je.length>0?{...R,pendingFiles:Je}:R;await s(oe),$([]),t();}catch(oe){console.error("Error submitting task:",oe);}},Le=(z,oe)=>{ce(ne=>{let xe={...ne,[z]:oe};if(z==="status"){let Ne=oe;Ne==="todo"?xe.progress=0:Ne==="in-progress"?(ne.progress===0||ne.progress===100)&&(xe.progress=50):Ne==="completed"||Ne==="closed"?xe.progress=100:(Ne==="in-review"||Ne==="review")&&(xe.progress=75);}if(z==="progress"){let Ne=typeof oe=="number"?oe:parseInt(oe,10);Ne===100&&ne.status!=="completed"?xe.status="completed":Ne>0&&Ne<100&&ne.status==="todo"?xe.status="in-progress":Ne===0&&ne.status!=="todo"&&(xe.status="todo");}return xe}),we[z]&&Ie(ne=>{let xe={...ne};return delete xe[z],xe});},Ye=T.find(z=>z.id===R.status)??ui[0],pt=gi.find(z=>z.id===R.priority)??gi[1],bt=rr.find(z=>z.value===R.color)??rr[0],it={backgroundColor:m.bgSecondary,border:`1px solid ${m.borderLight}`,color:m.textPrimary};return jsx(AnimatePresence,{children:e&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 z-50",onClick:t}),jsx(motion.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl pointer-events-auto overflow-hidden","data-theme":p,style:{backgroundColor:m.bgPrimary,border:`1px solid ${m.border}`},onClick:z=>z.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${m.border}`},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Ye.color||m.accent}}),jsx("span",{className:"text-sm font-medium",style:{color:m.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:m.textTertiary},onMouseEnter:z=>{z.currentTarget.style.backgroundColor=m.hoverBg,z.currentTarget.style.color=m.textPrimary;},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="transparent",z.currentTarget.style.color=m.textTertiary;},disabled:n,children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("form",{onSubmit:He,className:"max-h-[calc(100vh-200px)] overflow-y-auto",children:[jsxs("div",{className:"p-5 space-y-4",children:[jsxs("div",{children:[jsx("input",{type:"text",value:R.name,onChange:z=>Le("name",z.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:m.textPrimary},placeholder:"Nombre de la tarea",disabled:n,autoFocus:true}),we.name&&jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsx(AlertCircle,{className:"w-3 h-3"}),we.name]})]}),jsx("div",{children:jsx("textarea",{value:R.description||"",onChange:z=>Le("description",z.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:m.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:n})}),jsx("div",{style:{borderTop:`1px solid ${m.borderLight}`}}),jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxs("div",{ref:B,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&y(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...it,borderColor:Ye.color,backgroundColor:`${Ye.color}15`},disabled:n,children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:Ye.color}}),jsx("span",{style:{color:Ye.color},children:Ye.title}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:Ye.color}})]}),jsx(AnimatePresence,{children:b&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[140px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:m.bgPrimary,border:`1px solid ${m.border}`},children:T.map(z=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:m.textPrimary},onMouseEnter:oe=>oe.currentTarget.style.backgroundColor=m.hoverBg,onMouseLeave:oe=>oe.currentTarget.style.backgroundColor="transparent",onClick:()=>{Le("status",z.id),y(false);},children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:z.color}}),z.title,R.status===z.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:m.accent}})]},z.id))})})]}),jsxs("div",{ref:W,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&w(!l),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:it,disabled:n,children:[jsx(Flag,{className:"w-3.5 h-3.5",style:{color:pt.color}}),jsx("span",{children:pt.label}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:m.textTertiary}})]}),jsx(AnimatePresence,{children:l&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[130px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:m.bgPrimary,border:`1px solid ${m.border}`},children:gi.map(z=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:m.textPrimary},onMouseEnter:oe=>oe.currentTarget.style.backgroundColor=m.hoverBg,onMouseLeave:oe=>oe.currentTarget.style.backgroundColor="transparent",onClick:()=>{Le("priority",z.id),w(false);},children:[jsx("span",{children:z.icon}),z.label,R.priority===z.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:m.accent}})]},z.id))})})]}),o.length>0&&jsxs("div",{ref:D,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&S(!v),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:it,disabled:n,children:[R.assignees&&R.assignees.length>0?jsxs(Fragment,{children:[jsx("div",{className:"flex -space-x-1",children:R.assignees.slice(0,3).map((z,oe)=>jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] text-white font-medium border-2",style:{backgroundColor:z.color||m.accent,borderColor:m.bgSecondary},children:z.initials},oe))}),R.assignees.length>3&&jsxs("span",{style:{color:m.textTertiary},children:["+",R.assignees.length-3]})]}):jsxs(Fragment,{children:[jsx(Users,{className:"w-3.5 h-3.5",style:{color:m.textTertiary}}),jsx("span",{style:{color:m.textTertiary},children:"Asignar"})]}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:m.textTertiary}})]}),jsx(AnimatePresence,{children:v&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[180px] max-h-[200px] overflow-y-auto rounded-lg shadow-xl",style:{backgroundColor:m.bgPrimary,border:`1px solid ${m.border}`},children:o.map(z=>{let oe=R.assignees?.some(ne=>ne.name===z.name);return jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:m.textPrimary},onMouseEnter:ne=>ne.currentTarget.style.backgroundColor=m.hoverBg,onMouseLeave:ne=>ne.currentTarget.style.backgroundColor="transparent",onClick:()=>{let ne=oe?(R.assignees||[]).filter(xe=>xe.name!==z.name):[...R.assignees||[],{name:z.name,avatar:z.avatar,initials:z.name.split(" ").map(xe=>xe[0]).join("").toUpperCase().slice(0,2),color:m.accent}];Le("assignees",ne);},children:[jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs text-white font-medium flex-shrink-0",style:{backgroundColor:m.accent},children:z.name.charAt(0).toUpperCase()}),jsx("span",{className:"truncate flex-1 text-left",children:z.name}),jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:oe&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:m.accent}})})]},z.id)})})})]}),jsxs("div",{ref:Y,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>{if(!n)if(x)k(false);else {if(Y.current){let z=Y.current.getBoundingClientRect(),oe=window.innerHeight,ne=120,Ne=oe-z.bottom<ne?z.top-ne-8:z.bottom+8;A({top:Ne,left:z.left});}k(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:it,disabled:n,children:[jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:R.color}}),jsx("span",{children:bt.name}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:m.textTertiary}})]}),jsx(AnimatePresence,{children:x&&jsxs(ut,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>k(false)}),jsx(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:`${O.top}px`,left:`${O.left}px`,zIndex:99999,backgroundColor:m.bgPrimary,border:`1px solid ${m.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick:z=>z.stopPropagation(),children:jsx("div",{style:{padding:"6px 8px"},children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 28px)",gap:"2px"},children:rr.slice(0,18).map(z=>{let oe=R.color===z.value;return jsx("button",{type:"button",onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),Le("color",z.value),k(false);},style:{width:"28px",height:"28px",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",border:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0},title:z.name,children:jsx("span",{style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:z.value,outline:oe?`2px solid ${z.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},z.value)})})})})]})})]}),u.length>0||d?jsx(ar,{selectedTags:R.tags||[],availableTags:u,onChange:z=>Le("tags",z),onCreateTag:d,theme:m,disabled:n}):null]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Calendar,{className:"w-4 h-4",style:{color:m.textTertiary}}),jsxs("div",{ref:J,className:"flex items-center gap-2 flex-1 relative",children:[jsx("button",{type:"button",onClick:()=>{if(!n&&!R.isMilestone)if(N==="start")H(null);else {if(J.current){let z=J.current.getBoundingClientRect(),oe=window.innerHeight,ne=320,Ne=oe-z.bottom<ne?z.top-ne-8:z.bottom+8;ke({top:Ne,left:z.left});}H("start"),q(R.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...it,opacity:R.isMilestone?.5:1,cursor:R.isMilestone?"not-allowed":"pointer"},disabled:n||R.isMilestone,children:R.startDate?R.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsx("span",{style:{color:m.textTertiary},children:"\u2192"}),jsx("button",{type:"button",onClick:()=>{if(!n&&!R.isMilestone)if(N==="end")H(null);else {if(J.current){let z=J.current.getBoundingClientRect(),oe=window.innerHeight,ne=320,Ne=oe-z.bottom<ne?z.top-ne-8:z.bottom+8;ke({top:Ne,left:z.left});}H("end"),q(R.endDate||R.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...it,opacity:R.isMilestone?.5:1,cursor:R.isMilestone?"not-allowed":"pointer"},disabled:n||R.isMilestone,children:R.endDate?R.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsx(AnimatePresence,{children:N&&jsxs(ut,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>H(null)}),jsxs(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:`${ae.top}px`,left:`${ae.left}px`,zIndex:99999,backgroundColor:m.bgPrimary,border:`1px solid ${m.border}`},onClick:z=>z.stopPropagation(),children:[jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${m.border}`},children:[(()=>{let z=new Date,oe=new Date(z);oe.setDate(z.getDate()+1);let ne=new Date(z);ne.setDate(z.getDate()+7);let xe=new Date(z);return xe.setDate(z.getDate()+14),[{label:"Hoy",date:z},{label:"Ma\xF1ana",date:oe},{label:"Pr\xF3xima semana",date:ne},{label:"2 semanas",date:xe}].map((at,ft)=>jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:m.textPrimary},onMouseEnter:Be=>Be.currentTarget.style.backgroundColor=m.hoverBg,onMouseLeave:Be=>Be.currentTarget.style.backgroundColor="transparent",onClick:()=>{N==="start"?(Le("startDate",at.date),(!R.endDate||at.date>R.endDate)&&Le("endDate",at.date),H("end")):(Le("endDate",at.date),(!R.startDate||at.date<R.startDate)&&Le("startDate",at.date),H(null));},children:at.label},ft))})(),jsx("div",{style:{borderTop:`1px solid ${m.border}`,margin:"0.5rem 0"}}),jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:z=>z.currentTarget.style.backgroundColor=m.hoverBg,onMouseLeave:z=>z.currentTarget.style.backgroundColor="transparent",onClick:()=>{Le("startDate",void 0),Le("endDate",void 0),H(null);},children:"Borrar fechas"})]}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("button",{type:"button",onClick:()=>q(new Date(L.getFullYear(),L.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-4 h-4",style:{color:m.textSecondary}})}),jsx("span",{className:"text-sm font-medium",style:{color:m.textPrimary},children:L.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>q(new Date(L.getFullYear(),L.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-4 h-4",style:{color:m.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((z,oe)=>jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:m.textTertiary},children:z},oe))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let z=L.getFullYear(),oe=L.getMonth(),ne=new Date(z,oe,1).getDay(),xe=new Date(z,oe+1,0).getDate(),Ne=new Date,at=[];for(let Be=ne-1;Be>=0;Be--)at.push({day:new Date(z,oe,-Be).getDate(),date:new Date(z,oe-1,new Date(z,oe,-Be).getDate()),isCurrentMonth:false});for(let Be=1;Be<=xe;Be++)at.push({day:Be,date:new Date(z,oe,Be),isCurrentMonth:true});let ft=42-at.length;for(let Be=1;Be<=ft;Be++)at.push({day:Be,date:new Date(z,oe+1,Be),isCurrentMonth:false});return at.map((Be,he)=>{let Pe=Be.date.toDateString()===Ne.toDateString(),Mt=R.startDate?.toDateString()===Be.date.toDateString(),ht=R.endDate?.toDateString()===Be.date.toDateString(),oa=R.startDate&&R.endDate&&Be.date>=R.startDate&&Be.date<=R.endDate;return jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:Be.isCurrentMonth?Mt||ht?"#FFF":m.textPrimary:m.textTertiary,backgroundColor:Mt?"#3B82F6":ht?"#7C3AED":oa?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:Pe&&!Mt&&!ht?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{N==="start"?(Le("startDate",Be.date),R.endDate&&Be.date>R.endDate&&Le("endDate",Be.date),H("end")):(Le("endDate",Be.date),R.startDate&&Be.date<R.startDate&&Le("startDate",Be.date),H(null));},children:Be.day},he)})})()})]})]})]})})]}),we.endDate&&jsx("span",{className:"text-xs text-red-400",children:we.endDate})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:"w-4 h-4",style:{color:m.textTertiary}}),jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsx("input",{type:"range",min:"0",max:"100",step:"5",value:R.progress,onChange:z=>Le("progress",parseInt(z.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:m.bgSecondary,accentColor:R.progress<30?"#EF4444":R.progress<70?"#F59E0B":"#10B981"},disabled:n}),jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${R.progress<30?"#EF4444":R.progress<70?"#F59E0B":"#10B981"}20`,color:R.progress<30?"#EF4444":R.progress<70?"#F59E0B":"#10B981"},children:[R.progress,"%"]})]})]}),jsxs("div",{children:[jsxs("button",{type:"button",onClick:()=>Ve(!Fe),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:m.textTertiary},children:[jsx(ChevronDown,{className:`w-3 h-3 transition-transform ${Fe?"rotate-180":""}`}),"Opciones avanzadas"]}),jsx(AnimatePresence,{children:Fe&&jsx(motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:jsxs("div",{className:"pt-3 space-y-3",children:[(f||g.length>0||c==="create")&&jsxs("div",{children:[jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:m.textTertiary},children: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"})}),jsxs("span",{className:"text-xs",style:{color:m.textTertiary},children:["Adjuntos ",c==="create"?Je.length>0&&`(${Je.length})`:g.length>0&&`(${g.length})`]})]}),c==="create"?jsx(sr,{cardId:"pending",attachments:Je.map((z,oe)=>({id:`pending-${oe}`,cardId:"pending",name:z.name,size:z.size,type:z.type,url:URL.createObjectURL(z),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:z=>$(oe=>[...oe,...z]),onDelete:z=>{let oe=parseInt(z.replace("pending-",""),10);$(ne=>ne.filter((xe,Ne)=>Ne!==oe));},maxSizeMB:10,maxFiles:20}):jsx(sr,{cardId:a?.id||"new",attachments:g,onUpload:f&&a?.id?z=>f(a.id,z):void 0,onDelete:C,maxSizeMB:10,maxFiles:20}),c==="create"&&Je.length>0&&jsxs("p",{className:"text-xs mt-1",style:{color:m.textTertiary},children:[Je.length," archivo(s) se subir\xE1n al crear la tarea"]})]}),jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-lg transition-colors hover:bg-white/5",children:[jsx("input",{type:"checkbox",checked:R.isMilestone,onChange:z=>Le("isMilestone",z.target.checked),className:"w-4 h-4 rounded",style:{accentColor:m.accent},disabled:n}),jsx(Milestone,{className:"w-4 h-4 text-yellow-500"}),jsx("span",{className:"text-sm",style:{color:m.textPrimary},children:"Marcar como hito"})]}),r.length>0&&jsxs("div",{children:[jsxs("label",{className:"flex items-center gap-2 text-xs mb-2",style:{color:m.textTertiary},children:[jsx(Link2,{className:"w-3.5 h-3.5"}),"Dependencias"]}),jsx("div",{className:"flex flex-wrap gap-1.5 max-h-24 overflow-y-auto p-2 rounded-lg",style:{backgroundColor:m.bgSecondary},children:r.filter(z=>z.id!==a?.id).map(z=>{let oe=R.dependencies?.includes(z.id);return jsx("button",{type:"button",onClick:()=>{let ne=oe?(R.dependencies||[]).filter(xe=>xe!==z.id):[...R.dependencies||[],z.id];Le("dependencies",ne);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:oe?`${m.accent}30`:m.bgPrimary,color:oe?m.accent:m.textSecondary,border:`1px solid ${oe?m.accent:m.borderLight}`},disabled:n,children:z.name},z.id)})})]})]})})})]})]}),jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${m.border}`},children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:m.textSecondary},onMouseEnter:z=>z.currentTarget.style.backgroundColor=m.hoverBg,onMouseLeave:z=>z.currentTarget.style.backgroundColor="transparent",disabled:n,children:"Cancelar"}),jsx("button",{type:"submit",disabled:n,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:m.accent,color:"#FFF"},onMouseEnter:z=>!n&&(z.currentTarget.style.opacity="0.9"),onMouseLeave:z=>!n&&(z.currentTarget.style.opacity="1"),children:n?jsxs(Fragment,{children:[jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsx(Fragment,{children:c==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var xc=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
344
+ Task dependencies must flow in one direction only.`);return}let _=se=>se.map(fe=>{if(fe.id===I){let De=fe.dependencies||[];if(!De.includes(A.id))return {...fe,dependencies:[...De,A.id]}}return fe.subtasks?{...fe,subtasks:_(fe.subtasks)}:fe});Se(_(be)),Y?.(A.id,I);},[be,Y,pr]),pl=useCallback((A,I)=>{let _=se=>se.map(fe=>{if(fe.id===A&&fe.dependencies){let De=fe.dependencies.filter(Ct=>Ct!==I);return {...fe,dependencies:De}}return fe.subtasks?{...fe,subtasks:_(fe.subtasks)}:fe});Se(_(be)),ae?.(A,I);},[be,ae]),{startDate:Bm,endDate:Rm}=useMemo(()=>{let A=be.filter(De=>De.startDate&&De.endDate);if(A.length===0){let De=new Date,Ct=new Date(De);Ct.setDate(Ct.getDate()-30);let Xt=new Date(De);return Xt.setDate(Xt.getDate()+60),{startDate:Ct,endDate:Xt}}let I=A.flatMap(De=>[De.startDate,De.endDate]).filter(De=>De!==void 0),_=new Date(Math.min(...I.map(De=>De.getTime()))),se=new Date(Math.max(...I.map(De=>De.getTime()))),fe=R==="day"?7:R==="week"?14:30;return _.setDate(_.getDate()-fe),se.setDate(se.getDate()+fe),{startDate:_,endDate:se}},[be,R]),Om=useCallback(async()=>{if(!G.current||!He.current||!Oe.current)return;await new Promise(Br=>setTimeout(Br,200));let A=G.current,I=He.current.querySelector(".gantt-grid-scroll"),_=Oe.current,se=I?.scrollTop||0,fe=I?.scrollLeft||0,De=_.scrollTop,Ct=_.scrollLeft,Xt=A.style.overflow,ya=A.style.height,va=I?.style.overflow||"",Pa=_.style.overflow,yr=A.style.width,Jo=_.style.width;try{let Br=I?.querySelector(".gantt-taskgrid-content"),vr=_.querySelector("svg"),xr=vr?.getAttribute("height")?parseInt(vr.getAttribute("height"),10):vr?.getBoundingClientRect().height||0,ro=Br?.scrollHeight||I?.scrollHeight||600,Rr=Math.max(xr,_.scrollHeight),ul=vr?.getAttribute("width")?parseInt(vr.getAttribute("width"),10):vr?.getBoundingClientRect().width||_.scrollWidth,_m=A.querySelector('[class*="h-12"]')?.offsetHeight||48,Jn=Math.max(ro,Rr,xr),Zn=_m+Jn+50,Qn=(I?.offsetWidth||300)+ul+10;I&&(I.scrollTop=0,I.scrollLeft=0),_.scrollTop=0,_.scrollLeft=0,A.style.overflow="visible",A.style.height=`${Zn}px`,A.style.width=`${Qn}px`,I&&(I.style.overflow="visible",I.style.height=`${Jn+50}px`),_.style.overflow="visible",_.style.height=`${Jn+50}px`,_.style.width=`${ul+10}px`,await new Promise(ts=>setTimeout(ts,150));let Vm=await fc(A,{backgroundColor:ee.bgPrimary,scale:2,logging:!1,useCORS:!0,allowTaint:!0,width:Qn,height:Zn,windowWidth:Qn+100,windowHeight:Zn+100,scrollX:0,scrollY:0,ignoreElements:ts=>{let gl=window.getComputedStyle(ts),fl=parseInt(gl.zIndex,10);return !isNaN(fl)&&fl>=50||gl.position==="fixed"}}),es=document.createElement("a");es.download=`gantt-chart-${new Date().toISOString().slice(0,10)}.png`,es.href=Vm.toDataURL("image/png"),es.click();}finally{A.style.overflow=Xt,A.style.height=ya,A.style.width=yr,I&&(I.style.overflow=va,I.style.height="",I.scrollTop=se,I.scrollLeft=fe),_.style.overflow=Pa,_.style.height="",_.style.width=Jo,_.scrollTop=De,_.scrollLeft=Ct;}},[ee]),zm=useCallback(async()=>{await me.exportToPDF(be);},[be]),Um=useCallback(async()=>{await me.exportToExcel(be);},[be]),$m=useCallback(()=>{let A=me.exportToCSV(be),I=new Blob([A],{type:"text/csv;charset=utf-8;"}),_=document.createElement("a");_.href=URL.createObjectURL(I),_.download="gantt-chart.csv",_.click(),URL.revokeObjectURL(_.href);},[be]),Hm=useCallback(()=>{let A=me.exportToJSON(be),I=new Blob([A],{type:"application/json;charset=utf-8;"}),_=document.createElement("a");_.href=URL.createObjectURL(I),_.download="gantt-chart.json",_.click(),URL.revokeObjectURL(_.href);},[be]),Wm=useCallback(()=>{me.exportToMSProject(be,"Gantt Project","project.xml");},[be]),Gm=A=>{A.preventDefault(),yt(true);},ao=useRef(false);return useEffect(()=>{let A=Oe.current,I=He.current?.querySelector(".gantt-grid-scroll");if(!A||!I)return;let _=()=>{if(ao.current)return;ao.current=true;let Ct=A.scrollTop;Ye(Ct),I.scrollTop=Ct,requestAnimationFrame(()=>{ao.current=false;});},se=()=>{if(ao.current)return;ao.current=true;let Ct=I.scrollTop;Ye(Ct),A.scrollTop=Ct,requestAnimationFrame(()=>{ao.current=false;});},fe=Ct=>{if(ut&&I){let ya=I.parentElement?.getBoundingClientRect()?.left||0,va=Ct.clientX-ya,Pa=200,yr=at+K,Jo=window.innerWidth*te,Br=Math.max(yr,Jo);va>=Pa&&va<=Br&&z(va);}},De=()=>{yt(false);};return A.addEventListener("scroll",_),I.addEventListener("scroll",se),document.addEventListener("mousemove",fe),document.addEventListener("mouseup",De),()=>{A.removeEventListener("scroll",_),I.removeEventListener("scroll",se),document.removeEventListener("mousemove",fe),document.removeEventListener("mouseup",De);}},[ut,at]),jsx(ho.Provider,{value:Te,children:jsx(ss.Provider,{value:Be,children:jsxs("div",{ref:G,className:"flex flex-col h-full w-full",style:{backgroundColor:ee.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsx(xn,{theme:ee,timeScale:R,onTimeScaleChange:de,zoom:ce,onZoomChange:We,currentTheme:j,onThemeChange:Ie,rowDensity:we,onRowDensityChange:Me,showThemeSelector:p,showCreateTaskButton:b,createTaskLabel:y,onCreateTask:l,onExportPNG:i?Om:void 0,onExportPDF:i?zm:void 0,onExportExcel:i?Um:void 0,onExportCSV:i?$m:void 0,onExportJSON:i?Hm:void 0,onExportMSProject:i?Wm:void 0}),jsxs("div",{ref:He,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:Ee,overflowX:"auto",overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:jsx(Tn,{tasks:dt,theme:ee,rowHeight:Ka,availableUsers:u,templates:Et,onTaskClick:v,onTaskDblClick:ra,onTaskContextMenu:x,onTaskToggle:he,scrollTop:Fe,columns:Ge,onToggleColumn:za,onColumnResize:F,onTaskUpdate:q,onTaskIndent:Le,onTaskOutdent:ct,onTaskMove:ze,onMultiTaskDelete:xt,onTaskDuplicate:Ae,onTaskCreate:Qt,onTaskRename:mt,onCreateSubtask:la,onOpenTaskModal:v?A=>v(A):void 0,onDeleteRequest:(A,I)=>ht({taskId:A,taskName:I}),onTaskReparent:ne})}),jsx("div",{className:"flex-shrink-0 cursor-col-resize hover:bg-blue-500/50 transition-colors h-full",style:{width:1,backgroundColor:ee.border,zIndex:15},onMouseDown:Gm}),jsx("div",{ref:Oe,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsx(Fn,{tasks:dt,theme:ee,rowHeight:Ka,timeScale:R,startDate:Bm,endDate:Rm,zoom:ce,templates:Et,onTaskClick:v,onTaskDblClick:ra,onTaskContextMenu:Xe,onTaskDateChange:$t,onDependencyCreate:ml,onDependencyDelete:pl})})]}),re.task&&jsx(bo,{isOpen:re.isOpen,x:re.x,y:re.y,theme:ee,onClose:()=>oe({isOpen:false,x:0,y:0,task:null}),items:(()=>{let A=re.task;if(!A)return [];let I=me.findTaskById(be,A.id)||A;return I.subtasks&&I.subtasks.length>0?[{id:"addSubtask",label:Te.contextMenu?.addSubtask||"Add Subtask",icon:zt.Add,onClick:()=>{N?N(I):la(I.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:Te.contextMenu?.deleteTask||"Delete Task",icon:zt.Delete,onClick:()=>{ht({taskId:I.id,taskName:I.name});}}]:[{id:"edit",label:Te.contextMenu?.editTask||"Edit Task",icon:zt.Pencil,onClick:()=>{M?M(I):Ne(I);}},{id:"addSubtask",label:Te.contextMenu?.addSubtask||"Add Subtask",icon:zt.Add,onClick:()=>{N?N(I):la(I.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:Te.contextMenu?.markIncomplete||"Mark Incomplete",icon:zt.MarkIncomplete,onClick:()=>{H?H(I):q(I.id,{status:"todo",progress:0});},disabled:I.status==="todo"},{id:"setInProgress",label:Te.contextMenu?.setInProgress||"Set In Progress",icon:zt.SetInProgress,onClick:()=>{L?L(I):q(I.id,{status:"in-progress"});},disabled:I.status==="in-progress"},{id:"markComplete",label:Te.contextMenu?.markComplete||"Mark Complete",icon:zt.MarkComplete,onClick:()=>{q(I.id,{status:"completed",progress:100});},disabled:I.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:Te.contextMenu?.splitTask||"Split Task",icon:zt.Split,onClick:()=>{if(!I.startDate||!I.endDate){console.warn("Cannot split task without dates");return}let se=I.startDate.getTime(),fe=I.endDate.getTime(),De=se+(fe-se)/2,Ct=new Date(De);Mt(I,Ct);},disabled:!I.startDate||!I.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:Te.contextMenu?.deleteTask||"Delete Task",icon:zt.Delete,onClick:()=>{ht({taskId:I.id,taskName:I.name});}}]})()}),jsx(Gr,{task:xe,isOpen:!!xe,onClose:()=>Ne(null),onTaskUpdate:A=>{xe&&(q(xe.id,A),Ne(null));},theme:j==="light"?"light":"dark",locale:T==="es"?"es":"en",availableUsers:u,availableTasks:t}),jsx(AnimatePresence,{children:tt&&jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[10000] flex items-center justify-center p-4",style:{backgroundColor:"rgba(0, 0, 0, 0.6)"},onClick:()=>ht(null),children:jsxs(motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.2,ease:"easeOut"},onClick:A=>A.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:ee.bgSecondary,border:`1px solid ${ee.border}`},children:[jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${ee.border}`},children:jsxs("div",{className:"flex items-start gap-3",children:[jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"rgba(239, 68, 68, 0.2)"},children:jsx(AlertTriangle,{className:"w-5 h-5",style:{color:"#EF4444"}})}),jsxs("div",{className:"flex-1",children:[jsxs("h3",{className:"text-lg font-semibold",style:{color:ee.textPrimary,fontFamily:"Inter, sans-serif"},children:[Te.contextMenu?.deleteTask||"Delete Task","?"]}),jsx("p",{className:"text-sm mt-1",style:{color:ee.textSecondary,fontFamily:"Inter, sans-serif"},children:T==="es"?"Esta acci\xF3n no se puede deshacer":"This action cannot be undone"})]})]})}),jsx("div",{className:"px-6 py-4",children:jsxs("p",{className:"text-sm leading-relaxed",style:{color:ee.textSecondary,fontFamily:"Inter, sans-serif"},children:[T==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxs("span",{className:"font-semibold",style:{color:ee.textPrimary},children:['"',tt.taskName,'"']}),"."]})}),jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:ee.bgPrimary,borderTop:`1px solid ${ee.border}`},children:[jsx("button",{onClick:()=>ht(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:ee.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:A=>{A.currentTarget.style.backgroundColor=ee.hoverBg;},onMouseLeave:A=>{A.currentTarget.style.backgroundColor="transparent";},children:T==="es"?"Cancelar":"Cancel"}),jsxs("button",{onClick:()=>{xt([tt.taskId]),ht(null);},className:"px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:"#EF4444",fontFamily:"Inter, sans-serif"},onMouseEnter:A=>{A.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:A=>{A.currentTarget.style.backgroundColor="#EF4444";},children:[jsx(Trash2,{className:"w-4 h-4"}),T==="es"?"Eliminar":"Delete"]})]})]})})}),C?.enabled&&jsx(In,{tasks:be,theme:ee,config:C,onTasksUpdate:Se,onTaskUpdate:q,onTaskCreate:A=>{Se(I=>[...I,A]);},onTaskDelete:A=>{xt([A]);},onDependencyCreate:(A,I)=>{let _=me.findTaskById(be,A);_&&ml(_,I);},onDependencyDelete:pl})]})})})});var hi=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],bi=[{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 vc({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:n=false,mode:c=a?"edit":"create",theme:p="dark",customStatuses:i=[],availableTags:u=[],onCreateTag:d,attachments:g=[],onUploadAttachments:h,onDeleteAttachment:C}){let T=[...hi,...i.filter(z=>!hi.some(re=>re.id===z.id))],m=Ze[p]||Ze.dark,[b,y]=useState(false),[l,w]=useState(false),[v,P]=useState(false),[x,k]=useState(false),[O,M]=useState({top:0,left:0}),[N,H]=useState(null),[L,Y]=useState(new Date),[ae,ke]=useState({top:0,left:0}),[Pe,Ve]=useState(false),[Je,$]=useState([]),B=useRef(null),W=useRef(null),D=useRef(null),j=useRef(null),J=useRef(null),[R,de]=useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[we,Me]=useState({});useEffect(()=>{a?(de({name:a.name,description:a.description||"",startDate:a.startDate,endDate:a.endDate,progress:a.progress,status:a.status||"todo",priority:a.priority||"medium",isMilestone:a.isMilestone||false,color:a.color||"#6366F1",assignees:a.assignees||[],dependencies:a.dependencies||[],tags:a.tags||[]}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&Ve(true)):(de({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),Ve(false),$([]));},[a,e]),useEffect(()=>{let z=re=>{B.current&&!B.current.contains(re.target)&&y(false),W.current&&!W.current.contains(re.target)&&w(false),D.current&&!D.current.contains(re.target)&&P(false),j.current&&!j.current.contains(re.target)&&k(false);};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]);let ce=()=>{let z={};return R.name.trim()||(z.name="El nombre es requerido"),R.startDate&&R.endDate&&R.startDate>R.endDate&&(z.endDate="La fecha de fin debe ser posterior a la de inicio"),Me(z),Object.keys(z).length===0},We=async z=>{if(z.preventDefault(),!!ce())try{let re=c==="create"&&Je.length>0?{...R,pendingFiles:Je}:R;await s(re),$([]),t();}catch(re){console.error("Error submitting task:",re);}},Fe=(z,re)=>{de(oe=>{let xe={...oe,[z]:re};if(z==="status"){let Ne=re;Ne==="todo"?xe.progress=0:Ne==="in-progress"?(oe.progress===0||oe.progress===100)&&(xe.progress=50):Ne==="completed"||Ne==="closed"?xe.progress=100:(Ne==="in-review"||Ne==="review")&&(xe.progress=75);}if(z==="progress"){let Ne=typeof re=="number"?re:parseInt(re,10);Ne===100&&oe.status!=="completed"?xe.status="completed":Ne>0&&Ne<100&&oe.status==="todo"?xe.status="in-progress":Ne===0&&oe.status!=="todo"&&(xe.status="todo");}return xe}),we[z]&&Me(oe=>{let xe={...oe};return delete xe[z],xe});},Ye=T.find(z=>z.id===R.status)??hi[0],ut=bi.find(z=>z.id===R.priority)??bi[1],yt=sr.find(z=>z.value===R.color)??sr[0],nt={backgroundColor:m.bgSecondary,border:`1px solid ${m.borderLight}`,color:m.textPrimary};return jsx(AnimatePresence,{children:e&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 z-50",onClick:t}),jsx(motion.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl pointer-events-auto overflow-hidden","data-theme":p,style:{backgroundColor:m.bgPrimary,border:`1px solid ${m.border}`},onClick:z=>z.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${m.border}`},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Ye.color||m.accent}}),jsx("span",{className:"text-sm font-medium",style:{color:m.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:m.textTertiary},onMouseEnter:z=>{z.currentTarget.style.backgroundColor=m.hoverBg,z.currentTarget.style.color=m.textPrimary;},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="transparent",z.currentTarget.style.color=m.textTertiary;},disabled:n,children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("form",{onSubmit:We,className:"max-h-[calc(100vh-200px)] overflow-y-auto",children:[jsxs("div",{className:"p-5 space-y-4",children:[jsxs("div",{children:[jsx("input",{type:"text",value:R.name,onChange:z=>Fe("name",z.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:m.textPrimary},placeholder:"Nombre de la tarea",disabled:n,autoFocus:true}),we.name&&jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsx(AlertCircle,{className:"w-3 h-3"}),we.name]})]}),jsx("div",{children:jsx("textarea",{value:R.description||"",onChange:z=>Fe("description",z.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:m.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:n})}),jsx("div",{style:{borderTop:`1px solid ${m.borderLight}`}}),jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxs("div",{ref:B,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&y(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...nt,borderColor:Ye.color,backgroundColor:`${Ye.color}15`},disabled:n,children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:Ye.color}}),jsx("span",{style:{color:Ye.color},children:Ye.title}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:Ye.color}})]}),jsx(AnimatePresence,{children:b&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[140px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:m.bgPrimary,border:`1px solid ${m.border}`},children:T.map(z=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:m.textPrimary},onMouseEnter:re=>re.currentTarget.style.backgroundColor=m.hoverBg,onMouseLeave:re=>re.currentTarget.style.backgroundColor="transparent",onClick:()=>{Fe("status",z.id),y(false);},children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:z.color}}),z.title,R.status===z.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:m.accent}})]},z.id))})})]}),jsxs("div",{ref:W,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&w(!l),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:nt,disabled:n,children:[jsx(Flag,{className:"w-3.5 h-3.5",style:{color:ut.color}}),jsx("span",{children:ut.label}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:m.textTertiary}})]}),jsx(AnimatePresence,{children:l&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[130px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:m.bgPrimary,border:`1px solid ${m.border}`},children:bi.map(z=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:m.textPrimary},onMouseEnter:re=>re.currentTarget.style.backgroundColor=m.hoverBg,onMouseLeave:re=>re.currentTarget.style.backgroundColor="transparent",onClick:()=>{Fe("priority",z.id),w(false);},children:[jsx("span",{children:z.icon}),z.label,R.priority===z.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:m.accent}})]},z.id))})})]}),o.length>0&&jsxs("div",{ref:D,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&P(!v),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:nt,disabled:n,children:[R.assignees&&R.assignees.length>0?jsxs(Fragment,{children:[jsx("div",{className:"flex -space-x-1",children:R.assignees.slice(0,3).map((z,re)=>jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] text-white font-medium border-2",style:{backgroundColor:z.color||m.accent,borderColor:m.bgSecondary},children:z.initials},re))}),R.assignees.length>3&&jsxs("span",{style:{color:m.textTertiary},children:["+",R.assignees.length-3]})]}):jsxs(Fragment,{children:[jsx(Users,{className:"w-3.5 h-3.5",style:{color:m.textTertiary}}),jsx("span",{style:{color:m.textTertiary},children:"Asignar"})]}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:m.textTertiary}})]}),jsx(AnimatePresence,{children:v&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[180px] max-h-[200px] overflow-y-auto rounded-lg shadow-xl",style:{backgroundColor:m.bgPrimary,border:`1px solid ${m.border}`},children:o.map(z=>{let re=R.assignees?.some(oe=>oe.name===z.name);return jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:m.textPrimary},onMouseEnter:oe=>oe.currentTarget.style.backgroundColor=m.hoverBg,onMouseLeave:oe=>oe.currentTarget.style.backgroundColor="transparent",onClick:()=>{let oe=re?(R.assignees||[]).filter(xe=>xe.name!==z.name):[...R.assignees||[],{name:z.name,avatar:z.avatar,initials:z.name.split(" ").map(xe=>xe[0]).join("").toUpperCase().slice(0,2),color:m.accent}];Fe("assignees",oe);},children:[jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs text-white font-medium flex-shrink-0",style:{backgroundColor:m.accent},children:z.name.charAt(0).toUpperCase()}),jsx("span",{className:"truncate flex-1 text-left",children:z.name}),jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:re&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:m.accent}})})]},z.id)})})})]}),jsxs("div",{ref:j,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>{if(!n)if(x)k(false);else {if(j.current){let z=j.current.getBoundingClientRect(),re=window.innerHeight,oe=120,Ne=re-z.bottom<oe?z.top-oe-8:z.bottom+8;M({top:Ne,left:z.left});}k(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:nt,disabled:n,children:[jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:R.color}}),jsx("span",{children:yt.name}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:m.textTertiary}})]}),jsx(AnimatePresence,{children:x&&jsxs(gt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>k(false)}),jsx(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:`${O.top}px`,left:`${O.left}px`,zIndex:99999,backgroundColor:m.bgPrimary,border:`1px solid ${m.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick:z=>z.stopPropagation(),children:jsx("div",{style:{padding:"6px 8px"},children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 28px)",gap:"2px"},children:sr.slice(0,18).map(z=>{let re=R.color===z.value;return jsx("button",{type:"button",onClick:oe=>{oe.preventDefault(),oe.stopPropagation(),Fe("color",z.value),k(false);},style:{width:"28px",height:"28px",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",border:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0},title:z.name,children:jsx("span",{style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:z.value,outline:re?`2px solid ${z.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},z.value)})})})})]})})]}),u.length>0||d?jsx(nr,{selectedTags:R.tags||[],availableTags:u,onChange:z=>Fe("tags",z),onCreateTag:d,theme:m,disabled:n}):null]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Calendar,{className:"w-4 h-4",style:{color:m.textTertiary}}),jsxs("div",{ref:J,className:"flex items-center gap-2 flex-1 relative",children:[jsx("button",{type:"button",onClick:()=>{if(!n&&!R.isMilestone)if(N==="start")H(null);else {if(J.current){let z=J.current.getBoundingClientRect(),re=window.innerHeight,oe=320,Ne=re-z.bottom<oe?z.top-oe-8:z.bottom+8;ke({top:Ne,left:z.left});}H("start"),Y(R.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...nt,opacity:R.isMilestone?.5:1,cursor:R.isMilestone?"not-allowed":"pointer"},disabled:n||R.isMilestone,children:R.startDate?R.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsx("span",{style:{color:m.textTertiary},children:"\u2192"}),jsx("button",{type:"button",onClick:()=>{if(!n&&!R.isMilestone)if(N==="end")H(null);else {if(J.current){let z=J.current.getBoundingClientRect(),re=window.innerHeight,oe=320,Ne=re-z.bottom<oe?z.top-oe-8:z.bottom+8;ke({top:Ne,left:z.left});}H("end"),Y(R.endDate||R.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...nt,opacity:R.isMilestone?.5:1,cursor:R.isMilestone?"not-allowed":"pointer"},disabled:n||R.isMilestone,children:R.endDate?R.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsx(AnimatePresence,{children:N&&jsxs(gt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>H(null)}),jsxs(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:`${ae.top}px`,left:`${ae.left}px`,zIndex:99999,backgroundColor:m.bgPrimary,border:`1px solid ${m.border}`},onClick:z=>z.stopPropagation(),children:[jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${m.border}`},children:[(()=>{let z=new Date,re=new Date(z);re.setDate(z.getDate()+1);let oe=new Date(z);oe.setDate(z.getDate()+7);let xe=new Date(z);return xe.setDate(z.getDate()+14),[{label:"Hoy",date:z},{label:"Ma\xF1ana",date:re},{label:"Pr\xF3xima semana",date:oe},{label:"2 semanas",date:xe}].map((tt,ht)=>jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:m.textPrimary},onMouseEnter:Ie=>Ie.currentTarget.style.backgroundColor=m.hoverBg,onMouseLeave:Ie=>Ie.currentTarget.style.backgroundColor="transparent",onClick:()=>{N==="start"?(Fe("startDate",tt.date),(!R.endDate||tt.date>R.endDate)&&Fe("endDate",tt.date),H("end")):(Fe("endDate",tt.date),(!R.startDate||tt.date<R.startDate)&&Fe("startDate",tt.date),H(null));},children:tt.label},ht))})(),jsx("div",{style:{borderTop:`1px solid ${m.border}`,margin:"0.5rem 0"}}),jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:z=>z.currentTarget.style.backgroundColor=m.hoverBg,onMouseLeave:z=>z.currentTarget.style.backgroundColor="transparent",onClick:()=>{Fe("startDate",void 0),Fe("endDate",void 0),H(null);},children:"Borrar fechas"})]}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("button",{type:"button",onClick:()=>Y(new Date(L.getFullYear(),L.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-4 h-4",style:{color:m.textSecondary}})}),jsx("span",{className:"text-sm font-medium",style:{color:m.textPrimary},children:L.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>Y(new Date(L.getFullYear(),L.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-4 h-4",style:{color:m.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((z,re)=>jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:m.textTertiary},children:z},re))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let z=L.getFullYear(),re=L.getMonth(),oe=new Date(z,re,1).getDay(),xe=new Date(z,re+1,0).getDate(),Ne=new Date,tt=[];for(let Ie=oe-1;Ie>=0;Ie--)tt.push({day:new Date(z,re,-Ie).getDate(),date:new Date(z,re-1,new Date(z,re,-Ie).getDate()),isCurrentMonth:false});for(let Ie=1;Ie<=xe;Ie++)tt.push({day:Ie,date:new Date(z,re,Ie),isCurrentMonth:true});let ht=42-tt.length;for(let Ie=1;Ie<=ht;Ie++)tt.push({day:Ie,date:new Date(z,re+1,Ie),isCurrentMonth:false});return tt.map((Ie,be)=>{let Se=Ie.date.toDateString()===Ne.toDateString(),Ft=R.startDate?.toDateString()===Ie.date.toDateString(),bt=R.endDate?.toDateString()===Ie.date.toDateString(),sa=R.startDate&&R.endDate&&Ie.date>=R.startDate&&Ie.date<=R.endDate;return jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:Ie.isCurrentMonth?Ft||bt?"#FFF":m.textPrimary:m.textTertiary,backgroundColor:Ft?"#3B82F6":bt?"#7C3AED":sa?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:Se&&!Ft&&!bt?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{N==="start"?(Fe("startDate",Ie.date),R.endDate&&Ie.date>R.endDate&&Fe("endDate",Ie.date),H("end")):(Fe("endDate",Ie.date),R.startDate&&Ie.date<R.startDate&&Fe("startDate",Ie.date),H(null));},children:Ie.day},be)})})()})]})]})]})})]}),we.endDate&&jsx("span",{className:"text-xs text-red-400",children:we.endDate})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:"w-4 h-4",style:{color:m.textTertiary}}),jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsx("input",{type:"range",min:"0",max:"100",step:"5",value:R.progress,onChange:z=>Fe("progress",parseInt(z.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:m.bgSecondary,accentColor:R.progress<30?"#EF4444":R.progress<70?"#F59E0B":"#10B981"},disabled:n}),jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${R.progress<30?"#EF4444":R.progress<70?"#F59E0B":"#10B981"}20`,color:R.progress<30?"#EF4444":R.progress<70?"#F59E0B":"#10B981"},children:[R.progress,"%"]})]})]}),jsxs("div",{children:[jsxs("button",{type:"button",onClick:()=>Ve(!Pe),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:m.textTertiary},children:[jsx(ChevronDown,{className:`w-3 h-3 transition-transform ${Pe?"rotate-180":""}`}),"Opciones avanzadas"]}),jsx(AnimatePresence,{children:Pe&&jsx(motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:jsxs("div",{className:"pt-3 space-y-3",children:[(h||g.length>0||c==="create")&&jsxs("div",{children:[jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:m.textTertiary},children: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"})}),jsxs("span",{className:"text-xs",style:{color:m.textTertiary},children:["Adjuntos ",c==="create"?Je.length>0&&`(${Je.length})`:g.length>0&&`(${g.length})`]})]}),c==="create"?jsx(dr,{cardId:"pending",attachments:Je.map((z,re)=>({id:`pending-${re}`,cardId:"pending",name:z.name,size:z.size,type:z.type,url:URL.createObjectURL(z),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:z=>$(re=>[...re,...z]),onDelete:z=>{let re=parseInt(z.replace("pending-",""),10);$(oe=>oe.filter((xe,Ne)=>Ne!==re));},maxSizeMB:10,maxFiles:20}):jsx(dr,{cardId:a?.id||"new",attachments:g,onUpload:h&&a?.id?z=>h(a.id,z):void 0,onDelete:C,maxSizeMB:10,maxFiles:20}),c==="create"&&Je.length>0&&jsxs("p",{className:"text-xs mt-1",style:{color:m.textTertiary},children:[Je.length," archivo(s) se subir\xE1n al crear la tarea"]})]}),jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-lg transition-colors hover:bg-white/5",children:[jsx("input",{type:"checkbox",checked:R.isMilestone,onChange:z=>Fe("isMilestone",z.target.checked),className:"w-4 h-4 rounded",style:{accentColor:m.accent},disabled:n}),jsx(Milestone,{className:"w-4 h-4 text-yellow-500"}),jsx("span",{className:"text-sm",style:{color:m.textPrimary},children:"Marcar como hito"})]}),r.length>0&&jsxs("div",{children:[jsxs("label",{className:"flex items-center gap-2 text-xs mb-2",style:{color:m.textTertiary},children:[jsx(Link2,{className:"w-3.5 h-3.5"}),"Dependencias"]}),jsx("div",{className:"flex flex-wrap gap-1.5 max-h-24 overflow-y-auto p-2 rounded-lg",style:{backgroundColor:m.bgSecondary},children:r.filter(z=>z.id!==a?.id).map(z=>{let re=R.dependencies?.includes(z.id);return jsx("button",{type:"button",onClick:()=>{let oe=re?(R.dependencies||[]).filter(xe=>xe!==z.id):[...R.dependencies||[],z.id];Fe("dependencies",oe);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:re?`${m.accent}30`:m.bgPrimary,color:re?m.accent:m.textSecondary,border:`1px solid ${re?m.accent:m.borderLight}`},disabled:n,children:z.name},z.id)})})]})]})})})]})]}),jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${m.border}`},children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:m.textSecondary},onMouseEnter:z=>z.currentTarget.style.backgroundColor=m.hoverBg,onMouseLeave:z=>z.currentTarget.style.backgroundColor="transparent",disabled:n,children:"Cancelar"}),jsx("button",{type:"submit",disabled:n,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:m.accent,color:"#FFF"},onMouseEnter:z=>!n&&(z.currentTarget.style.opacity="0.9"),onMouseLeave:z=>!n&&(z.currentTarget.style.opacity="1"),children:n?jsxs(Fragment,{children:[jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsx(Fragment,{children:c==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var xc=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
345
345
 
346
346
  AVAILABLE COMMANDS:
347
347
  1. move_task - Move a task to a different date
@@ -386,13 +386,13 @@ If ambiguous, ask for clarification in the message field.`;function kc(e){return
386
386
  ${wc(e).map(r=>{let o=r.startDate?r.startDate.toISOString().split("T")[0]:"no date",s=r.endDate?r.endDate.toISOString().split("T")[0]:"no date",n=r.dependencies?.length?`deps: [${r.dependencies.join(", ")}]`:"";return `- ${r.id}: "${r.name}" (${o} to ${s}, ${r.progress}%, ${r.status||"todo"}) ${n}`}).join(`
387
387
  `)}
388
388
 
389
- Today's date: ${new Date().toISOString().split("T")[0]}`}function wc(e){let t=[],a=r=>{for(let o of r)t.push(o),o.subtasks?.length&&a(o.subtasks);};return a(e),t}function ur(e,t){let a=wc(e),r=t.toLowerCase().trim(),o=a.find(c=>c.name.toLowerCase()===r);if(o)return o;let s=a.find(c=>c.name.toLowerCase().includes(r));if(s)return s;let n=r.split(/\s+/);return a.find(c=>{let p=c.name.toLowerCase();return n.every(i=>p.includes(i))})}function fi(e,t=new Date){let a=e.toLowerCase().trim(),r=new Date(t);if(r.setHours(0,0,0,0),a==="today"||a==="hoy")return r;if(a==="tomorrow"||a==="ma\xF1ana"){let g=new Date(r);return g.setDate(g.getDate()+1),g}if(a==="yesterday"||a==="ayer"){let g=new Date(r);return g.setDate(g.getDate()-1),g}if(a==="next week"||a==="la pr\xF3xima semana"){let g=new Date(r);return g.setDate(g.getDate()+7),g}let o=a.match(/(?:next\s+)?(monday|tuesday|wednesday|thursday|friday|saturday|sunday|lunes|martes|miércoles|miercoles|jueves|viernes|sábado|sabado|domingo)/i);if(o){let f={sunday:0,domingo:0,monday:1,lunes:1,tuesday:2,martes:2,wednesday:3,mi\u00E9rcoles:3,miercoles:3,thursday:4,jueves:4,friday:5,viernes:5,saturday:6,s\u00E1bado:6,sabado:6}[o[1].toLowerCase()];if(f!==void 0){let C=new Date(r),T=C.getDay(),m=f-T;return m<=0&&(m+=7),C.setDate(C.getDate()+m),C}}let s=a.match(/in\s+(\d+)\s+(day|week|month|día|dias|semana|semanas|mes|meses)s?/i);if(s&&s[1]&&s[2]){let g=parseInt(s[1],10),f=s[2].toLowerCase(),C=new Date(r);return f==="day"||f==="d\xEDa"||f==="dias"?C.setDate(C.getDate()+g):f==="week"||f==="semana"||f==="semanas"?C.setDate(C.getDate()+g*7):(f==="month"||f==="mes"||f==="meses")&&C.setMonth(C.getMonth()+g),C}if(a.match(/(\d{4})-(\d{2})-(\d{2})/))return new Date(a);let c=a.match(/(\d{1,2})\/(\d{1,2})\/(\d{4})/);if(c&&c[1]&&c[2]&&c[3]){let g=parseInt(c[1],10),f=parseInt(c[2],10)-1,C=parseInt(c[3],10);return new Date(C,f,g)}let p={enero:0,febrero:1,marzo:2,abril:3,mayo:4,junio:5,julio:6,agosto:7,septiembre:8,octubre:9,noviembre:10,diciembre:11},i=a.match(/(\d{1,2})\s+de\s+(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)(?:\s+de\s+(\d{4}))?/i);if(i&&i[1]&&i[2]){let g=parseInt(i[1],10),f=p[i[2].toLowerCase()],C=i[3]?parseInt(i[3],10):r.getFullYear();if(f!==void 0)return new Date(C,f,g)}let u={january:0,february:1,march:2,april:3,may:4,june:5,july:6,august:7,september:8,october:9,november:10,december:11},d=a.match(/(january|february|march|april|may|june|july|august|september|october|november|december)\s+(\d{1,2})(?:,?\s+(\d{4}))?/i);if(d&&d[1]&&d[2]){let g=u[d[1].toLowerCase()],f=parseInt(d[2],10),C=d[3]?parseInt(d[3],10):r.getFullYear();if(g!==void 0)return new Date(C,g,f)}return null}function hi(e){let a=e.toLowerCase().trim().match(/(\d+)\s*(day|week|month|día|dias|semana|semanas|mes|meses)s?/i);if(a&&a[1]&&a[2]){let r=parseInt(a[1],10),o=a[2].toLowerCase();if(o==="day"||o==="d\xEDa"||o==="dias")return r;if(o==="week"||o==="semana"||o==="semanas")return r*7;if(o==="month"||o==="mes"||o==="meses")return r*30}return null}function bi(e){let t=e.match(/(\d+)(?:\s*%)?/);if(t&&t[1]){let a=parseInt(t[1],10);return Math.max(0,Math.min(100,a))}return null}function Cc(e){let t=e.toLowerCase().trim();return t.includes("todo")||t.includes("pendiente")||t.includes("por hacer")?"todo":t.includes("in progress")||t.includes("in-progress")||t.includes("en progreso")||t.includes("working")||t.includes("trabajando")?"in-progress":t.includes("done")||t.includes("complete")||t.includes("finished")||t.includes("completado")||t.includes("terminado")||t.includes("hecho")?"completed":null}function Tc(e,t){let a=e.toLowerCase().trim(),r=a.match(/(?:move|mover|mueve)\s+(?:la\s+tarea\s+)?["""]?(.+?)["""]?\s+(?:to|a|para)\s+(?:la\s+fecha\s+)?(.+)/i);if(r&&r[1]&&r[2]){let i=r[1].trim(),u=r[2].trim(),d=ur(t,i),g=fi(u);if(!d)return {type:"move_task",taskName:i,message:`Could not find a task named "${i}". Please check the task name and try again.`,success:false,error:"Task not found"};if(!g)return {type:"move_task",taskId:d.id,taskName:d.name,message:`Could not parse the date "${u}". Try using formats like "next Monday", "in 3 days", or "2024-01-15".`,success:false,error:"Invalid date"};let f=d.startDate&&d.endDate?Math.round((d.endDate.getTime()-d.startDate.getTime())/(1e3*60*60*24)):1,C=new Date(g);return C.setDate(C.getDate()+f),{type:"move_task",taskId:d.id,taskName:d.name,updates:{startDate:g,endDate:C},message:`Moved "${d.name}" to ${g.toLocaleDateString()}.`,success:true}}let o=a.match(/(?:extend|extender|extiende|alargar)\s+["""]?(.+?)["""]?\s+(?:by|por)\s+(.+)/i);if(o&&o[1]&&o[2]){let i=o[1].trim(),u=o[2].trim(),d=ur(t,i),g=hi(u);if(!d)return {type:"resize_task",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"};if(!g||!d.endDate)return {type:"resize_task",taskId:d.id,taskName:d.name,message:`Could not parse the duration "${u}".`,success:false,error:"Invalid duration"};let f=new Date(d.endDate);return f.setDate(f.getDate()+g),{type:"resize_task",taskId:d.id,taskName:d.name,updates:{endDate:f},message:`Extended "${d.name}" by ${g} days. New end date: ${f.toLocaleDateString()}.`,success:true}}let s=a.match(/(?:set|establecer|poner)\s+["""]?(.+?)["""]?\s+(?:progress|progreso)\s+(?:to|a|en)\s+(.+)/i);if(s&&s[1]&&s[2]){let i=s[1].trim(),u=s[2].trim(),d=ur(t,i),g=bi(u);return d?g===null?{type:"set_progress",taskId:d.id,taskName:d.name,message:`Could not parse the progress value "${u}".`,success:false,error:"Invalid progress"}:{type:"set_progress",taskId:d.id,taskName:d.name,updates:{progress:g},message:`Set "${d.name}" progress to ${g}%.`,success:true}:{type:"set_progress",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"}}let n=a.match(/(?:rename|renombrar|cambiar nombre de)\s+["""]?(.+?)["""]?\s+(?:to|a|por)\s+["""]?(.+?)["""]?$/i);if(n&&n[1]&&n[2]){let i=n[1].trim(),u=n[2].trim(),d=ur(t,i);return d?{type:"rename_task",taskId:d.id,taskName:d.name,updates:{name:u},message:`Renamed "${d.name}" to "${u}".`,success:true}:{type:"rename_task",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"}}let c=a.match(/(?:link|vincular|conectar)\s+["""]?(.+?)["""]?\s+(?:to|a|con)\s+["""]?(.+?)["""]?$/i);if(c&&c[1]&&c[2]){let i=c[1].trim(),u=c[2].trim(),d=ur(t,i),g=ur(t,u);return d?g?{type:"link_tasks",taskId:g.id,taskName:g.name,dependencyFrom:d.id,dependencyTo:g.id,message:`Linked "${d.name}" \u2192 "${g.name}".`,success:true}:{type:"link_tasks",taskName:u,message:`Could not find a task named "${u}".`,success:false,error:"Target task not found"}:{type:"link_tasks",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Source task not found"}}let p=a.match(/(?:delete|eliminar|borrar|remove|quitar)\s+["""]?(.+?)["""]?$/i);if(p&&p[1]){let i=p[1].trim(),u=ur(t,i);return u?{type:"delete_task",taskId:u.id,taskName:u.name,message:`Deleted "${u.name}".`,success:true}:{type:"delete_task",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"}}return null}function Nc(e){if(!e||typeof e!="object")return {type:"unknown",message:"Invalid response from AI",success:false,error:"Invalid response format"};let t=e;return {type:t.type||"unknown",taskId:typeof t.taskId=="string"?t.taskId:void 0,taskName:typeof t.taskName=="string"?t.taskName:void 0,updates:t.updates,newTask:t.newTask,dependencyFrom:typeof t.dependencyFrom=="string"?t.dependencyFrom:void 0,dependencyTo:typeof t.dependencyTo=="string"?t.dependencyTo:void 0,message:typeof t.message=="string"?t.message:"Command processed",success:typeof t.success=="boolean"?t.success:false,error:typeof t.error=="string"?t.error:void 0}}function M0(e){if(e)switch(e.toUpperCase()){case "TODO":case "BLOCKED":return "todo";case "IN_PROGRESS":case "REVIEW":return "in-progress";case "DONE":return "completed";default:return "todo"}}function A0(e){switch(e){case "todo":return "TODO";case "in-progress":return "IN_PROGRESS";case "completed":return "DONE";default:return e||"TODO"}}function Fn(e,t=[],a=[]){let r=e.assignedUserIds?.map(u=>{let d=a.find(g=>g.id===u);return d?{name:d.name,initials:d.initials,color:d.color}:null}).filter(u=>u!==null),o=t.filter(u=>u.metadata?.parentCardId===e.id).map(u=>Fn(u,t,a)),s;e.dependencies&&(typeof e.dependencies[0]=="string"?s=e.dependencies:s=e.dependencies.filter(u=>u.type==="finish-to-start").map(u=>u.taskId));let n=u=>{if(u)return typeof u=="string"?new Date(u):u},c=n(e.startDate),p=n(e.endDate),i=e.metadata?.isMilestone===true||c&&p&&Math.abs(p.getTime()-c.getTime())<=864e5;return {id:e.id,name:e.title,startDate:c,endDate:p,progress:e.progress||0,status:M0(e.metadata?.status),assignees:r?.length?r:void 0,dependencies:s?.length?s:void 0,subtasks:o?.length?o:void 0,isExpanded:e.metadata?.isExpanded===true,isMilestone:i,isCriticalPath:e.metadata?.isCriticalPath===true}}function Dc(e,t=[]){let a;return e.assignees&&e.assignees.length>0&&(a=e.assignees.map(r=>t.find(s=>s.name===r.name||s.initials===r.initials)?.id).filter(r=>r!==void 0)),{id:e.id,title:e.name,startDate:e.startDate,endDate:e.endDate,progress:e.progress,assignedUserIds:a?.length?a:void 0,metadata:{status:A0(e.status),isExpanded:e.isExpanded,isMilestone:e.isMilestone,isCriticalPath:e.isCriticalPath}}}function Sc(e,t=[]){return e.filter(r=>!r.metadata?.parentCardId).map(r=>Fn(r,e,t))}var yi={columns:{name:"Task Name",startDate:"Start Date",endDate:"End Date",progress:"Progress",status:"Status",assignees:"Assignees",priority:"Priority",actions:"Actions"},toolbar:{search:"Search",searchPlaceholder:"Search tasks...",filter:"Filter",clearFilters:"Clear Filters",export:"Export",columns:"Columns",newTask:"New Task"},filters:{status:"Status",assignees:"Assignees",dateRange:"Date Range",showCompleted:"Show Completed",all:"All",none:"None"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},actions:{edit:"Edit",delete:"Delete",duplicate:"Duplicate",viewDetails:"View Details"},empty:{noTasks:"No tasks yet",noResults:"No tasks match your filters",addFirstTask:"Add your first task"},pagination:{showing:"Showing",of:"of",tasks:"tasks",previous:"Previous",next:"Next"},bulk:{selected:"selected",delete:"Delete",move:"Move to",assignTo:"Assign to"}},vi={columns:{name:"Nombre de Tarea",startDate:"Fecha Inicio",endDate:"Fecha Fin",progress:"Progreso",status:"Estado",assignees:"Asignados",priority:"Prioridad",actions:"Acciones"},toolbar:{search:"Buscar",searchPlaceholder:"Buscar tareas...",filter:"Filtrar",clearFilters:"Limpiar Filtros",export:"Exportar",columns:"Columnas",newTask:"Nueva Tarea"},filters:{status:"Estado",assignees:"Asignados",dateRange:"Rango de Fechas",showCompleted:"Mostrar Completadas",all:"Todos",none:"Ninguno"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},actions:{edit:"Editar",delete:"Eliminar",duplicate:"Duplicar",viewDetails:"Ver Detalles"},empty:{noTasks:"Sin tareas a\xFAn",noResults:"Ninguna tarea coincide con los filtros",addFirstTask:"Agrega tu primera tarea"},pagination:{showing:"Mostrando",of:"de",tasks:"tareas",previous:"Anterior",next:"Siguiente"},bulk:{selected:"seleccionadas",delete:"Eliminar",move:"Mover a",assignTo:"Asignar a"}},In={en:yi,es:vi};function xi(e){return In[e]||In.en}function Ln(e,t){let a=xi(e);return t?{columns:{...a.columns,...t.columns},toolbar:{...a.toolbar,...t.toolbar},filters:{...a.filters,...t.filters},status:{...a.status,...t.status},actions:{...a.actions,...t.actions},empty:{...a.empty,...t.empty},pagination:{...a.pagination,...t.pagination},bulk:{...a.bulk,...t.bulk}}:a}function Ac(e,t=0){let a=[];for(let r of e)a.push({...r,level:t,hasChildren:(r.subtasks?.length||0)>0,parentPath:[r.id]}),r.subtasks?.length&&r.isExpanded!==false&&a.push(...Ac(r.subtasks,t+1));return a}function W0({status:e,progress:t}){return t===100||e==="completed"?jsx(CheckCircle2,{className:"w-5 h-5 text-green-500"}):t&&t>0||e==="in-progress"?jsx(PlayCircle,{className:"w-5 h-5 text-blue-500"}):jsx(Circle,{className:"w-5 h-5 text-gray-400"})}function Fc({tasks:e,config:t={},callbacks:a={},isLoading:r=false,error:o,className:s,style:n}){let{theme:c="dark",locale:p="en",customTranslations:i,showSearch:u=true,showHierarchy:d=true}=t,g=Ln(p,i),f=c==="dark",[C,T]=useState(new Set),[m,b]=useState("startDate"),[y,l]=useState("asc"),[w,v]=useState("");useMemo(()=>{let A=new Set;function N(H){for(let L of H)L.subtasks?.length&&(A.add(L.id),N(L.subtasks));}N(e),T(A);},[e]);let S=useCallback(A=>{T(N=>{let H=new Set(N);return H.has(A)?H.delete(A):H.add(A),H}),a.onTaskToggleExpand?.(A);},[a]),x=useCallback(A=>{m===A?l(N=>N==="asc"?"desc":"asc"):(b(A),l("asc")),a.onSortChange?.({column:A,direction:y==="asc"?"desc":"asc"});},[m,y,a]),k=useMemo(()=>{let A=Ac(e);if(w.trim()){let H=w.toLowerCase();A=A.filter(L=>L.name.toLowerCase().includes(H));}let N=[];for(let H of A){let L=H.level===0;H.level>0&&(L=true),(L||w.trim())&&N.push(H);}return w.trim()&&N.sort((H,L)=>{let q,ae;switch(m){case "name":q=H.name.toLowerCase(),ae=L.name.toLowerCase();break;case "startDate":q=H.startDate?.getTime()||0,ae=L.startDate?.getTime()||0;break;case "endDate":q=H.endDate?.getTime()||0,ae=L.endDate?.getTime()||0;break;case "progress":q=H.progress||0,ae=L.progress||0;break;case "status":q=H.status||"todo",ae=L.status||"todo";break;default:return 0}return q<ae?y==="asc"?-1:1:q>ae?y==="asc"?1:-1:0}),N},[e,w,m,y]),O=A=>A?(A instanceof Date?A:new Date(A)).toLocaleDateString(p==="es"?"es-ES":"en-US",{day:"numeric",month:"short"}):"-";return r?jsx("div",{className:h("flex-1 flex items-center justify-center",f?"bg-[#0F1117]":"bg-white",s),style:n,children:jsxs("div",{className:"flex flex-col items-center gap-4",children:[jsx("div",{className:"w-8 h-8 animate-spin rounded-full border-b-2 border-[#3B82F6]"}),jsxs("p",{className:h("text-sm",f?"text-[#9CA3AF]":"text-gray-600"),children:[g.empty.noTasks,"..."]})]})}):o?jsx("div",{className:h("flex-1 flex items-center justify-center",f?"bg-[#0F1117]":"bg-white",s),style:n,children:jsxs("div",{className:"flex flex-col items-center gap-4 max-w-md text-center",children:[jsx("div",{className:"w-12 h-12 rounded-full bg-red-500/10 flex items-center justify-center",children:jsx("span",{className:"text-red-500 text-2xl",children:"\u26A0"})}),jsxs("div",{children:[jsx("h3",{className:h("text-lg font-semibold mb-2",f?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:h("text-sm",f?"text-[#9CA3AF]":"text-gray-600"),children:typeof o=="string"?o:o.message})]})]})}):e.length===0?jsx("div",{className:h("flex-1 flex items-center justify-center",f?"bg-[#0F1117]":"bg-white",s),style:n,children:jsxs("div",{className:"text-center max-w-md",children:[jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-2xl bg-[#3B82F6]/10 flex items-center justify-center",children:jsx(List,{className:"w-8 h-8 text-[#3B82F6]"})}),jsx("h3",{className:h("text-lg font-semibold mb-2",f?"text-white":"text-gray-900"),children:g.empty.noTasks}),jsx("p",{className:h("text-sm",f?"text-[#9CA3AF]":"text-gray-600"),children:g.empty.addFirstTask})]})}):jsxs("div",{className:h("flex-1 flex flex-col w-full h-full overflow-hidden",f?"bg-[#0F1117]":"bg-white",s),style:n,children:[jsx("div",{className:h("flex-shrink-0 px-6 py-4 border-b",f?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-center gap-4",children:[u&&jsxs("div",{className:"relative flex-1 max-w-md",children:[jsx(Search,{className:h("absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4",f?"text-[#9CA3AF]":"text-gray-400")}),jsx("input",{type:"text",value:w,onChange:A=>v(A.target.value),placeholder:g.toolbar.searchPlaceholder,className:h("w-full h-9 pl-10 pr-4 rounded-lg border outline-none focus:ring-2 focus:ring-[#3B82F6]/30",f?"bg-white/5 border-white/10 text-white placeholder:text-[#6B7280]":"bg-gray-100 border-gray-200 text-gray-900 placeholder:text-gray-400")})]}),jsxs("div",{className:h("text-sm",f?"text-[#9CA3AF]":"text-gray-600"),children:[k.length," ",g.pagination.tasks]})]})}),jsxs("div",{className:h("flex-shrink-0 grid grid-cols-12 gap-4 px-6 py-3 border-b text-xs font-medium uppercase tracking-wider",f?"border-white/10 bg-white/5 text-[#9CA3AF]":"border-gray-200 bg-gray-50 text-gray-500"),children:[jsx("div",{className:"col-span-5 flex items-center gap-2",children:jsxs("button",{onClick:()=>x("name"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[g.columns.name,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>x("status"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[g.columns.status,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>x("startDate"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[g.columns.startDate,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>x("endDate"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[g.columns.endDate,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-1 flex items-center gap-1",children:jsxs("button",{onClick:()=>x("progress"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:["%",jsx(ArrowUpDown,{className:"w-3 h-3"})]})})]}),jsxs("div",{className:"flex-1 overflow-auto",children:[jsx(AnimatePresence,{children:k.map((A,N)=>{let H=C.has(A.id);return jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{delay:N*.02},className:h("grid grid-cols-12 gap-4 px-6 py-3 border-b transition-colors cursor-pointer",f?"border-white/5 hover:bg-white/5":"border-gray-100 hover:bg-gray-50"),style:{paddingLeft:d?`${24+A.level*24}px`:void 0},onClick:()=>a.onTaskClick?.(A),onDoubleClick:()=>a.onTaskDoubleClick?.(A),children:[jsxs("div",{className:"col-span-5 flex items-center gap-2 min-w-0",children:[d&&A.hasChildren&&jsx("button",{onClick:L=>{L.stopPropagation(),S(A.id);},className:h("p-0.5 rounded",f?"hover:bg-white/10":"hover:bg-gray-200"),children:H?jsx(ChevronDown,{className:h("w-4 h-4",f?"text-[#9CA3AF]":"text-gray-400")}):jsx(ChevronRight,{className:h("w-4 h-4",f?"text-[#9CA3AF]":"text-gray-400")})}),d&&!A.hasChildren&&jsx("div",{className:"w-5"}),jsx("button",{onClick:L=>{L.stopPropagation(),a.onTaskUpdate?.({...A,progress:A.progress===100?0:100,status:A.progress===100?"todo":"completed"});},className:"flex-shrink-0",children:jsx(W0,{status:A.status,progress:A.progress})}),jsx("span",{className:h("truncate",f?"text-white":"text-gray-900",A.progress===100&&(f?"line-through text-[#6B7280]":"line-through text-gray-400")),children:A.name})]}),jsx("div",{className:"col-span-2 flex items-center",children:jsx("span",{className:h("px-2 py-1 rounded-full text-xs font-medium",A.progress===100||A.status==="completed"?"bg-green-500/10 text-green-500":A.progress&&A.progress>0||A.status==="in-progress"?"bg-blue-500/10 text-blue-500":f?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:A.progress===100||A.status==="completed"?g.status.completed:A.progress&&A.progress>0||A.status==="in-progress"?g.status.inProgress:g.status.todo})}),jsxs("div",{className:h("col-span-2 flex items-center gap-1 text-sm",f?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Calendar,{className:"w-4 h-4"}),O(A.startDate)]}),jsxs("div",{className:h("col-span-2 flex items-center gap-1 text-sm",f?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Clock,{className:"w-4 h-4"}),O(A.endDate)]}),jsx("div",{className:"col-span-1 flex items-center",children:jsxs("div",{className:"flex items-center gap-2 w-full",children:[jsx("div",{className:h("flex-1 h-1.5 rounded-full overflow-hidden",f?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:h("h-full rounded-full transition-all",A.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${A.progress||0}%`}})}),jsxs("span",{className:h("text-xs w-8",f?"text-[#9CA3AF]":"text-gray-500"),children:[A.progress||0,"%"]})]})})]},A.id)})}),k.length===0&&w&&jsx("div",{className:"flex items-center justify-center py-12",children:jsxs("div",{className:"text-center",children:[jsx(List,{className:h("w-12 h-12 mx-auto mb-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:h(f?"text-[#9CA3AF]":"text-gray-600"),children:g.empty.noResults})]})})]})]})}var ki={bgPrimary:"#0d1117",bgSecondary:"#161b22",bgHover:"#21262d",bgSelected:"#1f6feb20",bgAlternate:"#0d111780",border:"#30363d",borderLight:"#21262d",textPrimary:"#c9d1d9",textSecondary:"#8b949e",textMuted:"#6e7681",accent:"#58a6ff",accentHover:"#79b8ff",accentLight:"#58a6ff20",statusTodo:"#8b949e",statusInProgress:"#f0883e",statusCompleted:"#3fb950",focusRing:"#58a6ff",checkboxBg:"#21262d",checkboxChecked:"#58a6ff"},wi={bgPrimary:"#ffffff",bgSecondary:"#f6f8fa",bgHover:"#f3f4f6",bgSelected:"#dbeafe",bgAlternate:"#f9fafb",border:"#d0d7de",borderLight:"#e5e7eb",textPrimary:"#24292f",textSecondary:"#57606a",textMuted:"#8b949e",accent:"#0969da",accentHover:"#0550ae",accentLight:"#dbeafe",statusTodo:"#8b949e",statusInProgress:"#bf8700",statusCompleted:"#1a7f37",focusRing:"#0969da",checkboxBg:"#ffffff",checkboxChecked:"#0969da"},Ci={bgPrimary:"#1a1a2e",bgSecondary:"#16213e",bgHover:"#1f3460",bgSelected:"#0f4c7520",bgAlternate:"#1a1a2e80",border:"#2a3f5f",borderLight:"#1f3460",textPrimary:"#e4e6eb",textSecondary:"#a8b2c1",textMuted:"#6b7280",accent:"#6366f1",accentHover:"#818cf8",accentLight:"#6366f120",statusTodo:"#9ca3af",statusInProgress:"#fbbf24",statusCompleted:"#34d399",focusRing:"#6366f1",checkboxBg:"#1f3460",checkboxChecked:"#6366f1"},Rn={dark:ki,light:wi,neutral:Ci};function Ic(e){return Rn[e]||Rn.dark}var Ti={navigation:{today:"Today",previous:"Previous",next:"Next",month:"Month",week:"Week",day:"Day"},weekdays:{sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},weekdaysFull:{sunday:"Sunday",monday:"Monday",tuesday:"Tuesday",wednesday:"Wednesday",thursday:"Thursday",friday:"Friday",saturday:"Saturday"},months:{january:"January",february:"February",march:"March",april:"April",may:"May",june:"June",july:"July",august:"August",september:"September",october:"October",november:"November",december:"December"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},labels:{allDay:"All day",moreEvents:"+{count} more",noEvents:"No tasks",newTask:"New Task",viewAll:"View all",week:"Week"},tooltips:{progress:"Progress",status:"Status",assignees:"Assignees",duration:"Duration",days:"days"}},Ni={navigation:{today:"Hoy",previous:"Anterior",next:"Siguiente",month:"Mes",week:"Semana",day:"D\xEDa"},weekdays:{sun:"Dom",mon:"Lun",tue:"Mar",wed:"Mi\xE9",thu:"Jue",fri:"Vie",sat:"S\xE1b"},weekdaysFull:{sunday:"Domingo",monday:"Lunes",tuesday:"Martes",wednesday:"Mi\xE9rcoles",thursday:"Jueves",friday:"Viernes",saturday:"S\xE1bado"},months:{january:"Enero",february:"Febrero",march:"Marzo",april:"Abril",may:"Mayo",june:"Junio",july:"Julio",august:"Agosto",september:"Septiembre",october:"Octubre",november:"Noviembre",december:"Diciembre"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},labels:{allDay:"Todo el d\xEDa",moreEvents:"+{count} m\xE1s",noEvents:"Sin tareas",newTask:"Nueva Tarea",viewAll:"Ver todo",week:"Semana"},tooltips:{progress:"Progreso",status:"Estado",assignees:"Asignados",duration:"Duraci\xF3n",days:"d\xEDas"}},On={en:Ti,es:Ni};function zo(e){return On[e]||On.en}function zn(e,t){let a=zo(e);return t?{navigation:{...a.navigation,...t.navigation},weekdays:{...a.weekdays,...t.weekdays},weekdaysFull:{...a.weekdaysFull,...t.weekdaysFull},months:{...a.months,...t.months},status:{...a.status,...t.status},labels:{...a.labels,...t.labels},tooltips:{...a.tooltips,...t.tooltips}}:a}function Lc(e){let t=zo(e);return [t.months.january,t.months.february,t.months.march,t.months.april,t.months.may,t.months.june,t.months.july,t.months.august,t.months.september,t.months.october,t.months.november,t.months.december]}function Bc(e,t=0,a=true){let r=zo(e),o=a?[r.weekdays.sun,r.weekdays.mon,r.weekdays.tue,r.weekdays.wed,r.weekdays.thu,r.weekdays.fri,r.weekdays.sat]:[r.weekdaysFull.sunday,r.weekdaysFull.monday,r.weekdaysFull.tuesday,r.weekdaysFull.wednesday,r.weekdaysFull.thursday,r.weekdaysFull.friday,r.weekdaysFull.saturday];return [...o.slice(t),...o.slice(0,t)]}function sh(e){let t=[];function a(r){for(let o of r)t.push(o),o.subtasks?.length&&a(o.subtasks);}return a(e),t}function Ai(e,t){if(!t.startDate||!t.endDate)return false;let a=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(t.startDate.getFullYear(),t.startDate.getMonth(),t.startDate.getDate()),o=new Date(t.endDate.getFullYear(),t.endDate.getMonth(),t.endDate.getDate());return a>=r&&a<=o}function $c({task:e}){return e.progress===100||e.status==="completed"?jsx(CheckCircle2,{className:"w-3 h-3 text-green-500 flex-shrink-0"}):e.progress&&e.progress>0||e.status==="in-progress"?jsx(PlayCircle,{className:"w-3 h-3 text-blue-500 flex-shrink-0"}):jsx(Circle,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})}function Wc({tasks:e,config:t={},callbacks:a={},initialDate:r,isLoading:o=false,error:s,className:n,style:c,availableTags:p=[],onCreateTag:i,attachmentsByTask:u,comments:d,onAddComment:g,currentUser:f,onTaskOpen:C}){let{theme:T="dark",locale:m="en",customTranslations:b}=t,y=zn(m,b),l=T==="dark",w={textTertiary:l?"#6B7280":"#9CA3AF",textSecondary:l?"#9CA3AF":"#6B7280",textPrimary:l?"#FFFFFF":"#111827",borderLight:l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",border:l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",bgPrimary:l?"#1A1D25":"#FFFFFF",bgSecondary:l?"#0F1117":"#F9FAFB",hoverBg:l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},[v,S]=useState(r||new Date),[x,k]=useState(null),[O,A]=useState(null),[N,H]=useState(null),[L,q]=useState(new Date),[ae,ke]=useState({}),Fe=4,Ve=3,[Je,$]=useState(false),[B,W]=useState(false),[D,Y]=useState(false),[J,R]=useState(false),[ce,we]=useState(null),[Ie,me]=useState(""),[He,Le]=useState(void 0),[Ye,pt]=useState(null),[bt,it]=useState(false),[z,oe]=useState(false),[ne,xe]=useState(null),[Ne,at]=useState(false),[ft,Be]=useState(new Date),[he,Pe]=useState(false),[Mt,ht]=useState(false),[oa,ma]=useState(false),[Ue,Oe]=useState(""),[na,ge]=useState(false),E=useCallback(()=>{S(new Date(v.getFullYear(),v.getMonth()-1,1));},[v]),Z=useCallback(()=>{S(new Date(v.getFullYear(),v.getMonth()+1,1));},[v]),be=useCallback(()=>{S(new Date);},[]),Te=useMemo(()=>{let M=v.getFullYear(),te=v.getMonth(),Re=new Date(M,te,1),lt=new Date(M,te+1,0),Et=Re.getDay(),se=lt.getDate(),j=sh(e),_e=new Date;_e.setHours(0,0,0,0);let De=[],ta=Et,sa=new Date(M,te,0).getDate();for(let kt=ta-1;kt>=0;kt--){let ze=new Date(M,te-1,sa-kt);De.push({date:ze,isCurrentMonth:false,isToday:false,isWeekend:ze.getDay()===0||ze.getDay()===6,events:j.filter(Ze=>Ai(ze,Ze)).map(Ze=>({id:Ze.id,title:Ze.name,start:Ze.startDate,end:Ze.endDate,task:Ze}))});}for(let kt=1;kt<=se;kt++){let ze=new Date(M,te,kt),Ze=ze.getTime()===_e.getTime();De.push({date:ze,isCurrentMonth:true,isToday:Ze,isWeekend:ze.getDay()===0||ze.getDay()===6,events:j.filter(jt=>Ai(ze,jt)).map(jt=>({id:jt.id,title:jt.name,start:jt.startDate,end:jt.endDate,task:jt}))});}let Yt=42-De.length;for(let kt=1;kt<=Yt;kt++){let ze=new Date(M,te+1,kt);De.push({date:ze,isCurrentMonth:false,isToday:false,isWeekend:ze.getDay()===0||ze.getDay()===6,events:j.filter(Ze=>Ai(ze,Ze)).map(Ze=>({id:Ze.id,title:Ze.name,start:Ze.startDate,end:Ze.endDate,task:Ze}))});}return De},[v,e]),qe=m==="es"?["Dom","Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b"]:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],We=v.toLocaleDateString(m==="es"?"es-ES":"en-US",{month:"long",year:"numeric"}),Ee=useCallback((M,te)=>{if(!x)return;let Re={...x,[M]:te};k(Re),a.onTaskUpdate?.(Re);},[x,a]),rt=useCallback(M=>{if(!x)return;let te=x.progress||0;M==="completed"?te=100:M==="todo"&&(te=0);let Re={...x,status:M,progress:te};k(Re),a.onTaskUpdate?.(Re),$(false);},[x,a]),st=useCallback((M,te)=>{if(!x)return;let Re={...x,startDate:M,endDate:te};k(Re),a.onTaskUpdate?.(Re);},[x,a]),V=useCallback(()=>{$(false),W(false),Y(false),H(null),ma(false),Oe(""),ge(false);},[]),re=useCallback(async M=>{if(M.preventDefault(),M.stopPropagation(),Pe(false),!x||!a.onUploadAttachments)return;let te=Array.from(M.dataTransfer.files);if(te.length!==0){ht(true);try{await a.onUploadAttachments(x.id,te);}finally{ht(false);}}},[x,a]),Me=useCallback(async M=>{if(!x||!a.onUploadAttachments||!M.target.files)return;let te=Array.from(M.target.files);if(te.length!==0){ht(true);try{await a.onUploadAttachments(x.id,te);}finally{ht(false);}M.target.value="";}},[x,a]),Xe=useCallback(M=>{M.preventDefault(),M.stopPropagation(),Pe(true);},[]),$e=useCallback(M=>{M.preventDefault(),M.stopPropagation(),Pe(false);},[]),G=useCallback(M=>M<1024?`${M} B`:M<1024*1024?`${(M/1024).toFixed(1)} KB`:`${(M/(1024*1024)).toFixed(1)} MB`,[]),ee=useCallback(M=>M.startsWith("image/")?Image:M.includes("pdf")||M.includes("document")?FileText:File,[]),Ae=useMemo(()=>!x||!u?[]:u.get(x.id)||[],[x,u]);return o?jsx("div",{className:h("flex-1 flex items-center justify-center",l?"bg-[#0F1117]":"bg-white",n),style:c,children:jsxs("div",{className:"flex flex-col items-center gap-4",children:[jsx("div",{className:"w-8 h-8 animate-spin rounded-full border-b-2 border-[#3B82F6]"}),jsxs("p",{className:h("text-sm",l?"text-[#9CA3AF]":"text-gray-600"),children:[y.labels.noEvents,"..."]})]})}):s?jsx("div",{className:h("flex-1 flex items-center justify-center",l?"bg-[#0F1117]":"bg-white",n),style:c,children:jsxs("div",{className:"flex flex-col items-center gap-4 max-w-md text-center",children:[jsx("div",{className:"w-12 h-12 rounded-full bg-red-500/10 flex items-center justify-center",children:jsx("span",{className:"text-red-500 text-2xl",children:"\u26A0"})}),jsxs("div",{children:[jsx("h3",{className:h("text-lg font-semibold mb-2",l?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:h("text-sm",l?"text-[#9CA3AF]":"text-gray-600"),children:typeof s=="string"?s:s.message})]})]})}):e.length===0?jsx("div",{className:h("flex-1 flex items-center justify-center",l?"bg-[#0F1117]":"bg-white",n),style:c,children:jsxs("div",{className:"text-center max-w-md",children:[jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-2xl bg-[#3B82F6]/10 flex items-center justify-center",children:jsx(Calendar,{className:"w-8 h-8 text-[#3B82F6]"})}),jsx("h3",{className:h("text-lg font-semibold mb-2",l?"text-white":"text-gray-900"),children:y.labels.noEvents}),jsx("p",{className:h("text-sm",l?"text-[#9CA3AF]":"text-gray-600"),children:y.labels.newTask})]})}):jsxs("div",{className:h("flex-1 flex flex-col w-full h-full overflow-auto",l?"bg-[#0F1117]":"bg-white",n),style:c,children:[jsx("div",{className:h("flex-shrink-0 px-6 py-4 border-b",l?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-4",children:[jsx("h2",{className:h("text-xl font-semibold capitalize",l?"text-white":"text-gray-900"),children:We}),jsx("button",{onClick:be,className:h("px-3 py-1.5 text-sm rounded-lg transition-colors",l?"bg-white/5 text-white hover:bg-white/10":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:y.navigation.today})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("button",{onClick:E,className:h("p-2 rounded-lg transition-colors",l?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:h("w-5 h-5",l?"text-[#9CA3AF]":"text-gray-600")})}),jsx("button",{onClick:Z,className:h("p-2 rounded-lg transition-colors",l?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:h("w-5 h-5",l?"text-[#9CA3AF]":"text-gray-600")})})]})]})}),jsx("div",{className:"flex-1 p-6 min-h-0",children:jsxs("div",{className:"flex flex-col",children:[jsx("div",{className:"grid grid-cols-7 gap-px mb-2",children:qe.map(M=>jsx("div",{className:h("py-2 text-center text-xs font-medium uppercase",l?"text-[#9CA3AF]":"text-gray-500"),children:M},M))}),jsx("div",{className:h("grid grid-cols-7 auto-rows-min gap-px rounded-lg",l?"bg-[#2D2D2D]":"bg-gray-300"),children:Te.map((M,te)=>{let Re=M.date.getDay()===0||M.date.getDay()===6;return jsxs("div",{className:h("min-h-[120px] p-2 transition-colors flex flex-col relative group",l?Re?"bg-[#1C1F26]":M.isCurrentMonth?"bg-[#13161B]":"bg-[#0D0F13]":Re?"bg-gray-100":M.isCurrentMonth?"bg-white":"bg-gray-50",M.isToday&&"ring-2 ring-[#3B82F6] ring-inset"),children:[(()=>{let lt=ae[te]||Fe,Et=M.events.slice(0,lt),se=M.events.length-lt;return jsxs("div",{className:"space-y-1 flex-1",children:[Et.map(j=>jsx("div",{className:"relative group",children:jsxs(motion.button,{onClick:()=>{k(j.task),a.onEventClick?.(j),C?.(j.task.id);},whileHover:{scale:1.02},className:h("w-full flex items-center gap-1 px-1.5 py-0.5 rounded text-xs truncate",j.task.progress===100?l?"bg-green-500/20 text-green-400":"bg-green-500/10 text-green-600":l?"bg-[#3B82F6]/20 text-[#3B82F6]":"bg-[#3B82F6]/10 text-[#3B82F6]"),children:[jsx($c,{task:j.task}),jsx("span",{className:"truncate",children:j.title})]})},j.id)),se>0&&jsxs("button",{onClick:j=>{j.stopPropagation(),ke(_e=>({..._e,[te]:lt+Ve}));},className:h("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",l?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:["+",se," ",m==="es"?"M\xC1S":"MORE"]}),lt>Fe&&M.events.length>Fe&&jsx("button",{onClick:j=>{j.stopPropagation(),ke(_e=>({..._e,[te]:Fe}));},className:h("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",l?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:m==="es"?"MENOS":"LESS"})]})})(),jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1",children:[(()=>{let lt=te>=28,Et=te%7>=5;return jsxs("div",{className:"relative",children:[jsx("button",{onClick:se=>{se.stopPropagation(),ce===te?we(null):(we(te),me(""),Le(void 0),pt(null),xe(null),it(false),oe(false),at(false),Be(M.date));},className:h("w-5 h-5 rounded flex items-center justify-center transition-all",ce===te?"opacity-100 bg-[#7C3AED] text-white":"opacity-0 group-hover:opacity-100",l?"hover:bg-[#7C3AED] text-[#6B7280] hover:text-white":"hover:bg-[#7C3AED] text-gray-400 hover:text-white"),children:jsx(Plus,{className:h("w-3.5 h-3.5 transition-transform",ce===te&&"rotate-45")})}),jsx(AnimatePresence,{children:ce===te&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{we(null),me(""),Le(void 0),pt(null),xe(null),it(false),oe(false),at(false);}}),jsxs(motion.div,{initial:{opacity:0,y:lt?-5:5,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:lt?-5:5,scale:.95},transition:{duration:.12},className:h("absolute w-[320px] rounded-lg shadow-2xl z-50",lt?"bottom-full mb-1":"top-full mt-1",Et?"right-0":"left-0",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:se=>{se.stopPropagation(),it(false),oe(false),at(false);},children:[jsx("div",{className:"p-2.5",children:jsx("input",{type:"text",value:Ie,onChange:se=>me(se.target.value),placeholder:m==="es"?'Escribe el nombre de la tarea o "/" para los comandos':'Type task name or "/" for commands',className:h("w-full bg-transparent text-sm outline-none placeholder:opacity-40",l?"text-white":"text-gray-900"),autoFocus:true,onKeyDown:se=>{if(se.key==="Enter"&&Ie.trim()){let j=t.availableUsers?.find(De=>De.id===Ye),_e=ne||M.date;a.onTaskCreate?.({name:Ie.trim(),startDate:_e,endDate:_e,priority:He,assignees:j?[j]:void 0}),me(""),Le(void 0),pt(null),xe(null),we(null);}se.key==="Escape"&&(we(null),me(""),Le(void 0),pt(null),xe(null));}})}),jsxs("div",{className:h("px-2.5 py-2 flex items-center justify-between border-t",l?"border-white/10":"border-gray-100"),children:[jsxs("div",{className:"flex items-center gap-1",children:[jsxs("div",{className:"relative",children:[jsx("button",{onClick:se=>{se.stopPropagation(),it(!bt),oe(false);},className:h("p-1 rounded transition-colors",He?He==="urgent"||He==="high"?"text-red-400 bg-red-500/20":He==="medium"?"text-yellow-400 bg-yellow-500/20":"text-green-400 bg-green-500/20":l?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:jsx(Flag,{className:"w-3.5 h-3.5"})}),jsx(AnimatePresence,{children:bt&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:h("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[120px]",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:se=>se.stopPropagation(),children:[{id:"urgent",label:m==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:m==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:m==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:m==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:m==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(se=>jsxs("button",{onClick:()=>{Le(se.id),it(false);},className:h("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",l?"hover:bg-white/5":"hover:bg-gray-50",He===se.id&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:h("w-2 h-2 rounded-full",se.color)}),jsx("span",{className:l?"text-white":"text-gray-900",children:se.label})]},se.id||"none"))})})]}),jsxs("div",{className:"relative",children:[jsxs("button",{onClick:se=>{se.stopPropagation(),at(!Ne),it(false),oe(false),Be(ne||M.date);},className:h("flex items-center gap-1 text-xs px-1.5 py-0.5 rounded transition-colors",ne?"bg-[#7C3AED]/20 text-[#7C3AED]":l?"bg-white/5 text-[#9CA3AF] hover:bg-white/10":"bg-gray-100 text-gray-500 hover:bg-gray-200"),children:[jsx(CalendarDays,{className:"w-3 h-3"}),(ne||M.date).toLocaleDateString(m==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})]}),jsx(AnimatePresence,{children:Ne&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:h("absolute left-0 bottom-full mb-1 z-[60] rounded-xl shadow-2xl overflow-hidden flex",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:se=>se.stopPropagation(),children:[jsx("div",{className:h("w-40 py-2 border-r",l?"border-white/10":"border-gray-200"),children:(()=>{let se=new Date,j=new Date(se);j.setDate(se.getDate()+1);let _e=new Date(se);_e.setDate(se.getDate()+((6-se.getDay()+7)%7||7));let De=new Date(se);De.setDate(se.getDate()+((1-se.getDay()+7)%7||7));let ta=new Date(se);ta.setDate(se.getDate()+14);let sa=new Date(se);return sa.setDate(se.getDate()+28),[{label:m==="es"?"Hoy":"Today",date:se,display:se.toLocaleDateString(m==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:m==="es"?"Ma\xF1ana":"Tomorrow",date:j,display:j.toLocaleDateString(m==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:m==="es"?"Este fin de semana":"This weekend",date:_e,display:m==="es"?"s\xE1b.":"sat."},{label:m==="es"?"Pr\xF3xima semana":"Next week",date:De,display:m==="es"?"lun.":"mon."},{label:m==="es"?"2 semanas":"2 weeks",date:ta,display:ta.toLocaleDateString(m==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:m==="es"?"4 semanas":"4 weeks",date:sa,display:sa.toLocaleDateString(m==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((kt,ze)=>jsxs("button",{className:h("w-full flex items-center justify-between px-3 py-1.5 text-xs transition-colors",l?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{xe(kt.date),at(false);},children:[jsx("span",{children:kt.label}),jsx("span",{className:h("text-[10px]",l?"text-[#6B7280]":"text-gray-400"),children:kt.display})]},ze))})()}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("span",{className:h("text-xs font-medium",l?"text-white":"text-gray-900"),children:ft.toLocaleDateString(m==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-0.5",children:[jsx("button",{onClick:()=>Be(new Date),className:h("px-1.5 py-0.5 rounded text-[10px] transition-colors",l?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:m==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>Be(new Date(ft.getFullYear(),ft.getMonth()-1)),className:h("p-0.5 rounded",l?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:()=>Be(new Date(ft.getFullYear(),ft.getMonth()+1)),className:h("p-0.5 rounded",l?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:"w-3.5 h-3.5"})})]})]}),jsx("div",{className:"grid grid-cols-7 gap-0.5 mb-1",children:(m==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(se=>jsx("div",{className:h("w-6 h-6 flex items-center justify-center text-[10px]",l?"text-[#6B7280]":"text-gray-400"),children:se},se))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let se=ft.getFullYear(),j=ft.getMonth(),_e=new Date(se,j,1).getDay(),De=new Date(se,j+1,0).getDate(),ta=new Date(se,j,0).getDate(),sa=new Date,Yt=[];for(let ze=_e-1;ze>=0;ze--)Yt.push({dayNum:ta-ze,isCurrentMonth:false,date:new Date(se,j-1,ta-ze)});for(let ze=1;ze<=De;ze++)Yt.push({dayNum:ze,isCurrentMonth:true,date:new Date(se,j,ze)});let kt=42-Yt.length;for(let ze=1;ze<=kt;ze++)Yt.push({dayNum:ze,isCurrentMonth:false,date:new Date(se,j+1,ze)});return Yt.map((ze,Ze)=>{let jt=ze.date.toDateString()===sa.toDateString(),tr=(ne||M.date).toDateString()===ze.date.toDateString();return jsx("button",{className:h("w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",!ze.isCurrentMonth&&(l?"text-[#4B5563]":"text-gray-300"),ze.isCurrentMonth&&(l?"text-white":"text-gray-900"),jt&&"ring-1 ring-[#3B82F6]",tr&&"bg-[#7C3AED] text-white",!tr&&(l?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{xe(ze.date),at(false);},children:ze.dayNum},Ze)})})()})]})]})})]}),jsxs("div",{className:"relative",children:[jsx("button",{onClick:se=>{se.stopPropagation(),oe(!z),it(false);},className:h("p-1 rounded transition-colors",Ye?"text-[#7C3AED] bg-[#7C3AED]/20":l?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:Ye?jsx("div",{className:"w-4 h-4 rounded-full flex items-center justify-center text-white text-[8px] font-medium",style:{backgroundColor:t.availableUsers?.find(se=>se.id===Ye)?.color||"#7C3AED"},children:t.availableUsers?.find(se=>se.id===Ye)?.initials||t.availableUsers?.find(se=>se.id===Ye)?.name?.slice(0,2).toUpperCase()}):jsx(User,{className:"w-3.5 h-3.5"})}),jsx(AnimatePresence,{children:z&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:h("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[160px] max-h-[200px] overflow-y-auto",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:se=>se.stopPropagation(),children:[jsxs("button",{onClick:()=>{pt(null),oe(false);},className:h("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",l?"hover:bg-white/5":"hover:bg-gray-50",!Ye&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:h("w-5 h-5 rounded-full flex items-center justify-center",l?"bg-white/10":"bg-gray-200"),children:jsx(User,{className:"w-3 h-3 text-gray-400"})}),jsx("span",{className:l?"text-[#9CA3AF]":"text-gray-500",children:m==="es"?"Sin asignar":"Unassigned"})]}),t.availableUsers?.map(se=>jsxs("button",{onClick:()=>{pt(se.id),oe(false);},className:h("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",l?"hover:bg-white/5":"hover:bg-gray-50",Ye===se.id&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-white text-[9px] font-medium",style:{backgroundColor:se.color||"#7C3AED"},children:se.initials||se.name?.slice(0,2).toUpperCase()}),jsx("span",{className:l?"text-white":"text-gray-900",children:se.name})]},se.id)),(!t.availableUsers||t.availableUsers.length===0)&&jsx("div",{className:h("px-3 py-2 text-xs",l?"text-[#6B7280]":"text-gray-400"),children:m==="es"?"No hay usuarios disponibles":"No users available"})]})})]})]}),jsx("button",{onClick:()=>{if(Ie.trim()){let se=t.availableUsers?.find(_e=>_e.id===Ye),j=ne||M.date;a.onTaskCreate?.({name:Ie.trim(),startDate:j,endDate:j,priority:He,assignees:se?[se]:void 0}),me(""),Le(void 0),pt(null),xe(null),we(null);}},disabled:!Ie.trim(),className:h("px-2.5 py-1 rounded text-xs font-medium transition-colors",Ie.trim()?"bg-[#7C3AED] hover:bg-[#6D28D9] text-white":l?"bg-white/5 text-[#4B5563]":"bg-gray-100 text-gray-400"),children:m==="es"?"Guardar":"Save"})]})]})]})})]})})(),jsx("span",{className:h("text-sm font-medium",M.isToday?"text-[#3B82F6]":M.isCurrentMonth?l?"text-white":"text-gray-900":l?"text-[#6B7280]":"text-gray-400"),children:M.date.getDate()})]})]},te)})})]})}),jsx(AnimatePresence,{children:x&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>k(null),className:"fixed inset-0 bg-black/50 z-40"}),jsxs(motion.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},className:h("fixed inset-4 md:inset-8 lg:inset-12 rounded-xl shadow-2xl z-50 flex overflow-hidden",l?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[jsxs("div",{className:h("px-6 py-3 border-b flex items-center gap-3",l?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:h("w-4 h-4",l?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:h("text-xs px-2 py-0.5 rounded",l?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[m==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:h("text-xs font-mono",l?"text-[#6B7280]":"text-gray-400"),children:x.id.slice(0,8)}),jsxs("button",{className:h("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-colors",l?"bg-purple-500/20 text-purple-400 hover:bg-purple-500/30":"bg-purple-100 text-purple-700 hover:bg-purple-200"),children:[jsx(Sparkles,{className:"w-3 h-3"}),"Ask AI"]})]}),jsx("div",{className:"flex-1"}),jsx("button",{className:h("p-1.5 rounded transition-colors",l?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Maximize2,{className:"w-4 h-4"})}),jsx("button",{className:h("p-1.5 rounded transition-colors",l?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(MoreHorizontal,{className:"w-5 h-5"})}),jsx("button",{onClick:()=>k(null),className:h("p-1.5 rounded transition-colors",l?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(X,{className:"w-5 h-5"})})]}),jsx("div",{className:"px-6 py-4",children:jsxs("div",{className:"flex items-start gap-3",children:[jsx("button",{onClick:()=>{let M=x.progress===100?0:100,Re={...x,progress:M,status:M===100?"completed":"todo"};k(Re),a.onTaskUpdate?.(Re);},className:h("mt-1 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors",x.progress===100?"bg-green-500 border-green-500":l?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:x.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("h2",{className:h("text-xl font-semibold flex-1",x.progress===100?"line-through text-[#6B7280]":l?"text-white":"text-gray-900"),children:x.name})]})}),jsxs("div",{className:"px-6 pb-6 flex-1 overflow-y-auto overflow-x-visible",children:[jsxs("div",{className:"grid grid-cols-2 gap-x-12 gap-y-5",children:[jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CheckCircle2,{className:h("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{V(),$(!Je);},className:h("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",x.progress===100||x.status==="completed"?"bg-green-500/20 text-green-400":x.progress&&x.progress>0||x.status==="in-progress"?"bg-blue-500/20 text-blue-400":l?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:x.progress===100||x.status==="completed"?m==="es"?"COMPLETADO":"DONE":x.progress&&x.progress>0||x.status==="in-progress"?m==="es"?"EN PROGRESO":"IN PROGRESS":m==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:Je&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>$(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:h("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"todo",label:m==="es"?"Por hacer":"To Do",color:"bg-white/10 text-white"},{id:"in-progress",label:m==="es"?"En progreso":"In Progress",color:"bg-blue-500/20 text-blue-400"},{id:"completed",label:m==="es"?"Completado":"Done",color:"bg-green-500/20 text-green-400"}].map(M=>jsxs("button",{onClick:()=>rt(M.id),className:h("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",l?"hover:bg-white/5":"hover:bg-gray-50",(x.status===M.id||M.id==="completed"&&x.progress===100||M.id==="in-progress"&&x.progress&&x.progress>0&&x.progress<100||M.id==="todo"&&(!x.progress||x.progress===0)&&x.status!=="in-progress"&&x.status!=="completed")&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:h("w-2 h-2 rounded-full",M.id==="completed"?"bg-green-500":M.id==="in-progress"?"bg-blue-500":"bg-gray-400")}),jsx("span",{className:l?"text-white":"text-gray-900",children:M.label})]},M.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(User,{className:h("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{$(false),W(false),H(null),Y(!D);},className:h("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",l?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[x.assignees&&x.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[x.assignees.slice(0,3).map((M,te)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:M.color||"#8B5CF6"},title:M.name,children:M.initials||M.name.slice(0,2).toUpperCase()},te)),x.assignees.length>3&&jsxs("span",{className:h("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:["+",x.assignees.length-3]})]}):jsx("span",{className:h("text-sm",l?"text-[#6B7280]":"text-gray-400"),children:m==="es"?"Agregar":"Add"}),jsx(ChevronDown,{className:h("w-3 h-3",l?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:D&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Y(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:h("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[200px] max-h-[280px] overflow-y-auto",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:t.availableUsers&&t.availableUsers.length>0?t.availableUsers.map(M=>{let te=x.assignees?.some(Re=>Re.name===M.name);return jsxs("button",{onClick:()=>{let Re=x.assignees||[],lt;te?lt=Re.filter(Et=>Et.name!==M.name):lt=[...Re,{name:M.name,avatar:M.avatar,initials:M.initials||M.name.slice(0,2).toUpperCase(),color:M.color||"#8B5CF6"}],Ee("assignees",lt);},className:h("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors",l?"hover:bg-white/5":"hover:bg-gray-50",te&&(l?"bg-white/5":"bg-gray-50")),children:[M.avatar?jsx("img",{src:M.avatar,alt:M.name,className:"w-6 h-6 rounded-full object-cover"}):jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:M.color||"#8B5CF6"},children:M.initials||M.name.slice(0,2).toUpperCase()}),jsx("span",{className:h("flex-1 text-left",l?"text-white":"text-gray-900"),children:M.name}),te&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},M.id||M.name)}):jsx("div",{className:h("px-3 py-4 text-sm text-center",l?"text-[#6B7280]":"text-gray-400"),children:m==="es"?"No hay usuarios disponibles":"No users available"})})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CalendarDays,{className:h("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{H(N?null:"start"),q(x.startDate||new Date);},className:h("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",l?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[x.startDate?.toLocaleDateString(m==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(m==="es"?"Inicio":"Start"),jsx("span",{className:h("mx-1",l?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),x.endDate?.toLocaleDateString(m==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(m==="es"?"Fin":"End"),(x.startDate||x.endDate)&&jsx(X,{className:"w-3.5 h-3.5 ml-1 opacity-50 hover:opacity-100",onClick:M=>{M.stopPropagation();}})]}),jsx(AnimatePresence,{children:N&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>H(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:h("absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:M=>M.stopPropagation(),children:[jsxs("div",{className:h("w-44 py-2 border-r",l?"border-white/10":"border-gray-200"),children:[(()=>{let M=new Date,te=new Date(M);te.setDate(M.getDate()+1);let Re=new Date(M);Re.setDate(M.getDate()+((6-M.getDay()+7)%7||7));let lt=new Date(M);lt.setDate(M.getDate()+((1-M.getDay()+7)%7||7));let Et=new Date(M);Et.setDate(M.getDate()+(6-M.getDay()+7)%7+7);let se=new Date(M);se.setDate(M.getDate()+14);let j=new Date(M);return j.setDate(M.getDate()+28),[{label:m==="es"?"Hoy":"Today",date:M,display:M.toLocaleDateString(m==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:m==="es"?"Ma\xF1ana":"Tomorrow",date:te,display:te.toLocaleDateString(m==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:m==="es"?"Este fin de semana":"This weekend",date:Re,display:m==="es"?"s\xE1b.":"sat."},{label:m==="es"?"Pr\xF3xima semana":"Next week",date:lt,display:m==="es"?"lun.":"mon."},{label:m==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:Et,display:Et.toLocaleDateString(m==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:m==="es"?"2 semanas":"2 weeks",date:se,display:se.toLocaleDateString(m==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:m==="es"?"4 semanas":"4 weeks",date:j,display:j.toLocaleDateString(m==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((De,ta)=>jsxs("button",{className:h("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",l?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if(N==="start"){let sa=x.endDate&&De.date>x.endDate?De.date:x.endDate;st(De.date,sa),H("end");}else {let sa=x.startDate&&De.date<x.startDate?De.date:x.startDate;st(sa,De.date),H(null);}},children:[jsx("span",{children:De.label}),jsx("span",{className:h("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:De.display})]},ta))})(),jsx("div",{className:h("border-t mt-2 pt-2",l?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{st(void 0,void 0),H(null);},className:h("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",l?"hover:bg-white/5 text-red-400":"hover:bg-gray-50 text-red-500"),children:[jsx("span",{children:m==="es"?"Quitar fechas":"Clear dates"}),jsx(X,{className:"w-4 h-4 opacity-50"})]})})]}),jsxs("div",{className:"p-4",children:[jsx("div",{className:h("text-xs mb-3 px-2 py-1 rounded",l?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:N==="start"?m==="es"?"\u{1F4C5} Selecciona fecha de inicio":"\u{1F4C5} Select start date":m==="es"?"\u{1F4C5} Selecciona fecha de fin":"\u{1F4C5} Select end date"}),jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsx("span",{className:h("font-medium",l?"text-white":"text-gray-900"),children:L.toLocaleDateString(m==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>q(new Date),className:h("p-1 rounded text-sm transition-colors",l?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:m==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>q(new Date(L.getFullYear(),L.getMonth()-1)),className:h("p-1 rounded",l?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-4 h-4"})}),jsx("button",{onClick:()=>q(new Date(L.getFullYear(),L.getMonth()+1)),className:h("p-1 rounded",l?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:"w-4 h-4"})})]})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:(m==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(M=>jsx("div",{className:h("w-8 h-8 flex items-center justify-center text-xs",l?"text-[#6B7280]":"text-gray-400"),children:M},M))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let M=L.getFullYear(),te=L.getMonth(),Re=new Date(M,te,1).getDay(),lt=new Date(M,te+1,0).getDate(),Et=new Date(M,te,0).getDate(),se=new Date,j=[];for(let De=Re-1;De>=0;De--)j.push({day:Et-De,isCurrentMonth:false,date:new Date(M,te-1,Et-De)});for(let De=1;De<=lt;De++)j.push({day:De,isCurrentMonth:true,date:new Date(M,te,De)});let _e=42-j.length;for(let De=1;De<=_e;De++)j.push({day:De,isCurrentMonth:false,date:new Date(M,te+1,De)});return j.map((De,ta)=>{let sa=De.date.toDateString()===se.toDateString(),Yt=x.startDate?.toDateString()===De.date.toDateString(),kt=x.endDate?.toDateString()===De.date.toDateString(),ze=Yt||kt,Ze=x.startDate&&x.endDate&&De.date>=x.startDate&&De.date<=x.endDate;return jsx("button",{className:h("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!De.isCurrentMonth&&(l?"text-[#4B5563]":"text-gray-300"),De.isCurrentMonth&&(l?"text-white":"text-gray-900"),sa&&"ring-2 ring-[#3B82F6]",Yt&&"bg-[#3B82F6] text-white",kt&&!Yt&&"bg-[#7C3AED] text-white",Ze&&!ze&&(l?"bg-[#7C3AED]/20":"bg-purple-100"),!ze&&(l?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{let jt=new Date(De.date);if(N==="start"){let tr=x.endDate&&jt>x.endDate?jt:x.endDate;st(jt,tr),H("end");}else {let tr=x.startDate&&jt<x.startDate?jt:x.startDate;st(tr,jt),H(null);}},children:De.day},ta)})})()})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:h("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{V(),W(!B);},className:h("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",x.priority==="high"||x.priority==="urgent"?"bg-red-500/20 text-red-400":x.priority==="medium"?"bg-yellow-500/20 text-yellow-400":x.priority==="low"?"bg-green-500/20 text-green-400":l?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:x.priority?x.priority==="high"||x.priority==="urgent"?m==="es"?"Urgente":"Urgent":x.priority==="medium"?m==="es"?"Media":"Medium":m==="es"?"Baja":"Low":m==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:B&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>W(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:h("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"urgent",label:m==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:m==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:m==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:m==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:m==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(M=>jsxs("button",{onClick:()=>{Ee("priority",M.id),W(false);},className:h("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",l?"hover:bg-white/5":"hover:bg-gray-50",x.priority===M.id&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:h("w-2 h-2 rounded-full",M.color)}),jsx("span",{className:l?"text-white":"text-gray-900",children:M.label})]},M.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:h("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:h("text-sm",l?"text-white":"text-gray-900"),children:x.startDate&&x.endDate?`${Math.ceil((x.endDate.getTime()-x.startDate.getTime())/(1e3*60*60*24))} ${m==="es"?"d\xEDas":"days"}`:m==="es"?"Sin definir":"Not set"})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:h("w-4 h-4 rounded-full border-2",l?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:h("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[J?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:x.progress||0,onChange:M=>{let te=parseInt(M.target.value),Re=x.status;te===100?Re="completed":te>0?Re="in-progress":Re="todo";let lt={...x,progress:te,status:Re};k(lt),a.onTaskUpdate?.(lt);},onBlur:()=>R(false),className:h("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",l?"bg-white/10":"bg-gray-200","[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[#3B82F6] [&::-webkit-slider-thumb]:cursor-pointer"),autoFocus:true}):jsx("button",{onClick:()=>R(true),className:h("flex-1 h-2 rounded-full overflow-hidden max-w-[120px] cursor-pointer hover:ring-2 hover:ring-white/20 transition-all",l?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:h("h-full rounded-full transition-all",x.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${x.progress||0}%`}})}),jsxs("span",{className:h("text-sm font-medium min-w-[40px]",l?"text-white":"text-gray-900"),children:[x.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:h("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Etiquetas":"Tags"}),jsx(ar,{selectedTags:x.tags||[],availableTags:p,onChange:M=>{Ee("tags",M);},onCreateTag:i,theme:w})]}),jsxs("div",{className:"flex items-start gap-3 relative",children:[jsx(Link2,{className:h("w-4 h-4 mt-1.5",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24 mt-1",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[x.dependencies&&x.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:x.dependencies.map(M=>{let te=e.find(Re=>Re.id===M);return jsxs("span",{className:h("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",l?"bg-blue-500/20 text-blue-400":"bg-blue-100 text-blue-700"),children:[te?.name||M.slice(0,8),jsx("button",{onClick:()=>{let Re=(x.dependencies||[]).filter(lt=>lt!==M);Ee("dependencies",Re);},className:h("ml-0.5 hover:bg-white/20 rounded-full p-0.5 transition-colors"),children:jsx(X,{className:"w-3 h-3"})})]},M)})}),jsxs("button",{onClick:()=>{V(),ma(!oa);},className:h("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",l?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{className:h("text-sm",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:oa&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{ma(false),Oe("");}}),jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:h("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[280px] max-h-[320px]",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[jsx("div",{className:h("p-2 border-b",l?"border-white/10":"border-gray-200"),children:jsx("input",{type:"text",value:Ue,onChange:M=>Oe(M.target.value),placeholder:m==="es"?"Buscar tarea...":"Search task...",className:h("w-full px-3 py-2 rounded-md text-sm outline-none",l?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400"),autoFocus:true})}),jsx("div",{className:"max-h-[240px] overflow-y-auto",children:e.length>0?e.filter(M=>M.id!==x.id).filter(M=>Ue===""||M.name.toLowerCase().includes(Ue.toLowerCase())).map(M=>{let te=x.dependencies?.includes(M.id);return jsxs("button",{onClick:()=>{let Re=x.dependencies||[],lt;te?lt=Re.filter(Et=>Et!==M.id):lt=[...Re,M.id],Ee("dependencies",lt);},className:h("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",l?"hover:bg-white/5":"hover:bg-gray-50",te&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:h("w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0",te?"bg-blue-500 border-blue-500":l?"border-white/30":"border-gray-300"),children:te&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("span",{className:h("block truncate",l?"text-white":"text-gray-900"),children:M.name}),jsx("span",{className:h("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:M.id.slice(0,8)})]})]},M.id)}):jsx("div",{className:h("px-3 py-4 text-sm text-center",l?"text-[#6B7280]":"text-gray-500"),children:m==="es"?"No hay tareas disponibles":"No tasks available"})})]})]})})]})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Palette,{className:h("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:"Color"}),jsxs("button",{onClick:()=>{V(),ge(!na);},className:h("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",l?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx("div",{className:"w-4 h-4 rounded-full",style:{backgroundColor:x.color||"#6366F1"}}),jsx("span",{className:h("text-sm",l?"text-white":"text-gray-900"),children:rr.find(M=>M.value===x.color)?.name||(m==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:h("w-3 h-3",l?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:na&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>ge(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:h("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden p-3",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:jsx("div",{className:"grid grid-cols-6 gap-1.5",children:rr.map(M=>{let te=x.color===M.value;return jsx("button",{onClick:()=>{Ee("color",M.value),ge(false);},className:h("w-7 h-7 rounded-full flex items-center justify-center transition-all",te&&"ring-2 ring-offset-2",l?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:M.value,outlineColor:te?M.value:void 0},title:M.name,children:te&&jsx(Check,{className:"w-3.5 h-3.5 text-white"})},M.value)})})})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Diamond,{className:h("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:h("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Hito":"Milestone"}),jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:x.isMilestone||false,onChange:M=>Ee("isMilestone",M.target.checked),className:h("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",x.isMilestone?"bg-purple-500 border-purple-500":l?"border-white/30 bg-transparent":"border-gray-300 bg-transparent","checked:bg-purple-500 checked:border-purple-500")}),jsx("span",{className:h("text-sm",l?"text-white":"text-gray-900"),children:m==="es"?"Marcar como hito":"Mark as milestone"})]})]})]}),jsxs("div",{className:h("mt-6 pt-4 border-t",l?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2 mb-3",children:[jsx(FileText,{className:h("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("h3",{className:h("text-sm font-semibold",l?"text-white":"text-gray-900"),children:m==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:x.description||"",onChange:M=>Ee("description",M.target.value),placeholder:m==="es"?"Agregar descripci\xF3n...":"Add description...",className:h("w-full min-h-[100px] px-3 py-2 rounded-lg text-sm resize-none outline-none transition-colors",l?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400 focus:bg-gray-200")}),jsxs("button",{className:h("flex items-center gap-2 text-sm mt-2 transition-colors",l?"text-purple-400 hover:text-purple-300":"text-purple-600 hover:text-purple-700"),children:[jsx(Sparkles,{className:"w-4 h-4"}),m==="es"?"Escribe con IA":"Write with AI"]})]}),jsxs("div",{className:h("mt-6 pt-4 border-t",l?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:h("text-sm font-semibold mb-3",l?"text-white":"text-gray-900"),children:m==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:h("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",l?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),m==="es"?"Crea un campo en esta lista":"Create a field in this list"]})]}),jsxs("div",{className:h("mt-6 pt-4 border-t",l?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:h("text-sm font-semibold mb-3",l?"text-white":"text-gray-900"),children:m==="es"?"Agregar subtarea":"Add subtask"}),x.subtasks&&x.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:x.subtasks.map(M=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:h("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",M.progress===100?"bg-green-500 border-green-500":l?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:M.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:h("text-sm",M.progress===100?"line-through text-[#6B7280]":l?"text-white":"text-gray-900"),children:M.name})]},M.id))}),jsxs("button",{className:h("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",l?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),m==="es"?"Add Tarea":"Add Task"]})]}),jsxs("div",{className:h("mt-6 pt-4 border-t",l?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("h3",{className:h("text-sm font-semibold",l?"text-white":"text-gray-900"),children:m==="es"?"Listas de control":"Checklists"}),jsx("button",{className:h("p-1 rounded transition-colors",l?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:jsx(Plus,{className:"w-4 h-4"})})]}),jsxs("button",{className:h("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",l?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(ListChecks,{className:"w-4 h-4"}),m==="es"?"Crear lista de control":"Create checklist"]})]}),jsxs("div",{className:h("mt-6 pt-4 border-t",l?"border-white/10":"border-gray-200"),children:[jsxs("h3",{className:h("text-sm font-semibold mb-3",l?"text-white":"text-gray-900"),children:[m==="es"?"Adjuntos":"Attachments",Ae.length>0&&jsxs("span",{className:h("ml-2 text-xs font-normal",l?"text-[#6B7280]":"text-gray-400"),children:["(",Ae.length,")"]})]}),Ae.length>0&&jsx("div",{className:"space-y-2 mb-4",children:Ae.map(M=>{let te=ee(M.type),Re=M.type.startsWith("image/");return jsxs("div",{className:h("flex items-center gap-3 p-2 rounded-lg group transition-colors",l?"bg-white/5 hover:bg-white/10":"bg-gray-50 hover:bg-gray-100"),children:[Re&&M.thumbnailUrl?jsx("img",{src:M.thumbnailUrl,alt:M.name,className:"w-10 h-10 rounded object-cover"}):jsx("div",{className:h("w-10 h-10 rounded flex items-center justify-center",l?"bg-white/10":"bg-gray-200"),children:jsx(te,{className:h("w-5 h-5",l?"text-[#9CA3AF]":"text-gray-500")})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("a",{href:M.url,target:"_blank",rel:"noopener noreferrer",className:h("text-sm font-medium truncate block hover:underline",l?"text-white":"text-gray-900"),children:M.name}),jsx("p",{className:h("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:G(M.size)})]}),a.onDeleteAttachment&&jsx("button",{onClick:()=>a.onDeleteAttachment?.(M.id),className:h("p-1.5 rounded opacity-0 group-hover:opacity-100 transition-all",l?"hover:bg-red-500/20 text-red-400":"hover:bg-red-100 text-red-500"),title:m==="es"?"Eliminar":"Delete",children:jsx(Trash2,{className:"w-4 h-4"})})]},M.id)})}),jsxs("div",{onDragOver:Xe,onDragLeave:$e,onDrop:re,className:h("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",he?l?"border-blue-500 bg-blue-500/10":"border-blue-400 bg-blue-50":l?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300",Mt&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:Me,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!a.onUploadAttachments||Mt}),Mt?jsxs(Fragment,{children:[jsx("div",{className:"w-6 h-6 mx-auto mb-2 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"}),jsx("p",{className:h("text-sm",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Subiendo...":"Uploading..."})]}):jsxs(Fragment,{children:[jsx(Upload,{className:h("w-6 h-6 mx-auto mb-2",he?"text-blue-500":l?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:h("text-sm",l?"text-[#9CA3AF]":"text-gray-500"),children:he?m==="es"?"Suelta los archivos aqu\xED":"Drop files here":m==="es"?jsxs(Fragment,{children:["Suelta tus archivos aqu\xED o ",jsx("span",{className:"underline",children:"haz clic para subir"})]}):jsxs(Fragment,{children:["Drop your files here or ",jsx("span",{className:"underline",children:"click to upload"})]})}),!a.onUploadAttachments&&jsx("p",{className:h("text-xs mt-1",l?"text-[#6B7280]":"text-gray-400"),children:m==="es"?"Upload no disponible":"Upload not available"})]})]})]})]})]}),jsxs("div",{className:h("w-[280px] border-l flex flex-col",l?"border-white/10 bg-[#141619]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:h("px-4 py-3 border-b flex items-center justify-between",l?"border-white/10":"border-gray-200"),children:jsx("span",{className:h("font-medium",l?"text-white":"text-gray-900"),children:m==="es"?"Actividad":"Activity"})}),jsx("div",{className:"flex-1 p-4 overflow-y-auto",children:d&&d.length>0?jsx("div",{className:"space-y-4",children:d.map(M=>{let te=(()=>{let Re=new Date,lt=new Date(M.createdAt),Et=Re.getTime()-lt.getTime(),se=Math.floor(Et/6e4),j=Math.floor(se/60),_e=Math.floor(j/24);return se<1?m==="es"?"ahora":"now":se<60?m==="es"?`hace ${se}m`:`${se}m ago`:j<24?m==="es"?`hace ${j}h`:`${j}h ago`:m==="es"?`hace ${_e}d`:`${_e}d ago`})();return jsxs("div",{className:"flex gap-3",children:[jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:"#8B5CF6"},children:M.user?.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:h("text-sm font-medium",l?"text-white":"text-gray-900"),children:M.user?.name||"User"}),jsx("span",{className:h("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:te})]}),jsx("p",{className:h("text-sm mt-1",l?"text-[#9CA3AF]":"text-gray-600"),children:M.content})]})]},M.id)})}):jsxs("div",{className:h("text-sm text-center py-8",l?"text-[#6B7280]":"text-gray-400"),children:[jsx(MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),m==="es"?"Sin actividad reciente":"No recent activity"]})}),jsx("div",{className:h("p-3 border-t",l?"border-white/10":"border-gray-200"),children:jsxs("div",{className:h("flex items-center gap-2 px-3 py-2 rounded-lg",l?"bg-white/5":"bg-white border border-gray-200"),children:[f&&jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:f.color||"#8B5CF6"},children:f.name?.slice(0,2).toUpperCase()||"U"}),jsx("input",{type:"text",placeholder:m==="es"?"Escribe un comentario...":"Write a comment...",className:h("flex-1 bg-transparent text-sm outline-none",l?"text-white placeholder-[#6B7280]":"text-gray-900 placeholder-gray-400"),onKeyDown:M=>{if(M.key==="Enter"&&!M.shiftKey&&x){let te=M.target,Re=te.value.trim();Re&&g&&(g(x.id,Re),te.value="");}}})]})})]})]})]})}),jsx(AnimatePresence,{children:O&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>A(null),className:"fixed inset-0 bg-black/30 z-40"}),jsxs(motion.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:h("fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-[320px] max-h-[400px] rounded-xl shadow-2xl z-50 overflow-hidden",l?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:h("px-4 py-3 border-b flex items-center justify-between",l?"border-white/10":"border-gray-200"),children:[jsx("span",{className:h("font-medium",l?"text-white":"text-gray-900"),children:O.date.toLocaleDateString(m==="es"?"es-ES":"en-US",{weekday:"long",month:"long",day:"numeric"})}),jsx("button",{onClick:()=>A(null),className:h("p-1 rounded",l?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(X,{className:"w-4 h-4"})})]}),jsx("div",{className:"p-3 max-h-[320px] overflow-y-auto space-y-2",children:O.events.map(M=>jsxs("button",{onClick:()=>{A(null),k(M.task),C?.(M.task.id);},className:h("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-left transition-colors",l?"hover:bg-white/5":"hover:bg-gray-50"),children:[jsx($c,{task:M.task}),jsx("span",{className:h("text-sm truncate flex-1",l?"text-white":"text-gray-900"),children:M.title}),M.task.priority==="high"||M.task.priority==="urgent"?jsx(Flag,{className:"w-3.5 h-3.5 text-red-400"}):null]},M.id))})]})]})})]})}var Fi={bgPrimary:"#0d1117",bgSecondary:"#161b22",bgHover:"#21262d",bgToday:"#1f6feb20",bgWeekend:"#161b2280",bgOtherMonth:"#0d111750",border:"#30363d",borderLight:"#21262d",textPrimary:"#c9d1d9",textSecondary:"#8b949e",textMuted:"#6e7681",textToday:"#58a6ff",accent:"#58a6ff",accentHover:"#79b8ff",accentLight:"#58a6ff20",statusTodo:"#8b949e",statusInProgress:"#f0883e",statusCompleted:"#3fb950",focusRing:"#58a6ff"},Ii={bgPrimary:"#ffffff",bgSecondary:"#f6f8fa",bgHover:"#f3f4f6",bgToday:"#dbeafe",bgWeekend:"#f9fafb",bgOtherMonth:"#f3f4f680",border:"#d0d7de",borderLight:"#e5e7eb",textPrimary:"#24292f",textSecondary:"#57606a",textMuted:"#8b949e",textToday:"#0969da",accent:"#0969da",accentHover:"#0550ae",accentLight:"#dbeafe",statusTodo:"#8b949e",statusInProgress:"#bf8700",statusCompleted:"#1a7f37",focusRing:"#0969da"},Li={bgPrimary:"#1a1a2e",bgSecondary:"#16213e",bgHover:"#1f3460",bgToday:"#6366f120",bgWeekend:"#16213e80",bgOtherMonth:"#1a1a2e50",border:"#2a3f5f",borderLight:"#1f3460",textPrimary:"#e4e6eb",textSecondary:"#a8b2c1",textMuted:"#6b7280",textToday:"#818cf8",accent:"#6366f1",accentHover:"#818cf8",accentLight:"#6366f120",statusTodo:"#9ca3af",statusInProgress:"#fbbf24",statusCompleted:"#34d399",focusRing:"#6366f1"},$n={dark:Fi,light:Ii,neutral:Li};function Gc(e){return $n[e]||$n.dark}function lh({stack:e,cards:t,renderCard:a,onCardClick:r,onToggleExpand:o,onUnstack:s,onDeleteStack:n,className:c}){let[p,i]=useState(false),u=useMemo(()=>t.filter(f=>e.cardIds.includes(f.id)),[t,e.cardIds]),d=useMemo(()=>{let f=u.length,C=new Set(u.flatMap(b=>b.assignedUserIds||[])).size,T=u.map(b=>b.priority).filter(Boolean),m=new Set(u.flatMap(b=>b.labels||[])).size;return {totalCards:f,uniqueAssignees:C,priorities:T,labels:m}},[u]),g=()=>{o?.(e.id);};return jsxs("div",{className:h("card-stack",!e.isExpanded&&"card-stack-collapsed",c),onMouseEnter:()=>i(true),onMouseLeave:()=>i(false),style:{"--stack-color":e.color||"var(--color-accent-primary)"},children:[jsxs("div",{className:"card-stack-header",onClick:g,children:[jsxs("div",{className:"card-stack-header-left",children:[jsx("button",{className:"card-stack-toggle","aria-label":e.isExpanded?"Collapse":"Expand",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:h("card-stack-chevron",e.isExpanded&&"expanded"),children:jsx("polyline",{points:"6 9 12 15 18 9"})})}),jsx("h3",{className:"card-stack-title",children:e.title}),jsx("div",{className:"card-stack-badge",children:d.totalCards}),jsxs("div",{className:"card-stack-strategy",children:[e.strategy==="ai-similarity"&&"\u2728 AI",e.strategy==="manual"&&"\u{1F464} Manual",e.strategy==="labels"&&"\u{1F3F7}\uFE0F Labels",e.strategy==="assignee"&&"\u{1F465} Assignee",e.strategy==="priority"&&"\u{1F3AF} Priority",e.strategy==="epic"&&"\u{1F4DA} Epic"]})]}),p&&jsx("div",{className:"card-stack-actions",children:jsx("button",{className:"card-stack-action",onClick:f=>{f.stopPropagation(),n?.(e.id);},"aria-label":"Delete stack",children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})})]}),!e.isExpanded&&jsxs("div",{className:"card-stack-summary",children:[jsxs("div",{className:"card-stack-summary-item",children:[jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),jsxs("span",{children:[d.uniqueAssignees," assignees"]})]}),d.labels>0&&jsxs("div",{className:"card-stack-summary-item",children:[jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"}),jsx("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]}),jsxs("span",{children:[d.labels," labels"]})]}),e.confidence&&jsx("div",{className:"card-stack-summary-item",children:jsxs("span",{className:"card-stack-confidence",children:[Math.round(e.confidence*100),"% match"]})})]}),e.isExpanded&&jsx("div",{className:"card-stack-content",children:u.length===0?jsxs("div",{className:"card-stack-empty",children:[jsx("p",{children:"No cards in this stack"}),jsx("span",{children:"Drag cards here or delete this stack"})]}):jsx("div",{className:"card-stack-cards",children:u.map(f=>jsxs("div",{className:"card-stack-card-wrapper",children:[a?jsx("div",{onClick:()=>r?.(f),children:a(f)}):jsxs("div",{className:"card-stack-default-card",onClick:()=>r?.(f),children:[jsx("h4",{children:f.title}),f.description&&jsxs("p",{children:[f.description.substring(0,100),"..."]})]}),jsx("button",{className:"card-stack-unstack-btn",onClick:C=>{C.stopPropagation(),s?.(e.id,f.id);},"aria-label":"Remove from stack",children:jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},f.id))})})]})}var Vc={showIcons:true,showAvatars:true,groupByDay:true,useRelativeTime:true,compact:false};function Ho(e){switch(e.type){case "created":return "Created card";case "status_changed":return `Changed status from "${e.changes.status?.from}" to "${e.changes.status?.to}"`;case "assignee_changed":return "Changed assignee";case "priority_changed":return `Changed priority from ${e.changes.priority?.from} to ${e.changes.priority?.to}`;case "moved":return `Moved from ${e.metadata?.fromColumn||"unknown"} to ${e.metadata?.toColumn||"unknown"}`;case "title_updated":return "Updated title";case "description_updated":return "Updated description";case "dates_changed":return "Changed dates";case "labels_changed":return "Updated labels";case "dependency_added":return "Added dependency";case "dependency_removed":return "Removed dependency";case "comment_added":return "Added comment";case "archived":return "Archived card";case "restored":return "Restored card";default:return "Updated card"}}function Wo(e){return {created:"\u2728",status_changed:"\u{1F504}",assignee_changed:"\u{1F464}",priority_changed:"\u{1F3AF}",moved:"\u27A1\uFE0F",title_updated:"\u270F\uFE0F",description_updated:"\u{1F4DD}",dates_changed:"\u{1F4C5}",labels_changed:"\u{1F3F7}\uFE0F",dependency_added:"\u{1F517}",dependency_removed:"\u26D3\uFE0F\u200D\u{1F4A5}",comment_added:"\u{1F4AC}",archived:"\u{1F4E6}",restored:"\u267B\uFE0F"}[e]||"\u{1F4CC}"}function jc(e){return {created:"#10b981",status_changed:"#3b82f6",assignee_changed:"#8b5cf6",priority_changed:"#f59e0b",moved:"#06b6d4",title_updated:"#6366f1",description_updated:"#6366f1",dates_changed:"#ec4899",labels_changed:"#14b8a6",dependency_added:"#a855f7",dependency_removed:"#ef4444",comment_added:"#84cc16",archived:"#6b7280",restored:"#10b981"}[e]||"#6b7280"}function Kc({events:e,filter:t,onFilterChange:a,onClearFilter:r,onEventClick:o,selectedEventId:s,config:n,className:c}){let p=useMemo(()=>({...Vc,...n}),[n]),[i,u]=useState(new Set),d=useRef(null),g=useMemo(()=>{if(!p.groupByDay)return [{date:null,events:e}];let y=new Map;return e.forEach(l=>{let w=l.timestamp.toISOString().split("T")[0],v=y.get(w);v?v.push(l):y.set(w,[l]);}),Array.from(y.entries()).sort((l,w)=>w[0].localeCompare(l[0])).map(([l,w])=>({date:new Date(l),events:w.sort((v,S)=>S.timestamp.getTime()-v.timestamp.getTime())}))},[e,p.groupByDay]),{uniqueUsers:f,uniqueTypes:C}=useMemo(()=>{let y=new Set,l=new Set;return e.forEach(w=>{y.add(w.userId),l.add(w.type);}),{uniqueUsers:Array.from(y),uniqueTypes:Array.from(l)}},[e]),T=y=>{u(l=>{let w=new Set(l);return w.has(y)?w.delete(y):w.add(y),w});},m=y=>{let w=new Date().getTime()-y.getTime(),v=Math.floor(w/6e4),S=Math.floor(w/36e5),x=Math.floor(w/864e5);return v<1?"just now":v<60?`${v}m ago`:S<24?`${S}h ago`:x<7?`${x}d ago`:y.toLocaleDateString()},b=useMemo(()=>{let y=0;return t.types&&t.types.length>0&&y++,t.users&&t.users.length>0&&y++,t.dateRange&&y++,t.searchTerm&&y++,y},[t]);return useEffect(()=>{if(s&&d.current){let y=d.current.querySelector(`[data-event-id="${s}"]`);y&&y.scrollIntoView({behavior:"smooth",block:"center"});}},[s]),e.length===0?jsxs("div",{className:h("history-timeline-empty",c),children:[jsx("div",{className:"history-timeline-empty-icon",children:"\u{1F4DC}"}),jsx("p",{className:"history-timeline-empty-text",children:"No history events yet"}),jsx("p",{className:"history-timeline-empty-subtext",children:"Changes to this card will appear here"})]}):jsxs("div",{className:h("history-timeline",p.compact&&"compact",c),children:[jsxs("div",{className:"history-timeline-filters",children:[jsxs("div",{className:"history-timeline-filter-group",children:[jsxs("select",{className:"history-timeline-filter-select",value:t.types?.[0]||"",onChange:y=>{let l=y.target.value;a({...t,types:l?[l]:void 0});},children:[jsx("option",{value:"",children:"All Events"}),C.map(y=>jsxs("option",{value:y,children:[Wo(y)," ",y.replace("_"," ")]},y))]}),f.length>1&&jsxs("select",{className:"history-timeline-filter-select",value:t.users?.[0]||"",onChange:y=>{let l=y.target.value;a({...t,users:l?[l]:void 0});},children:[jsx("option",{value:"",children:"All Users"}),f.map(y=>jsx("option",{value:y,children:y},y))]}),jsx("input",{type:"text",className:"history-timeline-filter-search",placeholder:"Search history...",value:t.searchTerm||"",onChange:y=>a({...t,searchTerm:y.target.value})})]}),b>0&&jsxs("button",{className:"history-timeline-filter-clear",onClick:r,children:["Clear filters (",b,")"]})]}),jsx("div",{className:"history-timeline-container",ref:d,children:g.map(y=>jsxs("div",{className:"history-timeline-group",children:[p.groupByDay&&y.date&&jsxs("div",{className:"history-timeline-day-header",children:[jsx("span",{className:"history-timeline-day-date",children:y.date.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),jsxs("span",{className:"history-timeline-day-count",children:[y.events.length," events"]})]}),jsx("div",{className:"history-timeline-events",children:y.events.map((l,w)=>{let v=i.has(l.id),S=s===l.id,x=jc(l.type);return jsxs("div",{"data-event-id":l.id,className:h("history-timeline-event",v&&"expanded",S&&"selected"),onClick:()=>o?.(l),children:[jsxs("div",{className:"history-timeline-line",children:[jsx("div",{className:"history-timeline-dot",style:{backgroundColor:x},children:p.showIcons&&jsx("span",{className:"history-timeline-dot-icon",children:Wo(l.type)})}),w<y.events.length-1&&jsx("div",{className:"history-timeline-connector",style:{borderColor:x}})]}),jsxs("div",{className:"history-timeline-event-content",children:[jsxs("div",{className:"history-timeline-event-header",children:[jsxs("div",{className:"history-timeline-event-header-left",children:[p.showAvatars&&l.userAvatar&&jsx("img",{src:l.userAvatar,alt:l.userName||l.userId,className:"history-timeline-event-avatar"}),jsxs("div",{className:"history-timeline-event-description",children:[jsx("span",{className:"history-timeline-event-user",children:l.userName||l.userId}),jsx("span",{className:"history-timeline-event-action",children:Ho(l)})]})]}),jsx("div",{className:"history-timeline-event-time",children:p.useRelativeTime?m(l.timestamp):l.timestamp.toLocaleString()})]}),Object.keys(l.changes).length>0&&jsxs("button",{className:"history-timeline-event-toggle",onClick:k=>{k.stopPropagation(),T(l.id);},children:[v?"\u25BC":"\u25B6"," Show changes"]}),v&&jsxs("div",{className:"history-timeline-event-changes",children:[Object.entries(l.changes).map(([k,O])=>jsxs("div",{className:"history-timeline-event-change",children:[jsxs("span",{className:"history-timeline-event-change-key",children:[k,":"]}),jsxs("div",{className:"history-timeline-event-change-values",children:[jsx("span",{className:"history-timeline-event-change-from",children:JSON.stringify(O.from)}),jsx("span",{className:"history-timeline-event-change-arrow",children:"\u2192"}),jsx("span",{className:"history-timeline-event-change-to",children:JSON.stringify(O.to)})]})]},k)),l.metadata&&Object.keys(l.metadata).length>0&&jsxs("div",{className:"history-timeline-event-metadata",children:[jsx("div",{className:"history-timeline-event-metadata-title",children:"Additional Info:"}),Object.entries(l.metadata).map(([k,O])=>jsxs("div",{className:"history-timeline-event-metadata-item",children:[jsxs("span",{className:"history-timeline-event-metadata-key",children:[k,":"]}),jsx("span",{className:"history-timeline-event-metadata-value",children:JSON.stringify(O)})]},k))]})]})]})]},l.id)})})]},y.date?.toISOString()||"all"))})]})}function qc({replayState:e,events:t,onStartReplay:a,onStopReplay:r,onTogglePlayback:o,onPrevious:s,onNext:n,onGoToEvent:c,onSpeedChange:p,className:i}){let u=[.5,1,1.5,2,3],d=useMemo(()=>!e||t.length===0?null:t[e.currentIndex],[e,t]),g=useMemo(()=>!e||e.totalEvents===0?0:e.currentIndex/(e.totalEvents-1)*100,[e]);return t.length===0?jsxs("div",{className:h("history-replay-empty",i),children:[jsx("div",{className:"history-replay-empty-icon",children:"\u23F3"}),jsx("p",{className:"history-replay-empty-text",children:"No history to replay"})]}):e?jsxs("div",{className:h("history-replay",i),children:[jsxs("div",{className:"history-replay-current-event",children:[jsx("div",{className:"history-replay-event-icon",children:d&&Wo(d.type)}),jsxs("div",{className:"history-replay-event-info",children:[jsx("div",{className:"history-replay-event-description",children:d&&Ho(d)}),jsxs("div",{className:"history-replay-event-meta",children:[jsxs("span",{className:"history-replay-event-index",children:["Event ",e.currentIndex+1," of ",e.totalEvents]}),jsx("span",{className:"history-replay-event-time",children:d&&d.timestamp.toLocaleString()})]})]})]}),jsxs("div",{className:"history-replay-progress-container",children:[jsx("input",{type:"range",className:"history-replay-progress-slider",min:"0",max:e.totalEvents-1,value:e.currentIndex,onChange:f=>c(parseInt(f.target.value))}),jsx("div",{className:"history-replay-progress-fill",style:{width:`${g}%`}}),jsx("div",{className:"history-replay-progress-markers",children:t.map((f,C)=>jsx("div",{className:h("history-replay-progress-marker",C===e.currentIndex&&"active"),style:{left:`${C/(e.totalEvents-1)*100}%`},onClick:()=>c(C),title:Ho(f)},f.id))})]}),jsxs("div",{className:"history-replay-controls",children:[jsx("button",{className:"history-replay-control-btn",onClick:s,disabled:!e.canGoBack,title:"Previous event (\u2190)",children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polygon",{points:"19 20 9 12 19 4 19 20"}),jsx("line",{x1:"5",y1:"19",x2:"5",y2:"5"})]})}),jsx("button",{className:"history-replay-control-btn history-replay-control-play",onClick:o,title:e.isPlaying?"Pause (Space)":"Play (Space)",children:e.isPlaying?jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:[jsx("rect",{x:"6",y:"4",width:"4",height:"16"}),jsx("rect",{x:"14",y:"4",width:"4",height:"16"})]}):jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})}),jsx("button",{className:"history-replay-control-btn",onClick:n,disabled:!e.canGoForward,title:"Next event (\u2192)",children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polygon",{points:"5 4 15 12 5 20 5 4"}),jsx("line",{x1:"19",y1:"5",x2:"19",y2:"19"})]})}),jsxs("div",{className:"history-replay-speed",children:[jsx("label",{className:"history-replay-speed-label",children:"Speed:"}),jsx("div",{className:"history-replay-speed-buttons",children:u.map(f=>jsxs("button",{className:h("history-replay-speed-btn",e.speed===f&&"active"),onClick:()=>p(f),children:[f,"x"]},f))})]}),jsx("button",{className:"history-replay-control-btn history-replay-stop",onClick:r,title:"Stop replay (Esc)",children:jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:jsx("rect",{x:"6",y:"6",width:"12",height:"12"})})})]}),jsxs("div",{className:"history-replay-shortcuts",children:[jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"Space"})," Play/Pause"]}),jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"\u2190"})," Previous"]}),jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"\u2192"})," Next"]}),jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"Esc"})," Stop"]})]}),jsxs("div",{className:"history-replay-card-preview",children:[jsxs("div",{className:"history-replay-card-preview-header",children:[jsx("span",{className:"history-replay-card-preview-title",children:"Card State at This Point"}),jsx("span",{className:"history-replay-card-preview-time",children:d&&d.timestamp.toLocaleDateString()})]}),jsxs("div",{className:"history-replay-card-preview-content",children:[jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Title:"}),jsx("span",{className:"history-replay-card-preview-value",children:e.cardState.title})]}),e.cardState.description&&jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Description:"}),jsx("span",{className:"history-replay-card-preview-value",children:e.cardState.description})]}),jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Priority:"}),jsx("span",{className:"history-replay-card-preview-value",children:e.cardState.priority||"None"})]}),e.cardState.labels&&e.cardState.labels.length>0&&jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Labels:"}),jsx("div",{className:"history-replay-card-preview-labels",children:e.cardState.labels.map(f=>jsx("span",{className:"history-replay-card-preview-label-tag",children:f},f))})]})]})]})]}):jsxs("div",{className:h("history-replay-start",i),children:[jsxs("button",{className:"history-replay-start-button",onClick:a,children:[jsx("svg",{className:"history-replay-start-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),jsx("span",{children:"Start Time Travel"})]}),jsxs("p",{className:"history-replay-start-hint",children:["Replay ",t.length," events from this card's history"]})]})}function Bi(e){return {blocks:"#ef4444",blocked_by:"#dc2626",depends_on:"#f59e0b",required_by:"#d97706",relates_to:"#6b7280",duplicates:"#8b5cf6",parent_of:"#3b82f6",child_of:"#2563eb",similar_to:"#10b981"}[e]||"#6b7280"}function Ri(e){return {blocks:"Blocks",blocked_by:"Blocked by",depends_on:"Depends on",required_by:"Required by",relates_to:"Relates to",duplicates:"Duplicates",parent_of:"Parent of",child_of:"Child of",similar_to:"Similar to"}[e]||e}function Xc(e){return {blocks:"\u{1F6AB}",blocked_by:"\u26D4",depends_on:"\u{1F517}",required_by:"\u{1F4CC}",relates_to:"\u{1F504}",duplicates:"\u{1F4CB}",parent_of:"\u{1F4C2}",child_of:"\u{1F4C4}",similar_to:"\u{1F50D}"}[e]||"\u{1F517}"}function Jc(e){return ["blocks","blocked_by","depends_on","required_by","parent_of","child_of"].includes(e)}function gh(e,t,a,r,o,s=100){let n=e.map(p=>({...p,x:p.x??a/2+Math.random()*100-50,y:p.y??r/2+Math.random()*100-50,vx:0,vy:0})),c=new Map(n.map(p=>[p.id,p]));for(let p=0;p<s;p++){let i=1-p/s;n.forEach(u=>{let d=a/2,g=r/2;u.vx+=(d-u.x)*o.centerForce*i,u.vy+=(g-u.y)*o.centerForce*i,n.forEach(f=>{if(u.id===f.id)return;let C=u.x-f.x,T=u.y-f.y,m=Math.sqrt(C*C+T*T)||1,b=o.chargeStrength*i/(m*m);u.vx+=C/m*b,u.vy+=T/m*b;});}),t.forEach(u=>{let d=c.get(typeof u.source=="string"?u.source:u.source.id),g=c.get(typeof u.target=="string"?u.target:u.target.id);if(!d||!g)return;let f=g.x-d.x,C=g.y-d.y,T=Math.sqrt(f*f+C*C)||1,m=(T-o.linkDistance)/T*o.forceStrength*i;d.vx+=f*m,d.vy+=C*m,g.vx-=f*m,g.vy-=C*m;}),n.forEach(u=>{u.fx!==null&&u.fx!==void 0?(u.x=u.fx,u.vx=0):u.x+=u.vx,u.fy!==null&&u.fy!==void 0?(u.y=u.fy,u.vy=0):u.y+=u.vy,u.x=Math.max(o.nodeSize,Math.min(a-o.nodeSize,u.x)),u.y=Math.max(o.nodeSize,Math.min(r-o.nodeSize,u.y)),u.vx*=.9,u.vy*=.9;});}return n}function Zc({nodes:e,edges:t,config:a,filter:r,onFilterChange:o,criticalPath:s,stats:n,onInteraction:c,className:p}){let i=useRef(null),[u,d]=useState([]),[g,f]=useState(null),[C,T]=useState(null),[m,b]=useState(null),[y,l]=useState(1),[w,v]=useState({x:0,y:0});useEffect(()=>{if(e.length===0)return;let L=gh(e,t,a.width,a.height,a,150);d(L);},[e,t,a]);let S=useCallback((L,q)=>{a.enableDragging&&(q.stopPropagation(),f(L));},[a.enableDragging]),x=useCallback(L=>{if(!g||!i.current)return;let ae=i.current.getBoundingClientRect(),ke=(L.clientX-ae.left-w.x)/y,Fe=(L.clientY-ae.top-w.y)/y;d(Ve=>Ve.map(Je=>Je.id===g?{...Je,x:ke,y:Fe,fx:ke,fy:Fe}:Je));},[g,y,w]),k=useCallback(()=>{f(null);},[]),O=useCallback((L,q)=>{q.stopPropagation(),c?.({type:"node-click",node:L,position:{x:q.clientX,y:q.clientY}});},[c]),A=useCallback((L,q)=>{q.stopPropagation(),c?.({type:"edge-click",edge:L,position:{x:q.clientX,y:q.clientY}});},[c]),N=useCallback(L=>{let q=u.find(ae=>ae.id===L);return q?{x:q.x,y:q.y}:{x:0,y:0}},[u]),H=useCallback(L=>{if(L.onCriticalPath)return "#ef4444";switch(a.colorScheme){case "status":return L.card.columnId==="done"?"#10b981":"#3b82f6";case "priority":let q=L.card.priority;return q==="URGENT"?"#ef4444":q==="HIGH"?"#f59e0b":q==="MEDIUM"?"#3b82f6":"#6b7280";case "assignee":return L.card.assigneeId?"#8b5cf6":"#6b7280";default:return "#3b82f6"}},[a.colorScheme]);return e.length===0?jsxs("div",{className:h("relationships-graph-empty",p),children:[jsx("div",{className:"relationships-graph-empty-icon",children:"\u{1F517}"}),jsx("p",{className:"relationships-graph-empty-text",children:"No relationships to display"}),jsx("p",{className:"relationships-graph-empty-subtext",children:"Add relationships between cards to see the graph"})]}):jsxs("div",{className:h("relationships-graph",p),children:[jsxs("div",{className:"relationships-graph-controls",children:[jsxs("div",{className:"relationships-graph-stats",children:[jsxs("span",{className:"relationships-graph-stat",children:[jsx("span",{className:"relationships-graph-stat-value",children:n.totalNodes}),jsx("span",{className:"relationships-graph-stat-label",children:"Cards"})]}),jsxs("span",{className:"relationships-graph-stat",children:[jsx("span",{className:"relationships-graph-stat-value",children:n.totalEdges}),jsx("span",{className:"relationships-graph-stat-label",children:"Relations"})]}),s&&jsxs("span",{className:"relationships-graph-stat relationships-graph-stat-critical",children:[jsx("span",{className:"relationships-graph-stat-value",children:s.cardIds.length}),jsx("span",{className:"relationships-graph-stat-label",children:"Critical Path"})]})]}),a.enableZoom&&jsxs("div",{className:"relationships-graph-zoom-controls",children:[jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>l(L=>Math.min(L+.2,3)),children:"+"}),jsxs("span",{className:"relationships-graph-zoom-value",children:[Math.round(y*100),"%"]}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>l(L=>Math.max(L-.2,.5)),children:"\u2212"}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>{l(1),v({x:0,y:0});},children:"Reset"})]})]}),jsx("div",{className:"relationships-graph-legend",children:Array.from(new Set(t.map(L=>L.type))).map(L=>jsxs("div",{className:"relationships-graph-legend-item",children:[jsx("div",{className:"relationships-graph-legend-color",style:{background:Bi(L)}}),jsxs("span",{className:"relationships-graph-legend-label",children:[Xc(L)," ",Ri(L)]})]},L))}),jsxs("svg",{ref:i,className:"relationships-graph-canvas",width:a.width,height:a.height,onMouseMove:x,onMouseUp:k,onMouseLeave:k,children:[jsxs("g",{transform:`translate(${w.x}, ${w.y}) scale(${y})`,children:[jsx("g",{className:"relationships-graph-edges",children:t.map(L=>{let q=N(typeof L.source=="string"?L.source:L.source.id),ae=N(typeof L.target=="string"?L.target:L.target.id),ke=Jc(L.type),Fe=m===L.id,Ve=L.onCriticalPath;return jsxs("g",{className:h("relationships-graph-edge",Fe&&"hovered",Ve&&"critical"),onMouseEnter:()=>b(L.id),onMouseLeave:()=>b(null),onClick:Je=>A(L,Je),children:[jsx("line",{x1:q.x,y1:q.y,x2:ae.x,y2:ae.y,stroke:Bi(L.type),strokeWidth:Ve?a.edgeWidth*2:a.edgeWidth,strokeOpacity:Fe?1:.6,markerEnd:ke?"url(#arrowhead)":void 0}),a.showEdgeLabels&&Fe&&jsx("text",{x:(q.x+ae.x)/2,y:(q.y+ae.y)/2,className:"relationships-graph-edge-label",textAnchor:"middle",children:Ri(L.type)})]},L.id)})}),jsx("g",{className:"relationships-graph-nodes",children:u.map(L=>{let q=C===L.id,ae=L.onCriticalPath;return jsxs("g",{className:h("relationships-graph-node",q&&"hovered",ae&&"critical"),transform:`translate(${L.x}, ${L.y})`,onMouseDown:ke=>S(L.id,ke),onMouseEnter:()=>T(L.id),onMouseLeave:()=>T(null),onClick:ke=>O(L,ke),children:[jsx("circle",{r:ae?a.nodeSize*1.2:a.nodeSize,fill:H(L),stroke:ae?"#fbbf24":"#ffffff",strokeWidth:ae?3:2,opacity:q?1:.9}),a.showLabels&&jsx("text",{y:a.nodeSize+20,className:"relationships-graph-node-label",textAnchor:"middle",children:L.card.title.length>20?L.card.title.substring(0,20)+"...":L.card.title})]},L.id)})})]}),jsx("defs",{children:jsx("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"10",refX:"9",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:jsx("path",{d:"M0,0 L0,6 L9,3 z",fill:"#6b7280"})})})]})]})}function tm({isOpen:e,onClose:t,onPlanGenerated:a,onGeneratePlan:r,isLoading:o}){let[s,n]=useState(""),[c,p]=useState(false),[i,u]=useState(null),[d,g]=useState(null),f=useRef(null),C=c||o;useEffect(()=>{e&&f.current&&f.current.focus();},[e]),useEffect(()=>{let y=l=>{l.key==="Escape"&&!C&&T();};if(e)return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[e,C]);let T=()=>{C||(n(""),u(null),g(null),t());},m=async()=>{if(!(!s.trim()||C)){p(true),u(null),g(null);try{let y=await r(s.trim());g(y);}catch(y){u(y instanceof Error?y.message:"Failed to generate plan");}finally{p(false);}}},b=()=>{d&&(a(d),T());};return e?jsxs(ut,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:T}),jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[100001] p-4",children:jsxs("div",{className:"w-full max-w-2xl rounded-2xl shadow-2xl border max-h-[90vh] overflow-hidden flex flex-col",style:{background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},onClick:y=>y.stopPropagation(),children:[jsxs("div",{className:"px-6 py-4 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-xl font-bold text-white flex items-center gap-2",children:[jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-blue-400",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Generate Project Plan with AI"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Describe your project and let AI create a complete Kanban board"})]}),jsx("button",{onClick:T,disabled:C,className:"text-white/60 hover:text-white transition-colors disabled:opacity-50",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:d?jsx(Fragment,{children:jsxs("div",{className:"space-y-4",children:[jsxs("div",{className:"flex items-center gap-2 text-green-400",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:jsx("path",{d:"M4 10L8 14L16 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"font-semibold",children:"Plan Generated Successfully!"})]}),d.explanation&&jsx("div",{className:"p-4 rounded-lg bg-blue-500/10 border border-blue-500/30",children:jsx("p",{className:"text-sm text-white/90",children:d.explanation})}),jsxs("div",{children:[jsxs("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:["Columns (",d.columns.length,")"]}),jsx("div",{className:"flex gap-2 flex-wrap",children:d.columns.map((y,l)=>jsx("div",{className:"px-3 py-1.5 rounded-lg bg-white/5 border border-white/20 text-sm text-white/80",children:y.title},l))})]}),jsxs("div",{children:[jsxs("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:["Tasks (",d.cards.length,")"]}),jsxs("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:[d.cards.slice(0,10).map((y,l)=>jsx("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10",children:jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex-1",children:[jsx("p",{className:"text-sm font-medium text-white/90",children:y.title}),y.description&&jsx("p",{className:"text-xs text-white/60 mt-1 line-clamp-2",children:y.description})]}),y.priority&&jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${y.priority==="URGENT"?"bg-red-500/20 text-red-400":y.priority==="HIGH"?"bg-orange-500/20 text-orange-400":y.priority==="MEDIUM"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:y.priority})]})},l)),d.cards.length>10&&jsxs("p",{className:"text-xs text-white/50 text-center py-2",children:["+",d.cards.length-10," more tasks..."]})]})]})]})}):jsxs(Fragment,{children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"Project Description"}),jsx("textarea",{ref:f,value:s,onChange:y=>n(y.target.value),placeholder:"Example: Build a mobile app for tracking fitness goals with user authentication, workout logging, progress charts, and social features...",className:"w-full h-32 px-4 py-3 rounded-lg text-sm bg-white/5 border border-white/20 text-white placeholder-white/40 outline-none focus:border-blue-500/50 transition-all resize-none",disabled:C}),jsx("p",{className:"text-xs text-white/50 mt-2",children:"Be as specific as possible. Include features, technologies, and any special requirements."})]}),i&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:i}),jsxs("div",{className:"border-t border-white/10 pt-4",children:[jsx("p",{className:"text-xs font-semibold text-white/70 uppercase tracking-wider mb-3",children:"Example Prompts"}),jsx("div",{className:"space-y-2",children:["Build an e-commerce platform with product catalog, shopping cart, payment integration, and order tracking","Create a task management app with team collaboration, real-time updates, file attachments, and notifications","Develop a blog platform with markdown editor, SEO optimization, comments system, and analytics dashboard"].map((y,l)=>jsx("button",{onClick:()=>n(y),disabled:C,className:"w-full text-left px-3 py-2 rounded-lg text-xs text-white/70 hover:text-white hover:bg-white/5 transition-all border border-white/10 hover:border-white/20 disabled:opacity-50",children:y},l))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:C&&jsxs("div",{className:"flex items-center gap-2 text-blue-400 text-sm",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),jsx("span",{children:"Generating with AI..."})]})}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("button",{onClick:T,disabled:C,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-all hover:bg-white/10 text-white/80 disabled:opacity-50",children:"Cancel"}),d?jsx("button",{onClick:b,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all",style:{background:"linear-gradient(135deg, #10B981 0%, #059669 100%)",color:"#ffffff"},children:"Apply Plan to Board"}):jsx("button",{onClick:m,disabled:!s.trim()||C,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all disabled:opacity-50",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#ffffff"},children:C?"Generating...":"Generate Plan"})]})]})]})})]}):null}var Oi={"gpt-4-turbo":{provider:"openai",name:"GPT-4 Turbo",contextWindow:128e3,costPer1kInput:.01,costPer1kOutput:.03,supportsVision:true,supportsJSON:true},"gpt-4":{provider:"openai",name:"GPT-4",contextWindow:8192,costPer1kInput:.03,costPer1kOutput:.06,supportsVision:false,supportsJSON:true},"gpt-3.5-turbo":{provider:"openai",name:"GPT-3.5 Turbo",contextWindow:16385,costPer1kInput:5e-4,costPer1kOutput:.0015,supportsVision:false,supportsJSON:true},"claude-3-5-sonnet-20241022":{provider:"anthropic",name:"Claude 3.5 Sonnet",contextWindow:2e5,costPer1kInput:.003,costPer1kOutput:.015,supportsVision:true,supportsJSON:true},"claude-3-opus-20240229":{provider:"anthropic",name:"Claude 3 Opus",contextWindow:2e5,costPer1kInput:.015,costPer1kOutput:.075,supportsVision:true,supportsJSON:true},"claude-3-haiku-20240307":{provider:"anthropic",name:"Claude 3 Haiku",contextWindow:2e5,costPer1kInput:25e-5,costPer1kOutput:.00125,supportsVision:true,supportsJSON:true}};var hh={hobby:{requestsPerMonth:50,maxConcurrent:1,maxTokensPerRequest:4096},pro:{requestsPerMonth:500,maxConcurrent:3,maxTokensPerRequest:8192},enterprise:{requestsPerMonth:2e3,maxConcurrent:10,maxTokensPerRequest:16384}},bh={generatePlan:{enabled:true,minPlanTier:"hobby",estimatedTokens:2e3},predictRisks:{enabled:true,minPlanTier:"pro",estimatedTokens:1500},suggestAssignee:{enabled:true,minPlanTier:"hobby",estimatedTokens:800},generateReport:{enabled:true,minPlanTier:"enterprise",estimatedTokens:3e3},generateSubtasks:{enabled:true,minPlanTier:"hobby",estimatedTokens:1e3}};function yh(e,t,a){let r=Oi[e];if(!r)throw new Error(`Unknown model: ${e}`);let o=t/1e3*r.costPer1kInput,s=a/1e3*r.costPer1kOutput;return o+s}function Go(e){return `$${e.toFixed(4)}`}var zi=class{constructor(){this.operations=[];this.listeners=[];}record(t){let a=yh(t.model,t.inputTokens,t.outputTokens),r={...t,id:`op_${Date.now()}_${Math.random().toString(36).substring(7)}`,timestamp:new Date,cost:a};return this.operations.push(r),this.listeners.forEach(o=>o(r)),this.operations.length>1e3&&(this.operations=this.operations.slice(-1e3)),r}getStats(t){let a=this.operations;t&&(a=a.filter(d=>d.timestamp>=t.start&&d.timestamp<=t.end));let r=a.length,o=a.reduce((d,g)=>d+g.cost,0),s=a.reduce((d,g)=>d+g.inputTokens,0),n=a.reduce((d,g)=>d+g.outputTokens,0),c=a.filter(d=>d.success),p=a.reduce((d,g)=>d+g.duration,0),i={},u={};return a.forEach(d=>{i[d.feature]=(i[d.feature]||0)+1,u[d.feature]=(u[d.feature]||0)+d.cost;}),{totalOperations:r,totalCost:o,totalInputTokens:s,totalOutputTokens:n,operationsByFeature:i,costsByFeature:u,averageDuration:r>0?p/r:0,successRate:r>0?c.length/r:0}}getRecentOperations(t=10){return this.operations.slice(-t).reverse()}checkLimit(t,a="month"){let o={hobby:{month:50,day:5},pro:{month:500,day:50},enterprise:{month:2e3,day:200}}[t][a],s=new Date,n=new Date;a==="month"?n.setMonth(s.getMonth()-1):n.setDate(s.getDate()-1);let c=this.operations.filter(u=>u.timestamp>=n).length,p=Math.max(0,o-c),i=c/o*100;return {used:c,limit:o,remaining:p,percentUsed:i,isExceeded:c>=o}}subscribe(t){return this.listeners.push(t),()=>{let a=this.listeners.indexOf(t);a>-1&&this.listeners.splice(a,1);}}clear(){this.operations=[];}export(){return JSON.stringify(this.operations,null,2)}},Yr=new zi;function om({isOpen:e,onClose:t,planTier:a="hobby"}){let[r,o]=useState(Yr.getStats()),[s,n]=useState(Yr.checkLimit(a));if(useEffect(()=>{if(!e)return;let p=setInterval(()=>{o(Yr.getStats()),n(Yr.checkLimit(a));},1e3);return ()=>clearInterval(p)},[e,a]),useEffect(()=>{let p=i=>{i.key==="Escape"&&t();};if(e)return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[e,t]),!e)return null;let c=Yr.getRecentOperations(5);return jsxs(ut,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:t}),jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[100001] p-4",children:jsxs("div",{className:"w-full max-w-3xl rounded-2xl shadow-2xl border max-h-[90vh] overflow-hidden flex flex-col",style:{background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},onClick:p=>p.stopPropagation(),children:[jsxs("div",{className:"px-6 py-4 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsx("h2",{className:"text-xl font-bold text-white",children:"AI Usage Dashboard"}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Monitor your AI consumption and costs"})]}),jsx("button",{onClick:t,className:"text-white/60 hover:text-white transition-colors",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[jsxs("div",{className:"p-4 rounded-xl bg-gradient-to-r from-blue-500/10 to-purple-500/10 border border-blue-500/30",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxs("span",{className:"text-sm font-semibold text-white/90",children:["Monthly Usage (",a.toUpperCase(),")"]}),jsxs("span",{className:"text-sm font-bold text-white",children:[s.used," / ",s.limit]})]}),jsx("div",{className:"w-full h-2 bg-white/10 rounded-full overflow-hidden",children:jsx("div",{className:"h-full transition-all",style:{width:`${Math.min(100,s.percentUsed)}%`,background:s.percentUsed>90?"#EF4444":s.percentUsed>70?"#F59E0B":"#10B981"}})}),jsxs("p",{className:"text-xs text-white/60 mt-2",children:[s.remaining," operations remaining this month"]})]}),jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Total Cost"}),jsx("p",{className:"text-2xl font-bold text-green-400 mt-1",children:Go(r.totalCost)})]}),jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Operations"}),jsx("p",{className:"text-2xl font-bold text-blue-400 mt-1",children:r.totalOperations})]}),jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Tokens Used"}),jsx("p",{className:"text-2xl font-bold text-purple-400 mt-1",children:(r.totalInputTokens+r.totalOutputTokens).toLocaleString()}),jsxs("p",{className:"text-xs text-white/50 mt-1",children:[r.totalInputTokens.toLocaleString()," in /"," ",r.totalOutputTokens.toLocaleString()," out"]})]}),jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Success Rate"}),jsxs("p",{className:"text-2xl font-bold text-green-400 mt-1",children:[(r.successRate*100).toFixed(1),"%"]}),jsxs("p",{className:"text-xs text-white/50 mt-1",children:["Avg: ",r.averageDuration.toFixed(0),"ms"]})]})]}),jsxs("div",{children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-3",children:"Usage by Feature"}),jsx("div",{className:"space-y-2",children:Object.entries(r.operationsByFeature).map(([p,i])=>{let u=r.costsByFeature[p]||0,d=r.totalOperations>0?i/r.totalOperations*100:0;return jsxs("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("span",{className:"text-sm font-medium text-white/90 capitalize",children:p.replace(/([A-Z])/g," $1").trim()}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-white/60",children:[i," ops"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:Go(u)})]})]}),jsx("div",{className:"w-full h-1.5 bg-white/10 rounded-full overflow-hidden",children:jsx("div",{className:"h-full bg-blue-500",style:{width:`${d}%`}})})]},p)})})]}),jsxs("div",{children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-3",children:"Recent Operations"}),c.length===0?jsx("p",{className:"text-sm text-white/50 text-center py-8",children:"No operations yet. Start using AI features!"}):jsx("div",{className:"space-y-2",children:c.map(p=>jsxs("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsx("p",{className:"text-sm font-medium text-white/90 capitalize",children:p.feature.replace(/([A-Z])/g," $1").trim()}),jsxs("p",{className:"text-xs text-white/50 mt-0.5",children:[new Date(p.timestamp).toLocaleTimeString()," \u2022"," ",p.duration,"ms"]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-white/60",children:[p.inputTokens+p.outputTokens," tokens"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:Go(p.cost)}),jsx("div",{className:`w-2 h-2 rounded-full ${p.success?"bg-green-400":"bg-red-400"}`})]})]},p.id))})]})]}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("p",{className:"text-xs text-white/50",children:"Costs are estimates. Actual API charges may vary."}),jsx("button",{onClick:t,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-all hover:bg-white/10 text-white/80",children:"Close"})]})]})})]})}function im({isOpen:e,onClose:t,onTasksGenerated:a,onGenerateTasks:r,isLoading:o,projectName:s}){let[n,c]=useState(""),[p,i]=useState(""),[u,d]=useState(""),[g,f]=useState(false),[C,T]=useState(null),[m,b]=useState(null),[y,l]=useState(null),w=useRef(null),v=g||o;useEffect(()=>{e&&w.current&&w.current.focus();},[e]),useEffect(()=>{let A=N=>{N.key==="Escape"&&!v&&S();};if(e)return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[e,v]);let S=()=>{v||(c(""),i(""),d(""),T(null),b(null),l(null),t());},x=async()=>{if(!(!n.trim()||v)){f(true),T(null),b(null),l(null);try{let A=await r({prompt:n.trim(),projectName:s||"Mi Proyecto",startDate:p||void 0,endDate:u||void 0});b(A.tasks.tasks),l({from_cache:A.from_cache,tokens_used:A.tokens_used,mock_mode:A.mock_mode,similarity:A.similarity,tokens_saved:A.tokens_saved});}catch(A){T(A instanceof Error?A.message:"Failed to generate tasks");}finally{f(false);}}},k=()=>{m&&(a(m),S());};if(!e)return null;let O=y?.similarity?((y.similarity||0)*100).toFixed(0):"0";return jsxs(ut,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:S}),jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[100001] p-4",children:jsxs("div",{className:"w-full max-w-3xl rounded-2xl shadow-2xl border max-h-[90vh] overflow-hidden flex flex-col",style:{background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},onClick:A=>A.stopPropagation(),children:[jsxs("div",{className:"px-6 py-4 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-xl font-bold text-white flex items-center gap-2",children:[jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-blue-400",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"2",rx:"1",fill:"currentColor"}),jsx("rect",{x:"3",y:"9",width:"18",height:"2",rx:"1",fill:"currentColor"}),jsx("rect",{x:"3",y:"14",width:"18",height:"2",rx:"1",fill:"currentColor"}),jsx("rect",{x:"3",y:"19",width:"18",height:"2",rx:"1",fill:"currentColor"})]}),"Generate Gantt Tasks with AI"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Describe your project and let AI create a complete task timeline"})]}),jsx("button",{onClick:S,disabled:v,className:"text-white/60 hover:text-white transition-colors disabled:opacity-50",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:m?jsx(Fragment,{children:jsxs("div",{className:"space-y-4",children:[jsxs("div",{className:"flex items-center gap-2 text-green-400",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:jsx("path",{d:"M4 10L8 14L16 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"font-semibold",children:"Tasks Generated Successfully!"})]}),jsxs("div",{className:"flex flex-wrap gap-2",children:[y?.mock_mode&&jsx("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-yellow-500/20 text-yellow-400 border border-yellow-500/30",children:"Mock Mode"}),y?.from_cache?jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-blue-500/20 text-blue-400 border border-blue-500/30",children:["From Cache (",O,"% similar)"]}):jsx("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-green-500/20 text-green-400 border border-green-500/30",children:"AI Generated"}),jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-purple-500/20 text-purple-400 border border-purple-500/30",children:[y?.tokens_used||0," tokens"]}),y?.tokens_saved&&jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-indigo-500/20 text-indigo-400 border border-indigo-500/30",children:[y.tokens_saved," tokens saved"]}),jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-pink-500/20 text-pink-400 border border-pink-500/30",children:[m.length," tasks"]})]}),jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:m.map((A,N)=>jsx("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10 hover:bg-white/10 transition-colors",children:jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex-1",children:[jsxs("div",{className:"flex items-center gap-2 mb-1",children:[jsxs("span",{className:"text-xs text-white/50",children:["#",N+1]}),jsx("p",{className:"text-sm font-medium text-white/90",children:A.name})]}),jsxs("div",{className:"flex items-center gap-3 text-xs text-white/60",children:[jsxs("span",{className:"flex items-center gap-1",children:[jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"text-white/40",children:[jsx("rect",{x:"1",y:"2",width:"10",height:"8",rx:"1",stroke:"currentColor"}),jsx("path",{d:"M1 4h10",stroke:"currentColor"})]}),A.start," \u2192 ",A.end]}),jsxs("span",{children:[A.duration," days"]}),A.dependencies.length>0&&jsxs("span",{className:"text-blue-400",children:["Depends: ",A.dependencies.join(", ")]})]})]}),jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${A.priority==="high"?"bg-red-500/20 text-red-400":A.priority==="medium"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:A.priority})]})},A.id))})]})}):jsxs(Fragment,{children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"Project Description *"}),jsx("textarea",{ref:w,value:n,onChange:A=>c(A.target.value),placeholder:"Example: Build a mobile app for tracking fitness goals with user authentication, workout logging, progress charts, and social features...",className:"w-full h-32 px-4 py-3 rounded-lg text-sm bg-white/5 border border-white/20 text-white placeholder-white/40 outline-none focus:border-blue-500/50 transition-all resize-none",disabled:v}),jsx("p",{className:"text-xs text-white/50 mt-2",children:"Be as specific as possible. Include features, technologies, and any special requirements."})]}),jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"Start Date (Optional)"}),jsx("input",{type:"date",value:p,onChange:A=>i(A.target.value),className:"w-full px-4 py-2 rounded-lg text-sm bg-white/5 border border-white/20 text-white outline-none focus:border-blue-500/50 transition-all",disabled:v})]}),jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"End Date (Optional)"}),jsx("input",{type:"date",value:u,onChange:A=>d(A.target.value),className:"w-full px-4 py-2 rounded-lg text-sm bg-white/5 border border-white/20 text-white outline-none focus:border-blue-500/50 transition-all",disabled:v})]})]}),C&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:C}),jsxs("div",{className:"border-t border-white/10 pt-4",children:[jsx("p",{className:"text-xs font-semibold text-white/70 uppercase tracking-wider mb-3",children:"Example Prompts"}),jsx("div",{className:"space-y-2",children:["Build an e-commerce platform with product catalog, shopping cart, payment integration, and order tracking","Create a task management app with team collaboration, real-time updates, file attachments, and notifications","Develop a blog platform with markdown editor, SEO optimization, comments system, and analytics dashboard"].map((A,N)=>jsx("button",{onClick:()=>c(A),disabled:v,className:"w-full text-left px-3 py-2 rounded-lg text-xs text-white/70 hover:text-white hover:bg-white/5 transition-all border border-white/10 hover:border-white/20 disabled:opacity-50",children:A},N))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:v&&jsxs("div",{className:"flex items-center gap-2 text-blue-400 text-sm",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),jsx("span",{children:"Generating with AI..."})]})}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("button",{onClick:S,disabled:v,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-all hover:bg-white/10 text-white/80 disabled:opacity-50",children:"Cancel"}),m?jsx("button",{onClick:k,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all",style:{background:"linear-gradient(135deg, #10B981 0%, #059669 100%)",color:"#ffffff"},children:"Apply Tasks to Gantt"}):jsx("button",{onClick:x,disabled:!n.trim()||v,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all disabled:opacity-50",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#ffffff"},children:v?"Generating...":"Generate Tasks"})]})]})]})})]})}function Gn({initialBoard:e,onPersist:t}){let[a,r]=useState(e),o=useCallback(m=>{t&&Zo(()=>Promise.resolve(t(m)),{maxAttempts:3,initialDelay:1e3,onRetry:(b,y,l)=>{console.warn(`Retry attempt ${y} after ${l}ms: ${b.message}`);}}).then(b=>{b.success||console.error(`Failed to persist board after ${b.attempts} attempts:`,b.error);});},[t]),s=useCallback(async(m,b,y)=>{r(l=>{let w=l.cards.find(A=>A.id===m);if(!w)return l;let v=w.columnId,S={...w,columnId:b,position:y},x=l.cards.map(A=>A.id===m?S:A),k=l.columns.map(A=>{if(A.id===v)return {...A,cardIds:A.cardIds.filter(N=>N!==m)};if(A.id===b){let N=x.filter(H=>H.columnId===b).sort((H,L)=>H.position-L.position);return {...A,cardIds:N.map(H=>H.id)}}return A}),O={...l,cards:x,columns:k};return o(O),O});},[o]),n=useCallback(async(m,b)=>{r(y=>{let l=y.cards.map(v=>v.id===m?{...v,...b}:v),w={...y,cards:l};return o(w),w});},[o]),c=useCallback(async m=>{let b=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(y=>{let l={...m,id:b},w=y.columns.map(S=>S.id===m.columnId?{...S,cardIds:[...S.cardIds,b]}:S),v={...y,cards:[...y.cards,l],columns:w};return o(v),v});},[o]),p=useCallback(async m=>{r(b=>{let y=b.cards.find(S=>S.id===m);if(!y)return b;let l=b.cards.filter(S=>S.id!==m),w=b.columns.map(S=>S.id===y.columnId?{...S,cardIds:S.cardIds.filter(x=>x!==m)}:S),v={...b,cards:l,columns:w};return o(v),v});},[o]),i=useCallback(async m=>{let b=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(y=>{let l={...m,id:b,cardIds:[]},w={...y,columns:[...y.columns,l]};return o(w),w});},[o]),u=useCallback(async(m,b)=>{r(y=>{let l=y.columns.map(v=>v.id===m?{...v,...b}:v),w={...y,columns:l};return o(w),w});},[o]),d=useCallback(async m=>{r(b=>{let y=b.cards.filter(v=>v.columnId!==m),l=b.columns.filter(v=>v.id!==m),w={...b,cards:y,columns:l};return o(w),w});},[o]),g=useCallback(m=>{let b=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return c(m),b},[c]),f=useCallback(m=>{let b=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return i(m),b},[i]),C=useCallback(()=>{r(m=>{let b={...m,cards:[],columns:[]};return o(b),b});},[o]);return {board:a,callbacks:{onCardMove:s,onCardUpdate:n,onCardCreate:c,onCardDelete:p,onColumnCreate:i,onColumnUpdate:u,onColumnDelete:d},setBoard:r,helpers:{addCard:g,addColumn:f,deleteCard:p,deleteColumn:d,clearBoard:C}}}function dm({initialData:e,availableUsers:t=[],onSave:a}){let{board:r,callbacks:o,helpers:s}=Gn({initialBoard:e,onPersist:a}),n=useMemo(()=>({addCard:(p,i,u={})=>{s.addCard({title:i,columnId:p,position:r.cards.filter(d=>d.columnId===p).length,...u});},addColumn:(p,i)=>{let u=r.columns.length>0?Math.max(...r.columns.map(d=>d.position)):0;s.addColumn({title:p,position:i??u+1e3});},reset:s.clearBoard}),[r.cards,r.columns,s]);return {props:useMemo(()=>({board:r,callbacks:o,availableUsers:t}),[r,o,t]),board:r,callbacks:o,utils:n}}var _o={dateFilter:"all",priorities:[],assignees:[],labels:[],columns:[],search:""},mm={by:"none",order:"asc"};function pm({initialFilters:e={},initialSort:t={},currentUserId:a}={}){let[r,o]=useState({..._o,...e}),[s,n]=useState({...mm,...t}),c=useCallback(T=>{o(m=>({...m,...T}));},[]),p=useCallback(T=>{n(m=>({...m,...T}));},[]),i=useCallback(()=>{o(_o),n(mm);},[]),u=useCallback(()=>{a&&o({..._o,assignees:[a]});},[a]),d=useCallback(()=>{o({..._o,dateFilter:"overdue"});},[]),g=useCallback(()=>{o({..._o,priorities:["HIGH","URGENT"]});},[]),f=useMemo(()=>r.dateFilter!=="all"||r.priorities.length>0||r.assignees.length>0||r.labels.length>0||r.columns.length>0||r.search!==""||s.by!=="none",[r,s]),C=useCallback(T=>{let m=[...T];if(r.search){let b=r.search.toLowerCase();m=m.filter(y=>y.title.toLowerCase().includes(b)||y.description?.toLowerCase().includes(b));}if(r.dateFilter!=="all"){let b=new Date,y=b.getFullYear(),l=String(b.getMonth()+1).padStart(2,"0"),w=String(b.getDate()).padStart(2,"0"),v=`${y}-${l}-${w}`;m=m.filter(S=>{if(!S.endDate&&!S.dueDate)return false;let x=S.endDate||S.dueDate;if(!x)return false;let k;if(typeof x=="string")k=x.split("T")[0]||x;else {let O=x.getUTCFullYear(),A=String(x.getUTCMonth()+1).padStart(2,"0"),N=String(x.getUTCDate()).padStart(2,"0");k=`${O}-${A}-${N}`;}switch(r.dateFilter){case "overdue":return k<v;case "today":return k===v;case "this-week":let O=new Date(v+"T00:00:00"),A=new Date(k+"T00:00:00"),N=new Date(O);return N.setDate(N.getDate()+7),A>=O&&A<=N;case "custom":if(r.dateRange){let H=typeof x=="string"?new Date(x):x;return H>=r.dateRange.start&&H<=r.dateRange.end}return true;default:return true}});}return r.priorities.length>0&&(m=m.filter(b=>b.priority&&r.priorities.includes(b.priority))),r.assignees.length>0&&(m=m.filter(b=>(b.assignedUserIds||(b.assigneeId?[b.assigneeId]:[])).some(l=>r.assignees.includes(l)))),r.labels.length>0&&(m=m.filter(b=>b.labels&&b.labels.some(y=>r.labels.includes(y)))),r.columns.length>0&&(m=m.filter(b=>r.columns.includes(b.columnId))),s.by!=="none"&&m.sort((b,y)=>{let l=0;switch(s.by){case "created":let w=b.createdAt?new Date(b.createdAt).getTime():0,v=y.createdAt?new Date(y.createdAt).getTime():0;l=w-v;break;case "priority":let S={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},x=S[b.priority||"LOW"],k=S[y.priority||"LOW"];l=x-k;break;case "dueDate":let O=b.endDate||b.dueDate,A=y.endDate||y.dueDate;if(!O)return 1;if(!A)return -1;let N=typeof O=="string"?new Date(O).getTime():O.getTime(),H=typeof A=="string"?new Date(A).getTime():A.getTime();l=N-H;break;case "title":l=b.title.localeCompare(y.title);break;case "estimate":let L=b.estimatedTime||0,q=y.estimatedTime||0;l=L-q;break;default:l=0;}return s.order==="asc"?l:-l}),m},[r,s]);return {filters:r,sort:s,setFilters:c,setSort:p,resetFilters:i,filterMyTasks:u,filterOverdue:d,filterHighPriority:g,applyFilters:C,hasActiveFilters:f}}var gm,fm;if(typeof window<"u")try{let e=qo("ai");gm=e.generateObject,fm=e.generateText;}catch{}function hm(e={}){let[t,a]=useState(false),[r,o]=useState(null),s=!!(gm&&fm&&e.apiKey),n=useCallback(async d=>{if(!s)throw new Error('AI features require the "ai" package and an API key. Install with: npm install ai');a(true),o(null);try{return console.log("Generating plan for:",d),{columns:[{title:"To Do",position:1e3,cardIds:[]},{title:"In Progress",position:2e3,cardIds:[]},{title:"Done",position:3e3,cardIds:[]}],cards:[{title:"Generated task from AI",description:`Based on: ${d}`,position:1e3,columnId:"temp-col-1"}],explanation:"This is a sample plan. Real implementation would use AI SDK."}}catch(g){let f=g instanceof Error?g:new Error("Failed to generate plan");throw o(f),f}finally{a(false);}},[s]),c=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Suggesting assignee for:",d.title),{userId:"user-123",confidence:.85,reasoning:"Based on past performance and expertise"}}catch(g){let f=g instanceof Error?g:new Error("Failed to suggest assignee");throw o(f),f}finally{a(false);}},[s]),p=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Analyzing board for risks..."),[{type:"RISK_OVERLOAD",severity:"HIGH",title:"Column overload detected",description:'Too many cards in "In Progress"',confidence:.9,suggestedAction:'Consider moving some cards back to "To Do"'}]}catch(g){let f=g instanceof Error?g:new Error("Failed to predict risks");throw o(f),f}finally{a(false);}},[s]),i=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Generating subtasks for:",d.title),[{title:`Subtask 1 for: ${d.title}`,position:d.position+.1,columnId:d.columnId},{title:`Subtask 2 for: ${d.title}`,position:d.position+.2,columnId:d.columnId}]}catch(g){let f=g instanceof Error?g:new Error("Failed to generate subtasks");throw o(f),f}finally{a(false);}},[s]),u=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Estimating effort for:",d.title),{hours:8,confidence:.75}}catch(g){let f=g instanceof Error?g:new Error("Failed to estimate effort");throw o(f),f}finally{a(false);}},[s]);return {onGeneratePlan:n,onSuggestAssignee:c,onPredictRisks:p,onGenerateSubtasks:i,onEstimateEffort:u,isAvailable:s,isLoading:t,error:r}}function $i(){let[e,t]=useState(()=>selectionStore.getState());useEffect(()=>selectionStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{selectionStore.setState(r);},[]);return [e,a]}function bm(e){let{cards:t}=e,[a,r]=$i(),o=useCallback(d=>a.selectedCardIds.includes(d),[a.selectedCardIds]),s=useCallback((d,g)=>{if(!g){r({selectedCardIds:[d],lastSelectedCardId:d});return}let f=g.ctrlKey||g.metaKey,C=g.shiftKey;if(f)a.selectedCardIds.includes(d)?r({selectedCardIds:a.selectedCardIds.filter(T=>T!==d),lastSelectedCardId:a.lastSelectedCardId}):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});else if(C&&a.lastSelectedCardId){let T=t.find(b=>b.id===d),m=t.find(b=>b.id===a.lastSelectedCardId);if(T&&m&&T.columnId===m.columnId){let b=t.filter(k=>k.columnId===T.columnId).sort((k,O)=>k.position-O.position),y=b.findIndex(k=>k.id===a.lastSelectedCardId),l=b.findIndex(k=>k.id===d),[w,v]=y<l?[y,l]:[l,y],S=b.slice(w,v+1).map(k=>k.id),x=Array.from(new Set([...a.selectedCardIds,...S]));r({selectedCardIds:x,lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});},[t,a,r]),n=useCallback(d=>{r({selectedCardIds:a.selectedCardIds.filter(g=>g!==d),lastSelectedCardId:a.lastSelectedCardId});},[a,r]),c=useCallback(()=>{r({selectedCardIds:[],lastSelectedCardId:null});},[r]),p=useCallback(()=>{r({selectedCardIds:t.map(d=>d.id),lastSelectedCardId:t[t.length-1]?.id||null});},[t,r]),i=useCallback(d=>{a.selectedCardIds.includes(d)?n(d):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});},[a,n,r]),u=useCallback(()=>t.filter(d=>a.selectedCardIds.includes(d.id)),[t,a.selectedCardIds]);return {selectedCardIds:a.selectedCardIds,lastSelectedCardId:a.lastSelectedCardId,isCardSelected:o,selectCard:s,deselectCard:n,clearSelection:c,selectAll:p,toggleCard:i,getSelectedCards:u}}var ym={enableAutoStacking:true,autoStackConfidenceThreshold:.7,minCardsPerStack:2,enableManualStacking:true,showStackSummaries:true,animationDuration:200};function vm(e){let{cards:t,config:a,aiService:r}=e,o=useMemo(()=>({...ym,...a}),[a]),[s,n]=useState([]),c=useCallback((T,m,b,y,l)=>{if(m.length<o.minCardsPerStack){console.warn(`Cannot create stack: minimum ${o.minCardsPerStack} cards required`);return}let w={id:`stack-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:T,cardIds:m,columnId:b,strategy:y,color:l,isExpanded:true,position:s.filter(v=>v.columnId===b).length,createdAt:new Date};n(v=>[...v,w]);},[o.minCardsPerStack,s]),p=useCallback(T=>{n(m=>m.filter(b=>b.id!==T));},[]),i=useCallback(T=>{n(m=>m.map(b=>b.id===T?{...b,isExpanded:!b.isExpanded}:b));},[]),u=useCallback((T,m)=>{n(b=>b.map(y=>y.id===T&&!y.cardIds.includes(m)?{...y,cardIds:[...y.cardIds,m]}:y));},[]),d=useCallback((T,m)=>{n(b=>b.map(y=>{if(y.id===T){let l=y.cardIds.filter(w=>w!==m);return l.length<o.minCardsPerStack?null:{...y,cardIds:l}}return y}).filter(y=>y!==null));},[o.minCardsPerStack]),g=useCallback(T=>s.filter(m=>m.columnId===T).sort((m,b)=>m.position-b.position),[s]),f=useCallback(async T=>{let m=t.filter(v=>v.columnId===T);if(m.length<o.minCardsPerStack*2)return [];let b=[],y=new Map;m.forEach(v=>{v.labels&&v.labels.length>0&&v.labels.forEach(S=>{y.has(S)||y.set(S,[]),y.get(S).push(v);});}),y.forEach((v,S)=>{v.length>=o.minCardsPerStack&&b.push({stack:{title:`\u{1F4CC} ${S}`,cardIds:v.map(x=>x.id),columnId:T,strategy:"labels",color:"#3b82f6"},reason:`${v.length} cards with label "${S}"`,confidence:.85});});let l=new Map;m.forEach(v=>{v.assignedUserIds&&v.assignedUserIds.length>0&&v.assignedUserIds.forEach(S=>{l.has(S)||l.set(S,[]),l.get(S).push(v);});}),l.forEach((v,S)=>{v.length>=o.minCardsPerStack&&b.push({stack:{title:`\u{1F464} Assigned to user-${S.slice(-4)}`,cardIds:v.map(x=>x.id),columnId:T,strategy:"assignee",color:"#8b5cf6"},reason:`${v.length} cards assigned to the same user`,confidence:.8});});let w=new Map;if(m.forEach(v=>{v.priority&&(w.has(v.priority)||w.set(v.priority,[]),w.get(v.priority).push(v));}),w.forEach((v,S)=>{if(v.length>=o.minCardsPerStack){let x={low:"\u{1F7E2}",medium:"\u{1F7E1}",high:"\u{1F534}",urgent:"\u{1F6A8}"}[S.toLowerCase()]||"\u26AA";b.push({stack:{title:`${x} ${S} Priority`,cardIds:v.map(k=>k.id),columnId:T,strategy:"priority",color:S==="high"||S==="urgent"?"#ef4444":"#10b981"},reason:`${v.length} cards with ${S} priority`,confidence:.75});}}),r&&o.enableAutoStacking)for(let v of m){let x=(await r.findSimilar(v,m)).filter(k=>k.similarity>=o.autoStackConfidenceThreshold);if(x.length>=o.minCardsPerStack-1){let k=[v.id,...x.map(A=>A.card.id)],O=x.reduce((A,N)=>A+N.similarity,0)/x.length;b.push({stack:{title:`\u2728 Similar to "${v.title.substring(0,30)}${v.title.length>30?"...":""}"`,cardIds:k,columnId:T,strategy:"ai-similarity",color:"#f59e0b"},reason:`AI detected ${x.length+1} similar tasks`,confidence:O});}}return b.filter(v=>v.confidence>=o.autoStackConfidenceThreshold).sort((v,S)=>S.confidence-v.confidence).slice(0,5)},[t,o,r]),C=useCallback(T=>{c(T.stack.title,T.stack.cardIds,T.stack.columnId,T.stack.strategy,T.stack.color);},[c]);return useEffect(()=>{o.enableAutoStacking&&s.length===0&&new Set(t.map(m=>m.columnId)).forEach(async m=>{let b=await f(m),y=b[0];b.length>0&&y&&y.confidence>=.9&&C(y);});},[]),{stacks:s,createStack:c,deleteStack:p,toggleStack:i,addToStack:u,removeFromStack:d,getStacksForColumn:g,getSuggestions:f,applySuggestion:C,config:o}}var xm=createContext(null);function km({children:e,initialData:t,onStateChange:a}){let r=useRef();if(!r.current){let s=new Map,n=new Map;t?.columns?.forEach(p=>{let{Column:i}=qo("@libxai/core");s.set(p.id,new i(p));}),t?.cards?.forEach(p=>{let{Card:i}=qo("@libxai/core");n.set(p.id,new i(p));});let c=null;if(t?.board){let{Board:p}=qo("@libxai/core");c=new p(t.board);}r.current=new BoardStore({board:c,columns:s,cards:n});}let o=r.current;return useEffect(()=>{if(a)return o.subscribeAll(s=>{a(o.getState());})},[o,a]),jsx(xm.Provider,{value:{store:o},children:e})}function _n(){let e=useContext(xm);if(!e)throw new Error("useBoardStore must be used within BoardProvider");return e.store}function jo(){let e=_n(),[t,a]=useState(e.getBoard()),[r,o]=useState(e.getAllColumns()),[s,n]=useState(e.getAllCards());useEffect(()=>e.subscribeAll(()=>{a(e.getBoard()),o(e.getAllColumns()),n(e.getAllCards());}),[e]);let c=useCallback(y=>{e.updateBoard(y);},[e]),p=useCallback(y=>{e.addColumn(y);},[e]),i=useCallback((y,l)=>{e.updateColumn(y,l);},[e]),u=useCallback(y=>{e.deleteColumn(y);},[e]),d=useCallback(y=>e.getColumn(y),[e]),g=useCallback(y=>{e.addCard(y);},[e]),f=useCallback((y,l)=>{e.updateCard(y,l);},[e]),C=useCallback(y=>{e.deleteCard(y);},[e]),T=useCallback((y,l,w)=>{e.moveCard(y,l,w);},[e]),m=useCallback(y=>e.getCard(y),[e]),b=useCallback(y=>e.getCardsByColumn(y),[e]);return {board:t,columns:r,cards:s,updateBoard:c,addColumn:p,updateColumn:i,deleteColumn:u,getColumn:d,addCard:g,updateCard:f,deleteCard:C,moveCard:T,getCard:m,getCardsByColumn:b}}function Cm(e){let{cards:t}=jo();return useMemo(()=>e?t.filter(a=>{if(e.searchQuery){let r=e.searchQuery.toLowerCase(),o=a.title.toLowerCase().includes(r),s=a.description?.toLowerCase().includes(r);if(!o&&!s)return false}return !(e.priorities&&e.priorities.length>0&&(!a.priority||!e.priorities.includes(a.priority))||e.statuses&&e.statuses.length>0&&(!a.status||!e.statuses.includes(a.status))||e.assignedUserIds&&e.assignedUserIds.length>0&&!e.assignedUserIds.some(o=>a.isAssignedTo(o))||e.labels&&e.labels.length>0&&!e.labels.some(o=>a.hasLabel(o))||e.columnIds&&e.columnIds.length>0&&!e.columnIds.includes(a.columnId)||e.isOverdue!==void 0&&e.isOverdue!==a.isOverdue())}):t,[t,e])}function Tm(e="position",t="asc"){let{cards:a}=jo();return useMemo(()=>[...a].sort((o,s)=>{let n=0;switch(e){case "title":n=o.title.localeCompare(s.title);break;case "priority":{let c={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},p=o.priority?c[o.priority]:0,i=s.priority?c[s.priority]:0;n=p-i;break}case "createdAt":n=o.createdAt.getTime()-s.createdAt.getTime();break;case "updatedAt":n=o.updatedAt.getTime()-s.updatedAt.getTime();break;case "position":n=o.position-s.position;break}return t==="asc"?n:-n}),[a,e,t])}var Vn=class{constructor(){this.plugins=new Map;this.enabled=new Set;this.config=new Map;this.context=null;this.pluginLogger=yl.child("PluginManager");}setContext(t){this.context=t;}register(t){if(!t.id||!t.name||!t.version)throw new Error("Plugin must have id, name, and version");if(this.plugins.has(t.id)&&this.pluginLogger.warn(`Plugin ${t.id} is already registered, overwriting...`),t.dependencies){for(let a of t.dependencies)if(!this.plugins.has(a))throw new Error(`Plugin ${t.id} depends on ${a} which is not registered`)}this.plugins.set(t.id,t),t.defaultConfig&&this.config.set(t.id,{...t.defaultConfig}),this.enabled.add(t.id),this.pluginLogger.info(`Plugin registered: ${t.name} v${t.version}`),t.onInit&&this.context&&Promise.resolve(t.onInit(this.context)).catch(a=>{this.pluginLogger.error(`Failed to initialize plugin ${t.id}`,a,{plugin:t.id});});}unregister(t){let a=this.plugins.get(t);if(!a){this.pluginLogger.warn(`Plugin ${t} is not registered`);return}a.onDestroy&&Promise.resolve(a.onDestroy()).catch(r=>{this.pluginLogger.error(`Failed to destroy plugin ${t}`,r);}),this.plugins.delete(t),this.enabled.delete(t),this.config.delete(t),this.pluginLogger.info(`Plugin unregistered: ${a.name}`);}getPlugin(t){return this.plugins.get(t)}getPlugins(){return Array.from(this.plugins.values())}hasPlugin(t){return this.plugins.has(t)}setEnabled(t,a){if(!this.plugins.has(t))throw new Error(`Plugin ${t} is not registered`);a?(this.enabled.add(t),this.pluginLogger.info(`Plugin enabled: ${t}`)):(this.enabled.delete(t),this.pluginLogger.info(`Plugin disabled: ${t}`));}isEnabled(t){return this.enabled.has(t)}getConfig(t,a){return this.config.get(t)?.[a]}setConfig(t,a,r){this.config.has(t)||this.config.set(t,{});let o=this.config.get(t);o[a]=r,this.pluginLogger.debug(`Plugin config set: ${t}.${a}`,{value:r});}async executeHook(t,a,r){let o=r;for(let s of this.plugins.values()){if(!this.enabled.has(s.id))continue;let n=s[t];if(typeof n=="function")try{let c=await Promise.resolve(n.apply(s,a));c!==void 0&&(o=c,a[0]=c);}catch(c){this.pluginLogger.error(`Plugin hook failed: ${s.id}.${t}`,c,{plugin:s.id,hook:t});}}return o}async executeHookParallel(t,a){let r=[];for(let o of this.plugins.values()){if(!this.enabled.has(o.id))continue;let s=o[t];typeof s=="function"&&r.push(Promise.resolve(s.apply(o,a)).catch(n=>{this.pluginLogger.error(`Plugin hook failed: ${o.id}.${t}`,n,{plugin:o.id,hook:t});}));}await Promise.all(r);}},Bh=new Vn;function Dm({items:e,height:t,estimateSize:a,renderItem:r,className:o="",overscan:s=5,horizontal:n=false,gap:c=0,getItemKey:p}){let i=useRef(null),u=useVirtualizer({count:e.length,getScrollElement:()=>i.current,estimateSize:()=>a,overscan:s,horizontal:n,gap:c}),d=u.getVirtualItems(),g={height:typeof t=="number"?`${t}px`:t,width:"100%",overflow:"auto",position:"relative"},f=n?{width:`${u.getTotalSize()}px`,height:"100%",position:"relative"}:{height:`${u.getTotalSize()}px`,width:"100%",position:"relative"};return jsx("div",{ref:i,style:g,className:o,children:jsx("div",{style:f,children:d.map(C=>{let T=e[C.index];if(!T)return null;let m=p?p(T,C.index):C.index,b={position:"absolute",top:n?0:C.start,left:n?C.start:0,width:n?C.size:"100%",height:n?"100%":C.size};return jsx("div",{style:b,"data-index":C.index,children:r(T,C.index)},m)})})})}function Sm(e){return useVirtualizer({count:e.items.length,getScrollElement:()=>e.scrollElement,estimateSize:()=>e.estimateSize,overscan:e.overscan??5,horizontal:e.horizontal??false,gap:e.gap??0})}function Pm({items:e,height:t,width:a="100%",estimateColumnWidth:r,renderColumn:o,className:s="",overscan:n=3,gap:c=16,getItemKey:p,horizontal:i=true}){let u=useRef(null),d=useVirtualizer({horizontal:i,count:e.length,getScrollElement:()=>u.current,estimateSize:()=>r,overscan:n,gap:c}),g=d.getVirtualItems(),f={height:typeof t=="number"?`${t}px`:t,width:typeof a=="number"?`${a}px`:a,overflow:"auto",position:"relative"},C={width:`${d.getTotalSize()}px`,height:"100%",position:"relative"};return jsx("div",{ref:u,style:f,className:s,children:jsx("div",{style:C,children:g.map(T=>{let m=e[T.index];if(!m)return null;let b=p?p(m,T.index):T.index,y={position:"absolute",top:0,left:T.start,width:T.size,height:"100%"};return jsx("div",{style:y,"data-index":T.index,children:o(m,T.index)},b)})})})}function Mm(e){let t=useVirtualizer({horizontal:true,count:e.items.length,getScrollElement:()=>e.scrollElement,estimateSize:()=>e.estimateColumnWidth,overscan:e.overscan??3,gap:e.gap??0});return {columnVirtualizer:t,virtualColumns:t.getVirtualItems(),totalWidth:t.getTotalSize()}}function Am(e,t=10){return e>t}var _i={none:0,xs:4,sm:8,md:12,lg:16,xl:20,"2xl":24,"3xl":32,"4xl":40,"5xl":48,"6xl":64},Vi={none:0,sm:4,md:8,lg:12,xl:16,"2xl":20,full:9999},ji={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48},Ki={light:300,normal:400,medium:500,semibold:600,bold:700,extrabold:800},Yi={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},qi={base:0,dropdown:1e3,sticky:1020,fixed:1030,modalBackdrop:1040,modal:1050,popover:1060,tooltip:1070},Xi={instant:0,fastest:75,faster:100,fast:150,normal:200,slow:300,slower:400,slowest:500},Ji={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",smooth:"cubic-bezier(0.4, 0.0, 0.2, 1)",sharp:"cubic-bezier(0.4, 0.0, 0.6, 1)",bounce:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},Zi={none:"none",sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",base:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",xl:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)","2xl":"0 25px 50px -12px rgba(0, 0, 0, 0.25)",inner:"inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)"},Qi={0:0,5:.05,10:.1,20:.2,30:.3,40:.4,50:.5,60:.6,70:.7,80:.8,90:.9,100:1},el={column:{width:320,minWidth:280,maxWidth:400,gap:16,padding:12,headerHeight:48},card:{minHeight:80,maxHeight:400,padding:12,gap:8},board:{padding:16,gap:16}},tl={timeline:{headerHeight:60,rowHeight:44,minRowHeight:32,maxRowHeight:80,taskPadding:4,gridLineWidth:1},task:{height:28,minHeight:20,maxHeight:40,borderRadius:4,padding:6},dependency:{lineWidth:2,arrowSize:8},scale:{day:{columnWidth:40,minColumnWidth:30,maxColumnWidth:60},week:{columnWidth:80,minColumnWidth:60,maxColumnWidth:120},month:{columnWidth:120,minColumnWidth:80,maxColumnWidth:200},quarter:{columnWidth:200,minColumnWidth:150,maxColumnWidth:300}},milestone:{size:16,rotation:45}},jn={spacing:_i,borderRadius:Vi,fontSize:ji,fontWeight:Ki,lineHeight:Yi,zIndex:qi,duration:Xi,easing:Ji,shadows:Zi,opacity:Qi,kanban:el,gantt:tl};function Fm(e,t,a){return e[t]??a}function al(e,t="",a={}){for(let[r,o]of Object.entries(e)){let s=t?`${t}-${r}`:r;typeof o=="object"&&o!==null&&!Array.isArray(o)?al(o,s,a):(typeof o=="string"||typeof o=="number")&&(a[s]=o);}return a}function zh(e){return typeof e=="number"?e>0&&e<1e3?`${e}px`:e.toString():e}function rl(e="asakaa"){let t=al(jn),a=[];for(let[r,o]of Object.entries(t)){let s=`--${e}-${r}`,n=zh(o);a.push(` ${s}: ${n};`);}return `:root {
389
+ Today's date: ${new Date().toISOString().split("T")[0]}`}function wc(e){let t=[],a=r=>{for(let o of r)t.push(o),o.subtasks?.length&&a(o.subtasks);};return a(e),t}function br(e,t){let a=wc(e),r=t.toLowerCase().trim(),o=a.find(c=>c.name.toLowerCase()===r);if(o)return o;let s=a.find(c=>c.name.toLowerCase().includes(r));if(s)return s;let n=r.split(/\s+/);return a.find(c=>{let p=c.name.toLowerCase();return n.every(i=>p.includes(i))})}function yi(e,t=new Date){let a=e.toLowerCase().trim(),r=new Date(t);if(r.setHours(0,0,0,0),a==="today"||a==="hoy")return r;if(a==="tomorrow"||a==="ma\xF1ana"){let g=new Date(r);return g.setDate(g.getDate()+1),g}if(a==="yesterday"||a==="ayer"){let g=new Date(r);return g.setDate(g.getDate()-1),g}if(a==="next week"||a==="la pr\xF3xima semana"){let g=new Date(r);return g.setDate(g.getDate()+7),g}let o=a.match(/(?:next\s+)?(monday|tuesday|wednesday|thursday|friday|saturday|sunday|lunes|martes|miércoles|miercoles|jueves|viernes|sábado|sabado|domingo)/i);if(o){let h={sunday:0,domingo:0,monday:1,lunes:1,tuesday:2,martes:2,wednesday:3,mi\u00E9rcoles:3,miercoles:3,thursday:4,jueves:4,friday:5,viernes:5,saturday:6,s\u00E1bado:6,sabado:6}[o[1].toLowerCase()];if(h!==void 0){let C=new Date(r),T=C.getDay(),m=h-T;return m<=0&&(m+=7),C.setDate(C.getDate()+m),C}}let s=a.match(/in\s+(\d+)\s+(day|week|month|día|dias|semana|semanas|mes|meses)s?/i);if(s&&s[1]&&s[2]){let g=parseInt(s[1],10),h=s[2].toLowerCase(),C=new Date(r);return h==="day"||h==="d\xEDa"||h==="dias"?C.setDate(C.getDate()+g):h==="week"||h==="semana"||h==="semanas"?C.setDate(C.getDate()+g*7):(h==="month"||h==="mes"||h==="meses")&&C.setMonth(C.getMonth()+g),C}if(a.match(/(\d{4})-(\d{2})-(\d{2})/))return new Date(a);let c=a.match(/(\d{1,2})\/(\d{1,2})\/(\d{4})/);if(c&&c[1]&&c[2]&&c[3]){let g=parseInt(c[1],10),h=parseInt(c[2],10)-1,C=parseInt(c[3],10);return new Date(C,h,g)}let p={enero:0,febrero:1,marzo:2,abril:3,mayo:4,junio:5,julio:6,agosto:7,septiembre:8,octubre:9,noviembre:10,diciembre:11},i=a.match(/(\d{1,2})\s+de\s+(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)(?:\s+de\s+(\d{4}))?/i);if(i&&i[1]&&i[2]){let g=parseInt(i[1],10),h=p[i[2].toLowerCase()],C=i[3]?parseInt(i[3],10):r.getFullYear();if(h!==void 0)return new Date(C,h,g)}let u={january:0,february:1,march:2,april:3,may:4,june:5,july:6,august:7,september:8,october:9,november:10,december:11},d=a.match(/(january|february|march|april|may|june|july|august|september|october|november|december)\s+(\d{1,2})(?:,?\s+(\d{4}))?/i);if(d&&d[1]&&d[2]){let g=u[d[1].toLowerCase()],h=parseInt(d[2],10),C=d[3]?parseInt(d[3],10):r.getFullYear();if(g!==void 0)return new Date(C,g,h)}return null}function vi(e){let a=e.toLowerCase().trim().match(/(\d+)\s*(day|week|month|día|dias|semana|semanas|mes|meses)s?/i);if(a&&a[1]&&a[2]){let r=parseInt(a[1],10),o=a[2].toLowerCase();if(o==="day"||o==="d\xEDa"||o==="dias")return r;if(o==="week"||o==="semana"||o==="semanas")return r*7;if(o==="month"||o==="mes"||o==="meses")return r*30}return null}function xi(e){let t=e.match(/(\d+)(?:\s*%)?/);if(t&&t[1]){let a=parseInt(t[1],10);return Math.max(0,Math.min(100,a))}return null}function Cc(e){let t=e.toLowerCase().trim();return t.includes("todo")||t.includes("pendiente")||t.includes("por hacer")?"todo":t.includes("in progress")||t.includes("in-progress")||t.includes("en progreso")||t.includes("working")||t.includes("trabajando")?"in-progress":t.includes("done")||t.includes("complete")||t.includes("finished")||t.includes("completado")||t.includes("terminado")||t.includes("hecho")?"completed":null}function Tc(e,t){let a=e.toLowerCase().trim(),r=a.match(/(?:move|mover|mueve)\s+(?:la\s+tarea\s+)?["""]?(.+?)["""]?\s+(?:to|a|para)\s+(?:la\s+fecha\s+)?(.+)/i);if(r&&r[1]&&r[2]){let i=r[1].trim(),u=r[2].trim(),d=br(t,i),g=yi(u);if(!d)return {type:"move_task",taskName:i,message:`Could not find a task named "${i}". Please check the task name and try again.`,success:false,error:"Task not found"};if(!g)return {type:"move_task",taskId:d.id,taskName:d.name,message:`Could not parse the date "${u}". Try using formats like "next Monday", "in 3 days", or "2024-01-15".`,success:false,error:"Invalid date"};let h=d.startDate&&d.endDate?Math.round((d.endDate.getTime()-d.startDate.getTime())/(1e3*60*60*24)):1,C=new Date(g);return C.setDate(C.getDate()+h),{type:"move_task",taskId:d.id,taskName:d.name,updates:{startDate:g,endDate:C},message:`Moved "${d.name}" to ${g.toLocaleDateString()}.`,success:true}}let o=a.match(/(?:extend|extender|extiende|alargar)\s+["""]?(.+?)["""]?\s+(?:by|por)\s+(.+)/i);if(o&&o[1]&&o[2]){let i=o[1].trim(),u=o[2].trim(),d=br(t,i),g=vi(u);if(!d)return {type:"resize_task",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"};if(!g||!d.endDate)return {type:"resize_task",taskId:d.id,taskName:d.name,message:`Could not parse the duration "${u}".`,success:false,error:"Invalid duration"};let h=new Date(d.endDate);return h.setDate(h.getDate()+g),{type:"resize_task",taskId:d.id,taskName:d.name,updates:{endDate:h},message:`Extended "${d.name}" by ${g} days. New end date: ${h.toLocaleDateString()}.`,success:true}}let s=a.match(/(?:set|establecer|poner)\s+["""]?(.+?)["""]?\s+(?:progress|progreso)\s+(?:to|a|en)\s+(.+)/i);if(s&&s[1]&&s[2]){let i=s[1].trim(),u=s[2].trim(),d=br(t,i),g=xi(u);return d?g===null?{type:"set_progress",taskId:d.id,taskName:d.name,message:`Could not parse the progress value "${u}".`,success:false,error:"Invalid progress"}:{type:"set_progress",taskId:d.id,taskName:d.name,updates:{progress:g},message:`Set "${d.name}" progress to ${g}%.`,success:true}:{type:"set_progress",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"}}let n=a.match(/(?:rename|renombrar|cambiar nombre de)\s+["""]?(.+?)["""]?\s+(?:to|a|por)\s+["""]?(.+?)["""]?$/i);if(n&&n[1]&&n[2]){let i=n[1].trim(),u=n[2].trim(),d=br(t,i);return d?{type:"rename_task",taskId:d.id,taskName:d.name,updates:{name:u},message:`Renamed "${d.name}" to "${u}".`,success:true}:{type:"rename_task",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"}}let c=a.match(/(?:link|vincular|conectar)\s+["""]?(.+?)["""]?\s+(?:to|a|con)\s+["""]?(.+?)["""]?$/i);if(c&&c[1]&&c[2]){let i=c[1].trim(),u=c[2].trim(),d=br(t,i),g=br(t,u);return d?g?{type:"link_tasks",taskId:g.id,taskName:g.name,dependencyFrom:d.id,dependencyTo:g.id,message:`Linked "${d.name}" \u2192 "${g.name}".`,success:true}:{type:"link_tasks",taskName:u,message:`Could not find a task named "${u}".`,success:false,error:"Target task not found"}:{type:"link_tasks",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Source task not found"}}let p=a.match(/(?:delete|eliminar|borrar|remove|quitar)\s+["""]?(.+?)["""]?$/i);if(p&&p[1]){let i=p[1].trim(),u=br(t,i);return u?{type:"delete_task",taskId:u.id,taskName:u.name,message:`Deleted "${u.name}".`,success:true}:{type:"delete_task",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"}}return null}function Nc(e){if(!e||typeof e!="object")return {type:"unknown",message:"Invalid response from AI",success:false,error:"Invalid response format"};let t=e;return {type:t.type||"unknown",taskId:typeof t.taskId=="string"?t.taskId:void 0,taskName:typeof t.taskName=="string"?t.taskName:void 0,updates:t.updates,newTask:t.newTask,dependencyFrom:typeof t.dependencyFrom=="string"?t.dependencyFrom:void 0,dependencyTo:typeof t.dependencyTo=="string"?t.dependencyTo:void 0,message:typeof t.message=="string"?t.message:"Command processed",success:typeof t.success=="boolean"?t.success:false,error:typeof t.error=="string"?t.error:void 0}}function M0(e){if(e)switch(e.toUpperCase()){case "TODO":case "BLOCKED":return "todo";case "IN_PROGRESS":case "REVIEW":return "in-progress";case "DONE":return "completed";default:return "todo"}}function A0(e){switch(e){case "todo":return "TODO";case "in-progress":return "IN_PROGRESS";case "completed":return "DONE";default:return e||"TODO"}}function Bn(e,t=[],a=[]){let r=e.assignedUserIds?.map(u=>{let d=a.find(g=>g.id===u);return d?{name:d.name,initials:d.initials,color:d.color}:null}).filter(u=>u!==null),o=t.filter(u=>u.metadata?.parentCardId===e.id).map(u=>Bn(u,t,a)),s;e.dependencies&&(typeof e.dependencies[0]=="string"?s=e.dependencies:s=e.dependencies.filter(u=>u.type==="finish-to-start").map(u=>u.taskId));let n=u=>{if(u)return typeof u=="string"?new Date(u):u},c=n(e.startDate),p=n(e.endDate),i=e.metadata?.isMilestone===true||c&&p&&Math.abs(p.getTime()-c.getTime())<=864e5;return {id:e.id,name:e.title,startDate:c,endDate:p,progress:e.progress||0,status:M0(e.metadata?.status),assignees:r?.length?r:void 0,dependencies:s?.length?s:void 0,subtasks:o?.length?o:void 0,isExpanded:e.metadata?.isExpanded===true,isMilestone:i,isCriticalPath:e.metadata?.isCriticalPath===true}}function Dc(e,t=[]){let a;return e.assignees&&e.assignees.length>0&&(a=e.assignees.map(r=>t.find(s=>s.name===r.name||s.initials===r.initials)?.id).filter(r=>r!==void 0)),{id:e.id,title:e.name,startDate:e.startDate,endDate:e.endDate,progress:e.progress,assignedUserIds:a?.length?a:void 0,metadata:{status:A0(e.status),isExpanded:e.isExpanded,isMilestone:e.isMilestone,isCriticalPath:e.isCriticalPath}}}function Sc(e,t=[]){return e.filter(r=>!r.metadata?.parentCardId).map(r=>Bn(r,e,t))}var ki={columns:{name:"Task Name",startDate:"Start Date",endDate:"End Date",progress:"Progress",status:"Status",assignees:"Assignees",priority:"Priority",actions:"Actions"},toolbar:{search:"Search",searchPlaceholder:"Search tasks...",filter:"Filter",clearFilters:"Clear Filters",export:"Export",columns:"Columns",newTask:"New Task"},filters:{status:"Status",assignees:"Assignees",dateRange:"Date Range",showCompleted:"Show Completed",all:"All",none:"None"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},actions:{edit:"Edit",delete:"Delete",duplicate:"Duplicate",viewDetails:"View Details"},empty:{noTasks:"No tasks yet",noResults:"No tasks match your filters",addFirstTask:"Add your first task"},pagination:{showing:"Showing",of:"of",tasks:"tasks",previous:"Previous",next:"Next"},bulk:{selected:"selected",delete:"Delete",move:"Move to",assignTo:"Assign to"}},wi={columns:{name:"Nombre de Tarea",startDate:"Fecha Inicio",endDate:"Fecha Fin",progress:"Progreso",status:"Estado",assignees:"Asignados",priority:"Prioridad",actions:"Acciones"},toolbar:{search:"Buscar",searchPlaceholder:"Buscar tareas...",filter:"Filtrar",clearFilters:"Limpiar Filtros",export:"Exportar",columns:"Columnas",newTask:"Nueva Tarea"},filters:{status:"Estado",assignees:"Asignados",dateRange:"Rango de Fechas",showCompleted:"Mostrar Completadas",all:"Todos",none:"Ninguno"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},actions:{edit:"Editar",delete:"Eliminar",duplicate:"Duplicar",viewDetails:"Ver Detalles"},empty:{noTasks:"Sin tareas a\xFAn",noResults:"Ninguna tarea coincide con los filtros",addFirstTask:"Agrega tu primera tarea"},pagination:{showing:"Mostrando",of:"de",tasks:"tareas",previous:"Anterior",next:"Siguiente"},bulk:{selected:"seleccionadas",delete:"Eliminar",move:"Mover a",assignTo:"Asignar a"}},Rn={en:ki,es:wi};function Ci(e){return Rn[e]||Rn.en}function On(e,t){let a=Ci(e);return t?{columns:{...a.columns,...t.columns},toolbar:{...a.toolbar,...t.toolbar},filters:{...a.filters,...t.filters},status:{...a.status,...t.status},actions:{...a.actions,...t.actions},empty:{...a.empty,...t.empty},pagination:{...a.pagination,...t.pagination},bulk:{...a.bulk,...t.bulk}}:a}function Ac(e,t=0){let a=[];for(let r of e)a.push({...r,level:t,hasChildren:(r.subtasks?.length||0)>0,parentPath:[r.id]}),r.subtasks?.length&&r.isExpanded!==false&&a.push(...Ac(r.subtasks,t+1));return a}function W0({status:e,progress:t}){return t===100||e==="completed"?jsx(CheckCircle2,{className:"w-5 h-5 text-green-500"}):t&&t>0||e==="in-progress"?jsx(PlayCircle,{className:"w-5 h-5 text-blue-500"}):jsx(Circle,{className:"w-5 h-5 text-gray-400"})}function Fc({tasks:e,config:t={},callbacks:a={},isLoading:r=false,error:o,className:s,style:n}){let{theme:c="dark",locale:p="en",customTranslations:i,showSearch:u=true,showHierarchy:d=true}=t,g=On(p,i),h=c==="dark",[C,T]=useState(new Set),[m,b]=useState("startDate"),[y,l]=useState("asc"),[w,v]=useState("");useMemo(()=>{let M=new Set;function N(H){for(let L of H)L.subtasks?.length&&(M.add(L.id),N(L.subtasks));}N(e),T(M);},[e]);let P=useCallback(M=>{T(N=>{let H=new Set(N);return H.has(M)?H.delete(M):H.add(M),H}),a.onTaskToggleExpand?.(M);},[a]),x=useCallback(M=>{m===M?l(N=>N==="asc"?"desc":"asc"):(b(M),l("asc")),a.onSortChange?.({column:M,direction:y==="asc"?"desc":"asc"});},[m,y,a]),k=useMemo(()=>{let M=Ac(e);if(w.trim()){let H=w.toLowerCase();M=M.filter(L=>L.name.toLowerCase().includes(H));}let N=[];for(let H of M){let L=H.level===0;H.level>0&&(L=true),(L||w.trim())&&N.push(H);}return w.trim()&&N.sort((H,L)=>{let Y,ae;switch(m){case "name":Y=H.name.toLowerCase(),ae=L.name.toLowerCase();break;case "startDate":Y=H.startDate?.getTime()||0,ae=L.startDate?.getTime()||0;break;case "endDate":Y=H.endDate?.getTime()||0,ae=L.endDate?.getTime()||0;break;case "progress":Y=H.progress||0,ae=L.progress||0;break;case "status":Y=H.status||"todo",ae=L.status||"todo";break;default:return 0}return Y<ae?y==="asc"?-1:1:Y>ae?y==="asc"?1:-1:0}),N},[e,w,m,y]),O=M=>M?(M instanceof Date?M:new Date(M)).toLocaleDateString(p==="es"?"es-ES":"en-US",{day:"numeric",month:"short"}):"-";return r?jsx("div",{className:f("flex-1 flex items-center justify-center",h?"bg-[#0F1117]":"bg-white",s),style:n,children:jsxs("div",{className:"flex flex-col items-center gap-4",children:[jsx("div",{className:"w-8 h-8 animate-spin rounded-full border-b-2 border-[#3B82F6]"}),jsxs("p",{className:f("text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:[g.empty.noTasks,"..."]})]})}):o?jsx("div",{className:f("flex-1 flex items-center justify-center",h?"bg-[#0F1117]":"bg-white",s),style:n,children:jsxs("div",{className:"flex flex-col items-center gap-4 max-w-md text-center",children:[jsx("div",{className:"w-12 h-12 rounded-full bg-red-500/10 flex items-center justify-center",children:jsx("span",{className:"text-red-500 text-2xl",children:"\u26A0"})}),jsxs("div",{children:[jsx("h3",{className:f("text-lg font-semibold mb-2",h?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:f("text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:typeof o=="string"?o:o.message})]})]})}):e.length===0?jsx("div",{className:f("flex-1 flex items-center justify-center",h?"bg-[#0F1117]":"bg-white",s),style:n,children:jsxs("div",{className:"text-center max-w-md",children:[jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-2xl bg-[#3B82F6]/10 flex items-center justify-center",children:jsx(List,{className:"w-8 h-8 text-[#3B82F6]"})}),jsx("h3",{className:f("text-lg font-semibold mb-2",h?"text-white":"text-gray-900"),children:g.empty.noTasks}),jsx("p",{className:f("text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:g.empty.addFirstTask})]})}):jsxs("div",{className:f("flex-1 flex flex-col w-full h-full overflow-hidden",h?"bg-[#0F1117]":"bg-white",s),style:n,children:[jsx("div",{className:f("flex-shrink-0 px-6 py-4 border-b",h?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-center gap-4",children:[u&&jsxs("div",{className:"relative flex-1 max-w-md",children:[jsx(Search,{className:f("absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4",h?"text-[#9CA3AF]":"text-gray-400")}),jsx("input",{type:"text",value:w,onChange:M=>v(M.target.value),placeholder:g.toolbar.searchPlaceholder,className:f("w-full h-9 pl-10 pr-4 rounded-lg border outline-none focus:ring-2 focus:ring-[#3B82F6]/30",h?"bg-white/5 border-white/10 text-white placeholder:text-[#6B7280]":"bg-gray-100 border-gray-200 text-gray-900 placeholder:text-gray-400")})]}),jsxs("div",{className:f("text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:[k.length," ",g.pagination.tasks]})]})}),jsxs("div",{className:f("flex-shrink-0 grid grid-cols-12 gap-4 px-6 py-3 border-b text-xs font-medium uppercase tracking-wider",h?"border-white/10 bg-white/5 text-[#9CA3AF]":"border-gray-200 bg-gray-50 text-gray-500"),children:[jsx("div",{className:"col-span-5 flex items-center gap-2",children:jsxs("button",{onClick:()=>x("name"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[g.columns.name,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>x("status"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[g.columns.status,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>x("startDate"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[g.columns.startDate,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>x("endDate"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[g.columns.endDate,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-1 flex items-center gap-1",children:jsxs("button",{onClick:()=>x("progress"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:["%",jsx(ArrowUpDown,{className:"w-3 h-3"})]})})]}),jsxs("div",{className:"flex-1 overflow-auto",children:[jsx(AnimatePresence,{children:k.map((M,N)=>{let H=C.has(M.id);return jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{delay:N*.02},className:f("grid grid-cols-12 gap-4 px-6 py-3 border-b transition-colors cursor-pointer",h?"border-white/5 hover:bg-white/5":"border-gray-100 hover:bg-gray-50"),style:{paddingLeft:d?`${24+M.level*24}px`:void 0},onClick:()=>a.onTaskClick?.(M),onDoubleClick:()=>a.onTaskDoubleClick?.(M),children:[jsxs("div",{className:"col-span-5 flex items-center gap-2 min-w-0",children:[d&&M.hasChildren&&jsx("button",{onClick:L=>{L.stopPropagation(),P(M.id);},className:f("p-0.5 rounded",h?"hover:bg-white/10":"hover:bg-gray-200"),children:H?jsx(ChevronDown,{className:f("w-4 h-4",h?"text-[#9CA3AF]":"text-gray-400")}):jsx(ChevronRight,{className:f("w-4 h-4",h?"text-[#9CA3AF]":"text-gray-400")})}),d&&!M.hasChildren&&jsx("div",{className:"w-5"}),jsx("button",{onClick:L=>{L.stopPropagation(),a.onTaskUpdate?.({...M,progress:M.progress===100?0:100,status:M.progress===100?"todo":"completed"});},className:"flex-shrink-0",children:jsx(W0,{status:M.status,progress:M.progress})}),jsx("span",{className:f("truncate",h?"text-white":"text-gray-900",M.progress===100&&(h?"line-through text-[#6B7280]":"line-through text-gray-400")),children:M.name})]}),jsx("div",{className:"col-span-2 flex items-center",children:jsx("span",{className:f("px-2 py-1 rounded-full text-xs font-medium",M.progress===100||M.status==="completed"?"bg-green-500/10 text-green-500":M.progress&&M.progress>0||M.status==="in-progress"?"bg-blue-500/10 text-blue-500":h?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:M.progress===100||M.status==="completed"?g.status.completed:M.progress&&M.progress>0||M.status==="in-progress"?g.status.inProgress:g.status.todo})}),jsxs("div",{className:f("col-span-2 flex items-center gap-1 text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Calendar,{className:"w-4 h-4"}),O(M.startDate)]}),jsxs("div",{className:f("col-span-2 flex items-center gap-1 text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Clock,{className:"w-4 h-4"}),O(M.endDate)]}),jsx("div",{className:"col-span-1 flex items-center",children:jsxs("div",{className:"flex items-center gap-2 w-full",children:[jsx("div",{className:f("flex-1 h-1.5 rounded-full overflow-hidden",h?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:f("h-full rounded-full transition-all",M.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${M.progress||0}%`}})}),jsxs("span",{className:f("text-xs w-8",h?"text-[#9CA3AF]":"text-gray-500"),children:[M.progress||0,"%"]})]})})]},M.id)})}),k.length===0&&w&&jsx("div",{className:"flex items-center justify-center py-12",children:jsxs("div",{className:"text-center",children:[jsx(List,{className:f("w-12 h-12 mx-auto mb-4",h?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:f(h?"text-[#9CA3AF]":"text-gray-600"),children:g.empty.noResults})]})})]})]})}var Ti={bgPrimary:"#0d1117",bgSecondary:"#161b22",bgHover:"#21262d",bgSelected:"#1f6feb20",bgAlternate:"#0d111780",border:"#30363d",borderLight:"#21262d",textPrimary:"#c9d1d9",textSecondary:"#8b949e",textMuted:"#6e7681",accent:"#58a6ff",accentHover:"#79b8ff",accentLight:"#58a6ff20",statusTodo:"#8b949e",statusInProgress:"#f0883e",statusCompleted:"#3fb950",focusRing:"#58a6ff",checkboxBg:"#21262d",checkboxChecked:"#58a6ff"},Ni={bgPrimary:"#ffffff",bgSecondary:"#f6f8fa",bgHover:"#f3f4f6",bgSelected:"#dbeafe",bgAlternate:"#f9fafb",border:"#d0d7de",borderLight:"#e5e7eb",textPrimary:"#24292f",textSecondary:"#57606a",textMuted:"#8b949e",accent:"#0969da",accentHover:"#0550ae",accentLight:"#dbeafe",statusTodo:"#8b949e",statusInProgress:"#bf8700",statusCompleted:"#1a7f37",focusRing:"#0969da",checkboxBg:"#ffffff",checkboxChecked:"#0969da"},Di={bgPrimary:"#1a1a2e",bgSecondary:"#16213e",bgHover:"#1f3460",bgSelected:"#0f4c7520",bgAlternate:"#1a1a2e80",border:"#2a3f5f",borderLight:"#1f3460",textPrimary:"#e4e6eb",textSecondary:"#a8b2c1",textMuted:"#6b7280",accent:"#6366f1",accentHover:"#818cf8",accentLight:"#6366f120",statusTodo:"#9ca3af",statusInProgress:"#fbbf24",statusCompleted:"#34d399",focusRing:"#6366f1",checkboxBg:"#1f3460",checkboxChecked:"#6366f1"},Un={dark:Ti,light:Ni,neutral:Di};function Ic(e){return Un[e]||Un.dark}var Si={navigation:{today:"Today",previous:"Previous",next:"Next",month:"Month",week:"Week",day:"Day"},weekdays:{sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},weekdaysFull:{sunday:"Sunday",monday:"Monday",tuesday:"Tuesday",wednesday:"Wednesday",thursday:"Thursday",friday:"Friday",saturday:"Saturday"},months:{january:"January",february:"February",march:"March",april:"April",may:"May",june:"June",july:"July",august:"August",september:"September",october:"October",november:"November",december:"December"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},labels:{allDay:"All day",moreEvents:"+{count} more",noEvents:"No tasks",newTask:"New Task",viewAll:"View all",week:"Week"},tooltips:{progress:"Progress",status:"Status",assignees:"Assignees",duration:"Duration",days:"days"}},Ei={navigation:{today:"Hoy",previous:"Anterior",next:"Siguiente",month:"Mes",week:"Semana",day:"D\xEDa"},weekdays:{sun:"Dom",mon:"Lun",tue:"Mar",wed:"Mi\xE9",thu:"Jue",fri:"Vie",sat:"S\xE1b"},weekdaysFull:{sunday:"Domingo",monday:"Lunes",tuesday:"Martes",wednesday:"Mi\xE9rcoles",thursday:"Jueves",friday:"Viernes",saturday:"S\xE1bado"},months:{january:"Enero",february:"Febrero",march:"Marzo",april:"Abril",may:"Mayo",june:"Junio",july:"Julio",august:"Agosto",september:"Septiembre",october:"Octubre",november:"Noviembre",december:"Diciembre"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},labels:{allDay:"Todo el d\xEDa",moreEvents:"+{count} m\xE1s",noEvents:"Sin tareas",newTask:"Nueva Tarea",viewAll:"Ver todo",week:"Semana"},tooltips:{progress:"Progreso",status:"Estado",assignees:"Asignados",duration:"Duraci\xF3n",days:"d\xEDas"}},$n={en:Si,es:Ei};function Ho(e){return $n[e]||$n.en}function Hn(e,t){let a=Ho(e);return t?{navigation:{...a.navigation,...t.navigation},weekdays:{...a.weekdays,...t.weekdays},weekdaysFull:{...a.weekdaysFull,...t.weekdaysFull},months:{...a.months,...t.months},status:{...a.status,...t.status},labels:{...a.labels,...t.labels},tooltips:{...a.tooltips,...t.tooltips}}:a}function Lc(e){let t=Ho(e);return [t.months.january,t.months.february,t.months.march,t.months.april,t.months.may,t.months.june,t.months.july,t.months.august,t.months.september,t.months.october,t.months.november,t.months.december]}function Bc(e,t=0,a=true){let r=Ho(e),o=a?[r.weekdays.sun,r.weekdays.mon,r.weekdays.tue,r.weekdays.wed,r.weekdays.thu,r.weekdays.fri,r.weekdays.sat]:[r.weekdaysFull.sunday,r.weekdaysFull.monday,r.weekdaysFull.tuesday,r.weekdaysFull.wednesday,r.weekdaysFull.thursday,r.weekdaysFull.friday,r.weekdaysFull.saturday];return [...o.slice(t),...o.slice(0,t)]}function ih(e){let t=[];function a(r){for(let o of r)t.push(o),o.subtasks?.length&&a(o.subtasks);}return a(e),t}function Li(e,t){if(!t.startDate||!t.endDate)return false;let a=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(t.startDate.getFullYear(),t.startDate.getMonth(),t.startDate.getDate()),o=new Date(t.endDate.getFullYear(),t.endDate.getMonth(),t.endDate.getDate());return a>=r&&a<=o}function $c({task:e}){return e.progress===100||e.status==="completed"?jsx(CheckCircle2,{className:"w-3 h-3 text-green-500 flex-shrink-0"}):e.progress&&e.progress>0||e.status==="in-progress"?jsx(PlayCircle,{className:"w-3 h-3 text-blue-500 flex-shrink-0"}):jsx(Circle,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})}function Wc({tasks:e,config:t={},callbacks:a={},initialDate:r,isLoading:o=false,error:s,className:n,style:c,availableTags:p=[],onCreateTag:i,attachmentsByTask:u,comments:d,onAddComment:g,currentUser:h,onTaskOpen:C}){let{theme:T="dark",locale:m="en",customTranslations:b}=t,y=Hn(m,b),l=T==="dark",w={textTertiary:l?"#6B7280":"#9CA3AF",textSecondary:l?"#9CA3AF":"#6B7280",textPrimary:l?"#FFFFFF":"#111827",borderLight:l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",border:l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",bgPrimary:l?"#1A1D25":"#FFFFFF",bgSecondary:l?"#0F1117":"#F9FAFB",hoverBg:l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},[v,P]=useState(r||new Date),[x,k]=useState(null),[O,M]=useState(null),[N,H]=useState(null),[L,Y]=useState(new Date),[ae,ke]=useState({}),Pe=4,Ve=3,[Je,$]=useState(false),[B,W]=useState(false),[D,j]=useState(false),[J,R]=useState(false),[de,we]=useState(null),[Me,ce]=useState(""),[We,Fe]=useState(void 0),[Ye,ut]=useState(null),[yt,nt]=useState(false),[z,re]=useState(false),[oe,xe]=useState(null),[Ne,tt]=useState(false),[ht,Ie]=useState(new Date),[be,Se]=useState(false),[Ft,bt]=useState(false),[sa,ua]=useState(false),[$e,Ue]=useState(""),[ia,ue]=useState(false),[S,Z]=useState(""),[ge,Te]=useState(false),qe=useCallback(()=>{P(new Date(v.getFullYear(),v.getMonth()-1,1));},[v]),Ge=useCallback(()=>{P(new Date(v.getFullYear(),v.getMonth()+1,1));},[v]),Re=useCallback(()=>{P(new Date);},[]),at=useMemo(()=>{let F=v.getFullYear(),he=v.getMonth(),q=new Date(F,he,1),Le=new Date(F,he+1,0),ct=q.getDay(),ne=Le.getDate(),ze=ih(e),xt=new Date;xt.setHours(0,0,0,0);let Ae=[],Qt=ct,mt=new Date(F,he,0).getDate();for(let $t=Qt-1;$t>=0;$t--){let Xe=new Date(F,he-1,mt-$t);Ae.push({date:Xe,isCurrentMonth:false,isToday:false,isWeekend:Xe.getDay()===0||Xe.getDay()===6,events:ze.filter(Mt=>Li(Xe,Mt)).map(Mt=>({id:Mt.id,title:Mt.name,start:Mt.startDate,end:Mt.endDate,task:Mt}))});}for(let $t=1;$t<=ne;$t++){let Xe=new Date(F,he,$t),Mt=Xe.getTime()===xt.getTime();Ae.push({date:Xe,isCurrentMonth:true,isToday:Mt,isWeekend:Xe.getDay()===0||Xe.getDay()===6,events:ze.filter(ra=>Li(Xe,ra)).map(ra=>({id:ra.id,title:ra.name,start:ra.startDate,end:ra.endDate,task:ra}))});}let la=42-Ae.length;for(let $t=1;$t<=la;$t++){let Xe=new Date(F,he+1,$t);Ae.push({date:Xe,isCurrentMonth:false,isToday:false,isWeekend:Xe.getDay()===0||Xe.getDay()===6,events:ze.filter(Mt=>Li(Xe,Mt)).map(Mt=>({id:Mt.id,title:Mt.name,start:Mt.startDate,end:Mt.endDate,task:Mt}))});}return Ae},[v,e]),lt=m==="es"?["Dom","Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b"]:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],K=v.toLocaleDateString(m==="es"?"es-ES":"en-US",{month:"long",year:"numeric"}),te=useCallback((F,he)=>{if(!x)return;let q={...x,[F]:he};k(q),a.onTaskUpdate?.(q);},[x,a]),Ee=useCallback(F=>{if(!x)return;let he=x.progress||0;F==="completed"?he=100:F==="todo"&&(he=0);let q={...x,status:F,progress:he};k(q),a.onTaskUpdate?.(q),$(false);},[x,a]),He=useCallback((F,he)=>{if(!x)return;let q={...x,startDate:F,endDate:he};k(q),a.onTaskUpdate?.(q);},[x,a]),Oe=useCallback(()=>{$(false),W(false),j(false),H(null),ua(false),Ue(""),ue(false);},[]),G=useCallback(async F=>{if(F.preventDefault(),F.stopPropagation(),Se(false),!x||!a.onUploadAttachments)return;let he=Array.from(F.dataTransfer.files);if(he.length!==0){bt(true);try{await a.onUploadAttachments(x.id,he);}finally{bt(false);}}},[x,a]),ee=useCallback(async F=>{if(!x||!a.onUploadAttachments||!F.target.files)return;let he=Array.from(F.target.files);if(he.length!==0){bt(true);try{await a.onUploadAttachments(x.id,he);}finally{bt(false);}F.target.value="";}},[x,a]),Be=useCallback(F=>{F.preventDefault(),F.stopPropagation(),Se(true);},[]),Et=useCallback(F=>{F.preventDefault(),F.stopPropagation(),Se(false);},[]),dt=useCallback(F=>F<1024?`${F} B`:F<1024*1024?`${(F/1024).toFixed(1)} KB`:`${(F/(1024*1024)).toFixed(1)} MB`,[]),Ka=useCallback(F=>F.startsWith("image/")?Image:F.includes("pdf")||F.includes("document")?FileText:File,[]),za=useMemo(()=>!x||!u?[]:u.get(x.id)||[],[x,u]);return o?jsx("div",{className:f("flex-1 flex items-center justify-center",l?"bg-[#0F1117]":"bg-white",n),style:c,children:jsxs("div",{className:"flex flex-col items-center gap-4",children:[jsx("div",{className:"w-8 h-8 animate-spin rounded-full border-b-2 border-[#3B82F6]"}),jsxs("p",{className:f("text-sm",l?"text-[#9CA3AF]":"text-gray-600"),children:[y.labels.noEvents,"..."]})]})}):s?jsx("div",{className:f("flex-1 flex items-center justify-center",l?"bg-[#0F1117]":"bg-white",n),style:c,children:jsxs("div",{className:"flex flex-col items-center gap-4 max-w-md text-center",children:[jsx("div",{className:"w-12 h-12 rounded-full bg-red-500/10 flex items-center justify-center",children:jsx("span",{className:"text-red-500 text-2xl",children:"\u26A0"})}),jsxs("div",{children:[jsx("h3",{className:f("text-lg font-semibold mb-2",l?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:f("text-sm",l?"text-[#9CA3AF]":"text-gray-600"),children:typeof s=="string"?s:s.message})]})]})}):e.length===0?jsx("div",{className:f("flex-1 flex items-center justify-center",l?"bg-[#0F1117]":"bg-white",n),style:c,children:jsxs("div",{className:"text-center max-w-md",children:[jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-2xl bg-[#3B82F6]/10 flex items-center justify-center",children:jsx(Calendar,{className:"w-8 h-8 text-[#3B82F6]"})}),jsx("h3",{className:f("text-lg font-semibold mb-2",l?"text-white":"text-gray-900"),children:y.labels.noEvents}),jsx("p",{className:f("text-sm",l?"text-[#9CA3AF]":"text-gray-600"),children:y.labels.newTask})]})}):jsxs("div",{className:f("flex-1 flex flex-col w-full h-full overflow-auto",l?"bg-[#0F1117]":"bg-white",n),style:c,children:[jsx("div",{className:f("flex-shrink-0 px-6 py-4 border-b",l?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-4",children:[jsx("h2",{className:f("text-xl font-semibold capitalize",l?"text-white":"text-gray-900"),children:K}),jsx("button",{onClick:Re,className:f("px-3 py-1.5 text-sm rounded-lg transition-colors",l?"bg-white/5 text-white hover:bg-white/10":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:y.navigation.today})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("button",{onClick:qe,className:f("p-2 rounded-lg transition-colors",l?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:f("w-5 h-5",l?"text-[#9CA3AF]":"text-gray-600")})}),jsx("button",{onClick:Ge,className:f("p-2 rounded-lg transition-colors",l?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:f("w-5 h-5",l?"text-[#9CA3AF]":"text-gray-600")})})]})]})}),jsx("div",{className:"flex-1 p-6 min-h-0",children:jsxs("div",{className:"flex flex-col",children:[jsx("div",{className:"grid grid-cols-7 gap-px mb-2",children:lt.map(F=>jsx("div",{className:f("py-2 text-center text-xs font-medium uppercase",l?"text-[#9CA3AF]":"text-gray-500"),children:F},F))}),jsx("div",{className:f("grid grid-cols-7 auto-rows-min gap-px rounded-lg",l?"bg-[#2D2D2D]":"bg-gray-300"),children:at.map((F,he)=>{let q=F.date.getDay()===0||F.date.getDay()===6;return jsxs("div",{className:f("min-h-[120px] p-2 transition-colors flex flex-col relative group",l?q?"bg-[#1C1F26]":F.isCurrentMonth?"bg-[#13161B]":"bg-[#0D0F13]":q?"bg-gray-100":F.isCurrentMonth?"bg-white":"bg-gray-50",F.isToday&&"ring-2 ring-[#3B82F6] ring-inset"),children:[(()=>{let Le=ae[he]||Pe,ct=F.events.slice(0,Le),ne=F.events.length-Le;return jsxs("div",{className:"space-y-1 flex-1",children:[ct.map(ze=>jsx("div",{className:"relative group",children:jsxs(motion.button,{onClick:()=>{k(ze.task),a.onEventClick?.(ze),C?.(ze.task.id);},whileHover:{scale:1.02},className:f("w-full flex items-center gap-1 px-1.5 py-0.5 rounded text-xs truncate",ze.task.progress===100?l?"bg-green-500/20 text-green-400":"bg-green-500/10 text-green-600":l?"bg-[#3B82F6]/20 text-[#3B82F6]":"bg-[#3B82F6]/10 text-[#3B82F6]"),children:[jsx($c,{task:ze.task}),jsx("span",{className:"truncate",children:ze.title})]})},ze.id)),ne>0&&jsxs("button",{onClick:ze=>{ze.stopPropagation(),ke(xt=>({...xt,[he]:Le+Ve}));},className:f("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",l?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:["+",ne," ",m==="es"?"M\xC1S":"MORE"]}),Le>Pe&&F.events.length>Pe&&jsx("button",{onClick:ze=>{ze.stopPropagation(),ke(xt=>({...xt,[he]:Pe}));},className:f("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",l?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:m==="es"?"MENOS":"LESS"})]})})(),jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1",children:[(()=>{let Le=he>=28,ct=he%7>=5;return jsxs("div",{className:"relative",children:[jsx("button",{onClick:ne=>{ne.stopPropagation(),de===he?we(null):(we(he),ce(""),Fe(void 0),ut(null),xe(null),nt(false),re(false),tt(false),Ie(F.date));},className:f("w-5 h-5 rounded flex items-center justify-center transition-all",de===he?"opacity-100 bg-[#7C3AED] text-white":"opacity-0 group-hover:opacity-100",l?"hover:bg-[#7C3AED] text-[#6B7280] hover:text-white":"hover:bg-[#7C3AED] text-gray-400 hover:text-white"),children:jsx(Plus,{className:f("w-3.5 h-3.5 transition-transform",de===he&&"rotate-45")})}),jsx(AnimatePresence,{children:de===he&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{we(null),ce(""),Fe(void 0),ut(null),xe(null),nt(false),re(false),tt(false);}}),jsxs(motion.div,{initial:{opacity:0,y:Le?-5:5,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:Le?-5:5,scale:.95},transition:{duration:.12},className:f("absolute w-[320px] rounded-lg shadow-2xl z-50",Le?"bottom-full mb-1":"top-full mt-1",ct?"right-0":"left-0",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:ne=>{ne.stopPropagation(),nt(false),re(false),tt(false);},children:[jsx("div",{className:"p-2.5",children:jsx("input",{type:"text",value:Me,onChange:ne=>ce(ne.target.value),placeholder:m==="es"?'Escribe el nombre de la tarea o "/" para los comandos':'Type task name or "/" for commands',className:f("w-full bg-transparent text-sm outline-none placeholder:opacity-40",l?"text-white":"text-gray-900"),autoFocus:true,onKeyDown:ne=>{if(ne.key==="Enter"&&Me.trim()){let ze=t.availableUsers?.find(Ae=>Ae.id===Ye),xt=oe||F.date;a.onTaskCreate?.({name:Me.trim(),startDate:xt,endDate:xt,priority:We,assignees:ze?[ze]:void 0}),ce(""),Fe(void 0),ut(null),xe(null),we(null);}ne.key==="Escape"&&(we(null),ce(""),Fe(void 0),ut(null),xe(null));}})}),jsxs("div",{className:f("px-2.5 py-2 flex items-center justify-between border-t",l?"border-white/10":"border-gray-100"),children:[jsxs("div",{className:"flex items-center gap-1",children:[jsxs("div",{className:"relative",children:[jsx("button",{onClick:ne=>{ne.stopPropagation(),nt(!yt),re(false);},className:f("p-1 rounded transition-colors",We?We==="urgent"||We==="high"?"text-red-400 bg-red-500/20":We==="medium"?"text-yellow-400 bg-yellow-500/20":"text-green-400 bg-green-500/20":l?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:jsx(Flag,{className:"w-3.5 h-3.5"})}),jsx(AnimatePresence,{children:yt&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:f("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[120px]",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:ne=>ne.stopPropagation(),children:[{id:"urgent",label:m==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:m==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:m==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:m==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:m==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(ne=>jsxs("button",{onClick:()=>{Fe(ne.id),nt(false);},className:f("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",l?"hover:bg-white/5":"hover:bg-gray-50",We===ne.id&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:f("w-2 h-2 rounded-full",ne.color)}),jsx("span",{className:l?"text-white":"text-gray-900",children:ne.label})]},ne.id||"none"))})})]}),jsxs("div",{className:"relative",children:[jsxs("button",{onClick:ne=>{ne.stopPropagation(),tt(!Ne),nt(false),re(false),Ie(oe||F.date);},className:f("flex items-center gap-1 text-xs px-1.5 py-0.5 rounded transition-colors",oe?"bg-[#7C3AED]/20 text-[#7C3AED]":l?"bg-white/5 text-[#9CA3AF] hover:bg-white/10":"bg-gray-100 text-gray-500 hover:bg-gray-200"),children:[jsx(CalendarDays,{className:"w-3 h-3"}),(oe||F.date).toLocaleDateString(m==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})]}),jsx(AnimatePresence,{children:Ne&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:f("absolute left-0 bottom-full mb-1 z-[60] rounded-xl shadow-2xl overflow-hidden flex",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:ne=>ne.stopPropagation(),children:[jsx("div",{className:f("w-40 py-2 border-r",l?"border-white/10":"border-gray-200"),children:(()=>{let ne=new Date,ze=new Date(ne);ze.setDate(ne.getDate()+1);let xt=new Date(ne);xt.setDate(ne.getDate()+((6-ne.getDay()+7)%7||7));let Ae=new Date(ne);Ae.setDate(ne.getDate()+((1-ne.getDay()+7)%7||7));let Qt=new Date(ne);Qt.setDate(ne.getDate()+14);let mt=new Date(ne);return mt.setDate(ne.getDate()+28),[{label:m==="es"?"Hoy":"Today",date:ne,display:ne.toLocaleDateString(m==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:m==="es"?"Ma\xF1ana":"Tomorrow",date:ze,display:ze.toLocaleDateString(m==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:m==="es"?"Este fin de semana":"This weekend",date:xt,display:m==="es"?"s\xE1b.":"sat."},{label:m==="es"?"Pr\xF3xima semana":"Next week",date:Ae,display:m==="es"?"lun.":"mon."},{label:m==="es"?"2 semanas":"2 weeks",date:Qt,display:Qt.toLocaleDateString(m==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:m==="es"?"4 semanas":"4 weeks",date:mt,display:mt.toLocaleDateString(m==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map(($t,Xe)=>jsxs("button",{className:f("w-full flex items-center justify-between px-3 py-1.5 text-xs transition-colors",l?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{xe($t.date),tt(false);},children:[jsx("span",{children:$t.label}),jsx("span",{className:f("text-[10px]",l?"text-[#6B7280]":"text-gray-400"),children:$t.display})]},Xe))})()}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("span",{className:f("text-xs font-medium",l?"text-white":"text-gray-900"),children:ht.toLocaleDateString(m==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-0.5",children:[jsx("button",{onClick:()=>Ie(new Date),className:f("px-1.5 py-0.5 rounded text-[10px] transition-colors",l?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:m==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>Ie(new Date(ht.getFullYear(),ht.getMonth()-1)),className:f("p-0.5 rounded",l?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:()=>Ie(new Date(ht.getFullYear(),ht.getMonth()+1)),className:f("p-0.5 rounded",l?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:"w-3.5 h-3.5"})})]})]}),jsx("div",{className:"grid grid-cols-7 gap-0.5 mb-1",children:(m==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(ne=>jsx("div",{className:f("w-6 h-6 flex items-center justify-center text-[10px]",l?"text-[#6B7280]":"text-gray-400"),children:ne},ne))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let ne=ht.getFullYear(),ze=ht.getMonth(),xt=new Date(ne,ze,1).getDay(),Ae=new Date(ne,ze+1,0).getDate(),Qt=new Date(ne,ze,0).getDate(),mt=new Date,la=[];for(let Xe=xt-1;Xe>=0;Xe--)la.push({dayNum:Qt-Xe,isCurrentMonth:false,date:new Date(ne,ze-1,Qt-Xe)});for(let Xe=1;Xe<=Ae;Xe++)la.push({dayNum:Xe,isCurrentMonth:true,date:new Date(ne,ze,Xe)});let $t=42-la.length;for(let Xe=1;Xe<=$t;Xe++)la.push({dayNum:Xe,isCurrentMonth:false,date:new Date(ne,ze+1,Xe)});return la.map((Xe,Mt)=>{let ra=Xe.date.toDateString()===mt.toDateString(),pr=(oe||F.date).toDateString()===Xe.date.toDateString();return jsx("button",{className:f("w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",!Xe.isCurrentMonth&&(l?"text-[#4B5563]":"text-gray-300"),Xe.isCurrentMonth&&(l?"text-white":"text-gray-900"),ra&&"ring-1 ring-[#3B82F6]",pr&&"bg-[#7C3AED] text-white",!pr&&(l?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{xe(Xe.date),tt(false);},children:Xe.dayNum},Mt)})})()})]})]})})]}),jsxs("div",{className:"relative",children:[jsx("button",{onClick:ne=>{ne.stopPropagation(),re(!z),nt(false);},className:f("p-1 rounded transition-colors",Ye?"text-[#7C3AED] bg-[#7C3AED]/20":l?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:Ye?jsx("div",{className:"w-4 h-4 rounded-full flex items-center justify-center text-white text-[8px] font-medium",style:{backgroundColor:t.availableUsers?.find(ne=>ne.id===Ye)?.color||"#7C3AED"},children:t.availableUsers?.find(ne=>ne.id===Ye)?.initials||t.availableUsers?.find(ne=>ne.id===Ye)?.name?.slice(0,2).toUpperCase()}):jsx(User,{className:"w-3.5 h-3.5"})}),jsx(AnimatePresence,{children:z&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:f("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[160px] max-h-[200px] overflow-y-auto",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:ne=>ne.stopPropagation(),children:[jsxs("button",{onClick:()=>{ut(null),re(false);},className:f("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",l?"hover:bg-white/5":"hover:bg-gray-50",!Ye&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:f("w-5 h-5 rounded-full flex items-center justify-center",l?"bg-white/10":"bg-gray-200"),children:jsx(User,{className:"w-3 h-3 text-gray-400"})}),jsx("span",{className:l?"text-[#9CA3AF]":"text-gray-500",children:m==="es"?"Sin asignar":"Unassigned"})]}),t.availableUsers?.map(ne=>jsxs("button",{onClick:()=>{ut(ne.id),re(false);},className:f("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",l?"hover:bg-white/5":"hover:bg-gray-50",Ye===ne.id&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-white text-[9px] font-medium",style:{backgroundColor:ne.color||"#7C3AED"},children:ne.initials||ne.name?.slice(0,2).toUpperCase()}),jsx("span",{className:l?"text-white":"text-gray-900",children:ne.name})]},ne.id)),(!t.availableUsers||t.availableUsers.length===0)&&jsx("div",{className:f("px-3 py-2 text-xs",l?"text-[#6B7280]":"text-gray-400"),children:m==="es"?"No hay usuarios disponibles":"No users available"})]})})]})]}),jsx("button",{onClick:()=>{if(Me.trim()){let ne=t.availableUsers?.find(xt=>xt.id===Ye),ze=oe||F.date;a.onTaskCreate?.({name:Me.trim(),startDate:ze,endDate:ze,priority:We,assignees:ne?[ne]:void 0}),ce(""),Fe(void 0),ut(null),xe(null),we(null);}},disabled:!Me.trim(),className:f("px-2.5 py-1 rounded text-xs font-medium transition-colors",Me.trim()?"bg-[#7C3AED] hover:bg-[#6D28D9] text-white":l?"bg-white/5 text-[#4B5563]":"bg-gray-100 text-gray-400"),children:m==="es"?"Guardar":"Save"})]})]})]})})]})})(),jsx("span",{className:f("text-sm font-medium",F.isToday?"text-[#3B82F6]":F.isCurrentMonth?l?"text-white":"text-gray-900":l?"text-[#6B7280]":"text-gray-400"),children:F.date.getDate()})]})]},he)})})]})}),jsx(AnimatePresence,{children:x&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>{k(null),Z("");},className:"fixed inset-0 bg-black/50 z-40"}),jsxs(motion.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},className:f("fixed inset-4 md:inset-8 lg:inset-12 rounded-xl shadow-2xl z-50 flex overflow-hidden",l?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[jsxs("div",{className:f("px-6 py-3 border-b flex items-center gap-3",l?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:f("w-4 h-4",l?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:f("text-xs px-2 py-0.5 rounded",l?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[m==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:f("text-xs font-mono",l?"text-[#6B7280]":"text-gray-400"),children:x.id.slice(0,8)}),jsxs("button",{className:f("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-colors",l?"bg-purple-500/20 text-purple-400 hover:bg-purple-500/30":"bg-purple-100 text-purple-700 hover:bg-purple-200"),children:[jsx(Sparkles,{className:"w-3 h-3"}),"Ask AI"]})]}),jsx("div",{className:"flex-1"}),jsx("button",{className:f("p-1.5 rounded transition-colors",l?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Maximize2,{className:"w-4 h-4"})}),jsx("button",{className:f("p-1.5 rounded transition-colors",l?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(MoreHorizontal,{className:"w-5 h-5"})}),jsx("button",{onClick:()=>{k(null),Z("");},className:f("p-1.5 rounded transition-colors",l?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(X,{className:"w-5 h-5"})})]}),jsx("div",{className:"px-6 py-4",children:jsxs("div",{className:"flex items-start gap-3",children:[jsx("button",{onClick:()=>{let F=x.progress===100?0:100,q={...x,progress:F,status:F===100?"completed":"todo"};k(q),a.onTaskUpdate?.(q);},className:f("mt-1 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors",x.progress===100?"bg-green-500 border-green-500":l?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:x.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("h2",{className:f("text-xl font-semibold flex-1",x.progress===100?"line-through text-[#6B7280]":l?"text-white":"text-gray-900"),children:x.name})]})}),jsxs("div",{className:"px-6 pb-6 flex-1 overflow-y-auto overflow-x-visible",children:[jsxs("div",{className:"grid grid-cols-2 gap-x-12 gap-y-5",children:[jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CheckCircle2,{className:f("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{Oe(),$(!Je);},className:f("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",x.progress===100||x.status==="completed"?"bg-green-500/20 text-green-400":x.progress&&x.progress>0||x.status==="in-progress"?"bg-blue-500/20 text-blue-400":l?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:x.progress===100||x.status==="completed"?m==="es"?"COMPLETADO":"DONE":x.progress&&x.progress>0||x.status==="in-progress"?m==="es"?"EN PROGRESO":"IN PROGRESS":m==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:Je&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>$(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:f("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"todo",label:m==="es"?"Por hacer":"To Do",color:"bg-white/10 text-white"},{id:"in-progress",label:m==="es"?"En progreso":"In Progress",color:"bg-blue-500/20 text-blue-400"},{id:"completed",label:m==="es"?"Completado":"Done",color:"bg-green-500/20 text-green-400"}].map(F=>jsxs("button",{onClick:()=>Ee(F.id),className:f("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",l?"hover:bg-white/5":"hover:bg-gray-50",(x.status===F.id||F.id==="completed"&&x.progress===100||F.id==="in-progress"&&x.progress&&x.progress>0&&x.progress<100||F.id==="todo"&&(!x.progress||x.progress===0)&&x.status!=="in-progress"&&x.status!=="completed")&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:f("w-2 h-2 rounded-full",F.id==="completed"?"bg-green-500":F.id==="in-progress"?"bg-blue-500":"bg-gray-400")}),jsx("span",{className:l?"text-white":"text-gray-900",children:F.label})]},F.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(User,{className:f("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{$(false),W(false),H(null),j(!D);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",l?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[x.assignees&&x.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[x.assignees.slice(0,3).map((F,he)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:F.color||"#8B5CF6"},title:F.name,children:F.initials||F.name.slice(0,2).toUpperCase()},he)),x.assignees.length>3&&jsxs("span",{className:f("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:["+",x.assignees.length-3]})]}):jsx("span",{className:f("text-sm",l?"text-[#6B7280]":"text-gray-400"),children:m==="es"?"Agregar":"Add"}),jsx(ChevronDown,{className:f("w-3 h-3",l?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:D&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>j(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:f("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[200px] max-h-[280px] overflow-y-auto",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:t.availableUsers&&t.availableUsers.length>0?t.availableUsers.map(F=>{let he=x.assignees?.some(q=>q.name===F.name);return jsxs("button",{onClick:()=>{let q=x.assignees||[],Le;he?Le=q.filter(ct=>ct.name!==F.name):Le=[...q,{name:F.name,avatar:F.avatar,initials:F.initials||F.name.slice(0,2).toUpperCase(),color:F.color||"#8B5CF6"}],te("assignees",Le);},className:f("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors",l?"hover:bg-white/5":"hover:bg-gray-50",he&&(l?"bg-white/5":"bg-gray-50")),children:[F.avatar?jsx("img",{src:F.avatar,alt:F.name,className:"w-6 h-6 rounded-full object-cover"}):jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:F.color||"#8B5CF6"},children:F.initials||F.name.slice(0,2).toUpperCase()}),jsx("span",{className:f("flex-1 text-left",l?"text-white":"text-gray-900"),children:F.name}),he&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},F.id||F.name)}):jsx("div",{className:f("px-3 py-4 text-sm text-center",l?"text-[#6B7280]":"text-gray-400"),children:m==="es"?"No hay usuarios disponibles":"No users available"})})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CalendarDays,{className:f("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{H(N?null:"start"),Y(x.startDate||new Date);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",l?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[x.startDate?.toLocaleDateString(m==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(m==="es"?"Inicio":"Start"),jsx("span",{className:f("mx-1",l?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),x.endDate?.toLocaleDateString(m==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(m==="es"?"Fin":"End"),(x.startDate||x.endDate)&&jsx(X,{className:"w-3.5 h-3.5 ml-1 opacity-50 hover:opacity-100",onClick:F=>{F.stopPropagation();}})]}),jsx(AnimatePresence,{children:N&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>H(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:f("absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:F=>F.stopPropagation(),children:[jsxs("div",{className:f("w-44 py-2 border-r",l?"border-white/10":"border-gray-200"),children:[(()=>{let F=new Date,he=new Date(F);he.setDate(F.getDate()+1);let q=new Date(F);q.setDate(F.getDate()+((6-F.getDay()+7)%7||7));let Le=new Date(F);Le.setDate(F.getDate()+((1-F.getDay()+7)%7||7));let ct=new Date(F);ct.setDate(F.getDate()+(6-F.getDay()+7)%7+7);let ne=new Date(F);ne.setDate(F.getDate()+14);let ze=new Date(F);return ze.setDate(F.getDate()+28),[{label:m==="es"?"Hoy":"Today",date:F,display:F.toLocaleDateString(m==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:m==="es"?"Ma\xF1ana":"Tomorrow",date:he,display:he.toLocaleDateString(m==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:m==="es"?"Este fin de semana":"This weekend",date:q,display:m==="es"?"s\xE1b.":"sat."},{label:m==="es"?"Pr\xF3xima semana":"Next week",date:Le,display:m==="es"?"lun.":"mon."},{label:m==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:ct,display:ct.toLocaleDateString(m==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:m==="es"?"2 semanas":"2 weeks",date:ne,display:ne.toLocaleDateString(m==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:m==="es"?"4 semanas":"4 weeks",date:ze,display:ze.toLocaleDateString(m==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Ae,Qt)=>jsxs("button",{className:f("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",l?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if(N==="start"){let mt=x.endDate&&Ae.date>x.endDate?Ae.date:x.endDate;He(Ae.date,mt),H("end");}else {let mt=x.startDate&&Ae.date<x.startDate?Ae.date:x.startDate;He(mt,Ae.date),H(null);}},children:[jsx("span",{children:Ae.label}),jsx("span",{className:f("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:Ae.display})]},Qt))})(),jsx("div",{className:f("border-t mt-2 pt-2",l?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{He(void 0,void 0),H(null);},className:f("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",l?"hover:bg-white/5 text-red-400":"hover:bg-gray-50 text-red-500"),children:[jsx("span",{children:m==="es"?"Quitar fechas":"Clear dates"}),jsx(X,{className:"w-4 h-4 opacity-50"})]})})]}),jsxs("div",{className:"p-4",children:[jsx("div",{className:f("text-xs mb-3 px-2 py-1 rounded",l?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:N==="start"?m==="es"?"\u{1F4C5} Selecciona fecha de inicio":"\u{1F4C5} Select start date":m==="es"?"\u{1F4C5} Selecciona fecha de fin":"\u{1F4C5} Select end date"}),jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsx("span",{className:f("font-medium",l?"text-white":"text-gray-900"),children:L.toLocaleDateString(m==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>Y(new Date),className:f("p-1 rounded text-sm transition-colors",l?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:m==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>Y(new Date(L.getFullYear(),L.getMonth()-1)),className:f("p-1 rounded",l?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-4 h-4"})}),jsx("button",{onClick:()=>Y(new Date(L.getFullYear(),L.getMonth()+1)),className:f("p-1 rounded",l?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:"w-4 h-4"})})]})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:(m==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(F=>jsx("div",{className:f("w-8 h-8 flex items-center justify-center text-xs",l?"text-[#6B7280]":"text-gray-400"),children:F},F))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let F=L.getFullYear(),he=L.getMonth(),q=new Date(F,he,1).getDay(),Le=new Date(F,he+1,0).getDate(),ct=new Date(F,he,0).getDate(),ne=new Date,ze=[];for(let Ae=q-1;Ae>=0;Ae--)ze.push({day:ct-Ae,isCurrentMonth:false,date:new Date(F,he-1,ct-Ae)});for(let Ae=1;Ae<=Le;Ae++)ze.push({day:Ae,isCurrentMonth:true,date:new Date(F,he,Ae)});let xt=42-ze.length;for(let Ae=1;Ae<=xt;Ae++)ze.push({day:Ae,isCurrentMonth:false,date:new Date(F,he+1,Ae)});return ze.map((Ae,Qt)=>{let mt=Ae.date.toDateString()===ne.toDateString(),la=x.startDate?.toDateString()===Ae.date.toDateString(),$t=x.endDate?.toDateString()===Ae.date.toDateString(),Xe=la||$t,Mt=x.startDate&&x.endDate&&Ae.date>=x.startDate&&Ae.date<=x.endDate;return jsx("button",{className:f("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!Ae.isCurrentMonth&&(l?"text-[#4B5563]":"text-gray-300"),Ae.isCurrentMonth&&(l?"text-white":"text-gray-900"),mt&&"ring-2 ring-[#3B82F6]",la&&"bg-[#3B82F6] text-white",$t&&!la&&"bg-[#7C3AED] text-white",Mt&&!Xe&&(l?"bg-[#7C3AED]/20":"bg-purple-100"),!Xe&&(l?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{let ra=new Date(Ae.date);if(N==="start"){let pr=x.endDate&&ra>x.endDate?ra:x.endDate;He(ra,pr),H("end");}else {let pr=x.startDate&&ra<x.startDate?ra:x.startDate;He(pr,ra),H(null);}},children:Ae.day},Qt)})})()})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:f("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{Oe(),W(!B);},className:f("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",x.priority==="high"||x.priority==="urgent"?"bg-red-500/20 text-red-400":x.priority==="medium"?"bg-yellow-500/20 text-yellow-400":x.priority==="low"?"bg-green-500/20 text-green-400":l?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:x.priority?x.priority==="high"||x.priority==="urgent"?m==="es"?"Urgente":"Urgent":x.priority==="medium"?m==="es"?"Media":"Medium":m==="es"?"Baja":"Low":m==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:B&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>W(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:f("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"urgent",label:m==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:m==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:m==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:m==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:m==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(F=>jsxs("button",{onClick:()=>{te("priority",F.id),W(false);},className:f("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",l?"hover:bg-white/5":"hover:bg-gray-50",x.priority===F.id&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:f("w-2 h-2 rounded-full",F.color)}),jsx("span",{className:l?"text-white":"text-gray-900",children:F.label})]},F.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:f("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:f("text-sm",l?"text-white":"text-gray-900"),children:x.startDate&&x.endDate?`${Math.ceil((x.endDate.getTime()-x.startDate.getTime())/(1e3*60*60*24))} ${m==="es"?"d\xEDas":"days"}`:m==="es"?"Sin definir":"Not set"})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:f("w-4 h-4 rounded-full border-2",l?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:f("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[J?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:x.progress||0,onChange:F=>{let he=parseInt(F.target.value),q=x.status;he===100?q="completed":he>0?q="in-progress":q="todo";let Le={...x,progress:he,status:q};k(Le),a.onTaskUpdate?.(Le);},onBlur:()=>R(false),className:f("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",l?"bg-white/10":"bg-gray-200","[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[#3B82F6] [&::-webkit-slider-thumb]:cursor-pointer"),autoFocus:true}):jsx("button",{onClick:()=>R(true),className:f("flex-1 h-2 rounded-full overflow-hidden max-w-[120px] cursor-pointer hover:ring-2 hover:ring-white/20 transition-all",l?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:f("h-full rounded-full transition-all",x.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${x.progress||0}%`}})}),jsxs("span",{className:f("text-sm font-medium min-w-[40px]",l?"text-white":"text-gray-900"),children:[x.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:f("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Etiquetas":"Tags"}),jsx(nr,{selectedTags:x.tags||[],availableTags:p,onChange:F=>{te("tags",F);},onCreateTag:i,theme:w})]}),jsxs("div",{className:"flex items-start gap-3 relative",children:[jsx(Link2,{className:f("w-4 h-4 mt-1.5",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24 mt-1",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[x.dependencies&&x.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:x.dependencies.map(F=>{let he=e.find(q=>q.id===F);return jsxs("span",{className:f("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",l?"bg-blue-500/20 text-blue-400":"bg-blue-100 text-blue-700"),children:[he?.name||F.slice(0,8),jsx("button",{onClick:()=>{let q=(x.dependencies||[]).filter(Le=>Le!==F);te("dependencies",q);},className:f("ml-0.5 hover:bg-white/20 rounded-full p-0.5 transition-colors"),children:jsx(X,{className:"w-3 h-3"})})]},F)})}),jsxs("button",{onClick:()=>{Oe(),ua(!sa);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",l?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{className:f("text-sm",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:sa&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{ua(false),Ue("");}}),jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:f("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[280px] max-h-[320px]",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[jsx("div",{className:f("p-2 border-b",l?"border-white/10":"border-gray-200"),children:jsx("input",{type:"text",value:$e,onChange:F=>Ue(F.target.value),placeholder:m==="es"?"Buscar tarea...":"Search task...",className:f("w-full px-3 py-2 rounded-md text-sm outline-none",l?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400"),autoFocus:true})}),jsx("div",{className:"max-h-[240px] overflow-y-auto",children:e.length>0?e.filter(F=>F.id!==x.id).filter(F=>$e===""||F.name.toLowerCase().includes($e.toLowerCase())).map(F=>{let he=x.dependencies?.includes(F.id);return jsxs("button",{onClick:()=>{let q=x.dependencies||[],Le;he?Le=q.filter(ct=>ct!==F.id):Le=[...q,F.id],te("dependencies",Le);},className:f("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",l?"hover:bg-white/5":"hover:bg-gray-50",he&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:f("w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0",he?"bg-blue-500 border-blue-500":l?"border-white/30":"border-gray-300"),children:he&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("span",{className:f("block truncate",l?"text-white":"text-gray-900"),children:F.name}),jsx("span",{className:f("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:F.id.slice(0,8)})]})]},F.id)}):jsx("div",{className:f("px-3 py-4 text-sm text-center",l?"text-[#6B7280]":"text-gray-500"),children:m==="es"?"No hay tareas disponibles":"No tasks available"})})]})]})})]})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Palette,{className:f("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:"Color"}),jsxs("button",{onClick:()=>{Oe(),ue(!ia);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",l?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx("div",{className:"w-4 h-4 rounded-full",style:{backgroundColor:x.color||"#6366F1"}}),jsx("span",{className:f("text-sm",l?"text-white":"text-gray-900"),children:sr.find(F=>F.value===x.color)?.name||(m==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:f("w-3 h-3",l?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:ia&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>ue(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:f("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden p-3",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:jsx("div",{className:"grid grid-cols-6 gap-1.5",children:sr.map(F=>{let he=x.color===F.value;return jsx("button",{onClick:()=>{te("color",F.value),ue(false);},className:f("w-7 h-7 rounded-full flex items-center justify-center transition-all",he&&"ring-2 ring-offset-2",l?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:F.value,outlineColor:he?F.value:void 0},title:F.name,children:he&&jsx(Check,{className:"w-3.5 h-3.5 text-white"})},F.value)})})})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Diamond,{className:f("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Hito":"Milestone"}),jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:x.isMilestone||false,onChange:F=>te("isMilestone",F.target.checked),className:f("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",x.isMilestone?"bg-purple-500 border-purple-500":l?"border-white/30 bg-transparent":"border-gray-300 bg-transparent","checked:bg-purple-500 checked:border-purple-500")}),jsx("span",{className:f("text-sm",l?"text-white":"text-gray-900"),children:m==="es"?"Marcar como hito":"Mark as milestone"})]})]})]}),jsxs("div",{className:f("mt-6 pt-4 border-t",l?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2 mb-3",children:[jsx(FileText,{className:f("w-4 h-4",l?"text-[#6B7280]":"text-gray-400")}),jsx("h3",{className:f("text-sm font-semibold",l?"text-white":"text-gray-900"),children:m==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:x.description||"",onChange:F=>te("description",F.target.value),placeholder:m==="es"?"Agregar descripci\xF3n...":"Add description...",className:f("w-full min-h-[100px] px-3 py-2 rounded-lg text-sm resize-none outline-none transition-colors",l?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400 focus:bg-gray-200")}),jsxs("button",{className:f("flex items-center gap-2 text-sm mt-2 transition-colors",l?"text-purple-400 hover:text-purple-300":"text-purple-600 hover:text-purple-700"),children:[jsx(Sparkles,{className:"w-4 h-4"}),m==="es"?"Escribe con IA":"Write with AI"]})]}),jsxs("div",{className:f("mt-6 pt-4 border-t",l?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:f("text-sm font-semibold mb-3",l?"text-white":"text-gray-900"),children:m==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:f("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",l?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),m==="es"?"Crea un campo en esta lista":"Create a field in this list"]})]}),jsxs("div",{className:f("mt-6 pt-4 border-t",l?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:f("text-sm font-semibold mb-3",l?"text-white":"text-gray-900"),children:m==="es"?"Agregar subtarea":"Add subtask"}),x.subtasks&&x.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:x.subtasks.map(F=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:f("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",F.progress===100?"bg-green-500 border-green-500":l?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:F.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:f("text-sm",F.progress===100?"line-through text-[#6B7280]":l?"text-white":"text-gray-900"),children:F.name})]},F.id))}),jsxs("button",{className:f("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",l?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),m==="es"?"Add Tarea":"Add Task"]})]}),jsxs("div",{className:f("mt-6 pt-4 border-t",l?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("h3",{className:f("text-sm font-semibold",l?"text-white":"text-gray-900"),children:m==="es"?"Listas de control":"Checklists"}),jsx("button",{className:f("p-1 rounded transition-colors",l?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:jsx(Plus,{className:"w-4 h-4"})})]}),jsxs("button",{className:f("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",l?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(ListChecks,{className:"w-4 h-4"}),m==="es"?"Crear lista de control":"Create checklist"]})]}),jsxs("div",{className:f("mt-6 pt-4 border-t",l?"border-white/10":"border-gray-200"),children:[jsxs("h3",{className:f("text-sm font-semibold mb-3",l?"text-white":"text-gray-900"),children:[m==="es"?"Adjuntos":"Attachments",za.length>0&&jsxs("span",{className:f("ml-2 text-xs font-normal",l?"text-[#6B7280]":"text-gray-400"),children:["(",za.length,")"]})]}),za.length>0&&jsx("div",{className:"space-y-2 mb-4",children:za.map(F=>{let he=Ka(F.type),q=F.type.startsWith("image/");return jsxs("div",{className:f("flex items-center gap-3 p-2 rounded-lg group transition-colors",l?"bg-white/5 hover:bg-white/10":"bg-gray-50 hover:bg-gray-100"),children:[q&&F.thumbnailUrl?jsx("img",{src:F.thumbnailUrl,alt:F.name,className:"w-10 h-10 rounded object-cover"}):jsx("div",{className:f("w-10 h-10 rounded flex items-center justify-center",l?"bg-white/10":"bg-gray-200"),children:jsx(he,{className:f("w-5 h-5",l?"text-[#9CA3AF]":"text-gray-500")})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("a",{href:F.url,target:"_blank",rel:"noopener noreferrer",className:f("text-sm font-medium truncate block hover:underline",l?"text-white":"text-gray-900"),children:F.name}),jsx("p",{className:f("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:dt(F.size)})]}),a.onDeleteAttachment&&jsx("button",{onClick:()=>a.onDeleteAttachment?.(F.id),className:f("p-1.5 rounded opacity-0 group-hover:opacity-100 transition-all",l?"hover:bg-red-500/20 text-red-400":"hover:bg-red-100 text-red-500"),title:m==="es"?"Eliminar":"Delete",children:jsx(Trash2,{className:"w-4 h-4"})})]},F.id)})}),jsxs("div",{onDragOver:Be,onDragLeave:Et,onDrop:G,className:f("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",be?l?"border-blue-500 bg-blue-500/10":"border-blue-400 bg-blue-50":l?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300",Ft&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:ee,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!a.onUploadAttachments||Ft}),Ft?jsxs(Fragment,{children:[jsx("div",{className:"w-6 h-6 mx-auto mb-2 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"}),jsx("p",{className:f("text-sm",l?"text-[#9CA3AF]":"text-gray-500"),children:m==="es"?"Subiendo...":"Uploading..."})]}):jsxs(Fragment,{children:[jsx(Upload,{className:f("w-6 h-6 mx-auto mb-2",be?"text-blue-500":l?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:f("text-sm",l?"text-[#9CA3AF]":"text-gray-500"),children:be?m==="es"?"Suelta los archivos aqu\xED":"Drop files here":m==="es"?jsxs(Fragment,{children:["Suelta tus archivos aqu\xED o ",jsx("span",{className:"underline",children:"haz clic para subir"})]}):jsxs(Fragment,{children:["Drop your files here or ",jsx("span",{className:"underline",children:"click to upload"})]})}),!a.onUploadAttachments&&jsx("p",{className:f("text-xs mt-1",l?"text-[#6B7280]":"text-gray-400"),children:m==="es"?"Upload no disponible":"Upload not available"})]})]})]})]})]}),jsxs("div",{className:f("w-80 border-l flex flex-col",l?"border-white/10 bg-[#0F1117]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:f("px-4 py-3 border-b",l?"border-white/10":"border-gray-200"),children:jsxs("h3",{className:f("text-sm font-semibold",l?"text-white":"text-gray-900"),children:[m==="es"?"Actividad":"Activity",d&&d.length>0&&jsxs("span",{className:f("ml-2 text-xs font-normal",l?"text-[#6B7280]":"text-gray-400"),children:["(",d.length,")"]})]})}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:d&&d.length>0?jsx("div",{className:"space-y-4",children:d.map(F=>{let he=(()=>{let q=new Date,Le=new Date(F.createdAt),ct=q.getTime()-Le.getTime(),ne=Math.floor(ct/6e4),ze=Math.floor(ne/60),xt=Math.floor(ze/24);return ne<1?m==="es"?"ahora":"now":ne<60?m==="es"?`hace ${ne}m`:`${ne}m ago`:ze<24?m==="es"?`hace ${ze}h`:`${ze}h ago`:m==="es"?`hace ${xt}d`:`${xt}d ago`})();return jsxs("div",{className:"flex gap-3",children:[jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:"#8B5CF6"},children:F.user?.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2 mb-1",children:[jsx("span",{className:f("text-sm font-medium",l?"text-white":"text-gray-900"),children:F.user?.name||(m==="es"?"Usuario":"User")}),jsx("span",{className:f("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:he})]}),jsx("p",{className:f("text-sm break-words",l?"text-[#9CA3AF]":"text-gray-600"),children:F.content})]})]},F.id)})}):jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[jsx(MessageSquare,{className:f("w-10 h-10 mb-3",l?"text-[#3B4252]":"text-gray-300")}),jsx("p",{className:f("text-sm",l?"text-[#6B7280]":"text-gray-500"),children:m==="es"?"Sin actividad reciente":"No recent activity"})]})}),jsx("div",{className:f("p-4 border-t",l?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-start gap-2",children:[h&&jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:h.color||"#8B5CF6"},children:h.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:f("flex-1 flex items-center gap-2 px-3 py-2 rounded-lg",l?"bg-white/5":"bg-white border border-gray-200"),children:[jsx("input",{type:"text",value:S,onChange:F=>Z(F.target.value),onKeyDown:async F=>{if(F.key==="Enter"&&!F.shiftKey&&x&&S.trim()&&g){F.preventDefault(),Te(true);try{await g(x.id,S.trim()),Z("");}finally{Te(false);}}},placeholder:m==="es"?"Escribe un comentario...":"Write a comment...",disabled:ge||!g,className:f("flex-1 bg-transparent text-sm outline-none",l?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400",(ge||!g)&&"opacity-50")}),jsx("button",{onClick:async()=>{if(x&&S.trim()&&g){Te(true);try{await g(x.id,S.trim()),Z("");}finally{Te(false);}}},disabled:ge||!S.trim()||!g,className:f("p-1.5 rounded transition-colors",S.trim()&&g?"bg-blue-500 text-white hover:bg-blue-600":l?"text-[#6B7280]":"text-gray-400",ge&&"opacity-50 cursor-not-allowed"),children:ge?jsx("div",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):jsx(Send,{className:"w-4 h-4"})})]})]})})]})]})]})}),jsx(AnimatePresence,{children:O&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>M(null),className:"fixed inset-0 bg-black/30 z-40"}),jsxs(motion.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:f("fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-[320px] max-h-[400px] rounded-xl shadow-2xl z-50 overflow-hidden",l?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:f("px-4 py-3 border-b flex items-center justify-between",l?"border-white/10":"border-gray-200"),children:[jsx("span",{className:f("font-medium",l?"text-white":"text-gray-900"),children:O.date.toLocaleDateString(m==="es"?"es-ES":"en-US",{weekday:"long",month:"long",day:"numeric"})}),jsx("button",{onClick:()=>M(null),className:f("p-1 rounded",l?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(X,{className:"w-4 h-4"})})]}),jsx("div",{className:"p-3 max-h-[320px] overflow-y-auto space-y-2",children:O.events.map(F=>jsxs("button",{onClick:()=>{M(null),k(F.task),C?.(F.task.id);},className:f("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-left transition-colors",l?"hover:bg-white/5":"hover:bg-gray-50"),children:[jsx($c,{task:F.task}),jsx("span",{className:f("text-sm truncate flex-1",l?"text-white":"text-gray-900"),children:F.title}),F.task.priority==="high"||F.task.priority==="urgent"?jsx(Flag,{className:"w-3.5 h-3.5 text-red-400"}):null]},F.id))})]})]})})]})}var Bi={bgPrimary:"#0d1117",bgSecondary:"#161b22",bgHover:"#21262d",bgToday:"#1f6feb20",bgWeekend:"#161b2280",bgOtherMonth:"#0d111750",border:"#30363d",borderLight:"#21262d",textPrimary:"#c9d1d9",textSecondary:"#8b949e",textMuted:"#6e7681",textToday:"#58a6ff",accent:"#58a6ff",accentHover:"#79b8ff",accentLight:"#58a6ff20",statusTodo:"#8b949e",statusInProgress:"#f0883e",statusCompleted:"#3fb950",focusRing:"#58a6ff"},Ri={bgPrimary:"#ffffff",bgSecondary:"#f6f8fa",bgHover:"#f3f4f6",bgToday:"#dbeafe",bgWeekend:"#f9fafb",bgOtherMonth:"#f3f4f680",border:"#d0d7de",borderLight:"#e5e7eb",textPrimary:"#24292f",textSecondary:"#57606a",textMuted:"#8b949e",textToday:"#0969da",accent:"#0969da",accentHover:"#0550ae",accentLight:"#dbeafe",statusTodo:"#8b949e",statusInProgress:"#bf8700",statusCompleted:"#1a7f37",focusRing:"#0969da"},Oi={bgPrimary:"#1a1a2e",bgSecondary:"#16213e",bgHover:"#1f3460",bgToday:"#6366f120",bgWeekend:"#16213e80",bgOtherMonth:"#1a1a2e50",border:"#2a3f5f",borderLight:"#1f3460",textPrimary:"#e4e6eb",textSecondary:"#a8b2c1",textMuted:"#6b7280",textToday:"#818cf8",accent:"#6366f1",accentHover:"#818cf8",accentLight:"#6366f120",statusTodo:"#9ca3af",statusInProgress:"#fbbf24",statusCompleted:"#34d399",focusRing:"#6366f1"},Gn={dark:Bi,light:Ri,neutral:Oi};function Gc(e){return Gn[e]||Gn.dark}function dh({stack:e,cards:t,renderCard:a,onCardClick:r,onToggleExpand:o,onUnstack:s,onDeleteStack:n,className:c}){let[p,i]=useState(false),u=useMemo(()=>t.filter(h=>e.cardIds.includes(h.id)),[t,e.cardIds]),d=useMemo(()=>{let h=u.length,C=new Set(u.flatMap(b=>b.assignedUserIds||[])).size,T=u.map(b=>b.priority).filter(Boolean),m=new Set(u.flatMap(b=>b.labels||[])).size;return {totalCards:h,uniqueAssignees:C,priorities:T,labels:m}},[u]),g=()=>{o?.(e.id);};return jsxs("div",{className:f("card-stack",!e.isExpanded&&"card-stack-collapsed",c),onMouseEnter:()=>i(true),onMouseLeave:()=>i(false),style:{"--stack-color":e.color||"var(--color-accent-primary)"},children:[jsxs("div",{className:"card-stack-header",onClick:g,children:[jsxs("div",{className:"card-stack-header-left",children:[jsx("button",{className:"card-stack-toggle","aria-label":e.isExpanded?"Collapse":"Expand",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:f("card-stack-chevron",e.isExpanded&&"expanded"),children:jsx("polyline",{points:"6 9 12 15 18 9"})})}),jsx("h3",{className:"card-stack-title",children:e.title}),jsx("div",{className:"card-stack-badge",children:d.totalCards}),jsxs("div",{className:"card-stack-strategy",children:[e.strategy==="ai-similarity"&&"\u2728 AI",e.strategy==="manual"&&"\u{1F464} Manual",e.strategy==="labels"&&"\u{1F3F7}\uFE0F Labels",e.strategy==="assignee"&&"\u{1F465} Assignee",e.strategy==="priority"&&"\u{1F3AF} Priority",e.strategy==="epic"&&"\u{1F4DA} Epic"]})]}),p&&jsx("div",{className:"card-stack-actions",children:jsx("button",{className:"card-stack-action",onClick:h=>{h.stopPropagation(),n?.(e.id);},"aria-label":"Delete stack",children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})})]}),!e.isExpanded&&jsxs("div",{className:"card-stack-summary",children:[jsxs("div",{className:"card-stack-summary-item",children:[jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),jsxs("span",{children:[d.uniqueAssignees," assignees"]})]}),d.labels>0&&jsxs("div",{className:"card-stack-summary-item",children:[jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"}),jsx("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]}),jsxs("span",{children:[d.labels," labels"]})]}),e.confidence&&jsx("div",{className:"card-stack-summary-item",children:jsxs("span",{className:"card-stack-confidence",children:[Math.round(e.confidence*100),"% match"]})})]}),e.isExpanded&&jsx("div",{className:"card-stack-content",children:u.length===0?jsxs("div",{className:"card-stack-empty",children:[jsx("p",{children:"No cards in this stack"}),jsx("span",{children:"Drag cards here or delete this stack"})]}):jsx("div",{className:"card-stack-cards",children:u.map(h=>jsxs("div",{className:"card-stack-card-wrapper",children:[a?jsx("div",{onClick:()=>r?.(h),children:a(h)}):jsxs("div",{className:"card-stack-default-card",onClick:()=>r?.(h),children:[jsx("h4",{children:h.title}),h.description&&jsxs("p",{children:[h.description.substring(0,100),"..."]})]}),jsx("button",{className:"card-stack-unstack-btn",onClick:C=>{C.stopPropagation(),s?.(e.id,h.id);},"aria-label":"Remove from stack",children:jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},h.id))})})]})}var Vc={showIcons:true,showAvatars:true,groupByDay:true,useRelativeTime:true,compact:false};function _o(e){switch(e.type){case "created":return "Created card";case "status_changed":return `Changed status from "${e.changes.status?.from}" to "${e.changes.status?.to}"`;case "assignee_changed":return "Changed assignee";case "priority_changed":return `Changed priority from ${e.changes.priority?.from} to ${e.changes.priority?.to}`;case "moved":return `Moved from ${e.metadata?.fromColumn||"unknown"} to ${e.metadata?.toColumn||"unknown"}`;case "title_updated":return "Updated title";case "description_updated":return "Updated description";case "dates_changed":return "Changed dates";case "labels_changed":return "Updated labels";case "dependency_added":return "Added dependency";case "dependency_removed":return "Removed dependency";case "comment_added":return "Added comment";case "archived":return "Archived card";case "restored":return "Restored card";default:return "Updated card"}}function Vo(e){return {created:"\u2728",status_changed:"\u{1F504}",assignee_changed:"\u{1F464}",priority_changed:"\u{1F3AF}",moved:"\u27A1\uFE0F",title_updated:"\u270F\uFE0F",description_updated:"\u{1F4DD}",dates_changed:"\u{1F4C5}",labels_changed:"\u{1F3F7}\uFE0F",dependency_added:"\u{1F517}",dependency_removed:"\u26D3\uFE0F\u200D\u{1F4A5}",comment_added:"\u{1F4AC}",archived:"\u{1F4E6}",restored:"\u267B\uFE0F"}[e]||"\u{1F4CC}"}function jc(e){return {created:"#10b981",status_changed:"#3b82f6",assignee_changed:"#8b5cf6",priority_changed:"#f59e0b",moved:"#06b6d4",title_updated:"#6366f1",description_updated:"#6366f1",dates_changed:"#ec4899",labels_changed:"#14b8a6",dependency_added:"#a855f7",dependency_removed:"#ef4444",comment_added:"#84cc16",archived:"#6b7280",restored:"#10b981"}[e]||"#6b7280"}function Kc({events:e,filter:t,onFilterChange:a,onClearFilter:r,onEventClick:o,selectedEventId:s,config:n,className:c}){let p=useMemo(()=>({...Vc,...n}),[n]),[i,u]=useState(new Set),d=useRef(null),g=useMemo(()=>{if(!p.groupByDay)return [{date:null,events:e}];let y=new Map;return e.forEach(l=>{let w=l.timestamp.toISOString().split("T")[0],v=y.get(w);v?v.push(l):y.set(w,[l]);}),Array.from(y.entries()).sort((l,w)=>w[0].localeCompare(l[0])).map(([l,w])=>({date:new Date(l),events:w.sort((v,P)=>P.timestamp.getTime()-v.timestamp.getTime())}))},[e,p.groupByDay]),{uniqueUsers:h,uniqueTypes:C}=useMemo(()=>{let y=new Set,l=new Set;return e.forEach(w=>{y.add(w.userId),l.add(w.type);}),{uniqueUsers:Array.from(y),uniqueTypes:Array.from(l)}},[e]),T=y=>{u(l=>{let w=new Set(l);return w.has(y)?w.delete(y):w.add(y),w});},m=y=>{let w=new Date().getTime()-y.getTime(),v=Math.floor(w/6e4),P=Math.floor(w/36e5),x=Math.floor(w/864e5);return v<1?"just now":v<60?`${v}m ago`:P<24?`${P}h ago`:x<7?`${x}d ago`:y.toLocaleDateString()},b=useMemo(()=>{let y=0;return t.types&&t.types.length>0&&y++,t.users&&t.users.length>0&&y++,t.dateRange&&y++,t.searchTerm&&y++,y},[t]);return useEffect(()=>{if(s&&d.current){let y=d.current.querySelector(`[data-event-id="${s}"]`);y&&y.scrollIntoView({behavior:"smooth",block:"center"});}},[s]),e.length===0?jsxs("div",{className:f("history-timeline-empty",c),children:[jsx("div",{className:"history-timeline-empty-icon",children:"\u{1F4DC}"}),jsx("p",{className:"history-timeline-empty-text",children:"No history events yet"}),jsx("p",{className:"history-timeline-empty-subtext",children:"Changes to this card will appear here"})]}):jsxs("div",{className:f("history-timeline",p.compact&&"compact",c),children:[jsxs("div",{className:"history-timeline-filters",children:[jsxs("div",{className:"history-timeline-filter-group",children:[jsxs("select",{className:"history-timeline-filter-select",value:t.types?.[0]||"",onChange:y=>{let l=y.target.value;a({...t,types:l?[l]:void 0});},children:[jsx("option",{value:"",children:"All Events"}),C.map(y=>jsxs("option",{value:y,children:[Vo(y)," ",y.replace("_"," ")]},y))]}),h.length>1&&jsxs("select",{className:"history-timeline-filter-select",value:t.users?.[0]||"",onChange:y=>{let l=y.target.value;a({...t,users:l?[l]:void 0});},children:[jsx("option",{value:"",children:"All Users"}),h.map(y=>jsx("option",{value:y,children:y},y))]}),jsx("input",{type:"text",className:"history-timeline-filter-search",placeholder:"Search history...",value:t.searchTerm||"",onChange:y=>a({...t,searchTerm:y.target.value})})]}),b>0&&jsxs("button",{className:"history-timeline-filter-clear",onClick:r,children:["Clear filters (",b,")"]})]}),jsx("div",{className:"history-timeline-container",ref:d,children:g.map(y=>jsxs("div",{className:"history-timeline-group",children:[p.groupByDay&&y.date&&jsxs("div",{className:"history-timeline-day-header",children:[jsx("span",{className:"history-timeline-day-date",children:y.date.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),jsxs("span",{className:"history-timeline-day-count",children:[y.events.length," events"]})]}),jsx("div",{className:"history-timeline-events",children:y.events.map((l,w)=>{let v=i.has(l.id),P=s===l.id,x=jc(l.type);return jsxs("div",{"data-event-id":l.id,className:f("history-timeline-event",v&&"expanded",P&&"selected"),onClick:()=>o?.(l),children:[jsxs("div",{className:"history-timeline-line",children:[jsx("div",{className:"history-timeline-dot",style:{backgroundColor:x},children:p.showIcons&&jsx("span",{className:"history-timeline-dot-icon",children:Vo(l.type)})}),w<y.events.length-1&&jsx("div",{className:"history-timeline-connector",style:{borderColor:x}})]}),jsxs("div",{className:"history-timeline-event-content",children:[jsxs("div",{className:"history-timeline-event-header",children:[jsxs("div",{className:"history-timeline-event-header-left",children:[p.showAvatars&&l.userAvatar&&jsx("img",{src:l.userAvatar,alt:l.userName||l.userId,className:"history-timeline-event-avatar"}),jsxs("div",{className:"history-timeline-event-description",children:[jsx("span",{className:"history-timeline-event-user",children:l.userName||l.userId}),jsx("span",{className:"history-timeline-event-action",children:_o(l)})]})]}),jsx("div",{className:"history-timeline-event-time",children:p.useRelativeTime?m(l.timestamp):l.timestamp.toLocaleString()})]}),Object.keys(l.changes).length>0&&jsxs("button",{className:"history-timeline-event-toggle",onClick:k=>{k.stopPropagation(),T(l.id);},children:[v?"\u25BC":"\u25B6"," Show changes"]}),v&&jsxs("div",{className:"history-timeline-event-changes",children:[Object.entries(l.changes).map(([k,O])=>jsxs("div",{className:"history-timeline-event-change",children:[jsxs("span",{className:"history-timeline-event-change-key",children:[k,":"]}),jsxs("div",{className:"history-timeline-event-change-values",children:[jsx("span",{className:"history-timeline-event-change-from",children:JSON.stringify(O.from)}),jsx("span",{className:"history-timeline-event-change-arrow",children:"\u2192"}),jsx("span",{className:"history-timeline-event-change-to",children:JSON.stringify(O.to)})]})]},k)),l.metadata&&Object.keys(l.metadata).length>0&&jsxs("div",{className:"history-timeline-event-metadata",children:[jsx("div",{className:"history-timeline-event-metadata-title",children:"Additional Info:"}),Object.entries(l.metadata).map(([k,O])=>jsxs("div",{className:"history-timeline-event-metadata-item",children:[jsxs("span",{className:"history-timeline-event-metadata-key",children:[k,":"]}),jsx("span",{className:"history-timeline-event-metadata-value",children:JSON.stringify(O)})]},k))]})]})]})]},l.id)})})]},y.date?.toISOString()||"all"))})]})}function qc({replayState:e,events:t,onStartReplay:a,onStopReplay:r,onTogglePlayback:o,onPrevious:s,onNext:n,onGoToEvent:c,onSpeedChange:p,className:i}){let u=[.5,1,1.5,2,3],d=useMemo(()=>!e||t.length===0?null:t[e.currentIndex],[e,t]),g=useMemo(()=>!e||e.totalEvents===0?0:e.currentIndex/(e.totalEvents-1)*100,[e]);return t.length===0?jsxs("div",{className:f("history-replay-empty",i),children:[jsx("div",{className:"history-replay-empty-icon",children:"\u23F3"}),jsx("p",{className:"history-replay-empty-text",children:"No history to replay"})]}):e?jsxs("div",{className:f("history-replay",i),children:[jsxs("div",{className:"history-replay-current-event",children:[jsx("div",{className:"history-replay-event-icon",children:d&&Vo(d.type)}),jsxs("div",{className:"history-replay-event-info",children:[jsx("div",{className:"history-replay-event-description",children:d&&_o(d)}),jsxs("div",{className:"history-replay-event-meta",children:[jsxs("span",{className:"history-replay-event-index",children:["Event ",e.currentIndex+1," of ",e.totalEvents]}),jsx("span",{className:"history-replay-event-time",children:d&&d.timestamp.toLocaleString()})]})]})]}),jsxs("div",{className:"history-replay-progress-container",children:[jsx("input",{type:"range",className:"history-replay-progress-slider",min:"0",max:e.totalEvents-1,value:e.currentIndex,onChange:h=>c(parseInt(h.target.value))}),jsx("div",{className:"history-replay-progress-fill",style:{width:`${g}%`}}),jsx("div",{className:"history-replay-progress-markers",children:t.map((h,C)=>jsx("div",{className:f("history-replay-progress-marker",C===e.currentIndex&&"active"),style:{left:`${C/(e.totalEvents-1)*100}%`},onClick:()=>c(C),title:_o(h)},h.id))})]}),jsxs("div",{className:"history-replay-controls",children:[jsx("button",{className:"history-replay-control-btn",onClick:s,disabled:!e.canGoBack,title:"Previous event (\u2190)",children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polygon",{points:"19 20 9 12 19 4 19 20"}),jsx("line",{x1:"5",y1:"19",x2:"5",y2:"5"})]})}),jsx("button",{className:"history-replay-control-btn history-replay-control-play",onClick:o,title:e.isPlaying?"Pause (Space)":"Play (Space)",children:e.isPlaying?jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:[jsx("rect",{x:"6",y:"4",width:"4",height:"16"}),jsx("rect",{x:"14",y:"4",width:"4",height:"16"})]}):jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})}),jsx("button",{className:"history-replay-control-btn",onClick:n,disabled:!e.canGoForward,title:"Next event (\u2192)",children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polygon",{points:"5 4 15 12 5 20 5 4"}),jsx("line",{x1:"19",y1:"5",x2:"19",y2:"19"})]})}),jsxs("div",{className:"history-replay-speed",children:[jsx("label",{className:"history-replay-speed-label",children:"Speed:"}),jsx("div",{className:"history-replay-speed-buttons",children:u.map(h=>jsxs("button",{className:f("history-replay-speed-btn",e.speed===h&&"active"),onClick:()=>p(h),children:[h,"x"]},h))})]}),jsx("button",{className:"history-replay-control-btn history-replay-stop",onClick:r,title:"Stop replay (Esc)",children:jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:jsx("rect",{x:"6",y:"6",width:"12",height:"12"})})})]}),jsxs("div",{className:"history-replay-shortcuts",children:[jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"Space"})," Play/Pause"]}),jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"\u2190"})," Previous"]}),jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"\u2192"})," Next"]}),jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"Esc"})," Stop"]})]}),jsxs("div",{className:"history-replay-card-preview",children:[jsxs("div",{className:"history-replay-card-preview-header",children:[jsx("span",{className:"history-replay-card-preview-title",children:"Card State at This Point"}),jsx("span",{className:"history-replay-card-preview-time",children:d&&d.timestamp.toLocaleDateString()})]}),jsxs("div",{className:"history-replay-card-preview-content",children:[jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Title:"}),jsx("span",{className:"history-replay-card-preview-value",children:e.cardState.title})]}),e.cardState.description&&jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Description:"}),jsx("span",{className:"history-replay-card-preview-value",children:e.cardState.description})]}),jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Priority:"}),jsx("span",{className:"history-replay-card-preview-value",children:e.cardState.priority||"None"})]}),e.cardState.labels&&e.cardState.labels.length>0&&jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Labels:"}),jsx("div",{className:"history-replay-card-preview-labels",children:e.cardState.labels.map(h=>jsx("span",{className:"history-replay-card-preview-label-tag",children:h},h))})]})]})]})]}):jsxs("div",{className:f("history-replay-start",i),children:[jsxs("button",{className:"history-replay-start-button",onClick:a,children:[jsx("svg",{className:"history-replay-start-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),jsx("span",{children:"Start Time Travel"})]}),jsxs("p",{className:"history-replay-start-hint",children:["Replay ",t.length," events from this card's history"]})]})}function zi(e){return {blocks:"#ef4444",blocked_by:"#dc2626",depends_on:"#f59e0b",required_by:"#d97706",relates_to:"#6b7280",duplicates:"#8b5cf6",parent_of:"#3b82f6",child_of:"#2563eb",similar_to:"#10b981"}[e]||"#6b7280"}function Ui(e){return {blocks:"Blocks",blocked_by:"Blocked by",depends_on:"Depends on",required_by:"Required by",relates_to:"Relates to",duplicates:"Duplicates",parent_of:"Parent of",child_of:"Child of",similar_to:"Similar to"}[e]||e}function Xc(e){return {blocks:"\u{1F6AB}",blocked_by:"\u26D4",depends_on:"\u{1F517}",required_by:"\u{1F4CC}",relates_to:"\u{1F504}",duplicates:"\u{1F4CB}",parent_of:"\u{1F4C2}",child_of:"\u{1F4C4}",similar_to:"\u{1F50D}"}[e]||"\u{1F517}"}function Jc(e){return ["blocks","blocked_by","depends_on","required_by","parent_of","child_of"].includes(e)}function fh(e,t,a,r,o,s=100){let n=e.map(p=>({...p,x:p.x??a/2+Math.random()*100-50,y:p.y??r/2+Math.random()*100-50,vx:0,vy:0})),c=new Map(n.map(p=>[p.id,p]));for(let p=0;p<s;p++){let i=1-p/s;n.forEach(u=>{let d=a/2,g=r/2;u.vx+=(d-u.x)*o.centerForce*i,u.vy+=(g-u.y)*o.centerForce*i,n.forEach(h=>{if(u.id===h.id)return;let C=u.x-h.x,T=u.y-h.y,m=Math.sqrt(C*C+T*T)||1,b=o.chargeStrength*i/(m*m);u.vx+=C/m*b,u.vy+=T/m*b;});}),t.forEach(u=>{let d=c.get(typeof u.source=="string"?u.source:u.source.id),g=c.get(typeof u.target=="string"?u.target:u.target.id);if(!d||!g)return;let h=g.x-d.x,C=g.y-d.y,T=Math.sqrt(h*h+C*C)||1,m=(T-o.linkDistance)/T*o.forceStrength*i;d.vx+=h*m,d.vy+=C*m,g.vx-=h*m,g.vy-=C*m;}),n.forEach(u=>{u.fx!==null&&u.fx!==void 0?(u.x=u.fx,u.vx=0):u.x+=u.vx,u.fy!==null&&u.fy!==void 0?(u.y=u.fy,u.vy=0):u.y+=u.vy,u.x=Math.max(o.nodeSize,Math.min(a-o.nodeSize,u.x)),u.y=Math.max(o.nodeSize,Math.min(r-o.nodeSize,u.y)),u.vx*=.9,u.vy*=.9;});}return n}function Zc({nodes:e,edges:t,config:a,filter:r,onFilterChange:o,criticalPath:s,stats:n,onInteraction:c,className:p}){let i=useRef(null),[u,d]=useState([]),[g,h]=useState(null),[C,T]=useState(null),[m,b]=useState(null),[y,l]=useState(1),[w,v]=useState({x:0,y:0});useEffect(()=>{if(e.length===0)return;let L=fh(e,t,a.width,a.height,a,150);d(L);},[e,t,a]);let P=useCallback((L,Y)=>{a.enableDragging&&(Y.stopPropagation(),h(L));},[a.enableDragging]),x=useCallback(L=>{if(!g||!i.current)return;let ae=i.current.getBoundingClientRect(),ke=(L.clientX-ae.left-w.x)/y,Pe=(L.clientY-ae.top-w.y)/y;d(Ve=>Ve.map(Je=>Je.id===g?{...Je,x:ke,y:Pe,fx:ke,fy:Pe}:Je));},[g,y,w]),k=useCallback(()=>{h(null);},[]),O=useCallback((L,Y)=>{Y.stopPropagation(),c?.({type:"node-click",node:L,position:{x:Y.clientX,y:Y.clientY}});},[c]),M=useCallback((L,Y)=>{Y.stopPropagation(),c?.({type:"edge-click",edge:L,position:{x:Y.clientX,y:Y.clientY}});},[c]),N=useCallback(L=>{let Y=u.find(ae=>ae.id===L);return Y?{x:Y.x,y:Y.y}:{x:0,y:0}},[u]),H=useCallback(L=>{if(L.onCriticalPath)return "#ef4444";switch(a.colorScheme){case "status":return L.card.columnId==="done"?"#10b981":"#3b82f6";case "priority":let Y=L.card.priority;return Y==="URGENT"?"#ef4444":Y==="HIGH"?"#f59e0b":Y==="MEDIUM"?"#3b82f6":"#6b7280";case "assignee":return L.card.assigneeId?"#8b5cf6":"#6b7280";default:return "#3b82f6"}},[a.colorScheme]);return e.length===0?jsxs("div",{className:f("relationships-graph-empty",p),children:[jsx("div",{className:"relationships-graph-empty-icon",children:"\u{1F517}"}),jsx("p",{className:"relationships-graph-empty-text",children:"No relationships to display"}),jsx("p",{className:"relationships-graph-empty-subtext",children:"Add relationships between cards to see the graph"})]}):jsxs("div",{className:f("relationships-graph",p),children:[jsxs("div",{className:"relationships-graph-controls",children:[jsxs("div",{className:"relationships-graph-stats",children:[jsxs("span",{className:"relationships-graph-stat",children:[jsx("span",{className:"relationships-graph-stat-value",children:n.totalNodes}),jsx("span",{className:"relationships-graph-stat-label",children:"Cards"})]}),jsxs("span",{className:"relationships-graph-stat",children:[jsx("span",{className:"relationships-graph-stat-value",children:n.totalEdges}),jsx("span",{className:"relationships-graph-stat-label",children:"Relations"})]}),s&&jsxs("span",{className:"relationships-graph-stat relationships-graph-stat-critical",children:[jsx("span",{className:"relationships-graph-stat-value",children:s.cardIds.length}),jsx("span",{className:"relationships-graph-stat-label",children:"Critical Path"})]})]}),a.enableZoom&&jsxs("div",{className:"relationships-graph-zoom-controls",children:[jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>l(L=>Math.min(L+.2,3)),children:"+"}),jsxs("span",{className:"relationships-graph-zoom-value",children:[Math.round(y*100),"%"]}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>l(L=>Math.max(L-.2,.5)),children:"\u2212"}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>{l(1),v({x:0,y:0});},children:"Reset"})]})]}),jsx("div",{className:"relationships-graph-legend",children:Array.from(new Set(t.map(L=>L.type))).map(L=>jsxs("div",{className:"relationships-graph-legend-item",children:[jsx("div",{className:"relationships-graph-legend-color",style:{background:zi(L)}}),jsxs("span",{className:"relationships-graph-legend-label",children:[Xc(L)," ",Ui(L)]})]},L))}),jsxs("svg",{ref:i,className:"relationships-graph-canvas",width:a.width,height:a.height,onMouseMove:x,onMouseUp:k,onMouseLeave:k,children:[jsxs("g",{transform:`translate(${w.x}, ${w.y}) scale(${y})`,children:[jsx("g",{className:"relationships-graph-edges",children:t.map(L=>{let Y=N(typeof L.source=="string"?L.source:L.source.id),ae=N(typeof L.target=="string"?L.target:L.target.id),ke=Jc(L.type),Pe=m===L.id,Ve=L.onCriticalPath;return jsxs("g",{className:f("relationships-graph-edge",Pe&&"hovered",Ve&&"critical"),onMouseEnter:()=>b(L.id),onMouseLeave:()=>b(null),onClick:Je=>M(L,Je),children:[jsx("line",{x1:Y.x,y1:Y.y,x2:ae.x,y2:ae.y,stroke:zi(L.type),strokeWidth:Ve?a.edgeWidth*2:a.edgeWidth,strokeOpacity:Pe?1:.6,markerEnd:ke?"url(#arrowhead)":void 0}),a.showEdgeLabels&&Pe&&jsx("text",{x:(Y.x+ae.x)/2,y:(Y.y+ae.y)/2,className:"relationships-graph-edge-label",textAnchor:"middle",children:Ui(L.type)})]},L.id)})}),jsx("g",{className:"relationships-graph-nodes",children:u.map(L=>{let Y=C===L.id,ae=L.onCriticalPath;return jsxs("g",{className:f("relationships-graph-node",Y&&"hovered",ae&&"critical"),transform:`translate(${L.x}, ${L.y})`,onMouseDown:ke=>P(L.id,ke),onMouseEnter:()=>T(L.id),onMouseLeave:()=>T(null),onClick:ke=>O(L,ke),children:[jsx("circle",{r:ae?a.nodeSize*1.2:a.nodeSize,fill:H(L),stroke:ae?"#fbbf24":"#ffffff",strokeWidth:ae?3:2,opacity:Y?1:.9}),a.showLabels&&jsx("text",{y:a.nodeSize+20,className:"relationships-graph-node-label",textAnchor:"middle",children:L.card.title.length>20?L.card.title.substring(0,20)+"...":L.card.title})]},L.id)})})]}),jsx("defs",{children:jsx("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"10",refX:"9",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:jsx("path",{d:"M0,0 L0,6 L9,3 z",fill:"#6b7280"})})})]})]})}function tm({isOpen:e,onClose:t,onPlanGenerated:a,onGeneratePlan:r,isLoading:o}){let[s,n]=useState(""),[c,p]=useState(false),[i,u]=useState(null),[d,g]=useState(null),h=useRef(null),C=c||o;useEffect(()=>{e&&h.current&&h.current.focus();},[e]),useEffect(()=>{let y=l=>{l.key==="Escape"&&!C&&T();};if(e)return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[e,C]);let T=()=>{C||(n(""),u(null),g(null),t());},m=async()=>{if(!(!s.trim()||C)){p(true),u(null),g(null);try{let y=await r(s.trim());g(y);}catch(y){u(y instanceof Error?y.message:"Failed to generate plan");}finally{p(false);}}},b=()=>{d&&(a(d),T());};return e?jsxs(gt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:T}),jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[100001] p-4",children:jsxs("div",{className:"w-full max-w-2xl rounded-2xl shadow-2xl border max-h-[90vh] overflow-hidden flex flex-col",style:{background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},onClick:y=>y.stopPropagation(),children:[jsxs("div",{className:"px-6 py-4 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-xl font-bold text-white flex items-center gap-2",children:[jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-blue-400",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Generate Project Plan with AI"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Describe your project and let AI create a complete Kanban board"})]}),jsx("button",{onClick:T,disabled:C,className:"text-white/60 hover:text-white transition-colors disabled:opacity-50",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:d?jsx(Fragment,{children:jsxs("div",{className:"space-y-4",children:[jsxs("div",{className:"flex items-center gap-2 text-green-400",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:jsx("path",{d:"M4 10L8 14L16 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"font-semibold",children:"Plan Generated Successfully!"})]}),d.explanation&&jsx("div",{className:"p-4 rounded-lg bg-blue-500/10 border border-blue-500/30",children:jsx("p",{className:"text-sm text-white/90",children:d.explanation})}),jsxs("div",{children:[jsxs("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:["Columns (",d.columns.length,")"]}),jsx("div",{className:"flex gap-2 flex-wrap",children:d.columns.map((y,l)=>jsx("div",{className:"px-3 py-1.5 rounded-lg bg-white/5 border border-white/20 text-sm text-white/80",children:y.title},l))})]}),jsxs("div",{children:[jsxs("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:["Tasks (",d.cards.length,")"]}),jsxs("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:[d.cards.slice(0,10).map((y,l)=>jsx("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10",children:jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex-1",children:[jsx("p",{className:"text-sm font-medium text-white/90",children:y.title}),y.description&&jsx("p",{className:"text-xs text-white/60 mt-1 line-clamp-2",children:y.description})]}),y.priority&&jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${y.priority==="URGENT"?"bg-red-500/20 text-red-400":y.priority==="HIGH"?"bg-orange-500/20 text-orange-400":y.priority==="MEDIUM"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:y.priority})]})},l)),d.cards.length>10&&jsxs("p",{className:"text-xs text-white/50 text-center py-2",children:["+",d.cards.length-10," more tasks..."]})]})]})]})}):jsxs(Fragment,{children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"Project Description"}),jsx("textarea",{ref:h,value:s,onChange:y=>n(y.target.value),placeholder:"Example: Build a mobile app for tracking fitness goals with user authentication, workout logging, progress charts, and social features...",className:"w-full h-32 px-4 py-3 rounded-lg text-sm bg-white/5 border border-white/20 text-white placeholder-white/40 outline-none focus:border-blue-500/50 transition-all resize-none",disabled:C}),jsx("p",{className:"text-xs text-white/50 mt-2",children:"Be as specific as possible. Include features, technologies, and any special requirements."})]}),i&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:i}),jsxs("div",{className:"border-t border-white/10 pt-4",children:[jsx("p",{className:"text-xs font-semibold text-white/70 uppercase tracking-wider mb-3",children:"Example Prompts"}),jsx("div",{className:"space-y-2",children:["Build an e-commerce platform with product catalog, shopping cart, payment integration, and order tracking","Create a task management app with team collaboration, real-time updates, file attachments, and notifications","Develop a blog platform with markdown editor, SEO optimization, comments system, and analytics dashboard"].map((y,l)=>jsx("button",{onClick:()=>n(y),disabled:C,className:"w-full text-left px-3 py-2 rounded-lg text-xs text-white/70 hover:text-white hover:bg-white/5 transition-all border border-white/10 hover:border-white/20 disabled:opacity-50",children:y},l))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:C&&jsxs("div",{className:"flex items-center gap-2 text-blue-400 text-sm",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),jsx("span",{children:"Generating with AI..."})]})}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("button",{onClick:T,disabled:C,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-all hover:bg-white/10 text-white/80 disabled:opacity-50",children:"Cancel"}),d?jsx("button",{onClick:b,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all",style:{background:"linear-gradient(135deg, #10B981 0%, #059669 100%)",color:"#ffffff"},children:"Apply Plan to Board"}):jsx("button",{onClick:m,disabled:!s.trim()||C,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all disabled:opacity-50",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#ffffff"},children:C?"Generating...":"Generate Plan"})]})]})]})})]}):null}var $i={"gpt-4-turbo":{provider:"openai",name:"GPT-4 Turbo",contextWindow:128e3,costPer1kInput:.01,costPer1kOutput:.03,supportsVision:true,supportsJSON:true},"gpt-4":{provider:"openai",name:"GPT-4",contextWindow:8192,costPer1kInput:.03,costPer1kOutput:.06,supportsVision:false,supportsJSON:true},"gpt-3.5-turbo":{provider:"openai",name:"GPT-3.5 Turbo",contextWindow:16385,costPer1kInput:5e-4,costPer1kOutput:.0015,supportsVision:false,supportsJSON:true},"claude-3-5-sonnet-20241022":{provider:"anthropic",name:"Claude 3.5 Sonnet",contextWindow:2e5,costPer1kInput:.003,costPer1kOutput:.015,supportsVision:true,supportsJSON:true},"claude-3-opus-20240229":{provider:"anthropic",name:"Claude 3 Opus",contextWindow:2e5,costPer1kInput:.015,costPer1kOutput:.075,supportsVision:true,supportsJSON:true},"claude-3-haiku-20240307":{provider:"anthropic",name:"Claude 3 Haiku",contextWindow:2e5,costPer1kInput:25e-5,costPer1kOutput:.00125,supportsVision:true,supportsJSON:true}};var bh={hobby:{requestsPerMonth:50,maxConcurrent:1,maxTokensPerRequest:4096},pro:{requestsPerMonth:500,maxConcurrent:3,maxTokensPerRequest:8192},enterprise:{requestsPerMonth:2e3,maxConcurrent:10,maxTokensPerRequest:16384}},yh={generatePlan:{enabled:true,minPlanTier:"hobby",estimatedTokens:2e3},predictRisks:{enabled:true,minPlanTier:"pro",estimatedTokens:1500},suggestAssignee:{enabled:true,minPlanTier:"hobby",estimatedTokens:800},generateReport:{enabled:true,minPlanTier:"enterprise",estimatedTokens:3e3},generateSubtasks:{enabled:true,minPlanTier:"hobby",estimatedTokens:1e3}};function vh(e,t,a){let r=$i[e];if(!r)throw new Error(`Unknown model: ${e}`);let o=t/1e3*r.costPer1kInput,s=a/1e3*r.costPer1kOutput;return o+s}function jo(e){return `$${e.toFixed(4)}`}var Hi=class{constructor(){this.operations=[];this.listeners=[];}record(t){let a=vh(t.model,t.inputTokens,t.outputTokens),r={...t,id:`op_${Date.now()}_${Math.random().toString(36).substring(7)}`,timestamp:new Date,cost:a};return this.operations.push(r),this.listeners.forEach(o=>o(r)),this.operations.length>1e3&&(this.operations=this.operations.slice(-1e3)),r}getStats(t){let a=this.operations;t&&(a=a.filter(d=>d.timestamp>=t.start&&d.timestamp<=t.end));let r=a.length,o=a.reduce((d,g)=>d+g.cost,0),s=a.reduce((d,g)=>d+g.inputTokens,0),n=a.reduce((d,g)=>d+g.outputTokens,0),c=a.filter(d=>d.success),p=a.reduce((d,g)=>d+g.duration,0),i={},u={};return a.forEach(d=>{i[d.feature]=(i[d.feature]||0)+1,u[d.feature]=(u[d.feature]||0)+d.cost;}),{totalOperations:r,totalCost:o,totalInputTokens:s,totalOutputTokens:n,operationsByFeature:i,costsByFeature:u,averageDuration:r>0?p/r:0,successRate:r>0?c.length/r:0}}getRecentOperations(t=10){return this.operations.slice(-t).reverse()}checkLimit(t,a="month"){let o={hobby:{month:50,day:5},pro:{month:500,day:50},enterprise:{month:2e3,day:200}}[t][a],s=new Date,n=new Date;a==="month"?n.setMonth(s.getMonth()-1):n.setDate(s.getDate()-1);let c=this.operations.filter(u=>u.timestamp>=n).length,p=Math.max(0,o-c),i=c/o*100;return {used:c,limit:o,remaining:p,percentUsed:i,isExceeded:c>=o}}subscribe(t){return this.listeners.push(t),()=>{let a=this.listeners.indexOf(t);a>-1&&this.listeners.splice(a,1);}}clear(){this.operations=[];}export(){return JSON.stringify(this.operations,null,2)}},Zr=new Hi;function om({isOpen:e,onClose:t,planTier:a="hobby"}){let[r,o]=useState(Zr.getStats()),[s,n]=useState(Zr.checkLimit(a));if(useEffect(()=>{if(!e)return;let p=setInterval(()=>{o(Zr.getStats()),n(Zr.checkLimit(a));},1e3);return ()=>clearInterval(p)},[e,a]),useEffect(()=>{let p=i=>{i.key==="Escape"&&t();};if(e)return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[e,t]),!e)return null;let c=Zr.getRecentOperations(5);return jsxs(gt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:t}),jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[100001] p-4",children:jsxs("div",{className:"w-full max-w-3xl rounded-2xl shadow-2xl border max-h-[90vh] overflow-hidden flex flex-col",style:{background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},onClick:p=>p.stopPropagation(),children:[jsxs("div",{className:"px-6 py-4 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsx("h2",{className:"text-xl font-bold text-white",children:"AI Usage Dashboard"}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Monitor your AI consumption and costs"})]}),jsx("button",{onClick:t,className:"text-white/60 hover:text-white transition-colors",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[jsxs("div",{className:"p-4 rounded-xl bg-gradient-to-r from-blue-500/10 to-purple-500/10 border border-blue-500/30",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxs("span",{className:"text-sm font-semibold text-white/90",children:["Monthly Usage (",a.toUpperCase(),")"]}),jsxs("span",{className:"text-sm font-bold text-white",children:[s.used," / ",s.limit]})]}),jsx("div",{className:"w-full h-2 bg-white/10 rounded-full overflow-hidden",children:jsx("div",{className:"h-full transition-all",style:{width:`${Math.min(100,s.percentUsed)}%`,background:s.percentUsed>90?"#EF4444":s.percentUsed>70?"#F59E0B":"#10B981"}})}),jsxs("p",{className:"text-xs text-white/60 mt-2",children:[s.remaining," operations remaining this month"]})]}),jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Total Cost"}),jsx("p",{className:"text-2xl font-bold text-green-400 mt-1",children:jo(r.totalCost)})]}),jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Operations"}),jsx("p",{className:"text-2xl font-bold text-blue-400 mt-1",children:r.totalOperations})]}),jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Tokens Used"}),jsx("p",{className:"text-2xl font-bold text-purple-400 mt-1",children:(r.totalInputTokens+r.totalOutputTokens).toLocaleString()}),jsxs("p",{className:"text-xs text-white/50 mt-1",children:[r.totalInputTokens.toLocaleString()," in /"," ",r.totalOutputTokens.toLocaleString()," out"]})]}),jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Success Rate"}),jsxs("p",{className:"text-2xl font-bold text-green-400 mt-1",children:[(r.successRate*100).toFixed(1),"%"]}),jsxs("p",{className:"text-xs text-white/50 mt-1",children:["Avg: ",r.averageDuration.toFixed(0),"ms"]})]})]}),jsxs("div",{children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-3",children:"Usage by Feature"}),jsx("div",{className:"space-y-2",children:Object.entries(r.operationsByFeature).map(([p,i])=>{let u=r.costsByFeature[p]||0,d=r.totalOperations>0?i/r.totalOperations*100:0;return jsxs("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("span",{className:"text-sm font-medium text-white/90 capitalize",children:p.replace(/([A-Z])/g," $1").trim()}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-white/60",children:[i," ops"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:jo(u)})]})]}),jsx("div",{className:"w-full h-1.5 bg-white/10 rounded-full overflow-hidden",children:jsx("div",{className:"h-full bg-blue-500",style:{width:`${d}%`}})})]},p)})})]}),jsxs("div",{children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-3",children:"Recent Operations"}),c.length===0?jsx("p",{className:"text-sm text-white/50 text-center py-8",children:"No operations yet. Start using AI features!"}):jsx("div",{className:"space-y-2",children:c.map(p=>jsxs("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsx("p",{className:"text-sm font-medium text-white/90 capitalize",children:p.feature.replace(/([A-Z])/g," $1").trim()}),jsxs("p",{className:"text-xs text-white/50 mt-0.5",children:[new Date(p.timestamp).toLocaleTimeString()," \u2022"," ",p.duration,"ms"]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-white/60",children:[p.inputTokens+p.outputTokens," tokens"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:jo(p.cost)}),jsx("div",{className:`w-2 h-2 rounded-full ${p.success?"bg-green-400":"bg-red-400"}`})]})]},p.id))})]})]}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("p",{className:"text-xs text-white/50",children:"Costs are estimates. Actual API charges may vary."}),jsx("button",{onClick:t,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-all hover:bg-white/10 text-white/80",children:"Close"})]})]})})]})}function im({isOpen:e,onClose:t,onTasksGenerated:a,onGenerateTasks:r,isLoading:o,projectName:s}){let[n,c]=useState(""),[p,i]=useState(""),[u,d]=useState(""),[g,h]=useState(false),[C,T]=useState(null),[m,b]=useState(null),[y,l]=useState(null),w=useRef(null),v=g||o;useEffect(()=>{e&&w.current&&w.current.focus();},[e]),useEffect(()=>{let M=N=>{N.key==="Escape"&&!v&&P();};if(e)return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[e,v]);let P=()=>{v||(c(""),i(""),d(""),T(null),b(null),l(null),t());},x=async()=>{if(!(!n.trim()||v)){h(true),T(null),b(null),l(null);try{let M=await r({prompt:n.trim(),projectName:s||"Mi Proyecto",startDate:p||void 0,endDate:u||void 0});b(M.tasks.tasks),l({from_cache:M.from_cache,tokens_used:M.tokens_used,mock_mode:M.mock_mode,similarity:M.similarity,tokens_saved:M.tokens_saved});}catch(M){T(M instanceof Error?M.message:"Failed to generate tasks");}finally{h(false);}}},k=()=>{m&&(a(m),P());};if(!e)return null;let O=y?.similarity?((y.similarity||0)*100).toFixed(0):"0";return jsxs(gt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:P}),jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[100001] p-4",children:jsxs("div",{className:"w-full max-w-3xl rounded-2xl shadow-2xl border max-h-[90vh] overflow-hidden flex flex-col",style:{background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},onClick:M=>M.stopPropagation(),children:[jsxs("div",{className:"px-6 py-4 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-xl font-bold text-white flex items-center gap-2",children:[jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-blue-400",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"2",rx:"1",fill:"currentColor"}),jsx("rect",{x:"3",y:"9",width:"18",height:"2",rx:"1",fill:"currentColor"}),jsx("rect",{x:"3",y:"14",width:"18",height:"2",rx:"1",fill:"currentColor"}),jsx("rect",{x:"3",y:"19",width:"18",height:"2",rx:"1",fill:"currentColor"})]}),"Generate Gantt Tasks with AI"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Describe your project and let AI create a complete task timeline"})]}),jsx("button",{onClick:P,disabled:v,className:"text-white/60 hover:text-white transition-colors disabled:opacity-50",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:m?jsx(Fragment,{children:jsxs("div",{className:"space-y-4",children:[jsxs("div",{className:"flex items-center gap-2 text-green-400",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:jsx("path",{d:"M4 10L8 14L16 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"font-semibold",children:"Tasks Generated Successfully!"})]}),jsxs("div",{className:"flex flex-wrap gap-2",children:[y?.mock_mode&&jsx("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-yellow-500/20 text-yellow-400 border border-yellow-500/30",children:"Mock Mode"}),y?.from_cache?jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-blue-500/20 text-blue-400 border border-blue-500/30",children:["From Cache (",O,"% similar)"]}):jsx("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-green-500/20 text-green-400 border border-green-500/30",children:"AI Generated"}),jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-purple-500/20 text-purple-400 border border-purple-500/30",children:[y?.tokens_used||0," tokens"]}),y?.tokens_saved&&jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-indigo-500/20 text-indigo-400 border border-indigo-500/30",children:[y.tokens_saved," tokens saved"]}),jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-pink-500/20 text-pink-400 border border-pink-500/30",children:[m.length," tasks"]})]}),jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:m.map((M,N)=>jsx("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10 hover:bg-white/10 transition-colors",children:jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex-1",children:[jsxs("div",{className:"flex items-center gap-2 mb-1",children:[jsxs("span",{className:"text-xs text-white/50",children:["#",N+1]}),jsx("p",{className:"text-sm font-medium text-white/90",children:M.name})]}),jsxs("div",{className:"flex items-center gap-3 text-xs text-white/60",children:[jsxs("span",{className:"flex items-center gap-1",children:[jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"text-white/40",children:[jsx("rect",{x:"1",y:"2",width:"10",height:"8",rx:"1",stroke:"currentColor"}),jsx("path",{d:"M1 4h10",stroke:"currentColor"})]}),M.start," \u2192 ",M.end]}),jsxs("span",{children:[M.duration," days"]}),M.dependencies.length>0&&jsxs("span",{className:"text-blue-400",children:["Depends: ",M.dependencies.join(", ")]})]})]}),jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${M.priority==="high"?"bg-red-500/20 text-red-400":M.priority==="medium"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:M.priority})]})},M.id))})]})}):jsxs(Fragment,{children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"Project Description *"}),jsx("textarea",{ref:w,value:n,onChange:M=>c(M.target.value),placeholder:"Example: Build a mobile app for tracking fitness goals with user authentication, workout logging, progress charts, and social features...",className:"w-full h-32 px-4 py-3 rounded-lg text-sm bg-white/5 border border-white/20 text-white placeholder-white/40 outline-none focus:border-blue-500/50 transition-all resize-none",disabled:v}),jsx("p",{className:"text-xs text-white/50 mt-2",children:"Be as specific as possible. Include features, technologies, and any special requirements."})]}),jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"Start Date (Optional)"}),jsx("input",{type:"date",value:p,onChange:M=>i(M.target.value),className:"w-full px-4 py-2 rounded-lg text-sm bg-white/5 border border-white/20 text-white outline-none focus:border-blue-500/50 transition-all",disabled:v})]}),jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"End Date (Optional)"}),jsx("input",{type:"date",value:u,onChange:M=>d(M.target.value),className:"w-full px-4 py-2 rounded-lg text-sm bg-white/5 border border-white/20 text-white outline-none focus:border-blue-500/50 transition-all",disabled:v})]})]}),C&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:C}),jsxs("div",{className:"border-t border-white/10 pt-4",children:[jsx("p",{className:"text-xs font-semibold text-white/70 uppercase tracking-wider mb-3",children:"Example Prompts"}),jsx("div",{className:"space-y-2",children:["Build an e-commerce platform with product catalog, shopping cart, payment integration, and order tracking","Create a task management app with team collaboration, real-time updates, file attachments, and notifications","Develop a blog platform with markdown editor, SEO optimization, comments system, and analytics dashboard"].map((M,N)=>jsx("button",{onClick:()=>c(M),disabled:v,className:"w-full text-left px-3 py-2 rounded-lg text-xs text-white/70 hover:text-white hover:bg-white/5 transition-all border border-white/10 hover:border-white/20 disabled:opacity-50",children:M},N))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:v&&jsxs("div",{className:"flex items-center gap-2 text-blue-400 text-sm",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),jsx("span",{children:"Generating with AI..."})]})}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("button",{onClick:P,disabled:v,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-all hover:bg-white/10 text-white/80 disabled:opacity-50",children:"Cancel"}),m?jsx("button",{onClick:k,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all",style:{background:"linear-gradient(135deg, #10B981 0%, #059669 100%)",color:"#ffffff"},children:"Apply Tasks to Gantt"}):jsx("button",{onClick:x,disabled:!n.trim()||v,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all disabled:opacity-50",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#ffffff"},children:v?"Generating...":"Generate Tasks"})]})]})]})})]})}function jn({initialBoard:e,onPersist:t}){let[a,r]=useState(e),o=useCallback(m=>{t&&tn(()=>Promise.resolve(t(m)),{maxAttempts:3,initialDelay:1e3,onRetry:(b,y,l)=>{console.warn(`Retry attempt ${y} after ${l}ms: ${b.message}`);}}).then(b=>{b.success||console.error(`Failed to persist board after ${b.attempts} attempts:`,b.error);});},[t]),s=useCallback(async(m,b,y)=>{r(l=>{let w=l.cards.find(M=>M.id===m);if(!w)return l;let v=w.columnId,P={...w,columnId:b,position:y},x=l.cards.map(M=>M.id===m?P:M),k=l.columns.map(M=>{if(M.id===v)return {...M,cardIds:M.cardIds.filter(N=>N!==m)};if(M.id===b){let N=x.filter(H=>H.columnId===b).sort((H,L)=>H.position-L.position);return {...M,cardIds:N.map(H=>H.id)}}return M}),O={...l,cards:x,columns:k};return o(O),O});},[o]),n=useCallback(async(m,b)=>{r(y=>{let l=y.cards.map(v=>v.id===m?{...v,...b}:v),w={...y,cards:l};return o(w),w});},[o]),c=useCallback(async m=>{let b=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(y=>{let l={...m,id:b},w=y.columns.map(P=>P.id===m.columnId?{...P,cardIds:[...P.cardIds,b]}:P),v={...y,cards:[...y.cards,l],columns:w};return o(v),v});},[o]),p=useCallback(async m=>{r(b=>{let y=b.cards.find(P=>P.id===m);if(!y)return b;let l=b.cards.filter(P=>P.id!==m),w=b.columns.map(P=>P.id===y.columnId?{...P,cardIds:P.cardIds.filter(x=>x!==m)}:P),v={...b,cards:l,columns:w};return o(v),v});},[o]),i=useCallback(async m=>{let b=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(y=>{let l={...m,id:b,cardIds:[]},w={...y,columns:[...y.columns,l]};return o(w),w});},[o]),u=useCallback(async(m,b)=>{r(y=>{let l=y.columns.map(v=>v.id===m?{...v,...b}:v),w={...y,columns:l};return o(w),w});},[o]),d=useCallback(async m=>{r(b=>{let y=b.cards.filter(v=>v.columnId!==m),l=b.columns.filter(v=>v.id!==m),w={...b,cards:y,columns:l};return o(w),w});},[o]),g=useCallback(m=>{let b=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return c(m),b},[c]),h=useCallback(m=>{let b=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return i(m),b},[i]),C=useCallback(()=>{r(m=>{let b={...m,cards:[],columns:[]};return o(b),b});},[o]);return {board:a,callbacks:{onCardMove:s,onCardUpdate:n,onCardCreate:c,onCardDelete:p,onColumnCreate:i,onColumnUpdate:u,onColumnDelete:d},setBoard:r,helpers:{addCard:g,addColumn:h,deleteCard:p,deleteColumn:d,clearBoard:C}}}function dm({initialData:e,availableUsers:t=[],onSave:a}){let{board:r,callbacks:o,helpers:s}=jn({initialBoard:e,onPersist:a}),n=useMemo(()=>({addCard:(p,i,u={})=>{s.addCard({title:i,columnId:p,position:r.cards.filter(d=>d.columnId===p).length,...u});},addColumn:(p,i)=>{let u=r.columns.length>0?Math.max(...r.columns.map(d=>d.position)):0;s.addColumn({title:p,position:i??u+1e3});},reset:s.clearBoard}),[r.cards,r.columns,s]);return {props:useMemo(()=>({board:r,callbacks:o,availableUsers:t}),[r,o,t]),board:r,callbacks:o,utils:n}}var Ko={dateFilter:"all",priorities:[],assignees:[],labels:[],columns:[],search:""},mm={by:"none",order:"asc"};function pm({initialFilters:e={},initialSort:t={},currentUserId:a}={}){let[r,o]=useState({...Ko,...e}),[s,n]=useState({...mm,...t}),c=useCallback(T=>{o(m=>({...m,...T}));},[]),p=useCallback(T=>{n(m=>({...m,...T}));},[]),i=useCallback(()=>{o(Ko),n(mm);},[]),u=useCallback(()=>{a&&o({...Ko,assignees:[a]});},[a]),d=useCallback(()=>{o({...Ko,dateFilter:"overdue"});},[]),g=useCallback(()=>{o({...Ko,priorities:["HIGH","URGENT"]});},[]),h=useMemo(()=>r.dateFilter!=="all"||r.priorities.length>0||r.assignees.length>0||r.labels.length>0||r.columns.length>0||r.search!==""||s.by!=="none",[r,s]),C=useCallback(T=>{let m=[...T];if(r.search){let b=r.search.toLowerCase();m=m.filter(y=>y.title.toLowerCase().includes(b)||y.description?.toLowerCase().includes(b));}if(r.dateFilter!=="all"){let b=new Date,y=b.getFullYear(),l=String(b.getMonth()+1).padStart(2,"0"),w=String(b.getDate()).padStart(2,"0"),v=`${y}-${l}-${w}`;m=m.filter(P=>{if(!P.endDate&&!P.dueDate)return false;let x=P.endDate||P.dueDate;if(!x)return false;let k;if(typeof x=="string")k=x.split("T")[0]||x;else {let O=x.getUTCFullYear(),M=String(x.getUTCMonth()+1).padStart(2,"0"),N=String(x.getUTCDate()).padStart(2,"0");k=`${O}-${M}-${N}`;}switch(r.dateFilter){case "overdue":return k<v;case "today":return k===v;case "this-week":let O=new Date(v+"T00:00:00"),M=new Date(k+"T00:00:00"),N=new Date(O);return N.setDate(N.getDate()+7),M>=O&&M<=N;case "custom":if(r.dateRange){let H=typeof x=="string"?new Date(x):x;return H>=r.dateRange.start&&H<=r.dateRange.end}return true;default:return true}});}return r.priorities.length>0&&(m=m.filter(b=>b.priority&&r.priorities.includes(b.priority))),r.assignees.length>0&&(m=m.filter(b=>(b.assignedUserIds||(b.assigneeId?[b.assigneeId]:[])).some(l=>r.assignees.includes(l)))),r.labels.length>0&&(m=m.filter(b=>b.labels&&b.labels.some(y=>r.labels.includes(y)))),r.columns.length>0&&(m=m.filter(b=>r.columns.includes(b.columnId))),s.by!=="none"&&m.sort((b,y)=>{let l=0;switch(s.by){case "created":let w=b.createdAt?new Date(b.createdAt).getTime():0,v=y.createdAt?new Date(y.createdAt).getTime():0;l=w-v;break;case "priority":let P={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},x=P[b.priority||"LOW"],k=P[y.priority||"LOW"];l=x-k;break;case "dueDate":let O=b.endDate||b.dueDate,M=y.endDate||y.dueDate;if(!O)return 1;if(!M)return -1;let N=typeof O=="string"?new Date(O).getTime():O.getTime(),H=typeof M=="string"?new Date(M).getTime():M.getTime();l=N-H;break;case "title":l=b.title.localeCompare(y.title);break;case "estimate":let L=b.estimatedTime||0,Y=y.estimatedTime||0;l=L-Y;break;default:l=0;}return s.order==="asc"?l:-l}),m},[r,s]);return {filters:r,sort:s,setFilters:c,setSort:p,resetFilters:i,filterMyTasks:u,filterOverdue:d,filterHighPriority:g,applyFilters:C,hasActiveFilters:h}}var gm,fm;if(typeof window<"u")try{let e=Zo("ai");gm=e.generateObject,fm=e.generateText;}catch{}function hm(e={}){let[t,a]=useState(false),[r,o]=useState(null),s=!!(gm&&fm&&e.apiKey),n=useCallback(async d=>{if(!s)throw new Error('AI features require the "ai" package and an API key. Install with: npm install ai');a(true),o(null);try{return console.log("Generating plan for:",d),{columns:[{title:"To Do",position:1e3,cardIds:[]},{title:"In Progress",position:2e3,cardIds:[]},{title:"Done",position:3e3,cardIds:[]}],cards:[{title:"Generated task from AI",description:`Based on: ${d}`,position:1e3,columnId:"temp-col-1"}],explanation:"This is a sample plan. Real implementation would use AI SDK."}}catch(g){let h=g instanceof Error?g:new Error("Failed to generate plan");throw o(h),h}finally{a(false);}},[s]),c=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Suggesting assignee for:",d.title),{userId:"user-123",confidence:.85,reasoning:"Based on past performance and expertise"}}catch(g){let h=g instanceof Error?g:new Error("Failed to suggest assignee");throw o(h),h}finally{a(false);}},[s]),p=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Analyzing board for risks..."),[{type:"RISK_OVERLOAD",severity:"HIGH",title:"Column overload detected",description:'Too many cards in "In Progress"',confidence:.9,suggestedAction:'Consider moving some cards back to "To Do"'}]}catch(g){let h=g instanceof Error?g:new Error("Failed to predict risks");throw o(h),h}finally{a(false);}},[s]),i=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Generating subtasks for:",d.title),[{title:`Subtask 1 for: ${d.title}`,position:d.position+.1,columnId:d.columnId},{title:`Subtask 2 for: ${d.title}`,position:d.position+.2,columnId:d.columnId}]}catch(g){let h=g instanceof Error?g:new Error("Failed to generate subtasks");throw o(h),h}finally{a(false);}},[s]),u=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Estimating effort for:",d.title),{hours:8,confidence:.75}}catch(g){let h=g instanceof Error?g:new Error("Failed to estimate effort");throw o(h),h}finally{a(false);}},[s]);return {onGeneratePlan:n,onSuggestAssignee:c,onPredictRisks:p,onGenerateSubtasks:i,onEstimateEffort:u,isAvailable:s,isLoading:t,error:r}}function Gi(){let[e,t]=useState(()=>selectionStore.getState());useEffect(()=>selectionStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{selectionStore.setState(r);},[]);return [e,a]}function bm(e){let{cards:t}=e,[a,r]=Gi(),o=useCallback(d=>a.selectedCardIds.includes(d),[a.selectedCardIds]),s=useCallback((d,g)=>{if(!g){r({selectedCardIds:[d],lastSelectedCardId:d});return}let h=g.ctrlKey||g.metaKey,C=g.shiftKey;if(h)a.selectedCardIds.includes(d)?r({selectedCardIds:a.selectedCardIds.filter(T=>T!==d),lastSelectedCardId:a.lastSelectedCardId}):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});else if(C&&a.lastSelectedCardId){let T=t.find(b=>b.id===d),m=t.find(b=>b.id===a.lastSelectedCardId);if(T&&m&&T.columnId===m.columnId){let b=t.filter(k=>k.columnId===T.columnId).sort((k,O)=>k.position-O.position),y=b.findIndex(k=>k.id===a.lastSelectedCardId),l=b.findIndex(k=>k.id===d),[w,v]=y<l?[y,l]:[l,y],P=b.slice(w,v+1).map(k=>k.id),x=Array.from(new Set([...a.selectedCardIds,...P]));r({selectedCardIds:x,lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});},[t,a,r]),n=useCallback(d=>{r({selectedCardIds:a.selectedCardIds.filter(g=>g!==d),lastSelectedCardId:a.lastSelectedCardId});},[a,r]),c=useCallback(()=>{r({selectedCardIds:[],lastSelectedCardId:null});},[r]),p=useCallback(()=>{r({selectedCardIds:t.map(d=>d.id),lastSelectedCardId:t[t.length-1]?.id||null});},[t,r]),i=useCallback(d=>{a.selectedCardIds.includes(d)?n(d):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});},[a,n,r]),u=useCallback(()=>t.filter(d=>a.selectedCardIds.includes(d.id)),[t,a.selectedCardIds]);return {selectedCardIds:a.selectedCardIds,lastSelectedCardId:a.lastSelectedCardId,isCardSelected:o,selectCard:s,deselectCard:n,clearSelection:c,selectAll:p,toggleCard:i,getSelectedCards:u}}var ym={enableAutoStacking:true,autoStackConfidenceThreshold:.7,minCardsPerStack:2,enableManualStacking:true,showStackSummaries:true,animationDuration:200};function vm(e){let{cards:t,config:a,aiService:r}=e,o=useMemo(()=>({...ym,...a}),[a]),[s,n]=useState([]),c=useCallback((T,m,b,y,l)=>{if(m.length<o.minCardsPerStack){console.warn(`Cannot create stack: minimum ${o.minCardsPerStack} cards required`);return}let w={id:`stack-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:T,cardIds:m,columnId:b,strategy:y,color:l,isExpanded:true,position:s.filter(v=>v.columnId===b).length,createdAt:new Date};n(v=>[...v,w]);},[o.minCardsPerStack,s]),p=useCallback(T=>{n(m=>m.filter(b=>b.id!==T));},[]),i=useCallback(T=>{n(m=>m.map(b=>b.id===T?{...b,isExpanded:!b.isExpanded}:b));},[]),u=useCallback((T,m)=>{n(b=>b.map(y=>y.id===T&&!y.cardIds.includes(m)?{...y,cardIds:[...y.cardIds,m]}:y));},[]),d=useCallback((T,m)=>{n(b=>b.map(y=>{if(y.id===T){let l=y.cardIds.filter(w=>w!==m);return l.length<o.minCardsPerStack?null:{...y,cardIds:l}}return y}).filter(y=>y!==null));},[o.minCardsPerStack]),g=useCallback(T=>s.filter(m=>m.columnId===T).sort((m,b)=>m.position-b.position),[s]),h=useCallback(async T=>{let m=t.filter(v=>v.columnId===T);if(m.length<o.minCardsPerStack*2)return [];let b=[],y=new Map;m.forEach(v=>{v.labels&&v.labels.length>0&&v.labels.forEach(P=>{y.has(P)||y.set(P,[]),y.get(P).push(v);});}),y.forEach((v,P)=>{v.length>=o.minCardsPerStack&&b.push({stack:{title:`\u{1F4CC} ${P}`,cardIds:v.map(x=>x.id),columnId:T,strategy:"labels",color:"#3b82f6"},reason:`${v.length} cards with label "${P}"`,confidence:.85});});let l=new Map;m.forEach(v=>{v.assignedUserIds&&v.assignedUserIds.length>0&&v.assignedUserIds.forEach(P=>{l.has(P)||l.set(P,[]),l.get(P).push(v);});}),l.forEach((v,P)=>{v.length>=o.minCardsPerStack&&b.push({stack:{title:`\u{1F464} Assigned to user-${P.slice(-4)}`,cardIds:v.map(x=>x.id),columnId:T,strategy:"assignee",color:"#8b5cf6"},reason:`${v.length} cards assigned to the same user`,confidence:.8});});let w=new Map;if(m.forEach(v=>{v.priority&&(w.has(v.priority)||w.set(v.priority,[]),w.get(v.priority).push(v));}),w.forEach((v,P)=>{if(v.length>=o.minCardsPerStack){let x={low:"\u{1F7E2}",medium:"\u{1F7E1}",high:"\u{1F534}",urgent:"\u{1F6A8}"}[P.toLowerCase()]||"\u26AA";b.push({stack:{title:`${x} ${P} Priority`,cardIds:v.map(k=>k.id),columnId:T,strategy:"priority",color:P==="high"||P==="urgent"?"#ef4444":"#10b981"},reason:`${v.length} cards with ${P} priority`,confidence:.75});}}),r&&o.enableAutoStacking)for(let v of m){let x=(await r.findSimilar(v,m)).filter(k=>k.similarity>=o.autoStackConfidenceThreshold);if(x.length>=o.minCardsPerStack-1){let k=[v.id,...x.map(M=>M.card.id)],O=x.reduce((M,N)=>M+N.similarity,0)/x.length;b.push({stack:{title:`\u2728 Similar to "${v.title.substring(0,30)}${v.title.length>30?"...":""}"`,cardIds:k,columnId:T,strategy:"ai-similarity",color:"#f59e0b"},reason:`AI detected ${x.length+1} similar tasks`,confidence:O});}}return b.filter(v=>v.confidence>=o.autoStackConfidenceThreshold).sort((v,P)=>P.confidence-v.confidence).slice(0,5)},[t,o,r]),C=useCallback(T=>{c(T.stack.title,T.stack.cardIds,T.stack.columnId,T.stack.strategy,T.stack.color);},[c]);return useEffect(()=>{o.enableAutoStacking&&s.length===0&&new Set(t.map(m=>m.columnId)).forEach(async m=>{let b=await h(m),y=b[0];b.length>0&&y&&y.confidence>=.9&&C(y);});},[]),{stacks:s,createStack:c,deleteStack:p,toggleStack:i,addToStack:u,removeFromStack:d,getStacksForColumn:g,getSuggestions:h,applySuggestion:C,config:o}}var xm=createContext(null);function km({children:e,initialData:t,onStateChange:a}){let r=useRef();if(!r.current){let s=new Map,n=new Map;t?.columns?.forEach(p=>{let{Column:i}=Zo("@libxai/core");s.set(p.id,new i(p));}),t?.cards?.forEach(p=>{let{Card:i}=Zo("@libxai/core");n.set(p.id,new i(p));});let c=null;if(t?.board){let{Board:p}=Zo("@libxai/core");c=new p(t.board);}r.current=new BoardStore({board:c,columns:s,cards:n});}let o=r.current;return useEffect(()=>{if(a)return o.subscribeAll(s=>{a(o.getState());})},[o,a]),jsx(xm.Provider,{value:{store:o},children:e})}function Kn(){let e=useContext(xm);if(!e)throw new Error("useBoardStore must be used within BoardProvider");return e.store}function qo(){let e=Kn(),[t,a]=useState(e.getBoard()),[r,o]=useState(e.getAllColumns()),[s,n]=useState(e.getAllCards());useEffect(()=>e.subscribeAll(()=>{a(e.getBoard()),o(e.getAllColumns()),n(e.getAllCards());}),[e]);let c=useCallback(y=>{e.updateBoard(y);},[e]),p=useCallback(y=>{e.addColumn(y);},[e]),i=useCallback((y,l)=>{e.updateColumn(y,l);},[e]),u=useCallback(y=>{e.deleteColumn(y);},[e]),d=useCallback(y=>e.getColumn(y),[e]),g=useCallback(y=>{e.addCard(y);},[e]),h=useCallback((y,l)=>{e.updateCard(y,l);},[e]),C=useCallback(y=>{e.deleteCard(y);},[e]),T=useCallback((y,l,w)=>{e.moveCard(y,l,w);},[e]),m=useCallback(y=>e.getCard(y),[e]),b=useCallback(y=>e.getCardsByColumn(y),[e]);return {board:t,columns:r,cards:s,updateBoard:c,addColumn:p,updateColumn:i,deleteColumn:u,getColumn:d,addCard:g,updateCard:h,deleteCard:C,moveCard:T,getCard:m,getCardsByColumn:b}}function Cm(e){let{cards:t}=qo();return useMemo(()=>e?t.filter(a=>{if(e.searchQuery){let r=e.searchQuery.toLowerCase(),o=a.title.toLowerCase().includes(r),s=a.description?.toLowerCase().includes(r);if(!o&&!s)return false}return !(e.priorities&&e.priorities.length>0&&(!a.priority||!e.priorities.includes(a.priority))||e.statuses&&e.statuses.length>0&&(!a.status||!e.statuses.includes(a.status))||e.assignedUserIds&&e.assignedUserIds.length>0&&!e.assignedUserIds.some(o=>a.isAssignedTo(o))||e.labels&&e.labels.length>0&&!e.labels.some(o=>a.hasLabel(o))||e.columnIds&&e.columnIds.length>0&&!e.columnIds.includes(a.columnId)||e.isOverdue!==void 0&&e.isOverdue!==a.isOverdue())}):t,[t,e])}function Tm(e="position",t="asc"){let{cards:a}=qo();return useMemo(()=>[...a].sort((o,s)=>{let n=0;switch(e){case "title":n=o.title.localeCompare(s.title);break;case "priority":{let c={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},p=o.priority?c[o.priority]:0,i=s.priority?c[s.priority]:0;n=p-i;break}case "createdAt":n=o.createdAt.getTime()-s.createdAt.getTime();break;case "updatedAt":n=o.updatedAt.getTime()-s.updatedAt.getTime();break;case "position":n=o.position-s.position;break}return t==="asc"?n:-n}),[a,e,t])}var Yn=class{constructor(){this.plugins=new Map;this.enabled=new Set;this.config=new Map;this.context=null;this.pluginLogger=yl.child("PluginManager");}setContext(t){this.context=t;}register(t){if(!t.id||!t.name||!t.version)throw new Error("Plugin must have id, name, and version");if(this.plugins.has(t.id)&&this.pluginLogger.warn(`Plugin ${t.id} is already registered, overwriting...`),t.dependencies){for(let a of t.dependencies)if(!this.plugins.has(a))throw new Error(`Plugin ${t.id} depends on ${a} which is not registered`)}this.plugins.set(t.id,t),t.defaultConfig&&this.config.set(t.id,{...t.defaultConfig}),this.enabled.add(t.id),this.pluginLogger.info(`Plugin registered: ${t.name} v${t.version}`),t.onInit&&this.context&&Promise.resolve(t.onInit(this.context)).catch(a=>{this.pluginLogger.error(`Failed to initialize plugin ${t.id}`,a,{plugin:t.id});});}unregister(t){let a=this.plugins.get(t);if(!a){this.pluginLogger.warn(`Plugin ${t} is not registered`);return}a.onDestroy&&Promise.resolve(a.onDestroy()).catch(r=>{this.pluginLogger.error(`Failed to destroy plugin ${t}`,r);}),this.plugins.delete(t),this.enabled.delete(t),this.config.delete(t),this.pluginLogger.info(`Plugin unregistered: ${a.name}`);}getPlugin(t){return this.plugins.get(t)}getPlugins(){return Array.from(this.plugins.values())}hasPlugin(t){return this.plugins.has(t)}setEnabled(t,a){if(!this.plugins.has(t))throw new Error(`Plugin ${t} is not registered`);a?(this.enabled.add(t),this.pluginLogger.info(`Plugin enabled: ${t}`)):(this.enabled.delete(t),this.pluginLogger.info(`Plugin disabled: ${t}`));}isEnabled(t){return this.enabled.has(t)}getConfig(t,a){return this.config.get(t)?.[a]}setConfig(t,a,r){this.config.has(t)||this.config.set(t,{});let o=this.config.get(t);o[a]=r,this.pluginLogger.debug(`Plugin config set: ${t}.${a}`,{value:r});}async executeHook(t,a,r){let o=r;for(let s of this.plugins.values()){if(!this.enabled.has(s.id))continue;let n=s[t];if(typeof n=="function")try{let c=await Promise.resolve(n.apply(s,a));c!==void 0&&(o=c,a[0]=c);}catch(c){this.pluginLogger.error(`Plugin hook failed: ${s.id}.${t}`,c,{plugin:s.id,hook:t});}}return o}async executeHookParallel(t,a){let r=[];for(let o of this.plugins.values()){if(!this.enabled.has(o.id))continue;let s=o[t];typeof s=="function"&&r.push(Promise.resolve(s.apply(o,a)).catch(n=>{this.pluginLogger.error(`Plugin hook failed: ${o.id}.${t}`,n,{plugin:o.id,hook:t});}));}await Promise.all(r);}},Rh=new Yn;function Dm({items:e,height:t,estimateSize:a,renderItem:r,className:o="",overscan:s=5,horizontal:n=false,gap:c=0,getItemKey:p}){let i=useRef(null),u=useVirtualizer({count:e.length,getScrollElement:()=>i.current,estimateSize:()=>a,overscan:s,horizontal:n,gap:c}),d=u.getVirtualItems(),g={height:typeof t=="number"?`${t}px`:t,width:"100%",overflow:"auto",position:"relative"},h=n?{width:`${u.getTotalSize()}px`,height:"100%",position:"relative"}:{height:`${u.getTotalSize()}px`,width:"100%",position:"relative"};return jsx("div",{ref:i,style:g,className:o,children:jsx("div",{style:h,children:d.map(C=>{let T=e[C.index];if(!T)return null;let m=p?p(T,C.index):C.index,b={position:"absolute",top:n?0:C.start,left:n?C.start:0,width:n?C.size:"100%",height:n?"100%":C.size};return jsx("div",{style:b,"data-index":C.index,children:r(T,C.index)},m)})})})}function Sm(e){return useVirtualizer({count:e.items.length,getScrollElement:()=>e.scrollElement,estimateSize:()=>e.estimateSize,overscan:e.overscan??5,horizontal:e.horizontal??false,gap:e.gap??0})}function Pm({items:e,height:t,width:a="100%",estimateColumnWidth:r,renderColumn:o,className:s="",overscan:n=3,gap:c=16,getItemKey:p,horizontal:i=true}){let u=useRef(null),d=useVirtualizer({horizontal:i,count:e.length,getScrollElement:()=>u.current,estimateSize:()=>r,overscan:n,gap:c}),g=d.getVirtualItems(),h={height:typeof t=="number"?`${t}px`:t,width:typeof a=="number"?`${a}px`:a,overflow:"auto",position:"relative"},C={width:`${d.getTotalSize()}px`,height:"100%",position:"relative"};return jsx("div",{ref:u,style:h,className:s,children:jsx("div",{style:C,children:g.map(T=>{let m=e[T.index];if(!m)return null;let b=p?p(m,T.index):T.index,y={position:"absolute",top:0,left:T.start,width:T.size,height:"100%"};return jsx("div",{style:y,"data-index":T.index,children:o(m,T.index)},b)})})})}function Mm(e){let t=useVirtualizer({horizontal:true,count:e.items.length,getScrollElement:()=>e.scrollElement,estimateSize:()=>e.estimateColumnWidth,overscan:e.overscan??3,gap:e.gap??0});return {columnVirtualizer:t,virtualColumns:t.getVirtualItems(),totalWidth:t.getTotalSize()}}function Am(e,t=10){return e>t}var Ki={none:0,xs:4,sm:8,md:12,lg:16,xl:20,"2xl":24,"3xl":32,"4xl":40,"5xl":48,"6xl":64},Yi={none:0,sm:4,md:8,lg:12,xl:16,"2xl":20,full:9999},qi={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48},Xi={light:300,normal:400,medium:500,semibold:600,bold:700,extrabold:800},Ji={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},Zi={base:0,dropdown:1e3,sticky:1020,fixed:1030,modalBackdrop:1040,modal:1050,popover:1060,tooltip:1070},Qi={instant:0,fastest:75,faster:100,fast:150,normal:200,slow:300,slower:400,slowest:500},el={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",smooth:"cubic-bezier(0.4, 0.0, 0.2, 1)",sharp:"cubic-bezier(0.4, 0.0, 0.6, 1)",bounce:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},tl={none:"none",sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",base:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",xl:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)","2xl":"0 25px 50px -12px rgba(0, 0, 0, 0.25)",inner:"inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)"},al={0:0,5:.05,10:.1,20:.2,30:.3,40:.4,50:.5,60:.6,70:.7,80:.8,90:.9,100:1},rl={column:{width:320,minWidth:280,maxWidth:400,gap:16,padding:12,headerHeight:48},card:{minHeight:80,maxHeight:400,padding:12,gap:8},board:{padding:16,gap:16}},ol={timeline:{headerHeight:60,rowHeight:44,minRowHeight:32,maxRowHeight:80,taskPadding:4,gridLineWidth:1},task:{height:28,minHeight:20,maxHeight:40,borderRadius:4,padding:6},dependency:{lineWidth:2,arrowSize:8},scale:{day:{columnWidth:40,minColumnWidth:30,maxColumnWidth:60},week:{columnWidth:80,minColumnWidth:60,maxColumnWidth:120},month:{columnWidth:120,minColumnWidth:80,maxColumnWidth:200},quarter:{columnWidth:200,minColumnWidth:150,maxColumnWidth:300}},milestone:{size:16,rotation:45}},qn={spacing:Ki,borderRadius:Yi,fontSize:qi,fontWeight:Xi,lineHeight:Ji,zIndex:Zi,duration:Qi,easing:el,shadows:tl,opacity:al,kanban:rl,gantt:ol};function Fm(e,t,a){return e[t]??a}function nl(e,t="",a={}){for(let[r,o]of Object.entries(e)){let s=t?`${t}-${r}`:r;typeof o=="object"&&o!==null&&!Array.isArray(o)?nl(o,s,a):(typeof o=="string"||typeof o=="number")&&(a[s]=o);}return a}function Uh(e){return typeof e=="number"?e>0&&e<1e3?`${e}px`:e.toString():e}function sl(e="asakaa"){let t=nl(qn),a=[];for(let[r,o]of Object.entries(t)){let s=`--${e}-${r}`,n=Uh(o);a.push(` ${s}: ${n};`);}return `:root {
390
390
  ${a.join(`
391
391
  `)}
392
- }`}function Ko(e,t="asakaa"){let a=[],r=al(e);for(let[o,s]of Object.entries(r)){let n=`--${t}-color-${o}`;a.push(` ${n}: ${s};`);}return `:root {
392
+ }`}function Xo(e,t="asakaa"){let a=[],r=nl(e);for(let[o,s]of Object.entries(r)){let n=`--${t}-color-${o}`;a.push(` ${n}: ${s};`);}return `:root {
393
393
  ${a.join(`
394
394
  `)}
395
- }`}var Kn={background:{primary:"#1a1a1a",secondary:"#2a2a2a",tertiary:"#3a3a3a",card:"#2d2d2d",hover:"#353535",active:"#404040"},text:{primary:"#ffffff",secondary:"#b0b0b0",tertiary:"#808080",disabled:"#606060",inverse:"#1a1a1a"},border:{default:"#404040",hover:"#505050",focus:"#0ea5e9",active:"#0284c7"},status:{success:"#22c55e",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6"},priority:{low:"#6b7280",medium:"#3b82f6",high:"#f59e0b",urgent:"#ef4444"},interactive:{primary:"#0ea5e9",primaryHover:"#0284c7",primaryActive:"#0369a1",secondary:"#6b7280",secondaryHover:"#4b5563",secondaryActive:"#374151"},gantt:{gridLine:"#404040",todayLine:"#0ea5e9",taskBackground:"#3b82f6",taskBorder:"#2563eb",criticalPath:"#ef4444",milestone:"#3b82f6",dependency:"#6b7280",weekend:"#2a2a2a"}},ol={background:{primary:"#ffffff",secondary:"#f9fafb",tertiary:"#f3f4f6",card:"#ffffff",hover:"#f3f4f6",active:"#e5e7eb"},text:{primary:"#111827",secondary:"#6b7280",tertiary:"#9ca3af",disabled:"#d1d5db",inverse:"#ffffff"},border:{default:"#e5e7eb",hover:"#d1d5db",focus:"#0ea5e9",active:"#0284c7"},status:{success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#2563eb"},priority:{low:"#9ca3af",medium:"#3b82f6",high:"#f59e0b",urgent:"#ef4444"},interactive:{primary:"#0ea5e9",primaryHover:"#0284c7",primaryActive:"#0369a1",secondary:"#6b7280",secondaryHover:"#4b5563",secondaryActive:"#374151"},gantt:{gridLine:"#e5e7eb",todayLine:"#0ea5e9",taskBackground:"#3b82f6",taskBorder:"#2563eb",criticalPath:"#ef4444",milestone:"#3b82f6",dependency:"#6b7280",weekend:"#f9fafb"}},nl={background:{primary:"#18181b",secondary:"#27272a",tertiary:"#3f3f46",card:"#27272a",hover:"#3f3f46",active:"#52525b"},text:{primary:"#fafafa",secondary:"#a1a1aa",tertiary:"#71717a",disabled:"#52525b",inverse:"#18181b"},border:{default:"#3f3f46",hover:"#52525b",focus:"#0ea5e9",active:"#0284c7"},status:{success:"#22c55e",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6"},priority:{low:"#71717a",medium:"#3b82f6",high:"#f59e0b",urgent:"#ef4444"},interactive:{primary:"#0ea5e9",primaryHover:"#0284c7",primaryActive:"#0369a1",secondary:"#71717a",secondaryHover:"#52525b",secondaryActive:"#3f3f46"},gantt:{gridLine:"#3f3f46",todayLine:"#0ea5e9",taskBackground:"#3b82f6",taskBorder:"#2563eb",criticalPath:"#ef4444",milestone:"#3b82f6",dependency:"#71717a",weekend:"#27272a"}};function sl(e=Kn,t="asakaa"){let a=rl(t),r=Ko(e,t);return `${a}
395
+ }`}var Xn={background:{primary:"#1a1a1a",secondary:"#2a2a2a",tertiary:"#3a3a3a",card:"#2d2d2d",hover:"#353535",active:"#404040"},text:{primary:"#ffffff",secondary:"#b0b0b0",tertiary:"#808080",disabled:"#606060",inverse:"#1a1a1a"},border:{default:"#404040",hover:"#505050",focus:"#0ea5e9",active:"#0284c7"},status:{success:"#22c55e",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6"},priority:{low:"#6b7280",medium:"#3b82f6",high:"#f59e0b",urgent:"#ef4444"},interactive:{primary:"#0ea5e9",primaryHover:"#0284c7",primaryActive:"#0369a1",secondary:"#6b7280",secondaryHover:"#4b5563",secondaryActive:"#374151"},gantt:{gridLine:"#404040",todayLine:"#0ea5e9",taskBackground:"#3b82f6",taskBorder:"#2563eb",criticalPath:"#ef4444",milestone:"#3b82f6",dependency:"#6b7280",weekend:"#2a2a2a"}},il={background:{primary:"#ffffff",secondary:"#f9fafb",tertiary:"#f3f4f6",card:"#ffffff",hover:"#f3f4f6",active:"#e5e7eb"},text:{primary:"#111827",secondary:"#6b7280",tertiary:"#9ca3af",disabled:"#d1d5db",inverse:"#ffffff"},border:{default:"#e5e7eb",hover:"#d1d5db",focus:"#0ea5e9",active:"#0284c7"},status:{success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#2563eb"},priority:{low:"#9ca3af",medium:"#3b82f6",high:"#f59e0b",urgent:"#ef4444"},interactive:{primary:"#0ea5e9",primaryHover:"#0284c7",primaryActive:"#0369a1",secondary:"#6b7280",secondaryHover:"#4b5563",secondaryActive:"#374151"},gantt:{gridLine:"#e5e7eb",todayLine:"#0ea5e9",taskBackground:"#3b82f6",taskBorder:"#2563eb",criticalPath:"#ef4444",milestone:"#3b82f6",dependency:"#6b7280",weekend:"#f9fafb"}},ll={background:{primary:"#18181b",secondary:"#27272a",tertiary:"#3f3f46",card:"#27272a",hover:"#3f3f46",active:"#52525b"},text:{primary:"#fafafa",secondary:"#a1a1aa",tertiary:"#71717a",disabled:"#52525b",inverse:"#18181b"},border:{default:"#3f3f46",hover:"#52525b",focus:"#0ea5e9",active:"#0284c7"},status:{success:"#22c55e",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6"},priority:{low:"#71717a",medium:"#3b82f6",high:"#f59e0b",urgent:"#ef4444"},interactive:{primary:"#0ea5e9",primaryHover:"#0284c7",primaryActive:"#0369a1",secondary:"#71717a",secondaryHover:"#52525b",secondaryActive:"#3f3f46"},gantt:{gridLine:"#3f3f46",todayLine:"#0ea5e9",taskBackground:"#3b82f6",taskBorder:"#2563eb",criticalPath:"#ef4444",milestone:"#3b82f6",dependency:"#71717a",weekend:"#27272a"}};function dl(e=Xn,t="asakaa"){let a=sl(t),r=Xo(e,t);return `${a}
396
396
 
397
397
  ${r}`}function Im(){return `/**
398
398
  * ASAKAA Design Tokens
@@ -400,21 +400,21 @@ ${r}`}function Im(){return `/**
400
400
  * Do not edit this file directly
401
401
  */
402
402
 
403
- ${sl(Kn)}
403
+ ${dl(Xn)}
404
404
 
405
405
  /* Light theme */
406
406
  [data-theme="light"] {
407
- ${Ko(ol,"asakaa").split(`
407
+ ${Xo(il,"asakaa").split(`
408
408
  `).slice(1,-1).join(`
409
409
  `)}
410
410
  }
411
411
 
412
412
  /* Neutral theme */
413
413
  [data-theme="neutral"] {
414
- ${Ko(nl,"asakaa").split(`
414
+ ${Xo(ll,"asakaa").split(`
415
415
  `).slice(1,-1).join(`
416
416
  `)}
417
417
  }
418
- `}var Uh=({theme:e})=>{switch(e){case "dark":return jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M13.5 8.5C13.5 11.2614 11.2614 13.5 8.5 13.5C5.73858 13.5 3.5 11.2614 3.5 8.5C3.5 5.73858 5.73858 3.5 8.5 3.5C8.66667 3.5 8.83074 3.50926 8.99199 3.52734C8.10635 4.35233 7.5 5.53318 7.5 6.85C7.5 9.33579 9.49421 11.33 11.98 11.33C12.5933 11.33 13.1751 11.2075 13.7069 10.9844C13.5698 11.8951 13.2042 12.7349 12.6674 13.4367",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});case "light":return jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"3",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 1V2M8 14V15M15 8H14M2 8H1M12.5 12.5L11.8 11.8M4.2 4.2L3.5 3.5M12.5 3.5L11.8 4.2M4.2 11.8L3.5 12.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "neutral":return jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M5 8L8 8L8 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}};function Lm({showLabels:e=true,compact:t=false,className:a=""}){let{theme:r,setTheme:o,themes:s}=co();return jsx("div",{className:`theme-switcher ${t?"theme-switcher--compact":""} ${a}`,children:Object.entries(s).map(([n,c])=>{let p=n,i=p===r;return jsxs("button",{onClick:()=>o(p),className:`theme-switcher__button ${i?"theme-switcher__button--active":""}`,"aria-label":`Switch to ${c.displayName} theme`,"aria-pressed":i,title:c.displayName,children:[jsx("span",{className:"theme-switcher__icon","aria-hidden":"true",children:jsx(Uh,{theme:p})}),e&&!t&&jsx("span",{className:"theme-switcher__label",children:c.displayName})]},p)})})}
419
- export{om as AIUsageDashboard,bh as AI_FEATURES,Oi as AI_MODELS,xs as AddCardButton,vs as AddColumnButton,sr as AttachmentUploader,km as BoardProvider,pn as BulkOperationsToolbar,Fs as BurnDownChart,Wc as CalendarBoard,dr as Card,Ds as CardDetailModal,Ps as CardDetailModalV2,qc as CardHistoryReplay,Kc as CardHistoryTimeline,Zc as CardRelationshipsGraph,lh as CardStack,Us as CardTemplateSelector,es as CircuitBreaker,ro as Column,yn as ColumnManager,Cs as CommandPalette,Gs as ConfigMenu,uo as ContextMenu,Po as DEFAULT_SHORTCUTS,zs as DEFAULT_TEMPLATES,xo as DateRangePicker,wo as DependenciesSelector,Nn as DependencyLine,Is as DistributionCharts,ls as EditableColumnTitle,no as ErrorBoundary,Hs as ExportImportModal,Ws as FilterBar,xc as GANTT_AI_SYSTEM_PROMPT,Mn as GanttAIAssistant,hc as GanttBoard,po as GanttI18nContext,Sn as GanttMilestone,bn as GanttToolbar,im as GenerateGanttTasksDialog,tm as GeneratePlanModal,Rs as GroupBySelector,wr as KanbanBoard,bs as KanbanToolbar,Do as KanbanViewAdapter,Os as KeyboardShortcutsHelp,Fc as ListView,Bt as MenuIcons,Vn as PluginManager,Lr as PrioritySelector,hh as RATE_LIMITS,Ls as SwimlaneBoardView,cs as TagBadge,Yl as TagList,ar as TagPicker,wn as TaskBar,Ur as TaskDetailModal,vc as TaskFormModal,kn as TaskGrid,Ks as ThemeModal,Fd as ThemeProvider,Lm as ThemeSwitcher,Pn as Timeline,Rr as UserAssignmentSelector,As as VelocityChart,Pm as VirtualGrid,Dm as VirtualList,Yr as aiUsageTracker,Vi as borderRadius,Jo as calculatePosition,Fi as calendarDarkTheme,Ti as calendarEnTranslations,Ni as calendarEsTranslations,Ii as calendarLightTheme,Li as calendarNeutralTheme,$n as calendarThemes,On as calendarTranslations,Fn as cardToGanttTask,Sc as cardsToGanttTasks,h as cn,md as createKanbanView,Zm as createRetryWrapper,_s as darkTheme,Kn as darkTokenTheme,gn as defaultTheme,jn as designTokens,Xi as duration,Ji as easing,Im as exportTokensToCSS,ur as findTaskByName,ji as fontSize,Ki as fontWeight,Go as formatCost,hn as ganttEnTranslations,Ld as ganttEsTranslations,Dc as ganttTaskToCardUpdate,Qe as ganttThemes,tl as ganttTokens,Ys as ganttTranslations,pe as ganttUtils,rl as generateCSSVariables,sl as generateCompleteCSS,Ym as generateInitialPositions,kc as generateTasksContext,Ko as generateThemeVariables,Gc as getCalendarTheme,zo as getCalendarTranslations,Ic as getListViewTheme,xi as getListViewTranslations,Lc as getMonthNames,Fm as getToken,Bd as getTranslations,Bc as getWeekdayNames,el as kanbanTokens,Vs as lightTheme,ol as lightTokenTheme,Yi as lineHeight,ki as listViewDarkTheme,yi as listViewEnTranslations,vi as listViewEsTranslations,wi as listViewLightTheme,Ci as listViewNeutralTheme,Rn as listViewThemes,In as listViewTranslations,zn as mergeCalendarTranslations,Ln as mergeListViewTranslations,qs as mergeTranslations,js as neutralTheme,nl as neutralTokenTheme,Qi as opacity,Tc as parseLocalCommand,fi as parseNaturalDate,hi as parseNaturalDuration,bi as parseProgress,Cc as parseStatus,Bh as pluginManager,Jm as retrySyncOperation,Zo as retryWithBackoff,Zi as shadows,Am as shouldVirtualizeGrid,_i as spacing,Wr as themes,hm as useAI,dm as useBoard,jo as useBoardCore,_n as useBoardStore,vm as useCardStacking,fs as useDragState,Cm as useFilteredCards,pm as useFilters,Mo as useGanttI18n,Gn as useKanbanState,Pd as useKeyboardShortcuts,bm as useMultiSelect,$i as useSelectionState,Tm as useSortedCards,co as useTheme,Mm as useVirtualGrid,Sm as useVirtualList,Nc as validateAIResponse,ks as withErrorBoundary,en as wouldCreateCircularDependency,qi as zIndex};//# sourceMappingURL=index.js.map
418
+ `}var $h=({theme:e})=>{switch(e){case "dark":return jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M13.5 8.5C13.5 11.2614 11.2614 13.5 8.5 13.5C5.73858 13.5 3.5 11.2614 3.5 8.5C3.5 5.73858 5.73858 3.5 8.5 3.5C8.66667 3.5 8.83074 3.50926 8.99199 3.52734C8.10635 4.35233 7.5 5.53318 7.5 6.85C7.5 9.33579 9.49421 11.33 11.98 11.33C12.5933 11.33 13.1751 11.2075 13.7069 10.9844C13.5698 11.8951 13.2042 12.7349 12.6674 13.4367",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});case "light":return jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"3",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 1V2M8 14V15M15 8H14M2 8H1M12.5 12.5L11.8 11.8M4.2 4.2L3.5 3.5M12.5 3.5L11.8 4.2M4.2 11.8L3.5 12.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "neutral":return jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M5 8L8 8L8 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}};function Lm({showLabels:e=true,compact:t=false,className:a=""}){let{theme:r,setTheme:o,themes:s}=go();return jsx("div",{className:`theme-switcher ${t?"theme-switcher--compact":""} ${a}`,children:Object.entries(s).map(([n,c])=>{let p=n,i=p===r;return jsxs("button",{onClick:()=>o(p),className:`theme-switcher__button ${i?"theme-switcher__button--active":""}`,"aria-label":`Switch to ${c.displayName} theme`,"aria-pressed":i,title:c.displayName,children:[jsx("span",{className:"theme-switcher__icon","aria-hidden":"true",children:jsx($h,{theme:p})}),e&&!t&&jsx("span",{className:"theme-switcher__label",children:c.displayName})]},p)})})}
419
+ export{om as AIUsageDashboard,yh as AI_FEATURES,$i as AI_MODELS,Cs as AddCardButton,ws as AddColumnButton,dr as AttachmentUploader,km as BoardProvider,fn as BulkOperationsToolbar,Bs as BurnDownChart,Wc as CalendarBoard,ur as Card,Ps as CardDetailModal,Fs as CardDetailModalV2,qc as CardHistoryReplay,Kc as CardHistoryTimeline,Zc as CardRelationshipsGraph,dh as CardStack,Ws as CardTemplateSelector,rs as CircuitBreaker,io as Column,kn as ColumnManager,Ds as CommandPalette,js as ConfigMenu,bo as ContextMenu,Fo as DEFAULT_SHORTCUTS,Hs as DEFAULT_TEMPLATES,Co as DateRangePicker,No as DependenciesSelector,En as DependencyLine,Rs as DistributionCharts,ms as EditableColumnTitle,co as ErrorBoundary,_s as ExportImportModal,Vs as FilterBar,xc as GANTT_AI_SYSTEM_PROMPT,In as GanttAIAssistant,hc as GanttBoard,ho as GanttI18nContext,Mn as GanttMilestone,xn as GanttToolbar,im as GenerateGanttTasksDialog,tm as GeneratePlanModal,Us as GroupBySelector,Dr as KanbanBoard,xs as KanbanToolbar,Po as KanbanViewAdapter,$s as KeyboardShortcutsHelp,Fc as ListView,zt as MenuIcons,Yn as PluginManager,zr as PrioritySelector,bh as RATE_LIMITS,Os as SwimlaneBoardView,us as TagBadge,Yl as TagList,nr as TagPicker,Nn as TaskBar,Gr as TaskDetailModal,vc as TaskFormModal,Tn as TaskGrid,Xs as ThemeModal,Fd as ThemeProvider,Lm as ThemeSwitcher,Fn as Timeline,$r as UserAssignmentSelector,Ls as VelocityChart,Pm as VirtualGrid,Dm as VirtualList,Zr as aiUsageTracker,Yi as borderRadius,en as calculatePosition,Bi as calendarDarkTheme,Si as calendarEnTranslations,Ei as calendarEsTranslations,Ri as calendarLightTheme,Oi as calendarNeutralTheme,Gn as calendarThemes,$n as calendarTranslations,Bn as cardToGanttTask,Sc as cardsToGanttTasks,f as cn,md as createKanbanView,Zm as createRetryWrapper,Ks as darkTheme,Xn as darkTokenTheme,bn as defaultTheme,qn as designTokens,Qi as duration,el as easing,Im as exportTokensToCSS,br as findTaskByName,qi as fontSize,Xi as fontWeight,jo as formatCost,vn as ganttEnTranslations,Ld as ganttEsTranslations,Dc as ganttTaskToCardUpdate,Ze as ganttThemes,ol as ganttTokens,Js as ganttTranslations,me as ganttUtils,sl as generateCSSVariables,dl as generateCompleteCSS,Ym as generateInitialPositions,kc as generateTasksContext,Xo as generateThemeVariables,Gc as getCalendarTheme,Ho as getCalendarTranslations,Ic as getListViewTheme,Ci as getListViewTranslations,Lc as getMonthNames,Fm as getToken,Bd as getTranslations,Bc as getWeekdayNames,rl as kanbanTokens,Ys as lightTheme,il as lightTokenTheme,Ji as lineHeight,Ti as listViewDarkTheme,ki as listViewEnTranslations,wi as listViewEsTranslations,Ni as listViewLightTheme,Di as listViewNeutralTheme,Un as listViewThemes,Rn as listViewTranslations,Hn as mergeCalendarTranslations,On as mergeListViewTranslations,Zs as mergeTranslations,qs as neutralTheme,ll as neutralTokenTheme,al as opacity,Tc as parseLocalCommand,yi as parseNaturalDate,vi as parseNaturalDuration,xi as parseProgress,Cc as parseStatus,Rh as pluginManager,Jm as retrySyncOperation,tn as retryWithBackoff,tl as shadows,Am as shouldVirtualizeGrid,Ki as spacing,jr as themes,hm as useAI,dm as useBoard,qo as useBoardCore,Kn as useBoardStore,vm as useCardStacking,ys as useDragState,Cm as useFilteredCards,pm as useFilters,Io as useGanttI18n,jn as useKanbanState,Pd as useKeyboardShortcuts,bm as useMultiSelect,Gi as useSelectionState,Tm as useSortedCards,go as useTheme,Mm as useVirtualGrid,Sm as useVirtualList,Nc as validateAIResponse,Ts as withErrorBoundary,rn as wouldCreateCircularDependency,Zi as zIndex};//# sourceMappingURL=index.js.map
420
420
  //# sourceMappingURL=index.js.map