@taskctrl/canvas-timeline 0.5.0 → 0.6.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/dist/canvas/GridLayer.d.ts +1 -1
- package/dist/canvas-timeline.cjs.js +1 -1
- package/dist/canvas-timeline.cjs.js.map +1 -1
- package/dist/canvas-timeline.es.js +974 -818
- package/dist/canvas-timeline.es.js.map +1 -1
- package/dist/dom/DateHeader.d.ts +2 -1
- package/dist/dom/TimelineHeaders.d.ts +2 -1
- package/dist/types.d.ts +8 -0
- package/dist/utils/timezone.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Group, TimelineTheme, DayStyle, RowStyle, TimeRangeHighlight } from '../types';
|
|
2
2
|
import type { ViewState } from '../core/ViewState';
|
|
3
3
|
export declare class GridLayer {
|
|
4
|
-
draw(ctx: CanvasRenderingContext2D, view: ViewState, groups: Group[], theme: TimelineTheme, dayStyle?: (date: Date) => DayStyle | null, rowStyle?: (group: Group) => RowStyle | null, highlights?: TimeRangeHighlight[]): void;
|
|
4
|
+
draw(ctx: CanvasRenderingContext2D, view: ViewState, groups: Group[], theme: TimelineTheme, dayStyle?: (date: Date) => DayStyle | null, rowStyle?: (group: Group) => RowStyle | null, highlights?: TimeRangeHighlight[], timezone?: string): void;
|
|
5
5
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("react/jsx-runtime"),f=require("react"),pi=require("react-dom"),he=require("dayjs"),ve={primary:"#269bf7",trainColors:{},status:{red:"#EF5350",yellow:"#FBBF24",green:"#31c48d"},grid:{line:"#E5E5E5",rowAlt:"#F7F7F7",weekend:"rgba(0,0,0,0.03)"},item:{radius:3,text:"#374151",selectedRing:"#a3a3a3"},marker:{today:"#FD7171",milestone:"#3B82F6",cursor:"#269bf7"},sidebar:{bg:"#F9FAFB",border:"#E5E7EB",text:"#6c737f"},header:{bg:"#F9FAFB",border:"#E5E7EB",text:"#6c737f"}};class lt{constructor(e){Object.defineProperty(this,"visibleTimeStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleTimeEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"canvasWidth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"canvasHeight",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sidebarWidth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"lineHeight",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"groupCount",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"scrollTop",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"groupHeights",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleDuration",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pixelsPerMs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"groupYOffsets",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.visibleTimeStart=e.visibleTimeStart,this.visibleTimeEnd=e.visibleTimeEnd,this.canvasWidth=e.canvasWidth,this.canvasHeight=e.canvasHeight,this.sidebarWidth=e.sidebarWidth,this.lineHeight=e.lineHeight,this.groupCount=e.groupCount,this.buffer=e.buffer,this.scrollTop=e.scrollTop,this.groupHeights=e.groupHeights??null,this.visibleDuration=this.visibleTimeEnd-this.visibleTimeStart,this.pixelsPerMs=this.canvasWidth/this.visibleDuration,this.groupYOffsets=[],this.recomputeGroupYOffsets()}update(e){e.visibleTimeStart!==void 0&&(this.visibleTimeStart=e.visibleTimeStart),e.visibleTimeEnd!==void 0&&(this.visibleTimeEnd=e.visibleTimeEnd),e.canvasWidth!==void 0&&(this.canvasWidth=e.canvasWidth),e.canvasHeight!==void 0&&(this.canvasHeight=e.canvasHeight),e.sidebarWidth!==void 0&&(this.sidebarWidth=e.sidebarWidth),e.lineHeight!==void 0&&(this.lineHeight=e.lineHeight),e.groupCount!==void 0&&(this.groupCount=e.groupCount),e.buffer!==void 0&&(this.buffer=e.buffer),e.scrollTop!==void 0&&(this.scrollTop=e.scrollTop),e.groupHeights!==void 0&&(this.groupHeights=e.groupHeights??null),this.visibleDuration=this.visibleTimeEnd-this.visibleTimeStart,this.pixelsPerMs=this.canvasWidth/this.visibleDuration,this.recomputeGroupYOffsets()}recomputeGroupYOffsets(){var t;const e=new Array(this.groupCount+1);e[0]=0;for(let n=0;n<this.groupCount;n++){const s=((t=this.groupHeights)==null?void 0:t[n])??this.lineHeight;e[n+1]=e[n]+s}this.groupYOffsets=e}timeToX(e){return(e-this.visibleTimeStart)*this.pixelsPerMs}xToTime(e){return this.visibleTimeStart+e/this.pixelsPerMs}yToGroupIndex(e){if(this.groupCount===0)return 0;const t=e+this.scrollTop;if(t<=0)return 0;if(t>=this.groupYOffsets[this.groupCount])return this.groupCount-1;let n=0,s=this.groupCount-1;for(;n<s;){const d=n+s>>>1;this.groupYOffsets[d+1]>t?s=d:n=d+1}return n}groupIndexToY(e){return e<0?-this.scrollTop:e>=this.groupCount?(this.groupYOffsets[this.groupCount]??0)-this.scrollTop:this.groupYOffsets[e]-this.scrollTop}groupIndexToHeight(e){var t;return e<0||e>=this.groupCount?this.lineHeight:((t=this.groupHeights)==null?void 0:t[e])??this.lineHeight}getBufferBounds(){const e=this.visibleDuration*1.5;return{bufferStart:this.visibleTimeStart-e,bufferEnd:this.visibleTimeEnd+e}}getVisibleGroupRange(){if(this.groupCount===0)return{firstVisible:0,lastVisible:-1};const e=this.yToGroupIndex(0),t=this.yToGroupIndex(this.canvasHeight);return{firstVisible:e,lastVisible:t}}isScrollInBuffer(e){const t=this.visibleDuration*1.5*this.pixelsPerMs;return Math.abs(e)<t}getTotalHeight(){return this.groupYOffsets[this.groupCount]??0}}class bi{constructor(){Object.defineProperty(this,"root",{enumerable:!0,configurable:!0,writable:!0,value:null})}buildFromItems(e,t,n){const s=e.map(d=>({item:d,start:t(d),end:n(d)}));this.root=this.buildNode(s)}buildNode(e){if(e.length===0)return null;let t=1/0,n=-1/0;for(const u of e)u.start<t&&(t=u.start),u.end>n&&(n=u.end);const s=(t+n)/2,d=[],l=[],c=[];for(const u of e)u.end<s?d.push(u):u.start>s?l.push(u):c.push(u);return{center:s,left:this.buildNode(d),right:this.buildNode(l),overlapping:c}}query(e,t){const n=[];return this.queryNode(this.root,e,t,n),n}queryNode(e,t,n,s){if(e!==null){for(const d of e.overlapping)d.start<=n&&d.end>=t&&s.push(d.item);t<=e.center&&e.left!==null&&this.queryNode(e.left,t,n,s),n>=e.center&&e.right!==null&&this.queryNode(e.right,t,n,s)}}}class vi{constructor(e,t){Object.defineProperty(this,"lineHeight",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"itemHeightRatio",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"layoutCache",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"groupMaxStack",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),this.lineHeight=e,this.itemHeightRatio=t}computeLayout(e,t,n){this.layoutCache=new Map,this.groupMaxStack=new Map;const s=this.lineHeight*this.itemHeightRatio,d=s*.6;if(!t){for(const c of e){const u=(n==null?void 0:n.isParent(c.id))??!1;this.layoutCache.set(c.id,{stackLevel:0,itemHeight:u?d:s}),this.groupMaxStack.set(c.group,0)}return this.layoutCache}const l=new Map;for(const c of e){let u=l.get(c.group);u||(u=[],l.set(c.group,u)),u.push(c)}for(const[c,u]of l)n?this.computeHierarchyLayout(u,n,s,d,c):this.computeFlatLayout(u,s,c);return this.layoutCache}computeFlatLayout(e,t,n){e.sort((l,c)=>{const u=l.start_time-c.start_time;return u!==0?u:c.end_time-c.start_time-(l.end_time-l.start_time)});const s=[];let d=0;for(const l of e){let c=-1;for(let u=0;u<s.length;u++)if(s[u]<=l.start_time){c=u;break}c===-1?(c=s.length,s.push(l.end_time)):s[c]=l.end_time,c>d&&(d=c),this.layoutCache.set(l.id,{stackLevel:c,itemHeight:t})}this.groupMaxStack.set(n,d)}computeHierarchyLayout(e,t,n,s,d){const l=[],c=[];for(const g of e)t.isParent(g.id)?c.push(g):l.push(g);l.sort((g,y)=>{const k=g.start_time-y.start_time;return k!==0?k:y.end_time-y.start_time-(g.end_time-g.start_time)});const u=[];let b=0;for(const g of l){let y=-1;for(let k=0;k<u.length;k++)if(u[k]<=g.start_time){y=k;break}y===-1?(y=u.length,u.push(g.end_time)):u[y]=g.end_time,y>b&&(b=y),this.layoutCache.set(g.id,{stackLevel:y,itemHeight:n})}c.sort((g,y)=>t.getNestingDepth(y.id)-t.getNestingDepth(g.id));let C=l.length>0?b+1:0;for(const g of c)this.layoutCache.set(g.id,{stackLevel:C,itemHeight:s}),C>b&&(b=C),C++;this.groupMaxStack.set(d,b)}getLayout(e){return this.layoutCache.get(e)}getGroupHeight(e){return((this.groupMaxStack.get(e)??0)+1)*this.lineHeight}}class jt{constructor(){Object.defineProperty(this,"parentToChildren",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"childToParent",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"itemMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"depthCache",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}rebuild(e){this.parentToChildren=new Map,this.childToParent=new Map,this.itemMap=new Map,this.depthCache=new Map;for(const t of e)this.itemMap.set(t.id,t);for(const t of e)if(t.parentId!==void 0&&this.itemMap.has(t.parentId)){this.childToParent.set(t.id,t.parentId);let n=this.parentToChildren.get(t.parentId);n||(n=[],this.parentToChildren.set(t.parentId,n)),n.push(t.id)}for(const t of this.childToParent.keys()){const n=new Set;let s=t;for(;s!==void 0;){if(n.has(s)){const d=this.childToParent.get(t);this.childToParent.delete(t);const l=this.parentToChildren.get(d);if(l){const c=l.indexOf(t);c!==-1&&l.splice(c,1),l.length===0&&this.parentToChildren.delete(d)}break}n.add(s),s=this.childToParent.get(s)}}}isParent(e){const t=this.parentToChildren.get(e);return t!==void 0&&t.length>0}getParent(e){return this.childToParent.get(e)}getChildren(e){return this.parentToChildren.get(e)??[]}getDescendants(e){const t=[],n=[...this.getChildren(e)];for(;n.length>0;){const s=n.pop();t.push(s);const d=this.parentToChildren.get(s);d&&n.push(...d)}return t}getEffectiveSpan(e){const t=this.itemMap.get(e);if(!t)return{start:0,end:0};let n=t.start_time,s=t.end_time;const d=this.getDescendants(e);for(const l of d){const c=this.itemMap.get(l);c&&(c.start_time<n&&(n=c.start_time),c.end_time>s&&(s=c.end_time))}return{start:n,end:s}}getNestingDepth(e){const t=this.depthCache.get(e);if(t!==void 0)return t;let n=0,s=this.childToParent.get(e);for(;s!==void 0;)n++,s=this.childToParent.get(s);return this.depthCache.set(e,n),n}getMoveDelta(e,t){const n=this.itemMap.get(e);if(!n)return[];const s=t-n.start_time;return this.getDescendants(e).map(l=>{const c=this.itemMap.get(l);return{itemId:l,newStart:c.start_time+s}})}getResizeConstraint(e,t){const n=this.getDescendants(e);if(n.length===0)return t==="left"?{min:-1/0,max:1/0}:{min:-1/0,max:1/0};if(t==="left"){let s=1/0;for(const d of n){const l=this.itemMap.get(d);l&&l.start_time<s&&(s=l.start_time)}return{min:-1/0,max:s}}else{let s=-1/0;for(const d of n){const l=this.itemMap.get(d);l&&l.end_time>s&&(s=l.end_time)}return{min:s,max:1/0}}}}function yi(i,e,t,n,s,d){const{x:l,y:c,width:u,height:b}=t,C=d.primary;i.globalAlpha=.15,i.fillStyle=C,i.fillRect(l,c,u,b),i.globalAlpha=1,i.strokeStyle=C,i.lineWidth=1.5,i.strokeRect(l,c,u,b);const g=Math.min(b*.5,6),y=c+b/2;i.fillStyle=C,i.beginPath(),i.moveTo(l,y),i.lineTo(l+g,y-g),i.lineTo(l+g*2,y),i.lineTo(l+g,y+g),i.closePath(),i.fill(),i.beginPath(),i.moveTo(l+u,y),i.lineTo(l+u-g,y-g),i.lineTo(l+u-g*2,y),i.lineTo(l+u-g,y+g),i.closePath(),i.fill();const k=e.title;if(k&&u>30){i.fillStyle=d.item.text,i.font='500 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',i.textBaseline="middle";const R=i.measureText(k).width,X=u-g*4-4;if(X>20){const x=R>X?k.slice(0,Math.floor(k.length*X/R))+"...":k;i.fillText(x,l+u/2-Math.min(R,X)/2,y)}}n.selected&&(i.strokeStyle=d.item.selectedRing,i.lineWidth=2,i.strokeRect(l-1,c-1,u+2,b+2))}function Ae(i,e,t,n,s,d){const l=t.xToTime(i),c=new Map;for(let g=0;g<d.length;g++)c.set(d[g].id,g);const u=n.query(l,l);let b=null,C=-1/0;for(const g of u){const y=c.get(g.group);if(y===void 0)continue;const k=s.getLayout(g.id);if(!k)continue;const R=t.timeToX(g.start_time),X=t.timeToX(g.end_time)-R;if(i<R||i>R+X)continue;const ne=t.groupIndexToY(y)+k.stackLevel*t.lineHeight+(t.lineHeight-k.itemHeight)/2,E=k.itemHeight;e<ne||e>ne+E||ne>C&&(C=ne,b=g)}return b}function at(i,e,t){const n=e.yToGroupIndex(i);return t[n]??null}function Dt(i,e,t,n=6){const s=t.timeToX(e.start_time),d=t.timeToX(e.end_time);return i-s<=n?"left":d-i<=n?"right":"body"}function ut(i,e,t){const n=window.devicePixelRatio||1,s=Math.round(e*n),d=Math.round(t*n);(i.width!==s||i.height!==d)&&(i.width=s,i.height=d,i.style.width=`${e}px`,i.style.height=`${t}px`);const l=i.getContext("2d");return l.setTransform(n,0,0,n,0,0),l}function ct(i,e){const t=window.devicePixelRatio||1;i.clearRect(0,0,e.width/t,e.height/t)}class Ti{constructor(e){Object.defineProperty(this,"dirty",{enumerable:!0,configurable:!0,writable:!0,value:{grid:!1,items:!1,overlay:!1}}),Object.defineProperty(this,"rafId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"drawCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.drawCallback=e}markDirty(e){this.dirty[e]=!0,this.schedule()}markAllDirty(){this.dirty.grid=!0,this.dirty.items=!0,this.dirty.overlay=!0,this.schedule()}dispose(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}schedule(){this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null;const e={...this.dirty};this.dirty.grid=!1,this.dirty.items=!1,this.dirty.overlay=!1,this.drawCallback(e)}))}}class ki{draw(e,t,n,s,d,l,c){const{firstVisible:u,lastVisible:b}=t.getVisibleGroupRange();for(let E=u;E<=b;E++){const _=t.groupIndexToY(E),w=t.groupIndexToHeight(E),P=n[E];if(!P)continue;let z;const Y=l==null?void 0:l(P);Y!=null&&Y.backgroundColor?z=Y.backgroundColor:z=E%2===0?"#FFFFFF":s.grid.rowAlt,e.fillStyle=z,e.fillRect(0,_,t.canvasWidth,w),e.strokeStyle=(Y==null?void 0:Y.borderBottomColor)??s.grid.line,e.lineWidth=.5,e.beginPath(),e.moveTo(0,_+w),e.lineTo(t.canvasWidth,_+w),e.stroke()}if(c&&c.length>0)for(const E of c){const _=t.timeToX(E.start),w=t.timeToX(E.end);if(w<0||_>t.canvasWidth)continue;const P=Math.max(0,_),z=Math.min(t.canvasWidth,w)-P,Y=E.opacity??.12,F=parseInt(E.color.slice(1,3),16),G=parseInt(E.color.slice(3,5),16),U=parseInt(E.color.slice(5,7),16);e.fillStyle=`rgb(${Math.round(F*Y+255*(1-Y))},${Math.round(G*Y+255*(1-Y))},${Math.round(U*Y+255*(1-Y))})`,e.fillRect(P,0,z,t.canvasHeight)}const C=t.visibleTimeStart,g=t.visibleTimeEnd,R=864e5/(g-C)*t.canvasWidth;let X="day";R<2?X="month":R<8&&(X="week");{let E=he(C).startOf("day");const _=he(g).endOf("day");let w=null,P=1,z=0;const Y=[],F=G=>{w!==null&&(e.fillStyle=w,P!==1&&(e.globalAlpha=P),e.fillRect(z,0,G-z,t.canvasHeight),P!==1&&(e.globalAlpha=1),w=null,P=1)};for(;E.isBefore(_);){const G=t.timeToX(E.valueOf()),U=E.toDate(),Q=d==null?void 0:d(U);let re=null,le=1;if(Q!=null&&Q.backgroundColor)re=Q.backgroundColor,le=Q.opacity??1;else{const ge=E.day();(ge===0||ge===6)&&(re=s.grid.weekend)}Q!=null&&Q.borderColor&&Y.push({x:G,color:Q.borderColor}),re===w&&le===P||(F(G),re!==null&&(w=re,P=le,z=G)),E=E.add(1,"day")}w!==null&&F(t.timeToX(E.valueOf()));for(const G of Y)e.strokeStyle=G.color,e.lineWidth=.5,e.beginPath(),e.moveTo(G.x,0),e.lineTo(G.x,t.canvasHeight),e.stroke()}let x=he(C).startOf(X);const ne=he(g).add(1,X);for(e.strokeStyle=s.grid.line,e.lineWidth=.5,e.beginPath();x.isBefore(ne);){const E=t.timeToX(x.valueOf());e.moveTo(E,0),e.lineTo(E,t.canvasHeight),x=x.add(1,X)}if(e.stroke(),c&&c.length>0)for(const E of c){const _=t.timeToX(E.start),w=t.timeToX(E.end);if(!(w<0||_>t.canvasWidth)&&(e.strokeStyle=E.color,e.globalAlpha=.4,e.lineWidth=1,e.beginPath(),_>=0&&_<=t.canvasWidth&&(e.moveTo(_,0),e.lineTo(_,t.canvasHeight)),w>=0&&w<=t.canvasWidth&&(e.moveTo(w,0),e.lineTo(w,t.canvasHeight)),e.stroke(),e.globalAlpha=1,E.label)){const P=Math.max(0,_),z=Math.min(t.canvasWidth,w)-P;e.save(),e.font='600 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';const Y=e.measureText(E.label).width,F=6,G=Y+F*2,U=18,Q=P+(z-G)/2,re=4;e.fillStyle=E.color,e.globalAlpha=.9,e.beginPath(),e.roundRect(Q,re,G,U,3),e.fill(),e.globalAlpha=1,e.fillStyle="#FFFFFF",e.textBaseline="middle",e.fillText(E.label,Q+F,re+U/2),e.restore()}}}}const Ot='500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';function Lt(i,e){return{roundRect(t,n,s,d,l=3){i.beginPath(),i.roundRect(t,n,s,d,l),i.fill()},fillText(t,n,s,d){if(i.font=Ot,d!==void 0&&i.measureText(t).width>d){let l=0,c=t.length;for(;l<c;){const u=Math.ceil((l+c)/2),b=t.slice(0,u)+"...";i.measureText(b).width<=d?l=u:c=u-1}i.fillText(t.slice(0,l)+"...",n,s)}else i.fillText(t,n,s)},gradient(t,n,s,d){const l=i.createLinearGradient(t,0,t+n,0);return l.addColorStop(0,s),l.addColorStop(.5,s),l.addColorStop(.5,d),l.addColorStop(1,d),l},leftBar(t,n=3){e&&(i.save(),i.fillStyle=t,i.fillRect(e.x,e.y,n,e.height),i.restore())},icon(t,n,s,d=14){i.save();const l=d/2;if(t==="check"){i.fillStyle="#31c48d",i.beginPath(),i.arc(n+l,s+l,l,0,Math.PI*2),i.fill(),i.strokeStyle="#ffffff",i.lineWidth=d*.12,i.beginPath();const c=n+l,u=s+l;i.moveTo(c-l*.45,u),i.lineTo(c-l*.1,u+l*.42),i.lineTo(c+l*.45,u-l*.35),i.stroke()}else if(t==="danger-red"||t==="danger-yellow"){const c=t==="danger-red"?"#EF5350":"#FBBF24";i.fillStyle=c,i.beginPath(),i.moveTo(n+l,s),i.lineTo(n+d,s+d),i.lineTo(n,s+d),i.closePath(),i.fill(),i.fillStyle="#ffffff";const u=d*.12,b=n+l-u/2;i.fillRect(b,s+d*.35,u,d*.35),i.beginPath(),i.arc(n+l,s+d*.82,u*.7,0,Math.PI*2),i.fill()}i.restore()},badge(t,n,s,d){i.save(),i.font=Ot;const c=i.measureText(t).width,u=8,C=12+3*2,g=c+u*2,y=C/2;i.fillStyle=d,i.beginPath(),i.roundRect(n,s,g,C,y),i.fill(),i.fillStyle="#ffffff",i.textAlign="center",i.textBaseline="middle",i.fillText(t,n+g/2,s+C/2),i.restore()}}}class Mi{draw(e,t,n,s,d,l,c,u,b,C,g,y,k,R){const X=(t.visibleTimeEnd-t.visibleTimeStart)*.1,x=t.visibleTimeStart-X,ne=t.visibleTimeEnd+X,E=d.query(x,ne),_=new Map;for(let F=0;F<n.length;F++)_.set(n[F].id,F);const w=new Set(C),P=new Map,z=-t.lineHeight,Y=t.canvasHeight+t.lineHeight;for(const F of E){const G=_.get(F.group);if(G===void 0)continue;const U=l.getLayout(F.id);if(!U)continue;const re=t.groupIndexToY(G)+U.stackLevel*t.lineHeight+(t.lineHeight-U.itemHeight)/2,le=U.itemHeight;if(re+le<z||re>Y)continue;const ge=t.timeToX(F.start_time),Re=t.timeToX(F.end_time)-ge,pe={x:ge,y:re,width:Re,height:le};P.set(F.id,pe);const Ie={selected:w.has(F.id),hovered:g===F.id,dragging:!1,filtered:F.filtered!==!1};e.save();const xe=Lt(e,pe);let Se;k&&(R!=null&&R.isParent(F.id))?Se=k:u&&(F.type==="control_area_group"||F.type==="construction_train")?Se=u:Se=c,Se(e,F,pe,Ie,xe),e.restore()}if(y&&y.length>0){const F=new Set;for(const G of y)P.has(G.fromItemId)||F.add(G.fromItemId),P.has(G.toItemId)||F.add(G.toItemId);if(F.size>0){const G=new Map;for(const U of s)F.has(U.id)&&G.set(U.id,U);for(const[U,Q]of G){const re=_.get(Q.group);if(re===void 0)continue;const le=l.getLayout(U);if(!le)continue;const Re=t.groupIndexToY(re)+le.stackLevel*t.lineHeight+(t.lineHeight-le.itemHeight)/2,pe=t.timeToX(Q.start_time),Ie=t.timeToX(Q.end_time)-pe;P.set(U,{x:pe,y:Re,width:Ie,height:le.itemHeight})}}this.drawDependencies(e,y,P,g,b)}}drawDependencies(e,t,n,s,d){for(const l of t){const c=n.get(l.fromItemId),u=n.get(l.toItemId);if(!c||!u)continue;const b=s===l.fromItemId||s===l.toItemId;e.strokeStyle=b?d.primary:l.color??"#94A3B8",e.lineWidth=b?2:1.5,e.setLineDash([]);const C=c.x+c.width,g=c.y+c.height/2,y=u.x,k=u.y+u.height/2,R=Math.abs(y-C),X=Math.max(R*.4,30);e.beginPath(),e.moveTo(C,g),e.bezierCurveTo(C+X,g,y-X,k,y,k),e.stroke();const x=6;e.fillStyle=e.strokeStyle,e.beginPath(),e.moveTo(y,k),e.lineTo(y-x,k-x/2),e.lineTo(y-x,k+x/2),e.closePath(),e.fill()}}}class Si{draw(e,t,n,s){const{cursorX:d,snapX:l,markers:c,interaction:u}=s;if(c)for(const b of c){const C=t.timeToX(b.date);if(e.fillStyle=b.color,e.fillRect(C-b.width/2,0,b.width,t.canvasHeight),b.label){e.save(),e.font='500 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';const g=e.measureText(b.label).width,y=8,k=200,R=Math.min(g+y*2,k),X=20,x=C-R/2,ne=4;e.fillStyle=b.color,e.beginPath(),e.roundRect(x,ne,R,X,3),e.fill(),e.fillStyle="#FFFFFF",e.textBaseline="middle";const E=k-y*2,_=g>E?b.label.slice(0,Math.floor(b.label.length*E/g))+"…":b.label;e.fillText(_,x+y,ne+X/2),e.restore()}}if(d!=null&&(e.strokeStyle=n.marker.cursor,e.lineWidth=1,e.beginPath(),e.moveTo(d,0),e.lineTo(d,t.canvasHeight),e.stroke()),l!=null&&(e.strokeStyle=n.primary,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(l,0),e.lineTo(l,t.canvasHeight),e.stroke(),e.setLineDash([])),u){u.groupChanged&&u.targetGroupY!==void 0&&(e.fillStyle="rgba(59, 130, 246, 0.08)",e.fillRect(0,u.targetGroupY,t.canvasWidth,t.lineHeight)),e.save(),e.globalAlpha=.5;const b=Lt(e,u.bounds);u.renderer(e,u.item,u.bounds,{selected:!1,hovered:!1,dragging:!0,filtered:!0},b),e.restore()}}}const Xt=120;function Ei(i){let e=i.deltaY||i.deltaX;return i.deltaMode===1?e*=15:i.deltaMode===2&&(e*=800),Math.max(-Xt,Math.min(Xt,e))}class Ci{constructor(e,t,n,s,d){Object.defineProperty(this,"onZoom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleTimeStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleTimeEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"minZoom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxZoom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.onZoom=e,this.visibleTimeStart=t,this.visibleTimeEnd=n,this.minZoom=s,this.maxZoom=d}updateBounds(e,t){this.visibleTimeStart=e,this.visibleTimeEnd=t}handleWheelZoom(e,t){const n=Ei(e),s=e.ctrlKey?10:e.metaKey?3:1,d=n>0?1+s*n/500:1/(1+s*-n/500),l=this.visibleTimeEnd-this.visibleTimeStart;let c=Math.round(l*d);c=Math.max(this.minZoom,Math.min(this.maxZoom,c));const u=Math.round(this.visibleTimeStart+(l-c)*t),b=u+c;this.onZoom(u,b)}}const wi=4;class Hi{constructor(e){Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"dragSnap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.dragSnap=e}startInteraction(e,t,n,s){this.state={item:e,mode:t,startX:n,startY:s,currentX:n,currentY:s,deltaX:0,originalGroup:e.group,currentGroup:e.group},this.activated=!1}update(e,t){this.state&&(this.state.currentX=e,this.state.currentY=t,this.state.deltaX=e-this.state.startX,!this.activated&&Math.abs(this.state.deltaX)>=wi&&(this.activated=!0))}setCurrentGroup(e){this.state&&(this.state.currentGroup=e)}endMove(e){if(!this.state)return null;const t=this.state.deltaX/e,n=this.state.item.start_time+t,s=Math.round(n/this.dragSnap)*this.dragSnap,d=this.state.currentGroup;return this.state=null,this.activated=!1,{newStartTime:s,newGroupId:d}}endResize(e){if(!this.state)return null;const t=this.state.deltaX/e,n=this.state.mode==="resize-left"?"left":"right",d=(n==="left"?this.state.item.start_time:this.state.item.end_time)+t,l=Math.round(d/this.dragSnap)*this.dragSnap;return this.state=null,this.activated=!1,{newTime:l,edge:n}}cancel(){this.state=null,this.activated=!1}getState(){return this.state}getMode(){var e;return((e=this.state)==null?void 0:e.mode)??null}isActive(){return this.state!==null&&this.activated}isPending(){return this.state!==null}}function dt(i,e,t){const n=[];for(const s of i)s.id!==e&&(n.push(t(s.start_time)),n.push(t(s.end_time)));return n}function Ue(i,e,t,n,s){if(e.length===0)return null;let d=e[0],l=Math.abs(i-d);for(let c=1;c<e.length;c++){const u=Math.abs(i-e[c]);u<l&&(l=u,d=e[c])}return l<=t?d:null}var At=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Gt={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(At,function(){var t="day";return function(n,s,d){var l=function(b){return b.add(4-b.isoWeekday(),t)},c=s.prototype;c.isoWeekYear=function(){return l(this).year()},c.isoWeek=function(b){if(!this.$utils().u(b))return this.add(7*(b-this.isoWeek()),t);var C,g,y,k,R=l(this),X=(C=this.isoWeekYear(),g=this.$u,y=(g?d.utc:d)().year(C).startOf("year"),k=4-y.isoWeekday(),y.isoWeekday()>4&&(k+=7),y.add(k,t));return R.diff(X,"week")+1},c.isoWeekday=function(b){return this.$utils().u(b)?this.day()||7:this.day(this.day()%7?b:b-7)};var u=c.startOf;c.startOf=function(b,C){var g=this.$utils(),y=!!g.u(C)||C;return g.p(b)==="isoweek"?y?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):u.bind(this)(b,C)}}})})(Gt);var Ri=Gt.exports;const Ii=xt(Ri),_t=200;function Ft({groups:i,width:e,lineHeight:t,groupHeights:n,scrollTop:s,canvasHeight:d,theme:l,groupRenderer:c,onScroll:u}){var _;const b=f.useRef(null),C=f.useRef(!1),g=f.useMemo(()=>{const w=new Array(i.length+1);w[0]=0;for(let P=0;P<i.length;P++)w[P+1]=w[P]+((n==null?void 0:n[P])??t);return w},[i.length,n,t]),y=g[i.length]??0,k=d,R=f.useCallback(w=>{if(i.length===0||w<=0)return 0;if(w>=y)return i.length-1;let P=0,z=i.length-1;for(;P<z;){const Y=P+z>>>1;g[Y+1]>w?z=Y:P=Y+1}return P},[i.length,g,y]),X=R(s-_t),x=R(s+d+_t),ne=f.useCallback(w=>{C.current||u(w.currentTarget.scrollTop)},[u]);f.useEffect(()=>{b.current&&(C.current=!0,b.current.scrollTop=s,requestAnimationFrame(()=>{C.current=!1}))},[s]);const E=[];for(let w=X;w<=x;w++){const P=i[w];if(!P)continue;const z=g[w],Y=g[w+1]-z;E.push(Z.jsx("div",{style:{position:"absolute",top:z,height:Y,width:"100%",overflow:"hidden",display:"flex",alignItems:"stretch",borderBottom:`1px solid ${((_=l.grid)==null?void 0:_.line)??"#E5E5E5"}`,boxSizing:"border-box"},children:c(P)},P.id))}return Z.jsx("div",{ref:b,onScroll:ne,style:{width:e,height:k,overflowY:y>d?"auto":"hidden",overflowX:"hidden",position:"relative",borderRight:`1px solid ${l.sidebar.border}`,backgroundColor:l.sidebar.bg},children:Z.jsx("div",{style:{height:y,position:"relative"},children:E})})}function Nt(i){return null}Nt.displayName="TodayMarker";function Wt(i){return{date:Math.floor(Date.now()/6e4)*6e4,color:i.color??"#FD7171",width:i.width??6,label:i.label}}function Pi(i){return i.interval??1e4}function zt(i){return null}zt.displayName="CustomMarker";function Bt(i){return{date:i.date,color:i.color??"#3B82F6",width:i.width??4,label:i.label}}he.extend(Ii);function Di(i){return i?{...ve,...i,status:{...ve.status,...i.status},grid:{...ve.grid,...i.grid},item:{...ve.item,...i.item},marker:{...ve.marker,...i.marker},sidebar:{...ve.sidebar,...i.sidebar},header:{...ve.header,...i.header}}:ve}const Yt=32,Oi=f.memo(f.forwardRef(function(e,t){const{groups:n,items:s,defaultTimeStart:d,defaultTimeEnd:l,sidebarWidth:c,lineHeight:u,itemHeightRatio:b,stackItems:C,canMove:g,canChangeGroup:y,canResize:k,dragSnap:R,minZoom:X,maxZoom:x,theme:ne,dayStyle:E,rowStyle:_,showCursorLine:w,itemRenderer:P,groupRenderer:z,sidebarGroupRenderer:Y,dependencies:F,highlights:G,onItemClick:U,onItemDoubleClick:Q,onItemContextMenu:re,onItemMove:le,onItemResize:ge,moveResizeValidator:Re,onItemHover:pe,onCanvasDoubleClick:Ie,onCanvasContextMenu:xe,onTimeChange:Se,onZoom:ft,selected:ht=[],rightSidebarWidth:Ke,rightSidebarGroupRenderer:mt,onReady:Ge,devBadge:Kt,children:ye}=e,be=f.useMemo(()=>Di(ne),[ne]),gt=f.useCallback((r,o)=>{for(let h=0;h<o.length;h++)if(o[h].id===r)return h;return 0},[]),Jt=ht.join(","),Je=f.useMemo(()=>ht,[Jt]),pt=f.useRef(null),bt=f.useRef(null),vt=f.useRef(null),_e=f.useRef(null),yt=f.useRef(null),Qt=f.useRef(null),[ei,ti]=f.useState(800);f.useEffect(()=>{const r=yt.current;if(!r)return;const o=new ResizeObserver(h=>{const m=h[0];m&&ti(m.contentRect.width)});return o.observe(r),()=>o.disconnect()},[]);const Te=Math.max(0,ei-c-(Ke??0)),Ee=f.useMemo(()=>{const r=new jt;return r.rebuild(s),r},[s]),Qe=f.useMemo(()=>{const r=new bi;return r.buildFromItems(s,o=>Ee.getEffectiveSpan(o.id).start,o=>Ee.getEffectiveSpan(o.id).end),r},[s,Ee]),Fe=f.useMemo(()=>{const r=new vi(u,b);return r.computeLayout(s,C,Ee),r},[s,u,b,C,Ee]),Ce=f.useMemo(()=>n.map(r=>Fe.getGroupHeight(r.id)),[n,Fe]),ke=f.useMemo(()=>Ce.reduce((r,o)=>r+o,0),[Ce]),W=f.useRef(new lt({visibleTimeStart:e.visibleTimeStart??d,visibleTimeEnd:e.visibleTimeEnd??l,canvasWidth:Te,canvasHeight:ke,sidebarWidth:c,lineHeight:u,groupCount:n.length,buffer:e.buffer??3,scrollTop:0,groupHeights:Ce})),et=f.useRef(null),We=f.useRef(void 0),me=f.useRef(null),we=f.useRef(!1),Tt=4,[kt,ii]=f.useState(e.visibleTimeStart??d),[Mt,ni]=f.useState(e.visibleTimeEnd??l),[St,Ne]=f.useState(0),Be=f.useRef(null),Pe=f.useCallback(()=>{const r=W.current;ii(r.visibleTimeStart),ni(r.visibleTimeEnd),Ne(r.scrollTop),Be.current=null},[]),tt=f.useCallback(()=>{Be.current===null&&(Be.current=setTimeout(Pe,Yt))},[Pe]);f.useEffect(()=>()=>{Be.current!==null&&clearTimeout(Be.current)},[]);const Et=f.useMemo(()=>e.summaryRenderer?e.summaryRenderer:(r,o,h,m,a)=>{yi(r,o,h,m,a,be)},[e.summaryRenderer,be]),De=f.useMemo(()=>new ki,[]),Oe=f.useMemo(()=>new Mi,[]),Xe=f.useMemo(()=>new Si,[]),ee=f.useMemo(()=>new Hi(R),[R]),ze=f.useMemo(()=>{const r=[];return f.Children.forEach(ye,o=>{var m;if(!f.isValidElement(o))return;const h=(m=o.type)==null?void 0:m.displayName;h==="TodayMarker"?r.push(Wt(o.props)):h==="CustomMarker"&&r.push(Bt(o.props))}),r},[ye]),$e=f.useMemo(()=>ze.map(r=>`${r.date}|${r.color}|${r.width}|${r.label??""}`).join(";"),[ze]),Ye=f.useRef(ze);Ye.current=ze;const it=f.useMemo(()=>{let r=0;return f.Children.forEach(ye,o=>{var m;if(!f.isValidElement(o))return;((m=o.type)==null?void 0:m.displayName)==="TodayMarker"&&(r=Pi(o.props))}),r},[ye]),j=f.useRef({groups:n,items:s,intervalTree:Qe,layoutEngine:Fe,itemRenderer:P,groupRenderer:z,theme:be,selected:Je,dependencies:F,highlights:G,dayStyle:E,rowStyle:_,showCursorLine:w,canvasWidth:Te,canvasHeight:ke,lineHeight:u,itemHeightRatio:b,onTimeChange:Se,onZoom:ft,onItemHover:pe,onItemClick:U,onItemDoubleClick:Q,onItemContextMenu:re,onItemMove:le,onItemResize:ge,onCanvasDoubleClick:Ie,onCanvasContextMenu:xe,canMove:g,canResize:k,canChangeGroup:y,dragSnap:R,sidebarWidth:c,moveResizeValidator:Re,summaryRenderer:Et,hierarchyEngine:Ee});j.current={groups:n,items:s,intervalTree:Qe,layoutEngine:Fe,itemRenderer:P,groupRenderer:z,theme:be,selected:Je,dependencies:F,highlights:G,dayStyle:E,rowStyle:_,showCursorLine:w,canvasWidth:Te,canvasHeight:ke,lineHeight:u,itemHeightRatio:b,onTimeChange:Se,onZoom:ft,onItemHover:pe,onItemClick:U,onItemDoubleClick:Q,onItemContextMenu:re,onItemMove:le,onItemResize:ge,onCanvasDoubleClick:Ie,onCanvasContextMenu:xe,canMove:g,canResize:k,canChangeGroup:y,dragSnap:R,sidebarWidth:c,moveResizeValidator:Re,summaryRenderer:Et,hierarchyEngine:Ee};const ri=f.useCallback(()=>{const r=pt.current;if(!r)return;const o=j.current,h=ut(r,o.canvasWidth,o.canvasHeight);ct(h,r),De.draw(h,W.current,o.groups,o.theme,o.dayStyle,o.rowStyle,o.highlights)},[De]),si=f.useCallback(()=>{const r=bt.current;if(!r)return;const o=j.current,h=ut(r,o.canvasWidth,o.canvasHeight);ct(h,r),Oe.draw(h,W.current,o.groups,o.items,o.intervalTree,o.layoutEngine,o.itemRenderer,o.groupRenderer,o.theme,o.selected,We.current,o.dependencies,o.summaryRenderer,o.hierarchyEngine)},[Oe]),Ct=f.useCallback((r,o,h)=>{const m=W.current,a=j.current,p=a.canvasWidth/(m.visibleTimeEnd-m.visibleTimeStart),T=o/p,S=[];h==="move"?(S.push(m.timeToX(r.start_time+T)),S.push(m.timeToX(r.end_time+T))):h==="resize-left"?S.push(m.timeToX(r.start_time+T)):S.push(m.timeToX(r.end_time+T));const I=(m.visibleTimeEnd-m.visibleTimeStart)*.1,D=a.intervalTree.query(m.visibleTimeStart-I,m.visibleTimeEnd+I),N=dt(D,r.id,K=>m.timeToX(K));for(const K of S){const q=Ue(K,N,8,p,a.dragSnap);if(q!==null)return q}const te=h==="resize-right"?r.end_time+T:r.start_time+T,B=Math.round(te/a.dragSnap)*a.dragSnap;return m.timeToX(B)},[]),oi=f.useCallback(()=>{const r=vt.current;if(!r)return;const o=j.current,h=ut(r,o.canvasWidth,o.canvasHeight);ct(h,r);const m=W.current,a=ee.getState();let p=null;if(a){const T=m.timeToX(a.item.start_time),S=m.timeToX(a.item.end_time)-T;let I,D;a.mode==="resize-left"?(I=T+a.deltaX,D=S-a.deltaX):a.mode==="resize-right"?(I=T,D=S+a.deltaX):(I=T+a.deltaX,D=S);const N=gt(a.currentGroup,o.groups),te=m.groupIndexToY(N),B=a.currentGroup!==a.originalGroup;p={item:a.item,mode:a.mode,bounds:{x:I,y:te+(o.lineHeight-o.lineHeight*o.itemHeightRatio)/2,width:D,height:o.lineHeight*o.itemHeightRatio},renderer:o.itemRenderer,targetGroupY:te,groupChanged:B}}Xe.draw(h,m,o.theme,{cursorX:o.showCursorLine?et.current:null,snapX:a?Ct(a.item,a.deltaX,a.mode):null,markers:Ye.current,interaction:p})},[Xe,ee,Ct,gt]),nt=f.useRef(null);nt.current||(nt.current=new Ti(r=>{r.grid&&ri(),r.items&&si(),r.overlay&&oi()}));const H=nt.current;f.useEffect(()=>()=>H.dispose(),[H]),f.useEffect(()=>{if(!it)return;const r=setInterval(()=>{const o=[];f.Children.forEach(ye,h=>{var a;if(!f.isValidElement(h))return;const m=(a=h.type)==null?void 0:a.displayName;m==="TodayMarker"?o.push(Wt(h.props)):m==="CustomMarker"&&o.push(Bt(h.props))}),Ye.current=o,H.markDirty("overlay")},it);return()=>clearInterval(r)},[it,ye,H]),f.useEffect(()=>{W.current.update({canvasWidth:Te,canvasHeight:ke,sidebarWidth:c,lineHeight:u,groupCount:n.length,groupHeights:Ce}),H.markAllDirty()},[Te,ke,c,u,n.length,Ce,H]),f.useEffect(()=>{H.markDirty("grid"),H.markDirty("items")},[s,n,Je,be,E,_,Qe,Fe,H]);const Ve=f.useMemo(()=>{var r;return((r=e.highlights)==null?void 0:r.map(o=>`${o.start}|${o.end}|${o.color}|${o.label??""}|${o.opacity??""}`).join(";"))??""},[e.highlights]),wt=f.useRef(Ve);f.useEffect(()=>{Ve!==wt.current&&(wt.current=Ve,H.markDirty("grid"))},[Ve,H]);const Ht=f.useRef($e);f.useEffect(()=>{$e!==Ht.current&&(Ht.current=$e,H.markDirty("overlay"))},[$e,H]);const Rt=f.useRef(e.visibleTimeStart),It=f.useRef(e.visibleTimeEnd);e.visibleTimeStart!==void 0&&e.visibleTimeStart!==Rt.current&&(Rt.current=e.visibleTimeStart,W.current.update({visibleTimeStart:e.visibleTimeStart}),H.markAllDirty()),e.visibleTimeEnd!==void 0&&e.visibleTimeEnd!==It.current&&(It.current=e.visibleTimeEnd,W.current.update({visibleTimeEnd:e.visibleTimeEnd}),H.markAllDirty());const je=f.useRef(null),rt=f.useCallback(r=>{je.current===null&&(je.current=setTimeout(()=>{var m,a;je.current=null;const o=W.current,h=j.current;r==="zoom"?(m=h.onZoom)==null||m.call(h,o.visibleTimeStart,o.visibleTimeEnd):(a=h.onTimeChange)==null||a.call(h,o.visibleTimeStart,o.visibleTimeEnd)},Yt))},[]);f.useEffect(()=>()=>{je.current!==null&&clearTimeout(je.current)},[]);const Ze=f.useRef(null),st=f.useMemo(()=>new Ci((r,o)=>{var h;W.current.update({visibleTimeStart:r,visibleTimeEnd:o}),(h=Ze.current)==null||h.updateBounds(r,o),H.markAllDirty(),tt(),rt("zoom")},d,l,X,x),[]);Ze.current=st;const qe=f.useCallback(r=>{const o=W.current,h=o.getTotalHeight(),m=Math.max(0,h-o.canvasHeight),a=Math.max(0,Math.min(m,o.scrollTop+r));a!==o.scrollTop&&(o.update({scrollTop:a}),H.markDirty("grid"),H.markDirty("items"),H.markDirty("overlay"),Ne(a))},[H]),Le=f.useCallback(r=>{var T,S,I;const o=W.current,h=o.canvasWidth/(o.visibleTimeEnd-o.visibleTimeStart),m=r/h,a=o.visibleTimeStart+m,p=o.visibleTimeEnd+m;o.update({visibleTimeStart:a,visibleTimeEnd:p}),(T=Ze.current)==null||T.updateBounds(a,p),H.markAllDirty(),pi.flushSync(()=>Pe()),(I=(S=j.current).onTimeChange)==null||I.call(S,a,p)},[H,Pe]);f.useEffect(()=>{const r=_e.current;if(!r)return;const o=h=>{if(h.ctrlKey||h.metaKey||h.altKey){h.preventDefault();const m=r.getBoundingClientRect(),a=(h.clientX-m.left)/m.width;st.handleWheelZoom(h,a)}else if(h.shiftKey)h.preventDefault(),Le(h.deltaY||h.deltaX);else{const m=h.deltaX;m!==0&&Math.abs(m)>Math.abs(h.deltaY)?(h.preventDefault(),Le(m)):h.deltaY!==0&&qe(h.deltaY)}};return r.addEventListener("wheel",o,{passive:!1}),()=>r.removeEventListener("wheel",o)},[st,qe,Le]);const Me=f.useRef({lastDistance:null,lastCenter:null});f.useEffect(()=>{const r=_e.current;if(!r)return;const o=(T,S)=>Math.abs(T.clientX-S.clientX),h=(T,S,I)=>(T.clientX+S.clientX)/2-I.left,m=T=>{T.touches.length===2&&(T.preventDefault(),Me.current.lastDistance=o(T.touches[0],T.touches[1]),Me.current.lastCenter=null)},a=T=>{var S;if(T.touches.length===2&&Me.current.lastDistance!==null){T.preventDefault();const I=o(T.touches[0],T.touches[1]),D=r.getBoundingClientRect(),te=h(T.touches[0],T.touches[1],D)/D.width;if(I!==0&&Me.current.lastDistance!==0){const B=Me.current.lastDistance/I,K=W.current,q=K.visibleTimeEnd-K.visibleTimeStart;let ae=q*B;ae=Math.max(X,Math.min(x,ae));const $=K.visibleTimeStart+q*te,M=$-ae*te,v=$+ae*(1-te);K.update({visibleTimeStart:M,visibleTimeEnd:v}),(S=Ze.current)==null||S.updateBounds(M,v),H.markAllDirty(),tt(),rt("zoom")}Me.current.lastDistance=I}},p=()=>{Me.current.lastDistance=null,Me.current.lastCenter=null};return r.addEventListener("touchstart",m,{passive:!1}),r.addEventListener("touchmove",a,{passive:!1}),r.addEventListener("touchend",p),()=>{r.removeEventListener("touchstart",m),r.removeEventListener("touchmove",a),r.removeEventListener("touchend",p)}},[H,tt,rt]);const li=f.useCallback(r=>{var I;const o=r.currentTarget,h=o.getBoundingClientRect(),m=r.clientX-h.left,a=r.clientY-h.top;if(et.current=m,me.current){const D=r.clientX-me.current.startX,N=r.clientY-me.current.startY;if(!we.current&&(Math.abs(D)>=Tt||Math.abs(N)>=Tt)&&(we.current=!0,o.style.cursor="grabbing",o.setPointerCapture(r.pointerId)),we.current){const te=r.clientX-me.current.lastX,B=r.clientY-me.current.lastY;me.current.lastX=r.clientX,me.current.lastY=r.clientY,Math.abs(te)>0&&Le(-te),Math.abs(B)>0&&qe(-B)}return}if(ee.isPending()){if(ee.update(m,a),ee.isActive()){const D=ee.getState();if(D&&D.mode==="move"&&j.current.canChangeGroup){const N=at(a,W.current,j.current.groups);N&&ee.setCurrentGroup(N.id)}H.markDirty("overlay")}return}j.current.showCursorLine&&H.markDirty("overlay");const p=j.current,T=Ae(m,a,W.current,p.intervalTree,p.layoutEngine,p.groups),S=T==null?void 0:T.id;if(S!==We.current&&(We.current=S,H.markDirty("items"),(I=p.onItemHover)==null||I.call(p,S??null,r.nativeEvent)),T){const D=Dt(m,T,W.current),N=p.canResize;D==="left"&&(N==="left"||N==="both")||D==="right"&&(N==="right"||N==="both")?o.style.cursor="col-resize":p.canMove?o.style.cursor="grab":o.style.cursor="default"}else o.style.cursor="default"},[ee,H,Le,qe]),ai=f.useCallback(r=>{const o=j.current,h=r.currentTarget.getBoundingClientRect(),m=r.clientX-h.left,a=r.clientY-h.top,p=Ae(m,a,W.current,o.intervalTree,o.layoutEngine,o.groups);if(!p){me.current={startX:r.clientX,startY:r.clientY,lastX:r.clientX,lastY:r.clientY},we.current=!1;return}const T=Dt(m,p,W.current),S=o.canResize;T==="left"&&(S==="left"||S==="both")?ee.startInteraction(p,"resize-left",m,a):T==="right"&&(S==="right"||S==="both")?ee.startInteraction(p,"resize-right",m,a):o.canMove&&ee.startInteraction(p,"move",m,a)},[ee]),ui=f.useCallback(r=>{var T,S,I,D,N,te;const o=r.currentTarget;if(me.current){const B=we.current;if(me.current=null,we.current=!1,o.style.cursor="default",B)return}if(ee.isActive()){const B=ee.getState(),K=W.current,q=K.canvasWidth/(K.visibleTimeEnd-K.visibleTimeStart);if(B){const ae=j.current.moveResizeValidator;if(B.mode==="move"){const $=ee.endMove(q);if($){const M=W.current,v=j.current,de=B.deltaX/q,L=M.timeToX(B.item.start_time+de),ce=M.timeToX(B.item.end_time+de),oe=(M.visibleTimeEnd-M.visibleTimeStart)*.1,O=v.intervalTree.query(M.visibleTimeStart-oe,M.visibleTimeEnd+oe),ie=dt(O,B.item.id,ue=>M.timeToX(ue));let V=$.newStartTime;const A=Ue(L,ie,8,q,v.dragSnap);if(A!==null)V=M.xToTime(A);else{const ue=Ue(ce,ie,8,q,v.dragSnap);if(ue!==null){const fe=B.item.end_time-B.item.start_time;V=M.xToTime(ue)-fe}}const J=ae?ae("move",B.item.id,V):V,se=j.current.hierarchyEngine.getMoveDelta(B.item.id,J);(S=(T=j.current).onItemMove)==null||S.call(T,B.item.id,J,$.newGroupId,se.length>0?se:void 0)}}else{const $=ee.endResize(q);if($){const M=W.current,v=j.current,de=B.deltaX/q,L=$.edge==="left"?B.item.start_time+de:B.item.end_time+de,ce=M.timeToX(L),oe=(M.visibleTimeEnd-M.visibleTimeStart)*.1,O=v.intervalTree.query(M.visibleTimeStart-oe,M.visibleTimeEnd+oe),ie=dt(O,B.item.id,ue=>M.timeToX(ue)),V=Ue(ce,ie,8,q,v.dragSnap);let A=V!==null?M.xToTime(V):$.newTime;const J=j.current.hierarchyEngine.getResizeConstraint(B.item.id,$.edge);$.edge==="left"&&A>J.max?A=J.max:$.edge==="right"&&A<J.min&&(A=J.min);const se=ae?ae("resize",B.item.id,A,$.edge):A;(D=(I=j.current).onItemResize)==null||D.call(I,B.item.id,se,$.edge)}}}o.style.cursor="default",H.markDirty("overlay");return}ee.isPending()&&ee.cancel();const h=o.getBoundingClientRect(),m=r.clientX-h.left,a=r.clientY-h.top,p=Ae(m,a,W.current,j.current.intervalTree,j.current.layoutEngine,j.current.groups);p&&((te=(N=j.current).onItemClick)==null||te.call(N,p.id,r.nativeEvent))},[ee,H]),ci=f.useCallback(r=>{var T,S;const o=r.currentTarget.getBoundingClientRect(),h=r.clientX-o.left,m=r.clientY-o.top,a=j.current,p=Ae(h,m,W.current,a.intervalTree,a.layoutEngine,a.groups);if(p)(T=a.onItemDoubleClick)==null||T.call(a,p.id,r.nativeEvent);else{const I=at(m,W.current,a.groups),D=W.current.xToTime(h);I&&((S=a.onCanvasDoubleClick)==null||S.call(a,I.id,D))}},[]),di=f.useCallback(r=>{var T,S;r.preventDefault();const o=r.currentTarget.getBoundingClientRect(),h=r.clientX-o.left,m=r.clientY-o.top,a=j.current,p=Ae(h,m,W.current,a.intervalTree,a.layoutEngine,a.groups);if(p)(T=a.onItemContextMenu)==null||T.call(a,p.id,r.nativeEvent);else{const I=at(m,W.current,a.groups),D=W.current.xToTime(h);I&&((S=a.onCanvasContextMenu)==null||S.call(a,I.id,D,r.nativeEvent))}},[]),fi=f.useCallback(()=>{var r,o;me.current=null,we.current=!1,et.current=null,_e.current&&(_e.current.style.cursor="default"),We.current!==void 0&&(We.current=void 0,H.markDirty("items"),(o=(r=j.current).onItemHover)==null||o.call(r,null,new PointerEvent("pointerleave"))),j.current.showCursorLine&&H.markDirty("overlay")},[H]),hi=f.useMemo(()=>{const r=[];return f.Children.forEach(ye,o=>{var m;if(!f.isValidElement(o))return;if(((m=o.type)==null?void 0:m.displayName)==="TimelineHeaders"){const a=o.props;r.push(f.cloneElement(o,{visibleTimeStart:a.visibleTimeStart??kt,visibleTimeEnd:a.visibleTimeEnd??Mt,canvasWidth:a.canvasWidth??Te,sidebarWidth:a.sidebarWidth??c,theme:a.theme??be,onZoomToInterval:a.onZoomToInterval??((p,T)=>{var S,I,D,N;W.current.update({visibleTimeStart:p,visibleTimeEnd:T}),H.markAllDirty(),Pe(),(I=(S=j.current).onTimeChange)==null||I.call(S,p,T),(N=(D=j.current).onZoom)==null||N.call(D,p,T)})}))}}),r},[ye,kt,Mt,Te,c,be,H,Pe]),Pt=f.useRef(!1);f.useEffect(()=>{Pt.current||(Pt.current=!0,H.markAllDirty())},[H]),f.useImperativeHandle(t,()=>({captureToCanvas({timeStart:r,timeEnd:o,scale:h,sidebarWidth:m}){const a=j.current,p=28,T=p*3,S=a.groups.map(L=>a.layoutEngine.getGroupHeight(L.id)),I=[0];for(let L=0;L<S.length;L++)I.push(I[L]+S[L]);const D=I[S.length],N=W.current,te=a.canvasWidth/(N.visibleTimeEnd-N.visibleTimeStart),B=o-r,K=Math.max(a.canvasWidth,Math.round(B*te)),q=(m+K)*h,ae=(T+D)*h,$=document.createElement("canvas");$.width=q,$.height=ae;const M=$.getContext("2d");M.scale(h,h);for(let L=0;L<a.groups.length;L++){const ce=a.groups[L],oe=S[L],O=T+I[L];if(a.rowStyle){const J=a.rowStyle(ce);J!=null&&J.backgroundColor&&(M.fillStyle=J.backgroundColor,M.fillRect(0,O,m,oe))}const ie=ce.type;let V="400",A=8;ie==="project"?V="700":ie==="CAG"?V="600":ie==="CA"&&(V="400",A=24),M.fillStyle="#111",M.font=`${V} 12px sans-serif`,M.textBaseline="middle",M.fillText(ce.title,A,O+oe/2,m-A-4)}const v=(L,ce,oe)=>{var V,A;M.fillStyle=((V=a.theme.header)==null?void 0:V.bg)??"#f5f5f5",M.fillRect(m,L,K,p),M.strokeStyle=((A=a.theme.grid)==null?void 0:A.line)??"#e0e0e0",M.lineWidth=1,M.strokeRect(m,L,K,p);let O=he(r).startOf(oe);O.valueOf()<r&&(O=O.add(1,oe));const ie=K/(o-r);for(;O.valueOf()<o;){const J=O.add(1,oe),se=m+(O.valueOf()-r)*ie,fe=m+(Math.min(J.valueOf(),o)-r)*ie-se;M.beginPath(),M.moveTo(se,L),M.lineTo(se,L+p),M.stroke(),M.fillStyle="#333",M.font="600 11px sans-serif",M.textBaseline="middle",M.textAlign="center",M.fillText(ce(O),se+fe/2,L+p/2,fe-4),O=J}M.textAlign="start"};v(0,L=>L.format("YYYY"),"year"),v(p,L=>L.format("MM"),"month"),v(p*2,L=>String(L.isoWeek()),"week");const de=new lt({visibleTimeStart:r,visibleTimeEnd:o,canvasWidth:K,canvasHeight:D,sidebarWidth:0,lineHeight:a.lineHeight,groupCount:a.groups.length,buffer:1,scrollTop:0,groupHeights:S});return M.save(),M.translate(m,T),M.beginPath(),M.rect(0,0,K,D),M.clip(),De.draw(M,de,a.groups,a.theme,a.dayStyle,a.rowStyle,a.highlights),Oe.draw(M,de,a.groups,a.items,a.intervalTree,a.layoutEngine,a.itemRenderer,a.groupRenderer,a.theme,a.selected,void 0,a.dependencies,a.summaryRenderer,a.hierarchyEngine),Xe.draw(M,de,a.theme,{cursorX:null,snapX:null,markers:Ye.current,interaction:null}),M.restore(),$}}),[De,Oe,Xe]),f.useEffect(()=>{const r={captureToCanvas({timeStart:o,timeEnd:h,scale:m,sidebarWidth:a}){var oe;const p=j.current,T=28,S=T*3,I=p.groups.map(O=>p.layoutEngine.getGroupHeight(O.id)),D=[0];for(let O=0;O<I.length;O++)D.push(D[O]+I[O]);const N=D[I.length],te=W.current,B=p.canvasWidth/(te.visibleTimeEnd-te.visibleTimeStart),K=h-o,q=Math.max(p.canvasWidth,Math.round(K*B)),ae=a+q,$=S+N,M=document.createElement("canvas");M.width=ae*m,M.height=$*m;const v=M.getContext("2d");v.scale(m,m),v.fillStyle="#FFFFFF",v.fillRect(0,0,ae,$),v.save(),v.beginPath(),v.rect(0,0,a,$),v.clip(),v.fillStyle="#F9FAFB",v.fillRect(0,0,a,S),v.strokeStyle="#E5E7EB",v.lineWidth=1,v.strokeRect(0,0,a,S);for(let O=0;O<p.groups.length;O++){const ie=p.groups[O],V=I[O],A=S+D[O],J=(oe=p.rowStyle)==null?void 0:oe.call(p,ie);v.fillStyle=(J==null?void 0:J.backgroundColor)??(O%2===0?"#FFFFFF":"#F7F7F7"),v.fillRect(0,A,a,V),v.strokeStyle="#E5E5E5",v.lineWidth=.5,v.beginPath(),v.moveTo(0,A+V),v.lineTo(a,A+V),v.stroke();const se=ie.type??"";let ue=8,fe="400",He=11;se==="project"?(fe="700",He=12):se==="control_area_group"?fe="600":se==="control_area"&&(ue=24),v.fillStyle="#374151",v.font=`${fe} ${He}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,v.textBaseline="middle";const gi=typeof ie.title=="string"?ie.title:String(ie.title);v.fillText(gi,ue,A+V/2,a-ue-8)}v.strokeStyle="#E5E7EB",v.lineWidth=1,v.beginPath(),v.moveTo(a,0),v.lineTo(a,$),v.stroke(),v.restore(),v.save(),v.beginPath(),v.rect(a,0,q,S),v.clip();const de=h-o,L=[{unit:"year",row:0},{unit:"month",row:1},{unit:"week",row:2}];for(const{unit:O,row:ie}of L){const V=ie*T;v.fillStyle="#F9FAFB",v.fillRect(a,V,q,T);let A=he(o).startOf(O);const J=he(h).add(1,O);for(;A.isBefore(J);){const se=A.add(1,O),ue=a+(A.valueOf()-o)/de*q,fe=(se.valueOf()-A.valueOf())/de*q;v.strokeStyle="#E5E7EB",v.lineWidth=.5,v.strokeRect(ue,V,fe,T);let He;O==="year"?He=A.format("YYYY"):O==="month"?He=A.format("MM"):He=`${A.week()}`,v.fillStyle="#6c737f",v.font=O==="year"?'600 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif':'400 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',v.textBaseline="middle",v.textAlign="center",fe>20&&v.fillText(He,ue+fe/2,V+T/2),A=se}}v.textAlign="start",v.restore(),v.save(),v.beginPath(),v.rect(a,S,q,N),v.clip(),v.translate(a,S);const ce=new lt({visibleTimeStart:o,visibleTimeEnd:h,canvasWidth:q,canvasHeight:N,sidebarWidth:0,lineHeight:p.lineHeight,groupCount:p.groups.length,buffer:1,scrollTop:0,groupHeights:I});return De.draw(v,ce,p.groups,p.theme,p.dayStyle,p.rowStyle,p.highlights),Oe.draw(v,ce,p.groups,p.items,p.intervalTree,p.layoutEngine,p.itemRenderer,p.groupRenderer,p.theme,p.selected,void 0,p.dependencies,p.summaryRenderer,p.hierarchyEngine),Xe.draw(v,ce,p.theme,{cursorX:null,markers:Ye.current}),v.restore(),M}};Ge==null||Ge(r)},[Ge,De,Oe,Xe]);const mi={position:"relative",width:Te,height:ke,overflow:"hidden",cursor:"default"},ot={position:"absolute",top:0,left:0};return Z.jsxs("div",{ref:yt,style:{display:"flex",flexDirection:"column",width:"100%",position:"relative"},children:[Kt?Z.jsxs("div",{style:{position:"absolute",top:0,left:0,zIndex:9999,padding:"2px 6px",fontSize:10,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:1.4,color:"#fff",background:"rgba(17, 24, 39, 0.78)",borderBottomRightRadius:4,pointerEvents:"none",userSelect:"none"},children:["v","0.5.0"," · ","15:09:31"]}):null,hi,Z.jsxs("div",{ref:Qt,style:{display:"flex",overflow:"hidden"},children:[Z.jsx(Ft,{groups:n,width:c,lineHeight:u,groupHeights:Ce,scrollTop:St,canvasHeight:ke,theme:be,groupRenderer:Y,onScroll:r=>{W.current.update({scrollTop:r}),H.markDirty("grid"),H.markDirty("items"),H.markDirty("overlay"),Ne(r)}}),Z.jsxs("div",{ref:_e,style:mi,onPointerMove:li,onPointerDown:ai,onPointerUp:ui,onDoubleClick:ci,onContextMenu:di,onPointerLeave:fi,children:[Z.jsx("canvas",{ref:pt,style:{...ot,zIndex:0}}),Z.jsx("canvas",{ref:bt,style:{...ot,zIndex:1}}),Z.jsx("canvas",{ref:vt,style:{...ot,zIndex:2}})]}),Ke&&mt?Z.jsx(Ft,{groups:n,width:Ke,lineHeight:u,groupHeights:Ce,scrollTop:St,canvasHeight:ke,theme:be,groupRenderer:mt,onScroll:r=>{W.current.update({scrollTop:r}),H.markDirty("grid"),H.markDirty("items"),H.markDirty("overlay"),Ne(r)}}):null]})]})}));function $t({children:i,theme:e,className:t,classNames:n,style:s,visibleTimeStart:d,visibleTimeEnd:l,canvasWidth:c,sidebarWidth:u=0,onZoomToInterval:b}){const C=f.Children.map(i,g=>{var k;if(!f.isValidElement(g))return g;if(((k=g.type)==null?void 0:k.displayName)==="DateHeader"){const R=g.props,X=f.cloneElement(g,{visibleTimeStart:R.visibleTimeStart??d,visibleTimeEnd:R.visibleTimeEnd??l,canvasWidth:R.canvasWidth??c,theme:R.theme??e,onZoomToInterval:R.onIntervalClick??R.onZoomToInterval??b});return Z.jsxs("div",{style:{display:"flex"},children:[Z.jsx("div",{style:{width:u,flexShrink:0}}),Z.jsx("div",{style:{flex:1,overflow:"hidden"},children:X})]})}return g});return Z.jsx("div",{className:t,style:{position:"sticky",top:0,zIndex:20,display:"flex",flexDirection:"column",backgroundColor:(e==null?void 0:e.header.bg)??"#F9FAFB",borderTop:`1px solid ${(e==null?void 0:e.header.border)??"#E5E7EB"}`,borderBottom:`1px solid ${(e==null?void 0:e.header.border)??"#E5E7EB"}`,...s},children:C})}$t.displayName="TimelineHeaders";var Vt={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(At,function(){var t="week",n="year";return function(s,d,l){var c=d.prototype;c.week=function(u){if(u===void 0&&(u=null),u!==null)return this.add(7*(u-this.week()),"day");var b=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var C=l(this).startOf(n).add(1,n).date(b),g=l(this).endOf(t);if(C.isBefore(g))return 1}var y=l(this).startOf(n).date(b).startOf(t).subtract(1,"millisecond"),k=this.diff(y,t,!0);return k<0?l(this).startOf("week").week():Math.ceil(k)},c.weeks=function(u){return u===void 0&&(u=null),this.week(u)}}})})(Vt);var Xi=Vt.exports;const _i=xt(Xi);he.extend(_i);const Fi={year:30,month:30,week:20,day:15,hour:30};function Zt({unit:i,visibleTimeStart:e=0,visibleTimeEnd:t=0,canvasWidth:n=0,theme:s,height:d=28,className:l,labelFormat:c,onIntervalClick:u,minCellWidth:b,onZoomToInterval:C}){const g=f.useMemo(()=>{if(!e||!t||!n)return[];const k=t-e,R=b??Fi[i];if(R>0){const E=he(e).startOf(i);if((E.add(1,i).valueOf()-E.valueOf())/k*n<R)return[]}const X=[];let x=he(e).startOf(i).subtract(1,i);const ne=he(t).add(2,i).valueOf();for(;x.valueOf()<ne;){const E=x.add(1,i),_=x.valueOf(),w=E.valueOf(),P=(_-e)/k*n,z=(w-_)/k*n,Y=Wi(x,E,i,c);X.push({start:_,end:w,label:Y,left:P,width:z}),x=E}return X},[e,t,n,i,c,b]),y=f.useCallback((k,R)=>{u?u(k,R):C&&C(k,R)},[u,C]);return g.length===0?null:Z.jsx("div",{style:{display:"flex",position:"relative",height:d,overflow:"hidden"},children:g.map(k=>Z.jsx("div",{className:l,onClick:()=>y(k.start,k.end),style:{position:"absolute",left:k.left,width:k.width,height:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderRight:`1px solid ${(s==null?void 0:s.header.border)??"#E5E7EB"}`,borderBottom:`1px solid ${(s==null?void 0:s.header.border)??"#E5E7EB"}`,fontSize:12,color:(s==null?void 0:s.header.text)??"#6c737f",backgroundColor:(s==null?void 0:s.header.bg)??"#F9FAFB",overflow:"hidden",whiteSpace:"nowrap",cursor:"pointer",userSelect:"none",padding:"0 4px",boxSizing:"border-box"},children:Z.jsx("span",{children:k.label})},k.start))})}Zt.displayName="DateHeader";function Wi(i,e,t,n,s){return typeof n=="function"?n(i.toDate(),e.toDate(),t):typeof n=="string"?i.format(n):Bi(i,t)}function Bi(i,e){switch(e){case"year":return i.format("YYYY");case"month":return i.format("MM");case"week":return`${i.week()}`;case"day":return i.format("D");case"hour":return i.format("HH:mm")}}function qt({width:i,children:e,style:t}){const n=()=>({style:{width:i,...t}});return e?Z.jsx(Z.Fragment,{children:e({getRootProps:n})}):Z.jsx("div",{style:{width:i}})}qt.displayName="SidebarHeader";function Ut({children:i}){return Z.jsx(Z.Fragment,{children:i})}Ut.displayName="CustomHeader";exports.CanvasTimeline=Oi;exports.CustomHeader=Ut;exports.CustomMarker=zt;exports.DEFAULT_THEME=ve;exports.DateHeader=Zt;exports.HierarchyEngine=jt;exports.SidebarHeader=qt;exports.TimelineHeaders=$t;exports.TodayMarker=Nt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),f=require("react"),Ei=require("react-dom"),$e=require("dayjs"),Te={primary:"#269bf7",trainColors:{},status:{red:"#EF5350",yellow:"#FBBF24",green:"#31c48d"},grid:{line:"#E5E5E5",rowAlt:"#F7F7F7",weekend:"rgba(0,0,0,0.03)"},item:{radius:3,text:"#374151",selectedRing:"#a3a3a3"},marker:{today:"#FD7171",milestone:"#3B82F6",cursor:"#269bf7"},sidebar:{bg:"#F9FAFB",border:"#E5E7EB",text:"#6c737f"},header:{bg:"#F9FAFB",border:"#E5E7EB",text:"#6c737f"}};class ht{constructor(e){Object.defineProperty(this,"visibleTimeStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleTimeEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"canvasWidth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"canvasHeight",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sidebarWidth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"lineHeight",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"groupCount",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"scrollTop",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"groupHeights",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleDuration",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pixelsPerMs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"groupYOffsets",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.visibleTimeStart=e.visibleTimeStart,this.visibleTimeEnd=e.visibleTimeEnd,this.canvasWidth=e.canvasWidth,this.canvasHeight=e.canvasHeight,this.sidebarWidth=e.sidebarWidth,this.lineHeight=e.lineHeight,this.groupCount=e.groupCount,this.buffer=e.buffer,this.scrollTop=e.scrollTop,this.groupHeights=e.groupHeights??null,this.visibleDuration=this.visibleTimeEnd-this.visibleTimeStart,this.pixelsPerMs=this.canvasWidth/this.visibleDuration,this.groupYOffsets=[],this.recomputeGroupYOffsets()}update(e){e.visibleTimeStart!==void 0&&(this.visibleTimeStart=e.visibleTimeStart),e.visibleTimeEnd!==void 0&&(this.visibleTimeEnd=e.visibleTimeEnd),e.canvasWidth!==void 0&&(this.canvasWidth=e.canvasWidth),e.canvasHeight!==void 0&&(this.canvasHeight=e.canvasHeight),e.sidebarWidth!==void 0&&(this.sidebarWidth=e.sidebarWidth),e.lineHeight!==void 0&&(this.lineHeight=e.lineHeight),e.groupCount!==void 0&&(this.groupCount=e.groupCount),e.buffer!==void 0&&(this.buffer=e.buffer),e.scrollTop!==void 0&&(this.scrollTop=e.scrollTop),e.groupHeights!==void 0&&(this.groupHeights=e.groupHeights??null),this.visibleDuration=this.visibleTimeEnd-this.visibleTimeStart,this.pixelsPerMs=this.canvasWidth/this.visibleDuration,this.recomputeGroupYOffsets()}recomputeGroupYOffsets(){var t;const e=new Array(this.groupCount+1);e[0]=0;for(let n=0;n<this.groupCount;n++){const s=((t=this.groupHeights)==null?void 0:t[n])??this.lineHeight;e[n+1]=e[n]+s}this.groupYOffsets=e}timeToX(e){return(e-this.visibleTimeStart)*this.pixelsPerMs}xToTime(e){return this.visibleTimeStart+e/this.pixelsPerMs}yToGroupIndex(e){if(this.groupCount===0)return 0;const t=e+this.scrollTop;if(t<=0)return 0;if(t>=this.groupYOffsets[this.groupCount])return this.groupCount-1;let n=0,s=this.groupCount-1;for(;n<s;){const d=n+s>>>1;this.groupYOffsets[d+1]>t?s=d:n=d+1}return n}groupIndexToY(e){return e<0?-this.scrollTop:e>=this.groupCount?(this.groupYOffsets[this.groupCount]??0)-this.scrollTop:this.groupYOffsets[e]-this.scrollTop}groupIndexToHeight(e){var t;return e<0||e>=this.groupCount?this.lineHeight:((t=this.groupHeights)==null?void 0:t[e])??this.lineHeight}getBufferBounds(){const e=this.visibleDuration*1.5;return{bufferStart:this.visibleTimeStart-e,bufferEnd:this.visibleTimeEnd+e}}getVisibleGroupRange(){if(this.groupCount===0)return{firstVisible:0,lastVisible:-1};const e=this.yToGroupIndex(0),t=this.yToGroupIndex(this.canvasHeight);return{firstVisible:e,lastVisible:t}}isScrollInBuffer(e){const t=this.visibleDuration*1.5*this.pixelsPerMs;return Math.abs(e)<t}getTotalHeight(){return this.groupYOffsets[this.groupCount]??0}}class wi{constructor(){Object.defineProperty(this,"root",{enumerable:!0,configurable:!0,writable:!0,value:null})}buildFromItems(e,t,n){const s=e.map(d=>({item:d,start:t(d),end:n(d)}));this.root=this.buildNode(s)}buildNode(e){if(e.length===0)return null;let t=1/0,n=-1/0;for(const l of e)l.start<t&&(t=l.start),l.end>n&&(n=l.end);const s=(t+n)/2,d=[],o=[],c=[];for(const l of e)l.end<s?d.push(l):l.start>s?o.push(l):c.push(l);return{center:s,left:this.buildNode(d),right:this.buildNode(o),overlapping:c}}query(e,t){const n=[];return this.queryNode(this.root,e,t,n),n}queryNode(e,t,n,s){if(e!==null){for(const d of e.overlapping)d.start<=n&&d.end>=t&&s.push(d.item);t<=e.center&&e.left!==null&&this.queryNode(e.left,t,n,s),n>=e.center&&e.right!==null&&this.queryNode(e.right,t,n,s)}}}class Hi{constructor(e,t){Object.defineProperty(this,"lineHeight",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"itemHeightRatio",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"layoutCache",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"groupMaxStack",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),this.lineHeight=e,this.itemHeightRatio=t}computeLayout(e,t,n){this.layoutCache=new Map,this.groupMaxStack=new Map;const s=this.lineHeight*this.itemHeightRatio,d=s*.6;if(!t){for(const c of e){const l=(n==null?void 0:n.isParent(c.id))??!1;this.layoutCache.set(c.id,{stackLevel:0,itemHeight:l?d:s}),this.groupMaxStack.set(c.group,0)}return this.layoutCache}const o=new Map;for(const c of e){let l=o.get(c.group);l||(l=[],o.set(c.group,l)),l.push(c)}for(const[c,l]of o)n?this.computeHierarchyLayout(l,n,s,d,c):this.computeFlatLayout(l,s,c);return this.layoutCache}computeFlatLayout(e,t,n){e.sort((o,c)=>{const l=o.start_time-c.start_time;return l!==0?l:c.end_time-c.start_time-(o.end_time-o.start_time)});const s=[];let d=0;for(const o of e){let c=-1;for(let l=0;l<s.length;l++)if(s[l]<=o.start_time){c=l;break}c===-1?(c=s.length,s.push(o.end_time)):s[c]=o.end_time,c>d&&(d=c),this.layoutCache.set(o.id,{stackLevel:c,itemHeight:t})}this.groupMaxStack.set(n,d)}computeHierarchyLayout(e,t,n,s,d){const o=[],c=[];for(const v of e)t.isParent(v.id)?c.push(v):o.push(v);o.sort((v,h)=>{const k=v.start_time-h.start_time;return k!==0?k:h.end_time-h.start_time-(v.end_time-v.start_time)});const l=[];let y=0;for(const v of o){let h=-1;for(let k=0;k<l.length;k++)if(l[k]<=v.start_time){h=k;break}h===-1?(h=l.length,l.push(v.end_time)):l[h]=v.end_time,h>y&&(y=h),this.layoutCache.set(v.id,{stackLevel:h,itemHeight:n})}c.sort((v,h)=>t.getNestingDepth(h.id)-t.getNestingDepth(v.id));let R=o.length>0?y+1:0;for(const v of c)this.layoutCache.set(v.id,{stackLevel:R,itemHeight:s}),R>y&&(y=R),R++;this.groupMaxStack.set(d,y)}getLayout(e){return this.layoutCache.get(e)}getGroupHeight(e){return((this.groupMaxStack.get(e)??0)+1)*this.lineHeight}}class Zt{constructor(){Object.defineProperty(this,"parentToChildren",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"childToParent",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"itemMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"depthCache",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}rebuild(e){this.parentToChildren=new Map,this.childToParent=new Map,this.itemMap=new Map,this.depthCache=new Map;for(const t of e)this.itemMap.set(t.id,t);for(const t of e)if(t.parentId!==void 0&&this.itemMap.has(t.parentId)){this.childToParent.set(t.id,t.parentId);let n=this.parentToChildren.get(t.parentId);n||(n=[],this.parentToChildren.set(t.parentId,n)),n.push(t.id)}for(const t of this.childToParent.keys()){const n=new Set;let s=t;for(;s!==void 0;){if(n.has(s)){const d=this.childToParent.get(t);this.childToParent.delete(t);const o=this.parentToChildren.get(d);if(o){const c=o.indexOf(t);c!==-1&&o.splice(c,1),o.length===0&&this.parentToChildren.delete(d)}break}n.add(s),s=this.childToParent.get(s)}}}isParent(e){const t=this.parentToChildren.get(e);return t!==void 0&&t.length>0}getParent(e){return this.childToParent.get(e)}getChildren(e){return this.parentToChildren.get(e)??[]}getDescendants(e){const t=[],n=[...this.getChildren(e)];for(;n.length>0;){const s=n.pop();t.push(s);const d=this.parentToChildren.get(s);d&&n.push(...d)}return t}getEffectiveSpan(e){const t=this.itemMap.get(e);if(!t)return{start:0,end:0};let n=t.start_time,s=t.end_time;const d=this.getDescendants(e);for(const o of d){const c=this.itemMap.get(o);c&&(c.start_time<n&&(n=c.start_time),c.end_time>s&&(s=c.end_time))}return{start:n,end:s}}getNestingDepth(e){const t=this.depthCache.get(e);if(t!==void 0)return t;let n=0,s=this.childToParent.get(e);for(;s!==void 0;)n++,s=this.childToParent.get(s);return this.depthCache.set(e,n),n}getMoveDelta(e,t){const n=this.itemMap.get(e);if(!n)return[];const s=t-n.start_time;return this.getDescendants(e).map(o=>{const c=this.itemMap.get(o);return{itemId:o,newStart:c.start_time+s}})}getResizeConstraint(e,t){const n=this.getDescendants(e);if(n.length===0)return t==="left"?{min:-1/0,max:1/0}:{min:-1/0,max:1/0};if(t==="left"){let s=1/0;for(const d of n){const o=this.itemMap.get(d);o&&o.start_time<s&&(s=o.start_time)}return{min:-1/0,max:s}}else{let s=-1/0;for(const d of n){const o=this.itemMap.get(d);o&&o.end_time>s&&(s=o.end_time)}return{min:s,max:1/0}}}}function Ri(i,e,t,n,s,d){const{x:o,y:c,width:l,height:y}=t,R=d.primary;i.globalAlpha=.15,i.fillStyle=R,i.fillRect(o,c,l,y),i.globalAlpha=1,i.strokeStyle=R,i.lineWidth=1.5,i.strokeRect(o,c,l,y);const v=Math.min(y*.5,6),h=c+y/2;i.fillStyle=R,i.beginPath(),i.moveTo(o,h),i.lineTo(o+v,h-v),i.lineTo(o+v*2,h),i.lineTo(o+v,h+v),i.closePath(),i.fill(),i.beginPath(),i.moveTo(o+l,h),i.lineTo(o+l-v,h-v),i.lineTo(o+l-v*2,h),i.lineTo(o+l-v,h+v),i.closePath(),i.fill();const k=e.title;if(k&&l>30){i.fillStyle=d.item.text,i.font='500 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',i.textBaseline="middle";const S=i.measureText(k).width,m=l-v*4-4;if(m>20){const H=S>m?k.slice(0,Math.floor(k.length*m/S))+"...":k;i.fillText(H,o+l/2-Math.min(S,m)/2,h)}}n.selected&&(i.strokeStyle=d.item.selectedRing,i.lineWidth=2,i.strokeRect(o-1,c-1,l+2,y+2))}function ze(i,e,t,n,s,d){const o=t.xToTime(i),c=new Map;for(let v=0;v<d.length;v++)c.set(d[v].id,v);const l=n.query(o,o);let y=null,R=-1/0;for(const v of l){const h=c.get(v.group);if(h===void 0)continue;const k=s.getLayout(v.id);if(!k)continue;const S=t.timeToX(v.start_time),m=t.timeToX(v.end_time)-S;if(i<S||i>S+m)continue;const X=t.groupIndexToY(h)+k.stackLevel*t.lineHeight+(t.lineHeight-k.itemHeight)/2,x=k.itemHeight;e<X||e>X+x||X>R&&(R=X,y=v)}return y}function mt(i,e,t){const n=e.yToGroupIndex(i);return t[n]??null}function xt(i,e,t,n=6){const s=t.timeToX(e.start_time),d=t.timeToX(e.end_time);return i-s<=n?"left":d-i<=n?"right":"body"}function gt(i,e,t){const n=window.devicePixelRatio||1,s=Math.round(e*n),d=Math.round(t*n);(i.width!==s||i.height!==d)&&(i.width=s,i.height=d,i.style.width=`${e}px`,i.style.height=`${t}px`);const o=i.getContext("2d");return o.setTransform(n,0,0,n,0,0),o}function pt(i,e){const t=window.devicePixelRatio||1;i.clearRect(0,0,e.width/t,e.height/t)}class Di{constructor(e){Object.defineProperty(this,"dirty",{enumerable:!0,configurable:!0,writable:!0,value:{grid:!1,items:!1,overlay:!1}}),Object.defineProperty(this,"rafId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"drawCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.drawCallback=e}markDirty(e){this.dirty[e]=!0,this.schedule()}markAllDirty(){this.dirty.grid=!0,this.dirty.items=!0,this.dirty.overlay=!0,this.schedule()}dispose(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}schedule(){this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null;const e={...this.dirty};this.dirty.grid=!1,this.dirty.items=!1,this.dirty.overlay=!1,this.drawCallback(e)}))}}var tt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function it(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Ut={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(tt,function(){var t="minute",n=/[+-]\d\d(?::?\d\d)?/g,s=/([+-]|\d\d)/g;return function(d,o,c){var l=o.prototype;c.utc=function(m){var H={date:m,utc:!0,args:arguments};return new o(H)},l.utc=function(m){var H=c(this.toDate(),{locale:this.$L,utc:!0});return m?H.add(this.utcOffset(),t):H},l.local=function(){return c(this.toDate(),{locale:this.$L,utc:!1})};var y=l.parse;l.parse=function(m){m.utc&&(this.$u=!0),this.$utils().u(m.$offset)||(this.$offset=m.$offset),y.call(this,m)};var R=l.init;l.init=function(){if(this.$u){var m=this.$d;this.$y=m.getUTCFullYear(),this.$M=m.getUTCMonth(),this.$D=m.getUTCDate(),this.$W=m.getUTCDay(),this.$H=m.getUTCHours(),this.$m=m.getUTCMinutes(),this.$s=m.getUTCSeconds(),this.$ms=m.getUTCMilliseconds()}else R.call(this)};var v=l.utcOffset;l.utcOffset=function(m,H){var X=this.$utils().u;if(X(m))return this.$u?0:X(this.$offset)?v.call(this):this.$offset;if(typeof m=="string"&&(m=function(C){C===void 0&&(C="");var F=C.match(n);if(!F)return null;var B=(""+F[0]).match(s)||["-",0,0],I=B[0],A=60*+B[1]+ +B[2];return A===0?0:I==="+"?A:-A}(m),m===null))return this;var x=Math.abs(m)<=16?60*m:m;if(x===0)return this.utc(H);var T=this.clone();if(H)return T.$offset=x,T.$u=!1,T;var D=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(T=this.local().add(x+D,t)).$offset=x,T.$x.$localOffset=D,T};var h=l.format;l.format=function(m){var H=m||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,H)},l.valueOf=function(){var m=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*m},l.isUTC=function(){return!!this.$u},l.toISOString=function(){return this.toDate().toISOString()},l.toString=function(){return this.toDate().toUTCString()};var k=l.toDate;l.toDate=function(m){return m==="s"&&this.$offset?c(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():k.call(this)};var S=l.diff;l.diff=function(m,H,X){if(m&&this.$u===m.$u)return S.call(this,m,H,X);var x=this.local(),T=c(m).local();return S.call(x,T,H,X)}}})})(Ut);var Ii=Ut.exports;const Oi=it(Ii);var Vt={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(tt,function(){var t={year:0,month:1,day:2,hour:3,minute:4,second:5},n={};return function(s,d,o){var c,l=function(h,k,S){S===void 0&&(S={});var m=new Date(h),H=function(X,x){x===void 0&&(x={});var T=x.timeZoneName||"short",D=X+"|"+T,C=n[D];return C||(C=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:X,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:T}),n[D]=C),C}(k,S);return H.formatToParts(m)},y=function(h,k){for(var S=l(h,k),m=[],H=0;H<S.length;H+=1){var X=S[H],x=X.type,T=X.value,D=t[x];D>=0&&(m[D]=parseInt(T,10))}var C=m[3],F=C===24?0:C,B=m[0]+"-"+m[1]+"-"+m[2]+" "+F+":"+m[4]+":"+m[5]+":000",I=+h;return(o.utc(B).valueOf()-(I-=I%1e3))/6e4},R=d.prototype;R.tz=function(h,k){h===void 0&&(h=c);var S,m=this.utcOffset(),H=this.toDate(),X=H.toLocaleString("en-US",{timeZone:h}),x=Math.round((H-new Date(X))/1e3/60),T=15*-Math.round(H.getTimezoneOffset()/15)-x;if(!Number(T))S=this.utcOffset(0,k);else if(S=o(X,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(T,!0),k){var D=S.utcOffset();S=S.add(m-D,"minute")}return S.$x.$timezone=h,S},R.offsetName=function(h){var k=this.$x.$timezone||o.tz.guess(),S=l(this.valueOf(),k,{timeZoneName:h}).find(function(m){return m.type.toLowerCase()==="timezonename"});return S&&S.value};var v=R.startOf;R.startOf=function(h,k){if(!this.$x||!this.$x.$timezone)return v.call(this,h,k);var S=o(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return v.call(S,h,k).tz(this.$x.$timezone,!0)},o.tz=function(h,k,S){var m=S&&k,H=S||k||c,X=y(+o(),H);if(typeof h!="string")return o(h).tz(H);var x=function(F,B,I){var A=F-60*B*1e3,_=y(A,I);if(B===_)return[A,B];var se=y(A-=60*(_-B)*1e3,I);return _===se?[A,_]:[F-60*Math.min(_,se)*1e3,Math.max(_,se)]}(o.utc(h,m).valueOf(),X,H),T=x[0],D=x[1],C=o(T).utcOffset(D);return C.$x.$timezone=H,C},o.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},o.tz.setDefault=function(h){c=h}}})})(Vt);var Pi=Vt.exports;const Xi=it(Pi);$e.extend(Oi);$e.extend(Xi);function pe(i,e){return e?$e(i).tz(e):$e(i)}class $i{draw(e,t,n,s,d,o,c,l){const{firstVisible:y,lastVisible:R}=t.getVisibleGroupRange();for(let T=y;T<=R;T++){const D=t.groupIndexToY(T),C=t.groupIndexToHeight(T),F=n[T];if(!F)continue;let B;const I=o==null?void 0:o(F);I!=null&&I.backgroundColor?B=I.backgroundColor:B=T%2===0?"#FFFFFF":s.grid.rowAlt,e.fillStyle=B,e.fillRect(0,D,t.canvasWidth,C),e.strokeStyle=(I==null?void 0:I.borderBottomColor)??s.grid.line,e.lineWidth=.5,e.beginPath(),e.moveTo(0,D+C),e.lineTo(t.canvasWidth,D+C),e.stroke()}if(c&&c.length>0)for(const T of c){const D=t.timeToX(T.start),C=t.timeToX(T.end);if(C<0||D>t.canvasWidth)continue;const F=Math.max(0,D),B=Math.min(t.canvasWidth,C)-F,I=T.opacity??.12,A=parseInt(T.color.slice(1,3),16),_=parseInt(T.color.slice(3,5),16),se=parseInt(T.color.slice(5,7),16);e.fillStyle=`rgb(${Math.round(A*I+255*(1-I))},${Math.round(_*I+255*(1-I))},${Math.round(se*I+255*(1-I))})`,e.fillRect(F,0,B,t.canvasHeight)}const v=t.visibleTimeStart,h=t.visibleTimeEnd,m=864e5/(h-v)*t.canvasWidth;let H="day";m<2?H="month":m<8&&(H="week");{let T=pe(v,l).startOf("day");const D=pe(h,l).endOf("day");let C=null,F=1,B=0;const I=[],A=_=>{C!==null&&(e.fillStyle=C,F!==1&&(e.globalAlpha=F),e.fillRect(B,0,_-B,t.canvasHeight),F!==1&&(e.globalAlpha=1),C=null,F=1)};for(;T.isBefore(D);){const _=t.timeToX(T.valueOf()),se=T.toDate(),J=d==null?void 0:d(se);let te=null,me=1;if(J!=null&&J.backgroundColor)te=J.backgroundColor,me=J.opacity??1;else{const ve=T.day();(ve===0||ve===6)&&(te=s.grid.weekend)}J!=null&&J.borderColor&&I.push({x:_,color:J.borderColor}),te===C&&me===F||(A(_),te!==null&&(C=te,F=me,B=_)),T=T.add(1,"day")}C!==null&&A(t.timeToX(T.valueOf()));for(const _ of I)e.strokeStyle=_.color,e.lineWidth=.5,e.beginPath(),e.moveTo(_.x,0),e.lineTo(_.x,t.canvasHeight),e.stroke()}let X=pe(v,l).startOf(H);const x=pe(h,l).add(1,H);for(e.strokeStyle=s.grid.line,e.lineWidth=.5,e.beginPath();X.isBefore(x);){const T=t.timeToX(X.valueOf());e.moveTo(T,0),e.lineTo(T,t.canvasHeight),X=X.add(1,H)}if(e.stroke(),c&&c.length>0)for(const T of c){const D=t.timeToX(T.start),C=t.timeToX(T.end);if(!(C<0||D>t.canvasWidth)&&(e.strokeStyle=T.color,e.globalAlpha=.4,e.lineWidth=1,e.beginPath(),D>=0&&D<=t.canvasWidth&&(e.moveTo(D,0),e.lineTo(D,t.canvasHeight)),C>=0&&C<=t.canvasWidth&&(e.moveTo(C,0),e.lineTo(C,t.canvasHeight)),e.stroke(),e.globalAlpha=1,T.label)){const F=Math.max(0,D),B=Math.min(t.canvasWidth,C)-F;e.save(),e.font='600 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';const I=e.measureText(T.label).width,A=6,_=I+A*2,se=18,J=F+(B-_)/2,te=4;e.fillStyle=T.color,e.globalAlpha=.9,e.beginPath(),e.roundRect(J,te,_,se,3),e.fill(),e.globalAlpha=1,e.fillStyle="#FFFFFF",e.textBaseline="middle",e.fillText(T.label,J+A,te+se/2),e.restore()}}}}const Bt='500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';function qt(i,e){return{roundRect(t,n,s,d,o=3){i.beginPath(),i.roundRect(t,n,s,d,o),i.fill()},fillText(t,n,s,d){if(i.font=Bt,d!==void 0&&i.measureText(t).width>d){let o=0,c=t.length;for(;o<c;){const l=Math.ceil((o+c)/2),y=t.slice(0,l)+"...";i.measureText(y).width<=d?o=l:c=l-1}i.fillText(t.slice(0,o)+"...",n,s)}else i.fillText(t,n,s)},gradient(t,n,s,d){const o=i.createLinearGradient(t,0,t+n,0);return o.addColorStop(0,s),o.addColorStop(.5,s),o.addColorStop(.5,d),o.addColorStop(1,d),o},leftBar(t,n=3){e&&(i.save(),i.fillStyle=t,i.fillRect(e.x,e.y,n,e.height),i.restore())},icon(t,n,s,d=14){i.save();const o=d/2;if(t==="check"){i.fillStyle="#31c48d",i.beginPath(),i.arc(n+o,s+o,o,0,Math.PI*2),i.fill(),i.strokeStyle="#ffffff",i.lineWidth=d*.12,i.beginPath();const c=n+o,l=s+o;i.moveTo(c-o*.45,l),i.lineTo(c-o*.1,l+o*.42),i.lineTo(c+o*.45,l-o*.35),i.stroke()}else if(t==="danger-red"||t==="danger-yellow"){const c=t==="danger-red"?"#EF5350":"#FBBF24";i.fillStyle=c,i.beginPath(),i.moveTo(n+o,s),i.lineTo(n+d,s+d),i.lineTo(n,s+d),i.closePath(),i.fill(),i.fillStyle="#ffffff";const l=d*.12,y=n+o-l/2;i.fillRect(y,s+d*.35,l,d*.35),i.beginPath(),i.arc(n+o,s+d*.82,l*.7,0,Math.PI*2),i.fill()}i.restore()},badge(t,n,s,d){i.save(),i.font=Bt;const c=i.measureText(t).width,l=8,R=12+3*2,v=c+l*2,h=R/2;i.fillStyle=d,i.beginPath(),i.roundRect(n,s,v,R,h),i.fill(),i.fillStyle="#ffffff",i.textAlign="center",i.textBaseline="middle",i.fillText(t,n+v/2,s+R/2),i.restore()}}}class Fi{draw(e,t,n,s,d,o,c,l,y,R,v,h,k,S){const m=(t.visibleTimeEnd-t.visibleTimeStart)*.1,H=t.visibleTimeStart-m,X=t.visibleTimeEnd+m,x=d.query(H,X),T=new Map;for(let I=0;I<n.length;I++)T.set(n[I].id,I);const D=new Set(R),C=new Map,F=-t.lineHeight,B=t.canvasHeight+t.lineHeight;for(const I of x){const A=T.get(I.group);if(A===void 0)continue;const _=o.getLayout(I.id);if(!_)continue;const J=t.groupIndexToY(A)+_.stackLevel*t.lineHeight+(t.lineHeight-_.itemHeight)/2,te=_.itemHeight;if(J+te<F||J>B)continue;const me=t.timeToX(I.start_time),ve=t.timeToX(I.end_time)-me,be={x:me,y:J,width:ve,height:te};C.set(I.id,be);const De={selected:D.has(I.id),hovered:v===I.id,dragging:!1,filtered:I.filtered!==!1};e.save();const Ae=qt(e,be);let Ce;k&&(S!=null&&S.isParent(I.id))?Ce=k:l&&(I.type==="control_area_group"||I.type==="construction_train")?Ce=l:Ce=c,Ce(e,I,be,De,Ae),e.restore()}if(h&&h.length>0){const I=new Set;for(const A of h)C.has(A.fromItemId)||I.add(A.fromItemId),C.has(A.toItemId)||I.add(A.toItemId);if(I.size>0){const A=new Map;for(const _ of s)I.has(_.id)&&A.set(_.id,_);for(const[_,se]of A){const J=T.get(se.group);if(J===void 0)continue;const te=o.getLayout(_);if(!te)continue;const ve=t.groupIndexToY(J)+te.stackLevel*t.lineHeight+(t.lineHeight-te.itemHeight)/2,be=t.timeToX(se.start_time),De=t.timeToX(se.end_time)-be;C.set(_,{x:be,y:ve,width:De,height:te.itemHeight})}}this.drawDependencies(e,h,C,v,y)}}drawDependencies(e,t,n,s,d){for(const o of t){const c=n.get(o.fromItemId),l=n.get(o.toItemId);if(!c||!l)continue;const y=s===o.fromItemId||s===o.toItemId;e.strokeStyle=y?d.primary:o.color??"#94A3B8",e.lineWidth=y?2:1.5,e.setLineDash([]);const R=c.x+c.width,v=c.y+c.height/2,h=l.x,k=l.y+l.height/2,S=Math.abs(h-R),m=Math.max(S*.4,30);e.beginPath(),e.moveTo(R,v),e.bezierCurveTo(R+m,v,h-m,k,h,k),e.stroke();const H=6;e.fillStyle=e.strokeStyle,e.beginPath(),e.moveTo(h,k),e.lineTo(h-H,k-H/2),e.lineTo(h-H,k+H/2),e.closePath(),e.fill()}}}class _i{draw(e,t,n,s){const{cursorX:d,snapX:o,markers:c,interaction:l}=s;if(c)for(const y of c){const R=t.timeToX(y.date);if(e.fillStyle=y.color,e.fillRect(R-y.width/2,0,y.width,t.canvasHeight),y.label){e.save(),e.font='500 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';const v=e.measureText(y.label).width,h=8,k=200,S=Math.min(v+h*2,k),m=20,H=R-S/2,X=4;e.fillStyle=y.color,e.beginPath(),e.roundRect(H,X,S,m,3),e.fill(),e.fillStyle="#FFFFFF",e.textBaseline="middle";const x=k-h*2,T=v>x?y.label.slice(0,Math.floor(y.label.length*x/v))+"…":y.label;e.fillText(T,H+h,X+m/2),e.restore()}}if(d!=null&&(e.strokeStyle=n.marker.cursor,e.lineWidth=1,e.beginPath(),e.moveTo(d,0),e.lineTo(d,t.canvasHeight),e.stroke()),o!=null&&(e.strokeStyle=n.primary,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(o,0),e.lineTo(o,t.canvasHeight),e.stroke(),e.setLineDash([])),l){l.groupChanged&&l.targetGroupY!==void 0&&(e.fillStyle="rgba(59, 130, 246, 0.08)",e.fillRect(0,l.targetGroupY,t.canvasWidth,t.lineHeight)),e.save(),e.globalAlpha=.5;const y=qt(e,l.bounds);l.renderer(e,l.item,l.bounds,{selected:!1,hovered:!1,dragging:!0,filtered:!0},y),e.restore()}}}const jt=120;function Yi(i){let e=i.deltaY||i.deltaX;return i.deltaMode===1?e*=15:i.deltaMode===2&&(e*=800),Math.max(-jt,Math.min(jt,e))}class Wi{constructor(e,t,n,s,d){Object.defineProperty(this,"onZoom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleTimeStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleTimeEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"minZoom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxZoom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.onZoom=e,this.visibleTimeStart=t,this.visibleTimeEnd=n,this.minZoom=s,this.maxZoom=d}updateBounds(e,t){this.visibleTimeStart=e,this.visibleTimeEnd=t}handleWheelZoom(e,t){const n=Yi(e),s=e.ctrlKey?10:e.metaKey?3:1,d=n>0?1+s*n/500:1/(1+s*-n/500),o=this.visibleTimeEnd-this.visibleTimeStart;let c=Math.round(o*d);c=Math.max(this.minZoom,Math.min(this.maxZoom,c));const l=Math.round(this.visibleTimeStart+(o-c)*t),y=l+c;this.onZoom(l,y)}}const xi=4;class Bi{constructor(e){Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"dragSnap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.dragSnap=e}startInteraction(e,t,n,s){this.state={item:e,mode:t,startX:n,startY:s,currentX:n,currentY:s,deltaX:0,originalGroup:e.group,currentGroup:e.group},this.activated=!1}update(e,t){this.state&&(this.state.currentX=e,this.state.currentY=t,this.state.deltaX=e-this.state.startX,!this.activated&&Math.abs(this.state.deltaX)>=xi&&(this.activated=!0))}setCurrentGroup(e){this.state&&(this.state.currentGroup=e)}endMove(e){if(!this.state)return null;const t=this.state.deltaX/e,n=this.state.item.start_time+t,s=Math.round(n/this.dragSnap)*this.dragSnap,d=this.state.currentGroup;return this.state=null,this.activated=!1,{newStartTime:s,newGroupId:d}}endResize(e){if(!this.state)return null;const t=this.state.deltaX/e,n=this.state.mode==="resize-left"?"left":"right",d=(n==="left"?this.state.item.start_time:this.state.item.end_time)+t,o=Math.round(d/this.dragSnap)*this.dragSnap;return this.state=null,this.activated=!1,{newTime:o,edge:n}}cancel(){this.state=null,this.activated=!1}getState(){return this.state}getMode(){var e;return((e=this.state)==null?void 0:e.mode)??null}isActive(){return this.state!==null&&this.activated}isPending(){return this.state!==null}}function vt(i,e,t){const n=[];for(const s of i)s.id!==e&&(n.push(t(s.start_time)),n.push(t(s.end_time)));return n}function et(i,e,t,n,s){if(e.length===0)return null;let d=e[0],o=Math.abs(i-d);for(let c=1;c<e.length;c++){const l=Math.abs(i-e[c]);l<o&&(o=l,d=e[c])}return o<=t?d:null}var Kt={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(tt,function(){var t="day";return function(n,s,d){var o=function(y){return y.add(4-y.isoWeekday(),t)},c=s.prototype;c.isoWeekYear=function(){return o(this).year()},c.isoWeek=function(y){if(!this.$utils().u(y))return this.add(7*(y-this.isoWeek()),t);var R,v,h,k,S=o(this),m=(R=this.isoWeekYear(),v=this.$u,h=(v?d.utc:d)().year(R).startOf("year"),k=4-h.isoWeekday(),h.isoWeekday()>4&&(k+=7),h.add(k,t));return S.diff(m,"week")+1},c.isoWeekday=function(y){return this.$utils().u(y)?this.day()||7:this.day(this.day()%7?y:y-7)};var l=c.startOf;c.startOf=function(y,R){var v=this.$utils(),h=!!v.u(R)||R;return v.p(y)==="isoweek"?h?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):l.bind(this)(y,R)}}})})(Kt);var ji=Kt.exports;const Li=it(ji),Lt=200;function zt({groups:i,width:e,lineHeight:t,groupHeights:n,scrollTop:s,canvasHeight:d,theme:o,groupRenderer:c,onScroll:l}){var T;const y=f.useRef(null),R=f.useRef(!1),v=f.useMemo(()=>{const D=new Array(i.length+1);D[0]=0;for(let C=0;C<i.length;C++)D[C+1]=D[C]+((n==null?void 0:n[C])??t);return D},[i.length,n,t]),h=v[i.length]??0,k=d,S=f.useCallback(D=>{if(i.length===0||D<=0)return 0;if(D>=h)return i.length-1;let C=0,F=i.length-1;for(;C<F;){const B=C+F>>>1;v[B+1]>D?F=B:C=B+1}return C},[i.length,v,h]),m=S(s-Lt),H=S(s+d+Lt),X=f.useCallback(D=>{R.current||l(D.currentTarget.scrollTop)},[l]);f.useEffect(()=>{y.current&&(R.current=!0,y.current.scrollTop=s,requestAnimationFrame(()=>{R.current=!1}))},[s]);const x=[];for(let D=m;D<=H;D++){const C=i[D];if(!C)continue;const F=v[D],B=v[D+1]-F;x.push(q.jsx("div",{style:{position:"absolute",top:F,height:B,width:"100%",overflow:"hidden",display:"flex",alignItems:"stretch",borderBottom:`1px solid ${((T=o.grid)==null?void 0:T.line)??"#E5E5E5"}`,boxSizing:"border-box"},children:c(C)},C.id))}return q.jsx("div",{ref:y,onScroll:X,style:{width:e,height:k,overflowY:h>d?"auto":"hidden",overflowX:"hidden",position:"relative",borderRight:`1px solid ${o.sidebar.border}`,backgroundColor:o.sidebar.bg},children:q.jsx("div",{style:{height:h,position:"relative"},children:x})})}function Jt(i){return null}Jt.displayName="TodayMarker";function At(i){return{date:Math.floor(Date.now()/6e4)*6e4,color:i.color??"#FD7171",width:i.width??6,label:i.label}}function zi(i){return i.interval??1e4}function Qt(i){return null}Qt.displayName="CustomMarker";function Gt(i){return{date:i.date,color:i.color??"#3B82F6",width:i.width??4,label:i.label}}$e.extend(Li);function Ai(i){return i?{...Te,...i,status:{...Te.status,...i.status},grid:{...Te.grid,...i.grid},item:{...Te.item,...i.item},marker:{...Te.marker,...i.marker},sidebar:{...Te.sidebar,...i.sidebar},header:{...Te.header,...i.header}}:Te}const Nt=32,Gi=f.memo(f.forwardRef(function(e,t){const{groups:n,items:s,defaultTimeStart:d,defaultTimeEnd:o,sidebarWidth:c,lineHeight:l,itemHeightRatio:y,stackItems:R,canMove:v,canChangeGroup:h,canResize:k,dragSnap:S,minZoom:m,maxZoom:H,theme:X,dayStyle:x,rowStyle:T,showCursorLine:D,itemRenderer:C,groupRenderer:F,sidebarGroupRenderer:B,dependencies:I,highlights:A,onItemClick:_,onItemDoubleClick:se,onItemContextMenu:J,onItemMove:te,onItemResize:me,moveResizeValidator:ve,onItemHover:be,onCanvasDoubleClick:De,onCanvasContextMenu:Ae,onTimeChange:Ce,onZoom:bt,selected:yt=[],rightSidebarWidth:nt,rightSidebarGroupRenderer:Tt,onReady:Ge,maxHeight:Fe,timezone:Ne,devBadge:si,children:Se}=e,ye=f.useMemo(()=>Ai(X),[X]),St=f.useCallback((r,a)=>{for(let g=0;g<a.length;g++)if(a[g].id===r)return g;return 0},[]),oi=yt.join(","),rt=f.useMemo(()=>yt,[oi]),Mt=f.useRef(null),kt=f.useRef(null),Ct=f.useRef(null),_e=f.useRef(null),Et=f.useRef(null),wt=f.useRef(null),[ai,li]=f.useState(800),[ui,ci]=f.useState(null);f.useEffect(()=>{const r=Et.current;if(!r)return;const a=new ResizeObserver(g=>{const p=g[0];p&&li(p.contentRect.width)});return a.observe(r),()=>a.disconnect()},[]),f.useEffect(()=>{const r=wt.current;if(!r||!Fe)return;const a=new ResizeObserver(g=>{const p=g[0];p&&ci(p.contentRect.height)});return a.observe(r),()=>a.disconnect()},[Fe]);const Me=Math.max(0,ai-c-(nt??0)),Ee=f.useMemo(()=>{const r=new Zt;return r.rebuild(s),r},[s]),st=f.useMemo(()=>{const r=new wi;return r.buildFromItems(s,a=>Ee.getEffectiveSpan(a.id).start,a=>Ee.getEffectiveSpan(a.id).end),r},[s,Ee]),Ye=f.useMemo(()=>{const r=new Hi(l,y);return r.computeLayout(s,R,Ee),r},[s,l,y,R,Ee]),we=f.useMemo(()=>n.map(r=>Ye.getGroupHeight(r.id)),[n,Ye]),Ze=f.useMemo(()=>we.reduce((r,a)=>r+a,0),[we]),Ht=typeof Fe=="number"?Fe:ui,ge=Ht?Math.min(Ze,Ht):Ze,j=f.useRef(new ht({visibleTimeStart:e.visibleTimeStart??d,visibleTimeEnd:e.visibleTimeEnd??o,canvasWidth:Me,canvasHeight:ge,sidebarWidth:c,lineHeight:l,groupCount:n.length,buffer:e.buffer??3,scrollTop:0,groupHeights:we})),ot=f.useRef(null),We=f.useRef(void 0),he=f.useRef(null),He=f.useRef(!1),Rt=4,[Dt,di]=f.useState(e.visibleTimeStart??d),[It,fi]=f.useState(e.visibleTimeEnd??o),[Ot,Ue]=f.useState(0),xe=f.useRef(null),Ie=f.useCallback(()=>{const r=j.current;di(r.visibleTimeStart),fi(r.visibleTimeEnd),Ue(r.scrollTop),xe.current=null},[]),at=f.useCallback(()=>{xe.current===null&&(xe.current=setTimeout(Ie,Nt))},[Ie]);f.useEffect(()=>()=>{xe.current!==null&&clearTimeout(xe.current)},[]);const Pt=f.useMemo(()=>e.summaryRenderer?e.summaryRenderer:(r,a,g,p,u)=>{Ri(r,a,g,p,u,ye)},[e.summaryRenderer,ye]),Oe=f.useMemo(()=>new $i,[]),Pe=f.useMemo(()=>new Fi,[]),Xe=f.useMemo(()=>new _i,[]),ie=f.useMemo(()=>new Bi(S),[S]),Ve=f.useMemo(()=>{const r=[];return f.Children.forEach(Se,a=>{var p;if(!f.isValidElement(a))return;const g=(p=a.type)==null?void 0:p.displayName;g==="TodayMarker"?r.push(At(a.props)):g==="CustomMarker"&&r.push(Gt(a.props))}),r},[Se]),qe=f.useMemo(()=>Ve.map(r=>`${r.date}|${r.color}|${r.width}|${r.label??""}`).join(";"),[Ve]),Be=f.useRef(Ve);Be.current=Ve;const lt=f.useMemo(()=>{let r=0;return f.Children.forEach(Se,a=>{var p;if(!f.isValidElement(a))return;((p=a.type)==null?void 0:p.displayName)==="TodayMarker"&&(r=zi(a.props))}),r},[Se]),z=f.useRef({groups:n,items:s,intervalTree:st,layoutEngine:Ye,itemRenderer:C,groupRenderer:F,theme:ye,selected:rt,dependencies:I,highlights:A,dayStyle:x,rowStyle:T,showCursorLine:D,canvasWidth:Me,canvasHeight:ge,lineHeight:l,itemHeightRatio:y,onTimeChange:Ce,onZoom:bt,onItemHover:be,onItemClick:_,onItemDoubleClick:se,onItemContextMenu:J,onItemMove:te,onItemResize:me,onCanvasDoubleClick:De,onCanvasContextMenu:Ae,canMove:v,canResize:k,canChangeGroup:h,dragSnap:S,sidebarWidth:c,moveResizeValidator:ve,summaryRenderer:Pt,hierarchyEngine:Ee,timezone:Ne});z.current={groups:n,items:s,intervalTree:st,layoutEngine:Ye,itemRenderer:C,groupRenderer:F,theme:ye,selected:rt,dependencies:I,highlights:A,dayStyle:x,rowStyle:T,showCursorLine:D,canvasWidth:Me,canvasHeight:ge,lineHeight:l,itemHeightRatio:y,onTimeChange:Ce,onZoom:bt,onItemHover:be,onItemClick:_,onItemDoubleClick:se,onItemContextMenu:J,onItemMove:te,onItemResize:me,onCanvasDoubleClick:De,onCanvasContextMenu:Ae,canMove:v,canResize:k,canChangeGroup:h,dragSnap:S,sidebarWidth:c,moveResizeValidator:ve,summaryRenderer:Pt,hierarchyEngine:Ee,timezone:Ne};const hi=f.useCallback(()=>{const r=Mt.current;if(!r)return;const a=z.current,g=gt(r,a.canvasWidth,a.canvasHeight);pt(g,r),Oe.draw(g,j.current,a.groups,a.theme,a.dayStyle,a.rowStyle,a.highlights,a.timezone)},[Oe]),mi=f.useCallback(()=>{const r=kt.current;if(!r)return;const a=z.current,g=gt(r,a.canvasWidth,a.canvasHeight);pt(g,r),Pe.draw(g,j.current,a.groups,a.items,a.intervalTree,a.layoutEngine,a.itemRenderer,a.groupRenderer,a.theme,a.selected,We.current,a.dependencies,a.summaryRenderer,a.hierarchyEngine)},[Pe]),Xt=f.useCallback((r,a,g)=>{const p=j.current,u=z.current,b=u.canvasWidth/(p.visibleTimeEnd-p.visibleTimeStart),E=a/b,O=[];g==="move"?(O.push(p.timeToX(r.start_time+E)),O.push(p.timeToX(r.end_time+E))):g==="resize-left"?O.push(p.timeToX(r.start_time+E)):O.push(p.timeToX(r.end_time+E));const $=(p.visibleTimeEnd-p.visibleTimeStart)*.1,Y=u.intervalTree.query(p.visibleTimeStart-$,p.visibleTimeEnd+$),Z=vt(Y,r.id,Q=>p.timeToX(Q));for(const Q of O){const K=et(Q,Z,8,b,u.dragSnap);if(K!==null)return K}const ne=g==="resize-right"?r.end_time+E:r.start_time+E,L=Math.round(ne/u.dragSnap)*u.dragSnap;return p.timeToX(L)},[]),gi=f.useCallback(()=>{const r=Ct.current;if(!r)return;const a=z.current,g=gt(r,a.canvasWidth,a.canvasHeight);pt(g,r);const p=j.current,u=ie.getState();let b=null;if(u){const E=p.timeToX(u.item.start_time),O=p.timeToX(u.item.end_time)-E;let $,Y;u.mode==="resize-left"?($=E+u.deltaX,Y=O-u.deltaX):u.mode==="resize-right"?($=E,Y=O+u.deltaX):($=E+u.deltaX,Y=O);const Z=St(u.currentGroup,a.groups),ne=p.groupIndexToY(Z),L=u.currentGroup!==u.originalGroup;b={item:u.item,mode:u.mode,bounds:{x:$,y:ne+(a.lineHeight-a.lineHeight*a.itemHeightRatio)/2,width:Y,height:a.lineHeight*a.itemHeightRatio},renderer:a.itemRenderer,targetGroupY:ne,groupChanged:L}}Xe.draw(g,p,a.theme,{cursorX:a.showCursorLine?ot.current:null,snapX:u?Xt(u.item,u.deltaX,u.mode):null,markers:Be.current,interaction:b})},[Xe,ie,Xt,St]),ut=f.useRef(null);ut.current||(ut.current=new Di(r=>{r.grid&&hi(),r.items&&mi(),r.overlay&&gi()}));const P=ut.current;f.useEffect(()=>()=>P.dispose(),[P]),f.useEffect(()=>{if(!lt)return;const r=setInterval(()=>{const a=[];f.Children.forEach(Se,g=>{var u;if(!f.isValidElement(g))return;const p=(u=g.type)==null?void 0:u.displayName;p==="TodayMarker"?a.push(At(g.props)):p==="CustomMarker"&&a.push(Gt(g.props))}),Be.current=a,P.markDirty("overlay")},lt);return()=>clearInterval(r)},[lt,Se,P]),f.useEffect(()=>{j.current.update({canvasWidth:Me,canvasHeight:ge,sidebarWidth:c,lineHeight:l,groupCount:n.length,groupHeights:we}),P.markAllDirty()},[Me,ge,c,l,n.length,we,P]),f.useEffect(()=>{P.markDirty("grid"),P.markDirty("items")},[s,n,rt,ye,x,T,st,Ye,P]);const Ke=f.useMemo(()=>{var r;return((r=e.highlights)==null?void 0:r.map(a=>`${a.start}|${a.end}|${a.color}|${a.label??""}|${a.opacity??""}`).join(";"))??""},[e.highlights]),$t=f.useRef(Ke);f.useEffect(()=>{Ke!==$t.current&&($t.current=Ke,P.markDirty("grid"))},[Ke,P]);const Ft=f.useRef(qe);f.useEffect(()=>{qe!==Ft.current&&(Ft.current=qe,P.markDirty("overlay"))},[qe,P]);const _t=f.useRef(e.visibleTimeStart),Yt=f.useRef(e.visibleTimeEnd);e.visibleTimeStart!==void 0&&e.visibleTimeStart!==_t.current&&(_t.current=e.visibleTimeStart,j.current.update({visibleTimeStart:e.visibleTimeStart}),P.markAllDirty()),e.visibleTimeEnd!==void 0&&e.visibleTimeEnd!==Yt.current&&(Yt.current=e.visibleTimeEnd,j.current.update({visibleTimeEnd:e.visibleTimeEnd}),P.markAllDirty());const je=f.useRef(null),ct=f.useCallback(r=>{je.current===null&&(je.current=setTimeout(()=>{var p,u;je.current=null;const a=j.current,g=z.current;r==="zoom"?(p=g.onZoom)==null||p.call(g,a.visibleTimeStart,a.visibleTimeEnd):(u=g.onTimeChange)==null||u.call(g,a.visibleTimeStart,a.visibleTimeEnd)},Nt))},[]);f.useEffect(()=>()=>{je.current!==null&&clearTimeout(je.current)},[]);const Je=f.useRef(null),dt=f.useMemo(()=>new Wi((r,a)=>{var g;j.current.update({visibleTimeStart:r,visibleTimeEnd:a}),(g=Je.current)==null||g.updateBounds(r,a),P.markAllDirty(),at(),ct("zoom")},d,o,m,H),[]);Je.current=dt;const Qe=f.useCallback(r=>{const a=j.current,g=a.getTotalHeight(),p=Math.max(0,g-a.canvasHeight),u=Math.max(0,Math.min(p,a.scrollTop+r));u!==a.scrollTop&&(a.update({scrollTop:u}),P.markDirty("grid"),P.markDirty("items"),P.markDirty("overlay"),Ue(u))},[P]),Le=f.useCallback(r=>{var E,O,$;const a=j.current,g=a.canvasWidth/(a.visibleTimeEnd-a.visibleTimeStart),p=r/g,u=a.visibleTimeStart+p,b=a.visibleTimeEnd+p;a.update({visibleTimeStart:u,visibleTimeEnd:b}),(E=Je.current)==null||E.updateBounds(u,b),P.markAllDirty(),Ei.flushSync(()=>Ie()),($=(O=z.current).onTimeChange)==null||$.call(O,u,b)},[P,Ie]);f.useEffect(()=>{const r=_e.current;if(!r)return;const a=g=>{if(g.ctrlKey||g.metaKey||g.altKey){g.preventDefault();const p=r.getBoundingClientRect(),u=(g.clientX-p.left)/p.width;dt.handleWheelZoom(g,u)}else if(g.shiftKey)g.preventDefault(),Le(g.deltaY||g.deltaX);else{const p=g.deltaX;p!==0&&Math.abs(p)>Math.abs(g.deltaY)?(g.preventDefault(),Le(p)):g.deltaY!==0&&(Ze>ge&&g.preventDefault(),Qe(g.deltaY))}};return r.addEventListener("wheel",a,{passive:!1}),()=>r.removeEventListener("wheel",a)},[dt,Qe,Le,Ze,ge]);const ke=f.useRef({lastDistance:null,lastCenter:null});f.useEffect(()=>{const r=_e.current;if(!r)return;const a=(E,O)=>Math.abs(E.clientX-O.clientX),g=(E,O,$)=>(E.clientX+O.clientX)/2-$.left,p=E=>{E.touches.length===2&&(E.preventDefault(),ke.current.lastDistance=a(E.touches[0],E.touches[1]),ke.current.lastCenter=null)},u=E=>{var O;if(E.touches.length===2&&ke.current.lastDistance!==null){E.preventDefault();const $=a(E.touches[0],E.touches[1]),Y=r.getBoundingClientRect(),ne=g(E.touches[0],E.touches[1],Y)/Y.width;if($!==0&&ke.current.lastDistance!==0){const L=ke.current.lastDistance/$,Q=j.current,K=Q.visibleTimeEnd-Q.visibleTimeStart;let le=K*L;le=Math.max(m,Math.min(H,le));const U=Q.visibleTimeStart+K*ne,w=U-le*ne,M=U+le*(1-ne);Q.update({visibleTimeStart:w,visibleTimeEnd:M}),(O=Je.current)==null||O.updateBounds(w,M),P.markAllDirty(),at(),ct("zoom")}ke.current.lastDistance=$}},b=()=>{ke.current.lastDistance=null,ke.current.lastCenter=null};return r.addEventListener("touchstart",p,{passive:!1}),r.addEventListener("touchmove",u,{passive:!1}),r.addEventListener("touchend",b),()=>{r.removeEventListener("touchstart",p),r.removeEventListener("touchmove",u),r.removeEventListener("touchend",b)}},[P,at,ct]);const pi=f.useCallback(r=>{var $;const a=r.currentTarget,g=a.getBoundingClientRect(),p=r.clientX-g.left,u=r.clientY-g.top;if(ot.current=p,he.current){const Y=r.clientX-he.current.startX,Z=r.clientY-he.current.startY;if(!He.current&&(Math.abs(Y)>=Rt||Math.abs(Z)>=Rt)&&(He.current=!0,a.style.cursor="grabbing",a.setPointerCapture(r.pointerId)),He.current){const ne=r.clientX-he.current.lastX,L=r.clientY-he.current.lastY;he.current.lastX=r.clientX,he.current.lastY=r.clientY,Math.abs(ne)>0&&Le(-ne),Math.abs(L)>0&&Qe(-L)}return}if(ie.isPending()){if(ie.update(p,u),ie.isActive()){const Y=ie.getState();if(Y&&Y.mode==="move"&&z.current.canChangeGroup){const Z=mt(u,j.current,z.current.groups);Z&&ie.setCurrentGroup(Z.id)}P.markDirty("overlay")}return}z.current.showCursorLine&&P.markDirty("overlay");const b=z.current,E=ze(p,u,j.current,b.intervalTree,b.layoutEngine,b.groups),O=E==null?void 0:E.id;if(O!==We.current&&(We.current=O,P.markDirty("items"),($=b.onItemHover)==null||$.call(b,O??null,r.nativeEvent)),E){const Y=xt(p,E,j.current),Z=b.canResize;Y==="left"&&(Z==="left"||Z==="both")||Y==="right"&&(Z==="right"||Z==="both")?a.style.cursor="col-resize":b.canMove?a.style.cursor="grab":a.style.cursor="default"}else a.style.cursor="default"},[ie,P,Le,Qe]),vi=f.useCallback(r=>{const a=z.current,g=r.currentTarget.getBoundingClientRect(),p=r.clientX-g.left,u=r.clientY-g.top,b=ze(p,u,j.current,a.intervalTree,a.layoutEngine,a.groups);if(!b){he.current={startX:r.clientX,startY:r.clientY,lastX:r.clientX,lastY:r.clientY},He.current=!1;return}const E=xt(p,b,j.current),O=a.canResize;E==="left"&&(O==="left"||O==="both")?ie.startInteraction(b,"resize-left",p,u):E==="right"&&(O==="right"||O==="both")?ie.startInteraction(b,"resize-right",p,u):a.canMove&&ie.startInteraction(b,"move",p,u)},[ie]),bi=f.useCallback(r=>{var E,O,$,Y,Z,ne;const a=r.currentTarget;if(he.current){const L=He.current;if(he.current=null,He.current=!1,a.style.cursor="default",L)return}if(ie.isActive()){const L=ie.getState(),Q=j.current,K=Q.canvasWidth/(Q.visibleTimeEnd-Q.visibleTimeStart);if(L){const le=z.current.moveResizeValidator;if(L.mode==="move"){const U=ie.endMove(K);if(U){const w=j.current,M=z.current,de=L.deltaX/K,G=w.timeToX(L.item.start_time+de),ce=w.timeToX(L.item.end_time+de),ae=(w.visibleTimeEnd-w.visibleTimeStart)*.1,W=M.intervalTree.query(w.visibleTimeStart-ae,w.visibleTimeEnd+ae),re=vt(W,L.item.id,ue=>w.timeToX(ue));let V=U.newStartTime;const N=et(G,re,8,K,M.dragSnap);if(N!==null)V=w.xToTime(N);else{const ue=et(ce,re,8,K,M.dragSnap);if(ue!==null){const fe=L.item.end_time-L.item.start_time;V=w.xToTime(ue)-fe}}const ee=le?le("move",L.item.id,V):V,oe=z.current.hierarchyEngine.getMoveDelta(L.item.id,ee);(O=(E=z.current).onItemMove)==null||O.call(E,L.item.id,ee,U.newGroupId,oe.length>0?oe:void 0)}}else{const U=ie.endResize(K);if(U){const w=j.current,M=z.current,de=L.deltaX/K,G=U.edge==="left"?L.item.start_time+de:L.item.end_time+de,ce=w.timeToX(G),ae=(w.visibleTimeEnd-w.visibleTimeStart)*.1,W=M.intervalTree.query(w.visibleTimeStart-ae,w.visibleTimeEnd+ae),re=vt(W,L.item.id,ue=>w.timeToX(ue)),V=et(ce,re,8,K,M.dragSnap);let N=V!==null?w.xToTime(V):U.newTime;const ee=z.current.hierarchyEngine.getResizeConstraint(L.item.id,U.edge);U.edge==="left"&&N>ee.max?N=ee.max:U.edge==="right"&&N<ee.min&&(N=ee.min);const oe=le?le("resize",L.item.id,N,U.edge):N;(Y=($=z.current).onItemResize)==null||Y.call($,L.item.id,oe,U.edge)}}}a.style.cursor="default",P.markDirty("overlay");return}ie.isPending()&&ie.cancel();const g=a.getBoundingClientRect(),p=r.clientX-g.left,u=r.clientY-g.top,b=ze(p,u,j.current,z.current.intervalTree,z.current.layoutEngine,z.current.groups);b&&((ne=(Z=z.current).onItemClick)==null||ne.call(Z,b.id,r.nativeEvent))},[ie,P]),yi=f.useCallback(r=>{var E,O;const a=r.currentTarget.getBoundingClientRect(),g=r.clientX-a.left,p=r.clientY-a.top,u=z.current,b=ze(g,p,j.current,u.intervalTree,u.layoutEngine,u.groups);if(b)(E=u.onItemDoubleClick)==null||E.call(u,b.id,r.nativeEvent);else{const $=mt(p,j.current,u.groups),Y=j.current.xToTime(g);$&&((O=u.onCanvasDoubleClick)==null||O.call(u,$.id,Y))}},[]),Ti=f.useCallback(r=>{var E,O;r.preventDefault();const a=r.currentTarget.getBoundingClientRect(),g=r.clientX-a.left,p=r.clientY-a.top,u=z.current,b=ze(g,p,j.current,u.intervalTree,u.layoutEngine,u.groups);if(b)(E=u.onItemContextMenu)==null||E.call(u,b.id,r.nativeEvent);else{const $=mt(p,j.current,u.groups),Y=j.current.xToTime(g);$&&((O=u.onCanvasContextMenu)==null||O.call(u,$.id,Y,r.nativeEvent))}},[]),Si=f.useCallback(()=>{var r,a;he.current=null,He.current=!1,ot.current=null,_e.current&&(_e.current.style.cursor="default"),We.current!==void 0&&(We.current=void 0,P.markDirty("items"),(a=(r=z.current).onItemHover)==null||a.call(r,null,new PointerEvent("pointerleave"))),z.current.showCursorLine&&P.markDirty("overlay")},[P]),Mi=f.useMemo(()=>{const r=[];return f.Children.forEach(Se,a=>{var p;if(!f.isValidElement(a))return;if(((p=a.type)==null?void 0:p.displayName)==="TimelineHeaders"){const u=a.props;r.push(f.cloneElement(a,{visibleTimeStart:u.visibleTimeStart??Dt,visibleTimeEnd:u.visibleTimeEnd??It,canvasWidth:u.canvasWidth??Me,sidebarWidth:u.sidebarWidth??c,theme:u.theme??ye,timezone:u.timezone??Ne,onZoomToInterval:u.onZoomToInterval??((b,E)=>{var O,$,Y,Z;j.current.update({visibleTimeStart:b,visibleTimeEnd:E}),P.markAllDirty(),Ie(),($=(O=z.current).onTimeChange)==null||$.call(O,b,E),(Z=(Y=z.current).onZoom)==null||Z.call(Y,b,E)})}))}}),r},[Se,Dt,It,Me,c,ye,Ne,P,Ie]),Wt=f.useRef(!1);f.useEffect(()=>{Wt.current||(Wt.current=!0,P.markAllDirty())},[P]),f.useImperativeHandle(t,()=>({captureToCanvas({timeStart:r,timeEnd:a,scale:g,sidebarWidth:p}){const u=z.current,b=28,E=b*3,O=u.groups.map(G=>u.layoutEngine.getGroupHeight(G.id)),$=[0];for(let G=0;G<O.length;G++)$.push($[G]+O[G]);const Y=$[O.length],Z=j.current,ne=u.canvasWidth/(Z.visibleTimeEnd-Z.visibleTimeStart),L=a-r,Q=Math.max(u.canvasWidth,Math.round(L*ne)),K=(p+Q)*g,le=(E+Y)*g,U=document.createElement("canvas");U.width=K,U.height=le;const w=U.getContext("2d");w.scale(g,g);for(let G=0;G<u.groups.length;G++){const ce=u.groups[G],ae=O[G],W=E+$[G];if(u.rowStyle){const ee=u.rowStyle(ce);ee!=null&&ee.backgroundColor&&(w.fillStyle=ee.backgroundColor,w.fillRect(0,W,p,ae))}const re=ce.type;let V="400",N=8;re==="project"?V="700":re==="CAG"?V="600":re==="CA"&&(V="400",N=24),w.fillStyle="#111",w.font=`${V} 12px sans-serif`,w.textBaseline="middle",w.fillText(ce.title,N,W+ae/2,p-N-4)}const M=(G,ce,ae)=>{var V,N;w.fillStyle=((V=u.theme.header)==null?void 0:V.bg)??"#f5f5f5",w.fillRect(p,G,Q,b),w.strokeStyle=((N=u.theme.grid)==null?void 0:N.line)??"#e0e0e0",w.lineWidth=1,w.strokeRect(p,G,Q,b);let W=pe(r,u.timezone).startOf(ae);W.valueOf()<r&&(W=W.add(1,ae));const re=Q/(a-r);for(;W.valueOf()<a;){const ee=W.add(1,ae),oe=p+(W.valueOf()-r)*re,fe=p+(Math.min(ee.valueOf(),a)-r)*re-oe;w.beginPath(),w.moveTo(oe,G),w.lineTo(oe,G+b),w.stroke(),w.fillStyle="#333",w.font="600 11px sans-serif",w.textBaseline="middle",w.textAlign="center",w.fillText(ce(W),oe+fe/2,G+b/2,fe-4),W=ee}w.textAlign="start"};M(0,G=>G.format("YYYY"),"year"),M(b,G=>G.format("MM"),"month"),M(b*2,G=>String(G.isoWeek()),"week");const de=new ht({visibleTimeStart:r,visibleTimeEnd:a,canvasWidth:Q,canvasHeight:Y,sidebarWidth:0,lineHeight:u.lineHeight,groupCount:u.groups.length,buffer:1,scrollTop:0,groupHeights:O});return w.save(),w.translate(p,E),w.beginPath(),w.rect(0,0,Q,Y),w.clip(),Oe.draw(w,de,u.groups,u.theme,u.dayStyle,u.rowStyle,u.highlights,u.timezone),Pe.draw(w,de,u.groups,u.items,u.intervalTree,u.layoutEngine,u.itemRenderer,u.groupRenderer,u.theme,u.selected,void 0,u.dependencies,u.summaryRenderer,u.hierarchyEngine),Xe.draw(w,de,u.theme,{cursorX:null,snapX:null,markers:Be.current,interaction:null}),w.restore(),U}}),[Oe,Pe,Xe]),f.useEffect(()=>{const r={captureToCanvas({timeStart:a,timeEnd:g,scale:p,sidebarWidth:u}){var ae;const b=z.current,E=28,O=E*3,$=b.groups.map(W=>b.layoutEngine.getGroupHeight(W.id)),Y=[0];for(let W=0;W<$.length;W++)Y.push(Y[W]+$[W]);const Z=Y[$.length],ne=j.current,L=b.canvasWidth/(ne.visibleTimeEnd-ne.visibleTimeStart),Q=g-a,K=Math.max(b.canvasWidth,Math.round(Q*L)),le=u+K,U=O+Z,w=document.createElement("canvas");w.width=le*p,w.height=U*p;const M=w.getContext("2d");M.scale(p,p),M.fillStyle="#FFFFFF",M.fillRect(0,0,le,U),M.save(),M.beginPath(),M.rect(0,0,u,U),M.clip(),M.fillStyle="#F9FAFB",M.fillRect(0,0,u,O),M.strokeStyle="#E5E7EB",M.lineWidth=1,M.strokeRect(0,0,u,O);for(let W=0;W<b.groups.length;W++){const re=b.groups[W],V=$[W],N=O+Y[W],ee=(ae=b.rowStyle)==null?void 0:ae.call(b,re);M.fillStyle=(ee==null?void 0:ee.backgroundColor)??(W%2===0?"#FFFFFF":"#F7F7F7"),M.fillRect(0,N,u,V),M.strokeStyle="#E5E5E5",M.lineWidth=.5,M.beginPath(),M.moveTo(0,N+V),M.lineTo(u,N+V),M.stroke();const oe=re.type??"";let ue=8,fe="400",Re=11;oe==="project"?(fe="700",Re=12):oe==="control_area_group"?fe="600":oe==="control_area"&&(ue=24),M.fillStyle="#374151",M.font=`${fe} ${Re}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,M.textBaseline="middle";const Ci=typeof re.title=="string"?re.title:String(re.title);M.fillText(Ci,ue,N+V/2,u-ue-8)}M.strokeStyle="#E5E7EB",M.lineWidth=1,M.beginPath(),M.moveTo(u,0),M.lineTo(u,U),M.stroke(),M.restore(),M.save(),M.beginPath(),M.rect(u,0,K,O),M.clip();const de=g-a,G=[{unit:"year",row:0},{unit:"month",row:1},{unit:"week",row:2}];for(const{unit:W,row:re}of G){const V=re*E;M.fillStyle="#F9FAFB",M.fillRect(u,V,K,E);let N=pe(a,b.timezone).startOf(W);const ee=pe(g,b.timezone).add(1,W);for(;N.isBefore(ee);){const oe=N.add(1,W),ue=u+(N.valueOf()-a)/de*K,fe=(oe.valueOf()-N.valueOf())/de*K;M.strokeStyle="#E5E7EB",M.lineWidth=.5,M.strokeRect(ue,V,fe,E);let Re;W==="year"?Re=N.format("YYYY"):W==="month"?Re=N.format("MM"):Re=`${N.week()}`,M.fillStyle="#6c737f",M.font=W==="year"?'600 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif':'400 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',M.textBaseline="middle",M.textAlign="center",fe>20&&M.fillText(Re,ue+fe/2,V+E/2),N=oe}}M.textAlign="start",M.restore(),M.save(),M.beginPath(),M.rect(u,O,K,Z),M.clip(),M.translate(u,O);const ce=new ht({visibleTimeStart:a,visibleTimeEnd:g,canvasWidth:K,canvasHeight:Z,sidebarWidth:0,lineHeight:b.lineHeight,groupCount:b.groups.length,buffer:1,scrollTop:0,groupHeights:$});return Oe.draw(M,ce,b.groups,b.theme,b.dayStyle,b.rowStyle,b.highlights,b.timezone),Pe.draw(M,ce,b.groups,b.items,b.intervalTree,b.layoutEngine,b.itemRenderer,b.groupRenderer,b.theme,b.selected,void 0,b.dependencies,b.summaryRenderer,b.hierarchyEngine),Xe.draw(M,ce,b.theme,{cursorX:null,markers:Be.current}),M.restore(),w}};Ge==null||Ge(r)},[Ge,Oe,Pe,Xe]);const ki={position:"relative",width:Me,height:ge,overflow:"hidden",cursor:"default"},ft={position:"absolute",top:0,left:0};return q.jsxs("div",{ref:Et,style:{display:"flex",flexDirection:"column",width:"100%",position:"relative"},children:[si?q.jsxs("div",{style:{position:"absolute",top:0,left:0,zIndex:9999,padding:"2px 6px",fontSize:10,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:1.4,color:"#fff",background:"rgba(17, 24, 39, 0.78)",borderBottomRightRadius:4,pointerEvents:"none",userSelect:"none"},children:["v","0.6.0"," · ","06:59:26"]}):null,Mi,q.jsxs("div",{ref:wt,style:{display:"flex",overflow:"hidden",maxHeight:Fe??void 0},children:[q.jsx(zt,{groups:n,width:c,lineHeight:l,groupHeights:we,scrollTop:Ot,canvasHeight:ge,theme:ye,groupRenderer:B,onScroll:r=>{j.current.update({scrollTop:r}),P.markDirty("grid"),P.markDirty("items"),P.markDirty("overlay"),Ue(r)}}),q.jsxs("div",{ref:_e,style:ki,onPointerMove:pi,onPointerDown:vi,onPointerUp:bi,onDoubleClick:yi,onContextMenu:Ti,onPointerLeave:Si,children:[q.jsx("canvas",{ref:Mt,style:{...ft,zIndex:0}}),q.jsx("canvas",{ref:kt,style:{...ft,zIndex:1}}),q.jsx("canvas",{ref:Ct,style:{...ft,zIndex:2}})]}),nt&&Tt?q.jsx(zt,{groups:n,width:nt,lineHeight:l,groupHeights:we,scrollTop:Ot,canvasHeight:ge,theme:ye,groupRenderer:Tt,onScroll:r=>{j.current.update({scrollTop:r}),P.markDirty("grid"),P.markDirty("items"),P.markDirty("overlay"),Ue(r)}}):null]})]})}));function ei({children:i,theme:e,className:t,classNames:n,style:s,visibleTimeStart:d,visibleTimeEnd:o,canvasWidth:c,sidebarWidth:l=0,onZoomToInterval:y,timezone:R}){const v=f.Children.map(i,h=>{var S;if(!f.isValidElement(h))return h;if(((S=h.type)==null?void 0:S.displayName)==="DateHeader"){const m=h.props,H=f.cloneElement(h,{visibleTimeStart:m.visibleTimeStart??d,visibleTimeEnd:m.visibleTimeEnd??o,canvasWidth:m.canvasWidth??c,theme:m.theme??e,onZoomToInterval:m.onIntervalClick??m.onZoomToInterval??y,timezone:m.timezone??R});return q.jsxs("div",{style:{display:"flex"},children:[q.jsx("div",{style:{width:l,flexShrink:0}}),q.jsx("div",{style:{flex:1,overflow:"hidden"},children:H})]})}return h});return q.jsx("div",{className:t,style:{position:"sticky",top:0,zIndex:20,display:"flex",flexDirection:"column",backgroundColor:(e==null?void 0:e.header.bg)??"#F9FAFB",borderTop:`1px solid ${(e==null?void 0:e.header.border)??"#E5E7EB"}`,borderBottom:`1px solid ${(e==null?void 0:e.header.border)??"#E5E7EB"}`,...s},children:v})}ei.displayName="TimelineHeaders";var ti={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(tt,function(){var t="week",n="year";return function(s,d,o){var c=d.prototype;c.week=function(l){if(l===void 0&&(l=null),l!==null)return this.add(7*(l-this.week()),"day");var y=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var R=o(this).startOf(n).add(1,n).date(y),v=o(this).endOf(t);if(R.isBefore(v))return 1}var h=o(this).startOf(n).date(y).startOf(t).subtract(1,"millisecond"),k=this.diff(h,t,!0);return k<0?o(this).startOf("week").week():Math.ceil(k)},c.weeks=function(l){return l===void 0&&(l=null),this.week(l)}}})})(ti);var Ni=ti.exports;const Zi=it(Ni);$e.extend(Zi);const Ui={year:30,month:30,week:20,day:15,hour:30};function ii({unit:i,visibleTimeStart:e=0,visibleTimeEnd:t=0,canvasWidth:n=0,theme:s,height:d=28,className:o,labelFormat:c,onIntervalClick:l,minCellWidth:y,onZoomToInterval:R,timezone:v}){const h=f.useMemo(()=>{if(!e||!t||!n)return[];const S=t-e,m=y??Ui[i];if(m>0){const T=pe(e,v).startOf(i);if((T.add(1,i).valueOf()-T.valueOf())/S*n<m)return[]}const H=[];let X=pe(e,v).startOf(i).subtract(1,i);const x=pe(t,v).add(2,i).valueOf();for(;X.valueOf()<x;){const T=X.add(1,i),D=X.valueOf(),C=T.valueOf(),F=(D-e)/S*n,B=(C-D)/S*n,I=Vi(X,T,i,c);H.push({start:D,end:C,label:I,left:F,width:B}),X=T}return H},[e,t,n,i,c,y,v]),k=f.useCallback((S,m)=>{l?l(S,m):R&&R(S,m)},[l,R]);return h.length===0?null:q.jsx("div",{style:{display:"flex",position:"relative",height:d,overflow:"hidden"},children:h.map(S=>q.jsx("div",{className:o,onClick:()=>k(S.start,S.end),style:{position:"absolute",left:S.left,width:S.width,height:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderRight:`1px solid ${(s==null?void 0:s.header.border)??"#E5E7EB"}`,borderBottom:`1px solid ${(s==null?void 0:s.header.border)??"#E5E7EB"}`,fontSize:12,color:(s==null?void 0:s.header.text)??"#6c737f",backgroundColor:(s==null?void 0:s.header.bg)??"#F9FAFB",overflow:"hidden",whiteSpace:"nowrap",cursor:"pointer",userSelect:"none",padding:"0 4px",boxSizing:"border-box"},children:q.jsx("span",{children:S.label})},S.start))})}ii.displayName="DateHeader";function Vi(i,e,t,n,s){return typeof n=="function"?n(i.toDate(),e.toDate(),t):typeof n=="string"?i.format(n):qi(i,t)}function qi(i,e){switch(e){case"year":return i.format("YYYY");case"month":return i.format("MM");case"week":return`${i.week()}`;case"day":return i.format("D");case"hour":return i.format("HH:mm")}}function ni({width:i,children:e,style:t}){const n=()=>({style:{width:i,...t}});return e?q.jsx(q.Fragment,{children:e({getRootProps:n})}):q.jsx("div",{style:{width:i}})}ni.displayName="SidebarHeader";function ri({children:i}){return q.jsx(q.Fragment,{children:i})}ri.displayName="CustomHeader";exports.CanvasTimeline=Gi;exports.CustomHeader=ri;exports.CustomMarker=Qt;exports.DEFAULT_THEME=Te;exports.DateHeader=ii;exports.HierarchyEngine=Zt;exports.SidebarHeader=ni;exports.TimelineHeaders=ei;exports.TodayMarker=Jt;
|
|
2
2
|
//# sourceMappingURL=canvas-timeline.cjs.js.map
|