toway-vtable-gantt
Version:
canvas table width high performance
1 lines • 162 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@visactor/vtable/es/vrender"),require("@visactor/vtable")):"function"==typeof define&&define.amd?define(["exports","@visactor/vtable/es/vrender","@visactor/vtable"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VTableGantt={},e.vrender$1,e.vtable$1)}(this,(function(e,t,i){"use strict";var s,a,n;!function(e){e.default="default",e.grabing="grabing",e.scrolling="scrolling"}(s||(s={})),function(e){e.FinishToStart="finish_to_start",e.StartToStart="start_to_start",e.FinishToFinish="finish_to_finish",e.StartToFinish="start_to_finish"}(a||(a={})),function(e){e.Tasks_Separate="tasks_separate",e.Sub_Tasks_Inline="sub_tasks_inline",e.Sub_Tasks_Separate="sub_tasks_separate",e.Sub_Tasks_Arrange="sub_tasks_arrange",e.Sub_Tasks_Compact="sub_tasks_compact"}(n||(n={}));const r={SCROLL:"scroll",CHANGE_DATE_RANGE:"change_date_range",CLICK_TASK_BAR:"click_task_bar",CONTEXTMENU_TASK_BAR:"contextmenu_task_bar",MOUSEENTER_TASK_BAR:"mouseenter_task_bar",MOUSELEAVE_TASK_BAR:"mouseleave_task_bar",CREATE_TASK_SCHEDULE:"create_task_schedule",CREATE_DEPENDENCY_LINK:"create_dependency_link",DELETE_DEPENDENCY_LINK:"delete_dependency_link",CLICK_DEPENDENCY_LINK_POINT:"click_dependency_link_point",CONTEXTMENU_DEPENDENCY_LINK:"contextmenu_dependency_link",CLICK_MARKLINE_CREATE:"click_markline_create",CLICK_MARKLINE_CONTENT:"click_markline_content"};var o=Object.freeze({__proto__:null,get DependencyType(){return a},GANTT_EVENT_TYPE:r,get InteractionState(){return s},get TasksShowMode(){return n}});const l={barColor:"blue",completedBarColor:"gray",width:30,cornerRadius:3,borderWidth:0,fontFamily:"Arial",fontSize:14};const d="undefined"==typeof window||void 0===window.window,h=864e5;function c(e,t){const i=e+t.stateManager.scroll.horizontalBarPos,s=t.getDateColWidth(0);return Math.floor((i-s)/t.parsedOptions.timelineColWidth)+1}function p(e){return e?!0===e?[{date:W().toLocaleDateString(),scrollToMarkLine:!0,position:"left",style:{lineColor:"red",lineWidth:1}}]:Array.isArray(e)?e.map(((e,t)=>({...e,date:e.date,scrollToMarkLine:e.scrollToMarkLine,position:e.position??"left",style:{lineColor:e.style?.lineColor||"red",lineWidth:e.style?.lineWidth||1,lineDash:e.style?.lineDash}}))):[{...e,date:e.date,scrollToMarkLine:e.scrollToMarkLine??!0,position:e.position??"left",style:{lineColor:e.style?.lineColor||"red",lineWidth:e.style?.lineWidth||1,lineDash:e.style?.lineDash}}]:[]}function g(e){const t=e.options;e.parsedOptions.tasksShowMode=t?.tasksShowMode??n.Tasks_Separate,e.parsedOptions.pixelRatio=t?.pixelRatio??1,e.parsedOptions.rowHeight=t?.rowHeight??40,e.parsedOptions.timelineColWidth=t?.timelineHeader?.colWidth??60,e.parsedOptions.startDateField=t.taskBar?.startDateField??"startDate",e.parsedOptions.endDateField=t.taskBar?.endDateField??"endDate",e.parsedOptions.progressField=t.taskBar?.progressField??"progress";const{unit:i,startOfWeek:s,step:a}=e.parsedOptions.reverseSortedTimelineScales[0];e.parsedOptions.minDate=t?.minDate?P(new Date(t.minDate),i,s):void 0,e.parsedOptions.maxDate=t?.maxDate?G(e.parsedOptions.minDate,new Date(t.maxDate),i,a):void 0,e.parsedOptions._minDateTime=e.parsedOptions.minDate?.getTime(),e.parsedOptions._maxDateTime=e.parsedOptions.maxDate?.getTime(),e.parsedOptions.overscrollBehavior=t?.overscrollBehavior??"auto",e.parsedOptions.underlayBackgroundColor=t?.underlayBackgroundColor??"#FFF",e.parsedOptions.scrollStyle=Object.assign({},{scrollRailColor:"rgba(100, 100, 100, 0.2)",scrollSliderColor:"rgba(100, 100, 100, 0.5)",scrollSliderCornerRadius:4,width:10,visible:"always",hoverOn:!0,barToSide:!1},t?.scrollStyle),e.parsedOptions.timelineHeaderHorizontalLineStyle=t?.timelineHeader?.horizontalLine,e.parsedOptions.timelineHeaderVerticalLineStyle=t?.timelineHeader?.verticalLine,e.parsedOptions.timelineHeaderBackgroundColor=t?.timelineHeader?.backgroundColor,e.parsedOptions.timeLineHeaderRowHeights=[],e.parsedOptions.timelineHeaderStyles=[];for(let i=0;i<e.parsedOptions.sortedTimelineScales.length;i++){const s=e.parsedOptions.sortedTimelineScales[i].style;e.parsedOptions.timelineHeaderStyles.push(Object.assign({fontSize:20,fontWeight:"bold",textAlign:"center",textBaseline:"middle",color:"#000",backgroundColor:"#fff"},s)),e.parsedOptions.timeLineHeaderRowHeights.push(e.parsedOptions.sortedTimelineScales[i].rowHeight??t?.headerRowHeight??40)}var r;e.parsedOptions.grid=Object.assign({},t?.grid),r=3*e.parsedOptions.rowHeight/4,l.width=r,e.parsedOptions.taskBarStyle=t?.taskBar?.barStyle&&"function"==typeof t?.taskBar?.barStyle?t.taskBar.barStyle:Object.assign({},l,t?.taskBar?.barStyle),e.parsedOptions.taskBarMilestoneStyle=Object.assign("function"==typeof e.parsedOptions.taskBarStyle?{}:{width:e.parsedOptions.taskBarStyle.width,borderColor:e.parsedOptions.taskBarStyle.borderColor,borderLineWidth:e.parsedOptions.taskBarStyle.borderLineWidth??1,fillColor:e.parsedOptions.taskBarStyle.barColor,cornerRadius:0},t?.taskBar?.milestoneStyle),e.parsedOptions.taskBarMilestoneHypotenuse=e.parsedOptions.taskBarMilestoneStyle.width*Math.sqrt(2),e.parsedOptions.dateFormat=t?.dateFormat,e.parsedOptions.taskBarHoverStyle=Object.assign({barOverlayColor:"rgba(99, 144, 0, 0.4)"},t?.taskBar?.hoverBarStyle),e.parsedOptions.taskBarSelectable=t?.taskBar?.selectable??!0,e.parsedOptions.taskBarSelectedStyle=Object.assign("function"==typeof e.parsedOptions.taskBarStyle?{shadowBlur:6,shadowOffsetX:0,shadowOffsetY:0,borderLineWidth:1}:{shadowBlur:6,shadowOffsetX:0,shadowOffsetY:0,shadowColor:e.parsedOptions.taskBarStyle.barColor,borderColor:e.parsedOptions.taskBarStyle.barColor,borderLineWidth:1},t?.taskBar?.selectedBarStyle),e.parsedOptions.taskBarLabelText=t?.taskBar?.labelText??"",e.parsedOptions.taskBarMoveable=t?.taskBar?.moveable??!0,e.parsedOptions.moveTaskBarToExtendDateRange=t?.taskBar?.moveToExtendDateRange??!0,e.parsedOptions.taskBarResizable=t?.taskBar?.resizable??!0,e.parsedOptions.taskBarDragOrder=t?.taskBar?.dragOrder??!0,e.parsedOptions.taskBarLabelStyle={fontFamily:t?.taskBar?.labelTextStyle?.fontFamily??"Arial",fontSize:t?.taskBar?.labelTextStyle?.fontSize??20,color:t?.taskBar?.labelTextStyle?.color??"#F01",textAlign:t?.taskBar?.labelTextStyle?.textAlign??"left",textBaseline:t?.taskBar?.labelTextStyle?.textBaseline??"middle",padding:t?.taskBar?.labelTextStyle?.padding??[0,0,0,10],textOverflow:t?.taskBar?.labelTextStyle?.textOverflow},e.parsedOptions.taskBarCustomLayout=t?.taskBar?.customLayout,e.parsedOptions.taskBarCreatable=t?.taskBar?.scheduleCreatable??!(e.parsedOptions.tasksShowMode!==n.Sub_Tasks_Separate&&e.parsedOptions.tasksShowMode!==n.Tasks_Separate),e.parsedOptions.taskBarCreationButtonStyle=Object.assign({lineColor:"rgb(99, 144, 0)",lineWidth:1,lineDash:[5,5],cornerRadius:4,backgroundColor:"#FFF"},t?.taskBar?.scheduleCreation?.buttonStyle),e.parsedOptions.taskBarCreationCustomLayout=t?.taskBar?.scheduleCreation?.customLayout,e.parsedOptions.taskBarCreationMaxWidth=t?.taskBar?.scheduleCreation?.maxWidth,e.parsedOptions.taskBarCreationMinWidth=t?.taskBar?.scheduleCreation?.minWidth,e.parsedOptions.outerFrameStyle=Object.assign({borderColor:"#e1e4e8",borderLineWidth:1,cornerRadius:4},t.frame?.outerFrameStyle),e.parsedOptions.markLine=p(t?.markLine),e.parsedOptions.markLine?.length&&(e.parsedOptions.markLine?.every((e=>void 0===e.scrollToMarkLine))&&(e.parsedOptions.markLine[0].scrollToMarkLine=!0),e.parsedOptions.markLine?.find((e=>e.scrollToMarkLine))&&(e.parsedOptions.scrollToMarkLineDate=P(new Date(e.parsedOptions.markLine?.find((e=>e.scrollToMarkLine)).date),i,s))),e.parsedOptions.verticalSplitLineHighlight=t.frame?.verticalSplitLineHighlight,e.parsedOptions.verticalSplitLine=Object.assign({lineColor:e.parsedOptions.outerFrameStyle?.borderColor,lineWidth:e.parsedOptions.outerFrameStyle?.borderLineWidth},t.frame?.verticalSplitLine),e.parsedOptions.horizontalSplitLine=t.frame?.horizontalSplitLine,e.parsedOptions.verticalSplitLineMoveable=t.frame?.verticalSplitLineMoveable,e.parsedOptions.taskKeyField=t.taskKeyField??"id",e.parsedOptions.dependencyLinks=t.dependency?.links??[],e.parsedOptions.dependencyLinkCreatable=t.dependency?.linkCreatable??!1,e.parsedOptions.dependencyLinkSelectable=t.dependency?.linkSelectable??!0,e.parsedOptions.dependencyLinkDeletable=t.dependency?.linkDeletable??!1,e.parsedOptions.dependencyLinkLineStyle=Object.assign({lineColor:"red",lineWidth:1},t.dependency?.linkLineStyle),e.parsedOptions.dependencyLinkSelectedLineStyle=Object.assign({shadowBlur:4,shadowOffset:0,shadowColor:e.parsedOptions.dependencyLinkLineStyle.lineColor,lineColor:e.parsedOptions.dependencyLinkLineStyle.lineColor,lineWidth:e.parsedOptions.dependencyLinkLineStyle.lineWidth},t?.dependency?.linkSelectedLineStyle),e.parsedOptions.dependencyLinkLineCreatePointStyle=Object.assign({strokeColor:"red",fillColor:"white",radius:5,strokeWidth:1},t?.dependency?.linkCreatePointStyle),e.parsedOptions.dependencyLinkLineCreatingPointStyle=Object.assign({strokeColor:"red",fillColor:"red",radius:5,strokeWidth:1},t?.dependency?.linkCreatingPointStyle),e.parsedOptions.dependencyLinkLineCreatingStyle=Object.assign({lineColor:"red",lineWidth:1,lineDash:[5,5]},t?.dependency?.linkCreatingLineStyle),e.parsedOptions.eventOptions=t?.eventOptions,e.parsedOptions.keyboardOptions=t?.keyboardOptions,e.parsedOptions.markLineCreateOptions=t?.markLineCreateOptions}function u(e,t,i){const{unit:s,step:a,format:n}=i,r=[];for(;e<t;)if("day"===s){const i=e.getFullYear(),s=e.getMonth(),o=e.getDate(),l=N(new Date(i,s,o+a-1),!0);l.getTime()>t.getTime()&&l.setTime(t.getTime());const d=e,c=n?.({dateIndex:o,startDate:d,endDate:l}),p=c||o.toString(),g={days:Math.abs(l.getTime()-e.getTime()+1)/h,startDate:d,endDate:l,step:a,unit:"day",title:p,dateIndex:o};r.push(g),e=new Date(i,s,o+a)}else if("month"===s){const i=e.getFullYear(),s=e.getMonth(),o=N(new Date(i,s+a,0),!0);o.getTime()>t.getTime()&&o.setTime(t.getTime());const l=e,d=n?.({dateIndex:s+1,startDate:l,endDate:o}),c=d||(s+1).toString(),p={days:Math.abs(o.getTime()-e.getTime()+1)/h,startDate:l,step:a,unit:"month",endDate:o,title:c,dateIndex:s+1};r.push(p),e=new Date(i,s+a,1)}else if("quarter"===s){const i=e.getFullYear(),s=Math.floor(e.getMonth()/3),o=N(new Date(i,3*(s+a),0),!0);o.getTime()>t.getTime()&&o.setTime(t.getTime());const l=e,d=n?.({dateIndex:s+1,startDate:l,endDate:o}),h=d||(s+1).toString(),c={days:Math.abs(o.getTime()-e.getTime()+1)/864e5,startDate:l,step:a,unit:"quarter",endDate:o,title:h,dateIndex:s+1};r.push(c),e=new Date(i,3*(s+a),1)}else if("year"===s){const i=e.getFullYear(),s=N(new Date(i+a-1,11,31),!0);s.getTime()>t.getTime()&&s.setTime(t.getTime());const o=e,l=n?.({dateIndex:i,startDate:o,endDate:s}),d=l||i.toString(),c={days:Math.abs(s.getTime()-e.getTime()+1)/h,startDate:o,endDate:s,step:a,unit:"year",title:d,dateIndex:i};r.push(c),e=new Date(i+a,0,1)}else if("week"===s){const s=i.startOfWeek??"monday";let o=e.getDay();"monday"===s&&(o=0===o?6:o-1);const l=W(e),d=N(e.getTime()+24*(7*a-o)*60*60*1e3-1,!0);d>t&&d.setTime(t.getTime());const c=A(l),p=n?.({dateIndex:c,startDate:l,endDate:d})||c.toString(),g={days:(d.getTime()-l.getTime()+1)/h,startDate:l,endDate:d,step:a,unit:"week",title:p,dateIndex:c};r.push(g),e.setTime(W(e.getTime()+24*(7*a-o)*60*60*1e3,!0).getTime())}else if("hour"===s){const i=e.getFullYear(),s=e.getMonth(),o=e.getDate(),l=e.getHours(),d=z(new Date(i,s,o,l+a-1),!0);d.getTime()>t.getTime()&&d.setTime(t.getTime());const c=e,p=n?.({dateIndex:l,startDate:c,endDate:d}),g=p||l.toString(),u={days:Math.abs(d.getTime()-e.getTime()+1)/h,startDate:c,endDate:d,step:a,unit:"hour",title:g,dateIndex:e.getHours()};r.push(u),e=new Date(i,s,o,l+a)}else if("minute"===s){const i=e.getFullYear(),s=e.getMonth(),o=e.getDate(),l=e.getHours(),d=e.getMinutes(),c=E(new Date(i,s,o,l,d+a-1),!0);c.getTime()>t.getTime()&&c.setTime(t.getTime());const p=e,g=n?.({dateIndex:d,startDate:p,endDate:c}),u=g||d.toString(),k={days:Math.abs(c.getTime()-e.getTime()+1)/h,startDate:p,endDate:c,step:a,unit:"minute",title:u,dateIndex:e.getMinutes()};r.push(k),e=new Date(i,s,o,l,d+a)}else if("second"===s){const i=e.getFullYear(),s=e.getMonth(),o=e.getDate(),l=e.getHours(),d=e.getMinutes(),c=e.getSeconds(),p=F(new Date(i,s,o,l,d,c+a-1),!0);p.getTime()>t.getTime()&&p.setTime(t.getTime());const g=e,u=n?.({dateIndex:c,startDate:g,endDate:p}),k=u||c.toString(),_={days:Math.abs(p.getTime()-e.getTime()+1)/h,startDate:g,endDate:p,step:a,unit:"second",title:k,dateIndex:e.getSeconds()};r.push(_),e=new Date(i,s,o,l,d,c+a)}return r}function k(e,t,i,s,a){let n=e[3]??10;"right"===t||"end"===t?n=s-0-(e[1]??10):"center"===t&&(n=0+(s-0+(e[3]??10)-(e[1]??10))/2);let r=0+(e[0]??10);return"bottom"===i||"alphabetic"===i||"ideographic"===i?r=a-0-(e[2]??10):"middle"===i&&(r=0+(a-0-(e[0]??10)-(e[2]??10))/2+(e[0]??10)),{x:n,y:r}}function _(e){if(e.verticalSplitResizeLine){e.verticalSplitResizeLine.style.position="absolute",e.verticalSplitResizeLine.style.top=e.tableY+"px",e.verticalSplitResizeLine.style.left=e.taskTableWidth?e.taskTableWidth-7+e.parsedOptions.verticalSplitLine.lineWidth/2+"px":"0px",e.verticalSplitResizeLine.style.width="14px",e.verticalSplitResizeLine.style.height=e.drawHeight+"px",e.verticalSplitResizeLine.style.backgroundColor="rgba(0,0,0,0)",e.verticalSplitResizeLine.style.zIndex="100",e.parsedOptions.verticalSplitLineMoveable&&(e.verticalSplitResizeLine.style.cursor="col-resize"),e.verticalSplitResizeLine.style.userSelect="none",e.verticalSplitResizeLine.style.opacity="1";const t=e.verticalSplitResizeLine.childNodes[0];if(t.style.position="absolute",t.style.top="0px",t.style.left=(14-e.parsedOptions.verticalSplitLine.lineWidth)/2+"px",t.style.width=e.parsedOptions.verticalSplitLine.lineWidth+"px",t.style.height="100%",t.style.backgroundColor=e.parsedOptions.verticalSplitLine.lineColor,t.style.zIndex="100",t.style.userSelect="none",t.style.pointerEvents="none",t.style.transition="background-color 0.3s",e.verticalSplitResizeLine.childNodes[1]){const t=e.verticalSplitResizeLine.childNodes[1];t.style.position="absolute",t.style.top="0px",t.style.left=(14-e.parsedOptions.verticalSplitLineHighlight.lineWidth??2)/2+"px",t.style.width=(e.parsedOptions.verticalSplitLineHighlight.lineWidth??2)+"px",t.style.height="100%",t.style.backgroundColor=e.parsedOptions.verticalSplitLineHighlight.lineColor,t.style.zIndex="100",t.style.cursor="col-resize",t.style.userSelect="none",t.style.pointerEvents="none",t.style.opacity="0",t.style.transition="background-color 0.3s"}}}function b(e,t,i,s="children"){for(let a=0;a<e.length;a++){if(Array.isArray(i)&&1===i.length&&e[a][t]===i[0]||e[a][t]===i)return{record:e[a],index:[a]};if(e[a][s]?.length)if(Array.isArray(i)&&i[0]===e[a][t]){const n=b(e[a][s],t,i.slice(1));if(n)return n.index.unshift(a),n}else if(!Array.isArray(i)){const n=b(e[a][s],t,i);if(n)return n.index.unshift(a),n}}}function m(e,t="children"){for(let i=0;i<e.length;i++)e[i][t]?.length?m(e[i][t],t):(delete e[i].vtable_gantt_linkedTo,delete e[i].vtable_gantt_linkedFrom)}function y(e,t="children"){for(let i=0;i<e.length;i++)e[i][t]?.length?y(e[i][t],t):delete e[i].vtable_gantt_showIndex}function S(e,t){let i,s;if(t.taskListTableInstance){const a=t.taskListTableInstance.getTargetRowAt(e+t.headerHeight);if(a){const{row:r}=a;i=r-t.taskListTableInstance.columnHeaderLevelCount;const o=t.getRowsHeightByIndex(0,i-1);t.parsedOptions.tasksShowMode!==n.Sub_Tasks_Inline&&t.parsedOptions.tasksShowMode!==n.Sub_Tasks_Arrange&&t.parsedOptions.tasksShowMode!==n.Sub_Tasks_Compact&&t.parsedOptions.tasksShowMode!==n.Sub_Tasks_Separate||(s=Math.floor((e-o)/t.parsedOptions.rowHeight))}}else i=Math.floor(e/t.parsedOptions.rowHeight);return{task_index:i,sub_task_index:s}}function T(e,t){if(!t.children||1===t.children.length)return 1===t.children?.length?t.children[0].vtable_gantt_showIndex=0:t.vtable_gantt_showIndex=0,1;const i=t.children.slice().sort(((t,i)=>{const{startDate:s}=x(e,t),{startDate:a}=x(e,i);return s.getTime()-a.getTime()})),s=[];for(let t=0;t<=i.length-1;t++){const a=i[t],{startDate:n,endDate:r}=x(e,a);let o=!1;for(let e=0;e<s.length;e++)if(n.getTime()>s[e]){s[e]=r.getTime(),o=!0,a.vtable_gantt_showIndex=e;break}o||(s.push(r.getTime()),a.vtable_gantt_showIndex=s.length-1)}return s.length}function L(e,t,i,s){return i.some((i=>{const{startDate:a,endDate:n}=x(s,i);return e<=n&&a<=t}))}function f(e,t){if(!t.children||1===t.children.length)return 1===t.children?.length?t.children[0].vtable_gantt_showIndex=0:t.vtable_gantt_showIndex=0,1;const i=[];for(let s=0;s<=t.children.length-1;s++){const a=t.children[s],{startDate:n,endDate:r}=x(e,a);let o=!1;for(let s=0;s<i.length;s++){if(!L(n,r,t.children.filter((e=>e!==a&&e.vtable_gantt_showIndex===s)),e)){i[s]=r.getTime(),o=!0,a.vtable_gantt_showIndex=s;break}}o||(i.push(r.getTime()),a.vtable_gantt_showIndex=i.length-1)}return i.length}function x(e,t){const{timeScaleIncludeHour:i,startDateField:s,endDateField:a}=e.parsedOptions,n=t[s],r=t[a];return i?{startDate:W(n),endDate:N(r)}:{startDate:W(n,!0),endDate:N(r,!0)}}function v(e){const t=e.options;e.parsedOptions.markLine=p(t?.markLine)}function B(e,t){return{left:e.globalTransMatrix.e+t.taskListTableInstance.tableNoFrameWidth+t.taskListTableInstance.tableX+t.tableX,top:e.globalTransMatrix.f,width:e.attribute.width,height:e.attribute.height}}function w(e,t){let i=null;return function(...s){i||(e.apply(this,s),i=setTimeout((()=>{i=null}),t))}}function O(e,t){const i=e.getFullYear().toString(),s=(e.getMonth()+1).toString().padStart(2,"0"),a=e.getDate().toString().padStart(2,"0");if((t=(t=(t=t.replace("yyyy",i)).replace("mm",s)).replace("dd",a)).length>10){const i=e.getHours().toString().padStart(2,"0"),s=e.getMinutes().toString().padStart(2,"0"),a=e.getSeconds().toString().padStart(2,"0");t=(t=(t=t.replace("hh",i)).replace("mm",s)).replace("ss",a)}return t}function D(e,t){const i=t.indexOf("yyyy"),s=t.indexOf("mm"),a=t.indexOf("dd"),n=s<i?s<a?0:1:s<a?1:2,r=a<i?a<s?0:1:a<s?1:2,o=parseInt(e[i<s?i<a?0:1:s<a?1:2],10),l=parseInt(e[n],10)-1,d=parseInt(e[r],10);if(isNaN(o)||o<1)return!1;if(isNaN(l)||l<0||l>11)return!1;const h=[31,M(o)?29:28,31,30,31,30,31,31,30,31,30,31];return!(isNaN(d)||d<1||d>h[l])}function C(e,t){if(t.includes("hh")||t.includes("mm")||t.includes("ss")){const i=t.indexOf("hh")>-1?t.indexOf("hh"):t.indexOf("HH"),s=parseInt(e[i],10),a=parseInt(e[i+1],10),n=e.length>i+2?parseInt(e[i+2],10):0;if(isNaN(s)||s<0||s>23)return!1;if(isNaN(a)||a<0||a>59)return!1;if(isNaN(n)||n<0||n>59)return!1}return!0}function M(e){return e%4==0&&e%100!=0||e%400==0}function I(e){const t=["yyyy-mm-dd","dd-mm-yyyy","mm/dd/yyyy","yyyy/mm/dd","dd/mm/yyyy","yyyy.mm.dd","mm.dd.yyyy","dd.mm.yyyy"],i=["hh:mm:ss","hh:mm"],s=(e=e.trim()).split(" "),a=s[0],n=s[1];let r,o;if(a)for(let e=0;e<t.length;e++){const i=t[e],s=a.split(R(i)),n=D(s,i);if(3===s.length&&n){r=i;break}}if(r&&n)for(let e=0;e<i.length;e++){const t=i[e],s=n.split(R(t)),a=t.split(R(t));if(C(s,t)&&s.length===a.length){o=t;break}}return a&&n&&r&&o?r+" "+o:a&&!n?r:"yyyy-mm-dd hh:mm:ss"}function R(e){const t=e.match(/[^\w]/g);if(t){const e=t.map((e=>"\\"+e)).join("|");return new RegExp(e,"g")}return/[^\w]/}function H(e){return Array.isArray(e)?3===e.length?[e[0],e[1],e[2],e[1]]:2===e.length?[e[0],e[1],e[0],e[1]]:1===e.length?[e[0],e[0],e[0],e[0]]:[e[0],e[1],e[2],e[3]]:[e,e,e,e]}function A(e){const t=new Date(e.getFullYear(),0,1);return Math.ceil(((e.getTime()+1-t.getTime())/864e5+1)/7)}function W(e,t=!1){let i;if(e){if(i=new Date(e),"string"==typeof e){if(e.length>10)return t&&i.setHours(0,0,0,0),i;i.setHours(0,0,0,0)}}else i=new Date;return t&&i.setHours(0,0,0,0),i}function z(e,t=!1){let i;if(e){if(i=new Date(e),"string"==typeof e){if(e.length>10)return t&&i.setMinutes(59,59,999),i;i.setMinutes(59,59,999)}}else i=new Date;return t&&i.setMinutes(59,59,999),i}function E(e,t=!1){let i;if(e){if(i=new Date(e),"string"==typeof e){if(e.length>10)return t&&i.setSeconds(59,999),i;i.setSeconds(59,999)}}else i=new Date;return t&&i.setSeconds(59,999),i}function F(e,t=!1){let i;if(e){if(i=new Date(e),"string"==typeof e){if(e.length>10)return t&&i.setMilliseconds(999),i;i.setMilliseconds(999)}}else i=new Date;return t&&i.setMilliseconds(999),i}function N(e,t=!1){let i;if(e){if(i=new Date(e),"string"==typeof e){if(e.length>10)return t&&i.setHours(23,59,59,999),i;i.setHours(23,59,59,999)}}else i=new Date;return t&&i.setHours(23,59,59,999),i}function G(e,t,i,s){let a=new Date(t);switch(i){case"second":a.setMilliseconds(999);break;case"minute":a.setSeconds(59,999);break;case"hour":a.setMinutes(59,59,999);break;case"day":a.setHours(23,59,59,999);break;case"week":const e=6-a.getDay();a.setDate(a.getDate()+e),a.setHours(23,59,59,999);break;case"month":const t=new Date(a.getFullYear(),a.getMonth()+1,0).getDate();a.setDate(t),a.setHours(23,59,59,999);break;case"quarter":const i=a.getMonth(),s=i-i%3+2,n=new Date(a.getFullYear(),s+1,0).getDate();a.setMonth(s,n),a.setHours(23,59,59,999);break;case"year":a.setMonth(11,31),a.setHours(23,59,59,999);break;default:throw new Error("Invalid time scale")}const n=Y(a,e,i,s,1),r=Math.ceil(n);if(r>n){const e=(r-n)*s,t=1e3,o=60*t,l=60*o,d=24*l,h=7*d;switch(new Date(a.getTime()+1),i){case"second":a.setTime(a.getTime()+e*t);break;case"minute":a.setTime(a.getTime()+e*o);break;case"hour":a.setTime(a.getTime()+e*l);break;case"day":a.setTime(a.getTime()+e*d);break;case"week":a.setTime(a.getTime()+e*h);break;case"month":a=new Date(a.getFullYear(),a.getMonth()+1+Math.round(e),0),a.setHours(23,59,59,999);break;case"quarter":const i=a.getMonth(),s=i-i%3+2;a=new Date(a.getFullYear(),s+Math.round(3*e)+1,0),a.setHours(23,59,59,999);break;case"year":a.setFullYear(a.getFullYear()+Math.floor(e)),a.setHours(23,59,59,999);break;default:throw new Error("Invalid time scale")}}return a}function P(e,t,i="monday"){const s=new Date(e);switch(t){case"second":s.setMilliseconds(0);break;case"minute":s.setSeconds(0,0);break;case"hour":s.setMinutes(0,0,0);break;case"day":s.setHours(0,0,0,0);break;case"week":const e=s.getDay();let t=e;t="monday"===i?0===e?-6:1-e:-e,s.setDate(s.getDate()+t),s.setHours(0,0,0,0);break;case"month":s.setDate(1),s.setHours(0,0,0,0);break;case"quarter":const a=s.getMonth(),n=a-a%3;s.setMonth(n,1),s.setHours(0,0,0,0);break;case"year":s.setMonth(0,1),s.setHours(0,0,0,0);break;default:throw new Error("Invalid time scale")}return s}function Y(e,t,i,s,a=0){const n=36e5,r=864e5;let o;const l=new Date(e.getTime()+a);switch(i){case"second":o=(l.getTime()-t.getTime())/1e3;break;case"minute":o=(l.getTime()-t.getTime())/6e4;break;case"hour":o=(l.getTime()-t.getTime())/n;break;case"day":o=(l.getTime()-t.getTime())/r;break;case"week":o=(l.getTime()-t.getTime())/6048e5;break;case"month":o=12*(l.getFullYear()-t.getFullYear())+(l.getMonth()-t.getMonth()),o+=(l.getDate()-t.getDate())/new Date(l.getFullYear(),l.getMonth()+1,0).getDate();break;case"quarter":o=4*(l.getFullYear()-t.getFullYear())+Math.floor(l.getMonth()/3)-Math.floor(t.getMonth()/3),o+=(l.getTime()-t.getTime())/h/(3*new Date(l.getFullYear(),l.getMonth()+1,0).getDate());break;case"year":o=l.getFullYear()-t.getFullYear(),o+=(l.getMonth()-t.getMonth())/12;break;default:throw new Error("Invalid time scale")}return o/s}class X{gridStyle;scrollLeft;scrollTop;x;y;width;height;rowHeight;rowCount;group;verticalLineGroup;horizontalLineGroup;verticalBackgroundRectsGroup;horizontalBackgroundRectsGroup;allGridHeight;allGridWidth;_scene;constructor(e){this._scene=e,this.scrollLeft=0,this.scrollTop=0,this.x=0,this.y=e._gantt.getAllHeaderRowsHeight(),this.width=e.ganttGroup.attribute.width,this.height=e.ganttGroup.attribute.height-e.timelineHeader.group.attribute.height,this.rowHeight=e._gantt.parsedOptions.rowHeight,this.rowCount=e._gantt.itemCount,this.allGridWidth=e._gantt.getAllDateColsWidth(),this.allGridHeight=e._gantt.getAllTaskBarsHeight(),this.group=new t.Group({x:this.x,y:this.y,width:this.width,height:this.height,clip:!0,fill:e._gantt.parsedOptions.grid?.backgroundColor}),this.group.name="grid-container",e.ganttGroup.addChild(this.group),this.createVerticalBackgroundRects(),this.createHorizontalBackgroundRects(),this.createVerticalLines(),this.createHorizontalLines(),this.createTimeLineHeaderBottomLine()}createTimeLineHeaderBottomLine(){const e=this._scene._gantt.parsedOptions,i=e.horizontalSplitLine?.lineWidth??e.timelineHeaderHorizontalLineStyle?.lineWidth,s=(1&i?-.5:0)+i/2,a=t.createLine({pickable:!1,stroke:e.horizontalSplitLine?.lineColor??e.timelineHeaderHorizontalLineStyle?.lineColor,lineWidth:i+(1&i?1:0),points:[{x:0,y:s},{x:this._scene._gantt.getAllDateColsWidth(),y:s}]});a.name="timeLine-header-bottom-line",this.group.addChild(a)}createVerticalLines(){const e=this._scene._gantt.parsedOptions.grid,i=e.verticalLineDependenceOnTimeScale??this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0].unit;if(e.verticalLine){this.verticalLineGroup=new t.Group({x:0,y:0,width:this.allGridWidth,height:this.allGridHeight}),this.verticalLineGroup.name="grid-vertical",this.group.appendChild(this.verticalLineGroup);const s=this._scene._gantt.parsedOptions.reverseSortedTimelineScales.find((e=>e.unit===i))??this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0],{unit:a,step:n}=this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0],{timelineDates:r}=s,o=this._scene._gantt.parsedOptions.timelineColWidth;if("function"==typeof e.verticalLine)for(let i=0;i<r?.length-1;i++){const{endDate:s}=r[i],l=e.verticalLine({index:i,dateIndex:r[i].dateIndex,date:r[i].endDate,ganttInstance:this._scene._gantt}),d=Math.ceil(Y(s,this._scene._gantt.parsedOptions.minDate,a,n,1)*o)+(1&l.lineWidth?.5:0),h=t.createLine({pickable:!1,stroke:l.lineColor,lineWidth:l.lineWidth,points:[{x:d,y:0},{x:d,y:this.allGridHeight}]});this.verticalLineGroup.appendChild(h)}else{const i=e.verticalLine;for(let e=0;e<r?.length-1;e++){const{endDate:s}=r[e],l=Math.ceil(Y(s,this._scene._gantt.parsedOptions.minDate,a,n,1)*o)+(1&i.lineWidth?.5:0),d=t.createLine({pickable:!1,stroke:i.lineColor,lineWidth:i.lineWidth,points:[{x:l,y:0},{x:l,y:this.allGridHeight}]});this.verticalLineGroup.appendChild(d)}}}}createHorizontalLines(){const e=this._scene._gantt.parsedOptions.grid;if(e.horizontalLine)if(this.horizontalLineGroup=new t.Group({x:0,y:0,width:this.allGridWidth,height:this.allGridHeight}),this.horizontalLineGroup.name="grid-horizontal",this.group.appendChild(this.horizontalLineGroup),"function"==typeof e.horizontalLine){let i=.5;for(let s=0;s<this.rowCount-1;s++){const a=e.horizontalLine({index:s,ganttInstance:this._scene._gantt});i+=this._scene._gantt.getRowHeightByIndex(s);const n=t.createLine({pickable:!1,stroke:a.lineColor,lineWidth:a.lineWidth,points:[{x:0,y:i},{x:this.allGridWidth,y:i}]});this.horizontalLineGroup.appendChild(n)}}else{const i=e.horizontalLine;let s=0;1&i.lineWidth&&(s+=.5);for(let e=0;e<this.rowCount-1;e++){s+=this._scene._gantt.getRowHeightByIndex(e);const a=t.createLine({pickable:!1,stroke:i.lineColor,lineWidth:i.lineWidth,points:[{x:0,y:s},{x:this.allGridWidth,y:s}]});this.horizontalLineGroup.appendChild(a)}}}createVerticalBackgroundRects(){const e=this._scene._gantt.parsedOptions.grid.verticalBackgroundColor,i=this._scene._gantt.parsedOptions.grid.weekendBackgroundColor;if(e||i){this.verticalBackgroundRectsGroup=new t.Group({x:0,y:0,width:this.allGridWidth,height:this.allGridHeight}),this.verticalBackgroundRectsGroup.name="grid-vertical-background",this.group.appendChild(this.verticalBackgroundRectsGroup);const{timelineDates:s,unit:a,step:n}=this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0],r=this._scene._gantt.parsedOptions.timelineColWidth;if(e||i)for(let o=0;o<=s?.length-1;o++){let l;if(!i||"day"!==a||1!==n||0!==s[o].startDate.getDay()&&6!==s[o].startDate.getDay()?"function"==typeof e?l=e({index:o,dateIndex:s[o].dateIndex,date:s[o].endDate,ganttInstance:this._scene._gantt}):e&&(l=e[o%e.length]):l=i,l){const e=Math.ceil(r*o),i=t.createRect({pickable:!1,fill:l,x:e,y:0,width:r,height:this.allGridHeight});this.verticalBackgroundRectsGroup.appendChild(i)}}}}createHorizontalBackgroundRects(){const e=this._scene._gantt.parsedOptions.grid.horizontalBackgroundColor;if(e){this.horizontalBackgroundRectsGroup=new t.Group({x:0,y:0,width:this.allGridWidth,height:this.allGridHeight}),this.horizontalBackgroundRectsGroup.name="grid-horizontal-background",this.group.appendChild(this.horizontalBackgroundRectsGroup);let i=0;for(let s=0;s<=this.rowCount-1;s++){let a;a="function"==typeof e?e({index:s,ganttInstance:this._scene._gantt}):e[s%e.length];const n=t.createRect({pickable:!1,fill:a,x:0,y:i,width:this.allGridWidth,height:this._scene._gantt.getRowHeightByIndex(s)});this.horizontalBackgroundRectsGroup.appendChild(n),i+=this._scene._gantt.getRowHeightByIndex(s)}}}refresh(){this.width=this._scene.ganttGroup.attribute.width,this.height=this._scene.ganttGroup.attribute.height-this._scene.timelineHeader.group.attribute.height,this.group.setAttributes({width:this.width,height:this.height,y:this._scene._gantt.getAllHeaderRowsHeight()}),this.rowCount=this._scene._gantt.itemCount,this.allGridWidth=this._scene._gantt.getAllDateColsWidth(),this.allGridHeight=this._scene._gantt.getAllTaskBarsHeight(),this.group.removeAllChild(),this.createVerticalBackgroundRects(),this.createHorizontalBackgroundRects(),this.createVerticalLines(),this.createHorizontalLines(),this.createTimeLineHeaderBottomLine()}setX(e){this.verticalLineGroup?.setAttribute("x",e),this.horizontalLineGroup?.setAttribute("x",e),this.verticalBackgroundRectsGroup?.setAttribute("x",e),this.horizontalBackgroundRectsGroup?.setAttribute("x",e)}setY(e){this.verticalLineGroup?.setAttribute("y",e),this.horizontalLineGroup?.setAttribute("y",e),this.verticalBackgroundRectsGroup?.setAttribute("y",e),this.horizontalBackgroundRectsGroup?.setAttribute("y",e)}resize(){this.width=this._scene.ganttGroup.attribute.width,this.height=this._scene.ganttGroup.attribute.height-this._scene.timelineHeader.group.attribute.height,this.group.setAttribute("width",this.width),this.group.setAttribute("height",this.height)}}class K{static _mode;static get mode(){return K._mode||(K._mode=function(){let e="browser";try{"node"===window.type?e="node":"undefined"==typeof window||window.performance?"undefined"==typeof window&&(e="node"):e="miniApp"}catch(t){e="node"}return e}()),K._mode}static set mode(e){K._mode=e}static dpr=0;static CreateCanvas;static LoadImage;static RequestAnimationFrame;static CancelAnimationFrame;static RegisterCreateCanvas(e){K.CreateCanvas=e}static RegisterLoadImage(e){K.LoadImage=e}static GetCreateCanvasFunc(){return K.CreateCanvas?K.CreateCanvas:"worker"===K.mode?(e=200,t=200)=>new OffscreenCanvas(e,t):void 0}static RegisterRequestAnimationFrame(e){K.RequestAnimationFrame=e()}static GetRequestAnimationFrame(){if(K.RequestAnimationFrame)return K.RequestAnimationFrame}static RegisterCancelAnimationFrame(e){K.CancelAnimationFrame=e()}static GetCancelAnimationFrame(){if(K.CancelAnimationFrame)return K.CancelAnimationFrame}}var V=e=>null!=e;class j{hScrollBar;vScrollBar;_gantt;_clearHorizontalScrollBar;_clearVerticalScrollBar;constructor(e){this._gantt=e,this.createScrollBar(e.tableNoFrameWidth,e.tableNoFrameHeight-e.getAllHeaderRowsHeight())}createScrollBar(e,i){const s=this._gantt.parsedOptions.scrollStyle.scrollRailColor,a=this._gantt.parsedOptions.scrollStyle.scrollSliderColor,n=this._gantt.parsedOptions.scrollStyle.scrollSliderCornerRadius,r=this._gantt.parsedOptions.scrollStyle.width;let o;o=V(n)?{cornerRadius:n,fill:a}:{fill:a},this._gantt.parsedOptions.scrollStyle?.visible,this._gantt.parsedOptions.scrollStyle?.hoverOn,this.hScrollBar=new t.ScrollBar({direction:"horizontal",x:2*-e,y:2*-i,width:e,height:r,padding:0,railStyle:{fill:s},sliderStyle:o,range:[0,.1],visible:!1}),this.hScrollBar.render(),this.hScrollBar.hideAll(),this.vScrollBar=new t.ScrollBar({direction:"vertical",x:2*-e,y:2*-i,width:r,height:i,padding:0,railStyle:{fill:s},sliderStyle:o,range:[0,.1],visible:!1}),this.vScrollBar.render(),this.vScrollBar.hideAll()}refresh(){}hideVerticalScrollBar(){const e=this._gantt.parsedOptions.scrollStyle.visible;"focus"!==e&&"scrolling"!==e||(this.vScrollBar.setAttribute("visible",!1),this.vScrollBar.hideAll(),this._gantt.scenegraph.updateNextFrame())}showVerticalScrollBar(e){const t=this._gantt.parsedOptions.scrollStyle.visible;"focus"!==t&&"scrolling"!==t||(this.vScrollBar.setAttribute("visible",!0),this.vScrollBar.showAll(),this._gantt.scenegraph.updateNextFrame(),e&&(clearTimeout(this._clearVerticalScrollBar),this._clearVerticalScrollBar=setTimeout((()=>{this.hideVerticalScrollBar()}),1e3)))}hideHorizontalScrollBar(){const e=this._gantt.parsedOptions.scrollStyle.visible;"focus"!==e&&"scrolling"!==e||(this.hScrollBar.setAttribute("visible",!1),this.hScrollBar.hideAll(),this._gantt.scenegraph.updateNextFrame())}showHorizontalScrollBar(e){const t=this._gantt.parsedOptions.scrollStyle.visible;"focus"!==t&&"scrolling"!==t||(this.hScrollBar.setAttribute("visible",!0),this.hScrollBar.showAll(),this._gantt.scenegraph.updateNextFrame(),e&&(clearTimeout(this._clearHorizontalScrollBar),this._clearHorizontalScrollBar=setTimeout((()=>{this.hideHorizontalScrollBar()}),1e3)))}updateVerticalScrollBarPos(e){const t=this.vScrollBar.attribute.range,i=t[1]-t[0],s=e*(1-i);this.vScrollBar.setAttribute("range",[s,s+i]);const a=this.vScrollBar.AABBBounds&&this.vScrollBar.globalAABBBounds;this.vScrollBar._viewPosition={x:a.x1,y:a.y1}}updateHorizontalScrollBarPos(e){const t=this.hScrollBar.attribute.range,i=t[1]-t[0],s=e*(1-i);this.hScrollBar.setAttribute("range",[s,s+i]);const a=this.hScrollBar.AABBBounds&&this.hScrollBar.globalAABBBounds;this.hScrollBar._viewPosition={x:a.x1,y:a.y1}}updateScrollBar(){const e=this._gantt.stateManager.scroll.horizontalBarPos,t=this._gantt.stateManager.scroll.verticalBarPos,i=this._gantt.parsedOptions.scrollStyle,s=i?.width,a=i?.visible,n=Math.ceil(this._gantt.scenegraph.ganttGroup.attribute.width),r=Math.ceil(this._gantt.scenegraph.ganttGroup.attribute.height),o=this._gantt.getAllRowsHeight(),l=this._gantt.getAllDateColsWidth(),d=this._gantt.getAllHeaderRowsHeight();if(l>n){const e=Math.min(r,o),t=Math.max(.05,n/l),d=i.hoverOn;let h=0;h=i.barToSide?this._gantt.tableNoFrameHeight-(d?s:-this._gantt.scenegraph.ganttGroup.attribute.y)+this._gantt.tableY:e-(d?s:-this._gantt.scenegraph.ganttGroup.attribute.y)+this._gantt.tableY,this.hScrollBar.setAttributes({x:this._gantt.scenegraph.ganttGroup.attribute.x,y:h,width:n,range:[0,t],visible:"always"===a});const c=this.hScrollBar.AABBBounds&&this.hScrollBar.globalAABBBounds;this.hScrollBar._viewPosition={x:c.x1,y:c.y1},"always"===a&&this.hScrollBar.showAll()}else this.hScrollBar.setAttributes({x:2*-this._gantt.tableNoFrameWidth,y:2*-this._gantt.tableNoFrameHeight,width:0,visible:!1});if(o>r){const e=Math.min(n,l)+this._gantt.scenegraph.ganttGroup.attribute.x,t=Math.max(.05,(r-d)/(o-d));let i=0;const h=this._gantt.parsedOptions.scrollStyle.hoverOn;i=this._gantt.parsedOptions.scrollStyle.barToSide?this._gantt.tableNoFrameWidth-(h?s:-this._gantt.scenegraph.ganttGroup.attribute.x):e-(h?s:-this._gantt.scenegraph.ganttGroup.attribute.x),this.vScrollBar.setAttributes({x:i,y:d+(h?0:this._gantt.scenegraph.ganttGroup.attribute.y)+this._gantt.tableY,height:r-d,range:[0,t],visible:"always"===a});const c=this.vScrollBar.AABBBounds&&this.vScrollBar.globalAABBBounds;this.vScrollBar._viewPosition={x:c.x1,y:c.y1},"always"===a&&this.vScrollBar.showAll()}else this.vScrollBar.setAttributes({x:2*-this._gantt.tableNoFrameWidth,y:2*-this._gantt.tableNoFrameHeight,height:0,visible:!1});this._gantt.stateManager.setScrollLeft(e),this._gantt.stateManager.setScrollTop(t)}}function U(e,t,i,s=!0){let{deltaX:a,deltaY:n}=e;e.shiftKey&&e.deltaY&&(a=n,n=0);const[r,o]=function(e,t,i){const s=2,a=Math.abs(e/t),n=a<=1/s?0:e,r=a>s?0:t;return[Math.ceil(n*(i.horizontal??0)),Math.ceil(r*(i.vertical??0))]}(a,n,{horizontal:1,vertical:1});r&&(t.setScrollLeft(t.scroll.horizontalBarPos+r),i.scenegraph.scrollbarComponent.showHorizontalScrollBar(!0)),o&&(t.setScrollTop(t.scroll.verticalBarPos+o),i.scenegraph.scrollbarComponent.showVerticalScrollBar(!0)),s&&t.resetInteractionState(),e.cancelable&&("none"===t._gantt.parsedOptions.overscrollBehavior||Math.abs(n)>=Math.abs(a)&&0!==n&&function(e,t){const i=t._gantt.getAllRowsHeight()-t._gantt.scenegraph.height;if(0===i)return!1;return!function(e,t){const i=t._gantt.getAllRowsHeight()-t._gantt.scenegraph.height;return 0!==i&&e<=0&&t.scroll.verticalBarPos<1}(e,t)&&!function(e,t){const i=t._gantt.getAllRowsHeight()-t._gantt.scenegraph.height;return 0!==i&&e>=0&&Math.abs(t.scroll.verticalBarPos-i)<1}(e,t)}(n,t)||Math.abs(n)<=Math.abs(a)&&0!==a&&function(e,t){const i=t._gantt.getAllDateColsWidth()-t._gantt.scenegraph.width;if(0===i)return!1;return!function(e,t){const i=t._gantt.getAllDateColsWidth()-t._gantt.scenegraph.width;return 0!==i&&e<=0&&t.scroll.horizontalBarPos<1}(e,t)&&!function(e,t){const i=t._gantt.getAllDateColsWidth()-t._gantt.scenegraph.width;return 0!==i&&e>=0&&Math.abs(t.scroll.horizontalBarPos-i)<1}(e,t)}(a,t))&&e.preventDefault()}class q{group;_scene;constructor(e){this._scene=e,this.initNodes()}initNodes(){const{_scene:e}=this,i=new t.Group({x:0,y:0,width:e._gantt.getAllDateColsWidth(),height:e._gantt.getAllHeaderRowsHeight(),clip:!0,pickable:!1});this.group=i,i.name="date-header-container",e.ganttGroup.addChild(this.group);const{unit:s,step:a}=e._gantt.parsedOptions.reverseSortedTimelineScales[0];let n=0;for(let r=0;r<e._gantt.timeLineHeaderLevel;r++){const{timelineDates:o,customLayout:l,visible:d}=e._gantt.parsedOptions.sortedTimelineScales[r];if(!1===d)continue;const h=new t.Group({x:0,y:n,width:e._gantt.getAllDateColsWidth(),height:e._gantt.parsedOptions.timeLineHeaderRowHeights[r],clip:!1});n+=h.attribute.height,h.name="row-header",i.addChild(h);for(let i=0;i<o?.length;i++){const{days:n,endDate:d,startDate:c,title:p,dateIndex:g,unit:u}=o[i],_=Math.ceil(Y(c,e._gantt.parsedOptions.minDate,s,a)*e._gantt.parsedOptions.timelineColWidth),b=Math.ceil(Y(d,e._gantt.parsedOptions.minDate,s,a,1)*e._gantt.parsedOptions.timelineColWidth)-_,m=new t.Group({x:_,y:0,width:b,height:h.attribute.height,clip:!1,fill:e._gantt.parsedOptions.timelineHeaderBackgroundColor});let y;m.name="date-header-cell";let S=!0;const T=h.attribute.height;if(l){let e;if("function"==typeof l){e=l({width:b,height:T,index:i,startDate:c,endDate:d,days:n,dateIndex:g,title:p,ganttInstance:this._scene._gantt})}else e=l;e&&(y=e.rootContainer,S=e.renderDefaultText??!1,y.name="task-bar-custom-render"),y&&m.appendChild(y)}if(S){const{padding:i,textAlign:s,textBaseline:a,textOverflow:n,fontSize:o,fontWeight:l,color:d,strokeColor:h,textStick:c}=e._gantt.parsedOptions.timelineHeaderStyles[r],g=k(H(i),s,a,b,T),u=new t.Text({x:g.x,y:g.y,maxLineWidth:b,heightLimit:T,pickable:!0,text:p.toLocaleString(),fontSize:o,fontWeight:l,fill:d,stroke:h,lineWidth:2,textAlign:s,textBaseline:a,ellipsis:"clip"===n?"":"ellipsis"===n?"...":V(n)?n:void 0});u.attribute.textStick=c,m.appendChild(u),u.name="date-header-cell-text"}if(r===e._gantt.timeLineHeaderLevel-1&&e._gantt.parsedOptions.markLineCreateOptions&&e._gantt.parsedOptions.markLineCreateOptions.markLineCreatable){const s=e._gantt.parsedOptions.markLineCreateOptions.markLineCreationStyle||{},a=s.size||24,n=s.iconSize||18,r=s.svg||'<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1471" width="24" height="24"> <path d="M840.05 153.35a27.61875 27.61875 0 0 0-22.95-4.95c-56.25 13.05-218.25 39.6-289.8 2.25-115.65-60.75-241.65-31.95-299.7-13.05V95.75a27.05625 27.05625 0 0 0-27-27 27.05625 27.05625 0 0 0-27 27v834.75c0 14.85 12.15 27 27 27s27-12.15 27-27V611.9c44.1-13.95 199.35-56.25 293.85 1.8 45.9 28.35 96.75 37.8 143.55 37.8 89.1 0 164.7-34.2 169.65-36.45a27.9 27.9 0 0 0 15.75-24.75V174.5a27.5625 27.5625 0 0 0-10.35-21.15z" fill="#f54319" p-id="1472"></path></svg>',l=new t.Group({x:b/2-a/2,y:T/2-a/2,width:a,height:a,visiable:!0});l.name="markline-hover-group",l.data=o[i];const d=new t.Group({x:0,y:0,width:a,height:a,cornerRadius:a/2,fill:s.fill||"#ccc",cursor:"pointer",display:"flex",justifyContent:"center",alignItems:"center",visibleAll:!1});d.name="markline-hover-inner-group",l.add(d);const h=new t.Image({width:n,height:n,image:r,cursor:"pointer",pickable:!0});h.name="markline-hover-icon",d.appendChild(h),m.add(l)}if(h.addChild(m),i>0){const i=t.createLine({pickable:!1,stroke:e._gantt.parsedOptions.timelineHeaderVerticalLineStyle?.lineColor,lineWidth:e._gantt.parsedOptions.timelineHeaderVerticalLineStyle?.lineWidth,points:[{x:1&e._gantt.parsedOptions.timelineHeaderVerticalLineStyle?.lineWidth?.5:0,y:0},{x:1&e._gantt.parsedOptions.timelineHeaderVerticalLineStyle?.lineWidth?.5:0,y:h.attribute.height}]});m.appendChild(i)}}if(r>0){const i=t.createLine({pickable:!1,stroke:e._gantt.parsedOptions.timelineHeaderHorizontalLineStyle?.lineColor,lineWidth:e._gantt.parsedOptions.timelineHeaderHorizontalLineStyle?.lineWidth,points:[{x:0,y:1&e._gantt.parsedOptions.timelineHeaderHorizontalLineStyle?.lineWidth?.5:0},{x:e._gantt.getAllDateColsWidth(),y:1&e._gantt.parsedOptions.timelineHeaderHorizontalLineStyle?.lineWidth?.5:0}]});h.addChild(i)}}}setX(e){this.group.setAttribute("x",e)}setY(e){this.group.setAttribute("y",e)}resize(){this.group.setAttribute("width",this.group.attribute?.width??0),this.group.setAttribute("height",this.group.attribute?.height??0)}refresh(){this.group?.parent.removeChild(this.group),this.initNodes()}showMarklineIcon(e){let t;return e.children.forEach((e=>{"date-header-cell-text"===e.name&&e.setAttribute("visible",!1),"markline-hover-group"===e.name&&(t=e.firstChild,t.setAttribute("visibleAll",!0))})),t}hideMarklineIconHover(e){let t;return e.children.forEach((e=>{"date-header-cell-text"===e.name&&e.setAttribute("visible",!0),"markline-hover-group"===e.name&&(t=e.firstChild,t.setAttribute("visibleAll",!1))})),t}}class $ extends t.Group{clipGroupBox;barRect;progressRect;textLabel;name;task_index;sub_task_index;record;constructor(e){super(e)}}const J='<svg width="100" height="200" xmlns="http://www.w3.org/2000/svg">\n <line x1="30" y1="10" x2="30" y2="190" stroke="black" stroke-width="4"/>\n <line x1="70" y1="10" x2="70" y2="190" stroke="black" stroke-width="4"/>\n</svg>',Q=10;class Z{group;barContainer;hoverBarGroup;creatingDependencyLine;hoverBarLeftIcon;hoverBarRightIcon;_scene;width;height;selectedBorders=[];constructor(e){this._scene=e,this.width=e._gantt.tableNoFrameWidth,this.height=e._gantt.gridHeight,this.group=new t.Group({x:0,y:e._gantt.getAllHeaderRowsHeight(),width:this.width,height:this.height,pickable:!1,clip:!0}),this.group.name="task-bar-container",e.ganttGroup.addChild(this.group),this.initBars(),this.initHoverBarIcons()}initBars(){this.barContainer=new t.Group({x:0,y:0,width:this._scene._gantt.getAllDateColsWidth(),height:this._scene._gantt.getAllTaskBarsHeight(),pickable:!1,clip:!0}),this.group.appendChild(this.barContainer);for(let e=0;e<this._scene._gantt.itemCount;e++)if(this._scene._gantt.parsedOptions.tasksShowMode!==n.Sub_Tasks_Inline&&this._scene._gantt.parsedOptions.tasksShowMode!==n.Sub_Tasks_Separate&&this._scene._gantt.parsedOptions.tasksShowMode!==n.Sub_Tasks_Arrange&&this._scene._gantt.parsedOptions.tasksShowMode!==n.Sub_Tasks_Compact){const t=this.initBar(e);t&&this.barContainer.appendChild(t)}else{const t=this._scene._gantt.getRecordByIndex(e);if(t.children?.length>0)for(let i=0;i<t.children?.length;i++){const s=this.initBar(e,i,t.children.length);s&&this.barContainer.appendChild(s)}else{const t=this.initBar(e);t&&this.barContainer.appendChild(t)}}}initBar(e,i,s){const a=this._scene._gantt.parsedOptions.taskBarCustomLayout,{startDate:r,endDate:o,taskDays:l,progress:d,taskRecord:h}=this._scene._gantt.getTaskInfoByTaskListIndex(e,i),c="milestone"===h.type;if(c&&!r||!c&&(l<=0||!r||!o||r.getTime()>o.getTime()))return null;const{unit:p,step:g}=this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0],u=Y(o,r,p,g,1)*this._scene._gantt.parsedOptions.timelineColWidth,_=this._scene._gantt.getTaskBarStyle(e,i),b=_.width;W(this._scene._gantt.parsedOptions.minDate),this._scene._gantt.parsedOptions.tasksShowMode===n.Sub_Tasks_Separate||(this._scene._gantt.parsedOptions.tasksShowMode===n.Sub_Tasks_Arrange?f(this._scene._gantt,this._scene._gantt.records[e]):this._scene._gantt.parsedOptions.tasksShowMode!==n.Sub_Tasks_Compact||T(this._scene._gantt,this._scene._gantt.records[e]));const m=this._scene._gantt.parsedOptions.rowHeight,y=this._scene._gantt.parsedOptions.taskBarMilestoneStyle.width,S=Y(r,this._scene._gantt.parsedOptions.minDate,p,g)*this._scene._gantt.parsedOptions.timelineColWidth-(c?y/2:0),L=this._scene._gantt.getRowsHeightByIndex(0,e-1)+(this._scene._gantt.parsedOptions.tasksShowMode===n.Sub_Tasks_Separate?(i??0)*m:this._scene._gantt.parsedOptions.tasksShowMode===n.Sub_Tasks_Arrange||this._scene._gantt.parsedOptions.tasksShowMode===n.Sub_Tasks_Compact?h.vtable_gantt_showIndex*m:0)+(m-(c?y:b))/2,x=new $({x:S,y:L,width:c?y:u,height:c?y:b,cornerRadius:c?this._scene._gantt.parsedOptions.taskBarMilestoneStyle.cornerRadius:_.cornerRadius,lineWidth:c?2*this._scene._gantt.parsedOptions.taskBarMilestoneStyle.borderLineWidth:2*(_.borderLineWidth??_.borderWidth),stroke:c?this._scene._gantt.parsedOptions.taskBarMilestoneStyle.borderColor:_.borderColor,angle:c?.25*Math.PI:0,anchor:c?[S+y/2,L+y/2]:void 0});x.name="task-bar",x.task_index=e,x.sub_task_index=i,x.record=h;const v=new t.Group({x:0,y:0,width:x.attribute.width,height:x.attribute.height,cornerRadius:c?this._scene._gantt.parsedOptions.taskBarMilestoneStyle.cornerRadius:_.cornerRadius,clip:!0});let B;v.name="task-bar-group",x.appendChild(v),x.clipGroupBox=v;let w=!0,O=!0;if(a){let t;if("function"==typeof a){t=a({width:u,height:b,index:e,startDate:r,endDate:o,taskDays:l,progress:d,taskRecord:h,ganttInstance:this._scene._gantt})}else t=a;t&&(B=t.rootContainer,w=t.renderDefaultBar??!1,O=t.renderDefaultText??!1,B&&(B.name="task-bar-custom-render"))}if(w){const e=t.createRect({x:0,y:0,width:x.attribute.width,height:x.attribute.height,fill:c?this._scene._gantt.parsedOptions.taskBarMilestoneStyle.fillColor:_.barColor,pickable:!1});if(e.name="task-bar-rect",v.appendChild(e),x.barRect=e,"milestone"!==h.type){const e=t.createRect({x:0,y:0,width:u*d/100,height:b,fill:_.completedBarColor,pickable:!1});e.name="task-bar-progress-rect",v.appendChild(e),x.progressRect=e}}if(B&&v.appendChild(B),O&&"milestone"!==h.type){const{textAlign:e,textBaseline:i,fontSize:s,fontFamily:a,textOverflow:n,color:r,padding:o}=this._scene._gantt.parsedOptions.taskBarLabelStyle,l=k(H(o),e,i,u,b),d=t.createText({x:l.x,y:l.y,fontSize:s,fill:r,fontFamily:a,text:(D=this._scene._gantt.parsedOptions.taskBarLabelText,C=h,D.replace(/\{([^}]+)\}/g,((e,t)=>{const i=t.split(".");let s=C;for(const t of i){if(!s.hasOwnProperty(t)){s=e;break}s=s[t]}return s}))),maxLineWidth:u-Q,textBaseline:i,textAlign:e,ellipsis:"clip"===n?"":"ellipsis"===n?"...":V(n)?n:void 0,poptip:{position:"bottom",dx:(u-Q)/4}});v.appendChild(d),x.textLabel=d}var D,C;return x}updateTaskBarNode(e,t){const i=this.getTaskBarNodeByIndex(e,t);i&&this.barContainer.removeChild(i);const s=this.initBar(e,t);s&&this.barContainer.insertInto(s,e)}initHoverBarIcons(){const e=new t.Group({x:0,y:0,width:100,height:100,clip:!0,pickable:!1,cornerRadius:this._scene._gantt.parsedOptions.taskBarHoverStyle.cornerRadius??l.cornerRadius??0,fill:this._scene._gantt.parsedOptions.taskBarHoverStyle.barOverlayColor,visibleAll:!1});if(this.hoverBarGroup=e,e.name="task-bar-hover-shadow",this._scene._gantt.parsedOptions.taskBarResizable){const i=new t.Image({x:0,y:0,width:Q,height:20,image:J,pickable:!0,cursor:"col-resize"});i.name="task-bar-hover-shadow-left-icon",this.hoverBarLeftIcon=i,e.appendChild(i);const s=new t.Image({x:0,y:0,width:Q,height:20,image:J,pickable:!0,cursor:"col-resize"});s.name="task-bar-hover-shadow-right-icon",this.hoverBarRightIcon=s,e.appendChild(s)}}setX(e){this.barContainer.setAttribute("x",e)}setY(e){this.barContainer.setAttribute("y",e)}refresh(){this.width=this._scene._gantt.tableNoFrameWidth,this.height=this._scene._gantt.gridHeight,this.group.setAttributes({height:this.height,width:this.width,y:this._scene._gantt.getAllHeaderRowsHeight()});const e=this.barContainer.attribute.x,t=this.barContainer.attribute.y;this.barContainer.removeAllChild(),this.group.removeChild(this.barContainer),this.initBars(),this.setX(e),this.setY(t)}resize(){this.width=this._scene._gantt.tableNoFrameWidth,this.height=this._scene._gantt.gridHeight,this.group.setAttribute("width",this.width),this.group.setAttribute("height",this.height)}showHoverBar(e,t,i,s,a){const{startDate:n,endDate:r,taskRecord:o}=this._scene._gantt.getTaskInfoByTaskListIndex(a.task_index,a.sub_task_index);a&&"task-bar"===a.name&&a.appendChild(this.hoverBarGroup),this.hoverBarGroup.setAttribute("x",0),this.hoverBarGroup.setAttribute("y",0),this.hoverBarGroup.setAttribute("width",i),this.hoverBarGroup.setAttribute("height",s),this.hoverBarGroup.setAttribute("visibleAll",!0);const l=this._scene._gantt.getTaskBarStyle(a.task_index,a.sub_task_index);if("milestone"===o.type)this.hoverBarGroup.setAttribute("cornerRadius",a.attribute.cornerRadius);else{const e=this._scene._gantt.parsedOptions.taskBarHoverStyle.cornerRadius??l.cornerRadius??0;this.hoverBarGroup.setAttribute("cornerRadius",e)}this.hoverBarLeftIcon?.setAttribute("visible",!1),this.hoverBarRightIcon?.setAttribute("visible",!1);let d=!0,h=!0;if("milestone"===o.type)d=!1,h=!1;else if("function"==typeof this._scene._gantt.parsedOptions.taskBarResizable){const e={index:a.task_index,startDate:n,endDate:r,taskRecord:o,ganttInstance:this._scene._gantt},t=this._scene._gantt.parsedOptions.taskBarResizable(e);Array.isArray(t)?[d,h]=t:(d=t,h=t)}else Array.isArray(this._scene._gantt.parsedOptions.taskBarResizable)?[d,h]=this._scene._gantt.parsedOptions.taskBarResizable:(d=this._scene._gantt.parsedOptions.taskBarResizable,h=this._scene._gantt.parsedOptions.taskBarResizable);d&&this.hoverBarLeftIco