text: AmCharts.translations["export"]||(AmCharts.translations["export"]={}),AmCharts.translations["export"].en||(AmCharts.translations["export"].en={"fallback.save.text":"CTRL + C to copy the data into the clipboard.","fallback.save.image":"Rightclick -> Save picture as... to save the image.","capturing.delayed.menu.label":"{{duration}}","capturing.delayed.menu.title":"Click to cancel","menu.label.print":"Print","menu.label.undo":"Undo","menu.label.redo":"Redo","menu.label.cancel":"Cancel","menu.label.save.image":"Download as ...","menu.label.save.data":"Save as ...","menu.label.draw":"Annotate ...","menu.label.draw.change":"Change ...","menu.label.draw.add":"Add ...","menu.label.draw.shapes":"Shape ...","menu.label.draw.colors":"Color ...","menu.label.draw.widths":"Size ...","menu.label.draw.opacities":"Opacity ...","menu.label.draw.text":"Text","menu.label.draw.modes":"Mode ...","menu.label.draw.modes.pencil":"Pencil","menu.label.draw.modes.line":"Line","menu.label.draw.modes.arrow":"Arrow"}),function(){AmCharts.export=function(e,t){var a={name:"export",version:"1.2.8",libs:{async:!0,autoLoad:!0,reload:!1,resources:[{"pdfmake/pdfmake.js":["pdfmake/vfs_fonts.js"],"jszip/jszip.js":["xlsx/xlsx.js"]},"fabric.js/fabric.js","FileSaver.js/FileSaver.js"]},config:{},setup:{chart:e,hasBlob:!1},drawing:{enabled:!1,undos:[],redos:[],buffer:{position:{x1:0,y1:0,x2:0,y2:0,xD:0,yD:0}},handler:{undo:function(e,t){var r=a.drawing.undos.pop();if(r){r.selectable=!0,a.drawing.redos.push(r),"added"==r.action&&a.setup.fabric.remove(r.target);var i=JSON.parse(r.state);r.target.set(i),r.target instanceof fabric.Group&&a.drawing.handler.change({color:i.cfg.color,width:i.cfg.width,opacity:i.cfg.opacity},!0,r.target),a.setup.fabric.renderAll(),r.state!=r.target.recentState||t||a.drawing.handler.undo(r,!0)}},redo:function(){var e=a.drawing.redos.pop();if(e){e.selectable=!0,a.drawing.undos.push(e),"added"==e.action&&a.setup.fabric.add(e.target);var t=JSON.parse(e.state);e.target.recentState=e.state,e.target.set(t),e.target instanceof fabric.Group&&a.drawing.handler.change({color:t.cfg.color,width:t.cfg.width,opacity:t.cfg.opacity},!0,e.target),a.setup.fabric.renderAll(),"addified"==e.action&&a.drawing.handler.redo()}},done:function(){a.drawing.buffer.enabled=!1,a.drawing.undos=[],a.drawing.redos=[],a.createMenu(a.config.menu),a.setup.fabric.deactivateAll(),a.setup.wrapper.setAttribute("class",a.setup.chart.classNamePrefix+"-export-canvas")},add:function(e){var t=a.deepMerge({top:a.setup.fabric.height/2,left:a.setup.fabric.width/2},e||{}),r=-1!=t.url.indexOf(".svg")?fabric.loadSVGFromURL:fabric.Image.fromURL;r(t.url,function(e,r){var i=void 0!==r?fabric.util.groupSVGElements(e,r):e,n=!1;(i.height>a.setup.fabric.height||i.width>a.setup.fabric.width)&&(n=a.setup.fabric.height/2/i.height),t.top>a.setup.fabric.height&&(t.top=a.setup.fabric.height/2),t.left>a.setup.fabric.width&&(t.left=a.setup.fabric.width/2),i.set({originX:"center",originY:"center",top:t.top,left:t.left,width:n?i.width*n:i.width,height:n?i.height*n:i.height,fill:a.drawing.color}),a.setup.fabric.add(i)})},change:function(e,t,r){var i,n,o,s=a.deepMerge({},e||{}),l=r||a.drawing.buffer.target,c=l?l._objects?l._objects:[l]:null;if(s.mode&&(a.drawing.mode=s.mode),s.width&&(a.drawing.width=s.width,a.drawing.fontSize=3*s.width),s.fontSize&&(a.drawing.fontSize=s.fontSize),s.color&&(a.drawing.color=s.color),s.opacity&&(a.drawing.opacity=s.opacity),o=new fabric.Color(a.drawing.color).getSource(),o.pop(),o.push(a.drawing.opacity),a.drawing.color="rgba("+o.join()+")",a.setup.fabric.freeDrawingBrush.color=a.drawing.color,a.setup.fabric.freeDrawingBrush.width=a.drawing.width,l){for(i=JSON.parse(l.recentState).cfg,i&&(s.color=s.color||i.color,s.width=s.width||i.width,s.opacity=s.opacity||i.opacity,s.fontSize=s.fontSize||3*s.width,o=new fabric.Color(s.color).getSource(),o.pop(),o.push(s.opacity),s.color="rgba("+o.join()+")"),n=0;n<c.length;n++)c[n]instanceof fabric.Text||c[n]instanceof fabric.PathGroup||c[n]instanceof fabric.Triangle?((s.color||s.opacity)&&c[n].set({fill:s.color}),s.fontSize&&c[n].set({fontSize:s.fontSize})):(c[n]instanceof fabric.Path||c[n]instanceof fabric.Line)&&(l instanceof fabric.Group?(s.color||s.opacity)&&c[n].set({stroke:s.color}):((s.color||s.opacity)&&c[n].set({stroke:s.color}),s.width&&c[n].set({strokeWidth:s.width})));t||(i=JSON.stringify(a.deepMerge(l.saveState().originalState,{cfg:{color:s.color,width:s.width,opacity:s.opacity}})),l.recentState=i,a.drawing.redos=[],a.drawing.undos.push({action:"modified",target:l,state:i})),a.setup.fabric.renderAll()}},text:function(e){var t=a.deepMerge({text:a.i18l("menu.label.draw.text"),top:a.setup.fabric.height/2,left:a.setup.fabric.width/2,fontSize:a.drawing.fontSize,fontFamily:a.setup.chart.fontFamily||"Verdana",fill:a.drawing.color},e||{});t.click=function(){};var r=new fabric.IText(t.text,t);return a.setup.fabric.add(r),a.setup.fabric.setActiveObject(r),r.selectAll(),r.enterEditing(),r},line:function(e){var t,r,i,n,o=a.deepMerge({x1:a.setup.fabric.width/2-a.setup.fabric.width/10,x2:a.setup.fabric.width/2+a.setup.fabric.width/10,y1:a.setup.fabric.height/2,y2:a.setup.fabric.height/2,angle:90,strokeLineCap:a.drawing.lineCap,arrow:a.drawing.arrow,color:a.drawing.color,width:a.drawing.width,group:[]},e||{}),s=new fabric.Line([o.x1,o.y1,o.x2,o.y2],{stroke:o.color,strokeWidth:o.width,strokeLineCap:o.strokeLineCap});if(o.group.push(s),o.arrow&&(o.angle=o.angle?o.angle:a.getAngle(o.x1,o.y1,o.x2,o.y2),"start"==o.arrow?(i=o.y1+o.width/2,n=o.x1+o.width/2):"middle"==o.arrow?(i=o.y2+o.width/2-(o.y2-o.y1)/2,n=o.x2+o.width/2-(o.x2-o.x1)/2):(i=o.y2+o.width/2,n=o.x2+o.width/2),r=new fabric.Triangle({top:i,left:n,fill:o.color,height:7*o.width,width:7*o.width,angle:o.angle,originX:"center",originY:"bottom"}),o.group.push(r)),"config"!=o.action){if(o.arrow){var l=new fabric.Group(o.group);return l.set({cfg:o,fill:o.color,action:o.action,selectable:!0,known:"change"==o.action}),"change"==o.action&&a.setup.fabric.setActiveObject(l),a.setup.fabric.add(l),l}return a.setup.fabric.add(s),s}for(t=0;t<o.group.length;t++)o.group[t].noUndo=!0,a.setup.fabric.add(o.group[t]);return o}}},defaults:{position:"top-right",fileName:"amCharts",action:"download",path:(e.path||"")+"plugins/export/",formats:{JPG:{mimeType:"image/jpg",extension:"jpg",capture:!0},PNG:{mimeType:"image/png",extension:"png",capture:!0},SVG:{mimeType:"text/xml",extension:"svg",capture:!0},PDF:{mimeType:"application/pdf",extension:"pdf",capture:!0},CSV:{mimeType:"text/plain",extension:"csv"},JSON:{mimeType:"text/plain",extension:"json"},XLSX:{mimeType:"application/octet-stream",extension:"xlsx"}},fabric:{backgroundColor:"#FFFFFF",removeImages:!0,selection:!1,drawing:{enabled:!0,arrow:"end",lineCap:"butt",mode:"pencil",modes:["pencil","line","arrow"],color:"#000000",colors:["#000000","#FFFFFF","#FF0000","#00FF00","#0000FF"],shapes:["11.svg","14.svg","16.svg","17.svg","20.svg","27.svg"],width:1,fontSize:11,widths:[1,5,10,15],opacity:1,opacities:[1,.8,.6,.4,.2],menu:void 0}},pdfMake:{pageSize:"A4",pageOrientation:"portrait",images:{},content:["Saved from:",window.location.href,{image:"reference",fit:[523.28,769.89]}]},menu:void 0,divId:null,menuReviver:null,menuWalker:null,fallback:!0,keyListener:!0,fileListener:!0},i18l:function(e,t){var r=t?langugage:a.setup.chart.language?a.setup.chart.language:"en",i=AmCharts.translations[a.name][r]||{};return i[e]||e},download:function(e,t,r){if(window.saveAs&&a.setup.hasBlob){a.toBlob({data:e,type:t},function(e){saveAs(e,r)})}else if(a.config.fallback&&"text/plain"==t){var i=document.createElement("div"),n=document.createElement("div"),o=document.createElement("textarea");n.innerHTML=a.i18l("fallback.save.text"),i.appendChild(n),i.appendChild(o),n.setAttribute("class","amcharts-export-fallback-message"),i.setAttribute("class","amcharts-export-fallback"),a.setup.chart.containerDiv.appendChild(i),o.setAttribute("readonly",""),o.value=e,o.focus(),o.select(),a.createMenu([{"class":"export-main export-close",label:"Done",click:function(){a.createMenu(a.config.menu),a.setup.chart.containerDiv.removeChild(i)}}])}else{if(!a.config.fallback||"image"!=t.split("/")[0])throw new Error("Unable to create file. Ensure saveAs (FileSaver.js) is supported.");var i=document.createElement("div"),n=document.createElement("div"),s=a.toImage({data:e});n.innerHTML=a.i18l("fallback.save.image"),i.appendChild(n),i.appendChild(s),n.setAttribute("class","amcharts-export-fallback-message"),i.setAttribute("class","amcharts-export-fallback"),a.setup.chart.containerDiv.appendChild(i),a.createMenu([{"class":"export-main export-close",label:"Done",click:function(){a.createMenu(a.config.menu),a.setup.chart.containerDiv.removeChild(i)}}])}return e},loadResource:function(e,t){function r(){if(t)for(i=0;i<t.length;i++)a.loadResource(t[i])}var i,n,o,s,l,c,d=-1!=e.indexOf("//")?e:[a.libs.path,e].join("");for(-1!=e.indexOf(".js")?(o=document.createElement("script"),o.setAttribute("type","text/javascript"),o.setAttribute("src",d),a.libs.async&&o.setAttribute("async","")):-1!=e.indexOf(".css")&&(o=document.createElement("link"),o.setAttribute("type","text/css"),o.setAttribute("rel","stylesheet"),o.setAttribute("href",d)),i=0;i<document.head.childNodes.length;i++)if(s=document.head.childNodes[i],l=s?s.src||s.href:!1,c=s?s.tagName:!1,s&&l&&-1!=l.indexOf(e)){a.libs.reload&&document.head.removeChild(s),n=!0;break}(!n||a.libs.reload)&&(o.addEventListener("load",r),document.head.appendChild(o))},loadDependencies:function(){var e,t;if(a.libs.autoLoad)for(e=0;e<a.libs.resources.length;e++)if(a.libs.resources[e]instanceof Object)for(t in a.libs.resources[e])a.loadResource(t,a.libs.resources[e][t]);else a.loadResource(a.libs.resources[e])},pxToNumber:function(e){return Number(String(e).replace("px",""))||0},numberToPx:function(e){return String(e)+"px"},deepMerge:function(e,t,r){var i,n,o=t instanceof Array?"array":"object";for(i in t)"array"==o&&isNaN(i)||(n=t[i],(void 0==e[i]||r)&&(n instanceof Array?e[i]=new Array:n instanceof Function?e[i]=new Function:n instanceof Date?e[i]=new Date:n instanceof Object?e[i]=new Object:n instanceof Number?e[i]=new Number:n instanceof String&&(e[i]=new String)),(e instanceof Object||e instanceof Array)&&(n instanceof Object||n instanceof Array)&&!(n instanceof Function||n instanceof Date||a.isElement(n))&&"chart"!=i?a.deepMerge(e[i],n,r):e instanceof Array&&!r?e.push(n):e[i]=n);return e},isElement:function(e){return e instanceof Object&&e&&1===e.nodeType},isPressed:function(e){return"mousemove"==e.type&&1===e.which||(a.drawing.buffer.isPressed="touchmove"==e.type||1===e.buttons||1===e.button||1===e.which?!0:!1),a.drawing.buffer.isPressed},isTainted:function(e){var t=String(window.location.origin||window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:""));return e&&-1!=e.indexOf("//")&&-1==e.indexOf(t.replace(/.*:/,""))?!0:!1},isSupported:function(){return a.config.enabled&&(!(AmCharts.isIE&&AmCharts.IEversion<=9)||Array.prototype.indexOf&&document.head&&a.config.fallback!==!1)?!0:!1},getAngle:function(e,t,a,r){var i,n=a-e,o=r-t;return i=0==n?0==o?0:o>0?Math.PI/2:3*Math.PI/2:0==o?n>0?0:Math.PI:0>n?Math.atan(o/n)+Math.PI:0>o?Math.atan(o/n)+2*Math.PI:Math.atan(o/n),180*i/Math.PI},gatherAttribute:function(e,t,r,i){var n,i=i?i:0,r=r?r:3;return e&&(n=e.getAttribute(t),!n&&r>i)?a.gatherAttribute(e.parentNode,t,r,i+1):n},gatherClassName:function(e,t,r,i){var n,i=i?i:0,r=r?r:3;if(a.isElement(e)){if(n=-1!=(e.getAttribute("class")||"").split(" ").indexOf(t),!n&&r>i)return a.gatherClassName(e.parentNode,t,r,i+1);n&&(n=e)}return n},gatherElements:function(e,t,r){var i,n;for(i=0;i<e.children.length;i++){var o=e.children[i];if("clipPath"==o.tagName){for(n=0;n<o.childNodes.length;n++)o.childNodes[n].setAttribute("fill","transparent");e.clippings[o.id]=o}else if("pattern"==o.tagName){var s={node:o,source:o.getAttribute("xlink:href"),width:Number(o.getAttribute("width")),height:Number(o.getAttribute("height")),repeat:"repeat"};for(n=0;n<o.childNodes.length;n++)"rect"==o.childNodes[n].tagName&&(s.fill=o.childNodes[n].getAttribute("fill"));t.removeImages&&a.isTainted(s.source)?e.patterns[o.id]=s.fill?s.fill:"transparent":(r.included++,fabric.Image.fromURL(s.source,function(t){return function(a){r.loaded++;var i=new fabric.StaticCanvas(void 0,{backgroundColor:t.fill});i.add(a);var n=new fabric.Pattern({source:function(){return i.setDimensions({width:t.width,height:t.height}),i.getElement()},repeat:"repeat"});e.patterns[t.node.id]=n}}(s)))}else"image"==o.tagName&&(r.included++,fabric.Image.fromURL(o.getAttribute("xlink:href"),function(){r.loaded++}))}return e},gatherPosition:function(e,t){var r,i=a.drawing.buffer.position,n=fabric.util.invertTransform(a.setup.fabric.viewportTransform);return"touchmove"==e.type&&("touches"in e?e=e.touches[0]:"changedTouches"in e&&(e=e.changedTouches[0])),r=fabric.util.transformPoint(a.setup.fabric.getPointer(e,!0),n),1==t&&(i.x1=r.x,i.y1=r.y),i.x2=r.x,i.y2=r.y,i.xD=i.x1-i.x2<0?-1*(i.x1-i.x2):i.x1-i.x2,i.yD=i.y1-i.y2<0?-1*(i.y1-i.y2):i.y1-i.y2,i},capture:function(e,t){var r,i=a.deepMerge(a.deepMerge({},a.config.fabric),e||{}),n=[],o={x:0,y:0,pX:0,pY:0,width:a.setup.chart.divRealWidth,height:a.setup.chart.divRealHeight},s={loaded:0,included:0},l=a.setup.chart.containerDiv.getElementsByTagName("svg");for(r=0;r<l.length;r++){var c={svg:l[r],parent:l[r].parentNode,children:l[r].getElementsByTagName("*"),offset:{x:0,y:0},patterns:{},clippings:{}};c=a.gatherElements(c,i,s),n.push(c)}if(a.config.legend&&a.setup.chart.legend&&"outside"==a.setup.chart.legend.position){var c={svg:a.setup.chart.legend.container.container,parent:a.setup.chart.legend.container.container.parentNode,children:a.setup.chart.legend.container.container.getElementsByTagName("*"),offset:{x:0,y:0},legend:{type:-1!=["top","left"].indexOf(a.config.legend.position)?"unshift":"push",position:a.config.legend.position,width:a.config.legend.width?a.config.legend.width:a.setup.chart.legend.container.width,height:a.config.legend.height?a.config.legend.height:a.setup.chart.legend.container.height},patterns:{},clippings:{}};-1!=["left","right"].indexOf(c.legend.position)?(o.width+=c.legend.width,o.height=c.legend.height>o.height?c.legend.height:o.height):-1!=["top","bottom"].indexOf(c.legend.position)&&(o.height+=c.legend.height),c=a.gatherElements(c,i,s),n[c.legend.type](c)}if(a.drawing.buffer.enabled="draw"==i.action,a.setup.wrapper?a.setup.wrapper.innerHTML="":(a.setup.wrapper=document.createElement("div"),a.setup.wrapper.setAttribute("class",a.setup.chart.classNamePrefix+"-export-canvas"),a.setup.chart.containerDiv.appendChild(a.setup.wrapper)),"stock"==a.setup.chart.type){var d={top:0,right:0,bottom:0,left:0};a.setup.chart.leftContainer&&(o.width-=a.setup.chart.leftContainer.offsetWidth,d.left=a.setup.chart.leftContainer.offsetWidth+2*a.setup.chart.panelsSettings.panelSpacing),a.setup.chart.rightContainer&&(o.width-=a.setup.chart.rightContainer.offsetWidth,d.right=a.setup.chart.rightContainer.offsetWidth+2*a.setup.chart.panelsSettings.panelSpacing),a.setup.chart.periodSelector&&-1!=["top","bottom"].indexOf(a.setup.chart.periodSelector.position)&&(o.height-=a.setup.chart.periodSelector.offsetHeight+a.setup.chart.panelsSettings.panelSpacing,d[a.setup.chart.periodSelector.position]+=a.setup.chart.periodSelector.offsetHeight+a.setup.chart.panelsSettings.panelSpacing),a.setup.chart.dataSetSelector&&-1!=["top","bottom"].indexOf(a.setup.chart.dataSetSelector.position)&&(o.height-=a.setup.chart.dataSetSelector.offsetHeight,d[a.setup.chart.dataSetSelector.position]+=a.setup.chart.dataSetSelector.offsetHeight),a.setup.wrapper.style.paddingTop=a.numberToPx(d.top),a.setup.wrapper.style.paddingRight=a.numberToPx(d.right),a.setup.wrapper.style.paddingBottom=a.numberToPx(d.bottom),a.setup.wrapper.style.paddingLeft=a.numberToPx(d.left)}for(a.setup.canvas=document.createElement("canvas"),a.setup.wrapper.appendChild(a.setup.canvas),a.setup.fabric=new fabric.Canvas(a.setup.canvas,a.deepMerge({width:o.width,height:o.height,isDrawingMode:!0},i)),a.deepMerge(a.setup.fabric,i),a.deepMerge(a.setup.fabric.freeDrawingBrush,i.drawing),a.deepMerge(a.drawing,i.drawing),a.drawing.handler.change(i.drawing),a.setup.fabric.on("mouse:down",function(e){a.gatherPosition(e.e,1);a.drawing.buffer.pressedTS=Number(new Date),a.isPressed(e.e)}),a.setup.fabric.on("mouse:move",function(e){var t=a.gatherPosition(e.e,2);if(a.isPressed(e.e),a.drawing.buffer.isPressed&&!a.drawing.buffer.line&&!a.drawing.buffer.isSelected&&"pencil"!=a.drawing.mode&&(t.xD>5||t.xD>5)&&(a.drawing.buffer.hasLine=!0,a.setup.fabric.isDrawingMode=!1,a.setup.fabric._onMouseUpInDrawingMode(e),a.drawing.buffer.line=a.drawing.handler.line({x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,arrow:"line"==a.drawing.mode?!1:a.drawing.arrow,action:"config"})),a.drawing.buffer.line){var i,n,o,s=a.drawing.buffer.line;for(s.x2=t.x2,s.y2=t.y2,r=0;r<s.group.length;r++)i=s.group[r],i instanceof fabric.Line?i.set({x2:s.x2,y2:s.y2}):i instanceof fabric.Triangle&&(s.angle=a.getAngle(s.x1,s.y1,s.x2,s.y2)+90,"start"==s.arrow?(n=s.y1+s.width/2,o=s.x1+s.width/2):"middle"==s.arrow?(n=s.y2+s.width/2-(s.y2-s.y1)/2,o=s.x2+s.width/2-(s.x2-s.x1)/2):(n=s.y2+s.width/2,o=s.x2+s.width/2),i.set({top:n,left:o,angle:s.angle}));a.setup.fabric.renderAll()}}),a.setup.fabric.on("mouse:up",function(e){if(Number(new Date)-a.drawing.buffer.pressedTS<200){var t=a.setup.fabric.findTarget(e.e);t&&t.selectable&&a.setup.fabric.setActiveObject(t)}if(a.drawing.buffer.line){for(r=0;r<a.drawing.buffer.line.group.length;r++)a.drawing.buffer.line.group[r].remove();delete a.drawing.buffer.line.action,delete a.drawing.buffer.line.group,a.drawing.handler.line(a.drawing.buffer.line)}a.drawing.buffer.line=!1,a.drawing.buffer.hasLine=!1,a.drawing.buffer.isPressed=!1}),a.setup.fabric.on("object:selected",function(e){a.drawing.buffer.isSelected=!0,a.drawing.buffer.target=e.target,a.setup.fabric.isDrawingMode=!1}),a.setup.fabric.on("selection:cleared",function(){a.drawing.buffer.onMouseDown=a.setup.fabric.freeDrawingBrush.onMouseDown,a.drawing.buffer.target=!1,a.drawing.buffer.isSelected&&(a.setup.fabric._isCurrentlyDrawing=!1,a.setup.fabric.freeDrawingBrush.onMouseDown=function(){}),setTimeout(function(){a.drawing.buffer.isSelected=!1,a.setup.fabric.isDrawingMode=!0,a.setup.fabric.freeDrawingBrush.onMouseDown=a.drawing.buffer.onMouseDown},10)}),a.setup.fabric.on("path:created",function(e){var t=e.path;return Number(new Date)-a.drawing.buffer.pressedTS<200||a.drawing.buffer.hasLine?(a.setup.fabric.remove(t),void a.setup.fabric.renderAll()):void 0}),a.setup.fabric.on("object:added",function(e){var t=e.target,r=a.deepMerge(t.saveState().originalState,{cfg:{color:a.drawing.color,width:a.drawing.width,opacity:a.drawing.opacity,fontSize:a.drawing.fontSize}});return Number(new Date)-a.drawing.buffer.pressedTS<200&&!t.noUndo?(a.setup.fabric.remove(t),void a.setup.fabric.renderAll()):(r=JSON.stringify(r),t.recentState=r,!t.selectable||t.known||t.noUndo||(a.drawing.undos.push({action:"added",target:t,state:r}),a.drawing.undos.push({action:"addified",target:t,state:r}),a.drawing.redos=[]),t.known=!0,void(a.setup.fabric.isDrawingMode=!0))}),a.setup.fabric.on("object:modified",function(e){var t=e.target,r=JSON.parse(t.recentState),i=a.deepMerge(t.saveState().originalState,{cfg:r.cfg});i=JSON.stringify(i),t.recentState=i,a.drawing.undos.push({action:"modified",target:t,state:i}),a.drawing.redos=[]}),a.setup.fabric.on("text:changed",function(e){var t=e.target;clearTimeout(t.timer),t.timer=setTimeout(function(){var e=JSON.stringify(t.saveState().originalState);t.recentState=e,a.drawing.redos=[],a.drawing.undos.push({action:"modified",target:t,state:e})},250)}),a.drawing.buffer.enabled?(a.setup.wrapper.setAttribute("class",a.setup.chart.classNamePrefix+"-export-canvas active"),a.setup.wrapper.style.backgroundColor=i.backgroundColor):a.setup.wrapper.setAttribute("class",a.setup.chart.classNamePrefix+"-export-canvas"),r=0;r<n.length;r++){var c=n[r],p=a.gatherClassName(c.parent,a.setup.chart.classNamePrefix+"-legend-div",1),f=a.gatherClassName(c.parent,a.setup.chart.classNamePrefix+"-stock-panel-div"),u=a.gatherClassName(c.parent,a.setup.chart.classNamePrefix+"-scrollbar-chart-div");"stock"==a.setup.chart.type&&a.setup.chart.legendSettings.position?-1!=["top","bottom"].indexOf(a.setup.chart.legendSettings.position)?c.parent.style.top||c.parent.style.left?(c.offset.y=a.pxToNumber(c.parent.style.top),c.offset.x=a.pxToNumber(c.parent.style.left)):(c.offset.x=o.x,c.offset.y=o.y,o.y+=a.pxToNumber(c.parent.style.height),f?(o.pY=a.pxToNumber(f.style.marginTop),c.offset.y+=o.pY):u&&(c.offset.y+=o.pY)):-1!=["left","right"].indexOf(a.setup.chart.legendSettings.position)&&(c.offset.y=a.pxToNumber(c.parent.style.top)+o.pY,c.offset.x=a.pxToNumber(c.parent.style.left)+o.pX,p?o.pY+=a.pxToNumber(f.style.height)+a.setup.chart.panelsSettings.panelSpacing:u&&(c.offset.y-=a.setup.chart.panelsSettings.panelSpacing)):(c.parent.style.top||c.parent.style.left?(c.offset.y=a.pxToNumber(c.parent.style.top),c.offset.x=a.pxToNumber(c.parent.style.left)):c.legend?"left"==c.legend.position?o.x+=c.legend.width:"right"==c.legend.position?c.offset.x+=o.width-c.legend.width:"top"==c.legend.position?o.y+=c.legend.height:"bottom"==c.legend.position&&(c.offset.y+=o.height-c.legend.height):(c.offset.x=o.x,c.offset.y=o.y+o.pY,o.y+=a.pxToNumber(c.parent.style.height)),p&&f&&f.style.marginTop&&(o.y+=a.pxToNumber(f.style.marginTop),c.offset.y+=a.pxToNumber(f.style.marginTop))),a.handleCallback(i.beforeCapture,i),fabric.parseSVGDocument(c.svg,function(e){return function(r,o){var l,c=fabric.util.groupSVGElements(r,o),d={top:e.offset.y,left:e.offset.x,selectable:!1};for(l=0;l<c.paths.length;l++)if(c.paths[l]){if(i.removeImages&&a.isTainted(c.paths[l]["xlink:href"])){c.paths.splice(l,1);continue}if(c.paths[l].fill instanceof Object)"radial"==c.paths[l].fill.type&&(c.paths[l].fill.coords.r2=-1*c.paths[l].fill.coords.r1,c.paths[l].fill.coords.r1=0),c.paths[l].set({opacity:c.paths[l].fillOpacity});else if("url"==String(c.paths[l].fill).slice(0,3)){var p=c.paths[l].fill.slice(5,-1);e.patterns&&e.patterns[p]&&c.paths[l].set({fill:e.patterns[p],opacity:c.paths[l].fillOpacity})}if("url"==String(c.paths[l].clipPath).slice(0,3)){var p=c.paths[l].clipPath.slice(5,-1);if(e.clippings[p]){var f=e.clippings[p].childNodes[0],u=c.paths[l].svg.getAttribute("transform")||"translate(0,0)";u=u.slice(10,-1).split(","),c.paths[l].set({clipTo:function(e,t){return function(a){var r=Number(e.getAttribute("width")||"0"),i=Number(e.getAttribute("height")||"0"),n=Number(e.getAttribute("x")||"0"),o=Number(e.getAttribute("y")||"0");a.rect(-1*Number(t[0])+n,-1*Number(t[1])+o,r,i)}}(f,u)})}}if(c.paths[l].originalBBox){var g=c.paths[l].originalBBox;c.paths[l].set("left"==c.paths[l].textAlign?{left:g.left+c.paths[l].width/2}:{left:g.left-c.paths[l].width/2})}}if(c.set(d),a.setup.fabric.add(c),e.svg.parentNode&&e.svg.parentNode.getElementsByTagName){var h=e.svg.parentNode.getElementsByClassName(a.setup.chart.classNamePrefix+"-balloon-div");for(l=0;l<h.length;l++)if(i.balloonFunction instanceof Function)i.balloonFunction.apply(a,[h[l],e]);else{var m=h[l],b=m.childNodes[0],w=new fabric.Text(b.innerText||b.innerHTML,{fontSize:a.pxToNumber(b.style.fontSize),fontFamily:b.style.fontFamily,fill:b.style.color,top:a.pxToNumber(m.style.top)+e.offset.y,left:a.pxToNumber(m.style.left)+e.offset.x,selectable:!1});a.setup.fabric.add(w)}}if(e.svg.nextSibling&&"A"==e.svg.nextSibling.tagName){var w=new fabric.Text(e.svg.nextSibling.innerText||e.svg.nextSibling.innerHTML,{fontSize:a.pxToNumber(e.svg.nextSibling.style.fontSize),fontFamily:e.svg.nextSibling.style.fontFamily,fill:e.svg.nextSibling.style.color,top:a.pxToNumber(e.svg.nextSibling.style.top)+e.offset.y,left:a.pxToNumber(e.svg.nextSibling.style.left)+e.offset.x,selectable:!1});a.setup.fabric.add(w)}if(n.pop(),!n.length)var y=setInterval(function(){s.loaded==s.included&&(clearTimeout(y),a.handleCallback(i.afterCapture,i),a.setup.fabric.renderAll(),a.handleCallback(t,i))},AmCharts.updateRate)}}(c),function(e,t){var r,n=a.gatherAttribute(e,"class"),o=a.gatherAttribute(e,"visibility"),s=a.gatherAttribute(e,"clip-path");if(t.className=String(n),t.classList=String(n).split(" "),t.clipPath=s,t.svg=e,"text"==e.tagName&&e.childNodes.length>1){var l=[],c=e.getAttribute("text-anchor")||"left",d={start:"left",middle:"center",end:"right"};for(r=0;r<e.childNodes.length;r++)l.push(e.childNodes[r].textContent);"middle"!=c&&(t.originalBBox=t.getBoundingRect()),t.set({lineHeight:1.05,top:t.top+t.height-t.fontSize*(.18+t._fontSizeFraction)/2,text:l.join("\n"),textAlign:d[c],selectable:!1})}if("hidden"==o)t.opacity=0;else{var p=["fill","stroke"];for(r=0;r<p.length;r++){var f=p[r],u=String(e.getAttribute(f)||""),g=Number(e.getAttribute(f+"-opacity")||"1"),h=fabric.Color.fromHex(u).getSource();-1==t.classList.indexOf(a.setup.chart.classNamePrefix+"-guide-fill")||u||(g=0,h=fabric.Color.fromHex("#000000").getSource()),h&&(h.pop(),h.push(g),t[f]="rgba("+h.join()+")",t[f+a.capitalize("opacity")]=g)}}a.handleCallback(i.reviver,t,e)})}},toCanvas:function(e,t){var r=(a.deepMerge({},e||{}),a.setup.canvas);return a.handleCallback(t,r),r},toImage:function(e,t){var r=a.deepMerge({format:"png",quality:1,multiplier:1},e||{}),i=r.data,n=document.createElement("img");return r.data||(i=r.lossless||"svg"==r.format?a.toSVG(a.deepMerge(r,{getBase64:!0})):a.setup.fabric.toDataURL(r)),n.setAttribute("src",i),a.handleCallback(t,n),n},toBlob:function(e,t){var r,i=a.deepMerge({data:"empty",type:"text/plain"},e||{}),n=/^data:.+;base64,(.*)$/.exec(i.data);return n&&(i.data=n[0],i.type=i.data.slice(5,i.data.indexOf(",")-7),i.data=a.toByteArray({data:i.data.slice(i.data.indexOf(",")+1,i.data.length)})),r=i.getByteArray?i.data:new Blob([i.data],{type:i.type}),a.handleCallback(t,r),r},toJPG:function(e,t){var r=a.deepMerge({format:"jpeg",quality:1,multiplier:1},e||{});r.format=r.format.toLowerCase();var i=a.setup.fabric.toDataURL(r);return a.handleCallback(t,i),i},toPNG:function(e,t){var r=a.deepMerge({format:"png",quality:1,multiplier:1},e||{}),i=a.setup.fabric.toDataURL(r);return a.handleCallback(t,i),i},toSVG:function(e,t){var r=a.deepMerge({reviver:function(e){var t=new RegExp(/\bstyle=(['"])(.*?)\1/),a=t.exec(e)[0].slice(7,-1),r=a.split(";"),i=[];for(i1=0;i1<r.length;i1++)if(r[i1]){var n=r[i1].replace(/\s/g,"").split(":"),o=n[0],s=n[1];if(-1!=["fill","stroke"].indexOf(o))if(s=fabric.Color.fromRgba(s),s&&s._source){var l="#"+s.toHex(),c=s._source[3];i.push([o,l].join(":")),i.push([o+"-opacity",c].join(":"))}else i.push(r[i1]);else"opactiy"!=o&&i.push(r[i1])}return e.replace(a,i.join(";"))}},e||{}),i=a.setup.fabric.toSVG(r,r.reviver);return r.getBase64&&(i="data:image/svg+xml;base64,"+btoa(i)),a.handleCallback(t,i),i},toPDF:function(e,t){var r=a.deepMerge(a.deepMerge({multiplier:2},a.config.pdfMake),e||{},!0);r.images.reference=a.toPNG(r);var i=new pdfMake.createPdf(r);return t&&i.getDataUrl(function(e){return function(){e.apply(a,arguments)}}(t)),i},toPRINT:function(e,t){var r,i=a.deepMerge({delay:1,lossless:!1},e||{}),n=a.toImage(i),o=[],s=document.body.childNodes;for(n.setAttribute("style","width: 100%; max-height: 100%;"),r=0;r<s.length;r++)a.isElement(s[r])&&(o[r]=s[r].style.display,s[r].style.display="none");return document.body.appendChild(n),window.print(),setTimeout(function(){for(r=0;r<s.length;r++)a.isElement(s[r])&&(s[r].style.display=o[r]);document.body.removeChild(n),a.handleCallback(t,n)},i.delay),n},toJSON:function(e,t){var r=a.deepMerge({data:a.getChartData(e)},e||{},!0),i=JSON.stringify(r.data,void 0,"	");return a.handleCallback(t,i),i},toCSV:function(e,t){function r(e){return"string"==typeof e&&(e=e),"string"==typeof e&&(o.escape&&(e=e.replace('"','""')),o.quotes&&(e=['"',e,'"'].join(""))),e}var i,n,o=a.deepMerge({data:a.getChartData(e),delimiter:",",quotes:!0,escape:!0},e||{},!0),s="",l=[],c=[];for(p in o.data[0])c.push(r(p)),l.push(p);s+=c.join(o.delimiter)+"\n";for(i in o.data)if(c=[],!isNaN(i)){for(n in l)if(!isNaN(n)){var d=l[n],p=o.data[i][d];c.push(r(p,d))}s+=c.join(o.delimiter)+"\n"}return a.handleCallback(t,s),s},toXLSX:function(e,t){function r(e,t){t&&(e+=1462);var a=Date.parse(e);return(a-new Date(Date.UTC(1899,11,30)))/864e5}function i(e){for(var t={},a={s:{c:1e7,r:1e7},e:{c:0,r:0}},i=0;i!=e.length;++i)for(var n=0;n!=e[i].length;++n){a.s.r>i&&(a.s.r=i),a.s.c>n&&(a.s.c=n),a.e.r<i&&(a.e.r=i),a.e.c<n&&(a.e.c=n);var o={v:e[i][n]};if(null!=o.v){var s=XLSX.utils.encode_cell({c:n,r:i});"number"==typeof o.v?o.t="n":"boolean"==typeof o.v?o.t="b":o.v instanceof Date?(o.t="n",o.z=XLSX.SSF._table[14],o.v=r(o.v)):o.t="s",t[s]=o}}return a.s.c<1e7&&(t["!ref"]=XLSX.utils.encode_range(a)),t}var n=a.deepMerge({name:"amCharts",dateFormat:"dateObject",withHeader:!0,stringify:!1},e||{},!0),o="",s={SheetNames:[],Sheets:{}};return n.data=n.data?n.data:a.getChartData(n),s.SheetNames.push(n.name),s.Sheets[n.name]=i(a.toArray(n)),o=XLSX.write(s,{bookType:"xlsx",bookSST:!0,type:"base64"}),o="data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,"+o,a.handleCallback(t,o),o},toArray:function(e,t){var r,i,n=a.deepMerge({data:a.getChartData(e),withHeader:!1,stringify:!0},e||{},!0),o=[],s=[];for(i in n.data[0])s.push(i);n.withHeader&&o.push(s);for(r in n.data){var l=[];if(!isNaN(r)){for(i in s)if(!isNaN(i)){var i=s[i],c=n.data[r][i]||"";c=n.stringify?String(c):c,l.push(c)}o.push(l)}}return a.handleCallback(t,o),o},toByteArray:function(e,t){function r(e){var t=e.charCodeAt(0);return t===s?62:t===l?63:c>t?-1:c+10>t?t-c+26+26:p+26>t?t-p:d+26>t?t-d+26:void 0}function i(e){function t(e){c[p++]=e}var a,i,n,s,l,c;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var d=e.length;l="="===e.charAt(d-2)?2:"="===e.charAt(d-1)?1:0,c=new o(3*e.length/4-l),n=l>0?e.length-4:e.length;var p=0;for(a=0,i=0;n>a;a+=4,i+=3)s=r(e.charAt(a))<<18|r(e.charAt(a+1))<<12|r(e.charAt(a+2))<<6|r(e.charAt(a+3)),t((16711680&s)>>16),t((65280&s)>>8),t(255&s);return 2===l?(s=r(e.charAt(a))<<2|r(e.charAt(a+1))>>4,t(255&s)):1===l&&(s=r(e.charAt(a))<<10|r(e.charAt(a+1))<<4|r(e.charAt(a+2))>>2,t(s>>8&255),t(255&s)),c}var n=a.deepMerge({},e||{}),o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),l="/".charCodeAt(0),c="0".charCodeAt(0),d="a".charCodeAt(0),p="A".charCodeAt(0),f=i(n.data);return a.handleCallback(t,f),f},handleCallback:function(e){var t,r=Array();if(e&&e instanceof Function){for(t=0;t<arguments.length;t++)t>0&&r.push(arguments[t]);e.apply(a,r)}},handleDropbox:function(e){if(a.drawing.buffer.enabled)if(e.preventDefault(),e.stopPropagation(),"dragover"==e.type)a.setup.wrapper.setAttribute("class",a.setup.chart.classNamePrefix+"-export-canvas active dropbox");else if(a.setup.wrapper.setAttribute("class",a.setup.chart.classNamePrefix+"-export-canvas active"),"drop"==e.type&&e.dataTransfer.files.length)for(var t=0;t<e.dataTransfer.files.length;t++){var r=new FileReader;r.onloadend=function(t){return function(){a.drawing.handler.add({url:r.result,top:e.layerY-10*t,left:e.layerX-10*t})}}(t),r.readAsDataURL(e.dataTransfer.files[t])}},getChartData:function(e){function t(e,t,i){function n(e,t){return-1!=s.dataFields.indexOf(e)?n([e,".",t].join("")):e}e&&s.exportTitles&&"gantt"!=a.setup.chart.type&&(r=n(e,i),s.dataFieldsMap[r]=e,s.dataFields.push(r),s.titles[r]=t||r)}var r,i,n,o,s=a.deepMerge({data:[],titles:{},dateFields:[],dataFields:[],dataFieldsMap:{},exportTitles:a.config.exportTitles,exportSelection:a.config.exportSelection},e||{},!0),l=["valueField","openField","closeField","highField","lowField","xField","yField"];if(0==s.data.length)if("stock"==a.setup.chart.type){for(s.data=a.setup.chart.mainDataSet.dataProvider,t(a.setup.chart.mainDataSet.categoryField),s.dateFields.push(a.setup.chart.mainDataSet.categoryField),i=0;i<a.setup.chart.mainDataSet.fieldMappings.length;i++){var c=a.setup.chart.mainDataSet.fieldMappings[i];for(n=0;n<a.setup.chart.panels.length;n++){var d=a.setup.chart.panels[n];
  for(o=0;o<d.stockGraphs.length;o++){var p=d.stockGraphs[o];for(i4=0;i4<l.length;i4++)p[l[i4]]==c.toField&&t(c.fromField,p.title,l[i4])}}}for(i=0;i<a.setup.chart.comparedGraphs.length;i++){var p=a.setup.chart.comparedGraphs[i];for(n=0;n<p.dataSet.dataProvider.length;n++)for(o=0;o<p.dataSet.fieldMappings.length;o++){var c=p.dataSet.fieldMappings[o],r=p.dataSet.id+"_"+c.toField;s.data[n][r]=p.dataSet.dataProvider[n][c.fromField],s.titles[r]||t(r,p.dataSet.title)}}}else if("gantt"==a.setup.chart.type){t(a.setup.chart.categoryField),s.dateFields.push(a.setup.chart.categoryField);var f=a.setup.chart.segmentsField;for(i=0;i<a.setup.chart.dataProvider.length;i++){var u=a.setup.chart.dataProvider[i];if(u[f])for(n=0;n<u[f].length;n++)u[f][n][a.setup.chart.categoryField]=u[a.setup.chart.categoryField],s.data.push(u[f][n])}for(i=0;i<a.setup.chart.graphs.length;i++){var p=a.setup.chart.graphs[i];for(n=0;n<l.length;n++){{var g=l[n],h=p[g];p.title}t(h,p.title,g)}}}else if(-1!=["pie","funnel"].indexOf(a.setup.chart.type))s.data=a.setup.chart.dataProvider,t(a.setup.chart.titleField),s.dateFields.push(a.setup.chart.titleField),t(a.setup.chart.valueField);else if("map"!=a.setup.chart.type)for(s.data=a.setup.chart.dataProvider,a.setup.chart.categoryAxis&&(t(a.setup.chart.categoryField,a.setup.chart.categoryAxis.title),s.dateFields.push(a.setup.chart.categoryField)),i=0;i<a.setup.chart.graphs.length;i++){var p=a.setup.chart.graphs[i];for(n=0;n<l.length;n++){var g=l[n],h=p[g];t(h,p.title,g)}}return a.processData(s)},processData:function(t){var r,i,n=a.deepMerge({data:[],titles:{},dateFields:[],dataFields:[],dataFieldsMap:{},dataDateFormat:a.setup.chart.dataDateFormat,dateFormat:a.config.dateFormat||a.setup.chart.dataDateFormat||"YYYY-MM-DD",exportTitles:a.config.exportTitles,exportSelection:a.config.exportSelection},t||{},!0);if(n.data.length){for(r=0;r<n.data.length;r++)for(i in n.data[r])-1==n.dataFields.indexOf(i)&&(n.dataFields.push(i),n.dataFieldsMap[i]=i);var o=[];for(r=0;r<n.data.length;r++){var s={},l=!1;for(i=0;i<n.dataFields.length;i++){var c=n.dataFields[i],d=n.dataFieldsMap[c],p=n.titles[c]||c,f=n.data[r][d]||void 0;n.exportTitles&&"gantt"!=a.setup.chart.type&&p in s&&(p+=["( ",c," )"].join("")),-1!=n.dateFields.indexOf(d)&&(n.dataDateFormat&&(f instanceof String||"string"==typeof f)&&(f=AmCharts.stringToDate(f,n.dataDateFormat)),n.exportSelection&&(f instanceof Date?(f<e.startDate||f>e.endDate)&&(l=!0):(r<e.startIndex||r>e.endIndex)&&(l=!0)),n.dateFormat&&"dateObject"!=n.dateFormat&&f instanceof Date&&(f=AmCharts.formatDate(f,n.dateFormat))),s[p]=f}l||o.push(s)}n.data=o}return n.data},capitalize:function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()},createMenu:function(t,r){function i(t,r){var n,o,s=document.createElement("ul");for(n=0;n<t.length;n++){var l="string"==typeof t[n]?{format:t[n]}:t[n],c=document.createElement("li"),d=document.createElement("a"),p=document.createElement("img"),f=document.createElement("span"),u=String(l.action?l.action:l.format).toLowerCase();if(l.format=String(l.format).toUpperCase(),a.config.formats[l.format]?l=a.deepMerge({label:l.icon?"":l.format,format:l.format,mimeType:a.config.formats[l.format].mimeType,extension:a.config.formats[l.format].extension,capture:a.config.formats[l.format].capture,action:a.config.action,fileName:a.config.fileName},l):l.label||(l.label=l.label?l.label:a.i18l("menu.label."+u)),!(-1!=["CSV","JSON","XLSX"].indexOf(l.format)&&-1!=["map","gauge"].indexOf(a.setup.chart.type)||!a.setup.hasBlob&&"UNDEFINED"!=l.format&&l.mimeType&&"image"!=l.mimeType.split("/")[0]&&"text/plain"!=l.mimeType)){if("draw"==l.action)a.config.fabric.drawing.enabled?(l.menu=l.menu?l.menu:a.config.fabric.drawing.menu,l.click=function(e){return function(){this.capture(e,function(){this.createMenu(e.menu)})}}(l)):l.menu=[];else if(!l.populated&&l.action&&-1!=l.action.indexOf("draw.")){var g=l.action.split(".")[1],h=l[g]||a.config.fabric.drawing[g]||[];for(l.menu=[],l.populated=!0,o=0;o<h.length;o++){var m={label:h[o]};if("shapes"==g){var b=-1==h[o].indexOf("//"),w=(b?a.config.path+"shapes/":"")+h[o];m.action="add",m.url=w,m.icon=w,m.ignore=b,m["class"]="export-drawing-shape"}else"colors"==g?(m.style="background-color: "+h[o],m.action="change",m.color=h[o],m["class"]="export-drawing-color"):"widths"==g?(m.action="change",m.width=h[o],m.label=document.createElement("span"),m.label.style.width=a.numberToPx(h[o]),m.label.style.height=a.numberToPx(h[o]),m["class"]="export-drawing-width"):"opacities"==g?(m.style="opacity: "+h[o],m.action="change",m.opacity=h[o],m.label=100*h[o]+"%",m["class"]="export-drawing-opacity"):"modes"==g&&(m.label=a.i18l("menu.label.draw.modes."+h[o]),m.click=function(e){return function(){a.drawing.mode=e}}(h[o]),m["class"]="export-drawing-mode");l.menu.push(m)}}else l.click||l.menu||l.items||(a.drawing.handler[u]instanceof Function?(l.action=u,l.click=function(e){return function(){this.drawing.handler[e.action](e)}}(l)):a.drawing.buffer.enabled?l.click=function(e){return function(){this.drawing.handler.done(),this["to"+e.format](e,function(t){"download"==e.action&&this.download(t,e.mimeType,[e.fileName,e.extension].join("."))})}}(l):"UNDEFINED"!=l.format&&(l.click=function(e){return function(){if(e.capture||"print"==e.action||"PRINT"==e.format)this.capture(e,function(){this.drawing.handler.done(),this["to"+e.format](e,function(t){"download"==e.action&&this.download(t,e.mimeType,[e.fileName,e.extension].join("."))})});else{if(!this["to"+e.format])throw new Error("Invalid format. Could not determine output type.");this["to"+e.format](e,function(t){this.download(t,e.mimeType,[e.fileName,e.extension].join("."))})}}}(l)));(void 0===l.menu||l.menu.length)&&(d.setAttribute("href","#"),d.addEventListener("click",function(e,t){return function(r){r.preventDefault();var i=[r,t];return("draw"==t.action||"PRINT"==t.format||"UNDEFINED"!=t.format&&t.capture)&&!a.drawing.enabled&&(t.delay=t.delay?t.delay:a.config.delay,t.delay)?void a.delay(t,e):void e.apply(a,i)}}(l.click||function(e){e.preventDefault()},l)),c.appendChild(d),a.isElement(l.label)?f.appendChild(l.label):f.innerHTML=l.label,l["class"]&&(c.className=l["class"]),l.style&&c.setAttribute("style",l.style),l.icon&&(p.setAttribute("src",(l.ignore||-1!=l.icon.slice(0,10).indexOf("//")?"":e.pathToImages)+l.icon),d.appendChild(p)),l.label&&d.appendChild(f),l.title&&d.setAttribute("title",l.title),a.config.menuReviver&&(c=a.config.menuReviver.apply(a,[l,c])),l.elements={li:c,a:d,img:p,span:f},(l.menu||l.items)&&"draw"!=l.action?i(l.menu||l.items,c).childNodes.length&&s.appendChild(c):s.appendChild(c))}}return r.appendChild(s)}return r||("string"==typeof a.config.divId?a.config.divId=r=document.getElementById(a.config.divId):r=a.isElement(a.config.divId)?a.config.divId:a.setup.chart.containerDiv),a.isElement(a.setup.menu)?a.setup.menu.innerHTML="":a.setup.menu=document.createElement("div"),a.setup.menu.setAttribute("class",a.setup.chart.classNamePrefix+"-export-menu "+a.setup.chart.classNamePrefix+"-export-menu-"+a.config.position+" amExportButton"),a.config.menuWalker&&(i=a.config.menuWalker),i.apply(this,[t,a.setup.menu]),r.appendChild(a.setup.menu),a.setup.menu},delay:function(e,t){var r,i,n=a.deepMerge({delay:3,precision:2},e||{}),o=Number(new Date),s=a.createMenu([{label:a.i18l("capturing.delayed.menu.label").replace("{{duration}}",AmCharts.toFixed(n.delay,n.precision)),title:a.i18l("capturing.delayed.menu.title"),"class":"export-delayed-capturing",click:function(){clearTimeout(r),clearTimeout(i),a.createMenu(a.config.menu)}}]),l=s.getElementsByTagName("a")[0];r=setInterval(function(){var e=n.delay-(Number(new Date)-o)/1e3;0>=e?(clearTimeout(r),"draw"!=n.action&&a.createMenu(a.config.menu)):l&&(l.innerHTML=a.i18l("capturing.delayed.menu.label").replace("{{duration}}",AmCharts.toFixed(e,2)))},10),i=setTimeout(function(){t.apply(a,arguments)},1e3*n.delay)},migrateSetup:function(e){function t(e){var r;for(r in e){var i=e[r];"export"==r.slice(0,6)&&i?a.menu.push(r.slice(6)):"userCFG"==r?t(i):"menuItems"==r?a.menu=i:"libs"==r?a.libs=i:"string"==typeof r&&(a[r]=i)}}var a={enabled:!0,migrated:!0,libs:{autoLoad:!0},menu:[]};return t(e),a},loadListeners:function(){function e(e){e&&(e.set({top:e.top+10,left:e.left+10}),a.setup.fabric.add(e))}a.config.keyListener&&"attached"!=a.config.keyListener&&(a.config.keyListener="attached",document.addEventListener("keydown",function(t){var r=a.drawing.buffer.target;8!=t.keyCode&&46!=t.keyCode||!r?27==t.keyCode&&a.drawing.enabled?(t.preventDefault(),a.drawing.handler.done()):67==t.keyCode&&(t.metaKey||t.ctrlKey)&&r?a.drawing.buffer.copy=r:88==t.keyCode&&(t.metaKey||t.ctrlKey)&&r?(a.drawing.buffer.copy=r,a.setup.fabric.remove(r)):86==t.keyCode&&(t.metaKey||t.ctrlKey)?a.drawing.buffer.copy&&e(a.drawing.buffer.copy.clone(e)):90==t.keyCode&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),t.shiftKey?a.drawing.handler.redo():a.drawing.handler.undo()):(t.preventDefault(),a.setup.fabric.remove(r))})),a.config.fileListener&&(a.setup.chart.containerDiv.addEventListener("dragover",a.handleDropbox),a.setup.chart.containerDiv.addEventListener("dragleave",a.handleDropbox),a.setup.chart.containerDiv.addEventListener("drop",a.handleDropbox))},init:function(){clearTimeout(a.timer),a.timer=setInterval(function(){a.setup.chart.containerDiv&&(clearTimeout(a.timer),a.config.enabled&&(a.setup.chart.AmExport=a,a.setup.chart.div.style.overflow="visible",a.loadListeners(),a.createMenu(a.config.menu)))},AmCharts.updateRate)},construct:function(){a.drawing.handler.cancel=a.drawing.handler.done;try{a.setup.hasBlob=!!new Blob}catch(e){}window.safari=window.safari?window.safari:{},a.defaults.fabric.drawing.fontSize=a.setup.chart.fontSize||11,a.config.drawing=a.deepMerge(a.defaults.fabric.drawing,a.config.drawing||{},!0),a.deepMerge(a.defaults.fabric,a.config,!0),a.deepMerge(a.defaults.fabric,a.config.fabric||{},!0),a.deepMerge(a.defaults.pdfMake,a.config,!0),a.deepMerge(a.defaults.pdfMake,a.config.pdfMake||{},!0),a.deepMerge(a.libs,a.config.libs||{},!0),a.config.drawing=a.defaults.fabric.drawing,a.config.fabric=a.defaults.fabric,a.config.pdfMake=a.defaults.pdfMake,a.config=a.deepMerge(a.defaults,a.config,!0),a.config.fabric.drawing.enabled&&void 0===a.config.fabric.drawing.menu&&(a.config.fabric.drawing.menu=[],a.deepMerge(a.config.fabric.drawing.menu,[{"class":"export-drawing",menu:[{label:a.i18l("menu.label.draw.add"),menu:[{label:a.i18l("menu.label.draw.shapes"),action:"draw.shapes"},{label:a.i18l("menu.label.draw.text"),action:"text"}]},{label:a.i18l("menu.label.draw.change"),menu:[{label:a.i18l("menu.label.draw.modes"),action:"draw.modes"},{label:a.i18l("menu.label.draw.colors"),action:"draw.colors"},{label:a.i18l("menu.label.draw.widths"),action:"draw.widths"},{label:a.i18l("menu.label.draw.opacities"),action:"draw.opacities"},"UNDO","REDO"]},{label:a.i18l("menu.label.save.image"),menu:["PNG","JPG","SVG","PDF"]},"PRINT","CANCEL"]}])),void 0===a.config.menu&&(a.config.menu=[],a.deepMerge(a.config,{menu:[{"class":"export-main",menu:[{label:a.i18l("menu.label.save.image"),menu:["PNG","JPG","SVG","PDF"]},{label:a.i18l("menu.label.save.data"),menu:["CSV","XLSX","JSON"]},{label:a.i18l("menu.label.draw"),action:"draw",menu:a.config.fabric.drawing.menu},{format:"PRINT",label:a.i18l("menu.label.print")}]}]})),a.libs.path||(a.libs.path=a.config.path+"libs/"),a.isSupported()&&(a.loadDependencies(a.libs.resources,a.libs.reload),a.setup.chart.addClassNames=!0,a.setup.chart[a.name]=a,a.init())}};if(t)a.config=t;else if(a.setup.chart[a.name])a.config=a.setup.chart[a.name];else{if(!a.setup.chart.amExport&&!a.setup.chart.exportConfig)return;a.config=a.migrateSetup(a.setup.chart.amExport||a.setup.chart.exportConfig)}return a.construct(),a.deepMerge(this,a)}}(),AmCharts.addInitHandler(function(e){new AmCharts.export(e)},["pie","serial","xy","funnel","radar","gauge","stock","map","gantt"]);