UNPKG

37.4 kBJavaScriptView Raw
1class Render{init(e,t,r){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);var 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(),e=(this.updateCanvasSize(),0<this.mainCanvas.width&&0<this.mainCanvas.height&&this.update(this.scaleFactor,this.cssWidth,this.cssHeight,e),performance.now()-t);this.log&&1<e&&console.log("Render.updateFrame: "+e.toFixed(2)+"ms")}}class Events{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");e=this.vizzu.toCString(e);try{var r=this.vizzu.call(this.module._addEventListener)(e);this.eventHandlers.set(r,t)}finally{this.module._free(e)}}remove(e,n){var t=this.vizzu.toCString(e);if(e!==""+e)throw new Error("first parameter should be string");try{if(n){let r=null;if(this.eventHandlers.forEach((e,t)=>{e===n&&(r=t)}),null===r)throw new Error("unknown event handler");this.vizzu.call(this.module._removeEventListener)(t,r)}else this.vizzu.call(this.module._removeEventListener)(t,0)}finally{this.eventHandlers.delete(n),this.module._free(t)}}invoke(t,r){try{if(this.eventHandlers.has(t)){let e=JSON.parse(this.vizzu.fromCString(r));e.preventDefault=()=>{this.vizzu.call(this.module._event_preventDefault)()},e.event.endsWith("-draw")&&(e.renderingContext=this.vizzu.render.dc()),this.eventHandlers.get(t)(e)}}catch(e){console.log("exception in event handler: "+e)}}}const assert=(e,t)=>{if(!e)throw new Error("Assert failed: "+t)},assertArray=(t,e,r)=>{assert(Array.isArray(e),"array is not a list");try{if(e.length!==t.dimensions[r].values.length)throw new Error("Assert failed")}catch(e){assert(!1,"dimensions are not the same")}e.forEach(e=>{Array.isArray(e)&&assertArray(t,e,r-1)})};class UnPivot{static isPivot(e){return void 0!==e?.dimensions||void 0!==e?.measures}static convert(i){assert("object"==typeof i&&null!==i&&!Array.isArray(i),"data is not an object"),assert("dimensions"in i,"data.dimensions is requreid"),assert("measures"in i,"data.measures is requreid"),i.series=[];let a=1;assert(Array.isArray(i.dimensions),"data.dimensions is not a list");for(let e=0;e<i.dimensions.length;e++){var t=i.dimensions[e];assert("object"==typeof t&&null!==t&&!Array.isArray(t),"data.dimensions.item is not an object"),assert("name"in t,"data.dimensions.item.name is requreid"),assert(void 0===t.type||"dimension"===t.type,"data.dimensions.item.type is invalid"),assert("values"in t,"data.dimensions.item.values is requreid"),assert(Array.isArray(t.values),"data.dimensions.item.values is not a list"),assert(0!==t.values.length,"data.dimensions.item.values length is zero"),a*=t.values.length}let s=1;for(let n=0;n<i.dimensions.length;n++){let e=i.dimensions[n],t=[],r=[];e.values.forEach(t=>{for(let e=1;e<=s;e++)r.push(t)}),s*=e.values.length;for(let e=1;e<=a/s;e++)t=t.concat(r);var o={name:e.name,type:e.type||"dimension",values:t};i.series.push(o)}assert("object"==typeof i.measures&&null!==i.measures,"data.measures is not a list or an object"),Array.isArray(i.measures)||(i.measures=[i.measures]);for(let r=0;r<i.measures.length;r++){let e=i.measures[r],t=(assert("object"==typeof e&&null!==e&&!Array.isArray(e),"data.measures.item is not an object"),assert("name"in e,"data.measures.item.name is requreid"),assert("values"in e,"data.measures.item.values is requreid"),assert(Array.isArray(e.values),"data.measures.item.values is not a list"),assertArray(i,e.values,i.dimensions.length-1),{name:e.name,type:e.type,values:e.values.flat(1/0)});void 0===t.type&&delete t.type,assert(t.values.length===a,"dimensions are not the same"),i.series.push(t)}}}class DataRecord{constructor(e,t){return this.chart=e,this.record=t,new Proxy(this,{get:(e,t)=>e.getValue(t)})}getValue(e){e=this.chart.toCString(e);let t,r;try{t=this.chart.call(this.chart.module._record_getValue)(this.record,e,!0),r=t?this.chart.fromCString(t):(t=this.chart.call(this.chart.module._record_getValue)(this.record,e,!1),this.chart.module.getValue(t,"double"))}finally{this.chart.module._free(e)}return r}}class Data{constructor(e){this.chart=e}set(e){if(e){if(UnPivot.isPivot(e)){if(this.is1NF(e))throw new Error("inconsistent data form: series/records and dimensions/measures are both set.");UnPivot.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 r of e.records)this.addRecord(r)}!e.filter&&null!==e.filter||this.setFilter(e.filter)}}addRecord(t){if(!Array.isArray(t))throw new Error("data record is not an array");let r=new Uint32Array(t.length);for(let e=0;e<t.length;e++){var n=this.chart.toCString(String(t[e]).toString());r[e]=n}var e=4*t.length,i=this.chart.module._malloc(e);new Uint8Array(this.chart.module.HEAPU8.buffer,i,e).set(new Uint8Array(r.buffer));try{this.chart.call(this.chart.module._data_addRecord)(i,t.length)}finally{for(var a of r)this.chart.module._free(a);this.chart.module._free(i)}}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");var n=this.chart.toCString(t[e]);r[e]=n}var i=4*t.length,a=this.chart.module._malloc(i),i=(new Uint8Array(this.chart.module.HEAPU8.buffer,a,i).set(new Uint8Array(r.buffer)),this.chart.toCString(e));try{this.chart.call(this.chart.module._data_addDimension)(i,a,t.length)}finally{this.chart.module._free(i);for(var s of r)this.chart.module._free(s);this.chart.module._free(a)}}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");var r=new Float64Array(t),n=8*t.length,i=this.chart.module._malloc(n),n=(new Uint8Array(this.chart.module.HEAPU8.buffer,i,n).set(new Uint8Array(r.buffer)),this.chart.toCString(e));try{this.chart.call(this.chart.module._data_addMeasure)(n,i,t.length)}finally{this.chart.module._free(n),this.chart.module._free(i)}}setFilter(t){if("function"==typeof t){var e=this.chart.module.addFunction(e=>t(new DataRecord(this.chart,e)),"ii");this.chart.call(this.chart.module._chart_setFilter)(e)}else{if(null!==t)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 AnimControl extends Promise{constructor(r,e){super((e,t)=>{r(e,t)}),this.chart=e}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}reverse(){return this.animControl("reverse"),this}animControl(e,t=""){e=this.chart.toCString(e),t=this.chart.toCString(t);try{this.chart.call(this.chart.module._anim_control)(e,t)}finally{this.chart.module._free(t),this.chart.module._free(e)}}}class Tooltip{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){var t;this.id===e&&(t=new Date-this.lastMove,!this.animating&&200<t?(this.lastMarkerId=null,this.animating=!0,this.chart.animate({config:{tooltip:null}},"250ms").then(()=>{this.animating=!1})):setTimeout(()=>{this.out(e)},200-t))}}var VizzuModule=function(){var We=import.meta.url;return function(e){var x,L,t,u=void 0!==(e=e||{})?e:{},r=(u.ready=new Promise(function(e,t){x=e,L=t}),{});for(t in u)u.hasOwnProperty(t)&&(r[t]=u[t]);var H,n="";document.currentScript&&(n=document.currentScript.src);var n=0!==(n=We?We:n).indexOf("blob:")?n.substr(0,n.lastIndexOf("/")+1):"",j=console.log.bind(console),a=console.warn.bind(console);for(t in r)r.hasOwnProperty(t)&&(u[t]=r[t]);var s,D,o,r=null,l=[];function R(t,r){var n,i=I;if(!s){s=new WeakMap;for(var e=0;e<i.length;e++){var a=i.get(e);a&&s.set(a,e)}}if(s.has(t))return s.get(t);if(l.length)n=l.pop();else{n=i.length;try{i.grow(1)}catch(e){if(e instanceof RangeError)throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";throw e}}try{i.set(n,t)}catch(e){if(!(e instanceof TypeError))throw e;r=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]]);return"v"==s?a.push(0):a=a.concat([1,l[s]]),a[1]=a.length-2,s=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])),s=new WebAssembly.Module(s),new WebAssembly.Instance(s,{e:{f:e}}).exports.f}(t,r);i.set(n,r)}return s.set(t,n),n}function i(e,t,r,n){switch(r="*"===(r=r||"i8").charAt(r.length-1)?"i32":r){case"i1":case"i8":f[e>>0]=t;break;case"i16":v[e>>1]=t;break;case"i32":y[e>>2]=t;break;case"i64":S=[t>>>0,1<=+ae(S=t)?0<S?(0|le(+oe(S/4294967296),4294967295))>>>0:~~+se((S-(~~S>>>0))/4294967296)>>>0:0],y[e>>2]=S[0],y[e+4>>2]=S[1];break;case"float":_[e>>2]=t;break;case"double":w[e>>3]=t;break;default:C("invalid type for setValue: "+r)}}function c(e,t,r){switch(t="*"===(t=t||"i8").charAt(t.length-1)?"i32":t){case"i1":case"i8":return f[e>>0];case"i16":return v[e>>1];case"i32":case"i64":return y[e>>2];case"float":return _[e>>2];case"double":return w[e>>3];default:C("invalid type for getValue: "+t)}return null}"object"!=typeof WebAssembly&&C("no native wasm support detected");var I=new WebAssembly.Table({initial:1164,element:"anyfunc"}),N=!1,B="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function q(e,t,r){for(var n=t+r,i=t;e[i]&&!(n<=i);)++i;if(16<i-t&&e.subarray&&B)return B.decode(e.subarray(t,i));for(var a="";t<i;){var s,o,l=e[t++];128&l?(o=63&e[t++],192==(224&l)?a+=String.fromCharCode((31&l)<<6|o):(s=63&e[t++],(l=224==(240&l)?(15&l)<<12|o<<6|s:(7&l)<<18|o<<12|s<<6|63&e[t++])<65536?a+=String.fromCharCode(l):(o=l-65536,a+=String.fromCharCode(55296|o>>10,56320|1023&o)))):a+=String.fromCharCode(l)}return a}function h(e,t){return e?q(m,e,t):""}function J(e,t,r){var n=e,i=m,a=t,e=r;if(!(0<e))return 0;for(var t=a,s=a+e-1,o=0;o<n.length;++o){var l=n.charCodeAt(o);if((l=55296<=l&&l<=57343?65536+((1023&l)<<10)|1023&n.charCodeAt(++o):l)<=127){if(s<=a)break;i[a++]=l}else if(l<=2047){if(s<=a+1)break;i[a++]=192|l>>6,i[a++]=128|63&l}else if(l<=65535){if(s<=a+2)break;i[a++]=224|l>>12,i[a++]=128|l>>6&63,i[a++]=128|63&l}else{if(s<=a+3)break;i[a++]=240|l>>18,i[a++]=128|l>>12&63,i[a++]=128|l>>6&63,i[a++]=128|63&l}}return i[a]=0,a-t}var Z="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function Y(e,t){for(var r,n=e>>1,i=n+t/2;!(i<=n)&&p[n];)++n;if(32<(r=n<<1)-e&&Z)return Z.decode(m.subarray(e,r));for(var a=0,s="";;){var o=v[e+2*a>>1];if(0==o||a==t/2)return s;++a,s+=String.fromCharCode(o)}}function $(e,t,r){if((r=void 0===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);v[t>>1]=s,t+=2}return v[t>>1]=0,t-n}function G(e){return 2*e.length}function K(e,t){for(var r=0,n="";!(t/4<=r);){var i,a=y[e+4*r>>2];if(0==a)break;++r,65536<=a?(i=a-65536,n+=String.fromCharCode(55296|i>>10,56320|1023&i)):n+=String.fromCharCode(a)}return n}function X(e,t,r){if((r=void 0===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(55296<=s&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++a)),y[t>>2]=s,i<(t+=4)+4)break}return y[t>>2]=0,t-n}function Q(e){for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);55296<=n&&n<=57343&&++r,t+=4}return t}var d,f,m,v,p,y,g,_,w;function ee(e){d=e,u.HEAP8=f=new Int8Array(e),u.HEAP16=v=new Int16Array(e),u.HEAP32=y=new Int32Array(e),u.HEAPU8=m=new Uint8Array(e),u.HEAPU16=p=new Uint16Array(e),u.HEAPU32=g=new Uint32Array(e),u.HEAPF32=_=new Float32Array(e),u.HEAPF64=w=new Float64Array(e)}function b(e){for(;0<e.length;){var t,r=e.shift();"function"==typeof r?r(u):"number"==typeof(t=r.func)?void 0===r.arg?u.dynCall_v(t):u.dynCall_vi(t,r.arg):t(void 0===r.arg?null:r.arg)}}o=new WebAssembly.Memory({initial:256,maximum:32768}),(d=o?o.buffer:d).byteLength,ee(d),y[14580]=5301360;var te=[],re=[],ne=[],ie=[];var ae=Math.abs,se=Math.ceil,oe=Math.floor,le=Math.min,A=0,z=null;function C(e){a(e+=""),N=!0,e="abort("+e+"). Build with -s ASSERTIONS=1 for more info.";e=new WebAssembly.RuntimeError(e);throw L(e),e}u.preloadedImages={},u.preloadedAudios={};function ue(e){return e=e,t="data:application/octet-stream;base64,",String.prototype.startsWith?e.startsWith(t):0===e.indexOf(t);var t}var ce,S,E="cvizzu.wasm";function he(){try{if(D)return new Uint8Array(D);if(H)return H(E);throw"both async and sync fetching of the wasm failed"}catch(e){C(e)}}function de(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)}}ue(E)||(ce=E,E=u.locateFile?u.locateFile(ce,n):n+ce),re.push({func:function(){Fe()}});var fe=void 0;function P(e){for(var t="",r=e;m[r];)t+=fe[m[r++]];return t}var me={},ve={},pe=48,ye=57;function ge(e,t){return e=function(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return pe<=t&&t<=ye?"_"+e:e}(e),new Function("body","return function "+e+'() {\n "use strict"; return body.apply(this, arguments);\n};\n')(t)}function _e(e,t){var r=ge(t,function(e){this.name=t,this.message=e;e=new Error(e).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.replace(/^Error(:[^\n]*)?\n/,""))});return r.prototype=Object.create(e.prototype),(r.prototype.constructor=r).prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},r}var we=void 0;function T(e){throw new we(e)}function F(e,t,r){if(r=r||{},!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");var n=t.name;if(e||T('type "'+n+'" must have a positive integer typeid pointer'),ve.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;T("Cannot register type '"+n+"' twice")}ve[e]=t,me.hasOwnProperty(e)&&(r=me[e],delete me[e],r.forEach(function(e){e()}))}var be=[],k=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Ae(){for(var e=0,t=5;t<k.length;++t)void 0!==k[t]&&++e;return e}function ze(){for(var e=5;e<k.length;++e)if(void 0!==k[e])return k[e];return null}function Ce(e){return this.fromWireType(g[e>>2])}function Se(e){if(null===e)return"null";var t=typeof e;return"object"==t||"array"==t||"function"==t?e.toString():""+e}var Ee=function(){return performance.now()};var W={mappings:{},buffers:[null,[],[]],printChar:function(e,t){var r=W.buffers[e];0===t||10===t?((1===e?j:a)(q(r,0)),r.length=0):r.push(t)},varargs:void 0,get:function(){return W.varargs+=4,y[W.varargs-4>>2]},getStr:function(e){return h(e)},get64:function(e,t){return e}};for(var Pe=new Array(256),O=0;O<256;++O)Pe[O]=String.fromCharCode(O);fe=Pe,we=u.BindingError=_e(Error,"BindingError"),u.InternalError=_e(Error,"InternalError"),u.count_emval_handles=Ae,u.get_first_emval=ze;var M,Te={a:function(e){return U(e)},b:function(e,t,r){throw e},x:function(e,r,n,i,a){var s=de(n);F(e,{name:r=P(r),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?i:a},argPackAdvance:8,readValueFromPointer:function(e){var t;if(1===n)t=f;else if(2===n)t=v;else{if(4!==n)throw new TypeError("Unknown boolean type size: "+r);t=y}return this.fromWireType(t[e>>s])},destructorFunction:null})},v:function(e,t){F(e,{name:t=P(t),fromWireType:function(e){var t=k[e].value;return 4<(e=e)&&0==--k[e].refcount&&(k[e]=void 0,be.push(e)),t},toWireType:function(e,t){var r=t;switch(r){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var n=be.length?be.pop():k.length;return k[n]={refcount:1,value:r},n}},argPackAdvance:8,readValueFromPointer:Ce,destructorFunction:null})},h:function(e,t,r){r=de(r),F(e,{name:t=P(t),fromWireType:function(e){return e},toWireType:function(e,t){if("number"!=typeof t&&"boolean"!=typeof t)throw new TypeError('Cannot convert "'+Se(t)+'" to '+this.name);return t},argPackAdvance:8,readValueFromPointer:function(e,t){switch(t){case 2:return function(e){return this.fromWireType(_[e>>2])};case 3:return function(e){return this.fromWireType(w[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}(t,r),destructorFunction:null})},d:function(e,r,t,n,i){r=P(r),-1===i&&(i=4294967295);var a,s=de(t),o=function(e){return e},l=(0===n&&(a=32-8*t,o=function(e){return e<<a>>>a}),-1!=r.indexOf("unsigned"));F(e,{name:r,fromWireType:o,toWireType:function(e,t){if("number"!=typeof t&&"boolean"!=typeof t)throw new TypeError('Cannot convert "'+Se(t)+'" to '+this.name);if(t<n||i<t)throw new TypeError('Passing a number "'+Se(t)+'" from JS side to C/C++ side to an argument of type "'+r+'", which is outside the valid range ['+n+", "+i+"]!");return l?t>>>0:0|t},argPackAdvance:8,readValueFromPointer:function(e,t,r){switch(t){case 0:return r?function(e){return f[e]}:function(e){return m[e]};case 1:return r?function(e){return v[e>>1]}:function(e){return p[e>>1]};case 2:return r?function(e){return y[e>>2]}:function(e){return g[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}(r,s,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=g,r=t[e>>=2],t=t[e+1];return new n(d,t,r)}F(e,{name:r=P(r),fromWireType:i,argPackAdvance:8,readValueFromPointer:i},{ignoreDuplicateRegistrations:!0})},i:function(e,t){var l="std::string"===(t=P(t));F(e,{name:t,fromWireType:function(e){var t=g[e>>2];if(l)for(var r=e+4,n=0;n<=t;++n){var i,a,s=e+4+n;n!=t&&0!=m[s]||(i=h(r,s-r),a=void 0===a?i:a+String.fromCharCode(0)+i,r=s+1)}else{for(var o=new Array(t),n=0;n<t;++n)o[n]=String.fromCharCode(m[e+4+n]);a=o.join("")}return V(e),a},toWireType:function(e,i){var t="string"==typeof(i=i instanceof ArrayBuffer?new Uint8Array(i):i),r=(t||i instanceof Uint8Array||i instanceof Uint8ClampedArray||i instanceof Int8Array||T("Cannot pass non-string to std::string"),(l&&t?function(){for(var e=i,t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);(n=55296<=n&&n<=57343?65536+((1023&n)<<10)|1023&e.charCodeAt(++r):n)<=127?++t:t+=n<=2047?2:n<=65535?3:4}return t}:function(){return i.length})()),n=U(4+r+1);if(g[n>>2]=r,l&&t)J(i,n+4,r+1);else if(t)for(var a=0;a<r;++a){var s=i.charCodeAt(a);255<s&&(V(n),T("String has UTF-16 code units that do not fit in 8 bits")),m[n+4+a]=s}else for(a=0;a<r;++a)m[n+4+a]=i[a];return null!==e&&e.push(V,n),n},argPackAdvance:8,readValueFromPointer:Ce,destructorFunction:function(e){V(e)}})},f:function(e,l,i){var u,a,c,s,h;i=P(i),2===l?(u=Y,a=$,s=G,c=function(){return p},h=1):4===l&&(u=K,a=X,s=Q,c=function(){return g},h=2),F(e,{name:i,fromWireType:function(e){for(var t=g[e>>2],r=c(),n=e+4,i=0;i<=t;++i){var a,s,o=e+4+i*l;i!=t&&0!=r[o>>h]||(a=u(n,o-n),s=void 0===s?a:s+String.fromCharCode(0)+a,n=o+l)}return V(e),s},toWireType:function(e,t){"string"!=typeof t&&T("Cannot pass non-string to C++ string type "+i);var r=s(t),n=U(4+r+l);return g[n>>2]=r>>h,a(t,n+4,r+l),null!==e&&e.push(V,n),n},argPackAdvance:8,readValueFromPointer:Ce,destructorFunction:function(e){V(e)}})},y:function(e,t){F(e,{isVoid:!0,name:t=P(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})},e:function(){C()},L:function(e,t,r,n,i,a){u.render.dc().bezierCurveTo(e,t,r,n,i,a)},M:function(e,t){var r=u.render.dc();u.render.startPolygonNotification()?r.moveTo(e,t):r.lineTo(e,t)},T:function(){},N:function(){u.render.dc().beginPath()},I:function(e,t,r){var n=u.render.dc();n.beginPath(),n.arc(e,t,r,0,6.28318530718),n.fill(),u.render.noneZeroLineWidth()&&n.stroke()},E:function(e,t,r,n,i,a){},P:function(){let e=u.render.dc();e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowColor="rgba(0, 0, 0, 0)"},K:function(){var e=u.render.dc();e.closePath(),e.fill(),u.render.noneZeroLineWidth()&&e.stroke(),u.render.endPolygonNotification()},C:function(){u.render.frameBegin()},k:function(){u.render.frameEnd()},H:function(e,t,r,n){var i=u.render.dc();i.beginPath(),i.moveTo(e,t),i.lineTo(r,n),u.render.noneZeroLineWidth()&&i.stroke()},J:function(e,t,r,n){var i=u.render.dc();i.beginPath(),i.rect(e,t,r,n),i.fill(),u.render.noneZeroLineWidth()&&i.stroke()},z:function(){u.render.dc().restore()},A:function(){u.render.dc().save()},X:function(e,t,r,n){u.render.dc().fillStyle="rgba("+255*e+","+255*t+","+255*r+","+n+")"},F:function(e,t,r,n,i,a){for(var s=u.render.dc(),o=s.createLinearGradient(e,t,r,n),l=0;l<40*i;l+=40)o.addColorStop(c(a+l,"double"),"rgba("+255*c(a+l+8,"double")+","+255*c(a+l+16,"double")+","+255*c(a+l+24,"double")+","+c(a+l+32,"double")+")");s.fillStyle=o},l:function(e,t,r){var n=u.render.dc();n.beginPath(),n.arc(e,t,r,0,6.28318530718),n.clip()},Y:function(){var e=u.render.dc();e.closePath(),e.clip(),u.render.endPolygonNotification()},m:function(e,t,r,n){var i=u.render.dc();i.beginPath(),i.rect(e,t,r,n),i.clip()},S:function(e){let t=u.render.dc();t.shadowBlur=e},R:function(e,t,r,n){let i=u.render.dc();i.shadowColor="rgba("+255*e+","+255*t+","+255*r+","+n+")"},Q:function(e,t){let r=u.render.dc();r.shadowOffsetX=e,r.shadowOffsetY=t},U:function(e){u.render.dc().font=h(e)},W:function(e,t,r,n){u.render.dc().strokeStyle="rgba("+255*e+","+255*t+","+255*r+","+n+")"},V:function(e){u.render.dc().lineWidth=e,u.render.lineWidthNotification(e)},G:function(e,t,r,n,i){var a=u.render.dc();a.textAlign="left",a.textBaseline="top",e+=r<0?-r:0,t+=n<0?-n:0,a.fillText(h(i),e,t)},n:function(e,t,r){var e=(n=u.render.dc()).measureText(h(e)).width,n=(n=n.measureText("Op")).actualBoundingBoxAscent+n.actualBoundingBoxDescent;i(t,e,"double"),i(r,n,"double")},B:function(e,t,r,n){var i=u.render.dc();i.translate(e,t),i.rotate(n),i.scale(r,r)},u:function(e,t){var r;if(0===e)r=Date.now();else{if(1!==e&&4!==e)return-1;r=Ee()}return y[t>>2]=r/1e3|0,y[t+4>>2]=r%1e3*1e3*1e3|0,0},r:function(e,t,r){m.copyWithin(e,t,t+r)},s:function(e){var t=m.length,r=2147483648;if(r<(e>>>=0))return!1;for(var n,i=1;i<=4;i*=2){var a=t*(1+.2/i),a=Math.min(a,e+100663296);if(function(e){try{return o.grow(e-d.byteLength+65535>>>16),ee(o.buffer),1}catch(e){}}(Math.min(r,(0<(a=Math.max(16777216,e,a))%(n=65536)&&(a+=n-a%n),a))))return!0}return!1},w:function(e,t){u.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=y[t+8*a>>2],o=y[t+(8*a+4)>>2],l=0;l<o;l++)W.printChar(e,m[s+l]);i+=o}return y[n>>2]=i,0},D:function(e){console.log((new Date).toISOString()+": "+h(e))},memory:o,o:function(e){window.open(h(e),"_blank")},O:function(e){u.removeFunction(e)},j:function(e){return 0<=(e=+e)?+oe(e+.5):+se(e-.5)},q:function(e){u.render.canvas().style.cursor=h(e)},table:I},Fe=(function(){var t={a:Te};function r(e,t){var e=e.exports;u.asm=e,0==--A&&z&&(e=z,z=null,e())}function n(e){r(e.instance)}function i(e){return("function"==typeof fetch?fetch(E,{credentials:"same-origin"}).then(function(e){if(e.ok)return e.arrayBuffer();throw"failed to load wasm binary file at '"+E+"'"}).catch(he):new Promise(function(e,t){e(he())})).then(function(e){return WebAssembly.instantiate(e,t)}).then(e,function(e){a("failed to asynchronously prepare wasm: "+e),C(e)})}if(A++,u.instantiateWasm)try{return u.instantiateWasm(t,r)}catch(e){return a("Module.instantiateWasm callback failed with error: "+e)}"function"!=typeof WebAssembly.instantiateStreaming||ue(E)||"function"!=typeof fetch?i(n):fetch(E,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,t).then(n,function(e){return a("wasm streaming compile failed: "+e),a("falling back to ArrayBuffer instantiation"),i(n)})})}(),u.___wasm_call_ctors=function(){return(Fe=u.___wasm_call_ctors=u.asm.Z).apply(null,arguments)}),U=(u._vizzu_errorMessage=function(){return(u._vizzu_errorMessage=u.asm._).apply(null,arguments)},u._vizzu_version=function(){return(u._vizzu_version=u.asm.$).apply(null,arguments)},u._vizzu_setLogging=function(){return(u._vizzu_setLogging=u.asm.aa).apply(null,arguments)},u._vizzu_init=function(){return(u._vizzu_init=u.asm.ba).apply(null,arguments)},u._vizzu_keyPress=function(){return(u._vizzu_keyPress=u.asm.ca).apply(null,arguments)},u._vizzu_mouseMove=function(){return(u._vizzu_mouseMove=u.asm.da).apply(null,arguments)},u._vizzu_mouseDown=function(){return(u._vizzu_mouseDown=u.asm.ea).apply(null,arguments)},u._vizzu_mouseUp=function(){return(u._vizzu_mouseUp=u.asm.fa).apply(null,arguments)},u._vizzu_mouseLeave=function(){return(u._vizzu_mouseLeave=u.asm.ga).apply(null,arguments)},u._vizzu_mousewheel=function(){return(u._vizzu_mousewheel=u.asm.ha).apply(null,arguments)},u._vizzu_poll=function(){return(u._vizzu_poll=u.asm.ia).apply(null,arguments)},u._vizzu_update=function(){return(u._vizzu_update=u.asm.ja).apply(null,arguments)},u._style_getList=function(){return(u._style_getList=u.asm.ka).apply(null,arguments)},u._style_setValue=function(){return(u._style_setValue=u.asm.la).apply(null,arguments)},u._style_getValue=function(){return(u._style_getValue=u.asm.ma).apply(null,arguments)},u._chart_store=function(){return(u._chart_store=u.asm.na).apply(null,arguments)},u._chart_restore=function(){return(u._chart_restore=u.asm.oa).apply(null,arguments)},u._chart_free=function(){return(u._chart_free=u.asm.pa).apply(null,arguments)},u._chart_getList=function(){return(u._chart_getList=u.asm.qa).apply(null,arguments)},u._chart_getValue=function(){return(u._chart_getValue=u.asm.ra).apply(null,arguments)},u._chart_setValue=function(){return(u._chart_setValue=u.asm.sa).apply(null,arguments)},u._chart_setFilter=function(){return(u._chart_setFilter=u.asm.ta).apply(null,arguments)},u._record_getValue=function(){return(u._record_getValue=u.asm.ua).apply(null,arguments)},u._data_addDimension=function(){return(u._data_addDimension=u.asm.va).apply(null,arguments)},u._data_addMeasure=function(){return(u._data_addMeasure=u.asm.wa).apply(null,arguments)},u._data_addRecord=function(){return(u._data_addRecord=u.asm.xa).apply(null,arguments)},u._addEventListener=function(){return(u._addEventListener=u.asm.ya).apply(null,arguments)},u._removeEventListener=function(){return(u._removeEventListener=u.asm.za).apply(null,arguments)},u._event_preventDefault=function(){return(u._event_preventDefault=u.asm.Aa).apply(null,arguments)},u._chart_animate=function(){return(u._chart_animate=u.asm.Ba).apply(null,arguments)},u._anim_control=function(){return(u._anim_control=u.asm.Ca).apply(null,arguments)},u._anim_setValue=function(){return(u._anim_setValue=u.asm.Da).apply(null,arguments)},u.___getTypeName=function(){return(u.___getTypeName=u.asm.Ea).apply(null,arguments)},u.___embind_register_native_and_builtin_types=function(){return(u.___embind_register_native_and_builtin_types=u.asm.Fa).apply(null,arguments)},u._malloc=function(){return(U=u._malloc=u.asm.Ga).apply(null,arguments)}),V=u._free=function(){return(V=u._free=u.asm.Ha).apply(null,arguments)};u.dynCall_vi=function(){return(u.dynCall_vi=u.asm.Ia).apply(null,arguments)},u.dynCall_v=function(){return(u.dynCall_v=u.asm.Ja).apply(null,arguments)};function ke(e){function t(){M||(M=!0,u.calledRun=!0,N||(b(re),b(ne),x(u),b(ie)))}0<A||(b(te),0<A||t())}return u.setValue=i,u.getValue=c,u.UTF8ToString=h,u.stringToUTF8=J,u.addFunction=R,u.removeFunction=function(e){e=e,s.delete(I.get(e)),l.push(e)},z=function e(){M||ke(),M||(z=e)},(u.run=ke)(),e.ready}}();const isAccessibleStylesheet=e=>{try{return e.cssRules,!0}catch(e){return!1}},getCSSCustomProps=(r="")=>[...document.styleSheets].filter(isAccessibleStylesheet).reduce((e,t)=>e.concat([...t.cssRules].filter(e=>1===e.type).reduce((e,t)=>{t=[...t.style].filter(e=>0===e.trim().indexOf("--"+r)).map(e=>e.trim());return[...e,...t]},[])),[]),getCSSCustomPropsForElement=(e,t="")=>{const r=getCSSCustomProps(t),n=getComputedStyle(e);return r.map(e=>[e,n.getPropertyValue(e).trim()]).filter(e=>""!==e[1])},propSet=(e,n,i,a)=>(n.reduce((e,t,r)=>(r===n.length-1?!a&&e[t]||(e[t]=i):e[t]||(e[t]={}),e[t]),e),e),propsToObject=(e,t,i="",a=!1)=>t=e.reduce((e,[t,r])=>{const n=t.replace("--"+(i?i+"-":""),"");t=n.split("-");return propSet(e,t,r,a),e},t=t||{});let vizzuOptions=null;class Vizzu{static options(e){vizzuOptions=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 AnimControl(e=>{this._resolveAnimate=e},this),this.anim=this.initializing;let r={};vizzuOptions?.wasmUrl&&(r.locateFile=function(e){return e.endsWith(".wasm")?vizzuOptions.wasmUrl:e}),VizzuModule(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){t=parseInt(e,10),t=this.module._vizzu_errorMessage(t),t=this.module.UTF8ToString(t);throw new Error("error: "+t)}}}iterateObject(r,n,i=""){r&&Object.keys(r).forEach(e=>{var t=i+(0===i.length?"":".")+e;null!==r[e]&&"object"==typeof r[e]?this.iterateObject(r[e],n,t):this.setValue(t,r[e],n)})}setNestedProp(r,e,n){let i=e.split(".");i.forEach((e,t)=>{t<i.length-1?(r[e]=r[e]||{},r=r[e]):r[e]=n.startsWith("[")?JSON.parse(n):n})}setValue(e,t,r){if(e!==""+e)throw new Error("first parameter should be string");e=this.toCString(e),t=this.toCString(String(t).toString());try{r(e,t)}finally{this.module._free(t),this.module._free(e)}}setStyle(e){this.iterateObject(e,(e,t)=>{this.call(this.module._style_setValue)(e,t)})}cloneObject(e,t){var r,e=this.call(e)(),e=this.fromCString(e),n={};for(r of JSON.parse(e)){var i=this.toCString(r);try{var a=this.call(t)(i),s=this.fromCString(a);this.setNestedProp(n,r,s)}finally{this.module._free(i)}}return Object.freeze(n),n}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)}setConfig(r){if(null!==r&&"object"==typeof r&&Object.keys(r).forEach(e=>{["color","lightness","size","label","x","y","noop"].includes(e)&&(r.channels=r.channels||{},r.channels[e]=r[e],delete r[e])}),r?.channels){let t=r.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(r,(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();var 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)}_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(t,e){if(t){let e=Object.assign({},t);var r;e.id?this.restore(e):(e.data||void 0!==e.style||e.config||(e={config:e}),this.data.set(e.data),null===e.style&&(e.style={"":null}),t=JSON.parse(JSON.stringify(e.style||{})),r=getCSSCustomPropsForElement(this.container,this._propPrefix),this.setStyle(propsToObject(r,t,this._propPrefix)),this.setConfig(Object.assign({},e.config)))}return this.setAnimation(e),new AnimControl(e=>{let t=this.module.addFunction(()=>{e(this),this.module.removeFunction(t)},"v");this.call(this.module._chart_animate)(t)},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();var 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){var 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(e){this.module=e;e=this.createCanvas();return this.render=new Render,this.module.render=this.render,this.data=new Data(this),this.events=new Events(this),this.module.events=this.events,this.tooltip=new Tooltip(this),this.render.init(this.call(this.module._vizzu_update),e,!1),this.call(this.module._vizzu_init)(),this.call(this.module._vizzu_setLogging)(!1),this.setupDOMEventHandlers(e),this.start(),this}createCanvas(){let e=null,t=this.container;if(t instanceof HTMLCanvasElement?e=t:((e=document.createElement("CANVAS")).style.width="100%",e.style.height="100%",t.appendChild(e)),e instanceof HTMLCanvasElement)return e;throw new Error("Error initializing <canvas> for Vizzu!")}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=>{e=this.getMousePos(e);this.call(this.module._vizzu_mouseMove)(e[0],e[1])}),e.addEventListener("mouseup",e=>{e=this.getMousePos(e);this.call(this.module._vizzu_mouseUp)(e[0],e[1])}),e.addEventListener("mousedown",e=>{e=this.getMousePos(e);this.call(this.module._vizzu_mouseDown)(e[0],e[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",t=>{let r=t.keyCode<=255?t.keyCode:0;var n=[33,34,36,35,37,39,38,40,27,9,13,46];for(let e=0;e<n.length;e++)t.key===n[e]&&(r=256+e);0!==r&&this.call(this.module._vizzu_keyPress)(r,t.ctrlKey,t.altKey,t.shiftKey)})}}export default Vizzu;