UNPKG

dhtmlx-gantt

Version:

An open source JavaScript Gantt chart that helps you illustrate a project schedule in a nice-looking chart.

23 lines (17 loc) 568 kB
(function(bt,W){typeof exports=="object"&&typeof module<"u"?W(exports):typeof define=="function"&&define.amd?define(["exports"],W):W((bt=typeof globalThis<"u"?globalThis:bt||self).dhtmlxgantt={})})(this,function(bt){"use strict";/** @license dhtmlxGantt v.9.0.11 Standard This version of dhtmlxGantt is distributed under GPL 2.0 license and can be legally used in GPL projects. To use dhtmlxGantt in non-GPL projects (and get Pro version of the product), please obtain Individual, Commercial, Enterprise or Ultimate license on our site https://dhtmlx.com/docs/products/dhtmlxGantt/#licensing or contact us at info@dhtmlx.com (c) XB Software */function W(t){var e=0,n=0,i=0,a=0;if(t.getBoundingClientRect){var r=t.getBoundingClientRect(),s=document.body,o=document.documentElement||document.body.parentNode||document.body,l=window.pageYOffset||o.scrollTop||s.scrollTop,d=window.pageXOffset||o.scrollLeft||s.scrollLeft,c=o.clientTop||s.clientTop||0,u=o.clientLeft||s.clientLeft||0;e=r.top+l-c,n=r.left+d-u,i=document.body.offsetWidth-r.right,a=document.body.offsetHeight-r.bottom}else{for(;t;)e+=parseInt(t.offsetTop,10),n+=parseInt(t.offsetLeft,10),t=t.offsetParent;i=document.body.offsetWidth-t.offsetWidth-n,a=document.body.offsetHeight-t.offsetHeight-e}return{y:Math.round(e),x:Math.round(n),width:t.offsetWidth,height:t.offsetHeight,right:Math.round(i),bottom:Math.round(a)}}function En(t){var e=!1,n=!1;if(window.getComputedStyle){var i=window.getComputedStyle(t,null);e=i.display,n=i.visibility}else t.currentStyle&&(e=t.currentStyle.display,n=t.currentStyle.visibility);return e!="none"&&n!="hidden"}function Cn(t){return!isNaN(t.getAttribute("tabindex"))&&1*t.getAttribute("tabindex")>=0}function Dn(t){return!{a:!0,area:!0}[t.nodeName.loLowerCase()]||!!t.getAttribute("href")}function An(t){return!{input:!0,select:!0,textarea:!0,button:!0,object:!0}[t.nodeName.toLowerCase()]||!t.hasAttribute("disabled")}function Et(t){for(var e=t.querySelectorAll(["a[href]","area[href]","input","select","textarea","button","iframe","object","embed","[tabindex]","[contenteditable]"].join(", ")),n=Array.prototype.slice.call(e,0),i=0;i<n.length;i++)n[i].$position=i;for(n.sort(function(r,s){return r.tabIndex===0&&s.tabIndex!==0?1:r.tabIndex!==0&&s.tabIndex===0?-1:r.tabIndex===s.tabIndex?r.$position-s.$position:r.tabIndex<s.tabIndex?-1:1}),i=0;i<n.length;i++){var a=n[i];(Cn(a)||An(a)||Dn(a))&&En(a)||(n.splice(i,1),i--)}return n}function Ce(){var t=document.createElement("div");t.style.cssText="visibility:hidden;position:absolute;left:-1000px;width:100px;padding:0px;margin:0px;height:110px;min-height:100px;overflow-y:scroll;",document.body.appendChild(t);var e=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),Math.max(e,15)}function J(t){if(!t)return"";var e=t.className||"";return e.baseVal&&(e=e.baseVal),e.indexOf||(e=""),ne(e)}function xt(t,e){e&&t.className.indexOf(e)===-1&&(t.className+=" "+e)}function Bt(t,e){e=e.split(" ");for(var n=0;n<e.length;n++){var i=new RegExp("\\s?\\b"+e[n]+"\\b(?![-_.])","");t.className=t.className.replace(i,"")}}function ee(t){return typeof t=="string"?document.getElementById(t)||document.querySelector(t)||document.body:t||document.body}var zt;function De(t,e){zt||(zt=document.createElement("div")),zt.innerHTML=e;var n=zt.firstChild;return t.appendChild(n),n}function Ae(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Ie(t,e){for(var n=t.childNodes,i=n.length,a=[],r=0;r<i;r++){var s=n[r];s.className&&s.className.indexOf(e)!==-1&&a.push(s)}return a}function vt(t){var e;return t.tagName?e=t:(e=(t=t||window.event).target||t.srcElement).shadowRoot&&t.composedPath&&(e=t.composedPath()[0]),e}function tt(t,e){if(e){for(var n=vt(t);n;){if(n.getAttribute&&n.getAttribute(e))return n;n=n.parentNode}return null}}function ne(t){return(String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")}).apply(t)}function _t(t,e,n){var i=vt(t),a="";for(n===void 0&&(n=!0);i;){if(a=J(i)){var r=a.indexOf(e);if(r>=0){if(!n)return i;var s=r===0||!ne(a.charAt(r-1)),o=r+e.length>=a.length||!ne(a.charAt(r+e.length));if(s&&o)return i}}i=i.parentNode}return null}function it(t,e){var n=document.documentElement,i=W(e);return{x:t.clientX+n.scrollLeft-n.clientLeft-i.x+e.scrollLeft,y:t.clientY+n.scrollTop-n.clientTop-i.y+e.scrollTop}}function Me(t,e){const n=W(t),i=W(e);return{x:n.x-i.x,y:n.y-i.y}}function G(t,e){if(!t||!e)return!1;for(;t&&t!=e;)t=t.parentNode;return t===e}function lt(t,e){if(t.closest)return t.closest(e);if(t.matches||t.msMatchesSelector||t.webkitMatchesSelector){var n=t;if(!document.documentElement.contains(n))return null;do{if((n.matches||n.msMatchesSelector||n.webkitMatchesSelector).call(n,e))return n;n=n.parentElement||n.parentNode}while(n!==null&&n.nodeType===1);return null}return console.error("Your browser is not supported"),null}function Ne(t){for(;t;){if(t.offsetWidth>0&&t.offsetHeight>0)return t;t=t.parentElement}return null}function Le(){return document.head.createShadowRoot||document.head.attachShadow}function ie(){var t=document.activeElement;return t.shadowRoot&&(t=t.shadowRoot.activeElement),t===document.body&&document.getSelection&&(t=document.getSelection().focusNode||document.body),t}function kt(t){if(!t||!Le())return document.body;for(;t.parentNode&&(t=t.parentNode);)if(t instanceof ShadowRoot)return t.host;return document.body}const Pe=Object.freeze(Object.defineProperty({__proto__:null,addClassName:xt,closest:lt,getActiveElement:ie,getChildNodes:Ie,getClassName:J,getClosestSizedElement:Ne,getFocusableNodes:Et,getNodePosition:W,getRelativeEventPosition:it,getRelativeNodePosition:Me,getRootNode:kt,getScrollSize:Ce,getTargetNode:vt,hasClass:function(t,e){return"classList"in t?t.classList.contains(e):new RegExp("\\b"+e+"\\b").test(t.className)},hasShadowParent:function(t){return!!kt(t)},insertNode:De,isChildOf:G,isShadowDomSupported:Le,locateAttribute:tt,locateClassName:_t,removeClassName:Bt,removeNode:Ae,toNode:ee},Symbol.toStringTag,{value:"Module"})),K=typeof window<"u"?window:global;let In=class{constructor(t){this._mouseDown=!1,this._touchStarts=!1,this._touchActive=!1,this._longTapTimer=!1,this._gantt=t,this._domEvents=t._createDomEventScope()}attach(t,e,n){const i=this._gantt,a=t.getViewPort();this._originPosition=K.getComputedStyle(a).display,this._restoreOriginPosition=()=>{a.style.position=this._originPosition},this._originPosition==="static"&&(a.style.position="relative");const r=i.$services.getService("state");r.registerProvider("clickDrag",()=>({autoscroll:!1}));let s=null;const o=()=>{s&&(this._mouseDown=!0,t.setStart(i.copy(s)),t.setPosition(i.copy(s)),t.setEnd(i.copy(s)),s=null)};this._domEvents.attach(a,"mousedown",p=>{u(p)});const l=kt(i.$root)||document.body;function d(p){return p.changedTouches&&p.changedTouches[0]||p}this._domEvents.attach(l,"mouseup",p=>{h(p)}),this._domEvents.attach(a,"mousemove",p=>{g(p)}),this._domEvents.attach(a,"touchstart",p=>{this._touchStarts=!0,this._longTapTimer=setTimeout(()=>{this._touchStarts&&(u(d(p)),this._touchStarts=!1,this._touchActive=!0)},this._gantt.config.touch_drag)}),this._domEvents.attach(l,"touchend",p=>{this._touchStarts=!1,this._touchActive=!1,clearTimeout(this._longTapTimer),h(d(p))}),this._domEvents.attach(a,"touchmove",p=>{if(this._touchActive){let y=c();if(y&&i.utils.dom.closest(p.target,y))return;g(d(p)),p.preventDefault()}else this._touchStarts=!1,clearTimeout(this._longTapTimer)});const c=()=>{let p=".gantt_task_line, .gantt_task_link";return n!==void 0&&(p=n instanceof Array?n.join(", "):n),p},u=p=>{s=null;let y=c();y&&i.utils.dom.closest(p.target,y)||(r.registerProvider("clickDrag",()=>({autoscroll:this._mouseDown})),e&&p[e]!==!0||(s=this._getCoordinates(p,t)))},h=p=>{if(s=null,(!e||p[e]===!0)&&this._mouseDown===!0){this._mouseDown=!1;const y=this._getCoordinates(p,t);t.dragEnd(y)}},g=p=>{if(e&&p[e]!==!0)return;const y=this._gantt.ext.clickDrag,v=(this._gantt.config.drag_timeline||{}).useKey;if(y&&v&&!e&&p[v])return;let b=null;if(!this._mouseDown&&s)return b=this._getCoordinates(p,t),void(Math.abs(s.relative.left-b.relative.left)>5&&o());this._mouseDown===!0&&(b=this._getCoordinates(p,t),t.setEnd(b),t.render())}}detach(){const t=this._gantt;this._domEvents.detachAll(),this._restoreOriginPosition&&this._restoreOriginPosition(),t.$services.getService("state").unregisterProvider("clickDrag")}destructor(){this.detach()}_getCoordinates(t,e){const n=e.getViewPort(),i=n.getBoundingClientRect(),{clientX:a,clientY:r}=t;return{absolute:{left:a,top:r},relative:{left:a-i.left+n.scrollLeft,top:r-i.top+n.scrollTop}}}};var Re=function(){this._silent_mode=!1,this.listeners={}};Re.prototype={_silentStart:function(){this._silent_mode=!0},_silentEnd:function(){this._silent_mode=!1}};function at(t){var e=new Re;t.attachEvent=function(n,i,a){n="ev_"+n.toLowerCase(),e.listeners[n]||(e.listeners[n]=function(s){var o={},l=0,d=function(){var c=!0;for(var u in o){var h=o[u].apply(s,arguments);c=c&&h}return c};return d.addEvent=function(c,u){if(typeof c=="function"){var h;if(u&&u.id?h=u.id:(h=l,l++),u&&u.once){var g=c;c=function(){g(),d.removeEvent(h)}}return o[h]=c,h}return!1},d.removeEvent=function(c){delete o[c]},d.clear=function(){o={}},d}(this)),a&&a.thisObject&&(i=i.bind(a.thisObject));var r=n+":"+e.listeners[n].addEvent(i,a);return a&&a.id&&(r=a.id),r},t.attachAll=function(n){this.attachEvent("listen_all",n)},t.callEvent=function(n,i){if(e._silent_mode)return!0;var a="ev_"+n.toLowerCase(),r=e.listeners;return r.ev_listen_all&&r.ev_listen_all.apply(this,[n].concat(i)),!r[a]||r[a].apply(this,i)},t.checkEvent=function(n){return!!e.listeners["ev_"+n.toLowerCase()]},t.detachEvent=function(n){if(n){var i=e.listeners;for(var a in i)i[a].removeEvent(n);var r=n.split(":");if(i=e.listeners,r.length===2){var s=r[0],o=r[1];i[s]&&i[s].removeEvent(o)}}},t.detachAllEvents=function(){for(var n in e.listeners)e.listeners[n].clear()}}var He={second:1,minute:60,hour:3600,day:86400,week:604800,month:2592e3,quarter:7776e3,year:31536e3};function Wt(t){return He[t]||He.hour}function yt(t,e){if(t.forEach)t.forEach(e);else for(var n=t.slice(),i=0;i<n.length;i++)e(n[i],i)}function Mn(t,e){if(t.find)return t.find(e);for(var n=0;n<t.length;n++)if(e(t[n],n))return t[n]}function jt(t,e){if(t.includes)return t.includes(e);for(var n=0;n<t.length;n++)if(t[n]===e)return!0;return!1}function ae(t){return Array.isArray?Array.isArray(t):t&&t.length!==void 0&&t.pop&&t.push}function X(t){return!(!t||typeof t!="object")&&!!(t.getFullYear&&t.getMonth&&t.getDate)}function $t(t){return X(t)&&!isNaN(t.getTime())}function Oe(t,e){var n,i=function(){i.$cancelTimeout(),i.$pending=!0;var a=Array.prototype.slice.call(arguments);n=setTimeout(function(){t.apply(this,a),i.$pending=!1},e)};return i.$pending=!1,i.$cancelTimeout=function(){clearTimeout(n),i.$pending=!1},i.$execute=function(){var a=Array.prototype.slice.call(arguments);t.apply(this,a),i.$cancelTimeout()},i}function rt(t,e){return Be(t)&&!Be(e)&&(t="0"),t}function Be(t){return t===0}function Ct(t,e){for(var n,i,a,r=0,s=t.length-1;r<=s;)if(i=+t[n=Math.floor((r+s)/2)],a=+t[n-1],i<e)r=n+1;else{if(!(i>e)){for(;+t[n]==+t[n+1];)n++;return n}if(!isNaN(a)&&a<e)return n-1;s=n-1}return t.length-1}class Nn{constructor(e,n,i){var a;this._el=document.createElement("div"),this.defaultRender=(r,s)=>{this._el||(this._el=document.createElement("div"));const o=this._el,l=Math.min(r.relative.top,s.relative.top),d=Math.max(r.relative.top,s.relative.top),c=Math.min(r.relative.left,s.relative.left),u=Math.max(r.relative.left,s.relative.left);if(this._singleRow){const h=this._getTaskPositionByTop(this._startPoint.relative.top);o.style.height=h.height+"px",o.style.top=h.top+"px"}else o.style.height=Math.abs(d-l)+"px",o.style.top=l+"px";return o.style.width=Math.abs(u-c)+"px",o.style.left=c+"px",o},this._gantt=n,this._view=i,this._viewPort=e.viewPort,this._el.classList.add(e.className),typeof e.callback=="function"&&(this._callback=e.callback),this.render=()=>{let r;r=e.render?e.render(this._startPoint,this._endPoint):this.defaultRender(this._startPoint,this._endPoint),r!==this._el&&(this._el&&this._el.parentNode&&this._el.parentNode.removeChild(this._el),this._el=r),e.className!==""&&this._el.classList.add(e.className),this.draw()},(a=this._viewPort).attachEvent&&a.detachEvent||at(this._viewPort),this._singleRow=e.singleRow,this._useRequestAnimationFrame=e.useRequestAnimationFrame}draw(){if(this._useRequestAnimationFrame)return requestAnimationFrame(()=>{this._viewPort.appendChild(this.getElement())});this._viewPort.appendChild(this.getElement())}clear(){if(this._useRequestAnimationFrame)return requestAnimationFrame(()=>{this._el.parentNode&&this._viewPort.removeChild(this._el)});this._el.parentNode&&this._viewPort.removeChild(this._el)}getElement(){return this._el}getViewPort(){return this._viewPort}setStart(e){const n=this._gantt;this._startPoint=e,this._startDate=n.dateFromPos(this._startPoint.relative.left),this._viewPort.callEvent("onBeforeDrag",[this._startPoint])}setEnd(e){const n=this._gantt;if(this._endPoint=e,this._singleRow){const i=this._getTaskPositionByTop(this._startPoint.relative.top);this._endPoint.relative.top=i.top}this._endDate=n.dateFromPos(this._endPoint.relative.left),this._startPoint.relative.left>this._endPoint.relative.left&&(this._positionPoint={relative:{left:this._endPoint.relative.left,top:this._positionPoint.relative.top},absolute:{left:this._endPoint.absolute.left,top:this._positionPoint.absolute.top}}),this._startPoint.relative.top>this._endPoint.relative.top&&(this._positionPoint={relative:{left:this._positionPoint.relative.left,top:this._endPoint.relative.top},absolute:{left:this._positionPoint.absolute.left,top:this._endPoint.absolute.top}}),this._viewPort.callEvent("onDrag",[this._startPoint,this._endPoint])}setPosition(e){this._positionPoint=e}dragEnd(e){const n=this._gantt;e.relative.left<0&&(e.relative.left=0),this._viewPort.callEvent("onBeforeDragEnd",[this._startPoint,e]),this.setEnd(e),this._endDate=this._endDate||n.getState().max_date,this._startDate.valueOf()>this._endDate.valueOf()&&([this._startDate,this._endDate]=[this._endDate,this._startDate]),this.clear();const i=n.getTaskByTime(this._startDate,this._endDate),a=this._getTasksByTop(this._startPoint.relative.top,this._endPoint.relative.top);this._viewPort.callEvent("onDragEnd",[this._startPoint,this._endPoint]),this._callback&&this._callback(this._startPoint,this._endPoint,this._startDate,this._endDate,i,a)}getInBounds(){return this._singleRow}_getTasksByTop(e,n){const i=this._gantt;let a=e,r=n;e>n&&(a=n,r=e);const s=this._getTaskPositionByTop(a).index,o=this._getTaskPositionByTop(r).index,l=[];for(let d=s;d<=o;d++)i.getTaskByIndex(d)&&l.push(i.getTaskByIndex(d));return l}_getTaskPositionByTop(e){const n=this._gantt,i=this._view,a=i.getItemIndexByTopPosition(e),r=n.getTaskByIndex(a);if(r){const s=i.getItemHeight(r.id);return{top:i.getItemTop(r.id)||0,height:s||0,index:a}}{const s=i.getTotalHeight();return{top:e>s?s:0,height:n.config.row_height,index:e>s?n.getTaskCount():0}}}}let re=!1;class Ft{constructor(e){this._mouseDown=!1,this._calculateDirectionVector=()=>{if(this._trace.length>=10){const n=this._trace.slice(this._trace.length-10),i=[];for(let r=1;r<n.length;r++)i.push({x:n[r].x-n[r-1].x,y:n[r].y-n[r-1].y});const a={x:0,y:0};return i.forEach(r=>{a.x+=r.x,a.y+=r.y}),{magnitude:Math.sqrt(a.x*a.x+a.y*a.y),angleDegrees:180*Math.atan2(Math.abs(a.y),Math.abs(a.x))/Math.PI}}return null},this._applyDndReadyStyles=()=>{this._timeline.$task.classList.add("gantt_timeline_move_available")},this._clearDndReadyStyles=()=>{this._timeline.$task.classList.remove("gantt_timeline_move_available")},this._getScrollPosition=n=>{const i=this._gantt;return{x:i.$ui.getView(n.$config.scrollX).getScrollState().position,y:i.$ui.getView(n.$config.scrollY).getScrollState().position}},this._countNewScrollPosition=n=>{const i=this._calculateDirectionVector();let a=this._startPoint.x-n.x,r=this._startPoint.y-n.y;return i&&(i.angleDegrees<15?r=0:i.angleDegrees>75&&(a=0)),{x:this._scrollState.x+a,y:this._scrollState.y+r}},this._setScrollPosition=(n,i)=>{const a=this._gantt;requestAnimationFrame(()=>{a.scrollLayoutCell(n.$id,i.x,i.y)})},this._stopDrag=n=>{const i=this._gantt;if(this._trace=[],i.$root.classList.remove("gantt_noselect"),this._originalReadonly!==void 0&&this._mouseDown&&(i.config.readonly=this._originalReadonly,i.config.drag_timeline&&i.config.drag_timeline.render&&i.render()),this._originAutoscroll!==void 0&&(i.config.autoscroll=this._originAutoscroll),i.config.drag_timeline){const{useKey:a}=i.config.drag_timeline;if(a&&n[a]!==!0)return}this._mouseDown=!1,re=!1},this._startDrag=n=>{const i=this._gantt;this._originAutoscroll=i.config.autoscroll,i.config.autoscroll=!1,re=!0,i.$root.classList.add("gantt_noselect"),this._originalReadonly=i.config.readonly,i.config.readonly=!0,i.config.drag_timeline&&i.config.drag_timeline.render&&i.render(),this._trace=[],this._mouseDown=!0;const{x:a,y:r}=this._getScrollPosition(this._timeline);this._scrollState={x:a,y:r},this._startPoint={x:n.clientX,y:n.clientY},this._trace.push(this._startPoint)},this._gantt=e,this._domEvents=e._createDomEventScope(),this._trace=[]}static create(e){return new Ft(e)}static _isDragInProgress(){return re}destructor(){this._domEvents.detachAll()}attach(e){this._timeline=e;const n=this._gantt;this._domEvents.attach(e.$task,"mousedown",i=>{if(!n.config.drag_timeline)return;const{useKey:a,ignore:r,enabled:s}=n.config.drag_timeline;if(s===!1)return;let o=".gantt_task_line, .gantt_task_link";r!==void 0&&(o=r instanceof Array?r.join(", "):r),o&&n.utils.dom.closest(i.target,o)||a&&i[a]!==!0||this._startDrag(i)}),this._domEvents.attach(document,"keydown",i=>{if(!n.config.drag_timeline)return;const{useKey:a}=n.config.drag_timeline;a&&i[a]===!0&&this._applyDndReadyStyles()}),this._domEvents.attach(document,"keyup",i=>{if(!n.config.drag_timeline)return;const{useKey:a}=n.config.drag_timeline;a&&i[a]===!1&&(this._clearDndReadyStyles(),this._stopDrag(i))}),this._domEvents.attach(document,"mouseup",i=>{this._stopDrag(i)}),this._domEvents.attach(n.$root,"mouseup",i=>{this._stopDrag(i)}),this._domEvents.attach(document,"mouseleave",i=>{this._stopDrag(i)}),this._domEvents.attach(n.$root,"mouseleave",i=>{this._stopDrag(i)}),this._domEvents.attach(n.$root,"mousemove",i=>{if(!n.config.drag_timeline)return;const{useKey:a}=n.config.drag_timeline;if(a&&i[a]!==!0)return;const r=this._gantt.ext.clickDrag,s=(this._gantt.config.click_drag||{}).useKey;if((!r||!s||a||!i[s])&&this._mouseDown===!0){this._trace.push({x:i.clientX,y:i.clientY});const o=this._countNewScrollPosition({x:i.clientX,y:i.clientY});this._setScrollPosition(e,o),this._scrollState=o,this._startPoint={x:i.clientX,y:i.clientY}}})}}function Ln(t){(function(){var e=[];function n(){return!!e.length}function i(d){setTimeout(function(){n()||t.$destroyed||t.focus()},1)}function a(d){t.eventRemove(d,"keydown",s),t.event(d,"keydown",s),e.push(d)}function r(){var d=e.pop();d&&t.eventRemove(d,"keydown",s),i()}function s(d){var c=d.currentTarget;c==e[e.length-1]&&t.$keyboardNavigation.trapFocus(c,d)}function o(){a(t.getLightbox())}t.attachEvent("onLightbox",o),t.attachEvent("onAfterLightbox",r),t.attachEvent("onLightboxChange",function(){r(),o()}),t.attachEvent("onAfterQuickInfo",function(){i()}),t.attachEvent("onMessagePopup",function(d){l=t.utils.dom.getActiveElement(),a(d)}),t.attachEvent("onAfterMessagePopup",function(){r(),setTimeout(function(){l&&(l.focus(),l=null)},1)});var l=null;t.$keyboardNavigation.isModal=n})()}class Pn{constructor(e){this.show=(n,i)=>{i===void 0?this._showForTask(n):this._showAtCoordinates(n,i)},this.hide=n=>{const i=this._gantt,a=this._quickInfoBox;this._quickInfoBoxId=0;const r=this._quickInfoTask;if(this._quickInfoTask=null,a&&a.parentNode){if(i.config.quick_info_detached)return i.callEvent("onAfterQuickInfo",[r]),a.parentNode.removeChild(a);a.className+=" gantt_qi_hidden",a.style.right==="auto"?a.style.left="-350px":a.style.right="-350px",n&&(a.style.left=a.style.right="",a.parentNode.removeChild(a)),i.callEvent("onAfterQuickInfo",[r])}},this.getNode=()=>this._quickInfoBox?this._quickInfoBox:null,this.setContainer=n=>{n&&(this._container=typeof n=="string"?document.getElementById(n):n)},this.setContent=n=>{const i=this._gantt,a={taskId:null,header:{title:"",date:""},content:"",buttons:i.config.quickinfo_buttons};n||(n=a),n.taskId||(n.taskId=a.taskId),n.header||(n.header=a.header),n.header.title||(n.header.title=a.header.title),n.header.date||(n.header.date=a.header.date),n.content||(n.content=a.content),n.buttons||(n.buttons=a.buttons);let r=this.getNode();r||(r=this._createQuickInfoElement()),n.taskId&&(this._quickInfoBoxId=n.taskId);const s=r.querySelector(".gantt_cal_qi_title"),o=s.querySelector(".gantt_cal_qi_tcontent"),l=s.querySelector(".gantt_cal_qi_tdate"),d=r.querySelector(".gantt_cal_qi_content"),c=r.querySelector(".gantt_cal_qi_controls");i._waiAria.quickInfoHeader(r,[n.header.title,n.header.date].join(" ")),o.innerHTML=n.header.title,l.innerHTML=n.header.date,n.header.title||n.header.date?s.style.display="":s.style.display="none",d.innerHTML=n.content;const u=n.buttons;u.length?c.style.display="":c.style.display="none";let h="";for(let g=0;g<u.length;g++){const p=i._waiAria.quickInfoButtonAttrString(i.locale.labels[u[g]]);h+=`<div class="gantt_qi_big_icon ${u[g]} dhx_gantt_${u[g]}" title="${i.locale.labels[u[g]]}" ${p}> <div class='dhx_menu_icon dhx_gantt_icon ${u[g]} gantt_menu_icon dhx_gantt_${u[g]}'></div> <div>${i.locale.labels[u[g]]}</div> </div>`}c.innerHTML=h,i.eventRemove(r,"click",this._qiButtonClickHandler),i.eventRemove(r,"keypress",this._qiKeyPressHandler),i.event(r,"click",this._qiButtonClickHandler),i.event(r,"keypress",this._qiKeyPressHandler)},this._qiButtonClickHandler=n=>{this._qi_button_click(n.target)},this._qiKeyPressHandler=n=>{const i=n.which;i!==13&&i!==32||setTimeout(()=>{this._qi_button_click(n.target)},1)},this._gantt=e}_showAtCoordinates(e,n){this.hide(!0),this._quickInfoBoxId=0,this._quickInfoTask=null,this._quickInfoBox||(this._createQuickInfoElement(),this.setContent()),this._appendAtCoordinates(e,n),this._gantt.callEvent("onQuickInfo",[null])}_showForTask(e){const n=this._gantt;if(e===this._quickInfoBoxId&&n.utils.dom.isChildOf(this._quickInfoBox,document.body)||!n.config.show_quick_info)return;this.hide(!0);const i=this._getContainer(),a=this._get_event_counter_part(e,6,i.xViewport,i.yViewport);a&&(this._quickInfoBox=this._init_quick_info(e),this._quickInfoTask=e,this._quickInfoBox.className=this._prepare_quick_info_classname(e),this._fill_quick_data(e),this._show_quick_info(a,6),n.callEvent("onQuickInfo",[e]))}_get_event_counter_part(e,n,i,a){const r=this._gantt;let s=r.getTaskNode(e);if(!s&&(s=r.getTaskRowNode(e),!s))return null;let o=0;const l=n+s.offsetTop+s.offsetHeight;let d=s;if(r.utils.dom.isChildOf(d,i))for(;d&&d!==i;)o+=d.offsetLeft,d=d.offsetParent;const c=r.getScrollState();return d?{left:o,top:l,dx:o+s.offsetWidth/2-c.x>i.offsetWidth/2?1:0,dy:l+s.offsetHeight/2-c.y>a.offsetHeight/2?1:0,width:s.offsetWidth,height:s.offsetHeight}:null}_createQuickInfoElement(){const e=this._gantt,n=document.createElement("div");n.className+="gantt_cal_quick_info",e._waiAria.quickInfoAttr(n);var i=` <div class="gantt_cal_qi_tcontrols"> <a class="gantt_cal_qi_close_btn dhx_gantt_icon dhx_gantt_icon_close"></a> </div> <div class="gantt_cal_qi_title" ${e._waiAria.quickInfoHeaderAttrString()}> <div class="gantt_cal_qi_tcontent"></div> <div class="gantt_cal_qi_tdate"></div> </div> <div class="gantt_cal_qi_content"></div>`;if(i+='<div class="gantt_cal_qi_controls">',i+="</div>",n.innerHTML=i,e.config.quick_info_detached){const a=this._getContainer();e.event(a.parent,"scroll",()=>{this.hide()})}return this._quickInfoBox=n,n}_init_quick_info(e){const n=this._gantt,i=n.getTask(e);return typeof this._quickInfoReadonly=="boolean"&&n.isReadonly(i)!==this._quickInfoReadonly&&(this.hide(!0),this._quickInfoBox=null),this._quickInfoReadonly=n.isReadonly(i),this._quickInfoBox||(this._quickInfoBox=this._createQuickInfoElement()),this._quickInfoBox}_prepare_quick_info_classname(e){const n=this._gantt,i=n.getTask(e);let a=`gantt_cal_quick_info gantt_${n.getTaskType(i)}`;const r=n.templates.quick_info_class(i.start_date,i.end_date,i);return r&&(a+=" "+r),a}_fill_quick_data(e){const n=this._gantt,i=n.getTask(e);this._quickInfoBoxId=e;let a=[];if(this._quickInfoReadonly){const r=n.config.quickinfo_buttons,s={icon_delete:!0,icon_edit:!0};for(let o=0;o<r.length;o++)this._quickInfoReadonly&&s[r[o]]||a.push(r[o])}else a=n.config.quickinfo_buttons;this.setContent({header:{title:n.templates.quick_info_title(i.start_date,i.end_date,i),date:n.templates.quick_info_date(i.start_date,i.end_date,i)},content:n.templates.quick_info_content(i.start_date,i.end_date,i),buttons:a})}_appendAtCoordinates(e,n){const i=this._quickInfoBox,a=this._getContainer();i.parentNode&&i.parentNode.nodeName.toLowerCase()!=="#document-fragment"||a.parent.appendChild(i),i.style.left=e+"px",i.style.top=n+"px"}_show_quick_info(e,n){const i=this._gantt,a=this._quickInfoBox;if(i.config.quick_info_detached){const r=this._getContainer();a.parentNode&&a.parentNode.nodeName.toLowerCase()!=="#document-fragment"||r.parent.appendChild(a);const s=a.offsetWidth,o=a.offsetHeight,l=i.getScrollState(),d=r.xViewport,c=r.yViewport,u=d.offsetWidth+l.x-s,h=e.top-l.y+o;let g=e.top;h>c.offsetHeight/2&&(g=e.top-(o+e.height+2*n),g<l.y&&h<=c.offsetHeight&&(g=e.top)),g<l.y&&(g=l.y);const p=Math.min(Math.max(l.x,e.left-e.dx*(s-e.width)),u),y=g;this._appendAtCoordinates(p,y)}else a.style.top="20px",e.dx===1?(a.style.right="auto",a.style.left="-300px",setTimeout(()=>{a.style.left="10px"},1)):(a.style.left="auto",a.style.right="-300px",setTimeout(()=>{a.style.right="10px"},1)),a.className+=" gantt_qi_"+(e.dx===1?"left":"right"),i.$root.appendChild(a)}_qi_button_click(e){const n=this._gantt,i=this._quickInfoBox;if(!e||e===i)return;if(e.closest(".gantt_cal_qi_close_btn"))return void this.hide();const a=e.className;if(a.indexOf("_icon")!==-1){const r=this._quickInfoBoxId;n.$click.buttons[a.split(" ")[1].replace("icon_","")](r)}else this._qi_button_click(e.parentNode)}_getContainer(){const e=this._gantt;let n=this._container?this._container:e.$task_data;return n&&n.offsetHeight&&n.offsetWidth?{parent:n,xViewport:e.$task,yViewport:e.$task_data}:(n=this._container?this._container:e.$grid_data,n&&n.offsetHeight&&n.offsetWidth?{parent:n,xViewport:e.$grid,yViewport:e.$grid_data}:{parent:this._container?this._container:e.$layout,xViewport:e.$layout,yViewport:e.$layout})}}var se,Rn={}.constructor.toString();function U(t){var e,n;if(t&&typeof t=="object")switch(!0){case X(t):n=new Date(t);break;case ae(t):for(n=new Array(t.length),e=0;e<t.length;e++)n[e]=U(t[e]);break;default:if(function(i){return i.constructor.toString()!==Rn}(t))n=Object.create(t);else{if(function(i){return i.$$typeof&&i.$$typeof.toString().includes("react.")}(t))return n=t;n={}}for(e in t)Object.prototype.hasOwnProperty.apply(t,[e])&&(n[e]=U(t[e]))}return n||t}function P(t,e,n){for(var i in e)(t[i]===void 0||n)&&(t[i]=e[i]);return t}function j(t){return t!==void 0}function st(){return se||(se=new Date().valueOf()),++se}function R(t,e){return t.bind?t.bind(e):function(){return t.apply(e,arguments)}}function ze(t,e,n,i){t.addEventListener?t.addEventListener(e,n,i!==void 0&&i):t.attachEvent&&t.attachEvent("on"+e,n)}function We(t,e,n,i){t.removeEventListener?t.removeEventListener(e,n,i!==void 0&&i):t.detachEvent&&t.detachEvent("on"+e,n)}const Hn=Object.freeze(Object.defineProperty({__proto__:null,bind:R,copy:U,defined:j,event:ze,eventRemove:We,mixin:P,uid:st},Symbol.toStringTag,{value:"Module"}));function oe(t,e){t=t||ze,e=e||We;var n=[],i={attach:function(a,r,s,o){n.push({element:a,event:r,callback:s,capture:o}),t(a,r,s,o)},detach:function(a,r,s,o){e(a,r,s,o);for(var l=0;l<n.length;l++){var d=n[l];d.element===a&&d.event===r&&d.callback===s&&d.capture===o&&(n.splice(l,1),l--)}},detachAll:function(){for(var a=n.slice(),r=0;r<a.length;r++){var s=a[r];i.detach(s.element,s.event,s.callback,s.capture),i.detach(s.element,s.event,s.callback,void 0),i.detach(s.element,s.event,s.callback,!1),i.detach(s.element,s.event,s.callback,!0)}n.splice(0,n.length)},extend:function(){return oe(this.event,this.eventRemove)}};return i}class On{constructor(e){this._gantt=e}getNode(){const e=this._gantt;return this._tooltipNode||(this._tooltipNode=document.createElement("div"),this._tooltipNode.className="gantt_tooltip",e._waiAria.tooltipAttr(this._tooltipNode)),this._tooltipNode}setViewport(e){return this._root=e,this}show(e,n){const i=this._gantt,a=document.body,r=this.getNode();if(G(r,a)||(this.hide(),r.style.top=r.style.top||"0px",r.style.left=r.style.left||"0px",a.appendChild(r)),this._isLikeMouseEvent(e)){const s=this._calculateTooltipPosition(e);n=s.top,e=s.left}return r.style.top=n+"px",r.style.left=e+"px",i._waiAria.tooltipVisibleAttr(r),this}hide(){const e=this._gantt,n=this.getNode();return n&&n.parentNode&&n.parentNode.removeChild(n),e._waiAria.tooltipHiddenAttr(n),this}setContent(e){return this.getNode().innerHTML=e,this}_isLikeMouseEvent(e){return!(!e||typeof e!="object")&&"clientX"in e&&"clientY"in e}_getViewPort(){return this._root||document.body}_calculateTooltipPosition(e){const n=this._gantt,i=this._getViewPortSize(),a=this.getNode(),r={top:0,left:0,width:a.offsetWidth,height:a.offsetHeight,bottom:0,right:0},s=n.config.tooltip_offset_x,o=n.config.tooltip_offset_y,l=document.body,d=it(e,l),c=W(l);d.y+=c.y,r.top=d.y,r.left=d.x,r.top+=o,r.left+=s,r.bottom=r.top+r.height,r.right=r.left+r.width;const u=window.scrollY+l.scrollTop;return r.top<i.top-u?(r.top=i.top,r.bottom=r.top+r.height):r.bottom>i.bottom&&(r.bottom=i.bottom,r.top=r.bottom-r.height),r.left<i.left?(r.left=i.left,r.right=i.left+r.width):r.right>i.right&&(r.right=i.right,r.left=r.right-r.width),d.x>=r.left&&d.x<=r.right&&(r.left=d.x-r.width-s,r.right=r.left+r.width),d.y>=r.top&&d.y<=r.bottom&&(r.top=d.y-r.height-o,r.bottom=r.top+r.height),r}_getViewPortSize(){const e=this._gantt,n=this._getViewPort();let i,a=n,r=window.scrollY+document.body.scrollTop,s=window.scrollX+document.body.scrollLeft;return n===e.$task_data?(a=e.$task,r=0,s=0,i=W(e.$task)):i=W(a),{left:i.x+s,top:i.y+r,width:i.width,height:i.height,bottom:i.y+i.height+r,right:i.x+i.width+s}}}class Bn{constructor(e){this._listeners={},this.tooltip=new On(e),this._gantt=e,this._domEvents=oe(),this._initDelayedFunctions()}destructor(){this.tooltip.hide(),this._domEvents.detachAll()}hideTooltip(){this.delayHide()}attach(e){let n=document.body;const i=this._gantt;e.global||(n=i.$root);let a=null;const r=s=>{const o=vt(s),l=lt(o,e.selector);if(G(o,this.tooltip.getNode()))return;const d=()=>{a=l,e.onmouseenter(s,l)};a?l&&l===a?e.onmousemove(s,l):(e.onmouseleave(s,a),a=null,l&&l!==a&&d()):l&&d()};this.detach(e.selector),this._domEvents.attach(n,"mousemove",r),this._listeners[e.selector]={node:n,handler:r}}detach(e){const n=this._listeners[e];n&&this._domEvents.detach(n.node,"mousemove",n.handler)}tooltipFor(e){const n=i=>{let a=i;return document.createEventObject&&!document.createEvent&&(a=document.createEventObject(i)),a};this._initDelayedFunctions(),this.attach({selector:e.selector,global:e.global,onmouseenter:(i,a)=>{const r=e.html(i,a);r&&this.delayShow(n(i),r)},onmousemove:(i,a)=>{const r=e.html(i,a);r?this.delayShow(n(i),r):(this.delayShow.$cancelTimeout(),this.delayHide())},onmouseleave:()=>{this.delayShow.$cancelTimeout(),this.delayHide()}})}_initDelayedFunctions(){const e=this._gantt;this.delayShow&&this.delayShow.$cancelTimeout(),this.delayHide&&this.delayHide.$cancelTimeout(),this.tooltip.hide(),this.delayShow=Oe((n,i)=>{e.callEvent("onBeforeTooltip",[n])===!1?this.tooltip.hide():(this.tooltip.setContent(i),this.tooltip.show(n))},e.config.tooltip_timeout||1),this.delayHide=Oe(()=>{this.delayShow.$cancelTimeout(),this.tooltip.hide()},e.config.tooltip_hide_timeout||1)}}const je={onBeforeUndo:"onAfterUndo",onBeforeRedo:"onAfterRedo"},Fe=["onTaskDragStart","onAfterTaskUpdate","onAfterParentExpand","onAfterTaskDelete","onBeforeBatchUpdate"];class zn{constructor(e,n){this._batchAction=null,this._batchMode=!1,this._ignore=!1,this._ignoreMoveEvents=!1,this._initialTasks={},this._initialLinks={},this._nestedTasks={},this._nestedLinks={},this._undo=e,this._gantt=n,this._attachEvents()}store(e,n,i=!1){return n===this._gantt.config.undo_types.task?this._storeTask(e,i):n===this._gantt.config.undo_types.link&&this._storeLink(e,i)}isMoveEventsIgnored(){return this._ignoreMoveEvents}toggleIgnoreMoveEvents(e){this._ignoreMoveEvents=e||!1}startIgnore(){this._ignore=!0}stopIgnore(){this._ignore=!1}startBatchAction(){this._timeout||(this._timeout=setTimeout(()=>{this.stopBatchAction(),this._timeout=null},10)),this._ignore||this._batchMode||(this._batchMode=!0,this._batchAction=this._undo.action.create())}stopBatchAction(){if(this._ignore)return;const e=this._undo;this._batchAction&&e.logAction(this._batchAction),this._batchMode=!1,this._batchAction=null}onTaskAdded(e){this._ignore||this._storeTaskCommand(e,this._undo.command.type.add)}onTaskUpdated(e){this._ignore||this._storeTaskCommand(e,this._undo.command.type.update)}onTaskMoved(e){this._ignore||(e.$local_index=this._gantt.getTaskIndex(e.id),this._storeEntityCommand(e,this.getInitialTask(e.id),this._undo.command.type.move,this._undo.command.entity.task))}onTaskDeleted(e){if(!this._ignore){if(this._storeTaskCommand(e,this._undo.command.type.remove),this._nestedTasks[e.id]){const n=this._nestedTasks[e.id];for(let i=0;i<n.length;i++)this._storeTaskCommand(n[i],this._undo.command.type.remove)}if(this._nestedLinks[e.id]){const n=this._nestedLinks[e.id];for(let i=0;i<n.length;i++)this._storeLinkCommand(n[i],this._undo.command.type.remove)}}}onLinkAdded(e){this._ignore||this._storeLinkCommand(e,this._undo.command.type.add)}onLinkUpdated(e){this._ignore||this._storeLinkCommand(e,this._undo.command.type.update)}onLinkDeleted(e){this._ignore||this._storeLinkCommand(e,this._undo.command.type.remove)}setNestedTasks(e,n){const i=this._gantt;let a=null;const r=[];let s=this._getLinks(i.getTask(e));for(let d=0;d<n.length;d++)a=this.setInitialTask(n[d]),s=s.concat(this._getLinks(a)),r.push(a);const o={};for(let d=0;d<s.length;d++)o[s[d]]=!0;const l=[];for(const d in o)l.push(this.setInitialLink(d));this._nestedTasks[e]=r,this._nestedLinks[e]=l}setInitialTask(e,n){const i=this._gantt;if(n||!this._initialTasks[e]||!this._batchMode){const a=i.copy(i.getTask(e));a.$index=i.getGlobalTaskIndex(e),a.$local_index=i.getTaskIndex(e),this.setInitialTaskObject(e,a)}return this._initialTasks[e]}getInitialTask(e){return this._initialTasks[e]}clearInitialTasks(){this._initialTasks={}}setInitialTaskObject(e,n){this._initialTasks[e]=n}setInitialLink(e,n){return this._initialLinks[e]&&this._batchMode||(this._initialLinks[e]=this._gantt.copy(this._gantt.getLink(e))),this._initialLinks[e]}getInitialLink(e){return this._initialLinks[e]}clearInitialLinks(){this._initialLinks={}}_attachEvents(){let e=null;const n=this._gantt,i=()=>{e||(e=setTimeout(()=>{e=null}),this.clearInitialTasks(),n.eachTask(l=>{this.setInitialTask(l.id)}),this.clearInitialLinks(),n.getLinks().forEach(l=>{this.setInitialLink(l.id)}))},a=l=>n.copy(n.getTask(l));for(const l in je)n.attachEvent(l,()=>(this.startIgnore(),!0)),n.attachEvent(je[l],()=>(this.stopIgnore(),!0));for(let l=0;l<Fe.length;l++)n.attachEvent(Fe[l],()=>(this.startBatchAction(),!0));n.attachEvent("onParse",()=>{this._undo.clearUndoStack(),this._undo.clearRedoStack(),i()}),n.attachEvent("onAfterTaskAdd",(l,d)=>{this.setInitialTask(l,!0),this.onTaskAdded(d)}),n.attachEvent("onAfterTaskUpdate",(l,d)=>{this.onTaskUpdated(d)}),n.attachEvent("onAfterParentExpand",(l,d)=>{this.onTaskUpdated(d)}),n.attachEvent("onAfterTaskDelete",(l,d)=>{this.onTaskDeleted(d)}),n.attachEvent("onAfterLinkAdd",(l,d)=>{this.setInitialLink(l,!0),this.onLinkAdded(d)}),n.attachEvent("onAfterLinkUpdate",(l,d)=>{this.onLinkUpdated(d)}),n.attachEvent("onAfterLinkDelete",(l,d)=>{this.onLinkDeleted(d)}),n.attachEvent("onRowDragEnd",(l,d)=>(this.onTaskMoved(a(l)),this.toggleIgnoreMoveEvents(),!0)),n.attachEvent("onBeforeTaskDelete",l=>{this.store(l,n.config.undo_types.task);const d=[];return i(),n.eachTask(c=>{d.push(c.id)},l),this.setNestedTasks(l,d),!0});const r=n.getDatastore("task");r.attachEvent("onBeforeItemMove",(l,d,c)=>(this.isMoveEventsIgnored()||i(),!0)),r.attachEvent("onAfterItemMove",(l,d,c)=>(this.isMoveEventsIgnored()||this.onTaskMoved(a(l)),!0)),n.attachEvent("onRowDragStart",(l,d,c)=>(this.toggleIgnoreMoveEvents(!0),i(),!0));let s=null,o=!1;if(n.attachEvent("onBeforeTaskDrag",l=>{if(s=n.getState().drag_id,s===l){const d=n.getTask(l);n.isSummaryTask(d)&&n.config.drag_project&&(o=!0)}if(n.plugins().multiselect){const d=n.getSelectedTasks();d.length>1&&d.forEach(c=>{this.store(c,n.config.undo_types.task,!0)})}return this.store(l,n.config.undo_types.task)}),n.attachEvent("onAfterTaskDrag",l=>{(o||n.plugins().multiselect&&n.getSelectedTasks().length>1)&&s===l&&(o=!1,s=null,this.stopBatchAction()),this.store(l,n.config.undo_types.task,!0)}),n.attachEvent("onLightbox",l=>this.store(l,n.config.undo_types.task)),n.attachEvent("onBeforeTaskAutoSchedule",l=>(this.store(l.id,n.config.undo_types.task,!0),!0)),n.ext.inlineEditors){let l=null,d=null;n.attachEvent("onGanttLayoutReady",()=>{l&&n.ext.inlineEditors.detachEvent(l),d&&n.ext.inlineEditors.detachEvent(d),d=n.ext.inlineEditors.attachEvent("onEditStart",c=>{this.store(c.id,n.config.undo_types.task)}),l=n.ext.inlineEditors.attachEvent("onBeforeEditStart",c=>(this.stopBatchAction(),!0))})}}_storeCommand(e){const n=this._undo;if(n.updateConfigs(),n.undoEnabled)if(this._batchMode)this._batchAction.commands.push(e);else{const i=n.action.create([e]);n.logAction(i)}}_storeEntityCommand(e,n,i,a){const r=this._undo.command.create(e,n,i,a);this._storeCommand(r)}_storeTaskCommand(e,n){this._gantt.isTaskExists(e.id)&&(e.$local_index=this._gantt.getTaskIndex(e.id)),this._storeEntityCommand(e,this.getInitialTask(e.id),n,this._undo.command.entity.task)}_storeLinkCommand(e,n){this._storeEntityCommand(e,this.getInitialLink(e.id),n,this._undo.command.entity.link)}_getLinks(e){return e.$source.concat(e.$target)}_storeTask(e,n=!1){const i=this._gantt;return this.setInitialTask(e,n),i.eachTask(a=>{this.setInitialTask(a.id)},e),!0}_storeLink(e,n=!1){return this.setInitialLink(e,n),!0}}class Wn{constructor(e){this.maxSteps=100,this.undoEnabled=!0,this.redoEnabled=!0,this.action={create:n=>({commands:n?n.slice():[]}),invert:n=>{const i=this._gantt.copy(n),a=this.command;for(let r=0;r<n.commands.length;r++){const s=i.commands[r]=a.invert(i.commands[r]);s.type!==a.type.update&&s.type!==a.type.move||([s.value,s.oldValue]=[s.oldValue,s.value])}return i}},this.command={entity:null,type:null,create:(n,i,a,r)=>{const s=this._gantt;return{entity:r,type:a,value:s.copy(n),oldValue:s.copy(i||n)}},invert:n=>{const i=this._gantt.copy(n);return i.type=this.command.inverseCommands(n.type),i},inverseCommands:n=>{const i=this._gantt,a=this.command.type;switch(n){case a.update:return a.update;case a.remove:return a.add;case a.add:return a.remove;case a.move:return a.move;default:return i.assert(!1,"Invalid command "+n),null}}},this._undoStack=[],this._redoStack=[],this._gantt=e}getUndoStack(){return this._undoStack}setUndoStack(e){this._undoStack=e}getRedoStack(){return this._redoStack}setRedoStack(e){this._redoStack=e}clearUndoStack(){this._undoStack=[]}clearRedoStack(){this._redoStack=[]}updateConfigs(){const e=this._gantt;this.maxSteps=e.config.undo_steps||100,this.command.entity=e.config.undo_types,this.command.type=e.config.undo_actions,this.undoEnabled=!!e.config.undo,this.redoEnabled=!!e.config.redo}undo(){const e=this._gantt;if(this.updateConfigs(),!this.undoEnabled)return;const n=this._pop(this._undoStack);if(n&&this._reorderCommands(n),e.callEvent("onBeforeUndo",[n])!==!1&&n)return this._applyAction(this.action.invert(n)),this._push(this._redoStack,e.copy(n)),void e.callEvent("onAfterUndo",[n]);e.callEvent("onAfterUndo",[null])}redo(){const e=this._gantt;if(this.updateConfigs(),!this.redoEnabled)return;const n=this._pop(this._redoStack);if(n&&this._reorderCommands(n),e.callEvent("onBeforeRedo",[n])!==!1&&n)return this._applyAction(n),this._push(this._undoStack,e.copy(n)),void e.callEvent("onAfterRedo",[n]);e.callEvent("onAfterRedo",[null])}logAction(e){this._push(this._undoStack,e),this._redoStack=[]}_push(e,n){const i=this._gantt;if(!n.commands.length)return;const a=e===this._undoStack?"onBeforeUndoStack":"onBeforeRedoStack";if(i.callEvent(a,[n])!==!1&&n.commands.length){for(e.push(n);e.length>this.maxSteps;)e.shift();return n}}_pop(e){return e.pop()}_reorderCommands(e){const n={any:0,link:1,task:2},i={move:1,any:0};e.commands.sort(function(a,r){if(a.entity==="task"&&r.entity==="task")return a.type!==r.type?(i[r.type]||0)-(i[a.type]||0):a.type==="move"&&a.oldValue&&r.oldValue&&r.oldValue.parent===a.oldValue.parent?a.oldValue.$index-r.oldValue.$index:0;{const s=n[a.entity]||n.any;return(n[r.entity]||n.any)-s}})}_applyAction(e){let n=null;const i=this.command.entity,a=this.command.type,r=this._gantt,s={};s[i.task]={add:"addTask",get:"getTask",update:"updateTask",remove:"deleteTask",move:"moveTask",isExists:"isTaskExists"},s[i.link]={add:"addLink",get:"getLink",update:"updateLink",remove:"deleteLink",isExists:"isLinkExists"},r.batchUpdate(function(){for(let o=0;o<e.commands.length;o++){n=e.commands[o];const l=s[n.entity][n.type],d=s[n.entity].get,c=s[n.entity].isExists;if(n.type===a.add)r[l](n.oldValue,n.oldValue.parent,n.oldValue.$local_index);else if(n.type===a.remove)r[c](n.value.id)&&r[l](n.value.id);else if(n.type===a.update){const u=r[d](n.value.id);for(const h in n.value){let g=!(h.startsWith("$")||h.startsWith("_"));["$open"].indexOf(h)>-1&&(g=!0),g&&(u[h]=n.value[h])}r[l](n.value.id)}else n.type===a.move&&(r[l](n.value.id,n.value.$local_index,n.value.parent),r.callEvent("onRowDragEnd",[n.value.id]))}})}}const jn={click_drag:function(t){t.ext||(t.ext={});const e={className:"gantt_click_drag_rect",useRequestAnimationFrame:!0,callback:void 0,singleRow:!1};function n(){const i={viewPort:t.$task_data,...e};t.ext.clickDrag&&t.ext.clickDrag.destructor(),t.ext.clickDrag=new In(t);const a=t.config.click_drag;i.render=a.render||e.render,i.className=a.className||e.className,i.callback=a.callback||e.callback,i.viewPort=a.viewPort||t.$task_data,i.useRequestAnimationFrame=a.useRequestAnimationFrame===void 0?e.useRequestAnimationFrame:a.useRequestAnimationFrame,i.singleRow=a.singleRow===void 0?e.singleRow:a.singleRow;const r=t.$ui.getView("timeline"),s=new Nn(i,t,r);t.ext.clickDrag.attach(s,a.useKey,a.ignore)}t.attachEvent("onGanttReady",()=>{t.config.click_drag&&n()}),t.attachEvent("onGanttLayoutReady",function(){t.$container&&t.config.click_drag&&t.attachEvent("onGanttRender",function(){n()},{once:!0})}),t.attachEvent("onDestroy",()=>{t.ext.clickDrag&&t.ext.clickDrag.destructor()})},drag_timeline:function(t){t.ext||(t.ext={}),t.ext.dragTimeline={create:()=>Ft.create(t),_isDragInProgress:()=>Ft._isDragInProgress},t.config.drag_timeline={enabled:!0,render:!1}},fullscreen:function(t){function e(){const c=document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement;return!(!c||c!==document.body)}function n(){try{return document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled}catch(c){console.error("Fullscreen is not available:",c)}}t.$services.getService("state").registerProvider("fullscreen",()=>n()?{fullscreen:e()}:void 0);let i={overflow:null,padding:null,paddingTop:null,paddingRight:null,paddingBottom:null,paddingLeft:null};const a={width:null,height:null,top:null,left:null,position:null,zIndex:null,modified:!1};let r=null;function s(c,u){u.width=c.width,u.height=c.height,u.top=c.top,u.left=c.left,u.position=c.position,u.zIndex=c.zIndex}let o=!1;function l(){if(!t.$container)return;let c;e()?o&&(c="onExpand",function(){const u=t.ext.fullscreen.getFullscreenElement(),h=document.body;s(u.style,a),i={overflow:h.style.overflow,padding:h.style.padding?h.style.padding:null,paddingTop:h.style.paddingTop?h.style.paddingTop:null,paddingRight:h.style.paddingRight?h.style.paddingRight:null,paddingBottom:h.style.paddingBottom?h.style.paddingBottom:null,paddingLeft:h.style.paddingLeft?h.style.paddingLeft:null},h.style.padding&&(h.style.padding="0"),h.style.paddingTop&&(h.style.paddingTop="0"),h.style.paddingRight&&(h.style.paddingRight="0"),h.style.paddingBottom&&(h.style.paddingBottom="0"),h.style.paddingLeft&&(h.style.paddingLeft="0"),h.style.overflow="hidden",u.style.width="100vw",u.style.height="100vh",u.style.top="0px",u.style.left="0px",u.style.position="absolute",u.style.zIndex=1,a.modified=!0,r=function(g){let p=g.parentNode;const y=[];for(;p&&p.style;)y.push({element:p,originalPositioning:p.style.position}),p.style.position="static",p=p.parentNode;return y}(u)}()):o&&(o=!1,c="onCollapse",function(){const u=t.ext.fullscreen.getFullscreenElement(),h=document.body;a.modified&&(i.padding&&(h.style.padding=i.padding),i.paddingTop&&(h.style.paddingTop=i.paddingTop),i.paddingRight&&(h.style.paddingRight=i.paddingRight),i.paddingBottom&&(h.style.paddingBottom=i.paddingBottom),i.paddingLeft&&(h.style.paddingLeft=i.paddingLeft),h.style.overflow=i.overflow,i={overflow:null,padding:null,paddingTop:null,paddingRight:null,paddingBottom:null,paddingLeft:null},s(a,u.style),a.modified=!1),r.forEach(g=>{g.element.style.position=g.originalPositioning}),r=null}()),setTimeout(()=>{t.render()}),setTimeout(()=>{t.callEvent(c,[t.ext.fullscreen.getFullscreenElement()])})}function d(){return!t.$container||!t.ext.fullscreen.getFullscreenElement()?!0:n()?!1:((console.warning||console.log)("The `fullscreen` feature not being allowed, or full-screen mode not being supported"),!0)}t.ext.fullscreen={expand(){if(d()||e()||!t.callEvent("onBeforeExpand",[this.getFullscreenElement()]))return;o=!0;const c=document.body,u=c.webkitRequestFullscreen?[Element.ALLOW_KEYBOARD_INPUT]:[],h=c.msRequestFullscreen||c.mozRequestFullScreen||c.webkitRequestFullscreen||c.requestFullscreen;h&&h.apply(c,u)},collapse(){if(d()||!e()||!t.callEvent("onBeforeCollapse",[this.getFullscreenElement()]))return;const c=document.msExitFullscreen||document.mozCancelFullScreen||document.webkitExitFullscreen||document.exitFullscreen;c&&c.apply(document)},toggle(){d()||(e()?this.collapse():this.expand())},getFullscreenElement:()=>t.$root},t.expand=function(){t.ext.fullscreen.expand()},t.collapse=function(){t.ext.fullscreen.collapse()},t.attachEvent("onGanttReady",function(){t.event(document,"webkitfullscreenchange",l),t.event(document,"mozfullscreenchange",l),t.event(document,"MSFullscreenChange",l),t.event(document,"fullscreenChange",l),t.event(document,"fullscreenchange",l)})},keyboard_navigation:function(t){(function(e){e.config.keyboard_navigation=!0,e.config.keyboard_navigation_cells=!1,e.$keyboardNavigation={},e._compose=function(){for(var n=Array.prototype.slice.call(arguments,0),i={},a=0;a<n.length;a++){var r=n[a];for(var s in typeof r=="function"&&(r=new r),r)i[s]=r[s]}return i},function(n){n.$keyboardNavigation.shortcuts={createCommand:function(){return{modifiers:{shift:!1,alt:!1,ctrl:!1,meta:!1},keyCode:null}},parse:function(i){for(var a=[],r=this.getExpressions(this.trim(i)),s=0;s<r.length;s++){for(var o=this.getWords(r[s]),l=this.createCommand(),d=0;d<o.length;d++)this.commandKeys[o[d]]?l.modifiers[o[d]]=!0:this.specialKeys[o[d]]?l.keyCode=this.specialKeys[o[d]]:l.keyCode=o[d].charCodeAt(0);a.push(l)}return a},getCommandFromEvent:function(i){var a=this.createCommand();a.modifiers.shift=!!i.shiftKey,a.modifiers.alt=!!i.altKey,a.modifiers.ctrl=!!i.ctrlKey,a.modifiers.meta=!!i.metaKey,a.keyCode=i.which||i.keyCode,a.keyCode>=96&&a.keyCode<=105&&(a.keyCode-=48);var r=String.fromCharCode(a.keyCode);return r&&(a.keyCode=r.toLowerCase().charCodeAt(0)),a},getHashFromEvent:function(i){return this.getHash(this.getCommandFromEvent(i))},getHash:function(i){var a=[];for(var r in i.modifiers)i.modifiers[r]&&a.push(r);return a.push(i.keyCode),a.join(this.junctionChar)},getExpressions:function(i){return i.split(this.junctionChar)},getWords:function(i){return i.split(this.combinationChar)},trim:function(i){return i.replace(/\s/g,"")},junctionChar:",",combinationChar:"+",commandKeys:{shift:16,alt:18,ctrl:17,meta:!0},specialKeys:{backspace:8,tab:9,enter:13,esc:27,space:32,up:38,down:40,left:37,right:39,home:36,end:35,pageup:33,pagedown:34,delete:46,insert:45,plus:107,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123}}}(e),function(n){n.$keyboardNavigation.EventHandler={_handlers:null,findHandler:function(i){this._handlers||(this._handlers={});var a=n.$keyboardNavigation.shortcuts.getHash(i);return this._handlers[a]},doAction:function(i,a){var r=this.findHandler(i);if(r){if(n.$keyboardNavigation.facade.callEvent("onBeforeAction",[i,a])===!1)return;r.call(this,a),a.preventDefault?a.preventDefault():a.returnValue=!1}},bind:function(i,a){this._handlers||(this._handlers={});for(var r=n.$keyboardNavigation.shortcuts,s=r.parse(i),o=0;o<s.length;o++)this._handlers[r.getHash(s[o])]=a},unbind:function(i){for(var a=n.$keyboardNavigation.shortcuts,r=a.parse(i),s=0;s<r.length;s++)this._handlers[a.getHash(r[s])]&&delete this._handlers[a.getHash(r[s])]},bindAll:function(i){for(var a in i)this.bind(a,i[a])},initKeys:function(){this._handlers||(this._handlers={}),this.keys&&this.bindAll(this.keys)}}}(e),function(n){n.$keyboardNavigation.getFocusableNodes=Et,n.$keyboardNavigation.trapFocus=function(i,a){if(a.keyCode!=9)return!1;for(var r=n.$keyboardNavigation.getFocusableNodes(i),s=ie(),o=-1,l=0;l<r.length;l++)if(r[l]==s){o=l;break}if(a.shiftKey){if(o<=0){var d=r[r.length-1];if(d)return d.focus(),a