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