@libxai/board 0.17.344 → 0.17.346

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 xc 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,Filter,FileImage,FileSpreadsheet,FileJson,FolderKanban,Download,Calendar,ChevronLeft,GripVertical,AlertCircle,CircleDot,Users,Milestone,List,Search}from'lucide-react';import {Command}from'cmdk';import _u from'react-markdown';import Vu from'remark-gfm';import ju 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 Zo=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 [Zo.Translate.toString(e),Zo.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 rp(e){return Array.from({length:e},(t,a)=>(a+1)*1e3)}function os(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 Cl(e,t=100){return e>t}var op=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 np(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=op,onRetry:p}=t,m,i=0;for(let u=1;u<=a;u++){i=u;try{return {data:await e(),attempts:i,success:!0}}catch(d){if(m=d,u===a||!n(m,u))return {error:m,attempts:i,success:false};let b=np(u,r,o,s);if(p)try{p(m,u,b);}catch(C){console.error("Error in retry callback:",C);}await new Promise(C=>setTimeout(C,b));}}return {error:m||new Error("Unknown error"),attempts:i,success:false}}function sp(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 ip(e,t={}){return async(...a)=>tn(()=>e(...a),t)}var ns=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 Tl=(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))(Tl||{}),$r=class $r{constructor(t={}){this.defaultLogHandler=t=>{let{timestamp:a,level:r,message:o,component:s,...n}=t,p=`[${a}] [${r}] [${s}]`,m=Object.keys(n).length>0;switch(r){case "DEBUG":console.debug(p,o,m?n:"");break;case "INFO":console.info(p,o,m?n:"");break;case "WARN":console.warn(p,o,m?n:"");break;case "ERROR":console.error(p,o,m?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",...$r.globalOptions};}static configure(t){$r.globalOptions={...$r.globalOptions,...t};}child(t){return new $r({...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:Tl[t],message:a,component:this.options.componentName,...r};this.options.onLog(o);}};$r.globalOptions={};var ss=$r,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}},Nl=new ss;function dp(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 cp(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(p=>p.id===s.columnId);return [s.id,is(s.title),is(s.description||""),is(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 mp(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 xc(r,{backgroundColor:"#0a0a0a",scale:1.5,logging:!1,useCORS:!0,allowTaint:!0,windowWidth:r.scrollWidth,windowHeight:r.scrollHeight}),p=n.toDataURL("image/png"),m=297,i=210,u=n.width/n.height,d=m-20,g=d/u;g>i-20&&(g=i-20,d=g*u);let b=new jsPDF({orientation:"landscape",unit:"mm",format:"a4"});b.setFontSize(16),b.setTextColor(255,255,255),b.setFillColor(10,10,10),b.rect(0,0,m,15,"F"),b.text(e.title||"Kanban Board",10,10);let C=(m-d)/2;return b.addImage(p,"PNG",C,20,d,g),b}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 p=e.cards.filter(m=>m.columnId===n.id);s>250&&(o.addPage(),s=20),o.setFontSize(16),o.setFont("helvetica","bold"),o.text(n.title,20,s),s+=8,p.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):p.forEach(m=>{if(s>260&&(o.addPage(),s=20),o.setFontSize(12),o.setFont("helvetica","bold"),o.text(m.title,25,s),s+=6,m.description){o.setFontSize(9),o.setFont("helvetica","normal");let u=o.splitTextToSize(m.description,160);o.text(u,25,s),s+=u.length*5;}let i=[];if(m.priority&&i.push(`Priority: ${m.priority}`),m.labels&&m.labels.length>0&&i.push(`Labels: ${m.labels.join(", ")}`),m.assignedUserIds&&m.assignedUserIds.length>0&&i.push(`Assigned: ${m.assignedUserIds.length} user(s)`),m.startDate||m.endDate){let u=[];m.startDate&&u.push(`Start: ${m.startDate}`),m.endDate&&u.push(`End: ${m.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 is(e){return e.includes(",")||e.includes('"')||e.includes(`
3
- `)?`"${e.replace(/"/g,'""')}"`:e}async function Sl(e,t,a,r){switch(t){case "json":return dp(e,r);case "csv":return cp(e);case "pdf":return await mp(e,a);default:throw new Error(`Unsupported export format: ${t}`)}}function El(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"},p=new Blob([e],{type:n[t]}),m=URL.createObjectURL(p),i=document.createElement("a");i.href=m,i.download=s,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(m);}function pp(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 up(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=Pl(t[0]),r=[],o=new Map,s=[];for(let n=1;n<t.length;n++)try{let p=Pl(t[n]||"");if(p.length>a.length){s.push(`Line ${n+1}: Too many columns`);continue}if(a.length-p.length>3){s.push(`Line ${n+1}: Column count mismatch (expected ${a.length}, got ${p.length})`);continue}for(;p.length<a.length;)p.push("");let i={};a.forEach((b,C)=>{i[b]=p[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(p){s.push(`Line ${n+1}: ${p instanceof Error?p.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 Pl(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 Ml(e,t){switch(t){case "json":return pp(e);case "csv":return up(e);default:return {success:false,errors:[`Unsupported import format: ${t}`]}}}function Al(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 ls=createContext(null);function Fl(){return useContext(ls)}var Ll=createContext(null);function Il({children:e,themeName:t}){return jsx(Ll.Provider,{value:{themeName:t},children:e})}function oo(){return useContext(Ll)}function ht({children:e,container:t}){let[a,r]=useState(false),o=Fl(),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:p,themeName:m}=o,i={"--asakaa-color-background-primary":p.bgPrimary,"--asakaa-color-background-secondary":p.bgSecondary,"--asakaa-color-background-card":p.bgGrid,"--asakaa-color-background-hover":p.hoverBg,"--asakaa-color-text-primary":p.textPrimary,"--asakaa-color-text-secondary":p.textSecondary,"--asakaa-color-text-tertiary":p.textTertiary,"--asakaa-color-text-inverse":p.taskBarHandle||"#FFFFFF","--asakaa-color-border-default":p.border,"--asakaa-color-border-hover":p.borderLight,"--asakaa-color-border-subtle":p.borderLight,"--asakaa-color-interactive-primary":p.accent,"--asakaa-color-interactive-primaryHover":p.accentHover,"--asakaa-color-interactive-primaryBorder":`${p.accent}4D`,"--asakaa-color-interactive-primaryBackground":`${p.accent}1A`,"--asakaa-color-interactive-primaryBackgroundHover":`${p.accent}33`,"--asakaa-color-status-success":p.statusCompleted,"--asakaa-color-status-warning":p.milestone,"--asakaa-color-status-error":p.criticalPath,"--asakaa-color-danger":p.criticalPath,"--asakaa-color-danger-border":`${p.criticalPath}4D`,"--asakaa-color-danger-background":`${p.criticalPath}14`,"--asakaa-color-danger-backgroundHover":`${p.criticalPath}26`};return createPortal(jsx("div",{"data-theme":m,"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 zl={URGENT:{label:"Urgent",color:"#E74C3C"},HIGH:{label:"High",color:"#E67E22"},MEDIUM:{label:"Normal",color:"#F1C40F"},LOW:{label:"Low",color:"#2ECC71"}},kp="#BDC3C7",wp=({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 Or({priority:e,onChange:t,className:a}){let[r,o]=useState(false),[s,n]=useState({top:0,left:0}),p=useRef(null),m=useRef(null),i=()=>{if(!m.current)return;let b=m.current.getBoundingClientRect(),C=window.innerHeight,T=window.innerWidth,c=160,h=220,v=4,l=b.right-c;l<10&&(l=b.left),l+c>T-10&&(l=T-c-10);let k=C-b.bottom,y=b.top,S;k>=h+v?S=b.bottom+v:y>=h+v?S=b.top-h-v:S=k>=y?b.bottom+v:Math.max(10,b.top-h-v),n({top:S,left:l}),o(true);};useEffect(()=>{let b=C=>{p.current&&!p.current.contains(C.target)&&!m.current?.contains(C.target)&&o(false);};if(r)return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[r]),useEffect(()=>{let b=C=>{C.key==="Escape"&&o(false);};if(r)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[r]);let u=b=>{t(b),o(false);},d=e?zl[e]:null,g=d?.color||kp;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:m,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(ht,{children:jsxs("div",{ref:p,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(zl).map(([b,C])=>jsxs("button",{onClick:()=>u(b),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(wp,{color:C.color}),jsx("span",{className:"font-semibold text-sm",children:C.label}),e===b&&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"})})]},b)),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: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("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 Cp=[{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 To({startDate:e,endDate:t,onChange:a,className:r}){let[o,s]=useState(false),[n,p]=useState({top:0,left:0}),m=useRef(null),i=useRef(null),g=(oo()?.themeName||"dark")==="dark",b=()=>{if(!i.current)return;let l=i.current.getBoundingClientRect(),k=window.innerHeight,y=window.innerWidth,S=320,w=380,x=4,R=l.left;R+S>y-10&&(R=y-S-10),R<10&&(R=10);let A=k-l.bottom,N=l.top,U;A>=w+x?U=l.bottom+x:N>=w+x?U=l.top-w-x:U=A>=N?l.bottom+x:Math.max(10,l.top-w-x),p({top:U,left:R}),s(true);};useEffect(()=>{let l=k=>{m.current&&!m.current.contains(k.target)&&!i.current?.contains(k.target)&&s(false);};if(o)return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[o]),useEffect(()=>{let l=k=>{k.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[o]);let C=l=>{let k=new Date,y=R=>{let A=R.getFullYear(),N=String(R.getMonth()+1).padStart(2,"0"),U=String(R.getDate()).padStart(2,"0");return `${A}-${N}-${U}`},S=y(k),w=new Date(k);w.setDate(w.getDate()+l);let x=y(w);a(S,x),s(false);},T=()=>{if(!e||!t)return "Set date";let l=w=>{if(w instanceof Date)return w;if(typeof w!="string"||!w.match(/^\d{4}-\d{2}-\d{2}$/))return null;let x=w.split("-").map(Number);if(x.length!==3||x.some(U=>isNaN(U)))return null;let R=x[0],A=x[1],N=x[2];return R===void 0||A===void 0||N===void 0?null:new Date(R,A-1,N)},k=l(e),y=l(t);if(!k||!y||isNaN(k.getTime())||isNaN(y.getTime()))return "Set date";let S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return `${S[k.getMonth()]} ${k.getDate()} \u2013 ${S[y.getMonth()]} ${y.getDate()}`},c=e&&t,v=(()=>{if(!t)return false;let l=typeof t=="string"?new Date(t):t,k=new Date;return k.setHours(0,0,0,0),l<k})();return jsxs("div",{className:`relative ${r||""}`,children:[jsxs("button",{ref:i,onClick:()=>o?s(false):b(),className:`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-all hover:bg-white/5 ${v?"asakaa-date-overdue":"asakaa-date"}`,title:c?`${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(ht,{children:jsxs("div",{ref:m,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:Cp.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:k=>{k.currentTarget.style.backgroundColor=g?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.1)",k.currentTarget.style.border=`1px solid ${g?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.25)"}`;},onMouseLeave:k=>{k.currentTarget.style.backgroundColor=g?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",k.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 Ur({assignedUsers:e=[],availableUsers:t,onChange:a,className:r,maxVisibleAvatars:o=3}){let[s,n]=useState(false),[p,m]=useState(""),[i,u]=useState({top:0,left:0}),d=useRef(null),g=useRef(null),b=()=>{if(!g.current)return;let v=g.current.getBoundingClientRect(),l=window.innerHeight,k=window.innerWidth,y=300,S=380,w=4,x=v.right-y;x<10&&(x=v.left),x+y>k-10&&(x=k-y-10);let R=l-v.bottom,A=v.top,N;R>=S+w?N=v.bottom+w:A>=S+w?N=v.top-S-w:N=R>=A?v.bottom+w:Math.max(10,v.top-S-w),u({top:N,left:x}),n(true);};useEffect(()=>{let v=l=>{d.current&&!d.current.contains(l.target)&&!g.current?.contains(l.target)&&(n(false),m(""));};if(s)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[s]),useEffect(()=>{let v=l=>{l.key==="Escape"&&(n(false),m(""));};if(s)return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[s]);let C=v=>{let l=e.some(k=>k.id===v.id);a(l?e.filter(k=>k.id!==v.id):[...e,v]);},T=t.filter(v=>v.name.toLowerCase().includes(p.toLowerCase())),c=e.slice(0,o),h=e.length-o;return jsxs("div",{className:`relative ${r||""}`,children:[jsx("button",{ref:g,onClick:()=>s?n(false):b(),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:[c.map(v=>jsx("div",{className:"asakaa-avatar",title:v.name,children:v.avatar?jsx("img",{src:v.avatar,alt:v.name,className:"asakaa-avatar-img"}):v.initials},v.id)),h>0&&jsxs("div",{className:"asakaa-avatar",children:["+",h]})]}):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(ht,{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:p,onChange:v=>m(v.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(v=>{let l=e.some(k=>k.id===v.id);return jsxs("button",{onClick:()=>C(v),className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm transition-all active:scale-98",style:{background:"transparent"},onMouseEnter:k=>{k.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.1))";},onMouseLeave:k=>{k.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:v.color,color:"#fff"},children:v.avatar?jsx("img",{src:v.avatar,alt:v.name,className:"w-full h-full rounded-full object-cover"}):v.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:v.name}),jsx("span",{className:"w-5 text-lg flex-shrink-0 text-right",style:{color:l?"#3b82f6":"transparent"},children:l?"\u2713":""})]},v.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(m=>{if(m.dependencies&&Array.isArray(m.dependencies)){let i=m.dependencies.map(u=>{if(typeof u=="string")return u;let d=u;return d.taskId||d.targetId||""}).filter(Boolean);r.set(m.id,i);}});let o=r.get(a)||[];r.set(a,[...o,t]);let s=new Set,n=new Set,p=m=>{if(!s.has(m)){s.add(m),n.add(m);let i=r.get(m)||[];for(let u of i){if(!s.has(u)&&p(u))return true;if(n.has(u))return true}}return n.delete(m),false};return p(a)}function Do({currentCardId:e,dependencies:t=[],availableTasks:a,onChange:r,className:o,validateCircular:s=true,onCircularDependencyError:n}){let[p,m]=useState(false),[i,u]=useState(""),[d,g]=useState(t.length>0),[b,C]=useState({top:0,left:0}),[T,c]=useState(null),h=useRef(null),v=useRef(null),l=()=>{if(!v.current)return;let x=v.current.getBoundingClientRect(),R=window.innerHeight,A=window.innerWidth,N=300,U=d?380:120,$=4,_=x.right-N;_<10&&(_=x.left),_+N>A-10&&(_=A-N-10);let q=R-x.bottom,pe=x.top,Te;q>=U+$?Te=x.bottom+$:pe>=U+$?Te=x.top-U-$:Te=q>=pe?x.bottom+$:Math.max(10,x.top-U-$),C({top:Te,left:_}),m(true);};useEffect(()=>{if(!p||!v.current)return;let x=v.current.getBoundingClientRect(),R=window.innerHeight,A=window.innerWidth,N=300,U=d?380:120,$=4,_=x.right-N;_<10&&(_=x.left),_+N>A-10&&(_=A-N-10);let q=R-x.bottom,pe=x.top,Te;q>=U+$?Te=x.bottom+$:pe>=U+$?Te=x.top-U-$:Te=q>=pe?x.bottom+$:Math.max(10,x.top-U-$),C({top:Te,left:_});},[d,p]),useEffect(()=>{let x=R=>{h.current&&!h.current.contains(R.target)&&!v.current?.contains(R.target)&&(m(false),u(""));};if(p)return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[p]),useEffect(()=>{let x=R=>{R.key==="Escape"&&(m(false),u(""));};if(p)return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[p]);let k=x=>{let R=t.includes(x),A=a.find(N=>N.id===x);if(c(null),R){let N=t.filter(U=>U!==x);r(N),N.length===0&&g(false);}else {if(s&&rn(a,x,e)){let U=`Cannot add "${A?.title||x}" as dependency - would create circular reference`;c(U),n?.(x,A?.title||x),setTimeout(()=>c(null),3e3);return}r([...t,x]),g(true);}},y=()=>{let x=!d;g(x),x||r([]);},S=a.filter(x=>x.id!==e).filter(x=>x.title.toLowerCase().includes(i.toLowerCase())||x.id.toLowerCase().includes(i.toLowerCase())),w=t.length>0?"#3B82F6":"#BDC3C7";return jsxs("div",{className:`relative ${o||""}`,children:[jsxs("button",{ref:v,onClick:()=>p?m(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:w,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),t.length>0&&jsx("span",{className:"text-xs font-medium",style:{color:w},children:t.length})]}),p&&jsx(ht,{children:jsxs("div",{ref:h,className:"dependencies-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${b.top}px`,left:`${b.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:y,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:x=>u(x.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(x=>{let R=t.includes(x.id);return jsxs("button",{onClick:()=>k(x.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:R?"#3b82f6":"transparent",borderColor:R?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:R&&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:x.title}),jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:x.id})]})]},x.id)})})]}),t.length>0&&jsx("div",{className:"px-3 py-2 border-t border-white/5",children:jsx("button",{onClick:()=>{r([]),g(false),m(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 pr=memo(({card:e,render:t,onClick:a,isSelected:r,disableDrag:o,className:s,onUpdate:n,availableUsers:p=[],allCards:m=[]})=>{let{attributes:i,listeners:u,setNodeRef:d,transform:g,transition:b,isDragging:C}=useSortable({id:e.id,disabled:o,data:{type:"card",card:e}}),T={transform:Zo.Transform.toString(g),transition:b};if(t)return jsx("div",{ref:d,style:T,...i,...u,onClick:()=>a?.(e),children:t(e)});let c=p.filter(k=>e.assignedUserIds?.includes(k.id)),h=e.progress===100,v=(e.attachments||[]).filter(k=>k.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:k=>{k.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:k=>{k.currentTarget.style.display="none";}})}),v.length>0&&!e.coverImage&&jsx("div",{className:"asakaa-card-attachments mb-3",children:v.length===1&&v[0]?jsx("img",{src:v[0].url,alt:v[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:k=>{k.currentTarget.style.display="none";}}):jsx("div",{className:"grid grid-cols-2 gap-1",children:v.slice(0,4).map((k,y)=>jsxs("div",{className:"relative",children:[jsx("img",{src:k.url,alt:k.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";}}),y===3&&v.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:["+",v.length-4]})})]},k.id))})}),jsx("h3",{className:"asakaa-card-title mb-2",style:{textDecoration:h?"line-through":"none",opacity:h?.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:k=>k.stopPropagation(),className:"priority-selector",children:jsx(Or,{priority:e.priority,onChange:k=>n?.(e.id,{priority:k})})}),jsx("div",{onClick:k=>k.stopPropagation(),className:"date-picker",children:jsx(To,{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:(k,y)=>n?.(e.id,{startDate:k,endDate:y})})}),p.length>0&&jsx("div",{onClick:k=>k.stopPropagation(),className:"user-selector",children:jsx(Ur,{assignedUsers:c,availableUsers:p,onChange:k=>n?.(e.id,{assignedUserIds:k.map(y=>y.id)})})}),jsx("div",{onClick:k=>k.stopPropagation(),className:"dependencies-selector",children:jsx(Do,{currentCardId:e.id,dependencies:Array.isArray(e.dependencies)?e.dependencies.map(k=>typeof k=="string"?k:k.taskId):[],availableTasks:m,onChange:k=>n?.(e.id,{dependencies:k})})})]}),e.labels&&e.labels.length>0&&jsx("div",{className:"flex flex-wrap gap-1",children:e.labels.slice(0,3).map(k=>jsx("span",{className:"asakaa-label",children:k},k))}),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)));pr.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"}},ql=({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 Xl({status:e="todo",onChange:t,className:a,customStatuses:r=[]}){let[o,s]=useState(false),[n,p]=useState({top:0,left:0}),m=useRef(null),i=useRef(null),u=[...Object.entries(on).map(([c,h])=>({id:c,label:h.label,color:h.color,icon:h.icon})),...r.filter(c=>!Object.keys(on).includes(c.id)).map(c=>({id:c.id,label:c.title,color:c.color||"#8B5CF6",icon:"circle-dot"}))],d=()=>{let c=on[e];if(c)return {...c,id:e};let h=r.find(v=>v.id===e);return h?{id:h.id,label:h.title,color:h.color||"#8B5CF6",icon:"circle-dot"}:{...on.todo,id:"todo"}},g=()=>{if(!i.current)return;let c=i.current.getBoundingClientRect(),h=window.innerHeight,v=window.innerWidth,l=180,k=280,y=4,S=c.right-l;S<10&&(S=c.left),S+l>v-10&&(S=v-l-10);let w=h-c.bottom,x=c.top,R;w>=k+y?R=c.bottom+y:x>=k+y?R=c.top-k-y:R=w>=x?c.bottom+y:Math.max(10,c.top-k-y),p({top:R,left:S}),s(true);};useEffect(()=>{let c=h=>{m.current&&!m.current.contains(h.target)&&!i.current?.contains(h.target)&&s(false);};if(o)return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[o]),useEffect(()=>{let c=h=>{h.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[o]);let b=c=>{t(c),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(ql,{icon:C.icon,color:T})}),o&&jsx(ht,{children:jsxs("div",{ref:m,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(c=>jsxs("button",{onClick:()=>b(c.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:c.color,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(ql,{icon:c.icon,color:c.color}),jsx("span",{className:"font-semibold",children:c.label}),e===c.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"})})]},c.id))})]})})]})}function Jl({columnTitle:e,onRename:t,onDelete:a,isDeletable:r=false,className:o}){let[s,n]=useState(false),[p,m]=useState(false),[i,u]=useState(e),[d,g]=useState({top:0,left:0}),b=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=k=>{b.current&&!b.current.contains(k.target)&&!C.current?.contains(k.target)&&(n(false),m(false));};if(s)return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[s]),useEffect(()=>{let l=k=>{k.key==="Escape"&&(n(false),m(false),u(e));};if(s)return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[s,e]),useEffect(()=>{p&&T.current&&(T.current.focus(),T.current.select());},[p]);let c=()=>{m(true),u(e);},h=()=>{let l=i.trim();l&&l!==e&&t(l),m(false),n(false),u(e);},v=l=>{l.key==="Enter"?h():l.key==="Escape"&&(m(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(ht,{children:jsx("div",{ref:b,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:p?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:v,onBlur:h,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:c,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:p,availableUsers:m,allCards:i,enableVirtualization:u,cardHeight:d=120,isCollapsed:g,onToggleCollapse:b,onColumnRename:C,onColumnDelete:T,isDeletable:c=false,className:h})=>{let{setNodeRef:v,isOver:l}=useDroppable({id:e.id,data:{type:"column",column:e}}),k=useRef(null),y=u??Cl(t.length),S=useVirtualizer({count:t.length,getScrollElement:()=>k.current,estimateSize:()=>d,enabled:y});if(a)return jsx("div",{ref:v,className:h,children:a(e,t)});let x=(()=>{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}})(),R=x.state==="exceeded",A=()=>"asakaa-column-count";return jsxs("div",{ref:v,className:f("asakaa-column",l&&"ring-2 ring-asakaa-accent-blue",R&&"ring-2 ring-asakaa-accent-red",h),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(A()),children:[t.length,e.wipLimit&&` / ${e.wipLimit}`]}),e.wipLimit&&x.state!=="none"&&jsxs("span",{className:"text-xs font-medium flex items-center",title:`${x.percentage.toFixed(0)}% capacity${e.wipLimitType==="hard"?" (Hard limit - blocks new cards)":" (Soft limit - shows warning)"}`,children:[x.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"})]}),x.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"})]}),x.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"})}),x.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(Jl,{columnTitle:e.title,onRename:N=>C?.(e.id,N),onDelete:T?()=>T(e.id):void 0,isDeletable:c}),b&&jsx("button",{onClick:b,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:k,className:"asakaa-column-cards",style:{maxHeight:y?"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"})}):y?jsx("div",{style:{height:`${S.getTotalSize()}px`,position:"relative"},children:S.getVirtualItems().map(N=>{let U=t[N.index];return U?jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${N.start}px)`},children:jsx(pr,{card:U,render:r,onClick:n,onUpdate:p,availableUsers:m,allCards:i})},U.id):null})}):t.map(N=>jsx(pr,{card:N,render:r,onClick:n,onUpdate:p,availableUsers:m,allCards:i},N.id))})})]})});io.displayName="Column";function us({title:e,onSave:t,className:a}){let[r,o]=useState(false),[s,n]=useState(e),p=useRef(null);useEffect(()=>{r&&p.current&&(p.current.focus(),p.current.select());},[r]);let m=()=>{let u=s.trim();u&&u!==e?t(u):n(e),o(false);},i=u=>{u.key==="Enter"?m():u.key==="Escape"&&(n(e),o(false));};return r?jsx("input",{ref:p,type:"text",value:s,onChange:u=>n(u.target.value),onBlur:m,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[p,m]=useState(false),[i,u]=useState(""),[d,g]=useState(false),[b,C]=useState(dn[10]||"#3B82F6"),[T,c]=useState({top:0,left:0}),h=useRef(null),v=useRef(null),l=useRef(null),k=useRef(null),y=t.filter(N=>N.name.toLowerCase().includes(i.toLowerCase())),S=t.some(N=>N.name.toLowerCase()===i.toLowerCase());useEffect(()=>{if(p&&v.current){let N=v.current.getBoundingClientRect();c({top:N.bottom+6,left:N.left});}},[p]),useEffect(()=>{let N=U=>{let $=U.target,_=h.current?.contains($),q=l.current?.contains($);!_&&!q&&(m(false),u(""),g(false));};if(p)return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[p]),useEffect(()=>{p&&k.current&&k.current.focus();},[p]);let w=N=>{let U=e.some($=>$.id===N.id);a(U?e.filter($=>$.id!==N.id):[...e,N]);},x=async()=>{if(!(!r||!i.trim())){g(true);try{let N=await r(i.trim(),b);N&&(a([...e,N]),u(""),C(dn[Math.floor(Math.random()*dn.length)]||"#3B82F6"));}finally{g(false);}}},R=(N,U)=>{U.stopPropagation(),a(e.filter($=>$.id!==N));},A={backgroundColor:`${o.textTertiary}15`,border:`1px solid ${o.borderLight}`,color:o.textSecondary};return jsxs("div",{ref:h,className:"relative",children:[jsxs("button",{ref:v,type:"button",onClick:()=>!s&&m(!p),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:p&&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:k,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&&x();}})}),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:U=>R(N.id,U),children:[N.name,jsx(X,{className:"w-3 h-3"})]},N.id))})]}),jsx("div",{className:"max-h-[200px] overflow-y-auto p-1",children:y.length>0?y.map(N=>{let U=e.some($=>$.id===N.id);return jsxs("button",{type:"button",onClick:()=>w(N),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors",style:{backgroundColor:U?`${N.color}15`:"transparent",color:o.textPrimary},onMouseEnter:$=>{U||($.currentTarget.style.backgroundColor=o.hoverBg);},onMouseLeave:$=>{U||($.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}),U&&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: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:b===N?`2px solid ${N}`:"none",outlineOffset:"2px"}},N))}),jsxs("button",{type:"button",onClick:x,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:b,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 fs({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 td({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(fs,{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 sd(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 du(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:p=[],availableTags:m=[],onCreateTag:i,attachments:u=[],onUploadAttachments:d,onDeleteAttachment:g,availableTasks:b=[],comments:C=[],onAddComment:T,currentUser:c}){let h=s==="dark",v={textTertiary:h?"#6B7280":"#9CA3AF",textSecondary:h?"#9CA3AF":"#6B7280",textPrimary:h?"#FFFFFF":"#111827",borderLight:h?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",border:h?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",bgPrimary:h?"#1A1D25":"#FFFFFF",bgSecondary:h?"#0F1117":"#F9FAFB",hoverBg:h?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},l=e&&"title"in e&&!("name"in e),k=e,[y,S]=useState(e?sd(e,p):null),[w,x]=useState(false),[R,A]=useState(false),[N,U]=useState(false),[$,_]=useState(null),[q,pe]=useState(new Date),[Te,Ze]=useState(false),[Oe,Be]=useState(false),[L,B]=useState(""),[D,W]=useState(false),[Y,O]=useState(false),[ie,ve]=useState(false),[Ee,fe]=useState(""),We=useRef(null),[Re,Le]=useState(""),ze=useRef(null),[yt,nt]=useState(""),[z,ne]=useState(false);useEffect(()=>{if(e){let E=sd(e,p);S(E),fe(E.description||""),Le(E.name||"");}},[e?.id,p]),useEffect(()=>()=>{We.current&&clearTimeout(We.current),ze.current&&clearTimeout(ze.current);},[]);let le=useCallback(E=>{S(E),l&&o&&k?o(du(E,k)):r&&r(E);},[l,k,o,r]),we=useCallback(()=>{x(false),A(false),U(false),_(null),Be(false),B(""),W(false);},[]),$e=useCallback((E,X)=>{if(!y)return;let be={...y,[E]:X};le(be);},[y,le]),et=useCallback(E=>{fe(E),We.current&&clearTimeout(We.current),We.current=setTimeout(()=>{if(y){let X={...y,description:E};le(X);}},800);},[y,le]),vt=useCallback(E=>{Le(E),ze.current&&clearTimeout(ze.current),ze.current=setTimeout(()=>{if(y&&E.trim()){let X={...y,name:E.trim()};le(X);}},800);},[y,le]),Pe=useCallback(async()=>{if(!(!y||!yt.trim()||!T)){ne(true);try{await T(y.id,yt.trim()),nt("");}finally{ne(false);}}},[y,yt,T]),Vt=useCallback(E=>{let X=typeof E=="string"?new Date(E):E,Ae=new Date().getTime()-X.getTime(),Ge=Math.floor(Ae/6e4),Ye=Math.floor(Ae/36e5),Ue=Math.floor(Ae/864e5);return Ge<1?n==="es"?"Ahora":"Just now":Ge<60?n==="es"?`Hace ${Ge} min`:`${Ge}m ago`:Ye<24?n==="es"?`Hace ${Ye}h`:`${Ye}h ago`:Ue<7?n==="es"?`Hace ${Ue}d`:`${Ue}d ago`:X.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})},[n]),ft=useCallback(E=>{if(!y)return;let X=y.progress||0;E==="completed"?X=100:E==="in-progress"&&X===0?X=10:E==="todo"&&(X=0);let be={...y,status:E,progress:X};le(be),x(false);},[y,le]),st=useCallback((E,X)=>{if(!y)return;let be={...y,startDate:E,endDate:X};le(be);},[y,le]),mt=useCallback(()=>{let E=q.getFullYear(),X=q.getMonth(),be=new Date(E,X,1),Ge=new Date(E,X+1,0).getDate(),Ye=be.getDay(),Ue=[],ot=new Date(E,X,0).getDate();for(let V=Ye-1;V>=0;V--)Ue.push({date:new Date(E,X-1,ot-V),isCurrentMonth:false});for(let V=1;V<=Ge;V++)Ue.push({date:new Date(E,X,V),isCurrentMonth:true});let pt=42-Ue.length;for(let V=1;V<=pt;V++)Ue.push({date:new Date(E,X+1,V),isCurrentMonth:false});return Ue},[q]),Lt=useCallback(async E=>{if(E.preventDefault(),E.stopPropagation(),O(false),!y||!d)return;let X=Array.from(E.dataTransfer.files);if(X.length!==0){ve(true);try{await d(y.id,X);}finally{ve(false);}}},[y,d]),va=useCallback(async E=>{if(!y||!d||!E.target.files)return;let X=Array.from(E.target.files);if(X.length!==0){ve(true);try{await d(y.id,X);}finally{ve(false);}E.target.value="";}},[y,d]),ee=useCallback(E=>{E.preventDefault(),E.stopPropagation(),O(true);},[]),te=useCallback(E=>{E.preventDefault(),E.stopPropagation(),O(false);},[]),it=useCallback(E=>E<1024?`${E} B`:E<1024*1024?`${(E/1024).toFixed(1)} KB`:`${(E/(1024*1024)).toFixed(1)} MB`,[]),ae=useCallback(E=>E.startsWith("image/")?Image:E.includes("pdf")||E.includes("document")?FileText:File,[]);return !t||!y?null:jsx(AnimatePresence,{children:t&&y&&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",h?"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",h?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:f("w-4 h-4",h?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:f("text-xs px-2 py-0.5 rounded",h?"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",h?"text-[#6B7280]":"text-gray-400"),children:y.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",h?"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",h?"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",h?"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",h?"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=y.progress===100?0:100,be={...y,progress:E,status:E===100?"completed":"todo"};le(be);},className:f("mt-2 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors flex-shrink-0",y.progress===100?"bg-green-500 border-green-500":h?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:y.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("input",{type:"text",value:Re,onChange:E=>vt(E.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",y.progress===100?"line-through text-[#6B7280]":h?"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",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{we(),x(!w);},className:f("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",y.progress===100||y.status==="completed"?"bg-green-500/20 text-green-400":y.progress&&y.progress>0||y.status==="in-progress"?"bg-blue-500/20 text-blue-400":h?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:y.progress===100||y.status==="completed"?n==="es"?"COMPLETADO":"DONE":y.progress&&y.progress>0||y.status==="in-progress"?n==="es"?"EN PROGRESO":"IN PROGRESS":n==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:w&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>x(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]",h?"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:()=>ft(E.id),className:f("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",h?"hover:bg-white/5":"hover:bg-gray-50",y.status===E.id&&(h?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:f("w-2 h-2 rounded-full",E.color)}),jsx("span",{className:h?"text-white":"text-gray-900",children:E.label})]},E.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(User,{className:f("w-4 h-4",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{we(),U(!N);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",h?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[y.assignees&&y.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[y.assignees.slice(0,3).map((E,X)=>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()},X)),y.assignees.length>3&&jsxs("span",{className:f("text-xs",h?"text-[#6B7280]":"text-gray-400"),children:["+",y.assignees.length-3]})]}):jsx("span",{className:f("text-sm",h?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Agregar":"Add"}),jsx(ChevronDown,{className:f("w-3 h-3",h?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:N&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>U(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",h?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:p.length>0?p.map(E=>{let X=y.assignees?.some(be=>be.name===E.name);return jsxs("button",{onClick:()=>{let be=y.assignees||[],Ae;X?Ae=be.filter(Ge=>Ge.name!==E.name):Ae=[...be,E],$e("assignees",Ae);},className:f("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",h?"hover:bg-white/5":"hover:bg-gray-50",X&&(h?"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:f("flex-1",h?"text-white":"text-gray-900"),children:E.name}),X&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},E.name)}):jsx("div",{className:f("px-3 py-4 text-sm text-center",h?"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",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{_($?null:"start"),pe(y.startDate||new Date);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",h?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[y.startDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Inicio":"Start"),jsx("span",{className:f("mx-1",h?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),y.endDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Fin":"End")]}),jsx(AnimatePresence,{children:$&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>_(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",h?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:E=>E.stopPropagation(),children:[jsxs("div",{className:f("w-44 py-2 border-r",h?"border-white/10":"border-gray-200"),children:[(()=>{let E=new Date,X=new Date(E);X.setDate(E.getDate()+1);let be=new Date(E);be.setDate(E.getDate()+((6-E.getDay()+7)%7||7));let Ae=new Date(E);Ae.setDate(E.getDate()+((1-E.getDay()+7)%7||7));let Ge=new Date(E);Ge.setDate(E.getDate()+(6-E.getDay()+7)%7+7);let Ye=new Date(E);Ye.setDate(E.getDate()+14);let Ue=new Date(E);return Ue.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:X,display:X.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:Ae,display:n==="es"?"lun.":"mon."},{label:n==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:Ge,display:Ge.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"2 semanas":"2 weeks",date:Ye,display:Ye.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:Ue,display:Ue.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((pt,V)=>jsxs("button",{className:f("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",h?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if($==="start"){let re=y.endDate&&pt.date>y.endDate?pt.date:y.endDate;st(pt.date,re),_("end");}else {let re=y.startDate&&pt.date<y.startDate?pt.date:y.startDate;st(re,pt.date),_(null);}},children:[jsx("span",{children:pt.label}),jsx("span",{className:f("text-xs",h?"text-[#6B7280]":"text-gray-400"),children:pt.display})]},V))})(),jsx("div",{className:f("border-t mt-2 pt-2",h?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{st(void 0,void 0),_(null);},className:f("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",h?"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",h?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:$==="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",h?"text-white":"text-gray-900"),children:q.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>pe(new Date),className:f("p-1 rounded text-sm transition-colors",h?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>pe(new Date(q.getFullYear(),q.getMonth()-1)),className:f("p-1 rounded",h?"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:()=>pe(new Date(q.getFullYear(),q.getMonth()+1)),className:f("p-1 rounded",h?"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:f("w-8 h-8 flex items-center justify-center text-xs",h?"text-[#6B7280]":"text-gray-400"),children:E},E))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:mt().map((E,X)=>{let be=E.date.toDateString()===new Date().toDateString(),Ae=y.startDate?.toDateString()===E.date.toDateString(),Ge=y.endDate?.toDateString()===E.date.toDateString(),Ye=Ae||Ge,Ue=y.startDate&&y.endDate&&E.date>=y.startDate&&E.date<=y.endDate;return jsx("button",{onClick:()=>{let ot=new Date(E.date);if($==="start"){let pt=y.endDate&&ot>y.endDate?ot:y.endDate;st(ot,pt),_("end");}else {let pt=y.startDate&&ot<y.startDate?ot:y.startDate;st(pt,ot),_(null);}},className:f("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!E.isCurrentMonth&&(h?"text-[#4B5563]":"text-gray-300"),E.isCurrentMonth&&(h?"text-white":"text-gray-900"),be&&"ring-2 ring-[#3B82F6]",Ae&&"bg-[#3B82F6] text-white",Ge&&!Ae&&"bg-[#7C3AED] text-white",Ue&&!Ye&&(h?"bg-[#7C3AED]/20":"bg-purple-100"),!Ye&&(h?"hover:bg-white/10":"hover:bg-gray-100")),children:E.date.getDate()},X)})})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:f("w-4 h-4",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{we(),A(!R);},className:f("text-xs px-2 py-1 rounded font-medium transition-all hover:ring-2 hover:ring-white/20",y.priority==="high"||y.priority==="urgent"?"bg-red-500/20 text-red-400":y.priority==="medium"?"bg-yellow-500/20 text-yellow-400":y.priority==="low"?"bg-green-500/20 text-green-400":h?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:y.priority?y.priority==="high"||y.priority==="urgent"?n==="es"?"Alta":"High":y.priority==="medium"?n==="es"?"Media":"Medium":n==="es"?"Baja":"Low":n==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:R&&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:f("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",h?"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:()=>{$e("priority",E.id),A(false);},className:f("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",h?"hover:bg-white/5":"hover:bg-gray-50",y.priority===E.id&&(h?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:f("w-2 h-2 rounded-full",E.color)}),jsx("span",{className:h?"text-white":"text-gray-900",children:E.label})]},E.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:f("w-4 h-4",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:f("text-sm",h?"text-white":"text-gray-900"),children:y.startDate&&y.endDate?`${Math.ceil((y.endDate.getTime()-y.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",h?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[Te?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:y.progress||0,onChange:E=>{let X=parseInt(E.target.value),be=y.status;X===100?be="completed":X>0?be="in-progress":be="todo";let Ae={...y,progress:X,status:be};le(Ae);},onBlur:()=>Ze(false),className:f("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",h?"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:()=>Ze(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",h?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:f("h-full rounded-full transition-all",y.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${y.progress||0}%`}})}),jsxs("span",{className:f("text-sm font-medium min-w-[40px]",h?"text-white":"text-gray-900"),children:[y.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:f("w-4 h-4",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Etiquetas":"Tags"}),jsx(nr,{selectedTags:y.tags||[],availableTags:m,onChange:E=>{$e("tags",E);},onCreateTag:i,theme:v})]}),jsxs("div",{className:"flex items-start gap-3 relative",children:[jsx(Link2,{className:f("w-4 h-4 mt-1.5",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24 mt-1",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[y.dependencies&&y.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:y.dependencies.map(E=>{let X$1=b.find(be=>be.id===E);return jsxs("span",{className:f("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",h?"bg-blue-500/20 text-blue-400":"bg-blue-100 text-blue-700"),children:[X$1?.name||E.slice(0,8),jsx("button",{onClick:()=>{let be=(y.dependencies||[]).filter(Ae=>Ae!==E);$e("dependencies",be);},className:f("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:()=>{we(),Be(!Oe);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",h?"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",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:Oe&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{Be(false),B("");}}),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]",h?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[jsx("div",{className:f("p-2 border-b",h?"border-white/10":"border-gray-200"),children:jsx("input",{type:"text",value:L,onChange:E=>B(E.target.value),placeholder:n==="es"?"Buscar tarea...":"Search task...",className:f("w-full px-3 py-2 rounded-md text-sm outline-none",h?"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:b.length>0?b.filter(E=>E.id!==y.id).filter(E=>L===""||E.name.toLowerCase().includes(L.toLowerCase())).map(E=>{let X=y.dependencies?.includes(E.id);return jsxs("button",{onClick:()=>{let be=y.dependencies||[],Ae;X?Ae=be.filter(Ge=>Ge!==E.id):Ae=[...be,E.id],$e("dependencies",Ae);},className:f("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",h?"hover:bg-white/5":"hover:bg-gray-50",X&&(h?"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",X?"bg-blue-500 border-blue-500":h?"border-white/30":"border-gray-300"),children:X&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("span",{className:f("block truncate",h?"text-white":"text-gray-900"),children:E.name}),jsx("span",{className:f("text-xs",h?"text-[#6B7280]":"text-gray-400"),children:E.id.slice(0,8)})]})]},E.id)}):jsx("div",{className:f("px-3 py-4 text-sm text-center",h?"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",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:"Color"}),jsxs("button",{onClick:()=>{we(),W(!D);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",h?"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:y.color||"#6366F1"}}),jsx("span",{className:f("text-sm",h?"text-white":"text-gray-900"),children:sr.find(E=>E.value===y.color)?.name||(n==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:f("w-3 h-3",h?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:D&&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 p-3",h?"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(E=>{let X=y.color===E.value;return jsx("button",{onClick:()=>{$e("color",E.value),W(false);},className:f("w-7 h-7 rounded-full flex items-center justify-center transition-all",X&&"ring-2 ring-offset-2",h?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:E.value,outlineColor:X?E.value:void 0},title:E.name,children:X&&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:f("w-4 h-4",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"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:y.isMilestone||false,onChange:E=>$e("isMilestone",E.target.checked),className:f("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",y.isMilestone?"bg-purple-500 border-purple-500":h?"border-white/30 bg-transparent":"border-gray-300 bg-transparent","checked:bg-purple-500 checked:border-purple-500")}),jsx("span",{className:f("text-sm",h?"text-white":"text-gray-900"),children:n==="es"?"Marcar como hito":"Mark as milestone"})]})]})]}),jsxs("div",{className:f("mt-6 pt-4 border-t",h?"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",h?"text-[#6B7280]":"text-gray-400")}),jsx("h3",{className:f("text-sm font-semibold",h?"text-white":"text-gray-900"),children:n==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:Ee,onChange:E=>et(E.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",h?"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",h?"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",h?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:f("text-sm font-semibold mb-3",h?"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",h?"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",h?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:f("text-sm font-semibold mb-3",h?"text-white":"text-gray-900"),children:n==="es"?"Subtareas":"Subtasks"}),y.subtasks&&y.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:y.subtasks.map(E=>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",E.progress===100?"bg-green-500 border-green-500":h?"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:f("text-sm",E.progress===100?"line-through text-[#6B7280]":h?"text-white":"text-gray-900"),children:E.name})]},E.id))}),jsxs("button",{className:f("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",h?"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",h?"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",h?"text-white":"text-gray-900"),children:n==="es"?"Listas de control":"Checklists"}),jsx("button",{className:f("p-1 rounded transition-colors",h?"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",h?"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",h?"border-white/10":"border-gray-200"),children:[jsxs("h3",{className:f("text-sm font-semibold mb-3",h?"text-white":"text-gray-900"),children:[n==="es"?"Adjuntos":"Attachments",u.length>0&&jsxs("span",{className:f("ml-2 text-xs font-normal",h?"text-[#6B7280]":"text-gray-400"),children:["(",u.length,")"]})]}),u.length>0&&jsx("div",{className:"space-y-2 mb-4",children:u.map(E=>{let X=ae(E.type),be=E.type.startsWith("image/");return jsxs("div",{className:f("flex items-center gap-3 p-2 rounded-lg group transition-colors",h?"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:f("w-10 h-10 rounded flex items-center justify-center",h?"bg-white/10":"bg-gray-200"),children:jsx(X,{className:f("w-5 h-5",h?"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:f("text-sm font-medium truncate block hover:underline",h?"text-white":"text-gray-900"),children:E.name}),jsx("p",{className:f("text-xs",h?"text-[#6B7280]":"text-gray-400"),children:it(E.size)})]}),g&&jsx("button",{onClick:()=>g(E.id),className:f("p-1.5 rounded opacity-0 group-hover:opacity-100 transition-all",h?"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:ee,onDragLeave:te,onDrop:Lt,className:f("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",Y?h?"border-blue-500 bg-blue-500/10":"border-blue-400 bg-blue-50":h?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300",ie&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:va,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!d||ie}),ie?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",h?"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",Y?"text-blue-500":h?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:f("text-sm",h?"text-[#9CA3AF]":"text-gray-500"),children:Y?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",h?"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",h?"border-white/10 bg-[#0F1117]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:f("px-4 py-3 border-b",h?"border-white/10":"border-gray-200"),children:jsxs("h3",{className:f("text-sm font-semibold",h?"text-white":"text-gray-900"),children:[n==="es"?"Actividad":"Activity",C.length>0&&jsxs("span",{className:f("ml-2 text-xs font-normal",h?"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:f("text-sm font-medium",h?"text-white":"text-gray-900"),children:E.user?.name||(n==="es"?"Usuario":"User")}),jsx("span",{className:f("text-xs",h?"text-[#6B7280]":"text-gray-400"),children:Vt(E.createdAt)})]}),jsx("p",{className:f("text-sm break-words",h?"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:f("w-10 h-10 mb-3",h?"text-[#3B4252]":"text-gray-300")}),jsx("p",{className:f("text-sm",h?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"Sin actividad reciente":"No recent activity"})]})}),jsx("div",{className:f("p-4 border-t",h?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-start gap-2",children:[c&&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:c.color||"#8B5CF6"},children:c.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:f("flex-1 flex items-center gap-2 px-3 py-2 rounded-lg",h?"bg-white/5":"bg-white border border-gray-200"),children:[jsx("input",{type:"text",value:yt,onChange:E=>nt(E.target.value),onKeyDown:E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),Pe());},placeholder:n==="es"?"Escribe un comentario...":"Write a comment...",disabled:z||!T,className:f("flex-1 bg-transparent text-sm outline-none",h?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400",(z||!T)&&"opacity-50")}),jsx("button",{onClick:Pe,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":h?"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 xs(){let[e,t]=useState(()=>dragStore.getState());useEffect(()=>dragStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{dragStore.setState(r);},[]);return [e,a]}function Sr({board:e,callbacks:t,onCardClick:a,renderProps:r,config:o,availableUsers:s=[],className:n,style:p,isLoading:m,error:i,children:u,availableTags:d=[],onCreateTag:g,attachmentsByCard:b,onUploadAttachments:C,onDeleteAttachment:T,comments:c,onAddComment:h,currentUser:v,onTaskOpen:l}){let[k,y]=xs(),[S,w]=useState(null),x=o?.theme||"dark",R=x==="dark"||x==="neutral",A=R?"dark":"",N=useCallback((D,W)=>{t.onCardUpdate?.(D,W);},[t]),U=useCallback((D,W)=>{t.onColumnUpdate?.(D,{title:W});},[t]),$=useCallback(D=>{t.onColumnDelete?.(D);},[t]),_=["todo","in-progress","completed"],q=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),pe=useMemo(()=>{let D=new Map;return e.columns.forEach(W=>{let Y=W.cardIds.map(O=>e.cards.find(ie=>ie.id===O)).filter(O=>O!==void 0).sort((O,ie)=>O.position-ie.position);D.set(W.id,Y);}),D},[e.cards,e.columns]),Te=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(W=>typeof W=="string"?W:W.taskId):[]})),[e.cards]),Ze=useCallback(D=>{let{active:W}=D,Y=e.cards.find(O=>O.id===W.id);Y&&y({isDragging:true,draggedCardId:Y.id,sourceColumnId:Y.columnId,targetColumnId:Y.columnId});},[e.cards,y]),Oe=useCallback(D=>{let{active:W,over:Y}=D;if(!Y||!e.cards.find(ve=>ve.id===W.id))return;let ie=null;Y.data.current?.type==="column"?ie=Y.id:Y.data.current?.type==="card"&&(ie=e.cards.find(Ee=>Ee.id===Y.id)?.columnId||null),ie&&ie!==k.targetColumnId&&y({...k,targetColumnId:ie});},[e.cards,k,y]),Be=useCallback(async D=>{let{active:W,over:Y}=D;if(y({isDragging:false,draggedCardId:null,sourceColumnId:null,targetColumnId:null}),!Y)return;let O=e.cards.find(fe=>fe.id===W.id);if(!O)return;let ie,ve;if(Y.data.current?.type==="column"){ie=Y.id;let fe=pe.get(ie)||[];ve=os(fe,0);}else {let fe=e.cards.find(Le=>Le.id===Y.id);if(!fe)return;ie=fe.columnId;let We=pe.get(ie)||[],Re=We.findIndex(Le=>Le.id===Y.id);ve=os(We,Re);}let Ee=e.columns.find(fe=>fe.id===ie);if(Ee&&Ee.wipLimit&&Ee.wipLimitType==="hard"){let fe=pe.get(ie)||[];if(O.columnId!==ie&&fe.length>=Ee.wipLimit){t.onWipLimitExceeded?.(Ee,O);return}}(O.columnId!==ie||O.position!==ve)&&await t.onCardMove?.(O.id,ie,ve);},[e.cards,e.columns,pe,t,y]),L=useCallback(D=>{w(D),a?.(D),l?.(D.id);},[a,l]),B=useCallback(D=>{t.onCardUpdate?.(D.id,D),w(D);},[t]);return m?jsx("div",{className:f("asakaa-board",A,n),style:p,children:jsx(ku,{columnCount:3})}):i?jsx("div",{className:f("asakaa-board",A,n),style:p,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(Il,{themeName:x,children:[jsxs(DndContext,{sensors:q,collisionDetection:closestCorners,onDragStart:Ze,onDragOver:Oe,onDragEnd:Be,children:[jsxs("div",{className:f("asakaa-board",A,n),style:p,"data-theme":x,children:[e.columns.sort((D,W)=>D.position-W.position).map(D=>{let W=pe.get(D.id)||[],Y=!_.includes(D.id);return jsx(io,{column:D,cards:W,renderCard:r?.renderCard,renderColumn:r?.renderColumn,renderHeader:r?.renderColumnHeader,renderEmptyState:r?.renderEmptyState,onCardClick:L,onCardUpdate:N,onColumnRename:U,onColumnDelete:$,isDeletable:Y,availableUsers:s,allCards:e.cards,enableVirtualization:o?.enableVirtualization,cardHeight:o?.cardHeight},D.id)}),u]}),jsx(DragOverlay,{children:k.draggedCardId?jsx(pr,{card:e.cards.find(D=>D.id===k.draggedCardId),render:r?.renderCardOverlay||r?.renderCard,disableDrag:true,className:"opacity-90 rotate-3 shadow-2xl"}):null})]}),jsx(Gr,{task:S,isOpen:!!S,onClose:()=>w(null),onCardUpdate:B,theme:R?"dark":"light",locale:o?.locale==="es"?"es":"en",availableUsers:s,availableTags:d,onCreateTag:g,attachments:S?b?.get(S.id)||[]:[],onUploadAttachments:C,onDeleteAttachment:T,availableTasks:Te,comments:c,onAddComment:h,currentUser:v})]})}function ku({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 Du={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)"},Su={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)"},Eu={newTask:"Nueva Tarea",selectColumn:"Seleccionar columna",export:"Exportar",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"},Pu={newTask:"New Task",selectColumn:"Select column",export:"Export",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"};function Mu({columns:e,onSelect:t,theme:a,t:r,createTaskLabel:o}){let[s,n]=useState(false),p=useRef(null);useEffect(()=>{let i=u=>{p.current&&!p.current.contains(u.target)&&n(false);};return s&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[s]);let m=i=>{t(i),n(false);};return jsxs("div",{ref:p,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:()=>m(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 Au({theme:e,t,onExportCSV:a,onExportJSON:r,onExportExcel:o}){let[s,n]=useState(false),[p,m]=useState(null),i=useRef(null);if(useEffect(()=>{let b=C=>{i.current&&!i.current.contains(C.target)&&n(false);};return s&&document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[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(b=>b.handler),g=async(b,C)=>{if(C){m(b);try{await C();}catch(T){console.error(`Export ${b} failed:`,T);}finally{m(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((b,C)=>jsxs(motion.button,{onClick:()=>g(b.id,b.handler),disabled:p!==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:p===b.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):b.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:b.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:b.description})]})]},b.id))})})})]})}function Fu({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 ws({columns:e,onCreateTask:t,createTaskLabel:a,theme:r="dark",locale:o="es",useColumnSelector:s=false,onExportCSV:n,onExportJSON:p,onExportExcel:m,translations:i}){let u=r==="dark"?Du:Su,d={...o==="es"?Eu:Pu,...i},g=n||p||m;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(Au,{theme:u,t:d,onExportCSV:n,onExportJSON:p,onExportExcel:m}),t&&jsx("div",{className:"w-px h-6",style:{backgroundColor:u.borderLight}})]}),t&&(s?jsx(Mu,{columns:e,onSelect:t,theme:u,t:d,createTaskLabel:a}):jsx(Fu,{onClick:()=>t(),label:a||d.newTask}))]})})}function Ts({onAddColumn:e,className:t,placeholder:a="Nombre de la columna...",buttonLabel:r="Agregar Columna",disabled:o=false}){let[s,n]=useState(false),[p,m]=useState(""),i=useCallback(()=>{let g=p.trim();g&&(e(g),m(""),n(false));},[p,e]),u=useCallback(g=>{g.key==="Enter"?(g.preventDefault(),i()):g.key==="Escape"&&(m(""),n(false));},[i]),d=useCallback(()=>{setTimeout(()=>{p.trim()||n(false);},150);},[p]);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:p,onChange:g=>m(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:!p.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:()=>{m(""),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 Ns({columnId:e,onAddCard:t,availableUsers:a=[],className:r,placeholder:o,buttonLabel:s,disabled:n=false,theme:p="dark",locale:m="es"}){let[i,u]=useState(false),[d,g]=useState(false),[b,C]=useState(""),[T,c]=useState([]),[h,v]=useState(""),[l,k]=useState(""),[y,S]=useState(""),[w,x]=useState(false),[R,A]=useState(false),[N,U]=useState(false),$=useRef(null),_=useRef(null),q={placeholder:o||(m==="es"?"Nombre de la tarea...":"Task Name..."),buttonLabel:s||(m==="es"?"Agregar Tarea":"Add Task"),save:m==="es"?"Guardar":"Save",addAssignee:m==="es"?"Agregar asignado":"Add assignee",addDates:m==="es"?"Agregar fechas":"Add dates",addPriority:m==="es"?"Agregar prioridad":"Add priority",startDate:m==="es"?"Inicio":"Start",endDate:m==="es"?"Fin":"End",low:m==="es"?"Baja":"Low",medium:m==="es"?"Media":"Medium",high:m==="es"?"Alta":"High",urgent:m==="es"?"Urgente":"Urgent"},pe=useCallback(()=>{C(""),c([]),v(""),k(""),S(""),x(false),A(false),U(false),u(false);},[]);useEffect(()=>{i&&$.current&&$.current.focus();},[i]),useEffect(()=>{if(!i)return;let L=B=>{_.current&&!_.current.contains(B.target)&&(b.trim()||pe());};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[i,b,pe]);let Te=useCallback(async()=>{let L=b.trim();if(!(!L||d)){g(true);try{await t({name:L,columnId:e,assigneeIds:T.length>0?T:void 0,startDate:h?new Date(h):void 0,endDate:l?new Date(l):void 0,priority:y||void 0}),C(""),c([]),v(""),k(""),S(""),x(!1),A(!1),U(!1),$.current?.focus();}catch(B){console.error("Error creating card:",B);}finally{g(false);}}},[b,e,T,h,l,y,t,d]),Ze=useCallback(L=>{L.key==="Enter"&&!L.shiftKey?(L.preventDefault(),Te()):L.key==="Escape"&&pe();},[Te,pe]),Oe=useCallback(L=>{c(B=>B.includes(L)?B.filter(D=>D!==L):[...B,L]);},[]),Be=p==="dark";return i?jsxs("div",{ref:_,className:f("rounded-lg overflow-hidden shadow-lg",Be?"bg-[#1e1e2e]":"bg-white",r),style:{border:"2px solid #10b981"},children:[jsxs("div",{className:"p-3",children:[jsx("input",{ref:$,type:"text",value:b,onChange:L=>C(L.target.value),onKeyDown:Ze,placeholder:q.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",Be?"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:()=>x(!w),className:f("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",w||T.length>0?"bg-emerald-500/20 text-emerald-400":Be?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:q.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(!R),className:f("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",R||h||l?"bg-blue-500/20 text-blue-400":Be?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:q.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:()=>U(!N),className:f("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",N||y?y==="urgent"?"bg-red-500/20 text-red-400":y==="high"?"bg-orange-500/20 text-orange-400":y==="medium"?"bg-yellow-500/20 text-yellow-400":y==="low"?"bg-green-500/20 text-green-400":"bg-orange-500/20 text-orange-400":Be?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:q.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:Te,disabled:!b.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"}):q.save})]})]}),w&&a.length>0&&jsx("div",{className:f("px-3 pb-3 pt-0","border-t",Be?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex flex-wrap gap-1.5 pt-3",children:a.map(L=>jsxs("button",{onClick:()=>Oe(L.id),className:f("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs transition-all",T.includes(L.id)?"bg-emerald-500 text-white":Be?"bg-[#2a2a3e] text-gray-300 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-700 hover:bg-gray-200"),type:"button",children:[L.avatar?jsx("img",{src:L.avatar,alt:L.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(L.id)?"bg-emerald-600 text-white":"bg-emerald-500 text-white"),children:L.name.charAt(0).toUpperCase()}),jsx("span",{children:L.name.split(" ")[0]})]},L.id))})}),R&&jsx("div",{className:f("px-3 pb-3 pt-0","border-t",Be?"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",Be?"text-gray-500":"text-gray-400"),children:q.startDate}),jsx("input",{type:"date",value:h,onChange:L=>v(L.target.value),className:f("w-full px-2 py-1.5 rounded text-xs border",Be?"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",Be?"text-gray-500":"text-gray-400"),children:q.endDate}),jsx("input",{type:"date",value:l,onChange:L=>k(L.target.value),className:f("w-full px-2 py-1.5 rounded text-xs border",Be?"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",Be?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex gap-1.5 pt-3",children:["low","medium","high","urgent"].map(L=>jsx("button",{onClick:()=>S(y===L?"":L),className:f("flex-1 px-2 py-1.5 rounded text-xs font-medium transition-all",y===L?`${{low:"bg-green-500",medium:"bg-yellow-500",high:"bg-orange-500",urgent:"bg-red-500"}[L]} text-white`:Be?"bg-[#2a2a3e] text-gray-400 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-600 hover:bg-gray-200"),type:"button",children:q[L]},L))})})]}):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",Be?"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:q.buttonLabel})]})}var Mo=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(Sr,{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 yd(e={}){return new Mo(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 Ds(e,t){let a=r=>jsx(co,{...t,children:jsx(e,{...r})});return a.displayName=`withErrorBoundary(${e.displayName||e.name||"Component"})`,a}function Es({board:e,onCreateCard:t,onNavigateToCard:a,onSearch:r,onChangePriority:o,onAssignUser:s,onGeneratePlan:n,onPredictRisks:p,onOpenAIUsage:m,shortcut:i="k",className:u=""}){let[d,g]=useState(false),[b,C]=useState(""),[T,c]=useState("home"),[h,v]=useState(""),[l,k]=useState("");useEffect(()=>{let x=R=>{(R.metaKey||R.ctrlKey)&&R.key===i&&(R.preventDefault(),g(A=>!A)),R.key==="Escape"&&(g(false),c("home"),C(""));};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[i]),useEffect(()=>{d||(c("home"),C(""),v(""),k(""));},[d]);let y=useCallback(()=>{g(false);},[]),S=useCallback(x=>{let[R,A]=x.split(":");switch(R){case "create-card":c("create-card");break;case "create-card-in":v(A||"");break;case "navigate":A?(a?.(A),y()):c("navigate");break;case "search":r?.(b),y();break;case "priority":c("priority");break;case "set-priority":l&&A&&(o?.(l,A),y());break;case "assign":c("assign");break;case "assign-user":l&&A&&(s?.(l,A),y());break;case "ai":c("ai");break;case "ai-generate-plan":n?.(),y();break;case "ai-predict-risks":p?.(),y();break;case "ai-usage":m?.(),y();break;case "back":c("home");break;}},[b,l,t,a,r,o,s,n,p,m,y]),w=useCallback(()=>{h&&b.trim()&&(t?.(h,b.trim()),y());},[h,b,t,y]);return d?jsx(ht,{children:jsx("div",{className:"command-palette-overlay",onClick:y,children:jsx("div",{className:`command-palette ${u}`,onClick:x=>x.stopPropagation(),children:jsxs(Command,{value:b,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"&&h?"Type card title and press Enter...":T==="create-card"?"Select a column first...":"Type a command or search...",className:"command-palette-input",onKeyDown:x=>{x.key==="Enter"&&T==="create-card"&&h&&w();}}),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(x=>jsxs(Command.Item,{value:`navigate:${x.id}`,onSelect:S,className:"command-palette-item",children:[jsx("div",{className:"command-palette-item-dot",style:{background:x.priority==="URGENT"?"#EF4444":x.priority==="HIGH"?"#F59E0B":x.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:x.title}),x.labels&&x.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:x.labels.slice(0,2).map(R=>jsx("span",{className:"command-palette-item-label",children:R},R))})]},x.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(x=>jsxs(Command.Item,{value:`create-card-in:${x.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:x.title}),jsxs("div",{className:"command-palette-item-count",children:[x.cardIds.length," cards"]})]},x.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(x=>{let R=e.columns.find(A=>A.id===x.columnId);return jsxs(Command.Item,{value:`navigate:${x.id}`,onSelect:S,className:"command-palette-item",keywords:[x.title,x.description||"",...x.labels||[]],children:[jsx("div",{className:"command-palette-item-dot",style:{background:x.priority==="URGENT"?"#EF4444":x.priority==="HIGH"?"#F59E0B":x.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsxs("div",{className:"command-palette-item-content",children:[jsx("div",{children:x.title}),jsx("div",{className:"command-palette-item-meta",children:R?.title})]}),x.labels&&x.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:x.labels.slice(0,2).map(A=>jsx("span",{className:"command-palette-item-label",children:A},A))})]},x.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 kd(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=`
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 xc 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,Filter,FileImage,FileSpreadsheet,FileJson,FolderKanban,Download,Calendar,ChevronLeft,GripVertical,AlertCircle,CircleDot,Users,Milestone,List,Search}from'lucide-react';import {Command}from'cmdk';import _u from'react-markdown';import Vu from'remark-gfm';import ju 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 Zo=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 [Zo.Translate.toString(e),Zo.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 rm(e){return Array.from({length:e},(t,a)=>(a+1)*1e3)}function os(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 Cl(e,t=100){return e>t}var om=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 nm(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=om,onRetry:m}=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 b=nm(u,r,o,s);if(m)try{m(p,u,b);}catch(C){console.error("Error in retry callback:",C);}await new Promise(C=>setTimeout(C,b));}}return {error:p||new Error("Unknown error"),attempts:i,success:false}}function sm(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 im(e,t={}){return async(...a)=>tn(()=>e(...a),t)}var ns=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 Tl=(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))(Tl||{}),$r=class $r{constructor(t={}){this.defaultLogHandler=t=>{let{timestamp:a,level:r,message:o,component:s,...n}=t,m=`[${a}] [${r}] [${s}]`,p=Object.keys(n).length>0;switch(r){case "DEBUG":console.debug(m,o,p?n:"");break;case "INFO":console.info(m,o,p?n:"");break;case "WARN":console.warn(m,o,p?n:"");break;case "ERROR":console.error(m,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",...$r.globalOptions};}static configure(t){$r.globalOptions={...$r.globalOptions,...t};}child(t){return new $r({...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:Tl[t],message:a,component:this.options.componentName,...r};this.options.onLog(o);}};$r.globalOptions={};var ss=$r,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}},Nl=new ss;function dm(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 cm(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(m=>m.id===s.columnId);return [s.id,is(s.title),is(s.description||""),is(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 pm(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 xc(r,{backgroundColor:"#0a0a0a",scale:1.5,logging:!1,useCORS:!0,allowTaint:!0,windowWidth:r.scrollWidth,windowHeight:r.scrollHeight}),m=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 b=new jsPDF({orientation:"landscape",unit:"mm",format:"a4"});b.setFontSize(16),b.setTextColor(255,255,255),b.setFillColor(10,10,10),b.rect(0,0,p,15,"F"),b.text(e.title||"Kanban Board",10,10);let C=(p-d)/2;return b.addImage(m,"PNG",C,20,d,g),b}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 m=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,m.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):m.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 is(e){return e.includes(",")||e.includes('"')||e.includes(`
3
+ `)?`"${e.replace(/"/g,'""')}"`:e}async function Sl(e,t,a,r){switch(t){case "json":return dm(e,r);case "csv":return cm(e);case "pdf":return await pm(e,a);default:throw new Error(`Unsupported export format: ${t}`)}}function El(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"},m=new Blob([e],{type:n[t]}),p=URL.createObjectURL(m),i=document.createElement("a");i.href=p,i.download=s,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(p);}function mm(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 um(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=Pl(t[0]),r=[],o=new Map,s=[];for(let n=1;n<t.length;n++)try{let m=Pl(t[n]||"");if(m.length>a.length){s.push(`Line ${n+1}: Too many columns`);continue}if(a.length-m.length>3){s.push(`Line ${n+1}: Column count mismatch (expected ${a.length}, got ${m.length})`);continue}for(;m.length<a.length;)m.push("");let i={};a.forEach((b,C)=>{i[b]=m[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(m){s.push(`Line ${n+1}: ${m instanceof Error?m.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 Pl(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 Ml(e,t){switch(t){case "json":return mm(e);case "csv":return um(e);default:return {success:false,errors:[`Unsupported import format: ${t}`]}}}function Al(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 ls=createContext(null);function Fl(){return useContext(ls)}var Ll=createContext(null);function Il({children:e,themeName:t}){return jsx(Ll.Provider,{value:{themeName:t},children:e})}function oo(){return useContext(Ll)}function ht({children:e,container:t}){let[a,r]=useState(false),o=Fl(),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:m,themeName:p}=o,i={"--asakaa-color-background-primary":m.bgPrimary,"--asakaa-color-background-secondary":m.bgSecondary,"--asakaa-color-background-card":m.bgGrid,"--asakaa-color-background-hover":m.hoverBg,"--asakaa-color-text-primary":m.textPrimary,"--asakaa-color-text-secondary":m.textSecondary,"--asakaa-color-text-tertiary":m.textTertiary,"--asakaa-color-text-inverse":m.taskBarHandle||"#FFFFFF","--asakaa-color-border-default":m.border,"--asakaa-color-border-hover":m.borderLight,"--asakaa-color-border-subtle":m.borderLight,"--asakaa-color-interactive-primary":m.accent,"--asakaa-color-interactive-primaryHover":m.accentHover,"--asakaa-color-interactive-primaryBorder":`${m.accent}4D`,"--asakaa-color-interactive-primaryBackground":`${m.accent}1A`,"--asakaa-color-interactive-primaryBackgroundHover":`${m.accent}33`,"--asakaa-color-status-success":m.statusCompleted,"--asakaa-color-status-warning":m.milestone,"--asakaa-color-status-error":m.criticalPath,"--asakaa-color-danger":m.criticalPath,"--asakaa-color-danger-border":`${m.criticalPath}4D`,"--asakaa-color-danger-background":`${m.criticalPath}14`,"--asakaa-color-danger-backgroundHover":`${m.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 zl={URGENT:{label:"Urgent",color:"#E74C3C"},HIGH:{label:"High",color:"#E67E22"},MEDIUM:{label:"Normal",color:"#F1C40F"},LOW:{label:"Low",color:"#2ECC71"}},km="#BDC3C7",wm=({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 Or({priority:e,onChange:t,className:a}){let[r,o]=useState(false),[s,n]=useState({top:0,left:0}),m=useRef(null),p=useRef(null),i=()=>{if(!p.current)return;let b=p.current.getBoundingClientRect(),C=window.innerHeight,T=window.innerWidth,c=160,h=220,v=4,l=b.right-c;l<10&&(l=b.left),l+c>T-10&&(l=T-c-10);let w=C-b.bottom,y=b.top,S;w>=h+v?S=b.bottom+v:y>=h+v?S=b.top-h-v:S=w>=y?b.bottom+v:Math.max(10,b.top-h-v),n({top:S,left:l}),o(true);};useEffect(()=>{let b=C=>{m.current&&!m.current.contains(C.target)&&!p.current?.contains(C.target)&&o(false);};if(r)return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[r]),useEffect(()=>{let b=C=>{C.key==="Escape"&&o(false);};if(r)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[r]);let u=b=>{t(b),o(false);},d=e?zl[e]:null,g=d?.color||km;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(ht,{children:jsxs("div",{ref:m,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(zl).map(([b,C])=>jsxs("button",{onClick:()=>u(b),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(wm,{color:C.color}),jsx("span",{className:"font-semibold text-sm",children:C.label}),e===b&&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"})})]},b)),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: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("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 Cm=[{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 To({startDate:e,endDate:t,onChange:a,className:r}){let[o,s]=useState(false),[n,m]=useState({top:0,left:0}),p=useRef(null),i=useRef(null),g=(oo()?.themeName||"dark")==="dark",b=()=>{if(!i.current)return;let l=i.current.getBoundingClientRect(),w=window.innerHeight,y=window.innerWidth,S=320,k=380,x=4,R=l.left;R+S>y-10&&(R=y-S-10),R<10&&(R=10);let A=w-l.bottom,N=l.top,H;A>=k+x?H=l.bottom+x:N>=k+x?H=l.top-k-x:H=A>=N?l.bottom+x:Math.max(10,l.top-k-x),m({top:H,left:R}),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,y=R=>{let A=R.getFullYear(),N=String(R.getMonth()+1).padStart(2,"0"),H=String(R.getDate()).padStart(2,"0");return `${A}-${N}-${H}`},S=y(w),k=new Date(w);k.setDate(k.getDate()+l);let x=y(k);a(S,x),s(false);},T=()=>{if(!e||!t)return "Set date";let l=k=>{if(k instanceof Date)return k;if(typeof k!="string"||!k.match(/^\d{4}-\d{2}-\d{2}$/))return null;let x=k.split("-").map(Number);if(x.length!==3||x.some(H=>isNaN(H)))return null;let R=x[0],A=x[1],N=x[2];return R===void 0||A===void 0||N===void 0?null:new Date(R,A-1,N)},w=l(e),y=l(t);if(!w||!y||isNaN(w.getTime())||isNaN(y.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[y.getMonth()]} ${y.getDate()}`},c=e&&t,v=(()=>{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):b(),className:`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-all hover:bg-white/5 ${v?"asakaa-date-overdue":"asakaa-date"}`,title:c?`${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(ht,{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:Cm.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 Ur({assignedUsers:e=[],availableUsers:t,onChange:a,className:r,maxVisibleAvatars:o=3}){let[s,n]=useState(false),[m,p]=useState(""),[i,u]=useState({top:0,left:0}),d=useRef(null),g=useRef(null),b=()=>{if(!g.current)return;let v=g.current.getBoundingClientRect(),l=window.innerHeight,w=window.innerWidth,y=300,S=380,k=4,x=v.right-y;x<10&&(x=v.left),x+y>w-10&&(x=w-y-10);let R=l-v.bottom,A=v.top,N;R>=S+k?N=v.bottom+k:A>=S+k?N=v.top-S-k:N=R>=A?v.bottom+k:Math.max(10,v.top-S-k),u({top:N,left:x}),n(true);};useEffect(()=>{let v=l=>{d.current&&!d.current.contains(l.target)&&!g.current?.contains(l.target)&&(n(false),p(""));};if(s)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[s]),useEffect(()=>{let v=l=>{l.key==="Escape"&&(n(false),p(""));};if(s)return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[s]);let C=v=>{let l=e.some(w=>w.id===v.id);a(l?e.filter(w=>w.id!==v.id):[...e,v]);},T=t.filter(v=>v.name.toLowerCase().includes(m.toLowerCase())),c=e.slice(0,o),h=e.length-o;return jsxs("div",{className:`relative ${r||""}`,children:[jsx("button",{ref:g,onClick:()=>s?n(false):b(),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:[c.map(v=>jsx("div",{className:"asakaa-avatar",title:v.name,children:v.avatar?jsx("img",{src:v.avatar,alt:v.name,className:"asakaa-avatar-img"}):v.initials},v.id)),h>0&&jsxs("div",{className:"asakaa-avatar",children:["+",h]})]}):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(ht,{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:m,onChange:v=>p(v.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(v=>{let l=e.some(w=>w.id===v.id);return jsxs("button",{onClick:()=>C(v),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:v.color,color:"#fff"},children:v.avatar?jsx("img",{src:v.avatar,alt:v.name,className:"w-full h-full rounded-full object-cover"}):v.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:v.name}),jsx("span",{className:"w-5 text-lg flex-shrink-0 text-right",style:{color:l?"#3b82f6":"transparent"},children:l?"\u2713":""})]},v.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,m=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)&&m(u))return true;if(n.has(u))return true}}return n.delete(p),false};return m(a)}function Do({currentCardId:e,dependencies:t=[],availableTasks:a,onChange:r,className:o,validateCircular:s=true,onCircularDependencyError:n}){let[m,p]=useState(false),[i,u]=useState(""),[d,g]=useState(t.length>0),[b,C]=useState({top:0,left:0}),[T,c]=useState(null),h=useRef(null),v=useRef(null),l=()=>{if(!v.current)return;let x=v.current.getBoundingClientRect(),R=window.innerHeight,A=window.innerWidth,N=300,H=d?380:120,$=4,_=x.right-N;_<10&&(_=x.left),_+N>A-10&&(_=A-N-10);let V=R-x.bottom,ie=x.top,Be;V>=H+$?Be=x.bottom+$:ie>=H+$?Be=x.top-H-$:Be=V>=ie?x.bottom+$:Math.max(10,x.top-H-$),C({top:Be,left:_}),p(true);};useEffect(()=>{if(!m||!v.current)return;let x=v.current.getBoundingClientRect(),R=window.innerHeight,A=window.innerWidth,N=300,H=d?380:120,$=4,_=x.right-N;_<10&&(_=x.left),_+N>A-10&&(_=A-N-10);let V=R-x.bottom,ie=x.top,Be;V>=H+$?Be=x.bottom+$:ie>=H+$?Be=x.top-H-$:Be=V>=ie?x.bottom+$:Math.max(10,x.top-H-$),C({top:Be,left:_});},[d,m]),useEffect(()=>{let x=R=>{h.current&&!h.current.contains(R.target)&&!v.current?.contains(R.target)&&(p(false),u(""));};if(m)return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[m]),useEffect(()=>{let x=R=>{R.key==="Escape"&&(p(false),u(""));};if(m)return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[m]);let w=x=>{let R=t.includes(x),A=a.find(N=>N.id===x);if(c(null),R){let N=t.filter(H=>H!==x);r(N),N.length===0&&g(false);}else {if(s&&rn(a,x,e)){let H=`Cannot add "${A?.title||x}" as dependency - would create circular reference`;c(H),n?.(x,A?.title||x),setTimeout(()=>c(null),3e3);return}r([...t,x]),g(true);}},y=()=>{let x=!d;g(x),x||r([]);},S=a.filter(x=>x.id!==e).filter(x=>x.title.toLowerCase().includes(i.toLowerCase())||x.id.toLowerCase().includes(i.toLowerCase())),k=t.length>0?"#3B82F6":"#BDC3C7";return jsxs("div",{className:`relative ${o||""}`,children:[jsxs("button",{ref:v,onClick:()=>m?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:k,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),t.length>0&&jsx("span",{className:"text-xs font-medium",style:{color:k},children:t.length})]}),m&&jsx(ht,{children:jsxs("div",{ref:h,className:"dependencies-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${b.top}px`,left:`${b.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:y,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:x=>u(x.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(x=>{let R=t.includes(x.id);return jsxs("button",{onClick:()=>w(x.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:R?"#3b82f6":"transparent",borderColor:R?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:R&&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:x.title}),jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:x.id})]})]},x.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 mr=memo(({card:e,render:t,onClick:a,isSelected:r,disableDrag:o,className:s,onUpdate:n,availableUsers:m=[],allCards:p=[]})=>{let{attributes:i,listeners:u,setNodeRef:d,transform:g,transition:b,isDragging:C}=useSortable({id:e.id,disabled:o,data:{type:"card",card:e}}),T={transform:Zo.Transform.toString(g),transition:b};if(t)return jsx("div",{ref:d,style:T,...i,...u,onClick:()=>a?.(e),children:t(e)});let c=m.filter(w=>e.assignedUserIds?.includes(w.id)),h=e.progress===100,v=(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";}})}),v.length>0&&!e.coverImage&&jsx("div",{className:"asakaa-card-attachments mb-3",children:v.length===1&&v[0]?jsx("img",{src:v[0].url,alt:v[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:v.slice(0,4).map((w,y)=>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";}}),y===3&&v.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:["+",v.length-4]})})]},w.id))})}),jsx("h3",{className:"asakaa-card-title mb-2",style:{textDecoration:h?"line-through":"none",opacity:h?.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(Or,{priority:e.priority,onChange:w=>n?.(e.id,{priority:w})})}),jsx("div",{onClick:w=>w.stopPropagation(),className:"date-picker",children:jsx(To,{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,y)=>n?.(e.id,{startDate:w,endDate:y})})}),m.length>0&&jsx("div",{onClick:w=>w.stopPropagation(),className:"user-selector",children:jsx(Ur,{assignedUsers:c,availableUsers:m,onChange:w=>n?.(e.id,{assignedUserIds:w.map(y=>y.id)})})}),jsx("div",{onClick:w=>w.stopPropagation(),className:"dependencies-selector",children:jsx(Do,{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)));mr.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"}},ql=({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 Xl({status:e="todo",onChange:t,className:a,customStatuses:r=[]}){let[o,s]=useState(false),[n,m]=useState({top:0,left:0}),p=useRef(null),i=useRef(null),u=[...Object.entries(on).map(([c,h])=>({id:c,label:h.label,color:h.color,icon:h.icon})),...r.filter(c=>!Object.keys(on).includes(c.id)).map(c=>({id:c.id,label:c.title,color:c.color||"#8B5CF6",icon:"circle-dot"}))],d=()=>{let c=on[e];if(c)return {...c,id:e};let h=r.find(v=>v.id===e);return h?{id:h.id,label:h.title,color:h.color||"#8B5CF6",icon:"circle-dot"}:{...on.todo,id:"todo"}},g=()=>{if(!i.current)return;let c=i.current.getBoundingClientRect(),h=window.innerHeight,v=window.innerWidth,l=180,w=280,y=4,S=c.right-l;S<10&&(S=c.left),S+l>v-10&&(S=v-l-10);let k=h-c.bottom,x=c.top,R;k>=w+y?R=c.bottom+y:x>=w+y?R=c.top-w-y:R=k>=x?c.bottom+y:Math.max(10,c.top-w-y),m({top:R,left:S}),s(true);};useEffect(()=>{let c=h=>{p.current&&!p.current.contains(h.target)&&!i.current?.contains(h.target)&&s(false);};if(o)return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[o]),useEffect(()=>{let c=h=>{h.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[o]);let b=c=>{t(c),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(ql,{icon:C.icon,color:T})}),o&&jsx(ht,{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(c=>jsxs("button",{onClick:()=>b(c.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:c.color,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(ql,{icon:c.icon,color:c.color}),jsx("span",{className:"font-semibold",children:c.label}),e===c.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"})})]},c.id))})]})})]})}function Jl({columnTitle:e,onRename:t,onDelete:a,isDeletable:r=false,className:o}){let[s,n]=useState(false),[m,p]=useState(false),[i,u]=useState(e),[d,g]=useState({top:0,left:0}),b=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=>{b.current&&!b.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(()=>{m&&T.current&&(T.current.focus(),T.current.select());},[m]);let c=()=>{p(true),u(e);},h=()=>{let l=i.trim();l&&l!==e&&t(l),p(false),n(false),u(e);},v=l=>{l.key==="Enter"?h():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(ht,{children:jsx("div",{ref:b,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:m?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:v,onBlur:h,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:c,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:m,availableUsers:p,allCards:i,enableVirtualization:u,cardHeight:d=120,isCollapsed:g,onToggleCollapse:b,onColumnRename:C,onColumnDelete:T,isDeletable:c=false,className:h})=>{let{setNodeRef:v,isOver:l}=useDroppable({id:e.id,data:{type:"column",column:e}}),w=useRef(null),y=u??Cl(t.length),S=useVirtualizer({count:t.length,getScrollElement:()=>w.current,estimateSize:()=>d,enabled:y});if(a)return jsx("div",{ref:v,className:h,children:a(e,t)});let x=(()=>{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}})(),R=x.state==="exceeded",A=()=>"asakaa-column-count";return jsxs("div",{ref:v,className:f("asakaa-column",l&&"ring-2 ring-asakaa-accent-blue",R&&"ring-2 ring-asakaa-accent-red",h),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(A()),children:[t.length,e.wipLimit&&` / ${e.wipLimit}`]}),e.wipLimit&&x.state!=="none"&&jsxs("span",{className:"text-xs font-medium flex items-center",title:`${x.percentage.toFixed(0)}% capacity${e.wipLimitType==="hard"?" (Hard limit - blocks new cards)":" (Soft limit - shows warning)"}`,children:[x.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"})]}),x.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"})]}),x.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"})}),x.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(Jl,{columnTitle:e.title,onRename:N=>C?.(e.id,N),onDelete:T?()=>T(e.id):void 0,isDeletable:c}),b&&jsx("button",{onClick:b,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:y?"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"})}):y?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(mr,{card:H,render:r,onClick:n,onUpdate:m,availableUsers:p,allCards:i})},H.id):null})}):t.map(N=>jsx(mr,{card:N,render:r,onClick:n,onUpdate:m,availableUsers:p,allCards:i},N.id))})})]})});io.displayName="Column";function us({title:e,onSave:t,className:a}){let[r,o]=useState(false),[s,n]=useState(e),m=useRef(null);useEffect(()=>{r&&m.current&&(m.current.focus(),m.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:m,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[m,p]=useState(false),[i,u]=useState(""),[d,g]=useState(false),[b,C]=useState(dn[10]||"#3B82F6"),[T,c]=useState({top:0,left:0}),h=useRef(null),v=useRef(null),l=useRef(null),w=useRef(null),y=t.filter(N=>N.name.toLowerCase().includes(i.toLowerCase())),S=t.some(N=>N.name.toLowerCase()===i.toLowerCase());useEffect(()=>{if(m&&v.current){let N=v.current.getBoundingClientRect();c({top:N.bottom+6,left:N.left});}},[m]),useEffect(()=>{let N=H=>{let $=H.target,_=h.current?.contains($),V=l.current?.contains($);!_&&!V&&(p(false),u(""),g(false));};if(m)return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[m]),useEffect(()=>{m&&w.current&&w.current.focus();},[m]);let k=N=>{let H=e.some($=>$.id===N.id);a(H?e.filter($=>$.id!==N.id):[...e,N]);},x=async()=>{if(!(!r||!i.trim())){g(true);try{let N=await r(i.trim(),b);N&&(a([...e,N]),u(""),C(dn[Math.floor(Math.random()*dn.length)]||"#3B82F6"));}finally{g(false);}}},R=(N,H)=>{H.stopPropagation(),a(e.filter($=>$.id!==N));},A={backgroundColor:`${o.textTertiary}15`,border:`1px solid ${o.borderLight}`,color:o.textSecondary};return jsxs("div",{ref:h,className:"relative",children:[jsxs("button",{ref:v,type:"button",onClick:()=>!s&&p(!m),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:m&&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&&x();}})}),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=>R(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:y.length>0?y.map(N=>{let H=e.some($=>$.id===N.id);return jsxs("button",{type:"button",onClick:()=>k(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:$=>{H||($.currentTarget.style.backgroundColor=o.hoverBg);},onMouseLeave:$=>{H||($.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: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:b===N?`2px solid ${N}`:"none",outlineOffset:"2px"}},N))}),jsxs("button",{type:"button",onClick:x,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:b,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 fs({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 td({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(fs,{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 sd(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 du(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:m=[],availableTags:p=[],onCreateTag:i,attachments:u=[],onUploadAttachments:d,onDeleteAttachment:g,availableTasks:b=[],comments:C=[],onAddComment:T,currentUser:c}){let h=s==="dark",v={textTertiary:h?"#6B7280":"#9CA3AF",textSecondary:h?"#9CA3AF":"#6B7280",textPrimary:h?"#FFFFFF":"#111827",borderLight:h?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",border:h?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",bgPrimary:h?"#1A1D25":"#FFFFFF",bgSecondary:h?"#0F1117":"#F9FAFB",hoverBg:h?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},l=e&&"title"in e&&!("name"in e),w=e,[y,S]=useState(e?sd(e,m):null),[k,x]=useState(false),[R,A]=useState(false),[N,H]=useState(false),[$,_]=useState(null),[V,ie]=useState(new Date),[Be,Oe]=useState(false),[ze,Pe]=useState(false),[L,B]=useState(""),[D,U]=useState(false),[q,O]=useState(false),[le,ve]=useState(false),[Ee,ue]=useState(""),We=useRef(null),[Me,Re]=useState(""),ft=useRef(null),[qe,it]=useState(""),[z,re]=useState(false);useEffect(()=>{if(e){let E=sd(e,m);S(E),ue(E.description||""),Re(E.name||"");}},[e?.id,m]),useEffect(()=>()=>{We.current&&clearTimeout(We.current),ft.current&&clearTimeout(ft.current);},[]);let fe=useCallback(E=>{S(E),l&&o&&w?o(du(E,w)):r&&r(E);},[l,w,o,r]),ye=useCallback(()=>{x(false),A(false),H(false),_(null),Pe(false),B(""),U(false);},[]),Ae=useCallback((E,X)=>{if(!y)return;let de={...y,[E]:X};fe(de);},[y,fe]),Ze=useCallback(E=>{ue(E),We.current&&clearTimeout(We.current),We.current=setTimeout(()=>{if(y){let X={...y,description:E};fe(X);}},800);},[y,fe]),kt=useCallback(E=>{Re(E),ft.current&&clearTimeout(ft.current),ft.current=setTimeout(()=>{if(y&&E.trim()){let X={...y,name:E.trim()};fe(X);}},800);},[y,fe]),De=useCallback(async()=>{if(!(!y||!qe.trim()||!T)){re(true);try{await T(y.id,qe.trim()),it("");}finally{re(false);}}},[y,qe,T]),It=useCallback(E=>{let X=typeof E=="string"?new Date(E):E,Le=new Date().getTime()-X.getTime(),Ge=Math.floor(Le/6e4),Je=Math.floor(Le/36e5),Ue=Math.floor(Le/864e5);return Ge<1?n==="es"?"Ahora":"Just now":Ge<60?n==="es"?`Hace ${Ge} min`:`${Ge}m ago`:Je<24?n==="es"?`Hace ${Je}h`:`${Je}h ago`:Ue<7?n==="es"?`Hace ${Ue}d`:`${Ue}d ago`:X.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})},[n]),Ft=useCallback(E=>{if(!y)return;let X=y.progress||0;E==="completed"?X=100:E==="in-progress"&&X===0?X=10:E==="todo"&&(X=0);let de={...y,status:E,progress:X};fe(de),x(false);},[y,fe]),lt=useCallback((E,X)=>{if(!y)return;let de={...y,startDate:E,endDate:X};fe(de);},[y,fe]),Xe=useCallback(()=>{let E=V.getFullYear(),X=V.getMonth(),de=new Date(E,X,1),Ge=new Date(E,X+1,0).getDate(),Je=de.getDay(),Ue=[],st=new Date(E,X,0).getDate();for(let j=Je-1;j>=0;j--)Ue.push({date:new Date(E,X-1,st-j),isCurrentMonth:false});for(let j=1;j<=Ge;j++)Ue.push({date:new Date(E,X,j),isCurrentMonth:true});let mt=42-Ue.length;for(let j=1;j<=mt;j++)Ue.push({date:new Date(E,X+1,j),isCurrentMonth:false});return Ue},[V]),Wt=useCallback(async E=>{if(E.preventDefault(),E.stopPropagation(),O(false),!y||!d)return;let X=Array.from(E.dataTransfer.files);if(X.length!==0){ve(true);try{await d(y.id,X);}finally{ve(false);}}},[y,d]),sa=useCallback(async E=>{if(!y||!d||!E.target.files)return;let X=Array.from(E.target.files);if(X.length!==0){ve(true);try{await d(y.id,X);}finally{ve(false);}E.target.value="";}},[y,d]),oe=useCallback(E=>{E.preventDefault(),E.stopPropagation(),O(true);},[]),J=useCallback(E=>{E.preventDefault(),E.stopPropagation(),O(false);},[]),Ve=useCallback(E=>E<1024?`${E} B`:E<1024*1024?`${(E/1024).toFixed(1)} KB`:`${(E/(1024*1024)).toFixed(1)} MB`,[]),ae=useCallback(E=>E.startsWith("image/")?Image:E.includes("pdf")||E.includes("document")?FileText:File,[]);return !t||!y?null:jsx(AnimatePresence,{children:t&&y&&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",h?"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",h?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:f("w-4 h-4",h?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:f("text-xs px-2 py-0.5 rounded",h?"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",h?"text-[#6B7280]":"text-gray-400"),children:y.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",h?"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",h?"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",h?"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",h?"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=y.progress===100?0:100,de={...y,progress:E,status:E===100?"completed":"todo"};fe(de);},className:f("mt-2 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors flex-shrink-0",y.progress===100?"bg-green-500 border-green-500":h?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:y.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("input",{type:"text",value:Me,onChange:E=>kt(E.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",y.progress===100?"line-through text-[#6B7280]":h?"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",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{ye(),x(!k);},className:f("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",y.progress===100||y.status==="completed"?"bg-green-500/20 text-green-400":y.progress&&y.progress>0||y.status==="in-progress"?"bg-blue-500/20 text-blue-400":h?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:y.progress===100||y.status==="completed"?n==="es"?"COMPLETADO":"DONE":y.progress&&y.progress>0||y.status==="in-progress"?n==="es"?"EN PROGRESO":"IN PROGRESS":n==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:k&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>x(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]",h?"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:()=>Ft(E.id),className:f("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",h?"hover:bg-white/5":"hover:bg-gray-50",y.status===E.id&&(h?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:f("w-2 h-2 rounded-full",E.color)}),jsx("span",{className:h?"text-white":"text-gray-900",children:E.label})]},E.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(User,{className:f("w-4 h-4",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{ye(),H(!N);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",h?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[y.assignees&&y.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[y.assignees.slice(0,3).map((E,X)=>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()},X)),y.assignees.length>3&&jsxs("span",{className:f("text-xs",h?"text-[#6B7280]":"text-gray-400"),children:["+",y.assignees.length-3]})]}):jsx("span",{className:f("text-sm",h?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Agregar":"Add"}),jsx(ChevronDown,{className:f("w-3 h-3",h?"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",h?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:m.length>0?m.map(E=>{let X=y.assignees?.some(de=>de.name===E.name);return jsxs("button",{onClick:()=>{let de=y.assignees||[],Le;X?Le=de.filter(Ge=>Ge.name!==E.name):Le=[...de,E],Ae("assignees",Le);},className:f("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",h?"hover:bg-white/5":"hover:bg-gray-50",X&&(h?"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:f("flex-1",h?"text-white":"text-gray-900"),children:E.name}),X&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},E.name)}):jsx("div",{className:f("px-3 py-4 text-sm text-center",h?"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",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{_($?null:"start"),ie(y.startDate||new Date);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",h?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[y.startDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Inicio":"Start"),jsx("span",{className:f("mx-1",h?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),y.endDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Fin":"End")]}),jsx(AnimatePresence,{children:$&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>_(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",h?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:E=>E.stopPropagation(),children:[jsxs("div",{className:f("w-44 py-2 border-r",h?"border-white/10":"border-gray-200"),children:[(()=>{let E=new Date,X=new Date(E);X.setDate(E.getDate()+1);let de=new Date(E);de.setDate(E.getDate()+((6-E.getDay()+7)%7||7));let Le=new Date(E);Le.setDate(E.getDate()+((1-E.getDay()+7)%7||7));let Ge=new Date(E);Ge.setDate(E.getDate()+(6-E.getDay()+7)%7+7);let Je=new Date(E);Je.setDate(E.getDate()+14);let Ue=new Date(E);return Ue.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:X,display:X.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Este fin de semana":"This weekend",date:de,display:n==="es"?"s\xE1b.":"sat."},{label:n==="es"?"Pr\xF3xima semana":"Next week",date:Le,display:n==="es"?"lun.":"mon."},{label:n==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:Ge,display:Ge.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"2 semanas":"2 weeks",date:Je,display:Je.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:Ue,display:Ue.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((mt,j)=>jsxs("button",{className:f("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",h?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if($==="start"){let te=y.endDate&&mt.date>y.endDate?mt.date:y.endDate;lt(mt.date,te),_("end");}else {let te=y.startDate&&mt.date<y.startDate?mt.date:y.startDate;lt(te,mt.date),_(null);}},children:[jsx("span",{children:mt.label}),jsx("span",{className:f("text-xs",h?"text-[#6B7280]":"text-gray-400"),children:mt.display})]},j))})(),jsx("div",{className:f("border-t mt-2 pt-2",h?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{lt(void 0,void 0),_(null);},className:f("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",h?"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",h?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:$==="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",h?"text-white":"text-gray-900"),children:V.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>ie(new Date),className:f("p-1 rounded text-sm transition-colors",h?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>ie(new Date(V.getFullYear(),V.getMonth()-1)),className:f("p-1 rounded",h?"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:()=>ie(new Date(V.getFullYear(),V.getMonth()+1)),className:f("p-1 rounded",h?"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:f("w-8 h-8 flex items-center justify-center text-xs",h?"text-[#6B7280]":"text-gray-400"),children:E},E))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:Xe().map((E,X)=>{let de=E.date.toDateString()===new Date().toDateString(),Le=y.startDate?.toDateString()===E.date.toDateString(),Ge=y.endDate?.toDateString()===E.date.toDateString(),Je=Le||Ge,Ue=y.startDate&&y.endDate&&E.date>=y.startDate&&E.date<=y.endDate;return jsx("button",{onClick:()=>{let st=new Date(E.date);if($==="start"){let mt=y.endDate&&st>y.endDate?st:y.endDate;lt(st,mt),_("end");}else {let mt=y.startDate&&st<y.startDate?st:y.startDate;lt(mt,st),_(null);}},className:f("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!E.isCurrentMonth&&(h?"text-[#4B5563]":"text-gray-300"),E.isCurrentMonth&&(h?"text-white":"text-gray-900"),de&&"ring-2 ring-[#3B82F6]",Le&&"bg-[#3B82F6] text-white",Ge&&!Le&&"bg-[#7C3AED] text-white",Ue&&!Je&&(h?"bg-[#7C3AED]/20":"bg-purple-100"),!Je&&(h?"hover:bg-white/10":"hover:bg-gray-100")),children:E.date.getDate()},X)})})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:f("w-4 h-4",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{ye(),A(!R);},className:f("text-xs px-2 py-1 rounded font-medium transition-all hover:ring-2 hover:ring-white/20",y.priority==="high"||y.priority==="urgent"?"bg-red-500/20 text-red-400":y.priority==="medium"?"bg-yellow-500/20 text-yellow-400":y.priority==="low"?"bg-green-500/20 text-green-400":h?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:y.priority?y.priority==="high"||y.priority==="urgent"?n==="es"?"Alta":"High":y.priority==="medium"?n==="es"?"Media":"Medium":n==="es"?"Baja":"Low":n==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:R&&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:f("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",h?"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:()=>{Ae("priority",E.id),A(false);},className:f("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",h?"hover:bg-white/5":"hover:bg-gray-50",y.priority===E.id&&(h?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:f("w-2 h-2 rounded-full",E.color)}),jsx("span",{className:h?"text-white":"text-gray-900",children:E.label})]},E.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:f("w-4 h-4",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:f("text-sm",h?"text-white":"text-gray-900"),children:y.startDate&&y.endDate?`${Math.ceil((y.endDate.getTime()-y.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",h?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[Be?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:y.progress||0,onChange:E=>{let X=parseInt(E.target.value),de=y.status;X===100?de="completed":X>0?de="in-progress":de="todo";let Le={...y,progress:X,status:de};fe(Le);},onBlur:()=>Oe(false),className:f("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",h?"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:()=>Oe(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",h?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:f("h-full rounded-full transition-all",y.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${y.progress||0}%`}})}),jsxs("span",{className:f("text-sm font-medium min-w-[40px]",h?"text-white":"text-gray-900"),children:[y.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:f("w-4 h-4",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Etiquetas":"Tags"}),jsx(nr,{selectedTags:y.tags||[],availableTags:p,onChange:E=>{Ae("tags",E);},onCreateTag:i,theme:v})]}),jsxs("div",{className:"flex items-start gap-3 relative",children:[jsx(Link2,{className:f("w-4 h-4 mt-1.5",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24 mt-1",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[y.dependencies&&y.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:y.dependencies.map(E=>{let X$1=b.find(de=>de.id===E);return jsxs("span",{className:f("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",h?"bg-blue-500/20 text-blue-400":"bg-blue-100 text-blue-700"),children:[X$1?.name||E.slice(0,8),jsx("button",{onClick:()=>{let de=(y.dependencies||[]).filter(Le=>Le!==E);Ae("dependencies",de);},className:f("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:()=>{ye(),Pe(!ze);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",h?"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",h?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:ze&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{Pe(false),B("");}}),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]",h?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[jsx("div",{className:f("p-2 border-b",h?"border-white/10":"border-gray-200"),children:jsx("input",{type:"text",value:L,onChange:E=>B(E.target.value),placeholder:n==="es"?"Buscar tarea...":"Search task...",className:f("w-full px-3 py-2 rounded-md text-sm outline-none",h?"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:b.length>0?b.filter(E=>E.id!==y.id).filter(E=>L===""||E.name.toLowerCase().includes(L.toLowerCase())).map(E=>{let X=y.dependencies?.includes(E.id);return jsxs("button",{onClick:()=>{let de=y.dependencies||[],Le;X?Le=de.filter(Ge=>Ge!==E.id):Le=[...de,E.id],Ae("dependencies",Le);},className:f("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",h?"hover:bg-white/5":"hover:bg-gray-50",X&&(h?"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",X?"bg-blue-500 border-blue-500":h?"border-white/30":"border-gray-300"),children:X&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("span",{className:f("block truncate",h?"text-white":"text-gray-900"),children:E.name}),jsx("span",{className:f("text-xs",h?"text-[#6B7280]":"text-gray-400"),children:E.id.slice(0,8)})]})]},E.id)}):jsx("div",{className:f("px-3 py-4 text-sm text-center",h?"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",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"text-[#9CA3AF]":"text-gray-500"),children:"Color"}),jsxs("button",{onClick:()=>{ye(),U(!D);},className:f("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",h?"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:y.color||"#6366F1"}}),jsx("span",{className:f("text-sm",h?"text-white":"text-gray-900"),children:sr.find(E=>E.value===y.color)?.name||(n==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:f("w-3 h-3",h?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:D&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>U(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",h?"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(E=>{let X=y.color===E.value;return jsx("button",{onClick:()=>{Ae("color",E.value),U(false);},className:f("w-7 h-7 rounded-full flex items-center justify-center transition-all",X&&"ring-2 ring-offset-2",h?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:E.value,outlineColor:X?E.value:void 0},title:E.name,children:X&&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:f("w-4 h-4",h?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:f("text-sm w-24",h?"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:y.isMilestone||false,onChange:E=>Ae("isMilestone",E.target.checked),className:f("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",y.isMilestone?"bg-purple-500 border-purple-500":h?"border-white/30 bg-transparent":"border-gray-300 bg-transparent","checked:bg-purple-500 checked:border-purple-500")}),jsx("span",{className:f("text-sm",h?"text-white":"text-gray-900"),children:n==="es"?"Marcar como hito":"Mark as milestone"})]})]})]}),jsxs("div",{className:f("mt-6 pt-4 border-t",h?"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",h?"text-[#6B7280]":"text-gray-400")}),jsx("h3",{className:f("text-sm font-semibold",h?"text-white":"text-gray-900"),children:n==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:Ee,onChange:E=>Ze(E.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",h?"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",h?"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",h?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:f("text-sm font-semibold mb-3",h?"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",h?"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",h?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:f("text-sm font-semibold mb-3",h?"text-white":"text-gray-900"),children:n==="es"?"Subtareas":"Subtasks"}),y.subtasks&&y.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:y.subtasks.map(E=>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",E.progress===100?"bg-green-500 border-green-500":h?"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:f("text-sm",E.progress===100?"line-through text-[#6B7280]":h?"text-white":"text-gray-900"),children:E.name})]},E.id))}),jsxs("button",{className:f("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",h?"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",h?"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",h?"text-white":"text-gray-900"),children:n==="es"?"Listas de control":"Checklists"}),jsx("button",{className:f("p-1 rounded transition-colors",h?"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",h?"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",h?"border-white/10":"border-gray-200"),children:[jsxs("h3",{className:f("text-sm font-semibold mb-3",h?"text-white":"text-gray-900"),children:[n==="es"?"Adjuntos":"Attachments",u.length>0&&jsxs("span",{className:f("ml-2 text-xs font-normal",h?"text-[#6B7280]":"text-gray-400"),children:["(",u.length,")"]})]}),u.length>0&&jsx("div",{className:"space-y-2 mb-4",children:u.map(E=>{let X=ae(E.type),de=E.type.startsWith("image/");return jsxs("div",{className:f("flex items-center gap-3 p-2 rounded-lg group transition-colors",h?"bg-white/5 hover:bg-white/10":"bg-gray-50 hover:bg-gray-100"),children:[de&&E.thumbnailUrl?jsx("img",{src:E.thumbnailUrl,alt:E.name,className:"w-10 h-10 rounded object-cover"}):jsx("div",{className:f("w-10 h-10 rounded flex items-center justify-center",h?"bg-white/10":"bg-gray-200"),children:jsx(X,{className:f("w-5 h-5",h?"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:f("text-sm font-medium truncate block hover:underline",h?"text-white":"text-gray-900"),children:E.name}),jsx("p",{className:f("text-xs",h?"text-[#6B7280]":"text-gray-400"),children:Ve(E.size)})]}),g&&jsx("button",{onClick:()=>g(E.id),className:f("p-1.5 rounded opacity-0 group-hover:opacity-100 transition-all",h?"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:oe,onDragLeave:J,onDrop:Wt,className:f("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",q?h?"border-blue-500 bg-blue-500/10":"border-blue-400 bg-blue-50":h?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300",le&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:sa,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!d||le}),le?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",h?"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",q?"text-blue-500":h?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:f("text-sm",h?"text-[#9CA3AF]":"text-gray-500"),children:q?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",h?"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",h?"border-white/10 bg-[#0F1117]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:f("px-4 py-3 border-b",h?"border-white/10":"border-gray-200"),children:jsxs("h3",{className:f("text-sm font-semibold",h?"text-white":"text-gray-900"),children:[n==="es"?"Actividad":"Activity",C.length>0&&jsxs("span",{className:f("ml-2 text-xs font-normal",h?"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:f("text-sm font-medium",h?"text-white":"text-gray-900"),children:E.user?.name||(n==="es"?"Usuario":"User")}),jsx("span",{className:f("text-xs",h?"text-[#6B7280]":"text-gray-400"),children:It(E.createdAt)})]}),jsx("p",{className:f("text-sm break-words",h?"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:f("w-10 h-10 mb-3",h?"text-[#3B4252]":"text-gray-300")}),jsx("p",{className:f("text-sm",h?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"Sin actividad reciente":"No recent activity"})]})}),jsx("div",{className:f("p-4 border-t",h?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-start gap-2",children:[c&&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:c.color||"#8B5CF6"},children:c.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:f("flex-1 flex items-center gap-2 px-3 py-2 rounded-lg",h?"bg-white/5":"bg-white border border-gray-200"),children:[jsx("input",{type:"text",value:qe,onChange:E=>it(E.target.value),onKeyDown:E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),De());},placeholder:n==="es"?"Escribe un comentario...":"Write a comment...",disabled:z||!T,className:f("flex-1 bg-transparent text-sm outline-none",h?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400",(z||!T)&&"opacity-50")}),jsx("button",{onClick:De,disabled:z||!qe.trim()||!T,className:f("p-1.5 rounded transition-colors",qe.trim()&&T?"bg-blue-500 text-white hover:bg-blue-600":h?"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 xs(){let[e,t]=useState(()=>dragStore.getState());useEffect(()=>dragStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{dragStore.setState(r);},[]);return [e,a]}function Sr({board:e,callbacks:t,onCardClick:a,renderProps:r,config:o,availableUsers:s=[],className:n,style:m,isLoading:p,error:i,children:u,availableTags:d=[],onCreateTag:g,attachmentsByCard:b,onUploadAttachments:C,onDeleteAttachment:T,comments:c,onAddComment:h,currentUser:v,onTaskOpen:l}){let[w,y]=xs(),[S,k]=useState(null),x=o?.theme||"dark",R=x==="dark"||x==="neutral",A=R?"dark":"",N=useCallback((D,U)=>{t.onCardUpdate?.(D,U);},[t]),H=useCallback((D,U)=>{t.onColumnUpdate?.(D,{title:U});},[t]),$=useCallback(D=>{t.onColumnDelete?.(D);},[t]),_=["todo","in-progress","completed"],V=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),ie=useMemo(()=>{let D=new Map;return e.columns.forEach(U=>{let q=U.cardIds.map(O=>e.cards.find(le=>le.id===O)).filter(O=>O!==void 0).sort((O,le)=>O.position-le.position);D.set(U.id,q);}),D},[e.cards,e.columns]),Be=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(U=>typeof U=="string"?U:U.taskId):[]})),[e.cards]),Oe=useCallback(D=>{let{active:U}=D,q=e.cards.find(O=>O.id===U.id);q&&y({isDragging:true,draggedCardId:q.id,sourceColumnId:q.columnId,targetColumnId:q.columnId});},[e.cards,y]),ze=useCallback(D=>{let{active:U,over:q}=D;if(!q||!e.cards.find(ve=>ve.id===U.id))return;let le=null;q.data.current?.type==="column"?le=q.id:q.data.current?.type==="card"&&(le=e.cards.find(Ee=>Ee.id===q.id)?.columnId||null),le&&le!==w.targetColumnId&&y({...w,targetColumnId:le});},[e.cards,w,y]),Pe=useCallback(async D=>{let{active:U,over:q}=D;if(y({isDragging:false,draggedCardId:null,sourceColumnId:null,targetColumnId:null}),!q)return;let O=e.cards.find(ue=>ue.id===U.id);if(!O)return;let le,ve;if(q.data.current?.type==="column"){le=q.id;let ue=ie.get(le)||[];ve=os(ue,0);}else {let ue=e.cards.find(Re=>Re.id===q.id);if(!ue)return;le=ue.columnId;let We=ie.get(le)||[],Me=We.findIndex(Re=>Re.id===q.id);ve=os(We,Me);}let Ee=e.columns.find(ue=>ue.id===le);if(Ee&&Ee.wipLimit&&Ee.wipLimitType==="hard"){let ue=ie.get(le)||[];if(O.columnId!==le&&ue.length>=Ee.wipLimit){t.onWipLimitExceeded?.(Ee,O);return}}(O.columnId!==le||O.position!==ve)&&await t.onCardMove?.(O.id,le,ve);},[e.cards,e.columns,ie,t,y]),L=useCallback(D=>{k(D),a?.(D),l?.(D.id);},[a,l]),B=useCallback(D=>{t.onCardUpdate?.(D.id,D),k(D);},[t]);return p?jsx("div",{className:f("asakaa-board",A,n),style:m,children:jsx(ku,{columnCount:3})}):i?jsx("div",{className:f("asakaa-board",A,n),style:m,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(Il,{themeName:x,children:[jsxs(DndContext,{sensors:V,collisionDetection:closestCorners,onDragStart:Oe,onDragOver:ze,onDragEnd:Pe,children:[jsxs("div",{className:f("asakaa-board",A,n),style:m,"data-theme":x,children:[e.columns.sort((D,U)=>D.position-U.position).map(D=>{let U=ie.get(D.id)||[],q=!_.includes(D.id);return jsx(io,{column:D,cards:U,renderCard:r?.renderCard,renderColumn:r?.renderColumn,renderHeader:r?.renderColumnHeader,renderEmptyState:r?.renderEmptyState,onCardClick:L,onCardUpdate:N,onColumnRename:H,onColumnDelete:$,isDeletable:q,availableUsers:s,allCards:e.cards,enableVirtualization:o?.enableVirtualization,cardHeight:o?.cardHeight},D.id)}),u]}),jsx(DragOverlay,{children:w.draggedCardId?jsx(mr,{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:S,isOpen:!!S,onClose:()=>k(null),onCardUpdate:B,theme:R?"dark":"light",locale:o?.locale==="es"?"es":"en",availableUsers:s,availableTags:d,onCreateTag:g,attachments:S?b?.get(S.id)||[]:[],onUploadAttachments:C,onDeleteAttachment:T,availableTasks:Be,comments:c,onAddComment:h,currentUser:v})]})}function ku({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 Du={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)"},Su={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)"},Eu={newTask:"Nueva Tarea",selectColumn:"Seleccionar columna",export:"Exportar",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"},Pu={newTask:"New Task",selectColumn:"Select column",export:"Export",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"};function Mu({columns:e,onSelect:t,theme:a,t:r,createTaskLabel:o}){let[s,n]=useState(false),m=useRef(null);useEffect(()=>{let i=u=>{m.current&&!m.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:m,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 Au({theme:e,t,onExportCSV:a,onExportJSON:r,onExportExcel:o}){let[s,n]=useState(false),[m,p]=useState(null),i=useRef(null);if(useEffect(()=>{let b=C=>{i.current&&!i.current.contains(C.target)&&n(false);};return s&&document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[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(b=>b.handler),g=async(b,C)=>{if(C){p(b);try{await C();}catch(T){console.error(`Export ${b} 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((b,C)=>jsxs(motion.button,{onClick:()=>g(b.id,b.handler),disabled:m!==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:m===b.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):b.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:b.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:b.description})]})]},b.id))})})})]})}function Fu({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 ws({columns:e,onCreateTask:t,createTaskLabel:a,theme:r="dark",locale:o="es",useColumnSelector:s=false,onExportCSV:n,onExportJSON:m,onExportExcel:p,translations:i}){let u=r==="dark"?Du:Su,d={...o==="es"?Eu:Pu,...i},g=n||m||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(Au,{theme:u,t:d,onExportCSV:n,onExportJSON:m,onExportExcel:p}),t&&jsx("div",{className:"w-px h-6",style:{backgroundColor:u.borderLight}})]}),t&&(s?jsx(Mu,{columns:e,onSelect:t,theme:u,t:d,createTaskLabel:a}):jsx(Fu,{onClick:()=>t(),label:a||d.newTask}))]})})}function Ts({onAddColumn:e,className:t,placeholder:a="Nombre de la columna...",buttonLabel:r="Agregar Columna",disabled:o=false}){let[s,n]=useState(false),[m,p]=useState(""),i=useCallback(()=>{let g=m.trim();g&&(e(g),p(""),n(false));},[m,e]),u=useCallback(g=>{g.key==="Enter"?(g.preventDefault(),i()):g.key==="Escape"&&(p(""),n(false));},[i]),d=useCallback(()=>{setTimeout(()=>{m.trim()||n(false);},150);},[m]);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:m,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:!m.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 Ns({columnId:e,onAddCard:t,availableUsers:a=[],className:r,placeholder:o,buttonLabel:s,disabled:n=false,theme:m="dark",locale:p="es"}){let[i,u]=useState(false),[d,g]=useState(false),[b,C]=useState(""),[T,c]=useState([]),[h,v]=useState(""),[l,w]=useState(""),[y,S]=useState(""),[k,x]=useState(false),[R,A]=useState(false),[N,H]=useState(false),$=useRef(null),_=useRef(null),V={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"},ie=useCallback(()=>{C(""),c([]),v(""),w(""),S(""),x(false),A(false),H(false),u(false);},[]);useEffect(()=>{i&&$.current&&$.current.focus();},[i]),useEffect(()=>{if(!i)return;let L=B=>{_.current&&!_.current.contains(B.target)&&(b.trim()||ie());};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[i,b,ie]);let Be=useCallback(async()=>{let L=b.trim();if(!(!L||d)){g(true);try{await t({name:L,columnId:e,assigneeIds:T.length>0?T:void 0,startDate:h?new Date(h):void 0,endDate:l?new Date(l):void 0,priority:y||void 0}),C(""),c([]),v(""),w(""),S(""),x(!1),A(!1),H(!1),$.current?.focus();}catch(B){console.error("Error creating card:",B);}finally{g(false);}}},[b,e,T,h,l,y,t,d]),Oe=useCallback(L=>{L.key==="Enter"&&!L.shiftKey?(L.preventDefault(),Be()):L.key==="Escape"&&ie();},[Be,ie]),ze=useCallback(L=>{c(B=>B.includes(L)?B.filter(D=>D!==L):[...B,L]);},[]),Pe=m==="dark";return i?jsxs("div",{ref:_,className:f("rounded-lg overflow-hidden shadow-lg",Pe?"bg-[#1e1e2e]":"bg-white",r),style:{border:"2px solid #10b981"},children:[jsxs("div",{className:"p-3",children:[jsx("input",{ref:$,type:"text",value:b,onChange:L=>C(L.target.value),onKeyDown:Oe,placeholder:V.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",Pe?"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:()=>x(!k),className:f("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",k||T.length>0?"bg-emerald-500/20 text-emerald-400":Pe?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:V.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(!R),className:f("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",R||h||l?"bg-blue-500/20 text-blue-400":Pe?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:V.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||y?y==="urgent"?"bg-red-500/20 text-red-400":y==="high"?"bg-orange-500/20 text-orange-400":y==="medium"?"bg-yellow-500/20 text-yellow-400":y==="low"?"bg-green-500/20 text-green-400":"bg-orange-500/20 text-orange-400":Pe?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:V.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:Be,disabled:!b.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"}):V.save})]})]}),k&&a.length>0&&jsx("div",{className:f("px-3 pb-3 pt-0","border-t",Pe?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex flex-wrap gap-1.5 pt-3",children:a.map(L=>jsxs("button",{onClick:()=>ze(L.id),className:f("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs transition-all",T.includes(L.id)?"bg-emerald-500 text-white":Pe?"bg-[#2a2a3e] text-gray-300 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-700 hover:bg-gray-200"),type:"button",children:[L.avatar?jsx("img",{src:L.avatar,alt:L.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(L.id)?"bg-emerald-600 text-white":"bg-emerald-500 text-white"),children:L.name.charAt(0).toUpperCase()}),jsx("span",{children:L.name.split(" ")[0]})]},L.id))})}),R&&jsx("div",{className:f("px-3 pb-3 pt-0","border-t",Pe?"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",Pe?"text-gray-500":"text-gray-400"),children:V.startDate}),jsx("input",{type:"date",value:h,onChange:L=>v(L.target.value),className:f("w-full px-2 py-1.5 rounded text-xs border",Pe?"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",Pe?"text-gray-500":"text-gray-400"),children:V.endDate}),jsx("input",{type:"date",value:l,onChange:L=>w(L.target.value),className:f("w-full px-2 py-1.5 rounded text-xs border",Pe?"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",Pe?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex gap-1.5 pt-3",children:["low","medium","high","urgent"].map(L=>jsx("button",{onClick:()=>S(y===L?"":L),className:f("flex-1 px-2 py-1.5 rounded text-xs font-medium transition-all",y===L?`${{low:"bg-green-500",medium:"bg-yellow-500",high:"bg-orange-500",urgent:"bg-red-500"}[L]} text-white`:Pe?"bg-[#2a2a3e] text-gray-400 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-600 hover:bg-gray-200"),type:"button",children:V[L]},L))})})]}):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",Pe?"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:V.buttonLabel})]})}var Mo=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(Sr,{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 yd(e={}){return new Mo(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 Ds(e,t){let a=r=>jsx(co,{...t,children:jsx(e,{...r})});return a.displayName=`withErrorBoundary(${e.displayName||e.name||"Component"})`,a}function Es({board:e,onCreateCard:t,onNavigateToCard:a,onSearch:r,onChangePriority:o,onAssignUser:s,onGeneratePlan:n,onPredictRisks:m,onOpenAIUsage:p,shortcut:i="k",className:u=""}){let[d,g]=useState(false),[b,C]=useState(""),[T,c]=useState("home"),[h,v]=useState(""),[l,w]=useState("");useEffect(()=>{let x=R=>{(R.metaKey||R.ctrlKey)&&R.key===i&&(R.preventDefault(),g(A=>!A)),R.key==="Escape"&&(g(false),c("home"),C(""));};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[i]),useEffect(()=>{d||(c("home"),C(""),v(""),w(""));},[d]);let y=useCallback(()=>{g(false);},[]),S=useCallback(x=>{let[R,A]=x.split(":");switch(R){case "create-card":c("create-card");break;case "create-card-in":v(A||"");break;case "navigate":A?(a?.(A),y()):c("navigate");break;case "search":r?.(b),y();break;case "priority":c("priority");break;case "set-priority":l&&A&&(o?.(l,A),y());break;case "assign":c("assign");break;case "assign-user":l&&A&&(s?.(l,A),y());break;case "ai":c("ai");break;case "ai-generate-plan":n?.(),y();break;case "ai-predict-risks":m?.(),y();break;case "ai-usage":p?.(),y();break;case "back":c("home");break;}},[b,l,t,a,r,o,s,n,m,p,y]),k=useCallback(()=>{h&&b.trim()&&(t?.(h,b.trim()),y());},[h,b,t,y]);return d?jsx(ht,{children:jsx("div",{className:"command-palette-overlay",onClick:y,children:jsx("div",{className:`command-palette ${u}`,onClick:x=>x.stopPropagation(),children:jsxs(Command,{value:b,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"&&h?"Type card title and press Enter...":T==="create-card"?"Select a column first...":"Type a command or search...",className:"command-palette-input",onKeyDown:x=>{x.key==="Enter"&&T==="create-card"&&h&&k();}}),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(x=>jsxs(Command.Item,{value:`navigate:${x.id}`,onSelect:S,className:"command-palette-item",children:[jsx("div",{className:"command-palette-item-dot",style:{background:x.priority==="URGENT"?"#EF4444":x.priority==="HIGH"?"#F59E0B":x.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:x.title}),x.labels&&x.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:x.labels.slice(0,2).map(R=>jsx("span",{className:"command-palette-item-label",children:R},R))})]},x.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(x=>jsxs(Command.Item,{value:`create-card-in:${x.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:x.title}),jsxs("div",{className:"command-palette-item-count",children:[x.cardIds.length," cards"]})]},x.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(x=>{let R=e.columns.find(A=>A.id===x.columnId);return jsxs(Command.Item,{value:`navigate:${x.id}`,onSelect:S,className:"command-palette-item",keywords:[x.title,x.description||"",...x.labels||[]],children:[jsx("div",{className:"command-palette-item-dot",style:{background:x.priority==="URGENT"?"#EF4444":x.priority==="HIGH"?"#F59E0B":x.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsxs("div",{className:"command-palette-item-content",children:[jsx("div",{children:x.title}),jsx("div",{className:"command-palette-item-meta",children:R?.title})]}),x.labels&&x.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:x.labels.slice(0,2).map(A=>jsx("span",{className:"command-palette-item-label",children:A},A))})]},x.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 kd(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;
@@ -11,12 +11,12 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
11
11
  justify-content: center !important;
12
12
  background: rgba(0, 0, 0, 0.95) !important;
13
13
  cursor: pointer !important;
14
- `;let p=document.createElement("img");p.src=e,p.alt=t,p.className="attachment-lightbox-image",p.style.cssText=`
14
+ `;let m=document.createElement("img");m.src=e,m.alt=t,m.className="attachment-lightbox-image",m.style.cssText=`
15
15
  max-width: 92vw !important;
16
16
  max-height: 92vh !important;
17
17
  object-fit: contain !important;
18
18
  cursor: default !important;
19
- `,p.onclick=d=>d.stopPropagation();let m=document.createElement("div");m.className="attachment-lightbox-hint",m.textContent="Click anywhere or press ESC to close",m.style.cssText=`
19
+ `,m.onclick=d=>d.stopPropagation();let p=document.createElement("div");p.className="attachment-lightbox-hint",p.textContent="Click anywhere or press ESC to close",p.style.cssText=`
20
20
  position: absolute !important;
21
21
  bottom: 24px !important;
22
22
  left: 50% !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
- `,b.onmouseenter=()=>{b.style.opacity="1";},b.onmouseleave=()=>{b.style.opacity="0.5";},b.onclick=C=>{C.stopPropagation();let T=r<a.length-1?r+1:0;i(),o(T);},n.appendChild(d),n.appendChild(g),n.appendChild(b);}n.appendChild(p),n.appendChild(m),document.body.appendChild(n),setTimeout(()=>{m.style.transition="opacity 0.5s ease",m.style.opacity="0";},2e3);}function Ou(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 zu(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 Ms(e){return e.startsWith("image/")}function dr({attachments:e=[],onUpload:t,onDelete:a,maxSizeMB:r=10,allowedTypes:o,maxFiles:s=10}){let[n,p]=useState(false),[m,i]=useState(false),[u,d]=useState(null),g=useRef(null),b=useRef(e);b.current=e;let C=useCallback((x,R)=>{R.preventDefault(),R.stopPropagation();let A=b.current.filter($=>Ms($.type)),N=A.findIndex($=>$.id===x.id),U=$=>{let _=b.current.filter(pe=>Ms(pe.type)),q=_[$];q&&kd(q.url,q.name,_,$,U);};kd(x.url,x.name,A,N,U);},[]),T=useCallback(x=>{let R=[],A=[];return e.length+x.length>s?(A.push(`Maximum ${s} files allowed`),{valid:R,errors:A}):(x.forEach(N=>{if(N.size/1048576>r){A.push(`${N.name} is too large (max ${r}MB)`);return}if(o&&!o.some($=>N.type.match($))){A.push(`${N.name} has invalid file type`);return}R.push(N);}),{valid:R,errors:A})},[e.length,s,r,o]),c=useCallback(async x=>{let{valid:R,errors:A}=T(x);if(A.length>0){d(A.join(", ")),setTimeout(()=>d(null),5e3);return}if(R.length!==0){i(true),d(null);try{await t?.(R);}catch(N){d(N instanceof Error?N.message:"Upload failed"),setTimeout(()=>d(null),5e3);}finally{i(false);}}},[T,t]),h=useCallback(x=>{x.preventDefault(),x.stopPropagation(),p(true);},[]),v=useCallback(x=>{x.preventDefault(),x.stopPropagation(),p(false);},[]),l=useCallback(x=>{x.preventDefault(),x.stopPropagation();},[]),k=useCallback(x=>{x.preventDefault(),x.stopPropagation(),p(false);let R=Array.from(x.dataTransfer.files);c(R);},[c]),y=useCallback(x=>{let R=x.target.files?Array.from(x.target.files):[];c(R),g.current&&(g.current.value="");},[c]),S=useCallback(()=>{g.current?.click();},[]),w=useCallback(x=>{confirm("Are you sure you want to delete this attachment?")&&a?.(x);},[a]);return jsxs("div",{className:"attachment-uploader",children:[jsxs("div",{className:`attachment-dropzone ${n?"dragging":""} ${m?"uploading":""}`,onDragEnter:h,onDragLeave:v,onDragOver:l,onDrop:k,onClick:S,children:[jsx("input",{ref:g,type:"file",multiple:true,onChange:y,style:{display:"none"},accept:o?.join(",")}),jsx("div",{className:"attachment-dropzone-content",children:m?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(x=>jsxs("div",{className:"attachment-item",children:[jsx("div",{className:"attachment-preview",children:Ms(x.type)&&x.url?jsxs("button",{type:"button",className:"attachment-thumbnail-btn",onClick:R=>C(x,R),title:"Click to view full size",children:[jsx("img",{src:x.thumbnailUrl||x.url,alt:x.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:zu(x.type)})}),jsxs("div",{className:"attachment-info",children:[jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",className:"attachment-name",title:x.name,children:x.name}),jsxs("div",{className:"attachment-meta",children:[jsx("span",{className:"attachment-size",children:Ou(x.size)}),jsx("span",{className:"attachment-separator",children:"\u2022"}),jsx("span",{className:"attachment-date",children:new Date(x.uploadedAt).toLocaleDateString()})]})]}),jsx("button",{onClick:()=>w(x.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"})})})]},x.id))})]})}function As({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:p=[],aiInsights:m=[],attachments:i=[],onAddComment:u,onDeleteComment:d,onUploadAttachments:g,onDeleteAttachment:b,onSuggestAssignee:C,onGenerateSubtasks:T,onEstimateEffort:c,currentUserId:h="user-1"}){let[v,l]=useState("details"),[k,y]=useState(false),[S,w]=useState({}),[x,R]=useState(""),[A,N]=useState(false),[U,$]=useState({});if(!t||!e)return null;let _=useCallback(()=>{y(false),w({}),l("details"),R(""),$({}),a();},[a]),q=useCallback(()=>{r&&Object.keys(S).length>0&&(r(e.id,S),w({}),y(false));},[e.id,S,r]),pe=useCallback(()=>{o&&window.confirm("Are you sure you want to delete this card?")&&(o(e.id),_());},[e.id,o,_]),Te=useCallback(()=>{u&&x.trim()&&(u(e.id,x.trim()),R(""));},[e.id,x,u]),Ze=useCallback(async()=>{if(C){N(true);try{let D=await C(e);$(W=>({...W,assignees:D}));}catch(D){console.error("Failed to suggest assignee:",D);}finally{N(false);}}},[e,C]),Oe=useCallback(async()=>{if(T){N(true);try{let D=await T(e);$(W=>({...W,subtasks:D}));}catch(D){console.error("Failed to generate subtasks:",D);}finally{N(false);}}},[e,T]),Be=useCallback(async()=>{if(c){N(true);try{let D=await c(e);$(W=>({...W,effort:D}));}catch(D){console.error("Failed to estimate effort:",D);}finally{N(false);}}},[e,c]),L={...e,...S},B=s.filter(D=>L.assignedUserIds?.includes(D.id));return jsx(ht,{children:jsx("div",{className:"card-detail-overlay",onClick:_,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:L.priority==="URGENT"?"#EF4444":L.priority==="HIGH"?"#F59E0B":L.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),k?jsx("input",{type:"text",value:S.title??L.title,onChange:D=>w({...S,title:D.target.value}),className:"card-detail-title-input",placeholder:"Card title"}):jsx("h2",{className:"card-detail-title",children:L.title})]}),jsxs("div",{className:"card-detail-header-actions",children:[k?jsxs(Fragment,{children:[jsx("button",{onClick:q,className:"card-detail-btn card-detail-btn-primary",children:"Save"}),jsx("button",{onClick:()=>{y(false),w({});},className:"card-detail-btn",children:"Cancel"})]}):jsxs("button",{onClick:()=>y(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:pe,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:_,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 ${v==="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 ${v==="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 ${v==="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",p.length>0&&jsx("span",{className:"card-detail-tab-badge",children:p.length})]}),jsxs("button",{onClick:()=>l("attachments"),className:`card-detail-tab ${v==="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 ${v==="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:[v==="details"&&jsxs("div",{className:"card-detail-details",children:[jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Description"}),k?jsx("textarea",{value:S.description??L.description??"",onChange:D=>w({...S,description:D.target.value}),className:"card-detail-textarea",placeholder:"Add a description...",rows:4}):jsx("p",{className:"card-detail-text",children:L.description||"No description"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Assigned To"}),k?jsx("select",{multiple:true,value:S.assignedUserIds??L.assignedUserIds??[],onChange:D=>{let W=Array.from(D.target.selectedOptions,Y=>Y.value);w({...S,assignedUserIds:W});},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:B.length>0?B.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"}),k?jsxs("select",{value:S.priority??L.priority??"",onChange:D=>w({...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:L.priority==="URGENT"?"#EF4444":L.priority==="HIGH"?"#F59E0B":L.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:L.priority||"None"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Labels"}),jsx("div",{className:"card-detail-labels",children:L.labels&&L.labels.length>0?L.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"}),k?jsx("input",{type:"date",value:S.startDate?new Date(S.startDate).toISOString().split("T")[0]:L.startDate?new Date(L.startDate).toISOString().split("T")[0]:"",onChange:D=>w({...S,startDate:D.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:L.startDate?new Date(L.startDate).toLocaleDateString():"Not set"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"End Date"}),k?jsx("input",{type:"date",value:S.endDate?new Date(S.endDate).toISOString().split("T")[0]:L.endDate?new Date(L.endDate).toISOString().split("T")[0]:"",onChange:D=>w({...S,endDate:D.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:L.endDate?new Date(L.endDate).toLocaleDateString():"Not set"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Estimated Hours"}),k?jsx("input",{type:"number",min:"0",step:"0.5",value:S.estimatedTime??L.estimatedTime??"",onChange:D=>w({...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:L.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:L.dependencies&&L.dependencies.length>0?L.dependencies.map(D=>{let W=typeof D=="string"?D:D.taskId;return jsxs("span",{className:"card-detail-dependency",children:["Card #",W.slice(-4)]},W)}):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:L.createdAt?new Date(L.createdAt).toLocaleString():"Unknown"})]})]}),v==="comments"&&jsxs("div",{className:"card-detail-comments",children:[jsxs("div",{className:"card-detail-comment-form",children:[jsx("textarea",{value:x,onChange:D=>R(D.target.value),className:"card-detail-comment-textarea",placeholder:"Write a comment...",rows:3}),jsx("button",{onClick:Te,disabled:!x.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 W=s.find(Y=>Y.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:[W&&jsx("div",{className:"card-detail-user-avatar",style:{background:W.color},children:W.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-comment-author-name",children:W?.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"})]})})]}),v==="activity"&&jsx("div",{className:"card-detail-activity",children:p.length>0?jsx("div",{className:"card-detail-activity-list",children:p.map(D=>{let W=s.find(Y=>Y.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:W?.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"})]})}),v==="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:b,currentUserId:h,maxSizeMB:10,maxFiles:20})}),v==="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:Ze,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:Oe,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:Be,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("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Estimate Effort"]})]}),U.assignees&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Assignee Suggestions"}),U.assignees.map((D,W)=>{let Y=s.find(O=>O.id===D.userId);return jsxs("div",{className:"card-detail-ai-suggestion",children:[Y&&jsx("div",{className:"card-detail-user-avatar",style:{background:Y.color},children:Y.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-ai-suggestion-name",children:Y?.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),"%"]})]})]},W)})]}),U.subtasks&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Suggested Subtasks"}),U.subtasks.map((D,W)=>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"]})]},W))]}),U.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:[U.effort.hours," hours"]}),jsxs("div",{className:"card-detail-ai-effort-confidence",children:["Confidence: ",(U.effort.confidence*100).toFixed(0),"%"]})]})]}),m.length>0&&jsxs("div",{className:"card-detail-ai-insights",children:[jsx("h4",{children:"AI Insights"}),m.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))]}),!U.assignees&&!U.subtasks&&!U.effort&&m.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 Fo({triggerRef:e,isOpen:t,onClose:a,children:r,width:o=200,estimatedHeight:s=300,className:n=""}){let[p,m]=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,b=window.innerWidth,C=4,T=d.left;T+o>b-10&&(T=b-o-10),T<10&&(T=10);let c=g-d.bottom,h=d.top,v;return c>=s+C?v=d.bottom+C:h>=s+C?v=d.top-s-C:c>=h?v=d.bottom+C:v=Math.max(10,d.top-s-C),{top:v,left:T}},[e,o,s]);return useEffect(()=>{t&&m(u());},[t,u]),useEffect(()=>{if(!t)return;let d=b=>{let C=b.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(ht,{children:jsx("div",{ref:i,className:`smart-popover ${n}`,style:{position:"fixed",top:`${p.top}px`,left:`${p.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 Xe={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 Ku=["LOW","MEDIUM","HIGH","URGENT"],Yu=["todo","in-progress","review","done"];function Is({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:p=[],onAddComment:m,onDeleteComment:i,currentUser:u,onAIGenerateDescription:d,onAICreateSubtasks:g,onAIFindSimilar:b,availableColumns:C=[],availableLabels:T=[],availableTags:c=[],onCreateTag:h,onUploadCoverImage:v,unsplashAccessKey:l,theme:k,onSubtasksChange:y,attachments:S=[],onUploadAttachments:w,onDeleteAttachment:x}){let R=oo(),A=k||R?.themeName||"dark",[N,U]=useState(e),[$,_]=useState(false),[q,pe]=useState(e?.subtasks||[]),[Te,Ze]=useState(false),[Oe,Be]=useState(""),[L,B]=useState(""),[D,W]=useState("all"),[Y,O]=useState(false),[ie,ve]=useState(false),[Ee,fe]=useState(false),[We,Re]=useState(false),[Le,ze]=useState(false),[yt,nt]=useState(false),z=useRef(null),ne=useRef(null),le=useRef(null),we=useRef(null),$e=useRef(null),et=useRef(null),vt=useRef(null),Pe=useRef(null),Vt=useRef(null),ft=useRef(null),st=useRef(null),mt=useRef(null);useEffect(()=>{e&&!N?(U({...e}),pe(e.subtasks||[])):e&&N&&e.id!==N.id&&(U({...e}),pe(e.subtasks||[]));},[e,N]),useEffect(()=>{let G=de=>{let Ie=de.target;we.current&&!we.current.contains(Ie)&&O(false),$e.current&&!$e.current.contains(Ie)&&ve(false),et.current&&!et.current.contains(Ie)&&fe(false),vt.current&&!vt.current.contains(Ie)&&Re(false);};if(Y||ie||Ee||We)return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[Y,ie,Ee,We]),useEffect(()=>{if(!t)return;let G=de=>{let Ie=de.target,At=Ie.tagName==="INPUT"||Ie.tagName==="TEXTAREA"||Ie.isContentEditable;if(de.key==="Escape"){de.preventDefault(),Y||ie||Ee||We||Le||yt?(O(false),ve(false),fe(false),Re(false),ze(false),nt(false)):At||a();return}if(At&&de.key!=="Escape")return;let tt=de.metaKey||de.ctrlKey;switch(de.key.toLowerCase()){case "s":de.preventDefault(),O(true);break;case "a":de.preventDefault(),fe(true);break;case "p":de.preventDefault(),ve(true);break;case "l":de.preventDefault(),Re(true);break;case "d":tt||(de.preventDefault(),ze(true),setTimeout(()=>Pe.current?.focus(),0));break;case "e":tt||(de.preventDefault(),nt(true));break;case "i":de.preventDefault(),_(true),setTimeout(()=>ne.current?.focus(),0);break;case "t":de.preventDefault(),Ze(true);break;case "c":de.preventDefault(),le.current?.focus();break}};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[t,a,Y,ie,Ee,We,Le,yt]);let Lt=useCallback(G=>{let de=G.currentTarget.textContent?.trim()||"";if(N&&de!==N.title){let Ie={...N,title:de};U(Ie),r?.(N.id,{title:de});}},[N,r]),va=useCallback(G=>{G.key==="Enter"&&(G.preventDefault(),G.currentTarget.blur()),G.key==="Escape"&&(G.preventDefault(),G.currentTarget.textContent=N?.title||"",G.currentTarget.blur());},[N]),ee=useCallback(()=>{N&&e&&N.description!==e.description&&r?.(N.id,{description:N.description}),_(false);},[N,e,r]),te=useCallback(G=>{if(N){let de={...N,columnId:G};U(de),r?.(N.id,{columnId:G}),O(false);}},[N,r]),it=useCallback(G=>{if(N){let de={...N,priority:G};U(de),r?.(N.id,{priority:G}),ve(false);}},[N,r]),ae=useCallback(G=>{if(N){let de=N.assignedUserIds||[],Ie=de.includes(G)?de.filter(tt=>tt!==G):[...de,G],At={...N,assignedUserIds:Ie};U(At),r?.(N.id,{assignedUserIds:Ie});}},[N,r]),E=useCallback(G=>{if(N){let de=N.labels||[],Ie=de.includes(G)?de.filter(tt=>tt!==G):[...de,G],At={...N,labels:Ie};U(At),r?.(N.id,{labels:Ie});}},[N,r]),X=useCallback(G=>{if(N){let de={...N,tags:G};U(de),r?.(N.id,{tags:G});}},[N,r]),be=useCallback(G=>{if(N){let de=G.target.value,Ie={...N,endDate:de};U(Ie),r?.(N.id,{endDate:de}),ze(false);}},[N,r]),Ae=useCallback(G=>{if(N){let de={...N,estimatedTime:parseFloat(G)||0};U(de),r?.(N.id,{estimatedTime:parseFloat(G)||0});}},[N,r]),Ge=useCallback(()=>{if(Oe.trim()&&N){let G={id:`subtask-${Date.now()}`,title:Oe.trim(),completed:false,createdAt:new Date},de=[...q,G];pe(de),Be(""),Ze(false),y?.(N.id,de);}},[Oe,q,N,y]),Ye=useCallback(G=>{let de=q.map(Ie=>Ie.id===G?{...Ie,completed:!Ie.completed,updatedAt:new Date}:Ie);pe(de),N&&y?.(N.id,de);},[q,N,y]),Ue=useCallback(G=>{let de=q.filter(Ie=>Ie.id!==G);pe(de),N&&y?.(N.id,de);},[q,N,y]),ot=useCallback(()=>{L.trim()&&N&&m&&(m(N.id,L.trim()),B(""));},[L,N,m]),pt=useCallback(G=>{(G.metaKey||G.ctrlKey)&&G.key==="Enter"&&(G.preventDefault(),ot());},[ot]),V=G=>jsx(_u,{remarkPlugins:[Vu],rehypePlugins:[ju],components:{a:({node:de,...Ie})=>jsx("a",{...Ie,target:"_blank",rel:"noopener noreferrer"})},children:G}),re=p.filter(G=>D==="comments"?G.type.includes("COMMENT"):D==="history"?!G.type.includes("COMMENT"):true);if(!t||!e)return null;let Se=N||e,qe=s.filter(G=>Se.assignedUserIds?.includes(G.id)),_e=q.filter(G=>G.completed).length;return jsx(ht,{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:Lt,onKeyDown:va,children:Se.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:we,children:[jsxs("button",{ref:Vt,className:"modal-v2-field",onClick:()=>O(!Y),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:Se.columnId||"No status"})]}),jsx(Fo,{triggerRef:Vt,isOpen:Y,onClose:()=>O(false),width:250,estimatedHeight:200,children:(C.length>0?C:Yu.map(G=>({id:G,title:G}))).map(G=>jsx("button",{className:`modal-v2-popover-item ${Se.columnId===G.id?"active":""}`,onClick:()=>te(G.id),children:G.title},G.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:et,children:[jsxs("button",{ref:ft,className:"modal-v2-field",onClick:()=>fe(!Ee),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:qe.length>0?jsx("div",{className:"modal-v2-avatars",children:qe.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(Fo,{triggerRef:ft,isOpen:Ee,onClose:()=>fe(false),width:280,estimatedHeight:300,children:s.map(G=>jsxs("button",{className:`modal-v2-popover-item ${Se.assignedUserIds?.includes(G.id)?"active":""}`,onClick:()=>ae(G.id),children:[jsx("div",{className:"modal-v2-avatar-small",style:{background:G.color},children:G.initials}),G.name,Se.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:$e,children:[jsxs("button",{ref:st,className:"modal-v2-field",onClick:()=>ve(!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:"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:Se.priority||"None"})]}),jsxs(Fo,{triggerRef:st,isOpen:ie,onClose:()=>ve(false),width:180,estimatedHeight:220,children:[Ku.map(G=>jsx("button",{className:`modal-v2-popover-item priority-${G.toLowerCase()} ${Se.priority===G?"active":""}`,onClick:()=>it(G),children:G},G)),jsx("button",{className:"modal-v2-popover-item",onClick:()=>it(""),children:"None"})]})]}),c.length>0||h?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:Se.tags||[],availableTags:c,onChange:X,onCreateTag:h,theme:Xe[A]||Xe.dark})})]})}):jsxs("div",{className:"modal-v2-field-wrapper",ref:vt,children:[jsxs("button",{ref:mt,className:"modal-v2-field",onClick:()=>Re(!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:Se.labels&&Se.labels.length>0?jsx("span",{children:Se.labels.join(", ")}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(Fo,{triggerRef:mt,isOpen:We,onClose:()=>Re(false),width:220,estimatedHeight:200,children:(T.length>0?T:["Bug","Feature","Enhancement","Documentation"]).map(G=>jsxs("button",{className:`modal-v2-popover-item ${Se.labels?.includes(G)?"active":""}`,onClick:()=>E(G),children:[G,Se.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:()=>{ze(!Le),setTimeout(()=>Pe.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:Se.endDate?new Date(Se.endDate).toLocaleDateString():"Not set"}),jsx("input",{ref:Pe,type:"date",value:typeof Se.endDate=="string"?Se.endDate.split("T")[0]:Se.endDate?(()=>{let G=new Date(Se.endDate),de=G.getUTCFullYear(),Ie=String(G.getUTCMonth()+1).padStart(2,"0"),At=String(G.getUTCDate()).padStart(2,"0");return `${de}-${Ie}-${At}`})():"",onChange:be,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:Se.estimatedTime?`${Se.estimatedTime}h`:"Not set"})]}),yt&&jsx("div",{className:"modal-v2-popover",children:jsx("input",{type:"number",min:"0",step:"0.5",placeholder:"Hours",value:Se.estimatedTime||"",onChange:G=>Ae(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"})]}),$?jsx("textarea",{className:"modal-v2-textarea",value:Se.description||"",onChange:G=>{if(N){let de={...N,description:G.target.value};U(de);}},onBlur:ee,placeholder:"Add a detailed description...",autoFocus:true}):jsx("div",{className:"modal-v2-content",onClick:()=>_(true),children:Se.description?jsx("div",{className:"modal-v2-markdown",children:V(Se.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"}),q.length>0&&jsxs("span",{className:"modal-v2-count",children:[_e,"/",q.length]}),jsxs("button",{className:"modal-v2-add-button",onClick:()=>Ze(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:[q.map(G=>jsxs("div",{className:`modal-v2-subtask ${G.completed?"completed":""}`,children:[jsx("button",{className:"modal-v2-subtask-checkbox",onClick:()=>Ye(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:()=>Ue(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)),Te&&jsx("div",{className:"modal-v2-subtask-input-row",children:jsx("input",{type:"text",placeholder:"Subtask title...",value:Oe,onChange:G=>Be(G.target.value),onKeyDown:G=>{G.key==="Enter"&&Ge(),G.key==="Escape"&&(Ze(false),Be(""));},onBlur:Ge,autoFocus:true,className:"modal-v2-subtask-input"})})]})]}),(w||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(dr,{cardId:Se.id,attachments:S,onUpload:w?G=>w(Se.id,G):void 0,onDelete:x,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:()=>W("all"),children:"All"}),jsx("button",{className:`modal-v2-filter ${D==="comments"?"active":""}`,onClick:()=>W("comments"),children:"Comments"}),jsx("button",{className:`modal-v2-filter ${D==="history"?"active":""}`,onClick:()=>W("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:le,className:"modal-v2-comment-textarea",placeholder:"Write a comment...",value:L,onChange:G=>B(G.target.value),onKeyDown:pt,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:ot,disabled:!L.trim(),children:"Send"})]})]})]}),jsxs("div",{className:"modal-v2-timeline",children:[re.map(G=>{let de=s.find(At=>At.id===G.userId);if(G.type.includes("COMMENT")){let At=n.find(tt=>tt.id===G.metadata?.commentId);return At?jsxs("div",{className:"modal-v2-activity-item comment-item",children:[de&&jsx("div",{className:"modal-v2-avatar",style:{background:de.color},children:de.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:de?.name||"Unknown"}),jsx("span",{className:"modal-v2-activity-time",children:new Date(G.timestamp).toLocaleString()})]}),jsx("div",{className:"modal-v2-comment-body",children:At.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:de?.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 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.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 Rs({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((p,m)=>p+m.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(rg,{})}),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,p)=>n+p.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,p)=>n+p.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,p)=>n+(p.planned||0),0)})]})]})]})}function pg({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 $s({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,p=e[e.length-1]?.ideal||0,m=s>0?(s-n)/s*100:0,i=n<=p;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(pg,{})}),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:m>=50?"#10B981":"#F59E0B"},children:[m.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 kg={URGENT:"#EF4444",HIGH:"#F59E0B",MEDIUM:"#3B82F6",LOW:"#10B981"},Md=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899"];function wg({cx:e,cy:t,midAngle:a,innerRadius:r,outerRadius:o,percent:s}){let n=r+(o-r)*.5,p=e+n*Math.cos(-a*(Math.PI/180)),m=t+n*Math.sin(-a*(Math.PI/180));return s<.05?null:jsx("text",{x:p,y:m,fill:"white",textAnchor:p>e?"start":"end",dominantBaseline:"central",style:{fontSize:"12px",fontWeight:600},children:`${(s*100).toFixed(0)}%`})}function Ad({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 Os({data:e,title:t="Distribution",type:a="pie",height:r=300,showPercentages:o=true}){let s=e.reduce((m,i)=>m+i.value,0),n=e.map(m=>({...m,totalValue:s,color:m.color||kg[m.name]||Md[e.indexOf(m)%Md.length]})),p=n.map(m=>m.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?wg:false,outerRadius:r*.35,fill:"#8884d8",dataKey:"value",children:n.map((m,i)=>jsx(Cell,{fill:p[i]},`cell-${i}`))}),jsx(Tooltip,{content:jsx(Ad,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"},formatter:(m,i)=>{let u=i.payload,d=s>0?(u.value/s*100).toFixed(0):"0";return `${m} (${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(Ad,{})}),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((m,i)=>jsx(Cell,{fill:p[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((m,i)=>i.value>m.value?i:m).name})]})]})]})}var fn=memo(({selectedCards:e,availableUsers:t=[],onClearSelection:a,callbacks:r,columns:o=[],availableLabels:s=[]})=>{let[n,p]=useState(false),[m,i]=useState(false),[u,d]=useState(false),[g,b]=useState(false);if(e.length===0)return null;let C=e.map(k=>k.id),T=k=>{r.onBulkUpdate?.(C,{priority:k}),p(false);},c=k=>{r.onBulkMove?.(C,k),i(false),a();},h=k=>{r.onBulkUpdate?.(C,{assignedUserIds:k}),d(false);},v=k=>{let y=new Set;e.forEach(w=>{w.labels?.forEach(x=>y.add(x));});let S=Array.from(new Set([...y,...k]));r.onBulkUpdate?.(C,{labels:S}),b(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:()=>p(!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(k=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>T(k),children:[jsx("span",{className:f("asakaa-priority-dot",k==="LOW"&&"bg-asakaa-priority-low",k==="MEDIUM"&&"bg-asakaa-priority-medium",k==="HIGH"&&"bg-asakaa-priority-high",k==="URGENT"&&"bg-asakaa-priority-urgent")}),k]},k))})]}),o.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>i(!m),title:"Move to column",children:jsx("span",{className:"text-sm",children:"Move"})}),m&&jsx("div",{className:"asakaa-bulk-menu",children:o.map(k=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>c(k.id),children:k.title},k.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(k=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>h([k.id]),children:[jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs font-medium",style:{backgroundColor:k.color},children:k.initials}),k.name]},k.id))})]}),s.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>b(!g),title:"Add labels",children:jsx("span",{className:"text-sm",children:"Labels"})}),g&&jsx("div",{className:"asakaa-bulk-menu",children:s.map(k=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>v([k]),children:k},k))})]}),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 Sg(e,t,a){if(t==="none")return [];let r=new Map;return e.forEach(o=>{let s,n,p,m,i;switch(t){case "assignee":let u=o.assignedUserIds||(o.assigneeId?[o.assigneeId]:[]);u.length>0?u.forEach(b=>{let C=a?.find(T=>T.id===b);n=`assignee-${b}`,p=C?.name||`User ${b}`,m=C?.color,i=C?.avatar,r.has(n)||r.set(n,{id:n,title:p,groupValue:b,cardIds:[],color:m,icon:i}),r.get(n).cardIds.push(o.id);}):(n="assignee-unassigned",p="Unassigned",m="#6b7280",i="\u{1F464}",r.has(n)||r.set(n,{id:n,title:p,groupValue:null,cardIds:[],color:m,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];p=g.title,m=g.color,r.has(n)||r.set(n,{id:n,title:p,groupValue:s,cardIds:[],color:m}),r.get(n).cardIds.push(o.id);break;case "label":o.labels&&o.labels.length>0?o.labels.forEach(b=>{n=`label-${b}`,p=b,m="#6b7280",r.has(n)||r.set(n,{id:n,title:p,groupValue:b,cardIds:[],color:m}),r.get(n).cardIds.push(o.id);}):(n="label-none",p="No Labels",m="#6b7280",r.has(n)||r.set(n,{id:n,title:p,groupValue:null,cardIds:[],color:m}),r.get(n).cardIds.push(o.id));break}}),Array.from(r.values()).sort((o,s)=>o.title.localeCompare(s.title))}function zs({board:e,swimlaneConfig:t,availableUsers:a,callbacks:r,className:o}){let[s,n]=useState(new Set),p=useMemo(()=>Sg(e.cards,t.groupBy,a),[e.cards,t.groupBy,a]),m=useCallback(i=>{n(u=>{let d=new Set(u);return d.has(i)?d.delete(i):d.add(i),d});},[]);return t.groupBy==="none"||p.length===0?jsx(Sr,{board:e,callbacks:r,availableUsers:a,className:o}):jsxs("div",{className:f("asakaa-swimlane-view",o),children:[p.map(i=>{let u=s.has(i.id),d=e.cards.filter(b=>i.cardIds.includes(b.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&&m(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(Sr,{board:g,callbacks:r,availableUsers:a})})]},i.id)}),p.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 Us=[{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 Hs({value:e,onChange:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null),p=Us.find(i=>i.value===e)||Us[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 m=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:p.icon}),jsx("span",{children:p.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:Us.map(i=>jsxs("button",{onClick:()=>m(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 Lo=[{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 Mg(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,p=o.alt?e.altKey:!e.altKey,m=o.meta?e.metaKey:true;return s&&n&&p&&m}function Rd(e={}){let{shortcuts:t=Lo,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(m=>{o.current=[...o.current,m];},[]),p=useCallback(m=>{o.current=o.current.filter(i=>i.action!==m);},[]);return useEffect(()=>{function m(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(Mg(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",m),()=>window.removeEventListener("keydown",m)},[r]),{registerShortcut:n,unregisterShortcut:p,isEnabled:a}}function Fg(e){return {ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192",Enter:"\u21B5",Escape:"Esc",Delete:"Del"," ":"Space"}[e]||e.toUpperCase()}function Lg(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 Ig(e){let t=Array.isArray(e.keys)?e.keys[0]:e.keys,a=Lg(e),r=t?Fg(t):"";return a?`${a} + ${r}`:r}function Bg(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 Ws({shortcuts:e=Lo,isOpen:t,onClose:a,className:r}){let[o,s]=useState(false);if(useEffect(()=>{s(true);},[]),useEffect(()=>{function p(m){m.key==="Escape"&&t&&a();}if(t)return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[t,a]),!o||!t)return null;let n=Bg(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(([p,m])=>m.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"}),p]}),jsx("div",{className:"space-y-3",children:m.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:Ig(i)})]},i.action))})]},p))})}),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 Gs=[{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
+ `,b.onmouseenter=()=>{b.style.opacity="1";},b.onmouseleave=()=>{b.style.opacity="0.5";},b.onclick=C=>{C.stopPropagation();let T=r<a.length-1?r+1:0;i(),o(T);},n.appendChild(d),n.appendChild(g),n.appendChild(b);}n.appendChild(m),n.appendChild(p),document.body.appendChild(n),setTimeout(()=>{p.style.transition="opacity 0.5s ease",p.style.opacity="0";},2e3);}function Ou(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 zu(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 Ms(e){return e.startsWith("image/")}function dr({attachments:e=[],onUpload:t,onDelete:a,maxSizeMB:r=10,allowedTypes:o,maxFiles:s=10}){let[n,m]=useState(false),[p,i]=useState(false),[u,d]=useState(null),g=useRef(null),b=useRef(e);b.current=e;let C=useCallback((x,R)=>{R.preventDefault(),R.stopPropagation();let A=b.current.filter($=>Ms($.type)),N=A.findIndex($=>$.id===x.id),H=$=>{let _=b.current.filter(ie=>Ms(ie.type)),V=_[$];V&&kd(V.url,V.name,_,$,H);};kd(x.url,x.name,A,N,H);},[]),T=useCallback(x=>{let R=[],A=[];return e.length+x.length>s?(A.push(`Maximum ${s} files allowed`),{valid:R,errors:A}):(x.forEach(N=>{if(N.size/1048576>r){A.push(`${N.name} is too large (max ${r}MB)`);return}if(o&&!o.some($=>N.type.match($))){A.push(`${N.name} has invalid file type`);return}R.push(N);}),{valid:R,errors:A})},[e.length,s,r,o]),c=useCallback(async x=>{let{valid:R,errors:A}=T(x);if(A.length>0){d(A.join(", ")),setTimeout(()=>d(null),5e3);return}if(R.length!==0){i(true),d(null);try{await t?.(R);}catch(N){d(N instanceof Error?N.message:"Upload failed"),setTimeout(()=>d(null),5e3);}finally{i(false);}}},[T,t]),h=useCallback(x=>{x.preventDefault(),x.stopPropagation(),m(true);},[]),v=useCallback(x=>{x.preventDefault(),x.stopPropagation(),m(false);},[]),l=useCallback(x=>{x.preventDefault(),x.stopPropagation();},[]),w=useCallback(x=>{x.preventDefault(),x.stopPropagation(),m(false);let R=Array.from(x.dataTransfer.files);c(R);},[c]),y=useCallback(x=>{let R=x.target.files?Array.from(x.target.files):[];c(R),g.current&&(g.current.value="");},[c]),S=useCallback(()=>{g.current?.click();},[]),k=useCallback(x=>{confirm("Are you sure you want to delete this attachment?")&&a?.(x);},[a]);return jsxs("div",{className:"attachment-uploader",children:[jsxs("div",{className:`attachment-dropzone ${n?"dragging":""} ${p?"uploading":""}`,onDragEnter:h,onDragLeave:v,onDragOver:l,onDrop:w,onClick:S,children:[jsx("input",{ref:g,type:"file",multiple:true,onChange:y,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(x=>jsxs("div",{className:"attachment-item",children:[jsx("div",{className:"attachment-preview",children:Ms(x.type)&&x.url?jsxs("button",{type:"button",className:"attachment-thumbnail-btn",onClick:R=>C(x,R),title:"Click to view full size",children:[jsx("img",{src:x.thumbnailUrl||x.url,alt:x.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:zu(x.type)})}),jsxs("div",{className:"attachment-info",children:[jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",className:"attachment-name",title:x.name,children:x.name}),jsxs("div",{className:"attachment-meta",children:[jsx("span",{className:"attachment-size",children:Ou(x.size)}),jsx("span",{className:"attachment-separator",children:"\u2022"}),jsx("span",{className:"attachment-date",children:new Date(x.uploadedAt).toLocaleDateString()})]})]}),jsx("button",{onClick:()=>k(x.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"})})})]},x.id))})]})}function As({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:m=[],aiInsights:p=[],attachments:i=[],onAddComment:u,onDeleteComment:d,onUploadAttachments:g,onDeleteAttachment:b,onSuggestAssignee:C,onGenerateSubtasks:T,onEstimateEffort:c,currentUserId:h="user-1"}){let[v,l]=useState("details"),[w,y]=useState(false),[S,k]=useState({}),[x,R]=useState(""),[A,N]=useState(false),[H,$]=useState({});if(!t||!e)return null;let _=useCallback(()=>{y(false),k({}),l("details"),R(""),$({}),a();},[a]),V=useCallback(()=>{r&&Object.keys(S).length>0&&(r(e.id,S),k({}),y(false));},[e.id,S,r]),ie=useCallback(()=>{o&&window.confirm("Are you sure you want to delete this card?")&&(o(e.id),_());},[e.id,o,_]),Be=useCallback(()=>{u&&x.trim()&&(u(e.id,x.trim()),R(""));},[e.id,x,u]),Oe=useCallback(async()=>{if(C){N(true);try{let D=await C(e);$(U=>({...U,assignees:D}));}catch(D){console.error("Failed to suggest assignee:",D);}finally{N(false);}}},[e,C]),ze=useCallback(async()=>{if(T){N(true);try{let D=await T(e);$(U=>({...U,subtasks:D}));}catch(D){console.error("Failed to generate subtasks:",D);}finally{N(false);}}},[e,T]),Pe=useCallback(async()=>{if(c){N(true);try{let D=await c(e);$(U=>({...U,effort:D}));}catch(D){console.error("Failed to estimate effort:",D);}finally{N(false);}}},[e,c]),L={...e,...S},B=s.filter(D=>L.assignedUserIds?.includes(D.id));return jsx(ht,{children:jsx("div",{className:"card-detail-overlay",onClick:_,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:L.priority==="URGENT"?"#EF4444":L.priority==="HIGH"?"#F59E0B":L.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),w?jsx("input",{type:"text",value:S.title??L.title,onChange:D=>k({...S,title:D.target.value}),className:"card-detail-title-input",placeholder:"Card title"}):jsx("h2",{className:"card-detail-title",children:L.title})]}),jsxs("div",{className:"card-detail-header-actions",children:[w?jsxs(Fragment,{children:[jsx("button",{onClick:V,className:"card-detail-btn card-detail-btn-primary",children:"Save"}),jsx("button",{onClick:()=>{y(false),k({});},className:"card-detail-btn",children:"Cancel"})]}):jsxs("button",{onClick:()=>y(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:ie,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:_,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 ${v==="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 ${v==="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 ${v==="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",m.length>0&&jsx("span",{className:"card-detail-tab-badge",children:m.length})]}),jsxs("button",{onClick:()=>l("attachments"),className:`card-detail-tab ${v==="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 ${v==="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:[v==="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??L.description??"",onChange:D=>k({...S,description:D.target.value}),className:"card-detail-textarea",placeholder:"Add a description...",rows:4}):jsx("p",{className:"card-detail-text",children:L.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??L.assignedUserIds??[],onChange:D=>{let U=Array.from(D.target.selectedOptions,q=>q.value);k({...S,assignedUserIds:U});},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:B.length>0?B.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??L.priority??"",onChange:D=>k({...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:L.priority==="URGENT"?"#EF4444":L.priority==="HIGH"?"#F59E0B":L.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:L.priority||"None"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Labels"}),jsx("div",{className:"card-detail-labels",children:L.labels&&L.labels.length>0?L.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]:L.startDate?new Date(L.startDate).toISOString().split("T")[0]:"",onChange:D=>k({...S,startDate:D.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:L.startDate?new Date(L.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]:L.endDate?new Date(L.endDate).toISOString().split("T")[0]:"",onChange:D=>k({...S,endDate:D.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:L.endDate?new Date(L.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??L.estimatedTime??"",onChange:D=>k({...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:L.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:L.dependencies&&L.dependencies.length>0?L.dependencies.map(D=>{let U=typeof D=="string"?D:D.taskId;return jsxs("span",{className:"card-detail-dependency",children:["Card #",U.slice(-4)]},U)}):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:L.createdAt?new Date(L.createdAt).toLocaleString():"Unknown"})]})]}),v==="comments"&&jsxs("div",{className:"card-detail-comments",children:[jsxs("div",{className:"card-detail-comment-form",children:[jsx("textarea",{value:x,onChange:D=>R(D.target.value),className:"card-detail-comment-textarea",placeholder:"Write a comment...",rows:3}),jsx("button",{onClick:Be,disabled:!x.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 U=s.find(q=>q.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:[U&&jsx("div",{className:"card-detail-user-avatar",style:{background:U.color},children:U.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-comment-author-name",children:U?.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"})]})})]}),v==="activity"&&jsx("div",{className:"card-detail-activity",children:m.length>0?jsx("div",{className:"card-detail-activity-list",children:m.map(D=>{let U=s.find(q=>q.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:U?.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"})]})}),v==="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:b,currentUserId:h,maxSizeMB:10,maxFiles:20})}),v==="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:Oe,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:ze,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:Pe,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("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,U)=>{let q=s.find(O=>O.id===D.userId);return jsxs("div",{className:"card-detail-ai-suggestion",children:[q&&jsx("div",{className:"card-detail-user-avatar",style:{background:q.color},children:q.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-ai-suggestion-name",children:q?.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),"%"]})]})]},U)})]}),H.subtasks&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Suggested Subtasks"}),H.subtasks.map((D,U)=>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"]})]},U))]}),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 Fo({triggerRef:e,isOpen:t,onClose:a,children:r,width:o=200,estimatedHeight:s=300,className:n=""}){let[m,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,b=window.innerWidth,C=4,T=d.left;T+o>b-10&&(T=b-o-10),T<10&&(T=10);let c=g-d.bottom,h=d.top,v;return c>=s+C?v=d.bottom+C:h>=s+C?v=d.top-s-C:c>=h?v=d.bottom+C:v=Math.max(10,d.top-s-C),{top:v,left:T}},[e,o,s]);return useEffect(()=>{t&&p(u());},[t,u]),useEffect(()=>{if(!t)return;let d=b=>{let C=b.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(ht,{children:jsx("div",{ref:i,className:`smart-popover ${n}`,style:{position:"fixed",top:`${m.top}px`,left:`${m.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 et={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 Ku=["LOW","MEDIUM","HIGH","URGENT"],Yu=["todo","in-progress","review","done"];function Is({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:m=[],onAddComment:p,onDeleteComment:i,currentUser:u,onAIGenerateDescription:d,onAICreateSubtasks:g,onAIFindSimilar:b,availableColumns:C=[],availableLabels:T=[],availableTags:c=[],onCreateTag:h,onUploadCoverImage:v,unsplashAccessKey:l,theme:w,onSubtasksChange:y,attachments:S=[],onUploadAttachments:k,onDeleteAttachment:x}){let R=oo(),A=w||R?.themeName||"dark",[N,H]=useState(e),[$,_]=useState(false),[V,ie]=useState(e?.subtasks||[]),[Be,Oe]=useState(false),[ze,Pe]=useState(""),[L,B]=useState(""),[D,U]=useState("all"),[q,O]=useState(false),[le,ve]=useState(false),[Ee,ue]=useState(false),[We,Me]=useState(false),[Re,ft]=useState(false),[qe,it]=useState(false),z=useRef(null),re=useRef(null),fe=useRef(null),ye=useRef(null),Ae=useRef(null),Ze=useRef(null),kt=useRef(null),De=useRef(null),It=useRef(null),Ft=useRef(null),lt=useRef(null),Xe=useRef(null);useEffect(()=>{e&&!N?(H({...e}),ie(e.subtasks||[])):e&&N&&e.id!==N.id&&(H({...e}),ie(e.subtasks||[]));},[e,N]),useEffect(()=>{let G=ce=>{let $e=ce.target;ye.current&&!ye.current.contains($e)&&O(false),Ae.current&&!Ae.current.contains($e)&&ve(false),Ze.current&&!Ze.current.contains($e)&&ue(false),kt.current&&!kt.current.contains($e)&&Me(false);};if(q||le||Ee||We)return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[q,le,Ee,We]),useEffect(()=>{if(!t)return;let G=ce=>{let $e=ce.target,Mt=$e.tagName==="INPUT"||$e.tagName==="TEXTAREA"||$e.isContentEditable;if(ce.key==="Escape"){ce.preventDefault(),q||le||Ee||We||Re||qe?(O(false),ve(false),ue(false),Me(false),ft(false),it(false)):Mt||a();return}if(Mt&&ce.key!=="Escape")return;let rt=ce.metaKey||ce.ctrlKey;switch(ce.key.toLowerCase()){case "s":ce.preventDefault(),O(true);break;case "a":ce.preventDefault(),ue(true);break;case "p":ce.preventDefault(),ve(true);break;case "l":ce.preventDefault(),Me(true);break;case "d":rt||(ce.preventDefault(),ft(true),setTimeout(()=>De.current?.focus(),0));break;case "e":rt||(ce.preventDefault(),it(true));break;case "i":ce.preventDefault(),_(true),setTimeout(()=>re.current?.focus(),0);break;case "t":ce.preventDefault(),Oe(true);break;case "c":ce.preventDefault(),fe.current?.focus();break}};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[t,a,q,le,Ee,We,Re,qe]);let Wt=useCallback(G=>{let ce=G.currentTarget.textContent?.trim()||"";if(N&&ce!==N.title){let $e={...N,title:ce};H($e),r?.(N.id,{title:ce});}},[N,r]),sa=useCallback(G=>{G.key==="Enter"&&(G.preventDefault(),G.currentTarget.blur()),G.key==="Escape"&&(G.preventDefault(),G.currentTarget.textContent=N?.title||"",G.currentTarget.blur());},[N]),oe=useCallback(()=>{N&&e&&N.description!==e.description&&r?.(N.id,{description:N.description}),_(false);},[N,e,r]),J=useCallback(G=>{if(N){let ce={...N,columnId:G};H(ce),r?.(N.id,{columnId:G}),O(false);}},[N,r]),Ve=useCallback(G=>{if(N){let ce={...N,priority:G};H(ce),r?.(N.id,{priority:G}),ve(false);}},[N,r]),ae=useCallback(G=>{if(N){let ce=N.assignedUserIds||[],$e=ce.includes(G)?ce.filter(rt=>rt!==G):[...ce,G],Mt={...N,assignedUserIds:$e};H(Mt),r?.(N.id,{assignedUserIds:$e});}},[N,r]),E=useCallback(G=>{if(N){let ce=N.labels||[],$e=ce.includes(G)?ce.filter(rt=>rt!==G):[...ce,G],Mt={...N,labels:$e};H(Mt),r?.(N.id,{labels:$e});}},[N,r]),X=useCallback(G=>{if(N){let ce={...N,tags:G};H(ce),r?.(N.id,{tags:G});}},[N,r]),de=useCallback(G=>{if(N){let ce=G.target.value,$e={...N,endDate:ce};H($e),r?.(N.id,{endDate:ce}),ft(false);}},[N,r]),Le=useCallback(G=>{if(N){let ce={...N,estimatedTime:parseFloat(G)||0};H(ce),r?.(N.id,{estimatedTime:parseFloat(G)||0});}},[N,r]),Ge=useCallback(()=>{if(ze.trim()&&N){let G={id:`subtask-${Date.now()}`,title:ze.trim(),completed:false,createdAt:new Date},ce=[...V,G];ie(ce),Pe(""),Oe(false),y?.(N.id,ce);}},[ze,V,N,y]),Je=useCallback(G=>{let ce=V.map($e=>$e.id===G?{...$e,completed:!$e.completed,updatedAt:new Date}:$e);ie(ce),N&&y?.(N.id,ce);},[V,N,y]),Ue=useCallback(G=>{let ce=V.filter($e=>$e.id!==G);ie(ce),N&&y?.(N.id,ce);},[V,N,y]),st=useCallback(()=>{L.trim()&&N&&p&&(p(N.id,L.trim()),B(""));},[L,N,p]),mt=useCallback(G=>{(G.metaKey||G.ctrlKey)&&G.key==="Enter"&&(G.preventDefault(),st());},[st]),j=G=>jsx(_u,{remarkPlugins:[Vu],rehypePlugins:[ju],components:{a:({node:ce,...$e})=>jsx("a",{...$e,target:"_blank",rel:"noopener noreferrer"})},children:G}),te=m.filter(G=>D==="comments"?G.type.includes("COMMENT"):D==="history"?!G.type.includes("COMMENT"):true);if(!t||!e)return null;let Se=N||e,Qe=s.filter(G=>Se.assignedUserIds?.includes(G.id)),_e=V.filter(G=>G.completed).length;return jsx(ht,{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:Wt,onKeyDown:sa,children:Se.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:ye,children:[jsxs("button",{ref:It,className:"modal-v2-field",onClick:()=>O(!q),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:Se.columnId||"No status"})]}),jsx(Fo,{triggerRef:It,isOpen:q,onClose:()=>O(false),width:250,estimatedHeight:200,children:(C.length>0?C:Yu.map(G=>({id:G,title:G}))).map(G=>jsx("button",{className:`modal-v2-popover-item ${Se.columnId===G.id?"active":""}`,onClick:()=>J(G.id),children:G.title},G.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:Ze,children:[jsxs("button",{ref:Ft,className:"modal-v2-field",onClick:()=>ue(!Ee),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:Qe.length>0?jsx("div",{className:"modal-v2-avatars",children:Qe.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(Fo,{triggerRef:Ft,isOpen:Ee,onClose:()=>ue(false),width:280,estimatedHeight:300,children:s.map(G=>jsxs("button",{className:`modal-v2-popover-item ${Se.assignedUserIds?.includes(G.id)?"active":""}`,onClick:()=>ae(G.id),children:[jsx("div",{className:"modal-v2-avatar-small",style:{background:G.color},children:G.initials}),G.name,Se.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:Ae,children:[jsxs("button",{ref:lt,className:"modal-v2-field",onClick:()=>ve(!le),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:Se.priority||"None"})]}),jsxs(Fo,{triggerRef:lt,isOpen:le,onClose:()=>ve(false),width:180,estimatedHeight:220,children:[Ku.map(G=>jsx("button",{className:`modal-v2-popover-item priority-${G.toLowerCase()} ${Se.priority===G?"active":""}`,onClick:()=>Ve(G),children:G},G)),jsx("button",{className:"modal-v2-popover-item",onClick:()=>Ve(""),children:"None"})]})]}),c.length>0||h?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:Se.tags||[],availableTags:c,onChange:X,onCreateTag:h,theme:et[A]||et.dark})})]})}):jsxs("div",{className:"modal-v2-field-wrapper",ref:kt,children:[jsxs("button",{ref:Xe,className:"modal-v2-field",onClick:()=>Me(!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:Se.labels&&Se.labels.length>0?jsx("span",{children:Se.labels.join(", ")}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(Fo,{triggerRef:Xe,isOpen:We,onClose:()=>Me(false),width:220,estimatedHeight:200,children:(T.length>0?T:["Bug","Feature","Enhancement","Documentation"]).map(G=>jsxs("button",{className:`modal-v2-popover-item ${Se.labels?.includes(G)?"active":""}`,onClick:()=>E(G),children:[G,Se.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:()=>{ft(!Re),setTimeout(()=>De.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:Se.endDate?new Date(Se.endDate).toLocaleDateString():"Not set"}),jsx("input",{ref:De,type:"date",value:typeof Se.endDate=="string"?Se.endDate.split("T")[0]:Se.endDate?(()=>{let G=new Date(Se.endDate),ce=G.getUTCFullYear(),$e=String(G.getUTCMonth()+1).padStart(2,"0"),Mt=String(G.getUTCDate()).padStart(2,"0");return `${ce}-${$e}-${Mt}`})():"",onChange:de,style:{position:"absolute",opacity:0,pointerEvents:"none"}})]}),jsxs("div",{className:"modal-v2-field-wrapper",children:[jsxs("button",{className:"modal-v2-field",onClick:()=>it(!qe),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:Se.estimatedTime?`${Se.estimatedTime}h`:"Not set"})]}),qe&&jsx("div",{className:"modal-v2-popover",children:jsx("input",{type:"number",min:"0",step:"0.5",placeholder:"Hours",value:Se.estimatedTime||"",onChange:G=>Le(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"})]}),$?jsx("textarea",{className:"modal-v2-textarea",value:Se.description||"",onChange:G=>{if(N){let ce={...N,description:G.target.value};H(ce);}},onBlur:oe,placeholder:"Add a detailed description...",autoFocus:true}):jsx("div",{className:"modal-v2-content",onClick:()=>_(true),children:Se.description?jsx("div",{className:"modal-v2-markdown",children:j(Se.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"}),V.length>0&&jsxs("span",{className:"modal-v2-count",children:[_e,"/",V.length]}),jsxs("button",{className:"modal-v2-add-button",onClick:()=>Oe(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:[V.map(G=>jsxs("div",{className:`modal-v2-subtask ${G.completed?"completed":""}`,children:[jsx("button",{className:"modal-v2-subtask-checkbox",onClick:()=>Je(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:()=>Ue(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)),Be&&jsx("div",{className:"modal-v2-subtask-input-row",children:jsx("input",{type:"text",placeholder:"Subtask title...",value:ze,onChange:G=>Pe(G.target.value),onKeyDown:G=>{G.key==="Enter"&&Ge(),G.key==="Escape"&&(Oe(false),Pe(""));},onBlur:Ge,autoFocus:true,className:"modal-v2-subtask-input"})})]})]}),(k||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(dr,{cardId:Se.id,attachments:S,onUpload:k?G=>k(Se.id,G):void 0,onDelete:x,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:()=>U("all"),children:"All"}),jsx("button",{className:`modal-v2-filter ${D==="comments"?"active":""}`,onClick:()=>U("comments"),children:"Comments"}),jsx("button",{className:`modal-v2-filter ${D==="history"?"active":""}`,onClick:()=>U("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:fe,className:"modal-v2-comment-textarea",placeholder:"Write a comment...",value:L,onChange:G=>B(G.target.value),onKeyDown:mt,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:st,disabled:!L.trim(),children:"Send"})]})]})]}),jsxs("div",{className:"modal-v2-timeline",children:[te.map(G=>{let ce=s.find(Mt=>Mt.id===G.userId);if(G.type.includes("COMMENT")){let Mt=n.find(rt=>rt.id===G.metadata?.commentId);return Mt?jsxs("div",{className:"modal-v2-activity-item comment-item",children:[ce&&jsx("div",{className:"modal-v2-avatar",style:{background:ce.color},children:ce.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:ce?.name||"Unknown"}),jsx("span",{className:"modal-v2-activity-time",children:new Date(G.timestamp).toLocaleString()})]}),jsx("div",{className:"modal-v2-comment-body",children:Mt.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:ce?.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 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.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 Rs({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((m,p)=>m+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(rg,{})}),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,m)=>n+m.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,m)=>n+m.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,m)=>n+(m.planned||0),0)})]})]})]})}function mg({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 $s({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,m=e[e.length-1]?.ideal||0,p=s>0?(s-n)/s*100:0,i=n<=m;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(mg,{})}),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 kg={URGENT:"#EF4444",HIGH:"#F59E0B",MEDIUM:"#3B82F6",LOW:"#10B981"},Md=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899"];function wg({cx:e,cy:t,midAngle:a,innerRadius:r,outerRadius:o,percent:s}){let n=r+(o-r)*.5,m=e+n*Math.cos(-a*(Math.PI/180)),p=t+n*Math.sin(-a*(Math.PI/180));return s<.05?null:jsx("text",{x:m,y:p,fill:"white",textAnchor:m>e?"start":"end",dominantBaseline:"central",style:{fontSize:"12px",fontWeight:600},children:`${(s*100).toFixed(0)}%`})}function Ad({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 Os({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||kg[p.name]||Md[e.indexOf(p)%Md.length]})),m=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?wg:false,outerRadius:r*.35,fill:"#8884d8",dataKey:"value",children:n.map((p,i)=>jsx(Cell,{fill:m[i]},`cell-${i}`))}),jsx(Tooltip,{content:jsx(Ad,{})}),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(Ad,{})}),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:m[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,m]=useState(false),[p,i]=useState(false),[u,d]=useState(false),[g,b]=useState(false);if(e.length===0)return null;let C=e.map(w=>w.id),T=w=>{r.onBulkUpdate?.(C,{priority:w}),m(false);},c=w=>{r.onBulkMove?.(C,w),i(false),a();},h=w=>{r.onBulkUpdate?.(C,{assignedUserIds:w}),d(false);},v=w=>{let y=new Set;e.forEach(k=>{k.labels?.forEach(x=>y.add(x));});let S=Array.from(new Set([...y,...w]));r.onBulkUpdate?.(C,{labels:S}),b(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:()=>m(!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:()=>c(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:()=>h([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:()=>b(!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:()=>v([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 Sg(e,t,a){if(t==="none")return [];let r=new Map;return e.forEach(o=>{let s,n,m,p,i;switch(t){case "assignee":let u=o.assignedUserIds||(o.assigneeId?[o.assigneeId]:[]);u.length>0?u.forEach(b=>{let C=a?.find(T=>T.id===b);n=`assignee-${b}`,m=C?.name||`User ${b}`,p=C?.color,i=C?.avatar,r.has(n)||r.set(n,{id:n,title:m,groupValue:b,cardIds:[],color:p,icon:i}),r.get(n).cardIds.push(o.id);}):(n="assignee-unassigned",m="Unassigned",p="#6b7280",i="\u{1F464}",r.has(n)||r.set(n,{id:n,title:m,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];m=g.title,p=g.color,r.has(n)||r.set(n,{id:n,title:m,groupValue:s,cardIds:[],color:p}),r.get(n).cardIds.push(o.id);break;case "label":o.labels&&o.labels.length>0?o.labels.forEach(b=>{n=`label-${b}`,m=b,p="#6b7280",r.has(n)||r.set(n,{id:n,title:m,groupValue:b,cardIds:[],color:p}),r.get(n).cardIds.push(o.id);}):(n="label-none",m="No Labels",p="#6b7280",r.has(n)||r.set(n,{id:n,title:m,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 zs({board:e,swimlaneConfig:t,availableUsers:a,callbacks:r,className:o}){let[s,n]=useState(new Set),m=useMemo(()=>Sg(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"||m.length===0?jsx(Sr,{board:e,callbacks:r,availableUsers:a,className:o}):jsxs("div",{className:f("asakaa-swimlane-view",o),children:[m.map(i=>{let u=s.has(i.id),d=e.cards.filter(b=>i.cardIds.includes(b.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(Sr,{board:g,callbacks:r,availableUsers:a})})]},i.id)}),m.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 Us=[{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 Hs({value:e,onChange:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null),m=Us.find(i=>i.value===e)||Us[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:m.icon}),jsx("span",{children:m.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:Us.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 Lo=[{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 Mg(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,m=o.alt?e.altKey:!e.altKey,p=o.meta?e.metaKey:true;return s&&n&&m&&p}function Rd(e={}){let{shortcuts:t=Lo,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];},[]),m=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(Mg(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:m,isEnabled:a}}function Fg(e){return {ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192",Enter:"\u21B5",Escape:"Esc",Delete:"Del"," ":"Space"}[e]||e.toUpperCase()}function Lg(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 Ig(e){let t=Array.isArray(e.keys)?e.keys[0]:e.keys,a=Lg(e),r=t?Fg(t):"";return a?`${a} + ${r}`:r}function Bg(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 Ws({shortcuts:e=Lo,isOpen:t,onClose:a,className:r}){let[o,s]=useState(false);if(useEffect(()=>{s(true);},[]),useEffect(()=>{function m(p){p.key==="Escape"&&t&&a();}if(t)return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[t,a]),!o||!t)return null;let n=Bg(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(([m,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"}),m]}),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:Ig(i)})]},i.action))})]},m))})}),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 Gs=[{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 _s({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 p=i=>{t(i),o(false);},m=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(m).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:()=>p(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 js({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[n,p]=useState("export"),[m,i]=useState("json"),[u,d]=useState(null),g=useRef(null);if(!t)return null;let b=async()=>{let T=o?.current||void 0,c=await Sl(e,m,T);El(c,m);},C=async T=>{let c=T.target.files?.[0];if(c){try{let h=await Al(c),v=c.name.endsWith(".json")?"json":"csv",l=Ml(h,v);d(l),l.success&&r&&r(l,h);}catch(h){d({success:false,errors:[`Failed to read file: ${h instanceof Error?h.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:()=>p("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:()=>p("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",m===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:b,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,c)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",T]},c))})]})]})]})]})]})}var Ug=["URGENT","HIGH","MEDIUM","LOW"],Hg=[{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"}],Wg=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function Ks({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:n,onFilterHighPriority:p,availableUsers:m=[],availableLabels:i=[],availableColumns:u=[],showQuickFilters:d=true,compact:g=false,groupBy:b="none",onGroupByChange:C}){let[T,c]=useState(true),h=useCallback(S=>{a({search:S.target.value});},[a]),v=useCallback(S=>{a({dateFilter:S.target.value});},[a]),l=useCallback(S=>{r({by:S.target.value});},[r]),k=useCallback(()=>{r({order:t.order==="asc"?"desc":"asc"});},[t.order,r]),y=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:()=>c(!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"}),y&&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"}),p&&jsx("button",{onClick:p,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:h,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:v,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 w=S.target.value;a({priorities:w==="all"?[]:[w]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),Ug.map(S=>jsx("option",{value:S,children:S},S))]})}),m.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:S=>{let w=S.target.value;a({assignees:w==="all"?[]:[w]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),m.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 w=S.target.value;a({labels:w==="all"?[]:[w]});},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:Hg.map(S=>jsx("option",{value:S.value,children:S.label},S.value))}),t.by!=="none"&&jsx("button",{onClick:k,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:b,onChange:S=>C(S.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Wg.map(S=>jsx("option",{value:S.value,children:S.label},S.value))})}),y&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function Ys({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:n,onExportGanttPNG:p,onExportGanttCSV:m}){let[i,u]=useState(false),d=useRef(null);useEffect(()=>{let b=C=>{d.current&&!d.current.contains(C.target)&&u(false);};return i&&document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b);}},[i]);let g=b=>{b(),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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",b.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",b.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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:b=>{b.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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:b=>{b.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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:b=>{b.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 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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:b=>{b.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(()=>m?.()),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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:b=>{b.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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:b=>{b.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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:b=>{b.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 qs={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"}},Xs={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"}},jr={dark:qs,light:Xs,neutral:Js},bn="dark";var yn=createContext(void 0),Qg="asakaa-theme";function zd({children:e,defaultTheme:t=bn,storageKey:a=Qg}){let[r,o]=useState(()=>{if(typeof window<"u"){let p=localStorage.getItem(a);if(p&&(p==="dark"||p==="light"||p==="neutral"))return p}return t}),s=useCallback(p=>{o(p),typeof window<"u"&&localStorage.setItem(a,p);},[a]);useEffect(()=>{if(typeof window>"u")return;let p=document.documentElement,m=jr[r];Object.entries(m.colors).forEach(([u,d])=>{d&&p.style.setProperty(`--theme-${Zg(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=m.colors[u];g&&p.style.setProperty(d,g);}),p.setAttribute("data-theme",r),p.classList.remove("theme-dark","theme-light","theme-neutral"),p.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 Zg(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Qs({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 Ud(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return Xe[e]||Xe.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,n)=>a.getPropertyValue(s).trim()||n;return {bgPrimary:r("--theme-bg-primary",Xe[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",Xe[e].bgSecondary),bgGrid:r("--theme-bg-card",Xe[e].bgGrid),bgWeekend:r("--theme-bg-hover",Xe[e].bgWeekend),border:r("--theme-border-primary",Xe[e].border),borderLight:r("--theme-border-subtle",Xe[e].borderLight),textPrimary:r("--theme-text-primary",Xe[e].textPrimary),textSecondary:r("--theme-text-secondary",Xe[e].textSecondary),textTertiary:r("--theme-text-tertiary",Xe[e].textTertiary),accent:r("--theme-accent-primary",Xe[e].accent),accentHover:r("--theme-accent-hover",Xe[e].accentHover),accentLight:r("--theme-accent-primary",Xe[e].accentLight),taskBarPrimary:r("--theme-accent-primary",Xe[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",Xe[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",Xe[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",Xe[e].dependency),dependencyHover:r("--theme-border-secondary",Xe[e].dependencyHover),criticalPath:r("--theme-error",Xe[e].criticalPath),criticalPathLight:r("--theme-error",Xe[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",Xe[e].today):e==="neutral"?r("--theme-text-primary",Xe[e].today):r("--theme-error",Xe[e].today),todayLight:e==="light"?r("--theme-accent-primary",Xe[e].todayLight):e==="neutral"?r("--theme-text-primary",Xe[e].todayLight):r("--theme-error",Xe[e].todayLight),milestone:r("--theme-warning",Xe[e].milestone),milestoneLight:r("--theme-warning",Xe[e].milestoneLight),statusTodo:r("--theme-text-tertiary",Xe[e].statusTodo),statusInProgress:r("--theme-accent-primary",Xe[e].statusInProgress),statusCompleted:r("--theme-success",Xe[e].statusCompleted),hoverBg:r("--theme-bg-hover",Xe[e].hoverBg),focusRing:r("--theme-accent-primary",Xe[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",filterAll:"All",filterIncomplete:"Incomplete",filterInProgress:"In Progress",filterCompleted:"Completed",filter:"Filter",filterBy:"Filter by status",filterAllDesc:"Show all tasks",filterIncompleteDesc:"Hide completed tasks",filterInProgressDesc:"Tasks currently being worked on",filterCompletedDesc:"Only show finished tasks",clearFilter:"Clear filter"},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"}},Hd={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",filterAll:"Todas",filterIncomplete:"Sin completar",filterInProgress:"En progreso",filterCompleted:"Completadas",filter:"Filtrar",filterBy:"Filtrar por estado",filterAllDesc:"Mostrar todas las tareas",filterIncompleteDesc:"Ocultar tareas completadas",filterInProgressDesc:"Tareas en las que se est\xE1 trabajando",filterCompletedDesc:"Solo mostrar tareas terminadas",clearFilter:"Limpiar filtro"},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"}},Zs={en:vn,es:Hd};function Wd(e){return Zs[e]||Zs.en}function ei(e,t){let a=Wd(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 bo(){return useContext(ho)}function hf({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:n}){let[p,m]=useState(false),[i,u]=useState(null),d=useRef(null),g=bo();if(useEffect(()=>{let c=h=>{d.current&&!d.current.contains(h.target)&&m(false);};return p&&document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[p]),!(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(c=>c.handler),T=async(c,h)=>{if(h){u(c);try{await h();}catch(v){console.error(`Export ${c} failed:`,v);}finally{u(null),m(false);}}};return jsxs("div",{ref:d,className:"relative",children:[jsxs(motion.button,{onClick:()=>m(!p),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:p?e.accent:e.bgSecondary,border:`1px solid ${p?e.accent:e.borderLight}`,color:p?"#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:p?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:p&&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((c,h)=>jsxs(motion.button,{onClick:()=>T(c.id,c.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:h<C.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:h*.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===c.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):c.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:c.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:c.description})]})]},c.id))})})})]})}function bf({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 yf({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 vf({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),n=bo();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 p=[{value:"compact",label:n.toolbar.compact||"Compact"},{value:"comfortable",label:n.toolbar.normal||"Normal"},{value:"spacious",label:n.toolbar.spacious||"Spacious"}],m=p.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"}: ${m}`,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:p.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<p.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 xf({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),n=bo();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 p=[{value:"all",label:n.toolbar.filterAll||"All tasks",description:n.toolbar.filterAllDesc||"Show all tasks"},{value:"incomplete",label:n.toolbar.filterIncomplete||"Incomplete only",description:n.toolbar.filterIncompleteDesc||"Hide completed tasks"},{value:"in_progress",label:n.toolbar.filterInProgress||"In progress",description:n.toolbar.filterInProgressDesc||"Tasks currently being worked on"},{value:"completed",label:n.toolbar.filterCompleted||"Completed",description:n.toolbar.filterCompletedDesc||"Only show finished tasks"}],m=t!=="all";return jsxs("div",{ref:s,className:"relative",children:[jsxs(motion.button,{onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:m||r?e.accentLight:e.bgSecondary,border:`1px solid ${m||r?e.accent:e.borderLight}`,color:m||r?e.accent:e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{backgroundColor:e.accentLight,borderColor:e.accent,color:e.accent,scale:1.02},whileTap:{scale:.98},children:[jsx(Filter,{className:"w-3.5 h-3.5"}),jsx("span",{children:n.toolbar.filter||"Filter"}),m&&jsx(motion.span,{initial:{scale:0},animate:{scale:1},className:"flex items-center justify-center w-4 h-4 rounded-full text-[10px] font-semibold",style:{backgroundColor:e.accent,color:"#FFFFFF"},children:"1"}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:r?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:r&&jsxs(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-56 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:"px-3 py-2 border-b",style:{borderColor:e.borderLight},children:jsx("span",{className:"text-xs font-medium",style:{color:e.textTertiary},children:n.toolbar.filterBy||"Filter by status"})}),jsx("div",{className:"py-1",children:p.map((i,u)=>{let d=t===i.value;return jsxs(motion.button,{onClick:()=>{a(i.value),o(false);},className:"w-full flex items-start gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:d?e.accentLight:"transparent"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:u*.03},children:[jsx("div",{className:"flex items-center justify-center w-4 h-4 rounded border mt-0.5 flex-shrink-0",style:{borderColor:d?e.accent:e.border,backgroundColor:d?e.accent:"transparent"},children:d&&jsx(Check,{className:"w-3 h-3",style:{color:"#FFFFFF"}})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium",style:{color:d?e.accent:e.textPrimary},children:i.label}),jsx("div",{className:"text-[10px] mt-0.5",style:{color:e.textTertiary},children:i.description})]})]},i.value)})}),m&&jsx("div",{className:"px-3 py-2 border-t",style:{borderColor:e.borderLight},children:jsx(motion.button,{onClick:()=>{a("all"),o(false);},className:"w-full text-xs py-1.5 rounded-md",style:{color:e.textTertiary},whileHover:{backgroundColor:e.hoverBg,color:e.textSecondary},children:n.toolbar.clearFilter||"Clear filter"})})]})})]})}function kn({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:n,rowDensity:p,onRowDensityChange:m,showThemeSelector:i=false,showCreateTaskButton:u=false,createTaskLabel:d,onCreateTask:g,taskFilter:b="all",onTaskFilterChange:C,onExportPNG:T,onExportPDF:c,onExportExcel:h,onExportCSV:v,onExportJSON:l,onExportMSProject:k}){let y=bo(),S=T||c||h||v||l||k,w=[{value:"day",label:y.toolbar.day},{value:"week",label:y.toolbar.week},{value:"month",label:y.toolbar.month}],x=[{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(yf,{options:w,value:t,onChange:R=>a(R),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(vf,{theme:e,value:p,onChange:m}),C&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsx(xf,{theme:e,value:b,onChange:C})]})]}),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||y.toolbar.createTask})]}),(S||i)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),S&&jsxs(Fragment,{children:[jsx(hf,{theme:e,onExportPNG:T,onExportPDF:c,onExportExcel:h,onExportCSV:v,onExportJSON:l,onExportMSProject:k}),i&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),i&&jsx(bf,{options:x,value:s,onChange:R=>n(R),theme:e})]})]})}function wn({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,n]=useState({x:0,y:0}),p=useRef(null),m=useRef(null);useEffect(()=>{if(!r)return;let u=d=>{p.current&&!p.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:m,onClick:()=>{if(!r&&m.current){let u=m.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(ht,{children:jsx(motion.div,{ref:p,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 yo({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let n=useRef(null),[p,m]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let u=200,d=r.length*36+8,g=8,b=window.innerWidth,C=window.innerHeight,T=t,c=a;t+u+g>b&&(T=t-u,T<g&&(T=g)),a+d+g>C&&(c=C-d-g,c<g&&(c=g)),m({x:T,y:c});},[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:`${p.x}px`,top:`${p.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 Ut={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 Zd({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:n,onTaskIndent:p,onTaskOutdent:m,onTaskRename:i,onTaskToggleExpand:u,onOpenTaskModal:d,enableKeyboard:g=true}){let b=useRef(false),C=useCallback(l=>{b.current=l;},[]),T=useCallback(l=>{let k=[],y=S=>{for(let w of S)k.push(w),w.subtasks&&w.subtasks.length>0&&w.isExpanded&&y(w.subtasks);};return y(l),k},[]),c=useCallback(()=>{let l=T(e);for(let k of l)if(t.has(k.id))return k;return null},[e,t,T]),h=useCallback((l,k)=>{let y=T(e);if(y.length===0)return;let S=c();if(!S){a(y[0].id,false);return}let w=y.findIndex(A=>A.id===S.id);if(w===-1)return;let x=l==="up"?w-1:w+1;if(x<0||x>=y.length)return;let R=y[x];a(R.id,k);},[e,c,T,a]),v=useCallback(l=>{if(!g)return;let k=l.target;if(k.tagName==="INPUT"||k.tagName==="TEXTAREA"||k.isContentEditable||b.current){l.key==="Escape"&&(k.blur(),b.current=false);return}let w=navigator.platform.toUpperCase().indexOf("MAC")>=0?l.metaKey:l.ctrlKey,x=Array.from(t),R=c();if(l.key==="ArrowUp"){l.preventDefault(),h("up",l.shiftKey);return}if(l.key==="ArrowDown"){l.preventDefault(),h("down",l.shiftKey);return}if(R&&(l.key==="ArrowRight"||l.key==="ArrowLeft")){R.subtasks&&R.subtasks.length>0&&(l.preventDefault(),(l.key==="ArrowRight"&&!R.isExpanded||l.key==="ArrowLeft"&&R.isExpanded)&&u(R.id));return}if(l.altKey&&(l.key==="ArrowUp"||l.key==="ArrowDown")){x.length>0&&(l.preventDefault(),n(x,l.key==="ArrowUp"?"up":"down"));return}if(l.key==="Tab"&&!l.shiftKey){x.length>0&&(l.preventDefault(),p(x));return}if(l.key==="Tab"&&l.shiftKey){x.length>0&&(l.preventDefault(),m(x));return}if(l.key==="Enter"&&!l.shiftKey&&!w){R&&(l.preventDefault(),r(R.id,"below"));return}if(l.key==="Enter"&&l.shiftKey&&!w){R&&(l.preventDefault(),r(R.id,"above"));return}if(l.key==="Enter"&&w){R&&(l.preventDefault(),d(R.id));return}if(l.key==="F2"){R&&(l.preventDefault(),i(R.id));return}if(l.key==="Delete"||l.key==="Backspace"&&w){x.length>0&&(l.preventDefault(),o(x));return}if(l.key==="d"&&w&&!l.shiftKey){x.length>0&&(l.preventDefault(),s(x));return}},[g,t,c,h,r,o,s,n,p,m,i,u,d]);return useEffect(()=>{if(g)return window.addEventListener("keydown",v),()=>{window.removeEventListener("keydown",v);}},[g,v]),{setIsEditing:C}}function tc(){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 b=new Set(g);return b.has(d)?b.delete(d):b.add(d),b}),r(d);},[]),n=useCallback((d,g)=>{if(!a){o(d);return}let b=g.indexOf(a),C=g.indexOf(d);if(b===-1||C===-1){o(d);return}let T=Math.min(b,C),c=Math.max(b,C),h=g.slice(T,c+1);t(new Set(h)),r(d);},[a,o]),p=useCallback((d,g,b,C)=>{C?n(d,g):b?s(d):o(d);},[o,s,n]),m=useCallback((d,g)=>{g?t(b=>{let C=new Set(b);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:p,handleKeyboardSelection:m,clearSelection:i,isTaskSelected:u}}function vo(e){let t=[],a=(r,o,s=0)=>{for(let n=0;n<r.length;n++){let p={...r[n],parentId:o,level:s,position:n};t.push(p),p.subtasks&&p.subtasks.length>0&&p.isExpanded&&a(p.subtasks,p.id,s+1);}};return a(e),t}function ac(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=ac(a.subtasks,t);if(r)return r}}return null}function si(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=si(a.subtasks,t);if(r)return r}return null}function ii(e,t){if(t.length===0)return e;let a=vo(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 b=[];return {tasks:d.filter(T=>{if(g.has(T.id))return b.push(T),false;if(T.subtasks){let c=n(T.subtasks,g);T.subtasks=c.tasks,b.push(...c.removed);}return true}),removed:b}},p=(d,g,b)=>d.map(C=>C.id===g?{...C,subtasks:[...C.subtasks||[],...b],isExpanded:true}:C.subtasks?{...C,subtasks:p(C.subtasks,g,b)}:C),m=new Set(t),{tasks:i,removed:u}=n(e,m);return p(i,s.id,u)}function li(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=si(a,r);if(!o)continue;let s=si(a,o.id),n=(i,u,d)=>{for(let g=0;g<i.length;g++){let b=i[g];if(b.id===u&&b.subtasks){let C=b.subtasks.findIndex(T=>T.id===d);if(C!==-1){let[T]=b.subtasks.splice(C,1);return T}}if(b.subtasks){let C=n(b.subtasks,u,d);if(C)return C}}return null},p=(i,u,d)=>{let g=i.findIndex(b=>b.id===u);if(g!==-1)return i.splice(g+1,0,d),i;for(let b of i)b.subtasks&&p(b.subtasks,u,d);return i},m=n(a,o.id,r);m&&(s&&s.subtasks?p(s.subtasks,o.id,m):p(a,o.id,m));}return a}function di(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(n,p,m)=>{let i=n.findIndex(d=>d.id===p);if(i===-1){for(let d of n)if(d.subtasks&&s(d.subtasks,p,m))return true;return false}let u=m==="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 ci(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 mi(e,t){let a=[...e];for(let r of t){let o=n=>{let p=n.findIndex(u=>u.id===r);if(p===-1){for(let u of n)if(u.subtasks&&o(u.subtasks))return true;return false}let m=n[p],i={...m,id:`${m.id}-copy-${Date.now()}`,name:`${m.name} (Copy)`,subtasks:m.subtasks?s(m.subtasks):void 0};return n.splice(p+1,0,i),true},s=n=>n.map(p=>({...p,id:`${p.id}-copy-${Date.now()}`,subtasks:p.subtasks?s(p.subtasks):void 0}));o(a);}return a}function rc(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"},p=m=>{let i=m.findIndex(d=>d.id===t);if(i===-1){for(let d of m)if(d.subtasks&&p(d.subtasks))return true;return false}let u=a==="above"?i:i+1;return m.splice(u,0,n),true};return p(r),{tasks:r,newTask:n}}function pi(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:pi(r.subtasks,t,a)}:r)}function ui(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:ui(a.subtasks,t)}:a)}function gi(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,p=r?.endDate||s,m={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(n),endDate:new Date(p),color:r?.color||"#3B82F6"},i=u=>u.map(d=>{if(d.id===t){let g=d.subtasks||[];return {...d,subtasks:[...g,m],isExpanded:true}}return d.subtasks?{...d,subtasks:i(d.subtasks)}:d});return {tasks:i(e),newTask:m}}function oc(e,t,a,r){if(t===a)return e;let o=ac(e,t);if(!o)return e;if(a){let p=(m,i)=>{if(!m.subtasks)return false;for(let u of m.subtasks)if(u.id===i||p(u,i))return true;return false};if(p(o,a))return e}let s=p=>p.filter(m=>m.id!==t).map(m=>m.subtasks&&m.subtasks.length>0?{...m,subtasks:s(m.subtasks)}:m),n=s(e);if(a===null){let p=r!==void 0?r:n.length;n.splice(p,0,{...o,parentId:void 0});}else {let p=m=>m.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:p(i.subtasks)}:i});n=p(n);}return n}function Nn({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:n,onTaskContextMenu:p,onTaskToggle:m,scrollTop:i,columns:u,onToggleColumn:d,onColumnResize:g,onTaskUpdate:b,onTaskIndent:C,onTaskOutdent:T,onTaskMove:c,onMultiTaskDelete:h,onTaskDuplicate:v,onTaskCreate:l,onTaskRename:k,onCreateSubtask:y,onOpenTaskModal:S,onDeleteRequest:w,onTaskReparent:x}){let R=useContext(ho),[A,N]=useState(null),[U,$]=useState(null),[_,q]=useState(""),pe=useRef(null),[Te,Ze]=useState(null),[Oe,Be]=useState(0),[L,B]=useState(0),[D,W]=useState({isOpen:false,x:0,y:0,type:"header"}),[Y,O]=useState(null),[ie,ve]=useState(null),[Ee,fe]=useState(null),We=useRef(0),Re=5,Le=useRef(false),[ze,yt]=useState(null),[nt,z]=useState(false),[ne,le]=useState(null),[we,$e]=useState(false),et=useRef(null);useEffect(()=>{function V(re){et.current&&!et.current.contains(re.target)&&$e(false);}if(we)return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[we]),useEffect(()=>{U&&pe.current&&(pe.current.focus(),pe.current.select());},[U]),useEffect(()=>{if(!Te)return;let V=Se=>{let qe=Se.clientX-Oe,_e=L+qe;g?.(Te,_e);},re=()=>{Ze(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="";}},[Te,Oe,L,g]);let{selectedTaskIds:vt,handleTaskClick:Pe,isTaskSelected:Vt}=tc(),{setIsEditing:ft}=Zd({tasks:e,selectedTaskIds:vt,onTaskSelect:(V,re)=>{let qe=vo(e).map(_e=>_e.id);Pe(V,qe,re||false,false);},onTaskCreate:l||(()=>{}),onTaskDelete:h||(()=>{}),onTaskDuplicate:v||(()=>{}),onTaskMove:c||(()=>{}),onTaskIndent:C||(()=>{}),onTaskOutdent:T||(()=>{}),onTaskRename:V=>{let re=vo(e).find(Se=>Se.id===V);re&&te(re);},onTaskToggleExpand:m||(()=>{}),onOpenTaskModal:V=>{let re=vo(e).find(Se=>Se.id===V);re&&S&&S(re);},enableKeyboard:true}),st=(V,re=0)=>{let Se=[];for(let qe of V)Se.push({task:qe,level:re}),qe.subtasks&&qe.subtasks.length>0&&qe.isExpanded&&Se.push(...st(qe.subtasks,re+1));return Se},mt=st(e),Lt=48,va=Math.max(mt.length*a,600-Lt),ee=V=>!V.startDate||!V.endDate?"-":`${Math.ceil((V.endDate.getTime()-V.startDate.getTime())/(1e3*60*60*24))}d`,te=V=>{$(V.id),q(V.name),ft(true);},it=V=>{_.trim()&&_!==e.find(re=>re.id===V)?.name&&k?.(V,_.trim()),$(null),q(""),ft(false);},ae=()=>{$(null),q(""),ft(false);},E=(V,re)=>{re.stopPropagation(),y?.(V.id);},X=(V,re)=>{re.preventDefault(),We.current=re.clientY,O(V),Le.current=false,z(false),yt({x:re.clientX,y:re.clientY});},be=V=>{if(!Y||(Math.abs(V.clientY-We.current)>Re&&!Le.current&&(Le.current=true,z(true)),yt({x:V.clientX,y:V.clientY}),!Le.current))return;let Se=document.querySelectorAll("[data-task-row]"),qe=null,_e=null;Se.forEach(G=>{let de=G.getBoundingClientRect(),Ie=G.getAttribute("data-task-row");if(Ie&&Ie!==Y&&V.clientY>=de.top&&V.clientY<=de.bottom){qe=Ie;let At=V.clientY-de.top,tt=de.height;At<tt*.25?_e="above":At>tt*.75?_e="below":_e="child";}}),ve(qe),fe(_e);},Ae=()=>{if(Le.current&&Y&&ie&&Ee){if(Ee==="child")x?.(Y,ie);else if(Ee==="above"||Ee==="below"){let V=(qe,_e,G=null)=>{for(let de of qe){if(de.id===_e)return G;if(de.subtasks){let Ie=V(de.subtasks,_e,de.id);if(Ie!==void 0)return Ie}}},re=V(e,ie,null),Se=(qe,_e)=>{let G=qe.findIndex(de=>de.id===_e);return Ee==="below"?G+1:G};if(re===null){let qe=Se(e,ie);x?.(Y,null,qe);}else {let qe=mt.find(_e=>_e.task.id===re)?.task;if(qe?.subtasks){let _e=Se(qe.subtasks,ie);x?.(Y,re,_e);}}}}O(null),ve(null),fe(null),yt(null),Le.current=false,z(false);};useEffect(()=>{if(Y)return document.addEventListener("mousemove",be),document.addEventListener("mouseup",Ae),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",be),document.removeEventListener("mouseup",Ae),document.body.style.cursor="",document.body.style.userSelect="";}},[Y,ie,Ee]);let Ge=(V,re,Se)=>{switch(V.id){case "name":let qe=U===re.id,_e=A===re.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${Se*20}px`},children:[x&&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:Q=>X(re.id,Q),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),re.subtasks&&re.subtasks.length>0?jsx("button",{onClick:Q=>{Q.stopPropagation(),m?.(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"})}),qe?jsx("input",{ref:pe,type:"text",value:_,onChange:Q=>q(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"?it(re.id):Q.key==="Escape"&&ae();},onBlur:()=>it(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:Q=>Q.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&&!qe&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:Q=>Q.stopPropagation(),children:[jsx("button",{onClick:Q=>E(re,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(),te(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 de=V.id==="startDate"?"startDate":"endDate",Ie=re[de],At=ne?.taskId===re.id&&ne?.field===de,tt=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(At)le(null);else {let Me=Q.currentTarget.getBoundingClientRect();le({taskId:re.id,field:de,month:Ie?typeof Ie=="string"?new Date(Ie):Ie:new Date,position:{top:Me.bottom+4,left:Me.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:tt(Ie)})]}),At&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>le(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:ne?.position.top,left:ne?.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,Me=new Date(Q);Me.setDate(Q.getDate()+1);let lt=new Date(Q);lt.setDate(Q.getDate()+7);let se=new Date(Q);return se.setDate(Q.getDate()+14),[{label:"Hoy",date:Q},{label:"Ma\xF1ana",date:Me},{label:"Pr\xF3xima semana",date:lt},{label:"2 semanas",date:se}].map((St,Fe)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:Bt=>Bt.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:Bt=>Bt.currentTarget.style.backgroundColor="transparent",onClick:()=>{b?.(re.id,{[de]:St.date}),le(null);},children:St.label},Fe))})(),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:()=>{b?.(re.id,{[de]:void 0}),le(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:()=>le(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:ne?.month.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>le(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,Me)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:Q},Me))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let Q=ne?.month||new Date,Me=Q.getFullYear(),lt=Q.getMonth(),se=new Date(Me,lt,1).getDay(),He=new Date(Me,lt+1,0).getDate(),St=new Date,Fe=[];for(let ut=se-1;ut>=0;ut--)Fe.push({day:new Date(Me,lt,-ut).getDate(),date:new Date(Me,lt-1,new Date(Me,lt,-ut).getDate()),isCurrentMonth:false});for(let ut=1;ut<=He;ut++)Fe.push({day:ut,date:new Date(Me,lt,ut),isCurrentMonth:true});let Bt=42-Fe.length;for(let ut=1;ut<=Bt;ut++)Fe.push({day:ut,date:new Date(Me,lt+1,ut),isCurrentMonth:false});return Fe.map((ut,fa)=>{let Wt=ut.date.toDateString()===St.toDateString(),Et=(Ie?typeof Ie=="string"?new Date(Ie):Ie:null)?.toDateString()===ut.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:ut.isCurrentMonth?Et?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:Et?"#3B82F6":"transparent",boxShadow:Wt&&!Et?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{b?.(re.id,{[de]:ut.date}),le(null);},children:ut.day},fa)})})()})]})]})]}),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:ee(re)})});case "assignees":let xa=r.filter(Q=>re.assignees?.some(Me=>Me.name===Q.name||Me.initials===Q.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:Q=>Q.stopPropagation(),children:jsx(Ur,{assignedUsers:xa,availableUsers:r,onChange:Q=>{let Me=Q.map(lt=>({id:lt.id,name:lt.name,initials:lt.initials,color:lt.color}));b?.(re.id,{assignees:Me.length>0?Me:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:Q=>Q.stopPropagation(),children:jsx(Xl,{status:re.status||"todo",onChange:Q=>{b?.(re.id,{status:Q,progress:Q==="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 ga={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},P={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},ye=ga[re.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:Q=>Q.stopPropagation(),children:jsx(Or,{priority:ye,onChange:Q=>{Q&&b?.(re.id,{priority:P[Q]||"medium"});}})});default:return null}},Ye=V=>[{id:"hide",label:"Hide Column",icon:Ut.Hide,onClick:()=>d(V),disabled:V==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:Ut.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:Ut.SortDesc,onClick:()=>{}}],Ue=V=>V.subtasks&&V.subtasks.length>0?[{id:"addSubtask",label:R?.contextMenu?.addSubtask||"Add Subtask",icon:Ut.Add,onClick:()=>{y?.(V.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:R?.contextMenu?.deleteTask||"Delete Task",icon:Ut.Delete,onClick:()=>{w?w(V.id,V.name):h?.([V.id]);}}]:[{id:"edit",label:R?.contextMenu?.editTask||"Edit Task",icon:Ut.Pencil,onClick:()=>{n?.(V);}},{id:"addSubtask",label:R?.contextMenu?.addSubtask||"Add Subtask",icon:Ut.Add,onClick:()=>{y?.(V.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:R?.contextMenu?.markIncomplete||"Mark Incomplete",icon:Ut.MarkIncomplete,onClick:()=>{b?.(V.id,{status:"todo",progress:0});},disabled:V.status==="todo"},{id:"setInProgress",label:R?.contextMenu?.setInProgress||"Set In Progress",icon:Ut.SetInProgress,onClick:()=>{b?.(V.id,{status:"in-progress"});},disabled:V.status==="in-progress"},{id:"markComplete",label:R?.contextMenu?.markComplete||"Mark Complete",icon:Ut.MarkComplete,onClick:()=>{b?.(V.id,{status:"completed",progress:100});},disabled:V.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:R?.contextMenu?.splitTask||"Split Task",icon:Ut.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:R?.contextMenu?.deleteTask||"Delete Task",icon:Ut.Delete,onClick:()=>{w?w(V.id,V.name):h?.([V.id]);}}],ot=u.filter(V=>V.visible),pt=ot.reduce((V,re)=>V+re.width,0);return jsxs("div",{className:"h-full",style:{backgroundColor:t.bgPrimary,minWidth:pt},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${Lt}px`,paddingLeft:"3px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:[jsx("div",{className:"flex items-center flex-1 min-w-0",children:ot.map((V,re)=>{let Se=re===ot.length-1,qe=V.id==="name";return jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${qe?"":"justify-center"}`,style:{width:`${V.width}px`,minWidth:`${V.minWidth??(qe?200:60)}px`,maxWidth:`${V.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:Se?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:_e=>{_e.preventDefault(),W({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:Te===V.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:_e=>{_e.preventDefault(),_e.stopPropagation(),Ze(V.id),Be(_e.clientX),B(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(wn,{columns:u,onToggleColumn:d,theme:t}),jsx("button",{onClick:()=>$e(!we),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"})}),we&&jsxs("div",{ref:et,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:()=>$e(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:va},children:mt.map(({task:V,level:re},Se)=>{let qe=Vt(V.id),_e=ie===V.id,G=_e&&Ee==="above",de=_e&&Ee==="below",Ie=_e&&Ee==="child",At={};return Ie&&(At.backgroundColor=`${t.accent}15`,At.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":V.id,className:`flex items-center cursor-pointer group ${Y===V.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:qe?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:qe?t.accentLight:Ie?`${t.accent}15`:Se%2===0?t.bgPrimary:t.bgGrid,...At},onMouseEnter:()=>N(V.id),onMouseLeave:()=>N(null),onClick:tt=>{let ga=vo(e).map(Q=>Q.id),ye=navigator.platform.toUpperCase().indexOf("MAC")>=0?tt.metaKey:tt.ctrlKey;Pe(V.id,ga,ye,tt.shiftKey),s?.(V);},onDoubleClick:tt=>{tt.stopPropagation(),n?.(V);},onContextMenu:tt=>{tt.preventDefault(),W({isOpen:true,x:tt.clientX,y:tt.clientY,type:"task",task:V}),p?.(V,tt);},whileHover:{backgroundColor:qe?t.accentLight:t.hoverBg},children:[G&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),de&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),ot.map((tt,xa)=>{let ga=xa===ot.length-1,P=tt.id==="name";return jsx("div",{className:`px-4 flex items-center ${P?"justify-start":"justify-center"}`,style:{width:`${tt.width}px`,minWidth:`${tt.minWidth??(P?200:60)}px`,maxWidth:`${tt.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:ga?"none":`1px solid ${A===V.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:Ge(tt,V,P?re:0)},`${V.id}-${tt.id}`)})]},V.id)})}),jsx(yo,{isOpen:D.isOpen,x:D.x,y:D.y,items:D.type==="header"&&D.columnId?Ye(D.columnId):D.type==="task"&&D.task?Ue(D.task):[],onClose:()=>W({...D,isOpen:false}),theme:t}),nt&&ze&&Y&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:ze.x+12,top:ze.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let V=mt.find(re=>re.task.id===Y)?.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 dc(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[n,p]=useState(e),[m,i]=useState(t),[u,d]=useState(null),[g,b]=useState(null),[C,T]=useState(null),[c,h]=useState(null),[v,l]=useState(0),[k,y]=useState(0),[S,w]=useState(null),[x,R]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:n,setGhostX:p,ghostWidth:m,setGhostWidth:i,connectionLine:u,setConnectionLine:d,hoveredTaskId:g,setHoveredTaskId:b,activeZone:C,setActiveZone:T,draggedSegmentIndex:c,setDraggedSegmentIndex:h,draggedSegmentStartX:v,setDraggedSegmentStartX:l,segmentDragOffsetX:k,setSegmentDragOffsetX:y,hoveredSegmentIndex:S,setHoveredSegmentIndex:w,isHovered:x,setIsHovered:R,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(_,q)=>{r("none"),d(null),b(null),p(_),i(q),y(0),h(null),l(0);}}}function Dn({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:n,templates:p,onClick:m,onDoubleClick:i,onContextMenu:u,onDateChange:d,onDependencyCreate:g,allTaskPositions:b=[],onDragMove:C,onHoverChange:T}){let c=dc(t,r),h=useRef(null),{dragMode:v,setDragMode:l,dragOffset:k,setDragOffset:y,ghostX:S,setGhostX:w,ghostWidth:x,setGhostWidth:R,connectionLine:A,setConnectionLine:N,hoveredTaskId:U,setHoveredTaskId:$,activeZone:_,setActiveZone:q,draggedSegmentIndex:pe,setDraggedSegmentIndex:Te,draggedSegmentStartX:Ze,setDraggedSegmentStartX:Oe,segmentDragOffsetX:Be,setSegmentDragOffsetX:L,hoveredSegmentIndex:B,setHoveredSegmentIndex:D,isHovered:W,setIsHovered:Y,isDragging:O,isResizing:ie,isConnecting:ve,resetDragState:Ee}=c,fe=32,We=8,Re=e.endDate&&e.endDate<new Date&&e.progress<100,Le=e.isCriticalPath,ze=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"},ne=e.isCriticalPath||Re?"#DC2626":e.color?e.color:e.priority&&nt[e.priority]?nt[e.priority]:o.taskBarPrimary,we=(ae=>ae>=80?20:ae>=60?15:ae>=50?12:10)(r),$e=r<50,et=r<40;useEffect(()=>{if(T)if(W&&!O&&!e.segments){let ae=a<100;T({task:e,x:t,y:a,width:r,height:fe,showBelow:ae});}else T(null);},[W,O,e,t,a,r,fe,T]);let vt=ae=>ae.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Pe=()=>{let ae=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${ae} day${ae!==1?"s":""}`},Vt=ae=>Math.round(ae/s)*s,ft=ae=>{let E=Math.round(ae/s),X=new Date(n);return X.setDate(X.getDate()+E),X},st=(ae,E)=>{for(let X of b){if(X.id===e.id)continue;let be=5;if(ae>=X.x-be&&ae<=X.x+X.width+be&&E>=X.y-be&&E<=X.y+X.height+be)return X.id}return null},mt=useCallback((ae,E,X)=>{ae.preventDefault(),ae.stopPropagation();let be=h.current?.ownerSVGElement;if(!be)return;let Ae=be.createSVGPoint();Ae.x=ae.clientX,Ae.y=ae.clientY;let Ge=Ae.matrixTransform(be.getScreenCTM()?.inverse()),Ye=X!==void 0?X:t,Ue=E;if(!Ue){let ot=Ge.x-Ye;ae.shiftKey?(Ue="connect",N({x:t+r,y:a+fe/2})):ae.ctrlKey||ae.metaKey?Ue="move":ae.altKey?Ue=ot<r/2?"resize-start":"resize-end":et?ot<r/2?Ue="move":Ue="resize-end":$e?ot<=we/2?Ue="resize-start":ot>=r-we/2?Ue="resize-end":Ue="move":ot<=we?Ue="resize-start":ot>=r-we?Ue="resize-end":Ue="move";}l(Ue),Y(false),q(null),Ue==="move"?y(Ge.x-Ye):Ue==="connect"?N({x:t+r,y:a+fe/2}):y(0),w(Ye),R(r);},[t,r,a,fe]),Lt=useCallback(ae=>{if(v==="none")return;let E=h.current?.ownerSVGElement;if(!E)return;let X=E.createSVGPoint();X.x=ae.clientX,X.y=ae.clientY;let be=X.matrixTransform(E.getScreenCTM()?.inverse());if(v==="connect"){N({x:be.x,y:be.y});let Ae=st(be.x,be.y);$(Ae);}else if(v==="move"){let Ae=be.x-k,Ge=Vt(Ae);w(Ge),R(r);let Ye=Math.round((Ge-t)/s);if(C?.(e.id,Ye,true),e.segments&&e.segments.length>0&&pe!==null){let Ue=Ge-Ze;L(Ue);}}else if(v==="resize-start"){let Ae=be.x,Ge=Vt(Ae),Ye=t+r-Ge;Ye>=s&&(w(Ge),R(Ye));}else if(v==="resize-end"){let Ae=be.x,Ye=Vt(Ae)-t;Ye>=s&&R(Ye);}},[v,t,r,s,k,e,Vt,pe,Ze,st,$,N,w,R,L,C]),va=useCallback(()=>{if(v!=="none"){if(v==="connect")U&&g&&g(e,U),N(null),$(null);else {let ae=e.endDate.getTime()-e.startDate.getTime(),E,X,be=true;if(v==="move"){if(E=ft(S),X=new Date(E.getTime()+ae),e.segments&&e.segments.length>0&&pe!==null){let Ae=Math.round(Be/s),Ge=e.segments.map((pt,V)=>{if(V===pe){let re=new Date(pt.startDate),Se=new Date(pt.endDate);return re.setDate(re.getDate()+Ae),Se.setDate(Se.getDate()+Ae),{startDate:re,endDate:Se}}return pt}),Ye=Ge.flatMap(pt=>[pt.startDate,pt.endDate]),Ue=new Date(Math.min(...Ye.map(pt=>pt.getTime()))),ot=new Date(Math.max(...Ye.map(pt=>pt.getTime())));d?.({...e,segments:Ge},Ue,ot),Ee(t,r);return}}else v==="resize-start"?(E=ft(S),X=e.endDate,E>X&&(console.warn("Invalid date range: start date must be before or equal to end date"),be=false)):v==="resize-end"?(E=e.startDate,X=ft(S+x),X<E&&(console.warn("Invalid date range: end date must be after or equal to start date"),be=false)):be=false;be&&E&&X&&(X.getTime()<E.getTime()?console.warn("Invalid date range: end date cannot be before start date"):d?.(e,E,X));}C?.(e.id,0,false),Ee(t,r);}},[v,S,x,e,d,U,g,t,r,s,ft,Be,pe,Ee,C]);useEffect(()=>{if(v==="none")return;let ae=X=>{Lt(X);},E=()=>{va();};return window.addEventListener("mousemove",ae),window.addEventListener("mouseup",E),()=>{window.removeEventListener("mousemove",ae),window.removeEventListener("mouseup",E);}},[v,Lt,va]);let ee=O&&!ve?S:t,te=O&&!ve?x:r,it=p.taskClass(e);return jsxs("g",{ref:h,onClick:()=>!O&&m?.(e),onDoubleClick:ae=>{O||(ae.stopPropagation(),i?.(e));},onContextMenu:ae=>{ae.preventDefault(),u?.(e,ae);},onMouseEnter:()=>!O&&Y(true),onMouseLeave:()=>{O||(Y(false),q(null));},children:[W&&!O&&!$e&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:we,height:fe,fill:_==="resize-start"?o.accent:"transparent",opacity:_==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>q("resize-start"),onMouseDown:ae=>mt(ae,"resize-start")}),jsx("rect",{x:t+we,y:a,width:r-we*2,height:fe,fill:_==="move"?o.accent:"transparent",opacity:_==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>q("move"),onMouseDown:ae=>mt(ae,"move")}),jsx("rect",{x:t+r-we,y:a,width:we,height:fe,fill:_==="resize-end"?o.accent:"transparent",opacity:_==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>q("resize-end"),onMouseDown:ae=>mt(ae,"resize-end")})]}),W&&!O&&et&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:fe,fill:_==="move"?o.accent:"transparent",opacity:_==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>q("move"),onMouseDown:ae=>mt(ae,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:fe,fill:_==="resize-end"?o.accent:"transparent",opacity:_==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>q("resize-end"),onMouseDown:ae=>mt(ae,"resize-end")}),W&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+fe-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),O&&!ve&&!e.segments&&jsx(motion.rect,{x:S,y:a,width:x,height:fe,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:ee,y:a,width:te,height:fe,rx:We,fill:ne,"data-task-class":it,initial:{opacity:0,scale:.95},animate:{opacity:O&&!ve?.15:e.parentId?.6:W?.9:.8,scale:W&&!O?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:ae=>mt(ae),style:{cursor:O?ve?"crosshair":ie?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:ee,y:a,width:te*(e.progress/100),height:fe,rx:We,fill:ne,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((ae,E)=>{let X=(ae.startDate.getTime()-n.getTime())/864e5*s,Ae=(ae.endDate.getTime()-n.getTime())/(1e3*60*60*24)*s-X+s,Ge=O&&v==="move"&&pe===E,Ye=B===E,Ue=Ge?X+Be:X;return jsxs("g",{onMouseEnter:()=>!O&&D(E),onMouseLeave:()=>!O&&D(null),children:[jsx(motion.rect,{x:Ue,y:a,width:Ae,height:fe,rx:We,fill:ne,initial:{opacity:0,scale:.95},animate:{opacity:Ge||e.parentId?.6:Ye?.9:.8,scale:Ye&&!O?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:ot=>{ot.stopPropagation(),Te(E),Oe(X),mt(ot,void 0,X);},style:{cursor:O?ve?"crosshair":ie?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:Ue,y:a,width:Ae*(e.progress/100),height:fe,rx:We,fill:ne,opacity:1,style:{pointerEvents:"none"}})]},`segment-${E}`)}),ze&&(Re||Le)&&!e.segments&&jsxs(Fragment,{children:[Le&&!Re&&jsx("rect",{x:ee,y:a,width:te,height:fe,rx:We,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),Re&&jsx("rect",{x:ee,y:a,width:te,height:fe,rx:We,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),te>60&&!e.segments&&(()=>{let ae=p.taskLabel(e),E=typeof ae=="string"?ae:e.name,X=E.length>Math.floor(te/8)?`${E.substring(0,Math.floor(te/8))}...`:E;return jsx("text",{x:ee+12,y:a+fe/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:X})})(),te>100&&e.progress>0&&e.progress<100&&!O&&!e.segments&&jsxs("text",{x:ee+te-12,y:a+fe/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&&te>80&&!O&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:ee+te-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:ee+te-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(W||ie)&&!ve&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{children:[jsx("rect",{x:ee-2,y:a,width:16,height:fe,fill:"transparent",style:{cursor:"ew-resize"},onMouseEnter:()=>q("resize-start"),onMouseLeave:()=>q(null),onMouseDown:ae=>{ae.stopPropagation(),mt(ae,"resize-start");}}),jsx(motion.rect,{x:ee+4,y:a+8,width:3,height:fe-16,rx:1.5,fill:_==="resize-start"||v==="resize-start"?"#ffffff":"rgba(255,255,255,0.5)",style:{pointerEvents:"none"},initial:{opacity:0},animate:{opacity:1},transition:{duration:.15}})]}),jsxs("g",{children:[jsx("rect",{x:ee+te-14,y:a,width:16,height:fe,fill:"transparent",style:{cursor:"ew-resize"},onMouseEnter:()=>q("resize-end"),onMouseLeave:()=>q(null),onMouseDown:ae=>{ae.stopPropagation(),mt(ae,"resize-end");}}),jsx(motion.rect,{x:ee+te-7,y:a+8,width:3,height:fe-16,rx:1.5,fill:_==="resize-end"||v==="resize-end"?"#ffffff":"rgba(255,255,255,0.5)",style:{pointerEvents:"none"},initial:{opacity:0},animate:{opacity:1},transition:{duration:.15}})]})]}),jsx(AnimatePresence,{children:W&&!O&&!e.segments&&jsxs(motion.g,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[jsx("circle",{cx:t+r+18,cy:a+fe/2,r:14,fill:"transparent",style:{cursor:"crosshair"},onMouseEnter:()=>q("connect"),onMouseLeave:()=>q(null),onMouseDown:ae=>{ae.stopPropagation(),mt(ae,"connect");}}),jsx(motion.circle,{cx:t+r+18,cy:a+fe/2,r:7,fill:o.accent,stroke:"#FFFFFF",strokeWidth:2,style:{pointerEvents:"none"},initial:{scale:0},animate:{scale:_==="connect"?1.3:1},exit:{scale:0},transition:{duration:.15,type:"spring",stiffness:500,damping:30}}),jsx("text",{x:t+r+32,y:a+fe/2,dominantBaseline:"middle",fill:_==="connect"?o.accent:o.textTertiary,fontSize:_==="connect"?"11":"10",fontWeight:_==="connect"?"600":"400",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:"Link"})]})}),ve&&A&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+fe/2,x2:A.x,y2:A.y,stroke:U?o.statusCompleted:o.accent,strokeWidth:U?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:U?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:A.x,cy:A.y,r:U?8:6,fill:U?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),U&&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"})]}),(W||O)&&!ve&&!e.segments&&jsx(motion.rect,{x:ee-2,y:a-2,width:te+4,height:fe+4,rx:We+2,fill:"none",stroke:O?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:O?.6:.4,initial:{opacity:0},animate:{opacity:O?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),ie&&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+x,y1:0,x2:S+x,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:W&&!O&&!e.segments&&!T&&(()=>{let X=a<100,be=X?a+fe+13:a-82-13,Ae=X?`M ${ee+te/2-6} ${a+fe+3} L ${ee+te/2} ${a+fe+13} L ${ee+te/2+6} ${a+fe+3}`:`M ${ee+te/2-6} ${a-13} L ${ee+te/2} ${a-3} L ${ee+te/2+6} ${a-13}`,Ge=be+22,Ye=be+40,Ue=be+55,ot=be+70,pt=X?be+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:X?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:X?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:Ae,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:ee+te/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:ee+te/2,y:Ge,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:ee+te/2-110,y:Ye,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:ee+te/2-70,y:Ye,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:vt(e.startDate)}),jsx("text",{x:ee+te/2-110,y:Ue,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:ee+te/2-70,y:Ue,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:vt(e.endDate)}),jsx("text",{x:ee+te/2+10,y:Ye,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:ee+te/2+65,y:Ye,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Pe()}),jsx("text",{x:ee+te/2+10,y:Ue,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:ee+te/2+65,y:Ue,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:ee+te/2-110,y:ot,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:ee+te/2-50,y:ot,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?"...":""]})]}),!X&&jsx("text",{x:ee+te/2,y:pt,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:et?"Left: move \u2022 Right: resize":$e?"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 pc({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:n,showBelow:p}=e,m=82,i=13,u=p?o+n+i:o-m-i,d=p?`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,b=u+40,C=u+55,T=u+70,c=k=>k.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),h=()=>{if(!a.startDate||!a.endDate)return "N/A";let k=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${k} day${k!==1?"s":""}`};return jsx(AnimatePresence,{children:jsxs(motion.g,{initial:{opacity:0,y:p?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:p?-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:m,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:b,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y:b,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?c(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?c(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y:b,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y:b,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:h()}),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(k=>k.name).join(", ").substring(0,30),a.assignees.map(k=>k.name).join(", ").length>30?"...":""]})]})]})})}function Pn({x1:e,y1:t,x2:a,y2:r,routeY:o,fromIndex:s,toIndex:n,rowHeight:p,theme:m,onDelete:i,onHoverChange:u,lineStyle:d="curved"}){let[g,b]=useState(false),C=a-e,T=r-t,c=s!==void 0&&n!==void 0&&s===n,h=e+C/2,v=56,l;s!==void 0&&n!==void 0?l=Math.min(s,n)*v+44+6:l=o??Math.max(t,r)+20;let k=8,y=5,S;if(c||Math.abs(T)<5)if(d==="squared")S=`M ${e} ${t} L ${a} ${r}`;else {let _=Math.min(Math.abs(C)/3,30);S=`M ${e} ${t} C ${e+_} ${t}, ${a-_} ${r}, ${a} ${r}`;}else {let _=r>t,q=e+k,pe=a-k;if(d==="squared")S=`M ${e} ${t} L ${q} ${t} L ${q} ${l} L ${pe} ${l} L ${pe} ${r} L ${a} ${r}`;else {let Te=y;_?S=`M ${e} ${t} L ${q-Te} ${t} Q ${q} ${t} ${q} ${t+Te} L ${q} ${l-Te} Q ${q} ${l} ${q+Te} ${l} L ${pe-Te} ${l} Q ${pe} ${l} ${pe} ${l+Te} L ${pe} ${r-Te} Q ${pe} ${r} ${pe+Te} ${r} L ${a} ${r}`:S=`M ${e} ${t} L ${q-Te} ${t} Q ${q} ${t} ${q} ${t-Te} L ${q} ${l+Te} Q ${q} ${l} ${q+Te} ${l} L ${pe-Te} ${l} Q ${pe} ${l} ${pe} ${l-Te} L ${pe} ${r+Te} Q ${pe} ${r} ${pe+Te} ${r} L ${a} ${r}`;}}let w=5,x=a-w,R=r-w*.5,A=a-w,N=r+w*.5,U=m.dependency;useEffect(()=>{u&&i&&u(g?{x1:e,y1:t,x2:a,y2:r,routeY:l,onDelete:i,lineStyle:d}:null);},[g,e,t,a,r,l,i,u,d]);let $=!i&&!u;return jsxs("g",{onMouseEnter:()=>!$&&b(true),onMouseLeave:()=>!$&&b(false),style:{pointerEvents:$?"none":"auto"},children:[!$&&jsx("path",{d:S,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx(motion.path,{d:S,fill:"none",stroke:U,strokeWidth:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:g&&u?0:g?1:.8,strokeWidth:g?2.5:2},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2},strokeWidth:{duration:.2}}}),jsx(motion.path,{d:`M ${a} ${r} L ${x} ${R} M ${a} ${r} L ${A} ${N}`,fill:"none",stroke:U,strokeWidth:2,strokeLinecap:"round",initial:{opacity:0,scale:.8},animate:{opacity:g&&u?0:g?1:.8,scale:g?1.1:1,strokeWidth:g?2.5:2},transition:{duration:.2}}),jsx(motion.circle,{cx:a,cy:r,r:3,fill:U,initial:{scale:0},animate:{scale:g&&u?0:g?1.3:1,opacity:g&&u?0:g?1:.8},transition:{scale:{delay:.3,duration:.15},opacity:{duration:.2}}}),g&&i&&!u&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:_=>{_.stopPropagation(),i();},style:{cursor:"pointer"},children:[jsx("circle",{cx:h,cy:(t+r)/2,r:10,fill:m.bgSecondary,stroke:m.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:h-4,y1:(t+r)/2-4,x2:h+4,y2:(t+r)/2+4,stroke:m.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:h+4,y1:(t+r)/2-4,x2:h-4,y2:(t+r)/2+4,stroke:m.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})}function An({task:e,x:t,y:a,theme:r,onClick:o}){let[s,n]=useState(false),p=16,m=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:p+4,fill:r.criticalPathLight,initial:{scale:0},animate:{scale:s?1.2:1},transition:{duration:.3}}),jsx(motion.rect,{x:t-p/2,y:a+16-p/2,width:p,height:p,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-(p+4)/2,y:a+16-(p+4)/2,width:p+4,height:p+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:m(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 ge={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,p=new Set,m=i=>{if(!n.has(i)){n.add(i),p.add(i);let u=r.get(i)||[];for(let d of u){if(!n.has(d)&&m(d))return true;if(p.has(d))return true}}return p.delete(i),false};return m(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=ge.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=ge.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=ge.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=ge.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=ge.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=ge.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)=>ge.flattenTasks(e).filter(r=>r.dependencies&&r.dependencies.includes(t)),getDependencyTasks:(e,t)=>{let a=ge.findTaskById(e,t);return !a||!a.dependencies?[]:ge.flattenTasks(e).filter(o=>a.dependencies.includes(o.id))},filterByStatus:(e,t)=>ge.flattenTasks(e).filter(a=>a.status===t),filterByDateRange:(e,t,a)=>ge.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=ge.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=>ge.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=ge.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"]],p=s.map(m=>{let i=m.startDate&&m.endDate?ge.calculateDuration(m.startDate,m.endDate):0;return [m.name,m.startDate?ge.formatDate(m.startDate):"N/A",m.endDate?ge.formatDate(m.endDate):"N/A",i>0?`${i} days`:"N/A",`${m.progress}%`,m.status||"N/A"]});r(o,{head:n,body:p,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=ge.flattenTasks(e).map(m=>{let i=m.startDate&&m.endDate?ge.calculateDuration(m.startDate,m.endDate):0;return {"Task ID":m.id,"Task Name":m.name,"Start Date":m.startDate?ge.formatDate(m.startDate):"","End Date":m.endDate?ge.formatDate(m.endDate):"","Duration (days)":i>0?i:"","Progress (%)":m.progress,Status:m.status||"",Assignees:m.assignees?.map(u=>u.name).join(", ")||"",Dependencies:m.dependencies?.join(", ")||"","Is Milestone":m.isMilestone?"Yes":"No","Parent ID":m.parentId||"",Level:m.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 p=a.utils.book_new();a.utils.book_append_sheet(p,s,"Gantt Tasks"),a.writeFile(p,t);},exportToMSProject:(e,t="Gantt Project",a="project.xml")=>{let r=ge.flattenTasks(e),o=new Map;r.forEach((g,b)=>{o.set(g.id,b+1);});let s=g=>g.toISOString().replace("Z",""),n=ge.getEarliestStartDate(e)||new Date,p=ge.getLatestEndDate(e)||new Date,m=r.map((g,b)=>{let C=o.get(g.id),T=g.startDate&&g.endDate?ge.calculateDuration(g.startDate,g.endDate):0,c=(g.dependencies||[]).filter(h=>o.has(h)).map(h=>`
111
+ - [ ] `,priority:"MEDIUM",labels:["meeting"]}}];function _s({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 m=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:()=>m(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 js({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[n,m]=useState("export"),[p,i]=useState("json"),[u,d]=useState(null),g=useRef(null);if(!t)return null;let b=async()=>{let T=o?.current||void 0,c=await Sl(e,p,T);El(c,p);},C=async T=>{let c=T.target.files?.[0];if(c){try{let h=await Al(c),v=c.name.endsWith(".json")?"json":"csv",l=Ml(h,v);d(l),l.success&&r&&r(l,h);}catch(h){d({success:false,errors:[`Failed to read file: ${h instanceof Error?h.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:()=>m("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:()=>m("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:b,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,c)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",T]},c))})]})]})]})]})]})}var Ug=["URGENT","HIGH","MEDIUM","LOW"],Hg=[{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"}],Wg=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function Ks({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:n,onFilterHighPriority:m,availableUsers:p=[],availableLabels:i=[],availableColumns:u=[],showQuickFilters:d=true,compact:g=false,groupBy:b="none",onGroupByChange:C}){let[T,c]=useState(true),h=useCallback(S=>{a({search:S.target.value});},[a]),v=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]),y=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:()=>c(!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"}),y&&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"}),m&&jsx("button",{onClick:m,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:h,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:v,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 k=S.target.value;a({priorities:k==="all"?[]:[k]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),Ug.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 k=S.target.value;a({assignees:k==="all"?[]:[k]});},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 k=S.target.value;a({labels:k==="all"?[]:[k]});},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:Hg.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:b,onChange:S=>C(S.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Wg.map(S=>jsx("option",{value:S.value,children:S.label},S.value))})}),y&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function Ys({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:n,onExportGanttPNG:m,onExportGanttCSV:p}){let[i,u]=useState(false),d=useRef(null);useEffect(()=>{let b=C=>{d.current&&!d.current.contains(C.target)&&u(false);};return i&&document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b);}},[i]);let g=b=>{b(),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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",b.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",b.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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:b=>{b.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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:b=>{b.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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:b=>{b.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 m?.()),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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:b=>{b.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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:b=>{b.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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:b=>{b.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:b=>{b.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:b=>{b.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 qs={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"}},Xs={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"}},jr={dark:qs,light:Xs,neutral:Js},bn="dark";var yn=createContext(void 0),Qg="asakaa-theme";function zd({children:e,defaultTheme:t=bn,storageKey:a=Qg}){let[r,o]=useState(()=>{if(typeof window<"u"){let m=localStorage.getItem(a);if(m&&(m==="dark"||m==="light"||m==="neutral"))return m}return t}),s=useCallback(m=>{o(m),typeof window<"u"&&localStorage.setItem(a,m);},[a]);useEffect(()=>{if(typeof window>"u")return;let m=document.documentElement,p=jr[r];Object.entries(p.colors).forEach(([u,d])=>{d&&m.style.setProperty(`--theme-${Zg(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&&m.style.setProperty(d,g);}),m.setAttribute("data-theme",r),m.classList.remove("theme-dark","theme-light","theme-neutral"),m.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 Zg(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Qs({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 Ud(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return et[e]||et.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,n)=>a.getPropertyValue(s).trim()||n;return {bgPrimary:r("--theme-bg-primary",et[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",et[e].bgSecondary),bgGrid:r("--theme-bg-card",et[e].bgGrid),bgWeekend:r("--theme-bg-hover",et[e].bgWeekend),border:r("--theme-border-primary",et[e].border),borderLight:r("--theme-border-subtle",et[e].borderLight),textPrimary:r("--theme-text-primary",et[e].textPrimary),textSecondary:r("--theme-text-secondary",et[e].textSecondary),textTertiary:r("--theme-text-tertiary",et[e].textTertiary),accent:r("--theme-accent-primary",et[e].accent),accentHover:r("--theme-accent-hover",et[e].accentHover),accentLight:r("--theme-accent-primary",et[e].accentLight),taskBarPrimary:r("--theme-accent-primary",et[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",et[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",et[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",et[e].dependency),dependencyHover:r("--theme-border-secondary",et[e].dependencyHover),criticalPath:r("--theme-error",et[e].criticalPath),criticalPathLight:r("--theme-error",et[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",et[e].today):e==="neutral"?r("--theme-text-primary",et[e].today):r("--theme-error",et[e].today),todayLight:e==="light"?r("--theme-accent-primary",et[e].todayLight):e==="neutral"?r("--theme-text-primary",et[e].todayLight):r("--theme-error",et[e].todayLight),milestone:r("--theme-warning",et[e].milestone),milestoneLight:r("--theme-warning",et[e].milestoneLight),statusTodo:r("--theme-text-tertiary",et[e].statusTodo),statusInProgress:r("--theme-accent-primary",et[e].statusInProgress),statusCompleted:r("--theme-success",et[e].statusCompleted),hoverBg:r("--theme-bg-hover",et[e].hoverBg),focusRing:r("--theme-accent-primary",et[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",filterAll:"All",filterIncomplete:"Incomplete",filterInProgress:"In Progress",filterCompleted:"Completed",filter:"Filter",filterBy:"Filter by status",filterAllDesc:"Show all tasks",filterIncompleteDesc:"Hide completed tasks",filterInProgressDesc:"Tasks currently being worked on",filterCompletedDesc:"Only show finished tasks",clearFilter:"Clear filter"},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"}},Hd={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",filterAll:"Todas",filterIncomplete:"Sin completar",filterInProgress:"En progreso",filterCompleted:"Completadas",filter:"Filtrar",filterBy:"Filtrar por estado",filterAllDesc:"Mostrar todas las tareas",filterIncompleteDesc:"Ocultar tareas completadas",filterInProgressDesc:"Tareas en las que se est\xE1 trabajando",filterCompletedDesc:"Solo mostrar tareas terminadas",clearFilter:"Limpiar filtro"},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"}},Zs={en:vn,es:Hd};function Wd(e){return Zs[e]||Zs.en}function ei(e,t){let a=Wd(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 bo(){return useContext(ho)}function hf({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:n}){let[m,p]=useState(false),[i,u]=useState(null),d=useRef(null),g=bo();if(useEffect(()=>{let c=h=>{d.current&&!d.current.contains(h.target)&&p(false);};return m&&document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[m]),!(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(c=>c.handler),T=async(c,h)=>{if(h){u(c);try{await h();}catch(v){console.error(`Export ${c} failed:`,v);}finally{u(null),p(false);}}};return jsxs("div",{ref:d,className:"relative",children:[jsxs(motion.button,{onClick:()=>p(!m),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:m?e.accent:e.bgSecondary,border:`1px solid ${m?e.accent:e.borderLight}`,color:m?"#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:m?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:m&&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((c,h)=>jsxs(motion.button,{onClick:()=>T(c.id,c.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:h<C.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:h*.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===c.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):c.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:c.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:c.description})]})]},c.id))})})})]})}function bf({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 yf({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 vf({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),n=bo();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 m=[{value:"compact",label:n.toolbar.compact||"Compact"},{value:"comfortable",label:n.toolbar.normal||"Normal"},{value:"spacious",label:n.toolbar.spacious||"Spacious"}],p=m.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:m.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<m.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 xf({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),n=bo();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 m=[{value:"all",label:n.toolbar.filterAll||"All tasks",description:n.toolbar.filterAllDesc||"Show all tasks"},{value:"incomplete",label:n.toolbar.filterIncomplete||"Incomplete only",description:n.toolbar.filterIncompleteDesc||"Hide completed tasks"},{value:"in_progress",label:n.toolbar.filterInProgress||"In progress",description:n.toolbar.filterInProgressDesc||"Tasks currently being worked on"},{value:"completed",label:n.toolbar.filterCompleted||"Completed",description:n.toolbar.filterCompletedDesc||"Only show finished tasks"}],p=t!=="all";return jsxs("div",{ref:s,className:"relative",children:[jsxs(motion.button,{onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:p||r?e.accentLight:e.bgSecondary,border:`1px solid ${p||r?e.accent:e.borderLight}`,color:p||r?e.accent:e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{backgroundColor:e.accentLight,borderColor:e.accent,color:e.accent,scale:1.02},whileTap:{scale:.98},children:[jsx(Filter,{className:"w-3.5 h-3.5"}),jsx("span",{children:n.toolbar.filter||"Filter"}),p&&jsx(motion.span,{initial:{scale:0},animate:{scale:1},className:"flex items-center justify-center w-4 h-4 rounded-full text-[10px] font-semibold",style:{backgroundColor:e.accent,color:"#FFFFFF"},children:"1"}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:r?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:r&&jsxs(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-56 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:"px-3 py-2 border-b",style:{borderColor:e.borderLight},children:jsx("span",{className:"text-xs font-medium",style:{color:e.textTertiary},children:n.toolbar.filterBy||"Filter by status"})}),jsx("div",{className:"py-1",children:m.map((i,u)=>{let d=t===i.value;return jsxs(motion.button,{onClick:()=>{a(i.value),o(false);},className:"w-full flex items-start gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:d?e.accentLight:"transparent"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:u*.03},children:[jsx("div",{className:"flex items-center justify-center w-4 h-4 rounded border mt-0.5 flex-shrink-0",style:{borderColor:d?e.accent:e.border,backgroundColor:d?e.accent:"transparent"},children:d&&jsx(Check,{className:"w-3 h-3",style:{color:"#FFFFFF"}})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium",style:{color:d?e.accent:e.textPrimary},children:i.label}),jsx("div",{className:"text-[10px] mt-0.5",style:{color:e.textTertiary},children:i.description})]})]},i.value)})}),p&&jsx("div",{className:"px-3 py-2 border-t",style:{borderColor:e.borderLight},children:jsx(motion.button,{onClick:()=>{a("all"),o(false);},className:"w-full text-xs py-1.5 rounded-md",style:{color:e.textTertiary},whileHover:{backgroundColor:e.hoverBg,color:e.textSecondary},children:n.toolbar.clearFilter||"Clear filter"})})]})})]})}function kn({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:n,rowDensity:m,onRowDensityChange:p,showThemeSelector:i=false,showCreateTaskButton:u=false,createTaskLabel:d,onCreateTask:g,taskFilter:b="all",onTaskFilterChange:C,onExportPNG:T,onExportPDF:c,onExportExcel:h,onExportCSV:v,onExportJSON:l,onExportMSProject:w}){let y=bo(),S=T||c||h||v||l||w,k=[{value:"day",label:y.toolbar.day},{value:"week",label:y.toolbar.week},{value:"month",label:y.toolbar.month}],x=[{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(yf,{options:k,value:t,onChange:R=>a(R),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(vf,{theme:e,value:m,onChange:p}),C&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsx(xf,{theme:e,value:b,onChange:C})]})]}),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||y.toolbar.createTask})]}),(S||i)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),S&&jsxs(Fragment,{children:[jsx(hf,{theme:e,onExportPNG:T,onExportPDF:c,onExportExcel:h,onExportCSV:v,onExportJSON:l,onExportMSProject:w}),i&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),i&&jsx(bf,{options:x,value:s,onChange:R=>n(R),theme:e})]})]})}function wn({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,n]=useState({x:0,y:0}),m=useRef(null),p=useRef(null);useEffect(()=>{if(!r)return;let u=d=>{m.current&&!m.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(ht,{children:jsx(motion.div,{ref:m,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 yo({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let n=useRef(null),[m,p]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let u=200,d=r.length*36+8,g=8,b=window.innerWidth,C=window.innerHeight,T=t,c=a;t+u+g>b&&(T=t-u,T<g&&(T=g)),a+d+g>C&&(c=C-d-g,c<g&&(c=g)),p({x:T,y:c});},[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:`${m.x}px`,top:`${m.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 Ut={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 Zd({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:n,onTaskIndent:m,onTaskOutdent:p,onTaskRename:i,onTaskToggleExpand:u,onOpenTaskModal:d,enableKeyboard:g=true}){let b=useRef(false),C=useCallback(l=>{b.current=l;},[]),T=useCallback(l=>{let w=[],y=S=>{for(let k of S)w.push(k),k.subtasks&&k.subtasks.length>0&&k.isExpanded&&y(k.subtasks);};return y(l),w},[]),c=useCallback(()=>{let l=T(e);for(let w of l)if(t.has(w.id))return w;return null},[e,t,T]),h=useCallback((l,w)=>{let y=T(e);if(y.length===0)return;let S=c();if(!S){a(y[0].id,false);return}let k=y.findIndex(A=>A.id===S.id);if(k===-1)return;let x=l==="up"?k-1:k+1;if(x<0||x>=y.length)return;let R=y[x];a(R.id,w);},[e,c,T,a]),v=useCallback(l=>{if(!g)return;let w=l.target;if(w.tagName==="INPUT"||w.tagName==="TEXTAREA"||w.isContentEditable||b.current){l.key==="Escape"&&(w.blur(),b.current=false);return}let k=navigator.platform.toUpperCase().indexOf("MAC")>=0?l.metaKey:l.ctrlKey,x=Array.from(t),R=c();if(l.key==="ArrowUp"){l.preventDefault(),h("up",l.shiftKey);return}if(l.key==="ArrowDown"){l.preventDefault(),h("down",l.shiftKey);return}if(R&&(l.key==="ArrowRight"||l.key==="ArrowLeft")){R.subtasks&&R.subtasks.length>0&&(l.preventDefault(),(l.key==="ArrowRight"&&!R.isExpanded||l.key==="ArrowLeft"&&R.isExpanded)&&u(R.id));return}if(l.altKey&&(l.key==="ArrowUp"||l.key==="ArrowDown")){x.length>0&&(l.preventDefault(),n(x,l.key==="ArrowUp"?"up":"down"));return}if(l.key==="Tab"&&!l.shiftKey){x.length>0&&(l.preventDefault(),m(x));return}if(l.key==="Tab"&&l.shiftKey){x.length>0&&(l.preventDefault(),p(x));return}if(l.key==="Enter"&&!l.shiftKey&&!k){R&&(l.preventDefault(),r(R.id,"below"));return}if(l.key==="Enter"&&l.shiftKey&&!k){R&&(l.preventDefault(),r(R.id,"above"));return}if(l.key==="Enter"&&k){R&&(l.preventDefault(),d(R.id));return}if(l.key==="F2"){R&&(l.preventDefault(),i(R.id));return}if(l.key==="Delete"||l.key==="Backspace"&&k){x.length>0&&(l.preventDefault(),o(x));return}if(l.key==="d"&&k&&!l.shiftKey){x.length>0&&(l.preventDefault(),s(x));return}},[g,t,c,h,r,o,s,n,m,p,i,u,d]);return useEffect(()=>{if(g)return window.addEventListener("keydown",v),()=>{window.removeEventListener("keydown",v);}},[g,v]),{setIsEditing:C}}function tc(){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 b=new Set(g);return b.has(d)?b.delete(d):b.add(d),b}),r(d);},[]),n=useCallback((d,g)=>{if(!a){o(d);return}let b=g.indexOf(a),C=g.indexOf(d);if(b===-1||C===-1){o(d);return}let T=Math.min(b,C),c=Math.max(b,C),h=g.slice(T,c+1);t(new Set(h)),r(d);},[a,o]),m=useCallback((d,g,b,C)=>{C?n(d,g):b?s(d):o(d);},[o,s,n]),p=useCallback((d,g)=>{g?t(b=>{let C=new Set(b);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:m,handleKeyboardSelection:p,clearSelection:i,isTaskSelected:u}}function vo(e){let t=[],a=(r,o,s=0)=>{for(let n=0;n<r.length;n++){let m={...r[n],parentId:o,level:s,position:n};t.push(m),m.subtasks&&m.subtasks.length>0&&m.isExpanded&&a(m.subtasks,m.id,s+1);}};return a(e),t}function ac(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=ac(a.subtasks,t);if(r)return r}}return null}function si(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=si(a.subtasks,t);if(r)return r}return null}function ii(e,t){if(t.length===0)return e;let a=vo(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 b=[];return {tasks:d.filter(T=>{if(g.has(T.id))return b.push(T),false;if(T.subtasks){let c=n(T.subtasks,g);T.subtasks=c.tasks,b.push(...c.removed);}return true}),removed:b}},m=(d,g,b)=>d.map(C=>C.id===g?{...C,subtasks:[...C.subtasks||[],...b],isExpanded:true}:C.subtasks?{...C,subtasks:m(C.subtasks,g,b)}:C),p=new Set(t),{tasks:i,removed:u}=n(e,p);return m(i,s.id,u)}function li(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=si(a,r);if(!o)continue;let s=si(a,o.id),n=(i,u,d)=>{for(let g=0;g<i.length;g++){let b=i[g];if(b.id===u&&b.subtasks){let C=b.subtasks.findIndex(T=>T.id===d);if(C!==-1){let[T]=b.subtasks.splice(C,1);return T}}if(b.subtasks){let C=n(b.subtasks,u,d);if(C)return C}}return null},m=(i,u,d)=>{let g=i.findIndex(b=>b.id===u);if(g!==-1)return i.splice(g+1,0,d),i;for(let b of i)b.subtasks&&m(b.subtasks,u,d);return i},p=n(a,o.id,r);p&&(s&&s.subtasks?m(s.subtasks,o.id,p):m(a,o.id,p));}return a}function di(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(n,m,p)=>{let i=n.findIndex(d=>d.id===m);if(i===-1){for(let d of n)if(d.subtasks&&s(d.subtasks,m,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 ci(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 pi(e,t){let a=[...e];for(let r of t){let o=n=>{let m=n.findIndex(u=>u.id===r);if(m===-1){for(let u of n)if(u.subtasks&&o(u.subtasks))return true;return false}let p=n[m],i={...p,id:`${p.id}-copy-${Date.now()}`,name:`${p.name} (Copy)`,subtasks:p.subtasks?s(p.subtasks):void 0};return n.splice(m+1,0,i),true},s=n=>n.map(m=>({...m,id:`${m.id}-copy-${Date.now()}`,subtasks:m.subtasks?s(m.subtasks):void 0}));o(a);}return a}function rc(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"},m=p=>{let i=p.findIndex(d=>d.id===t);if(i===-1){for(let d of p)if(d.subtasks&&m(d.subtasks))return true;return false}let u=a==="above"?i:i+1;return p.splice(u,0,n),true};return m(r),{tasks:r,newTask:n}}function mi(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:mi(r.subtasks,t,a)}:r)}function ui(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:ui(a.subtasks,t)}:a)}function gi(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,m=r?.endDate||s,p={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(n),endDate:new Date(m),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 oc(e,t,a,r){if(t===a)return e;let o=ac(e,t);if(!o)return e;if(a){let m=(p,i)=>{if(!p.subtasks)return false;for(let u of p.subtasks)if(u.id===i||m(u,i))return true;return false};if(m(o,a))return e}let s=m=>m.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 m=r!==void 0?r:n.length;n.splice(m,0,{...o,parentId:void 0});}else {let m=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:m(i.subtasks)}:i});n=m(n);}return n}function Nn({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:n,onTaskContextMenu:m,onTaskToggle:p,scrollTop:i,columns:u,onToggleColumn:d,onColumnResize:g,onTaskUpdate:b,onTaskIndent:C,onTaskOutdent:T,onTaskMove:c,onMultiTaskDelete:h,onTaskDuplicate:v,onTaskCreate:l,onTaskRename:w,onCreateSubtask:y,onOpenTaskModal:S,onDeleteRequest:k,onTaskReparent:x}){let R=useContext(ho),[A,N]=useState(null),[H,$]=useState(null),[_,V]=useState(""),ie=useRef(null),[Be,Oe]=useState(null),[ze,Pe]=useState(0),[L,B]=useState(0),[D,U]=useState({isOpen:false,x:0,y:0,type:"header"}),[q,O]=useState(null),[le,ve]=useState(null),[Ee,ue]=useState(null),We=useRef(0),Me=5,Re=useRef(false),[ft,qe]=useState(null),[it,z]=useState(false),[re,fe]=useState(null),[ye,Ae]=useState(false),Ze=useRef(null);useEffect(()=>{function j(te){Ze.current&&!Ze.current.contains(te.target)&&Ae(false);}if(ye)return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[ye]),useEffect(()=>{H&&ie.current&&(ie.current.focus(),ie.current.select());},[H]),useEffect(()=>{if(!Be)return;let j=Se=>{let Qe=Se.clientX-ze,_e=L+Qe;g?.(Be,_e);},te=()=>{Oe(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",j),document.addEventListener("mouseup",te),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",te),document.body.style.cursor="",document.body.style.userSelect="";}},[Be,ze,L,g]);let{selectedTaskIds:kt,handleTaskClick:De,isTaskSelected:It}=tc(),{setIsEditing:Ft}=Zd({tasks:e,selectedTaskIds:kt,onTaskSelect:(j,te)=>{let Qe=vo(e).map(_e=>_e.id);De(j,Qe,te||false,false);},onTaskCreate:l||(()=>{}),onTaskDelete:h||(()=>{}),onTaskDuplicate:v||(()=>{}),onTaskMove:c||(()=>{}),onTaskIndent:C||(()=>{}),onTaskOutdent:T||(()=>{}),onTaskRename:j=>{let te=vo(e).find(Se=>Se.id===j);te&&J(te);},onTaskToggleExpand:p||(()=>{}),onOpenTaskModal:j=>{let te=vo(e).find(Se=>Se.id===j);te&&S&&S(te);},enableKeyboard:true}),lt=(j,te=0)=>{let Se=[];for(let Qe of j)Se.push({task:Qe,level:te}),Qe.subtasks&&Qe.subtasks.length>0&&Qe.isExpanded&&Se.push(...lt(Qe.subtasks,te+1));return Se},Xe=lt(e),Wt=48,sa=Math.max(Xe.length*a,600-Wt),oe=j=>!j.startDate||!j.endDate?"-":`${Math.ceil((j.endDate.getTime()-j.startDate.getTime())/(1e3*60*60*24))}d`,J=j=>{$(j.id),V(j.name),Ft(true);},Ve=j=>{_.trim()&&_!==e.find(te=>te.id===j)?.name&&w?.(j,_.trim()),$(null),V(""),Ft(false);},ae=()=>{$(null),V(""),Ft(false);},E=(j,te)=>{te.stopPropagation(),y?.(j.id);},X=(j,te)=>{te.preventDefault(),We.current=te.clientY,O(j),Re.current=false,z(false),qe({x:te.clientX,y:te.clientY});},de=j=>{if(!q||(Math.abs(j.clientY-We.current)>Me&&!Re.current&&(Re.current=true,z(true)),qe({x:j.clientX,y:j.clientY}),!Re.current))return;let Se=document.querySelectorAll("[data-task-row]"),Qe=null,_e=null;Se.forEach(G=>{let ce=G.getBoundingClientRect(),$e=G.getAttribute("data-task-row");if($e&&$e!==q&&j.clientY>=ce.top&&j.clientY<=ce.bottom){Qe=$e;let Mt=j.clientY-ce.top,rt=ce.height;Mt<rt*.25?_e="above":Mt>rt*.75?_e="below":_e="child";}}),ve(Qe),ue(_e);},Le=()=>{if(Re.current&&q&&le&&Ee){if(Ee==="child")x?.(q,le);else if(Ee==="above"||Ee==="below"){let j=(Qe,_e,G=null)=>{for(let ce of Qe){if(ce.id===_e)return G;if(ce.subtasks){let $e=j(ce.subtasks,_e,ce.id);if($e!==void 0)return $e}}},te=j(e,le,null),Se=(Qe,_e)=>{let G=Qe.findIndex(ce=>ce.id===_e);return Ee==="below"?G+1:G};if(te===null){let Qe=Se(e,le);x?.(q,null,Qe);}else {let Qe=Xe.find(_e=>_e.task.id===te)?.task;if(Qe?.subtasks){let _e=Se(Qe.subtasks,le);x?.(q,te,_e);}}}}O(null),ve(null),ue(null),qe(null),Re.current=false,z(false);};useEffect(()=>{if(q)return document.addEventListener("mousemove",de),document.addEventListener("mouseup",Le),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",de),document.removeEventListener("mouseup",Le),document.body.style.cursor="",document.body.style.userSelect="";}},[q,le,Ee]);let Ge=(j,te,Se)=>{switch(j.id){case "name":let Qe=H===te.id,_e=A===te.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${Se*20}px`},children:[x&&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:Z=>X(te.id,Z),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),te.subtasks&&te.subtasks.length>0?jsx("button",{onClick:Z=>{Z.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"})}),Qe?jsx("input",{ref:ie,type:"text",value:_,onChange:Z=>V(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"?Ve(te.id):Z.key==="Escape"&&ae();},onBlur:()=>Ve(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:Z=>Z.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}),_e&&!Qe&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:Z=>Z.stopPropagation(),children:[jsx("button",{onClick:Z=>E(te,Z),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:Z=>{Z.stopPropagation(),J(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 ce=j.id==="startDate"?"startDate":"endDate",$e=te[ce],Mt=re?.taskId===te.id&&re?.field===ce,rt=Z=>Z?(typeof Z=="string"?new Date(Z):Z).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):"-";return jsxs("div",{className:"flex items-center justify-center w-full relative",onClick:Z=>Z.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:Z=>{if(Mt)fe(null);else {let Fe=Z.currentTarget.getBoundingClientRect();fe({taskId:te.id,field:ce,month:$e?typeof $e=="string"?new Date($e):$e:new Date,position:{top:Fe.bottom+4,left:Fe.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:rt($e)})]}),Mt&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>fe(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:Z=>Z.stopPropagation(),children:[jsxs("div",{className:"w-36 py-2",style:{borderRight:`1px solid ${t.border}`},children:[(()=>{let Z=new Date,Fe=new Date(Z);Fe.setDate(Z.getDate()+1);let dt=new Date(Z);dt.setDate(Z.getDate()+7);let se=new Date(Z);return se.setDate(Z.getDate()+14),[{label:"Hoy",date:Z},{label:"Ma\xF1ana",date:Fe},{label:"Pr\xF3xima semana",date:dt},{label:"2 semanas",date:se}].map((Dt,Ie)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:Bt=>Bt.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:Bt=>Bt.currentTarget.style.backgroundColor="transparent",onClick:()=>{b?.(te.id,{[ce]:Dt.date}),fe(null);},children:Dt.label},Ie))})(),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:Z=>Z.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:Z=>Z.currentTarget.style.backgroundColor="transparent",onClick:()=>{b?.(te.id,{[ce]:void 0}),fe(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:()=>fe(Z=>Z?{...Z,month:new Date(Z.month.getFullYear(),Z.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:()=>fe(Z=>Z?{...Z,month:new Date(Z.month.getFullYear(),Z.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((Z,Fe)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:Z},Fe))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let Z=re?.month||new Date,Fe=Z.getFullYear(),dt=Z.getMonth(),se=new Date(Fe,dt,1).getDay(),He=new Date(Fe,dt+1,0).getDate(),Dt=new Date,Ie=[];for(let ut=se-1;ut>=0;ut--)Ie.push({day:new Date(Fe,dt,-ut).getDate(),date:new Date(Fe,dt-1,new Date(Fe,dt,-ut).getDate()),isCurrentMonth:false});for(let ut=1;ut<=He;ut++)Ie.push({day:ut,date:new Date(Fe,dt,ut),isCurrentMonth:true});let Bt=42-Ie.length;for(let ut=1;ut<=Bt;ut++)Ie.push({day:ut,date:new Date(Fe,dt+1,ut),isCurrentMonth:false});return Ie.map((ut,ha)=>{let Gt=ut.date.toDateString()===Dt.toDateString(),St=($e?typeof $e=="string"?new Date($e):$e:null)?.toDateString()===ut.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:ut.isCurrentMonth?St?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:St?"#3B82F6":"transparent",boxShadow:Gt&&!St?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{b?.(te.id,{[ce]:ut.date}),fe(null);},children:ut.day},ha)})})()})]})]})]}),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:oe(te)})});case "assignees":let xa=r.filter(Z=>te.assignees?.some(Fe=>Fe.name===Z.name||Fe.initials===Z.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:Z=>Z.stopPropagation(),children:jsx(Ur,{assignedUsers:xa,availableUsers:r,onChange:Z=>{let Fe=Z.map(dt=>({id:dt.id,name:dt.name,initials:dt.initials,color:dt.color}));b?.(te.id,{assignees:Fe.length>0?Fe:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:Z=>Z.stopPropagation(),children:jsx(Xl,{status:te.status||"todo",onChange:Z=>{b?.(te.id,{status:Z,progress:Z==="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 fa={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},P={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},xe=fa[te.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:Z=>Z.stopPropagation(),children:jsx(Or,{priority:xe,onChange:Z=>{Z&&b?.(te.id,{priority:P[Z]||"medium"});}})});default:return null}},Je=j=>[{id:"hide",label:"Hide Column",icon:Ut.Hide,onClick:()=>d(j),disabled:j==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:Ut.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:Ut.SortDesc,onClick:()=>{}}],Ue=j=>j.subtasks&&j.subtasks.length>0?[{id:"addSubtask",label:R?.contextMenu?.addSubtask||"Add Subtask",icon:Ut.Add,onClick:()=>{y?.(j.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:R?.contextMenu?.deleteTask||"Delete Task",icon:Ut.Delete,onClick:()=>{k?k(j.id,j.name):h?.([j.id]);}}]:[{id:"edit",label:R?.contextMenu?.editTask||"Edit Task",icon:Ut.Pencil,onClick:()=>{n?.(j);}},{id:"addSubtask",label:R?.contextMenu?.addSubtask||"Add Subtask",icon:Ut.Add,onClick:()=>{y?.(j.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:R?.contextMenu?.markIncomplete||"Mark Incomplete",icon:Ut.MarkIncomplete,onClick:()=>{b?.(j.id,{status:"todo",progress:0});},disabled:j.status==="todo"},{id:"setInProgress",label:R?.contextMenu?.setInProgress||"Set In Progress",icon:Ut.SetInProgress,onClick:()=>{b?.(j.id,{status:"in-progress"});},disabled:j.status==="in-progress"},{id:"markComplete",label:R?.contextMenu?.markComplete||"Mark Complete",icon:Ut.MarkComplete,onClick:()=>{b?.(j.id,{status:"completed",progress:100});},disabled:j.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:R?.contextMenu?.splitTask||"Split Task",icon:Ut.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:R?.contextMenu?.deleteTask||"Delete Task",icon:Ut.Delete,onClick:()=>{k?k(j.id,j.name):h?.([j.id]);}}],st=u.filter(j=>j.visible),mt=st.reduce((j,te)=>j+te.width,0);return jsxs("div",{className:"h-full",style:{backgroundColor:t.bgPrimary,minWidth:mt},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${Wt}px`,paddingLeft:"3px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:[jsx("div",{className:"flex items-center flex-1 min-w-0",children:st.map((j,te)=>{let Se=te===st.length-1,Qe=j.id==="name";return jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${Qe?"":"justify-center"}`,style:{width:`${j.width}px`,minWidth:`${j.minWidth??(Qe?200:60)}px`,maxWidth:`${j.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:Se?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:_e=>{_e.preventDefault(),U({isOpen:true,x:_e.clientX,y:_e.clientY,type:"header",columnId:j.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:j.label,children:j.label}),j.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:Be===j.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:_e=>{_e.preventDefault(),_e.stopPropagation(),Oe(j.id),Pe(_e.clientX),B(j.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"}})})]},j.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(wn,{columns:u,onToggleColumn:d,theme:t}),jsx("button",{onClick:()=>Ae(!ye),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"})}),ye&&jsxs("div",{ref:Ze,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:j=>j.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:()=>Ae(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:sa},children:Xe.map(({task:j,level:te},Se)=>{let Qe=It(j.id),_e=le===j.id,G=_e&&Ee==="above",ce=_e&&Ee==="below",$e=_e&&Ee==="child",Mt={};return $e&&(Mt.backgroundColor=`${t.accent}15`,Mt.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":j.id,className:`flex items-center cursor-pointer group ${q===j.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:Qe?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:Qe?t.accentLight:$e?`${t.accent}15`:Se%2===0?t.bgPrimary:t.bgGrid,...Mt},onMouseEnter:()=>N(j.id),onMouseLeave:()=>N(null),onClick:rt=>{let fa=vo(e).map(Z=>Z.id),xe=navigator.platform.toUpperCase().indexOf("MAC")>=0?rt.metaKey:rt.ctrlKey;De(j.id,fa,xe,rt.shiftKey),s?.(j);},onDoubleClick:rt=>{rt.stopPropagation(),n?.(j);},onContextMenu:rt=>{rt.preventDefault(),U({isOpen:true,x:rt.clientX,y:rt.clientY,type:"task",task:j}),m?.(j,rt);},whileHover:{backgroundColor:Qe?t.accentLight:t.hoverBg},children:[G&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),ce&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),st.map((rt,xa)=>{let fa=xa===st.length-1,P=rt.id==="name";return jsx("div",{className:`px-4 flex items-center ${P?"justify-start":"justify-center"}`,style:{width:`${rt.width}px`,minWidth:`${rt.minWidth??(P?200:60)}px`,maxWidth:`${rt.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:fa?"none":`1px solid ${A===j.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:Ge(rt,j,P?te:0)},`${j.id}-${rt.id}`)})]},j.id)})}),jsx(yo,{isOpen:D.isOpen,x:D.x,y:D.y,items:D.type==="header"&&D.columnId?Je(D.columnId):D.type==="task"&&D.task?Ue(D.task):[],onClose:()=>U({...D,isOpen:false}),theme:t}),it&&ft&&q&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:ft.x+12,top:ft.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let j=Xe.find(te=>te.task.id===q)?.task;return j?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:j.name})}):null})()}),document.body)]})}function dc(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[n,m]=useState(e),[p,i]=useState(t),[u,d]=useState(null),[g,b]=useState(null),[C,T]=useState(null),[c,h]=useState(null),[v,l]=useState(0),[w,y]=useState(0),[S,k]=useState(null),[x,R]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:n,setGhostX:m,ghostWidth:p,setGhostWidth:i,connectionLine:u,setConnectionLine:d,hoveredTaskId:g,setHoveredTaskId:b,activeZone:C,setActiveZone:T,draggedSegmentIndex:c,setDraggedSegmentIndex:h,draggedSegmentStartX:v,setDraggedSegmentStartX:l,segmentDragOffsetX:w,setSegmentDragOffsetX:y,hoveredSegmentIndex:S,setHoveredSegmentIndex:k,isHovered:x,setIsHovered:R,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(_,V)=>{r("none"),d(null),b(null),m(_),i(V),y(0),h(null),l(0);}}}function Dn({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:n,templates:m,onClick:p,onDoubleClick:i,onContextMenu:u,onDateChange:d,onDependencyCreate:g,allTaskPositions:b=[],onDragMove:C,onHoverChange:T}){let c=dc(t,r),h=useRef(null),{dragMode:v,setDragMode:l,dragOffset:w,setDragOffset:y,ghostX:S,setGhostX:k,ghostWidth:x,setGhostWidth:R,connectionLine:A,setConnectionLine:N,hoveredTaskId:H,setHoveredTaskId:$,activeZone:_,setActiveZone:V,draggedSegmentIndex:ie,setDraggedSegmentIndex:Be,draggedSegmentStartX:Oe,setDraggedSegmentStartX:ze,segmentDragOffsetX:Pe,setSegmentDragOffsetX:L,hoveredSegmentIndex:B,setHoveredSegmentIndex:D,isHovered:U,setIsHovered:q,isDragging:O,isResizing:le,isConnecting:ve,resetDragState:Ee}=c,ue=32,We=8,Me=e.endDate&&e.endDate<new Date&&e.progress<100,Re=e.isCriticalPath,ft=o.name==="neutral"||o.today==="#1C1917",qe=e.status==="completed"||e.progress===100,it={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},re=e.isCriticalPath||Me?"#DC2626":e.color?e.color:e.priority&&it[e.priority]?it[e.priority]:o.taskBarPrimary,ye=(ae=>ae>=80?20:ae>=60?15:ae>=50?12:10)(r),Ae=r<50,Ze=r<40;useEffect(()=>{if(T)if(U&&!O&&!e.segments){let ae=a<100;T({task:e,x:t,y:a,width:r,height:ue,showBelow:ae});}else T(null);},[U,O,e,t,a,r,ue,T]);let kt=ae=>ae.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),De=()=>{let ae=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${ae} day${ae!==1?"s":""}`},It=ae=>Math.round(ae/s)*s,Ft=ae=>{let E=Math.round(ae/s),X=new Date(n);return X.setDate(X.getDate()+E),X},lt=(ae,E)=>{for(let X of b){if(X.id===e.id)continue;let de=5;if(ae>=X.x-de&&ae<=X.x+X.width+de&&E>=X.y-de&&E<=X.y+X.height+de)return X.id}return null},Xe=useCallback((ae,E,X)=>{ae.preventDefault(),ae.stopPropagation();let de=h.current?.ownerSVGElement;if(!de)return;let Le=de.createSVGPoint();Le.x=ae.clientX,Le.y=ae.clientY;let Ge=Le.matrixTransform(de.getScreenCTM()?.inverse()),Je=X!==void 0?X:t,Ue=E;if(!Ue){let st=Ge.x-Je;ae.shiftKey?(Ue="connect",N({x:t+r,y:a+ue/2})):ae.ctrlKey||ae.metaKey?Ue="move":ae.altKey?Ue=st<r/2?"resize-start":"resize-end":Ze?st<r/2?Ue="move":Ue="resize-end":Ae?st<=ye/2?Ue="resize-start":st>=r-ye/2?Ue="resize-end":Ue="move":st<=ye?Ue="resize-start":st>=r-ye?Ue="resize-end":Ue="move";}l(Ue),q(false),V(null),Ue==="move"?y(Ge.x-Je):Ue==="connect"?N({x:t+r,y:a+ue/2}):y(0),k(Je),R(r);},[t,r,a,ue]),Wt=useCallback(ae=>{if(v==="none")return;let E=h.current?.ownerSVGElement;if(!E)return;let X=E.createSVGPoint();X.x=ae.clientX,X.y=ae.clientY;let de=X.matrixTransform(E.getScreenCTM()?.inverse());if(v==="connect"){N({x:de.x,y:de.y});let Le=lt(de.x,de.y);$(Le);}else if(v==="move"){let Le=de.x-w,Ge=It(Le);k(Ge),R(r);let Je=Math.round((Ge-t)/s);if(C?.(e.id,Je,true),e.segments&&e.segments.length>0&&ie!==null){let Ue=Ge-Oe;L(Ue);}}else if(v==="resize-start"){let Le=de.x,Ge=It(Le),Je=t+r-Ge;Je>=s&&(k(Ge),R(Je));}else if(v==="resize-end"){let Le=de.x,Je=It(Le)-t;Je>=s&&R(Je);}},[v,t,r,s,w,e,It,ie,Oe,lt,$,N,k,R,L,C]),sa=useCallback(()=>{if(v!=="none"){if(v==="connect")H&&g&&g(e,H),N(null),$(null);else {let ae=e.endDate.getTime()-e.startDate.getTime(),E,X,de=true;if(v==="move"){if(E=Ft(S),X=new Date(E.getTime()+ae),e.segments&&e.segments.length>0&&ie!==null){let Le=Math.round(Pe/s),Ge=e.segments.map((mt,j)=>{if(j===ie){let te=new Date(mt.startDate),Se=new Date(mt.endDate);return te.setDate(te.getDate()+Le),Se.setDate(Se.getDate()+Le),{startDate:te,endDate:Se}}return mt}),Je=Ge.flatMap(mt=>[mt.startDate,mt.endDate]),Ue=new Date(Math.min(...Je.map(mt=>mt.getTime()))),st=new Date(Math.max(...Je.map(mt=>mt.getTime())));d?.({...e,segments:Ge},Ue,st),Ee(t,r);return}}else v==="resize-start"?(E=Ft(S),X=e.endDate,E>X&&(console.warn("Invalid date range: start date must be before or equal to end date"),de=false)):v==="resize-end"?(E=e.startDate,X=Ft(S+x),X<E&&(console.warn("Invalid date range: end date must be after or equal to start date"),de=false)):de=false;de&&E&&X&&(X.getTime()<E.getTime()?console.warn("Invalid date range: end date cannot be before start date"):d?.(e,E,X));}C?.(e.id,0,false),Ee(t,r);}},[v,S,x,e,d,H,g,t,r,s,Ft,Pe,ie,Ee,C]);useEffect(()=>{if(v==="none")return;let ae=X=>{Wt(X);},E=()=>{sa();};return window.addEventListener("mousemove",ae),window.addEventListener("mouseup",E),()=>{window.removeEventListener("mousemove",ae),window.removeEventListener("mouseup",E);}},[v,Wt,sa]);let oe=O&&!ve?S:t,J=O&&!ve?x:r,Ve=m.taskClass(e);return jsxs("g",{ref:h,onClick:()=>!O&&p?.(e),onDoubleClick:ae=>{O||(ae.stopPropagation(),i?.(e));},onContextMenu:ae=>{ae.preventDefault(),u?.(e,ae);},onMouseEnter:()=>!O&&q(true),onMouseLeave:()=>{O||(q(false),V(null));},children:[U&&!O&&!Ae&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:ye,height:ue,fill:_==="resize-start"?o.accent:"transparent",opacity:_==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>V("resize-start"),onMouseDown:ae=>Xe(ae,"resize-start")}),jsx("rect",{x:t+ye,y:a,width:r-ye*2,height:ue,fill:_==="move"?o.accent:"transparent",opacity:_==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>V("move"),onMouseDown:ae=>Xe(ae,"move")}),jsx("rect",{x:t+r-ye,y:a,width:ye,height:ue,fill:_==="resize-end"?o.accent:"transparent",opacity:_==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>V("resize-end"),onMouseDown:ae=>Xe(ae,"resize-end")})]}),U&&!O&&Ze&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:ue,fill:_==="move"?o.accent:"transparent",opacity:_==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>V("move"),onMouseDown:ae=>Xe(ae,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:ue,fill:_==="resize-end"?o.accent:"transparent",opacity:_==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>V("resize-end"),onMouseDown:ae=>Xe(ae,"resize-end")}),U&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+ue-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),O&&!ve&&!e.segments&&jsx(motion.rect,{x:S,y:a,width:x,height:ue,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:oe,y:a,width:J,height:ue,rx:We,fill:re,"data-task-class":Ve,initial:{opacity:0,scale:.95},animate:{opacity:O&&!ve?.15:e.parentId?.6:U?.9:.8,scale:U&&!O?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:ae=>Xe(ae),style:{cursor:O?ve?"crosshair":le?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:oe,y:a,width:J*(e.progress/100),height:ue,rx:We,fill:re,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((ae,E)=>{let X=(ae.startDate.getTime()-n.getTime())/864e5*s,Le=(ae.endDate.getTime()-n.getTime())/(1e3*60*60*24)*s-X+s,Ge=O&&v==="move"&&ie===E,Je=B===E,Ue=Ge?X+Pe:X;return jsxs("g",{onMouseEnter:()=>!O&&D(E),onMouseLeave:()=>!O&&D(null),children:[jsx(motion.rect,{x:Ue,y:a,width:Le,height:ue,rx:We,fill:re,initial:{opacity:0,scale:.95},animate:{opacity:Ge||e.parentId?.6:Je?.9:.8,scale:Je&&!O?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:st=>{st.stopPropagation(),Be(E),ze(X),Xe(st,void 0,X);},style:{cursor:O?ve?"crosshair":le?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:Ue,y:a,width:Le*(e.progress/100),height:ue,rx:We,fill:re,opacity:1,style:{pointerEvents:"none"}})]},`segment-${E}`)}),ft&&(Me||Re)&&!e.segments&&jsxs(Fragment,{children:[Re&&!Me&&jsx("rect",{x:oe,y:a,width:J,height:ue,rx:We,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),Me&&jsx("rect",{x:oe,y:a,width:J,height:ue,rx:We,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),J>60&&!e.segments&&(()=>{let ae=m.taskLabel(e),E=typeof ae=="string"?ae:e.name,X=E.length>Math.floor(J/8)?`${E.substring(0,Math.floor(J/8))}...`:E;return jsx("text",{x:oe+12,y:a+ue/2,dominantBaseline:"middle",fill:qe?"rgba(255, 255, 255, 0.6)":"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none",textDecoration:qe?"line-through":"none"},children:X})})(),J>100&&e.progress>0&&e.progress<100&&!O&&!e.segments&&jsxs("text",{x:oe+J-12,y:a+ue/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&&J>80&&!O&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:oe+J-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:oe+J-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(U||le)&&!ve&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{children:[jsx("rect",{x:oe-2,y:a,width:16,height:ue,fill:"transparent",style:{cursor:"ew-resize"},onMouseEnter:()=>V("resize-start"),onMouseLeave:()=>V(null),onMouseDown:ae=>{ae.stopPropagation(),Xe(ae,"resize-start");}}),jsx(motion.rect,{x:oe+4,y:a+8,width:3,height:ue-16,rx:1.5,fill:_==="resize-start"||v==="resize-start"?"#ffffff":"rgba(255,255,255,0.5)",style:{pointerEvents:"none"},initial:{opacity:0},animate:{opacity:1},transition:{duration:.15}})]}),jsxs("g",{children:[jsx("rect",{x:oe+J-14,y:a,width:16,height:ue,fill:"transparent",style:{cursor:"ew-resize"},onMouseEnter:()=>V("resize-end"),onMouseLeave:()=>V(null),onMouseDown:ae=>{ae.stopPropagation(),Xe(ae,"resize-end");}}),jsx(motion.rect,{x:oe+J-7,y:a+8,width:3,height:ue-16,rx:1.5,fill:_==="resize-end"||v==="resize-end"?"#ffffff":"rgba(255,255,255,0.5)",style:{pointerEvents:"none"},initial:{opacity:0},animate:{opacity:1},transition:{duration:.15}})]})]}),jsx(AnimatePresence,{children:U&&!O&&!e.segments&&jsxs(motion.g,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[jsx("circle",{cx:t+r+18,cy:a+ue/2,r:14,fill:"transparent",style:{cursor:"crosshair"},onMouseEnter:()=>V("connect"),onMouseLeave:()=>V(null),onMouseDown:ae=>{ae.stopPropagation(),Xe(ae,"connect");}}),jsx(motion.circle,{cx:t+r+18,cy:a+ue/2,r:7,fill:o.accent,stroke:"#FFFFFF",strokeWidth:2,style:{pointerEvents:"none"},initial:{scale:0},animate:{scale:_==="connect"?1.3:1},exit:{scale:0},transition:{duration:.15,type:"spring",stiffness:500,damping:30}}),jsx("text",{x:t+r+32,y:a+ue/2,dominantBaseline:"middle",fill:_==="connect"?o.accent:o.textTertiary,fontSize:_==="connect"?"11":"10",fontWeight:_==="connect"?"600":"400",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:"Link"})]})}),ve&&A&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+ue/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"})]}),(U||O)&&!ve&&!e.segments&&jsx(motion.rect,{x:oe-2,y:a-2,width:J+4,height:ue+4,rx:We+2,fill:"none",stroke:O?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:O?.6:.4,initial:{opacity:0},animate:{opacity:O?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),le&&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+x,y1:0,x2:S+x,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:U&&!O&&!e.segments&&!T&&(()=>{let X=a<100,de=X?a+ue+13:a-82-13,Le=X?`M ${oe+J/2-6} ${a+ue+3} L ${oe+J/2} ${a+ue+13} L ${oe+J/2+6} ${a+ue+3}`:`M ${oe+J/2-6} ${a-13} L ${oe+J/2} ${a-3} L ${oe+J/2+6} ${a-13}`,Ge=de+22,Je=de+40,Ue=de+55,st=de+70,mt=X?de+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:X?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:X?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:Le,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:oe+J/2-120,y:de,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:oe+J/2,y:Ge,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:oe+J/2-110,y:Je,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:oe+J/2-70,y:Je,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:kt(e.startDate)}),jsx("text",{x:oe+J/2-110,y:Ue,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:oe+J/2-70,y:Ue,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:kt(e.endDate)}),jsx("text",{x:oe+J/2+10,y:Je,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:oe+J/2+65,y:Je,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:De()}),jsx("text",{x:oe+J/2+10,y:Ue,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:oe+J/2+65,y:Ue,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:oe+J/2-110,y:st,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:oe+J/2-50,y:st,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(j=>j.name).join(", ").substring(0,30),e.assignees.map(j=>j.name).join(", ").length>30?"...":""]})]}),!X&&jsx("text",{x:oe+J/2,y:mt,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:Ze?"Left: move \u2022 Right: resize":Ae?"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 mc({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:n,showBelow:m}=e,p=82,i=13,u=m?o+n+i:o-p-i,d=m?`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,b=u+40,C=u+55,T=u+70,c=w=>w.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),h=()=>{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:m?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:m?-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:b,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y:b,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?c(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?c(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y:b,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y:b,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:h()}),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 Pn({x1:e,y1:t,x2:a,y2:r,routeY:o,fromIndex:s,toIndex:n,rowHeight:m,theme:p,onDelete:i,onHoverChange:u,lineStyle:d="curved"}){let[g,b]=useState(false),C=a-e,T=r-t,c=s!==void 0&&n!==void 0&&s===n,h=e+C/2,v=56,l=8,w=5,y=Math.abs(C)<80,S=s!==void 0?s*v+44+6:o??t+22,k;if(c||Math.abs(T)<5)if(d==="squared")k=`M ${e} ${t} L ${a} ${r}`;else {let V=Math.min(Math.abs(C)/3,30);k=`M ${e} ${t} C ${e+V} ${t}, ${a-V} ${r}, ${a} ${r}`;}else if(y){let V=(e+a)/2,ie=w;d==="squared"?k=`M ${e} ${t} L ${V} ${t} L ${V} ${r} L ${a} ${r}`:r>t?k=`M ${e} ${t} L ${V-ie} ${t} Q ${V} ${t} ${V} ${t+ie} L ${V} ${r-ie} Q ${V} ${r} ${V+ie} ${r} L ${a} ${r}`:k=`M ${e} ${t} L ${V-ie} ${t} Q ${V} ${t} ${V} ${t-ie} L ${V} ${r+ie} Q ${V} ${r} ${V+ie} ${r} L ${a} ${r}`;}else {let V=e+l,ie=a-l,Be=r<S;if(d==="squared")k=`M ${e} ${t} L ${V} ${t} L ${V} ${S} L ${ie} ${S} L ${ie} ${r} L ${a} ${r}`;else {let Oe=w,ze=`M ${e} ${t} L ${V-Oe} ${t} Q ${V} ${t} ${V} ${t+Oe} L ${V} ${S-Oe} Q ${V} ${S} ${V+Oe} ${S} L ${ie-Oe} ${S} `,Pe;Be?Pe=`Q ${ie} ${S} ${ie} ${S-Oe} L ${ie} ${r+Oe} Q ${ie} ${r} ${ie+Oe} ${r} L ${a} ${r}`:Pe=`Q ${ie} ${S} ${ie} ${S+Oe} L ${ie} ${r-Oe} Q ${ie} ${r} ${ie+Oe} ${r} L ${a} ${r}`,k=ze+Pe;}}let x=5,R=a-x,A=r-x*.5,N=a-x,H=r+x*.5,$=p.dependency;useEffect(()=>{u&&i&&u(g?{x1:e,y1:t,x2:a,y2:r,routeY:S,onDelete:i,lineStyle:d}:null);},[g,e,t,a,r,S,i,u,d]);let _=!i&&!u;return jsxs("g",{onMouseEnter:()=>!_&&b(true),onMouseLeave:()=>!_&&b(false),style:{pointerEvents:_?"none":"auto"},children:[!_&&jsx("path",{d:k,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx(motion.path,{d:k,fill:"none",stroke:$,strokeWidth:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:g&&u?0:g?1:.8,strokeWidth:g?2.5:2},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2},strokeWidth:{duration:.2}}}),jsx(motion.path,{d:`M ${a} ${r} L ${R} ${A} M ${a} ${r} L ${N} ${H}`,fill:"none",stroke:$,strokeWidth:2,strokeLinecap:"round",initial:{opacity:0,scale:.8},animate:{opacity:g&&u?0:g?1:.8,scale:g?1.1:1,strokeWidth:g?2.5:2},transition:{duration:.2}}),jsx(motion.circle,{cx:a,cy:r,r:3,fill:$,initial:{scale:0},animate:{scale:g&&u?0:g?1.3:1,opacity:g&&u?0:g?1:.8},transition:{scale:{delay:.3,duration:.15},opacity:{duration:.2}}}),g&&i&&!u&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:V=>{V.stopPropagation(),i();},style:{cursor:"pointer"},children:[jsx("circle",{cx:h,cy:(t+r)/2,r:10,fill:p.bgSecondary,stroke:p.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:h-4,y1:(t+r)/2-4,x2:h+4,y2:(t+r)/2+4,stroke:p.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:h+4,y1:(t+r)/2-4,x2:h-4,y2:(t+r)/2+4,stroke:p.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})}function An({task:e,x:t,y:a,theme:r,onClick:o}){let[s,n]=useState(false),m=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:m+4,fill:r.criticalPathLight,initial:{scale:0},animate:{scale:s?1.2:1},transition:{duration:.3}}),jsx(motion.rect,{x:t-m/2,y:a+16-m/2,width:m,height:m,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-(m+4)/2,y:a+16-(m+4)/2,width:m+4,height:m+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 he={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,m=new Set,p=i=>{if(!n.has(i)){n.add(i),m.add(i);let u=r.get(i)||[];for(let d of u){if(!n.has(d)&&p(d))return true;if(m.has(d))return true}}return m.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=he.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=he.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=he.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=he.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=he.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=he.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)=>he.flattenTasks(e).filter(r=>r.dependencies&&r.dependencies.includes(t)),getDependencyTasks:(e,t)=>{let a=he.findTaskById(e,t);return !a||!a.dependencies?[]:he.flattenTasks(e).filter(o=>a.dependencies.includes(o.id))},filterByStatus:(e,t)=>he.flattenTasks(e).filter(a=>a.status===t),filterByDateRange:(e,t,a)=>he.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=he.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=>he.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=he.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"]],m=s.map(p=>{let i=p.startDate&&p.endDate?he.calculateDuration(p.startDate,p.endDate):0;return [p.name,p.startDate?he.formatDate(p.startDate):"N/A",p.endDate?he.formatDate(p.endDate):"N/A",i>0?`${i} days`:"N/A",`${p.progress}%`,p.status||"N/A"]});r(o,{head:n,body:m,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=he.flattenTasks(e).map(p=>{let i=p.startDate&&p.endDate?he.calculateDuration(p.startDate,p.endDate):0;return {"Task ID":p.id,"Task Name":p.name,"Start Date":p.startDate?he.formatDate(p.startDate):"","End Date":p.endDate?he.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 m=a.utils.book_new();a.utils.book_append_sheet(m,s,"Gantt Tasks"),a.writeFile(m,t);},exportToMSProject:(e,t="Gantt Project",a="project.xml")=>{let r=he.flattenTasks(e),o=new Map;r.forEach((g,b)=>{o.set(g.id,b+1);});let s=g=>g.toISOString().replace("Z",""),n=he.getEarliestStartDate(e)||new Date,m=he.getLatestEndDate(e)||new Date,p=r.map((g,b)=>{let C=o.get(g.id),T=g.startDate&&g.endDate?he.calculateDuration(g.startDate,g.endDate):0,c=(g.dependencies||[]).filter(h=>o.has(h)).map(h=>`
113
113
  <PredecessorLink>
114
114
  <PredecessorUID>${o.get(h)}</PredecessorUID>
115
115
  <Type>1</Type>
@@ -201,7 +201,7 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
201
201
  <LastSaved>${s(new Date)}</LastSaved>
202
202
  <ScheduleFromStart>1</ScheduleFromStart>
203
203
  <StartDate>${s(n)}</StartDate>
204
- <FinishDate>${s(p)}</FinishDate>
204
+ <FinishDate>${s(m)}</FinishDate>
205
205
  <FYStartDate>1</FYStartDate>
206
206
  <CriticalSlackLimit>0</CriticalSlackLimit>
207
207
  <CurrencyDigits>2</CurrencyDigits>
@@ -337,11 +337,11 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
337
337
  </WeekDays>
338
338
  </Calendar>
339
339
  </Calendars>
340
- <Tasks>${m}
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=ge.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?ge.calculateDuration(i.startDate,i.endDate):0,d=0;if(i.dependencies&&i.dependencies.length>0)for(let b of i.dependencies){let C=t.find(T=>T.id===b);if(C){o(C);let T=r.get(b)?.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,p=i=>{if(n.has(i.id))return;let u=i.startDate&&i.endDate?ge.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){p(C);let T=n.get(C.id)?.ls||0;g=Math.min(g,T);}let b=g-u;n.set(i.id,{ls:b,lf:g});};a.forEach(p);let m=[];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&&m.push(i.id);}}return m},calculateSlack:(e,t)=>{let a=ge.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(ge.calculateCriticalPath(e).includes(t))return 0;let o=ge.getDependentTasks(e,t);if(o.length===0){let p=ge.getLatestEndDate(e);if(!p)return null;let m=ge.calculateDuration(a.endDate,p);return Math.max(0,m)}let s=o.filter(p=>p.startDate).map(p=>p.startDate.getTime()).sort((p,m)=>p-m)[0];if(!s)return null;let n=ge.calculateDuration(a.endDate,new Date(s));return Math.max(0,n)},isOnCriticalPath:(e,t)=>ge.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=ge.findTaskById(e,t);if(!r||!r.endDate)return e;let o=ge.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let n of o){if(!n.startDate||!n.endDate)continue;let p=ge.calculateDuration(n.startDate,n.endDate),m;a!==void 0?(m=new Date(n.startDate),m.setDate(m.getDate()+a)):(m=new Date(r.endDate),m.setDate(m.getDate()+1));let i=ge.calculateEndDate(m,p),u=d=>d.map(g=>g.id===n.id?{...g,startDate:m,endDate:i}:g.subtasks?{...g,subtasks:u(g.subtasks)}:g);s=u(s),s=ge.autoScheduleDependents(s,n.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,n,p)=>{if(a===0)return [];let m=[],i=o.getTime(),u=1e3*60*60*24,d=ge.findTaskById(e,t);if(!d||!d.endDate)return [];let g=(b,C,T=new Set)=>{if(T.has(b))return;T.add(b);let c=ge.getDependentTasks(e,b);for(let h of c){if(!h.startDate||!h.endDate)continue;let v=r.findIndex(N=>N.id===h.id);if(v===-1)continue;let l=h.startDate.getTime(),y=(h.endDate.getTime()-l)/u,w=(l-i)/u*s,x=w+C*s,R=Math.max(y*s,s),A=p+v*n+12;m.push({taskId:h.id,taskName:h.name,originalX:w,previewX:x,width:R,y:A,rowIndex:v,daysDelta:C,color:h.color}),g(h.id,C,T);}};return g(t,a),m},splitTask:(e,t,a,r=3)=>{let o=ge.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 p=new Date(o.endDate);p.setDate(p.getDate()+r);let m=[{startDate:new Date(o.startDate),endDate:s},{startDate:n,endDate:p}],i=u=>u.map(d=>d.id===o.id?{...d,endDate:p,segments:m}:d.subtasks?{...d,subtasks:i(d.subtasks)}:d);return i(e)}};function Ln({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:n,templates:p,dependencyLineStyle:m="curved",onTaskClick:i,onTaskDblClick:u,onTaskContextMenu:d,onTaskDateChange:g,onDependencyCreate:b,onDependencyDelete:C}){let[c,h]=useState([]),[v,l]=useState(null),[k,y]=useState(null),S=useCallback(L=>{l(L);},[]),w=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),x=r==="day"?60:r==="week"?20:8,R=w*x*n,A=L=>{let B=new Date(Date.UTC(L.getFullYear(),L.getMonth(),L.getDate())),D=B.getUTCDay()||7;B.setUTCDate(B.getUTCDate()+4-D);let W=new Date(Date.UTC(B.getUTCFullYear(),0,1));return Math.ceil(((B.getTime()-W.getTime())/864e5+1)/7)},N=L=>{let B=L.getDay();return B===0||B===6},U=useCallback(L=>{let B=Math.round(L/(x*n)),D=new Date(o);return D.setDate(D.getDate()+B),D},[o,x,n]),$=useCallback((L,B)=>{if(B.startDate&&B.endDate)return;let D=L.currentTarget.ownerSVGElement;if(!D)return;let W=D.createSVGPoint();W.x=L.clientX,W.y=L.clientY;let Y=W.matrixTransform(D.getScreenCTM()?.inverse()),O=U(Y.x),ie=new Date(O);ie.setDate(ie.getDate()+1),g?.(B,O,ie);},[U,g]),_=useMemo(()=>{let L=Y=>Y.map(O=>{if(O.subtasks&&O.subtasks.length>0){let ie=L(O.subtasks),ve=ie.filter(Ee=>Ee.startDate&&Ee.endDate);if(ve.length>0){let Ee=ve.map(Le=>Le.startDate.getTime()),fe=ve.map(Le=>Le.endDate.getTime()),We=new Date(Math.min(...Ee)),Re=new Date(Math.max(...fe));return {...O,subtasks:ie,startDate:We,endDate:Re}}return {...O,subtasks:ie}}return O}),B=(Y,O=[])=>{for(let ie of Y)O.push(ie),ie.subtasks&&ie.subtasks.length>0&&(ie.isExpanded===void 0||ie.isExpanded)&&B(ie.subtasks,O);return O},D=L(e);return B(D)},[e]),q=useCallback(L=>{if(!L.startDate||!L.endDate)return {x:0,width:0};let B=L.startDate.getTime(),D=L.endDate.getTime(),W=o.getTime(),Y=(B-W)/(1e3*60*60*24),O=(D-B)/(1e3*60*60*24),ie=Y*x*n,ve=Math.max(x*n,40),Ee=Math.max(O*x*n,ve);return {x:ie,width:Ee}},[o,x,n]),pe=useMemo(()=>_.filter(L=>L.startDate&&L.endDate).map(L=>{let{x:B,width:D}=q(L),Y=_.findIndex(O=>O.id===L.id)*a+12;return {id:L.id,x:B,y:Y,width:D,height:32}}),[_,q]),Te=useCallback((L,B,D)=>{if(!D||B===0){h([]);return}let W=ge.calculateCascadePreview(e,L,B,_,o,x*n,a,48);h(W);},[e,_,o,x,n,a,48]),Ze=useMemo(()=>{let L=[],B=new Date(o);for(;B<=s;){let Y=(B.getTime()-o.getTime())/864e5*x*n;if(r==="day")L.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 O=A(B);L.push({date:new Date(B),label:`Week ${O}`,x:Y}),B.setDate(B.getDate()+7);}else L.push({date:new Date(B),label:B.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:Y}),B.setMonth(B.getMonth()+1);}return L},[o,s,r,x,n]),Oe=useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*x*n,[o,x,n]),Be=Math.max(_.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(R,1e3),height:47,style:{display:"block"},children:[jsx("rect",{x:0,y:0,width:Math.max(R,1e3),height:48,fill:t.bgGrid}),Ze.map((L,B)=>jsxs("g",{children:[B>0&&jsx("line",{x1:L.x,y1:0,x2:L.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsx("text",{x:L.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:L.label})]},`header-${B}`)),Oe>=0&&Oe<=R&&jsx("circle",{cx:Oe,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxs("svg",{width:Math.max(R,1e3),height:Be,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(R,1e3),height:Be,fill:t.bgPrimary}),Ze.map((L,B)=>{let D=Ze[B+1]?.x||R,W=N(L.date);return jsxs("g",{children:[W&&jsx("rect",{x:L.x,y:0,width:D-L.x,height:_.length*a,fill:t.bgWeekend,opacity:1}),B>0&&jsx("line",{x1:L.x,y1:0,x2:L.x,y2:_.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},B)}),_.map((L,B)=>{let D=L.startDate&&L.endDate;return jsxs("g",{children:[jsx("rect",{x:0,y:B*a,width:R,height:a,fill:B%2===0?t.bgPrimary:t.bgGrid,opacity:1,style:{pointerEvents:"none"}},`row-${L.id}`),!D&&jsxs(Fragment,{children:[jsx("rect",{x:0,y:B*a,width:R,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:W=>$(W,L),onMouseEnter:W=>{W.currentTarget.setAttribute("fill",t.accentLight),W.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:W=>{W.currentTarget.setAttribute("fill","transparent"),W.currentTarget.setAttribute("opacity","1");}},`clickable-${L.id}`),jsx("text",{x:Oe>0?Oe:100,y:B*a+a/2,fill:t.textTertiary,fontSize:"12",fontFamily:"Inter, sans-serif",fontStyle:"italic",dominantBaseline:"middle",opacity:.4,style:{pointerEvents:"none",userSelect:"none"},children:"Click to set dates..."},`placeholder-${L.id}`)]})]},`row-group-${L.id}`)}),_.map((L,B)=>!L.dependencies||L.dependencies.length===0||!L.startDate||!L.endDate?null:L.dependencies.map(D=>{let W=_.find(ze=>ze.id===D);if(!W||!W.startDate||!W.endDate)return null;let Y=_.findIndex(ze=>ze.id===D),O=q(W),ie=q(L),ve=O.x+O.width,Ee=Y*a+28,fe=ie.x,We=B*a+28,Le=Math.min(Y,B)*a+50;return jsx(Pn,{x1:ve,y1:Ee,x2:fe,y2:We,routeY:Le,fromIndex:Y,toIndex:B,rowHeight:a,theme:t,lineStyle:m},`dep-${D}-${L.id}`)})),_.map((L,B)=>{if(!L.startDate||!L.endDate)return null;let{x:D,width:W}=q(L),Y=B*a+12,O=L.subtasks&&L.subtasks.length>0&&!L.isMilestone;return L.isMilestone?jsx(An,{task:L,x:D+W/2,y:Y+16,theme:t,onClick:i},L.id):O?jsxs("g",{onClick:()=>i?.(L),onContextMenu:ie=>{ie.preventDefault(),ie.stopPropagation(),d?.(L,ie);},style:{cursor:"default"},children:[jsx("rect",{x:D,y:Y,width:W,height:32,fill:t.primary,opacity:.25,rx:6}),jsx("line",{x1:D,y1:Y,x2:D+W,y2:Y,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:D,y1:Y,x2:D,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:D+W,y1:Y,x2:D+W,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:D,y1:Y+32,x2:D+W,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),W>60&&jsx("text",{x:D+12,y:Y+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:L.name})]},L.id):jsx(Dn,{task:L,x:D,y:Y,width:W,theme:t,dayWidth:x*n,startDate:o,templates:p,onClick:i,onDoubleClick:u,onContextMenu:d,onDateChange:g,onDependencyCreate:b,allTaskPositions:pe,onDragMove:Te,onHoverChange:S},L.id)}),_.map((L,B)=>!L.dependencies||L.dependencies.length===0||!L.startDate||!L.endDate?null:L.dependencies.map(D=>{let W=_.find(le=>le.id===D);if(!W||!W.startDate||!W.endDate)return null;let Y=_.findIndex(le=>le.id===D),O=q(W),ie=q(L),ve=O.x+O.width,Ee=Y*a+28,fe=ie.x,We=B*a+28,Le=Math.min(Y,B)*a+50,ze=Y===B,yt=8,nt;if(ze){let le=ve+20,we=fe-15;nt=`M ${le} ${Ee} L ${we} ${We}`;}else {let le=ve+yt+10,we=fe-yt-10;nt=`M ${le} ${Le} L ${we} ${Le}`;}if(k&&k.x1===ve&&k.y1===Ee&&k.x2===fe&&k.y2===We)return null;let ne=le=>{let we=le.currentTarget.ownerSVGElement;if(!we)return;let $e=we.getBoundingClientRect(),et=le.clientX-$e.left,vt=le.clientY-$e.top;y({x1:ve,y1:Ee,x2:fe,y2:We,routeY:Le,onDelete:()=>C?.(L.id,D),lineStyle:m,mouseX:et,mouseY:vt});};return jsx("path",{d:nt,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:ne,onMouseMove:ne},`dep-hover-${D}-${L.id}`)})),c.map(L=>jsxs("g",{style:{pointerEvents:"none"},children:[jsx("rect",{x:L.previewX,y:L.y-48,width:L.width,height:32,rx:8,fill:L.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(L.daysDelta)>0&&jsx("text",{x:L.previewX+L.width/2,y:L.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:L.daysDelta>0?`+${L.daysDelta}d`:`${L.daysDelta}d`})]},`cascade-preview-${L.taskId}`)),k&&(()=>{let{x1:L,y1:B,x2:D,y2:W,routeY:Y,onDelete:O,lineStyle:ie,mouseX:ve,mouseY:Ee}=k,fe=D-L,We=W-B,Re=L+fe/2,Le=Math.abs(We)<5,ze=Y??Math.min(B,W)+22,yt=8,nt=5,z;if(Le)if(ie==="squared")z=`M ${L} ${B} L ${D} ${W}`;else {let ee=Math.min(Math.abs(fe)/3,30);z=`M ${L} ${B} C ${L+ee} ${B}, ${D-ee} ${W}, ${D} ${W}`;}else {let ee=W>B,te=L+yt,it=D-yt,ae=nt;ie==="squared"?z=`M ${L} ${B} L ${te} ${B} L ${te} ${ze} L ${it} ${ze} L ${it} ${W} L ${D} ${W}`:ee?z=`M ${L} ${B} L ${te-ae} ${B} Q ${te} ${B} ${te} ${B+ae} L ${te} ${ze-ae} Q ${te} ${ze} ${te+ae} ${ze} L ${it-ae} ${ze} Q ${it} ${ze} ${it} ${ze+ae} L ${it} ${W-ae} Q ${it} ${W} ${it+ae} ${W} L ${D} ${W}`:z=`M ${L} ${B} L ${te-ae} ${B} Q ${te} ${B} ${te} ${B-ae} L ${te} ${ze+ae} Q ${te} ${ze} ${te+ae} ${ze} L ${it-ae} ${ze} Q ${it} ${ze} ${it} ${ze-ae} L ${it} ${W+ae} Q ${it} ${W} ${it+ae} ${W} L ${D} ${W}`;}let ne=5,le=D-ne,we=W-ne*.5,$e=D-ne,et=W+ne*.5,vt=t.dependency,Pe="#f87171",Vt="rgba(248, 113, 113, 0.15)",ft=Re,st=Le?(B+W)/2:ze,mt=false;ve!==void 0&&Ee!==void 0&&!Le?(ft=Math.max(L+yt+20,Math.min(D-yt-20,ve)),st=ze):ve!==void 0&&Le&&(ft=Math.max(L+20,Math.min(D-20,ve)),st=(B+W)/2);let Lt=Math.floor(st/a);if(Lt>=0&&Lt<_.length){let ee=_[Lt];if(ee&&ee.startDate&&ee.endDate){let te=q(ee),it=Lt*a+12,ae=it+32,E=te.x-15,X=te.x+te.width+50;ft>=E&&ft<=X&&st>=it-5&&st<=ae+5&&(mt=true);}}return jsxs("g",{onMouseLeave:()=>y(null),onMouseMove:ee=>{let te=ee.currentTarget.ownerSVGElement||ee.currentTarget;if(!te)return;let it=te.getBoundingClientRect(),ae=ee.clientX-it.left,E=ee.clientY-it.top;y(X=>X?{...X,mouseX:ae,mouseY:E}:null);},children:[jsx("path",{d:z,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx("path",{d:z,fill:"none",stroke:vt,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsx("path",{d:z,fill:"none",stroke:vt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("path",{d:`M ${D} ${W} L ${le} ${we} M ${D} ${W} L ${$e} ${et}`,fill:"none",stroke:vt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("circle",{cx:D,cy:W,r:4,fill:vt,opacity:.9,style:{pointerEvents:"none"}}),!mt&&jsxs(motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:ee=>{ee.stopPropagation(),y(null),O();},style:{cursor:"pointer"},children:[jsx("circle",{cx:ft,cy:st,r:9,fill:Vt,stroke:Pe,strokeWidth:1.5}),jsx("line",{x1:ft-3,y1:st-3,x2:ft+3,y2:st+3,stroke:Pe,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:ft+3,y1:st-3,x2:ft-3,y2:st+3,stroke:Pe,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),Oe>=0&&Oe<=R&&jsx("line",{x1:Oe,y1:0,x2:Oe,y2:Be,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),v&&jsx(pc,{tooltipData:v,theme:t})]})]})}var u0=['Move "Task Name" to next Monday','Extend "Task Name" by 3 days','Rename "Old Name" to "New Name"','Set "Task Name" progress to 50%','Link "Task A" to "Task B"','Create a new task called "New Task"','Delete "Task Name"','Assign John to "Task Name"'],fc=()=>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"})]}),g0=()=>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"})}),f0=()=>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"})}),h0=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M5 12h14"})}),b0=()=>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:p,onDependencyDelete:m}){let[i,u]=useState(false),[d,g]=useState(false),[b,C]=useState([]),[T,c]=useState(""),[h,v]=useState(false),[l,k]=useState(true),y=useRef(null),S=useRef(null),w=useRef(null),{enabled:x=true,placeholder:R='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:A="bottom-right",onCommand:N,suggestions:U=u0,maxHistory:$=50,persistHistory:_}=a,q=_?.storageKey||"gantt-ai-history",pe=_?.maxMessages??5;useEffect(()=>{if(_?.enabled)try{let B=localStorage.getItem(q);if(B){let W=JSON.parse(B).map(Y=>({...Y,timestamp:new Date(Y.timestamp)}));C(W.slice(-pe));}}catch(B){console.warn("[GanttAIAssistant] Failed to load persisted history:",B);}},[_?.enabled,q,pe]),useEffect(()=>{if(_?.enabled&&b.length>0)try{let B=b.filter(D=>!D.isLoading).slice(-pe);localStorage.setItem(q,JSON.stringify(B));}catch(B){console.warn("[GanttAIAssistant] Failed to persist history:",B);}},[b,_?.enabled,q,pe]),useEffect(()=>{S.current&&S.current.scrollIntoView({behavior:"smooth"});},[b]),useEffect(()=>{i&&!d&&y.current&&setTimeout(()=>y.current?.focus(),100);},[i,d]);let Te=useCallback(B=>{if(B.success)switch(B.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":B.taskId&&B.updates&&o?.(B.taskId,B.updates);break;case "create_task":B.newTask&&s?.(B.newTask);break;case "delete_task":B.taskId&&n?.(B.taskId);break;case "link_tasks":B.dependencyFrom&&B.dependencyTo&&p?.(B.dependencyFrom,B.dependencyTo);break;case "unlink_tasks":B.taskId&&B.dependencyFrom&&m?.(B.taskId,B.dependencyFrom);break}},[o,s,n,p,m]),Ze=useCallback(async B=>{if(!B.trim()||h)return;let D={id:`user-${Date.now()}`,role:"user",content:B,timestamp:new Date};C(Y=>[...Y.slice(-($-1)),D]),c(""),k(false),v(true);let W={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};C(Y=>[...Y,W]);try{if(N){let Y=await N(B,e);C(O=>{let ie=O.filter(Ee=>!Ee.isLoading),ve={id:`assistant-${Date.now()}`,role:"assistant",content:Y.message,timestamp:new Date,command:Y};return [...ie,ve]}),Te(Y);}else C(Y=>[...Y.filter(ie=>!ie.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(Y){C(O=>[...O.filter(ve=>!ve.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${Y instanceof Error?Y.message:"Unknown error"}`,timestamp:new Date}]);}finally{v(false);}},[h,$,N,e,Te]),Oe=B=>{B.preventDefault(),Ze(T);},Be=B=>{c(B),y.current?.focus();};if(useEffect(()=>{let B=D=>{(D.metaKey||D.ctrlKey)&&D.key==="k"&&(D.preventDefault(),u(W=>!W),i||g(false)),D.key==="Escape"&&i&&u(false);};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[i]),useEffect(()=>{if(!i)return;let B=W=>{let Y=W.target;w.current&&!w.current.contains(Y)&&u(false);},D=setTimeout(()=>{document.addEventListener("mousedown",B);},100);return ()=>{clearTimeout(D),document.removeEventListener("mousedown",B);}},[i]),!x)return null;let L={"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(ht,{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 ${L[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(fc,{}),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:w,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:d?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${L[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(fc,{}),jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>g(B=>!B),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(h0,{})}),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(f0,{})})]})]}),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:[b.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:U.slice(0,4).map((B,D)=>jsx("button",{onClick:()=>Be(B),className:"text-xs px-3 py-1.5 rounded-full transition-colors",style:{background:t.bgSecondary,color:t.textSecondary,border:`1px solid ${t.border}`},children:B.length>30?B.slice(0,30)+"...":B},D))})]}),b.map(B=>jsx(motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${B.role==="user"?"justify-end":"justify-start"}`,children:jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${B.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:B.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:B.role==="user"?"white":t.textPrimary},children:[B.isLoading?jsx(b0,{}):jsx("p",{className:"text-sm whitespace-pre-wrap",children:B.content}),B.command&&jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:B.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:B.command.success?"#10B981":"#EF4444"},children:[B.command.success?"\u2713":"\u2717",jsx("span",{className:"capitalize",children:B.command.type.replace(/_/g," ")})]})]})},B.id)),jsx("div",{ref:S})]}),jsxs("form",{onSubmit:Oe,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:y,type:"text",value:T,onChange:B=>c(B.target.value),placeholder:R,disabled:h,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsx("button",{type:"submit",disabled:!T.trim()||h,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(g0,{})})]}),jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function hc(e,t=50){let[a,r]=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 b=[...d.past,d.present];return b.length>t&&b.shift(),{past:b,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]}});},[]),p=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}});},[]),m=useCallback(()=>{r(i=>({past:[],present:i.present,future:[]}));},[]);return {state:a.present,setState:s,undo:n,redo:p,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:m}}function bc({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){useEffect(()=>{if(!o)return;let s=n=>{let p=navigator.platform.toUpperCase().indexOf("MAC")>=0,m=p?n.metaKey:n.ctrlKey;if(m&&n.key==="z"&&!n.shiftKey&&a){n.preventDefault(),e();return}if(r){if(!p&&m&&n.key==="y"){n.preventDefault(),t();return}if(p&&m&&n.shiftKey&&n.key==="z"){n.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var k0={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${ge.formatDate(e.startDate)} - ${ge.formatDate(e.endDate)}`);let a=ge.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=>ge.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function yc(e){return {...k0,...e}}var E0=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},kc=forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:n="week",rowDensity:p="comfortable",showThemeSelector:m=true,showExportButton:i=true,availableUsers:u=[],templates:d,enableAutoCriticalPath:g=true,persistExpandedState:b,aiAssistant:C,locale:T="en",customTranslations:c,showCreateTaskButton:h=false,createTaskLabel:v,onCreateTask:l,taskFilter:k,onTaskFilterChange:y,onThemeChange:S,onTaskClick:w,onTaskDblClick:x,onTaskContextMenu:R,onTaskUpdate:A,onProgressChange:N,onTaskEdit:U,onTaskAddSubtask:$,onTaskMarkIncomplete:_,onTaskSetInProgress:q,onDependencyCreate:pe,onDependencyDelete:Te,onBeforeTaskAdd:Ze,onAfterTaskAdd:Oe,onBeforeTaskUpdate:Be,onAfterTaskUpdate:L,onBeforeTaskDelete:B,onAfterTaskDelete:D}=a,Y=useContext(yn)?.theme,[O,ie]=useState(Y||s||"dark"),[ve,Ee]=useState(n),[fe,We]=useState(p),[Re,Le]=useState(1),[ze,yt]=useState("all"),nt=k??ze,z=y??yt,[ne,le]=useState(0),[we,$e]=useState(false),[et,vt]=useState(null),[Pe,Vt]=useState({isOpen:false,x:0,y:0,task:null}),[ft,st]=useState(null),[mt,Lt]=useState(null);useEffect(()=>{Y&&Y!==O&&ie(Y);},[Y]),useEffect(()=>{s&&s!==O&&ie(s);},[s]);let va=useCallback(F=>{ie(F),S?.(F);},[S]),{state:ee,setState:te,undo:it,redo:ae,canUndo:E,canRedo:X,clearHistory:be}=hc(t,50),Ae=useCallback(()=>b?typeof b=="string"?b:"gantt-expanded-tasks":null,[b]),Ge=useRef(new Map),Ye=useRef(false);if(!Ye.current&&b){Ye.current=true;let F=typeof b=="string"?b:"gantt-expanded-tasks";try{let I=localStorage.getItem(F);if(I){let j=JSON.parse(I);Array.isArray(j)&&(Ge.current=new Map(j));}}catch(I){console.warn("[GanttBoard] Error loading expanded state from localStorage:",I);}}let Ue=useCallback(()=>{let F=Ae();if(F)try{let I=Array.from(Ge.current.entries());localStorage.setItem(F,JSON.stringify(I));}catch(I){console.warn("[GanttBoard] Error saving expanded state to localStorage:",I);}},[Ae]);useEffect(()=>{let F=I=>I.map(j=>{let oe=Ge.current.get(j.id),ue=oe!==void 0?{...j,isExpanded:oe}:j;return ue.subtasks?.length?{...ue,subtasks:F(ue.subtasks)}:ue});Ge.current.size>0?te(F(t)):te(t);},[t,te]);let ot=useRef(t),pt=useRef(true);useEffect(()=>{if(pt.current){pt.current=false,ot.current=ee;return}if(!r)return;let F=JSON.stringify(ot.current),I=JSON.stringify(ee);F!==I&&(ot.current=ee,r(ee));},[ee,r]);let V=useMemo(()=>ei(T,c),[T,c]),re=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}],[]),[Se,qe]=useState(()=>re(V));useEffect(()=>{qe(F=>F.map(I=>({...I,label:V.columns[I.id==="name"?"taskName":I.id]||I.label})));},[V]);let _e=useMemo(()=>Se.filter(I=>I.visible).reduce((I,j)=>I+j.width,0),[Se]),G=useRef(Se.filter(F=>F.visible).map(F=>F.id).join(","));useEffect(()=>{let F=Se.filter(oe=>oe.visible),I=F.map(oe=>oe.id).join(","),j=G.current;if(I!==j){let oe=F.some(Ne=>Ne.id!=="name"),ue=j.includes(",");oe?!ue&&oe&&vt(null):vt(null),G.current=I;}},[Se]);let de=60,Ie=.6,At=useMemo(()=>{let I=_e+de,j=typeof window<"u"?window.innerWidth*Ie:800,oe=Math.max(I,j);return et!==null?Math.max(200,Math.min(et,oe)):Math.max(200,I)},[et,_e]),tt=useRef(null),xa=useRef(null),ga=useRef(null),P=useMemo(()=>Ud(O),[O]),ye=useMemo(()=>({theme:P,themeName:O}),[P,O]),Q=useMemo(()=>yc(d),[d]),Me=useMemo(()=>{if(!g)return ee;let F=ge.calculateCriticalPath(ee),I=j=>j.map(oe=>({...oe,isCriticalPath:F.includes(oe.id),subtasks:oe.subtasks?I(oe.subtasks):void 0}));return I(ee)},[ee,g]),lt=useMemo(()=>{if(nt==="all")return Me;let F=I=>{let j=[];for(let oe of I){let ue=oe.subtasks?.length?F(oe.subtasks):void 0,Ne=false;switch(nt){case "incomplete":Ne=oe.progress<100;break;case "in_progress":Ne=oe.progress>0&&oe.progress<100;break;case "completed":Ne=oe.progress===100;break}(Ne||ue&&ue.length>0)&&j.push({...oe,subtasks:ue});}return j};return F(Me)},[Me,nt]),se=E0(fe);bc({undo:it,redo:ae,canUndo:E,canRedo:X,enabled:true}),useImperativeHandle(o,()=>({getTask:F=>ge.findTaskById(ee,F),addTask:(F,I)=>{te(j=>{if(!I)return [...j,{...F,level:0}];let oe=ue=>ue.map(Ne=>Ne.id===I?{...Ne,subtasks:[...Ne.subtasks||[],{...F,parentId:I,level:(Ne.level||0)+1}],isExpanded:true}:Ne.subtasks?{...Ne,subtasks:oe(Ne.subtasks)}:Ne);return oe(j)});},updateTask:(F,I)=>{te(j=>{let oe=ue=>ue.map(Ne=>Ne.id===F?{...Ne,...I}:Ne.subtasks?{...Ne,subtasks:oe(Ne.subtasks)}:Ne);return oe(j)});},deleteTask:F=>{te(I=>{let j=oe=>oe.filter(ue=>ue.id===F?false:(ue.subtasks&&(ue.subtasks=j(ue.subtasks)),true));return j(I)});},deleteTasks:F=>{te(I=>ci(I,F));},duplicateTask:F=>{te(I=>mi(I,[F]));},splitTask:(F,I,j=3)=>{te(oe=>ge.splitTask(oe,F,I,j));},calculateEndDate:ge.calculateEndDate,calculateDuration:ge.calculateDuration,validateDependency:(F,I)=>!ge.validateDependencies(ee,F,I),getAllTasks:()=>ge.flattenTasks(ee),getTasksByStatus:F=>ge.flattenTasks(ee).filter(I=>I.status===F),getTasksByParent:F=>F?ge.findTaskById(ee,F)?.subtasks||[]:ee.filter(j=>!j.parentId),getCriticalPath:()=>ge.flattenTasks(ee).filter(F=>F.isCriticalPath),indentTask:F=>{te(I=>ii(I,[F]));},outdentTask:F=>{te(I=>li(I,[F]));},moveTask:(F,I)=>{te(j=>di(j,[F],I));},createSubtask:async F=>{let{tasks:I,newTask:j}=gi(ee,F);if(Ze){let oe=Ze({...j,parentId:F});if((oe instanceof Promise?await oe:oe)===false)return}te(I),Oe&&Oe({...j,parentId:F});},scrollToTask:F=>{let j=ge.flattenTasks(ee).findIndex(oe=>oe.id===F);if(j!==-1&&tt.current){let oe=j*se;tt.current.scrollTo({top:oe,behavior:"smooth"}),xa.current&&xa.current.scrollTo({top:oe,behavior:"smooth"});}},highlightTask:(F,I=2e3)=>{},expandTask:F=>{te(I=>{let j=oe=>oe.map(ue=>ue.id===F?{...ue,isExpanded:true}:ue.subtasks?{...ue,subtasks:j(ue.subtasks)}:ue);return j(I)});},collapseTask:F=>{te(I=>{let j=oe=>oe.map(ue=>ue.id===F?{...ue,isExpanded:false}:ue.subtasks?{...ue,subtasks:j(ue.subtasks)}:ue);return j(I)});},expandAll:()=>{te(F=>{let I=j=>j.map(oe=>({...oe,isExpanded:true,subtasks:oe.subtasks?I(oe.subtasks):void 0}));return I(F)});},collapseAll:()=>{te(F=>{let I=j=>j.map(oe=>({...oe,isExpanded:false,subtasks:oe.subtasks?I(oe.subtasks):void 0}));return I(F)});},undo:it,redo:ae,canUndo:()=>E,canRedo:()=>X,clearHistory:be,exportToPNG:async()=>{if(!ga.current||!tt.current||!xa.current)throw new Error("Gantt container not found");let F=ga.current,I=tt.current.querySelector(".gantt-grid-scroll"),j=xa.current,oe=I?.scrollTop||0,ue=j.scrollTop,Ne=F.style.overflow,Ct=F.style.height;try{let ea=I?.querySelector(".gantt-taskgrid-content"),ka=j.querySelector("svg"),wa=ea?.scrollHeight||I?.scrollHeight||600,Aa=ka?.getBoundingClientRect().height||j.scrollHeight,Br=(F.querySelector('[class*="h-12"]')?.offsetHeight||48)+Math.max(wa,Aa)+20;I&&(I.scrollTop=0),j.scrollTop=0,F.style.overflow="visible",F.style.height=`${Br}px`,await new Promise(kr=>setTimeout(kr,100));let xr=await xc(F,{backgroundColor:P.bgPrimary,scale:2,logging:!1,useCORS:!0,ignoreElements:kr=>{let ro=window.getComputedStyle(kr),Rr=parseInt(ro.zIndex,10);return !isNaN(Rr)&&Rr>=50||ro.position==="fixed"}});return new Promise((kr,ro)=>{xr.toBlob(Rr=>{Rr?kr(Rr):ro(new Error("Failed to create blob from canvas"));},"image/png");})}finally{F.style.overflow=Ne,F.style.height=Ct,I&&(I.scrollTop=oe),j.scrollTop=ue;}},exportToPDF:async F=>{await ge.exportToPDF(ee,F);},exportToExcel:async F=>{await ge.exportToExcel(ee,F);},exportToJSON:()=>ge.exportToJSON(ee),exportToCSV:()=>ge.exportToCSV(ee),importFromJSON:F=>{let I=ge.importFromJSON(F);te(I);},getTasks:()=>ee,refresh:()=>{te(F=>[...F]);},clearAll:()=>{te([]);}}),[ee,it,ae,E,X,be,P,se]);let He=useCallback(F=>{qe(I=>I.map(j=>j.id===F?{...j,visible:!j.visible}:j));},[]),St=useCallback((F,I)=>{qe(j=>j.map(oe=>{if(oe.id!==F)return oe;let ue=oe.minWidth??100,Ne=oe.maxWidth??800,Ct=Math.max(ue,Math.min(Ne,I));return {...oe,width:Ct}}));},[]),Fe=useCallback(F=>{te(I=>{let j=ui(I,F),oe=ue=>{for(let Ne of ue){if(Ne.id===F){Ge.current.set(F,Ne.isExpanded??true);return}Ne.subtasks?.length&&oe(Ne.subtasks);}};return oe(j),Ue(),j}),a.onTaskToggleExpand?.(F);},[a,Ue]),Bt=useCallback((F,I)=>{if(Be&&Be(F,I)===false)return;let oe=ge.findTaskById(ee,F)?.progress,ue=Ct=>Ct.map(ea=>ea.id===F?{...ea,...I}:ea.subtasks?{...ea,subtasks:ue(ea.subtasks)}:ea);te(ue(ee));let Ne=ge.findTaskById(ue(ee),F);Ne&&(A?.(Ne),L?.(Ne),I.progress!==void 0&&oe!==void 0&&I.progress!==oe&&N?.(F,oe,I.progress));},[ee,A,Be,L,N]),ut=useCallback(F=>{F.length!==0&&(te(I=>ii(I,F)),a.onTaskIndent?.(F[0]));},[a]),fa=useCallback(F=>{F.length!==0&&(te(I=>li(I,F)),a.onTaskOutdent?.(F[0]));},[a]),Wt=useCallback((F,I,j)=>{te(oe=>oc(oe,F,I,j)),a.onTaskReparent?.(F,I,j);},[a]),Ke=useCallback((F,I)=>{F.length!==0&&(te(j=>di(j,F,I)),a.onTaskMove?.(F[0],I));},[a]),Et=useCallback(async F=>{let I=[];for(let j of F)B&&await Promise.resolve(B(j))===false||I.push(j);I.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(I):(te(j=>ci(j,I)),I.forEach(j=>a.onTaskDelete?.(j))),D&&I.forEach(j=>D(j)));},[a,B,D]),da=useCallback(F=>{te(I=>mi(I,F)),F.forEach(I=>a.onTaskDuplicate?.(I));},[a]),yr=useCallback((F,I)=>{te(j=>{let{tasks:oe,newTask:ue}=rc(j,F,I);return Ze&&Ze(ue)===false?j:(a.onTaskCreate?.(ue.parentId,ue.position||0),Oe?.(ue),oe)});},[a,Ze,Oe]),Um=useCallback((F,I)=>{te(j=>pi(j,F,I)),a.onTaskRename?.(F,I);},[a]),Qn=useCallback(F=>{te(I=>{let{tasks:j}=gi(I,F);return a.onTaskCreate?.(F,0),j});},[a]),Hm=useCallback((F,I,j)=>{let oe=F.startDate?Math.round((I.getTime()-F.startDate.getTime())/864e5):0,ue=ea=>ea.map(ka=>ka.id===F.id?{...ka,startDate:I,endDate:j,...F.segments&&{segments:F.segments}}:ka.subtasks?{...ka,subtasks:ue(ka.subtasks)}:ka),Ne=ue(ee);Ne=ge.autoScheduleDependents(Ne,F.id,oe),te(Ne);let Ct={...F,startDate:I,endDate:j};A?.(Ct);},[ee,A]),Wm=useCallback((F,I)=>{R?.(F,I),Vt({isOpen:true,x:I.clientX,y:I.clientY,task:F});},[R]),Gm=useCallback((F,I)=>{let j=ge.splitTask(ee,F.id,I);te(j),Vt({isOpen:false,x:0,y:0,task:null});},[ee]),hl=useCallback(F=>{let I=ge.findTaskById(ee,F.id)||F;x?.(I),U||st(I);},[ee,x,U]),bl=useCallback((F,I,j)=>{let oe=new Map,ue=wa=>{wa.forEach(Aa=>{Aa.dependencies&&oe.set(Aa.id,Aa.dependencies),Aa.subtasks&&ue(Aa.subtasks);});};ue(j);let Ne=oe.get(I)||[];oe.set(I,[...Ne,F]);let Ct=new Set,ea=new Set,ka=wa=>{if(!Ct.has(wa)){Ct.add(wa),ea.add(wa);let Aa=oe.get(wa)||[];for(let vr of Aa){if(!Ct.has(vr)&&ka(vr))return true;if(ea.has(vr))return true}}return ea.delete(wa),false};return ka(I)},[]),yl=useCallback((F,I)=>{if(bl(F.id,I,ee)){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=he.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?he.calculateDuration(i.startDate,i.endDate):0,d=0;if(i.dependencies&&i.dependencies.length>0)for(let b of i.dependencies){let C=t.find(T=>T.id===b);if(C){o(C);let T=r.get(b)?.ef||0;d=Math.max(d,T);}}let g=d+u;r.set(i.id,{es:d,ef:g});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(i=>i.ef)),n=new Map,m=i=>{if(n.has(i.id))return;let u=i.startDate&&i.endDate?he.calculateDuration(i.startDate,i.endDate):0,d=t.filter(C=>C.dependencies&&C.dependencies.includes(i.id)),g=s;if(d.length>0)for(let C of d){m(C);let T=n.get(C.id)?.ls||0;g=Math.min(g,T);}let b=g-u;n.set(i.id,{ls:b,lf:g});};a.forEach(m);let p=[];for(let i of a){let u=r.get(i.id),d=n.get(i.id);if(u&&d){let g=d.ls-u.es;Math.abs(g)<.01&&p.push(i.id);}}return p},calculateSlack:(e,t)=>{let a=he.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(he.calculateCriticalPath(e).includes(t))return 0;let o=he.getDependentTasks(e,t);if(o.length===0){let m=he.getLatestEndDate(e);if(!m)return null;let p=he.calculateDuration(a.endDate,m);return Math.max(0,p)}let s=o.filter(m=>m.startDate).map(m=>m.startDate.getTime()).sort((m,p)=>m-p)[0];if(!s)return null;let n=he.calculateDuration(a.endDate,new Date(s));return Math.max(0,n)},isOnCriticalPath:(e,t)=>he.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=he.findTaskById(e,t);if(!r||!r.endDate)return e;let o=he.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let n of o){if(!n.startDate||!n.endDate)continue;let m=he.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=he.calculateEndDate(p,m),u=d=>d.map(g=>g.id===n.id?{...g,startDate:p,endDate:i}:g.subtasks?{...g,subtasks:u(g.subtasks)}:g);s=u(s),s=he.autoScheduleDependents(s,n.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,n,m)=>{if(a===0)return [];let p=[],i=o.getTime(),u=1e3*60*60*24,d=he.findTaskById(e,t);if(!d||!d.endDate)return [];let g=(b,C,T=new Set)=>{if(T.has(b))return;T.add(b);let c=he.getDependentTasks(e,b);for(let h of c){if(!h.startDate||!h.endDate)continue;let v=r.findIndex(N=>N.id===h.id);if(v===-1)continue;let l=h.startDate.getTime(),y=(h.endDate.getTime()-l)/u,k=(l-i)/u*s,x=k+C*s,R=Math.max(y*s,s),A=m+v*n+12;p.push({taskId:h.id,taskName:h.name,originalX:k,previewX:x,width:R,y:A,rowIndex:v,daysDelta:C,color:h.color}),g(h.id,C,T);}};return g(t,a),p},splitTask:(e,t,a,r=3)=>{let o=he.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let n=new Date(a);n.setDate(n.getDate()+r);let m=new Date(o.endDate);m.setDate(m.getDate()+r);let p=[{startDate:new Date(o.startDate),endDate:s},{startDate:n,endDate:m}],i=u=>u.map(d=>d.id===o.id?{...d,endDate:m,segments:p}:d.subtasks?{...d,subtasks:i(d.subtasks)}:d);return i(e)}};function Ln({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:n,templates:m,dependencyLineStyle:p="curved",onTaskClick:i,onTaskDblClick:u,onTaskContextMenu:d,onTaskDateChange:g,onDependencyCreate:b,onDependencyDelete:C}){let[c,h]=useState([]),[v,l]=useState(null),[w,y]=useState(null),S=useCallback(L=>{l(L);},[]),k=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),x=r==="day"?60:r==="week"?20:8,R=k*x*n,A=L=>{let B=new Date(Date.UTC(L.getFullYear(),L.getMonth(),L.getDate())),D=B.getUTCDay()||7;B.setUTCDate(B.getUTCDate()+4-D);let U=new Date(Date.UTC(B.getUTCFullYear(),0,1));return Math.ceil(((B.getTime()-U.getTime())/864e5+1)/7)},N=L=>{let B=L.getDay();return B===0||B===6},H=useCallback(L=>{let B=Math.round(L/(x*n)),D=new Date(o);return D.setDate(D.getDate()+B),D},[o,x,n]),$=useCallback((L,B)=>{if(B.startDate&&B.endDate)return;let D=L.currentTarget.ownerSVGElement;if(!D)return;let U=D.createSVGPoint();U.x=L.clientX,U.y=L.clientY;let q=U.matrixTransform(D.getScreenCTM()?.inverse()),O=H(q.x),le=new Date(O);le.setDate(le.getDate()+1),g?.(B,O,le);},[H,g]),_=useMemo(()=>{let L=q=>q.map(O=>{if(O.subtasks&&O.subtasks.length>0){let le=L(O.subtasks),ve=le.filter(Ee=>Ee.startDate&&Ee.endDate);if(ve.length>0){let Ee=ve.map(Re=>Re.startDate.getTime()),ue=ve.map(Re=>Re.endDate.getTime()),We=new Date(Math.min(...Ee)),Me=new Date(Math.max(...ue));return {...O,subtasks:le,startDate:We,endDate:Me}}return {...O,subtasks:le}}return O}),B=(q,O=[])=>{for(let le of q)O.push(le),le.subtasks&&le.subtasks.length>0&&(le.isExpanded===void 0||le.isExpanded)&&B(le.subtasks,O);return O},D=L(e);return B(D)},[e]),V=useCallback(L=>{if(!L.startDate||!L.endDate)return {x:0,width:0};let B=L.startDate.getTime(),D=L.endDate.getTime(),U=o.getTime(),q=(B-U)/(1e3*60*60*24),O=(D-B)/(1e3*60*60*24),le=q*x*n,ve=Math.max(x*n,40),Ee=Math.max(O*x*n,ve);return {x:le,width:Ee}},[o,x,n]),ie=useMemo(()=>_.filter(L=>L.startDate&&L.endDate).map(L=>{let{x:B,width:D}=V(L),q=_.findIndex(O=>O.id===L.id)*a+12;return {id:L.id,x:B,y:q,width:D,height:32}}),[_,V]),Be=useCallback((L,B,D)=>{if(!D||B===0){h([]);return}let U=he.calculateCascadePreview(e,L,B,_,o,x*n,a,48);h(U);},[e,_,o,x,n,a,48]),Oe=useMemo(()=>{let L=[],B=new Date(o);for(;B<=s;){let q=(B.getTime()-o.getTime())/864e5*x*n;if(r==="day")L.push({date:new Date(B),label:B.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:q}),B.setDate(B.getDate()+1);else if(r==="week"){let O=A(B);L.push({date:new Date(B),label:`Week ${O}`,x:q}),B.setDate(B.getDate()+7);}else L.push({date:new Date(B),label:B.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:q}),B.setMonth(B.getMonth()+1);}return L},[o,s,r,x,n]),ze=useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*x*n,[o,x,n]),Pe=Math.max(_.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(R,1e3),height:47,style:{display:"block"},children:[jsx("rect",{x:0,y:0,width:Math.max(R,1e3),height:48,fill:t.bgGrid}),Oe.map((L,B)=>jsxs("g",{children:[B>0&&jsx("line",{x1:L.x,y1:0,x2:L.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsx("text",{x:L.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:L.label})]},`header-${B}`)),ze>=0&&ze<=R&&jsx("circle",{cx:ze,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxs("svg",{width:Math.max(R,1e3),height:Pe,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(R,1e3),height:Pe,fill:t.bgPrimary}),Oe.map((L,B)=>{let D=Oe[B+1]?.x||R,U=N(L.date);return jsxs("g",{children:[U&&jsx("rect",{x:L.x,y:0,width:D-L.x,height:_.length*a,fill:t.bgWeekend,opacity:1}),B>0&&jsx("line",{x1:L.x,y1:0,x2:L.x,y2:_.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},B)}),_.map((L,B)=>{let D=L.startDate&&L.endDate;return jsxs("g",{children:[jsx("rect",{x:0,y:B*a,width:R,height:a,fill:B%2===0?t.bgPrimary:t.bgGrid,opacity:1,style:{pointerEvents:"none"}},`row-${L.id}`),!D&&jsxs(Fragment,{children:[jsx("rect",{x:0,y:B*a,width:R,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:U=>$(U,L),onMouseEnter:U=>{U.currentTarget.setAttribute("fill",t.accentLight),U.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:U=>{U.currentTarget.setAttribute("fill","transparent"),U.currentTarget.setAttribute("opacity","1");}},`clickable-${L.id}`),jsx("text",{x:ze>0?ze: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-${L.id}`)]})]},`row-group-${L.id}`)}),_.map((L,B)=>!L.dependencies||L.dependencies.length===0||!L.startDate||!L.endDate?null:L.dependencies.map(D=>{let U=_.find(Re=>Re.id===D);if(!U||!U.startDate||!U.endDate)return null;let q=_.findIndex(Re=>Re.id===D),O=V(U),le=V(L),ve=O.x+O.width,Ee=q*a+28,ue=le.x,We=B*a+28,Me=q*a+50;return jsx(Pn,{x1:ve,y1:Ee,x2:ue,y2:We,routeY:Me,fromIndex:q,toIndex:B,rowHeight:a,theme:t,lineStyle:p},`dep-${D}-${L.id}`)})),_.map((L,B)=>{if(!L.startDate||!L.endDate)return null;let{x:D,width:U}=V(L),q=B*a+12,O=L.subtasks&&L.subtasks.length>0&&!L.isMilestone;return L.isMilestone?jsx(An,{task:L,x:D+U/2,y:q+16,theme:t,onClick:i},L.id):O?jsxs("g",{onClick:()=>i?.(L),onContextMenu:le=>{le.preventDefault(),le.stopPropagation(),d?.(L,le);},style:{cursor:"default"},children:[jsx("rect",{x:D,y:q,width:U,height:32,fill:t.primary,opacity:.25,rx:6}),jsx("line",{x1:D,y1:q,x2:D+U,y2:q,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:D,y1:q,x2:D,y2:q+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:D+U,y1:q,x2:D+U,y2:q+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:D,y1:q+32,x2:D+U,y2:q+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),U>60&&jsx("text",{x:D+12,y:q+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:L.name})]},L.id):jsx(Dn,{task:L,x:D,y:q,width:U,theme:t,dayWidth:x*n,startDate:o,templates:m,onClick:i,onDoubleClick:u,onContextMenu:d,onDateChange:g,onDependencyCreate:b,allTaskPositions:ie,onDragMove:Be,onHoverChange:S},L.id)}),_.map((L,B)=>!L.dependencies||L.dependencies.length===0||!L.startDate||!L.endDate?null:L.dependencies.map(D=>{let U=_.find(ye=>ye.id===D);if(!U||!U.startDate||!U.endDate)return null;let q=_.findIndex(ye=>ye.id===D),O=V(U),le=V(L),ve=O.x+O.width,Ee=q*a+28,ue=le.x,We=B*a+28,Me=q*a+50,Re=q===B,ft=8,qe,it=ue-ve,z=Math.abs(it)<80;if(Re){let ye=ve+20,Ae=ue-15;qe=`M ${ye} ${Ee} L ${Ae} ${We}`;}else if(z){let ye=(ve+ue)/2;qe=`M ${ye} ${Ee+10} L ${ye} ${We-10}`;}else {let ye=ve+ft+10,Ae=ue-ft-10;qe=`M ${ye} ${Me} L ${Ae} ${Me}`;}if(w&&w.x1===ve&&w.y1===Ee&&w.x2===ue&&w.y2===We)return null;let fe=ye=>{let Ae=ye.currentTarget.ownerSVGElement;if(!Ae)return;let Ze=Ae.getBoundingClientRect(),kt=ye.clientX-Ze.left,De=ye.clientY-Ze.top;y({x1:ve,y1:Ee,x2:ue,y2:We,routeY:Me,onDelete:()=>C?.(L.id,D),lineStyle:p,mouseX:kt,mouseY:De});};return jsx("path",{d:qe,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:fe,onMouseMove:fe},`dep-hover-${D}-${L.id}`)})),c.map(L=>jsxs("g",{style:{pointerEvents:"none"},children:[jsx("rect",{x:L.previewX,y:L.y-48,width:L.width,height:32,rx:8,fill:L.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(L.daysDelta)>0&&jsx("text",{x:L.previewX+L.width/2,y:L.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:L.daysDelta>0?`+${L.daysDelta}d`:`${L.daysDelta}d`})]},`cascade-preview-${L.taskId}`)),w&&(()=>{let{x1:L,y1:B,x2:D,y2:U,routeY:q,onDelete:O,lineStyle:le,mouseX:ve,mouseY:Ee}=w,ue=D-L,We=U-B,Me=L+ue/2,Re=Math.abs(We)<5,ft=Math.abs(ue)<80,qe=q??B+22,it=8,z=5,re;if(Re)if(le==="squared")re=`M ${L} ${B} L ${D} ${U}`;else {let J=Math.min(Math.abs(ue)/3,30);re=`M ${L} ${B} C ${L+J} ${B}, ${D-J} ${U}, ${D} ${U}`;}else if(ft){let J=(L+D)/2,Ve=z,ae=U>B;le==="squared"?re=`M ${L} ${B} L ${J} ${B} L ${J} ${U} L ${D} ${U}`:ae?re=`M ${L} ${B} L ${J-Ve} ${B} Q ${J} ${B} ${J} ${B+Ve} L ${J} ${U-Ve} Q ${J} ${U} ${J+Ve} ${U} L ${D} ${U}`:re=`M ${L} ${B} L ${J-Ve} ${B} Q ${J} ${B} ${J} ${B-Ve} L ${J} ${U+Ve} Q ${J} ${U} ${J+Ve} ${U} L ${D} ${U}`;}else {let J=L+it,Ve=D-it,ae=z,E=U<qe;if(le==="squared")re=`M ${L} ${B} L ${J} ${B} L ${J} ${qe} L ${Ve} ${qe} L ${Ve} ${U} L ${D} ${U}`;else {let X=`M ${L} ${B} L ${J-ae} ${B} Q ${J} ${B} ${J} ${B+ae} L ${J} ${qe-ae} Q ${J} ${qe} ${J+ae} ${qe} L ${Ve-ae} ${qe} `,de;E?de=`Q ${Ve} ${qe} ${Ve} ${qe-ae} L ${Ve} ${U+ae} Q ${Ve} ${U} ${Ve+ae} ${U} L ${D} ${U}`:de=`Q ${Ve} ${qe} ${Ve} ${qe+ae} L ${Ve} ${U-ae} Q ${Ve} ${U} ${Ve+ae} ${U} L ${D} ${U}`,re=X+de;}}let fe=5,ye=D-fe,Ae=U-fe*.5,Ze=D-fe,kt=U+fe*.5,De=t.dependency,It="#f87171",Ft="rgba(248, 113, 113, 0.15)",lt=Me,Xe=Re?(B+U)/2:qe,Wt=false;ve!==void 0&&Ee!==void 0&&!Re?(lt=Math.max(L+it+20,Math.min(D-it-20,ve)),Xe=qe):ve!==void 0&&Re&&(lt=Math.max(L+20,Math.min(D-20,ve)),Xe=(B+U)/2);let sa=Math.floor(Xe/a);if(sa>=0&&sa<_.length){let J=_[sa];if(J&&J.startDate&&J.endDate){let Ve=V(J),ae=sa*a+12,E=ae+32,X=Ve.x-15,de=Ve.x+Ve.width+50;lt>=X&&lt<=de&&Xe>=ae-5&&Xe<=E+5&&(Wt=true);}}return jsxs("g",{onMouseLeave:()=>y(null),onMouseMove:J=>{let Ve=J.currentTarget.ownerSVGElement||J.currentTarget;if(!Ve)return;let ae=Ve.getBoundingClientRect(),E=J.clientX-ae.left,X=J.clientY-ae.top;y(de=>de?{...de,mouseX:E,mouseY:X}:null);},children:[jsx("path",{d:re,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx("path",{d:re,fill:"none",stroke:De,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsx("path",{d:re,fill:"none",stroke:De,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("path",{d:`M ${D} ${U} L ${ye} ${Ae} M ${D} ${U} L ${Ze} ${kt}`,fill:"none",stroke:De,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("circle",{cx:D,cy:U,r:4,fill:De,opacity:.9,style:{pointerEvents:"none"}}),!Wt&&jsxs(motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:J=>{J.stopPropagation(),y(null),O();},style:{cursor:"pointer"},children:[jsx("circle",{cx:lt,cy:Xe,r:9,fill:Ft,stroke:It,strokeWidth:1.5}),jsx("line",{x1:lt-3,y1:Xe-3,x2:lt+3,y2:Xe+3,stroke:It,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:lt+3,y1:Xe-3,x2:lt-3,y2:Xe+3,stroke:It,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),ze>=0&&ze<=R&&jsx("line",{x1:ze,y1:0,x2:ze,y2:Pe,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),v&&jsx(mc,{tooltipData:v,theme:t})]})]})}var u0=['Move "Task Name" to next Monday','Extend "Task Name" by 3 days','Rename "Old Name" to "New Name"','Set "Task Name" progress to 50%','Link "Task A" to "Task B"','Create a new task called "New Task"','Delete "Task Name"','Assign John to "Task Name"'],fc=()=>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"})]}),g0=()=>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"})}),f0=()=>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"})}),h0=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M5 12h14"})}),b0=()=>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:m,onDependencyDelete:p}){let[i,u]=useState(false),[d,g]=useState(false),[b,C]=useState([]),[T,c]=useState(""),[h,v]=useState(false),[l,w]=useState(true),y=useRef(null),S=useRef(null),k=useRef(null),{enabled:x=true,placeholder:R='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:A="bottom-right",onCommand:N,suggestions:H=u0,maxHistory:$=50,persistHistory:_}=a,V=_?.storageKey||"gantt-ai-history",ie=_?.maxMessages??5;useEffect(()=>{if(_?.enabled)try{let B=localStorage.getItem(V);if(B){let U=JSON.parse(B).map(q=>({...q,timestamp:new Date(q.timestamp)}));C(U.slice(-ie));}}catch(B){console.warn("[GanttAIAssistant] Failed to load persisted history:",B);}},[_?.enabled,V,ie]),useEffect(()=>{if(_?.enabled&&b.length>0)try{let B=b.filter(D=>!D.isLoading).slice(-ie);localStorage.setItem(V,JSON.stringify(B));}catch(B){console.warn("[GanttAIAssistant] Failed to persist history:",B);}},[b,_?.enabled,V,ie]),useEffect(()=>{S.current&&S.current.scrollIntoView({behavior:"smooth"});},[b]),useEffect(()=>{i&&!d&&y.current&&setTimeout(()=>y.current?.focus(),100);},[i,d]);let Be=useCallback(B=>{if(B.success)switch(B.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":B.taskId&&B.updates&&o?.(B.taskId,B.updates);break;case "create_task":B.newTask&&s?.(B.newTask);break;case "delete_task":B.taskId&&n?.(B.taskId);break;case "link_tasks":B.dependencyFrom&&B.dependencyTo&&m?.(B.dependencyFrom,B.dependencyTo);break;case "unlink_tasks":B.taskId&&B.dependencyFrom&&p?.(B.taskId,B.dependencyFrom);break}},[o,s,n,m,p]),Oe=useCallback(async B=>{if(!B.trim()||h)return;let D={id:`user-${Date.now()}`,role:"user",content:B,timestamp:new Date};C(q=>[...q.slice(-($-1)),D]),c(""),w(false),v(true);let U={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};C(q=>[...q,U]);try{if(N){let q=await N(B,e);C(O=>{let le=O.filter(Ee=>!Ee.isLoading),ve={id:`assistant-${Date.now()}`,role:"assistant",content:q.message,timestamp:new Date,command:q};return [...le,ve]}),Be(q);}else C(q=>[...q.filter(le=>!le.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(q){C(O=>[...O.filter(ve=>!ve.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${q instanceof Error?q.message:"Unknown error"}`,timestamp:new Date}]);}finally{v(false);}},[h,$,N,e,Be]),ze=B=>{B.preventDefault(),Oe(T);},Pe=B=>{c(B),y.current?.focus();};if(useEffect(()=>{let B=D=>{(D.metaKey||D.ctrlKey)&&D.key==="k"&&(D.preventDefault(),u(U=>!U),i||g(false)),D.key==="Escape"&&i&&u(false);};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[i]),useEffect(()=>{if(!i)return;let B=U=>{let q=U.target;k.current&&!k.current.contains(q)&&u(false);},D=setTimeout(()=>{document.addEventListener("mousedown",B);},100);return ()=>{clearTimeout(D),document.removeEventListener("mousedown",B);}},[i]),!x)return null;let L={"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(ht,{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 ${L[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(fc,{}),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:k,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 ${L[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(fc,{}),jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>g(B=>!B),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(h0,{})}),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(f0,{})})]})]}),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:[b.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((B,D)=>jsx("button",{onClick:()=>Pe(B),className:"text-xs px-3 py-1.5 rounded-full transition-colors",style:{background:t.bgSecondary,color:t.textSecondary,border:`1px solid ${t.border}`},children:B.length>30?B.slice(0,30)+"...":B},D))})]}),b.map(B=>jsx(motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${B.role==="user"?"justify-end":"justify-start"}`,children:jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${B.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:B.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:B.role==="user"?"white":t.textPrimary},children:[B.isLoading?jsx(b0,{}):jsx("p",{className:"text-sm whitespace-pre-wrap",children:B.content}),B.command&&jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:B.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:B.command.success?"#10B981":"#EF4444"},children:[B.command.success?"\u2713":"\u2717",jsx("span",{className:"capitalize",children:B.command.type.replace(/_/g," ")})]})]})},B.id)),jsx("div",{ref:S})]}),jsxs("form",{onSubmit:ze,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:y,type:"text",value:T,onChange:B=>c(B.target.value),placeholder:R,disabled:h,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsx("button",{type:"submit",disabled:!T.trim()||h,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(g0,{})})]}),jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function hc(e,t=50){let[a,r]=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 b=[...d.past,d.present];return b.length>t&&b.shift(),{past:b,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]}});},[]),m=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:m,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function bc({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){useEffect(()=>{if(!o)return;let s=n=>{let m=navigator.platform.toUpperCase().indexOf("MAC")>=0,p=m?n.metaKey:n.ctrlKey;if(p&&n.key==="z"&&!n.shiftKey&&a){n.preventDefault(),e();return}if(r){if(!m&&p&&n.key==="y"){n.preventDefault(),t();return}if(m&&p&&n.shiftKey&&n.key==="z"){n.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var k0={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${he.formatDate(e.startDate)} - ${he.formatDate(e.endDate)}`);let a=he.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=>he.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function yc(e){return {...k0,...e}}var E0=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},kc=forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:n="week",rowDensity:m="comfortable",showThemeSelector:p=true,showExportButton:i=true,availableUsers:u=[],templates:d,enableAutoCriticalPath:g=true,persistExpandedState:b,aiAssistant:C,locale:T="en",customTranslations:c,showCreateTaskButton:h=false,createTaskLabel:v,onCreateTask:l,taskFilter:w,onTaskFilterChange:y,onThemeChange:S,onTaskClick:k,onTaskDblClick:x,onTaskContextMenu:R,onTaskUpdate:A,onProgressChange:N,onTaskEdit:H,onTaskAddSubtask:$,onTaskMarkIncomplete:_,onTaskSetInProgress:V,onDependencyCreate:ie,onDependencyDelete:Be,onBeforeTaskAdd:Oe,onAfterTaskAdd:ze,onBeforeTaskUpdate:Pe,onAfterTaskUpdate:L,onBeforeTaskDelete:B,onAfterTaskDelete:D}=a,q=useContext(yn)?.theme,[O,le]=useState(q||s||"dark"),[ve,Ee]=useState(n),[ue,We]=useState(m),[Me,Re]=useState(1),[ft,qe]=useState("all"),it=w??ft,z=y??qe,[re,fe]=useState(0),[ye,Ae]=useState(false),[Ze,kt]=useState(null),[De,It]=useState({isOpen:false,x:0,y:0,task:null}),[Ft,lt]=useState(null),[Xe,Wt]=useState(null);useEffect(()=>{q&&q!==O&&le(q);},[q]),useEffect(()=>{s&&s!==O&&le(s);},[s]);let sa=useCallback(F=>{le(F),S?.(F);},[S]),{state:oe,setState:J,undo:Ve,redo:ae,canUndo:E,canRedo:X,clearHistory:de}=hc(t,50),Le=useCallback(()=>b?typeof b=="string"?b:"gantt-expanded-tasks":null,[b]),Ge=useRef(new Map),Je=useRef(false);if(!Je.current&&b){Je.current=true;let F=typeof b=="string"?b:"gantt-expanded-tasks";try{let I=localStorage.getItem(F);if(I){let K=JSON.parse(I);Array.isArray(K)&&(Ge.current=new Map(K));}}catch(I){console.warn("[GanttBoard] Error loading expanded state from localStorage:",I);}}let Ue=useCallback(()=>{let F=Le();if(F)try{let I=Array.from(Ge.current.entries());localStorage.setItem(F,JSON.stringify(I));}catch(I){console.warn("[GanttBoard] Error saving expanded state to localStorage:",I);}},[Le]);useEffect(()=>{let F=I=>I.map(K=>{let ne=Ge.current.get(K.id),ge=ne!==void 0?{...K,isExpanded:ne}:K;return ge.subtasks?.length?{...ge,subtasks:F(ge.subtasks)}:ge});Ge.current.size>0?J(F(t)):J(t);},[t,J]);let st=useRef(t),mt=useRef(true);useEffect(()=>{if(mt.current){mt.current=false,st.current=oe;return}if(!r)return;let F=JSON.stringify(st.current),I=JSON.stringify(oe);F!==I&&(st.current=oe,r(oe));},[oe,r]);let j=useMemo(()=>ei(T,c),[T,c]),te=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}],[]),[Se,Qe]=useState(()=>te(j));useEffect(()=>{Qe(F=>F.map(I=>({...I,label:j.columns[I.id==="name"?"taskName":I.id]||I.label})));},[j]);let _e=useMemo(()=>Se.filter(I=>I.visible).reduce((I,K)=>I+K.width,0),[Se]),G=useRef(Se.filter(F=>F.visible).map(F=>F.id).join(","));useEffect(()=>{let F=Se.filter(ne=>ne.visible),I=F.map(ne=>ne.id).join(","),K=G.current;if(I!==K){let ne=F.some(Te=>Te.id!=="name"),ge=K.includes(",");ne?!ge&&ne&&kt(null):kt(null),G.current=I;}},[Se]);let ce=60,$e=.6,Mt=useMemo(()=>{let I=_e+ce,K=typeof window<"u"?window.innerWidth*$e:800,ne=Math.max(I,K);return Ze!==null?Math.max(200,Math.min(Ze,ne)):Math.max(200,I)},[Ze,_e]),rt=useRef(null),xa=useRef(null),fa=useRef(null),P=useMemo(()=>Ud(O),[O]),xe=useMemo(()=>({theme:P,themeName:O}),[P,O]),Z=useMemo(()=>yc(d),[d]),Fe=useMemo(()=>{if(!g)return oe;let F=he.calculateCriticalPath(oe),I=K=>K.map(ne=>({...ne,isCriticalPath:F.includes(ne.id),subtasks:ne.subtasks?I(ne.subtasks):void 0}));return I(oe)},[oe,g]),dt=useMemo(()=>{if(it==="all")return Fe;let F=I=>{let K=[];for(let ne of I){let ge=ne.subtasks?.length?F(ne.subtasks):void 0,Te=false;switch(it){case "incomplete":Te=ne.progress<100;break;case "in_progress":Te=ne.progress>0&&ne.progress<100;break;case "completed":Te=ne.progress===100;break}(Te||ge&&ge.length>0)&&K.push({...ne,subtasks:ge});}return K};return F(Fe)},[Fe,it]),se=E0(ue);bc({undo:Ve,redo:ae,canUndo:E,canRedo:X,enabled:true}),useImperativeHandle(o,()=>({getTask:F=>he.findTaskById(oe,F),addTask:(F,I)=>{J(K=>{if(!I)return [...K,{...F,level:0}];let ne=ge=>ge.map(Te=>Te.id===I?{...Te,subtasks:[...Te.subtasks||[],{...F,parentId:I,level:(Te.level||0)+1}],isExpanded:true}:Te.subtasks?{...Te,subtasks:ne(Te.subtasks)}:Te);return ne(K)});},updateTask:(F,I)=>{J(K=>{let ne=ge=>ge.map(Te=>Te.id===F?{...Te,...I}:Te.subtasks?{...Te,subtasks:ne(Te.subtasks)}:Te);return ne(K)});},deleteTask:F=>{J(I=>{let K=ne=>ne.filter(ge=>ge.id===F?false:(ge.subtasks&&(ge.subtasks=K(ge.subtasks)),true));return K(I)});},deleteTasks:F=>{J(I=>ci(I,F));},duplicateTask:F=>{J(I=>pi(I,[F]));},splitTask:(F,I,K=3)=>{J(ne=>he.splitTask(ne,F,I,K));},calculateEndDate:he.calculateEndDate,calculateDuration:he.calculateDuration,validateDependency:(F,I)=>!he.validateDependencies(oe,F,I),getAllTasks:()=>he.flattenTasks(oe),getTasksByStatus:F=>he.flattenTasks(oe).filter(I=>I.status===F),getTasksByParent:F=>F?he.findTaskById(oe,F)?.subtasks||[]:oe.filter(K=>!K.parentId),getCriticalPath:()=>he.flattenTasks(oe).filter(F=>F.isCriticalPath),indentTask:F=>{J(I=>ii(I,[F]));},outdentTask:F=>{J(I=>li(I,[F]));},moveTask:(F,I)=>{J(K=>di(K,[F],I));},createSubtask:async F=>{let{tasks:I,newTask:K}=gi(oe,F);if(Oe){let ne=Oe({...K,parentId:F});if((ne instanceof Promise?await ne:ne)===false)return}J(I),ze&&ze({...K,parentId:F});},scrollToTask:F=>{let K=he.flattenTasks(oe).findIndex(ne=>ne.id===F);if(K!==-1&&rt.current){let ne=K*se;rt.current.scrollTo({top:ne,behavior:"smooth"}),xa.current&&xa.current.scrollTo({top:ne,behavior:"smooth"});}},highlightTask:(F,I=2e3)=>{},expandTask:F=>{J(I=>{let K=ne=>ne.map(ge=>ge.id===F?{...ge,isExpanded:true}:ge.subtasks?{...ge,subtasks:K(ge.subtasks)}:ge);return K(I)});},collapseTask:F=>{J(I=>{let K=ne=>ne.map(ge=>ge.id===F?{...ge,isExpanded:false}:ge.subtasks?{...ge,subtasks:K(ge.subtasks)}:ge);return K(I)});},expandAll:()=>{J(F=>{let I=K=>K.map(ne=>({...ne,isExpanded:true,subtasks:ne.subtasks?I(ne.subtasks):void 0}));return I(F)});},collapseAll:()=>{J(F=>{let I=K=>K.map(ne=>({...ne,isExpanded:false,subtasks:ne.subtasks?I(ne.subtasks):void 0}));return I(F)});},undo:Ve,redo:ae,canUndo:()=>E,canRedo:()=>X,clearHistory:de,exportToPNG:async()=>{if(!fa.current||!rt.current||!xa.current)throw new Error("Gantt container not found");let F=fa.current,I=rt.current.querySelector(".gantt-grid-scroll"),K=xa.current,ne=I?.scrollTop||0,ge=K.scrollTop,Te=F.style.overflow,wt=F.style.height;try{let ea=I?.querySelector(".gantt-taskgrid-content"),ka=K.querySelector("svg"),wa=ea?.scrollHeight||I?.scrollHeight||600,Aa=ka?.getBoundingClientRect().height||K.scrollHeight,Br=(F.querySelector('[class*="h-12"]')?.offsetHeight||48)+Math.max(wa,Aa)+20;I&&(I.scrollTop=0),K.scrollTop=0,F.style.overflow="visible",F.style.height=`${Br}px`,await new Promise(kr=>setTimeout(kr,100));let xr=await xc(F,{backgroundColor:P.bgPrimary,scale:2,logging:!1,useCORS:!0,ignoreElements:kr=>{let ro=window.getComputedStyle(kr),Rr=parseInt(ro.zIndex,10);return !isNaN(Rr)&&Rr>=50||ro.position==="fixed"}});return new Promise((kr,ro)=>{xr.toBlob(Rr=>{Rr?kr(Rr):ro(new Error("Failed to create blob from canvas"));},"image/png");})}finally{F.style.overflow=Te,F.style.height=wt,I&&(I.scrollTop=ne),K.scrollTop=ge;}},exportToPDF:async F=>{await he.exportToPDF(oe,F);},exportToExcel:async F=>{await he.exportToExcel(oe,F);},exportToJSON:()=>he.exportToJSON(oe),exportToCSV:()=>he.exportToCSV(oe),importFromJSON:F=>{let I=he.importFromJSON(F);J(I);},getTasks:()=>oe,refresh:()=>{J(F=>[...F]);},clearAll:()=>{J([]);}}),[oe,Ve,ae,E,X,de,P,se]);let He=useCallback(F=>{Qe(I=>I.map(K=>K.id===F?{...K,visible:!K.visible}:K));},[]),Dt=useCallback((F,I)=>{Qe(K=>K.map(ne=>{if(ne.id!==F)return ne;let ge=ne.minWidth??100,Te=ne.maxWidth??800,wt=Math.max(ge,Math.min(Te,I));return {...ne,width:wt}}));},[]),Ie=useCallback(F=>{J(I=>{let K=ui(I,F),ne=ge=>{for(let Te of ge){if(Te.id===F){Ge.current.set(F,Te.isExpanded??true);return}Te.subtasks?.length&&ne(Te.subtasks);}};return ne(K),Ue(),K}),a.onTaskToggleExpand?.(F);},[a,Ue]),Bt=useCallback((F,I)=>{if(Pe&&Pe(F,I)===false)return;let ne=he.findTaskById(oe,F)?.progress,ge=wt=>wt.map(ea=>ea.id===F?{...ea,...I}:ea.subtasks?{...ea,subtasks:ge(ea.subtasks)}:ea);J(ge(oe));let Te=he.findTaskById(ge(oe),F);Te&&(A?.(Te),L?.(Te),I.progress!==void 0&&ne!==void 0&&I.progress!==ne&&N?.(F,ne,I.progress));},[oe,A,Pe,L,N]),ut=useCallback(F=>{F.length!==0&&(J(I=>ii(I,F)),a.onTaskIndent?.(F[0]));},[a]),ha=useCallback(F=>{F.length!==0&&(J(I=>li(I,F)),a.onTaskOutdent?.(F[0]));},[a]),Gt=useCallback((F,I,K)=>{J(ne=>oc(ne,F,I,K)),a.onTaskReparent?.(F,I,K);},[a]),Ye=useCallback((F,I)=>{F.length!==0&&(J(K=>di(K,F,I)),a.onTaskMove?.(F[0],I));},[a]),St=useCallback(async F=>{let I=[];for(let K of F)B&&await Promise.resolve(B(K))===false||I.push(K);I.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(I):(J(K=>ci(K,I)),I.forEach(K=>a.onTaskDelete?.(K))),D&&I.forEach(K=>D(K)));},[a,B,D]),ca=useCallback(F=>{J(I=>pi(I,F)),F.forEach(I=>a.onTaskDuplicate?.(I));},[a]),yr=useCallback((F,I)=>{J(K=>{let{tasks:ne,newTask:ge}=rc(K,F,I);return Oe&&Oe(ge)===false?K:(a.onTaskCreate?.(ge.parentId,ge.position||0),ze?.(ge),ne)});},[a,Oe,ze]),Up=useCallback((F,I)=>{J(K=>mi(K,F,I)),a.onTaskRename?.(F,I);},[a]),Qn=useCallback(F=>{J(I=>{let{tasks:K}=gi(I,F);return a.onTaskCreate?.(F,0),K});},[a]),Hp=useCallback((F,I,K)=>{let ne=F.startDate?Math.round((I.getTime()-F.startDate.getTime())/864e5):0,ge=ea=>ea.map(ka=>ka.id===F.id?{...ka,startDate:I,endDate:K,...F.segments&&{segments:F.segments}}:ka.subtasks?{...ka,subtasks:ge(ka.subtasks)}:ka),Te=ge(oe);Te=he.autoScheduleDependents(Te,F.id,ne),J(Te);let wt={...F,startDate:I,endDate:K};A?.(wt);},[oe,A]),Wp=useCallback((F,I)=>{R?.(F,I),It({isOpen:true,x:I.clientX,y:I.clientY,task:F});},[R]),Gp=useCallback((F,I)=>{let K=he.splitTask(oe,F.id,I);J(K),It({isOpen:false,x:0,y:0,task:null});},[oe]),hl=useCallback(F=>{let I=he.findTaskById(oe,F.id)||F;x?.(I),H||lt(I);},[oe,x,H]),bl=useCallback((F,I,K)=>{let ne=new Map,ge=wa=>{wa.forEach(Aa=>{Aa.dependencies&&ne.set(Aa.id,Aa.dependencies),Aa.subtasks&&ge(Aa.subtasks);});};ge(K);let Te=ne.get(I)||[];ne.set(I,[...Te,F]);let wt=new Set,ea=new Set,ka=wa=>{if(!wt.has(wa)){wt.add(wa),ea.add(wa);let Aa=ne.get(wa)||[];for(let vr of Aa){if(!wt.has(vr)&&ka(vr))return true;if(ea.has(vr))return true}}return ea.delete(wa),false};return ka(I)},[]),yl=useCallback((F,I)=>{if(bl(F.id,I,oe)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
343
343
 
344
- Task dependencies must flow in one direction only.`);return}let j=oe=>oe.map(ue=>{if(ue.id===I){let Ne=ue.dependencies||[];if(!Ne.includes(F.id))return {...ue,dependencies:[...Ne,F.id]}}return ue.subtasks?{...ue,subtasks:j(ue.subtasks)}:ue});te(j(ee)),pe?.(F.id,I);},[ee,pe,bl]),vl=useCallback((F,I)=>{let j=oe=>oe.map(ue=>{if(ue.id===F&&ue.dependencies){let Ne=ue.dependencies.filter(Ct=>Ct!==I);return {...ue,dependencies:Ne}}return ue.subtasks?{...ue,subtasks:j(ue.subtasks)}:ue});te(j(ee)),Te?.(F,I);},[ee,Te]),{startDate:_m,endDate:Vm}=useMemo(()=>{let F=ee.filter(Ne=>Ne.startDate&&Ne.endDate);if(F.length===0){let Ne=new Date,Ct=new Date(Ne);Ct.setDate(Ct.getDate()-30);let ea=new Date(Ne);return ea.setDate(ea.getDate()+60),{startDate:Ct,endDate:ea}}let I=F.flatMap(Ne=>[Ne.startDate,Ne.endDate]).filter(Ne=>Ne!==void 0),j=new Date(Math.min(...I.map(Ne=>Ne.getTime()))),oe=new Date(Math.max(...I.map(Ne=>Ne.getTime()))),ue=ve==="day"?7:ve==="week"?14:30;return j.setDate(j.getDate()-ue),oe.setDate(oe.getDate()+ue),{startDate:j,endDate:oe}},[ee,ve]),jm=useCallback(async()=>{if(!ga.current||!tt.current||!xa.current)return;await new Promise(Br=>setTimeout(Br,200));let F=ga.current,I=tt.current.querySelector(".gantt-grid-scroll"),j=xa.current,oe=I?.scrollTop||0,ue=I?.scrollLeft||0,Ne=j.scrollTop,Ct=j.scrollLeft,ea=F.style.overflow,ka=F.style.height,wa=I?.style.overflow||"",Aa=j.style.overflow,vr=F.style.width,Jo=j.style.width;try{let Br=I?.querySelector(".gantt-taskgrid-content"),xr=j.querySelector("svg"),kr=xr?.getAttribute("height")?parseInt(xr.getAttribute("height"),10):xr?.getBoundingClientRect().height||0,ro=Br?.scrollHeight||I?.scrollHeight||600,Rr=Math.max(kr,j.scrollHeight),xl=xr?.getAttribute("width")?parseInt(xr.getAttribute("width"),10):xr?.getBoundingClientRect().width||j.scrollWidth,Zm=F.querySelector('[class*="h-12"]')?.offsetHeight||48,Zn=Math.max(ro,Rr,kr),es=Zm+Zn+50,ts=(I?.offsetWidth||300)+xl+10;I&&(I.scrollTop=0,I.scrollLeft=0),j.scrollTop=0,j.scrollLeft=0,F.style.overflow="visible",F.style.height=`${es}px`,F.style.width=`${ts}px`,I&&(I.style.overflow="visible",I.style.height=`${Zn+50}px`),j.style.overflow="visible",j.style.height=`${Zn+50}px`,j.style.width=`${xl+10}px`,await new Promise(rs=>setTimeout(rs,150));let ep=await xc(F,{backgroundColor:P.bgPrimary,scale:2,logging:!1,useCORS:!0,allowTaint:!0,width:ts,height:es,windowWidth:ts+100,windowHeight:es+100,scrollX:0,scrollY:0,ignoreElements:rs=>{let kl=window.getComputedStyle(rs),wl=parseInt(kl.zIndex,10);return !isNaN(wl)&&wl>=50||kl.position==="fixed"}}),as=document.createElement("a");as.download=`gantt-chart-${new Date().toISOString().slice(0,10)}.png`,as.href=ep.toDataURL("image/png"),as.click();}finally{F.style.overflow=ea,F.style.height=ka,F.style.width=vr,I&&(I.style.overflow=wa,I.style.height="",I.scrollTop=oe,I.scrollLeft=ue),j.style.overflow=Aa,j.style.height="",j.style.width=Jo,j.scrollTop=Ne,j.scrollLeft=Ct;}},[P]),Km=useCallback(async()=>{await ge.exportToPDF(ee);},[ee]),Ym=useCallback(async()=>{await ge.exportToExcel(ee);},[ee]),qm=useCallback(()=>{let F=ge.exportToCSV(ee),I=new Blob([F],{type:"text/csv;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(I),j.download="gantt-chart.csv",j.click(),URL.revokeObjectURL(j.href);},[ee]),Xm=useCallback(()=>{let F=ge.exportToJSON(ee),I=new Blob([F],{type:"application/json;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(I),j.download="gantt-chart.json",j.click(),URL.revokeObjectURL(j.href);},[ee]),Jm=useCallback(()=>{ge.exportToMSProject(ee,"Gantt Project","project.xml");},[ee]),Qm=F=>{F.preventDefault(),$e(true);},ao=useRef(false);return useEffect(()=>{let F=xa.current,I=tt.current?.querySelector(".gantt-grid-scroll");if(!F||!I)return;let j=()=>{if(ao.current)return;ao.current=true;let Ct=F.scrollTop;le(Ct),I.scrollTop=Ct,requestAnimationFrame(()=>{ao.current=false;});},oe=()=>{if(ao.current)return;ao.current=true;let Ct=I.scrollTop;le(Ct),F.scrollTop=Ct,requestAnimationFrame(()=>{ao.current=false;});},ue=Ct=>{if(we&&I){let ka=I.parentElement?.getBoundingClientRect()?.left||0,wa=Ct.clientX-ka,Aa=200,vr=_e+de,Jo=window.innerWidth*Ie,Br=Math.max(vr,Jo);wa>=Aa&&wa<=Br&&vt(wa);}},Ne=()=>{$e(false);};return F.addEventListener("scroll",j),I.addEventListener("scroll",oe),document.addEventListener("mousemove",ue),document.addEventListener("mouseup",Ne),()=>{F.removeEventListener("scroll",j),I.removeEventListener("scroll",oe),document.removeEventListener("mousemove",ue),document.removeEventListener("mouseup",Ne);}},[we,_e]),jsx(ho.Provider,{value:V,children:jsx(ls.Provider,{value:ye,children:jsxs("div",{ref:ga,className:"flex flex-col h-full w-full",style:{backgroundColor:P.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsx(kn,{theme:P,timeScale:ve,onTimeScaleChange:Ee,zoom:Re,onZoomChange:Le,currentTheme:O,onThemeChange:va,rowDensity:fe,onRowDensityChange:We,showThemeSelector:m,showCreateTaskButton:h,createTaskLabel:v,onCreateTask:l,taskFilter:nt,onTaskFilterChange:z,onExportPNG:i?jm:void 0,onExportPDF:i?Km:void 0,onExportExcel:i?Ym:void 0,onExportCSV:i?qm:void 0,onExportJSON:i?Xm:void 0,onExportMSProject:i?Jm:void 0}),jsxs("div",{ref:tt,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:At,overflowX:"auto",overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:jsx(Nn,{tasks:lt,theme:P,rowHeight:se,availableUsers:u,templates:Q,onTaskClick:w,onTaskDblClick:hl,onTaskContextMenu:R,onTaskToggle:Fe,scrollTop:ne,columns:Se,onToggleColumn:He,onColumnResize:St,onTaskUpdate:Bt,onTaskIndent:ut,onTaskOutdent:fa,onTaskMove:Ke,onMultiTaskDelete:Et,onTaskDuplicate:da,onTaskCreate:yr,onTaskRename:Um,onCreateSubtask:Qn,onOpenTaskModal:w?F=>w(F):void 0,onDeleteRequest:(F,I)=>Lt({taskId:F,taskName:I}),onTaskReparent:Wt})}),jsx("div",{className:"flex-shrink-0 cursor-col-resize hover:bg-blue-500/50 transition-colors h-full",style:{width:1,backgroundColor:P.border,zIndex:15},onMouseDown:Qm}),jsx("div",{ref:xa,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsx(Ln,{tasks:lt,theme:P,rowHeight:se,timeScale:ve,startDate:_m,endDate:Vm,zoom:Re,templates:Q,dependencyLineStyle:a?.dependencyLineStyle,onTaskClick:w,onTaskDblClick:hl,onTaskContextMenu:Wm,onTaskDateChange:Hm,onDependencyCreate:yl,onDependencyDelete:vl})})]}),Pe.task&&jsx(yo,{isOpen:Pe.isOpen,x:Pe.x,y:Pe.y,theme:P,onClose:()=>Vt({isOpen:false,x:0,y:0,task:null}),items:(()=>{let F=Pe.task;if(!F)return [];let I=ge.findTaskById(ee,F.id)||F;return I.subtasks&&I.subtasks.length>0?[{id:"addSubtask",label:V.contextMenu?.addSubtask||"Add Subtask",icon:Ut.Add,onClick:()=>{$?$(I):Qn(I.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:V.contextMenu?.deleteTask||"Delete Task",icon:Ut.Delete,onClick:()=>{Lt({taskId:I.id,taskName:I.name});}}]:[{id:"edit",label:V.contextMenu?.editTask||"Edit Task",icon:Ut.Pencil,onClick:()=>{U?U(I):st(I);}},{id:"addSubtask",label:V.contextMenu?.addSubtask||"Add Subtask",icon:Ut.Add,onClick:()=>{$?$(I):Qn(I.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:V.contextMenu?.markIncomplete||"Mark Incomplete",icon:Ut.MarkIncomplete,onClick:()=>{_?_(I):Bt(I.id,{status:"todo",progress:0});},disabled:I.status==="todo"},{id:"setInProgress",label:V.contextMenu?.setInProgress||"Set In Progress",icon:Ut.SetInProgress,onClick:()=>{q?q(I):Bt(I.id,{status:"in-progress"});},disabled:I.status==="in-progress"},{id:"markComplete",label:V.contextMenu?.markComplete||"Mark Complete",icon:Ut.MarkComplete,onClick:()=>{Bt(I.id,{status:"completed",progress:100});},disabled:I.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:V.contextMenu?.splitTask||"Split Task",icon:Ut.Split,onClick:()=>{if(!I.startDate||!I.endDate){console.warn("Cannot split task without dates");return}let oe=I.startDate.getTime(),ue=I.endDate.getTime(),Ne=oe+(ue-oe)/2,Ct=new Date(Ne);Gm(I,Ct);},disabled:!I.startDate||!I.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:V.contextMenu?.deleteTask||"Delete Task",icon:Ut.Delete,onClick:()=>{Lt({taskId:I.id,taskName:I.name});}}]})()}),jsx(Gr,{task:ft,isOpen:!!ft,onClose:()=>st(null),onTaskUpdate:F=>{ft&&(Bt(ft.id,F),st(null));},theme:O==="light"?"light":"dark",locale:T==="es"?"es":"en",availableUsers:u,availableTasks:t}),jsx(AnimatePresence,{children:mt&&jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[10000] flex items-center justify-center p-4",style:{backgroundColor:"rgba(0, 0, 0, 0.6)"},onClick:()=>Lt(null),children:jsxs(motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.2,ease:"easeOut"},onClick:F=>F.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:P.bgSecondary,border:`1px solid ${P.border}`},children:[jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${P.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:P.textPrimary,fontFamily:"Inter, sans-serif"},children:[V.contextMenu?.deleteTask||"Delete Task","?"]}),jsx("p",{className:"text-sm mt-1",style:{color:P.textSecondary,fontFamily:"Inter, sans-serif"},children:T==="es"?"Esta acci\xF3n no se puede deshacer":"This action cannot be undone"})]})]})}),jsx("div",{className:"px-6 py-4",children:jsxs("p",{className:"text-sm leading-relaxed",style:{color:P.textSecondary,fontFamily:"Inter, sans-serif"},children:[T==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxs("span",{className:"font-semibold",style:{color:P.textPrimary},children:['"',mt.taskName,'"']}),"."]})}),jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:P.bgPrimary,borderTop:`1px solid ${P.border}`},children:[jsx("button",{onClick:()=>Lt(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:P.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:F=>{F.currentTarget.style.backgroundColor=P.hoverBg;},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="transparent";},children:T==="es"?"Cancelar":"Cancel"}),jsxs("button",{onClick:()=>{Et([mt.taskId]),Lt(null);},className:"px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:"#EF4444",fontFamily:"Inter, sans-serif"},onMouseEnter: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(In,{tasks:ee,theme:P,config:C,onTasksUpdate:te,onTaskUpdate:Bt,onTaskCreate:F=>{te(I=>[...I,F]);},onTaskDelete:F=>{Et([F]);},onDependencyCreate:(F,I)=>{let j=ge.findTaskById(ee,F);j&&yl(j,I);},onDependencyDelete:vl})]})})})});var ki=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],wi=[{id:"low",label:"Baja",color:"#10B981",icon:"\u{1F7E2}"},{id:"medium",label:"Media",color:"#F59E0B",icon:"\u{1F7E1}"},{id:"high",label:"Alta",color:"#F97316",icon:"\u{1F7E0}"},{id:"urgent",label:"Urgente",color:"#EF4444",icon:"\u{1F534}"}];function Tc({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:n=false,mode:p=a?"edit":"create",theme:m="dark",customStatuses:i=[],availableTags:u=[],onCreateTag:d,attachments:g=[],onUploadAttachments:b,onDeleteAttachment:C}){let T=[...ki,...i.filter(z=>!ki.some(ne=>ne.id===z.id))],c=Xe[m]||Xe.dark,[h,v]=useState(false),[l,k]=useState(false),[y,S]=useState(false),[w,x]=useState(false),[R,A]=useState({top:0,left:0}),[N,U]=useState(null),[$,_]=useState(new Date),[q,pe]=useState({top:0,left:0}),[Te,Ze]=useState(false),[Oe,Be]=useState([]),L=useRef(null),B=useRef(null),D=useRef(null),W=useRef(null),Y=useRef(null),[O,ie]=useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[ve,Ee]=useState({});useEffect(()=>{a?(ie({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)&&Ze(true)):(ie({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),Ze(false),Be([]));},[a,e]),useEffect(()=>{let z=ne=>{L.current&&!L.current.contains(ne.target)&&v(false),B.current&&!B.current.contains(ne.target)&&k(false),D.current&&!D.current.contains(ne.target)&&S(false),W.current&&!W.current.contains(ne.target)&&x(false);};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]);let fe=()=>{let z={};return O.name.trim()||(z.name="El nombre es requerido"),O.startDate&&O.endDate&&O.startDate>O.endDate&&(z.endDate="La fecha de fin debe ser posterior a la de inicio"),Ee(z),Object.keys(z).length===0},We=async z=>{if(z.preventDefault(),!!fe())try{let ne=p==="create"&&Oe.length>0?{...O,pendingFiles:Oe}:O;await s(ne),Be([]),t();}catch(ne){console.error("Error submitting task:",ne);}},Re=(z,ne)=>{ie(le=>{let we={...le,[z]:ne};if(z==="status"){let $e=ne;$e==="todo"?we.progress=0:$e==="in-progress"?(le.progress===0||le.progress===100)&&(we.progress=50):$e==="completed"||$e==="closed"?we.progress=100:($e==="in-review"||$e==="review")&&(we.progress=75);}if(z==="progress"){let $e=typeof ne=="number"?ne:parseInt(ne,10);$e===100&&le.status!=="completed"?we.status="completed":$e>0&&$e<100&&le.status==="todo"?we.status="in-progress":$e===0&&le.status!=="todo"&&(we.status="todo");}return we}),ve[z]&&Ee(le=>{let we={...le};return delete we[z],we});},Le=T.find(z=>z.id===O.status)??ki[0],ze=wi.find(z=>z.id===O.priority)??wi[1],yt=sr.find(z=>z.value===O.color)??sr[0],nt={backgroundColor:c.bgSecondary,border:`1px solid ${c.borderLight}`,color:c.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":m,style:{backgroundColor:c.bgPrimary,border:`1px solid ${c.border}`},onClick:z=>z.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${c.border}`},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Le.color||c.accent}}),jsx("span",{className:"text-sm font-medium",style:{color:c.textSecondary},children:p==="create"?"Nueva tarea":"Editar tarea"})]}),jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:c.textTertiary},onMouseEnter:z=>{z.currentTarget.style.backgroundColor=c.hoverBg,z.currentTarget.style.color=c.textPrimary;},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="transparent",z.currentTarget.style.color=c.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:O.name,onChange:z=>Re("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:c.textPrimary},placeholder:"Nombre de la tarea",disabled:n,autoFocus:true}),ve.name&&jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsx(AlertCircle,{className:"w-3 h-3"}),ve.name]})]}),jsx("div",{children:jsx("textarea",{value:O.description||"",onChange:z=>Re("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:c.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:n})}),jsx("div",{style:{borderTop:`1px solid ${c.borderLight}`}}),jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxs("div",{ref:L,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&v(!h),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...nt,borderColor:Le.color,backgroundColor:`${Le.color}15`},disabled:n,children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:Le.color}}),jsx("span",{style:{color:Le.color},children:Le.title}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:Le.color}})]}),jsx(AnimatePresence,{children:h&&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:c.bgPrimary,border:`1px solid ${c.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:c.textPrimary},onMouseEnter:ne=>ne.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:ne=>ne.currentTarget.style.backgroundColor="transparent",onClick:()=>{Re("status",z.id),v(false);},children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:z.color}}),z.title,O.status===z.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:c.accent}})]},z.id))})})]}),jsxs("div",{ref:B,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&k(!l),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:nt,disabled:n,children:[jsx(Flag,{className:"w-3.5 h-3.5",style:{color:ze.color}}),jsx("span",{children:ze.label}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:c.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:c.bgPrimary,border:`1px solid ${c.border}`},children:wi.map(z=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:c.textPrimary},onMouseEnter:ne=>ne.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:ne=>ne.currentTarget.style.backgroundColor="transparent",onClick:()=>{Re("priority",z.id),k(false);},children:[jsx("span",{children:z.icon}),z.label,O.priority===z.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:c.accent}})]},z.id))})})]}),o.length>0&&jsxs("div",{ref:D,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&S(!y),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:[O.assignees&&O.assignees.length>0?jsxs(Fragment,{children:[jsx("div",{className:"flex -space-x-1",children:O.assignees.slice(0,3).map((z,ne)=>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||c.accent,borderColor:c.bgSecondary},children:z.initials},ne))}),O.assignees.length>3&&jsxs("span",{style:{color:c.textTertiary},children:["+",O.assignees.length-3]})]}):jsxs(Fragment,{children:[jsx(Users,{className:"w-3.5 h-3.5",style:{color:c.textTertiary}}),jsx("span",{style:{color:c.textTertiary},children:"Asignar"})]}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:c.textTertiary}})]}),jsx(AnimatePresence,{children:y&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[180px] max-h-[200px] overflow-y-auto rounded-lg shadow-xl",style:{backgroundColor:c.bgPrimary,border:`1px solid ${c.border}`},children:o.map(z=>{let ne=O.assignees?.some(le=>le.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:c.textPrimary},onMouseEnter:le=>le.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:le=>le.currentTarget.style.backgroundColor="transparent",onClick:()=>{let le=ne?(O.assignees||[]).filter(we=>we.name!==z.name):[...O.assignees||[],{name:z.name,avatar:z.avatar,initials:z.name.split(" ").map(we=>we[0]).join("").toUpperCase().slice(0,2),color:c.accent}];Re("assignees",le);},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:c.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:ne&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:c.accent}})})]},z.id)})})})]}),jsxs("div",{ref:W,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>{if(!n)if(w)x(false);else {if(W.current){let z=W.current.getBoundingClientRect(),ne=window.innerHeight,le=120,$e=ne-z.bottom<le?z.top-le-8:z.bottom+8;A({top:$e,left:z.left});}x(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:O.color}}),jsx("span",{children:yt.name}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:c.textTertiary}})]}),jsx(AnimatePresence,{children:w&&jsxs(ht,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>x(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:`${R.top}px`,left:`${R.left}px`,zIndex:99999,backgroundColor:c.bgPrimary,border:`1px solid ${c.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick: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 ne=O.color===z.value;return jsx("button",{type:"button",onClick:le=>{le.preventDefault(),le.stopPropagation(),Re("color",z.value),x(false);},style:{width:"28px",height:"28px",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",border:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0},title:z.name,children:jsx("span",{style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:z.value,outline:ne?`2px solid ${z.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},z.value)})})})})]})})]}),u.length>0||d?jsx(nr,{selectedTags:O.tags||[],availableTags:u,onChange:z=>Re("tags",z),onCreateTag:d,theme:c,disabled:n}):null]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Calendar,{className:"w-4 h-4",style:{color:c.textTertiary}}),jsxs("div",{ref:Y,className:"flex items-center gap-2 flex-1 relative",children:[jsx("button",{type:"button",onClick:()=>{if(!n&&!O.isMilestone)if(N==="start")U(null);else {if(Y.current){let z=Y.current.getBoundingClientRect(),ne=window.innerHeight,le=320,$e=ne-z.bottom<le?z.top-le-8:z.bottom+8;pe({top:$e,left:z.left});}U("start"),_(O.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...nt,opacity:O.isMilestone?.5:1,cursor:O.isMilestone?"not-allowed":"pointer"},disabled:n||O.isMilestone,children:O.startDate?O.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsx("span",{style:{color:c.textTertiary},children:"\u2192"}),jsx("button",{type:"button",onClick:()=>{if(!n&&!O.isMilestone)if(N==="end")U(null);else {if(Y.current){let z=Y.current.getBoundingClientRect(),ne=window.innerHeight,le=320,$e=ne-z.bottom<le?z.top-le-8:z.bottom+8;pe({top:$e,left:z.left});}U("end"),_(O.endDate||O.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...nt,opacity:O.isMilestone?.5:1,cursor:O.isMilestone?"not-allowed":"pointer"},disabled:n||O.isMilestone,children:O.endDate?O.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsx(AnimatePresence,{children:N&&jsxs(ht,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>U(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:`${q.top}px`,left:`${q.left}px`,zIndex:99999,backgroundColor:c.bgPrimary,border:`1px solid ${c.border}`},onClick:z=>z.stopPropagation(),children:[jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${c.border}`},children:[(()=>{let z=new Date,ne=new Date(z);ne.setDate(z.getDate()+1);let le=new Date(z);le.setDate(z.getDate()+7);let we=new Date(z);return we.setDate(z.getDate()+14),[{label:"Hoy",date:z},{label:"Ma\xF1ana",date:ne},{label:"Pr\xF3xima semana",date:le},{label:"2 semanas",date:we}].map((et,vt)=>jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:c.textPrimary},onMouseEnter:Pe=>Pe.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:Pe=>Pe.currentTarget.style.backgroundColor="transparent",onClick:()=>{N==="start"?(Re("startDate",et.date),(!O.endDate||et.date>O.endDate)&&Re("endDate",et.date),U("end")):(Re("endDate",et.date),(!O.startDate||et.date<O.startDate)&&Re("startDate",et.date),U(null));},children:et.label},vt))})(),jsx("div",{style:{borderTop:`1px solid ${c.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=c.hoverBg,onMouseLeave:z=>z.currentTarget.style.backgroundColor="transparent",onClick:()=>{Re("startDate",void 0),Re("endDate",void 0),U(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:()=>_(new Date($.getFullYear(),$.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-4 h-4",style:{color:c.textSecondary}})}),jsx("span",{className:"text-sm font-medium",style:{color:c.textPrimary},children:$.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>_(new Date($.getFullYear(),$.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-4 h-4",style:{color:c.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((z,ne)=>jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:c.textTertiary},children:z},ne))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let z=$.getFullYear(),ne=$.getMonth(),le=new Date(z,ne,1).getDay(),we=new Date(z,ne+1,0).getDate(),$e=new Date,et=[];for(let Pe=le-1;Pe>=0;Pe--)et.push({day:new Date(z,ne,-Pe).getDate(),date:new Date(z,ne-1,new Date(z,ne,-Pe).getDate()),isCurrentMonth:false});for(let Pe=1;Pe<=we;Pe++)et.push({day:Pe,date:new Date(z,ne,Pe),isCurrentMonth:true});let vt=42-et.length;for(let Pe=1;Pe<=vt;Pe++)et.push({day:Pe,date:new Date(z,ne+1,Pe),isCurrentMonth:false});return et.map((Pe,Vt)=>{let ft=Pe.date.toDateString()===$e.toDateString(),st=O.startDate?.toDateString()===Pe.date.toDateString(),mt=O.endDate?.toDateString()===Pe.date.toDateString(),Lt=O.startDate&&O.endDate&&Pe.date>=O.startDate&&Pe.date<=O.endDate;return jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:Pe.isCurrentMonth?st||mt?"#FFF":c.textPrimary:c.textTertiary,backgroundColor:st?"#3B82F6":mt?"#7C3AED":Lt?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:ft&&!st&&!mt?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{N==="start"?(Re("startDate",Pe.date),O.endDate&&Pe.date>O.endDate&&Re("endDate",Pe.date),U("end")):(Re("endDate",Pe.date),O.startDate&&Pe.date<O.startDate&&Re("startDate",Pe.date),U(null));},children:Pe.day},Vt)})})()})]})]})]})})]}),ve.endDate&&jsx("span",{className:"text-xs text-red-400",children:ve.endDate})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:"w-4 h-4",style:{color:c.textTertiary}}),jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsx("input",{type:"range",min:"0",max:"100",step:"5",value:O.progress,onChange:z=>Re("progress",parseInt(z.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:c.bgSecondary,accentColor:O.progress<30?"#EF4444":O.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:`${O.progress<30?"#EF4444":O.progress<70?"#F59E0B":"#10B981"}20`,color:O.progress<30?"#EF4444":O.progress<70?"#F59E0B":"#10B981"},children:[O.progress,"%"]})]})]}),jsxs("div",{children:[jsxs("button",{type:"button",onClick:()=>Ze(!Te),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:c.textTertiary},children:[jsx(ChevronDown,{className:`w-3 h-3 transition-transform ${Te?"rotate-180":""}`}),"Opciones avanzadas"]}),jsx(AnimatePresence,{children:Te&&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:[(b||g.length>0||p==="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:c.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:c.textTertiary},children:["Adjuntos ",p==="create"?Oe.length>0&&`(${Oe.length})`:g.length>0&&`(${g.length})`]})]}),p==="create"?jsx(dr,{cardId:"pending",attachments:Oe.map((z,ne)=>({id:`pending-${ne}`,cardId:"pending",name:z.name,size:z.size,type:z.type,url:URL.createObjectURL(z),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:z=>Be(ne=>[...ne,...z]),onDelete:z=>{let ne=parseInt(z.replace("pending-",""),10);Be(le=>le.filter((we,$e)=>$e!==ne));},maxSizeMB:10,maxFiles:20}):jsx(dr,{cardId:a?.id||"new",attachments:g,onUpload:b&&a?.id?z=>b(a.id,z):void 0,onDelete:C,maxSizeMB:10,maxFiles:20}),p==="create"&&Oe.length>0&&jsxs("p",{className:"text-xs mt-1",style:{color:c.textTertiary},children:[Oe.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:O.isMilestone,onChange:z=>Re("isMilestone",z.target.checked),className:"w-4 h-4 rounded",style:{accentColor:c.accent},disabled:n}),jsx(Milestone,{className:"w-4 h-4 text-yellow-500"}),jsx("span",{className:"text-sm",style:{color:c.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:c.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:c.bgSecondary},children:r.filter(z=>z.id!==a?.id).map(z=>{let ne=O.dependencies?.includes(z.id);return jsx("button",{type:"button",onClick:()=>{let le=ne?(O.dependencies||[]).filter(we=>we!==z.id):[...O.dependencies||[],z.id];Re("dependencies",le);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:ne?`${c.accent}30`:c.bgPrimary,color:ne?c.accent:c.textSecondary,border:`1px solid ${ne?c.accent:c.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 ${c.border}`},children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:c.textSecondary},onMouseEnter:z=>z.currentTarget.style.backgroundColor=c.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:c.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:p==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var Nc=`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 K=ne=>ne.map(ge=>{if(ge.id===I){let Te=ge.dependencies||[];if(!Te.includes(F.id))return {...ge,dependencies:[...Te,F.id]}}return ge.subtasks?{...ge,subtasks:K(ge.subtasks)}:ge});J(K(oe)),ie?.(F.id,I);},[oe,ie,bl]),vl=useCallback((F,I)=>{let K=ne=>ne.map(ge=>{if(ge.id===F&&ge.dependencies){let Te=ge.dependencies.filter(wt=>wt!==I);return {...ge,dependencies:Te}}return ge.subtasks?{...ge,subtasks:K(ge.subtasks)}:ge});J(K(oe)),Be?.(F,I);},[oe,Be]),{startDate:_p,endDate:Vp}=useMemo(()=>{let F=oe.filter(Te=>Te.startDate&&Te.endDate);if(F.length===0){let Te=new Date,wt=new Date(Te);wt.setDate(wt.getDate()-30);let ea=new Date(Te);return ea.setDate(ea.getDate()+60),{startDate:wt,endDate:ea}}let I=F.flatMap(Te=>[Te.startDate,Te.endDate]).filter(Te=>Te!==void 0),K=new Date(Math.min(...I.map(Te=>Te.getTime()))),ne=new Date(Math.max(...I.map(Te=>Te.getTime()))),ge=ve==="day"?7:ve==="week"?14:30;return K.setDate(K.getDate()-ge),ne.setDate(ne.getDate()+ge),{startDate:K,endDate:ne}},[oe,ve]),jp=useCallback(async()=>{if(!fa.current||!rt.current||!xa.current)return;await new Promise(Br=>setTimeout(Br,200));let F=fa.current,I=rt.current.querySelector(".gantt-grid-scroll"),K=xa.current,ne=I?.scrollTop||0,ge=I?.scrollLeft||0,Te=K.scrollTop,wt=K.scrollLeft,ea=F.style.overflow,ka=F.style.height,wa=I?.style.overflow||"",Aa=K.style.overflow,vr=F.style.width,Jo=K.style.width;try{let Br=I?.querySelector(".gantt-taskgrid-content"),xr=K.querySelector("svg"),kr=xr?.getAttribute("height")?parseInt(xr.getAttribute("height"),10):xr?.getBoundingClientRect().height||0,ro=Br?.scrollHeight||I?.scrollHeight||600,Rr=Math.max(kr,K.scrollHeight),xl=xr?.getAttribute("width")?parseInt(xr.getAttribute("width"),10):xr?.getBoundingClientRect().width||K.scrollWidth,Zp=F.querySelector('[class*="h-12"]')?.offsetHeight||48,Zn=Math.max(ro,Rr,kr),es=Zp+Zn+50,ts=(I?.offsetWidth||300)+xl+10;I&&(I.scrollTop=0,I.scrollLeft=0),K.scrollTop=0,K.scrollLeft=0,F.style.overflow="visible",F.style.height=`${es}px`,F.style.width=`${ts}px`,I&&(I.style.overflow="visible",I.style.height=`${Zn+50}px`),K.style.overflow="visible",K.style.height=`${Zn+50}px`,K.style.width=`${xl+10}px`,await new Promise(rs=>setTimeout(rs,150));let em=await xc(F,{backgroundColor:P.bgPrimary,scale:2,logging:!1,useCORS:!0,allowTaint:!0,width:ts,height:es,windowWidth:ts+100,windowHeight:es+100,scrollX:0,scrollY:0,ignoreElements:rs=>{let kl=window.getComputedStyle(rs),wl=parseInt(kl.zIndex,10);return !isNaN(wl)&&wl>=50||kl.position==="fixed"}}),as=document.createElement("a");as.download=`gantt-chart-${new Date().toISOString().slice(0,10)}.png`,as.href=em.toDataURL("image/png"),as.click();}finally{F.style.overflow=ea,F.style.height=ka,F.style.width=vr,I&&(I.style.overflow=wa,I.style.height="",I.scrollTop=ne,I.scrollLeft=ge),K.style.overflow=Aa,K.style.height="",K.style.width=Jo,K.scrollTop=Te,K.scrollLeft=wt;}},[P]),Kp=useCallback(async()=>{await he.exportToPDF(oe);},[oe]),Yp=useCallback(async()=>{await he.exportToExcel(oe);},[oe]),qp=useCallback(()=>{let F=he.exportToCSV(oe),I=new Blob([F],{type:"text/csv;charset=utf-8;"}),K=document.createElement("a");K.href=URL.createObjectURL(I),K.download="gantt-chart.csv",K.click(),URL.revokeObjectURL(K.href);},[oe]),Xp=useCallback(()=>{let F=he.exportToJSON(oe),I=new Blob([F],{type:"application/json;charset=utf-8;"}),K=document.createElement("a");K.href=URL.createObjectURL(I),K.download="gantt-chart.json",K.click(),URL.revokeObjectURL(K.href);},[oe]),Jp=useCallback(()=>{he.exportToMSProject(oe,"Gantt Project","project.xml");},[oe]),Qp=F=>{F.preventDefault(),Ae(true);},ao=useRef(false);return useEffect(()=>{let F=xa.current,I=rt.current?.querySelector(".gantt-grid-scroll");if(!F||!I)return;let K=()=>{if(ao.current)return;ao.current=true;let wt=F.scrollTop;fe(wt),I.scrollTop=wt,requestAnimationFrame(()=>{ao.current=false;});},ne=()=>{if(ao.current)return;ao.current=true;let wt=I.scrollTop;fe(wt),F.scrollTop=wt,requestAnimationFrame(()=>{ao.current=false;});},ge=wt=>{if(ye&&I){let ka=I.parentElement?.getBoundingClientRect()?.left||0,wa=wt.clientX-ka,Aa=200,vr=_e+ce,Jo=window.innerWidth*$e,Br=Math.max(vr,Jo);wa>=Aa&&wa<=Br&&kt(wa);}},Te=()=>{Ae(false);};return F.addEventListener("scroll",K),I.addEventListener("scroll",ne),document.addEventListener("mousemove",ge),document.addEventListener("mouseup",Te),()=>{F.removeEventListener("scroll",K),I.removeEventListener("scroll",ne),document.removeEventListener("mousemove",ge),document.removeEventListener("mouseup",Te);}},[ye,_e]),jsx(ho.Provider,{value:j,children:jsx(ls.Provider,{value:xe,children:jsxs("div",{ref:fa,className:"flex flex-col h-full w-full",style:{backgroundColor:P.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsx(kn,{theme:P,timeScale:ve,onTimeScaleChange:Ee,zoom:Me,onZoomChange:Re,currentTheme:O,onThemeChange:sa,rowDensity:ue,onRowDensityChange:We,showThemeSelector:p,showCreateTaskButton:h,createTaskLabel:v,onCreateTask:l,taskFilter:it,onTaskFilterChange:z,onExportPNG:i?jp:void 0,onExportPDF:i?Kp:void 0,onExportExcel:i?Yp:void 0,onExportCSV:i?qp:void 0,onExportJSON:i?Xp:void 0,onExportMSProject:i?Jp:void 0}),jsxs("div",{ref:rt,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:Mt,overflowX:"auto",overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:jsx(Nn,{tasks:dt,theme:P,rowHeight:se,availableUsers:u,templates:Z,onTaskClick:k,onTaskDblClick:hl,onTaskContextMenu:R,onTaskToggle:Ie,scrollTop:re,columns:Se,onToggleColumn:He,onColumnResize:Dt,onTaskUpdate:Bt,onTaskIndent:ut,onTaskOutdent:ha,onTaskMove:Ye,onMultiTaskDelete:St,onTaskDuplicate:ca,onTaskCreate:yr,onTaskRename:Up,onCreateSubtask:Qn,onOpenTaskModal:k?F=>k(F):void 0,onDeleteRequest:(F,I)=>Wt({taskId:F,taskName:I}),onTaskReparent:Gt})}),jsx("div",{className:"flex-shrink-0 cursor-col-resize hover:bg-blue-500/50 transition-colors h-full",style:{width:1,backgroundColor:P.border,zIndex:15},onMouseDown:Qp}),jsx("div",{ref:xa,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsx(Ln,{tasks:dt,theme:P,rowHeight:se,timeScale:ve,startDate:_p,endDate:Vp,zoom:Me,templates:Z,dependencyLineStyle:a?.dependencyLineStyle,onTaskClick:k,onTaskDblClick:hl,onTaskContextMenu:Wp,onTaskDateChange:Hp,onDependencyCreate:yl,onDependencyDelete:vl})})]}),De.task&&jsx(yo,{isOpen:De.isOpen,x:De.x,y:De.y,theme:P,onClose:()=>It({isOpen:false,x:0,y:0,task:null}),items:(()=>{let F=De.task;if(!F)return [];let I=he.findTaskById(oe,F.id)||F;return I.subtasks&&I.subtasks.length>0?[{id:"addSubtask",label:j.contextMenu?.addSubtask||"Add Subtask",icon:Ut.Add,onClick:()=>{$?$(I):Qn(I.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:j.contextMenu?.deleteTask||"Delete Task",icon:Ut.Delete,onClick:()=>{Wt({taskId:I.id,taskName:I.name});}}]:[{id:"edit",label:j.contextMenu?.editTask||"Edit Task",icon:Ut.Pencil,onClick:()=>{H?H(I):lt(I);}},{id:"addSubtask",label:j.contextMenu?.addSubtask||"Add Subtask",icon:Ut.Add,onClick:()=>{$?$(I):Qn(I.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:j.contextMenu?.markIncomplete||"Mark Incomplete",icon:Ut.MarkIncomplete,onClick:()=>{_?_(I):Bt(I.id,{status:"todo",progress:0});},disabled:I.status==="todo"},{id:"setInProgress",label:j.contextMenu?.setInProgress||"Set In Progress",icon:Ut.SetInProgress,onClick:()=>{V?V(I):Bt(I.id,{status:"in-progress"});},disabled:I.status==="in-progress"},{id:"markComplete",label:j.contextMenu?.markComplete||"Mark Complete",icon:Ut.MarkComplete,onClick:()=>{Bt(I.id,{status:"completed",progress:100});},disabled:I.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:j.contextMenu?.splitTask||"Split Task",icon:Ut.Split,onClick:()=>{if(!I.startDate||!I.endDate){console.warn("Cannot split task without dates");return}let ne=I.startDate.getTime(),ge=I.endDate.getTime(),Te=ne+(ge-ne)/2,wt=new Date(Te);Gp(I,wt);},disabled:!I.startDate||!I.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:j.contextMenu?.deleteTask||"Delete Task",icon:Ut.Delete,onClick:()=>{Wt({taskId:I.id,taskName:I.name});}}]})()}),jsx(Gr,{task:Ft,isOpen:!!Ft,onClose:()=>lt(null),onTaskUpdate:F=>{Ft&&(Bt(Ft.id,F),lt(null));},theme:O==="light"?"light":"dark",locale:T==="es"?"es":"en",availableUsers:u,availableTasks:t}),jsx(AnimatePresence,{children:Xe&&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:()=>Wt(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:P.bgSecondary,border:`1px solid ${P.border}`},children:[jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${P.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:P.textPrimary,fontFamily:"Inter, sans-serif"},children:[j.contextMenu?.deleteTask||"Delete Task","?"]}),jsx("p",{className:"text-sm mt-1",style:{color:P.textSecondary,fontFamily:"Inter, sans-serif"},children:T==="es"?"Esta acci\xF3n no se puede deshacer":"This action cannot be undone"})]})]})}),jsx("div",{className:"px-6 py-4",children:jsxs("p",{className:"text-sm leading-relaxed",style:{color:P.textSecondary,fontFamily:"Inter, sans-serif"},children:[T==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxs("span",{className:"font-semibold",style:{color:P.textPrimary},children:['"',Xe.taskName,'"']}),"."]})}),jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:P.bgPrimary,borderTop:`1px solid ${P.border}`},children:[jsx("button",{onClick:()=>Wt(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:P.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:F=>{F.currentTarget.style.backgroundColor=P.hoverBg;},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="transparent";},children:T==="es"?"Cancelar":"Cancel"}),jsxs("button",{onClick:()=>{St([Xe.taskId]),Wt(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(In,{tasks:oe,theme:P,config:C,onTasksUpdate:J,onTaskUpdate:Bt,onTaskCreate:F=>{J(I=>[...I,F]);},onTaskDelete:F=>{St([F]);},onDependencyCreate:(F,I)=>{let K=he.findTaskById(oe,F);K&&yl(K,I);},onDependencyDelete:vl})]})})})});var ki=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],wi=[{id:"low",label:"Baja",color:"#10B981",icon:"\u{1F7E2}"},{id:"medium",label:"Media",color:"#F59E0B",icon:"\u{1F7E1}"},{id:"high",label:"Alta",color:"#F97316",icon:"\u{1F7E0}"},{id:"urgent",label:"Urgente",color:"#EF4444",icon:"\u{1F534}"}];function Tc({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:n=false,mode:m=a?"edit":"create",theme:p="dark",customStatuses:i=[],availableTags:u=[],onCreateTag:d,attachments:g=[],onUploadAttachments:b,onDeleteAttachment:C}){let T=[...ki,...i.filter(z=>!ki.some(re=>re.id===z.id))],c=et[p]||et.dark,[h,v]=useState(false),[l,w]=useState(false),[y,S]=useState(false),[k,x]=useState(false),[R,A]=useState({top:0,left:0}),[N,H]=useState(null),[$,_]=useState(new Date),[V,ie]=useState({top:0,left:0}),[Be,Oe]=useState(false),[ze,Pe]=useState([]),L=useRef(null),B=useRef(null),D=useRef(null),U=useRef(null),q=useRef(null),[O,le]=useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[ve,Ee]=useState({});useEffect(()=>{a?(le({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)&&Oe(true)):(le({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),Oe(false),Pe([]));},[a,e]),useEffect(()=>{let z=re=>{L.current&&!L.current.contains(re.target)&&v(false),B.current&&!B.current.contains(re.target)&&w(false),D.current&&!D.current.contains(re.target)&&S(false),U.current&&!U.current.contains(re.target)&&x(false);};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]);let ue=()=>{let z={};return O.name.trim()||(z.name="El nombre es requerido"),O.startDate&&O.endDate&&O.startDate>O.endDate&&(z.endDate="La fecha de fin debe ser posterior a la de inicio"),Ee(z),Object.keys(z).length===0},We=async z=>{if(z.preventDefault(),!!ue())try{let re=m==="create"&&ze.length>0?{...O,pendingFiles:ze}:O;await s(re),Pe([]),t();}catch(re){console.error("Error submitting task:",re);}},Me=(z,re)=>{le(fe=>{let ye={...fe,[z]:re};if(z==="status"){let Ae=re;Ae==="todo"?ye.progress=0:Ae==="in-progress"?(fe.progress===0||fe.progress===100)&&(ye.progress=50):Ae==="completed"||Ae==="closed"?ye.progress=100:(Ae==="in-review"||Ae==="review")&&(ye.progress=75);}if(z==="progress"){let Ae=typeof re=="number"?re:parseInt(re,10);Ae===100&&fe.status!=="completed"?ye.status="completed":Ae>0&&Ae<100&&fe.status==="todo"?ye.status="in-progress":Ae===0&&fe.status!=="todo"&&(ye.status="todo");}return ye}),ve[z]&&Ee(fe=>{let ye={...fe};return delete ye[z],ye});},Re=T.find(z=>z.id===O.status)??ki[0],ft=wi.find(z=>z.id===O.priority)??wi[1],qe=sr.find(z=>z.value===O.color)??sr[0],it={backgroundColor:c.bgSecondary,border:`1px solid ${c.borderLight}`,color:c.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:c.bgPrimary,border:`1px solid ${c.border}`},onClick:z=>z.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${c.border}`},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Re.color||c.accent}}),jsx("span",{className:"text-sm font-medium",style:{color:c.textSecondary},children:m==="create"?"Nueva tarea":"Editar tarea"})]}),jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:c.textTertiary},onMouseEnter:z=>{z.currentTarget.style.backgroundColor=c.hoverBg,z.currentTarget.style.color=c.textPrimary;},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="transparent",z.currentTarget.style.color=c.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:O.name,onChange:z=>Me("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:c.textPrimary},placeholder:"Nombre de la tarea",disabled:n,autoFocus:true}),ve.name&&jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsx(AlertCircle,{className:"w-3 h-3"}),ve.name]})]}),jsx("div",{children:jsx("textarea",{value:O.description||"",onChange:z=>Me("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:c.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:n})}),jsx("div",{style:{borderTop:`1px solid ${c.borderLight}`}}),jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxs("div",{ref:L,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&v(!h),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...it,borderColor:Re.color,backgroundColor:`${Re.color}15`},disabled:n,children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:Re.color}}),jsx("span",{style:{color:Re.color},children:Re.title}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:Re.color}})]}),jsx(AnimatePresence,{children:h&&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:c.bgPrimary,border:`1px solid ${c.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:c.textPrimary},onMouseEnter:re=>re.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:re=>re.currentTarget.style.backgroundColor="transparent",onClick:()=>{Me("status",z.id),v(false);},children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:z.color}}),z.title,O.status===z.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:c.accent}})]},z.id))})})]}),jsxs("div",{ref:B,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:ft.color}}),jsx("span",{children:ft.label}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:c.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:c.bgPrimary,border:`1px solid ${c.border}`},children:wi.map(z=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:c.textPrimary},onMouseEnter:re=>re.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:re=>re.currentTarget.style.backgroundColor="transparent",onClick:()=>{Me("priority",z.id),w(false);},children:[jsx("span",{children:z.icon}),z.label,O.priority===z.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:c.accent}})]},z.id))})})]}),o.length>0&&jsxs("div",{ref:D,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&S(!y),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:[O.assignees&&O.assignees.length>0?jsxs(Fragment,{children:[jsx("div",{className:"flex -space-x-1",children:O.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||c.accent,borderColor:c.bgSecondary},children:z.initials},re))}),O.assignees.length>3&&jsxs("span",{style:{color:c.textTertiary},children:["+",O.assignees.length-3]})]}):jsxs(Fragment,{children:[jsx(Users,{className:"w-3.5 h-3.5",style:{color:c.textTertiary}}),jsx("span",{style:{color:c.textTertiary},children:"Asignar"})]}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:c.textTertiary}})]}),jsx(AnimatePresence,{children:y&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[180px] max-h-[200px] overflow-y-auto rounded-lg shadow-xl",style:{backgroundColor:c.bgPrimary,border:`1px solid ${c.border}`},children:o.map(z=>{let re=O.assignees?.some(fe=>fe.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:c.textPrimary},onMouseEnter:fe=>fe.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:fe=>fe.currentTarget.style.backgroundColor="transparent",onClick:()=>{let fe=re?(O.assignees||[]).filter(ye=>ye.name!==z.name):[...O.assignees||[],{name:z.name,avatar:z.avatar,initials:z.name.split(" ").map(ye=>ye[0]).join("").toUpperCase().slice(0,2),color:c.accent}];Me("assignees",fe);},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:c.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:c.accent}})})]},z.id)})})})]}),jsxs("div",{ref:U,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>{if(!n)if(k)x(false);else {if(U.current){let z=U.current.getBoundingClientRect(),re=window.innerHeight,fe=120,Ae=re-z.bottom<fe?z.top-fe-8:z.bottom+8;A({top:Ae,left:z.left});}x(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:O.color}}),jsx("span",{children:qe.name}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:c.textTertiary}})]}),jsx(AnimatePresence,{children:k&&jsxs(ht,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>x(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:`${R.top}px`,left:`${R.left}px`,zIndex:99999,backgroundColor:c.bgPrimary,border:`1px solid ${c.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick: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=O.color===z.value;return jsx("button",{type:"button",onClick:fe=>{fe.preventDefault(),fe.stopPropagation(),Me("color",z.value),x(false);},style:{width:"28px",height:"28px",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",border:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0},title: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:O.tags||[],availableTags:u,onChange:z=>Me("tags",z),onCreateTag:d,theme:c,disabled:n}):null]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Calendar,{className:"w-4 h-4",style:{color:c.textTertiary}}),jsxs("div",{ref:q,className:"flex items-center gap-2 flex-1 relative",children:[jsx("button",{type:"button",onClick:()=>{if(!n&&!O.isMilestone)if(N==="start")H(null);else {if(q.current){let z=q.current.getBoundingClientRect(),re=window.innerHeight,fe=320,Ae=re-z.bottom<fe?z.top-fe-8:z.bottom+8;ie({top:Ae,left:z.left});}H("start"),_(O.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...it,opacity:O.isMilestone?.5:1,cursor:O.isMilestone?"not-allowed":"pointer"},disabled:n||O.isMilestone,children:O.startDate?O.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsx("span",{style:{color:c.textTertiary},children:"\u2192"}),jsx("button",{type:"button",onClick:()=>{if(!n&&!O.isMilestone)if(N==="end")H(null);else {if(q.current){let z=q.current.getBoundingClientRect(),re=window.innerHeight,fe=320,Ae=re-z.bottom<fe?z.top-fe-8:z.bottom+8;ie({top:Ae,left:z.left});}H("end"),_(O.endDate||O.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...it,opacity:O.isMilestone?.5:1,cursor:O.isMilestone?"not-allowed":"pointer"},disabled:n||O.isMilestone,children:O.endDate?O.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsx(AnimatePresence,{children:N&&jsxs(ht,{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:`${V.top}px`,left:`${V.left}px`,zIndex:99999,backgroundColor:c.bgPrimary,border:`1px solid ${c.border}`},onClick:z=>z.stopPropagation(),children:[jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${c.border}`},children:[(()=>{let z=new Date,re=new Date(z);re.setDate(z.getDate()+1);let fe=new Date(z);fe.setDate(z.getDate()+7);let ye=new Date(z);return ye.setDate(z.getDate()+14),[{label:"Hoy",date:z},{label:"Ma\xF1ana",date:re},{label:"Pr\xF3xima semana",date:fe},{label:"2 semanas",date:ye}].map((Ze,kt)=>jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:c.textPrimary},onMouseEnter:De=>De.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:De=>De.currentTarget.style.backgroundColor="transparent",onClick:()=>{N==="start"?(Me("startDate",Ze.date),(!O.endDate||Ze.date>O.endDate)&&Me("endDate",Ze.date),H("end")):(Me("endDate",Ze.date),(!O.startDate||Ze.date<O.startDate)&&Me("startDate",Ze.date),H(null));},children:Ze.label},kt))})(),jsx("div",{style:{borderTop:`1px solid ${c.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=c.hoverBg,onMouseLeave:z=>z.currentTarget.style.backgroundColor="transparent",onClick:()=>{Me("startDate",void 0),Me("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:()=>_(new Date($.getFullYear(),$.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-4 h-4",style:{color:c.textSecondary}})}),jsx("span",{className:"text-sm font-medium",style:{color:c.textPrimary},children:$.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>_(new Date($.getFullYear(),$.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-4 h-4",style:{color:c.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:c.textTertiary},children:z},re))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let z=$.getFullYear(),re=$.getMonth(),fe=new Date(z,re,1).getDay(),ye=new Date(z,re+1,0).getDate(),Ae=new Date,Ze=[];for(let De=fe-1;De>=0;De--)Ze.push({day:new Date(z,re,-De).getDate(),date:new Date(z,re-1,new Date(z,re,-De).getDate()),isCurrentMonth:false});for(let De=1;De<=ye;De++)Ze.push({day:De,date:new Date(z,re,De),isCurrentMonth:true});let kt=42-Ze.length;for(let De=1;De<=kt;De++)Ze.push({day:De,date:new Date(z,re+1,De),isCurrentMonth:false});return Ze.map((De,It)=>{let Ft=De.date.toDateString()===Ae.toDateString(),lt=O.startDate?.toDateString()===De.date.toDateString(),Xe=O.endDate?.toDateString()===De.date.toDateString(),Wt=O.startDate&&O.endDate&&De.date>=O.startDate&&De.date<=O.endDate;return jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:De.isCurrentMonth?lt||Xe?"#FFF":c.textPrimary:c.textTertiary,backgroundColor:lt?"#3B82F6":Xe?"#7C3AED":Wt?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:Ft&&!lt&&!Xe?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{N==="start"?(Me("startDate",De.date),O.endDate&&De.date>O.endDate&&Me("endDate",De.date),H("end")):(Me("endDate",De.date),O.startDate&&De.date<O.startDate&&Me("startDate",De.date),H(null));},children:De.day},It)})})()})]})]})]})})]}),ve.endDate&&jsx("span",{className:"text-xs text-red-400",children:ve.endDate})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:"w-4 h-4",style:{color:c.textTertiary}}),jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsx("input",{type:"range",min:"0",max:"100",step:"5",value:O.progress,onChange:z=>Me("progress",parseInt(z.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:c.bgSecondary,accentColor:O.progress<30?"#EF4444":O.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:`${O.progress<30?"#EF4444":O.progress<70?"#F59E0B":"#10B981"}20`,color:O.progress<30?"#EF4444":O.progress<70?"#F59E0B":"#10B981"},children:[O.progress,"%"]})]})]}),jsxs("div",{children:[jsxs("button",{type:"button",onClick:()=>Oe(!Be),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:c.textTertiary},children:[jsx(ChevronDown,{className:`w-3 h-3 transition-transform ${Be?"rotate-180":""}`}),"Opciones avanzadas"]}),jsx(AnimatePresence,{children:Be&&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:[(b||g.length>0||m==="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:c.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:c.textTertiary},children:["Adjuntos ",m==="create"?ze.length>0&&`(${ze.length})`:g.length>0&&`(${g.length})`]})]}),m==="create"?jsx(dr,{cardId:"pending",attachments:ze.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=>Pe(re=>[...re,...z]),onDelete:z=>{let re=parseInt(z.replace("pending-",""),10);Pe(fe=>fe.filter((ye,Ae)=>Ae!==re));},maxSizeMB:10,maxFiles:20}):jsx(dr,{cardId:a?.id||"new",attachments:g,onUpload:b&&a?.id?z=>b(a.id,z):void 0,onDelete:C,maxSizeMB:10,maxFiles:20}),m==="create"&&ze.length>0&&jsxs("p",{className:"text-xs mt-1",style:{color:c.textTertiary},children:[ze.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:O.isMilestone,onChange:z=>Me("isMilestone",z.target.checked),className:"w-4 h-4 rounded",style:{accentColor:c.accent},disabled:n}),jsx(Milestone,{className:"w-4 h-4 text-yellow-500"}),jsx("span",{className:"text-sm",style:{color:c.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:c.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:c.bgSecondary},children:r.filter(z=>z.id!==a?.id).map(z=>{let re=O.dependencies?.includes(z.id);return jsx("button",{type:"button",onClick:()=>{let fe=re?(O.dependencies||[]).filter(ye=>ye!==z.id):[...O.dependencies||[],z.id];Me("dependencies",fe);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:re?`${c.accent}30`:c.bgPrimary,color:re?c.accent:c.textSecondary,border:`1px solid ${re?c.accent:c.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 ${c.border}`},children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:c.textSecondary},onMouseEnter:z=>z.currentTarget.style.backgroundColor=c.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:c.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:m==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var Nc=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
345
345
 
346
346
  AVAILABLE COMMANDS:
347
347
  1. move_task - Move a task to a different date
@@ -386,15 +386,15 @@ If ambiguous, ask for clarification in the message field.`;function Dc(e){return
386
386
  ${Sc(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 Sc(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=Sc(e),r=t.toLowerCase().trim(),o=a.find(p=>p.name.toLowerCase()===r);if(o)return o;let s=a.find(p=>p.name.toLowerCase().includes(r));if(s)return s;let n=r.split(/\s+/);return a.find(p=>{let m=p.name.toLowerCase();return n.every(i=>m.includes(i))})}function Ci(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 b={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(b!==void 0){let C=new Date(r),T=C.getDay(),c=b-T;return c<=0&&(c+=7),C.setDate(C.getDate()+c),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),b=s[2].toLowerCase(),C=new Date(r);return b==="day"||b==="d\xEDa"||b==="dias"?C.setDate(C.getDate()+g):b==="week"||b==="semana"||b==="semanas"?C.setDate(C.getDate()+g*7):(b==="month"||b==="mes"||b==="meses")&&C.setMonth(C.getMonth()+g),C}if(a.match(/(\d{4})-(\d{2})-(\d{2})/))return new Date(a);let p=a.match(/(\d{1,2})\/(\d{1,2})\/(\d{4})/);if(p&&p[1]&&p[2]&&p[3]){let g=parseInt(p[1],10),b=parseInt(p[2],10)-1,C=parseInt(p[3],10);return new Date(C,b,g)}let m={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),b=m[i[2].toLowerCase()],C=i[3]?parseInt(i[3],10):r.getFullYear();if(b!==void 0)return new Date(C,b,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()],b=parseInt(d[2],10),C=d[3]?parseInt(d[3],10):r.getFullYear();if(g!==void 0)return new Date(C,g,b)}return null}function Ti(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 Ni(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 Ec(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 Pc(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=Ci(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 b=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()+b),{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=Ti(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 b=new Date(d.endDate);return b.setDate(b.getDate()+g),{type:"resize_task",taskId:d.id,taskName:d.name,updates:{endDate:b},message:`Extended "${d.name}" by ${g} days. New end date: ${b.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=Ni(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 p=a.match(/(?:link|vincular|conectar)\s+["""]?(.+?)["""]?\s+(?:to|a|con)\s+["""]?(.+?)["""]?$/i);if(p&&p[1]&&p[2]){let i=p[1].trim(),u=p[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 m=a.match(/(?:delete|eliminar|borrar|remove|quitar)\s+["""]?(.+?)["""]?$/i);if(m&&m[1]){let i=m[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 Mc(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 z0(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 U0(e){switch(e){case "todo":return "TODO";case "in-progress":return "IN_PROGRESS";case "completed":return "DONE";default:return e||"TODO"}}function Rn(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=>Rn(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},p=n(e.startDate),m=n(e.endDate),i=e.metadata?.isMilestone===true||p&&m&&Math.abs(m.getTime()-p.getTime())<=864e5;return {id:e.id,name:e.title,startDate:p,endDate:m,progress:e.progress||0,status:z0(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 Ac(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:U0(e.status),isExpanded:e.isExpanded,isMilestone:e.isMilestone,isCriticalPath:e.isCriticalPath}}}function Fc(e,t=[]){return e.filter(r=>!r.metadata?.parentCardId).map(r=>Rn(r,e,t))}var Di={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"}},Si={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"}},$n={en:Di,es:Si};function Ei(e){return $n[e]||$n.en}function On(e,t){let a=Ei(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 Rc(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(...Rc(r.subtasks,t+1));return a}function J0({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 $c({tasks:e,config:t={},callbacks:a={},isLoading:r=false,error:o,className:s,style:n}){let{theme:p="dark",locale:m="en",customTranslations:i,showSearch:u=true,showHierarchy:d=true}=t,g=On(m,i),b=p==="dark",[C,T]=useState(new Set),[c,h]=useState("startDate"),[v,l]=useState("asc"),[k,y]=useState("");useMemo(()=>{let A=new Set;function N(U){for(let $ of U)$.subtasks?.length&&(A.add($.id),N($.subtasks));}N(e),T(A);},[e]);let S=useCallback(A=>{T(N=>{let U=new Set(N);return U.has(A)?U.delete(A):U.add(A),U}),a.onTaskToggleExpand?.(A);},[a]),w=useCallback(A=>{c===A?l(N=>N==="asc"?"desc":"asc"):(h(A),l("asc")),a.onSortChange?.({column:A,direction:v==="asc"?"desc":"asc"});},[c,v,a]),x=useMemo(()=>{let A=Rc(e);if(k.trim()){let U=k.toLowerCase();A=A.filter($=>$.name.toLowerCase().includes(U));}let N=[];for(let U of A){let $=U.level===0;U.level>0&&($=true),($||k.trim())&&N.push(U);}return k.trim()&&N.sort((U,$)=>{let _,q;switch(c){case "name":_=U.name.toLowerCase(),q=$.name.toLowerCase();break;case "startDate":_=U.startDate?.getTime()||0,q=$.startDate?.getTime()||0;break;case "endDate":_=U.endDate?.getTime()||0,q=$.endDate?.getTime()||0;break;case "progress":_=U.progress||0,q=$.progress||0;break;case "status":_=U.status||"todo",q=$.status||"todo";break;default:return 0}return _<q?v==="asc"?-1:1:_>q?v==="asc"?1:-1:0}),N},[e,k,c,v]),R=A=>A?(A instanceof Date?A:new Date(A)).toLocaleDateString(m==="es"?"es-ES":"en-US",{day:"numeric",month:"short"}):"-";return r?jsx("div",{className:f("flex-1 flex items-center justify-center",b?"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",b?"text-[#9CA3AF]":"text-gray-600"),children:[g.empty.noTasks,"..."]})]})}):o?jsx("div",{className:f("flex-1 flex items-center justify-center",b?"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",b?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:f("text-sm",b?"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",b?"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",b?"text-white":"text-gray-900"),children:g.empty.noTasks}),jsx("p",{className:f("text-sm",b?"text-[#9CA3AF]":"text-gray-600"),children:g.empty.addFirstTask})]})}):jsxs("div",{className:f("flex-1 flex flex-col w-full h-full overflow-hidden",b?"bg-[#0F1117]":"bg-white",s),style:n,children:[jsx("div",{className:f("flex-shrink-0 px-6 py-4 border-b",b?"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",b?"text-[#9CA3AF]":"text-gray-400")}),jsx("input",{type:"text",value:k,onChange:A=>y(A.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",b?"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",b?"text-[#9CA3AF]":"text-gray-600"),children:[x.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",b?"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:()=>w("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:()=>w("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:()=>w("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:()=>w("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:()=>w("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:x.map((A,N)=>{let U=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:f("grid grid-cols-12 gap-4 px-6 py-3 border-b transition-colors cursor-pointer",b?"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:$=>{$.stopPropagation(),S(A.id);},className:f("p-0.5 rounded",b?"hover:bg-white/10":"hover:bg-gray-200"),children:U?jsx(ChevronDown,{className:f("w-4 h-4",b?"text-[#9CA3AF]":"text-gray-400")}):jsx(ChevronRight,{className:f("w-4 h-4",b?"text-[#9CA3AF]":"text-gray-400")})}),d&&!A.hasChildren&&jsx("div",{className:"w-5"}),jsx("button",{onClick:$=>{$.stopPropagation(),a.onTaskUpdate?.({...A,progress:A.progress===100?0:100,status:A.progress===100?"todo":"completed"});},className:"flex-shrink-0",children:jsx(J0,{status:A.status,progress:A.progress})}),jsx("span",{className:f("truncate",b?"text-white":"text-gray-900",A.progress===100&&(b?"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:f("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":b?"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:f("col-span-2 flex items-center gap-1 text-sm",b?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Calendar,{className:"w-4 h-4"}),R(A.startDate)]}),jsxs("div",{className:f("col-span-2 flex items-center gap-1 text-sm",b?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Clock,{className:"w-4 h-4"}),R(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:f("flex-1 h-1.5 rounded-full overflow-hidden",b?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:f("h-full rounded-full transition-all",A.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${A.progress||0}%`}})}),jsxs("span",{className:f("text-xs w-8",b?"text-[#9CA3AF]":"text-gray-500"),children:[A.progress||0,"%"]})]})})]},A.id)})}),x.length===0&&k&&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",b?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:f(b?"text-[#9CA3AF]":"text-gray-600"),children:g.empty.noResults})]})})]})]})}var Pi={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"},Mi={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"},Ai={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:Pi,light:Mi,neutral:Ai};function Oc(e){return Un[e]||Un.dark}var Fi={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"}},Li={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"}},Hn={en:Fi,es:Li};function Ho(e){return Hn[e]||Hn.en}function Wn(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 zc(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 Uc(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 hh(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 zi(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 Vc({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 Kc({tasks:e,config:t={},callbacks:a={},initialDate:r,isLoading:o=false,error:s,className:n,style:p,availableTags:m=[],onCreateTag:i,attachmentsByTask:u,comments:d,onAddComment:g,currentUser:b,onTaskOpen:C}){let{theme:T="dark",locale:c="en",customTranslations:h}=t,v=Wn(c,h),l=T==="dark",k={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)"},[y,S]=useState(r||new Date),[w,x]=useState(null),[R,A]=useState(null),[N,U]=useState(null),[$,_]=useState(new Date),[q,pe]=useState({}),Te=4,Ze=3,[Oe,Be]=useState(false),[L,B]=useState(false),[D,W]=useState(false),[Y,O]=useState(false),[ie,ve]=useState(null),[Ee,fe]=useState(""),[We,Re]=useState(void 0),[Le,ze]=useState(null),[yt,nt]=useState(false),[z,ne]=useState(false),[le,we]=useState(null),[$e,et]=useState(false),[vt,Pe]=useState(new Date),[Vt,ft]=useState(false),[st,mt]=useState(false),[Lt,va]=useState(false),[ee,te]=useState(""),[it,ae]=useState(false),[E,X$1]=useState(""),[be,Ae]=useState(false),Ge=useCallback(()=>{S(new Date(y.getFullYear(),y.getMonth()-1,1));},[y]),Ye=useCallback(()=>{S(new Date(y.getFullYear(),y.getMonth()+1,1));},[y]),Ue=useCallback(()=>{S(new Date);},[]),ot=useMemo(()=>{let P=y.getFullYear(),ye=y.getMonth(),Q=new Date(P,ye,1),Me=new Date(P,ye+1,0),lt=Q.getDay(),se=Me.getDate(),He=hh(e),St=new Date;St.setHours(0,0,0,0);let Fe=[],Bt=lt,ut=new Date(P,ye,0).getDate();for(let Wt=Bt-1;Wt>=0;Wt--){let Ke=new Date(P,ye-1,ut-Wt);Fe.push({date:Ke,isCurrentMonth:false,isToday:false,isWeekend:Ke.getDay()===0||Ke.getDay()===6,events:He.filter(Et=>zi(Ke,Et)).map(Et=>({id:Et.id,title:Et.name,start:Et.startDate,end:Et.endDate,task:Et}))});}for(let Wt=1;Wt<=se;Wt++){let Ke=new Date(P,ye,Wt),Et=Ke.getTime()===St.getTime();Fe.push({date:Ke,isCurrentMonth:true,isToday:Et,isWeekend:Ke.getDay()===0||Ke.getDay()===6,events:He.filter(da=>zi(Ke,da)).map(da=>({id:da.id,title:da.name,start:da.startDate,end:da.endDate,task:da}))});}let fa=42-Fe.length;for(let Wt=1;Wt<=fa;Wt++){let Ke=new Date(P,ye+1,Wt);Fe.push({date:Ke,isCurrentMonth:false,isToday:false,isWeekend:Ke.getDay()===0||Ke.getDay()===6,events:He.filter(Et=>zi(Ke,Et)).map(Et=>({id:Et.id,title:Et.name,start:Et.startDate,end:Et.endDate,task:Et}))});}return Fe},[y,e]),pt=c==="es"?["Dom","Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b"]:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],V=y.toLocaleDateString(c==="es"?"es-ES":"en-US",{month:"long",year:"numeric"}),re=useCallback((P,ye)=>{if(!w)return;let Q={...w,[P]:ye};x(Q),a.onTaskUpdate?.(Q);},[w,a]),Se=useCallback(P=>{if(!w)return;let ye=w.progress||0;P==="completed"?ye=100:P==="todo"&&(ye=0);let Q={...w,status:P,progress:ye};x(Q),a.onTaskUpdate?.(Q),Be(false);},[w,a]),qe=useCallback((P,ye)=>{if(!w)return;let Q={...w,startDate:P,endDate:ye};x(Q),a.onTaskUpdate?.(Q);},[w,a]),_e=useCallback(()=>{Be(false),B(false),W(false),U(null),va(false),te(""),ae(false);},[]),G=useCallback(async P=>{if(P.preventDefault(),P.stopPropagation(),ft(false),!w||!a.onUploadAttachments)return;let ye=Array.from(P.dataTransfer.files);if(ye.length!==0){mt(true);try{await a.onUploadAttachments(w.id,ye);}finally{mt(false);}}},[w,a]),de=useCallback(async P=>{if(!w||!a.onUploadAttachments||!P.target.files)return;let ye=Array.from(P.target.files);if(ye.length!==0){mt(true);try{await a.onUploadAttachments(w.id,ye);}finally{mt(false);}P.target.value="";}},[w,a]),Ie=useCallback(P=>{P.preventDefault(),P.stopPropagation(),ft(true);},[]),At=useCallback(P=>{P.preventDefault(),P.stopPropagation(),ft(false);},[]),tt=useCallback(P=>P<1024?`${P} B`:P<1024*1024?`${(P/1024).toFixed(1)} KB`:`${(P/(1024*1024)).toFixed(1)} MB`,[]),xa=useCallback(P=>P.startsWith("image/")?Image:P.includes("pdf")||P.includes("document")?FileText:File,[]),ga=useMemo(()=>!w||!u?[]:u.get(w.id)||[],[w,u]);return o?jsx("div",{className:f("flex-1 flex items-center justify-center",l?"bg-[#0F1117]":"bg-white",n),style:p,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:[v.labels.noEvents,"..."]})]})}):s?jsx("div",{className:f("flex-1 flex items-center justify-center",l?"bg-[#0F1117]":"bg-white",n),style:p,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:p,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:v.labels.noEvents}),jsx("p",{className:f("text-sm",l?"text-[#9CA3AF]":"text-gray-600"),children:v.labels.newTask})]})}):jsxs("div",{className:f("flex-1 flex flex-col w-full h-full overflow-auto",l?"bg-[#0F1117]":"bg-white",n),style:p,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:V}),jsx("button",{onClick:Ue,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:v.navigation.today})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("button",{onClick:Ge,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:Ye,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:pt.map(P=>jsx("div",{className:f("py-2 text-center text-xs font-medium uppercase",l?"text-[#9CA3AF]":"text-gray-500"),children:P},P))}),jsx("div",{className:f("grid grid-cols-7 auto-rows-min gap-px rounded-lg",l?"bg-[#2D2D2D]":"bg-gray-300"),children:ot.map((P,ye)=>{let Q=P.date.getDay()===0||P.date.getDay()===6;return jsxs("div",{className:f("min-h-[120px] p-2 transition-colors flex flex-col relative group",l?Q?"bg-[#1C1F26]":P.isCurrentMonth?"bg-[#13161B]":"bg-[#0D0F13]":Q?"bg-gray-100":P.isCurrentMonth?"bg-white":"bg-gray-50",P.isToday&&"ring-2 ring-[#3B82F6] ring-inset"),children:[(()=>{let Me=q[ye]||Te,lt=P.events.slice(0,Me),se=P.events.length-Me;return jsxs("div",{className:"space-y-1 flex-1",children:[lt.map(He=>jsx("div",{className:"relative group",children:jsxs(motion.button,{onClick:()=>{x(He.task),a.onEventClick?.(He),C?.(He.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",He.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(Vc,{task:He.task}),jsx("span",{className:"truncate",children:He.title})]})},He.id)),se>0&&jsxs("button",{onClick:He=>{He.stopPropagation(),pe(St=>({...St,[ye]:Me+Ze}));},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:["+",se," ",c==="es"?"M\xC1S":"MORE"]}),Me>Te&&P.events.length>Te&&jsx("button",{onClick:He=>{He.stopPropagation(),pe(St=>({...St,[ye]:Te}));},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:c==="es"?"MENOS":"LESS"})]})})(),jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1",children:[(()=>{let Me=ye>=28,lt=ye%7>=5;return jsxs("div",{className:"relative",children:[jsx("button",{onClick:se=>{se.stopPropagation(),ie===ye?ve(null):(ve(ye),fe(""),Re(void 0),ze(null),we(null),nt(false),ne(false),et(false),Pe(P.date));},className:f("w-5 h-5 rounded flex items-center justify-center transition-all",ie===ye?"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",ie===ye&&"rotate-45")})}),jsx(AnimatePresence,{children:ie===ye&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{ve(null),fe(""),Re(void 0),ze(null),we(null),nt(false),ne(false),et(false);}}),jsxs(motion.div,{initial:{opacity:0,y:Me?-5:5,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:Me?-5:5,scale:.95},transition:{duration:.12},className:f("absolute w-[320px] rounded-lg shadow-2xl z-50",Me?"bottom-full mb-1":"top-full mt-1",lt?"right-0":"left-0",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:se=>{se.stopPropagation(),nt(false),ne(false),et(false);},children:[jsx("div",{className:"p-2.5",children:jsx("input",{type:"text",value:Ee,onChange:se=>fe(se.target.value),placeholder:c==="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:se=>{if(se.key==="Enter"&&Ee.trim()){let He=t.availableUsers?.find(Fe=>Fe.id===Le),St=le||P.date;a.onTaskCreate?.({name:Ee.trim(),startDate:St,endDate:St,priority:We,assignees:He?[He]:void 0}),fe(""),Re(void 0),ze(null),we(null),ve(null);}se.key==="Escape"&&(ve(null),fe(""),Re(void 0),ze(null),we(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:se=>{se.stopPropagation(),nt(!yt),ne(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:se=>se.stopPropagation(),children:[{id:"urgent",label:c==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:c==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:c==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:c==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:c==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(se=>jsxs("button",{onClick:()=>{Re(se.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===se.id&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:f("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(),et(!$e),nt(false),ne(false),Pe(le||P.date);},className:f("flex items-center gap-1 text-xs px-1.5 py-0.5 rounded transition-colors",le?"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"}),(le||P.date).toLocaleDateString(c==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})]}),jsx(AnimatePresence,{children:$e&&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:se=>se.stopPropagation(),children:[jsx("div",{className:f("w-40 py-2 border-r",l?"border-white/10":"border-gray-200"),children:(()=>{let se=new Date,He=new Date(se);He.setDate(se.getDate()+1);let St=new Date(se);St.setDate(se.getDate()+((6-se.getDay()+7)%7||7));let Fe=new Date(se);Fe.setDate(se.getDate()+((1-se.getDay()+7)%7||7));let Bt=new Date(se);Bt.setDate(se.getDate()+14);let ut=new Date(se);return ut.setDate(se.getDate()+28),[{label:c==="es"?"Hoy":"Today",date:se,display:se.toLocaleDateString(c==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:c==="es"?"Ma\xF1ana":"Tomorrow",date:He,display:He.toLocaleDateString(c==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:c==="es"?"Este fin de semana":"This weekend",date:St,display:c==="es"?"s\xE1b.":"sat."},{label:c==="es"?"Pr\xF3xima semana":"Next week",date:Fe,display:c==="es"?"lun.":"mon."},{label:c==="es"?"2 semanas":"2 weeks",date:Bt,display:Bt.toLocaleDateString(c==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:c==="es"?"4 semanas":"4 weeks",date:ut,display:ut.toLocaleDateString(c==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Wt,Ke)=>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:()=>{we(Wt.date),et(false);},children:[jsx("span",{children:Wt.label}),jsx("span",{className:f("text-[10px]",l?"text-[#6B7280]":"text-gray-400"),children:Wt.display})]},Ke))})()}),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:vt.toLocaleDateString(c==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-0.5",children:[jsx("button",{onClick:()=>Pe(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:c==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>Pe(new Date(vt.getFullYear(),vt.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:()=>Pe(new Date(vt.getFullYear(),vt.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:(c==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(se=>jsx("div",{className:f("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=vt.getFullYear(),He=vt.getMonth(),St=new Date(se,He,1).getDay(),Fe=new Date(se,He+1,0).getDate(),Bt=new Date(se,He,0).getDate(),ut=new Date,fa=[];for(let Ke=St-1;Ke>=0;Ke--)fa.push({dayNum:Bt-Ke,isCurrentMonth:false,date:new Date(se,He-1,Bt-Ke)});for(let Ke=1;Ke<=Fe;Ke++)fa.push({dayNum:Ke,isCurrentMonth:true,date:new Date(se,He,Ke)});let Wt=42-fa.length;for(let Ke=1;Ke<=Wt;Ke++)fa.push({dayNum:Ke,isCurrentMonth:false,date:new Date(se,He+1,Ke)});return fa.map((Ke,Et)=>{let da=Ke.date.toDateString()===ut.toDateString(),yr=(le||P.date).toDateString()===Ke.date.toDateString();return jsx("button",{className:f("w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",!Ke.isCurrentMonth&&(l?"text-[#4B5563]":"text-gray-300"),Ke.isCurrentMonth&&(l?"text-white":"text-gray-900"),da&&"ring-1 ring-[#3B82F6]",yr&&"bg-[#7C3AED] text-white",!yr&&(l?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{we(Ke.date),et(false);},children:Ke.dayNum},Et)})})()})]})]})})]}),jsxs("div",{className:"relative",children:[jsx("button",{onClick:se=>{se.stopPropagation(),ne(!z),nt(false);},className:f("p-1 rounded transition-colors",Le?"text-[#7C3AED] bg-[#7C3AED]/20":l?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:Le?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===Le)?.color||"#7C3AED"},children:t.availableUsers?.find(se=>se.id===Le)?.initials||t.availableUsers?.find(se=>se.id===Le)?.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:se=>se.stopPropagation(),children:[jsxs("button",{onClick:()=>{ze(null),ne(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",!Le&&(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:c==="es"?"Sin asignar":"Unassigned"})]}),t.availableUsers?.map(se=>jsxs("button",{onClick:()=>{ze(se.id),ne(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",Le===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:f("px-3 py-2 text-xs",l?"text-[#6B7280]":"text-gray-400"),children:c==="es"?"No hay usuarios disponibles":"No users available"})]})})]})]}),jsx("button",{onClick:()=>{if(Ee.trim()){let se=t.availableUsers?.find(St=>St.id===Le),He=le||P.date;a.onTaskCreate?.({name:Ee.trim(),startDate:He,endDate:He,priority:We,assignees:se?[se]:void 0}),fe(""),Re(void 0),ze(null),we(null),ve(null);}},disabled:!Ee.trim(),className:f("px-2.5 py-1 rounded text-xs font-medium transition-colors",Ee.trim()?"bg-[#7C3AED] hover:bg-[#6D28D9] text-white":l?"bg-white/5 text-[#4B5563]":"bg-gray-100 text-gray-400"),children:c==="es"?"Guardar":"Save"})]})]})]})})]})})(),jsx("span",{className:f("text-sm font-medium",P.isToday?"text-[#3B82F6]":P.isCurrentMonth?l?"text-white":"text-gray-900":l?"text-[#6B7280]":"text-gray-400"),children:P.date.getDate()})]})]},ye)})})]})}),jsx(AnimatePresence,{children:w&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>{x(null),X$1("");},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:[c==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:f("text-xs font-mono",l?"text-[#6B7280]":"text-gray-400"),children:w.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:()=>{x(null),X$1("");},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 P=w.progress===100?0:100,Q={...w,progress:P,status:P===100?"completed":"todo"};x(Q),a.onTaskUpdate?.(Q);},className:f("mt-1 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors",w.progress===100?"bg-green-500 border-green-500":l?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:w.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("h2",{className:f("text-xl font-semibold flex-1",w.progress===100?"line-through text-[#6B7280]":l?"text-white":"text-gray-900"),children:w.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:c==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{_e(),Be(!Oe);},className:f("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",w.progress===100||w.status==="completed"?"bg-green-500/20 text-green-400":w.progress&&w.progress>0||w.status==="in-progress"?"bg-blue-500/20 text-blue-400":l?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:w.progress===100||w.status==="completed"?c==="es"?"COMPLETADO":"DONE":w.progress&&w.progress>0||w.status==="in-progress"?c==="es"?"EN PROGRESO":"IN PROGRESS":c==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:Oe&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Be(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:c==="es"?"Por hacer":"To Do",color:"bg-white/10 text-white"},{id:"in-progress",label:c==="es"?"En progreso":"In Progress",color:"bg-blue-500/20 text-blue-400"},{id:"completed",label:c==="es"?"Completado":"Done",color:"bg-green-500/20 text-green-400"}].map(P=>jsxs("button",{onClick:()=>Se(P.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",(w.status===P.id||P.id==="completed"&&w.progress===100||P.id==="in-progress"&&w.progress&&w.progress>0&&w.progress<100||P.id==="todo"&&(!w.progress||w.progress===0)&&w.status!=="in-progress"&&w.status!=="completed")&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:f("w-2 h-2 rounded-full",P.id==="completed"?"bg-green-500":P.id==="in-progress"?"bg-blue-500":"bg-gray-400")}),jsx("span",{className:l?"text-white":"text-gray-900",children:P.label})]},P.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:c==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{Be(false),B(false),U(null),W(!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:[w.assignees&&w.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[w.assignees.slice(0,3).map((P,ye)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:P.color||"#8B5CF6"},title:P.name,children:P.initials||P.name.slice(0,2).toUpperCase()},ye)),w.assignees.length>3&&jsxs("span",{className:f("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:["+",w.assignees.length-3]})]}):jsx("span",{className:f("text-sm",l?"text-[#6B7280]":"text-gray-400"),children:c==="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:()=>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-[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(P=>{let ye=w.assignees?.some(Q=>Q.name===P.name);return jsxs("button",{onClick:()=>{let Q=w.assignees||[],Me;ye?Me=Q.filter(lt=>lt.name!==P.name):Me=[...Q,{name:P.name,avatar:P.avatar,initials:P.initials||P.name.slice(0,2).toUpperCase(),color:P.color||"#8B5CF6"}],re("assignees",Me);},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",ye&&(l?"bg-white/5":"bg-gray-50")),children:[P.avatar?jsx("img",{src:P.avatar,alt:P.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:P.color||"#8B5CF6"},children:P.initials||P.name.slice(0,2).toUpperCase()}),jsx("span",{className:f("flex-1 text-left",l?"text-white":"text-gray-900"),children:P.name}),ye&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},P.id||P.name)}):jsx("div",{className:f("px-3 py-4 text-sm text-center",l?"text-[#6B7280]":"text-gray-400"),children:c==="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:c==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{U(N?null:"start"),_(w.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:[w.startDate?.toLocaleDateString(c==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(c==="es"?"Inicio":"Start"),jsx("span",{className:f("mx-1",l?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),w.endDate?.toLocaleDateString(c==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(c==="es"?"Fin":"End"),(w.startDate||w.endDate)&&jsx(X,{className:"w-3.5 h-3.5 ml-1 opacity-50 hover:opacity-100",onClick:P=>{P.stopPropagation();}})]}),jsx(AnimatePresence,{children:N&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>U(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:P=>P.stopPropagation(),children:[jsxs("div",{className:f("w-44 py-2 border-r",l?"border-white/10":"border-gray-200"),children:[(()=>{let P=new Date,ye=new Date(P);ye.setDate(P.getDate()+1);let Q=new Date(P);Q.setDate(P.getDate()+((6-P.getDay()+7)%7||7));let Me=new Date(P);Me.setDate(P.getDate()+((1-P.getDay()+7)%7||7));let lt=new Date(P);lt.setDate(P.getDate()+(6-P.getDay()+7)%7+7);let se=new Date(P);se.setDate(P.getDate()+14);let He=new Date(P);return He.setDate(P.getDate()+28),[{label:c==="es"?"Hoy":"Today",date:P,display:P.toLocaleDateString(c==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:c==="es"?"Ma\xF1ana":"Tomorrow",date:ye,display:ye.toLocaleDateString(c==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:c==="es"?"Este fin de semana":"This weekend",date:Q,display:c==="es"?"s\xE1b.":"sat."},{label:c==="es"?"Pr\xF3xima semana":"Next week",date:Me,display:c==="es"?"lun.":"mon."},{label:c==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:lt,display:lt.toLocaleDateString(c==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:c==="es"?"2 semanas":"2 weeks",date:se,display:se.toLocaleDateString(c==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:c==="es"?"4 semanas":"4 weeks",date:He,display:He.toLocaleDateString(c==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Fe,Bt)=>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 ut=w.endDate&&Fe.date>w.endDate?Fe.date:w.endDate;qe(Fe.date,ut),U("end");}else {let ut=w.startDate&&Fe.date<w.startDate?Fe.date:w.startDate;qe(ut,Fe.date),U(null);}},children:[jsx("span",{children:Fe.label}),jsx("span",{className:f("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:Fe.display})]},Bt))})(),jsx("div",{className:f("border-t mt-2 pt-2",l?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{qe(void 0,void 0),U(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:c==="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"?c==="es"?"\u{1F4C5} Selecciona fecha de inicio":"\u{1F4C5} Select start date":c==="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:$.toLocaleDateString(c==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>_(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:c==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>_(new Date($.getFullYear(),$.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:()=>_(new Date($.getFullYear(),$.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:(c==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(P=>jsx("div",{className:f("w-8 h-8 flex items-center justify-center text-xs",l?"text-[#6B7280]":"text-gray-400"),children:P},P))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let P=$.getFullYear(),ye=$.getMonth(),Q=new Date(P,ye,1).getDay(),Me=new Date(P,ye+1,0).getDate(),lt=new Date(P,ye,0).getDate(),se=new Date,He=[];for(let Fe=Q-1;Fe>=0;Fe--)He.push({day:lt-Fe,isCurrentMonth:false,date:new Date(P,ye-1,lt-Fe)});for(let Fe=1;Fe<=Me;Fe++)He.push({day:Fe,isCurrentMonth:true,date:new Date(P,ye,Fe)});let St=42-He.length;for(let Fe=1;Fe<=St;Fe++)He.push({day:Fe,isCurrentMonth:false,date:new Date(P,ye+1,Fe)});return He.map((Fe,Bt)=>{let ut=Fe.date.toDateString()===se.toDateString(),fa=w.startDate?.toDateString()===Fe.date.toDateString(),Wt=w.endDate?.toDateString()===Fe.date.toDateString(),Ke=fa||Wt,Et=w.startDate&&w.endDate&&Fe.date>=w.startDate&&Fe.date<=w.endDate;return jsx("button",{className:f("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!Fe.isCurrentMonth&&(l?"text-[#4B5563]":"text-gray-300"),Fe.isCurrentMonth&&(l?"text-white":"text-gray-900"),ut&&"ring-2 ring-[#3B82F6]",fa&&"bg-[#3B82F6] text-white",Wt&&!fa&&"bg-[#7C3AED] text-white",Et&&!Ke&&(l?"bg-[#7C3AED]/20":"bg-purple-100"),!Ke&&(l?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{let da=new Date(Fe.date);if(N==="start"){let yr=w.endDate&&da>w.endDate?da:w.endDate;qe(da,yr),U("end");}else {let yr=w.startDate&&da<w.startDate?da:w.startDate;qe(yr,da),U(null);}},children:Fe.day},Bt)})})()})]})]})]})})]}),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:c==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{_e(),B(!L);},className:f("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",w.priority==="high"||w.priority==="urgent"?"bg-red-500/20 text-red-400":w.priority==="medium"?"bg-yellow-500/20 text-yellow-400":w.priority==="low"?"bg-green-500/20 text-green-400":l?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:w.priority?w.priority==="high"||w.priority==="urgent"?c==="es"?"Urgente":"Urgent":w.priority==="medium"?c==="es"?"Media":"Medium":c==="es"?"Baja":"Low":c==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:L&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>B(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:c==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:c==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:c==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:c==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:c==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(P=>jsxs("button",{onClick:()=>{re("priority",P.id),B(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",w.priority===P.id&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:f("w-2 h-2 rounded-full",P.color)}),jsx("span",{className:l?"text-white":"text-gray-900",children:P.label})]},P.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:c==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:f("text-sm",l?"text-white":"text-gray-900"),children:w.startDate&&w.endDate?`${Math.ceil((w.endDate.getTime()-w.startDate.getTime())/(1e3*60*60*24))} ${c==="es"?"d\xEDas":"days"}`:c==="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:c==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[Y?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:w.progress||0,onChange:P=>{let ye=parseInt(P.target.value),Q=w.status;ye===100?Q="completed":ye>0?Q="in-progress":Q="todo";let Me={...w,progress:ye,status:Q};x(Me),a.onTaskUpdate?.(Me);},onBlur:()=>O(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:()=>O(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",w.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${w.progress||0}%`}})}),jsxs("span",{className:f("text-sm font-medium min-w-[40px]",l?"text-white":"text-gray-900"),children:[w.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:c==="es"?"Etiquetas":"Tags"}),jsx(nr,{selectedTags:w.tags||[],availableTags:m,onChange:P=>{re("tags",P);},onCreateTag:i,theme:k})]}),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:c==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[w.dependencies&&w.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:w.dependencies.map(P=>{let ye=e.find(Q=>Q.id===P);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:[ye?.name||P.slice(0,8),jsx("button",{onClick:()=>{let Q=(w.dependencies||[]).filter(Me=>Me!==P);re("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"})})]},P)})}),jsxs("button",{onClick:()=>{_e(),va(!Lt);},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:c==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:Lt&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{va(false),te("");}}),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:ee,onChange:P=>te(P.target.value),placeholder:c==="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(P=>P.id!==w.id).filter(P=>ee===""||P.name.toLowerCase().includes(ee.toLowerCase())).map(P=>{let ye=w.dependencies?.includes(P.id);return jsxs("button",{onClick:()=>{let Q=w.dependencies||[],Me;ye?Me=Q.filter(lt=>lt!==P.id):Me=[...Q,P.id],re("dependencies",Me);},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",ye&&(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",ye?"bg-blue-500 border-blue-500":l?"border-white/30":"border-gray-300"),children:ye&&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:P.name}),jsx("span",{className:f("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:P.id.slice(0,8)})]})]},P.id)}):jsx("div",{className:f("px-3 py-4 text-sm text-center",l?"text-[#6B7280]":"text-gray-500"),children:c==="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:()=>{_e(),ae(!it);},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:w.color||"#6366F1"}}),jsx("span",{className:f("text-sm",l?"text-white":"text-gray-900"),children:sr.find(P=>P.value===w.color)?.name||(c==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:f("w-3 h-3",l?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:it&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>ae(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(P=>{let ye=w.color===P.value;return jsx("button",{onClick:()=>{re("color",P.value),ae(false);},className:f("w-7 h-7 rounded-full flex items-center justify-center transition-all",ye&&"ring-2 ring-offset-2",l?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:P.value,outlineColor:ye?P.value:void 0},title:P.name,children:ye&&jsx(Check,{className:"w-3.5 h-3.5 text-white"})},P.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:c==="es"?"Hito":"Milestone"}),jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:w.isMilestone||false,onChange:P=>re("isMilestone",P.target.checked),className:f("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",w.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:c==="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:c==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:w.description||"",onChange:P=>re("description",P.target.value),placeholder:c==="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"}),c==="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:c==="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"}),c==="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:c==="es"?"Agregar subtarea":"Add subtask"}),w.subtasks&&w.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:w.subtasks.map(P=>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",P.progress===100?"bg-green-500 border-green-500":l?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:P.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:f("text-sm",P.progress===100?"line-through text-[#6B7280]":l?"text-white":"text-gray-900"),children:P.name})]},P.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"}),c==="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:c==="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"}),c==="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:[c==="es"?"Adjuntos":"Attachments",ga.length>0&&jsxs("span",{className:f("ml-2 text-xs font-normal",l?"text-[#6B7280]":"text-gray-400"),children:["(",ga.length,")"]})]}),ga.length>0&&jsx("div",{className:"space-y-2 mb-4",children:ga.map(P=>{let ye=xa(P.type),Q=P.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&&P.thumbnailUrl?jsx("img",{src:P.thumbnailUrl,alt:P.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(ye,{className:f("w-5 h-5",l?"text-[#9CA3AF]":"text-gray-500")})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("a",{href:P.url,target:"_blank",rel:"noopener noreferrer",className:f("text-sm font-medium truncate block hover:underline",l?"text-white":"text-gray-900"),children:P.name}),jsx("p",{className:f("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:tt(P.size)})]}),a.onDeleteAttachment&&jsx("button",{onClick:()=>a.onDeleteAttachment?.(P.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:c==="es"?"Eliminar":"Delete",children:jsx(Trash2,{className:"w-4 h-4"})})]},P.id)})}),jsxs("div",{onDragOver:Ie,onDragLeave:At,onDrop:G,className:f("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",Vt?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",st&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:de,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!a.onUploadAttachments||st}),st?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:c==="es"?"Subiendo...":"Uploading..."})]}):jsxs(Fragment,{children:[jsx(Upload,{className:f("w-6 h-6 mx-auto mb-2",Vt?"text-blue-500":l?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:f("text-sm",l?"text-[#9CA3AF]":"text-gray-500"),children:Vt?c==="es"?"Suelta los archivos aqu\xED":"Drop files here":c==="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:c==="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:[c==="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(P=>{let ye=(()=>{let Q=new Date,Me=new Date(P.createdAt),lt=Q.getTime()-Me.getTime(),se=Math.floor(lt/6e4),He=Math.floor(se/60),St=Math.floor(He/24);return se<1?c==="es"?"ahora":"now":se<60?c==="es"?`hace ${se}m`:`${se}m ago`:He<24?c==="es"?`hace ${He}h`:`${He}h ago`:c==="es"?`hace ${St}d`:`${St}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:P.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:P.user?.name||(c==="es"?"Usuario":"User")}),jsx("span",{className:f("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:ye})]}),jsx("p",{className:f("text-sm break-words",l?"text-[#9CA3AF]":"text-gray-600"),children:P.content})]})]},P.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:c==="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:[b&&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:b.color||"#8B5CF6"},children:b.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:E,onChange:P=>X$1(P.target.value),onKeyDown:async P=>{if(P.key==="Enter"&&!P.shiftKey&&w&&E.trim()&&g){P.preventDefault(),Ae(true);try{await g(w.id,E.trim()),X$1("");}finally{Ae(false);}}},placeholder:c==="es"?"Escribe un comentario...":"Write a comment...",disabled:be||!g,className:f("flex-1 bg-transparent text-sm outline-none",l?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400",(be||!g)&&"opacity-50")}),jsx("button",{onClick:async()=>{if(w&&E.trim()&&g){Ae(true);try{await g(w.id,E.trim()),X$1("");}finally{Ae(false);}}},disabled:be||!E.trim()||!g,className:f("p-1.5 rounded transition-colors",E.trim()&&g?"bg-blue-500 text-white hover:bg-blue-600":l?"text-[#6B7280]":"text-gray-400",be&&"opacity-50 cursor-not-allowed"),children:be?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:R&&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: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:R.date.toLocaleDateString(c==="es"?"es-ES":"en-US",{weekday:"long",month:"long",day:"numeric"})}),jsx("button",{onClick:()=>A(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:R.events.map(P=>jsxs("button",{onClick:()=>{A(null),x(P.task),C?.(P.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(Vc,{task:P.task}),jsx("span",{className:f("text-sm truncate flex-1",l?"text-white":"text-gray-900"),children:P.title}),P.task.priority==="high"||P.task.priority==="urgent"?jsx(Flag,{className:"w-3.5 h-3.5 text-red-400"}):null]},P.id))})]})]})})]})}var Ui={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"},Hi={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"},Wi={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:Ui,light:Hi,neutral:Wi};function Yc(e){return _n[e]||_n.dark}function yh({stack:e,cards:t,renderCard:a,onCardClick:r,onToggleExpand:o,onUnstack:s,onDeleteStack:n,className:p}){let[m,i]=useState(false),u=useMemo(()=>t.filter(b=>e.cardIds.includes(b.id)),[t,e.cardIds]),d=useMemo(()=>{let b=u.length,C=new Set(u.flatMap(h=>h.assignedUserIds||[])).size,T=u.map(h=>h.priority).filter(Boolean),c=new Set(u.flatMap(h=>h.labels||[])).size;return {totalCards:b,uniqueAssignees:C,priorities:T,labels:c}},[u]),g=()=>{o?.(e.id);};return jsxs("div",{className:f("card-stack",!e.isExpanded&&"card-stack-collapsed",p),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"]})]}),m&&jsx("div",{className:"card-stack-actions",children:jsx("button",{className:"card-stack-action",onClick:b=>{b.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(b=>jsxs("div",{className:"card-stack-card-wrapper",children:[a?jsx("div",{onClick:()=>r?.(b),children:a(b)}):jsxs("div",{className:"card-stack-default-card",onClick:()=>r?.(b),children:[jsx("h4",{children:b.title}),b.description&&jsxs("p",{children:[b.description.substring(0,100),"..."]})]}),jsx("button",{className:"card-stack-unstack-btn",onClick:C=>{C.stopPropagation(),s?.(e.id,b.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"})]})})]},b.id))})})]})}var Xc={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 Qc({events:e,filter:t,onFilterChange:a,onClearFilter:r,onEventClick:o,selectedEventId:s,config:n,className:p}){let m=useMemo(()=>({...Xc,...n}),[n]),[i,u]=useState(new Set),d=useRef(null),g=useMemo(()=>{if(!m.groupByDay)return [{date:null,events:e}];let v=new Map;return e.forEach(l=>{let k=l.timestamp.toISOString().split("T")[0],y=v.get(k);y?y.push(l):v.set(k,[l]);}),Array.from(v.entries()).sort((l,k)=>k[0].localeCompare(l[0])).map(([l,k])=>({date:new Date(l),events:k.sort((y,S)=>S.timestamp.getTime()-y.timestamp.getTime())}))},[e,m.groupByDay]),{uniqueUsers:b,uniqueTypes:C}=useMemo(()=>{let v=new Set,l=new Set;return e.forEach(k=>{v.add(k.userId),l.add(k.type);}),{uniqueUsers:Array.from(v),uniqueTypes:Array.from(l)}},[e]),T=v=>{u(l=>{let k=new Set(l);return k.has(v)?k.delete(v):k.add(v),k});},c=v=>{let k=new Date().getTime()-v.getTime(),y=Math.floor(k/6e4),S=Math.floor(k/36e5),w=Math.floor(k/864e5);return y<1?"just now":y<60?`${y}m ago`:S<24?`${S}h ago`:w<7?`${w}d ago`:v.toLocaleDateString()},h=useMemo(()=>{let v=0;return t.types&&t.types.length>0&&v++,t.users&&t.users.length>0&&v++,t.dateRange&&v++,t.searchTerm&&v++,v},[t]);return useEffect(()=>{if(s&&d.current){let v=d.current.querySelector(`[data-event-id="${s}"]`);v&&v.scrollIntoView({behavior:"smooth",block:"center"});}},[s]),e.length===0?jsxs("div",{className:f("history-timeline-empty",p),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",m.compact&&"compact",p),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:v=>{let l=v.target.value;a({...t,types:l?[l]:void 0});},children:[jsx("option",{value:"",children:"All Events"}),C.map(v=>jsxs("option",{value:v,children:[Vo(v)," ",v.replace("_"," ")]},v))]}),b.length>1&&jsxs("select",{className:"history-timeline-filter-select",value:t.users?.[0]||"",onChange:v=>{let l=v.target.value;a({...t,users:l?[l]:void 0});},children:[jsx("option",{value:"",children:"All Users"}),b.map(v=>jsx("option",{value:v,children:v},v))]}),jsx("input",{type:"text",className:"history-timeline-filter-search",placeholder:"Search history...",value:t.searchTerm||"",onChange:v=>a({...t,searchTerm:v.target.value})})]}),h>0&&jsxs("button",{className:"history-timeline-filter-clear",onClick:r,children:["Clear filters (",h,")"]})]}),jsx("div",{className:"history-timeline-container",ref:d,children:g.map(v=>jsxs("div",{className:"history-timeline-group",children:[m.groupByDay&&v.date&&jsxs("div",{className:"history-timeline-day-header",children:[jsx("span",{className:"history-timeline-day-date",children:v.date.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),jsxs("span",{className:"history-timeline-day-count",children:[v.events.length," events"]})]}),jsx("div",{className:"history-timeline-events",children:v.events.map((l,k)=>{let y=i.has(l.id),S=s===l.id,w=Jc(l.type);return jsxs("div",{"data-event-id":l.id,className:f("history-timeline-event",y&&"expanded",S&&"selected"),onClick:()=>o?.(l),children:[jsxs("div",{className:"history-timeline-line",children:[jsx("div",{className:"history-timeline-dot",style:{backgroundColor:w},children:m.showIcons&&jsx("span",{className:"history-timeline-dot-icon",children:Vo(l.type)})}),k<v.events.length-1&&jsx("div",{className:"history-timeline-connector",style:{borderColor:w}})]}),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:[m.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:m.useRelativeTime?c(l.timestamp):l.timestamp.toLocaleString()})]}),Object.keys(l.changes).length>0&&jsxs("button",{className:"history-timeline-event-toggle",onClick:x=>{x.stopPropagation(),T(l.id);},children:[y?"\u25BC":"\u25B6"," Show changes"]}),y&&jsxs("div",{className:"history-timeline-event-changes",children:[Object.entries(l.changes).map(([x,R])=>jsxs("div",{className:"history-timeline-event-change",children:[jsxs("span",{className:"history-timeline-event-change-key",children:[x,":"]}),jsxs("div",{className:"history-timeline-event-change-values",children:[jsx("span",{className:"history-timeline-event-change-from",children:JSON.stringify(R.from)}),jsx("span",{className:"history-timeline-event-change-arrow",children:"\u2192"}),jsx("span",{className:"history-timeline-event-change-to",children:JSON.stringify(R.to)})]})]},x)),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(([x,R])=>jsxs("div",{className:"history-timeline-event-metadata-item",children:[jsxs("span",{className:"history-timeline-event-metadata-key",children:[x,":"]}),jsx("span",{className:"history-timeline-event-metadata-value",children:JSON.stringify(R)})]},x))]})]})]})]},l.id)})})]},v.date?.toISOString()||"all"))})]})}function em({replayState:e,events:t,onStartReplay:a,onStopReplay:r,onTogglePlayback:o,onPrevious:s,onNext:n,onGoToEvent:p,onSpeedChange:m,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:b=>p(parseInt(b.target.value))}),jsx("div",{className:"history-replay-progress-fill",style:{width:`${g}%`}}),jsx("div",{className:"history-replay-progress-markers",children:t.map((b,C)=>jsx("div",{className:f("history-replay-progress-marker",C===e.currentIndex&&"active"),style:{left:`${C/(e.totalEvents-1)*100}%`},onClick:()=>p(C),title:_o(b)},b.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(b=>jsxs("button",{className:f("history-replay-speed-btn",e.speed===b&&"active"),onClick:()=>m(b),children:[b,"x"]},b))})]}),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(b=>jsx("span",{className:"history-replay-card-preview-label-tag",children:b},b))})]})]})]})]}):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 Gi(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 _i(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 tm(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 am(e){return ["blocks","blocked_by","depends_on","required_by","parent_of","child_of"].includes(e)}function Th(e,t,a,r,o,s=100){let n=e.map(m=>({...m,x:m.x??a/2+Math.random()*100-50,y:m.y??r/2+Math.random()*100-50,vx:0,vy:0})),p=new Map(n.map(m=>[m.id,m]));for(let m=0;m<s;m++){let i=1-m/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(b=>{if(u.id===b.id)return;let C=u.x-b.x,T=u.y-b.y,c=Math.sqrt(C*C+T*T)||1,h=o.chargeStrength*i/(c*c);u.vx+=C/c*h,u.vy+=T/c*h;});}),t.forEach(u=>{let d=p.get(typeof u.source=="string"?u.source:u.source.id),g=p.get(typeof u.target=="string"?u.target:u.target.id);if(!d||!g)return;let b=g.x-d.x,C=g.y-d.y,T=Math.sqrt(b*b+C*C)||1,c=(T-o.linkDistance)/T*o.forceStrength*i;d.vx+=b*c,d.vy+=C*c,g.vx-=b*c,g.vy-=C*c;}),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 rm({nodes:e,edges:t,config:a,filter:r,onFilterChange:o,criticalPath:s,stats:n,onInteraction:p,className:m}){let i=useRef(null),[u,d]=useState([]),[g,b]=useState(null),[C,T]=useState(null),[c,h]=useState(null),[v,l]=useState(1),[k,y]=useState({x:0,y:0});useEffect(()=>{if(e.length===0)return;let $=Th(e,t,a.width,a.height,a,150);d($);},[e,t,a]);let S=useCallback(($,_)=>{a.enableDragging&&(_.stopPropagation(),b($));},[a.enableDragging]),w=useCallback($=>{if(!g||!i.current)return;let q=i.current.getBoundingClientRect(),pe=($.clientX-q.left-k.x)/v,Te=($.clientY-q.top-k.y)/v;d(Ze=>Ze.map(Oe=>Oe.id===g?{...Oe,x:pe,y:Te,fx:pe,fy:Te}:Oe));},[g,v,k]),x=useCallback(()=>{b(null);},[]),R=useCallback(($,_)=>{_.stopPropagation(),p?.({type:"node-click",node:$,position:{x:_.clientX,y:_.clientY}});},[p]),A=useCallback(($,_)=>{_.stopPropagation(),p?.({type:"edge-click",edge:$,position:{x:_.clientX,y:_.clientY}});},[p]),N=useCallback($=>{let _=u.find(q=>q.id===$);return _?{x:_.x,y:_.y}:{x:0,y:0}},[u]),U=useCallback($=>{if($.onCriticalPath)return "#ef4444";switch(a.colorScheme){case "status":return $.card.columnId==="done"?"#10b981":"#3b82f6";case "priority":let _=$.card.priority;return _==="URGENT"?"#ef4444":_==="HIGH"?"#f59e0b":_==="MEDIUM"?"#3b82f6":"#6b7280";case "assignee":return $.card.assigneeId?"#8b5cf6":"#6b7280";default:return "#3b82f6"}},[a.colorScheme]);return e.length===0?jsxs("div",{className:f("relationships-graph-empty",m),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",m),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($=>Math.min($+.2,3)),children:"+"}),jsxs("span",{className:"relationships-graph-zoom-value",children:[Math.round(v*100),"%"]}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>l($=>Math.max($-.2,.5)),children:"\u2212"}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>{l(1),y({x:0,y:0});},children:"Reset"})]})]}),jsx("div",{className:"relationships-graph-legend",children:Array.from(new Set(t.map($=>$.type))).map($=>jsxs("div",{className:"relationships-graph-legend-item",children:[jsx("div",{className:"relationships-graph-legend-color",style:{background:Gi($)}}),jsxs("span",{className:"relationships-graph-legend-label",children:[tm($)," ",_i($)]})]},$))}),jsxs("svg",{ref:i,className:"relationships-graph-canvas",width:a.width,height:a.height,onMouseMove:w,onMouseUp:x,onMouseLeave:x,children:[jsxs("g",{transform:`translate(${k.x}, ${k.y}) scale(${v})`,children:[jsx("g",{className:"relationships-graph-edges",children:t.map($=>{let _=N(typeof $.source=="string"?$.source:$.source.id),q=N(typeof $.target=="string"?$.target:$.target.id),pe=am($.type),Te=c===$.id,Ze=$.onCriticalPath;return jsxs("g",{className:f("relationships-graph-edge",Te&&"hovered",Ze&&"critical"),onMouseEnter:()=>h($.id),onMouseLeave:()=>h(null),onClick:Oe=>A($,Oe),children:[jsx("line",{x1:_.x,y1:_.y,x2:q.x,y2:q.y,stroke:Gi($.type),strokeWidth:Ze?a.edgeWidth*2:a.edgeWidth,strokeOpacity:Te?1:.6,markerEnd:pe?"url(#arrowhead)":void 0}),a.showEdgeLabels&&Te&&jsx("text",{x:(_.x+q.x)/2,y:(_.y+q.y)/2,className:"relationships-graph-edge-label",textAnchor:"middle",children:_i($.type)})]},$.id)})}),jsx("g",{className:"relationships-graph-nodes",children:u.map($=>{let _=C===$.id,q=$.onCriticalPath;return jsxs("g",{className:f("relationships-graph-node",_&&"hovered",q&&"critical"),transform:`translate(${$.x}, ${$.y})`,onMouseDown:pe=>S($.id,pe),onMouseEnter:()=>T($.id),onMouseLeave:()=>T(null),onClick:pe=>R($,pe),children:[jsx("circle",{r:q?a.nodeSize*1.2:a.nodeSize,fill:U($),stroke:q?"#fbbf24":"#ffffff",strokeWidth:q?3:2,opacity:_?1:.9}),a.showLabels&&jsx("text",{y:a.nodeSize+20,className:"relationships-graph-node-label",textAnchor:"middle",children:$.card.title.length>20?$.card.title.substring(0,20)+"...":$.card.title})]},$.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 sm({isOpen:e,onClose:t,onPlanGenerated:a,onGeneratePlan:r,isLoading:o}){let[s,n]=useState(""),[p,m]=useState(false),[i,u]=useState(null),[d,g]=useState(null),b=useRef(null),C=p||o;useEffect(()=>{e&&b.current&&b.current.focus();},[e]),useEffect(()=>{let v=l=>{l.key==="Escape"&&!C&&T();};if(e)return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[e,C]);let T=()=>{C||(n(""),u(null),g(null),t());},c=async()=>{if(!(!s.trim()||C)){m(true),u(null),g(null);try{let v=await r(s.trim());g(v);}catch(v){u(v instanceof Error?v.message:"Failed to generate plan");}finally{m(false);}}},h=()=>{d&&(a(d),T());};return e?jsxs(ht,{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:v=>v.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((v,l)=>jsx("div",{className:"px-3 py-1.5 rounded-lg bg-white/5 border border-white/20 text-sm text-white/80",children:v.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((v,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:v.title}),v.description&&jsx("p",{className:"text-xs text-white/60 mt-1 line-clamp-2",children:v.description})]}),v.priority&&jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${v.priority==="URGENT"?"bg-red-500/20 text-red-400":v.priority==="HIGH"?"bg-orange-500/20 text-orange-400":v.priority==="MEDIUM"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:v.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:b,value:s,onChange:v=>n(v.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((v,l)=>jsx("button",{onClick:()=>n(v),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:v},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:h,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:c,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 Vi={"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 Dh={hobby:{requestsPerMonth:50,maxConcurrent:1,maxTokensPerRequest:4096},pro:{requestsPerMonth:500,maxConcurrent:3,maxTokensPerRequest:8192},enterprise:{requestsPerMonth:2e3,maxConcurrent:10,maxTokensPerRequest:16384}},Sh={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 Eh(e,t,a){let r=Vi[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 ji=class{constructor(){this.operations=[];this.listeners=[];}record(t){let a=Eh(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),p=a.filter(d=>d.success),m=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?m/r:0,successRate:r>0?p.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 p=this.operations.filter(u=>u.timestamp>=n).length,m=Math.max(0,o-p),i=p/o*100;return {used:p,limit:o,remaining:m,percentUsed:i,isExceeded:p>=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)}},Qr=new ji;function dm({isOpen:e,onClose:t,planTier:a="hobby"}){let[r,o]=useState(Qr.getStats()),[s,n]=useState(Qr.checkLimit(a));if(useEffect(()=>{if(!e)return;let m=setInterval(()=>{o(Qr.getStats()),n(Qr.checkLimit(a));},1e3);return ()=>clearInterval(m)},[e,a]),useEffect(()=>{let m=i=>{i.key==="Escape"&&t();};if(e)return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[e,t]),!e)return null;let p=Qr.getRecentOperations(5);return jsxs(ht,{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: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:[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(([m,i])=>{let u=r.costsByFeature[m]||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:m.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}%`}})})]},m)})})]}),jsxs("div",{children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-3",children:"Recent Operations"}),p.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:p.map(m=>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:m.feature.replace(/([A-Z])/g," $1").trim()}),jsxs("p",{className:"text-xs text-white/50 mt-0.5",children:[new Date(m.timestamp).toLocaleTimeString()," \u2022"," ",m.duration,"ms"]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-white/60",children:[m.inputTokens+m.outputTokens," tokens"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:jo(m.cost)}),jsx("div",{className:`w-2 h-2 rounded-full ${m.success?"bg-green-400":"bg-red-400"}`})]})]},m.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 pm({isOpen:e,onClose:t,onTasksGenerated:a,onGenerateTasks:r,isLoading:o,projectName:s}){let[n,p]=useState(""),[m,i]=useState(""),[u,d]=useState(""),[g,b]=useState(false),[C,T]=useState(null),[c,h]=useState(null),[v,l]=useState(null),k=useRef(null),y=g||o;useEffect(()=>{e&&k.current&&k.current.focus();},[e]),useEffect(()=>{let A=N=>{N.key==="Escape"&&!y&&S();};if(e)return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[e,y]);let S=()=>{y||(p(""),i(""),d(""),T(null),h(null),l(null),t());},w=async()=>{if(!(!n.trim()||y)){b(true),T(null),h(null),l(null);try{let A=await r({prompt:n.trim(),projectName:s||"Mi Proyecto",startDate:m||void 0,endDate:u||void 0});h(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{b(false);}}},x=()=>{c&&(a(c),S());};if(!e)return null;let R=v?.similarity?((v.similarity||0)*100).toFixed(0):"0";return jsxs(ht,{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:y,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:c?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:[v?.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"}),v?.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 (",R,"% 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:[v?.tokens_used||0," tokens"]}),v?.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:[v.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:[c.length," tasks"]})]}),jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:c.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:k,value:n,onChange:A=>p(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:y}),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:m,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:y})]}),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:y})]})]}),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:()=>p(A),disabled:y,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:y&&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:y,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"}),c?jsx("button",{onClick:x,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:w,disabled:!n.trim()||y,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:y?"Generating...":"Generate Tasks"})]})]})]})})]})}function Kn({initialBoard:e,onPersist:t}){let[a,r]=useState(e),o=useCallback(c=>{t&&tn(()=>Promise.resolve(t(c)),{maxAttempts:3,initialDelay:1e3,onRetry:(h,v,l)=>{console.warn(`Retry attempt ${v} after ${l}ms: ${h.message}`);}}).then(h=>{h.success||console.error(`Failed to persist board after ${h.attempts} attempts:`,h.error);});},[t]),s=useCallback(async(c,h,v)=>{r(l=>{let k=l.cards.find(A=>A.id===c);if(!k)return l;let y=k.columnId,S={...k,columnId:h,position:v},w=l.cards.map(A=>A.id===c?S:A),x=l.columns.map(A=>{if(A.id===y)return {...A,cardIds:A.cardIds.filter(N=>N!==c)};if(A.id===h){let N=w.filter(U=>U.columnId===h).sort((U,$)=>U.position-$.position);return {...A,cardIds:N.map(U=>U.id)}}return A}),R={...l,cards:w,columns:x};return o(R),R});},[o]),n=useCallback(async(c,h)=>{r(v=>{let l=v.cards.map(y=>y.id===c?{...y,...h}:y),k={...v,cards:l};return o(k),k});},[o]),p=useCallback(async c=>{let h=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(v=>{let l={...c,id:h},k=v.columns.map(S=>S.id===c.columnId?{...S,cardIds:[...S.cardIds,h]}:S),y={...v,cards:[...v.cards,l],columns:k};return o(y),y});},[o]),m=useCallback(async c=>{r(h=>{let v=h.cards.find(S=>S.id===c);if(!v)return h;let l=h.cards.filter(S=>S.id!==c),k=h.columns.map(S=>S.id===v.columnId?{...S,cardIds:S.cardIds.filter(w=>w!==c)}:S),y={...h,cards:l,columns:k};return o(y),y});},[o]),i=useCallback(async c=>{let h=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(v=>{let l={...c,id:h,cardIds:[]},k={...v,columns:[...v.columns,l]};return o(k),k});},[o]),u=useCallback(async(c,h)=>{r(v=>{let l=v.columns.map(y=>y.id===c?{...y,...h}:y),k={...v,columns:l};return o(k),k});},[o]),d=useCallback(async c=>{r(h=>{let v=h.cards.filter(y=>y.columnId!==c),l=h.columns.filter(y=>y.id!==c),k={...h,cards:v,columns:l};return o(k),k});},[o]),g=useCallback(c=>{let h=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return p(c),h},[p]),b=useCallback(c=>{let h=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return i(c),h},[i]),C=useCallback(()=>{r(c=>{let h={...c,cards:[],columns:[]};return o(h),h});},[o]);return {board:a,callbacks:{onCardMove:s,onCardUpdate:n,onCardCreate:p,onCardDelete:m,onColumnCreate:i,onColumnUpdate:u,onColumnDelete:d},setBoard:r,helpers:{addCard:g,addColumn:b,deleteCard:m,deleteColumn:d,clearBoard:C}}}function gm({initialData:e,availableUsers:t=[],onSave:a}){let{board:r,callbacks:o,helpers:s}=Kn({initialBoard:e,onPersist:a}),n=useMemo(()=>({addCard:(m,i,u={})=>{s.addCard({title:i,columnId:m,position:r.cards.filter(d=>d.columnId===m).length,...u});},addColumn:(m,i)=>{let u=r.columns.length>0?Math.max(...r.columns.map(d=>d.position)):0;s.addColumn({title:m,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:""},hm={by:"none",order:"asc"};function bm({initialFilters:e={},initialSort:t={},currentUserId:a}={}){let[r,o]=useState({...Ko,...e}),[s,n]=useState({...hm,...t}),p=useCallback(T=>{o(c=>({...c,...T}));},[]),m=useCallback(T=>{n(c=>({...c,...T}));},[]),i=useCallback(()=>{o(Ko),n(hm);},[]),u=useCallback(()=>{a&&o({...Ko,assignees:[a]});},[a]),d=useCallback(()=>{o({...Ko,dateFilter:"overdue"});},[]),g=useCallback(()=>{o({...Ko,priorities:["HIGH","URGENT"]});},[]),b=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 c=[...T];if(r.search){let h=r.search.toLowerCase();c=c.filter(v=>v.title.toLowerCase().includes(h)||v.description?.toLowerCase().includes(h));}if(r.dateFilter!=="all"){let h=new Date,v=h.getFullYear(),l=String(h.getMonth()+1).padStart(2,"0"),k=String(h.getDate()).padStart(2,"0"),y=`${v}-${l}-${k}`;c=c.filter(S=>{if(!S.endDate&&!S.dueDate)return false;let w=S.endDate||S.dueDate;if(!w)return false;let x;if(typeof w=="string")x=w.split("T")[0]||w;else {let R=w.getUTCFullYear(),A=String(w.getUTCMonth()+1).padStart(2,"0"),N=String(w.getUTCDate()).padStart(2,"0");x=`${R}-${A}-${N}`;}switch(r.dateFilter){case "overdue":return x<y;case "today":return x===y;case "this-week":let R=new Date(y+"T00:00:00"),A=new Date(x+"T00:00:00"),N=new Date(R);return N.setDate(N.getDate()+7),A>=R&&A<=N;case "custom":if(r.dateRange){let U=typeof w=="string"?new Date(w):w;return U>=r.dateRange.start&&U<=r.dateRange.end}return true;default:return true}});}return r.priorities.length>0&&(c=c.filter(h=>h.priority&&r.priorities.includes(h.priority))),r.assignees.length>0&&(c=c.filter(h=>(h.assignedUserIds||(h.assigneeId?[h.assigneeId]:[])).some(l=>r.assignees.includes(l)))),r.labels.length>0&&(c=c.filter(h=>h.labels&&h.labels.some(v=>r.labels.includes(v)))),r.columns.length>0&&(c=c.filter(h=>r.columns.includes(h.columnId))),s.by!=="none"&&c.sort((h,v)=>{let l=0;switch(s.by){case "created":let k=h.createdAt?new Date(h.createdAt).getTime():0,y=v.createdAt?new Date(v.createdAt).getTime():0;l=k-y;break;case "priority":let S={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},w=S[h.priority||"LOW"],x=S[v.priority||"LOW"];l=w-x;break;case "dueDate":let R=h.endDate||h.dueDate,A=v.endDate||v.dueDate;if(!R)return 1;if(!A)return -1;let N=typeof R=="string"?new Date(R).getTime():R.getTime(),U=typeof A=="string"?new Date(A).getTime():A.getTime();l=N-U;break;case "title":l=h.title.localeCompare(v.title);break;case "estimate":let $=h.estimatedTime||0,_=v.estimatedTime||0;l=$-_;break;default:l=0;}return s.order==="asc"?l:-l}),c},[r,s]);return {filters:r,sort:s,setFilters:p,setSort:m,resetFilters:i,filterMyTasks:u,filterOverdue:d,filterHighPriority:g,applyFilters:C,hasActiveFilters:b}}var vm,xm;if(typeof window<"u")try{let e=Qo("ai");vm=e.generateObject,xm=e.generateText;}catch{}function km(e={}){let[t,a]=useState(false),[r,o]=useState(null),s=!!(vm&&xm&&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 b=g instanceof Error?g:new Error("Failed to generate plan");throw o(b),b}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("Suggesting assignee for:",d.title),{userId:"user-123",confidence:.85,reasoning:"Based on past performance and expertise"}}catch(g){let b=g instanceof Error?g:new Error("Failed to suggest assignee");throw o(b),b}finally{a(false);}},[s]),m=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 b=g instanceof Error?g:new Error("Failed to predict risks");throw o(b),b}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 b=g instanceof Error?g:new Error("Failed to generate subtasks");throw o(b),b}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 b=g instanceof Error?g:new Error("Failed to estimate effort");throw o(b),b}finally{a(false);}},[s]);return {onGeneratePlan:n,onSuggestAssignee:p,onPredictRisks:m,onGenerateSubtasks:i,onEstimateEffort:u,isAvailable:s,isLoading:t,error:r}}function Yi(){let[e,t]=useState(()=>selectionStore.getState());useEffect(()=>selectionStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{selectionStore.setState(r);},[]);return [e,a]}function wm(e){let{cards:t}=e,[a,r]=Yi(),o=useCallback(d=>a.selectedCardIds.includes(d),[a.selectedCardIds]),s=useCallback((d,g)=>{if(!g){r({selectedCardIds:[d],lastSelectedCardId:d});return}let b=g.ctrlKey||g.metaKey,C=g.shiftKey;if(b)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(h=>h.id===d),c=t.find(h=>h.id===a.lastSelectedCardId);if(T&&c&&T.columnId===c.columnId){let h=t.filter(x=>x.columnId===T.columnId).sort((x,R)=>x.position-R.position),v=h.findIndex(x=>x.id===a.lastSelectedCardId),l=h.findIndex(x=>x.id===d),[k,y]=v<l?[v,l]:[l,v],S=h.slice(k,y+1).map(x=>x.id),w=Array.from(new Set([...a.selectedCardIds,...S]));r({selectedCardIds:w,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]),p=useCallback(()=>{r({selectedCardIds:[],lastSelectedCardId:null});},[r]),m=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:p,selectAll:m,toggleCard:i,getSelectedCards:u}}var Cm={enableAutoStacking:true,autoStackConfidenceThreshold:.7,minCardsPerStack:2,enableManualStacking:true,showStackSummaries:true,animationDuration:200};function Tm(e){let{cards:t,config:a,aiService:r}=e,o=useMemo(()=>({...Cm,...a}),[a]),[s,n]=useState([]),p=useCallback((T,c,h,v,l)=>{if(c.length<o.minCardsPerStack){console.warn(`Cannot create stack: minimum ${o.minCardsPerStack} cards required`);return}let k={id:`stack-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:T,cardIds:c,columnId:h,strategy:v,color:l,isExpanded:true,position:s.filter(y=>y.columnId===h).length,createdAt:new Date};n(y=>[...y,k]);},[o.minCardsPerStack,s]),m=useCallback(T=>{n(c=>c.filter(h=>h.id!==T));},[]),i=useCallback(T=>{n(c=>c.map(h=>h.id===T?{...h,isExpanded:!h.isExpanded}:h));},[]),u=useCallback((T,c)=>{n(h=>h.map(v=>v.id===T&&!v.cardIds.includes(c)?{...v,cardIds:[...v.cardIds,c]}:v));},[]),d=useCallback((T,c)=>{n(h=>h.map(v=>{if(v.id===T){let l=v.cardIds.filter(k=>k!==c);return l.length<o.minCardsPerStack?null:{...v,cardIds:l}}return v}).filter(v=>v!==null));},[o.minCardsPerStack]),g=useCallback(T=>s.filter(c=>c.columnId===T).sort((c,h)=>c.position-h.position),[s]),b=useCallback(async T=>{let c=t.filter(y=>y.columnId===T);if(c.length<o.minCardsPerStack*2)return [];let h=[],v=new Map;c.forEach(y=>{y.labels&&y.labels.length>0&&y.labels.forEach(S=>{v.has(S)||v.set(S,[]),v.get(S).push(y);});}),v.forEach((y,S)=>{y.length>=o.minCardsPerStack&&h.push({stack:{title:`\u{1F4CC} ${S}`,cardIds:y.map(w=>w.id),columnId:T,strategy:"labels",color:"#3b82f6"},reason:`${y.length} cards with label "${S}"`,confidence:.85});});let l=new Map;c.forEach(y=>{y.assignedUserIds&&y.assignedUserIds.length>0&&y.assignedUserIds.forEach(S=>{l.has(S)||l.set(S,[]),l.get(S).push(y);});}),l.forEach((y,S)=>{y.length>=o.minCardsPerStack&&h.push({stack:{title:`\u{1F464} Assigned to user-${S.slice(-4)}`,cardIds:y.map(w=>w.id),columnId:T,strategy:"assignee",color:"#8b5cf6"},reason:`${y.length} cards assigned to the same user`,confidence:.8});});let k=new Map;if(c.forEach(y=>{y.priority&&(k.has(y.priority)||k.set(y.priority,[]),k.get(y.priority).push(y));}),k.forEach((y,S)=>{if(y.length>=o.minCardsPerStack){let w={low:"\u{1F7E2}",medium:"\u{1F7E1}",high:"\u{1F534}",urgent:"\u{1F6A8}"}[S.toLowerCase()]||"\u26AA";h.push({stack:{title:`${w} ${S} Priority`,cardIds:y.map(x=>x.id),columnId:T,strategy:"priority",color:S==="high"||S==="urgent"?"#ef4444":"#10b981"},reason:`${y.length} cards with ${S} priority`,confidence:.75});}}),r&&o.enableAutoStacking)for(let y of c){let w=(await r.findSimilar(y,c)).filter(x=>x.similarity>=o.autoStackConfidenceThreshold);if(w.length>=o.minCardsPerStack-1){let x=[y.id,...w.map(A=>A.card.id)],R=w.reduce((A,N)=>A+N.similarity,0)/w.length;h.push({stack:{title:`\u2728 Similar to "${y.title.substring(0,30)}${y.title.length>30?"...":""}"`,cardIds:x,columnId:T,strategy:"ai-similarity",color:"#f59e0b"},reason:`AI detected ${w.length+1} similar tasks`,confidence:R});}}return h.filter(y=>y.confidence>=o.autoStackConfidenceThreshold).sort((y,S)=>S.confidence-y.confidence).slice(0,5)},[t,o,r]),C=useCallback(T=>{p(T.stack.title,T.stack.cardIds,T.stack.columnId,T.stack.strategy,T.stack.color);},[p]);return useEffect(()=>{o.enableAutoStacking&&s.length===0&&new Set(t.map(c=>c.columnId)).forEach(async c=>{let h=await b(c),v=h[0];h.length>0&&v&&v.confidence>=.9&&C(v);});},[]),{stacks:s,createStack:p,deleteStack:m,toggleStack:i,addToStack:u,removeFromStack:d,getStacksForColumn:g,getSuggestions:b,applySuggestion:C,config:o}}var Nm=createContext(null);function Dm({children:e,initialData:t,onStateChange:a}){let r=useRef();if(!r.current){let s=new Map,n=new Map;t?.columns?.forEach(m=>{let{Column:i}=Qo("@libxai/core");s.set(m.id,new i(m));}),t?.cards?.forEach(m=>{let{Card:i}=Qo("@libxai/core");n.set(m.id,new i(m));});let p=null;if(t?.board){let{Board:m}=Qo("@libxai/core");p=new m(t.board);}r.current=new BoardStore({board:p,columns:s,cards:n});}let o=r.current;return useEffect(()=>{if(a)return o.subscribeAll(s=>{a(o.getState());})},[o,a]),jsx(Nm.Provider,{value:{store:o},children:e})}function Yn(){let e=useContext(Nm);if(!e)throw new Error("useBoardStore must be used within BoardProvider");return e.store}function qo(){let e=Yn(),[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 p=useCallback(v=>{e.updateBoard(v);},[e]),m=useCallback(v=>{e.addColumn(v);},[e]),i=useCallback((v,l)=>{e.updateColumn(v,l);},[e]),u=useCallback(v=>{e.deleteColumn(v);},[e]),d=useCallback(v=>e.getColumn(v),[e]),g=useCallback(v=>{e.addCard(v);},[e]),b=useCallback((v,l)=>{e.updateCard(v,l);},[e]),C=useCallback(v=>{e.deleteCard(v);},[e]),T=useCallback((v,l,k)=>{e.moveCard(v,l,k);},[e]),c=useCallback(v=>e.getCard(v),[e]),h=useCallback(v=>e.getCardsByColumn(v),[e]);return {board:t,columns:r,cards:s,updateBoard:p,addColumn:m,updateColumn:i,deleteColumn:u,getColumn:d,addCard:g,updateCard:b,deleteCard:C,moveCard:T,getCard:c,getCardsByColumn:h}}function Em(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 Pm(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 p={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},m=o.priority?p[o.priority]:0,i=s.priority?p[s.priority]:0;n=m-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 qn=class{constructor(){this.plugins=new Map;this.enabled=new Set;this.config=new Map;this.context=null;this.pluginLogger=Nl.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 p=await Promise.resolve(n.apply(s,a));p!==void 0&&(o=p,a[0]=p);}catch(p){this.pluginLogger.error(`Plugin hook failed: ${s.id}.${t}`,p,{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);}},Vh=new qn;function Am({items:e,height:t,estimateSize:a,renderItem:r,className:o="",overscan:s=5,horizontal:n=false,gap:p=0,getItemKey:m}){let i=useRef(null),u=useVirtualizer({count:e.length,getScrollElement:()=>i.current,estimateSize:()=>a,overscan:s,horizontal:n,gap:p}),d=u.getVirtualItems(),g={height:typeof t=="number"?`${t}px`:t,width:"100%",overflow:"auto",position:"relative"},b=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:b,children:d.map(C=>{let T=e[C.index];if(!T)return null;let c=m?m(T,C.index):C.index,h={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:h,"data-index":C.index,children:r(T,C.index)},c)})})})}function Fm(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 Im({items:e,height:t,width:a="100%",estimateColumnWidth:r,renderColumn:o,className:s="",overscan:n=3,gap:p=16,getItemKey:m,horizontal:i=true}){let u=useRef(null),d=useVirtualizer({horizontal:i,count:e.length,getScrollElement:()=>u.current,estimateSize:()=>r,overscan:n,gap:p}),g=d.getVirtualItems(),b={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:b,className:s,children:jsx("div",{style:C,children:g.map(T=>{let c=e[T.index];if(!c)return null;let h=m?m(c,T.index):T.index,v={position:"absolute",top:0,left:T.start,width:T.size,height:"100%"};return jsx("div",{style:v,"data-index":T.index,children:o(c,T.index)},h)})})})}function Bm(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 Rm(e,t=10){return e>t}var Qi={none:0,xs:4,sm:8,md:12,lg:16,xl:20,"2xl":24,"3xl":32,"4xl":40,"5xl":48,"6xl":64},Zi={none:0,sm:4,md:8,lg:12,xl:16,"2xl":20,full:9999},el={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48},tl={light:300,normal:400,medium:500,semibold:600,bold:700,extrabold:800},al={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},rl={base:0,dropdown:1e3,sticky:1020,fixed:1030,modalBackdrop:1040,modal:1050,popover:1060,tooltip:1070},ol={instant:0,fastest:75,faster:100,fast:150,normal:200,slow:300,slower:400,slowest:500},nl={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)"},sl={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)"},il={0:0,5:.05,10:.1,20:.2,30:.3,40:.4,50:.5,60:.6,70:.7,80:.8,90:.9,100:1},ll={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}},dl={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}},Xn={spacing:Qi,borderRadius:Zi,fontSize:el,fontWeight:tl,lineHeight:al,zIndex:rl,duration:ol,easing:nl,shadows:sl,opacity:il,kanban:ll,gantt:dl};function $m(e,t,a){return e[t]??a}function cl(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)?cl(o,s,a):(typeof o=="string"||typeof o=="number")&&(a[s]=o);}return a}function Yh(e){return typeof e=="number"?e>0&&e<1e3?`${e}px`:e.toString():e}function ml(e="asakaa"){let t=cl(Xn),a=[];for(let[r,o]of Object.entries(t)){let s=`--${e}-${r}`,n=Yh(o);a.push(` ${s}: ${n};`);}return `:root {
389
+ Today's date: ${new Date().toISOString().split("T")[0]}`}function Sc(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=Sc(e),r=t.toLowerCase().trim(),o=a.find(m=>m.name.toLowerCase()===r);if(o)return o;let s=a.find(m=>m.name.toLowerCase().includes(r));if(s)return s;let n=r.split(/\s+/);return a.find(m=>{let p=m.name.toLowerCase();return n.every(i=>p.includes(i))})}function Ci(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 b={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(b!==void 0){let C=new Date(r),T=C.getDay(),c=b-T;return c<=0&&(c+=7),C.setDate(C.getDate()+c),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),b=s[2].toLowerCase(),C=new Date(r);return b==="day"||b==="d\xEDa"||b==="dias"?C.setDate(C.getDate()+g):b==="week"||b==="semana"||b==="semanas"?C.setDate(C.getDate()+g*7):(b==="month"||b==="mes"||b==="meses")&&C.setMonth(C.getMonth()+g),C}if(a.match(/(\d{4})-(\d{2})-(\d{2})/))return new Date(a);let m=a.match(/(\d{1,2})\/(\d{1,2})\/(\d{4})/);if(m&&m[1]&&m[2]&&m[3]){let g=parseInt(m[1],10),b=parseInt(m[2],10)-1,C=parseInt(m[3],10);return new Date(C,b,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),b=p[i[2].toLowerCase()],C=i[3]?parseInt(i[3],10):r.getFullYear();if(b!==void 0)return new Date(C,b,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()],b=parseInt(d[2],10),C=d[3]?parseInt(d[3],10):r.getFullYear();if(g!==void 0)return new Date(C,g,b)}return null}function Ti(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 Ni(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 Ec(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 Pc(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=Ci(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 b=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()+b),{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=Ti(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 b=new Date(d.endDate);return b.setDate(b.getDate()+g),{type:"resize_task",taskId:d.id,taskName:d.name,updates:{endDate:b},message:`Extended "${d.name}" by ${g} days. New end date: ${b.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=Ni(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 m=a.match(/(?:link|vincular|conectar)\s+["""]?(.+?)["""]?\s+(?:to|a|con)\s+["""]?(.+?)["""]?$/i);if(m&&m[1]&&m[2]){let i=m[1].trim(),u=m[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 Mc(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 z0(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 U0(e){switch(e){case "todo":return "TODO";case "in-progress":return "IN_PROGRESS";case "completed":return "DONE";default:return e||"TODO"}}function Rn(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=>Rn(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},m=n(e.startDate),p=n(e.endDate),i=e.metadata?.isMilestone===true||m&&p&&Math.abs(p.getTime()-m.getTime())<=864e5;return {id:e.id,name:e.title,startDate:m,endDate:p,progress:e.progress||0,status:z0(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 Ac(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:U0(e.status),isExpanded:e.isExpanded,isMilestone:e.isMilestone,isCriticalPath:e.isCriticalPath}}}function Fc(e,t=[]){return e.filter(r=>!r.metadata?.parentCardId).map(r=>Rn(r,e,t))}var Di={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"}},Si={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"}},$n={en:Di,es:Si};function Ei(e){return $n[e]||$n.en}function On(e,t){let a=Ei(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 Rc(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(...Rc(r.subtasks,t+1));return a}function J0({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 $c({tasks:e,config:t={},callbacks:a={},isLoading:r=false,error:o,className:s,style:n}){let{theme:m="dark",locale:p="en",customTranslations:i,showSearch:u=true,showHierarchy:d=true}=t,g=On(p,i),b=m==="dark",[C,T]=useState(new Set),[c,h]=useState("startDate"),[v,l]=useState("asc"),[w,y]=useState("");useMemo(()=>{let A=new Set;function N(H){for(let $ of H)$.subtasks?.length&&(A.add($.id),N($.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]),k=useCallback(A=>{c===A?l(N=>N==="asc"?"desc":"asc"):(h(A),l("asc")),a.onSortChange?.({column:A,direction:v==="asc"?"desc":"asc"});},[c,v,a]),x=useMemo(()=>{let A=Rc(e);if(w.trim()){let H=w.toLowerCase();A=A.filter($=>$.name.toLowerCase().includes(H));}let N=[];for(let H of A){let $=H.level===0;H.level>0&&($=true),($||w.trim())&&N.push(H);}return w.trim()&&N.sort((H,$)=>{let _,V;switch(c){case "name":_=H.name.toLowerCase(),V=$.name.toLowerCase();break;case "startDate":_=H.startDate?.getTime()||0,V=$.startDate?.getTime()||0;break;case "endDate":_=H.endDate?.getTime()||0,V=$.endDate?.getTime()||0;break;case "progress":_=H.progress||0,V=$.progress||0;break;case "status":_=H.status||"todo",V=$.status||"todo";break;default:return 0}return _<V?v==="asc"?-1:1:_>V?v==="asc"?1:-1:0}),N},[e,w,c,v]),R=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:f("flex-1 flex items-center justify-center",b?"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",b?"text-[#9CA3AF]":"text-gray-600"),children:[g.empty.noTasks,"..."]})]})}):o?jsx("div",{className:f("flex-1 flex items-center justify-center",b?"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",b?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:f("text-sm",b?"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",b?"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",b?"text-white":"text-gray-900"),children:g.empty.noTasks}),jsx("p",{className:f("text-sm",b?"text-[#9CA3AF]":"text-gray-600"),children:g.empty.addFirstTask})]})}):jsxs("div",{className:f("flex-1 flex flex-col w-full h-full overflow-hidden",b?"bg-[#0F1117]":"bg-white",s),style:n,children:[jsx("div",{className:f("flex-shrink-0 px-6 py-4 border-b",b?"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",b?"text-[#9CA3AF]":"text-gray-400")}),jsx("input",{type:"text",value:w,onChange:A=>y(A.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",b?"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",b?"text-[#9CA3AF]":"text-gray-600"),children:[x.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",b?"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:()=>k("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:()=>k("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:()=>k("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:()=>k("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:()=>k("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:x.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:f("grid grid-cols-12 gap-4 px-6 py-3 border-b transition-colors cursor-pointer",b?"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:$=>{$.stopPropagation(),S(A.id);},className:f("p-0.5 rounded",b?"hover:bg-white/10":"hover:bg-gray-200"),children:H?jsx(ChevronDown,{className:f("w-4 h-4",b?"text-[#9CA3AF]":"text-gray-400")}):jsx(ChevronRight,{className:f("w-4 h-4",b?"text-[#9CA3AF]":"text-gray-400")})}),d&&!A.hasChildren&&jsx("div",{className:"w-5"}),jsx("button",{onClick:$=>{$.stopPropagation(),a.onTaskUpdate?.({...A,progress:A.progress===100?0:100,status:A.progress===100?"todo":"completed"});},className:"flex-shrink-0",children:jsx(J0,{status:A.status,progress:A.progress})}),jsx("span",{className:f("truncate",b?"text-white":"text-gray-900",A.progress===100&&(b?"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:f("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":b?"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:f("col-span-2 flex items-center gap-1 text-sm",b?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Calendar,{className:"w-4 h-4"}),R(A.startDate)]}),jsxs("div",{className:f("col-span-2 flex items-center gap-1 text-sm",b?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Clock,{className:"w-4 h-4"}),R(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:f("flex-1 h-1.5 rounded-full overflow-hidden",b?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:f("h-full rounded-full transition-all",A.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${A.progress||0}%`}})}),jsxs("span",{className:f("text-xs w-8",b?"text-[#9CA3AF]":"text-gray-500"),children:[A.progress||0,"%"]})]})})]},A.id)})}),x.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",b?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:f(b?"text-[#9CA3AF]":"text-gray-600"),children:g.empty.noResults})]})})]})]})}var Pi={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"},Mi={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"},Ai={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:Pi,light:Mi,neutral:Ai};function Oc(e){return Un[e]||Un.dark}var Fi={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"}},Li={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"}},Hn={en:Fi,es:Li};function Ho(e){return Hn[e]||Hn.en}function Wn(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 zc(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 Uc(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 hh(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 zi(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 Vc({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 Kc({tasks:e,config:t={},callbacks:a={},initialDate:r,isLoading:o=false,error:s,className:n,style:m,availableTags:p=[],onCreateTag:i,attachmentsByTask:u,comments:d,onAddComment:g,currentUser:b,onTaskOpen:C}){let{theme:T="dark",locale:c="en",customTranslations:h}=t,v=Wn(c,h),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)"},[y,S]=useState(r||new Date),[k,x]=useState(null),[R,A]=useState(null),[N,H]=useState(null),[$,_]=useState(new Date),[V,ie]=useState({}),Be=4,Oe=3,[ze,Pe]=useState(false),[L,B]=useState(false),[D,U]=useState(false),[q,O]=useState(false),[le,ve]=useState(null),[Ee,ue]=useState(""),[We,Me]=useState(void 0),[Re,ft]=useState(null),[qe,it]=useState(false),[z,re]=useState(false),[fe,ye]=useState(null),[Ae,Ze]=useState(false),[kt,De]=useState(new Date),[It,Ft]=useState(false),[lt,Xe]=useState(false),[Wt,sa]=useState(false),[oe,J]=useState(""),[Ve,ae]=useState(false),[E,X$1]=useState(""),[de,Le]=useState(false),Ge=useCallback(()=>{S(new Date(y.getFullYear(),y.getMonth()-1,1));},[y]),Je=useCallback(()=>{S(new Date(y.getFullYear(),y.getMonth()+1,1));},[y]),Ue=useCallback(()=>{S(new Date);},[]),st=useMemo(()=>{let P=y.getFullYear(),xe=y.getMonth(),Z=new Date(P,xe,1),Fe=new Date(P,xe+1,0),dt=Z.getDay(),se=Fe.getDate(),He=hh(e),Dt=new Date;Dt.setHours(0,0,0,0);let Ie=[],Bt=dt,ut=new Date(P,xe,0).getDate();for(let Gt=Bt-1;Gt>=0;Gt--){let Ye=new Date(P,xe-1,ut-Gt);Ie.push({date:Ye,isCurrentMonth:false,isToday:false,isWeekend:Ye.getDay()===0||Ye.getDay()===6,events:He.filter(St=>zi(Ye,St)).map(St=>({id:St.id,title:St.name,start:St.startDate,end:St.endDate,task:St}))});}for(let Gt=1;Gt<=se;Gt++){let Ye=new Date(P,xe,Gt),St=Ye.getTime()===Dt.getTime();Ie.push({date:Ye,isCurrentMonth:true,isToday:St,isWeekend:Ye.getDay()===0||Ye.getDay()===6,events:He.filter(ca=>zi(Ye,ca)).map(ca=>({id:ca.id,title:ca.name,start:ca.startDate,end:ca.endDate,task:ca}))});}let ha=42-Ie.length;for(let Gt=1;Gt<=ha;Gt++){let Ye=new Date(P,xe+1,Gt);Ie.push({date:Ye,isCurrentMonth:false,isToday:false,isWeekend:Ye.getDay()===0||Ye.getDay()===6,events:He.filter(St=>zi(Ye,St)).map(St=>({id:St.id,title:St.name,start:St.startDate,end:St.endDate,task:St}))});}return Ie},[y,e]),mt=c==="es"?["Dom","Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b"]:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],j=y.toLocaleDateString(c==="es"?"es-ES":"en-US",{month:"long",year:"numeric"}),te=useCallback((P,xe)=>{if(!k)return;let Z={...k,[P]:xe};x(Z),a.onTaskUpdate?.(Z);},[k,a]),Se=useCallback(P=>{if(!k)return;let xe=k.progress||0;P==="completed"?xe=100:P==="todo"&&(xe=0);let Z={...k,status:P,progress:xe};x(Z),a.onTaskUpdate?.(Z),Pe(false);},[k,a]),Qe=useCallback((P,xe)=>{if(!k)return;let Z={...k,startDate:P,endDate:xe};x(Z),a.onTaskUpdate?.(Z);},[k,a]),_e=useCallback(()=>{Pe(false),B(false),U(false),H(null),sa(false),J(""),ae(false);},[]),G=useCallback(async P=>{if(P.preventDefault(),P.stopPropagation(),Ft(false),!k||!a.onUploadAttachments)return;let xe=Array.from(P.dataTransfer.files);if(xe.length!==0){Xe(true);try{await a.onUploadAttachments(k.id,xe);}finally{Xe(false);}}},[k,a]),ce=useCallback(async P=>{if(!k||!a.onUploadAttachments||!P.target.files)return;let xe=Array.from(P.target.files);if(xe.length!==0){Xe(true);try{await a.onUploadAttachments(k.id,xe);}finally{Xe(false);}P.target.value="";}},[k,a]),$e=useCallback(P=>{P.preventDefault(),P.stopPropagation(),Ft(true);},[]),Mt=useCallback(P=>{P.preventDefault(),P.stopPropagation(),Ft(false);},[]),rt=useCallback(P=>P<1024?`${P} B`:P<1024*1024?`${(P/1024).toFixed(1)} KB`:`${(P/(1024*1024)).toFixed(1)} MB`,[]),xa=useCallback(P=>P.startsWith("image/")?Image:P.includes("pdf")||P.includes("document")?FileText:File,[]),fa=useMemo(()=>!k||!u?[]:u.get(k.id)||[],[k,u]);return o?jsx("div",{className:f("flex-1 flex items-center justify-center",l?"bg-[#0F1117]":"bg-white",n),style:m,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:[v.labels.noEvents,"..."]})]})}):s?jsx("div",{className:f("flex-1 flex items-center justify-center",l?"bg-[#0F1117]":"bg-white",n),style:m,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:m,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:v.labels.noEvents}),jsx("p",{className:f("text-sm",l?"text-[#9CA3AF]":"text-gray-600"),children:v.labels.newTask})]})}):jsxs("div",{className:f("flex-1 flex flex-col w-full h-full overflow-auto",l?"bg-[#0F1117]":"bg-white",n),style:m,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:j}),jsx("button",{onClick:Ue,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:v.navigation.today})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("button",{onClick:Ge,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:Je,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:mt.map(P=>jsx("div",{className:f("py-2 text-center text-xs font-medium uppercase",l?"text-[#9CA3AF]":"text-gray-500"),children:P},P))}),jsx("div",{className:f("grid grid-cols-7 auto-rows-min gap-px rounded-lg",l?"bg-[#2D2D2D]":"bg-gray-300"),children:st.map((P,xe)=>{let Z=P.date.getDay()===0||P.date.getDay()===6;return jsxs("div",{className:f("min-h-[120px] p-2 transition-colors flex flex-col relative group",l?Z?"bg-[#1C1F26]":P.isCurrentMonth?"bg-[#13161B]":"bg-[#0D0F13]":Z?"bg-gray-100":P.isCurrentMonth?"bg-white":"bg-gray-50",P.isToday&&"ring-2 ring-[#3B82F6] ring-inset"),children:[(()=>{let Fe=V[xe]||Be,dt=P.events.slice(0,Fe),se=P.events.length-Fe;return jsxs("div",{className:"space-y-1 flex-1",children:[dt.map(He=>jsx("div",{className:"relative group",children:jsxs(motion.button,{onClick:()=>{x(He.task),a.onEventClick?.(He),C?.(He.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",He.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(Vc,{task:He.task}),jsx("span",{className:"truncate",children:He.title})]})},He.id)),se>0&&jsxs("button",{onClick:He=>{He.stopPropagation(),ie(Dt=>({...Dt,[xe]:Fe+Oe}));},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:["+",se," ",c==="es"?"M\xC1S":"MORE"]}),Fe>Be&&P.events.length>Be&&jsx("button",{onClick:He=>{He.stopPropagation(),ie(Dt=>({...Dt,[xe]:Be}));},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:c==="es"?"MENOS":"LESS"})]})})(),jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1",children:[(()=>{let Fe=xe>=28,dt=xe%7>=5;return jsxs("div",{className:"relative",children:[jsx("button",{onClick:se=>{se.stopPropagation(),le===xe?ve(null):(ve(xe),ue(""),Me(void 0),ft(null),ye(null),it(false),re(false),Ze(false),De(P.date));},className:f("w-5 h-5 rounded flex items-center justify-center transition-all",le===xe?"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",le===xe&&"rotate-45")})}),jsx(AnimatePresence,{children:le===xe&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{ve(null),ue(""),Me(void 0),ft(null),ye(null),it(false),re(false),Ze(false);}}),jsxs(motion.div,{initial:{opacity:0,y:Fe?-5:5,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:Fe?-5:5,scale:.95},transition:{duration:.12},className:f("absolute w-[320px] rounded-lg shadow-2xl z-50",Fe?"bottom-full mb-1":"top-full mt-1",dt?"right-0":"left-0",l?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:se=>{se.stopPropagation(),it(false),re(false),Ze(false);},children:[jsx("div",{className:"p-2.5",children:jsx("input",{type:"text",value:Ee,onChange:se=>ue(se.target.value),placeholder:c==="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:se=>{if(se.key==="Enter"&&Ee.trim()){let He=t.availableUsers?.find(Ie=>Ie.id===Re),Dt=fe||P.date;a.onTaskCreate?.({name:Ee.trim(),startDate:Dt,endDate:Dt,priority:We,assignees:He?[He]:void 0}),ue(""),Me(void 0),ft(null),ye(null),ve(null);}se.key==="Escape"&&(ve(null),ue(""),Me(void 0),ft(null),ye(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:se=>{se.stopPropagation(),it(!qe),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:qe&&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:se=>se.stopPropagation(),children:[{id:"urgent",label:c==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:c==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:c==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:c==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:c==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(se=>jsxs("button",{onClick:()=>{Me(se.id),it(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===se.id&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:f("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(),Ze(!Ae),it(false),re(false),De(fe||P.date);},className:f("flex items-center gap-1 text-xs px-1.5 py-0.5 rounded transition-colors",fe?"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"}),(fe||P.date).toLocaleDateString(c==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})]}),jsx(AnimatePresence,{children:Ae&&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:se=>se.stopPropagation(),children:[jsx("div",{className:f("w-40 py-2 border-r",l?"border-white/10":"border-gray-200"),children:(()=>{let se=new Date,He=new Date(se);He.setDate(se.getDate()+1);let Dt=new Date(se);Dt.setDate(se.getDate()+((6-se.getDay()+7)%7||7));let Ie=new Date(se);Ie.setDate(se.getDate()+((1-se.getDay()+7)%7||7));let Bt=new Date(se);Bt.setDate(se.getDate()+14);let ut=new Date(se);return ut.setDate(se.getDate()+28),[{label:c==="es"?"Hoy":"Today",date:se,display:se.toLocaleDateString(c==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:c==="es"?"Ma\xF1ana":"Tomorrow",date:He,display:He.toLocaleDateString(c==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:c==="es"?"Este fin de semana":"This weekend",date:Dt,display:c==="es"?"s\xE1b.":"sat."},{label:c==="es"?"Pr\xF3xima semana":"Next week",date:Ie,display:c==="es"?"lun.":"mon."},{label:c==="es"?"2 semanas":"2 weeks",date:Bt,display:Bt.toLocaleDateString(c==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:c==="es"?"4 semanas":"4 weeks",date:ut,display:ut.toLocaleDateString(c==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Gt,Ye)=>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:()=>{ye(Gt.date),Ze(false);},children:[jsx("span",{children:Gt.label}),jsx("span",{className:f("text-[10px]",l?"text-[#6B7280]":"text-gray-400"),children:Gt.display})]},Ye))})()}),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:kt.toLocaleDateString(c==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-0.5",children:[jsx("button",{onClick:()=>De(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:c==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>De(new Date(kt.getFullYear(),kt.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:()=>De(new Date(kt.getFullYear(),kt.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:(c==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(se=>jsx("div",{className:f("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=kt.getFullYear(),He=kt.getMonth(),Dt=new Date(se,He,1).getDay(),Ie=new Date(se,He+1,0).getDate(),Bt=new Date(se,He,0).getDate(),ut=new Date,ha=[];for(let Ye=Dt-1;Ye>=0;Ye--)ha.push({dayNum:Bt-Ye,isCurrentMonth:false,date:new Date(se,He-1,Bt-Ye)});for(let Ye=1;Ye<=Ie;Ye++)ha.push({dayNum:Ye,isCurrentMonth:true,date:new Date(se,He,Ye)});let Gt=42-ha.length;for(let Ye=1;Ye<=Gt;Ye++)ha.push({dayNum:Ye,isCurrentMonth:false,date:new Date(se,He+1,Ye)});return ha.map((Ye,St)=>{let ca=Ye.date.toDateString()===ut.toDateString(),yr=(fe||P.date).toDateString()===Ye.date.toDateString();return jsx("button",{className:f("w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",!Ye.isCurrentMonth&&(l?"text-[#4B5563]":"text-gray-300"),Ye.isCurrentMonth&&(l?"text-white":"text-gray-900"),ca&&"ring-1 ring-[#3B82F6]",yr&&"bg-[#7C3AED] text-white",!yr&&(l?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{ye(Ye.date),Ze(false);},children:Ye.dayNum},St)})})()})]})]})})]}),jsxs("div",{className:"relative",children:[jsx("button",{onClick:se=>{se.stopPropagation(),re(!z),it(false);},className:f("p-1 rounded transition-colors",Re?"text-[#7C3AED] bg-[#7C3AED]/20":l?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:Re?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===Re)?.color||"#7C3AED"},children:t.availableUsers?.find(se=>se.id===Re)?.initials||t.availableUsers?.find(se=>se.id===Re)?.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:se=>se.stopPropagation(),children:[jsxs("button",{onClick:()=>{ft(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",!Re&&(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:c==="es"?"Sin asignar":"Unassigned"})]}),t.availableUsers?.map(se=>jsxs("button",{onClick:()=>{ft(se.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",Re===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:f("px-3 py-2 text-xs",l?"text-[#6B7280]":"text-gray-400"),children:c==="es"?"No hay usuarios disponibles":"No users available"})]})})]})]}),jsx("button",{onClick:()=>{if(Ee.trim()){let se=t.availableUsers?.find(Dt=>Dt.id===Re),He=fe||P.date;a.onTaskCreate?.({name:Ee.trim(),startDate:He,endDate:He,priority:We,assignees:se?[se]:void 0}),ue(""),Me(void 0),ft(null),ye(null),ve(null);}},disabled:!Ee.trim(),className:f("px-2.5 py-1 rounded text-xs font-medium transition-colors",Ee.trim()?"bg-[#7C3AED] hover:bg-[#6D28D9] text-white":l?"bg-white/5 text-[#4B5563]":"bg-gray-100 text-gray-400"),children:c==="es"?"Guardar":"Save"})]})]})]})})]})})(),jsx("span",{className:f("text-sm font-medium",P.isToday?"text-[#3B82F6]":P.isCurrentMonth?l?"text-white":"text-gray-900":l?"text-[#6B7280]":"text-gray-400"),children:P.date.getDate()})]})]},xe)})})]})}),jsx(AnimatePresence,{children:k&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>{x(null),X$1("");},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:[c==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:f("text-xs font-mono",l?"text-[#6B7280]":"text-gray-400"),children:k.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:()=>{x(null),X$1("");},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 P=k.progress===100?0:100,Z={...k,progress:P,status:P===100?"completed":"todo"};x(Z),a.onTaskUpdate?.(Z);},className:f("mt-1 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors",k.progress===100?"bg-green-500 border-green-500":l?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:k.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("h2",{className:f("text-xl font-semibold flex-1",k.progress===100?"line-through text-[#6B7280]":l?"text-white":"text-gray-900"),children:k.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:c==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{_e(),Pe(!ze);},className:f("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",k.progress===100||k.status==="completed"?"bg-green-500/20 text-green-400":k.progress&&k.progress>0||k.status==="in-progress"?"bg-blue-500/20 text-blue-400":l?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:k.progress===100||k.status==="completed"?c==="es"?"COMPLETADO":"DONE":k.progress&&k.progress>0||k.status==="in-progress"?c==="es"?"EN PROGRESO":"IN PROGRESS":c==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:ze&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Pe(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:c==="es"?"Por hacer":"To Do",color:"bg-white/10 text-white"},{id:"in-progress",label:c==="es"?"En progreso":"In Progress",color:"bg-blue-500/20 text-blue-400"},{id:"completed",label:c==="es"?"Completado":"Done",color:"bg-green-500/20 text-green-400"}].map(P=>jsxs("button",{onClick:()=>Se(P.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",(k.status===P.id||P.id==="completed"&&k.progress===100||P.id==="in-progress"&&k.progress&&k.progress>0&&k.progress<100||P.id==="todo"&&(!k.progress||k.progress===0)&&k.status!=="in-progress"&&k.status!=="completed")&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:f("w-2 h-2 rounded-full",P.id==="completed"?"bg-green-500":P.id==="in-progress"?"bg-blue-500":"bg-gray-400")}),jsx("span",{className:l?"text-white":"text-gray-900",children:P.label})]},P.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:c==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{Pe(false),B(false),H(null),U(!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:[k.assignees&&k.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[k.assignees.slice(0,3).map((P,xe)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:P.color||"#8B5CF6"},title:P.name,children:P.initials||P.name.slice(0,2).toUpperCase()},xe)),k.assignees.length>3&&jsxs("span",{className:f("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:["+",k.assignees.length-3]})]}):jsx("span",{className:f("text-sm",l?"text-[#6B7280]":"text-gray-400"),children:c==="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:()=>U(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(P=>{let xe=k.assignees?.some(Z=>Z.name===P.name);return jsxs("button",{onClick:()=>{let Z=k.assignees||[],Fe;xe?Fe=Z.filter(dt=>dt.name!==P.name):Fe=[...Z,{name:P.name,avatar:P.avatar,initials:P.initials||P.name.slice(0,2).toUpperCase(),color:P.color||"#8B5CF6"}],te("assignees",Fe);},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",xe&&(l?"bg-white/5":"bg-gray-50")),children:[P.avatar?jsx("img",{src:P.avatar,alt:P.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:P.color||"#8B5CF6"},children:P.initials||P.name.slice(0,2).toUpperCase()}),jsx("span",{className:f("flex-1 text-left",l?"text-white":"text-gray-900"),children:P.name}),xe&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},P.id||P.name)}):jsx("div",{className:f("px-3 py-4 text-sm text-center",l?"text-[#6B7280]":"text-gray-400"),children:c==="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:c==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{H(N?null:"start"),_(k.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:[k.startDate?.toLocaleDateString(c==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(c==="es"?"Inicio":"Start"),jsx("span",{className:f("mx-1",l?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),k.endDate?.toLocaleDateString(c==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(c==="es"?"Fin":"End"),(k.startDate||k.endDate)&&jsx(X,{className:"w-3.5 h-3.5 ml-1 opacity-50 hover:opacity-100",onClick:P=>{P.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:P=>P.stopPropagation(),children:[jsxs("div",{className:f("w-44 py-2 border-r",l?"border-white/10":"border-gray-200"),children:[(()=>{let P=new Date,xe=new Date(P);xe.setDate(P.getDate()+1);let Z=new Date(P);Z.setDate(P.getDate()+((6-P.getDay()+7)%7||7));let Fe=new Date(P);Fe.setDate(P.getDate()+((1-P.getDay()+7)%7||7));let dt=new Date(P);dt.setDate(P.getDate()+(6-P.getDay()+7)%7+7);let se=new Date(P);se.setDate(P.getDate()+14);let He=new Date(P);return He.setDate(P.getDate()+28),[{label:c==="es"?"Hoy":"Today",date:P,display:P.toLocaleDateString(c==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:c==="es"?"Ma\xF1ana":"Tomorrow",date:xe,display:xe.toLocaleDateString(c==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:c==="es"?"Este fin de semana":"This weekend",date:Z,display:c==="es"?"s\xE1b.":"sat."},{label:c==="es"?"Pr\xF3xima semana":"Next week",date:Fe,display:c==="es"?"lun.":"mon."},{label:c==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:dt,display:dt.toLocaleDateString(c==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:c==="es"?"2 semanas":"2 weeks",date:se,display:se.toLocaleDateString(c==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:c==="es"?"4 semanas":"4 weeks",date:He,display:He.toLocaleDateString(c==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Ie,Bt)=>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 ut=k.endDate&&Ie.date>k.endDate?Ie.date:k.endDate;Qe(Ie.date,ut),H("end");}else {let ut=k.startDate&&Ie.date<k.startDate?Ie.date:k.startDate;Qe(ut,Ie.date),H(null);}},children:[jsx("span",{children:Ie.label}),jsx("span",{className:f("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:Ie.display})]},Bt))})(),jsx("div",{className:f("border-t mt-2 pt-2",l?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{Qe(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:c==="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"?c==="es"?"\u{1F4C5} Selecciona fecha de inicio":"\u{1F4C5} Select start date":c==="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:$.toLocaleDateString(c==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>_(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:c==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>_(new Date($.getFullYear(),$.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:()=>_(new Date($.getFullYear(),$.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:(c==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(P=>jsx("div",{className:f("w-8 h-8 flex items-center justify-center text-xs",l?"text-[#6B7280]":"text-gray-400"),children:P},P))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let P=$.getFullYear(),xe=$.getMonth(),Z=new Date(P,xe,1).getDay(),Fe=new Date(P,xe+1,0).getDate(),dt=new Date(P,xe,0).getDate(),se=new Date,He=[];for(let Ie=Z-1;Ie>=0;Ie--)He.push({day:dt-Ie,isCurrentMonth:false,date:new Date(P,xe-1,dt-Ie)});for(let Ie=1;Ie<=Fe;Ie++)He.push({day:Ie,isCurrentMonth:true,date:new Date(P,xe,Ie)});let Dt=42-He.length;for(let Ie=1;Ie<=Dt;Ie++)He.push({day:Ie,isCurrentMonth:false,date:new Date(P,xe+1,Ie)});return He.map((Ie,Bt)=>{let ut=Ie.date.toDateString()===se.toDateString(),ha=k.startDate?.toDateString()===Ie.date.toDateString(),Gt=k.endDate?.toDateString()===Ie.date.toDateString(),Ye=ha||Gt,St=k.startDate&&k.endDate&&Ie.date>=k.startDate&&Ie.date<=k.endDate;return jsx("button",{className:f("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!Ie.isCurrentMonth&&(l?"text-[#4B5563]":"text-gray-300"),Ie.isCurrentMonth&&(l?"text-white":"text-gray-900"),ut&&"ring-2 ring-[#3B82F6]",ha&&"bg-[#3B82F6] text-white",Gt&&!ha&&"bg-[#7C3AED] text-white",St&&!Ye&&(l?"bg-[#7C3AED]/20":"bg-purple-100"),!Ye&&(l?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{let ca=new Date(Ie.date);if(N==="start"){let yr=k.endDate&&ca>k.endDate?ca:k.endDate;Qe(ca,yr),H("end");}else {let yr=k.startDate&&ca<k.startDate?ca:k.startDate;Qe(yr,ca),H(null);}},children:Ie.day},Bt)})})()})]})]})]})})]}),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:c==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{_e(),B(!L);},className:f("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",k.priority==="high"||k.priority==="urgent"?"bg-red-500/20 text-red-400":k.priority==="medium"?"bg-yellow-500/20 text-yellow-400":k.priority==="low"?"bg-green-500/20 text-green-400":l?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:k.priority?k.priority==="high"||k.priority==="urgent"?c==="es"?"Urgente":"Urgent":k.priority==="medium"?c==="es"?"Media":"Medium":c==="es"?"Baja":"Low":c==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:L&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>B(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:c==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:c==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:c==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:c==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:c==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(P=>jsxs("button",{onClick:()=>{te("priority",P.id),B(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",k.priority===P.id&&(l?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:f("w-2 h-2 rounded-full",P.color)}),jsx("span",{className:l?"text-white":"text-gray-900",children:P.label})]},P.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:c==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:f("text-sm",l?"text-white":"text-gray-900"),children:k.startDate&&k.endDate?`${Math.ceil((k.endDate.getTime()-k.startDate.getTime())/(1e3*60*60*24))} ${c==="es"?"d\xEDas":"days"}`:c==="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:c==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[q?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:k.progress||0,onChange:P=>{let xe=parseInt(P.target.value),Z=k.status;xe===100?Z="completed":xe>0?Z="in-progress":Z="todo";let Fe={...k,progress:xe,status:Z};x(Fe),a.onTaskUpdate?.(Fe);},onBlur:()=>O(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:()=>O(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",k.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${k.progress||0}%`}})}),jsxs("span",{className:f("text-sm font-medium min-w-[40px]",l?"text-white":"text-gray-900"),children:[k.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:c==="es"?"Etiquetas":"Tags"}),jsx(nr,{selectedTags:k.tags||[],availableTags:p,onChange:P=>{te("tags",P);},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:c==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[k.dependencies&&k.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:k.dependencies.map(P=>{let xe=e.find(Z=>Z.id===P);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:[xe?.name||P.slice(0,8),jsx("button",{onClick:()=>{let Z=(k.dependencies||[]).filter(Fe=>Fe!==P);te("dependencies",Z);},className:f("ml-0.5 hover:bg-white/20 rounded-full p-0.5 transition-colors"),children:jsx(X,{className:"w-3 h-3"})})]},P)})}),jsxs("button",{onClick:()=>{_e(),sa(!Wt);},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:c==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:Wt&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{sa(false),J("");}}),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:oe,onChange:P=>J(P.target.value),placeholder:c==="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(P=>P.id!==k.id).filter(P=>oe===""||P.name.toLowerCase().includes(oe.toLowerCase())).map(P=>{let xe=k.dependencies?.includes(P.id);return jsxs("button",{onClick:()=>{let Z=k.dependencies||[],Fe;xe?Fe=Z.filter(dt=>dt!==P.id):Fe=[...Z,P.id],te("dependencies",Fe);},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",xe&&(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",xe?"bg-blue-500 border-blue-500":l?"border-white/30":"border-gray-300"),children:xe&&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:P.name}),jsx("span",{className:f("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:P.id.slice(0,8)})]})]},P.id)}):jsx("div",{className:f("px-3 py-4 text-sm text-center",l?"text-[#6B7280]":"text-gray-500"),children:c==="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:()=>{_e(),ae(!Ve);},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:k.color||"#6366F1"}}),jsx("span",{className:f("text-sm",l?"text-white":"text-gray-900"),children:sr.find(P=>P.value===k.color)?.name||(c==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:f("w-3 h-3",l?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:Ve&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>ae(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(P=>{let xe=k.color===P.value;return jsx("button",{onClick:()=>{te("color",P.value),ae(false);},className:f("w-7 h-7 rounded-full flex items-center justify-center transition-all",xe&&"ring-2 ring-offset-2",l?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:P.value,outlineColor:xe?P.value:void 0},title:P.name,children:xe&&jsx(Check,{className:"w-3.5 h-3.5 text-white"})},P.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:c==="es"?"Hito":"Milestone"}),jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:k.isMilestone||false,onChange:P=>te("isMilestone",P.target.checked),className:f("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",k.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:c==="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:c==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:k.description||"",onChange:P=>te("description",P.target.value),placeholder:c==="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"}),c==="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:c==="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"}),c==="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:c==="es"?"Agregar subtarea":"Add subtask"}),k.subtasks&&k.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:k.subtasks.map(P=>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",P.progress===100?"bg-green-500 border-green-500":l?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:P.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:f("text-sm",P.progress===100?"line-through text-[#6B7280]":l?"text-white":"text-gray-900"),children:P.name})]},P.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"}),c==="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:c==="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"}),c==="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:[c==="es"?"Adjuntos":"Attachments",fa.length>0&&jsxs("span",{className:f("ml-2 text-xs font-normal",l?"text-[#6B7280]":"text-gray-400"),children:["(",fa.length,")"]})]}),fa.length>0&&jsx("div",{className:"space-y-2 mb-4",children:fa.map(P=>{let xe=xa(P.type),Z=P.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:[Z&&P.thumbnailUrl?jsx("img",{src:P.thumbnailUrl,alt:P.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(xe,{className:f("w-5 h-5",l?"text-[#9CA3AF]":"text-gray-500")})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("a",{href:P.url,target:"_blank",rel:"noopener noreferrer",className:f("text-sm font-medium truncate block hover:underline",l?"text-white":"text-gray-900"),children:P.name}),jsx("p",{className:f("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:rt(P.size)})]}),a.onDeleteAttachment&&jsx("button",{onClick:()=>a.onDeleteAttachment?.(P.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:c==="es"?"Eliminar":"Delete",children:jsx(Trash2,{className:"w-4 h-4"})})]},P.id)})}),jsxs("div",{onDragOver:$e,onDragLeave:Mt,onDrop:G,className:f("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",It?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",lt&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:ce,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!a.onUploadAttachments||lt}),lt?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:c==="es"?"Subiendo...":"Uploading..."})]}):jsxs(Fragment,{children:[jsx(Upload,{className:f("w-6 h-6 mx-auto mb-2",It?"text-blue-500":l?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:f("text-sm",l?"text-[#9CA3AF]":"text-gray-500"),children:It?c==="es"?"Suelta los archivos aqu\xED":"Drop files here":c==="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:c==="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:[c==="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(P=>{let xe=(()=>{let Z=new Date,Fe=new Date(P.createdAt),dt=Z.getTime()-Fe.getTime(),se=Math.floor(dt/6e4),He=Math.floor(se/60),Dt=Math.floor(He/24);return se<1?c==="es"?"ahora":"now":se<60?c==="es"?`hace ${se}m`:`${se}m ago`:He<24?c==="es"?`hace ${He}h`:`${He}h ago`:c==="es"?`hace ${Dt}d`:`${Dt}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:P.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:P.user?.name||(c==="es"?"Usuario":"User")}),jsx("span",{className:f("text-xs",l?"text-[#6B7280]":"text-gray-400"),children:xe})]}),jsx("p",{className:f("text-sm break-words",l?"text-[#9CA3AF]":"text-gray-600"),children:P.content})]})]},P.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:c==="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:[b&&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:b.color||"#8B5CF6"},children:b.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:E,onChange:P=>X$1(P.target.value),onKeyDown:async P=>{if(P.key==="Enter"&&!P.shiftKey&&k&&E.trim()&&g){P.preventDefault(),Le(true);try{await g(k.id,E.trim()),X$1("");}finally{Le(false);}}},placeholder:c==="es"?"Escribe un comentario...":"Write a comment...",disabled:de||!g,className:f("flex-1 bg-transparent text-sm outline-none",l?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400",(de||!g)&&"opacity-50")}),jsx("button",{onClick:async()=>{if(k&&E.trim()&&g){Le(true);try{await g(k.id,E.trim()),X$1("");}finally{Le(false);}}},disabled:de||!E.trim()||!g,className:f("p-1.5 rounded transition-colors",E.trim()&&g?"bg-blue-500 text-white hover:bg-blue-600":l?"text-[#6B7280]":"text-gray-400",de&&"opacity-50 cursor-not-allowed"),children:de?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:R&&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: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:R.date.toLocaleDateString(c==="es"?"es-ES":"en-US",{weekday:"long",month:"long",day:"numeric"})}),jsx("button",{onClick:()=>A(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:R.events.map(P=>jsxs("button",{onClick:()=>{A(null),x(P.task),C?.(P.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(Vc,{task:P.task}),jsx("span",{className:f("text-sm truncate flex-1",l?"text-white":"text-gray-900"),children:P.title}),P.task.priority==="high"||P.task.priority==="urgent"?jsx(Flag,{className:"w-3.5 h-3.5 text-red-400"}):null]},P.id))})]})]})})]})}var Ui={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"},Hi={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"},Wi={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:Ui,light:Hi,neutral:Wi};function Yc(e){return _n[e]||_n.dark}function yh({stack:e,cards:t,renderCard:a,onCardClick:r,onToggleExpand:o,onUnstack:s,onDeleteStack:n,className:m}){let[p,i]=useState(false),u=useMemo(()=>t.filter(b=>e.cardIds.includes(b.id)),[t,e.cardIds]),d=useMemo(()=>{let b=u.length,C=new Set(u.flatMap(h=>h.assignedUserIds||[])).size,T=u.map(h=>h.priority).filter(Boolean),c=new Set(u.flatMap(h=>h.labels||[])).size;return {totalCards:b,uniqueAssignees:C,priorities:T,labels:c}},[u]),g=()=>{o?.(e.id);};return jsxs("div",{className:f("card-stack",!e.isExpanded&&"card-stack-collapsed",m),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:b=>{b.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(b=>jsxs("div",{className:"card-stack-card-wrapper",children:[a?jsx("div",{onClick:()=>r?.(b),children:a(b)}):jsxs("div",{className:"card-stack-default-card",onClick:()=>r?.(b),children:[jsx("h4",{children:b.title}),b.description&&jsxs("p",{children:[b.description.substring(0,100),"..."]})]}),jsx("button",{className:"card-stack-unstack-btn",onClick:C=>{C.stopPropagation(),s?.(e.id,b.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"})]})})]},b.id))})})]})}var Xc={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 Qc({events:e,filter:t,onFilterChange:a,onClearFilter:r,onEventClick:o,selectedEventId:s,config:n,className:m}){let p=useMemo(()=>({...Xc,...n}),[n]),[i,u]=useState(new Set),d=useRef(null),g=useMemo(()=>{if(!p.groupByDay)return [{date:null,events:e}];let v=new Map;return e.forEach(l=>{let w=l.timestamp.toISOString().split("T")[0],y=v.get(w);y?y.push(l):v.set(w,[l]);}),Array.from(v.entries()).sort((l,w)=>w[0].localeCompare(l[0])).map(([l,w])=>({date:new Date(l),events:w.sort((y,S)=>S.timestamp.getTime()-y.timestamp.getTime())}))},[e,p.groupByDay]),{uniqueUsers:b,uniqueTypes:C}=useMemo(()=>{let v=new Set,l=new Set;return e.forEach(w=>{v.add(w.userId),l.add(w.type);}),{uniqueUsers:Array.from(v),uniqueTypes:Array.from(l)}},[e]),T=v=>{u(l=>{let w=new Set(l);return w.has(v)?w.delete(v):w.add(v),w});},c=v=>{let w=new Date().getTime()-v.getTime(),y=Math.floor(w/6e4),S=Math.floor(w/36e5),k=Math.floor(w/864e5);return y<1?"just now":y<60?`${y}m ago`:S<24?`${S}h ago`:k<7?`${k}d ago`:v.toLocaleDateString()},h=useMemo(()=>{let v=0;return t.types&&t.types.length>0&&v++,t.users&&t.users.length>0&&v++,t.dateRange&&v++,t.searchTerm&&v++,v},[t]);return useEffect(()=>{if(s&&d.current){let v=d.current.querySelector(`[data-event-id="${s}"]`);v&&v.scrollIntoView({behavior:"smooth",block:"center"});}},[s]),e.length===0?jsxs("div",{className:f("history-timeline-empty",m),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",m),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:v=>{let l=v.target.value;a({...t,types:l?[l]:void 0});},children:[jsx("option",{value:"",children:"All Events"}),C.map(v=>jsxs("option",{value:v,children:[Vo(v)," ",v.replace("_"," ")]},v))]}),b.length>1&&jsxs("select",{className:"history-timeline-filter-select",value:t.users?.[0]||"",onChange:v=>{let l=v.target.value;a({...t,users:l?[l]:void 0});},children:[jsx("option",{value:"",children:"All Users"}),b.map(v=>jsx("option",{value:v,children:v},v))]}),jsx("input",{type:"text",className:"history-timeline-filter-search",placeholder:"Search history...",value:t.searchTerm||"",onChange:v=>a({...t,searchTerm:v.target.value})})]}),h>0&&jsxs("button",{className:"history-timeline-filter-clear",onClick:r,children:["Clear filters (",h,")"]})]}),jsx("div",{className:"history-timeline-container",ref:d,children:g.map(v=>jsxs("div",{className:"history-timeline-group",children:[p.groupByDay&&v.date&&jsxs("div",{className:"history-timeline-day-header",children:[jsx("span",{className:"history-timeline-day-date",children:v.date.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),jsxs("span",{className:"history-timeline-day-count",children:[v.events.length," events"]})]}),jsx("div",{className:"history-timeline-events",children:v.events.map((l,w)=>{let y=i.has(l.id),S=s===l.id,k=Jc(l.type);return jsxs("div",{"data-event-id":l.id,className:f("history-timeline-event",y&&"expanded",S&&"selected"),onClick:()=>o?.(l),children:[jsxs("div",{className:"history-timeline-line",children:[jsx("div",{className:"history-timeline-dot",style:{backgroundColor:k},children:p.showIcons&&jsx("span",{className:"history-timeline-dot-icon",children:Vo(l.type)})}),w<v.events.length-1&&jsx("div",{className:"history-timeline-connector",style:{borderColor:k}})]}),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?c(l.timestamp):l.timestamp.toLocaleString()})]}),Object.keys(l.changes).length>0&&jsxs("button",{className:"history-timeline-event-toggle",onClick:x=>{x.stopPropagation(),T(l.id);},children:[y?"\u25BC":"\u25B6"," Show changes"]}),y&&jsxs("div",{className:"history-timeline-event-changes",children:[Object.entries(l.changes).map(([x,R])=>jsxs("div",{className:"history-timeline-event-change",children:[jsxs("span",{className:"history-timeline-event-change-key",children:[x,":"]}),jsxs("div",{className:"history-timeline-event-change-values",children:[jsx("span",{className:"history-timeline-event-change-from",children:JSON.stringify(R.from)}),jsx("span",{className:"history-timeline-event-change-arrow",children:"\u2192"}),jsx("span",{className:"history-timeline-event-change-to",children:JSON.stringify(R.to)})]})]},x)),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(([x,R])=>jsxs("div",{className:"history-timeline-event-metadata-item",children:[jsxs("span",{className:"history-timeline-event-metadata-key",children:[x,":"]}),jsx("span",{className:"history-timeline-event-metadata-value",children:JSON.stringify(R)})]},x))]})]})]})]},l.id)})})]},v.date?.toISOString()||"all"))})]})}function ep({replayState:e,events:t,onStartReplay:a,onStopReplay:r,onTogglePlayback:o,onPrevious:s,onNext:n,onGoToEvent:m,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:b=>m(parseInt(b.target.value))}),jsx("div",{className:"history-replay-progress-fill",style:{width:`${g}%`}}),jsx("div",{className:"history-replay-progress-markers",children:t.map((b,C)=>jsx("div",{className:f("history-replay-progress-marker",C===e.currentIndex&&"active"),style:{left:`${C/(e.totalEvents-1)*100}%`},onClick:()=>m(C),title:_o(b)},b.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(b=>jsxs("button",{className:f("history-replay-speed-btn",e.speed===b&&"active"),onClick:()=>p(b),children:[b,"x"]},b))})]}),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(b=>jsx("span",{className:"history-replay-card-preview-label-tag",children:b},b))})]})]})]})]}):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 Gi(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 _i(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 tp(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 ap(e){return ["blocks","blocked_by","depends_on","required_by","parent_of","child_of"].includes(e)}function Th(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})),m=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(b=>{if(u.id===b.id)return;let C=u.x-b.x,T=u.y-b.y,c=Math.sqrt(C*C+T*T)||1,h=o.chargeStrength*i/(c*c);u.vx+=C/c*h,u.vy+=T/c*h;});}),t.forEach(u=>{let d=m.get(typeof u.source=="string"?u.source:u.source.id),g=m.get(typeof u.target=="string"?u.target:u.target.id);if(!d||!g)return;let b=g.x-d.x,C=g.y-d.y,T=Math.sqrt(b*b+C*C)||1,c=(T-o.linkDistance)/T*o.forceStrength*i;d.vx+=b*c,d.vy+=C*c,g.vx-=b*c,g.vy-=C*c;}),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 rp({nodes:e,edges:t,config:a,filter:r,onFilterChange:o,criticalPath:s,stats:n,onInteraction:m,className:p}){let i=useRef(null),[u,d]=useState([]),[g,b]=useState(null),[C,T]=useState(null),[c,h]=useState(null),[v,l]=useState(1),[w,y]=useState({x:0,y:0});useEffect(()=>{if(e.length===0)return;let $=Th(e,t,a.width,a.height,a,150);d($);},[e,t,a]);let S=useCallback(($,_)=>{a.enableDragging&&(_.stopPropagation(),b($));},[a.enableDragging]),k=useCallback($=>{if(!g||!i.current)return;let V=i.current.getBoundingClientRect(),ie=($.clientX-V.left-w.x)/v,Be=($.clientY-V.top-w.y)/v;d(Oe=>Oe.map(ze=>ze.id===g?{...ze,x:ie,y:Be,fx:ie,fy:Be}:ze));},[g,v,w]),x=useCallback(()=>{b(null);},[]),R=useCallback(($,_)=>{_.stopPropagation(),m?.({type:"node-click",node:$,position:{x:_.clientX,y:_.clientY}});},[m]),A=useCallback(($,_)=>{_.stopPropagation(),m?.({type:"edge-click",edge:$,position:{x:_.clientX,y:_.clientY}});},[m]),N=useCallback($=>{let _=u.find(V=>V.id===$);return _?{x:_.x,y:_.y}:{x:0,y:0}},[u]),H=useCallback($=>{if($.onCriticalPath)return "#ef4444";switch(a.colorScheme){case "status":return $.card.columnId==="done"?"#10b981":"#3b82f6";case "priority":let _=$.card.priority;return _==="URGENT"?"#ef4444":_==="HIGH"?"#f59e0b":_==="MEDIUM"?"#3b82f6":"#6b7280";case "assignee":return $.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($=>Math.min($+.2,3)),children:"+"}),jsxs("span",{className:"relationships-graph-zoom-value",children:[Math.round(v*100),"%"]}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>l($=>Math.max($-.2,.5)),children:"\u2212"}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>{l(1),y({x:0,y:0});},children:"Reset"})]})]}),jsx("div",{className:"relationships-graph-legend",children:Array.from(new Set(t.map($=>$.type))).map($=>jsxs("div",{className:"relationships-graph-legend-item",children:[jsx("div",{className:"relationships-graph-legend-color",style:{background:Gi($)}}),jsxs("span",{className:"relationships-graph-legend-label",children:[tp($)," ",_i($)]})]},$))}),jsxs("svg",{ref:i,className:"relationships-graph-canvas",width:a.width,height:a.height,onMouseMove:k,onMouseUp:x,onMouseLeave:x,children:[jsxs("g",{transform:`translate(${w.x}, ${w.y}) scale(${v})`,children:[jsx("g",{className:"relationships-graph-edges",children:t.map($=>{let _=N(typeof $.source=="string"?$.source:$.source.id),V=N(typeof $.target=="string"?$.target:$.target.id),ie=ap($.type),Be=c===$.id,Oe=$.onCriticalPath;return jsxs("g",{className:f("relationships-graph-edge",Be&&"hovered",Oe&&"critical"),onMouseEnter:()=>h($.id),onMouseLeave:()=>h(null),onClick:ze=>A($,ze),children:[jsx("line",{x1:_.x,y1:_.y,x2:V.x,y2:V.y,stroke:Gi($.type),strokeWidth:Oe?a.edgeWidth*2:a.edgeWidth,strokeOpacity:Be?1:.6,markerEnd:ie?"url(#arrowhead)":void 0}),a.showEdgeLabels&&Be&&jsx("text",{x:(_.x+V.x)/2,y:(_.y+V.y)/2,className:"relationships-graph-edge-label",textAnchor:"middle",children:_i($.type)})]},$.id)})}),jsx("g",{className:"relationships-graph-nodes",children:u.map($=>{let _=C===$.id,V=$.onCriticalPath;return jsxs("g",{className:f("relationships-graph-node",_&&"hovered",V&&"critical"),transform:`translate(${$.x}, ${$.y})`,onMouseDown:ie=>S($.id,ie),onMouseEnter:()=>T($.id),onMouseLeave:()=>T(null),onClick:ie=>R($,ie),children:[jsx("circle",{r:V?a.nodeSize*1.2:a.nodeSize,fill:H($),stroke:V?"#fbbf24":"#ffffff",strokeWidth:V?3:2,opacity:_?1:.9}),a.showLabels&&jsx("text",{y:a.nodeSize+20,className:"relationships-graph-node-label",textAnchor:"middle",children:$.card.title.length>20?$.card.title.substring(0,20)+"...":$.card.title})]},$.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 sp({isOpen:e,onClose:t,onPlanGenerated:a,onGeneratePlan:r,isLoading:o}){let[s,n]=useState(""),[m,p]=useState(false),[i,u]=useState(null),[d,g]=useState(null),b=useRef(null),C=m||o;useEffect(()=>{e&&b.current&&b.current.focus();},[e]),useEffect(()=>{let v=l=>{l.key==="Escape"&&!C&&T();};if(e)return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[e,C]);let T=()=>{C||(n(""),u(null),g(null),t());},c=async()=>{if(!(!s.trim()||C)){p(true),u(null),g(null);try{let v=await r(s.trim());g(v);}catch(v){u(v instanceof Error?v.message:"Failed to generate plan");}finally{p(false);}}},h=()=>{d&&(a(d),T());};return e?jsxs(ht,{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:v=>v.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((v,l)=>jsx("div",{className:"px-3 py-1.5 rounded-lg bg-white/5 border border-white/20 text-sm text-white/80",children:v.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((v,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:v.title}),v.description&&jsx("p",{className:"text-xs text-white/60 mt-1 line-clamp-2",children:v.description})]}),v.priority&&jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${v.priority==="URGENT"?"bg-red-500/20 text-red-400":v.priority==="HIGH"?"bg-orange-500/20 text-orange-400":v.priority==="MEDIUM"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:v.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:b,value:s,onChange:v=>n(v.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((v,l)=>jsx("button",{onClick:()=>n(v),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:v},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:h,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:c,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 Vi={"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 Dh={hobby:{requestsPerMonth:50,maxConcurrent:1,maxTokensPerRequest:4096},pro:{requestsPerMonth:500,maxConcurrent:3,maxTokensPerRequest:8192},enterprise:{requestsPerMonth:2e3,maxConcurrent:10,maxTokensPerRequest:16384}},Sh={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 Eh(e,t,a){let r=Vi[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 ji=class{constructor(){this.operations=[];this.listeners=[];}record(t){let a=Eh(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),m=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?m.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 m=this.operations.filter(u=>u.timestamp>=n).length,p=Math.max(0,o-m),i=m/o*100;return {used:m,limit:o,remaining:p,percentUsed:i,isExceeded:m>=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)}},Qr=new ji;function dp({isOpen:e,onClose:t,planTier:a="hobby"}){let[r,o]=useState(Qr.getStats()),[s,n]=useState(Qr.checkLimit(a));if(useEffect(()=>{if(!e)return;let p=setInterval(()=>{o(Qr.getStats()),n(Qr.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 m=Qr.getRecentOperations(5);return jsxs(ht,{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"}),m.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:m.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 mp({isOpen:e,onClose:t,onTasksGenerated:a,onGenerateTasks:r,isLoading:o,projectName:s}){let[n,m]=useState(""),[p,i]=useState(""),[u,d]=useState(""),[g,b]=useState(false),[C,T]=useState(null),[c,h]=useState(null),[v,l]=useState(null),w=useRef(null),y=g||o;useEffect(()=>{e&&w.current&&w.current.focus();},[e]),useEffect(()=>{let A=N=>{N.key==="Escape"&&!y&&S();};if(e)return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[e,y]);let S=()=>{y||(m(""),i(""),d(""),T(null),h(null),l(null),t());},k=async()=>{if(!(!n.trim()||y)){b(true),T(null),h(null),l(null);try{let A=await r({prompt:n.trim(),projectName:s||"Mi Proyecto",startDate:p||void 0,endDate:u||void 0});h(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{b(false);}}},x=()=>{c&&(a(c),S());};if(!e)return null;let R=v?.similarity?((v.similarity||0)*100).toFixed(0):"0";return jsxs(ht,{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:y,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:c?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:[v?.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"}),v?.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 (",R,"% 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:[v?.tokens_used||0," tokens"]}),v?.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:[v.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:[c.length," tasks"]})]}),jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:c.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=>m(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:y}),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:y})]}),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:y})]})]}),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:()=>m(A),disabled:y,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:y&&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:y,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"}),c?jsx("button",{onClick:x,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:k,disabled:!n.trim()||y,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:y?"Generating...":"Generate Tasks"})]})]})]})})]})}function Kn({initialBoard:e,onPersist:t}){let[a,r]=useState(e),o=useCallback(c=>{t&&tn(()=>Promise.resolve(t(c)),{maxAttempts:3,initialDelay:1e3,onRetry:(h,v,l)=>{console.warn(`Retry attempt ${v} after ${l}ms: ${h.message}`);}}).then(h=>{h.success||console.error(`Failed to persist board after ${h.attempts} attempts:`,h.error);});},[t]),s=useCallback(async(c,h,v)=>{r(l=>{let w=l.cards.find(A=>A.id===c);if(!w)return l;let y=w.columnId,S={...w,columnId:h,position:v},k=l.cards.map(A=>A.id===c?S:A),x=l.columns.map(A=>{if(A.id===y)return {...A,cardIds:A.cardIds.filter(N=>N!==c)};if(A.id===h){let N=k.filter(H=>H.columnId===h).sort((H,$)=>H.position-$.position);return {...A,cardIds:N.map(H=>H.id)}}return A}),R={...l,cards:k,columns:x};return o(R),R});},[o]),n=useCallback(async(c,h)=>{r(v=>{let l=v.cards.map(y=>y.id===c?{...y,...h}:y),w={...v,cards:l};return o(w),w});},[o]),m=useCallback(async c=>{let h=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(v=>{let l={...c,id:h},w=v.columns.map(S=>S.id===c.columnId?{...S,cardIds:[...S.cardIds,h]}:S),y={...v,cards:[...v.cards,l],columns:w};return o(y),y});},[o]),p=useCallback(async c=>{r(h=>{let v=h.cards.find(S=>S.id===c);if(!v)return h;let l=h.cards.filter(S=>S.id!==c),w=h.columns.map(S=>S.id===v.columnId?{...S,cardIds:S.cardIds.filter(k=>k!==c)}:S),y={...h,cards:l,columns:w};return o(y),y});},[o]),i=useCallback(async c=>{let h=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(v=>{let l={...c,id:h,cardIds:[]},w={...v,columns:[...v.columns,l]};return o(w),w});},[o]),u=useCallback(async(c,h)=>{r(v=>{let l=v.columns.map(y=>y.id===c?{...y,...h}:y),w={...v,columns:l};return o(w),w});},[o]),d=useCallback(async c=>{r(h=>{let v=h.cards.filter(y=>y.columnId!==c),l=h.columns.filter(y=>y.id!==c),w={...h,cards:v,columns:l};return o(w),w});},[o]),g=useCallback(c=>{let h=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return m(c),h},[m]),b=useCallback(c=>{let h=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return i(c),h},[i]),C=useCallback(()=>{r(c=>{let h={...c,cards:[],columns:[]};return o(h),h});},[o]);return {board:a,callbacks:{onCardMove:s,onCardUpdate:n,onCardCreate:m,onCardDelete:p,onColumnCreate:i,onColumnUpdate:u,onColumnDelete:d},setBoard:r,helpers:{addCard:g,addColumn:b,deleteCard:p,deleteColumn:d,clearBoard:C}}}function gp({initialData:e,availableUsers:t=[],onSave:a}){let{board:r,callbacks:o,helpers:s}=Kn({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:""},hp={by:"none",order:"asc"};function bp({initialFilters:e={},initialSort:t={},currentUserId:a}={}){let[r,o]=useState({...Ko,...e}),[s,n]=useState({...hp,...t}),m=useCallback(T=>{o(c=>({...c,...T}));},[]),p=useCallback(T=>{n(c=>({...c,...T}));},[]),i=useCallback(()=>{o(Ko),n(hp);},[]),u=useCallback(()=>{a&&o({...Ko,assignees:[a]});},[a]),d=useCallback(()=>{o({...Ko,dateFilter:"overdue"});},[]),g=useCallback(()=>{o({...Ko,priorities:["HIGH","URGENT"]});},[]),b=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 c=[...T];if(r.search){let h=r.search.toLowerCase();c=c.filter(v=>v.title.toLowerCase().includes(h)||v.description?.toLowerCase().includes(h));}if(r.dateFilter!=="all"){let h=new Date,v=h.getFullYear(),l=String(h.getMonth()+1).padStart(2,"0"),w=String(h.getDate()).padStart(2,"0"),y=`${v}-${l}-${w}`;c=c.filter(S=>{if(!S.endDate&&!S.dueDate)return false;let k=S.endDate||S.dueDate;if(!k)return false;let x;if(typeof k=="string")x=k.split("T")[0]||k;else {let R=k.getUTCFullYear(),A=String(k.getUTCMonth()+1).padStart(2,"0"),N=String(k.getUTCDate()).padStart(2,"0");x=`${R}-${A}-${N}`;}switch(r.dateFilter){case "overdue":return x<y;case "today":return x===y;case "this-week":let R=new Date(y+"T00:00:00"),A=new Date(x+"T00:00:00"),N=new Date(R);return N.setDate(N.getDate()+7),A>=R&&A<=N;case "custom":if(r.dateRange){let H=typeof k=="string"?new Date(k):k;return H>=r.dateRange.start&&H<=r.dateRange.end}return true;default:return true}});}return r.priorities.length>0&&(c=c.filter(h=>h.priority&&r.priorities.includes(h.priority))),r.assignees.length>0&&(c=c.filter(h=>(h.assignedUserIds||(h.assigneeId?[h.assigneeId]:[])).some(l=>r.assignees.includes(l)))),r.labels.length>0&&(c=c.filter(h=>h.labels&&h.labels.some(v=>r.labels.includes(v)))),r.columns.length>0&&(c=c.filter(h=>r.columns.includes(h.columnId))),s.by!=="none"&&c.sort((h,v)=>{let l=0;switch(s.by){case "created":let w=h.createdAt?new Date(h.createdAt).getTime():0,y=v.createdAt?new Date(v.createdAt).getTime():0;l=w-y;break;case "priority":let S={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},k=S[h.priority||"LOW"],x=S[v.priority||"LOW"];l=k-x;break;case "dueDate":let R=h.endDate||h.dueDate,A=v.endDate||v.dueDate;if(!R)return 1;if(!A)return -1;let N=typeof R=="string"?new Date(R).getTime():R.getTime(),H=typeof A=="string"?new Date(A).getTime():A.getTime();l=N-H;break;case "title":l=h.title.localeCompare(v.title);break;case "estimate":let $=h.estimatedTime||0,_=v.estimatedTime||0;l=$-_;break;default:l=0;}return s.order==="asc"?l:-l}),c},[r,s]);return {filters:r,sort:s,setFilters:m,setSort:p,resetFilters:i,filterMyTasks:u,filterOverdue:d,filterHighPriority:g,applyFilters:C,hasActiveFilters:b}}var vp,xp;if(typeof window<"u")try{let e=Qo("ai");vp=e.generateObject,xp=e.generateText;}catch{}function kp(e={}){let[t,a]=useState(false),[r,o]=useState(null),s=!!(vp&&xp&&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 b=g instanceof Error?g:new Error("Failed to generate plan");throw o(b),b}finally{a(false);}},[s]),m=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 b=g instanceof Error?g:new Error("Failed to suggest assignee");throw o(b),b}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 b=g instanceof Error?g:new Error("Failed to predict risks");throw o(b),b}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 b=g instanceof Error?g:new Error("Failed to generate subtasks");throw o(b),b}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 b=g instanceof Error?g:new Error("Failed to estimate effort");throw o(b),b}finally{a(false);}},[s]);return {onGeneratePlan:n,onSuggestAssignee:m,onPredictRisks:p,onGenerateSubtasks:i,onEstimateEffort:u,isAvailable:s,isLoading:t,error:r}}function Yi(){let[e,t]=useState(()=>selectionStore.getState());useEffect(()=>selectionStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{selectionStore.setState(r);},[]);return [e,a]}function wp(e){let{cards:t}=e,[a,r]=Yi(),o=useCallback(d=>a.selectedCardIds.includes(d),[a.selectedCardIds]),s=useCallback((d,g)=>{if(!g){r({selectedCardIds:[d],lastSelectedCardId:d});return}let b=g.ctrlKey||g.metaKey,C=g.shiftKey;if(b)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(h=>h.id===d),c=t.find(h=>h.id===a.lastSelectedCardId);if(T&&c&&T.columnId===c.columnId){let h=t.filter(x=>x.columnId===T.columnId).sort((x,R)=>x.position-R.position),v=h.findIndex(x=>x.id===a.lastSelectedCardId),l=h.findIndex(x=>x.id===d),[w,y]=v<l?[v,l]:[l,v],S=h.slice(w,y+1).map(x=>x.id),k=Array.from(new Set([...a.selectedCardIds,...S]));r({selectedCardIds:k,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]),m=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:m,selectAll:p,toggleCard:i,getSelectedCards:u}}var Cp={enableAutoStacking:true,autoStackConfidenceThreshold:.7,minCardsPerStack:2,enableManualStacking:true,showStackSummaries:true,animationDuration:200};function Tp(e){let{cards:t,config:a,aiService:r}=e,o=useMemo(()=>({...Cp,...a}),[a]),[s,n]=useState([]),m=useCallback((T,c,h,v,l)=>{if(c.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:c,columnId:h,strategy:v,color:l,isExpanded:true,position:s.filter(y=>y.columnId===h).length,createdAt:new Date};n(y=>[...y,w]);},[o.minCardsPerStack,s]),p=useCallback(T=>{n(c=>c.filter(h=>h.id!==T));},[]),i=useCallback(T=>{n(c=>c.map(h=>h.id===T?{...h,isExpanded:!h.isExpanded}:h));},[]),u=useCallback((T,c)=>{n(h=>h.map(v=>v.id===T&&!v.cardIds.includes(c)?{...v,cardIds:[...v.cardIds,c]}:v));},[]),d=useCallback((T,c)=>{n(h=>h.map(v=>{if(v.id===T){let l=v.cardIds.filter(w=>w!==c);return l.length<o.minCardsPerStack?null:{...v,cardIds:l}}return v}).filter(v=>v!==null));},[o.minCardsPerStack]),g=useCallback(T=>s.filter(c=>c.columnId===T).sort((c,h)=>c.position-h.position),[s]),b=useCallback(async T=>{let c=t.filter(y=>y.columnId===T);if(c.length<o.minCardsPerStack*2)return [];let h=[],v=new Map;c.forEach(y=>{y.labels&&y.labels.length>0&&y.labels.forEach(S=>{v.has(S)||v.set(S,[]),v.get(S).push(y);});}),v.forEach((y,S)=>{y.length>=o.minCardsPerStack&&h.push({stack:{title:`\u{1F4CC} ${S}`,cardIds:y.map(k=>k.id),columnId:T,strategy:"labels",color:"#3b82f6"},reason:`${y.length} cards with label "${S}"`,confidence:.85});});let l=new Map;c.forEach(y=>{y.assignedUserIds&&y.assignedUserIds.length>0&&y.assignedUserIds.forEach(S=>{l.has(S)||l.set(S,[]),l.get(S).push(y);});}),l.forEach((y,S)=>{y.length>=o.minCardsPerStack&&h.push({stack:{title:`\u{1F464} Assigned to user-${S.slice(-4)}`,cardIds:y.map(k=>k.id),columnId:T,strategy:"assignee",color:"#8b5cf6"},reason:`${y.length} cards assigned to the same user`,confidence:.8});});let w=new Map;if(c.forEach(y=>{y.priority&&(w.has(y.priority)||w.set(y.priority,[]),w.get(y.priority).push(y));}),w.forEach((y,S)=>{if(y.length>=o.minCardsPerStack){let k={low:"\u{1F7E2}",medium:"\u{1F7E1}",high:"\u{1F534}",urgent:"\u{1F6A8}"}[S.toLowerCase()]||"\u26AA";h.push({stack:{title:`${k} ${S} Priority`,cardIds:y.map(x=>x.id),columnId:T,strategy:"priority",color:S==="high"||S==="urgent"?"#ef4444":"#10b981"},reason:`${y.length} cards with ${S} priority`,confidence:.75});}}),r&&o.enableAutoStacking)for(let y of c){let k=(await r.findSimilar(y,c)).filter(x=>x.similarity>=o.autoStackConfidenceThreshold);if(k.length>=o.minCardsPerStack-1){let x=[y.id,...k.map(A=>A.card.id)],R=k.reduce((A,N)=>A+N.similarity,0)/k.length;h.push({stack:{title:`\u2728 Similar to "${y.title.substring(0,30)}${y.title.length>30?"...":""}"`,cardIds:x,columnId:T,strategy:"ai-similarity",color:"#f59e0b"},reason:`AI detected ${k.length+1} similar tasks`,confidence:R});}}return h.filter(y=>y.confidence>=o.autoStackConfidenceThreshold).sort((y,S)=>S.confidence-y.confidence).slice(0,5)},[t,o,r]),C=useCallback(T=>{m(T.stack.title,T.stack.cardIds,T.stack.columnId,T.stack.strategy,T.stack.color);},[m]);return useEffect(()=>{o.enableAutoStacking&&s.length===0&&new Set(t.map(c=>c.columnId)).forEach(async c=>{let h=await b(c),v=h[0];h.length>0&&v&&v.confidence>=.9&&C(v);});},[]),{stacks:s,createStack:m,deleteStack:p,toggleStack:i,addToStack:u,removeFromStack:d,getStacksForColumn:g,getSuggestions:b,applySuggestion:C,config:o}}var Np=createContext(null);function Dp({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 m=null;if(t?.board){let{Board:p}=Qo("@libxai/core");m=new p(t.board);}r.current=new BoardStore({board:m,columns:s,cards:n});}let o=r.current;return useEffect(()=>{if(a)return o.subscribeAll(s=>{a(o.getState());})},[o,a]),jsx(Np.Provider,{value:{store:o},children:e})}function Yn(){let e=useContext(Np);if(!e)throw new Error("useBoardStore must be used within BoardProvider");return e.store}function qo(){let e=Yn(),[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 m=useCallback(v=>{e.updateBoard(v);},[e]),p=useCallback(v=>{e.addColumn(v);},[e]),i=useCallback((v,l)=>{e.updateColumn(v,l);},[e]),u=useCallback(v=>{e.deleteColumn(v);},[e]),d=useCallback(v=>e.getColumn(v),[e]),g=useCallback(v=>{e.addCard(v);},[e]),b=useCallback((v,l)=>{e.updateCard(v,l);},[e]),C=useCallback(v=>{e.deleteCard(v);},[e]),T=useCallback((v,l,w)=>{e.moveCard(v,l,w);},[e]),c=useCallback(v=>e.getCard(v),[e]),h=useCallback(v=>e.getCardsByColumn(v),[e]);return {board:t,columns:r,cards:s,updateBoard:m,addColumn:p,updateColumn:i,deleteColumn:u,getColumn:d,addCard:g,updateCard:b,deleteCard:C,moveCard:T,getCard:c,getCardsByColumn:h}}function Ep(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 Pp(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 m={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},p=o.priority?m[o.priority]:0,i=s.priority?m[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 qn=class{constructor(){this.plugins=new Map;this.enabled=new Set;this.config=new Map;this.context=null;this.pluginLogger=Nl.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 m=await Promise.resolve(n.apply(s,a));m!==void 0&&(o=m,a[0]=m);}catch(m){this.pluginLogger.error(`Plugin hook failed: ${s.id}.${t}`,m,{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);}},Vh=new qn;function Ap({items:e,height:t,estimateSize:a,renderItem:r,className:o="",overscan:s=5,horizontal:n=false,gap:m=0,getItemKey:p}){let i=useRef(null),u=useVirtualizer({count:e.length,getScrollElement:()=>i.current,estimateSize:()=>a,overscan:s,horizontal:n,gap:m}),d=u.getVirtualItems(),g={height:typeof t=="number"?`${t}px`:t,width:"100%",overflow:"auto",position:"relative"},b=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:b,children:d.map(C=>{let T=e[C.index];if(!T)return null;let c=p?p(T,C.index):C.index,h={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:h,"data-index":C.index,children:r(T,C.index)},c)})})})}function Fp(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 Ip({items:e,height:t,width:a="100%",estimateColumnWidth:r,renderColumn:o,className:s="",overscan:n=3,gap:m=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:m}),g=d.getVirtualItems(),b={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:b,className:s,children:jsx("div",{style:C,children:g.map(T=>{let c=e[T.index];if(!c)return null;let h=p?p(c,T.index):T.index,v={position:"absolute",top:0,left:T.start,width:T.size,height:"100%"};return jsx("div",{style:v,"data-index":T.index,children:o(c,T.index)},h)})})})}function Bp(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 Rp(e,t=10){return e>t}var Qi={none:0,xs:4,sm:8,md:12,lg:16,xl:20,"2xl":24,"3xl":32,"4xl":40,"5xl":48,"6xl":64},Zi={none:0,sm:4,md:8,lg:12,xl:16,"2xl":20,full:9999},el={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48},tl={light:300,normal:400,medium:500,semibold:600,bold:700,extrabold:800},al={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},rl={base:0,dropdown:1e3,sticky:1020,fixed:1030,modalBackdrop:1040,modal:1050,popover:1060,tooltip:1070},ol={instant:0,fastest:75,faster:100,fast:150,normal:200,slow:300,slower:400,slowest:500},nl={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)"},sl={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)"},il={0:0,5:.05,10:.1,20:.2,30:.3,40:.4,50:.5,60:.6,70:.7,80:.8,90:.9,100:1},ll={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}},dl={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}},Xn={spacing:Qi,borderRadius:Zi,fontSize:el,fontWeight:tl,lineHeight:al,zIndex:rl,duration:ol,easing:nl,shadows:sl,opacity:il,kanban:ll,gantt:dl};function $p(e,t,a){return e[t]??a}function cl(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)?cl(o,s,a):(typeof o=="string"||typeof o=="number")&&(a[s]=o);}return a}function Yh(e){return typeof e=="number"?e>0&&e<1e3?`${e}px`:e.toString():e}function pl(e="asakaa"){let t=cl(Xn),a=[];for(let[r,o]of Object.entries(t)){let s=`--${e}-${r}`,n=Yh(o);a.push(` ${s}: ${n};`);}return `:root {
390
390
  ${a.join(`
391
391
  `)}
392
392
  }`}function Xo(e,t="asakaa"){let a=[],r=cl(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 Jn={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"}},pl={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"}},ul={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 gl(e=Jn,t="asakaa"){let a=ml(t),r=Xo(e,t);return `${a}
395
+ }`}var Jn={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"}},ml={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"}},ul={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 gl(e=Jn,t="asakaa"){let a=pl(t),r=Xo(e,t);return `${a}
396
396
 
397
- ${r}`}function Om(){return `/**
397
+ ${r}`}function Op(){return `/**
398
398
  * ASAKAA Design Tokens
399
399
  * Auto-generated from design-tokens.ts
400
400
  * Do not edit this file directly
@@ -404,7 +404,7 @@ ${gl(Jn)}
404
404
 
405
405
  /* Light theme */
406
406
  [data-theme="light"] {
407
- ${Xo(pl,"asakaa").split(`
407
+ ${Xo(ml,"asakaa").split(`
408
408
  `).slice(1,-1).join(`
409
409
  `)}
410
410
  }
@@ -415,6 +415,6 @@ ${Xo(ul,"asakaa").split(`
415
415
  `).slice(1,-1).join(`
416
416
  `)}
417
417
  }
418
- `}var qh=({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 zm({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,p])=>{let m=n,i=m===r;return jsxs("button",{onClick:()=>o(m),className:`theme-switcher__button ${i?"theme-switcher__button--active":""}`,"aria-label":`Switch to ${p.displayName} theme`,"aria-pressed":i,title:p.displayName,children:[jsx("span",{className:"theme-switcher__icon","aria-hidden":"true",children:jsx(qh,{theme:m})}),e&&!t&&jsx("span",{className:"theme-switcher__label",children:p.displayName})]},m)})})}
419
- export{dm as AIUsageDashboard,Sh as AI_FEATURES,Vi as AI_MODELS,Ns as AddCardButton,Ts as AddColumnButton,dr as AttachmentUploader,Dm as BoardProvider,fn as BulkOperationsToolbar,$s as BurnDownChart,Kc as CalendarBoard,pr as Card,As as CardDetailModal,Is as CardDetailModalV2,em as CardHistoryReplay,Qc as CardHistoryTimeline,rm as CardRelationshipsGraph,yh as CardStack,_s as CardTemplateSelector,ns as CircuitBreaker,io as Column,wn as ColumnManager,Es as CommandPalette,Ys as ConfigMenu,yo as ContextMenu,Lo as DEFAULT_SHORTCUTS,Gs as DEFAULT_TEMPLATES,To as DateRangePicker,Do as DependenciesSelector,Pn as DependencyLine,Os as DistributionCharts,us as EditableColumnTitle,co as ErrorBoundary,js as ExportImportModal,Ks as FilterBar,Nc as GANTT_AI_SYSTEM_PROMPT,In as GanttAIAssistant,kc as GanttBoard,ho as GanttI18nContext,An as GanttMilestone,kn as GanttToolbar,pm as GenerateGanttTasksDialog,sm as GeneratePlanModal,Hs as GroupBySelector,Sr as KanbanBoard,ws as KanbanToolbar,Mo as KanbanViewAdapter,Ws as KeyboardShortcutsHelp,$c as ListView,Ut as MenuIcons,qn as PluginManager,Or as PrioritySelector,Dh as RATE_LIMITS,zs as SwimlaneBoardView,fs as TagBadge,td as TagList,nr as TagPicker,Dn as TaskBar,Gr as TaskDetailModal,Tc as TaskFormModal,Nn as TaskGrid,Qs as ThemeModal,zd as ThemeProvider,zm as ThemeSwitcher,Ln as Timeline,Ur as UserAssignmentSelector,Rs as VelocityChart,Im as VirtualGrid,Am as VirtualList,Qr as aiUsageTracker,Zi as borderRadius,en as calculatePosition,Ui as calendarDarkTheme,Fi as calendarEnTranslations,Li as calendarEsTranslations,Hi as calendarLightTheme,Wi as calendarNeutralTheme,_n as calendarThemes,Hn as calendarTranslations,Rn as cardToGanttTask,Fc as cardsToGanttTasks,f as cn,yd as createKanbanView,ip as createRetryWrapper,qs as darkTheme,Jn as darkTokenTheme,bn as defaultTheme,Xn as designTokens,ol as duration,nl as easing,Om as exportTokensToCSS,br as findTaskByName,el as fontSize,tl as fontWeight,jo as formatCost,vn as ganttEnTranslations,Hd as ganttEsTranslations,Ac as ganttTaskToCardUpdate,Xe as ganttThemes,dl as ganttTokens,Zs as ganttTranslations,ge as ganttUtils,ml as generateCSSVariables,gl as generateCompleteCSS,rp as generateInitialPositions,Dc as generateTasksContext,Xo as generateThemeVariables,Yc as getCalendarTheme,Ho as getCalendarTranslations,Oc as getListViewTheme,Ei as getListViewTranslations,zc as getMonthNames,$m as getToken,Wd as getTranslations,Uc as getWeekdayNames,ll as kanbanTokens,Xs as lightTheme,pl as lightTokenTheme,al as lineHeight,Pi as listViewDarkTheme,Di as listViewEnTranslations,Si as listViewEsTranslations,Mi as listViewLightTheme,Ai as listViewNeutralTheme,Un as listViewThemes,$n as listViewTranslations,Wn as mergeCalendarTranslations,On as mergeListViewTranslations,ei as mergeTranslations,Js as neutralTheme,ul as neutralTokenTheme,il as opacity,Pc as parseLocalCommand,Ci as parseNaturalDate,Ti as parseNaturalDuration,Ni as parseProgress,Ec as parseStatus,Vh as pluginManager,sp as retrySyncOperation,tn as retryWithBackoff,sl as shadows,Rm as shouldVirtualizeGrid,Qi as spacing,jr as themes,km as useAI,gm as useBoard,qo as useBoardCore,Yn as useBoardStore,Tm as useCardStacking,xs as useDragState,Em as useFilteredCards,bm as useFilters,bo as useGanttI18n,Kn as useKanbanState,Rd as useKeyboardShortcuts,wm as useMultiSelect,Yi as useSelectionState,Pm as useSortedCards,go as useTheme,Bm as useVirtualGrid,Fm as useVirtualList,Mc as validateAIResponse,Ds as withErrorBoundary,rn as wouldCreateCircularDependency,rl as zIndex};//# sourceMappingURL=index.js.map
418
+ `}var qh=({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 zp({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,m])=>{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 ${m.displayName} theme`,"aria-pressed":i,title:m.displayName,children:[jsx("span",{className:"theme-switcher__icon","aria-hidden":"true",children:jsx(qh,{theme:p})}),e&&!t&&jsx("span",{className:"theme-switcher__label",children:m.displayName})]},p)})})}
419
+ export{dp as AIUsageDashboard,Sh as AI_FEATURES,Vi as AI_MODELS,Ns as AddCardButton,Ts as AddColumnButton,dr as AttachmentUploader,Dp as BoardProvider,fn as BulkOperationsToolbar,$s as BurnDownChart,Kc as CalendarBoard,mr as Card,As as CardDetailModal,Is as CardDetailModalV2,ep as CardHistoryReplay,Qc as CardHistoryTimeline,rp as CardRelationshipsGraph,yh as CardStack,_s as CardTemplateSelector,ns as CircuitBreaker,io as Column,wn as ColumnManager,Es as CommandPalette,Ys as ConfigMenu,yo as ContextMenu,Lo as DEFAULT_SHORTCUTS,Gs as DEFAULT_TEMPLATES,To as DateRangePicker,Do as DependenciesSelector,Pn as DependencyLine,Os as DistributionCharts,us as EditableColumnTitle,co as ErrorBoundary,js as ExportImportModal,Ks as FilterBar,Nc as GANTT_AI_SYSTEM_PROMPT,In as GanttAIAssistant,kc as GanttBoard,ho as GanttI18nContext,An as GanttMilestone,kn as GanttToolbar,mp as GenerateGanttTasksDialog,sp as GeneratePlanModal,Hs as GroupBySelector,Sr as KanbanBoard,ws as KanbanToolbar,Mo as KanbanViewAdapter,Ws as KeyboardShortcutsHelp,$c as ListView,Ut as MenuIcons,qn as PluginManager,Or as PrioritySelector,Dh as RATE_LIMITS,zs as SwimlaneBoardView,fs as TagBadge,td as TagList,nr as TagPicker,Dn as TaskBar,Gr as TaskDetailModal,Tc as TaskFormModal,Nn as TaskGrid,Qs as ThemeModal,zd as ThemeProvider,zp as ThemeSwitcher,Ln as Timeline,Ur as UserAssignmentSelector,Rs as VelocityChart,Ip as VirtualGrid,Ap as VirtualList,Qr as aiUsageTracker,Zi as borderRadius,en as calculatePosition,Ui as calendarDarkTheme,Fi as calendarEnTranslations,Li as calendarEsTranslations,Hi as calendarLightTheme,Wi as calendarNeutralTheme,_n as calendarThemes,Hn as calendarTranslations,Rn as cardToGanttTask,Fc as cardsToGanttTasks,f as cn,yd as createKanbanView,im as createRetryWrapper,qs as darkTheme,Jn as darkTokenTheme,bn as defaultTheme,Xn as designTokens,ol as duration,nl as easing,Op as exportTokensToCSS,br as findTaskByName,el as fontSize,tl as fontWeight,jo as formatCost,vn as ganttEnTranslations,Hd as ganttEsTranslations,Ac as ganttTaskToCardUpdate,et as ganttThemes,dl as ganttTokens,Zs as ganttTranslations,he as ganttUtils,pl as generateCSSVariables,gl as generateCompleteCSS,rm as generateInitialPositions,Dc as generateTasksContext,Xo as generateThemeVariables,Yc as getCalendarTheme,Ho as getCalendarTranslations,Oc as getListViewTheme,Ei as getListViewTranslations,zc as getMonthNames,$p as getToken,Wd as getTranslations,Uc as getWeekdayNames,ll as kanbanTokens,Xs as lightTheme,ml as lightTokenTheme,al as lineHeight,Pi as listViewDarkTheme,Di as listViewEnTranslations,Si as listViewEsTranslations,Mi as listViewLightTheme,Ai as listViewNeutralTheme,Un as listViewThemes,$n as listViewTranslations,Wn as mergeCalendarTranslations,On as mergeListViewTranslations,ei as mergeTranslations,Js as neutralTheme,ul as neutralTokenTheme,il as opacity,Pc as parseLocalCommand,Ci as parseNaturalDate,Ti as parseNaturalDuration,Ni as parseProgress,Ec as parseStatus,Vh as pluginManager,sm as retrySyncOperation,tn as retryWithBackoff,sl as shadows,Rp as shouldVirtualizeGrid,Qi as spacing,jr as themes,kp as useAI,gp as useBoard,qo as useBoardCore,Yn as useBoardStore,Tp as useCardStacking,xs as useDragState,Ep as useFilteredCards,bp as useFilters,bo as useGanttI18n,Kn as useKanbanState,Rd as useKeyboardShortcuts,wp as useMultiSelect,Yi as useSelectionState,Pp as useSortedCards,go as useTheme,Bp as useVirtualGrid,Fp as useVirtualList,Mc as validateAIResponse,Ds as withErrorBoundary,rn as wouldCreateCircularDependency,rl as zIndex};//# sourceMappingURL=index.js.map
420
420
  //# sourceMappingURL=index.js.map