1 | class e{init(e,t,r){this.enabled=!0,this.polygonFirstPoint=!1,this.offscreenCanvas=document.createElement("CANVAS"),this.offscreenContext=this.offscreenCanvas.getContext("2d"),this.update=e,this.mainCanvas=t,this.mainCanvas.font="Roboto Condensed",this.mainCanvas.textAlign="left",this.mainCanvas.textBaseline="top",this.context=t.getContext("2d"),this.log=r,this.updateCanvasSize(),this.prevUpdateHash=""}canvas(){return this.mainCanvas}dc(){return this.offscreenContext}clientRect(){return this.mainCanvas.getBoundingClientRect()}frameBegin(){this.currentLineWidth=1,this.offscreenContext.clearRect(-1,-1,this.mainCanvas.width+1,this.mainCanvas.height+1)}frameEnd(){this.context.clearRect(-1,-1,this.mainCanvas.width+1,this.mainCanvas.height+1),this.context.drawImage(this.offscreenCanvas,0,0)}lineWidthNotification(e){this.currentLineWidth=e}noneZeroLineWidth(){return 0!==this.currentLineWidth}startPolygonNotification(){var e=this.polygonFirstPoint;return this.polygonFirstPoint=!0,!e}endPolygonNotification(){this.polygonFirstPoint=!1}updateCanvasSize(){this.scaleFactor=window.devicePixelRatio,this.cssWidth=+getComputedStyle(this.mainCanvas).width.slice(0,-2),this.cssHeight=+getComputedStyle(this.mainCanvas).height.slice(0,-2);let e=`${this.scaleFactor}:${this.cssWidth}:${this.cssHeight}`;e!==this.prevUpdateHash&&(this.mainCanvas.width=this.cssWidth*this.scaleFactor,this.mainCanvas.height=this.cssHeight*this.scaleFactor,this.offscreenCanvas.width=this.cssWidth*this.scaleFactor,this.offscreenCanvas.height=this.cssHeight*this.scaleFactor,this.offscreenContext.translate(.5,.5),this.offscreenContext.scale(this.scaleFactor,this.scaleFactor)),this.prevUpdateHash=e}updateFrame(e){var t=performance.now();if(this.updateCanvasSize(),this.mainCanvas.width>0&&this.mainCanvas.height>0){let t=this.enabled?e?1:0:2;this.update(this.cssWidth,this.cssHeight,t)}var r=performance.now()-t;this.log&&r>1&&console.log("Render.updateFrame: "+r.toFixed(2)+"ms")}}class t{constructor(e){this.vizzu=e,this.module=e.module,this.eventHandlers=new Map}add(e,t){if(e!==""+e)throw new Error("first parameter should be string");let r=this.vizzu.toCString(e);try{let e=this.vizzu.call(this.module._addEventListener)(r);this.eventHandlers.set(e,t)}finally{this.module._free(r)}}remove(e,t){let r=this.vizzu.toCString(e);if(e!==""+e)throw new Error("first parameter should be string");try{if(t){let e=null;if(this.eventHandlers.forEach(((r,n)=>{r===t&&(e=n)})),null===e)throw new Error("unknown event handler");this.vizzu.call(this.module._removeEventListener)(r,e)}else this.vizzu.call(this.module._removeEventListener)(r,0)}finally{this.eventHandlers.delete(t),this.module._free(r)}}invoke(e,t){try{if(this.eventHandlers.has(e)){let r=JSON.parse(this.vizzu.fromCString(t));r.preventDefault=()=>{this.vizzu.call(this.module._event_preventDefault)()},r.event.endsWith("-draw")&&(r.renderingContext=this.vizzu.render.dc()),this.eventHandlers.get(e)(r)}}catch(e){console.log("exception in event handler: "+e)}}}const r=(e,t)=>{if(!e)throw new Error("Assert failed: "+t)},n=(e,t,i)=>{r(Array.isArray(t),"array is not a list");try{if(t.length!==e.dimensions[i].values.length)throw new Error("Assert failed")}catch(e){r(!1,"dimensions are not the same")}t.forEach((t=>{Array.isArray(t)&&n(e,t,i-1)}))};class i{static isPivot(e){return void 0!==e?.dimensions||void 0!==e?.measures}static convert(e){r("object"==typeof e&&null!==e&&!Array.isArray(e),"data is not an object"),r("dimensions"in e,"data.dimensions is requreid"),r("measures"in e,"data.measures is requreid"),e.series=[];let t=1;r(Array.isArray(e.dimensions),"data.dimensions is not a list");for(let n=0;n<e.dimensions.length;n++){let i=e.dimensions[n];r("object"==typeof i&&null!==i&&!Array.isArray(i),"data.dimensions.item is not an object"),r("name"in i,"data.dimensions.item.name is requreid"),r(void 0===i.type||"dimension"===i.type,"data.dimensions.item.type is invalid"),r("values"in i,"data.dimensions.item.values is requreid"),r(Array.isArray(i.values),"data.dimensions.item.values is not a list"),r(0!==i.values.length,"data.dimensions.item.values length is zero"),t*=i.values.length}let i=1;for(let r=0;r<e.dimensions.length;r++){let n=e.dimensions[r],a=[],s=[];n.values.forEach((e=>{for(let t=1;t<=i;t++)s.push(e)})),i*=n.values.length;for(let e=1;e<=t/i;e++)a=a.concat(s);let o={name:n.name,type:n.type||"dimension",values:a};e.series.push(o)}r("object"==typeof e.measures&&null!==e.measures,"data.measures is not a list or an object"),Array.isArray(e.measures)||(e.measures=[e.measures]);for(let i=0;i<e.measures.length;i++){let a=e.measures[i];r("object"==typeof a&&null!==a&&!Array.isArray(a),"data.measures.item is not an object"),r("name"in a,"data.measures.item.name is requreid"),r("values"in a,"data.measures.item.values is requreid"),r(Array.isArray(a.values),"data.measures.item.values is not a list"),n(e,a.values,e.dimensions.length-1);let s={name:a.name,type:a.type,values:a.values.flat(1/0)};void 0===s.type&&delete s.type,r(s.values.length===t,"dimensions are not the same"),e.series.push(s)}}}class a{constructor(e,t){return this.chart=e,this.record=t,new Proxy(this,{get:(e,t)=>e.getValue(t)})}getValue(e){let t,r,n=this.chart.toCString(e);try{t=this.chart.call(this.chart.module._record_getValue)(this.record,n,!0),t?r=this.chart.fromCString(t):(t=this.chart.call(this.chart.module._record_getValue)(this.record,n,!1),r=this.chart.module.getValue(t,"double"))}finally{this.chart.module._free(n)}return r}}class s{constructor(e){this.chart=e}set(e){if(e){if(i.isPivot(e)){if(this.is1NF(e))throw new Error("inconsistent data form: series/records and dimensions/measures are both set.");i.convert(e)}if(e.series){if(!Array.isArray(e.series))throw new Error("data series field is not an array");for(const t of e.series)this.setSeries(t)}if(e.records){if(!Array.isArray(e.records))throw new Error("data records field is not an array");for(const t of e.records)this.addRecord(t)}(e.filter||null===e.filter)&&this.setFilter(e.filter)}}addRecord(e){if(!Array.isArray(e))throw new Error("data record is not an array");let t=new Uint32Array(e.length);for(let r=0;r<e.length;r++){let n=this.chart.toCString(String(e[r]).toString());t[r]=n}let r=4*e.length,n=this.chart.module._malloc(r);new Uint8Array(this.chart.module.HEAPU8.buffer,n,r).set(new Uint8Array(t.buffer));try{this.chart.call(this.chart.module._data_addRecord)(n,e.length)}finally{for(let e of t)this.chart.module._free(e);this.chart.module._free(n)}}setSeries(e){if(!e.name)throw new Error("missing series name");if(e.values||(e.values=[]),e.type||(e.type=this.detectType(e.values)),"dimension"===e.type)this.addDimension(e.name,e.values);else{if("measure"!==e.type)throw new Error("invalid series type: "+e.type);this.addMeasure(e.name,e.values)}}detectType(e){if(Array.isArray(e)&&e.length){if("number"==typeof e[0])return"measure";if(e[0]===""+e[0])return"dimension"}return null}addDimension(e,t){if("string"!=typeof e&&!(e instanceof String))throw new Error("first parameter should be string");if(!(t instanceof Array))throw new Error("second parameter should be an array");let r=new Uint32Array(t.length);for(let e=0;e<t.length;e++){if("string"!=typeof t[e]&&!(t[e]instanceof String))throw new Error("array element should be string");let n=this.chart.toCString(t[e]);r[e]=n}let n=4*t.length,i=this.chart.module._malloc(n);new Uint8Array(this.chart.module.HEAPU8.buffer,i,n).set(new Uint8Array(r.buffer));let a=this.chart.toCString(e);try{this.chart.call(this.chart.module._data_addDimension)(a,i,t.length)}finally{this.chart.module._free(a);for(let e of r)this.chart.module._free(e);this.chart.module._free(i)}}addMeasure(e,t){if("string"!=typeof e&&!(e instanceof String))throw new Error("first parameter should be string");if(!(t instanceof Array))throw new Error("second parameter should be an array");let r=new Float64Array(t),n=8*t.length,i=this.chart.module._malloc(n);new Uint8Array(this.chart.module.HEAPU8.buffer,i,n).set(new Uint8Array(r.buffer));let a=this.chart.toCString(e);try{this.chart.call(this.chart.module._data_addMeasure)(a,i,t.length)}finally{this.chart.module._free(a),this.chart.module._free(i)}}setFilter(e){if("function"==typeof e){let t=t=>e(new a(this.chart,t)),r=this.chart.module.addFunction(t,"ii");this.chart.call(this.chart.module._chart_setFilter)(r)}else{if(null!==e)throw new Error("data filter is not a function or null");this.chart.call(this.chart.module._chart_setFilter)(0)}}is1NF(e){return e.series||e.records}}class o extends Promise{constructor(e,t){super(((t,r)=>{e(t,r)})),this.chart=t}then(e,t){const r=super.then(e,t);return r.chart=this.chart,r}get[Symbol.toStringTag](){return"AnimControl"}seek(e){return this.animControl("seek",e),this}pause(){return this.animControl("pause"),this}play(){return this.animControl("play"),this}stop(){return this.animControl("stop"),this}cancel(){return this.animControl("cancel"),this}reverse(){return this.animControl("reverse"),this}animControl(e,t=""){let r=this.chart.toCString(e),n=this.chart.toCString(t);try{this.chart.call(this.chart.module._anim_control)(r,n)}finally{this.chart.module._free(n),this.chart.module._free(r)}}}class l{constructor(e){this.set=!1,this.chart=e,this.id=0,this.animating=!1,this.lastMarkerId=null,this.lastMove=new Date,this.mouseMoveHandler=e=>{this.mousemove(e)},this.mouseOnHandler=e=>{this.mouseon(e)},this.enabled=!1}enable(e){e!==this.set&&(e?(this.chart.on("mousemove",this.mouseMoveHandler),this.chart.on("mouseon",this.mouseOnHandler)):(this.chart.off("mousemove",this.mouseMoveHandler),this.chart.off("mouseon",this.mouseOnHandler),this.id++,setTimeout((()=>{this.out(this.id)}),200)),this.set=e)}mousemove(){this.lastMove=new Date}mouseon(e){this.id++;let t=this.id;e.data.marker?setTimeout((()=>{this.in(t,e.data.marker.id)}),0):setTimeout((()=>{this.out(t)}),200)}in(e,t){this.id===e&&(this.animating?setTimeout((()=>{this.in(e,t)}),100):(this.lastMarkerId=t,this.animating=!0,this.chart.animate({config:{tooltip:t}},this.lastMarkerId?"100ms":"250ms").then((()=>{this.animating=!1}))))}out(e){if(this.id===e){let t=new Date-this.lastMove;!this.animating&&t>200?(this.lastMarkerId=null,this.animating=!0,this.chart.animate({config:{tooltip:null}},"250ms").then((()=>{this.animating=!1}))):setTimeout((()=>{this.out(e)}),200-t)}}}class u{constructor(e){this._presetConfigs={column:{channels:{x:"x",y:"y",label:"y"}},groupedColumn:{channels:{x:["groupedBy","x"],y:"y",label:"y",color:"x"}},stackedColumn:{channels:{x:"x",y:["y","stackedBy"],label:"y",color:"stackedBy"}},splittedColumn:{channels:{x:"x",y:["y","splittedBy"],color:"splittedBy",label:"y"},split:!0},percentageColumn:{channels:{x:"x",y:["y","stackedBy"],color:"stackedBy",label:"y"},align:"stretch"},waterfall:{channels:{x:"x",y:["y","x"],label:"y",color:"y"},align:"stretch"},mekko:{channels:{x:["x","groupedBy"],y:["y","stackedBy"],color:"stackedBy",label:"groupedBy"}},marimekko:{channels:{x:["x","groupedBy"],y:["y","stackedBy"],color:"stackedBy",label:"groupedBy"},align:"stretch",orientation:"horizontal"},bar:{channels:{x:"x",y:"y",label:"x"}},groupedBar:{channels:{x:"x",y:["groupedBy","y"],label:"x",color:"y"}},stackedBar:{channels:{x:["x","stackedBy"],y:"y",label:"x",color:"stackedBy"}},splittedBar:{channels:{x:["x","splittedBy"],y:"y",color:"splittedBy",label:"x"},split:!0},percentageBar:{channels:{x:["x","stackedBy"],y:"y",color:"stackedBy",label:"x"},align:"stretch"},lollipop:{channels:{x:"x",y:"y",label:"y"},geometry:"circle"},scatter:{channels:{x:"x",y:"y",noop:"dividedBy"},geometry:"circle"},bubbleplot:{channels:{x:"x",y:"y",color:"color",size:"size",label:"dividedBy",noop:"dividedBy"},geometry:"circle"},area:{channels:{x:"x",y:"y"},geometry:"area"},stackedArea:{channels:{x:"x",y:["y","stackedBy"],color:"stackedBy"},geometry:"area"},percentageArea:{channels:{x:"x",y:["y","stackedBy"],color:"stackedBy"},align:"stretch",geometry:"area"},splittedArea:{channels:{x:"x",y:["y","splittedBy"],color:"splittedBy"},split:!0,geometry:"area"},stream:{channels:{x:"x",y:["y","stackedBy"],color:"stackedBy"},geometry:"area",align:"center"},verticalStream:{channels:{x:["x","stackedBy"],y:"y",color:"stackedBy"},geometry:"area",align:"center"},violin:{channels:{x:"x",y:["y","splittedBy"],color:"splittedBy"},geometry:"area",align:"center",split:!0},verticalViolin:{channels:{x:["x","splittedBy"],y:"y",color:"splittedBy"},geometry:"area",align:"center",split:!0},line:{channels:{x:"x",y:"y",color:"dividedBy"},geometry:"line"},verticalLine:{channels:{x:"x",y:"y",color:"dividedBy"},geometry:"line"},pie:{channels:{x:["angle","by"],color:"by",label:"angle"},coordSystem:"polar"},polarColumn:{channels:{x:"angle",y:"radius",label:"radius"},coordSystem:"polar"},polarStackedColumn:{channels:{x:"angle",y:["radius","stackedBy"],color:"stackedBy"},coordSystem:"polar"},variableRadiusPie:{channels:{x:["angle","by"],y:"radius",color:"by",label:"radius"},coordSystem:"polar"},radialBar:{channels:{x:"angle",y:{set:"radius",range:{min:"-50%"}},label:"angle"},coordSystem:"polar"},radialStackedBar:{channels:{x:["angle","stackedBy"],y:{set:"radius",range:{min:"-50%"}},color:"stackedBy",label:"angle"},coordSystem:"polar"},donut:{channels:{x:["angle","stackedBy"],y:{range:{min:"-200%",max:"100%"}},color:"stackedBy"},coordSystem:"polar"},nestedDonut:{channels:{x:["angle","stackedBy"],y:{set:"radius",range:{min:"-50%"}},color:"stackedBy",label:"angle"},coordSystem:"polar",align:"stretch"},polarScatter:{channels:{x:"angle",y:"radius",noop:"dividedBy"},coordSystem:"polar",geometry:"circle"},polarLine:{channels:{x:"angle",y:"radius",color:"dividedBy"},coordSystem:"polar",geometry:"line"},treemap:{channels:{size:["size","color"],color:"color",label:"color"}},stackedTreemap:{channels:{size:["size","dividedBy"],color:"color",label:"dividedBy",lightness:"size"}},heatmap:{channels:{x:"x",y:"y",lightness:"lightness"}},bubble:{channels:{size:"size",color:"color",label:"color"},geometry:"circle"},stackedBubble:{channels:{size:["size","stackedBy"],color:"color"},geometry:"circle"}};for(let e in this._presetConfigs)this._initPresetConfigChannels(this._presetConfigs[e].channels),this[e]=t=>this._buildPresetConfig(e,t)}_initPresetConfigChannels(e){for(let t in e)("object"!=typeof e[t]||Array.isArray(e[t]))&&(e[t]={set:e[t]})}_nullConfig(){return{align:"none",coordSystem:"cartesian",orientation:"horizontal",rotate:0,split:!1,geometry:"rectangle",channels:{x:null,y:null,color:null,lightness:null,size:null,noop:null,label:null}}}_createPresetConfig(e){let t=this._presetConfigs[e],r=this._nullConfig(),n=Object.assign(r.channels,t.channels),i=Object.assign(this._nullConfig(),t);return i.channels=n,i}_getChannelCopy(e){return null==e?null:(Array.isArray(e)&&e.map((e=>e)),[e])}_fillChannels(e,t){if(!t)return;let r=e.channels;for(let e in r)if(null!==r[e])if("string"==typeof r[e].set)r[e].set=this._getChannelCopy(t[r[e].set]);else if(Array.isArray(r[e].set)){let n=[];for(let i=0;i<r[e].set.length;i++){let a=this._getChannelCopy(t[r[e].set[i]]);null!==a&&n.push(a)}r[e].set=n.length>0?n.flat():null}}_setupUserParams(e,t){["legend","title","reverse","sort"].forEach((r=>{void 0!==t[r]&&(e[r]=t[r])}))}_buildPresetConfig(e,t){let r=this._createPresetConfig(e);return this._fillChannels(r,t),this._setupUserParams(r,t),r}}var c,h=(c=import.meta.url,function(e){var t,r,n=void 0!==(e=e||{})?e:{};n.ready=new Promise((function(e,n){t=e,r=n}));var i,a={};for(i in n)n.hasOwnProperty(i)&&(a[i]=n[i]);var s="";document.currentScript&&(s=document.currentScript.src),c&&(s=c),s=0!==s.indexOf("blob:")?s.substr(0,s.lastIndexOf("/")+1):"";var o=console.log.bind(console),l=console.warn.bind(console);for(i in a)a.hasOwnProperty(i)&&(n[i]=a[i]);a=null;var u,h,d=[];function f(e,t){var r,n=p;if(!u){u=new WeakMap;for(var i=0;i<n.length;i++){var a=n.get(i);a&&u.set(a,i)}}if(u.has(e))return u.get(e);if(d.length)r=d.pop();else{r=n.length;try{n.grow(1)}catch(e){if(!(e instanceof RangeError))throw e;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."}}try{n.set(r,e)}catch(i){if(!(i instanceof TypeError))throw i;var s=function(e,t){if("function"==typeof WebAssembly.Function){for(var r={i:"i32",j:"i64",f:"f32",d:"f64"},n={parameters:[],results:"v"==t[0]?[]:[r[t[0]]]},i=1;i<t.length;++i)n.parameters.push(r[t[i]]);return new WebAssembly.Function(n,e)}var a=[1,0,1,96],s=t.slice(0,1),o=t.slice(1),l={i:127,j:126,f:125,d:124};for(a.push(o.length),i=0;i<o.length;++i)a.push(l[o[i]]);"v"==s?a.push(0):a=a.concat([1,l[s]]),a[1]=a.length-2;var u=new Uint8Array([0,97,115,109,1,0,0,0].concat(a,[2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0])),c=new WebAssembly.Module(u);return new WebAssembly.Instance(c,{e:{f:e}}).exports.f}(e,t);n.set(r,s)}return u.set(e,r),r}function m(e,t,r,n){switch("*"===(r=r||"i8").charAt(r.length-1)&&(r="i32"),r){case"i1":case"i8":A[e>>0]=t;break;case"i16":x[e>>1]=t;break;case"i32":S[e>>2]=t;break;case"i64":te=[t>>>0,(ee=t,+q(ee)>=1?ee>0?(0|$(+Z(ee/4294967296),4294967295))>>>0:~~+J((ee-+(~~ee>>>0))/4294967296)>>>0:0)],S[e>>2]=te[0],S[e+4>>2]=te[1];break;case"float":B[e>>2]=t;break;case"double":P[e>>3]=t;break;default:G("invalid type for setValue: "+r)}}function y(e,t,r){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return A[e>>0];case"i16":return x[e>>1];case"i32":case"i64":return S[e>>2];case"float":return B[e>>2];case"double":return P[e>>3];default:G("invalid type for getValue: "+t)}return null}"object"!=typeof WebAssembly&&G("no native wasm support detected");var p=new WebAssembly.Table({initial:1183,element:"anyfunc"}),g=!1,v="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function _(e,t,r){for(var n=t+r,i=t;e[i]&&!(i>=n);)++i;if(i-t>16&&e.subarray&&v)return v.decode(e.subarray(t,i));for(var a="";t<i;){var s=e[t++];if(128&s){var o=63&e[t++];if(192!=(224&s)){var l=63&e[t++];if((s=224==(240&s)?(15&s)<<12|o<<6|l:(7&s)<<18|o<<12|l<<6|63&e[t++])<65536)a+=String.fromCharCode(s);else{var u=s-65536;a+=String.fromCharCode(55296|u>>10,56320|1023&u)}}else a+=String.fromCharCode((31&s)<<6|o)}else a+=String.fromCharCode(s)}return a}function b(e,t){return e?_(z,e,t):""}function w(e,t,r){return function(e,t,r,n){if(!(n>0))return 0;for(var i=r,a=r+n-1,s=0;s<e.length;++s){var o=e.charCodeAt(s);if(o>=55296&&o<=57343&&(o=65536+((1023&o)<<10)|1023&e.charCodeAt(++s)),o<=127){if(r>=a)break;t[r++]=o}else if(o<=2047){if(r+1>=a)break;t[r++]=192|o>>6,t[r++]=128|63&o}else if(o<=65535){if(r+2>=a)break;t[r++]=224|o>>12,t[r++]=128|o>>6&63,t[r++]=128|63&o}else{if(r+3>=a)break;t[r++]=240|o>>18,t[r++]=128|o>>12&63,t[r++]=128|o>>6&63,t[r++]=128|63&o}}return t[r]=0,r-i}(e,z,t,r)}var C,A,z,x,k,S,E,B,P,T="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function F(e,t){for(var r=e,n=r>>1,i=n+t/2;!(n>=i)&&k[n];)++n;if((r=n<<1)-e>32&&T)return T.decode(z.subarray(e,r));for(var a=0,s="";;){var o=x[e+2*a>>1];if(0==o||a==t/2)return s;++a,s+=String.fromCharCode(o)}}function W(e,t,r){if(void 0===r&&(r=2147483647),r<2)return 0;for(var n=t,i=(r-=2)<2*e.length?r/2:e.length,a=0;a<i;++a){var s=e.charCodeAt(a);x[t>>1]=s,t+=2}return x[t>>1]=0,t-n}function O(e){return 2*e.length}function M(e,t){for(var r=0,n="";!(r>=t/4);){var i=S[e+4*r>>2];if(0==i)break;if(++r,i>=65536){var a=i-65536;n+=String.fromCharCode(55296|a>>10,56320|1023&a)}else n+=String.fromCharCode(i)}return n}function U(e,t,r){if(void 0===r&&(r=2147483647),r<4)return 0;for(var n=t,i=n+r-4,a=0;a<e.length;++a){var s=e.charCodeAt(a);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++a)),S[t>>2]=s,(t+=4)+4>i)break}return S[t>>2]=0,t-n}function L(e){for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n>=55296&&n<=57343&&++r,t+=4}return t}function V(e){C=e,n.HEAP8=A=new Int8Array(e),n.HEAP16=x=new Int16Array(e),n.HEAP32=S=new Int32Array(e),n.HEAPU8=z=new Uint8Array(e),n.HEAPU16=k=new Uint16Array(e),n.HEAPU32=E=new Uint32Array(e),n.HEAPF32=B=new Float32Array(e),n.HEAPF64=P=new Float64Array(e)}var H=16777216;function j(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var r=t.func;"number"==typeof r?void 0===t.arg?n.dynCall_v(r):n.dynCall_vi(r,t.arg):r(void 0===t.arg?null:t.arg)}else t(n)}}(h=new WebAssembly.Memory({initial:H/65536,maximum:32768}))&&(C=h.buffer),H=C.byteLength,V(C),S[14788]=5302192;var D=[],I=[],R=[],N=[],q=Math.abs,J=Math.ceil,Z=Math.floor,$=Math.min,K=0,Y=null;function G(e){l(e+=""),g=!0,e="abort("+e+"). Build with -s ASSERTIONS=1 for more info.";var t=new WebAssembly.RuntimeError(e);throw r(t),t}function X(e){return t=e,r="data:application/octet-stream;base64,",String.prototype.startsWith?t.startsWith(r):0===t.indexOf(r);var t,r}n.preloadedImages={},n.preloadedAudios={};var Q,ee,te,re="cvizzu.wasm";function ne(){try{throw"both async and sync fetching of the wasm failed"}catch(e){G(e)}}function ie(){return ie.uncaught_exceptions>0}function ae(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+e)}}X(re)||(Q=re,re=n.locateFile?n.locateFile(Q,s):s+Q),I.push({func:function(){ke()}});var se=void 0;function oe(e){for(var t="",r=e;z[r];)t+=se[z[r++]];return t}var le={},ue={};function ce(e,t){var r,n,i=(n=function(e){this.name=t,this.message=e;var r=new Error(e).stack;void 0!==r&&(this.stack=this.toString()+"\n"+r.replace(/^Error(:[^\n]*)?\n/,""))},r=function(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=48&&t<=57?"_"+e:e}(r=t),new Function("body","return function "+r+'() {\n "use strict"; return body.apply(this, arguments);\n};\n')(n));return i.prototype=Object.create(e.prototype),i.prototype.constructor=i,i.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},i}var he=void 0;function de(e){throw new he(e)}function fe(e,t,r){if(r=r||{},!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");var n=t.name;if(e||de('type "'+n+'" must have a positive integer typeid pointer'),ue.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;de("Cannot register type '"+n+"' twice")}if(ue[e]=t,le.hasOwnProperty(e)){var i=le[e];delete le[e],i.forEach((function(e){e()}))}}var me,ye=[],pe=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function ge(){for(var e=0,t=5;t<pe.length;++t)void 0!==pe[t]&&++e;return e}function ve(){for(var e=5;e<pe.length;++e)if(void 0!==pe[e])return pe[e];return null}function _e(e){return this.fromWireType(E[e>>2])}function be(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function we(e,t){switch(t){case 2:return function(e){return this.fromWireType(B[e>>2])};case 3:return function(e){return this.fromWireType(P[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Ce(e,t,r){switch(t){case 0:return r?function(e){return A[e]}:function(e){return z[e]};case 1:return r?function(e){return x[e>>1]}:function(e){return k[e>>1]};case 2:return r?function(e){return S[e>>2]}:function(e){return E[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}function Ae(e){try{return h.grow(e-C.byteLength+65535>>>16),V(h.buffer),1}catch(e){}}me=function(){return performance.now()};var ze={mappings:{},buffers:[null,[],[]],printChar:function(e,t){var r=ze.buffers[e];0===t||10===t?((1===e?o:l)(_(r,0)),r.length=0):r.push(t)},varargs:void 0,get:function(){return ze.varargs+=4,S[ze.varargs-4>>2]},getStr:function(e){return b(e)},get64:function(e,t){return e}};!function(){for(var e=new Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);se=e}(),he=n.BindingError=ce(Error,"BindingError"),n.InternalError=ce(Error,"InternalError"),n.count_emval_handles=ge,n.get_first_emval=ve;var xe={a:function(e){return Ee(e)},b:function(e,t,r){throw"uncaught_exception"in ie?ie.uncaught_exceptions++:ie.uncaught_exceptions=1,e},x:function(e,t,r,n,i){var a=ae(r);fe(e,{name:t=oe(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?n:i},argPackAdvance:8,readValueFromPointer:function(e){var n;if(1===r)n=A;else if(2===r)n=x;else{if(4!==r)throw new TypeError("Unknown boolean type size: "+t);n=S}return this.fromWireType(n[e>>a])},destructorFunction:null})},v:function(e,t){fe(e,{name:t=oe(t),fromWireType:function(e){var t=pe[e].value;return function(e){e>4&&0==--pe[e].refcount&&(pe[e]=void 0,ye.push(e))}(e),t},toWireType:function(e,t){return function(e){switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var t=ye.length?ye.pop():pe.length;return pe[t]={refcount:1,value:e},t}}(t)},argPackAdvance:8,readValueFromPointer:_e,destructorFunction:null})},h:function(e,t,r){var n=ae(r);fe(e,{name:t=oe(t),fromWireType:function(e){return e},toWireType:function(e,t){if("number"!=typeof t&&"boolean"!=typeof t)throw new TypeError('Cannot convert "'+be(t)+'" to '+this.name);return t},argPackAdvance:8,readValueFromPointer:we(t,n),destructorFunction:null})},d:function(e,t,r,n,i){t=oe(t),-1===i&&(i=4294967295);var a=ae(r),s=function(e){return e};if(0===n){var o=32-8*r;s=function(e){return e<<o>>>o}}var l=-1!=t.indexOf("unsigned");fe(e,{name:t,fromWireType:s,toWireType:function(e,r){if("number"!=typeof r&&"boolean"!=typeof r)throw new TypeError('Cannot convert "'+be(r)+'" to '+this.name);if(r<n||r>i)throw new TypeError('Passing a number "'+be(r)+'" from JS side to C/C++ side to an argument of type "'+t+'", which is outside the valid range ['+n+", "+i+"]!");return l?r>>>0:0|r},argPackAdvance:8,readValueFromPointer:Ce(t,a,0!==n),destructorFunction:null})},c:function(e,t,r){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function i(e){var t=E,r=t[e>>=2],i=t[e+1];return new n(C,i,r)}fe(e,{name:r=oe(r),fromWireType:i,argPackAdvance:8,readValueFromPointer:i},{ignoreDuplicateRegistrations:!0})},i:function(e,t){var r="std::string"===(t=oe(t));fe(e,{name:t,fromWireType:function(e){var t,n=E[e>>2];if(r)for(var i=e+4,a=0;a<=n;++a){var s=e+4+a;if(a==n||0==z[s]){var o=b(i,s-i);void 0===t?t=o:(t+=String.fromCharCode(0),t+=o),i=s+1}}else{var l=new Array(n);for(a=0;a<n;++a)l[a]=String.fromCharCode(z[e+4+a]);t=l.join("")}return Be(e),t},toWireType:function(e,t){var n;t instanceof ArrayBuffer&&(t=new Uint8Array(t));var i="string"==typeof t;i||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||de("Cannot pass non-string to std::string"),n=r&&i?function(){return function(e){for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n>=55296&&n<=57343&&(n=65536+((1023&n)<<10)|1023&e.charCodeAt(++r)),n<=127?++t:t+=n<=2047?2:n<=65535?3:4}return t}(t)}:function(){return t.length};var a=n(),s=Ee(4+a+1);if(E[s>>2]=a,r&&i)w(t,s+4,a+1);else if(i)for(var o=0;o<a;++o){var l=t.charCodeAt(o);l>255&&(Be(s),de("String has UTF-16 code units that do not fit in 8 bits")),z[s+4+o]=l}else for(o=0;o<a;++o)z[s+4+o]=t[o];return null!==e&&e.push(Be,s),s},argPackAdvance:8,readValueFromPointer:_e,destructorFunction:function(e){Be(e)}})},f:function(e,t,r){var n,i,a,s,o;r=oe(r),2===t?(n=F,i=W,s=O,a=function(){return k},o=1):4===t&&(n=M,i=U,s=L,a=function(){return E},o=2),fe(e,{name:r,fromWireType:function(e){for(var r,i=E[e>>2],s=a(),l=e+4,u=0;u<=i;++u){var c=e+4+u*t;if(u==i||0==s[c>>o]){var h=n(l,c-l);void 0===r?r=h:(r+=String.fromCharCode(0),r+=h),l=c+t}}return Be(e),r},toWireType:function(e,n){"string"!=typeof n&&de("Cannot pass non-string to C++ string type "+r);var a=s(n),l=Ee(4+a+t);return E[l>>2]=a>>o,i(n,l+4,a+t),null!==e&&e.push(Be,l),l},argPackAdvance:8,readValueFromPointer:_e,destructorFunction:function(e){Be(e)}})},y:function(e,t){fe(e,{isVoid:!0,name:t=oe(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})},e:function(){G()},L:function(e,t,r,i,a,s){n.render.dc().bezierCurveTo(e,t,r,i,a,s)},M:function(e,t){var r=n.render.dc();n.render.startPolygonNotification()?r.moveTo(e,t):r.lineTo(e,t)},T:function(){},N:function(){n.render.dc().beginPath()},I:function(e,t,r){var i=n.render.dc();i.beginPath(),i.arc(e,t,r,0,6.28318530718),i.fill(),n.render.noneZeroLineWidth()&&i.stroke()},E:function(e,t,r,n,i,a){},P:function(){let e=n.render.dc();e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowColor="rgba(0, 0, 0, 0)"},K:function(){var e=n.render.dc();e.closePath(),e.fill(),n.render.noneZeroLineWidth()&&e.stroke(),n.render.endPolygonNotification()},C:function(){n.render.frameBegin()},k:function(){n.render.frameEnd()},H:function(e,t,r,i){var a=n.render.dc();a.beginPath(),a.moveTo(e,t),a.lineTo(r,i),n.render.noneZeroLineWidth()&&a.stroke()},J:function(e,t,r,i){var a=n.render.dc();a.beginPath(),a.rect(e,t,r,i),a.fill(),n.render.noneZeroLineWidth()&&a.stroke()},z:function(){n.render.dc().restore()},A:function(){n.render.dc().save()},X:function(e,t,r,i){n.render.dc().fillStyle="rgba("+255*e+","+255*t+","+255*r+","+i+")"},F:function(e,t,r,i,a,s){for(var o=n.render.dc(),l=o.createLinearGradient(e,t,r,i),u=0;u<40*a;u+=40)l.addColorStop(y(s+u,"double"),"rgba("+255*y(s+u+8,"double")+","+255*y(s+u+16,"double")+","+255*y(s+u+24,"double")+","+y(s+u+32,"double")+")");o.fillStyle=l},l:function(e,t,r){var i=n.render.dc();i.beginPath(),i.arc(e,t,r,0,6.28318530718),i.clip()},Y:function(){var e=n.render.dc();e.closePath(),e.clip(),n.render.endPolygonNotification()},m:function(e,t,r,i){var a=n.render.dc();a.beginPath(),a.rect(e,t,r,i),a.clip()},S:function(e){n.render.dc().shadowBlur=e},R:function(e,t,r,i){n.render.dc().shadowColor="rgba("+255*e+","+255*t+","+255*r+","+i+")"},Q:function(e,t){let r=n.render.dc();r.shadowOffsetX=e,r.shadowOffsetY=t},U:function(e){n.render.dc().font=b(e)},W:function(e,t,r,i){n.render.dc().strokeStyle="rgba("+255*e+","+255*t+","+255*r+","+i+")"},V:function(e){n.render.dc().lineWidth=e,n.render.lineWidthNotification(e)},G:function(e,t,r,i,a){var s=n.render.dc();s.textAlign="left",s.textBaseline="top",e+=r<0?-r:0,t+=i<0?-i:0,s.fillText(b(a),e,t)},n:function(e,t,r){var i=n.render.dc(),a=i.measureText(b(e)),s=a.width,o=(a=i.measureText("Op")).actualBoundingBoxAscent+a.actualBoundingBoxDescent;m(t,s,"double"),m(r,o,"double")},B:function(e,t,r,i){var a=n.render.dc();a.translate(e,t),a.rotate(i),a.scale(r,r)},u:function(e,t){var r;if(0===e)r=Date.now();else{if(1!==e&&4!==e)return-1;r=me()}return S[t>>2]=r/1e3|0,S[t+4>>2]=r%1e3*1e3*1e3|0,0},r:function(e,t,r){z.copyWithin(e,t,t+r)},s:function(e){e>>>=0;var t=z.length,r=2147483648;if(e>r)return!1;for(var n,i,a=1;a<=4;a*=2){var s=t*(1+.2/a);if(s=Math.min(s,e+100663296),Ae(Math.min(r,((n=Math.max(16777216,e,s))%(i=65536)>0&&(n+=i-n%i),n))))return!0}return!1},w:function(e,t){n.events.invoke(e,t)},t:function(e){return 0},p:function(e,t,r,n,i){},g:function(e,t,r,n){for(var i=0,a=0;a<r;a++){for(var s=S[t+8*a>>2],o=S[t+(8*a+4)>>2],l=0;l<o;l++)ze.printChar(e,z[s+l]);i+=o}return S[n>>2]=i,0},D:function(e){console.log((new Date).toISOString()+": "+b(e))},memory:h,o:function(e){window.open(b(e),"_blank")},O:function(e){n.removeFunction(e)},j:function(e){return(e=+e)>=0?+Z(e+.5):+J(e-.5)},q:function(e){n.render.canvas().style.cursor=b(e)},table:p};!function(){var e={a:xe};function t(e,t){var r=e.exports;n.asm=r,function(e){if(0==--K&&Y){var t=Y;Y=null,t()}}()}function r(e){t(e.instance)}function i(t){return("function"==typeof fetch?fetch(re,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+re+"'";return e.arrayBuffer()})).catch((function(){return ne()})):new Promise((function(e,t){e(ne())}))).then((function(t){return WebAssembly.instantiate(t,e)})).then(t,(function(e){l("failed to asynchronously prepare wasm: "+e),G(e)}))}if(K++,n.instantiateWasm)try{return n.instantiateWasm(e,t)}catch(e){return l("Module.instantiateWasm callback failed with error: "+e),!1}!function(){if("function"!=typeof WebAssembly.instantiateStreaming||X(re)||"function"!=typeof fetch)return i(r);fetch(re,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(r,(function(e){return l("wasm streaming compile failed: "+e),l("falling back to ArrayBuffer instantiation"),i(r)}))}))}()}();var ke=n.___wasm_call_ctors=function(){return(ke=n.___wasm_call_ctors=n.asm.Z).apply(null,arguments)};n._vizzu_errorMessage=function(){return(n._vizzu_errorMessage=n.asm._).apply(null,arguments)},n._vizzu_version=function(){return(n._vizzu_version=n.asm.$).apply(null,arguments)},n._vizzu_setLogging=function(){return(n._vizzu_setLogging=n.asm.aa).apply(null,arguments)},n._vizzu_init=function(){return(n._vizzu_init=n.asm.ba).apply(null,arguments)},n._vizzu_keyPress=function(){return(n._vizzu_keyPress=n.asm.ca).apply(null,arguments)},n._vizzu_mouseMove=function(){return(n._vizzu_mouseMove=n.asm.da).apply(null,arguments)},n._vizzu_mouseDown=function(){return(n._vizzu_mouseDown=n.asm.ea).apply(null,arguments)},n._vizzu_mouseUp=function(){return(n._vizzu_mouseUp=n.asm.fa).apply(null,arguments)},n._vizzu_mouseLeave=function(){return(n._vizzu_mouseLeave=n.asm.ga).apply(null,arguments)},n._vizzu_mousewheel=function(){return(n._vizzu_mousewheel=n.asm.ha).apply(null,arguments)},n._vizzu_poll=function(){return(n._vizzu_poll=n.asm.ia).apply(null,arguments)},n._vizzu_update=function(){return(n._vizzu_update=n.asm.ja).apply(null,arguments)},n._style_getList=function(){return(n._style_getList=n.asm.ka).apply(null,arguments)},n._style_setValue=function(){return(n._style_setValue=n.asm.la).apply(null,arguments)},n._style_getValue=function(){return(n._style_getValue=n.asm.ma).apply(null,arguments)},n._chart_store=function(){return(n._chart_store=n.asm.na).apply(null,arguments)},n._chart_restore=function(){return(n._chart_restore=n.asm.oa).apply(null,arguments)},n._chart_free=function(){return(n._chart_free=n.asm.pa).apply(null,arguments)},n._chart_getList=function(){return(n._chart_getList=n.asm.qa).apply(null,arguments)},n._chart_getValue=function(){return(n._chart_getValue=n.asm.ra).apply(null,arguments)},n._chart_setValue=function(){return(n._chart_setValue=n.asm.sa).apply(null,arguments)},n._chart_setFilter=function(){return(n._chart_setFilter=n.asm.ta).apply(null,arguments)},n._record_getValue=function(){return(n._record_getValue=n.asm.ua).apply(null,arguments)},n._data_addDimension=function(){return(n._data_addDimension=n.asm.va).apply(null,arguments)},n._data_addMeasure=function(){return(n._data_addMeasure=n.asm.wa).apply(null,arguments)},n._data_addRecord=function(){return(n._data_addRecord=n.asm.xa).apply(null,arguments)},n._data_metaInfo=function(){return(n._data_metaInfo=n.asm.ya).apply(null,arguments)},n._addEventListener=function(){return(n._addEventListener=n.asm.za).apply(null,arguments)},n._removeEventListener=function(){return(n._removeEventListener=n.asm.Aa).apply(null,arguments)},n._event_preventDefault=function(){return(n._event_preventDefault=n.asm.Ba).apply(null,arguments)},n._chart_animate=function(){return(n._chart_animate=n.asm.Ca).apply(null,arguments)},n._anim_control=function(){return(n._anim_control=n.asm.Da).apply(null,arguments)},n._anim_setValue=function(){return(n._anim_setValue=n.asm.Ea).apply(null,arguments)},n.___getTypeName=function(){return(n.___getTypeName=n.asm.Fa).apply(null,arguments)},n.___embind_register_native_and_builtin_types=function(){return(n.___embind_register_native_and_builtin_types=n.asm.Ga).apply(null,arguments)};var Se,Ee=n._malloc=function(){return(Ee=n._malloc=n.asm.Ha).apply(null,arguments)},Be=n._free=function(){return(Be=n._free=n.asm.Ia).apply(null,arguments)};function Pe(e){K>0||(j(D),K>0||Se||(Se=!0,n.calledRun=!0,g||(j(I),j(R),t(n),j(N))))}return n.dynCall_vi=function(){return(n.dynCall_vi=n.asm.Ja).apply(null,arguments)},n.dynCall_v=function(){return(n.dynCall_v=n.asm.Ka).apply(null,arguments)},n.setValue=m,n.getValue=y,n.UTF8ToString=b,n.stringToUTF8=w,n.addFunction=function(e,t){return f(e,t)},n.removeFunction=function(e){!function(e){u.delete(p.get(e)),d.push(e)}(e)},Y=function e(){Se||Pe(),Se||(Y=e)},n.run=Pe,Pe(),e.ready});const d=e=>{try{return e.cssRules,!0}catch(e){return!1}},f=(e,t="")=>{const r=((e="")=>[...document.styleSheets].filter(d).reduce(((t,r)=>t.concat([...r.cssRules].filter((e=>1===e.type)).reduce(((t,r)=>[...t,...[...r.style].filter((t=>0===t.trim().indexOf("--"+e))).map((e=>e.trim()))]),[]))),[]))(t),n=getComputedStyle(e);return r.map((e=>[e,n.getPropertyValue(e).trim()])).filter((e=>""!==e[1]))};let m=null;class y{static get presets(){return new u}static options(e){m=e}constructor(e,t){if(this.container=e,this.container instanceof HTMLElement||(this.container=document.getElementById(e)),!this.container)throw new Error(`Cannot find container ${this.container} to render Vizzu!`);this._propPrefix="vizzu",this.started=!1,this._resolveAnimate=null,this.initializing=new o((e=>{this._resolveAnimate=e}),this),this.anim=this.initializing;let r={};m?.wasmUrl&&(r.locateFile=function(e){return e.endsWith(".wasm")?m.wasmUrl:e}),h(r).then((e=>{this._resolveAnimate&&this._resolveAnimate(this.init(e))})),t&&this.animate(t,0),this.snapshotRegistry=new FinalizationRegistry((e=>{this.call(this.module._chart_free)(e)}))}call(e){return(...t)=>{try{return e(...t)}catch(e){let t=parseInt(e,10),r=this.module._vizzu_errorMessage(t),n=this.module.UTF8ToString(r);throw new Error("error: "+n)}}}iterateObject(e,t,r=""){e&&Object.keys(e).forEach((n=>{let i=r+(0===r.length?"":".")+n;null!==e[n]&&"object"==typeof e[n]?this.iterateObject(e[n],t,i):this.setValue(i,e[n],t)}))}setNestedProp(e,t,r){let n=t.split(".");n.forEach(((t,i)=>{i<n.length-1?(e[t]=e[t]||("number"==typeof n[i+1]?[]:{}),e=e[t]):e[t]=r.startsWith("[")||r.startsWith("{")?JSON.parse(r):r}))}setValue(e,t,r){if(e!==""+e)throw new Error("first parameter should be string");let n=this.toCString(e),i=this.toCString(String(t).toString());try{r(n,i)}finally{this.module._free(i),this.module._free(n)}}setStyle(e){this.iterateObject(e,((e,t)=>{this.call(this.module._style_setValue)(e,t)}))}cloneObject(e,t){let r=this.call(e)(),n=this.fromCString(r),i=JSON.parse(n),a={};for(let e of i){let r,n=this.toCString(e);try{r=this.call(t)(n);let i=this.fromCString(r);this.setNestedProp(a,e,i)}finally{this.module._free(n)}}return Object.freeze(a),a}get config(){return this.cloneObject(this.module._chart_getList,this.module._chart_getValue)}get style(){return this.cloneObject(this.module._style_getList,this.module._style_getValue)}get data(){let e=this.call(this.module._data_metaInfo)(),t=this.fromCString(e);return{series:JSON.parse(t)}}setConfig(e){if(null!==e&&"object"==typeof e&&Object.keys(e).forEach((t=>{["color","lightness","size","label","x","y","noop"].includes(t)&&(e.channels=e.channels||{},e.channels[t]=e[t],delete e[t])})),e?.channels){let t=e.channels;Object.keys(t).forEach((e=>{"string"==typeof t[e]&&(t[e]=[t[e]]),(null===t[e]||Array.isArray(t[e]))&&(t[e]={set:t[e]}),"string"==typeof t[e].attach&&(t[e].attach=[t[e].attach]),"string"==typeof t[e].detach&&(t[e].detach=[t[e].detach]),"string"==typeof t[e].set&&(t[e].set=[t[e].set]),Array.isArray(t[e].set)&&0===t[e].set.length&&(t[e].set=null)}))}this.iterateObject(e,((e,t)=>{this.call(this.module._chart_setValue)(e,t)}))}on(e,t){this._validateModule(),this.events.add(e,t)}off(e,t){this._validateModule(),this.events.remove(e,t)}store(){this._validateModule();let e=this.call(this.module._chart_store)(),t={id:e};return this.snapshotRegistry.register(t,e),t}restore(e){this._validateModule(),this.call(this.module._chart_restore)(e.id)}feature(e,t){this._validateModule(),"tooltip"===e?this.tooltip.enable(t):"logging"===e?this.call(this.module._vizzu_setLogging)(t):"rendering"===e&&(this.render.enabled=t)}_validateModule(){if(!this.module)throw new Error("Vizzu not initialized. Use `initializing` promise.")}animate(e,t){return this.anim=this.anim.then((()=>this.animStep(e,t))),this.anim}animStep(e,t){if(e){let t=Object.assign({},e);if(t.id)this.restore(t);else{t.data||void 0!==t.style||t.config||(t={config:t}),this._data.set(t.data),null===t.style&&(t.style={"":null});const e=JSON.parse(JSON.stringify(t.style||{})),r=f(this.container,this._propPrefix);this.setStyle(((e,t,r="",n=!1)=>(t=t||{},t=e.reduce(((e,[t,i])=>(((e,t,r,n)=>{t.reduce(((e,i,a)=>(a===t.length-1?!n&&e[i]||(e[i]=r):e[i]||(e[i]={}),e[i])),e)})(e,t.replace("--"+(r?r+"-":""),"").split("-"),i,n),e)),t),t))(r,e,this._propPrefix)),this.setConfig(Object.assign({},t.config))}}return this.setAnimation(t),new o(((e,t)=>{let r=this.module.addFunction((n=>{n?e(this):(t("animation canceled"),this.anim=Promise.resolve(this)),this.module.removeFunction(r)}),"vi");this.call(this.module._chart_animate)(r)}),this)}setAnimation(e){if(void 0!==e){if(null===e?e={duration:0}:"string"!=typeof e&&"number"!=typeof e||(e={duration:e}),"object"!=typeof e)throw new Error("invalid animation option");e=Object.assign({},e),this.iterateObject(e,((e,t)=>{this.call(this.module._anim_setValue)(e,t)}))}}get animation(){return this.anim}version(){this._validateModule();let e=this.module._vizzu_version();return this.module.UTF8ToString(e)}start(){this.started||(this.call(this.module._vizzu_poll)(),this.render.updateFrame(!1),setInterval((()=>{this.call(this.module._vizzu_poll)()}),10),setInterval((()=>{this.render.updateFrame(!1)}),25),this.started=!0)}getMousePos(e){var t=this.render.clientRect();return[e.clientX-t.left,e.clientY-t.top]}toCString(e){let t=4*e.length+1,r=this.module._malloc(t);return this.module.stringToUTF8(e,r,t),r}fromCString(e){return this.module.UTF8ToString(e)}init(r){this.module=r;let n=this.createCanvas();return this.render=new e,this.module.render=this.render,this._data=new s(this),this.events=new t(this),this.module.events=this.events,this.tooltip=new l(this),this.render.init(this.call(this.module._vizzu_update),n,!1),this.call(this.module._vizzu_init)(),this.call(this.module._vizzu_setLogging)(!1),this.setupDOMEventHandlers(n),this.start(),this}createCanvas(){let e=null,t=this.container;if(t instanceof HTMLCanvasElement?e=t:(e=document.createElement("CANVAS"),e.style.width="100%",e.style.height="100%",t.appendChild(e)),!(e instanceof HTMLCanvasElement))throw new Error("Error initializing <canvas> for Vizzu!");return e}setupDOMEventHandlers(e){this.resizeObserver=new ResizeObserver((()=>{this.render.updateFrame(!0)})),this.resizeObserver.observe(e),window.addEventListener("resize",(()=>{this.render.updateFrame(!0)})),e.addEventListener("mousemove",(e=>{let t=this.getMousePos(e);this.call(this.module._vizzu_mouseMove)(t[0],t[1])})),e.addEventListener("mouseup",(e=>{let t=this.getMousePos(e);this.call(this.module._vizzu_mouseUp)(t[0],t[1])})),e.addEventListener("mousedown",(e=>{let t=this.getMousePos(e);this.call(this.module._vizzu_mouseDown)(t[0],t[1])})),e.addEventListener("mouseout",(()=>{this.call(this.module._vizzu_mouseLeave)()})),e.addEventListener("wheel",(e=>{this.call(this.module._vizzu_mousewheel)(e.deltaY)})),document.addEventListener("keydown",(e=>{let t=e.keyCode<=255?e.keyCode:0;const r=[33,34,36,35,37,39,38,40,27,9,13,46];for(let n=0;n<r.length;n++)e.key===r[n]&&(t=256+n);0!==t&&this.call(this.module._vizzu_keyPress)(t,e.ctrlKey,e.altKey,e.shiftKey)}))}}export{y as default};
|