UNPKG

@syncfusion/ej2-gantt

Version:
10 lines 1.24 MB
/*! * filename: ej2-gantt.min.js * version : 30.1.42 * Copyright Syncfusion Inc. 2001 - 2024. All rights reserved. * Use of this code is subject to the terms of our license. * A copy of the current license can be obtained at any time by e-mailing * licensing@syncfusion.com. Any infringement will be prosecuted under * applicable laws. */ this.ej=this.ej||{},this.ej.gantt=function(e,t,i,a,r,n,s,o,l,d,h,p,u,c,g){"use strict";function f(e,t,i){for(var a=e;a&&(i?a.id!==t:!a.classList.contains(t));)a=a.parentElement;return a}function m(e){return t.isNullOrUndefined(e.startDate)&&t.isNullOrUndefined(e.endDate)&&t.isNullOrUndefined(e.duration)?null:!(t.isNullOrUndefined(e.startDate)||t.isNullOrUndefined(e.endDate)||t.isNullOrUndefined(e.duration))}function y(e){return!(!e.dataSource||e.dataSource instanceof a.DataManager||!("result"in e.dataSource))}function D(e){for(var t={},i=0,a=Object.keys(e);i<a.length;i++){var r=a[i];t[e[r]]=r}return t}function v(e){return!t.isNullOrUndefined(e)&&"object"==typeof e&&0===Object.keys(e).length}function k(e){var t=e.getFullYear(),i=e.getMonth(),a=e.getDate(),r=e.getHours(),n=e.getMinutes(),s=e.getSeconds(),o=e.getMilliseconds();return Date.UTC(t,i,a,r,n,s,o)}function b(e){if(e instanceof a.DataManager){var t=e.adaptor;return t instanceof a.ODataAdaptor||t instanceof a.ODataV4Adaptor||t instanceof a.WebApiAdaptor||t instanceof a.WebMethodAdaptor||t instanceof a.CacheAdaptor||t instanceof a.RemoteSaveAdaptor||t instanceof a.UrlAdaptor}return!1}function w(e,i,a,r){if(a){for(var n=void 0,s=0;s<e.length;s++)n=o=i?e[parseInt(s.toString(),10)].taskData:t.extend({},e[parseInt(s.toString(),10)].taskData,{},!0);return n}for(var n=[],s=0;s<e.length;s++){!t.isNullOrUndefined(r)&&r.timezone&&T(e[s],r);var o=i?e[parseInt(s.toString(),10)].taskData:t.extend({},e[parseInt(s.toString(),10)].taskData,{},!0);n.push(o)}return n}function T(e,i){return e&&!t.isNullOrUndefined(e.ganttProperties)&&(e.taskData[i.taskFields.startDate]=i.dateValidationModule.remove(e.ganttProperties.startDate,i.timezone),null!==i.taskFields.endDate&&(e.taskData[i.taskFields.endDate]=i.dateValidationModule.remove(e.ganttProperties.endDate,i.timezone)),(i.taskFields.baselineEndDate||i.taskFields.baselineStartDate)&&(e.taskData[i.taskFields.baselineStartDate]=i.dateValidationModule.remove(e.ganttProperties.baselineStartDate,i.timezone),e.taskData[i.taskFields.baselineEndDate]=i.dateValidationModule.remove(e.ganttProperties.baselineEndDate,i.timezone))),null}function P(e,t){for(var i,a=0;a<t.length;a++)i=new RegExp("\\{"+a+"\\}","gm"),e=e.replace(i,t[a].toString());return e}function S(e,i,a,r){for(var n=-1,s=0;s<a.length;s++)if(t.getValue(i,a[s])===t.getValue(i,e)&&t.isNullOrUndefined(r)||!t.isNullOrUndefined(r)&&t.getValue(i,a[s])===t.getValue(i,e)&&t.getValue(r,a[s])===t.getValue(r,e)){n=s;break}return n}function C(e){return 76*e/92}function R(e){return 92*e/76}function M(){return x++}var x=0;!function(e){e[e.AsSoonAsPossible=0]="AsSoonAsPossible",e[e.AsLateAsPossible=1]="AsLateAsPossible",e[e.MustStartOn=2]="MustStartOn",e[e.MustFinishOn=3]="MustFinishOn",e[e.StartNoEarlierThan=4]="StartNoEarlierThan",e[e.StartNoLaterThan=5]="StartNoLaterThan",e[e.FinishNoEarlierThan=6]="FinishNoEarlierThan",e[e.FinishNoLaterThan=7]="FinishNoLaterThan"}(e.ConstraintType||(e.ConstraintType={}));var O=function(){function i(e){this.fromSegments=!1,this.mondayTimeRangeLength=0,this.tuesdayTimeRangeLength=0,this.wednesdayTimeRangeLength=0,this.thursdayTimeRangeLength=0,this.fridayTimeRangeLength=0,this.saturdayTimeRangeLength=0,this.sundayTimeRangeLength=0,this.parent=e}return i.prototype.isValidateNonWorkDays=function(e){return!t.isNullOrUndefined(e)&&e.isAutoSchedule&&(!this.parent.includeWeekend||this.parent.totalHolidayDates.length>0)||t.isNullOrUndefined(e)&&(!this.parent.includeWeekend||this.parent.totalHolidayDates.length>0)},i.prototype.checkStartDate=function(e,i,a,r){if(t.isNullOrUndefined(e))return null;var n=new Date(e.getTime()),s=this.parent.getCurrentDayStartTime(n),o=this.parent.getCurrentDayEndTime(n),l=new Date(e.getTime()),d=this.getSecondsInDecimal(l);if(a=t.isNullOrUndefined(a)?!t.isNullOrUndefined(i)&&i.isMilestone:a,d<s&&(!a||r))this.setTime(s,l);else if(d<s&&a)this.setTime(s,l);else if(d===o&&(!i||!a)||d>o)l.setDate(l.getDate()+1),s=this.parent.getCurrentDayStartTime(l),this.setTime(s,l);else if(d>s&&d<o){var h=this.parent.workingTimeRanges;this.parent.weekWorkingTime.length>0&&(h=this.parent.getWorkingRange(l));for(var p=0;p<h.length;p++){var u=h[p];if(d>=u.to&&h[p+1]&&d<h[p+1].from){(d!==u.to||i&&a)&&d===u.to||this.setTime(h[p+1].from,l);break}}}var c;if(!this.parent.autoCalculateDateScheduling||this.parent.isLoad&&this.parent.treeGrid.loadChildOnDemand&&this.parent.taskFields.hasChildMapping)return new Date(l.getTime());do{c=new Date(l.getTime());var g=this.parent.totalHolidayDates.length;if(this.isValidateNonWorkDays(i)){s=this.parent.getCurrentDayStartTime(c),i&&(o=this.parent.getCurrentDayEndTime(i.endDate?i.isAutoSchedule?i.endDate:i.autoEndDate:c));var f=!a||r?s:o;if(!this.parent.includeWeekend){var m=new Date(l.getTime());l=this.getNextWorkingDay(l),f=this.parent.getCurrentDayStartTime(l),m.getTime()===l.getTime()||a||this.setTime(f,l)}for(var y=0;y<g;y++){var D=this.getDateFromFormat(new Date(this.parent.totalHolidayDates[y])),v=new Date(D.getTime());D.setHours(0,0,0,0),v.setHours(23,59,59,59),l.getTime()>=D.getTime()&&l.getTime()<v.getTime()&&(l.setDate(l.getDate()+1),f=this.parent.getCurrentDayStartTime(l),this.setTime(f,l))}}}while(c.getTime()!==l.getTime());return new Date(l.getTime())},i.prototype.getDateByConstraint=function(i,a,r,n){var s=i.ganttProperties?i.ganttProperties:i,o=new Date(s.constraintDate),l=this.parent.isLoad;if(t.isNullOrUndefined(n)&&(n=!0),(!o||!a)&&n)return null;switch(o=this.parent.assignTimeToDate(o,this.parent.getCurrentDayStartTime(o)),s.constraintType){case e.ConstraintType.AsSoonAsPossible:if(l)return a;s.constraintDate=null;var d=this.parent.getRecordByID(s.taskId).parentItem;return s.predecessor&&s.predecessor.length>0?this.parent.assignTimeToDate(a,this.parent.getCurrentDayStartTime(a)):d?this.parent.getRecordByID(d.taskId).ganttProperties.startDate:this.parent.dateValidationModule.checkStartDate(new Date(this.parent.projectStartDate));case e.ConstraintType.AsLateAsPossible:if(l)return a;if(d=this.parent.getRecordByID(s.taskId).parentItem){g=this.parent.dateValidationModule.checkEndDate(this.parent.getRecordByID(d.taskId).ganttProperties.endDate);return f=this.parent.dateValidationModule.getStartDate(g,s.duration,s.durationUnit,s)}g=this.parent.dateValidationModule.checkEndDate(new Date(this.parent.projectEndDate));return f=this.parent.dateValidationModule.getStartDate(g,s.duration,s.durationUnit,s);case e.ConstraintType.MustStartOn:var h=o.getTime()!==s.startDate.getTime(),p=void 0;this.parent.editModule&&this.parent.editModule.dialogModule&&(p=this.parent.editModule.dialogModule.dialogConstraintValue);var u=t.isNullOrUndefined(p)||2===p||3===p;return h&&!l&&u&&(this.parent.constraintViolationType="MustStartOn"),p=null,l?this.parent.dateValidationModule.checkStartDate(new Date(o)):this.parent.assignTimeToDate(a,this.parent.getCurrentDayStartTime(a));case e.ConstraintType.MustFinishOn:var h=o.getTime()!==s.endDate.getTime(),c=new Date(o);c.setDate(c.getDate()+1);var g=this.parent.dateValidationModule.checkEndDate(c),f=this.parent.dateValidationModule.getStartDate(g,s.duration,s.durationUnit,s);return h&&!l&&(this.parent.constraintViolationType="MustFinishOn"),r?a:f;case e.ConstraintType.StartNoEarlierThan:return o.getTime()<a.getTime()||!l?this.parent.assignTimeToDate(a,this.parent.getCurrentDayStartTime(a)):this.parent.dateValidationModule.checkStartDate(new Date(o));case e.ConstraintType.StartNoLaterThan:return(h=o.getTime()!==s.startDate.getTime())&&!l&&(this.parent.constraintViolationType="StartNoLaterThan"),l?s.predecessor&&s.predecessor.length>0?a:this.parent.dateValidationModule.checkStartDate(new Date(this.parent.projectStartDate)):this.parent.assignTimeToDate(a,this.parent.getCurrentDayStartTime(a));case e.ConstraintType.FinishNoEarlierThan:if(o.getTime()<a.getTime())return this.parent.assignTimeToDate(a,this.parent.getCurrentDayEndTime(a));var m=new Date(o);m.setDate(m.getDate()+1);g=this.parent.dateValidationModule.checkEndDate(m);return this.parent.dateValidationModule.getStartDate(g,s.duration,s.durationUnit,s);case e.ConstraintType.FinishNoLaterThan:return(h=o.getTime()!==s.endDate.getTime())&&!l&&(this.parent.constraintViolationType="FinishNoLaterThan"),l?s.predecessor&&s.predecessor.length>0?a:this.parent.dateValidationModule.checkStartDate(new Date(this.parent.projectStartDate)):this.parent.assignTimeToDate(a,this.parent.getCurrentDayEndTime(a));default:return a}},i.prototype.checkEndDate=function(e,i,a){if(t.isNullOrUndefined(e))return null;var r,n;if(this.parent.weekWorkingTime.length>0){var s=e;(!this.parent.includeWeekend&&i&&i.isAutoSchedule||this.parent.editModule&&this.parent.editModule.taskbarEditModule&&this.parent.editModule.taskbarEditModule.taskBarEditRecord&&!this.parent.editModule.taskbarEditModule.taskBarEditRecord.ganttProperties.isAutoSchedule)&&(s=this.getNextWorkingDay(e)),r=this.parent.getStartTime(s),n=this.parent.getEndTime(s)}else r=this.parent.defaultStartTime,n=this.parent.defaultEndTime;var o=new Date(e.getTime()),l=this.getSecondsInDecimal(o);if(l>n)this.setTime(n,o);else if(l<=r&&86400!==n&&!a){var d=this.parent.taskFields;this.parent.editModule&&this.parent.editModule.editedRecord&&!this.parent.editModule.editedRecord[d.startDate]&&this.parent.editModule.editedRecord[d.endDate]?o.setDate(o.getDate()):o.setDate(o.getDate()-1),n=this.parent.getCurrentDayEndTime(o),this.setTime(n,o)}else if(l>r&&l<n)for(var h=0;h<this.parent.workingTimeRanges.length;h++)if(l>this.parent.workingTimeRanges[h].to&&this.parent.workingTimeRanges[h+1]&&l<=this.parent.workingTimeRanges[h+1].from){this.setTime(this.parent.workingTimeRanges[h].to,o);break}var p;if(!this.parent.autoCalculateDateScheduling||this.parent.isLoad&&this.parent.treeGrid.loadChildOnDemand&&this.parent.taskFields.hasChildMapping)return t.isNullOrUndefined(o)||86400===this.parent.defaultEndTime||(n=this.parent.getCurrentDayEndTime(e),this.setTime(n,o)),new Date(o.getTime());do{p=new Date(o.getTime());var u=this.parent.totalHolidayDates.length;if(this.isValidateNonWorkDays(i)){if(!this.parent.includeWeekend){var c=new Date(o.getTime());o=this.getPreviousWorkingDay(o),n=this.parent.getCurrentDayEndTime(o),c.getTime()!==o.getTime()&&this.setTime(n,o)}for(var g=0;g<u;g++){var f=this.getDateFromFormat(new Date(this.parent.totalHolidayDates[g])),m=new Date(f.getTime()),y=new Date(o.getTime());y.setMinutes(o.getMilliseconds()-2),f.setHours(0,0,0,0),m.setHours(23,59,59,59),(o.getTime()>=f.getTime()&&o.getTime()<m.getTime()||y.getTime()>=f.getTime()&&y.getTime()<m.getTime())&&(o.setDate(o.getDate()-1),n=this.parent.getCurrentDayEndTime(o),o.getTime()===f.getTime()&&86400===n&&0===this.getSecondsInDecimal(o)||this.setTime(n,o))}}}while(p.getTime()!==o.getTime());return new Date(o.getTime())},i.prototype.checkBaselineStartDate=function(e,i){if(t.isNullOrUndefined(e))return null;var a=this.parent.getCurrentDayStartTime(e),r=this.parent.getCurrentDayEndTime(i&&i.endDate?i.isAutoSchedule?i.endDate:i.autoEndDate:e),n=new Date(e.getTime()),s=this.getSecondsInDecimal(n);if(s<a)this.setTime(a,n);else if(s>r)n.setDate(n.getDate()+1),a=this.parent.weekWorkingTime.length>0?this.parent.getStartTime(n):this.parent.defaultStartTime,this.setTime(a,n);else if(s>a&&s<r)for(var o=0;o<this.parent.workingTimeRanges.length;o++)if(s>this.parent.workingTimeRanges[o].to&&this.parent.workingTimeRanges[o+1]&&s<this.parent.workingTimeRanges[o+1].from){this.setTime(this.parent.workingTimeRanges[o+1].from,n);break}return n},i.prototype.checkBaselineEndDate=function(e,i){if(t.isNullOrUndefined(e))return null;var a=this.parent.getCurrentDayEndTime(e),r=this.parent.getCurrentDayStartTime(i&&i.startDate?i.isAutoSchedule?i.startDate:i.autoStartDate:e),n=new Date(e.getTime()),s=this.getSecondsInDecimal(n);if(s>a)this.setTime(a,n);else if(s<r&&!t.isNullOrUndefined(i)&&!i.isMilestone)n.setDate(n.getDate()-1),a=this.parent.getCurrentDayEndTime(n),this.setTime(a,n);else if(s>r&&s<a)for(var o=0;o<this.parent.workingTimeRanges.length;o++)if(s>this.parent.workingTimeRanges[o].to&&this.parent.workingTimeRanges[o+1]&&s<=this.parent.workingTimeRanges[o+1].from){this.setTime(this.parent.workingTimeRanges[o].to,n);break}return i&&i.baselineStartDate&&n&&i.baselineStartDate.getTime()>n.getTime()&&n.setDate(n.getDate()+1),n},i.prototype.calculateStartDate=function(e){var i=e.ganttProperties,a=null;t.isNullOrUndefined(i.endDate)||t.isNullOrUndefined(i.duration)||(a=this.getStartDate(i.endDate,i.duration,i.durationUnit,i)),this.parent.setRecordValue("startDate",a,i,!0),this.parent.taskFields.startDate&&this.parent.dataOperation.updateMappingData(e,"startDate")},i.prototype.calculateEndDate=function(e){var i,a,r=e.ganttProperties,n=null;if(t.isNullOrUndefined(r.startDate))n=e[this.parent.taskFields.endDate],t.isNullOrUndefined(n)||(a=this.parent.getCurrentDayEndTime(n),this.setTime(a,n)),this.parent.setRecordValue("endDate",n,r,!0);else{if(!t.isNullOrUndefined(r.endDate)&&t.isNullOrUndefined(r.duration)&&(1===this.compareDates(r.startDate,r.endDate)&&(this.parent.setRecordValue("startDate",new Date(r.endDate.getTime()),r,!0),i=this.parent.getCurrentDayStartTime(r.isAutoSchedule?r.autoStartDate:r.startDate),a=this.parent.getCurrentDayEndTime(r.isAutoSchedule?r.autoEndDate:r.endDate),this.setTime(i,r.startDate)),this.calculateDuration(e)),!t.isNullOrUndefined(r.duration)){var s=!t.isNullOrUndefined(r.segments)&&r.segments.length>1?this.totalDuration(r.segments):r.duration;n=this.getEndDate(r.startDate,s,r.durationUnit,r,!1)}this.parent.setRecordValue("endDate",n,r,!0)}this.parent.taskFields.endDate&&this.parent.dataOperation.updateMappingData(e,"endDate")},i.prototype.totalDuration=function(e){for(var t=0,i=0;i<e.length;i++)t+=e[i].duration+e[i].offsetDuration;return t},i.prototype.calculateDuration=function(e){var i,a=e.ganttProperties;i=!t.isNullOrUndefined(a.segments)&&a.segments.length>0&&!t.isNullOrUndefined(this.parent.editModule.taskbarEditModule)?this.parent.editModule.taskbarEditModule.sumOfDuration(a.segments):t.isNullOrUndefined(this.parent.taskFields.milestone)||t.isNullOrUndefined(a.startDate)||t.isNullOrUndefined(a.endDate)||a.startDate.getTime()!==a.endDate.getTime()||!1!==e.taskData[this.parent.taskFields.milestone]?this.getDuration(a.startDate,a.endDate,a.durationUnit,a.isAutoSchedule,a.isMilestone):1,this.parent.setRecordValue("duration",i,a,!0);var r=this.parent.columnByField[this.parent.columnMapping.duration];if(!(t.isNullOrUndefined(this.parent.editModule)||t.isNullOrUndefined(this.parent.editModule.cellEditModule)||this.parent.editModule.cellEditModule.isCellEdit||t.isNullOrUndefined(r))){if(!t.isNullOrUndefined(r.edit)&&!t.isNullOrUndefined(r.edit.read)){var n=this.parent.editModule.dialogModule.dialog;if(!t.isNullOrUndefined(n)){var s=n.querySelector("#"+this.parent.element.id+"Duration").ej2_instances[0];t.isNullOrUndefined(s)||s.value===i.toString()||(s.value=i.toString(),s.dataBind())}}this.parent.taskFields.duration&&(this.parent.dataOperation.updateMappingData(e,"duration"),this.parent.taskFields.durationUnit&&this.parent.dataOperation.updateMappingData(e,"durationUnit"))}},i.prototype.getNonworkingTime=function(e,i,a,r){r=!!t.isNullOrUndefined(r)||r;var n=this.parent.includeWeekend||!this.parent.autoCalculateDateScheduling||this.parent.isLoad&&this.parent.treeGrid.loadChildOnDemand&&this.parent.taskFields.hasChildMapping||!a?0:this.getWeekendCount(e,i),s=this.getNumberOfSeconds(e,i,r),o=!a||!this.parent.autoCalculateDateScheduling||this.parent.isLoad&&this.parent.treeGrid.loadChildOnDemand&&this.parent.taskFields.hasChildMapping?0:this.getHolidaysCount(e,i),l=(s-86400*n-86400*o)/86400,d=this.getNonWorkingSecondsOnDate(e,i,a);return(this.parent.weekWorkingTime.length>0?this.nonWorkingSeconds(e,i,a,l):l*(86400-this.parent.secondsPerDay))+86400*n+86400*o+d},i.prototype.nonWorkingSeconds=function(e,i,a,r,n){var s=e.getTime()>i.getTime()?new Date(i.getTime()):new Date(e.getTime()),o=e.getTime()>i.getTime()?new Date(e.getTime()):new Date(i.getTime()),l=0,d=0;if(n){var h=this.parent.getCurrentDayStartTime(s),p=this.parent.getCurrentDayEndTime(s);s.getHours()<p/3600&&s.getHours()>=h/3600||s.setDate(s.getDate()+1)}else s.setDate(s.getDate()+1),s.setHours(0,0,0,0),o.setHours(0,0,0,0);if(!(r>0||t.isNullOrUndefined(r)))return 0;for(;n&&s.getTime()<=o.getTime()||!n&&s.getTime()<o.getTime();){if(a){if(this.isOnHolidayOrWeekEnd(s,!0))do{s.setDate(s.getDate()+1)}while(this.isOnHolidayOrWeekEnd(s,!0));this.parent.includeWeekend||this.getNextWorkingDay(s)}if(s.getTime()<=o.getTime()){d++;var u=this.parent.getSecondsPerDay(s);if(l+=n?u:86400-u,s.setDate(s.getDate()+1),a){if(this.isOnHolidayOrWeekEnd(s,!0))do{s.setDate(s.getDate()+1)}while(this.isOnHolidayOrWeekEnd(s,!0));this.parent.includeWeekend||this.getNextWorkingDay(s)}}}return n&&(l>0?l/=d:l=this.parent.secondsPerDay),l},i.prototype.getDuration=function(e,t,i,a,r,n){if(void 0===n&&(n=!0),!e||!t)return null;var s,o=0,l=this.parent.getFormatedDate(e)===this.parent.getFormatedDate(t);if(this.parent.weekWorkingTime.length>0){var d=new Date(e);s=this.nonWorkingSeconds(e,t,a,void 0,!0);for(var h=0;d<=t;){var p=this.parent.getFormatedDate(d),u=this.parent.getSecondsPerDay(d),c=new Date(d),g=new Date(d);c.setHours(0,0,0,0),g.setHours(0,0,0,0),c.setSeconds(this.parent.getCurrentDayStartTime(d)),g.setSeconds(this.parent.getCurrentDayEndTime(d)),p===this.parent.getFormatedDate(e)&&c.setTime(e.getTime()),p===this.parent.getFormatedDate(t)&&g.setTime(t.getTime());var f=this.getTimeDifference(c,g,n)/1e3,m=this.getNonworkingTime(c,g,a,n);h+=Math.max(0,f-m)/u,d.setDate(d.getDate()+1)}r&&l||(o=this.calculateDurationValue(i,h,s))}else{s=this.parent.secondsPerDay;var y=this.getTimeDifference(e,t,n)/1e3-this.getNonworkingTime(e,t,a,n);r&&l||(o=this.calculateDurationValue(i,y/s,s))}return parseFloat(o.toString())},i.prototype.calculateDurationValue=function(e,t,i){return e&&"day"!==e?"minute"===e?t*(i/60):t*(i/3600):t},i.prototype.getDurationAsSeconds=function(e,t,i){var a;return a=this.parent.weekWorkingTime.length>0?this.parent.getSecondsPerDay(i):this.parent.secondsPerDay,t&&"day"!==t.toLocaleLowerCase()?"hour"===t.toLocaleLowerCase()?3600*e:60*e:a*e},i.prototype.getEndDate=function(e,t,i,a,r){var n,s=new Date(e.getTime()),o=new Date(e.getTime()),l=new Date(e.getTime());n=this.parent.weekWorkingTime.length>0&&(!i||"day"===i.toLocaleLowerCase())?this.calculateSecondDuration(t,l,n,e,!0):this.getDurationAsSeconds(t,i,e);for(;n>0;)o.setSeconds(o.getSeconds()+n),(n-=n-this.getNonworkingTime(s,o,a.isAutoSchedule,!0))>0&&(o=this.checkStartDate(o,a,r)),s=new Date(o.getTime());return o},i.prototype.getStartDate=function(e,t,i,a,r){var n,s=new Date(e.getTime()),o=new Date(e.getTime()),l=new Date(s.getTime());n=this.parent.weekWorkingTime.length>0?this.calculateSecondDuration(t,l,n,s,!1):this.getDurationAsSeconds(t,i,s);for(;n>0;)o.setSeconds(o.getSeconds()-n),(n-=n-this.getNonworkingTime(o,s,a.isAutoSchedule,!0))>0&&(s=this.checkEndDate(o,a)),s=new Date(o.getTime());if(r&&a.isMilestone){o.setDate(o.getDate()-1);var d=this.parent.getCurrentDayEndTime(a.endDate?a.isAutoSchedule?a.endDate:a.autoEndDate:o);this.parent.dateValidationModule.setTime(d,o),o=this.parent.dateValidationModule.checkStartDate(o,a,!0)}return o},i.prototype.calculateSecondDuration=function(e,t,i,a,r){if(e<1)i=this.parent.getSecondsPerDay(t)*e;else{i=0;var n=e,s=this.parent.getCurrentDayStartTime(t),o=this.parent.getCurrentDayEndTime(t);for(t.getHours()<o/3600&&t.getHours()>s/3600||!this.fromSegments||(r?t.setDate(t.getDate()+1):t.setDate(t.getDate()-1));n>0;){if(this.isOnHolidayOrWeekEnd(t,!0))do{r?t.setDate(t.getDate()+1):t.setDate(t.getDate()-1)}while(this.isOnHolidayOrWeekEnd(t,!0));this.parent.includeWeekend||(t=r?this.getNextWorkingDay(t):this.getPreviousWorkingDay(t));var l=this.parent.getSecondsPerDay(t),d=0;if(this.getSecondsInDecimal(a)!==this.parent.getStartTime(a)&&!Number.isInteger(n)){var h=e.toString().split(".");l*=d=parseFloat("."+h[1]),n-=d}n<1&&(l*=n),i+=l,r?t.setDate(t.getDate()+1):t.setDate(t.getDate()-1),d||n--}}return i},i.prototype.getProjectStartDate=function(e,i){if(!t.isNullOrUndefined(this.parent.cloneProjectStartDate)){"string"==typeof this.parent.cloneProjectStartDate&&(this.parent.cloneProjectStartDate=this.getDateFromFormat(this.parent.cloneProjectStartDate));o=this.checkStartDate(this.parent.cloneProjectStartDate);return this.parent.cloneProjectStartDate=o,new Date(o.getTime())}if(t.isNullOrUndefined(this.parent.projectStartDate)){if(t.isNullOrUndefined(i))return null;var a=this.parent.flatData,r=void 0;a.length>0?r=a[0].ganttProperties.startDate:(r=new Date).setHours(0,0,0,0);for(var n=1;n<a.length;n++){var s=a[n].ganttProperties.startDate;t.isNullOrUndefined(s)||-1!==this.compareDates(s,r)||(r=s)}this.parent.cloneProjectStartDate=this.checkStartDate(r,e)}else{var o=this.getDateFromFormat(this.parent.projectStartDate);this.parent.cloneProjectStartDate=this.checkStartDate(o)}return new Date(this.parent.cloneProjectStartDate.getTime())},i.prototype.getValidStartDate=function(e,i){var a=null,r=i?e.autoStartDate:e.startDate,n=i?e.autoEndDate:e.endDate,s=!e.isAutoSchedule&&e.autoDuration?e.autoDuration:e.duration;if(t.isNullOrUndefined(r))if(t.isNullOrUndefined(n)){if(!t.isNullOrUndefined(s)){var o=this.parent.getTaskByUniqueID(e.uniqueID);if(this.parent.allowUnscheduledTasks&&o&&o.parentItem&&t.isNullOrUndefined(r)&&t.isNullOrUndefined(n)){for(var l=this.parent.getParentTask(o.parentItem);l&&!l.ganttProperties.startDate;)l=this.parent.getParentTask(l.parentItem);a=l&&l.ganttProperties.startDate?l.ganttProperties.startDate:this.parent.cloneProjectStartDate}else a=this.getProjectStartDate(e)}}else{a=new Date(n.getTime());var d=this.parent.getCurrentDayStartTime(a);this.setTime(d,a)}else a=new Date(r.getTime());return a},i.prototype.getValidEndDate=function(e,i){var a=null,r=i?e.autoStartDate:e.startDate,n=i?e.autoEndDate:e.endDate,s=i?e.autoDuration:e.duration;if(t.isNullOrUndefined(n))if(t.isNullOrUndefined(r)){if(!t.isNullOrUndefined(s)){var o=this.getValidStartDate(e);o&&(a=this.getEndDate(o,s,e.durationUnit,e,!1))}}else if(e.isMilestone)a=this.checkStartDate(r);else{a=new Date(r.getTime());var l=this.parent.getCurrentDayEndTime(n||a);this.setTime(l,a)}else a=new Date(n.getTime());return a},i.prototype.getWorkingTime=function(e,i,a,r,n,s,o,l){if(!t.isNullOrUndefined(i.from)&&!t.isNullOrUndefined(i.to)){a.setHours(0,0,0,0);var d=new Date(a.getTime());a.setTime(a.getTime()+36e5*i.from);var h=new Date(a.getTime());if(24===i.to){d.setTime(d.getTime()+864e5)}else d.setTime(d.getTime()+36e5*i.to);var p=new Date(d.getTime()),u=p.getTime()-h.getTime(),c=this.getSecondsInDecimal(h),g=this.getSecondsInDecimal(p);0===g&&(g=86400),r+=u/1e3,0===n&&(this.parent.defaultStartTime=c,this.parent.weekWorkingTime.length>0&&this.assignStartTime(e,c)),n!==this[e.toLowerCase()+"TimeRangeLength"]-1&&""!==e||(this.parent.defaultEndTime=g,this.parent.weekWorkingTime.length>0&&this.assignEndTime(e,g)),n>0?""===e?(s.push(s[s.length-1]+c-o[n-1].to),o[n-1].to<c&&l.push({from:o[n-1].to,to:c,isWorking:!1,interval:c-o[n-1].to})):(this.parent[e.toLowerCase()+"NonWorkingHours"].push(this.parent[e.toLowerCase()+"NonWorkingHours"][this.parent[e.toLowerCase()+"NonWorkingHours"].length-1]+c-this.parent[e.toLowerCase()+"NonWorkingTimeRanges"][n-1].to),this.parent[e.toLowerCase()+"WorkingTimeRanges"][n-1].to<c&&this.parent[e.toLowerCase()+"NonWorkingTimeRanges"].push({from:this.parent[e.toLowerCase()+"WorkingTimeRanges"][n-1].to,to:c,isWorking:!1,interval:c-this.parent[e.toLowerCase()+"WorkingTimeRanges"][n-1].to})):""===e?(s.push(0),l.push({from:0,to:c,isWorking:!1,interval:c})):(this.parent[e.toLowerCase()+"NonWorkingHours"].push(0),this.parent[e.toLowerCase()+"NonWorkingTimeRanges"].push({from:0,to:c,isWorking:!1,interval:c})),""===e?(o.push({from:c,to:g}),l.push({from:c,to:g,isWorking:!0,interval:g-c})):(this.parent[e.toLowerCase()+"WorkingTimeRanges"].push({from:c,to:g}),this.parent[e.toLowerCase()+"NonWorkingTimeRanges"].push({from:c,to:g,isWorking:!0,interval:g-c}))}return r},i.prototype.assignStartTime=function(e,t){switch(e){case"Monday":this.parent.mondayDefaultStartTime=t;break;case"Tuesday":this.parent.tuesdayDefaultStartTime=t;break;case"Wednesday":this.parent.wednesdayDefaultStartTime=t;break;case"Thursday":this.parent.thursdayDefaultStartTime=t;break;case"Friday":this.parent.fridayDefaultStartTime=t;break;case"Saturday":this.parent.saturdayDefaultStartTime=t;break;case"Sunday":this.parent.sundayDefaultStartTime=t}},i.prototype.assignEndTime=function(e,t){switch(e){case"Monday":this.parent.mondayDefaultEndTime=t;break;case"Tuesday":this.parent.tuesdayDefaultEndTime=t;break;case"Wednesday":this.parent.wednesdayDefaultEndTime=t;break;case"Thursday":this.parent.thursdayDefaultEndTime=t;break;case"Friday":this.parent.fridayDefaultEndTime=t;break;case"Saturday":this.parent.saturdayDefaultEndTime=t;break;case"Sunday":this.parent.sundayDefaultEndTime=t}},i.prototype.calculateWeekWorkTime=function(e,t,i,a,r,n,s){for(var o=0,l=0;l<t.length;l++){var d=t[l];o+=this.getWorkingTime(e,d,i,a,l,r,n,s)}return this.parent[e.toLowerCase()+"DefaultStartTime"]/3600!=24&&this.parent[e.toLowerCase()+"NonWorkingTimeRanges"].push({from:this.parent[e.toLowerCase()+"DefaultEndTime"],to:86400,isWorking:!1,interval:86400-this.parent[e.toLowerCase()+"DefaultEndTime"]}),o},i.prototype.getSecondsPerDay=function(){var e=0,i=new Date("10/11/2018");this.parent.nonWorkingHours=[];var a=this.parent.nonWorkingHours;this.parent.workingTimeRanges=[],this.parent.workingTimeRanges=[];var r=this.parent.workingTimeRanges;this.parent.nonWorkingTimeRanges=[];for(var n=this.parent.nonWorkingTimeRanges,s=0,o=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];s<o.length;s++)this[(y=o[s]).toLowerCase()+"TimeRangeLength"]=this.parent.dayWorkingTime.length;if(this.parent.weekWorkingTime.length>0){for(var l=0;l<this.parent.weekWorkingTime.length;l++)this[this.parent.weekWorkingTime[l].dayOfWeek.toLowerCase()+"TimeRangeLength"]=this.parent.weekWorkingTime[l].timeRange.length;for(var d=this.parent.weekWorkingTime,h=this.parent.dayWorkingTime,p=0,u=d;p<u.length;p++){var c=u[p];if(c.timeRange&&c.timeRange.length>0){var g=this.calculateWeekWorkTime(c.dayOfWeek,c.timeRange,i,e,a,r,n);this.parent[c.dayOfWeek.toLowerCase()+"Seconds"]=g}}for(var f=0,m=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];f<m.length;f++){var y=m[f],D=this.parent[y.toLowerCase()+"DefaultStartTime"];if(t.isNullOrUndefined(D)){var v=this.calculateWeekWorkTime(y,h,i,e,a,r,n);this.parent[y.toLowerCase()+"Seconds"]=v}}}for(var k=this.parent.dayWorkingTime,b=k.length,w=0,T=0;T<b;T++){var P=k[T];w+=this.getWorkingTime("",P,i,e,T,a,r,n)}return this.parent.defaultEndTime/3600!=24&&n.push({from:this.parent.defaultEndTime,to:86400,isWorking:!1,interval:86400-this.parent.defaultEndTime}),e=w},i.prototype.getDurationValue=function(e){var i=null,a=null;if("string"==typeof e){var r=e.match(/(\d*\.*\d+|.+$)/g);if(r&&r.length<=2){a=parseFloat(r[0].toString().trim());var n=r[1]?r[1].toString().trim().toLowerCase():null;-1!==t.getValue("minute",this.parent.durationUnitEditText).indexOf(n)?i="minute":-1!==t.getValue("hour",this.parent.durationUnitEditText).indexOf(n)?i="hour":-1!==t.getValue("day",this.parent.durationUnitEditText).indexOf(n)&&(i="day")}}else a=e,i=null;return{duration:a,durationUnit:i}},i.prototype.getNextWorkingDay=function(e){var t=e.getDay();return-1!==this.parent.nonWorkingDayIndex.indexOf(t)?(e.setDate(e.getDate()+1),e=this.getNextWorkingDay(e)):e},i.prototype.getWeekendCount=function(e,t){var i=0,a=new Date(e.getTime()),r=new Date(t.getTime());for(a.setHours(0,0,0,0),a.setDate(a.getDate()+1),r.setHours(0,0,0,0);a.getTime()<r.getTime();)-1!==this.parent.nonWorkingDayIndex.indexOf(a.getDay())&&(i+=1),a.setDate(a.getDate()+1);return i},i.prototype.getNumberOfSeconds=function(e,t,i){var a=new Date(e.getTime()),r=new Date(t.getTime()),n=0;return a.setDate(a.getDate()+1),a.setHours(0,0,0,0),r.setHours(0,0,0,0),a.getTime()<r.getTime()&&(n=this.getTimeDifference(a,r,i)/1e3),n%86400!=0&&(n=n-n%86400+86400),n},i.prototype.getHolidaysCount=function(e,t){var i=0,a=this.parent.totalHolidayDates,r=new Date(e.getTime()),n=new Date(t.getTime());if(r.setDate(r.getDate()+1),r.setHours(0,0,0,0),n.setHours(0,0,0,0),r.getTime()<n.getTime())for(var s=0;s<a.length;s++){var o=this.getDateFromFormat(new Date(a[s]));r.getTime()<=o.getTime()&&n.getTime()>o.getTime()&&(!this.parent.includeWeekend&&-1===this.parent.nonWorkingDayIndex.indexOf(o.getDay())||this.parent.includeWeekend)&&(i+=1)}return i},i.prototype.getHolidayDates=function(){for(var e=this.parent.holidays,i=[],a=0;a<e.length;a++){var r=this.getDateFromFormat(e[a].from),n=this.getDateFromFormat(e[a].to);if(!t.isNullOrUndefined(r)||!t.isNullOrUndefined(n))if(t.isNullOrUndefined(r)||t.isNullOrUndefined(n)){var s=r||n;s.setHours(0,0,0,0),-1===i.indexOf(s.getTime())&&i.push(s.getTime())}else for(;r<=n;)r.setHours(0,0,0,0),-1===i.indexOf(r.getTime())&&i.push(r.getTime()),r.setDate(r.getDate()+1)}return i},i.prototype.isOnHolidayOrWeekEnd=function(e,i){if(i=t.isNullOrUndefined(i)?this.parent.includeWeekend:i,this.parent.autoCalculateDateScheduling||this.parent.isLoad&&this.parent.treeGrid.loadChildOnDemand&&this.parent.taskFields.hasChildMapping||(i=!0),!i&&-1!==this.parent.nonWorkingDayIndex.indexOf(e.getDay()))return!0;for(var a=this.parent.totalHolidayDates,r=0;r<a.length;r++){var n=this.getDateFromFormat(new Date(a[r])),s=new Date(n.getTime());if(n.setHours(0,0,0,0),s.setHours(23,59,59,59),e.getTime()>=n.getTime()&&e.getTime()<s.getTime())return!0}return!1},i.prototype.getNonWorkingSecondsOnDate=function(e,i,a){var r,n,s=this.getSecondsInDecimal(e),o=this.getSecondsInDecimal(i),l=-1,d=-1,h=0,p=!(!a||!this.parent.autoCalculateDateScheduling||this.parent.isLoad&&this.parent.treeGrid.loadChildOnDemand&&this.parent.taskFields.hasChildMapping)&&this.isOnHolidayOrWeekEnd(e,null),u=!(!a||!this.parent.autoCalculateDateScheduling||this.parent.isLoad&&this.parent.treeGrid.loadChildOnDemand&&this.parent.taskFields.hasChildMapping)&&this.isOnHolidayOrWeekEnd(i,null);if(this.parent.weekWorkingTime.length>0){r=this.parent.getNonWorkingRange(e);for(g=0;g<r.length;g++)s>=(c=r[g]).from&&s<=c.to&&(l=g);n=this.parent.getNonWorkingRange(i);for(g=0;g<n.length;g++)o>=(c=n[g]).from&&o<=c.to&&(d=g)}else{r=this.parent.nonWorkingTimeRanges,n=this.parent.nonWorkingTimeRanges;for(g=0;g<r.length;g++){var c=r[g];s>=c.from&&s<=c.to&&(l=g),o>=c.from&&o<=c.to&&(d=g)}}if(e.getDate()!==i.getDate()||e.getMonth()!==i.getMonth()||e.getFullYear()!==i.getFullYear()){if(p)h+=86400-s;else for(g=l;g<r.length;g++)t.isNullOrUndefined(r[g])||r[g].isWorking||(h+=g===l?r[g].to-s:r[g].interval);if(u)h+=o;else for(g=0;g<=d;g++)n[g].isWorking||(h+=g===d?o-n[g].from:n[g].interval)}else if(l!==d)if(u)h+=o-s;else for(var g=l;g<=d;g++)t.isNullOrUndefined(r[g])||r[g].isWorking||(h+=g===l?r[g].to-s:g===d?o-r[g].from:r[g].interval);else u?h+=o-s:r[l].isWorking||(h=o-s);return h},i.prototype.getPreviousWorkingDay=function(e){var t=e.getDay(),i=0===t?6:t-1,a=this.parent.getCurrentDayEndTime(e);return-1!==this.parent.nonWorkingDayIndex.indexOf(t)||-1!==this.parent.nonWorkingDayIndex.indexOf(i)&&86400!==a&&0===this.getSecondsInDecimal(e)?(e.setDate(e.getDate()-1),-1!==this.parent.nonWorkingDayIndex.indexOf(e.getDay())&&(e=this.getPreviousWorkingDay(e)),e):e},i.prototype.getNonWorkingDayIndex=function(){var e=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],t=e.length;0===this.parent.workWeek.length&&(this.parent.workWeek=["Monday","Tuesday","Wednesday","Thursday","Friday"]);for(var i=this.parent.workWeek.slice(),a=i.length,r=0;r<a;r++)i[r]=i[r].toLowerCase();this.parent.nonWorkingDayIndex=[];for(r=0;r<t;r++)-1===i.indexOf(e[r])&&this.parent.nonWorkingDayIndex.push(r)},i.prototype.setTime=function(e,t){var i=e/3600,a=(e-3600*(i=parseInt(i,10)))/60,r=e-3600*i-60*(a=parseInt(a,10));t.setHours(i,a,r)},i.prototype.getTimeDifference=function(e,t,i){var a=new Date(e.getTime()),r=new Date(t.getTime());return i&&this.updateDateWithTimeZone(a,r),r.getTime()-a.getTime()},i.prototype.updateDateWithTimeZone=function(e,t){var i,a,r=e.getTimezoneOffset(),n=t.getTimezoneOffset();if(r!==n){var s=new Date((new Date).getFullYear(),0,1).getTimezoneOffset();if(s!==r?(a=e,i=r):s!==n&&(a=t,i=n),s<0){o=s-i;a.setTime(a.getTime()+60*o*1e3)}else if(s>=0){var o=i-s;a.setTime(a.getTime()-60*o*1e3)}}},i.prototype.getSecondsInDecimal=function(e){return 60*e.getHours()*60+60*e.getMinutes()+e.getSeconds()+e.getMilliseconds()/1e3},i.prototype.offset=function(e,t){var i=e.getTimezoneOffset();try{var a=new Date(e.toLocaleString("en-US",{timeZone:t}));return isNaN(a.getTime())?0:(e.getTime()-a.getTime())/6e4+i}catch(e){return 0}},i.prototype.remove=function(e,i){return t.isNullOrUndefined(e)||(e=this.reverse(e,i,e.getTimezoneOffset())),e},i.prototype.reverse=function(e,t,i){"string"==typeof t&&(t=this.offset(e,t)),"string"==typeof i&&(i=this.offset(e,i));var a=e.getTimezoneOffset(),r=(e=new Date(e.getTime()+6e4*(t-i))).getTimezoneOffset();return new Date(e.getTime()+6e4*(r-a))},i.prototype.convert=function(e,t){var i=e.getTimezoneOffset(),a=this.offset(e,t);"string"==typeof i&&(i=this.offset(e,i)),"string"==typeof a&&(a=this.offset(e,a));var r=e.getTimezoneOffset(),n=(e=new Date(e.getTime()+6e4*(i-a))).getTimezoneOffset();return new Date(e.getTime()+6e4*(n-r))},i.prototype.getDateFromFormat=function(e,i){var a;if(t.isNullOrUndefined(e))return null;if(e instanceof Date)a=new Date(e.getTime());else{var r=this.parent.globalize.parseDate(e,{format:this.parent.getDateFormat(),type:"dateTime"});a=t.isNullOrUndefined(r)&&!isNaN(new Date(e).getTime())?new Date(e):r}return!t.isNullOrUndefined(this.parent.timezone)&&i?this.convert(a,this.parent.timezone):a},i.prototype.compareDates=function(e,i){return t.isNullOrUndefined(e)||t.isNullOrUndefined(i)?!t.isNullOrUndefined(e)&&t.isNullOrUndefined(i)?1:t.isNullOrUndefined(e)&&!t.isNullOrUndefined(i)?-1:null:e.getTime()>i.getTime()?1:e.getTime()<i.getTime()?-1:0},i.prototype.getDurationString=function(e,i){var a="";if(!t.isNullOrUndefined(e)&&(a+=parseFloat(e.toFixed(2))+" ",!t.isNullOrUndefined(i))){var r=1!==e;"day"===i?a+=r?this.parent.localeObj.getConstant("days"):this.parent.localeObj.getConstant("day"):"hour"===i?a+=r?this.parent.localeObj.getConstant("hours"):this.parent.localeObj.getConstant("hour"):"minute"===i&&(a+=r?this.parent.localeObj.getConstant("minutes"):this.parent.localeObj.getConstant("minute"))}return a},i.prototype.getWorkString=function(e,i){var a="";if(!t.isNullOrUndefined(e)&&(a+=parseFloat(e).toFixed(2)+" ",!t.isNullOrUndefined(i))){var r=1!==e;"day"===i?a+=r?this.parent.localeObj.getConstant("days"):this.parent.localeObj.getConstant("day"):"hour"===i?a+=r?this.parent.localeObj.getConstant("hours"):this.parent.localeObj.getConstant("hour"):"minute"===i&&(a+=r?this.parent.localeObj.getConstant("minutes"):this.parent.localeObj.getConstant("minute"))}return a},i.prototype.calculateProjectDatesForValidatedTasks=function(e){var i=this,a="string"==typeof this.parent.projectStartDate?new Date(this.parent.projectStartDate):this.parent.projectStartDate,r="string"==typeof this.parent.projectEndDate?new Date(this.parent.projectEndDate):this.parent.projectEndDate,n=null,s=null,o=t.getValue("dataOperation.dataArray",this.parent);if(a&&r||!o||0!==o.length){if(o.length>0){var l=o.slice().sort(function(e,t){return new Date(e[i.parent.taskFields.startDate]).getTime()-new Date(t[i.parent.taskFields.startDate]).getTime()}),d=o.slice().sort(function(e,t){return new Date(t[i.parent.taskFields.endDate]).getTime()-new Date(e[i.parent.taskFields.endDate]).getTime()});n=l[0][this.parent.taskFields.startDate],s=d[d.length-1][this.parent.taskFields.endDate]}}else n=this.getDateFromFormat(new Date),s=this.getDateFromFormat(new Date(n.getTime()));this.parent.cloneProjectStartDate=a?new Date(a.getTime()):"string"==typeof n?new Date(n):n,this.parent.cloneProjectEndDate=r?new Date(r.getTime()):"string"==typeof s?new Date(s):s},i.prototype.calculateProjectDates=function(e){var i=this;if(this.parent.isLoad&&this.parent.enablePersistence&&this.parent.cloneProjectStartDate&&this.parent.cloneProjectEndDate)return this.parent.cloneProjectStartDate=this.getDateFromFormat(this.parent.cloneProjectStartDate),void(this.parent.cloneProjectEndDate=this.getDateFromFormat(this.parent.cloneProjectEndDate));var a="string"==typeof this.parent.projectStartDate?new Date(this.parent.projectStartDate):this.parent.projectStartDate,r="string"==typeof this.parent.projectEndDate?new Date(this.parent.projectEndDate):this.parent.projectEndDate,n=this.parent.timelineModule.isZooming&&this.parent.cloneProjectStartDate?this.getDateFromFormat(this.parent.cloneProjectStartDate):this.getDateFromFormat(a),s=this.parent.timelineModule.isZooming&&this.parent.cloneProjectEndDate?this.getDateFromFormat(this.parent.cloneProjectEndDate):this.getDateFromFormat(r),o=null,l=null,d=this.parent.flatData,h=this.parent.currentViewData,p=[],u=function(e){t.isNullOrUndefined(e)||p.push(e)},c=function(e){e.length>0&&(e.sort(function(e,t){return e.getTime()-t.getTime()}),o=new Date(e[0].getTime()),l=e.length>1?new Date(e[e.length-1].getTime()):null)};if((!n||!s)&&d.length>0||e||this.parent.timelineModule.isZoomToFit){(h.length>0&&this.parent.timelineModule.isZoomToFit&&this.parent.treeGrid.filterModule&&this.parent.treeGrid.filterModule.filteredResult.length>0?h:d).forEach(function(e){p=[];var a,r,n=e.ganttProperties;t.isNullOrUndefined(n.startDate)&&t.isNullOrUndefined(n.endDate)?(a=null,r=null):(a=i.getValidStartDate(n),r=i.getValidEndDate(n)),u(o),u(l),u(a),u(r),i.parent.renderBaseline&&!i.parent.timelineModule.isZoomToFit&&(u(n.baselineStartDate),u(n.baselineEndDate)),n.indicators&&n.indicators.length>0&&!i.parent.timelineModule.isZoomToFit&&n.indicators.forEach(function(e){u(i.getDateFromFormat(e.date))}),c(p)}),p=[],u(o),u(l),this.parent.eventMarkers.length>0&&!this.parent.timelineModule.isZoomToFit&&this.parent.eventMarkers.forEach(function(e,t){u(i.getDateFromFormat(e.day))}),this.parent.totalHolidayDates.length>0&&!this.parent.timelineModule.isZoomToFit&&this.parent.totalHolidayDates.forEach(function(e,t){u(new Date(e))}),c(p),o&&l||(o?o=t.isNullOrUndefined(o)?this.getDateFromFormat(new Date):o:(o=t.isNullOrUndefined(o)?this.getDateFromFormat(new Date):o).setHours(0,0,0,0),(l=this.getDateFromFormat(new Date(o.getTime()))).setDate(l.getDate()+20))}else n&&s||0!==d.length||(o=this.getDateFromFormat(new Date),l=this.getDateFromFormat(new Date(o.getTime())));e?(t.setValue("minStartDate",o,e),t.setValue("maxEndDate",l,e)):(this.prevProjectStartDate=this.parent.cloneProjectStartDate,this.parent.cloneProjectStartDate=o?this.parent.timelineModule.isZoomToFit?o:t.isNullOrUndefined(n)?o:new Date(n.getTime()):new Date(n.getTime()),this.parent.cloneProjectEndDate=l?this.parent.timelineModule.isZoomToFit?l:t.isNullOrUndefined(s)?l:new Date(s.getTime()):new Date(s.getTime())),this.parent.isProjectDateUpdated=!0},i.prototype.splitTasksDuration=function(e){var t=0,i=e[0].startDate,a=e[e.length-1].endDate;return"Hour"===this.parent.timelineModule.bottomTier?t+=Math.ceil(this.getTimeDifference(i,a)/36e5):"Minutes"===this.parent.timelineModule.bottomTier?t+=Math.ceil(this.getTimeDifference(i,a)/6e4):t+=Math.ceil(this.getTimeDifference(i,a)/864e5),t},i}(),I=function(){var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(t,i)};return function(t,i){function a(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(a.prototype=i.prototype,new a)}}(),E=function(e){function i(t){var i=e.call(this,t)||this;return i.customSegmentProperties=[],i.isBaseline=!1,i.uid=0,i.isTaskIDInteger=!0,i.recordIndex=0,i.taskIds=[],i.hierarchyData=[],i.addEventListener(),i}return I(i,e),i.prototype.addEventListener=function(){this.parent.on("beforeDataManipulate",this.checkDataBinding.bind(this))},i.prototype.checkDataBinding=function(e){var i=this;if(e&&(this.parent.flatData=[],this.parent.currentViewData=[],this.parent.updatedRecords=[],this.dataArray=[],this.taskIds=[],this.parent.ids=[],this.recordIndex=0,this.hierarchyData=[],this.parent.predecessorsCollection=[],this.parent.treeGrid.parentData=[],this.parent.taskIds=[]),t.isNullOrUndefined(this.parent.dataSource))this.parent.dataSource=[],this.parent.processTimeline(),this.parent.renderGantt(e);else if(this.parent.dataSource instanceof a.DataManager)this.initDataSource(e);else{if(this.parent.dataSource instanceof Object&&y(this.parent)){var r=t.getValue("result",this.parent.dataSource);this.dataArray=r}else this.dataArray=this.parent.dataSource;this.processTimeline(),this.cloneDataSource(),this.parent.renderGantt(e),this.parent.flatData.map(function(e){i.parent.chartRowsModule.updateSegment(e.ganttProperties.segments,e.ganttProperties.taskId)})}this.parent.flatData.map(function(e){i.parent.chartRowsModule.updateSegment(e.ganttProperties.segments,e.ganttProperties.taskId)})},i.prototype.processTimeline=function(){this.parent.processTimeline(),this.parent.enableValidation||(this.parent.dataOperation.calculateProjectDatesForValidatedTasks(),this.parent.timelineModule.validateTimelineProp())},i.prototype.initDataSource=function(e){var t=this,i=this.parent.query instanceof a.Query?this.parent.query:new a.Query;i.requiresCount();var r=this.parent.dataSource;this.parent.loadChildOnDemand&&this.parent.taskFields.hasChildMapping?(this.processTimeline(),this.parent.renderGantt(e)):r.executeQuery(i).then(function(i){t.dataArray=i.result,t.processTimeline(),(!t.parent.loadChildOnDemand||t.parent.loadChildOnDemand&&!t.parent.taskFields.hasChildMapping)&&t.cloneDataSource(),t.parent.renderGantt(e)}).catch(function(i){t.parent.processTimeline(),t.parent.renderGantt(e),t.parent.trigger("actionFailure",{error:i})})},i.prototype.constructDataSource=function(e){for(var i,r=new a.DataManager(e).executeLocal((new a.Query).group(this.parent.taskFields.parentID)),n=[],s=0;s<r.length;s++){var o=r[s];!t.isNullOrUndefined(o.key)&&(i=this.taskIds.indexOf(o.key.toString()))>-1&&!t.isNullOrUndefined(o.key)?e[i][this.parent.taskFields.child]=o.items:(-1!==i||this.parent.loadChildOnDemand&&this.parent.taskFields.hasChildMapping)&&n.push.apply(n,o.items)}this.hierarchyData=this.dataReorder(e,n)},i.prototype.cloneDataSource=function(){var e=this.parent.taskFields.id,i=this.parent.taskFields.parentID,r=[];if(t.isNullOrUndefined(e)||t.isNullOrUndefined(i))r=this.dataArray;else{var n=[],s=void 0;this.parent.loadChildOnDemand&&this.parent.taskFields.hasChildMapping&&!this.parent.enableVirtualization&&(s=JSON.parse(JSON.stringify(this.dataArray)));for(var o=0;o<this.dataArray.length;o++){var l=this.dataArray[o];l.parentItem&&delete l.parentItem,n.push(t.extend({},{},l,!0)),t.isNullOrUndefined(l[e])||this.taskIds.push(l[e].toString())}this.parent.taskFields.child||this.parent.setProperties({taskFields:{child:"Children"}},!0),t.isNullOrUndefined(s)?this.constructDataSource(n):(this.constructDataSource(this.dataArray),this.dataArray=s),r=this.hierarchyData}if(this.parent.taskFields.segmentId&&(this.segmentCollection=new a.DataManager(this.parent.segmentData).executeLocal((new a.Query).group(this.parent.taskFields.segmentId)),this.parent.taskFields.segments||(this.parent.taskFields.segments="Segments")),"ProjectView"!==this.parent.viewType){var d=t.extend([],[],this.parent.resources,!0),h=[];if(this.constructResourceViewDataSource(d,r,h),h.length>0){var p={},u=this.parent.resourceFields.name||"resourceName";p[this.parent.resourceFields.id]=0,p[u]=this.parent.localeObj.getConstant("unassignedTask"),p[this.parent.taskFields.child]=h,d.push(p)}r=d}this.prepareDataSource(r)},i.prototype.constructResourceViewDataSource=function(e,t,i){for(var a=this,r=0;r<t.length;r++)!function(r){var n=t[r],s=null!==a.parent.taskFields.child?a.parent.taskFields.child:a.parent.taskFields.child="Children",o=n&&n[a.parent.taskFields.resourceInfo],l=a.parent.resourceFields.id;if(n[s]&&0!==n[s].length||!o||!o.length)(!n[s]||n[s]&&0===n[s].length)&&i.push(n);else if("string"==typeof o){a.isResourceString=!0;for(var d=o,h=0;h<e.length;h++)if(e[h][a.parent.resourceFields.name].toString()===d.toString()){e[h][s]?e[h][s].push(n):e[h][s]=[n];break}}else o.forEach(function(t){for(var i="object"==typeof t?t[l]:t,a=0;a<e.length;a++)if(e[a][l].toString()===i.toString()){e[a][s]?e[a][s].push(n):e[a][s]=[n];break}});n[a.parent.taskFields.child]&&n[a.parent.taskFields.child].length&&a.constructResourceViewDataSource(e,n[a.parent.taskFields.child],i)}(r)},i.prototype.prepareDataSource=function(e){this.prepareRecordCollection(e,0),this.parent.initialLoadData=t.extend({},{},this.parent.flatData,!0),(!this.parent.autoCalculateDateScheduling||this.parent.isLoad&&this.parent.treeGrid.loadChildOnDemand&&this.parent.taskFields.hasChildMapping)&&(this.parent.dataMap=this.parent.flatData.reduce(function(e,t){return e.set(t.uniqueID,t),e},new Map)),"ResourceView"===this.parent.viewType&&this.calculateSharedTaskUniqueIds(),this.parent.taskFields.dependency&&this.parent.predecessorModule&&this.parent.predecessorModule.ensurePredecessorCollection()},i.prototype.calculateSharedTaskUniqueIds=function(){for(var e=this,t=0;t<this.parent.getTaskIds().length;t++)!function(t){var i=[];if(i[0]=e.parent.getTaskIds()[t][0],i[1]=e.parent.getTaskIds()[t].slice(1),"R"!==i[0]){var a=[],r=[];e.parent.flatData.filter(function(e){e.ganttProperties.taskId.toString()===i[1]&&0!==e.level&&(r.push(e.ganttProperties.rowUniqueID),a.push(e))});for(var n=0;n<a.length;n++)a[n].ganttProperties.sharedTaskUniqueIds=r}}(t)},i.prototype.prepareRecordCollection=function(e,i,a){for(var r=this,n=e.length,s=this,o=0;o<n;o++)!function(n){var o=e[n];if(!t.isNullOrUndefined(s.parent.taskFields.segmentId)){var l=s.segmentCollection.filter(function(e){return e.key===o[r.parent.taskFields.id]});l.length>0&&(o[s.parent.taskFields.segments]=l[0].items)}s.parent.taskFields.hasChildMapping&&o.parentUniqueID&&(a=s.parent.getTaskByUniqueID(o.parentUniqueID)),!t.isNullOrUndefined(s.parent.taskFields.constraintDate)&&!t.isNullOrUndefined(s.parent.taskFields.constraintType)&&t.isNullOrUndefined(o[s.parent.taskFields.constraintDate])&&t.isNullOrUndefined(o[s.parent.taskFields.constraintType])&&(o[s.parent.taskFields.constraintType]=0,o[s.parent.taskFields.constraintDate]=t.isNullOrUndefined(o[s.parent.taskFields.startDate])?o[s.parent.taskFields.endDate]:o[s.parent.taskFields.startDate]);var d=s.createRecord(o,i,a,!0);(!s.parent.enableValidation||!s.parent.autoCalculateDateScheduling||s.parent.isLoad&&s.parent.treeGrid.loadChildOnDemand&&s.parent.taskFields.hasChildMapping)&&s.updateTaskLeftWidth(d),d.index=s.recordIndex++,s.parent.ids[d.index]=d.ganttProperties.rowUniqueID,s.parent.flatData.push(d),s.parent.setTaskIds(d);var h=o[s.parent.taskFields.child]||o.taskData&&o.taskData[s.parent.taskFields.child];if("ResourceView"===s.parent.viewType&&t.isNullOrUndefined(h)&&t.isNullOrUndefined(d.parentItem)&&0===d.level){var p=d.ganttProperties,u=d;s.parent.setRecordValue(p.isAutoSchedule?"startDate":"autoStartDate",null,u.ganttProperties,!0),s.parent.setRecordValue(p.isAutoSchedule?"endDate":"autoEndDate",null,u.ganttProperties,!0);var c=u.ganttProperties;s.parent.setRecordValue("isMilestone",!1,c,!0),c.isAutoSchedule&&s.calculateDuration(u),s.updateWorkWithDuration(u);var g=c.work;s.parent.setRecordValue("work",g,c,!0),s.parent.setRecordValue("taskType","FixedDuration",c,!0),t.isNullOrUndefined(s.parent.taskFields.type)||s.updateMappingData(u,"type"),s.parent.setRecordValue("progress",Math.floor(0),c,!0),s.parent.setRecordValue("totalProgress",0,c,!0),s.parent.setRecordValue("totalDuration",0,c,!0),c.isAutoSchedule||(s.parent.setRecordValue("autoDuration",s.calculateAutoDuration(c),c,!0),s.updateAutoWidthLeft(u)),s.parent.allowParentDependency||s.resetDependency(u),s.updateWidthLeft(u),s.updateTaskData(u)}s.parent.taskFields.hasChildMapping&&(a=null),!t.isNullOrUndefined(h)&&h.length>0&&s.prepareRecordCollection(h,d.level+1,d)}(o)},i.prototype.addCustomFieldValue=function(e,t){var i=this.parent.ganttColumns,a=i.length;if(a)for(var r=0;r<a;r++)void 0===t[i[r].field]&&this.parent.setRecordValue(i[r].field,e[i[r].field],t)},i.prototype.getGanttUid=function(e){return e+this.uid++},i.prototype.createRecord=function(e,i,a,r){var n=this.parent.taskFields,s=this.parent.resourceFields,o=e[n.progress],l=null,d=null,h=e[n.notes];o=100<(o=o&&parseFloat(o.toString())?parseFloat(o.toString()):0)?100:o;var p,u,c=e[n.dependency],g=this.getDateFromFormat(e[n.baselineStartDate],!0),f=this.getDateFromFormat(e[n.baselineEndDate],!0);this.parent.loadChildOnDemand&&n.hasChildMapping&&!this.parent.enableVirtualization?(p=e,u=JSON.parse(JSON.stringify(e))):p={};var m={},D="Auto"===this.parent.taskMode||"Manual"!==this.parent.taskMode&&!0!==e[n.manual];this.parent.setRecordValue("ganttProperties",m,p),e.ganttProperties&&e.ganttProperties.predecessor&&e.ganttProperties.predecessor.length>0&&this.parent.undoRedoModule&&this.parent.undoRedoModule.isUndoRedoPerformed&&this.parent.setRecordValue("predecessor",e.ganttProperties.predecessor,m,!0),t.isNullOrUndefined(e[n.id])?t.isNullOrUndefined(e[s.id])||(l=e[s.id],d=t.isNullOrUndefined(e[s.name])&&"Unassigned Task"===e.resourceName?e.resourceName:e[s.name],this.addTaskData(p,e,!1)):("number"==typeof(l=e[n.id])||/^-?\d+$/.test(l)||(this.isTaskIDInteger=!1),d=e[n.name],!!(this.parent.loadChildOnDemand&&n.hasChildMapping&&e