@object-ui/plugin-gantt 17.6.0 → 18.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3524 -0
- package/README.md +425 -155
- package/dist/GanttView.d.ts +26 -21
- package/dist/GanttView.d.ts.map +1 -1
- package/dist/ObjectGantt.d.ts +192 -4
- package/dist/ObjectGantt.d.ts.map +1 -1
- package/dist/ResourceWorkload.d.ts +1 -1
- package/dist/ResourceWorkload.d.ts.map +1 -1
- package/dist/index.d.ts +55 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1987 -1722
- package/dist/index.umd.cjs +3 -4
- package/dist/scheduling.d.ts +10 -2
- package/dist/scheduling.d.ts.map +1 -1
- package/dist/tzShift.d.ts +55 -0
- package/dist/tzShift.d.ts.map +1 -0
- package/dist/useGanttTranslation.d.ts.map +1 -1
- package/package.json +16 -13
package/dist/index.umd.cjs
CHANGED
|
@@ -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("@object-ui/i18n"),require("sonner"),require("@objectstack/spec/ui"),require("@objectstack/spec/data"),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`,`@object-ui/i18n`,`sonner`,`@objectstack/spec/ui`,`@objectstack/spec/data`,`@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._object_ui_i18n,e.sonner,e._objectstack_spec_ui,e._objectstack_spec_data,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 x(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 S(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function C(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function re(e,t){let n=S(e);for(;!x(n,t);)n=C(n,1);return n.getTime()}function w(e,t,n){if(t<=e)return 0;let r=0,i=S(e),a=S(t).getTime();for(;i.getTime()<a;)x(i,n)&&r++,i=C(i,1);return r}function T(e,t,n){if(t<=0)return S(e).getTime();let r=S(e),i=t;for(;i>0;)x(r,n)&&i--,r=C(r,1);return r.getTime()}function E(e,t,n){if(t<=0)return S(e).getTime();let r=S(e),i=t;for(;i>0;)r=C(r,-1),x(r,n)&&i--;return r.getTime()}var D=e=>String(e);function ie(e){return e===`ss`||e===`ff`||e===`sf`?e:`fs`}function O(e){let t=new Set(e.map(e=>D(e.id))),n=[];for(let r of e){let e=D(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=D(a);o!==e&&t.has(o)&&n.push({pred:o,succ:e,type:ie(r?i.type:void 0)})}}return n}function k(e){let t=new Set;for(let n of e)n.parent!=null&&n.parent!==``&&t.add(D(n.parent));return t}function ae(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 oe(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?w(n.start.getTime(),n.end.getTime(),t):(n.end.getTime()-n.start.getTime())/ee;r.set(D(n.id),Number.isFinite(e)&&e>0?e:0)}let i=O(e),a=e.map(e=>D(e.id)),{order:o,hasCycle:s}=ae(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 A(e,t,n){if(!e.length)return{changes:[],skippedLocked:[]};let r=O(e),i=e.map(e=>D(e.id)),{order:a,hasCycle:o}=ae(i,r);if(o)return{changes:[],skippedLocked:[]};let s=k(e),c=new Map;for(let t of e)c.set(D(t.id),t);let l=new Map;for(let t of e){if(t.parent==null||t.parent===``)continue;let e=D(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(D(t.id),t.start.getTime()),m.set(D(t.id),t.end.getTime());let h=[];for(let e of a){let r=c.get(e);if(!r)continue;let i=t?w(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?E(r,i,t):r-i;break;case`sf`:a=t?E(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=re(o,t);p.set(e,n),m.set(e,T(n,i,t))}else p.set(e,o),m.set(e,o+i)}}if(u)for(let t of e){let e=D(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=D(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=D(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 se(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 ce=6e4;1440*ce;var j=1440;function le(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 ue(e){if(!e||!Array.isArray(e.bands)||e.bands.length===0)return null;let t=le(e.dayStart)??0,n=[];for(let t=0;t<e.bands.length;t++){let r=e.bands[t],i=le(r.start),a=le(r.end);if(i==null||a==null||!r.label)return null;let o=(a-i+j)%j||j;n.push({key:r.key??`band${t}`,label:r.label,color:r.color,durMs:o*ce})}return{dayStartMin:t,bands:n,showMidnight:e.showMidnight!==!1}}function M(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 de(e,t){if(t.bands.length===0)return null;let n=M(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 fe(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 pe(e){let t={delta:0,to:e=>e,from:e=>e,now:()=>new Date};if(!e)return t;try{fe(e,new Date)}catch{return console.warn(`[GanttView] invalid timeZone "${e}" — falling back to the browser zone`),t}let n=t=>fe(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 me=18e5;function N(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*me;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 P(e,t){return e.delta===0?t:N(e.to,t,`any`)}function he(e,t){return e.delta===0?t:N(e.from,t,`latest`)}var ge={"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`},_e=new Intl.PluralRules(`en`);function F(e,t){let n=t?.count,r=(typeof n==`number`&&Number.isFinite(n)?ge[`${e}_${_e.select(n)}`]:void 0)||ge[e]||e;if(t)for(let[e,n]of Object.entries(t))r=r.split(`{{${e}}}`).join(String(n));return r}function ve(){let e=(0,r.useObjectTranslation)();return{t:(t,n)=>{let r=e.t(t,n);return typeof r==`string`&&r!==t?r:F(t,n)},language:e.language}}var ye=8;function be(e,t){if(t.width<=0)return`move`;let n=Math.min(ye,t.width/3),r=e-t.left;return r<=n?`resize-left`:r>=t.width-n?`resize-right`:`move`}var xe=110,Se=160,Ce=.375,we=320,I=560;function Te(e){return e<640?140:e<1024?220:Math.round(Math.min(I,Math.max(we,e*Ce)))}var Ee=412;function De(e){return e>=Ee}function Oe(e){return e<640?32:40}var ke=[`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 M(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=>({"&":`&`,"<":`<`,">":`>`,'"':`"`})[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&&ke.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 Ye({tasks:e,viewMode:r,startDate:o,endDate:s,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:x=!1,workingCalendar:S,shiftSegments:C,showBaselines:re=!0,readOnly:w=!1,mobileReadOnly:T=!1,groupBy:E,ungroupedLabel:D=`Ungrouped`,defaultCollapsedDepth:ie,summaryExtent:O=`children`,persistLayoutKey:k,onLayoutChange:ae,onRefresh:ce,refreshing:j=!1,dependencyTypes:le=!0,timeZone:ue,exportFileName:de,interactions:fe,onBeforeTaskUpdate:me}){let N=t.useMemo(()=>pe(ue),[ue]),P=t.useMemo(()=>N.delta===0?e:e.map(e=>({...e,start:N.to(e.start),end:N.to(e.end),baselineStart:e.baselineStart?N.to(e.baselineStart):e.baselineStart,baselineEnd:e.baselineEnd?N.to(e.baselineEnd):e.baselineEnd})),[e,N]),he=t.useMemo(()=>o&&N.delta!==0?N.to(o):o,[o,N]),ge=t.useMemo(()=>s&&N.delta!==0?N.to(s):s,[s,N]),_e=t.useMemo(()=>!c||N.delta===0?c:c.map(e=>typeof e.date==`string`&&(0,n.isRealCalendarDate)(e.date)?{...e,date:(0,n.toDisplayDate)(e.date)}:{...e,date:N.to((0,n.toDisplayDate)(e.date))}),[c,N]),{t:F}=ve(),Ce=(0,i.useDisplayLocale)(),we=N.now().getFullYear(),I=(e,t)=>e.toLocaleDateString(Ce,e.getFullYear()===we?{month:t,day:`numeric`}:{month:t,day:`numeric`,year:t===`numeric`?`2-digit`:`numeric`}),Ee=t.useRef(null),{width:Ke}=(0,u.useResizeObserver)(Ee),Ye=Ke||(typeof window<`u`?window.innerWidth:1024),Xe=Ye<640,R=w||T&&Xe,Ze=fe?.move!==!1,z=fe?.resize!==!1,Qe=fe?.progress!==!1,$e=fe?.link!==!1,B=t.useMemo(()=>{if(!R&&d)return N.delta===0?d:(e,t)=>{let n={...t};n.start instanceof Date&&(n.start=N.from(n.start)),n.end instanceof Date&&(n.end=N.from(n.end)),d(e,n)}},[R,d,N]),et=R?void 0:m,V=R||!$e?void 0:g,tt=R||!$e?void 0:v,nt=R?void 0:y,rt=!R&&ee,it=!R&&te,at=!R&&ne,H=Oe(Ye),ot=t.useRef(void 0);ot.current===void 0&&(ot.current=qe(k));let st=ot.current,[ct,lt]=t.useState(st?st.columnWidth:null),[ut,dt]=t.useState(st?st.taskListWidth??null:null),[U,ft]=t.useState(r&&ke.includes(r)?r:st?.viewMode??`day`);t.useEffect(()=>{r&&ke.includes(r)&&ft(r)},[r]);let pt=t.useRef(null),mt=t.useRef(null),ht=t.useRef(!0),[gt,_t]=t.useState(st?st.taskListCollapsed:!1),vt=t.useRef(!1);t.useEffect(()=>{!vt.current&&Xe&&(_t(!0),vt.current=!0)},[Xe]);let yt=Math.max(Se,Ye-200),W=gt?0:ut==null?Te(Ye):Math.max(Se,Math.min(ut,yt)),bt=t.useMemo(()=>{if(ct!=null||ge||P.length===0)return null;let e=he?new Date(he):new Date(Math.min(...P.map(e=>e.start.getTime()))),t=new Date(Math.max(...P.map(e=>e.end.getTime())));he||e.setDate(e.getDate()-7),t.setDate(t.getDate()+14),e=Me(e,U),t.setHours(23,59,59,999);let n=Math.max(1,(t.getTime()-e.getTime())/je),r=Math.max(0,Ye-W);if(r<=0)return null;let i=r/n*Ae[U];if(i<=xe)return null;let a=Math.min(i,r*.6);return a>xe?a:null},[ct,P,he,ge,U,Ye,W]),xt=ct??bt??xe,St=xt/Ae[U],Ct=De(W),[wt,Tt]=t.useState(null),[Et,Dt]=t.useState({}),[Ot,kt]=t.useState(null),At=t.useMemo(()=>{if(!E)return P;let e=new Set;for(let t of P){let n=t.parent!=null&&t.parent!==``?String(t.parent):null;n&&e.add(n)}let t=new Map;for(let n of P){if(e.has(String(n.id)))continue;let r=E(n),i=r?String(r.key):`__ungrouped__`,a=r?r.label:D,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},[E,P,D]),jt=t.useMemo(()=>{let e=new Set(At.map(e=>String(e.id))),t=new Map;for(let n of At){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},[At]),Mt=t.useMemo(()=>{let e=new Map;for(let t of At)e.set(String(t.id),t);return e},[At]),Nt=t.useCallback(e=>{let t=[],n=new Set,r=e=>{for(let i of jt.get(e)??[]){let e=String(i.id);n.has(e)||(n.add(e),t.push(i),r(e))}};return r(String(e)),t},[jt]),[G,Pt]=t.useState(null),Ft=t.useRef(null);t.useEffect(()=>{Ft.current=G},[G]);let It=t.useRef(!1),Lt=t.useCallback(e=>{let t=U===`day`&&!!C&&C.bands.length>0,n=(e,t)=>Wn.current?Wn.current(e,t):L(e,t,`day`),r=new Date(e.originStart),i=new Date(e.originEnd);if(t&&C){let t=Math.min(...C.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}},[U,C]),Rt=e=>{let t=Lt(e);return Ie(t.start,t.end)},zt=t.useRef(P);zt.current=P;let Bt=t.useRef([]),Vt=t.useRef([]),[Ht,Ut]=t.useState(0),Wt=t.useCallback(e=>{if(!B)return;let t=e.filter(e=>!e.task.locked);(async()=>{let e=t;if(me){let n=[];for(let e of t){let t;try{t=await me(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)}B(t,r),a&&n.push({taskId:String(t.id),before:e,after:i})}n.length&&(Bt.current.push(n),Vt.current=[],Ut(e=>e+1))})()},[B,me]),[Gt,Kt]=t.useState(null),qt=t.useCallback(e=>{if(!C)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+C.dayStartMin*6e4;for(let t of C.bands){if(r>=e)return r;r+=t.durMs}}return e},[C]),Jt=t.useMemo(()=>({summaryExtent:O,snapStart:C?qt:void 0}),[O,C,qt]),Yt=t.useCallback(e=>{if(!at)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}=A(zt.current.map(e=>{let n=t.get(String(e.id));return n?{...e,start:n.start,end:n.end}:e}),S,Jt),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&&Kt(r)},[at,S,Jt]),Xt=t.useCallback(()=>{if(!Gt)return;let e=Gt.map(e=>{let t=zt.current.find(t=>String(t.id)===e.id);return t?{task:t,changes:{start:e.start,end:e.end}}:null}).filter(Boolean);e.length&&Wt(e),Kt(null)},[Gt,Wt]),Zt=t.useCallback((e,t)=>{if(B)for(let n of e){let e=zt.current.find(e=>String(e.id)===n.taskId);e&&B(e,t===`undo`?n.before:n.after)}},[B]),Qt=t.useCallback(()=>{let e=Bt.current.pop();e&&(Zt(e,`undo`),Vt.current.push(e),Ut(e=>e+1))},[Zt]),$t=t.useCallback(()=>{let e=Vt.current.pop();e&&(Zt(e,`redo`),Bt.current.push(e),Ut(e=>e+1))},[Zt]),{canUndo:en,canRedo:tn}=t.useMemo(()=>({canUndo:Bt.current.length>0,canRedo:Vt.current.length>0}),[Ht]);t.useEffect(()=>{if(!G)return;let e=U===`day`&&!!C&&C.bands.length>0,t=e&&C?St*Math.min(...C.bands.map(e=>e.durMs))/je:St,n=e=>{let n=Ft.current;if(!n)return;let r=Math.round((e.clientX-n.originClientX)/Math.max(t,1));r!==n.unitDelta&&Pt({...n,unitDelta:r})},r=()=>{let t=Ft.current;if(t){if(t.unitDelta!==0){let n=P.find(e=>e.id===t.taskId);if(n&&B){let{start:r,end:i}=Lt(t);if(t.group){let i=Fe(t.originStart,r,e),a=[n,...Nt(n.id).filter(e=>!e.locked)].map(e=>({task:e,changes:{start:i(e.start),end:i(e.end)}}));Wt(a),Yt(a)}else{let e=[{task:n,changes:{start:r,end:i}}];Wt(e),Yt(e)}}It.current=!0,window.setTimeout(()=>{It.current=!1},0)}Pt(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,xt,St,U,C,P,B,Lt,Nt,Wt,Yt]);let nn=t.useCallback((e,t,n,r)=>{!B||e.data?.__group||e.locked||(n.stopPropagation(),n.preventDefault(),Pt({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}))},[B]),[rn,an]=t.useState(null),on=t.useRef(null);t.useEffect(()=>{on.current=rn},[rn]),t.useEffect(()=>{if(!rn)return;let e=e=>{let t=on.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&&an({...t,value:n})},t=()=>{let e=on.current;if(e){if(e.value!==e.originProgress){let t=P.find(t=>t.id===e.taskId);t&&B&&Wt([{task:t,changes:{progress:e.value}}]),It.current=!0,window.setTimeout(()=>{It.current=!1},0)}an(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)}},[rn,P,B,Wt]);let sn=t.useMemo(()=>{let e=[];for(let t of P)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},[P]),cn=t.useCallback((e,t)=>String(t.id)===String(e)?`self`:t.locked?`locked`:t.type===`group`?`group`:se(sn,e,t.id)?`cycle`:null,[sn]),ln=t.useCallback((e,t)=>cn(e,t)===null,[cn]),un=t.useRef(null),[K,dn]=t.useState(null),fn=t.useRef(null);t.useEffect(()=>{fn.current=K},[K]),t.useEffect(()=>{if(!K)return;let e=e=>{let t=un.current?.getBoundingClientRect();if(!t)return;let n=e.clientX-t.left,r=e.clientY-t.top;dn(e=>e&&{...e,x:n,y:r})},t=()=>{let e=fn.current;if(e&&e.targetId!=null&&V){let t=P.find(t=>String(t.id)===String(e.sourceId)),n=P.find(t=>String(t.id)===String(e.targetId)),r=e.targetEnd??`start`,i=le?`${e.sourceEnd===`end`?`f`:`s`}${r===`end`?`f`:`s`}`:`fs`;t&&n&&ln(e.sourceId,n)&&(_?.(t,n,i)??!0)&&V(t,n,i)}else e&&e.rejectedReason&&V&&a.toast.error(F(`gantt.link.rejected.${e.rejectedReason}`));It.current=!0,window.setTimeout(()=>{It.current=!1},0),dn(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,P,V,_,ln,le,F]);let[pn,mn]=t.useState(null),hn=t.useRef(null);t.useEffect(()=>{if(!pn)return;let e=e=>{hn.current&&e.target instanceof Node&&hn.current.contains(e.target)||mn(null)},t=e=>{e.key===`Escape`&&mn(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[pn]);let[gn,_n]=t.useState(null),vn=t.useRef(null);t.useEffect(()=>{if(!gn)return;let e=e=>{vn.current&&e.target instanceof Node&&vn.current.contains(e.target)||_n(null)},t=e=>{e.key===`Escape`&&_n(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[gn]);let[yn,bn]=t.useState(null),[xn,Sn]=t.useState(``),Cn=t.useRef(null);t.useEffect(()=>{if(!yn)return;let e=e=>{Cn.current&&e.target instanceof Node&&Cn.current.contains(e.target)||bn(null)},t=e=>{e.key===`Escape`&&bn(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[yn]);let[wn,Tn]=t.useState(null),En=!!(l||B||V||et),Dn=t.useCallback((e,t)=>{t.preventDefault(),t.stopPropagation(),Tn(e.id),En&&mn({x:t.clientX,y:t.clientY,taskId:e.id})},[En]),On=t.useCallback((e,t,n,r)=>{r.preventDefault(),r.stopPropagation(),(V||tt)&&_n({x:r.clientX,y:r.clientY,sourceId:e,targetId:t,type:n})},[V,tt]),[kn,An]=t.useState(()=>new Set(st?.collapsedIds??[])),jn=t.useCallback(e=>{An(t=>{let n=new Set(t),r=String(e);return n.has(r)?n.delete(r):n.add(r),n})},[]),Mn=t.useRef(st?.collapsedIds!=null);t.useEffect(()=>{if(Mn.current||ie==null||At.length===0)return;Mn.current=!0;let e=new Map(At.map(e=>[String(e.id),e])),t=new Set;for(let n of At){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 At){let i=String(e.id);t.has(i)&&n(e)>=ie&&r.add(i)}r.size&&An(e=>e.size?e:r)},[ie,At]);let q=t.useMemo(()=>{let e=new Set(At.map(e=>String(e.id))),t=new Map,n=[];for(let r of At){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&&O===`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(kn.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 At)o.has(String(e.id))||c(e,0);return a},[At,kn,O]),Nn=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?$t():Qt();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`Y`)){e.preventDefault(),$t();return}if(!q.length)return;let t=wn==null?-1:q.findIndex(e=>String(e.task.id)===String(wn));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);Tn(q[n].task.id);let r=Q.current;if(r){let e=n*H;e<r.scrollTop?r.scrollTop=e:e+H>r.scrollTop+r.clientHeight&&(r.scrollTop=e+H-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`?et&&(e.preventDefault(),et(n.task)):(e.key===`ArrowRight`&&n.hasChildren&&kn.has(String(n.task.id))||e.key===`ArrowLeft`&&n.hasChildren&&!kn.has(String(n.task.id)))&&(e.preventDefault(),jn(n.task.id))},[q,wn,l,et,kn,jn,H,Qt,$t]),J=t.useMemo(()=>{let e=he?new Date(he):N.now(),t=ge?new Date(ge):N.now();return!he&&P.length>0&&(e=new Date(Math.min(...P.map(e=>e.start.getTime()))),e.setDate(e.getDate()-7)),!ge&&P.length>0&&(t=new Date(Math.max(...P.map(e=>e.end.getTime()))),t.setDate(t.getDate()+14)),e=U===`day`&&C&&C.bands.length>0?M(e,C.dayStartMin):Me(e,U),t.setHours(23,59,59,999),{start:e,end:t}},[he,ge,P,U,C,N]),Pn=U===`day`&&!!C&&C.bands.length>0,Fn=!Pn&&U===`day`&&!!S&&(!!S.skipWeekends||!!(S.holidays&&S.holidays.size)),In=t.useCallback(e=>{if(!S)return!0;if(S.skipWeekends){let t=e.getDay();if(t===0||t===6)return!1}if(S.holidays&&S.holidays.size){let t=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;if(S.holidays.has(t))return!1}return!0},[S]),Y=t.useMemo(()=>{let e=[];if(Pn&&C){let t=new Date(J.start);for(;t<=J.end;)for(let n of C.bands){let r=n.durMs/je*St;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,U);if(Fn&&!In(t)){t=n;continue}let r=(n.getTime()-t.getTime())/je*St,i,a;U===`day`?(i=String(t.getDate()),a=t.toLocaleDateString(Ce,{weekday:`narrow`})):i=U===`week`?t.toLocaleDateString(Ce,{month:`numeric`,day:`numeric`}):U===`month`?t.toLocaleDateString(Ce,{month:`short`}):U===`quarter`?`Q${Math.floor(t.getMonth()/3)+1}`:String(t.getFullYear()),e.push({date:new Date(t),label:i,sublabel:a,isWeekend:U===`day`&&(t.getDay()===0||t.getDay()===6),width:r}),t=n}return e},[J,U,St,Ce,Fn,In,Pn,C]),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]),Ln=X[X.length-1],Rn=t.useMemo(()=>Y.map(e=>e.date.getTime()),[Y]),zn=t.useMemo(()=>Y.map(e=>e.realMs==null?L(e.date,1,U).getTime()-e.date.getTime():e.realMs),[Y,U]),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;Rn[e]<=n?(a=e,r=e+1):i=e-1}let o=zn[a]||864e5,s=(n-Rn[a])/o;return(Fn||Pn)&&(s=Math.max(0,Math.min(s,1))),X[a]+s*Y[a].width},[Y,Rn,zn,X,Fn,Pn]),Bn=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]),Vn=t.useCallback(e=>{let t=Bn(e);if(t<0)return new Date(J.start);let n=Y[t].width||1,r=(e-X[t])/n;return new Date(Rn[t]+r*(zn[t]||864e5))},[Bn,Y,Rn,zn,X,J]),Hn=t.useCallback(e=>{let t=Q.current;mt.current==null&&t&&t.clientWidth>0&&(mt.current=Vn(t.scrollLeft)),pt.current=mt.current,ht.current=!0,ft(e),h?.(e)},[h,Vn]);t.useLayoutEffect(()=>{let e=pt.current;if(e==null)return;pt.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,U))),n));t.scrollLeft!==r&&(t.scrollLeft=r)},[U,Z]);let Un=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;Rn[e]<=r?(o=e,i=e+1):a=e-1}let s=Math.min(n-1,Math.max(0,o+t)),c=r-Rn[o];return new Date(Rn[s]+c)},[Y,Rn]),Wn=t.useRef(null);Wn.current=Fn||Pn?Un:null;let Gn=t.useMemo(()=>{let e=[];if(Pn&&C){let t=0;for(let n of Y){let r=String(M(n.date,C.dayStartMin).getTime()),i=e[e.length-1];i&&i.key===r?i.width+=n.width:e.push({key:r,label:n.date.toLocaleDateString(Ce,{month:`short`,day:`numeric`}),width:n.width,offset:t}),t+=n.width}return e}let t=U===`year`?`decade`:U===`month`||U===`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(Ce,{month:`short`,year:`numeric`}),width:r.width,offset:n}),n+=r.width}return e},[Y,U,Ce,Pn,C]),Kn=t.useMemo(()=>(_e??[]).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),[_e,J,Z]),qn=t.useRef(null),Jn=t.useRef(null),Yn=t.useRef(null),Q=t.useRef(null);t.useEffect(()=>{let e=Q.current;if(!e)return;let t=()=>{ht.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[Xn,Zn]=t.useState(null),Qn=t.useRef([]),$n=t.useRef(null),[er,tr]=t.useState({top:0,left:0}),[nr,rr]=t.useState({width:4e3,height:600}),ir=t.useCallback(()=>{let e=Q.current;if(!e)return;let t=e.clientWidth||4e3,n=e.clientHeight||600;rr(e=>e.width===t&&e.height===n?e:{width:t,height:n})},[]);t.useLayoutEffect(()=>{ir();let e=Q.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(ir);return t.observe(e),()=>t.disconnect()},[ir]);let ar=t.useMemo(()=>Ne(X,er.left-240,er.left+nr.width+240),[X,er.left,nr.width]),or=t.useMemo(()=>{let e=Gn.map(e=>e.offset);return e.push(Ln),e},[Gn,Ln]),sr=t.useMemo(()=>Ne(or,er.left-240,er.left+nr.width+240),[or,er.left,nr.width]),$=t.useMemo(()=>({startIdx:Math.max(0,Math.floor(er.top/H)-6),endIdx:Math.min(q.length,Math.ceil((er.top+nr.height)/H)+6)}),[er.top,nr.height,H,q.length]),cr=q.length*H,lr=Re(U,Pn),ur=t.useMemo(()=>{let e=Bn(er.left);return ze(e>=0?Y[e].date:J.start,lr,C?.dayStartMin??0)},[Bn,er.left,Y,J,lr,C]),dr=t.useMemo(()=>Ve(ur,lr,Ce),[ur,lr,Ce]),fr=t.useCallback(e=>{let t=Q.current;if(!t)return;let n=Be(ur,e,lr),r=Math.max(0,Ln-nr.width),i=Math.max(0,Math.min(Math.round(Z(n)),r));t.scrollLeft=i,tr(e=>e.left===i?e:{...e,left:i})},[ur,lr,Ln,nr.width,Z]),[pr,mr]=t.useState(!1);t.useEffect(()=>{let e=()=>mr(!!document.fullscreenElement);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let hr=t.useCallback(()=>{let e=Ee.current;e&&(document.fullscreenElement?document.exitFullscreen?.():e.requestFullscreen?.())},[]),gr=t.useRef(null),_r=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;gr.current={baseDistance:Math.max(1,Math.sqrt(t*t+n*n)),baseColumn:xt}}},[xt]),vr=t.useCallback(e=>{if(e.touches.length!==2||!gr.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))/gr.current.baseDistance,i=Math.max(15,Math.min(120,Math.round(gr.current.baseColumn*r)));lt(i)},[]),yr=t.useCallback(()=>{gr.current=null},[]),br=t.useMemo(()=>{let e=N.now();return e<J.start||e>J.end?null:Math.round(Z(e))},[J,Z,N]),xr=t.useCallback(()=>{if(br==null||!Q.current)return;let e=Math.max(0,br-Q.current.clientWidth/2);Q.current.scrollTo({left:e,behavior:`smooth`})},[br]),Sr=t.useRef(!1);t.useEffect(()=>{if(Sr.current||P.length===0)return;let e=window.requestAnimationFrame(()=>{let e=Q.current;if(!e||e.clientWidth===0)return;let t=br;if(t==null){let e=new Date(Math.min(...P.map(e=>e.start.getTime())));t=Math.round(Z(e))}e.scrollLeft=Math.max(0,t-e.clientWidth/2),Sr.current=!0});return()=>window.cancelAnimationFrame(e)},[P,br,Z]);let Cr=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]),wr=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));Qn.current.forEach(e=>window.clearTimeout(e)),Qn.current=[],$n.current?.(),$n.current=null,Zn(null);let u=()=>{if(n==null)return;let e=window.requestAnimationFrame(()=>{Zn(n),Qn.current.push(window.setTimeout(()=>Zn(e=>e===n?null:e),1500))});$n.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),Qn.current.push(window.setTimeout(m,f?1500:500)),$n.current=()=>r.removeEventListener(`scrollend`,m)},[Z]);t.useEffect(()=>()=>{Qn.current.forEach(e=>window.clearTimeout(e)),$n.current?.()},[]);let Tr=t.useCallback(()=>Cr(Me(N.now(),`week`)),[Cr,N]),Er=t.useCallback(()=>Cr(Me(N.now(),`month`)),[Cr,N]),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.useRef(null),Pr=t.useRef(null),Fr=t.useCallback(()=>{let e=Yn.current,t=Dr.current,n=Or.current,r=kr.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=jr.current,a=Mr.current,o=Nr.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(()=>{Fr()});let Ir=e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=Yn.current,n=Or.current,r=kr.current;if(!t||!n||!r)return;Ar.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=Ar.current;n&&(t.scrollLeft=n.startLeft+(e.clientX-n.startX)*s)},l=()=>{Ar.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=Yn.current,n=Or.current,r=kr.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)},Rr=e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=Yn.current,n=Mr.current,r=Nr.current;if(!t||!n||!r)return;Pr.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=Pr.current;n&&(t.scrollTop=n.startTop+(e.clientY-n.startY)*s)},l=()=>{Pr.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)},zr=e=>{if(e.button!==0||e.target!==e.currentTarget)return;let t=Yn.current,n=Mr.current,r=Nr.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)},Br=e=>{let t=e.currentTarget;!ht.current&&t.clientWidth>0&&(mt.current=Vn(t.scrollLeft)),qn.current&&(qn.current.scrollLeft=t.scrollLeft),Fr(),Jn.current&&Jn.current.scrollTop!==t.scrollTop&&(Jn.current.scrollTop=t.scrollTop),tr(e=>e.top===t.scrollTop&&e.left===t.scrollLeft?e:{top:t.scrollTop,left:t.scrollLeft}),ir()},Vr=e=>{let t=e.currentTarget,n=Q.current;n&&n.scrollTop!==t.scrollTop&&(n.scrollTop=t.scrollTop),tr(e=>e.top===t.scrollTop?e:{...e,top:t.scrollTop})},Hr=(e,t)=>{let n=Z(e),r=Pn&&C?St*Math.min(...C.bands.map(e=>e.durMs))/je:St;return{left:n,width:Math.max(Z(t)-n,r,3)}},Ur=G?.group?G.taskId:null,Wr=t.useMemo(()=>{if(Ur==null)return null;let e=new Set([String(Ur)]);for(let t of Nt(Ur))t.locked||e.add(String(t.id));return e},[Ur,Nt]),Gr=t.useMemo(()=>{if(!G||G.group)return null;let e=new Set,t=new Set,n=Mt.get(String(G.taskId));for(;n&&n.parent!=null&&n.parent!==``;){let r=String(n.parent);if(t.has(r)||!Mt.has(r))break;t.add(r),e.add(r),n=Mt.get(r)}return e.size?e:null},[G,Mt]),Kr=e=>{if(G){if(Wr?.has(String(e.task.id))){let t=Lt(G),n=Fe(G.originStart,t.start,Pn);return Hr(n(e.start),n(e.end))}if(G.taskId===e.task.id&&!G.group){let e=Lt(G);return Hr(e.start,e.end)}if(e.isSummary&&Gr?.has(String(e.task.id))&&(O!==`self`||e.task.hasOwnDates===!1)){let t=Lt(G),n=String(G.taskId),r=null,i=null;for(let a of Nt(e.task.id)){if((jt.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 Hr(r,i)}}return Hr(e.start,e.end)},qr=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]),Jr=Math.max(2,Math.round(H/2)-14),Yr=H-Jr*2,Xr=Math.round(Yr/2),Zr=Math.max(Math.round(H*.4),12),Qr=Zr*Math.SQRT2/2,$r=Yr,ei=Jr,ti=Math.max(3,Math.round(H*.13)),ni=H-ti-1,ri=`rgba(100, 116, 139, 0.35)`,ii=`rgba(100, 116, 139, 0.6)`,ai=e=>{let t=q[e.sourceIndex],n=q[e.targetIndex];if(!t||!n)return null;let r=Kr(t),i=Kr(n),a=e=>e.isSummary?ei+$r/2:H/2,o=e.sourceIndex*H+a(t),s=e.targetIndex*H+a(n),c=e.type===`fs`||e.type===`ff`,l=e.type===`ff`||e.type===`sf`,u=t.isMilestone?r.left+(c?Qr:-Qr):c?r.left+r.width:r.left,d=n.isMilestone?i.left+(l?Qr:-Qr):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)*H:e.sourceIndex*H;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(` `)},oi=G?.taskId??Ot,[si,ci]=t.useState(x),li=t.useMemo(()=>si?oe(P,S):null,[si,P,S]),ui=t.useCallback(e=>li?.criticalIds.has(String(e))??!1,[li]),di=`#dc2626`,[fi,pi]=t.useState(null),[mi,hi]=t.useState(!1);t.useEffect(()=>{if(!mi)return;let e=setTimeout(()=>hi(!1),2500);return()=>clearTimeout(e)},[mi]);let gi=t.useCallback(()=>{if(!B)return;let{changes:e,skippedLocked:t}=A(P,S,Jt);if(!e.length){hi(!0);return}pi({changes:e,skipped:t.length})},[P,B,S,Jt]),_i=t.useCallback(()=>{if(!fi)return;let e=[];for(let t of fi.changes){let n=P.find(e=>String(e.id)===t.id);n&&e.push({task:n,changes:{start:t.start,end:t.end}})}e.length&&Wt(e),pi(null)},[fi,P,Wt]),vi=t.useCallback(()=>{if(typeof document>`u`||!P.length)return null;let e=e=>String(e).replace(/[&<>"]/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`})[e]),t=Math.max(W,200),n=Math.ceil(t+Ln),r=Math.ceil(36+q.length*H),i=li?.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">`),Gn.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*H;a.push(`<line x1="0" y1="${(i+H).toFixed(1)}" x2="${t}" y2="${(i+H).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+H/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*H,{left:i,width:s}=Hr(t.start,t.end),c=ui(t.task.id),l=c?` stroke="${di}" stroke-width="2"`:``;if(re&&t.task.baselineStart&&t.task.baselineEnd){let e=Hr(t.task.baselineStart,t.task.baselineEnd);a.push(`<rect x="${e.left.toFixed(1)}" y="${(r+ni).toFixed(1)}" width="${Math.max(2,e.width).toFixed(1)}" height="${ti}" rx="1" fill="${ri}" stroke="${ii}"/>`)}if(t.isMilestone){let e=i,n=r+H/2,o=Zr/2,s=c?di: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+ei).toFixed(1)}" width="${s.toFixed(1)}" height="${$r}" 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+ei).toFixed(1)}" width="${c.toFixed(1)}" height="${$r}" 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+H/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+Jr).toFixed(1)}" width="${s.toFixed(1)}" height="${Yr}" 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+Jr).toFixed(1)}" width="${c.toFixed(1)}" height="${Yr}" 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+H/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+H/2+3).toFixed(1)}" text-anchor="middle" fill="#ffffff">${Math.round(t.progress)}%</text>`)}}),qr.forEach(e=>{let t=ai(e);if(!t)return;let n=i?.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,r=n?di:`#94a3b8`;a.push(`<path d="${t}" fill="none" stroke="${r}" stroke-width="${n?2:1.5}"/>`)}),br!=null&&a.push(`<line x1="${br.toFixed(1)}" y1="0" x2="${br.toFixed(1)}" y2="${q.length*H}" stroke="#ef4444" stroke-width="1.5"/>`);let s=q.length*H;return Kn.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}},[P,q,qr,ai,Hr,ui,li,Y,X,Ln,W,H,Jr,Yr,ei,$r,Zr,br,U,re,ni,ti,ri,ii,Kn,Gn]),yi=t.useCallback(()=>{let e=(de??``).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())}`}`},[de]),bi=t.useCallback(async()=>{let e=vi();if(!e)return;let t=await He(e.svg,e.W,e.H);t&&t.toBlob(e=>{e&&Ue(e,`${yi()}.png`)},`image/png`)},[vi,yi]),xi=t.useCallback(async()=>{let e=vi();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),`${yi()}.pdf`)},[vi,yi]),[Si,Ci]=t.useState(!1),wi=t.useCallback(()=>{let e={viewMode:U,columnWidth:ct,taskListCollapsed:gt,taskListWidth:ut,collapsedIds:Array.from(kn)};k&&Je(k,e),ae?.(e),Ci(!0)},[U,ct,gt,ut,kn,k,ae]);return t.useEffect(()=>{if(!Si)return;let e=setTimeout(()=>Ci(!1),1500);return()=>clearTimeout(e)},[Si]),(0,p.jsxs)(`div`,{ref:Ee,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":T&&Xe?`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":F(`gantt.toolbar.prevPeriod`),"data-testid":`gantt-toolbar-prev-period`,onClick:()=>fr(-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":F(`gantt.toolbar.nextPeriod`),"data-testid":`gantt-toolbar-next-period`,onClick:()=>fr(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:dr}),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:F(`gantt.readOnlyHint`),children:[(0,p.jsx)(f.Lock,{className:`h-3 w-3`}),F(`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":F(`gantt.toolbar.viewMode`),children:ke.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`,U===e&&`bg-background shadow-sm hover:bg-background`),onClick:()=>Hn(e),"aria-pressed":U===e,"data-testid":`gantt-view-mode-${e}`,children:F(`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(xt>15)lt(Math.max(15,xt-10));else{let e=ke.indexOf(U);e<ke.length-1&&(Hn(ke[e+1]),lt(xe))}},"aria-label":F(`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(xt<120)lt(Math.min(120,xt+10));else{let e=ke.indexOf(U);e>0&&(Hn(ke[e-1]),lt(xe))}},"aria-label":F(`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:()=>_t(e=>!e),"aria-label":F(gt?`gantt.toolbar.showTaskList`:`gantt.toolbar.hideTaskList`),"aria-pressed":gt,"data-testid":`gantt-toggle-task-list`,children:gt?(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:xr,disabled:br==null,"aria-label":F(`gantt.toolbar.jumpToToday`),"data-testid":`gantt-jump-today`,children:F(`gantt.toolbar.today`)}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:Tr,"aria-label":F(`gantt.toolbar.thisWeek`),"data-testid":`gantt-jump-week`,children:F(`gantt.toolbar.thisWeek`)}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:Er,"aria-label":F(`gantt.toolbar.thisMonth`),"data-testid":`gantt-jump-month`,children:F(`gantt.toolbar.thisMonth`)}),ce?(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>void ce(),disabled:j,"aria-label":F(`gantt.toolbar.refresh`),"aria-busy":j,"data-testid":`gantt-refresh`,children:(0,p.jsx)(f.RefreshCw,{className:`h-4 w-4`})}):null,B?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Qt,disabled:!en,"aria-label":F(`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:$t,disabled:!tn,"aria-label":F(`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:()=>ci(e=>!e),"aria-label":F(`gantt.toolbar.criticalPath`),"aria-pressed":si,"data-testid":`gantt-critical-path`,style:si?{color:di}:void 0,children:(0,p.jsx)(f.Activity,{className:`h-4 w-4`})}),it&&B?(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:gi,"aria-label":F(`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:bi,"aria-label":F(`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:xi,"aria-label":F(`gantt.toolbar.exportPdf`),"data-testid":`gantt-export-pdf`,children:(0,p.jsx)(f.FileDown,{className:`h-4 w-4`})}),ae||k?(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:wi,"aria-label":F(`gantt.toolbar.saveLayout`),"aria-pressed":Si,"data-testid":`gantt-save-layout`,style:Si?{color:di}: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:hr,"aria-label":F(pr?`gantt.toolbar.exitFullscreen`:`gantt.toolbar.enterFullscreen`),"aria-pressed":pr,"data-testid":`gantt-fullscreen`,children:pr?(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:Nn,"data-testid":`gantt-body`,children:[!gt&&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(Se,Ye-200),i=e=>{let i=Math.max(Se,Math.min(n+(e.clientX-t),r));dt(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:()=>dt(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:F(`gantt.column.taskName`)}),Ct&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:F(`gantt.column.start`)}),(0,p.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:F(`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:qn,children:(0,p.jsxs)(`div`,{className:`flex flex-col h-full`,style:{width:Ln},children:[(0,p.jsx)(`div`,{className:`relative border-b`,style:{height:`45%`},"data-testid":`gantt-header-groups`,children:Gn.slice(sr.start,sr.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(ar.start,ar.end).map((e,t)=>{let n=ar.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&&xt>=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:Jn,onScroll:Vr,style:{width:W,minWidth:W},role:`tree`,"aria-label":F(`gantt.aria.taskList`),children:[$.startIdx>0&&(0,p.jsx)(`div`,{style:{height:$.startIdx*H},"aria-hidden":`true`}),q.slice($.startIdx,$.endIdx).map(e=>{let t=e.task,r=rt&&wt===t.id,i=kn.has(String(t.id)),a=wn!=null&&String(wn)===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:H,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:!!nt&&!r&&!t.locked,onDragStart:nt?e=>{e.dataTransfer.setData(`text/plain`,String(t.id)),e.dataTransfer.effectAllowed=`move`}:void 0,onDragOver:nt?e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`}:void 0,onDrop:nt?e=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);if(!n||n===String(t.id))return;let r=Mt.get(n);r&&String(r.parent??``)===String(t.parent??``)&&nt(r,t)}:void 0,onContextMenu:e=>Dn(t,e),onClick:()=>{Tn(t.id),r||wr(e.start,e.end,t.id)},onDoubleClick:()=>{r||(rt&&B&&!e.isSummary&&!t.locked?(Tt(t.id),Dt({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(),jn(t.id)},"aria-expanded":!i,"aria-label":F(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:Et.title||``,onChange:e=>Dt(t=>({...t,title:e.target.value})),onKeyDown:e=>{e.key===`Enter`?(Wt([{task:t,changes:{title:Et.title,start:(0,n.toDisplayDate)(Et.start),end:Le(Et.end,t),progress:Number(Et.progress)||0}}]),Tt(null)):e.key===`Escape`&&Tt(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}),!Ct&&(0,p.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,"data-testid":`gantt-row-dates-${t.id}`,children:[I(e.start,`numeric`),` → `,I(Ie(e.start,e.end),`numeric`)]})]})]}),Ct&&(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:Et.start||``,onChange:e=>Dt(t=>({...t,start:e.target.value})),onClick:e=>e.stopPropagation()}):I(e.start,`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:Et.end||``,onChange:e=>Dt(t=>({...t,end:e.target.value})),onClick:e=>e.stopPropagation()}):I(Ie(e.start,e.end),`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:F(`gantt.row.open`),"aria-label":F(`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)*H},"aria-hidden":`true`})]}),(0,p.jsx)(`div`,{className:`flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]`,ref:e=>{Yn.current=e,Q.current=e},onScroll:Br,onTouchStart:_r,onTouchMove:vr,onTouchEnd:yr,"data-testid":`gantt-timeline`,children:(0,p.jsxs)(`div`,{className:`relative`,style:{width:Ln},children:[br!=null&&(0,p.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px z-20 pointer-events-none`,style:{left:br,backgroundColor:`rgba(239, 68, 68, 0.8)`},"data-testid":`gantt-today-marker`,"aria-label":F(`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:F(`gantt.toolbar.today`)})}),Kn.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:un,children:[(0,p.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:Y.slice(ar.start,ar.end).map((e,t)=>{let n=ar.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)})}),Pn&&C&&C.showMidnight&&(0,p.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:Y.slice(ar.start,ar.end).map((e,t)=>{let n=ar.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*H},"aria-hidden":`true`}),q.slice($.startIdx,$.endIdx).map((e,n)=>{let r=e.task,i=$.startIdx+n,a=ui(r.id),o=Hr(e.start,e.end),s=re&&r.baselineStart&&r.baselineEnd?Hr(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:ni,height:ti,backgroundColor:ri,border:`1px solid ${ii}`},"data-testid":`gantt-baseline-${r.id}`,"aria-hidden":`true`}):null,l=G?.taskId===r.id,d=Wr?.has(String(r.id))??!1,f=Gr?.has(String(r.id))??!1,m=l||d||f?Kr(e):o,h=!!r.locked,g=!!B&&!e.isSummary&&!h,_=g&&Ze,v=g&&z,y=g&&Qe,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,x=K?e=>{let t=e.currentTarget.getBoundingClientRect(),n=t.width>0&&e.clientX-t.left>t.width/2?`end`:`start`;dn(e=>{if(!e)return e;let t=cn(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,S=K?e=>{e.target===e.currentTarget&&dn(e=>e&&{...e,targetId:null,targetEnd:null,rejectedId:null,rejectedReason:null})}:void 0,C=Math.max(1,Math.round((e.end.getTime()-e.start.getTime())/je)),w=(i+1)*H+300>cr&&i*H>300,T=Ot===r.id&&!G&&!rn&&!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),...w?{bottom:H-8}:{top:H-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:[I(e.start,`short`),` → `,I(Ie(e.start,e.end),`short`),` · `,C,F(`gantt.tooltip.days`),` · `,Math.round(e.progress),`%`]}),r.locked||R&&!B?(0,p.jsxs)(`div`,{className:`text-muted-foreground`,style:{marginTop:4},"data-testid":`gantt-tooltip-locked-${r.id}`,children:[`🚫 `,F(`gantt.lockedHint`)]}):null]}):null;if(r.type===`group`)return(0,p.jsx)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:H},onPointerMove:S,children:T},r.id);if(e.isSummary){let t=r.color||`#0d9488`,n=O===`self`&&r.hasOwnDates!==!1,i=!!B&&Ze&&!h,o=!!B&&z&&n&&!h;return(0,p.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:H},onPointerMove:S,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`,Xn===r.id&&`gantt-flash z-10`),style:{left:m.left,width:m.width,top:ei,height:$r,cursor:i||o?void 0:ee?`not-allowed`:`pointer`,backgroundColor:t,borderColor:a?di:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${di}`: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:()=>kt(r.id),onMouseLeave:()=>kt(e=>e===r.id?null:e),onPointerMove:x,onPointerDown:t=>{if(t.button===0){if(o){let e=be(t.clientX,t.currentTarget.getBoundingClientRect());if(e!==`move`){nn(r,e,t);return}}i&&nn(r,`move`,t,{group:!0,originStart:e.start,originEnd:e.end})}},onClick:()=>{It.current||Tn(r.id)},onContextMenu:e=>Dn(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:ye,height:Xr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${r.id}`,onPointerDown:e=>{e.button===0&&nn(r,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,p.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:ye,height:Xr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${r.id}`,onPointerDown:e=>{e.button===0&&nn(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}),V&&!h&&[`start`,`end`].map(e=>{let t=K!=null&&String(K.sourceId)===String(r.id)&&K.sourceEnd===e,n=t||Ot===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=un.current?.getBoundingClientRect();dn({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:ei+$r+2},"data-testid":`gantt-summary-drag-chip-${r.id}`,children:[I(Lt(G).start,`numeric`),` → `,I(Rt(G),`numeric`)]}),T]},r.id)}if(e.isMilestone){let e=Zr;return(0,p.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:H},onPointerMove:S,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`,Xn===r.id&&`gantt-flash z-10`),style:{left:m.left-e/2,top:(H-e)/2,width:e,height:e,cursor:_?void 0:ee?`not-allowed`:`pointer`,backgroundColor:a?di:r.color||`#3b82f6`,borderColor:a?di:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${di}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0,...ne},"data-critical":a?`true`:void 0,"data-testid":`gantt-milestone-${r.id}`,onMouseEnter:()=>kt(r.id),onMouseLeave:()=>kt(e=>e===r.id?null:e),onClick:()=>{It.current||Tn(r.id)},onContextMenu:e=>Dn(r,e),onPointerMove:x,onPointerDown:_?e=>{e.button===0&&nn(r,`move`,e)}:void 0}),T]},r.id)}let E=rn&&rn.taskId===r.id?rn.value:r.progress;return(0,p.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:H},onPointerMove:S,onMouseEnter:()=>kt(r.id),onMouseLeave:()=>kt(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:Jr,height:Yr,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`,Xn===r.id&&`gantt-flash z-10`),style:{left:m.left,width:m.width,top:Jr,height:Yr,cursor:b?void 0:ee?`not-allowed`:`pointer`,backgroundColor:r.color||`#3b82f6`,borderColor:a?di:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${di}`: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:()=>{It.current||Tn(r.id)},onContextMenu:e=>Dn(r,e),onPointerMove:x,onPointerDown:b?e=>{if(e.button!==0)return;let t=be(e.clientX,e.currentTarget.getBoundingClientRect()),n=t!==`move`&&v?t:_?`move`:null;n&&nn(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:ye,height:Xr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${r.id}`,onPointerDown:e=>{e.button===0&&nn(r,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,p.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:ye,height:Xr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${r.id}`,onPointerDown:e=>{e.button===0&&nn(r,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),E>0&&(0,p.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 pointer-events-none`,style:{width:`${E}%`,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`,rn?.taskId===r.id?`opacity-100`:`opacity-0 group-hover:opacity-100 transition-opacity`),style:{left:`${E}%`},"data-testid":`gantt-progress-handle-${r.id}`,onPointerDown:e=>{e.button===0&&(e.stopPropagation(),e.preventDefault(),an({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))`}})}),V&&!h&&[`start`,`end`].map(e=>{let t=K!=null&&String(K.sourceId)===String(r.id)&&K.sourceEnd===e,n=t||Ot===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=un.current?.getBoundingClientRect();dn({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?`${I(Lt(G).start,`numeric`)} → ${I(Rt(G),`numeric`)}`:`${Math.round(E)}%`})]}),T]},r.id)}),$.endIdx<q.length&&(0,p.jsx)(`div`,{style:{height:(q.length-$.endIdx)*H},"aria-hidden":`true`}),(qr.length>0||K)&&(0,p.jsxs)(`svg`,{className:`absolute top-0 left-0 pointer-events-none z-10`,width:Ln,height:cr,"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:di})})]}),qr.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=ai(e);if(!r)return null;let i=oi!=null&&(String(e.sourceId)===String(oi)||String(e.targetId)===String(oi)),a=li?.criticalEdges.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,o=a?`gantt-link-arrow-critical`:i?`gantt-link-arrow-active`:`gantt-link-arrow`,s=!!(tt||V);return(0,p.jsxs)(t.Fragment,{children:[(0,p.jsx)(`path`,{d:r,fill:`none`,stroke:a?di: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=>On(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=Kr(q[e]),n=q[e].isMilestone?t.left+(K.sourceEnd===`start`?-Qr:Qr):K.sourceEnd===`start`?t.left:t.left+t.width,r=e*H+H/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=P.find(e=>String(e.id)===String(K.sourceId));if(!e)return null;let t=K.targetId==null?null:P.find(e=>String(e.id)===String(K.targetId)),n=e=>F(`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:jr,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:Mr,className:`relative h-full`,onPointerDown:zr,role:`scrollbar`,"aria-controls":`gantt-timeline`,"aria-orientation":`vertical`,children:(0,p.jsx)(`div`,{ref:Nr,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:Rr})})})]}),(0,p.jsx)(`div`,{ref:Dr,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:Or,className:`relative`,style:{marginLeft:W,height:14},onPointerDown:Lr,role:`scrollbar`,"aria-controls":`gantt-timeline`,"aria-orientation":`horizontal`,children:(0,p.jsx)(`div`,{ref:kr,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:Ir})})})]}),pn&&(()=>{let e=P.find(e=>String(e.id)===String(pn.taskId));if(!e)return null;let t=q.find(e=>String(e.task.id)===String(pn.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:hn,className:`fixed z-50 min-w-[160px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:pn.x,top:pn.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:()=>{mn(null),l(e)},children:F(`gantt.menu.view`)}),rt&&B&&t&&!t.isSummary&&!e.locked&&(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-edit`,onClick:()=>{mn(null),Tt(e.id),Dt({title:e.title,start:e.start.toLocaleDateString(`en-CA`),end:(0,n.toDateInputValue)(Ie(e.start,e.end)),progress:String(e.progress)})},children:F(`gantt.menu.edit`)}),V&&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=pn;mn(null),Sn(``),bn({x:t.x,y:t.y,taskId:e.id,relation:`pred`})},children:F(`gantt.menu.addPredecessor`)}),(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-add-successor`,onClick:()=>{let t=pn;mn(null),Sn(``),bn({x:t.x,y:t.y,taskId:e.id,relation:`succ`})},children:F(`gantt.menu.addSuccessor`)})]}),et&&!e.locked&&(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:(0,u.cn)(r,`text-destructive`),"data-testid":`gantt-context-menu-delete`,onClick:()=>{mn(null),et(e)},children:F(`gantt.menu.delete`)})]})})(),gn&&(()=>{let e=P.find(e=>String(e.id)===String(gn.sourceId)),t=P.find(e=>String(e.id)===String(gn.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:vn,className:`fixed z-50 min-w-[180px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:gn.x,top:gn.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:[`🚫 `,F(`gantt.lockedHint`)]}),V&&le&&r.map(r=>(0,p.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":gn.type===r,disabled:i,className:(0,u.cn)(n,gn.type===r&&`font-semibold`,i&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-type-${r}`,onClick:()=>{i||(_n(null),r!==gn.type&&V(e,t,r))},children:[gn.type===r?`✓ `:`\xA0\xA0`,F(`gantt.linkType.${r}`)]},r)),tt&&(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||(_n(null),tt(e,t))},children:F(`gantt.menu.removeDependency`)})]})]})})(),yn&&V&&(()=>{let e=P.find(e=>String(e.id)===String(yn.taskId));if(!e)return null;let t=new Set(qr.map(e=>`${String(e.sourceId)}->${String(e.targetId)}`)),n=P.filter(n=>{if(String(n.id)===String(e.id)||n.type===`group`||n.locked)return!1;let r=yn.relation===`pred`?`${String(n.id)}->${String(e.id)}`:`${String(e.id)}->${String(n.id)}`;return!t.has(r)}),r=xn.trim().toLowerCase(),i=r?n.filter(e=>String(e.title??``).toLowerCase().includes(r)):n;return(0,p.jsxs)(`div`,{ref:Cn,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:yn.x,top:yn.y},role:`menu`,"data-testid":`gantt-dep-picker`,children:[(0,p.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:yn.relation===`pred`?F(`gantt.menu.addPredecessor`):F(`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:xn,onChange:e=>Sn(e.target.value),placeholder:F(`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:F(`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:()=>{bn(null),yn.relation===`pred`?V(t,e,`fs`):V(e,t,`fs`)},children:t.title},String(t.id)))]})})(),fi&&(0,p.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-autoschedule-overlay`,onClick:()=>pi(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:F(`gantt.autoScheduleDlg.title`)}),(0,p.jsxs)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:[F(`gantt.autoScheduleDlg.body`,{count:fi.changes.length}),fi.skipped>0&&(0,p.jsxs)(p.Fragment,{children:[` `,(0,p.jsx)(`span`,{"data-testid":`gantt-autoschedule-skipped`,children:F(`gantt.autoScheduleDlg.skipped`,{count:fi.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:()=>pi(null),children:F(`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:_i,children:F(`gantt.autoScheduleDlg.confirm`)})]})]})}),mi&&(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:F(`gantt.autoScheduleDlg.none`)}),Gt&&(0,p.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-conflict-overlay`,onClick:()=>Kt(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:F(`gantt.conflict.title`)}),(0,p.jsx)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:F(`gantt.conflict.body`,{count:Gt.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:()=>Kt(null),children:F(`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:Xt,children:F(`gantt.conflict.confirm`)})]})]})})]})}function Xe(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 R(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)Xe(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},z=48,Qe=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:a=1,viewMode:o=`day`,unassignedLabel:s=`Unassigned`,className:c}){let{t:l}=ve(),u=(0,i.useDisplayLocale)(),d=Ze[o],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,o),i=L(Me(n,o),1,o),a=[],s=0;for(;r<i&&s++<4e3;){let e=L(r,1,o);a.push({date:new Date(r),col:{start:new Date(r),end:new Date(e)},label:B(r,o,u)}),r=e}return a},[e,o,u]),m=t.useMemo(()=>R(e,f.map(e=>e.col),{assignee:n,effort:r,capacity:a,unassignedLabel:s}),[e,f,n,r,a,s]),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:z,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=Qe*(1-Math.min(e.capacity/h,1));return(0,p.jsxs)(`div`,{style:{position:`relative`,display:`flex`,height:z,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,Qe*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 V={display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8,padding:`8px 12px`,borderBottom:`1px solid hsl(var(--border))`,background:`hsl(var(--background))`,fontSize:13},tt={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`},nt={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)`},rt={display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,borderRadius:6,cursor:`pointer`,userSelect:`none`};function it({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:{...tt,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:nt,"data-testid":`quick-filter-panel-${e.field}`,children:e.options.length===0?(0,p.jsx)(`div`,{style:{...rt,cursor:`default`,opacity:.6},children:i.empty}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{role:`option`,"aria-selected":u,style:{...rt,fontWeight:600},"data-testid":`quick-filter-all-${e.field}`,onClick:()=>f(),children:[(0,p.jsx)(it,{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:{...rt,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)(it,{checked:n}),(0,p.jsx)(`span`,{children:t.label})]},t.value)})]})})]})}var H=({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:V,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:{...tt,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 ot(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 st={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 ct(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=st[String(n.type??``).toLowerCase().replace(/-/g,`_`)];t.push(r?{id:e,type:r}:{id:e})}else t.push(n)}return t}function lt(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 ut(e,t){let r=(0,n.toDisplayDate)(e);return typeof e==`string`&&(0,n.isRealCalendarDate)(e)?P(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=P(t,r);return t.to(i).getTime()===r.getTime()?i:P(t,new Date(r.getTime()-1))}function U(e,t,r,i,a=`start`){if(!(typeof t==`string`?t===`date`:typeof r==`string`&&(0,n.isRealCalendarDate)(r)))return e.toISOString();let o=he(i,e);return(0,n.toDateInputValue)(a===`end`?(0,n.toInclusiveEndDay)(o):o)}var ft=()=>globalThis.process?.env?.NODE_ENV!==`production`,pt=[...Object.keys(o.GanttConfigSchema.shape),`dependencyField`],mt=new Set;function ht(e){if(!ft())return;let t=pt.filter(t=>e[t]!==void 0);if(t.length===0)return;let n=`${e.type??`gantt`}::${e.objectName??``}::${t.join(`,`)}`;mt.has(n)||(mt.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=o.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,x]=(0,t.useState)(null),[S,C]=(0,t.useState)(null),{currency:re}=(0,i.useLocalization)(),w=(0,i.useDisplayLocale)(),{t:T}=ve(),E=(0,t.useCallback)(e=>{a.toast.error(T(`gantt.writeFailed`),{description:lt(e)??void 0})},[T]),D=(0,n.resolveRecordSourceConfig)(e,`view-data`),ie=JSON.stringify(D),O=(0,t.useMemo)(()=>D,[ie]),k=gt(e),ae=O?.provider,oe=ae===`value`,A=(0,t.useMemo)(()=>(0,n.resolveDataSource)(O,f??null),[O,f]),se=(0,t.useRef)(A);se.current=A;let ce=JSON.stringify(D?.provider===`value`?{provider:`value`,items:D.items}:{provider:D?.provider??null}),j=(0,n.resolveRecordSourceObjectName)(e,O)??``,{ready:le,def:M}=(0,r.useSettledSchema)(j,oe?void 0:A),de=(0,l.usePermissions)(),fe=typeof e.search==`string`&&e.search!==``?e.search:void 0,me=fe&&Array.isArray(e.searchableFields)&&e.searchableFields.length>0?e.searchableFields:void 0,N=me?JSON.stringify(me):``,[P,he]=(0,t.useState)(!1),ge=(0,r.useFilterScope)(),_e=(0,r.useResolvedFilter)(e.filter,ge),F=(0,t.useRef)(0),ye=(0,t.useRef)(!1),be=(0,t.useRef)(!1),xe=v.data,Se=Array.isArray(xe)&&xe.length>0?xe:null,Ce=(0,t.useRef)(Se);Ce.current=Se;let we=(0,t.useCallback)(async({silent:t=!1,inPlace:r=t}={})=>{let i=++F.current,a=()=>F.current===i,o=!t||be.current;be.current=o;try{r?he(!0):te(!0);let t=Ce.current;if(t){a()&&(b(t),C(null),x(null),ye.current=!0);return}let i=se.current;if(!i||typeof i.find!=`function`)throw Error(`DataSource required for the object provider`);let o=(0,n.buildExpandFields)(M?.fields),s=!de?.isLoaded||!j?o:o.filter(e=>de.checkField(j,e,`read`)),c=await i.find(j,{$filter:_e,$orderby:(0,n.convertSortToQueryParams)(e.sort),...(0,n.nonGridRowCeilingQuery)(),...s.length>0?{$expand:s}:{},...fe?{$search:fe,...me?{$searchFields:me}:{}}:{}}),l=(0,n.applyNonGridRowCeiling)(c);a()&&(b(l.rows),C(l),x(null),ye.current=!0)}catch(e){o?a()&&x(e):console.error(`[ObjectGantt] Failed to refresh data:`,e)}finally{a()&&(be.current=!1,he(!1),te(!1))}},[ce,f,j,oe,ae,_e,e.sort,fe,N,M,de]),I=Se===null&&!oe,Te=(0,t.useRef)(we);Te.current=we,(0,t.useEffect)(()=>{(!I||le)&&Te.current(ye.current?{inPlace:!0}:{})},[ce,f,j,oe,ae,_e,e.sort,fe,N,M,de,I,le]);let Ee=(0,r.useDataInvalidation)(I&&j?j:void 0),De=(0,t.useRef)(0);(0,t.useEffect)(()=>{Ee!==De.current&&(De.current=Ee,(!I||le)&&Te.current({silent:!0}))},[Ee,I,le]);let Oe=(0,t.useMemo)(()=>{if(!k||!y.length)return[];let{startDateField:e,endDateField:t,titleField:r,progressField:a,dependenciesField:o,colorField:c,borderColorField:l,parentField:u,typeField:f,lockField:p,tooltipFields:m,baselineStartField:h,baselineEndField:g,quickFilters:_}=k,v=M?.fields??{},b=pe(k.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 x=(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},S=e=>{let t=[x(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)(M,e)},C=(e,t)=>{if(t)return t;let n=v[e]??v[e.split(`.`)[0]];return n?.label?n.label:(0,d.humanizeLabel)(e)},T=(e,t)=>{if(e==null||e===``)return`—`;let n=v[t]??v[t.split(`.`)[0]],r=n?.type,a=n?.options;if(Array.isArray(a)&&a.length){let t=a.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:w});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:w})}switch(r){case`date`:return(0,d.formatDate)(e,void 0,{locale:w});case`datetime`:return(0,d.formatDateTime)(e,{locale:w});case`number`:case`integer`:case`float`:case`decimal`:{let t=(0,s.resolveFieldScale)({type:n?.type,scale:n?.scale});return(0,i.formatDisplayNumber)(Number(e),t===void 0?{locale:w,minimumFractionDigits:0,maximumFractionDigits:20}:{locale:w,minimumFractionDigits:t,maximumFractionDigits:t})}case`currency`:return(0,d.formatCurrency)(Number(e),(0,i.resolveFieldCurrency)(n,re),w);case`percent`:return(0,d.formatPercent)(Number(e),(0,d.percentCellScale)(n),(0,s.resolveFieldScale)({type:n?.type,scale:n?.scale}),w);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)}},E=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=x(e,r);a==null||a===``||Array.isArray(a)&&a.length===0||t.push({label:C(r,i),value:T(a,r)})}return t.length?t:void 0};return y.map((n,r)=>{let i=n[e],s=n[t],m=h?n[h]:void 0,_=g?n[g]:void 0,v=m?ut(m,b):void 0,y=_?dt(_,b):void 0,ne=S(n),x=a?n[a]:0,C=o?n[o]:[],re=c?n[c]:void 0,w=ee(re);if(!w&&re!=null&&re!==``&&(w=(0,d.getSemanticHex)((0,d.getSemanticColorName)(String(re),re))),!w){let e=n.status??n.state??n.priority??n.severity;if(e!=null&&e!==``){let t=(0,d.getSemanticColorName)(void 0,e);t&&(w=(0,d.getSemanticHex)(t))}}let T=l?n[l]:void 0,D=T!=null&&T!==``?te(T)??(0,d.getSemanticHex)(String(T),String(T)):void 0;return{id:n.id||n._id||`task-${r}`,title:ne,start:i?ut(i,b):new Date,end:s?dt(s,b):new Date,hasOwnDates:!!(i&&s),progress:Math.min(100,Math.max(0,x||0)),dependencies:ct(C),parent:u?n[u]??null:void 0,type:f?ot(n[f]):void 0,locked:p?!!n[p]:void 0,color:w,borderColor:D,baselineStart:v&&!isNaN(v.getTime())?v:void 0,baselineEnd:y&&!isNaN(y.getTime())?y:void 0,fields:E(n),data:n}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[y,k,M,w,re]),ke=(0,t.useMemo)(()=>{let e=k?.groupByField;if(!e)return;let t=M?.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)}}},[k?.groupByField,M]),Ae=(0,t.useMemo)(()=>{let e=k?.assigneeField;if(!e)return;let t=M?.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)}}},[k?.assigneeField,M]),je=(0,t.useMemo)(()=>{let e=k?.effortField;if(e)return t=>{let n=t.data?.[e],r=Number(n);return Number.isFinite(r)&&r>0?r:1}},[k?.effortField]),Me=(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]),Ne=(0,t.useMemo)(()=>ue(k?.timeSegments),[k?.timeSegments]),L=(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)},[]),Pe=k?.quickFilters,[Fe,Ie]=(0,t.useState)({});(0,t.useEffect)(()=>{if(!Pe?.length||!f||typeof f.find!=`function`)return;let e=M?.fields??{},t=!1;return(async()=>{let r={};for(let t of Pe){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||Ie(e=>({...e,...r}))})(),()=>{t=!0}},[JSON.stringify(Pe),f,M]);let Le=(0,t.useMemo)(()=>{if(!Pe?.length)return[];let e=M?.fields??{};return Pe.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(Fe[t.field]?.length)i=Fe[t.field];else{let e=new Map;for(let n of y){let r=L(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}})},[Pe,M,Fe,y,L]),Re=e.persistLayout===!1?void 0:`${e.objectName||(O?.provider===`object`?O.object:``)||`gantt`}:${e.viewName||`default`}`,ze=Re?`gantt-layout:${Re}:filters`:null,[Be,Ve]=(0,t.useState)(()=>{if(!ze||typeof window>`u`)return{};try{let e=JSON.parse(window.localStorage.getItem(ze)||`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{}}}),He=(0,t.useCallback)(()=>{if(!(!ze||typeof window>`u`))try{window.localStorage.setItem(ze,JSON.stringify(Be))}catch{}},[ze,Be]),Ue=(0,t.useCallback)((e,t)=>{Ve(n=>({...n,[e]:t}))},[]),We=(0,t.useCallback)(()=>Ve({}),[]),Ge=(0,t.useCallback)(e=>!!k?.objectField&&!String(e?.[k.objectField]??``).trim(),[k?.objectField]),Ke=(0,t.useCallback)(e=>{let t=(k?.objectField?String(e[k.objectField]??``).trim():``)||j,n=e.id??e._id;if(!t||n==null)return null;let r=j?(0,c.deriveRecordPageHref)(j,n):null;return{objectName:t,recordId:n,href:!j||t===j?r:r?.replace(`/${j}/record/`,`/${t}/record/`)??null}},[k?.objectField,j]),qe=(0,t.useMemo)(()=>{let e=Object.entries(Be).filter(([,e])=>e.length>0);if(!e.length)return Oe;let t=new Map(Oe.map(e=>[String(e.id),e])),n=new Set;for(let r of Oe){if(!e.every(([e,t])=>{let n=L(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 Oe.filter(e=>n.has(String(e.id)))},[Oe,Be,L]),Je=(0,t.useMemo)(()=>{if(k?.autoZoomToFilter!==!1||!Oe.length)return null;let e=1/0,t=-1/0;for(let n of Oe){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)}},[Oe,k?.autoZoomToFilter]),Xe=e.navigation??{mode:`drawer`},R=Xe.mode===`drawer`||Xe.mode===`modal`||Xe.mode===`split`||Xe.mode===`popover`,Ze=(0,t.useCallback)((e,t)=>{if(typeof window>`u`)return;let n=String(e),r=Oe.find(e=>{let t=e.data;return!!t&&String(t.id??t._id)===n})?.data,i=r?Ke(r)?.href??null:j?(0,c.deriveRecordPageHref)(j,e):null;if(i){if(t===`new_window`){window.open(i,`_blank`);return}window.history.pushState({},``,i),window.dispatchEvent(new PopStateEvent(`popstate`))}},[Oe,Ke,j]),z=(0,r.useNavigationOverlay)({navigation:Xe,objectName:e.objectName,onNavigate:Ze,onRowClick:R?void 0:g}),{anchorRef:Qe,anchorCaptureProps:$e}=(0,u.useOverlayAnchor)(),[B,V]=(0,t.useState)(null),tt=z.isOverlay&&z.isOpen?z.selectedRecord:null;(0,t.useEffect)(()=>{if(!tt){V(null);return}let e=Ke(tt);if(!e){V(null);return}let{objectName:t,recordId:n}=e;if(t===j||!f||typeof f.findOne!=`function`){V(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||V(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||V(null)}})(),()=>{i=!0}},[tt,Ke,j,f]);let nt=(0,t.useCallback)(async(e,t)=>{if(!k||!A||typeof A.update!=`function`)return;let{startDateField:n,endDateField:r,titleField:i,progressField:a}=k,o=M?.fields,s=e.data??{},c=pe(k.timeZone),l={};if(t.start instanceof Date&&(l[n]=U(t.start,o?.[n]?.type,s[n],c)),t.end instanceof Date&&(l[r]=U(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 A.update(j,String(u),l),we({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist task update:`,e),b(d),E(e)}},[k,A,j,y,we,E,M]),rt=(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)},it=(0,t.useCallback)(async(e,t,n)=>{let r=k?.dependenciesField;if(!r||!A||typeof A.update!=`function`)return;let i=rt(t,n),a=y;b(t=>t.map(t=>String(t.id??t._id)===String(e)?{...t,[r]:i}:t));try{await A.update(j,String(e),{[r]:i}),we({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist dependency:`,e),b(a),E(e)}},[k,A,j,y,we,E]),at=(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=k?.dependenciesField;if(!a)return;let o=y.find(e=>String(e.id??e._id)===String(i))?.[a],s=ct(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 it(i,o,f)},[k,y,it]),st=(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=k?.dependenciesField;if(!i)return;let a=y.find(e=>String(e.id??e._id)===String(r))?.[i],o=ct(a),s=e=>String(typeof e==`object`?e.id:e),c=o.filter(e=>s(e)!==String(n));c.length!==o.length&&await it(r,a,c)},[k,y,it]),[ft,pt]=(0,t.useState)(null),[mt,ht]=(0,t.useState)(!1),_t=(0,t.useCallback)(e=>{pt(e)},[]),vt=(0,t.useCallback)(async()=>{if(!ft)return;if(!A?.delete){pt(null);return}let e=ft.data?.id??ft.data?._id??ft.id;if(e==null){pt(null);return}ht(!0);let t=y;b(t=>t.filter(t=>String(t.id??t._id)!==String(e)));try{if(await A.delete(j,String(e))===!1)throw Error(T(`gantt.writeFailed`));pt(null),we({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to delete:`,e),b(t),pt(null),E(e)}finally{ht(!1)}},[ft,A,j,y,we,E,T]),yt={objectSchema:M,objectName:j,perms:de},W=(0,n.resolveAffordance)(`rowEdit`,yt).allowed,bt=(0,n.resolveAffordance)(`rowDelete`,yt).allowed;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(!k)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 xt=t=>{if(!z.isOverlay||!z.isOpen||!z.selectedRecord)return null;let n=z.selectedRecord,r=Ke(n);if(!r||Ge(n))return null;let{objectName:i,recordId:a}=r,o=r.href??void 0,s=k?.titleField?String(n[k.titleField]??T(`gantt.drawer.fallbackTitle`)):T(`gantt.drawer.fallbackTitle`),l=!!e.readOnly||(k?.lockField?!!n[k.lockField]:!1),d=B?.key===`${i}:${a}`?B:null,m=d?.record??n,h=d?.schema??(i===j?M:void 0),g=d&&f?f:A;return(0,p.jsx)(u.NavigationOverlay,{...z,title:s,mainContent:t,popoverAnchorRef:Qe,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=lt(e);throw t?Error(t):e}d&&V(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)),we({silent:!0})}},onDelete:l?void 0:async()=>{if(A?.delete){try{if(await A.delete(i,String(a))===!1)throw Error(T(`gantt.writeFailed`))}catch(e){throw E(e),e}b(e=>e.filter(e=>String(e.id??e._id)!==String(a)))}}})})})},St=(0,p.jsxs)(`div`,{className:(0,u.cn)(`flex h-full min-h-0 flex-col`,m),...$e,children:[Le.length>0&&(0,p.jsx)(H,{filters:Le,value:Be,onChange:Ue,onClear:We,resultCount:qe.length,totalCount:Oe.length,labels:{all:T(`gantt.quickFilter.all`),clear:T(`gantt.quickFilter.clear`),empty:T(`gantt.quickFilter.empty`),resultSummary:(e,t)=>T(`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:P,ariaLabel:T(`gantt.aria.refreshing`)}),k?.resourceView&&Ae?(0,p.jsx)(et,{tasks:qe,assignee:Ae,effort:je,capacity:k?.capacity??1,viewMode:k?.viewMode||`day`}):(0,p.jsx)(Ye,{tasks:qe,viewMode:k?.viewMode,startDate:Je?.start,endDate:Je?.end,onTaskClick:e=>{Ge(e.data)||z.handleClick(e.data),h?.(e.data)},onTaskUpdate:W?nt:void 0,onTaskDelete:bt?_t:void 0,onDependencyCreate:W&&k?.dependenciesField?at:void 0,onDependencyDelete:W&&k?.dependenciesField?st:void 0,markers:e.markers,autoSchedule:!!k?.dependenciesField,rescheduleOnConflict:!!k?.dependenciesField,criticalPathDefault:!!e.criticalPath,workingCalendar:Me,shiftSegments:Ne,showBaselines:e.showBaselines!==!1,readOnly:!!e.readOnly,mobileReadOnly:e.mobileReadOnly!==!1,persistLayoutKey:Re,onLayoutChange:ze?He:void 0,groupBy:ke,defaultCollapsedDepth:k?.defaultCollapsedDepth,summaryExtent:k?.summaryExtent,interactions:k?.interactions,dependencyTypes:k?.dependencyTypes,timeZone:k?.timeZone,onBeforeTaskUpdate:_,exportFileName:String(k?.exportFileName??(0,o.resolveI18nLabel)(e.label,w)??M?.label??e.objectName??``)||void 0,inlineEdit:!0,onRefresh:O?.provider===`object`&&typeof A?.find==`function`?()=>we({silent:!0}):void 0,refreshing:P})]}),S&&(0,p.jsx)(r.NonGridRowCeilingNote,{result:S}),(0,p.jsx)(u.AlertDialog,{open:!!ft,onOpenChange:e=>{!e&&!mt&&pt(null)},children:(0,p.jsxs)(u.AlertDialogContent,{children:[(0,p.jsxs)(u.AlertDialogHeader,{children:[(0,p.jsx)(u.AlertDialogTitle,{children:T(`gantt.delete.title`)}),(0,p.jsx)(u.AlertDialogDescription,{children:ft?T(`gantt.delete.body`,{title:ft.title}):null})]}),(0,p.jsxs)(u.AlertDialogFooter,{children:[(0,p.jsx)(u.AlertDialogCancel,{disabled:mt,children:T(`gantt.delete.cancel`)}),(0,p.jsx)(u.AlertDialogAction,{onClick:e=>{e.preventDefault(),vt()},disabled:mt,"data-testid":`gantt-delete-confirm`,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:T(mt?`gantt.delete.deleting`:`gantt.delete.confirm`)})]})]})})]});if(z.isOverlay&&z.mode===`split`&&z.isOpen&&z.selectedRecord){let e=xt(St);if(e)return(0,p.jsx)(p.Fragment,{children:e})}return(0,p.jsxs)(p.Fragment,{children:[St,xt()]})},vt={filter:!0,sort:!0},yt=(0,n.elementDataSourceBlock)(({schema:e})=>{let{dataSource:t}=(0,r.useSchemaContext)()||{},n=t??void 0,{t:a}=(0,i.useObjectTranslation)();return(0,p.jsx)(r.ElementDataSourceGate,{schema:e,mapping:vt,dataSource:n,testId:`object-gantt`,errorTitle:a(`element.gantt.sourceUnresolved`,{defaultValue:`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`,yt,{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 — each `{ date, label?, color? }`: `date` places the line (a date outside the drawn range draws none), `label` is drawn against it, `color` paints it. `color` is a 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=Ye,e.ObjectGantt=_t,e.ObjectGanttRenderer=yt,e.QuickFilterBar=H,e.ResourceWorkload=et,e.bandAt=de,e.computeWorkload=R,e.normalizeDependencies=ct,e.normalizeShiftSegments=ue,e.normalizeTaskType=ot,e.parseHHMM=le,e.shiftDayStart=M});
|