@object-ui/plugin-gantt 17.6.0 → 17.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("sonner"),require("@objectstack/spec/ui"),require("@object-ui/i18n"),require("@object-ui/plugin-detail"),require("@object-ui/components"),require("@object-ui/fields"),require("lucide-react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/core`,`@object-ui/react`,`sonner`,`@objectstack/spec/ui`,`@object-ui/i18n`,`@object-ui/plugin-detail`,`@object-ui/components`,`@object-ui/fields`,`lucide-react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginGantt={},e.React,e.ObjectUICore,e.ObjectUIReact,e.sonner,e._objectstack_spec_ui,e._object_ui_i18n,e._object_ui_plugin_detail,e.ObjectUIComponents,e._object_ui_fields,e.LucideReact,e.react_jsx_runtime))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var f=Object.create,p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,g=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,v=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=h(t),a=0,o=i.length,s;a<o;a++)s=i[a],!_.call(e,s)&&s!==n&&p(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=m(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:f(g(e)),v(t||!e||!e.__esModule||!_.call(e,`default`)?p(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);var y=864e5,ee=e=>e.toISOString().slice(0,10);function te(e,t){if(t.skipWeekends){let t=e.getUTCDay();if(t===0||t===6)return!1}return!(t.holidays&&t.holidays.has(ee(e)))}function b(e){let t=new Date(e);return t.setUTCHours(0,0,0,0),t}function x(e,t){let n=b(e);for(;!te(n,t);)n=new Date(n.getTime()+y);return n.getTime()}function S(e,t,n){if(t<=e)return 0;let r=0,i=b(e),a=b(t).getTime();for(;i.getTime()<a;)te(i,n)&&r++,i=new Date(i.getTime()+y);return r}function C(e,t,n){if(t<=0)return b(e).getTime();let r=b(e),i=t;for(;i>0;)te(r,n)&&i--,r=new Date(r.getTime()+y);return r.getTime()}function w(e,t,n){if(t<=0)return b(e).getTime();let r=b(e),i=t;for(;i>0;)r=new Date(r.getTime()-y),te(r,n)&&i--;return r.getTime()}var T=e=>String(e);function ne(e){return e===`ss`||e===`ff`||e===`sf`?e:`fs`}function E(e){let t=new Set(e.map(e=>T(e.id))),n=[];for(let r of e){let e=T(r.id);for(let i of r.dependencies??[]){let r=typeof i==`object`&&!!i,a=r?i.id:i;if(a==null||a===``)continue;let o=T(a);o===e||!t.has(o)||n.push({pred:o,succ:e,type:ne(r?i.type:void 0)})}}return n}function D(e){let t=new Set;for(let n of e)n.parent!=null&&n.parent!==``&&t.add(T(n.parent));return t}function re(e,t){let n=new Map,r=new Map;for(let t of e)n.set(t,0),r.set(t,[]);for(let e of t)r.get(e.pred).push(e.succ),n.set(e.succ,(n.get(e.succ)??0)+1);let i=e.filter(e=>(n.get(e)??0)===0),a=[];for(;i.length;){let e=i.shift();a.push(e);for(let t of r.get(e)??[]){let e=(n.get(t)??0)-1;n.set(t,e),e===0&&i.push(t)}}if(a.length<e.length){let t=new Set(a);for(let n of e)t.has(n)||a.push(n);return{order:a,hasCycle:!0}}return{order:a,hasCycle:!1}}function ie(e,t){let n={criticalIds:new Set,criticalEdges:new Set};if(!e.length)return n;let r=new Map;for(let n of e){let e=t?S(n.start.getTime(),n.end.getTime(),t):(n.end.getTime()-n.start.getTime())/y;r.set(T(n.id),Number.isFinite(e)&&e>0?e:0)}let i=E(e),a=e.map(e=>T(e.id)),{order:o,hasCycle:s}=re(a,i);if(s)return n;let c=new Map,l=new Map;for(let e of a)c.set(e,[]),l.set(e,[]);for(let e of i)c.get(e.succ).push(e),l.get(e.pred).push(e);let u=new Map,d=new Map;for(let e of o){let t=0;for(let n of c.get(e)??[])t=Math.max(t,d.get(n.pred)??0);u.set(e,t),d.set(e,t+(r.get(e)??0))}let f=Math.max(0,...a.map(e=>d.get(e)??0)),p=new Map,m=new Map;for(let e=o.length-1;e>=0;e--){let t=o[e],n=l.get(t)??[],i=f;n.length&&(i=Math.min(...n.map(e=>m.get(e.succ)??f))),p.set(t,i),m.set(t,i-(r.get(t)??0))}let h=1e-6,g=new Set;for(let e of a){let t=(m.get(e)??0)-(u.get(e)??0);Math.abs(t)<=h&&g.add(e)}let _=new Set;for(let e of i)_.add(e.pred),_.add(e.succ);for(let e of[...g])!_.has(e)&&(r.get(e)??0)===0&&g.delete(e);let v=new Set;for(let e of i)!g.has(e.pred)||!g.has(e.succ)||Math.abs((d.get(e.pred)??0)-(u.get(e.succ)??0))<=h&&v.add(`${e.pred}->${e.succ}`);return{criticalIds:g,criticalEdges:v}}function O(e,t,n){if(!e.length)return{changes:[],skippedLocked:[]};let r=E(e),i=e.map(e=>T(e.id)),{order:a,hasCycle:o}=re(i,r);if(o)return{changes:[],skippedLocked:[]};let s=D(e),c=new Map;for(let t of e)c.set(T(t.id),t);let l=new Map;for(let t of e){if(t.parent==null||t.parent===``)continue;let e=T(t.parent),n=l.get(e)??[];n.push(t),l.set(e,n)}let u=n?.summaryExtent===`self`,d=e=>u&&e.hasOwnDates!==!1&&!e.locked,f=new Map;for(let e of i)f.set(e,[]);for(let e of r)f.get(e.succ).push(e);let p=new Map,m=new Map;for(let t of e)p.set(T(t.id),t.start.getTime()),m.set(T(t.id),t.end.getTime());let h=[];for(let e of a){let r=c.get(e);if(!r)continue;let i=t?S(p.get(e),m.get(e),t):m.get(e)-p.get(e),a=r.start.getTime(),o=a;for(let n of f.get(e)??[]){let e=p.get(n.pred),r=m.get(n.pred),a;switch(n.type){case`ss`:a=e;break;case`ff`:a=t?w(r,i,t):r-i;break;case`sf`:a=t?w(e,i,t):e-i;break;default:a=r}a>o&&(o=a)}let l=o>a;if(!(s.has(e)&&!d(r))){if(r.locked){l&&h.push(e);continue}if(l&&!t&&n?.snapStart&&(o=Math.max(o,n.snapStart(o))),t){let n=x(o,t);p.set(e,n),m.set(e,C(n,i,t))}else p.set(e,o),m.set(e,o+i)}}if(u)for(let t of e){let e=T(t.id);if(!s.has(e)||!d(t))continue;let n=p.get(e)-t.start.getTime();if(n<=0)continue;let r=[...l.get(e)??[]];for(;r.length;){let e=r.pop(),t=T(e.id);if(r.push(...l.get(t)??[]),e.locked)continue;let i=e.start.getTime()+n;if(i>p.get(t)){let e=m.get(t)-p.get(t);p.set(t,i),m.set(t,i+e)}}}let g=[];for(let t of e){let e=T(t.id),n=p.get(e),r=m.get(e);(n!==t.start.getTime()||r!==t.end.getTime())&&g.push({id:e,start:new Date(n),end:new Date(r)})}return{changes:g,skippedLocked:h}}function k(e,t,n){let r=String(t),i=String(n);if(r===i)return!0;let a=new Map;for(let[t,n]of e){let e=a.get(t);e?e.push(n):a.set(t,[n])}let o=new Set([i]),s=[i];for(;s.length;){let e=s.pop();for(let t of a.get(e)??[]){if(t===r)return!0;o.has(t)||(o.add(t),s.push(t))}}return!1}var ae=6e4;1440*ae;var oe=1440;function se(e){if(typeof e!=`string`)return null;let t=/^(\d{1,2}):(\d{2})$/.exec(e.trim());if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return n<0||n>23||r<0||r>59?null:n*60+r}function ce(e){if(!e||!Array.isArray(e.bands)||e.bands.length===0)return null;let t=se(e.dayStart)??0,n=[];for(let t=0;t<e.bands.length;t++){let r=e.bands[t],i=se(r.start),a=se(r.end);if(i==null||a==null||!r.label)return null;let o=(a-i+oe)%oe||oe;n.push({key:r.key??`band${t}`,label:r.label,color:r.color,durMs:o*ae})}return{dayStartMin:t,bands:n,showMidnight:e.showMidnight!==!1}}function A(e,t){let n=new Date(e);return n.setHours(0,0,0,0),n.setMinutes(t),n.getTime()>e.getTime()&&n.setDate(n.getDate()-1),n}function j(e,t){if(t.bands.length===0)return null;let n=A(e,t.dayStartMin).getTime(),r=e.getTime()-n,i=0;for(let e of t.bands)if(i+=e.durMs,r<i)return e;return t.bands[t.bands.length-1]}var le={"gantt.column.taskName":`Task Name`,"gantt.column.start":`Start`,"gantt.column.end":`End`,"gantt.toolbar.prevPeriod":`Previous period`,"gantt.toolbar.nextPeriod":`Next period`,"gantt.toolbar.zoomIn":`Zoom in`,"gantt.toolbar.zoomOut":`Zoom out`,"gantt.toolbar.jumpToToday":`Jump to today`,"gantt.toolbar.today":`Today`,"gantt.toolbar.thisWeek":`This week`,"gantt.toolbar.thisMonth":`This month`,"gantt.toolbar.exportPdf":`Export PDF`,"gantt.toolbar.saveLayout":`Save layout`,"gantt.toolbar.showTaskList":`Show task list`,"gantt.toolbar.hideTaskList":`Hide task list`,"gantt.toolbar.viewMode":`Timeline granularity`,"gantt.toolbar.enterFullscreen":`Enter fullscreen`,"gantt.toolbar.exitFullscreen":`Exit fullscreen`,"gantt.toolbar.criticalPath":`Highlight critical path`,"gantt.toolbar.autoSchedule":`Auto-schedule dependencies`,"gantt.toolbar.exportPng":`Export as PNG`,"gantt.toolbar.refresh":`Refresh`,"gantt.toolbar.undo":`Undo`,"gantt.toolbar.redo":`Redo`,"gantt.viewMode.day":`Day`,"gantt.viewMode.week":`Week`,"gantt.viewMode.month":`Month`,"gantt.viewMode.quarter":`Quarter`,"gantt.viewMode.year":`Year`,"gantt.row.expand":`Expand`,"gantt.row.collapse":`Collapse`,"gantt.row.open":`Open details`,"gantt.aria.taskList":`Task list`,"gantt.tooltip.days":`d`,"gantt.menu.view":`View details`,"gantt.menu.edit":`Edit inline`,"gantt.menu.delete":`Delete`,"gantt.menu.addPredecessor":`Add predecessor…`,"gantt.menu.addSuccessor":`Add successor…`,"gantt.menu.removeDependency":`Remove dependency`,"gantt.menu.noCandidates":`No available tasks`,"gantt.menu.searchTasks":`Search tasks…`,"gantt.delete.title":`Delete this task?`,"gantt.delete.body":`"{{title}}" will be permanently removed. This action cannot be undone.`,"gantt.delete.cancel":`Cancel`,"gantt.delete.confirm":`Delete`,"gantt.delete.deleting":`Deleting…`,"gantt.drawer.fallbackTitle":`Task Details`,"gantt.linkType.fs":`Finish → Start`,"gantt.linkType.ss":`Start → Start`,"gantt.linkType.ff":`Finish → Finish`,"gantt.linkType.sf":`Start → Finish`,"gantt.linkEnd.start":`start`,"gantt.linkEnd.end":`end`,"gantt.link.rejected.self":`A task cannot depend on itself.`,"gantt.link.rejected.locked":`This row is locked and cannot take a new dependency.`,"gantt.link.rejected.group":`A summary row cannot take a dependency — link one of its tasks instead.`,"gantt.link.rejected.cycle":`That link would create a circular dependency.`,"gantt.conflict.title":`Schedule conflict`,"gantt.conflict.body":`This move conflicts with dependency constraints. Auto-reschedule {{count}} affected task(s)?`,"gantt.conflict.confirm":`Auto-reschedule`,"gantt.conflict.cancel":`Keep as is`,"gantt.autoScheduleDlg.title":`Auto-schedule`,"gantt.autoScheduleDlg.body":`Shift {{count}} task(s) later to satisfy dependency links?`,"gantt.autoScheduleDlg.skipped":`{{count}} locked task(s) also violate links and were skipped.`,"gantt.autoScheduleDlg.confirm":`Apply`,"gantt.autoScheduleDlg.cancel":`Cancel`,"gantt.autoScheduleDlg.none":`All dependencies satisfied — nothing to reschedule.`,"gantt.quickFilter.all":`All`,"gantt.quickFilter.clear":`Clear filters`,"gantt.quickFilter.empty":`No options`,"gantt.quickFilter.resultSummary":`Showing {shown} / {total} tasks`,"gantt.resource.header":`Resource`,"gantt.resource.peak":`Peak`,"gantt.resource.over":`overloaded`,"gantt.resource.empty":`No tasks to allocate.`,"gantt.readOnly":`Read-only`,"gantt.readOnlyHint":`Editing is disabled for this view.`,"gantt.lockedHint":`No edit permission`,"gantt.writeFailed":`Save failed — the change was rolled back`};function ue(e,t){let n=le[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.split(`{{${e}}}`).join(String(r));return n}function de(){let e=(0,r.useObjectTranslation)();return{t:(t,n)=>{let r=e.t(t,n);return typeof r==`string`&&r!==t?r:ue(t,n)},language:e.language}}var fe=8;function pe(e,t){if(t.width<=0)return`move`;let n=Math.min(fe,t.width/3),r=e-t.left;return r<=n?`resize-left`:r>=t.width-n?`resize-right`:`move`}function me(e){return 110}function he(e){return e<640?140:e<1024?220:320}function ge(e){return e>=280}function _e(e){return e<640?32:40}var ve=[`day`,`week`,`month`,`quarter`,`year`],ye={day:1,week:7,month:30.44,quarter:91.31,year:365.25},be=864e5;function xe(e,t){let n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour12:!1,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),r=e=>Number(n.formatToParts(t).find(t=>t.type===e)?.value??0);return Date.UTC(r(`year`),r(`month`)-1,r(`day`),r(`hour`)%24,r(`minute`),r(`second`))-Math.floor(t.getTime()/1e3)*1e3}function Se(e){let t={delta:0,to:e=>e,from:e=>e,now:()=>new Date};if(!e)return t;try{xe(e,new Date)}catch{return console.warn(`[GanttView] invalid timeZone "${e}" — falling back to the browser zone`),t}let n=t=>xe(e,t)- -t.getTimezoneOffset()*6e4,r=n(new Date);return r===0?t:{delta:r,to:e=>new Date(e.getTime()+n(e)),from:e=>new Date(e.getTime()-n(e)),now:()=>new Date(Date.now()+n(new Date))}}function Ce(e,t){let n=new Date(e);return n.setHours(0,0,0,0),t===`week`?n.setDate(n.getDate()-(n.getDay()+6)%7):t===`month`?n.setDate(1):t===`quarter`?n.setMonth(Math.floor(n.getMonth()/3)*3,1):t===`year`&&n.setMonth(0,1),n}function we(e,t,n){let r=e.length-1,i=0;for(;i<r&&e[i+1]<t;)i++;let a=i;for(;a<r&&e[a]<n;)a++;return{start:i,end:a}}function Te(e,t,n){let r=new Date(e);if(n===`day`)r.setDate(r.getDate()+t);else if(n===`week`)r.setDate(r.getDate()+t*7);else{let e=t*(n===`month`?1:n===`quarter`?3:12),i=r.getDate();r.setDate(1),r.setMonth(r.getMonth()+e);let a=new Date(r.getFullYear(),r.getMonth()+1,0).getDate();r.setDate(Math.min(i,a))}return r}function Ee(e,t,n,r=2){return new Promise(i=>{let a=new Blob([e],{type:`image/svg+xml;charset=utf-8`}),o=URL.createObjectURL(a),s=new Image;s.onload=()=>{let e=document.createElement(`canvas`);e.width=t*r,e.height=n*r;let a=e.getContext(`2d`);a&&(a.fillStyle=`#ffffff`,a.fillRect(0,0,e.width,e.height),a.scale(r,r),a.drawImage(s,0,0)),URL.revokeObjectURL(o),i(e)},s.onerror=()=>{URL.revokeObjectURL(o),i(null)},s.src=o})}function De(e,t){let n=document.createElement(`a`);n.href=URL.createObjectURL(e),n.download=t,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(n.href),1e3)}function Oe(e,t,n){let r=e=>{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t},i=`q ${t} 0 0 ${n} 0 0 cm /Im0 Do Q`,a=[],o=[],s=0,c=e=>{a.push(e),s+=e.length},l=()=>{o.push(s)};c(r(`%PDF-1.3
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("sonner"),require("@objectstack/spec/ui"),require("@objectstack/spec/data"),require("@object-ui/i18n"),require("@object-ui/plugin-detail"),require("@object-ui/permissions"),require("@object-ui/components"),require("@object-ui/fields"),require("lucide-react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/core`,`@object-ui/react`,`sonner`,`@objectstack/spec/ui`,`@objectstack/spec/data`,`@object-ui/i18n`,`@object-ui/plugin-detail`,`@object-ui/permissions`,`@object-ui/components`,`@object-ui/fields`,`lucide-react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginGantt={},e.React,e.ObjectUICore,e.ObjectUIReact,e.sonner,e._objectstack_spec_ui,e._objectstack_spec_data,e._object_ui_i18n,e._object_ui_plugin_detail,e._object_ui_permissions,e.ObjectUIComponents,e._object_ui_fields,e.LucideReact,e.react_jsx_runtime))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var m=Object.create,h=Object.defineProperty,g=Object.getOwnPropertyDescriptor,_=Object.getOwnPropertyNames,v=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty,b=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=_(t),a=0,o=i.length,s;a<o;a++)s=i[a],!y.call(e,s)&&s!==n&&h(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=g(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:m(v(e)),b(t||!e||!e.__esModule||!y.call(e,`default`)?h(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);var ee=864e5,te=e=>String(e).padStart(2,`0`),ne=e=>`${e.getFullYear()}-${te(e.getMonth()+1)}-${te(e.getDate())}`;function re(e,t){if(t.skipWeekends){let t=e.getDay();if(t===0||t===6)return!1}return!(t.holidays&&t.holidays.has(ne(e)))}function x(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function S(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function ie(e,t){let n=x(e);for(;!re(n,t);)n=S(n,1);return n.getTime()}function C(e,t,n){if(t<=e)return 0;let r=0,i=x(e),a=x(t).getTime();for(;i.getTime()<a;)re(i,n)&&r++,i=S(i,1);return r}function w(e,t,n){if(t<=0)return x(e).getTime();let r=x(e),i=t;for(;i>0;)re(r,n)&&i--,r=S(r,1);return r.getTime()}function T(e,t,n){if(t<=0)return x(e).getTime();let r=x(e),i=t;for(;i>0;)r=S(r,-1),re(r,n)&&i--;return r.getTime()}var E=e=>String(e);function ae(e){return e===`ss`||e===`ff`||e===`sf`?e:`fs`}function D(e){let t=new Set(e.map(e=>E(e.id))),n=[];for(let r of e){let e=E(r.id);for(let i of r.dependencies??[]){let r=typeof i==`object`&&!!i,a=r?i.id:i;if(a==null||a===``)continue;let o=E(a);o!==e&&t.has(o)&&n.push({pred:o,succ:e,type:ae(r?i.type:void 0)})}}return n}function O(e){let t=new Set;for(let n of e)n.parent!=null&&n.parent!==``&&t.add(E(n.parent));return t}function oe(e,t){let n=new Map,r=new Map;for(let t of e)n.set(t,0),r.set(t,[]);for(let e of t)r.get(e.pred).push(e.succ),n.set(e.succ,(n.get(e.succ)??0)+1);let i=e.filter(e=>(n.get(e)??0)===0),a=[];for(;i.length;){let e=i.shift();a.push(e);for(let t of r.get(e)??[]){let e=(n.get(t)??0)-1;n.set(t,e),e===0&&i.push(t)}}if(a.length<e.length){let t=new Set(a);for(let n of e)t.has(n)||a.push(n);return{order:a,hasCycle:!0}}return{order:a,hasCycle:!1}}function se(e,t){let n={criticalIds:new Set,criticalEdges:new Set};if(!e.length)return n;let r=new Map;for(let n of e){let e=t?C(n.start.getTime(),n.end.getTime(),t):(n.end.getTime()-n.start.getTime())/ee;r.set(E(n.id),Number.isFinite(e)&&e>0?e:0)}let i=D(e),a=e.map(e=>E(e.id)),{order:o,hasCycle:s}=oe(a,i);if(s)return n;let c=new Map,l=new Map;for(let e of a)c.set(e,[]),l.set(e,[]);for(let e of i)c.get(e.succ).push(e),l.get(e.pred).push(e);let u=new Map,d=new Map;for(let e of o){let t=0;for(let n of c.get(e)??[])t=Math.max(t,d.get(n.pred)??0);u.set(e,t),d.set(e,t+(r.get(e)??0))}let f=Math.max(0,...a.map(e=>d.get(e)??0)),p=new Map,m=new Map;for(let e=o.length-1;e>=0;e--){let t=o[e],n=l.get(t)??[],i=f;n.length&&(i=Math.min(...n.map(e=>m.get(e.succ)??f))),p.set(t,i),m.set(t,i-(r.get(t)??0))}let h=1e-6,g=new Set;for(let e of a){let t=(m.get(e)??0)-(u.get(e)??0);Math.abs(t)<=h&&g.add(e)}let _=new Set;for(let e of i)_.add(e.pred),_.add(e.succ);for(let e of[...g])!_.has(e)&&(r.get(e)??0)===0&&g.delete(e);let v=new Set;for(let e of i)g.has(e.pred)&&g.has(e.succ)&&Math.abs((d.get(e.pred)??0)-(u.get(e.succ)??0))<=h&&v.add(`${e.pred}->${e.succ}`);return{criticalIds:g,criticalEdges:v}}function ce(e,t,n){if(!e.length)return{changes:[],skippedLocked:[]};let r=D(e),i=e.map(e=>E(e.id)),{order:a,hasCycle:o}=oe(i,r);if(o)return{changes:[],skippedLocked:[]};let s=O(e),c=new Map;for(let t of e)c.set(E(t.id),t);let l=new Map;for(let t of e){if(t.parent==null||t.parent===``)continue;let e=E(t.parent),n=l.get(e)??[];n.push(t),l.set(e,n)}let u=n?.summaryExtent===`self`,d=e=>u&&e.hasOwnDates!==!1&&!e.locked,f=new Map;for(let e of i)f.set(e,[]);for(let e of r)f.get(e.succ).push(e);let p=new Map,m=new Map;for(let t of e)p.set(E(t.id),t.start.getTime()),m.set(E(t.id),t.end.getTime());let h=[];for(let e of a){let r=c.get(e);if(!r)continue;let i=t?C(p.get(e),m.get(e),t):m.get(e)-p.get(e),a=r.start.getTime(),o=a;for(let n of f.get(e)??[]){let e=p.get(n.pred),r=m.get(n.pred),a;switch(n.type){case`ss`:a=e;break;case`ff`:a=t?T(r,i,t):r-i;break;case`sf`:a=t?T(e,i,t):e-i;break;default:a=r}a>o&&(o=a)}let l=o>a;if(!s.has(e)||d(r)){if(r.locked){l&&h.push(e);continue}if(l&&!t&&n?.snapStart&&(o=Math.max(o,n.snapStart(o))),t){let n=ie(o,t);p.set(e,n),m.set(e,w(n,i,t))}else p.set(e,o),m.set(e,o+i)}}if(u)for(let t of e){let e=E(t.id);if(!s.has(e)||!d(t))continue;let n=p.get(e)-t.start.getTime();if(n<=0)continue;let r=[...l.get(e)??[]];for(;r.length;){let e=r.pop(),t=E(e.id);if(r.push(...l.get(t)??[]),e.locked)continue;let i=e.start.getTime()+n;if(i>p.get(t)){let e=m.get(t)-p.get(t);p.set(t,i),m.set(t,i+e)}}}let g=[];for(let t of e){let e=E(t.id),n=p.get(e),r=m.get(e);(n!==t.start.getTime()||r!==t.end.getTime())&&g.push({id:e,start:new Date(n),end:new Date(r)})}return{changes:g,skippedLocked:h}}function k(e,t,n){let r=String(t),i=String(n);if(r===i)return!0;let a=new Map;for(let[t,n]of e){let e=a.get(t);e?e.push(n):a.set(t,[n])}let o=new Set([i]),s=[i];for(;s.length;){let e=s.pop();for(let t of a.get(e)??[]){if(t===r)return!0;o.has(t)||(o.add(t),s.push(t))}}return!1}var le=6e4;1440*le;var ue=1440;function A(e){if(typeof e!=`string`)return null;let t=/^(\d{1,2}):(\d{2})$/.exec(e.trim());if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return n<0||n>23||r<0||r>59?null:n*60+r}function de(e){if(!e||!Array.isArray(e.bands)||e.bands.length===0)return null;let t=A(e.dayStart)??0,n=[];for(let t=0;t<e.bands.length;t++){let r=e.bands[t],i=A(r.start),a=A(r.end);if(i==null||a==null||!r.label)return null;let o=(a-i+ue)%ue||ue;n.push({key:r.key??`band${t}`,label:r.label,color:r.color,durMs:o*le})}return{dayStartMin:t,bands:n,showMidnight:e.showMidnight!==!1}}function fe(e,t){let n=new Date(e);return n.setHours(0,0,0,0),n.setMinutes(t),n.getTime()>e.getTime()&&n.setDate(n.getDate()-1),n}function j(e,t){if(t.bands.length===0)return null;let n=fe(e,t.dayStartMin).getTime(),r=e.getTime()-n,i=0;for(let e of t.bands)if(i+=e.durMs,r<i)return e;return t.bands[t.bands.length-1]}function pe(e,t){let n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour12:!1,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),r=e=>Number(n.formatToParts(t).find(t=>t.type===e)?.value??0);return Date.UTC(r(`year`),r(`month`)-1,r(`day`),r(`hour`)%24,r(`minute`),r(`second`))-Math.floor(t.getTime()/1e3)*1e3}function me(e){let t={delta:0,to:e=>e,from:e=>e,now:()=>new Date};if(!e)return t;try{pe(e,new Date)}catch{return console.warn(`[GanttView] invalid timeZone "${e}" — falling back to the browser zone`),t}let n=t=>pe(e,t)- -t.getTimezoneOffset()*6e4,r=n(new Date);return r===0?t:{delta:r,to:e=>new Date(e.getTime()+n(e)),from:e=>new Date(e.getTime()-n(e)),now:()=>new Date(Date.now()+n(new Date))}}var he=18e5;function M(e,t,n){let r=t.getTime(),i=new Map,a=t=>{let n=i.get(t);return n===void 0&&(n=e(new Date(t)).getTime(),i.set(t,n)),n},o=r-(a(r)-r);if(n===`any`&&a(o)===r)return new Date(o);let s=new Set([o]);for(let e=-6;e<=6;e++){let t=o+e*he;s.add(r-(a(t)-t))}let c=[...s].filter(e=>a(e)===r).sort((e,t)=>e-t);if(c.length>0)return new Date(n===`latest`?c[c.length-1]:c[0]);let l=[...s].filter(e=>a(e)>r).sort((e,t)=>a(e)-a(t));return new Date(l.length>0?l[0]:o)}function N(e,t){return e.delta===0?t:M(e.to,t,`any`)}function ge(e,t){return e.delta===0?t:M(e.from,t,`latest`)}var _e={"gantt.column.taskName":`Task Name`,"gantt.column.start":`Start`,"gantt.column.end":`End`,"gantt.toolbar.prevPeriod":`Previous period`,"gantt.toolbar.nextPeriod":`Next period`,"gantt.toolbar.zoomIn":`Zoom in`,"gantt.toolbar.zoomOut":`Zoom out`,"gantt.toolbar.jumpToToday":`Jump to today`,"gantt.toolbar.today":`Today`,"gantt.toolbar.thisWeek":`This week`,"gantt.toolbar.thisMonth":`This month`,"gantt.toolbar.exportPdf":`Export PDF`,"gantt.toolbar.saveLayout":`Save layout`,"gantt.toolbar.showTaskList":`Show task list`,"gantt.toolbar.hideTaskList":`Hide task list`,"gantt.toolbar.viewMode":`Timeline granularity`,"gantt.toolbar.enterFullscreen":`Enter fullscreen`,"gantt.toolbar.exitFullscreen":`Exit fullscreen`,"gantt.toolbar.criticalPath":`Highlight critical path`,"gantt.toolbar.autoSchedule":`Auto-schedule dependencies`,"gantt.toolbar.exportPng":`Export as PNG`,"gantt.toolbar.refresh":`Refresh`,"gantt.toolbar.undo":`Undo`,"gantt.toolbar.redo":`Redo`,"gantt.viewMode.day":`Day`,"gantt.viewMode.week":`Week`,"gantt.viewMode.month":`Month`,"gantt.viewMode.quarter":`Quarter`,"gantt.viewMode.year":`Year`,"gantt.row.expand":`Expand`,"gantt.row.collapse":`Collapse`,"gantt.row.open":`Open details`,"gantt.aria.taskList":`Task list`,"gantt.aria.refreshing":`Refreshing…`,"gantt.tooltip.days":`d`,"gantt.menu.view":`View details`,"gantt.menu.edit":`Edit inline`,"gantt.menu.delete":`Delete`,"gantt.menu.addPredecessor":`Add predecessor…`,"gantt.menu.addSuccessor":`Add successor…`,"gantt.menu.removeDependency":`Remove dependency`,"gantt.menu.noCandidates":`No available tasks`,"gantt.menu.searchTasks":`Search tasks…`,"gantt.delete.title":`Delete this task?`,"gantt.delete.body":`"{{title}}" will be permanently removed. This action cannot be undone.`,"gantt.delete.cancel":`Cancel`,"gantt.delete.confirm":`Delete`,"gantt.delete.deleting":`Deleting…`,"gantt.drawer.fallbackTitle":`Task Details`,"gantt.linkType.fs":`Finish → Start`,"gantt.linkType.ss":`Start → Start`,"gantt.linkType.ff":`Finish → Finish`,"gantt.linkType.sf":`Start → Finish`,"gantt.linkEnd.start":`start`,"gantt.linkEnd.end":`end`,"gantt.link.rejected.self":`A task cannot depend on itself.`,"gantt.link.rejected.locked":`This row is locked and cannot take a new dependency.`,"gantt.link.rejected.group":`A summary row cannot take a dependency — link one of its tasks instead.`,"gantt.link.rejected.cycle":`That link would create a circular dependency.`,"gantt.conflict.title":`Schedule conflict`,"gantt.conflict.body":`This move conflicts with dependency constraints. Auto-reschedule {{count}} affected task(s)?`,"gantt.conflict.body_one":`This move conflicts with dependency constraints. Auto-reschedule {{count}} affected task?`,"gantt.conflict.body_other":`This move conflicts with dependency constraints. Auto-reschedule {{count}} affected tasks?`,"gantt.conflict.confirm":`Auto-reschedule`,"gantt.conflict.cancel":`Keep as is`,"gantt.autoScheduleDlg.title":`Auto-schedule`,"gantt.autoScheduleDlg.body":`Shift {{count}} task(s) later to satisfy dependency links?`,"gantt.autoScheduleDlg.body_one":`Shift {{count}} task later to satisfy dependency links?`,"gantt.autoScheduleDlg.body_other":`Shift {{count}} tasks later to satisfy dependency links?`,"gantt.autoScheduleDlg.skipped":`{{count}} locked task(s) also violate links and were skipped.`,"gantt.autoScheduleDlg.skipped_one":`{{count}} locked task also violates links and was skipped.`,"gantt.autoScheduleDlg.skipped_other":`{{count}} locked tasks also violate links and were skipped.`,"gantt.autoScheduleDlg.confirm":`Apply`,"gantt.autoScheduleDlg.cancel":`Cancel`,"gantt.autoScheduleDlg.none":`All dependencies satisfied — nothing to reschedule.`,"gantt.quickFilter.all":`All`,"gantt.quickFilter.clear":`Clear filters`,"gantt.quickFilter.empty":`No options`,"gantt.quickFilter.resultSummary":`Showing {shown} / {total} tasks`,"gantt.resource.header":`Resource`,"gantt.resource.peak":`Peak`,"gantt.resource.over":`overloaded`,"gantt.resource.empty":`No tasks to allocate.`,"gantt.readOnly":`Read-only`,"gantt.readOnlyHint":`Editing is disabled for this view.`,"gantt.lockedHint":`No edit permission`,"gantt.writeFailed":`Save failed — the change was rolled back`},ve=new Intl.PluralRules(`en`);function P(e,t){let n=t?.count,r=(typeof n==`number`&&Number.isFinite(n)?_e[`${e}_${ve.select(n)}`]:void 0)||_e[e]||e;if(t)for(let[e,n]of Object.entries(t))r=r.split(`{{${e}}}`).join(String(n));return r}function ye(){let e=(0,r.useObjectTranslation)();return{t:(t,n)=>{let r=e.t(t,n);return typeof r==`string`&&r!==t?r:P(t,n)},language:e.language}}var be=8;function xe(e,t){if(t.width<=0)return`move`;let n=Math.min(be,t.width/3),r=e-t.left;return r<=n?`resize-left`:r>=t.width-n?`resize-right`:`move`}var Se=110,Ce=160,F=.375,we=320,Te=560;function Ee(e){return e<640?140:e<1024?220:Math.round(Math.min(Te,Math.max(we,e*F)))}var De=412;function Oe(e){return e>=De}function ke(e){return e<640?32:40}var I=[`day`,`week`,`month`,`quarter`,`year`],Ae={day:1,week:7,month:30.44,quarter:91.31,year:365.25},je=864e5;function Me(e,t){let n=new Date(e);return n.setHours(0,0,0,0),t===`week`?n.setDate(n.getDate()-(n.getDay()+6)%7):t===`month`?n.setDate(1):t===`quarter`?n.setMonth(Math.floor(n.getMonth()/3)*3,1):t===`year`&&n.setMonth(0,1),n}function Ne(e,t,n){let r=e.length-1,i=0;for(;i<r&&e[i+1]<t;)i++;let a=i;for(;a<r&&e[a]<n;)a++;return{start:i,end:a}}function L(e,t,n){let r=new Date(e);if(n===`day`)r.setDate(r.getDate()+t);else if(n===`week`)r.setDate(r.getDate()+t*7);else{let e=t*(n===`month`?1:n===`quarter`?3:12),i=r.getDate();r.setDate(1),r.setMonth(r.getMonth()+e);let a=new Date(r.getFullYear(),r.getMonth()+1,0).getDate();r.setDate(Math.min(i,a))}return r}function Pe(e,t){return(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())-Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()))/je}function Fe(e,t,n){if(n){let n=t.getTime()-e.getTime();return e=>new Date(e.getTime()+n)}let r=Pe(e,t);return e=>L(e,r,`day`)}function Ie(e,t){return t.getTime()>e.getTime()?(0,n.toInclusiveEndDay)(t):t}function Le(e,t){return t.end.getTime()>t.start.getTime()?(0,n.toDisplayEndDate)(e):(0,n.toDisplayDate)(e)}function Re(e,t){return t?`shiftDay`:e===`year`?`decade`:e===`month`||e===`quarter`?`year`:`month`}function ze(e,t,n=0){if(t===`shiftDay`)return fe(e,n);let r=new Date(e);return r.setHours(0,0,0,0),t===`month`?r.setDate(1):t===`year`?r.setMonth(0,1):(r.setMonth(0,1),r.setFullYear(Math.floor(r.getFullYear()/10)*10)),r}function Be(e,t,n){return n===`shiftDay`?L(e,t,`day`):n===`month`?L(e,t,`month`):L(e,t*(n===`decade`?10:1),`year`)}function Ve(e,t,n){return t===`decade`?`${Math.floor(e.getFullYear()/10)*10}s`:t===`year`?String(e.getFullYear()):t===`shiftDay`?e.toLocaleDateString(n,{year:`numeric`,month:`long`,day:`numeric`}):e.toLocaleDateString(n,{month:`long`,year:`numeric`})}function He(e,t,n,r=2){return new Promise(i=>{let a=new Blob([e],{type:`image/svg+xml;charset=utf-8`}),o=URL.createObjectURL(a),s=new Image;s.onload=()=>{let e=document.createElement(`canvas`);e.width=t*r,e.height=n*r;let a=e.getContext(`2d`);a&&(a.fillStyle=`#ffffff`,a.fillRect(0,0,e.width,e.height),a.scale(r,r),a.drawImage(s,0,0)),URL.revokeObjectURL(o),i(e)},s.onerror=()=>{URL.revokeObjectURL(o),i(null)},s.src=o})}function Ue(e,t){let n=document.createElement(`a`);n.href=URL.createObjectURL(e),n.download=t,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(n.href),1e3)}function We(e,t,n){let r=e=>{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t},i=`q ${t} 0 0 ${n} 0 0 cm /Im0 Do Q`,a=[],o=[],s=0,c=e=>{a.push(e),s+=e.length},l=()=>{o.push(s)};c(r(`%PDF-1.3
2
2
  %ÿÿÿÿ
3
3
  `)),l(),c(r(`1 0 obj
4
4
  << /Type /Catalog /Pages 2 0 R >>
@@ -12,7 +12,7 @@ endobj
12
12
  `)),l(),c(r(`5 0 obj\n<< /Length ${i.length} >>\nstream\n${i}\nendstream\nendobj\n`));let u=s,d=`xref
13
13
  0 6
14
14
  0000000000 65535 f
15
- `;for(let e of o)d+=`${String(e).padStart(10,`0`)} 00000 n \n`;return d+=`trailer\n<< /Size 6 /Root 1 0 R >>\nstartxref\n${u}\n%%EOF\n`,c(r(d)),new Blob(a,{type:`application/pdf`})}function ke(e){let t=e.slice(e.indexOf(`,`)+1),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}var Ae=`gantt-layout:`;function je(e){if(!e||typeof window>`u`)return null;try{let t=window.localStorage.getItem(Ae+e);if(!t)return null;let n=JSON.parse(t),r=n.viewMode&&ve.includes(n.viewMode)?n.viewMode:null;if(!r)return null;let i=typeof n.columnWidth==`number`&&isFinite(n.columnWidth)?n.columnWidth:null,a=typeof n.taskListWidth==`number`&&isFinite(n.taskListWidth)?n.taskListWidth:null,o=Array.isArray(n.collapsedIds)?n.collapsedIds.filter(e=>typeof e==`string`):void 0;return{viewMode:r,columnWidth:i,taskListCollapsed:!!n.taskListCollapsed,taskListWidth:a,collapsedIds:o}}catch{return null}}function Me(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(Ae+e,JSON.stringify(t))}catch{}}function M({tasks:e,viewMode:n,startDate:r,endDate:a,markers:o,onTaskClick:s,onTaskUpdate:l,onTaskDelete:f,onViewChange:p,onDependencyCreate:m,onBeforeDependencyCreate:h,onDependencyDelete:g,onTaskReorder:_,className:v,inlineEdit:y=!1,autoSchedule:ee=!1,rescheduleOnConflict:te=!1,criticalPathDefault:b=!1,workingCalendar:x,shiftSegments:S,showBaselines:C=!0,readOnly:w=!1,mobileReadOnly:T=!1,groupBy:ne,ungroupedLabel:E=`Ungrouped`,defaultCollapsedDepth:D,summaryExtent:re=`children`,persistLayoutKey:ae,onLayoutChange:oe,onRefresh:se,refreshing:ce=!1,dependencyTypes:j=!0,timeZone:le,exportFileName:ue,interactions:xe,onBeforeTaskUpdate:Ae}){let M=t.useMemo(()=>Se(le),[le]),N=t.useMemo(()=>M.delta===0?e:e.map(e=>({...e,start:M.to(e.start),end:M.to(e.end),baselineStart:e.baselineStart?M.to(e.baselineStart):e.baselineStart,baselineEnd:e.baselineEnd?M.to(e.baselineEnd):e.baselineEnd})),[e,M]),Ne=t.useMemo(()=>r&&M.delta!==0?M.to(r):r,[r,M]),Pe=t.useMemo(()=>a&&M.delta!==0?M.to(a):a,[a,M]),Fe=t.useMemo(()=>!o||M.delta===0?o:o.map(e=>({...e,date:M.to(new Date(e.date))})),[o,M]),{t:P,language:Ie}=de(),F=Ie||void 0,[Le,Re]=t.useState(()=>M.now()),ze=t.useRef(null),{width:Be}=(0,c.useResizeObserver)(ze),I=Be||(typeof window<`u`?window.innerWidth:1024),Ve=I<640,L=w||T&&Ve,He=xe?.move!==!1,Ue=xe?.resize!==!1,We=xe?.progress!==!1,Ge=xe?.link!==!1,R=t.useMemo(()=>{if(!(L||!l))return M.delta===0?l:(e,t)=>{let n={...t};n.start instanceof Date&&(n.start=M.from(n.start)),n.end instanceof Date&&(n.end=M.from(n.end)),l(e,n)}},[L,l,M]),Ke=L?void 0:f,z=L||!Ge?void 0:m,qe=L||!Ge?void 0:g,Je=L?void 0:_,Ye=!L&&y,Xe=!L&&ee,Ze=!L&&te,B=_e(I),Qe=me(I),$e=t.useRef(void 0);$e.current===void 0&&($e.current=je(ae));let et=$e.current,[tt,nt]=t.useState(et?et.columnWidth:null),[rt,it]=t.useState(et?et.taskListWidth??null:null),[V,at]=t.useState(n&&ve.includes(n)?n:et?.viewMode??`day`);t.useEffect(()=>{n&&ve.includes(n)&&at(n)},[n]);let ot=t.useRef(null),st=t.useRef(null),ct=t.useRef(!0),[lt,ut]=t.useState(et?et.taskListCollapsed:!1),dt=t.useRef(!1);t.useEffect(()=>{!dt.current&&Ve&&(ut(!0),dt.current=!0)},[Ve]);let ft=Math.max(160,I-200),H=lt?0:rt==null?he(I):Math.max(160,Math.min(rt,ft)),pt=t.useMemo(()=>{if(tt!=null||Pe||N.length===0)return null;let e=Ne?new Date(Ne):new Date(Math.min(...N.map(e=>e.start.getTime()))),t=new Date(Math.max(...N.map(e=>e.end.getTime())));Ne||e.setDate(e.getDate()-7),t.setDate(t.getDate()+14),e=Ce(e,V),t.setHours(23,59,59,999);let n=Math.max(1,(t.getTime()-e.getTime())/be),r=Math.max(0,I-H);if(r<=0)return null;let i=r/n*ye[V];if(i<=Qe)return null;let a=Math.min(i,r*.6);return a>Qe?a:null},[tt,N,Ne,Pe,V,I,H,Qe]),mt=tt??pt??Qe,ht=mt/ye[V],gt=ge(H),[_t,vt]=t.useState(null),[yt,bt]=t.useState({}),[xt,St]=t.useState(null),U=t.useMemo(()=>{if(!ne)return N;let e=new Set;for(let t of N){let n=t.parent!=null&&t.parent!==``?String(t.parent):null;n&&e.add(n)}let t=new Map;for(let n of N){if(e.has(String(n.id)))continue;let r=ne(n),i=r?String(r.key):`__ungrouped__`,a=r?r.label:E,o=t.get(i);o||(o={key:i,label:a,items:[]},t.set(i,o)),o.items.push(n)}let n=[];for(let e of t.values()){let t=`__group__${e.key}`,r=e.items[0];n.push({id:t,title:e.label,start:r.start,end:r.end,progress:0,type:`summary`,parent:null,data:{__group:!0}});for(let r of e.items)n.push({...r,parent:t})}return n},[ne,N,E]),Ct=t.useMemo(()=>{let e=new Set(U.map(e=>String(e.id))),t=new Map;for(let n of U){let r=n.parent!=null&&n.parent!==``?String(n.parent):null;if(r&&r!==String(n.id)&&e.has(r)){let e=t.get(r);e?e.push(n):t.set(r,[n])}}return t},[U]),wt=t.useMemo(()=>{let e=new Map;for(let t of U)e.set(String(t.id),t);return e},[U]),Tt=t.useCallback(e=>{let t=[],n=new Set,r=e=>{for(let i of Ct.get(e)??[]){let e=String(i.id);n.has(e)||(n.add(e),t.push(i),r(e))}};return r(String(e)),t},[Ct]),[W,Et]=t.useState(null),Dt=t.useRef(null);t.useEffect(()=>{Dt.current=W},[W]);let Ot=t.useRef(!1),kt=t.useCallback(e=>{let t=V===`day`&&S&&S.bands.length>0&&S?Math.min(...S.bands.map(e=>e.durMs)):be,n=(e,t)=>Pn.current?Pn.current(e,t):Te(e,t,`day`),r=new Date(e.originStart),i=new Date(e.originEnd);return e.mode===`move`?(r=n(e.originStart,e.unitDelta),i=new Date(e.originEnd.getTime()+(r.getTime()-e.originStart.getTime()))):e.mode===`resize-left`?(r=n(e.originStart,e.unitDelta),i.getTime()-r.getTime()<t&&(r=new Date(i.getTime()-t))):e.mode===`resize-right`&&(i=n(e.originEnd,e.unitDelta),i.getTime()-r.getTime()<t&&(i=new Date(r.getTime()+t))),{start:r,end:i}},[V,S]),At=t.useRef(N);At.current=N;let jt=t.useRef([]),Mt=t.useRef([]),[Nt,Pt]=t.useState(0),Ft=t.useCallback(e=>{if(!R)return;let t=e.filter(e=>!e.task.locked);(async()=>{let e=t;if(Ae){let n=[];for(let e of t){let t;try{t=await Ae(e.task,e.changes)!==!1}catch{t=!1}t&&n.push(e)}e=n}let n=[];for(let{task:t,changes:r}of e){let e={},i={},a=!1;for(let n of Object.keys(r)){let o=r[n],s=t[n],c=o instanceof Date&&s instanceof Date?o.getTime()===s.getTime():o===s;e[n]=s,i[n]=o,c||(a=!0)}R(t,r),a&&n.push({taskId:String(t.id),before:e,after:i})}n.length&&(jt.current.push(n),Mt.current=[],Pt(e=>e+1))})()},[R,Ae]),[It,Lt]=t.useState(null),Rt=t.useCallback(e=>{if(!S)return e;let t=new Date(e);t.setHours(0,0,0,0);for(let n=-1;n<=1;n++){let r=t.getTime()+n*be+S.dayStartMin*6e4;for(let t of S.bands){if(r>=e)return r;r+=t.durMs}}return e},[S]),zt=t.useMemo(()=>({summaryExtent:re,snapStart:S?Rt:void 0}),[re,S,Rt]),Bt=t.useCallback(e=>{if(!Ze)return;let t=new Map;for(let{task:n,changes:r}of e)t.set(String(n.id),{start:r.start??n.start,end:r.end??n.end});let{changes:n}=O(At.current.map(e=>{let n=t.get(String(e.id));return n?{...e,start:n.start,end:n.end}:e}),x,zt),r=n.filter(e=>{let n=t.get(e.id);return!n||e.start.getTime()!==n.start.getTime()||e.end.getTime()!==n.end.getTime()});r.length&&Lt(r)},[Ze,x,zt]),Vt=t.useCallback(()=>{if(!It)return;let e=It.map(e=>{let t=At.current.find(t=>String(t.id)===e.id);return t?{task:t,changes:{start:e.start,end:e.end}}:null}).filter(Boolean);e.length&&Ft(e),Lt(null)},[It,Ft]),Ht=t.useCallback((e,t)=>{if(R)for(let n of e){let e=At.current.find(e=>String(e.id)===n.taskId);e&&R(e,t===`undo`?n.before:n.after)}},[R]),Ut=t.useCallback(()=>{let e=jt.current.pop();e&&(Ht(e,`undo`),Mt.current.push(e),Pt(e=>e+1))},[Ht]),Wt=t.useCallback(()=>{let e=Mt.current.pop();e&&(Ht(e,`redo`),jt.current.push(e),Pt(e=>e+1))},[Ht]),{canUndo:Gt,canRedo:Kt}=t.useMemo(()=>({canUndo:jt.current.length>0,canRedo:Mt.current.length>0}),[Nt]);t.useEffect(()=>{if(!W)return;let e=V===`day`&&S&&S.bands.length>0&&S?ht*Math.min(...S.bands.map(e=>e.durMs))/be:ht,t=t=>{let n=Dt.current;if(!n)return;let r=Math.round((t.clientX-n.originClientX)/Math.max(e,1));r!==n.unitDelta&&Et({...n,unitDelta:r})},n=()=>{let e=Dt.current;if(e){if(e.unitDelta!==0){let t=N.find(t=>t.id===e.taskId);if(t&&R){let{start:n,end:r}=kt(e);if(e.group){let r=n.getTime()-e.originStart.getTime(),i=[t,...Tt(t.id).filter(e=>!e.locked)].map(e=>({task:e,changes:{start:new Date(e.start.getTime()+r),end:new Date(e.end.getTime()+r)}}));Ft(i),Bt(i)}else{let e=[{task:t,changes:{start:n,end:r}}];Ft(e),Bt(e)}}Ot.current=!0,window.setTimeout(()=>{Ot.current=!1},0)}Et(null)}};return window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,n),()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,n)}},[W,mt,ht,V,S,N,R,kt,Tt,Ft,Bt]);let qt=t.useCallback((e,t,n,r)=>{!R||e.data?.__group||e.locked||(n.stopPropagation(),n.preventDefault(),Et({taskId:e.id,mode:t,group:r?.group??!1,originStart:new Date(r?.originStart??e.start),originEnd:new Date(r?.originEnd??e.end),originClientX:n.clientX,unitDelta:0}))},[R]),[Jt,Yt]=t.useState(null),Xt=t.useRef(null);t.useEffect(()=>{Xt.current=Jt},[Jt]),t.useEffect(()=>{if(!Jt)return;let e=e=>{let t=Xt.current;if(!t)return;let n=Math.min(100,Math.max(0,Math.round(t.originProgress+(e.clientX-t.originClientX)/Math.max(t.barWidth,1)*100)));n!==t.value&&Yt({...t,value:n})},t=()=>{let e=Xt.current;if(e){if(e.value!==e.originProgress){let t=N.find(t=>t.id===e.taskId);t&&R&&Ft([{task:t,changes:{progress:e.value}}]),Ot.current=!0,window.setTimeout(()=>{Ot.current=!1},0)}Yt(null)}};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[Jt,N,R,Ft]);let Zt=t.useMemo(()=>{let e=[];for(let t of N)for(let n of t.dependencies??[]){let r=typeof n==`object`&&n?n.id:n;r!=null&&r!==``&&e.push([String(r),String(t.id)])}return e},[N]),Qt=t.useCallback((e,t)=>String(t.id)===String(e)?`self`:t.locked?`locked`:t.type===`group`?`group`:k(Zt,e,t.id)?`cycle`:null,[Zt]),$t=t.useCallback((e,t)=>Qt(e,t)===null,[Qt]),en=t.useRef(null),[G,tn]=t.useState(null),nn=t.useRef(null);t.useEffect(()=>{nn.current=G},[G]),t.useEffect(()=>{if(!G)return;let e=e=>{let t=en.current?.getBoundingClientRect();if(!t)return;let n=e.clientX-t.left,r=e.clientY-t.top;tn(e=>e&&{...e,x:n,y:r})},t=()=>{let e=nn.current;if(e&&e.targetId!=null&&z){let t=N.find(t=>String(t.id)===String(e.sourceId)),n=N.find(t=>String(t.id)===String(e.targetId)),r=e.targetEnd??`start`,i=j?`${e.sourceEnd===`end`?`f`:`s`}${r===`end`?`f`:`s`}`:`fs`;t&&n&&$t(e.sourceId,n)&&(h?.(t,n,i)??!0)&&z(t,n,i)}else e&&e.rejectedReason&&z&&i.toast.error(P(`gantt.link.rejected.${e.rejectedReason}`));Ot.current=!0,window.setTimeout(()=>{Ot.current=!1},0),tn(null)};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[G,N,z,h,$t,j,P]);let[rn,an]=t.useState(null),on=t.useRef(null);t.useEffect(()=>{if(!rn)return;let e=e=>{on.current&&e.target instanceof Node&&on.current.contains(e.target)||an(null)},t=e=>{e.key===`Escape`&&an(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[rn]);let[sn,cn]=t.useState(null),ln=t.useRef(null);t.useEffect(()=>{if(!sn)return;let e=e=>{ln.current&&e.target instanceof Node&&ln.current.contains(e.target)||cn(null)},t=e=>{e.key===`Escape`&&cn(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[sn]);let[un,dn]=t.useState(null),[fn,pn]=t.useState(``),mn=t.useRef(null);t.useEffect(()=>{if(!un)return;let e=e=>{mn.current&&e.target instanceof Node&&mn.current.contains(e.target)||dn(null)},t=e=>{e.key===`Escape`&&dn(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[un]);let[hn,gn]=t.useState(null),_n=!!(s||R||z||Ke),vn=t.useCallback((e,t)=>{t.preventDefault(),t.stopPropagation(),gn(e.id),_n&&an({x:t.clientX,y:t.clientY,taskId:e.id})},[_n]),yn=t.useCallback((e,t,n,r)=>{r.preventDefault(),r.stopPropagation(),!(!z&&!qe)&&cn({x:r.clientX,y:r.clientY,sourceId:e,targetId:t,type:n})},[z,qe]),[bn,xn]=t.useState(()=>new Set(et?.collapsedIds??[])),Sn=t.useCallback(e=>{xn(t=>{let n=new Set(t),r=String(e);return n.has(r)?n.delete(r):n.add(r),n})},[]),Cn=t.useRef(et?.collapsedIds!=null);t.useEffect(()=>{if(Cn.current||D==null||U.length===0)return;Cn.current=!0;let e=new Map(U.map(e=>[String(e.id),e])),t=new Set;for(let n of U){let r=n.parent!=null&&n.parent!==``?String(n.parent):null;r&&r!==String(n.id)&&e.has(r)&&t.add(r)}let n=t=>{let n=0,r=new Set([String(t.id)]),i=t.parent!=null&&t.parent!==``?e.get(String(t.parent)):void 0;for(;i&&!r.has(String(i.id));)n+=1,r.add(String(i.id)),i=i.parent!=null&&i.parent!==``?e.get(String(i.parent)):void 0;return n},r=new Set;for(let e of U){let i=String(e.id);t.has(i)&&n(e)>=D&&r.add(i)}r.size&&xn(e=>e.size?e:r)},[D,U]);let K=t.useMemo(()=>{let e=new Set(U.map(e=>String(e.id))),t=new Map,n=[];for(let r of U){let i=r.parent!=null&&r.parent!==``?String(r.parent):null;if(i&&i!==String(r.id)&&e.has(i)){let e=t.get(i);e?e.push(r):t.set(i,[r])}else n.push(r)}let r=new Map,i=(e,n)=>{let a=String(e.id),o=r.get(a);if(o)return o;let s=t.get(a)??[],c;if(!s.length||n.has(a))c={start:e.start,end:e.end,progress:e.progress};else{n.add(a);let e=null,t=null,r=0,o=0;for(let a of s){let s=i(a,n);(!e||s.start<e)&&(e=s.start),(!t||s.end>t)&&(t=s.end);let c=Math.max(s.end.getTime()-s.start.getTime(),be);r+=c*s.progress,o+=c}n.delete(a),c={start:e,end:t,progress:o?r/o:0}}return r.set(a,c),c},a=[],o=new Set,s=e=>{for(let n of t.get(String(e.id))??[])o.has(String(n.id))||(o.add(String(n.id)),s(n))},c=(e,n)=>{let r=String(e.id);if(o.has(r))return;o.add(r);let l=t.get(r)??[],u=l.length>0,d=u||e.type===`summary`,f=u&&re===`self`&&e.hasOwnDates!==!1,p=u&&!f?i(e,new Set):{start:e.start,end:e.end,progress:e.progress},m=!d&&(e.type===`milestone`||e.end.getTime()<=e.start.getTime());if(a.push({task:e,depth:n,hasChildren:u,isSummary:d,isMilestone:m,...p}),u){if(bn.has(r))s(e);else for(let e of l)c(e,n+1)}};for(let e of n)c(e,0);for(let e of U)o.has(String(e.id))||c(e,0);return a},[U,bn,re]),wn=t.useCallback(e=>{if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement)return;if((e.ctrlKey||e.metaKey)&&(e.key===`z`||e.key===`Z`)){e.preventDefault(),e.shiftKey?Wt():Ut();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`Y`)){e.preventDefault(),Wt();return}if(!K.length)return;let t=hn==null?-1:K.findIndex(e=>String(e.task.id)===String(hn));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?Math.min(K.length-1,t+1):Math.max(0,t<=0?0:t-1);gn(K[n].task.id);let r=Z.current;if(r){let e=n*B;e<r.scrollTop?r.scrollTop=e:e+B>r.scrollTop+r.clientHeight&&(r.scrollTop=e+B-r.clientHeight)}return}if(t<0)return;let n=K[t];e.key===`Enter`?(e.preventDefault(),s?.(n.task)):e.key===`Delete`||e.key===`Backspace`?Ke&&(e.preventDefault(),Ke(n.task)):(e.key===`ArrowRight`&&n.hasChildren&&bn.has(String(n.task.id))||e.key===`ArrowLeft`&&n.hasChildren&&!bn.has(String(n.task.id)))&&(e.preventDefault(),Sn(n.task.id))},[K,hn,s,Ke,bn,Sn,B,Ut,Wt]),q=t.useMemo(()=>{let e=Ne?new Date(Ne):M.now(),t=Pe?new Date(Pe):M.now();return!Ne&&N.length>0&&(e=new Date(Math.min(...N.map(e=>e.start.getTime()))),e.setDate(e.getDate()-7)),!Pe&&N.length>0&&(t=new Date(Math.max(...N.map(e=>e.end.getTime()))),t.setDate(t.getDate()+14)),e=V===`day`&&S&&S.bands.length>0?A(e,S.dayStartMin):Ce(e,V),t.setHours(23,59,59,999),{start:e,end:t}},[Ne,Pe,N,V,S,M]),Tn=V===`day`&&!!S&&S.bands.length>0,En=!Tn&&V===`day`&&!!x&&(!!x.skipWeekends||!!(x.holidays&&x.holidays.size)),Dn=t.useCallback(e=>{if(!x)return!0;if(x.skipWeekends){let t=e.getDay();if(t===0||t===6)return!1}if(x.holidays&&x.holidays.size){let t=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;if(x.holidays.has(t))return!1}return!0},[x]),J=t.useMemo(()=>{let e=[];if(Tn&&S){let t=new Date(q.start);for(;t<=q.end;)for(let n of S.bands){let r=n.durMs/be*ht;e.push({date:new Date(t),label:n.label,isWeekend:!1,width:r,realMs:n.durMs,bandColor:n.color}),t=new Date(t.getTime()+n.durMs)}return e}let t=new Date(q.start);for(;t<=q.end;){let n=Te(t,1,V);if(En&&!Dn(t)){t=n;continue}let r=(n.getTime()-t.getTime())/be*ht,i,a;V===`day`?(i=String(t.getDate()),a=t.toLocaleDateString(F,{weekday:`narrow`})):i=V===`week`?t.toLocaleDateString(F,{month:`numeric`,day:`numeric`}):V===`month`?t.toLocaleDateString(F,{month:`short`}):V===`quarter`?`Q${Math.floor(t.getMonth()/3)+1}`:String(t.getFullYear()),e.push({date:new Date(t),label:i,sublabel:a,isWeekend:V===`day`&&(t.getDay()===0||t.getDay()===6),width:r}),t=n}return e},[q,V,ht,F,En,Dn,Tn,S]),Y=t.useMemo(()=>{let e=Array(J.length+1),t=0;for(let n=0;n<J.length;n++)e[n]=t,t+=J[n].width;return e[J.length]=t,e},[J]),On=Y[Y.length-1],kn=t.useMemo(()=>J.map(e=>e.date.getTime()),[J]),An=t.useMemo(()=>J.map(e=>e.realMs==null?Te(e.date,1,V).getTime()-e.date.getTime():e.realMs),[J,V]),X=t.useCallback(e=>{let t=J.length;if(t===0)return 0;let n=e.getTime(),r=0,i=t-1,a=0;for(;r<=i;){let e=r+i>>1;kn[e]<=n?(a=e,r=e+1):i=e-1}let o=An[a]||864e5,s=(n-kn[a])/o;return(En||Tn)&&(s=Math.max(0,Math.min(s,1))),Y[a]+s*J[a].width},[J,kn,An,Y,En,Tn]),jn=t.useCallback(e=>{let t=J.length;if(t===0)return new Date(q.start);let n=0,r=t-1,i=0;for(;n<=r;){let t=n+r>>1;Y[t]<=e?(i=t,n=t+1):r=t-1}let a=J[i].width||1,o=(e-Y[i])/a;return new Date(kn[i]+o*(An[i]||864e5))},[J,kn,An,Y,q]),Mn=t.useCallback(e=>{let t=Z.current;st.current==null&&t&&t.clientWidth>0&&(st.current=jn(t.scrollLeft)),ot.current=st.current,ct.current=!0,at(e),p?.(e)},[p,jn]);t.useLayoutEffect(()=>{let e=ot.current;if(e==null)return;ot.current=null;let t=Z.current;if(!t||t.clientWidth===0)return;let n=Math.max(0,t.scrollWidth-t.clientWidth),r=Math.max(0,Math.min(Math.round(X(Ce(e,V))),n));t.scrollLeft!==r&&(t.scrollLeft=r)},[V,X]);let Nn=t.useCallback((e,t)=>{let n=J.length;if(n===0||t===0)return new Date(e);let r=e.getTime(),i=0,a=n-1,o=0;for(;i<=a;){let e=i+a>>1;kn[e]<=r?(o=e,i=e+1):a=e-1}let s=Math.min(n-1,Math.max(0,o+t)),c=r-kn[o];return new Date(kn[s]+c)},[J,kn]),Pn=t.useRef(null);Pn.current=En||Tn?Nn:null;let Fn=t.useMemo(()=>{let e=[];if(Tn&&S){let t=0;for(let n of J){let r=String(A(n.date,S.dayStartMin).getTime()),i=e[e.length-1];i&&i.key===r?i.width+=n.width:e.push({key:r,label:n.date.toLocaleDateString(F,{month:`short`,day:`numeric`}),width:n.width,offset:t}),t+=n.width}return e}let t=V===`year`?`decade`:V===`month`||V===`quarter`?`year`:`month`,n=0;for(let r of J){let i=r.date.getFullYear(),a=Math.floor(i/10)*10,o=t===`decade`?String(a):t===`year`?String(i):`${i}-${r.date.getMonth()}`,s=e[e.length-1];s&&s.key===o?s.width+=r.width:e.push({key:o,label:t===`decade`?`${a}s`:t===`year`?String(i):r.date.toLocaleDateString(F,{month:`short`,year:`numeric`}),width:r.width,offset:n}),n+=r.width}return e},[J,V,F,Tn,S]),In=t.useMemo(()=>(Fe??[]).map((e,t)=>{let n=e.date instanceof Date?e.date:new Date(e.date);return{index:t,label:e.label,color:e.color||`hsl(var(--primary))`,left:Math.round(X(n)),valid:!isNaN(n.getTime())&&n>=q.start&&n<=q.end}}).filter(e=>e.valid),[Fe,q,X]),Ln=t.useRef(null),Rn=t.useRef(null),zn=t.useRef(null),Z=t.useRef(null);t.useEffect(()=>{let e=Z.current;if(!e)return;let t=()=>{ct.current=!1},n=new Set([`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `,`Spacebar`]),r=e=>{n.has(e.key)&&t()};return e.addEventListener(`wheel`,t,{passive:!0}),e.addEventListener(`touchstart`,t,{passive:!0}),e.addEventListener(`pointerdown`,t,{passive:!0}),e.addEventListener(`keydown`,r),()=>{e.removeEventListener(`wheel`,t),e.removeEventListener(`touchstart`,t),e.removeEventListener(`pointerdown`,t),e.removeEventListener(`keydown`,r)}},[]);let[Bn,Vn]=t.useState(null),Hn=t.useRef([]),Un=t.useRef(null),[Wn,Gn]=t.useState({top:0,left:0}),[Kn,qn]=t.useState({width:4e3,height:600}),Jn=t.useCallback(()=>{let e=Z.current;if(!e)return;let t=e.clientWidth||4e3,n=e.clientHeight||600;qn(e=>e.width===t&&e.height===n?e:{width:t,height:n})},[]);t.useLayoutEffect(()=>{Jn();let e=Z.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(Jn);return t.observe(e),()=>t.disconnect()},[Jn]);let Yn=t.useMemo(()=>we(Y,Wn.left-240,Wn.left+Kn.width+240),[Y,Wn.left,Kn.width]),Xn=t.useMemo(()=>{let e=Fn.map(e=>e.offset);return e.push(On),e},[Fn,On]),Zn=t.useMemo(()=>we(Xn,Wn.left-240,Wn.left+Kn.width+240),[Xn,Wn.left,Kn.width]),Q=t.useMemo(()=>({startIdx:Math.max(0,Math.floor(Wn.top/B)-6),endIdx:Math.min(K.length,Math.ceil((Wn.top+Kn.height)/B)+6)}),[Wn.top,Kn.height,B,K.length]),Qn=K.length*B,[$n,er]=t.useState(!1);t.useEffect(()=>{let e=()=>er(!!document.fullscreenElement);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let tr=t.useCallback(()=>{let e=ze.current;e&&(document.fullscreenElement?document.exitFullscreen?.():e.requestFullscreen?.())},[]),nr=t.useRef(null),rr=t.useCallback(e=>{if(e.touches.length===2){let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;nr.current={baseDistance:Math.max(1,Math.sqrt(t*t+n*n)),baseColumn:mt}}},[mt]),ir=t.useCallback(e=>{if(e.touches.length!==2||!nr.current)return;let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY,r=Math.max(1,Math.sqrt(t*t+n*n))/nr.current.baseDistance,i=Math.max(15,Math.min(120,Math.round(nr.current.baseColumn*r)));nt(i)},[]),ar=t.useCallback(()=>{nr.current=null},[]),or=t.useMemo(()=>{let e=M.now();return e<q.start||e>q.end?null:Math.round(X(e))},[q,X,M]),sr=t.useCallback(()=>{if(or==null||!Z.current)return;let e=Math.max(0,or-Z.current.clientWidth/2);Z.current.scrollTo({left:e,behavior:`smooth`})},[or]),cr=t.useRef(!1);t.useEffect(()=>{if(cr.current||N.length===0)return;let e=window.requestAnimationFrame(()=>{let e=Z.current;if(!e||e.clientWidth===0)return;let t=or;if(t==null){let e=new Date(Math.min(...N.map(e=>e.start.getTime())));t=Math.round(X(e))}e.scrollLeft=Math.max(0,t-e.clientWidth/2),cr.current=!0});return()=>window.cancelAnimationFrame(e)},[N,or,X]);let lr=t.useCallback((e,t=`left`)=>{let n=Z.current;if(!n||e<q.start||e>q.end)return!1;let r=Math.round(X(e)),i=t===`center`?r-n.clientWidth/2:r-24;return n.scrollTo({left:Math.max(0,i),behavior:`smooth`}),!0},[q,X]),ur=t.useCallback((e,t,n)=>{let r=Z.current;if(!r)return;let i=X(e),a=X(t),o=Math.max(0,r.scrollWidth-r.clientWidth),s=Math.min(96,r.clientWidth*.15),c=a-i<=r.clientWidth-s?(i+a)/2-r.clientWidth/2:i-s,l=Math.max(0,Math.min(c,o));Hn.current.forEach(e=>window.clearTimeout(e)),Hn.current=[],Un.current?.(),Un.current=null,Vn(null);let u=()=>{if(n==null)return;let e=window.requestAnimationFrame(()=>{Vn(n),Hn.current.push(window.setTimeout(()=>Vn(e=>e===n?null:e),1500))});Un.current=()=>window.cancelAnimationFrame(e)},d=Math.abs(r.scrollLeft-l)>2;if(r.scrollTo({left:l,behavior:`smooth`}),!d){u();return}let f=`onscrollend`in r,p=!1,m=()=>{p||(p=!0,r.removeEventListener(`scrollend`,m),u())};r.addEventListener(`scrollend`,m),Hn.current.push(window.setTimeout(m,f?1500:500)),Un.current=()=>r.removeEventListener(`scrollend`,m)},[X]);t.useEffect(()=>()=>{Hn.current.forEach(e=>window.clearTimeout(e)),Un.current?.()},[]);let dr=t.useCallback(()=>lr(Ce(M.now(),`week`)),[lr,M]),fr=t.useCallback(()=>lr(Ce(M.now(),`month`)),[lr,M]),pr=t.useRef(null),mr=t.useRef(null),hr=t.useRef(null),gr=t.useRef(null),_r=t.useRef(null),vr=t.useRef(null),yr=t.useRef(null),br=t.useRef(null),xr=t.useCallback(()=>{let e=zn.current,t=pr.current,n=mr.current,r=hr.current;if(e&&t&&n&&r){let i=e.scrollWidth>e.clientWidth+1;if(t.style.display=i?`block`:`none`,i){let t=n.clientWidth;if(t>0){let n=Math.min(t,Math.max(40,e.clientWidth/e.scrollWidth*t)),i=e.scrollWidth-e.clientWidth,a=i>0?e.scrollLeft/i*(t-n):0;r.style.width=`${n}px`,r.style.transform=`translateX(${a}px)`}}}let i=_r.current,a=vr.current,o=yr.current;if(e&&i&&a&&o){let t=e.scrollHeight>e.clientHeight+1;if(i.style.display=t?`block`:`none`,t){let t=a.clientHeight;if(t>0){let n=Math.min(t,Math.max(40,e.clientHeight/e.scrollHeight*t)),r=e.scrollHeight-e.clientHeight,i=r>0?e.scrollTop/r*(t-n):0;o.style.height=`${n}px`,o.style.transform=`translateY(${i}px)`}}}},[]);t.useEffect(()=>{xr()});let Sr=e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=zn.current,n=mr.current,r=hr.current;if(!t||!n||!r)return;gr.current={startX:e.clientX,startLeft:t.scrollLeft};let i=n.clientWidth,a=r.getBoundingClientRect().width,o=t.scrollWidth-t.clientWidth,s=i-a>0?o/(i-a):0,c=e=>{let n=gr.current;n&&(t.scrollLeft=n.startLeft+(e.clientX-n.startX)*s)},l=()=>{gr.current=null,window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),window.removeEventListener(`pointercancel`,l)};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l),window.addEventListener(`pointercancel`,l)},Cr=e=>{if(e.button!==0||e.target!==e.currentTarget)return;let t=zn.current,n=mr.current,r=hr.current;if(!t||!n||!r)return;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect().width,o=t.scrollWidth-t.clientWidth,s=i.width-a;s<=0||(t.scrollLeft=Math.min(Math.max(e.clientX-i.x-a/2,0),s)/s*o)},wr=e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=zn.current,n=vr.current,r=yr.current;if(!t||!n||!r)return;br.current={startY:e.clientY,startTop:t.scrollTop};let i=n.clientHeight,a=r.getBoundingClientRect().height,o=t.scrollHeight-t.clientHeight,s=i-a>0?o/(i-a):0,c=e=>{let n=br.current;n&&(t.scrollTop=n.startTop+(e.clientY-n.startY)*s)},l=()=>{br.current=null,window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),window.removeEventListener(`pointercancel`,l)};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l),window.addEventListener(`pointercancel`,l)},Tr=e=>{if(e.button!==0||e.target!==e.currentTarget)return;let t=zn.current,n=vr.current,r=yr.current;if(!t||!n||!r)return;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect().height,o=t.scrollHeight-t.clientHeight,s=i.height-a;s<=0||(t.scrollTop=Math.min(Math.max(e.clientY-i.y-a/2,0),s)/s*o)},Er=e=>{let t=e.currentTarget;!ct.current&&t.clientWidth>0&&(st.current=jn(t.scrollLeft)),Ln.current&&(Ln.current.scrollLeft=t.scrollLeft),xr(),Rn.current&&Rn.current.scrollTop!==t.scrollTop&&(Rn.current.scrollTop=t.scrollTop),Gn(e=>e.top===t.scrollTop&&e.left===t.scrollLeft?e:{top:t.scrollTop,left:t.scrollLeft}),Jn()},Dr=e=>{let t=e.currentTarget,n=Z.current;n&&n.scrollTop!==t.scrollTop&&(n.scrollTop=t.scrollTop),Gn(e=>e.top===t.scrollTop?e:{...e,top:t.scrollTop})},Or=(e,t)=>{let n=X(e),r=Tn&&S?ht*Math.min(...S.bands.map(e=>e.durMs))/be:ht;return{left:n,width:Math.max(X(t)-n,r,3)}},kr=W?.group?W.taskId:null,Ar=t.useMemo(()=>{if(kr==null)return null;let e=new Set([String(kr)]);for(let t of Tt(kr))t.locked||e.add(String(t.id));return e},[kr,Tt]),jr=t.useMemo(()=>{if(!W||W.group)return null;let e=new Set,t=new Set,n=wt.get(String(W.taskId));for(;n&&n.parent!=null&&n.parent!==``;){let r=String(n.parent);if(t.has(r)||!wt.has(r))break;t.add(r),e.add(r),n=wt.get(r)}return e.size?e:null},[W,wt]),Mr=e=>{if(W){if(Ar?.has(String(e.task.id))){let t=kt(W).start.getTime()-W.originStart.getTime();return Or(new Date(e.start.getTime()+t),new Date(e.end.getTime()+t))}if(W.taskId===e.task.id&&!W.group){let e=kt(W);return Or(e.start,e.end)}if(e.isSummary&&jr?.has(String(e.task.id))&&(re!==`self`||e.task.hasOwnDates===!1)){let t=kt(W),n=String(W.taskId),r=null,i=null;for(let a of Tt(e.task.id)){if((Ct.get(String(a.id))??[]).length!==0)continue;let e=String(a.id)===n?t.start:a.start,o=String(a.id)===n?t.end:a.end;(!r||e<r)&&(r=e),(!i||o>i)&&(i=o)}if(r&&i)return Or(r,i)}}return Or(e.start,e.end)},Nr=t.useMemo(()=>{let e=new Map;K.forEach((t,n)=>e.set(String(t.task.id),n));let t=[];return K.forEach(({task:n},r)=>{for(let i of n.dependencies??[]){let a=typeof i==`object`&&!!i,o=a?i.id:i;if(o==null||o===``)continue;let s=e.get(String(o));if(s==null||s===r)continue;let c=a?i.type:void 0,l=c===`ss`||c===`ff`||c===`sf`?c:`fs`;t.push({key:`${String(o)}->${String(n.id)}:${l}`,sourceId:o,targetId:n.id,type:l,sourceIndex:s,targetIndex:r})}}),t},[K]),Pr=Math.max(2,Math.round(B/2)-14),Fr=B-Pr*2,Ir=Math.round(Fr/2),Lr=Math.max(Math.round(B*.4),12),Rr=Lr*Math.SQRT2/2,zr=Fr,Br=Pr,Vr=Math.max(3,Math.round(B*.13)),Hr=B-Vr-1,Ur=`rgba(100, 116, 139, 0.35)`,Wr=`rgba(100, 116, 139, 0.6)`,Gr=e=>{let t=K[e.sourceIndex],n=K[e.targetIndex];if(!t||!n)return null;let r=Mr(t),i=Mr(n),a=e=>e.isSummary?Br+zr/2:B/2,o=e.sourceIndex*B+a(t),s=e.targetIndex*B+a(n),c=e.type===`fs`||e.type===`ff`,l=e.type===`ff`||e.type===`sf`,u=t.isMilestone?r.left+(c?Rr:-Rr):c?r.left+r.width:r.left,d=n.isMilestone?i.left+(l?Rr:-Rr):l?i.left+i.width:i.left,f=u+(c?10:-10),p=d+(l?10:-10),m=Math.round,h=[`M ${m(u)} ${m(o)}`,`L ${m(f)} ${m(o)}`];if(l?f>=p:f<=p)h.push(`L ${m(f)} ${m(s)}`,`L ${m(d)} ${m(s)}`);else{let t=s>=o?(e.sourceIndex+1)*B:e.sourceIndex*B;h.push(`L ${m(f)} ${m(t)}`,`L ${m(p)} ${m(t)}`,`L ${m(p)} ${m(s)}`,`L ${m(d)} ${m(s)}`)}return h.join(` `)},Kr=W?.taskId??xt,[qr,Jr]=t.useState(b),Yr=t.useMemo(()=>qr?ie(N,x):null,[qr,N,x]),Xr=t.useCallback(e=>Yr?.criticalIds.has(String(e))??!1,[Yr]),$=`#dc2626`,[Zr,Qr]=t.useState(null),[$r,ei]=t.useState(!1);t.useEffect(()=>{if(!$r)return;let e=setTimeout(()=>ei(!1),2500);return()=>clearTimeout(e)},[$r]);let ti=t.useCallback(()=>{if(!R)return;let{changes:e,skippedLocked:t}=O(N,x,zt);if(!e.length){ei(!0);return}Qr({changes:e,skipped:t.length})},[N,R,x,zt]),ni=t.useCallback(()=>{if(!Zr)return;let e=[];for(let t of Zr.changes){let n=N.find(e=>String(e.id)===t.id);n&&e.push({task:n,changes:{start:t.start,end:t.end}})}e.length&&Ft(e),Qr(null)},[Zr,N,Ft]),ri=t.useCallback(()=>{if(typeof document>`u`||!N.length)return null;let e=e=>String(e).replace(/[&<>"]/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`})[e]),t=Math.max(H,200),n=Math.ceil(t+On),r=Math.ceil(36+K.length*B),i=Yr?.criticalEdges??null,a=[];a.push(`<rect x="0" y="0" width="${n}" height="${r}" fill="#ffffff"/>`),a.push(`<rect x="0" y="0" width="${n}" height="36" fill="#f8fafc"/>`),a.push(`<g transform="translate(${t},0)" font-family="sans-serif" font-size="10" fill="#475569">`),Fn.forEach(t=>{a.push(`<line x1="${t.offset.toFixed(1)}" y1="0" x2="${t.offset.toFixed(1)}" y2="36" stroke="#e2e8f0"/>`),a.push(`<text x="${(t.offset+t.width/2).toFixed(1)}" y="12" text-anchor="middle" font-weight="600">${e(t.label)}</text>`)}),J.forEach((t,n)=>{let i=Y[n];a.push(`<line x1="${i.toFixed(1)}" y1="18" x2="${i.toFixed(1)}" y2="${r}" stroke="#eef2f7"/>`),a.push(`<text x="${(i+t.width/2).toFixed(1)}" y="30" text-anchor="middle" fill="#1f2937">${e(t.label)}</text>`)}),a.push(`</g>`),a.push(`<line x1="0" y1="18" x2="${n}" y2="18" stroke="#e2e8f0"/>`),a.push(`<line x1="0" y1="36" x2="${n}" y2="36" stroke="#cbd5e1"/>`),a.push(`<line x1="${t}" y1="0" x2="${t}" y2="${r}" stroke="#cbd5e1"/>`),a.push(`<g transform="translate(0,36)" font-family="sans-serif" font-size="11" fill="#1f2937">`),K.forEach((n,r)=>{let i=r*B;a.push(`<line x1="0" y1="${(i+B).toFixed(1)}" x2="${t}" y2="${(i+B).toFixed(1)}" stroke="#f1f5f9"/>`);let o=8+n.depth*14,s=Math.max(4,Math.floor((t-o)/6.5)),c=n.task.title.length>s?n.task.title.slice(0,s-1)+`…`:n.task.title,l=n.isSummary?` font-weight="600"`:``;a.push(`<text x="${o}" y="${(i+B/2+4).toFixed(1)}"${l}>${e(c)}</text>`)}),a.push(`</g>`);let o=(e,t)=>{let n=t-12;if(n<=9)return``;let r=0,i=``;for(let t of e){let a=t.charCodeAt(0)>255?9:5.5;if(r+a>n)return i.length<e.length?`${i.slice(0,-1)}…`:i;r+=a,i+=t}return i};a.push(`<g transform="translate(${t},36)" font-family="sans-serif" font-size="9">`),K.forEach((t,n)=>{if(t.task.type===`group`)return;let r=n*B,{left:i,width:s}=Or(t.start,t.end),c=Xr(t.task.id),l=c?` stroke="${$}" stroke-width="2"`:``;if(C&&t.task.baselineStart&&t.task.baselineEnd){let e=Or(t.task.baselineStart,t.task.baselineEnd);a.push(`<rect x="${e.left.toFixed(1)}" y="${(r+Hr).toFixed(1)}" width="${Math.max(2,e.width).toFixed(1)}" height="${Vr}" rx="1" fill="${Ur}" stroke="${Wr}"/>`)}if(t.isMilestone){let e=i,n=r+B/2,o=Lr/2,s=c?$:t.task.color||`#3b82f6`;a.push(`<polygon points="${e},${n-o} ${e+o},${n} ${e},${n+o} ${e-o},${n}" fill="${s}"/>`)}else if(t.isSummary){let n=t.task.color||`#64748b`;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Br).toFixed(1)}" width="${s.toFixed(1)}" height="${zr}" rx="3" fill="${n}"${l}/>`);let c=s*Math.min(100,Math.max(0,t.progress))/100;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Br).toFixed(1)}" width="${c.toFixed(1)}" height="${zr}" rx="3" fill="rgba(0,0,0,0.2)"/>`);let u=o(t.task.title,s);u&&a.push(`<text x="${(i+6).toFixed(1)}" y="${(r+B/2+3).toFixed(1)}" fill="#ffffff" font-weight="500">${e(u)}</text>`)}else{let n=t.task.color||`#3b82f6`;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Pr).toFixed(1)}" width="${s.toFixed(1)}" height="${Fr}" rx="3" fill="${n}"${l}/>`);let c=s*Math.min(100,Math.max(0,t.progress))/100;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Pr).toFixed(1)}" width="${c.toFixed(1)}" height="${Fr}" rx="3" fill="rgba(0,0,0,0.18)"/>`);let u=o(t.task.title,s);u?a.push(`<text x="${(i+6).toFixed(1)}" y="${(r+B/2+3).toFixed(1)}" fill="#ffffff" font-weight="500">${e(u)}</text>`):s>=24&&a.push(`<text x="${(i+s/2).toFixed(1)}" y="${(r+B/2+3).toFixed(1)}" text-anchor="middle" fill="#ffffff">${Math.round(t.progress)}%</text>`)}}),Nr.forEach(e=>{let t=Gr(e);if(!t)return;let n=i?.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,r=n?$:`#94a3b8`;a.push(`<path d="${t}" fill="none" stroke="${r}" stroke-width="${n?2:1.5}"/>`)}),or!=null&&a.push(`<line x1="${or.toFixed(1)}" y1="0" x2="${or.toFixed(1)}" y2="${K.length*B}" stroke="#ef4444" stroke-width="1.5"/>`);let s=K.length*B;return In.forEach(t=>{let n=/var\(/.test(t.color)?`#6366f1`:t.color;if(a.push(`<line x1="${t.left.toFixed(1)}" y1="0" x2="${t.left.toFixed(1)}" y2="${s}" stroke="${e(n)}" stroke-width="1.5"/>`),t.label){let r=t.label.length*6+8;a.push(`<rect x="${(t.left-r/2).toFixed(1)}" y="0" width="${r}" height="14" rx="2" fill="${e(n)}"/>`),a.push(`<text x="${t.left.toFixed(1)}" y="10" text-anchor="middle" font-size="9" font-weight="600" fill="#ffffff">${e(t.label)}</text>`)}}),a.push(`</g>`),{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${r}" viewBox="0 0 ${n} ${r}">${a.join(``)}</svg>`,W:n,H:r}},[N,K,Nr,Gr,Or,Xr,Yr,J,Y,On,H,B,Pr,Fr,Br,zr,Lr,or,V,C,Hr,Vr,Ur,Wr,In,Fn]),ii=t.useCallback(()=>{let e=(ue??``).replace(/[\\/:*?"<>|\s]+/g,` `).trim()||`gantt`,t=new Date,n=e=>String(e).padStart(2,`0`);return`${e}-${`${t.getFullYear()}${n(t.getMonth()+1)}${n(t.getDate())}-${n(t.getHours())}${n(t.getMinutes())}`}`},[ue]),ai=t.useCallback(async()=>{let e=ri();if(!e)return;let t=await Ee(e.svg,e.W,e.H);t&&t.toBlob(e=>{e&&De(e,`${ii()}.png`)},`image/png`)},[ri,ii]),oi=t.useCallback(async()=>{let e=ri();if(!e)return;let t=await Ee(e.svg,e.W,e.H);t&&De(Oe(ke(t.toDataURL(`image/jpeg`,.92)),t.width,t.height),`${ii()}.pdf`)},[ri,ii]),[si,ci]=t.useState(!1),li=t.useCallback(()=>{let e={viewMode:V,columnWidth:tt,taskListCollapsed:lt,taskListWidth:rt,collapsedIds:Array.from(bn)};ae&&Me(ae,e),oe?.(e),ci(!0)},[V,tt,lt,rt,bn,ae,oe]);return t.useEffect(()=>{if(!si)return;let e=setTimeout(()=>ci(!1),1500);return()=>clearTimeout(e)},[si]),(0,d.jsxs)(`div`,{ref:ze,className:(0,c.cn)(`flex flex-col h-full bg-background overflow-hidden min-w-0`,v),"data-readonly":L?`true`:void 0,"data-mobile-readonly":T&&Ve?`true`:void 0,children:[(0,d.jsx)(`style`,{children:`
15
+ `;for(let e of o)d+=`${String(e).padStart(10,`0`)} 00000 n \n`;return d+=`trailer\n<< /Size 6 /Root 1 0 R >>\nstartxref\n${u}\n%%EOF\n`,c(r(d)),new Blob(a,{type:`application/pdf`})}function Ge(e){let t=e.slice(e.indexOf(`,`)+1),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}var Ke=`gantt-layout:`;function qe(e){if(!e||typeof window>`u`)return null;try{let t=window.localStorage.getItem(Ke+e);if(!t)return null;let n=JSON.parse(t),r=n.viewMode&&I.includes(n.viewMode)?n.viewMode:null;if(!r)return null;let i=typeof n.columnWidth==`number`&&isFinite(n.columnWidth)?n.columnWidth:null,a=typeof n.taskListWidth==`number`&&isFinite(n.taskListWidth)?n.taskListWidth:null,o=Array.isArray(n.collapsedIds)?n.collapsedIds.filter(e=>typeof e==`string`):void 0;return{viewMode:r,columnWidth:i,taskListCollapsed:!!n.taskListCollapsed,taskListWidth:a,collapsedIds:o}}catch{return null}}function Je(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(Ke+e,JSON.stringify(t))}catch{}}function R({tasks:e,viewMode:r,startDate:a,endDate:o,markers:c,onTaskClick:l,onTaskUpdate:d,onTaskDelete:m,onViewChange:h,onDependencyCreate:g,onBeforeDependencyCreate:_,onDependencyDelete:v,onTaskReorder:y,className:b,inlineEdit:ee=!1,autoSchedule:te=!1,rescheduleOnConflict:ne=!1,criticalPathDefault:re=!1,workingCalendar:x,shiftSegments:S,showBaselines:ie=!0,readOnly:C=!1,mobileReadOnly:w=!1,groupBy:T,ungroupedLabel:E=`Ungrouped`,defaultCollapsedDepth:ae,summaryExtent:D=`children`,persistLayoutKey:O,onLayoutChange:oe,onRefresh:le,refreshing:ue=!1,dependencyTypes:A=!0,timeZone:de,exportFileName:j,interactions:pe,onBeforeTaskUpdate:he}){let M=t.useMemo(()=>me(de),[de]),N=t.useMemo(()=>M.delta===0?e:e.map(e=>({...e,start:M.to(e.start),end:M.to(e.end),baselineStart:e.baselineStart?M.to(e.baselineStart):e.baselineStart,baselineEnd:e.baselineEnd?M.to(e.baselineEnd):e.baselineEnd})),[e,M]),ge=t.useMemo(()=>a&&M.delta!==0?M.to(a):a,[a,M]),_e=t.useMemo(()=>o&&M.delta!==0?M.to(o):o,[o,M]),ve=t.useMemo(()=>!c||M.delta===0?c:c.map(e=>typeof e.date==`string`&&(0,n.isRealCalendarDate)(e.date)?{...e,date:(0,n.toDisplayDate)(e.date)}:{...e,date:M.to((0,n.toDisplayDate)(e.date))}),[c,M]),{t:P}=ye(),F=(0,s.useDisplayLocale)(),we=t.useRef(null),{width:Te}=(0,u.useResizeObserver)(we),De=Te||(typeof window<`u`?window.innerWidth:1024),Ke=De<640,R=C||w&&Ke,Ye=pe?.move!==!1,Xe=pe?.resize!==!1,Ze=pe?.progress!==!1,Qe=pe?.link!==!1,z=t.useMemo(()=>{if(!R&&d)return M.delta===0?d:(e,t)=>{let n={...t};n.start instanceof Date&&(n.start=M.from(n.start)),n.end instanceof Date&&(n.end=M.from(n.end)),d(e,n)}},[R,d,M]),$e=R?void 0:m,B=R||!Qe?void 0:g,et=R||!Qe?void 0:v,tt=R?void 0:y,nt=!R&&ee,rt=!R&&te,it=!R&&ne,V=ke(De),at=t.useRef(void 0);at.current===void 0&&(at.current=qe(O));let ot=at.current,[st,ct]=t.useState(ot?ot.columnWidth:null),[lt,ut]=t.useState(ot?ot.taskListWidth??null:null),[H,dt]=t.useState(r&&I.includes(r)?r:ot?.viewMode??`day`);t.useEffect(()=>{r&&I.includes(r)&&dt(r)},[r]);let ft=t.useRef(null),pt=t.useRef(null),mt=t.useRef(!0),[U,ht]=t.useState(ot?ot.taskListCollapsed:!1),gt=t.useRef(!1);t.useEffect(()=>{!gt.current&&Ke&&(ht(!0),gt.current=!0)},[Ke]);let _t=Math.max(Ce,De-200),W=U?0:lt==null?Ee(De):Math.max(Ce,Math.min(lt,_t)),vt=t.useMemo(()=>{if(st!=null||_e||N.length===0)return null;let e=ge?new Date(ge):new Date(Math.min(...N.map(e=>e.start.getTime()))),t=new Date(Math.max(...N.map(e=>e.end.getTime())));ge||e.setDate(e.getDate()-7),t.setDate(t.getDate()+14),e=Me(e,H),t.setHours(23,59,59,999);let n=Math.max(1,(t.getTime()-e.getTime())/je),r=Math.max(0,De-W);if(r<=0)return null;let i=r/n*Ae[H];if(i<=Se)return null;let a=Math.min(i,r*.6);return a>Se?a:null},[st,N,ge,_e,H,De,W]),yt=st??vt??Se,bt=yt/Ae[H],xt=Oe(W),[St,Ct]=t.useState(null),[wt,Tt]=t.useState({}),[Et,Dt]=t.useState(null),Ot=t.useMemo(()=>{if(!T)return N;let e=new Set;for(let t of N){let n=t.parent!=null&&t.parent!==``?String(t.parent):null;n&&e.add(n)}let t=new Map;for(let n of N){if(e.has(String(n.id)))continue;let r=T(n),i=r?String(r.key):`__ungrouped__`,a=r?r.label:E,o=t.get(i);o||(o={key:i,label:a,items:[]},t.set(i,o)),o.items.push(n)}let n=[];for(let e of t.values()){let t=`__group__${e.key}`,r=e.items[0];n.push({id:t,title:e.label,start:r.start,end:r.end,progress:0,type:`summary`,parent:null,data:{__group:!0}});for(let r of e.items)n.push({...r,parent:t})}return n},[T,N,E]),kt=t.useMemo(()=>{let e=new Set(Ot.map(e=>String(e.id))),t=new Map;for(let n of Ot){let r=n.parent!=null&&n.parent!==``?String(n.parent):null;if(r&&r!==String(n.id)&&e.has(r)){let e=t.get(r);e?e.push(n):t.set(r,[n])}}return t},[Ot]),At=t.useMemo(()=>{let e=new Map;for(let t of Ot)e.set(String(t.id),t);return e},[Ot]),jt=t.useCallback(e=>{let t=[],n=new Set,r=e=>{for(let i of kt.get(e)??[]){let e=String(i.id);n.has(e)||(n.add(e),t.push(i),r(e))}};return r(String(e)),t},[kt]),[G,Mt]=t.useState(null),Nt=t.useRef(null);t.useEffect(()=>{Nt.current=G},[G]);let Pt=t.useRef(!1),Ft=t.useCallback(e=>{let t=H===`day`&&!!S&&S.bands.length>0,n=(e,t)=>Hn.current?Hn.current(e,t):L(e,t,`day`),r=new Date(e.originStart),i=new Date(e.originEnd);if(t&&S){let t=Math.min(...S.bands.map(e=>e.durMs));return e.mode===`move`?(r=n(e.originStart,e.unitDelta),i=new Date(e.originEnd.getTime()+(r.getTime()-e.originStart.getTime()))):e.mode===`resize-left`?(r=n(e.originStart,e.unitDelta),i.getTime()-r.getTime()<t&&(r=new Date(i.getTime()-t))):e.mode===`resize-right`&&(i=n(e.originEnd,e.unitDelta),i.getTime()-r.getTime()<t&&(i=new Date(r.getTime()+t))),{start:r,end:i}}let a=t=>Pe(t,n(t,e.unitDelta));if(e.mode===`move`){let t=a(e.originStart);r=L(e.originStart,t,`day`),i=L(e.originEnd,t,`day`)}else if(e.mode===`resize-left`){r=L(e.originStart,a(e.originStart),`day`);let t=L(i,-1,`day`);r.getTime()>t.getTime()&&(r=t)}else if(e.mode===`resize-right`){i=L(e.originEnd,a(e.originEnd),`day`);let t=L(r,1,`day`);i.getTime()<t.getTime()&&(i=t)}return{start:r,end:i}},[H,S]),It=e=>{let t=Ft(e);return Ie(t.start,t.end)},Lt=t.useRef(N);Lt.current=N;let Rt=t.useRef([]),zt=t.useRef([]),[Bt,Vt]=t.useState(0),Ht=t.useCallback(e=>{if(!z)return;let t=e.filter(e=>!e.task.locked);(async()=>{let e=t;if(he){let n=[];for(let e of t){let t;try{t=await he(e.task,e.changes)!==!1}catch{t=!1}t&&n.push(e)}e=n}let n=[];for(let{task:t,changes:r}of e){let e={},i={},a=!1;for(let n of Object.keys(r)){let o=r[n],s=t[n],c=o instanceof Date&&s instanceof Date?o.getTime()===s.getTime():o===s;e[n]=s,i[n]=o,c||(a=!0)}z(t,r),a&&n.push({taskId:String(t.id),before:e,after:i})}n.length&&(Rt.current.push(n),zt.current=[],Vt(e=>e+1))})()},[z,he]),[Ut,Wt]=t.useState(null),Gt=t.useCallback(e=>{if(!S)return e;let t=new Date(e);t.setHours(0,0,0,0);for(let n=-1;n<=1;n++){let r=t.getTime()+n*je+S.dayStartMin*6e4;for(let t of S.bands){if(r>=e)return r;r+=t.durMs}}return e},[S]),Kt=t.useMemo(()=>({summaryExtent:D,snapStart:S?Gt:void 0}),[D,S,Gt]),qt=t.useCallback(e=>{if(!it)return;let t=new Map;for(let{task:n,changes:r}of e)t.set(String(n.id),{start:r.start??n.start,end:r.end??n.end});let{changes:n}=ce(Lt.current.map(e=>{let n=t.get(String(e.id));return n?{...e,start:n.start,end:n.end}:e}),x,Kt),r=n.filter(e=>{let n=t.get(e.id);return!n||e.start.getTime()!==n.start.getTime()||e.end.getTime()!==n.end.getTime()});r.length&&Wt(r)},[it,x,Kt]),Jt=t.useCallback(()=>{if(!Ut)return;let e=Ut.map(e=>{let t=Lt.current.find(t=>String(t.id)===e.id);return t?{task:t,changes:{start:e.start,end:e.end}}:null}).filter(Boolean);e.length&&Ht(e),Wt(null)},[Ut,Ht]),Yt=t.useCallback((e,t)=>{if(z)for(let n of e){let e=Lt.current.find(e=>String(e.id)===n.taskId);e&&z(e,t===`undo`?n.before:n.after)}},[z]),Xt=t.useCallback(()=>{let e=Rt.current.pop();e&&(Yt(e,`undo`),zt.current.push(e),Vt(e=>e+1))},[Yt]),Zt=t.useCallback(()=>{let e=zt.current.pop();e&&(Yt(e,`redo`),Rt.current.push(e),Vt(e=>e+1))},[Yt]),{canUndo:Qt,canRedo:$t}=t.useMemo(()=>({canUndo:Rt.current.length>0,canRedo:zt.current.length>0}),[Bt]);t.useEffect(()=>{if(!G)return;let e=H===`day`&&!!S&&S.bands.length>0,t=e&&S?bt*Math.min(...S.bands.map(e=>e.durMs))/je:bt,n=e=>{let n=Nt.current;if(!n)return;let r=Math.round((e.clientX-n.originClientX)/Math.max(t,1));r!==n.unitDelta&&Mt({...n,unitDelta:r})},r=()=>{let t=Nt.current;if(t){if(t.unitDelta!==0){let n=N.find(e=>e.id===t.taskId);if(n&&z){let{start:r,end:i}=Ft(t);if(t.group){let i=Fe(t.originStart,r,e),a=[n,...jt(n.id).filter(e=>!e.locked)].map(e=>({task:e,changes:{start:i(e.start),end:i(e.end)}}));Ht(a),qt(a)}else{let e=[{task:n,changes:{start:r,end:i}}];Ht(e),qt(e)}}Pt.current=!0,window.setTimeout(()=>{Pt.current=!1},0)}Mt(null)}};return window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r),()=>{window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r)}},[G,yt,bt,H,S,N,z,Ft,jt,Ht,qt]);let en=t.useCallback((e,t,n,r)=>{!z||e.data?.__group||e.locked||(n.stopPropagation(),n.preventDefault(),Mt({taskId:e.id,mode:t,group:r?.group??!1,originStart:new Date(r?.originStart??e.start),originEnd:new Date(r?.originEnd??e.end),originClientX:n.clientX,unitDelta:0}))},[z]),[tn,nn]=t.useState(null),rn=t.useRef(null);t.useEffect(()=>{rn.current=tn},[tn]),t.useEffect(()=>{if(!tn)return;let e=e=>{let t=rn.current;if(!t)return;let n=Math.min(100,Math.max(0,Math.round(t.originProgress+(e.clientX-t.originClientX)/Math.max(t.barWidth,1)*100)));n!==t.value&&nn({...t,value:n})},t=()=>{let e=rn.current;if(e){if(e.value!==e.originProgress){let t=N.find(t=>t.id===e.taskId);t&&z&&Ht([{task:t,changes:{progress:e.value}}]),Pt.current=!0,window.setTimeout(()=>{Pt.current=!1},0)}nn(null)}};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[tn,N,z,Ht]);let an=t.useMemo(()=>{let e=[];for(let t of N)for(let n of t.dependencies??[]){let r=typeof n==`object`&&n?n.id:n;r!=null&&r!==``&&e.push([String(r),String(t.id)])}return e},[N]),on=t.useCallback((e,t)=>String(t.id)===String(e)?`self`:t.locked?`locked`:t.type===`group`?`group`:k(an,e,t.id)?`cycle`:null,[an]),sn=t.useCallback((e,t)=>on(e,t)===null,[on]),cn=t.useRef(null),[K,ln]=t.useState(null),un=t.useRef(null);t.useEffect(()=>{un.current=K},[K]),t.useEffect(()=>{if(!K)return;let e=e=>{let t=cn.current?.getBoundingClientRect();if(!t)return;let n=e.clientX-t.left,r=e.clientY-t.top;ln(e=>e&&{...e,x:n,y:r})},t=()=>{let e=un.current;if(e&&e.targetId!=null&&B){let t=N.find(t=>String(t.id)===String(e.sourceId)),n=N.find(t=>String(t.id)===String(e.targetId)),r=e.targetEnd??`start`,i=A?`${e.sourceEnd===`end`?`f`:`s`}${r===`end`?`f`:`s`}`:`fs`;t&&n&&sn(e.sourceId,n)&&(_?.(t,n,i)??!0)&&B(t,n,i)}else e&&e.rejectedReason&&B&&i.toast.error(P(`gantt.link.rejected.${e.rejectedReason}`));Pt.current=!0,window.setTimeout(()=>{Pt.current=!1},0),ln(null)};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[K,N,B,_,sn,A,P]);let[dn,fn]=t.useState(null),pn=t.useRef(null);t.useEffect(()=>{if(!dn)return;let e=e=>{pn.current&&e.target instanceof Node&&pn.current.contains(e.target)||fn(null)},t=e=>{e.key===`Escape`&&fn(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[dn]);let[mn,hn]=t.useState(null),gn=t.useRef(null);t.useEffect(()=>{if(!mn)return;let e=e=>{gn.current&&e.target instanceof Node&&gn.current.contains(e.target)||hn(null)},t=e=>{e.key===`Escape`&&hn(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[mn]);let[_n,vn]=t.useState(null),[yn,bn]=t.useState(``),xn=t.useRef(null);t.useEffect(()=>{if(!_n)return;let e=e=>{xn.current&&e.target instanceof Node&&xn.current.contains(e.target)||vn(null)},t=e=>{e.key===`Escape`&&vn(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[_n]);let[Sn,Cn]=t.useState(null),wn=!!(l||z||B||$e),Tn=t.useCallback((e,t)=>{t.preventDefault(),t.stopPropagation(),Cn(e.id),wn&&fn({x:t.clientX,y:t.clientY,taskId:e.id})},[wn]),En=t.useCallback((e,t,n,r)=>{r.preventDefault(),r.stopPropagation(),(B||et)&&hn({x:r.clientX,y:r.clientY,sourceId:e,targetId:t,type:n})},[B,et]),[Dn,On]=t.useState(()=>new Set(ot?.collapsedIds??[])),kn=t.useCallback(e=>{On(t=>{let n=new Set(t),r=String(e);return n.has(r)?n.delete(r):n.add(r),n})},[]),An=t.useRef(ot?.collapsedIds!=null);t.useEffect(()=>{if(An.current||ae==null||Ot.length===0)return;An.current=!0;let e=new Map(Ot.map(e=>[String(e.id),e])),t=new Set;for(let n of Ot){let r=n.parent!=null&&n.parent!==``?String(n.parent):null;r&&r!==String(n.id)&&e.has(r)&&t.add(r)}let n=t=>{let n=0,r=new Set([String(t.id)]),i=t.parent!=null&&t.parent!==``?e.get(String(t.parent)):void 0;for(;i&&!r.has(String(i.id));)n+=1,r.add(String(i.id)),i=i.parent!=null&&i.parent!==``?e.get(String(i.parent)):void 0;return n},r=new Set;for(let e of Ot){let i=String(e.id);t.has(i)&&n(e)>=ae&&r.add(i)}r.size&&On(e=>e.size?e:r)},[ae,Ot]);let q=t.useMemo(()=>{let e=new Set(Ot.map(e=>String(e.id))),t=new Map,n=[];for(let r of Ot){let i=r.parent!=null&&r.parent!==``?String(r.parent):null;if(i&&i!==String(r.id)&&e.has(i)){let e=t.get(i);e?e.push(r):t.set(i,[r])}else n.push(r)}let r=new Map,i=(e,n)=>{let a=String(e.id),o=r.get(a);if(o)return o;let s=t.get(a)??[],c;if(!s.length||n.has(a))c={start:e.start,end:e.end,progress:e.progress};else{n.add(a);let e=null,t=null,r=0,o=0;for(let a of s){let s=i(a,n);(!e||s.start<e)&&(e=s.start),(!t||s.end>t)&&(t=s.end);let c=Math.max(s.end.getTime()-s.start.getTime(),je);r+=c*s.progress,o+=c}n.delete(a),c={start:e,end:t,progress:o?r/o:0}}return r.set(a,c),c},a=[],o=new Set,s=e=>{for(let n of t.get(String(e.id))??[])o.has(String(n.id))||(o.add(String(n.id)),s(n))},c=(e,n)=>{let r=String(e.id);if(o.has(r))return;o.add(r);let l=t.get(r)??[],u=l.length>0,d=u||e.type===`summary`,f=u&&D===`self`&&e.hasOwnDates!==!1,p=u&&!f?i(e,new Set):{start:e.start,end:e.end,progress:e.progress},m=!d&&(e.type===`milestone`||e.end.getTime()<=e.start.getTime());if(a.push({task:e,depth:n,hasChildren:u,isSummary:d,isMilestone:m,...p}),u){if(Dn.has(r))s(e);else for(let e of l)c(e,n+1)}};for(let e of n)c(e,0);for(let e of Ot)o.has(String(e.id))||c(e,0);return a},[Ot,Dn,D]),jn=t.useCallback(e=>{if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement)return;if((e.ctrlKey||e.metaKey)&&(e.key===`z`||e.key===`Z`)){e.preventDefault(),e.shiftKey?Zt():Xt();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`Y`)){e.preventDefault(),Zt();return}if(!q.length)return;let t=Sn==null?-1:q.findIndex(e=>String(e.task.id)===String(Sn));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?Math.min(q.length-1,t+1):Math.max(0,t<=0?0:t-1);Cn(q[n].task.id);let r=Q.current;if(r){let e=n*V;e<r.scrollTop?r.scrollTop=e:e+V>r.scrollTop+r.clientHeight&&(r.scrollTop=e+V-r.clientHeight)}return}if(t<0)return;let n=q[t];e.key===`Enter`?(e.preventDefault(),l?.(n.task)):e.key===`Delete`||e.key===`Backspace`?$e&&(e.preventDefault(),$e(n.task)):(e.key===`ArrowRight`&&n.hasChildren&&Dn.has(String(n.task.id))||e.key===`ArrowLeft`&&n.hasChildren&&!Dn.has(String(n.task.id)))&&(e.preventDefault(),kn(n.task.id))},[q,Sn,l,$e,Dn,kn,V,Xt,Zt]),J=t.useMemo(()=>{let e=ge?new Date(ge):M.now(),t=_e?new Date(_e):M.now();return!ge&&N.length>0&&(e=new Date(Math.min(...N.map(e=>e.start.getTime()))),e.setDate(e.getDate()-7)),!_e&&N.length>0&&(t=new Date(Math.max(...N.map(e=>e.end.getTime()))),t.setDate(t.getDate()+14)),e=H===`day`&&S&&S.bands.length>0?fe(e,S.dayStartMin):Me(e,H),t.setHours(23,59,59,999),{start:e,end:t}},[ge,_e,N,H,S,M]),Mn=H===`day`&&!!S&&S.bands.length>0,Nn=!Mn&&H===`day`&&!!x&&(!!x.skipWeekends||!!(x.holidays&&x.holidays.size)),Pn=t.useCallback(e=>{if(!x)return!0;if(x.skipWeekends){let t=e.getDay();if(t===0||t===6)return!1}if(x.holidays&&x.holidays.size){let t=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;if(x.holidays.has(t))return!1}return!0},[x]),Y=t.useMemo(()=>{let e=[];if(Mn&&S){let t=new Date(J.start);for(;t<=J.end;)for(let n of S.bands){let r=n.durMs/je*bt;e.push({date:new Date(t),label:n.label,isWeekend:!1,width:r,realMs:n.durMs,bandColor:n.color}),t=new Date(t.getTime()+n.durMs)}return e}let t=new Date(J.start);for(;t<=J.end;){let n=L(t,1,H);if(Nn&&!Pn(t)){t=n;continue}let r=(n.getTime()-t.getTime())/je*bt,i,a;H===`day`?(i=String(t.getDate()),a=t.toLocaleDateString(F,{weekday:`narrow`})):i=H===`week`?t.toLocaleDateString(F,{month:`numeric`,day:`numeric`}):H===`month`?t.toLocaleDateString(F,{month:`short`}):H===`quarter`?`Q${Math.floor(t.getMonth()/3)+1}`:String(t.getFullYear()),e.push({date:new Date(t),label:i,sublabel:a,isWeekend:H===`day`&&(t.getDay()===0||t.getDay()===6),width:r}),t=n}return e},[J,H,bt,F,Nn,Pn,Mn,S]),X=t.useMemo(()=>{let e=Array(Y.length+1),t=0;for(let n=0;n<Y.length;n++)e[n]=t,t+=Y[n].width;return e[Y.length]=t,e},[Y]),Fn=X[X.length-1],In=t.useMemo(()=>Y.map(e=>e.date.getTime()),[Y]),Ln=t.useMemo(()=>Y.map(e=>e.realMs==null?L(e.date,1,H).getTime()-e.date.getTime():e.realMs),[Y,H]),Z=t.useCallback(e=>{let t=Y.length;if(t===0)return 0;let n=e.getTime(),r=0,i=t-1,a=0;for(;r<=i;){let e=r+i>>1;In[e]<=n?(a=e,r=e+1):i=e-1}let o=Ln[a]||864e5,s=(n-In[a])/o;return(Nn||Mn)&&(s=Math.max(0,Math.min(s,1))),X[a]+s*Y[a].width},[Y,In,Ln,X,Nn,Mn]),Rn=t.useCallback(e=>{let t=Y.length;if(t===0)return-1;let n=0,r=t-1,i=0;for(;n<=r;){let t=n+r>>1;X[t]<=e?(i=t,n=t+1):r=t-1}return i},[Y,X]),zn=t.useCallback(e=>{let t=Rn(e);if(t<0)return new Date(J.start);let n=Y[t].width||1,r=(e-X[t])/n;return new Date(In[t]+r*(Ln[t]||864e5))},[Rn,Y,In,Ln,X,J]),Bn=t.useCallback(e=>{let t=Q.current;pt.current==null&&t&&t.clientWidth>0&&(pt.current=zn(t.scrollLeft)),ft.current=pt.current,mt.current=!0,dt(e),h?.(e)},[h,zn]);t.useLayoutEffect(()=>{let e=ft.current;if(e==null)return;ft.current=null;let t=Q.current;if(!t||t.clientWidth===0)return;let n=Math.max(0,t.scrollWidth-t.clientWidth),r=Math.max(0,Math.min(Math.round(Z(Me(e,H))),n));t.scrollLeft!==r&&(t.scrollLeft=r)},[H,Z]);let Vn=t.useCallback((e,t)=>{let n=Y.length;if(n===0||t===0)return new Date(e);let r=e.getTime(),i=0,a=n-1,o=0;for(;i<=a;){let e=i+a>>1;In[e]<=r?(o=e,i=e+1):a=e-1}let s=Math.min(n-1,Math.max(0,o+t)),c=r-In[o];return new Date(In[s]+c)},[Y,In]),Hn=t.useRef(null);Hn.current=Nn||Mn?Vn:null;let Un=t.useMemo(()=>{let e=[];if(Mn&&S){let t=0;for(let n of Y){let r=String(fe(n.date,S.dayStartMin).getTime()),i=e[e.length-1];i&&i.key===r?i.width+=n.width:e.push({key:r,label:n.date.toLocaleDateString(F,{month:`short`,day:`numeric`}),width:n.width,offset:t}),t+=n.width}return e}let t=H===`year`?`decade`:H===`month`||H===`quarter`?`year`:`month`,n=0;for(let r of Y){let i=r.date.getFullYear(),a=Math.floor(i/10)*10,o=t===`decade`?String(a):t===`year`?String(i):`${i}-${r.date.getMonth()}`,s=e[e.length-1];s&&s.key===o?s.width+=r.width:e.push({key:o,label:t===`decade`?`${a}s`:t===`year`?String(i):r.date.toLocaleDateString(F,{month:`short`,year:`numeric`}),width:r.width,offset:n}),n+=r.width}return e},[Y,H,F,Mn,S]),Wn=t.useMemo(()=>(ve??[]).map((e,t)=>{let r=(0,n.toDisplayDate)(e.date);return{index:t,label:e.label,color:e.color||`hsl(var(--primary))`,left:Math.round(Z(r)),valid:!isNaN(r.getTime())&&r>=J.start&&r<=J.end}}).filter(e=>e.valid),[ve,J,Z]),Gn=t.useRef(null),Kn=t.useRef(null),qn=t.useRef(null),Q=t.useRef(null);t.useEffect(()=>{let e=Q.current;if(!e)return;let t=()=>{mt.current=!1},n=new Set([`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `,`Spacebar`]),r=e=>{n.has(e.key)&&t()};return e.addEventListener(`wheel`,t,{passive:!0}),e.addEventListener(`touchstart`,t,{passive:!0}),e.addEventListener(`pointerdown`,t,{passive:!0}),e.addEventListener(`keydown`,r),()=>{e.removeEventListener(`wheel`,t),e.removeEventListener(`touchstart`,t),e.removeEventListener(`pointerdown`,t),e.removeEventListener(`keydown`,r)}},[]);let[Jn,Yn]=t.useState(null),Xn=t.useRef([]),Zn=t.useRef(null),[Qn,$n]=t.useState({top:0,left:0}),[er,tr]=t.useState({width:4e3,height:600}),nr=t.useCallback(()=>{let e=Q.current;if(!e)return;let t=e.clientWidth||4e3,n=e.clientHeight||600;tr(e=>e.width===t&&e.height===n?e:{width:t,height:n})},[]);t.useLayoutEffect(()=>{nr();let e=Q.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(nr);return t.observe(e),()=>t.disconnect()},[nr]);let rr=t.useMemo(()=>Ne(X,Qn.left-240,Qn.left+er.width+240),[X,Qn.left,er.width]),ir=t.useMemo(()=>{let e=Un.map(e=>e.offset);return e.push(Fn),e},[Un,Fn]),ar=t.useMemo(()=>Ne(ir,Qn.left-240,Qn.left+er.width+240),[ir,Qn.left,er.width]),$=t.useMemo(()=>({startIdx:Math.max(0,Math.floor(Qn.top/V)-6),endIdx:Math.min(q.length,Math.ceil((Qn.top+er.height)/V)+6)}),[Qn.top,er.height,V,q.length]),or=q.length*V,sr=Re(H,Mn),cr=t.useMemo(()=>{let e=Rn(Qn.left);return ze(e>=0?Y[e].date:J.start,sr,S?.dayStartMin??0)},[Rn,Qn.left,Y,J,sr,S]),lr=t.useMemo(()=>Ve(cr,sr,F),[cr,sr,F]),ur=t.useCallback(e=>{let t=Q.current;if(!t)return;let n=Be(cr,e,sr),r=Math.max(0,Fn-er.width),i=Math.max(0,Math.min(Math.round(Z(n)),r));t.scrollLeft=i,$n(e=>e.left===i?e:{...e,left:i})},[cr,sr,Fn,er.width,Z]),[dr,fr]=t.useState(!1);t.useEffect(()=>{let e=()=>fr(!!document.fullscreenElement);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let pr=t.useCallback(()=>{let e=we.current;e&&(document.fullscreenElement?document.exitFullscreen?.():e.requestFullscreen?.())},[]),mr=t.useRef(null),hr=t.useCallback(e=>{if(e.touches.length===2){let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;mr.current={baseDistance:Math.max(1,Math.sqrt(t*t+n*n)),baseColumn:yt}}},[yt]),gr=t.useCallback(e=>{if(e.touches.length!==2||!mr.current)return;let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY,r=Math.max(1,Math.sqrt(t*t+n*n))/mr.current.baseDistance,i=Math.max(15,Math.min(120,Math.round(mr.current.baseColumn*r)));ct(i)},[]),_r=t.useCallback(()=>{mr.current=null},[]),vr=t.useMemo(()=>{let e=M.now();return e<J.start||e>J.end?null:Math.round(Z(e))},[J,Z,M]),yr=t.useCallback(()=>{if(vr==null||!Q.current)return;let e=Math.max(0,vr-Q.current.clientWidth/2);Q.current.scrollTo({left:e,behavior:`smooth`})},[vr]),br=t.useRef(!1);t.useEffect(()=>{if(br.current||N.length===0)return;let e=window.requestAnimationFrame(()=>{let e=Q.current;if(!e||e.clientWidth===0)return;let t=vr;if(t==null){let e=new Date(Math.min(...N.map(e=>e.start.getTime())));t=Math.round(Z(e))}e.scrollLeft=Math.max(0,t-e.clientWidth/2),br.current=!0});return()=>window.cancelAnimationFrame(e)},[N,vr,Z]);let xr=t.useCallback((e,t=`left`)=>{let n=Q.current;if(!n||e<J.start||e>J.end)return!1;let r=Math.round(Z(e)),i=t===`center`?r-n.clientWidth/2:r-24;return n.scrollTo({left:Math.max(0,i),behavior:`smooth`}),!0},[J,Z]),Sr=t.useCallback((e,t,n)=>{let r=Q.current;if(!r)return;let i=Z(e),a=Z(t),o=Math.max(0,r.scrollWidth-r.clientWidth),s=Math.min(96,r.clientWidth*.15),c=a-i<=r.clientWidth-s?(i+a)/2-r.clientWidth/2:i-s,l=Math.max(0,Math.min(c,o));Xn.current.forEach(e=>window.clearTimeout(e)),Xn.current=[],Zn.current?.(),Zn.current=null,Yn(null);let u=()=>{if(n==null)return;let e=window.requestAnimationFrame(()=>{Yn(n),Xn.current.push(window.setTimeout(()=>Yn(e=>e===n?null:e),1500))});Zn.current=()=>window.cancelAnimationFrame(e)},d=Math.abs(r.scrollLeft-l)>2;if(r.scrollTo({left:l,behavior:`smooth`}),!d){u();return}let f=`onscrollend`in r,p=!1,m=()=>{p||(p=!0,r.removeEventListener(`scrollend`,m),u())};r.addEventListener(`scrollend`,m),Xn.current.push(window.setTimeout(m,f?1500:500)),Zn.current=()=>r.removeEventListener(`scrollend`,m)},[Z]);t.useEffect(()=>()=>{Xn.current.forEach(e=>window.clearTimeout(e)),Zn.current?.()},[]);let Cr=t.useCallback(()=>xr(Me(M.now(),`week`)),[xr,M]),wr=t.useCallback(()=>xr(Me(M.now(),`month`)),[xr,M]),Tr=t.useRef(null),Er=t.useRef(null),Dr=t.useRef(null),Or=t.useRef(null),kr=t.useRef(null),Ar=t.useRef(null),jr=t.useRef(null),Mr=t.useRef(null),Nr=t.useCallback(()=>{let e=qn.current,t=Tr.current,n=Er.current,r=Dr.current;if(e&&t&&n&&r){let i=e.scrollWidth>e.clientWidth+1;if(t.style.display=i?`block`:`none`,i){let t=n.clientWidth;if(t>0){let n=Math.min(t,Math.max(40,e.clientWidth/e.scrollWidth*t)),i=e.scrollWidth-e.clientWidth,a=i>0?e.scrollLeft/i*(t-n):0;r.style.width=`${n}px`,r.style.transform=`translateX(${a}px)`}}}let i=kr.current,a=Ar.current,o=jr.current;if(e&&i&&a&&o){let t=e.scrollHeight>e.clientHeight+1;if(i.style.display=t?`block`:`none`,t){let t=a.clientHeight;if(t>0){let n=Math.min(t,Math.max(40,e.clientHeight/e.scrollHeight*t)),r=e.scrollHeight-e.clientHeight,i=r>0?e.scrollTop/r*(t-n):0;o.style.height=`${n}px`,o.style.transform=`translateY(${i}px)`}}}},[]);t.useEffect(()=>{Nr()});let Pr=e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=qn.current,n=Er.current,r=Dr.current;if(!t||!n||!r)return;Or.current={startX:e.clientX,startLeft:t.scrollLeft};let i=n.clientWidth,a=r.getBoundingClientRect().width,o=t.scrollWidth-t.clientWidth,s=i-a>0?o/(i-a):0,c=e=>{let n=Or.current;n&&(t.scrollLeft=n.startLeft+(e.clientX-n.startX)*s)},l=()=>{Or.current=null,window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),window.removeEventListener(`pointercancel`,l)};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l),window.addEventListener(`pointercancel`,l)},Fr=e=>{if(e.button!==0||e.target!==e.currentTarget)return;let t=qn.current,n=Er.current,r=Dr.current;if(!t||!n||!r)return;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect().width,o=t.scrollWidth-t.clientWidth,s=i.width-a;s<=0||(t.scrollLeft=Math.min(Math.max(e.clientX-i.x-a/2,0),s)/s*o)},Ir=e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=qn.current,n=Ar.current,r=jr.current;if(!t||!n||!r)return;Mr.current={startY:e.clientY,startTop:t.scrollTop};let i=n.clientHeight,a=r.getBoundingClientRect().height,o=t.scrollHeight-t.clientHeight,s=i-a>0?o/(i-a):0,c=e=>{let n=Mr.current;n&&(t.scrollTop=n.startTop+(e.clientY-n.startY)*s)},l=()=>{Mr.current=null,window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),window.removeEventListener(`pointercancel`,l)};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l),window.addEventListener(`pointercancel`,l)},Lr=e=>{if(e.button!==0||e.target!==e.currentTarget)return;let t=qn.current,n=Ar.current,r=jr.current;if(!t||!n||!r)return;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect().height,o=t.scrollHeight-t.clientHeight,s=i.height-a;s<=0||(t.scrollTop=Math.min(Math.max(e.clientY-i.y-a/2,0),s)/s*o)},Rr=e=>{let t=e.currentTarget;!mt.current&&t.clientWidth>0&&(pt.current=zn(t.scrollLeft)),Gn.current&&(Gn.current.scrollLeft=t.scrollLeft),Nr(),Kn.current&&Kn.current.scrollTop!==t.scrollTop&&(Kn.current.scrollTop=t.scrollTop),$n(e=>e.top===t.scrollTop&&e.left===t.scrollLeft?e:{top:t.scrollTop,left:t.scrollLeft}),nr()},zr=e=>{let t=e.currentTarget,n=Q.current;n&&n.scrollTop!==t.scrollTop&&(n.scrollTop=t.scrollTop),$n(e=>e.top===t.scrollTop?e:{...e,top:t.scrollTop})},Br=(e,t)=>{let n=Z(e),r=Mn&&S?bt*Math.min(...S.bands.map(e=>e.durMs))/je:bt;return{left:n,width:Math.max(Z(t)-n,r,3)}},Vr=G?.group?G.taskId:null,Hr=t.useMemo(()=>{if(Vr==null)return null;let e=new Set([String(Vr)]);for(let t of jt(Vr))t.locked||e.add(String(t.id));return e},[Vr,jt]),Ur=t.useMemo(()=>{if(!G||G.group)return null;let e=new Set,t=new Set,n=At.get(String(G.taskId));for(;n&&n.parent!=null&&n.parent!==``;){let r=String(n.parent);if(t.has(r)||!At.has(r))break;t.add(r),e.add(r),n=At.get(r)}return e.size?e:null},[G,At]),Wr=e=>{if(G){if(Hr?.has(String(e.task.id))){let t=Ft(G),n=Fe(G.originStart,t.start,Mn);return Br(n(e.start),n(e.end))}if(G.taskId===e.task.id&&!G.group){let e=Ft(G);return Br(e.start,e.end)}if(e.isSummary&&Ur?.has(String(e.task.id))&&(D!==`self`||e.task.hasOwnDates===!1)){let t=Ft(G),n=String(G.taskId),r=null,i=null;for(let a of jt(e.task.id)){if((kt.get(String(a.id))??[]).length!==0)continue;let e=String(a.id)===n?t.start:a.start,o=String(a.id)===n?t.end:a.end;(!r||e<r)&&(r=e),(!i||o>i)&&(i=o)}if(r&&i)return Br(r,i)}}return Br(e.start,e.end)},Gr=t.useMemo(()=>{let e=new Map;q.forEach((t,n)=>e.set(String(t.task.id),n));let t=[];return q.forEach(({task:n},r)=>{for(let i of n.dependencies??[]){let a=typeof i==`object`&&!!i,o=a?i.id:i;if(o==null||o===``)continue;let s=e.get(String(o));if(s==null||s===r)continue;let c=a?i.type:void 0,l=c===`ss`||c===`ff`||c===`sf`?c:`fs`;t.push({key:`${String(o)}->${String(n.id)}:${l}`,sourceId:o,targetId:n.id,type:l,sourceIndex:s,targetIndex:r})}}),t},[q]),Kr=Math.max(2,Math.round(V/2)-14),qr=V-Kr*2,Jr=Math.round(qr/2),Yr=Math.max(Math.round(V*.4),12),Xr=Yr*Math.SQRT2/2,Zr=qr,Qr=Kr,$r=Math.max(3,Math.round(V*.13)),ei=V-$r-1,ti=`rgba(100, 116, 139, 0.35)`,ni=`rgba(100, 116, 139, 0.6)`,ri=e=>{let t=q[e.sourceIndex],n=q[e.targetIndex];if(!t||!n)return null;let r=Wr(t),i=Wr(n),a=e=>e.isSummary?Qr+Zr/2:V/2,o=e.sourceIndex*V+a(t),s=e.targetIndex*V+a(n),c=e.type===`fs`||e.type===`ff`,l=e.type===`ff`||e.type===`sf`,u=t.isMilestone?r.left+(c?Xr:-Xr):c?r.left+r.width:r.left,d=n.isMilestone?i.left+(l?Xr:-Xr):l?i.left+i.width:i.left,f=u+(c?10:-10),p=d+(l?10:-10),m=Math.round,h=[`M ${m(u)} ${m(o)}`,`L ${m(f)} ${m(o)}`];if(l?f>=p:f<=p)h.push(`L ${m(f)} ${m(s)}`,`L ${m(d)} ${m(s)}`);else{let t=s>=o?(e.sourceIndex+1)*V:e.sourceIndex*V;h.push(`L ${m(f)} ${m(t)}`,`L ${m(p)} ${m(t)}`,`L ${m(p)} ${m(s)}`,`L ${m(d)} ${m(s)}`)}return h.join(` `)},ii=G?.taskId??Et,[ai,oi]=t.useState(re),si=t.useMemo(()=>ai?se(N,x):null,[ai,N,x]),ci=t.useCallback(e=>si?.criticalIds.has(String(e))??!1,[si]),li=`#dc2626`,[ui,di]=t.useState(null),[fi,pi]=t.useState(!1);t.useEffect(()=>{if(!fi)return;let e=setTimeout(()=>pi(!1),2500);return()=>clearTimeout(e)},[fi]);let mi=t.useCallback(()=>{if(!z)return;let{changes:e,skippedLocked:t}=ce(N,x,Kt);if(!e.length){pi(!0);return}di({changes:e,skipped:t.length})},[N,z,x,Kt]),hi=t.useCallback(()=>{if(!ui)return;let e=[];for(let t of ui.changes){let n=N.find(e=>String(e.id)===t.id);n&&e.push({task:n,changes:{start:t.start,end:t.end}})}e.length&&Ht(e),di(null)},[ui,N,Ht]),gi=t.useCallback(()=>{if(typeof document>`u`||!N.length)return null;let e=e=>String(e).replace(/[&<>"]/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`})[e]),t=Math.max(W,200),n=Math.ceil(t+Fn),r=Math.ceil(36+q.length*V),i=si?.criticalEdges??null,a=[];a.push(`<rect x="0" y="0" width="${n}" height="${r}" fill="#ffffff"/>`),a.push(`<rect x="0" y="0" width="${n}" height="36" fill="#f8fafc"/>`),a.push(`<g transform="translate(${t},0)" font-family="sans-serif" font-size="10" fill="#475569">`),Un.forEach(t=>{a.push(`<line x1="${t.offset.toFixed(1)}" y1="0" x2="${t.offset.toFixed(1)}" y2="36" stroke="#e2e8f0"/>`),a.push(`<text x="${(t.offset+t.width/2).toFixed(1)}" y="12" text-anchor="middle" font-weight="600">${e(t.label)}</text>`)}),Y.forEach((t,n)=>{let i=X[n];a.push(`<line x1="${i.toFixed(1)}" y1="18" x2="${i.toFixed(1)}" y2="${r}" stroke="#eef2f7"/>`),a.push(`<text x="${(i+t.width/2).toFixed(1)}" y="30" text-anchor="middle" fill="#1f2937">${e(t.label)}</text>`)}),a.push(`</g>`),a.push(`<line x1="0" y1="18" x2="${n}" y2="18" stroke="#e2e8f0"/>`),a.push(`<line x1="0" y1="36" x2="${n}" y2="36" stroke="#cbd5e1"/>`),a.push(`<line x1="${t}" y1="0" x2="${t}" y2="${r}" stroke="#cbd5e1"/>`),a.push(`<g transform="translate(0,36)" font-family="sans-serif" font-size="11" fill="#1f2937">`),q.forEach((n,r)=>{let i=r*V;a.push(`<line x1="0" y1="${(i+V).toFixed(1)}" x2="${t}" y2="${(i+V).toFixed(1)}" stroke="#f1f5f9"/>`);let o=8+n.depth*14,s=Math.max(4,Math.floor((t-o)/6.5)),c=n.task.title.length>s?n.task.title.slice(0,s-1)+`…`:n.task.title,l=n.isSummary?` font-weight="600"`:``;a.push(`<text x="${o}" y="${(i+V/2+4).toFixed(1)}"${l}>${e(c)}</text>`)}),a.push(`</g>`);let o=(e,t)=>{let n=t-12;if(n<=9)return``;let r=0,i=``;for(let t of e){let a=t.charCodeAt(0)>255?9:5.5;if(r+a>n)return i.length<e.length?`${i.slice(0,-1)}…`:i;r+=a,i+=t}return i};a.push(`<g transform="translate(${t},36)" font-family="sans-serif" font-size="9">`),q.forEach((t,n)=>{if(t.task.type===`group`)return;let r=n*V,{left:i,width:s}=Br(t.start,t.end),c=ci(t.task.id),l=c?` stroke="${li}" stroke-width="2"`:``;if(ie&&t.task.baselineStart&&t.task.baselineEnd){let e=Br(t.task.baselineStart,t.task.baselineEnd);a.push(`<rect x="${e.left.toFixed(1)}" y="${(r+ei).toFixed(1)}" width="${Math.max(2,e.width).toFixed(1)}" height="${$r}" rx="1" fill="${ti}" stroke="${ni}"/>`)}if(t.isMilestone){let e=i,n=r+V/2,o=Yr/2,s=c?li:t.task.color||`#3b82f6`;a.push(`<polygon points="${e},${n-o} ${e+o},${n} ${e},${n+o} ${e-o},${n}" fill="${s}"/>`)}else if(t.isSummary){let n=t.task.color||`#64748b`;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Qr).toFixed(1)}" width="${s.toFixed(1)}" height="${Zr}" rx="3" fill="${n}"${l}/>`);let c=s*Math.min(100,Math.max(0,t.progress))/100;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Qr).toFixed(1)}" width="${c.toFixed(1)}" height="${Zr}" rx="3" fill="rgba(0,0,0,0.2)"/>`);let u=o(t.task.title,s);u&&a.push(`<text x="${(i+6).toFixed(1)}" y="${(r+V/2+3).toFixed(1)}" fill="#ffffff" font-weight="500">${e(u)}</text>`)}else{let n=t.task.color||`#3b82f6`;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Kr).toFixed(1)}" width="${s.toFixed(1)}" height="${qr}" rx="3" fill="${n}"${l}/>`);let c=s*Math.min(100,Math.max(0,t.progress))/100;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Kr).toFixed(1)}" width="${c.toFixed(1)}" height="${qr}" rx="3" fill="rgba(0,0,0,0.18)"/>`);let u=o(t.task.title,s);u?a.push(`<text x="${(i+6).toFixed(1)}" y="${(r+V/2+3).toFixed(1)}" fill="#ffffff" font-weight="500">${e(u)}</text>`):s>=24&&a.push(`<text x="${(i+s/2).toFixed(1)}" y="${(r+V/2+3).toFixed(1)}" text-anchor="middle" fill="#ffffff">${Math.round(t.progress)}%</text>`)}}),Gr.forEach(e=>{let t=ri(e);if(!t)return;let n=i?.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,r=n?li:`#94a3b8`;a.push(`<path d="${t}" fill="none" stroke="${r}" stroke-width="${n?2:1.5}"/>`)}),vr!=null&&a.push(`<line x1="${vr.toFixed(1)}" y1="0" x2="${vr.toFixed(1)}" y2="${q.length*V}" stroke="#ef4444" stroke-width="1.5"/>`);let s=q.length*V;return Wn.forEach(t=>{let n=/var\(/.test(t.color)?`#6366f1`:t.color;if(a.push(`<line x1="${t.left.toFixed(1)}" y1="0" x2="${t.left.toFixed(1)}" y2="${s}" stroke="${e(n)}" stroke-width="1.5"/>`),t.label){let r=t.label.length*6+8;a.push(`<rect x="${(t.left-r/2).toFixed(1)}" y="0" width="${r}" height="14" rx="2" fill="${e(n)}"/>`),a.push(`<text x="${t.left.toFixed(1)}" y="10" text-anchor="middle" font-size="9" font-weight="600" fill="#ffffff">${e(t.label)}</text>`)}}),a.push(`</g>`),{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${r}" viewBox="0 0 ${n} ${r}">${a.join(``)}</svg>`,W:n,H:r}},[N,q,Gr,ri,Br,ci,si,Y,X,Fn,W,V,Kr,qr,Qr,Zr,Yr,vr,H,ie,ei,$r,ti,ni,Wn,Un]),_i=t.useCallback(()=>{let e=(j??``).replace(/[\\/:*?"<>|\s]+/g,` `).trim()||`gantt`,t=new Date,n=e=>String(e).padStart(2,`0`);return`${e}-${`${t.getFullYear()}${n(t.getMonth()+1)}${n(t.getDate())}-${n(t.getHours())}${n(t.getMinutes())}`}`},[j]),vi=t.useCallback(async()=>{let e=gi();if(!e)return;let t=await He(e.svg,e.W,e.H);t&&t.toBlob(e=>{e&&Ue(e,`${_i()}.png`)},`image/png`)},[gi,_i]),yi=t.useCallback(async()=>{let e=gi();if(!e)return;let t=await He(e.svg,e.W,e.H);t&&Ue(We(Ge(t.toDataURL(`image/jpeg`,.92)),t.width,t.height),`${_i()}.pdf`)},[gi,_i]),[bi,xi]=t.useState(!1),Si=t.useCallback(()=>{let e={viewMode:H,columnWidth:st,taskListCollapsed:U,taskListWidth:lt,collapsedIds:Array.from(Dn)};O&&Je(O,e),oe?.(e),xi(!0)},[H,st,U,lt,Dn,O,oe]);return t.useEffect(()=>{if(!bi)return;let e=setTimeout(()=>xi(!1),1500);return()=>clearTimeout(e)},[bi]),(0,p.jsxs)(`div`,{ref:we,className:(0,u.cn)(`flex flex-col h-full bg-background overflow-hidden min-w-0`,b),"data-readonly":R?`true`:void 0,"data-mobile-readonly":w&&Ke?`true`:void 0,children:[(0,p.jsx)(`style`,{children:`
16
16
  .gantt-resize-handle:hover { background-color: rgba(255, 255, 255, 0.4); }
17
17
  .gantt-bar-hover:hover { filter: brightness(1.1); }
18
18
  .gantt-row-open-btn { opacity: 0; transition: opacity 0.15s ease; }
@@ -43,7 +43,6 @@ endobj
43
43
  @media (min-width: 640px) {
44
44
  .gantt-sm-h50 { height: 50px; }
45
45
  .gantt-sm-w20 { width: 80px; }
46
- .gantt-sm-hidden { display: none; }
47
46
  }
48
47
  /* The timeline's NATIVE scrollbars are fully hidden — both axes are
49
48
  replaced by the self-drawn bars (horizontal at the bottom, vertical
@@ -61,4 +60,4 @@ endobj
61
60
  bar. Hide it — the pane stays wheel/drag-scrollable and synced. */
62
61
  .gantt-task-list::-webkit-scrollbar { width: 0; height: 0; }
63
62
  .gantt-task-list { scrollbar-width: none; }
64
- `}),(0,d.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 p-2 border-b bg-card`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":P(`gantt.toolbar.prevPeriod`),children:(0,d.jsx)(u.ChevronLeft,{className:`h-4 w-4`})}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":P(`gantt.toolbar.nextPeriod`),children:(0,d.jsx)(u.ChevronRight,{className:`h-4 w-4`})}),(0,d.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,children:q.start.toLocaleDateString(F,{month:`long`,year:`numeric`})}),L&&(0,d.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,"data-testid":`gantt-readonly-badge`,title:P(`gantt.readOnlyHint`),children:[(0,d.jsx)(u.Lock,{className:`h-3 w-3`}),P(`gantt.readOnly`)]})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`div`,{className:`flex bg-muted rounded-md p-1`,role:`group`,"aria-label":P(`gantt.toolbar.viewMode`),children:ve.map(e=>(0,d.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:(0,c.cn)(`h-6 px-1.5 sm:px-2 text-xs`,V===e&&`bg-background shadow-sm hover:bg-background`),onClick:()=>Mn(e),"aria-pressed":V===e,"data-testid":`gantt-view-mode-${e}`,children:P(`gantt.viewMode.${e}`)},e))}),(0,d.jsxs)(`div`,{className:`flex bg-muted rounded-md p-1`,children:[(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(mt>15)nt(Math.max(15,mt-10));else{let e=ve.indexOf(V);e<ve.length-1&&(Mn(ve[e+1]),nt(Qe))}},"aria-label":P(`gantt.toolbar.zoomOut`),children:(0,d.jsx)(u.ZoomOut,{className:`h-3 w-3`})}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(mt<120)nt(Math.min(120,mt+10));else{let e=ve.indexOf(V);e>0&&(Mn(ve[e-1]),nt(Qe))}},"aria-label":P(`gantt.toolbar.zoomIn`),children:(0,d.jsx)(u.ZoomIn,{className:`h-3 w-3`})})]}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>ut(e=>!e),"aria-label":P(lt?`gantt.toolbar.showTaskList`:`gantt.toolbar.hideTaskList`),"aria-pressed":lt,"data-testid":`gantt-toggle-task-list`,children:lt?(0,d.jsx)(u.PanelLeft,{className:`h-4 w-4`}):(0,d.jsx)(u.PanelLeftClose,{className:`h-4 w-4`})}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:sr,disabled:or==null,"aria-label":P(`gantt.toolbar.jumpToToday`),"data-testid":`gantt-jump-today`,children:P(`gantt.toolbar.today`)}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:dr,"aria-label":P(`gantt.toolbar.thisWeek`),"data-testid":`gantt-jump-week`,children:P(`gantt.toolbar.thisWeek`)}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:fr,"aria-label":P(`gantt.toolbar.thisMonth`),"data-testid":`gantt-jump-month`,children:P(`gantt.toolbar.thisMonth`)}),se?(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>void se(),disabled:ce,"aria-label":P(`gantt.toolbar.refresh`),"aria-busy":ce,"data-testid":`gantt-refresh`,children:(0,d.jsx)(u.RefreshCw,{className:`h-4 w-4`})}):null,R?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Ut,disabled:!Gt,"aria-label":P(`gantt.toolbar.undo`),"data-testid":`gantt-undo`,children:(0,d.jsx)(u.Undo2,{className:`h-4 w-4`})}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Wt,disabled:!Kt,"aria-label":P(`gantt.toolbar.redo`),"data-testid":`gantt-redo`,children:(0,d.jsx)(u.Redo2,{className:`h-4 w-4`})})]}):null,(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>Jr(e=>!e),"aria-label":P(`gantt.toolbar.criticalPath`),"aria-pressed":qr,"data-testid":`gantt-critical-path`,style:qr?{color:$}:void 0,children:(0,d.jsx)(u.Activity,{className:`h-4 w-4`})}),Xe&&R?(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:ti,"aria-label":P(`gantt.toolbar.autoSchedule`),"data-testid":`gantt-auto-schedule`,children:(0,d.jsx)(u.Wand2,{className:`h-4 w-4`})}):null,(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:ai,"aria-label":P(`gantt.toolbar.exportPng`),"data-testid":`gantt-export-png`,children:(0,d.jsx)(u.Download,{className:`h-4 w-4`})}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:oi,"aria-label":P(`gantt.toolbar.exportPdf`),"data-testid":`gantt-export-pdf`,children:(0,d.jsx)(u.FileDown,{className:`h-4 w-4`})}),oe||ae?(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:li,"aria-label":P(`gantt.toolbar.saveLayout`),"aria-pressed":si,"data-testid":`gantt-save-layout`,style:si?{color:$}:void 0,children:(0,d.jsx)(u.Save,{className:`h-4 w-4`})}):null,(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:tr,"aria-label":P($n?`gantt.toolbar.exitFullscreen`:`gantt.toolbar.enterFullscreen`),"aria-pressed":$n,"data-testid":`gantt-fullscreen`,children:$n?(0,d.jsx)(u.Minimize2,{className:`h-4 w-4`}):(0,d.jsx)(u.Maximize2,{className:`h-4 w-4`})})]})]}),(0,d.jsxs)(`div`,{className:`relative flex flex-col flex-1 overflow-hidden outline-none focus-visible:ring-1 focus-visible:ring-ring`,tabIndex:0,onKeyDown:wn,"data-testid":`gantt-body`,children:[!lt&&H>0&&(0,d.jsx)(`div`,{className:`absolute top-0 bottom-0 z-30 group/splitter`,style:{left:H-3,width:7,cursor:`col-resize`},"data-testid":`gantt-list-resize`,role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{if(e.button!==0)return;e.preventDefault();let t=e.clientX,n=H,r=Math.max(160,I-200),i=e=>{let i=Math.max(160,Math.min(n+(e.clientX-t),r));it(i)},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),window.removeEventListener(`pointercancel`,a),document.body.style.cursor=``};document.body.style.cursor=`col-resize`,window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a),window.addEventListener(`pointercancel`,a)},onDoubleClick:()=>it(null),children:(0,d.jsx)(`div`,{className:`absolute inset-y-0 left-1/2 -translate-x-1/2 w-px bg-border group-hover/splitter:w-[3px] group-hover/splitter:bg-primary transition-all`})}),(0,d.jsxs)(`div`,{className:`flex border-b bg-muted/30 shrink-0 h-10 gantt-sm-h50`,children:[(0,d.jsxs)(`div`,{className:`flex items-center font-medium text-xs text-muted-foreground px-2 sm:px-4 border-r bg-card z-20 shadow-sm`,style:{width:H,minWidth:H},children:[(0,d.jsx)(`div`,{className:`flex-1 truncate`,children:P(`gantt.column.taskName`)}),gt&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:P(`gantt.column.start`)}),(0,d.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:P(`gantt.column.end`)})]}),s&&(0,d.jsx)(`div`,{className:`w-6 shrink-0 hidden sm:block`,style:{marginLeft:4},"aria-hidden":`true`,"data-testid":`gantt-header-open-spacer`})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-hidden`,ref:Ln,children:(0,d.jsxs)(`div`,{className:`flex flex-col h-full`,style:{width:On},children:[(0,d.jsx)(`div`,{className:`relative border-b`,style:{height:`45%`},"data-testid":`gantt-header-groups`,children:Fn.slice(Zn.start,Zn.end).map(e=>(0,d.jsx)(`div`,{className:`absolute top-0 bottom-0 flex items-center justify-center border-r text-[10px] font-medium text-muted-foreground overflow-hidden`,style:{left:e.offset,width:e.width},children:(0,d.jsx)(`span`,{className:`truncate px-1`,children:e.label})},e.key))}),(0,d.jsx)(`div`,{className:`relative flex-1`,"data-testid":`gantt-header-units`,children:J.slice(Yn.start,Yn.end).map((e,t)=>{let n=Yn.start+t;return(0,d.jsxs)(`div`,{className:(0,c.cn)(`absolute top-0 bottom-0 flex items-center justify-center gap-1 border-r text-xs text-muted-foreground overflow-hidden`,e.isWeekend&&`bg-muted/50`),style:{left:Y[n],width:e.width,backgroundColor:e.bandColor?`color-mix(in srgb, ${e.bandColor} 16%, transparent)`:void 0},children:[(0,d.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.label}),e.sublabel&&mt>=32&&(0,d.jsx)(`span`,{className:`text-[10px] opacity-70`,children:e.sublabel})]},n)})})]})})]}),(0,d.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,d.jsxs)(`div`,{className:`gantt-task-list overflow-y-auto overflow-x-hidden border-r bg-card z-10 shadow-sm`,ref:Rn,onScroll:Dr,style:{width:H,minWidth:H},role:`tree`,"aria-label":P(`gantt.aria.taskList`),children:[Q.startIdx>0&&(0,d.jsx)(`div`,{style:{height:Q.startIdx*B},"aria-hidden":`true`}),K.slice(Q.startIdx,Q.endIdx).map(e=>{let t=e.task,n=Ye&&_t===t.id,r=bn.has(String(t.id)),i=hn!=null&&String(hn)===String(t.id);return(0,d.jsxs)(`div`,{className:(0,c.cn)(`group/task-row relative flex items-center border-b px-2 sm:px-4 hover:bg-accent/50 cursor-pointer transition-colors`,i&&`bg-accent/50`),style:{height:B,touchAction:`manipulation`},role:`treeitem`,"data-testid":`gantt-task-row-${t.id}`,"aria-level":e.depth+1,"aria-selected":i,"aria-expanded":e.hasChildren?!r:void 0,draggable:!!Je&&!n&&!t.locked,onDragStart:Je?e=>{e.dataTransfer.setData(`text/plain`,String(t.id)),e.dataTransfer.effectAllowed=`move`}:void 0,onDragOver:Je?e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`}:void 0,onDrop:Je?e=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);if(!n||n===String(t.id))return;let r=wt.get(n);r&&String(r.parent??``)===String(t.parent??``)&&Je(r,t)}:void 0,onContextMenu:e=>vn(t,e),onClick:()=>{gn(t.id),n||ur(e.start,e.end,t.id)},onDoubleClick:()=>{n||(Ye&&R&&!e.isSummary&&!t.locked?(vt(t.id),bt({title:t.title,start:t.start.toLocaleDateString(`en-CA`),end:t.end.toLocaleDateString(`en-CA`),progress:String(t.progress)})):s?.(t))},children:[(0,d.jsxs)(`div`,{className:`flex-1 truncate font-medium text-xs sm:text-sm flex items-center gap-2`,style:e.depth>0?{paddingLeft:e.depth*14}:void 0,children:[e.hasChildren?(0,d.jsx)(`button`,{type:`button`,className:`h-4 w-4 shrink-0 flex items-center justify-center text-muted-foreground hover:text-foreground`,style:{marginLeft:-4},onClick:e=>{e.stopPropagation(),Sn(t.id)},"aria-expanded":!r,"aria-label":P(r?`gantt.row.expand`:`gantt.row.collapse`),"data-testid":`gantt-row-toggle-${t.id}`,children:r?(0,d.jsx)(u.ChevronRight,{className:`h-3.5 w-3.5`}):(0,d.jsx)(u.ChevronDown,{className:`h-3.5 w-3.5`})}):(0,d.jsx)(`span`,{className:`w-3 shrink-0`,style:{marginLeft:-4},"aria-hidden":`true`}),(0,d.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0`,style:{backgroundColor:t.color||`#3b82f6`}}),n?(0,d.jsx)(`input`,{className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:yt.title||``,onChange:e=>bt(t=>({...t,title:e.target.value})),onKeyDown:e=>{e.key===`Enter`?(Ft([{task:t,changes:{title:yt.title,start:new Date(yt.start),end:new Date(yt.end),progress:Number(yt.progress)||0}}]),vt(null)):e.key===`Escape`&&vt(null)},onClick:e=>e.stopPropagation(),autoFocus:!0}):(0,d.jsxs)(`span`,{className:`flex flex-col min-w-0`,children:[(0,d.jsx)(`span`,{className:(0,c.cn)(`truncate`,e.isSummary&&`font-semibold`),children:t.title}),(0,d.jsxs)(`span`,{className:`text-[10px] text-muted-foreground gantt-sm-hidden`,children:[e.start.toLocaleDateString(F,{month:`numeric`,day:`numeric`}),` → `,e.end.toLocaleDateString(F,{month:`numeric`,day:`numeric`})]})]})]}),(0,d.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!gt,style:gt?void 0:{display:`none`},children:n?(0,d.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:yt.start||``,onChange:e=>bt(t=>({...t,start:e.target.value})),onClick:e=>e.stopPropagation()}):e.start.toLocaleDateString(F,{month:`numeric`,day:`numeric`})}),(0,d.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!gt,style:gt?void 0:{display:`none`},children:n?(0,d.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:yt.end||``,onChange:e=>bt(t=>({...t,end:e.target.value})),onClick:e=>e.stopPropagation()}):e.end.toLocaleDateString(F,{month:`numeric`,day:`numeric`})}),s&&(0,d.jsx)(`div`,{className:`w-6 shrink-0 hidden sm:block`,style:{marginLeft:4},children:!n&&(0,d.jsx)(`button`,{type:`button`,title:P(`gantt.row.open`),"aria-label":P(`gantt.row.open`),"data-testid":`gantt-row-open-${t.id}`,className:`gantt-row-open-btn h-6 w-6 rounded-md flex items-center justify-center hover:bg-accent text-muted-foreground hover:text-foreground`,onClick:e=>{e.stopPropagation(),s(t)},children:(0,d.jsx)(u.ArrowRight,{className:`h-3.5 w-3.5`})})})]},t.id)}),Q.endIdx<K.length&&(0,d.jsx)(`div`,{style:{height:(K.length-Q.endIdx)*B},"aria-hidden":`true`})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]`,ref:e=>{zn.current=e,Z.current=e},onScroll:Er,onTouchStart:rr,onTouchMove:ir,onTouchEnd:ar,"data-testid":`gantt-timeline`,children:(0,d.jsxs)(`div`,{className:`relative`,style:{width:On},children:[or!=null&&(0,d.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px z-20 pointer-events-none`,style:{left:or,backgroundColor:`rgba(239, 68, 68, 0.8)`},"data-testid":`gantt-today-marker`,"aria-label":P(`gantt.toolbar.today`),children:(0,d.jsx)(`div`,{className:`absolute -translate-x-1/2 left-0 text-[10px] font-semibold text-white rounded-sm px-1 py-0.5 whitespace-nowrap z-30`,style:{top:2,backgroundColor:`#ef4444`},children:P(`gantt.toolbar.today`)})}),In.map(e=>(0,d.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px z-20 pointer-events-none`,style:{left:e.left,backgroundColor:e.color},"data-testid":`gantt-marker-${e.index}`,"aria-label":e.label,children:e.label&&(0,d.jsx)(`div`,{className:`absolute -translate-x-1/2 left-0 text-[10px] font-semibold text-white rounded-sm px-1 py-0.5 whitespace-nowrap z-30`,style:{top:2,backgroundColor:e.color},children:e.label})},e.index)),(0,d.jsxs)(`div`,{className:`relative`,ref:en,children:[(0,d.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:J.slice(Yn.start,Yn.end).map((e,t)=>{let n=Yn.start+t;return(0,d.jsx)(`div`,{className:`absolute top-0 bottom-0 border-r`,style:{left:Y[n],width:e.width,backgroundColor:e.bandColor?`color-mix(in srgb, ${e.bandColor} 8%, transparent)`:e.isWeekend?`hsl(var(--muted) / 0.4)`:void 0}},n)})}),Tn&&S&&S.showMidnight&&(0,d.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:J.slice(Yn.start,Yn.end).map((e,t)=>{let n=Yn.start+t,r=e.realMs??0;if(!r)return null;let i=e.date.getTime(),a=e.date,o=new Date(a.getFullYear(),a.getMonth(),a.getDate()+1,0,0,0,0).getTime();if(o<=i||o>=i+r)return null;let s=Y[n]+(o-i)/r*e.width;return(0,d.jsx)(`div`,{className:`absolute top-0 bottom-0`,style:{left:s,borderLeft:`1px dashed hsl(var(--muted-foreground) / 0.4)`},"data-testid":`gantt-midnight-${n}`,"aria-hidden":`true`},`midnight-${n}`)})}),Q.startIdx>0&&(0,d.jsx)(`div`,{style:{height:Q.startIdx*B},"aria-hidden":`true`}),K.slice(Q.startIdx,Q.endIdx).map((e,n)=>{let r=e.task,i=Q.startIdx+n,a=Xr(r.id),o=Or(e.start,e.end),s=C&&r.baselineStart&&r.baselineEnd?Or(r.baselineStart,r.baselineEnd):null,l=s?(0,d.jsx)(`div`,{className:`absolute pointer-events-none rounded-[1px]`,style:{left:s.left,width:Math.max(2,s.width),top:Hr,height:Vr,backgroundColor:Ur,border:`1px solid ${Wr}`},"data-testid":`gantt-baseline-${r.id}`,"aria-hidden":`true`}):null,u=W?.taskId===r.id,f=Ar?.has(String(r.id))??!1,p=jr?.has(String(r.id))??!1,m=u||f||p?Mr(e):o,h=!!r.locked,g=!!R&&!e.isSummary&&!h,_=g&&He,v=g&&Ue,y=g&&We,ee=_||v,te=L||h,b=G!=null&&G.targetId!=null&&String(G.targetId)===String(r.id)&&String(G.sourceId)!==String(r.id),x=G!=null&&G.rejectedId!=null&&String(G.rejectedId)===String(r.id)?{cursor:`not-allowed`,boxShadow:`0 0 0 2px hsl(var(--destructive))`}:void 0,S=G?e=>{let t=e.currentTarget.getBoundingClientRect(),n=t.width>0&&e.clientX-t.left>t.width/2?`end`:`start`;tn(e=>{if(!e)return e;let t=Qt(e.sourceId,r);return t===null?{...e,targetId:r.id,targetEnd:n,rejectedId:null,rejectedReason:null}:{...e,targetId:null,targetEnd:null,rejectedId:r.id,rejectedReason:t}})}:void 0,w=G?e=>{e.target===e.currentTarget&&tn(e=>e&&{...e,targetId:null,targetEnd:null,rejectedId:null,rejectedReason:null})}:void 0,T=Math.max(1,Math.round((e.end.getTime()-e.start.getTime())/be)),ne=(i+1)*B+300>Qn&&i*B>300,E=xt===r.id&&!W&&!Jt&&!G?(0,d.jsxs)(`div`,{className:`absolute z-30 pointer-events-none rounded-md border bg-popover text-popover-foreground px-2.5 py-1.5 text-xs shadow-md whitespace-nowrap`,style:{left:Math.max(m.left+8,4),...ne?{bottom:B-8}:{top:B-8}},role:`tooltip`,"data-testid":`gantt-tooltip-${r.id}`,children:[(0,d.jsx)(`div`,{className:`font-semibold`,children:r.title}),r.fields&&r.fields.length>0?(0,d.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`auto 1fr`,columnGap:10,rowGap:2,marginTop:4},children:r.fields.map((e,n)=>(0,d.jsxs)(t.Fragment,{children:[(0,d.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,d.jsx)(`span`,{style:{fontWeight:500},children:e.value})]},n))}):(0,d.jsxs)(`div`,{className:`text-muted-foreground`,children:[e.start.toLocaleDateString(F,{month:`short`,day:`numeric`}),` → `,e.end.toLocaleDateString(F,{month:`short`,day:`numeric`}),` · `,T,P(`gantt.tooltip.days`),` · `,Math.round(e.progress),`%`]}),r.locked||L&&!R?(0,d.jsxs)(`div`,{className:`text-muted-foreground`,style:{marginTop:4},"data-testid":`gantt-tooltip-locked-${r.id}`,children:[`🚫 `,P(`gantt.lockedHint`)]}):null]}):null;if(r.type===`group`)return(0,d.jsx)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:B},onPointerMove:w,children:E},r.id);if(e.isSummary){let t=r.color||`#0d9488`,n=re===`self`&&r.hasOwnDates!==!1,i=!!R&&He&&!h,o=!!R&&Ue&&n&&!h;return(0,d.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:B},onPointerMove:w,children:[l,(0,d.jsxs)(`div`,{className:(0,c.cn)(`gantt-bar-hover absolute rounded-sm border shadow-sm flex items-center px-2 select-none group`,i&&`cursor-grab active:cursor-grabbing`,u&&`ring-2 ring-primary z-10`,b&&`ring-2 ring-primary`,Bn===r.id&&`gantt-flash z-10`),style:{left:m.left,width:m.width,top:Br,height:zr,cursor:i||o?void 0:te?`not-allowed`:`pointer`,backgroundColor:t,borderColor:a?$:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${$}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0,...x},"data-critical":a?`true`:void 0,"data-testid":`gantt-summary-bar-${r.id}`,"data-progress":Math.round(e.progress),onMouseEnter:()=>St(r.id),onMouseLeave:()=>St(e=>e===r.id?null:e),onPointerMove:S,onPointerDown:t=>{if(t.button===0){if(o){let e=pe(t.clientX,t.currentTarget.getBoundingClientRect());if(e!==`move`){qt(r,e,t);return}}i&&qt(r,`move`,t,{group:!0,originStart:e.start,originEnd:e.end})}},onClick:()=>{Ot.current||gn(r.id)},onContextMenu:e=>vn(r,e),children:[(0,d.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 pointer-events-none`,style:{width:`${Math.round(e.progress)}%`,backgroundColor:`rgba(0, 0, 0, 0.2)`,borderTopLeftRadius:`var(--radius-sm)`,borderBottomLeftRadius:`var(--radius-sm)`}}),o&&m.width>=14&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0`,style:{width:fe,height:Ir,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${r.id}`,onPointerDown:e=>{e.button===0&&qt(r,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,d.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:fe,height:Ir,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${r.id}`,onPointerDown:e=>{e.button===0&&qt(r,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),(0,d.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none`,children:r.title}),z&&!h&&[`start`,`end`].map(e=>{let t=G!=null&&String(G.sourceId)===String(r.id)&&G.sourceEnd===e,n=t||xt===r.id,i=n&&G==null;return(0,d.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2 z-20 flex items-center transition-opacity`,style:{[e===`start`?`left`:`right`]:-28,height:24,width:30,cursor:`crosshair`,opacity:+!!n,pointerEvents:i?`auto`:`none`,justifyContent:e===`start`?`flex-start`:`flex-end`,paddingLeft:e===`start`?4:0,paddingRight:e===`end`?4:0},"data-testid":`gantt-link-dot-${e}-${r.id}`,onPointerDown:t=>{if(t.button!==0)return;t.stopPropagation(),t.preventDefault();let n=en.current?.getBoundingClientRect();tn({sourceId:r.id,sourceEnd:e,x:n?t.clientX-n.left:0,y:n?t.clientY-n.top:0,targetId:null,targetEnd:null,rejectedId:null,rejectedReason:null})},onClick:e=>e.stopPropagation(),children:(0,d.jsx)(`div`,{className:`rounded-full`,style:{height:12,width:12,backgroundColor:`hsl(var(--background))`,border:`2px solid hsl(var(--primary))`,boxShadow:t?`0 0 0 3px hsl(var(--primary) / 0.25)`:`0 1px 2px rgba(0,0,0,0.25)`}})},e)})]}),u&&W&&(0,d.jsxs)(`div`,{className:`absolute z-30 pointer-events-none rounded border bg-popover text-popover-foreground px-1.5 py-0.5 text-[10px] shadow whitespace-nowrap`,style:{left:Math.max(m.left,4),top:Br+zr+2},"data-testid":`gantt-summary-drag-chip-${r.id}`,children:[kt(W).start.toLocaleDateString(F,{month:`numeric`,day:`numeric`}),` → `,kt(W).end.toLocaleDateString(F,{month:`numeric`,day:`numeric`})]}),E]},r.id)}if(e.isMilestone){let e=Lr;return(0,d.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:B},onPointerMove:w,children:[l,(0,d.jsx)(`div`,{className:(0,c.cn)(`gantt-bar-hover absolute rotate-45 rounded-[2px] border shadow-sm select-none`,_&&`cursor-grab active:cursor-grabbing`,u&&`ring-2 ring-primary z-10`,b&&`ring-2 ring-primary`,Bn===r.id&&`gantt-flash z-10`),style:{left:m.left-e/2,top:(B-e)/2,width:e,height:e,cursor:_?void 0:te?`not-allowed`:`pointer`,backgroundColor:a?$:r.color||`#3b82f6`,borderColor:a?$:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${$}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0,...x},"data-critical":a?`true`:void 0,"data-testid":`gantt-milestone-${r.id}`,onMouseEnter:()=>St(r.id),onMouseLeave:()=>St(e=>e===r.id?null:e),onClick:()=>{Ot.current||gn(r.id)},onContextMenu:e=>vn(r,e),onPointerMove:S,onPointerDown:_?e=>{e.button===0&&qt(r,`move`,e)}:void 0}),E]},r.id)}let D=Jt&&Jt.taskId===r.id?Jt.value:r.progress;return(0,d.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:B},onPointerMove:w,onMouseEnter:()=>St(r.id),onMouseLeave:()=>St(e=>e===r.id?null:e),children:[u&&(0,d.jsx)(`div`,{className:`absolute rounded-sm border border-dashed pointer-events-none`,style:{left:o.left,width:o.width,top:Pr,height:Fr,opacity:.35,borderColor:`hsl(var(--primary) / 0.6)`},"aria-hidden":`true`}),l,(0,d.jsxs)(`div`,{className:(0,c.cn)(`gantt-bar-hover absolute rounded-sm bg-primary border shadow-sm flex items-center px-2 group select-none`,ee&&`cursor-grab active:cursor-grabbing`,u&&`ring-2 ring-primary z-10`,b&&`ring-2 ring-primary`,Bn===r.id&&`gantt-flash z-10`),style:{left:m.left,width:m.width,top:Pr,height:Fr,cursor:ee?void 0:te?`not-allowed`:`pointer`,backgroundColor:r.color||`#3b82f6`,borderColor:a?$:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${$}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0,...x},"data-critical":a?`true`:void 0,"data-testid":`gantt-task-bar-${r.id}`,onClick:()=>{Ot.current||gn(r.id)},onContextMenu:e=>vn(r,e),onPointerMove:S,onPointerDown:ee?e=>{if(e.button!==0)return;let t=pe(e.clientX,e.currentTarget.getBoundingClientRect()),n=t!==`move`&&v?t:_?`move`:null;n&&qt(r,n,e)}:void 0,children:[v&&m.width>=14&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0`,style:{width:fe,height:Ir,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${r.id}`,onPointerDown:e=>{e.button===0&&qt(r,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,d.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:fe,height:Ir,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${r.id}`,onPointerDown:e=>{e.button===0&&qt(r,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),D>0&&(0,d.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 pointer-events-none`,style:{width:`${D}%`,backgroundColor:`rgba(0, 0, 0, 0.2)`,borderTopLeftRadius:`var(--radius-sm)`,borderBottomLeftRadius:`var(--radius-sm)`}}),y&&m.width>=30&&(0,d.jsx)(`div`,{className:(0,c.cn)(`absolute bottom-0 h-1/2 w-4 -translate-x-1/2 cursor-col-resize flex items-end justify-center pb-px`,Jt?.taskId===r.id?`opacity-100`:`opacity-0 group-hover:opacity-100 transition-opacity`),style:{left:`${D}%`},"data-testid":`gantt-progress-handle-${r.id}`,onPointerDown:e=>{e.button===0&&(e.stopPropagation(),e.preventDefault(),Yt({taskId:r.id,originClientX:e.clientX,originProgress:r.progress,barWidth:m.width,value:r.progress}))},onClick:e=>e.stopPropagation(),children:(0,d.jsx)(`div`,{style:{width:0,height:0,borderLeft:`5px solid transparent`,borderRight:`5px solid transparent`,borderBottom:`7px solid #fff`,filter:`drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35))`}})}),z&&!h&&[`start`,`end`].map(e=>{let t=G!=null&&String(G.sourceId)===String(r.id)&&G.sourceEnd===e,n=t||xt===r.id,i=n&&G==null;return(0,d.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2 z-20 flex items-center transition-opacity`,style:{[e===`start`?`left`:`right`]:-28,height:24,width:30,cursor:`crosshair`,opacity:+!!n,pointerEvents:i?`auto`:`none`,justifyContent:e===`start`?`flex-start`:`flex-end`,paddingLeft:e===`start`?4:0,paddingRight:e===`end`?4:0},"data-testid":`gantt-link-dot-${e}-${r.id}`,onPointerDown:t=>{if(t.button!==0)return;t.stopPropagation(),t.preventDefault();let n=en.current?.getBoundingClientRect();tn({sourceId:r.id,sourceEnd:e,x:n?t.clientX-n.left:0,y:n?t.clientY-n.top:0,targetId:null,targetEnd:null,rejectedId:null,rejectedReason:null})},onClick:e=>e.stopPropagation(),children:(0,d.jsx)(`div`,{className:`rounded-full`,style:{height:12,width:12,backgroundColor:`hsl(var(--background))`,border:`2px solid hsl(var(--primary))`,boxShadow:t?`0 0 0 3px hsl(var(--primary) / 0.25)`:`0 1px 2px rgba(0,0,0,0.25)`}})},e)}),(0,d.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none group-hover:opacity-0 transition-opacity`,children:r.title}),(0,d.jsx)(`span`,{className:`absolute inset-0 flex items-center px-2 text-[10px] text-white font-medium truncate opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none`,children:u?`${kt(W).start.toLocaleDateString(F,{month:`numeric`,day:`numeric`})} → ${kt(W).end.toLocaleDateString(F,{month:`numeric`,day:`numeric`})}`:`${Math.round(D)}%`})]}),E]},r.id)}),Q.endIdx<K.length&&(0,d.jsx)(`div`,{style:{height:(K.length-Q.endIdx)*B},"aria-hidden":`true`}),(Nr.length>0||G)&&(0,d.jsxs)(`svg`,{className:`absolute top-0 left-0 pointer-events-none z-10`,width:On,height:Qn,"data-testid":`gantt-links`,"aria-hidden":`true`,children:[(0,d.jsxs)(`defs`,{children:[(0,d.jsx)(`marker`,{id:`gantt-link-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,d.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--muted-foreground))`})}),(0,d.jsx)(`marker`,{id:`gantt-link-arrow-active`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,d.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--primary))`})}),(0,d.jsx)(`marker`,{id:`gantt-link-arrow-critical`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,d.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:$})})]}),Nr.map(e=>{let n=Math.min(e.sourceIndex,e.targetIndex);if(Math.max(e.sourceIndex,e.targetIndex)<Q.startIdx-6||n>Q.endIdx+6)return null;let r=Gr(e);if(!r)return null;let i=Kr!=null&&(String(e.sourceId)===String(Kr)||String(e.targetId)===String(Kr)),a=Yr?.criticalEdges.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,o=a?`gantt-link-arrow-critical`:i?`gantt-link-arrow-active`:`gantt-link-arrow`,s=!!(qe||z);return(0,d.jsxs)(t.Fragment,{children:[(0,d.jsx)(`path`,{d:r,fill:`none`,stroke:a?$:i?`hsl(var(--primary))`:`hsl(var(--muted-foreground))`,strokeOpacity:a||i?1:.7,strokeWidth:a||i?2:1.5,markerEnd:`url(#${o})`,"data-testid":`gantt-link-${e.sourceId}-${e.targetId}`,"data-link-type":e.type,"data-active":i?`true`:`false`,"data-critical":a?`true`:void 0}),s&&(0,d.jsx)(`path`,{d:r,fill:`none`,stroke:`transparent`,strokeWidth:10,style:{pointerEvents:`stroke`,cursor:`context-menu`},"data-testid":`gantt-link-hit-${e.sourceId}-${e.targetId}`,onContextMenu:t=>yn(e.sourceId,e.targetId,e.type,t)})]},e.key)}),G&&(()=>{let e=K.findIndex(e=>String(e.task.id)===String(G.sourceId));if(e<0)return null;let t=Mr(K[e]),n=K[e].isMilestone?t.left+(G.sourceEnd===`start`?-Rr:Rr):G.sourceEnd===`start`?t.left:t.left+t.width,r=e*B+B/2;return(0,d.jsx)(`path`,{d:`M ${Math.round(n)} ${Math.round(r)} L ${Math.round(G.x)} ${Math.round(G.y)}`,fill:`none`,stroke:`hsl(var(--primary))`,strokeWidth:1.5,strokeDasharray:`4 3`,"data-testid":`gantt-link-draft`})})()]}),G&&(()=>{let e=N.find(e=>String(e.id)===String(G.sourceId));if(!e)return null;let t=G.targetId==null?null:N.find(e=>String(e.id)===String(G.targetId)),n=e=>P(`gantt.linkEnd.${e}`),r=t?`${e.title} (${n(G.sourceEnd)}) → ${t.title} (${n(G.targetEnd??`start`)})`:`${e.title} (${n(G.sourceEnd)})`;return(0,d.jsx)(`div`,{className:`absolute z-30 pointer-events-none rounded-md border bg-popover text-popover-foreground px-2 py-1 text-[11px] font-medium shadow-md whitespace-nowrap`,style:{left:G.x+12,top:G.y+12},"data-testid":`gantt-link-draft-hint`,children:r})})()]})]})}),(0,d.jsx)(`div`,{ref:_r,className:`shrink-0 border-l bg-card/95 select-none`,style:{width:14,display:`none`},"data-testid":`gantt-vscrollbar`,children:(0,d.jsx)(`div`,{ref:vr,className:`relative h-full`,onPointerDown:Tr,role:`scrollbar`,"aria-controls":`gantt-timeline`,"aria-orientation":`vertical`,children:(0,d.jsx)(`div`,{ref:yr,className:`absolute rounded-full`,style:{left:2,right:2,top:0,height:0,backgroundColor:`rgba(130,130,130,0.55)`,cursor:`grab`},"data-testid":`gantt-vscrollbar-thumb`,onPointerDown:wr})})})]}),(0,d.jsx)(`div`,{ref:pr,className:`shrink-0 border-t bg-card/95 select-none`,style:{position:`sticky`,bottom:0,zIndex:30,display:`none`},"data-testid":`gantt-hscrollbar`,children:(0,d.jsx)(`div`,{ref:mr,className:`relative`,style:{marginLeft:H,height:14},onPointerDown:Cr,role:`scrollbar`,"aria-controls":`gantt-timeline`,"aria-orientation":`horizontal`,children:(0,d.jsx)(`div`,{ref:hr,className:`absolute rounded-full`,style:{top:2,bottom:2,left:0,width:0,backgroundColor:`rgba(130,130,130,0.55)`,cursor:`grab`},"data-testid":`gantt-hscrollbar-thumb`,onPointerDown:Sr})})})]}),rn&&(()=>{let e=N.find(e=>String(e.id)===String(rn.taskId));if(!e)return null;let t=K.find(e=>String(e.task.id)===String(rn.taskId)),n=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`;return(0,d.jsxs)(`div`,{ref:on,className:`fixed z-50 min-w-[160px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:rn.x,top:rn.y},role:`menu`,"data-testid":`gantt-context-menu`,children:[s&&(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:n,"data-testid":`gantt-context-menu-view`,onClick:()=>{an(null),s(e)},children:P(`gantt.menu.view`)}),Ye&&R&&t&&!t.isSummary&&!e.locked&&(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:n,"data-testid":`gantt-context-menu-edit`,onClick:()=>{an(null),vt(e.id),bt({title:e.title,start:e.start.toLocaleDateString(`en-CA`),end:e.end.toLocaleDateString(`en-CA`),progress:String(e.progress)})},children:P(`gantt.menu.edit`)}),z&&t&&!t.isMilestone&&!e.locked&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:n,"data-testid":`gantt-context-menu-add-predecessor`,onClick:()=>{let t=rn;an(null),pn(``),dn({x:t.x,y:t.y,taskId:e.id,relation:`pred`})},children:P(`gantt.menu.addPredecessor`)}),(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:n,"data-testid":`gantt-context-menu-add-successor`,onClick:()=>{let t=rn;an(null),pn(``),dn({x:t.x,y:t.y,taskId:e.id,relation:`succ`})},children:P(`gantt.menu.addSuccessor`)})]}),Ke&&!e.locked&&(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:(0,c.cn)(n,`text-destructive`),"data-testid":`gantt-context-menu-delete`,onClick:()=>{an(null),Ke(e)},children:P(`gantt.menu.delete`)})]})})(),sn&&(()=>{let e=N.find(e=>String(e.id)===String(sn.sourceId)),t=N.find(e=>String(e.id)===String(sn.targetId));if(!e||!t)return null;let n=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`,r=[`fs`,`ss`,`ff`,`sf`],i=!!t.locked;return(0,d.jsxs)(`div`,{ref:ln,className:`fixed z-50 min-w-[180px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:sn.x,top:sn.y},role:`menu`,"data-testid":`gantt-link-context-menu`,children:[(0,d.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground truncate`,children:[e.title,` → `,t.title]}),i&&(0,d.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,"data-testid":`gantt-link-menu-locked`,children:[`🚫 `,P(`gantt.lockedHint`)]}),z&&j&&r.map(r=>(0,d.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":sn.type===r,disabled:i,className:(0,c.cn)(n,sn.type===r&&`font-semibold`,i&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-type-${r}`,onClick:()=>{i||(cn(null),r!==sn.type&&z(e,t,r))},children:[sn.type===r?`✓ `:`\xA0\xA0`,P(`gantt.linkType.${r}`)]},r)),qe&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`my-1 border-t`}),(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:i,className:(0,c.cn)(n,`text-destructive`,i&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-remove`,onClick:()=>{i||(cn(null),qe(e,t))},children:P(`gantt.menu.removeDependency`)})]})]})})(),un&&z&&(()=>{let e=N.find(e=>String(e.id)===String(un.taskId));if(!e)return null;let t=new Set(Nr.map(e=>`${String(e.sourceId)}->${String(e.targetId)}`)),n=N.filter(n=>{if(String(n.id)===String(e.id)||n.type===`group`||n.locked)return!1;let r=un.relation===`pred`?`${String(n.id)}->${String(e.id)}`:`${String(e.id)}->${String(n.id)}`;return!t.has(r)}),r=fn.trim().toLowerCase(),i=r?n.filter(e=>String(e.title??``).toLowerCase().includes(r)):n;return(0,d.jsxs)(`div`,{ref:mn,className:`fixed z-50 min-w-[200px] max-h-[280px] overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:un.x,top:un.y},role:`menu`,"data-testid":`gantt-dep-picker`,children:[(0,d.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:un.relation===`pred`?P(`gantt.menu.addPredecessor`):P(`gantt.menu.addSuccessor`)}),(0,d.jsx)(`div`,{className:`px-2 pb-1`,children:(0,d.jsx)(`input`,{className:`border rounded px-2 py-1 text-sm w-full bg-background`,value:fn,onChange:e=>pn(e.target.value),placeholder:P(`gantt.menu.searchTasks`),"data-testid":`gantt-dep-picker-search`,autoFocus:!0})}),i.length===0?(0,d.jsx)(`div`,{className:`px-3 py-1.5 text-muted-foreground`,children:P(`gantt.menu.noCandidates`)}):i.map(t=>(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none truncate`,"data-testid":`gantt-dep-picker-option-${t.id}`,onClick:()=>{dn(null),un.relation===`pred`?z(t,e,`fs`):z(e,t,`fs`)},children:t.title},String(t.id)))]})})(),Zr&&(0,d.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-autoschedule-overlay`,onClick:()=>Qr(null),children:(0,d.jsxs)(`div`,{className:`min-w-[280px] max-w-[360px] rounded-lg border bg-popover text-popover-foreground shadow-lg p-4`,role:`alertdialog`,"aria-modal":`true`,"data-testid":`gantt-autoschedule-dialog`,onClick:e=>e.stopPropagation(),children:[(0,d.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-autoschedule-title`,children:P(`gantt.autoScheduleDlg.title`)}),(0,d.jsxs)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:[P(`gantt.autoScheduleDlg.body`,{count:Zr.changes.length}),Zr.skipped>0&&(0,d.jsxs)(d.Fragment,{children:[` `,(0,d.jsx)(`span`,{"data-testid":`gantt-autoschedule-skipped`,children:P(`gantt.autoScheduleDlg.skipped`,{count:Zr.skipped})})]})]}),(0,d.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,className:`px-3 py-1.5 text-sm rounded-md border hover:bg-accent outline-none`,"data-testid":`gantt-autoschedule-cancel`,onClick:()=>Qr(null),children:P(`gantt.autoScheduleDlg.cancel`)}),(0,d.jsx)(`button`,{type:`button`,className:`px-3 py-1.5 text-sm rounded-md bg-primary text-primary-foreground hover:opacity-90 outline-none`,"data-testid":`gantt-autoschedule-confirm`,onClick:ni,children:P(`gantt.autoScheduleDlg.confirm`)})]})]})}),$r&&(0,d.jsx)(`div`,{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-[60] rounded-md border bg-popover text-popover-foreground px-3 py-1.5 text-sm shadow-md`,role:`status`,"data-testid":`gantt-autoschedule-clean`,children:P(`gantt.autoScheduleDlg.none`)}),It&&(0,d.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-conflict-overlay`,onClick:()=>Lt(null),children:(0,d.jsxs)(`div`,{className:`min-w-[280px] max-w-[360px] rounded-lg border bg-popover text-popover-foreground shadow-lg p-4`,role:`alertdialog`,"aria-modal":`true`,"data-testid":`gantt-conflict-dialog`,onClick:e=>e.stopPropagation(),children:[(0,d.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-conflict-title`,children:P(`gantt.conflict.title`)}),(0,d.jsx)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:P(`gantt.conflict.body`,{count:It.length})}),(0,d.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,className:`px-3 py-1.5 text-sm rounded-md border hover:bg-accent outline-none`,"data-testid":`gantt-conflict-cancel`,onClick:()=>Lt(null),children:P(`gantt.conflict.cancel`)}),(0,d.jsx)(`button`,{type:`button`,className:`px-3 py-1.5 text-sm rounded-md bg-primary text-primary-foreground hover:opacity-90 outline-none`,"data-testid":`gantt-conflict-confirm`,onClick:Vt,children:P(`gantt.conflict.confirm`)})]})]})})]})}function N(e,t,n,r){return t.getTime()===e.getTime()?e.getTime()>=n.getTime()&&e.getTime()<r.getTime():e.getTime()<r.getTime()&&t.getTime()>n.getTime()}function Ne(e,t,n){let{assignee:r,effort:i,capacity:a=1,unassignedLabel:o=`Unassigned`}=n,s=e=>typeof a==`function`?a(e):a,c=e=>{let t=i?i(e):1;return Number.isFinite(t)&&t>0?t:0},l=new Map;for(let t of e){let e=r(t),n=e?String(e.key):`__unassigned__`,i=e?e.label:o,a=l.get(n);a||(a={key:n,label:i,items:[]},l.set(n,a)),a.items.push(t)}let u=[];for(let e of l.values()){let n=s(e.key),r=0,i=0,a=t.map(t=>{let a=0;for(let n of e.items)N(n.start,n.end,t.start,t.end)&&(a+=c(n));a>r&&(r=a);let o=a>n+1e-9;return o&&i++,{load:a,capacity:n,overloaded:o}});u.push({key:e.key,label:e.label,capacity:n,cells:a,peak:r,overloadedCount:i})}return u}var Pe={day:26,week:56,month:76,quarter:88,year:104},Fe=48,P=34,Ie=180;function F(e,t,n){return t===`day`?String(e.getDate()):t===`week`?e.toLocaleDateString(n,{month:`numeric`,day:`numeric`}):t===`month`?e.toLocaleDateString(n,{month:`short`}):t===`year`?String(e.getFullYear()):`Q${Math.floor(e.getMonth()/3)+1}`}function Le({tasks:e,assignee:n,effort:r,capacity:i=1,viewMode:a=`day`,unassignedLabel:o=`Unassigned`,className:s}){let{t:c,language:l}=de(),u=l||void 0,f=Pe[a],p=t.useMemo(()=>{if(!e.length)return[];let t=new Date(Math.min(...e.map(e=>e.start.getTime()))),n=new Date(Math.max(...e.map(e=>e.end.getTime()))),r=Ce(t,a),i=Te(Ce(n,a),1,a),o=[],s=0;for(;r<i&&s++<4e3;){let e=Te(r,1,a);o.push({date:new Date(r),col:{start:new Date(r),end:new Date(e)},label:F(r,a,u)}),r=e}return o},[e,a,u]),m=t.useMemo(()=>Ne(e,p.map(e=>e.col),{assignee:n,effort:r,capacity:i,unassignedLabel:o}),[e,p,n,r,i,o]),h=t.useMemo(()=>{let e=0;for(let t of m)e=Math.max(e,t.peak,t.capacity);return e||1},[m]),g=p.length*f;return e.length?(0,d.jsx)(`div`,{className:s,"data-testid":`resource-workload`,style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`auto`},children:(0,d.jsxs)(`div`,{style:{display:`flex`,minWidth:Ie+g},children:[(0,d.jsxs)(`div`,{style:{width:Ie,flexShrink:0},children:[(0,d.jsx)(`div`,{style:{height:28,display:`flex`,alignItems:`center`,padding:`0 12px`,fontSize:12,fontWeight:600,borderBottom:`1px solid hsl(var(--border))`},children:c(`gantt.resource.header`)}),m.map(e=>(0,d.jsxs)(`div`,{"data-testid":`resource-row-${e.key}`,style:{height:Fe,display:`flex`,flexDirection:`column`,justifyContent:`center`,padding:`0 12px`,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,d.jsx)(`span`,{style:{fontSize:13,fontWeight:500,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:e.label}),(0,d.jsxs)(`span`,{"data-testid":`resource-peak-${e.key}`,"data-overloaded":e.overloadedCount>0?`true`:void 0,style:{fontSize:10,color:e.overloadedCount>0?`hsl(var(--destructive))`:`hsl(var(--muted-foreground))`},children:[c(`gantt.resource.peak`),`: `,Math.round(e.peak*100)/100,` / `,e.capacity,e.overloadedCount>0?` · ${e.overloadedCount} ${c(`gantt.resource.over`)}`:``]})]},e.key))]}),(0,d.jsxs)(`div`,{style:{flex:1},children:[(0,d.jsx)(`div`,{style:{display:`flex`,height:28,borderBottom:`1px solid hsl(var(--border))`},children:p.map((e,t)=>(0,d.jsx)(`div`,{style:{width:f,flexShrink:0,textAlign:`center`,fontSize:10,color:`hsl(var(--muted-foreground))`,borderLeft:`1px solid hsl(var(--border) / 0.4)`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:e.label},t))}),m.map(e=>{let t=P*(1-Math.min(e.capacity/h,1));return(0,d.jsxs)(`div`,{style:{position:`relative`,display:`flex`,height:Fe,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,d.jsx)(`div`,{"aria-hidden":`true`,style:{position:`absolute`,left:0,right:0,top:7+t,borderTop:`1px dashed hsl(var(--muted-foreground) / 0.6)`,pointerEvents:`none`,zIndex:1}}),e.cells.map((t,n)=>{let r=Math.max(t.load>0?2:0,P*Math.min(t.load/h,1));return(0,d.jsx)(`div`,{"data-testid":`resource-cell-${e.key}-${n}`,"data-load":t.load,"data-overloaded":t.overloaded?`true`:void 0,title:`${p[n]?.date.toLocaleDateString(u)} — ${Math.round(t.load*100)/100} / ${t.capacity}`,style:{width:f,flexShrink:0,position:`relative`,borderLeft:`1px solid hsl(var(--border) / 0.4)`,display:`flex`,alignItems:`flex-end`,justifyContent:`center`,paddingBottom:7},children:t.load>0&&(0,d.jsx)(`div`,{style:{width:f-6,height:r,borderRadius:2,backgroundColor:t.overloaded?`hsl(var(--destructive))`:`hsl(var(--primary))`,opacity:t.overloaded?.9:.75}})},n)})]},e.key)})]})]})}):(0,d.jsx)(`div`,{className:s,"data-testid":`resource-workload`,children:(0,d.jsx)(`div`,{className:`flex items-center justify-center h-40 text-sm text-muted-foreground`,children:c(`gantt.resource.empty`)})})}var Re={display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8,padding:`8px 12px`,borderBottom:`1px solid hsl(var(--border))`,background:`hsl(var(--background))`,fontSize:13},ze={display:`inline-flex`,alignItems:`center`,gap:6,height:30,padding:`0 10px`,borderRadius:6,border:`1px solid hsl(var(--border))`,background:`hsl(var(--background))`,color:`hsl(var(--foreground))`,cursor:`pointer`,whiteSpace:`nowrap`,lineHeight:`28px`},Be={position:`absolute`,top:`calc(100% + 4px)`,left:0,zIndex:50,minWidth:200,maxHeight:320,overflowY:`auto`,padding:4,borderRadius:8,border:`1px solid hsl(var(--border))`,background:`hsl(var(--popover, var(--background)))`,color:`hsl(var(--popover-foreground, var(--foreground)))`,boxShadow:`0 8px 24px rgba(0,0,0,0.18)`},I={display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,borderRadius:6,cursor:`pointer`,userSelect:`none`};function Ve({checked:e}){return(0,d.jsx)(`span`,{"aria-hidden":!0,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:15,height:15,flex:`0 0 auto`,borderRadius:3,border:`1px solid ${e?`hsl(var(--primary))`:`hsl(var(--border))`}`,background:e?`hsl(var(--primary))`:`transparent`,color:`hsl(var(--primary-foreground, var(--background)))`,fontSize:11,lineHeight:1},children:e?`✓`:``})}function L({filter:e,selected:n,onChange:r,labels:i}){let[a,o]=(0,t.useState)(!1),s=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);let c=new Set(n),l=n.length,u=e.options.length>0&&l===e.options.length,f=t=>{let n=new Set(c);n.has(t)?n.delete(t):n.add(t),n.size===e.options.length?r([]):r([...n])},p=()=>{r(l>0?[]:e.options.map(e=>e.value))},m=l===0?e.label:l===1?`${e.label}: ${e.options.find(e=>e.value===n[0])?.label??n[0]}`:`${e.label} · ${l}`;return(0,d.jsxs)(`div`,{ref:s,style:{position:`relative`},"data-testid":`quick-filter-${e.field}`,children:[(0,d.jsxs)(`button`,{type:`button`,style:{...ze,borderColor:l>0?`hsl(var(--primary))`:`hsl(var(--border))`,color:l>0?`hsl(var(--primary))`:`hsl(var(--foreground))`},"aria-haspopup":`listbox`,"aria-expanded":a,"data-testid":`quick-filter-trigger-${e.field}`,onClick:()=>o(e=>!e),children:[(0,d.jsx)(`span`,{children:m}),(0,d.jsx)(`span`,{"aria-hidden":!0,style:{fontSize:10,opacity:.7},children:`▾`})]}),a&&(0,d.jsx)(`div`,{role:`listbox`,style:Be,"data-testid":`quick-filter-panel-${e.field}`,children:e.options.length===0?(0,d.jsx)(`div`,{style:{...I,cursor:`default`,opacity:.6},children:i.empty}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{role:`option`,"aria-selected":u,style:{...I,fontWeight:600},"data-testid":`quick-filter-all-${e.field}`,onClick:()=>p(),children:[(0,d.jsx)(Ve,{checked:u}),(0,d.jsx)(`span`,{children:i.all})]}),(0,d.jsx)(`div`,{style:{height:1,background:`hsl(var(--border))`,margin:`2px 0`}}),e.options.map(t=>{let n=c.has(t.value);return(0,d.jsxs)(`div`,{role:`option`,"aria-selected":n,style:{...I,background:n?`hsl(var(--accent, var(--muted)))`:`transparent`},"data-testid":`quick-filter-option-${e.field}-${t.value}`,onClick:()=>f(t.value),children:[(0,d.jsx)(Ve,{checked:n}),(0,d.jsx)(`span`,{children:t.label})]},t.value)})]})})]})}var He=({filters:e,value:t,onChange:n,onClear:r,resultCount:i,totalCount:a,labels:o,className:s})=>{if(!e.length)return null;let c=o?.all??`All`,l=o?.empty??`No options`,u=o?.clear??`Clear`,f=e.some(e=>(t[e.field]?.length??0)>0);return(0,d.jsxs)(`div`,{style:Re,className:s,"data-testid":`quick-filter-bar`,children:[e.map(e=>(0,d.jsx)(L,{filter:e,selected:t[e.field]??[],onChange:t=>n(e.field,t),labels:{all:c,empty:l}},e.field)),f&&(0,d.jsx)(`button`,{type:`button`,style:{...ze,height:28,color:`hsl(var(--muted-foreground))`},"data-testid":`quick-filter-clear`,onClick:r,children:u}),o?.resultSummary&&i!=null&&a!=null&&(0,d.jsx)(`span`,{"data-testid":`quick-filter-summary`,style:{marginLeft:`auto`,color:`hsl(var(--muted-foreground))`},children:o.resultSummary(i,a)})]})};function Ue(e){if(e==null)return;let t=String(e).toLowerCase().trim();if(t===`milestone`)return`milestone`;if(t===`group`||t===`folder`)return`group`;if(t===`summary`||t===`project`||t===`phase`)return`summary`;if(t===`task`)return`task`}var We={fs:`fs`,ss:`ss`,ff:`ff`,sf:`sf`,finish_to_start:`fs`,start_to_start:`ss`,finish_to_finish:`ff`,start_to_finish:`sf`,end_to_start:`fs`,end_to_end:`ff`,start_to_end:`sf`};function Ge(e){if(e==null||e===``)return[];if(typeof e==`string`)return e.split(`,`).map(e=>e.trim()).filter(Boolean);if(typeof e==`number`)return[e];if(!Array.isArray(e))return[];let t=[];for(let n of e)if(n!=null&&n!==``){if(typeof n==`object`){let e=n.id??n._id??n.task??n.target;if(e==null||e===``)continue;let r=We[String(n.type??``).toLowerCase().replace(/-/g,`_`)];t.push(r?{id:e,type:r}:{id:e})}else t.push(n)}return t}function R(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function Ke(e){let t=e instanceof Error?e.message:String(e??``),n=t.indexOf(`{`);if(n>=0)try{let e=JSON.parse(t.slice(n)),r=e?.message??e?.error;if(typeof r==`string`&&r.trim())return r}catch{}return null}function z(e){let t=null;if(e.startDateField&&e.endDateField)return t={startDateField:e.startDateField,endDateField:e.endDateField,titleField:e.titleField||`name`,progressField:e.progressField,dependenciesField:e.dependenciesField||e.dependencyField,colorField:e.colorField,borderColorField:e.borderColorField,parentField:e.parentField,typeField:e.typeField,lockField:e.lockField,objectField:e.objectField,summaryExtent:e.summaryExtent,defaultCollapsedDepth:e.defaultCollapsedDepth,tooltipFields:e.tooltipFields,baselineStartField:e.baselineStartField,baselineEndField:e.baselineEndField,groupByField:e.groupByField,resourceView:e.resourceView,assigneeField:e.assigneeField,effortField:e.effortField,capacity:e.capacity,quickFilters:e.quickFilters,autoZoomToFilter:e.autoZoomToFilter,viewMode:e.viewMode,timeSegments:e.timeSegments,interactions:e.interactions,exportFileName:e.exportFileName,timeZone:e.timeZone,dependencyTypes:e.dependencyTypes},t;if(e.gantt&&(t=e.gantt),t){let e=a.GanttConfigSchema.safeParse(t);return e.success||console.warn(`[ObjectGantt] Invalid gantt configuration:`,e.error.format()),t}return null}var qe=({schema:e,dataSource:a,className:u,onTaskClick:f,onRowClick:p,onBeforeTaskUpdate:m,...h})=>{let[g,_]=(0,t.useState)([]),[v,y]=(0,t.useState)(!0),[ee,te]=(0,t.useState)(null),[b,x]=(0,t.useState)(null),{currency:S}=(0,o.useLocalization)(),C=(0,o.useDisplayLocale)(),{t:w}=de(),T=(0,t.useCallback)(e=>{i.toast.error(w(`gantt.writeFailed`),{description:Ke(e)??void 0})},[w]),ne=R(e),E=(0,t.useMemo)(()=>ne,[JSON.stringify(ne)]),D=z(e),re=E?.provider===`value`,ie=(0,t.useContext)(r.SchemaRendererContext)?.apiFetch,O=(0,t.useMemo)(()=>(0,n.resolveDataSource)(E,a??null,{fetch:ie}),[E,a,ie]),k=E?.provider===`object`?E.object:e.objectName??``,[ae,oe]=(0,t.useState)(!1),se=(0,t.useRef)(0),A=(0,t.useCallback)(async({silent:t=!1}={})=>{let r=++se.current,i=()=>se.current===r;try{if(t?oe(!0):y(!0),h.data&&Array.isArray(h.data)){i()&&_(h.data);return}if(re&&E?.provider===`value`){i()&&_(E.items);return}if(!O||typeof O.find!=`function`)throw Error(`DataSource required for object/api providers`);let r=(0,n.buildExpandFields)(b?.fields),a=await O.find(k,{$filter:e.filter,$orderby:(0,n.convertSortToQueryParams)(e.sort),...r.length>0?{$expand:r}:{}});i()&&_((0,n.extractRecords)(a))}catch(e){t?console.error(`[ObjectGantt] Failed to refresh data:`,e):i()&&te(e)}finally{t?oe(!1):y(!1)}},[O,k,re,E,e.filter,e.sort,b]);(0,t.useEffect)(()=>{A()},[A]),(0,t.useEffect)(()=>{!re&&O&&(async()=>{try{if(!O||!k)return;let e=await O.getObjectSchema(k);x(e)}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[k,O,re,E]);let j=(0,t.useMemo)(()=>{if(!D||!g.length)return[];let{startDateField:e,endDateField:t,titleField:r,progressField:i,dependenciesField:a,colorField:s,borderColorField:c,parentField:u,typeField:d,lockField:f,tooltipFields:p,baselineStartField:m,baselineEndField:h,quickFilters:_}=D,v=b?.fields??{},y=new Map;for(let e of _??[]){if(!e?.field||!Array.isArray(e.options)||!e.options.length)continue;let t=new Map;for(let n of e.options)typeof n==`string`?t.set(n,n):n&&n.value!=null&&t.set(String(n.value),n.label??String(n.value));t.size&&y.set(e.field,t)}let ee=(e,t)=>{if(!t)return;let n=t.split(`.`),r=e;for(let e of n){if(r==null)return;r=r[e]}return r},te=e=>{let t=[ee(e,r),e?.account?.name,e?.opportunity?.name,e?.contact&&[e.contact.first_name,e.contact.last_name].filter(Boolean).join(` `)];for(let e of t)if(e!=null&&String(e).trim()!==``)return String(e);return(0,n.getRecordDisplayName)(b,e)},x=(e,t)=>{if(t)return t;let n=v[e]??v[e.split(`.`)[0]];return n?.label?n.label:(0,l.humanizeLabel)(e)},w=(e,t)=>{if(e==null||e===``)return`—`;let n=v[t]??v[t.split(`.`)[0]],r=n?.type,i=n?.options;if(Array.isArray(i)&&i.length){let t=i.find(t=>String(t.value)===String(e));if(t)return t.label}if(typeof e!=`object`){let n=y.get(t)?.get(String(e));if(n!=null)return n}if(r==null&&typeof e==`string`){if(/^\d{4}-\d{2}-\d{2}$/.test(e))return(0,l.formatDate)(e,void 0,{locale:C});if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/.test(e)&&!isNaN(new Date(e).getTime()))return(0,l.formatDateTime)(e,{locale:C})}switch(r){case`date`:return(0,l.formatDate)(e,void 0,{locale:C});case`datetime`:return(0,l.formatDateTime)(e,{locale:C});case`number`:case`integer`:case`float`:case`decimal`:return(0,l.formatNumber)(Number(e),void 0,C);case`currency`:return(0,l.formatCurrency)(Number(e),(0,o.resolveFieldCurrency)(n,S),C);case`percent`:return(0,l.formatPercent)(Number(e),void 0,C);case`boolean`:case`checkbox`:return e?`Yes`:`No`;default:if(Array.isArray(e)){let t=e.map(e=>{if(e==null)return``;if(typeof e==`object`){let t=e;return String(t.name??t.label??t.title??t.id??``)}return String(e)}).filter(Boolean);return t.length?t.join(`, `):`—`}if(typeof e==`object`){let t=e;return String(t.name??t.label??t.title??t.id??`—`)}return String(e)}},T=e=>{if(!p||!p.length)return;let t=[];for(let n of p){let r=typeof n==`string`?n:n?.field;if(!r)continue;let i=typeof n==`object`?n.label:void 0,a=ee(e,r);a==null||a===``||Array.isArray(a)&&a.length===0||t.push({label:x(r,i),value:w(a,r)})}return t.length?t:void 0};return g.map((n,r)=>{let o=n[e],p=n[t],g=m?n[m]:void 0,_=h?n[h]:void 0,v=g?new Date(g):void 0,y=_?new Date(_):void 0,ee=te(n),b=i?n[i]:0,x=a?n[a]:[],S=s?n[s]:void 0;if(!S){let e=n.status??n.state??n.priority??n.severity;if(e!=null&&e!==``){let t=(0,l.getSemanticColorName)(void 0,e);t&&(S=(0,l.getSemanticHex)(t))}}let C=c?n[c]:void 0,w=C!=null&&C!==``?(0,l.getSemanticHex)(String(C),String(C)):void 0;return{id:n.id||n._id||`task-${r}`,title:ee,start:o?new Date(o):new Date,end:p?new Date(p):new Date,hasOwnDates:!!(o&&p),progress:Math.min(100,Math.max(0,b||0)),dependencies:Ge(x),parent:u?n[u]??null:void 0,type:d?Ue(n[d]):void 0,locked:f?!!n[f]:void 0,color:S,borderColor:w,baselineStart:v&&!isNaN(v.getTime())?v:void 0,baselineEnd:y&&!isNaN(y.getTime())?y:void 0,fields:T(n),data:n}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[g,D,b,C,S]),le=(0,t.useMemo)(()=>{let e=D?.groupByField;if(!e)return;let t=b?.fields??{},n=(e,t)=>{if(!t)return;let n=e;for(let e of t.split(`.`)){if(n==null)return;n=n[e]}return n},r=n=>{let r=(t[e]??t[e.split(`.`)[0]])?.options;if(Array.isArray(r)&&r.length){let e=r.find(e=>String(e.value)===String(n));if(e)return e.label}if(typeof n==`object`&&n){let e=n;return String(e.name??e.label??e.title??e.id??n)}return String(n)};return t=>{let i=n(t.data,e);return i==null||i===``?null:{key:typeof i==`object`&&i?String(i.id??i._id??r(i)):i,label:r(i)}}},[D?.groupByField,b]),ue=(0,t.useMemo)(()=>{let e=D?.assigneeField;if(!e)return;let t=b?.fields??{},n=(e,t)=>{if(!t)return;let n=e;for(let e of t.split(`.`)){if(n==null)return;n=n[e]}return n},r=n=>{let r=(t[e]??t[e.split(`.`)[0]])?.options;if(Array.isArray(r)&&r.length){let e=r.find(e=>String(e.value)===String(n));if(e)return e.label}if(typeof n==`object`&&n){let e=n;return String(e.name??e.label??e.title??e.id??n)}return String(n)};return t=>{let i=n(t.data,e);return i==null||i===``?null:{key:typeof i==`object`&&i?String(i.id??i._id??r(i)):i,label:r(i)}}},[D?.assigneeField,b]),fe=(0,t.useMemo)(()=>{let e=D?.effortField;if(e)return t=>{let n=t.data?.[e],r=Number(n);return Number.isFinite(r)&&r>0?r:1}},[D?.effortField]),pe=(0,t.useMemo)(()=>{let t=e.skipWeekends,n=e.holidays;if(!(!t&&(!n||n.length===0)))return{skipWeekends:!!t,holidays:n&&n.length?new Set(n):void 0}},[e]),me=(0,t.useMemo)(()=>ce(D?.timeSegments),[D?.timeSegments]),he=(0,t.useCallback)((e,t)=>{if(!e||!t)return null;let n=e;for(let e of t.split(`.`)){if(n==null)return null;n=n[e]}if(n==null||n===``)return null;if(typeof n==`object`){let e=n;return String(e.id??e._id??e.value??e.name??``)}return String(n)},[]),ge=D?.quickFilters,[_e,ve]=(0,t.useState)({});(0,t.useEffect)(()=>{if(!ge?.length||!a||typeof a.find!=`function`)return;let e=b?.fields??{},t=!1;return(async()=>{let r={};for(let t of ge){if(t.options)continue;let i=e[t.field]??e[t.field.split(`.`)[0]],o=i?.type;if(o!==`lookup`&&o!==`master_detail`)continue;let s=i?.reference_to??i?.reference??i?.referenceTo;if(s)try{let e=await a.find(s,{$top:1e3}),i=(0,n.extractRecords)(e);r[t.field]=i.map(e=>({value:String(e.id??e._id??e.value??``),label:String(e.name??e.label??e.title??e.id??e._id??``)}))}catch(e){console.warn(`[ObjectGantt] Failed to load quick-filter options for "${t.field}":`,e)}}t||ve(e=>({...e,...r}))})(),()=>{t=!0}},[JSON.stringify(ge),a,b]);let ye=(0,t.useMemo)(()=>{if(!ge?.length)return[];let e=b?.fields??{};return ge.map(t=>{let n=e[t.field]??e[t.field.split(`.`)[0]],r=t.label??n?.label??(0,l.humanizeLabel)(t.field),i;if(t.options?.length)i=t.options.map(e=>typeof e==`object`?{value:String(e.value),label:String(e.label??e.value)}:{value:String(e),label:String(e)});else if(Array.isArray(n?.options)&&n.options.length)i=n.options.map(e=>({value:String(e.value??e),label:String(e.label??e.value??e)}));else if(_e[t.field]?.length)i=_e[t.field];else{let e=new Map;for(let n of g){let r=he(n,t.field);if(r!=null&&!e.has(r)){let i=n;for(let e of t.field.split(`.`))i=i?.[e];let a=i&&typeof i==`object`?String(i.name??i.label??i.title??r):r;e.set(r,a)}}i=[...e.entries()].map(([e,t])=>({value:e,label:t}))}return{field:t.field,label:r,options:i}})},[ge,b,_e,g,he]),be=e.persistLayout===!1?void 0:`${e.objectName||(E?.provider===`object`?E.object:``)||`gantt`}:${e.viewName||`default`}`,xe=be?`gantt-layout:${be}:filters`:null,[Se,Ce]=(0,t.useState)(()=>{if(!xe||typeof window>`u`)return{};try{let e=JSON.parse(window.localStorage.getItem(xe)||`null`);if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Array.isArray(r)&&(t[n]=r.filter(e=>typeof e==`string`));return t}catch{return{}}}),we=(0,t.useCallback)(()=>{if(!(!xe||typeof window>`u`))try{window.localStorage.setItem(xe,JSON.stringify(Se))}catch{}},[xe,Se]),Te=(0,t.useCallback)((e,t)=>{Ce(n=>({...n,[e]:t}))},[]),Ee=(0,t.useCallback)(()=>Ce({}),[]),De=(0,t.useCallback)(e=>!!D?.objectField&&!String(e?.[D.objectField]??``).trim(),[D?.objectField]),Oe=(0,t.useCallback)(e=>{let t=(D?.objectField?String(e[D.objectField]??``).trim():``)||k,n=e.id??e._id;if(!t||n==null)return null;let r=k?(0,s.deriveRecordPageHref)(k,n):null;return{objectName:t,recordId:n,href:!k||t===k?r:r?.replace(`/${k}/record/`,`/${t}/record/`)??null}},[D?.objectField,k]),ke=(0,t.useMemo)(()=>{let e=Object.entries(Se).filter(([,e])=>e.length>0);if(!e.length)return j;let t=new Map(j.map(e=>[String(e.id),e])),n=new Set;for(let r of j){if(!e.every(([e,t])=>{let n=he(r.data,e);return n!=null&&t.includes(n)}))continue;let i=r;for(;i&&!n.has(String(i.id));)n.add(String(i.id)),i=i.parent==null?void 0:t.get(String(i.parent))}return j.filter(e=>n.has(String(e.id)))},[j,Se,he]),Ae=(0,t.useMemo)(()=>{if(D?.autoZoomToFilter!==!1||!j.length)return null;let e=j[0].start.getTime(),t=j[0].end.getTime();for(let n of j)e=Math.min(e,n.start.getTime()),t=Math.max(t,n.end.getTime());return{start:new Date(e),end:new Date(t)}},[j,D?.autoZoomToFilter]),je=e.navigation??{mode:`drawer`,width:`min(960px, 60vw)`},Me=je.mode===`drawer`||je.mode===`modal`||je.mode===`split`||je.mode===`popover`,N=(0,r.useNavigationOverlay)({navigation:je,objectName:e.objectName,onRowClick:Me?void 0:p}),[Ne,Pe]=(0,t.useState)(null),Fe=N.isOverlay&&N.isOpen?N.selectedRecord:null;(0,t.useEffect)(()=>{if(!Fe){Pe(null);return}let e=Oe(Fe);if(!e){Pe(null);return}let{objectName:t,recordId:n}=e;if(E?.provider!==`api`&&t===k||!a||typeof a.findOne!=`function`){Pe(null);return}let r=`${t}:${n}`,i=!1;return(async()=>{try{let[e,o]=await Promise.all([a.findOne(t,String(n)),typeof a.getObjectSchema==`function`?a.getObjectSchema(t).catch(()=>null):Promise.resolve(null)]);i||Pe(e?{key:r,record:e,schema:o}:null)}catch(e){console.error(`[ObjectGantt] Failed to fetch drawer record, falling back to row payload:`,e),i||Pe(null)}})(),()=>{i=!0}},[Fe,Oe,E?.provider,k,a]);let P=(0,t.useCallback)(async(e,t)=>{if(!D||!O||typeof O.update!=`function`)return;let{startDateField:n,endDateField:r,titleField:i,progressField:a}=D,o={};if(t.start instanceof Date&&(o[n]=t.start.toISOString()),t.end instanceof Date&&(o[r]=t.end.toISOString()),typeof t.title==`string`&&i&&(o[i]=t.title),typeof t.progress==`number`&&a&&(o[a]=t.progress),Object.keys(o).length===0)return;let s=e.data?.id??e.data?._id??e.id;if(s==null)return;let c=g;_(e=>e.map(e=>String(e.id??e._id)===String(s)?{...e,...o}:e));try{await O.update(k,String(s),o),A({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist task update:`,e),_(c),T(e)}},[D,O,k,g,A,T]),Ie=(e,t)=>{let n=t.some(e=>typeof e==`object`&&e.type&&e.type!==`fs`);return!n&&typeof e==`string`?t.map(e=>String(typeof e==`object`?e.id:e)).join(`,`):n?t.map(e=>typeof e==`object`?e.type&&e.type!==`fs`?{id:e.id,type:e.type}:e.id:e):t.map(e=>typeof e==`object`?e.id:e)},F=(0,t.useCallback)(async(e,t,n)=>{let r=D?.dependenciesField;if(!r||!O||typeof O.update!=`function`)return;let i=Ie(t,n),a=g;_(t=>t.map(t=>String(t.id??t._id)===String(e)?{...t,[r]:i}:t));try{await O.update(k,String(e),{[r]:i}),A({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist dependency:`,e),_(a),T(e)}},[D,O,k,g,A,T]),Re=(0,t.useCallback)(async(e,t,n=`fs`)=>{let r=e.data?.id??e.data?._id??e.id,i=t.data?.id??t.data?._id??t.id;if(r==null||i==null)return;let a=D?.dependenciesField;if(!a)return;let o=g.find(e=>String(e.id??e._id)===String(i))?.[a],s=Ge(o),c=e=>String(typeof e==`object`?e.id:e),l=s.find(e=>c(e)===String(r)),u=l&&typeof l==`object`?l.type??`fs`:`fs`;if(l&&u===n)return;let d=n===`fs`?r:{id:r,type:n},f=l?s.map(e=>c(e)===String(r)?d:e):[...s,d];await F(i,o,f)},[D,g,F]),ze=(0,t.useCallback)(async(e,t)=>{let n=e.data?.id??e.data?._id??e.id,r=t.data?.id??t.data?._id??t.id;if(n==null||r==null)return;let i=D?.dependenciesField;if(!i)return;let a=g.find(e=>String(e.id??e._id)===String(r))?.[i],o=Ge(a),s=e=>String(typeof e==`object`?e.id:e),c=o.filter(e=>s(e)!==String(n));c.length!==o.length&&await F(r,a,c)},[D,g,F]),[Be,I]=(0,t.useState)(null),[Ve,L]=(0,t.useState)(!1),We=(0,t.useCallback)(e=>{I(e)},[]),qe=(0,t.useCallback)(async()=>{if(!Be)return;if(!O?.delete){I(null);return}let e=Be.data?.id??Be.data?._id??Be.id;if(e==null){I(null);return}L(!0);let t=g;_(t=>t.filter(t=>String(t.id??t._id)!==String(e)));try{if(await O.delete(k,String(e))===!1)throw Error(w(`gantt.writeFailed`));I(null),A({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to delete:`,e),_(t),I(null),T(e)}finally{L(!1)}},[Be,O,k,g,A,T,w]);return v?(0,d.jsx)(`div`,{className:u,children:(0,d.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,d.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading Gantt chart...`})})}):ee?(0,d.jsx)(`div`,{className:u,children:(0,d.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,d.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,ee.message]})})}):D?(0,d.jsxs)(`div`,{className:(0,c.cn)(`flex h-full min-h-0 flex-col`,u),children:[ye.length>0&&(0,d.jsx)(He,{filters:ye,value:Se,onChange:Te,onClear:Ee,resultCount:ke.length,totalCount:j.length,labels:{all:w(`gantt.quickFilter.all`),clear:w(`gantt.quickFilter.clear`),empty:w(`gantt.quickFilter.empty`),resultSummary:(e,t)=>w(`gantt.quickFilter.resultSummary`).replace(`{shown}`,String(e)).replace(`{total}`,String(t))}}),(0,d.jsx)(`div`,{className:`flex-1 min-h-[420px]`,children:D?.resourceView&&ue?(0,d.jsx)(Le,{tasks:ke,assignee:ue,effort:fe,capacity:D?.capacity??1,viewMode:D?.viewMode||`day`}):(0,d.jsx)(M,{tasks:ke,viewMode:D?.viewMode,startDate:Ae?.start,endDate:Ae?.end,onTaskClick:e=>{De(e.data)||N.handleClick(e.data),f?.(e.data)},onTaskUpdate:P,onTaskDelete:We,onDependencyCreate:D?.dependenciesField?Re:void 0,onDependencyDelete:D?.dependenciesField?ze:void 0,markers:e.markers,autoSchedule:!!D?.dependenciesField,rescheduleOnConflict:!!D?.dependenciesField,criticalPathDefault:!!e.criticalPath,workingCalendar:pe,shiftSegments:me,showBaselines:e.showBaselines!==!1,readOnly:!!e.readOnly,mobileReadOnly:e.mobileReadOnly!==!1,persistLayoutKey:be,onLayoutChange:xe?we:void 0,groupBy:le,defaultCollapsedDepth:D?.defaultCollapsedDepth,summaryExtent:D?.summaryExtent,interactions:D?.interactions,dependencyTypes:D?.dependencyTypes,timeZone:D?.timeZone,onBeforeTaskUpdate:m,exportFileName:String(D?.exportFileName??e.label??b?.label??e.objectName??``)||void 0,inlineEdit:!0,onRefresh:(E?.provider===`object`||E?.provider===`api`)&&typeof O?.find==`function`?()=>A({silent:!0}):void 0,refreshing:ae})}),N.isOverlay&&N.isOpen&&N.selectedRecord&&(()=>{let t=N.selectedRecord,n=Oe(t);if(!n||De(t))return null;let{objectName:r,recordId:i}=n,o=n.href??void 0,c=D?.titleField?String(t[D.titleField]??w(`gantt.drawer.fallbackTitle`)):w(`gantt.drawer.fallbackTitle`),l=!!e.readOnly||(D?.lockField?!!t[D.lockField]:!1),u=Ne?.key===`${r}:${i}`?Ne:null,f=u?.record??t,p=u?.schema??(r===k?b:void 0),m=u&&a?a:O;return(0,d.jsx)(s.RecordDetailDrawer,{open:!0,onClose:N.close,title:c,record:f,objectName:r,recordId:i,dataSource:m??void 0,objectSchema:p,width:N.width,fullPageHref:o,onFieldSave:l?void 0:async(e,t)=>{if(m?.update){try{await m.update(r,String(i),{[e]:t})}catch(e){let t=Ke(e);throw t?Error(t):e}u&&Pe(n=>n&&n.key===u.key?{...n,record:{...n.record,[e]:t}}:n),_(n=>n.map(n=>String(n.id??n._id)===String(i)?{...n,[e]:t}:n)),A({silent:!0})}},onDelete:l?void 0:async()=>{if(O?.delete){try{if(await O.delete(r,String(i))===!1)throw Error(w(`gantt.writeFailed`))}catch(e){throw T(e),e}_(e=>e.filter(e=>String(e.id??e._id)!==String(i)))}}})})(),(0,d.jsx)(c.AlertDialog,{open:!!Be,onOpenChange:e=>{!e&&!Ve&&I(null)},children:(0,d.jsxs)(c.AlertDialogContent,{children:[(0,d.jsxs)(c.AlertDialogHeader,{children:[(0,d.jsx)(c.AlertDialogTitle,{children:w(`gantt.delete.title`)}),(0,d.jsx)(c.AlertDialogDescription,{children:Be?w(`gantt.delete.body`,{title:Be.title}):null})]}),(0,d.jsxs)(c.AlertDialogFooter,{children:[(0,d.jsx)(c.AlertDialogCancel,{disabled:Ve,children:w(`gantt.delete.cancel`)}),(0,d.jsx)(c.AlertDialogAction,{onClick:e=>{e.preventDefault(),qe()},disabled:Ve,"data-testid":`gantt-delete-confirm`,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:w(Ve?`gantt.delete.deleting`:`gantt.delete.confirm`)})]})]})})]}):(0,d.jsx)(`div`,{className:u,children:(0,d.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,d.jsx)(`div`,{className:`text-muted-foreground`,children:`Gantt configuration required. Please specify startDateField, endDateField, and titleField.`})})})},Je={filter:!0,sort:!0},Ye=({schema:e})=>{let{dataSource:t}=(0,r.useSchemaContext)()||{};return(0,d.jsx)(r.ElementDataSourceGate,{schema:e,mapping:Je,dataSource:t,testId:`object-gantt`,errorTitle:`This gantt chart’s data source could not be resolved`,children:e=>(0,d.jsx)(qe,{schema:e,dataSource:t})})};n.ComponentRegistry.register(`object-gantt`,Ye,{namespace:`plugin-gantt`,label:`Object Gantt`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`gantt`,type:`object`,label:`Gantt Config`,description:`startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField`}]}),n.ComponentRegistry.register(`gantt`,Ye,{namespace:`view`,label:`Gantt View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`gantt`,type:`object`,label:`Gantt Config`,description:`startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField`}]}),e.GanttView=M,e.ObjectGantt=qe,e.ObjectGanttRenderer=Ye,e.QuickFilterBar=He,e.ResourceWorkload=Le,e.bandAt=j,e.computeWorkload=Ne,e.normalizeDependencies=Ge,e.normalizeShiftSegments=ce,e.normalizeTaskType=Ue,e.parseHHMM=se,e.shiftDayStart=A});
63
+ `}),(0,p.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 p-2 border-b bg-card`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":P(`gantt.toolbar.prevPeriod`),"data-testid":`gantt-toolbar-prev-period`,onClick:()=>ur(-1),children:(0,p.jsx)(f.ChevronLeft,{className:`h-4 w-4`})}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":P(`gantt.toolbar.nextPeriod`),"data-testid":`gantt-toolbar-next-period`,onClick:()=>ur(1),children:(0,p.jsx)(f.ChevronRight,{className:`h-4 w-4`})}),(0,p.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,"data-testid":`gantt-toolbar-period`,children:lr}),R&&(0,p.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,"data-testid":`gantt-readonly-badge`,title:P(`gantt.readOnlyHint`),children:[(0,p.jsx)(f.Lock,{className:`h-3 w-3`}),P(`gantt.readOnly`)]})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`div`,{className:`flex bg-muted rounded-md p-1`,role:`group`,"aria-label":P(`gantt.toolbar.viewMode`),children:I.map(e=>(0,p.jsx)(u.Button,{variant:`ghost`,size:`sm`,className:(0,u.cn)(`h-6 px-1.5 sm:px-2 text-xs`,H===e&&`bg-background shadow-sm hover:bg-background`),onClick:()=>Bn(e),"aria-pressed":H===e,"data-testid":`gantt-view-mode-${e}`,children:P(`gantt.viewMode.${e}`)},e))}),(0,p.jsxs)(`div`,{className:`flex bg-muted rounded-md p-1`,children:[(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(yt>15)ct(Math.max(15,yt-10));else{let e=I.indexOf(H);e<I.length-1&&(Bn(I[e+1]),ct(Se))}},"aria-label":P(`gantt.toolbar.zoomOut`),children:(0,p.jsx)(f.ZoomOut,{className:`h-3 w-3`})}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(yt<120)ct(Math.min(120,yt+10));else{let e=I.indexOf(H);e>0&&(Bn(I[e-1]),ct(Se))}},"aria-label":P(`gantt.toolbar.zoomIn`),children:(0,p.jsx)(f.ZoomIn,{className:`h-3 w-3`})})]}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>ht(e=>!e),"aria-label":P(U?`gantt.toolbar.showTaskList`:`gantt.toolbar.hideTaskList`),"aria-pressed":U,"data-testid":`gantt-toggle-task-list`,children:U?(0,p.jsx)(f.PanelLeft,{className:`h-4 w-4`}):(0,p.jsx)(f.PanelLeftClose,{className:`h-4 w-4`})}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:yr,disabled:vr==null,"aria-label":P(`gantt.toolbar.jumpToToday`),"data-testid":`gantt-jump-today`,children:P(`gantt.toolbar.today`)}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:Cr,"aria-label":P(`gantt.toolbar.thisWeek`),"data-testid":`gantt-jump-week`,children:P(`gantt.toolbar.thisWeek`)}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:wr,"aria-label":P(`gantt.toolbar.thisMonth`),"data-testid":`gantt-jump-month`,children:P(`gantt.toolbar.thisMonth`)}),le?(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>void le(),disabled:ue,"aria-label":P(`gantt.toolbar.refresh`),"aria-busy":ue,"data-testid":`gantt-refresh`,children:(0,p.jsx)(f.RefreshCw,{className:`h-4 w-4`})}):null,z?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Xt,disabled:!Qt,"aria-label":P(`gantt.toolbar.undo`),"data-testid":`gantt-undo`,children:(0,p.jsx)(f.Undo2,{className:`h-4 w-4`})}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Zt,disabled:!$t,"aria-label":P(`gantt.toolbar.redo`),"data-testid":`gantt-redo`,children:(0,p.jsx)(f.Redo2,{className:`h-4 w-4`})})]}):null,(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>oi(e=>!e),"aria-label":P(`gantt.toolbar.criticalPath`),"aria-pressed":ai,"data-testid":`gantt-critical-path`,style:ai?{color:li}:void 0,children:(0,p.jsx)(f.Activity,{className:`h-4 w-4`})}),rt&&z?(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:mi,"aria-label":P(`gantt.toolbar.autoSchedule`),"data-testid":`gantt-auto-schedule`,children:(0,p.jsx)(f.Wand2,{className:`h-4 w-4`})}):null,(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:vi,"aria-label":P(`gantt.toolbar.exportPng`),"data-testid":`gantt-export-png`,children:(0,p.jsx)(f.Download,{className:`h-4 w-4`})}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:yi,"aria-label":P(`gantt.toolbar.exportPdf`),"data-testid":`gantt-export-pdf`,children:(0,p.jsx)(f.FileDown,{className:`h-4 w-4`})}),oe||O?(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Si,"aria-label":P(`gantt.toolbar.saveLayout`),"aria-pressed":bi,"data-testid":`gantt-save-layout`,style:bi?{color:li}:void 0,children:(0,p.jsx)(f.Save,{className:`h-4 w-4`})}):null,(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:pr,"aria-label":P(dr?`gantt.toolbar.exitFullscreen`:`gantt.toolbar.enterFullscreen`),"aria-pressed":dr,"data-testid":`gantt-fullscreen`,children:dr?(0,p.jsx)(f.Minimize2,{className:`h-4 w-4`}):(0,p.jsx)(f.Maximize2,{className:`h-4 w-4`})})]})]}),(0,p.jsxs)(`div`,{className:`relative flex flex-col flex-1 overflow-hidden outline-none focus-visible:ring-1 focus-visible:ring-ring`,tabIndex:0,onKeyDown:jn,"data-testid":`gantt-body`,children:[!U&&W>0&&(0,p.jsx)(`div`,{className:`absolute top-0 bottom-0 z-30 group/splitter`,style:{left:W-3,width:7,cursor:`col-resize`},"data-testid":`gantt-list-resize`,role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{if(e.button!==0)return;e.preventDefault();let t=e.clientX,n=W,r=Math.max(Ce,De-200),i=e=>{let i=Math.max(Ce,Math.min(n+(e.clientX-t),r));ut(i)},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),window.removeEventListener(`pointercancel`,a),document.body.style.cursor=``};document.body.style.cursor=`col-resize`,window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a),window.addEventListener(`pointercancel`,a)},onDoubleClick:()=>ut(null),children:(0,p.jsx)(`div`,{className:`absolute inset-y-0 left-1/2 -translate-x-1/2 w-px bg-border group-hover/splitter:w-[3px] group-hover/splitter:bg-primary transition-all`})}),(0,p.jsxs)(`div`,{className:`flex border-b bg-muted/30 shrink-0 h-10 gantt-sm-h50`,children:[(0,p.jsxs)(`div`,{className:`flex items-center font-medium text-xs text-muted-foreground px-2 sm:px-4 border-r bg-card z-20 shadow-sm`,style:{width:W,minWidth:W},children:[(0,p.jsx)(`div`,{className:`flex-1 truncate`,children:P(`gantt.column.taskName`)}),xt&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:P(`gantt.column.start`)}),(0,p.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:P(`gantt.column.end`)})]}),l&&(0,p.jsx)(`div`,{className:`w-6 shrink-0 hidden sm:block`,style:{marginLeft:4},"aria-hidden":`true`,"data-testid":`gantt-header-open-spacer`})]}),(0,p.jsx)(`div`,{className:`flex-1 overflow-hidden`,ref:Gn,children:(0,p.jsxs)(`div`,{className:`flex flex-col h-full`,style:{width:Fn},children:[(0,p.jsx)(`div`,{className:`relative border-b`,style:{height:`45%`},"data-testid":`gantt-header-groups`,children:Un.slice(ar.start,ar.end).map(e=>(0,p.jsx)(`div`,{className:`absolute top-0 bottom-0 flex items-center justify-center border-r text-[10px] font-medium text-muted-foreground overflow-hidden`,style:{left:e.offset,width:e.width},children:(0,p.jsx)(`span`,{className:`truncate px-1`,children:e.label})},e.key))}),(0,p.jsx)(`div`,{className:`relative flex-1`,"data-testid":`gantt-header-units`,children:Y.slice(rr.start,rr.end).map((e,t)=>{let n=rr.start+t;return(0,p.jsxs)(`div`,{className:(0,u.cn)(`absolute top-0 bottom-0 flex items-center justify-center gap-1 border-r text-xs text-muted-foreground overflow-hidden`,e.isWeekend&&`bg-muted/50`),style:{left:X[n],width:e.width,backgroundColor:e.bandColor?`color-mix(in srgb, ${e.bandColor} 16%, transparent)`:void 0},children:[(0,p.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.label}),e.sublabel&&yt>=32&&(0,p.jsx)(`span`,{className:`text-[10px] opacity-70`,children:e.sublabel})]},n)})})]})})]}),(0,p.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,p.jsxs)(`div`,{className:`gantt-task-list overflow-y-auto overflow-x-hidden border-r bg-card z-10 shadow-sm`,ref:Kn,onScroll:zr,style:{width:W,minWidth:W},role:`tree`,"aria-label":P(`gantt.aria.taskList`),children:[$.startIdx>0&&(0,p.jsx)(`div`,{style:{height:$.startIdx*V},"aria-hidden":`true`}),q.slice($.startIdx,$.endIdx).map(e=>{let t=e.task,r=nt&&St===t.id,i=Dn.has(String(t.id)),a=Sn!=null&&String(Sn)===String(t.id);return(0,p.jsxs)(`div`,{className:(0,u.cn)(`group/task-row relative flex items-center border-b px-2 sm:px-4 hover:bg-accent/50 cursor-pointer transition-colors`,a&&`bg-accent/50`),style:{height:V,touchAction:`manipulation`},role:`treeitem`,"data-testid":`gantt-task-row-${t.id}`,"aria-level":e.depth+1,"aria-selected":a,"aria-expanded":e.hasChildren?!i:void 0,draggable:!!tt&&!r&&!t.locked,onDragStart:tt?e=>{e.dataTransfer.setData(`text/plain`,String(t.id)),e.dataTransfer.effectAllowed=`move`}:void 0,onDragOver:tt?e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`}:void 0,onDrop:tt?e=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);if(!n||n===String(t.id))return;let r=At.get(n);r&&String(r.parent??``)===String(t.parent??``)&&tt(r,t)}:void 0,onContextMenu:e=>Tn(t,e),onClick:()=>{Cn(t.id),r||Sr(e.start,e.end,t.id)},onDoubleClick:()=>{r||(nt&&z&&!e.isSummary&&!t.locked?(Ct(t.id),Tt({title:t.title,start:t.start.toLocaleDateString(`en-CA`),end:(0,n.toDateInputValue)(Ie(t.start,t.end)),progress:String(t.progress)})):l?.(t))},children:[(0,p.jsxs)(`div`,{className:`flex-1 truncate font-medium text-xs sm:text-sm flex items-center gap-2`,style:e.depth>0?{paddingLeft:e.depth*14}:void 0,children:[e.hasChildren?(0,p.jsx)(`button`,{type:`button`,className:`h-4 w-4 shrink-0 flex items-center justify-center text-muted-foreground hover:text-foreground`,style:{marginLeft:-4},onClick:e=>{e.stopPropagation(),kn(t.id)},"aria-expanded":!i,"aria-label":P(i?`gantt.row.expand`:`gantt.row.collapse`),"data-testid":`gantt-row-toggle-${t.id}`,children:i?(0,p.jsx)(f.ChevronRight,{className:`h-3.5 w-3.5`}):(0,p.jsx)(f.ChevronDown,{className:`h-3.5 w-3.5`})}):(0,p.jsx)(`span`,{className:`w-3 shrink-0`,style:{marginLeft:-4},"aria-hidden":`true`}),(0,p.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0`,style:{backgroundColor:t.color||`#3b82f6`}}),r?(0,p.jsx)(`input`,{className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:wt.title||``,onChange:e=>Tt(t=>({...t,title:e.target.value})),onKeyDown:e=>{e.key===`Enter`?(Ht([{task:t,changes:{title:wt.title,start:(0,n.toDisplayDate)(wt.start),end:Le(wt.end,t),progress:Number(wt.progress)||0}}]),Ct(null)):e.key===`Escape`&&Ct(null)},onClick:e=>e.stopPropagation(),autoFocus:!0}):(0,p.jsxs)(`span`,{className:`flex flex-col min-w-0`,children:[(0,p.jsx)(`span`,{className:(0,u.cn)(`truncate`,e.isSummary&&`font-semibold`),"data-testid":`gantt-row-title-${t.id}`,children:t.title}),!xt&&(0,p.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,"data-testid":`gantt-row-dates-${t.id}`,children:[e.start.toLocaleDateString(F,{month:`numeric`,day:`numeric`}),` → `,Ie(e.start,e.end).toLocaleDateString(F,{month:`numeric`,day:`numeric`})]})]})]}),xt&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground`,"data-testid":`gantt-row-start-${t.id}`,children:r?(0,p.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:wt.start||``,onChange:e=>Tt(t=>({...t,start:e.target.value})),onClick:e=>e.stopPropagation()}):e.start.toLocaleDateString(F,{month:`numeric`,day:`numeric`})}),(0,p.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground`,"data-testid":`gantt-row-end-${t.id}`,children:r?(0,p.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:wt.end||``,onChange:e=>Tt(t=>({...t,end:e.target.value})),onClick:e=>e.stopPropagation()}):Ie(e.start,e.end).toLocaleDateString(F,{month:`numeric`,day:`numeric`})})]}),l&&(0,p.jsx)(`div`,{className:`w-6 shrink-0 hidden sm:block`,style:{marginLeft:4},children:!r&&(0,p.jsx)(`button`,{type:`button`,title:P(`gantt.row.open`),"aria-label":P(`gantt.row.open`),"data-testid":`gantt-row-open-${t.id}`,className:`gantt-row-open-btn h-6 w-6 rounded-md flex items-center justify-center hover:bg-accent text-muted-foreground hover:text-foreground`,onClick:e=>{e.stopPropagation(),l(t)},children:(0,p.jsx)(f.ArrowRight,{className:`h-3.5 w-3.5`})})})]},t.id)}),$.endIdx<q.length&&(0,p.jsx)(`div`,{style:{height:(q.length-$.endIdx)*V},"aria-hidden":`true`})]}),(0,p.jsx)(`div`,{className:`flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]`,ref:e=>{qn.current=e,Q.current=e},onScroll:Rr,onTouchStart:hr,onTouchMove:gr,onTouchEnd:_r,"data-testid":`gantt-timeline`,children:(0,p.jsxs)(`div`,{className:`relative`,style:{width:Fn},children:[vr!=null&&(0,p.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px z-20 pointer-events-none`,style:{left:vr,backgroundColor:`rgba(239, 68, 68, 0.8)`},"data-testid":`gantt-today-marker`,"aria-label":P(`gantt.toolbar.today`),children:(0,p.jsx)(`div`,{className:`absolute -translate-x-1/2 left-0 text-[10px] font-semibold text-white rounded-sm px-1 py-0.5 whitespace-nowrap z-30`,style:{top:2,backgroundColor:`#ef4444`},children:P(`gantt.toolbar.today`)})}),Wn.map(e=>(0,p.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px z-20 pointer-events-none`,style:{left:e.left,backgroundColor:e.color},"data-testid":`gantt-marker-${e.index}`,"aria-label":e.label,children:e.label&&(0,p.jsx)(`div`,{className:`absolute -translate-x-1/2 left-0 text-[10px] font-semibold text-white rounded-sm px-1 py-0.5 whitespace-nowrap z-30`,style:{top:2,backgroundColor:e.color},children:e.label})},e.index)),(0,p.jsxs)(`div`,{className:`relative`,ref:cn,children:[(0,p.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:Y.slice(rr.start,rr.end).map((e,t)=>{let n=rr.start+t;return(0,p.jsx)(`div`,{className:`absolute top-0 bottom-0 border-r`,style:{left:X[n],width:e.width,backgroundColor:e.bandColor?`color-mix(in srgb, ${e.bandColor} 8%, transparent)`:e.isWeekend?`hsl(var(--muted) / 0.4)`:void 0}},n)})}),Mn&&S&&S.showMidnight&&(0,p.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:Y.slice(rr.start,rr.end).map((e,t)=>{let n=rr.start+t,r=e.realMs??0;if(!r)return null;let i=e.date.getTime(),a=e.date,o=new Date(a.getFullYear(),a.getMonth(),a.getDate()+1,0,0,0,0).getTime();if(o<=i||o>=i+r)return null;let s=X[n]+(o-i)/r*e.width;return(0,p.jsx)(`div`,{className:`absolute top-0 bottom-0`,style:{left:s,borderLeft:`1px dashed hsl(var(--muted-foreground) / 0.4)`},"data-testid":`gantt-midnight-${n}`,"aria-hidden":`true`},`midnight-${n}`)})}),$.startIdx>0&&(0,p.jsx)(`div`,{style:{height:$.startIdx*V},"aria-hidden":`true`}),q.slice($.startIdx,$.endIdx).map((e,n)=>{let r=e.task,i=$.startIdx+n,a=ci(r.id),o=Br(e.start,e.end),s=ie&&r.baselineStart&&r.baselineEnd?Br(r.baselineStart,r.baselineEnd):null,c=s?(0,p.jsx)(`div`,{className:`absolute pointer-events-none rounded-[1px]`,style:{left:s.left,width:Math.max(2,s.width),top:ei,height:$r,backgroundColor:ti,border:`1px solid ${ni}`},"data-testid":`gantt-baseline-${r.id}`,"aria-hidden":`true`}):null,l=G?.taskId===r.id,d=Hr?.has(String(r.id))??!1,f=Ur?.has(String(r.id))??!1,m=l||d||f?Wr(e):o,h=!!r.locked,g=!!z&&!e.isSummary&&!h,_=g&&Ye,v=g&&Xe,y=g&&Ze,b=_||v,ee=R||h,te=K!=null&&K.targetId!=null&&String(K.targetId)===String(r.id)&&String(K.sourceId)!==String(r.id),ne=K!=null&&K.rejectedId!=null&&String(K.rejectedId)===String(r.id)?{cursor:`not-allowed`,boxShadow:`0 0 0 2px hsl(var(--destructive))`}:void 0,re=K?e=>{let t=e.currentTarget.getBoundingClientRect(),n=t.width>0&&e.clientX-t.left>t.width/2?`end`:`start`;ln(e=>{if(!e)return e;let t=on(e.sourceId,r);return t===null?{...e,targetId:r.id,targetEnd:n,rejectedId:null,rejectedReason:null}:{...e,targetId:null,targetEnd:null,rejectedId:r.id,rejectedReason:t}})}:void 0,x=K?e=>{e.target===e.currentTarget&&ln(e=>e&&{...e,targetId:null,targetEnd:null,rejectedId:null,rejectedReason:null})}:void 0,S=Math.max(1,Math.round((e.end.getTime()-e.start.getTime())/je)),C=(i+1)*V+300>or&&i*V>300,w=Et===r.id&&!G&&!tn&&!K?(0,p.jsxs)(`div`,{className:`absolute z-30 pointer-events-none rounded-md border bg-popover text-popover-foreground px-2.5 py-1.5 text-xs shadow-md whitespace-nowrap`,style:{left:Math.max(m.left+8,4),...C?{bottom:V-8}:{top:V-8}},role:`tooltip`,"data-testid":`gantt-tooltip-${r.id}`,children:[(0,p.jsx)(`div`,{className:`font-semibold`,children:r.title}),r.fields&&r.fields.length>0?(0,p.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`auto 1fr`,columnGap:10,rowGap:2,marginTop:4},children:r.fields.map((e,n)=>(0,p.jsxs)(t.Fragment,{children:[(0,p.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,p.jsx)(`span`,{style:{fontWeight:500},children:e.value})]},n))}):(0,p.jsxs)(`div`,{className:`text-muted-foreground`,children:[e.start.toLocaleDateString(F,{month:`short`,day:`numeric`}),` → `,Ie(e.start,e.end).toLocaleDateString(F,{month:`short`,day:`numeric`}),` · `,S,P(`gantt.tooltip.days`),` · `,Math.round(e.progress),`%`]}),r.locked||R&&!z?(0,p.jsxs)(`div`,{className:`text-muted-foreground`,style:{marginTop:4},"data-testid":`gantt-tooltip-locked-${r.id}`,children:[`🚫 `,P(`gantt.lockedHint`)]}):null]}):null;if(r.type===`group`)return(0,p.jsx)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:V},onPointerMove:x,children:w},r.id);if(e.isSummary){let t=r.color||`#0d9488`,n=D===`self`&&r.hasOwnDates!==!1,i=!!z&&Ye&&!h,o=!!z&&Xe&&n&&!h;return(0,p.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:V},onPointerMove:x,children:[c,(0,p.jsxs)(`div`,{className:(0,u.cn)(`gantt-bar-hover absolute rounded-sm border shadow-sm flex items-center px-2 select-none group`,i&&`cursor-grab active:cursor-grabbing`,l&&`ring-2 ring-primary z-10`,te&&`ring-2 ring-primary`,Jn===r.id&&`gantt-flash z-10`),style:{left:m.left,width:m.width,top:Qr,height:Zr,cursor:i||o?void 0:ee?`not-allowed`:`pointer`,backgroundColor:t,borderColor:a?li:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${li}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0,...ne},"data-critical":a?`true`:void 0,"data-testid":`gantt-summary-bar-${r.id}`,"data-progress":Math.round(e.progress),onMouseEnter:()=>Dt(r.id),onMouseLeave:()=>Dt(e=>e===r.id?null:e),onPointerMove:re,onPointerDown:t=>{if(t.button===0){if(o){let e=xe(t.clientX,t.currentTarget.getBoundingClientRect());if(e!==`move`){en(r,e,t);return}}i&&en(r,`move`,t,{group:!0,originStart:e.start,originEnd:e.end})}},onClick:()=>{Pt.current||Cn(r.id)},onContextMenu:e=>Tn(r,e),children:[(0,p.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 pointer-events-none`,style:{width:`${Math.round(e.progress)}%`,backgroundColor:`rgba(0, 0, 0, 0.2)`,borderTopLeftRadius:`var(--radius-sm)`,borderBottomLeftRadius:`var(--radius-sm)`}}),o&&m.width>=14&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0`,style:{width:be,height:Jr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${r.id}`,onPointerDown:e=>{e.button===0&&en(r,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,p.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:be,height:Jr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${r.id}`,onPointerDown:e=>{e.button===0&&en(r,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),(0,p.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none`,children:r.title}),B&&!h&&[`start`,`end`].map(e=>{let t=K!=null&&String(K.sourceId)===String(r.id)&&K.sourceEnd===e,n=t||Et===r.id,i=n&&K==null;return(0,p.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2 z-20 flex items-center transition-opacity`,style:{[e===`start`?`left`:`right`]:-28,height:24,width:30,cursor:`crosshair`,opacity:+!!n,pointerEvents:i?`auto`:`none`,justifyContent:e===`start`?`flex-start`:`flex-end`,paddingLeft:e===`start`?4:0,paddingRight:e===`end`?4:0},"data-testid":`gantt-link-dot-${e}-${r.id}`,onPointerDown:t=>{if(t.button!==0)return;t.stopPropagation(),t.preventDefault();let n=cn.current?.getBoundingClientRect();ln({sourceId:r.id,sourceEnd:e,x:n?t.clientX-n.left:0,y:n?t.clientY-n.top:0,targetId:null,targetEnd:null,rejectedId:null,rejectedReason:null})},onClick:e=>e.stopPropagation(),children:(0,p.jsx)(`div`,{className:`rounded-full`,style:{height:12,width:12,backgroundColor:`hsl(var(--background))`,border:`2px solid hsl(var(--primary))`,boxShadow:t?`0 0 0 3px hsl(var(--primary) / 0.25)`:`0 1px 2px rgba(0,0,0,0.25)`}})},e)})]}),l&&G&&(0,p.jsxs)(`div`,{className:`absolute z-30 pointer-events-none rounded border bg-popover text-popover-foreground px-1.5 py-0.5 text-[10px] shadow whitespace-nowrap`,style:{left:Math.max(m.left,4),top:Qr+Zr+2},"data-testid":`gantt-summary-drag-chip-${r.id}`,children:[Ft(G).start.toLocaleDateString(F,{month:`numeric`,day:`numeric`}),` → `,It(G).toLocaleDateString(F,{month:`numeric`,day:`numeric`})]}),w]},r.id)}if(e.isMilestone){let e=Yr;return(0,p.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:V},onPointerMove:x,children:[c,(0,p.jsx)(`div`,{className:(0,u.cn)(`gantt-bar-hover absolute rotate-45 rounded-[2px] border shadow-sm select-none`,_&&`cursor-grab active:cursor-grabbing`,l&&`ring-2 ring-primary z-10`,te&&`ring-2 ring-primary`,Jn===r.id&&`gantt-flash z-10`),style:{left:m.left-e/2,top:(V-e)/2,width:e,height:e,cursor:_?void 0:ee?`not-allowed`:`pointer`,backgroundColor:a?li:r.color||`#3b82f6`,borderColor:a?li:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${li}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0,...ne},"data-critical":a?`true`:void 0,"data-testid":`gantt-milestone-${r.id}`,onMouseEnter:()=>Dt(r.id),onMouseLeave:()=>Dt(e=>e===r.id?null:e),onClick:()=>{Pt.current||Cn(r.id)},onContextMenu:e=>Tn(r,e),onPointerMove:re,onPointerDown:_?e=>{e.button===0&&en(r,`move`,e)}:void 0}),w]},r.id)}let T=tn&&tn.taskId===r.id?tn.value:r.progress;return(0,p.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:V},onPointerMove:x,onMouseEnter:()=>Dt(r.id),onMouseLeave:()=>Dt(e=>e===r.id?null:e),children:[l&&(0,p.jsx)(`div`,{className:`absolute rounded-sm border border-dashed pointer-events-none`,style:{left:o.left,width:o.width,top:Kr,height:qr,opacity:.35,borderColor:`hsl(var(--primary) / 0.6)`},"aria-hidden":`true`}),c,(0,p.jsxs)(`div`,{className:(0,u.cn)(`gantt-bar-hover absolute rounded-sm bg-primary border shadow-sm flex items-center px-2 group select-none`,b&&`cursor-grab active:cursor-grabbing`,l&&`ring-2 ring-primary z-10`,te&&`ring-2 ring-primary`,Jn===r.id&&`gantt-flash z-10`),style:{left:m.left,width:m.width,top:Kr,height:qr,cursor:b?void 0:ee?`not-allowed`:`pointer`,backgroundColor:r.color||`#3b82f6`,borderColor:a?li:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${li}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0,...ne},"data-critical":a?`true`:void 0,"data-testid":`gantt-task-bar-${r.id}`,onClick:()=>{Pt.current||Cn(r.id)},onContextMenu:e=>Tn(r,e),onPointerMove:re,onPointerDown:b?e=>{if(e.button!==0)return;let t=xe(e.clientX,e.currentTarget.getBoundingClientRect()),n=t!==`move`&&v?t:_?`move`:null;n&&en(r,n,e)}:void 0,children:[v&&m.width>=14&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0`,style:{width:be,height:Jr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${r.id}`,onPointerDown:e=>{e.button===0&&en(r,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,p.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:be,height:Jr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${r.id}`,onPointerDown:e=>{e.button===0&&en(r,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),T>0&&(0,p.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 pointer-events-none`,style:{width:`${T}%`,backgroundColor:`rgba(0, 0, 0, 0.2)`,borderTopLeftRadius:`var(--radius-sm)`,borderBottomLeftRadius:`var(--radius-sm)`}}),y&&m.width>=30&&(0,p.jsx)(`div`,{className:(0,u.cn)(`absolute bottom-0 h-1/2 w-4 -translate-x-1/2 cursor-col-resize flex items-end justify-center pb-px`,tn?.taskId===r.id?`opacity-100`:`opacity-0 group-hover:opacity-100 transition-opacity`),style:{left:`${T}%`},"data-testid":`gantt-progress-handle-${r.id}`,onPointerDown:e=>{e.button===0&&(e.stopPropagation(),e.preventDefault(),nn({taskId:r.id,originClientX:e.clientX,originProgress:r.progress,barWidth:m.width,value:r.progress}))},onClick:e=>e.stopPropagation(),children:(0,p.jsx)(`div`,{style:{width:0,height:0,borderLeft:`5px solid transparent`,borderRight:`5px solid transparent`,borderBottom:`7px solid #fff`,filter:`drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35))`}})}),B&&!h&&[`start`,`end`].map(e=>{let t=K!=null&&String(K.sourceId)===String(r.id)&&K.sourceEnd===e,n=t||Et===r.id,i=n&&K==null;return(0,p.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2 z-20 flex items-center transition-opacity`,style:{[e===`start`?`left`:`right`]:-28,height:24,width:30,cursor:`crosshair`,opacity:+!!n,pointerEvents:i?`auto`:`none`,justifyContent:e===`start`?`flex-start`:`flex-end`,paddingLeft:e===`start`?4:0,paddingRight:e===`end`?4:0},"data-testid":`gantt-link-dot-${e}-${r.id}`,onPointerDown:t=>{if(t.button!==0)return;t.stopPropagation(),t.preventDefault();let n=cn.current?.getBoundingClientRect();ln({sourceId:r.id,sourceEnd:e,x:n?t.clientX-n.left:0,y:n?t.clientY-n.top:0,targetId:null,targetEnd:null,rejectedId:null,rejectedReason:null})},onClick:e=>e.stopPropagation(),children:(0,p.jsx)(`div`,{className:`rounded-full`,style:{height:12,width:12,backgroundColor:`hsl(var(--background))`,border:`2px solid hsl(var(--primary))`,boxShadow:t?`0 0 0 3px hsl(var(--primary) / 0.25)`:`0 1px 2px rgba(0,0,0,0.25)`}})},e)}),(0,p.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none group-hover:opacity-0 transition-opacity`,children:r.title}),(0,p.jsx)(`span`,{className:`absolute inset-0 flex items-center px-2 text-[10px] text-white font-medium truncate opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none`,children:l?`${Ft(G).start.toLocaleDateString(F,{month:`numeric`,day:`numeric`})} → ${It(G).toLocaleDateString(F,{month:`numeric`,day:`numeric`})}`:`${Math.round(T)}%`})]}),w]},r.id)}),$.endIdx<q.length&&(0,p.jsx)(`div`,{style:{height:(q.length-$.endIdx)*V},"aria-hidden":`true`}),(Gr.length>0||K)&&(0,p.jsxs)(`svg`,{className:`absolute top-0 left-0 pointer-events-none z-10`,width:Fn,height:or,"data-testid":`gantt-links`,"aria-hidden":`true`,children:[(0,p.jsxs)(`defs`,{children:[(0,p.jsx)(`marker`,{id:`gantt-link-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,p.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--muted-foreground))`})}),(0,p.jsx)(`marker`,{id:`gantt-link-arrow-active`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,p.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--primary))`})}),(0,p.jsx)(`marker`,{id:`gantt-link-arrow-critical`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,p.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:li})})]}),Gr.map(e=>{let n=Math.min(e.sourceIndex,e.targetIndex);if(Math.max(e.sourceIndex,e.targetIndex)<$.startIdx-6||n>$.endIdx+6)return null;let r=ri(e);if(!r)return null;let i=ii!=null&&(String(e.sourceId)===String(ii)||String(e.targetId)===String(ii)),a=si?.criticalEdges.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,o=a?`gantt-link-arrow-critical`:i?`gantt-link-arrow-active`:`gantt-link-arrow`,s=!!(et||B);return(0,p.jsxs)(t.Fragment,{children:[(0,p.jsx)(`path`,{d:r,fill:`none`,stroke:a?li:i?`hsl(var(--primary))`:`hsl(var(--muted-foreground))`,strokeOpacity:a||i?1:.7,strokeWidth:a||i?2:1.5,markerEnd:`url(#${o})`,"data-testid":`gantt-link-${e.sourceId}-${e.targetId}`,"data-link-type":e.type,"data-active":i?`true`:`false`,"data-critical":a?`true`:void 0}),s&&(0,p.jsx)(`path`,{d:r,fill:`none`,stroke:`transparent`,strokeWidth:10,style:{pointerEvents:`stroke`,cursor:`context-menu`},"data-testid":`gantt-link-hit-${e.sourceId}-${e.targetId}`,onContextMenu:t=>En(e.sourceId,e.targetId,e.type,t)})]},e.key)}),K&&(()=>{let e=q.findIndex(e=>String(e.task.id)===String(K.sourceId));if(e<0)return null;let t=Wr(q[e]),n=q[e].isMilestone?t.left+(K.sourceEnd===`start`?-Xr:Xr):K.sourceEnd===`start`?t.left:t.left+t.width,r=e*V+V/2;return(0,p.jsx)(`path`,{d:`M ${Math.round(n)} ${Math.round(r)} L ${Math.round(K.x)} ${Math.round(K.y)}`,fill:`none`,stroke:`hsl(var(--primary))`,strokeWidth:1.5,strokeDasharray:`4 3`,"data-testid":`gantt-link-draft`})})()]}),K&&(()=>{let e=N.find(e=>String(e.id)===String(K.sourceId));if(!e)return null;let t=K.targetId==null?null:N.find(e=>String(e.id)===String(K.targetId)),n=e=>P(`gantt.linkEnd.${e}`),r=t?`${e.title} (${n(K.sourceEnd)}) → ${t.title} (${n(K.targetEnd??`start`)})`:`${e.title} (${n(K.sourceEnd)})`;return(0,p.jsx)(`div`,{className:`absolute z-30 pointer-events-none rounded-md border bg-popover text-popover-foreground px-2 py-1 text-[11px] font-medium shadow-md whitespace-nowrap`,style:{left:K.x+12,top:K.y+12},"data-testid":`gantt-link-draft-hint`,children:r})})()]})]})}),(0,p.jsx)(`div`,{ref:kr,className:`shrink-0 border-l bg-card/95 select-none`,style:{width:14,display:`none`},"data-testid":`gantt-vscrollbar`,children:(0,p.jsx)(`div`,{ref:Ar,className:`relative h-full`,onPointerDown:Lr,role:`scrollbar`,"aria-controls":`gantt-timeline`,"aria-orientation":`vertical`,children:(0,p.jsx)(`div`,{ref:jr,className:`absolute rounded-full`,style:{left:2,right:2,top:0,height:0,backgroundColor:`rgba(130,130,130,0.55)`,cursor:`grab`},"data-testid":`gantt-vscrollbar-thumb`,onPointerDown:Ir})})})]}),(0,p.jsx)(`div`,{ref:Tr,className:`shrink-0 border-t bg-card/95 select-none`,style:{position:`sticky`,bottom:0,zIndex:30,display:`none`},"data-testid":`gantt-hscrollbar`,children:(0,p.jsx)(`div`,{ref:Er,className:`relative`,style:{marginLeft:W,height:14},onPointerDown:Fr,role:`scrollbar`,"aria-controls":`gantt-timeline`,"aria-orientation":`horizontal`,children:(0,p.jsx)(`div`,{ref:Dr,className:`absolute rounded-full`,style:{top:2,bottom:2,left:0,width:0,backgroundColor:`rgba(130,130,130,0.55)`,cursor:`grab`},"data-testid":`gantt-hscrollbar-thumb`,onPointerDown:Pr})})})]}),dn&&(()=>{let e=N.find(e=>String(e.id)===String(dn.taskId));if(!e)return null;let t=q.find(e=>String(e.task.id)===String(dn.taskId)),r=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`;return(0,p.jsxs)(`div`,{ref:pn,className:`fixed z-50 min-w-[160px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:dn.x,top:dn.y},role:`menu`,"data-testid":`gantt-context-menu`,children:[l&&(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-view`,onClick:()=>{fn(null),l(e)},children:P(`gantt.menu.view`)}),nt&&z&&t&&!t.isSummary&&!e.locked&&(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-edit`,onClick:()=>{fn(null),Ct(e.id),Tt({title:e.title,start:e.start.toLocaleDateString(`en-CA`),end:(0,n.toDateInputValue)(Ie(e.start,e.end)),progress:String(e.progress)})},children:P(`gantt.menu.edit`)}),B&&t&&!t.isMilestone&&!e.locked&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-add-predecessor`,onClick:()=>{let t=dn;fn(null),bn(``),vn({x:t.x,y:t.y,taskId:e.id,relation:`pred`})},children:P(`gantt.menu.addPredecessor`)}),(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-add-successor`,onClick:()=>{let t=dn;fn(null),bn(``),vn({x:t.x,y:t.y,taskId:e.id,relation:`succ`})},children:P(`gantt.menu.addSuccessor`)})]}),$e&&!e.locked&&(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:(0,u.cn)(r,`text-destructive`),"data-testid":`gantt-context-menu-delete`,onClick:()=>{fn(null),$e(e)},children:P(`gantt.menu.delete`)})]})})(),mn&&(()=>{let e=N.find(e=>String(e.id)===String(mn.sourceId)),t=N.find(e=>String(e.id)===String(mn.targetId));if(!e||!t)return null;let n=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`,r=[`fs`,`ss`,`ff`,`sf`],i=!!t.locked;return(0,p.jsxs)(`div`,{ref:gn,className:`fixed z-50 min-w-[180px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:mn.x,top:mn.y},role:`menu`,"data-testid":`gantt-link-context-menu`,children:[(0,p.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground truncate`,children:[e.title,` → `,t.title]}),i&&(0,p.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,"data-testid":`gantt-link-menu-locked`,children:[`🚫 `,P(`gantt.lockedHint`)]}),B&&A&&r.map(r=>(0,p.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":mn.type===r,disabled:i,className:(0,u.cn)(n,mn.type===r&&`font-semibold`,i&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-type-${r}`,onClick:()=>{i||(hn(null),r!==mn.type&&B(e,t,r))},children:[mn.type===r?`✓ `:`\xA0\xA0`,P(`gantt.linkType.${r}`)]},r)),et&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`my-1 border-t`}),(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:i,className:(0,u.cn)(n,`text-destructive`,i&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-remove`,onClick:()=>{i||(hn(null),et(e,t))},children:P(`gantt.menu.removeDependency`)})]})]})})(),_n&&B&&(()=>{let e=N.find(e=>String(e.id)===String(_n.taskId));if(!e)return null;let t=new Set(Gr.map(e=>`${String(e.sourceId)}->${String(e.targetId)}`)),n=N.filter(n=>{if(String(n.id)===String(e.id)||n.type===`group`||n.locked)return!1;let r=_n.relation===`pred`?`${String(n.id)}->${String(e.id)}`:`${String(e.id)}->${String(n.id)}`;return!t.has(r)}),r=yn.trim().toLowerCase(),i=r?n.filter(e=>String(e.title??``).toLowerCase().includes(r)):n;return(0,p.jsxs)(`div`,{ref:xn,className:`fixed z-50 min-w-[200px] max-h-[280px] overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:_n.x,top:_n.y},role:`menu`,"data-testid":`gantt-dep-picker`,children:[(0,p.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:_n.relation===`pred`?P(`gantt.menu.addPredecessor`):P(`gantt.menu.addSuccessor`)}),(0,p.jsx)(`div`,{className:`px-2 pb-1`,children:(0,p.jsx)(`input`,{className:`border rounded px-2 py-1 text-sm w-full bg-background`,value:yn,onChange:e=>bn(e.target.value),placeholder:P(`gantt.menu.searchTasks`),"data-testid":`gantt-dep-picker-search`,autoFocus:!0})}),i.length===0?(0,p.jsx)(`div`,{className:`px-3 py-1.5 text-muted-foreground`,children:P(`gantt.menu.noCandidates`)}):i.map(t=>(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none truncate`,"data-testid":`gantt-dep-picker-option-${t.id}`,onClick:()=>{vn(null),_n.relation===`pred`?B(t,e,`fs`):B(e,t,`fs`)},children:t.title},String(t.id)))]})})(),ui&&(0,p.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-autoschedule-overlay`,onClick:()=>di(null),children:(0,p.jsxs)(`div`,{className:`min-w-[280px] max-w-[360px] rounded-lg border bg-popover text-popover-foreground shadow-lg p-4`,role:`alertdialog`,"aria-modal":`true`,"data-testid":`gantt-autoschedule-dialog`,onClick:e=>e.stopPropagation(),children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-autoschedule-title`,children:P(`gantt.autoScheduleDlg.title`)}),(0,p.jsxs)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:[P(`gantt.autoScheduleDlg.body`,{count:ui.changes.length}),ui.skipped>0&&(0,p.jsxs)(p.Fragment,{children:[` `,(0,p.jsx)(`span`,{"data-testid":`gantt-autoschedule-skipped`,children:P(`gantt.autoScheduleDlg.skipped`,{count:ui.skipped})})]})]}),(0,p.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,p.jsx)(`button`,{type:`button`,className:`px-3 py-1.5 text-sm rounded-md border hover:bg-accent outline-none`,"data-testid":`gantt-autoschedule-cancel`,onClick:()=>di(null),children:P(`gantt.autoScheduleDlg.cancel`)}),(0,p.jsx)(`button`,{type:`button`,className:`px-3 py-1.5 text-sm rounded-md bg-primary text-primary-foreground hover:opacity-90 outline-none`,"data-testid":`gantt-autoschedule-confirm`,onClick:hi,children:P(`gantt.autoScheduleDlg.confirm`)})]})]})}),fi&&(0,p.jsx)(`div`,{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-[60] rounded-md border bg-popover text-popover-foreground px-3 py-1.5 text-sm shadow-md`,role:`status`,"data-testid":`gantt-autoschedule-clean`,children:P(`gantt.autoScheduleDlg.none`)}),Ut&&(0,p.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-conflict-overlay`,onClick:()=>Wt(null),children:(0,p.jsxs)(`div`,{className:`min-w-[280px] max-w-[360px] rounded-lg border bg-popover text-popover-foreground shadow-lg p-4`,role:`alertdialog`,"aria-modal":`true`,"data-testid":`gantt-conflict-dialog`,onClick:e=>e.stopPropagation(),children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-conflict-title`,children:P(`gantt.conflict.title`)}),(0,p.jsx)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:P(`gantt.conflict.body`,{count:Ut.length})}),(0,p.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,p.jsx)(`button`,{type:`button`,className:`px-3 py-1.5 text-sm rounded-md border hover:bg-accent outline-none`,"data-testid":`gantt-conflict-cancel`,onClick:()=>Wt(null),children:P(`gantt.conflict.cancel`)}),(0,p.jsx)(`button`,{type:`button`,className:`px-3 py-1.5 text-sm rounded-md bg-primary text-primary-foreground hover:opacity-90 outline-none`,"data-testid":`gantt-conflict-confirm`,onClick:Jt,children:P(`gantt.conflict.confirm`)})]})]})})]})}function Ye(e,t,n,r){return t.getTime()===e.getTime()?e.getTime()>=n.getTime()&&e.getTime()<r.getTime():e.getTime()<r.getTime()&&t.getTime()>n.getTime()}function Xe(e,t,n){let{assignee:r,effort:i,capacity:a=1,unassignedLabel:o=`Unassigned`}=n,s=e=>typeof a==`function`?a(e):a,c=e=>{let t=i?i(e):1;return Number.isFinite(t)&&t>0?t:0},l=new Map;for(let t of e){let e=r(t),n=e?String(e.key):`__unassigned__`,i=e?e.label:o,a=l.get(n);a||(a={key:n,label:i,items:[]},l.set(n,a)),a.items.push(t)}let u=[];for(let e of l.values()){let n=s(e.key),r=0,i=0,a=t.map(t=>{let a=0;for(let n of e.items)Ye(n.start,n.end,t.start,t.end)&&(a+=c(n));a>r&&(r=a);let o=a>n+1e-9;return o&&i++,{load:a,capacity:n,overloaded:o}});u.push({key:e.key,label:e.label,capacity:n,cells:a,peak:r,overloadedCount:i})}return u}var Ze={day:26,week:56,month:76,quarter:88,year:104},Qe=48,z=34,$e=180;function B(e,t,n){return t===`day`?String(e.getDate()):t===`week`?e.toLocaleDateString(n,{month:`numeric`,day:`numeric`}):t===`month`?e.toLocaleDateString(n,{month:`short`}):t===`year`?String(e.getFullYear()):`Q${Math.floor(e.getMonth()/3)+1}`}function et({tasks:e,assignee:n,effort:r,capacity:i=1,viewMode:a=`day`,unassignedLabel:o=`Unassigned`,className:c}){let{t:l}=ye(),u=(0,s.useDisplayLocale)(),d=Ze[a],f=t.useMemo(()=>{if(!e.length)return[];let t=new Date(Math.min(...e.map(e=>e.start.getTime()))),n=new Date(Math.max(...e.map(e=>e.end.getTime()))),r=Me(t,a),i=L(Me(n,a),1,a),o=[],s=0;for(;r<i&&s++<4e3;){let e=L(r,1,a);o.push({date:new Date(r),col:{start:new Date(r),end:new Date(e)},label:B(r,a,u)}),r=e}return o},[e,a,u]),m=t.useMemo(()=>Xe(e,f.map(e=>e.col),{assignee:n,effort:r,capacity:i,unassignedLabel:o}),[e,f,n,r,i,o]),h=t.useMemo(()=>{let e=0;for(let t of m)e=Math.max(e,t.peak,t.capacity);return e||1},[m]),g=f.length*d;return e.length?(0,p.jsx)(`div`,{className:c,"data-testid":`resource-workload`,style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`auto`},children:(0,p.jsxs)(`div`,{style:{display:`flex`,minWidth:$e+g},children:[(0,p.jsxs)(`div`,{style:{width:$e,flexShrink:0},children:[(0,p.jsx)(`div`,{style:{height:28,display:`flex`,alignItems:`center`,padding:`0 12px`,fontSize:12,fontWeight:600,borderBottom:`1px solid hsl(var(--border))`},children:l(`gantt.resource.header`)}),m.map(e=>(0,p.jsxs)(`div`,{"data-testid":`resource-row-${e.key}`,style:{height:Qe,display:`flex`,flexDirection:`column`,justifyContent:`center`,padding:`0 12px`,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,p.jsx)(`span`,{style:{fontSize:13,fontWeight:500,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:e.label}),(0,p.jsxs)(`span`,{"data-testid":`resource-peak-${e.key}`,"data-overloaded":e.overloadedCount>0?`true`:void 0,style:{fontSize:10,color:e.overloadedCount>0?`hsl(var(--destructive))`:`hsl(var(--muted-foreground))`},children:[l(`gantt.resource.peak`),`: `,Math.round(e.peak*100)/100,` / `,e.capacity,e.overloadedCount>0?` · ${e.overloadedCount} ${l(`gantt.resource.over`)}`:``]})]},e.key))]}),(0,p.jsxs)(`div`,{style:{flex:1},children:[(0,p.jsx)(`div`,{style:{display:`flex`,height:28,borderBottom:`1px solid hsl(var(--border))`},children:f.map((e,t)=>(0,p.jsx)(`div`,{style:{width:d,flexShrink:0,textAlign:`center`,fontSize:10,color:`hsl(var(--muted-foreground))`,borderLeft:`1px solid hsl(var(--border) / 0.4)`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:e.label},t))}),m.map(e=>{let t=z*(1-Math.min(e.capacity/h,1));return(0,p.jsxs)(`div`,{style:{position:`relative`,display:`flex`,height:Qe,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,p.jsx)(`div`,{"aria-hidden":`true`,style:{position:`absolute`,left:0,right:0,top:7+t,borderTop:`1px dashed hsl(var(--muted-foreground) / 0.6)`,pointerEvents:`none`,zIndex:1}}),e.cells.map((t,n)=>{let r=Math.max(t.load>0?2:0,z*Math.min(t.load/h,1));return(0,p.jsx)(`div`,{"data-testid":`resource-cell-${e.key}-${n}`,"data-load":t.load,"data-overloaded":t.overloaded?`true`:void 0,title:`${f[n]?.date.toLocaleDateString(u)} — ${Math.round(t.load*100)/100} / ${t.capacity}`,style:{width:d,flexShrink:0,position:`relative`,borderLeft:`1px solid hsl(var(--border) / 0.4)`,display:`flex`,alignItems:`flex-end`,justifyContent:`center`,paddingBottom:7},children:t.load>0&&(0,p.jsx)(`div`,{style:{width:d-6,height:r,borderRadius:2,backgroundColor:t.overloaded?`hsl(var(--destructive))`:`hsl(var(--primary))`,opacity:t.overloaded?.9:.75}})},n)})]},e.key)})]})]})}):(0,p.jsx)(`div`,{className:c,"data-testid":`resource-workload`,children:(0,p.jsx)(`div`,{className:`flex items-center justify-center h-40 text-sm text-muted-foreground`,children:l(`gantt.resource.empty`)})})}var tt={display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8,padding:`8px 12px`,borderBottom:`1px solid hsl(var(--border))`,background:`hsl(var(--background))`,fontSize:13},nt={display:`inline-flex`,alignItems:`center`,gap:6,height:30,padding:`0 10px`,borderRadius:6,border:`1px solid hsl(var(--border))`,background:`hsl(var(--background))`,color:`hsl(var(--foreground))`,cursor:`pointer`,whiteSpace:`nowrap`,lineHeight:`28px`},rt={position:`absolute`,top:`calc(100% + 4px)`,left:0,zIndex:50,minWidth:200,maxHeight:320,overflowY:`auto`,padding:4,borderRadius:8,border:`1px solid hsl(var(--border))`,background:`hsl(var(--popover, var(--background)))`,color:`hsl(var(--popover-foreground, var(--foreground)))`,boxShadow:`0 8px 24px rgba(0,0,0,0.18)`},it={display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,borderRadius:6,cursor:`pointer`,userSelect:`none`};function V({checked:e}){return(0,p.jsx)(`span`,{"aria-hidden":!0,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:15,height:15,flex:`0 0 auto`,borderRadius:3,border:`1px solid ${e?`hsl(var(--primary))`:`hsl(var(--border))`}`,background:e?`hsl(var(--primary))`:`transparent`,color:`hsl(var(--primary-foreground, var(--background)))`,fontSize:11,lineHeight:1},children:e?`✓`:``})}function at({filter:e,selected:n,onChange:r,labels:i}){let[a,o]=(0,t.useState)(!1),s=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);let c=new Set(n),l=n.length,u=e.options.length>0&&l===e.options.length,d=t=>{let n=new Set(c);n.has(t)?n.delete(t):n.add(t),n.size===e.options.length?r([]):r([...n])},f=()=>{r(l>0?[]:e.options.map(e=>e.value))},m=l===0?e.label:l===1?`${e.label}: ${e.options.find(e=>e.value===n[0])?.label??n[0]}`:`${e.label} · ${l}`;return(0,p.jsxs)(`div`,{ref:s,style:{position:`relative`},"data-testid":`quick-filter-${e.field}`,children:[(0,p.jsxs)(`button`,{type:`button`,style:{...nt,borderColor:l>0?`hsl(var(--primary))`:`hsl(var(--border))`,color:l>0?`hsl(var(--primary))`:`hsl(var(--foreground))`},"aria-haspopup":`listbox`,"aria-expanded":a,"data-testid":`quick-filter-trigger-${e.field}`,onClick:()=>o(e=>!e),children:[(0,p.jsx)(`span`,{children:m}),(0,p.jsx)(`span`,{"aria-hidden":!0,style:{fontSize:10,opacity:.7},children:`▾`})]}),a&&(0,p.jsx)(`div`,{role:`listbox`,style:rt,"data-testid":`quick-filter-panel-${e.field}`,children:e.options.length===0?(0,p.jsx)(`div`,{style:{...it,cursor:`default`,opacity:.6},children:i.empty}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{role:`option`,"aria-selected":u,style:{...it,fontWeight:600},"data-testid":`quick-filter-all-${e.field}`,onClick:()=>f(),children:[(0,p.jsx)(V,{checked:u}),(0,p.jsx)(`span`,{children:i.all})]}),(0,p.jsx)(`div`,{style:{height:1,background:`hsl(var(--border))`,margin:`2px 0`}}),e.options.map(t=>{let n=c.has(t.value);return(0,p.jsxs)(`div`,{role:`option`,"aria-selected":n,style:{...it,background:n?`hsl(var(--accent, var(--muted)))`:`transparent`},"data-testid":`quick-filter-option-${e.field}-${t.value}`,onClick:()=>d(t.value),children:[(0,p.jsx)(V,{checked:n}),(0,p.jsx)(`span`,{children:t.label})]},t.value)})]})})]})}var ot=({filters:e,value:t,onChange:n,onClear:r,resultCount:i,totalCount:a,labels:o,className:s})=>{if(!e.length)return null;let c=o?.all??`All`,l=o?.empty??`No options`,u=o?.clear??`Clear`,d=e.some(e=>(t[e.field]?.length??0)>0);return(0,p.jsxs)(`div`,{style:tt,className:s,"data-testid":`quick-filter-bar`,children:[e.map(e=>(0,p.jsx)(at,{filter:e,selected:t[e.field]??[],onChange:t=>n(e.field,t),labels:{all:c,empty:l}},e.field)),d&&(0,p.jsx)(`button`,{type:`button`,style:{...nt,height:28,color:`hsl(var(--muted-foreground))`},"data-testid":`quick-filter-clear`,onClick:r,children:u}),o?.resultSummary&&i!=null&&a!=null&&(0,p.jsx)(`span`,{"data-testid":`quick-filter-summary`,style:{marginLeft:`auto`,color:`hsl(var(--muted-foreground))`},children:o.resultSummary(i,a)})]})};function st(e){if(e==null)return;let t=String(e).toLowerCase().trim();if(t===`milestone`)return`milestone`;if(t===`group`||t===`folder`)return`group`;if(t===`summary`||t===`project`||t===`phase`)return`summary`;if(t===`task`)return`task`}var ct={fs:`fs`,ss:`ss`,ff:`ff`,sf:`sf`,finish_to_start:`fs`,start_to_start:`ss`,finish_to_finish:`ff`,start_to_finish:`sf`,end_to_start:`fs`,end_to_end:`ff`,start_to_end:`sf`};function lt(e){if(e==null||e===``)return[];if(typeof e==`string`)return e.split(`,`).map(e=>e.trim()).filter(Boolean);if(typeof e==`number`)return[e];if(!Array.isArray(e))return[];let t=[];for(let n of e)if(n!=null&&n!==``){if(typeof n==`object`){let e=n.id??n._id??n.task??n.target;if(e==null||e===``)continue;let r=ct[String(n.type??``).toLowerCase().replace(/-/g,`_`)];t.push(r?{id:e,type:r}:{id:e})}else t.push(n)}return t}function ut(e){let t=e instanceof Error?e.message:String(e??``),n=t.indexOf(`{`);if(n>=0)try{let e=JSON.parse(t.slice(n)),r=e?.message??e?.error;if(typeof r==`string`&&r.trim())return r}catch{}return null}function H(e,t){let r=(0,n.toDisplayDate)(e);return typeof e==`string`&&(0,n.isRealCalendarDate)(e)?N(t,r):r}function dt(e,t){let r=(0,n.toDisplayEndDate)(e);if(typeof e!=`string`||!(0,n.isRealCalendarDate)(e))return r;let i=N(t,r);return t.to(i).getTime()===r.getTime()?i:N(t,new Date(r.getTime()-1))}function ft(e,t,r,i,a=`start`){if(!(typeof t==`string`?t===`date`:typeof r==`string`&&(0,n.isRealCalendarDate)(r)))return e.toISOString();let o=ge(i,e);return(0,n.toDateInputValue)(a===`end`?(0,n.toInclusiveEndDay)(o):o)}var pt=()=>globalThis.process?.env?.NODE_ENV!==`production`,mt=[...Object.keys(a.GanttConfigSchema.shape),`dependencyField`],U=new Set;function ht(e){if(!pt())return;let t=mt.filter(t=>e[t]!==void 0);if(t.length===0)return;let n=`${e.type??`gantt`}::${e.objectName??``}::${t.join(`,`)}`;U.has(n)||(U.add(n),console.warn(`[ObjectGantt] The \`gantt\` block configures this chart, so these top-level keys are IGNORED: ${t.map(e=>`\`${e}\``).join(`, `)}. The \`gantt\` block is the authoring shape; the flat top-level spelling is the internal form ObjectView/ListView produce when they flatten \`options.gantt\`, and what the author wrote outranks it. The block is taken WHOLE — the flat keys are not merged into it — so move anything you still need into \`gantt\`, or drop the \`gantt\` block. objectui#6469.`))}function gt(e){if(e.gantt){let t=e.gantt,n=a.GanttConfigSchema.safeParse(t);return n.success||console.warn(`[ObjectGantt] Invalid gantt configuration:`,n.error.format()),ht(e),t}return e.startDateField&&e.endDateField?{startDateField:e.startDateField,endDateField:e.endDateField,titleField:e.titleField||`name`,progressField:e.progressField,dependenciesField:e.dependenciesField||e.dependencyField,colorField:e.colorField,borderColorField:e.borderColorField,parentField:e.parentField,typeField:e.typeField,lockField:e.lockField,objectField:e.objectField,summaryExtent:e.summaryExtent,defaultCollapsedDepth:e.defaultCollapsedDepth,tooltipFields:e.tooltipFields,baselineStartField:e.baselineStartField,baselineEndField:e.baselineEndField,groupByField:e.groupByField,resourceView:e.resourceView,assigneeField:e.assigneeField,effortField:e.effortField,capacity:e.capacity,quickFilters:e.quickFilters,autoZoomToFilter:e.autoZoomToFilter,viewMode:e.viewMode,timeSegments:e.timeSegments,interactions:e.interactions,exportFileName:e.exportFileName,timeZone:e.timeZone,dependencyTypes:e.dependencyTypes}:null}var _t=({schema:e,dataSource:f,className:m,onTaskClick:h,onRowClick:g,onBeforeTaskUpdate:_,...v})=>{let[y,b]=(0,t.useState)([]),[ee,te]=(0,t.useState)(!0),[ne,re]=(0,t.useState)(null),[x,S]=(0,t.useState)(null),{currency:ie}=(0,s.useLocalization)(),C=(0,s.useDisplayLocale)(),{t:w}=ye(),T=(0,t.useCallback)(e=>{i.toast.error(w(`gantt.writeFailed`),{description:ut(e)??void 0})},[w]),E=(0,n.resolveRecordSourceConfig)(e,`view-data`),ae=JSON.stringify(E),D=(0,t.useMemo)(()=>E,[ae]),O=gt(e),oe=D?.provider,se=oe===`value`,ce=(0,t.useContext)(r.SchemaRendererContext)?.apiFetch,k=(0,t.useMemo)(()=>(0,n.resolveDataSource)(D,f??null,{fetch:ce}),[D,f,ce]),le=(0,t.useRef)(k);le.current=k;let ue=JSON.stringify(E?.provider===`api`?{provider:`api`,read:E.read,write:E.write}:E?.provider===`value`?{provider:`value`,items:E.items}:{provider:E?.provider??null}),A=(0,n.resolveRecordSourceObjectName)(e,D)??``,{ready:fe,def:j}=(0,r.useSettledSchema)(A,se?void 0:k),pe=(0,l.usePermissions)(),he=typeof e.search==`string`&&e.search!==``?e.search:void 0,M=he&&Array.isArray(e.searchableFields)&&e.searchableFields.length>0?e.searchableFields:void 0,N=M?JSON.stringify(M):``,[ge,_e]=(0,t.useState)(!1),ve=(0,r.useFilterScope)(),P=(0,r.useResolvedFilter)(e.filter,ve),be=(0,t.useRef)(0),xe=(0,t.useRef)(!1),Se=(0,t.useRef)(!1),Ce=v.data,F=Array.isArray(Ce)&&Ce.length>0?Ce:null,we=(0,t.useRef)(F);we.current=F;let Te=(0,t.useCallback)(async({silent:t=!1,inPlace:r=t}={})=>{let i=++be.current,a=()=>be.current===i,o=!t||Se.current;Se.current=o;try{r?_e(!0):te(!0);let t=we.current;if(t){a()&&(b(t),S(null),re(null),xe.current=!0);return}let i=le.current;if(!i||typeof i.find!=`function`)throw Error(`DataSource required for object/api providers`);let o=(0,n.buildExpandFields)(j?.fields),s=!pe?.isLoaded||!A?o:o.filter(e=>pe.checkField(A,e,`read`)),c=await i.find(A,{$filter:P,$orderby:(0,n.convertSortToQueryParams)(e.sort),...(0,n.nonGridRowCeilingQuery)(),...s.length>0?{$expand:s}:{},...he?{$search:he,...M?{$searchFields:M}:{}}:{}}),l=(0,n.applyNonGridRowCeiling)(c);a()&&(b(l.rows),S(l),re(null),xe.current=!0)}catch(e){o?a()&&re(e):console.error(`[ObjectGantt] Failed to refresh data:`,e)}finally{a()&&(Se.current=!1,_e(!1),te(!1))}},[ue,f,ce,A,se,oe,P,e.sort,he,N,j,pe]),Ee=F===null&&!se,De=(0,t.useRef)(Te);De.current=Te,(0,t.useEffect)(()=>{(!Ee||fe)&&De.current(xe.current?{inPlace:!0}:{})},[ue,f,ce,A,se,oe,P,e.sort,he,N,j,pe,Ee,fe]);let Oe=(0,r.useDataInvalidation)(Ee&&A?A:void 0),ke=(0,t.useRef)(0);(0,t.useEffect)(()=>{Oe!==ke.current&&(ke.current=Oe,(!Ee||fe)&&De.current({silent:!0}))},[Oe,Ee,fe]);let I=(0,t.useMemo)(()=>{if(!O||!y.length)return[];let{startDateField:e,endDateField:t,titleField:r,progressField:i,dependenciesField:a,colorField:c,borderColorField:l,parentField:u,typeField:f,lockField:p,tooltipFields:m,baselineStartField:h,baselineEndField:g,quickFilters:_}=O,v=j?.fields??{},b=me(O.timeZone),ee=(0,n.createFieldColorResolver)(v[c??``]),te=(0,n.createFieldColorResolver)(v[l??``]),ne=new Map;for(let e of _??[]){if(!e?.field||!Array.isArray(e.options)||!e.options.length)continue;let t=new Map;for(let n of e.options)typeof n==`string`?t.set(n,n):n&&n.value!=null&&t.set(String(n.value),n.label??String(n.value));t.size&&ne.set(e.field,t)}let re=(e,t)=>{if(!t)return;let n=t.split(`.`),r=e;for(let e of n){if(r==null)return;r=r[e]}return r},x=e=>{let t=[re(e,r),e?.account?.name,e?.opportunity?.name,e?.contact&&[e.contact.first_name,e.contact.last_name].filter(Boolean).join(` `)];for(let e of t)if(e!=null&&String(e).trim()!==``)return String(e);return(0,n.getRecordDisplayName)(j,e)},S=(e,t)=>{if(t)return t;let n=v[e]??v[e.split(`.`)[0]];return n?.label?n.label:(0,d.humanizeLabel)(e)},w=(e,t)=>{if(e==null||e===``)return`—`;let n=v[t]??v[t.split(`.`)[0]],r=n?.type,i=n?.options;if(Array.isArray(i)&&i.length){let t=i.find(t=>String(t.value)===String(e));if(t)return t.label}if(typeof e!=`object`){let n=ne.get(t)?.get(String(e));if(n!=null)return n}if(r==null&&typeof e==`string`){if(/^\d{4}-\d{2}-\d{2}$/.test(e))return(0,d.formatDate)(e,void 0,{locale:C});if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/.test(e)&&!isNaN(new Date(e).getTime()))return(0,d.formatDateTime)(e,{locale:C})}switch(r){case`date`:return(0,d.formatDate)(e,void 0,{locale:C});case`datetime`:return(0,d.formatDateTime)(e,{locale:C});case`number`:case`integer`:case`float`:case`decimal`:{let t=(0,o.resolveFieldScale)({type:n?.type,scale:n?.scale});return(0,s.formatDisplayNumber)(Number(e),t===void 0?{locale:C,minimumFractionDigits:0,maximumFractionDigits:20}:{locale:C,minimumFractionDigits:t,maximumFractionDigits:t})}case`currency`:return(0,d.formatCurrency)(Number(e),(0,s.resolveFieldCurrency)(n,ie),C);case`percent`:return(0,d.formatPercent)(Number(e),(0,d.percentCellScale)(n),(0,o.resolveFieldScale)({type:n?.type,scale:n?.scale}),C);case`boolean`:case`checkbox`:return e?`Yes`:`No`;default:if(Array.isArray(e)){let t=e.map(e=>{if(e==null)return``;if(typeof e==`object`){let t=e;return String(t.name??t.label??t.title??t.id??``)}return String(e)}).filter(Boolean);return t.length?t.join(`, `):`—`}if(typeof e==`object`){let t=e;return String(t.name??t.label??t.title??t.id??`—`)}return String(e)}},T=e=>{if(!m||!m.length)return;let t=[];for(let n of m){let r=typeof n==`string`?n:n?.field;if(!r)continue;let i=typeof n==`object`?n.label:void 0,a=re(e,r);a==null||a===``||Array.isArray(a)&&a.length===0||t.push({label:S(r,i),value:w(a,r)})}return t.length?t:void 0};return y.map((n,r)=>{let o=n[e],s=n[t],m=h?n[h]:void 0,_=g?n[g]:void 0,v=m?H(m,b):void 0,y=_?dt(_,b):void 0,ne=x(n),re=i?n[i]:0,S=a?n[a]:[],ie=c?n[c]:void 0,C=ee(ie);if(!C&&ie!=null&&ie!==``&&(C=(0,d.getSemanticHex)((0,d.getSemanticColorName)(String(ie),ie))),!C){let e=n.status??n.state??n.priority??n.severity;if(e!=null&&e!==``){let t=(0,d.getSemanticColorName)(void 0,e);t&&(C=(0,d.getSemanticHex)(t))}}let w=l?n[l]:void 0,E=w!=null&&w!==``?te(w)??(0,d.getSemanticHex)(String(w),String(w)):void 0;return{id:n.id||n._id||`task-${r}`,title:ne,start:o?H(o,b):new Date,end:s?dt(s,b):new Date,hasOwnDates:!!(o&&s),progress:Math.min(100,Math.max(0,re||0)),dependencies:lt(S),parent:u?n[u]??null:void 0,type:f?st(n[f]):void 0,locked:p?!!n[p]:void 0,color:C,borderColor:E,baselineStart:v&&!isNaN(v.getTime())?v:void 0,baselineEnd:y&&!isNaN(y.getTime())?y:void 0,fields:T(n),data:n}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[y,O,j,C,ie]),Ae=(0,t.useMemo)(()=>{let e=O?.groupByField;if(!e)return;let t=j?.fields??{},n=(e,t)=>{if(!t)return;let n=e;for(let e of t.split(`.`)){if(n==null)return;n=n[e]}return n},r=n=>{let r=(t[e]??t[e.split(`.`)[0]])?.options;if(Array.isArray(r)&&r.length){let e=r.find(e=>String(e.value)===String(n));if(e)return e.label}if(typeof n==`object`&&n){let e=n;return String(e.name??e.label??e.title??e.id??n)}return String(n)};return t=>{let i=n(t.data,e);return i==null||i===``?null:{key:typeof i==`object`&&i?String(i.id??i._id??r(i)):i,label:r(i)}}},[O?.groupByField,j]),je=(0,t.useMemo)(()=>{let e=O?.assigneeField;if(!e)return;let t=j?.fields??{},n=(e,t)=>{if(!t)return;let n=e;for(let e of t.split(`.`)){if(n==null)return;n=n[e]}return n},r=n=>{let r=(t[e]??t[e.split(`.`)[0]])?.options;if(Array.isArray(r)&&r.length){let e=r.find(e=>String(e.value)===String(n));if(e)return e.label}if(typeof n==`object`&&n){let e=n;return String(e.name??e.label??e.title??e.id??n)}return String(n)};return t=>{let i=n(t.data,e);return i==null||i===``?null:{key:typeof i==`object`&&i?String(i.id??i._id??r(i)):i,label:r(i)}}},[O?.assigneeField,j]),Me=(0,t.useMemo)(()=>{let e=O?.effortField;if(e)return t=>{let n=t.data?.[e],r=Number(n);return Number.isFinite(r)&&r>0?r:1}},[O?.effortField]),Ne=(0,t.useMemo)(()=>{let t=e.skipWeekends,n=e.holidays;if(t||n&&n.length!==0)return{skipWeekends:!!t,holidays:n&&n.length?new Set(n):void 0}},[e]),L=(0,t.useMemo)(()=>de(O?.timeSegments),[O?.timeSegments]),Pe=(0,t.useCallback)((e,t)=>{if(!e||!t)return null;let n=e;for(let e of t.split(`.`)){if(n==null)return null;n=n[e]}if(n==null||n===``)return null;if(typeof n==`object`){let e=n;return String(e.id??e._id??e.value??e.name??``)}return String(n)},[]),Fe=O?.quickFilters,[Ie,Le]=(0,t.useState)({});(0,t.useEffect)(()=>{if(!Fe?.length||!f||typeof f.find!=`function`)return;let e=j?.fields??{},t=!1;return(async()=>{let r={};for(let t of Fe){if(t.options)continue;let i=e[t.field]??e[t.field.split(`.`)[0]],a=i?.type;if(a!==`lookup`&&a!==`master_detail`)continue;let o=i?.reference;if(o)try{let e=await f.find(o,{$top:1e3}),i=(0,n.extractRecords)(e);r[t.field]=i.map(e=>({value:String(e.id??e._id??e.value??``),label:String(e.name??e.label??e.title??e.id??e._id??``)}))}catch(e){console.warn(`[ObjectGantt] Failed to load quick-filter options for "${t.field}":`,e)}}t||Le(e=>({...e,...r}))})(),()=>{t=!0}},[JSON.stringify(Fe),f,j]);let Re=(0,t.useMemo)(()=>{if(!Fe?.length)return[];let e=j?.fields??{};return Fe.map(t=>{let n=e[t.field]??e[t.field.split(`.`)[0]],r=t.label??n?.label??(0,d.humanizeLabel)(t.field),i;if(t.options?.length)i=t.options.map(e=>typeof e==`object`?{value:String(e.value),label:String(e.label??e.value)}:{value:String(e),label:String(e)});else if(Array.isArray(n?.options)&&n.options.length)i=n.options.map(e=>({value:String(e.value??e),label:String(e.label??e.value??e)}));else if(Ie[t.field]?.length)i=Ie[t.field];else{let e=new Map;for(let n of y){let r=Pe(n,t.field);if(r!=null&&!e.has(r)){let i=n;for(let e of t.field.split(`.`))i=i?.[e];let a=i&&typeof i==`object`?String(i.name??i.label??i.title??r):r;e.set(r,a)}}i=[...e.entries()].map(([e,t])=>({value:e,label:t}))}return{field:t.field,label:r,options:i}})},[Fe,j,Ie,y,Pe]),ze=e.persistLayout===!1?void 0:`${e.objectName||(D?.provider===`object`?D.object:``)||`gantt`}:${e.viewName||`default`}`,Be=ze?`gantt-layout:${ze}:filters`:null,[Ve,He]=(0,t.useState)(()=>{if(!Be||typeof window>`u`)return{};try{let e=JSON.parse(window.localStorage.getItem(Be)||`null`);if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Array.isArray(r)&&(t[n]=r.filter(e=>typeof e==`string`));return t}catch{return{}}}),Ue=(0,t.useCallback)(()=>{if(!(!Be||typeof window>`u`))try{window.localStorage.setItem(Be,JSON.stringify(Ve))}catch{}},[Be,Ve]),We=(0,t.useCallback)((e,t)=>{He(n=>({...n,[e]:t}))},[]),Ge=(0,t.useCallback)(()=>He({}),[]),Ke=(0,t.useCallback)(e=>!!O?.objectField&&!String(e?.[O.objectField]??``).trim(),[O?.objectField]),qe=(0,t.useCallback)(e=>{let t=(O?.objectField?String(e[O.objectField]??``).trim():``)||A,n=e.id??e._id;if(!t||n==null)return null;let r=A?(0,c.deriveRecordPageHref)(A,n):null;return{objectName:t,recordId:n,href:!A||t===A?r:r?.replace(`/${A}/record/`,`/${t}/record/`)??null}},[O?.objectField,A]),Je=(0,t.useMemo)(()=>{let e=Object.entries(Ve).filter(([,e])=>e.length>0);if(!e.length)return I;let t=new Map(I.map(e=>[String(e.id),e])),n=new Set;for(let r of I){if(!e.every(([e,t])=>{let n=Pe(r.data,e);return n!=null&&t.includes(n)}))continue;let i=r;for(;i&&!n.has(String(i.id));)n.add(String(i.id)),i=i.parent==null?void 0:t.get(String(i.parent))}return I.filter(e=>n.has(String(e.id)))},[I,Ve,Pe]),Ye=(0,t.useMemo)(()=>{if(O?.autoZoomToFilter!==!1||!I.length)return null;let e=1/0,t=-1/0;for(let n of I){let r=n.start.getTime(),i=n.end.getTime();e=Math.min(e,r),t=Math.max(t,i>r?i-1:r)}return{start:new Date(e),end:new Date(t)}},[I,O?.autoZoomToFilter]),Xe=e.navigation??{mode:`drawer`},Ze=Xe.mode===`drawer`||Xe.mode===`modal`||Xe.mode===`split`||Xe.mode===`popover`,Qe=(0,t.useCallback)((e,t)=>{if(typeof window>`u`)return;let n=String(e),r=I.find(e=>{let t=e.data;return!!t&&String(t.id??t._id)===n})?.data,i=r?qe(r)?.href??null:A?(0,c.deriveRecordPageHref)(A,e):null;if(i){if(t===`new_window`){window.open(i,`_blank`);return}window.history.pushState({},``,i),window.dispatchEvent(new PopStateEvent(`popstate`))}},[I,qe,A]),z=(0,r.useNavigationOverlay)({navigation:Xe,objectName:e.objectName,onNavigate:Qe,onRowClick:Ze?void 0:g}),{anchorRef:$e,anchorCaptureProps:B}=(0,u.useOverlayAnchor)(),[tt,nt]=(0,t.useState)(null),rt=z.isOverlay&&z.isOpen?z.selectedRecord:null;(0,t.useEffect)(()=>{if(!rt){nt(null);return}let e=qe(rt);if(!e){nt(null);return}let{objectName:t,recordId:n}=e;if(D?.provider!==`api`&&t===A||!f||typeof f.findOne!=`function`){nt(null);return}let r=`${t}:${n}`,i=!1;return(async()=>{try{let[e,a]=await Promise.all([f.findOne(t,String(n)),typeof f.getObjectSchema==`function`?f.getObjectSchema(t).catch(()=>null):Promise.resolve(null)]);i||nt(e?{key:r,record:e,schema:a}:null)}catch(e){console.error(`[ObjectGantt] Failed to fetch drawer record, falling back to row payload:`,e),i||nt(null)}})(),()=>{i=!0}},[rt,qe,D?.provider,A,f]);let it=(0,t.useCallback)(async(e,t)=>{if(!O||!k||typeof k.update!=`function`)return;let{startDateField:n,endDateField:r,titleField:i,progressField:a}=O,o=j?.fields,s=e.data??{},c=me(O.timeZone),l={};if(t.start instanceof Date&&(l[n]=ft(t.start,o?.[n]?.type,s[n],c)),t.end instanceof Date&&(l[r]=ft(t.end,o?.[r]?.type,s[r],c,`end`)),typeof t.title==`string`&&i&&(l[i]=t.title),typeof t.progress==`number`&&a&&(l[a]=t.progress),Object.keys(l).length===0)return;let u=e.data?.id??e.data?._id??e.id;if(u==null)return;let d=y;b(e=>e.map(e=>String(e.id??e._id)===String(u)?{...e,...l}:e));try{await k.update(A,String(u),l),Te({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist task update:`,e),b(d),T(e)}},[O,k,A,y,Te,T,j]),V=(e,t)=>{let n=t.some(e=>typeof e==`object`&&e.type&&e.type!==`fs`);return!n&&typeof e==`string`?t.map(e=>String(typeof e==`object`?e.id:e)).join(`,`):n?t.map(e=>typeof e==`object`?e.type&&e.type!==`fs`?{id:e.id,type:e.type}:e.id:e):t.map(e=>typeof e==`object`?e.id:e)},at=(0,t.useCallback)(async(e,t,n)=>{let r=O?.dependenciesField;if(!r||!k||typeof k.update!=`function`)return;let i=V(t,n),a=y;b(t=>t.map(t=>String(t.id??t._id)===String(e)?{...t,[r]:i}:t));try{await k.update(A,String(e),{[r]:i}),Te({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist dependency:`,e),b(a),T(e)}},[O,k,A,y,Te,T]),ct=(0,t.useCallback)(async(e,t,n=`fs`)=>{let r=e.data?.id??e.data?._id??e.id,i=t.data?.id??t.data?._id??t.id;if(r==null||i==null)return;let a=O?.dependenciesField;if(!a)return;let o=y.find(e=>String(e.id??e._id)===String(i))?.[a],s=lt(o),c=e=>String(typeof e==`object`?e.id:e),l=s.find(e=>c(e)===String(r)),u=l&&typeof l==`object`?l.type??`fs`:`fs`;if(l&&u===n)return;let d=n===`fs`?r:{id:r,type:n},f=l?s.map(e=>c(e)===String(r)?d:e):[...s,d];await at(i,o,f)},[O,y,at]),pt=(0,t.useCallback)(async(e,t)=>{let n=e.data?.id??e.data?._id??e.id,r=t.data?.id??t.data?._id??t.id;if(n==null||r==null)return;let i=O?.dependenciesField;if(!i)return;let a=y.find(e=>String(e.id??e._id)===String(r))?.[i],o=lt(a),s=e=>String(typeof e==`object`?e.id:e),c=o.filter(e=>s(e)!==String(n));c.length!==o.length&&await at(r,a,c)},[O,y,at]),[mt,U]=(0,t.useState)(null),[ht,_t]=(0,t.useState)(!1),W=(0,t.useCallback)(e=>{U(e)},[]),vt=(0,t.useCallback)(async()=>{if(!mt)return;if(!k?.delete){U(null);return}let e=mt.data?.id??mt.data?._id??mt.id;if(e==null){U(null);return}_t(!0);let t=y;b(t=>t.filter(t=>String(t.id??t._id)!==String(e)));try{if(await k.delete(A,String(e))===!1)throw Error(w(`gantt.writeFailed`));U(null),Te({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to delete:`,e),b(t),U(null),T(e)}finally{_t(!1)}},[mt,k,A,y,Te,T,w]);if(ee)return(0,p.jsx)(`div`,{className:m,children:(0,p.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,p.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading Gantt chart...`})})});if(ne)return(0,p.jsx)(`div`,{className:m,children:(0,p.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,p.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,ne.message]})})});if(!O)return(0,p.jsx)(`div`,{className:m,children:(0,p.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,p.jsx)(`div`,{className:`text-muted-foreground`,children:`Gantt configuration required. Please specify startDateField, endDateField, and titleField.`})})});let yt=t=>{if(!z.isOverlay||!z.isOpen||!z.selectedRecord)return null;let n=z.selectedRecord,r=qe(n);if(!r||Ke(n))return null;let{objectName:i,recordId:a}=r,o=r.href??void 0,s=O?.titleField?String(n[O.titleField]??w(`gantt.drawer.fallbackTitle`)):w(`gantt.drawer.fallbackTitle`),l=!!e.readOnly||(O?.lockField?!!n[O.lockField]:!1),d=tt?.key===`${i}:${a}`?tt:null,m=d?.record??n,h=d?.schema??(i===A?j:void 0),g=d&&f?f:k;return(0,p.jsx)(u.NavigationOverlay,{...z,title:s,mainContent:t,popoverAnchorRef:$e,storageKey:(0,u.recordOverlayWidthStorageKey)(i),legacyStorageKey:(0,u.legacyRecordDrawerWidthKey)(i),width:z.width??c.RECORD_OVERLAY_DEFAULT_WIDTH,children:()=>(0,p.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,p.jsx)(c.RecordDetailPanel,{record:m,objectName:i,recordId:a,dataSource:g??void 0,objectSchema:h,onClose:z.close,fullPageHref:o,onFieldSave:l?void 0:async(e,t)=>{if(g?.update){try{await g.update(i,String(a),{[e]:t})}catch(e){let t=ut(e);throw t?Error(t):e}d&&nt(n=>n&&n.key===d.key?{...n,record:{...n.record,[e]:t}}:n),b(n=>n.map(n=>String(n.id??n._id)===String(a)?{...n,[e]:t}:n)),Te({silent:!0})}},onDelete:l?void 0:async()=>{if(k?.delete){try{if(await k.delete(i,String(a))===!1)throw Error(w(`gantt.writeFailed`))}catch(e){throw T(e),e}b(e=>e.filter(e=>String(e.id??e._id)!==String(a)))}}})})})},bt=(0,p.jsxs)(`div`,{className:(0,u.cn)(`flex h-full min-h-0 flex-col`,m),...B,children:[Re.length>0&&(0,p.jsx)(ot,{filters:Re,value:Ve,onChange:We,onClear:Ge,resultCount:Je.length,totalCount:I.length,labels:{all:w(`gantt.quickFilter.all`),clear:w(`gantt.quickFilter.clear`),empty:w(`gantt.quickFilter.empty`),resultSummary:(e,t)=>w(`gantt.quickFilter.resultSummary`).replace(`{shown}`,String(e)).replace(`{total}`,String(t))}}),(0,p.jsxs)(`div`,{className:`relative flex-1 min-h-[420px]`,children:[(0,p.jsx)(u.RefreshIndicator,{active:ge,ariaLabel:w(`gantt.aria.refreshing`)}),O?.resourceView&&je?(0,p.jsx)(et,{tasks:Je,assignee:je,effort:Me,capacity:O?.capacity??1,viewMode:O?.viewMode||`day`}):(0,p.jsx)(R,{tasks:Je,viewMode:O?.viewMode,startDate:Ye?.start,endDate:Ye?.end,onTaskClick:e=>{Ke(e.data)||z.handleClick(e.data),h?.(e.data)},onTaskUpdate:it,onTaskDelete:W,onDependencyCreate:O?.dependenciesField?ct:void 0,onDependencyDelete:O?.dependenciesField?pt:void 0,markers:e.markers,autoSchedule:!!O?.dependenciesField,rescheduleOnConflict:!!O?.dependenciesField,criticalPathDefault:!!e.criticalPath,workingCalendar:Ne,shiftSegments:L,showBaselines:e.showBaselines!==!1,readOnly:!!e.readOnly,mobileReadOnly:e.mobileReadOnly!==!1,persistLayoutKey:ze,onLayoutChange:Be?Ue:void 0,groupBy:Ae,defaultCollapsedDepth:O?.defaultCollapsedDepth,summaryExtent:O?.summaryExtent,interactions:O?.interactions,dependencyTypes:O?.dependencyTypes,timeZone:O?.timeZone,onBeforeTaskUpdate:_,exportFileName:String(O?.exportFileName??(0,a.resolveI18nLabel)(e.label,C)??j?.label??e.objectName??``)||void 0,inlineEdit:!0,onRefresh:(D?.provider===`object`||D?.provider===`api`)&&typeof k?.find==`function`?()=>Te({silent:!0}):void 0,refreshing:ge})]}),x&&(0,p.jsx)(r.NonGridRowCeilingNote,{result:x}),(0,p.jsx)(u.AlertDialog,{open:!!mt,onOpenChange:e=>{!e&&!ht&&U(null)},children:(0,p.jsxs)(u.AlertDialogContent,{children:[(0,p.jsxs)(u.AlertDialogHeader,{children:[(0,p.jsx)(u.AlertDialogTitle,{children:w(`gantt.delete.title`)}),(0,p.jsx)(u.AlertDialogDescription,{children:mt?w(`gantt.delete.body`,{title:mt.title}):null})]}),(0,p.jsxs)(u.AlertDialogFooter,{children:[(0,p.jsx)(u.AlertDialogCancel,{disabled:ht,children:w(`gantt.delete.cancel`)}),(0,p.jsx)(u.AlertDialogAction,{onClick:e=>{e.preventDefault(),vt()},disabled:ht,"data-testid":`gantt-delete-confirm`,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:w(ht?`gantt.delete.deleting`:`gantt.delete.confirm`)})]})]})})]});if(z.isOverlay&&z.mode===`split`&&z.isOpen&&z.selectedRecord){let e=yt(bt);if(e)return(0,p.jsx)(p.Fragment,{children:e})}return(0,p.jsxs)(p.Fragment,{children:[bt,yt()]})},W={filter:!0,sort:!0},vt=(0,n.elementDataSourceBlock)(({schema:e})=>{let{dataSource:t}=(0,r.useSchemaContext)()||{},n=t??void 0;return(0,p.jsx)(r.ElementDataSourceGate,{schema:e,mapping:W,dataSource:n,testId:`object-gantt`,errorTitle:`This gantt chart’s data source could not be resolved`,children:e=>(0,p.jsx)(_t,{schema:e,dataSource:n})})});n.ComponentRegistry.register(`object-gantt`,vt,{namespace:`plugin-gantt`,label:`Object Gantt`,category:`view`,inputs:[{name:`objectName`,type:`string`,description:"ObjectQL object name. The record source is one of `data`, `staticData` and `objectName`; the `object-gantt` schema refuses a block that declares none of them, unless the node's `dataSource.object` names the object, which then lands on this key."},{name:`gantt`,type:`object`,description:"Gantt-timeline configuration, the author face — the same block `ListViewSchema.gantt` declares, and the one the renderer validates this node against. Taken WHOLE when present: the flat top-level spelling beside it is ignored. The spec requires `startDateField`, `endDateField` and `titleField`, which name the record fields a task's bar starts at, ends at and is titled by; the other members (`progressField`, `colorField`, `dependenciesField`, `parentField`, `viewMode`, `exportFileName`, …) are optional."},{name:`data`,type:`object`,description:"A `{ provider, … }` data-source configuration, read FIRST on the record-source ladder: a gantt carrying one never reaches `staticData` and never queries `objectName`. `{ provider: 'value', items }` charts those rows, `{ provider: 'object', object }` queries that object and `{ provider: 'api', read }` reads through that request. A bare array is not this key’s shape and is not a record source: the gantt falls through to `staticData`, then `objectName`, so inline rows belong under `staticData`."},{name:`staticData`,type:`array`,description:"Inline records, read SECOND on the record-source ladder: a `data` configuration wins and this key is then never reached, while `objectName` is read AFTER it, so a gantt carrying both charts these rows and never queries that object. `filter` and `sort` narrow and order these rows exactly as they do fetched ones."},{name:`filter`,type:`array`,description:"Base query filter in the rule-array form `[{ field, operator, value }, ...]`, narrowing the tasks the gantt charts — from every record source it reads: the object, an `api` request, or inline rows. Context tokens such as `{current_user_id}` are resolved first, then the filter is lowered to `$filter` on the query. The MongoDB-style record form is not this key’s shape."},{name:`sort`,type:`array`,description:"Task order in `[{ field, order }]` form, ordering the rows the gantt charts. Lowered to `$orderby` on the same query."},{name:`navigation`,type:`object`,description:"What a task click opens — the `{ mode, size, openNewTab, preventNavigation }` block a list view declares. With the key ABSENT a click opens the task's record in a drawer, this renderer's own default. `mode` is an overlay (`drawer`, `modal`, `split`, `popover`), `new_window`, `page` or `none`, and a block written without `mode` takes the spec's `page` default. `drawer`, `modal` and `popover` open the task's record in that overlay, and `split` opens it beside the chart, which stays drawn; `none` opens nothing. `page` opens the task's record page in the same tab and `new_window` opens it in a new tab. The gantt builds that address itself from the page it is on and does not use a record navigator the host publishes, so a host that publishes one changes nothing: on the object's own list or view route (`…/OBJECT/view/VIEW`) the address is the record page `…/OBJECT/record/ID`, while on any other page, such as a custom page, `/OBJECT/record/ID` is appended to the current address. The object is `data.object` when `data` is the object provider, else `objectName`; on inline rows that name neither there is no record to open, and every mode, the default drawer included, opens nothing. `preventNavigation: true` opens nothing whatever the mode, `openNewTab: true` opens the record page in a new tab and outranks every mode except `none`, and `size` sets the overlay width."},{name:`label`,type:[`string`,`object`],description:'Gantt label — the second link of the exported PNG/PDF file-name chain, after `gantt.exportFileName` and before the bound object\'s own label. A string is used as written, and an inline locale map (`{ en, "zh-CN", … }`) gives the entry for the display locale. The chart draws it nowhere else.'},{name:`skipWeekends`,type:`boolean`,description:`Measure duration and auto-schedule math in WORKING days, skipping Saturdays and Sundays. The day view also folds the Saturday and Sunday columns out of its axis.`},{name:`holidays`,type:`array`,of:`string`,description:"Additional non-working dates for the working calendar, ISO `yyyy-mm-dd` strings; folded into a Set for the duration math. A non-empty list turns the working calendar on by itself, without `skipWeekends`, and the day view folds each listed date's column out of its axis."},{name:`persistLayout`,type:`boolean`,description:"Opt OUT of layout and filter-chip persistence — only an explicit `false` disables it; the storage key is `objectName:viewName`. The object half is `objectName`, else `data.object`, and `gantt` on inline rows that name neither. With `false` the toolbar has no save-layout button and nothing is stored."},{name:`viewName`,type:`string`,description:"Layout-persistence scope, the second half of the `objectName:viewName` storage key (renderer default `'default'`). Two gantts on the same object with different names keep separate saved layouts, and a gantt restores only the layout saved under its own name."},{name:`markers`,type:`array`,description:"Extra vertical reference lines drawn like the Today marker ({ date, label?, color? }). `date` places the line, and a date outside the chart's range draws none; `label` is the text drawn against it; `color` is its CSS colour, the theme's primary colour when omitted."},{name:`criticalPath`,type:`boolean`,description:`Seed the critical-path highlight ON; the toolbar toggle stays available either way`},{name:`showBaselines`,type:`boolean`,description:"Render the planned-vs-actual baseline bars — ON unless an explicit `false` disables it. A task draws one only when `gantt.baselineStartField` and `gantt.baselineEndField` give it both baseline dates."},{name:`readOnly`,type:`boolean`,description:`Disable every write path on this gantt and lock the record drawer. A task click still opens the record, read-only.`},{name:`mobileReadOnly`,type:`boolean`,description:"Auto read-only on narrow viewports — ON unless an explicit `false` disables it. Narrow is under 640px: the chart's own width once it is measured, the viewport's until then. A narrow chart's own write paths are gated as under `readOnly`, read-only badge included, but the record drawer is locked by `readOnly` alone, so a task's record still opens writable. `false` keeps a narrow chart editable, and `readOnly: true` locks the chart and the drawer at any width."}]}),e.GanttView=R,e.ObjectGantt=_t,e.ObjectGanttRenderer=vt,e.QuickFilterBar=ot,e.ResourceWorkload=et,e.bandAt=j,e.computeWorkload=Xe,e.normalizeDependencies=lt,e.normalizeShiftSegments=de,e.normalizeTaskType=st,e.parseHHMM=A,e.shiftDayStart=fe});