UNPKG

57 kBJavaScriptView Raw
1class t extends Error{constructor(t,e){const n=new e.ExceptionInfo(t).get_type(),s=e._vizzu_errorMessage(t,n);super("error: "+e.UTF8ToString(s)),this.name="CError"}}class e{constructor(t,e){this.tt=t,this.et=e}nt(t){const e=4*t.length+1,n=this.tt._malloc(e);return this.tt.stringToUTF8(t,n,e),n}st(t){return this.tt.UTF8ToString(t)}rt(t){return this.et.get(this.it(t))}it(e){return(...n)=>{try{return e(...n)}catch(e){throw"number"==typeof e&&Number.isInteger(e)?new t(e,this.tt):e}}}cObjectParams(){return[this.tt,this.et]}}class n extends e{constructor(t,e){super(...e.cObjectParams()),this.getId=t}ot(t){return this.et.get(this.ht(t))}ht(t){return super.it(t).bind(this,this.getId())}}class s extends n{}class r extends n{animControl(t,e=""){const n=this.nt(t),s=this.nt(e);try{this.ht(this.tt._anim_control)(n,s)}finally{this.tt._free(s),this.tt._free(n)}}storeAnim(){return new s(this.ot(this.tt._chart_anim_store),this)}}class i extends n{constructor(t,e,n){super((()=>e),t),this.stops=this.ct(n)}ct(t){const e=[],n=this.getId();for(let s=0;s<40*t;s+=40)e.push({offset:this.tt.getValue(n+s,"double"),color:"rgba("+255*this.tt.getValue(n+s+8,"double")+","+255*this.tt.getValue(n+s+16,"double")+","+255*this.tt.getValue(n+s+24,"double")+","+this.tt.getValue(n+s+32,"double")+")"});return e}}class o extends n{constructor(t,e){super(e,t)}getColorGradient(t,e){return new i(this,t,e)}getString(t){return this.tt.UTF8ToString(t)}setNumber(t,e){this.tt.setValue(t,e,"double")}}function a(t,e){if(null===t||"object"!=typeof t)return t;if(t instanceof Function)return t;if(Array.isArray(t)&&t instanceof Array)return t.map((t=>a(t,e)));if(e&&t instanceof e)return t;const n={};for(const s in t)s in t&&(n[s]=a(t[s],e));return n}function h(t,e,n=""){t&&null!==t&&"object"==typeof t&&Object.keys(t).forEach((s=>{const r=n+(0===n.length?"":".")+s,i=t[s];null!==i&&"object"==typeof i?h(i,e,r):e(r,i)}))}function c(t,e,n){const s=e.split(".");let r=t;s.forEach(((t,e)=>{if(!function(t){return"object"==typeof t&&null!==t}(r))throw new Error("Expected an object, but got "+typeof r);e<s.length-1?(r[t]=r[t]||("number"==typeof s[e+1]?[]:{}),r=r[t]):r[t]=n}))}class u extends n{constructor(t,e,n,s,r){super(t,e),this.ut=n,this.lt=s,this.ft=r}set(t){h(t,this.setParam.bind(this))}get(){return function(t,e){const n=t(),s={};for(const t of n)c(s,t,e(t));return Object.freeze(s)}(this.listParams.bind(this),this.getParam.bind(this))}listParams(){const t=this.ht(this.ut)(),e=this.st(t);return JSON.parse(e)}getParam(t){const e=this.nt(t);try{const t=this.ht(this.lt)(e),n=this.st(t);return n.startsWith("[")||n.startsWith("{")?JSON.parse(n):n}finally{this.tt._free(e)}}setParam(t,e){const n=this.nt(t),s=this.nt(String(e).toString());try{this.ht(this.ft)(n,s)}finally{this.tt._free(s),this.tt._free(n)}}}class l extends n{}class f extends n{preventDefault(){this.ht(this.tt._event_preventDefault)()}}class d extends u{}class y extends u{}class m extends u{}class p extends n{constructor(t,e){super(e,t),this.config=this.dt(),this.style=this.yt(!1),this.computedStyle=this.yt(!0),this.animOptions=this.gt()}update(t,e,n,s){this.vt=t,this.ht(this.tt._vizzu_update)(t.getId(),e,n,s)}animate(t){const e=this.tt.addFunction((n=>{t(n),this.tt.removeFunction(e)}),"vi");this.ht(this.tt._chart_animate)(e)}storeSnapshot(){return new l(this.ot(this.tt._chart_store),this)}restoreSnapshot(t){this.ht(this.tt._chart_restore)(t.getId())}restoreAnim(t){this.ht(this.tt._chart_anim_restore)(t.getId())}setKeyframe(){this.ht(this.tt._chart_setKeyframe)()}addEventListener(t,e){const n=this.tt.addFunction(((t,n)=>{const s=new f((()=>t),this);e(s,JSON.parse(this.st(n)))}),"vii"),s=this.nt(t);try{this.ht(this.tt._addEventListener)(s,n)}finally{this.tt._free(s)}return n}removeEventListener(t,e){const n=this.nt(t);try{this.ht(this.tt._removeEventListener)(n,e)}finally{this.tt._free(n)}this.tt.removeFunction(e)}pointerdown(t,e,n){this.vt&&this.ht(this.tt._vizzu_pointerDown)(this.vt.getId(),t,e,n)}pointermove(t,e,n){this.vt&&this.ht(this.tt._vizzu_pointerMove)(this.vt.getId(),t,e,n)}pointerup(t,e,n){this.vt&&this.ht(this.tt._vizzu_pointerUp)(this.vt.getId(),t,e,n)}pointerleave(t){this.vt&&this.ht(this.tt._vizzu_pointerLeave)(this.vt.getId(),t)}wheel(t){this.vt&&this.ht(this.tt._vizzu_wheel)(this.vt.getId(),t)}dt(){return new d(this.getId,this,this.tt._chart_getList,this.tt._chart_getValue,this.tt._chart_setValue)}yt(t){return new y(this.getId,this,this.tt._style_getList,((e,n)=>this.tt._style_getValue(e,n,t)),this.tt._style_setValue)}gt(){return new m(this.getId,this,(()=>0),(()=>0),this.tt._anim_setValue)}}class g extends n{constructor(t,e){super((()=>e),t)}getValue(t){const e=this.nt(t);let n,s;try{n=this.ht(this.tt._record_getValue)(e),s=this.tt.getValue(n,"i1")?this.st(this.tt.getValue(n+8,"i8*")):this.tt.getValue(n+8,"double")}finally{this.tt._free(e)}return s}}class v extends n{getMetaInfo(){const t=this.ht(this.tt._data_metaInfo)(),e=this.st(t);return{series:JSON.parse(e)}}addDimension(t,e){const n=new Uint32Array(e.length);for(let t=0;t<e.length;t++){const s=this.nt(e[t]);n[t]=s}const s=4*e.length,r=this.tt._malloc(s);new Uint8Array(this.tt.HEAPU8.buffer,r,s).set(new Uint8Array(n.buffer));const i=this.nt(t);try{this.ht(this.tt._data_addDimension)(i,r,e.length)}finally{this.tt._free(i);for(const t of n)this.tt._free(t);this.tt._free(r)}}addMeasure(t,e,n){const s=new Float64Array(n),r=8*n.length,i=this.tt._malloc(r);new Uint8Array(this.tt.HEAPU8.buffer,i,r).set(new Uint8Array(s.buffer));const o=this.nt(t),a=this.nt(e);try{this.ht(this.tt._data_addMeasure)(o,a,i,n.length)}finally{this.tt._free(o),this.tt._free(a),this.tt._free(i)}}addRecord(t){const e=new Uint32Array(t.length);for(let n=0;n<t.length;n++){const s=this.nt(String(t[n]).toString());e[n]=s}const n=4*t.length,s=this.tt._malloc(n);new Uint8Array(this.tt.HEAPU8.buffer,s,n).set(new Uint8Array(e.buffer));try{this.ht(this.tt._data_addRecord)(s,t.length)}finally{for(const t of e)this.tt._free(t);this.tt._free(s)}}setFilter(t){const e=[0,0];if(null!==t){const n=e=>t(new g(this,e));e[0]=this.tt.addFunction(n,"ii");const s=t=>{t!==e[0]&&console.warn("Wrong pointer passed to destructor"),this.tt.removeFunction(e[0]),this.tt.removeFunction(e[1])};e[1]=this.tt.addFunction(s,"vi")}this.ht(this.tt._chart_setFilter)(...e)}}class w{constructor(t){this.wt=new FinalizationRegistry((e=>{t(e)}))}get(t){const e=t(),n=()=>e;return this.wt.register(n,e),n}}class b extends n{toCanvasCoords(t){const e=this.ht(this.tt._chart_relToCanvasCoords)(t.x,t.y);return this.bt(e)}toRelCoords(t){const e=this.ht(this.tt._chart_canvasToRelCoords)(t.x,t.y);return this.bt(e)}bt(t){return{x:this.tt.getValue(t,"double"),y:this.tt.getValue(t+8,"double")}}}class _ extends e{constructor(t){super(t,new w(t._object_free)),this.tt.canvases={},this.setLogging(!1)}registerRenderer(t,e){this.tt.canvases[t.getId()]=e}version(){return this.tt.UTF8ToString(this.tt._vizzu_version())}setLogging(t){this.it(this.tt._vizzu_setLogging)(t)}getData(t){return new v(t.getId,this)}getCoordSystem(t){return new b(t.getId,this)}getAnimControl(t){return new r(t.getId,this)}createChart(){return new p(this,this.rt(this.tt._vizzu_createChart))}createCanvas(){return new o(this,this.rt(this.tt._vizzu_createCanvas))}}var x,A=(x=import.meta.url,function(t={}){var e,n,s=void 0!==t?t:{};s.ready=new Promise(((t,s)=>{e=t,n=s}));var r=Object.assign({},s),i="";"undefined"!=typeof document&&document.currentScript&&(i=document.currentScript.src),x&&(i=x),i=0!==i.indexOf("blob:")?i.substr(0,i.replace(/[?#].*/,"").lastIndexOf("/")+1):"";var o,a,h=console.log.bind(console),c=console.error.bind(console);Object.assign(s,r),r=null,"object"!=typeof WebAssembly&&S("no native wasm support detected");var u,l,f,d,y,m,p,g,v,w=!1;function b(){var t=a.buffer;s.HEAP8=u=new Int8Array(t),s.HEAP16=f=new Int16Array(t),s.HEAP32=y=new Int32Array(t),s.HEAPU8=l=new Uint8Array(t),s.HEAPU16=d=new Uint16Array(t),s.HEAPU32=m=new Uint32Array(t),s.HEAPF32=p=new Float32Array(t),s.HEAPF64=g=new Float64Array(t)}var _=[],A=[],k=[],B=0,C=null;function S(t){c(t="Aborted("+t+")"),w=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}var E,T,j="data:application/octet-stream;base64,";function P(t){return t.startsWith(j)}function z(t){try{if(t==E&&o)return new Uint8Array(o);throw"both async and sync fetching of the wasm failed"}catch(t){S(t)}}function O(t,e,n){return function(t){return"function"==typeof fetch?fetch(t,{credentials:"same-origin"}).then((e=>{if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()})).catch((()=>z(t))):Promise.resolve().then((()=>z(t)))}(t).then((t=>WebAssembly.instantiate(t,e))).then((t=>t)).then(n,(t=>{c("failed to asynchronously prepare wasm: "+t),S(t)}))}function W(t){for(;t.length>0;)t.shift()(s)}function F(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){m[this.ptr+4>>2]=t},this.get_type=function(){return m[this.ptr+4>>2]},this.set_destructor=function(t){m[this.ptr+8>>2]=t},this.get_destructor=function(){return m[this.ptr+8>>2]},this.set_caught=function(t){t=t?1:0,u[this.ptr+12>>0]=t},this.get_caught=function(){return 0!=u[this.ptr+12>>0]},this.set_rethrown=function(t){t=t?1:0,u[this.ptr+13>>0]=t},this.get_rethrown=function(){return 0!=u[this.ptr+13>>0]},this.init=function(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)},this.set_adjusted_ptr=function(t){m[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return m[this.ptr+16>>2]},this.get_exception_ptr=function(){if(Ct(this.get_type()))return m[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function U(t){switch(t){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${t}`)}}s.locateFile?P(E="cvizzu.wasm")||(T=E,E=s.locateFile?s.locateFile(T,i):i+T):E=new URL("cvizzu.wasm",import.meta.url).href;var D=void 0;function I(t){for(var e="",n=t;l[n];)e+=D[l[n++]];return e}var R={},M={},N=48,L=57;function V(t,e){return{[t=function(t){if(void 0===t)return"_unknown";var e=(t=t.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return e>=N&&e<=L?`_${t}`:t}(t)]:function(){return e.apply(this,arguments)}}[t]}function $(t,e){var n=V(e,(function(t){this.name=e,this.message=t;var n=new Error(t).stack;void 0!==n&&(this.stack=this.toString()+"\n"+n.replace(/^Error(:[^\n]*)?\n/,""))}));return n.prototype=Object.create(t.prototype),n.prototype.constructor=n,n.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},n}var H=void 0;function q(t){throw new H(t)}function K(t,e,n={}){if(!("argPackAdvance"in e))throw new TypeError("registerType registeredInstance requires argPackAdvance");var s=e.name;if(t||q(`type "${s}" must have a positive integer typeid pointer`),M.hasOwnProperty(t)){if(n.ignoreDuplicateRegistrations)return;q(`Cannot register type '${s}' twice`)}if(M[t]=e,R.hasOwnProperty(t)){var r=R[t];delete R[t],r.forEach((t=>t()))}}var G=new function(){this.allocated=[void 0],this.freelist=[],this.get=function(t){return this.allocated[t]},this.has=function(t){return void 0!==this.allocated[t]},this.allocate=function(t){var e=this.freelist.pop()||this.allocated.length;return this.allocated[e]=t,e},this.free=function(t){this.allocated[t]=void 0,this.freelist.push(t)}};function J(){for(var t=0,e=G.reserved;e<G.allocated.length;++e)void 0!==G.allocated[e]&&++t;return t}var Q=t=>(t||q("Cannot use deleted val. handle = "+t),G.get(t).value),Y=t=>{switch(t){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return G.allocate({refcount:1,value:t})}};function Z(t){return this.fromWireType(y[t>>2])}function X(t,e){switch(e){case 2:return function(t){return this.fromWireType(p[t>>2])};case 3:return function(t){return this.fromWireType(g[t>>3])};default:throw new TypeError("Unknown float type: "+t)}}function tt(t,e,n){switch(e){case 0:return n?function(t){return u[t]}:function(t){return l[t]};case 1:return n?function(t){return f[t>>1]}:function(t){return d[t>>1]};case 2:return n?function(t){return y[t>>2]}:function(t){return m[t>>2]};default:throw new TypeError("Unknown integer type: "+t)}}function et(t,e,n){return function(t,e,n,s){if(!(s>0))return 0;for(var r=n,i=n+s-1,o=0;o<t.length;++o){var a=t.charCodeAt(o);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&t.charCodeAt(++o)),a<=127){if(n>=i)break;e[n++]=a}else if(a<=2047){if(n+1>=i)break;e[n++]=192|a>>6,e[n++]=128|63&a}else if(a<=65535){if(n+2>=i)break;e[n++]=224|a>>12,e[n++]=128|a>>6&63,e[n++]=128|63&a}else{if(n+3>=i)break;e[n++]=240|a>>18,e[n++]=128|a>>12&63,e[n++]=128|a>>6&63,e[n++]=128|63&a}}return e[n]=0,n-r}(t,l,e,n)}var nt="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function st(t,e,n){for(var s=e+n,r=e;t[r]&&!(r>=s);)++r;if(r-e>16&&t.buffer&&nt)return nt.decode(t.subarray(e,r));for(var i="";e<r;){var o=t[e++];if(128&o){var a=63&t[e++];if(192!=(224&o)){var h=63&t[e++];if((o=224==(240&o)?(15&o)<<12|a<<6|h:(7&o)<<18|a<<12|h<<6|63&t[e++])<65536)i+=String.fromCharCode(o);else{var c=o-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&o)<<6|a)}else i+=String.fromCharCode(o)}return i}function rt(t,e){return t?st(l,t,e):""}var it,ot="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function at(t,e){for(var n=t,s=n>>1,r=s+e/2;!(s>=r)&&d[s];)++s;if((n=s<<1)-t>32&&ot)return ot.decode(l.subarray(t,n));for(var i="",o=0;!(o>=e/2);++o){var a=f[t+2*o>>1];if(0==a)break;i+=String.fromCharCode(a)}return i}function ht(t,e,n){if(void 0===n&&(n=2147483647),n<2)return 0;for(var s=e,r=(n-=2)<2*t.length?n/2:t.length,i=0;i<r;++i){var o=t.charCodeAt(i);f[e>>1]=o,e+=2}return f[e>>1]=0,e-s}function ct(t){return 2*t.length}function ut(t,e){for(var n=0,s="";!(n>=e/4);){var r=y[t+4*n>>2];if(0==r)break;if(++n,r>=65536){var i=r-65536;s+=String.fromCharCode(55296|i>>10,56320|1023&i)}else s+=String.fromCharCode(r)}return s}function lt(t,e,n){if(void 0===n&&(n=2147483647),n<4)return 0;for(var s=e,r=s+n-4,i=0;i<t.length;++i){var o=t.charCodeAt(i);if(o>=55296&&o<=57343&&(o=65536+((1023&o)<<10)|1023&t.charCodeAt(++i)),y[e>>2]=o,(e+=4)+4>r)break}return y[e>>2]=0,e-s}function ft(t){for(var e=0,n=0;n<t.length;++n){var s=t.charCodeAt(n);s>=55296&&s<=57343&&++n,e+=4}return e}function dt(t){var e=t-a.buffer.byteLength+65535>>>16;try{return a.grow(e),b(),1}catch(t){}}it=()=>performance.now();var yt=[null,[],[]];function mt(t,e){t<128?e.push(t):e.push(t%128|128,t>>7)}function pt(t,e){if("function"==typeof WebAssembly.Function)return new WebAssembly.Function(function(t){for(var e={i:"i32",j:"i64",f:"f32",d:"f64",p:"i32"},n={parameters:[],results:"v"==t[0]?[]:[e[t[0]]]},s=1;s<t.length;++s)n.parameters.push(e[t[s]]);return n}(e),t);var n=[1];!function(t,e){var n=t.slice(0,1),s=t.slice(1),r={i:127,p:127,j:126,f:125,d:124};e.push(96),mt(s.length,e);for(var i=0;i<s.length;++i)e.push(r[s[i]]);"v"==n?e.push(0):e.push(1,r[n])}(e,n);var s=[0,97,115,109,1,0,0,0,1];mt(n.length,s),s.push.apply(s,n),s.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var r=new WebAssembly.Module(new Uint8Array(s));return new WebAssembly.Instance(r,{e:{f:t}}).exports.f}function gt(t){return v.get(t)}var vt=void 0;function wt(t){return vt||(vt=new WeakMap,function(t,e){if(vt)for(var n=t;n<t+e;n++){var s=gt(n);s&&vt.set(s,n)}}(0,v.length)),vt.get(t)||0}var bt=[];function _t(t,e){v.set(t,e)}!function(){for(var t=new Array(256),e=0;e<256;++e)t[e]=String.fromCharCode(e);D=t}(),H=s.BindingError=$(Error,"BindingError"),s.InternalError=$(Error,"InternalError"),G.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),G.reserved=G.allocated.length,s.count_emval_handles=J;var xt={a:function(t,e,n){throw new F(t).init(e,n),t},n:function(t,e,n,s,r){},v:function(t,e,n,s,r){var i=U(n);K(t,{name:e=I(e),fromWireType:function(t){return!!t},toWireType:function(t,e){return e?s:r},argPackAdvance:8,readValueFromPointer:function(t){var s;if(1===n)s=u;else if(2===n)s=f;else{if(4!==n)throw new TypeError("Unknown boolean type size: "+e);s=y}return this.fromWireType(s[t>>i])},destructorFunction:null})},u:function(t,e){K(t,{name:e=I(e),fromWireType:function(t){var e=Q(t);return function(t){t>=G.reserved&&0==--G.get(t).refcount&&G.free(t)}(t),e},toWireType:function(t,e){return Y(e)},argPackAdvance:8,readValueFromPointer:Z,destructorFunction:null})},f:function(t,e,n){var s=U(n);K(t,{name:e=I(e),fromWireType:function(t){return t},toWireType:function(t,e){return e},argPackAdvance:8,readValueFromPointer:X(e,s),destructorFunction:null})},c:function(t,e,n,s,r){e=I(e);var i=U(n),o=t=>t;if(0===s){var a=32-8*n;o=t=>t<<a>>>a}var h=e.includes("unsigned");K(t,{name:e,fromWireType:o,toWireType:h?function(t,e){return this.name,e>>>0}:function(t,e){return this.name,e},argPackAdvance:8,readValueFromPointer:tt(e,i,0!==s),destructorFunction:null})},b:function(t,e,n){var s=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][e];function r(t){var e=m,n=e[t>>=2],r=e[t+1];return new s(e.buffer,r,n)}K(t,{name:n=I(n),fromWireType:r,argPackAdvance:8,readValueFromPointer:r},{ignoreDuplicateRegistrations:!0})},g:function(t,e){var n="std::string"===(e=I(e));K(t,{name:e,fromWireType:function(t){var e,s=m[t>>2],r=t+4;if(n)for(var i=r,o=0;o<=s;++o){var a=r+o;if(o==s||0==l[a]){var h=rt(i,a-i);void 0===e?e=h:(e+=String.fromCharCode(0),e+=h),i=a+1}}else{var c=new Array(s);for(o=0;o<s;++o)c[o]=String.fromCharCode(l[r+o]);e=c.join("")}return Bt(t),e},toWireType:function(t,e){var s;e instanceof ArrayBuffer&&(e=new Uint8Array(e));var r="string"==typeof e;r||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||q("Cannot pass non-string to std::string"),s=n&&r?function(t){for(var e=0,n=0;n<t.length;++n){var s=t.charCodeAt(n);s<=127?e++:s<=2047?e+=2:s>=55296&&s<=57343?(e+=4,++n):e+=3}return e}(e):e.length;var i=kt(4+s+1),o=i+4;if(m[i>>2]=s,n&&r)et(e,o,s+1);else if(r)for(var a=0;a<s;++a){var h=e.charCodeAt(a);h>255&&(Bt(o),q("String has UTF-16 code units that do not fit in 8 bits")),l[o+a]=h}else for(a=0;a<s;++a)l[o+a]=e[a];return null!==t&&t.push(Bt,i),i},argPackAdvance:8,readValueFromPointer:Z,destructorFunction:function(t){Bt(t)}})},e:function(t,e,n){var s,r,i,o,a;n=I(n),2===e?(s=at,r=ht,o=ct,i=()=>d,a=1):4===e&&(s=ut,r=lt,o=ft,i=()=>m,a=2),K(t,{name:n,fromWireType:function(t){for(var n,r=m[t>>2],o=i(),h=t+4,c=0;c<=r;++c){var u=t+4+c*e;if(c==r||0==o[u>>a]){var l=s(h,u-h);void 0===n?n=l:(n+=String.fromCharCode(0),n+=l),h=u+e}}return Bt(t),n},toWireType:function(t,s){"string"!=typeof s&&q(`Cannot pass non-string to C++ string type ${n}`);var i=o(s),h=kt(4+i+e);return m[h>>2]=i>>a,r(s,h+4,i+e),null!==t&&t.push(Bt,h),h},argPackAdvance:8,readValueFromPointer:Z,destructorFunction:function(t){Bt(t)}})},w:function(t,e){K(t,{isVoid:!0,name:e=I(e),argPackAdvance:0,fromWireType:function(){},toWireType:function(t,e){}})},t:function(){return!0},d:function(){S("")},K:function(t,e,n,r,i,o,a){s.canvases[t].addBezier(e,n,r,i,o,a)},L:function(t,e,n){s.canvases[t].addPoint(e,n)},R:function(t){s.canvases[t].beginDropShadow()},M:function(t){s.canvases[t].beginPolygon()},G:function(t,e,n,r){s.canvases[t].circle(e,n,r)},N:function(t){s.canvases[t].endDropShadow()},J:function(t){s.canvases[t].endPolygon()},B:function(t){s.canvases[t].frameBegin()},C:function(t){s.canvases[t].frameEnd()},F:function(t,e,n,r,i){s.canvases[t].line(e,n,r,i)},H:function(t,e,n,r,i){s.canvases[t].rectangle(e,n,r,i)},y:function(t){s.canvases[t].restore()},z:function(t){s.canvases[t].save()},j:function(t,e,n,r,i){s.canvases[t].setBrushColor(e,n,r,i)},D:function(t,e,n,r,i,o,a){s.canvases[t].setBrushGradient(e,n,r,i,o,a)},l:function(t,e,n,r){s.canvases[t].setClipCircle(e,n,r)},k:function(t){s.canvases[t].setClipPolygon()},r:function(t,e,n,r,i){s.canvases[t].setClipRect(e,n,r,i)},T:function(t,e){s.canvases[t].setCursor(e)},Q:function(t,e){s.canvases[t].setDropShadowBlur(e)},P:function(t,e,n,r,i){s.canvases[t].setDropShadowColor(e,n,r,i)},O:function(t,e,n){s.canvases[t].setDropShadowOffset(e,n)},S:function(t,e){s.canvases[t].setFont(e)},i:function(t,e,n,r,i){s.canvases[t].setLineColor(e,n,r,i)},h:function(t,e){s.canvases[t].setLineWidth(e)},E:function(t,e,n,r,i,o){s.canvases[t].text(e,n,r,i,o)},x:function(t,e,n,r){s.canvases[t].textBoundary(e,n,r)},A:function(t,e,n,r,i,o,a){s.canvases[t].transform(e,n,r,i,o,a)},s:it,p:function(t){var e=l.length,n=2147483648;if((t>>>=0)>n)return!1;for(var s,r,i=1;i<=4;i*=2){var o=e*(1+.2/i);if(o=Math.min(o,t+100663296),dt(Math.min(n,(s=Math.max(t,o))+((r=65536)-s%r)%r)))return!0}return!1},o:function(t){return 52},m:function(t,e,n,s,r){return 70},q:function(t,e,n,s){for(var r,i,o,a=0,u=0;u<n;u++){var f=m[e>>2],d=m[e+4>>2];e+=8;for(var y=0;y<d;y++)r=t,i=l[f+y],o=void 0,o=yt[r],0===i||10===i?((1===r?h:c)(st(o,0)),o.length=0):o.push(i);a+=d}return m[s>>2]=a,0},I:function(t){window.open(rt(t),"_blank")}};!function(){var t,e,r,i;function h(t,e){var n,r=t.exports;return s.asm=r,a=s.asm.U,b(),v=s.asm.Ga,n=s.asm.V,A.unshift(n),function(t){if(0==--B&&C){var e=C;C=null,e()}}(),r}B++,(t=o,e=E,r={a:xt},i=function(t){h(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||P(e)||"function"!=typeof fetch?O(e,r,i):fetch(e,{credentials:"same-origin"}).then((t=>WebAssembly.instantiateStreaming(t,r).then(i,(function(t){return c("wasm streaming compile failed: "+t),c("falling back to ArrayBuffer instantiation"),O(e,r,i)}))))).catch(n)}(),s._vizzu_errorMessage=function(){return(s._vizzu_errorMessage=s.asm.W).apply(null,arguments)},s._vizzu_version=function(){return(s._vizzu_version=s.asm.X).apply(null,arguments)},s._vizzu_setLogging=function(){return(s._vizzu_setLogging=s.asm.Y).apply(null,arguments)},s._vizzu_createChart=function(){return(s._vizzu_createChart=s.asm.Z).apply(null,arguments)},s._vizzu_createCanvas=function(){return(s._vizzu_createCanvas=s.asm._).apply(null,arguments)},s._vizzu_pointerMove=function(){return(s._vizzu_pointerMove=s.asm.$).apply(null,arguments)},s._vizzu_pointerDown=function(){return(s._vizzu_pointerDown=s.asm.aa).apply(null,arguments)},s._vizzu_pointerUp=function(){return(s._vizzu_pointerUp=s.asm.ba).apply(null,arguments)},s._vizzu_pointerLeave=function(){return(s._vizzu_pointerLeave=s.asm.ca).apply(null,arguments)},s._vizzu_wheel=function(){return(s._vizzu_wheel=s.asm.da).apply(null,arguments)},s._vizzu_update=function(){return(s._vizzu_update=s.asm.ea).apply(null,arguments)},s._style_getList=function(){return(s._style_getList=s.asm.fa).apply(null,arguments)},s._style_setValue=function(){return(s._style_setValue=s.asm.ga).apply(null,arguments)},s._style_getValue=function(){return(s._style_getValue=s.asm.ha).apply(null,arguments)},s._chart_store=function(){return(s._chart_store=s.asm.ia).apply(null,arguments)},s._chart_restore=function(){return(s._chart_restore=s.asm.ja).apply(null,arguments)},s._chart_anim_store=function(){return(s._chart_anim_store=s.asm.ka).apply(null,arguments)},s._chart_anim_restore=function(){return(s._chart_anim_restore=s.asm.la).apply(null,arguments)},s._object_free=function(){return(s._object_free=s.asm.ma).apply(null,arguments)},s._chart_getList=function(){return(s._chart_getList=s.asm.na).apply(null,arguments)},s._chart_getValue=function(){return(s._chart_getValue=s.asm.oa).apply(null,arguments)},s._chart_setValue=function(){return(s._chart_setValue=s.asm.pa).apply(null,arguments)},s._chart_setFilter=function(){return(s._chart_setFilter=s.asm.qa).apply(null,arguments)},s._record_getValue=function(){return(s._record_getValue=s.asm.ra).apply(null,arguments)},s._data_addDimension=function(){return(s._data_addDimension=s.asm.sa).apply(null,arguments)},s._data_addMeasure=function(){return(s._data_addMeasure=s.asm.ta).apply(null,arguments)},s._data_addRecord=function(){return(s._data_addRecord=s.asm.ua).apply(null,arguments)},s._data_metaInfo=function(){return(s._data_metaInfo=s.asm.va).apply(null,arguments)},s._addEventListener=function(){return(s._addEventListener=s.asm.wa).apply(null,arguments)},s._removeEventListener=function(){return(s._removeEventListener=s.asm.xa).apply(null,arguments)},s._event_preventDefault=function(){return(s._event_preventDefault=s.asm.ya).apply(null,arguments)},s._chart_animate=function(){return(s._chart_animate=s.asm.za).apply(null,arguments)},s._chart_relToCanvasCoords=function(){return(s._chart_relToCanvasCoords=s.asm.Aa).apply(null,arguments)},s._chart_canvasToRelCoords=function(){return(s._chart_canvasToRelCoords=s.asm.Ba).apply(null,arguments)},s._chart_setKeyframe=function(){return(s._chart_setKeyframe=s.asm.Ca).apply(null,arguments)},s._anim_control=function(){return(s._anim_control=s.asm.Da).apply(null,arguments)},s._anim_setValue=function(){return(s._anim_setValue=s.asm.Ea).apply(null,arguments)},s.__embind_initialize_bindings=function(){return(s.__embind_initialize_bindings=s.asm.Fa).apply(null,arguments)};var At,kt=s._malloc=function(){return(kt=s._malloc=s.asm.Ha).apply(null,arguments)},Bt=s._free=function(){return(Bt=s._free=s.asm.Ia).apply(null,arguments)},Ct=function(){return(Ct=s.asm.Ja).apply(null,arguments)};function St(){B>0||(W(_),B>0||At||(At=!0,s.calledRun=!0,w||(W(A),e(s),W(k))))}return s.addFunction=function(t,e){var n=wt(t);if(n)return n;var s=function(){if(bt.length)return bt.pop();try{v.grow(1)}catch(t){if(!(t instanceof RangeError))throw t;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."}return v.length-1}();try{_t(s,t)}catch(n){if(!(n instanceof TypeError))throw n;_t(s,pt(t,e))}return vt.set(t,s),s},s.removeFunction=function(t){vt.delete(gt(t)),bt.push(t)},s.setValue=function(t,e,n="i8"){switch(n.endsWith("*")&&(n="*"),n){case"i1":case"i8":u[t>>0]=e;break;case"i16":f[t>>1]=e;break;case"i32":y[t>>2]=e;break;case"i64":S("to do setValue(i64) use WASM_BIGINT");case"float":p[t>>2]=e;break;case"double":g[t>>3]=e;break;case"*":m[t>>2]=e;break;default:S(`invalid type for setValue: ${n}`)}},s.getValue=function(t,e="i8"){switch(e.endsWith("*")&&(e="*"),e){case"i1":case"i8":return u[t>>0];case"i16":return f[t>>1];case"i32":return y[t>>2];case"i64":S("to do getValue(i64) use WASM_BIGINT");case"float":return p[t>>2];case"double":return g[t>>3];case"*":return m[t>>2];default:S(`invalid type for getValue: ${e}`)}},s.UTF8ToString=rt,s.stringToUTF8=et,s.ExceptionInfo=F,C=function t(){At||St(),At||(C=t)},St(),t.ready});const k=new class{constructor(){this._t={},this.xt=null}set options(t){this._t={...this._t,...t}}get options(){return this._t}initialize(){return this.xt||(this.xt=this.At()),this.xt}async At(){return new _(await A(this.kt()))}kt(){const t={};if(this._t?.wasmUrl){const e=this._t.wasmUrl;t.locateFile=t=>t.endsWith(".wasm")?e:t}return t}};class B{constructor(t){this.meta={name:"coordSystem"},this.api={toCanvas:t=>this.Bt.toCanvasCoords(t),toRelative:t=>this.Bt.toRelCoords(t)},this.Bt=t}}const C=t=>{try{return t.cssRules,!0}catch(t){return!1}},S=(t,e="")=>{const n=((t="")=>[...document.styleSheets].filter(C).reduce(((e,n)=>e.concat([...n.cssRules].filter((t=>"CSSStyleRule"===t.constructor.name)).reduce(((e,n)=>[...e,...[...n.style].filter((e=>0===e.trim().indexOf("--"+t+"-"))).map((t=>t.trim()))]),[]))),[]))(e),s=getComputedStyle(t);return n.map((t=>[t,s.getPropertyValue(t).trim()])).filter((t=>""!==t[1]))};class E{constructor(t={}){this.meta={name:"cssProperties",depends:["htmlCanvas"]},this.api={prefix:"vizzu"},t?.prefix&&(this.api.prefix=t.prefix)}get hooks(){return{prepareAnimation:(t,e)=>{const n=S(this.Ct.feature.htmlCanvas.element,this.api.prefix);Array.isArray(t.target)&&t.target.forEach((({target:t})=>{t instanceof l||(t.style=((t,e,n="",s=!1)=>(e=e||{},e=t.reduce(((t,[e,r])=>(e&&((t,e,n,s)=>{e.reduce(((t,r,i)=>(i===e.length-1?!s&&t[r]||(t[r]=n):t[r]||(t[r]={}),t[r])),t)})(t,e.replace("--"+(n?n+"-":""),"").split("-"),r,s),t)),e),e))(n,t.style,this.api.prefix))})),e()}}}register(t){this.Ct=t}}class T{constructor(t){this.meta={name:"logging"},this.St=t}enable(t){this.St(t)}}const j=(t,e)=>{if(!t)throw new Error("Assert failed: "+e)},P=(t,e,n)=>{j(Array.isArray(e),"array is not a list");try{if(e.length!==t.dimensions[n].values.length)throw new Error("Assert failed")}catch(t){j(!1,"dimensions are not the same")}e.forEach((e=>{Array.isArray(e)&&P(t,e,n-1)}))};class z{static isPivot(t){return void 0!==t&&("dimensions"in t&&void 0!==t.dimensions||"measures"in t&&void 0!==t.measures)}static convert(t){j("object"==typeof t&&null!==t&&!Array.isArray(t),"data is not an object"),j("dimensions"in t,"data.dimensions is requreid"),j("measures"in t,"data.measures is requreid");const e=(({dimensions:t,measures:e,...n})=>Object.assign(n,{series:[]}))(t);let n=1;j(Array.isArray(t.dimensions),"data.dimensions is not a list");for(let e=0;e<t.dimensions.length;e++){const s=t.dimensions[e];j("object"==typeof s&&null!==s&&!Array.isArray(s),"data.dimensions.item is not an object"),j("name"in s,"data.dimensions.item.name is requreid"),j(void 0===s.type||"dimension"===s.type,"data.dimensions.item.type is invalid"),j("values"in s,"data.dimensions.item.values is requreid"),j(Array.isArray(s.values),"data.dimensions.item.values is not a list"),j(0!==s.values.length,"data.dimensions.item.values length is zero"),n*=s.values.length}let s=1;for(let r=0;r<t.dimensions.length;r++){const i=t.dimensions[r];let o=[];const a=[];i.values.forEach((t=>{for(let e=1;e<=s;e++)a.push(t)})),s*=i.values.length;for(let t=1;t<=n/s;t++)o=o.concat(a);const h={name:i.name,type:i.type||"dimension",values:o};e.series.push(h)}j("object"==typeof t.measures&&null!==t.measures,"data.measures is not a list or an object"),Array.isArray(t.measures)||(t.measures=[t.measures]);for(let s=0;s<t.measures.length;s++){const r=t.measures[s];j("object"==typeof r&&null!==r&&!Array.isArray(r),"data.measures.item is not an object"),j("name"in r,"data.measures.item.name is requreid"),j("values"in r,"data.measures.item.values is requreid"),j(Array.isArray(r.values),"data.measures.item.values is not a list"),P(t,r.values,t.dimensions.length-1);const i={name:r.name,type:r.type,values:r.values.flat(1/0)};void 0===i.type&&delete i.type,j(i.values.length===n,"dimensions are not the same"),e.series.push(i)}return e}}class O{constructor(){this.meta={name:"pivotData"}}get hooks(){return{prepareAnimation:(t,e)=>{Array.isArray(t.target)&&t.target.forEach((({target:t})=>{if(!(t instanceof l)&&t.data&&t.data&&z.isPivot(t.data)){if(O.Et(t.data))throw new Error("inconsistent data form: series/records and dimensions/measures are both set.");t.data=z.convert(t.data)}})),e()}}}static Et(t){return"series"in t||"records"in t}}class W extends Error{constructor(){super("animation canceled"),this.name="CancelError"}}class F extends Error{constructor(){super("vizzu is not initialized, use `initializing` promise"),this.name="NotInitializedError"}}class U{constructor(t){this.Tt=!1,this.meta={name:"pointerEvents",depends:["htmlCanvas"]},this.jt={pointermove:e=>{this.Pt(e,t.pointermove.bind(t))},pointerup:e=>{this.Pt(e,t.pointerup.bind(t))},pointerdown:e=>{this.Pt(e,t.pointerdown.bind(t))},pointerleave:e=>{this.Pt(e,t.pointerleave.bind(t))},wheel:e=>{this.Pt(e,t.wheel.bind(t),"deltaY")}}}register(t){this.zt=t,this.Ot=this.zt?.feature.htmlCanvas}unregister(){this.Tt&&this.Wt()}enable(t){this.Tt=t,t?this.Ft():this.Wt()}Ft(){if(!this.zt||!this.jt)throw new F;this.Ut=this.zt.feature.htmlCanvas.element;for(const[t,e]of Object.entries(this.jt))this.Ut.addEventListener(t,e)}Wt(){if(this.jt&&this.Ut)for(const[t,e]of Object.entries(this.jt))this.Ut.removeEventListener(t,e);delete this.Ut}Pt(t,e,n="pointerId"){const s=[t[n]];void 0!==t.clientX&&s.push(...this.Dt(t)),e(...s)}Dt(t){const e={x:t.clientX,y:t.clientY};if(!this.Ot)throw new F;const n=this.Ot.clientToCanvas(e);return[n.x,n.y]}}class D{get api(){return{update:()=>{this.updateFrame(!0)}}}enable(t){this.Tt=t}constructor(t,e,n){this.It=1,this.meta={name:"rendering"},this.Ut=n,this.Ut.onchange=()=>{this.updateFrame(!0)},this.Tt=!0,this.Rt=!1,this.Mt=e,this.Nt=t.createCanvas(),t.registerRenderer(this.Nt,this)}updateFrame(t=!1){const e=this.Ut.calcSize();if(e.x>=1&&e.y>=1){const n=this.Tt?t?1:0:2;this.Mt.update(this.Nt,e.x,e.y,n)}}setCursor(t){this.Ut.element.style.cursor=this.Nt.getString(t)}frameBegin(){this.It=1,this.Ut.frameBegin()}frameEnd(){this.Ut.frameEnd()}setClipRect(t,e,n,s){const r=this.Ut.context;r.beginPath(),r.rect(t,e,n,s),r.clip()}setClipCircle(t,e,n){const s=this.Ut.context;s.beginPath(),s.arc(t,e,n,0,6.28318530718),s.clip()}setClipPolygon(){const t=this.Ut.context;t.closePath(),t.clip(),this.Rt=!1}setBrushColor(t,e,n,s){this.Ut.context.fillStyle="rgba("+255*t+","+255*e+","+255*n+","+s+")"}setLineColor(t,e,n,s){this.Ut.context.strokeStyle="rgba("+255*t+","+255*e+","+255*n+","+s+")"}setLineWidth(t){this.Ut.context.lineWidth=t,this.It=t}setFont(t){this.Ut.context.font=this.Nt.getString(t)}beginDropShadow(){}setDropShadowBlur(t){this.Ut.context.shadowBlur=t}setDropShadowColor(t,e,n,s){this.Ut.context.shadowColor="rgba("+255*t+","+255*e+","+255*n+","+s+")"}setDropShadowOffset(t,e){const n=this.Ut.context;n.shadowOffsetX=t,n.shadowOffsetY=e}endDropShadow(){const t=this.Ut.context;t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowColor="rgba(0, 0, 0, 0)"}beginPolygon(){this.Ut.context.beginPath()}addPoint(t,e){const n=this.Ut.context;this.Rt?n.lineTo(t,e):n.moveTo(t,e),this.Rt=!0}addBezier(t,e,n,s,r,i){this.Ut.context.bezierCurveTo(t,e,n,s,r,i)}endPolygon(){const t=this.Ut.context;t.closePath(),t.fill(),0!==this.It&&t.stroke(),this.Rt=!1}rectangle(t,e,n,s){const r=this.Ut.context;r.beginPath(),r.rect(t,e,n,s),r.fill(),0!==this.It&&r.stroke()}circle(t,e,n){const s=this.Ut.context;s.beginPath(),s.arc(t,e,n,0,6.28318530718),s.fill(),0!==this.It&&s.stroke()}line(t,e,n,s){const r=this.Ut.context;r.beginPath(),r.moveTo(t,e),r.lineTo(n,s),0!==this.It&&r.stroke()}textBoundary(t,e,n){const s=this.Ut.context;let r=s.measureText(this.Nt.getString(t));const i=r.width;r=s.measureText("Op");const o=r.actualBoundingBoxAscent+r.actualBoundingBoxDescent;this.Nt.setNumber(e,i),this.Nt.setNumber(n,o)}text(t,e,n,s,r){const i=this.Ut.context;i.textAlign="left",i.textBaseline="top",t+=n<0?-n:0,e+=s<0?-s:0,i.fillText(this.Nt.getString(r),t,e)}setBrushGradient(t,e,n,s,r,i){const o=this.Ut.context,a=o.createLinearGradient(t,e,n,s);this.Nt.getColorGradient(i,r).stops.forEach((t=>a.addColorStop(t.offset,t.color))),o.fillStyle=a}transform(t,e,n,s,r,i){this.Ut.context.transform(t,e,n,s,r,i)}save(){this.Ut.context.save()}restore(){this.Ut.context.restore()}}class I{constructor(t){return new Proxy(this,{get:(e,n)=>t.getValue(n)})}}class R{constructor(t){this.Lt=t}set(t){if(t){if(t.series){if(!Array.isArray(t.series))throw new Error("data series field is not an array");for(const e of t.series)this.Vt(e)}if("records"in t){if(!Array.isArray(t.records))throw new Error("data records field is not an array");const e=this.Lt.getMetaInfo().series;for(const n of t.records)this.$t(n,e)}(t.filter||null===t.filter)&&this.Ht(t.filter)}}$t(t,e){if(!Array.isArray(t)){if("object"!=typeof t||null===t)throw new Error("data record is not an array or object");t=this.qt(t,e)}this.Lt.addRecord(t)}qt(t,e){const n=[];return e.forEach((e=>{e.name in t?n.push(t[e.name]||this.Kt(e.type)):n.push(this.Kt(e.type))})),n}Kt(t){return"measure"===t?0:""}Vt(t){if(!t.name)throw new Error("missing series name");const e=t.values?t.values:[],n=t.type?t.type:this.Gt(e);if("dimension"===n)this.Jt(t.name,e);else{if("measure"!==n)throw new Error("invalid series type: "+t.type);t.unit||(t.unit=""),this.Qt(t.name,t.unit,e)}}Gt(t){if(Array.isArray(t)&&t.length){if("number"==typeof t[0])return"measure";if("string"==typeof t[0])return"dimension"}return null}Jt(t,e){if("string"!=typeof t)throw new Error("first parameter should be string");if(!(e instanceof Array))throw new Error("second parameter should be an array");if(!this.Yt(e))throw new Error("array element should be string");this.Lt.addDimension(t,e)}Yt(t){for(const e of t)if("string"!=typeof e)return!1;return!0}Qt(t,e,n){if("string"!=typeof t)throw new Error("'name' parameter should be string");if("string"!=typeof e)throw new Error("'unit' parameter should be string");if(!(n instanceof Array))throw new Error("'values' parameter should be an array");const s=n.map((t=>Number(t)));this.Lt.addMeasure(t,e,s)}Ht(t){if("function"==typeof t){const e=e=>t(new I(e));this.Lt.setFilter(e)}else{if(null!==t)throw new Error("data filter is not a function or null");this.Lt.setFilter(null)}}}var M;!function(t){t.click="click",t.pointermove="pointermove",t.pointerdown="pointerdown",t.pointerup="pointerup",t.pointerleave="pointerleave",t.wheel="wheel",t.update="update",t.drawBegin="draw-begin",t.drawComplete="draw-complete",t.backgroundDraw="background-draw",t.titleDraw="title-draw",t.subtitleDraw="subtitle-draw",t.captionDraw="caption-draw",t.logoDraw="logo-draw",t.legendBackgroundDraw="legend-background-draw",t.legendTitleDraw="legend-title-draw",t.legendLabelDraw="legend-label-draw",t.legendMarkerDraw="legend-marker-draw",t.legendBarDraw="legend-bar-draw",t.plotBackgroundDraw="plot-background-draw",t.plotAreaDraw="plot-area-draw",t.plotMarkerDraw="plot-marker-draw",t.plotMarkerLabelDraw="plot-marker-label-draw",t.plotMarkerGuideDraw="plot-marker-guide-draw",t.plotAxisDraw="plot-axis-draw",t.plotAxisTitleDraw="plot-axis-title-draw",t.plotAxisLabelDraw="plot-axis-label-draw",t.plotAxisTickDraw="plot-axis-tick-draw",t.plotAxisGuideDraw="plot-axis-guide-draw",t.plotAxisInterlacingDraw="plot-axis-interlacing-draw",t.animationBegin="animation-begin",t.animationComplete="animation-complete"}(M||(M={}));class N{constructor(t,e){this.Zt={},this.Xt=t,this.Ut=e}add(t,e){if("string"!=typeof t)throw new Error("first parameter should be string");this.te(t).push(e)}te(t){if(!(t in this.Zt)){let e=null;if(!this.ee(t)){const n=(e,n)=>{this.ne(t,n,e)};e=this.Xt.addEventListener(t,n)}this.Zt[t]=[e,[]]}return this.Zt[t][1]}remove(t,e){if("string"!=typeof t)throw new Error("first parameter should be string");const n=this.Zt[t];if(!n)throw new Error("unknown event handler");const[s,r]=n;r.find(((t,n)=>t===e&&(r.splice(n,1),!0))),0===r.length&&(this.ee(t)||s&&this.Xt.removeEventListener(t,s),delete this.Zt[t])}addMany(t){for(const[e,n]of Object.entries(t))this.add(e,n)}removeMany(t){for(const[e,n]of Object.entries(t))this.remove(e,n)}ne(t,e,n){const s={canceled:!1};try{const r=this.Zt[t];if(r)for(const i of[...r[1]]){i(this.ee(t)?this.se(e,s):n?this.re(n,e,s):e)}}catch(t){console.log("exception in event handler: "+t)}return s.canceled}ee(t){return t.startsWith("api-")}se(t,e){return t.preventDefault=()=>{e.canceled=!0},t}re(t,e,n){return e.preventDefault=()=>{t.preventDefault(),n.canceled=!0},(e.type.endsWith("-draw")||e.type.startsWith("draw-"))&&(e.renderingContext=this.Ut.context),e}}var L,V=Object.freeze({__proto__:null,get EventType(){return M},Events:N});!function(t){t.prepareAnimation="prepareAnimation",t.registerAnimation="registerAnimation",t.runAnimation="runAnimation"}(L||(L={}));class ${constructor(t,e){if(this.ie=t,this.oe=[],e){if(!Array.isArray(e))throw new Error("Plugins must be an array");e.forEach((t=>this.register(t,!0)))}}init(t){this.ae=t,this.oe.forEach((t=>{t.enabled&&this.he(t)}))}enable(t,e){const n=this.ce(t);this.ue(n,e)}getRegisteredName(t){const e=this.oe.find((e=>e.instance===t));return e?.name}register(t,e=!0){this.le(t);const n=this.fe(t);t.register&&this.ie&&t.register(this.ie);const s={name:n,instance:t,enabled:!e};return this.oe.push(s),this.ue(s,e),n}destruct(){const t=this.oe.map((t=>t.name));try{t.forEach((t=>this.unregister(t)))}finally{this.oe=[],this.ie=null}}unregister(t){const e=this.oe.findIndex((e=>e.name===t));if(-1!==e){const t=this.oe[e];this.oe.splice(e,1),t?.instance.unregister&&this.ie&&t.instance.unregister(this.ie)}}api(t){return this.ce(t).instance.api||{}}hook(t,e){return{default:(n=(()=>{}))=>{this.de(e,t,n)}}}ue(t,e){t.enabled!==e&&(t.enabled=e,t.instance.enable&&t.instance.enable(e),t.enabled?this.he(t):this.ye(t))}he(t){t.instance.listeners&&(t.registeredListeners=t.instance.listeners,this.ae?.addMany(t.registeredListeners))}ye(t){t.registeredListeners&&this.ae?.removeMany(t.registeredListeners),delete t.registeredListeners}le(t){this.me(t),this.pe(t)}me(t){const e=this.fe(t);if(!("string"==typeof e&&e.length>0))throw new Error("Plugin must have a non empty name string")}fe(t){return t.meta?.name??(t.constructor?.name?this.ge(t.constructor.name):void 0)}ge(t){return"string"==typeof t&&t[0]?t[0].toLowerCase()+t.slice(1):""}pe(t){if(t.meta?.depends){if(Array.isArray(t.meta.depends)){for(const e of t.meta.depends)this.ce(e);return}throw new Error("Plugin depends must be an array")}}ce(t){const e=this.oe.find((e=>e.name===t));if(e)return e;throw new Error(`Plugin ${t} is not registered`)}de(t,e,n){const s=[...this.ve(e),n];this.we(s,t)}ve(t){return this.oe.filter((e=>e.enabled&&e.instance.hooks?.[t])).map((e=>e.instance.hooks[t])).sort(((t,e)=>(e.priority||0)-(t.priority||0)))}we(t,e){let n=()=>{};const s=t.map((t=>t?()=>t(e,n):()=>n()))[Symbol.iterator]();n=()=>s.next().value(),n()}}var H=Object.freeze({__proto__:null,get Hooks(){return L},PluginRegistry:$});class q{constructor(){this.meta={name:"shorthands"}}get hooks(){return{prepareAnimation:Object.assign(((t,e)=>{this.be(t),e()}),{priority:1})}}register(t){this.Ct=t,this._e=Object.keys(this.Ct.config.channels)}be(t){if(!(t.target instanceof s)){const e=this.xe(t.target,t.options);void 0===t.options||this.Ae(t.target)||delete t.options,t.target=e}const e=this.ke(t.options);e&&(t.options=e)}xe(t,e){return(this.Ae(t)?t:[this.Be(t,e)]).map((t=>this.Ce(t)?t:{target:t})).map((t=>this.Se(t)))}Be(t,e){return Object.assign({target:t},void 0!==e?{options:e}:{})}Ae(t){return Array.isArray(t)}Ce(t){return"target"in t}Se(t){const e=this.ke(t.options);return Object.assign({target:this.Ee(t.target)},e?{options:e}:{})}Ee(t){if(t&&!(t instanceof l)){if(this.Te(t))return{config:this.je(t)};void 0!==t.config&&(t.config=this.je(t.config)),void 0!==t.style&&(t.style=this.Pe(t.style))}return t}Pe(t){return null===t?{"":null}:void 0===t?{}:t}ze(t){return"data"in t||"style"in t||"config"in t}Te(t){return!this.ze(t)}je(t){const{channels:e,...n}=this.Oe(t);return{...n,...e?{channels:this.We(e)}:{}}}Oe(t){if(null!==t&&"object"==typeof t){t.channels=t.channels||{};for(const e in t){const n=e;if(this.Fe(n)){const e=t[n];void 0!==e&&(t.channels[n]=e),delete t[n]}}}return t}Fe(t){return this._e.includes(t)}We(t){const e={};for(const n in t){const s=n,r=t[s];void 0!==r&&(e[s]=this.Ue(r))}return e}Ue(t){return"string"==typeof t&&(t=[t]),(null===t||Array.isArray(t))&&(t={set:t}),"string"==typeof t?.attach&&(t.attach=[t.attach]),"string"==typeof t?.detach&&(t.detach=[t.detach]),"string"==typeof t?.set&&(t.set=[t.set]),Array.isArray(t?.set)&&0===t?.set.length&&(t.set=null),t}ke(t){return void 0!==t&&(null===t?t={duration:0}:"string"!=typeof t&&"number"!=typeof t||(t={duration:t})),t}}class K{constructor(){this.De=0,this.Ie=!1,this.Re=null,this.Me=null,this.Ne=(new Date).getTime(),this.meta={name:"tooltip",depends:["pointerEvents"]},this.listeners={pointermove:this.Le.bind(this),pointerleave:this.Ve.bind(this)}}register(t){this.zt=t}enable(t){t||null===this.Re||(this.De++,setTimeout((()=>{this.$e(this.De)}),200))}Le(t){this.Ne=(new Date).getTime();const e=this.He(t.target);e!==this.Me&&(this.Me=e,this.qe(t))}Ve(t){this.Ne=(new Date).getTime(),this.Me=null,this.qe(t)}qe(t){this.De++;const e=this.De;if(t.target&&this.Ke(t.target)){const n=t.target.index;setTimeout((()=>{this.Ge(e,n)}),0)}else setTimeout((()=>{this.$e(e)}),200)}He(t){return t&&this.Ke(t)?t.index:null}Ke(t){return"plot-marker"===t.tagName}Ge(t,e){this.De===t&&(this.Ie?setTimeout((()=>{this.Ge(t,e)}),100):(this.Re=e,this.Ie=!0,this.zt?.animate([{target:{config:{tooltip:e}},options:{duration:this.Re?"100ms":"250ms"}}]).then((()=>{this.Ie=!1}))))}$e(t){if(this.De===t){const e=(new Date).getTime()-this.Ne;!this.Ie&&e>200?(this.Re=null,this.Ie=!0,this.zt?.animate([{target:{config:{tooltip:null}},options:{duration:"250ms"}}]).then((()=>{this.Ie=!1}))):setTimeout((()=>{this.$e(t)}),200-e)}}}class G{get api(){return{element:this.element,clientToCanvas:this.Je.bind(this),canvasToClient:this.Qe.bind(this)}}static extractOptions(t){const e="object"!=typeof t||t instanceof HTMLElement?{element:t}:t;if(null===e||!("element"in e))throw new Error("element not specified");let n=e.element;if("string"==typeof n&&(n=document.getElementById(n)),!(n instanceof HTMLElement))throw new Error(`Cannot find element ${e.element} to render Vizzu!`);return{element:n}}constructor(t){this.onchange=()=>{},this.Ye="",this.Ze=1,this.Xe=1,this.tn=1,this.meta={name:"htmlCanvas"},this.en=this.nn(t.element),this.sn=document.createElement("canvas");const e=this.sn.getContext("2d");if(!e)throw Error("Cannot get rendering context of internal canvas");this.rn=e;const n=this.en.getContext("2d");if(!n)throw Error("Cannot get rendering context of canvas");this.an=n,this.calcSize(),this.hn=this.cn(this.en)}destruct(){this.hn.disconnect(),this.un&&this.un.removeChild(this.en)}get element(){return this.en}get context(){return this.rn}calcSize(){this.Ze=window.devicePixelRatio,this.Xe=+getComputedStyle(this.en).width.slice(0,-2),this.tn=+getComputedStyle(this.en).height.slice(0,-2);const t=`${this.Ze}:${this.Xe}:${this.tn}`;return t!==this.Ye&&(this.en.width=this.Xe*this.Ze,this.en.height=this.tn*this.Ze,this.sn.width=this.Xe*this.Ze,this.sn.height=this.tn*this.Ze,this.rn.translate(.5,.5),this.rn.scale(this.Ze,this.Ze)),this.Ye=t,{x:this.Xe,y:this.tn}}frameBegin(){this.rn.clearRect(-1,-1,this.en.width+1,this.en.height+1)}frameEnd(){this.an.clearRect(-1,-1,this.en.width+1,this.en.height+1),this.an.drawImage(this.sn,0,0)}ln(){return this.en.getBoundingClientRect()}fn(t){return{x:t.width/(this.en.width/this.Ze),y:t.height/(this.en.height/this.Ze)}}Je(t){const e=this.ln(),n=this.fn(e);return{x:(t.x-e.x)/n.x,y:(t.y-e.y)/n.y}}Qe(t){const e=this.ln(),n=this.fn(e);return{x:e.x+t.x*n.x,y:e.y+t.y*n.y}}nn(t){if(t instanceof HTMLCanvasElement)return t;{const e=document.createElement("canvas");return e.style.width="100%",e.style.height="100%",this.un=t,this.un.appendChild(e),e}}cn(t){const e=new ResizeObserver((()=>{this.onchange()}));return e.observe(t),e}}class J{constructor(t){this.dn=t}store(){return this.dn.storeAnim()}seek(t){const e="string"!=typeof t?t.toString():t;return this.yn("seek",e),this}set speed(t){const e="string"!=typeof t?t.toString():t;this.yn("setSpeed",e)}pause(){return this.yn("pause"),this}play(){return this.yn("play"),this}stop(){return this.yn("stop"),this}cancel(){return this.yn("cancel"),this}reverse(){return this.yn("reverse"),this}yn(t,e=""){this.dn.animControl(t,e)}}class Q{constructor(t,e,n){this.oe=n,this.mn=t,this.Ut=new G(G.extractOptions(e)),this.Xt=this.mn.createChart(),this.Lt=this.mn.getData(this.Xt),this.pn=new R(this.Lt),this.gn=new D(this.mn,this.Xt,this.Ut),this.ae=new N(this.Xt,this.Ut),this.oe.init(this.ae)}registerBuiltins(){this.oe.register(new T(this.mn.setLogging.bind(this.mn)),!1),this.oe.register(this.Ut,!0),this.oe.register(this.gn,!0),this.oe.register(new B(this.mn.getCoordSystem(this.Xt)),!0),this.oe.register(new E,!1),this.oe.register(new q,!0),this.oe.register(new O,!0),this.oe.register(new U(this.Xt),!0),this.oe.register(new K,!1)}start(){this.vn||(this.gn.updateFrame(),this.vn=setInterval((()=>{this.gn.updateFrame()}),25))}async prepareAnimation(t,e){const n=Object.assign({target:t},void 0!==e?{options:e}:{});await this.oe.hook(L.prepareAnimation,n).default((t=>{this.setAnimParams(t.target,t.options)}))}runAnimation(t){const e={callback:t};this.oe.hook(L.runAnimation,e).default((t=>{this.Xt.animate(t.callback)}))}setAnimParams(t,e){if(t instanceof s)this.Xt.restoreAnim(t);else for(const e of t)this.wn(e.target,e.options);e&&this.Xt.animOptions.set(e)}wn(t,e){t&&(t instanceof l?this.Xt.restoreSnapshot(t):(t.data&&this.pn.set(t.data),t.style&&this.Xt.style.set(t.style),t.config&&this.Xt.config.set(t.config))),e&&this.Xt.animOptions.set(e),this.Xt.setKeyframe()}destruct(){this.Ut.destruct(),this.vn&&clearInterval(this.vn),delete this.vn}version(){return this.mn.version()}get data(){return this.Lt.getMetaInfo()}get config(){return this.Xt.config.get()}get style(){return this.Xt.style.get()}getComputedStyle(){return this.Xt.computedStyle.get()}on(t,e){this.ae.add(t,e)}off(t,e){this.ae.remove(t,e)}store(){return this.Xt.storeSnapshot()}getAnimControl(){return new J(this.bn())}bn(){return this.mn.getAnimControl(this.Xt)}}const Y={column:{channels:{x:{set:["x"]},y:{set:["y"]},label:{set:["y"]}}},groupedColumn:{channels:{x:{set:["groupedBy","x"]},y:{set:["y"]},label:{set:["y"]},color:{set:["x"]}}},stackedColumn:{channels:{x:{set:["x"]},y:{set:["y","stackedBy"]},label:{set:["y"]},color:{set:["stackedBy"]}}},splittedColumn:{channels:{x:{set:["x"]},y:{set:["y","splittedBy"]},color:{set:["splittedBy"]},label:{set:["y"]}},split:!0},percentageColumn:{channels:{x:{set:["x"]},y:{set:["y","stackedBy"]},color:{set:["stackedBy"]},label:{set:["y"]}},align:"stretch"},waterfall:{channels:{x:{set:["x"]},y:{set:["y","x"]},label:{set:["y"]},color:{set:["y"]}},align:"stretch"},mekko:{channels:{x:{set:["x","groupedBy"]},y:{set:["y","stackedBy"]},color:{set:["stackedBy"]},label:{set:["groupedBy"]}}},marimekko:{channels:{x:{set:["x","groupedBy"]},y:{set:["y","stackedBy"]},color:{set:["stackedBy"]},label:{set:["groupedBy"]}},align:"stretch"},bar:{channels:{x:{set:["x"]},y:{set:["y"]},label:{set:["x"]}}},groupedBar:{channels:{x:{set:["x"]},y:{set:["groupedBy","y"]},label:{set:["x"]},color:{set:["y"]}}},stackedBar:{channels:{x:{set:["x","stackedBy"]},y:{set:["y"]},label:{set:["x"]},color:{set:["stackedBy"]}}},splittedBar:{channels:{x:{set:["x","splittedBy"]},y:{set:["y"]},color:{set:["splittedBy"]},label:{set:["x"]}},split:!0},percentageBar:{channels:{x:{set:["x","stackedBy"]},y:{set:["y"]},color:{set:["stackedBy"]},label:{set:["x"]}},align:"stretch"},lollipop:{channels:{x:{set:["x"]},y:{set:["y"]},label:{set:["y"]}},geometry:"circle"},scatter:{channels:{x:{set:["x"]},y:{set:["y"]},noop:{set:["dividedBy"]}},geometry:"circle"},bubbleplot:{channels:{x:{set:["x"]},y:{set:["y"]},color:{set:["color"]},size:{set:["size"]},label:{set:["dividedBy"]},noop:{set:["dividedBy"]}},geometry:"circle"},area:{channels:{x:{set:["x"]},y:{set:["y"]}},geometry:"area"},stackedArea:{channels:{x:{set:["x"]},y:{set:["y","stackedBy"]},color:{set:["stackedBy"]}},geometry:"area"},percentageArea:{channels:{x:{set:["x"]},y:{set:["y","stackedBy"]},color:{set:["stackedBy"]}},align:"stretch",geometry:"area"},splittedArea:{channels:{x:{set:["x"]},y:{set:["y","splittedBy"]},color:{set:["splittedBy"]}},split:!0,geometry:"area"},stream:{channels:{x:{set:["x"]},y:{set:["y","stackedBy"]},color:{set:["stackedBy"]}},geometry:"area",align:"center"},verticalStream:{channels:{x:{set:["x","stackedBy"]},y:{set:["y"]},color:{set:["stackedBy"]}},geometry:"area",align:"center"},violin:{channels:{x:{set:["x"]},y:{set:["y","splittedBy"]},color:{set:["splittedBy"]}},geometry:"area",align:"center",split:!0},verticalViolin:{channels:{x:{set:["x","splittedBy"]},y:{set:["y"]},color:{set:["splittedBy"]}},geometry:"area",align:"center",split:!0},line:{channels:{x:{set:["x"]},y:{set:["y"]},color:{set:["dividedBy"]}},geometry:"line"},verticalLine:{channels:{x:{set:["x"]},y:{set:["y"]},color:{set:["dividedBy"]}},geometry:"line"},pie:{channels:{x:{set:["angle","by"]},color:{set:["by"]},label:{set:["angle"]}},coordSystem:"polar"},polarColumn:{channels:{x:{set:["angle"]},y:{set:["radius"]},label:{set:["radius"]}},coordSystem:"polar"},polarStackedColumn:{channels:{x:{set:["angle"]},y:{set:["radius","stackedBy"]},color:{set:["stackedBy"]}},coordSystem:"polar"},variableRadiusPie:{channels:{x:{set:["angle","by"]},y:{set:["radius"]},color:{set:["by"]},label:{set:["radius"]}},coordSystem:"polar"},radialBar:{channels:{x:{set:["angle"]},y:{set:["radius"],range:{min:"-50%"}},label:{set:["angle"]}},coordSystem:"polar"},radialStackedBar:{channels:{x:{set:["angle","stackedBy"]},y:{set:["radius"],range:{min:"-50%"}},color:{set:["stackedBy"]},label:{set:["angle"]}},coordSystem:"polar"},donut:{channels:{x:{set:["angle","stackedBy"]},y:{range:{min:"-200%",max:"100%"}},color:{set:["stackedBy"]}},coordSystem:"polar"},nestedDonut:{channels:{x:{set:["angle","stackedBy"]},y:{set:["radius"],range:{min:"-50%"}},color:{set:["stackedBy"]},label:{set:["angle"]}},coordSystem:"polar",align:"stretch"},polarScatter:{channels:{x:{set:["angle"]},y:{set:["radius"]},noop:{set:["dividedBy"]}},coordSystem:"polar",geometry:"circle"},polarLine:{channels:{x:{set:["angle"]},y:{set:["radius"]},color:{set:["dividedBy"]}},coordSystem:"polar",geometry:"line"},treemap:{channels:{size:{set:["size","color"]},color:{set:["color"]},label:{set:["color"]}}},stackedTreemap:{channels:{size:{set:["size","dividedBy"]},color:{set:["color"]},label:{set:["dividedBy"]},lightness:{set:["size"]}}},heatmap:{channels:{x:{set:["x"]},y:{set:["y"]},lightness:{set:["lightness"]}}},bubble:{channels:{size:{set:["size"]},color:{set:["color"]},label:{set:["color"]}},geometry:"circle"},stackedBubble:{channels:{size:{set:["size","stackedBy"]},color:{set:["color"]}},geometry:"circle"}};class Z{constructor(){this._n=Y;for(const t in this._n){const e=t;this[e]=t=>this.xn(e,t)}}An(){return{align:"none",coordSystem:"cartesian",orientation:"auto",rotate:0,split:!1,geometry:"rectangle",channels:{x:{set:null},y:{set:null},color:{set:null},lightness:{set:null},size:{set:null},noop:{set:null},label:{set:null}}}}kn(t){const e=a(this._n[t]),n={...this.An().channels,...e.channels},s=Object.assign(this.An(),e);return s.channels=n,s}Bn(t){return null==t?null:Array.isArray(t)?t:[t]}Cn(t,e){if(!e)return;const n=t.channels;for(const t in n){const s=n[t];if(this.Sn(s))if("string"==typeof s.set){const t=s.set;s.set=this.Bn(e[t])}else if(Array.isArray(s.set)){const t=[];for(let n=0;n<s.set.length;n++){const r=s.set[n],i=this.Bn(e[r]);null!==i&&t.push(i)}s.set=t.length>0?t.flat():null}}}Sn(t){return"object"==typeof t&&null!==t&&"set"in t}En(t,e){["legend","title","subtitle","caption","reverse","sort"].forEach((n=>{const s=n;void 0!==e[s]&&(t[s]=e[s])}))}xn(t,e){const n=this.kn(t);return this.Cn(n,e),this.En(n,e),n}}class X{static get presets(){return new Z}static options(t){k.options=t}static initialize(){return k.initialize().then((()=>{}))}constructor(t,e){this.oe=new $(this,this.Tn(t)),this.initializing=k.initialize().then((e=>(this.Ct=new Q(e,t,this.oe),this.Ct.registerBuiltins(),this.Ct.start(),this))),this.jn=this.initializing,e&&(this.initializing=this.animate([{target:e,options:{duration:0}}]).then((()=>this)))}Tn(t){return"object"==typeof t&&null!==t&&"features"in t?t.features:[]}get feature(){const t=this.Pn.bind(this);return new Proxy(t,{get:(t,e)=>this.oe.api(e)})}Pn(t,e){if(void 0!==e&&"boolean"!=typeof e)throw new Error("enabled parameter must be boolean if specified");let n,s=!1;if("string"!=typeof t){const r=t;n=this.oe.getRegisteredName(r),n||(n=this.oe.register(r,e??!0),s=!0)}else n=t;return void 0!==e&&!s&&this.oe.enable(n,e),this.oe.api(n)}animate(t,e){const s=a(t,n),r=a(e),i=Object.assign({target:s,promise:this.jn},void 0!==r?{options:r}:{});return this.oe.hook(L.registerAnimation,i).default((t=>{let e=()=>{};const n=new Promise((t=>{e=t})),i=t.promise.then((()=>this.zn(s,r,e)));t.promise=Object.assign(i,{activated:n})})),this.jn=i.promise,this.jn}zn(t,e,n){if(!this.Ct)throw new F;return this.Ct.prepareAnimation(t,e).then((()=>this.On(n)))}On(t){return new Promise(((e,n)=>{if(!this.Ct)throw new F;this.Ct.runAnimation((t=>{t?e(this):(n(new W),this.jn=Promise.resolve(this))})),t(this.Ct.getAnimControl())}))}get animation(){if(!this.Ct)throw new F;return this.Ct.getAnimControl()}version(){if(!this.Ct)throw new F;return this.Ct.version()}get data(){if(!this.Ct)throw new F;return this.Ct.data}get config(){if(!this.Ct)throw new F;return this.Ct.config}get style(){if(!this.Ct)throw new F;return this.Ct.style}getComputedStyle(){if(!this.Ct)throw new F;return this.Ct.getComputedStyle()}on(t,e){if(!this.Ct)throw new F;this.Ct.on(t,e)}off(t,e){if(!this.Ct)throw new F;this.Ct.off(t,e)}store(){if(!this.Ct)throw new F;return this.Ct.store()}detach(){try{this.oe.destruct()}finally{this.Ct?.destruct()}}}var tt=Object.freeze({__proto__:null}),et=Object.freeze({__proto__:null}),nt=Object.freeze({__proto__:null}),st=Object.freeze({__proto__:null}),rt=Object.freeze({__proto__:null}),it=Object.freeze({__proto__:null});export{tt as Anim,J as AnimControl,r as CAnimControl,s as CAnimation,o as CCanvas,p as CChart,v as CData,e as CEnv,t as CError,f as CEvent,n as CObject,u as CProxy,g as CRecord,E as CSSProperties,W as CancelError,Q as Chart,et as Config,B as CoordSystem,nt as Data,I as DataRecord,V as Events,it as Geom,G as HtmlCanvas,T as Logging,_ as Module,F as NotInitializedError,w as ObjectRegistry,O as PivotData,H as Plugins,U as PointerEvents,st as Presets,D as Render,q as Shorthands,l as Snapshot,rt as Styles,K as Tooltip,X as Vizzu,X as default,k as loader};