Date.createUTC=function(e){let t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds())},Date.prototype.isLeapYear=function(){let e=this.getFullYear();return(3&e)==0&&(e%100!=0||e%400==0)},Date.prototype.getDayOfTheYear=function(){let e=[0,31,59,90,120,151,181,212,243,273,304,334],t=this.getMonth(),a=this.getDate();return t>1&&this.isLeapYear()?e[t]+a+1:e[t]+a},Date.prototype.getWeekOfTheYear=function(){let e=this.getDayOfTheYear(),t=Math.floor((e-1)/7)+1;return t>52?52:t},Highcharts.dateFormats.W=function(e){let t=new Date.createUTC(e);return t.getWeekOfTheYear()},Highcharts.dateFormats.Q=function(e){let t=new Date.createUTC(e),a=t.getMonth()+1;return Math.ceil(a/3)},Highcharts.SVGRenderer.prototype.symbols.play=function(e,t,a,i){return["M",e,t,"L",e,t+i,e+a,t+i/2,"Z"]};let language;try{language=PsrCore.Globalization.getLanguage()}catch(e){language=document.documentElement.lang}function random_string(e=6){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a="";for(let i=0;i'+Highcharts.numberFormat(this.x,4,".")+" — "+Highcharts.numberFormat(this.x2,4,".")+'
? '+this.series.name+": "+Highcharts.numberFormat(this.y/this.series.userOptions.size*100,2,".")+"%
"}}},heatmap:{marker:{enabled:!0},turboThreshold:Number.MAX_VALUE},line:{lineWidth:2},pie:{dataLabels:{enabled:!0,format:"{point.name}: {point.percentage:.1f} %"},tooltip:{headerFormat:"",pointFormat:"{point.name}: {point.y}"}},scatter:{marker:{enabled:!0,radius:5,states:{hover:{enabled:!0,lineColor:"rgb(100,100,100)"}}},states:{hover:{marker:{enabled:!1}}}},spline:{lineWidth:2}},responsive:{rules:[{chartOptions:{legend:{enabled:!1}},condition:{maxWidth:720}}]},exporting:{sourceWidth:1024,csv:{dateFormat:"%b %d, %Y %I:%M%p"},buttons:{play:{enabled:!1,symbol:"play",onclick:function(){let e=this;void 0===e.sequenceTimer?e.sequenceTimer=setInterval(function(){i.current_series+=1,i.current_series>=i.series.length&&(i.current_series=0),i.redraw()},1e3):(clearTimeout(e.sequenceTimer),e.sequenceTimer=void 0)}},pause:{enabled:!1,symbol:"square",onclick:function(){clearTimeout(this.sequenceTimer),this.sequenceTimer=void 0,i.current_series=0,i.redraw()}},contextButton:{symbol:"menuball",symbolStrokeWidth:1,menuItems:[{text:Highcharts.getOptions().lang.showSeries,onclick:function(){let e=this.series;this.showHideSeries?e.forEach(e=>{e.setVisible(!1,!1)}):e.forEach(e=>{e.setVisible(!0,!1)}),this.showHideSeries=!this.showHideSeries,this.redraw()}},{text:Highcharts.getOptions().lang.showLegend,onclick:function(){this.update({legend:{enabled:!this.legend.options.enabled}})}},{text:Highcharts.getOptions().lang.showDataTable,onclick:function(){this.toggleDataTable()}},{text:Highcharts.getOptions().lang.enableVerticalZoom,onclick:function(){this.enableVerticalZoom=!this.enableVerticalZoom,this.update({chart:{zoomType:this.enableVerticalZoom?"xy":"x"}})}},"viewFullscreen","downloadPNG","downloadSVG",{text:Highcharts.getOptions().lang.downloadCSV||"Download CSV",onclick:function(){let e="dados-do-grafico",t=this.title.textStr;if(t&&t.trim().length>0){let a=t.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9_-]/g,"");a&&(e=a)}let i="\uFEFFsep=,\n"+this.getCSV(),s=new Blob([i],{type:"text/csv;charset=utf-8;"}),r=document.createElement("a"),n=URL.createObjectURL(s);r.setAttribute("href",n),r.setAttribute("download",e+".csv"),r.style.visibility="hidden",document.body.appendChild(r),r.click(),document.body.removeChild(r)}},"downloadXLS","printChart",]}}},xAxis:[],yAxis:[],colorAxis:[]})}tooltip_chart(e){let t=300,a=300;void 0!==e[0][0][0].data&&(e[0][0][0].width&&(t=e[0][0][0].width),e[0][0][0].height&&(a=e[0][0][0].height));let i="width: "+t+"px;";i+=" height: "+a+"px;";let s="tooltip-"+this.id;this.highcharts.update({tooltip:{useHTML:!0,headerFormat:"",pointFormat:'
'}}),Highcharts.addEvent(Highcharts.Tooltip,"refresh",function(){let t=this.chart.hoverPoint.index,a=this.chart.hoverPoint.series.index,i=e[t]&&void 0!==e[t][a]?e[t][a]:null;this.chart.hoverPoint&&render_chart(i,s,this.chart.hoverPoint.y)})}enable_controls(){this.highcharts.update({exporting:{buttons:{play:{enabled:!0},pause:{enabled:!0}}}})}invert_axes(){this.highcharts.update({chart:{inverted:!this.inverted}}),this.highcharts.update({yAxis:{reversed:!1,crosshair:!this.inverted}}),this.highcharts.update({xAxis:{crosshair:this.inverted}})}horizontal_legend(){this.highcharts.update({legend:{enabled:!0,layout:"horizontal",align:"center",verticalAlign:"bottom"}})}hide_series(){let e=Highcharts.charts.filter(e=>e).find(e=>e.renderTo.id===this.id);e.update({plotOptions:{series:{states:{hover:{lineWidthPlus:0,lineWidth:0}}}}})}xlabel_date_format(e="%b %Y "){this.highcharts.update({xAxis:{labels:{format:"{value:"+e+"}"}}})}set_yaxis_categories(e){this.highcharts.update({yAxis:{categories:e}})}enable_vertical_zoom(){this.highcharts.update({chart:{zoomType:"xy"}})}add_xAxis_line(e,t={}){let a={color:"rgb(0, 0, 0)",width:2,value:e,...t};this.highcharts.update({xAxis:{plotLines:[a]}})}add_xAxis_range(e,t,a={}){let i={color:"rgba(255, 0, 0, 0.1)",width:2,from:e,to:t,...a};this.highcharts.update({xAxis:{plotBands:[i]}})}add_yAxis_line(e,t={}){let a={color:"rgb(0, 0, 0)",width:2,value:e,...t};this.highcharts.update({yAxis:{plotLines:[a]}})}add_yAxis_range(e,t,a={}){let i={color:"rgba(255, 0, 0, 0.1)",width:2,from:e,to:t,...a};this.highcharts.update({yAxis:{plotBands:[i]}})}disable_context_button(){this.highcharts.update({exporting:{buttons:{contextButton:{enabled:!1}}}})}tooltip_header_format(e){let t=e.length;if(t>1)for(let a=0;a"+e[a]+"
"}})}else this.highcharts.update({tooltip:{headerFormat:""+e[0]+"
"}})}tooltip_point_format(e){let t=e.length;if(t>1)for(let a=0;a"+e[a]+"
"}})}else this.highcharts.update({tooltip:{pointFormat:""+e[0]+"
"}})}tooltip_shared(){this.highcharts.update({tooltip:{crosshairs:!0,shared:!0}})}processing(){Highcharts.setOptions({lang:{noData:Highcharts.getOptions().lang.processing}}),this.clear(),Highcharts.setOptions({lang:{noData:Highcharts.getOptions().lang.noDataDefault}})}update_play(e){clearInterval(this.sequenceTimer),this.current_series=parseInt(this.rangeInput.value),this.rangeInput.value=this.current_series,this.titleElement.textContent=this.series[this.current_series][0].sequence_label,this.redraw()}play(){let e=this;e.sequenceTimer=setInterval(function(){e.current_series+=1,e.current_series>=e.series.length&&(e.current_series=0),e.titleElement.textContent=e.series[e.current_series][0].sequence_label,e.rangeInput.value=e.current_series,e.redraw()},800)}pause(){clearInterval(this.sequenceTimer)}push_series(e,t){if(this.series.length<=e)for(let a=this.series.length;a<=e;++a)this.series.push([]);this.series[e].push(t),0==e&&this.highcharts.addSeries(t,!1,!1)}push_layer(e,t=0){if(null===e)return this;let a=0;null!==e.data&&(a=e.data.length);let i=e.type,s=e.hasOwnProperty("sequence")?Math.trunc(e.sequence)-1:0,r="",n="",o=0;switch(e.domain){case"linear":r="linear";break;case"category":r="category";break;case"errorbar":r="errorbar";break;case"1min":r="datetime",o=6e4,n="%b %d, %Y %I:%M%p",e.pointInterval=o;break;case"5min":r="datetime",o=3e5,n="%b %d, %Y %I:%M%p",e.pointInterval=o;break;case"10min":r="datetime",o=6e5,n="%b %d, %Y %I:%M%p",e.pointInterval=o;break;case"15min":r="datetime",o=9e5,n="%b %d, %Y %I:%M%p",e.pointInterval=o;break;case"20min":r="datetime",o=12e5,n="%b %d, %Y %I:%M%p",e.pointInterval=o;break;case"30min":r="datetime",o=18e5,n="%b %d, %Y %I:%M%p",e.pointInterval=o;break;case"hour":r="datetime",o=36e5,n="%b %d, %Y %I:%M%p",e.pointInterval=o;break;case"day":r="datetime",o=864e5,n="%b %d, %Y",e.pointInterval=1,e.pointIntervalUnit="day";break;case"week":r="datetime",o=6048e5,n="%b %d, %Y - %W week",e.pointInterval=7,e.pointIntervalUnit="day";break;case"month":r="datetime",o=26784e5,n="%B %Y",e.pointInterval=1,e.pointIntervalUnit="month";break;case"3months":r="datetime",o=78624e5,n="%B %Y (Q%Q)",e.pointInterval=3,e.pointIntervalUnit="month";break;case"year":r="datetime",o=31536e6,n="%Y",e.pointInterval=1,e.pointIntervalUnit="year";break;case"decade":r="datetime",o=31536e7,n="%Y",e.pointInterval=10,e.pointIntervalUnit="year";break;default:return console.error("domain not found "+e.domain),this}let l=e.yUnit,h=e.xUnit;switch(e.date_format&&(n=e.date_format),e.tooltip={xDateFormat:n,valueSuffix:" "+e.yUnit},i){case"line":e.type="line";break;case"line_stacking":e.type="line",e.stacking="normal";break;case"line_percent":l="%",e.type="line",e.stacking="percent";break;case"spline":e.type="spline";break;case"column":e.type="column";break;case"column_stacking":e.type="column",e.stacking="normal";break;case"column_percent":l="%",e.type="column",e.stacking="percent";break;case"column_range":e.type="columnrange";break;case"area":e.type="area";break;case"area_stacking":e.type="area",e.stacking="normal";break;case"area_percent":l="%",e.type="area",e.stacking="percent";break;case"area_range":e.type="arearange";break;case"area_spline":e.type="areaspline";break;case"area_spline_stacking":e.type="areaspline",e.stacking="normal";break;case"area_spline_percent":l="%",e.type="areaspline",e.stacking="percent";break;case"area_spline_range":e.type="areasplinerange";break;case"error_bar":case"errorbar":e.type="errorbar";break;case"stream":e.type="streamgraph";break;case"pie":e.type="pie";break;case"scatter":e.type="scatter";break;case"box_plot":e.type="boxplot";break;case"waterfall":e.type="waterfall";break;case"histogram":e.type="histogram",e.domain="linear",h=e.yUnit,e.yUnit="%",l="%";break;case"heatmap":switch(e.domain){case"hour":e.type="heatmap",l="hour",o=864e5,e.colsize=o,e.tooltip={xDateFormat:n,valueSuffix:" "+e.yUnit,pointFormat:"{point.x:%b %d, %Y}, {point.y:,.0f}:00: {point.value}
"};break;case"day":e.type="heatmap",l="day",o=26784e5,e.colsize=o,e.tooltip={xDateFormat:n,valueSuffix:" "+e.yUnit,pointFormat:"{point.x:%b, %Y}, {point.y:,.0f}: {point.value}
"};break;default:e.type="heatmap",e.colsize=o,e.tooltip={xDateFormat:n,valueSuffix:" "+e.yUnit,pointFormat:"{point.x:"+n+"}, {point.y:,.0f}: {point.value}
"}}case"heatmap_series":case"heatmap_agents":e.type="heatmap",e.colsize=o,e.tooltip={xDateFormat:n,valueSuffix:" "+e.yUnit,pointFormat:"{point.x:"+n+"}: {point.value}
"};break;default:return console.error("plot type not found"),this}if(e.pointRange=o,e.hasOwnProperty("colors")&&Array.isArray(e.colors)?e.color=e.colors[t%e.colors.length]:e.hasOwnProperty("color")&&Array.isArray(e.color)&&(e.color=e.color[t%e.color.length]),e.xAxis=r,this.domains.has(r)){if(e.categories){e.categories.forEach(e=>{this.unique_categories.includes(e)||this.unique_categories.push(e)}),this.highcharts.xAxis[0].setCategories(this.unique_categories,!1),this.highcharts.series.forEach(e=>{let t=new Map;e.options.data.forEach((a,i)=>t.set(e.xAxis.categories[i],a));let a=this.unique_categories.map(e=>t.get(e)??0);e.setData(a,!1)});let d=new Map(e.categories.map((t,a)=>[t,e.data[a]]));e.data=this.unique_categories.map(e=>d.get(e)??0)}let c=this.highcharts.get(r);c.options.minTickInterval=Math.min(c.options.minTickInterval,o)}else{this.unique_categories=e.categories,this.domains.add(r);let p={id:r,type:r,minTickInterval:o,crosshair:!0};e.hasOwnProperty("xLabel")?p.title={text:e.xLabel}:p.title={text:h},"hour"===e.domain&&24===a&&(p.dateTimeLabelFormats={hour:"%H:%M",day:"%H:%M"}),e.hasOwnProperty("xLabelsEnabled")&&(p.hasOwnProperty("labels")?p.labels.enabled=e.xLabelsEnabled:p.labels={enabled:e.xLabelsEnabled}),e.hasOwnProperty("xMin")&&(p.min=Number(e.xMin)),e.hasOwnProperty("xMax")&&(p.max=Number(e.xMax)),e.hasOwnProperty("categories")&&(p.categories=e.categories),e.hasOwnProperty("xLine")&&(p.plotLines=[{value:Number(e.xLine),width:2,zIndex:9999}]),e.hasOwnProperty("xGridLineWidth")&&(p.gridLineWidth=Number(e.xGridLineWidth)),e.hasOwnProperty("xAllowDecimals")&&(p.allowDecimals=e.xAllowDecimals),e.hasOwnProperty("xTickPixelInterval")&&(p.tickPixelInterval=e.xTickPixelInterval),this.highcharts.addAxis(p,!0,!1,!1)}if(e.yAxis=l,!this.units.has(l)){this.units.add(l);let u={id:l,type:"linear",opposite:this.units.size%2==0};if(e.hasOwnProperty("yLabel")?u.title={text:e.yLabel}:u.title={text:l},"histogram"===i)e.size=a,u.labels={formatter:function(){return Highcharts.numberFormat(this.value/a*100,2,".")+"%"}},e.hasOwnProperty("xtickPositions")&&(u.tickPositioner=function(t,i){return this.chart.resetZoomButton?null:e.xtickPositions.map(e=>e*a/100)});else if("heatmap"===i){switch(e.domain){case"hour":u.min=0,u.max=23;break;case"day":u.min=1,u.max=31}u.minPadding=0,u.maxPadding=0,u.startOnTick=!1,u.endOnTick=!1,u.reversed=!0}else"heatmap_series"===i&&(u.minPadding=0,u.maxPadding=0,u.startOnTick=!1,u.endOnTick=!1,u.reversed=!0);e.hasOwnProperty("yLabelsEnabled")&&(u.hasOwnProperty("labels")?u.labels.enabled=e.yLabelsEnabled:u.labels={enabled:e.yLabelsEnabled}),e.hasOwnProperty("yMin")&&(u.min=Number(e.yMin)),e.hasOwnProperty("yMax")&&(u.max=Number(e.yMax)),e.hasOwnProperty("yLine")&&(u.plotLines=[{value:Number(e.yLine),width:2,zIndex:9999}]),e.hasOwnProperty("yAllowDecimals")&&(u.allowDecimals=e.yAllowDecimals),e.hasOwnProperty("yTickPixelInterval")&&(u.tickPixelInterval=e.yTickPixelInterval),this.highcharts.addAxis(u,!1,!1,!1)}if("pie"===i){let b={},m=[];0==s&&this.actual_sequence!==s&&this.highcharts.addSeries({type:"pie",tooltip:e.tooltip,data:b},!1,!1);for(let g=0;g1&&this.set_yaxis_categories(this.agent_list),this}redraw(){let e=document.querySelector("#"+this.id);new IntersectionObserver((e,t)=>{e.forEach(e=>{if(e.intersectionRatio>0&&this.series.length>0){let a=JSON.parse(JSON.stringify(this.series[this.current_series]));this.highcharts.update({series:a}),this.highcharts.redraw(),t.disconnect()}})}).observe(e)}}class PSRSpreadsheet{constructor(e,t=[]){let a=[{title:"Agent",width:"35%"},{title:"Date",width:"10%"}],i=t.map(e=>({title:e,width:`${55/t.length}%`})),s=a.concat(i);this.tableId=e,this.activeFilters={values:{}},this.savedStates={},this.dataSet=[],this.criteriaColumnIndexs=[],this.criteria=[],this.criteriaColors=[],this.table=$("#"+e).DataTable({columns:s,responsive:!0,autoWidth:!0,scrollCollapse:!0,columnDefs:[{className:"dt-center",targets:"_all"},{targets:"_all",render:function(e,t,a){return''+e+""}}],dom:'<"top"lf>rt<"bottom"ipB><"clear">',scrollY:"400px",fixedHeader:!0}),this.table.on("draw",()=>this.highlight_cells_by_criteria())}addNewRow(e){this.dataSet.push(e)}push_table_line(e){return null===e||(Array.isArray(e[0])?e.forEach(e=>{this.addNewRow(e)}):this.addNewRow(e)),this}save_input_states=()=>{let e=document.querySelectorAll(`#${this.tableId} thead .filter-row input`),t={},a=null;return e.forEach((e,i)=>{let s=e.dataset.columnIndex;t[s]=e.value,document.activeElement===e&&(a=i)}),{values:t,activeElementIndex:a}};restore_input_states=e=>{let t=document.querySelectorAll(`#${this.tableId} thead .filter-row input`);t.forEach((t,a)=>{let i=t.dataset.columnIndex;if(void 0!==e.values[i]&&(t.value=e.values[i]),e.activeElementIndex===a){t.focus();let s=t.value;t.value="",t.value=s}})};redraw(){this.savedStates&&0===Object.keys(this.savedStates).length&&(this.savedStates=this.save_input_states()),this.table.rows.add(this.dataSet).draw();let e=e=>{this.table.columns.adjust().draw(!1),e&&Object.keys(e).length&&this.restore_input_states(e)},t=t=>{t.forEach(t=>{t.isIntersecting&&e(this.savedStates)})};this.viewportObserver?e(this.savedStates):(this.viewportObserver=new IntersectionObserver(t),this.viewportObserver.observe(document.querySelector(`#${this.tableId}`))),$(window).off("resize.redraw").on("resize.redraw",()=>{e(this.activeFilters)}),setTimeout(()=>{this.table.columns.adjust().draw(!1),e(this.savedStates)},100)}passes_filter=(e,t)=>{let a=/^(>=|<=|>|<|)([-+]?\d*\.?\d+)(-?)([-+]?\d*\.?\d+)?$/,i=t.match(a);if(i){let[,s,r,n,o]=i,l=0,h=0;switch("0"!=r&&(l=parseFloat(r)||-1/0),"0"!=o&&(h=parseFloat(o)||1/0),s){case">":return e>l;case">=":return e>=l;case"<":return e=l&&e<=h:e===l}}return e.toString().includes(t)};add_column_filters(){let e=this.table,t=(t,a)=>{a?this.activeFilters.values[t]=a:delete this.activeFilters.values[t],$.fn.dataTable.ext.search.length=0,$.fn.dataTable.ext.search.push((e,t)=>{for(let[a,i]of Object.entries(this.activeFilters.values)){let s=parseFloat(t[a])||0;if(!this.passes_filter(s,i))return!1}return!0}),e.draw()},a=()=>{if(document.querySelector(`#${this.tableId} thead .filter-row`))return;let e=document.querySelector(`#${this.tableId} thead tr`);if(!e){console.error("Cabe\xe7alho da tabela n\xe3o encontrado!");return}let a=document.createElement("tr");a.classList.add("filter-row"),$(e).children("th").each((e,i)=>{let s=document.createElement("th"),r=document.createElement("input");r.type="text",r.placeholder="Column Filter",r.style.width="100%",r.dataset.columnIndex=e,r.addEventListener("keyup",()=>t(e,r.value.trim())),s.appendChild(r),a.appendChild(s)});let i=document.querySelector(`#${this.tableId} thead`);i.appendChild(a)};a(),e.on("preDraw",()=>{this.savedInputState=this.save_input_states()}),e.on("draw",()=>{a(),this.savedInputState&&this.restore_input_states(this.savedInputState)})}default_column_filter(e,t){let a=this.table;t?this.activeFilters.values[e]=t:delete this.activeFilters.values[e];let i=document.querySelector(`#${this.tableId} thead .filter-row input[data-column-index="${e}"]`);i&&(i.value=t),$.fn.dataTable.ext.search.length=0,$.fn.dataTable.ext.search.push((e,t)=>{for(let[a,i]of Object.entries(this.activeFilters.values)){let s=parseFloat(t[a])||0;if(!this.passes_filter(s,i))return!1}return!0}),a.draw(),this.savedStates=this.save_input_states()}highlight_criteria(e,t,a={color:"salmon"}){this.criteriaColumnIndexs.push(e),this.criteria.push(t),this.criteriaColors.push(a.color)}highlight_cells_by_criteria(){let e=this;this.table.rows({search:"applied"}).every(t=>{for(let a=0;ae).find(e=>e.renderTo.id===this.id);e.update({plotOptions:{series:{dataLabels:{enabled:!0,format:"{point.label}",style:{fontWeight:"normal",textOutline:"none"}}}}})}remove_grid(){let e=Highcharts.charts.filter(e=>e).find(e=>e.renderTo.id===this.id);e.update({yAxis:{grid:{borderWidth:0},gridLineWidth:0},xAxis:{grid:{borderWidth:0}}})}push_layer(e){if(!e)return this;let t=new Set,a=new Set,i=new Set;return e.forEach(e=>{e.parent&&!e.id&&t.add(`${e.name}`),e.id&&!e.parent&&a.add(`${e.name}`),e.id&&e.parent&&i.add(`${e.name}`)}),this.lines=t.size+a.size+i.size,this.highcharts.addSeries({data:e},!1),this}redraw(){let e=Highcharts.charts.filter(e=>e).find(e=>e.renderTo.id===this.id),t=e.yAxis[0].options.max,a=this.lines;at&&e.yAxis[0].update({scrollbar:{enabled:!0}}),this.highcharts.redraw()}first_max_visible_lines(e){let t=this.lines||1;e>t&&(e=t),this.highcharts.update({yAxis:{max:e-1}})}set_height(e){this.highcharts.update({chart:{height:e}})}set_auto_height(){this.highcharts.update({chart:{height:void 0},yAxis:{max:void 0}})}}function disable_gantt_collapse(){document.addEventListener("click",function(e){(e.target.classList.contains("highcharts-treegrid-node-expanded")||e.target.classList.contains("highcharts-treegrid-node-collapsed"))&&(e.stopPropagation(),e.preventDefault()),e.target.closest(".highcharts-label-icon")&&(e.stopPropagation(),e.preventDefault())},!0)}