/*

@license
dhtmlxScheduler.Net v.4.0.3 Professional Evaluation

This software is covered by DHTMLX Evaluation License. Contact sales@dhtmlx.com to get Commercial or Enterprise license. Usage without proper license is prohibited.

(c) XB Software Ltd.

*/
Scheduler.plugin(function(e){e._temp_matrix_scope=function(){function t(e,a){if(a=a||[],e.children)for(var n=0;n<e.children.length;n++)a.push(e.children[n].key),t(e.children[n],a);return a}function a(e,t){var a=t.order[e];return void 0===a&&(a="$_"+e),a}function n(e,t){if(t[e.key]=e,e.children)for(var a=0;a<e.children.length;a++)n(e.children[a],t)}function i(e){for(var t={},a=e.y_unit_original||e.y_unit,i=0;i<a.length;i++)n(a[i],t);return t}function r(t,n){function r(e,t,a,n){e[t]||(e[t]=[])
;for(var i=a;i<=n;i++)e[t][i]||(e[t][i]=[]),e[t][i].push(u)}for(var o=[],d=0;d<n.y_unit.length;d++)o[d]=[];var l;o[l]||(o[l]=[]);var _=i(n),s="tree"==n.render;s&&(o.$tree={});for(var c=n.y_property,d=0;d<t.length;d++){var u=t[d],h=u[c];l=a(h,n);var p=e._get_date_index(n,u.start_date),v=e._get_date_index(n,u.end_date);u.end_date.valueOf()==n._trace_x[v].valueOf()&&(v-=1),o[l]||(o[l]=[]),r(o,l,p,v);var m=_[h];if(s&&m&&m.$parent)for(var g={};m.$parent;){
if(g[m.key])throw new Error("Invalid sections tree. Section `{key:'"+m.key+"', label:'"+m.label+"'}` has the same key as one of its parents. Make sure all sections have unique keys");g[m.key]=!0;var f=_[m.$parent];r(o.$tree,f.key,p,v),m=f}}return o}function o(){var e=document.createElement("p");e.style.width="100%",e.style.height="200px";var t=document.createElement("div");t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.visibility="hidden",t.style.width="200px",
t.style.height="150px",t.style.overflow="hidden",t.appendChild(e),document.body.appendChild(t);var a=e.offsetWidth;t.style.overflow="scroll";var n=e.offsetWidth;return a==n&&(n=t.clientWidth),document.body.removeChild(t),a-n}function d(t){return e._helpers.formatDate(t)}function l(t,a){var n=t.querySelector(".dhx_timeline_data_wrapper");return a.scrollable||(n=e.$container.querySelector(".dhx_cal_data")),n}function _(e){return e.querySelector(".dhx_timeline_label_wrapper")}function s(){
return e.$container.querySelector(".dhx_cal_data .dhx_timeline_label_col")}function c(t,a,n,i){function r(e){if(e=e||window.event,!e.shiftKey){var t=e.deltaY||e.detail||-e.wheelDelta;t=t<0?-100:100,d.scrollTop+=t,e.preventDefault&&e.preventDefault()}}a._is_ev_creating=!1;var d=l(t,a),c=e._els.dhx_cal_header[0],u=_(t);if(u&&(u.addEventListener?"onwheel"in document?u.addEventListener("wheel",r):"onmousewheel"in document&&u.addEventListener("mousewheel",r):u.attachEvent("onmousewheel",r),
!u.$eventsAttached)){u.$eventsAttached=!0;var h={pageX:0,pageY:0};u.addEventListener("touchstart",function(e){var t=e;e.touches&&(t=e.touches[0]),h={pageX:t.pageX,pageY:t.pageY}}),u.addEventListener("touchmove",function(e){var t=e;e.touches&&(t=e.touches[0]);var a=h.pageY-t.pageY;h={pageX:t.pageX,pageY:t.pageY},a&&(d.scrollTop+=a),e&&e.preventDefault&&e.preventDefault()})}var p;if(d.onscroll=function(r){
var _=l(t,a),u=_.scrollTop,h=a.scrollHelper.getScrollValue(_),v=e._timeline_smart_render.getViewPort(a.scrollHelper,0,h,u),m=s();if(a.scrollable&&(m.style.top=-u+"px"),!1!==a.smart_rendering){if((h!==a._x_scroll||a._is_ev_creating)&&(a.second_scale?e._timeline_smart_render.updateHeader(a,v,c.children[1]):e._timeline_smart_render.updateHeader(a,v,c.children[0])),e.config.rtl){
var g=+e.$container.querySelector(".dhx_timeline_label_wrapper").style.height.replace("px",""),f=a._section_height[a.y_unit.length]+a._label_rows[a._label_rows.length-1].top;a.scrollHelper.getMode()==a.scrollHelper.modes.minMax&&(f>g||"tree"==a.render)?c.style.right=-1-h-o()+"px":c.style.right=-1-h+"px",c.style.left="unset"}else c.style.left=-1-h+"px";(a._options_changed||u!==a._y_scroll||a._is_ev_creating)&&e._timeline_smart_render.updateLabels(a,v,m),a._is_ev_creating=!1,
e._timeline_smart_render.updateGridCols(a,v),e._timeline_smart_render.updateGridRows(a,v);var y=!1;"cell"!=a.render&&(window.requestAnimationFrame?(y=!0,p&&cancelAnimationFrame(p),p=requestAnimationFrame(function(){a.name===e.getState().mode&&(e._timeline_smart_render.updateEvents(a,v),p=0,a.callEvent("onScroll",[a.scrollHelper.getScrollValue(d),d.scrollTop]))})):e._timeline_smart_render.updateEvents(a,v));var b=0;a._scales={};var x
;x="cell"===a.render?_.querySelectorAll(".dhx_timeline_data_col .dhx_timeline_data_row"):_.querySelectorAll(".dhx_timeline_data_col .dhx_matrix_line");for(var k=0,w=x.length;k<w;k++){var D=x[k].getAttribute("data-section-id"),E=a.order[D];n[E]=i[E].height,a._scales[D]=x[k]}for(var k=0,w=n.length;k<w;k++)b+=n[k];e.$container.querySelector(".dhx_timeline_data_col").style.height=b+"px"
;var S=_.scrollTop,M=a.scrollHelper.getScrollValue(_),N=a._summ-e.$container.querySelector(".dhx_cal_data").offsetWidth+a.dx+a.custom_scroll_width;e._timeline_save_scroll_pos(a,S,M,N),y||a.callEvent("onScroll",[M,S]),a._is_new_view=!1}},!d.$eventsAttached){d.$eventsAttached=!0;var v={pageX:0,pageY:0};d.addEventListener("touchstart",function(e){var t=e;e.touches&&(t=e.touches[0]),v={pageX:t.pageX,pageY:t.pageY}}),d.addEventListener("touchmove",function(t){var n=t;t.touches&&(n=t.touches[0])
;var i=s(),r=v.pageX-n.pageX,o=v.pageY-n.pageY;if(v={pageX:n.pageX,pageY:n.pageY},(r||o)&&!e.getState().drag_id){var l=Math.abs(r),_=Math.abs(o),c=Math.sqrt(r*r+o*o),u=l/c,h=_/c;u<.42?r=0:h<.42&&(o=0),a.scrollHelper.setScrollValue(d,a.scrollHelper.getScrollValue(d)+r),d.scrollTop+=o,a.scrollable&&o&&(i.style.top=-d.scrollTop+"px")}return t&&t.preventDefault&&t.preventDefault(),!1})}a.scroll_position&&a._is_new_view?a.scrollTo(a.scroll_position):e._timeline_set_scroll_pos(t,a),
a._is_ev_creating=!0}function u(e,t){if(e.closest)return e.closest(t);if(e.matches||e.msMatchesSelector||e.webkitMatchesSelector){var a=e;if(!document.documentElement.contains(a))return null;do{if((a.matches||a.msMatchesSelector||a.webkitMatchesSelector).call(a,t))return a;a=a.parentElement||a.parentNode}while(null!==a&&1===a.nodeType);return null}return window.console.error("Your browser is not supported"),null}function h(t,a){var n=e.matrix[e._mode],i={},r={},o=a
;for(i.x=t.touches?t.touches[0].pageX:t.pageX,i.y=t.touches?t.touches[0].pageY:t.pageY,r.left=o.offsetLeft+n.dx,r.top=o.offsetTop;o;)r.left+=o.offsetLeft,r.top+=o.offsetTop,o=o.offsetParent;return{x:i.x-r.left,y:i.y-r.top}}function p(t){N&&clearInterval(N),e._schedulerOuter=e.$container.querySelector(".dhx_timeline_data_wrapper");var a={pageX:t.touches?t.touches[0].pageX:t.pageX,pageY:t.touches?t.touches[0].pageY:t.pageY};N=setInterval(function(){v(a)},M)}function v(t){
if(!e.getState().drag_id)return clearInterval(N),void(A=null);var a=e.matrix[e._mode];if(a){var n=e._schedulerOuter,i=h(t,n),r=n.offsetWidth-a.dx,o=n.offsetHeight,d=i.x,l=i.y,_=a.autoscroll||{};e._merge(_,{range_x:200,range_y:100,speed_x:20,speed_y:10});var s=m(d,r,A?A.x:0,_.range_x);a.scrollable||(s=0);var c=m(l,o,A?A.y:0,_.range_y);!c&&!s||A||(A={x:d,y:l},s=0,c=0),s*=_.speed_x,c*=_.speed_y,s&&c&&(Math.abs(s/5)>Math.abs(c)?c=0:Math.abs(c/5)>Math.abs(s)&&(s=0)),s||c?(A.started=!0,
g(s,c)):clearInterval(N)}}function m(e,t,a,n){return e<n&&(!A||A.started||e<a)?-1:t-e<n&&(!A||A.started||e>a)?1:0}function g(t,a){var n=e._schedulerOuter;a&&(n.scrollTop+=a),t&&(n.scrollLeft+=t)}var f=function(){return function(){function e(){var e=document.createElement("div");e.style.cssText="direction: rtl;overflow: auto;width:100px;height: 100px;position:absolute;top: -100500px;left: -100500px;";var t=document.createElement("div");return t.style.cssText="width: 100500px;height: 1px;",
e.appendChild(t),e}function t(){var t=d.minMax,a=e();return document.body.appendChild(a),a.scrollLeft>0?t=d.minMax:(a.scrollLeft=-50,t=-50===a.scrollLeft?d.nMaxMin:d.maxMin),document.body.removeChild(a),t}function a(e,t){var a=r();return a===d.nMaxMin?e?-e:0:a===d.minMax?t-e:e}function n(e){var t=getComputedStyle(e).direction;if(t&&"ltr"!==t){var n=e.scrollWidth-e.offsetWidth;return a(e.scrollLeft,n)}return e.scrollLeft}function i(e,t){var n=getComputedStyle(e).direction;if(n&&"ltr"!==n){
var i=e.scrollWidth-e.offsetWidth,r=a(t,i);e.scrollLeft=r}else e.scrollLeft=t}function r(){return o||(o=t()),o}var o,d={minMax:"[0;max]",maxMin:"[max;0]",nMaxMin:"[-max;0]"};return{modes:d,getMode:r,normalizeValue:a,getScrollValue:n,setScrollValue:i}}}();e.matrix={},e._merge=function(e,t){for(var a in t)void 0===e[a]&&(e[a]=t[a])},e.createTimelineView=function(a){function n(a,n,i){var r=e._timeline_smart_render.getPreparedEvents(i),o=i.order[a],d=i.y_unit[o];if(!d)return[];var l=[a];n&&t(d,l)
;for(var _=[],s=0;s<l.length;s++){var o=i.order[l[s]];if(void 0!==o&&r[o])_=_.concat(r[o]);else if(r.undefined)for(var c=0;c<r.undefined.length;c++){var u=r.undefined[c];u[i.y_property]==l[s]&&_.push(u)}}return _}function i(t,a,n,i){var r=e._timeline_smart_render.getPreparedEvents(i),o=[],d=[],l=i.order[t],_=i.y_unit[l];if(!_)return[];var s=e._get_date_index(i,a);return r.$matrix?(o=r.$matrix[l][s]||[],n&&r.$matrix.$tree&&r.$matrix.$tree[_.key]&&(d=r.$matrix.$tree[_.key][s]||[]),
o.concat(d)):r[l]||[]}function r(t,a,n){for(var i=e.date[n.name+"_start"](new Date(t)),r=0,o=i,d=n.x_step,l=n.x_unit;o<a;)r++,o=e.date.add(o,d,l);return r}e._skin_init(),e._merge(a,{scrollHelper:f(),column_width:100,autoscroll:{range_x:200,range_y:100,speed_x:20,speed_y:10},_is_new_view:!0,_section_autowidth:!0,_x_scroll:0,_y_scroll:0,_h_cols:{},_label_rows:[],section_autoheight:!0,name:"matrix",x:"time",y:"time",x_step:1,x_unit:"hour",y_unit:"day",y_step:1,x_start:0,x_size:24,y_start:0,
y_size:7,render:"cell",dx:200,dy:50,event_dy:e.xy.bar_height-5,event_min_dy:e.xy.bar_height-5,resize_events:!0,fit_events:!0,show_unassigned:!1,second_scale:!1,round_position:!1,_logic:function(t,a,n){var i={};return e.checkEvent("onBeforeSectionRender")&&(i=e.callEvent("onBeforeSectionRender",[t,a,n])),i}}),a._original_x_start=a.x_start,"day"!=a.x_unit&&(a.first_hour=a.last_hour=0),a._start_correction=a.first_hour?60*a.first_hour*60*1e3:0,
a._end_correction=a.last_hour?60*(24-a.last_hour)*60*1e3:0,e.checkEvent("onTimelineCreated")&&e.callEvent("onTimelineCreated",[a]),dhtmlxEventable(a);var d=e.render_data;e.render_data=function(t,n){if(this._mode!=a.name)return d.apply(this,arguments);if(n&&!a.show_unassigned&&"cell"!=a.render)for(var i=0;i<t.length;i++)this.clear_event(t[i]),this.render_timeline_event.call(this.matrix[this._mode],t[i],!0);else e._renderMatrix.call(a,!0,!0)},e.matrix[a.name]=a,
e.templates[a.name+"_cell_value"]=function(e){return e?e.length:""},e.templates[a.name+"_cell_class"]=function(e){return""},e.templates[a.name+"_scalex_class"]=function(e){return""},e.templates[a.name+"_second_scalex_class"]=function(e){return""},e.templates[a.name+"_row_class"]=function(e,t){return t.folder_events_available&&e.children?"folder":""},e.templates[a.name+"_scaley_class"]=function(e,t,a){return""},e.templates[a.name+"_scale_label"]=function(e,t,a){return t},
e.templates[a.name+"_tooltip"]=function(e,t,a){return a.text},e.templates[a.name+"_date"]=function(t,a){return t.getDay()==a.getDay()&&a-t<864e5||+t==+e.date.date_part(new Date(a))||+e.date.add(t,1,"day")==+a&&0===a.getHours()&&0===a.getMinutes()?e.templates.day_date(t):t.getDay()!=a.getDay()&&a-t<864e5?e.templates.day_date(t)+" &ndash; "+e.templates.day_date(a):e.templates.week_date(t,a)},e.templates[a.name+"_scale_date"]=e.date.date_to_str(a.x_date||e.config.hour_date),
e.templates[a.name+"_second_scale_date"]=e.date.date_to_str(a.second_scale&&a.second_scale.x_date?a.second_scale.x_date:e.config.hour_date),e.date["add_"+a.name+"_private"]=function(t,n){var i=n,r=a.x_unit;if("minute"==a.x_unit||"hour"==a.x_unit){var o=i;"hour"==a.x_unit&&(o*=60),o%1440||(i=o/1440,r="day")}return e.date.add(t,i,r)},e.date["add_"+a.name]=function(t,n,i){var r=e.date["add_"+a.name+"_private"](t,(a.x_length||a.x_size)*a.x_step*n);if("minute"==a.x_unit||"hour"==a.x_unit){
var o=a.x_length||a.x_size,d="hour"==a.x_unit?60*a.x_step:a.x_step;if(d*o%1440)if(+e.date.date_part(new Date(t))==+e.date.date_part(new Date(r)))a.x_start+=n*o;else{var l=1440/(o*d)-1,_=Math.round(l*o);a.x_start=n>0?a.x_start-_:_+a.x_start}}return r},e.date[a.name+"_start"]=function(t){var n=e.date[a.x_unit+"_start"]||e.date.day_start,i=n.call(e.date,t),r=i.getTimezoneOffset();i=e.date.add(i,a.x_step*a.x_start,a.x_unit);var o=i.getTimezoneOffset();return r!=o&&i.setTime(i.getTime()+6e4*(o-r)),i
},a.scrollTo=e.bind(function(t){if(t){var a;a=t.date?t.date:t.left?t.left:t;var n=-1;t.section?n=this.posFromSection(t.section):t.top&&(n=t.top);var i;if(i="number"==typeof a?a:this.posFromDate(a),e.config.rtl){var r=+e.$container.querySelector(".dhx_timeline_label_wrapper").style.height.replace("px",""),d=this._section_height[this.y_unit.length]+this._label_rows[this._label_rows.length-1].top;this.scrollHelper.getMode()==this.scrollHelper.modes.minMax&&(d>r||"tree"==this.render)&&(i-=o())}
var l=e.$container.querySelector(".dhx_timeline_data_wrapper");this.scrollable||(l=e.$container.querySelector(".dhx_cal_data")),this.scrollable&&this.scrollHelper.setScrollValue(l,i),n>0&&(l.scrollTop=n)}},a),a.getScrollPosition=e.bind(function(){return{left:this._x_scroll||0,top:this._y_scroll||0}},a),a.posFromDate=e.bind(function(t){return e._timeline_getX({start_date:t},!1,this)-1},a),a.posFromSection=e.bind(function(e){var t=this.order[e];if(void 0===t)return-1;var a=0
;for(var n in this.order)this.order[n]<t&&(a+=this._section_height[n]);return a},a),a.selectEvents=e.bind(function(e){var t=e.section,a=e.date,r=e.selectNested;return a?i(t,a,r,this):t?n(t,r,this):void 0},a),a.setRange=e.bind(function(t,a){var n=e.date[this.name+"_start"](new Date(t)),i=r(t,a,this);this.x_size=i,e.setCurrentView(n,this.name)},a),e.callEvent("onOptionsLoad",[a]),e[a.name+"_view"]=function(t){t?e._set_timeline_dates(a):e._renderMatrix.apply(a,arguments)};var l=new Date
;e.date.add(l,a.x_step,a.x_unit).valueOf(),l.valueOf();e["mouse_"+a.name]=function(t){var n=this._drag_event;if(this._drag_id&&(n=this.getEvent(this._drag_id)),a.scrollable&&!t.converted){if(t.converted=1,t.x+=-a.dx+a._x_scroll,e.config.rtl){var i=+e.$container.querySelector(".dhx_timeline_label_wrapper").style.height.replace("px",""),r=a._section_height[a.y_unit.length]+a._label_rows[a._label_rows.length-1].top;t.x+=e.xy.scale_width,
a.scrollHelper.getMode()==a.scrollHelper.modes.minMax&&(r>i||"tree"==a.render)&&(t.x+=o())}t.y+=a._y_scroll}else e.config.rtl?t.x-=a.dx-e.xy.scale_width:t.x-=a.dx;var d=e._timeline_drag_date(a,t.x);if(t.x=0,t.force_redraw=!0,t.custom=!0,"move"==this._drag_mode&&this._drag_id&&this._drag_event){var n=this.getEvent(this._drag_id),l=this._drag_event;if(t._ignores=this._ignores_detected||a._start_correction||a._end_correction,void 0===l._move_delta&&(l._move_delta=(n.start_date-d)/6e4,
this.config.preserve_length&&t._ignores&&(l._move_delta=this._get_real_event_length(n.start_date,d,a),l._event_length=this._get_real_event_length(n.start_date,n.end_date,a))),this.config.preserve_length&&t._ignores){var _=(l._event_length,this._get_fictional_event_length(d,l._move_delta,a,!0));d=new Date(d-_)}else d=e.date.add(d,l._move_delta,"minute")}
if("resize"==this._drag_mode&&n&&(this.config.timeline_swap_resize&&this._drag_id&&(this._drag_from_start&&+d>+n.end_date?this._drag_from_start=!1:!this._drag_from_start&&+d<+n.start_date&&(this._drag_from_start=!0)),t.resize_from_start=this._drag_from_start,!this.config.timeline_swap_resize&&this._drag_id&&this._drag_from_start&&+d>=+e.date.add(n.end_date,-e.config.time_step,"minute")&&(d=e.date.add(n.end_date,-e.config.time_step,"minute"))),a.round_position)switch(this._drag_mode){case"move":
this.config.preserve_length||(d=e._timeline_get_rounded_date.call(a,d,!1),"day"==a.x_unit&&(t.custom=!1));break;case"resize":this._drag_event&&(null!==this._drag_event._resize_from_start&&void 0!==this._drag_event._resize_from_start||(this._drag_event._resize_from_start=t.resize_from_start),t.resize_from_start=this._drag_event._resize_from_start,d=e._timeline_get_rounded_date.call(a,d,!this._drag_event._resize_from_start))}this._resolve_timeline_section(a,t),
t.section&&this._update_timeline_section({pos:t,event:this.getEvent(this._drag_id),view:a}),t.y=Math.round((this._correct_shift(d,1)-this._min_date)/(6e4*this.config.time_step)),t.shift=this.config.time_step,a.round_position&&"new-size"==this._drag_mode&&d<=this._drag_start&&(t.shift=e.date.add(this._drag_start,a.x_step,a.x_unit)-this._drag_start);var s=this._is_pos_changed(this._drag_pos,t);return this._drag_pos&&s&&(this._drag_event._dhx_changed=!0),
s||this._drag_pos.has_moved||(t.force_redraw=!1),t}},e._prepare_timeline_events=function(t){var a=[];if("cell"==t.render)a=e._timeline_trace_events.call(t);else{for(var n=e.get_visible_events(),i=t.order,r=0;r<n.length;r++){var o=n[r],d=o[t.y_property],l=t.order[d];t.y_unit[l];if(t.show_unassigned&&!d){for(var _ in i)if(i.hasOwnProperty(_)){l=i[_],a[l]||(a[l]=[]);var s=e._lame_copy({},o);s[t.y_property]=_,a[l].push(s);break}}else a[l]||(a[l]=[]),a[l].push(o)}
a.$matrix=e._timeline_trace_events.call(t)}return a},e._populate_timeline_rendered=function(t){e._rendered=[];for(var a=t.querySelectorAll("div[event_id]"),n=0;n<a.length;n++)e._rendered.push(a[n])},e._get_timeline_event_height=function(e,t){var a=e[t.y_property],n=t.event_dy;return"full"==t.event_dy&&(n=t.section_autoheight?t._section_height[a]-6:t.dy-3),t.resize_events&&(n=Math.max(Math.floor(n/(e._count||1)),t.event_min_dy)),n},e._get_timeline_event_y=function(t,a){
var n=t||0,i=2+n*a+(n?2*n:0);return e.config.cascade_event_display&&(i=2+n*e.config.cascade_event_margin+(n?2*n:0)),i},e.render_timeline_event=function(t,a){var n=t[this.y_property];if(!n)return"";var i=t._sorder,r=e._timeline_getX(t,!1,this),o=e._timeline_getX(t,!0,this),d=e._get_timeline_event_height(t,this),l=d-2;t._inner||"full"!=this.event_dy||(l=(l+2)*(t._count-i)-2),l+=3;var _=e._get_timeline_event_y(t._sorder,d),s=d+_+2
;(!this._events_height[n]||this._events_height[n]<s)&&(this._events_height[n]=s);var c=e.templates.event_class(t.start_date,t.end_date,t);c="dhx_cal_event_line "+(c||""),e.getState().select_id==t.id&&(c+=" dhx_cal_event_selected"),t._no_drag_move&&(c+=" no_drag_move")
;var u=t.color?"background:"+t.color+";":"",h=t.textColor?"color:"+t.textColor+";":"",p=e.templates.event_bar_text(t.start_date,t.end_date,t),v="<div "+e._waiAria.eventBarAttrString(t)+" event_id='"+t.id+"' class='"+c+"' style='"+u+h+"position:absolute; top:"+_+"px; height: "+l+"px; "+(e.config.rtl?"right:":"left:")+r+"px; width:"+Math.max(0,o-r)+"px;"+(t._text_style||"")+"'>";if(e.config.drag_resize&&!e.config.readonly){
var m="dhx_event_resize",g=l+1,f="<div class='"+m+" "+m+"_start' style='height: "+g+"px;'></div>",y="<div class='"+m+" "+m+"_end' style='height: "+g+"px;'></div>";v+=(t._no_resize_start?"":f)+(t._no_resize_end?"":y)}if(v+=p+"</div>",!a)return v;var b=document.createElement("div");b.innerHTML=v;var x=this._scales[n];x&&(e._rendered.push(b.firstChild),x.appendChild(b.firstChild))};var y=function(e){return String(e).replace(/'/g,"&apos;").replace(/"/g,"&quot;")},b=function(e){
return String(e).replace(/'/g,"\\'").replace(/"/g,'\\"')};e._timeline_trace_events=function(){return r(e.get_visible_events(),this)},e._timeline_getX=function(t,a,n){var i=0,r=n._step,o=n.round_position,d=0,l=a?t.end_date:t.start_date;l.valueOf()>e._max_date.valueOf()&&(l=e._max_date);var _=l-e._min_date_timeline;if(_>0){var s=e._get_date_index(n,l);e._ignores[s]&&(o=!0);for(var c=0;c<s;c++)i+=e._cols[c];var u=e._timeline_get_rounded_date.apply(n,[l,!1]);o?+l>+u&&a&&(d=e._cols[s]):(_=l-u,
n.first_hour||n.last_hour?(_-=n._start_correction,_<0&&(_=0),(d=Math.round(_/r))>e._cols[s]&&(d=e._cols[s])):d=Math.round(_/r))}e._border_box_events();return i+=a?0===_||o?d-2:d:d+1},e._timeline_get_rounded_date=function(t,a){var n=e._get_date_index(this,t),i=this._trace_x[n];return a&&+t!=+this._trace_x[n]&&(i=this._trace_x[n+1]?this._trace_x[n+1]:e.date.add(this._trace_x[n],this.x_step,this.x_unit)),new Date(i)},e._timeline_skip_ignored=function(t){
if(e._ignores_detected)for(var a,n,i,r,o=0;o<t.length;o++){for(r=t[o],i=!1,a=e._get_date_index(this,r.start_date),n=e._get_date_index(this,r.end_date);a<n;){if(!e._ignores[a]){i=!0;break}a++}i||a!=n||e._ignores[n]||+r.end_date>+this._trace_x[n]&&(i=!0),i||(t.splice(o,1),o--)}},e._timeline_calculate_event_positions=function(t){if(t&&"cell"!=this.render){e._timeline_skip_ignored.call(this,t),t.sort(this.sort||function(e,t){
return e.start_date.valueOf()==t.start_date.valueOf()?e.id>t.id?1:-1:e.start_date>t.start_date?1:-1});for(var a=[],n=t.length,i=-1,r=null,o=0;o<n;o++){var d=t[o];d._inner=!1;var l=this.round_position?e._timeline_get_rounded_date.apply(this,[d.start_date,!1]):d.start_date;for(this.round_position?e._timeline_get_rounded_date.apply(this,[d.end_date,!0]):d.end_date;a.length;){if(!(a[a.length-1].end_date.valueOf()<=l.valueOf()))break;a.splice(a.length-1,1)}for(var _=!1,s=0;s<a.length;s++){var c=a[s]
;if(c.end_date.valueOf()<=l.valueOf()){_=!0,d._sorder=c._sorder,a.splice(s,1),d._inner=!0;break}}if(a.length&&(a[a.length-1]._inner=!0),!_)if(a.length)if(a.length<=a[a.length-1]._sorder){if(a[a.length-1]._sorder)for(var u=0;u<a.length;u++){for(var h=!1,p=0;p<a.length;p++)if(a[p]._sorder==u){h=!0;break}if(!h){d._sorder=u;break}}else d._sorder=0;d._inner=!0}else{for(var v=a[0]._sorder,m=1;m<a.length;m++)a[m]._sorder>v&&(v=a[m]._sorder);d._sorder=v+1,i<d._sorder&&(i=d._sorder,r=d),d._inner=!1
}else d._sorder=0;a.push(d),a.length>(a.max_count||0)?(a.max_count=a.length,d._count=a.length):d._count=d._count?d._count:1}for(var g=0;g<t.length;g++)t[g]._count=a.max_count,e._register_copy&&e._register_copy(t[g]);(r||t[0])&&e.render_timeline_event.call(this,r||t[0],!1)}},e._timeline_get_events_html=function(t){var a="";if(t&&"cell"!=this.render)for(var n=0;n<t.length;n++)a+=e.render_timeline_event.call(this,t[n],!1);return a},e._timeline_update_events_html=function(t){var a=""
;if(t&&"cell"!=this.render){var n=e.getView(),i={},r=function(e,t){return e+"_"+t};t.forEach(function(e){i[r(e.id,e[n.y_property])]=!0}),e._rendered.forEach(function(e){if(e.parentNode){var t=e.parentNode.getAttribute("data-section-id");i[r(e.getAttribute("event_id"),t)]&&e.parentNode.removeChild(e)}});for(var o=0;o<t.length;o++)a+=e.render_timeline_event.call(this,t[o],!1)}return a},e._timeline_get_block_stats=function(t,a){var n={};return a._sch_height=t.offsetHeight,
n.style_data_wrapper=(e.config.rtl?"padding-right:":"padding-left:")+a.dx+"px;",n.style_label_wrapper="width: "+a.dx+"px;",a.scrollable?(n.style_data_wrapper+="height:"+(a._sch_height-1)+"px;",void 0===a.html_scroll_width&&(a.html_scroll_width=o()),a._section_autowidth?a.custom_scroll_width=0:a.custom_scroll_width=a.html_scroll_width,n.style_label_wrapper+="height:"+(a._sch_height-1-a.custom_scroll_width)+"px;"):(n.style_data_wrapper+="height:"+(a._sch_height-1)+"px;",
n.style_label_wrapper+="height:"+(a._sch_height-1)+"px;overflow:visible;"),n},e._timeline_get_cur_row_stats=function(t,a){var n=t._logic(t.render,t.y_unit[a],t);if(e._merge(n,{height:t.dy}),t.section_autoheight){var i=t.scrollable?t._sch_height-e.xy.scroll_width:t._sch_height;t.y_unit.length*n.height<i&&(n.height=Math.max(n.height,Math.floor((i-1)/t.y_unit.length)))}return t._section_height[t.y_unit[a].key]=n.height,
n.td_className||(n.td_className="dhx_matrix_scell"+(e.templates[t.name+"_scaley_class"](t.y_unit[a].key,t.y_unit[a].label,t.y_unit[a])?" "+e.templates[t.name+"_scaley_class"](t.y_unit[a].key,t.y_unit[a].label,t.y_unit[a]):"")),n.td_content||(n.td_content=e.templates[t.name+"_scale_label"](t.y_unit[a].key,t.y_unit[a].label,t.y_unit[a])),e._merge(n,{tr_className:"",style_height:"height:"+n.height+"px;",style_width:"width:"+t.dx+"px;",summ_width:"width:"+t._summ+"px;",table_className:""}),n},
e._timeline_get_fit_events_stats=function(e,t,a){if(e.fit_events){var n=e._events_height[e.y_unit[t].key]||0;a.height=n>a.height?n:a.height,a.style_height="height:"+a.height+"px;",a.style_line_height="line-height:"+(a.height-1)+"px;",e._section_height[e.y_unit[t].key]=a.height}return a.style_height="height:"+a.height+"px;",a.style_line_height="line-height:"+(a.height-1)+"px;",e._section_height[e.y_unit[t].key]=a.height,a},e._timeline_set_scroll_pos=function(e,t){
var a=e.querySelector(".dhx_timeline_data_wrapper");a.scrollTop=t._y_scroll||0,t.scrollHelper.setScrollValue(a,t._x_scroll||0),t.scrollHelper.getMode()!=t.scrollHelper.modes.maxMin&&a.scrollLeft==t._summ-a.offsetWidth+t.dx&&(a.scrollLeft+=o())},e._timeline_save_scroll_pos=function(e,t,a,n){e._y_scroll=t||0,e._x_scroll=a||0},e._timeline_get_html_for_cell_data_row=function(e,t,a,n,i){var r="";return i.template&&(r+=" "+(i.template(i.section,i.view)||"")),
"<div class='dhx_timeline_data_row"+r+"' data-section-id='"+y(n)+"' data-section-index='"+e+"' style='"+t.summ_width+t.style_height+" position:absolute; top:"+a+"px;'>"},e._timeline_get_html_for_cell_ignores=function(e){return'<div class="dhx_matrix_cell dhx_timeline_data_cell" style="'+e.style_height+e.style_line_height+';display:none"></div>'},e._timeline_get_html_for_cell=function(t,a,n,i,r,o){var l=n._trace_x[t],_=n.y_unit[a],s=e._cols[t],c=d(l),u=e.templates[n.name+"_cell_value"](i,l,_)
;return"<div data-col-id='"+t+"' data-col-date='"+c+"' class='dhx_matrix_cell dhx_timeline_data_cell "+e.templates[n.name+"_cell_class"](i,l,_)+"' style='width:"+s+"px;"+r.style_height+r.style_line_height+(e.config.rtl?" right:":"  left:")+o+"px;'><div style='width:auto'>"+u+"</div></div>"},e._timeline_get_html_for_bar_matrix_line=function(e,t,a,n){
return"<div style='"+t.summ_width+" "+t.style_height+" position:absolute; top:"+a+"px;' data-section-id='"+y(n)+"' data-section-index='"+e+"' class='dhx_matrix_line'>"},e._timeline_get_html_for_bar_data_row=function(e,t){var a=e.table_className;return t.template&&(a+=" "+(t.template(t.section,t.view)||"")),"<div class='dhx_timeline_data_row "+a+"' style='"+e.summ_width+" "+e.style_height+"' >"},e._timeline_get_html_for_bar_ignores=function(){return""},
e._timeline_get_html_for_bar=function(t,a,n,i,r,o){var l=d(n._trace_x[t]),_=n.y_unit[a],s="";n.cell_template&&(s=e.templates[n.name+"_cell_value"](i,n._trace_x[t],_,o));var c="line-height:"+n._section_height[_.key]+"px;"
;return"<div class='dhx_matrix_cell dhx_timeline_data_cell "+e.templates[n.name+"_cell_class"](i,n._trace_x[t],_,o)+"' style='width:"+e._cols[t]+"px; "+(e.config.rtl?"right:":"left:")+r+"px;'  data-col-id='"+t+"' data-col-date='"+l+"' ><div style='width:auto; height:100%;position:relative;"+c+"'>"+s+"</div></div>"},e._timeline_render_scale_header=function(t,a){var n=e.$container.querySelector(".dhx_timeline_scale_header");if(n&&n.parentNode.removeChild(n),a){n=document.createElement("div")
;var i="dhx_timeline_scale_header";t.second_scale&&(i+=" dhx_timeline_second_scale");var r=e.xy.scale_height;n.className=i,n.style.cssText=["width:"+(t.dx-1)+"px","height:"+r+"px","line-height:"+r+"px","top:"+(e.xy.nav_height+2)+"px",e.config.rtl?"right:0":"left:0"].join(";"),n.innerHTML=e.locale.labels[t.name+"_scale_header"]||"",e.$container.appendChild(n)}},e._timeline_y_scale=function(t){
var a=e._timeline_get_block_stats(t,this),n=this.scrollable?" dhx_timeline_scrollable_data":"",i="<div class='dhx_timeline_table_wrapper'>",r="<div class='dhx_timeline_label_wrapper' style='"+a.style_label_wrapper+"'><div class='dhx_timeline_label_col'>",o="<div class='dhx_timeline_data_wrapper"+n+"' style='"+a.style_data_wrapper+"'><div class='dhx_timeline_data_col'>";e._load_mode&&e._load(),e._timeline_smart_render.clearPreparedEventsCache(d)
;var d=e._timeline_smart_render.getPreparedEvents(this);e._timeline_smart_render.cachePreparedEvents(d);for(var l=0,_=0;_<e._cols.length;_++)l+=e._cols[_];var s=new Date,u=e._cols.length-e._ignores_detected;s=(e.date.add(s,this.x_step*u,this.x_unit)-s-(this._start_correction+this._end_correction)*u)/l,this._step=s,this._summ=l;var h=e._colsS.heights=[],p=[];this._events_height={},this._section_height={},this._label_rows=[];var v=!1,m=0,g=null
;(this.scrollable||this.smart_rendering)&&(g=e._timeline_smart_render.getViewPort(this.scrollHelper,this._sch_height)),e._timeline_smart_render._rendered_labels_cache=[],e._timeline_smart_render._rendered_events_cache=[];var f,b=!!g;f=this.scrollable?!1!==this.smart_rendering&&!!b:!!this.smart_rendering&&b;for(var x=[],k=0,w=0;w<this.y_unit.length;w++){e._timeline_calculate_event_positions.call(this,d[w]);var D=e._timeline_get_cur_row_stats(this,w);D=e._timeline_get_fit_events_stats(this,w,D),
x.push(D),k+=D.height}g&&k<g.scrollTop&&(g.scrollTop=Math.max(0,k-g.height));for(var w=0;w<this.y_unit.length;w++){var D=x[w],E=this.y_unit[w],S="<div class='dhx_timeline_label_row "+D.tr_className+"' style='top:"+m+"px;"+D.style_height+D.style_line_height+"'data-row-index='"+w+"' data-row-id='"+y(E.key)+"'><div class='"+D.td_className+"' style='"+D.style_width+" height:"+D.height+"px;' "+e._waiAria.label(D.td_content)+">"+D.td_content+"</div></div>";if(f&&this._label_rows.push({div:S,top:m,
section:E}),f&&(e._timeline_smart_render.isInYViewPort({top:m,bottom:m+D.height},g)||(v=!0)),m+=D.height,v)v=!1;else{r+=S,f&&e._timeline_smart_render._rendered_labels_cache.push(w);var M=e.templates[this.name+"_row_class"],N={view:this,section:E,template:M},A=0;if("cell"==this.render){o+=e._timeline_get_html_for_cell_data_row(w,D,m-D.height,E.key,N);for(var C=0;C<e._cols.length;C++)e._ignores[C]&&!f?o+=e._timeline_get_html_for_cell_ignores(D):f&&b?e._timeline_smart_render.isInXViewPort({left:A,
right:A+e._cols[C]},g)&&(o+=e._timeline_get_html_for_cell(C,w,this,d[w][C],D,A)):o+=e._timeline_get_html_for_cell(C,w,this,d[w][C],D,A),A+=e._cols[C];o+="</div>"}else{o+=e._timeline_get_html_for_bar_matrix_line(w,D,m-D.height,E.key);var O=d[w];f&&b&&(O=e._timeline_smart_render.getVisibleEventsForRow(this,g,d,w));o+=e._timeline_get_events_html.call(this,O),o+=e._timeline_get_html_for_bar_data_row(D,N)
;for(var C=0;C<e._cols.length;C++)e._ignores[C]?o+=e._timeline_get_html_for_bar_ignores():f&&b?e._timeline_smart_render.isInXViewPort({left:A,right:A+e._cols[C]},g)&&(o+=e._timeline_get_html_for_bar(C,w,this,d[w],A)):o+=e._timeline_get_html_for_bar(C,w,this,d[w],A),A+=e._cols[C];o+="</div></div>"}}D.sectionKey=E.key,p.push(D)}if(i+=r+"</div></div>",i+=o+"</div></div>",i+="</div>",this._matrix=d,t.innerHTML=i,f){e.$container.querySelector(".dhx_timeline_data_col").style.height=m+"px"}
e._populate_timeline_rendered(t),this._scales={};for(var _=0,T=p.length;_<T;_++){h.push(p[_].height);var L=p[_].sectionKey;e._timeline_finalize_section_add(this,L,t)}f&&e._timeline_smart_render&&(e._timeline_smart_render._rendered_events_cache=[]),(f||this.scrollable)&&c(t,this,h,p)},e._timeline_finalize_section_add=function(t,a,n){var i=t._scales[a]=n.querySelector(".dhx_timeline_data_col [data-section-id='"+b(a)+"']");i&&e.callEvent("onScaleAdd",[i,a])},
e.attachEvent("onBeforeViewChange",function(t,a,n,i){if(e.matrix[n]){var r=e.matrix[n];if(r.scrollable){if("tree"==r.render&&t===n&&a===i)return!0;r._x_scroll=r._y_scroll=0,e.$container.querySelector(".dhx_timeline_scrollable_data")&&e._timeline_set_scroll_pos(e._els.dhx_cal_data[0],r)}}return!0}),e._timeline_x_dates=function(t){var a=e._min_date,n=e._max_date;e._process_ignores(a,this.x_size,this.x_unit,this.x_step,t);for(var i=(this.x_size,t&&e._ignores_detected,
0),r=0;+a<+n;)if(this._trace_x[r]=new Date(a),"month"==this.x_unit&&e.date[this.x_unit+"_start"]&&(a=e.date[this.x_unit+"_start"](new Date(a))),a=e.date.add(a,this.x_step,this.x_unit),e.date[this.x_unit+"_start"]&&(a=e.date[this.x_unit+"_start"](a)),e._ignores[r]||i++,r++,t)if(i<this.x_size&&!(+a<+n))n=e.date["add_"+this.name+"_private"](n,(this.x_length||this.x_size)*this.x_step);else if(i>=this.x_size){e._max_date=a;break}return{total:r,displayed:i}},e._timeline_x_scale=function(t){
var a=e.xy.scale_height,n=this._header_resized||e.xy.scale_height;e._cols=[],e._colsS={height:0},this._trace_x=[];var i=e.config.preserve_scale_length,r=e._timeline_x_dates.call(this,i),o=e._x-this.dx-e.xy.scroll_width;if(this.scrollable&&this.column_width>0){var l=this.column_width*r.displayed;l>o&&(o=l,this._section_autowidth=!1)}var _=[this.dx];e._els.dhx_cal_header[0].style.width=_[0]+o+"px"
;for(var s=e._min_date_timeline=e._min_date,c=r.displayed,u=r.total,h=0;h<u;h++)e._ignores[h]?(e._cols[h]=0,c++):e._cols[h]=Math.floor(o/(c-h)),o-=e._cols[h],_[h+1]=_[h]+e._cols[h];if(t.innerHTML="<div></div>",this.second_scale){for(var p=this.second_scale.x_unit,v=[this._trace_x[0]],m=[],g=[this.dx,this.dx],f=0,y=0;y<this._trace_x.length;y++){var b=this._trace_x[y];e._timeline_is_new_interval(p,b,v[f])&&(++f,v[f]=b,g[f+1]=g[f]);var x=f+1;m[f]=e._cols[y]+(m[f]||0),g[x]+=e._cols[y]}
t.innerHTML="<div></div><div></div>";var k=t.firstChild;k.style.height=n+"px";var w=t.lastChild;w.style.position="relative",w.className="dhx_bottom_scale_container";for(var D=0;D<v.length;D++){var E=v[D],S=e.templates[this.name+"_second_scalex_class"](E),M=document.createElement("div");M.className="dhx_scale_bar dhx_second_scale_bar"+(S?" "+S:""),e.set_xy(M,m[D]-1,n-3,g[D],0),M.innerHTML=e.templates[this.name+"_second_scale_date"](E),k.appendChild(M)}}e.xy.scale_height=n,t=t.lastChild,
this._h_cols={};for(var N=0;N<this._trace_x.length;N++)if(!e._ignores[N]){s=this._trace_x[N],e._render_x_header(N,_[N],s,t);var A=e.templates[this.name+"_scalex_class"](s);A&&(t.lastChild.className+=" "+A),t.lastChild.setAttribute("data-col-id",N),t.lastChild.setAttribute("data-col-date",d(s));var C=t.lastChild.cloneNode(!0);this._h_cols[N]={div:C,left:_[N]}}e.xy.scale_height=a;var O=this._trace_x;t.onclick=function(t){var a=e._timeline_locate_hcell(t)
;a&&e.callEvent("onXScaleClick",[a.x,O[a.x],t||event])},t.ondblclick=function(t){var a=e._timeline_locate_hcell(t);a&&e.callEvent("onXScaleDblClick",[a.x,O[a.x],t||event])}},e._timeline_is_new_interval=function(t,a,n){switch(t){case"hour":return a.getHours()!=n.getHours()||e._timeline_is_new_interval("day",a,n);case"day":return!(a.getDate()==n.getDate()&&a.getMonth()==n.getMonth()&&a.getFullYear()==n.getFullYear());case"week":
return!(e.date.week_start(new Date(a)).valueOf()==e.date.week_start(new Date(n)).valueOf());case"month":return!(a.getMonth()==n.getMonth()&&a.getFullYear()==n.getFullYear());case"year":return!(a.getFullYear()==n.getFullYear());default:return!1}},e._timeline_reset_scale_height=function(t){if(this._header_resized&&(!t||!this.second_scale)){e.xy.scale_height/=2,this._header_resized=!1;var a=e._els.dhx_cal_header[0];a.className=a.className.replace(/ dhx_second_cal_header/gi,"")}},
e._timeline_set_full_view=function(t){if(e._timeline_reset_scale_height.call(this,t),t){this.second_scale&&!this._header_resized&&(this._header_resized=e.xy.scale_height,e.xy.scale_height*=2,e._els.dhx_cal_header[0].className+=" dhx_second_cal_header"),e.set_sizes(),e._init_matrix_tooltip();var a=e._min_date;if(e._timeline_x_scale.call(this,e._els.dhx_cal_header[0]),e.$container.querySelector(".dhx_timeline_scrollable_data")){
var n=e._timeline_smart_render.getViewPort(this.scrollHelper),i=e._timeline_smart_render.getVisibleHeader(this,n);i&&(this.second_scale?e._els.dhx_cal_header[0].children[1].innerHTML=i:e._els.dhx_cal_header[0].children[0].innerHTML=i)}e._timeline_y_scale.call(this,e._els.dhx_cal_data[0]),e._min_date=a;var r=e._getNavDateElement();r&&(r.innerHTML=e.templates[this.name+"_date"](e._min_date,e._max_date)),e._mark_now&&e._mark_now(),e._timeline_reset_scale_height.call(this,t)}
e._timeline_render_scale_header(this,t),e._timeline_hideToolTip()},e._timeline_hideToolTip=function(){e._tooltip&&(e._tooltip.style.display="none",e._tooltip.date="")},e._timeline_showToolTip=function(t,a,n){if("cell"==t.render){var i=a.x+"_"+a.y,r=t._matrix[a.y][a.x];if(!r)return e._timeline_hideToolTip();if(r.sort(function(e,t){return e.start_date>t.start_date?1:-1}),e._tooltip){if(e._tooltip.date==i)return;e._tooltip.innerHTML=""}else{var o=e._tooltip=document.createElement("div")
;o.className="dhx_year_tooltip",e.config.rtl&&(o.className+=" dhx_tooltip_rtl"),document.body.appendChild(o),o.onclick=e._click.dhx_cal_data}for(var d="",l=0;l<r.length;l++){var _=r[l].color?"background-color:"+r[l].color+";":"",s=r[l].textColor?"color:"+r[l].textColor+";":"";d+="<div class='dhx_tooltip_line' event_id='"+r[l].id+"' style='"+_+s+"'>",d+="<div class='dhx_tooltip_date'>"+(r[l]._timed?e.templates.event_date(r[l].start_date):"")+"</div>",
d+="<div class='dhx_event_icon icon_details'>&nbsp;</div>",d+=e.templates[t.name+"_tooltip"](r[l].start_date,r[l].end_date,r[l])+"</div>"}e._tooltip.style.display="",e._tooltip.style.top="0px",e.config.rtl&&n.left-e._tooltip.offsetWidth>=0||document.body.offsetWidth-a.src.offsetWidth-n.left-e._tooltip.offsetWidth<0?e._tooltip.style.left=n.left-e._tooltip.offsetWidth+"px":e._tooltip.style.left=n.left+a.src.offsetWidth+"px",e._tooltip.date=i,e._tooltip.innerHTML=d,
document.body.offsetHeight-n.top-e._tooltip.offsetHeight<0?e._tooltip.style.top=n.top-e._tooltip.offsetHeight+a.src.offsetHeight+"px":e._tooltip.style.top=n.top+"px"}},e._matrix_tooltip_handler=function(t){var a=e.matrix[e._mode];if(a&&"cell"==a.render){if(a){var n=e._locate_cell_timeline(t),t=t||event;t.target||t.srcElement;if(n)return e._timeline_showToolTip(a,n,e.$domHelpers.getOffset(n.src))}e._timeline_hideToolTip()}},e._init_matrix_tooltip=function(){
e._detachDomEvent(e._els.dhx_cal_data[0],"mouseover",e._matrix_tooltip_handler),e.event(e._els.dhx_cal_data[0],"mouseover",e._matrix_tooltip_handler)},e._set_timeline_dates=function(t){e._min_date=e.date[t.name+"_start"](new Date(e._date)),e._max_date=e.date["add_"+t.name+"_private"](e._min_date,t.x_size*t.x_step),e.date[t.x_unit+"_start"]&&(e._max_date=e.date[t.x_unit+"_start"](e._max_date)),e._table_view=!0},e._renderMatrix=function(t,a){a||(e._els.dhx_cal_data[0].scrollTop=0),
e._set_timeline_dates(this),e._timeline_set_full_view.call(this,t)},e._timeline_html_index=function(t){for(var a=t.parentNode.childNodes,n=-1,i=0;i<a.length;i++)if(a[i]==t){n=i;break}var r=n;if(e._ignores_detected)for(var o in e._ignores)e._ignores[o]&&1*o<=r&&r++;return r},e._timeline_locate_hcell=function(t){t=t||event;for(var a=t.target?t.target:t.srcElement;a&&"DIV"!=a.tagName;)a=a.parentNode;if(a&&"DIV"==a.tagName){if("dhx_scale_bar"==e._getClassName(a).split(" ")[0])return{
x:e._timeline_html_index(a),y:-1,src:a,scale:!0}}},e._locate_cell_timeline=function(t){t=t||event;for(var a=t.target?t.target:t.srcElement,n={},i=e.matrix[e._mode],r=e.getActionData(t),o=e._ignores,d=0,l=0;l<i._trace_x.length-1&&!(+r.date<i._trace_x[l+1]);l++)o[l]||d++;n.x=0===d?0:l,n.y=i.order[r.section];var _=(e._isRender("cell"),0);if(i.scrollable&&"cell"===i.render){if(!i._scales[r.section]||!i._scales[r.section].querySelector(".dhx_matrix_cell"))return
;var s=i._scales[r.section].querySelector(".dhx_matrix_cell");if(!s)return;var c=s.offsetLeft;if(c>0){for(var h=e._timeline_drag_date(i,c),p=0;p<i._trace_x.length-1&&!(+h<i._trace_x[p+1]);p++);_=p}}n.src=i._scales[r.section]?i._scales[r.section].querySelectorAll(".dhx_matrix_cell")[l-_]:null;var v=!1,m=u(a,".dhx_matrix_scell");return m&&(a=m,v=!0),v?(n.x=-1,n.src=a,n.scale=!0):n.x=l,n};var x=e._click.dhx_cal_data;e._click.dhx_marked_timespan=e._click.dhx_cal_data=function(t){
var a=x.apply(this,arguments),n=e.matrix[e._mode];if(n){var i=e._locate_cell_timeline(t);i&&(i.scale?e.callEvent("onYScaleClick",[i.y,n.y_unit[i.y],t||event]):(e.callEvent("onCellClick",[i.x,i.y,n._trace_x[i.x],(n._matrix[i.y]||{})[i.x]||[],t||event]),e._timeline_set_scroll_pos(e._els.dhx_cal_data[0],n)))}return a},e.dblclick_dhx_matrix_cell=function(t){var a=e.matrix[e._mode];if(a){var n=e._locate_cell_timeline(t)
;n&&(n.scale?e.callEvent("onYScaleDblClick",[n.y,a.y_unit[n.y],t||event]):e.callEvent("onCellDblClick",[n.x,n.y,a._trace_x[n.x],(a._matrix[n.y]||{})[n.x]||[],t||event]))}};var k=e.dblclick_dhx_marked_timespan||function(){};e.dblclick_dhx_marked_timespan=function(t){return e.matrix[e._mode]?e.dblclick_dhx_matrix_cell(t):k.apply(this,arguments)},e.dblclick_dhx_matrix_scell=function(t){return e.dblclick_dhx_matrix_cell(t)},e._isRender=function(t){
return e.matrix[e._mode]&&e.matrix[e._mode].render==t},e.attachEvent("onCellDblClick",function(t,a,n,i,r){if(!this.config.readonly&&("dblclick"!=r.type||this.config.dblclick_create)){var o=e.matrix[e._mode],d={};d.start_date=o._trace_x[t],d.end_date=o._trace_x[t+1]?o._trace_x[t+1]:e.date.add(o._trace_x[t],o.x_step,o.x_unit),o._start_correction&&(d.start_date=new Date(1*d.start_date+o._start_correction)),o._end_correction&&(d.end_date=new Date(d.end_date-o._end_correction)),
d[o.y_property]=o.y_unit[a].key,e.addEventNow(d,null,r)}}),e.attachEvent("onBeforeDrag",function(t,a,n){return!e._isRender("cell")}),e.attachEvent("onEventChanged",function(e,t){t._timed=this.isOneDayEvent(t)}),e.attachEvent("onBeforeEventChanged",function(e,t,a,n){return e&&(e._move_delta=void 0),n&&(n._move_delta=void 0),!0}),e._is_column_visible=function(t){var a=e.matrix[e._mode],n=e._get_date_index(a,t);return!e._ignores[n]};var w=e._render_marked_timespan
;e._render_marked_timespan=function(t,a,n,i,r){if(!e.config.display_marked_timespans)return[];if(e.matrix&&e.matrix[e._mode]){if(e._isRender("cell"))return;var o=e._lame_copy({},e.matrix[e._mode]);o.round_position=!1;var d=[],l=[],_=[],s=t.sections?t.sections.units||t.sections.timeline:null;if(n)_=[a],l=[n];else{var c=o.order;if(s)c.hasOwnProperty(s)&&(l.push(s),_.push(o._scales[s]));else if(o._scales)for(var u in c)c.hasOwnProperty(u)&&o._scales[u]&&(l.push(u),_.push(o._scales[u]))}
var i=i?new Date(i):e._min_date,r=r?new Date(r):e._max_date;if(i.valueOf()<e._min_date.valueOf()&&(i=new Date(e._min_date)),r.valueOf()>e._max_date.valueOf()&&(r=new Date(e._max_date)),!o._trace_x)return;for(var h=0;h<o._trace_x.length&&!e._is_column_visible(o._trace_x[h]);h++);if(h==o._trace_x.length)return;var p=[];if(t.days>6){var v=new Date(t.days);e.date.date_part(new Date(i))<=+v&&+r>=+v&&p.push(v)}else p.push.apply(p,e._get_dates_by_index(t.days))
;for(var m=t.zones,g=e._get_css_classes_by_config(t),f=0;f<l.length;f++){a=_[f],n=l[f];for(var h=0;h<p.length;h++)for(var y=p[h],b=0;b<m.length;b+=2){var x=m[b],k=m[b+1],D=new Date(+y+60*x*1e3),E=new Date(+y+60*k*1e3);if(D=new Date(D.valueOf()+1e3*(D.getTimezoneOffset()-y.getTimezoneOffset())*60),E=new Date(E.valueOf()+1e3*(E.getTimezoneOffset()-y.getTimezoneOffset())*60),i<E&&r>D){var S=e._get_block_by_config(t);S.className=g;var M=e._timeline_getX({start_date:D},!1,o)-1,N=e._timeline_getX({
start_date:E},!1,o)-1,A=Math.max(1,N-M-1),C=o._section_height[n]-1||o.dy-1;S.style.cssText="height: "+C+"px; "+(e.config.rtl?"right: ":"left: ")+M+"px; width: "+A+"px; top: 0;",a.insertBefore(S,a.firstChild),d.push(S)}}}return d}return w.apply(e,[t,a,n])};var D=e._append_mark_now;e._append_mark_now=function(t,a){if(e.matrix&&e.matrix[e._mode]){var n=e._currentDate(),i=e._get_zone_minutes(n),r={days:+e.date.date_part(n),zones:[i,i+1],css:"dhx_matrix_now_time",type:"dhx_now_time"}
;return e._render_marked_timespan(r)}return D.apply(e,[t,a])};var E=e._mark_timespans;e._mark_timespans=function(){if(e.matrix&&e.matrix[e.getState().mode]){for(var t=[],a=e.matrix[e.getState().mode],n=a.y_unit,i=0;i<n.length;i++){var r=n[i].key,o=a._scales[r],d=e._on_scale_add_marker(o,r);t.push.apply(t,d)}return t}return E.apply(this,arguments)};var S=e._on_scale_add_marker;e._on_scale_add_marker=function(t,a){if(e.matrix&&e.matrix[e._mode]){var n=[],i=e._marked_timespans
;if(i&&e.matrix&&e.matrix[e._mode])for(var r=e._mode,o=e._min_date,d=e._max_date,l=i.global,_=e.date.date_part(new Date(o));_<d;_=e.date.add(_,1,"day")){var s=+_,c=_.getDay(),u=[],h=l[s]||l[c];if(u.push.apply(u,e._get_configs_to_render(h)),i[r]&&i[r][a]){var p=[],v=e._get_types_to_render(i[r][a][c],i[r][a][s]);p.push.apply(p,e._get_configs_to_render(v)),p.length&&(u=p)}for(var m=0;m<u.length;m++){var g=u[m],f=g.days;f<7?(f=s,
n.push.apply(n,e._render_marked_timespan(g,t,a,_,e.date.add(_,1,"day"))),f=c):n.push.apply(n,e._render_marked_timespan(g,t,a,_,e.date.add(_,1,"day")))}}return n}return S.apply(this,arguments)},e._resolve_timeline_section=function(e,t){var a=0,n=0;for(a;a<this._colsS.heights.length&&!((n+=this._colsS.heights[a])>t.y);a++);e.y_unit[a]||(a=e.y_unit.length-1),this._drag_event&&!this._drag_event._orig_section&&(this._drag_event._orig_section=e.y_unit[a].key),t.fields={},
a>=0&&e.y_unit[a]&&(t.section=t.fields[e.y_property]=e.y_unit[a].key)},e._update_timeline_section=function(e){var t=e.view,a=e.event,n=e.pos;if(a){if(a[t.y_property]!=n.section){var i=this._get_timeline_event_height(a,t);a._sorder=this._get_dnd_order(a._sorder,i,t._section_height[n.section])}a[t.y_property]=n.section}},e._get_date_index=function(e,t){for(var a=e._trace_x,n=0,i=a.length-1,r=t.valueOf();i-n>3;){var o=n+Math.floor((i-n)/2);a[o].valueOf()>r?i=o:n=o}for(var d=n;d<=i&&+t>=+a[d+1];)d++
;return d},e._timeline_drag_date=function(t,a){var n=t,i={x:a};if(!n._trace_x.length)return new Date(e.getState().date);var r,o,d=0,l=0;for(l;l<=this._cols.length-1;l++)if(o=this._cols[l],(d+=o)>i.x){r=(i.x-(d-o))/o,r=r<0?0:r;break}if(n.round_position){var _=1,s=e.getState().drag_mode;s&&"move"!=s&&"create"!=s&&(_=.5),r>=_&&l++,r=0}if(0===l&&this._ignores[0])for(l=1,r=0;this._ignores[l];)l++;else if(l==this._cols.length&&this._ignores[l-1]){for(l=this._cols.length-1,r=0;this._ignores[l];)l--;l++
}var c;if(l>=n._trace_x.length)c=e.date.add(n._trace_x[n._trace_x.length-1],n.x_step,n.x_unit),n._end_correction&&(c=new Date(c-n._end_correction));else{var u=r*o*n._step+n._start_correction;c=new Date(+n._trace_x[l]+u)}return c},e.attachEvent("onBeforeTodayDisplayed",function(){for(var t in e.matrix){var a=e.matrix[t];a.x_start=a._original_x_start}return!0}),e.attachEvent("onOptionsLoad",function(){for(var t in e.matrix){var a=e.matrix[t];a.order={},e.callEvent("onOptionsLoadStart",[])
;for(var t=0;t<a.y_unit.length;t++)a.order[a.y_unit[t].key]=t;e.callEvent("onOptionsLoadFinal",[]),e._date&&a.name==e._mode&&(a._options_changed=!0,e.setCurrentView(e._date,e._mode),setTimeout(function(){a._options_changed=!1}))}}),e.attachEvent("onEventIdChange",function(){var t=e.getView();t&&e.matrix[t.name]&&e._timeline_smart_render&&(e._timeline_smart_render.clearPreparedEventsCache(),e._timeline_smart_render.getPreparedEvents(t))}),e.attachEvent("onBeforeDrag",function(t,a,n){
if("resize"==a){var i=n.target||n.srcElement;e._getClassName(i).indexOf("dhx_event_resize_end")<0?e._drag_from_start=!0:e._drag_from_start=!1}return!0});var M=10,N=null,A=null,C=e.attachEvent("onSchedulerReady",function(){e.matrix&&(e.event(document.body,"mousemove",p),e.detachEvent(C))});e._timeline_smart_render={_prepared_events_cache:null,_rendered_events_cache:[],_rendered_header_cache:[],_rendered_labels_cache:[],_rows_to_delete:[],_rows_to_add:[],_cols_to_delete:[],_cols_to_add:[],
getViewPort:function(t,a,n,i){var r=e.$container.querySelector(".dhx_cal_data"),o=r.getBoundingClientRect(),d=e.$container.querySelector(".dhx_timeline_scrollable_data");d&&void 0===n&&(n=t.getScrollValue(d)),void 0===i&&(i=d?d.scrollTop:r.scrollTop);var l={};for(var _ in o)l[_]=o[_];return l.scrollLeft=n||0,l.scrollTop=i||0,a&&(o.height=a),l},isInXViewPort:function(e,t){var a=t.scrollLeft,n=t.width+t.scrollLeft;return e.left<n+100&&e.right>a-100},isInYViewPort:function(e,t){
var a=t.scrollTop,n=t.height+t.scrollTop;return e.top<n+100&&e.bottom>a-100},getVisibleHeader:function(t,a){var n="";this._rendered_header_cache=[];for(var i in t._h_cols){var r=t._h_cols[i];if(this.isInXViewPort({left:r.left,right:r.left+e._cols[i]},a)){n+=r.div.outerHTML,this._rendered_header_cache.push(r.div.getAttribute("data-col-id"))}}return n},updateHeader:function(t,a,n){this._cols_to_delete=[],this._cols_to_add=[]
;for(var i=e.$container.querySelectorAll(".dhx_cal_header > div"),r=i[i.length-1].querySelectorAll(".dhx_scale_bar"),o=[],d=0;d<r.length;d++)o.push(r[d].getAttribute("data-col-id"));if(this.getVisibleHeader(t,a)){for(var l=this._rendered_header_cache.slice(),_=[],d=0,s=o.length;d<s;d++){var c=l.indexOf(o[d]);c>-1?l.splice(c,1):_.push(o[d])}_.length&&(this._cols_to_delete=_.slice(),this._deleteHeaderCells(_,t,n)),l.length&&(this._cols_to_add=l.slice(),this._addHeaderCells(l,t,n))}},
_deleteHeaderCells:function(e,t,a){for(var n=0;n<e.length;n++){var i=a.querySelector('[data-col-id="'+e[n]+'"]');i&&a.removeChild(i)}},_addHeaderCells:function(e,t,a){for(var n="",i=0;i<e.length;i++)n+=t._h_cols[e[i]].div.outerHTML;a.insertAdjacentHTML("beforeEnd",n)},getVisibleLabels:function(e,t){if(e._label_rows.length){var a="";this._rendered_labels_cache=[];for(var n=0;n<e._label_rows.length;n++)if(this.isInYViewPort({top:e._label_rows[n].top,
bottom:e._label_rows[n].top+e._section_height[e.y_unit[n].key]},t)){var i=e._label_rows[n].div;a+=i,this._rendered_labels_cache.push(n)}return a}},updateLabels:function(e,t,a){this._rows_to_delete=[],this._rows_to_add=[];var n=this._rendered_labels_cache.slice();if(n.length||(this.getVisibleLabels(e,t),n=this._rendered_labels_cache.slice()),this.getVisibleLabels(e,t)){for(var i=this._rendered_labels_cache.slice(),r=[],o=0,d=n.length;o<d;o++){var l=i.indexOf(n[o]);l>-1?i.splice(l,1):r.push(n[o])}
r.length&&(this._rows_to_delete=r.slice(),this._deleteLabelCells(r,e,a)),i.length&&(this._rows_to_add=i.slice(),this._addLabelCells(i,e,a))}},_deleteLabelCells:function(e,t,a){for(var n=0;n<e.length;n++){var i=a.querySelector('[data-row-index="'+e[n]+'"]');i&&a.removeChild(i)}},_addLabelCells:function(e,t,a){for(var n="",i=0;i<e.length;i++)n+=t._label_rows[e[i]].div;a.insertAdjacentHTML("beforeEnd",n)},clearPreparedEventsCache:function(){this.cachePreparedEvents(null)},
cachePreparedEvents:function(e){this._prepared_events_cache=e,this._prepared_events_coordinate_cache=e},getPreparedEvents:function(t){var a;return this._prepared_events_cache?a=this._prepared_events_cache:(a=e._prepare_timeline_events(t),a.$coordinates={},this.cachePreparedEvents(a)),a},updateEvents:function(t,a){var n=this.getPreparedEvents(t),i=this._rendered_events_cache.slice();this._rendered_events_cache=[];var r=e.$container.querySelector(".dhx_cal_data .dhx_timeline_data_col");if(r){
for(var o=0;o<this._rendered_labels_cache.length;o++){var d=this._rendered_labels_cache[o],l=[],_=i[d]?i[d].slice():[];e._timeline_calculate_event_positions.call(t,n[d]);for(var s=e._timeline_smart_render.getVisibleEventsForRow(t,a,n,d),c=0,u=s.length;c<u;c++){var h=_.indexOf(s[c].id);h>-1?_.splice(h,1):l.push(s[c])}var p=r.querySelector('[data-section-index="'+d+'"]');_.length&&this._deleteEvents(_,t,p),l.length&&this._addEvents(l,t,p,d)}e._populate_timeline_rendered(e.$container),t._matrix=n}
},_deleteEvents:function(e,t,a){for(var n=0;n<e.length;n++){var i=a.querySelector('[event_id="'+e[n]+'"]');i&&(i.classList.contains("dhx_in_move")||a.removeChild(i))}},_addEvents:function(t,a,n,i){var r=e._timeline_update_events_html.call(a,t);n.insertAdjacentHTML("beforeEnd",r)},getVisibleEventsForRow:function(t,a,n,i){var r=[];if("cell"==t.render)r=n;else{var o=n[i];if(o)for(var d=0,l=o.length;d<l;d++){var _,s,c=o[d],u=i+"_"+c.id;n.$coordinates&&n.$coordinates[u]?(_=n.$coordinates[u].xStart,
s=n.$coordinates[u].xEnd):(_=e._timeline_getX(c,!1,t),s=e._timeline_getX(c,!0,t),n.$coordinates&&(n.$coordinates[u]={xStart:_,xEnd:s})),e._timeline_smart_render.isInXViewPort({left:_,right:s},a)&&(r.push(c),this._rendered_events_cache[i]||(this._rendered_events_cache[i]=[]),this._rendered_events_cache[i].push(c.id))}}return r},getVisibleRowCellsHTML:function(t,a,n,i,r){for(var o,d="",l=this._rendered_header_cache,_=0;_<l.length;_++){var s=l[_];o=t._h_cols[s].left-t.dx,
e._ignores[s]?"cell"==t.render?d+=e._timeline_get_html_for_cell_ignores(n):d+=e._timeline_get_html_for_bar_ignores():"cell"==t.render?d+=e._timeline_get_html_for_cell(s,r,t,i[r][s],n,o):d+=e._timeline_get_html_for_bar(s,r,t,i[r],o)}return d},getVisibleTimelineRowsHTML:function(t,a,n,i){var r="",o=e._timeline_get_cur_row_stats(t,i);o=e._timeline_get_fit_events_stats(t,i,o);var d=t._label_rows[i],l=e.templates[t.name+"_row_class"],_={view:t,section:d.section,template:l}
;return"cell"==t.render?(r+=e._timeline_get_html_for_cell_data_row(i,o,d.top,d.section.key,_),r+=this.getVisibleRowCellsHTML(t,a,o,n,i),r+="</div>"):(r+=e._timeline_get_html_for_bar_matrix_line(i,o,d.top,d.section.key,_),r+=e._timeline_get_html_for_bar_data_row(o,_),r+=this.getVisibleRowCellsHTML(t,a,o,n,i),r+="</div></div>"),r},updateGridRows:function(e,t){this._rows_to_delete.length&&this._deleteGridRows(this._rows_to_delete),this._rows_to_add.length&&this._addGridRows(this._rows_to_add,e,t)},
_deleteGridRows:function(t){var a=e.$container.querySelector(".dhx_cal_data .dhx_timeline_data_col");if(a){for(var n=0;n<t.length;n++){var i=a.querySelector('[data-section-index="'+t[n]+'"]');a.removeChild(i)}this._rows_to_delete=[]}},_addGridRows:function(t,a,n){var i=e.$container.querySelector(".dhx_cal_data .dhx_timeline_data_col");if(i){for(var r=this.getPreparedEvents(a),o="",d=0;d<t.length;d++)o+=this.getVisibleTimelineRowsHTML(a,n,r,t[d]);i.insertAdjacentHTML("beforeEnd",o)
;for(var d=0;d<t.length;d++)e._timeline_finalize_section_add(a,a.y_unit[t[d]].key,i);e._mark_now&&e._mark_now(),this._rows_to_add=[]}},updateGridCols:function(t,a){for(var n=this._rendered_header_cache,i={},r={},o=0;o<n.length;o++)r[n[o]]=!0;var d=e.$container.querySelector(".dhx_timeline_data_row");if(d)for(var l=d.querySelectorAll("[data-col-id]"),o=0;o<l.length;o++)i[l[o].getAttribute("data-col-id")]=!0;var _=[],s=[];for(var o in i)r[o]||_.push(o);for(var o in r)i[o]||s.push(o)
;_.length&&this._deleteGridCols(_,t),s.length&&this._addGridCols(s,t,a)},_deleteGridCols:function(t,a){var n=e.$container.querySelector(".dhx_cal_data .dhx_timeline_data_col");if(n){for(var i=0;i<this._rendered_labels_cache.length;i++){var r;if(r="cell"==a.render?n.querySelector('[data-section-index="'+this._rendered_labels_cache[i]+'"]'):n.querySelector('[data-section-index="'+this._rendered_labels_cache[i]+'"] .dhx_timeline_data_row '))for(var o=0;o<t.length;o++){
var d=r.querySelector('[data-col-id="'+t[o]+'"]');d&&r.removeChild(d)}}this._cols_to_delete=[]}},_addGridCols:function(t,a,n){var i=e.$container.querySelector(".dhx_cal_data .dhx_timeline_data_col");if(i){for(var r=this.getPreparedEvents(a),o=0;o<this._rendered_labels_cache.length;o++){var d=this._rendered_labels_cache[o],l="",_=e._timeline_get_cur_row_stats(a,d);_=e._timeline_get_fit_events_stats(a,d,_);var s
;if(s="cell"==a.render?i.querySelector('[data-section-index="'+d+'"]'):i.querySelector('[data-section-index="'+d+'"] .dhx_timeline_data_row')){for(var c=0;c<t.length;c++){if(!s.querySelector('[data-col-id="'+t[c]+'"]')){var u=this.getVisibleGridCell(a,n,_,r,d,t[c]);u&&(l+=u)}}s.insertAdjacentHTML("beforeEnd",l)}}this._cols_to_add=[]}},getVisibleGridCell:function(t,a,n,i,r,o){if(t._h_cols[o]){var d="",l=t._h_cols[o].left-t.dx
;return"cell"==t.render?e._ignores[o]||(d+=e._timeline_get_html_for_cell(o,r,t,i[r][o],n,l)):e._ignores[o]||(d+=e._timeline_get_html_for_bar(o,r,t,i[r],l)),d}}}},e._temp_matrix_scope()});