@object-ui/plugin-gantt 11.0.0 → 11.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/dist/ObjectGantt.d.ts.map +1 -1
- package/dist/index.js +443 -449
- package/dist/index.umd.cjs +1 -1
- package/package.json +13 -13
package/dist/index.umd.cjs
CHANGED
|
@@ -90,4 +90,4 @@ endobj
|
|
|
90
90
|
bar. Hide it — the pane stays wheel/drag-scrollable and synced. */
|
|
91
91
|
.gantt-task-list::-webkit-scrollbar { width: 0; height: 0; }
|
|
92
92
|
.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":E(`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":E(`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:E(`gantt.readOnlyHint`),children:[(0,u.jsx)(l.Lock,{className:`h-3 w-3`}),E(`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":E(`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:E(`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":E(`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":E(`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":E(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":E(`gantt.toolbar.jumpToToday`),"data-testid":`gantt-jump-today`,children:E(`gantt.toolbar.today`)}),(0,u.jsx)(s.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:Fn,"aria-label":E(`gantt.toolbar.thisWeek`),"data-testid":`gantt-jump-week`,children:E(`gantt.toolbar.thisWeek`)}),(0,u.jsx)(s.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:In,"aria-label":E(`gantt.toolbar.thisMonth`),"data-testid":`gantt-jump-month`,children:E(`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":E(`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":E(`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:()=>ir(e=>!e),"aria-label":E(`gantt.toolbar.criticalPath`),"aria-pressed":rr,"data-testid":`gantt-critical-path`,style:rr?{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:sr,"aria-label":E(`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:lr,"aria-label":E(`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:ur,"aria-label":E(`gantt.toolbar.exportPdf`),"data-testid":`gantt-export-pdf`,children:(0,u.jsx)(l.FileDown,{className:`h-4 w-4`})}),ie||re?(0,u.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:pr,"aria-label":E(`gantt.toolbar.saveLayout`),"aria-pressed":dr,"data-testid":`gantt-save-layout`,style:dr?{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":E(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=>{Be(Math.max(160,Math.min(n+(e.clientX-t),r)))},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:E(`gantt.column.taskName`)}),Ze&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:E(`gantt.column.start`)}),(0,u.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:E(`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":E(`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":E(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:E(`gantt.row.locate`),"aria-label":E(`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":E(`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:E(`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&&x&&x.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=or(n.id),i=zn(e.start,e.end),a=te&&n.baselineStart&&n.baselineEnd?zn(n.baselineStart,n.baselineEnd):null,c=a?(0,u.jsx)(`div`,{className:`absolute pointer-events-none rounded-[1px]`,style:{left:a.left,width:Math.max(2,a.width),top:Qn,height:Zn,backgroundColor:$n,border:`1px solid ${er}`},"data-testid":`gantt-baseline-${n.id}`,"aria-hidden":`true`}):null,l=B?.taskId===n.id,d=Vn?.has(String(n.id))??!1,f=Hn?.has(String(n.id))??!1,p=l||d||f?Un(e):i,m=!!n.locked,h=!!N&&!e.isSummary&&!m,g=H!=null&&H.targetId!=null&&String(H.targetId)===String(n.id)&&String(H.sourceId)!==String(n.id),_=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,v=H?e=>{e.target===e.currentTarget&&At(e=>e&&{...e,targetId:null,targetEnd:null})}:void 0,ee=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(p.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`}),` · `,ee,E(`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:v,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:v,children:[c,(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`,l&&`ring-2 ring-primary z-10`,dn===n.id&&`gantt-flash z-10`),style:{left:p.left,width:p.width,top:Xn,height:Yn,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||o?.(n)},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})]}),l&&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(p.left,4),top:Xn+Yn+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=qn;return(0,u.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:F},onPointerMove:v,children:[c,(0,u.jsx)(`div`,{className:(0,s.cn)(`gantt-bar-hover absolute rotate-45 rounded-[2px] border shadow-sm select-none`,h?`cursor-grab active:cursor-grabbing`:`cursor-pointer`,l&&`ring-2 ring-primary z-10`,g&&`ring-2 ring-primary`,dn===n.id&&`gantt-flash z-10`),style:{left:p.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||o?.(n)},onContextMenu:e=>Ut(n,e),onPointerMove:_,onPointerDown:h?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:v,onMouseEnter:()=>rt(n.id),onMouseLeave:()=>rt(e=>e===n.id?null:e),children:[l&&(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`}),c,(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`,h?`cursor-grab active:cursor-grabbing`:`cursor-pointer`,l&&`ring-2 ring-primary z-10`,g&&`ring-2 ring-primary`,dn===n.id&&`gantt-flash z-10`),style:{left:p.left,width:p.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||o?.(n)},onContextMenu:e=>Ut(n,e),onPointerMove:_,onPointerDown:h?e=>{e.button===0&&Tt(n,`move`,e)}:void 0,children:[h&&p.width>=14&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0 bottom-0`,style:{width:6,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 bottom-0`,style:{width:6,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)`}}),h&&p.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:p.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&&!m&&[`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:l?`${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=tr(e);if(!r)return null;let i=nr!=null&&(String(e.sourceId)===String(nr)||String(e.targetId)===String(nr)),a=ar?.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`?-Jn:Jn):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=>E(`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:E(`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:E(`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:E(`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:E(`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:E(`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`,E(`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:E(`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`?E(`gantt.menu.addPredecessor`):E(`gantt.menu.addSuccessor`)}),r.length===0?(0,u.jsx)(`div`,{className:`px-3 py-1.5 text-muted-foreground`,children:E(`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:E(`gantt.conflict.title`)}),(0,u.jsx)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:E(`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:E(`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:E(`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,ee]=(0,t.useState)(null),[y,b]=(0,t.useState)(null),{currency:x}=(0,a.useLocalization)(),te=Ve(e),S=(0,t.useMemo)(()=>te,[JSON.stringify(te)]),C=Ue(e),w=S?.provider===`value`;(0,t.useEffect)(()=>{(async()=>{try{if(_(!0),p.data&&Array.isArray(p.data)){h(p.data),_(!1);return}if(w&&S?.provider===`value`){h(S.items),_(!1);return}if(!i||typeof i.find!=`function`)throw Error(`DataSource required for object/api providers`);if(S?.provider===`object`){let t=S.object,r=(0,n.buildExpandFields)(y?.fields);h((0,n.extractRecords)(await i.find(t,{$filter:e.filter,$orderby:He(e.sort),...r.length>0?{$expand:r}:{}})))}else S?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectGantt`),h([]));_(!1)}catch(e){ee(e),_(!1)}})()},[S,i,w,e.filter,e.sort,y]),(0,t.useEffect)(()=>{!w&&i&&(async()=>{try{if(!i)return;let t=S?.provider===`object`?S.object:e.objectName;if(!t)return;b(await i.getObjectSchema(t))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,i,w,S]);let T=(0,t.useMemo)(()=>{if(!C||!m.length)return[];let{startDateField:e,endDateField:t,titleField:n,progressField:r,dependenciesField:i,colorField:o,parentField:s,typeField:l,lockField:u,tooltipFields:d,baselineStartField:f,baselineEndField:p}=C,h=y?.fields??{},g=(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},_=e=>{let t=[g(e,n),e?.name,e?.title,e?.subject,e?.label,e?.account?.name,e?.opportunity?.name,e?.contact&&[e.contact.first_name,e.contact.last_name].filter(Boolean).join(` `),e?.id,e?._id];for(let e of t)if(e!=null&&String(e).trim()!==``)return String(e);return`Untitled`},v=(e,t)=>{if(t)return t;let n=h[e]??h[e.split(`.`)[0]];return n?.label?n.label:(0,c.humanizeLabel)(e)},ee=(e,t)=>{if(e==null||e===``)return`—`;let n=h[t]??h[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,x));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)}},b=e=>{if(!d||!d.length)return;let t=[];for(let n of d){let r=typeof n==`string`?n:n?.field;if(!r)continue;let i=typeof n==`object`?n.label:void 0;t.push({label:v(r,i),value:ee(g(e,r),r)})}return t.length?t:void 0};return m.map((n,a)=>{let d=n[e],m=n[t],h=f?n[f]:void 0,g=p?n[p]:void 0,v=h?new Date(h):void 0,ee=g?new Date(g):void 0,y=_(n),x=r?n[r]:0,te=i?n[i]:[],S=o?n[o]:void 0;if(!S){let e=n.status??n.state??n.priority??n.severity;if(e!=null&&e!==``){let t=(0,c.getSemanticColorName)(void 0,e);t&&(S=(0,c.getSemanticHex)(t))}}return{id:n.id||n._id||`task-${a}`,title:y,start:d?new Date(d):new Date,end:m?new Date(m):new Date,progress:Math.min(100,Math.max(0,x||0)),dependencies:I(te),parent:s?n[s]??null:void 0,type:l?ze(n[l]):void 0,locked:u?!!n[u]:void 0,color:S,baselineStart:v&&!isNaN(v.getTime())?v:void 0,baselineEnd:ee&&!isNaN(ee.getTime())?ee:void 0,fields:b(n),data:n}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[m,C,y]),ne=(0,t.useMemo)(()=>{let e=C?.groupByField;if(!e)return;let t=y?.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)}}},[C?.groupByField,y]),re=(0,t.useMemo)(()=>{let e=C?.assigneeField;if(!e)return;let t=y?.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)}}},[C?.assigneeField,y]),ie=(0,t.useMemo)(()=>{let e=C?.effortField;if(e)return t=>{let n=t.data?.[e],r=Number(n);return Number.isFinite(r)&&r>0?r:1}},[C?.effortField]),ae=(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]),oe=(0,t.useMemo)(()=>se(C?.timeSegments),[C?.timeSegments]),E=(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)},[]),D=C?.quickFilters,[O,ce]=(0,t.useState)({});(0,t.useEffect)(()=>{if(!D?.length||!i||typeof i.find!=`function`)return;let e=y?.fields??{},t=!1;return(async()=>{let r={};for(let t of D){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(D),i,y]);let le=(0,t.useMemo)(()=>{if(!D?.length)return[];let e=y?.fields??{};return D.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=E(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}})},[D,y,O,m,E]),[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?T.filter(t=>e.every(([e,n])=>{let r=E(t.data,e);return r!=null&&n.includes(r)})):T},[T,ue,E]),he=(0,t.useMemo)(()=>{if(C?.autoZoomToFilter!==!1||!T.length)return null;let e=T[0].start.getTime(),t=T[0].end.getTime();for(let n of T)e=Math.min(e,n.start.getTime()),t=Math.max(t,n.end.getTime());return{start:new Date(e),end:new Date(t)}},[T,C?.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(!C)return;let r=S?.provider===`object`?S.object:e.objectName;if(!r||!i||typeof i.update!=`function`)return;let{startDateField:a,endDateField:o,titleField:s,progressField:c}=C,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)}},[C,S,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=C?.dependenciesField;if(!a)return;let o=S?.provider===`object`?S.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)}},[C,S,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=C?.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};await be(i,o,l?s.map(e=>c(e)===String(r)?d:e):[...s,d])},[C,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=C?.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)},[C,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=S?.provider===`object`?S.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,S,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]})})}):C?(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:T.length,labels:{all:`全部`,clear:`清除筛选`,empty:`无可选项`,resultSummary:(e,t)=>`显示 ${e} / ${t} 项任务`}}),(0,u.jsx)(`div`,{className:`h-[calc(100vh-200px)] min-h-[600px]`,children:C?.resourceView&&re?(0,u.jsx)(Me,{tasks:me,assignee:re,effort:ie,capacity:C?.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:C?.dependenciesField?xe:void 0,onDependencyDelete:C?.dependenciesField?Se:void 0,markers:e.markers,autoSchedule:!!C?.dependenciesField,rescheduleOnConflict:!!C?.dependenciesField,criticalPathDefault:!!e.criticalPath,workingCalendar:ae,shiftSegments:oe,showBaselines:e.showBaselines!==!1,readOnly:!!e.readOnly,mobileReadOnly:e.mobileReadOnly!==!1,persistLayoutKey:e.persistLayout===!1?void 0:`${e.objectName||(S?.provider===`object`?S.object:``)||`gantt`}:${e.viewName||`default`}`,groupBy:ne,defaultCollapsedDepth:C?.defaultCollapsedDepth,inlineEdit:!0})}),_e.isOverlay&&_e.isOpen&&_e.selectedRecord&&(()=>{let t=S?.provider===`object`?S.object:e.objectName,n=_e.selectedRecord,r=n.id??n._id;if(!t||r==null)return null;let a=C?.titleField?String(n[C.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:y,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});
|
|
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":E(`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":E(`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:E(`gantt.readOnlyHint`),children:[(0,u.jsx)(l.Lock,{className:`h-3 w-3`}),E(`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":E(`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:E(`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":E(`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":E(`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":E(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":E(`gantt.toolbar.jumpToToday`),"data-testid":`gantt-jump-today`,children:E(`gantt.toolbar.today`)}),(0,u.jsx)(s.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:Fn,"aria-label":E(`gantt.toolbar.thisWeek`),"data-testid":`gantt-jump-week`,children:E(`gantt.toolbar.thisWeek`)}),(0,u.jsx)(s.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:In,"aria-label":E(`gantt.toolbar.thisMonth`),"data-testid":`gantt-jump-month`,children:E(`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":E(`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":E(`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:()=>ir(e=>!e),"aria-label":E(`gantt.toolbar.criticalPath`),"aria-pressed":rr,"data-testid":`gantt-critical-path`,style:rr?{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:sr,"aria-label":E(`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:lr,"aria-label":E(`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:ur,"aria-label":E(`gantt.toolbar.exportPdf`),"data-testid":`gantt-export-pdf`,children:(0,u.jsx)(l.FileDown,{className:`h-4 w-4`})}),ie||re?(0,u.jsx)(s.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:pr,"aria-label":E(`gantt.toolbar.saveLayout`),"aria-pressed":dr,"data-testid":`gantt-save-layout`,style:dr?{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":E(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=>{Be(Math.max(160,Math.min(n+(e.clientX-t),r)))},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:E(`gantt.column.taskName`)}),Ze&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:E(`gantt.column.start`)}),(0,u.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:E(`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":E(`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":E(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:E(`gantt.row.locate`),"aria-label":E(`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":E(`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:E(`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&&x&&x.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=or(n.id),i=zn(e.start,e.end),a=te&&n.baselineStart&&n.baselineEnd?zn(n.baselineStart,n.baselineEnd):null,c=a?(0,u.jsx)(`div`,{className:`absolute pointer-events-none rounded-[1px]`,style:{left:a.left,width:Math.max(2,a.width),top:Qn,height:Zn,backgroundColor:$n,border:`1px solid ${er}`},"data-testid":`gantt-baseline-${n.id}`,"aria-hidden":`true`}):null,l=B?.taskId===n.id,d=Vn?.has(String(n.id))??!1,f=Hn?.has(String(n.id))??!1,p=l||d||f?Un(e):i,m=!!n.locked,h=!!N&&!e.isSummary&&!m,g=H!=null&&H.targetId!=null&&String(H.targetId)===String(n.id)&&String(H.sourceId)!==String(n.id),_=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,v=H?e=>{e.target===e.currentTarget&&At(e=>e&&{...e,targetId:null,targetEnd:null})}:void 0,ee=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(p.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`}),` · `,ee,E(`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:v,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:v,children:[c,(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`,l&&`ring-2 ring-primary z-10`,dn===n.id&&`gantt-flash z-10`),style:{left:p.left,width:p.width,top:Xn,height:Yn,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||o?.(n)},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})]}),l&&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(p.left,4),top:Xn+Yn+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=qn;return(0,u.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:F},onPointerMove:v,children:[c,(0,u.jsx)(`div`,{className:(0,s.cn)(`gantt-bar-hover absolute rotate-45 rounded-[2px] border shadow-sm select-none`,h?`cursor-grab active:cursor-grabbing`:`cursor-pointer`,l&&`ring-2 ring-primary z-10`,g&&`ring-2 ring-primary`,dn===n.id&&`gantt-flash z-10`),style:{left:p.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||o?.(n)},onContextMenu:e=>Ut(n,e),onPointerMove:_,onPointerDown:h?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:v,onMouseEnter:()=>rt(n.id),onMouseLeave:()=>rt(e=>e===n.id?null:e),children:[l&&(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`}),c,(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`,h?`cursor-grab active:cursor-grabbing`:`cursor-pointer`,l&&`ring-2 ring-primary z-10`,g&&`ring-2 ring-primary`,dn===n.id&&`gantt-flash z-10`),style:{left:p.left,width:p.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||o?.(n)},onContextMenu:e=>Ut(n,e),onPointerMove:_,onPointerDown:h?e=>{e.button===0&&Tt(n,`move`,e)}:void 0,children:[h&&p.width>=14&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0 bottom-0`,style:{width:6,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 bottom-0`,style:{width:6,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)`}}),h&&p.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:p.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&&!m&&[`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:l?`${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=tr(e);if(!r)return null;let i=nr!=null&&(String(e.sourceId)===String(nr)||String(e.targetId)===String(nr)),a=ar?.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`?-Jn:Jn):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=>E(`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:E(`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:E(`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:E(`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:E(`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:E(`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`,E(`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:E(`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`?E(`gantt.menu.addPredecessor`):E(`gantt.menu.addSuccessor`)}),r.length===0?(0,u.jsx)(`div`,{className:`px-3 py-1.5 text-muted-foreground`,children:E(`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:E(`gantt.conflict.title`)}),(0,u.jsx)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:E(`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:E(`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:E(`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,ee]=(0,t.useState)(null),[y,b]=(0,t.useState)(null),{currency:x}=(0,a.useLocalization)(),te=Ve(e),S=(0,t.useMemo)(()=>te,[JSON.stringify(te)]),C=Ue(e),w=S?.provider===`value`;(0,t.useEffect)(()=>{(async()=>{try{if(_(!0),p.data&&Array.isArray(p.data)){h(p.data),_(!1);return}if(w&&S?.provider===`value`){h(S.items),_(!1);return}if(!i||typeof i.find!=`function`)throw Error(`DataSource required for object/api providers`);if(S?.provider===`object`){let t=S.object,r=(0,n.buildExpandFields)(y?.fields);h((0,n.extractRecords)(await i.find(t,{$filter:e.filter,$orderby:He(e.sort),...r.length>0?{$expand:r}:{}})))}else S?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectGantt`),h([]));_(!1)}catch(e){ee(e),_(!1)}})()},[S,i,w,e.filter,e.sort,y]),(0,t.useEffect)(()=>{!w&&i&&(async()=>{try{if(!i)return;let t=S?.provider===`object`?S.object:e.objectName;if(!t)return;b(await i.getObjectSchema(t))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,i,w,S]);let T=(0,t.useMemo)(()=>{if(!C||!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}=C,g=y?.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)(y,e)},ee=(e,t)=>{if(t)return t;let n=g[e]??g[e.split(`.`)[0]];return n?.label?n.label:(0,c.humanizeLabel)(e)},b=(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,x));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)}},te=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:ee(r,i),value:b(_(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,ee=g?new Date(g):void 0,y=v(n),b=i?n[i]:0,x=o?n[o]:[],S=s?n[s]:void 0;if(!S){let e=n.status??n.state??n.priority??n.severity;if(e!=null&&e!==``){let t=(0,c.getSemanticColorName)(void 0,e);t&&(S=(0,c.getSemanticHex)(t))}}return{id:n.id||n._id||`task-${r}`,title:y,start:a?new Date(a):new Date,end:f?new Date(f):new Date,progress:Math.min(100,Math.max(0,b||0)),dependencies:I(x),parent:l?n[l]??null:void 0,type:u?ze(n[u]):void 0,locked:d?!!n[d]:void 0,color:S,baselineStart:_&&!isNaN(_.getTime())?_:void 0,baselineEnd:ee&&!isNaN(ee.getTime())?ee:void 0,fields:te(n),data:n}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[m,C,y]),ne=(0,t.useMemo)(()=>{let e=C?.groupByField;if(!e)return;let t=y?.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)}}},[C?.groupByField,y]),re=(0,t.useMemo)(()=>{let e=C?.assigneeField;if(!e)return;let t=y?.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)}}},[C?.assigneeField,y]),ie=(0,t.useMemo)(()=>{let e=C?.effortField;if(e)return t=>{let n=t.data?.[e],r=Number(n);return Number.isFinite(r)&&r>0?r:1}},[C?.effortField]),ae=(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]),oe=(0,t.useMemo)(()=>se(C?.timeSegments),[C?.timeSegments]),E=(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)},[]),D=C?.quickFilters,[O,ce]=(0,t.useState)({});(0,t.useEffect)(()=>{if(!D?.length||!i||typeof i.find!=`function`)return;let e=y?.fields??{},t=!1;return(async()=>{let r={};for(let t of D){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(D),i,y]);let le=(0,t.useMemo)(()=>{if(!D?.length)return[];let e=y?.fields??{};return D.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=E(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}})},[D,y,O,m,E]),[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?T.filter(t=>e.every(([e,n])=>{let r=E(t.data,e);return r!=null&&n.includes(r)})):T},[T,ue,E]),he=(0,t.useMemo)(()=>{if(C?.autoZoomToFilter!==!1||!T.length)return null;let e=T[0].start.getTime(),t=T[0].end.getTime();for(let n of T)e=Math.min(e,n.start.getTime()),t=Math.max(t,n.end.getTime());return{start:new Date(e),end:new Date(t)}},[T,C?.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(!C)return;let r=S?.provider===`object`?S.object:e.objectName;if(!r||!i||typeof i.update!=`function`)return;let{startDateField:a,endDateField:o,titleField:s,progressField:c}=C,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)}},[C,S,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=C?.dependenciesField;if(!a)return;let o=S?.provider===`object`?S.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)}},[C,S,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=C?.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};await be(i,o,l?s.map(e=>c(e)===String(r)?d:e):[...s,d])},[C,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=C?.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)},[C,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=S?.provider===`object`?S.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,S,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]})})}):C?(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:T.length,labels:{all:`全部`,clear:`清除筛选`,empty:`无可选项`,resultSummary:(e,t)=>`显示 ${e} / ${t} 项任务`}}),(0,u.jsx)(`div`,{className:`h-[calc(100vh-200px)] min-h-[600px]`,children:C?.resourceView&&re?(0,u.jsx)(Me,{tasks:me,assignee:re,effort:ie,capacity:C?.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:C?.dependenciesField?xe:void 0,onDependencyDelete:C?.dependenciesField?Se:void 0,markers:e.markers,autoSchedule:!!C?.dependenciesField,rescheduleOnConflict:!!C?.dependenciesField,criticalPathDefault:!!e.criticalPath,workingCalendar:ae,shiftSegments:oe,showBaselines:e.showBaselines!==!1,readOnly:!!e.readOnly,mobileReadOnly:e.mobileReadOnly!==!1,persistLayoutKey:e.persistLayout===!1?void 0:`${e.objectName||(S?.provider===`object`?S.object:``)||`gantt`}:${e.viewName||`default`}`,groupBy:ne,defaultCollapsedDepth:C?.defaultCollapsedDepth,inlineEdit:!0})}),_e.isOverlay&&_e.isOpen&&_e.selectedRecord&&(()=>{let t=S?.provider===`object`?S.object:e.objectName,n=_e.selectedRecord,r=n.id??n._id;if(!t||r==null)return null;let a=C?.titleField?String(n[C.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:y,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});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/plugin-gantt",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Gantt chart plugin for Object UI",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@objectstack/spec": "^11.
|
|
28
|
-
"lucide-react": "^1.
|
|
29
|
-
"@object-ui/components": "11.
|
|
30
|
-
"@object-ui/core": "11.
|
|
31
|
-
"@object-ui/fields": "11.
|
|
32
|
-
"@object-ui/i18n": "11.
|
|
33
|
-
"@object-ui/plugin-detail": "11.
|
|
34
|
-
"@object-ui/react": "11.
|
|
35
|
-
"@object-ui/types": "11.
|
|
27
|
+
"@objectstack/spec": "^11.2.0",
|
|
28
|
+
"lucide-react": "^1.22.0",
|
|
29
|
+
"@object-ui/components": "11.3.0",
|
|
30
|
+
"@object-ui/core": "11.3.0",
|
|
31
|
+
"@object-ui/fields": "11.3.0",
|
|
32
|
+
"@object-ui/i18n": "11.3.0",
|
|
33
|
+
"@object-ui/plugin-detail": "11.3.0",
|
|
34
|
+
"@object-ui/react": "11.3.0",
|
|
35
|
+
"@object-ui/types": "11.3.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/react": "19.2.17",
|
|
43
43
|
"@types/react-dom": "19.2.3",
|
|
44
|
-
"@vitejs/plugin-react": "^6.0.
|
|
44
|
+
"@vitejs/plugin-react": "^6.0.3",
|
|
45
45
|
"typescript": "^6.0.3",
|
|
46
|
-
"vite": "^8.0
|
|
47
|
-
"vite-plugin-dts": "^5.0.
|
|
46
|
+
"vite": "^8.1.0",
|
|
47
|
+
"vite-plugin-dts": "^5.0.3"
|
|
48
48
|
},
|
|
49
49
|
"keywords": [
|
|
50
50
|
"objectui",
|