@libxai/board 0.17.203 → 0.17.204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +21 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
2
|
-
`)}async function
|
|
3
|
-
`)?`"${e.replace(/"/g,'""')}"`:e}async function
|
|
4
|
-
`);if(t.length<1||!t[0])return {success:!1,errors:["CSV file is empty or invalid"]};let a=Ki(t[0]),r=[],o=new Map,s=[];for(let l=1;l<t.length;l++)try{let c=Ki(t[l]||"");if(c.length>a.length){s.push(`Line ${l+1}: Too many columns`);continue}if(a.length-c.length>3){s.push(`Line ${l+1}: Column count mismatch (expected ${a.length}, got ${c.length})`);continue}for(;c.length<a.length;)c.push("");let n={};a.forEach((u,x)=>{n[u]=c[x]||"";});let m=n.Column||"Unnamed";o.has(m)||o.set(m,{id:`col-${o.size+1}`,title:m,position:o.size+1,cardIds:[]});let d=o.get(m),i={id:n["Card ID"]||`card-${l}`,title:n.Title||"Untitled",description:n.Description?n.Description:void 0,columnId:d.id,position:d.cardIds.length+1,priority:n.Priority||void 0,labels:n.Labels?n.Labels.split(";").filter(Boolean):void 0,assignedUserIds:n["Assigned Users"]?n["Assigned Users"].split(";").filter(Boolean):void 0,startDate:n["Start Date"]?n["Start Date"]:void 0,endDate:n["End Date"]?n["End Date"]:void 0,createdAt:n["Created At"]?n["Created At"]:void 0,updatedAt:n["Updated At"]?n["Updated At"]:void 0};r.push(i),d.cardIds.push(i.id);}catch(c){s.push(`Line ${l+1}: ${c instanceof Error?c.message:"Unknown error"}`);}return r.length===0?{success:!1,errors:["No valid cards found in CSV",...s]}:{success:!0,cardsImported:r.length,columnsImported:o.size,errors:s.length>0?s:void 0}}catch(t){return {success:false,errors:[`Failed to parse CSV: ${t instanceof Error?t.message:"Unknown error"}`]}}}function Ki(e){let t=[],a="",r=false;for(let o=0;o<e.length;o++){let s=e[o],l=e[o+1];s==='"'&&r&&l==='"'?(a+='"',o++):s==='"'?r=!r:s===","&&!r?(t.push(a),a=""):a+=s;}return t.push(a),t}function Yi(e,t){switch(t){case "json":return vp(e);case "csv":return xp(e);default:return {success:false,errors:[`Unsupported import format: ${t}`]}}}function qi(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 Rn=createContext(null);function Xi(){return useContext(Rn)}var Ji=createContext(null);function Zi({children:e,themeName:t}){return jsx(Ji.Provider,{value:{themeName:t},children:e})}function Br(){return useContext(Ji)}function rt({children:e,container:t}){let[a,r]=useState(false),o=Xi(),s=Br();if(useEffect(()=>(r(true),()=>r(false)),[]),!a)return null;let l=t||(typeof document<"u"?document.body:null);if(!l)return null;if(o){let{theme:c,themeName:p}=o,n={"--asakaa-color-background-primary":c.bgPrimary,"--asakaa-color-background-secondary":c.bgSecondary,"--asakaa-color-background-card":c.bgGrid,"--asakaa-color-background-hover":c.hoverBg,"--asakaa-color-text-primary":c.textPrimary,"--asakaa-color-text-secondary":c.textSecondary,"--asakaa-color-text-tertiary":c.textTertiary,"--asakaa-color-text-inverse":c.taskBarHandle||"#FFFFFF","--asakaa-color-border-default":c.border,"--asakaa-color-border-hover":c.borderLight,"--asakaa-color-border-subtle":c.borderLight,"--asakaa-color-interactive-primary":c.accent,"--asakaa-color-interactive-primaryHover":c.accentHover,"--asakaa-color-interactive-primaryBorder":`${c.accent}4D`,"--asakaa-color-interactive-primaryBackground":`${c.accent}1A`,"--asakaa-color-interactive-primaryBackgroundHover":`${c.accent}33`,"--asakaa-color-status-success":c.statusCompleted,"--asakaa-color-status-warning":c.milestone,"--asakaa-color-status-error":c.criticalPath,"--asakaa-color-danger":c.criticalPath,"--asakaa-color-danger-border":`${c.criticalPath}4D`,"--asakaa-color-danger-background":`${c.criticalPath}14`,"--asakaa-color-danger-backgroundHover":`${c.criticalPath}26`};return createPortal(jsx("div",{"data-theme":p,"data-gantt-portal":"true",style:n,children:e}),l)}return s?createPortal(jsx("div",{"data-theme":s.themeName,"data-kanban-portal":"true",children:e}),l):createPortal(e,l)}var rl={URGENT:{label:"Urgent",color:"#E74C3C"},HIGH:{label:"High",color:"#E67E22"},MEDIUM:{label:"Normal",color:"#F1C40F"},LOW:{label:"Low",color:"#2ECC71"}},Ep="#BDC3C7",Pp=({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 ur({priority:e,onChange:t,className:a}){let[r,o]=useState(false),[s,l]=useState({top:0,left:0}),c=useRef(null),p=useRef(null),n=()=>{if(!p.current)return;let u=p.current.getBoundingClientRect(),x=window.innerHeight,f=window.innerWidth,g=160,k=220,h=4,b=u.right-g;b<10&&(b=u.left),b+g>f-10&&(b=f-g-10);let y=x-u.bottom,D=u.top,N;y>=k+h?N=u.bottom+h:D>=k+h?N=u.top-k-h:N=y>=D?u.bottom+h:Math.max(10,u.top-k-h),l({top:N,left:b}),o(true);};useEffect(()=>{let u=x=>{c.current&&!c.current.contains(x.target)&&!p.current?.contains(x.target)&&o(false);};if(r)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]),useEffect(()=>{let u=x=>{x.key==="Escape"&&o(false);};if(r)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[r]);let m=u=>{t(u),o(false);},d=e?rl[e]:null,i=d?.color||Ep;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:p,onClick:()=>r?o(false):n(),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?`${i}10`:"transparent",boxShadow:e?`0 0 0 2px ${i}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:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:i,fillOpacity:e?"0.6":"0.4"})})}),r&&jsx(rt,{children:jsxs("div",{ref:c,className:"priority-selector-menu",style:{position:"fixed",top:`${s.top}px`,left:`${s.left}px`,zIndex:99999,minWidth:"160px",maxHeight:"calc(100vh - 40px)",borderRadius:"8px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},children:[jsx("div",{className:"px-3 py-1.5 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.7))"},children:"Priority"})}),jsxs("div",{className:"py-1",children:[Object.entries(rl).map(([u,x])=>jsxs("button",{onClick:()=>m(u),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:x.color,background:"transparent"},onMouseEnter:f=>{f.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:f=>{f.currentTarget.style.background="transparent";},children:[jsx(Pp,{color:x.color}),jsx("span",{className:"font-semibold text-sm",children:x.label}),e===u&&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"})})]},u)),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:()=>m(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:u=>{u.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:u=>{u.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 Mp=[{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 eo({startDate:e,endDate:t,onChange:a,className:r}){let[o,s]=useState(false),[l,c]=useState({top:0,left:0}),p=useRef(null),n=useRef(null),i=(Br()?.themeName||"dark")==="dark",u=()=>{if(!n.current)return;let b=n.current.getBoundingClientRect(),y=window.innerHeight,D=window.innerWidth,N=320,A=380,v=4,B=b.left;B+N>D-10&&(B=D-N-10),B<10&&(B=10);let T=y-b.bottom,w=b.top,R;T>=A+v?R=b.bottom+v:w>=A+v?R=b.top-A-v:R=T>=w?b.bottom+v:Math.max(10,b.top-A-v),c({top:R,left:B}),s(true);};useEffect(()=>{let b=y=>{p.current&&!p.current.contains(y.target)&&!n.current?.contains(y.target)&&s(false);};if(o)return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[o]),useEffect(()=>{let b=y=>{y.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[o]);let x=b=>{let y=new Date,D=B=>{let T=B.getFullYear(),w=String(B.getMonth()+1).padStart(2,"0"),R=String(B.getDate()).padStart(2,"0");return `${T}-${w}-${R}`},N=D(y),A=new Date(y);A.setDate(A.getDate()+b);let v=D(A);a(N,v),s(false);},f=()=>{if(!e||!t)return "Set date";let b=A=>{if(A instanceof Date)return A;if(typeof A!="string"||!A.match(/^\d{4}-\d{2}-\d{2}$/))return null;let v=A.split("-").map(Number);if(v.length!==3||v.some(R=>isNaN(R)))return null;let B=v[0],T=v[1],w=v[2];return B===void 0||T===void 0||w===void 0?null:new Date(B,T-1,w)},y=b(e),D=b(t);if(!y||!D||isNaN(y.getTime())||isNaN(D.getTime()))return "Set date";let N=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return `${N[y.getMonth()]} ${y.getDate()} \u2013 ${N[D.getMonth()]} ${D.getDate()}`},g=e&&t,h=(()=>{if(!t)return false;let b=typeof t=="string"?new Date(t):t,y=new Date;return y.setHours(0,0,0,0),b<y})();return jsxs("div",{className:`relative ${r||""}`,children:[jsxs("button",{ref:n,onClick:()=>o?s(false):u(),className:`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-all hover:bg-white/5 ${h?"asakaa-date-overdue":"asakaa-date"}`,title:g?`${f()}`:"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:f()})]}),o&&jsx(rt,{children:jsxs("div",{ref:p,className:"date-picker-menu rounded-xl shadow-2xl border min-w-[320px]",style:{position:"fixed",top:`${l.top}px`,left:`${l.left}px`,background:i?"#1A1D25":"#FFFFFF",border:`1px solid ${i?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.12)"}`,boxShadow:i?"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:i?"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:i?"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:Mp.map(b=>jsx("button",{onClick:()=>x(b.days),className:"px-3 py-2.5 rounded-lg text-xs font-semibold transition-all active:scale-95",style:{color:i?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",border:`1px solid ${i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`,backgroundColor:i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)"},onMouseEnter:y=>{y.currentTarget.style.backgroundColor=i?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.1)",y.currentTarget.style.border=`1px solid ${i?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.25)"}`;},onMouseLeave:y=>{y.currentTarget.style.backgroundColor=i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",y.currentTarget.style.border=`1px solid ${i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`;},children:b.label},b.label))})]}),jsxs("div",{className:"p-4",children:[jsx("span",{className:"text-xs font-bold uppercase tracking-wider block mb-3",style:{color:i?"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:b=>a(b.target.value,t),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:i?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:i?"dark":"light"}}),jsx("input",{type:"date",value:t||"",onChange:b=>a(e,b.target.value),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:i?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:i?"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:b=>{b.currentTarget.style.background="rgba(239, 68, 68, 0.2)";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(239, 68, 68, 0.1)";},children:"Clear Dates"})]})]})})]})}function fr({assignedUsers:e=[],availableUsers:t,onChange:a,className:r,maxVisibleAvatars:o=3}){let[s,l]=useState(false),[c,p]=useState(""),[n,m]=useState({top:0,left:0}),d=useRef(null),i=useRef(null),u=()=>{if(!i.current)return;let h=i.current.getBoundingClientRect(),b=window.innerHeight,y=window.innerWidth,D=300,N=380,A=4,v=h.right-D;v<10&&(v=h.left),v+D>y-10&&(v=y-D-10);let B=b-h.bottom,T=h.top,w;B>=N+A?w=h.bottom+A:T>=N+A?w=h.top-N-A:w=B>=T?h.bottom+A:Math.max(10,h.top-N-A),m({top:w,left:v}),l(true);};useEffect(()=>{let h=b=>{d.current&&!d.current.contains(b.target)&&!i.current?.contains(b.target)&&(l(false),p(""));};if(s)return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s]),useEffect(()=>{let h=b=>{b.key==="Escape"&&(l(false),p(""));};if(s)return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[s]);let x=h=>{let b=e.some(y=>y.id===h.id);a(b?e.filter(y=>y.id!==h.id):[...e,h]);},f=t.filter(h=>h.name.toLowerCase().includes(c.toLowerCase())),g=e.slice(0,o),k=e.length-o;return jsxs("div",{className:`relative ${r||""}`,children:[jsx("button",{ref:i,onClick:()=>s?l(false):u(),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:[g.map(h=>jsx("div",{className:"asakaa-avatar",title:h.name,children:h.avatar?jsx("img",{src:h.avatar,alt:h.name,className:"asakaa-avatar-img"}):h.initials},h.id)),k>0&&jsxs("div",{className:"asakaa-avatar",children:["+",k]})]}):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(rt,{children:jsxs("div",{ref:d,className:"user-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${n.top}px`,left:`${n.left}px`,maxHeight:"calc(100vh - 40px)",overflow:"hidden",display:"flex",flexDirection:"column",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:[jsx("div",{className:"px-4 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-xs font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.8))"},children:"Assign Users"})}),jsx("div",{className:"px-3 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("input",{type:"text",value:c,onChange:h=>p(h.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:f.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"}):f.map(h=>{let b=e.some(y=>y.id===h.id);return jsxs("button",{onClick:()=>x(h),className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm transition-all active:scale-98",style:{background:"transparent"},onMouseEnter:y=>{y.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.1))";},onMouseLeave:y=>{y.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:h.color,color:"#fff"},children:h.avatar?jsx("img",{src:h.avatar,alt:h.name,className:"w-full h-full rounded-full object-cover"}):h.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:h.name}),jsx("span",{className:"w-5 text-lg flex-shrink-0 text-right",style:{color:b?"#3b82f6":"transparent"},children:b?"\u2713":""})]},h.id)})}),e.length>0&&jsx("div",{className:"px-3 py-3 border-t border-white/10",children:jsx("button",{onClick:()=>{a([]),l(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 Lo(e,t,a){let r=new Map;e.forEach(p=>{if(p.dependencies&&Array.isArray(p.dependencies)){let n=p.dependencies.map(m=>{if(typeof m=="string")return m;let d=m;return d.taskId||d.targetId||""}).filter(Boolean);r.set(p.id,n);}});let o=r.get(a)||[];r.set(a,[...o,t]);let s=new Set,l=new Set,c=p=>{if(!s.has(p)){s.add(p),l.add(p);let n=r.get(p)||[];for(let m of n){if(!s.has(m)&&c(m))return true;if(l.has(m))return true}}return l.delete(p),false};return c(a)}function ao({currentCardId:e,dependencies:t=[],availableTasks:a,onChange:r,className:o,validateCircular:s=true,onCircularDependencyError:l}){let[c,p]=useState(false),[n,m]=useState(""),[d,i]=useState(t.length>0),[u,x]=useState({top:0,left:0}),[f,g]=useState(null),k=useRef(null),h=useRef(null),b=()=>{if(!h.current)return;let v=h.current.getBoundingClientRect(),B=window.innerHeight,T=window.innerWidth,w=300,R=d?380:120,P=4,H=v.right-w;H<10&&(H=v.left),H+w>T-10&&(H=T-w-10);let q=B-v.bottom,he=v.top,xe;q>=R+P?xe=v.bottom+P:he>=R+P?xe=v.top-R-P:xe=q>=he?v.bottom+P:Math.max(10,v.top-R-P),x({top:xe,left:H}),p(true);};useEffect(()=>{if(!c||!h.current)return;let v=h.current.getBoundingClientRect(),B=window.innerHeight,T=window.innerWidth,w=300,R=d?380:120,P=4,H=v.right-w;H<10&&(H=v.left),H+w>T-10&&(H=T-w-10);let q=B-v.bottom,he=v.top,xe;q>=R+P?xe=v.bottom+P:he>=R+P?xe=v.top-R-P:xe=q>=he?v.bottom+P:Math.max(10,v.top-R-P),x({top:xe,left:H});},[d,c]),useEffect(()=>{let v=B=>{k.current&&!k.current.contains(B.target)&&!h.current?.contains(B.target)&&(p(false),m(""));};if(c)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[c]),useEffect(()=>{let v=B=>{B.key==="Escape"&&(p(false),m(""));};if(c)return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[c]);let y=v=>{let B=t.includes(v),T=a.find(w=>w.id===v);if(g(null),B){let w=t.filter(R=>R!==v);r(w),w.length===0&&i(false);}else {if(s&&Lo(a,v,e)){let R=`Cannot add "${T?.title||v}" as dependency - would create circular reference`;g(R),l?.(v,T?.title||v),setTimeout(()=>g(null),3e3);return}r([...t,v]),i(true);}},D=()=>{let v=!d;i(v),v||r([]);},N=a.filter(v=>v.id!==e).filter(v=>v.title.toLowerCase().includes(n.toLowerCase())||v.id.toLowerCase().includes(n.toLowerCase())),A=t.length>0?"#3B82F6":"#BDC3C7";return jsxs("div",{className:`relative ${o||""}`,children:[jsxs("button",{ref:h,onClick:()=>c?p(false):b(),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:A,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),t.length>0&&jsx("span",{className:"text-xs font-medium",style:{color:A},children:t.length})]}),c&&jsx(rt,{children:jsxs("div",{ref:k,className:"dependencies-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${u.top}px`,left:`${u.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:[f&&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:f})]}),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:D,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:n,onChange:v=>m(v.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:N.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"}):N.map(v=>{let B=t.includes(v.id);return jsxs("button",{onClick:()=>y(v.id),className:"w-full px-4 py-2 flex items-start gap-3 text-sm transition-colors",style:{background:"transparent"},onMouseEnter:T=>{T.currentTarget.style.background="var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))";},onMouseLeave:T=>{T.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:B?"#3b82f6":"transparent",borderColor:B?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:B&&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:v.title}),jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:v.id})]})]},v.id)})})]}),t.length>0&&jsx("div",{className:"px-3 py-2 border-t border-white/5",children:jsx("button",{onClick:()=>{r([]),i(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 _a=memo(({card:e,render:t,onClick:a,isSelected:r,disableDrag:o,className:s,onUpdate:l,availableUsers:c=[],allCards:p=[]})=>{let{attributes:n,listeners:m,setNodeRef:d,transform:i,transition:u,isDragging:x}=useSortable({id:e.id,disabled:o,data:{type:"card",card:e}}),f={transform:Po.Transform.toString(i),transition:u};if(t)return jsx("div",{ref:d,style:f,...n,...m,onClick:()=>a?.(e),children:t(e)});let g=c.filter(y=>e.assignedUserIds?.includes(y.id)),k=e.progress===100,h=(e.attachments||[]).filter(y=>y.type.startsWith("image/")),b={...f,...e.color&&{borderTopWidth:"3px",borderTopStyle:"solid",borderTopColor:e.color}};return jsxs("div",{ref:d,style:b,className:C("asakaa-card",x&&"asakaa-card-dragging",r&&"ring-2 ring-asakaa-accent-blue",s),...n,...m,onClick:y=>{y.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:y=>{y.currentTarget.style.display="none";}})}),h.length>0&&!e.coverImage&&jsx("div",{className:"asakaa-card-attachments mb-3",children:h.length===1&&h[0]?jsx("img",{src:h[0].thumbnailUrl||h[0].url,alt:h[0].name,className:"w-full h-28 object-cover rounded-md",loading:"lazy",onError:y=>{y.currentTarget.style.display="none";}}):jsx("div",{className:"grid grid-cols-2 gap-1",children:h.slice(0,4).map((y,D)=>jsxs("div",{className:"relative",children:[jsx("img",{src:y.thumbnailUrl||y.url,alt:y.name,className:"w-full h-14 object-cover rounded",loading:"lazy",onError:N=>{N.currentTarget.style.display="none";}}),D===3&&h.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:["+",h.length-4]})})]},y.id))})}),jsx("h3",{className:"asakaa-card-title mb-2",style:{textDecoration:k?"line-through":"none",opacity:k?.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:y=>y.stopPropagation(),className:"priority-selector",children:jsx(ur,{priority:e.priority,onChange:y=>l?.(e.id,{priority:y})})}),jsx("div",{onClick:y=>y.stopPropagation(),className:"date-picker",children:jsx(eo,{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:(y,D)=>l?.(e.id,{startDate:y,endDate:D})})}),c.length>0&&jsx("div",{onClick:y=>y.stopPropagation(),className:"user-selector",children:jsx(fr,{assignedUsers:g,availableUsers:c,onChange:y=>l?.(e.id,{assignedUserIds:y.map(D=>D.id)})})}),jsx("div",{onClick:y=>y.stopPropagation(),className:"dependencies-selector",children:jsx(ao,{currentCardId:e.id,dependencies:Array.isArray(e.dependencies)?e.dependencies.map(y=>typeof y=="string"?y:y.taskId):[],availableTasks:p,onChange:y=>l?.(e.id,{dependencies:y})})})]}),e.labels&&e.labels.length>0&&jsx("div",{className:"flex flex-wrap gap-1",children:e.labels.slice(0,3).map(y=>jsx("span",{className:"asakaa-label",children:y},y))}),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)));_a.displayName="Card";var Fo={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"}},ul=({icon:e,color:t})=>e==="circle"?jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("circle",{cx:"8",cy:"8",r:"6",stroke:t,strokeWidth:"1.5",fill:"none"})}):e==="circle-dot"?jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:t,strokeWidth:"1.5",fill:"none"}),jsx("circle",{cx:"8",cy:"8",r:"3",fill:t})]}):jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:t,strokeWidth:"1.5",fill:t,fillOpacity:"0.2"}),jsx("path",{d:"M5 8L7 10L11 6",stroke:t,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});function gl({status:e="todo",onChange:t,className:a,customStatuses:r=[]}){let[o,s]=useState(false),[l,c]=useState({top:0,left:0}),p=useRef(null),n=useRef(null),m=[...Object.entries(Fo).map(([g,k])=>({id:g,label:k.label,color:k.color,icon:k.icon})),...r.filter(g=>!Object.keys(Fo).includes(g.id)).map(g=>({id:g.id,label:g.title,color:g.color||"#8B5CF6",icon:"circle-dot"}))],d=()=>{let g=Fo[e];if(g)return {...g,id:e};let k=r.find(h=>h.id===e);return k?{id:k.id,label:k.title,color:k.color||"#8B5CF6",icon:"circle-dot"}:{...Fo.todo,id:"todo"}},i=()=>{if(!n.current)return;let g=n.current.getBoundingClientRect(),k=window.innerHeight,h=window.innerWidth,b=180,y=280,D=4,N=g.right-b;N<10&&(N=g.left),N+b>h-10&&(N=h-b-10);let A=k-g.bottom,v=g.top,B;A>=y+D?B=g.bottom+D:v>=y+D?B=g.top-y-D:B=A>=v?g.bottom+D:Math.max(10,g.top-y-D),c({top:B,left:N}),s(true);};useEffect(()=>{let g=k=>{p.current&&!p.current.contains(k.target)&&!n.current?.contains(k.target)&&s(false);};if(o)return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[o]),useEffect(()=>{let g=k=>{k.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[o]);let u=g=>{t(g),s(false);},x=d(),f=x.color;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:n,onClick:()=>o?s(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:`${f}10`,boxShadow:`0 0 0 2px ${f}30 inset`},title:x.label,children:jsx(ul,{icon:x.icon,color:f})}),o&&jsx(rt,{children:jsxs("div",{ref:p,className:"status-selector-menu",style:{position:"fixed",top:`${l.top}px`,left:`${l.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:m.map(g=>jsxs("button",{onClick:()=>u(g.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:g.color,background:"transparent"},onMouseEnter:k=>{k.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:k=>{k.currentTarget.style.background="transparent";},children:[jsx(ul,{icon:g.icon,color:g.color}),jsx("span",{className:"font-semibold",children:g.label}),e===g.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"})})]},g.id))})]})})]})}function fl({columnTitle:e,onRename:t,onDelete:a,isDeletable:r=false,className:o}){let[s,l]=useState(false),[c,p]=useState(false),[n,m]=useState(e),[d,i]=useState({top:0,left:0}),u=useRef(null),x=useRef(null),f=useRef(null);useEffect(()=>{if(s&&x.current){let b=x.current.getBoundingClientRect();i({top:b.bottom+window.scrollY+8,left:b.left+window.scrollX});}},[s]),useEffect(()=>{let b=y=>{u.current&&!u.current.contains(y.target)&&!x.current?.contains(y.target)&&(l(false),p(false));};if(s)return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s]),useEffect(()=>{let b=y=>{y.key==="Escape"&&(l(false),p(false),m(e));};if(s)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[s,e]),useEffect(()=>{c&&f.current&&(f.current.focus(),f.current.select());},[c]);let g=()=>{p(true),m(e);},k=()=>{let b=n.trim();b&&b!==e&&t(b),p(false),l(false),m(e);},h=b=>{b.key==="Enter"?k():b.key==="Escape"&&(p(false),m(e));};return jsxs("div",{className:`relative ${o||""}`,children:[jsx("button",{ref:x,onClick:()=>l(!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(rt,{children:jsx("div",{ref:u,className:"fixed rounded-xl shadow-2xl border min-w-[200px]",style:{top:`${d.top}px`,left:`${d.left}px`,background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:c?jsxs("div",{className:"p-3",children:[jsx("label",{className:"text-xs font-bold text-white/80 uppercase tracking-wider block mb-2",children:"Rename Column"}),jsx("input",{ref:f,type:"text",value:n,onChange:b=>m(b.target.value),onKeyDown:h,onBlur:k,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:g,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(),l(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 zr=memo(({column:e,cards:t,renderColumn:a,renderCard:r,renderHeader:o,renderEmptyState:s,onCardClick:l,onCardUpdate:c,availableUsers:p,allCards:n,enableVirtualization:m,cardHeight:d=120,isCollapsed:i,onToggleCollapse:u,onColumnRename:x,onColumnDelete:f,isDeletable:g=false,className:k})=>{let{setNodeRef:h,isOver:b}=useDroppable({id:e.id,data:{type:"column",column:e}}),y=useRef(null),D=m??Wi(t.length),N=useVirtualizer({count:t.length,getScrollElement:()=>y.current,estimateSize:()=>d,enabled:D});if(a)return jsx("div",{ref:h,className:k,children:a(e,t)});let v=(()=>{if(!e.wipLimit)return {state:"none",percentage:0};let w=t.length/e.wipLimit*100;return t.length>e.wipLimit?{state:"exceeded",percentage:w}:w>=80?{state:"warning",percentage:w}:w>=60?{state:"approaching",percentage:w}:{state:"ok",percentage:w}})(),B=v.state==="exceeded",T=()=>"asakaa-column-count";return jsxs("div",{ref:h,className:C("asakaa-column",b&&"ring-2 ring-asakaa-accent-blue",B&&"ring-2 ring-asakaa-accent-red",k),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:C(T()),children:[t.length,e.wipLimit&&` / ${e.wipLimit}`]}),e.wipLimit&&v.state!=="none"&&jsxs("span",{className:"text-xs font-medium flex items-center",title:`${v.percentage.toFixed(0)}% capacity${e.wipLimitType==="hard"?" (Hard limit - blocks new cards)":" (Soft limit - shows warning)"}`,children:[v.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"})]}),v.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"})]}),v.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"})}),v.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"})]})]}),(x||f)&&jsx(fl,{columnTitle:e.title,onRename:w=>x?.(e.id,w),onDelete:f?()=>f(e.id):void 0,isDeletable:g}),u&&jsx("button",{onClick:u,className:"text-asakaa-text-tertiary hover:text-asakaa-text-primary","aria-label":i?"Expand column":"Collapse column",children:i?"\u25B6":"\u25BC"})]})]}),!i&&jsx("div",{ref:y,className:"asakaa-column-cards",style:{maxHeight:D?"600px":void 0},children:jsx(SortableContext,{items:t.map(w=>w.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"})}):D?jsx("div",{style:{height:`${N.getTotalSize()}px`,position:"relative"},children:N.getVirtualItems().map(w=>{let R=t[w.index];return R?jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${w.start}px)`},children:jsx(_a,{card:R,render:r,onClick:l,onUpdate:c,availableUsers:p,allCards:n})},R.id):null})}):t.map(w=>jsx(_a,{card:w,render:r,onClick:l,onUpdate:c,availableUsers:p,allCards:n},w.id))})})]})});zr.displayName="Column";function Wn({title:e,onSave:t,className:a}){let[r,o]=useState(false),[s,l]=useState(e),c=useRef(null);useEffect(()=>{r&&c.current&&(c.current.focus(),c.current.select());},[r]);let p=()=>{let m=s.trim();m&&m!==e?t(m):l(e),o(false);},n=m=>{m.key==="Enter"?p():m.key==="Escape"&&(l(e),o(false));};return r?jsx("input",{ref:c,type:"text",value:s,onChange:m=>l(m.target.value),onBlur:p,onKeyDown:n,className:C("asakaa-column-title bg-transparent border-b-2 border-blue-500","outline-none px-1 -ml-1",a),maxLength:50}):jsx("h2",{className:C("asakaa-column-title cursor-pointer",a),onClick:()=>o(true),title:"Click to edit",children:e})}function Gn(){let[e,t]=useState(()=>dragStore.getState());useEffect(()=>dragStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{dragStore.setState(r);},[]);return [e,a]}function Qa({board:e,callbacks:t,onCardClick:a,renderProps:r,config:o,availableUsers:s=[],className:l,style:c,isLoading:p,error:n,children:m}){let[d,i]=Gn(),u=o?.theme||"dark",f=u==="dark"||u==="neutral"?"dark":"",g=useCallback((T,w)=>{t.onCardUpdate?.(T,w);},[t]),k=useCallback((T,w)=>{t.onColumnUpdate?.(T,{title:w});},[t]),h=useCallback(T=>{t.onColumnDelete?.(T);},[t]),b=["todo","in-progress","completed"],y=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),D=useMemo(()=>{let T=new Map;return e.columns.forEach(w=>{let R=w.cardIds.map(P=>e.cards.find(H=>H.id===P)).filter(P=>P!==void 0).sort((P,H)=>P.position-H.position);T.set(w.id,R);}),T},[e.cards,e.columns]),N=useCallback(T=>{let{active:w}=T,R=e.cards.find(P=>P.id===w.id);R&&i({isDragging:true,draggedCardId:R.id,sourceColumnId:R.columnId,targetColumnId:R.columnId});},[e.cards,i]),A=useCallback(T=>{let{active:w,over:R}=T;if(!R||!e.cards.find(q=>q.id===w.id))return;let H=null;R.data.current?.type==="column"?H=R.id:R.data.current?.type==="card"&&(H=e.cards.find(he=>he.id===R.id)?.columnId||null),H&&H!==d.targetColumnId&&i({...d,targetColumnId:H});},[e.cards,d,i]),v=useCallback(async T=>{let{active:w,over:R}=T;if(i({isDragging:false,draggedCardId:null,sourceColumnId:null,targetColumnId:null}),!R)return;let P=e.cards.find(xe=>xe.id===w.id);if(!P)return;let H,q;if(R.data.current?.type==="column"){H=R.id;let xe=D.get(H)||[];q=In(xe,0);}else {let xe=e.cards.find($=>$.id===R.id);if(!xe)return;H=xe.columnId;let Ae=D.get(H)||[],Be=Ae.findIndex($=>$.id===R.id);q=In(Ae,Be);}let he=e.columns.find(xe=>xe.id===H);if(he&&he.wipLimit&&he.wipLimitType==="hard"){let xe=D.get(H)||[];if(P.columnId!==H&&xe.length>=he.wipLimit){t.onWipLimitExceeded?.(he,P);return}}(P.columnId!==H||P.position!==q)&&await t.onCardMove?.(P.id,H,q);},[e.cards,e.columns,D,t,i]),B=useCallback(T=>{a?.(T);},[a]);return p?jsx("div",{className:C("asakaa-board",f,l),style:c,children:jsx(em,{columnCount:3})}):n?jsx("div",{className:C("asakaa-board",f,l),style:c,children:jsx("div",{className:"flex items-center justify-center w-full h-64",children:jsxs("div",{className:"text-center",children:[jsx("p",{className:"text-asakaa-accent-red text-lg font-semibold mb-2",children:"Error loading board"}),jsx("p",{className:"text-asakaa-text-secondary text-sm",children:typeof n=="string"?n:n.message})]})})}):jsx(Zi,{themeName:u,children:jsxs(DndContext,{sensors:y,collisionDetection:closestCorners,onDragStart:N,onDragOver:A,onDragEnd:v,children:[jsxs("div",{className:C("asakaa-board",f,l),style:c,"data-theme":u,children:[e.columns.sort((T,w)=>T.position-w.position).map(T=>{let w=D.get(T.id)||[],R=!b.includes(T.id);return jsx(zr,{column:T,cards:w,renderCard:r?.renderCard,renderColumn:r?.renderColumn,renderHeader:r?.renderColumnHeader,renderEmptyState:r?.renderEmptyState,onCardClick:B,onCardUpdate:g,onColumnRename:k,onColumnDelete:h,isDeletable:R,availableUsers:s,allCards:e.cards,enableVirtualization:o?.enableVirtualization,cardHeight:o?.cardHeight},T.id)}),m]}),jsx(DragOverlay,{children:d.draggedCardId?jsx(_a,{card:e.cards.find(T=>T.id===d.draggedCardId),render:r?.renderCardOverlay||r?.renderCard,disableDrag:true,className:"opacity-90 rotate-3 shadow-2xl"}):null})]})})}function em({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 nm={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)"},sm={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)"},im={newTask:"Nueva Tarea",selectColumn:"Seleccionar columna",export:"Exportar",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"},lm={newTask:"New Task",selectColumn:"Select column",export:"Export",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"};function dm({columns:e,onSelect:t,theme:a,t:r,createTaskLabel:o}){let[s,l]=useState(false),c=useRef(null);useEffect(()=>{let n=m=>{c.current&&!c.current.contains(m.target)&&l(false);};return s&&document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[s]);let p=n=>{t(n),l(false);};return jsxs("div",{ref:c,className:"relative",children:[jsxs(motion.button,{onClick:()=>l(!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((n,m)=>n.position-m.position).map((n,m)=>jsxs(motion.button,{onClick:()=>p(n.id),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:m<e.length-1?`1px solid ${a.borderLight}`:"none"},whileHover:{backgroundColor:a.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:m*.03},children:[jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:n.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:n.title}),jsxs("div",{className:"text-[10px] truncate",style:{color:a.textTertiary},children:[n.cardIds.length," ",n.cardIds.length===1?"tarea":"tareas"]})]})]},n.id))]})})})]})}function cm({theme:e,t,onExportCSV:a,onExportJSON:r,onExportExcel:o}){let[s,l]=useState(false),[c,p]=useState(null),n=useRef(null);if(useEffect(()=>{let u=x=>{n.current&&!n.current.contains(x.target)&&l(false);};return s&&document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[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(u=>u.handler),i=async(u,x)=>{if(x){p(u);try{await x();}catch(f){console.error(`Export ${u} failed:`,f);}finally{p(null),l(false);}}};return jsxs("div",{ref:n,className:"relative",children:[jsxs(motion.button,{onClick:()=>l(!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((u,x)=>jsxs(motion.button,{onClick:()=>i(u.id,u.handler),disabled:c!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:x<d.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:x*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:c===u.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):u.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:u.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:u.description})]})]},u.id))})})})]})}function pm({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 Vn({columns:e,onCreateTask:t,createTaskLabel:a,theme:r="dark",locale:o="es",useColumnSelector:s=false,onExportCSV:l,onExportJSON:c,onExportExcel:p,translations:n}){let m=r==="dark"?nm:sm,d={...o==="es"?im:lm,...n},i=l||c||p;return jsx("div",{className:"h-12 px-4 flex items-center justify-end border-b sticky top-0 z-10",style:{backgroundColor:m.bgGrid,borderColor:m.border},children:jsxs("div",{className:"flex items-center gap-3",children:[i&&jsxs(Fragment,{children:[jsx(cm,{theme:m,t:d,onExportCSV:l,onExportJSON:c,onExportExcel:p}),t&&jsx("div",{className:"w-px h-6",style:{backgroundColor:m.borderLight}})]}),t&&(s?jsx(dm,{columns:e,onSelect:t,theme:m,t:d,createTaskLabel:a}):jsx(pm,{onClick:()=>t(),label:a||d.newTask}))]})})}function Kn({onAddColumn:e,className:t,placeholder:a="Nombre de la columna...",buttonLabel:r="Agregar Columna",disabled:o=false}){let[s,l]=useState(false),[c,p]=useState(""),n=useCallback(()=>{let i=c.trim();i&&(e(i),p(""),l(false));},[c,e]),m=useCallback(i=>{i.key==="Enter"?(i.preventDefault(),n()):i.key==="Escape"&&(p(""),l(false));},[n]),d=useCallback(()=>{setTimeout(()=>{c.trim()||l(false);},150);},[c]);return s?jsx("div",{className:C("asakaa-add-column asakaa-add-column--editing",t),children:jsxs("div",{className:"asakaa-add-column__input-wrapper",children:[jsx("input",{type:"text",value:c,onChange:i=>p(i.target.value),onKeyDown:m,onBlur:d,placeholder:a,autoFocus:true,className:"asakaa-add-column__input"}),jsxs("div",{className:"asakaa-add-column__actions",children:[jsx("button",{onClick:n,disabled:!c.trim(),className:"asakaa-add-column__submit",type:"button",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}),jsx("button",{onClick:()=>{p(""),l(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:C("asakaa-add-column",t),children:jsxs("button",{onClick:()=>l(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 Yn({columnId:e,onAddCard:t,availableUsers:a=[],className:r,placeholder:o,buttonLabel:s,disabled:l=false,theme:c="dark",locale:p="es"}){let[n,m]=useState(false),[d,i]=useState(false),[u,x]=useState(""),[f,g]=useState([]),[k,h]=useState(""),[b,y]=useState(""),[D,N]=useState(""),[A,v]=useState(false),[B,T]=useState(false),[w,R]=useState(false),P=useRef(null),H=useRef(null),q={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"},he=useCallback(()=>{x(""),g([]),h(""),y(""),N(""),v(false),T(false),R(false),m(false);},[]);useEffect(()=>{n&&P.current&&P.current.focus();},[n]),useEffect(()=>{if(!n)return;let F=W=>{H.current&&!H.current.contains(W.target)&&(u.trim()||he());};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[n,u,he]);let xe=useCallback(async()=>{let F=u.trim();if(!(!F||d)){i(true);try{await t({name:F,columnId:e,assigneeIds:f.length>0?f:void 0,startDate:k?new Date(k):void 0,endDate:b?new Date(b):void 0,priority:D||void 0}),x(""),g([]),h(""),y(""),N(""),v(!1),T(!1),R(!1),P.current?.focus();}catch(W){console.error("Error creating card:",W);}finally{i(false);}}},[u,e,f,k,b,D,t,d]),Ae=useCallback(F=>{F.key==="Enter"&&!F.shiftKey?(F.preventDefault(),xe()):F.key==="Escape"&&he();},[xe,he]),Be=useCallback(F=>{g(W=>W.includes(F)?W.filter(E=>E!==F):[...W,F]);},[]),$=c==="dark";return n?jsxs("div",{ref:H,className:C("rounded-lg overflow-hidden shadow-lg",$?"bg-[#1e1e2e]":"bg-white",r),style:{border:"2px solid #10b981"},children:[jsxs("div",{className:"p-3",children:[jsx("input",{ref:P,type:"text",value:u,onChange:F=>x(F.target.value),onKeyDown:Ae,placeholder:q.placeholder,disabled:d,className:C("w-full px-0 py-1 text-sm font-medium border-0 bg-transparent focus:outline-none focus:ring-0",$?"text-gray-100 placeholder-gray-500":"text-gray-800 placeholder-gray-400")}),jsxs("div",{className:"flex items-center gap-1 mt-3",children:[a.length>0&&jsxs("button",{onClick:()=>v(!A),className:C("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",A||f.length>0?"bg-emerald-500/20 text-emerald-400":$?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title: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"})]}),f.length>0&&jsx("span",{className:"ml-0.5",children:f.length})]}),jsx("button",{onClick:()=>T(!B),className:C("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",B||k||b?"bg-blue-500/20 text-blue-400":$?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title: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:()=>R(!w),className:C("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",w||D?D==="urgent"?"bg-red-500/20 text-red-400":D==="high"?"bg-orange-500/20 text-orange-400":D==="medium"?"bg-yellow-500/20 text-yellow-400":D==="low"?"bg-green-500/20 text-green-400":"bg-orange-500/20 text-orange-400":$?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title: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:xe,disabled:!u.trim()||d,className:C("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})]})]}),A&&a.length>0&&jsx("div",{className:C("px-3 pb-3 pt-0","border-t",$?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex flex-wrap gap-1.5 pt-3",children:a.map(F=>jsxs("button",{onClick:()=>Be(F.id),className:C("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs transition-all",f.includes(F.id)?"bg-emerald-500 text-white":$?"bg-[#2a2a3e] text-gray-300 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-700 hover:bg-gray-200"),type:"button",children:[F.avatar?jsx("img",{src:F.avatar,alt:F.name,className:"w-4 h-4 rounded-full"}):jsx("div",{className:C("w-4 h-4 rounded-full flex items-center justify-center text-[10px] font-medium",f.includes(F.id)?"bg-emerald-600 text-white":"bg-emerald-500 text-white"),children:F.name.charAt(0).toUpperCase()}),jsx("span",{children:F.name.split(" ")[0]})]},F.id))})}),B&&jsx("div",{className:C("px-3 pb-3 pt-0","border-t",$?"border-[#3a3a4e]":"border-gray-200"),children:jsxs("div",{className:"grid grid-cols-2 gap-2 pt-3",children:[jsxs("div",{children:[jsx("label",{className:C("block text-[10px] uppercase tracking-wide mb-1",$?"text-gray-500":"text-gray-400"),children:q.startDate}),jsx("input",{type:"date",value:k,onChange:F=>h(F.target.value),className:C("w-full px-2 py-1.5 rounded text-xs border",$?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]}),jsxs("div",{children:[jsx("label",{className:C("block text-[10px] uppercase tracking-wide mb-1",$?"text-gray-500":"text-gray-400"),children:q.endDate}),jsx("input",{type:"date",value:b,onChange:F=>y(F.target.value),className:C("w-full px-2 py-1.5 rounded text-xs border",$?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]})]})}),w&&jsx("div",{className:C("px-3 pb-3 pt-0","border-t",$?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex gap-1.5 pt-3",children:["low","medium","high","urgent"].map(F=>jsx("button",{onClick:()=>N(D===F?"":F),className:C("flex-1 px-2 py-1.5 rounded text-xs font-medium transition-all",D===F?`${{low:"bg-green-500",medium:"bg-yellow-500",high:"bg-orange-500",urgent:"bg-red-500"}[F]} text-white`:$?"bg-[#2a2a3e] text-gray-400 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-600 hover:bg-gray-200"),type:"button",children:q[F]},F))})})]}):jsxs("button",{onClick:()=>m(true),disabled:l,className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg transition-all duration-200","text-emerald-500 hover:text-emerald-400",$?"hover:bg-[#2a2a3e]":"hover:bg-gray-100",l&&"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 so=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(Qa,{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(l=>{l?o(l):s(new Error("Failed to create PNG blob"));},"image/png");})}};function El(e={}){return new so(e)}var $r=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(l){console.error("Error in error handler:",l);}}render(){let{hasError:a,error:r}=this.state,{children:o,fallback:s,componentName:l}=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:l?`Error in ${l}`:"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 qn(e,t){let a=r=>jsx($r,{...t,children:jsx(e,{...r})});return a.displayName=`withErrorBoundary(${e.displayName||e.name||"Component"})`,a}function Jn({board:e,onCreateCard:t,onNavigateToCard:a,onSearch:r,onChangePriority:o,onAssignUser:s,onGeneratePlan:l,onPredictRisks:c,onOpenAIUsage:p,shortcut:n="k",className:m=""}){let[d,i]=useState(false),[u,x]=useState(""),[f,g]=useState("home"),[k,h]=useState(""),[b,y]=useState("");useEffect(()=>{let v=B=>{(B.metaKey||B.ctrlKey)&&B.key===n&&(B.preventDefault(),i(T=>!T)),B.key==="Escape"&&(i(false),g("home"),x(""));};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[n]),useEffect(()=>{d||(g("home"),x(""),h(""),y(""));},[d]);let D=useCallback(()=>{i(false);},[]),N=useCallback(v=>{let[B,T]=v.split(":");switch(B){case "create-card":g("create-card");break;case "create-card-in":h(T||"");break;case "navigate":T?(a?.(T),D()):g("navigate");break;case "search":r?.(u),D();break;case "priority":g("priority");break;case "set-priority":b&&T&&(o?.(b,T),D());break;case "assign":g("assign");break;case "assign-user":b&&T&&(s?.(b,T),D());break;case "ai":g("ai");break;case "ai-generate-plan":l?.(),D();break;case "ai-predict-risks":c?.(),D();break;case "ai-usage":p?.(),D();break;case "back":g("home");break;}},[u,b,t,a,r,o,s,l,c,p,D]),A=useCallback(()=>{k&&u.trim()&&(t?.(k,u.trim()),D());},[k,u,t,D]);return d?jsx(rt,{children:jsx("div",{className:"command-palette-overlay",onClick:D,children:jsx("div",{className:`command-palette ${m}`,onClick:v=>v.stopPropagation(),children:jsxs(Command,{value:u,onValueChange:x,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:f==="create-card"&&k?"Type card title and press Enter...":f==="create-card"?"Select a column first...":"Type a command or search...",className:"command-palette-input",onKeyDown:v=>{v.key==="Enter"&&f==="create-card"&&k&&A();}}),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."}),f==="home"&&jsxs(Fragment,{children:[jsxs(Command.Group,{heading:"Actions",className:"command-palette-group",children:[jsxs(Command.Item,{value:"create-card",onSelect:N,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:N,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:N,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:N,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(v=>jsxs(Command.Item,{value:`navigate:${v.id}`,onSelect:N,className:"command-palette-item",children:[jsx("div",{className:"command-palette-item-dot",style:{background:v.priority==="URGENT"?"#EF4444":v.priority==="HIGH"?"#F59E0B":v.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:v.title}),v.labels&&v.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:v.labels.slice(0,2).map(B=>jsx("span",{className:"command-palette-item-label",children:B},B))})]},v.id))})]}),f==="create-card"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:N,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(v=>jsxs(Command.Item,{value:`create-card-in:${v.id}`,onSelect:N,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:v.title}),jsxs("div",{className:"command-palette-item-count",children:[v.cardIds.length," cards"]})]},v.id))})]}),f==="navigate"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:N,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(v=>{let B=e.columns.find(T=>T.id===v.columnId);return jsxs(Command.Item,{value:`navigate:${v.id}`,onSelect:N,className:"command-palette-item",keywords:[v.title,v.description||"",...v.labels||[]],children:[jsx("div",{className:"command-palette-item-dot",style:{background:v.priority==="URGENT"?"#EF4444":v.priority==="HIGH"?"#F59E0B":v.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsxs("div",{className:"command-palette-item-content",children:[jsx("div",{children:v.title}),jsx("div",{className:"command-palette-item-meta",children:B?.title})]}),v.labels&&v.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:v.labels.slice(0,2).map(T=>jsx("span",{className:"command-palette-item-label",children:T},T))})]},v.id)})})]}),f==="ai"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:N,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:N,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:N,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:N,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 Al(e,t,a,r,o){let s=document.getElementById("attachment-lightbox-native");s&&s.remove();let l=document.createElement("div");l.id="attachment-lightbox-native",l.className="attachment-lightbox",l.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 Bd from'html2canvas';import {createPortal}from'react-dom';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {CheckCircle2,PlayCircle,Circle,Scissors,Settings,Eye,EyeOff,ArrowDown,ArrowUp,ArrowUpDown,BarChart3,Link2,Minus,Plus,Trash2,Pencil,Edit3,Keyboard,AlertTriangle,Moon,Sun,Palette,ZoomOut,ZoomIn,Check,ChevronRight,X,AlertCircle,CircleDot,ChevronDown,Flag,Users,Calendar,ChevronLeft,Clock,Milestone,Rows3,FileImage,FileText,FileSpreadsheet,FileJson,FolderKanban,Download,GripVertical,Tag,List,Search,CalendarDays,User,Sparkles,Maximize2,MoreHorizontal,ListChecks,Upload,MessageSquare}from'lucide-react';import {AnimatePresence,motion}from'framer-motion';import {Command}from'cmdk';import Lm from'react-markdown';import Fm from'remark-gfm';import Bm from'rehype-sanitize';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Legend,Line,AreaChart,Area,PieChart,Pie,Cell,BarChart,Bar}from'recharts';var No=(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 So=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 [So.Translate.toString(e),So.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:a,easing:r}=e;return t+" "+a+"ms "+r}}});function C(...e){return twMerge(clsx(e))}function Eo(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 up(e){return Array.from({length:e},(t,a)=>(a+1)*1e3)}function En(e,t){return e.length===0?1e3:t===0?Eo(null,e[0].position):t>=e.length?Eo(e[e.length-1].position,null):Eo(e[t-1].position,e[t].position)}function Ui(e,t=100){return e>t}var gp=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 fp(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 Po(e,t={}){let{maxAttempts:a=3,initialDelay:r=1e3,backoffMultiplier:o=2,maxDelay:s=1e4,shouldRetry:l=gp,onRetry:c}=t,p,n=0;for(let m=1;m<=a;m++){n=m;try{return {data:await e(),attempts:n,success:!0}}catch(d){if(p=d,m===a||!l(p,m))return {error:p,attempts:n,success:false};let u=fp(m,r,o,s);if(c)try{c(p,m,u);}catch(x){console.error("Error in retry callback:",x);}await new Promise(x=>setTimeout(x,u));}}return {error:p||new Error("Unknown error"),attempts:n,success:false}}function hp(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 bp(e,t={}){return async(...a)=>Po(()=>e(...a),t)}var Pn=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 Wi=(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))(Wi||{}),pr=class pr{constructor(t={}){this.defaultLogHandler=t=>{let{timestamp:a,level:r,message:o,component:s,...l}=t,c=`[${a}] [${r}] [${s}]`,p=Object.keys(l).length>0;switch(r){case "DEBUG":console.debug(c,o,p?l:"");break;case "INFO":console.info(c,o,p?l:"");break;case "WARN":console.warn(c,o,p?l:"");break;case "ERROR":console.error(c,o,p?l:""),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",...pr.globalOptions};}static configure(t){pr.globalOptions={...pr.globalOptions,...t};}child(t){return new pr({...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 Mo((a,r)=>{this.log(0,`${t} completed`,{...r,action:t,duration:a});},true):new Mo(()=>{},false)}log(t,a,r){if(!this.options.enabled||t<this.options.minLevel)return;let o={timestamp:new Date().toISOString(),level:Wi[t],message:a,component:this.options.componentName,...r};this.options.onLog(o);}};pr.globalOptions={};var Mn=pr,Mo=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}},Hi=new Mn;function vp(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 xp(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 l=e.columns.find(c=>c.id===s.columnId);return [s.id,An(s.title),An(s.description||""),An(l?.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 kp(e,t,a){let r=t;if(!r){let l=document.querySelector(".asakaa-board");l&&(r=l.parentElement||l);}if(r)try{let l=await Bd(r,{backgroundColor:"#0a0a0a",scale:1.5,logging:!1,useCORS:!0,allowTaint:!0,windowWidth:r.scrollWidth,windowHeight:r.scrollHeight}),c=l.toDataURL("image/png"),p=297,n=210,m=l.width/l.height,d=p-20,i=d/m;i>n-20&&(i=n-20,d=i*m);let u=new jsPDF({orientation:"landscape",unit:"mm",format:"a4"});u.setFontSize(16),u.setTextColor(255,255,255),u.setFillColor(10,10,10),u.rect(0,0,p,15,"F"),u.text(e.title||"Kanban Board",10,10);let x=(p-d)/2;return u.addImage(c,"PNG",x,20,d,i),u}catch(l){console.error("Error capturing board:",l);}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(l=>{let c=e.cards.filter(p=>p.columnId===l.id);s>250&&(o.addPage(),s=20),o.setFontSize(16),o.setFont("helvetica","bold"),o.text(l.title,20,s),s+=8,c.length===0?(o.setFontSize(10),o.setFont("helvetica","italic"),o.setTextColor(128,128,128),o.text("No cards in this column",20,s),o.setTextColor(0,0,0),s+=10):c.forEach(p=>{if(s>260&&(o.addPage(),s=20),o.setFontSize(12),o.setFont("helvetica","bold"),o.text(p.title,25,s),s+=6,p.description){o.setFontSize(9),o.setFont("helvetica","normal");let m=o.splitTextToSize(p.description,160);o.text(m,25,s),s+=m.length*5;}let n=[];if(p.priority&&n.push(`Priority: ${p.priority}`),p.labels&&p.labels.length>0&&n.push(`Labels: ${p.labels.join(", ")}`),p.assignedUserIds&&p.assignedUserIds.length>0&&n.push(`Assigned: ${p.assignedUserIds.length} user(s)`),p.startDate||p.endDate){let m=[];p.startDate&&m.push(`Start: ${p.startDate}`),p.endDate&&m.push(`End: ${p.endDate}`),n.push(m.join(" \u2192 "));}n.length>0&&(o.setFontSize(8),o.setTextColor(100,100,100),o.text(n.join(" \u2022 "),25,s),o.setTextColor(0,0,0),s+=5),s+=5;}),s+=5;}),o}function An(e){return e.includes(",")||e.includes('"')||e.includes(`
|
|
3
|
+
`)?`"${e.replace(/"/g,'""')}"`:e}async function _i(e,t,a,r){switch(t){case "json":return vp(e,r);case "csv":return xp(e);case "pdf":return await kp(e,a);default:throw new Error(`Unsupported export format: ${t}`)}}function Vi(e,t,a){let r=`board-export-${new Date().getTime()}`;if(t==="pdf"&&typeof e=="object"&&e!==null&&"save"in e){let m=`${r}.pdf`;e.save(m);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]}`,l={json:"application/json",csv:"text/csv",pdf:"application/pdf"},c=new Blob([e],{type:l[t]}),p=URL.createObjectURL(c),n=document.createElement("a");n.href=p,n.download=s,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(p);}function wp(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 Cp(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=ji(t[0]),r=[],o=new Map,s=[];for(let l=1;l<t.length;l++)try{let c=ji(t[l]||"");if(c.length>a.length){s.push(`Line ${l+1}: Too many columns`);continue}if(a.length-c.length>3){s.push(`Line ${l+1}: Column count mismatch (expected ${a.length}, got ${c.length})`);continue}for(;c.length<a.length;)c.push("");let n={};a.forEach((u,x)=>{n[u]=c[x]||"";});let m=n.Column||"Unnamed";o.has(m)||o.set(m,{id:`col-${o.size+1}`,title:m,position:o.size+1,cardIds:[]});let d=o.get(m),i={id:n["Card ID"]||`card-${l}`,title:n.Title||"Untitled",description:n.Description?n.Description:void 0,columnId:d.id,position:d.cardIds.length+1,priority:n.Priority||void 0,labels:n.Labels?n.Labels.split(";").filter(Boolean):void 0,assignedUserIds:n["Assigned Users"]?n["Assigned Users"].split(";").filter(Boolean):void 0,startDate:n["Start Date"]?n["Start Date"]:void 0,endDate:n["End Date"]?n["End Date"]:void 0,createdAt:n["Created At"]?n["Created At"]:void 0,updatedAt:n["Updated At"]?n["Updated At"]:void 0};r.push(i),d.cardIds.push(i.id);}catch(c){s.push(`Line ${l+1}: ${c instanceof Error?c.message:"Unknown error"}`);}return r.length===0?{success:!1,errors:["No valid cards found in CSV",...s]}:{success:!0,cardsImported:r.length,columnsImported:o.size,errors:s.length>0?s:void 0}}catch(t){return {success:false,errors:[`Failed to parse CSV: ${t instanceof Error?t.message:"Unknown error"}`]}}}function ji(e){let t=[],a="",r=false;for(let o=0;o<e.length;o++){let s=e[o],l=e[o+1];s==='"'&&r&&l==='"'?(a+='"',o++):s==='"'?r=!r:s===","&&!r?(t.push(a),a=""):a+=s;}return t.push(a),t}function Ki(e,t){switch(t){case "json":return wp(e);case "csv":return Cp(e);default:return {success:false,errors:[`Unsupported import format: ${t}`]}}}function Yi(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 In=createContext(null);function qi(){return useContext(In)}var Xi=createContext(null);function Ji({children:e,themeName:t}){return jsx(Xi.Provider,{value:{themeName:t},children:e})}function Mr(){return useContext(Xi)}function at({children:e,container:t}){let[a,r]=useState(false),o=qi(),s=Mr();if(useEffect(()=>(r(true),()=>r(false)),[]),!a)return null;let l=t||(typeof document<"u"?document.body:null);if(!l)return null;if(o){let{theme:c,themeName:p}=o,n={"--asakaa-color-background-primary":c.bgPrimary,"--asakaa-color-background-secondary":c.bgSecondary,"--asakaa-color-background-card":c.bgGrid,"--asakaa-color-background-hover":c.hoverBg,"--asakaa-color-text-primary":c.textPrimary,"--asakaa-color-text-secondary":c.textSecondary,"--asakaa-color-text-tertiary":c.textTertiary,"--asakaa-color-text-inverse":c.taskBarHandle||"#FFFFFF","--asakaa-color-border-default":c.border,"--asakaa-color-border-hover":c.borderLight,"--asakaa-color-border-subtle":c.borderLight,"--asakaa-color-interactive-primary":c.accent,"--asakaa-color-interactive-primaryHover":c.accentHover,"--asakaa-color-interactive-primaryBorder":`${c.accent}4D`,"--asakaa-color-interactive-primaryBackground":`${c.accent}1A`,"--asakaa-color-interactive-primaryBackgroundHover":`${c.accent}33`,"--asakaa-color-status-success":c.statusCompleted,"--asakaa-color-status-warning":c.milestone,"--asakaa-color-status-error":c.criticalPath,"--asakaa-color-danger":c.criticalPath,"--asakaa-color-danger-border":`${c.criticalPath}4D`,"--asakaa-color-danger-background":`${c.criticalPath}14`,"--asakaa-color-danger-backgroundHover":`${c.criticalPath}26`};return createPortal(jsx("div",{"data-theme":p,"data-gantt-portal":"true",style:n,children:e}),l)}return s?createPortal(jsx("div",{"data-theme":s.themeName,"data-kanban-portal":"true",children:e}),l):createPortal(e,l)}var al={URGENT:{label:"Urgent",color:"#E74C3C"},HIGH:{label:"High",color:"#E67E22"},MEDIUM:{label:"Normal",color:"#F1C40F"},LOW:{label:"Low",color:"#2ECC71"}},Ap="#BDC3C7",Ip=({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 mr({priority:e,onChange:t,className:a}){let[r,o]=useState(false),[s,l]=useState({top:0,left:0}),c=useRef(null),p=useRef(null),n=()=>{if(!p.current)return;let u=p.current.getBoundingClientRect(),x=window.innerHeight,f=window.innerWidth,g=160,k=220,h=4,b=u.right-g;b<10&&(b=u.left),b+g>f-10&&(b=f-g-10);let y=x-u.bottom,D=u.top,N;y>=k+h?N=u.bottom+h:D>=k+h?N=u.top-k-h:N=y>=D?u.bottom+h:Math.max(10,u.top-k-h),l({top:N,left:b}),o(true);};useEffect(()=>{let u=x=>{c.current&&!c.current.contains(x.target)&&!p.current?.contains(x.target)&&o(false);};if(r)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]),useEffect(()=>{let u=x=>{x.key==="Escape"&&o(false);};if(r)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[r]);let m=u=>{t(u),o(false);},d=e?al[e]:null,i=d?.color||Ap;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:p,onClick:()=>r?o(false):n(),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?`${i}10`:"transparent",boxShadow:e?`0 0 0 2px ${i}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:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:i,fillOpacity:e?"0.6":"0.4"})})}),r&&jsx(at,{children:jsxs("div",{ref:c,className:"priority-selector-menu",style:{position:"fixed",top:`${s.top}px`,left:`${s.left}px`,zIndex:99999,minWidth:"160px",maxHeight:"calc(100vh - 40px)",borderRadius:"8px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},children:[jsx("div",{className:"px-3 py-1.5 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.7))"},children:"Priority"})}),jsxs("div",{className:"py-1",children:[Object.entries(al).map(([u,x])=>jsxs("button",{onClick:()=>m(u),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:x.color,background:"transparent"},onMouseEnter:f=>{f.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:f=>{f.currentTarget.style.background="transparent";},children:[jsx(Ip,{color:x.color}),jsx("span",{className:"font-semibold text-sm",children:x.label}),e===u&&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"})})]},u)),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:()=>m(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:u=>{u.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:u=>{u.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 Lp=[{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 Jr({startDate:e,endDate:t,onChange:a,className:r}){let[o,s]=useState(false),[l,c]=useState({top:0,left:0}),p=useRef(null),n=useRef(null),i=(Mr()?.themeName||"dark")==="dark",u=()=>{if(!n.current)return;let b=n.current.getBoundingClientRect(),y=window.innerHeight,D=window.innerWidth,N=320,A=380,v=4,F=b.left;F+N>D-10&&(F=D-N-10),F<10&&(F=10);let T=y-b.bottom,w=b.top,B;T>=A+v?B=b.bottom+v:w>=A+v?B=b.top-A-v:B=T>=w?b.bottom+v:Math.max(10,b.top-A-v),c({top:B,left:F}),s(true);};useEffect(()=>{let b=y=>{p.current&&!p.current.contains(y.target)&&!n.current?.contains(y.target)&&s(false);};if(o)return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[o]),useEffect(()=>{let b=y=>{y.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[o]);let x=b=>{let y=new Date,D=F=>{let T=F.getFullYear(),w=String(F.getMonth()+1).padStart(2,"0"),B=String(F.getDate()).padStart(2,"0");return `${T}-${w}-${B}`},N=D(y),A=new Date(y);A.setDate(A.getDate()+b);let v=D(A);a(N,v),s(false);},f=()=>{if(!e||!t)return "Set date";let b=A=>{if(A instanceof Date)return A;if(typeof A!="string"||!A.match(/^\d{4}-\d{2}-\d{2}$/))return null;let v=A.split("-").map(Number);if(v.length!==3||v.some(B=>isNaN(B)))return null;let F=v[0],T=v[1],w=v[2];return F===void 0||T===void 0||w===void 0?null:new Date(F,T-1,w)},y=b(e),D=b(t);if(!y||!D||isNaN(y.getTime())||isNaN(D.getTime()))return "Set date";let N=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return `${N[y.getMonth()]} ${y.getDate()} \u2013 ${N[D.getMonth()]} ${D.getDate()}`},g=e&&t,h=(()=>{if(!t)return false;let b=typeof t=="string"?new Date(t):t,y=new Date;return y.setHours(0,0,0,0),b<y})();return jsxs("div",{className:`relative ${r||""}`,children:[jsxs("button",{ref:n,onClick:()=>o?s(false):u(),className:`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-all hover:bg-white/5 ${h?"asakaa-date-overdue":"asakaa-date"}`,title:g?`${f()}`:"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:f()})]}),o&&jsx(at,{children:jsxs("div",{ref:p,className:"date-picker-menu rounded-xl shadow-2xl border min-w-[320px]",style:{position:"fixed",top:`${l.top}px`,left:`${l.left}px`,background:i?"#1A1D25":"#FFFFFF",border:`1px solid ${i?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.12)"}`,boxShadow:i?"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:i?"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:i?"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:Lp.map(b=>jsx("button",{onClick:()=>x(b.days),className:"px-3 py-2.5 rounded-lg text-xs font-semibold transition-all active:scale-95",style:{color:i?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",border:`1px solid ${i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`,backgroundColor:i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)"},onMouseEnter:y=>{y.currentTarget.style.backgroundColor=i?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.1)",y.currentTarget.style.border=`1px solid ${i?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.25)"}`;},onMouseLeave:y=>{y.currentTarget.style.backgroundColor=i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",y.currentTarget.style.border=`1px solid ${i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`;},children:b.label},b.label))})]}),jsxs("div",{className:"p-4",children:[jsx("span",{className:"text-xs font-bold uppercase tracking-wider block mb-3",style:{color:i?"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:b=>a(b.target.value,t),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:i?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:i?"dark":"light"}}),jsx("input",{type:"date",value:t||"",onChange:b=>a(e,b.target.value),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:i?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:i?"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:b=>{b.currentTarget.style.background="rgba(239, 68, 68, 0.2)";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(239, 68, 68, 0.1)";},children:"Clear Dates"})]})]})})]})}function gr({assignedUsers:e=[],availableUsers:t,onChange:a,className:r,maxVisibleAvatars:o=3}){let[s,l]=useState(false),[c,p]=useState(""),[n,m]=useState({top:0,left:0}),d=useRef(null),i=useRef(null),u=()=>{if(!i.current)return;let h=i.current.getBoundingClientRect(),b=window.innerHeight,y=window.innerWidth,D=300,N=380,A=4,v=h.right-D;v<10&&(v=h.left),v+D>y-10&&(v=y-D-10);let F=b-h.bottom,T=h.top,w;F>=N+A?w=h.bottom+A:T>=N+A?w=h.top-N-A:w=F>=T?h.bottom+A:Math.max(10,h.top-N-A),m({top:w,left:v}),l(true);};useEffect(()=>{let h=b=>{d.current&&!d.current.contains(b.target)&&!i.current?.contains(b.target)&&(l(false),p(""));};if(s)return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s]),useEffect(()=>{let h=b=>{b.key==="Escape"&&(l(false),p(""));};if(s)return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[s]);let x=h=>{let b=e.some(y=>y.id===h.id);a(b?e.filter(y=>y.id!==h.id):[...e,h]);},f=t.filter(h=>h.name.toLowerCase().includes(c.toLowerCase())),g=e.slice(0,o),k=e.length-o;return jsxs("div",{className:`relative ${r||""}`,children:[jsx("button",{ref:i,onClick:()=>s?l(false):u(),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:[g.map(h=>jsx("div",{className:"asakaa-avatar",title:h.name,children:h.avatar?jsx("img",{src:h.avatar,alt:h.name,className:"asakaa-avatar-img"}):h.initials},h.id)),k>0&&jsxs("div",{className:"asakaa-avatar",children:["+",k]})]}):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(at,{children:jsxs("div",{ref:d,className:"user-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${n.top}px`,left:`${n.left}px`,maxHeight:"calc(100vh - 40px)",overflow:"hidden",display:"flex",flexDirection:"column",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:[jsx("div",{className:"px-4 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-xs font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.8))"},children:"Assign Users"})}),jsx("div",{className:"px-3 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("input",{type:"text",value:c,onChange:h=>p(h.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:f.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"}):f.map(h=>{let b=e.some(y=>y.id===h.id);return jsxs("button",{onClick:()=>x(h),className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm transition-all active:scale-98",style:{background:"transparent"},onMouseEnter:y=>{y.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.1))";},onMouseLeave:y=>{y.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:h.color,color:"#fff"},children:h.avatar?jsx("img",{src:h.avatar,alt:h.name,className:"w-full h-full rounded-full object-cover"}):h.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:h.name}),jsx("span",{className:"w-5 text-lg flex-shrink-0 text-right",style:{color:b?"#3b82f6":"transparent"},children:b?"\u2713":""})]},h.id)})}),e.length>0&&jsx("div",{className:"px-3 py-3 border-t border-white/10",children:jsx("button",{onClick:()=>{a([]),l(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 Ao(e,t,a){let r=new Map;e.forEach(p=>{if(p.dependencies&&Array.isArray(p.dependencies)){let n=p.dependencies.map(m=>{if(typeof m=="string")return m;let d=m;return d.taskId||d.targetId||""}).filter(Boolean);r.set(p.id,n);}});let o=r.get(a)||[];r.set(a,[...o,t]);let s=new Set,l=new Set,c=p=>{if(!s.has(p)){s.add(p),l.add(p);let n=r.get(p)||[];for(let m of n){if(!s.has(m)&&c(m))return true;if(l.has(m))return true}}return l.delete(p),false};return c(a)}function Qr({currentCardId:e,dependencies:t=[],availableTasks:a,onChange:r,className:o,validateCircular:s=true,onCircularDependencyError:l}){let[c,p]=useState(false),[n,m]=useState(""),[d,i]=useState(t.length>0),[u,x]=useState({top:0,left:0}),[f,g]=useState(null),k=useRef(null),h=useRef(null),b=()=>{if(!h.current)return;let v=h.current.getBoundingClientRect(),F=window.innerHeight,T=window.innerWidth,w=300,B=d?380:120,P=4,H=v.right-w;H<10&&(H=v.left),H+w>T-10&&(H=T-w-10);let X=F-v.bottom,fe=v.top,ve;X>=B+P?ve=v.bottom+P:fe>=B+P?ve=v.top-B-P:ve=X>=fe?v.bottom+P:Math.max(10,v.top-B-P),x({top:ve,left:H}),p(true);};useEffect(()=>{if(!c||!h.current)return;let v=h.current.getBoundingClientRect(),F=window.innerHeight,T=window.innerWidth,w=300,B=d?380:120,P=4,H=v.right-w;H<10&&(H=v.left),H+w>T-10&&(H=T-w-10);let X=F-v.bottom,fe=v.top,ve;X>=B+P?ve=v.bottom+P:fe>=B+P?ve=v.top-B-P:ve=X>=fe?v.bottom+P:Math.max(10,v.top-B-P),x({top:ve,left:H});},[d,c]),useEffect(()=>{let v=F=>{k.current&&!k.current.contains(F.target)&&!h.current?.contains(F.target)&&(p(false),m(""));};if(c)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[c]),useEffect(()=>{let v=F=>{F.key==="Escape"&&(p(false),m(""));};if(c)return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[c]);let y=v=>{let F=t.includes(v),T=a.find(w=>w.id===v);if(g(null),F){let w=t.filter(B=>B!==v);r(w),w.length===0&&i(false);}else {if(s&&Ao(a,v,e)){let B=`Cannot add "${T?.title||v}" as dependency - would create circular reference`;g(B),l?.(v,T?.title||v),setTimeout(()=>g(null),3e3);return}r([...t,v]),i(true);}},D=()=>{let v=!d;i(v),v||r([]);},N=a.filter(v=>v.id!==e).filter(v=>v.title.toLowerCase().includes(n.toLowerCase())||v.id.toLowerCase().includes(n.toLowerCase())),A=t.length>0?"#3B82F6":"#BDC3C7";return jsxs("div",{className:`relative ${o||""}`,children:[jsxs("button",{ref:h,onClick:()=>c?p(false):b(),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:A,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),t.length>0&&jsx("span",{className:"text-xs font-medium",style:{color:A},children:t.length})]}),c&&jsx(at,{children:jsxs("div",{ref:k,className:"dependencies-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${u.top}px`,left:`${u.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:[f&&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:f})]}),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:D,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:n,onChange:v=>m(v.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:N.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"}):N.map(v=>{let F=t.includes(v.id);return jsxs("button",{onClick:()=>y(v.id),className:"w-full px-4 py-2 flex items-start gap-3 text-sm transition-colors",style:{background:"transparent"},onMouseEnter:T=>{T.currentTarget.style.background="var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))";},onMouseLeave:T=>{T.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:F?"#3b82f6":"transparent",borderColor:F?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:F&&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:v.title}),jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:v.id})]})]},v.id)})})]}),t.length>0&&jsx("div",{className:"px-3 py-2 border-t border-white/5",children:jsx("button",{onClick:()=>{r([]),i(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 _a=memo(({card:e,render:t,onClick:a,isSelected:r,disableDrag:o,className:s,onUpdate:l,availableUsers:c=[],allCards:p=[]})=>{let{attributes:n,listeners:m,setNodeRef:d,transform:i,transition:u,isDragging:x}=useSortable({id:e.id,disabled:o,data:{type:"card",card:e}}),f={transform:So.Transform.toString(i),transition:u};if(t)return jsx("div",{ref:d,style:f,...n,...m,onClick:()=>a?.(e),children:t(e)});let g=c.filter(y=>e.assignedUserIds?.includes(y.id)),k=e.progress===100,h=(e.attachments||[]).filter(y=>y.type.startsWith("image/")),b={...f,...e.color&&{borderTopWidth:"3px",borderTopStyle:"solid",borderTopColor:e.color}};return jsxs("div",{ref:d,style:b,className:C("asakaa-card",x&&"asakaa-card-dragging",r&&"ring-2 ring-asakaa-accent-blue",s),...n,...m,onClick:y=>{y.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:y=>{y.currentTarget.style.display="none";}})}),h.length>0&&!e.coverImage&&jsx("div",{className:"asakaa-card-attachments mb-3",children:h.length===1&&h[0]?jsx("img",{src:h[0].thumbnailUrl||h[0].url,alt:h[0].name,className:"w-full h-28 object-cover rounded-md",loading:"lazy",onError:y=>{y.currentTarget.style.display="none";}}):jsx("div",{className:"grid grid-cols-2 gap-1",children:h.slice(0,4).map((y,D)=>jsxs("div",{className:"relative",children:[jsx("img",{src:y.thumbnailUrl||y.url,alt:y.name,className:"w-full h-14 object-cover rounded",loading:"lazy",onError:N=>{N.currentTarget.style.display="none";}}),D===3&&h.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:["+",h.length-4]})})]},y.id))})}),jsx("h3",{className:"asakaa-card-title mb-2",style:{textDecoration:k?"line-through":"none",opacity:k?.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:y=>y.stopPropagation(),className:"priority-selector",children:jsx(mr,{priority:e.priority,onChange:y=>l?.(e.id,{priority:y})})}),jsx("div",{onClick:y=>y.stopPropagation(),className:"date-picker",children:jsx(Jr,{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:(y,D)=>l?.(e.id,{startDate:y,endDate:D})})}),c.length>0&&jsx("div",{onClick:y=>y.stopPropagation(),className:"user-selector",children:jsx(gr,{assignedUsers:g,availableUsers:c,onChange:y=>l?.(e.id,{assignedUserIds:y.map(D=>D.id)})})}),jsx("div",{onClick:y=>y.stopPropagation(),className:"dependencies-selector",children:jsx(Qr,{currentCardId:e.id,dependencies:Array.isArray(e.dependencies)?e.dependencies.map(y=>typeof y=="string"?y:y.taskId):[],availableTasks:p,onChange:y=>l?.(e.id,{dependencies:y})})})]}),e.labels&&e.labels.length>0&&jsx("div",{className:"flex flex-wrap gap-1",children:e.labels.slice(0,3).map(y=>jsx("span",{className:"asakaa-label",children:y},y))}),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)));_a.displayName="Card";var Io={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"}},ml=({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 ul({status:e="todo",onChange:t,className:a,customStatuses:r=[]}){let[o,s]=useState(false),[l,c]=useState({top:0,left:0}),p=useRef(null),n=useRef(null),m=[...Object.entries(Io).map(([g,k])=>({id:g,label:k.label,color:k.color,icon:k.icon})),...r.filter(g=>!Object.keys(Io).includes(g.id)).map(g=>({id:g.id,label:g.title,color:g.color||"#8B5CF6",icon:"circle-dot"}))],d=()=>{let g=Io[e];if(g)return {...g,id:e};let k=r.find(h=>h.id===e);return k?{id:k.id,label:k.title,color:k.color||"#8B5CF6",icon:"circle-dot"}:{...Io.todo,id:"todo"}},i=()=>{if(!n.current)return;let g=n.current.getBoundingClientRect(),k=window.innerHeight,h=window.innerWidth,b=180,y=280,D=4,N=g.right-b;N<10&&(N=g.left),N+b>h-10&&(N=h-b-10);let A=k-g.bottom,v=g.top,F;A>=y+D?F=g.bottom+D:v>=y+D?F=g.top-y-D:F=A>=v?g.bottom+D:Math.max(10,g.top-y-D),c({top:F,left:N}),s(true);};useEffect(()=>{let g=k=>{p.current&&!p.current.contains(k.target)&&!n.current?.contains(k.target)&&s(false);};if(o)return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[o]),useEffect(()=>{let g=k=>{k.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[o]);let u=g=>{t(g),s(false);},x=d(),f=x.color;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:n,onClick:()=>o?s(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:`${f}10`,boxShadow:`0 0 0 2px ${f}30 inset`},title:x.label,children:jsx(ml,{icon:x.icon,color:f})}),o&&jsx(at,{children:jsxs("div",{ref:p,className:"status-selector-menu",style:{position:"fixed",top:`${l.top}px`,left:`${l.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:m.map(g=>jsxs("button",{onClick:()=>u(g.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:g.color,background:"transparent"},onMouseEnter:k=>{k.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:k=>{k.currentTarget.style.background="transparent";},children:[jsx(ml,{icon:g.icon,color:g.color}),jsx("span",{className:"font-semibold",children:g.label}),e===g.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"})})]},g.id))})]})})]})}function gl({columnTitle:e,onRename:t,onDelete:a,isDeletable:r=false,className:o}){let[s,l]=useState(false),[c,p]=useState(false),[n,m]=useState(e),[d,i]=useState({top:0,left:0}),u=useRef(null),x=useRef(null),f=useRef(null);useEffect(()=>{if(s&&x.current){let b=x.current.getBoundingClientRect();i({top:b.bottom+window.scrollY+8,left:b.left+window.scrollX});}},[s]),useEffect(()=>{let b=y=>{u.current&&!u.current.contains(y.target)&&!x.current?.contains(y.target)&&(l(false),p(false));};if(s)return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s]),useEffect(()=>{let b=y=>{y.key==="Escape"&&(l(false),p(false),m(e));};if(s)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[s,e]),useEffect(()=>{c&&f.current&&(f.current.focus(),f.current.select());},[c]);let g=()=>{p(true),m(e);},k=()=>{let b=n.trim();b&&b!==e&&t(b),p(false),l(false),m(e);},h=b=>{b.key==="Enter"?k():b.key==="Escape"&&(p(false),m(e));};return jsxs("div",{className:`relative ${o||""}`,children:[jsx("button",{ref:x,onClick:()=>l(!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(at,{children:jsx("div",{ref:u,className:"fixed rounded-xl shadow-2xl border min-w-[200px]",style:{top:`${d.top}px`,left:`${d.left}px`,background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:c?jsxs("div",{className:"p-3",children:[jsx("label",{className:"text-xs font-bold text-white/80 uppercase tracking-wider block mb-2",children:"Rename Column"}),jsx("input",{ref:f,type:"text",value:n,onChange:b=>m(b.target.value),onKeyDown:h,onBlur:k,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:g,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(),l(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 Lr=memo(({column:e,cards:t,renderColumn:a,renderCard:r,renderHeader:o,renderEmptyState:s,onCardClick:l,onCardUpdate:c,availableUsers:p,allCards:n,enableVirtualization:m,cardHeight:d=120,isCollapsed:i,onToggleCollapse:u,onColumnRename:x,onColumnDelete:f,isDeletable:g=false,className:k})=>{let{setNodeRef:h,isOver:b}=useDroppable({id:e.id,data:{type:"column",column:e}}),y=useRef(null),D=m??Ui(t.length),N=useVirtualizer({count:t.length,getScrollElement:()=>y.current,estimateSize:()=>d,enabled:D});if(a)return jsx("div",{ref:h,className:k,children:a(e,t)});let v=(()=>{if(!e.wipLimit)return {state:"none",percentage:0};let w=t.length/e.wipLimit*100;return t.length>e.wipLimit?{state:"exceeded",percentage:w}:w>=80?{state:"warning",percentage:w}:w>=60?{state:"approaching",percentage:w}:{state:"ok",percentage:w}})(),F=v.state==="exceeded",T=()=>"asakaa-column-count";return jsxs("div",{ref:h,className:C("asakaa-column",b&&"ring-2 ring-asakaa-accent-blue",F&&"ring-2 ring-asakaa-accent-red",k),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:C(T()),children:[t.length,e.wipLimit&&` / ${e.wipLimit}`]}),e.wipLimit&&v.state!=="none"&&jsxs("span",{className:"text-xs font-medium flex items-center",title:`${v.percentage.toFixed(0)}% capacity${e.wipLimitType==="hard"?" (Hard limit - blocks new cards)":" (Soft limit - shows warning)"}`,children:[v.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"})]}),v.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"})]}),v.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"})}),v.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"})]})]}),(x||f)&&jsx(gl,{columnTitle:e.title,onRename:w=>x?.(e.id,w),onDelete:f?()=>f(e.id):void 0,isDeletable:g}),u&&jsx("button",{onClick:u,className:"text-asakaa-text-tertiary hover:text-asakaa-text-primary","aria-label":i?"Expand column":"Collapse column",children:i?"\u25B6":"\u25BC"})]})]}),!i&&jsx("div",{ref:y,className:"asakaa-column-cards",style:{maxHeight:D?"600px":void 0},children:jsx(SortableContext,{items:t.map(w=>w.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"})}):D?jsx("div",{style:{height:`${N.getTotalSize()}px`,position:"relative"},children:N.getVirtualItems().map(w=>{let B=t[w.index];return B?jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${w.start}px)`},children:jsx(_a,{card:B,render:r,onClick:l,onUpdate:c,availableUsers:p,allCards:n})},B.id):null})}):t.map(w=>jsx(_a,{card:w,render:r,onClick:l,onUpdate:c,availableUsers:p,allCards:n},w.id))})})]})});Lr.displayName="Column";function On({title:e,onSave:t,className:a}){let[r,o]=useState(false),[s,l]=useState(e),c=useRef(null);useEffect(()=>{r&&c.current&&(c.current.focus(),c.current.select());},[r]);let p=()=>{let m=s.trim();m&&m!==e?t(m):l(e),o(false);},n=m=>{m.key==="Enter"?p():m.key==="Escape"&&(l(e),o(false));};return r?jsx("input",{ref:c,type:"text",value:s,onChange:m=>l(m.target.value),onBlur:p,onKeyDown:n,className:C("asakaa-column-title bg-transparent border-b-2 border-blue-500","outline-none px-1 -ml-1",a),maxLength:50}):jsx("h2",{className:C("asakaa-column-title cursor-pointer",a),onClick:()=>o(true),title:"Click to edit",children:e})}function $n(){let[e,t]=useState(()=>dragStore.getState());useEffect(()=>dragStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{dragStore.setState(r);},[]);return [e,a]}function Qa({board:e,callbacks:t,onCardClick:a,renderProps:r,config:o,availableUsers:s=[],className:l,style:c,isLoading:p,error:n,children:m}){let[d,i]=$n(),u=o?.theme||"dark",f=u==="dark"||u==="neutral"?"dark":"",g=useCallback((T,w)=>{t.onCardUpdate?.(T,w);},[t]),k=useCallback((T,w)=>{t.onColumnUpdate?.(T,{title:w});},[t]),h=useCallback(T=>{t.onColumnDelete?.(T);},[t]),b=["todo","in-progress","completed"],y=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),D=useMemo(()=>{let T=new Map;return e.columns.forEach(w=>{let B=w.cardIds.map(P=>e.cards.find(H=>H.id===P)).filter(P=>P!==void 0).sort((P,H)=>P.position-H.position);T.set(w.id,B);}),T},[e.cards,e.columns]),N=useCallback(T=>{let{active:w}=T,B=e.cards.find(P=>P.id===w.id);B&&i({isDragging:true,draggedCardId:B.id,sourceColumnId:B.columnId,targetColumnId:B.columnId});},[e.cards,i]),A=useCallback(T=>{let{active:w,over:B}=T;if(!B||!e.cards.find(X=>X.id===w.id))return;let H=null;B.data.current?.type==="column"?H=B.id:B.data.current?.type==="card"&&(H=e.cards.find(fe=>fe.id===B.id)?.columnId||null),H&&H!==d.targetColumnId&&i({...d,targetColumnId:H});},[e.cards,d,i]),v=useCallback(async T=>{let{active:w,over:B}=T;if(i({isDragging:false,draggedCardId:null,sourceColumnId:null,targetColumnId:null}),!B)return;let P=e.cards.find(ve=>ve.id===w.id);if(!P)return;let H,X;if(B.data.current?.type==="column"){H=B.id;let ve=D.get(H)||[];X=En(ve,0);}else {let ve=e.cards.find(z=>z.id===B.id);if(!ve)return;H=ve.columnId;let Re=D.get(H)||[],Ue=Re.findIndex(z=>z.id===B.id);X=En(Re,Ue);}let fe=e.columns.find(ve=>ve.id===H);if(fe&&fe.wipLimit&&fe.wipLimitType==="hard"){let ve=D.get(H)||[];if(P.columnId!==H&&ve.length>=fe.wipLimit){t.onWipLimitExceeded?.(fe,P);return}}(P.columnId!==H||P.position!==X)&&await t.onCardMove?.(P.id,H,X);},[e.cards,e.columns,D,t,i]),F=useCallback(T=>{a?.(T);},[a]);return p?jsx("div",{className:C("asakaa-board",f,l),style:c,children:jsx(rm,{columnCount:3})}):n?jsx("div",{className:C("asakaa-board",f,l),style:c,children:jsx("div",{className:"flex items-center justify-center w-full h-64",children:jsxs("div",{className:"text-center",children:[jsx("p",{className:"text-asakaa-accent-red text-lg font-semibold mb-2",children:"Error loading board"}),jsx("p",{className:"text-asakaa-text-secondary text-sm",children:typeof n=="string"?n:n.message})]})})}):jsx(Ji,{themeName:u,children:jsxs(DndContext,{sensors:y,collisionDetection:closestCorners,onDragStart:N,onDragOver:A,onDragEnd:v,children:[jsxs("div",{className:C("asakaa-board",f,l),style:c,"data-theme":u,children:[e.columns.sort((T,w)=>T.position-w.position).map(T=>{let w=D.get(T.id)||[],B=!b.includes(T.id);return jsx(Lr,{column:T,cards:w,renderCard:r?.renderCard,renderColumn:r?.renderColumn,renderHeader:r?.renderColumnHeader,renderEmptyState:r?.renderEmptyState,onCardClick:F,onCardUpdate:g,onColumnRename:k,onColumnDelete:h,isDeletable:B,availableUsers:s,allCards:e.cards,enableVirtualization:o?.enableVirtualization,cardHeight:o?.cardHeight},T.id)}),m]}),jsx(DragOverlay,{children:d.draggedCardId?jsx(_a,{card:e.cards.find(T=>T.id===d.draggedCardId),render:r?.renderCardOverlay||r?.renderCard,disableDrag:true,className:"opacity-90 rotate-3 shadow-2xl"}):null})]})})}function rm({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 lm={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)"},dm={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)"},cm={newTask:"Nueva Tarea",selectColumn:"Seleccionar columna",export:"Exportar",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"},pm={newTask:"New Task",selectColumn:"Select column",export:"Export",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"};function mm({columns:e,onSelect:t,theme:a,t:r,createTaskLabel:o}){let[s,l]=useState(false),c=useRef(null);useEffect(()=>{let n=m=>{c.current&&!c.current.contains(m.target)&&l(false);};return s&&document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[s]);let p=n=>{t(n),l(false);};return jsxs("div",{ref:c,className:"relative",children:[jsxs(motion.button,{onClick:()=>l(!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((n,m)=>n.position-m.position).map((n,m)=>jsxs(motion.button,{onClick:()=>p(n.id),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:m<e.length-1?`1px solid ${a.borderLight}`:"none"},whileHover:{backgroundColor:a.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:m*.03},children:[jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:n.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:n.title}),jsxs("div",{className:"text-[10px] truncate",style:{color:a.textTertiary},children:[n.cardIds.length," ",n.cardIds.length===1?"tarea":"tareas"]})]})]},n.id))]})})})]})}function um({theme:e,t,onExportCSV:a,onExportJSON:r,onExportExcel:o}){let[s,l]=useState(false),[c,p]=useState(null),n=useRef(null);if(useEffect(()=>{let u=x=>{n.current&&!n.current.contains(x.target)&&l(false);};return s&&document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[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(u=>u.handler),i=async(u,x)=>{if(x){p(u);try{await x();}catch(f){console.error(`Export ${u} failed:`,f);}finally{p(null),l(false);}}};return jsxs("div",{ref:n,className:"relative",children:[jsxs(motion.button,{onClick:()=>l(!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((u,x)=>jsxs(motion.button,{onClick:()=>i(u.id,u.handler),disabled:c!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:x<d.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:x*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:c===u.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):u.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:u.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:u.description})]})]},u.id))})})})]})}function gm({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 Wn({columns:e,onCreateTask:t,createTaskLabel:a,theme:r="dark",locale:o="es",useColumnSelector:s=false,onExportCSV:l,onExportJSON:c,onExportExcel:p,translations:n}){let m=r==="dark"?lm:dm,d={...o==="es"?cm:pm,...n},i=l||c||p;return jsx("div",{className:"h-12 px-4 flex items-center justify-end border-b sticky top-0 z-10",style:{backgroundColor:m.bgGrid,borderColor:m.border},children:jsxs("div",{className:"flex items-center gap-3",children:[i&&jsxs(Fragment,{children:[jsx(um,{theme:m,t:d,onExportCSV:l,onExportJSON:c,onExportExcel:p}),t&&jsx("div",{className:"w-px h-6",style:{backgroundColor:m.borderLight}})]}),t&&(s?jsx(mm,{columns:e,onSelect:t,theme:m,t:d,createTaskLabel:a}):jsx(gm,{onClick:()=>t(),label:a||d.newTask}))]})})}function Gn({onAddColumn:e,className:t,placeholder:a="Nombre de la columna...",buttonLabel:r="Agregar Columna",disabled:o=false}){let[s,l]=useState(false),[c,p]=useState(""),n=useCallback(()=>{let i=c.trim();i&&(e(i),p(""),l(false));},[c,e]),m=useCallback(i=>{i.key==="Enter"?(i.preventDefault(),n()):i.key==="Escape"&&(p(""),l(false));},[n]),d=useCallback(()=>{setTimeout(()=>{c.trim()||l(false);},150);},[c]);return s?jsx("div",{className:C("asakaa-add-column asakaa-add-column--editing",t),children:jsxs("div",{className:"asakaa-add-column__input-wrapper",children:[jsx("input",{type:"text",value:c,onChange:i=>p(i.target.value),onKeyDown:m,onBlur:d,placeholder:a,autoFocus:true,className:"asakaa-add-column__input"}),jsxs("div",{className:"asakaa-add-column__actions",children:[jsx("button",{onClick:n,disabled:!c.trim(),className:"asakaa-add-column__submit",type:"button",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}),jsx("button",{onClick:()=>{p(""),l(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:C("asakaa-add-column",t),children:jsxs("button",{onClick:()=>l(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 _n({columnId:e,onAddCard:t,availableUsers:a=[],className:r,placeholder:o,buttonLabel:s,disabled:l=false,theme:c="dark",locale:p="es"}){let[n,m]=useState(false),[d,i]=useState(false),[u,x]=useState(""),[f,g]=useState([]),[k,h]=useState(""),[b,y]=useState(""),[D,N]=useState(""),[A,v]=useState(false),[F,T]=useState(false),[w,B]=useState(false),P=useRef(null),H=useRef(null),X={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"},fe=useCallback(()=>{x(""),g([]),h(""),y(""),N(""),v(false),T(false),B(false),m(false);},[]);useEffect(()=>{n&&P.current&&P.current.focus();},[n]),useEffect(()=>{if(!n)return;let L=U=>{H.current&&!H.current.contains(U.target)&&(u.trim()||fe());};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[n,u,fe]);let ve=useCallback(async()=>{let L=u.trim();if(!(!L||d)){i(true);try{await t({name:L,columnId:e,assigneeIds:f.length>0?f:void 0,startDate:k?new Date(k):void 0,endDate:b?new Date(b):void 0,priority:D||void 0}),x(""),g([]),h(""),y(""),N(""),v(!1),T(!1),B(!1),P.current?.focus();}catch(U){console.error("Error creating card:",U);}finally{i(false);}}},[u,e,f,k,b,D,t,d]),Re=useCallback(L=>{L.key==="Enter"&&!L.shiftKey?(L.preventDefault(),ve()):L.key==="Escape"&&fe();},[ve,fe]),Ue=useCallback(L=>{g(U=>U.includes(L)?U.filter(E=>E!==L):[...U,L]);},[]),z=c==="dark";return n?jsxs("div",{ref:H,className:C("rounded-lg overflow-hidden shadow-lg",z?"bg-[#1e1e2e]":"bg-white",r),style:{border:"2px solid #10b981"},children:[jsxs("div",{className:"p-3",children:[jsx("input",{ref:P,type:"text",value:u,onChange:L=>x(L.target.value),onKeyDown:Re,placeholder:X.placeholder,disabled:d,className:C("w-full px-0 py-1 text-sm font-medium border-0 bg-transparent focus:outline-none focus:ring-0",z?"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:()=>v(!A),className:C("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",A||f.length>0?"bg-emerald-500/20 text-emerald-400":z?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:X.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"})]}),f.length>0&&jsx("span",{className:"ml-0.5",children:f.length})]}),jsx("button",{onClick:()=>T(!F),className:C("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",F||k||b?"bg-blue-500/20 text-blue-400":z?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:X.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:()=>B(!w),className:C("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",w||D?D==="urgent"?"bg-red-500/20 text-red-400":D==="high"?"bg-orange-500/20 text-orange-400":D==="medium"?"bg-yellow-500/20 text-yellow-400":D==="low"?"bg-green-500/20 text-green-400":"bg-orange-500/20 text-orange-400":z?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:X.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:ve,disabled:!u.trim()||d,className:C("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"}):X.save})]})]}),A&&a.length>0&&jsx("div",{className:C("px-3 pb-3 pt-0","border-t",z?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex flex-wrap gap-1.5 pt-3",children:a.map(L=>jsxs("button",{onClick:()=>Ue(L.id),className:C("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs transition-all",f.includes(L.id)?"bg-emerald-500 text-white":z?"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:C("w-4 h-4 rounded-full flex items-center justify-center text-[10px] font-medium",f.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))})}),F&&jsx("div",{className:C("px-3 pb-3 pt-0","border-t",z?"border-[#3a3a4e]":"border-gray-200"),children:jsxs("div",{className:"grid grid-cols-2 gap-2 pt-3",children:[jsxs("div",{children:[jsx("label",{className:C("block text-[10px] uppercase tracking-wide mb-1",z?"text-gray-500":"text-gray-400"),children:X.startDate}),jsx("input",{type:"date",value:k,onChange:L=>h(L.target.value),className:C("w-full px-2 py-1.5 rounded text-xs border",z?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]}),jsxs("div",{children:[jsx("label",{className:C("block text-[10px] uppercase tracking-wide mb-1",z?"text-gray-500":"text-gray-400"),children:X.endDate}),jsx("input",{type:"date",value:b,onChange:L=>y(L.target.value),className:C("w-full px-2 py-1.5 rounded text-xs border",z?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]})]})}),w&&jsx("div",{className:C("px-3 pb-3 pt-0","border-t",z?"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:()=>N(D===L?"":L),className:C("flex-1 px-2 py-1.5 rounded text-xs font-medium transition-all",D===L?`${{low:"bg-green-500",medium:"bg-yellow-500",high:"bg-orange-500",urgent:"bg-red-500"}[L]} text-white`:z?"bg-[#2a2a3e] text-gray-400 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-600 hover:bg-gray-200"),type:"button",children:X[L]},L))})})]}):jsxs("button",{onClick:()=>m(true),disabled:l,className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg transition-all duration-200","text-emerald-500 hover:text-emerald-400",z?"hover:bg-[#2a2a3e]":"hover:bg-gray-100",l&&"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:X.buttonLabel})]})}var ro=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(Qa,{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(l=>{l?o(l):s(new Error("Failed to create PNG blob"));},"image/png");})}};function Sl(e={}){return new ro(e)}var Fr=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(l){console.error("Error in error handler:",l);}}render(){let{hasError:a,error:r}=this.state,{children:o,fallback:s,componentName:l}=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:l?`Error in ${l}`:"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 Vn(e,t){let a=r=>jsx(Fr,{...t,children:jsx(e,{...r})});return a.displayName=`withErrorBoundary(${e.displayName||e.name||"Component"})`,a}function Kn({board:e,onCreateCard:t,onNavigateToCard:a,onSearch:r,onChangePriority:o,onAssignUser:s,onGeneratePlan:l,onPredictRisks:c,onOpenAIUsage:p,shortcut:n="k",className:m=""}){let[d,i]=useState(false),[u,x]=useState(""),[f,g]=useState("home"),[k,h]=useState(""),[b,y]=useState("");useEffect(()=>{let v=F=>{(F.metaKey||F.ctrlKey)&&F.key===n&&(F.preventDefault(),i(T=>!T)),F.key==="Escape"&&(i(false),g("home"),x(""));};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[n]),useEffect(()=>{d||(g("home"),x(""),h(""),y(""));},[d]);let D=useCallback(()=>{i(false);},[]),N=useCallback(v=>{let[F,T]=v.split(":");switch(F){case "create-card":g("create-card");break;case "create-card-in":h(T||"");break;case "navigate":T?(a?.(T),D()):g("navigate");break;case "search":r?.(u),D();break;case "priority":g("priority");break;case "set-priority":b&&T&&(o?.(b,T),D());break;case "assign":g("assign");break;case "assign-user":b&&T&&(s?.(b,T),D());break;case "ai":g("ai");break;case "ai-generate-plan":l?.(),D();break;case "ai-predict-risks":c?.(),D();break;case "ai-usage":p?.(),D();break;case "back":g("home");break;}},[u,b,t,a,r,o,s,l,c,p,D]),A=useCallback(()=>{k&&u.trim()&&(t?.(k,u.trim()),D());},[k,u,t,D]);return d?jsx(at,{children:jsx("div",{className:"command-palette-overlay",onClick:D,children:jsx("div",{className:`command-palette ${m}`,onClick:v=>v.stopPropagation(),children:jsxs(Command,{value:u,onValueChange:x,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:f==="create-card"&&k?"Type card title and press Enter...":f==="create-card"?"Select a column first...":"Type a command or search...",className:"command-palette-input",onKeyDown:v=>{v.key==="Enter"&&f==="create-card"&&k&&A();}}),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."}),f==="home"&&jsxs(Fragment,{children:[jsxs(Command.Group,{heading:"Actions",className:"command-palette-group",children:[jsxs(Command.Item,{value:"create-card",onSelect:N,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:N,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:N,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:N,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(v=>jsxs(Command.Item,{value:`navigate:${v.id}`,onSelect:N,className:"command-palette-item",children:[jsx("div",{className:"command-palette-item-dot",style:{background:v.priority==="URGENT"?"#EF4444":v.priority==="HIGH"?"#F59E0B":v.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:v.title}),v.labels&&v.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:v.labels.slice(0,2).map(F=>jsx("span",{className:"command-palette-item-label",children:F},F))})]},v.id))})]}),f==="create-card"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:N,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(v=>jsxs(Command.Item,{value:`create-card-in:${v.id}`,onSelect:N,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:v.title}),jsxs("div",{className:"command-palette-item-count",children:[v.cardIds.length," cards"]})]},v.id))})]}),f==="navigate"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:N,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(v=>{let F=e.columns.find(T=>T.id===v.columnId);return jsxs(Command.Item,{value:`navigate:${v.id}`,onSelect:N,className:"command-palette-item",keywords:[v.title,v.description||"",...v.labels||[]],children:[jsx("div",{className:"command-palette-item-dot",style:{background:v.priority==="URGENT"?"#EF4444":v.priority==="HIGH"?"#F59E0B":v.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsxs("div",{className:"command-palette-item-content",children:[jsx("div",{children:v.title}),jsx("div",{className:"command-palette-item-meta",children:F?.title})]}),v.labels&&v.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:v.labels.slice(0,2).map(T=>jsx("span",{className:"command-palette-item-label",children:T},T))})]},v.id)})})]}),f==="ai"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:N,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:N,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:N,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:N,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 Ml(e,t,a,r,o){let s=document.getElementById("attachment-lightbox-native");s&&s.remove();let l=document.createElement("div");l.id="attachment-lightbox-native",l.className="attachment-lightbox",l.style.cssText=`
|
|
6
6
|
position: fixed !important;
|
|
7
7
|
inset: 0 !important;
|
|
8
8
|
z-index: 2147483647 !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
|
-
`,u.onmouseenter=()=>{u.style.opacity="1";},u.onmouseleave=()=>{u.style.opacity="0.5";},u.onclick=x=>{x.stopPropagation();let f=r<a.length-1?r+1:0;n(),o(f);},l.appendChild(d),l.appendChild(i),l.appendChild(u);}l.appendChild(c),l.appendChild(p),document.body.appendChild(l),setTimeout(()=>{p.style.transition="opacity 0.5s ease",p.style.opacity="0";},2e3);}function bm(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 ym(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 Qn(e){return e.startsWith("image/")}function $a({attachments:e=[],onUpload:t,onDelete:a,maxSizeMB:r=10,allowedTypes:o,maxFiles:s=10}){let[l,c]=useState(false),[p,n]=useState(false),[m,d]=useState(null),i=useRef(null),u=useRef(e);u.current=e;let x=useCallback((v,B)=>{B.preventDefault(),B.stopPropagation();let T=u.current.filter(P=>Qn(P.type)),w=T.findIndex(P=>P.id===v.id),R=P=>{let H=u.current.filter(he=>Qn(he.type)),q=H[P];q&&Al(q.url,q.name,H,P,R);};Al(v.url,v.name,T,w,R);},[]),f=useCallback(v=>{let B=[],T=[];return e.length+v.length>s?(T.push(`Maximum ${s} files allowed`),{valid:B,errors:T}):(v.forEach(w=>{if(w.size/1048576>r){T.push(`${w.name} is too large (max ${r}MB)`);return}if(o&&!o.some(P=>w.type.match(P))){T.push(`${w.name} has invalid file type`);return}B.push(w);}),{valid:B,errors:T})},[e.length,s,r,o]),g=useCallback(async v=>{let{valid:B,errors:T}=f(v);if(T.length>0){d(T.join(", ")),setTimeout(()=>d(null),5e3);return}if(B.length!==0){n(true),d(null);try{await t?.(B);}catch(w){d(w instanceof Error?w.message:"Upload failed"),setTimeout(()=>d(null),5e3);}finally{n(false);}}},[f,t]),k=useCallback(v=>{v.preventDefault(),v.stopPropagation(),c(true);},[]),h=useCallback(v=>{v.preventDefault(),v.stopPropagation(),c(false);},[]),b=useCallback(v=>{v.preventDefault(),v.stopPropagation();},[]),y=useCallback(v=>{v.preventDefault(),v.stopPropagation(),c(false);let B=Array.from(v.dataTransfer.files);g(B);},[g]),D=useCallback(v=>{let B=v.target.files?Array.from(v.target.files):[];g(B),i.current&&(i.current.value="");},[g]),N=useCallback(()=>{i.current?.click();},[]),A=useCallback(v=>{confirm("Are you sure you want to delete this attachment?")&&a?.(v);},[a]);return jsxs("div",{className:"attachment-uploader",children:[jsxs("div",{className:`attachment-dropzone ${l?"dragging":""} ${p?"uploading":""}`,onDragEnter:k,onDragLeave:h,onDragOver:b,onDrop:y,onClick:N,children:[jsx("input",{ref:i,type:"file",multiple:true,onChange:D,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:l?"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"]})]})})]}),m&&jsxs("div",{className:"attachment-error",children:[jsx("span",{className:"attachment-error-icon",children:"\u26A0\uFE0F"}),jsx("span",{className:"attachment-error-text",children:m})]}),e.length>0&&jsx("div",{className:"attachment-list",children:e.map(v=>jsxs("div",{className:"attachment-item",children:[jsx("div",{className:"attachment-preview",children:Qn(v.type)&&v.url?jsxs("button",{type:"button",className:"attachment-thumbnail-btn",onClick:B=>x(v,B),title:"Click to view full size",children:[jsx("img",{src:v.thumbnailUrl||v.url,alt:v.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:ym(v.type)})}),jsxs("div",{className:"attachment-info",children:[jsx("a",{href:v.url,target:"_blank",rel:"noopener noreferrer",className:"attachment-name",title:v.name,children:v.name}),jsxs("div",{className:"attachment-meta",children:[jsx("span",{className:"attachment-size",children:bm(v.size)}),jsx("span",{className:"attachment-separator",children:"\u2022"}),jsx("span",{className:"attachment-date",children:new Date(v.uploadedAt).toLocaleDateString()})]})]}),jsx("button",{onClick:()=>A(v.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"})})})]},v.id))})]})}function es({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:l=[],activities:c=[],aiInsights:p=[],attachments:n=[],onAddComment:m,onDeleteComment:d,onUploadAttachments:i,onDeleteAttachment:u,onSuggestAssignee:x,onGenerateSubtasks:f,onEstimateEffort:g,currentUserId:k="user-1"}){let[h,b]=useState("details"),[y,D]=useState(false),[N,A]=useState({}),[v,B]=useState(""),[T,w]=useState(false),[R,P]=useState({});if(!t||!e)return null;let H=useCallback(()=>{D(false),A({}),b("details"),B(""),P({}),a();},[a]),q=useCallback(()=>{r&&Object.keys(N).length>0&&(r(e.id,N),A({}),D(false));},[e.id,N,r]),he=useCallback(()=>{o&&window.confirm("Are you sure you want to delete this card?")&&(o(e.id),H());},[e.id,o,H]),xe=useCallback(()=>{m&&v.trim()&&(m(e.id,v.trim()),B(""));},[e.id,v,m]),Ae=useCallback(async()=>{if(x){w(true);try{let E=await x(e);P(K=>({...K,assignees:E}));}catch(E){console.error("Failed to suggest assignee:",E);}finally{w(false);}}},[e,x]),Be=useCallback(async()=>{if(f){w(true);try{let E=await f(e);P(K=>({...K,subtasks:E}));}catch(E){console.error("Failed to generate subtasks:",E);}finally{w(false);}}},[e,f]),$=useCallback(async()=>{if(g){w(true);try{let E=await g(e);P(K=>({...K,effort:E}));}catch(E){console.error("Failed to estimate effort:",E);}finally{w(false);}}},[e,g]),F={...e,...N},W=s.filter(E=>F.assignedUserIds?.includes(E.id));return jsx(rt,{children:jsx("div",{className:"card-detail-overlay",onClick:H,children:jsxs("div",{className:"card-detail-modal",onClick:E=>E.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:F.priority==="URGENT"?"#EF4444":F.priority==="HIGH"?"#F59E0B":F.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),y?jsx("input",{type:"text",value:N.title??F.title,onChange:E=>A({...N,title:E.target.value}),className:"card-detail-title-input",placeholder:"Card title"}):jsx("h2",{className:"card-detail-title",children:F.title})]}),jsxs("div",{className:"card-detail-header-actions",children:[y?jsxs(Fragment,{children:[jsx("button",{onClick:q,className:"card-detail-btn card-detail-btn-primary",children:"Save"}),jsx("button",{onClick:()=>{D(false),A({});},className:"card-detail-btn",children:"Cancel"})]}):jsxs("button",{onClick:()=>D(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:he,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:H,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:()=>b("details"),className:`card-detail-tab ${h==="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:()=>b("comments"),className:`card-detail-tab ${h==="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",l.length>0&&jsx("span",{className:"card-detail-tab-badge",children:l.length})]}),jsxs("button",{onClick:()=>b("activity"),className:`card-detail-tab ${h==="activity"?"active":""}`,children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})}),"Activity",c.length>0&&jsx("span",{className:"card-detail-tab-badge",children:c.length})]}),jsxs("button",{onClick:()=>b("attachments"),className:`card-detail-tab ${h==="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",n.length>0&&jsx("span",{className:"card-detail-tab-badge",children:n.length})]}),jsxs("button",{onClick:()=>b("ai"),className:`card-detail-tab ${h==="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:[h==="details"&&jsxs("div",{className:"card-detail-details",children:[jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Description"}),y?jsx("textarea",{value:N.description??F.description??"",onChange:E=>A({...N,description:E.target.value}),className:"card-detail-textarea",placeholder:"Add a description...",rows:4}):jsx("p",{className:"card-detail-text",children:F.description||"No description"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Assigned To"}),y?jsx("select",{multiple:true,value:N.assignedUserIds??F.assignedUserIds??[],onChange:E=>{let K=Array.from(E.target.selectedOptions,X=>X.value);A({...N,assignedUserIds:K});},className:"card-detail-textarea",style:{height:"120px",padding:"8px 12px"},children:s.map(E=>jsx("option",{value:E.id,children:E.name},E.id))}):jsx("div",{className:"card-detail-users",children:W.length>0?W.map(E=>jsxs("div",{className:"card-detail-user",children:[jsx("div",{className:"card-detail-user-avatar",style:{background:E.color},children:E.initials}),jsx("span",{children:E.name})]},E.id)):jsx("span",{className:"card-detail-empty",children:"Unassigned"})})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Priority"}),y?jsxs("select",{value:N.priority??F.priority??"",onChange:E=>A({...N,priority:E.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:F.priority==="URGENT"?"#EF4444":F.priority==="HIGH"?"#F59E0B":F.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:F.priority||"None"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Labels"}),jsx("div",{className:"card-detail-labels",children:F.labels&&F.labels.length>0?F.labels.map(E=>jsx("span",{className:"card-detail-label-tag",children:E},E)):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"}),y?jsx("input",{type:"date",value:N.startDate?new Date(N.startDate).toISOString().split("T")[0]:F.startDate?new Date(F.startDate).toISOString().split("T")[0]:"",onChange:E=>A({...N,startDate:E.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:F.startDate?new Date(F.startDate).toLocaleDateString():"Not set"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"End Date"}),y?jsx("input",{type:"date",value:N.endDate?new Date(N.endDate).toISOString().split("T")[0]:F.endDate?new Date(F.endDate).toISOString().split("T")[0]:"",onChange:E=>A({...N,endDate:E.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:F.endDate?new Date(F.endDate).toLocaleDateString():"Not set"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Estimated Hours"}),y?jsx("input",{type:"number",min:"0",step:"0.5",value:N.estimatedTime??F.estimatedTime??"",onChange:E=>A({...N,estimatedTime:E.target.value?parseFloat(E.target.value):void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"},placeholder:"Enter hours"}):jsx("span",{className:"card-detail-text",children:F.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:F.dependencies&&F.dependencies.length>0?F.dependencies.map(E=>{let K=typeof E=="string"?E:E.taskId;return jsxs("span",{className:"card-detail-dependency",children:["Card #",K.slice(-4)]},K)}):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:F.createdAt?new Date(F.createdAt).toLocaleString():"Unknown"})]})]}),h==="comments"&&jsxs("div",{className:"card-detail-comments",children:[jsxs("div",{className:"card-detail-comment-form",children:[jsx("textarea",{value:v,onChange:E=>B(E.target.value),className:"card-detail-comment-textarea",placeholder:"Write a comment...",rows:3}),jsx("button",{onClick:xe,disabled:!v.trim(),className:"card-detail-btn card-detail-btn-primary",children:"Add Comment"})]}),jsx("div",{className:"card-detail-comments-list",children:l.length>0?l.map(E=>{let K=s.find(X=>X.id===E.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:[K&&jsx("div",{className:"card-detail-user-avatar",style:{background:K.color},children:K.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-comment-author-name",children:K?.name||"Unknown"}),jsx("div",{className:"card-detail-comment-time",children:new Date(E.createdAt).toLocaleString()})]})]}),d&&jsx("button",{onClick:()=>d(E.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:E.content})]},E.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"})]})})]}),h==="activity"&&jsx("div",{className:"card-detail-activity",children:c.length>0?jsx("div",{className:"card-detail-activity-list",children:c.map(E=>{let K=s.find(X=>X.id===E.userId);return jsxs("div",{className:"card-detail-activity-item",children:[jsxs("div",{className:"card-detail-activity-icon",children:[E.type.includes("CREATED")&&"\u2795",E.type.includes("UPDATED")&&"\u270F\uFE0F",E.type.includes("MOVED")&&"\u27A1\uFE0F",E.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",E.type.includes("COMMENT")&&"\u{1F4AC}",E.type.includes("ASSIGNED")&&"\u{1F464}",E.type.includes("PRIORITY")&&"\u{1F3AF}",E.type.includes("LABEL")&&"\u{1F3F7}\uFE0F",E.type.includes("ATTACHMENT")&&"\u{1F4CE}"]}),jsxs("div",{className:"card-detail-activity-content",children:[jsxs("div",{className:"card-detail-activity-text",children:[jsx("strong",{children:K?.name||"Unknown"})," ",E.type.replace(/_/g," ").toLowerCase(),E.newValue&&jsxs("span",{className:"card-detail-activity-value",children:[" ","to ",jsx("strong",{children:E.newValue})]})]}),jsx("div",{className:"card-detail-activity-time",children:new Date(E.timestamp).toLocaleString()})]})]},E.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"})]})}),h==="attachments"&&jsx("div",{className:"card-detail-attachments",children:jsx($a,{cardId:e.id,attachments:n,onUpload:i?E=>i(e.id,E):void 0,onDelete:u,currentUserId:k,maxSizeMB:10,maxFiles:20})}),h==="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:Ae,disabled:T||!x,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:Be,disabled:T||!f,className:"card-detail-ai-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"8",y1:"6",x2:"21",y2:"6"}),jsx("line",{x1:"8",y1:"12",x2:"21",y2:"12"}),jsx("line",{x1:"8",y1:"18",x2:"21",y2:"18"}),jsx("line",{x1:"3",y1:"6",x2:"3.01",y2:"6"}),jsx("line",{x1:"3",y1:"12",x2:"3.01",y2:"12"}),jsx("line",{x1:"3",y1:"18",x2:"3.01",y2:"18"})]}),"Generate Subtasks"]}),jsxs("button",{onClick:$,disabled:T||!g,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"]})]}),R.assignees&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Assignee Suggestions"}),R.assignees.map((E,K)=>{let X=s.find(U=>U.id===E.userId);return jsxs("div",{className:"card-detail-ai-suggestion",children:[X&&jsx("div",{className:"card-detail-user-avatar",style:{background:X.color},children:X.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-ai-suggestion-name",children:X?.name}),jsx("div",{className:"card-detail-ai-suggestion-reason",children:E.reasoning}),jsxs("div",{className:"card-detail-ai-suggestion-confidence",children:["Confidence: ",(E.confidence*100).toFixed(0),"%"]})]})]},K)})]}),R.subtasks&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Suggested Subtasks"}),R.subtasks.map((E,K)=>jsxs("div",{className:"card-detail-ai-subtask",children:[jsx("div",{className:"card-detail-ai-subtask-title",children:E.title}),E.description&&jsx("div",{className:"card-detail-ai-subtask-desc",children:E.description}),E.estimatedTime&&jsxs("div",{className:"card-detail-ai-subtask-time",children:["Est: ",E.estimatedTime,"h"]})]},K))]}),R.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:[R.effort.hours," hours"]}),jsxs("div",{className:"card-detail-ai-effort-confidence",children:["Confidence: ",(R.effort.confidence*100).toFixed(0),"%"]})]})]}),p.length>0&&jsxs("div",{className:"card-detail-ai-insights",children:[jsx("h4",{children:"AI Insights"}),p.map(E=>jsxs("div",{className:`card-detail-ai-insight card-detail-ai-insight-${E.severity.toLowerCase()}`,children:[jsxs("div",{className:"card-detail-ai-insight-header",children:[jsx("span",{className:"card-detail-ai-insight-title",children:E.title}),jsx("span",{className:"card-detail-ai-insight-severity",children:E.severity})]}),jsx("p",{className:"card-detail-ai-insight-desc",children:E.description}),E.suggestedAction&&jsxs("div",{className:"card-detail-ai-insight-action",children:["\u{1F4A1} ",E.suggestedAction]})]},E.id))]}),!R.assignees&&!R.subtasks&&!R.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 lo({triggerRef:e,isOpen:t,onClose:a,children:r,width:o=200,estimatedHeight:s=300,className:l=""}){let[c,p]=useState({top:0,left:0}),n=useRef(null),m=useCallback(()=>{if(!e.current)return {top:0,left:0};let d=e.current.getBoundingClientRect(),i=window.innerHeight,u=window.innerWidth,x=4,f=d.left;f+o>u-10&&(f=u-o-10),f<10&&(f=10);let g=i-d.bottom,k=d.top,h;return g>=s+x?h=d.bottom+x:k>=s+x?h=d.top-s-x:g>=k?h=d.bottom+x:h=Math.max(10,d.top-s-x),{top:h,left:f}},[e,o,s]);return useEffect(()=>{t&&p(m());},[t,m]),useEffect(()=>{if(!t)return;let d=u=>{let x=u.target;n.current&&!n.current.contains(x)&&e.current&&!e.current.contains(x)&&a();},i=setTimeout(()=>{document.addEventListener("mousedown",d);},0);return ()=>{clearTimeout(i),document.removeEventListener("mousedown",d);}},[t,a,e]),useEffect(()=>{if(!t)return;let d=i=>{i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),a());};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,a]),t?jsx(rt,{children:jsx("div",{ref:n,className:`smart-popover ${l}`,style:{position:"fixed",top:`${c.top}px`,left:`${c.left}px`,width:`${o}px`,maxHeight:"calc(100vh - 40px)",overflowY:"auto",zIndex:99999,padding:"6px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",borderRadius:"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",animation:"popoverSlideIn 100ms ease-out"},children:r})}):null}var Wo=["#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#22C55E","#10B981","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899"];function Wr({selectedTags:e,availableTags:t,onChange:a,onCreateTag:r,theme:o,disabled:s=false,compact:l=true}){let[c,p]=useState(false),[n,m]=useState(""),[d,i]=useState(false),[u,x]=useState(Wo[10]||"#3B82F6"),[f,g]=useState({top:0,left:0}),k=useRef(null),h=useRef(null),b=useRef(null),y=useRef(null),D=t.filter(w=>w.name.toLowerCase().includes(n.toLowerCase())),N=t.some(w=>w.name.toLowerCase()===n.toLowerCase());useEffect(()=>{if(c&&h.current){let w=h.current.getBoundingClientRect();g({top:w.bottom+6,left:w.left});}},[c]),useEffect(()=>{let w=R=>{let P=R.target,H=k.current?.contains(P),q=b.current?.contains(P);!H&&!q&&(p(false),m(""),i(false));};if(c)return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[c]),useEffect(()=>{c&&y.current&&y.current.focus();},[c]);let A=w=>{let R=e.some(P=>P.id===w.id);a(R?e.filter(P=>P.id!==w.id):[...e,w]);},v=async()=>{if(!(!r||!n.trim())){i(true);try{let w=await r(n.trim(),u);w&&(a([...e,w]),m(""),x(Wo[Math.floor(Math.random()*Wo.length)]||"#3B82F6"));}finally{i(false);}}},B=(w,R)=>{R.stopPropagation(),a(e.filter(P=>P.id!==w));},T={backgroundColor:`${o.textTertiary}15`,border:`1px solid ${o.borderLight}`,color:o.textSecondary};return jsxs("div",{ref:k,className:"relative",children:[jsxs("button",{ref:h,type:"button",onClick:()=>!s&&p(!c),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:T,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(w=>jsx("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",style:{backgroundColor:`${w.color}20`,color:w.color},children:w.name},w.id)),e.length>2&&jsxs("span",{className:"text-xs",style:{color:o.textTertiary},children:["+",e.length-2]})]}):jsx("span",{children:"Etiquetas"}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:o.textTertiary}})]}),typeof document<"u"&&createPortal(jsx(AnimatePresence,{children:c&&jsxs(motion.div,{ref:b,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:f.top,left:f.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:y,type:"text",value:n,onChange:w=>m(w.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:w=>{w.key==="Enter"&&n.trim()&&!N&&r&&v();}})}),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(w=>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:`${w.color}20`,color:w.color},onClick:R=>B(w.id,R),children:[w.name,jsx(X,{className:"w-3 h-3"})]},w.id))})]}),jsx("div",{className:"max-h-[200px] overflow-y-auto p-1",children:D.length>0?D.map(w=>{let R=e.some(P=>P.id===w.id);return jsxs("button",{type:"button",onClick:()=>A(w),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors",style:{backgroundColor:R?`${w.color}15`:"transparent",color:o.textPrimary},onMouseEnter:P=>{R||(P.currentTarget.style.backgroundColor=o.hoverBg);},onMouseLeave:P=>{R||(P.currentTarget.style.backgroundColor="transparent");},children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:w.color}}),jsx("span",{className:"flex-1 text-left",children:w.name}),R&&jsx(Check,{className:"w-4 h-4",style:{color:w.color}})]},w.id)}):n.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"})}),n.trim()&&!N&&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:Wo.map(w=>jsx("button",{type:"button",onClick:()=>x(w),className:"w-5 h-5 rounded-full transition-transform hover:scale-110",style:{backgroundColor:w,outline:u===w?`2px solid ${w}`:"none",outlineOffset:"2px"}},w))}),jsxs("button",{type:"button",onClick:v,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:u,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 "',n.trim(),'"']})]})]})}),document.body)]})}function rs({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 Bl({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(rs,{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 _e={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 Lm=["LOW","MEDIUM","HIGH","URGENT"],Fm=["todo","in-progress","review","done"];function ns({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:l=[],activities:c=[],onAddComment:p,onDeleteComment:n,currentUser:m,onAIGenerateDescription:d,onAICreateSubtasks:i,onAIFindSimilar:u,availableColumns:x=[],availableLabels:f=[],availableTags:g=[],onCreateTag:k,onUploadCoverImage:h,unsplashAccessKey:b,theme:y,onSubtasksChange:D,attachments:N=[],onUploadAttachments:A,onDeleteAttachment:v}){let B=Br(),T=y||B?.themeName||"dark",[w,R]=useState(e),[P,H]=useState(false),[q,he]=useState(e?.subtasks||[]),[xe,Ae]=useState(false),[Be,$]=useState(""),[F,W]=useState(""),[E,K]=useState("all"),[X,U]=useState(false),[De,ke]=useState(false),[$e,be]=useState(false),[tt,Pe]=useState(false),[et,ht]=useState(false),[Dt,dt]=useState(false),O=useRef(null),re=useRef(null),de=useRef(null),Ce=useRef(null),Ee=useRef(null),at=useRef(null),ut=useRef(null),Ie=useRef(null),I=useRef(null),Y=useRef(null),He=useRef(null),We=useRef(null);useEffect(()=>{e&&!w?(R({...e}),he(e.subtasks||[])):e&&w&&e.id!==w.id&&(R({...e}),he(e.subtasks||[]));},[e,w]),useEffect(()=>{let z=ne=>{let Ge=ne.target;Ce.current&&!Ce.current.contains(Ge)&&U(false),Ee.current&&!Ee.current.contains(Ge)&&ke(false),at.current&&!at.current.contains(Ge)&&be(false),ut.current&&!ut.current.contains(Ge)&&Pe(false);};if(X||De||$e||tt)return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[X,De,$e,tt]),useEffect(()=>{if(!t)return;let z=ne=>{let Ge=ne.target,Ke=Ge.tagName==="INPUT"||Ge.tagName==="TEXTAREA"||Ge.isContentEditable;if(ne.key==="Escape"){ne.preventDefault(),X||De||$e||tt||et||Dt?(U(false),ke(false),be(false),Pe(false),ht(false),dt(false)):Ke||a();return}if(Ke&&ne.key!=="Escape")return;let aa=ne.metaKey||ne.ctrlKey;switch(ne.key.toLowerCase()){case "s":ne.preventDefault(),U(true);break;case "a":ne.preventDefault(),be(true);break;case "p":ne.preventDefault(),ke(true);break;case "l":ne.preventDefault(),Pe(true);break;case "d":aa||(ne.preventDefault(),ht(true),setTimeout(()=>Ie.current?.focus(),0));break;case "e":aa||(ne.preventDefault(),dt(true));break;case "i":ne.preventDefault(),H(true),setTimeout(()=>re.current?.focus(),0);break;case "t":ne.preventDefault(),Ae(true);break;case "c":ne.preventDefault(),de.current?.focus();break}};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[t,a,X,De,$e,tt,et,Dt]);let yt=useCallback(z=>{let ne=z.currentTarget.textContent?.trim()||"";if(w&&ne!==w.title){let Ge={...w,title:ne};R(Ge),r?.(w.id,{title:ne});}},[w,r]),Q=useCallback(z=>{z.key==="Enter"&&(z.preventDefault(),z.currentTarget.blur()),z.key==="Escape"&&(z.preventDefault(),z.currentTarget.textContent=w?.title||"",z.currentTarget.blur());},[w]),te=useCallback(()=>{w&&e&&w.description!==e.description&&r?.(w.id,{description:w.description}),H(false);},[w,e,r]),ve=useCallback(z=>{if(w){let ne={...w,columnId:z};R(ne),r?.(w.id,{columnId:z}),U(false);}},[w,r]),Te=useCallback(z=>{if(w){let ne={...w,priority:z};R(ne),r?.(w.id,{priority:z}),ke(false);}},[w,r]),oe=useCallback(z=>{if(w){let ne=w.assignedUserIds||[],Ge=ne.includes(z)?ne.filter(aa=>aa!==z):[...ne,z],Ke={...w,assignedUserIds:Ge};R(Ke),r?.(w.id,{assignedUserIds:Ge});}},[w,r]),Se=useCallback(z=>{if(w){let ne=w.labels||[],Ge=ne.includes(z)?ne.filter(aa=>aa!==z):[...ne,z],Ke={...w,labels:Ge};R(Ke),r?.(w.id,{labels:Ge});}},[w,r]),ye=useCallback(z=>{if(w){let ne={...w,tags:z};R(ne),r?.(w.id,{tags:z});}},[w,r]),Ne=useCallback(z=>{if(w){let ne=z.target.value,Ge={...w,endDate:ne};R(Ge),r?.(w.id,{endDate:ne}),ht(false);}},[w,r]),ie=useCallback(z=>{if(w){let ne={...w,estimatedTime:parseFloat(z)||0};R(ne),r?.(w.id,{estimatedTime:parseFloat(z)||0});}},[w,r]),Fe=useCallback(()=>{if(Be.trim()&&w){let z={id:`subtask-${Date.now()}`,title:Be.trim(),completed:false,createdAt:new Date},ne=[...q,z];he(ne),$(""),Ae(false),D?.(w.id,ne);}},[Be,q,w,D]),Me=useCallback(z=>{let ne=q.map(Ge=>Ge.id===z?{...Ge,completed:!Ge.completed,updatedAt:new Date}:Ge);he(ne),w&&D?.(w.id,ne);},[q,w,D]),Re=useCallback(z=>{let ne=q.filter(Ge=>Ge.id!==z);he(ne),w&&D?.(w.id,ne);},[q,w,D]),Mt=useCallback(()=>{F.trim()&&w&&p&&(p(w.id,F.trim()),W(""));},[F,w,p]),V=useCallback(z=>{(z.metaKey||z.ctrlKey)&&z.key==="Enter"&&(z.preventDefault(),Mt());},[Mt]),Z=z=>jsx(Mm,{remarkPlugins:[Am],rehypePlugins:[Im],components:{a:({node:ne,...Ge})=>jsx("a",{...Ge,target:"_blank",rel:"noopener noreferrer"})},children:z}),nt=c.filter(z=>E==="comments"?z.type.includes("COMMENT"):E==="history"?!z.type.includes("COMMENT"):true);if(!t||!e)return null;let fe=w||e,Ue=s.filter(z=>fe.assignedUserIds?.includes(z.id)),Je=q.filter(z=>z.completed).length;return jsx(rt,{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:z=>z.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"modal-title","data-theme":T,children:[jsxs("header",{className:"modal-v2-header",children:[jsx("h1",{id:"modal-title",ref:O,className:"modal-v2-title",contentEditable:true,suppressContentEditableWarning:true,onBlur:yt,onKeyDown:Q,children:fe.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:Ce,children:[jsxs("button",{ref:I,className:"modal-v2-field",onClick:()=>U(!X),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:fe.columnId||"No status"})]}),jsx(lo,{triggerRef:I,isOpen:X,onClose:()=>U(false),width:250,estimatedHeight:200,children:(x.length>0?x:Fm.map(z=>({id:z,title:z}))).map(z=>jsx("button",{className:`modal-v2-popover-item ${fe.columnId===z.id?"active":""}`,onClick:()=>ve(z.id),children:z.title},z.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:at,children:[jsxs("button",{ref:Y,className:"modal-v2-field",onClick:()=>be(!$e),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:Ue.length>0?jsx("div",{className:"modal-v2-avatars",children:Ue.map(z=>jsx("div",{className:"modal-v2-avatar",style:{background:z.color},title:z.name,children:z.initials},z.id))}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(lo,{triggerRef:Y,isOpen:$e,onClose:()=>be(false),width:280,estimatedHeight:300,children:s.map(z=>jsxs("button",{className:`modal-v2-popover-item ${fe.assignedUserIds?.includes(z.id)?"active":""}`,onClick:()=>oe(z.id),children:[jsx("div",{className:"modal-v2-avatar-small",style:{background:z.color},children:z.initials}),z.name,fe.assignedUserIds?.includes(z.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"})})]},z.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:Ee,children:[jsxs("button",{ref:He,className:"modal-v2-field",onClick:()=>ke(!De),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),jsx("span",{children:"Priority"}),jsx("kbd",{className:"modal-v2-shortcut",children:"P"})]}),jsx("div",{className:"modal-v2-field-value",children:fe.priority||"None"})]}),jsxs(lo,{triggerRef:He,isOpen:De,onClose:()=>ke(false),width:180,estimatedHeight:220,children:[Lm.map(z=>jsx("button",{className:`modal-v2-popover-item priority-${z.toLowerCase()} ${fe.priority===z?"active":""}`,onClick:()=>Te(z),children:z},z)),jsx("button",{className:"modal-v2-popover-item",onClick:()=>Te(""),children:"None"})]})]}),g.length>0||k?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(Wr,{selectedTags:fe.tags||[],availableTags:g,onChange:ye,onCreateTag:k,theme:_e[T]||_e.dark})})]})}):jsxs("div",{className:"modal-v2-field-wrapper",ref:ut,children:[jsxs("button",{ref:We,className:"modal-v2-field",onClick:()=>Pe(!tt),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:fe.labels&&fe.labels.length>0?jsx("span",{children:fe.labels.join(", ")}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(lo,{triggerRef:We,isOpen:tt,onClose:()=>Pe(false),width:220,estimatedHeight:200,children:(f.length>0?f:["Bug","Feature","Enhancement","Documentation"]).map(z=>jsxs("button",{className:`modal-v2-popover-item ${fe.labels?.includes(z)?"active":""}`,onClick:()=>Se(z),children:[z,fe.labels?.includes(z)&&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"})})]},z))})]}),jsxs("button",{className:"modal-v2-field",onClick:()=>{ht(!et),setTimeout(()=>Ie.current?.showPicker?.(),0);},children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),jsx("span",{children:"Due Date"}),jsx("kbd",{className:"modal-v2-shortcut",children:"D"})]}),jsx("div",{className:"modal-v2-field-value",children:fe.endDate?new Date(fe.endDate).toLocaleDateString():"Not set"}),jsx("input",{ref:Ie,type:"date",value:typeof fe.endDate=="string"?fe.endDate.split("T")[0]:fe.endDate?(()=>{let z=new Date(fe.endDate),ne=z.getUTCFullYear(),Ge=String(z.getUTCMonth()+1).padStart(2,"0"),Ke=String(z.getUTCDate()).padStart(2,"0");return `${ne}-${Ge}-${Ke}`})():"",onChange:Ne,style:{position:"absolute",opacity:0,pointerEvents:"none"}})]}),jsxs("div",{className:"modal-v2-field-wrapper",children:[jsxs("button",{className:"modal-v2-field",onClick:()=>dt(!Dt),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:fe.estimatedTime?`${fe.estimatedTime}h`:"Not set"})]}),Dt&&jsx("div",{className:"modal-v2-popover",children:jsx("input",{type:"number",min:"0",step:"0.5",placeholder:"Hours",value:fe.estimatedTime||"",onChange:z=>ie(z.target.value),className:"modal-v2-time-input",autoFocus:true,onBlur:()=>dt(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"})]}),P?jsx("textarea",{className:"modal-v2-textarea",value:fe.description||"",onChange:z=>{if(w){let ne={...w,description:z.target.value};R(ne);}},onBlur:te,placeholder:"Add a detailed description...",autoFocus:true}):jsx("div",{className:"modal-v2-content",onClick:()=>H(true),children:fe.description?jsx("div",{className:"modal-v2-markdown",children:Z(fe.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:[Je,"/",q.length]}),jsxs("button",{className:"modal-v2-add-button",onClick:()=>Ae(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(z=>jsxs("div",{className:`modal-v2-subtask ${z.completed?"completed":""}`,children:[jsx("button",{className:"modal-v2-subtask-checkbox",onClick:()=>Me(z.id),children:z.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:z.title}),jsx("button",{className:"modal-v2-subtask-delete",onClick:()=>Re(z.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"})]})})]},z.id)),xe&&jsx("div",{className:"modal-v2-subtask-input-row",children:jsx("input",{type:"text",placeholder:"Subtask title...",value:Be,onChange:z=>$(z.target.value),onKeyDown:z=>{z.key==="Enter"&&Fe(),z.key==="Escape"&&(Ae(false),$(""));},onBlur:Fe,autoFocus:true,className:"modal-v2-subtask-input"})})]})]}),(A||N.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"}),N.length>0&&jsx("span",{className:"modal-v2-count",children:N.length})]}),jsx($a,{cardId:fe.id,attachments:N,onUpload:A?z=>A(fe.id,z):void 0,onDelete:v,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 ${E==="all"?"active":""}`,onClick:()=>K("all"),children:"All"}),jsx("button",{className:`modal-v2-filter ${E==="comments"?"active":""}`,onClick:()=>K("comments"),children:"Comments"}),jsx("button",{className:`modal-v2-filter ${E==="history"?"active":""}`,onClick:()=>K("history"),children:"History"})]})]}),jsxs("div",{className:"modal-v2-comment-input",children:[m&&jsx("div",{className:"modal-v2-avatar",style:{background:m.color},children:m.initials}),jsxs("div",{className:"modal-v2-comment-wrapper",children:[jsx("textarea",{ref:de,className:"modal-v2-comment-textarea",placeholder:"Write a comment...",value:F,onChange:z=>W(z.target.value),onKeyDown:V,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:Mt,disabled:!F.trim(),children:"Send"})]})]})]}),jsxs("div",{className:"modal-v2-timeline",children:[nt.map(z=>{let ne=s.find(Ke=>Ke.id===z.userId);if(z.type.includes("COMMENT")){let Ke=l.find(aa=>aa.id===z.metadata?.commentId);return Ke?jsxs("div",{className:"modal-v2-activity-item comment-item",children:[ne&&jsx("div",{className:"modal-v2-avatar",style:{background:ne.color},children:ne.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:ne?.name||"Unknown"}),jsx("span",{className:"modal-v2-activity-time",children:new Date(z.timestamp).toLocaleString()})]}),jsx("div",{className:"modal-v2-comment-body",children:Ke.content})]})]},z.id):null}return jsxs("div",{className:"modal-v2-activity-item history-item",children:[jsxs("div",{className:"modal-v2-history-icon",children:[z.type.includes("CREATED")&&"\u2795",z.type.includes("UPDATED")&&"\u270F\uFE0F",z.type.includes("MOVED")&&"\u27A1\uFE0F",z.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",z.type.includes("ASSIGNED")&&"\u{1F464}",z.type.includes("PRIORITY")&&"\u{1F3AF}",z.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:ne?.name||"Unknown"})," ",z.type.replace(/_/g," ").toLowerCase(),z.newValue&&jsxs(Fragment,{children:[" to ",jsx("strong",{children:z.newValue})]})]}),jsx("span",{className:"modal-v2-activity-time",children:new Date(z.timestamp).toLocaleString()})]})]},z.id)}),nt.length===0&&jsxs("div",{className:"modal-v2-empty",children:[jsx("p",{children:"No activity yet"}),jsx("span",{children:"Activity will appear here"})]})]})]})]})})})}function Gm({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 is({data:e,title:t="Team Velocity",height:a=300,showAverage:r=true,showPlanned:o=true}){let s=e.map(l=>({...l,average:l.average??e.reduce((c,p)=>c+p.completed,0)/e.length}));return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:a,children:jsxs(LineChart,{data:s,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"period",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(Gm,{})}),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((l,c)=>l+c.completed,0)})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Average Velocity"}),jsx("span",{className:"chart-stat-value",style:{color:"#F59E0B"},children:(e.reduce((l,c)=>l+c.completed,0)/e.length).toFixed(1)})]}),o&&e.some(l=>l.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((l,c)=>l+(c.planned||0),0)})]})]})]})}function Zm({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 ls({data:e,title:t="Sprint Burndown",height:a=300,totalTasks:r,useArea:o=false}){let s=r??(e[0]?.ideal||e[0]?.remaining||0),l=e[e.length-1]?.remaining||0,c=e[e.length-1]?.ideal||0,p=s>0?(s-l)/s*100:0,n=l<=c;return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:a,children:jsxs(o?AreaChart:LineChart,{data:e,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"day",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(Zm,{})}),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:n?"#10B981":"#EF4444",fill:n?"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:n?"#10B981":"#EF4444",strokeWidth:3,name:"Remaining",dot:{fill:n?"#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:n?"#10B981":"#EF4444"},children:l})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Status"}),jsx("span",{className:"chart-stat-badge",style:{background:n?"rgba(16, 185, 129, 0.15)":"rgba(239, 68, 68, 0.15)",color:n?"#10B981":"#EF4444"},children:n?"\u2713 On Track":"\u26A0 Behind"})]})]})]})}var iu={URGENT:"#EF4444",HIGH:"#F59E0B",MEDIUM:"#3B82F6",LOW:"#10B981"},Hl=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899"];function lu({cx:e,cy:t,midAngle:a,innerRadius:r,outerRadius:o,percent:s}){let l=r+(o-r)*.5,c=e+l*Math.cos(-a*(Math.PI/180)),p=t+l*Math.sin(-a*(Math.PI/180));return s<.05?null:jsx("text",{x:c,y:p,fill:"white",textAnchor:c>e?"start":"end",dominantBaseline:"central",style:{fontSize:"12px",fontWeight:600},children:`${(s*100).toFixed(0)}%`})}function Gl({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 ds({data:e,title:t="Distribution",type:a="pie",height:r=300,showPercentages:o=true}){let s=e.reduce((p,n)=>p+n.value,0),l=e.map(p=>({...p,totalValue:s,color:p.color||iu[p.name]||Hl[e.indexOf(p)%Hl.length]})),c=l.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:l,cx:"50%",cy:"50%",labelLine:false,label:o?lu:false,outerRadius:r*.35,fill:"#8884d8",dataKey:"value",children:l.map((p,n)=>jsx(Cell,{fill:c[n]},`cell-${n}`))}),jsx(Tooltip,{content:jsx(Gl,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"},formatter:(p,n)=>{let m=n.payload,d=s>0?(m.value/s*100).toFixed(0):"0";return `${p} (${m.value} - ${d}%)`}})]}):jsxs(BarChart,{data:l,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(Gl,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),jsx(Bar,{dataKey:"value",name:"Count",radius:[8,8,0,0],children:l.map((p,n)=>jsx(Cell,{fill:c[n]},`cell-${n}`))})]})}),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,n)=>n.value>p.value?n:p).name})]})]})]})}var Go=memo(({selectedCards:e,availableUsers:t=[],onClearSelection:a,callbacks:r,columns:o=[],availableLabels:s=[]})=>{let[l,c]=useState(false),[p,n]=useState(false),[m,d]=useState(false),[i,u]=useState(false);if(e.length===0)return null;let x=e.map(y=>y.id),f=y=>{r.onBulkUpdate?.(x,{priority:y}),c(false);},g=y=>{r.onBulkMove?.(x,y),n(false),a();},k=y=>{r.onBulkUpdate?.(x,{assignedUserIds:y}),d(false);},h=y=>{let D=new Set;e.forEach(A=>{A.labels?.forEach(v=>D.add(v));});let N=Array.from(new Set([...D,...y]));r.onBulkUpdate?.(x,{labels:N}),u(false);},b=()=>{confirm(`Delete ${e.length} card(s)? This cannot be undone.`)&&(r.onBulkDelete?.(x),a());};return jsx("div",{className:"asakaa-bulk-toolbar",children:jsxs("div",{className:"asakaa-bulk-toolbar-content",children:[jsxs("div",{className:"asakaa-bulk-toolbar-count",children:[e.length," card",e.length!==1?"s":""," selected"]}),jsxs("div",{className:"asakaa-bulk-toolbar-actions",children:[jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>c(!l),title:"Update priority",children:jsx("span",{className:"text-sm",children:"Priority"})}),l&&jsx("div",{className:"asakaa-bulk-menu",children:["LOW","MEDIUM","HIGH","URGENT"].map(y=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>f(y),children:[jsx("span",{className:C("asakaa-priority-dot",y==="LOW"&&"bg-asakaa-priority-low",y==="MEDIUM"&&"bg-asakaa-priority-medium",y==="HIGH"&&"bg-asakaa-priority-high",y==="URGENT"&&"bg-asakaa-priority-urgent")}),y]},y))})]}),o.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>n(!p),title:"Move to column",children:jsx("span",{className:"text-sm",children:"Move"})}),p&&jsx("div",{className:"asakaa-bulk-menu",children:o.map(y=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>g(y.id),children:y.title},y.id))})]}),t.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>d(!m),title:"Assign users",children:jsx("span",{className:"text-sm",children:"Assign"})}),m&&jsx("div",{className:"asakaa-bulk-menu",children:t.map(y=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>k([y.id]),children:[jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs font-medium",style:{backgroundColor:y.color},children:y.initials}),y.name]},y.id))})]}),s.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>u(!i),title:"Add labels",children:jsx("span",{className:"text-sm",children:"Labels"})}),i&&jsx("div",{className:"asakaa-bulk-menu",children:s.map(y=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>h([y]),children:y},y))})]}),jsx("button",{className:"asakaa-bulk-toolbar-button asakaa-bulk-toolbar-button-danger",onClick:b,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"})})]})]})})});Go.displayName="BulkOperationsToolbar";function uu(e,t,a){if(t==="none")return [];let r=new Map;return e.forEach(o=>{let s,l,c,p,n;switch(t){case "assignee":let m=o.assignedUserIds||(o.assigneeId?[o.assigneeId]:[]);m.length>0?m.forEach(u=>{let x=a?.find(f=>f.id===u);l=`assignee-${u}`,c=x?.name||`User ${u}`,p=x?.color,n=x?.avatar,r.has(l)||r.set(l,{id:l,title:c,groupValue:u,cardIds:[],color:p,icon:n}),r.get(l).cardIds.push(o.id);}):(l="assignee-unassigned",c="Unassigned",p="#6b7280",n="\u{1F464}",r.has(l)||r.set(l,{id:l,title:c,groupValue:null,cardIds:[],color:p,icon:n}),r.get(l).cardIds.push(o.id));break;case "priority":s=o.priority||"NONE",l=`priority-${s}`;let i={URGENT:{title:"\u{1F534} Urgent",color:"#ef4444"},HIGH:{title:"\u{1F7E0} High",color:"#f97316"},MEDIUM:{title:"\u{1F7E1} Medium",color:"#eab308"},LOW:{title:"\u{1F7E2} Low",color:"#22c55e"},NONE:{title:"\u26AA No Priority",color:"#6b7280"}}[s];c=i.title,p=i.color,r.has(l)||r.set(l,{id:l,title:c,groupValue:s,cardIds:[],color:p}),r.get(l).cardIds.push(o.id);break;case "label":o.labels&&o.labels.length>0?o.labels.forEach(u=>{l=`label-${u}`,c=u,p="#6b7280",r.has(l)||r.set(l,{id:l,title:c,groupValue:u,cardIds:[],color:p}),r.get(l).cardIds.push(o.id);}):(l="label-none",c="No Labels",p="#6b7280",r.has(l)||r.set(l,{id:l,title:c,groupValue:null,cardIds:[],color:p}),r.get(l).cardIds.push(o.id));break}}),Array.from(r.values()).sort((o,s)=>o.title.localeCompare(s.title))}function cs({board:e,swimlaneConfig:t,availableUsers:a,callbacks:r,className:o}){let[s,l]=useState(new Set),c=useMemo(()=>uu(e.cards,t.groupBy,a),[e.cards,t.groupBy,a]),p=useCallback(n=>{l(m=>{let d=new Set(m);return d.has(n)?d.delete(n):d.add(n),d});},[]);return t.groupBy==="none"||c.length===0?jsx(Qa,{board:e,callbacks:r,availableUsers:a,className:o}):jsxs("div",{className:C("asakaa-swimlane-view",o),children:[c.map(n=>{let m=s.has(n.id),d=e.cards.filter(u=>n.cardIds.includes(u.id)),i={...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(n.id),style:{borderLeft:n.color?`4px solid ${n.color}`:void 0},children:[jsxs("div",{className:"flex items-center gap-3",children:[n.icon&&jsx("span",{className:"text-2xl leading-none",children:n.icon}),jsx("h3",{className:"text-lg font-semibold",style:{color:n.color},children:n.title}),jsxs("span",{className:"text-sm text-white/50 font-medium",children:["(",n.cardIds.length," ",n.cardIds.length===1?"card":"cards",")"]})]}),t.collapsible&&jsx("button",{className:"text-white/50 hover:text-white transition-colors","aria-label":m?"Expand lane":"Collapse lane",children:m?"\u25B6":"\u25BC"})]}),!m&&jsx("div",{className:"asakaa-swimlane-content p-4",children:jsx(Qa,{board:i,callbacks:r,availableUsers:a})})]},n.id)}),c.length===0&&jsxs("div",{className:"text-center py-12 text-white/50",children:[jsx("p",{className:"text-lg",children:"No cards to display"}),jsx("p",{className:"text-sm mt-2",children:"Cards will appear here when they match the grouping criteria"})]})]})}var ps=[{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 ms({value:e,onChange:t,className:a}){let[r,o]=useState(false),s=useRef(null),l=useRef(null),c=ps.find(n=>n.value===e)||ps[0];useEffect(()=>{function n(m){s.current&&!s.current.contains(m.target)&&l.current&&!l.current.contains(m.target)&&o(false);}if(r)return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let p=n=>{t(n),o(false);};return jsxs("div",{className:C("relative inline-block",a),children:[jsxs("button",{ref:l,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-white/10 hover:bg-white/15 border border-white/20 transition-all text-sm font-medium text-white/90",children:[jsx("span",{className:"text-base leading-none",children:c.icon}),jsx("span",{children:c.label}),jsx("svg",{className:C("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:ps.map(n=>jsxs("button",{onClick:()=>p(n.value),className:C("w-full px-3 py-2 flex items-start gap-3 text-left transition-all hover:bg-white/10",e===n.value&&"bg-white/5"),children:[jsx("span",{className:"text-xl leading-none mt-0.5",children:n.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:n.label}),e===n.value&&jsx("span",{className:"text-blue-400 text-xs",children:"\u2713"})]}),jsx("p",{className:"text-xs text-white/60 mt-0.5",children:n.description})]})]},n.value))})]})]})}var po=[{keys:"ArrowUp",action:"navigate_up",description:"Navigate to card above"},{keys:"ArrowDown",action:"navigate_down",description:"Navigate to card below"},{keys:"ArrowLeft",action:"navigate_left",description:"Navigate to previous column"},{keys:"ArrowRight",action:"navigate_right",description:"Navigate to next column"},{keys:"Enter",action:"open_card",description:"Open selected card"},{keys:"Escape",action:"close_modal",description:"Close modal or dialog"},{keys:"Delete",action:"delete_card",description:"Delete selected card",modifiers:{shift:true}},{keys:"n",action:"new_card",description:"Create new card",modifiers:{ctrl:true}},{keys:"k",action:"search",description:"Open search/command palette",modifiers:{ctrl:true}},{keys:"s",action:"save",description:"Save changes",modifiers:{ctrl:true}},{keys:"z",action:"undo",description:"Undo last action",modifiers:{ctrl:true}},{keys:"y",action:"redo",description:"Redo last undone action",modifiers:{ctrl:true}},{keys:"a",action:"select_all",description:"Select all cards",modifiers:{ctrl:true}},{keys:"Escape",action:"deselect_all",description:"Deselect all cards"},{keys:"?",action:"show_shortcuts",description:"Show keyboard shortcuts help",modifiers:{shift:true}}];function hu(e,t){if(!(Array.isArray(t.keys)?t.keys:[t.keys]).some(n=>e.key===n||e.code===n))return false;let o=t.modifiers||{},s=o.ctrl?e.ctrlKey||e.metaKey:!e.ctrlKey&&!e.metaKey,l=o.shift?e.shiftKey:!e.shiftKey,c=o.alt?e.altKey:!e.altKey,p=o.meta?e.metaKey:true;return s&&l&&c&&p}function Yl(e={}){let{shortcuts:t=po,enabled:a=true,preventDefault:r=true}=e,o=useRef(t),s=useRef(a);useEffect(()=>{o.current=t,s.current=a;},[t,a]);let l=useCallback(p=>{o.current=[...o.current,p];},[]),c=useCallback(p=>{o.current=o.current.filter(n=>n.action!==p);},[]);return useEffect(()=>{function p(n){if(!s.current)return;let m=n.target;if(!((m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.isContentEditable)&&n.key!=="Escape"&&!n.ctrlKey&&!n.metaKey)){for(let d of o.current)if(hu(n,d)){r&&n.preventDefault();let i=new CustomEvent("keyboard-action",{detail:d.action,bubbles:true,cancelable:true});window.dispatchEvent(i);break}}}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r]),{registerShortcut:l,unregisterShortcut:c,isEnabled:a}}function yu(e){return {ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192",Enter:"\u21B5",Escape:"Esc",Delete:"Del"," ":"Space"}[e]||e.toUpperCase()}function vu(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 xu(e){let t=Array.isArray(e.keys)?e.keys[0]:e.keys,a=vu(e),r=t?yu(t):"";return a?`${a} + ${r}`:r}function ku(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 us({shortcuts:e=po,isOpen:t,onClose:a,className:r}){let[o,s]=useState(false);if(useEffect(()=>{s(true);},[]),useEffect(()=>{function c(p){p.key==="Escape"&&t&&a();}if(t)return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t,a]),!o||!t)return null;let l=ku(e);return jsxs("div",{className:C("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(l).map(([c,p])=>p.length===0?null:jsxs("div",{children:[jsxs("h3",{className:"text-lg font-semibold text-white/90 mb-4 flex items-center gap-2",children:[jsx("span",{className:"w-1 h-5 bg-blue-500 rounded-full"}),c]}),jsx("div",{className:"space-y-3",children:p.map(n=>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:n.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:xu(n)})]},n.action))})]},c))})}),jsx("div",{className:"px-6 py-4 border-t border-white/10 bg-white/5",children:jsxs("p",{className:"text-xs text-white/50 text-center",children:["Press ",jsx("kbd",{className:"px-2 py-0.5 bg-white/10 rounded text-white/70",children:"?"})," to toggle this help panel"]})})]})]})}var 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
|
+
`,u.onmouseenter=()=>{u.style.opacity="1";},u.onmouseleave=()=>{u.style.opacity="0.5";},u.onclick=x=>{x.stopPropagation();let f=r<a.length-1?r+1:0;n(),o(f);},l.appendChild(d),l.appendChild(i),l.appendChild(u);}l.appendChild(c),l.appendChild(p),document.body.appendChild(l),setTimeout(()=>{p.style.transition="opacity 0.5s ease",p.style.opacity="0";},2e3);}function xm(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 km(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 qn(e){return e.startsWith("image/")}function Ua({attachments:e=[],onUpload:t,onDelete:a,maxSizeMB:r=10,allowedTypes:o,maxFiles:s=10}){let[l,c]=useState(false),[p,n]=useState(false),[m,d]=useState(null),i=useRef(null),u=useRef(e);u.current=e;let x=useCallback((v,F)=>{F.preventDefault(),F.stopPropagation();let T=u.current.filter(P=>qn(P.type)),w=T.findIndex(P=>P.id===v.id),B=P=>{let H=u.current.filter(fe=>qn(fe.type)),X=H[P];X&&Ml(X.url,X.name,H,P,B);};Ml(v.url,v.name,T,w,B);},[]),f=useCallback(v=>{let F=[],T=[];return e.length+v.length>s?(T.push(`Maximum ${s} files allowed`),{valid:F,errors:T}):(v.forEach(w=>{if(w.size/1048576>r){T.push(`${w.name} is too large (max ${r}MB)`);return}if(o&&!o.some(P=>w.type.match(P))){T.push(`${w.name} has invalid file type`);return}F.push(w);}),{valid:F,errors:T})},[e.length,s,r,o]),g=useCallback(async v=>{let{valid:F,errors:T}=f(v);if(T.length>0){d(T.join(", ")),setTimeout(()=>d(null),5e3);return}if(F.length!==0){n(true),d(null);try{await t?.(F);}catch(w){d(w instanceof Error?w.message:"Upload failed"),setTimeout(()=>d(null),5e3);}finally{n(false);}}},[f,t]),k=useCallback(v=>{v.preventDefault(),v.stopPropagation(),c(true);},[]),h=useCallback(v=>{v.preventDefault(),v.stopPropagation(),c(false);},[]),b=useCallback(v=>{v.preventDefault(),v.stopPropagation();},[]),y=useCallback(v=>{v.preventDefault(),v.stopPropagation(),c(false);let F=Array.from(v.dataTransfer.files);g(F);},[g]),D=useCallback(v=>{let F=v.target.files?Array.from(v.target.files):[];g(F),i.current&&(i.current.value="");},[g]),N=useCallback(()=>{i.current?.click();},[]),A=useCallback(v=>{confirm("Are you sure you want to delete this attachment?")&&a?.(v);},[a]);return jsxs("div",{className:"attachment-uploader",children:[jsxs("div",{className:`attachment-dropzone ${l?"dragging":""} ${p?"uploading":""}`,onDragEnter:k,onDragLeave:h,onDragOver:b,onDrop:y,onClick:N,children:[jsx("input",{ref:i,type:"file",multiple:true,onChange:D,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:l?"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"]})]})})]}),m&&jsxs("div",{className:"attachment-error",children:[jsx("span",{className:"attachment-error-icon",children:"\u26A0\uFE0F"}),jsx("span",{className:"attachment-error-text",children:m})]}),e.length>0&&jsx("div",{className:"attachment-list",children:e.map(v=>jsxs("div",{className:"attachment-item",children:[jsx("div",{className:"attachment-preview",children:qn(v.type)&&v.url?jsxs("button",{type:"button",className:"attachment-thumbnail-btn",onClick:F=>x(v,F),title:"Click to view full size",children:[jsx("img",{src:v.thumbnailUrl||v.url,alt:v.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:km(v.type)})}),jsxs("div",{className:"attachment-info",children:[jsx("a",{href:v.url,target:"_blank",rel:"noopener noreferrer",className:"attachment-name",title:v.name,children:v.name}),jsxs("div",{className:"attachment-meta",children:[jsx("span",{className:"attachment-size",children:xm(v.size)}),jsx("span",{className:"attachment-separator",children:"\u2022"}),jsx("span",{className:"attachment-date",children:new Date(v.uploadedAt).toLocaleDateString()})]})]}),jsx("button",{onClick:()=>A(v.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"})})})]},v.id))})]})}function Xn({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:l=[],activities:c=[],aiInsights:p=[],attachments:n=[],onAddComment:m,onDeleteComment:d,onUploadAttachments:i,onDeleteAttachment:u,onSuggestAssignee:x,onGenerateSubtasks:f,onEstimateEffort:g,currentUserId:k="user-1"}){let[h,b]=useState("details"),[y,D]=useState(false),[N,A]=useState({}),[v,F]=useState(""),[T,w]=useState(false),[B,P]=useState({});if(!t||!e)return null;let H=useCallback(()=>{D(false),A({}),b("details"),F(""),P({}),a();},[a]),X=useCallback(()=>{r&&Object.keys(N).length>0&&(r(e.id,N),A({}),D(false));},[e.id,N,r]),fe=useCallback(()=>{o&&window.confirm("Are you sure you want to delete this card?")&&(o(e.id),H());},[e.id,o,H]),ve=useCallback(()=>{m&&v.trim()&&(m(e.id,v.trim()),F(""));},[e.id,v,m]),Re=useCallback(async()=>{if(x){w(true);try{let E=await x(e);P(q=>({...q,assignees:E}));}catch(E){console.error("Failed to suggest assignee:",E);}finally{w(false);}}},[e,x]),Ue=useCallback(async()=>{if(f){w(true);try{let E=await f(e);P(q=>({...q,subtasks:E}));}catch(E){console.error("Failed to generate subtasks:",E);}finally{w(false);}}},[e,f]),z=useCallback(async()=>{if(g){w(true);try{let E=await g(e);P(q=>({...q,effort:E}));}catch(E){console.error("Failed to estimate effort:",E);}finally{w(false);}}},[e,g]),L={...e,...N},U=s.filter(E=>L.assignedUserIds?.includes(E.id));return jsx(at,{children:jsx("div",{className:"card-detail-overlay",onClick:H,children:jsxs("div",{className:"card-detail-modal",onClick:E=>E.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"}}),y?jsx("input",{type:"text",value:N.title??L.title,onChange:E=>A({...N,title:E.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:[y?jsxs(Fragment,{children:[jsx("button",{onClick:X,className:"card-detail-btn card-detail-btn-primary",children:"Save"}),jsx("button",{onClick:()=>{D(false),A({});},className:"card-detail-btn",children:"Cancel"})]}):jsxs("button",{onClick:()=>D(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:fe,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:H,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:()=>b("details"),className:`card-detail-tab ${h==="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:()=>b("comments"),className:`card-detail-tab ${h==="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",l.length>0&&jsx("span",{className:"card-detail-tab-badge",children:l.length})]}),jsxs("button",{onClick:()=>b("activity"),className:`card-detail-tab ${h==="activity"?"active":""}`,children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})}),"Activity",c.length>0&&jsx("span",{className:"card-detail-tab-badge",children:c.length})]}),jsxs("button",{onClick:()=>b("attachments"),className:`card-detail-tab ${h==="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",n.length>0&&jsx("span",{className:"card-detail-tab-badge",children:n.length})]}),jsxs("button",{onClick:()=>b("ai"),className:`card-detail-tab ${h==="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:[h==="details"&&jsxs("div",{className:"card-detail-details",children:[jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Description"}),y?jsx("textarea",{value:N.description??L.description??"",onChange:E=>A({...N,description:E.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"}),y?jsx("select",{multiple:true,value:N.assignedUserIds??L.assignedUserIds??[],onChange:E=>{let q=Array.from(E.target.selectedOptions,J=>J.value);A({...N,assignedUserIds:q});},className:"card-detail-textarea",style:{height:"120px",padding:"8px 12px"},children:s.map(E=>jsx("option",{value:E.id,children:E.name},E.id))}):jsx("div",{className:"card-detail-users",children:U.length>0?U.map(E=>jsxs("div",{className:"card-detail-user",children:[jsx("div",{className:"card-detail-user-avatar",style:{background:E.color},children:E.initials}),jsx("span",{children:E.name})]},E.id)):jsx("span",{className:"card-detail-empty",children:"Unassigned"})})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Priority"}),y?jsxs("select",{value:N.priority??L.priority??"",onChange:E=>A({...N,priority:E.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(E=>jsx("span",{className:"card-detail-label-tag",children:E},E)):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"}),y?jsx("input",{type:"date",value:N.startDate?new Date(N.startDate).toISOString().split("T")[0]:L.startDate?new Date(L.startDate).toISOString().split("T")[0]:"",onChange:E=>A({...N,startDate:E.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"}),y?jsx("input",{type:"date",value:N.endDate?new Date(N.endDate).toISOString().split("T")[0]:L.endDate?new Date(L.endDate).toISOString().split("T")[0]:"",onChange:E=>A({...N,endDate:E.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"}),y?jsx("input",{type:"number",min:"0",step:"0.5",value:N.estimatedTime??L.estimatedTime??"",onChange:E=>A({...N,estimatedTime:E.target.value?parseFloat(E.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(E=>{let q=typeof E=="string"?E:E.taskId;return jsxs("span",{className:"card-detail-dependency",children:["Card #",q.slice(-4)]},q)}):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"})]})]}),h==="comments"&&jsxs("div",{className:"card-detail-comments",children:[jsxs("div",{className:"card-detail-comment-form",children:[jsx("textarea",{value:v,onChange:E=>F(E.target.value),className:"card-detail-comment-textarea",placeholder:"Write a comment...",rows:3}),jsx("button",{onClick:ve,disabled:!v.trim(),className:"card-detail-btn card-detail-btn-primary",children:"Add Comment"})]}),jsx("div",{className:"card-detail-comments-list",children:l.length>0?l.map(E=>{let q=s.find(J=>J.id===E.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:[q&&jsx("div",{className:"card-detail-user-avatar",style:{background:q.color},children:q.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-comment-author-name",children:q?.name||"Unknown"}),jsx("div",{className:"card-detail-comment-time",children:new Date(E.createdAt).toLocaleString()})]})]}),d&&jsx("button",{onClick:()=>d(E.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:E.content})]},E.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"})]})})]}),h==="activity"&&jsx("div",{className:"card-detail-activity",children:c.length>0?jsx("div",{className:"card-detail-activity-list",children:c.map(E=>{let q=s.find(J=>J.id===E.userId);return jsxs("div",{className:"card-detail-activity-item",children:[jsxs("div",{className:"card-detail-activity-icon",children:[E.type.includes("CREATED")&&"\u2795",E.type.includes("UPDATED")&&"\u270F\uFE0F",E.type.includes("MOVED")&&"\u27A1\uFE0F",E.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",E.type.includes("COMMENT")&&"\u{1F4AC}",E.type.includes("ASSIGNED")&&"\u{1F464}",E.type.includes("PRIORITY")&&"\u{1F3AF}",E.type.includes("LABEL")&&"\u{1F3F7}\uFE0F",E.type.includes("ATTACHMENT")&&"\u{1F4CE}"]}),jsxs("div",{className:"card-detail-activity-content",children:[jsxs("div",{className:"card-detail-activity-text",children:[jsx("strong",{children:q?.name||"Unknown"})," ",E.type.replace(/_/g," ").toLowerCase(),E.newValue&&jsxs("span",{className:"card-detail-activity-value",children:[" ","to ",jsx("strong",{children:E.newValue})]})]}),jsx("div",{className:"card-detail-activity-time",children:new Date(E.timestamp).toLocaleString()})]})]},E.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"})]})}),h==="attachments"&&jsx("div",{className:"card-detail-attachments",children:jsx(Ua,{cardId:e.id,attachments:n,onUpload:i?E=>i(e.id,E):void 0,onDelete:u,currentUserId:k,maxSizeMB:10,maxFiles:20})}),h==="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:Re,disabled:T||!x,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:Ue,disabled:T||!f,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:z,disabled:T||!g,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"]})]}),B.assignees&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Assignee Suggestions"}),B.assignees.map((E,q)=>{let J=s.find($=>$.id===E.userId);return jsxs("div",{className:"card-detail-ai-suggestion",children:[J&&jsx("div",{className:"card-detail-user-avatar",style:{background:J.color},children:J.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-ai-suggestion-name",children:J?.name}),jsx("div",{className:"card-detail-ai-suggestion-reason",children:E.reasoning}),jsxs("div",{className:"card-detail-ai-suggestion-confidence",children:["Confidence: ",(E.confidence*100).toFixed(0),"%"]})]})]},q)})]}),B.subtasks&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Suggested Subtasks"}),B.subtasks.map((E,q)=>jsxs("div",{className:"card-detail-ai-subtask",children:[jsx("div",{className:"card-detail-ai-subtask-title",children:E.title}),E.description&&jsx("div",{className:"card-detail-ai-subtask-desc",children:E.description}),E.estimatedTime&&jsxs("div",{className:"card-detail-ai-subtask-time",children:["Est: ",E.estimatedTime,"h"]})]},q))]}),B.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:[B.effort.hours," hours"]}),jsxs("div",{className:"card-detail-ai-effort-confidence",children:["Confidence: ",(B.effort.confidence*100).toFixed(0),"%"]})]})]}),p.length>0&&jsxs("div",{className:"card-detail-ai-insights",children:[jsx("h4",{children:"AI Insights"}),p.map(E=>jsxs("div",{className:`card-detail-ai-insight card-detail-ai-insight-${E.severity.toLowerCase()}`,children:[jsxs("div",{className:"card-detail-ai-insight-header",children:[jsx("span",{className:"card-detail-ai-insight-title",children:E.title}),jsx("span",{className:"card-detail-ai-insight-severity",children:E.severity})]}),jsx("p",{className:"card-detail-ai-insight-desc",children:E.description}),E.suggestedAction&&jsxs("div",{className:"card-detail-ai-insight-action",children:["\u{1F4A1} ",E.suggestedAction]})]},E.id))]}),!B.assignees&&!B.subtasks&&!B.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 no({triggerRef:e,isOpen:t,onClose:a,children:r,width:o=200,estimatedHeight:s=300,className:l=""}){let[c,p]=useState({top:0,left:0}),n=useRef(null),m=useCallback(()=>{if(!e.current)return {top:0,left:0};let d=e.current.getBoundingClientRect(),i=window.innerHeight,u=window.innerWidth,x=4,f=d.left;f+o>u-10&&(f=u-o-10),f<10&&(f=10);let g=i-d.bottom,k=d.top,h;return g>=s+x?h=d.bottom+x:k>=s+x?h=d.top-s-x:g>=k?h=d.bottom+x:h=Math.max(10,d.top-s-x),{top:h,left:f}},[e,o,s]);return useEffect(()=>{t&&p(m());},[t,m]),useEffect(()=>{if(!t)return;let d=u=>{let x=u.target;n.current&&!n.current.contains(x)&&e.current&&!e.current.contains(x)&&a();},i=setTimeout(()=>{document.addEventListener("mousedown",d);},0);return ()=>{clearTimeout(i),document.removeEventListener("mousedown",d);}},[t,a,e]),useEffect(()=>{if(!t)return;let d=i=>{i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),a());};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,a]),t?jsx(at,{children:jsx("div",{ref:n,className:`smart-popover ${l}`,style:{position:"fixed",top:`${c.top}px`,left:`${c.left}px`,width:`${o}px`,maxHeight:"calc(100vh - 40px)",overflowY:"auto",zIndex:99999,padding:"6px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",borderRadius:"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",animation:"popoverSlideIn 100ms ease-out"},children:r})}):null}var $o=["#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#22C55E","#10B981","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899"];function Rr({selectedTags:e,availableTags:t,onChange:a,onCreateTag:r,theme:o,disabled:s=false,compact:l=true}){let[c,p]=useState(false),[n,m]=useState(""),[d,i]=useState(false),[u,x]=useState($o[10]||"#3B82F6"),[f,g]=useState({top:0,left:0}),k=useRef(null),h=useRef(null),b=useRef(null),y=useRef(null),D=t.filter(w=>w.name.toLowerCase().includes(n.toLowerCase())),N=t.some(w=>w.name.toLowerCase()===n.toLowerCase());useEffect(()=>{if(c&&h.current){let w=h.current.getBoundingClientRect();g({top:w.bottom+6,left:w.left});}},[c]),useEffect(()=>{let w=B=>{let P=B.target,H=k.current?.contains(P),X=b.current?.contains(P);!H&&!X&&(p(false),m(""),i(false));};if(c)return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[c]),useEffect(()=>{c&&y.current&&y.current.focus();},[c]);let A=w=>{let B=e.some(P=>P.id===w.id);a(B?e.filter(P=>P.id!==w.id):[...e,w]);},v=async()=>{if(!(!r||!n.trim())){i(true);try{let w=await r(n.trim(),u);w&&(a([...e,w]),m(""),x($o[Math.floor(Math.random()*$o.length)]||"#3B82F6"));}finally{i(false);}}},F=(w,B)=>{B.stopPropagation(),a(e.filter(P=>P.id!==w));},T={backgroundColor:`${o.textTertiary}15`,border:`1px solid ${o.borderLight}`,color:o.textSecondary};return jsxs("div",{ref:k,className:"relative",children:[jsxs("button",{ref:h,type:"button",onClick:()=>!s&&p(!c),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:T,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(w=>jsx("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",style:{backgroundColor:`${w.color}20`,color:w.color},children:w.name},w.id)),e.length>2&&jsxs("span",{className:"text-xs",style:{color:o.textTertiary},children:["+",e.length-2]})]}):jsx("span",{children:"Etiquetas"}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:o.textTertiary}})]}),typeof document<"u"&&createPortal(jsx(AnimatePresence,{children:c&&jsxs(motion.div,{ref:b,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:f.top,left:f.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:y,type:"text",value:n,onChange:w=>m(w.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:w=>{w.key==="Enter"&&n.trim()&&!N&&r&&v();}})}),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(w=>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:`${w.color}20`,color:w.color},onClick:B=>F(w.id,B),children:[w.name,jsx(X,{className:"w-3 h-3"})]},w.id))})]}),jsx("div",{className:"max-h-[200px] overflow-y-auto p-1",children:D.length>0?D.map(w=>{let B=e.some(P=>P.id===w.id);return jsxs("button",{type:"button",onClick:()=>A(w),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors",style:{backgroundColor:B?`${w.color}15`:"transparent",color:o.textPrimary},onMouseEnter:P=>{B||(P.currentTarget.style.backgroundColor=o.hoverBg);},onMouseLeave:P=>{B||(P.currentTarget.style.backgroundColor="transparent");},children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:w.color}}),jsx("span",{className:"flex-1 text-left",children:w.name}),B&&jsx(Check,{className:"w-4 h-4",style:{color:w.color}})]},w.id)}):n.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"})}),n.trim()&&!N&&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:$o.map(w=>jsx("button",{type:"button",onClick:()=>x(w),className:"w-5 h-5 rounded-full transition-transform hover:scale-110",style:{backgroundColor:w,outline:u===w?`2px solid ${w}`:"none",outlineOffset:"2px"}},w))}),jsxs("button",{type:"button",onClick:v,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:u,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 "',n.trim(),'"']})]})]})}),document.body)]})}function Qn({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 Fl({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(Qn,{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 _e={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 Rm=["LOW","MEDIUM","HIGH","URGENT"],Om=["todo","in-progress","review","done"];function ts({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:l=[],activities:c=[],onAddComment:p,onDeleteComment:n,currentUser:m,onAIGenerateDescription:d,onAICreateSubtasks:i,onAIFindSimilar:u,availableColumns:x=[],availableLabels:f=[],availableTags:g=[],onCreateTag:k,onUploadCoverImage:h,unsplashAccessKey:b,theme:y,onSubtasksChange:D,attachments:N=[],onUploadAttachments:A,onDeleteAttachment:v}){let F=Mr(),T=y||F?.themeName||"dark",[w,B]=useState(e),[P,H]=useState(false),[X,fe]=useState(e?.subtasks||[]),[ve,Re]=useState(false),[Ue,z]=useState(""),[L,U]=useState(""),[E,q]=useState("all"),[J,$]=useState(false),[Te,ke]=useState(false),[Ge,he]=useState(false),[tt,Fe]=useState(false),[et,ft]=useState(false),[Tt,dt]=useState(false),O=useRef(null),ne=useRef(null),ie=useRef(null),Se=useRef(null),Ae=useRef(null),ot=useRef(null),st=useRef(null),Le=useRef(null),V=useRef(null),xe=useRef(null),qe=useRef(null),Z=useRef(null);useEffect(()=>{e&&!w?(B({...e}),fe(e.subtasks||[])):e&&w&&e.id!==w.id&&(B({...e}),fe(e.subtasks||[]));},[e,w]),useEffect(()=>{let R=ue=>{let K=ue.target;Se.current&&!Se.current.contains(K)&&$(false),Ae.current&&!Ae.current.contains(K)&&ke(false),ot.current&&!ot.current.contains(K)&&he(false),st.current&&!st.current.contains(K)&&Fe(false);};if(J||Te||Ge||tt)return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[J,Te,Ge,tt]),useEffect(()=>{if(!t)return;let R=ue=>{let K=ue.target,Ft=K.tagName==="INPUT"||K.tagName==="TEXTAREA"||K.isContentEditable;if(ue.key==="Escape"){ue.preventDefault(),J||Te||Ge||tt||et||Tt?($(false),ke(false),he(false),Fe(false),ft(false),dt(false)):Ft||a();return}if(Ft&&ue.key!=="Escape")return;let aa=ue.metaKey||ue.ctrlKey;switch(ue.key.toLowerCase()){case "s":ue.preventDefault(),$(true);break;case "a":ue.preventDefault(),he(true);break;case "p":ue.preventDefault(),ke(true);break;case "l":ue.preventDefault(),Fe(true);break;case "d":aa||(ue.preventDefault(),ft(true),setTimeout(()=>Le.current?.focus(),0));break;case "e":aa||(ue.preventDefault(),dt(true));break;case "i":ue.preventDefault(),H(true),setTimeout(()=>ne.current?.focus(),0);break;case "t":ue.preventDefault(),Re(true);break;case "c":ue.preventDefault(),ie.current?.focus();break}};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[t,a,J,Te,Ge,tt,et,Tt]);let we=useCallback(R=>{let ue=R.currentTarget.textContent?.trim()||"";if(w&&ue!==w.title){let K={...w,title:ue};B(K),r?.(w.id,{title:ue});}},[w,r]),ee=useCallback(R=>{R.key==="Enter"&&(R.preventDefault(),R.currentTarget.blur()),R.key==="Escape"&&(R.preventDefault(),R.currentTarget.textContent=w?.title||"",R.currentTarget.blur());},[w]),ae=useCallback(()=>{w&&e&&w.description!==e.description&&r?.(w.id,{description:w.description}),H(false);},[w,e,r]),ye=useCallback(R=>{if(w){let ue={...w,columnId:R};B(ue),r?.(w.id,{columnId:R}),$(false);}},[w,r]),De=useCallback(R=>{if(w){let ue={...w,priority:R};B(ue),r?.(w.id,{priority:R}),ke(false);}},[w,r]),re=useCallback(R=>{if(w){let ue=w.assignedUserIds||[],K=ue.includes(R)?ue.filter(aa=>aa!==R):[...ue,R],Ft={...w,assignedUserIds:K};B(Ft),r?.(w.id,{assignedUserIds:K});}},[w,r]),Ee=useCallback(R=>{if(w){let ue=w.labels||[],K=ue.includes(R)?ue.filter(aa=>aa!==R):[...ue,R],Ft={...w,labels:K};B(Ft),r?.(w.id,{labels:K});}},[w,r]),be=useCallback(R=>{if(w){let ue={...w,tags:R};B(ue),r?.(w.id,{tags:R});}},[w,r]),Ne=useCallback(R=>{if(w){let ue=R.target.value,K={...w,endDate:ue};B(K),r?.(w.id,{endDate:ue}),ft(false);}},[w,r]),ce=useCallback(R=>{if(w){let ue={...w,estimatedTime:parseFloat(R)||0};B(ue),r?.(w.id,{estimatedTime:parseFloat(R)||0});}},[w,r]),Oe=useCallback(()=>{if(Ue.trim()&&w){let R={id:`subtask-${Date.now()}`,title:Ue.trim(),completed:false,createdAt:new Date},ue=[...X,R];fe(ue),z(""),Re(false),D?.(w.id,ue);}},[Ue,X,w,D]),W=useCallback(R=>{let ue=X.map(K=>K.id===R?{...K,completed:!K.completed,updatedAt:new Date}:K);fe(ue),w&&D?.(w.id,ue);},[X,w,D]),G=useCallback(R=>{let ue=X.filter(K=>K.id!==R);fe(ue),w&&D?.(w.id,ue);},[X,w,D]),je=useCallback(()=>{L.trim()&&w&&p&&(p(w.id,L.trim()),U(""));},[L,w,p]),Ie=useCallback(R=>{(R.metaKey||R.ctrlKey)&&R.key==="Enter"&&(R.preventDefault(),je());},[je]),ze=R=>jsx(Lm,{remarkPlugins:[Fm],rehypePlugins:[Bm],components:{a:({node:ue,...K})=>jsx("a",{...K,target:"_blank",rel:"noopener noreferrer"})},children:R}),Ut=c.filter(R=>E==="comments"?R.type.includes("COMMENT"):E==="history"?!R.type.includes("COMMENT"):true);if(!t||!e)return null;let Pe=w||e,Dt=s.filter(R=>Pe.assignedUserIds?.includes(R.id)),Qt=X.filter(R=>R.completed).length;return jsx(at,{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:R=>R.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"modal-title","data-theme":T,children:[jsxs("header",{className:"modal-v2-header",children:[jsx("h1",{id:"modal-title",ref:O,className:"modal-v2-title",contentEditable:true,suppressContentEditableWarning:true,onBlur:we,onKeyDown:ee,children:Pe.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:Se,children:[jsxs("button",{ref:V,className:"modal-v2-field",onClick:()=>$(!J),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M12 6v6l4 2"})]}),jsx("span",{children:"Status"}),jsx("kbd",{className:"modal-v2-shortcut",children:"S"})]}),jsx("div",{className:"modal-v2-field-value",children:Pe.columnId||"No status"})]}),jsx(no,{triggerRef:V,isOpen:J,onClose:()=>$(false),width:250,estimatedHeight:200,children:(x.length>0?x:Om.map(R=>({id:R,title:R}))).map(R=>jsx("button",{className:`modal-v2-popover-item ${Pe.columnId===R.id?"active":""}`,onClick:()=>ye(R.id),children:R.title},R.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:ot,children:[jsxs("button",{ref:xe,className:"modal-v2-field",onClick:()=>he(!Ge),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:Dt.length>0?jsx("div",{className:"modal-v2-avatars",children:Dt.map(R=>jsx("div",{className:"modal-v2-avatar",style:{background:R.color},title:R.name,children:R.initials},R.id))}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(no,{triggerRef:xe,isOpen:Ge,onClose:()=>he(false),width:280,estimatedHeight:300,children:s.map(R=>jsxs("button",{className:`modal-v2-popover-item ${Pe.assignedUserIds?.includes(R.id)?"active":""}`,onClick:()=>re(R.id),children:[jsx("div",{className:"modal-v2-avatar-small",style:{background:R.color},children:R.initials}),R.name,Pe.assignedUserIds?.includes(R.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"})})]},R.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:Ae,children:[jsxs("button",{ref:qe,className:"modal-v2-field",onClick:()=>ke(!Te),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:Pe.priority||"None"})]}),jsxs(no,{triggerRef:qe,isOpen:Te,onClose:()=>ke(false),width:180,estimatedHeight:220,children:[Rm.map(R=>jsx("button",{className:`modal-v2-popover-item priority-${R.toLowerCase()} ${Pe.priority===R?"active":""}`,onClick:()=>De(R),children:R},R)),jsx("button",{className:"modal-v2-popover-item",onClick:()=>De(""),children:"None"})]})]}),g.length>0||k?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(Rr,{selectedTags:Pe.tags||[],availableTags:g,onChange:be,onCreateTag:k,theme:_e[T]||_e.dark})})]})}):jsxs("div",{className:"modal-v2-field-wrapper",ref:st,children:[jsxs("button",{ref:Z,className:"modal-v2-field",onClick:()=>Fe(!tt),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:Pe.labels&&Pe.labels.length>0?jsx("span",{children:Pe.labels.join(", ")}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(no,{triggerRef:Z,isOpen:tt,onClose:()=>Fe(false),width:220,estimatedHeight:200,children:(f.length>0?f:["Bug","Feature","Enhancement","Documentation"]).map(R=>jsxs("button",{className:`modal-v2-popover-item ${Pe.labels?.includes(R)?"active":""}`,onClick:()=>Ee(R),children:[R,Pe.labels?.includes(R)&&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"})})]},R))})]}),jsxs("button",{className:"modal-v2-field",onClick:()=>{ft(!et),setTimeout(()=>Le.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:Pe.endDate?new Date(Pe.endDate).toLocaleDateString():"Not set"}),jsx("input",{ref:Le,type:"date",value:typeof Pe.endDate=="string"?Pe.endDate.split("T")[0]:Pe.endDate?(()=>{let R=new Date(Pe.endDate),ue=R.getUTCFullYear(),K=String(R.getUTCMonth()+1).padStart(2,"0"),Ft=String(R.getUTCDate()).padStart(2,"0");return `${ue}-${K}-${Ft}`})():"",onChange:Ne,style:{position:"absolute",opacity:0,pointerEvents:"none"}})]}),jsxs("div",{className:"modal-v2-field-wrapper",children:[jsxs("button",{className:"modal-v2-field",onClick:()=>dt(!Tt),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:Pe.estimatedTime?`${Pe.estimatedTime}h`:"Not set"})]}),Tt&&jsx("div",{className:"modal-v2-popover",children:jsx("input",{type:"number",min:"0",step:"0.5",placeholder:"Hours",value:Pe.estimatedTime||"",onChange:R=>ce(R.target.value),className:"modal-v2-time-input",autoFocus:true,onBlur:()=>dt(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"})]}),P?jsx("textarea",{className:"modal-v2-textarea",value:Pe.description||"",onChange:R=>{if(w){let ue={...w,description:R.target.value};B(ue);}},onBlur:ae,placeholder:"Add a detailed description...",autoFocus:true}):jsx("div",{className:"modal-v2-content",onClick:()=>H(true),children:Pe.description?jsx("div",{className:"modal-v2-markdown",children:ze(Pe.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"}),X.length>0&&jsxs("span",{className:"modal-v2-count",children:[Qt,"/",X.length]}),jsxs("button",{className:"modal-v2-add-button",onClick:()=>Re(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:[X.map(R=>jsxs("div",{className:`modal-v2-subtask ${R.completed?"completed":""}`,children:[jsx("button",{className:"modal-v2-subtask-checkbox",onClick:()=>W(R.id),children:R.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:R.title}),jsx("button",{className:"modal-v2-subtask-delete",onClick:()=>G(R.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"})]})})]},R.id)),ve&&jsx("div",{className:"modal-v2-subtask-input-row",children:jsx("input",{type:"text",placeholder:"Subtask title...",value:Ue,onChange:R=>z(R.target.value),onKeyDown:R=>{R.key==="Enter"&&Oe(),R.key==="Escape"&&(Re(false),z(""));},onBlur:Oe,autoFocus:true,className:"modal-v2-subtask-input"})})]})]}),(A||N.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"}),N.length>0&&jsx("span",{className:"modal-v2-count",children:N.length})]}),jsx(Ua,{cardId:Pe.id,attachments:N,onUpload:A?R=>A(Pe.id,R):void 0,onDelete:v,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 ${E==="all"?"active":""}`,onClick:()=>q("all"),children:"All"}),jsx("button",{className:`modal-v2-filter ${E==="comments"?"active":""}`,onClick:()=>q("comments"),children:"Comments"}),jsx("button",{className:`modal-v2-filter ${E==="history"?"active":""}`,onClick:()=>q("history"),children:"History"})]})]}),jsxs("div",{className:"modal-v2-comment-input",children:[m&&jsx("div",{className:"modal-v2-avatar",style:{background:m.color},children:m.initials}),jsxs("div",{className:"modal-v2-comment-wrapper",children:[jsx("textarea",{ref:ie,className:"modal-v2-comment-textarea",placeholder:"Write a comment...",value:L,onChange:R=>U(R.target.value),onKeyDown:Ie,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:je,disabled:!L.trim(),children:"Send"})]})]})]}),jsxs("div",{className:"modal-v2-timeline",children:[Ut.map(R=>{let ue=s.find(Ft=>Ft.id===R.userId);if(R.type.includes("COMMENT")){let Ft=l.find(aa=>aa.id===R.metadata?.commentId);return Ft?jsxs("div",{className:"modal-v2-activity-item comment-item",children:[ue&&jsx("div",{className:"modal-v2-avatar",style:{background:ue.color},children:ue.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:ue?.name||"Unknown"}),jsx("span",{className:"modal-v2-activity-time",children:new Date(R.timestamp).toLocaleString()})]}),jsx("div",{className:"modal-v2-comment-body",children:Ft.content})]})]},R.id):null}return jsxs("div",{className:"modal-v2-activity-item history-item",children:[jsxs("div",{className:"modal-v2-history-icon",children:[R.type.includes("CREATED")&&"\u2795",R.type.includes("UPDATED")&&"\u270F\uFE0F",R.type.includes("MOVED")&&"\u27A1\uFE0F",R.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",R.type.includes("ASSIGNED")&&"\u{1F464}",R.type.includes("PRIORITY")&&"\u{1F3AF}",R.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:ue?.name||"Unknown"})," ",R.type.replace(/_/g," ").toLowerCase(),R.newValue&&jsxs(Fragment,{children:[" to ",jsx("strong",{children:R.newValue})]})]}),jsx("span",{className:"modal-v2-activity-time",children:new Date(R.timestamp).toLocaleString()})]})]},R.id)}),Ut.length===0&&jsxs("div",{className:"modal-v2-empty",children:[jsx("p",{children:"No activity yet"}),jsx("span",{children:"Activity will appear here"})]})]})]})]})})})}function jm({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(l=>({...l,average:l.average??e.reduce((c,p)=>c+p.completed,0)/e.length}));return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:a,children:jsxs(LineChart,{data:s,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"period",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(jm,{})}),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((l,c)=>l+c.completed,0)})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Average Velocity"}),jsx("span",{className:"chart-stat-value",style:{color:"#F59E0B"},children:(e.reduce((l,c)=>l+c.completed,0)/e.length).toFixed(1)})]}),o&&e.some(l=>l.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((l,c)=>l+(c.planned||0),0)})]})]})]})}function tu({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 os({data:e,title:t="Sprint Burndown",height:a=300,totalTasks:r,useArea:o=false}){let s=r??(e[0]?.ideal||e[0]?.remaining||0),l=e[e.length-1]?.remaining||0,c=e[e.length-1]?.ideal||0,p=s>0?(s-l)/s*100:0,n=l<=c;return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:a,children:jsxs(o?AreaChart:LineChart,{data:e,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"day",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(tu,{})}),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:n?"#10B981":"#EF4444",fill:n?"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:n?"#10B981":"#EF4444",strokeWidth:3,name:"Remaining",dot:{fill:n?"#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:n?"#10B981":"#EF4444"},children:l})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Status"}),jsx("span",{className:"chart-stat-badge",style:{background:n?"rgba(16, 185, 129, 0.15)":"rgba(239, 68, 68, 0.15)",color:n?"#10B981":"#EF4444"},children:n?"\u2713 On Track":"\u26A0 Behind"})]})]})]})}var cu={URGENT:"#EF4444",HIGH:"#F59E0B",MEDIUM:"#3B82F6",LOW:"#10B981"},Wl=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899"];function pu({cx:e,cy:t,midAngle:a,innerRadius:r,outerRadius:o,percent:s}){let l=r+(o-r)*.5,c=e+l*Math.cos(-a*(Math.PI/180)),p=t+l*Math.sin(-a*(Math.PI/180));return s<.05?null:jsx("text",{x:c,y:p,fill:"white",textAnchor:c>e?"start":"end",dominantBaseline:"central",style:{fontSize:"12px",fontWeight:600},children:`${(s*100).toFixed(0)}%`})}function Hl({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 ns({data:e,title:t="Distribution",type:a="pie",height:r=300,showPercentages:o=true}){let s=e.reduce((p,n)=>p+n.value,0),l=e.map(p=>({...p,totalValue:s,color:p.color||cu[p.name]||Wl[e.indexOf(p)%Wl.length]})),c=l.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:l,cx:"50%",cy:"50%",labelLine:false,label:o?pu:false,outerRadius:r*.35,fill:"#8884d8",dataKey:"value",children:l.map((p,n)=>jsx(Cell,{fill:c[n]},`cell-${n}`))}),jsx(Tooltip,{content:jsx(Hl,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"},formatter:(p,n)=>{let m=n.payload,d=s>0?(m.value/s*100).toFixed(0):"0";return `${p} (${m.value} - ${d}%)`}})]}):jsxs(BarChart,{data:l,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(Hl,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),jsx(Bar,{dataKey:"value",name:"Count",radius:[8,8,0,0],children:l.map((p,n)=>jsx(Cell,{fill:c[n]},`cell-${n}`))})]})}),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,n)=>n.value>p.value?n:p).name})]})]})]})}var Wo=memo(({selectedCards:e,availableUsers:t=[],onClearSelection:a,callbacks:r,columns:o=[],availableLabels:s=[]})=>{let[l,c]=useState(false),[p,n]=useState(false),[m,d]=useState(false),[i,u]=useState(false);if(e.length===0)return null;let x=e.map(y=>y.id),f=y=>{r.onBulkUpdate?.(x,{priority:y}),c(false);},g=y=>{r.onBulkMove?.(x,y),n(false),a();},k=y=>{r.onBulkUpdate?.(x,{assignedUserIds:y}),d(false);},h=y=>{let D=new Set;e.forEach(A=>{A.labels?.forEach(v=>D.add(v));});let N=Array.from(new Set([...D,...y]));r.onBulkUpdate?.(x,{labels:N}),u(false);},b=()=>{confirm(`Delete ${e.length} card(s)? This cannot be undone.`)&&(r.onBulkDelete?.(x),a());};return jsx("div",{className:"asakaa-bulk-toolbar",children:jsxs("div",{className:"asakaa-bulk-toolbar-content",children:[jsxs("div",{className:"asakaa-bulk-toolbar-count",children:[e.length," card",e.length!==1?"s":""," selected"]}),jsxs("div",{className:"asakaa-bulk-toolbar-actions",children:[jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>c(!l),title:"Update priority",children:jsx("span",{className:"text-sm",children:"Priority"})}),l&&jsx("div",{className:"asakaa-bulk-menu",children:["LOW","MEDIUM","HIGH","URGENT"].map(y=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>f(y),children:[jsx("span",{className:C("asakaa-priority-dot",y==="LOW"&&"bg-asakaa-priority-low",y==="MEDIUM"&&"bg-asakaa-priority-medium",y==="HIGH"&&"bg-asakaa-priority-high",y==="URGENT"&&"bg-asakaa-priority-urgent")}),y]},y))})]}),o.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>n(!p),title:"Move to column",children:jsx("span",{className:"text-sm",children:"Move"})}),p&&jsx("div",{className:"asakaa-bulk-menu",children:o.map(y=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>g(y.id),children:y.title},y.id))})]}),t.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>d(!m),title:"Assign users",children:jsx("span",{className:"text-sm",children:"Assign"})}),m&&jsx("div",{className:"asakaa-bulk-menu",children:t.map(y=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>k([y.id]),children:[jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs font-medium",style:{backgroundColor:y.color},children:y.initials}),y.name]},y.id))})]}),s.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>u(!i),title:"Add labels",children:jsx("span",{className:"text-sm",children:"Labels"})}),i&&jsx("div",{className:"asakaa-bulk-menu",children:s.map(y=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>h([y]),children:y},y))})]}),jsx("button",{className:"asakaa-bulk-toolbar-button asakaa-bulk-toolbar-button-danger",onClick:b,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"})})]})]})})});Wo.displayName="BulkOperationsToolbar";function hu(e,t,a){if(t==="none")return [];let r=new Map;return e.forEach(o=>{let s,l,c,p,n;switch(t){case "assignee":let m=o.assignedUserIds||(o.assigneeId?[o.assigneeId]:[]);m.length>0?m.forEach(u=>{let x=a?.find(f=>f.id===u);l=`assignee-${u}`,c=x?.name||`User ${u}`,p=x?.color,n=x?.avatar,r.has(l)||r.set(l,{id:l,title:c,groupValue:u,cardIds:[],color:p,icon:n}),r.get(l).cardIds.push(o.id);}):(l="assignee-unassigned",c="Unassigned",p="#6b7280",n="\u{1F464}",r.has(l)||r.set(l,{id:l,title:c,groupValue:null,cardIds:[],color:p,icon:n}),r.get(l).cardIds.push(o.id));break;case "priority":s=o.priority||"NONE",l=`priority-${s}`;let i={URGENT:{title:"\u{1F534} Urgent",color:"#ef4444"},HIGH:{title:"\u{1F7E0} High",color:"#f97316"},MEDIUM:{title:"\u{1F7E1} Medium",color:"#eab308"},LOW:{title:"\u{1F7E2} Low",color:"#22c55e"},NONE:{title:"\u26AA No Priority",color:"#6b7280"}}[s];c=i.title,p=i.color,r.has(l)||r.set(l,{id:l,title:c,groupValue:s,cardIds:[],color:p}),r.get(l).cardIds.push(o.id);break;case "label":o.labels&&o.labels.length>0?o.labels.forEach(u=>{l=`label-${u}`,c=u,p="#6b7280",r.has(l)||r.set(l,{id:l,title:c,groupValue:u,cardIds:[],color:p}),r.get(l).cardIds.push(o.id);}):(l="label-none",c="No Labels",p="#6b7280",r.has(l)||r.set(l,{id:l,title:c,groupValue:null,cardIds:[],color:p}),r.get(l).cardIds.push(o.id));break}}),Array.from(r.values()).sort((o,s)=>o.title.localeCompare(s.title))}function ss({board:e,swimlaneConfig:t,availableUsers:a,callbacks:r,className:o}){let[s,l]=useState(new Set),c=useMemo(()=>hu(e.cards,t.groupBy,a),[e.cards,t.groupBy,a]),p=useCallback(n=>{l(m=>{let d=new Set(m);return d.has(n)?d.delete(n):d.add(n),d});},[]);return t.groupBy==="none"||c.length===0?jsx(Qa,{board:e,callbacks:r,availableUsers:a,className:o}):jsxs("div",{className:C("asakaa-swimlane-view",o),children:[c.map(n=>{let m=s.has(n.id),d=e.cards.filter(u=>n.cardIds.includes(u.id)),i={...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(n.id),style:{borderLeft:n.color?`4px solid ${n.color}`:void 0},children:[jsxs("div",{className:"flex items-center gap-3",children:[n.icon&&jsx("span",{className:"text-2xl leading-none",children:n.icon}),jsx("h3",{className:"text-lg font-semibold",style:{color:n.color},children:n.title}),jsxs("span",{className:"text-sm text-white/50 font-medium",children:["(",n.cardIds.length," ",n.cardIds.length===1?"card":"cards",")"]})]}),t.collapsible&&jsx("button",{className:"text-white/50 hover:text-white transition-colors","aria-label":m?"Expand lane":"Collapse lane",children:m?"\u25B6":"\u25BC"})]}),!m&&jsx("div",{className:"asakaa-swimlane-content p-4",children:jsx(Qa,{board:i,callbacks:r,availableUsers:a})})]},n.id)}),c.length===0&&jsxs("div",{className:"text-center py-12 text-white/50",children:[jsx("p",{className:"text-lg",children:"No cards to display"}),jsx("p",{className:"text-sm mt-2",children:"Cards will appear here when they match the grouping criteria"})]})]})}var is=[{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 ls({value:e,onChange:t,className:a}){let[r,o]=useState(false),s=useRef(null),l=useRef(null),c=is.find(n=>n.value===e)||is[0];useEffect(()=>{function n(m){s.current&&!s.current.contains(m.target)&&l.current&&!l.current.contains(m.target)&&o(false);}if(r)return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let p=n=>{t(n),o(false);};return jsxs("div",{className:C("relative inline-block",a),children:[jsxs("button",{ref:l,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-white/10 hover:bg-white/15 border border-white/20 transition-all text-sm font-medium text-white/90",children:[jsx("span",{className:"text-base leading-none",children:c.icon}),jsx("span",{children:c.label}),jsx("svg",{className:C("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:is.map(n=>jsxs("button",{onClick:()=>p(n.value),className:C("w-full px-3 py-2 flex items-start gap-3 text-left transition-all hover:bg-white/10",e===n.value&&"bg-white/5"),children:[jsx("span",{className:"text-xl leading-none mt-0.5",children:n.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:n.label}),e===n.value&&jsx("span",{className:"text-blue-400 text-xs",children:"\u2713"})]}),jsx("p",{className:"text-xs text-white/60 mt-0.5",children:n.description})]})]},n.value))})]})]})}var io=[{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 vu(e,t){if(!(Array.isArray(t.keys)?t.keys:[t.keys]).some(n=>e.key===n||e.code===n))return false;let o=t.modifiers||{},s=o.ctrl?e.ctrlKey||e.metaKey:!e.ctrlKey&&!e.metaKey,l=o.shift?e.shiftKey:!e.shiftKey,c=o.alt?e.altKey:!e.altKey,p=o.meta?e.metaKey:true;return s&&l&&c&&p}function Kl(e={}){let{shortcuts:t=io,enabled:a=true,preventDefault:r=true}=e,o=useRef(t),s=useRef(a);useEffect(()=>{o.current=t,s.current=a;},[t,a]);let l=useCallback(p=>{o.current=[...o.current,p];},[]),c=useCallback(p=>{o.current=o.current.filter(n=>n.action!==p);},[]);return useEffect(()=>{function p(n){if(!s.current)return;let m=n.target;if(!((m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.isContentEditable)&&n.key!=="Escape"&&!n.ctrlKey&&!n.metaKey)){for(let d of o.current)if(vu(n,d)){r&&n.preventDefault();let i=new CustomEvent("keyboard-action",{detail:d.action,bubbles:true,cancelable:true});window.dispatchEvent(i);break}}}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r]),{registerShortcut:l,unregisterShortcut:c,isEnabled:a}}function ku(e){return {ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192",Enter:"\u21B5",Escape:"Esc",Delete:"Del"," ":"Space"}[e]||e.toUpperCase()}function wu(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 Cu(e){let t=Array.isArray(e.keys)?e.keys[0]:e.keys,a=wu(e),r=t?ku(t):"";return a?`${a} + ${r}`:r}function Tu(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 ds({shortcuts:e=io,isOpen:t,onClose:a,className:r}){let[o,s]=useState(false);if(useEffect(()=>{s(true);},[]),useEffect(()=>{function c(p){p.key==="Escape"&&t&&a();}if(t)return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t,a]),!o||!t)return null;let l=Tu(e);return jsxs("div",{className:C("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(l).map(([c,p])=>p.length===0?null:jsxs("div",{children:[jsxs("h3",{className:"text-lg font-semibold text-white/90 mb-4 flex items-center gap-2",children:[jsx("span",{className:"w-1 h-5 bg-blue-500 rounded-full"}),c]}),jsx("div",{className:"space-y-3",children:p.map(n=>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:n.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:Cu(n)})]},n.action))})]},c))})}),jsx("div",{className:"px-6 py-4 border-t border-white/10 bg-white/5",children:jsxs("p",{className:"text-xs text-white/50 text-center",children:["Press ",jsx("kbd",{className:"px-2 py-0.5 bg-white/10 rounded text-white/70",children:"?"})," to toggle this help panel"]})})]})]})}var cs=[{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 fs({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),l=useRef(null);useEffect(()=>{function n(m){s.current&&!s.current.contains(m.target)&&l.current&&!l.current.contains(m.target)&&o(false);}if(r)return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=n=>{t(n),o(false);},p=e.reduce((n,m)=>{let d=m.category||"Other";return n[d]||(n[d]=[]),n[d].push(m),n},{});return jsxs("div",{className:C("relative inline-block",a),children:[jsxs("button",{ref:l,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:n=>{n.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",n.currentTarget.style.borderColor="var(--theme-border-secondary)";},onMouseLeave:n=>{n.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",n.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:C("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(([n,m])=>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:n})}),jsx("div",{children:m.map(d=>jsxs("button",{onClick:()=>c(d),className:"w-full px-4 py-3 flex items-start gap-3 text-left transition-all active:scale-[0.98]",style:{color:"var(--theme-text-primary)"},onMouseEnter:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:i=>{i.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))})]},n)),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 bs({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[l,c]=useState("export"),[p,n]=useState("json"),[m,d]=useState(null),i=useRef(null);if(!t)return null;let u=async()=>{let f=o?.current||void 0,g=await Vi(e,p,f);ji(g,p);},x=async f=>{let g=f.target.files?.[0];if(g){try{let k=await qi(g),h=g.name.endsWith(".json")?"json":"csv",b=Yi(k,h);d(b),b.success&&r&&r(b,k);}catch(k){d({success:false,errors:[`Failed to read file: ${k instanceof Error?k.message:"Unknown error"}`]});}i.current&&(i.current.value="");}};return jsxs("div",{className:C("fixed inset-0 z-[9999] flex items-center justify-center",s),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:a}),jsxs("div",{className:"relative bg-gradient-to-br from-gray-900/95 to-gray-800/95 backdrop-blur-xl rounded-2xl border border-white/20 shadow-2xl max-w-2xl w-full mx-4",children:[jsxs("div",{className:"px-6 py-5 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[jsx("span",{className:"text-3xl",children:"\u{1F4E6}"}),"Export / Import"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Transfer your board data"})]}),jsx("button",{onClick:a,className:"text-white/50 hover:text-white transition-colors text-2xl leading-none p-2 hover:bg-white/10 rounded-lg","aria-label":"Close",children:"\xD7"})]}),jsxs("div",{className:"flex border-b border-white/10",children:[jsx("button",{onClick:()=>c("export"),className:C("flex-1 px-6 py-4 font-semibold transition-colors",l==="export"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Export"}),jsx("button",{onClick:()=>c("import"),className:C("flex-1 px-6 py-4 font-semibold transition-colors",l==="import"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Import"})]}),jsxs("div",{className:"p-6",children:[l==="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(f=>jsxs("button",{onClick:()=>n(f),className:C("p-4 rounded-lg border-2 transition-all text-center",p===f?"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:[f==="json"&&"\u{1F4C4}",f==="csv"&&"\u{1F4CA}",f==="pdf"&&"\u{1F4DD}"]}),jsx("div",{className:"font-semibold uppercase text-xs",children:f})]},f))})]}),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:u,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"})]}),l==="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:i,type:"file",accept:".json,.csv",onChange:x,className:"hidden"}),jsxs("button",{onClick:()=>i.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"})]})]}),m&&jsxs("div",{className:C("p-4 rounded-lg",m.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:C("font-semibold mb-2",m.success?"text-green-400":"text-red-400"),children:m.success?"\u2713 Import Successful":"\u2717 Import Failed"}),m.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",m.cardsImported]}),jsxs("div",{children:["Columns imported: ",m.columnsImported]})]}),m.errors&&m.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:m.errors.map((f,g)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",f]},g))})]})]})]})]})]})}var Nu=["URGENT","HIGH","MEDIUM","LOW"],Su=[{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"}],Eu=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function ys({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:l,onFilterHighPriority:c,availableUsers:p=[],availableLabels:n=[],availableColumns:m=[],showQuickFilters:d=true,compact:i=false,groupBy:u="none",onGroupByChange:x}){let[f,g]=useState(true),k=useCallback(N=>{a({search:N.target.value});},[a]),h=useCallback(N=>{a({dateFilter:N.target.value});},[a]),b=useCallback(N=>{r({by:N.target.value});},[r]),y=useCallback(()=>{r({order:t.order==="asc"?"desc":"asc"});},[t.order,r]),D=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 ${i?"filter-bar--compact":""} ${f?"filter-bar--collapsed":""}`,children:[jsxs("div",{className:"filter-bar__header",onClick:()=>g(!f),style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:f?"0":"12px",padding:"4px 6px",borderRadius:"6px",transition:"all 0.2s ease"},onMouseEnter:N=>{N.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:N=>{N.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:f?"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"}),D&&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)"]})]}),!f&&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"}),l&&jsx("button",{onClick:l,className:"filter-bar__quick-btn",title:"Show overdue tasks",children:"Overdue"}),c&&jsx("button",{onClick:c,className:"filter-bar__quick-btn",title:"Show high priority tasks",children:"High Priority"})]}),jsxs("div",{className:"filter-bar__main",children:[jsx("div",{className:"filter-bar__field",children:jsx("input",{type:"text",placeholder:"Search tasks...",value:e.search,onChange:k,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:h,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:N=>{let A=N.target.value;a({priorities:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),Nu.map(N=>jsx("option",{value:N,children:N},N))]})}),p.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:N=>{let A=N.target.value;a({assignees:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),p.map(N=>jsx("option",{value:N.id,children:N.name},N.id))]})}),n.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:N=>{let A=N.target.value;a({labels:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),n.map(N=>jsx("option",{value:N,children:N},N))]})}),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:b,className:"filter-bar__select filter-bar__select--sm",children:Su.map(N=>jsx("option",{value:N.value,children:N.label},N.value))}),t.by!=="none"&&jsx("button",{onClick:y,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),x&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:u,onChange:N=>x(N.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Eu.map(N=>jsx("option",{value:N.value,children:N.label},N.value))})}),D&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function vs({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:l,onExportGanttPNG:c,onExportGanttCSV:p}){let[n,m]=useState(false),d=useRef(null);useEffect(()=>{let u=x=>{d.current&&!d.current.contains(x.target)&&m(false);};return n&&document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[n]);let i=u=>{u(),m(false);};return jsxs("div",{className:C("relative",r),ref:d,children:[jsxs("button",{onClick:()=>m(!n),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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",u.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",u.currentTarget.style.color="var(--theme-text-secondary)";},"aria-label":"Configuration Menu","aria-expanded":n,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"})]}),n&&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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(async()=>await l?.()),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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(async()=>await c?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(()=>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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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 xs={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"}},ks={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"}},ws={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"}},xr={dark:xs,light:ks,neutral:ws},Vo="dark";var jo=createContext(void 0),zu="asakaa-theme";function Jl({children:e,defaultTheme:t=Vo,storageKey:a=zu}){let[r,o]=useState(()=>{if(typeof window<"u"){let c=localStorage.getItem(a);if(c&&(c==="dark"||c==="light"||c==="neutral"))return c}return t}),s=useCallback(c=>{o(c),typeof window<"u"&&localStorage.setItem(a,c);},[a]);useEffect(()=>{if(typeof window>"u")return;let c=document.documentElement,p=xr[r];Object.entries(p.colors).forEach(([m,d])=>{d&&c.style.setProperty(`--theme-${$u(m)}`,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(([m,d])=>{let i=p.colors[m];i&&c.style.setProperty(d,i);}),c.setAttribute("data-theme",r),c.classList.remove("theme-dark","theme-light","theme-neutral"),c.classList.add(`theme-${r}`);},[r]);let l={theme:r,setTheme:s,themes:xr};return jsx(jo.Provider,{value:l,children:e})}function _r(){let e=useContext(jo);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function $u(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Cs({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=_r();return e?jsxs("div",{className:C("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(xr).map(([s,l])=>jsxs("button",{onClick:()=>{o(s),t();},className:C("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:l.emoji}),jsxs("div",{className:"text-left flex-1",children:[jsx("div",{className:"font-semibold",style:{color:"var(--theme-text-primary)"},children:l.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 Zl(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return _e[e]||_e.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,l)=>a.getPropertyValue(s).trim()||l;return {bgPrimary:r("--theme-bg-primary",_e[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",_e[e].bgSecondary),bgGrid:r("--theme-bg-card",_e[e].bgGrid),bgWeekend:r("--theme-bg-hover",_e[e].bgWeekend),border:r("--theme-border-primary",_e[e].border),borderLight:r("--theme-border-subtle",_e[e].borderLight),textPrimary:r("--theme-text-primary",_e[e].textPrimary),textSecondary:r("--theme-text-secondary",_e[e].textSecondary),textTertiary:r("--theme-text-tertiary",_e[e].textTertiary),accent:r("--theme-accent-primary",_e[e].accent),accentHover:r("--theme-accent-hover",_e[e].accentHover),accentLight:r("--theme-accent-primary",_e[e].accentLight),taskBarPrimary:r("--theme-accent-primary",_e[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",_e[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",_e[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",_e[e].dependency),dependencyHover:r("--theme-border-secondary",_e[e].dependencyHover),criticalPath:r("--theme-error",_e[e].criticalPath),criticalPathLight:r("--theme-error",_e[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",_e[e].today):e==="neutral"?r("--theme-text-primary",_e[e].today):r("--theme-error",_e[e].today),todayLight:e==="light"?r("--theme-accent-primary",_e[e].todayLight):e==="neutral"?r("--theme-text-primary",_e[e].todayLight):r("--theme-error",_e[e].todayLight),milestone:r("--theme-warning",_e[e].milestone),milestoneLight:r("--theme-warning",_e[e].milestoneLight),statusTodo:r("--theme-text-tertiary",_e[e].statusTodo),statusInProgress:r("--theme-accent-primary",_e[e].statusInProgress),statusCompleted:r("--theme-success",_e[e].statusCompleted),hoverBg:r("--theme-bg-hover",_e[e].hoverBg),focusRing:r("--theme-accent-primary",_e[e].focusRing)}}var Ko={columns:{taskName:"TASK NAME",startDate:"Start Date",endDate:"End Date",duration:"Duration",assignees:"Assignees",status:"Status",progress:"% Complete",priority:"Priority"},toolbar:{today:"Today",day:"Day",week:"Week",month:"Month",export:"Export",exportPdf:"Export to PDF",exportPng:"Export to PNG",exportCsv:"Export to CSV",exportExcel:"Export to Excel",exportMsProject:"Export to MS Project",undo:"Undo",redo:"Redo",createTask:"New Task",density:"Row Density",compact:"Compact",normal:"Normal",spacious:"Spacious"},contextMenu:{editTask:"Edit Task",addSubtask:"Add Subtask",markIncomplete:"Mark Incomplete",setInProgress:"Set In Progress",markComplete:"Mark Complete",splitTask:"Split Task",deleteTask:"Delete Task"},actions:{edit:"Edit",delete:"Delete",duplicate:"Duplicate",addSubtask:"Add Subtask",indent:"Indent",outdent:"Outdent",moveUp:"Move Up",moveDown:"Move Down",splitTask:"Split Task",linkTasks:"Link Tasks",unlinkTasks:"Unlink Tasks"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},labels:{progress:"Progress",duration:"Duration",days:"days",day:"day",assigned:"Assigned",milestone:"Milestone",criticalPath:"Critical Path",subtask:"Subtask",task:"Task",noTasks:"No tasks yet",addTask:"Add task",newTask:"New Task",loading:"Loading...",error:"Error",today:"Today"},ai:{placeholder:'Ask AI to edit tasks... (e.g., "Move Design to next week")',thinking:"Thinking...",suggestions:{moveTask:'Move "Task Name" to next Monday',extendTask:'Extend "Task Name" by 3 days',renameTask:'Rename "Old Name" to "New Name"',setProgress:'Set "Task Name" progress to 50%',linkTasks:'Link "Task A" to "Task B"',createTask:'Create a new task called "New Task"',deleteTask:'Delete "Task Name"',assignTask:'Assign John to "Task Name"'},errors:{taskNotFound:"Task not found",invalidDate:"Invalid date",invalidDuration:"Invalid duration",invalidProgress:"Invalid progress value",unknownCommand:"Unknown command",processingError:"Error processing command"}},export:{projectName:"Gantt Project",ganttTasks:"Gantt Tasks",taskId:"Task ID",taskName:"Task Name",startDate:"Start Date",endDate:"End Date",isMilestone:"Is Milestone",parentId:"Parent ID",yes:"Yes",no:"No",noTasksToExport:"No tasks available to export"},dateFormat:{short:"MM/dd",medium:"MMM d",long:"MMMM d, yyyy"}},Ql={columns:{taskName:"NOMBRE DE TAREA",startDate:"Fecha Inicio",endDate:"Fecha Fin",duration:"Duraci\xF3n",assignees:"Asignados",status:"Estado",progress:"% Completado",priority:"Prioridad"},toolbar:{today:"Hoy",day:"D\xEDa",week:"Semana",month:"Mes",export:"Exportar",exportPdf:"Exportar a PDF",exportPng:"Exportar a PNG",exportCsv:"Exportar a CSV",exportExcel:"Exportar a Excel",exportMsProject:"Exportar a MS Project",undo:"Deshacer",redo:"Rehacer",createTask:"Nueva Tarea",density:"Densidad",compact:"Compacto",normal:"Normal",spacious:"Espacioso"},contextMenu:{editTask:"Editar Tarea",addSubtask:"Agregar Subtarea",markIncomplete:"Marcar Incompleta",setInProgress:"Marcar En Progreso",markComplete:"Marcar Completada",splitTask:"Dividir Tarea",deleteTask:"Eliminar Tarea"},actions:{edit:"Editar",delete:"Eliminar",duplicate:"Duplicar",addSubtask:"Agregar Subtarea",indent:"Aumentar Nivel",outdent:"Disminuir Nivel",moveUp:"Mover Arriba",moveDown:"Mover Abajo",splitTask:"Dividir Tarea",linkTasks:"Vincular Tareas",unlinkTasks:"Desvincular Tareas"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},labels:{progress:"Progreso",duration:"Duraci\xF3n",days:"d\xEDas",day:"d\xEDa",assigned:"Asignado",milestone:"Hito",criticalPath:"Ruta Cr\xEDtica",subtask:"Subtarea",task:"Tarea",noTasks:"Sin tareas a\xFAn",addTask:"Agregar tarea",newTask:"Nueva Tarea",loading:"Cargando...",error:"Error",today:"Hoy"},ai:{placeholder:'P\xEDdele a la IA que edite tareas... (ej: "Mover Dise\xF1o a la pr\xF3xima semana")',thinking:"Pensando...",suggestions:{moveTask:'Mover "Nombre de Tarea" al pr\xF3ximo lunes',extendTask:'Extender "Nombre de Tarea" por 3 d\xEDas',renameTask:'Renombrar "Nombre Anterior" a "Nombre Nuevo"',setProgress:'Establecer progreso de "Nombre de Tarea" al 50%',linkTasks:'Vincular "Tarea A" con "Tarea B"',createTask:'Crear una nueva tarea llamada "Nueva Tarea"',deleteTask:'Eliminar "Nombre de Tarea"',assignTask:'Asignar a Juan a "Nombre de Tarea"'},errors:{taskNotFound:"Tarea no encontrada",invalidDate:"Fecha inv\xE1lida",invalidDuration:"Duraci\xF3n inv\xE1lida",invalidProgress:"Valor de progreso inv\xE1lido",unknownCommand:"Comando desconocido",processingError:"Error procesando el comando"}},export:{projectName:"Proyecto Gantt",ganttTasks:"Tareas Gantt",taskId:"ID de Tarea",taskName:"Nombre de Tarea",startDate:"Fecha Inicio",endDate:"Fecha Fin",isMilestone:"Es Hito",parentId:"ID Padre",yes:"S\xED",no:"No",noTasksToExport:"No hay tareas disponibles para exportar"},dateFormat:{short:"dd/MM",medium:"d MMM",long:"d de MMMM de yyyy"}},Ts={en:Ko,es:Ql};function ed(e){return Ts[e]||Ts.en}function Ds(e,t){let a=ed(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 jr=createContext(Ko);function mo(){return useContext(jr)}function ag({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:l}){let[c,p]=useState(false),[n,m]=useState(null),d=useRef(null),i=mo();if(useEffect(()=>{let g=k=>{d.current&&!d.current.contains(k.target)&&p(false);};return c&&document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[c]),!(t||a||r||o||s||l))return null;let x=[{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:l}].filter(g=>g.handler),f=async(g,k)=>{if(k){m(g);try{await k();}catch(h){console.error(`Export ${g} failed:`,h);}finally{m(null),p(false);}}};return jsxs("div",{ref:d,className:"relative",children:[jsxs(motion.button,{onClick:()=>p(!c),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:c?e.accent:e.bgSecondary,border:`1px solid ${c?e.accent:e.borderLight}`,color:c?"#FFFFFF":e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{scale:1.02,backgroundColor:e.accent,color:"#FFFFFF"},whileTap:{scale:.98},children:[jsx(Download,{className:"w-3.5 h-3.5"}),jsx("span",{children:i.toolbar.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:c?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:c&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute right-0 mt-2 w-48 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:x.map((g,k)=>jsxs(motion.button,{onClick:()=>f(g.id,g.handler),disabled:n!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:k<x.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:k*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:n===g.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):g.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:g.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:g.description})]})]},g.id))})})})]})}function rg({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 l=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:l?r.textPrimary:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:l?600:500,zIndex:l?2:1},whileHover:{scale:1.02},whileTap:{scale:.98},children:[l&&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:l?"#FFFFFF":r.textTertiary},children:s.icon}),jsx("span",{className:"relative z-10",style:{color:l?"#FFFFFF":r.textTertiary},children:s.label})]},s.value)})})}function og({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 ng({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),l=mo();useEffect(()=>{let n=m=>{s.current&&!s.current.contains(m.target)&&o(false);};return r&&document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=[{value:"compact",label:l.toolbar.compact||"Compact"},{value:"comfortable",label:l.toolbar.normal||"Normal"},{value:"spacious",label:l.toolbar.spacious||"Spacious"}],p=c.find(n=>n.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:`${l.toolbar.density||"Density"}: ${p}`,children:jsx(Rows3,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute left-0 mt-2 w-36 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:c.map((n,m)=>{let d=t===n.value;return jsxs(motion.button,{onClick:()=>{a(n.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:m<c.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:m*.03},children:[jsx("span",{className:"text-xs",style:{color:d?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:d?600:500},children:n.label}),d&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},n.value)})})})})]})}function Yo({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:l,rowDensity:c,onRowDensityChange:p,showThemeSelector:n=false,showCreateTaskButton:m=false,createTaskLabel:d,onCreateTask:i,onExportPNG:u,onExportPDF:x,onExportExcel:f,onExportCSV:g,onExportJSON:k,onExportMSProject:h}){let b=mo(),y=u||x||f||g||k||h,D=[{value:"day",label:b.toolbar.day},{value:"week",label:b.toolbar.week},{value:"month",label:b.toolbar.month}],N=[{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(og,{options:D,value:t,onChange:A=>a(A),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(ng,{theme:e,value:c,onChange:p})]}),jsxs("div",{className:"flex items-center gap-3",children:[m&&i&&jsxs(Fragment,{children:[jsxs(motion.button,{onClick:i,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||b.toolbar.createTask})]}),(y||n)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),y&&jsxs(Fragment,{children:[jsx(ag,{theme:e,onExportPNG:u,onExportPDF:x,onExportExcel:f,onExportCSV:g,onExportJSON:k,onExportMSProject:h}),n&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),n&&jsx(rg,{options:N,value:s,onChange:A=>l(A),theme:e})]})]})}function qo({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,l]=useState({x:0,y:0}),c=useRef(null),p=useRef(null);useEffect(()=>{if(!r)return;let m=d=>{c.current&&!c.current.contains(d.target)&&o(false);};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[r]);let n=e.filter(m=>m.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:p,onClick:()=>{if(!r&&p.current){let m=p.current.getBoundingClientRect();l({x:m.left,y:m.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(rt,{children:jsx(motion.div,{ref:c,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15},className:"column-manager-menu fixed min-w-[180px] rounded-lg shadow-xl z-[9999]",style:{left:`${s.x}px`,top:`${s.y}px`,backgroundColor:a.bgSecondary,border:`1px solid ${a.border}`},children:jsxs("div",{className:"py-1",children:[jsx("div",{className:"px-3 py-2 text-xs uppercase tracking-wider",style:{color:a.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600},children:"Add Column"}),n.map(m=>jsxs("button",{onClick:()=>{t(m.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:m.label}),m.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},m.id))]})})})})]})}function Kr({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let l=useRef(null),[c,p]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let m=200,d=r.length*36+8,i=8,u=window.innerWidth,x=window.innerHeight,f=t,g=a;t+m+i>u&&(f=t-m,f<i&&(f=i)),a+d+i>x&&(g=x-d-i,g<i&&(g=i)),p({x:f,y:g});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let m=i=>{l.current&&!l.current.contains(i.target)&&o();},d=i=>{i.key==="Escape"&&o();};return document.addEventListener("mousedown",m),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",d);}},[e,o]),!e)return null;let n=m=>m.startsWith("#")&&(m.length===7||m.length===4)?m: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:l,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed z-[9999] min-w-[200px] rounded-lg",style:{left:`${c.x}px`,top:`${c.y}px`,backgroundColor:n(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(m=>jsxs("div",{children:[m.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{m.disabled||(m.onClick(),o());},disabled:m.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:m.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:m.disabled?"not-allowed":"pointer",opacity:m.disabled?.5:1},onMouseEnter:d=>{m.disabled||(d.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[m.icon&&jsx("span",{style:{color:s.textSecondary},children:m.icon}),jsx("span",{className:"flex-1",children:m.label}),m.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},m.id))})})})}var Ct={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 ud({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:l,onTaskIndent:c,onTaskOutdent:p,onTaskRename:n,onTaskToggleExpand:m,onOpenTaskModal:d,enableKeyboard:i=true}){let u=useRef(false),x=useCallback(b=>{u.current=b;},[]),f=useCallback(b=>{let y=[],D=N=>{for(let A of N)y.push(A),A.subtasks&&A.subtasks.length>0&&A.isExpanded&&D(A.subtasks);};return D(b),y},[]),g=useCallback(()=>{let b=f(e);for(let y of b)if(t.has(y.id))return y;return null},[e,t,f]),k=useCallback((b,y)=>{let D=f(e);if(D.length===0)return;let N=g();if(!N){a(D[0].id,false);return}let A=D.findIndex(T=>T.id===N.id);if(A===-1)return;let v=b==="up"?A-1:A+1;if(v<0||v>=D.length)return;let B=D[v];a(B.id,y);},[e,g,f,a]),h=useCallback(b=>{if(!i)return;let y=b.target;if(y.tagName==="INPUT"||y.tagName==="TEXTAREA"||y.isContentEditable||u.current){b.key==="Escape"&&(y.blur(),u.current=false);return}let A=navigator.platform.toUpperCase().indexOf("MAC")>=0?b.metaKey:b.ctrlKey,v=Array.from(t),B=g();if(b.key==="ArrowUp"){b.preventDefault(),k("up",b.shiftKey);return}if(b.key==="ArrowDown"){b.preventDefault(),k("down",b.shiftKey);return}if(B&&(b.key==="ArrowRight"||b.key==="ArrowLeft")){B.subtasks&&B.subtasks.length>0&&(b.preventDefault(),(b.key==="ArrowRight"&&!B.isExpanded||b.key==="ArrowLeft"&&B.isExpanded)&&m(B.id));return}if(b.altKey&&(b.key==="ArrowUp"||b.key==="ArrowDown")){v.length>0&&(b.preventDefault(),l(v,b.key==="ArrowUp"?"up":"down"));return}if(b.key==="Tab"&&!b.shiftKey){v.length>0&&(b.preventDefault(),c(v));return}if(b.key==="Tab"&&b.shiftKey){v.length>0&&(b.preventDefault(),p(v));return}if(b.key==="Enter"&&!b.shiftKey&&!A){B&&(b.preventDefault(),r(B.id,"below"));return}if(b.key==="Enter"&&b.shiftKey&&!A){B&&(b.preventDefault(),r(B.id,"above"));return}if(b.key==="Enter"&&A){B&&(b.preventDefault(),d(B.id));return}if(b.key==="F2"){B&&(b.preventDefault(),n(B.id));return}if(b.key==="Delete"||b.key==="Backspace"&&A){v.length>0&&(b.preventDefault(),o(v));return}if(b.key==="d"&&A&&!b.shiftKey){v.length>0&&(b.preventDefault(),s(v));return}},[i,t,g,k,r,o,s,l,c,p,n,m,d]);return useEffect(()=>{if(i)return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h);}},[i,h]),{setIsEditing:x}}function fd(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(d=>{t(new Set([d])),r(d);},[]),s=useCallback(d=>{t(i=>{let u=new Set(i);return u.has(d)?u.delete(d):u.add(d),u}),r(d);},[]),l=useCallback((d,i)=>{if(!a){o(d);return}let u=i.indexOf(a),x=i.indexOf(d);if(u===-1||x===-1){o(d);return}let f=Math.min(u,x),g=Math.max(u,x),k=i.slice(f,g+1);t(new Set(k)),r(d);},[a,o]),c=useCallback((d,i,u,x)=>{x?l(d,i):u?s(d):o(d);},[o,s,l]),p=useCallback((d,i)=>{i?t(u=>{let x=new Set(u);return x.add(d),x}):o(d);},[o]),n=useCallback(()=>{t(new Set),r(null);},[]),m=useCallback(d=>e.has(d),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:l,handleTaskClick:c,handleKeyboardSelection:p,clearSelection:n,isTaskSelected:m}}function Yr(e){let t=[],a=(r,o,s=0)=>{for(let l=0;l<r.length;l++){let c={...r[l],parentId:o,level:s,position:l};t.push(c),c.subtasks&&c.subtasks.length>0&&c.isExpanded&&a(c.subtasks,c.id,s+1);}};return a(e),t}function hd(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=hd(a.subtasks,t);if(r)return r}}return null}function Es(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=Es(a.subtasks,t);if(r)return r}return null}function Ps(e,t){if(t.length===0)return e;let a=Yr(e),r=t[0],o=a.findIndex(d=>d.id===r);if(o<=0)return e;let s=a[o-1],l=(d,i)=>{let u=[];return {tasks:d.filter(f=>{if(i.has(f.id))return u.push(f),false;if(f.subtasks){let g=l(f.subtasks,i);f.subtasks=g.tasks,u.push(...g.removed);}return true}),removed:u}},c=(d,i,u)=>d.map(x=>x.id===i?{...x,subtasks:[...x.subtasks||[],...u],isExpanded:true}:x.subtasks?{...x,subtasks:c(x.subtasks,i,u)}:x),p=new Set(t),{tasks:n,removed:m}=l(e,p);return c(n,s.id,m)}function Ms(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=Es(a,r);if(!o)continue;let s=Es(a,o.id),l=(n,m,d)=>{for(let i=0;i<n.length;i++){let u=n[i];if(u.id===m&&u.subtasks){let x=u.subtasks.findIndex(f=>f.id===d);if(x!==-1){let[f]=u.subtasks.splice(x,1);return f}}if(u.subtasks){let x=l(u.subtasks,m,d);if(x)return x}}return null},c=(n,m,d)=>{let i=n.findIndex(u=>u.id===m);if(i!==-1)return n.splice(i+1,0,d),n;for(let u of n)u.subtasks&&c(u.subtasks,m,d);return n},p=l(a,o.id,r);p&&(s&&s.subtasks?c(s.subtasks,o.id,p):c(a,o.id,p));}return a}function As(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(l,c,p)=>{let n=l.findIndex(d=>d.id===c);if(n===-1){for(let d of l)if(d.subtasks&&s(d.subtasks,c,p))return true;return false}let m=p==="up"?n-1:n+1;return m<0||m>=l.length?false:([l[n],l[m]]=[l[m],l[n]],true)};return s(r,o,a),r}function Is(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 Ls(e,t){let a=[...e];for(let r of t){let o=l=>{let c=l.findIndex(m=>m.id===r);if(c===-1){for(let m of l)if(m.subtasks&&o(m.subtasks))return true;return false}let p=l[c],n={...p,id:`${p.id}-copy-${Date.now()}`,name:`${p.name} (Copy)`,subtasks:p.subtasks?s(p.subtasks):void 0};return l.splice(c+1,0,n),true},s=l=>l.map(c=>({...c,id:`${c.id}-copy-${Date.now()}`,subtasks:c.subtasks?s(c.subtasks):void 0}));o(a);}return a}function bd(e,t,a){let r=[...e],o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let l={id:`task-${Date.now()}`,name:"New Task",progress:0,status:"todo",startDate:o,endDate:s,color:"#6366F1"},c=p=>{let n=p.findIndex(d=>d.id===t);if(n===-1){for(let d of p)if(d.subtasks&&c(d.subtasks))return true;return false}let m=a==="above"?n:n+1;return p.splice(m,0,l),true};return c(r),{tasks:r,newTask:l}}function Fs(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:Fs(r.subtasks,t,a)}:r)}function Bs(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:Bs(a.subtasks,t)}:a)}function Rs(e,t){let a=m=>{for(let d of m){if(d.id===t)return d;if(d.subtasks){let i=a(d.subtasks);if(i)return i}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let l=r?.startDate||o,c=r?.endDate||s,p={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(l),endDate:new Date(c),color:r?.color||"#3B82F6"},n=m=>m.map(d=>{if(d.id===t){let i=d.subtasks||[];return {...d,subtasks:[...i,p],isExpanded:true}}return d.subtasks?{...d,subtasks:n(d.subtasks)}:d});return {tasks:n(e),newTask:p}}function yd(e,t,a,r){if(t===a)return e;let o=hd(e,t);if(!o)return e;if(a){let c=(p,n)=>{if(!p.subtasks)return false;for(let m of p.subtasks)if(m.id===n||c(m,n))return true;return false};if(c(o,a))return e}let s=c=>c.filter(p=>p.id!==t).map(p=>p.subtasks&&p.subtasks.length>0?{...p,subtasks:s(p.subtasks)}:p),l=s(e);if(a===null){let c=r!==void 0?r:l.length;l.splice(c,0,{...o,parentId:void 0});}else {let c=p=>p.map(n=>{if(n.id===a){let m=n.subtasks||[],d=r!==void 0?r:m.length,i=[...m];return i.splice(d,0,{...o,parentId:a}),{...n,subtasks:i,isExpanded:true}}return n.subtasks&&n.subtasks.length>0?{...n,subtasks:c(n.subtasks)}:n});l=c(l);}return l}function Zo({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:l,onTaskContextMenu:c,onTaskToggle:p,scrollTop:n,columns:m,onToggleColumn:d,onColumnResize:i,onTaskUpdate:u,onTaskIndent:x,onTaskOutdent:f,onTaskMove:g,onMultiTaskDelete:k,onTaskDuplicate:h,onTaskCreate:b,onTaskRename:y,onCreateSubtask:D,onOpenTaskModal:N,onDeleteRequest:A,onTaskReparent:v}){let B=useContext(jr),[T,w]=useState(null),[R,P]=useState(null),[H,q]=useState(""),he=useRef(null),[xe,Ae]=useState(null),[Be,$]=useState(0),[F,W]=useState(0),[E,K]=useState({isOpen:false,x:0,y:0,type:"header"}),[X,U]=useState(null),[De,ke]=useState(null),[$e,be]=useState(null),tt=useRef(0),Pe=5,et=useRef(false),[ht,Dt]=useState(null),[dt,O]=useState(false),[re,de]=useState(null),[Ce,Ee]=useState(false),at=useRef(null);useEffect(()=>{function V(Z){at.current&&!at.current.contains(Z.target)&&Ee(false);}if(Ce)return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[Ce]),useEffect(()=>{R&&he.current&&(he.current.focus(),he.current.select());},[R]),useEffect(()=>{if(!xe)return;let V=nt=>{let fe=nt.clientX-Be,Ue=F+fe;i?.(xe,Ue);},Z=()=>{Ae(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",V),document.addEventListener("mouseup",Z),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",V),document.removeEventListener("mouseup",Z),document.body.style.cursor="",document.body.style.userSelect="";}},[xe,Be,F,i]);let{selectedTaskIds:ut,handleTaskClick:Ie,isTaskSelected:I}=fd(),{setIsEditing:Y}=ud({tasks:e,selectedTaskIds:ut,onTaskSelect:(V,Z)=>{let fe=Yr(e).map(Ue=>Ue.id);Ie(V,fe,Z||false,false);},onTaskCreate:b||(()=>{}),onTaskDelete:k||(()=>{}),onTaskDuplicate:h||(()=>{}),onTaskMove:g||(()=>{}),onTaskIndent:x||(()=>{}),onTaskOutdent:f||(()=>{}),onTaskRename:V=>{let Z=Yr(e).find(nt=>nt.id===V);Z&&te(Z);},onTaskToggleExpand:p||(()=>{}),onOpenTaskModal:V=>{let Z=Yr(e).find(nt=>nt.id===V);Z&&N&&N(Z);},enableKeyboard:true}),He=(V,Z=0)=>{let nt=[];for(let fe of V)nt.push({task:fe,level:Z}),fe.subtasks&&fe.subtasks.length>0&&fe.isExpanded&&nt.push(...He(fe.subtasks,Z+1));return nt},We=He(e),yt=48,Q=V=>!V.startDate||!V.endDate?"-":`${Math.ceil((V.endDate.getTime()-V.startDate.getTime())/(1e3*60*60*24))}d`,te=V=>{P(V.id),q(V.name),Y(true);},ve=V=>{H.trim()&&H!==e.find(Z=>Z.id===V)?.name&&y?.(V,H.trim()),P(null),q(""),Y(false);},Te=()=>{P(null),q(""),Y(false);},oe=(V,Z)=>{Z.stopPropagation(),D?.(V.id);},Se=(V,Z)=>{Z.preventDefault(),tt.current=Z.clientY,U(V),et.current=false,O(false),Dt({x:Z.clientX,y:Z.clientY});},ye=V=>{if(!X||(Math.abs(V.clientY-tt.current)>Pe&&!et.current&&(et.current=true,O(true)),Dt({x:V.clientX,y:V.clientY}),!et.current))return;let nt=document.querySelectorAll("[data-task-row]"),fe=null,Ue=null;nt.forEach(Je=>{let z=Je.getBoundingClientRect(),ne=Je.getAttribute("data-task-row");if(ne&&ne!==X&&V.clientY>=z.top&&V.clientY<=z.bottom){fe=ne;let Ge=V.clientY-z.top,Ke=z.height;Ge<Ke*.25?Ue="above":Ge>Ke*.75?Ue="below":Ue="child";}}),ke(fe),be(Ue);},Ne=()=>{if(et.current&&X&&De&&$e){if($e==="child")v?.(X,De);else if($e==="above"||$e==="below"){let V=(fe,Ue,Je=null)=>{for(let z of fe){if(z.id===Ue)return Je;if(z.subtasks){let ne=V(z.subtasks,Ue,z.id);if(ne!==void 0)return ne}}},Z=V(e,De,null),nt=(fe,Ue)=>{let Je=fe.findIndex(z=>z.id===Ue);return $e==="below"?Je+1:Je};if(Z===null){let fe=nt(e,De);v?.(X,null,fe);}else {let fe=We.find(Ue=>Ue.task.id===Z)?.task;if(fe?.subtasks){let Ue=nt(fe.subtasks,De);v?.(X,Z,Ue);}}}}U(null),ke(null),be(null),Dt(null),et.current=false,O(false);};useEffect(()=>{if(X)return document.addEventListener("mousemove",ye),document.addEventListener("mouseup",Ne),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",ye),document.removeEventListener("mouseup",Ne),document.body.style.cursor="",document.body.style.userSelect="";}},[X,De,$e]);let ie=(V,Z,nt)=>{switch(V.id){case "name":let fe=R===Z.id,Ue=T===Z.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${nt*20}px`},children:[v&&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:Ue?1:.3},onMouseDown:pe=>Se(Z.id,pe),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),Z.subtasks&&Z.subtasks.length>0?jsx("button",{onClick:pe=>{pe.stopPropagation(),p?.(Z.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:Z.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:Z.color||"#3B82F6",opacity:Z.parentId?.6:1,borderColor:Z.isMilestone?t.accent:"transparent",borderWidth:Z.isMilestone?"2px":"0px"},title:Z.isMilestone?"Milestone":Z.parentId?"Subtask":"Task"})}),fe?jsx("input",{ref:he,type:"text",value:H,onChange:pe=>q(pe.target.value),onKeyDown:pe=>{pe.key==="Enter"?ve(Z.id):pe.key==="Escape"&&Te();},onBlur:()=>ve(Z.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:pe=>pe.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:Z.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:Z.parentId?"13px":"14px",fontWeight:Z.isMilestone?600:Z.parentId?400:600,letterSpacing:Z.parentId?"0":"-0.01em"},title:Z.name,children:Z.name}),Ue&&!fe&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:pe=>pe.stopPropagation(),children:[jsx("button",{onClick:pe=>oe(Z,pe),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:pe=>{pe.stopPropagation(),te(Z);},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 z=V.id==="startDate"?"startDate":"endDate",ne=Z[z],Ge=re?.taskId===Z.id&&re?.field===z,Ke=pe=>pe?(typeof pe=="string"?new Date(pe):pe).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):"-";return jsxs("div",{className:"flex items-center justify-center w-full relative",onClick:pe=>pe.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:pe=>{if(Ge)de(null);else {let Nt=pe.currentTarget.getBoundingClientRect();de({taskId:Z.id,field:z,month:ne?typeof ne=="string"?new Date(ne):ne:new Date,position:{top:Nt.bottom+4,left:Nt.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:Ke(ne)})]}),Ge&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>de(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:pe=>pe.stopPropagation(),children:[jsxs("div",{className:"w-36 py-2",style:{borderRight:`1px solid ${t.border}`},children:[(()=>{let pe=new Date,Nt=new Date(pe);Nt.setDate(pe.getDate()+1);let Jt=new Date(pe);Jt.setDate(pe.getDate()+7);let Ar=new Date(pe);return Ar.setDate(pe.getDate()+14),[{label:"Hoy",date:pe},{label:"Ma\xF1ana",date:Nt},{label:"Pr\xF3xima semana",date:Jt},{label:"2 semanas",date:Ar}].map((Lr,Ha)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:cr=>cr.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:cr=>cr.currentTarget.style.backgroundColor="transparent",onClick:()=>{u?.(Z.id,{[z]:Lr.date}),de(null);},children:Lr.label},Ha))})(),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:pe=>pe.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:pe=>pe.currentTarget.style.backgroundColor="transparent",onClick:()=>{u?.(Z.id,{[z]:void 0}),de(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:()=>de(pe=>pe?{...pe,month:new Date(pe.month.getFullYear(),pe.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:()=>de(pe=>pe?{...pe,month:new Date(pe.month.getFullYear(),pe.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((pe,Nt)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:pe},Nt))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let pe=re?.month||new Date,Nt=pe.getFullYear(),Jt=pe.getMonth(),Ar=new Date(Nt,Jt,1).getDay(),Ir=new Date(Nt,Jt+1,0).getDate(),Lr=new Date,Ha=[];for(let St=Ar-1;St>=0;St--)Ha.push({day:new Date(Nt,Jt,-St).getDate(),date:new Date(Nt,Jt-1,new Date(Nt,Jt,-St).getDate()),isCurrentMonth:false});for(let St=1;St<=Ir;St++)Ha.push({day:St,date:new Date(Nt,Jt,St),isCurrentMonth:true});let cr=42-Ha.length;for(let St=1;St<=cr;St++)Ha.push({day:St,date:new Date(Nt,Jt+1,St),isCurrentMonth:false});return Ha.map((St,Mn)=>{let An=St.date.toDateString()===Lr.toDateString(),Fr=(ne?typeof ne=="string"?new Date(ne):ne:null)?.toDateString()===St.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:St.isCurrentMonth?Fr?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:Fr?"#3B82F6":"transparent",boxShadow:An&&!Fr?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{u?.(Z.id,{[z]:St.date}),de(null);},children:St.day},Mn)})})()})]})]})]}),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:Q(Z)})});case "assignees":let aa=r.filter(pe=>Z.assignees?.some(Nt=>Nt.name===pe.name||Nt.initials===pe.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:pe=>pe.stopPropagation(),children:jsx(fr,{assignedUsers:aa,availableUsers:r,onChange:pe=>{let Nt=pe.map(Jt=>({id:Jt.id,name:Jt.name,initials:Jt.initials,color:Jt.color}));u?.(Z.id,{assignees:Nt.length>0?Nt:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:pe=>pe.stopPropagation(),children:jsx(gl,{status:Z.status||"todo",onChange:pe=>{u?.(Z.id,{status:pe,progress:pe==="completed"?100:Z.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:`${Z.progress}%`,backgroundColor:Z.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:[Z.progress,"%"]})]});case "priority":let dr={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},qa={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},Ra=dr[Z.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:pe=>pe.stopPropagation(),children:jsx(ur,{priority:Ra,onChange:pe=>{pe&&u?.(Z.id,{priority:qa[pe]||"medium"});}})});default:return null}},Fe=V=>[{id:"hide",label:"Hide Column",icon:Ct.Hide,onClick:()=>d(V),disabled:V==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:Ct.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:Ct.SortDesc,onClick:()=>{}}],Me=V=>V.subtasks&&V.subtasks.length>0?[{id:"addSubtask",label:B?.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{D?.(V.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:B?.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{A?A(V.id,V.name):k?.([V.id]);}}]:[{id:"edit",label:B?.contextMenu?.editTask||"Edit Task",icon:Ct.Pencil,onClick:()=>{l?.(V);}},{id:"addSubtask",label:B?.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{D?.(V.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:B?.contextMenu?.markIncomplete||"Mark Incomplete",icon:Ct.MarkIncomplete,onClick:()=>{u?.(V.id,{status:"todo",progress:0});},disabled:V.status==="todo"},{id:"setInProgress",label:B?.contextMenu?.setInProgress||"Set In Progress",icon:Ct.SetInProgress,onClick:()=>{u?.(V.id,{status:"in-progress"});},disabled:V.status==="in-progress"},{id:"markComplete",label:B?.contextMenu?.markComplete||"Mark Complete",icon:Ct.MarkComplete,onClick:()=>{u?.(V.id,{status:"completed",progress:100});},disabled:V.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:B?.contextMenu?.splitTask||"Split Task",icon:Ct.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:B?.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{A?A(V.id,V.name):k?.([V.id]);}}],Re=m.filter(V=>V.visible),Mt=Re.reduce((V,Z)=>V+Z.width,0)+60;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:`${yt}px`,paddingLeft:"3px",paddingRight:"60px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box",position:"relative"},children:[jsxs("div",{className:"flex items-center gap-1 px-2 flex-shrink-0",style:{height:"100%",position:"absolute",right:0,top:0,zIndex:5,backgroundColor:t.bgGrid},children:[jsx(qo,{columns:m,onToggleColumn:d,theme:t}),jsx("button",{onClick:()=>Ee(!Ce),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"})}),Ce&&jsxs("div",{ref:at,className:"absolute top-full right-0 mt-2 p-4 rounded-lg shadow-2xl z-50 min-w-[400px]",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,color:t.textPrimary},onClick:V=>V.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b",style:{borderColor:t.border},children:[jsx("h3",{className:"font-semibold text-sm",style:{color:t.textPrimary},children:"Keyboard Shortcuts"}),jsx("button",{onClick:()=>Ee(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"})]})]})]})]})]})]}),Re.map((V,Z)=>{let nt=Z===Re.length-1,fe=V.id==="name";return jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${fe?"":"justify-center"}`,style:{width:`${V.width}px`,minWidth:`${V.minWidth??(fe?200:60)}px`,maxWidth:`${V.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:nt?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:Ue=>{Ue.preventDefault(),K({isOpen:true,x:Ue.clientX,y:Ue.clientY,type:"header",columnId:V.id});},onMouseEnter:Ue=>{Ue.currentTarget.style.backgroundColor=t.hoverBg;},onMouseLeave:Ue=>{Ue.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:xe===V.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:Ue=>{Ue.preventDefault(),Ue.stopPropagation(),Ae(V.id),$(Ue.clientX),W(V.width);},title:"Drag to resize column",children:jsx("div",{className:"absolute top-2 bottom-2 opacity-0 group-hover:opacity-100 transition-opacity",style:{left:"3px",width:"2px",backgroundColor:t.accent,borderRadius:"1px"}})})]},V.id)})]}),jsx("div",{className:"gantt-taskgrid-content",children:We.map(({task:V,level:Z},nt)=>{let fe=I(V.id),Ue=De===V.id,Je=Ue&&$e==="above",z=Ue&&$e==="below",ne=Ue&&$e==="child",Ge={};return ne&&(Ge.backgroundColor=`${t.accent}15`,Ge.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":V.id,className:`flex items-center cursor-pointer group ${X===V.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:fe?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:fe?t.accentLight:ne?`${t.accent}15`:nt%2===0?t.bgPrimary:t.bgGrid,...Ge},onMouseEnter:()=>w(V.id),onMouseLeave:()=>w(null),onClick:Ke=>{let dr=Yr(e).map(pe=>pe.id),Ra=navigator.platform.toUpperCase().indexOf("MAC")>=0?Ke.metaKey:Ke.ctrlKey;Ie(V.id,dr,Ra,Ke.shiftKey),s?.(V);},onDoubleClick:Ke=>{Ke.stopPropagation(),l?.(V);},onContextMenu:Ke=>{Ke.preventDefault(),K({isOpen:true,x:Ke.clientX,y:Ke.clientY,type:"task",task:V}),c?.(V,Ke);},whileHover:{backgroundColor:fe?t.accentLight:t.hoverBg},children:[Je&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),z&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),Re.map((Ke,aa)=>{let dr=aa===Re.length-1,qa=Ke.id==="name";return jsx("div",{className:`px-4 flex items-center ${qa?"justify-start":"justify-center"}`,style:{width:`${Ke.width}px`,minWidth:`${Ke.minWidth??(qa?200:60)}px`,maxWidth:`${Ke.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:dr?"none":`1px solid ${T===V.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:ie(Ke,V,qa?Z:0)},`${V.id}-${Ke.id}`)})]},V.id)})}),jsx(Kr,{isOpen:E.isOpen,x:E.x,y:E.y,items:E.type==="header"&&E.columnId?Fe(E.columnId):E.type==="task"&&E.task?Me(E.task):[],onClose:()=>K({...E,isOpen:false}),theme:t}),dt&&ht&&X&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:ht.x+12,top:ht.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let V=We.find(Z=>Z.task.id===X)?.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 Cd(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[l,c]=useState(e),[p,n]=useState(t),[m,d]=useState(null),[i,u]=useState(null),[x,f]=useState(null),[g,k]=useState(null),[h,b]=useState(0),[y,D]=useState(0),[N,A]=useState(null),[v,B]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:l,setGhostX:c,ghostWidth:p,setGhostWidth:n,connectionLine:m,setConnectionLine:d,hoveredTaskId:i,setHoveredTaskId:u,activeZone:x,setActiveZone:f,draggedSegmentIndex:g,setDraggedSegmentIndex:k,draggedSegmentStartX:h,setDraggedSegmentStartX:b,segmentDragOffsetX:y,setSegmentDragOffsetX:D,hoveredSegmentIndex:N,setHoveredSegmentIndex:A,isHovered:v,setIsHovered:B,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(H,q)=>{r("none"),d(null),u(null),c(H),n(q),D(0),k(null),b(0);}}}function Qo({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:l,templates:c,onClick:p,onDoubleClick:n,onContextMenu:m,onDateChange:d,onDependencyCreate:i,allTaskPositions:u=[],onDragMove:x,onHoverChange:f}){let g=Cd(t,r),k=useRef(null),{dragMode:h,setDragMode:b,dragOffset:y,setDragOffset:D,ghostX:N,setGhostX:A,ghostWidth:v,setGhostWidth:B,connectionLine:T,setConnectionLine:w,hoveredTaskId:R,setHoveredTaskId:P,activeZone:H,setActiveZone:q,draggedSegmentIndex:he,setDraggedSegmentIndex:xe,draggedSegmentStartX:Ae,setDraggedSegmentStartX:Be,segmentDragOffsetX:$,setSegmentDragOffsetX:F,hoveredSegmentIndex:W,setHoveredSegmentIndex:E,isHovered:K,setIsHovered:X,isDragging:U,isResizing:De,isConnecting:ke,resetDragState:$e}=g,be=32,tt=8,Pe=e.endDate&&e.endDate<new Date&&e.progress<100,et=e.isCriticalPath,ht=o.name==="neutral"||o.today==="#1C1917",Dt=e.status==="completed"||e.progress===100,dt={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},re=e.isCriticalPath||Pe?"#DC2626":e.color?e.color:e.priority&&dt[e.priority]?dt[e.priority]:o.taskBarPrimary,Ce=(oe=>oe>=80?20:oe>=60?15:oe>=50?12:10)(r),Ee=r<50,at=r<40;useEffect(()=>{if(f)if(K&&!U&&!e.segments){let oe=a<100;f({task:e,x:t,y:a,width:r,height:be,showBelow:oe});}else f(null);},[K,U,e,t,a,r,be,f]);let ut=oe=>oe.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Ie=()=>{let oe=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${oe} day${oe!==1?"s":""}`},I=oe=>Math.round(oe/s)*s,Y=oe=>{let Se=Math.round(oe/s),ye=new Date(l);return ye.setDate(ye.getDate()+Se),ye},He=(oe,Se)=>{for(let ye of u){if(ye.id===e.id)continue;let Ne=5;if(oe>=ye.x-Ne&&oe<=ye.x+ye.width+Ne&&Se>=ye.y-Ne&&Se<=ye.y+ye.height+Ne)return ye.id}return null},We=useCallback((oe,Se,ye)=>{oe.preventDefault(),oe.stopPropagation();let Ne=k.current?.ownerSVGElement;if(!Ne)return;let ie=Ne.createSVGPoint();ie.x=oe.clientX,ie.y=oe.clientY;let Fe=ie.matrixTransform(Ne.getScreenCTM()?.inverse()),Me=ye!==void 0?ye:t,Re=Se;if(!Re){let Mt=Fe.x-Me;oe.shiftKey?(Re="connect",w({x:t+r,y:a+be/2})):oe.ctrlKey||oe.metaKey?Re="move":oe.altKey?Re=Mt<r/2?"resize-start":"resize-end":at?Mt<r/2?Re="move":Re="resize-end":Ee?Mt<=Ce/2?Re="resize-start":Mt>=r-Ce/2?Re="resize-end":Re="move":Mt<=Ce?Re="resize-start":Mt>=r-Ce?Re="resize-end":Re="move";}b(Re),X(false),q(null),Re==="move"?D(Fe.x-Me):Re==="connect"?w({x:t+r,y:a+be/2}):D(0),A(Me),B(r);},[t,r,a,be]),yt=useCallback(oe=>{if(h==="none")return;let Se=k.current?.ownerSVGElement;if(!Se)return;let ye=Se.createSVGPoint();ye.x=oe.clientX,ye.y=oe.clientY;let Ne=ye.matrixTransform(Se.getScreenCTM()?.inverse());if(h==="connect"){w({x:Ne.x,y:Ne.y});let ie=He(Ne.x,Ne.y);P(ie);}else if(h==="move"){let ie=Ne.x-y,Fe=I(ie);A(Fe),B(r);let Me=Math.round((Fe-t)/s);if(x?.(e.id,Me,true),e.segments&&e.segments.length>0&&he!==null){let Re=Fe-Ae;F(Re);}}else if(h==="resize-start"){let ie=Ne.x,Fe=I(ie),Me=t+r-Fe;Me>=s&&(A(Fe),B(Me));}else if(h==="resize-end"){let ie=Ne.x,Me=I(ie)-t;Me>=s&&B(Me);}},[h,t,r,s,y,e,I,he,Ae,He,P,w,A,B,F,x]),Q=useCallback(()=>{if(h!=="none"){if(h==="connect")R&&i&&i(e,R),w(null),P(null);else {let oe=e.endDate.getTime()-e.startDate.getTime(),Se,ye,Ne=true;if(h==="move"){if(Se=Y(N),ye=new Date(Se.getTime()+oe),e.segments&&e.segments.length>0&&he!==null){let ie=Math.round($/s),Fe=e.segments.map((V,Z)=>{if(Z===he){let nt=new Date(V.startDate),fe=new Date(V.endDate);return nt.setDate(nt.getDate()+ie),fe.setDate(fe.getDate()+ie),{startDate:nt,endDate:fe}}return V}),Me=Fe.flatMap(V=>[V.startDate,V.endDate]),Re=new Date(Math.min(...Me.map(V=>V.getTime()))),Mt=new Date(Math.max(...Me.map(V=>V.getTime())));d?.({...e,segments:Fe},Re,Mt),$e(t,r);return}}else h==="resize-start"?(Se=Y(N),ye=e.endDate,Se>ye&&(console.warn("Invalid date range: start date must be before or equal to end date"),Ne=false)):h==="resize-end"?(Se=e.startDate,ye=Y(N+v),ye<Se&&(console.warn("Invalid date range: end date must be after or equal to start date"),Ne=false)):Ne=false;Ne&&Se&&ye&&(ye.getTime()<Se.getTime()?console.warn("Invalid date range: end date cannot be before start date"):d?.(e,Se,ye));}x?.(e.id,0,false),$e(t,r);}},[h,N,v,e,d,R,i,t,r,s,Y,$,he,$e,x]);useEffect(()=>{if(h==="none")return;let oe=ye=>{yt(ye);},Se=()=>{Q();};return window.addEventListener("mousemove",oe),window.addEventListener("mouseup",Se),()=>{window.removeEventListener("mousemove",oe),window.removeEventListener("mouseup",Se);}},[h,yt,Q]);let te=U&&!ke?N:t,ve=U&&!ke?v:r,Te=c.taskClass(e);return jsxs("g",{ref:k,onMouseEnter:()=>!U&&X(true),onMouseLeave:()=>{U||(X(false),q(null));},onClick:()=>!U&&p?.(e),onDoubleClick:oe=>{U||(oe.stopPropagation(),n?.(e));},onContextMenu:oe=>{oe.preventDefault(),m?.(e,oe);},children:[K&&!U&&!Ee&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:Ce,height:be,fill:H==="resize-start"?o.accent:"transparent",opacity:H==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>q("resize-start"),onMouseDown:oe=>We(oe,"resize-start")}),jsx("rect",{x:t+Ce,y:a,width:r-Ce*2,height:be,fill:H==="move"?o.accent:"transparent",opacity:H==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>q("move"),onMouseDown:oe=>We(oe,"move")}),jsx("rect",{x:t+r-Ce,y:a,width:Ce,height:be,fill:H==="resize-end"?o.accent:"transparent",opacity:H==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>q("resize-end"),onMouseDown:oe=>We(oe,"resize-end")})]}),K&&!U&&at&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:be,fill:H==="move"?o.accent:"transparent",opacity:H==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>q("move"),onMouseDown:oe=>We(oe,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:be,fill:H==="resize-end"?o.accent:"transparent",opacity:H==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>q("resize-end"),onMouseDown:oe=>We(oe,"resize-end")}),K&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+be-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),U&&!ke&&!e.segments&&jsx(motion.rect,{x:N,y:a,width:v,height:be,rx:tt,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:te,y:a,width:ve,height:be,rx:tt,fill:re,"data-task-class":Te,initial:{opacity:0,scale:.95},animate:{opacity:U&&!ke?.15:e.parentId?.6:K?.9:.8,scale:K&&!U?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:oe=>We(oe),style:{cursor:U?ke?"crosshair":De?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:te,y:a,width:ve*(e.progress/100),height:be,rx:tt,fill:re,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((oe,Se)=>{let ye=(oe.startDate.getTime()-l.getTime())/864e5*s,ie=(oe.endDate.getTime()-l.getTime())/(1e3*60*60*24)*s-ye+s,Fe=U&&h==="move"&&he===Se,Me=W===Se,Re=Fe?ye+$:ye;return jsxs("g",{onMouseEnter:()=>!U&&E(Se),onMouseLeave:()=>!U&&E(null),children:[jsx(motion.rect,{x:Re,y:a,width:ie,height:be,rx:tt,fill:re,initial:{opacity:0,scale:.95},animate:{opacity:Fe||e.parentId?.6:Me?.9:.8,scale:Me&&!U?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:Mt=>{Mt.stopPropagation(),xe(Se),Be(ye),We(Mt,void 0,ye);},style:{cursor:U?ke?"crosshair":De?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:Re,y:a,width:ie*(e.progress/100),height:be,rx:tt,fill:re,opacity:1,style:{pointerEvents:"none"}})]},`segment-${Se}`)}),ht&&(Pe||et)&&!e.segments&&jsxs(Fragment,{children:[et&&!Pe&&jsx("rect",{x:te,y:a,width:ve,height:be,rx:tt,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),Pe&&jsx("rect",{x:te,y:a,width:ve,height:be,rx:tt,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),ve>60&&!e.segments&&(()=>{let oe=c.taskLabel(e),Se=typeof oe=="string"?oe:e.name,ye=Se.length>Math.floor(ve/8)?`${Se.substring(0,Math.floor(ve/8))}...`:Se;return jsx("text",{x:te+12,y:a+be/2,dominantBaseline:"middle",fill:Dt?"rgba(255, 255, 255, 0.6)":"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none",textDecoration:Dt?"line-through":"none"},children:ye})})(),ve>100&&e.progress>0&&e.progress<100&&!U&&!e.segments&&jsxs("text",{x:te+ve-12,y:a+be/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&&ve>80&&!U&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:te+ve-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:te+ve-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(K||De)&&!ke&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:Ee?te-15:te-10,y:a-5,width:Ee?25:20,height:be+10,fill:"transparent",onMouseDown:oe=>We(oe,"resize-start"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ee?te-8:te-3,y:a+6,width:Ee?8:6,height:Ee?be-12:be-16,rx:3,fill:h==="resize-start"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:h==="resize-start"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]}),jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:te+ve-10,y:a-5,width:Ee?25:20,height:be+10,fill:"transparent",onMouseDown:oe=>We(oe,"resize-end"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ee?te+ve:te+ve-3,y:a+6,width:Ee?8:6,height:Ee?be-12:be-16,rx:3,fill:h==="resize-end"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:h==="resize-end"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]})]}),jsx(AnimatePresence,{children:K&&!U&&!e.segments&&jsxs(motion.g,{style:{pointerEvents:"all"},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[jsx(motion.circle,{cx:t+r+8,cy:a+be/2,r:6,fill:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},exit:{scale:0},transition:{duration:.2,type:"spring",stiffness:400,damping:25},onMouseDown:oe=>{oe.stopPropagation(),We(oe,"connect");},style:{cursor:"crosshair"}}),jsx("text",{x:t+r+20,y:a+be/2,dominantBaseline:"middle",fill:o.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:"Link"})]})}),ke&&T&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+be/2,x2:T.x,y2:T.y,stroke:R?o.statusCompleted:o.accent,strokeWidth:R?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:R?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:T.x,cy:T.y,r:R?8:6,fill:R?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),R&&jsx(motion.text,{x:T.x+15,y:T.y,dominantBaseline:"middle",fill:o.statusCompleted,fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",initial:{opacity:0,x:T.x+10},animate:{opacity:1,x:T.x+15},transition:{duration:.2},children:"Connect"})]}),(K||U)&&!ke&&!e.segments&&jsx(motion.rect,{x:te-2,y:a-2,width:ve+4,height:be+4,rx:tt+2,fill:"none",stroke:U?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:U?.6:.4,initial:{opacity:0},animate:{opacity:U?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),De&&jsxs(Fragment,{children:[jsx("line",{x1:N,y1:0,x2:N,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:N+v,y1:0,x2:N+v,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:K&&!U&&!e.segments&&!f&&(()=>{let ye=a<100,Ne=ye?a+be+13:a-82-13,ie=ye?`M ${te+ve/2-6} ${a+be+3} L ${te+ve/2} ${a+be+13} L ${te+ve/2+6} ${a+be+3}`:`M ${te+ve/2-6} ${a-13} L ${te+ve/2} ${a-3} L ${te+ve/2+6} ${a-13}`,Fe=Ne+22,Me=Ne+40,Re=Ne+55,Mt=Ne+70,V=ye?Ne+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:ye?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:ye?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:ie,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:te+ve/2-120,y:Ne,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:te+ve/2,y:Fe,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:te+ve/2-110,y:Me,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:te+ve/2-70,y:Me,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:ut(e.startDate)}),jsx("text",{x:te+ve/2-110,y:Re,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:te+ve/2-70,y:Re,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:ut(e.endDate)}),jsx("text",{x:te+ve/2+10,y:Me,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:te+ve/2+65,y:Me,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Ie()}),jsx("text",{x:te+ve/2+10,y:Re,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:te+ve/2+65,y:Re,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.progress,"%"]}),e.assignees&&e.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:te+ve/2-110,y:Mt,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:te+ve/2-50,y:Mt,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(Z=>Z.name).join(", ").substring(0,30),e.assignees.map(Z=>Z.name).join(", ").length>30?"...":""]})]}),!ye&&jsx("text",{x:te+ve/2,y:V,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:at?"Left: move \u2022 Right: resize":Ee?"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 Nd({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:l,showBelow:c}=e,p=82,n=13,m=c?o+l+n:o-p-n,d=c?`M ${r+s/2-6} ${o+l+3} L ${r+s/2} ${o+l+13} L ${r+s/2+6} ${o+l+3}`:`M ${r+s/2-6} ${o-13} L ${r+s/2} ${o-3} L ${r+s/2+6} ${o-13}`,i=m+22,u=m+40,x=m+55,f=m+70,g=y=>y.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),k=()=>{if(!a.startDate||!a.endDate)return "N/A";let y=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${y} day${y!==1?"s":""}`};return jsx(AnimatePresence,{children:jsxs(motion.g,{initial:{opacity:0,y:c?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:c?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:m,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:i,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:u,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y:u,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?g(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y:x,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y:x,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?g(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y:u,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y:u,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:k()}),jsx("text",{x:r+s/2+10,y:x,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y:x,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:f,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:r+s/2-50,y:f,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.assignees.map(y=>y.name).join(", ").substring(0,30),a.assignees.map(y=>y.name).join(", ").length>30?"...":""]})]})]})})}function an({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,onHoverChange:l}){let[c,p]=useState(false),n=a-e,m=r-t,d=e+n/2,i=`M ${e} ${t} C ${d} ${t}, ${d} ${r}, ${a} ${r}`,u=6,x=Math.atan2(m,n),f=a-u*Math.cos(x-Math.PI/6),g=r-u*Math.sin(x-Math.PI/6),k=a-u*Math.cos(x+Math.PI/6),h=r-u*Math.sin(x+Math.PI/6),b=o.dependency;useEffect(()=>{l&&s&&l(c?{x1:e,y1:t,x2:a,y2:r,onDelete:s}:null);},[c,e,t,a,r,s,l]);let y=!s&&!l;return jsxs("g",{onMouseEnter:()=>!y&&p(true),onMouseLeave:()=>!y&&p(false),style:{pointerEvents:y?"none":"auto"},children:[!y&&jsx("path",{d:i,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx(motion.path,{d:i,fill:"none",stroke:b,strokeWidth:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:c&&l?0:c?1:.8,strokeWidth:c?2.5:2},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2},strokeWidth:{duration:.2}}}),jsx(motion.path,{d:`M ${a} ${r} L ${f} ${g} M ${a} ${r} L ${k} ${h}`,fill:"none",stroke:b,strokeWidth:2,strokeLinecap:"round",initial:{opacity:0,scale:.8},animate:{opacity:c&&l?0:c?1:.8,scale:c?1.1:1,strokeWidth:c?2.5:2},transition:{duration:.2}}),jsx(motion.circle,{cx:a,cy:r,r:3,fill:b,initial:{scale:0},animate:{scale:c&&l?0:c?1.3:1,opacity:c&&l?0:c?1:.8},transition:{scale:{delay:.3,duration:.15},opacity:{duration:.2}}}),c&&s&&!l&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:D=>{D.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:d,cy:(t+r)/2,r:10,fill:o.bgSecondary,stroke:o.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:d-4,y1:(t+r)/2-4,x2:d+4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:d+4,y1:(t+r)/2-4,x2:d-4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})}function on({task:e,x:t,y:a,theme:r,onClick:o}){let[s,l]=useState(false),c=16,p=n=>n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),onClick:()=>o?.(e),style:{cursor:"pointer"},children:[e.isCriticalPath&&jsx(motion.circle,{cx:t,cy:a+16,r:c+4,fill:r.criticalPathLight,initial:{scale:0},animate:{scale:s?1.2:1},transition:{duration:.3}}),jsx(motion.rect,{x:t-c/2,y:a+16-c/2,width:c,height:c,fill:e.isCriticalPath?r.criticalPath:r.milestone,stroke:r.bgGrid,strokeWidth:2,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:0,rotate:0},animate:{scale:s?1.15:1,rotate:45},transition:{duration:.3,type:"spring",stiffness:300,damping:20}}),s&&jsx(motion.rect,{x:t-(c+4)/2,y:a+16-(c+4)/2,width:c+4,height:c+4,fill:"none",stroke:e.isCriticalPath?r.criticalPath:r.milestone,strokeWidth:2,opacity:.5,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:.8,opacity:0},animate:{scale:1,opacity:.5},transition:{duration:.2}}),jsx(AnimatePresence,{children:s&&jsxs(motion.g,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.2},children:[jsx("rect",{x:t-80,y:a-50,width:160,height:44,rx:8,fill:r.bgSecondary,stroke:r.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("path",{d:`M ${t-6} ${a-6} L ${t} ${a+4} L ${t+6} ${a-6}`,fill:r.bgSecondary,stroke:r.border,strokeWidth:1}),jsx("rect",{x:t-70,y:a-38,width:8,height:8,fill:e.isCriticalPath?r.criticalPath:r.milestone,transform:`rotate(45 ${t-66} ${a-34})`}),jsx("text",{x:t-55,y:a-32,fill:r.textPrimary,fontSize:"12",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>18?`${e.name.substring(0,18)}...`:e.name}),jsx("text",{x:t-55,y:a-18,fill:r.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",children:p(e.startDate)}),e.isCriticalPath&&jsxs("g",{children:[jsx("rect",{x:t+10,y:a-40,width:60,height:16,rx:4,fill:r.criticalPathLight}),jsx("text",{x:t+40,y:a-30,textAnchor:"middle",fill:r.criticalPath,fontSize:"9",fontWeight:"700",fontFamily:"Inter, sans-serif",letterSpacing:"0.5",children:"CRITICAL"})]})]})})]})}var le={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=n=>{n.forEach(m=>{m.dependencies&&r.set(m.id,m.dependencies),m.subtasks&&o(m.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let l=new Set,c=new Set,p=n=>{if(!l.has(n)){l.add(n),c.add(n);let m=r.get(n)||[];for(let d of m){if(!l.has(d)&&p(d))return true;if(c.has(d))return true}}return c.delete(n),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=le.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=le.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=le.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=le.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=
|
|
111
|
+
- [ ] `,priority:"MEDIUM",labels:["meeting"]}}];function ps({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),l=useRef(null);useEffect(()=>{function n(m){s.current&&!s.current.contains(m.target)&&l.current&&!l.current.contains(m.target)&&o(false);}if(r)return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=n=>{t(n),o(false);},p=e.reduce((n,m)=>{let d=m.category||"Other";return n[d]||(n[d]=[]),n[d].push(m),n},{});return jsxs("div",{className:C("relative inline-block",a),children:[jsxs("button",{ref:l,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:n=>{n.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",n.currentTarget.style.borderColor="var(--theme-border-secondary)";},onMouseLeave:n=>{n.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",n.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:C("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(([n,m])=>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:n})}),jsx("div",{children:m.map(d=>jsxs("button",{onClick:()=>c(d),className:"w-full px-4 py-3 flex items-start gap-3 text-left transition-all active:scale-[0.98]",style:{color:"var(--theme-text-primary)"},onMouseEnter:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:i=>{i.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))})]},n)),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 us({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[l,c]=useState("export"),[p,n]=useState("json"),[m,d]=useState(null),i=useRef(null);if(!t)return null;let u=async()=>{let f=o?.current||void 0,g=await _i(e,p,f);Vi(g,p);},x=async f=>{let g=f.target.files?.[0];if(g){try{let k=await Yi(g),h=g.name.endsWith(".json")?"json":"csv",b=Ki(k,h);d(b),b.success&&r&&r(b,k);}catch(k){d({success:false,errors:[`Failed to read file: ${k instanceof Error?k.message:"Unknown error"}`]});}i.current&&(i.current.value="");}};return jsxs("div",{className:C("fixed inset-0 z-[9999] flex items-center justify-center",s),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:a}),jsxs("div",{className:"relative bg-gradient-to-br from-gray-900/95 to-gray-800/95 backdrop-blur-xl rounded-2xl border border-white/20 shadow-2xl max-w-2xl w-full mx-4",children:[jsxs("div",{className:"px-6 py-5 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[jsx("span",{className:"text-3xl",children:"\u{1F4E6}"}),"Export / Import"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Transfer your board data"})]}),jsx("button",{onClick:a,className:"text-white/50 hover:text-white transition-colors text-2xl leading-none p-2 hover:bg-white/10 rounded-lg","aria-label":"Close",children:"\xD7"})]}),jsxs("div",{className:"flex border-b border-white/10",children:[jsx("button",{onClick:()=>c("export"),className:C("flex-1 px-6 py-4 font-semibold transition-colors",l==="export"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Export"}),jsx("button",{onClick:()=>c("import"),className:C("flex-1 px-6 py-4 font-semibold transition-colors",l==="import"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Import"})]}),jsxs("div",{className:"p-6",children:[l==="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(f=>jsxs("button",{onClick:()=>n(f),className:C("p-4 rounded-lg border-2 transition-all text-center",p===f?"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:[f==="json"&&"\u{1F4C4}",f==="csv"&&"\u{1F4CA}",f==="pdf"&&"\u{1F4DD}"]}),jsx("div",{className:"font-semibold uppercase text-xs",children:f})]},f))})]}),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:u,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"})]}),l==="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:i,type:"file",accept:".json,.csv",onChange:x,className:"hidden"}),jsxs("button",{onClick:()=>i.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"})]})]}),m&&jsxs("div",{className:C("p-4 rounded-lg",m.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:C("font-semibold mb-2",m.success?"text-green-400":"text-red-400"),children:m.success?"\u2713 Import Successful":"\u2717 Import Failed"}),m.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",m.cardsImported]}),jsxs("div",{children:["Columns imported: ",m.columnsImported]})]}),m.errors&&m.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:m.errors.map((f,g)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",f]},g))})]})]})]})]})]})}var Pu=["URGENT","HIGH","MEDIUM","LOW"],Mu=[{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"}],Au=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function gs({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:l,onFilterHighPriority:c,availableUsers:p=[],availableLabels:n=[],availableColumns:m=[],showQuickFilters:d=true,compact:i=false,groupBy:u="none",onGroupByChange:x}){let[f,g]=useState(true),k=useCallback(N=>{a({search:N.target.value});},[a]),h=useCallback(N=>{a({dateFilter:N.target.value});},[a]),b=useCallback(N=>{r({by:N.target.value});},[r]),y=useCallback(()=>{r({order:t.order==="asc"?"desc":"asc"});},[t.order,r]),D=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 ${i?"filter-bar--compact":""} ${f?"filter-bar--collapsed":""}`,children:[jsxs("div",{className:"filter-bar__header",onClick:()=>g(!f),style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:f?"0":"12px",padding:"4px 6px",borderRadius:"6px",transition:"all 0.2s ease"},onMouseEnter:N=>{N.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:N=>{N.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:f?"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"}),D&&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)"]})]}),!f&&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"}),l&&jsx("button",{onClick:l,className:"filter-bar__quick-btn",title:"Show overdue tasks",children:"Overdue"}),c&&jsx("button",{onClick:c,className:"filter-bar__quick-btn",title:"Show high priority tasks",children:"High Priority"})]}),jsxs("div",{className:"filter-bar__main",children:[jsx("div",{className:"filter-bar__field",children:jsx("input",{type:"text",placeholder:"Search tasks...",value:e.search,onChange:k,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:h,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:N=>{let A=N.target.value;a({priorities:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),Pu.map(N=>jsx("option",{value:N,children:N},N))]})}),p.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:N=>{let A=N.target.value;a({assignees:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),p.map(N=>jsx("option",{value:N.id,children:N.name},N.id))]})}),n.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:N=>{let A=N.target.value;a({labels:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),n.map(N=>jsx("option",{value:N,children:N},N))]})}),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:b,className:"filter-bar__select filter-bar__select--sm",children:Mu.map(N=>jsx("option",{value:N.value,children:N.label},N.value))}),t.by!=="none"&&jsx("button",{onClick:y,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),x&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:u,onChange:N=>x(N.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Au.map(N=>jsx("option",{value:N.value,children:N.label},N.value))})}),D&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function fs({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:l,onExportGanttPNG:c,onExportGanttCSV:p}){let[n,m]=useState(false),d=useRef(null);useEffect(()=>{let u=x=>{d.current&&!d.current.contains(x.target)&&m(false);};return n&&document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[n]);let i=u=>{u(),m(false);};return jsxs("div",{className:C("relative",r),ref:d,children:[jsxs("button",{onClick:()=>m(!n),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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",u.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",u.currentTarget.style.color="var(--theme-text-secondary)";},"aria-label":"Configuration Menu","aria-expanded":n,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"})]}),n&&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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(async()=>await l?.()),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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(async()=>await c?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(()=>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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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 hs={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"}},bs={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"}},ys={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"}},vr={dark:hs,light:bs,neutral:ys},Go="dark";var _o=createContext(void 0),Wu="asakaa-theme";function Xl({children:e,defaultTheme:t=Go,storageKey:a=Wu}){let[r,o]=useState(()=>{if(typeof window<"u"){let c=localStorage.getItem(a);if(c&&(c==="dark"||c==="light"||c==="neutral"))return c}return t}),s=useCallback(c=>{o(c),typeof window<"u"&&localStorage.setItem(a,c);},[a]);useEffect(()=>{if(typeof window>"u")return;let c=document.documentElement,p=vr[r];Object.entries(p.colors).forEach(([m,d])=>{d&&c.style.setProperty(`--theme-${Hu(m)}`,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(([m,d])=>{let i=p.colors[m];i&&c.style.setProperty(d,i);}),c.setAttribute("data-theme",r),c.classList.remove("theme-dark","theme-light","theme-neutral"),c.classList.add(`theme-${r}`);},[r]);let l={theme:r,setTheme:s,themes:vr};return jsx(_o.Provider,{value:l,children:e})}function $r(){let e=useContext(_o);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function Hu(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function vs({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=$r();return e?jsxs("div",{className:C("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(vr).map(([s,l])=>jsxs("button",{onClick:()=>{o(s),t();},className:C("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:l.emoji}),jsxs("div",{className:"text-left flex-1",children:[jsx("div",{className:"font-semibold",style:{color:"var(--theme-text-primary)"},children:l.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 Jl(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return _e[e]||_e.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,l)=>a.getPropertyValue(s).trim()||l;return {bgPrimary:r("--theme-bg-primary",_e[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",_e[e].bgSecondary),bgGrid:r("--theme-bg-card",_e[e].bgGrid),bgWeekend:r("--theme-bg-hover",_e[e].bgWeekend),border:r("--theme-border-primary",_e[e].border),borderLight:r("--theme-border-subtle",_e[e].borderLight),textPrimary:r("--theme-text-primary",_e[e].textPrimary),textSecondary:r("--theme-text-secondary",_e[e].textSecondary),textTertiary:r("--theme-text-tertiary",_e[e].textTertiary),accent:r("--theme-accent-primary",_e[e].accent),accentHover:r("--theme-accent-hover",_e[e].accentHover),accentLight:r("--theme-accent-primary",_e[e].accentLight),taskBarPrimary:r("--theme-accent-primary",_e[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",_e[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",_e[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",_e[e].dependency),dependencyHover:r("--theme-border-secondary",_e[e].dependencyHover),criticalPath:r("--theme-error",_e[e].criticalPath),criticalPathLight:r("--theme-error",_e[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",_e[e].today):e==="neutral"?r("--theme-text-primary",_e[e].today):r("--theme-error",_e[e].today),todayLight:e==="light"?r("--theme-accent-primary",_e[e].todayLight):e==="neutral"?r("--theme-text-primary",_e[e].todayLight):r("--theme-error",_e[e].todayLight),milestone:r("--theme-warning",_e[e].milestone),milestoneLight:r("--theme-warning",_e[e].milestoneLight),statusTodo:r("--theme-text-tertiary",_e[e].statusTodo),statusInProgress:r("--theme-accent-primary",_e[e].statusInProgress),statusCompleted:r("--theme-success",_e[e].statusCompleted),hoverBg:r("--theme-bg-hover",_e[e].hoverBg),focusRing:r("--theme-accent-primary",_e[e].focusRing)}}var Vo={columns:{taskName:"TASK NAME",startDate:"Start Date",endDate:"End Date",duration:"Duration",assignees:"Assignees",status:"Status",progress:"% Complete",priority:"Priority"},toolbar:{today:"Today",day:"Day",week:"Week",month:"Month",export:"Export",exportPdf:"Export to PDF",exportPng:"Export to PNG",exportCsv:"Export to CSV",exportExcel:"Export to Excel",exportMsProject:"Export to MS Project",undo:"Undo",redo:"Redo",createTask:"New Task",density:"Row Density",compact:"Compact",normal:"Normal",spacious:"Spacious"},contextMenu:{editTask:"Edit Task",addSubtask:"Add Subtask",markIncomplete:"Mark Incomplete",setInProgress:"Set In Progress",markComplete:"Mark Complete",splitTask:"Split Task",deleteTask:"Delete Task"},actions:{edit:"Edit",delete:"Delete",duplicate:"Duplicate",addSubtask:"Add Subtask",indent:"Indent",outdent:"Outdent",moveUp:"Move Up",moveDown:"Move Down",splitTask:"Split Task",linkTasks:"Link Tasks",unlinkTasks:"Unlink Tasks"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},labels:{progress:"Progress",duration:"Duration",days:"days",day:"day",assigned:"Assigned",milestone:"Milestone",criticalPath:"Critical Path",subtask:"Subtask",task:"Task",noTasks:"No tasks yet",addTask:"Add task",newTask:"New Task",loading:"Loading...",error:"Error",today:"Today"},ai:{placeholder:'Ask AI to edit tasks... (e.g., "Move Design to next week")',thinking:"Thinking...",suggestions:{moveTask:'Move "Task Name" to next Monday',extendTask:'Extend "Task Name" by 3 days',renameTask:'Rename "Old Name" to "New Name"',setProgress:'Set "Task Name" progress to 50%',linkTasks:'Link "Task A" to "Task B"',createTask:'Create a new task called "New Task"',deleteTask:'Delete "Task Name"',assignTask:'Assign John to "Task Name"'},errors:{taskNotFound:"Task not found",invalidDate:"Invalid date",invalidDuration:"Invalid duration",invalidProgress:"Invalid progress value",unknownCommand:"Unknown command",processingError:"Error processing command"}},export:{projectName:"Gantt Project",ganttTasks:"Gantt Tasks",taskId:"Task ID",taskName:"Task Name",startDate:"Start Date",endDate:"End Date",isMilestone:"Is Milestone",parentId:"Parent ID",yes:"Yes",no:"No",noTasksToExport:"No tasks available to export"},dateFormat:{short:"MM/dd",medium:"MMM d",long:"MMMM d, yyyy"}},Zl={columns:{taskName:"NOMBRE DE TAREA",startDate:"Fecha Inicio",endDate:"Fecha Fin",duration:"Duraci\xF3n",assignees:"Asignados",status:"Estado",progress:"% Completado",priority:"Prioridad"},toolbar:{today:"Hoy",day:"D\xEDa",week:"Semana",month:"Mes",export:"Exportar",exportPdf:"Exportar a PDF",exportPng:"Exportar a PNG",exportCsv:"Exportar a CSV",exportExcel:"Exportar a Excel",exportMsProject:"Exportar a MS Project",undo:"Deshacer",redo:"Rehacer",createTask:"Nueva Tarea",density:"Densidad",compact:"Compacto",normal:"Normal",spacious:"Espacioso"},contextMenu:{editTask:"Editar Tarea",addSubtask:"Agregar Subtarea",markIncomplete:"Marcar Incompleta",setInProgress:"Marcar En Progreso",markComplete:"Marcar Completada",splitTask:"Dividir Tarea",deleteTask:"Eliminar Tarea"},actions:{edit:"Editar",delete:"Eliminar",duplicate:"Duplicar",addSubtask:"Agregar Subtarea",indent:"Aumentar Nivel",outdent:"Disminuir Nivel",moveUp:"Mover Arriba",moveDown:"Mover Abajo",splitTask:"Dividir Tarea",linkTasks:"Vincular Tareas",unlinkTasks:"Desvincular Tareas"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},labels:{progress:"Progreso",duration:"Duraci\xF3n",days:"d\xEDas",day:"d\xEDa",assigned:"Asignado",milestone:"Hito",criticalPath:"Ruta Cr\xEDtica",subtask:"Subtarea",task:"Tarea",noTasks:"Sin tareas a\xFAn",addTask:"Agregar tarea",newTask:"Nueva Tarea",loading:"Cargando...",error:"Error",today:"Hoy"},ai:{placeholder:'P\xEDdele a la IA que edite tareas... (ej: "Mover Dise\xF1o a la pr\xF3xima semana")',thinking:"Pensando...",suggestions:{moveTask:'Mover "Nombre de Tarea" al pr\xF3ximo lunes',extendTask:'Extender "Nombre de Tarea" por 3 d\xEDas',renameTask:'Renombrar "Nombre Anterior" a "Nombre Nuevo"',setProgress:'Establecer progreso de "Nombre de Tarea" al 50%',linkTasks:'Vincular "Tarea A" con "Tarea B"',createTask:'Crear una nueva tarea llamada "Nueva Tarea"',deleteTask:'Eliminar "Nombre de Tarea"',assignTask:'Asignar a Juan a "Nombre de Tarea"'},errors:{taskNotFound:"Tarea no encontrada",invalidDate:"Fecha inv\xE1lida",invalidDuration:"Duraci\xF3n inv\xE1lida",invalidProgress:"Valor de progreso inv\xE1lido",unknownCommand:"Comando desconocido",processingError:"Error procesando el comando"}},export:{projectName:"Proyecto Gantt",ganttTasks:"Tareas Gantt",taskId:"ID de Tarea",taskName:"Nombre de Tarea",startDate:"Fecha Inicio",endDate:"Fecha Fin",isMilestone:"Es Hito",parentId:"ID Padre",yes:"S\xED",no:"No",noTasksToExport:"No hay tareas disponibles para exportar"},dateFormat:{short:"dd/MM",medium:"d MMM",long:"d de MMMM de yyyy"}},xs={en:Vo,es:Zl};function Ql(e){return xs[e]||xs.en}function ks(e,t){let a=Ql(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 Wr=createContext(Vo);function lo(){return useContext(Wr)}function ng({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:l}){let[c,p]=useState(false),[n,m]=useState(null),d=useRef(null),i=lo();if(useEffect(()=>{let g=k=>{d.current&&!d.current.contains(k.target)&&p(false);};return c&&document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[c]),!(t||a||r||o||s||l))return null;let x=[{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:l}].filter(g=>g.handler),f=async(g,k)=>{if(k){m(g);try{await k();}catch(h){console.error(`Export ${g} failed:`,h);}finally{m(null),p(false);}}};return jsxs("div",{ref:d,className:"relative",children:[jsxs(motion.button,{onClick:()=>p(!c),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:c?e.accent:e.bgSecondary,border:`1px solid ${c?e.accent:e.borderLight}`,color:c?"#FFFFFF":e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{scale:1.02,backgroundColor:e.accent,color:"#FFFFFF"},whileTap:{scale:.98},children:[jsx(Download,{className:"w-3.5 h-3.5"}),jsx("span",{children:i.toolbar.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:c?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:c&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute right-0 mt-2 w-48 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:x.map((g,k)=>jsxs(motion.button,{onClick:()=>f(g.id,g.handler),disabled:n!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:k<x.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:k*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:n===g.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):g.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:g.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:g.description})]})]},g.id))})})})]})}function sg({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 l=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:l?r.textPrimary:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:l?600:500,zIndex:l?2:1},whileHover:{scale:1.02},whileTap:{scale:.98},children:[l&&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:l?"#FFFFFF":r.textTertiary},children:s.icon}),jsx("span",{className:"relative z-10",style:{color:l?"#FFFFFF":r.textTertiary},children:s.label})]},s.value)})})}function ig({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 lg({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),l=lo();useEffect(()=>{let n=m=>{s.current&&!s.current.contains(m.target)&&o(false);};return r&&document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=[{value:"compact",label:l.toolbar.compact||"Compact"},{value:"comfortable",label:l.toolbar.normal||"Normal"},{value:"spacious",label:l.toolbar.spacious||"Spacious"}],p=c.find(n=>n.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:`${l.toolbar.density||"Density"}: ${p}`,children:jsx(Rows3,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute left-0 mt-2 w-36 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:c.map((n,m)=>{let d=t===n.value;return jsxs(motion.button,{onClick:()=>{a(n.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:m<c.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:m*.03},children:[jsx("span",{className:"text-xs",style:{color:d?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:d?600:500},children:n.label}),d&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},n.value)})})})})]})}function jo({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:l,rowDensity:c,onRowDensityChange:p,showThemeSelector:n=false,showCreateTaskButton:m=false,createTaskLabel:d,onCreateTask:i,onExportPNG:u,onExportPDF:x,onExportExcel:f,onExportCSV:g,onExportJSON:k,onExportMSProject:h}){let b=lo(),y=u||x||f||g||k||h,D=[{value:"day",label:b.toolbar.day},{value:"week",label:b.toolbar.week},{value:"month",label:b.toolbar.month}],N=[{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(ig,{options:D,value:t,onChange:A=>a(A),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(lg,{theme:e,value:c,onChange:p})]}),jsxs("div",{className:"flex items-center gap-3",children:[m&&i&&jsxs(Fragment,{children:[jsxs(motion.button,{onClick:i,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||b.toolbar.createTask})]}),(y||n)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),y&&jsxs(Fragment,{children:[jsx(ng,{theme:e,onExportPNG:u,onExportPDF:x,onExportExcel:f,onExportCSV:g,onExportJSON:k,onExportMSProject:h}),n&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),n&&jsx(sg,{options:N,value:s,onChange:A=>l(A),theme:e})]})]})}function Hr({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let l=useRef(null),[c,p]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let m=200,d=r.length*36+8,i=8,u=window.innerWidth,x=window.innerHeight,f=t,g=a;t+m+i>u&&(f=t-m,f<i&&(f=i)),a+d+i>x&&(g=x-d-i,g<i&&(g=i)),p({x:f,y:g});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let m=i=>{l.current&&!l.current.contains(i.target)&&o();},d=i=>{i.key==="Escape"&&o();};return document.addEventListener("mousedown",m),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",d);}},[e,o]),!e)return null;let n=m=>m.startsWith("#")&&(m.length===7||m.length===4)?m: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:l,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed z-[9999] min-w-[200px] rounded-lg",style:{left:`${c.x}px`,top:`${c.y}px`,backgroundColor:n(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(m=>jsxs("div",{children:[m.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{m.disabled||(m.onClick(),o());},disabled:m.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:m.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:m.disabled?"not-allowed":"pointer",opacity:m.disabled?.5:1},onMouseEnter:d=>{m.disabled||(d.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[m.icon&&jsx("span",{style:{color:s.textSecondary},children:m.icon}),jsx("span",{className:"flex-1",children:m.label}),m.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},m.id))})})})}var wt={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 dd({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:l,onTaskIndent:c,onTaskOutdent:p,onTaskRename:n,onTaskToggleExpand:m,onOpenTaskModal:d,enableKeyboard:i=true}){let u=useRef(false),x=useCallback(b=>{u.current=b;},[]),f=useCallback(b=>{let y=[],D=N=>{for(let A of N)y.push(A),A.subtasks&&A.subtasks.length>0&&A.isExpanded&&D(A.subtasks);};return D(b),y},[]),g=useCallback(()=>{let b=f(e);for(let y of b)if(t.has(y.id))return y;return null},[e,t,f]),k=useCallback((b,y)=>{let D=f(e);if(D.length===0)return;let N=g();if(!N){a(D[0].id,false);return}let A=D.findIndex(T=>T.id===N.id);if(A===-1)return;let v=b==="up"?A-1:A+1;if(v<0||v>=D.length)return;let F=D[v];a(F.id,y);},[e,g,f,a]),h=useCallback(b=>{if(!i)return;let y=b.target;if(y.tagName==="INPUT"||y.tagName==="TEXTAREA"||y.isContentEditable||u.current){b.key==="Escape"&&(y.blur(),u.current=false);return}let A=navigator.platform.toUpperCase().indexOf("MAC")>=0?b.metaKey:b.ctrlKey,v=Array.from(t),F=g();if(b.key==="ArrowUp"){b.preventDefault(),k("up",b.shiftKey);return}if(b.key==="ArrowDown"){b.preventDefault(),k("down",b.shiftKey);return}if(F&&(b.key==="ArrowRight"||b.key==="ArrowLeft")){F.subtasks&&F.subtasks.length>0&&(b.preventDefault(),(b.key==="ArrowRight"&&!F.isExpanded||b.key==="ArrowLeft"&&F.isExpanded)&&m(F.id));return}if(b.altKey&&(b.key==="ArrowUp"||b.key==="ArrowDown")){v.length>0&&(b.preventDefault(),l(v,b.key==="ArrowUp"?"up":"down"));return}if(b.key==="Tab"&&!b.shiftKey){v.length>0&&(b.preventDefault(),c(v));return}if(b.key==="Tab"&&b.shiftKey){v.length>0&&(b.preventDefault(),p(v));return}if(b.key==="Enter"&&!b.shiftKey&&!A){F&&(b.preventDefault(),r(F.id,"below"));return}if(b.key==="Enter"&&b.shiftKey&&!A){F&&(b.preventDefault(),r(F.id,"above"));return}if(b.key==="Enter"&&A){F&&(b.preventDefault(),d(F.id));return}if(b.key==="F2"){F&&(b.preventDefault(),n(F.id));return}if(b.key==="Delete"||b.key==="Backspace"&&A){v.length>0&&(b.preventDefault(),o(v));return}if(b.key==="d"&&A&&!b.shiftKey){v.length>0&&(b.preventDefault(),s(v));return}},[i,t,g,k,r,o,s,l,c,p,n,m,d]);return useEffect(()=>{if(i)return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h);}},[i,h]),{setIsEditing:x}}function pd(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(d=>{t(new Set([d])),r(d);},[]),s=useCallback(d=>{t(i=>{let u=new Set(i);return u.has(d)?u.delete(d):u.add(d),u}),r(d);},[]),l=useCallback((d,i)=>{if(!a){o(d);return}let u=i.indexOf(a),x=i.indexOf(d);if(u===-1||x===-1){o(d);return}let f=Math.min(u,x),g=Math.max(u,x),k=i.slice(f,g+1);t(new Set(k)),r(d);},[a,o]),c=useCallback((d,i,u,x)=>{x?l(d,i):u?s(d):o(d);},[o,s,l]),p=useCallback((d,i)=>{i?t(u=>{let x=new Set(u);return x.add(d),x}):o(d);},[o]),n=useCallback(()=>{t(new Set),r(null);},[]),m=useCallback(d=>e.has(d),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:l,handleTaskClick:c,handleKeyboardSelection:p,clearSelection:n,isTaskSelected:m}}function Gr(e){let t=[],a=(r,o,s=0)=>{for(let l=0;l<r.length;l++){let c={...r[l],parentId:o,level:s,position:l};t.push(c),c.subtasks&&c.subtasks.length>0&&c.isExpanded&&a(c.subtasks,c.id,s+1);}};return a(e),t}function md(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=md(a.subtasks,t);if(r)return r}}return null}function Cs(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=Cs(a.subtasks,t);if(r)return r}return null}function Ts(e,t){if(t.length===0)return e;let a=Gr(e),r=t[0],o=a.findIndex(d=>d.id===r);if(o<=0)return e;let s=a[o-1],l=(d,i)=>{let u=[];return {tasks:d.filter(f=>{if(i.has(f.id))return u.push(f),false;if(f.subtasks){let g=l(f.subtasks,i);f.subtasks=g.tasks,u.push(...g.removed);}return true}),removed:u}},c=(d,i,u)=>d.map(x=>x.id===i?{...x,subtasks:[...x.subtasks||[],...u],isExpanded:true}:x.subtasks?{...x,subtasks:c(x.subtasks,i,u)}:x),p=new Set(t),{tasks:n,removed:m}=l(e,p);return c(n,s.id,m)}function Ds(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=Cs(a,r);if(!o)continue;let s=Cs(a,o.id),l=(n,m,d)=>{for(let i=0;i<n.length;i++){let u=n[i];if(u.id===m&&u.subtasks){let x=u.subtasks.findIndex(f=>f.id===d);if(x!==-1){let[f]=u.subtasks.splice(x,1);return f}}if(u.subtasks){let x=l(u.subtasks,m,d);if(x)return x}}return null},c=(n,m,d)=>{let i=n.findIndex(u=>u.id===m);if(i!==-1)return n.splice(i+1,0,d),n;for(let u of n)u.subtasks&&c(u.subtasks,m,d);return n},p=l(a,o.id,r);p&&(s&&s.subtasks?c(s.subtasks,o.id,p):c(a,o.id,p));}return a}function Ns(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(l,c,p)=>{let n=l.findIndex(d=>d.id===c);if(n===-1){for(let d of l)if(d.subtasks&&s(d.subtasks,c,p))return true;return false}let m=p==="up"?n-1:n+1;return m<0||m>=l.length?false:([l[n],l[m]]=[l[m],l[n]],true)};return s(r,o,a),r}function Ss(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 Es(e,t){let a=[...e];for(let r of t){let o=l=>{let c=l.findIndex(m=>m.id===r);if(c===-1){for(let m of l)if(m.subtasks&&o(m.subtasks))return true;return false}let p=l[c],n={...p,id:`${p.id}-copy-${Date.now()}`,name:`${p.name} (Copy)`,subtasks:p.subtasks?s(p.subtasks):void 0};return l.splice(c+1,0,n),true},s=l=>l.map(c=>({...c,id:`${c.id}-copy-${Date.now()}`,subtasks:c.subtasks?s(c.subtasks):void 0}));o(a);}return a}function ud(e,t,a){let r=[...e],o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let l={id:`task-${Date.now()}`,name:"New Task",progress:0,status:"todo",startDate:o,endDate:s,color:"#6366F1"},c=p=>{let n=p.findIndex(d=>d.id===t);if(n===-1){for(let d of p)if(d.subtasks&&c(d.subtasks))return true;return false}let m=a==="above"?n:n+1;return p.splice(m,0,l),true};return c(r),{tasks:r,newTask:l}}function Ps(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:Ps(r.subtasks,t,a)}:r)}function Ms(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:Ms(a.subtasks,t)}:a)}function As(e,t){let a=m=>{for(let d of m){if(d.id===t)return d;if(d.subtasks){let i=a(d.subtasks);if(i)return i}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let l=r?.startDate||o,c=r?.endDate||s,p={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(l),endDate:new Date(c),color:r?.color||"#3B82F6"},n=m=>m.map(d=>{if(d.id===t){let i=d.subtasks||[];return {...d,subtasks:[...i,p],isExpanded:true}}return d.subtasks?{...d,subtasks:n(d.subtasks)}:d});return {tasks:n(e),newTask:p}}function gd(e,t,a,r){if(t===a)return e;let o=md(e,t);if(!o)return e;if(a){let c=(p,n)=>{if(!p.subtasks)return false;for(let m of p.subtasks)if(m.id===n||c(m,n))return true;return false};if(c(o,a))return e}let s=c=>c.filter(p=>p.id!==t).map(p=>p.subtasks&&p.subtasks.length>0?{...p,subtasks:s(p.subtasks)}:p),l=s(e);if(a===null){let c=r!==void 0?r:l.length;l.splice(c,0,{...o,parentId:void 0});}else {let c=p=>p.map(n=>{if(n.id===a){let m=n.subtasks||[],d=r!==void 0?r:m.length,i=[...m];return i.splice(d,0,{...o,parentId:a}),{...n,subtasks:i,isExpanded:true}}return n.subtasks&&n.subtasks.length>0?{...n,subtasks:c(n.subtasks)}:n});l=c(l);}return l}function Ko({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:l,onTaskContextMenu:c,onTaskToggle:p,scrollTop:n,columns:m,onToggleColumn:d,onColumnResize:i,onTaskUpdate:u,onTaskIndent:x,onTaskOutdent:f,onTaskMove:g,onMultiTaskDelete:k,onTaskDuplicate:h,onTaskCreate:b,onTaskRename:y,onCreateSubtask:D,onOpenTaskModal:N,onDeleteRequest:A,onTaskReparent:v}){let F=useContext(Wr),[T,w]=useState(null),[B,P]=useState(null),[H,X]=useState(""),fe=useRef(null),[ve,Re]=useState(null),[Ue,z]=useState(0),[L,U]=useState(0),[E,q]=useState({isOpen:false,x:0,y:0,type:"header"}),[J,$]=useState(null),[Te,ke]=useState(null),[Ge,he]=useState(null),tt=useRef(0),Fe=5,et=useRef(false),[ft,Tt]=useState(null),[dt,O]=useState(false),[ne,ie]=useState(null);useEffect(()=>{B&&fe.current&&(fe.current.focus(),fe.current.select());},[B]),useEffect(()=>{if(!ve)return;let W=je=>{let Ie=je.clientX-Ue,ze=L+Ie;i?.(ve,ze);},G=()=>{Re(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",W),document.addEventListener("mouseup",G),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",W),document.removeEventListener("mouseup",G),document.body.style.cursor="",document.body.style.userSelect="";}},[ve,Ue,L,i]);let{selectedTaskIds:Se,handleTaskClick:Ae,isTaskSelected:ot}=pd(),{setIsEditing:st}=dd({tasks:e,selectedTaskIds:Se,onTaskSelect:(W,G)=>{let Ie=Gr(e).map(ze=>ze.id);Ae(W,Ie,G||false,false);},onTaskCreate:b||(()=>{}),onTaskDelete:k||(()=>{}),onTaskDuplicate:h||(()=>{}),onTaskMove:g||(()=>{}),onTaskIndent:x||(()=>{}),onTaskOutdent:f||(()=>{}),onTaskRename:W=>{let G=Gr(e).find(je=>je.id===W);G&&Z(G);},onTaskToggleExpand:p||(()=>{}),onOpenTaskModal:W=>{let G=Gr(e).find(je=>je.id===W);G&&N&&N(G);},enableKeyboard:true}),Le=(W,G=0)=>{let je=[];for(let Ie of W)je.push({task:Ie,level:G}),Ie.subtasks&&Ie.subtasks.length>0&&Ie.isExpanded&&je.push(...Le(Ie.subtasks,G+1));return je},V=Le(e),xe=48,qe=W=>!W.startDate||!W.endDate?"-":`${Math.ceil((W.endDate.getTime()-W.startDate.getTime())/(1e3*60*60*24))}d`,Z=W=>{P(W.id),X(W.name),st(true);},we=W=>{H.trim()&&H!==e.find(G=>G.id===W)?.name&&y?.(W,H.trim()),P(null),X(""),st(false);},ee=()=>{P(null),X(""),st(false);},ae=(W,G)=>{G.stopPropagation(),D?.(W.id);},ye=(W,G)=>{G.preventDefault(),tt.current=G.clientY,$(W),et.current=false,O(false),Tt({x:G.clientX,y:G.clientY});},De=W=>{if(!J||(Math.abs(W.clientY-tt.current)>Fe&&!et.current&&(et.current=true,O(true)),Tt({x:W.clientX,y:W.clientY}),!et.current))return;let je=document.querySelectorAll("[data-task-row]"),Ie=null,ze=null;je.forEach(Ut=>{let Pe=Ut.getBoundingClientRect(),Dt=Ut.getAttribute("data-task-row");if(Dt&&Dt!==J&&W.clientY>=Pe.top&&W.clientY<=Pe.bottom){Ie=Dt;let Qt=W.clientY-Pe.top,R=Pe.height;Qt<R*.25?ze="above":Qt>R*.75?ze="below":ze="child";}}),ke(Ie),he(ze);},re=()=>{if(et.current&&J&&Te&&Ge){if(Ge==="child")v?.(J,Te);else if(Ge==="above"||Ge==="below"){let W=(Ie,ze,Ut=null)=>{for(let Pe of Ie){if(Pe.id===ze)return Ut;if(Pe.subtasks){let Dt=W(Pe.subtasks,ze,Pe.id);if(Dt!==void 0)return Dt}}},G=W(e,Te,null),je=(Ie,ze)=>{let Ut=Ie.findIndex(Pe=>Pe.id===ze);return Ge==="below"?Ut+1:Ut};if(G===null){let Ie=je(e,Te);v?.(J,null,Ie);}else {let Ie=V.find(ze=>ze.task.id===G)?.task;if(Ie?.subtasks){let ze=je(Ie.subtasks,Te);v?.(J,G,ze);}}}}$(null),ke(null),he(null),Tt(null),et.current=false,O(false);};useEffect(()=>{if(J)return document.addEventListener("mousemove",De),document.addEventListener("mouseup",re),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",De),document.removeEventListener("mouseup",re),document.body.style.cursor="",document.body.style.userSelect="";}},[J,Te,Ge]);let Ee=(W,G,je)=>{switch(W.id){case "name":let Ie=B===G.id,ze=T===G.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${je*20}px`},children:[v&&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:ze?1:.3},onMouseDown:le=>ye(G.id,le),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),G.subtasks&&G.subtasks.length>0?jsx("button",{onClick:le=>{le.stopPropagation(),p?.(G.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:G.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:G.color||"#3B82F6",opacity:G.parentId?.6:1,borderColor:G.isMilestone?t.accent:"transparent",borderWidth:G.isMilestone?"2px":"0px"},title:G.isMilestone?"Milestone":G.parentId?"Subtask":"Task"})}),Ie?jsx("input",{ref:fe,type:"text",value:H,onChange:le=>X(le.target.value),onKeyDown:le=>{le.key==="Enter"?we(G.id):le.key==="Escape"&&ee();},onBlur:()=>we(G.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:le=>le.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:G.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:G.parentId?"13px":"14px",fontWeight:G.isMilestone?600:G.parentId?400:600,letterSpacing:G.parentId?"0":"-0.01em"},title:G.name,children:G.name}),ze&&!Ie&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:le=>le.stopPropagation(),children:[jsx("button",{onClick:le=>ae(G,le),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:le=>{le.stopPropagation(),Z(G);},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 Pe=W.id==="startDate"?"startDate":"endDate",Dt=G[Pe],Qt=ne?.taskId===G.id&&ne?.field===Pe,R=le=>le?(typeof le=="string"?new Date(le):le).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):"-";return jsxs("div",{className:"flex items-center justify-center w-full relative",onClick:le=>le.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:le=>{if(Qt)ie(null);else {let ht=le.currentTarget.getBoundingClientRect();ie({taskId:G.id,field:Pe,month:Dt?typeof Dt=="string"?new Date(Dt):Dt:new Date,position:{top:ht.bottom+4,left:ht.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:R(Dt)})]}),Qt&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>ie(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:le=>le.stopPropagation(),children:[jsxs("div",{className:"w-36 py-2",style:{borderRight:`1px solid ${t.border}`},children:[(()=>{let le=new Date,ht=new Date(le);ht.setDate(le.getDate()+1);let jt=new Date(le);jt.setDate(le.getDate()+7);let Pr=new Date(le);return Pr.setDate(le.getDate()+14),[{label:"Hoy",date:le},{label:"Ma\xF1ana",date:ht},{label:"Pr\xF3xima semana",date:jt},{label:"2 semanas",date:Pr}].map((Sa,Ha)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:dr=>dr.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:dr=>dr.currentTarget.style.backgroundColor="transparent",onClick:()=>{u?.(G.id,{[Pe]:Sa.date}),ie(null);},children:Sa.label},Ha))})(),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:le=>le.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:le=>le.currentTarget.style.backgroundColor="transparent",onClick:()=>{u?.(G.id,{[Pe]:void 0}),ie(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:()=>ie(le=>le?{...le,month:new Date(le.month.getFullYear(),le.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:()=>ie(le=>le?{...le,month:new Date(le.month.getFullYear(),le.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((le,ht)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:le},ht))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let le=ne?.month||new Date,ht=le.getFullYear(),jt=le.getMonth(),Pr=new Date(ht,jt,1).getDay(),Do=new Date(ht,jt+1,0).getDate(),Sa=new Date,Ha=[];for(let Bt=Pr-1;Bt>=0;Bt--)Ha.push({day:new Date(ht,jt,-Bt).getDate(),date:new Date(ht,jt-1,new Date(ht,jt,-Bt).getDate()),isCurrentMonth:false});for(let Bt=1;Bt<=Do;Bt++)Ha.push({day:Bt,date:new Date(ht,jt,Bt),isCurrentMonth:true});let dr=42-Ha.length;for(let Bt=1;Bt<=dr;Bt++)Ha.push({day:Bt,date:new Date(ht,jt+1,Bt),isCurrentMonth:false});return Ha.map((Bt,Nn)=>{let qr=Bt.date.toDateString()===Sa.toDateString(),Xr=(Dt?typeof Dt=="string"?new Date(Dt):Dt:null)?.toDateString()===Bt.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:Bt.isCurrentMonth?Xr?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:Xr?"#3B82F6":"transparent",boxShadow:qr&&!Xr?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{u?.(G.id,{[Pe]:Bt.date}),ie(null);},children:Bt.day},Nn)})})()})]})]})]}),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:qe(G)})});case "assignees":let ue=r.filter(le=>G.assignees?.some(ht=>ht.name===le.name||ht.initials===le.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:le=>le.stopPropagation(),children:jsx(gr,{assignedUsers:ue,availableUsers:r,onChange:le=>{let ht=le.map(jt=>({id:jt.id,name:jt.name,initials:jt.initials,color:jt.color}));u?.(G.id,{assignees:ht.length>0?ht:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:le=>le.stopPropagation(),children:jsx(ul,{status:G.status||"todo",onChange:le=>{u?.(G.id,{status:le,progress:le==="completed"?100:G.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:`${G.progress}%`,backgroundColor:G.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:[G.progress,"%"]})]});case "priority":let K={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},Ft={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},aa=K[G.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:le=>le.stopPropagation(),children:jsx(mr,{priority:aa,onChange:le=>{le&&u?.(G.id,{priority:Ft[le]||"medium"});}})});default:return null}},be=W=>[{id:"hide",label:"Hide Column",icon:wt.Hide,onClick:()=>d(W),disabled:W==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:wt.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:wt.SortDesc,onClick:()=>{}}],Ne=W=>W.subtasks&&W.subtasks.length>0?[{id:"addSubtask",label:F?.contextMenu?.addSubtask||"Add Subtask",icon:wt.Add,onClick:()=>{D?.(W.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:F?.contextMenu?.deleteTask||"Delete Task",icon:wt.Delete,onClick:()=>{A?A(W.id,W.name):k?.([W.id]);}}]:[{id:"edit",label:F?.contextMenu?.editTask||"Edit Task",icon:wt.Pencil,onClick:()=>{l?.(W);}},{id:"addSubtask",label:F?.contextMenu?.addSubtask||"Add Subtask",icon:wt.Add,onClick:()=>{D?.(W.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:F?.contextMenu?.markIncomplete||"Mark Incomplete",icon:wt.MarkIncomplete,onClick:()=>{u?.(W.id,{status:"todo",progress:0});},disabled:W.status==="todo"},{id:"setInProgress",label:F?.contextMenu?.setInProgress||"Set In Progress",icon:wt.SetInProgress,onClick:()=>{u?.(W.id,{status:"in-progress"});},disabled:W.status==="in-progress"},{id:"markComplete",label:F?.contextMenu?.markComplete||"Mark Complete",icon:wt.MarkComplete,onClick:()=>{u?.(W.id,{status:"completed",progress:100});},disabled:W.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:F?.contextMenu?.splitTask||"Split Task",icon:wt.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:F?.contextMenu?.deleteTask||"Delete Task",icon:wt.Delete,onClick:()=>{A?A(W.id,W.name):k?.([W.id]);}}],ce=m.filter(W=>W.visible),Oe=ce.reduce((W,G)=>W+G.width,0)+60;return jsxs("div",{className:"h-full",style:{backgroundColor:t.bgPrimary,minWidth:Oe},children:[jsx("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${xe}px`,paddingLeft:"3px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:ce.map((W,G)=>{let je=G===ce.length-1,Ie=W.id==="name";return jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${Ie?"":"justify-center"}`,style:{width:`${W.width}px`,minWidth:`${W.minWidth??(Ie?200:60)}px`,maxWidth:`${W.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:je?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:ze=>{ze.preventDefault(),q({isOpen:true,x:ze.clientX,y:ze.clientY,type:"header",columnId:W.id});},onMouseEnter:ze=>{ze.currentTarget.style.backgroundColor=t.hoverBg;},onMouseLeave:ze=>{ze.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:W.label,children:W.label}),W.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:ve===W.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:ze=>{ze.preventDefault(),ze.stopPropagation(),Re(W.id),z(ze.clientX),U(W.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"}})})]},W.id)})}),jsx("div",{className:"gantt-taskgrid-content",children:V.map(({task:W,level:G},je)=>{let Ie=ot(W.id),ze=Te===W.id,Ut=ze&&Ge==="above",Pe=ze&&Ge==="below",Dt=ze&&Ge==="child",Qt={};return Dt&&(Qt.backgroundColor=`${t.accent}15`,Qt.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":W.id,className:`flex items-center cursor-pointer group ${J===W.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:Ie?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:Ie?t.accentLight:Dt?`${t.accent}15`:je%2===0?t.bgPrimary:t.bgGrid,...Qt},onMouseEnter:()=>w(W.id),onMouseLeave:()=>w(null),onClick:R=>{let K=Gr(e).map(le=>le.id),aa=navigator.platform.toUpperCase().indexOf("MAC")>=0?R.metaKey:R.ctrlKey;Ae(W.id,K,aa,R.shiftKey),s?.(W);},onDoubleClick:R=>{R.stopPropagation(),l?.(W);},onContextMenu:R=>{R.preventDefault(),q({isOpen:true,x:R.clientX,y:R.clientY,type:"task",task:W}),c?.(W,R);},whileHover:{backgroundColor:Ie?t.accentLight:t.hoverBg},children:[Ut&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),Pe&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),ce.map((R,ue)=>{let K=ue===ce.length-1,Ft=R.id==="name";return jsx("div",{className:`px-4 flex items-center ${Ft?"justify-start":"justify-center"}`,style:{width:`${R.width}px`,minWidth:`${R.minWidth??(Ft?200:60)}px`,maxWidth:`${R.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:K?"none":`1px solid ${T===W.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:Ee(R,W,Ft?G:0)},`${W.id}-${R.id}`)})]},W.id)})}),jsx(Hr,{isOpen:E.isOpen,x:E.x,y:E.y,items:E.type==="header"&&E.columnId?be(E.columnId):E.type==="task"&&E.task?Ne(E.task):[],onClose:()=>q({...E,isOpen:false}),theme:t}),dt&&ft&&J&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:ft.x+12,top:ft.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let W=V.find(G=>G.task.id===J)?.task;return W?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:W.name})}):null})()}),document.body)]})}function vd(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[l,c]=useState(e),[p,n]=useState(t),[m,d]=useState(null),[i,u]=useState(null),[x,f]=useState(null),[g,k]=useState(null),[h,b]=useState(0),[y,D]=useState(0),[N,A]=useState(null),[v,F]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:l,setGhostX:c,ghostWidth:p,setGhostWidth:n,connectionLine:m,setConnectionLine:d,hoveredTaskId:i,setHoveredTaskId:u,activeZone:x,setActiveZone:f,draggedSegmentIndex:g,setDraggedSegmentIndex:k,draggedSegmentStartX:h,setDraggedSegmentStartX:b,segmentDragOffsetX:y,setSegmentDragOffsetX:D,hoveredSegmentIndex:N,setHoveredSegmentIndex:A,isHovered:v,setIsHovered:F,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(H,X)=>{r("none"),d(null),u(null),c(H),n(X),D(0),k(null),b(0);}}}function Yo({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:l,templates:c,onClick:p,onDoubleClick:n,onContextMenu:m,onDateChange:d,onDependencyCreate:i,allTaskPositions:u=[],onDragMove:x,onHoverChange:f}){let g=vd(t,r),k=useRef(null),{dragMode:h,setDragMode:b,dragOffset:y,setDragOffset:D,ghostX:N,setGhostX:A,ghostWidth:v,setGhostWidth:F,connectionLine:T,setConnectionLine:w,hoveredTaskId:B,setHoveredTaskId:P,activeZone:H,setActiveZone:X,draggedSegmentIndex:fe,setDraggedSegmentIndex:ve,draggedSegmentStartX:Re,setDraggedSegmentStartX:Ue,segmentDragOffsetX:z,setSegmentDragOffsetX:L,hoveredSegmentIndex:U,setHoveredSegmentIndex:E,isHovered:q,setIsHovered:J,isDragging:$,isResizing:Te,isConnecting:ke,resetDragState:Ge}=g,he=32,tt=8,Fe=e.endDate&&e.endDate<new Date&&e.progress<100,et=e.isCriticalPath,ft=o.name==="neutral"||o.today==="#1C1917",Tt=e.status==="completed"||e.progress===100,dt={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},ne=e.isCriticalPath||Fe?"#DC2626":e.color?e.color:e.priority&&dt[e.priority]?dt[e.priority]:o.taskBarPrimary,Se=(re=>re>=80?20:re>=60?15:re>=50?12:10)(r),Ae=r<50,ot=r<40;useEffect(()=>{if(f)if(q&&!$&&!e.segments){let re=a<100;f({task:e,x:t,y:a,width:r,height:he,showBelow:re});}else f(null);},[q,$,e,t,a,r,he,f]);let st=re=>re.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Le=()=>{let re=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${re} day${re!==1?"s":""}`},V=re=>Math.round(re/s)*s,xe=re=>{let Ee=Math.round(re/s),be=new Date(l);return be.setDate(be.getDate()+Ee),be},qe=(re,Ee)=>{for(let be of u){if(be.id===e.id)continue;let Ne=5;if(re>=be.x-Ne&&re<=be.x+be.width+Ne&&Ee>=be.y-Ne&&Ee<=be.y+be.height+Ne)return be.id}return null},Z=useCallback((re,Ee,be)=>{re.preventDefault(),re.stopPropagation();let Ne=k.current?.ownerSVGElement;if(!Ne)return;let ce=Ne.createSVGPoint();ce.x=re.clientX,ce.y=re.clientY;let Oe=ce.matrixTransform(Ne.getScreenCTM()?.inverse()),W=be!==void 0?be:t,G=Ee;if(!G){let je=Oe.x-W;re.shiftKey?(G="connect",w({x:t+r,y:a+he/2})):re.ctrlKey||re.metaKey?G="move":re.altKey?G=je<r/2?"resize-start":"resize-end":ot?je<r/2?G="move":G="resize-end":Ae?je<=Se/2?G="resize-start":je>=r-Se/2?G="resize-end":G="move":je<=Se?G="resize-start":je>=r-Se?G="resize-end":G="move";}b(G),J(false),X(null),G==="move"?D(Oe.x-W):G==="connect"?w({x:t+r,y:a+he/2}):D(0),A(W),F(r);},[t,r,a,he]),we=useCallback(re=>{if(h==="none")return;let Ee=k.current?.ownerSVGElement;if(!Ee)return;let be=Ee.createSVGPoint();be.x=re.clientX,be.y=re.clientY;let Ne=be.matrixTransform(Ee.getScreenCTM()?.inverse());if(h==="connect"){w({x:Ne.x,y:Ne.y});let ce=qe(Ne.x,Ne.y);P(ce);}else if(h==="move"){let ce=Ne.x-y,Oe=V(ce);A(Oe),F(r);let W=Math.round((Oe-t)/s);if(x?.(e.id,W,true),e.segments&&e.segments.length>0&&fe!==null){let G=Oe-Re;L(G);}}else if(h==="resize-start"){let ce=Ne.x,Oe=V(ce),W=t+r-Oe;W>=s&&(A(Oe),F(W));}else if(h==="resize-end"){let ce=Ne.x,W=V(ce)-t;W>=s&&F(W);}},[h,t,r,s,y,e,V,fe,Re,qe,P,w,A,F,L,x]),ee=useCallback(()=>{if(h!=="none"){if(h==="connect")B&&i&&i(e,B),w(null),P(null);else {let re=e.endDate.getTime()-e.startDate.getTime(),Ee,be,Ne=true;if(h==="move"){if(Ee=xe(N),be=new Date(Ee.getTime()+re),e.segments&&e.segments.length>0&&fe!==null){let ce=Math.round(z/s),Oe=e.segments.map((Ie,ze)=>{if(ze===fe){let Ut=new Date(Ie.startDate),Pe=new Date(Ie.endDate);return Ut.setDate(Ut.getDate()+ce),Pe.setDate(Pe.getDate()+ce),{startDate:Ut,endDate:Pe}}return Ie}),W=Oe.flatMap(Ie=>[Ie.startDate,Ie.endDate]),G=new Date(Math.min(...W.map(Ie=>Ie.getTime()))),je=new Date(Math.max(...W.map(Ie=>Ie.getTime())));d?.({...e,segments:Oe},G,je),Ge(t,r);return}}else h==="resize-start"?(Ee=xe(N),be=e.endDate,Ee>be&&(console.warn("Invalid date range: start date must be before or equal to end date"),Ne=false)):h==="resize-end"?(Ee=e.startDate,be=xe(N+v),be<Ee&&(console.warn("Invalid date range: end date must be after or equal to start date"),Ne=false)):Ne=false;Ne&&Ee&&be&&(be.getTime()<Ee.getTime()?console.warn("Invalid date range: end date cannot be before start date"):d?.(e,Ee,be));}x?.(e.id,0,false),Ge(t,r);}},[h,N,v,e,d,B,i,t,r,s,xe,z,fe,Ge,x]);useEffect(()=>{if(h==="none")return;let re=be=>{we(be);},Ee=()=>{ee();};return window.addEventListener("mousemove",re),window.addEventListener("mouseup",Ee),()=>{window.removeEventListener("mousemove",re),window.removeEventListener("mouseup",Ee);}},[h,we,ee]);let ae=$&&!ke?N:t,ye=$&&!ke?v:r,De=c.taskClass(e);return jsxs("g",{ref:k,onMouseEnter:()=>!$&&J(true),onMouseLeave:()=>{$||(J(false),X(null));},onClick:()=>!$&&p?.(e),onDoubleClick:re=>{$||(re.stopPropagation(),n?.(e));},onContextMenu:re=>{re.preventDefault(),m?.(e,re);},children:[q&&!$&&!Ae&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:Se,height:he,fill:H==="resize-start"?o.accent:"transparent",opacity:H==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>X("resize-start"),onMouseDown:re=>Z(re,"resize-start")}),jsx("rect",{x:t+Se,y:a,width:r-Se*2,height:he,fill:H==="move"?o.accent:"transparent",opacity:H==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>X("move"),onMouseDown:re=>Z(re,"move")}),jsx("rect",{x:t+r-Se,y:a,width:Se,height:he,fill:H==="resize-end"?o.accent:"transparent",opacity:H==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>X("resize-end"),onMouseDown:re=>Z(re,"resize-end")})]}),q&&!$&&ot&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:he,fill:H==="move"?o.accent:"transparent",opacity:H==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>X("move"),onMouseDown:re=>Z(re,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:he,fill:H==="resize-end"?o.accent:"transparent",opacity:H==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>X("resize-end"),onMouseDown:re=>Z(re,"resize-end")}),q&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+he-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),$&&!ke&&!e.segments&&jsx(motion.rect,{x:N,y:a,width:v,height:he,rx:tt,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:ae,y:a,width:ye,height:he,rx:tt,fill:ne,"data-task-class":De,initial:{opacity:0,scale:.95},animate:{opacity:$&&!ke?.15:e.parentId?.6:q?.9:.8,scale:q&&!$?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:re=>Z(re),style:{cursor:$?ke?"crosshair":Te?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:ae,y:a,width:ye*(e.progress/100),height:he,rx:tt,fill:ne,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((re,Ee)=>{let be=(re.startDate.getTime()-l.getTime())/864e5*s,ce=(re.endDate.getTime()-l.getTime())/(1e3*60*60*24)*s-be+s,Oe=$&&h==="move"&&fe===Ee,W=U===Ee,G=Oe?be+z:be;return jsxs("g",{onMouseEnter:()=>!$&&E(Ee),onMouseLeave:()=>!$&&E(null),children:[jsx(motion.rect,{x:G,y:a,width:ce,height:he,rx:tt,fill:ne,initial:{opacity:0,scale:.95},animate:{opacity:Oe||e.parentId?.6:W?.9:.8,scale:W&&!$?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:je=>{je.stopPropagation(),ve(Ee),Ue(be),Z(je,void 0,be);},style:{cursor:$?ke?"crosshair":Te?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:G,y:a,width:ce*(e.progress/100),height:he,rx:tt,fill:ne,opacity:1,style:{pointerEvents:"none"}})]},`segment-${Ee}`)}),ft&&(Fe||et)&&!e.segments&&jsxs(Fragment,{children:[et&&!Fe&&jsx("rect",{x:ae,y:a,width:ye,height:he,rx:tt,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),Fe&&jsx("rect",{x:ae,y:a,width:ye,height:he,rx:tt,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),ye>60&&!e.segments&&(()=>{let re=c.taskLabel(e),Ee=typeof re=="string"?re:e.name,be=Ee.length>Math.floor(ye/8)?`${Ee.substring(0,Math.floor(ye/8))}...`:Ee;return jsx("text",{x:ae+12,y:a+he/2,dominantBaseline:"middle",fill:Tt?"rgba(255, 255, 255, 0.6)":"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none",textDecoration:Tt?"line-through":"none"},children:be})})(),ye>100&&e.progress>0&&e.progress<100&&!$&&!e.segments&&jsxs("text",{x:ae+ye-12,y:a+he/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&&ye>80&&!$&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:ae+ye-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:ae+ye-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(q||Te)&&!ke&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:Ae?ae-15:ae-10,y:a-5,width:Ae?25:20,height:he+10,fill:"transparent",onMouseDown:re=>Z(re,"resize-start"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ae?ae-8:ae-3,y:a+6,width:Ae?8:6,height:Ae?he-12:he-16,rx:3,fill:h==="resize-start"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:h==="resize-start"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]}),jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:ae+ye-10,y:a-5,width:Ae?25:20,height:he+10,fill:"transparent",onMouseDown:re=>Z(re,"resize-end"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ae?ae+ye:ae+ye-3,y:a+6,width:Ae?8:6,height:Ae?he-12:he-16,rx:3,fill:h==="resize-end"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:h==="resize-end"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]})]}),jsx(AnimatePresence,{children:q&&!$&&!e.segments&&jsxs(motion.g,{style:{pointerEvents:"all"},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[jsx(motion.circle,{cx:t+r+8,cy:a+he/2,r:6,fill:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},exit:{scale:0},transition:{duration:.2,type:"spring",stiffness:400,damping:25},onMouseDown:re=>{re.stopPropagation(),Z(re,"connect");},style:{cursor:"crosshair"}}),jsx("text",{x:t+r+20,y:a+he/2,dominantBaseline:"middle",fill:o.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:"Link"})]})}),ke&&T&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+he/2,x2:T.x,y2:T.y,stroke:B?o.statusCompleted:o.accent,strokeWidth:B?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:B?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:T.x,cy:T.y,r:B?8:6,fill:B?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),B&&jsx(motion.text,{x:T.x+15,y:T.y,dominantBaseline:"middle",fill:o.statusCompleted,fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",initial:{opacity:0,x:T.x+10},animate:{opacity:1,x:T.x+15},transition:{duration:.2},children:"Connect"})]}),(q||$)&&!ke&&!e.segments&&jsx(motion.rect,{x:ae-2,y:a-2,width:ye+4,height:he+4,rx:tt+2,fill:"none",stroke:$?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:$?.6:.4,initial:{opacity:0},animate:{opacity:$?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),Te&&jsxs(Fragment,{children:[jsx("line",{x1:N,y1:0,x2:N,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:N+v,y1:0,x2:N+v,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:q&&!$&&!e.segments&&!f&&(()=>{let be=a<100,Ne=be?a+he+13:a-82-13,ce=be?`M ${ae+ye/2-6} ${a+he+3} L ${ae+ye/2} ${a+he+13} L ${ae+ye/2+6} ${a+he+3}`:`M ${ae+ye/2-6} ${a-13} L ${ae+ye/2} ${a-3} L ${ae+ye/2+6} ${a-13}`,Oe=Ne+22,W=Ne+40,G=Ne+55,je=Ne+70,Ie=be?Ne+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:be?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:be?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:ce,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:ae+ye/2-120,y:Ne,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:ae+ye/2,y:Oe,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:ae+ye/2-110,y:W,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:ae+ye/2-70,y:W,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:st(e.startDate)}),jsx("text",{x:ae+ye/2-110,y:G,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:ae+ye/2-70,y:G,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:st(e.endDate)}),jsx("text",{x:ae+ye/2+10,y:W,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:ae+ye/2+65,y:W,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Le()}),jsx("text",{x:ae+ye/2+10,y:G,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:ae+ye/2+65,y:G,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:ae+ye/2-110,y:je,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:ae+ye/2-50,y:je,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(ze=>ze.name).join(", ").substring(0,30),e.assignees.map(ze=>ze.name).join(", ").length>30?"...":""]})]}),!be&&jsx("text",{x:ae+ye/2,y:Ie,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:ot?"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 wd({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:l,showBelow:c}=e,p=82,n=13,m=c?o+l+n:o-p-n,d=c?`M ${r+s/2-6} ${o+l+3} L ${r+s/2} ${o+l+13} L ${r+s/2+6} ${o+l+3}`:`M ${r+s/2-6} ${o-13} L ${r+s/2} ${o-3} L ${r+s/2+6} ${o-13}`,i=m+22,u=m+40,x=m+55,f=m+70,g=y=>y.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),k=()=>{if(!a.startDate||!a.endDate)return "N/A";let y=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${y} day${y!==1?"s":""}`};return jsx(AnimatePresence,{children:jsxs(motion.g,{initial:{opacity:0,y:c?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:c?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:m,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:i,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:u,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y:u,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?g(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y:x,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y:x,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?g(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y:u,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y:u,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:k()}),jsx("text",{x:r+s/2+10,y:x,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y:x,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:f,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:r+s/2-50,y:f,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.assignees.map(y=>y.name).join(", ").substring(0,30),a.assignees.map(y=>y.name).join(", ").length>30?"...":""]})]})]})})}function Jo({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,onHoverChange:l}){let[c,p]=useState(false),n=a-e,m=r-t,d=e+n/2,i=`M ${e} ${t} C ${d} ${t}, ${d} ${r}, ${a} ${r}`,u=6,x=Math.atan2(m,n),f=a-u*Math.cos(x-Math.PI/6),g=r-u*Math.sin(x-Math.PI/6),k=a-u*Math.cos(x+Math.PI/6),h=r-u*Math.sin(x+Math.PI/6),b=o.dependency;useEffect(()=>{l&&s&&l(c?{x1:e,y1:t,x2:a,y2:r,onDelete:s}:null);},[c,e,t,a,r,s,l]);let y=!s&&!l;return jsxs("g",{onMouseEnter:()=>!y&&p(true),onMouseLeave:()=>!y&&p(false),style:{pointerEvents:y?"none":"auto"},children:[!y&&jsx("path",{d:i,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx(motion.path,{d:i,fill:"none",stroke:b,strokeWidth:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:c&&l?0:c?1:.8,strokeWidth:c?2.5:2},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2},strokeWidth:{duration:.2}}}),jsx(motion.path,{d:`M ${a} ${r} L ${f} ${g} M ${a} ${r} L ${k} ${h}`,fill:"none",stroke:b,strokeWidth:2,strokeLinecap:"round",initial:{opacity:0,scale:.8},animate:{opacity:c&&l?0:c?1:.8,scale:c?1.1:1,strokeWidth:c?2.5:2},transition:{duration:.2}}),jsx(motion.circle,{cx:a,cy:r,r:3,fill:b,initial:{scale:0},animate:{scale:c&&l?0:c?1.3:1,opacity:c&&l?0:c?1:.8},transition:{scale:{delay:.3,duration:.15},opacity:{duration:.2}}}),c&&s&&!l&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:D=>{D.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:d,cy:(t+r)/2,r:10,fill:o.bgSecondary,stroke:o.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:d-4,y1:(t+r)/2-4,x2:d+4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:d+4,y1:(t+r)/2-4,x2:d-4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})}function Qo({task:e,x:t,y:a,theme:r,onClick:o}){let[s,l]=useState(false),c=16,p=n=>n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),onClick:()=>o?.(e),style:{cursor:"pointer"},children:[e.isCriticalPath&&jsx(motion.circle,{cx:t,cy:a+16,r:c+4,fill:r.criticalPathLight,initial:{scale:0},animate:{scale:s?1.2:1},transition:{duration:.3}}),jsx(motion.rect,{x:t-c/2,y:a+16-c/2,width:c,height:c,fill:e.isCriticalPath?r.criticalPath:r.milestone,stroke:r.bgGrid,strokeWidth:2,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:0,rotate:0},animate:{scale:s?1.15:1,rotate:45},transition:{duration:.3,type:"spring",stiffness:300,damping:20}}),s&&jsx(motion.rect,{x:t-(c+4)/2,y:a+16-(c+4)/2,width:c+4,height:c+4,fill:"none",stroke:e.isCriticalPath?r.criticalPath:r.milestone,strokeWidth:2,opacity:.5,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:.8,opacity:0},animate:{scale:1,opacity:.5},transition:{duration:.2}}),jsx(AnimatePresence,{children:s&&jsxs(motion.g,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.2},children:[jsx("rect",{x:t-80,y:a-50,width:160,height:44,rx:8,fill:r.bgSecondary,stroke:r.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("path",{d:`M ${t-6} ${a-6} L ${t} ${a+4} L ${t+6} ${a-6}`,fill:r.bgSecondary,stroke:r.border,strokeWidth:1}),jsx("rect",{x:t-70,y:a-38,width:8,height:8,fill:e.isCriticalPath?r.criticalPath:r.milestone,transform:`rotate(45 ${t-66} ${a-34})`}),jsx("text",{x:t-55,y:a-32,fill:r.textPrimary,fontSize:"12",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>18?`${e.name.substring(0,18)}...`:e.name}),jsx("text",{x:t-55,y:a-18,fill:r.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",children:p(e.startDate)}),e.isCriticalPath&&jsxs("g",{children:[jsx("rect",{x:t+10,y:a-40,width:60,height:16,rx:4,fill:r.criticalPathLight}),jsx("text",{x:t+40,y:a-30,textAnchor:"middle",fill:r.criticalPath,fontSize:"9",fontWeight:"700",fontFamily:"Inter, sans-serif",letterSpacing:"0.5",children:"CRITICAL"})]})]})})]})}var se={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=n=>{n.forEach(m=>{m.dependencies&&r.set(m.id,m.dependencies),m.subtasks&&o(m.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let l=new Set,c=new Set,p=n=>{if(!l.has(n)){l.add(n),c.add(n);let m=r.get(n)||[];for(let d of m){if(!l.has(d)&&p(d))return true;if(c.has(d))return true}}return c.delete(n),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=se.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=se.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=se.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=se.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=se.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=se.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)=>se.flattenTasks(e).filter(r=>r.dependencies&&r.dependencies.includes(t)),getDependencyTasks:(e,t)=>{let a=se.findTaskById(e,t);return !a||!a.dependencies?[]:se.flattenTasks(e).filter(o=>a.dependencies.includes(o.id))},filterByStatus:(e,t)=>se.flattenTasks(e).filter(a=>a.status===t),filterByDateRange:(e,t,a)=>se.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=se.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=>se.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=se.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 l=[["Task Name","Start Date","End Date","Duration","Progress","Status"]],c=s.map(p=>{let n=p.startDate&&p.endDate?se.calculateDuration(p.startDate,p.endDate):0;return [p.name,p.startDate?se.formatDate(p.startDate):"N/A",p.endDate?se.formatDate(p.endDate):"N/A",n>0?`${n} days`:"N/A",`${p.progress}%`,p.status||"N/A"]});r(o,{head:l,body:c,startY:30,styles:{fontSize:9,cellPadding:3},headStyles:{fillColor:[66,139,202],textColor:255,fontStyle:"bold"},alternateRowStyles:{fillColor:[245,245,245]},columnStyles:{0:{cellWidth:60},1:{cellWidth:30},2:{cellWidth:30},3:{cellWidth:25},4:{cellWidth:20},5:{cellWidth:25}}}),o.save(t);}catch(a){throw a}},exportToExcel:async(e,t="gantt-chart.xlsx")=>{let a=await import('xlsx'),o=se.flattenTasks(e).map(p=>{let n=p.startDate&&p.endDate?se.calculateDuration(p.startDate,p.endDate):0;return {"Task ID":p.id,"Task Name":p.name,"Start Date":p.startDate?se.formatDate(p.startDate):"","End Date":p.endDate?se.formatDate(p.endDate):"","Duration (days)":n>0?n:"","Progress (%)":p.progress,Status:p.status||"",Assignees:p.assignees?.map(m=>m.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),l=[{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"]=l;let c=a.utils.book_new();a.utils.book_append_sheet(c,s,"Gantt Tasks"),a.writeFile(c,t);},exportToMSProject:(e,t="Gantt Project",a="project.xml")=>{let r=se.flattenTasks(e),o=new Map;r.forEach((i,u)=>{o.set(i.id,u+1);});let s=i=>i.toISOString().replace("Z",""),l=se.getEarliestStartDate(e)||new Date,c=se.getLatestEndDate(e)||new Date,p=r.map((i,u)=>{let x=o.get(i.id),f=i.startDate&&i.endDate?se.calculateDuration(i.startDate,i.endDate):0,g=(i.dependencies||[]).filter(k=>o.has(k)).map(k=>`
|
|
113
113
|
<PredecessorLink>
|
|
114
114
|
<PredecessorUID>${o.get(k)}</PredecessorUID>
|
|
115
115
|
<Type>1</Type>
|
|
@@ -339,9 +339,9 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
|
|
|
339
339
|
</Calendars>
|
|
340
340
|
<Tasks>${p}
|
|
341
341
|
</Tasks>
|
|
342
|
-
</Project>`,m=new Blob([n],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(m),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=le.flattenTasks(e),a=t.filter(n=>n.startDate&&n.endDate);if(a.length===0)return [];let r=new Map,o=n=>{if(r.has(n.id))return;let m=n.startDate&&n.endDate?le.calculateDuration(n.startDate,n.endDate):0,d=0;if(n.dependencies&&n.dependencies.length>0)for(let u of n.dependencies){let x=t.find(f=>f.id===u);if(x){o(x);let f=r.get(u)?.ef||0;d=Math.max(d,f);}}let i=d+m;r.set(n.id,{es:d,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(n=>n.ef)),l=new Map,c=n=>{if(l.has(n.id))return;let m=n.startDate&&n.endDate?le.calculateDuration(n.startDate,n.endDate):0,d=t.filter(x=>x.dependencies&&x.dependencies.includes(n.id)),i=s;if(d.length>0)for(let x of d){c(x);let f=l.get(x.id)?.ls||0;i=Math.min(i,f);}let u=i-m;l.set(n.id,{ls:u,lf:i});};a.forEach(c);let p=[];for(let n of a){let m=r.get(n.id),d=l.get(n.id);if(m&&d){let i=d.ls-m.es;Math.abs(i)<.01&&p.push(n.id);}}return p},calculateSlack:(e,t)=>{let a=le.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(le.calculateCriticalPath(e).includes(t))return 0;let o=le.getDependentTasks(e,t);if(o.length===0){let c=le.getLatestEndDate(e);if(!c)return null;let p=le.calculateDuration(a.endDate,c);return Math.max(0,p)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,p)=>c-p)[0];if(!s)return null;let l=le.calculateDuration(a.endDate,new Date(s));return Math.max(0,l)},isOnCriticalPath:(e,t)=>le.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=le.findTaskById(e,t);if(!r||!r.endDate)return e;let o=le.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let l of o){if(!l.startDate||!l.endDate)continue;let c=le.calculateDuration(l.startDate,l.endDate),p;a!==void 0?(p=new Date(l.startDate),p.setDate(p.getDate()+a)):(p=new Date(r.endDate),p.setDate(p.getDate()+1));let n=le.calculateEndDate(p,c),m=d=>d.map(i=>i.id===l.id?{...i,startDate:p,endDate:n}:i.subtasks?{...i,subtasks:m(i.subtasks)}:i);s=m(s),s=le.autoScheduleDependents(s,l.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,l,c)=>{if(a===0)return [];let p=[],n=o.getTime(),m=1e3*60*60*24,d=le.findTaskById(e,t);if(!d||!d.endDate)return [];let i=(u,x,f=new Set)=>{if(f.has(u))return;f.add(u);let g=le.getDependentTasks(e,u);for(let k of g){if(!k.startDate||!k.endDate)continue;let h=r.findIndex(w=>w.id===k.id);if(h===-1)continue;let b=k.startDate.getTime(),D=(k.endDate.getTime()-b)/m,A=(b-n)/m*s,v=A+x*s,B=Math.max(D*s,s),T=c+h*l+12;p.push({taskId:k.id,taskName:k.name,originalX:A,previewX:v,width:B,y:T,rowIndex:h,daysDelta:x,color:k.color}),i(k.id,x,f);}};return i(t,a),p},splitTask:(e,t,a,r=3)=>{let o=le.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let l=new Date(a);l.setDate(l.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let p=[{startDate:new Date(o.startDate),endDate:s},{startDate:l,endDate:c}],n=m=>m.map(d=>d.id===o.id?{...d,endDate:c,segments:p}:d.subtasks?{...d,subtasks:n(d.subtasks)}:d);return n(e)}};function sn({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:l,templates:c,onTaskClick:p,onTaskDblClick:n,onTaskContextMenu:m,onTaskDateChange:d,onDependencyCreate:i,onDependencyDelete:u}){let[f,g]=useState([]),[k,h]=useState(null),[b,y]=useState(null),D=useCallback($=>{h($);},[]),N=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),A=r==="day"?60:r==="week"?20:8,v=N*A*l,B=$=>{let F=new Date(Date.UTC($.getFullYear(),$.getMonth(),$.getDate())),W=F.getUTCDay()||7;F.setUTCDate(F.getUTCDate()+4-W);let E=new Date(Date.UTC(F.getUTCFullYear(),0,1));return Math.ceil(((F.getTime()-E.getTime())/864e5+1)/7)},T=$=>{let F=$.getDay();return F===0||F===6},w=useCallback($=>{let F=Math.round($/(A*l)),W=new Date(o);return W.setDate(W.getDate()+F),W},[o,A,l]),R=useCallback(($,F)=>{if(F.startDate&&F.endDate)return;let W=$.currentTarget.ownerSVGElement;if(!W)return;let E=W.createSVGPoint();E.x=$.clientX,E.y=$.clientY;let K=E.matrixTransform(W.getScreenCTM()?.inverse()),X=w(K.x),U=new Date(X);U.setDate(U.getDate()+1),d?.(F,X,U);},[w,d]),P=useMemo(()=>{let $=K=>K.map(X=>{if(X.subtasks&&X.subtasks.length>0){let U=$(X.subtasks),De=U.filter(ke=>ke.startDate&&ke.endDate);if(De.length>0){let ke=De.map(Pe=>Pe.startDate.getTime()),$e=De.map(Pe=>Pe.endDate.getTime()),be=new Date(Math.min(...ke)),tt=new Date(Math.max(...$e));return {...X,subtasks:U,startDate:be,endDate:tt}}return {...X,subtasks:U}}return X}),F=(K,X=[])=>{for(let U of K)X.push(U),U.subtasks&&U.subtasks.length>0&&(U.isExpanded===void 0||U.isExpanded)&&F(U.subtasks,X);return X},W=$(e);return F(W)},[e]),H=useCallback($=>{if(!$.startDate||!$.endDate)return {x:0,width:0};let F=$.startDate.getTime(),W=$.endDate.getTime(),E=o.getTime(),K=(F-E)/(1e3*60*60*24),X=(W-F)/(1e3*60*60*24),U=K*A*l,De=Math.max(A*l,40),ke=Math.max(X*A*l,De);return {x:U,width:ke}},[o,A,l]),q=useMemo(()=>P.filter($=>$.startDate&&$.endDate).map($=>{let{x:F,width:W}=H($),K=P.findIndex(X=>X.id===$.id)*a+12;return {id:$.id,x:F,y:K,width:W,height:32}}),[P,H]),he=useCallback(($,F,W)=>{if(!W||F===0){g([]);return}let E=le.calculateCascadePreview(e,$,F,P,o,A*l,a,48);g(E);},[e,P,o,A,l,a,48]),xe=useMemo(()=>{let $=[],F=new Date(o);for(;F<=s;){let K=(F.getTime()-o.getTime())/864e5*A*l;if(r==="day")$.push({date:new Date(F),label:F.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:K}),F.setDate(F.getDate()+1);else if(r==="week"){let X=B(F);$.push({date:new Date(F),label:`Week ${X}`,x:K}),F.setDate(F.getDate()+7);}else $.push({date:new Date(F),label:F.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:K}),F.setMonth(F.getMonth()+1);}return $},[o,s,r,A,l]),Ae=useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*A*l,[o,A,l]),Be=Math.max(P.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(v,1e3),height:47,style:{display:"block"},children:[jsx("rect",{x:0,y:0,width:Math.max(v,1e3),height:48,fill:t.bgGrid}),xe.map(($,F)=>jsxs("g",{children:[F>0&&jsx("line",{x1:$.x,y1:0,x2:$.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsx("text",{x:$.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:$.label})]},`header-${F}`)),Ae>=0&&Ae<=v&&jsx("circle",{cx:Ae,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxs("svg",{width:Math.max(v,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(v,1e3),height:Be,fill:t.bgPrimary}),xe.map(($,F)=>{let W=xe[F+1]?.x||v,E=T($.date);return jsxs("g",{children:[E&&jsx("rect",{x:$.x,y:0,width:W-$.x,height:P.length*a,fill:t.bgWeekend,opacity:1}),F>0&&jsx("line",{x1:$.x,y1:0,x2:$.x,y2:P.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},F)}),P.map(($,F)=>{let W=$.startDate&&$.endDate;return jsxs("g",{children:[jsx("rect",{x:0,y:F*a,width:v,height:a,fill:F%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${$.id}`),!W&&jsxs(Fragment,{children:[jsx("rect",{x:0,y:F*a,width:v,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:E=>R(E,$),onMouseEnter:E=>{E.currentTarget.setAttribute("fill",t.accentLight),E.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:E=>{E.currentTarget.setAttribute("fill","transparent"),E.currentTarget.setAttribute("opacity","1");}},`clickable-${$.id}`),jsx("text",{x:Ae>0?Ae:100,y:F*a+a/2,fill:t.textTertiary,fontSize:"12",fontFamily:"Inter, sans-serif",fontStyle:"italic",dominantBaseline:"middle",opacity:.4,style:{pointerEvents:"none",userSelect:"none"},children:"Click to set dates..."},`placeholder-${$.id}`)]})]},`row-group-${$.id}`)}),P.map(($,F)=>!$.dependencies||$.dependencies.length===0||!$.startDate||!$.endDate?null:$.dependencies.map(W=>{let E=P.find(De=>De.id===W);if(!E||!E.startDate||!E.endDate)return null;let K=P.findIndex(De=>De.id===W),X=H(E),U=H($);return jsx(an,{x1:X.x+X.width,y1:K*a+a/2,x2:U.x,y2:F*a+a/2,theme:t},`dep-${W}-${$.id}`)})),P.map(($,F)=>{if(!$.startDate||!$.endDate)return null;let{x:W,width:E}=H($),K=F*a+12,X=$.subtasks&&$.subtasks.length>0&&!$.isMilestone;return $.isMilestone?jsx(on,{task:$,x:W+E/2,y:K+16,theme:t,onClick:p},$.id):X?jsxs("g",{onClick:()=>p?.($),onContextMenu:U=>{U.preventDefault(),U.stopPropagation(),m?.($,U);},style:{cursor:"default"},children:[jsx("rect",{x:W,y:K,width:E,height:32,fill:t.primary,opacity:.25,rx:6}),jsx("line",{x1:W,y1:K,x2:W+E,y2:K,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W,y1:K,x2:W,y2:K+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W+E,y1:K,x2:W+E,y2:K+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W,y1:K+32,x2:W+E,y2:K+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),E>60&&jsx("text",{x:W+12,y:K+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:$.name})]},$.id):jsx(Qo,{task:$,x:W,y:K,width:E,theme:t,dayWidth:A*l,startDate:o,templates:c,onClick:p,onDoubleClick:n,onContextMenu:m,onDateChange:d,onDependencyCreate:i,allTaskPositions:q,onDragMove:he,onHoverChange:D},$.id)}),P.map(($,F)=>!$.dependencies||$.dependencies.length===0||!$.startDate||!$.endDate?null:$.dependencies.map(W=>{let E=P.find(de=>de.id===W);if(!E||!E.startDate||!E.endDate)return null;let K=P.findIndex(de=>de.id===W),X=H(E),U=H($),De=X.x+X.width,ke=K*a+a/2,$e=U.x,be=F*a+a/2,tt=$e-De,Pe=De+tt/2,et=de=>{let Ce=1-de,Ee=Ce*Ce,at=Ee*Ce,ut=de*de,Ie=ut*de,I=at*De+3*Ee*de*Pe+3*Ce*ut*Pe+Ie*$e,Y=at*ke+3*Ee*de*ke+3*Ce*ut*be+Ie*be;return {x:I,y:Y}},ht=20,Dt=[];for(let de=0;de<=ht;de++){let Ce=.1+de/ht*.8;Dt.push(et(Ce));}let dt=Dt[0],O=`M ${dt.x} ${dt.y} `+Dt.slice(1).map(de=>`L ${de.x} ${de.y}`).join(" ");return b&&b.x1===De&&b.y1===ke&&b.x2===$e&&b.y2===be?null:jsx("path",{d:O,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:()=>{y({x1:De,y1:ke,x2:$e,y2:be,onDelete:()=>u?.($.id,W)});}},`dep-hover-${W}-${$.id}`)})),f.map($=>jsxs("g",{style:{pointerEvents:"none"},children:[jsx("rect",{x:$.previewX,y:$.y-48,width:$.width,height:32,rx:8,fill:$.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs($.daysDelta)>0&&jsx("text",{x:$.previewX+$.width/2,y:$.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:$.daysDelta>0?`+${$.daysDelta}d`:`${$.daysDelta}d`})]},`cascade-preview-${$.taskId}`)),b&&(()=>{let{x1:$,y1:F,x2:W,y2:E,onDelete:K}=b,X=W-$,U=E-F,De=$+X/2,ke=(F+E)/2,$e=`M ${$} ${F} C ${De} ${F}, ${De} ${E}, ${W} ${E}`,be=6,tt=Math.atan2(U,X),Pe=W-be*Math.cos(tt-Math.PI/6),et=E-be*Math.sin(tt-Math.PI/6),ht=W-be*Math.cos(tt+Math.PI/6),Dt=E-be*Math.sin(tt+Math.PI/6),dt=t.dependency,O="#f87171";return jsxs("g",{onMouseLeave:()=>y(null),children:[jsx("path",{d:$e,fill:"none",stroke:"transparent",strokeWidth:50,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx("circle",{cx:De,cy:ke,r:25,fill:"transparent",style:{cursor:"pointer"}}),jsx("path",{d:$e,fill:"none",stroke:dt,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsx("path",{d:$e,fill:"none",stroke:dt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("path",{d:`M ${W} ${E} L ${Pe} ${et} M ${W} ${E} L ${ht} ${Dt}`,fill:"none",stroke:dt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("circle",{cx:W,cy:E,r:4,fill:dt,opacity:.9,style:{pointerEvents:"none"}}),jsxs(motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:de=>{de.stopPropagation(),y(null),K();},style:{cursor:"pointer"},children:[jsx("circle",{cx:De,cy:ke,r:9,fill:"rgba(248, 113, 113, 0.15)",stroke:O,strokeWidth:1.5,style:{transition:"all 0.15s ease"}}),jsx("line",{x1:De-3,y1:ke-3,x2:De+3,y2:ke+3,stroke:O,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:De+3,y1:ke-3,x2:De-3,y2:ke+3,stroke:O,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),Ae>=0&&Ae<=v&&jsx("line",{x1:Ae,y1:0,x2:Ae,y2:Be,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),k&&jsx(Nd,{tooltipData:k,theme:t})]})]})}var ln=[{name:"Azul",value:"#6366F1",light:"#818CF8"},{name:"P\xFArpura",value:"#A855F7",light:"#C084FC"},{name:"Rosa",value:"#EC4899",light:"#F472B6"},{name:"Rojo",value:"#EF4444",light:"#F87171"},{name:"Naranja",value:"#F59E0B",light:"#FBBF24"},{name:"Amarillo",value:"#EAB308",light:"#FACC15"},{name:"Lima",value:"#84CC16",light:"#A3E635"},{name:"Verde",value:"#10B981",light:"#34D399"},{name:"Esmeralda",value:"#059669",light:"#10B981"},{name:"Cyan",value:"#06B6D4",light:"#22D3EE"},{name:"Azul Cielo",value:"#0EA5E9",light:"#38BDF8"},{name:"\xCDndigo",value:"#4F46E5",light:"#6366F1"},{name:"Violeta",value:"#8B5CF6",light:"#A78BFA"},{name:"Fucsia",value:"#D946EF",light:"#E879F9"},{name:"Coral",value:"#F97316",light:"#FB923C"},{name:"Magenta",value:"#E11D48",light:"#FB7185"}];var Ws=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],Hs=[{id:"low",label:"Baja",color:"#10B981",icon:"\u{1F7E2}"},{id:"medium",label:"Media",color:"#F59E0B",icon:"\u{1F7E1}"},{id:"high",label:"Alta",color:"#F97316",icon:"\u{1F7E0}"},{id:"urgent",label:"Urgente",color:"#EF4444",icon:"\u{1F534}"}];function dn({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:l=false,mode:c=a?"edit":"create",theme:p="dark",customStatuses:n=[],availableTags:m=[],onCreateTag:d,attachments:i=[],onUploadAttachments:u,onDeleteAttachment:x}){let f=[...Ws,...n.filter(O=>!Ws.some(re=>re.id===O.id))],g=_e[p]||_e.dark,[k,h]=useState(false),[b,y]=useState(false),[D,N]=useState(false),[A,v]=useState(false),[B,T]=useState({top:0,left:0}),[w,R]=useState(null),[P,H]=useState(new Date),[q,he]=useState({top:0,left:0}),[xe,Ae]=useState(false),[Be,$]=useState([]),F=useRef(null),W=useRef(null),E=useRef(null),K=useRef(null),X$1=useRef(null),[U,De]=useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[ke,$e]=useState({});useEffect(()=>{a?(De({name:a.name,description:a.description||"",startDate:a.startDate,endDate:a.endDate,progress:a.progress,status:a.status||"todo",priority:a.priority||"medium",isMilestone:a.isMilestone||false,color:a.color||"#6366F1",assignees:a.assignees||[],dependencies:a.dependencies||[],tags:a.tags||[]}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&Ae(true)):(De({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),Ae(false),$([]));},[a,e]),useEffect(()=>{let O=re=>{F.current&&!F.current.contains(re.target)&&h(false),W.current&&!W.current.contains(re.target)&&y(false),E.current&&!E.current.contains(re.target)&&N(false),K.current&&!K.current.contains(re.target)&&v(false);};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]);let be=()=>{let O={};return U.name.trim()||(O.name="El nombre es requerido"),U.startDate&&U.endDate&&U.startDate>U.endDate&&(O.endDate="La fecha de fin debe ser posterior a la de inicio"),$e(O),Object.keys(O).length===0},tt=async O=>{if(O.preventDefault(),!!be())try{let re=c==="create"&&Be.length>0?{...U,pendingFiles:Be}:U;await s(re),$([]),t();}catch(re){console.error("Error submitting task:",re);}},Pe=(O,re)=>{De(de=>{let Ce={...de,[O]:re};if(O==="status"){let Ee=re;Ee==="todo"?Ce.progress=0:Ee==="in-progress"?(de.progress===0||de.progress===100)&&(Ce.progress=50):Ee==="completed"||Ee==="closed"?Ce.progress=100:(Ee==="in-review"||Ee==="review")&&(Ce.progress=75);}if(O==="progress"){let Ee=typeof re=="number"?re:parseInt(re,10);Ee===100&&de.status!=="completed"?Ce.status="completed":Ee>0&&Ee<100&&de.status==="todo"?Ce.status="in-progress":Ee===0&&de.status!=="todo"&&(Ce.status="todo");}return Ce}),ke[O]&&$e(de=>{let Ce={...de};return delete Ce[O],Ce});},et=f.find(O=>O.id===U.status)??Ws[0],ht=Hs.find(O=>O.id===U.priority)??Hs[1],Dt=ln.find(O=>O.value===U.color)??ln[0],dt={backgroundColor:g.bgSecondary,border:`1px solid ${g.borderLight}`,color:g.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:g.bgPrimary,border:`1px solid ${g.border}`},onClick:O=>O.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${g.border}`},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:et.color||g.accent}}),jsx("span",{className:"text-sm font-medium",style:{color:g.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:g.textTertiary},onMouseEnter:O=>{O.currentTarget.style.backgroundColor=g.hoverBg,O.currentTarget.style.color=g.textPrimary;},onMouseLeave:O=>{O.currentTarget.style.backgroundColor="transparent",O.currentTarget.style.color=g.textTertiary;},disabled:l,children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("form",{onSubmit:tt,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:U.name,onChange:O=>Pe("name",O.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:g.textPrimary},placeholder:"Nombre de la tarea",disabled:l,autoFocus:true}),ke.name&&jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsx(AlertCircle,{className:"w-3 h-3"}),ke.name]})]}),jsx("div",{children:jsx("textarea",{value:U.description||"",onChange:O=>Pe("description",O.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:g.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:l})}),jsx("div",{style:{borderTop:`1px solid ${g.borderLight}`}}),jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxs("div",{ref:F,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!l&&h(!k),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...dt,borderColor:et.color,backgroundColor:`${et.color}15`},disabled:l,children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:et.color}}),jsx("span",{style:{color:et.color},children:et.title}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:et.color}})]}),jsx(AnimatePresence,{children:k&&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:g.bgPrimary,border:`1px solid ${g.border}`},children:f.map(O=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:re=>re.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:re=>re.currentTarget.style.backgroundColor="transparent",onClick:()=>{Pe("status",O.id),h(false);},children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:O.color}}),O.title,U.status===O.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:g.accent}})]},O.id))})})]}),jsxs("div",{ref:W,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!l&&y(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:dt,disabled:l,children:[jsx(Flag,{className:"w-3.5 h-3.5",style:{color:ht.color}}),jsx("span",{children:ht.label}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsx(AnimatePresence,{children:b&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[130px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},children:Hs.map(O=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:re=>re.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:re=>re.currentTarget.style.backgroundColor="transparent",onClick:()=>{Pe("priority",O.id),y(false);},children:[jsx("span",{children:O.icon}),O.label,U.priority===O.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:g.accent}})]},O.id))})})]}),o.length>0&&jsxs("div",{ref:E,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!l&&N(!D),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:dt,disabled:l,children:[U.assignees&&U.assignees.length>0?jsxs(Fragment,{children:[jsx("div",{className:"flex -space-x-1",children:U.assignees.slice(0,3).map((O,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:O.color||g.accent,borderColor:g.bgSecondary},children:O.initials},re))}),U.assignees.length>3&&jsxs("span",{style:{color:g.textTertiary},children:["+",U.assignees.length-3]})]}):jsxs(Fragment,{children:[jsx(Users,{className:"w-3.5 h-3.5",style:{color:g.textTertiary}}),jsx("span",{style:{color:g.textTertiary},children:"Asignar"})]}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsx(AnimatePresence,{children:D&&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:g.bgPrimary,border:`1px solid ${g.border}`},children:o.map(O=>{let re=U.assignees?.some(de=>de.name===O.name);return jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:de=>de.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:de=>de.currentTarget.style.backgroundColor="transparent",onClick:()=>{let de=re?(U.assignees||[]).filter(Ce=>Ce.name!==O.name):[...U.assignees||[],{name:O.name,avatar:O.avatar,initials:O.name.split(" ").map(Ce=>Ce[0]).join("").toUpperCase().slice(0,2),color:g.accent}];Pe("assignees",de);},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:g.accent},children:O.name.charAt(0).toUpperCase()}),jsx("span",{className:"truncate flex-1 text-left",children:O.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:g.accent}})})]},O.id)})})})]}),jsxs("div",{ref:K,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>{if(!l)if(A)v(false);else {if(K.current){let O=K.current.getBoundingClientRect(),re=window.innerHeight,de=120,Ee=re-O.bottom<de?O.top-de-8:O.bottom+8;T({top:Ee,left:O.left});}v(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:dt,disabled:l,children:[jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:U.color}}),jsx("span",{children:Dt.name}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsx(AnimatePresence,{children:A&&jsxs(rt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>v(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:`${B.top}px`,left:`${B.left}px`,zIndex:99999,backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick:O=>O.stopPropagation(),children:jsx("div",{style:{padding:"6px 8px"},children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 28px)",gap:"2px"},children:ln.slice(0,18).map(O=>{let re=U.color===O.value;return jsx("button",{type:"button",onClick:de=>{de.preventDefault(),de.stopPropagation(),Pe("color",O.value),v(false);},style:{width:"28px",height:"28px",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",border:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0},title:O.name,children:jsx("span",{style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:O.value,outline:re?`2px solid ${O.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},O.value)})})})})]})})]}),m.length>0||d?jsx(Wr,{selectedTags:U.tags||[],availableTags:m,onChange:O=>Pe("tags",O),onCreateTag:d,theme:g,disabled:l}):null]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Calendar,{className:"w-4 h-4",style:{color:g.textTertiary}}),jsxs("div",{ref:X$1,className:"flex items-center gap-2 flex-1 relative",children:[jsx("button",{type:"button",onClick:()=>{if(!l&&!U.isMilestone)if(w==="start")R(null);else {if(X$1.current){let O=X$1.current.getBoundingClientRect(),re=window.innerHeight,de=320,Ee=re-O.bottom<de?O.top-de-8:O.bottom+8;he({top:Ee,left:O.left});}R("start"),H(U.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...dt,opacity:U.isMilestone?.5:1,cursor:U.isMilestone?"not-allowed":"pointer"},disabled:l||U.isMilestone,children:U.startDate?U.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsx("span",{style:{color:g.textTertiary},children:"\u2192"}),jsx("button",{type:"button",onClick:()=>{if(!l&&!U.isMilestone)if(w==="end")R(null);else {if(X$1.current){let O=X$1.current.getBoundingClientRect(),re=window.innerHeight,de=320,Ee=re-O.bottom<de?O.top-de-8:O.bottom+8;he({top:Ee,left:O.left});}R("end"),H(U.endDate||U.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...dt,opacity:U.isMilestone?.5:1,cursor:U.isMilestone?"not-allowed":"pointer"},disabled:l||U.isMilestone,children:U.endDate?U.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsx(AnimatePresence,{children:w&&jsxs(rt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>R(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:g.bgPrimary,border:`1px solid ${g.border}`},onClick:O=>O.stopPropagation(),children:[jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${g.border}`},children:[(()=>{let O=new Date,re=new Date(O);re.setDate(O.getDate()+1);let de=new Date(O);de.setDate(O.getDate()+7);let Ce=new Date(O);return Ce.setDate(O.getDate()+14),[{label:"Hoy",date:O},{label:"Ma\xF1ana",date:re},{label:"Pr\xF3xima semana",date:de},{label:"2 semanas",date:Ce}].map((at,ut)=>jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:g.textPrimary},onMouseEnter:Ie=>Ie.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:Ie=>Ie.currentTarget.style.backgroundColor="transparent",onClick:()=>{w==="start"?(Pe("startDate",at.date),(!U.endDate||at.date>U.endDate)&&Pe("endDate",at.date),R("end")):(Pe("endDate",at.date),(!U.startDate||at.date<U.startDate)&&Pe("startDate",at.date),R(null));},children:at.label},ut))})(),jsx("div",{style:{borderTop:`1px solid ${g.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:O=>O.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:O=>O.currentTarget.style.backgroundColor="transparent",onClick:()=>{Pe("startDate",void 0),Pe("endDate",void 0),R(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:()=>H(new Date(P.getFullYear(),P.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-4 h-4",style:{color:g.textSecondary}})}),jsx("span",{className:"text-sm font-medium",style:{color:g.textPrimary},children:P.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>H(new Date(P.getFullYear(),P.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-4 h-4",style:{color:g.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((O,re)=>jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:g.textTertiary},children:O},re))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let O=P.getFullYear(),re=P.getMonth(),de=new Date(O,re,1).getDay(),Ce=new Date(O,re+1,0).getDate(),Ee=new Date,at=[];for(let Ie=de-1;Ie>=0;Ie--)at.push({day:new Date(O,re,-Ie).getDate(),date:new Date(O,re-1,new Date(O,re,-Ie).getDate()),isCurrentMonth:false});for(let Ie=1;Ie<=Ce;Ie++)at.push({day:Ie,date:new Date(O,re,Ie),isCurrentMonth:true});let ut=42-at.length;for(let Ie=1;Ie<=ut;Ie++)at.push({day:Ie,date:new Date(O,re+1,Ie),isCurrentMonth:false});return at.map((Ie,I)=>{let Y=Ie.date.toDateString()===Ee.toDateString(),He=U.startDate?.toDateString()===Ie.date.toDateString(),We=U.endDate?.toDateString()===Ie.date.toDateString(),yt=U.startDate&&U.endDate&&Ie.date>=U.startDate&&Ie.date<=U.endDate;return jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:Ie.isCurrentMonth?He||We?"#FFF":g.textPrimary:g.textTertiary,backgroundColor:He?"#3B82F6":We?"#7C3AED":yt?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:Y&&!He&&!We?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{w==="start"?(Pe("startDate",Ie.date),U.endDate&&Ie.date>U.endDate&&Pe("endDate",Ie.date),R("end")):(Pe("endDate",Ie.date),U.startDate&&Ie.date<U.startDate&&Pe("startDate",Ie.date),R(null));},children:Ie.day},I)})})()})]})]})]})})]}),ke.endDate&&jsx("span",{className:"text-xs text-red-400",children:ke.endDate})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:"w-4 h-4",style:{color:g.textTertiary}}),jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsx("input",{type:"range",min:"0",max:"100",step:"5",value:U.progress,onChange:O=>Pe("progress",parseInt(O.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:g.bgSecondary,accentColor:U.progress<30?"#EF4444":U.progress<70?"#F59E0B":"#10B981"},disabled:l}),jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${U.progress<30?"#EF4444":U.progress<70?"#F59E0B":"#10B981"}20`,color:U.progress<30?"#EF4444":U.progress<70?"#F59E0B":"#10B981"},children:[U.progress,"%"]})]})]}),(u||i.length>0||c==="create")&&jsxs("div",{className:"pt-2",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:g.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:g.textTertiary},children:["Adjuntos ",c==="create"?Be.length>0&&`(${Be.length})`:i.length>0&&`(${i.length})`]})]}),c==="create"?jsx($a,{cardId:"pending",attachments:Be.map((O,re)=>({id:`pending-${re}`,cardId:"pending",name:O.name,size:O.size,type:O.type,url:URL.createObjectURL(O),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:O=>$(re=>[...re,...O]),onDelete:O=>{let re=parseInt(O.replace("pending-",""),10);$(de=>de.filter((Ce,Ee)=>Ee!==re));},maxSizeMB:10,maxFiles:20}):jsx($a,{cardId:a?.id||"new",attachments:i,onUpload:u&&a?.id?O=>u(a.id,O):void 0,onDelete:x,maxSizeMB:10,maxFiles:20}),c==="create"&&Be.length>0&&jsxs("p",{className:"text-xs mt-1",style:{color:g.textTertiary},children:[Be.length," archivo(s) se subir\xE1n al crear la tarea"]})]}),jsxs("div",{children:[jsxs("button",{type:"button",onClick:()=>Ae(!xe),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:g.textTertiary},children:[jsx(ChevronDown,{className:`w-3 h-3 transition-transform ${xe?"rotate-180":""}`}),"Opciones avanzadas"]}),jsx(AnimatePresence,{children:xe&&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:[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:U.isMilestone,onChange:O=>Pe("isMilestone",O.target.checked),className:"w-4 h-4 rounded",style:{accentColor:g.accent},disabled:l}),jsx(Milestone,{className:"w-4 h-4 text-yellow-500"}),jsx("span",{className:"text-sm",style:{color:g.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:g.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:g.bgSecondary},children:r.filter(O=>O.id!==a?.id).map(O=>{let re=U.dependencies?.includes(O.id);return jsx("button",{type:"button",onClick:()=>{let de=re?(U.dependencies||[]).filter(Ce=>Ce!==O.id):[...U.dependencies||[],O.id];Pe("dependencies",de);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:re?`${g.accent}30`:g.bgPrimary,color:re?g.accent:g.textSecondary,border:`1px solid ${re?g.accent:g.borderLight}`},disabled:l,children:O.name},O.id)})})]})]})})})]})]}),jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${g.border}`},children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:g.textSecondary},onMouseEnter:O=>O.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:O=>O.currentTarget.style.backgroundColor="transparent",disabled:l,children:"Cancelar"}),jsx("button",{type:"submit",disabled:l,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:g.accent,color:"#FFF"},onMouseEnter:O=>!l&&(O.currentTarget.style.opacity="0.9"),onMouseLeave:O=>!l&&(O.currentTarget.style.opacity="1"),children:l?jsxs(Fragment,{children:[jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsx(Fragment,{children:c==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var df=['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"'],Ad=()=>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"})]}),cf=()=>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"})}),pf=()=>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"})}),mf=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M5 12h14"})}),uf=()=>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 cn({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:l,onDependencyCreate:c,onDependencyDelete:p}){let[n,m]=useState(false),[d,i]=useState(false),[u,x]=useState([]),[f,g]=useState(""),[k,h]=useState(false),[b,y]=useState(true),D=useRef(null),N=useRef(null),A=useRef(null),{enabled:v=true,placeholder:B='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:T="bottom-right",onCommand:w,suggestions:R=df,maxHistory:P=50,persistHistory:H}=a,q=H?.storageKey||"gantt-ai-history",he=H?.maxMessages??5;useEffect(()=>{if(H?.enabled)try{let W=localStorage.getItem(q);if(W){let K=JSON.parse(W).map(X=>({...X,timestamp:new Date(X.timestamp)}));x(K.slice(-he));}}catch(W){console.warn("[GanttAIAssistant] Failed to load persisted history:",W);}},[H?.enabled,q,he]),useEffect(()=>{if(H?.enabled&&u.length>0)try{let W=u.filter(E=>!E.isLoading).slice(-he);localStorage.setItem(q,JSON.stringify(W));}catch(W){console.warn("[GanttAIAssistant] Failed to persist history:",W);}},[u,H?.enabled,q,he]),useEffect(()=>{N.current&&N.current.scrollIntoView({behavior:"smooth"});},[u]),useEffect(()=>{n&&!d&&D.current&&setTimeout(()=>D.current?.focus(),100);},[n,d]);let xe=useCallback(W=>{if(W.success)switch(W.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":W.taskId&&W.updates&&o?.(W.taskId,W.updates);break;case "create_task":W.newTask&&s?.(W.newTask);break;case "delete_task":W.taskId&&l?.(W.taskId);break;case "link_tasks":W.dependencyFrom&&W.dependencyTo&&c?.(W.dependencyFrom,W.dependencyTo);break;case "unlink_tasks":W.taskId&&W.dependencyFrom&&p?.(W.taskId,W.dependencyFrom);break}},[o,s,l,c,p]),Ae=useCallback(async W=>{if(!W.trim()||k)return;let E={id:`user-${Date.now()}`,role:"user",content:W,timestamp:new Date};x(X=>[...X.slice(-(P-1)),E]),g(""),y(false),h(true);let K={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};x(X=>[...X,K]);try{if(w){let X=await w(W,e);x(U=>{let De=U.filter($e=>!$e.isLoading),ke={id:`assistant-${Date.now()}`,role:"assistant",content:X.message,timestamp:new Date,command:X};return [...De,ke]}),xe(X);}else x(X=>[...X.filter(De=>!De.isLoading),{id:`assistant-${Date.now()}`,role:"assistant",content:"AI handler not configured. Please provide an onCommand handler in the aiAssistant config.",timestamp:new Date}]);}catch(X){x(U=>[...U.filter(ke=>!ke.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${X instanceof Error?X.message:"Unknown error"}`,timestamp:new Date}]);}finally{h(false);}},[k,P,w,e,xe]),Be=W=>{W.preventDefault(),Ae(f);},$=W=>{g(W),D.current?.focus();};if(useEffect(()=>{let W=E=>{(E.metaKey||E.ctrlKey)&&E.key==="k"&&(E.preventDefault(),m(K=>!K),n||i(false)),E.key==="Escape"&&n&&m(false);};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[n]),useEffect(()=>{if(!n)return;let W=K=>{let X=K.target;A.current&&!A.current.contains(X)&&m(false);},E=setTimeout(()=>{document.addEventListener("mousedown",W);},100);return ()=>{clearTimeout(E),document.removeEventListener("mousedown",W);}},[n]),!v)return null;let F={"bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-right":"top-4 right-4","top-left":"top-4 left-4"};return jsxs(rt,{children:[jsx(AnimatePresence,{children:!n&&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 ${F[T]} z-[99999] flex items-center gap-2 px-4 py-3 rounded-full shadow-lg transition-colors`,style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"white",boxShadow:"0 4px 20px rgba(59, 130, 246, 0.4)"},onClick:()=>m(true),children:[jsx(Ad,{}),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:n&&jsxs(motion.div,{ref:A,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:d?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${F[T]} z-[99999] w-96 rounded-2xl overflow-hidden shadow-2xl flex flex-col`,style:{background:t.bgPrimary,border:`1px solid ${t.border}`,boxShadow:`0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px ${t.border}`},children:[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(Ad,{}),jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>i(W=>!W),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(mf,{})}),jsx("button",{onClick:()=>m(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(pf,{})})]})]}),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:[u.length===0&&b&&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:R.slice(0,4).map((W,E)=>jsx("button",{onClick:()=>$(W),className:"text-xs px-3 py-1.5 rounded-full transition-colors",style:{background:t.bgSecondary,color:t.textSecondary,border:`1px solid ${t.border}`},children:W.length>30?W.slice(0,30)+"...":W},E))})]}),u.map(W=>jsx(motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${W.role==="user"?"justify-end":"justify-start"}`,children:jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${W.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:W.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:W.role==="user"?"white":t.textPrimary},children:[W.isLoading?jsx(uf,{}):jsx("p",{className:"text-sm whitespace-pre-wrap",children:W.content}),W.command&&jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:W.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:W.command.success?"#10B981":"#EF4444"},children:[W.command.success?"\u2713":"\u2717",jsx("span",{className:"capitalize",children:W.command.type.replace(/_/g," ")})]})]})},W.id)),jsx("div",{ref:N})]}),jsxs("form",{onSubmit:Be,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:D,type:"text",value:f,onChange:W=>g(W.target.value),placeholder:B,disabled:k,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsx("button",{type:"submit",disabled:!f.trim()||k,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:f.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:f.trim()?"white":t.textSecondary},children:jsx(cf,{})})]}),jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function Id(e,t=50){let[a,r]=useState({past:[],present:e,future:[]}),o=useRef(false),s=useCallback((n,m=true)=>{r(d=>{let i=typeof n=="function"?n(d.present):n;if(o.current)return {...d,present:i};if(!m)return {...d,present:i};let u=[...d.past,d.present];return u.length>t&&u.shift(),{past:u,present:i,future:[]}});},[t]),l=useCallback(()=>{r(n=>{if(n.past.length===0)return n;let m=n.past[n.past.length-1],d=n.past.slice(0,n.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:m,future:[n.present,...n.future]}});},[]),c=useCallback(()=>{r(n=>{if(n.future.length===0)return n;let m=n.future[0],d=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:m,future:d}});},[]),p=useCallback(()=>{r(n=>({past:[],present:n.present,future:[]}));},[]);return {state:a.present,setState:s,undo:l,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function Ld({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){useEffect(()=>{if(!o)return;let s=l=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,p=c?l.metaKey:l.ctrlKey;if(p&&l.key==="z"&&!l.shiftKey&&a){l.preventDefault(),e();return}if(r){if(!c&&p&&l.key==="y"){l.preventDefault(),t();return}if(c&&p&&l.shiftKey&&l.key==="z"){l.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var bf={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${le.formatDate(e.startDate)} - ${le.formatDate(e.endDate)}`);let a=le.calculateDuration(e.startDate,e.endDate);t.push(`Duration: ${a} days`);}if(e.progress!==void 0&&t.push(`Progress: ${e.progress}%`),e.status&&t.push(`Status: ${e.status}`),e.assignees&&e.assignees.length>0){let a=e.assignees.map(r=>r.name).join(", ");t.push(`Assigned: ${a}`);}return e.dependencies&&e.dependencies.length>0&&t.push(`Dependencies: ${e.dependencies.length}`),t.join("<br/>")},taskLabel:e=>e.name,gridCell:(e,t,a)=>a,taskClass:e=>{let t=[];return e.isCriticalPath&&t.push("critical-path"),e.status==="completed"?t.push("completed"):e.status==="in-progress"?t.push("in-progress"):e.status==="todo"&&t.push("todo"),e.isMilestone&&t.push("milestone"),t.join(" ")},milestoneContent:e=>`\u25C6 ${e.name}`,dateFormat:e=>le.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function Fd(e){return {...bf,...e}}var Tf=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},Od=forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:l="week",rowDensity:c="comfortable",showThemeSelector:p=true,showExportButton:n=true,availableUsers:m=[],templates:d,enableAutoCriticalPath:i=true,persistExpandedState:u,aiAssistant:x,locale:f="en",customTranslations:g,showCreateTaskButton:k=false,createTaskLabel:h,onCreateTask:b,onThemeChange:y,onTaskClick:D,onTaskDblClick:N,onTaskContextMenu:A,onTaskUpdate:v,onProgressChange:B,onTaskEdit:T,onTaskAddSubtask:w,onTaskMarkIncomplete:R,onTaskSetInProgress:P,onDependencyCreate:H,onDependencyDelete:q,onBeforeTaskAdd:he,onAfterTaskAdd:xe,onBeforeTaskUpdate:Ae,onAfterTaskUpdate:Be,onBeforeTaskDelete:$,onAfterTaskDelete:F}=a,E=useContext(jo)?.theme,[K,X]=useState(E||s||"dark"),[U,De]=useState(l),[ke,$e]=useState(c),[be,tt]=useState(1),[Pe,et]=useState(0),[ht,Dt]=useState(false),[dt,O]=useState(null),[re,de]=useState({isOpen:false,x:0,y:0,task:null}),[Ce,Ee]=useState(null),[at,ut]=useState(null);useEffect(()=>{E&&E!==K&&X(E);},[E]),useEffect(()=>{s&&s!==K&&X(s);},[s]);let Ie=useCallback(S=>{X(S),y?.(S);},[y]),{state:I,setState:Y,undo:He,redo:We,canUndo:yt,canRedo:Q,clearHistory:te}=Id(t,50),ve=useCallback(()=>u?typeof u=="string"?u:"gantt-expanded-tasks":null,[u]),Te=useRef(new Map),oe=useRef(false);if(!oe.current&&u){oe.current=true;let S=typeof u=="string"?u:"gantt-expanded-tasks";try{let M=localStorage.getItem(S);if(M){let j=JSON.parse(M);Array.isArray(j)&&(Te.current=new Map(j));}}catch(M){console.warn("[GanttBoard] Error loading expanded state from localStorage:",M);}}let Se=useCallback(()=>{let S=ve();if(S)try{let M=Array.from(Te.current.entries());localStorage.setItem(S,JSON.stringify(M));}catch(M){console.warn("[GanttBoard] Error saving expanded state to localStorage:",M);}},[ve]);useEffect(()=>{let S=M=>M.map(j=>{let J=Te.current.get(j.id),ce=J!==void 0?{...j,isExpanded:J}:j;return ce.subtasks?.length?{...ce,subtasks:S(ce.subtasks)}:ce});Te.current.size>0?Y(S(t)):Y(t);},[t,Y]);let ye=useRef(t),Ne=useRef(true);useEffect(()=>{if(Ne.current){Ne.current=false,ye.current=I;return}if(!r)return;let S=JSON.stringify(ye.current),M=JSON.stringify(I);S!==M&&(ye.current=I,r(I));},[I,r]);let ie=useMemo(()=>Ds(f,g),[f,g]),Fe=useCallback(S=>[{id:"name",label:S.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:S.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:S.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:S.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:S.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:S.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:S.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:S.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Me,Re]=useState(()=>Fe(ie));useEffect(()=>{Re(S=>S.map(M=>({...M,label:ie.columns[M.id==="name"?"taskName":M.id]||M.label})));},[ie]);let Mt=useMemo(()=>{let S=Me.filter(J=>J.visible),M=S.some(J=>J.id!=="name");return S.reduce((J,ce)=>J+ce.width,0)+(M?20:0)},[Me]),V=useRef(Me.filter(S=>S.visible).map(S=>S.id).join(","));useEffect(()=>{let S=Me.filter(J=>J.visible),M=S.map(J=>J.id).join(","),j=V.current;if(M!==j){let J=S.some(we=>we.id!=="name"),ce=j.includes(",");J?!ce&&J&&O(null):O(null),V.current=M;}},[Me]);let Z=useMemo(()=>dt!==null?Math.max(280,dt):Math.max(280,Mt),[dt,Mt]),nt=useRef(null),fe=useRef(null),Ue=useRef(null),Je=useMemo(()=>Zl(K),[K]),z=useMemo(()=>({theme:Je,themeName:K}),[Je,K]),ne=useMemo(()=>Fd(d),[d]),Ge=useMemo(()=>{if(!i)return I;let S=le.calculateCriticalPath(I),M=j=>j.map(J=>({...J,isCriticalPath:S.includes(J.id),subtasks:J.subtasks?M(J.subtasks):void 0}));return M(I)},[I,i]),Ke=Tf(ke);Ld({undo:He,redo:We,canUndo:yt,canRedo:Q,enabled:true}),useImperativeHandle(o,()=>({getTask:S=>le.findTaskById(I,S),addTask:(S,M)=>{Y(j=>{if(!M)return [...j,{...S,level:0}];let J=ce=>ce.map(we=>we.id===M?{...we,subtasks:[...we.subtasks||[],{...S,parentId:M,level:(we.level||0)+1}],isExpanded:true}:we.subtasks?{...we,subtasks:J(we.subtasks)}:we);return J(j)});},updateTask:(S,M)=>{Y(j=>{let J=ce=>ce.map(we=>we.id===S?{...we,...M}:we.subtasks?{...we,subtasks:J(we.subtasks)}:we);return J(j)});},deleteTask:S=>{Y(M=>{let j=J=>J.filter(ce=>ce.id===S?false:(ce.subtasks&&(ce.subtasks=j(ce.subtasks)),true));return j(M)});},deleteTasks:S=>{Y(M=>Is(M,S));},duplicateTask:S=>{Y(M=>Ls(M,[S]));},splitTask:(S,M,j=3)=>{Y(J=>le.splitTask(J,S,M,j));},calculateEndDate:le.calculateEndDate,calculateDuration:le.calculateDuration,validateDependency:(S,M)=>!le.validateDependencies(I,S,M),getAllTasks:()=>le.flattenTasks(I),getTasksByStatus:S=>le.flattenTasks(I).filter(M=>M.status===S),getTasksByParent:S=>S?le.findTaskById(I,S)?.subtasks||[]:I.filter(j=>!j.parentId),getCriticalPath:()=>le.flattenTasks(I).filter(S=>S.isCriticalPath),indentTask:S=>{Y(M=>Ps(M,[S]));},outdentTask:S=>{Y(M=>Ms(M,[S]));},moveTask:(S,M)=>{Y(j=>As(j,[S],M));},createSubtask:async S=>{let{tasks:M,newTask:j}=Rs(I,S);if(he){let J=he({...j,parentId:S});if((J instanceof Promise?await J:J)===false)return}Y(M),xe&&xe({...j,parentId:S});},scrollToTask:S=>{let j=le.flattenTasks(I).findIndex(J=>J.id===S);if(j!==-1&&nt.current){let J=j*Ke;nt.current.scrollTo({top:J,behavior:"smooth"}),fe.current&&fe.current.scrollTo({top:J,behavior:"smooth"});}},highlightTask:(S,M=2e3)=>{},expandTask:S=>{Y(M=>{let j=J=>J.map(ce=>ce.id===S?{...ce,isExpanded:true}:ce.subtasks?{...ce,subtasks:j(ce.subtasks)}:ce);return j(M)});},collapseTask:S=>{Y(M=>{let j=J=>J.map(ce=>ce.id===S?{...ce,isExpanded:false}:ce.subtasks?{...ce,subtasks:j(ce.subtasks)}:ce);return j(M)});},expandAll:()=>{Y(S=>{let M=j=>j.map(J=>({...J,isExpanded:true,subtasks:J.subtasks?M(J.subtasks):void 0}));return M(S)});},collapseAll:()=>{Y(S=>{let M=j=>j.map(J=>({...J,isExpanded:false,subtasks:J.subtasks?M(J.subtasks):void 0}));return M(S)});},undo:He,redo:We,canUndo:()=>yt,canRedo:()=>Q,clearHistory:te,exportToPNG:async()=>{if(!Ue.current)throw new Error("Gantt container not found");let S=await Rd(Ue.current,{backgroundColor:Je.bgPrimary,scale:2});return new Promise((M,j)=>{S.toBlob(J=>{J?M(J):j(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async S=>{await le.exportToPDF(I,S);},exportToExcel:async S=>{await le.exportToExcel(I,S);},exportToJSON:()=>le.exportToJSON(I),exportToCSV:()=>le.exportToCSV(I),importFromJSON:S=>{let M=le.importFromJSON(S);Y(M);},getTasks:()=>I,refresh:()=>{Y(S=>[...S]);},clearAll:()=>{Y([]);}}),[I,He,We,yt,Q,te,Je,Ke]);let aa=useCallback(S=>{Re(M=>M.map(j=>j.id===S?{...j,visible:!j.visible}:j));},[]),dr=useCallback((S,M)=>{Re(j=>j.map(J=>{if(J.id!==S)return J;let ce=J.minWidth??100,we=J.maxWidth??800,zt=Math.max(ce,Math.min(we,M));return {...J,width:zt}}));},[]),qa=useCallback(S=>{Y(M=>{let j=Bs(M,S),J=ce=>{for(let we of ce){if(we.id===S){Te.current.set(S,we.isExpanded??true);return}we.subtasks?.length&&J(we.subtasks);}};return J(j),Se(),j}),a.onTaskToggleExpand?.(S);},[a,Se]),Ra=useCallback((S,M)=>{if(Ae&&Ae(S,M)===false)return;let J=le.findTaskById(I,S)?.progress,ce=zt=>zt.map(_t=>_t.id===S?{..._t,...M}:_t.subtasks?{..._t,subtasks:ce(_t.subtasks)}:_t);Y(ce(I));let we=le.findTaskById(ce(I),S);we&&(v?.(we),Be?.(we),M.progress!==void 0&&J!==void 0&&M.progress!==J&&B?.(S,J,M.progress));},[I,v,Ae,Be,B]),pe=useCallback(S=>{S.length!==0&&(Y(M=>Ps(M,S)),a.onTaskIndent?.(S[0]));},[a]),Nt=useCallback(S=>{S.length!==0&&(Y(M=>Ms(M,S)),a.onTaskOutdent?.(S[0]));},[a]),Jt=useCallback((S,M,j)=>{Y(J=>yd(J,S,M,j)),a.onTaskReparent?.(S,M,j);},[a]),Ar=useCallback((S,M)=>{S.length!==0&&(Y(j=>As(j,S,M)),a.onTaskMove?.(S[0],M));},[a]),Ir=useCallback(async S=>{let M=[];for(let j of S)$&&await Promise.resolve($(j))===false||M.push(j);M.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(M):(Y(j=>Is(j,M)),M.forEach(j=>a.onTaskDelete?.(j))),F&&M.forEach(j=>F(j)));},[a,$,F]),Lr=useCallback(S=>{Y(M=>Ls(M,S)),S.forEach(M=>a.onTaskDuplicate?.(M));},[a]),Ha=useCallback((S,M)=>{Y(j=>{let{tasks:J,newTask:ce}=bd(j,S,M);return he&&he(ce)===false?j:(a.onTaskCreate?.(ce.parentId,ce.position||0),xe?.(ce),J)});},[a,he,xe]),cr=useCallback((S,M)=>{Y(j=>Fs(j,S,M)),a.onTaskRename?.(S,M);},[a]),St=useCallback(S=>{Y(M=>{let{tasks:j}=Rs(M,S);return a.onTaskCreate?.(S,0),j});},[a]),Mn=useCallback((S,M,j)=>{let J=S.startDate?Math.round((M.getTime()-S.startDate.getTime())/864e5):0,ce=_t=>_t.map(Zt=>Zt.id===S.id?{...Zt,startDate:M,endDate:j,...S.segments&&{segments:S.segments}}:Zt.subtasks?{...Zt,subtasks:ce(Zt.subtasks)}:Zt),we=ce(I);we=le.autoScheduleDependents(we,S.id,J),Y(we);let zt={...S,startDate:M,endDate:j};v?.(zt);},[I,v]),An=useCallback((S,M)=>{A?.(S,M),de({isOpen:true,x:M.clientX,y:M.clientY,task:S});},[A]),Oi=useCallback((S,M)=>{let j=le.splitTask(I,S.id,M);Y(j),de({isOpen:false,x:0,y:0,task:null});},[I]),Fr=useCallback(S=>{let M=le.findTaskById(I,S.id)||S;N?.(M),T||Ee(M);},[I,N,T]),zi=useCallback((S,M,j)=>{let J=new Map,ce=Da=>{Da.forEach(Ga=>{Ga.dependencies&&J.set(Ga.id,Ga.dependencies),Ga.subtasks&&ce(Ga.subtasks);});};ce(j);let we=J.get(M)||[];J.set(M,[...we,S]);let zt=new Set,_t=new Set,Zt=Da=>{if(!zt.has(Da)){zt.add(Da),_t.add(Da);let Ga=J.get(Da)||[];for(let pr of Ga){if(!zt.has(pr)&&Zt(pr))return true;if(_t.has(pr))return true}}return _t.delete(Da),false};return Zt(M)},[]),$i=useCallback((S,M)=>{if(zi(S.id,M,I)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
|
|
342
|
+
</Project>`,m=new Blob([n],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(m),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=se.flattenTasks(e),a=t.filter(n=>n.startDate&&n.endDate);if(a.length===0)return [];let r=new Map,o=n=>{if(r.has(n.id))return;let m=n.startDate&&n.endDate?se.calculateDuration(n.startDate,n.endDate):0,d=0;if(n.dependencies&&n.dependencies.length>0)for(let u of n.dependencies){let x=t.find(f=>f.id===u);if(x){o(x);let f=r.get(u)?.ef||0;d=Math.max(d,f);}}let i=d+m;r.set(n.id,{es:d,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(n=>n.ef)),l=new Map,c=n=>{if(l.has(n.id))return;let m=n.startDate&&n.endDate?se.calculateDuration(n.startDate,n.endDate):0,d=t.filter(x=>x.dependencies&&x.dependencies.includes(n.id)),i=s;if(d.length>0)for(let x of d){c(x);let f=l.get(x.id)?.ls||0;i=Math.min(i,f);}let u=i-m;l.set(n.id,{ls:u,lf:i});};a.forEach(c);let p=[];for(let n of a){let m=r.get(n.id),d=l.get(n.id);if(m&&d){let i=d.ls-m.es;Math.abs(i)<.01&&p.push(n.id);}}return p},calculateSlack:(e,t)=>{let a=se.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(se.calculateCriticalPath(e).includes(t))return 0;let o=se.getDependentTasks(e,t);if(o.length===0){let c=se.getLatestEndDate(e);if(!c)return null;let p=se.calculateDuration(a.endDate,c);return Math.max(0,p)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,p)=>c-p)[0];if(!s)return null;let l=se.calculateDuration(a.endDate,new Date(s));return Math.max(0,l)},isOnCriticalPath:(e,t)=>se.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=se.findTaskById(e,t);if(!r||!r.endDate)return e;let o=se.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let l of o){if(!l.startDate||!l.endDate)continue;let c=se.calculateDuration(l.startDate,l.endDate),p;a!==void 0?(p=new Date(l.startDate),p.setDate(p.getDate()+a)):(p=new Date(r.endDate),p.setDate(p.getDate()+1));let n=se.calculateEndDate(p,c),m=d=>d.map(i=>i.id===l.id?{...i,startDate:p,endDate:n}:i.subtasks?{...i,subtasks:m(i.subtasks)}:i);s=m(s),s=se.autoScheduleDependents(s,l.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,l,c)=>{if(a===0)return [];let p=[],n=o.getTime(),m=1e3*60*60*24,d=se.findTaskById(e,t);if(!d||!d.endDate)return [];let i=(u,x,f=new Set)=>{if(f.has(u))return;f.add(u);let g=se.getDependentTasks(e,u);for(let k of g){if(!k.startDate||!k.endDate)continue;let h=r.findIndex(w=>w.id===k.id);if(h===-1)continue;let b=k.startDate.getTime(),D=(k.endDate.getTime()-b)/m,A=(b-n)/m*s,v=A+x*s,F=Math.max(D*s,s),T=c+h*l+12;p.push({taskId:k.id,taskName:k.name,originalX:A,previewX:v,width:F,y:T,rowIndex:h,daysDelta:x,color:k.color}),i(k.id,x,f);}};return i(t,a),p},splitTask:(e,t,a,r=3)=>{let o=se.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let l=new Date(a);l.setDate(l.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let p=[{startDate:new Date(o.startDate),endDate:s},{startDate:l,endDate:c}],n=m=>m.map(d=>d.id===o.id?{...d,endDate:c,segments:p}:d.subtasks?{...d,subtasks:n(d.subtasks)}:d);return n(e)}};function tn({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:l,templates:c,onTaskClick:p,onTaskDblClick:n,onTaskContextMenu:m,onTaskDateChange:d,onDependencyCreate:i,onDependencyDelete:u}){let[f,g]=useState([]),[k,h]=useState(null),[b,y]=useState(null),D=useCallback(z=>{h(z);},[]),N=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),A=r==="day"?60:r==="week"?20:8,v=N*A*l,F=z=>{let L=new Date(Date.UTC(z.getFullYear(),z.getMonth(),z.getDate())),U=L.getUTCDay()||7;L.setUTCDate(L.getUTCDate()+4-U);let E=new Date(Date.UTC(L.getUTCFullYear(),0,1));return Math.ceil(((L.getTime()-E.getTime())/864e5+1)/7)},T=z=>{let L=z.getDay();return L===0||L===6},w=useCallback(z=>{let L=Math.round(z/(A*l)),U=new Date(o);return U.setDate(U.getDate()+L),U},[o,A,l]),B=useCallback((z,L)=>{if(L.startDate&&L.endDate)return;let U=z.currentTarget.ownerSVGElement;if(!U)return;let E=U.createSVGPoint();E.x=z.clientX,E.y=z.clientY;let q=E.matrixTransform(U.getScreenCTM()?.inverse()),J=w(q.x),$=new Date(J);$.setDate($.getDate()+1),d?.(L,J,$);},[w,d]),P=useMemo(()=>{let z=q=>q.map(J=>{if(J.subtasks&&J.subtasks.length>0){let $=z(J.subtasks),Te=$.filter(ke=>ke.startDate&&ke.endDate);if(Te.length>0){let ke=Te.map(Fe=>Fe.startDate.getTime()),Ge=Te.map(Fe=>Fe.endDate.getTime()),he=new Date(Math.min(...ke)),tt=new Date(Math.max(...Ge));return {...J,subtasks:$,startDate:he,endDate:tt}}return {...J,subtasks:$}}return J}),L=(q,J=[])=>{for(let $ of q)J.push($),$.subtasks&&$.subtasks.length>0&&($.isExpanded===void 0||$.isExpanded)&&L($.subtasks,J);return J},U=z(e);return L(U)},[e]),H=useCallback(z=>{if(!z.startDate||!z.endDate)return {x:0,width:0};let L=z.startDate.getTime(),U=z.endDate.getTime(),E=o.getTime(),q=(L-E)/(1e3*60*60*24),J=(U-L)/(1e3*60*60*24),$=q*A*l,Te=Math.max(A*l,40),ke=Math.max(J*A*l,Te);return {x:$,width:ke}},[o,A,l]),X=useMemo(()=>P.filter(z=>z.startDate&&z.endDate).map(z=>{let{x:L,width:U}=H(z),q=P.findIndex(J=>J.id===z.id)*a+12;return {id:z.id,x:L,y:q,width:U,height:32}}),[P,H]),fe=useCallback((z,L,U)=>{if(!U||L===0){g([]);return}let E=se.calculateCascadePreview(e,z,L,P,o,A*l,a,48);g(E);},[e,P,o,A,l,a,48]),ve=useMemo(()=>{let z=[],L=new Date(o);for(;L<=s;){let q=(L.getTime()-o.getTime())/864e5*A*l;if(r==="day")z.push({date:new Date(L),label:L.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:q}),L.setDate(L.getDate()+1);else if(r==="week"){let J=F(L);z.push({date:new Date(L),label:`Week ${J}`,x:q}),L.setDate(L.getDate()+7);}else z.push({date:new Date(L),label:L.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:q}),L.setMonth(L.getMonth()+1);}return z},[o,s,r,A,l]),Re=useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*A*l,[o,A,l]),Ue=Math.max(P.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(v,1e3),height:47,style:{display:"block"},children:[jsx("rect",{x:0,y:0,width:Math.max(v,1e3),height:48,fill:t.bgGrid}),ve.map((z,L)=>jsxs("g",{children:[L>0&&jsx("line",{x1:z.x,y1:0,x2:z.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsx("text",{x:z.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:z.label})]},`header-${L}`)),Re>=0&&Re<=v&&jsx("circle",{cx:Re,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxs("svg",{width:Math.max(v,1e3),height:Ue,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(v,1e3),height:Ue,fill:t.bgPrimary}),ve.map((z,L)=>{let U=ve[L+1]?.x||v,E=T(z.date);return jsxs("g",{children:[E&&jsx("rect",{x:z.x,y:0,width:U-z.x,height:P.length*a,fill:t.bgWeekend,opacity:1}),L>0&&jsx("line",{x1:z.x,y1:0,x2:z.x,y2:P.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},L)}),P.map((z,L)=>{let U=z.startDate&&z.endDate;return jsxs("g",{children:[jsx("rect",{x:0,y:L*a,width:v,height:a,fill:L%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${z.id}`),!U&&jsxs(Fragment,{children:[jsx("rect",{x:0,y:L*a,width:v,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:E=>B(E,z),onMouseEnter:E=>{E.currentTarget.setAttribute("fill",t.accentLight),E.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:E=>{E.currentTarget.setAttribute("fill","transparent"),E.currentTarget.setAttribute("opacity","1");}},`clickable-${z.id}`),jsx("text",{x:Re>0?Re:100,y:L*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-${z.id}`)]})]},`row-group-${z.id}`)}),P.map((z,L)=>!z.dependencies||z.dependencies.length===0||!z.startDate||!z.endDate?null:z.dependencies.map(U=>{let E=P.find(Te=>Te.id===U);if(!E||!E.startDate||!E.endDate)return null;let q=P.findIndex(Te=>Te.id===U),J=H(E),$=H(z);return jsx(Jo,{x1:J.x+J.width,y1:q*a+a/2,x2:$.x,y2:L*a+a/2,theme:t},`dep-${U}-${z.id}`)})),P.map((z,L)=>{if(!z.startDate||!z.endDate)return null;let{x:U,width:E}=H(z),q=L*a+12,J=z.subtasks&&z.subtasks.length>0&&!z.isMilestone;return z.isMilestone?jsx(Qo,{task:z,x:U+E/2,y:q+16,theme:t,onClick:p},z.id):J?jsxs("g",{onClick:()=>p?.(z),onContextMenu:$=>{$.preventDefault(),$.stopPropagation(),m?.(z,$);},style:{cursor:"default"},children:[jsx("rect",{x:U,y:q,width:E,height:32,fill:t.primary,opacity:.25,rx:6}),jsx("line",{x1:U,y1:q,x2:U+E,y2:q,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:U,y1:q,x2:U,y2:q+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:U+E,y1:q,x2:U+E,y2:q+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:U,y1:q+32,x2:U+E,y2:q+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),E>60&&jsx("text",{x:U+12,y:q+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:z.name})]},z.id):jsx(Yo,{task:z,x:U,y:q,width:E,theme:t,dayWidth:A*l,startDate:o,templates:c,onClick:p,onDoubleClick:n,onContextMenu:m,onDateChange:d,onDependencyCreate:i,allTaskPositions:X,onDragMove:fe,onHoverChange:D},z.id)}),P.map((z,L)=>!z.dependencies||z.dependencies.length===0||!z.startDate||!z.endDate?null:z.dependencies.map(U=>{let E=P.find(ie=>ie.id===U);if(!E||!E.startDate||!E.endDate)return null;let q=P.findIndex(ie=>ie.id===U),J=H(E),$=H(z),Te=J.x+J.width,ke=q*a+a/2,Ge=$.x,he=L*a+a/2,tt=Ge-Te,Fe=Te+tt/2,et=ie=>{let Se=1-ie,Ae=Se*Se,ot=Ae*Se,st=ie*ie,Le=st*ie,V=ot*Te+3*Ae*ie*Fe+3*Se*st*Fe+Le*Ge,xe=ot*ke+3*Ae*ie*ke+3*Se*st*he+Le*he;return {x:V,y:xe}},ft=20,Tt=[];for(let ie=0;ie<=ft;ie++){let Se=.1+ie/ft*.8;Tt.push(et(Se));}let dt=Tt[0],O=`M ${dt.x} ${dt.y} `+Tt.slice(1).map(ie=>`L ${ie.x} ${ie.y}`).join(" ");return b&&b.x1===Te&&b.y1===ke&&b.x2===Ge&&b.y2===he?null:jsx("path",{d:O,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:()=>{y({x1:Te,y1:ke,x2:Ge,y2:he,onDelete:()=>u?.(z.id,U)});}},`dep-hover-${U}-${z.id}`)})),f.map(z=>jsxs("g",{style:{pointerEvents:"none"},children:[jsx("rect",{x:z.previewX,y:z.y-48,width:z.width,height:32,rx:8,fill:z.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(z.daysDelta)>0&&jsx("text",{x:z.previewX+z.width/2,y:z.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:z.daysDelta>0?`+${z.daysDelta}d`:`${z.daysDelta}d`})]},`cascade-preview-${z.taskId}`)),b&&(()=>{let{x1:z,y1:L,x2:U,y2:E,onDelete:q}=b,J=U-z,$=E-L,Te=z+J/2,ke=(L+E)/2,Ge=`M ${z} ${L} C ${Te} ${L}, ${Te} ${E}, ${U} ${E}`,he=6,tt=Math.atan2($,J),Fe=U-he*Math.cos(tt-Math.PI/6),et=E-he*Math.sin(tt-Math.PI/6),ft=U-he*Math.cos(tt+Math.PI/6),Tt=E-he*Math.sin(tt+Math.PI/6),dt=t.dependency,O="#f87171";return jsxs("g",{onMouseLeave:()=>y(null),children:[jsx("path",{d:Ge,fill:"none",stroke:"transparent",strokeWidth:50,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx("circle",{cx:Te,cy:ke,r:25,fill:"transparent",style:{cursor:"pointer"}}),jsx("path",{d:Ge,fill:"none",stroke:dt,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsx("path",{d:Ge,fill:"none",stroke:dt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("path",{d:`M ${U} ${E} L ${Fe} ${et} M ${U} ${E} L ${ft} ${Tt}`,fill:"none",stroke:dt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("circle",{cx:U,cy:E,r:4,fill:dt,opacity:.9,style:{pointerEvents:"none"}}),jsxs(motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:ie=>{ie.stopPropagation(),y(null),q();},style:{cursor:"pointer"},children:[jsx("circle",{cx:Te,cy:ke,r:9,fill:"rgba(248, 113, 113, 0.15)",stroke:O,strokeWidth:1.5,style:{transition:"all 0.15s ease"}}),jsx("line",{x1:Te-3,y1:ke-3,x2:Te+3,y2:ke+3,stroke:O,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:Te+3,y1:ke-3,x2:Te-3,y2:ke+3,stroke:O,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),Re>=0&&Re<=v&&jsx("line",{x1:Re,y1:0,x2:Re,y2:Ue,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),k&&jsx(wd,{tooltipData:k,theme:t})]})]})}var an=[{name:"Azul",value:"#6366F1",light:"#818CF8"},{name:"P\xFArpura",value:"#A855F7",light:"#C084FC"},{name:"Rosa",value:"#EC4899",light:"#F472B6"},{name:"Rojo",value:"#EF4444",light:"#F87171"},{name:"Naranja",value:"#F59E0B",light:"#FBBF24"},{name:"Amarillo",value:"#EAB308",light:"#FACC15"},{name:"Lima",value:"#84CC16",light:"#A3E635"},{name:"Verde",value:"#10B981",light:"#34D399"},{name:"Esmeralda",value:"#059669",light:"#10B981"},{name:"Cyan",value:"#06B6D4",light:"#22D3EE"},{name:"Azul Cielo",value:"#0EA5E9",light:"#38BDF8"},{name:"\xCDndigo",value:"#4F46E5",light:"#6366F1"},{name:"Violeta",value:"#8B5CF6",light:"#A78BFA"},{name:"Fucsia",value:"#D946EF",light:"#E879F9"},{name:"Coral",value:"#F97316",light:"#FB923C"},{name:"Magenta",value:"#E11D48",light:"#FB7185"}];var zs=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],$s=[{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 rn({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:l=false,mode:c=a?"edit":"create",theme:p="dark",customStatuses:n=[],availableTags:m=[],onCreateTag:d,attachments:i=[],onUploadAttachments:u,onDeleteAttachment:x}){let f=[...zs,...n.filter(O=>!zs.some(ne=>ne.id===O.id))],g=_e[p]||_e.dark,[k,h]=useState(false),[b,y]=useState(false),[D,N]=useState(false),[A,v]=useState(false),[F,T]=useState({top:0,left:0}),[w,B]=useState(null),[P,H]=useState(new Date),[X$1,fe]=useState({top:0,left:0}),[ve,Re]=useState(false),[Ue,z]=useState([]),L=useRef(null),U=useRef(null),E=useRef(null),q=useRef(null),J=useRef(null),[$,Te]=useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[ke,Ge]=useState({});useEffect(()=>{a?(Te({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)&&Re(true)):(Te({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),Re(false),z([]));},[a,e]),useEffect(()=>{let O=ne=>{L.current&&!L.current.contains(ne.target)&&h(false),U.current&&!U.current.contains(ne.target)&&y(false),E.current&&!E.current.contains(ne.target)&&N(false),q.current&&!q.current.contains(ne.target)&&v(false);};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]);let he=()=>{let O={};return $.name.trim()||(O.name="El nombre es requerido"),$.startDate&&$.endDate&&$.startDate>$.endDate&&(O.endDate="La fecha de fin debe ser posterior a la de inicio"),Ge(O),Object.keys(O).length===0},tt=async O=>{if(O.preventDefault(),!!he())try{let ne=c==="create"&&Ue.length>0?{...$,pendingFiles:Ue}:$;await s(ne),z([]),t();}catch(ne){console.error("Error submitting task:",ne);}},Fe=(O,ne)=>{Te(ie=>{let Se={...ie,[O]:ne};if(O==="status"){let Ae=ne;Ae==="todo"?Se.progress=0:Ae==="in-progress"?(ie.progress===0||ie.progress===100)&&(Se.progress=50):Ae==="completed"||Ae==="closed"?Se.progress=100:(Ae==="in-review"||Ae==="review")&&(Se.progress=75);}if(O==="progress"){let Ae=typeof ne=="number"?ne:parseInt(ne,10);Ae===100&&ie.status!=="completed"?Se.status="completed":Ae>0&&Ae<100&&ie.status==="todo"?Se.status="in-progress":Ae===0&&ie.status!=="todo"&&(Se.status="todo");}return Se}),ke[O]&&Ge(ie=>{let Se={...ie};return delete Se[O],Se});},et=f.find(O=>O.id===$.status)??zs[0],ft=$s.find(O=>O.id===$.priority)??$s[1],Tt=an.find(O=>O.value===$.color)??an[0],dt={backgroundColor:g.bgSecondary,border:`1px solid ${g.borderLight}`,color:g.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:g.bgPrimary,border:`1px solid ${g.border}`},onClick:O=>O.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${g.border}`},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:et.color||g.accent}}),jsx("span",{className:"text-sm font-medium",style:{color:g.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:g.textTertiary},onMouseEnter:O=>{O.currentTarget.style.backgroundColor=g.hoverBg,O.currentTarget.style.color=g.textPrimary;},onMouseLeave:O=>{O.currentTarget.style.backgroundColor="transparent",O.currentTarget.style.color=g.textTertiary;},disabled:l,children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("form",{onSubmit:tt,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:$.name,onChange:O=>Fe("name",O.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:g.textPrimary},placeholder:"Nombre de la tarea",disabled:l,autoFocus:true}),ke.name&&jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsx(AlertCircle,{className:"w-3 h-3"}),ke.name]})]}),jsx("div",{children:jsx("textarea",{value:$.description||"",onChange:O=>Fe("description",O.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:g.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:l})}),jsx("div",{style:{borderTop:`1px solid ${g.borderLight}`}}),jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxs("div",{ref:L,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!l&&h(!k),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...dt,borderColor:et.color,backgroundColor:`${et.color}15`},disabled:l,children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:et.color}}),jsx("span",{style:{color:et.color},children:et.title}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:et.color}})]}),jsx(AnimatePresence,{children:k&&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:g.bgPrimary,border:`1px solid ${g.border}`},children:f.map(O=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:ne=>ne.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:ne=>ne.currentTarget.style.backgroundColor="transparent",onClick:()=>{Fe("status",O.id),h(false);},children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:O.color}}),O.title,$.status===O.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:g.accent}})]},O.id))})})]}),jsxs("div",{ref:U,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!l&&y(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:dt,disabled:l,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:g.textTertiary}})]}),jsx(AnimatePresence,{children:b&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[130px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},children:$s.map(O=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:ne=>ne.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:ne=>ne.currentTarget.style.backgroundColor="transparent",onClick:()=>{Fe("priority",O.id),y(false);},children:[jsx("span",{children:O.icon}),O.label,$.priority===O.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:g.accent}})]},O.id))})})]}),o.length>0&&jsxs("div",{ref:E,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!l&&N(!D),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:dt,disabled:l,children:[$.assignees&&$.assignees.length>0?jsxs(Fragment,{children:[jsx("div",{className:"flex -space-x-1",children:$.assignees.slice(0,3).map((O,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:O.color||g.accent,borderColor:g.bgSecondary},children:O.initials},ne))}),$.assignees.length>3&&jsxs("span",{style:{color:g.textTertiary},children:["+",$.assignees.length-3]})]}):jsxs(Fragment,{children:[jsx(Users,{className:"w-3.5 h-3.5",style:{color:g.textTertiary}}),jsx("span",{style:{color:g.textTertiary},children:"Asignar"})]}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsx(AnimatePresence,{children:D&&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:g.bgPrimary,border:`1px solid ${g.border}`},children:o.map(O=>{let ne=$.assignees?.some(ie=>ie.name===O.name);return jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:ie=>ie.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:ie=>ie.currentTarget.style.backgroundColor="transparent",onClick:()=>{let ie=ne?($.assignees||[]).filter(Se=>Se.name!==O.name):[...$.assignees||[],{name:O.name,avatar:O.avatar,initials:O.name.split(" ").map(Se=>Se[0]).join("").toUpperCase().slice(0,2),color:g.accent}];Fe("assignees",ie);},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:g.accent},children:O.name.charAt(0).toUpperCase()}),jsx("span",{className:"truncate flex-1 text-left",children:O.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:g.accent}})})]},O.id)})})})]}),jsxs("div",{ref:q,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>{if(!l)if(A)v(false);else {if(q.current){let O=q.current.getBoundingClientRect(),ne=window.innerHeight,ie=120,Ae=ne-O.bottom<ie?O.top-ie-8:O.bottom+8;T({top:Ae,left:O.left});}v(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:dt,disabled:l,children:[jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:$.color}}),jsx("span",{children:Tt.name}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsx(AnimatePresence,{children:A&&jsxs(at,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>v(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:`${F.top}px`,left:`${F.left}px`,zIndex:99999,backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick:O=>O.stopPropagation(),children:jsx("div",{style:{padding:"6px 8px"},children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 28px)",gap:"2px"},children:an.slice(0,18).map(O=>{let ne=$.color===O.value;return jsx("button",{type:"button",onClick:ie=>{ie.preventDefault(),ie.stopPropagation(),Fe("color",O.value),v(false);},style:{width:"28px",height:"28px",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",border:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0},title:O.name,children:jsx("span",{style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:O.value,outline:ne?`2px solid ${O.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},O.value)})})})})]})})]}),m.length>0||d?jsx(Rr,{selectedTags:$.tags||[],availableTags:m,onChange:O=>Fe("tags",O),onCreateTag:d,theme:g,disabled:l}):null]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Calendar,{className:"w-4 h-4",style:{color:g.textTertiary}}),jsxs("div",{ref:J,className:"flex items-center gap-2 flex-1 relative",children:[jsx("button",{type:"button",onClick:()=>{if(!l&&!$.isMilestone)if(w==="start")B(null);else {if(J.current){let O=J.current.getBoundingClientRect(),ne=window.innerHeight,ie=320,Ae=ne-O.bottom<ie?O.top-ie-8:O.bottom+8;fe({top:Ae,left:O.left});}B("start"),H($.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...dt,opacity:$.isMilestone?.5:1,cursor:$.isMilestone?"not-allowed":"pointer"},disabled:l||$.isMilestone,children:$.startDate?$.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsx("span",{style:{color:g.textTertiary},children:"\u2192"}),jsx("button",{type:"button",onClick:()=>{if(!l&&!$.isMilestone)if(w==="end")B(null);else {if(J.current){let O=J.current.getBoundingClientRect(),ne=window.innerHeight,ie=320,Ae=ne-O.bottom<ie?O.top-ie-8:O.bottom+8;fe({top:Ae,left:O.left});}B("end"),H($.endDate||$.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...dt,opacity:$.isMilestone?.5:1,cursor:$.isMilestone?"not-allowed":"pointer"},disabled:l||$.isMilestone,children:$.endDate?$.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsx(AnimatePresence,{children:w&&jsxs(at,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>B(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:`${X$1.top}px`,left:`${X$1.left}px`,zIndex:99999,backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},onClick:O=>O.stopPropagation(),children:[jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${g.border}`},children:[(()=>{let O=new Date,ne=new Date(O);ne.setDate(O.getDate()+1);let ie=new Date(O);ie.setDate(O.getDate()+7);let Se=new Date(O);return Se.setDate(O.getDate()+14),[{label:"Hoy",date:O},{label:"Ma\xF1ana",date:ne},{label:"Pr\xF3xima semana",date:ie},{label:"2 semanas",date:Se}].map((ot,st)=>jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:g.textPrimary},onMouseEnter:Le=>Le.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:Le=>Le.currentTarget.style.backgroundColor="transparent",onClick:()=>{w==="start"?(Fe("startDate",ot.date),(!$.endDate||ot.date>$.endDate)&&Fe("endDate",ot.date),B("end")):(Fe("endDate",ot.date),(!$.startDate||ot.date<$.startDate)&&Fe("startDate",ot.date),B(null));},children:ot.label},st))})(),jsx("div",{style:{borderTop:`1px solid ${g.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:O=>O.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:O=>O.currentTarget.style.backgroundColor="transparent",onClick:()=>{Fe("startDate",void 0),Fe("endDate",void 0),B(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:()=>H(new Date(P.getFullYear(),P.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-4 h-4",style:{color:g.textSecondary}})}),jsx("span",{className:"text-sm font-medium",style:{color:g.textPrimary},children:P.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>H(new Date(P.getFullYear(),P.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-4 h-4",style:{color:g.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((O,ne)=>jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:g.textTertiary},children:O},ne))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let O=P.getFullYear(),ne=P.getMonth(),ie=new Date(O,ne,1).getDay(),Se=new Date(O,ne+1,0).getDate(),Ae=new Date,ot=[];for(let Le=ie-1;Le>=0;Le--)ot.push({day:new Date(O,ne,-Le).getDate(),date:new Date(O,ne-1,new Date(O,ne,-Le).getDate()),isCurrentMonth:false});for(let Le=1;Le<=Se;Le++)ot.push({day:Le,date:new Date(O,ne,Le),isCurrentMonth:true});let st=42-ot.length;for(let Le=1;Le<=st;Le++)ot.push({day:Le,date:new Date(O,ne+1,Le),isCurrentMonth:false});return ot.map((Le,V)=>{let xe=Le.date.toDateString()===Ae.toDateString(),qe=$.startDate?.toDateString()===Le.date.toDateString(),Z=$.endDate?.toDateString()===Le.date.toDateString(),we=$.startDate&&$.endDate&&Le.date>=$.startDate&&Le.date<=$.endDate;return jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:Le.isCurrentMonth?qe||Z?"#FFF":g.textPrimary:g.textTertiary,backgroundColor:qe?"#3B82F6":Z?"#7C3AED":we?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:xe&&!qe&&!Z?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{w==="start"?(Fe("startDate",Le.date),$.endDate&&Le.date>$.endDate&&Fe("endDate",Le.date),B("end")):(Fe("endDate",Le.date),$.startDate&&Le.date<$.startDate&&Fe("startDate",Le.date),B(null));},children:Le.day},V)})})()})]})]})]})})]}),ke.endDate&&jsx("span",{className:"text-xs text-red-400",children:ke.endDate})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:"w-4 h-4",style:{color:g.textTertiary}}),jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsx("input",{type:"range",min:"0",max:"100",step:"5",value:$.progress,onChange:O=>Fe("progress",parseInt(O.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:g.bgSecondary,accentColor:$.progress<30?"#EF4444":$.progress<70?"#F59E0B":"#10B981"},disabled:l}),jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${$.progress<30?"#EF4444":$.progress<70?"#F59E0B":"#10B981"}20`,color:$.progress<30?"#EF4444":$.progress<70?"#F59E0B":"#10B981"},children:[$.progress,"%"]})]})]}),(u||i.length>0||c==="create")&&jsxs("div",{className:"pt-2",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:g.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:g.textTertiary},children:["Adjuntos ",c==="create"?Ue.length>0&&`(${Ue.length})`:i.length>0&&`(${i.length})`]})]}),c==="create"?jsx(Ua,{cardId:"pending",attachments:Ue.map((O,ne)=>({id:`pending-${ne}`,cardId:"pending",name:O.name,size:O.size,type:O.type,url:URL.createObjectURL(O),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:O=>z(ne=>[...ne,...O]),onDelete:O=>{let ne=parseInt(O.replace("pending-",""),10);z(ie=>ie.filter((Se,Ae)=>Ae!==ne));},maxSizeMB:10,maxFiles:20}):jsx(Ua,{cardId:a?.id||"new",attachments:i,onUpload:u&&a?.id?O=>u(a.id,O):void 0,onDelete:x,maxSizeMB:10,maxFiles:20}),c==="create"&&Ue.length>0&&jsxs("p",{className:"text-xs mt-1",style:{color:g.textTertiary},children:[Ue.length," archivo(s) se subir\xE1n al crear la tarea"]})]}),jsxs("div",{children:[jsxs("button",{type:"button",onClick:()=>Re(!ve),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:g.textTertiary},children:[jsx(ChevronDown,{className:`w-3 h-3 transition-transform ${ve?"rotate-180":""}`}),"Opciones avanzadas"]}),jsx(AnimatePresence,{children:ve&&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:[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:$.isMilestone,onChange:O=>Fe("isMilestone",O.target.checked),className:"w-4 h-4 rounded",style:{accentColor:g.accent},disabled:l}),jsx(Milestone,{className:"w-4 h-4 text-yellow-500"}),jsx("span",{className:"text-sm",style:{color:g.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:g.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:g.bgSecondary},children:r.filter(O=>O.id!==a?.id).map(O=>{let ne=$.dependencies?.includes(O.id);return jsx("button",{type:"button",onClick:()=>{let ie=ne?($.dependencies||[]).filter(Se=>Se!==O.id):[...$.dependencies||[],O.id];Fe("dependencies",ie);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:ne?`${g.accent}30`:g.bgPrimary,color:ne?g.accent:g.textSecondary,border:`1px solid ${ne?g.accent:g.borderLight}`},disabled:l,children:O.name},O.id)})})]})]})})})]})]}),jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${g.border}`},children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:g.textSecondary},onMouseEnter:O=>O.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:O=>O.currentTarget.style.backgroundColor="transparent",disabled:l,children:"Cancelar"}),jsx("button",{type:"submit",disabled:l,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:g.accent,color:"#FFF"},onMouseEnter:O=>!l&&(O.currentTarget.style.opacity="0.9"),onMouseLeave:O=>!l&&(O.currentTarget.style.opacity="1"),children:l?jsxs(Fragment,{children:[jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsx(Fragment,{children:c==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var nf=['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"'],Sd=()=>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"})]}),sf=()=>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"})}),lf=()=>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"})}),df=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M5 12h14"})}),cf=()=>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 on({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:l,onDependencyCreate:c,onDependencyDelete:p}){let[n,m]=useState(false),[d,i]=useState(false),[u,x]=useState([]),[f,g]=useState(""),[k,h]=useState(false),[b,y]=useState(true),D=useRef(null),N=useRef(null),A=useRef(null),{enabled:v=true,placeholder:F='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:T="bottom-right",onCommand:w,suggestions:B=nf,maxHistory:P=50,persistHistory:H}=a,X=H?.storageKey||"gantt-ai-history",fe=H?.maxMessages??5;useEffect(()=>{if(H?.enabled)try{let U=localStorage.getItem(X);if(U){let q=JSON.parse(U).map(J=>({...J,timestamp:new Date(J.timestamp)}));x(q.slice(-fe));}}catch(U){console.warn("[GanttAIAssistant] Failed to load persisted history:",U);}},[H?.enabled,X,fe]),useEffect(()=>{if(H?.enabled&&u.length>0)try{let U=u.filter(E=>!E.isLoading).slice(-fe);localStorage.setItem(X,JSON.stringify(U));}catch(U){console.warn("[GanttAIAssistant] Failed to persist history:",U);}},[u,H?.enabled,X,fe]),useEffect(()=>{N.current&&N.current.scrollIntoView({behavior:"smooth"});},[u]),useEffect(()=>{n&&!d&&D.current&&setTimeout(()=>D.current?.focus(),100);},[n,d]);let ve=useCallback(U=>{if(U.success)switch(U.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":U.taskId&&U.updates&&o?.(U.taskId,U.updates);break;case "create_task":U.newTask&&s?.(U.newTask);break;case "delete_task":U.taskId&&l?.(U.taskId);break;case "link_tasks":U.dependencyFrom&&U.dependencyTo&&c?.(U.dependencyFrom,U.dependencyTo);break;case "unlink_tasks":U.taskId&&U.dependencyFrom&&p?.(U.taskId,U.dependencyFrom);break}},[o,s,l,c,p]),Re=useCallback(async U=>{if(!U.trim()||k)return;let E={id:`user-${Date.now()}`,role:"user",content:U,timestamp:new Date};x(J=>[...J.slice(-(P-1)),E]),g(""),y(false),h(true);let q={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};x(J=>[...J,q]);try{if(w){let J=await w(U,e);x($=>{let Te=$.filter(Ge=>!Ge.isLoading),ke={id:`assistant-${Date.now()}`,role:"assistant",content:J.message,timestamp:new Date,command:J};return [...Te,ke]}),ve(J);}else x(J=>[...J.filter(Te=>!Te.isLoading),{id:`assistant-${Date.now()}`,role:"assistant",content:"AI handler not configured. Please provide an onCommand handler in the aiAssistant config.",timestamp:new Date}]);}catch(J){x($=>[...$.filter(ke=>!ke.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${J instanceof Error?J.message:"Unknown error"}`,timestamp:new Date}]);}finally{h(false);}},[k,P,w,e,ve]),Ue=U=>{U.preventDefault(),Re(f);},z=U=>{g(U),D.current?.focus();};if(useEffect(()=>{let U=E=>{(E.metaKey||E.ctrlKey)&&E.key==="k"&&(E.preventDefault(),m(q=>!q),n||i(false)),E.key==="Escape"&&n&&m(false);};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[n]),useEffect(()=>{if(!n)return;let U=q=>{let J=q.target;A.current&&!A.current.contains(J)&&m(false);},E=setTimeout(()=>{document.addEventListener("mousedown",U);},100);return ()=>{clearTimeout(E),document.removeEventListener("mousedown",U);}},[n]),!v)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(at,{children:[jsx(AnimatePresence,{children:!n&&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[T]} z-[99999] flex items-center gap-2 px-4 py-3 rounded-full shadow-lg transition-colors`,style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"white",boxShadow:"0 4px 20px rgba(59, 130, 246, 0.4)"},onClick:()=>m(true),children:[jsx(Sd,{}),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:n&&jsxs(motion.div,{ref:A,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:d?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${L[T]} z-[99999] w-96 rounded-2xl overflow-hidden shadow-2xl flex flex-col`,style:{background:t.bgPrimary,border:`1px solid ${t.border}`,boxShadow:`0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px ${t.border}`},children:[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(Sd,{}),jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>i(U=>!U),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(df,{})}),jsx("button",{onClick:()=>m(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(lf,{})})]})]}),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:[u.length===0&&b&&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:B.slice(0,4).map((U,E)=>jsx("button",{onClick:()=>z(U),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:U.length>30?U.slice(0,30)+"...":U},E))})]}),u.map(U=>jsx(motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${U.role==="user"?"justify-end":"justify-start"}`,children:jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${U.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:U.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:U.role==="user"?"white":t.textPrimary},children:[U.isLoading?jsx(cf,{}):jsx("p",{className:"text-sm whitespace-pre-wrap",children:U.content}),U.command&&jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:U.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:U.command.success?"#10B981":"#EF4444"},children:[U.command.success?"\u2713":"\u2717",jsx("span",{className:"capitalize",children:U.command.type.replace(/_/g," ")})]})]})},U.id)),jsx("div",{ref:N})]}),jsxs("form",{onSubmit:Ue,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:D,type:"text",value:f,onChange:U=>g(U.target.value),placeholder:F,disabled:k,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsx("button",{type:"submit",disabled:!f.trim()||k,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:f.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:f.trim()?"white":t.textSecondary},children:jsx(sf,{})})]}),jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function nn({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,l]=useState({x:0,y:0}),c=useRef(null),p=useRef(null);useEffect(()=>{if(!r)return;let m=d=>{c.current&&!c.current.contains(d.target)&&o(false);};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[r]);let n=e.filter(m=>m.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:p,onClick:()=>{if(!r&&p.current){let m=p.current.getBoundingClientRect();l({x:m.left,y:m.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(at,{children:jsx(motion.div,{ref:c,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15},className:"column-manager-menu fixed min-w-[180px] rounded-lg shadow-xl z-[9999]",style:{left:`${s.x}px`,top:`${s.y}px`,backgroundColor:a.bgSecondary,border:`1px solid ${a.border}`},children:jsxs("div",{className:"py-1",children:[jsx("div",{className:"px-3 py-2 text-xs uppercase tracking-wider",style:{color:a.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600},children:"Add Column"}),n.map(m=>jsxs("button",{onClick:()=>{t(m.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:m.label}),m.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},m.id))]})})})})]})}function Ad(e,t=50){let[a,r]=useState({past:[],present:e,future:[]}),o=useRef(false),s=useCallback((n,m=true)=>{r(d=>{let i=typeof n=="function"?n(d.present):n;if(o.current)return {...d,present:i};if(!m)return {...d,present:i};let u=[...d.past,d.present];return u.length>t&&u.shift(),{past:u,present:i,future:[]}});},[t]),l=useCallback(()=>{r(n=>{if(n.past.length===0)return n;let m=n.past[n.past.length-1],d=n.past.slice(0,n.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:m,future:[n.present,...n.future]}});},[]),c=useCallback(()=>{r(n=>{if(n.future.length===0)return n;let m=n.future[0],d=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:m,future:d}});},[]),p=useCallback(()=>{r(n=>({past:[],present:n.present,future:[]}));},[]);return {state:a.present,setState:s,undo:l,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function Id({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){useEffect(()=>{if(!o)return;let s=l=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,p=c?l.metaKey:l.ctrlKey;if(p&&l.key==="z"&&!l.shiftKey&&a){l.preventDefault(),e();return}if(r){if(!c&&p&&l.key==="y"){l.preventDefault(),t();return}if(c&&p&&l.shiftKey&&l.key==="z"){l.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var vf={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${se.formatDate(e.startDate)} - ${se.formatDate(e.endDate)}`);let a=se.calculateDuration(e.startDate,e.endDate);t.push(`Duration: ${a} days`);}if(e.progress!==void 0&&t.push(`Progress: ${e.progress}%`),e.status&&t.push(`Status: ${e.status}`),e.assignees&&e.assignees.length>0){let a=e.assignees.map(r=>r.name).join(", ");t.push(`Assigned: ${a}`);}return e.dependencies&&e.dependencies.length>0&&t.push(`Dependencies: ${e.dependencies.length}`),t.join("<br/>")},taskLabel:e=>e.name,gridCell:(e,t,a)=>a,taskClass:e=>{let t=[];return e.isCriticalPath&&t.push("critical-path"),e.status==="completed"?t.push("completed"):e.status==="in-progress"?t.push("in-progress"):e.status==="todo"&&t.push("todo"),e.isMilestone&&t.push("milestone"),t.join(" ")},milestoneContent:e=>`\u25C6 ${e.name}`,dateFormat:e=>se.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function Ld(e){return {...vf,...e}}var Sf=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},Rd=forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:l="week",rowDensity:c="comfortable",showThemeSelector:p=true,showExportButton:n=true,availableUsers:m=[],templates:d,enableAutoCriticalPath:i=true,persistExpandedState:u,aiAssistant:x,locale:f="en",customTranslations:g,showCreateTaskButton:k=false,createTaskLabel:h,onCreateTask:b,onThemeChange:y,onTaskClick:D,onTaskDblClick:N,onTaskContextMenu:A,onTaskUpdate:v,onProgressChange:F,onTaskEdit:T,onTaskAddSubtask:w,onTaskMarkIncomplete:B,onTaskSetInProgress:P,onDependencyCreate:H,onDependencyDelete:X,onBeforeTaskAdd:fe,onAfterTaskAdd:ve,onBeforeTaskUpdate:Re,onAfterTaskUpdate:Ue,onBeforeTaskDelete:z,onAfterTaskDelete:L}=a,E=useContext(_o)?.theme,[q,J]=useState(E||s||"dark"),[$,Te]=useState(l),[ke,Ge]=useState(c),[he,tt]=useState(1),[Fe,et]=useState(0),[ft,Tt]=useState(false),[dt,O]=useState(null),[ne,ie]=useState({isOpen:false,x:0,y:0,task:null}),[Se,Ae]=useState(null),[ot,st]=useState(null),[Le,V]=useState(false),xe=useRef(null);useEffect(()=>{function S(M){xe.current&&!xe.current.contains(M.target)&&V(false);}if(Le)return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[Le]),useEffect(()=>{E&&E!==q&&J(E);},[E]),useEffect(()=>{s&&s!==q&&J(s);},[s]);let qe=useCallback(S=>{J(S),y?.(S);},[y]),{state:Z,setState:we,undo:ee,redo:ae,canUndo:ye,canRedo:De,clearHistory:re}=Ad(t,50),Ee=useCallback(()=>u?typeof u=="string"?u:"gantt-expanded-tasks":null,[u]),be=useRef(new Map),Ne=useRef(false);if(!Ne.current&&u){Ne.current=true;let S=typeof u=="string"?u:"gantt-expanded-tasks";try{let M=localStorage.getItem(S);if(M){let Y=JSON.parse(M);Array.isArray(Y)&&(be.current=new Map(Y));}}catch(M){console.warn("[GanttBoard] Error loading expanded state from localStorage:",M);}}let ce=useCallback(()=>{let S=Ee();if(S)try{let M=Array.from(be.current.entries());localStorage.setItem(S,JSON.stringify(M));}catch(M){console.warn("[GanttBoard] Error saving expanded state to localStorage:",M);}},[Ee]);useEffect(()=>{let S=M=>M.map(Y=>{let Q=be.current.get(Y.id),de=Q!==void 0?{...Y,isExpanded:Q}:Y;return de.subtasks?.length?{...de,subtasks:S(de.subtasks)}:de});be.current.size>0?we(S(t)):we(t);},[t,we]);let Oe=useRef(t),W=useRef(true);useEffect(()=>{if(W.current){W.current=false,Oe.current=Z;return}if(!r)return;let S=JSON.stringify(Oe.current),M=JSON.stringify(Z);S!==M&&(Oe.current=Z,r(Z));},[Z,r]);let G=useMemo(()=>ks(f,g),[f,g]),je=useCallback(S=>[{id:"name",label:S.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:S.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:S.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:S.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:S.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:S.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:S.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:S.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Ie,ze]=useState(()=>je(G));useEffect(()=>{ze(S=>S.map(M=>({...M,label:G.columns[M.id==="name"?"taskName":M.id]||M.label})));},[G]);let Ut=useMemo(()=>{let S=Ie.filter(Q=>Q.visible),M=S.some(Q=>Q.id!=="name");return S.reduce((Q,de)=>Q+de.width,0)+(M?20:0)},[Ie]),Pe=useRef(Ie.filter(S=>S.visible).map(S=>S.id).join(","));useEffect(()=>{let S=Ie.filter(Q=>Q.visible),M=S.map(Q=>Q.id).join(","),Y=Pe.current;if(M!==Y){let Q=S.some(Ce=>Ce.id!=="name"),de=Y.includes(",");Q?!de&&Q&&O(null):O(null),Pe.current=M;}},[Ie]);let Dt=useMemo(()=>dt!==null?Math.max(280,dt):Math.max(280,Ut),[dt,Ut]),Qt=useRef(null),R=useRef(null),ue=useRef(null),K=useMemo(()=>Jl(q),[q]),Ft=useMemo(()=>({theme:K,themeName:q}),[K,q]),aa=useMemo(()=>Ld(d),[d]),le=useMemo(()=>{if(!i)return Z;let S=se.calculateCriticalPath(Z),M=Y=>Y.map(Q=>({...Q,isCriticalPath:S.includes(Q.id),subtasks:Q.subtasks?M(Q.subtasks):void 0}));return M(Z)},[Z,i]),ht=Sf(ke);Id({undo:ee,redo:ae,canUndo:ye,canRedo:De,enabled:true}),useImperativeHandle(o,()=>({getTask:S=>se.findTaskById(Z,S),addTask:(S,M)=>{we(Y=>{if(!M)return [...Y,{...S,level:0}];let Q=de=>de.map(Ce=>Ce.id===M?{...Ce,subtasks:[...Ce.subtasks||[],{...S,parentId:M,level:(Ce.level||0)+1}],isExpanded:true}:Ce.subtasks?{...Ce,subtasks:Q(Ce.subtasks)}:Ce);return Q(Y)});},updateTask:(S,M)=>{we(Y=>{let Q=de=>de.map(Ce=>Ce.id===S?{...Ce,...M}:Ce.subtasks?{...Ce,subtasks:Q(Ce.subtasks)}:Ce);return Q(Y)});},deleteTask:S=>{we(M=>{let Y=Q=>Q.filter(de=>de.id===S?false:(de.subtasks&&(de.subtasks=Y(de.subtasks)),true));return Y(M)});},deleteTasks:S=>{we(M=>Ss(M,S));},duplicateTask:S=>{we(M=>Es(M,[S]));},splitTask:(S,M,Y=3)=>{we(Q=>se.splitTask(Q,S,M,Y));},calculateEndDate:se.calculateEndDate,calculateDuration:se.calculateDuration,validateDependency:(S,M)=>!se.validateDependencies(Z,S,M),getAllTasks:()=>se.flattenTasks(Z),getTasksByStatus:S=>se.flattenTasks(Z).filter(M=>M.status===S),getTasksByParent:S=>S?se.findTaskById(Z,S)?.subtasks||[]:Z.filter(Y=>!Y.parentId),getCriticalPath:()=>se.flattenTasks(Z).filter(S=>S.isCriticalPath),indentTask:S=>{we(M=>Ts(M,[S]));},outdentTask:S=>{we(M=>Ds(M,[S]));},moveTask:(S,M)=>{we(Y=>Ns(Y,[S],M));},createSubtask:async S=>{let{tasks:M,newTask:Y}=As(Z,S);if(fe){let Q=fe({...Y,parentId:S});if((Q instanceof Promise?await Q:Q)===false)return}we(M),ve&&ve({...Y,parentId:S});},scrollToTask:S=>{let Y=se.flattenTasks(Z).findIndex(Q=>Q.id===S);if(Y!==-1&&Qt.current){let Q=Y*ht;Qt.current.scrollTo({top:Q,behavior:"smooth"}),R.current&&R.current.scrollTo({top:Q,behavior:"smooth"});}},highlightTask:(S,M=2e3)=>{},expandTask:S=>{we(M=>{let Y=Q=>Q.map(de=>de.id===S?{...de,isExpanded:true}:de.subtasks?{...de,subtasks:Y(de.subtasks)}:de);return Y(M)});},collapseTask:S=>{we(M=>{let Y=Q=>Q.map(de=>de.id===S?{...de,isExpanded:false}:de.subtasks?{...de,subtasks:Y(de.subtasks)}:de);return Y(M)});},expandAll:()=>{we(S=>{let M=Y=>Y.map(Q=>({...Q,isExpanded:true,subtasks:Q.subtasks?M(Q.subtasks):void 0}));return M(S)});},collapseAll:()=>{we(S=>{let M=Y=>Y.map(Q=>({...Q,isExpanded:false,subtasks:Q.subtasks?M(Q.subtasks):void 0}));return M(S)});},undo:ee,redo:ae,canUndo:()=>ye,canRedo:()=>De,clearHistory:re,exportToPNG:async()=>{if(!ue.current)throw new Error("Gantt container not found");let S=await Bd(ue.current,{backgroundColor:K.bgPrimary,scale:2});return new Promise((M,Y)=>{S.toBlob(Q=>{Q?M(Q):Y(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async S=>{await se.exportToPDF(Z,S);},exportToExcel:async S=>{await se.exportToExcel(Z,S);},exportToJSON:()=>se.exportToJSON(Z),exportToCSV:()=>se.exportToCSV(Z),importFromJSON:S=>{let M=se.importFromJSON(S);we(M);},getTasks:()=>Z,refresh:()=>{we(S=>[...S]);},clearAll:()=>{we([]);}}),[Z,ee,ae,ye,De,re,K,ht]);let jt=useCallback(S=>{ze(M=>M.map(Y=>Y.id===S?{...Y,visible:!Y.visible}:Y));},[]),Pr=useCallback((S,M)=>{ze(Y=>Y.map(Q=>{if(Q.id!==S)return Q;let de=Q.minWidth??100,Ce=Q.maxWidth??800,Ot=Math.max(de,Math.min(Ce,M));return {...Q,width:Ot}}));},[]),Do=useCallback(S=>{we(M=>{let Y=Ms(M,S),Q=de=>{for(let Ce of de){if(Ce.id===S){be.current.set(S,Ce.isExpanded??true);return}Ce.subtasks?.length&&Q(Ce.subtasks);}};return Q(Y),ce(),Y}),a.onTaskToggleExpand?.(S);},[a,ce]),Sa=useCallback((S,M)=>{if(Re&&Re(S,M)===false)return;let Q=se.findTaskById(Z,S)?.progress,de=Ot=>Ot.map(Gt=>Gt.id===S?{...Gt,...M}:Gt.subtasks?{...Gt,subtasks:de(Gt.subtasks)}:Gt);we(de(Z));let Ce=se.findTaskById(de(Z),S);Ce&&(v?.(Ce),Ue?.(Ce),M.progress!==void 0&&Q!==void 0&&M.progress!==Q&&F?.(S,Q,M.progress));},[Z,v,Re,Ue,F]),Ha=useCallback(S=>{S.length!==0&&(we(M=>Ts(M,S)),a.onTaskIndent?.(S[0]));},[a]),dr=useCallback(S=>{S.length!==0&&(we(M=>Ds(M,S)),a.onTaskOutdent?.(S[0]));},[a]),Bt=useCallback((S,M,Y)=>{we(Q=>gd(Q,S,M,Y)),a.onTaskReparent?.(S,M,Y);},[a]),Nn=useCallback((S,M)=>{S.length!==0&&(we(Y=>Ns(Y,S,M)),a.onTaskMove?.(S[0],M));},[a]),qr=useCallback(async S=>{let M=[];for(let Y of S)z&&await Promise.resolve(z(Y))===false||M.push(Y);M.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(M):(we(Y=>Ss(Y,M)),M.forEach(Y=>a.onTaskDelete?.(Y))),L&&M.forEach(Y=>L(Y)));},[a,z,L]),Bi=useCallback(S=>{we(M=>Es(M,S)),S.forEach(M=>a.onTaskDuplicate?.(M));},[a]),Xr=useCallback((S,M)=>{we(Y=>{let{tasks:Q,newTask:de}=ud(Y,S,M);return fe&&fe(de)===false?Y:(a.onTaskCreate?.(de.parentId,de.position||0),ve?.(de),Q)});},[a,fe,ve]),Xc=useCallback((S,M)=>{we(Y=>Ps(Y,S,M)),a.onTaskRename?.(S,M);},[a]),Sn=useCallback(S=>{we(M=>{let{tasks:Y}=As(M,S);return a.onTaskCreate?.(S,0),Y});},[a]),Jc=useCallback((S,M,Y)=>{let Q=S.startDate?Math.round((M.getTime()-S.startDate.getTime())/864e5):0,de=Gt=>Gt.map(Jt=>Jt.id===S.id?{...Jt,startDate:M,endDate:Y,...S.segments&&{segments:S.segments}}:Jt.subtasks?{...Jt,subtasks:de(Jt.subtasks)}:Jt),Ce=de(Z);Ce=se.autoScheduleDependents(Ce,S.id,Q),we(Ce);let Ot={...S,startDate:M,endDate:Y};v?.(Ot);},[Z,v]),Zc=useCallback((S,M)=>{A?.(S,M),ie({isOpen:true,x:M.clientX,y:M.clientY,task:S});},[A]),Qc=useCallback((S,M)=>{let Y=se.splitTask(Z,S.id,M);we(Y),ie({isOpen:false,x:0,y:0,task:null});},[Z]),Ri=useCallback(S=>{let M=se.findTaskById(Z,S.id)||S;N?.(M),T||Ae(M);},[Z,N,T]),Oi=useCallback((S,M,Y)=>{let Q=new Map,de=Ea=>{Ea.forEach(Ga=>{Ga.dependencies&&Q.set(Ga.id,Ga.dependencies),Ga.subtasks&&de(Ga.subtasks);});};de(Y);let Ce=Q.get(M)||[];Q.set(M,[...Ce,S]);let Ot=new Set,Gt=new Set,Jt=Ea=>{if(!Ot.has(Ea)){Ot.add(Ea),Gt.add(Ea);let Ga=Q.get(Ea)||[];for(let cr of Ga){if(!Ot.has(cr)&&Jt(cr))return true;if(Gt.has(cr))return true}}return Gt.delete(Ea),false};return Jt(M)},[]),zi=useCallback((S,M)=>{if(Oi(S.id,M,Z)){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=J=>J.map(ce=>{if(ce.id===M){let we=ce.dependencies||[];if(!we.includes(S.id))return {...ce,dependencies:[...we,S.id]}}return ce.subtasks?{...ce,subtasks:j(ce.subtasks)}:ce});Y(j(I)),H?.(S.id,M);},[I,H,zi]),Ui=useCallback((S,M)=>{let j=J=>J.map(ce=>{if(ce.id===S&&ce.dependencies){let we=ce.dependencies.filter(zt=>zt!==M);return {...ce,dependencies:we}}return ce.subtasks?{...ce,subtasks:j(ce.subtasks)}:ce});Y(j(I)),q?.(S,M);},[I,q]),{startDate:Jc,endDate:Zc}=useMemo(()=>{let S=I.filter(we=>we.startDate&&we.endDate);if(S.length===0){let we=new Date,zt=new Date(we);zt.setDate(zt.getDate()-30);let _t=new Date(we);return _t.setDate(_t.getDate()+60),{startDate:zt,endDate:_t}}let M=S.flatMap(we=>[we.startDate,we.endDate]).filter(we=>we!==void 0),j=new Date(Math.min(...M.map(we=>we.getTime()))),J=new Date(Math.max(...M.map(we=>we.getTime()))),ce=U==="day"?7:U==="week"?14:30;return j.setDate(j.getDate()-ce),J.setDate(J.getDate()+ce),{startDate:j,endDate:J}},[I,U]),Qc=useCallback(async()=>{if(!Ue.current)return;let S=await Rd(Ue.current,{backgroundColor:Je.bgPrimary,scale:2}),M=document.createElement("a");M.download="gantt-chart.png",M.href=S.toDataURL("image/png"),M.click();},[Je]),ep=useCallback(async()=>{await le.exportToPDF(I);},[I]),tp=useCallback(async()=>{await le.exportToExcel(I);},[I]),ap=useCallback(()=>{let S=le.exportToCSV(I),M=new Blob([S],{type:"text/csv;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(M),j.download="gantt-chart.csv",j.click(),URL.revokeObjectURL(j.href);},[I]),rp=useCallback(()=>{let S=le.exportToJSON(I),M=new Blob([S],{type:"application/json;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(M),j.download="gantt-chart.json",j.click(),URL.revokeObjectURL(j.href);},[I]),op=useCallback(()=>{le.exportToMSProject(I,"Gantt Project","project.xml");},[I]),np=S=>{S.preventDefault(),Dt(true);};return useEffect(()=>{let S=fe.current,M=nt.current;if(!S||!M)return;let j=M.querySelector(".gantt-taskgrid-content"),J=()=>{let Zt=S.scrollTop;et(Zt),j&&(j.style.transform=`translateY(-${Zt}px)`);},ce=Zt=>{if(ht&&M){let Ga=M.parentElement?.getBoundingClientRect()?.left||0,pr=Zt.clientX-Ga,sp=280,ip=window.innerWidth-100;pr>=sp&&pr<=ip&&O(pr);}},we=()=>{Dt(false);},zt=M.querySelector(".gantt-grid-scroll")||M,_t=Zt=>{let Da=Zt;Da.deltaY!==0&&(S.scrollTop+=Da.deltaY,Zt.preventDefault());};return S.addEventListener("scroll",J),zt.addEventListener("wheel",_t,{passive:false}),document.addEventListener("mousemove",ce),document.addEventListener("mouseup",we),()=>{S.removeEventListener("scroll",J),zt.removeEventListener("wheel",_t),document.removeEventListener("mousemove",ce),document.removeEventListener("mouseup",we);}},[ht]),jsx(jr.Provider,{value:ie,children:jsx(Rn.Provider,{value:z,children:jsxs("div",{ref:Ue,className:"flex flex-col h-full w-full",style:{backgroundColor:Je.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsx(Yo,{theme:Je,timeScale:U,onTimeScaleChange:De,zoom:be,onZoomChange:tt,currentTheme:K,onThemeChange:Ie,rowDensity:ke,onRowDensityChange:$e,showThemeSelector:p,showCreateTaskButton:k,createTaskLabel:h,onCreateTask:b,onExportPNG:n?Qc:void 0,onExportPDF:n?ep:void 0,onExportExcel:n?tp:void 0,onExportCSV:n?ap:void 0,onExportJSON:n?rp:void 0,onExportMSProject:n?op:void 0}),jsxs("div",{ref:nt,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:Z,overflowX:"auto",overflowY:"hidden"},children:jsx(Zo,{tasks:Ge,theme:Je,rowHeight:Ke,availableUsers:m,templates:ne,onTaskClick:D,onTaskDblClick:Fr,onTaskContextMenu:A,onTaskToggle:qa,scrollTop:Pe,columns:Me,onToggleColumn:aa,onColumnResize:dr,onTaskUpdate:Ra,onTaskIndent:pe,onTaskOutdent:Nt,onTaskMove:Ar,onMultiTaskDelete:Ir,onTaskDuplicate:Lr,onTaskCreate:Ha,onTaskRename:cr,onCreateSubtask:St,onOpenTaskModal:D?S=>D(S):void 0,onDeleteRequest:(S,M)=>ut({taskId:S,taskName:M}),onTaskReparent:Jt})}),jsx("div",{className:"flex-shrink-0 cursor-col-resize hover:bg-blue-500/20 transition-colors h-full",style:{width:5,backgroundColor:"transparent",borderLeft:`1px solid ${Je.border}`,zIndex:15},onMouseDown:np}),jsx("div",{ref:fe,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsx(sn,{tasks:Ge,theme:Je,rowHeight:Ke,timeScale:U,startDate:Jc,endDate:Zc,zoom:be,templates:ne,onTaskClick:D,onTaskDblClick:Fr,onTaskContextMenu:An,onTaskDateChange:Mn,onDependencyCreate:$i,onDependencyDelete:Ui})})]}),re.task&&jsx(Kr,{isOpen:re.isOpen,x:re.x,y:re.y,theme:Je,onClose:()=>de({isOpen:false,x:0,y:0,task:null}),items:(()=>{let S=re.task;if(!S)return [];let M=le.findTaskById(I,S.id)||S;return M.subtasks&&M.subtasks.length>0?[{id:"addSubtask",label:ie.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{w?w(M):St(M.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:ie.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{ut({taskId:M.id,taskName:M.name});}}]:[{id:"edit",label:ie.contextMenu?.editTask||"Edit Task",icon:Ct.Pencil,onClick:()=>{T?T(M):Ee(M);}},{id:"addSubtask",label:ie.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{w?w(M):St(M.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:ie.contextMenu?.markIncomplete||"Mark Incomplete",icon:Ct.MarkIncomplete,onClick:()=>{R?R(M):Ra(M.id,{status:"todo",progress:0});},disabled:M.status==="todo"},{id:"setInProgress",label:ie.contextMenu?.setInProgress||"Set In Progress",icon:Ct.SetInProgress,onClick:()=>{P?P(M):Ra(M.id,{status:"in-progress"});},disabled:M.status==="in-progress"},{id:"markComplete",label:ie.contextMenu?.markComplete||"Mark Complete",icon:Ct.MarkComplete,onClick:()=>{Ra(M.id,{status:"completed",progress:100});},disabled:M.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:ie.contextMenu?.splitTask||"Split Task",icon:Ct.Split,onClick:()=>{if(!M.startDate||!M.endDate){console.warn("Cannot split task without dates");return}let J=M.startDate.getTime(),ce=M.endDate.getTime(),we=J+(ce-J)/2,zt=new Date(we);Oi(M,zt);},disabled:!M.startDate||!M.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:ie.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{ut({taskId:M.id,taskName:M.name});}}]})()}),Ce&&jsx(dn,{isOpen:true,onClose:()=>Ee(null),task:Ce,onSubmit:S=>{Ra(Ce.id,S),Ee(null);},mode:"edit",theme:K}),jsx(AnimatePresence,{children:at&&jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[10000] flex items-center justify-center p-4",style:{backgroundColor:"rgba(0, 0, 0, 0.6)"},onClick:()=>ut(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:S=>S.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:Je.bgSecondary,border:`1px solid ${Je.border}`},children:[jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${Je.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:Je.textPrimary,fontFamily:"Inter, sans-serif"},children:[ie.contextMenu?.deleteTask||"Delete Task","?"]}),jsx("p",{className:"text-sm mt-1",style:{color:Je.textSecondary,fontFamily:"Inter, sans-serif"},children:f==="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:Je.textSecondary,fontFamily:"Inter, sans-serif"},children:[f==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxs("span",{className:"font-semibold",style:{color:Je.textPrimary},children:['"',at.taskName,'"']}),"."]})}),jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:Je.bgPrimary,borderTop:`1px solid ${Je.border}`},children:[jsx("button",{onClick:()=>ut(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:Je.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor=Je.hoverBg;},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent";},children:f==="es"?"Cancelar":"Cancel"}),jsxs("button",{onClick:()=>{Ir([at.taskId]),ut(null);},className:"px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:"#EF4444",fontFamily:"Inter, sans-serif"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="#EF4444";},children:[jsx(Trash2,{className:"w-4 h-4"}),f==="es"?"Eliminar":"Delete"]})]})]})})}),x?.enabled&&jsx(cn,{tasks:I,theme:Je,config:x,onTasksUpdate:Y,onTaskUpdate:Ra,onTaskCreate:S=>{Y(M=>[...M,S]);},onTaskDelete:S=>{Ir([S]);},onDependencyCreate:(S,M)=>{let j=le.findTaskById(I,S);j&&$i(j,M);},onDependencyDelete:Ui})]})})})});var zd=`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 Y=Q=>Q.map(de=>{if(de.id===M){let Ce=de.dependencies||[];if(!Ce.includes(S.id))return {...de,dependencies:[...Ce,S.id]}}return de.subtasks?{...de,subtasks:Y(de.subtasks)}:de});we(Y(Z)),H?.(S.id,M);},[Z,H,Oi]),$i=useCallback((S,M)=>{let Y=Q=>Q.map(de=>{if(de.id===S&&de.dependencies){let Ce=de.dependencies.filter(Ot=>Ot!==M);return {...de,dependencies:Ce}}return de.subtasks?{...de,subtasks:Y(de.subtasks)}:de});we(Y(Z)),X?.(S,M);},[Z,X]),{startDate:ep,endDate:tp}=useMemo(()=>{let S=Z.filter(Ce=>Ce.startDate&&Ce.endDate);if(S.length===0){let Ce=new Date,Ot=new Date(Ce);Ot.setDate(Ot.getDate()-30);let Gt=new Date(Ce);return Gt.setDate(Gt.getDate()+60),{startDate:Ot,endDate:Gt}}let M=S.flatMap(Ce=>[Ce.startDate,Ce.endDate]).filter(Ce=>Ce!==void 0),Y=new Date(Math.min(...M.map(Ce=>Ce.getTime()))),Q=new Date(Math.max(...M.map(Ce=>Ce.getTime()))),de=$==="day"?7:$==="week"?14:30;return Y.setDate(Y.getDate()-de),Q.setDate(Q.getDate()+de),{startDate:Y,endDate:Q}},[Z,$]),ap=useCallback(async()=>{if(!ue.current)return;let S=await Bd(ue.current,{backgroundColor:K.bgPrimary,scale:2}),M=document.createElement("a");M.download="gantt-chart.png",M.href=S.toDataURL("image/png"),M.click();},[K]),rp=useCallback(async()=>{await se.exportToPDF(Z);},[Z]),op=useCallback(async()=>{await se.exportToExcel(Z);},[Z]),np=useCallback(()=>{let S=se.exportToCSV(Z),M=new Blob([S],{type:"text/csv;charset=utf-8;"}),Y=document.createElement("a");Y.href=URL.createObjectURL(M),Y.download="gantt-chart.csv",Y.click(),URL.revokeObjectURL(Y.href);},[Z]),sp=useCallback(()=>{let S=se.exportToJSON(Z),M=new Blob([S],{type:"application/json;charset=utf-8;"}),Y=document.createElement("a");Y.href=URL.createObjectURL(M),Y.download="gantt-chart.json",Y.click(),URL.revokeObjectURL(Y.href);},[Z]),ip=useCallback(()=>{se.exportToMSProject(Z,"Gantt Project","project.xml");},[Z]),lp=S=>{S.preventDefault(),Tt(true);};return useEffect(()=>{let S=R.current,M=Qt.current;if(!S||!M)return;let Y=M.querySelector(".gantt-taskgrid-content"),Q=()=>{let Jt=S.scrollTop;et(Jt),Y&&(Y.style.transform=`translateY(-${Jt}px)`);},de=Jt=>{if(ft&&M){let Ga=M.parentElement?.getBoundingClientRect()?.left||0,cr=Jt.clientX-Ga,dp=280,cp=window.innerWidth-100;cr>=dp&&cr<=cp&&O(cr);}},Ce=()=>{Tt(false);},Ot=M.querySelector(".gantt-grid-scroll")||M,Gt=Jt=>{let Ea=Jt;Ea.deltaY!==0&&(S.scrollTop+=Ea.deltaY,Jt.preventDefault());};return S.addEventListener("scroll",Q),Ot.addEventListener("wheel",Gt,{passive:false}),document.addEventListener("mousemove",de),document.addEventListener("mouseup",Ce),()=>{S.removeEventListener("scroll",Q),Ot.removeEventListener("wheel",Gt),document.removeEventListener("mousemove",de),document.removeEventListener("mouseup",Ce);}},[ft]),jsx(Wr.Provider,{value:G,children:jsx(In.Provider,{value:Ft,children:jsxs("div",{ref:ue,className:"flex flex-col h-full w-full",style:{backgroundColor:K.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsx(jo,{theme:K,timeScale:$,onTimeScaleChange:Te,zoom:he,onZoomChange:tt,currentTheme:q,onThemeChange:qe,rowDensity:ke,onRowDensityChange:Ge,showThemeSelector:p,showCreateTaskButton:k,createTaskLabel:h,onCreateTask:b,onExportPNG:n?ap:void 0,onExportPDF:n?rp:void 0,onExportExcel:n?op:void 0,onExportCSV:n?np:void 0,onExportJSON:n?sp:void 0,onExportMSProject:n?ip:void 0}),jsxs("div",{ref:Qt,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:Dt,overflowX:"auto",overflowY:"hidden"},children:jsx(Ko,{tasks:le,theme:K,rowHeight:ht,availableUsers:m,templates:aa,onTaskClick:D,onTaskDblClick:Ri,onTaskContextMenu:A,onTaskToggle:Do,scrollTop:Fe,columns:Ie,onToggleColumn:jt,onColumnResize:Pr,onTaskUpdate:Sa,onTaskIndent:Ha,onTaskOutdent:dr,onTaskMove:Nn,onMultiTaskDelete:qr,onTaskDuplicate:Bi,onTaskCreate:Xr,onTaskRename:Xc,onCreateSubtask:Sn,onOpenTaskModal:D?S=>D(S):void 0,onDeleteRequest:(S,M)=>st({taskId:S,taskName:M}),onTaskReparent:Bt})}),jsxs("div",{className:"flex-shrink-0 flex flex-col h-full",style:{zIndex:15},children:[jsxs("div",{className:"flex items-center gap-1 px-2",style:{height:"48px",backgroundColor:K.bgGrid,borderBottom:`1px solid ${K.border}`,flexShrink:0,position:"relative"},children:[jsx(nn,{columns:Ie,onToggleColumn:jt,theme:K}),jsx("button",{onClick:()=>V(!Le),className:"p-1.5 rounded hover:bg-opacity-10 transition-colors",style:{color:K.textTertiary},title:"Keyboard shortcuts",children:jsx(Keyboard,{className:"w-4 h-4"})}),Le&&jsxs("div",{ref:xe,className:"absolute top-full left-0 mt-2 p-4 rounded-lg shadow-2xl z-50 min-w-[400px]",style:{backgroundColor:K.bgPrimary,border:`1px solid ${K.border}`,color:K.textPrimary},onClick:S=>S.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b",style:{borderColor:K.border},children:[jsx("h3",{className:"font-semibold text-sm",style:{color:K.textPrimary},children:"Keyboard Shortcuts"}),jsx("button",{onClick:()=>V(false),className:"text-xs px-2 py-1 rounded hover:bg-opacity-10",style:{color:K.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:K.textSecondary},children:"Navigation"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Move focus up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"\u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Select range"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Shift + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Toggle selection"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Cmd/Ctrl + Click"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:K.textSecondary},children:"Hierarchy"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Indent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Outdent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Shift + Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Expand/Collapse"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"\u2192 / \u2190"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:K.textSecondary},children:"Editing"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Create task below"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Create task above"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Shift + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Open task modal"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Cmd/Ctrl + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Rename task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"F2"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:K.textSecondary},children:"Actions"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Move task up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Alt + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Delete task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Delete"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Duplicate task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Cmd/Ctrl + D"})]})]})]})]})]})]}),jsx("div",{className:"flex-1 cursor-col-resize hover:bg-blue-500/20 transition-colors",style:{width:"100%",minWidth:"60px",backgroundColor:K.bgPrimary,borderLeft:`1px solid ${K.border}`},onMouseDown:lp})]}),jsx("div",{ref:R,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsx(tn,{tasks:le,theme:K,rowHeight:ht,timeScale:$,startDate:ep,endDate:tp,zoom:he,templates:aa,onTaskClick:D,onTaskDblClick:Ri,onTaskContextMenu:Zc,onTaskDateChange:Jc,onDependencyCreate:zi,onDependencyDelete:$i})})]}),ne.task&&jsx(Hr,{isOpen:ne.isOpen,x:ne.x,y:ne.y,theme:K,onClose:()=>ie({isOpen:false,x:0,y:0,task:null}),items:(()=>{let S=ne.task;if(!S)return [];let M=se.findTaskById(Z,S.id)||S;return M.subtasks&&M.subtasks.length>0?[{id:"addSubtask",label:G.contextMenu?.addSubtask||"Add Subtask",icon:wt.Add,onClick:()=>{w?w(M):Sn(M.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:G.contextMenu?.deleteTask||"Delete Task",icon:wt.Delete,onClick:()=>{st({taskId:M.id,taskName:M.name});}}]:[{id:"edit",label:G.contextMenu?.editTask||"Edit Task",icon:wt.Pencil,onClick:()=>{T?T(M):Ae(M);}},{id:"addSubtask",label:G.contextMenu?.addSubtask||"Add Subtask",icon:wt.Add,onClick:()=>{w?w(M):Sn(M.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:G.contextMenu?.markIncomplete||"Mark Incomplete",icon:wt.MarkIncomplete,onClick:()=>{B?B(M):Sa(M.id,{status:"todo",progress:0});},disabled:M.status==="todo"},{id:"setInProgress",label:G.contextMenu?.setInProgress||"Set In Progress",icon:wt.SetInProgress,onClick:()=>{P?P(M):Sa(M.id,{status:"in-progress"});},disabled:M.status==="in-progress"},{id:"markComplete",label:G.contextMenu?.markComplete||"Mark Complete",icon:wt.MarkComplete,onClick:()=>{Sa(M.id,{status:"completed",progress:100});},disabled:M.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:G.contextMenu?.splitTask||"Split Task",icon:wt.Split,onClick:()=>{if(!M.startDate||!M.endDate){console.warn("Cannot split task without dates");return}let Q=M.startDate.getTime(),de=M.endDate.getTime(),Ce=Q+(de-Q)/2,Ot=new Date(Ce);Qc(M,Ot);},disabled:!M.startDate||!M.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:G.contextMenu?.deleteTask||"Delete Task",icon:wt.Delete,onClick:()=>{st({taskId:M.id,taskName:M.name});}}]})()}),Se&&jsx(rn,{isOpen:true,onClose:()=>Ae(null),task:Se,onSubmit:S=>{Sa(Se.id,S),Ae(null);},mode:"edit",theme:q}),jsx(AnimatePresence,{children:ot&&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:()=>st(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:S=>S.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:K.bgSecondary,border:`1px solid ${K.border}`},children:[jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${K.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:K.textPrimary,fontFamily:"Inter, sans-serif"},children:[G.contextMenu?.deleteTask||"Delete Task","?"]}),jsx("p",{className:"text-sm mt-1",style:{color:K.textSecondary,fontFamily:"Inter, sans-serif"},children:f==="es"?"Esta acci\xF3n no se puede deshacer":"This action cannot be undone"})]})]})}),jsx("div",{className:"px-6 py-4",children:jsxs("p",{className:"text-sm leading-relaxed",style:{color:K.textSecondary,fontFamily:"Inter, sans-serif"},children:[f==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxs("span",{className:"font-semibold",style:{color:K.textPrimary},children:['"',ot.taskName,'"']}),"."]})}),jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:K.bgPrimary,borderTop:`1px solid ${K.border}`},children:[jsx("button",{onClick:()=>st(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:K.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor=K.hoverBg;},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent";},children:f==="es"?"Cancelar":"Cancel"}),jsxs("button",{onClick:()=>{qr([ot.taskId]),st(null);},className:"px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:"#EF4444",fontFamily:"Inter, sans-serif"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="#EF4444";},children:[jsx(Trash2,{className:"w-4 h-4"}),f==="es"?"Eliminar":"Delete"]})]})]})})}),x?.enabled&&jsx(on,{tasks:Z,theme:K,config:x,onTasksUpdate:we,onTaskUpdate:Sa,onTaskCreate:S=>{we(M=>[...M,S]);},onTaskDelete:S=>{qr([S]);},onDependencyCreate:(S,M)=>{let Y=se.findTaskById(Z,S);Y&&zi(Y,M);},onDependencyDelete:$i})]})})})});var Od=`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
|
|
@@ -382,39 +382,39 @@ Tasks have: id, name, startDate, endDate, progress, status, dependencies[], assi
|
|
|
382
382
|
|
|
383
383
|
Always try to match task names case-insensitively and handle partial matches.
|
|
384
384
|
If you can't find a task by name, search through the provided task list.
|
|
385
|
-
If ambiguous, ask for clarification in the message field.`;function
|
|
386
|
-
${
|
|
385
|
+
If ambiguous, ask for clarification in the message field.`;function zd(e){return `CURRENT TASKS:
|
|
386
|
+
${$d(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",l=r.dependencies?.length?`deps: [${r.dependencies.join(", ")}]`:"";return `- ${r.id}: "${r.name}" (${o} to ${s}, ${r.progress}%, ${r.status||"todo"}) ${l}`}).join(`
|
|
387
387
|
`)}
|
|
388
388
|
|
|
389
|
-
Today's date: ${new Date().toISOString().split("T")[0]}`}function Ud(e){let t=[],a=r=>{for(let o of r)t.push(o),o.subtasks?.length&&a(o.subtasks);};return a(e),t}function Ka(e,t){let a=Ud(e),r=t.toLowerCase().trim(),o=a.find(c=>c.name.toLowerCase()===r);if(o)return o;let s=a.find(c=>c.name.toLowerCase().includes(r));if(s)return s;let l=r.split(/\s+/);return a.find(c=>{let p=c.name.toLowerCase();return l.every(n=>p.includes(n))})}function Vs(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 i=new Date(r);return i.setDate(i.getDate()+1),i}if(a==="yesterday"||a==="ayer"){let i=new Date(r);return i.setDate(i.getDate()-1),i}if(a==="next week"||a==="la pr\xF3xima semana"){let i=new Date(r);return i.setDate(i.getDate()+7),i}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 u={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(u!==void 0){let x=new Date(r),f=x.getDay(),g=u-f;return g<=0&&(g+=7),x.setDate(x.getDate()+g),x}}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 i=parseInt(s[1],10),u=s[2].toLowerCase(),x=new Date(r);return u==="day"||u==="d\xEDa"||u==="dias"?x.setDate(x.getDate()+i):u==="week"||u==="semana"||u==="semanas"?x.setDate(x.getDate()+i*7):(u==="month"||u==="mes"||u==="meses")&&x.setMonth(x.getMonth()+i),x}if(a.match(/(\d{4})-(\d{2})-(\d{2})/))return new Date(a);let c=a.match(/(\d{1,2})\/(\d{1,2})\/(\d{4})/);if(c&&c[1]&&c[2]&&c[3]){let i=parseInt(c[1],10),u=parseInt(c[2],10)-1,x=parseInt(c[3],10);return new Date(x,u,i)}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},n=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(n&&n[1]&&n[2]){let i=parseInt(n[1],10),u=p[n[2].toLowerCase()],x=n[3]?parseInt(n[3],10):r.getFullYear();if(u!==void 0)return new Date(x,u,i)}let m={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 i=m[d[1].toLowerCase()],u=parseInt(d[2],10),x=d[3]?parseInt(d[3],10):r.getFullYear();if(i!==void 0)return new Date(x,i,u)}return null}function js(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 Ks(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 Wd(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 Hd(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 n=r[1].trim(),m=r[2].trim(),d=Ka(t,n),i=Vs(m);if(!d)return {type:"move_task",taskName:n,message:`Could not find a task named "${n}". Please check the task name and try again.`,success:false,error:"Task not found"};if(!i)return {type:"move_task",taskId:d.id,taskName:d.name,message:`Could not parse the date "${m}". Try using formats like "next Monday", "in 3 days", or "2024-01-15".`,success:false,error:"Invalid date"};let u=d.startDate&&d.endDate?Math.round((d.endDate.getTime()-d.startDate.getTime())/(1e3*60*60*24)):1,x=new Date(i);return x.setDate(x.getDate()+u),{type:"move_task",taskId:d.id,taskName:d.name,updates:{startDate:i,endDate:x},message:`Moved "${d.name}" to ${i.toLocaleDateString()}.`,success:true}}let o=a.match(/(?:extend|extender|extiende|alargar)\s+["""]?(.+?)["""]?\s+(?:by|por)\s+(.+)/i);if(o&&o[1]&&o[2]){let n=o[1].trim(),m=o[2].trim(),d=Ka(t,n),i=js(m);if(!d)return {type:"resize_task",taskName:n,message:`Could not find a task named "${n}".`,success:false,error:"Task not found"};if(!i||!d.endDate)return {type:"resize_task",taskId:d.id,taskName:d.name,message:`Could not parse the duration "${m}".`,success:false,error:"Invalid duration"};let u=new Date(d.endDate);return u.setDate(u.getDate()+i),{type:"resize_task",taskId:d.id,taskName:d.name,updates:{endDate:u},message:`Extended "${d.name}" by ${i} days. New end date: ${u.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 n=s[1].trim(),m=s[2].trim(),d=Ka(t,n),i=Ks(m);return d?i===null?{type:"set_progress",taskId:d.id,taskName:d.name,message:`Could not parse the progress value "${m}".`,success:false,error:"Invalid progress"}:{type:"set_progress",taskId:d.id,taskName:d.name,updates:{progress:i},message:`Set "${d.name}" progress to ${i}%.`,success:true}:{type:"set_progress",taskName:n,message:`Could not find a task named "${n}".`,success:false,error:"Task not found"}}let l=a.match(/(?:rename|renombrar|cambiar nombre de)\s+["""]?(.+?)["""]?\s+(?:to|a|por)\s+["""]?(.+?)["""]?$/i);if(l&&l[1]&&l[2]){let n=l[1].trim(),m=l[2].trim(),d=Ka(t,n);return d?{type:"rename_task",taskId:d.id,taskName:d.name,updates:{name:m},message:`Renamed "${d.name}" to "${m}".`,success:true}:{type:"rename_task",taskName:n,message:`Could not find a task named "${n}".`,success:false,error:"Task not found"}}let c=a.match(/(?:link|vincular|conectar)\s+["""]?(.+?)["""]?\s+(?:to|a|con)\s+["""]?(.+?)["""]?$/i);if(c&&c[1]&&c[2]){let n=c[1].trim(),m=c[2].trim(),d=Ka(t,n),i=Ka(t,m);return d?i?{type:"link_tasks",taskId:i.id,taskName:i.name,dependencyFrom:d.id,dependencyTo:i.id,message:`Linked "${d.name}" \u2192 "${i.name}".`,success:true}:{type:"link_tasks",taskName:m,message:`Could not find a task named "${m}".`,success:false,error:"Target task not found"}:{type:"link_tasks",taskName:n,message:`Could not find a task named "${n}".`,success:false,error:"Source task not found"}}let p=a.match(/(?:delete|eliminar|borrar|remove|quitar)\s+["""]?(.+?)["""]?$/i);if(p&&p[1]){let n=p[1].trim(),m=Ka(t,n);return m?{type:"delete_task",taskId:m.id,taskName:m.name,message:`Deleted "${m.name}".`,success:true}:{type:"delete_task",taskName:n,message:`Could not find a task named "${n}".`,success:false,error:"Task not found"}}return null}function Gd(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 Df(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 Nf(e){switch(e){case "todo":return "TODO";case "in-progress":return "IN_PROGRESS";case "completed":return "DONE";default:return e||"TODO"}}function mn(e,t=[],a=[]){let r=e.assignedUserIds?.map(m=>{let d=a.find(i=>i.id===m);return d?{name:d.name,initials:d.initials,color:d.color}:null}).filter(m=>m!==null),o=t.filter(m=>m.metadata?.parentCardId===e.id).map(m=>mn(m,t,a)),s;e.dependencies&&(typeof e.dependencies[0]=="string"?s=e.dependencies:s=e.dependencies.filter(m=>m.type==="finish-to-start").map(m=>m.taskId));let l=m=>{if(m)return typeof m=="string"?new Date(m):m},c=l(e.startDate),p=l(e.endDate),n=e.metadata?.isMilestone===true||c&&p&&Math.abs(p.getTime()-c.getTime())<=864e5;return {id:e.id,name:e.title,startDate:c,endDate:p,progress:e.progress||0,status:Df(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:n,isCriticalPath:e.metadata?.isCriticalPath===true}}function _d(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:Nf(e.status),isExpanded:e.isExpanded,isMilestone:e.isMilestone,isCriticalPath:e.isCriticalPath}}}function Vd(e,t=[]){return e.filter(r=>!r.metadata?.parentCardId).map(r=>mn(r,e,t))}var Ys={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"}},qs={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"}},un={en:Ys,es:qs};function Xs(e){return un[e]||un.en}function gn(e,t){let a=Xs(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 qd(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(...qd(r.subtasks,t+1));return a}function Of({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 Xd({tasks:e,config:t={},callbacks:a={},isLoading:r=false,error:o,className:s,style:l}){let{theme:c="dark",locale:p="en",customTranslations:n,showSearch:m=true,showHierarchy:d=true}=t,i=gn(p,n),u=c==="dark",[x,f]=useState(new Set),[g,k]=useState("startDate"),[h,b]=useState("asc"),[y,D]=useState("");useMemo(()=>{let T=new Set;function w(R){for(let P of R)P.subtasks?.length&&(T.add(P.id),w(P.subtasks));}w(e),f(T);},[e]);let N=useCallback(T=>{f(w=>{let R=new Set(w);return R.has(T)?R.delete(T):R.add(T),R}),a.onTaskToggleExpand?.(T);},[a]),A=useCallback(T=>{g===T?b(w=>w==="asc"?"desc":"asc"):(k(T),b("asc")),a.onSortChange?.({column:T,direction:h==="asc"?"desc":"asc"});},[g,h,a]),v=useMemo(()=>{let T=qd(e);if(y.trim()){let R=y.toLowerCase();T=T.filter(P=>P.name.toLowerCase().includes(R));}let w=[];for(let R of T){let P=R.level===0;R.level>0&&(P=true),(P||y.trim())&&w.push(R);}return y.trim()&&w.sort((R,P)=>{let H,q;switch(g){case "name":H=R.name.toLowerCase(),q=P.name.toLowerCase();break;case "startDate":H=R.startDate?.getTime()||0,q=P.startDate?.getTime()||0;break;case "endDate":H=R.endDate?.getTime()||0,q=P.endDate?.getTime()||0;break;case "progress":H=R.progress||0,q=P.progress||0;break;case "status":H=R.status||"todo",q=P.status||"todo";break;default:return 0}return H<q?h==="asc"?-1:1:H>q?h==="asc"?1:-1:0}),w},[e,y,g,h]),B=T=>T?(T instanceof Date?T:new Date(T)).toLocaleDateString(p==="es"?"es-ES":"en-US",{day:"numeric",month:"short"}):"-";return r?jsx("div",{className:C("flex-1 flex items-center justify-center",u?"bg-[#0F1117]":"bg-white",s),style:l,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:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[i.empty.noTasks,"..."]})]})}):o?jsx("div",{className:C("flex-1 flex items-center justify-center",u?"bg-[#0F1117]":"bg-white",s),style:l,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:C("text-lg font-semibold mb-2",u?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:typeof o=="string"?o:o.message})]})]})}):e.length===0?jsx("div",{className:C("flex-1 flex items-center justify-center",u?"bg-[#0F1117]":"bg-white",s),style:l,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:C("text-lg font-semibold mb-2",u?"text-white":"text-gray-900"),children:i.empty.noTasks}),jsx("p",{className:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:i.empty.addFirstTask})]})}):jsxs("div",{className:C("flex-1 flex flex-col w-full h-full overflow-hidden",u?"bg-[#0F1117]":"bg-white",s),style:l,children:[jsx("div",{className:C("flex-shrink-0 px-6 py-4 border-b",u?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-center gap-4",children:[m&&jsxs("div",{className:"relative flex-1 max-w-md",children:[jsx(Search,{className:C("absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4",u?"text-[#9CA3AF]":"text-gray-400")}),jsx("input",{type:"text",value:y,onChange:T=>D(T.target.value),placeholder:i.toolbar.searchPlaceholder,className:C("w-full h-9 pl-10 pr-4 rounded-lg border outline-none focus:ring-2 focus:ring-[#3B82F6]/30",u?"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:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[v.length," ",i.pagination.tasks]})]})}),jsxs("div",{className:C("flex-shrink-0 grid grid-cols-12 gap-4 px-6 py-3 border-b text-xs font-medium uppercase tracking-wider",u?"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:()=>A("name"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.name,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>A("status"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.status,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>A("startDate"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.startDate,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>A("endDate"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.endDate,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-1 flex items-center gap-1",children:jsxs("button",{onClick:()=>A("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:v.map((T,w)=>{let R=x.has(T.id);return jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{delay:w*.02},className:C("grid grid-cols-12 gap-4 px-6 py-3 border-b transition-colors cursor-pointer",u?"border-white/5 hover:bg-white/5":"border-gray-100 hover:bg-gray-50"),style:{paddingLeft:d?`${24+T.level*24}px`:void 0},onClick:()=>a.onTaskClick?.(T),onDoubleClick:()=>a.onTaskDoubleClick?.(T),children:[jsxs("div",{className:"col-span-5 flex items-center gap-2 min-w-0",children:[d&&T.hasChildren&&jsx("button",{onClick:P=>{P.stopPropagation(),N(T.id);},className:C("p-0.5 rounded",u?"hover:bg-white/10":"hover:bg-gray-200"),children:R?jsx(ChevronDown,{className:C("w-4 h-4",u?"text-[#9CA3AF]":"text-gray-400")}):jsx(ChevronRight,{className:C("w-4 h-4",u?"text-[#9CA3AF]":"text-gray-400")})}),d&&!T.hasChildren&&jsx("div",{className:"w-5"}),jsx("button",{onClick:P=>{P.stopPropagation(),a.onTaskUpdate?.({...T,progress:T.progress===100?0:100,status:T.progress===100?"todo":"completed"});},className:"flex-shrink-0",children:jsx(Of,{status:T.status,progress:T.progress})}),jsx("span",{className:C("truncate",u?"text-white":"text-gray-900",T.progress===100&&(u?"line-through text-[#6B7280]":"line-through text-gray-400")),children:T.name})]}),jsx("div",{className:"col-span-2 flex items-center",children:jsx("span",{className:C("px-2 py-1 rounded-full text-xs font-medium",T.progress===100||T.status==="completed"?"bg-green-500/10 text-green-500":T.progress&&T.progress>0||T.status==="in-progress"?"bg-blue-500/10 text-blue-500":u?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:T.progress===100||T.status==="completed"?i.status.completed:T.progress&&T.progress>0||T.status==="in-progress"?i.status.inProgress:i.status.todo})}),jsxs("div",{className:C("col-span-2 flex items-center gap-1 text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Calendar,{className:"w-4 h-4"}),B(T.startDate)]}),jsxs("div",{className:C("col-span-2 flex items-center gap-1 text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Clock,{className:"w-4 h-4"}),B(T.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:C("flex-1 h-1.5 rounded-full overflow-hidden",u?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:C("h-full rounded-full transition-all",T.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${T.progress||0}%`}})}),jsxs("span",{className:C("text-xs w-8",u?"text-[#9CA3AF]":"text-gray-500"),children:[T.progress||0,"%"]})]})})]},T.id)})}),v.length===0&&y&&jsx("div",{className:"flex items-center justify-center py-12",children:jsxs("div",{className:"text-center",children:[jsx(List,{className:C("w-12 h-12 mx-auto mb-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:C(u?"text-[#9CA3AF]":"text-gray-600"),children:i.empty.noResults})]})})]})]})}var Js={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"},Zs={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"},Qs={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"},hn={dark:Js,light:Zs,neutral:Qs};function Jd(e){return hn[e]||hn.dark}var ei={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"}},ti={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"}},bn={en:ei,es:ti};function xo(e){return bn[e]||bn.en}function yn(e,t){let a=xo(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 Zd(e){let t=xo(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 Qd(e,t=0,a=true){let r=xo(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 Xf(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 si(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 ac({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 oc({tasks:e,config:t={},callbacks:a={},initialDate:r,isLoading:o=false,error:s,className:l,style:c}){let{theme:p="dark",locale:n="en",customTranslations:m}=t,d=yn(n,m),i=p==="dark",[u,x]=useState(r||new Date),[f,g]=useState(null),[k,h]=useState(null),[b,y]=useState(null),[D,N]=useState(new Date),[A,v]=useState({}),B=4,T=3,[w,R]=useState(false),[P,H]=useState(false),[q,he]=useState(false),[xe,Ae]=useState(null),[Be,$]=useState(""),[F,W]=useState(void 0),[E,K]=useState(null),[X$1,U]=useState(false),[De,ke]=useState(false),[$e,be]=useState(null),[tt,Pe]=useState(false),[et,ht]=useState(new Date),Dt=useCallback(()=>{x(new Date(u.getFullYear(),u.getMonth()-1,1));},[u]),dt=useCallback(()=>{x(new Date(u.getFullYear(),u.getMonth()+1,1));},[u]),O=useCallback(()=>{x(new Date);},[]),re=useMemo(()=>{let I=u.getFullYear(),Y=u.getMonth(),He=new Date(I,Y,1),We=new Date(I,Y+1,0),yt=He.getDay(),Q=We.getDate(),te=Xf(e),ve=new Date;ve.setHours(0,0,0,0);let Te=[],oe=yt,Se=new Date(I,Y,0).getDate();for(let Ne=oe-1;Ne>=0;Ne--){let ie=new Date(I,Y-1,Se-Ne);Te.push({date:ie,isCurrentMonth:false,isToday:false,isWeekend:ie.getDay()===0||ie.getDay()===6,events:te.filter(Fe=>si(ie,Fe)).map(Fe=>({id:Fe.id,title:Fe.name,start:Fe.startDate,end:Fe.endDate,task:Fe}))});}for(let Ne=1;Ne<=Q;Ne++){let ie=new Date(I,Y,Ne),Fe=ie.getTime()===ve.getTime();Te.push({date:ie,isCurrentMonth:true,isToday:Fe,isWeekend:ie.getDay()===0||ie.getDay()===6,events:te.filter(Me=>si(ie,Me)).map(Me=>({id:Me.id,title:Me.name,start:Me.startDate,end:Me.endDate,task:Me}))});}let ye=42-Te.length;for(let Ne=1;Ne<=ye;Ne++){let ie=new Date(I,Y+1,Ne);Te.push({date:ie,isCurrentMonth:false,isToday:false,isWeekend:ie.getDay()===0||ie.getDay()===6,events:te.filter(Fe=>si(ie,Fe)).map(Fe=>({id:Fe.id,title:Fe.name,start:Fe.startDate,end:Fe.endDate,task:Fe}))});}return Te},[u,e]),de=n==="es"?["Dom","Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b"]:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ce=u.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"}),Ee=useCallback((I,Y)=>{if(!f)return;let He={...f,[I]:Y};g(He),a.onTaskUpdate?.(He);},[f,a]),at=useCallback(I=>{if(!f)return;let Y=f.progress||0;I==="completed"?Y=100:I==="todo"&&(Y=0);let He={...f,status:I,progress:Y};g(He),a.onTaskUpdate?.(He),R(false);},[f,a]),ut=useCallback((I,Y)=>{if(!f)return;let He={...f,startDate:I,endDate:Y};g(He),a.onTaskUpdate?.(He);},[f,a]),Ie=useCallback(()=>{R(false),H(false),y(null);},[]);return o?jsx("div",{className:C("flex-1 flex items-center justify-center",i?"bg-[#0F1117]":"bg-white",l),style:c,children:jsxs("div",{className:"flex flex-col items-center gap-4",children:[jsx("div",{className:"w-8 h-8 animate-spin rounded-full border-b-2 border-[#3B82F6]"}),jsxs("p",{className:C("text-sm",i?"text-[#9CA3AF]":"text-gray-600"),children:[d.labels.noEvents,"..."]})]})}):s?jsx("div",{className:C("flex-1 flex items-center justify-center",i?"bg-[#0F1117]":"bg-white",l),style:c,children:jsxs("div",{className:"flex flex-col items-center gap-4 max-w-md text-center",children:[jsx("div",{className:"w-12 h-12 rounded-full bg-red-500/10 flex items-center justify-center",children:jsx("span",{className:"text-red-500 text-2xl",children:"\u26A0"})}),jsxs("div",{children:[jsx("h3",{className:C("text-lg font-semibold mb-2",i?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:C("text-sm",i?"text-[#9CA3AF]":"text-gray-600"),children:typeof s=="string"?s:s.message})]})]})}):e.length===0?jsx("div",{className:C("flex-1 flex items-center justify-center",i?"bg-[#0F1117]":"bg-white",l),style:c,children:jsxs("div",{className:"text-center max-w-md",children:[jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-2xl bg-[#3B82F6]/10 flex items-center justify-center",children:jsx(Calendar,{className:"w-8 h-8 text-[#3B82F6]"})}),jsx("h3",{className:C("text-lg font-semibold mb-2",i?"text-white":"text-gray-900"),children:d.labels.noEvents}),jsx("p",{className:C("text-sm",i?"text-[#9CA3AF]":"text-gray-600"),children:d.labels.newTask})]})}):jsxs("div",{className:C("flex-1 flex flex-col w-full h-full overflow-auto",i?"bg-[#0F1117]":"bg-white",l),style:c,children:[jsx("div",{className:C("flex-shrink-0 px-6 py-4 border-b",i?"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:C("text-xl font-semibold capitalize",i?"text-white":"text-gray-900"),children:Ce}),jsx("button",{onClick:O,className:C("px-3 py-1.5 text-sm rounded-lg transition-colors",i?"bg-white/5 text-white hover:bg-white/10":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:d.navigation.today})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("button",{onClick:Dt,className:C("p-2 rounded-lg transition-colors",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:C("w-5 h-5",i?"text-[#9CA3AF]":"text-gray-600")})}),jsx("button",{onClick:dt,className:C("p-2 rounded-lg transition-colors",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:C("w-5 h-5",i?"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:de.map(I=>jsx("div",{className:C("py-2 text-center text-xs font-medium uppercase",i?"text-[#9CA3AF]":"text-gray-500"),children:I},I))}),jsx("div",{className:C("grid grid-cols-7 auto-rows-min gap-px rounded-lg",i?"bg-[#2D2D2D]":"bg-gray-300"),children:re.map((I,Y)=>{let He=I.date.getDay()===0||I.date.getDay()===6;return jsxs("div",{className:C("min-h-[120px] p-2 transition-colors flex flex-col relative group",i?He?"bg-[#1C1F26]":I.isCurrentMonth?"bg-[#13161B]":"bg-[#0D0F13]":He?"bg-gray-100":I.isCurrentMonth?"bg-white":"bg-gray-50",I.isToday&&"ring-2 ring-[#3B82F6] ring-inset"),children:[(()=>{let We=A[Y]||B,yt=I.events.slice(0,We),Q=I.events.length-We;return jsxs("div",{className:"space-y-1 flex-1",children:[yt.map(te=>jsx("div",{className:"relative group",children:jsxs(motion.button,{onClick:()=>{g(te.task),a.onEventClick?.(te);},whileHover:{scale:1.02},className:C("w-full flex items-center gap-1 px-1.5 py-0.5 rounded text-xs truncate",te.task.progress===100?i?"bg-green-500/20 text-green-400":"bg-green-500/10 text-green-600":i?"bg-[#3B82F6]/20 text-[#3B82F6]":"bg-[#3B82F6]/10 text-[#3B82F6]"),children:[jsx(ac,{task:te.task}),jsx("span",{className:"truncate",children:te.title})]})},te.id)),Q>0&&jsxs("button",{onClick:te=>{te.stopPropagation(),v(ve=>({...ve,[Y]:We+T}));},className:C("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",i?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:["+",Q," ",n==="es"?"M\xC1S":"MORE"]}),We>B&&I.events.length>B&&jsx("button",{onClick:te=>{te.stopPropagation(),v(ve=>({...ve,[Y]:B}));},className:C("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",i?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:n==="es"?"MENOS":"LESS"})]})})(),jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1",children:[(()=>{let We=Y>=28,yt=Y%7>=5;return jsxs("div",{className:"relative",children:[jsx("button",{onClick:Q=>{Q.stopPropagation(),xe===Y?Ae(null):(Ae(Y),$(""),W(void 0),K(null),be(null),U(false),ke(false),Pe(false),ht(I.date));},className:C("w-5 h-5 rounded flex items-center justify-center transition-all",xe===Y?"opacity-100 bg-[#7C3AED] text-white":"opacity-0 group-hover:opacity-100",i?"hover:bg-[#7C3AED] text-[#6B7280] hover:text-white":"hover:bg-[#7C3AED] text-gray-400 hover:text-white"),children:jsx(Plus,{className:C("w-3.5 h-3.5 transition-transform",xe===Y&&"rotate-45")})}),jsx(AnimatePresence,{children:xe===Y&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{Ae(null),$(""),W(void 0),K(null),be(null),U(false),ke(false),Pe(false);}}),jsxs(motion.div,{initial:{opacity:0,y:We?-5:5,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:We?-5:5,scale:.95},transition:{duration:.12},className:C("absolute w-[320px] rounded-lg shadow-2xl z-50",We?"bottom-full mb-1":"top-full mt-1",yt?"right-0":"left-0",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:Q=>{Q.stopPropagation(),U(false),ke(false),Pe(false);},children:[jsx("div",{className:"p-2.5",children:jsx("input",{type:"text",value:Be,onChange:Q=>$(Q.target.value),placeholder:n==="es"?'Escribe el nombre de la tarea o "/" para los comandos':'Type task name or "/" for commands',className:C("w-full bg-transparent text-sm outline-none placeholder:opacity-40",i?"text-white":"text-gray-900"),autoFocus:true,onKeyDown:Q=>{if(Q.key==="Enter"&&Be.trim()){let te=t.availableUsers?.find(Te=>Te.id===E),ve=$e||I.date;a.onTaskCreate?.({name:Be.trim(),startDate:ve,endDate:ve,priority:F,assignees:te?[te]:void 0}),$(""),W(void 0),K(null),be(null),Ae(null);}Q.key==="Escape"&&(Ae(null),$(""),W(void 0),K(null),be(null));}})}),jsxs("div",{className:C("px-2.5 py-2 flex items-center justify-between border-t",i?"border-white/10":"border-gray-100"),children:[jsxs("div",{className:"flex items-center gap-1",children:[jsxs("div",{className:"relative",children:[jsx("button",{onClick:Q=>{Q.stopPropagation(),U(!X$1),ke(false);},className:C("p-1 rounded transition-colors",F?F==="urgent"||F==="high"?"text-red-400 bg-red-500/20":F==="medium"?"text-yellow-400 bg-yellow-500/20":"text-green-400 bg-green-500/20":i?"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:X$1&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[120px]",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:Q=>Q.stopPropagation(),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(Q=>jsxs("button",{onClick:()=>{W(Q.id),U(false);},className:C("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",F===Q.id&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:C("w-2 h-2 rounded-full",Q.color)}),jsx("span",{className:i?"text-white":"text-gray-900",children:Q.label})]},Q.id||"none"))})})]}),jsxs("div",{className:"relative",children:[jsxs("button",{onClick:Q=>{Q.stopPropagation(),Pe(!tt),U(false),ke(false),ht($e||I.date);},className:C("flex items-center gap-1 text-xs px-1.5 py-0.5 rounded transition-colors",$e?"bg-[#7C3AED]/20 text-[#7C3AED]":i?"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"}),($e||I.date).toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})]}),jsx(AnimatePresence,{children:tt&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-0 bottom-full mb-1 z-[60] rounded-xl shadow-2xl overflow-hidden flex",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:Q=>Q.stopPropagation(),children:[jsx("div",{className:C("w-40 py-2 border-r",i?"border-white/10":"border-gray-200"),children:(()=>{let Q=new Date,te=new Date(Q);te.setDate(Q.getDate()+1);let ve=new Date(Q);ve.setDate(Q.getDate()+((6-Q.getDay()+7)%7||7));let Te=new Date(Q);Te.setDate(Q.getDate()+((1-Q.getDay()+7)%7||7));let oe=new Date(Q);oe.setDate(Q.getDate()+14);let Se=new Date(Q);return Se.setDate(Q.getDate()+28),[{label:n==="es"?"Hoy":"Today",date:Q,display:Q.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Ma\xF1ana":"Tomorrow",date:te,display:te.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Este fin de semana":"This weekend",date:ve,display:n==="es"?"s\xE1b.":"sat."},{label:n==="es"?"Pr\xF3xima semana":"Next week",date:Te,display:n==="es"?"lun.":"mon."},{label:n==="es"?"2 semanas":"2 weeks",date:oe,display:oe.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:Se,display:Se.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Ne,ie)=>jsxs("button",{className:C("w-full flex items-center justify-between px-3 py-1.5 text-xs transition-colors",i?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{be(Ne.date),Pe(false);},children:[jsx("span",{children:Ne.label}),jsx("span",{className:C("text-[10px]",i?"text-[#6B7280]":"text-gray-400"),children:Ne.display})]},ie))})()}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("span",{className:C("text-xs font-medium",i?"text-white":"text-gray-900"),children:et.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-0.5",children:[jsx("button",{onClick:()=>ht(new Date),className:C("px-1.5 py-0.5 rounded text-[10px] transition-colors",i?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>ht(new Date(et.getFullYear(),et.getMonth()-1)),className:C("p-0.5 rounded",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:()=>ht(new Date(et.getFullYear(),et.getMonth()+1)),className:C("p-0.5 rounded",i?"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:(n==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(Q=>jsx("div",{className:C("w-6 h-6 flex items-center justify-center text-[10px]",i?"text-[#6B7280]":"text-gray-400"),children:Q},Q))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let Q=et.getFullYear(),te=et.getMonth(),ve=new Date(Q,te,1).getDay(),Te=new Date(Q,te+1,0).getDate(),oe=new Date(Q,te,0).getDate(),Se=new Date,ye=[];for(let ie=ve-1;ie>=0;ie--)ye.push({dayNum:oe-ie,isCurrentMonth:false,date:new Date(Q,te-1,oe-ie)});for(let ie=1;ie<=Te;ie++)ye.push({dayNum:ie,isCurrentMonth:true,date:new Date(Q,te,ie)});let Ne=42-ye.length;for(let ie=1;ie<=Ne;ie++)ye.push({dayNum:ie,isCurrentMonth:false,date:new Date(Q,te+1,ie)});return ye.map((ie,Fe)=>{let Me=ie.date.toDateString()===Se.toDateString(),Re=($e||I.date).toDateString()===ie.date.toDateString();return jsx("button",{className:C("w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",!ie.isCurrentMonth&&(i?"text-[#4B5563]":"text-gray-300"),ie.isCurrentMonth&&(i?"text-white":"text-gray-900"),Me&&"ring-1 ring-[#3B82F6]",Re&&"bg-[#7C3AED] text-white",!Re&&(i?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{be(ie.date),Pe(false);},children:ie.dayNum},Fe)})})()})]})]})})]}),jsxs("div",{className:"relative",children:[jsx("button",{onClick:Q=>{Q.stopPropagation(),ke(!De),U(false);},className:C("p-1 rounded transition-colors",E?"text-[#7C3AED] bg-[#7C3AED]/20":i?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:E?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(Q=>Q.id===E)?.color||"#7C3AED"},children:t.availableUsers?.find(Q=>Q.id===E)?.initials||t.availableUsers?.find(Q=>Q.id===E)?.name?.slice(0,2).toUpperCase()}):jsx(User,{className:"w-3.5 h-3.5"})}),jsx(AnimatePresence,{children:De&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[160px] max-h-[200px] overflow-y-auto",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:Q=>Q.stopPropagation(),children:[jsxs("button",{onClick:()=>{K(null),ke(false);},className:C("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",!E&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:C("w-5 h-5 rounded-full flex items-center justify-center",i?"bg-white/10":"bg-gray-200"),children:jsx(User,{className:"w-3 h-3 text-gray-400"})}),jsx("span",{className:i?"text-[#9CA3AF]":"text-gray-500",children:n==="es"?"Sin asignar":"Unassigned"})]}),t.availableUsers?.map(Q=>jsxs("button",{onClick:()=>{K(Q.id),ke(false);},className:C("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",E===Q.id&&(i?"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:Q.color||"#7C3AED"},children:Q.initials||Q.name?.slice(0,2).toUpperCase()}),jsx("span",{className:i?"text-white":"text-gray-900",children:Q.name})]},Q.id)),(!t.availableUsers||t.availableUsers.length===0)&&jsx("div",{className:C("px-3 py-2 text-xs",i?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"No hay usuarios disponibles":"No users available"})]})})]})]}),jsx("button",{onClick:()=>{if(Be.trim()){let Q=t.availableUsers?.find(ve=>ve.id===E),te=$e||I.date;a.onTaskCreate?.({name:Be.trim(),startDate:te,endDate:te,priority:F,assignees:Q?[Q]:void 0}),$(""),W(void 0),K(null),be(null),Ae(null);}},disabled:!Be.trim(),className:C("px-2.5 py-1 rounded text-xs font-medium transition-colors",Be.trim()?"bg-[#7C3AED] hover:bg-[#6D28D9] text-white":i?"bg-white/5 text-[#4B5563]":"bg-gray-100 text-gray-400"),children:n==="es"?"Guardar":"Save"})]})]})]})})]})})(),jsx("span",{className:C("text-sm font-medium",I.isToday?"text-[#3B82F6]":I.isCurrentMonth?i?"text-white":"text-gray-900":i?"text-[#6B7280]":"text-gray-400"),children:I.date.getDate()})]})]},Y)})})]})}),jsx(AnimatePresence,{children:f&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>g(null),className:"fixed inset-0 bg-black/50 z-40"}),jsxs(motion.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},className:C("fixed inset-4 md:inset-8 lg:inset-12 rounded-xl shadow-2xl z-50 flex overflow-hidden",i?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[jsxs("div",{className:C("px-6 py-3 border-b flex items-center gap-3",i?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:C("w-4 h-4",i?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:C("text-xs px-2 py-0.5 rounded",i?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[n==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:C("text-xs font-mono",i?"text-[#6B7280]":"text-gray-400"),children:f.id.slice(0,8)}),jsxs("button",{className:C("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-colors",i?"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:C("p-1.5 rounded transition-colors",i?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Maximize2,{className:"w-4 h-4"})}),jsx("button",{className:C("p-1.5 rounded transition-colors",i?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(MoreHorizontal,{className:"w-5 h-5"})}),jsx("button",{onClick:()=>g(null),className:C("p-1.5 rounded transition-colors",i?"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 I=f.progress===100?0:100,He={...f,progress:I,status:I===100?"completed":"todo"};g(He),a.onTaskUpdate?.(He);},className:C("mt-1 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors",f.progress===100?"bg-green-500 border-green-500":i?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:f.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("h2",{className:C("text-xl font-semibold flex-1",f.progress===100?"line-through text-[#6B7280]":i?"text-white":"text-gray-900"),children:f.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:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{Ie(),R(!w);},className:C("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",f.progress===100||f.status==="completed"?"bg-green-500/20 text-green-400":f.progress&&f.progress>0||f.status==="in-progress"?"bg-blue-500/20 text-blue-400":i?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:f.progress===100||f.status==="completed"?n==="es"?"COMPLETADO":"DONE":f.progress&&f.progress>0||f.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:()=>R(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"todo",label:n==="es"?"Por hacer":"To Do",color:"bg-white/10 text-white"},{id:"in-progress",label:n==="es"?"En progreso":"In Progress",color:"bg-blue-500/20 text-blue-400"},{id:"completed",label:n==="es"?"Completado":"Done",color:"bg-green-500/20 text-green-400"}].map(I=>jsxs("button",{onClick:()=>at(I.id),className:C("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",(f.status===I.id||I.id==="completed"&&f.progress===100||I.id==="in-progress"&&f.progress&&f.progress>0&&f.progress<100||I.id==="todo"&&(!f.progress||f.progress===0)&&f.status!=="in-progress"&&f.status!=="completed")&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:C("w-2 h-2 rounded-full",I.id==="completed"?"bg-green-500":I.id==="in-progress"?"bg-blue-500":"bg-gray-400")}),jsx("span",{className:i?"text-white":"text-gray-900",children:I.label})]},I.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(User,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Asignados":"Assignees"}),f.assignees&&f.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[f.assignees.slice(0,3).map((I,Y)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:I.color||"#8B5CF6"},title:I.name,children:I.initials||I.name.slice(0,2).toUpperCase()},Y)),f.assignees.length>3&&jsxs("span",{className:C("text-xs",i?"text-[#6B7280]":"text-gray-400"),children:["+",f.assignees.length-3]})]}):jsx("span",{className:C("text-sm",i?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Sin asignar":"Unassigned"})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CalendarDays,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{y(b?null:"start"),N(f.startDate||new Date);},className:C("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",i?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[f.startDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Inicio":"Start"),jsx("span",{className:C("mx-1",i?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),f.endDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Fin":"End"),(f.startDate||f.endDate)&&jsx(X,{className:"w-3.5 h-3.5 ml-1 opacity-50 hover:opacity-100",onClick:I=>{I.stopPropagation();}})]}),jsx(AnimatePresence,{children:b&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>y(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:C("absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:I=>I.stopPropagation(),children:[jsxs("div",{className:C("w-44 py-2 border-r",i?"border-white/10":"border-gray-200"),children:[(()=>{let I=new Date,Y=new Date(I);Y.setDate(I.getDate()+1);let He=new Date(I);He.setDate(I.getDate()+((6-I.getDay()+7)%7||7));let We=new Date(I);We.setDate(I.getDate()+((1-I.getDay()+7)%7||7));let yt=new Date(I);yt.setDate(I.getDate()+(6-I.getDay()+7)%7+7);let Q=new Date(I);Q.setDate(I.getDate()+14);let te=new Date(I);return te.setDate(I.getDate()+28),[{label:n==="es"?"Hoy":"Today",date:I,display:I.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Ma\xF1ana":"Tomorrow",date:Y,display:Y.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Este fin de semana":"This weekend",date:He,display:n==="es"?"s\xE1b.":"sat."},{label:n==="es"?"Pr\xF3xima semana":"Next week",date:We,display:n==="es"?"lun.":"mon."},{label:n==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:yt,display:yt.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"2 semanas":"2 weeks",date:Q,display:Q.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:te,display:te.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Te,oe)=>jsxs("button",{className:C("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",i?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if(b==="start"){let Se=f.endDate&&Te.date>f.endDate?Te.date:f.endDate;ut(Te.date,Se),y("end");}else {let Se=f.startDate&&Te.date<f.startDate?Te.date:f.startDate;ut(Se,Te.date),y(null);}},children:[jsx("span",{children:Te.label}),jsx("span",{className:C("text-xs",i?"text-[#6B7280]":"text-gray-400"),children:Te.display})]},oe))})(),jsx("div",{className:C("border-t mt-2 pt-2",i?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{ut(void 0,void 0),y(null);},className:C("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",i?"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:C("text-xs mb-3 px-2 py-1 rounded",i?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:b==="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:C("font-medium",i?"text-white":"text-gray-900"),children:D.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>N(new Date),className:C("p-1 rounded text-sm transition-colors",i?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>N(new Date(D.getFullYear(),D.getMonth()-1)),className:C("p-1 rounded",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-4 h-4"})}),jsx("button",{onClick:()=>N(new Date(D.getFullYear(),D.getMonth()+1)),className:C("p-1 rounded",i?"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:(n==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(I=>jsx("div",{className:C("w-8 h-8 flex items-center justify-center text-xs",i?"text-[#6B7280]":"text-gray-400"),children:I},I))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let I=D.getFullYear(),Y=D.getMonth(),He=new Date(I,Y,1).getDay(),We=new Date(I,Y+1,0).getDate(),yt=new Date(I,Y,0).getDate(),Q=new Date,te=[];for(let Te=He-1;Te>=0;Te--)te.push({day:yt-Te,isCurrentMonth:false,date:new Date(I,Y-1,yt-Te)});for(let Te=1;Te<=We;Te++)te.push({day:Te,isCurrentMonth:true,date:new Date(I,Y,Te)});let ve=42-te.length;for(let Te=1;Te<=ve;Te++)te.push({day:Te,isCurrentMonth:false,date:new Date(I,Y+1,Te)});return te.map((Te,oe)=>{let Se=Te.date.toDateString()===Q.toDateString(),ye=f.startDate?.toDateString()===Te.date.toDateString(),Ne=f.endDate?.toDateString()===Te.date.toDateString(),ie=ye||Ne,Fe=f.startDate&&f.endDate&&Te.date>=f.startDate&&Te.date<=f.endDate;return jsx("button",{className:C("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!Te.isCurrentMonth&&(i?"text-[#4B5563]":"text-gray-300"),Te.isCurrentMonth&&(i?"text-white":"text-gray-900"),Se&&"ring-2 ring-[#3B82F6]",ye&&"bg-[#3B82F6] text-white",Ne&&!ye&&"bg-[#7C3AED] text-white",Fe&&!ie&&(i?"bg-[#7C3AED]/20":"bg-purple-100"),!ie&&(i?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{let Me=new Date(Te.date);if(b==="start"){let Re=f.endDate&&Me>f.endDate?Me:f.endDate;ut(Me,Re),y("end");}else {let Re=f.startDate&&Me<f.startDate?Me:f.startDate;ut(Re,Me),y(null);}},children:Te.day},oe)})})()})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{Ie(),H(!P);},className:C("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",f.priority==="high"||f.priority==="urgent"?"bg-red-500/20 text-red-400":f.priority==="medium"?"bg-yellow-500/20 text-yellow-400":f.priority==="low"?"bg-green-500/20 text-green-400":i?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:f.priority?f.priority==="high"||f.priority==="urgent"?n==="es"?"Urgente":"Urgent":f.priority==="medium"?n==="es"?"Media":"Medium":n==="es"?"Baja":"Low":n==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:P&&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:C("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",i?"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(I=>jsxs("button",{onClick:()=>{Ee("priority",I.id),H(false);},className:C("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",f.priority===I.id&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:C("w-2 h-2 rounded-full",I.color)}),jsx("span",{className:i?"text-white":"text-gray-900",children:I.label})]},I.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:C("text-sm",i?"text-white":"text-gray-900"),children:f.startDate&&f.endDate?`${Math.ceil((f.endDate.getTime()-f.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:C("w-4 h-4 rounded-full border-2",i?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="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:f.progress||0,onChange:I=>{let Y=parseInt(I.target.value),He=f.status;Y===100?He="completed":Y>0?He="in-progress":He="todo";let We={...f,progress:Y,status:He};g(We),a.onTaskUpdate?.(We);},onBlur:()=>he(false),className:C("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",i?"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:()=>he(true),className:C("flex-1 h-2 rounded-full overflow-hidden max-w-[120px] cursor-pointer hover:ring-2 hover:ring-white/20 transition-all",i?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:C("h-full rounded-full transition-all",f.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${f.progress||0}%`}})}),jsxs("span",{className:C("text-sm font-medium min-w-[40px]",i?"text-white":"text-gray-900"),children:[f.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Etiquetas":"Tags"}),jsx("span",{className:C("text-sm",i?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Vac\xEDo":"Empty"})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Link2,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Relaciones":"Relations"}),jsx("span",{className:C("text-sm",i?"text-[#6B7280]":"text-gray-400"),children:f.dependencies&&f.dependencies.length>0?`${f.dependencies.length} ${n==="es"?"dependencias":"dependencies"}`:n==="es"?"Vac\xEDo":"Empty"})]})]}),jsxs("div",{className:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsxs("button",{className:C("flex items-center gap-2 text-sm transition-colors",i?"text-[#9CA3AF] hover:text-white":"text-gray-500 hover:text-gray-900"),children:[jsx(FileText,{className:"w-4 h-4"}),n==="es"?"Agregar descripci\xF3n":"Add description"]}),jsxs("button",{className:C("flex items-center gap-2 text-sm mt-2 transition-colors",i?"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:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:C("text-sm font-semibold mb-3",i?"text-white":"text-gray-900"),children:n==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",i?"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:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:C("text-sm font-semibold mb-3",i?"text-white":"text-gray-900"),children:n==="es"?"Agregar subtarea":"Add subtask"}),f.subtasks&&f.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:f.subtasks.map(I=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:C("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",I.progress===100?"bg-green-500 border-green-500":i?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:I.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:C("text-sm",I.progress===100?"line-through text-[#6B7280]":i?"text-white":"text-gray-900"),children:I.name})]},I.id))}),jsxs("button",{className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",i?"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"?"Add Tarea":"Add Task"]})]}),jsxs("div",{className:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("h3",{className:C("text-sm font-semibold",i?"text-white":"text-gray-900"),children:n==="es"?"Listas de control":"Checklists"}),jsx("button",{className:C("p-1 rounded transition-colors",i?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:jsx(Plus,{className:"w-4 h-4"})})]}),jsxs("button",{className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",i?"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:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:C("text-sm font-semibold mb-3",i?"text-white":"text-gray-900"),children:n==="es"?"Adjuntos":"Attachments"}),jsxs("div",{className:C("border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer",i?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300"),children:[jsx(Upload,{className:C("w-6 h-6 mx-auto mb-2",i?"text-[#6B7280]":"text-gray-400")}),jsxs("p",{className:C("text-sm",i?"text-[#9CA3AF]":"text-gray-500"),children:[n==="es"?"Suelta tus archivos aqu\xED para ":"Drop your files here to ",jsx("span",{className:C("underline",i?"text-white":"text-gray-700"),children:n==="es"?"subir":"upload"})]})]})]})]})]}),jsxs("div",{className:C("w-[280px] border-l flex flex-col",i?"border-white/10 bg-[#141619]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:C("px-4 py-3 border-b flex items-center justify-between",i?"border-white/10":"border-gray-200"),children:jsx("span",{className:C("font-medium",i?"text-white":"text-gray-900"),children:n==="es"?"Actividad":"Activity"})}),jsx("div",{className:"flex-1 p-4 overflow-y-auto",children:jsxs("div",{className:C("text-sm text-center py-8",i?"text-[#6B7280]":"text-gray-400"),children:[jsx(MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),n==="es"?"Sin actividad reciente":"No recent activity"]})}),jsx("div",{className:C("p-3 border-t",i?"border-white/10":"border-gray-200"),children:jsx("div",{className:C("flex items-center gap-2 px-3 py-2 rounded-lg",i?"bg-white/5":"bg-white border border-gray-200"),children:jsx("input",{type:"text",placeholder:n==="es"?"Escribe un comentario...":"Write a comment...",className:C("flex-1 bg-transparent text-sm outline-none",i?"text-white placeholder-[#6B7280]":"text-gray-900 placeholder-gray-400")})})})]})]})]})}),jsx(AnimatePresence,{children:k&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>h(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:C("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",i?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:C("px-4 py-3 border-b flex items-center justify-between",i?"border-white/10":"border-gray-200"),children:[jsx("span",{className:C("font-medium",i?"text-white":"text-gray-900"),children:k.date.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"long",month:"long",day:"numeric"})}),jsx("button",{onClick:()=>h(null),className:C("p-1 rounded",i?"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:k.events.map(I=>jsxs("button",{onClick:()=>{h(null),g(I.task);},className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-left transition-colors",i?"hover:bg-white/5":"hover:bg-gray-50"),children:[jsx(ac,{task:I.task}),jsx("span",{className:C("text-sm truncate flex-1",i?"text-white":"text-gray-900"),children:I.title}),I.task.priority==="high"||I.task.priority==="urgent"?jsx(Flag,{className:"w-3.5 h-3.5 text-red-400"}):null]},I.id))})]})]})})]})}var ii={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"},li={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"},di={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"},wn={dark:ii,light:li,neutral:di};function nc(e){return wn[e]||wn.dark}function Zf({stack:e,cards:t,renderCard:a,onCardClick:r,onToggleExpand:o,onUnstack:s,onDeleteStack:l,className:c}){let[p,n]=useState(false),m=useMemo(()=>t.filter(u=>e.cardIds.includes(u.id)),[t,e.cardIds]),d=useMemo(()=>{let u=m.length,x=new Set(m.flatMap(k=>k.assignedUserIds||[])).size,f=m.map(k=>k.priority).filter(Boolean),g=new Set(m.flatMap(k=>k.labels||[])).size;return {totalCards:u,uniqueAssignees:x,priorities:f,labels:g}},[m]),i=()=>{o?.(e.id);};return jsxs("div",{className:C("card-stack",!e.isExpanded&&"card-stack-collapsed",c),onMouseEnter:()=>n(true),onMouseLeave:()=>n(false),style:{"--stack-color":e.color||"var(--color-accent-primary)"},children:[jsxs("div",{className:"card-stack-header",onClick:i,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:C("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:u=>{u.stopPropagation(),l?.(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:m.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:m.map(u=>jsxs("div",{className:"card-stack-card-wrapper",children:[a?jsx("div",{onClick:()=>r?.(u),children:a(u)}):jsxs("div",{className:"card-stack-default-card",onClick:()=>r?.(u),children:[jsx("h4",{children:u.title}),u.description&&jsxs("p",{children:[u.description.substring(0,100),"..."]})]}),jsx("button",{className:"card-stack-unstack-btn",onClick:x=>{x.stopPropagation(),s?.(e.id,u.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"})]})})]},u.id))})})]})}var ic={showIcons:true,showAvatars:true,groupByDay:true,useRelativeTime:true,compact:false};function ko(e){switch(e.type){case "created":return "Created card";case "status_changed":return `Changed status from "${e.changes.status?.from}" to "${e.changes.status?.to}"`;case "assignee_changed":return "Changed assignee";case "priority_changed":return `Changed priority from ${e.changes.priority?.from} to ${e.changes.priority?.to}`;case "moved":return `Moved from ${e.metadata?.fromColumn||"unknown"} to ${e.metadata?.toColumn||"unknown"}`;case "title_updated":return "Updated title";case "description_updated":return "Updated description";case "dates_changed":return "Changed dates";case "labels_changed":return "Updated labels";case "dependency_added":return "Added dependency";case "dependency_removed":return "Removed dependency";case "comment_added":return "Added comment";case "archived":return "Archived card";case "restored":return "Restored card";default:return "Updated card"}}function wo(e){return {created:"\u2728",status_changed:"\u{1F504}",assignee_changed:"\u{1F464}",priority_changed:"\u{1F3AF}",moved:"\u27A1\uFE0F",title_updated:"\u270F\uFE0F",description_updated:"\u{1F4DD}",dates_changed:"\u{1F4C5}",labels_changed:"\u{1F3F7}\uFE0F",dependency_added:"\u{1F517}",dependency_removed:"\u26D3\uFE0F\u200D\u{1F4A5}",comment_added:"\u{1F4AC}",archived:"\u{1F4E6}",restored:"\u267B\uFE0F"}[e]||"\u{1F4CC}"}function lc(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 dc({events:e,filter:t,onFilterChange:a,onClearFilter:r,onEventClick:o,selectedEventId:s,config:l,className:c}){let p=useMemo(()=>({...ic,...l}),[l]),[n,m]=useState(new Set),d=useRef(null),i=useMemo(()=>{if(!p.groupByDay)return [{date:null,events:e}];let h=new Map;return e.forEach(b=>{let y=b.timestamp.toISOString().split("T")[0],D=h.get(y);D?D.push(b):h.set(y,[b]);}),Array.from(h.entries()).sort((b,y)=>y[0].localeCompare(b[0])).map(([b,y])=>({date:new Date(b),events:y.sort((D,N)=>N.timestamp.getTime()-D.timestamp.getTime())}))},[e,p.groupByDay]),{uniqueUsers:u,uniqueTypes:x}=useMemo(()=>{let h=new Set,b=new Set;return e.forEach(y=>{h.add(y.userId),b.add(y.type);}),{uniqueUsers:Array.from(h),uniqueTypes:Array.from(b)}},[e]),f=h=>{m(b=>{let y=new Set(b);return y.has(h)?y.delete(h):y.add(h),y});},g=h=>{let y=new Date().getTime()-h.getTime(),D=Math.floor(y/6e4),N=Math.floor(y/36e5),A=Math.floor(y/864e5);return D<1?"just now":D<60?`${D}m ago`:N<24?`${N}h ago`:A<7?`${A}d ago`:h.toLocaleDateString()},k=useMemo(()=>{let h=0;return t.types&&t.types.length>0&&h++,t.users&&t.users.length>0&&h++,t.dateRange&&h++,t.searchTerm&&h++,h},[t]);return useEffect(()=>{if(s&&d.current){let h=d.current.querySelector(`[data-event-id="${s}"]`);h&&h.scrollIntoView({behavior:"smooth",block:"center"});}},[s]),e.length===0?jsxs("div",{className:C("history-timeline-empty",c),children:[jsx("div",{className:"history-timeline-empty-icon",children:"\u{1F4DC}"}),jsx("p",{className:"history-timeline-empty-text",children:"No history events yet"}),jsx("p",{className:"history-timeline-empty-subtext",children:"Changes to this card will appear here"})]}):jsxs("div",{className:C("history-timeline",p.compact&&"compact",c),children:[jsxs("div",{className:"history-timeline-filters",children:[jsxs("div",{className:"history-timeline-filter-group",children:[jsxs("select",{className:"history-timeline-filter-select",value:t.types?.[0]||"",onChange:h=>{let b=h.target.value;a({...t,types:b?[b]:void 0});},children:[jsx("option",{value:"",children:"All Events"}),x.map(h=>jsxs("option",{value:h,children:[wo(h)," ",h.replace("_"," ")]},h))]}),u.length>1&&jsxs("select",{className:"history-timeline-filter-select",value:t.users?.[0]||"",onChange:h=>{let b=h.target.value;a({...t,users:b?[b]:void 0});},children:[jsx("option",{value:"",children:"All Users"}),u.map(h=>jsx("option",{value:h,children:h},h))]}),jsx("input",{type:"text",className:"history-timeline-filter-search",placeholder:"Search history...",value:t.searchTerm||"",onChange:h=>a({...t,searchTerm:h.target.value})})]}),k>0&&jsxs("button",{className:"history-timeline-filter-clear",onClick:r,children:["Clear filters (",k,")"]})]}),jsx("div",{className:"history-timeline-container",ref:d,children:i.map(h=>jsxs("div",{className:"history-timeline-group",children:[p.groupByDay&&h.date&&jsxs("div",{className:"history-timeline-day-header",children:[jsx("span",{className:"history-timeline-day-date",children:h.date.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),jsxs("span",{className:"history-timeline-day-count",children:[h.events.length," events"]})]}),jsx("div",{className:"history-timeline-events",children:h.events.map((b,y)=>{let D=n.has(b.id),N=s===b.id,A=lc(b.type);return jsxs("div",{"data-event-id":b.id,className:C("history-timeline-event",D&&"expanded",N&&"selected"),onClick:()=>o?.(b),children:[jsxs("div",{className:"history-timeline-line",children:[jsx("div",{className:"history-timeline-dot",style:{backgroundColor:A},children:p.showIcons&&jsx("span",{className:"history-timeline-dot-icon",children:wo(b.type)})}),y<h.events.length-1&&jsx("div",{className:"history-timeline-connector",style:{borderColor:A}})]}),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&&b.userAvatar&&jsx("img",{src:b.userAvatar,alt:b.userName||b.userId,className:"history-timeline-event-avatar"}),jsxs("div",{className:"history-timeline-event-description",children:[jsx("span",{className:"history-timeline-event-user",children:b.userName||b.userId}),jsx("span",{className:"history-timeline-event-action",children:ko(b)})]})]}),jsx("div",{className:"history-timeline-event-time",children:p.useRelativeTime?g(b.timestamp):b.timestamp.toLocaleString()})]}),Object.keys(b.changes).length>0&&jsxs("button",{className:"history-timeline-event-toggle",onClick:v=>{v.stopPropagation(),f(b.id);},children:[D?"\u25BC":"\u25B6"," Show changes"]}),D&&jsxs("div",{className:"history-timeline-event-changes",children:[Object.entries(b.changes).map(([v,B])=>jsxs("div",{className:"history-timeline-event-change",children:[jsxs("span",{className:"history-timeline-event-change-key",children:[v,":"]}),jsxs("div",{className:"history-timeline-event-change-values",children:[jsx("span",{className:"history-timeline-event-change-from",children:JSON.stringify(B.from)}),jsx("span",{className:"history-timeline-event-change-arrow",children:"\u2192"}),jsx("span",{className:"history-timeline-event-change-to",children:JSON.stringify(B.to)})]})]},v)),b.metadata&&Object.keys(b.metadata).length>0&&jsxs("div",{className:"history-timeline-event-metadata",children:[jsx("div",{className:"history-timeline-event-metadata-title",children:"Additional Info:"}),Object.entries(b.metadata).map(([v,B])=>jsxs("div",{className:"history-timeline-event-metadata-item",children:[jsxs("span",{className:"history-timeline-event-metadata-key",children:[v,":"]}),jsx("span",{className:"history-timeline-event-metadata-value",children:JSON.stringify(B)})]},v))]})]})]})]},b.id)})})]},h.date?.toISOString()||"all"))})]})}function pc({replayState:e,events:t,onStartReplay:a,onStopReplay:r,onTogglePlayback:o,onPrevious:s,onNext:l,onGoToEvent:c,onSpeedChange:p,className:n}){let m=[.5,1,1.5,2,3],d=useMemo(()=>!e||t.length===0?null:t[e.currentIndex],[e,t]),i=useMemo(()=>!e||e.totalEvents===0?0:e.currentIndex/(e.totalEvents-1)*100,[e]);return t.length===0?jsxs("div",{className:C("history-replay-empty",n),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:C("history-replay",n),children:[jsxs("div",{className:"history-replay-current-event",children:[jsx("div",{className:"history-replay-event-icon",children:d&&wo(d.type)}),jsxs("div",{className:"history-replay-event-info",children:[jsx("div",{className:"history-replay-event-description",children:d&&ko(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:u=>c(parseInt(u.target.value))}),jsx("div",{className:"history-replay-progress-fill",style:{width:`${i}%`}}),jsx("div",{className:"history-replay-progress-markers",children:t.map((u,x)=>jsx("div",{className:C("history-replay-progress-marker",x===e.currentIndex&&"active"),style:{left:`${x/(e.totalEvents-1)*100}%`},onClick:()=>c(x),title:ko(u)},u.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:l,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:m.map(u=>jsxs("button",{className:C("history-replay-speed-btn",e.speed===u&&"active"),onClick:()=>p(u),children:[u,"x"]},u))})]}),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(u=>jsx("span",{className:"history-replay-card-preview-label-tag",children:u},u))})]})]})]})]}):jsxs("div",{className:C("history-replay-start",n),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 ci(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 pi(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 mc(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 uc(e){return ["blocks","blocked_by","depends_on","required_by","parent_of","child_of"].includes(e)}function oh(e,t,a,r,o,s=100){let l=e.map(p=>({...p,x:p.x??a/2+Math.random()*100-50,y:p.y??r/2+Math.random()*100-50,vx:0,vy:0})),c=new Map(l.map(p=>[p.id,p]));for(let p=0;p<s;p++){let n=1-p/s;l.forEach(m=>{let d=a/2,i=r/2;m.vx+=(d-m.x)*o.centerForce*n,m.vy+=(i-m.y)*o.centerForce*n,l.forEach(u=>{if(m.id===u.id)return;let x=m.x-u.x,f=m.y-u.y,g=Math.sqrt(x*x+f*f)||1,k=o.chargeStrength*n/(g*g);m.vx+=x/g*k,m.vy+=f/g*k;});}),t.forEach(m=>{let d=c.get(typeof m.source=="string"?m.source:m.source.id),i=c.get(typeof m.target=="string"?m.target:m.target.id);if(!d||!i)return;let u=i.x-d.x,x=i.y-d.y,f=Math.sqrt(u*u+x*x)||1,g=(f-o.linkDistance)/f*o.forceStrength*n;d.vx+=u*g,d.vy+=x*g,i.vx-=u*g,i.vy-=x*g;}),l.forEach(m=>{m.fx!==null&&m.fx!==void 0?(m.x=m.fx,m.vx=0):m.x+=m.vx,m.fy!==null&&m.fy!==void 0?(m.y=m.fy,m.vy=0):m.y+=m.vy,m.x=Math.max(o.nodeSize,Math.min(a-o.nodeSize,m.x)),m.y=Math.max(o.nodeSize,Math.min(r-o.nodeSize,m.y)),m.vx*=.9,m.vy*=.9;});}return l}function gc({nodes:e,edges:t,config:a,filter:r,onFilterChange:o,criticalPath:s,stats:l,onInteraction:c,className:p}){let n=useRef(null),[m,d]=useState([]),[i,u]=useState(null),[x,f]=useState(null),[g,k]=useState(null),[h,b]=useState(1),[y,D]=useState({x:0,y:0});useEffect(()=>{if(e.length===0)return;let P=oh(e,t,a.width,a.height,a,150);d(P);},[e,t,a]);let N=useCallback((P,H)=>{a.enableDragging&&(H.stopPropagation(),u(P));},[a.enableDragging]),A=useCallback(P=>{if(!i||!n.current)return;let q=n.current.getBoundingClientRect(),he=(P.clientX-q.left-y.x)/h,xe=(P.clientY-q.top-y.y)/h;d(Ae=>Ae.map(Be=>Be.id===i?{...Be,x:he,y:xe,fx:he,fy:xe}:Be));},[i,h,y]),v=useCallback(()=>{u(null);},[]),B=useCallback((P,H)=>{H.stopPropagation(),c?.({type:"node-click",node:P,position:{x:H.clientX,y:H.clientY}});},[c]),T=useCallback((P,H)=>{H.stopPropagation(),c?.({type:"edge-click",edge:P,position:{x:H.clientX,y:H.clientY}});},[c]),w=useCallback(P=>{let H=m.find(q=>q.id===P);return H?{x:H.x,y:H.y}:{x:0,y:0}},[m]),R=useCallback(P=>{if(P.onCriticalPath)return "#ef4444";switch(a.colorScheme){case "status":return P.card.columnId==="done"?"#10b981":"#3b82f6";case "priority":let H=P.card.priority;return H==="URGENT"?"#ef4444":H==="HIGH"?"#f59e0b":H==="MEDIUM"?"#3b82f6":"#6b7280";case "assignee":return P.card.assigneeId?"#8b5cf6":"#6b7280";default:return "#3b82f6"}},[a.colorScheme]);return e.length===0?jsxs("div",{className:C("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:C("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:l.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:l.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:()=>b(P=>Math.min(P+.2,3)),children:"+"}),jsxs("span",{className:"relationships-graph-zoom-value",children:[Math.round(h*100),"%"]}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>b(P=>Math.max(P-.2,.5)),children:"\u2212"}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>{b(1),D({x:0,y:0});},children:"Reset"})]})]}),jsx("div",{className:"relationships-graph-legend",children:Array.from(new Set(t.map(P=>P.type))).map(P=>jsxs("div",{className:"relationships-graph-legend-item",children:[jsx("div",{className:"relationships-graph-legend-color",style:{background:ci(P)}}),jsxs("span",{className:"relationships-graph-legend-label",children:[mc(P)," ",pi(P)]})]},P))}),jsxs("svg",{ref:n,className:"relationships-graph-canvas",width:a.width,height:a.height,onMouseMove:A,onMouseUp:v,onMouseLeave:v,children:[jsxs("g",{transform:`translate(${y.x}, ${y.y}) scale(${h})`,children:[jsx("g",{className:"relationships-graph-edges",children:t.map(P=>{let H=w(typeof P.source=="string"?P.source:P.source.id),q=w(typeof P.target=="string"?P.target:P.target.id),he=uc(P.type),xe=g===P.id,Ae=P.onCriticalPath;return jsxs("g",{className:C("relationships-graph-edge",xe&&"hovered",Ae&&"critical"),onMouseEnter:()=>k(P.id),onMouseLeave:()=>k(null),onClick:Be=>T(P,Be),children:[jsx("line",{x1:H.x,y1:H.y,x2:q.x,y2:q.y,stroke:ci(P.type),strokeWidth:Ae?a.edgeWidth*2:a.edgeWidth,strokeOpacity:xe?1:.6,markerEnd:he?"url(#arrowhead)":void 0}),a.showEdgeLabels&&xe&&jsx("text",{x:(H.x+q.x)/2,y:(H.y+q.y)/2,className:"relationships-graph-edge-label",textAnchor:"middle",children:pi(P.type)})]},P.id)})}),jsx("g",{className:"relationships-graph-nodes",children:m.map(P=>{let H=x===P.id,q=P.onCriticalPath;return jsxs("g",{className:C("relationships-graph-node",H&&"hovered",q&&"critical"),transform:`translate(${P.x}, ${P.y})`,onMouseDown:he=>N(P.id,he),onMouseEnter:()=>f(P.id),onMouseLeave:()=>f(null),onClick:he=>B(P,he),children:[jsx("circle",{r:q?a.nodeSize*1.2:a.nodeSize,fill:R(P),stroke:q?"#fbbf24":"#ffffff",strokeWidth:q?3:2,opacity:H?1:.9}),a.showLabels&&jsx("text",{y:a.nodeSize+20,className:"relationships-graph-node-label",textAnchor:"middle",children:P.card.title.length>20?P.card.title.substring(0,20)+"...":P.card.title})]},P.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 bc({isOpen:e,onClose:t,onPlanGenerated:a,onGeneratePlan:r,isLoading:o}){let[s,l]=useState(""),[c,p]=useState(false),[n,m]=useState(null),[d,i]=useState(null),u=useRef(null),x=c||o;useEffect(()=>{e&&u.current&&u.current.focus();},[e]),useEffect(()=>{let h=b=>{b.key==="Escape"&&!x&&f();};if(e)return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[e,x]);let f=()=>{x||(l(""),m(null),i(null),t());},g=async()=>{if(!(!s.trim()||x)){p(true),m(null),i(null);try{let h=await r(s.trim());i(h);}catch(h){m(h instanceof Error?h.message:"Failed to generate plan");}finally{p(false);}}},k=()=>{d&&(a(d),f());};return e?jsxs(rt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:f}),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:h=>h.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:f,disabled:x,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((h,b)=>jsx("div",{className:"px-3 py-1.5 rounded-lg bg-white/5 border border-white/20 text-sm text-white/80",children:h.title},b))})]}),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((h,b)=>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:h.title}),h.description&&jsx("p",{className:"text-xs text-white/60 mt-1 line-clamp-2",children:h.description})]}),h.priority&&jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${h.priority==="URGENT"?"bg-red-500/20 text-red-400":h.priority==="HIGH"?"bg-orange-500/20 text-orange-400":h.priority==="MEDIUM"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:h.priority})]})},b)),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:u,value:s,onChange:h=>l(h.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:x}),jsx("p",{className:"text-xs text-white/50 mt-2",children:"Be as specific as possible. Include features, technologies, and any special requirements."})]}),n&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:n}),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((h,b)=>jsx("button",{onClick:()=>l(h),disabled:x,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:h},b))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:x&&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:f,disabled:x,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:k,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all",style:{background:"linear-gradient(135deg, #10B981 0%, #059669 100%)",color:"#ffffff"},children:"Apply Plan to Board"}):jsx("button",{onClick:g,disabled:!s.trim()||x,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:x?"Generating...":"Generate Plan"})]})]})]})})]}):null}var mi={"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 sh={hobby:{requestsPerMonth:50,maxConcurrent:1,maxTokensPerRequest:4096},pro:{requestsPerMonth:500,maxConcurrent:3,maxTokensPerRequest:8192},enterprise:{requestsPerMonth:2e3,maxConcurrent:10,maxTokensPerRequest:16384}},ih={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 lh(e,t,a){let r=mi[e];if(!r)throw new Error(`Unknown model: ${e}`);let o=t/1e3*r.costPer1kInput,s=a/1e3*r.costPer1kOutput;return o+s}function Co(e){return `$${e.toFixed(4)}`}var ui=class{constructor(){this.operations=[];this.listeners=[];}record(t){let a=lh(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,i)=>d+i.cost,0),s=a.reduce((d,i)=>d+i.inputTokens,0),l=a.reduce((d,i)=>d+i.outputTokens,0),c=a.filter(d=>d.success),p=a.reduce((d,i)=>d+i.duration,0),n={},m={};return a.forEach(d=>{n[d.feature]=(n[d.feature]||0)+1,m[d.feature]=(m[d.feature]||0)+d.cost;}),{totalOperations:r,totalCost:o,totalInputTokens:s,totalOutputTokens:l,operationsByFeature:n,costsByFeature:m,averageDuration:r>0?p/r:0,successRate:r>0?c.length/r:0}}getRecentOperations(t=10){return this.operations.slice(-t).reverse()}checkLimit(t,a="month"){let o={hobby:{month:50,day:5},pro:{month:500,day:50},enterprise:{month:2e3,day:200}}[t][a],s=new Date,l=new Date;a==="month"?l.setMonth(s.getMonth()-1):l.setDate(s.getDate()-1);let c=this.operations.filter(m=>m.timestamp>=l).length,p=Math.max(0,o-c),n=c/o*100;return {used:c,limit:o,remaining:p,percentUsed:n,isExceeded:c>=o}}subscribe(t){return this.listeners.push(t),()=>{let a=this.listeners.indexOf(t);a>-1&&this.listeners.splice(a,1);}}clear(){this.operations=[];}export(){return JSON.stringify(this.operations,null,2)}},Sr=new ui;function xc({isOpen:e,onClose:t,planTier:a="hobby"}){let[r,o]=useState(Sr.getStats()),[s,l]=useState(Sr.checkLimit(a));if(useEffect(()=>{if(!e)return;let p=setInterval(()=>{o(Sr.getStats()),l(Sr.checkLimit(a));},1e3);return ()=>clearInterval(p)},[e,a]),useEffect(()=>{let p=n=>{n.key==="Escape"&&t();};if(e)return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[e,t]),!e)return null;let c=Sr.getRecentOperations(5);return jsxs(rt,{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:Co(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,n])=>{let m=r.costsByFeature[p]||0,d=r.totalOperations>0?n/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:[n," ops"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:Co(m)})]})]}),jsx("div",{className:"w-full h-1.5 bg-white/10 rounded-full overflow-hidden",children:jsx("div",{className:"h-full bg-blue-500",style:{width:`${d}%`}})})]},p)})})]}),jsxs("div",{children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-3",children:"Recent Operations"}),c.length===0?jsx("p",{className:"text-sm text-white/50 text-center py-8",children:"No operations yet. Start using AI features!"}):jsx("div",{className:"space-y-2",children:c.map(p=>jsxs("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsx("p",{className:"text-sm font-medium text-white/90 capitalize",children:p.feature.replace(/([A-Z])/g," $1").trim()}),jsxs("p",{className:"text-xs text-white/50 mt-0.5",children:[new Date(p.timestamp).toLocaleTimeString()," \u2022"," ",p.duration,"ms"]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-white/60",children:[p.inputTokens+p.outputTokens," tokens"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:Co(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 Cc({isOpen:e,onClose:t,onTasksGenerated:a,onGenerateTasks:r,isLoading:o,projectName:s}){let[l,c]=useState(""),[p,n]=useState(""),[m,d]=useState(""),[i,u]=useState(false),[x,f]=useState(null),[g,k]=useState(null),[h,b]=useState(null),y=useRef(null),D=i||o;useEffect(()=>{e&&y.current&&y.current.focus();},[e]),useEffect(()=>{let T=w=>{w.key==="Escape"&&!D&&N();};if(e)return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[e,D]);let N=()=>{D||(c(""),n(""),d(""),f(null),k(null),b(null),t());},A=async()=>{if(!(!l.trim()||D)){u(true),f(null),k(null),b(null);try{let T=await r({prompt:l.trim(),projectName:s||"Mi Proyecto",startDate:p||void 0,endDate:m||void 0});k(T.tasks.tasks),b({from_cache:T.from_cache,tokens_used:T.tokens_used,mock_mode:T.mock_mode,similarity:T.similarity,tokens_saved:T.tokens_saved});}catch(T){f(T instanceof Error?T.message:"Failed to generate tasks");}finally{u(false);}}},v=()=>{g&&(a(g),N());};if(!e)return null;let B=h?.similarity?((h.similarity||0)*100).toFixed(0):"0";return jsxs(rt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:N}),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:T=>T.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:N,disabled:D,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:g?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:[h?.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"}),h?.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 (",B,"% 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:[h?.tokens_used||0," tokens"]}),h?.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:[h.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:[g.length," tasks"]})]}),jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:g.map((T,w)=>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:["#",w+1]}),jsx("p",{className:"text-sm font-medium text-white/90",children:T.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"})]}),T.start," \u2192 ",T.end]}),jsxs("span",{children:[T.duration," days"]}),T.dependencies.length>0&&jsxs("span",{className:"text-blue-400",children:["Depends: ",T.dependencies.join(", ")]})]})]}),jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${T.priority==="high"?"bg-red-500/20 text-red-400":T.priority==="medium"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:T.priority})]})},T.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:y,value:l,onChange:T=>c(T.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:D}),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:T=>n(T.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:D})]}),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:m,onChange:T=>d(T.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:D})]})]}),x&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:x}),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((T,w)=>jsx("button",{onClick:()=>c(T),disabled:D,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:T},w))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:D&&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:N,disabled:D,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"}),g?jsx("button",{onClick:v,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:A,disabled:!l.trim()||D,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:D?"Generating...":"Generate Tasks"})]})]})]})})]})}function Dn({initialBoard:e,onPersist:t}){let[a,r]=useState(e),o=useCallback(g=>{t&&Ao(()=>Promise.resolve(t(g)),{maxAttempts:3,initialDelay:1e3,onRetry:(k,h,b)=>{console.warn(`Retry attempt ${h} after ${b}ms: ${k.message}`);}}).then(k=>{k.success||console.error(`Failed to persist board after ${k.attempts} attempts:`,k.error);});},[t]),s=useCallback(async(g,k,h)=>{r(b=>{let y=b.cards.find(T=>T.id===g);if(!y)return b;let D=y.columnId,N={...y,columnId:k,position:h},A=b.cards.map(T=>T.id===g?N:T),v=b.columns.map(T=>{if(T.id===D)return {...T,cardIds:T.cardIds.filter(w=>w!==g)};if(T.id===k){let w=A.filter(R=>R.columnId===k).sort((R,P)=>R.position-P.position);return {...T,cardIds:w.map(R=>R.id)}}return T}),B={...b,cards:A,columns:v};return o(B),B});},[o]),l=useCallback(async(g,k)=>{r(h=>{let b=h.cards.map(D=>D.id===g?{...D,...k}:D),y={...h,cards:b};return o(y),y});},[o]),c=useCallback(async g=>{let k=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(h=>{let b={...g,id:k},y=h.columns.map(N=>N.id===g.columnId?{...N,cardIds:[...N.cardIds,k]}:N),D={...h,cards:[...h.cards,b],columns:y};return o(D),D});},[o]),p=useCallback(async g=>{r(k=>{let h=k.cards.find(N=>N.id===g);if(!h)return k;let b=k.cards.filter(N=>N.id!==g),y=k.columns.map(N=>N.id===h.columnId?{...N,cardIds:N.cardIds.filter(A=>A!==g)}:N),D={...k,cards:b,columns:y};return o(D),D});},[o]),n=useCallback(async g=>{let k=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(h=>{let b={...g,id:k,cardIds:[]},y={...h,columns:[...h.columns,b]};return o(y),y});},[o]),m=useCallback(async(g,k)=>{r(h=>{let b=h.columns.map(D=>D.id===g?{...D,...k}:D),y={...h,columns:b};return o(y),y});},[o]),d=useCallback(async g=>{r(k=>{let h=k.cards.filter(D=>D.columnId!==g),b=k.columns.filter(D=>D.id!==g),y={...k,cards:h,columns:b};return o(y),y});},[o]),i=useCallback(g=>{let k=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return c(g),k},[c]),u=useCallback(g=>{let k=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return n(g),k},[n]),x=useCallback(()=>{r(g=>{let k={...g,cards:[],columns:[]};return o(k),k});},[o]);return {board:a,callbacks:{onCardMove:s,onCardUpdate:l,onCardCreate:c,onCardDelete:p,onColumnCreate:n,onColumnUpdate:m,onColumnDelete:d},setBoard:r,helpers:{addCard:i,addColumn:u,deleteCard:p,deleteColumn:d,clearBoard:x}}}function Dc({initialData:e,availableUsers:t=[],onSave:a}){let{board:r,callbacks:o,helpers:s}=Dn({initialBoard:e,onPersist:a}),l=useMemo(()=>({addCard:(p,n,m={})=>{s.addCard({title:n,columnId:p,position:r.cards.filter(d=>d.columnId===p).length,...m});},addColumn:(p,n)=>{let m=r.columns.length>0?Math.max(...r.columns.map(d=>d.position)):0;s.addColumn({title:p,position:n??m+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:l}}var To={dateFilter:"all",priorities:[],assignees:[],labels:[],columns:[],search:""},Sc={by:"none",order:"asc"};function Ec({initialFilters:e={},initialSort:t={},currentUserId:a}={}){let[r,o]=useState({...To,...e}),[s,l]=useState({...Sc,...t}),c=useCallback(f=>{o(g=>({...g,...f}));},[]),p=useCallback(f=>{l(g=>({...g,...f}));},[]),n=useCallback(()=>{o(To),l(Sc);},[]),m=useCallback(()=>{a&&o({...To,assignees:[a]});},[a]),d=useCallback(()=>{o({...To,dateFilter:"overdue"});},[]),i=useCallback(()=>{o({...To,priorities:["HIGH","URGENT"]});},[]),u=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]),x=useCallback(f=>{let g=[...f];if(r.search){let k=r.search.toLowerCase();g=g.filter(h=>h.title.toLowerCase().includes(k)||h.description?.toLowerCase().includes(k));}if(r.dateFilter!=="all"){let k=new Date,h=k.getFullYear(),b=String(k.getMonth()+1).padStart(2,"0"),y=String(k.getDate()).padStart(2,"0"),D=`${h}-${b}-${y}`;g=g.filter(N=>{if(!N.endDate&&!N.dueDate)return false;let A=N.endDate||N.dueDate;if(!A)return false;let v;if(typeof A=="string")v=A.split("T")[0]||A;else {let B=A.getUTCFullYear(),T=String(A.getUTCMonth()+1).padStart(2,"0"),w=String(A.getUTCDate()).padStart(2,"0");v=`${B}-${T}-${w}`;}switch(r.dateFilter){case "overdue":return v<D;case "today":return v===D;case "this-week":let B=new Date(D+"T00:00:00"),T=new Date(v+"T00:00:00"),w=new Date(B);return w.setDate(w.getDate()+7),T>=B&&T<=w;case "custom":if(r.dateRange){let R=typeof A=="string"?new Date(A):A;return R>=r.dateRange.start&&R<=r.dateRange.end}return true;default:return true}});}return r.priorities.length>0&&(g=g.filter(k=>k.priority&&r.priorities.includes(k.priority))),r.assignees.length>0&&(g=g.filter(k=>(k.assignedUserIds||(k.assigneeId?[k.assigneeId]:[])).some(b=>r.assignees.includes(b)))),r.labels.length>0&&(g=g.filter(k=>k.labels&&k.labels.some(h=>r.labels.includes(h)))),r.columns.length>0&&(g=g.filter(k=>r.columns.includes(k.columnId))),s.by!=="none"&&g.sort((k,h)=>{let b=0;switch(s.by){case "created":let y=k.createdAt?new Date(k.createdAt).getTime():0,D=h.createdAt?new Date(h.createdAt).getTime():0;b=y-D;break;case "priority":let N={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},A=N[k.priority||"LOW"],v=N[h.priority||"LOW"];b=A-v;break;case "dueDate":let B=k.endDate||k.dueDate,T=h.endDate||h.dueDate;if(!B)return 1;if(!T)return -1;let w=typeof B=="string"?new Date(B).getTime():B.getTime(),R=typeof T=="string"?new Date(T).getTime():T.getTime();b=w-R;break;case "title":b=k.title.localeCompare(h.title);break;case "estimate":let P=k.estimatedTime||0,H=h.estimatedTime||0;b=P-H;break;default:b=0;}return s.order==="asc"?b:-b}),g},[r,s]);return {filters:r,sort:s,setFilters:c,setSort:p,resetFilters:n,filterMyTasks:m,filterOverdue:d,filterHighPriority:i,applyFilters:x,hasActiveFilters:u}}var Mc,Ac;if(typeof window<"u")try{let e=Eo("ai");Mc=e.generateObject,Ac=e.generateText;}catch{}function Ic(e={}){let[t,a]=useState(false),[r,o]=useState(null),s=!!(Mc&&Ac&&e.apiKey),l=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(i){let u=i instanceof Error?i:new Error("Failed to generate plan");throw o(u),u}finally{a(false);}},[s]),c=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Suggesting assignee for:",d.title),{userId:"user-123",confidence:.85,reasoning:"Based on past performance and expertise"}}catch(i){let u=i instanceof Error?i:new Error("Failed to suggest assignee");throw o(u),u}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(i){let u=i instanceof Error?i:new Error("Failed to predict risks");throw o(u),u}finally{a(false);}},[s]),n=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(i){let u=i instanceof Error?i:new Error("Failed to generate subtasks");throw o(u),u}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("Estimating effort for:",d.title),{hours:8,confidence:.75}}catch(i){let u=i instanceof Error?i:new Error("Failed to estimate effort");throw o(u),u}finally{a(false);}},[s]);return {onGeneratePlan:l,onSuggestAssignee:c,onPredictRisks:p,onGenerateSubtasks:n,onEstimateEffort:m,isAvailable:s,isLoading:t,error:r}}function fi(){let[e,t]=useState(()=>selectionStore.getState());useEffect(()=>selectionStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{selectionStore.setState(r);},[]);return [e,a]}function Lc(e){let{cards:t}=e,[a,r]=fi(),o=useCallback(d=>a.selectedCardIds.includes(d),[a.selectedCardIds]),s=useCallback((d,i)=>{if(!i){r({selectedCardIds:[d],lastSelectedCardId:d});return}let u=i.ctrlKey||i.metaKey,x=i.shiftKey;if(u)a.selectedCardIds.includes(d)?r({selectedCardIds:a.selectedCardIds.filter(f=>f!==d),lastSelectedCardId:a.lastSelectedCardId}):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});else if(x&&a.lastSelectedCardId){let f=t.find(k=>k.id===d),g=t.find(k=>k.id===a.lastSelectedCardId);if(f&&g&&f.columnId===g.columnId){let k=t.filter(v=>v.columnId===f.columnId).sort((v,B)=>v.position-B.position),h=k.findIndex(v=>v.id===a.lastSelectedCardId),b=k.findIndex(v=>v.id===d),[y,D]=h<b?[h,b]:[b,h],N=k.slice(y,D+1).map(v=>v.id),A=Array.from(new Set([...a.selectedCardIds,...N]));r({selectedCardIds:A,lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});},[t,a,r]),l=useCallback(d=>{r({selectedCardIds:a.selectedCardIds.filter(i=>i!==d),lastSelectedCardId:a.lastSelectedCardId});},[a,r]),c=useCallback(()=>{r({selectedCardIds:[],lastSelectedCardId:null});},[r]),p=useCallback(()=>{r({selectedCardIds:t.map(d=>d.id),lastSelectedCardId:t[t.length-1]?.id||null});},[t,r]),n=useCallback(d=>{a.selectedCardIds.includes(d)?l(d):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});},[a,l,r]),m=useCallback(()=>t.filter(d=>a.selectedCardIds.includes(d.id)),[t,a.selectedCardIds]);return {selectedCardIds:a.selectedCardIds,lastSelectedCardId:a.lastSelectedCardId,isCardSelected:o,selectCard:s,deselectCard:l,clearSelection:c,selectAll:p,toggleCard:n,getSelectedCards:m}}var Fc={enableAutoStacking:true,autoStackConfidenceThreshold:.7,minCardsPerStack:2,enableManualStacking:true,showStackSummaries:true,animationDuration:200};function Bc(e){let{cards:t,config:a,aiService:r}=e,o=useMemo(()=>({...Fc,...a}),[a]),[s,l]=useState([]),c=useCallback((f,g,k,h,b)=>{if(g.length<o.minCardsPerStack){console.warn(`Cannot create stack: minimum ${o.minCardsPerStack} cards required`);return}let y={id:`stack-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:f,cardIds:g,columnId:k,strategy:h,color:b,isExpanded:true,position:s.filter(D=>D.columnId===k).length,createdAt:new Date};l(D=>[...D,y]);},[o.minCardsPerStack,s]),p=useCallback(f=>{l(g=>g.filter(k=>k.id!==f));},[]),n=useCallback(f=>{l(g=>g.map(k=>k.id===f?{...k,isExpanded:!k.isExpanded}:k));},[]),m=useCallback((f,g)=>{l(k=>k.map(h=>h.id===f&&!h.cardIds.includes(g)?{...h,cardIds:[...h.cardIds,g]}:h));},[]),d=useCallback((f,g)=>{l(k=>k.map(h=>{if(h.id===f){let b=h.cardIds.filter(y=>y!==g);return b.length<o.minCardsPerStack?null:{...h,cardIds:b}}return h}).filter(h=>h!==null));},[o.minCardsPerStack]),i=useCallback(f=>s.filter(g=>g.columnId===f).sort((g,k)=>g.position-k.position),[s]),u=useCallback(async f=>{let g=t.filter(D=>D.columnId===f);if(g.length<o.minCardsPerStack*2)return [];let k=[],h=new Map;g.forEach(D=>{D.labels&&D.labels.length>0&&D.labels.forEach(N=>{h.has(N)||h.set(N,[]),h.get(N).push(D);});}),h.forEach((D,N)=>{D.length>=o.minCardsPerStack&&k.push({stack:{title:`\u{1F4CC} ${N}`,cardIds:D.map(A=>A.id),columnId:f,strategy:"labels",color:"#3b82f6"},reason:`${D.length} cards with label "${N}"`,confidence:.85});});let b=new Map;g.forEach(D=>{D.assignedUserIds&&D.assignedUserIds.length>0&&D.assignedUserIds.forEach(N=>{b.has(N)||b.set(N,[]),b.get(N).push(D);});}),b.forEach((D,N)=>{D.length>=o.minCardsPerStack&&k.push({stack:{title:`\u{1F464} Assigned to user-${N.slice(-4)}`,cardIds:D.map(A=>A.id),columnId:f,strategy:"assignee",color:"#8b5cf6"},reason:`${D.length} cards assigned to the same user`,confidence:.8});});let y=new Map;if(g.forEach(D=>{D.priority&&(y.has(D.priority)||y.set(D.priority,[]),y.get(D.priority).push(D));}),y.forEach((D,N)=>{if(D.length>=o.minCardsPerStack){let A={low:"\u{1F7E2}",medium:"\u{1F7E1}",high:"\u{1F534}",urgent:"\u{1F6A8}"}[N.toLowerCase()]||"\u26AA";k.push({stack:{title:`${A} ${N} Priority`,cardIds:D.map(v=>v.id),columnId:f,strategy:"priority",color:N==="high"||N==="urgent"?"#ef4444":"#10b981"},reason:`${D.length} cards with ${N} priority`,confidence:.75});}}),r&&o.enableAutoStacking)for(let D of g){let A=(await r.findSimilar(D,g)).filter(v=>v.similarity>=o.autoStackConfidenceThreshold);if(A.length>=o.minCardsPerStack-1){let v=[D.id,...A.map(T=>T.card.id)],B=A.reduce((T,w)=>T+w.similarity,0)/A.length;k.push({stack:{title:`\u2728 Similar to "${D.title.substring(0,30)}${D.title.length>30?"...":""}"`,cardIds:v,columnId:f,strategy:"ai-similarity",color:"#f59e0b"},reason:`AI detected ${A.length+1} similar tasks`,confidence:B});}}return k.filter(D=>D.confidence>=o.autoStackConfidenceThreshold).sort((D,N)=>N.confidence-D.confidence).slice(0,5)},[t,o,r]),x=useCallback(f=>{c(f.stack.title,f.stack.cardIds,f.stack.columnId,f.stack.strategy,f.stack.color);},[c]);return useEffect(()=>{o.enableAutoStacking&&s.length===0&&new Set(t.map(g=>g.columnId)).forEach(async g=>{let k=await u(g),h=k[0];k.length>0&&h&&h.confidence>=.9&&x(h);});},[]),{stacks:s,createStack:c,deleteStack:p,toggleStack:n,addToStack:m,removeFromStack:d,getStacksForColumn:i,getSuggestions:u,applySuggestion:x,config:o}}var Rc=createContext(null);function Oc({children:e,initialData:t,onStateChange:a}){let r=useRef();if(!r.current){let s=new Map,l=new Map;t?.columns?.forEach(p=>{let{Column:n}=Eo("@libxai/core");s.set(p.id,new n(p));}),t?.cards?.forEach(p=>{let{Card:n}=Eo("@libxai/core");l.set(p.id,new n(p));});let c=null;if(t?.board){let{Board:p}=Eo("@libxai/core");c=new p(t.board);}r.current=new BoardStore({board:c,columns:s,cards:l});}let o=r.current;return useEffect(()=>{if(a)return o.subscribeAll(s=>{a(o.getState());})},[o,a]),jsx(Rc.Provider,{value:{store:o},children:e})}function Nn(){let e=useContext(Rc);if(!e)throw new Error("useBoardStore must be used within BoardProvider");return e.store}function No(){let e=Nn(),[t,a]=useState(e.getBoard()),[r,o]=useState(e.getAllColumns()),[s,l]=useState(e.getAllCards());useEffect(()=>e.subscribeAll(()=>{a(e.getBoard()),o(e.getAllColumns()),l(e.getAllCards());}),[e]);let c=useCallback(h=>{e.updateBoard(h);},[e]),p=useCallback(h=>{e.addColumn(h);},[e]),n=useCallback((h,b)=>{e.updateColumn(h,b);},[e]),m=useCallback(h=>{e.deleteColumn(h);},[e]),d=useCallback(h=>e.getColumn(h),[e]),i=useCallback(h=>{e.addCard(h);},[e]),u=useCallback((h,b)=>{e.updateCard(h,b);},[e]),x=useCallback(h=>{e.deleteCard(h);},[e]),f=useCallback((h,b,y)=>{e.moveCard(h,b,y);},[e]),g=useCallback(h=>e.getCard(h),[e]),k=useCallback(h=>e.getCardsByColumn(h),[e]);return {board:t,columns:r,cards:s,updateBoard:c,addColumn:p,updateColumn:n,deleteColumn:m,getColumn:d,addCard:i,updateCard:u,deleteCard:x,moveCard:f,getCard:g,getCardsByColumn:k}}function $c(e){let{cards:t}=No();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 Uc(e="position",t="asc"){let{cards:a}=No();return useMemo(()=>[...a].sort((o,s)=>{let l=0;switch(e){case "title":l=o.title.localeCompare(s.title);break;case "priority":{let c={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},p=o.priority?c[o.priority]:0,n=s.priority?c[s.priority]:0;l=p-n;break}case "createdAt":l=o.createdAt.getTime()-s.createdAt.getTime();break;case "updatedAt":l=o.updatedAt.getTime()-s.updatedAt.getTime();break;case "position":l=o.position-s.position;break}return t==="asc"?l:-l}),[a,e,t])}var Sn=class{constructor(){this.plugins=new Map;this.enabled=new Set;this.config=new Map;this.context=null;this.pluginLogger=Gi.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 l=s[t];if(typeof l=="function")try{let c=await Promise.resolve(l.apply(s,a));c!==void 0&&(o=c,a[0]=c);}catch(c){this.pluginLogger.error(`Plugin hook failed: ${s.id}.${t}`,c,{plugin:s.id,hook:t});}}return o}async executeHookParallel(t,a){let r=[];for(let o of this.plugins.values()){if(!this.enabled.has(o.id))continue;let s=o[t];typeof s=="function"&&r.push(Promise.resolve(s.apply(o,a)).catch(l=>{this.pluginLogger.error(`Plugin hook failed: ${o.id}.${t}`,l,{plugin:o.id,hook:t});}));}await Promise.all(r);}},Dh=new Sn;function Hc({items:e,height:t,estimateSize:a,renderItem:r,className:o="",overscan:s=5,horizontal:l=false,gap:c=0,getItemKey:p}){let n=useRef(null),m=useVirtualizer({count:e.length,getScrollElement:()=>n.current,estimateSize:()=>a,overscan:s,horizontal:l,gap:c}),d=m.getVirtualItems(),i={height:typeof t=="number"?`${t}px`:t,width:"100%",overflow:"auto",position:"relative"},u=l?{width:`${m.getTotalSize()}px`,height:"100%",position:"relative"}:{height:`${m.getTotalSize()}px`,width:"100%",position:"relative"};return jsx("div",{ref:n,style:i,className:o,children:jsx("div",{style:u,children:d.map(x=>{let f=e[x.index];if(!f)return null;let g=p?p(f,x.index):x.index,k={position:"absolute",top:l?0:x.start,left:l?x.start:0,width:l?x.size:"100%",height:l?"100%":x.size};return jsx("div",{style:k,"data-index":x.index,children:r(f,x.index)},g)})})})}function Gc(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 Vc({items:e,height:t,width:a="100%",estimateColumnWidth:r,renderColumn:o,className:s="",overscan:l=3,gap:c=16,getItemKey:p,horizontal:n=true}){let m=useRef(null),d=useVirtualizer({horizontal:n,count:e.length,getScrollElement:()=>m.current,estimateSize:()=>r,overscan:l,gap:c}),i=d.getVirtualItems(),u={height:typeof t=="number"?`${t}px`:t,width:typeof a=="number"?`${a}px`:a,overflow:"auto",position:"relative"},x={width:`${d.getTotalSize()}px`,height:"100%",position:"relative"};return jsx("div",{ref:m,style:u,className:s,children:jsx("div",{style:x,children:i.map(f=>{let g=e[f.index];if(!g)return null;let k=p?p(g,f.index):f.index,h={position:"absolute",top:0,left:f.start,width:f.size,height:"100%"};return jsx("div",{style:h,"data-index":f.index,children:o(g,f.index)},k)})})})}function jc(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 Kc(e,t=10){return e>t}var vi={none:0,xs:4,sm:8,md:12,lg:16,xl:20,"2xl":24,"3xl":32,"4xl":40,"5xl":48,"6xl":64},xi={none:0,sm:4,md:8,lg:12,xl:16,"2xl":20,full:9999},ki={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48},wi={light:300,normal:400,medium:500,semibold:600,bold:700,extrabold:800},Ci={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},Ti={base:0,dropdown:1e3,sticky:1020,fixed:1030,modalBackdrop:1040,modal:1050,popover:1060,tooltip:1070},Di={instant:0,fastest:75,faster:100,fast:150,normal:200,slow:300,slower:400,slowest:500},Ni={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)"},Si={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)"},Ei={0:0,5:.05,10:.1,20:.2,30:.3,40:.4,50:.5,60:.6,70:.7,80:.8,90:.9,100:1},Pi={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}},Mi={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}},En={spacing:vi,borderRadius:xi,fontSize:ki,fontWeight:wi,lineHeight:Ci,zIndex:Ti,duration:Di,easing:Ni,shadows:Si,opacity:Ei,kanban:Pi,gantt:Mi};function Yc(e,t,a){return e[t]??a}function Ai(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)?Ai(o,s,a):(typeof o=="string"||typeof o=="number")&&(a[s]=o);}return a}function Eh(e){return typeof e=="number"?e>0&&e<1e3?`${e}px`:e.toString():e}function Ii(e="asakaa"){let t=Ai(En),a=[];for(let[r,o]of Object.entries(t)){let s=`--${e}-${r}`,l=Eh(o);a.push(` ${s}: ${l};`);}return `:root {
|
|
389
|
+
Today's date: ${new Date().toISOString().split("T")[0]}`}function $d(e){let t=[],a=r=>{for(let o of r)t.push(o),o.subtasks?.length&&a(o.subtasks);};return a(e),t}function Ya(e,t){let a=$d(e),r=t.toLowerCase().trim(),o=a.find(c=>c.name.toLowerCase()===r);if(o)return o;let s=a.find(c=>c.name.toLowerCase().includes(r));if(s)return s;let l=r.split(/\s+/);return a.find(c=>{let p=c.name.toLowerCase();return l.every(n=>p.includes(n))})}function Gs(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 i=new Date(r);return i.setDate(i.getDate()+1),i}if(a==="yesterday"||a==="ayer"){let i=new Date(r);return i.setDate(i.getDate()-1),i}if(a==="next week"||a==="la pr\xF3xima semana"){let i=new Date(r);return i.setDate(i.getDate()+7),i}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 u={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(u!==void 0){let x=new Date(r),f=x.getDay(),g=u-f;return g<=0&&(g+=7),x.setDate(x.getDate()+g),x}}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 i=parseInt(s[1],10),u=s[2].toLowerCase(),x=new Date(r);return u==="day"||u==="d\xEDa"||u==="dias"?x.setDate(x.getDate()+i):u==="week"||u==="semana"||u==="semanas"?x.setDate(x.getDate()+i*7):(u==="month"||u==="mes"||u==="meses")&&x.setMonth(x.getMonth()+i),x}if(a.match(/(\d{4})-(\d{2})-(\d{2})/))return new Date(a);let c=a.match(/(\d{1,2})\/(\d{1,2})\/(\d{4})/);if(c&&c[1]&&c[2]&&c[3]){let i=parseInt(c[1],10),u=parseInt(c[2],10)-1,x=parseInt(c[3],10);return new Date(x,u,i)}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},n=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(n&&n[1]&&n[2]){let i=parseInt(n[1],10),u=p[n[2].toLowerCase()],x=n[3]?parseInt(n[3],10):r.getFullYear();if(u!==void 0)return new Date(x,u,i)}let m={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 i=m[d[1].toLowerCase()],u=parseInt(d[2],10),x=d[3]?parseInt(d[3],10):r.getFullYear();if(i!==void 0)return new Date(x,i,u)}return null}function _s(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 Vs(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 Ud(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 Wd(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 n=r[1].trim(),m=r[2].trim(),d=Ya(t,n),i=Gs(m);if(!d)return {type:"move_task",taskName:n,message:`Could not find a task named "${n}". Please check the task name and try again.`,success:false,error:"Task not found"};if(!i)return {type:"move_task",taskId:d.id,taskName:d.name,message:`Could not parse the date "${m}". Try using formats like "next Monday", "in 3 days", or "2024-01-15".`,success:false,error:"Invalid date"};let u=d.startDate&&d.endDate?Math.round((d.endDate.getTime()-d.startDate.getTime())/(1e3*60*60*24)):1,x=new Date(i);return x.setDate(x.getDate()+u),{type:"move_task",taskId:d.id,taskName:d.name,updates:{startDate:i,endDate:x},message:`Moved "${d.name}" to ${i.toLocaleDateString()}.`,success:true}}let o=a.match(/(?:extend|extender|extiende|alargar)\s+["""]?(.+?)["""]?\s+(?:by|por)\s+(.+)/i);if(o&&o[1]&&o[2]){let n=o[1].trim(),m=o[2].trim(),d=Ya(t,n),i=_s(m);if(!d)return {type:"resize_task",taskName:n,message:`Could not find a task named "${n}".`,success:false,error:"Task not found"};if(!i||!d.endDate)return {type:"resize_task",taskId:d.id,taskName:d.name,message:`Could not parse the duration "${m}".`,success:false,error:"Invalid duration"};let u=new Date(d.endDate);return u.setDate(u.getDate()+i),{type:"resize_task",taskId:d.id,taskName:d.name,updates:{endDate:u},message:`Extended "${d.name}" by ${i} days. New end date: ${u.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 n=s[1].trim(),m=s[2].trim(),d=Ya(t,n),i=Vs(m);return d?i===null?{type:"set_progress",taskId:d.id,taskName:d.name,message:`Could not parse the progress value "${m}".`,success:false,error:"Invalid progress"}:{type:"set_progress",taskId:d.id,taskName:d.name,updates:{progress:i},message:`Set "${d.name}" progress to ${i}%.`,success:true}:{type:"set_progress",taskName:n,message:`Could not find a task named "${n}".`,success:false,error:"Task not found"}}let l=a.match(/(?:rename|renombrar|cambiar nombre de)\s+["""]?(.+?)["""]?\s+(?:to|a|por)\s+["""]?(.+?)["""]?$/i);if(l&&l[1]&&l[2]){let n=l[1].trim(),m=l[2].trim(),d=Ya(t,n);return d?{type:"rename_task",taskId:d.id,taskName:d.name,updates:{name:m},message:`Renamed "${d.name}" to "${m}".`,success:true}:{type:"rename_task",taskName:n,message:`Could not find a task named "${n}".`,success:false,error:"Task not found"}}let c=a.match(/(?:link|vincular|conectar)\s+["""]?(.+?)["""]?\s+(?:to|a|con)\s+["""]?(.+?)["""]?$/i);if(c&&c[1]&&c[2]){let n=c[1].trim(),m=c[2].trim(),d=Ya(t,n),i=Ya(t,m);return d?i?{type:"link_tasks",taskId:i.id,taskName:i.name,dependencyFrom:d.id,dependencyTo:i.id,message:`Linked "${d.name}" \u2192 "${i.name}".`,success:true}:{type:"link_tasks",taskName:m,message:`Could not find a task named "${m}".`,success:false,error:"Target task not found"}:{type:"link_tasks",taskName:n,message:`Could not find a task named "${n}".`,success:false,error:"Source task not found"}}let p=a.match(/(?:delete|eliminar|borrar|remove|quitar)\s+["""]?(.+?)["""]?$/i);if(p&&p[1]){let n=p[1].trim(),m=Ya(t,n);return m?{type:"delete_task",taskId:m.id,taskName:m.name,message:`Deleted "${m.name}".`,success:true}:{type:"delete_task",taskName:n,message:`Could not find a task named "${n}".`,success:false,error:"Task not found"}}return null}function Hd(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 Ef(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 Pf(e){switch(e){case "todo":return "TODO";case "in-progress":return "IN_PROGRESS";case "completed":return "DONE";default:return e||"TODO"}}function ln(e,t=[],a=[]){let r=e.assignedUserIds?.map(m=>{let d=a.find(i=>i.id===m);return d?{name:d.name,initials:d.initials,color:d.color}:null}).filter(m=>m!==null),o=t.filter(m=>m.metadata?.parentCardId===e.id).map(m=>ln(m,t,a)),s;e.dependencies&&(typeof e.dependencies[0]=="string"?s=e.dependencies:s=e.dependencies.filter(m=>m.type==="finish-to-start").map(m=>m.taskId));let l=m=>{if(m)return typeof m=="string"?new Date(m):m},c=l(e.startDate),p=l(e.endDate),n=e.metadata?.isMilestone===true||c&&p&&Math.abs(p.getTime()-c.getTime())<=864e5;return {id:e.id,name:e.title,startDate:c,endDate:p,progress:e.progress||0,status:Ef(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:n,isCriticalPath:e.metadata?.isCriticalPath===true}}function Gd(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:Pf(e.status),isExpanded:e.isExpanded,isMilestone:e.isMilestone,isCriticalPath:e.isCriticalPath}}}function _d(e,t=[]){return e.filter(r=>!r.metadata?.parentCardId).map(r=>ln(r,e,t))}var js={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"}},Ks={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"}},dn={en:js,es:Ks};function Ys(e){return dn[e]||dn.en}function cn(e,t){let a=Ys(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 Yd(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(...Yd(r.subtasks,t+1));return a}function Uf({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 qd({tasks:e,config:t={},callbacks:a={},isLoading:r=false,error:o,className:s,style:l}){let{theme:c="dark",locale:p="en",customTranslations:n,showSearch:m=true,showHierarchy:d=true}=t,i=cn(p,n),u=c==="dark",[x,f]=useState(new Set),[g,k]=useState("startDate"),[h,b]=useState("asc"),[y,D]=useState("");useMemo(()=>{let T=new Set;function w(B){for(let P of B)P.subtasks?.length&&(T.add(P.id),w(P.subtasks));}w(e),f(T);},[e]);let N=useCallback(T=>{f(w=>{let B=new Set(w);return B.has(T)?B.delete(T):B.add(T),B}),a.onTaskToggleExpand?.(T);},[a]),A=useCallback(T=>{g===T?b(w=>w==="asc"?"desc":"asc"):(k(T),b("asc")),a.onSortChange?.({column:T,direction:h==="asc"?"desc":"asc"});},[g,h,a]),v=useMemo(()=>{let T=Yd(e);if(y.trim()){let B=y.toLowerCase();T=T.filter(P=>P.name.toLowerCase().includes(B));}let w=[];for(let B of T){let P=B.level===0;B.level>0&&(P=true),(P||y.trim())&&w.push(B);}return y.trim()&&w.sort((B,P)=>{let H,X;switch(g){case "name":H=B.name.toLowerCase(),X=P.name.toLowerCase();break;case "startDate":H=B.startDate?.getTime()||0,X=P.startDate?.getTime()||0;break;case "endDate":H=B.endDate?.getTime()||0,X=P.endDate?.getTime()||0;break;case "progress":H=B.progress||0,X=P.progress||0;break;case "status":H=B.status||"todo",X=P.status||"todo";break;default:return 0}return H<X?h==="asc"?-1:1:H>X?h==="asc"?1:-1:0}),w},[e,y,g,h]),F=T=>T?(T instanceof Date?T:new Date(T)).toLocaleDateString(p==="es"?"es-ES":"en-US",{day:"numeric",month:"short"}):"-";return r?jsx("div",{className:C("flex-1 flex items-center justify-center",u?"bg-[#0F1117]":"bg-white",s),style:l,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:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[i.empty.noTasks,"..."]})]})}):o?jsx("div",{className:C("flex-1 flex items-center justify-center",u?"bg-[#0F1117]":"bg-white",s),style:l,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:C("text-lg font-semibold mb-2",u?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:typeof o=="string"?o:o.message})]})]})}):e.length===0?jsx("div",{className:C("flex-1 flex items-center justify-center",u?"bg-[#0F1117]":"bg-white",s),style:l,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:C("text-lg font-semibold mb-2",u?"text-white":"text-gray-900"),children:i.empty.noTasks}),jsx("p",{className:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:i.empty.addFirstTask})]})}):jsxs("div",{className:C("flex-1 flex flex-col w-full h-full overflow-hidden",u?"bg-[#0F1117]":"bg-white",s),style:l,children:[jsx("div",{className:C("flex-shrink-0 px-6 py-4 border-b",u?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-center gap-4",children:[m&&jsxs("div",{className:"relative flex-1 max-w-md",children:[jsx(Search,{className:C("absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4",u?"text-[#9CA3AF]":"text-gray-400")}),jsx("input",{type:"text",value:y,onChange:T=>D(T.target.value),placeholder:i.toolbar.searchPlaceholder,className:C("w-full h-9 pl-10 pr-4 rounded-lg border outline-none focus:ring-2 focus:ring-[#3B82F6]/30",u?"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:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[v.length," ",i.pagination.tasks]})]})}),jsxs("div",{className:C("flex-shrink-0 grid grid-cols-12 gap-4 px-6 py-3 border-b text-xs font-medium uppercase tracking-wider",u?"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:()=>A("name"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.name,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>A("status"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.status,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>A("startDate"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.startDate,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>A("endDate"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.endDate,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-1 flex items-center gap-1",children:jsxs("button",{onClick:()=>A("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:v.map((T,w)=>{let B=x.has(T.id);return jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{delay:w*.02},className:C("grid grid-cols-12 gap-4 px-6 py-3 border-b transition-colors cursor-pointer",u?"border-white/5 hover:bg-white/5":"border-gray-100 hover:bg-gray-50"),style:{paddingLeft:d?`${24+T.level*24}px`:void 0},onClick:()=>a.onTaskClick?.(T),onDoubleClick:()=>a.onTaskDoubleClick?.(T),children:[jsxs("div",{className:"col-span-5 flex items-center gap-2 min-w-0",children:[d&&T.hasChildren&&jsx("button",{onClick:P=>{P.stopPropagation(),N(T.id);},className:C("p-0.5 rounded",u?"hover:bg-white/10":"hover:bg-gray-200"),children:B?jsx(ChevronDown,{className:C("w-4 h-4",u?"text-[#9CA3AF]":"text-gray-400")}):jsx(ChevronRight,{className:C("w-4 h-4",u?"text-[#9CA3AF]":"text-gray-400")})}),d&&!T.hasChildren&&jsx("div",{className:"w-5"}),jsx("button",{onClick:P=>{P.stopPropagation(),a.onTaskUpdate?.({...T,progress:T.progress===100?0:100,status:T.progress===100?"todo":"completed"});},className:"flex-shrink-0",children:jsx(Uf,{status:T.status,progress:T.progress})}),jsx("span",{className:C("truncate",u?"text-white":"text-gray-900",T.progress===100&&(u?"line-through text-[#6B7280]":"line-through text-gray-400")),children:T.name})]}),jsx("div",{className:"col-span-2 flex items-center",children:jsx("span",{className:C("px-2 py-1 rounded-full text-xs font-medium",T.progress===100||T.status==="completed"?"bg-green-500/10 text-green-500":T.progress&&T.progress>0||T.status==="in-progress"?"bg-blue-500/10 text-blue-500":u?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:T.progress===100||T.status==="completed"?i.status.completed:T.progress&&T.progress>0||T.status==="in-progress"?i.status.inProgress:i.status.todo})}),jsxs("div",{className:C("col-span-2 flex items-center gap-1 text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Calendar,{className:"w-4 h-4"}),F(T.startDate)]}),jsxs("div",{className:C("col-span-2 flex items-center gap-1 text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Clock,{className:"w-4 h-4"}),F(T.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:C("flex-1 h-1.5 rounded-full overflow-hidden",u?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:C("h-full rounded-full transition-all",T.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${T.progress||0}%`}})}),jsxs("span",{className:C("text-xs w-8",u?"text-[#9CA3AF]":"text-gray-500"),children:[T.progress||0,"%"]})]})})]},T.id)})}),v.length===0&&y&&jsx("div",{className:"flex items-center justify-center py-12",children:jsxs("div",{className:"text-center",children:[jsx(List,{className:C("w-12 h-12 mx-auto mb-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:C(u?"text-[#9CA3AF]":"text-gray-600"),children:i.empty.noResults})]})})]})]})}var qs={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"},Xs={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"},Js={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"},mn={dark:qs,light:Xs,neutral:Js};function Xd(e){return mn[e]||mn.dark}var Zs={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"}},Qs={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"}},un={en:Zs,es:Qs};function bo(e){return un[e]||un.en}function gn(e,t){let a=bo(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 Jd(e){let t=bo(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 Zd(e,t=0,a=true){let r=bo(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 Qf(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 oi(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 tc({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 rc({tasks:e,config:t={},callbacks:a={},initialDate:r,isLoading:o=false,error:s,className:l,style:c}){let{theme:p="dark",locale:n="en",customTranslations:m}=t,d=gn(n,m),i=p==="dark",[u,x]=useState(r||new Date),[f,g]=useState(null),[k,h]=useState(null),[b,y]=useState(null),[D,N]=useState(new Date),[A,v]=useState({}),F=4,T=3,[w,B]=useState(false),[P,H]=useState(false),[X$1,fe]=useState(false),[ve,Re]=useState(null),[Ue,z]=useState(""),[L,U]=useState(void 0),[E,q]=useState(null),[J,$]=useState(false),[Te,ke]=useState(false),[Ge,he]=useState(null),[tt,Fe]=useState(false),[et,ft]=useState(new Date),Tt=useCallback(()=>{x(new Date(u.getFullYear(),u.getMonth()-1,1));},[u]),dt=useCallback(()=>{x(new Date(u.getFullYear(),u.getMonth()+1,1));},[u]),O=useCallback(()=>{x(new Date);},[]),ne=useMemo(()=>{let V=u.getFullYear(),xe=u.getMonth(),qe=new Date(V,xe,1),Z=new Date(V,xe+1,0),we=qe.getDay(),ee=Z.getDate(),ae=Qf(e),ye=new Date;ye.setHours(0,0,0,0);let De=[],re=we,Ee=new Date(V,xe,0).getDate();for(let Ne=re-1;Ne>=0;Ne--){let ce=new Date(V,xe-1,Ee-Ne);De.push({date:ce,isCurrentMonth:false,isToday:false,isWeekend:ce.getDay()===0||ce.getDay()===6,events:ae.filter(Oe=>oi(ce,Oe)).map(Oe=>({id:Oe.id,title:Oe.name,start:Oe.startDate,end:Oe.endDate,task:Oe}))});}for(let Ne=1;Ne<=ee;Ne++){let ce=new Date(V,xe,Ne),Oe=ce.getTime()===ye.getTime();De.push({date:ce,isCurrentMonth:true,isToday:Oe,isWeekend:ce.getDay()===0||ce.getDay()===6,events:ae.filter(W=>oi(ce,W)).map(W=>({id:W.id,title:W.name,start:W.startDate,end:W.endDate,task:W}))});}let be=42-De.length;for(let Ne=1;Ne<=be;Ne++){let ce=new Date(V,xe+1,Ne);De.push({date:ce,isCurrentMonth:false,isToday:false,isWeekend:ce.getDay()===0||ce.getDay()===6,events:ae.filter(Oe=>oi(ce,Oe)).map(Oe=>({id:Oe.id,title:Oe.name,start:Oe.startDate,end:Oe.endDate,task:Oe}))});}return De},[u,e]),ie=n==="es"?["Dom","Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b"]:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Se=u.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"}),Ae=useCallback((V,xe)=>{if(!f)return;let qe={...f,[V]:xe};g(qe),a.onTaskUpdate?.(qe);},[f,a]),ot=useCallback(V=>{if(!f)return;let xe=f.progress||0;V==="completed"?xe=100:V==="todo"&&(xe=0);let qe={...f,status:V,progress:xe};g(qe),a.onTaskUpdate?.(qe),B(false);},[f,a]),st=useCallback((V,xe)=>{if(!f)return;let qe={...f,startDate:V,endDate:xe};g(qe),a.onTaskUpdate?.(qe);},[f,a]),Le=useCallback(()=>{B(false),H(false),y(null);},[]);return o?jsx("div",{className:C("flex-1 flex items-center justify-center",i?"bg-[#0F1117]":"bg-white",l),style:c,children:jsxs("div",{className:"flex flex-col items-center gap-4",children:[jsx("div",{className:"w-8 h-8 animate-spin rounded-full border-b-2 border-[#3B82F6]"}),jsxs("p",{className:C("text-sm",i?"text-[#9CA3AF]":"text-gray-600"),children:[d.labels.noEvents,"..."]})]})}):s?jsx("div",{className:C("flex-1 flex items-center justify-center",i?"bg-[#0F1117]":"bg-white",l),style:c,children:jsxs("div",{className:"flex flex-col items-center gap-4 max-w-md text-center",children:[jsx("div",{className:"w-12 h-12 rounded-full bg-red-500/10 flex items-center justify-center",children:jsx("span",{className:"text-red-500 text-2xl",children:"\u26A0"})}),jsxs("div",{children:[jsx("h3",{className:C("text-lg font-semibold mb-2",i?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:C("text-sm",i?"text-[#9CA3AF]":"text-gray-600"),children:typeof s=="string"?s:s.message})]})]})}):e.length===0?jsx("div",{className:C("flex-1 flex items-center justify-center",i?"bg-[#0F1117]":"bg-white",l),style:c,children:jsxs("div",{className:"text-center max-w-md",children:[jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-2xl bg-[#3B82F6]/10 flex items-center justify-center",children:jsx(Calendar,{className:"w-8 h-8 text-[#3B82F6]"})}),jsx("h3",{className:C("text-lg font-semibold mb-2",i?"text-white":"text-gray-900"),children:d.labels.noEvents}),jsx("p",{className:C("text-sm",i?"text-[#9CA3AF]":"text-gray-600"),children:d.labels.newTask})]})}):jsxs("div",{className:C("flex-1 flex flex-col w-full h-full overflow-auto",i?"bg-[#0F1117]":"bg-white",l),style:c,children:[jsx("div",{className:C("flex-shrink-0 px-6 py-4 border-b",i?"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:C("text-xl font-semibold capitalize",i?"text-white":"text-gray-900"),children:Se}),jsx("button",{onClick:O,className:C("px-3 py-1.5 text-sm rounded-lg transition-colors",i?"bg-white/5 text-white hover:bg-white/10":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:d.navigation.today})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("button",{onClick:Tt,className:C("p-2 rounded-lg transition-colors",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:C("w-5 h-5",i?"text-[#9CA3AF]":"text-gray-600")})}),jsx("button",{onClick:dt,className:C("p-2 rounded-lg transition-colors",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:C("w-5 h-5",i?"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:ie.map(V=>jsx("div",{className:C("py-2 text-center text-xs font-medium uppercase",i?"text-[#9CA3AF]":"text-gray-500"),children:V},V))}),jsx("div",{className:C("grid grid-cols-7 auto-rows-min gap-px rounded-lg",i?"bg-[#2D2D2D]":"bg-gray-300"),children:ne.map((V,xe)=>{let qe=V.date.getDay()===0||V.date.getDay()===6;return jsxs("div",{className:C("min-h-[120px] p-2 transition-colors flex flex-col relative group",i?qe?"bg-[#1C1F26]":V.isCurrentMonth?"bg-[#13161B]":"bg-[#0D0F13]":qe?"bg-gray-100":V.isCurrentMonth?"bg-white":"bg-gray-50",V.isToday&&"ring-2 ring-[#3B82F6] ring-inset"),children:[(()=>{let Z=A[xe]||F,we=V.events.slice(0,Z),ee=V.events.length-Z;return jsxs("div",{className:"space-y-1 flex-1",children:[we.map(ae=>jsx("div",{className:"relative group",children:jsxs(motion.button,{onClick:()=>{g(ae.task),a.onEventClick?.(ae);},whileHover:{scale:1.02},className:C("w-full flex items-center gap-1 px-1.5 py-0.5 rounded text-xs truncate",ae.task.progress===100?i?"bg-green-500/20 text-green-400":"bg-green-500/10 text-green-600":i?"bg-[#3B82F6]/20 text-[#3B82F6]":"bg-[#3B82F6]/10 text-[#3B82F6]"),children:[jsx(tc,{task:ae.task}),jsx("span",{className:"truncate",children:ae.title})]})},ae.id)),ee>0&&jsxs("button",{onClick:ae=>{ae.stopPropagation(),v(ye=>({...ye,[xe]:Z+T}));},className:C("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",i?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:["+",ee," ",n==="es"?"M\xC1S":"MORE"]}),Z>F&&V.events.length>F&&jsx("button",{onClick:ae=>{ae.stopPropagation(),v(ye=>({...ye,[xe]:F}));},className:C("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",i?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:n==="es"?"MENOS":"LESS"})]})})(),jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1",children:[(()=>{let Z=xe>=28,we=xe%7>=5;return jsxs("div",{className:"relative",children:[jsx("button",{onClick:ee=>{ee.stopPropagation(),ve===xe?Re(null):(Re(xe),z(""),U(void 0),q(null),he(null),$(false),ke(false),Fe(false),ft(V.date));},className:C("w-5 h-5 rounded flex items-center justify-center transition-all",ve===xe?"opacity-100 bg-[#7C3AED] text-white":"opacity-0 group-hover:opacity-100",i?"hover:bg-[#7C3AED] text-[#6B7280] hover:text-white":"hover:bg-[#7C3AED] text-gray-400 hover:text-white"),children:jsx(Plus,{className:C("w-3.5 h-3.5 transition-transform",ve===xe&&"rotate-45")})}),jsx(AnimatePresence,{children:ve===xe&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{Re(null),z(""),U(void 0),q(null),he(null),$(false),ke(false),Fe(false);}}),jsxs(motion.div,{initial:{opacity:0,y:Z?-5:5,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:Z?-5:5,scale:.95},transition:{duration:.12},className:C("absolute w-[320px] rounded-lg shadow-2xl z-50",Z?"bottom-full mb-1":"top-full mt-1",we?"right-0":"left-0",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:ee=>{ee.stopPropagation(),$(false),ke(false),Fe(false);},children:[jsx("div",{className:"p-2.5",children:jsx("input",{type:"text",value:Ue,onChange:ee=>z(ee.target.value),placeholder:n==="es"?'Escribe el nombre de la tarea o "/" para los comandos':'Type task name or "/" for commands',className:C("w-full bg-transparent text-sm outline-none placeholder:opacity-40",i?"text-white":"text-gray-900"),autoFocus:true,onKeyDown:ee=>{if(ee.key==="Enter"&&Ue.trim()){let ae=t.availableUsers?.find(De=>De.id===E),ye=Ge||V.date;a.onTaskCreate?.({name:Ue.trim(),startDate:ye,endDate:ye,priority:L,assignees:ae?[ae]:void 0}),z(""),U(void 0),q(null),he(null),Re(null);}ee.key==="Escape"&&(Re(null),z(""),U(void 0),q(null),he(null));}})}),jsxs("div",{className:C("px-2.5 py-2 flex items-center justify-between border-t",i?"border-white/10":"border-gray-100"),children:[jsxs("div",{className:"flex items-center gap-1",children:[jsxs("div",{className:"relative",children:[jsx("button",{onClick:ee=>{ee.stopPropagation(),$(!J),ke(false);},className:C("p-1 rounded transition-colors",L?L==="urgent"||L==="high"?"text-red-400 bg-red-500/20":L==="medium"?"text-yellow-400 bg-yellow-500/20":"text-green-400 bg-green-500/20":i?"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:J&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[120px]",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:ee=>ee.stopPropagation(),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(ee=>jsxs("button",{onClick:()=>{U(ee.id),$(false);},className:C("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",L===ee.id&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:C("w-2 h-2 rounded-full",ee.color)}),jsx("span",{className:i?"text-white":"text-gray-900",children:ee.label})]},ee.id||"none"))})})]}),jsxs("div",{className:"relative",children:[jsxs("button",{onClick:ee=>{ee.stopPropagation(),Fe(!tt),$(false),ke(false),ft(Ge||V.date);},className:C("flex items-center gap-1 text-xs px-1.5 py-0.5 rounded transition-colors",Ge?"bg-[#7C3AED]/20 text-[#7C3AED]":i?"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"}),(Ge||V.date).toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})]}),jsx(AnimatePresence,{children:tt&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-0 bottom-full mb-1 z-[60] rounded-xl shadow-2xl overflow-hidden flex",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:ee=>ee.stopPropagation(),children:[jsx("div",{className:C("w-40 py-2 border-r",i?"border-white/10":"border-gray-200"),children:(()=>{let ee=new Date,ae=new Date(ee);ae.setDate(ee.getDate()+1);let ye=new Date(ee);ye.setDate(ee.getDate()+((6-ee.getDay()+7)%7||7));let De=new Date(ee);De.setDate(ee.getDate()+((1-ee.getDay()+7)%7||7));let re=new Date(ee);re.setDate(ee.getDate()+14);let Ee=new Date(ee);return Ee.setDate(ee.getDate()+28),[{label:n==="es"?"Hoy":"Today",date:ee,display:ee.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Ma\xF1ana":"Tomorrow",date:ae,display:ae.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Este fin de semana":"This weekend",date:ye,display:n==="es"?"s\xE1b.":"sat."},{label:n==="es"?"Pr\xF3xima semana":"Next week",date:De,display:n==="es"?"lun.":"mon."},{label:n==="es"?"2 semanas":"2 weeks",date:re,display:re.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:Ee,display:Ee.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Ne,ce)=>jsxs("button",{className:C("w-full flex items-center justify-between px-3 py-1.5 text-xs transition-colors",i?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{he(Ne.date),Fe(false);},children:[jsx("span",{children:Ne.label}),jsx("span",{className:C("text-[10px]",i?"text-[#6B7280]":"text-gray-400"),children:Ne.display})]},ce))})()}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("span",{className:C("text-xs font-medium",i?"text-white":"text-gray-900"),children:et.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-0.5",children:[jsx("button",{onClick:()=>ft(new Date),className:C("px-1.5 py-0.5 rounded text-[10px] transition-colors",i?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>ft(new Date(et.getFullYear(),et.getMonth()-1)),className:C("p-0.5 rounded",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:()=>ft(new Date(et.getFullYear(),et.getMonth()+1)),className:C("p-0.5 rounded",i?"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:(n==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(ee=>jsx("div",{className:C("w-6 h-6 flex items-center justify-center text-[10px]",i?"text-[#6B7280]":"text-gray-400"),children:ee},ee))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let ee=et.getFullYear(),ae=et.getMonth(),ye=new Date(ee,ae,1).getDay(),De=new Date(ee,ae+1,0).getDate(),re=new Date(ee,ae,0).getDate(),Ee=new Date,be=[];for(let ce=ye-1;ce>=0;ce--)be.push({dayNum:re-ce,isCurrentMonth:false,date:new Date(ee,ae-1,re-ce)});for(let ce=1;ce<=De;ce++)be.push({dayNum:ce,isCurrentMonth:true,date:new Date(ee,ae,ce)});let Ne=42-be.length;for(let ce=1;ce<=Ne;ce++)be.push({dayNum:ce,isCurrentMonth:false,date:new Date(ee,ae+1,ce)});return be.map((ce,Oe)=>{let W=ce.date.toDateString()===Ee.toDateString(),G=(Ge||V.date).toDateString()===ce.date.toDateString();return jsx("button",{className:C("w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",!ce.isCurrentMonth&&(i?"text-[#4B5563]":"text-gray-300"),ce.isCurrentMonth&&(i?"text-white":"text-gray-900"),W&&"ring-1 ring-[#3B82F6]",G&&"bg-[#7C3AED] text-white",!G&&(i?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{he(ce.date),Fe(false);},children:ce.dayNum},Oe)})})()})]})]})})]}),jsxs("div",{className:"relative",children:[jsx("button",{onClick:ee=>{ee.stopPropagation(),ke(!Te),$(false);},className:C("p-1 rounded transition-colors",E?"text-[#7C3AED] bg-[#7C3AED]/20":i?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:E?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(ee=>ee.id===E)?.color||"#7C3AED"},children:t.availableUsers?.find(ee=>ee.id===E)?.initials||t.availableUsers?.find(ee=>ee.id===E)?.name?.slice(0,2).toUpperCase()}):jsx(User,{className:"w-3.5 h-3.5"})}),jsx(AnimatePresence,{children:Te&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[160px] max-h-[200px] overflow-y-auto",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:ee=>ee.stopPropagation(),children:[jsxs("button",{onClick:()=>{q(null),ke(false);},className:C("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",!E&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:C("w-5 h-5 rounded-full flex items-center justify-center",i?"bg-white/10":"bg-gray-200"),children:jsx(User,{className:"w-3 h-3 text-gray-400"})}),jsx("span",{className:i?"text-[#9CA3AF]":"text-gray-500",children:n==="es"?"Sin asignar":"Unassigned"})]}),t.availableUsers?.map(ee=>jsxs("button",{onClick:()=>{q(ee.id),ke(false);},className:C("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",E===ee.id&&(i?"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:ee.color||"#7C3AED"},children:ee.initials||ee.name?.slice(0,2).toUpperCase()}),jsx("span",{className:i?"text-white":"text-gray-900",children:ee.name})]},ee.id)),(!t.availableUsers||t.availableUsers.length===0)&&jsx("div",{className:C("px-3 py-2 text-xs",i?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"No hay usuarios disponibles":"No users available"})]})})]})]}),jsx("button",{onClick:()=>{if(Ue.trim()){let ee=t.availableUsers?.find(ye=>ye.id===E),ae=Ge||V.date;a.onTaskCreate?.({name:Ue.trim(),startDate:ae,endDate:ae,priority:L,assignees:ee?[ee]:void 0}),z(""),U(void 0),q(null),he(null),Re(null);}},disabled:!Ue.trim(),className:C("px-2.5 py-1 rounded text-xs font-medium transition-colors",Ue.trim()?"bg-[#7C3AED] hover:bg-[#6D28D9] text-white":i?"bg-white/5 text-[#4B5563]":"bg-gray-100 text-gray-400"),children:n==="es"?"Guardar":"Save"})]})]})]})})]})})(),jsx("span",{className:C("text-sm font-medium",V.isToday?"text-[#3B82F6]":V.isCurrentMonth?i?"text-white":"text-gray-900":i?"text-[#6B7280]":"text-gray-400"),children:V.date.getDate()})]})]},xe)})})]})}),jsx(AnimatePresence,{children:f&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>g(null),className:"fixed inset-0 bg-black/50 z-40"}),jsxs(motion.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},className:C("fixed inset-4 md:inset-8 lg:inset-12 rounded-xl shadow-2xl z-50 flex overflow-hidden",i?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[jsxs("div",{className:C("px-6 py-3 border-b flex items-center gap-3",i?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:C("w-4 h-4",i?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:C("text-xs px-2 py-0.5 rounded",i?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[n==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:C("text-xs font-mono",i?"text-[#6B7280]":"text-gray-400"),children:f.id.slice(0,8)}),jsxs("button",{className:C("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-colors",i?"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:C("p-1.5 rounded transition-colors",i?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Maximize2,{className:"w-4 h-4"})}),jsx("button",{className:C("p-1.5 rounded transition-colors",i?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(MoreHorizontal,{className:"w-5 h-5"})}),jsx("button",{onClick:()=>g(null),className:C("p-1.5 rounded transition-colors",i?"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 V=f.progress===100?0:100,qe={...f,progress:V,status:V===100?"completed":"todo"};g(qe),a.onTaskUpdate?.(qe);},className:C("mt-1 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors",f.progress===100?"bg-green-500 border-green-500":i?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:f.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("h2",{className:C("text-xl font-semibold flex-1",f.progress===100?"line-through text-[#6B7280]":i?"text-white":"text-gray-900"),children:f.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:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{Le(),B(!w);},className:C("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",f.progress===100||f.status==="completed"?"bg-green-500/20 text-green-400":f.progress&&f.progress>0||f.status==="in-progress"?"bg-blue-500/20 text-blue-400":i?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:f.progress===100||f.status==="completed"?n==="es"?"COMPLETADO":"DONE":f.progress&&f.progress>0||f.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:()=>B(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"todo",label:n==="es"?"Por hacer":"To Do",color:"bg-white/10 text-white"},{id:"in-progress",label:n==="es"?"En progreso":"In Progress",color:"bg-blue-500/20 text-blue-400"},{id:"completed",label:n==="es"?"Completado":"Done",color:"bg-green-500/20 text-green-400"}].map(V=>jsxs("button",{onClick:()=>ot(V.id),className:C("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",(f.status===V.id||V.id==="completed"&&f.progress===100||V.id==="in-progress"&&f.progress&&f.progress>0&&f.progress<100||V.id==="todo"&&(!f.progress||f.progress===0)&&f.status!=="in-progress"&&f.status!=="completed")&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:C("w-2 h-2 rounded-full",V.id==="completed"?"bg-green-500":V.id==="in-progress"?"bg-blue-500":"bg-gray-400")}),jsx("span",{className:i?"text-white":"text-gray-900",children:V.label})]},V.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(User,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Asignados":"Assignees"}),f.assignees&&f.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[f.assignees.slice(0,3).map((V,xe)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:V.color||"#8B5CF6"},title:V.name,children:V.initials||V.name.slice(0,2).toUpperCase()},xe)),f.assignees.length>3&&jsxs("span",{className:C("text-xs",i?"text-[#6B7280]":"text-gray-400"),children:["+",f.assignees.length-3]})]}):jsx("span",{className:C("text-sm",i?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Sin asignar":"Unassigned"})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CalendarDays,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{y(b?null:"start"),N(f.startDate||new Date);},className:C("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",i?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[f.startDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Inicio":"Start"),jsx("span",{className:C("mx-1",i?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),f.endDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Fin":"End"),(f.startDate||f.endDate)&&jsx(X,{className:"w-3.5 h-3.5 ml-1 opacity-50 hover:opacity-100",onClick:V=>{V.stopPropagation();}})]}),jsx(AnimatePresence,{children:b&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>y(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:C("absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:V=>V.stopPropagation(),children:[jsxs("div",{className:C("w-44 py-2 border-r",i?"border-white/10":"border-gray-200"),children:[(()=>{let V=new Date,xe=new Date(V);xe.setDate(V.getDate()+1);let qe=new Date(V);qe.setDate(V.getDate()+((6-V.getDay()+7)%7||7));let Z=new Date(V);Z.setDate(V.getDate()+((1-V.getDay()+7)%7||7));let we=new Date(V);we.setDate(V.getDate()+(6-V.getDay()+7)%7+7);let ee=new Date(V);ee.setDate(V.getDate()+14);let ae=new Date(V);return ae.setDate(V.getDate()+28),[{label:n==="es"?"Hoy":"Today",date:V,display:V.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Ma\xF1ana":"Tomorrow",date:xe,display:xe.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Este fin de semana":"This weekend",date:qe,display:n==="es"?"s\xE1b.":"sat."},{label:n==="es"?"Pr\xF3xima semana":"Next week",date:Z,display:n==="es"?"lun.":"mon."},{label:n==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:we,display:we.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"2 semanas":"2 weeks",date:ee,display:ee.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:ae,display:ae.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((De,re)=>jsxs("button",{className:C("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",i?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if(b==="start"){let Ee=f.endDate&&De.date>f.endDate?De.date:f.endDate;st(De.date,Ee),y("end");}else {let Ee=f.startDate&&De.date<f.startDate?De.date:f.startDate;st(Ee,De.date),y(null);}},children:[jsx("span",{children:De.label}),jsx("span",{className:C("text-xs",i?"text-[#6B7280]":"text-gray-400"),children:De.display})]},re))})(),jsx("div",{className:C("border-t mt-2 pt-2",i?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{st(void 0,void 0),y(null);},className:C("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",i?"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:C("text-xs mb-3 px-2 py-1 rounded",i?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:b==="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:C("font-medium",i?"text-white":"text-gray-900"),children:D.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>N(new Date),className:C("p-1 rounded text-sm transition-colors",i?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>N(new Date(D.getFullYear(),D.getMonth()-1)),className:C("p-1 rounded",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-4 h-4"})}),jsx("button",{onClick:()=>N(new Date(D.getFullYear(),D.getMonth()+1)),className:C("p-1 rounded",i?"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:(n==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(V=>jsx("div",{className:C("w-8 h-8 flex items-center justify-center text-xs",i?"text-[#6B7280]":"text-gray-400"),children:V},V))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let V=D.getFullYear(),xe=D.getMonth(),qe=new Date(V,xe,1).getDay(),Z=new Date(V,xe+1,0).getDate(),we=new Date(V,xe,0).getDate(),ee=new Date,ae=[];for(let De=qe-1;De>=0;De--)ae.push({day:we-De,isCurrentMonth:false,date:new Date(V,xe-1,we-De)});for(let De=1;De<=Z;De++)ae.push({day:De,isCurrentMonth:true,date:new Date(V,xe,De)});let ye=42-ae.length;for(let De=1;De<=ye;De++)ae.push({day:De,isCurrentMonth:false,date:new Date(V,xe+1,De)});return ae.map((De,re)=>{let Ee=De.date.toDateString()===ee.toDateString(),be=f.startDate?.toDateString()===De.date.toDateString(),Ne=f.endDate?.toDateString()===De.date.toDateString(),ce=be||Ne,Oe=f.startDate&&f.endDate&&De.date>=f.startDate&&De.date<=f.endDate;return jsx("button",{className:C("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!De.isCurrentMonth&&(i?"text-[#4B5563]":"text-gray-300"),De.isCurrentMonth&&(i?"text-white":"text-gray-900"),Ee&&"ring-2 ring-[#3B82F6]",be&&"bg-[#3B82F6] text-white",Ne&&!be&&"bg-[#7C3AED] text-white",Oe&&!ce&&(i?"bg-[#7C3AED]/20":"bg-purple-100"),!ce&&(i?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{let W=new Date(De.date);if(b==="start"){let G=f.endDate&&W>f.endDate?W:f.endDate;st(W,G),y("end");}else {let G=f.startDate&&W<f.startDate?W:f.startDate;st(G,W),y(null);}},children:De.day},re)})})()})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{Le(),H(!P);},className:C("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",f.priority==="high"||f.priority==="urgent"?"bg-red-500/20 text-red-400":f.priority==="medium"?"bg-yellow-500/20 text-yellow-400":f.priority==="low"?"bg-green-500/20 text-green-400":i?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:f.priority?f.priority==="high"||f.priority==="urgent"?n==="es"?"Urgente":"Urgent":f.priority==="medium"?n==="es"?"Media":"Medium":n==="es"?"Baja":"Low":n==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:P&&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:C("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",i?"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(V=>jsxs("button",{onClick:()=>{Ae("priority",V.id),H(false);},className:C("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",f.priority===V.id&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:C("w-2 h-2 rounded-full",V.color)}),jsx("span",{className:i?"text-white":"text-gray-900",children:V.label})]},V.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:C("text-sm",i?"text-white":"text-gray-900"),children:f.startDate&&f.endDate?`${Math.ceil((f.endDate.getTime()-f.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:C("w-4 h-4 rounded-full border-2",i?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[X$1?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:f.progress||0,onChange:V=>{let xe=parseInt(V.target.value),qe=f.status;xe===100?qe="completed":xe>0?qe="in-progress":qe="todo";let Z={...f,progress:xe,status:qe};g(Z),a.onTaskUpdate?.(Z);},onBlur:()=>fe(false),className:C("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",i?"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:()=>fe(true),className:C("flex-1 h-2 rounded-full overflow-hidden max-w-[120px] cursor-pointer hover:ring-2 hover:ring-white/20 transition-all",i?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:C("h-full rounded-full transition-all",f.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${f.progress||0}%`}})}),jsxs("span",{className:C("text-sm font-medium min-w-[40px]",i?"text-white":"text-gray-900"),children:[f.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Etiquetas":"Tags"}),jsx("span",{className:C("text-sm",i?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Vac\xEDo":"Empty"})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Link2,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Relaciones":"Relations"}),jsx("span",{className:C("text-sm",i?"text-[#6B7280]":"text-gray-400"),children:f.dependencies&&f.dependencies.length>0?`${f.dependencies.length} ${n==="es"?"dependencias":"dependencies"}`:n==="es"?"Vac\xEDo":"Empty"})]})]}),jsxs("div",{className:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsxs("button",{className:C("flex items-center gap-2 text-sm transition-colors",i?"text-[#9CA3AF] hover:text-white":"text-gray-500 hover:text-gray-900"),children:[jsx(FileText,{className:"w-4 h-4"}),n==="es"?"Agregar descripci\xF3n":"Add description"]}),jsxs("button",{className:C("flex items-center gap-2 text-sm mt-2 transition-colors",i?"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:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:C("text-sm font-semibold mb-3",i?"text-white":"text-gray-900"),children:n==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",i?"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:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:C("text-sm font-semibold mb-3",i?"text-white":"text-gray-900"),children:n==="es"?"Agregar subtarea":"Add subtask"}),f.subtasks&&f.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:f.subtasks.map(V=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:C("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",V.progress===100?"bg-green-500 border-green-500":i?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:V.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:C("text-sm",V.progress===100?"line-through text-[#6B7280]":i?"text-white":"text-gray-900"),children:V.name})]},V.id))}),jsxs("button",{className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",i?"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"?"Add Tarea":"Add Task"]})]}),jsxs("div",{className:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("h3",{className:C("text-sm font-semibold",i?"text-white":"text-gray-900"),children:n==="es"?"Listas de control":"Checklists"}),jsx("button",{className:C("p-1 rounded transition-colors",i?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:jsx(Plus,{className:"w-4 h-4"})})]}),jsxs("button",{className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",i?"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:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:C("text-sm font-semibold mb-3",i?"text-white":"text-gray-900"),children:n==="es"?"Adjuntos":"Attachments"}),jsxs("div",{className:C("border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer",i?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300"),children:[jsx(Upload,{className:C("w-6 h-6 mx-auto mb-2",i?"text-[#6B7280]":"text-gray-400")}),jsxs("p",{className:C("text-sm",i?"text-[#9CA3AF]":"text-gray-500"),children:[n==="es"?"Suelta tus archivos aqu\xED para ":"Drop your files here to ",jsx("span",{className:C("underline",i?"text-white":"text-gray-700"),children:n==="es"?"subir":"upload"})]})]})]})]})]}),jsxs("div",{className:C("w-[280px] border-l flex flex-col",i?"border-white/10 bg-[#141619]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:C("px-4 py-3 border-b flex items-center justify-between",i?"border-white/10":"border-gray-200"),children:jsx("span",{className:C("font-medium",i?"text-white":"text-gray-900"),children:n==="es"?"Actividad":"Activity"})}),jsx("div",{className:"flex-1 p-4 overflow-y-auto",children:jsxs("div",{className:C("text-sm text-center py-8",i?"text-[#6B7280]":"text-gray-400"),children:[jsx(MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),n==="es"?"Sin actividad reciente":"No recent activity"]})}),jsx("div",{className:C("p-3 border-t",i?"border-white/10":"border-gray-200"),children:jsx("div",{className:C("flex items-center gap-2 px-3 py-2 rounded-lg",i?"bg-white/5":"bg-white border border-gray-200"),children:jsx("input",{type:"text",placeholder:n==="es"?"Escribe un comentario...":"Write a comment...",className:C("flex-1 bg-transparent text-sm outline-none",i?"text-white placeholder-[#6B7280]":"text-gray-900 placeholder-gray-400")})})})]})]})]})}),jsx(AnimatePresence,{children:k&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>h(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:C("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",i?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:C("px-4 py-3 border-b flex items-center justify-between",i?"border-white/10":"border-gray-200"),children:[jsx("span",{className:C("font-medium",i?"text-white":"text-gray-900"),children:k.date.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"long",month:"long",day:"numeric"})}),jsx("button",{onClick:()=>h(null),className:C("p-1 rounded",i?"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:k.events.map(V=>jsxs("button",{onClick:()=>{h(null),g(V.task);},className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-left transition-colors",i?"hover:bg-white/5":"hover:bg-gray-50"),children:[jsx(tc,{task:V.task}),jsx("span",{className:C("text-sm truncate flex-1",i?"text-white":"text-gray-900"),children:V.title}),V.task.priority==="high"||V.task.priority==="urgent"?jsx(Flag,{className:"w-3.5 h-3.5 text-red-400"}):null]},V.id))})]})]})})]})}var ni={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"},si={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"},ii={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"},yn={dark:ni,light:si,neutral:ii};function oc(e){return yn[e]||yn.dark}function th({stack:e,cards:t,renderCard:a,onCardClick:r,onToggleExpand:o,onUnstack:s,onDeleteStack:l,className:c}){let[p,n]=useState(false),m=useMemo(()=>t.filter(u=>e.cardIds.includes(u.id)),[t,e.cardIds]),d=useMemo(()=>{let u=m.length,x=new Set(m.flatMap(k=>k.assignedUserIds||[])).size,f=m.map(k=>k.priority).filter(Boolean),g=new Set(m.flatMap(k=>k.labels||[])).size;return {totalCards:u,uniqueAssignees:x,priorities:f,labels:g}},[m]),i=()=>{o?.(e.id);};return jsxs("div",{className:C("card-stack",!e.isExpanded&&"card-stack-collapsed",c),onMouseEnter:()=>n(true),onMouseLeave:()=>n(false),style:{"--stack-color":e.color||"var(--color-accent-primary)"},children:[jsxs("div",{className:"card-stack-header",onClick:i,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:C("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:u=>{u.stopPropagation(),l?.(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:m.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:m.map(u=>jsxs("div",{className:"card-stack-card-wrapper",children:[a?jsx("div",{onClick:()=>r?.(u),children:a(u)}):jsxs("div",{className:"card-stack-default-card",onClick:()=>r?.(u),children:[jsx("h4",{children:u.title}),u.description&&jsxs("p",{children:[u.description.substring(0,100),"..."]})]}),jsx("button",{className:"card-stack-unstack-btn",onClick:x=>{x.stopPropagation(),s?.(e.id,u.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"})]})})]},u.id))})})]})}var sc={showIcons:true,showAvatars:true,groupByDay:true,useRelativeTime:true,compact:false};function yo(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 ic(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 lc({events:e,filter:t,onFilterChange:a,onClearFilter:r,onEventClick:o,selectedEventId:s,config:l,className:c}){let p=useMemo(()=>({...sc,...l}),[l]),[n,m]=useState(new Set),d=useRef(null),i=useMemo(()=>{if(!p.groupByDay)return [{date:null,events:e}];let h=new Map;return e.forEach(b=>{let y=b.timestamp.toISOString().split("T")[0],D=h.get(y);D?D.push(b):h.set(y,[b]);}),Array.from(h.entries()).sort((b,y)=>y[0].localeCompare(b[0])).map(([b,y])=>({date:new Date(b),events:y.sort((D,N)=>N.timestamp.getTime()-D.timestamp.getTime())}))},[e,p.groupByDay]),{uniqueUsers:u,uniqueTypes:x}=useMemo(()=>{let h=new Set,b=new Set;return e.forEach(y=>{h.add(y.userId),b.add(y.type);}),{uniqueUsers:Array.from(h),uniqueTypes:Array.from(b)}},[e]),f=h=>{m(b=>{let y=new Set(b);return y.has(h)?y.delete(h):y.add(h),y});},g=h=>{let y=new Date().getTime()-h.getTime(),D=Math.floor(y/6e4),N=Math.floor(y/36e5),A=Math.floor(y/864e5);return D<1?"just now":D<60?`${D}m ago`:N<24?`${N}h ago`:A<7?`${A}d ago`:h.toLocaleDateString()},k=useMemo(()=>{let h=0;return t.types&&t.types.length>0&&h++,t.users&&t.users.length>0&&h++,t.dateRange&&h++,t.searchTerm&&h++,h},[t]);return useEffect(()=>{if(s&&d.current){let h=d.current.querySelector(`[data-event-id="${s}"]`);h&&h.scrollIntoView({behavior:"smooth",block:"center"});}},[s]),e.length===0?jsxs("div",{className:C("history-timeline-empty",c),children:[jsx("div",{className:"history-timeline-empty-icon",children:"\u{1F4DC}"}),jsx("p",{className:"history-timeline-empty-text",children:"No history events yet"}),jsx("p",{className:"history-timeline-empty-subtext",children:"Changes to this card will appear here"})]}):jsxs("div",{className:C("history-timeline",p.compact&&"compact",c),children:[jsxs("div",{className:"history-timeline-filters",children:[jsxs("div",{className:"history-timeline-filter-group",children:[jsxs("select",{className:"history-timeline-filter-select",value:t.types?.[0]||"",onChange:h=>{let b=h.target.value;a({...t,types:b?[b]:void 0});},children:[jsx("option",{value:"",children:"All Events"}),x.map(h=>jsxs("option",{value:h,children:[vo(h)," ",h.replace("_"," ")]},h))]}),u.length>1&&jsxs("select",{className:"history-timeline-filter-select",value:t.users?.[0]||"",onChange:h=>{let b=h.target.value;a({...t,users:b?[b]:void 0});},children:[jsx("option",{value:"",children:"All Users"}),u.map(h=>jsx("option",{value:h,children:h},h))]}),jsx("input",{type:"text",className:"history-timeline-filter-search",placeholder:"Search history...",value:t.searchTerm||"",onChange:h=>a({...t,searchTerm:h.target.value})})]}),k>0&&jsxs("button",{className:"history-timeline-filter-clear",onClick:r,children:["Clear filters (",k,")"]})]}),jsx("div",{className:"history-timeline-container",ref:d,children:i.map(h=>jsxs("div",{className:"history-timeline-group",children:[p.groupByDay&&h.date&&jsxs("div",{className:"history-timeline-day-header",children:[jsx("span",{className:"history-timeline-day-date",children:h.date.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),jsxs("span",{className:"history-timeline-day-count",children:[h.events.length," events"]})]}),jsx("div",{className:"history-timeline-events",children:h.events.map((b,y)=>{let D=n.has(b.id),N=s===b.id,A=ic(b.type);return jsxs("div",{"data-event-id":b.id,className:C("history-timeline-event",D&&"expanded",N&&"selected"),onClick:()=>o?.(b),children:[jsxs("div",{className:"history-timeline-line",children:[jsx("div",{className:"history-timeline-dot",style:{backgroundColor:A},children:p.showIcons&&jsx("span",{className:"history-timeline-dot-icon",children:vo(b.type)})}),y<h.events.length-1&&jsx("div",{className:"history-timeline-connector",style:{borderColor:A}})]}),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&&b.userAvatar&&jsx("img",{src:b.userAvatar,alt:b.userName||b.userId,className:"history-timeline-event-avatar"}),jsxs("div",{className:"history-timeline-event-description",children:[jsx("span",{className:"history-timeline-event-user",children:b.userName||b.userId}),jsx("span",{className:"history-timeline-event-action",children:yo(b)})]})]}),jsx("div",{className:"history-timeline-event-time",children:p.useRelativeTime?g(b.timestamp):b.timestamp.toLocaleString()})]}),Object.keys(b.changes).length>0&&jsxs("button",{className:"history-timeline-event-toggle",onClick:v=>{v.stopPropagation(),f(b.id);},children:[D?"\u25BC":"\u25B6"," Show changes"]}),D&&jsxs("div",{className:"history-timeline-event-changes",children:[Object.entries(b.changes).map(([v,F])=>jsxs("div",{className:"history-timeline-event-change",children:[jsxs("span",{className:"history-timeline-event-change-key",children:[v,":"]}),jsxs("div",{className:"history-timeline-event-change-values",children:[jsx("span",{className:"history-timeline-event-change-from",children:JSON.stringify(F.from)}),jsx("span",{className:"history-timeline-event-change-arrow",children:"\u2192"}),jsx("span",{className:"history-timeline-event-change-to",children:JSON.stringify(F.to)})]})]},v)),b.metadata&&Object.keys(b.metadata).length>0&&jsxs("div",{className:"history-timeline-event-metadata",children:[jsx("div",{className:"history-timeline-event-metadata-title",children:"Additional Info:"}),Object.entries(b.metadata).map(([v,F])=>jsxs("div",{className:"history-timeline-event-metadata-item",children:[jsxs("span",{className:"history-timeline-event-metadata-key",children:[v,":"]}),jsx("span",{className:"history-timeline-event-metadata-value",children:JSON.stringify(F)})]},v))]})]})]})]},b.id)})})]},h.date?.toISOString()||"all"))})]})}function cc({replayState:e,events:t,onStartReplay:a,onStopReplay:r,onTogglePlayback:o,onPrevious:s,onNext:l,onGoToEvent:c,onSpeedChange:p,className:n}){let m=[.5,1,1.5,2,3],d=useMemo(()=>!e||t.length===0?null:t[e.currentIndex],[e,t]),i=useMemo(()=>!e||e.totalEvents===0?0:e.currentIndex/(e.totalEvents-1)*100,[e]);return t.length===0?jsxs("div",{className:C("history-replay-empty",n),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:C("history-replay",n),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&&yo(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:u=>c(parseInt(u.target.value))}),jsx("div",{className:"history-replay-progress-fill",style:{width:`${i}%`}}),jsx("div",{className:"history-replay-progress-markers",children:t.map((u,x)=>jsx("div",{className:C("history-replay-progress-marker",x===e.currentIndex&&"active"),style:{left:`${x/(e.totalEvents-1)*100}%`},onClick:()=>c(x),title:yo(u)},u.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:l,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:m.map(u=>jsxs("button",{className:C("history-replay-speed-btn",e.speed===u&&"active"),onClick:()=>p(u),children:[u,"x"]},u))})]}),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(u=>jsx("span",{className:"history-replay-card-preview-label-tag",children:u},u))})]})]})]})]}):jsxs("div",{className:C("history-replay-start",n),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 li(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 di(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 pc(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 mc(e){return ["blocks","blocked_by","depends_on","required_by","parent_of","child_of"].includes(e)}function ih(e,t,a,r,o,s=100){let l=e.map(p=>({...p,x:p.x??a/2+Math.random()*100-50,y:p.y??r/2+Math.random()*100-50,vx:0,vy:0})),c=new Map(l.map(p=>[p.id,p]));for(let p=0;p<s;p++){let n=1-p/s;l.forEach(m=>{let d=a/2,i=r/2;m.vx+=(d-m.x)*o.centerForce*n,m.vy+=(i-m.y)*o.centerForce*n,l.forEach(u=>{if(m.id===u.id)return;let x=m.x-u.x,f=m.y-u.y,g=Math.sqrt(x*x+f*f)||1,k=o.chargeStrength*n/(g*g);m.vx+=x/g*k,m.vy+=f/g*k;});}),t.forEach(m=>{let d=c.get(typeof m.source=="string"?m.source:m.source.id),i=c.get(typeof m.target=="string"?m.target:m.target.id);if(!d||!i)return;let u=i.x-d.x,x=i.y-d.y,f=Math.sqrt(u*u+x*x)||1,g=(f-o.linkDistance)/f*o.forceStrength*n;d.vx+=u*g,d.vy+=x*g,i.vx-=u*g,i.vy-=x*g;}),l.forEach(m=>{m.fx!==null&&m.fx!==void 0?(m.x=m.fx,m.vx=0):m.x+=m.vx,m.fy!==null&&m.fy!==void 0?(m.y=m.fy,m.vy=0):m.y+=m.vy,m.x=Math.max(o.nodeSize,Math.min(a-o.nodeSize,m.x)),m.y=Math.max(o.nodeSize,Math.min(r-o.nodeSize,m.y)),m.vx*=.9,m.vy*=.9;});}return l}function uc({nodes:e,edges:t,config:a,filter:r,onFilterChange:o,criticalPath:s,stats:l,onInteraction:c,className:p}){let n=useRef(null),[m,d]=useState([]),[i,u]=useState(null),[x,f]=useState(null),[g,k]=useState(null),[h,b]=useState(1),[y,D]=useState({x:0,y:0});useEffect(()=>{if(e.length===0)return;let P=ih(e,t,a.width,a.height,a,150);d(P);},[e,t,a]);let N=useCallback((P,H)=>{a.enableDragging&&(H.stopPropagation(),u(P));},[a.enableDragging]),A=useCallback(P=>{if(!i||!n.current)return;let X=n.current.getBoundingClientRect(),fe=(P.clientX-X.left-y.x)/h,ve=(P.clientY-X.top-y.y)/h;d(Re=>Re.map(Ue=>Ue.id===i?{...Ue,x:fe,y:ve,fx:fe,fy:ve}:Ue));},[i,h,y]),v=useCallback(()=>{u(null);},[]),F=useCallback((P,H)=>{H.stopPropagation(),c?.({type:"node-click",node:P,position:{x:H.clientX,y:H.clientY}});},[c]),T=useCallback((P,H)=>{H.stopPropagation(),c?.({type:"edge-click",edge:P,position:{x:H.clientX,y:H.clientY}});},[c]),w=useCallback(P=>{let H=m.find(X=>X.id===P);return H?{x:H.x,y:H.y}:{x:0,y:0}},[m]),B=useCallback(P=>{if(P.onCriticalPath)return "#ef4444";switch(a.colorScheme){case "status":return P.card.columnId==="done"?"#10b981":"#3b82f6";case "priority":let H=P.card.priority;return H==="URGENT"?"#ef4444":H==="HIGH"?"#f59e0b":H==="MEDIUM"?"#3b82f6":"#6b7280";case "assignee":return P.card.assigneeId?"#8b5cf6":"#6b7280";default:return "#3b82f6"}},[a.colorScheme]);return e.length===0?jsxs("div",{className:C("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:C("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:l.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:l.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:()=>b(P=>Math.min(P+.2,3)),children:"+"}),jsxs("span",{className:"relationships-graph-zoom-value",children:[Math.round(h*100),"%"]}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>b(P=>Math.max(P-.2,.5)),children:"\u2212"}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>{b(1),D({x:0,y:0});},children:"Reset"})]})]}),jsx("div",{className:"relationships-graph-legend",children:Array.from(new Set(t.map(P=>P.type))).map(P=>jsxs("div",{className:"relationships-graph-legend-item",children:[jsx("div",{className:"relationships-graph-legend-color",style:{background:li(P)}}),jsxs("span",{className:"relationships-graph-legend-label",children:[pc(P)," ",di(P)]})]},P))}),jsxs("svg",{ref:n,className:"relationships-graph-canvas",width:a.width,height:a.height,onMouseMove:A,onMouseUp:v,onMouseLeave:v,children:[jsxs("g",{transform:`translate(${y.x}, ${y.y}) scale(${h})`,children:[jsx("g",{className:"relationships-graph-edges",children:t.map(P=>{let H=w(typeof P.source=="string"?P.source:P.source.id),X=w(typeof P.target=="string"?P.target:P.target.id),fe=mc(P.type),ve=g===P.id,Re=P.onCriticalPath;return jsxs("g",{className:C("relationships-graph-edge",ve&&"hovered",Re&&"critical"),onMouseEnter:()=>k(P.id),onMouseLeave:()=>k(null),onClick:Ue=>T(P,Ue),children:[jsx("line",{x1:H.x,y1:H.y,x2:X.x,y2:X.y,stroke:li(P.type),strokeWidth:Re?a.edgeWidth*2:a.edgeWidth,strokeOpacity:ve?1:.6,markerEnd:fe?"url(#arrowhead)":void 0}),a.showEdgeLabels&&ve&&jsx("text",{x:(H.x+X.x)/2,y:(H.y+X.y)/2,className:"relationships-graph-edge-label",textAnchor:"middle",children:di(P.type)})]},P.id)})}),jsx("g",{className:"relationships-graph-nodes",children:m.map(P=>{let H=x===P.id,X=P.onCriticalPath;return jsxs("g",{className:C("relationships-graph-node",H&&"hovered",X&&"critical"),transform:`translate(${P.x}, ${P.y})`,onMouseDown:fe=>N(P.id,fe),onMouseEnter:()=>f(P.id),onMouseLeave:()=>f(null),onClick:fe=>F(P,fe),children:[jsx("circle",{r:X?a.nodeSize*1.2:a.nodeSize,fill:B(P),stroke:X?"#fbbf24":"#ffffff",strokeWidth:X?3:2,opacity:H?1:.9}),a.showLabels&&jsx("text",{y:a.nodeSize+20,className:"relationships-graph-node-label",textAnchor:"middle",children:P.card.title.length>20?P.card.title.substring(0,20)+"...":P.card.title})]},P.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 hc({isOpen:e,onClose:t,onPlanGenerated:a,onGeneratePlan:r,isLoading:o}){let[s,l]=useState(""),[c,p]=useState(false),[n,m]=useState(null),[d,i]=useState(null),u=useRef(null),x=c||o;useEffect(()=>{e&&u.current&&u.current.focus();},[e]),useEffect(()=>{let h=b=>{b.key==="Escape"&&!x&&f();};if(e)return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[e,x]);let f=()=>{x||(l(""),m(null),i(null),t());},g=async()=>{if(!(!s.trim()||x)){p(true),m(null),i(null);try{let h=await r(s.trim());i(h);}catch(h){m(h instanceof Error?h.message:"Failed to generate plan");}finally{p(false);}}},k=()=>{d&&(a(d),f());};return e?jsxs(at,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:f}),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:h=>h.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:f,disabled:x,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((h,b)=>jsx("div",{className:"px-3 py-1.5 rounded-lg bg-white/5 border border-white/20 text-sm text-white/80",children:h.title},b))})]}),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((h,b)=>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:h.title}),h.description&&jsx("p",{className:"text-xs text-white/60 mt-1 line-clamp-2",children:h.description})]}),h.priority&&jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${h.priority==="URGENT"?"bg-red-500/20 text-red-400":h.priority==="HIGH"?"bg-orange-500/20 text-orange-400":h.priority==="MEDIUM"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:h.priority})]})},b)),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:u,value:s,onChange:h=>l(h.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:x}),jsx("p",{className:"text-xs text-white/50 mt-2",children:"Be as specific as possible. Include features, technologies, and any special requirements."})]}),n&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:n}),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((h,b)=>jsx("button",{onClick:()=>l(h),disabled:x,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:h},b))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:x&&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:f,disabled:x,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:k,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all",style:{background:"linear-gradient(135deg, #10B981 0%, #059669 100%)",color:"#ffffff"},children:"Apply Plan to Board"}):jsx("button",{onClick:g,disabled:!s.trim()||x,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:x?"Generating...":"Generate Plan"})]})]})]})})]}):null}var ci={"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}},ch={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 ph(e,t,a){let r=ci[e];if(!r)throw new Error(`Unknown model: ${e}`);let o=t/1e3*r.costPer1kInput,s=a/1e3*r.costPer1kOutput;return o+s}function xo(e){return `$${e.toFixed(4)}`}var pi=class{constructor(){this.operations=[];this.listeners=[];}record(t){let a=ph(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,i)=>d+i.cost,0),s=a.reduce((d,i)=>d+i.inputTokens,0),l=a.reduce((d,i)=>d+i.outputTokens,0),c=a.filter(d=>d.success),p=a.reduce((d,i)=>d+i.duration,0),n={},m={};return a.forEach(d=>{n[d.feature]=(n[d.feature]||0)+1,m[d.feature]=(m[d.feature]||0)+d.cost;}),{totalOperations:r,totalCost:o,totalInputTokens:s,totalOutputTokens:l,operationsByFeature:n,costsByFeature:m,averageDuration:r>0?p/r:0,successRate:r>0?c.length/r:0}}getRecentOperations(t=10){return this.operations.slice(-t).reverse()}checkLimit(t,a="month"){let o={hobby:{month:50,day:5},pro:{month:500,day:50},enterprise:{month:2e3,day:200}}[t][a],s=new Date,l=new Date;a==="month"?l.setMonth(s.getMonth()-1):l.setDate(s.getDate()-1);let c=this.operations.filter(m=>m.timestamp>=l).length,p=Math.max(0,o-c),n=c/o*100;return {used:c,limit:o,remaining:p,percentUsed:n,isExceeded:c>=o}}subscribe(t){return this.listeners.push(t),()=>{let a=this.listeners.indexOf(t);a>-1&&this.listeners.splice(a,1);}}clear(){this.operations=[];}export(){return JSON.stringify(this.operations,null,2)}},Dr=new pi;function vc({isOpen:e,onClose:t,planTier:a="hobby"}){let[r,o]=useState(Dr.getStats()),[s,l]=useState(Dr.checkLimit(a));if(useEffect(()=>{if(!e)return;let p=setInterval(()=>{o(Dr.getStats()),l(Dr.checkLimit(a));},1e3);return ()=>clearInterval(p)},[e,a]),useEffect(()=>{let p=n=>{n.key==="Escape"&&t();};if(e)return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[e,t]),!e)return null;let c=Dr.getRecentOperations(5);return jsxs(at,{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:xo(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,n])=>{let m=r.costsByFeature[p]||0,d=r.totalOperations>0?n/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:[n," ops"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:xo(m)})]})]}),jsx("div",{className:"w-full h-1.5 bg-white/10 rounded-full overflow-hidden",children:jsx("div",{className:"h-full bg-blue-500",style:{width:`${d}%`}})})]},p)})})]}),jsxs("div",{children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-3",children:"Recent Operations"}),c.length===0?jsx("p",{className:"text-sm text-white/50 text-center py-8",children:"No operations yet. Start using AI features!"}):jsx("div",{className:"space-y-2",children:c.map(p=>jsxs("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsx("p",{className:"text-sm font-medium text-white/90 capitalize",children:p.feature.replace(/([A-Z])/g," $1").trim()}),jsxs("p",{className:"text-xs text-white/50 mt-0.5",children:[new Date(p.timestamp).toLocaleTimeString()," \u2022"," ",p.duration,"ms"]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-white/60",children:[p.inputTokens+p.outputTokens," tokens"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:xo(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 wc({isOpen:e,onClose:t,onTasksGenerated:a,onGenerateTasks:r,isLoading:o,projectName:s}){let[l,c]=useState(""),[p,n]=useState(""),[m,d]=useState(""),[i,u]=useState(false),[x,f]=useState(null),[g,k]=useState(null),[h,b]=useState(null),y=useRef(null),D=i||o;useEffect(()=>{e&&y.current&&y.current.focus();},[e]),useEffect(()=>{let T=w=>{w.key==="Escape"&&!D&&N();};if(e)return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[e,D]);let N=()=>{D||(c(""),n(""),d(""),f(null),k(null),b(null),t());},A=async()=>{if(!(!l.trim()||D)){u(true),f(null),k(null),b(null);try{let T=await r({prompt:l.trim(),projectName:s||"Mi Proyecto",startDate:p||void 0,endDate:m||void 0});k(T.tasks.tasks),b({from_cache:T.from_cache,tokens_used:T.tokens_used,mock_mode:T.mock_mode,similarity:T.similarity,tokens_saved:T.tokens_saved});}catch(T){f(T instanceof Error?T.message:"Failed to generate tasks");}finally{u(false);}}},v=()=>{g&&(a(g),N());};if(!e)return null;let F=h?.similarity?((h.similarity||0)*100).toFixed(0):"0";return jsxs(at,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:N}),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:T=>T.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:N,disabled:D,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:g?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:[h?.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"}),h?.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 (",F,"% 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:[h?.tokens_used||0," tokens"]}),h?.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:[h.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:[g.length," tasks"]})]}),jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:g.map((T,w)=>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:["#",w+1]}),jsx("p",{className:"text-sm font-medium text-white/90",children:T.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"})]}),T.start," \u2192 ",T.end]}),jsxs("span",{children:[T.duration," days"]}),T.dependencies.length>0&&jsxs("span",{className:"text-blue-400",children:["Depends: ",T.dependencies.join(", ")]})]})]}),jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${T.priority==="high"?"bg-red-500/20 text-red-400":T.priority==="medium"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:T.priority})]})},T.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:y,value:l,onChange:T=>c(T.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:D}),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:T=>n(T.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:D})]}),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:m,onChange:T=>d(T.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:D})]})]}),x&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:x}),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((T,w)=>jsx("button",{onClick:()=>c(T),disabled:D,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:T},w))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:D&&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:N,disabled:D,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"}),g?jsx("button",{onClick:v,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:A,disabled:!l.trim()||D,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:D?"Generating...":"Generate Tasks"})]})]})]})})]})}function kn({initialBoard:e,onPersist:t}){let[a,r]=useState(e),o=useCallback(g=>{t&&Po(()=>Promise.resolve(t(g)),{maxAttempts:3,initialDelay:1e3,onRetry:(k,h,b)=>{console.warn(`Retry attempt ${h} after ${b}ms: ${k.message}`);}}).then(k=>{k.success||console.error(`Failed to persist board after ${k.attempts} attempts:`,k.error);});},[t]),s=useCallback(async(g,k,h)=>{r(b=>{let y=b.cards.find(T=>T.id===g);if(!y)return b;let D=y.columnId,N={...y,columnId:k,position:h},A=b.cards.map(T=>T.id===g?N:T),v=b.columns.map(T=>{if(T.id===D)return {...T,cardIds:T.cardIds.filter(w=>w!==g)};if(T.id===k){let w=A.filter(B=>B.columnId===k).sort((B,P)=>B.position-P.position);return {...T,cardIds:w.map(B=>B.id)}}return T}),F={...b,cards:A,columns:v};return o(F),F});},[o]),l=useCallback(async(g,k)=>{r(h=>{let b=h.cards.map(D=>D.id===g?{...D,...k}:D),y={...h,cards:b};return o(y),y});},[o]),c=useCallback(async g=>{let k=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(h=>{let b={...g,id:k},y=h.columns.map(N=>N.id===g.columnId?{...N,cardIds:[...N.cardIds,k]}:N),D={...h,cards:[...h.cards,b],columns:y};return o(D),D});},[o]),p=useCallback(async g=>{r(k=>{let h=k.cards.find(N=>N.id===g);if(!h)return k;let b=k.cards.filter(N=>N.id!==g),y=k.columns.map(N=>N.id===h.columnId?{...N,cardIds:N.cardIds.filter(A=>A!==g)}:N),D={...k,cards:b,columns:y};return o(D),D});},[o]),n=useCallback(async g=>{let k=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(h=>{let b={...g,id:k,cardIds:[]},y={...h,columns:[...h.columns,b]};return o(y),y});},[o]),m=useCallback(async(g,k)=>{r(h=>{let b=h.columns.map(D=>D.id===g?{...D,...k}:D),y={...h,columns:b};return o(y),y});},[o]),d=useCallback(async g=>{r(k=>{let h=k.cards.filter(D=>D.columnId!==g),b=k.columns.filter(D=>D.id!==g),y={...k,cards:h,columns:b};return o(y),y});},[o]),i=useCallback(g=>{let k=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return c(g),k},[c]),u=useCallback(g=>{let k=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return n(g),k},[n]),x=useCallback(()=>{r(g=>{let k={...g,cards:[],columns:[]};return o(k),k});},[o]);return {board:a,callbacks:{onCardMove:s,onCardUpdate:l,onCardCreate:c,onCardDelete:p,onColumnCreate:n,onColumnUpdate:m,onColumnDelete:d},setBoard:r,helpers:{addCard:i,addColumn:u,deleteCard:p,deleteColumn:d,clearBoard:x}}}function Tc({initialData:e,availableUsers:t=[],onSave:a}){let{board:r,callbacks:o,helpers:s}=kn({initialBoard:e,onPersist:a}),l=useMemo(()=>({addCard:(p,n,m={})=>{s.addCard({title:n,columnId:p,position:r.cards.filter(d=>d.columnId===p).length,...m});},addColumn:(p,n)=>{let m=r.columns.length>0?Math.max(...r.columns.map(d=>d.position)):0;s.addColumn({title:p,position:n??m+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:l}}var ko={dateFilter:"all",priorities:[],assignees:[],labels:[],columns:[],search:""},Nc={by:"none",order:"asc"};function Sc({initialFilters:e={},initialSort:t={},currentUserId:a}={}){let[r,o]=useState({...ko,...e}),[s,l]=useState({...Nc,...t}),c=useCallback(f=>{o(g=>({...g,...f}));},[]),p=useCallback(f=>{l(g=>({...g,...f}));},[]),n=useCallback(()=>{o(ko),l(Nc);},[]),m=useCallback(()=>{a&&o({...ko,assignees:[a]});},[a]),d=useCallback(()=>{o({...ko,dateFilter:"overdue"});},[]),i=useCallback(()=>{o({...ko,priorities:["HIGH","URGENT"]});},[]),u=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]),x=useCallback(f=>{let g=[...f];if(r.search){let k=r.search.toLowerCase();g=g.filter(h=>h.title.toLowerCase().includes(k)||h.description?.toLowerCase().includes(k));}if(r.dateFilter!=="all"){let k=new Date,h=k.getFullYear(),b=String(k.getMonth()+1).padStart(2,"0"),y=String(k.getDate()).padStart(2,"0"),D=`${h}-${b}-${y}`;g=g.filter(N=>{if(!N.endDate&&!N.dueDate)return false;let A=N.endDate||N.dueDate;if(!A)return false;let v;if(typeof A=="string")v=A.split("T")[0]||A;else {let F=A.getUTCFullYear(),T=String(A.getUTCMonth()+1).padStart(2,"0"),w=String(A.getUTCDate()).padStart(2,"0");v=`${F}-${T}-${w}`;}switch(r.dateFilter){case "overdue":return v<D;case "today":return v===D;case "this-week":let F=new Date(D+"T00:00:00"),T=new Date(v+"T00:00:00"),w=new Date(F);return w.setDate(w.getDate()+7),T>=F&&T<=w;case "custom":if(r.dateRange){let B=typeof A=="string"?new Date(A):A;return B>=r.dateRange.start&&B<=r.dateRange.end}return true;default:return true}});}return r.priorities.length>0&&(g=g.filter(k=>k.priority&&r.priorities.includes(k.priority))),r.assignees.length>0&&(g=g.filter(k=>(k.assignedUserIds||(k.assigneeId?[k.assigneeId]:[])).some(b=>r.assignees.includes(b)))),r.labels.length>0&&(g=g.filter(k=>k.labels&&k.labels.some(h=>r.labels.includes(h)))),r.columns.length>0&&(g=g.filter(k=>r.columns.includes(k.columnId))),s.by!=="none"&&g.sort((k,h)=>{let b=0;switch(s.by){case "created":let y=k.createdAt?new Date(k.createdAt).getTime():0,D=h.createdAt?new Date(h.createdAt).getTime():0;b=y-D;break;case "priority":let N={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},A=N[k.priority||"LOW"],v=N[h.priority||"LOW"];b=A-v;break;case "dueDate":let F=k.endDate||k.dueDate,T=h.endDate||h.dueDate;if(!F)return 1;if(!T)return -1;let w=typeof F=="string"?new Date(F).getTime():F.getTime(),B=typeof T=="string"?new Date(T).getTime():T.getTime();b=w-B;break;case "title":b=k.title.localeCompare(h.title);break;case "estimate":let P=k.estimatedTime||0,H=h.estimatedTime||0;b=P-H;break;default:b=0;}return s.order==="asc"?b:-b}),g},[r,s]);return {filters:r,sort:s,setFilters:c,setSort:p,resetFilters:n,filterMyTasks:m,filterOverdue:d,filterHighPriority:i,applyFilters:x,hasActiveFilters:u}}var Pc,Mc;if(typeof window<"u")try{let e=No("ai");Pc=e.generateObject,Mc=e.generateText;}catch{}function Ac(e={}){let[t,a]=useState(false),[r,o]=useState(null),s=!!(Pc&&Mc&&e.apiKey),l=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(i){let u=i instanceof Error?i:new Error("Failed to generate plan");throw o(u),u}finally{a(false);}},[s]),c=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Suggesting assignee for:",d.title),{userId:"user-123",confidence:.85,reasoning:"Based on past performance and expertise"}}catch(i){let u=i instanceof Error?i:new Error("Failed to suggest assignee");throw o(u),u}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(i){let u=i instanceof Error?i:new Error("Failed to predict risks");throw o(u),u}finally{a(false);}},[s]),n=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(i){let u=i instanceof Error?i:new Error("Failed to generate subtasks");throw o(u),u}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("Estimating effort for:",d.title),{hours:8,confidence:.75}}catch(i){let u=i instanceof Error?i:new Error("Failed to estimate effort");throw o(u),u}finally{a(false);}},[s]);return {onGeneratePlan:l,onSuggestAssignee:c,onPredictRisks:p,onGenerateSubtasks:n,onEstimateEffort:m,isAvailable:s,isLoading:t,error:r}}function ui(){let[e,t]=useState(()=>selectionStore.getState());useEffect(()=>selectionStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{selectionStore.setState(r);},[]);return [e,a]}function Ic(e){let{cards:t}=e,[a,r]=ui(),o=useCallback(d=>a.selectedCardIds.includes(d),[a.selectedCardIds]),s=useCallback((d,i)=>{if(!i){r({selectedCardIds:[d],lastSelectedCardId:d});return}let u=i.ctrlKey||i.metaKey,x=i.shiftKey;if(u)a.selectedCardIds.includes(d)?r({selectedCardIds:a.selectedCardIds.filter(f=>f!==d),lastSelectedCardId:a.lastSelectedCardId}):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});else if(x&&a.lastSelectedCardId){let f=t.find(k=>k.id===d),g=t.find(k=>k.id===a.lastSelectedCardId);if(f&&g&&f.columnId===g.columnId){let k=t.filter(v=>v.columnId===f.columnId).sort((v,F)=>v.position-F.position),h=k.findIndex(v=>v.id===a.lastSelectedCardId),b=k.findIndex(v=>v.id===d),[y,D]=h<b?[h,b]:[b,h],N=k.slice(y,D+1).map(v=>v.id),A=Array.from(new Set([...a.selectedCardIds,...N]));r({selectedCardIds:A,lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});},[t,a,r]),l=useCallback(d=>{r({selectedCardIds:a.selectedCardIds.filter(i=>i!==d),lastSelectedCardId:a.lastSelectedCardId});},[a,r]),c=useCallback(()=>{r({selectedCardIds:[],lastSelectedCardId:null});},[r]),p=useCallback(()=>{r({selectedCardIds:t.map(d=>d.id),lastSelectedCardId:t[t.length-1]?.id||null});},[t,r]),n=useCallback(d=>{a.selectedCardIds.includes(d)?l(d):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});},[a,l,r]),m=useCallback(()=>t.filter(d=>a.selectedCardIds.includes(d.id)),[t,a.selectedCardIds]);return {selectedCardIds:a.selectedCardIds,lastSelectedCardId:a.lastSelectedCardId,isCardSelected:o,selectCard:s,deselectCard:l,clearSelection:c,selectAll:p,toggleCard:n,getSelectedCards:m}}var Lc={enableAutoStacking:true,autoStackConfidenceThreshold:.7,minCardsPerStack:2,enableManualStacking:true,showStackSummaries:true,animationDuration:200};function Fc(e){let{cards:t,config:a,aiService:r}=e,o=useMemo(()=>({...Lc,...a}),[a]),[s,l]=useState([]),c=useCallback((f,g,k,h,b)=>{if(g.length<o.minCardsPerStack){console.warn(`Cannot create stack: minimum ${o.minCardsPerStack} cards required`);return}let y={id:`stack-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:f,cardIds:g,columnId:k,strategy:h,color:b,isExpanded:true,position:s.filter(D=>D.columnId===k).length,createdAt:new Date};l(D=>[...D,y]);},[o.minCardsPerStack,s]),p=useCallback(f=>{l(g=>g.filter(k=>k.id!==f));},[]),n=useCallback(f=>{l(g=>g.map(k=>k.id===f?{...k,isExpanded:!k.isExpanded}:k));},[]),m=useCallback((f,g)=>{l(k=>k.map(h=>h.id===f&&!h.cardIds.includes(g)?{...h,cardIds:[...h.cardIds,g]}:h));},[]),d=useCallback((f,g)=>{l(k=>k.map(h=>{if(h.id===f){let b=h.cardIds.filter(y=>y!==g);return b.length<o.minCardsPerStack?null:{...h,cardIds:b}}return h}).filter(h=>h!==null));},[o.minCardsPerStack]),i=useCallback(f=>s.filter(g=>g.columnId===f).sort((g,k)=>g.position-k.position),[s]),u=useCallback(async f=>{let g=t.filter(D=>D.columnId===f);if(g.length<o.minCardsPerStack*2)return [];let k=[],h=new Map;g.forEach(D=>{D.labels&&D.labels.length>0&&D.labels.forEach(N=>{h.has(N)||h.set(N,[]),h.get(N).push(D);});}),h.forEach((D,N)=>{D.length>=o.minCardsPerStack&&k.push({stack:{title:`\u{1F4CC} ${N}`,cardIds:D.map(A=>A.id),columnId:f,strategy:"labels",color:"#3b82f6"},reason:`${D.length} cards with label "${N}"`,confidence:.85});});let b=new Map;g.forEach(D=>{D.assignedUserIds&&D.assignedUserIds.length>0&&D.assignedUserIds.forEach(N=>{b.has(N)||b.set(N,[]),b.get(N).push(D);});}),b.forEach((D,N)=>{D.length>=o.minCardsPerStack&&k.push({stack:{title:`\u{1F464} Assigned to user-${N.slice(-4)}`,cardIds:D.map(A=>A.id),columnId:f,strategy:"assignee",color:"#8b5cf6"},reason:`${D.length} cards assigned to the same user`,confidence:.8});});let y=new Map;if(g.forEach(D=>{D.priority&&(y.has(D.priority)||y.set(D.priority,[]),y.get(D.priority).push(D));}),y.forEach((D,N)=>{if(D.length>=o.minCardsPerStack){let A={low:"\u{1F7E2}",medium:"\u{1F7E1}",high:"\u{1F534}",urgent:"\u{1F6A8}"}[N.toLowerCase()]||"\u26AA";k.push({stack:{title:`${A} ${N} Priority`,cardIds:D.map(v=>v.id),columnId:f,strategy:"priority",color:N==="high"||N==="urgent"?"#ef4444":"#10b981"},reason:`${D.length} cards with ${N} priority`,confidence:.75});}}),r&&o.enableAutoStacking)for(let D of g){let A=(await r.findSimilar(D,g)).filter(v=>v.similarity>=o.autoStackConfidenceThreshold);if(A.length>=o.minCardsPerStack-1){let v=[D.id,...A.map(T=>T.card.id)],F=A.reduce((T,w)=>T+w.similarity,0)/A.length;k.push({stack:{title:`\u2728 Similar to "${D.title.substring(0,30)}${D.title.length>30?"...":""}"`,cardIds:v,columnId:f,strategy:"ai-similarity",color:"#f59e0b"},reason:`AI detected ${A.length+1} similar tasks`,confidence:F});}}return k.filter(D=>D.confidence>=o.autoStackConfidenceThreshold).sort((D,N)=>N.confidence-D.confidence).slice(0,5)},[t,o,r]),x=useCallback(f=>{c(f.stack.title,f.stack.cardIds,f.stack.columnId,f.stack.strategy,f.stack.color);},[c]);return useEffect(()=>{o.enableAutoStacking&&s.length===0&&new Set(t.map(g=>g.columnId)).forEach(async g=>{let k=await u(g),h=k[0];k.length>0&&h&&h.confidence>=.9&&x(h);});},[]),{stacks:s,createStack:c,deleteStack:p,toggleStack:n,addToStack:m,removeFromStack:d,getStacksForColumn:i,getSuggestions:u,applySuggestion:x,config:o}}var Bc=createContext(null);function Rc({children:e,initialData:t,onStateChange:a}){let r=useRef();if(!r.current){let s=new Map,l=new Map;t?.columns?.forEach(p=>{let{Column:n}=No("@libxai/core");s.set(p.id,new n(p));}),t?.cards?.forEach(p=>{let{Card:n}=No("@libxai/core");l.set(p.id,new n(p));});let c=null;if(t?.board){let{Board:p}=No("@libxai/core");c=new p(t.board);}r.current=new BoardStore({board:c,columns:s,cards:l});}let o=r.current;return useEffect(()=>{if(a)return o.subscribeAll(s=>{a(o.getState());})},[o,a]),jsx(Bc.Provider,{value:{store:o},children:e})}function wn(){let e=useContext(Bc);if(!e)throw new Error("useBoardStore must be used within BoardProvider");return e.store}function Co(){let e=wn(),[t,a]=useState(e.getBoard()),[r,o]=useState(e.getAllColumns()),[s,l]=useState(e.getAllCards());useEffect(()=>e.subscribeAll(()=>{a(e.getBoard()),o(e.getAllColumns()),l(e.getAllCards());}),[e]);let c=useCallback(h=>{e.updateBoard(h);},[e]),p=useCallback(h=>{e.addColumn(h);},[e]),n=useCallback((h,b)=>{e.updateColumn(h,b);},[e]),m=useCallback(h=>{e.deleteColumn(h);},[e]),d=useCallback(h=>e.getColumn(h),[e]),i=useCallback(h=>{e.addCard(h);},[e]),u=useCallback((h,b)=>{e.updateCard(h,b);},[e]),x=useCallback(h=>{e.deleteCard(h);},[e]),f=useCallback((h,b,y)=>{e.moveCard(h,b,y);},[e]),g=useCallback(h=>e.getCard(h),[e]),k=useCallback(h=>e.getCardsByColumn(h),[e]);return {board:t,columns:r,cards:s,updateBoard:c,addColumn:p,updateColumn:n,deleteColumn:m,getColumn:d,addCard:i,updateCard:u,deleteCard:x,moveCard:f,getCard:g,getCardsByColumn:k}}function zc(e){let{cards:t}=Co();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 $c(e="position",t="asc"){let{cards:a}=Co();return useMemo(()=>[...a].sort((o,s)=>{let l=0;switch(e){case "title":l=o.title.localeCompare(s.title);break;case "priority":{let c={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},p=o.priority?c[o.priority]:0,n=s.priority?c[s.priority]:0;l=p-n;break}case "createdAt":l=o.createdAt.getTime()-s.createdAt.getTime();break;case "updatedAt":l=o.updatedAt.getTime()-s.updatedAt.getTime();break;case "position":l=o.position-s.position;break}return t==="asc"?l:-l}),[a,e,t])}var Cn=class{constructor(){this.plugins=new Map;this.enabled=new Set;this.config=new Map;this.context=null;this.pluginLogger=Hi.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 l=s[t];if(typeof l=="function")try{let c=await Promise.resolve(l.apply(s,a));c!==void 0&&(o=c,a[0]=c);}catch(c){this.pluginLogger.error(`Plugin hook failed: ${s.id}.${t}`,c,{plugin:s.id,hook:t});}}return o}async executeHookParallel(t,a){let r=[];for(let o of this.plugins.values()){if(!this.enabled.has(o.id))continue;let s=o[t];typeof s=="function"&&r.push(Promise.resolve(s.apply(o,a)).catch(l=>{this.pluginLogger.error(`Plugin hook failed: ${o.id}.${t}`,l,{plugin:o.id,hook:t});}));}await Promise.all(r);}},Eh=new Cn;function Wc({items:e,height:t,estimateSize:a,renderItem:r,className:o="",overscan:s=5,horizontal:l=false,gap:c=0,getItemKey:p}){let n=useRef(null),m=useVirtualizer({count:e.length,getScrollElement:()=>n.current,estimateSize:()=>a,overscan:s,horizontal:l,gap:c}),d=m.getVirtualItems(),i={height:typeof t=="number"?`${t}px`:t,width:"100%",overflow:"auto",position:"relative"},u=l?{width:`${m.getTotalSize()}px`,height:"100%",position:"relative"}:{height:`${m.getTotalSize()}px`,width:"100%",position:"relative"};return jsx("div",{ref:n,style:i,className:o,children:jsx("div",{style:u,children:d.map(x=>{let f=e[x.index];if(!f)return null;let g=p?p(f,x.index):x.index,k={position:"absolute",top:l?0:x.start,left:l?x.start:0,width:l?x.size:"100%",height:l?"100%":x.size};return jsx("div",{style:k,"data-index":x.index,children:r(f,x.index)},g)})})})}function Hc(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 _c({items:e,height:t,width:a="100%",estimateColumnWidth:r,renderColumn:o,className:s="",overscan:l=3,gap:c=16,getItemKey:p,horizontal:n=true}){let m=useRef(null),d=useVirtualizer({horizontal:n,count:e.length,getScrollElement:()=>m.current,estimateSize:()=>r,overscan:l,gap:c}),i=d.getVirtualItems(),u={height:typeof t=="number"?`${t}px`:t,width:typeof a=="number"?`${a}px`:a,overflow:"auto",position:"relative"},x={width:`${d.getTotalSize()}px`,height:"100%",position:"relative"};return jsx("div",{ref:m,style:u,className:s,children:jsx("div",{style:x,children:i.map(f=>{let g=e[f.index];if(!g)return null;let k=p?p(g,f.index):f.index,h={position:"absolute",top:0,left:f.start,width:f.size,height:"100%"};return jsx("div",{style:h,"data-index":f.index,children:o(g,f.index)},k)})})})}function Vc(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 jc(e,t=10){return e>t}var bi={none:0,xs:4,sm:8,md:12,lg:16,xl:20,"2xl":24,"3xl":32,"4xl":40,"5xl":48,"6xl":64},yi={none:0,sm:4,md:8,lg:12,xl:16,"2xl":20,full:9999},vi={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48},xi={light:300,normal:400,medium:500,semibold:600,bold:700,extrabold:800},ki={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},wi={base:0,dropdown:1e3,sticky:1020,fixed:1030,modalBackdrop:1040,modal:1050,popover:1060,tooltip:1070},Ci={instant:0,fastest:75,faster:100,fast:150,normal:200,slow:300,slower:400,slowest:500},Ti={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)"},Di={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)"},Ni={0:0,5:.05,10:.1,20:.2,30:.3,40:.4,50:.5,60:.6,70:.7,80:.8,90:.9,100:1},Si={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}},Ei={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}},Tn={spacing:bi,borderRadius:yi,fontSize:vi,fontWeight:xi,lineHeight:ki,zIndex:wi,duration:Ci,easing:Ti,shadows:Di,opacity:Ni,kanban:Si,gantt:Ei};function Kc(e,t,a){return e[t]??a}function Pi(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)?Pi(o,s,a):(typeof o=="string"||typeof o=="number")&&(a[s]=o);}return a}function Ah(e){return typeof e=="number"?e>0&&e<1e3?`${e}px`:e.toString():e}function Mi(e="asakaa"){let t=Pi(Tn),a=[];for(let[r,o]of Object.entries(t)){let s=`--${e}-${r}`,l=Ah(o);a.push(` ${s}: ${l};`);}return `:root {
|
|
390
390
|
${a.join(`
|
|
391
391
|
`)}
|
|
392
|
-
}`}function
|
|
392
|
+
}`}function To(e,t="asakaa"){let a=[],r=Pi(e);for(let[o,s]of Object.entries(r)){let l=`--${t}-color-${o}`;a.push(` ${l}: ${s};`);}return `:root {
|
|
393
393
|
${a.join(`
|
|
394
394
|
`)}
|
|
395
|
-
}`}var
|
|
395
|
+
}`}var Dn={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"}},Ai={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"}},Ii={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 Li(e=Dn,t="asakaa"){let a=Mi(t),r=To(e,t);return `${a}
|
|
396
396
|
|
|
397
|
-
${r}`}function
|
|
397
|
+
${r}`}function Yc(){return `/**
|
|
398
398
|
* ASAKAA Design Tokens
|
|
399
399
|
* Auto-generated from design-tokens.ts
|
|
400
400
|
* Do not edit this file directly
|
|
401
401
|
*/
|
|
402
402
|
|
|
403
|
-
${
|
|
403
|
+
${Li(Dn)}
|
|
404
404
|
|
|
405
405
|
/* Light theme */
|
|
406
406
|
[data-theme="light"] {
|
|
407
|
-
${
|
|
407
|
+
${To(Ai,"asakaa").split(`
|
|
408
408
|
`).slice(1,-1).join(`
|
|
409
409
|
`)}
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
/* Neutral theme */
|
|
413
413
|
[data-theme="neutral"] {
|
|
414
|
-
${
|
|
414
|
+
${To(Ii,"asakaa").split(`
|
|
415
415
|
`).slice(1,-1).join(`
|
|
416
416
|
`)}
|
|
417
417
|
}
|
|
418
|
-
`}var
|
|
419
|
-
export{
|
|
418
|
+
`}var Ih=({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 qc({showLabels:e=true,compact:t=false,className:a=""}){let{theme:r,setTheme:o,themes:s}=$r();return jsx("div",{className:`theme-switcher ${t?"theme-switcher--compact":""} ${a}`,children:Object.entries(s).map(([l,c])=>{let p=l,n=p===r;return jsxs("button",{onClick:()=>o(p),className:`theme-switcher__button ${n?"theme-switcher__button--active":""}`,"aria-label":`Switch to ${c.displayName} theme`,"aria-pressed":n,title:c.displayName,children:[jsx("span",{className:"theme-switcher__icon","aria-hidden":"true",children:jsx(Ih,{theme:p})}),e&&!t&&jsx("span",{className:"theme-switcher__label",children:c.displayName})]},p)})})}
|
|
419
|
+
export{vc as AIUsageDashboard,ch as AI_FEATURES,ci as AI_MODELS,_n as AddCardButton,Gn as AddColumnButton,Ua as AttachmentUploader,Rc as BoardProvider,Wo as BulkOperationsToolbar,os as BurnDownChart,rc as CalendarBoard,_a as Card,Xn as CardDetailModal,ts as CardDetailModalV2,cc as CardHistoryReplay,lc as CardHistoryTimeline,uc as CardRelationshipsGraph,th as CardStack,ps as CardTemplateSelector,Pn as CircuitBreaker,Lr as Column,nn as ColumnManager,Kn as CommandPalette,fs as ConfigMenu,Hr as ContextMenu,io as DEFAULT_SHORTCUTS,cs as DEFAULT_TEMPLATES,Jr as DateRangePicker,Qr as DependenciesSelector,Jo as DependencyLine,ns as DistributionCharts,On as EditableColumnTitle,Fr as ErrorBoundary,us as ExportImportModal,gs as FilterBar,Od as GANTT_AI_SYSTEM_PROMPT,on as GanttAIAssistant,Rd as GanttBoard,Wr as GanttI18nContext,Qo as GanttMilestone,jo as GanttToolbar,wc as GenerateGanttTasksDialog,hc as GeneratePlanModal,ls as GroupBySelector,Qa as KanbanBoard,Wn as KanbanToolbar,ro as KanbanViewAdapter,ds as KeyboardShortcutsHelp,qd as ListView,wt as MenuIcons,Cn as PluginManager,mr as PrioritySelector,dh as RATE_LIMITS,ss as SwimlaneBoardView,Qn as TagBadge,Fl as TagList,Rr as TagPicker,Yo as TaskBar,rn as TaskFormModal,Ko as TaskGrid,vs as ThemeModal,Xl as ThemeProvider,qc as ThemeSwitcher,tn as Timeline,gr as UserAssignmentSelector,rs as VelocityChart,_c as VirtualGrid,Wc as VirtualList,Dr as aiUsageTracker,yi as borderRadius,Eo as calculatePosition,ni as calendarDarkTheme,Zs as calendarEnTranslations,Qs as calendarEsTranslations,si as calendarLightTheme,ii as calendarNeutralTheme,yn as calendarThemes,un as calendarTranslations,ln as cardToGanttTask,_d as cardsToGanttTasks,C as cn,Sl as createKanbanView,bp as createRetryWrapper,hs as darkTheme,Dn as darkTokenTheme,Go as defaultTheme,Tn as designTokens,Ci as duration,Ti as easing,Yc as exportTokensToCSS,Ya as findTaskByName,vi as fontSize,xi as fontWeight,xo as formatCost,Vo as ganttEnTranslations,Zl as ganttEsTranslations,Gd as ganttTaskToCardUpdate,_e as ganttThemes,Ei as ganttTokens,xs as ganttTranslations,se as ganttUtils,Mi as generateCSSVariables,Li as generateCompleteCSS,up as generateInitialPositions,zd as generateTasksContext,To as generateThemeVariables,oc as getCalendarTheme,bo as getCalendarTranslations,Xd as getListViewTheme,Ys as getListViewTranslations,Jd as getMonthNames,Kc as getToken,Ql as getTranslations,Zd as getWeekdayNames,Si as kanbanTokens,bs as lightTheme,Ai as lightTokenTheme,ki as lineHeight,qs as listViewDarkTheme,js as listViewEnTranslations,Ks as listViewEsTranslations,Xs as listViewLightTheme,Js as listViewNeutralTheme,mn as listViewThemes,dn as listViewTranslations,gn as mergeCalendarTranslations,cn as mergeListViewTranslations,ks as mergeTranslations,ys as neutralTheme,Ii as neutralTokenTheme,Ni as opacity,Wd as parseLocalCommand,Gs as parseNaturalDate,_s as parseNaturalDuration,Vs as parseProgress,Ud as parseStatus,Eh as pluginManager,hp as retrySyncOperation,Po as retryWithBackoff,Di as shadows,jc as shouldVirtualizeGrid,bi as spacing,vr as themes,Ac as useAI,Tc as useBoard,Co as useBoardCore,wn as useBoardStore,Fc as useCardStacking,$n as useDragState,zc as useFilteredCards,Sc as useFilters,lo as useGanttI18n,kn as useKanbanState,Kl as useKeyboardShortcuts,Ic as useMultiSelect,ui as useSelectionState,$c as useSortedCards,$r as useTheme,Vc as useVirtualGrid,Hc as useVirtualList,Hd as validateAIResponse,Vn as withErrorBoundary,Ao as wouldCreateCircularDependency,wi as zIndex};//# sourceMappingURL=index.js.map
|
|
420
420
|
//# sourceMappingURL=index.js.map
|