vizzu
Version:
Vizzu is a free, open-source Javascript/C++ library utilizing a generic dataviz engine that generates many types of charts and seamlessly animates between them. It can be used to create static charts but more importantly it is designed for building animat
2 lines • 60.5 kB
JavaScript
class t extends Error{constructor(t,e){const s=new e.ExceptionInfo(t).get_type(),n=e._vizzu_errorMessage(t,s);super("error: "+e.UTF8ToString(n)),this.name="CError"}}class e{constructor(t,e){this.tt=t,this.et=e}st(t){const e=4*t.length+1,s=this.tt._malloc(e);return this.tt.stringToUTF8(t,s,e),s}nt(t){return this.tt.UTF8ToString(t)}rt(t){const e=this.it(t)();return()=>e}it(e){return(...s)=>{try{return e(...s)}catch(e){throw"number"==typeof e&&Number.isInteger(e)?new t(e,this.tt):e}}}cObjectParams(){return[this.tt,this.et]}}class s extends e{constructor(t,e){super(...e.cObjectParams()),this.getId=t}ot(t){const e=this.ht(t)();return()=>e}ht(t){return super.it(t).bind(this,this.getId())}}class n extends s{constructor(t,e){super(t,e),this.et.register(this.getId)}free(){this.et.unregister(this.getId),this.tt._object_free(this.getId())}}class r extends n{}class i extends s{setParam(t,e=""){const s=this.st(t),n=this.st(e);try{this.ht(this.tt._anim_control_setValue)(s,n)}finally{this.tt._free(n),this.tt._free(s)}}getParam(t){const e=this.st(t);try{const t=this.ht(this.tt._anim_control_getValue)(e);return this.nt(t)}finally{this.tt._free(e)}}storeAnim(){return new r(this.ot(this.tt._chart_anim_store),this)}}class a extends s{constructor(t,e,s){super((()=>e),t),this.stops=this.lt(s)}lt(t){const e=[],s=this.getId();for(let n=0;n<40*t;n+=40)e.push({offset:this.tt.getValue(s+n,"double"),color:"rgba("+255*this.tt.getValue(s+n+8,"double")+","+255*this.tt.getValue(s+n+16,"double")+","+255*this.tt.getValue(s+n+24,"double")+","+this.tt.getValue(s+n+32,"double")+")"});return e}}class o extends n{constructor(t,e){super(e,t)}getColorGradient(t,e){return new a(this,t,e)}getString(t){return this.tt.UTF8ToString(t)}}function h(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=>h(t,e)));if(e&&t instanceof e)return t;const s={};for(const n in t)n in t&&(s[n]=h(t[n],e));return s}function l(t,e,s=""){if(t&&null!==t&&"object"==typeof t){const n=Array.isArray(t);n&&e(s+".begin",t.length),Object.keys(t).forEach((n=>{const r=s+(0===s.length?"":".")+n,i=t[n];!function(t){return"object"==typeof t&&null!==t}(i)?e(r,i):l(i,e,r)})),n&&e(s+".end",t.length)}}function c(t,e,s){const n=e.split(".");let r=t;n.forEach(((t,e)=>{if(!function(t){return"object"==typeof t&&null!==t}(r))throw new Error("Expected an object, but got "+typeof r);e<n.length-1?(r[t]=r[t]||("number"==typeof n[e+1]?[]:{}),r=r[t]):r[t]=s}))}class u extends s{constructor(t,e,s,n,r,i){super(t,e),this.ct=s,this.ut=n,this.dt=r,this.ft=i||((t,e)=>e)}set(t){l(t,this.setParam.bind(this))}get(){return function(t,e){const s=t(),n={};for(const t of s)c(n,t,e(t));return Object.freeze(n)}(this.listParams.bind(this),this.getParam.bind(this))}listParams(){const t=this.ht(this.ct)(),e=this.nt(t);return JSON.parse(e)}getParam(t){const e=this.st(t);try{const s=this.ht(this.ut)(e),n=this.nt(s);return this.ft(t,n)}finally{this.tt._free(e)}}setParam(t,e){const s=this.st(t),n=this.st(String(e).toString());try{this.ht(this.dt)(s,n)}finally{this.tt._free(n),this.tt._free(s)}}}class d extends n{}class m extends s{preventDefault(){this.ht(this.tt._event_preventDefault)()}}class f extends u{}class y extends u{}class p extends u{}class g extends n{constructor(t,e){super(e,t),this.config=this.yt(),this.style=this.gt(!1),this.computedStyle=this.gt(!0),this.animOptions=this.wt()}update(t){this.ht(this.tt._vizzu_update)(t)}render(t,e,s){this.vt=t,this.ht(this.tt._vizzu_render)(t.getId(),e,s)}animate(t){const e=this.tt.addFunction((s=>{t(s),this.tt.removeFunction(e)}),"vi");this.ht(this.tt._chart_animate)(e)}storeSnapshot(){return new d(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 s=this.tt.addFunction(((t,s)=>{const n=new m((()=>t),this);e(n,JSON.parse(this.nt(s)))}),"vii"),n=this.st(t);try{this.ht(this.tt._addEventListener)(n,s)}finally{this.tt._free(n)}return s}removeEventListener(t,e){const s=this.st(t);try{this.ht(this.tt._removeEventListener)(s,e)}finally{this.tt._free(s)}this.tt.removeFunction(e)}pointerdown(t,e,s){this.vt&&this.ht(this.tt._vizzu_pointerDown)(this.vt.getId(),t,e,s)}pointermove(t,e,s){this.vt&&this.ht(this.tt._vizzu_pointerMove)(this.vt.getId(),t,e,s)}pointerup(t,e,s){this.vt&&this.ht(this.tt._vizzu_pointerUp)(this.vt.getId(),t,e,s)}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)}getString(t){return this.tt.UTF8ToString(t)}yt(){return new f(this.getId,this,this.tt._chart_getList,this.tt._chart_getValue,this.tt._chart_setValue,((t,e)=>t.startsWith("channels.")&&t.endsWith(".set")?JSON.parse(e):e))}gt(t){return new y(this.getId,this,this.tt._style_getList,((e,s)=>this.tt._style_getValue(e,s,t)),this.tt._style_setValue)}wt(){return new p(this.getId,this,(()=>0),(()=>0),this.tt._anim_setValue)}}class w extends s{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 v extends s{constructor(t,e){super((()=>e),t)}getValue(t){const e=this.st(t);let s,n;try{s=this.ht(this.tt._record_getValue)(e),n=this.tt.getValue(s,"i1")?this.nt(this.tt.getValue(s+8,"i8*")):this.tt.getValue(s+8,"double")}finally{this.tt._free(e)}return n}}class b extends s{getMetaInfo(){const t=this.ht(this.tt._data_metaInfo)(),e=this.nt(t);return{series:JSON.parse(e)}}addDimension(t,e,s){const n=new Uint32Array(s.length);for(let t=0;t<s.length;t++){const e=this.st(s[t]);n[t]=e}const r=4*s.length,i=this.tt._malloc(r);new Uint8Array(this.tt.HEAPU8.buffer,i,r).set(new Uint8Array(n.buffer));const a=4*e.length,o=this.tt._malloc(a);new Uint8Array(this.tt.HEAPU8.buffer,o,a).set(new Uint8Array(new Uint32Array(e).buffer));const h=this.st(t);try{this.ht(this.tt._data_addDimension)(h,i,s.length,o,e.length)}finally{this.tt._free(h);for(const t of n)this.tt._free(t);this.tt._free(o),this.tt._free(i)}}addMeasure(t,e,s){const n=new Float64Array(s),r=8*s.length,i=this.tt._malloc(r);new Uint8Array(this.tt.HEAPU8.buffer,i,r).set(new Uint8Array(n.buffer));const a=this.st(t),o=this.st(e);try{this.ht(this.tt._data_addMeasure)(a,o,i,s.length)}finally{this.tt._free(a),this.tt._free(o),this.tt._free(i)}}addRecord(t){const e=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const n=this.st(String(t[s]).toString());e[s]=n}const s=4*t.length,n=this.tt._malloc(s);new Uint8Array(this.tt.HEAPU8.buffer,n,s).set(new Uint8Array(e.buffer));try{this.ht(this.tt._data_addRecord)(n,t.length)}finally{for(const t of e)this.tt._free(t);this.tt._free(n)}}setFilter(t){const e=[0,0];if(null!==t){const s=e=>t(new v(this,e));e[0]=this.tt.addFunction(s,"ii");const n=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(n,"vi")}this.ht(this.tt._chart_setFilter)(...e)}}class _{setFont(t){this.canvas&&this.setFontStyle(this.canvas.getString(t))}text(t,e,s,n,r){this.canvas&&this.drawText(t,e,s,n,this.canvas.getString(r))}setBrushGradient(t,e,s,n,r,i){this.canvas&&this.setGradient(t,e,s,n,this.canvas.getColorGradient(i,r))}}class x{constructor(t){this._t=new FinalizationRegistry((e=>{t(e)}))}register(t){this._t.register(t,t())}unregister(t){this._t.unregister(t)}}class A extends e{constructor(t){super(t,new x(t._object_free));const e=document.createElement("canvas").getContext("2d");if(!e)throw new Error("Failed to get 2D context");this.tt.measureCanvas=e,this.tt.canvases={},this.tt.charts={},this.setLogging(!1)}registerChart(t,e){this.tt.charts[t.getId()]=e}unregisterChart(t){delete this.tt.charts[t.getId()]}registerRenderer(t,e){this.tt.canvases[t.getId()]=e}unregisterRenderer(t){delete this.tt.canvases[t.getId()]}version(){return this.tt.UTF8ToString(this.tt._vizzu_version())}setLogging(t){this.it(this.tt._vizzu_setLogging)(t)}getData(t){return new b(t.getId,this)}getCoordSystem(t){return new w(t.getId,this)}getAnimControl(t){return new i(t.getId,this)}createChart(){return new g(this,this.rt(this.tt._vizzu_createChart))}createCanvas(){return new o(this,this.rt(this.tt._vizzu_createCanvas))}}var k,C=(k=import.meta.url,function(t={}){var e,s,n,r=t,i=new Promise(((t,n)=>{e=t,s=n})),a=Object.assign({},r),o="";"undefined"!=typeof document&&document.currentScript&&(o=document.currentScript.src),k&&(o=k),o=o.startsWith("blob:")?"":o.substr(0,o.replace(/[?#].*/,"").lastIndexOf("/")+1),n=t=>fetch(t,{credentials:"same-origin"}).then((t=>t.ok?t.arrayBuffer():Promise.reject(new Error(t.status+" : "+t.url))));var h,l,c=console.log.bind(console),u=console.error.bind(console);Object.assign(r,a),a=null;var d,m,f,y,p,g,w,v,b=!1;function _(){var t=l.buffer;d=new Int8Array(t),f=new Int16Array(t),r.HEAPU8=m=new Uint8Array(t),y=new Uint16Array(t),p=new Int32Array(t),g=new Uint32Array(t),w=new Float32Array(t),v=new Float64Array(t)}var x=[],A=[],C=[],S=0,E=null;function B(t){u(t="Aborted("+t+")"),b=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw s(e),e}var j,P=t=>t.startsWith("data:application/octet-stream;base64,");function T(){if(r.locateFile){var t="cvizzu.wasm";return P(t)?t:(e=t,r.locateFile?r.locateFile(e,o):o+e)}var e;return new URL("cvizzu.wasm",import.meta.url).href}function z(t){return n(t).then((t=>new Uint8Array(t)),(()=>function(t){if(t==j&&h)return new Uint8Array(h);throw"both async and sync fetching of the wasm failed"}(t)))}function O(t,e,s){return z(t).then((t=>WebAssembly.instantiate(t,e))).then(s,(t=>{u(`failed to asynchronously prepare wasm: ${t}`),B(t)}))}var F=t=>{for(;t.length>0;)t.shift()(r)};function W(t,e,s="i8"){switch(s.endsWith("*")&&(s="*"),s){case"i1":case"i8":d[t]=e;break;case"i16":f[t>>1]=e;break;case"i32":p[t>>2]=e;break;case"i64":B("to do setValue(i64) use WASM_BIGINT");case"float":w[t>>2]=e;break;case"double":v[t>>3]=e;break;case"*":g[t>>2]=e;break;default:B(`invalid type for setValue: ${s}`)}}class D{constructor(t){this.excPtr=t,this.ptr=t-24}set_type(t){g[this.ptr+4>>2]=t}get_type(){return g[this.ptr+4>>2]}set_destructor(t){g[this.ptr+8>>2]=t}get_destructor(){return g[this.ptr+8>>2]}set_caught(t){t=t?1:0,d[this.ptr+12]=t}get_caught(){return 0!=d[this.ptr+12]}set_rethrown(t){t=t?1:0,d[this.ptr+13]=t}get_rethrown(){return 0!=d[this.ptr+13]}init(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)}set_adjusted_ptr(t){g[this.ptr+16>>2]=t}get_adjusted_ptr(){return g[this.ptr+16>>2]}get_exception_ptr(){if(Ct(this.get_type()))return g[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}var U,I,M=t=>{for(var e="",s=t;m[s];)e+=U[m[s++]];return e},N={},R={},L=t=>{throw new I(t)};function $(t,e,s={}){if(!("argPackAdvance"in e))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(t,e,s={}){var n=e.name;if(t||L(`type "${n}" must have a positive integer typeid pointer`),R.hasOwnProperty(t)){if(s.ignoreDuplicateRegistrations)return;L(`Cannot register type '${n}' twice`)}if(R[t]=e,N.hasOwnProperty(t)){var r=N[t];delete N[t],r.forEach((t=>t()))}}(t,e,s)}var V=[],H=[],q=()=>H.length/2-5-V.length,G=t=>(t||L("Cannot use deleted val. handle = "+t),H[t]),K=t=>{switch(t){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{const e=V.pop()||H.length;return H[e]=t,H[e+1]=1,e}}};function J(t){return this.fromWireType(g[t>>2])}var Y,Q,X={name:"emscripten::val",fromWireType:t=>{var e=G(t);return(t=>{t>9&&0==--H[t+1]&&(H[t]=void 0,V.push(t))})(t),e},toWireType:(t,e)=>K(e),argPackAdvance:8,readValueFromPointer:J,destructorFunction:null},Z=(t,e)=>{switch(e){case 4:return function(t){return this.fromWireType(w[t>>2])};case 8:return function(t){return this.fromWireType(v[t>>3])};default:throw new TypeError(`invalid float width (${e}): ${t}`)}},tt=(t,e,s)=>{switch(e){case 1:return s?t=>d[t]:t=>m[t];case 2:return s?t=>f[t>>1]:t=>y[t>>1];case 4:return s?t=>p[t>>2]:t=>g[t>>2];default:throw new TypeError(`invalid integer width (${e}): ${t}`)}},et=(t,e,s)=>((t,e,s,n)=>{if(!(n>0))return 0;for(var r=s,i=s+n-1,a=0;a<t.length;++a){var o=t.charCodeAt(a);if(o>=55296&&o<=57343&&(o=65536+((1023&o)<<10)|1023&t.charCodeAt(++a)),o<=127){if(s>=i)break;e[s++]=o}else if(o<=2047){if(s+1>=i)break;e[s++]=192|o>>6,e[s++]=128|63&o}else if(o<=65535){if(s+2>=i)break;e[s++]=224|o>>12,e[s++]=128|o>>6&63,e[s++]=128|63&o}else{if(s+3>=i)break;e[s++]=240|o>>18,e[s++]=128|o>>12&63,e[s++]=128|o>>6&63,e[s++]=128|63&o}}return e[s]=0,s-r})(t,m,e,s),st="undefined"!=typeof TextDecoder?new TextDecoder:void 0,nt=(t,e,s)=>{for(var n=e+s,r=e;t[r]&&!(r>=n);)++r;if(r-e>16&&t.buffer&&st)return st.decode(t.subarray(e,r));for(var i="";e<r;){var a=t[e++];if(128&a){var o=63&t[e++];if(192!=(224&a)){var h=63&t[e++];if((a=224==(240&a)?(15&a)<<12|o<<6|h:(7&a)<<18|o<<12|h<<6|63&t[e++])<65536)i+=String.fromCharCode(a);else{var l=a-65536;i+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else i+=String.fromCharCode((31&a)<<6|o)}else i+=String.fromCharCode(a)}return i},rt=(t,e)=>t?nt(m,t,e):"",it="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,at=(t,e)=>{for(var s=t,n=s>>1,r=n+e/2;!(n>=r)&&y[n];)++n;if((s=n<<1)-t>32&&it)return it.decode(m.subarray(t,s));for(var i="",a=0;!(a>=e/2);++a){var o=f[t+2*a>>1];if(0==o)break;i+=String.fromCharCode(o)}return i},ot=(t,e,s)=>{if(s??=2147483647,s<2)return 0;for(var n=e,r=(s-=2)<2*t.length?s/2:t.length,i=0;i<r;++i){var a=t.charCodeAt(i);f[e>>1]=a,e+=2}return f[e>>1]=0,e-n},ht=t=>2*t.length,lt=(t,e)=>{for(var s=0,n="";!(s>=e/4);){var r=p[t+4*s>>2];if(0==r)break;if(++s,r>=65536){var i=r-65536;n+=String.fromCharCode(55296|i>>10,56320|1023&i)}else n+=String.fromCharCode(r)}return n},ct=(t,e,s)=>{if(s??=2147483647,s<4)return 0;for(var n=e,r=n+s-4,i=0;i<t.length;++i){var a=t.charCodeAt(i);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&t.charCodeAt(++i)),p[e>>2]=a,(e+=4)+4>r)break}return p[e>>2]=0,e-n},ut=t=>{for(var e=0,s=0;s<t.length;++s){var n=t.charCodeAt(s);n>=55296&&n<=57343&&++s,e+=4}return e},dt=t=>{var e=(t-l.buffer.byteLength+65535)/65536;try{return l.grow(e),_(),1}catch(t){}},mt=[null,[],[]],ft=(t,e)=>{t<128?e.push(t):e.push(t%128|128,t>>7)},yt=(t,e)=>{if("function"==typeof WebAssembly.Function)return new WebAssembly.Function((t=>{for(var e={i:"i32",j:"i64",f:"f32",d:"f64",e:"externref",p:"i32"},s={parameters:[],results:"v"==t[0]?[]:[e[t[0]]]},n=1;n<t.length;++n)s.parameters.push(e[t[n]]);return s})(e),t);var s=[1];((t,e)=>{var s=t.slice(0,1),n=t.slice(1),r={i:127,p:127,j:126,f:125,d:124,e:111};e.push(96),ft(n.length,e);for(var i=0;i<n.length;++i)e.push(r[n[i]]);"v"==s?e.push(0):e.push(1,r[s])})(e,s);var n=[0,97,115,109,1,0,0,0,1];ft(s.length,n),n.push(...s),n.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var r=new WebAssembly.Module(new Uint8Array(n));return new WebAssembly.Instance(r,{e:{f:t}}).exports.f},pt=t=>Y.get(t),gt=t=>(Q||(Q=new WeakMap,((t,e)=>{if(Q)for(var s=t;s<t+e;s++){var n=pt(s);n&&Q.set(n,s)}})(0,Y.length)),Q.get(t)||0),wt=[],vt=(t,e)=>Y.set(t,e);(()=>{for(var t=new Array(256),e=0;e<256;++e)t[e]=String.fromCharCode(e);U=t})(),I=r.BindingError=class extends Error{constructor(t){super(t),this.name="BindingError"}},r.InternalError=class extends Error{constructor(t){super(t),this.name="InternalError"}},H.push(0,1,void 0,1,null,1,!0,1,!1,1),r.count_emval_handles=q;var bt={a:(t,e,s)=>{throw new D(t).init(e,s),t},q:()=>{B("")},l:(t,e,s,n,r)=>{},o:(t,e,s,n)=>{$(t,{name:e=M(e),fromWireType:function(t){return!!t},toWireType:function(t,e){return e?s:n},argPackAdvance:8,readValueFromPointer:function(t){return this.fromWireType(m[t])},destructorFunction:null})},n:t=>$(t,X),e:(t,e,s)=>{$(t,{name:e=M(e),fromWireType:t=>t,toWireType:(t,e)=>e,argPackAdvance:8,readValueFromPointer:Z(e,s),destructorFunction:null})},c:(t,e,s,n,r)=>{e=M(e);var i=t=>t;if(0===n){var a=32-8*s;i=t=>t<<a>>>a}var o=e.includes("unsigned");$(t,{name:e,fromWireType:i,toWireType:o?function(t,e){return this.name,e>>>0}:function(t,e){return this.name,e},argPackAdvance:8,readValueFromPointer:tt(e,s,0!==n),destructorFunction:null})},b:(t,e,s)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][e];function r(t){var e=g[t>>2],s=g[t+4>>2];return new n(d.buffer,s,e)}$(t,{name:s=M(s),fromWireType:r,argPackAdvance:8,readValueFromPointer:r},{ignoreDuplicateRegistrations:!0})},f:(t,e)=>{var s="std::string"===(e=M(e));$(t,{name:e,fromWireType(t){var e,n=g[t>>2],r=t+4;if(s)for(var i=r,a=0;a<=n;++a){var o=r+a;if(a==n||0==m[o]){var h=rt(i,o-i);void 0===e?e=h:(e+=String.fromCharCode(0),e+=h),i=o+1}}else{var l=new Array(n);for(a=0;a<n;++a)l[a]=String.fromCharCode(m[r+a]);e=l.join("")}return kt(t),e},toWireType(t,e){var n;e instanceof ArrayBuffer&&(e=new Uint8Array(e));var r="string"==typeof e;r||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||L("Cannot pass non-string to std::string"),n=s&&r?(t=>{for(var e=0,s=0;s<t.length;++s){var n=t.charCodeAt(s);n<=127?e++:n<=2047?e+=2:n>=55296&&n<=57343?(e+=4,++s):e+=3}return e})(e):e.length;var i=At(4+n+1),a=i+4;if(g[i>>2]=n,s&&r)et(e,a,n+1);else if(r)for(var o=0;o<n;++o){var h=e.charCodeAt(o);h>255&&(kt(a),L("String has UTF-16 code units that do not fit in 8 bits")),m[a+o]=h}else for(o=0;o<n;++o)m[a+o]=e[o];return null!==t&&t.push(kt,i),i},argPackAdvance:8,readValueFromPointer:J,destructorFunction(t){kt(t)}})},d:(t,e,s)=>{var n,r,i,a;s=M(s),2===e?(n=at,r=ot,a=ht,i=t=>y[t>>1]):4===e&&(n=lt,r=ct,a=ut,i=t=>g[t>>2]),$(t,{name:s,fromWireType:t=>{for(var s,r=g[t>>2],a=t+4,o=0;o<=r;++o){var h=t+4+o*e;if(o==r||0==i(h)){var l=n(a,h-a);void 0===s?s=l:(s+=String.fromCharCode(0),s+=l),a=h+e}}return kt(t),s},toWireType:(t,n)=>{"string"!=typeof n&&L(`Cannot pass non-string to C++ string type ${s}`);var i=a(n),o=At(4+i+e);return g[o>>2]=i/e,r(n,o+4,i+e),null!==t&&t.push(kt,o),o},argPackAdvance:8,readValueFromPointer:J,destructorFunction(t){kt(t)}})},p:(t,e)=>{$(t,{isVoid:!0,name:e=M(e),argPackAdvance:0,fromWireType:()=>{},toWireType:(t,e)=>{}})},H:function(t,e,s,n,i,a,o){r.canvases[t].addBezier(e,s,n,i,a,o)},I:function(t,e,s){r.canvases[t].addPoint(e,s)},O:function(t){r.canvases[t].beginDropShadow()},J:function(t){r.canvases[t].beginPolygon()},D:function(t,e,s,n){r.canvases[t].circle(e,s,n)},K:function(t){r.canvases[t].endDropShadow()},G:function(t){r.canvases[t].endPolygon()},y:function(t){r.canvases[t].frameBegin()},z:function(t){r.canvases[t].frameEnd()},C:function(t,e,s,n,i){r.canvases[t].line(e,s,n,i)},F:function(t,e,s,n,i){r.canvases[t].rectangle(e,s,n,i)},v:function(t){r.canvases[t].restore()},w:function(t){r.canvases[t].save()},j:function(t,e,s,n,i){r.canvases[t].setBrushColor(e,s,n,i)},A:function(t,e,s,n,i,a,o){r.canvases[t].setBrushGradient(e,s,n,i,a,o)},m:function(t,e,s,n){r.canvases[t].setClipCircle(e,s,n)},k:function(t){r.canvases[t].setClipPolygon()},t:function(t,e,s,n,i){r.canvases[t].setClipRect(e,s,n,i)},N:function(t,e){r.canvases[t].setDropShadowBlur(e)},M:function(t,e,s,n,i){r.canvases[t].setDropShadowColor(e,s,n,i)},L:function(t,e,s){r.canvases[t].setDropShadowOffset(e,s)},g:function(t,e){r.canvases[t].setFont(e)},i:function(t,e,s,n,i){r.canvases[t].setLineColor(e,s,n,i)},h:function(t,e){r.canvases[t].setLineWidth(e)},B:function(t,e,s,n,i,a){r.canvases[t].text(e,s,n,i,a)},x:function(t,e,s,n,i,a,o){r.canvases[t].transform(e,s,n,i,a,o)},E:function(t){r.charts[t].doChange()},P:function(t,e){r.charts[t].openUrl(e)},r:t=>{var e=m.length,s=2147483648;if((t>>>=0)>s)return!1;for(var n,r,i=1;i<=4;i*=2){var a=e*(1+.2/i);a=Math.min(a,t+100663296);var o=Math.min(s,(n=Math.max(t,a))+((r=65536)-n%r)%r);if(dt(o))return!0}return!1},s:(t,e,s,n)=>{for(var r,i,a,o=0,h=0;h<s;h++){var l=g[e>>2],d=g[e+4>>2];e+=8;for(var f=0;f<d;f++)r=t,i=m[l+f],a=void 0,a=mt[r],0===i||10===i?((1===r?c:u)(nt(a,0)),a.length=0):a.push(i);o+=d}return g[n>>2]=o,0},u:function(t,e,s,n){const i=r.measureCanvas;i.font=rt(t);let a=i.measureText(rt(e));const o=a.width;a=i.measureText("Op");const h=a.actualBoundingBoxAscent+a.actualBoundingBoxDescent;W(s,o,"double"),W(n,h,"double")}},_t=function(){var t,e,n,r,i={a:bt};function a(t,e){var s;return _t=t.exports,l=_t.Q,_(),Y=_t.Da,s=_t.R,A.unshift(s),function(t){if(0==--S&&E){var e=E;E=null,e()}}(),_t}return S++,j||(j=T()),(t=h,e=j,n=i,r=function(t){a(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||P(e)||"function"!=typeof fetch?O(e,n,r):fetch(e,{credentials:"same-origin"}).then((t=>WebAssembly.instantiateStreaming(t,n).then(r,(function(t){return u(`wasm streaming compile failed: ${t}`),u("falling back to ArrayBuffer instantiation"),O(e,n,r)}))))).catch(s),{}}();r._vizzu_errorMessage=(t,e)=>(r._vizzu_errorMessage=_t.S)(t,e),r._vizzu_version=()=>(r._vizzu_version=_t.T)(),r._vizzu_setLogging=t=>(r._vizzu_setLogging=_t.U)(t),r._vizzu_createChart=()=>(r._vizzu_createChart=_t.V)(),r._vizzu_createCanvas=()=>(r._vizzu_createCanvas=_t.W)(),r._vizzu_pointerMove=(t,e,s,n,i)=>(r._vizzu_pointerMove=_t.X)(t,e,s,n,i),r._vizzu_pointerDown=(t,e,s,n,i)=>(r._vizzu_pointerDown=_t.Y)(t,e,s,n,i),r._vizzu_pointerUp=(t,e,s,n,i)=>(r._vizzu_pointerUp=_t.Z)(t,e,s,n,i),r._vizzu_pointerLeave=(t,e,s)=>(r._vizzu_pointerLeave=_t._)(t,e,s),r._vizzu_wheel=(t,e,s)=>(r._vizzu_wheel=_t.$)(t,e,s),r._vizzu_update=(t,e)=>(r._vizzu_update=_t.aa)(t,e),r._vizzu_render=(t,e,s,n)=>(r._vizzu_render=_t.ba)(t,e,s,n),r._style_getList=()=>(r._style_getList=_t.ca)(),r._style_setValue=(t,e,s)=>(r._style_setValue=_t.da)(t,e,s),r._style_getValue=(t,e,s)=>(r._style_getValue=_t.ea)(t,e,s),r._chart_store=t=>(r._chart_store=_t.fa)(t),r._chart_restore=(t,e)=>(r._chart_restore=_t.ga)(t,e),r._chart_anim_store=t=>(r._chart_anim_store=_t.ha)(t),r._chart_anim_restore=(t,e)=>(r._chart_anim_restore=_t.ia)(t,e),r._object_free=t=>(r._object_free=_t.ja)(t),r._chart_getList=()=>(r._chart_getList=_t.ka)(),r._chart_getValue=(t,e)=>(r._chart_getValue=_t.la)(t,e),r._chart_setValue=(t,e,s)=>(r._chart_setValue=_t.ma)(t,e,s),r._chart_setFilter=(t,e,s)=>(r._chart_setFilter=_t.na)(t,e,s),r._record_getValue=(t,e)=>(r._record_getValue=_t.oa)(t,e),r._data_addDimension=(t,e,s,n,i,a)=>(r._data_addDimension=_t.pa)(t,e,s,n,i,a),r._data_addMeasure=(t,e,s,n,i)=>(r._data_addMeasure=_t.qa)(t,e,s,n,i),r._data_addRecord=(t,e,s)=>(r._data_addRecord=_t.ra)(t,e,s),r._data_metaInfo=t=>(r._data_metaInfo=_t.sa)(t),r._addEventListener=(t,e,s)=>(r._addEventListener=_t.ta)(t,e,s),r._removeEventListener=(t,e,s)=>(r._removeEventListener=_t.ua)(t,e,s),r._event_preventDefault=t=>(r._event_preventDefault=_t.va)(t),r._chart_animate=(t,e)=>(r._chart_animate=_t.wa)(t,e),r._chart_relToCanvasCoords=(t,e,s)=>(r._chart_relToCanvasCoords=_t.xa)(t,e,s),r._chart_canvasToRelCoords=(t,e,s)=>(r._chart_canvasToRelCoords=_t.ya)(t,e,s),r._chart_setKeyframe=t=>(r._chart_setKeyframe=_t.za)(t),r._anim_control_setValue=(t,e,s)=>(r._anim_control_setValue=_t.Aa)(t,e,s),r._anim_control_getValue=(t,e)=>(r._anim_control_getValue=_t.Ba)(t,e),r._anim_setValue=(t,e,s)=>(r._anim_setValue=_t.Ca)(t,e,s);var xt,At=r._malloc=t=>(At=r._malloc=_t.Ea)(t),kt=r._free=t=>(kt=r._free=_t.Fa)(t),Ct=t=>(Ct=_t.Ga)(t);function St(){S>0||(F(x),S>0||xt||(xt=!0,r.calledRun=!0,b||(F(A),e(r),F(C))))}return r.addFunction=(t,e)=>{var s=gt(t);if(s)return s;var n=(()=>{if(wt.length)return wt.pop();try{Y.grow(1)}catch(t){if(!(t instanceof RangeError))throw t;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."}return Y.length-1})();try{vt(n,t)}catch(s){if(!(s instanceof TypeError))throw s;var r=yt(t,e);vt(n,r)}return Q.set(t,n),n},r.removeFunction=t=>{Q.delete(pt(t)),vt(t,null),wt.push(t)},r.setValue=W,r.getValue=function(t,e="i8"){switch(e.endsWith("*")&&(e="*"),e){case"i1":case"i8":return d[t];case"i16":return f[t>>1];case"i32":return p[t>>2];case"i64":B("to do getValue(i64) use WASM_BIGINT");case"float":return w[t>>2];case"double":return v[t>>3];case"*":return g[t>>2];default:B(`invalid type for getValue: ${e}`)}},r.UTF8ToString=rt,r.stringToUTF8=et,r.ExceptionInfo=D,E=function t(){xt||St(),xt||(E=t)},St(),i});const S=new class{constructor(){this.xt={},this.At=null}set options(t){this.xt={...this.xt,...t}}get options(){return this.xt}initialize(){return this.At||(this.At=this.kt()),this.At}async kt(){return new A(await C(this.Ct()))}Ct(){const t={};if(this.xt?.wasmUrl){const e=this.xt.wasmUrl;t.locateFile=t=>t.endsWith(".wasm")?e:t}return t}};class E extends Error{constructor(){super("Canvas is not initialized"),this.name="CanvasError"}}class B extends _{constructor(){super(...arguments),this.St=!1,this.Et=1}get hooks(){return{render:(t,e)=>{"htmlCanvas"in t&&(this.Bt=t.htmlCanvas,t.renderer=this),e()}}}get jt(){if(!this.Bt)throw new E;return this.Bt}get Pt(){if(!this.Bt)throw new E;return this.Bt.context}frameBegin(){this.Et=1,this.St=!1,this.jt.frameBegin()}frameEnd(){this.jt.frameEnd()}setClipRect(t,e,s,n){const r=this.Pt;r.beginPath(),r.rect(t,e,s,n),r.clip()}setClipCircle(t,e,s){const n=this.Pt;n.beginPath(),n.arc(t,e,s,0,6.28318530718),n.clip()}setClipPolygon(){const t=this.Pt;t.closePath(),t.clip(),this.St=!1}setBrushColor(t,e,s,n){this.Pt.fillStyle="rgba("+255*t+","+255*e+","+255*s+","+n+")"}setLineColor(t,e,s,n){this.Pt.strokeStyle="rgba("+255*t+","+255*e+","+255*s+","+n+")"}setLineWidth(t){this.Pt.lineWidth=t,this.Et=t}setFontStyle(t){this.Pt.font=t}beginDropShadow(){}setDropShadowBlur(t){this.Pt.shadowBlur=t}setDropShadowColor(t,e,s,n){this.Pt.shadowColor="rgba("+255*t+","+255*e+","+255*s+","+n+")"}setDropShadowOffset(t,e){const s=this.Pt;s.shadowOffsetX=t,s.shadowOffsetY=e}endDropShadow(){const t=this.Pt;t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowColor="rgba(0, 0, 0, 0)"}beginPolygon(){this.Pt.beginPath()}addPoint(t,e){const s=this.Pt;this.St?s.lineTo(t,e):s.moveTo(t,e),this.St=!0}addBezier(t,e,s,n,r,i){this.Pt.bezierCurveTo(t,e,s,n,r,i)}endPolygon(){const t=this.Pt;t.closePath(),t.fill(),0!==this.Et&&t.stroke(),this.St=!1}rectangle(t,e,s,n){const r=this.Pt;r.beginPath(),r.rect(t,e,s,n),r.fill(),0!==this.Et&&r.stroke()}circle(t,e,s){const n=this.Pt;n.beginPath(),n.arc(t,e,s,0,6.28318530718),n.fill(),0!==this.Et&&n.stroke()}line(t,e,s,n){const r=this.Pt;r.beginPath(),r.moveTo(t,e),r.lineTo(s,n),0!==this.Et&&r.stroke()}drawText(t,e,s,n,r){const i=this.Pt;i.textAlign="left",i.textBaseline="top",t+=s<0?-s:0,e+=n<0?-n:0,i.fillText(r,t,e)}setGradient(t,e,s,n,r){const i=this.Pt,a=i.createLinearGradient(t,e,s,n);r.stops.forEach((t=>a.addColorStop(t.offset,t.color))),i.fillStyle=a}transform(t,e,s,n,r,i){this.Pt.transform(t,e,s,n,r,i)}save(){this.Pt.save()}restore(){this.Pt.restore()}}class j{constructor(){this.meta={name:"clock"}}get api(){return{now:()=>this.Tt()}}get hooks(){return{update:(t,e)=>{null===t.timeInMSecs&&(t.timeInMSecs=this.Tt()),e()}}}Tt(){return performance.now()}}class P{constructor(t){this.meta={name:"coordSystem"},this.api={toCanvas:t=>this.zt.toCanvasCoords(t),toRelative:t=>this.zt.toRelCoords(t)},this.zt=t}}const T=t=>{try{return t.cssRules,!0}catch(t){return!1}},z=(t,e="")=>{const s=((t="")=>[...document.styleSheets].filter(T).reduce(((e,s)=>e.concat([...s.cssRules].filter((t=>"CSSStyleRule"===t.constructor.name)).reduce(((e,s)=>[...e,...[...s.style].filter((e=>0===e.trim().indexOf("--"+t+"-"))).map((t=>t.trim()))]),[]))),[]))(e),n=getComputedStyle(t);return s.map((t=>[t,n.getPropertyValue(t).trim()])).filter((t=>""!==t[1]))};class O{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 s=z(this.Ot.feature.htmlCanvas.element,this.api.prefix);Array.isArray(t.target)&&t.target.forEach((({target:t})=>{t instanceof d||(t.style=((t,e,s="",n=!1)=>(e=e||{},e=t.reduce(((t,[e,r])=>(e&&((t,e,s,n)=>{e.reduce(((t,r,i)=>(i===e.length-1?!n&&t[r]||(t[r]=s):t[r]||(t[r]={}),t[r])),t)})(t,e.replace("--"+(s?s+"-":""),"").split("-"),r,n),t)),e),e))(s,t.style,this.api.prefix))})),e()}}}register(t){this.Ot=t}}var F;!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"}(F||(F={}));class W{constructor(t){this.Ft={},this.Wt=t}add(t,e){if("string"!=typeof t)throw new Error("first parameter should be string");this.Dt(t).push(e)}Dt(t){if(!(t in this.Ft)){let e=null;if(!this.Ut(t)){const s=(e,s)=>{this.It(t,s,e)};e=this.Wt.addEventListener(t,s)}this.Ft[t]=[e,[]]}return this.Ft[t][1]}remove(t,e){if("string"!=typeof t)throw new Error("first parameter should be string");const s=this.Ft[t];if(!s)throw new Error("unknown event handler");const[n,r]=s;r.find(((t,s)=>t===e&&(r.splice(s,1),!0))),0===r.length&&(this.Ut(t)||n&&this.Wt.removeEventListener(t,n),delete this.Ft[t])}addMany(t){for(const[e,s]of Object.entries(t))this.add(e,s)}removeMany(t){for(const[e,s]of Object.entries(t))this.remove(e,s)}It(t,e,s){const n={canceled:!1};try{const r=this.Ft[t];if(r)for(const i of[...r[1]]){i(this.Ut(t)?this.Mt(e,n):s?this.Nt(s,e,n):e)}}catch(t){console.log("exception in event handler: "+t)}return n.canceled}Ut(t){return t.startsWith("api-")}Mt(t,e){return t.preventDefault=()=>{e.canceled=!0},t}Nt(t,e,s){return e.preventDefault=()=>{t.preventDefault(),s.canceled=!0},e}}var D=Object.freeze({__proto__:null,get EventType(){return F},Events:W});class U{get api(){const t=this;return{get element(){return t.Rt},set element(e){t.Lt(e)},context:this.context,clientToCanvas:this.$t.bind(this),canvasToClient:this.Vt.bind(this)}}get hooks(){return{start:(t,e)=>{this.Ht=t.update,e()},render:(t,e)=>{t.htmlCanvas=this,t.size=this.qt(),e()}}}get listeners(){return Object.fromEntries(Object.values(F).filter((t=>t.endsWith("-draw")||t.startsWith("draw-"))).map((t=>[t,this.Gt.bind(this)])))}Gt(t){t.renderingContext=this.context}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 s=e.element;if("string"==typeof s&&(s=document.getElementById(s)),!(s instanceof HTMLElement))throw new Error(`Cannot find element ${e.element} to render Vizzu!`);return{element:s}}constructor(t){this.Ht=()=>{},this.Kt="",this.Jt=1,this.Yt=1,this.Qt=1,this.meta={name:"htmlCanvas"},this.Xt=document.createElement("canvas");const e=this.Xt.getContext("2d");if(!e)throw Error("Cannot get rendering context of internal canvas");this.Zt=e,this.te=()=>{this.Ht(!0)},this.Lt(t.element),window.addEventListener("resize",this.te)}Lt(t){this.Rt=this.ee(t),this.Kt="";const e=this.Rt.getContext("2d");if(!e)throw Error("Cannot get rendering context of canvas");this.Pt=e,this.qt(),this.se=this.ne(this.Rt)}unregister(){window.removeEventListener("resize",this.te),this.se.disconnect(),this.re&&this.re.removeChild(this.Rt)}get element(){return this.Rt}set element(t){this.Lt(t)}get context(){return this.Zt}qt(){this.Jt=window.devicePixelRatio,this.Yt=+getComputedStyle(this.Rt).width.slice(0,-2),this.Qt=+getComputedStyle(this.Rt).height.slice(0,-2);const t=`${this.Jt}:${this.Yt}:${this.Qt}`;return t!==this.Kt&&(this.Rt.width=this.Yt*this.Jt,this.Rt.height=this.Qt*this.Jt,this.Xt.width=this.Yt*this.Jt,this.Xt.height=this.Qt*this.Jt,this.Zt.setTransform(1,0,0,1,0,0),this.Zt.translate(.5,.5),this.Zt.scale(this.Jt,this.Jt)),this.Kt=t,{x:this.Yt,y:this.Qt}}frameBegin(){this.Zt.clearRect(-1,-1,this.Yt+2,this.Qt+2)}frameEnd(){this.Pt.clearRect(-1,-1,this.Rt.width+1,this.Rt.height+1),this.Pt.drawImage(this.Xt,0,0)}ie(){return this.Rt.getBoundingClientRect()}ae(t){return{x:t.width/(this.Rt.width/this.Jt),y:t.height/(this.Rt.height/this.Jt)}}$t(t){const e=this.ie(),s=this.ae(e);return{x:(t.x-e.x)/s.x,y:(t.y-e.y)/s.y}}Vt(t){const e=this.ie(),s=this.ae(e);return{x:e.x+t.x*s.x,y:e.y+t.y*s.y}}ee(t){if(t instanceof HTMLCanvasElement)return t;{const e=document.createElement("canvas");return e.style.width="100%",e.style.height="100%",this.re=t,this.re.appendChild(e),e}}ne(t){const e=new ResizeObserver((()=>{this.Ht(!0)}));return e.observe(t),e}}class I{constructor(t){this.meta={name:"logging"},this.oe=t}enable(t){this.oe(t)}}const M=(t,e)=>{if(!t)throw new Error("Assert failed: "+e)},N=(t,e,s)=>{M(Array.isArray(e),"array is not a list");try{if(e.length!==t.dimensions[s].values.length)throw new Error("Assert failed")}catch(t){M(!1,"dimensions are not the same")}e.forEach((e=>{Array.isArray(e)&&N(t,e,s-1)}))};class R{static isPivot(t){return void 0!==t&&("dimensions"in t&&void 0!==t.dimensions||"measures"in t&&void 0!==t.measures)}static convert(t){M("object"==typeof t&&null!==t&&!Array.isArray(t),"data is not an object"),M("dimensions"in t,"data.dimensions is requreid"),M("measures"in t,"data.measures is requreid");const e=(({dimensions:t,measures:e,...s})=>Object.assign(s,{series:[]}))(t);let s=1;M(Array.isArray(t.dimensions),"data.dimensions is not a list");for(let e=0;e<t.dimensions.length;e++){const n=t.dimensions[e];M("object"==typeof n&&null!==n&&!Array.isArray(n),"data.dimensions.item is not an object"),M("name"in n,"data.dimensions.item.name is requreid"),M(void 0===n.type||"dimension"===n.type,"data.dimensions.item.type is invalid"),M("values"in n,"data.dimensions.item.values is requreid"),M(Array.isArray(n.values),"data.dimensions.item.values is not a list"),M(0!==n.values.length,"data.dimensions.item.values length is zero"),s*=n.values.length}let n=1;for(let r=0;r<t.dimensions.length;r++){const i=t.dimensions[r];let a=[];const o=[];i.values.forEach((t=>{for(let e=1;e<=n;e++)o.push(t)})),n*=i.values.length;for(let t=1;t<=s/n;t++)a=a.concat(o);const h={name:i.name,type:"dimension",values:a};e.series.push(h)}M("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 n=0;n<t.measures.length;n++){const r=t.measures[n];M("object"==typeof r&&null!==r&&!Array.isArray(r),"data.measures.item is not an object"),M("name"in r,"data.measures.item.name is requreid"),M("values"in r,"data.measures.item.values is requreid"),M(Array.isArray(r.values),"data.measures.item.values is not a list"),N(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,M(i.values.length===s,"dimensions are not the same"),e.series.push(i)}return e}}class L{constructor(){this.meta={name:"pivotData"}}get hooks(){return{prepareAnimation:(t,e)=>{Array.isArray(t.target)&&t.target.forEach((({target:t})=>{if(!(t instanceof d)&&t.data&&t.data&&R.isPivot(t.data)){if(L.he(t.data))throw new Error("inconsistent data form: series/records and dimensions/measures are both set.");t.data=R.convert(t.data)}})),e()}}}static he(t){return"series"in t||"records"in t}}class $ extends Error{constructor(){super("animation canceled"),this.name="CancelError"}}class V extends Error{constructor(){super("vizzu is not initialized, use `initializing` promise"),this.name="NotInitializedError"}}class H{constructor(t){this.le=!1,this.meta={name:"pointerEvents",depends:["htmlCanvas"]},this.ce={pointermove:e=>{this.ue(e,t.pointermove.bind(t))},pointerup:e=>{this.ue(e,t.pointerup.bind(t))},pointerdown:e=>{this.ue(e,t.pointerdown.bind(t))},pointerleave:e=>{this.ue(e,t.pointerleave.bind(t))},wheel:e=>{this.ue(e,t.wheel.bind(t),"deltaY")}}}register(t){this.de=t,this.me=this.de?.feature.htmlCanvas}unregister(){this.le&&this.fe()}enable(t){this.le=t,t?this.ye():this.fe()}ye(){if(!this.de||!this.ce)throw new V;this.jt=this.de.feature.htmlCanvas.element;for(const[t,e]of Object.entries(this.ce))this.jt.addEventListener(t,e,{passive:!1})}fe(){if(this.ce&&this.jt)for(const[t,e]of Object.entries(this.ce))this.jt.removeEventListener(t,e);delete this.jt}ue(t,e,s="pointerId"){const n=[t[s]];void 0!==t.clientX&&n.push(...this.pe(t)),e(...n)}pe(t){const e={x:t.clientX,y:t.clientY};if(!this.me)throw new V;const s=this.me.clientToCanvas(e);return[s.x,s.y]}}const q={column:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},label:{set:[{name:"y"}]}}},groupedColumn:{channels:{x:{set:[{name:"groupedBy"},{name:"x"}]},y:{set:[{name:"y"}]},label:{set:[{name:"y"}]},color:{set:[{name:"x"}]}}},stackedColumn:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"stackedBy"}]},label:{set:[{name:"y"}]},color:{set:[{name:"stackedBy"}]}}},splittedColumn:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"splittedBy"}]},color:{set:[{name:"splittedBy"}]},label:{set:[{name:"y"}]}},split:!0},percentageColumn:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"stackedBy"}]},color:{set:[{name:"stackedBy"}]},label:{set:[{name:"y"}]}},align:"stretch"},waterfall:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"x"}]},label:{set:[{name:"y"}]},color:{set:[{name:"y"}]}}},mekko:{channels:{x:{set:[{name:"x"},{name:"groupedBy"}]},y:{set:[{name:"y"},{name:"stackedBy"}]},color:{set:[{name:"stackedBy"}]},label:{set:[{name:"x"}]}}},marimekko:{channels:{x:{set:[{name:"x"},{name:"groupedBy"}]},y:{set:[{name:"y"},{name:"stackedBy"}]},color:{set:[{name:"stackedBy"}]},label:{set:[{name:"x"}]}},align:"stretch"},bar:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},label:{set:[{name:"x"}]}}},groupedBar:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"groupedBy"},{name:"y"}]},label:{set:[{name:"x"}]},color:{set:[{name:"y"}]}}},stackedBar:{channels:{x:{set:[{name:"x"},{name:"stackedBy"}]},y:{set:[{name:"y"}]},label:{set:[{name:"x"}]},color:{set:[{name:"stackedBy"}]}}},splittedBar:{channels:{x:{set:[{name:"x"},{name:"splittedBy"}]},y:{set:[{name:"y"}]},color:{set:[{name:"splittedBy"}]},label:{set:[{name:"x"}]}},split:!0},percentageBar:{channels:{x:{set:[{name:"x"},{name:"stackedBy"}]},y:{set:[{name:"y"}]},color:{set:[{name:"stackedBy"}]},label:{set:[{name:"x"}]}},align:"stretch"},lollipop:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},label:{set:[{name:"y"}]}},geometry:"circle"},scatter:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},noop:{set:[{name:"dividedBy"}]}},geometry:"circle"},bubbleplot:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},color:{set:[{name:"color"}]},size:{set:[{name:"size"}]},label:{set:[{name:"dividedBy"}]},noop:{set:[{name:"dividedBy"}]}},geometry:"circle"},area:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]}},geometry:"area"},stackedArea:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"stackedBy"}]},color:{set:[{name:"stackedBy"}]}},geometry:"area"},percentageArea:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"stackedBy"}]},color:{set:[{name:"stackedBy"}]}},align:"stretch",geometry:"area"},splittedArea:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"splittedBy"}]},color:{set:[{name:"splittedBy"}]}},split:!0,geometry:"area"},stream:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"stackedBy"}]},color:{set:[{name:"stackedBy"}]}},geometry:"area",align:"center"},verticalStream:{channels:{x:{set:[{name:"x"},{name:"stackedBy"}]},y:{set:[{name:"y"}]},color:{set:[{name:"stackedBy"}]}},geometry:"area",align:"center"},violin:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"},{name:"splittedBy"}]},color:{set:[{name:"splittedBy"}]}},geometry:"area",align:"center",split:!0},verticalViolin:{channels:{x:{set:[{name:"x"},{name:"splittedBy"}]},y:{set:[{name:"y"}]},color:{set:[{name:"splittedBy"}]}},geometry:"area",align:"center",split:!0},line:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},color:{set:[{name:"dividedBy"}]}},geometry:"line"},verticalLine:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},color:{set:[{name:"dividedBy"}]}},geometry:"line"},pie:{channels:{x:{set:[{name:"angle"},{name:"by"}]},color:{set:[{name:"by"}]},label:{set:[{name:"angle"}]}},coordSystem:"polar"},polarColumn:{channels:{x:{set:[{name:"angle"}]},y:{set:[{name:"radius"}]},label:{set:[{name:"radius"}]}},coordSystem:"polar"},polarStackedColumn:{channels:{x:{set:[{name:"angle"}]},y:{set:[{name:"radius"},{name:"stackedBy"}]},color:{set:[{name:"stackedBy"}]}},coordSystem:"polar"},variableRadiusPie:{channels:{x:{set:[{name:"angle"},{name:"by"}]},y:{set:[{name:"radius"}]},color:{set:[{name:"by"}]},label:{set:[{name:"radius"}]}},coordSystem:"polar"},radialBar:{channels:{x:{set:[{name:"angle"}]},y:{set:[{name:"radius"}],range:{min:"-50%"}},label:{set:[{name:"angle"}]}},coordSystem:"polar"},radialStackedBar:{channels:{x:{set:[{name:"angle"},{name:"stackedBy"}]},y:{set:[{name:"radius"}],range:{min:"-50%"}},color:{set:[{name:"stackedBy"}]},label:{set:[{name:"angle"}]}},coordSystem:"polar"},donut:{channels:{x:{set:[{name:"angle"},{name:"stackedBy"}]},y:{range:{min:"-200%",max:"100%"}},color:{set:[{name:"stackedBy"}]}},coordSystem:"polar"},nestedDonut:{channels:{x:{set:[{name:"angle"},{name:"stackedBy"}]},y:{set:[{name:"radius"}],range:{min:"-50%"}},color:{set:[{name:"stackedBy"}]},label:{set:[{name:"angle"}]}},coordSystem:"polar",align:"stretch"},polarScatter:{channels:{x:{set:[{name:"angle"}]},y:{set:[{name:"radius"}]},noop:{set:[{name:"dividedBy"}]}},coordSystem:"polar",geometry:"circle"},polarLine:{channels:{x:{set:[{name:"angle"}]},y:{set:[{name:"radius"}]},color:{set:[{name:"dividedBy"}]}},coordSystem:"polar",geometry:"line"},treemap:{channels:{size:{set:[{name:"size"},{name:"color"}]},color:{set:[{name:"color"}]},label:{set:[{name:"color"}]}}},stackedTreemap:{channels:{size:{set:[{name:"size"},{name:"dividedBy"}]},color:{set:[{name:"color"}]},label:{set:[{name:"dividedBy"}]},lightness:{set:[{name:"size"}]}}},heatmap:{channels:{x:{set:[{name:"x"}]},y:{set:[{name:"y"}]},lightness:{set:[{name:"lightness"}]}}},bubble:{channels:{size:{set:[{name:"size"}]},color:{set:[{name:"color"}]},label:{set:[{name:"color"}]}},geometry:"circle"},stackedBubble:{channels:{size:{set:[{name:"size"},{name:"stackedBy"}]},color:{set:[{name:"color"}]}},geometry:"circle"}};class G{constructor(){this.ge=q;for(const t in this.ge){const e=t;this[e]=t=>this.we(e,t)}}ve(){return{align:"none",coordSystem:"cartesian",orientation:"auto",angle: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}}}}be(t){const e=h(this.ge[t]),s={...this.ve().channels,...e.channels},n=Object.assign(this.ve(),e);return n.channels=s,n}_e(t){return null==t?null:Array.isArray(t)?t:[t]}xe(t,e){if(!e)return;const s=t.channels;for(const t in s){const n=s[t];if(this.Ae(n))if("string"==typeof n.set){const t=n.set;n.set=this._e(e[t])}else if(Array.isArray(n.set)){const t=[];for(let s=0;s<n.set.length;s++){const r=n.set[s].name,i=this._e(e[r]);null!==i&&t.push(i)}n.set=t.length>0?t.flat():null}}}Ae(t){return"object"==typeof t&&null!==t&&"set"in t}ke(t,e,s){const n=e[s];void 0!==n&&(t[s]=n)}Ce(t,e){["legend","title","subtitle","caption","reverse","sort"].forEach((s=>{const n=s;this.ke(t,e,n)}))}we(t,e){const s=this.be(t);return this.xe(s,e),this.Ce(s,e),s}}var K,J;!function(t){t.start="start",t.update="update",t.render="render",t.prepareAnimation="prepareAnimation",t.registerAnimation="registerAnimation",t.runAnimation="runAnimation"}(K||(K={})),function(t){t.forced="forced",t.allowed="allowed",t.disabled="disabled"}(J||(J={}));class Y{constructor(t,e){if(this.Se=t,this.Ee=[],e){if(!Array.isArray(e))throw new Error("Plugins must be an array");e.forEach((t=>this.register(t,!0)))}}init(t){this.Be=t,this.Ee.forEach((t=>{t.enabled&&this.je(t)}))}enable(t,e){const s=this.Pe(t);this.Te(s,e)}getRegisteredName(t){const e=this.Ee.find((e=>e.instance===t));return e?.name}register(t,e=!0){this.ze(t);const s=this.Oe(t);t.register&&this.Se&&t.register(this.Se);const n={name:s,instance:t,enabled:!e};return this.Ee.push(n),this.Te(n,e),s}destruct(){const t=this.Ee.map((t=>t.name));try{t.forEach((t=>this.unregister(t)))}finally{this.Ee=[],this.Se=null}}unregister(t){const e=this.Ee.findIndex((e=>e.name===t));if(-1!==e){const t=this.Ee[e];this.Ee.splice(e,1),t?.instance.unregister&&this.Se&&t.instance.unregister(this.Se)}}api(t){return this.Pe(t).instance.api||{}}hook(t,e){return{default:(s=(()=>{}))=>{this.Fe(e,t,s)}}}Te(t,e){t.enabled!==e&&(t.enabled=e,t.instance.enable&&t.instance.enable(e),t.enabled?this.je(t):this.We(t))}je(t){t.instance.listeners&&(t.registeredListeners=t.instance.listeners,this.Be?.addMany(t.registeredListeners))}We(t){t.registeredListeners&&this.Be?.removeMany(t.registeredListeners),delete t.registeredListeners}ze(t){this.De(t),this.Ue(t)}De(t){const e=this.Oe(t);if(!("string"==typeof e&&e.length>0))throw new Error("Plugin must have a non empty name string")}Oe(t){return t.meta?.name??(t.constructor?.name?this.Ie(t.constructor.name):void 0)}Ie(t){return"string"==typeof t&&t[0]?t[0].toLowerCase()+t.slice(1):""}Ue(t){if(t.meta?.depends){if(Array.isArray(t.meta.depends)){for(const e of t.meta.depends)this.Pe(e);return}throw new Error("Plugin depends must be an array")}}Pe(t){const e=this.Ee.find((e=>e.name===t));if(e)return e;throw new Error(`Plugin ${t} is not registered`)}Fe(t,e,s){const n=[...this.Me(e),s];this.Ne(n,t)}Me(t){return this.Ee.filter((e=>e.enabled&&e.instance.hooks?.[t])).map((e=>e.instance.hooks[t])).sort(((t,e)=>(e.priority||0)-(t.priority||0)))}Ne(t,e){const s=n=>{if(n>=t.length)return;const r=t[n],i=()=>s(n+1);r?r(e,i):i()};s(0)}}var Q=Object.freeze({__proto__:null,get Hooks(){return K},PluginRegistry:Y,get RenderControlMode(){return J}});class X{constructor(){this.Ht=()=>{},this.Re=null,this.le=!0,this.meta={name:"rendering"}}get api(){return{update:(t=null)=>{this.Re=t,this.Ht(!0)}}}get hooks(){return{start:(t,e)=>{this.Ht=t.update,e()},update:(t,e)=>{null!==this.Re&&(t.timeInMSecs=this.Re,this.Re=null),e()},render:(t,e)=>{t.control===J.disabled&&this.le&&(t.control=J.allowed),e()}}}enable(t){this.le=t}}class Z{constructor(){this.Ht=()=>{},this.le=!1,this.meta={name:"scheduler"}}get hooks(){return{start:(t,e)=>{this.Ht=t.update,this.Le(),e()}}}enable(t){this.le=t,this.le?this.Le():this.$e()}unregister(){this.$e()}Le(){this.Ve||(this.Ht(!1),this.Ve=setInterval((()=>{this.le&&this.Ht(!1)}),25))}$e(){this.Ve&&clearInterval(this.Ve),delete this.Ve}}class tt{constructor(t){return new Proxy(this,{get:(e,s)=>t.getValue(s)})}}class et{constructor(t){this.He=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.qe(e)}if("records"in t){if(!Array.isArray(t.records))throw new Error("data records field is not an array");const e=this.He.getMetaInfo().series;for(const s of t.records)this.Ge(s,e)}(t.filter||null===t.filter)&&this.Ke(t.filter)}}Ge(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.Je(t,e)}this.He.addRecord(t)}Je(t,e){const s=[];return e.forEach((e=>{e.name in t?s.push(t[e.name]||this.Ye(e.type)):s.push(this.Ye(e.type))})),s}Ye(t){return"measure"===t?0:""}qe(t){if(!t.name)throw new Error("missing series name");if(this.Qe(t))this.Xe(t),this.Ze(t.name,t.values??[],t.categories);else{const e=t?.values??[],s=t?.type??this.ts(e);if("dimension"===s){const{indexes:s,categories:n}=this.es(e);this.Ze(t.name,s,n)}else{if(!this.ss(t,s))throw new Error("invalid series type: "+t.type);t.unit||(t.unit=""),this.ns(t.name,t.unit,e)}}}Qe(t){return!(!("categories"in t)||!Array.isArray(t.categories))}ss(t,e){return"measure"===e||"unit"in t&&"string"==typeof t.unit}Xe(t){if(t.values&&Array.isArray(t.values)){const e=t.categories.length;for(const s of t.values){if(null===s)continue;const t=Number(s);if(!Number.isInteger(t))throw new Error("invalid category value (not an int): "+t);if(t<0)throw new Error("invalid category value (negative): "+t);if(t>=e)throw new Error("invalid category value (out of range): "+t)}}if(new Set(t.categories).size!==t.categories.length)throw new Error("duplicate category values")}ts(t){if(Array.isArray(t)&&t.length){if("number"==typeof t[0]||null===t[0])return"measure";if("string"==typeof t[0])return"dimension"}return null}Ze(t,e,s){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(!(s instanceof Array))throw new Error("third parameter should be an array");if(!this.rs(s))throw new Error("third parameter should be an array of strings");if(!this.os(e))throw new Error("the measure index array element should be number");this.He.addDimension(t,e,s)}rs(t){for(const e of t)if("string"!=typeof e)return!1;return!0}os(t){for(const e of t){const t=Number(e);if(!Number.isInteger(t)||t<0)return!1}return!0}es(t){const e=new Map,s=[],n=new Array(t.length);for(let r=0;r<t.length;r++){const i=t[r];if("string"!=typeof i)continue;let a=e.get(i);void 0===a&&(a=s.length,e.set(i,a),s.push(i)),n[r]=a}return{categories:s,indexes:n}}ns(t,e,s){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(!(s instanceof Array))throw new Error("'values' parameter should be an array");const n=s.map((t=>Number(t)));this.He.addMeasure(t,e,n)}Ke(t){if("function"==typeof t){const e=e=>t(new tt(e));this.He.setFilter(e)}else{if(null!==t)throw new Error("data filter is not a function or null");this.He.setFilter(null)}}}class st{constructor(t){this.hs=t}store(){return this.hs.storeAnim()}seek(t){const e="string"!=typeof t?t.toString():t;return this.ls("seek",e),this}set speed(t){const e="string"!=typeof t?t.toString():t;this.ls("speed",e)}get speed(){return Number(this.cs("speed"))}set playState(t){this.ls("playState",t)}get playState(){return this.cs("playState")}set direction(t){this.ls("direction",t)}get direction(){return this.cs("direction")}set position(t){const e="string"!=typeof t?t.toString():t;this.ls("position",e)}get position(){return this.cs("position")}pause(){return this.playState="paused",this}play(){return this.playState="running",this}stop(){return this.ls("stop"),this}cancel(){return this.ls("cancel"),this}reverse(){return this.direction="reverse"===this.direction?"normal":"reverse",this}ls(t,e=""){this.hs.setParam(t,e)}cs(t){return this.hs.getParam(t)}}class nt{constructor(){this.meta={name:"shorthands"}}get hooks(){return{prepareAnimation:Object.assign(((t,e)=>{this.us(t),e()}),{priority:1})}}register(t){this.Ot=t,this.ds=Object.keys(this.Ot.config.channels)}us(t){if(!(t.target instanceof r)){const e=this.fs(t.target,t.options);void 0===t.options||this.ys(t.target)||delete t.options,t.target=e}const e=this.ps(t.options);e&&(t.options=e)}fs(t,e){return(this.ys(t)?t:[this.gs(t,e)]).map((t=>this.ws(t)?t:{target:t})).map((t=>this.vs(t)))}gs(t,e){return Object.assign({target:t},void 0!==e?{options:e}:{})}ys(t){return Array.isArray(t)}ws(t){return"target"in t}vs(t){const e=this.ps(t.options);return Object.assign({target:this.bs(t.target)},e?{options:e}:{})}bs(t){if(t&&!(t instanceof d)){if(this._s(t))return{config:this.xs(t)};void 0!==t.config&&(t.config=this.xs(t.config)),void 0!==t.style&&(t.style=this.As(t.style))}return t}As(t){return null===t?{"":null}:void 0===t?{}:t}ks(t){return"data"in t||"style"in t||"config"in t}_s(t){return!this.ks(t)}xs(t){const{channels:e,...s}=this.Cs(t);return{...s,...e?{channels:this.Ss(e)}:{}}}Cs(t){if(null!==t&&"object"==typeof t){t.channels=t.channels||{};for(const e in t){const s=e;if(this.Es(s)){const e=t[s];void 0!==e&&(t.channels[s]=e),delete t[s]}}}return t}Es(t){return this.ds.includes(t)}Ss(t){const e={};for(const s in t){const n=s,r=t[n];void 0!==r&&(e[n]=this.Bs(r))}return e}Bs(t){if("string"==typeof t&&(t=[t]),this.js(t)?t={set:this.Ps(t)}:void 0!==t.set&&this.js(t.set)&&(t.set=this.Ps(t.set)),void 0!==t.attach&&this.js(t.attach)){const e=this.Ps(t.attach);null!==e?t.attach=e:delete t.attach}if(void 0!==t.detach&&this.js(t.detach)){const e=this.Ps(t.detach);null!==e?t.detach=e:delete t.detach}return t}js(t){return null===t||"string"==typeof t||Array.isArray(t)||"object"==typeof t&&"name"in t}Ps(t){return null===t?null:Array.isArray(t)?0===t.length?null:t.map((t=>this.Ts(t))):"string"==typeof t?[this.Ts(t)]:"object"==typeof t&&"name"in t?[t]:null}Ts(t){if("string"==typeof t){const e=/^(\w+)\((.*?)\)$/,s=t.match(e);return s?{name:s[2],aggregator:s[1]}:{name:t}}return t}ps(t){return void 0!==t&&(null===t?t={duration:0}:"string"!=typeof t&&"number"!=typeof t||(t={duration:t})),t}}class rt{constructor(){this.zs=0,this.Os=!1,this.Fs=null,this.Ws=null,this.Ds=(new Date).getTime(),this.meta={name:"tooltip",depends:["pointerEvents"]},this.listeners={pointermove:this.Us.bind(this),pointerleave:this.Is.bind(this)}}get hooks(){return{prepareAnimation:(t,e)=>{Array.isArray(t.target)&&t.target.forEach((({target:t})=>{t instanceof d||(t.config||(t.config={}),"tooltip"in t.config||(t.config.tooltip=null,this.zs++,this.Fs=null))})),e()}}}register(t){this.de=t}enable(t){t||null===this.Fs||(this.zs++,setTimeout((()=>{this.Ms(this.zs)}),200))}Us(t){this.Ds=(new Date).getTime();const e=this.Ns(t.target);e!==this.Ws&&(this.Ws=e,this.Rs(t))}Is(t){this.Ds=(new Date).getTime(),this.Ws=null,this.Rs(t)}Rs(t){this.zs++;const e=this.zs,s=this.Ns(t.target);null!==s?setTimeout((()=>{this.Ls(e,s)}),0):setTimeout((()=>{this.Ms(e)}),200)}Ns(t){return t&&this.$s(t)?t.index:t&&this.Vs(t)?t.parent.index:null}$s(t){return"plot-marker"===t.tagName}Vs(t){return"plot-marker-label"===t.tagName}Ls(t,e){this.zs===t&&(this.Os?setTimeout((()=>{this.Ls(t,e)}),100):(this.Fs=e,this.Os=!0,this.de?.animate([{target:{config:{tooltip:e}},options:{duration:this.Fs?"100ms":"250ms"}}]).then((()=>{this.Os=!1}))))}Ms(t){if(this.zs===t){const e=(new Date).getTime()-this.Ds;!this.Os&&e>200?(this.Fs=null,this.Os=!0,this.de?.animate([{target:{config:{tooltip:null}},options:{duration:"250ms"}}]).then((()=>{this.Os=!1}))):setTimeout((()=>{this.Ms(t)}),200-e)}}}class it{constructor(t,e,s){this.Hs=!0,this.xt=e,this.Ee=s,this.qs=t,this.Wt=this.qs.createChart(),this.qs.registerChart(this.Wt,this),this.vt=this.qs.createCanvas(),this.He=this.qs.getData(this.Wt),this.Gs=new et(this.He),this.Be=new W(this.Wt),this.Ee.init(this.Be)}registerBuiltins(){this.Ee.register(new I(this.qs.setLogging.bind(this.qs)),!1),this.Ee.register(new U(U.extractOptions(this.xt)),!0),this.Ee.register(new B,!0),this.Ee.register(new j,!0),this.Ee.register(new Z,!0),this.Ee.register(new X,!0),this.Ee.register(new P(this.qs.getCoordSystem(this.Wt)),!0),this.Ee.register(new O,!1),this.Ee.register(new nt,!0),this.Ee.register(new L,!0),this.Ee.register(new H(this.Wt),!0),this.Ee.register(new rt,!1)}detach(){this.qs.unregisterChart(this.Wt),this.vt.free(),this.Wt.free()}start(){const t={update:t=>this.updateAndRender(t)};this.Ee.hook(K.start,t).default((()=>{this.updateAndRender()}))}updateAndRender(t=!1){this.Ht(),this.Ks(t)}Ht(){this.Ee.hook(K.update,{timeInMSecs:null}).default((t=>{t.timeInMSecs&&this.Wt.update(t.timeInMSecs)}))}Ks(t){const e={renderer:null,control:t?J.forced:J.disabled,changed:this.Hs,size:{x:0,y:0}};this.Ee.hook(K.render,e).default((t=>{if(t.size.x<1||t.size.y<1||!t.renderer)return;(t.control===J.forced||t.control===J.allowed&&t.changed)&&(t.renderer.canvas=this.vt,this.qs.registerRenderer(this.vt,t.renderer),this.Wt.render(this.vt,t.size.x,t.size.y),this.qs.unregisterRenderer(this.vt),this.Hs=!1)}))}doChange(){this.Hs=!0}openUrl(t){window.open(this.Wt.getString(t),"_blank")}async prepareAnimation(t,e){const s=Object.assign({target:t},void 0!==e?{options:e}:{});await this.Ee.hook(K.prepareAnimation,s).default((t=>{this.setAnimParams(t.target,t.options)}))}runAnimation(t){const e={callback:t};this.Ee.hook(K.runAnimation,e).default((t=>{this.Wt.animate(t.callback)}))}setAnimParams(t,e){if(t instanceof r)this.Wt.restoreAnim(t);else for(const e of t)this.Js(e.target,e.options);e&&this.Wt.animOptions.set(e)}Js(t,e){t&&(t instanceof d?this.Wt.restoreSnapshot(t):(t.data&&this.Gs.set(t.data),t.style&&this.Wt.style.set(t.style),t.config&&(this.Ys(t.config),this.Wt.config.set(t.config)))),e&&this.Wt.animOptions.set(e),this.Wt.setKeyframe()}Ys(t){t.channels&&Object.values(t.channels).forEach((t=>{Array.isArray(t?.set)&&0===t?.set.length&&(t.set=null)}))}version(){return this.qs.version()}get data(){return this.He.getMetaInfo()}get config(){return this.Wt.config.get()}get style(){return this.Wt.style.get()}getComputedStyle(){return this.Wt.computedStyle.get()}on(t,e){this.Be.add(t,e)}off(t,e){this.Be.remove(t,e)}store(){return this.Wt.storeSnapshot()}getAnimControl(){return new st(this.Qs())}Qs(){return this.qs.getAnimControl(this.Wt)}}class at{static get presets(){return new G}static options(t){S.options=t}static initialize(){return S.initialize().then((()=>{}))}constructor(t,e){this.Ee=new Y(this,this.Xs(t)),this.initializing=S.initialize().then((e=>(this.Ot=new it(e,t,this.Ee),this.Ot.registerBuiltins(),this.Ot.start(),this))),this.Zs=this.initializing,e&&(this.initializing=this.animate([{target:e,options:{duration:0}}]).then((()=>this)))}Xs(t){return"object"==typeof t&&null!==t&&"features"in t?t.features:[]}get feature(){const t=this.tn.bind(this);return new Proxy(t,{get:(t,e)=>this.Ee.api(e)})}tn(t,e){if(void 0!==e&&"boolean"!=typeof e)throw new Error("enabled parameter must be boolean if specified");let s,n=!1;if("string"!=typeof t){const r=t;s=this.Ee.getRegisteredName(r),s||(s=this.Ee.register(r,e??!0),n=!0)}else s=t;return void 0!==e&&!n&&this.Ee.enable(s,e),this.Ee.api(s)}animate(t,e){const n=h(t,s),r=h(e),i=Object.assign({target:n,promise:this.Zs},void 0!==r?{options:r}:{});return this.Ee.hook(K.registerAnimation,i).default((t=>{let e=()=>{};const s=new Promise((t=>{e=t})),i=t.promise.then((()=>this.en(n,r,e)));t.promise=Object.assign(i,{activated:s})})),this.Zs=i.promise,this.Zs}en(t,e,s){if(!this.Ot)throw new V;return this.Ot.prepareAnimation(t,e).then((()=>this.sn(s)))}sn(t){return new Promise(((e,s)=>{if(!this.Ot)throw new V;this.Ot.runAnimation((t=>{t?e(this):(s(new $),this.Zs=Promise.resolve(this))})),t(this.Ot.getAnimControl())}))}get animation(){if(!this.Ot)throw new V;return this.Ot.getAnimControl()}version(){if(!this.Ot)throw new V;return this.Ot.version()}get data(){if(!this.Ot)throw new V;return this.Ot.data}get config(){if(!this.Ot)throw new V;return this.Ot.config}get style(){if(!this.Ot)throw new V;return this.Ot.style}getComputedStyle(){if(!this.Ot)throw new V;return this.Ot.getComputedStyle()}on(t,e){if(!this.Ot)throw new V;this.Ot.on(t,e)}off(t,e){if(!this.Ot)throw new V;this.Ot.off(t,e)}store(){if(!this.Ot)throw new V;return this.Ot.store()}detach(){try{this.Ee.destruct(),this.Ot?.detach()}catch(t){console.error(`Error during plugin destruct: ${t}`)}}}var ot=Object.freeze({__proto__:null}),ht=Object.freeze({__proto__:null}),lt=Object.freeze({__proto__:null}),ct=Object.freeze({__proto__:null}),ut=Object.freeze({__proto__:null}),dt=Object.freeze({__proto__:null});export{ot as Anim,st as AnimControl,i as CAnimControl,r as CAnimation,o as CCanvas,g as CChart,a as CColorGradient,w as CCoordSystem,b as CData,e as CEnv,t as CError,m as CEvent,n as CManagedObject,s as CObject,u as CProxy,v as CRecord,_ as CRenderer,O as CSSProperties,$ as CancelError,E as CanvasError,B as CanvasRenderer,it as Chart,j as Clock,ht as Config,P as CoordSystem,lt as Data,tt as DataRecord,D as Events,dt as Geom,U as HtmlCanvas,I as Logging,A as Module,V as NotInitializedError,x as ObjectRegistry,L as PivotData,Q as Plugins,H as PointerEvents,ct as Presets,X as RenderControl,Z as Scheduler,nt as Shorthands,d as Snapshot,ut as Styles,rt as Tooltip,at as Vizzu,at as default,S as loader};