@object-ui/plugin-gantt 13.2.0 → 14.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.
@@ -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("@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`,`@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._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){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var d=Object.create,f=Object.defineProperty,p=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyNames,h=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty,_=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=m(t),a=0,o=i.length,s;a<o;a++)s=i[a],!g.call(e,s)&&s!==n&&f(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=p(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:d(h(e)),_(t||!e||!e.__esModule?f(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);var v=1e3*60*60*24,y=e=>e.toISOString().slice(0,10);function b(e,t){if(t.skipWeekends){let t=e.getUTCDay();if(t===0||t===6)return!1}return!(t.holidays&&t.holidays.has(y(e)))}function x(e){let t=new Date(e);return t.setUTCHours(0,0,0,0),t}function S(e,t){let n=x(e);for(;!b(n,t);)n=new Date(n.getTime()+v);return n.getTime()}function ee(e,t,n){if(t<=e)return 0;let r=0,i=x(e),a=x(t).getTime();for(;i.getTime()<a;)b(i,n)&&r++,i=new Date(i.getTime()+v);return r}function C(e,t,n){if(t<=0)return x(e).getTime();let r=x(e),i=t;for(;i>0;)b(r,n)&&i--,r=new Date(r.getTime()+v);return r.getTime()}function w(e,t,n){if(t<=0)return x(e).getTime();let r=x(e),i=t;for(;i>0;)r=new Date(r.getTime()-v),b(r,n)&&i--;return r.getTime()}var T=e=>String(e);function E(e){return e===`ss`||e===`ff`||e===`sf`?e:`fs`}function te(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:E(r?i.type:void 0)})}}return n}function ne(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?ee(n.start.getTime(),n.end.getTime(),t):(n.end.getTime()-n.start.getTime())/v;r.set(T(n.id),Number.isFinite(e)&&e>0?e:0)}let i=te(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 y=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&&y.add(`${e.pred}->${e.succ}`);return{criticalIds:g,criticalEdges:y}}function ae(e,t){if(!e.length)return[];let n=te(e),r=e.map(e=>T(e.id)),{order:i,hasCycle:a}=re(r,n);if(a)return[];let o=ne(e),s=new Map;for(let t of e)s.set(T(t.id),t);let c=new Map;for(let e of r)c.set(e,[]);for(let e of n)c.get(e.succ).push(e);let l=new Map,u=new Map;for(let t of e)l.set(T(t.id),t.start.getTime()),u.set(T(t.id),t.end.getTime());for(let e of i){let n=s.get(e);if(!n)continue;let r=t?ee(l.get(e),u.get(e),t):u.get(e)-l.get(e),i=n.start.getTime();for(let n of c.get(e)??[]){let e=l.get(n.pred),a=u.get(n.pred),o;switch(n.type){case`ss`:o=e;break;case`ff`:o=t?w(a,r,t):a-r;break;case`sf`:o=t?w(e,r,t):e-r;break;default:o=a;break}o>i&&(i=o)}if(!o.has(e))if(t){let n=S(i,t);l.set(e,n),u.set(e,C(n,r,t))}else l.set(e,i),u.set(e,i+r)}let d=[];for(let t of e){let e=T(t.id);if(o.has(e))continue;let n=l.get(e),r=u.get(e);(n!==t.start.getTime()||r!==t.end.getTime())&&d.push({id:e,start:new Date(n),end:new Date(r)})}return d}var D=6e4;1440*D;var oe=1440;function O(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 se(e){if(!e||!Array.isArray(e.bands)||e.bands.length===0)return null;let t=O(e.dayStart)??0,n=[];for(let t=0;t<e.bands.length;t++){let r=e.bands[t],i=O(r.start),a=O(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*D})}return{dayStartMin:t,bands:n,showMidnight:e.showMidnight!==!1}}function ce(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 le(e,t){if(t.bands.length===0)return null;let n=ce(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 ue={"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.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.locate":`Locate on timeline`,"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.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.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.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.`};function de(e,t){let n=ue[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}function fe(){try{let e=(0,r.useObjectTranslation)();return{t:(t,n)=>{let r=e.t(t,n);return typeof r==`string`&&r!==t?r:de(t,n)},language:e.language}}catch{return{t:de,language:void 0}}}function pe(e){return 110}function me(e){return e<640?140:e<1024?220:320}function he(e){return e>=280}function ge(e){return e<640?32:40}var k=[`day`,`week`,`month`,`quarter`,`year`],_e={day:1,week:7,month:30.44,quarter:91.31,year:365.25},ve=1e3*60*60*24;function ye(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 be(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 xe(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 Se(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 A(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 Ce(e,t,n){let r=e=>{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t},i=`q ${t} 0 0 ${n} 0 0 cm /Im0 Do Q`,a=[],o=[],s=0,c=e=>{a.push(e),s+=e.length},l=()=>{o.push(s)};c(r(`%PDF-1.3
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("sonner"),require("@objectstack/spec/ui"),require("@object-ui/i18n"),require("@object-ui/plugin-detail"),require("@object-ui/components"),require("@object-ui/fields"),require("lucide-react"),require("qrcode"),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`,`qrcode`,`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.qrcode,e.react_jsx_runtime))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var p=Object.create,m=Object.defineProperty,h=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyNames,_=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty,ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=g(t),a=0,o=i.length,s;a<o;a++)s=i[a],!v.call(e,s)&&s!==n&&m(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=h(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:p(_(e)),ee(t||!e||!e.__esModule?m(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);var y=1e3*60*60*24,b=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(b(e)))}function ne(e){let t=new Date(e);return t.setUTCHours(0,0,0,0),t}function x(e,t){let n=ne(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=ne(e),a=ne(t).getTime();for(;i.getTime()<a;)te(i,n)&&r++,i=new Date(i.getTime()+y);return r}function re(e,t,n){if(t<=0)return ne(e).getTime();let r=ne(e),i=t;for(;i>0;)te(r,n)&&i--,r=new Date(r.getTime()+y);return r.getTime()}function C(e,t,n){if(t<=0)return ne(e).getTime();let r=ne(e),i=t;for(;i>0;)r=new Date(r.getTime()-y),te(r,n)&&i--;return r.getTime()}var w=e=>String(e);function ie(e){return e===`ss`||e===`ff`||e===`sf`?e:`fs`}function T(e){let t=new Set(e.map(e=>w(e.id))),n=[];for(let r of e){let e=w(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=w(a);o===e||!t.has(o)||n.push({pred:o,succ:e,type:ie(r?i.type:void 0)})}}return n}function E(e){let t=new Set;for(let n of e)n.parent!=null&&n.parent!==``&&t.add(w(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?S(n.start.getTime(),n.end.getTime(),t):(n.end.getTime()-n.start.getTime())/y;r.set(w(n.id),Number.isFinite(e)&&e>0?e:0)}let i=T(e),a=e.map(e=>w(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 se(e,t){if(!e.length)return[];let n=T(e),r=e.map(e=>w(e.id)),{order:i,hasCycle:a}=ae(r,n);if(a)return[];let o=E(e),s=new Map;for(let t of e)s.set(w(t.id),t);let c=new Map;for(let e of r)c.set(e,[]);for(let e of n)c.get(e.succ).push(e);let l=new Map,u=new Map;for(let t of e)l.set(w(t.id),t.start.getTime()),u.set(w(t.id),t.end.getTime());for(let e of i){let n=s.get(e);if(!n)continue;let r=t?S(l.get(e),u.get(e),t):u.get(e)-l.get(e),i=n.start.getTime();for(let n of c.get(e)??[]){let e=l.get(n.pred),a=u.get(n.pred),o;switch(n.type){case`ss`:o=e;break;case`ff`:o=t?C(a,r,t):a-r;break;case`sf`:o=t?C(e,r,t):e-r;break;default:o=a;break}o>i&&(i=o)}if(!o.has(e))if(t){let n=x(i,t);l.set(e,n),u.set(e,re(n,r,t))}else l.set(e,i),u.set(e,i+r)}let d=[];for(let t of e){let e=w(t.id);if(o.has(e))continue;let n=l.get(e),r=u.get(e);(n!==t.start.getTime()||r!==t.end.getTime())&&d.push({id:e,start:new Date(n),end:new Date(r)})}return d}function D(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 O=6e4;1440*O;var ce=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+ce)%ce||ce;n.push({key:r.key??`band${t}`,label:r.label,color:r.color,durMs:o*O})}return{dayStartMin:t,bands:n,showMidnight:e.showMidnight!==!1}}function de(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 k(e,t){if(t.bands.length===0)return null;let n=de(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 fe={"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.qrcode":`Mobile QR code`,"gantt.qr.title":`Open on mobile`,"gantt.qr.hint":`Scan with a phone to open the details`,"gantt.qr.copy":`Copy link`,"gantt.qr.copied":`Copied`,"gantt.qr.close":`Close`,"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.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.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 A(e,t){let n=fe[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}function pe(){try{let e=(0,r.useObjectTranslation)();return{t:(t,n)=>{let r=e.t(t,n);return typeof r==`string`&&r!==t?r:A(t,n)},language:e.language}}catch{return{t:A,language:void 0}}}var me=8;function he(e,t){if(t.width<=0)return`move`;let n=Math.min(me,t.width/3),r=e-t.left;return r<=n?`resize-left`:r>=t.width-n?`resize-right`:`move`}function ge(e){return 110}function _e(e){return e<640?140:e<1024?220:320}function ve(e){return e>=280}function ye(e){return e<640?32:40}var j=[`day`,`week`,`month`,`quarter`,`year`],be={day:1,week:7,month:30.44,quarter:91.31,year:365.25},xe=1e3*60*60*24;function Se(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 Ce(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 we(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 Te(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 Ee(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 De(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,12 +12,14 @@ 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 we(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 j=`gantt-layout:`;function Te(e){if(!e||typeof window>`u`)return null;try{let t=window.localStorage.getItem(j+e);if(!t)return null;let n=JSON.parse(t),r=n.viewMode&&k.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;return{viewMode:r,columnWidth:i,taskListCollapsed:!!n.taskListCollapsed,taskListWidth:a}}catch{return null}}function Ee(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(j+e,JSON.stringify(t))}catch{}}function De({tasks:e,viewMode:n,startDate:r,endDate:i,markers:a,onTaskClick:o,onTaskUpdate:c,onTaskDelete:d,onViewChange:f,onDependencyCreate:p,onDependencyDelete:m,onTaskReorder:h,className:g,inlineEdit:_=!1,autoSchedule:v=!1,rescheduleOnConflict:y=!1,criticalPathDefault:b=!1,workingCalendar:x,shiftSegments:S,showBaselines:ee=!0,readOnly:C=!1,mobileReadOnly:w=!1,groupBy:T,ungroupedLabel:E=`Ungrouped`,defaultCollapsedDepth:te,persistLayoutKey:ne,onLayoutChange:re}){let{t:D,language:oe}=fe(),O=oe||void 0,[se,le]=t.useState(new Date),ue=t.useRef(null),{width:de}=(0,s.useResizeObserver)(ue),j=de||(typeof window<`u`?window.innerWidth:1024),De=j<640,M=C||w&&De,N=M?void 0:c,Oe=M?void 0:d,P=M?void 0:p,ke=M?void 0:m,Ae=M?void 0:h,je=M?!1:_,Me=M?!1:v,Ne=M?!1:y,F=ge(j),Pe=pe(j),Fe=t.useRef(void 0);Fe.current===void 0&&(Fe.current=Te(ne));let Ie=Fe.current,[Le,Re]=t.useState(Ie?Ie.columnWidth:null),[ze,Be]=t.useState(Ie?Ie.taskListWidth??null:null),[I,Ve]=t.useState(n&&k.includes(n)?n:Ie?.viewMode??`day`);t.useEffect(()=>{n&&k.includes(n)&&Ve(n)},[n]);let He=t.useRef(null),Ue=t.useRef(null),We=t.useRef(!0),[Ge,Ke]=t.useState(Ie?Ie.taskListCollapsed:!1),qe=t.useRef(!1);t.useEffect(()=>{!qe.current&&De&&(Ke(!0),qe.current=!0)},[De]);let Je=Math.max(160,j-200),L=Ge?0:ze==null?me(j):Math.max(160,Math.min(ze,Je)),Ye=t.useMemo(()=>{if(Le!=null||i||e.length===0)return null;let t=r?new Date(r):new Date(Math.min(...e.map(e=>e.start.getTime()))),n=new Date(Math.max(...e.map(e=>e.end.getTime())));r||t.setDate(t.getDate()-7),n.setDate(n.getDate()+14),t=ye(t,I),n.setHours(23,59,59,999);let a=Math.max(1,(n.getTime()-t.getTime())/ve),o=Math.max(0,j-L);if(o<=0)return null;let s=o/a*_e[I];if(s<=Pe)return null;let c=Math.min(s,o*.6);return c>Pe?c:null},[Le,e,r,i,I,j,L,Pe]),R=Le??Ye??Pe,Xe=R/_e[I],Ze=he(L),[Qe,$e]=t.useState(null),[et,tt]=t.useState({}),[nt,rt]=t.useState(null),z=t.useMemo(()=>{if(!T)return e;let t=new Set;for(let n of e){let e=n.parent!=null&&n.parent!==``?String(n.parent):null;e&&t.add(e)}let n=new Map;for(let r of e){if(t.has(String(r.id)))continue;let e=T(r),i=e?String(e.key):`__ungrouped__`,a=e?e.label:E,o=n.get(i);o||(o={key:i,label:a,items:[]},n.set(i,o)),o.items.push(r)}let r=[];for(let e of n.values()){let t=`__group__${e.key}`,n=e.items[0];r.push({id:t,title:e.label,start:n.start,end:n.end,progress:0,type:`summary`,parent:null,data:{__group:!0}});for(let n of e.items)r.push({...n,parent:t})}return r},[T,e,E]),it=t.useMemo(()=>{let e=new Set(z.map(e=>String(e.id))),t=new Map;for(let n of z){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},[z]),at=t.useMemo(()=>{let e=new Map;for(let t of z)e.set(String(t.id),t);return e},[z]),ot=t.useCallback(e=>{let t=[],n=new Set,r=e=>{for(let i of it.get(e)??[]){let e=String(i.id);n.has(e)||(n.add(e),t.push(i),r(e))}};return r(String(e)),t},[it]),[B,st]=t.useState(null),ct=t.useRef(null);t.useEffect(()=>{ct.current=B},[B]);let lt=t.useRef(!1),ut=t.useCallback(e=>{let t=I===`day`&&S&&S.bands.length>0&&S?Math.min(...S.bands.map(e=>e.durMs)):ve,n=(e,t)=>an.current?an.current(e,t):xe(e,t,I),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}},[I,S]),dt=t.useRef(e);dt.current=e;let ft=t.useRef([]),pt=t.useRef([]),[mt,ht]=t.useState(0),V=t.useCallback(e=>{if(!N)return;let t=[];for(let{task:n,changes:r}of e){let e={},i={},a=!1;for(let t of Object.keys(r)){let o=r[t],s=n[t],c=o instanceof Date&&s instanceof Date?o.getTime()===s.getTime():o===s;e[t]=s,i[t]=o,c||(a=!0)}N(n,r),a&&t.push({taskId:String(n.id),before:e,after:i})}t.length&&(ft.current.push(t),pt.current=[],ht(e=>e+1))},[N]),[gt,_t]=t.useState(null),vt=t.useCallback(e=>{if(!Ne)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 n=ae(dt.current.map(e=>{let n=t.get(String(e.id));return n?{...e,start:n.start,end:n.end}:e}),x).filter(e=>{let n=t.get(e.id);return!n||e.start.getTime()!==n.start.getTime()||e.end.getTime()!==n.end.getTime()});n.length&&_t(n)},[Ne,x]),yt=t.useCallback(()=>{if(!gt)return;let e=gt.map(e=>{let t=dt.current.find(t=>String(t.id)===e.id);return t?{task:t,changes:{start:e.start,end:e.end}}:null}).filter(Boolean);e.length&&V(e),_t(null)},[gt,V]),bt=t.useCallback((e,t)=>{if(N)for(let n of e){let e=dt.current.find(e=>String(e.id)===n.taskId);e&&N(e,t===`undo`?n.before:n.after)}},[N]),xt=t.useCallback(()=>{let e=ft.current.pop();e&&(bt(e,`undo`),pt.current.push(e),ht(e=>e+1))},[bt]),St=t.useCallback(()=>{let e=pt.current.pop();e&&(bt(e,`redo`),ft.current.push(e),ht(e=>e+1))},[bt]),{canUndo:Ct,canRedo:wt}=t.useMemo(()=>({canUndo:ft.current.length>0,canRedo:pt.current.length>0}),[mt]);t.useEffect(()=>{if(!B)return;let t=I===`day`&&S&&S.bands.length>0&&S?Xe*Math.min(...S.bands.map(e=>e.durMs))/ve:R,n=e=>{let n=ct.current;if(!n)return;let r=Math.round((e.clientX-n.originClientX)/Math.max(t,1));r!==n.unitDelta&&st({...n,unitDelta:r})},r=()=>{let t=ct.current;if(t){if(t.unitDelta!==0){let n=e.find(e=>e.id===t.taskId);if(n&&N){let{start:e,end:r}=ut(t);if(t.group){let r=e.getTime()-t.originStart.getTime(),i=[n,...ot(n.id)].map(e=>({task:e,changes:{start:new Date(e.start.getTime()+r),end:new Date(e.end.getTime()+r)}}));V(i),vt(i)}else{let t=[{task:n,changes:{start:e,end:r}}];V(t),vt(t)}}lt.current=!0,window.setTimeout(()=>{lt.current=!1},0)}st(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)}},[B,R,Xe,I,S,e,N,ut,ot,V,vt]);let Tt=t.useCallback((e,t,n,r)=>{!N||e.data?.__group||(n.stopPropagation(),n.preventDefault(),st({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}))},[N]),[Et,Dt]=t.useState(null),Ot=t.useRef(null);t.useEffect(()=>{Ot.current=Et},[Et]),t.useEffect(()=>{if(!Et)return;let t=e=>{let t=Ot.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&&Dt({...t,value:n})},n=()=>{let t=Ot.current;if(t){if(t.value!==t.originProgress){let n=e.find(e=>e.id===t.taskId);n&&N&&V([{task:n,changes:{progress:t.value}}]),lt.current=!0,window.setTimeout(()=>{lt.current=!1},0)}Dt(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)}},[Et,e,N,V]);let kt=t.useRef(null),[H,At]=t.useState(null),jt=t.useRef(null);t.useEffect(()=>{jt.current=H},[H]),t.useEffect(()=>{if(!H)return;let t=e=>{let t=kt.current?.getBoundingClientRect();if(!t)return;let n=e.clientX-t.left,r=e.clientY-t.top;At(e=>e&&{...e,x:n,y:r})},n=()=>{let t=jt.current;if(t&&t.targetId!=null&&String(t.targetId)!==String(t.sourceId)&&P){let n=e.find(e=>String(e.id)===String(t.sourceId)),r=e.find(e=>String(e.id)===String(t.targetId)),i=t.targetEnd??`start`,a=`${t.sourceEnd===`end`?`f`:`s`}${i===`end`?`f`:`s`}`;n&&r&&P(n,r,a)}lt.current=!0,window.setTimeout(()=>{lt.current=!1},0),At(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)}},[H,e,P]);let[Mt,Nt]=t.useState(null),Pt=t.useRef(null);t.useEffect(()=>{if(!Mt)return;let e=e=>{Pt.current&&e.target instanceof Node&&Pt.current.contains(e.target)||Nt(null)},t=e=>{e.key===`Escape`&&Nt(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[Mt]);let[U,Ft]=t.useState(null),It=t.useRef(null);t.useEffect(()=>{if(!U)return;let e=e=>{It.current&&e.target instanceof Node&&It.current.contains(e.target)||Ft(null)},t=e=>{e.key===`Escape`&&Ft(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[U]);let[Lt,Rt]=t.useState(null),zt=t.useRef(null);t.useEffect(()=>{if(!Lt)return;let e=e=>{zt.current&&e.target instanceof Node&&zt.current.contains(e.target)||Rt(null)},t=e=>{e.key===`Escape`&&Rt(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[Lt]);let[Bt,Vt]=t.useState(null),Ht=!!(o||N||P||Oe),Ut=t.useCallback((e,t)=>{t.preventDefault(),t.stopPropagation(),Vt(e.id),Ht&&Nt({x:t.clientX,y:t.clientY,taskId:e.id})},[Ht]),Wt=t.useCallback((e,t,n,r)=>{r.preventDefault(),r.stopPropagation(),!(!P&&!ke)&&Ft({x:r.clientX,y:r.clientY,sourceId:e,targetId:t,type:n})},[P,ke]),[Gt,Kt]=t.useState(()=>new Set),qt=t.useCallback(e=>{Kt(t=>{let n=new Set(t),r=String(e);return n.has(r)?n.delete(r):n.add(r),n})},[]),Jt=t.useRef(!1);t.useEffect(()=>{if(Jt.current||te==null||z.length===0)return;Jt.current=!0;let e=new Map(z.map(e=>[String(e.id),e])),t=new Set;for(let n of z){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 z){let i=String(e.id);t.has(i)&&n(e)>=te&&r.add(i)}r.size&&Kt(e=>e.size?e:r)},[te,z]);let W=t.useMemo(()=>{let e=new Set(z.map(e=>String(e.id))),t=new Map,n=[];for(let r of z){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(),ve);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?i(e,new Set):{start:e.start,end:e.end,progress:e.progress},p=!d&&(e.type===`milestone`||e.end.getTime()<=e.start.getTime());if(a.push({task:e,depth:n,hasChildren:u,isSummary:d,isMilestone:p,...f}),u)if(Gt.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 z)o.has(String(e.id))||c(e,0);return a},[z,Gt]),Yt=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?St():xt();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`Y`)){e.preventDefault(),St();return}if(!W.length)return;let t=Bt==null?-1:W.findIndex(e=>String(e.task.id)===String(Bt));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?Math.min(W.length-1,t+1):Math.max(0,t<=0?0:t-1);Vt(W[n].task.id);let r=X.current;if(r){let e=n*F;e<r.scrollTop?r.scrollTop=e:e+F>r.scrollTop+r.clientHeight&&(r.scrollTop=e+F-r.clientHeight)}return}if(t<0)return;let n=W[t];e.key===`Enter`?(e.preventDefault(),o?.(n.task)):e.key===`Delete`||e.key===`Backspace`?Oe&&(e.preventDefault(),Oe(n.task)):(e.key===`ArrowRight`&&n.hasChildren&&Gt.has(String(n.task.id))||e.key===`ArrowLeft`&&n.hasChildren&&!Gt.has(String(n.task.id)))&&(e.preventDefault(),qt(n.task.id))},[W,Bt,o,Oe,Gt,qt,F,xt,St]),G=t.useMemo(()=>{let t=r?new Date(r):new Date,n=i?new Date(i):new Date;return!r&&e.length>0&&(t=new Date(Math.min(...e.map(e=>e.start.getTime()))),t.setDate(t.getDate()-7)),!i&&e.length>0&&(n=new Date(Math.max(...e.map(e=>e.end.getTime()))),n.setDate(n.getDate()+14)),t=I===`day`&&S&&S.bands.length>0?ce(t,S.dayStartMin):ye(t,I),n.setHours(23,59,59,999),{start:t,end:n}},[r,i,e,I,S]),K=I===`day`&&!!S&&S.bands.length>0,Xt=!K&&I===`day`&&!!x&&(!!x.skipWeekends||!!(x.holidays&&x.holidays.size)),Zt=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]),q=t.useMemo(()=>{let e=[];if(K&&S){let t=new Date(G.start);for(;t<=G.end;)for(let n of S.bands){let r=n.durMs/ve*Xe;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(G.start);for(;t<=G.end;){let n=xe(t,1,I);if(Xt&&!Zt(t)){t=n;continue}let r=(n.getTime()-t.getTime())/ve*Xe,i,a;I===`day`?(i=String(t.getDate()),a=t.toLocaleDateString(O,{weekday:`narrow`})):i=I===`week`?t.toLocaleDateString(O,{month:`numeric`,day:`numeric`}):I===`month`?t.toLocaleDateString(O,{month:`short`}):I===`quarter`?`Q${Math.floor(t.getMonth()/3)+1}`:String(t.getFullYear()),e.push({date:new Date(t),label:i,sublabel:a,isWeekend:I===`day`&&(t.getDay()===0||t.getDay()===6),width:r}),t=n}return e},[G,I,Xe,O,Xt,Zt,K,S]),J=t.useMemo(()=>{let e=Array(q.length+1),t=0;for(let n=0;n<q.length;n++)e[n]=t,t+=q[n].width;return e[q.length]=t,e},[q]),Qt=J[J.length-1],$t=t.useMemo(()=>q.map(e=>e.date.getTime()),[q]),en=t.useMemo(()=>q.map(e=>e.realMs==null?xe(e.date,1,I).getTime()-e.date.getTime():e.realMs),[q,I]),Y=t.useCallback(e=>{let t=q.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;$t[e]<=n?(a=e,r=e+1):i=e-1}let o=en[a]||864e5,s=(n-$t[a])/o;return(Xt||K)&&(s=Math.max(0,Math.min(s,1))),J[a]+s*q[a].width},[q,$t,en,J,Xt,K]),tn=t.useCallback(e=>{let t=q.length;if(t===0)return new Date(G.start);let n=0,r=t-1,i=0;for(;n<=r;){let t=n+r>>1;J[t]<=e?(i=t,n=t+1):r=t-1}let a=q[i].width||1,o=(e-J[i])/a;return new Date($t[i]+o*(en[i]||864e5))},[q,$t,en,J,G]),nn=t.useCallback(e=>{let t=X.current;Ue.current==null&&t&&t.clientWidth>0&&(Ue.current=tn(t.scrollLeft)),He.current=Ue.current,We.current=!0,Ve(e),f?.(e)},[f,tn]);t.useLayoutEffect(()=>{let e=He.current;if(e==null)return;He.current=null;let t=X.current;if(!t||t.clientWidth===0)return;let n=Math.max(0,t.scrollWidth-t.clientWidth),r=Math.max(0,Math.min(Math.round(Y(ye(e,I))),n));t.scrollLeft!==r&&(t.scrollLeft=r)},[I,Y]);let rn=t.useCallback((e,t)=>{let n=q.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;$t[e]<=r?(o=e,i=e+1):a=e-1}let s=Math.min(n-1,Math.max(0,o+t)),c=r-$t[o];return new Date($t[s]+c)},[q,$t]),an=t.useRef(null);an.current=Xt||K?rn:null;let on=t.useMemo(()=>{let e=[];if(K&&S){let t=0;for(let n of q){let r=String(ce(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(O,{month:`short`,day:`numeric`}),width:n.width,offset:t}),t+=n.width}return e}let t=I===`year`?`decade`:I===`month`||I===`quarter`?`year`:`month`,n=0;for(let r of q){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(O,{month:`short`,year:`numeric`}),width:r.width,offset:n}),n+=r.width}return e},[q,I,O,K,S]),sn=t.useMemo(()=>(a??[]).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(Y(n)),valid:!isNaN(n.getTime())&&n>=G.start&&n<=G.end}}).filter(e=>e.valid),[a,G,Y]),cn=t.useRef(null),ln=t.useRef(null),un=t.useRef(null),X=t.useRef(null);t.useEffect(()=>{let e=X.current;if(!e)return;let t=()=>{We.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[dn,fn]=t.useState(null),pn=t.useRef([]),mn=t.useRef(null),[hn,gn]=t.useState({top:0,left:0}),[_n,vn]=t.useState({width:4e3,height:600}),yn=t.useCallback(()=>{let e=X.current;if(!e)return;let t=e.clientWidth||4e3,n=e.clientHeight||600;vn(e=>e.width===t&&e.height===n?e:{width:t,height:n})},[]);t.useLayoutEffect(()=>{yn();let e=X.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(yn);return t.observe(e),()=>t.disconnect()},[yn]);let bn=t.useMemo(()=>be(J,hn.left-240,hn.left+_n.width+240),[J,hn.left,_n.width]),xn=t.useMemo(()=>{let e=on.map(e=>e.offset);return e.push(Qt),e},[on,Qt]),Sn=t.useMemo(()=>be(xn,hn.left-240,hn.left+_n.width+240),[xn,hn.left,_n.width]),Z=t.useMemo(()=>({startIdx:Math.max(0,Math.floor(hn.top/F)-6),endIdx:Math.min(W.length,Math.ceil((hn.top+_n.height)/F)+6)}),[hn.top,_n.height,F,W.length]),Cn=W.length*F,[wn,Tn]=t.useState(!1);t.useEffect(()=>{let e=()=>Tn(!!document.fullscreenElement);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let En=t.useCallback(()=>{let e=ue.current;e&&(document.fullscreenElement?document.exitFullscreen?.():e.requestFullscreen?.())},[]),Dn=t.useRef(null),On=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;Dn.current={baseDistance:Math.max(1,Math.sqrt(t*t+n*n)),baseColumn:R}}},[R]),kn=t.useCallback(e=>{if(e.touches.length!==2||!Dn.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))/Dn.current.baseDistance,i=Math.max(15,Math.min(120,Math.round(Dn.current.baseColumn*r)));Re(i)},[]),An=t.useCallback(()=>{Dn.current=null},[]),Q=t.useMemo(()=>{let e=new Date;return e<G.start||e>G.end?null:Math.round(Y(e))},[G,Y]),jn=t.useCallback(()=>{if(Q==null||!X.current)return;let e=Math.max(0,Q-X.current.clientWidth/2);X.current.scrollTo({left:e,behavior:`smooth`})},[Q]),Mn=t.useRef(!1);t.useEffect(()=>{if(Mn.current||e.length===0)return;let t=window.requestAnimationFrame(()=>{let t=X.current;if(!t||t.clientWidth===0)return;let n=Q;if(n==null){let t=new Date(Math.min(...e.map(e=>e.start.getTime())));n=Math.round(Y(t))}t.scrollLeft=Math.max(0,n-t.clientWidth/2),Mn.current=!0});return()=>window.cancelAnimationFrame(t)},[e,Q,Y]);let Nn=t.useCallback((e,t=`left`)=>{let n=X.current;if(!n||e<G.start||e>G.end)return!1;let r=Math.round(Y(e)),i=t===`center`?r-n.clientWidth/2:r-24;return n.scrollTo({left:Math.max(0,i),behavior:`smooth`}),!0},[G,Y]),Pn=t.useCallback((e,t,n)=>{let r=X.current;if(!r)return;let i=Y(e),a=Y(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));pn.current.forEach(e=>window.clearTimeout(e)),pn.current=[],mn.current?.(),mn.current=null,fn(null);let u=()=>{if(n==null)return;let e=window.requestAnimationFrame(()=>{fn(n),pn.current.push(window.setTimeout(()=>fn(e=>e===n?null:e),1500))});mn.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),pn.current.push(window.setTimeout(m,f?1500:500)),mn.current=()=>r.removeEventListener(`scrollend`,m)},[Y]);t.useEffect(()=>()=>{pn.current.forEach(e=>window.clearTimeout(e)),mn.current?.()},[]);let Fn=t.useCallback(()=>Nn(ye(new Date,`week`)),[Nn]),In=t.useCallback(()=>Nn(ye(new Date,`month`)),[Nn]),Ln=e=>{let t=e.currentTarget;!We.current&&t.clientWidth>0&&(Ue.current=tn(t.scrollLeft)),cn.current&&(cn.current.scrollLeft=t.scrollLeft),ln.current&&ln.current.scrollTop!==t.scrollTop&&(ln.current.scrollTop=t.scrollTop),gn(e=>e.top===t.scrollTop&&e.left===t.scrollLeft?e:{top:t.scrollTop,left:t.scrollLeft}),yn()},Rn=e=>{let t=e.currentTarget,n=X.current;n&&n.scrollTop!==t.scrollTop&&(n.scrollTop=t.scrollTop),gn(e=>e.top===t.scrollTop?e:{...e,top:t.scrollTop})},zn=(e,t)=>{let n=Y(e),r=K&&S?Xe*Math.min(...S.bands.map(e=>e.durMs))/ve:Xe;return{left:n,width:Math.max(Y(t)-n,r,3)}},Bn=B?.group?B.taskId:null,Vn=t.useMemo(()=>{if(Bn==null)return null;let e=new Set([String(Bn)]);for(let t of ot(Bn))e.add(String(t.id));return e},[Bn,ot]),Hn=t.useMemo(()=>{if(!B||B.group)return null;let e=new Set,t=new Set,n=at.get(String(B.taskId));for(;n&&n.parent!=null&&n.parent!==``;){let r=String(n.parent);if(t.has(r)||!at.has(r))break;t.add(r),e.add(r),n=at.get(r)}return e.size?e:null},[B,at]),Un=e=>{if(B){if(Vn?.has(String(e.task.id))){let t=ut(B).start.getTime()-B.originStart.getTime();return zn(new Date(e.start.getTime()+t),new Date(e.end.getTime()+t))}if(!e.isSummary&&B.taskId===e.task.id){let e=ut(B);return zn(e.start,e.end)}if(e.isSummary&&Hn?.has(String(e.task.id))){let t=ut(B),n=String(B.taskId),r=null,i=null;for(let a of ot(e.task.id)){if((it.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 zn(r,i)}}return zn(e.start,e.end)},Wn=t.useMemo(()=>{let e=new Map;W.forEach((t,n)=>e.set(String(t.task.id),n));let t=[];return W.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},[W]),Gn=Math.max(2,Math.round(F/2)-14),Kn=F-Gn*2,qn=Math.round(Kn/2),Jn=Math.max(Math.round(F*.4),12),Yn=Jn*Math.SQRT2/2,Xn=Kn,Zn=Gn,Qn=Math.max(3,Math.round(F*.13)),$n=F-Qn-1,er=`rgba(100, 116, 139, 0.35)`,tr=`rgba(100, 116, 139, 0.6)`,nr=e=>{let t=W[e.sourceIndex],n=W[e.targetIndex];if(!t||!n)return null;let r=Un(t),i=Un(n),a=e=>e.isSummary?Zn+Xn/2:F/2,o=e.sourceIndex*F+a(t),s=e.targetIndex*F+a(n),c=e.type===`fs`||e.type===`ff`,l=e.type===`ff`||e.type===`sf`,u=t.isMilestone?r.left+(c?Yn:-Yn):c?r.left+r.width:r.left,d=n.isMilestone?i.left+(l?Yn:-Yn):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)*F:e.sourceIndex*F;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(` `)},rr=B?.taskId??nt,[ir,ar]=t.useState(b),or=t.useMemo(()=>ir?ie(e,x):null,[ir,e,x]),sr=t.useCallback(e=>or?.criticalIds.has(String(e))??!1,[or]),$=`#dc2626`,cr=t.useCallback(()=>{if(!N)return;let t=ae(e,x),n=[];for(let r of t){let t=e.find(e=>String(e.id)===r.id);t&&n.push({task:t,changes:{start:r.start,end:r.end}})}V(n)},[e,N,x,V]),lr=t.useCallback(()=>{if(typeof document>`u`||!e.length)return null;let t=e=>String(e).replace(/[&<>"]/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`})[e]),n=Math.max(L,200),r=Math.ceil(n+Qt),i=Math.ceil(36+W.length*F),a=or?.criticalEdges??null,o=[];o.push(`<rect x="0" y="0" width="${r}" height="${i}" fill="#ffffff"/>`),o.push(`<rect x="0" y="0" width="${r}" height="36" fill="#f8fafc"/>`),o.push(`<g transform="translate(${n},0)" font-family="sans-serif" font-size="10" fill="#475569">`),on.forEach(e=>{o.push(`<line x1="${e.offset.toFixed(1)}" y1="0" x2="${e.offset.toFixed(1)}" y2="36" stroke="#e2e8f0"/>`),o.push(`<text x="${(e.offset+e.width/2).toFixed(1)}" y="12" text-anchor="middle" font-weight="600">${t(e.label)}</text>`)}),q.forEach((e,n)=>{let r=J[n];o.push(`<line x1="${r.toFixed(1)}" y1="18" x2="${r.toFixed(1)}" y2="${i}" stroke="#eef2f7"/>`),o.push(`<text x="${(r+e.width/2).toFixed(1)}" y="30" text-anchor="middle" fill="#1f2937">${t(e.label)}</text>`)}),o.push(`</g>`),o.push(`<line x1="0" y1="18" x2="${r}" y2="18" stroke="#e2e8f0"/>`),o.push(`<line x1="0" y1="36" x2="${r}" y2="36" stroke="#cbd5e1"/>`),o.push(`<line x1="${n}" y1="0" x2="${n}" y2="${i}" stroke="#cbd5e1"/>`),o.push(`<g transform="translate(0,36)" font-family="sans-serif" font-size="11" fill="#1f2937">`),W.forEach((e,r)=>{let i=r*F;o.push(`<line x1="0" y1="${(i+F).toFixed(1)}" x2="${n}" y2="${(i+F).toFixed(1)}" stroke="#f1f5f9"/>`);let a=8+e.depth*14,s=Math.max(4,Math.floor((n-a)/6.5)),c=e.task.title.length>s?e.task.title.slice(0,s-1)+`…`:e.task.title,l=e.isSummary?` font-weight="600"`:``;o.push(`<text x="${a}" y="${(i+F/2+4).toFixed(1)}"${l}>${t(c)}</text>`)}),o.push(`</g>`),o.push(`<g transform="translate(${n},36)" font-family="sans-serif" font-size="9">`),W.forEach((e,t)=>{let n=t*F,{left:r,width:i}=zn(e.start,e.end),a=sr(e.task.id),s=a?` stroke="${$}" stroke-width="2"`:``;if(ee&&e.task.baselineStart&&e.task.baselineEnd){let t=zn(e.task.baselineStart,e.task.baselineEnd);o.push(`<rect x="${t.left.toFixed(1)}" y="${(n+$n).toFixed(1)}" width="${Math.max(2,t.width).toFixed(1)}" height="${Qn}" rx="1" fill="${er}" stroke="${tr}"/>`)}if(e.isMilestone){let t=r,i=n+F/2,s=Jn/2,c=a?$:e.task.color||`#3b82f6`;o.push(`<polygon points="${t},${i-s} ${t+s},${i} ${t},${i+s} ${t-s},${i}" fill="${c}"/>`)}else if(e.isSummary){let t=e.task.color||`#64748b`;o.push(`<rect x="${r.toFixed(1)}" y="${(n+Zn).toFixed(1)}" width="${i.toFixed(1)}" height="${Xn}" rx="3" fill="${t}"${s}/>`);let a=i*Math.min(100,Math.max(0,e.progress))/100;o.push(`<rect x="${r.toFixed(1)}" y="${(n+Zn).toFixed(1)}" width="${a.toFixed(1)}" height="${Xn}" rx="3" fill="rgba(0,0,0,0.2)"/>`)}else{let t=e.task.color||`#3b82f6`;o.push(`<rect x="${r.toFixed(1)}" y="${(n+Gn).toFixed(1)}" width="${i.toFixed(1)}" height="${Kn}" rx="3" fill="${t}"${s}/>`);let a=i*Math.min(100,Math.max(0,e.progress))/100;o.push(`<rect x="${r.toFixed(1)}" y="${(n+Gn).toFixed(1)}" width="${a.toFixed(1)}" height="${Kn}" rx="3" fill="rgba(0,0,0,0.18)"/>`),i>=24&&o.push(`<text x="${(r+i/2).toFixed(1)}" y="${(n+F/2+3).toFixed(1)}" text-anchor="middle" fill="#ffffff">${Math.round(e.progress)}%</text>`)}}),Wn.forEach(e=>{let t=nr(e);if(!t)return;let n=a?.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,r=n?$:`#94a3b8`;o.push(`<path d="${t}" fill="none" stroke="${r}" stroke-width="${n?2:1.5}"/>`)}),Q!=null&&o.push(`<line x1="${Q.toFixed(1)}" y1="0" x2="${Q.toFixed(1)}" y2="${W.length*F}" stroke="#ef4444" stroke-width="1.5"/>`);let s=W.length*F;return sn.forEach(e=>{let n=/var\(/.test(e.color)?`#6366f1`:e.color;if(o.push(`<line x1="${e.left.toFixed(1)}" y1="0" x2="${e.left.toFixed(1)}" y2="${s}" stroke="${t(n)}" stroke-width="1.5"/>`),e.label){let r=e.label.length*6+8;o.push(`<rect x="${(e.left-r/2).toFixed(1)}" y="0" width="${r}" height="14" rx="2" fill="${t(n)}"/>`),o.push(`<text x="${e.left.toFixed(1)}" y="10" text-anchor="middle" font-size="9" font-weight="600" fill="#ffffff">${t(e.label)}</text>`)}}),o.push(`</g>`),{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${i}" viewBox="0 0 ${r} ${i}">${o.join(``)}</svg>`,W:r,H:i}},[e,W,Wn,nr,zn,sr,or,q,J,Qt,L,F,Gn,Kn,Zn,Xn,Jn,Q,I,ee,$n,Qn,er,tr,sn,on]),ur=t.useCallback(async()=>{let e=lr();if(!e)return;let t=await Se(e.svg,e.W,e.H);t&&t.toBlob(e=>{e&&A(e,`gantt-${I}.png`)},`image/png`)},[lr,I]),dr=t.useCallback(async()=>{let e=lr();if(!e)return;let t=await Se(e.svg,e.W,e.H);t&&A(Ce(we(t.toDataURL(`image/jpeg`,.92)),t.width,t.height),`gantt-${I}.pdf`)},[lr,I]),[fr,pr]=t.useState(!1),mr=t.useCallback(()=>{let e={viewMode:I,columnWidth:Le,taskListCollapsed:Ge,taskListWidth:ze};ne&&Ee(ne,e),re?.(e),pr(!0)},[I,Le,Ge,ze,ne,re]);return t.useEffect(()=>{if(!fr)return;let e=setTimeout(()=>pr(!1),1500);return()=>clearTimeout(e)},[fr]),(0,u.jsxs)(`div`,{ref:ue,className:(0,s.cn)(`flex flex-col h-full bg-background overflow-hidden min-w-0`,g),"data-readonly":M?`true`:void 0,"data-mobile-readonly":w&&De?`true`:void 0,children:[(0,u.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 Oe(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 M(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&&j.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 Ae(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(ke+e,JSON.stringify(t))}catch{}}function je({tasks:e,viewMode:n,startDate:r,endDate:i,markers:a,onTaskClick:o,taskUrl:s,onTaskUpdate:l,onTaskDelete:p,onViewChange:m,onDependencyCreate:h,onBeforeDependencyCreate:g,onDependencyDelete:_,onTaskReorder:v,className:ee,inlineEdit:y=!1,autoSchedule:b=!1,rescheduleOnConflict:te=!1,criticalPathDefault:ne=!1,workingCalendar:x,shiftSegments:S,showBaselines:re=!0,readOnly:C=!1,mobileReadOnly:w=!1,groupBy:ie,ungroupedLabel:T=`Ungrouped`,defaultCollapsedDepth:E,summaryExtent:ae=`children`,persistLayoutKey:O,onLayoutChange:ce,onRefresh:le,refreshing:ue=!1}){let{t:k,language:fe}=pe(),A=fe||void 0,[ke,je]=t.useState(new Date),Me=t.useRef(null),{width:Ne}=(0,c.useResizeObserver)(Me),Pe=Ne||(typeof window<`u`?window.innerWidth:1024),Fe=Pe<640,N=C||w&&Fe,P=N?void 0:l,Ie=N?void 0:p,F=N?void 0:h,I=N?void 0:_,L=N?void 0:v,Le=!N&&y,Re=!N&&b,ze=!N&&te,R=ye(Pe),Be=ge(Pe),Ve=t.useRef(void 0);Ve.current===void 0&&(Ve.current=M(O));let He=Ve.current,[Ue,We]=t.useState(He?He.columnWidth:null),[Ge,Ke]=t.useState(He?He.taskListWidth??null:null),[z,qe]=t.useState(n&&j.includes(n)?n:He?.viewMode??`day`);t.useEffect(()=>{n&&j.includes(n)&&qe(n)},[n]);let Je=t.useRef(null),Ye=t.useRef(null),Xe=t.useRef(!0),[Ze,Qe]=t.useState(He?He.taskListCollapsed:!1),$e=t.useRef(!1);t.useEffect(()=>{!$e.current&&Fe&&(Qe(!0),$e.current=!0)},[Fe]);let et=Math.max(160,Pe-200),B=Ze?0:Ge==null?_e(Pe):Math.max(160,Math.min(Ge,et)),tt=t.useMemo(()=>{if(Ue!=null||i||e.length===0)return null;let t=r?new Date(r):new Date(Math.min(...e.map(e=>e.start.getTime()))),n=new Date(Math.max(...e.map(e=>e.end.getTime())));r||t.setDate(t.getDate()-7),n.setDate(n.getDate()+14),t=Se(t,z),n.setHours(23,59,59,999);let a=Math.max(1,(n.getTime()-t.getTime())/xe),o=Math.max(0,Pe-B);if(o<=0)return null;let s=o/a*be[z];if(s<=Be)return null;let c=Math.min(s,o*.6);return c>Be?c:null},[Ue,e,r,i,z,Pe,B,Be]),nt=Ue??tt??Be,rt=nt/be[z],it=ve(B),[at,ot]=t.useState(null),[st,ct]=t.useState({}),[lt,ut]=t.useState(null),V=t.useMemo(()=>{if(!ie)return e;let t=new Set;for(let n of e){let e=n.parent!=null&&n.parent!==``?String(n.parent):null;e&&t.add(e)}let n=new Map;for(let r of e){if(t.has(String(r.id)))continue;let e=ie(r),i=e?String(e.key):`__ungrouped__`,a=e?e.label:T,o=n.get(i);o||(o={key:i,label:a,items:[]},n.set(i,o)),o.items.push(r)}let r=[];for(let e of n.values()){let t=`__group__${e.key}`,n=e.items[0];r.push({id:t,title:e.label,start:n.start,end:n.end,progress:0,type:`summary`,parent:null,data:{__group:!0}});for(let n of e.items)r.push({...n,parent:t})}return r},[ie,e,T]),dt=t.useMemo(()=>{let e=new Set(V.map(e=>String(e.id))),t=new Map;for(let n of V){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},[V]),ft=t.useMemo(()=>{let e=new Map;for(let t of V)e.set(String(t.id),t);return e},[V]),pt=t.useCallback(e=>{let t=[],n=new Set,r=e=>{for(let i of dt.get(e)??[]){let e=String(i.id);n.has(e)||(n.add(e),t.push(i),r(e))}};return r(String(e)),t},[dt]),[H,mt]=t.useState(null),ht=t.useRef(null);t.useEffect(()=>{ht.current=H},[H]);let gt=t.useRef(!1),_t=t.useCallback(e=>{let t=z===`day`&&S&&S.bands.length>0&&S?Math.min(...S.bands.map(e=>e.durMs)):xe,n=(e,t)=>Tn.current?Tn.current(e,t):we(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}},[z,S]),vt=t.useRef(e);vt.current=e;let yt=t.useRef([]),bt=t.useRef([]),[xt,St]=t.useState(0),Ct=t.useCallback(e=>{if(!P)return;let t=[];for(let{task:n,changes:r}of e.filter(e=>!e.task.locked)){let e={},i={},a=!1;for(let t of Object.keys(r)){let o=r[t],s=n[t],c=o instanceof Date&&s instanceof Date?o.getTime()===s.getTime():o===s;e[t]=s,i[t]=o,c||(a=!0)}P(n,r),a&&t.push({taskId:String(n.id),before:e,after:i})}t.length&&(yt.current.push(t),bt.current=[],St(e=>e+1))},[P]),[wt,Tt]=t.useState(null),Et=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 n=se(vt.current.map(e=>{let n=t.get(String(e.id));return n?{...e,start:n.start,end:n.end}:e}),x).filter(e=>{let n=t.get(e.id);return!n||e.start.getTime()!==n.start.getTime()||e.end.getTime()!==n.end.getTime()});n.length&&Tt(n)},[ze,x]),Dt=t.useCallback(()=>{if(!wt)return;let e=wt.map(e=>{let t=vt.current.find(t=>String(t.id)===e.id);return t?{task:t,changes:{start:e.start,end:e.end}}:null}).filter(Boolean);e.length&&Ct(e),Tt(null)},[wt,Ct]),Ot=t.useCallback((e,t)=>{if(P)for(let n of e){let e=vt.current.find(e=>String(e.id)===n.taskId);e&&P(e,t===`undo`?n.before:n.after)}},[P]),kt=t.useCallback(()=>{let e=yt.current.pop();e&&(Ot(e,`undo`),bt.current.push(e),St(e=>e+1))},[Ot]),At=t.useCallback(()=>{let e=bt.current.pop();e&&(Ot(e,`redo`),yt.current.push(e),St(e=>e+1))},[Ot]),{canUndo:jt,canRedo:Mt}=t.useMemo(()=>({canUndo:yt.current.length>0,canRedo:bt.current.length>0}),[xt]);t.useEffect(()=>{if(!H)return;let t=z===`day`&&S&&S.bands.length>0&&S?rt*Math.min(...S.bands.map(e=>e.durMs))/xe:rt,n=e=>{let n=ht.current;if(!n)return;let r=Math.round((e.clientX-n.originClientX)/Math.max(t,1));r!==n.unitDelta&&mt({...n,unitDelta:r})},r=()=>{let t=ht.current;if(t){if(t.unitDelta!==0){let n=e.find(e=>e.id===t.taskId);if(n&&P){let{start:e,end:r}=_t(t);if(t.group){let r=e.getTime()-t.originStart.getTime(),i=[n,...pt(n.id).filter(e=>!e.locked)].map(e=>({task:e,changes:{start:new Date(e.start.getTime()+r),end:new Date(e.end.getTime()+r)}}));Ct(i),Et(i)}else{let t=[{task:n,changes:{start:e,end:r}}];Ct(t),Et(t)}}gt.current=!0,window.setTimeout(()=>{gt.current=!1},0)}mt(null)}};return window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r),()=>{window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r)}},[H,nt,rt,z,S,e,P,_t,pt,Ct,Et]);let Nt=t.useCallback((e,t,n,r)=>{!P||e.data?.__group||e.locked||(n.stopPropagation(),n.preventDefault(),mt({taskId:e.id,mode:t,group:r?.group??!1,originStart:new Date(r?.originStart??e.start),originEnd:new Date(r?.originEnd??e.end),originClientX:n.clientX,unitDelta:0}))},[P]),[Pt,Ft]=t.useState(null),It=t.useRef(null);t.useEffect(()=>{It.current=Pt},[Pt]),t.useEffect(()=>{if(!Pt)return;let t=e=>{let t=It.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&&Ft({...t,value:n})},n=()=>{let t=It.current;if(t){if(t.value!==t.originProgress){let n=e.find(e=>e.id===t.taskId);n&&P&&Ct([{task:n,changes:{progress:t.value}}]),gt.current=!0,window.setTimeout(()=>{gt.current=!1},0)}Ft(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)}},[Pt,e,P,Ct]);let Lt=t.useMemo(()=>{let t=[];for(let n of e)for(let e of n.dependencies??[]){let r=typeof e==`object`&&e?e.id:e;r==null||r===``||t.push([String(r),String(n.id)])}return t},[e]),Rt=t.useCallback((e,t)=>String(t.id)!==String(e)&&!t.locked&&t.type!==`group`&&!D(Lt,e,t.id),[Lt]),zt=t.useRef(null),[U,Bt]=t.useState(null),Vt=t.useRef(null);t.useEffect(()=>{Vt.current=U},[U]),t.useEffect(()=>{if(!U)return;let t=e=>{let t=zt.current?.getBoundingClientRect();if(!t)return;let n=e.clientX-t.left,r=e.clientY-t.top;Bt(e=>e&&{...e,x:n,y:r})},n=()=>{let t=Vt.current;if(t&&t.targetId!=null&&F){let n=e.find(e=>String(e.id)===String(t.sourceId)),r=e.find(e=>String(e.id)===String(t.targetId)),i=t.targetEnd??`start`,a=`${t.sourceEnd===`end`?`f`:`s`}${i===`end`?`f`:`s`}`;n&&r&&Rt(t.sourceId,r)&&(g?.(n,r,a)??!0)&&F(n,r,a)}gt.current=!0,window.setTimeout(()=>{gt.current=!1},0),Bt(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)}},[U,e,F,g,Rt]);let[Ht,Ut]=t.useState(null),Wt=t.useRef(null);t.useEffect(()=>{if(!Ht)return;let e=e=>{Wt.current&&e.target instanceof Node&&Wt.current.contains(e.target)||Ut(null)},t=e=>{e.key===`Escape`&&Ut(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[Ht]);let[Gt,Kt]=t.useState(null),[qt,Jt]=t.useState(null),[Yt,Xt]=t.useState(!1);t.useEffect(()=>{if(!Gt){Jt(null),Xt(!1);return}let e=!1;(0,d.toDataURL)(Gt.url,{width:220,margin:1}).then(t=>{e||Jt(t)}).catch(()=>{e||Jt(null)});let t=e=>{e.key===`Escape`&&Kt(null)};return window.addEventListener(`keydown`,t),()=>{e=!0,window.removeEventListener(`keydown`,t)}},[Gt]);let Zt=t.useCallback(()=>{Gt&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(Gt.url).then(()=>{Xt(!0),window.setTimeout(()=>Xt(!1),1500)}).catch(()=>{})},[Gt]),[W,Qt]=t.useState(null),$t=t.useRef(null);t.useEffect(()=>{if(!W)return;let e=e=>{$t.current&&e.target instanceof Node&&$t.current.contains(e.target)||Qt(null)},t=e=>{e.key===`Escape`&&Qt(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[W]);let[en,tn]=t.useState(null),[nn,rn]=t.useState(``),an=t.useRef(null);t.useEffect(()=>{if(!en)return;let e=e=>{an.current&&e.target instanceof Node&&an.current.contains(e.target)||tn(null)},t=e=>{e.key===`Escape`&&tn(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[en]);let[on,sn]=t.useState(null),cn=!!(o||P||F||Ie),ln=t.useCallback((e,t)=>{t.preventDefault(),t.stopPropagation(),sn(e.id),!(!cn&&!(s&&s(e)))&&Ut({x:t.clientX,y:t.clientY,taskId:e.id})},[cn,s]),un=t.useCallback((e,t,n,r)=>{r.preventDefault(),r.stopPropagation(),!(!F&&!I)&&Qt({x:r.clientX,y:r.clientY,sourceId:e,targetId:t,type:n})},[F,I]),[dn,fn]=t.useState(()=>new Set(He?.collapsedIds??[])),pn=t.useCallback(e=>{fn(t=>{let n=new Set(t),r=String(e);return n.has(r)?n.delete(r):n.add(r),n})},[]),mn=t.useRef(He?.collapsedIds!=null);t.useEffect(()=>{if(mn.current||E==null||V.length===0)return;mn.current=!0;let e=new Map(V.map(e=>[String(e.id),e])),t=new Set;for(let n of V){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 V){let i=String(e.id);t.has(i)&&n(e)>=E&&r.add(i)}r.size&&fn(e=>e.size?e:r)},[E,V]);let G=t.useMemo(()=>{let e=new Set(V.map(e=>String(e.id))),t=new Map,n=[];for(let r of V){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(),xe);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&&ae===`self`&&e.hasOwnDates!==!1,p=u&&!f?i(e,new Set):{start:e.start,end:e.end,progress:e.progress},m=!d&&(e.type===`milestone`||e.end.getTime()<=e.start.getTime());if(a.push({task:e,depth:n,hasChildren:u,isSummary:d,isMilestone:m,...p}),u)if(dn.has(r))s(e);else for(let e of l)c(e,n+1)};for(let e of n)c(e,0);for(let e of V)o.has(String(e.id))||c(e,0);return a},[V,dn,ae]),hn=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?At():kt();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`Y`)){e.preventDefault(),At();return}if(!G.length)return;let t=on==null?-1:G.findIndex(e=>String(e.task.id)===String(on));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?Math.min(G.length-1,t+1):Math.max(0,t<=0?0:t-1);sn(G[n].task.id);let r=X.current;if(r){let e=n*R;e<r.scrollTop?r.scrollTop=e:e+R>r.scrollTop+r.clientHeight&&(r.scrollTop=e+R-r.clientHeight)}return}if(t<0)return;let n=G[t];e.key===`Enter`?(e.preventDefault(),o?.(n.task)):e.key===`Delete`||e.key===`Backspace`?Ie&&(e.preventDefault(),Ie(n.task)):(e.key===`ArrowRight`&&n.hasChildren&&dn.has(String(n.task.id))||e.key===`ArrowLeft`&&n.hasChildren&&!dn.has(String(n.task.id)))&&(e.preventDefault(),pn(n.task.id))},[G,on,o,Ie,dn,pn,R,kt,At]),K=t.useMemo(()=>{let t=r?new Date(r):new Date,n=i?new Date(i):new Date;return!r&&e.length>0&&(t=new Date(Math.min(...e.map(e=>e.start.getTime()))),t.setDate(t.getDate()-7)),!i&&e.length>0&&(n=new Date(Math.max(...e.map(e=>e.end.getTime()))),n.setDate(n.getDate()+14)),t=z===`day`&&S&&S.bands.length>0?de(t,S.dayStartMin):Se(t,z),n.setHours(23,59,59,999),{start:t,end:n}},[r,i,e,z,S]),gn=z===`day`&&!!S&&S.bands.length>0,_n=!gn&&z===`day`&&!!x&&(!!x.skipWeekends||!!(x.holidays&&x.holidays.size)),vn=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]),q=t.useMemo(()=>{let e=[];if(gn&&S){let t=new Date(K.start);for(;t<=K.end;)for(let n of S.bands){let r=n.durMs/xe*rt;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(K.start);for(;t<=K.end;){let n=we(t,1,z);if(_n&&!vn(t)){t=n;continue}let r=(n.getTime()-t.getTime())/xe*rt,i,a;z===`day`?(i=String(t.getDate()),a=t.toLocaleDateString(A,{weekday:`narrow`})):i=z===`week`?t.toLocaleDateString(A,{month:`numeric`,day:`numeric`}):z===`month`?t.toLocaleDateString(A,{month:`short`}):z===`quarter`?`Q${Math.floor(t.getMonth()/3)+1}`:String(t.getFullYear()),e.push({date:new Date(t),label:i,sublabel:a,isWeekend:z===`day`&&(t.getDay()===0||t.getDay()===6),width:r}),t=n}return e},[K,z,rt,A,_n,vn,gn,S]),J=t.useMemo(()=>{let e=Array(q.length+1),t=0;for(let n=0;n<q.length;n++)e[n]=t,t+=q[n].width;return e[q.length]=t,e},[q]),yn=J[J.length-1],bn=t.useMemo(()=>q.map(e=>e.date.getTime()),[q]),xn=t.useMemo(()=>q.map(e=>e.realMs==null?we(e.date,1,z).getTime()-e.date.getTime():e.realMs),[q,z]),Y=t.useCallback(e=>{let t=q.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;bn[e]<=n?(a=e,r=e+1):i=e-1}let o=xn[a]||864e5,s=(n-bn[a])/o;return(_n||gn)&&(s=Math.max(0,Math.min(s,1))),J[a]+s*q[a].width},[q,bn,xn,J,_n,gn]),Sn=t.useCallback(e=>{let t=q.length;if(t===0)return new Date(K.start);let n=0,r=t-1,i=0;for(;n<=r;){let t=n+r>>1;J[t]<=e?(i=t,n=t+1):r=t-1}let a=q[i].width||1,o=(e-J[i])/a;return new Date(bn[i]+o*(xn[i]||864e5))},[q,bn,xn,J,K]),Cn=t.useCallback(e=>{let t=X.current;Ye.current==null&&t&&t.clientWidth>0&&(Ye.current=Sn(t.scrollLeft)),Je.current=Ye.current,Xe.current=!0,qe(e),m?.(e)},[m,Sn]);t.useLayoutEffect(()=>{let e=Je.current;if(e==null)return;Je.current=null;let t=X.current;if(!t||t.clientWidth===0)return;let n=Math.max(0,t.scrollWidth-t.clientWidth),r=Math.max(0,Math.min(Math.round(Y(Se(e,z))),n));t.scrollLeft!==r&&(t.scrollLeft=r)},[z,Y]);let wn=t.useCallback((e,t)=>{let n=q.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;bn[e]<=r?(o=e,i=e+1):a=e-1}let s=Math.min(n-1,Math.max(0,o+t)),c=r-bn[o];return new Date(bn[s]+c)},[q,bn]),Tn=t.useRef(null);Tn.current=_n||gn?wn:null;let En=t.useMemo(()=>{let e=[];if(gn&&S){let t=0;for(let n of q){let r=String(de(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(A,{month:`short`,day:`numeric`}),width:n.width,offset:t}),t+=n.width}return e}let t=z===`year`?`decade`:z===`month`||z===`quarter`?`year`:`month`,n=0;for(let r of q){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(A,{month:`short`,year:`numeric`}),width:r.width,offset:n}),n+=r.width}return e},[q,z,A,gn,S]),Dn=t.useMemo(()=>(a??[]).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(Y(n)),valid:!isNaN(n.getTime())&&n>=K.start&&n<=K.end}}).filter(e=>e.valid),[a,K,Y]),On=t.useRef(null),kn=t.useRef(null),An=t.useRef(null),X=t.useRef(null);t.useEffect(()=>{let e=X.current;if(!e)return;let t=()=>{Xe.current=!1},n=new Set([`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `,`Spacebar`]),r=e=>{n.has(e.key)&&t()};return e.addEventListener(`wheel`,t,{passive:!0}),e.addEventListener(`touchstart`,t,{passive:!0}),e.addEventListener(`pointerdown`,t,{passive:!0}),e.addEventListener(`keydown`,r),()=>{e.removeEventListener(`wheel`,t),e.removeEventListener(`touchstart`,t),e.removeEventListener(`pointerdown`,t),e.removeEventListener(`keydown`,r)}},[]);let[jn,Mn]=t.useState(null),Nn=t.useRef([]),Pn=t.useRef(null),[Fn,In]=t.useState({top:0,left:0}),[Ln,Rn]=t.useState({width:4e3,height:600}),zn=t.useCallback(()=>{let e=X.current;if(!e)return;let t=e.clientWidth||4e3,n=e.clientHeight||600;Rn(e=>e.width===t&&e.height===n?e:{width:t,height:n})},[]);t.useLayoutEffect(()=>{zn();let e=X.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(zn);return t.observe(e),()=>t.disconnect()},[zn]);let Bn=t.useMemo(()=>Ce(J,Fn.left-240,Fn.left+Ln.width+240),[J,Fn.left,Ln.width]),Vn=t.useMemo(()=>{let e=En.map(e=>e.offset);return e.push(yn),e},[En,yn]),Hn=t.useMemo(()=>Ce(Vn,Fn.left-240,Fn.left+Ln.width+240),[Vn,Fn.left,Ln.width]),Z=t.useMemo(()=>({startIdx:Math.max(0,Math.floor(Fn.top/R)-6),endIdx:Math.min(G.length,Math.ceil((Fn.top+Ln.height)/R)+6)}),[Fn.top,Ln.height,R,G.length]),Un=G.length*R,[Wn,Gn]=t.useState(!1);t.useEffect(()=>{let e=()=>Gn(!!document.fullscreenElement);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let Kn=t.useCallback(()=>{let e=Me.current;e&&(document.fullscreenElement?document.exitFullscreen?.():e.requestFullscreen?.())},[]),qn=t.useRef(null),Jn=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;qn.current={baseDistance:Math.max(1,Math.sqrt(t*t+n*n)),baseColumn:nt}}},[nt]),Yn=t.useCallback(e=>{if(e.touches.length!==2||!qn.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))/qn.current.baseDistance,i=Math.max(15,Math.min(120,Math.round(qn.current.baseColumn*r)));We(i)},[]),Xn=t.useCallback(()=>{qn.current=null},[]),Q=t.useMemo(()=>{let e=new Date;return e<K.start||e>K.end?null:Math.round(Y(e))},[K,Y]),Zn=t.useCallback(()=>{if(Q==null||!X.current)return;let e=Math.max(0,Q-X.current.clientWidth/2);X.current.scrollTo({left:e,behavior:`smooth`})},[Q]),Qn=t.useRef(!1);t.useEffect(()=>{if(Qn.current||e.length===0)return;let t=window.requestAnimationFrame(()=>{let t=X.current;if(!t||t.clientWidth===0)return;let n=Q;if(n==null){let t=new Date(Math.min(...e.map(e=>e.start.getTime())));n=Math.round(Y(t))}t.scrollLeft=Math.max(0,n-t.clientWidth/2),Qn.current=!0});return()=>window.cancelAnimationFrame(t)},[e,Q,Y]);let $n=t.useCallback((e,t=`left`)=>{let n=X.current;if(!n||e<K.start||e>K.end)return!1;let r=Math.round(Y(e)),i=t===`center`?r-n.clientWidth/2:r-24;return n.scrollTo({left:Math.max(0,i),behavior:`smooth`}),!0},[K,Y]),er=t.useCallback((e,t,n)=>{let r=X.current;if(!r)return;let i=Y(e),a=Y(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));Nn.current.forEach(e=>window.clearTimeout(e)),Nn.current=[],Pn.current?.(),Pn.current=null,Mn(null);let u=()=>{if(n==null)return;let e=window.requestAnimationFrame(()=>{Mn(n),Nn.current.push(window.setTimeout(()=>Mn(e=>e===n?null:e),1500))});Pn.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),Nn.current.push(window.setTimeout(m,f?1500:500)),Pn.current=()=>r.removeEventListener(`scrollend`,m)},[Y]);t.useEffect(()=>()=>{Nn.current.forEach(e=>window.clearTimeout(e)),Pn.current?.()},[]);let tr=t.useCallback(()=>$n(Se(new Date,`week`)),[$n]),nr=t.useCallback(()=>$n(Se(new Date,`month`)),[$n]),rr=e=>{let t=e.currentTarget;!Xe.current&&t.clientWidth>0&&(Ye.current=Sn(t.scrollLeft)),On.current&&(On.current.scrollLeft=t.scrollLeft),kn.current&&kn.current.scrollTop!==t.scrollTop&&(kn.current.scrollTop=t.scrollTop),In(e=>e.top===t.scrollTop&&e.left===t.scrollLeft?e:{top:t.scrollTop,left:t.scrollLeft}),zn()},ir=e=>{let t=e.currentTarget,n=X.current;n&&n.scrollTop!==t.scrollTop&&(n.scrollTop=t.scrollTop),In(e=>e.top===t.scrollTop?e:{...e,top:t.scrollTop})},ar=(e,t)=>{let n=Y(e),r=gn&&S?rt*Math.min(...S.bands.map(e=>e.durMs))/xe:rt;return{left:n,width:Math.max(Y(t)-n,r,3)}},or=H?.group?H.taskId:null,sr=t.useMemo(()=>{if(or==null)return null;let e=new Set([String(or)]);for(let t of pt(or))t.locked||e.add(String(t.id));return e},[or,pt]),cr=t.useMemo(()=>{if(!H||H.group)return null;let e=new Set,t=new Set,n=ft.get(String(H.taskId));for(;n&&n.parent!=null&&n.parent!==``;){let r=String(n.parent);if(t.has(r)||!ft.has(r))break;t.add(r),e.add(r),n=ft.get(r)}return e.size?e:null},[H,ft]),lr=e=>{if(H){if(sr?.has(String(e.task.id))){let t=_t(H).start.getTime()-H.originStart.getTime();return ar(new Date(e.start.getTime()+t),new Date(e.end.getTime()+t))}if(!e.isSummary&&H.taskId===e.task.id){let e=_t(H);return ar(e.start,e.end)}if(e.isSummary&&cr?.has(String(e.task.id))&&!(ae===`self`&&e.task.hasOwnDates!==!1)){let t=_t(H),n=String(H.taskId),r=null,i=null;for(let a of pt(e.task.id)){if((dt.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 ar(r,i)}}return ar(e.start,e.end)},ur=t.useMemo(()=>{let e=new Map;G.forEach((t,n)=>e.set(String(t.task.id),n));let t=[];return G.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},[G]),dr=Math.max(2,Math.round(R/2)-14),fr=R-dr*2,pr=Math.round(fr/2),mr=Math.max(Math.round(R*.4),12),hr=mr*Math.SQRT2/2,gr=fr,_r=dr,vr=Math.max(3,Math.round(R*.13)),yr=R-vr-1,br=`rgba(100, 116, 139, 0.35)`,xr=`rgba(100, 116, 139, 0.6)`,Sr=e=>{let t=G[e.sourceIndex],n=G[e.targetIndex];if(!t||!n)return null;let r=lr(t),i=lr(n),a=e=>e.isSummary?_r+gr/2:R/2,o=e.sourceIndex*R+a(t),s=e.targetIndex*R+a(n),c=e.type===`fs`||e.type===`ff`,l=e.type===`ff`||e.type===`sf`,u=t.isMilestone?r.left+(c?hr:-hr):c?r.left+r.width:r.left,d=n.isMilestone?i.left+(l?hr:-hr):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)*R:e.sourceIndex*R;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(` `)},Cr=H?.taskId??lt,[wr,Tr]=t.useState(ne),Er=t.useMemo(()=>wr?oe(e,x):null,[wr,e,x]),Dr=t.useCallback(e=>Er?.criticalIds.has(String(e))??!1,[Er]),$=`#dc2626`,Or=t.useCallback(()=>{if(!P)return;let t=se(e,x),n=[];for(let r of t){let t=e.find(e=>String(e.id)===r.id);t&&n.push({task:t,changes:{start:r.start,end:r.end}})}Ct(n)},[e,P,x,Ct]),kr=t.useCallback(()=>{if(typeof document>`u`||!e.length)return null;let t=e=>String(e).replace(/[&<>"]/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`})[e]),n=Math.max(B,200),r=Math.ceil(n+yn),i=Math.ceil(36+G.length*R),a=Er?.criticalEdges??null,o=[];o.push(`<rect x="0" y="0" width="${r}" height="${i}" fill="#ffffff"/>`),o.push(`<rect x="0" y="0" width="${r}" height="36" fill="#f8fafc"/>`),o.push(`<g transform="translate(${n},0)" font-family="sans-serif" font-size="10" fill="#475569">`),En.forEach(e=>{o.push(`<line x1="${e.offset.toFixed(1)}" y1="0" x2="${e.offset.toFixed(1)}" y2="36" stroke="#e2e8f0"/>`),o.push(`<text x="${(e.offset+e.width/2).toFixed(1)}" y="12" text-anchor="middle" font-weight="600">${t(e.label)}</text>`)}),q.forEach((e,n)=>{let r=J[n];o.push(`<line x1="${r.toFixed(1)}" y1="18" x2="${r.toFixed(1)}" y2="${i}" stroke="#eef2f7"/>`),o.push(`<text x="${(r+e.width/2).toFixed(1)}" y="30" text-anchor="middle" fill="#1f2937">${t(e.label)}</text>`)}),o.push(`</g>`),o.push(`<line x1="0" y1="18" x2="${r}" y2="18" stroke="#e2e8f0"/>`),o.push(`<line x1="0" y1="36" x2="${r}" y2="36" stroke="#cbd5e1"/>`),o.push(`<line x1="${n}" y1="0" x2="${n}" y2="${i}" stroke="#cbd5e1"/>`),o.push(`<g transform="translate(0,36)" font-family="sans-serif" font-size="11" fill="#1f2937">`),G.forEach((e,r)=>{let i=r*R;o.push(`<line x1="0" y1="${(i+R).toFixed(1)}" x2="${n}" y2="${(i+R).toFixed(1)}" stroke="#f1f5f9"/>`);let a=8+e.depth*14,s=Math.max(4,Math.floor((n-a)/6.5)),c=e.task.title.length>s?e.task.title.slice(0,s-1)+`…`:e.task.title,l=e.isSummary?` font-weight="600"`:``;o.push(`<text x="${a}" y="${(i+R/2+4).toFixed(1)}"${l}>${t(c)}</text>`)}),o.push(`</g>`),o.push(`<g transform="translate(${n},36)" font-family="sans-serif" font-size="9">`),G.forEach((e,t)=>{let n=t*R,{left:r,width:i}=ar(e.start,e.end),a=Dr(e.task.id),s=a?` stroke="${$}" stroke-width="2"`:``;if(re&&e.task.baselineStart&&e.task.baselineEnd){let t=ar(e.task.baselineStart,e.task.baselineEnd);o.push(`<rect x="${t.left.toFixed(1)}" y="${(n+yr).toFixed(1)}" width="${Math.max(2,t.width).toFixed(1)}" height="${vr}" rx="1" fill="${br}" stroke="${xr}"/>`)}if(e.isMilestone){let t=r,i=n+R/2,s=mr/2,c=a?$:e.task.color||`#3b82f6`;o.push(`<polygon points="${t},${i-s} ${t+s},${i} ${t},${i+s} ${t-s},${i}" fill="${c}"/>`)}else if(e.isSummary){let t=e.task.color||`#64748b`;o.push(`<rect x="${r.toFixed(1)}" y="${(n+_r).toFixed(1)}" width="${i.toFixed(1)}" height="${gr}" rx="3" fill="${t}"${s}/>`);let a=i*Math.min(100,Math.max(0,e.progress))/100;o.push(`<rect x="${r.toFixed(1)}" y="${(n+_r).toFixed(1)}" width="${a.toFixed(1)}" height="${gr}" rx="3" fill="rgba(0,0,0,0.2)"/>`)}else{let t=e.task.color||`#3b82f6`;o.push(`<rect x="${r.toFixed(1)}" y="${(n+dr).toFixed(1)}" width="${i.toFixed(1)}" height="${fr}" rx="3" fill="${t}"${s}/>`);let a=i*Math.min(100,Math.max(0,e.progress))/100;o.push(`<rect x="${r.toFixed(1)}" y="${(n+dr).toFixed(1)}" width="${a.toFixed(1)}" height="${fr}" rx="3" fill="rgba(0,0,0,0.18)"/>`),i>=24&&o.push(`<text x="${(r+i/2).toFixed(1)}" y="${(n+R/2+3).toFixed(1)}" text-anchor="middle" fill="#ffffff">${Math.round(e.progress)}%</text>`)}}),ur.forEach(e=>{let t=Sr(e);if(!t)return;let n=a?.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,r=n?$:`#94a3b8`;o.push(`<path d="${t}" fill="none" stroke="${r}" stroke-width="${n?2:1.5}"/>`)}),Q!=null&&o.push(`<line x1="${Q.toFixed(1)}" y1="0" x2="${Q.toFixed(1)}" y2="${G.length*R}" stroke="#ef4444" stroke-width="1.5"/>`);let s=G.length*R;return Dn.forEach(e=>{let n=/var\(/.test(e.color)?`#6366f1`:e.color;if(o.push(`<line x1="${e.left.toFixed(1)}" y1="0" x2="${e.left.toFixed(1)}" y2="${s}" stroke="${t(n)}" stroke-width="1.5"/>`),e.label){let r=e.label.length*6+8;o.push(`<rect x="${(e.left-r/2).toFixed(1)}" y="0" width="${r}" height="14" rx="2" fill="${t(n)}"/>`),o.push(`<text x="${e.left.toFixed(1)}" y="10" text-anchor="middle" font-size="9" font-weight="600" fill="#ffffff">${t(e.label)}</text>`)}}),o.push(`</g>`),{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${i}" viewBox="0 0 ${r} ${i}">${o.join(``)}</svg>`,W:r,H:i}},[e,G,ur,Sr,ar,Dr,Er,q,J,yn,B,R,dr,fr,_r,gr,mr,Q,z,re,yr,vr,br,xr,Dn,En]),Ar=t.useCallback(async()=>{let e=kr();if(!e)return;let t=await Te(e.svg,e.W,e.H);t&&t.toBlob(e=>{e&&Ee(e,`gantt-${z}.png`)},`image/png`)},[kr,z]),jr=t.useCallback(async()=>{let e=kr();if(!e)return;let t=await Te(e.svg,e.W,e.H);t&&Ee(De(Oe(t.toDataURL(`image/jpeg`,.92)),t.width,t.height),`gantt-${z}.pdf`)},[kr,z]),[Mr,Nr]=t.useState(!1),Pr=t.useCallback(()=>{let e={viewMode:z,columnWidth:Ue,taskListCollapsed:Ze,taskListWidth:Ge,collapsedIds:Array.from(dn)};O&&Ae(O,e),ce?.(e),Nr(!0)},[z,Ue,Ze,Ge,dn,O,ce]);return t.useEffect(()=>{if(!Mr)return;let e=setTimeout(()=>Nr(!1),1500);return()=>clearTimeout(e)},[Mr]),(0,f.jsxs)(`div`,{ref:Me,className:(0,c.cn)(`flex flex-col h-full bg-background overflow-hidden min-w-0`,ee),"data-readonly":N?`true`:void 0,"data-mobile-readonly":w&&Fe?`true`:void 0,children:[(0,f.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
- .gantt-locate-btn { opacity: 0; transition: opacity 0.15s ease; }
19
- .group\\/task-row:hover .gantt-locate-btn { opacity: 0.6; }
20
- .gantt-locate-btn:hover, .gantt-locate-btn:focus-visible { opacity: 1; }
18
+ .gantt-row-open-btn { opacity: 0; transition: opacity 0.15s ease; }
19
+ /* :where keeps the row-hover reveal at zero specificity so the
20
+ button's own :hover/:focus-visible full-opacity rule can win. */
21
+ :where(.group\\/task-row:hover) .gantt-row-open-btn { opacity: 0.6; }
22
+ .gantt-row-open-btn:hover, .gantt-row-open-btn:focus-visible { opacity: 1; }
21
23
  /* 定位闪烁: blink the located bar 3× with a thick ring + colored glow so
22
24
  it's hard to miss. The ring is an outline (not box-shadow) and the glow
23
25
  is a drop-shadow *filter* — both stay clear of the critical-path bar's
@@ -90,4 +92,4 @@ endobj
90
92
  bar. Hide it — the pane stays wheel/drag-scrollable and synced. */
91
93
  .gantt-task-list::-webkit-scrollbar { width: 0; height: 0; }
92
94
  .gantt-task-list { scrollbar-width: none; }
93
- `}),(0,u.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,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":D(`gantt.toolbar.prevPeriod`),children:(0,u.jsx)(l.ChevronLeft,{className:`h-4 w-4`})}),(0,u.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":D(`gantt.toolbar.nextPeriod`),children:(0,u.jsx)(l.ChevronRight,{className:`h-4 w-4`})}),(0,u.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,children:G.start.toLocaleDateString(O,{month:`long`,year:`numeric`})}),M&&(0,u.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:D(`gantt.readOnlyHint`),children:[(0,u.jsx)(l.Lock,{className:`h-3 w-3`}),D(`gantt.readOnly`)]})]}),(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(`div`,{className:`flex bg-muted rounded-md p-1`,role:`group`,"aria-label":D(`gantt.toolbar.viewMode`),children:k.map(e=>(0,u.jsx)(s.Button,{variant:`ghost`,size:`sm`,className:(0,s.cn)(`h-6 px-1.5 sm:px-2 text-xs`,I===e&&`bg-background shadow-sm hover:bg-background`),onClick:()=>nn(e),"aria-pressed":I===e,"data-testid":`gantt-view-mode-${e}`,children:D(`gantt.viewMode.${e}`)},e))}),(0,u.jsxs)(`div`,{className:`flex bg-muted rounded-md p-1`,children:[(0,u.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(R>15)Re(Math.max(15,R-10));else{let e=k.indexOf(I);e<k.length-1&&(nn(k[e+1]),Re(Pe))}},"aria-label":D(`gantt.toolbar.zoomOut`),children:(0,u.jsx)(l.ZoomOut,{className:`h-3 w-3`})}),(0,u.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(R<120)Re(Math.min(120,R+10));else{let e=k.indexOf(I);e>0&&(nn(k[e-1]),Re(Pe))}},"aria-label":D(`gantt.toolbar.zoomIn`),children:(0,u.jsx)(l.ZoomIn,{className:`h-3 w-3`})})]}),(0,u.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>Ke(e=>!e),"aria-label":D(Ge?`gantt.toolbar.showTaskList`:`gantt.toolbar.hideTaskList`),"aria-pressed":Ge,"data-testid":`gantt-toggle-task-list`,children:Ge?(0,u.jsx)(l.PanelLeft,{className:`h-4 w-4`}):(0,u.jsx)(l.PanelLeftClose,{className:`h-4 w-4`})}),(0,u.jsx)(s.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:jn,disabled:Q==null,"aria-label":D(`gantt.toolbar.jumpToToday`),"data-testid":`gantt-jump-today`,children:D(`gantt.toolbar.today`)}),(0,u.jsx)(s.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:Fn,"aria-label":D(`gantt.toolbar.thisWeek`),"data-testid":`gantt-jump-week`,children:D(`gantt.toolbar.thisWeek`)}),(0,u.jsx)(s.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:In,"aria-label":D(`gantt.toolbar.thisMonth`),"data-testid":`gantt-jump-month`,children:D(`gantt.toolbar.thisMonth`)}),N?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:xt,disabled:!Ct,"aria-label":D(`gantt.toolbar.undo`),"data-testid":`gantt-undo`,children:(0,u.jsx)(l.Undo2,{className:`h-4 w-4`})}),(0,u.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:St,disabled:!wt,"aria-label":D(`gantt.toolbar.redo`),"data-testid":`gantt-redo`,children:(0,u.jsx)(l.Redo2,{className:`h-4 w-4`})})]}):null,(0,u.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>ar(e=>!e),"aria-label":D(`gantt.toolbar.criticalPath`),"aria-pressed":ir,"data-testid":`gantt-critical-path`,style:ir?{color:$}:void 0,children:(0,u.jsx)(l.Activity,{className:`h-4 w-4`})}),Me&&N?(0,u.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:cr,"aria-label":D(`gantt.toolbar.autoSchedule`),"data-testid":`gantt-auto-schedule`,children:(0,u.jsx)(l.Wand2,{className:`h-4 w-4`})}):null,(0,u.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:ur,"aria-label":D(`gantt.toolbar.exportPng`),"data-testid":`gantt-export-png`,children:(0,u.jsx)(l.Download,{className:`h-4 w-4`})}),(0,u.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:dr,"aria-label":D(`gantt.toolbar.exportPdf`),"data-testid":`gantt-export-pdf`,children:(0,u.jsx)(l.FileDown,{className:`h-4 w-4`})}),re||ne?(0,u.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:mr,"aria-label":D(`gantt.toolbar.saveLayout`),"aria-pressed":fr,"data-testid":`gantt-save-layout`,style:fr?{color:$}:void 0,children:(0,u.jsx)(l.Save,{className:`h-4 w-4`})}):null,(0,u.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:En,"aria-label":D(wn?`gantt.toolbar.exitFullscreen`:`gantt.toolbar.enterFullscreen`),"aria-pressed":wn,"data-testid":`gantt-fullscreen`,children:wn?(0,u.jsx)(l.Minimize2,{className:`h-4 w-4`}):(0,u.jsx)(l.Maximize2,{className:`h-4 w-4`})})]})]}),(0,u.jsxs)(`div`,{className:`relative flex flex-col flex-1 overflow-hidden outline-none focus-visible:ring-1 focus-visible:ring-ring`,tabIndex:0,onKeyDown:Yt,"data-testid":`gantt-body`,children:[!Ge&&L>0&&(0,u.jsx)(`div`,{className:`absolute top-0 bottom-0 z-30 group/splitter`,style:{left:L-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=L,r=Math.max(160,j-200),i=e=>{let i=Math.max(160,Math.min(n+(e.clientX-t),r));Be(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:()=>Be(null),children:(0,u.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,u.jsxs)(`div`,{className:`flex border-b bg-muted/30 shrink-0 h-10 gantt-sm-h50`,children:[(0,u.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:L,minWidth:L},children:[(0,u.jsx)(`div`,{className:`flex-1 truncate`,children:D(`gantt.column.taskName`)}),Ze&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:D(`gantt.column.start`)}),(0,u.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:D(`gantt.column.end`)})]})]}),(0,u.jsx)(`div`,{className:`flex-1 overflow-hidden`,ref:cn,children:(0,u.jsxs)(`div`,{className:`flex flex-col h-full`,style:{width:Qt},children:[(0,u.jsx)(`div`,{className:`relative border-b`,style:{height:`45%`},"data-testid":`gantt-header-groups`,children:on.slice(Sn.start,Sn.end).map(e=>(0,u.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,u.jsx)(`span`,{className:`truncate px-1`,children:e.label})},e.key))}),(0,u.jsx)(`div`,{className:`relative flex-1`,"data-testid":`gantt-header-units`,children:q.slice(bn.start,bn.end).map((e,t)=>{let n=bn.start+t;return(0,u.jsxs)(`div`,{className:(0,s.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:J[n],width:e.width,backgroundColor:e.bandColor?`color-mix(in srgb, ${e.bandColor} 16%, transparent)`:void 0},children:[(0,u.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.label}),e.sublabel&&R>=32&&(0,u.jsx)(`span`,{className:`text-[10px] opacity-70`,children:e.sublabel})]},n)})})]})})]}),(0,u.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,u.jsxs)(`div`,{className:`gantt-task-list overflow-y-auto overflow-x-hidden border-r bg-card z-10 shadow-sm`,ref:ln,onScroll:Rn,style:{width:L,minWidth:L},role:`tree`,"aria-label":D(`gantt.aria.taskList`),children:[Z.startIdx>0&&(0,u.jsx)(`div`,{style:{height:Z.startIdx*F},"aria-hidden":`true`}),W.slice(Z.startIdx,Z.endIdx).map(e=>{let t=e.task,n=je&&Qe===t.id,r=Gt.has(String(t.id)),i=Bt!=null&&String(Bt)===String(t.id);return(0,u.jsxs)(`div`,{className:(0,s.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:F,touchAction:`manipulation`},role:`treeitem`,"aria-level":e.depth+1,"aria-selected":i,"aria-expanded":e.hasChildren?!r:void 0,draggable:!!Ae&&!n&&!t.locked,onDragStart:Ae?e=>{e.dataTransfer.setData(`text/plain`,String(t.id)),e.dataTransfer.effectAllowed=`move`}:void 0,onDragOver:Ae?e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`}:void 0,onDrop:Ae?e=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);if(!n||n===String(t.id))return;let r=at.get(n);r&&String(r.parent??``)===String(t.parent??``)&&Ae(r,t)}:void 0,onContextMenu:e=>Ut(t,e),onClick:()=>{Vt(t.id),n||o?.(t)},onDoubleClick:()=>{je&&N&&!e.isSummary&&!t.locked&&($e(t.id),tt({title:t.title,start:t.start.toLocaleDateString(`en-CA`),end:t.end.toLocaleDateString(`en-CA`),progress:String(t.progress)}))},children:[(0,u.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,u.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(),qt(t.id)},"aria-expanded":!r,"aria-label":D(r?`gantt.row.expand`:`gantt.row.collapse`),"data-testid":`gantt-row-toggle-${t.id}`,children:r?(0,u.jsx)(l.ChevronRight,{className:`h-3.5 w-3.5`}):(0,u.jsx)(l.ChevronDown,{className:`h-3.5 w-3.5`})}):(0,u.jsx)(`span`,{className:`w-3 shrink-0`,style:{marginLeft:-4},"aria-hidden":`true`}),(0,u.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0`,style:{backgroundColor:t.color||`#3b82f6`}}),n?(0,u.jsx)(`input`,{className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:et.title||``,onChange:e=>tt(t=>({...t,title:e.target.value})),onKeyDown:e=>{e.key===`Enter`?(V([{task:t,changes:{title:et.title,start:new Date(et.start),end:new Date(et.end),progress:Number(et.progress)||0}}]),$e(null)):e.key===`Escape`&&$e(null)},onClick:e=>e.stopPropagation(),autoFocus:!0}):(0,u.jsxs)(`span`,{className:`flex flex-col min-w-0`,children:[(0,u.jsx)(`span`,{className:(0,s.cn)(`truncate`,e.isSummary&&`font-semibold`),children:t.title}),(0,u.jsxs)(`span`,{className:`text-[10px] text-muted-foreground gantt-sm-hidden`,children:[e.start.toLocaleDateString(O,{month:`numeric`,day:`numeric`}),` → `,e.end.toLocaleDateString(O,{month:`numeric`,day:`numeric`})]})]})]}),(0,u.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!Ze,style:Ze?void 0:{display:`none`},children:n?(0,u.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:et.start||``,onChange:e=>tt(t=>({...t,start:e.target.value})),onClick:e=>e.stopPropagation()}):e.start.toLocaleDateString(O,{month:`numeric`,day:`numeric`})}),(0,u.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!Ze,style:Ze?void 0:{display:`none`},children:n?(0,u.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:et.end||``,onChange:e=>tt(t=>({...t,end:e.target.value})),onClick:e=>e.stopPropagation()}):e.end.toLocaleDateString(O,{month:`numeric`,day:`numeric`})}),!n&&(0,u.jsx)(`button`,{type:`button`,title:D(`gantt.row.locate`),"aria-label":D(`gantt.row.locate`),className:`gantt-locate-btn hidden sm:block absolute top-1/2 -translate-y-1/2`,style:{right:1},onClick:t=>{t.stopPropagation(),Pn(e.start,e.end,e.task.id)},children:(0,u.jsx)(l.Crosshair,{className:`w-3 h-3`})})]},t.id)}),Z.endIdx<W.length&&(0,u.jsx)(`div`,{style:{height:(W.length-Z.endIdx)*F},"aria-hidden":`true`})]}),(0,u.jsx)(`div`,{className:`flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]`,ref:e=>{un.current=e,X.current=e},onScroll:Ln,onTouchStart:On,onTouchMove:kn,onTouchEnd:An,"data-testid":`gantt-timeline`,children:(0,u.jsxs)(`div`,{className:`relative`,style:{width:Qt},children:[Q!=null&&(0,u.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px z-20 pointer-events-none`,style:{left:Q,backgroundColor:`rgba(239, 68, 68, 0.8)`},"data-testid":`gantt-today-marker`,"aria-label":D(`gantt.toolbar.today`),children:(0,u.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:D(`gantt.toolbar.today`)})}),sn.map(e=>(0,u.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,u.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,u.jsxs)(`div`,{className:`relative`,ref:kt,children:[(0,u.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:q.slice(bn.start,bn.end).map((e,t)=>{let n=bn.start+t;return(0,u.jsx)(`div`,{className:`absolute top-0 bottom-0 border-r`,style:{left:J[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)})}),K&&S&&S.showMidnight&&(0,u.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:q.slice(bn.start,bn.end).map((e,t)=>{let n=bn.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();return o<=i||o>=i+r?null:(0,u.jsx)(`div`,{className:`absolute top-0 bottom-0`,style:{left:J[n]+(o-i)/r*e.width,borderLeft:`1px dashed hsl(var(--muted-foreground) / 0.4)`},"data-testid":`gantt-midnight-${n}`,"aria-hidden":`true`},`midnight-${n}`)})}),Z.startIdx>0&&(0,u.jsx)(`div`,{style:{height:Z.startIdx*F},"aria-hidden":`true`}),W.slice(Z.startIdx,Z.endIdx).map(e=>{let n=e.task,r=sr(n.id),i=zn(e.start,e.end),a=ee&&n.baselineStart&&n.baselineEnd?zn(n.baselineStart,n.baselineEnd):null,o=a?(0,u.jsx)(`div`,{className:`absolute pointer-events-none rounded-[1px]`,style:{left:a.left,width:Math.max(2,a.width),top:$n,height:Qn,backgroundColor:er,border:`1px solid ${tr}`},"data-testid":`gantt-baseline-${n.id}`,"aria-hidden":`true`}):null,c=B?.taskId===n.id,l=Vn?.has(String(n.id))??!1,d=Hn?.has(String(n.id))??!1,f=c||l||d?Un(e):i,p=!!n.locked,m=!!N&&!e.isSummary&&!p,h=H!=null&&H.targetId!=null&&String(H.targetId)===String(n.id)&&String(H.sourceId)!==String(n.id),g=H?e=>{let t=e.currentTarget.getBoundingClientRect(),r=t.width>0&&e.clientX-t.left>t.width/2?`end`:`start`;At(e=>e&&String(e.sourceId)!==String(n.id)?{...e,targetId:n.id,targetEnd:r}:e)}:void 0,_=H?e=>{e.target===e.currentTarget&&At(e=>e&&{...e,targetId:null,targetEnd:null})}:void 0,v=Math.max(1,Math.round((e.end.getTime()-e.start.getTime())/ve)),y=nt===n.id&&!B&&!Et&&!H?(0,u.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(f.left+8,4),top:F-8},role:`tooltip`,"data-testid":`gantt-tooltip-${n.id}`,children:[(0,u.jsx)(`div`,{className:`font-semibold`,children:n.title}),n.fields&&n.fields.length>0?(0,u.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`auto 1fr`,columnGap:10,rowGap:2,marginTop:4},children:n.fields.map((e,n)=>(0,u.jsxs)(t.Fragment,{children:[(0,u.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,u.jsx)(`span`,{style:{fontWeight:500},children:e.value})]},n))}):(0,u.jsxs)(`div`,{className:`text-muted-foreground`,children:[e.start.toLocaleDateString(O,{month:`short`,day:`numeric`}),` → `,e.end.toLocaleDateString(O,{month:`short`,day:`numeric`}),` · `,v,D(`gantt.tooltip.days`),` · `,Math.round(e.progress),`%`]})]}):null;if(n.type===`group`)return(0,u.jsx)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:F},onPointerMove:_,children:y},n.id);if(e.isSummary){let t=n.color||`#0d9488`;return(0,u.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:F},onPointerMove:_,children:[o,(0,u.jsxs)(`div`,{className:(0,s.cn)(`gantt-bar-hover absolute rounded-sm border shadow-sm flex items-center px-2 select-none`,N?`cursor-grab active:cursor-grabbing`:`cursor-pointer`,c&&`ring-2 ring-primary z-10`,dn===n.id&&`gantt-flash z-10`),style:{left:f.left,width:f.width,top:Zn,height:Xn,backgroundColor:t,borderColor:r?$:`hsl(var(--primary-foreground) / 0.2)`,boxShadow:r?`0 0 0 2px ${$}`:void 0},"data-critical":r?`true`:void 0,"data-testid":`gantt-summary-bar-${n.id}`,"data-progress":Math.round(e.progress),onMouseEnter:()=>rt(n.id),onMouseLeave:()=>rt(e=>e===n.id?null:e),onPointerDown:t=>{t.button===0&&Tt(n,`move`,t,{group:!0,originStart:e.start,originEnd:e.end})},onClick:()=>{lt.current||Vt(n.id)},onContextMenu:e=>Ut(n,e),children:[(0,u.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)`}}),(0,u.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none`,children:n.title})]}),c&&B&&(0,u.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(f.left,4),top:Zn+Xn+2},"data-testid":`gantt-summary-drag-chip-${n.id}`,children:[ut(B).start.toLocaleDateString(O,{month:`numeric`,day:`numeric`}),` → `,ut(B).end.toLocaleDateString(O,{month:`numeric`,day:`numeric`})]}),y]},n.id)}if(e.isMilestone){let e=Jn;return(0,u.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:F},onPointerMove:_,children:[o,(0,u.jsx)(`div`,{className:(0,s.cn)(`gantt-bar-hover absolute rotate-45 rounded-[2px] border shadow-sm select-none`,m?`cursor-grab active:cursor-grabbing`:`cursor-pointer`,c&&`ring-2 ring-primary z-10`,h&&`ring-2 ring-primary`,dn===n.id&&`gantt-flash z-10`),style:{left:f.left-e/2,top:(F-e)/2,width:e,height:e,backgroundColor:r?$:n.color||`#3b82f6`,borderColor:r?$:`hsl(var(--primary-foreground) / 0.2)`,boxShadow:r?`0 0 0 2px ${$}`:void 0},"data-critical":r?`true`:void 0,"data-testid":`gantt-milestone-${n.id}`,onMouseEnter:()=>rt(n.id),onMouseLeave:()=>rt(e=>e===n.id?null:e),onClick:()=>{lt.current||Vt(n.id)},onContextMenu:e=>Ut(n,e),onPointerMove:g,onPointerDown:m?e=>{e.button===0&&Tt(n,`move`,e)}:void 0}),y]},n.id)}let b=Et&&Et.taskId===n.id?Et.value:n.progress;return(0,u.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:F},onPointerMove:_,onMouseEnter:()=>rt(n.id),onMouseLeave:()=>rt(e=>e===n.id?null:e),children:[c&&(0,u.jsx)(`div`,{className:`absolute rounded-sm border border-dashed pointer-events-none`,style:{left:i.left,width:i.width,top:Gn,height:Kn,opacity:.35,borderColor:`hsl(var(--primary) / 0.6)`},"aria-hidden":`true`}),o,(0,u.jsxs)(`div`,{className:(0,s.cn)(`gantt-bar-hover absolute rounded-sm bg-primary border shadow-sm flex items-center px-2 group select-none`,m?`cursor-grab active:cursor-grabbing`:`cursor-pointer`,c&&`ring-2 ring-primary z-10`,h&&`ring-2 ring-primary`,dn===n.id&&`gantt-flash z-10`),style:{left:f.left,width:f.width,top:Gn,height:Kn,backgroundColor:n.color||`#3b82f6`,borderColor:r?$:`hsl(var(--primary-foreground) / 0.2)`,boxShadow:r?`0 0 0 2px ${$}`:void 0},"data-critical":r?`true`:void 0,"data-testid":`gantt-task-bar-${n.id}`,onClick:()=>{lt.current||Vt(n.id)},onContextMenu:e=>Ut(n,e),onPointerMove:g,onPointerDown:m?e=>{e.button===0&&Tt(n,`move`,e)}:void 0,children:[m&&f.width>=14&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0`,style:{width:6,height:qn,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${n.id}`,onPointerDown:e=>{e.button===0&&Tt(n,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,u.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:6,height:qn,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${n.id}`,onPointerDown:e=>{e.button===0&&Tt(n,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),b>0&&(0,u.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 pointer-events-none`,style:{width:`${b}%`,backgroundColor:`rgba(0, 0, 0, 0.2)`,borderTopLeftRadius:`var(--radius-sm)`,borderBottomLeftRadius:`var(--radius-sm)`}}),m&&f.width>=30&&(0,u.jsx)(`div`,{className:(0,s.cn)(`absolute bottom-0 h-1/2 w-4 -translate-x-1/2 cursor-col-resize flex items-end justify-center pb-px`,Et?.taskId===n.id?`opacity-100`:`opacity-0 group-hover:opacity-100 transition-opacity`),style:{left:`${b}%`},"data-testid":`gantt-progress-handle-${n.id}`,onPointerDown:e=>{e.button===0&&(e.stopPropagation(),e.preventDefault(),Dt({taskId:n.id,originClientX:e.clientX,originProgress:n.progress,barWidth:f.width,value:n.progress}))},onClick:e=>e.stopPropagation(),children:(0,u.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))`}})}),P&&!p&&[`start`,`end`].map(e=>{let t=H!=null&&String(H.sourceId)===String(n.id)&&H.sourceEnd===e,r=t||nt===n.id,i=r&&H==null;return(0,u.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:+!!r,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}-${n.id}`,onPointerDown:t=>{if(t.button!==0)return;t.stopPropagation(),t.preventDefault();let r=kt.current?.getBoundingClientRect();At({sourceId:n.id,sourceEnd:e,x:r?t.clientX-r.left:0,y:r?t.clientY-r.top:0,targetId:null,targetEnd:null})},onClick:e=>e.stopPropagation(),children:(0,u.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,u.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none group-hover:opacity-0 transition-opacity`,children:n.title}),(0,u.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:c?`${ut(B).start.toLocaleDateString(O,{month:`numeric`,day:`numeric`})} → ${ut(B).end.toLocaleDateString(O,{month:`numeric`,day:`numeric`})}`:`${Math.round(b)}%`})]}),y]},n.id)}),Z.endIdx<W.length&&(0,u.jsx)(`div`,{style:{height:(W.length-Z.endIdx)*F},"aria-hidden":`true`}),(Wn.length>0||H)&&(0,u.jsxs)(`svg`,{className:`absolute top-0 left-0 pointer-events-none z-10`,width:Qt,height:Cn,"data-testid":`gantt-links`,"aria-hidden":`true`,children:[(0,u.jsxs)(`defs`,{children:[(0,u.jsx)(`marker`,{id:`gantt-link-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,u.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--muted-foreground))`})}),(0,u.jsx)(`marker`,{id:`gantt-link-arrow-active`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,u.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--primary))`})}),(0,u.jsx)(`marker`,{id:`gantt-link-arrow-critical`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,u.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:$})})]}),Wn.map(e=>{let n=Math.min(e.sourceIndex,e.targetIndex);if(Math.max(e.sourceIndex,e.targetIndex)<Z.startIdx-6||n>Z.endIdx+6)return null;let r=nr(e);if(!r)return null;let i=rr!=null&&(String(e.sourceId)===String(rr)||String(e.targetId)===String(rr)),a=or?.criticalEdges.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,o=a?`gantt-link-arrow-critical`:i?`gantt-link-arrow-active`:`gantt-link-arrow`,s=!!(ke||P);return(0,u.jsxs)(t.Fragment,{children:[(0,u.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,u.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=>Wt(e.sourceId,e.targetId,e.type,t)})]},e.key)}),H&&(()=>{let e=W.findIndex(e=>String(e.task.id)===String(H.sourceId));if(e<0)return null;let t=Un(W[e]),n=W[e].isMilestone?t.left+(H.sourceEnd===`start`?-Yn:Yn):H.sourceEnd===`start`?t.left:t.left+t.width,r=e*F+F/2;return(0,u.jsx)(`path`,{d:`M ${Math.round(n)} ${Math.round(r)} L ${Math.round(H.x)} ${Math.round(H.y)}`,fill:`none`,stroke:`hsl(var(--primary))`,strokeWidth:1.5,strokeDasharray:`4 3`,"data-testid":`gantt-link-draft`})})()]}),H&&(()=>{let t=e.find(e=>String(e.id)===String(H.sourceId));if(!t)return null;let n=H.targetId==null?null:e.find(e=>String(e.id)===String(H.targetId)),r=e=>D(`gantt.linkEnd.${e}`),i=n?`${t.title} (${r(H.sourceEnd)}) → ${n.title} (${r(H.targetEnd??`start`)})`:`${t.title} (${r(H.sourceEnd)})`;return(0,u.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:H.x+12,top:H.y+12},"data-testid":`gantt-link-draft-hint`,children:i})})()]})]})})]})]}),Mt&&(()=>{let t=e.find(e=>String(e.id)===String(Mt.taskId));if(!t)return null;let n=W.find(e=>String(e.task.id)===String(Mt.taskId)),r=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`;return(0,u.jsxs)(`div`,{ref:Pt,className:`fixed z-50 min-w-[160px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:Mt.x,top:Mt.y},role:`menu`,"data-testid":`gantt-context-menu`,children:[o&&(0,u.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-view`,onClick:()=>{Nt(null),o(t)},children:D(`gantt.menu.view`)}),je&&N&&n&&!n.isSummary&&!t.locked&&(0,u.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-edit`,onClick:()=>{Nt(null),$e(t.id),tt({title:t.title,start:t.start.toLocaleDateString(`en-CA`),end:t.end.toLocaleDateString(`en-CA`),progress:String(t.progress)})},children:D(`gantt.menu.edit`)}),P&&n&&!n.isMilestone&&!t.locked&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-add-predecessor`,onClick:()=>{let e=Mt;Nt(null),Rt({x:e.x,y:e.y,taskId:t.id,relation:`pred`})},children:D(`gantt.menu.addPredecessor`)}),(0,u.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-add-successor`,onClick:()=>{let e=Mt;Nt(null),Rt({x:e.x,y:e.y,taskId:t.id,relation:`succ`})},children:D(`gantt.menu.addSuccessor`)})]}),Oe&&!t.locked&&(0,u.jsx)(`button`,{type:`button`,role:`menuitem`,className:(0,s.cn)(r,`text-destructive`),"data-testid":`gantt-context-menu-delete`,onClick:()=>{Nt(null),Oe(t)},children:D(`gantt.menu.delete`)})]})})(),U&&(()=>{let t=e.find(e=>String(e.id)===String(U.sourceId)),n=e.find(e=>String(e.id)===String(U.targetId));if(!t||!n)return null;let r=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`;return(0,u.jsxs)(`div`,{ref:It,className:`fixed z-50 min-w-[180px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:U.x,top:U.y},role:`menu`,"data-testid":`gantt-link-context-menu`,children:[(0,u.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground truncate`,children:[t.title,` → `,n.title]}),P&&[`fs`,`ss`,`ff`,`sf`].map(e=>(0,u.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":U.type===e,className:(0,s.cn)(r,U.type===e&&`font-semibold`),"data-testid":`gantt-link-menu-type-${e}`,onClick:()=>{Ft(null),e!==U.type&&P(t,n,e)},children:[U.type===e?`✓ `:`\xA0\xA0`,D(`gantt.linkType.${e}`)]},e)),ke&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{className:`my-1 border-t`}),(0,u.jsx)(`button`,{type:`button`,role:`menuitem`,className:(0,s.cn)(r,`text-destructive`),"data-testid":`gantt-link-menu-remove`,onClick:()=>{Ft(null),ke(t,n)},children:D(`gantt.menu.removeDependency`)})]})]})})(),Lt&&P&&(()=>{let t=e.find(e=>String(e.id)===String(Lt.taskId));if(!t)return null;let n=new Set(Wn.map(e=>`${String(e.sourceId)}->${String(e.targetId)}`)),r=e.filter(e=>{if(String(e.id)===String(t.id)||e.type===`summary`)return!1;let r=Lt.relation===`pred`?`${String(e.id)}->${String(t.id)}`:`${String(t.id)}->${String(e.id)}`;return!n.has(r)});return(0,u.jsxs)(`div`,{ref:zt,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:Lt.x,top:Lt.y},role:`menu`,"data-testid":`gantt-dep-picker`,children:[(0,u.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:Lt.relation===`pred`?D(`gantt.menu.addPredecessor`):D(`gantt.menu.addSuccessor`)}),r.length===0?(0,u.jsx)(`div`,{className:`px-3 py-1.5 text-muted-foreground`,children:D(`gantt.menu.noCandidates`)}):r.map(e=>(0,u.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-${e.id}`,onClick:()=>{Rt(null),Lt.relation===`pred`?P(e,t,`fs`):P(t,e,`fs`)},children:e.title},String(e.id)))]})})(),gt&&(0,u.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-conflict-overlay`,onClick:()=>_t(null),children:(0,u.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,u.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-conflict-title`,children:D(`gantt.conflict.title`)}),(0,u.jsx)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:D(`gantt.conflict.body`).replace(`{count}`,String(gt.length))}),(0,u.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,u.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:()=>_t(null),children:D(`gantt.conflict.cancel`)}),(0,u.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:yt,children:D(`gantt.conflict.confirm`)})]})]})})]})}function M(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 N(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)M(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 Oe={day:26,week:56,month:76,quarter:88,year:104},P=48,ke=34,Ae=180;function je(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 Me({tasks:e,assignee:n,effort:r,capacity:i=1,viewMode:a=`day`,unassignedLabel:o=`Unassigned`,className:s}){let{t:c,language:l}=fe(),d=l||void 0,f=Oe[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=ye(t,a),i=xe(ye(n,a),1,a),o=[],s=0;for(;r<i&&s++<4e3;){let e=xe(r,1,a);o.push({date:new Date(r),col:{start:new Date(r),end:new Date(e)},label:je(r,a,d)}),r=e}return o},[e,a,d]),m=t.useMemo(()=>N(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,u.jsx)(`div`,{className:s,"data-testid":`resource-workload`,style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`auto`},children:(0,u.jsxs)(`div`,{style:{display:`flex`,minWidth:Ae+g},children:[(0,u.jsxs)(`div`,{style:{width:Ae,flexShrink:0},children:[(0,u.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,u.jsxs)(`div`,{"data-testid":`resource-row-${e.key}`,style:{height:P,display:`flex`,flexDirection:`column`,justifyContent:`center`,padding:`0 12px`,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,u.jsx)(`span`,{style:{fontSize:13,fontWeight:500,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:e.label}),(0,u.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,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(`div`,{style:{display:`flex`,height:28,borderBottom:`1px solid hsl(var(--border))`},children:p.map((e,t)=>(0,u.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=ke*(1-Math.min(e.capacity/h,1));return(0,u.jsxs)(`div`,{style:{position:`relative`,display:`flex`,height:P,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,u.jsx)(`div`,{"aria-hidden":`true`,style:{position:`absolute`,left:0,right:0,top:(P-ke)/2+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,ke*Math.min(t.load/h,1));return(0,u.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(d)} — ${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:(P-ke)/2},children:t.load>0&&(0,u.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,u.jsx)(`div`,{className:s,"data-testid":`resource-workload`,children:(0,u.jsx)(`div`,{className:`flex items-center justify-center h-40 text-sm text-muted-foreground`,children:c(`gantt.resource.empty`)})})}var Ne={display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8,padding:`8px 12px`,borderBottom:`1px solid hsl(var(--border))`,background:`hsl(var(--background))`,fontSize:13},F={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`},Pe={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)`},Fe={display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,borderRadius:6,cursor:`pointer`,userSelect:`none`};function Ie({checked:e}){return(0,u.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 Le({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,d=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,u.jsxs)(`div`,{ref:s,style:{position:`relative`},"data-testid":`quick-filter-${e.field}`,children:[(0,u.jsxs)(`button`,{type:`button`,style:{...F,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,u.jsx)(`span`,{children:m}),(0,u.jsx)(`span`,{"aria-hidden":!0,style:{fontSize:10,opacity:.7},children:`▾`})]}),a&&(0,u.jsx)(`div`,{role:`listbox`,style:Pe,"data-testid":`quick-filter-panel-${e.field}`,children:e.options.length===0?(0,u.jsx)(`div`,{style:{...Fe,cursor:`default`,opacity:.6},children:i.empty}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{role:`option`,"aria-selected":d,style:{...Fe,fontWeight:600},"data-testid":`quick-filter-all-${e.field}`,onClick:()=>p(),children:[(0,u.jsx)(Ie,{checked:d}),(0,u.jsx)(`span`,{children:i.all})]}),(0,u.jsx)(`div`,{style:{height:1,background:`hsl(var(--border))`,margin:`2px 0`}}),e.options.map(t=>{let n=c.has(t.value);return(0,u.jsxs)(`div`,{role:`option`,"aria-selected":n,style:{...Fe,background:n?`hsl(var(--accent, var(--muted)))`:`transparent`},"data-testid":`quick-filter-option-${e.field}-${t.value}`,onClick:()=>f(t.value),children:[(0,u.jsx)(Ie,{checked:n}),(0,u.jsx)(`span`,{children:t.label})]},t.value)})]})})]})}var Re=({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`,d=o?.clear??`Clear`,f=e.some(e=>(t[e.field]?.length??0)>0);return(0,u.jsxs)(`div`,{style:Ne,className:s,"data-testid":`quick-filter-bar`,children:[e.map(e=>(0,u.jsx)(Le,{filter:e,selected:t[e.field]??[],onChange:t=>n(e.field,t),labels:{all:c,empty:l}},e.field)),f&&(0,u.jsx)(`button`,{type:`button`,style:{...F,height:28,color:`hsl(var(--muted-foreground))`},"data-testid":`quick-filter-clear`,onClick:r,children:d}),o?.resultSummary&&i!=null&&a!=null&&(0,u.jsx)(`span`,{"data-testid":`quick-filter-summary`,style:{marginLeft:`auto`,color:`hsl(var(--muted-foreground))`},children:o.resultSummary(i,a)})]})};function ze(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 Be={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 I(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=Be[String(n.type??``).toLowerCase().replace(/-/g,`_`)];t.push(r?{id:e,type:r}:{id:e})}else t.push(n);return t}function Ve(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function He(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function Ue(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,parentField:e.parentField,typeField:e.typeField,lockField:e.lockField,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,timeSegments:e.timeSegments},t;if(e.gantt&&(t=e.gantt),t){let e=i.GanttConfigSchema.safeParse(t);return e.success||console.warn(`[ObjectGantt] Invalid gantt configuration:`,e.error.format()),t}return null}var We=({schema:e,dataSource:i,className:l,onTaskClick:d,onRowClick:f,...p})=>{let[m,h]=(0,t.useState)([]),[g,_]=(0,t.useState)(!0),[v,y]=(0,t.useState)(null),[b,x]=(0,t.useState)(null),{currency:S}=(0,a.useLocalization)(),ee=Ve(e),C=(0,t.useMemo)(()=>ee,[JSON.stringify(ee)]),w=Ue(e),T=C?.provider===`value`;(0,t.useEffect)(()=>{(async()=>{try{if(_(!0),p.data&&Array.isArray(p.data)){h(p.data),_(!1);return}if(T&&C?.provider===`value`){h(C.items),_(!1);return}if(!i||typeof i.find!=`function`)throw Error(`DataSource required for object/api providers`);if(C?.provider===`object`){let t=C.object,r=(0,n.buildExpandFields)(b?.fields),a=(0,n.extractRecords)(await i.find(t,{$filter:e.filter,$orderby:He(e.sort),...r.length>0?{$expand:r}:{}}));h(a)}else C?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectGantt`),h([]));_(!1)}catch(e){y(e),_(!1)}})()},[C,i,T,e.filter,e.sort,b]),(0,t.useEffect)(()=>{!T&&i&&(async()=>{try{if(!i)return;let t=C?.provider===`object`?C.object:e.objectName;if(!t)return;let n=await i.getObjectSchema(t);x(n)}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,i,T,C]);let E=(0,t.useMemo)(()=>{if(!w||!m.length)return[];let{startDateField:e,endDateField:t,titleField:r,progressField:i,dependenciesField:o,colorField:s,parentField:l,typeField:u,lockField:d,tooltipFields:f,baselineStartField:p,baselineEndField:h}=w,g=b?.fields??{},_=(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},v=e=>{let t=[_(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)},y=(e,t)=>{if(t)return t;let n=g[e]??g[e.split(`.`)[0]];return n?.label?n.label:(0,c.humanizeLabel)(e)},x=(e,t)=>{if(e==null||e===``)return`—`;let n=g[t]??g[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}switch(r){case`date`:return(0,c.formatDate)(e);case`datetime`:return(0,c.formatDateTime)(e);case`number`:case`integer`:case`float`:case`decimal`:return(0,c.formatNumber)(Number(e));case`currency`:return(0,c.formatCurrency)(Number(e),(0,a.resolveFieldCurrency)(n,S));case`percent`:return(0,c.formatPercent)(Number(e));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)}},ee=e=>{if(!f||!f.length)return;let t=[];for(let n of f){let r=typeof n==`string`?n:n?.field;if(!r)continue;let i=typeof n==`object`?n.label:void 0;t.push({label:y(r,i),value:x(_(e,r),r)})}return t.length?t:void 0};return m.map((n,r)=>{let a=n[e],f=n[t],m=p?n[p]:void 0,g=h?n[h]:void 0,_=m?new Date(m):void 0,y=g?new Date(g):void 0,b=v(n),x=i?n[i]:0,S=o?n[o]:[],C=s?n[s]:void 0;if(!C){let e=n.status??n.state??n.priority??n.severity;if(e!=null&&e!==``){let t=(0,c.getSemanticColorName)(void 0,e);t&&(C=(0,c.getSemanticHex)(t))}}return{id:n.id||n._id||`task-${r}`,title:b,start:a?new Date(a):new Date,end:f?new Date(f):new Date,progress:Math.min(100,Math.max(0,x||0)),dependencies:I(S),parent:l?n[l]??null:void 0,type:u?ze(n[u]):void 0,locked:d?!!n[d]:void 0,color:C,baselineStart:_&&!isNaN(_.getTime())?_:void 0,baselineEnd:y&&!isNaN(y.getTime())?y:void 0,fields:ee(n),data:n}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[m,w,b]),te=(0,t.useMemo)(()=>{let e=w?.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)}}},[w?.groupByField,b]),ne=(0,t.useMemo)(()=>{let e=w?.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)}}},[w?.assigneeField,b]),re=(0,t.useMemo)(()=>{let e=w?.effortField;if(e)return t=>{let n=t.data?.[e],r=Number(n);return Number.isFinite(r)&&r>0?r:1}},[w?.effortField]),ie=(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]),ae=(0,t.useMemo)(()=>se(w?.timeSegments),[w?.timeSegments]),D=(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)},[]),oe=w?.quickFilters,[O,ce]=(0,t.useState)({});(0,t.useEffect)(()=>{if(!oe?.length||!i||typeof i.find!=`function`)return;let e=b?.fields??{},t=!1;return(async()=>{let r={};for(let t of oe){if(t.options)continue;let a=e[t.field]??e[t.field.split(`.`)[0]],o=a?.type;if(o!==`lookup`&&o!==`master_detail`)continue;let s=a?.reference_to??a?.referenceTo;if(s)try{let e=(0,n.extractRecords)(await i.find(s,{$top:1e3}));r[t.field]=e.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||ce(e=>({...e,...r}))})(),()=>{t=!0}},[JSON.stringify(oe),i,b]);let le=(0,t.useMemo)(()=>{if(!oe?.length)return[];let e=b?.fields??{};return oe.map(t=>{let n=e[t.field]??e[t.field.split(`.`)[0]],r=t.label??n?.label??(0,c.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(O[t.field]?.length)i=O[t.field];else{let e=new Map;for(let n of m){let r=D(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}})},[oe,b,O,m,D]),[ue,de]=(0,t.useState)({}),fe=(0,t.useCallback)((e,t)=>{de(n=>({...n,[e]:t}))},[]),pe=(0,t.useCallback)(()=>de({}),[]),me=(0,t.useMemo)(()=>{let e=Object.entries(ue).filter(([,e])=>e.length>0);return e.length?E.filter(t=>e.every(([e,n])=>{let r=D(t.data,e);return r!=null&&n.includes(r)})):E},[E,ue,D]),he=(0,t.useMemo)(()=>{if(w?.autoZoomToFilter!==!1||!E.length)return null;let e=E[0].start.getTime(),t=E[0].end.getTime();for(let n of E)e=Math.min(e,n.start.getTime()),t=Math.max(t,n.end.getTime());return{start:new Date(e),end:new Date(t)}},[E,w?.autoZoomToFilter]),ge=e.navigation??{mode:`drawer`,width:`min(960px, 60vw)`},k=ge.mode===`drawer`||ge.mode===`modal`||ge.mode===`split`||ge.mode===`popover`,_e=(0,r.useNavigationOverlay)({navigation:ge,objectName:e.objectName,onRowClick:k?void 0:f}),ve=(0,t.useCallback)(async(t,n)=>{if(!w)return;let r=C?.provider===`object`?C.object:e.objectName;if(!r||!i||typeof i.update!=`function`)return;let{startDateField:a,endDateField:o,titleField:s,progressField:c}=w,l={};if(n.start instanceof Date&&(l[a]=n.start.toISOString()),n.end instanceof Date&&(l[o]=n.end.toISOString()),typeof n.title==`string`&&s&&(l[s]=n.title),typeof n.progress==`number`&&c&&(l[c]=n.progress),Object.keys(l).length===0)return;let u=t.data?.id??t.data?._id??t.id;if(u==null)return;let d=m;h(e=>e.map(e=>String(e.id??e._id)===String(u)?{...e,...l}:e));try{await i.update(r,String(u),l)}catch(e){console.error(`[ObjectGantt] Failed to persist task update:`,e),h(d)}},[w,C,i,e.objectName,m]),ye=(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)},be=(0,t.useCallback)(async(t,n,r)=>{let a=w?.dependenciesField;if(!a)return;let o=C?.provider===`object`?C.object:e.objectName;if(!o||!i||typeof i.update!=`function`)return;let s=ye(n,r),c=m;h(e=>e.map(e=>String(e.id??e._id)===String(t)?{...e,[a]:s}:e));try{await i.update(o,String(t),{[a]:s})}catch(e){console.error(`[ObjectGantt] Failed to persist dependency:`,e),h(c)}},[w,C,i,e.objectName,m]),xe=(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=w?.dependenciesField;if(!a)return;let o=m.find(e=>String(e.id??e._id)===String(i))?.[a],s=I(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 be(i,o,f)},[w,m,be]),Se=(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=w?.dependenciesField;if(!i)return;let a=m.find(e=>String(e.id??e._id)===String(r))?.[i],o=I(a),s=e=>String(typeof e==`object`?e.id:e),c=o.filter(e=>s(e)!==String(n));c.length!==o.length&&await be(r,a,c)},[w,m,be]),[A,Ce]=(0,t.useState)(null),[we,j]=(0,t.useState)(!1),Te=(0,t.useCallback)(e=>{Ce(e)},[]),Ee=(0,t.useCallback)(async()=>{if(!A)return;let t=C?.provider===`object`?C.object:e.objectName;if(!t||!i?.delete){Ce(null);return}let n=A.data?.id??A.data?._id??A.id;if(n==null){Ce(null);return}j(!0);let r=m;h(e=>e.filter(e=>String(e.id??e._id)!==String(n)));try{await i.delete(t,String(n)),Ce(null)}catch(e){console.error(`[ObjectGantt] Failed to delete:`,e),h(r),Ce(null)}finally{j(!1)}},[A,C,i,e.objectName,m]);return g?(0,u.jsx)(`div`,{className:l,children:(0,u.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,u.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading Gantt chart...`})})}):v?(0,u.jsx)(`div`,{className:l,children:(0,u.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,u.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,v.message]})})}):w?(0,u.jsxs)(`div`,{className:l,children:[le.length>0&&(0,u.jsx)(Re,{filters:le,value:ue,onChange:fe,onClear:pe,resultCount:me.length,totalCount:E.length,labels:{all:`全部`,clear:`清除筛选`,empty:`无可选项`,resultSummary:(e,t)=>`显示 ${e} / ${t} 项任务`}}),(0,u.jsx)(`div`,{className:`h-[calc(100vh-200px)] min-h-[600px]`,children:w?.resourceView&&ne?(0,u.jsx)(Me,{tasks:me,assignee:ne,effort:re,capacity:w?.capacity??1,viewMode:e.viewMode||`day`}):(0,u.jsx)(De,{tasks:me,startDate:he?.start,endDate:he?.end,onTaskClick:e=>{_e.handleClick(e.data),d?.(e.data)},onTaskUpdate:ve,onTaskDelete:Te,onDependencyCreate:w?.dependenciesField?xe:void 0,onDependencyDelete:w?.dependenciesField?Se:void 0,markers:e.markers,autoSchedule:!!w?.dependenciesField,rescheduleOnConflict:!!w?.dependenciesField,criticalPathDefault:!!e.criticalPath,workingCalendar:ie,shiftSegments:ae,showBaselines:e.showBaselines!==!1,readOnly:!!e.readOnly,mobileReadOnly:e.mobileReadOnly!==!1,persistLayoutKey:e.persistLayout===!1?void 0:`${e.objectName||(C?.provider===`object`?C.object:``)||`gantt`}:${e.viewName||`default`}`,groupBy:te,defaultCollapsedDepth:w?.defaultCollapsedDepth,inlineEdit:!0})}),_e.isOverlay&&_e.isOpen&&_e.selectedRecord&&(()=>{let t=C?.provider===`object`?C.object:e.objectName,n=_e.selectedRecord,r=n.id??n._id;if(!t||r==null)return null;let a=w?.titleField?String(n[w.titleField]??`Task Details`):`Task Details`;return(0,u.jsx)(o.RecordDetailDrawer,{open:!0,onClose:_e.close,title:a,record:n,objectName:t,recordId:r,dataSource:i,objectSchema:b,width:_e.width,fullPageHref:(0,o.deriveRecordPageHref)(t,r)??void 0,onFieldSave:async(e,n)=>{i?.update&&(await i.update(t,String(r),{[e]:n}),h(t=>t.map(t=>String(t.id??t._id)===String(r)?{...t,[e]:n}:t)))},onDelete:async()=>{i?.delete&&(await i.delete(t,String(r)),h(e=>e.filter(e=>String(e.id??e._id)!==String(r))))}})})(),(0,u.jsx)(s.AlertDialog,{open:!!A,onOpenChange:e=>{!e&&!we&&Ce(null)},children:(0,u.jsxs)(s.AlertDialogContent,{children:[(0,u.jsxs)(s.AlertDialogHeader,{children:[(0,u.jsx)(s.AlertDialogTitle,{children:`Delete this task?`}),(0,u.jsx)(s.AlertDialogDescription,{children:A?(0,u.jsxs)(u.Fragment,{children:[`"`,A.title,`" will be permanently removed. This action cannot be undone.`]}):null})]}),(0,u.jsxs)(s.AlertDialogFooter,{children:[(0,u.jsx)(s.AlertDialogCancel,{disabled:we,children:`Cancel`}),(0,u.jsx)(s.AlertDialogAction,{onClick:e=>{e.preventDefault(),Ee()},disabled:we,"data-testid":`gantt-delete-confirm`,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:we?`Deleting…`:`Delete`})]})]})})]}):(0,u.jsx)(`div`,{className:l,children:(0,u.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,u.jsx)(`div`,{className:`text-muted-foreground`,children:`Gantt configuration required. Please specify startDateField, endDateField, and titleField.`})})})},Ge=({schema:e})=>{let{dataSource:t}=(0,r.useSchemaContext)()||{};return(0,u.jsx)(We,{schema:e,dataSource:t})};n.ComponentRegistry.register(`object-gantt`,Ge,{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`,Ge,{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=De,e.ObjectGantt=We,e.ObjectGanttRenderer=Ge,e.QuickFilterBar=Re,e.ResourceWorkload=Me,e.bandAt=le,e.computeWorkload=N,e.normalizeDependencies=I,e.normalizeShiftSegments=se,e.normalizeTaskType=ze,e.parseHHMM=O,e.shiftDayStart=ce});
95
+ `}),(0,f.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,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":k(`gantt.toolbar.prevPeriod`),children:(0,f.jsx)(u.ChevronLeft,{className:`h-4 w-4`})}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":k(`gantt.toolbar.nextPeriod`),children:(0,f.jsx)(u.ChevronRight,{className:`h-4 w-4`})}),(0,f.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,children:K.start.toLocaleDateString(A,{month:`long`,year:`numeric`})}),N&&(0,f.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:k(`gantt.readOnlyHint`),children:[(0,f.jsx)(u.Lock,{className:`h-3 w-3`}),k(`gantt.readOnly`)]})]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(`div`,{className:`flex bg-muted rounded-md p-1`,role:`group`,"aria-label":k(`gantt.toolbar.viewMode`),children:j.map(e=>(0,f.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:(0,c.cn)(`h-6 px-1.5 sm:px-2 text-xs`,z===e&&`bg-background shadow-sm hover:bg-background`),onClick:()=>Cn(e),"aria-pressed":z===e,"data-testid":`gantt-view-mode-${e}`,children:k(`gantt.viewMode.${e}`)},e))}),(0,f.jsxs)(`div`,{className:`flex bg-muted rounded-md p-1`,children:[(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(nt>15)We(Math.max(15,nt-10));else{let e=j.indexOf(z);e<j.length-1&&(Cn(j[e+1]),We(Be))}},"aria-label":k(`gantt.toolbar.zoomOut`),children:(0,f.jsx)(u.ZoomOut,{className:`h-3 w-3`})}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(nt<120)We(Math.min(120,nt+10));else{let e=j.indexOf(z);e>0&&(Cn(j[e-1]),We(Be))}},"aria-label":k(`gantt.toolbar.zoomIn`),children:(0,f.jsx)(u.ZoomIn,{className:`h-3 w-3`})})]}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>Qe(e=>!e),"aria-label":k(Ze?`gantt.toolbar.showTaskList`:`gantt.toolbar.hideTaskList`),"aria-pressed":Ze,"data-testid":`gantt-toggle-task-list`,children:Ze?(0,f.jsx)(u.PanelLeft,{className:`h-4 w-4`}):(0,f.jsx)(u.PanelLeftClose,{className:`h-4 w-4`})}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:Zn,disabled:Q==null,"aria-label":k(`gantt.toolbar.jumpToToday`),"data-testid":`gantt-jump-today`,children:k(`gantt.toolbar.today`)}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:tr,"aria-label":k(`gantt.toolbar.thisWeek`),"data-testid":`gantt-jump-week`,children:k(`gantt.toolbar.thisWeek`)}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:nr,"aria-label":k(`gantt.toolbar.thisMonth`),"data-testid":`gantt-jump-month`,children:k(`gantt.toolbar.thisMonth`)}),le?(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>void le(),disabled:ue,"aria-label":k(`gantt.toolbar.refresh`),"aria-busy":ue,"data-testid":`gantt-refresh`,children:(0,f.jsx)(u.RefreshCw,{className:`h-4 w-4`})}):null,P?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:kt,disabled:!jt,"aria-label":k(`gantt.toolbar.undo`),"data-testid":`gantt-undo`,children:(0,f.jsx)(u.Undo2,{className:`h-4 w-4`})}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:At,disabled:!Mt,"aria-label":k(`gantt.toolbar.redo`),"data-testid":`gantt-redo`,children:(0,f.jsx)(u.Redo2,{className:`h-4 w-4`})})]}):null,(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>Tr(e=>!e),"aria-label":k(`gantt.toolbar.criticalPath`),"aria-pressed":wr,"data-testid":`gantt-critical-path`,style:wr?{color:$}:void 0,children:(0,f.jsx)(u.Activity,{className:`h-4 w-4`})}),Re&&P?(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Or,"aria-label":k(`gantt.toolbar.autoSchedule`),"data-testid":`gantt-auto-schedule`,children:(0,f.jsx)(u.Wand2,{className:`h-4 w-4`})}):null,(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Ar,"aria-label":k(`gantt.toolbar.exportPng`),"data-testid":`gantt-export-png`,children:(0,f.jsx)(u.Download,{className:`h-4 w-4`})}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:jr,"aria-label":k(`gantt.toolbar.exportPdf`),"data-testid":`gantt-export-pdf`,children:(0,f.jsx)(u.FileDown,{className:`h-4 w-4`})}),ce||O?(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Pr,"aria-label":k(`gantt.toolbar.saveLayout`),"aria-pressed":Mr,"data-testid":`gantt-save-layout`,style:Mr?{color:$}:void 0,children:(0,f.jsx)(u.Save,{className:`h-4 w-4`})}):null,(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Kn,"aria-label":k(Wn?`gantt.toolbar.exitFullscreen`:`gantt.toolbar.enterFullscreen`),"aria-pressed":Wn,"data-testid":`gantt-fullscreen`,children:Wn?(0,f.jsx)(u.Minimize2,{className:`h-4 w-4`}):(0,f.jsx)(u.Maximize2,{className:`h-4 w-4`})})]})]}),(0,f.jsxs)(`div`,{className:`relative flex flex-col flex-1 overflow-hidden outline-none focus-visible:ring-1 focus-visible:ring-ring`,tabIndex:0,onKeyDown:hn,"data-testid":`gantt-body`,children:[!Ze&&B>0&&(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0 z-30 group/splitter`,style:{left:B-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=B,r=Math.max(160,Pe-200),i=e=>{let i=Math.max(160,Math.min(n+(e.clientX-t),r));Ke(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:()=>Ke(null),children:(0,f.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,f.jsxs)(`div`,{className:`flex border-b bg-muted/30 shrink-0 h-10 gantt-sm-h50`,children:[(0,f.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:B,minWidth:B},children:[(0,f.jsx)(`div`,{className:`flex-1 truncate`,children:k(`gantt.column.taskName`)}),it&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:k(`gantt.column.start`)}),(0,f.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:k(`gantt.column.end`)})]})]}),(0,f.jsx)(`div`,{className:`flex-1 overflow-hidden`,ref:On,children:(0,f.jsxs)(`div`,{className:`flex flex-col h-full`,style:{width:yn},children:[(0,f.jsx)(`div`,{className:`relative border-b`,style:{height:`45%`},"data-testid":`gantt-header-groups`,children:En.slice(Hn.start,Hn.end).map(e=>(0,f.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,f.jsx)(`span`,{className:`truncate px-1`,children:e.label})},e.key))}),(0,f.jsx)(`div`,{className:`relative flex-1`,"data-testid":`gantt-header-units`,children:q.slice(Bn.start,Bn.end).map((e,t)=>{let n=Bn.start+t;return(0,f.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:J[n],width:e.width,backgroundColor:e.bandColor?`color-mix(in srgb, ${e.bandColor} 16%, transparent)`:void 0},children:[(0,f.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.label}),e.sublabel&&nt>=32&&(0,f.jsx)(`span`,{className:`text-[10px] opacity-70`,children:e.sublabel})]},n)})})]})})]}),(0,f.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,f.jsxs)(`div`,{className:`gantt-task-list overflow-y-auto overflow-x-hidden border-r bg-card z-10 shadow-sm`,ref:kn,onScroll:ir,style:{width:B,minWidth:B},role:`tree`,"aria-label":k(`gantt.aria.taskList`),children:[Z.startIdx>0&&(0,f.jsx)(`div`,{style:{height:Z.startIdx*R},"aria-hidden":`true`}),G.slice(Z.startIdx,Z.endIdx).map(e=>{let t=e.task,n=Le&&at===t.id,r=dn.has(String(t.id)),i=on!=null&&String(on)===String(t.id);return(0,f.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:R,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:!!L&&!n&&!t.locked,onDragStart:L?e=>{e.dataTransfer.setData(`text/plain`,String(t.id)),e.dataTransfer.effectAllowed=`move`}:void 0,onDragOver:L?e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`}:void 0,onDrop:L?e=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);if(!n||n===String(t.id))return;let r=ft.get(n);r&&String(r.parent??``)===String(t.parent??``)&&L(r,t)}:void 0,onContextMenu:e=>ln(t,e),onClick:()=>{sn(t.id),n||er(e.start,e.end,t.id)},onDoubleClick:()=>{n||(Le&&P&&!e.isSummary&&!t.locked?(ot(t.id),ct({title:t.title,start:t.start.toLocaleDateString(`en-CA`),end:t.end.toLocaleDateString(`en-CA`),progress:String(t.progress)})):o?.(t))},children:[(0,f.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,f.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(),pn(t.id)},"aria-expanded":!r,"aria-label":k(r?`gantt.row.expand`:`gantt.row.collapse`),"data-testid":`gantt-row-toggle-${t.id}`,children:r?(0,f.jsx)(u.ChevronRight,{className:`h-3.5 w-3.5`}):(0,f.jsx)(u.ChevronDown,{className:`h-3.5 w-3.5`})}):(0,f.jsx)(`span`,{className:`w-3 shrink-0`,style:{marginLeft:-4},"aria-hidden":`true`}),(0,f.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0`,style:{backgroundColor:t.color||`#3b82f6`}}),n?(0,f.jsx)(`input`,{className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:st.title||``,onChange:e=>ct(t=>({...t,title:e.target.value})),onKeyDown:e=>{e.key===`Enter`?(Ct([{task:t,changes:{title:st.title,start:new Date(st.start),end:new Date(st.end),progress:Number(st.progress)||0}}]),ot(null)):e.key===`Escape`&&ot(null)},onClick:e=>e.stopPropagation(),autoFocus:!0}):(0,f.jsxs)(`span`,{className:`flex flex-col min-w-0`,children:[(0,f.jsx)(`span`,{className:(0,c.cn)(`truncate`,e.isSummary&&`font-semibold`),children:t.title}),(0,f.jsxs)(`span`,{className:`text-[10px] text-muted-foreground gantt-sm-hidden`,children:[e.start.toLocaleDateString(A,{month:`numeric`,day:`numeric`}),` → `,e.end.toLocaleDateString(A,{month:`numeric`,day:`numeric`})]})]})]}),(0,f.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!it,style:it?void 0:{display:`none`},children:n?(0,f.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:st.start||``,onChange:e=>ct(t=>({...t,start:e.target.value})),onClick:e=>e.stopPropagation()}):e.start.toLocaleDateString(A,{month:`numeric`,day:`numeric`})}),(0,f.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!it,style:it?void 0:{display:`none`},children:n?(0,f.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:st.end||``,onChange:e=>ct(t=>({...t,end:e.target.value})),onClick:e=>e.stopPropagation()}):e.end.toLocaleDateString(A,{month:`numeric`,day:`numeric`})}),o&&(0,f.jsx)(`div`,{className:`w-6 shrink-0 hidden sm:block`,style:{marginLeft:4},children:!n&&(0,f.jsx)(`button`,{type:`button`,title:k(`gantt.row.open`),"aria-label":k(`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(),o(t)},children:(0,f.jsx)(u.ArrowRight,{className:`h-3.5 w-3.5`})})})]},t.id)}),Z.endIdx<G.length&&(0,f.jsx)(`div`,{style:{height:(G.length-Z.endIdx)*R},"aria-hidden":`true`})]}),(0,f.jsx)(`div`,{className:`flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]`,ref:e=>{An.current=e,X.current=e},onScroll:rr,onTouchStart:Jn,onTouchMove:Yn,onTouchEnd:Xn,"data-testid":`gantt-timeline`,children:(0,f.jsxs)(`div`,{className:`relative`,style:{width:yn},children:[Q!=null&&(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px z-20 pointer-events-none`,style:{left:Q,backgroundColor:`rgba(239, 68, 68, 0.8)`},"data-testid":`gantt-today-marker`,"aria-label":k(`gantt.toolbar.today`),children:(0,f.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:k(`gantt.toolbar.today`)})}),Dn.map(e=>(0,f.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,f.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,f.jsxs)(`div`,{className:`relative`,ref:zt,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:q.slice(Bn.start,Bn.end).map((e,t)=>{let n=Bn.start+t;return(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0 border-r`,style:{left:J[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)})}),gn&&S&&S.showMidnight&&(0,f.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:q.slice(Bn.start,Bn.end).map((e,t)=>{let n=Bn.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();return o<=i||o>=i+r?null:(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0`,style:{left:J[n]+(o-i)/r*e.width,borderLeft:`1px dashed hsl(var(--muted-foreground) / 0.4)`},"data-testid":`gantt-midnight-${n}`,"aria-hidden":`true`},`midnight-${n}`)})}),Z.startIdx>0&&(0,f.jsx)(`div`,{style:{height:Z.startIdx*R},"aria-hidden":`true`}),G.slice(Z.startIdx,Z.endIdx).map(e=>{let n=e.task,r=Dr(n.id),i=ar(e.start,e.end),a=re&&n.baselineStart&&n.baselineEnd?ar(n.baselineStart,n.baselineEnd):null,o=a?(0,f.jsx)(`div`,{className:`absolute pointer-events-none rounded-[1px]`,style:{left:a.left,width:Math.max(2,a.width),top:yr,height:vr,backgroundColor:br,border:`1px solid ${xr}`},"data-testid":`gantt-baseline-${n.id}`,"aria-hidden":`true`}):null,s=H?.taskId===n.id,l=sr?.has(String(n.id))??!1,u=cr?.has(String(n.id))??!1,d=s||l||u?lr(e):i,p=!!n.locked,m=!!P&&!e.isSummary&&!p,h=N||p,g=U!=null&&U.targetId!=null&&String(U.targetId)===String(n.id)&&String(U.sourceId)!==String(n.id),_=U?e=>{let t=e.currentTarget.getBoundingClientRect(),r=t.width>0&&e.clientX-t.left>t.width/2?`end`:`start`;Bt(e=>e&&Rt(e.sourceId,n)?{...e,targetId:n.id,targetEnd:r}:e)}:void 0,v=U?e=>{e.target===e.currentTarget&&Bt(e=>e&&{...e,targetId:null,targetEnd:null})}:void 0,ee=Math.max(1,Math.round((e.end.getTime()-e.start.getTime())/xe)),y=lt===n.id&&!H&&!Pt&&!U?(0,f.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(d.left+8,4),top:R-8},role:`tooltip`,"data-testid":`gantt-tooltip-${n.id}`,children:[(0,f.jsx)(`div`,{className:`font-semibold`,children:n.title}),n.fields&&n.fields.length>0?(0,f.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`auto 1fr`,columnGap:10,rowGap:2,marginTop:4},children:n.fields.map((e,n)=>(0,f.jsxs)(t.Fragment,{children:[(0,f.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,f.jsx)(`span`,{style:{fontWeight:500},children:e.value})]},n))}):(0,f.jsxs)(`div`,{className:`text-muted-foreground`,children:[e.start.toLocaleDateString(A,{month:`short`,day:`numeric`}),` → `,e.end.toLocaleDateString(A,{month:`short`,day:`numeric`}),` · `,ee,k(`gantt.tooltip.days`),` · `,Math.round(e.progress),`%`]}),n.locked||N&&!P?(0,f.jsxs)(`div`,{className:`text-muted-foreground`,style:{marginTop:4},"data-testid":`gantt-tooltip-locked-${n.id}`,children:[`🚫 `,k(`gantt.lockedHint`)]}):null]}):null;if(n.type===`group`)return(0,f.jsx)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:R},onPointerMove:v,children:y},n.id);if(e.isSummary){let t=n.color||`#0d9488`;return(0,f.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:R},onPointerMove:v,children:[o,(0,f.jsxs)(`div`,{className:(0,c.cn)(`gantt-bar-hover absolute rounded-sm border shadow-sm flex items-center px-2 select-none`,P&&`cursor-grab active:cursor-grabbing`,s&&`ring-2 ring-primary z-10`,jn===n.id&&`gantt-flash z-10`),style:{left:d.left,width:d.width,top:_r,height:gr,cursor:P?void 0:h?`not-allowed`:`pointer`,backgroundColor:t,borderColor:r?$:n.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:r?`0 0 0 2px ${$}`:n.borderColor?`0 0 0 2px ${n.borderColor}`:void 0},"data-critical":r?`true`:void 0,"data-testid":`gantt-summary-bar-${n.id}`,"data-progress":Math.round(e.progress),onMouseEnter:()=>ut(n.id),onMouseLeave:()=>ut(e=>e===n.id?null:e),onPointerDown:t=>{t.button===0&&Nt(n,`move`,t,{group:!0,originStart:e.start,originEnd:e.end})},onClick:()=>{gt.current||sn(n.id)},onContextMenu:e=>ln(n,e),children:[(0,f.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)`}}),(0,f.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none`,children:n.title})]}),s&&H&&(0,f.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(d.left,4),top:_r+gr+2},"data-testid":`gantt-summary-drag-chip-${n.id}`,children:[_t(H).start.toLocaleDateString(A,{month:`numeric`,day:`numeric`}),` → `,_t(H).end.toLocaleDateString(A,{month:`numeric`,day:`numeric`})]}),y]},n.id)}if(e.isMilestone){let e=mr;return(0,f.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:R},onPointerMove:v,children:[o,(0,f.jsx)(`div`,{className:(0,c.cn)(`gantt-bar-hover absolute rotate-45 rounded-[2px] border shadow-sm select-none`,m&&`cursor-grab active:cursor-grabbing`,s&&`ring-2 ring-primary z-10`,g&&`ring-2 ring-primary`,jn===n.id&&`gantt-flash z-10`),style:{left:d.left-e/2,top:(R-e)/2,width:e,height:e,cursor:m?void 0:h?`not-allowed`:`pointer`,backgroundColor:r?$:n.color||`#3b82f6`,borderColor:r?$:n.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:r?`0 0 0 2px ${$}`:n.borderColor?`0 0 0 2px ${n.borderColor}`:void 0},"data-critical":r?`true`:void 0,"data-testid":`gantt-milestone-${n.id}`,onMouseEnter:()=>ut(n.id),onMouseLeave:()=>ut(e=>e===n.id?null:e),onClick:()=>{gt.current||sn(n.id)},onContextMenu:e=>ln(n,e),onPointerMove:_,onPointerDown:m?e=>{e.button===0&&Nt(n,`move`,e)}:void 0}),y]},n.id)}let b=Pt&&Pt.taskId===n.id?Pt.value:n.progress;return(0,f.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:R},onPointerMove:v,onMouseEnter:()=>ut(n.id),onMouseLeave:()=>ut(e=>e===n.id?null:e),children:[s&&(0,f.jsx)(`div`,{className:`absolute rounded-sm border border-dashed pointer-events-none`,style:{left:i.left,width:i.width,top:dr,height:fr,opacity:.35,borderColor:`hsl(var(--primary) / 0.6)`},"aria-hidden":`true`}),o,(0,f.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`,m&&`cursor-grab active:cursor-grabbing`,s&&`ring-2 ring-primary z-10`,g&&`ring-2 ring-primary`,jn===n.id&&`gantt-flash z-10`),style:{left:d.left,width:d.width,top:dr,height:fr,cursor:m?void 0:h?`not-allowed`:`pointer`,backgroundColor:n.color||`#3b82f6`,borderColor:r?$:n.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:r?`0 0 0 2px ${$}`:n.borderColor?`0 0 0 2px ${n.borderColor}`:void 0},"data-critical":r?`true`:void 0,"data-testid":`gantt-task-bar-${n.id}`,onClick:()=>{gt.current||sn(n.id)},onContextMenu:e=>ln(n,e),onPointerMove:_,onPointerDown:m?e=>{if(e.button!==0)return;let t=he(e.clientX,e.currentTarget.getBoundingClientRect());Nt(n,t,e)}:void 0,children:[m&&d.width>=14&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0`,style:{width:me,height:pr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${n.id}`,onPointerDown:e=>{e.button===0&&Nt(n,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,f.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:me,height:pr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${n.id}`,onPointerDown:e=>{e.button===0&&Nt(n,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),b>0&&(0,f.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 pointer-events-none`,style:{width:`${b}%`,backgroundColor:`rgba(0, 0, 0, 0.2)`,borderTopLeftRadius:`var(--radius-sm)`,borderBottomLeftRadius:`var(--radius-sm)`}}),m&&d.width>=30&&(0,f.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`,Pt?.taskId===n.id?`opacity-100`:`opacity-0 group-hover:opacity-100 transition-opacity`),style:{left:`${b}%`},"data-testid":`gantt-progress-handle-${n.id}`,onPointerDown:e=>{e.button===0&&(e.stopPropagation(),e.preventDefault(),Ft({taskId:n.id,originClientX:e.clientX,originProgress:n.progress,barWidth:d.width,value:n.progress}))},onClick:e=>e.stopPropagation(),children:(0,f.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))`}})}),F&&!p&&[`start`,`end`].map(e=>{let t=U!=null&&String(U.sourceId)===String(n.id)&&U.sourceEnd===e,r=t||lt===n.id,i=r&&U==null;return(0,f.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:+!!r,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}-${n.id}`,onPointerDown:t=>{if(t.button!==0)return;t.stopPropagation(),t.preventDefault();let r=zt.current?.getBoundingClientRect();Bt({sourceId:n.id,sourceEnd:e,x:r?t.clientX-r.left:0,y:r?t.clientY-r.top:0,targetId:null,targetEnd:null})},onClick:e=>e.stopPropagation(),children:(0,f.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,f.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none group-hover:opacity-0 transition-opacity`,children:n.title}),(0,f.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:s?`${_t(H).start.toLocaleDateString(A,{month:`numeric`,day:`numeric`})} → ${_t(H).end.toLocaleDateString(A,{month:`numeric`,day:`numeric`})}`:`${Math.round(b)}%`})]}),y]},n.id)}),Z.endIdx<G.length&&(0,f.jsx)(`div`,{style:{height:(G.length-Z.endIdx)*R},"aria-hidden":`true`}),(ur.length>0||U)&&(0,f.jsxs)(`svg`,{className:`absolute top-0 left-0 pointer-events-none z-10`,width:yn,height:Un,"data-testid":`gantt-links`,"aria-hidden":`true`,children:[(0,f.jsxs)(`defs`,{children:[(0,f.jsx)(`marker`,{id:`gantt-link-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,f.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--muted-foreground))`})}),(0,f.jsx)(`marker`,{id:`gantt-link-arrow-active`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,f.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--primary))`})}),(0,f.jsx)(`marker`,{id:`gantt-link-arrow-critical`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,f.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:$})})]}),ur.map(e=>{let n=Math.min(e.sourceIndex,e.targetIndex);if(Math.max(e.sourceIndex,e.targetIndex)<Z.startIdx-6||n>Z.endIdx+6)return null;let r=Sr(e);if(!r)return null;let i=Cr!=null&&(String(e.sourceId)===String(Cr)||String(e.targetId)===String(Cr)),a=Er?.criticalEdges.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,o=a?`gantt-link-arrow-critical`:i?`gantt-link-arrow-active`:`gantt-link-arrow`,s=!!(I||F);return(0,f.jsxs)(t.Fragment,{children:[(0,f.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,f.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=>un(e.sourceId,e.targetId,e.type,t)})]},e.key)}),U&&(()=>{let e=G.findIndex(e=>String(e.task.id)===String(U.sourceId));if(e<0)return null;let t=lr(G[e]),n=G[e].isMilestone?t.left+(U.sourceEnd===`start`?-hr:hr):U.sourceEnd===`start`?t.left:t.left+t.width,r=e*R+R/2;return(0,f.jsx)(`path`,{d:`M ${Math.round(n)} ${Math.round(r)} L ${Math.round(U.x)} ${Math.round(U.y)}`,fill:`none`,stroke:`hsl(var(--primary))`,strokeWidth:1.5,strokeDasharray:`4 3`,"data-testid":`gantt-link-draft`})})()]}),U&&(()=>{let t=e.find(e=>String(e.id)===String(U.sourceId));if(!t)return null;let n=U.targetId==null?null:e.find(e=>String(e.id)===String(U.targetId)),r=e=>k(`gantt.linkEnd.${e}`),i=n?`${t.title} (${r(U.sourceEnd)}) → ${n.title} (${r(U.targetEnd??`start`)})`:`${t.title} (${r(U.sourceEnd)})`;return(0,f.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:U.x+12,top:U.y+12},"data-testid":`gantt-link-draft-hint`,children:i})})()]})]})})]})]}),Ht&&(()=>{let t=e.find(e=>String(e.id)===String(Ht.taskId));if(!t)return null;let n=G.find(e=>String(e.task.id)===String(Ht.taskId)),r=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`;return(0,f.jsxs)(`div`,{ref:Wt,className:`fixed z-50 min-w-[160px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:Ht.x,top:Ht.y},role:`menu`,"data-testid":`gantt-context-menu`,children:[o&&(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-view`,onClick:()=>{Ut(null),o(t)},children:k(`gantt.menu.view`)}),s&&(()=>{let e=s(t);return e?(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-qrcode`,onClick:()=>{Ut(null),Kt({task:t,url:e})},children:k(`gantt.menu.qrcode`)}):null})(),Le&&P&&n&&!n.isSummary&&!t.locked&&(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-edit`,onClick:()=>{Ut(null),ot(t.id),ct({title:t.title,start:t.start.toLocaleDateString(`en-CA`),end:t.end.toLocaleDateString(`en-CA`),progress:String(t.progress)})},children:k(`gantt.menu.edit`)}),F&&n&&!n.isMilestone&&!t.locked&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-add-predecessor`,onClick:()=>{let e=Ht;Ut(null),rn(``),tn({x:e.x,y:e.y,taskId:t.id,relation:`pred`})},children:k(`gantt.menu.addPredecessor`)}),(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-add-successor`,onClick:()=>{let e=Ht;Ut(null),rn(``),tn({x:e.x,y:e.y,taskId:t.id,relation:`succ`})},children:k(`gantt.menu.addSuccessor`)})]}),Ie&&!t.locked&&(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:(0,c.cn)(r,`text-destructive`),"data-testid":`gantt-context-menu-delete`,onClick:()=>{Ut(null),Ie(t)},children:k(`gantt.menu.delete`)})]})})(),Gt&&(0,f.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,"data-testid":`gantt-qr-dialog`,onClick:()=>Kt(null),children:(0,f.jsxs)(`div`,{role:`dialog`,"aria-label":k(`gantt.qr.title`),className:`w-[280px] rounded-lg border bg-popover text-popover-foreground p-4 shadow-lg`,onClick:e=>e.stopPropagation(),children:[(0,f.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-sm font-medium`,children:[(0,f.jsx)(u.QrCode,{className:`h-4 w-4 shrink-0`}),(0,f.jsx)(`span`,{className:`truncate`,children:Gt.task.title})]}),(0,f.jsx)(`div`,{className:`mb-2 text-xs text-muted-foreground`,children:k(`gantt.qr.hint`)}),qt?(0,f.jsx)(`img`,{src:qt,alt:k(`gantt.qr.title`),"data-testid":`gantt-qr-image`,className:`mx-auto block h-[220px] w-[220px] rounded bg-white`}):(0,f.jsx)(`div`,{className:`flex h-[220px] items-center justify-center text-sm text-muted-foreground`,children:`…`}),(0,f.jsx)(`div`,{className:`mt-2 break-all text-[11px] text-muted-foreground`,"data-testid":`gantt-qr-url`,children:Gt.url}),(0,f.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,f.jsxs)(c.Button,{variant:`outline`,size:`sm`,"data-testid":`gantt-qr-copy`,onClick:Zt,children:[Yt?(0,f.jsx)(u.Check,{className:`mr-1 h-3 w-3`}):(0,f.jsx)(u.Copy,{className:`mr-1 h-3 w-3`}),k(Yt?`gantt.qr.copied`:`gantt.qr.copy`)]}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`sm`,"data-testid":`gantt-qr-close`,onClick:()=>Kt(null),children:k(`gantt.qr.close`)})]})]})}),W&&(()=>{let t=e.find(e=>String(e.id)===String(W.sourceId)),n=e.find(e=>String(e.id)===String(W.targetId));if(!t||!n)return null;let r=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`,i=[`fs`,`ss`,`ff`,`sf`],a=!!n.locked;return(0,f.jsxs)(`div`,{ref:$t,className:`fixed z-50 min-w-[180px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:W.x,top:W.y},role:`menu`,"data-testid":`gantt-link-context-menu`,children:[(0,f.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground truncate`,children:[t.title,` → `,n.title]}),a&&(0,f.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,"data-testid":`gantt-link-menu-locked`,children:[`🚫 `,k(`gantt.lockedHint`)]}),F&&i.map(e=>(0,f.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":W.type===e,disabled:a,className:(0,c.cn)(r,W.type===e&&`font-semibold`,a&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-type-${e}`,onClick:()=>{a||(Qt(null),e!==W.type&&F(t,n,e))},children:[W.type===e?`✓ `:`\xA0\xA0`,k(`gantt.linkType.${e}`)]},e)),I&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:`my-1 border-t`}),(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:a,className:(0,c.cn)(r,`text-destructive`,a&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-remove`,onClick:()=>{a||(Qt(null),I(t,n))},children:k(`gantt.menu.removeDependency`)})]})]})})(),en&&F&&(()=>{let t=e.find(e=>String(e.id)===String(en.taskId));if(!t)return null;let n=new Set(ur.map(e=>`${String(e.sourceId)}->${String(e.targetId)}`)),r=e.filter(e=>{if(String(e.id)===String(t.id)||e.type===`group`||e.locked)return!1;let r=en.relation===`pred`?`${String(e.id)}->${String(t.id)}`:`${String(t.id)}->${String(e.id)}`;return!n.has(r)}),i=nn.trim().toLowerCase(),a=i?r.filter(e=>String(e.title??``).toLowerCase().includes(i)):r;return(0,f.jsxs)(`div`,{ref:an,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:en.x,top:en.y},role:`menu`,"data-testid":`gantt-dep-picker`,children:[(0,f.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:en.relation===`pred`?k(`gantt.menu.addPredecessor`):k(`gantt.menu.addSuccessor`)}),(0,f.jsx)(`div`,{className:`px-2 pb-1`,children:(0,f.jsx)(`input`,{className:`border rounded px-2 py-1 text-sm w-full bg-background`,value:nn,onChange:e=>rn(e.target.value),placeholder:k(`gantt.menu.searchTasks`),"data-testid":`gantt-dep-picker-search`,autoFocus:!0})}),a.length===0?(0,f.jsx)(`div`,{className:`px-3 py-1.5 text-muted-foreground`,children:k(`gantt.menu.noCandidates`)}):a.map(e=>(0,f.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-${e.id}`,onClick:()=>{tn(null),en.relation===`pred`?F(e,t,`fs`):F(t,e,`fs`)},children:e.title},String(e.id)))]})})(),wt&&(0,f.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-conflict-overlay`,onClick:()=>Tt(null),children:(0,f.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,f.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-conflict-title`,children:k(`gantt.conflict.title`)}),(0,f.jsx)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:k(`gantt.conflict.body`).replace(`{count}`,String(wt.length))}),(0,f.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,f.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:()=>Tt(null),children:k(`gantt.conflict.cancel`)}),(0,f.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:Dt,children:k(`gantt.conflict.confirm`)})]})]})})]})}function Me(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)Me(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,N=34,P=180;function Ie(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 F({tasks:e,assignee:n,effort:r,capacity:i=1,viewMode:a=`day`,unassignedLabel:o=`Unassigned`,className:s}){let{t:c,language:l}=pe(),u=l||void 0,d=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=Se(t,a),i=we(Se(n,a),1,a),o=[],s=0;for(;r<i&&s++<4e3;){let e=we(r,1,a);o.push({date:new Date(r),col:{start:new Date(r),end:new Date(e)},label:Ie(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*d;return e.length?(0,f.jsx)(`div`,{className:s,"data-testid":`resource-workload`,style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`auto`},children:(0,f.jsxs)(`div`,{style:{display:`flex`,minWidth:P+g},children:[(0,f.jsxs)(`div`,{style:{width:P,flexShrink:0},children:[(0,f.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,f.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,f.jsx)(`span`,{style:{fontSize:13,fontWeight:500,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:e.label}),(0,f.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,f.jsxs)(`div`,{style:{flex:1},children:[(0,f.jsx)(`div`,{style:{display:`flex`,height:28,borderBottom:`1px solid hsl(var(--border))`},children:p.map((e,t)=>(0,f.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=N*(1-Math.min(e.capacity/h,1));return(0,f.jsxs)(`div`,{style:{position:`relative`,display:`flex`,height:Fe,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,f.jsx)(`div`,{"aria-hidden":`true`,style:{position:`absolute`,left:0,right:0,top:(Fe-N)/2+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,N*Math.min(t.load/h,1));return(0,f.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:d,flexShrink:0,position:`relative`,borderLeft:`1px solid hsl(var(--border) / 0.4)`,display:`flex`,alignItems:`flex-end`,justifyContent:`center`,paddingBottom:(Fe-N)/2},children:t.load>0&&(0,f.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,f.jsx)(`div`,{className:s,"data-testid":`resource-workload`,children:(0,f.jsx)(`div`,{className:`flex items-center justify-center h-40 text-sm text-muted-foreground`,children:c(`gantt.resource.empty`)})})}var I={display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8,padding:`8px 12px`,borderBottom:`1px solid hsl(var(--border))`,background:`hsl(var(--background))`,fontSize:13},L={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`},Le={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)`},Re={display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,borderRadius:6,cursor:`pointer`,userSelect:`none`};function ze({checked:e}){return(0,f.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 R({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])},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,f.jsxs)(`div`,{ref:s,style:{position:`relative`},"data-testid":`quick-filter-${e.field}`,children:[(0,f.jsxs)(`button`,{type:`button`,style:{...L,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,f.jsx)(`span`,{children:m}),(0,f.jsx)(`span`,{"aria-hidden":!0,style:{fontSize:10,opacity:.7},children:`▾`})]}),a&&(0,f.jsx)(`div`,{role:`listbox`,style:Le,"data-testid":`quick-filter-panel-${e.field}`,children:e.options.length===0?(0,f.jsx)(`div`,{style:{...Re,cursor:`default`,opacity:.6},children:i.empty}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`div`,{role:`option`,"aria-selected":u,style:{...Re,fontWeight:600},"data-testid":`quick-filter-all-${e.field}`,onClick:()=>p(),children:[(0,f.jsx)(ze,{checked:u}),(0,f.jsx)(`span`,{children:i.all})]}),(0,f.jsx)(`div`,{style:{height:1,background:`hsl(var(--border))`,margin:`2px 0`}}),e.options.map(t=>{let n=c.has(t.value);return(0,f.jsxs)(`div`,{role:`option`,"aria-selected":n,style:{...Re,background:n?`hsl(var(--accent, var(--muted)))`:`transparent`},"data-testid":`quick-filter-option-${e.field}-${t.value}`,onClick:()=>d(t.value),children:[(0,f.jsx)(ze,{checked:n}),(0,f.jsx)(`span`,{children:t.label})]},t.value)})]})})]})}var Be=({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,f.jsxs)(`div`,{style:I,className:s,"data-testid":`quick-filter-bar`,children:[e.map(e=>(0,f.jsx)(R,{filter:e,selected:t[e.field]??[],onChange:t=>n(e.field,t),labels:{all:c,empty:l}},e.field)),d&&(0,f.jsx)(`button`,{type:`button`,style:{...L,height:28,color:`hsl(var(--muted-foreground))`},"data-testid":`quick-filter-clear`,onClick:r,children:u}),o?.resultSummary&&i!=null&&a!=null&&(0,f.jsx)(`span`,{"data-testid":`quick-filter-summary`,style:{marginLeft:`auto`,color:`hsl(var(--muted-foreground))`},children:o.resultSummary(i,a)})]})};function Ve(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 He={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 Ue(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=He[String(n.type??``).toLowerCase().replace(/-/g,`_`)];t.push(r?{id:e,type:r}:{id:e})}else t.push(n);return t}function We(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function Ge(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}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,timeSegments:e.timeSegments},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:d,onRowClick:p,...m})=>{let[h,g]=(0,t.useState)([]),[_,v]=(0,t.useState)(!0),[ee,y]=(0,t.useState)(null),[b,te]=(0,t.useState)(null),{currency:ne}=(0,o.useLocalization)(),{t:x}=pe(),S=(0,t.useCallback)(e=>{i.toast.error(x(`gantt.writeFailed`),{description:Ke(e)??void 0})},[x]),re=We(e),C=(0,t.useMemo)(()=>re,[JSON.stringify(re)]),w=z(e),ie=C?.provider===`value`,T=(0,t.useMemo)(()=>(0,n.resolveDataSource)(C,a??null),[C,a]),E=C?.provider===`object`?C.object:e.objectName??``,[ae,oe]=(0,t.useState)(!1),se=(0,t.useRef)(0),D=(0,t.useCallback)(async({silent:t=!1}={})=>{let r=++se.current,i=()=>se.current===r;try{if(t?oe(!0):v(!0),m.data&&Array.isArray(m.data)){i()&&g(m.data);return}if(ie&&C?.provider===`value`){i()&&g(C.items);return}if(!T||typeof T.find!=`function`)throw Error(`DataSource required for object/api providers`);let r=(0,n.buildExpandFields)(b?.fields),a=await T.find(E,{$filter:e.filter,$orderby:Ge(e.sort),...r.length>0?{$expand:r}:{}});i()&&g((0,n.extractRecords)(a))}catch(e){t?console.error(`[ObjectGantt] Failed to refresh data:`,e):i()&&y(e)}finally{t?oe(!1):v(!1)}},[T,E,ie,C,e.filter,e.sort,b]);(0,t.useEffect)(()=>{D()},[D]),(0,t.useEffect)(()=>{!ie&&T&&(async()=>{try{if(!T||!E)return;let e=await T.getObjectSchema(E);te(e)}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[E,T,ie,C]);let O=(0,t.useMemo)(()=>{if(!w||!h.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:g,quickFilters:_}=w,v=b?.fields??{},ee=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&&ee.set(e.field,t)}let y=(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=[y(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)},S=(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=ee.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);if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/.test(e)&&!isNaN(new Date(e).getTime()))return(0,l.formatDateTime)(e)}switch(r){case`date`:return(0,l.formatDate)(e);case`datetime`:return(0,l.formatDateTime)(e);case`number`:case`integer`:case`float`:case`decimal`:return(0,l.formatNumber)(Number(e));case`currency`:return(0,l.formatCurrency)(Number(e),(0,o.resolveFieldCurrency)(n,ne));case`percent`:return(0,l.formatPercent)(Number(e));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)}},re=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=y(e,r);a==null||a===``||Array.isArray(a)&&a.length===0||t.push({label:x(r,i),value:S(a,r)})}return t.length?t:void 0};return h.map((n,r)=>{let o=n[e],p=n[t],h=m?n[m]:void 0,_=g?n[g]:void 0,v=h?new Date(h):void 0,ee=_?new Date(_):void 0,y=te(n),b=i?n[i]:0,ne=a?n[a]:[],x=s?n[s]:void 0;if(!x){let e=n.status??n.state??n.priority??n.severity;if(e!=null&&e!==``){let t=(0,l.getSemanticColorName)(void 0,e);t&&(x=(0,l.getSemanticHex)(t))}}let S=c?n[c]:void 0,C=S!=null&&S!==``?(0,l.getSemanticHex)(String(S),String(S)):void 0;return{id:n.id||n._id||`task-${r}`,title:y,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:Ue(ne),parent:u?n[u]??null:void 0,type:d?Ve(n[d]):void 0,locked:f?!!n[f]:void 0,color:x,borderColor:C,baselineStart:v&&!isNaN(v.getTime())?v:void 0,baselineEnd:ee&&!isNaN(ee.getTime())?ee:void 0,fields:re(n),data:n}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[h,w,b]),ce=(0,t.useMemo)(()=>{let e=w?.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)}}},[w?.groupByField,b]),le=(0,t.useMemo)(()=>{let e=w?.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)}}},[w?.assigneeField,b]),de=(0,t.useMemo)(()=>{let e=w?.effortField;if(e)return t=>{let n=t.data?.[e],r=Number(n);return Number.isFinite(r)&&r>0?r:1}},[w?.effortField]),k=(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]),fe=(0,t.useMemo)(()=>ue(w?.timeSegments),[w?.timeSegments]),A=(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)},[]),me=w?.quickFilters,[he,ge]=(0,t.useState)({});(0,t.useEffect)(()=>{if(!me?.length||!a||typeof a.find!=`function`)return;let e=b?.fields??{},t=!1;return(async()=>{let r={};for(let t of me){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?.referenceTo;if(s)try{let e=(0,n.extractRecords)(await a.find(s,{$top:1e3}));r[t.field]=e.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||ge(e=>({...e,...r}))})(),()=>{t=!0}},[JSON.stringify(me),a,b]);let _e=(0,t.useMemo)(()=>{if(!me?.length)return[];let e=b?.fields??{};return me.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(he[t.field]?.length)i=he[t.field];else{let e=new Map;for(let n of h){let r=A(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}})},[me,b,he,h,A]),ve=e.persistLayout===!1?void 0:`${e.objectName||(C?.provider===`object`?C.object:``)||`gantt`}:${e.viewName||`default`}`,ye=ve?`gantt-layout:${ve}:filters`:null,[j,be]=(0,t.useState)(()=>{if(!ye||typeof window>`u`)return{};try{let e=JSON.parse(window.localStorage.getItem(ye)||`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{}}}),xe=(0,t.useCallback)(()=>{if(!(!ye||typeof window>`u`))try{window.localStorage.setItem(ye,JSON.stringify(j))}catch{}},[ye,j]),Se=(0,t.useCallback)((e,t)=>{be(n=>({...n,[e]:t}))},[]),Ce=(0,t.useCallback)(()=>be({}),[]),we=(0,t.useCallback)(e=>!!w?.objectField&&!String(e?.[w.objectField]??``).trim(),[w?.objectField]),Te=(0,t.useCallback)(e=>{let t=(w?.objectField?String(e[w.objectField]??``).trim():``)||E,n=e.id??e._id;if(!t||n==null)return null;let r=E?(0,s.deriveRecordPageHref)(E,n):null;return{objectName:t,recordId:n,href:!E||t===E?r:r?.replace(`/${E}/record/`,`/${t}/record/`)??null}},[w?.objectField,E]),Ee=(0,t.useMemo)(()=>{let e=Object.entries(j).filter(([,e])=>e.length>0);if(!e.length)return O;let t=new Map(O.map(e=>[String(e.id),e])),n=new Set;for(let r of O){if(!e.every(([e,t])=>{let n=A(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 O.filter(e=>n.has(String(e.id)))},[O,j,A]),De=(0,t.useMemo)(()=>{if(w?.autoZoomToFilter!==!1||!O.length)return null;let e=O[0].start.getTime(),t=O[0].end.getTime();for(let n of O)e=Math.min(e,n.start.getTime()),t=Math.max(t,n.end.getTime());return{start:new Date(e),end:new Date(t)}},[O,w?.autoZoomToFilter]),Oe=e.navigation??{mode:`drawer`,width:`min(960px, 60vw)`},ke=Oe.mode===`drawer`||Oe.mode===`modal`||Oe.mode===`split`||Oe.mode===`popover`,M=(0,r.useNavigationOverlay)({navigation:Oe,objectName:e.objectName,onRowClick:ke?void 0:p}),[Ae,Me]=(0,t.useState)(null),Ne=M.isOverlay&&M.isOpen?M.selectedRecord:null;(0,t.useEffect)(()=>{if(!Ne){Me(null);return}let e=Te(Ne);if(!e){Me(null);return}let{objectName:t,recordId:n}=e;if(!(C?.provider===`api`||t!==E)||!a||typeof a.findOne!=`function`){Me(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||Me(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||Me(null)}})(),()=>{i=!0}},[Ne,Te,C?.provider,E,a]);let Pe=(0,t.useCallback)(async(e,t)=>{if(!w||!T||typeof T.update!=`function`)return;let{startDateField:n,endDateField:r,titleField:i,progressField:a}=w,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=h;g(e=>e.map(e=>String(e.id??e._id)===String(s)?{...e,...o}:e));try{await T.update(E,String(s),o),D({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist task update:`,e),g(c),S(e)}},[w,T,E,h,D,S]),Fe=(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)},N=(0,t.useCallback)(async(e,t,n)=>{let r=w?.dependenciesField;if(!r||!T||typeof T.update!=`function`)return;let i=Fe(t,n),a=h;g(t=>t.map(t=>String(t.id??t._id)===String(e)?{...t,[r]:i}:t));try{await T.update(E,String(e),{[r]:i}),D({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist dependency:`,e),g(a),S(e)}},[w,T,E,h,D,S]),P=(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=w?.dependenciesField;if(!a)return;let o=h.find(e=>String(e.id??e._id)===String(i))?.[a],s=Ue(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 N(i,o,f)},[w,h,N]),Ie=(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=w?.dependenciesField;if(!i)return;let a=h.find(e=>String(e.id??e._id)===String(r))?.[i],o=Ue(a),s=e=>String(typeof e==`object`?e.id:e),c=o.filter(e=>s(e)!==String(n));c.length!==o.length&&await N(r,a,c)},[w,h,N]),[I,L]=(0,t.useState)(null),[Le,Re]=(0,t.useState)(!1),ze=(0,t.useCallback)(e=>{L(e)},[]),R=(0,t.useCallback)(async()=>{if(!I)return;if(!T?.delete){L(null);return}let e=I.data?.id??I.data?._id??I.id;if(e==null){L(null);return}Re(!0);let t=h;g(t=>t.filter(t=>String(t.id??t._id)!==String(e)));try{if(await T.delete(E,String(e))===!1)throw Error(x(`gantt.writeFailed`));L(null),D({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to delete:`,e),g(t),L(null),S(e)}finally{Re(!1)}},[I,T,E,h,D,S,x]);return _?(0,f.jsx)(`div`,{className:u,children:(0,f.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,f.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading Gantt chart...`})})}):ee?(0,f.jsx)(`div`,{className:u,children:(0,f.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,f.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,ee.message]})})}):w?(0,f.jsxs)(`div`,{className:u,children:[_e.length>0&&(0,f.jsx)(Be,{filters:_e,value:j,onChange:Se,onClear:Ce,resultCount:Ee.length,totalCount:O.length,labels:{all:`全部`,clear:`清除筛选`,empty:`无可选项`,resultSummary:(e,t)=>`显示 ${e} / ${t} 项任务`}}),(0,f.jsx)(`div`,{className:`h-[calc(100vh-200px)] min-h-[600px]`,children:w?.resourceView&&le?(0,f.jsx)(F,{tasks:Ee,assignee:le,effort:de,capacity:w?.capacity??1,viewMode:e.viewMode||`day`}):(0,f.jsx)(je,{tasks:Ee,startDate:De?.start,endDate:De?.end,onTaskClick:e=>{we(e.data)||M.handleClick(e.data),d?.(e.data)},taskUrl:e=>{let t=e.data;if(!t||we(t))return null;let n=Te(t)?.href;return n?typeof window>`u`?n:new URL(n,window.location.href).toString():null},onTaskUpdate:Pe,onTaskDelete:ze,onDependencyCreate:w?.dependenciesField?P:void 0,onDependencyDelete:w?.dependenciesField?Ie:void 0,markers:e.markers,autoSchedule:!!w?.dependenciesField,rescheduleOnConflict:!!w?.dependenciesField,criticalPathDefault:!!e.criticalPath,workingCalendar:k,shiftSegments:fe,showBaselines:e.showBaselines!==!1,readOnly:!!e.readOnly,mobileReadOnly:e.mobileReadOnly!==!1,persistLayoutKey:ve,onLayoutChange:ye?xe:void 0,groupBy:ce,defaultCollapsedDepth:w?.defaultCollapsedDepth,summaryExtent:w?.summaryExtent,inlineEdit:!0,onRefresh:(C?.provider===`object`||C?.provider===`api`)&&typeof T?.find==`function`?()=>D({silent:!0}):void 0,refreshing:ae})}),M.isOverlay&&M.isOpen&&M.selectedRecord&&(()=>{let t=M.selectedRecord,n=Te(t);if(!n||we(t))return null;let{objectName:r,recordId:i}=n,o=n.href??void 0,c=w?.titleField?String(t[w.titleField]??x(`gantt.drawer.fallbackTitle`)):x(`gantt.drawer.fallbackTitle`),l=!!e.readOnly||(w?.lockField?!!t[w.lockField]:!1),u=Ae?.key===`${r}:${i}`?Ae:null,d=u?.record??t,p=u?.schema??(r===E?b:void 0),m=u&&a?a:T;return(0,f.jsx)(s.RecordDetailDrawer,{open:!0,onClose:M.close,title:c,record:d,objectName:r,recordId:i,dataSource:m??void 0,objectSchema:p,width:M.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&&Me(n=>n&&n.key===u.key?{...n,record:{...n.record,[e]:t}}:n),g(n=>n.map(n=>String(n.id??n._id)===String(i)?{...n,[e]:t}:n)),D({silent:!0})}},onDelete:l?void 0:async()=>{if(T?.delete){try{if(await T.delete(r,String(i))===!1)throw Error(x(`gantt.writeFailed`))}catch(e){throw S(e),e}g(e=>e.filter(e=>String(e.id??e._id)!==String(i)))}}})})(),(0,f.jsx)(c.AlertDialog,{open:!!I,onOpenChange:e=>{!e&&!Le&&L(null)},children:(0,f.jsxs)(c.AlertDialogContent,{children:[(0,f.jsxs)(c.AlertDialogHeader,{children:[(0,f.jsx)(c.AlertDialogTitle,{children:x(`gantt.delete.title`)}),(0,f.jsx)(c.AlertDialogDescription,{children:I?x(`gantt.delete.body`,{title:I.title}):null})]}),(0,f.jsxs)(c.AlertDialogFooter,{children:[(0,f.jsx)(c.AlertDialogCancel,{disabled:Le,children:x(`gantt.delete.cancel`)}),(0,f.jsx)(c.AlertDialogAction,{onClick:e=>{e.preventDefault(),R()},disabled:Le,"data-testid":`gantt-delete-confirm`,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:x(Le?`gantt.delete.deleting`:`gantt.delete.confirm`)})]})]})})]}):(0,f.jsx)(`div`,{className:u,children:(0,f.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,f.jsx)(`div`,{className:`text-muted-foreground`,children:`Gantt configuration required. Please specify startDateField, endDateField, and titleField.`})})})},Je=({schema:e})=>{let{dataSource:t}=(0,r.useSchemaContext)()||{};return(0,f.jsx)(qe,{schema:e,dataSource:t})};n.ComponentRegistry.register(`object-gantt`,Je,{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`,Je,{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=je,e.ObjectGantt=qe,e.ObjectGanttRenderer=Je,e.QuickFilterBar=Be,e.ResourceWorkload=F,e.bandAt=k,e.computeWorkload=Ne,e.normalizeDependencies=Ue,e.normalizeShiftSegments=ue,e.normalizeTaskType=Ve,e.parseHHMM=le,e.shiftDayStart=de});
@@ -80,4 +80,16 @@ export interface RescheduleChange {
80
80
  * Returns an empty array when the graph has a cycle (ambiguous ordering).
81
81
  */
82
82
  export declare function computeProjectReschedule(tasks: SchedulableTask[], cal?: WorkingCalendar): RescheduleChange[];
83
+ /**
84
+ * Would adding the dependency edge `sourceId → targetId` (predecessor →
85
+ * dependent) close a cycle? `edges` is the EXISTING graph as
86
+ * [predecessorId, dependentId] pairs — build it from the full task set, not
87
+ * from visible rows, so links hidden inside collapsed subtrees still count.
88
+ *
89
+ * The new edge cycles iff `sourceId` is already reachable from `targetId`
90
+ * (a path target ⇝ source exists). The toposort above only *skips* cyclic
91
+ * chains during scheduling; this guard is what keeps them from being created
92
+ * in the first place.
93
+ */
94
+ export declare function wouldCreateDependencyCycle(edges: Array<[string, string]>, sourceId: string | number, targetId: string | number): boolean;
83
95
  //# sourceMappingURL=scheduling.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scheduling.d.ts","sourceRoot":"","sources":["../src/scheduling.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEtD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACxB;AAuED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,CAAC;IACV,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/E,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAkFD,MAAM,WAAW,kBAAkB;IACjC,sDAAsD;IACtD,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,8CAA8C;IAC9C,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,GAAG,CAAC,EAAE,eAAe,GAAG,kBAAkB,CAiFvG;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,CAAC;CACX;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,GAAG,CAAC,EAAE,eAAe,GAAG,gBAAgB,EAAE,CAkF5G"}
1
+ {"version":3,"file":"scheduling.d.ts","sourceRoot":"","sources":["../src/scheduling.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEtD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACxB;AAuED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,CAAC;IACV,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/E,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAkFD,MAAM,WAAW,kBAAkB;IACjC,sDAAsD;IACtD,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,8CAA8C;IAC9C,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,GAAG,CAAC,EAAE,eAAe,GAAG,kBAAkB,CAiFvG;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,CAAC;CACX;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,GAAG,CAAC,EAAE,eAAe,GAAG,gBAAgB,EAAE,CAkF5G;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC9B,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,QAAQ,EAAE,MAAM,GAAG,MAAM,GACxB,OAAO,CAuBT"}
@@ -1 +1 @@
1
- {"version":3,"file":"useGanttTranslation.d.ts","sourceRoot":"","sources":["../src/useGanttTranslation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAyD7D,CAAC;AAYF,wBAAgB,mBAAmB;aAgBf,MAAM,YAAY,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,MAAM;;EAYrE"}
1
+ {"version":3,"file":"useGanttTranslation.d.ts","sourceRoot":"","sources":["../src/useGanttTranslation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAyE7D,CAAC;AAYF,wBAAgB,mBAAmB;aAgBf,MAAM,YAAY,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,MAAM;;EAYrE"}