suivi-dhx-trial-gantt
Version:
An open source JavaScript Gantt chart that helps you illustrate a project schedule in a nice-looking chart.
11 lines (8 loc) • 669 kB
JavaScript
(function(St,It){typeof exports=="object"&&typeof module<"u"?It(exports):typeof define=="function"&&define.amd?define(["exports"],It):It((St=typeof globalThis<"u"?globalThis:St||self).dhtmlxgantt={})})(this,function(St){"use strict";/** @license
dhtmlxGantt v.9.0.7 Professional Evaluation
This software is covered by DHTMLX Evaluation License. Contact sales@dhtmlx.com to get a proprietary license. Usage without proper license is prohibited.
(c) XB Software
*/function It(t){t.config.auto_scheduling_use_progress=!1,t.config.auto_scheduling_project_constraint=!1}function en(t){t._get_linked_task=function(s,l){var d=null,u=l?s.target:s.source;return t.isTaskExists(u)&&(d=t.getTask(u)),d},t._get_link_target=function(s){return t._get_linked_task(s,!0)},t._get_link_source=function(s){return t._get_linked_task(s,!1)};var n=!1,e={},i={},a={},r={};function o(s){return t.isSummaryTask(s)&&s.auto_scheduling===!1}t._isLinksCacheEnabled=function(){return n},t._startLinksCache=function(){e={},i={},a={},r={},n=!0},t._endLinksCache=function(){e={},i={},a={},r={},n=!1},t._formatLink=function(s,l,d){if(n&&e[s.id])return e[s.id];var u=[],c=this._get_link_target(s),h=this._get_link_source(s);if(!h||!c||t.isSummaryTask(c)&&t.isChildOf(h.id,c.id)||t.isSummaryTask(h)&&t.isChildOf(c.id,h.id))return u;var _=t.config.schedule_from_end&&t.config.project_end,f=t.config.auto_scheduling_move_projects;!t.config.auto_scheduling_compatibility&&t.config.auto_scheduling_strict&&(f=!1),l=l||this.isSummaryTask(h)&&!o(h)?this.getSubtaskDates(h.id):{start_date:h.start_date,end_date:h.end_date};var k=this._getImplicitLinks(s,h,function(S){return f&&_?S.$source.length||t.getState("tasksDnd").drag_id==S.id?0:t.calculateDuration({start_date:S.end_date,end_date:l.end_date,task:h}):0},!0);d||(d={start_date:c.start_date,end_date:c.end_date},this.isSummaryTask(c)&&!o(c)&&((d=this.getSubtaskDates(c.id)).start_date=d.end_date,this.eachTask(function(S){S.type!==this.config.types.project&&!S.$target.length&&S.start_date<d.start_date&&(d.start_date=S.start_date)},c.id)));for(var m=this._getImplicitLinks(s,c,function(S){return!f||_||S.$target.length||t.getState("tasksDnd").drag_id==S.id?0:t.calculateDuration({start_date:d.start_date,end_date:S.start_date,task:c})}),b=0,g=k.length;b<g;b++)for(var v=k[b],p=0,y=m.length;p<y;p++){var w=m[p],$=1*v.lag+1*w.lag,x={id:s.id,type:s.type,source:v.task,target:w.task,subtaskLink:v.subtaskLink,lag:(1*s.lag||0)+$};t._linkedTasks[x.target]=t._linkedTasks[x.target]||{},t._linkedTasks[x.target][x.source]=!0,u.push(t._convertToFinishToStartLink(w.task,x,h,c,v.taskParent,w.taskParent))}return n&&(e[s.id]=u),u},t._isAutoSchedulable=function(s){if(!(s.auto_scheduling!==!1&&s.unscheduled!==!0))return!1;if(this.isSummaryTask(s)){let l=!0;if(this.eachTask(function(d){l&&t._isAutoSchedulable(d)&&(l=!1)},s.id),l)return!1}return!0},t._getImplicitLinks=function(s,l,d,u){var c=[];if(this.isSummaryTask(l)&&!o(l)){var h,_={};for(var f in this.eachTask(function(y){this.isSummaryTask(y)&&!o(y)||(_[y.id]=y)},l.id),_){var k=_[f];if(t._isAutoSchedulable(k)){var m=u?k.$source:k.$target;h=!1;for(var b=0;b<m.length&&s.type!=t.config.links.start_to_start&&s.type!=t.config.links.start_to_finish;b++){var g=t.getLink(m[b]),v=u?g.target:g.source,p=_[v];if(p&&t._isAutoSchedulable(k)&&t._isAutoSchedulable(p)){let y=0;if(g.lag&&(y=Math.abs(g.lag)),g.type!=t.config.links.finish_to_start){y+=t._convertToFinishToStartLink(null,{},k,p).additionalLag;continue}const w=g.target==p.id&&y&&y<=p.duration,$=g.target==k.id&&y&&y<=k.duration;if(w||$){h=!0;break}}}if(!h){let y=!0;for(const $ in t._linkedTasks[k.id])if(t.isChildOf($,s.target)){y=!1;break}let w=0;y&&(w=d(k)),c.push({task:k.id,taskParent:k.parent,lag:w,subtaskLink:!0})}}}}else c.push({task:l.id,taskParent:l.parent,lag:0});return c},t._getDirectDependencies=function(s,l){t._linkedTasks=t._linkedTasks||{};for(var d=[],u=[],c=l?s.$source:s.$target,h=0;h<c.length;h++){var _=this.getLink(c[h]);if(this.isTaskExists(_.source)&&this.isTaskExists(_.target)){var f=this.getTask(_.target);if(!this._isAutoSchedulable(f)||!this._isAutoSchedulable(s))continue;if(t.config.auto_scheduling_use_progress){if(f.progress==1)continue;d.push(_)}else d.push(_)}}for(h=0;h<d.length;h++)u=u.concat(this._formatLink(d[h]));return u},t._getInheritedDependencies=function(s,l){var d,u=!1,c=[];return this.isTaskExists(s.id)&&this.eachParent(function(h){var _;u||(n&&(d=l?i:a)[h.id]?c=c.concat(d[h.id]):this.isSummaryTask(h)&&(this._isAutoSchedulable(h)?(_=this._getDirectDependencies(h,l),n&&(d[h.id]=_),c=c.concat(_)):u=!0))},s.id,this),c},t._getDirectSuccessors=function(s){return this._getDirectDependencies(s,!0)},t._getInheritedSuccessors=function(s){return this._getInheritedDependencies(s,!0)},t._getDirectPredecessors=function(s){return this._getDirectDependencies(s,!1)},t._getInheritedPredecessors=function(s){return this._getInheritedDependencies(s,!1)},t._getSuccessors=function(s,l){var d=this._getDirectSuccessors(s);return l?d:d.concat(this._getInheritedSuccessors(s))},t._getPredecessors=function(s,l){var d,u=String(s.id)+"-"+String(l);if(n&&r[u])return r[u];var c=this._getDirectPredecessors(s);return d=l?c:c.concat(this._getInheritedPredecessors(s)),n&&(r[u]=d),d},t._convertToFinishToStartLink=function(s,l,d,u,c,h){var _={target:s,link:t.config.links.finish_to_start,id:l.id,lag:l.lag||0,sourceLag:0,targetLag:0,trueLag:l.lag||0,source:l.source,preferredStart:null,sourceParent:c,targetParent:h,hashSum:null,subtaskLink:l.subtaskLink},f=0;switch(String(l.type)){case String(t.config.links.start_to_start):f=-d.duration,_.sourceLag=f;break;case String(t.config.links.finish_to_finish):f=-u.duration,_.targetLag=f;break;case String(t.config.links.start_to_finish):f=-d.duration-u.duration,_.sourceLag=-d.duration,_.targetLag=-u.duration;break;default:f=0}return _.lag+=f,_.hashSum=_.lag+"_"+_.link+"_"+_.source+"_"+_.target,_}}var nn={second:1,minute:60,hour:3600,day:86400,week:604800,month:2592e3,quarter:7776e3,year:31536e3};function Jt(t){return nn[t]||nn.hour}function st(t,n){if(t.forEach)t.forEach(n);else for(var e=t.slice(),i=0;i<e.length;i++)n(e[i],i)}function fe(t,n){if(t.find)return t.find(n);for(var e=0;e<t.length;e++)if(n(t[e],e))return t[e]}function Kt(t,n){if(t.includes)return t.includes(n);for(var e=0;e<t.length;e++)if(t[e]===n)return!0;return!1}function Lt(t){return Array.isArray?Array.isArray(t):t&&t.length!==void 0&&t.pop&&t.push}function nt(t){return!(!t||typeof t!="object")&&!!(t.getFullYear&&t.getMonth&&t.getDate)}function Tt(t){return nt(t)&&!isNaN(t.getTime())}function Xt(t,n){var e,i=function(){i.$cancelTimeout(),i.$pending=!0;var a=Array.prototype.slice.call(arguments);e=setTimeout(function(){t.apply(this,a),i.$pending=!1},n)};return i.$pending=!1,i.$cancelTimeout=function(){clearTimeout(e),i.$pending=!1},i.$execute=function(){var a=Array.prototype.slice.call(arguments);t.apply(this,a),i.$cancelTimeout()},i}function ot(t,n){return an(t)&&!an(n)&&(t="0"),t}function an(t){return t===0}function Bt(t,n){for(var e,i,a,r=0,o=t.length-1;r<=o;)if(i=+t[e=Math.floor((r+o)/2)],a=+t[e-1],i<n)r=e+1;else{if(!(i>n)){for(;+t[e]==+t[e+1];)e++;return e}if(!isNaN(a)&&a<n)return e-1;o=e-1}return t.length-1}function rn(){return{getVertices:function(t){for(var n,e={},i=0,a=t.length;i<a;i++)e[(n=t[i]).target]=n.target,e[n.source]=n.source;var r,o=[];for(var i in e)r=e[i],o.push(r);return o},topologicalSort:function(t){for(var n=this.getVertices(t),e={},i=0,a=n.length;i<a;i++)e[n[i]]={id:n[i],$source:[],$target:[],$incoming:0};for(i=0,a=t.length;i<a;i++){var r=e[t[i].target];r.$target.push(i),r.$incoming=r.$target.length,e[t[i].source].$source.push(i)}for(var o=n.filter(function(c){return!e[c].$incoming}),s=[];o.length;){var l=o.pop();s.push(l);var d=e[l];for(i=0;i<d.$source.length;i++){var u=e[t[d.$source[i]].target];u.$incoming--,u.$incoming||o.push(u.id)}}return s},groupAdjacentEdges:function(t){for(var n,e={},i=0,a=t.length;i<a;i++)e[(n=t[i]).source]||(e[n.source]=[]),e[n.source].push(n);return e},tarjanStronglyConnectedComponents:function(t,n){for(var e={},i=[],a=this.groupAdjacentEdges(n),r=!1,o=[],s=0;s<t.length;s++){var l=k(t[s]);if(!l.visited)for(var d=[l],u=0;d.length;){var c=d.pop();c.visited||(c.index=u,c.lowLink=u,u++,i.push(c),c.onStack=!0,c.visited=!0),r=!1,n=a[c.id]||[];for(var h=0;h<n.length;h++){var _=k(n[h].target);if(_.edge=n[h],_.index===void 0){d.push(c),d.push(_),r=!0;break}_.onStack&&(c.lowLink=Math.min(c.lowLink,_.index))}if(!r){if(c.index==c.lowLink){for(var f={tasks:[],links:[],linkKeys:[]};(_=i.pop()).onStack=!1,f.tasks.push(_.id),_.edge&&(f.links.push(_.edge.id),f.linkKeys.push(_.edge.hashSum)),_!=c;);o.push(f)}d.length&&(_=c,(c=d[d.length-1]).lowLink=Math.min(c.lowLink,_.lowLink))}}}return o;function k(m){return e[m]||(e[m]={id:m,onStack:!1,index:void 0,lowLink:void 0,edge:void 0}),e[m]}},findLoops:function(t){var n=[];st(t,function(i){i.target==i.source&&n.push({tasks:[i.source],links:[i.id]})});var e=this.getVertices(t);return st(this.tarjanStronglyConnectedComponents(e,t),function(i){i.tasks.length>1&&n.push(i)}),n}}}function sn(t){return{getVirtualRoot:function(){return t.mixin(t.getSubtaskDates(),{id:t.config.root_id,type:t.config.types.project,$source:[],$target:[],$virtual:!0})},getLinkedTasks:function(n,e){var i=[n],a=!1;t._isLinksCacheEnabled()||(t._startLinksCache(),a=!0);for(var r=[],o={},s={},l=0;l<i.length;l++)this._getLinkedTasks(i[l],o,e,s);for(var l in s)r.push(s[l]);return a&&t._endLinksCache(),r},_collectRelations:function(n,e,i,a){var r,o=t._getSuccessors(n,e),s=[];i&&(s=t._getPredecessors(n,e));for(var l=[],d=0;d<o.length;d++)a[r=o[d].hashSum]||(a[r]=!0,l.push(o[d]));for(d=0;d<s.length;d++)a[r=s[d].hashSum]||(a[r]=!0,l.push(s[d]));return l},_getLinkedTasks:function(n,e,i,a){for(var r,o=n===void 0?t.config.root_id:n,s=(e={},{}),l=[{from:o,includePredecessors:i,isChild:!1}];l.length;){var d=l.pop(),u=d.isChild;if(!e[o=d.from]){r=t.isTaskExists(o)?t.getTask(o):this.getVirtualRoot(),e[o]=!0;for(var c=this._collectRelations(r,u,i,s),h=0;h<c.length;h++){var _=c[h];let m=!0;t.config.auto_scheduling_use_progress&&t.getTask(_.target).progress==1&&(m=!1);const b=t.getTask(_.target),g=t.getTask(_.source);(b.unscheduled||g.unscheduled)&&(m=!1),m&&(a[_.hashSum]=_);var f=_.sourceParent==_.targetParent;e[_.target]||l.push({from:_.target,includePredecessors:!0,isChild:f})}if(t.hasChild(r.id)){var k=t.getChildren(r.id);for(h=0;h<k.length;h++)e[k[h]]||l.push({from:k[h],includePredecessors:!0,isChild:!0})}}}return a}}}var Zt,V=(t=>(t.ASAP="asap",t.ALAP="alap",t.SNET="snet",t.SNLT="snlt",t.FNET="fnet",t.FNLT="fnlt",t.MSO="mso",t.MFO="mfo",t))(V||{});class Nt{static Create(n){const e=new Nt;if(n)for(const i in e)n[i]!==void 0&&(e[i]=n[i]);return e}constructor(){this.link=null,this.task=null,this.start_date=null,this.end_date=null,this.latestStart=null,this.earliestStart=null,this.earliestEnd=null,this.latestEnd=null,this.latestSchedulingStart=null,this.earliestSchedulingStart=null,this.latestSchedulingEnd=null,this.earliestSchedulingEnd=null,this.kind="asap",this.conflict=!1}}class pe{constructor(n){this.isAsapTask=e=>{const i=this.getConstraintType(e);return this._gantt.config.schedule_from_end?i===V.ASAP:i!==V.ALAP},this.isAlapTask=e=>!this.isAsapTask(e),this.getConstraintType=e=>{if(!this._gantt._isAutoSchedulable(e))return;const i=this._getTaskConstraint(e);return i.constraint_type?i.constraint_type:this._gantt.config.schedule_from_end?V.ALAP:V.ASAP},this._getTaskConstraint=e=>{let i=this._getOwnConstraint(e);if(this._gantt.config.auto_scheduling_project_constraint&&!this._gantt.getState().group_mode){let a=V.ASAP;this._gantt.config.schedule_from_end&&(a=V.ALAP),(i&&i.constraint_type)!==a&&i||(i=this._getParentConstraint(e))}return i},this._getOwnConstraint=e=>({constraint_type:e.constraint_type,constraint_date:e.constraint_date}),this._getParentConstraint=e=>{let i=V.ASAP;this._gantt.config.schedule_from_end&&(i=V.ALAP);let a={constraint_type:i,constraint_date:null};return this._gantt.eachParent(r=>{a.constraint_type===i&&r.constraint_type&&r.constraint_type!==i&&(a={constraint_type:r.constraint_type,constraint_date:r.constraint_date})},e.id),a},this.hasConstraint=e=>!!this.getConstraintType(e),this.processConstraint=(e,i)=>{const a=this._getTaskConstraint(e);if(a&&!(a.constraint_type===V.ALAP||a.constraint_type===V.ASAP)){if(Tt(a.constraint_date)){const r=a.constraint_date,o=Nt.Create(i);switch(o.task=e.id,a.constraint_type){case V.SNET:o.earliestStart=new Date(r),o.earliestEnd=this._gantt.calculateEndDate({start_date:o.earliestStart,duration:e.duration,task:e}),o.link=null;break;case V.SNLT:o.latestStart=new Date(r),o.latestEnd=this._gantt.calculateEndDate({start_date:o.latestStart,duration:e.duration,task:e}),o.link=null;break;case V.FNET:o.earliestStart=this._gantt.calculateEndDate({start_date:r,duration:-e.duration,task:e}),o.earliestEnd=new Date(r),o.link=null;break;case V.FNLT:o.latestStart=this._gantt.calculateEndDate({start_date:r,duration:-e.duration,task:e}),o.latestEnd=new Date(r),o.link=null;break;case V.MSO:o.earliestStart=new Date(r),o.earliestEnd=this._gantt.calculateEndDate({start_date:o.earliestStart,duration:e.duration,task:e}),o.latestStart=o.earliestStart,o.latestEnd=o.earliestEnd,o.link=null;break;case V.MFO:o.earliestStart=this._gantt.calculateEndDate({start_date:r,duration:-e.duration,task:e}),o.earliestEnd=this._gantt.calculateEndDate({start_date:o.earliestStart,duration:e.duration,task:e}),o.latestStart=o.earliestStart,o.latestEnd=o.earliestEnd,o.link=null}return o}}return i},this.getConstraints=(e,i)=>{const a=[],r={},o=l=>{r[l.id]||this.hasConstraint(l)&&!this._gantt.isSummaryTask(l)&&(r[l.id]=l)};if(this._gantt.isTaskExists(e)){const l=this._gantt.getTask(e);o(l)}let s;if(this._gantt.eachTask(l=>o(l),e),i)for(let l=0;l<i.length;l++){const d=i[l];r[d.target]||(s=this._gantt.getTask(d.target),o(s)),r[d.source]||(s=this._gantt.getTask(d.source),o(s))}for(const l in r)r[l].type!==this._gantt.config.types.placeholder&&a.push(r[l]);return a},this._gantt=n}static Create(n){return new pe(n)}}class on{constructor(n){this._gantt=n}isEqual(n,e,i){return!this._gantt._hasDuration(n,e,i)}isFirstSmaller(n,e,i){return n.valueOf()<e.valueOf()&&!this.isEqual(n,e,i)}isSmallerOrDefault(n,e,i){return!(n&&!this.isFirstSmaller(n,e,i))}isGreaterOrDefault(n,e,i){return!(n&&!this.isFirstSmaller(e,n,i))}}class me{static Create(n){const e=new me;return e._gantt=n,e._comparator=new on(n),e}resolveRelationDate(n,e,i){let a=null,r=null,o=null,s=null;const l=this._gantt.getTask(n),d=e.successors;let u=null;const c=i[n];for(let _=0;_<d.length;_++){const f=d[_];s=f.preferredStart;const k=this.getLatestEndDate(f,i,l),m=this._gantt.calculateEndDate({start_date:k,duration:-l.duration,task:l});this._comparator.isGreaterOrDefault(u,k,l)&&(u=k),this._comparator.isGreaterOrDefault(s,m,l)&&this._comparator.isGreaterOrDefault(a,k,l)&&(a=k,o=m,r=f.id)}!d.length&&this._gantt.config.project_end&&(this._comparator.isGreaterOrDefault(this._gantt.config.project_end,l.end_date,l)&&(a=this._gantt.config.project_end),this._gantt.callEvent("onBeforeTaskAutoSchedule",[l,l.end_date])===!1&&(a=l.end_date)),a&&(l.duration?(a=this._gantt.getClosestWorkTime({date:a,dir:"future",task:l}),o=this._gantt.calculateEndDate({start_date:a,duration:-l.duration,task:l})):o=a=this._gantt.getClosestWorkTime({date:a,dir:"past",task:l}));const h=Nt.Create(c);return h.link=r,h.task=n,h.end_date=a,h.start_date=o,h.kind="alap",u&&(h.latestSchedulingStart=this._gantt.calculateEndDate({start_date:u,duration:-l.duration,task:l}),h.latestSchedulingEnd=u),h}getSuccessorStartDate(n,e){const i=e[n],a=this._gantt.getTask(n);let r;return r=i&&(i.start_date||i.end_date)?i.start_date?i.start_date:this._gantt.calculateEndDate({start_date:i.end_date,duration:-a.duration,task:a}):a.start_date,r}getLatestEndDate(n,e,i){const a=this.getSuccessorStartDate(n.target,e),r=i;let o=this._gantt.getClosestWorkTime({date:a,dir:"past",task:r});return o&&n.lag&&1*n.lag==1*n.lag&&(o=this._gantt.calculateEndDate({start_date:o,duration:1*-n.lag,task:r})),o}}class ve{static Create(n){const e=new ve;return e._gantt=n,e._comparator=new on(n),e}resolveRelationDate(n,e,i){let a=null,r=null,o=null;const s=this._gantt.getTask(n),l=e.predecessors,d={};let u=null;for(let f=0;f<l.length;f++){const k=l[f];o=k.preferredStart;const m=this.getEarliestStartDate(k,i,s);if(this._comparator.isSmallerOrDefault(u,m,s)&&(u=m),this._comparator.isSmallerOrDefault(o,m,s)&&this._comparator.isSmallerOrDefault(a,m,s)&&(a=m,r=k.id),!s.duration){const b=this._gantt.getLink(k.id);(d[b.type]===void 0||d[b.type]<+m)&&(d[b.type]=+m)}}!l.length&&this._gantt.config.project_start&&((this._comparator.isSmallerOrDefault(s.start_date,this._gantt.config.project_start,s)||this._gantt.config.auto_scheduling_strict&&this._comparator.isGreaterOrDefault(s.start_date,this._gantt.config.project_start,s))&&(a=this._gantt.config.project_start),this._gantt.callEvent("onBeforeTaskAutoSchedule",[s,s.start_date])===!1&&(a=s.start_date));let c=null;if(a)if(s.duration)a=this._gantt.getClosestWorkTime({date:a,dir:"future",task:s}),c=this._gantt.calculateEndDate({start_date:a,duration:s.duration,task:s});else{let f="future";const k=this._gantt.config.links;if(d[k.finish_to_finish]!==void 0){const m=l.length===1;let b=!0;for(const g in d)if(g!=k.finish_to_finish&&d[k.finish_to_finish]<d[g]){b=!1;break}(m||b)&&(f="past")}a=c=this._gantt.getClosestWorkTime({date:a,dir:f,task:s})}const h=i[n],_=Nt.Create(h);return _.link=r,_.task=n,_.start_date=a,_.end_date=c,_.kind="asap",u&&(_.earliestSchedulingStart=u,_.earliestSchedulingEnd=this._gantt.calculateEndDate({start_date:u,duration:s.duration,task:s})),_}getPredecessorEndDate(n,e){const i=e[n],a=this._gantt.getTask(n);let r;return r=i&&(i.start_date||i.end_date)?i.end_date?i.end_date:this._gantt.calculateEndDate({start_date:i.start_date,duration:a.duration,task:a}):a.end_date,r}getEarliestStartDate(n,e,i){const a=this.getPredecessorEndDate(n.source,e),r=i,o=this._gantt.getTask(n.source);let s;if(a&&n.lag&&1*n.lag==1*n.lag){let l=r;this._gantt.config.auto_scheduling_move_projects&&n.subtaskLink&&this._gantt.isTaskExists(n.targetParent)&&(l=this._gantt.getTask(n.targetParent)),s=this._gantt.getClosestWorkTime({date:a,dir:"future",task:o}),n.sourceLag&&(s=this._gantt.calculateEndDate({start_date:s,duration:1*n.sourceLag,task:o})),n.targetLag&&(s=this._gantt.calculateEndDate({start_date:s,duration:1*n.targetLag,task:l})),s=this._gantt.calculateEndDate({start_date:s,duration:1*n.trueLag,task:l})}else{const l=this._gantt.getLink(n.id).type===this._gantt.config.links.finish_to_finish;s=!r.duration&&l?this._gantt.getClosestWorkTime({date:a,dir:"past",task:r}):this._gantt.getClosestWorkTime({date:a,dir:"future",task:r})}return s}}class si{constructor(n,e,i){this._secondIteration=!1,this._gantt=n,this._constraintsHelper=i,this._graphHelper=e,this._asapStrategy=ve.Create(n),this._alapStrategy=me.Create(n),this._secondIterationRequired=!1}generatePlan(n,e){const i=this._graphHelper,a=this._gantt,r=this._constraintsHelper,o=this._alapStrategy,s=this._asapStrategy,{orderedIds:l,reversedIds:d,relationsMap:u,plansHash:c}=this.buildWorkCollections(n,e,i);let h;return this.processConstraints(l,c,a,r),h=a.config.schedule_from_end?this.iterateTasks(d,l,r.isAlapTask,o,s,u,c):this.iterateTasks(l,d,r.isAsapTask,s,o,u,c),h}applyProjectPlan(n){const e=this._gantt;let i,a,r,o;const s=[];for(let l=0;l<n.length;l++){if(r=null,o=null,i=n[l],!e.isTaskExists(i.task))continue;a=e.getTask(i.task),i.link&&(r=e.getLink(i.link),o=i.kind==="asap"?this._gantt.getTask(r.source):this._gantt.getTask(r.target));let d=null;i.start_date&&a.start_date.valueOf()!==i.start_date.valueOf()&&(d=i.start_date),d&&(a.start_date=d,a.end_date=e.calculateEndDate(a),s.push(a.id),e.callEvent("onAfterTaskAutoSchedule",[a,d,r,o]))}return s}iterateTasks(n,e,i,a,r,o,s){const l=this._gantt,d=[];for(let u=0;u<n.length;u++){const c=n[u],h=l.getTask(c);if(!l._isAutoSchedulable(h))continue;const _=a.resolveRelationDate(c,o[c],s);this.limitPlanDates(h,_),i(h)?this.processResolvedDate(h,_,d,s):s[h.id]=_}for(let u=0;u<e.length;u++){const c=e[u],h=l.getTask(c);if(l._isAutoSchedulable(h)&&!i(h)){const _=r.resolveRelationDate(c,o[c],s);this.limitPlanDates(h,_),this.processResolvedDate(h,_,d,s)}}if(this._secondIterationRequired){if(this._secondIteration)this._secondIteration=!1;else if(this._secondIteration=!0,this.summaryLagChanged(l,o,s))return this.iterateTasks(n,e,i,a,r,o,s)}return d}summaryLagChanged(n,e,i){const a={},r={};for(const s in e)e[s].predecessors.forEach(l=>{if(l.subtaskLink){const d=n.getLink(l.id);this.getProjectUpdates(n,i,l,d,"source",a,r),this.getProjectUpdates(n,i,l,d,"target",a,r)}});let o=!1;for(const s in a){const l=a[s];if(!l.min||!l.max)continue;const d=n.getTask(s),u=n.calculateDuration({start_date:d.start_date,end_date:d.end_date,task:d}),c=n.calculateDuration({start_date:l.min,end_date:l.max,task:d});c!==u&&(d.start_date=l.min,d.end_date=l.max,d.duration=c)}for(const s in r){const l=r[s];let d,u;const c=a[l.source],h=a[l.target];c&&(d={start_date:c.start_date,end_date:c.end_date}),h&&(d={start_date:h.start_date,end_date:h.end_date}),n._formatLink(l,d,u).forEach(function(_){for(const f in e)e[f].predecessors.forEach(function(k){const m=k.id===_.id,b=k.target===_.target,g=k.source===_.source;m&&b&&g&&(k.lag=_.lag,k.sourceLag=_.sourceLag,k.targetLag=_.targetLag,k.hashSum=_.hashSum)})}),o=!0}return o}getProjectUpdates(n,e,i,a,r,o,s){if(n.getTask(a[r]).type===n.config.types.project){o[a[r]]=o[a[r]]||{id:a[r],link:a};const l=o[a[r]];let d=e[i[r]];d&&(r!="source"||d.start_date&&d.end_date||(d=n.getTask(d.task)),l.min=l.min||d.start_date,l.min>d.start_date&&(l.min=d.start_date),l.max=l.max||d.end_date,l.max<d.end_date&&(l.max=d.end_date),s[a.id]=a)}}processResolvedDate(n,e,i,a){if(e.start_date&&this._gantt.isLinkExists(e.link)){let r=null,o=null;if(e.link&&(r=this._gantt.getLink(e.link),o=e.kind==="asap"?this._gantt.getTask(r.source):this._gantt.getTask(r.target)),n.start_date.valueOf()!==e.start_date.valueOf()&&this._gantt.callEvent("onBeforeTaskAutoSchedule",[n,e.start_date,r,o])===!1)return}a[n.id]=e,e.start_date&&i.push(e)}limitPlanDates(n,e){const i=e.start_date||n.start_date;return e.earliestStart&&i<e.earliestStart&&(e.start_date=e.earliestStart,e.end_date=e.earliestEnd),e.latestStart&&i>e.latestStart&&(e.start_date=e.latestStart,e.end_date=e.latestEnd),e.latestSchedulingStart&&i>e.latestSchedulingStart&&(e.start_date=e.latestSchedulingStart,e.end_date=e.latestSchedulingEnd),e.earliestSchedulingStart&&i<e.earliestSchedulingStart&&(e.start_date=e.earliestSchedulingStart,e.end_date=e.earliestSchedulingEnd),e.start_date&&(e.start_date>e.latestSchedulingStart||e.start_date<e.earliestSchedulingStart||e.start_date>e.latestStart||e.start_date<e.earliestStart||e.end_date>e.latestSchedulingEnd||e.end_date<e.earliestSchedulingEnd||e.end_date>e.latestEnd||e.end_date<e.earliestEnd)&&(e.conflict=!0),e}buildWorkCollections(n,e,i){const a=this._gantt,r=i.topologicalSort(n),o=r.slice().reverse(),s={},l={};for(let d=0,u=r.length;d<u;d++){const c=r[d],h=a.getTask(c);a._isAutoSchedulable(h)&&(l[c]={successors:[],predecessors:[]},s[c]=null)}for(let d=0,u=e.length;d<u;d++){const c=e[d];s[c.id]===void 0&&(o.unshift(c.id),r.unshift(c.id),s[c.id]=null,l[c.id]={successors:[],predecessors:[]})}for(let d=0,u=n.length;d<u;d++){const c=n[d];l[c.source]&&l[c.source].successors.push(c),l[c.target]&&l[c.target].predecessors.push(c)}return{orderedIds:r,reversedIds:o,relationsMap:l,plansHash:s}}processConstraints(n,e,i,a){for(let r=0;r<n.length;r++){const o=n[r],s=i.getTask(o),l=a.getConstraintType(s);if(l&&l!==V.ASAP&&l!==V.ALAP){const d=a.processConstraint(s,Nt.Create());e[s.id]=d}}}}function ke(t,n,e){const i=[t],a=[],r={},o={};let s;for(;i.length>0;)if(s=i.shift(),!e[s]){e[s]=!0,a.push(s);for(let u=0;u<n.length;u++){const c=n[u];c.source==s||c.sourceParent==s?(e[c.target]||(i.push(c.target),o[c.id]=!0,n.splice(u,1),u--),r[c.hashSum]=c):c.target!=s&&c.targetParent!=s||(e[c.source]||(i.push(c.source),o[c.id]=!0,n.splice(u,1),u--),r[c.hashSum]=c)}}const l=[];let d=[];for(const u in o)l.push(u);for(const u in r)d.push(r[u]);return d.length||(d=n),{tasks:a,links:l,processedLinks:d}}class oi{constructor(n,e){this.getConnectedGroupRelations=i=>ke(i,this._linksBuilder.getLinkedTasks(),{}).processedLinks,this.getConnectedGroup=i=>{const a=this._linksBuilder.getLinkedTasks();if(i!==void 0){if(this._gantt.getTask(i).type===this._gantt.config.types.project)return{tasks:[],links:[]};const r=ke(i,a,{});return{tasks:r.tasks,links:r.links}}return function(r){const o={},s=[];let l,d,u;for(let c=0;c<r.length;c++)if(l=r[c].source,d=r[c].target,u=null,o[l]?o[d]||(u=d):u=l,u){const h=r.length;s.push(ke(u,r,o)),h!==r.length&&(c=-1)}return s}(a).map(r=>({tasks:r.tasks,links:r.links}))},this._linksBuilder=e,this._gantt=n}}class li{constructor(n,e,i){this.isCircularLink=a=>!!this.getLoopContainingLink(a),this.getLoopContainingLink=a=>{const r=this._graphHelper,o=this._linksBuilder,s=this._gantt;let l=o.getLinkedTasks();s.isLinkExists(a.id)||(l=l.concat(s._formatLink(a)));const d=r.findLoops(l);for(let u=0;u<d.length;u++){const c=d[u].links;for(let h=0;h<c.length;h++)if(c[h]==a.id)return d[u]}return null},this.findCycles=()=>{const a=this._graphHelper,r=this._linksBuilder.getLinkedTasks();return a.findLoops(r)},this._linksBuilder=i,this._graphHelper=e,this._gantt=n}}function di(t,n,e,i){const a=function(){let r,o,s=!1;function l($,x){t.config.auto_scheduling&&!t._autoscheduling_in_progress&&(t.getState().batch_update?s=!0:t.autoSchedule(x.source))}function d($,x){const S=t.config.auto_scheduling_use_progress;return t.config.auto_scheduling_use_progress=!1,t.isCircularLink(x)?(t.callEvent("onCircularLinkError",[x,e.getLoopContainingLink(x)]),t.config.auto_scheduling_use_progress=S,!1):(t.config.auto_scheduling_use_progress=S,!0)}function u($,x){const S=t.getTask(x.source),T=t.getTask(x.target);return!(!t.config.auto_scheduling_descendant_links&&(t.isChildOf(S.id,T.id)&&t.isSummaryTask(T)||t.isChildOf(T.id,S.id)&&t.isSummaryTask(S)))}function c($,x,S,T){return!!$!=!!x||!(!$&&!x)&&($.valueOf()>x.valueOf()?t._hasDuration({start_date:x,end_date:$,task:T}):t._hasDuration({start_date:$,end_date:x,task:S}))}function h($,x){return!!c($.start_date,x.start_date,$,x)||t.getConstraintType($)!==t.getConstraintType(x)||!!c($.constraint_date,x.constraint_date,$,x)||!(!c($.start_date,x.start_date,$,x)&&(!c($.end_date,x.end_date,$,x)&&$.duration===x.duration||$.type===t.config.types.milestone))||void 0}function _($){return t.config.auto_scheduling_compatibility?n.getLinkedTasks($,!0):i.getConnectedGroupRelations($)}function f($,x){let S=!1;for(let T=0;T<r.length;T++){const E=t.getLink(x[T].id);!E||E.type!==t.config.links.start_to_start&&E.type!==t.config.links.start_to_finish||(x.splice(T,1),T--,S=!0)}if(S){const T={};for(let C=0;C<x.length;C++)T[x[C].id]=!0;const E=_($);for(let C=0;C<E.length;C++)T[E[C].id]||x.push(E[C])}}function k($,x){if(t.config.schedule_from_end){if(x.end_date&&$.end_date&&$.end_date.valueOf()===x.end_date.valueOf())return!0}else if(x.start_date&&$.start_date&&$.start_date.valueOf()===x.start_date.valueOf())return!0}function m($){if($.auto_scheduling===!1)return;const x=t.config.constraint_types,S=[x.SNLT,x.FNLT,x.MSO,x.MFO],T=[x.SNET,x.FNET,x.MSO,x.MFO];t.config.schedule_from_end?S.indexOf($.constraint_type)>-1?$.constraint_type==x.SNLT||$.constraint_type==x.MSO?$.constraint_date=new Date($.start_date):$.constraint_date=new Date($.end_date):($.constraint_type=x.FNLT,$.constraint_date=new Date($.end_date)):T.indexOf($.constraint_type)>-1?$.constraint_type==x.SNET||$.constraint_type==x.MSO?$.constraint_date=new Date($.start_date):$.constraint_date=new Date($.end_date):($.constraint_type=x.SNET,$.constraint_date=new Date($.start_date))}function b($){t.config.auto_scheduling_compatibility&&($.constraint_type!==t.config.constraint_types.SNET&&$.constraint_type!==t.config.constraint_types.FNLT||($.constraint_type=null,$.constraint_date=null))}t.attachEvent("onAfterBatchUpdate",function(){s&&t.autoSchedule(),s=!1}),t.attachEvent("onAfterLinkUpdate",l),t.attachEvent("onAfterLinkAdd",l),t.attachEvent("onAfterLinkDelete",function($,x){if(t.config.auto_scheduling&&!t._autoscheduling_in_progress&&t.isTaskExists(x.target)){const S=t.getTask(x.target),T=t._getPredecessors(S);T.length&&(t.getState().batch_update?s=!0:t.autoSchedule(T[0].source,!1))}}),t.attachEvent("onParse",function(){t.config.auto_scheduling&&t.config.auto_scheduling_initial&&t.autoSchedule()}),t.attachEvent("onBeforeLinkAdd",d),t.attachEvent("onBeforeLinkAdd",u),t.attachEvent("onBeforeLinkUpdate",d),t.attachEvent("onBeforeLinkUpdate",u),t.attachEvent("onBeforeTaskDrag",function($,x,S){return t.config.auto_scheduling&&(t.getState().drag_mode!=="progress"&&(r=_($)),o=$),!0});const g=function($,x){const S=t.getTask($);k(S,x)||m(S)};let v,p=null;if(t.ext&&t.ext.inlineEditors){const $=t.ext.inlineEditors,x={start_date:!0,end_date:!0,duration:!0,constraint_type:!0,constraint_date:!0};$.attachEvent("onBeforeSave",function(S){if(x[S.columnName]){p=S.id,S.columnName==="constraint_type"&&(v=!0);const T=S.columnName==="duration",E=t.config.schedule_from_end&&S.columnName==="start_date",C=!t.config.schedule_from_end&&S.columnName==="end_date",D=t.config.inline_editors_date_processing!=="keepDuration"&&(E||C),I=S.columnName==="constraint_date";(T||D||I)&&(t.getTask(S.id).$keep_constraints=!0)}return!0})}const y={};let w;t.attachEvent("onBeforeTaskChanged",function($,x,S){return g($,S),y[$]=S,!0}),t.attachEvent("onAfterTaskDrag",function($,x,S){$===o&&(clearTimeout(w),w=setTimeout(function(){(function(T,E){if(t.config.auto_scheduling&&!t._autoscheduling_in_progress){const C=t.getTask(T),D=t.config.auto_scheduling_use_progress&&E.progress===1!=(C.progress===1);if(h(E,C)){if(g(T,E),t.config.auto_scheduling_move_projects&&o==T){let I=!0;t.calculateDuration(E)!==t.calculateDuration(C)&&(f(T,r),I=!1),D?t.autoSchedule():(I&&f(T,r),t._autoSchedule(T,r))}else t.autoSchedule(C.id);b(C)}}r=null,o=null})($,y[$])}))}),t.ext.inlineEditors&&t.ext.inlineEditors.attachEvent("onBeforeSave",function($){if(t.config.auto_scheduling&&!t._autoscheduling_in_progress){const x=t.ext.inlineEditors.getEditorConfig($.columnName);x.map_to!=="start_date"&&x.map_to!=="end_date"&&x.map_to!=="duration"||(p=$.id)}return!0}),t.attachEvent("onLightboxSave",function($,x){if(t.config.auto_scheduling&&!t._autoscheduling_in_progress){v=!1;const S=t.getTask($);h(x,S)&&(p=$,k(x,S)&&(x.$keep_constraints=!0),t.getConstraintType(x)===t.getConstraintType(S)&&+x.constraint_date==+S.constraint_date||(v=!0))}return!0}),t.attachEvent("onAfterTaskUpdate",function($,x){return t.config.auto_scheduling&&!t._autoscheduling_in_progress&&p!==null&&p==$&&(p=null,x.$keep_constraints?delete x.$keep_constraints:v||m(x),t.autoSchedule(x.id),v||b(x)),!0})};t.attachEvent("onGanttReady",function(){a()},{once:!0})}function Y(t){var n=0,e=0,i=0,a=0;if(t.getBoundingClientRect){var r=t.getBoundingClientRect(),o=document.body,s=document.documentElement||document.body.parentNode||document.body,l=window.pageYOffset||s.scrollTop||o.scrollTop,d=window.pageXOffset||s.scrollLeft||o.scrollLeft,u=s.clientTop||o.clientTop||0,c=s.clientLeft||o.clientLeft||0;n=r.top+l-u,e=r.left+d-c,i=document.body.offsetWidth-r.right,a=document.body.offsetHeight-r.bottom}else{for(;t;)n+=parseInt(t.offsetTop,10),e+=parseInt(t.offsetLeft,10),t=t.offsetParent;i=document.body.offsetWidth-t.offsetWidth-e,a=document.body.offsetHeight-t.offsetHeight-n}return{y:Math.round(n),x:Math.round(e),width:t.offsetWidth,height:t.offsetHeight,right:Math.round(i),bottom:Math.round(a)}}function ci(t){var n=!1,e=!1;if(window.getComputedStyle){var i=window.getComputedStyle(t,null);n=i.display,e=i.visibility}else t.currentStyle&&(n=t.currentStyle.display,e=t.currentStyle.visibility);return n!="none"&&e!="hidden"}function ui(t){return!isNaN(t.getAttribute("tabindex"))&&1*t.getAttribute("tabindex")>=0}function hi(t){return!{a:!0,area:!0}[t.nodeName.loLowerCase()]||!!t.getAttribute("href")}function _i(t){return!{input:!0,select:!0,textarea:!0,button:!0,object:!0}[t.nodeName.toLowerCase()]||!t.hasAttribute("disabled")}function zt(t){for(var n=t.querySelectorAll(["a[href]","area[href]","input","select","textarea","button","iframe","object","embed","[tabindex]","[contenteditable]"].join(", ")),e=Array.prototype.slice.call(n,0),i=0;i<e.length;i++)e[i].$position=i;for(e.sort(function(r,o){return r.tabIndex===0&&o.tabIndex!==0?1:r.tabIndex!==0&&o.tabIndex===0?-1:r.tabIndex===o.tabIndex?r.$position-o.$position:r.tabIndex<o.tabIndex?-1:1}),i=0;i<e.length;i++){var a=e[i];(ui(a)||_i(a)||hi(a))&&ci(a)||(e.splice(i,1),i--)}return e}function ln(){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 n=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),Math.max(n,15)}function it(t){if(!t)return"";var n=t.className||"";return n.baseVal&&(n=n.baseVal),n.indexOf||(n=""),be(n)}function $t(t,n){n&&t.className.indexOf(n)===-1&&(t.className+=" "+n)}function Pt(t,n){n=n.split(" ");for(var e=0;e<n.length;e++){var i=new RegExp("\\s?\\b"+n[e]+"\\b(?![-_.])","");t.className=t.className.replace(i,"")}}function ye(t){return typeof t=="string"?document.getElementById(t)||document.querySelector(t)||document.body:t||document.body}function dn(t,n){Zt||(Zt=document.createElement("div")),Zt.innerHTML=n;var e=Zt.firstChild;return t.appendChild(e),e}function cn(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function un(t,n){for(var e=t.childNodes,i=e.length,a=[],r=0;r<i;r++){var o=e[r];o.className&&o.className.indexOf(n)!==-1&&a.push(o)}return a}function Et(t){var n;return t.tagName?n=t:(n=(t=t||window.event).target||t.srcElement).shadowRoot&&t.composedPath&&(n=t.composedPath()[0]),n}function Z(t,n){if(n){for(var e=Et(t);e;){if(e.getAttribute&&e.getAttribute(n))return e;e=e.parentNode}return null}}function be(t){return(String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")}).apply(t)}function vt(t,n,e){var i=Et(t),a="";for(e===void 0&&(e=!0);i;){if(a=it(i)){var r=a.indexOf(n);if(r>=0){if(!e)return i;var o=r===0||!be(a.charAt(r-1)),s=r+n.length>=a.length||!be(a.charAt(r+n.length));if(o&&s)return i}}i=i.parentNode}return null}function lt(t,n){var e=document.documentElement,i=Y(n);return{x:t.clientX+e.scrollLeft-e.clientLeft-i.x+n.scrollLeft,y:t.clientY+e.scrollTop-e.clientTop-i.y+n.scrollTop}}function hn(t,n){const e=Y(t),i=Y(n);return{x:e.x-i.x,y:e.y-i.y}}function Q(t,n){if(!t||!n)return!1;for(;t&&t!=n;)t=t.parentNode;return t===n}function dt(t,n){if(t.closest)return t.closest(n);if(t.matches||t.msMatchesSelector||t.webkitMatchesSelector){var e=t;if(!document.documentElement.contains(e))return null;do{if((e.matches||e.msMatchesSelector||e.webkitMatchesSelector).call(e,n))return e;e=e.parentElement||e.parentNode}while(e!==null&&e.nodeType===1);return null}return console.error("Your browser is not supported"),null}function _n(t){for(;t;){if(t.offsetWidth>0&&t.offsetHeight>0)return t;t=t.parentElement}return null}function gn(){return document.head.createShadowRoot||document.head.attachShadow}function $e(){var t=document.activeElement;return t.shadowRoot&&(t=t.shadowRoot.activeElement),t===document.body&&document.getSelection&&(t=document.getSelection().focusNode||document.body),t}function Ct(t){if(!t||!gn())return document.body;for(;t.parentNode&&(t=t.parentNode);)if(t instanceof ShadowRoot)return t.host;return document.body}const fn=Object.freeze(Object.defineProperty({__proto__:null,addClassName:$t,closest:dt,getActiveElement:$e,getChildNodes:un,getClassName:it,getClosestSizedElement:_n,getFocusableNodes:zt,getNodePosition:Y,getRelativeEventPosition:lt,getRelativeNodePosition:hn,getRootNode:Ct,getScrollSize:ln,getTargetNode:Et,hasClass:function(t,n){return"classList"in t?t.classList.contains(n):new RegExp("\\b"+n+"\\b").test(t.className)},hasShadowParent:function(t){return!!Ct(t)},insertNode:dn,isChildOf:Q,isShadowDomSupported:gn,locateAttribute:Z,locateClassName:vt,removeClassName:Pt,removeNode:cn,toNode:ye},Symbol.toStringTag,{value:"Module"})),tt=typeof window<"u"?window:global;let gi=class{constructor(t){this._mouseDown=!1,this._gantt=t,this._domEvents=t._createDomEventScope()}attach(t,n,e){const i=this._gantt,a=t.getViewPort();this._originPosition=tt.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 o=null;const s=()=>{o&&(this._mouseDown=!0,t.setStart(i.copy(o)),t.setPosition(i.copy(o)),t.setEnd(i.copy(o)),o=null)};this._domEvents.attach(a,"mousedown",d=>{o=null;let u=".gantt_task_line, .gantt_task_link";e!==void 0&&(u=e instanceof Array?e.join(", "):e),u&&i.utils.dom.closest(d.target,u)||(r.registerProvider("clickDrag",()=>({autoscroll:this._mouseDown})),n&&d[n]!==!0||(o=this._getCoordinates(d,t)))});const l=Ct(i.$root)||document.body;this._domEvents.attach(l,"mouseup",d=>{if(o=null,(!n||d[n]===!0)&&this._mouseDown===!0){this._mouseDown=!1;const u=this._getCoordinates(d,t);t.dragEnd(u)}}),this._domEvents.attach(a,"mousemove",d=>{if(n&&d[n]!==!0)return;const u=this._gantt.ext.clickDrag,c=(this._gantt.config.drag_timeline||{}).useKey;if(u&&c&&!n&&d[c])return;let h=null;if(!this._mouseDown&&o)return h=this._getCoordinates(d,t),void(Math.abs(o.relative.left-h.relative.left)>5&&s());this._mouseDown===!0&&(h=this._getCoordinates(d,t),t.setEnd(h),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,n){const e=n.getViewPort(),i=e.getBoundingClientRect(),{clientX:a,clientY:r}=t;return{absolute:{left:a,top:r},relative:{left:a-i.left+e.scrollLeft,top:r-i.top+e.scrollTop}}}};var pn=function(){this._silent_mode=!1,this.listeners={}};pn.prototype={_silentStart:function(){this._silent_mode=!0},_silentEnd:function(){this._silent_mode=!1}};var fi=function(t){var n={},e=0,i=function(){var a=!0;for(var r in n){var o=n[r].apply(t,arguments);a=a&&o}return a};return i.addEvent=function(a,r){if(typeof a=="function"){var o;if(r&&r.id?o=r.id:(o=e,e++),r&&r.once){var s=a;a=function(){s(),i.removeEvent(o)}}return n[o]=a,o}return!1},i.removeEvent=function(a){delete n[a]},i.clear=function(){n={}},i};function ct(t){var n=new pn;t.attachEvent=function(e,i,a){e="ev_"+e.toLowerCase(),n.listeners[e]||(n.listeners[e]=fi(this)),a&&a.thisObject&&(i=i.bind(a.thisObject));var r=e+":"+n.listeners[e].addEvent(i,a);return a&&a.id&&(r=a.id),r},t.attachAll=function(e){this.attachEvent("listen_all",e)},t.callEvent=function(e,i){if(n._silent_mode)return!0;var a="ev_"+e.toLowerCase(),r=n.listeners;return r.ev_listen_all&&r.ev_listen_all.apply(this,[e].concat(i)),!r[a]||r[a].apply(this,i)},t.checkEvent=function(e){return!!n.listeners["ev_"+e.toLowerCase()]},t.detachEvent=function(e){if(e){var i=n.listeners;for(var a in i)i[a].removeEvent(e);var r=e.split(":");if(i=n.listeners,r.length===2){var o=r[0],s=r[1];i[o]&&i[o].removeEvent(s)}}},t.detachAllEvents=function(){for(var e in n.listeners)n.listeners[e].clear()}}class pi{constructor(n,e,i){var a;this._el=document.createElement("div"),this.defaultRender=(r,o)=>{this._el||(this._el=document.createElement("div"));const s=this._el,l=Math.min(r.relative.top,o.relative.top),d=Math.max(r.relative.top,o.relative.top),u=Math.min(r.relative.left,o.relative.left),c=Math.max(r.relative.left,o.relative.left);if(this._singleRow){const h=this._getTaskPositionByTop(this._startPoint.relative.top);s.style.height=h.height+"px",s.style.top=h.top+"px"}else s.style.height=Math.abs(d-l)+"px",s.style.top=l+"px";return s.style.width=Math.abs(c-u)+"px",s.style.left=u+"px",s},this._gantt=e,this._view=i,this._viewPort=n.viewPort,this._el.classList.add(n.className),typeof n.callback=="function"&&(this._callback=n.callback),this.render=()=>{let r;r=n.render?n.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),n.className!==""&&this._el.classList.add(n.className),this.draw()},(a=this._viewPort).attachEvent&&a.detachEvent||ct(this._viewPort),this._singleRow=n.singleRow,this._useRequestAnimationFrame=n.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(n){const e=this._gantt;this._startPoint=n,this._startDate=e.dateFromPos(this._startPoint.relative.left),this._viewPort.callEvent("onBeforeDrag",[this._startPoint])}setEnd(n){const e=this._gantt;if(this._endPoint=n,this._singleRow){const i=this._getTaskPositionByTop(this._startPoint.relative.top);this._endPoint.relative.top=i.top}this._endDate=e.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(n){this._positionPoint=n}dragEnd(n){const e=this._gantt;n.relative.left<0&&(n.relative.left=0),this._viewPort.callEvent("onBeforeDragEnd",[this._startPoint,n]),this.setEnd(n),this._endDate=this._endDate||e.getState().max_date,this._startDate.valueOf()>this._endDate.valueOf()&&([this._startDate,this._endDate]=[this._endDate,this._startDate]),this.clear();const i=e.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(n,e){const i=this._gantt;let a=n,r=e;n>e&&(a=e,r=n);const o=this._getTaskPositionByTop(a).index,s=this._getTaskPositionByTop(r).index,l=[];for(let d=o;d<=s;d++)i.getTaskByIndex(d)&&l.push(i.getTaskByIndex(d));return l}_getTaskPositionByTop(n){const e=this._gantt,i=this._view,a=i.getItemIndexByTopPosition(n),r=e.getTaskByIndex(a);if(r){const o=i.getItemHeight(r.id);return{top:i.getItemTop(r.id)||0,height:o||0,index:a}}{const o=i.getTotalHeight();return{top:n>o?o:0,height:e.config.row_height,index:n>o?e.getTaskCount():0}}}}let xe=!1;class Qt{constructor(n){this._mouseDown=!1,this._calculateDirectionVector=()=>{if(this._trace.length>=10){const e=this._trace.slice(this._trace.length-10),i=[];for(let r=1;r<e.length;r++)i.push({x:e[r].x-e[r-1].x,y:e[r].y-e[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=e=>{const i=this._gantt;return{x:i.$ui.getView(e.$config.scrollX).getScrollState().position,y:i.$ui.getView(e.$config.scrollY).getScrollState().position}},this._countNewScrollPosition=e=>{const i=this._calculateDirectionVector();let a=this._startPoint.x-e.x,r=this._startPoint.y-e.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=(e,i)=>{const a=this._gantt;requestAnimationFrame(()=>{a.scrollLayoutCell(e.$id,i.x,i.y)})},this._stopDrag=e=>{const i=this._gantt;if(this._trace=[],i.$root.classList.remove("gantt_noselect"),this._originalReadonly!==void 0&&(i.config.readonly=this._originalReadonly,this._mouseDown&&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&&e[a]!==!0)return}this._mouseDown=!1,xe=!1},this._startDrag=e=>{const i=this._gantt;this._originAutoscroll=i.config.autoscroll,i.config.autoscroll=!1,xe=!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:e.clientX,y:e.clientY},this._trace.push(this._startPoint)},this._gantt=n,this._domEvents=n._createDomEventScope(),this._trace=[]}static create(n){return new Qt(n)}static _isDragInProgress(){return xe}destructor(){this._domEvents.detachAll()}attach(n){this._timeline=n;const e=this._gantt;this._domEvents.attach(n.$task,"mousedown",i=>{if(!e.config.drag_timeline)return;const{useKey:a,ignore:r,enabled:o}=e.config.drag_timeline;if(o===!1)return;let s=".gantt_task_line, .gantt_task_link";r!==void 0&&(s=r instanceof Array?r.join(", "):r),s&&e.utils.dom.closest(i.target,s)||a&&i[a]!==!0||this._startDrag(i)}),this._domEvents.attach(document,"keydown",i=>{if(!e.config.drag_timeline)return;const{useKey:a}=e.config.drag_timeline;a&&i[a]===!0&&this._applyDndReadyStyles()}),this._domEvents.attach(document,"keyup",i=>{if(!e.config.drag_timeline)return;const{useKey:a}=e.config.drag_timeline;a&&i[a]===!1&&(this._clearDndReadyStyles(),this._stopDrag(i))}),this._domEvents.attach(document,"mouseup",i=>{this._stopDrag(i)}),this._domEvents.attach(e.$root,"mouseup",i=>{this._stopDrag(i)}),this._domEvents.attach(document,"mouseleave",i=>{this._stopDrag(i)}),this._domEvents.attach(e.$root,"mouseleave",i=>{this._stopDrag(i)}),this._domEvents.attach(e.$root,"mousemove",i=>{if(!e.config.drag_timeline)return;const{useKey:a}=e.config.drag_timeline;if(a&&i[a]!==!0)return;const r=this._gantt.ext.clickDrag,o=(this._gantt.config.click_drag||{}).useKey;if((!r||!o||a||!i[o])&&this._mouseDown===!0){this._trace.push({x:i.clientX,y:i.clientY});const s=this._countNewScrollPosition({x:i.clientX,y:i.clientY});this._setScrollPosition(n,s),this._scrollState=s,this._startPoint={x:i.clientX,y:i.clientY}}})}}function mi(t){(function(){var n=[];function e(){return!!n.length}function i(d){setTimeout(function(){e()||t.$destroyed||t.focus()},1)}function a(d){t.eventRemove(d,"keydown",o),t.event(d,"keydown",o),n.push(d)}function r(){var d=n.pop();d&&t.eventRemove(d,"keydown",o),i()}function o(d){var u=d.currentTarget;u==n[n.length-1]&&t.$keyboardNavigation.trapFocus(u,d)}function s(){a(t.getLightbox())}t.attachEvent("onLightbox",s),t.attachEvent("onAfterLightbox",r),t.attachEvent("onLightboxChange",function(){r(),s()}),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=e})()}class vi{constructor(n){this.show=(e,i)=>{i===void 0?this._showForTask(e):this._showAtCoordinates(e,i)},this.hide=e=>{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",e&&(a.style.left=a.style.right="",a.parentNode.removeChild(a)),i.callEvent("onAfterQuickInfo",[r])}},this.getNode=()=>this._quickInfoBox?this._quickInfoBox:null,this.setContainer=e=>{e&&(this._container=typeof e=="string"?document.getElementById(e):e)},this.setContent=e=>{const i=this._gantt,a={taskId:null,header:{title:"",date:""},content:"",buttons:i.config.quickinfo_buttons};e||(e=a),e.taskId||(e.taskId=a.taskId),e.header||(e.header=a.header),e.header.title||(e.header.title=a.header.title),e.header.date||(e.header.date=a.header.date),e.content||(e.content=a.content),e.buttons||(e.buttons=a.buttons);let r=this.getNode();r||(r=this._createQuickInfoElement()),e.taskId&&(this._quickInfoBoxId=e.taskId);const o=r.querySelector(".gantt_cal_qi_title"),s=o.querySelector(".gantt_cal_qi_tcontent"),l=o.querySelector(".gantt_cal_qi_tdate"),d=r.querySelector(".gantt_cal_qi_content"),u=r.querySelector(".gantt_cal_qi_controls");i._waiAria.quickInfoHeader(r,[e.header.title,e.header.date].join(" ")),s.innerHTML=e.header.title,l.innerHTML=e.header.date,e.header.title||e.header.date?o.style.display="":o.style.display="none",d.innerHTML=e.content;const c=e.buttons;c.length?u.style.display="":u.style.display="none";let h="";for(let _=0;_<c.length;_++){const f=i._waiAria.quickInfoButtonAttrString(i.locale.labels[c[_]]);h+=`<div class="gantt_qi_big_icon ${c[_]} dhx_gantt_${c[_]}" title="${i.locale.labels[c[_]]}" ${f}>
<div class='dhx_menu_icon dhx_gantt_icon ${c[_]} gantt_menu_icon dhx_gantt_${c[_]}'></div>
<div>${i.locale.labels[c[_]]}</div>
</div>`}u.innerHTML=h,i.eventRemove(r,"click",this._qiButtonClickHandler),i.eventRemove(r,"keypres