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