@datagrok/eda 1.4.12 → 1.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +0 -1
- package/CHANGELOG.md +8 -0
- package/CLAUDE.md +185 -0
- package/css/pmpo.css +9 -0
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/eslintrc.json +0 -1
- package/files/drugs-props-train-scores.csv +664 -0
- package/package.json +7 -3
- package/src/package-api.ts +7 -3
- package/src/package-test.ts +4 -1
- package/src/package.g.ts +21 -9
- package/src/package.ts +32 -23
- package/src/pareto-optimization/pareto-computations.ts +6 -0
- package/src/probabilistic-scoring/data-generator.ts +157 -0
- package/src/probabilistic-scoring/nelder-mead.ts +204 -0
- package/src/probabilistic-scoring/pmpo-defs.ts +112 -2
- package/src/probabilistic-scoring/pmpo-utils.ts +100 -77
- package/src/probabilistic-scoring/prob-scoring.ts +442 -88
- package/src/probabilistic-scoring/stat-tools.ts +140 -5
- package/src/tests/anova-tests.ts +1 -1
- package/src/tests/classifiers-tests.ts +1 -1
- package/src/tests/dim-reduction-tests.ts +1 -1
- package/src/tests/linear-methods-tests.ts +1 -1
- package/src/tests/mis-vals-imputation-tests.ts +1 -1
- package/src/tests/pareto-tests.ts +253 -0
- package/src/tests/pmpo-tests.ts +157 -0
- package/test-console-output-1.log +158 -222
- package/test-record-1.mp4 +0 -0
- package/files/mpo-done.ipynb +0 -2123
package/dist/package-test.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var eda_test;(()=>{var t={944:(t,n)=>{"use strict";n.Vb=void 0,n.Vb=function(t,n,e){var r=function(t,n,e){if(0===t.length||0===n.length)return 0;if(e&&!e.caseSensitive&&(t=t.toUpperCase(),n=n.toUpperCase()),t===n)return 1;for(var r=0,o=t.length,i=n.length,s=Math.floor(Math.max(o,i)/2)-1,a=new Array(o),u=new Array(i),c=0;c<o;c++)for(var l=Math.max(0,c-s);l<=Math.min(i,c+s+1);l++)if(!a[c]&&!u[l]&&t[c]===n[l]){++r,a[c]=u[l]=!0;break}if(0===r)return 0;var f=0,h=0;for(c=0;c<o;c++)if(a[c]){for(;!u[h];)h++;t.charAt(c)!==n.charAt(h++)&&f++}return(r/o+r/i+(r-(f/=2))/r)/3}(t,n,e),o=0;if(r>.7){for(var i=Math.min(t.length,n.length),s=0;t[s]===n[s]&&s<4&&s<i;)++o,s++;r+=.1*o*(1-r)}return r}},5540:(t,n,e)=>{"use strict";t=e.hmd(t);var r,o=(r="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var n,e,o=void 0!==t?t:{};o.ready=new Promise(function(t,r){n=t,e=r});var i,s=Object.assign({},o),a="object"==typeof window,u="function"==typeof importScripts,c=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(a||u)&&(u?c=self.location.href:"undefined"!=typeof document&&document.currentScript&&(c=document.currentScript.src),r&&(c=r),c=0!==c.indexOf("blob:")?c.substr(0,c.replace(/[?#].*/,"").lastIndexOf("/")+1):"",u&&(i=t=>{var n=new XMLHttpRequest;return n.open("GET",t,!1),n.responseType="arraybuffer",n.send(null),new Uint8Array(n.response)})),o.print||console.log.bind(console);var l,f,h=o.printErr||console.warn.bind(console);Object.assign(o,s),s=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit,o.wasmBinary&&(l=o.wasmBinary),o.noExitRuntime,"object"!=typeof WebAssembly&&T("no native wasm support detected");var m,d,p,g=!1;function y(){var t=f.buffer;o.HEAP8=m=new Int8Array(t),o.HEAP16=new Int16Array(t),o.HEAP32=new Int32Array(t),o.HEAPU8=d=new Uint8Array(t),o.HEAPU16=new Uint16Array(t),o.HEAPU32=p=new Uint32Array(t),o.HEAPF32=new Float32Array(t),o.HEAPF64=new Float64Array(t)}var v=[],w=[],E=[];function A(t){v.unshift(t)}function C(t){E.unshift(t)}var _,N,x=0,b=null,S=null;function T(t){o.onAbort&&o.onAbort(t),h(t="Aborted("+t+")"),g=!0,t+=". Build with -sASSERTIONS for more info.";var n=new WebAssembly.RuntimeError(t);throw e(n),n}function I(t){return t.startsWith("data:application/octet-stream;base64,")}function M(t){try{if(t==_&&l)return new Uint8Array(l);if(i)return i(t);throw"both async and sync fetching of the wasm failed"}catch(t){T(t)}}function O(t,n,e){return function(t){return l||!a&&!u||"function"!=typeof fetch?Promise.resolve().then(function(){return M(t)}):fetch(t,{credentials:"same-origin"}).then(function(n){if(!n.ok)throw"failed to load wasm binary file at '"+t+"'";return n.arrayBuffer()}).catch(function(){return M(t)})}(t).then(function(t){return WebAssembly.instantiate(t,n)}).then(function(t){return t}).then(e,function(t){h("failed to asynchronously prepare wasm: "+t),T(t)})}function R(t){for(;t.length>0;)t.shift()(o)}function L(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){p[this.ptr+4>>2]=t},this.get_type=function(){return p[this.ptr+4>>2]},this.set_destructor=function(t){p[this.ptr+8>>2]=t},this.get_destructor=function(){return p[this.ptr+8>>2]},this.set_caught=function(t){t=t?1:0,m[this.ptr+12|0]=t},this.get_caught=function(){return 0!=m[this.ptr+12|0]},this.set_rethrown=function(t){t=t?1:0,m[this.ptr+13|0]=t},this.get_rethrown=function(){return 0!=m[this.ptr+13|0]},this.init=function(t,n){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(n)},this.set_adjusted_ptr=function(t){p[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return p[this.ptr+16>>2]},this.get_exception_ptr=function(){if(q(this.get_type()))return p[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function P(t){var n=f.buffer;try{return f.grow(t-n.byteLength+65535>>>16),y(),1}catch(t){}}function D(t){return o["_"+t]}I(_="wasmDbscan.wasm")||(N=_,_=o.locateFile?o.locateFile(N,c):c+N);var F="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function U(t,n,e,r,o){var i={string:t=>{var n=0;return null!=t&&0!==t&&(n=function(t){var n=function(t){for(var n=0,e=0;e<t.length;++e){var r=t.charCodeAt(e);r<=127?n++:r<=2047?n+=2:r>=55296&&r<=57343?(n+=4,++e):n+=3}return n}(t)+1,e=V(n);return function(t,n,e){!function(t,n,e,r){if(!(r>0))return 0;for(var o=e+r-1,i=0;i<t.length;++i){var s=t.charCodeAt(i);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&t.charCodeAt(++i)),s<=127){if(e>=o)break;n[e++]=s}else if(s<=2047){if(e+1>=o)break;n[e++]=192|s>>6,n[e++]=128|63&s}else if(s<=65535){if(e+2>=o)break;n[e++]=224|s>>12,n[e++]=128|s>>6&63,n[e++]=128|63&s}else{if(e+3>=o)break;n[e++]=240|s>>18,n[e++]=128|s>>12&63,n[e++]=128|s>>6&63,n[e++]=128|63&s}}n[e]=0}(t,d,n,e)}(t,e,n),e}(t)),n},array:t=>{var n,e,r=V(t.length);return n=t,e=r,m.set(n,e),r}},s=D(t),a=[],u=0;if(r)for(var c=0;c<r.length;c++){var l=i[e[c]];l?(0===u&&(u=H()),a[c]=l(r[c])):a[c]=r[c]}var f=s.apply(null,a);return function(t){return 0!==u&&G(u),function(t){return"string"===n?(e=t)?function(t,n,e){for(var r=n+e,o=n;t[o]&&!(o>=r);)++o;if(o-n>16&&t.buffer&&F)return F.decode(t.subarray(n,o));for(var i="";n<o;){var s=t[n++];if(128&s){var a=63&t[n++];if(192!=(224&s)){var u=63&t[n++];if((s=224==(240&s)?(15&s)<<12|a<<6|u:(7&s)<<18|a<<12|u<<6|63&t[n++])<65536)i+=String.fromCharCode(s);else{var c=s-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&s)<<6|a)}else i+=String.fromCharCode(s)}return i}(d,e,r):"":"boolean"===n?Boolean(t):t;var e,r}(t)}(f)}var B,k={__cxa_throw:function(t,n,e){throw new L(t).init(n,e),t},abort:function(){T("")},emscripten_memcpy_big:function(t,n,e){d.copyWithin(t,n,n+e)},emscripten_resize_heap:function(t){var n=d.length,e=2147483648;if((t>>>=0)>e)return!1;let r=(t,n)=>t+(n-t%n)%n;for(var o=1;o<=4;o*=2){var i=n*(1+.2/o);if(i=Math.min(i,t+100663296),P(Math.min(e,r(Math.max(t,i),65536))))return!0}return!1}},H=(function(){var t,n,r,i,s={env:k,wasi_snapshot_preview1:k};function a(t,n){var e,r=t.exports;return o.asm=r,f=o.asm.memory,y(),o.asm.__indirect_function_table,e=o.asm.__wasm_call_ctors,w.unshift(e),function(){if(x--,o.monitorRunDependencies&&o.monitorRunDependencies(x),0==x&&(null!==b&&(clearInterval(b),b=null),S)){var t=S;S=null,t()}}(),r}if(x++,o.monitorRunDependencies&&o.monitorRunDependencies(x),o.instantiateWasm)try{return o.instantiateWasm(s,a)}catch(t){h("Module.instantiateWasm callback failed with error: "+t),e(t)}(t=l,n=_,r=s,i=function(t){a(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||I(n)||"function"!=typeof fetch?O(n,r,i):fetch(n,{credentials:"same-origin"}).then(function(t){return WebAssembly.instantiateStreaming(t,r).then(i,function(t){return h("wasm streaming compile failed: "+t),h("falling back to ArrayBuffer instantiation"),O(n,r,i)})})).catch(e)}(),o._dbscan=function(){return(o._dbscan=o.asm.dbscan).apply(null,arguments)},o._malloc=function(){return(o._malloc=o.asm.malloc).apply(null,arguments)},o._free=function(){return(o._free=o.asm.free).apply(null,arguments)},function(){return(H=o.asm.stackSave).apply(null,arguments)}),G=function(){return(G=o.asm.stackRestore).apply(null,arguments)},V=function(){return(V=o.asm.stackAlloc).apply(null,arguments)},q=function(){return(q=o.asm.__cxa_is_pointer_type).apply(null,arguments)};function W(){function t(){B||(B=!0,o.calledRun=!0,g||(R(w),n(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)C(o.postRun.shift());R(E)}()))}x>0||(function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)A(o.preRun.shift());R(v)}(),x>0||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),t()},1)):t()))}if(o.ccall=U,o.cwrap=function(t,n,e,r){var o=!e||e.every(t=>"number"===t||"boolean"===t);return"string"!==n&&o&&!r?D(t):function(){return U(t,n,e,arguments)}},S=function t(){B||W(),B||(S=t)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return W(),t.ready});"object"==typeof exports?t.exports=o:"function"==typeof define&&e.amdO?define([],function(){return o}):"object"==typeof exports&&(exports.exportCppDbscanLib=o)},6572:function(t){var n;t.exports=(n=function(t,n){var e=Array.prototype.concat,r=Array.prototype.slice,o=Object.prototype.toString;function i(n,e){var r=n>e?n:e;return t.pow(10,17-~~(t.log(r>0?r:-r)*t.LOG10E))}var s=Array.isArray||function(t){return"[object Array]"===o.call(t)};function a(t){return"[object Function]"===o.call(t)}function u(t){return"number"==typeof t&&t-t===0}function c(){return new c._init(arguments)}function l(){return 0}function f(){return 1}function h(t,n){return t===n?1:0}c.fn=c.prototype,c._init=function(t){if(s(t[0]))if(s(t[0][0])){a(t[1])&&(t[0]=c.map(t[0],t[1]));for(var n=0;n<t[0].length;n++)this[n]=t[0][n];this.length=t[0].length}else this[0]=a(t[1])?c.map(t[0],t[1]):t[0],this.length=1;else if(u(t[0]))this[0]=c.seq.apply(null,t),this.length=1;else{if(t[0]instanceof c)return c(t[0].toArray());this[0]=[],this.length=1}return this},c._init.prototype=c.prototype,c._init.constructor=c,c.utils={calcRdx:i,isArray:s,isFunction:a,isNumber:u,toVector:function(t){return e.apply([],t)}},c._random_fn=t.random,c.setRandom=function(t){if("function"!=typeof t)throw new TypeError("fn is not a function");c._random_fn=t},c.extend=function(t){var n,e;if(1===arguments.length){for(e in t)c[e]=t[e];return this}for(n=1;n<arguments.length;n++)for(e in arguments[n])t[e]=arguments[n][e];return t},c.rows=function(t){return t.length||1},c.cols=function(t){return t[0].length||1},c.dimensions=function(t){return{rows:c.rows(t),cols:c.cols(t)}},c.row=function(t,n){return s(n)?n.map(function(n){return c.row(t,n)}):t[n]},c.rowa=function(t,n){return c.row(t,n)},c.col=function(t,n){if(s(n)){var e=c.arange(t.length).map(function(){return new Array(n.length)});return n.forEach(function(n,r){c.arange(t.length).forEach(function(o){e[o][r]=t[o][n]})}),e}for(var r=new Array(t.length),o=0;o<t.length;o++)r[o]=[t[o][n]];return r},c.cola=function(t,n){return c.col(t,n).map(function(t){return t[0]})},c.diag=function(t){for(var n=c.rows(t),e=new Array(n),r=0;r<n;r++)e[r]=[t[r][r]];return e},c.antidiag=function(t){for(var n=c.rows(t)-1,e=new Array(n),r=0;n>=0;n--,r++)e[r]=[t[r][n]];return e},c.transpose=function(t){var n,e,r,o,i,a=[];for(s(t[0])||(t=[t]),e=t.length,r=t[0].length,i=0;i<r;i++){for(n=new Array(e),o=0;o<e;o++)n[o]=t[o][i];a.push(n)}return 1===a.length?a[0]:a},c.map=function(t,n,e){var r,o,i,a,u;for(s(t[0])||(t=[t]),o=t.length,i=t[0].length,a=e?t:new Array(o),r=0;r<o;r++)for(a[r]||(a[r]=new Array(i)),u=0;u<i;u++)a[r][u]=n(t[r][u],r,u);return 1===a.length?a[0]:a},c.cumreduce=function(t,n,e){var r,o,i,a,u;for(s(t[0])||(t=[t]),o=t.length,i=t[0].length,a=e?t:new Array(o),r=0;r<o;r++)for(a[r]||(a[r]=new Array(i)),i>0&&(a[r][0]=t[r][0]),u=1;u<i;u++)a[r][u]=n(a[r][u-1],t[r][u]);return 1===a.length?a[0]:a},c.alter=function(t,n){return c.map(t,n,!0)},c.create=function(t,n,e){var r,o,i=new Array(t);for(a(n)&&(e=n,n=t),r=0;r<t;r++)for(i[r]=new Array(n),o=0;o<n;o++)i[r][o]=e(r,o);return i},c.zeros=function(t,n){return u(n)||(n=t),c.create(t,n,l)},c.ones=function(t,n){return u(n)||(n=t),c.create(t,n,f)},c.rand=function(t,n){return u(n)||(n=t),c.create(t,n,c._random_fn)},c.identity=function(t,n){return u(n)||(n=t),c.create(t,n,h)},c.symmetric=function(t){var n,e,r=t.length;if(t.length!==t[0].length)return!1;for(n=0;n<r;n++)for(e=0;e<r;e++)if(t[e][n]!==t[n][e])return!1;return!0},c.clear=function(t){return c.alter(t,l)},c.seq=function(t,n,e,r){a(r)||(r=!1);var o,s=[],u=i(t,n),c=(n*u-t*u)/((e-1)*u),l=t;for(o=0;l<=n&&o<e;l=(t*u+c*u*++o)/u)s.push(r?r(l,o):l);return s},c.arange=function(t,e,r){var o,i=[];if(r=r||1,e===n&&(e=t,t=0),t===e||0===r)return[];if(t<e&&r<0)return[];if(t>e&&r>0)return[];if(r>0)for(o=t;o<e;o+=r)i.push(o);else for(o=t;o>e;o+=r)i.push(o);return i},c.slice=function(){function t(t,e,r,o){var i,s=[],a=t.length;if(e===n&&r===n&&o===n)return c.copy(t);if(o=o||1,(e=(e=e||0)>=0?e:a+e)===(r=(r=r||t.length)>=0?r:a+r)||0===o)return[];if(e<r&&o<0)return[];if(e>r&&o>0)return[];if(o>0)for(i=e;i<r;i+=o)s.push(t[i]);else for(i=e;i>r;i+=o)s.push(t[i]);return s}return function(n,e){var r,o;return u((e=e||{}).row)?u(e.col)?n[e.row][e.col]:t(c.rowa(n,e.row),(r=e.col||{}).start,r.end,r.step):u(e.col)?t(c.cola(n,e.col),(o=e.row||{}).start,o.end,o.step):(o=e.row||{},r=e.col||{},t(n,o.start,o.end,o.step).map(function(n){return t(n,r.start,r.end,r.step)}))}}(),c.sliceAssign=function(e,r,o){var i,s;if(u(r.row)){if(u(r.col))return e[r.row][r.col]=o;r.col=r.col||{},r.col.start=r.col.start||0,r.col.end=r.col.end||e[0].length,r.col.step=r.col.step||1,i=c.arange(r.col.start,t.min(e.length,r.col.end),r.col.step);var a=r.row;return i.forEach(function(t,n){e[a][t]=o[n]}),e}if(u(r.col)){r.row=r.row||{},r.row.start=r.row.start||0,r.row.end=r.row.end||e.length,r.row.step=r.row.step||1,s=c.arange(r.row.start,t.min(e[0].length,r.row.end),r.row.step);var l=r.col;return s.forEach(function(t,n){e[t][l]=o[n]}),e}return o[0].length===n&&(o=[o]),r.row.start=r.row.start||0,r.row.end=r.row.end||e.length,r.row.step=r.row.step||1,r.col.start=r.col.start||0,r.col.end=r.col.end||e[0].length,r.col.step=r.col.step||1,s=c.arange(r.row.start,t.min(e.length,r.row.end),r.row.step),i=c.arange(r.col.start,t.min(e[0].length,r.col.end),r.col.step),s.forEach(function(t,n){i.forEach(function(r,i){e[t][r]=o[n][i]})}),e},c.diagonal=function(t){var n=c.zeros(t.length,t.length);return t.forEach(function(t,e){n[e][e]=t}),n},c.copy=function(t){return t.map(function(t){return u(t)?t:t.map(function(t){return t})})};var m=c.prototype;return m.length=0,m.push=Array.prototype.push,m.sort=Array.prototype.sort,m.splice=Array.prototype.splice,m.slice=Array.prototype.slice,m.toArray=function(){return this.length>1?r.call(this):r.call(this)[0]},m.map=function(t,n){return c(c.map(this,t,n))},m.cumreduce=function(t,n){return c(c.cumreduce(this,t,n))},m.alter=function(t){return c.alter(this,t),this},function(t){for(var n=0;n<t.length;n++)(function(t){m[t]=function(n){var e,r=this;return n?(setTimeout(function(){n.call(r,m[t].call(r))}),this):(e=c[t](this),s(e)?c(e):e)}})(t[n])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(t){for(var n=0;n<t.length;n++)(function(t){m[t]=function(n,e){var r=this;return e?(setTimeout(function(){e.call(r,m[t].call(r,n))}),this):c(c[t](this,n))}})(t[n])}("row col".split(" ")),function(t){for(var n=0;n<t.length;n++)(function(t){m[t]=function(){return c(c[t].apply(null,arguments))}})(t[n])}("create zeros ones rand identity".split(" ")),c}(Math),function(t,n){var e=t.utils.isFunction;function r(t,n){return t-n}function o(t,e,r){return n.max(e,n.min(t,r))}t.sum=function(t){for(var n=0,e=t.length;--e>=0;)n+=t[e];return n},t.sumsqrd=function(t){for(var n=0,e=t.length;--e>=0;)n+=t[e]*t[e];return n},t.sumsqerr=function(n){for(var e,r=t.mean(n),o=0,i=n.length;--i>=0;)o+=(e=n[i]-r)*e;return o},t.sumrow=function(t){for(var n=0,e=t.length;--e>=0;)n+=t[e];return n},t.product=function(t){for(var n=1,e=t.length;--e>=0;)n*=t[e];return n},t.min=function(t){for(var n=t[0],e=0;++e<t.length;)t[e]<n&&(n=t[e]);return n},t.max=function(t){for(var n=t[0],e=0;++e<t.length;)t[e]>n&&(n=t[e]);return n},t.unique=function(t){for(var n={},e=[],r=0;r<t.length;r++)n[t[r]]||(n[t[r]]=!0,e.push(t[r]));return e},t.mean=function(n){return t.sum(n)/n.length},t.meansqerr=function(n){return t.sumsqerr(n)/n.length},t.geomean=function(e){var r=e.map(n.log),o=t.mean(r);return n.exp(o)},t.median=function(t){var n=t.length,e=t.slice().sort(r);return 1&n?e[n/2|0]:(e[n/2-1]+e[n/2])/2},t.cumsum=function(n){return t.cumreduce(n,function(t,n){return t+n})},t.cumprod=function(n){return t.cumreduce(n,function(t,n){return t*n})},t.diff=function(t){var n,e=[],r=t.length;for(n=1;n<r;n++)e.push(t[n]-t[n-1]);return e},t.rank=function(t){var n,e=[],o={};for(n=0;n<t.length;n++)o[u=t[n]]?o[u]++:(o[u]=1,e.push(u));var i=e.sort(r),s={},a=1;for(n=0;n<i.length;n++){var u,c=o[u=i[n]],l=(a+(a+c-1))/2;s[u]=l,a+=c}return t.map(function(t){return s[t]})},t.mode=function(t){var n,e=t.length,o=t.slice().sort(r),i=1,s=0,a=0,u=[];for(n=0;n<e;n++)o[n]===o[n+1]?i++:(i>s?(u=[o[n]],s=i,a=0):i===s&&(u.push(o[n]),a++),i=1);return 0===a?u[0]:u},t.range=function(n){return t.max(n)-t.min(n)},t.variance=function(n,e){return t.sumsqerr(n)/(n.length-(e?1:0))},t.pooledvariance=function(n){return n.reduce(function(n,e){return n+t.sumsqerr(e)},0)/(n.reduce(function(t,n){return t+n.length},0)-n.length)},t.deviation=function(n){for(var e=t.mean(n),r=n.length,o=new Array(r),i=0;i<r;i++)o[i]=n[i]-e;return o},t.stdev=function(e,r){return n.sqrt(t.variance(e,r))},t.pooledstdev=function(e){return n.sqrt(t.pooledvariance(e))},t.meandev=function(e){for(var r=t.mean(e),o=[],i=e.length-1;i>=0;i--)o.push(n.abs(e[i]-r));return t.mean(o)},t.meddev=function(e){for(var r=t.median(e),o=[],i=e.length-1;i>=0;i--)o.push(n.abs(e[i]-r));return t.median(o)},t.coeffvar=function(n){return t.stdev(n)/t.mean(n)},t.quartiles=function(t){var e=t.length,o=t.slice().sort(r);return[o[n.round(e/4)-1],o[n.round(e/2)-1],o[n.round(3*e/4)-1]]},t.quantiles=function(t,e,i,s){var a,u,c,l,f,h=t.slice().sort(r),m=[e.length],d=t.length;for(void 0===i&&(i=3/8),void 0===s&&(s=3/8),a=0;a<e.length;a++)c=d*(u=e[a])+(i+u*(1-i-s)),l=n.floor(o(c,1,d-1)),f=o(c-l,0,1),m[a]=(1-f)*h[l-1]+f*h[l];return m},t.percentile=function(t,n,e){var o=t.slice().sort(r),i=n*(o.length+(e?1:-1))+(e?0:1),s=parseInt(i),a=i-s;return s+1<o.length?o[s-1]+a*(o[s]-o[s-1]):o[s-1]},t.percentileOfScore=function(t,n,e){var r,o,i=0,s=t.length,a=!1;for("strict"===e&&(a=!0),o=0;o<s;o++)r=t[o],(a&&r<n||!a&&r<=n)&&i++;return i/s},t.histogram=function(e,r){r=r||4;var o,i=t.min(e),s=(t.max(e)-i)/r,a=e.length,u=[];for(o=0;o<r;o++)u[o]=0;for(o=0;o<a;o++)u[n.min(n.floor((e[o]-i)/s),r-1)]+=1;return u},t.covariance=function(n,e){var r,o=t.mean(n),i=t.mean(e),s=n.length,a=new Array(s);for(r=0;r<s;r++)a[r]=(n[r]-o)*(e[r]-i);return t.sum(a)/(s-1)},t.corrcoeff=function(n,e){return t.covariance(n,e)/t.stdev(n,1)/t.stdev(e,1)},t.spearmancoeff=function(n,e){return n=t.rank(n),e=t.rank(e),t.corrcoeff(n,e)},t.stanMoment=function(e,r){for(var o=t.mean(e),i=t.stdev(e),s=e.length,a=0,u=0;u<s;u++)a+=n.pow((e[u]-o)/i,r);return a/e.length},t.skewness=function(n){return t.stanMoment(n,3)},t.kurtosis=function(n){return t.stanMoment(n,4)-3};var i=t.prototype;!function(n){for(var r=0;r<n.length;r++)(function(n){i[n]=function(r,o){var s=[],a=0,u=this;if(e(r)&&(o=r,r=!1),o)return setTimeout(function(){o.call(u,i[n].call(u,r))}),this;if(this.length>1){for(u=!0===r?this:this.transpose();a<u.length;a++)s[a]=t[n](u[a]);return s}return t[n](this[0],r)}})(n[r])}("cumsum cumprod".split(" ")),function(n){for(var r=0;r<n.length;r++)(function(n){i[n]=function(r,o){var s=[],a=0,u=this;if(e(r)&&(o=r,r=!1),o)return setTimeout(function(){o.call(u,i[n].call(u,r))}),this;if(this.length>1){for("sumrow"!==n&&(u=!0===r?this:this.transpose());a<u.length;a++)s[a]=t[n](u[a]);return!0===r?t[n](t.utils.toVector(s)):s}return t[n](this[0],r)}})(n[r])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(n){for(var r=0;r<n.length;r++)(function(n){i[n]=function(){var r,o=[],s=0,a=this,u=Array.prototype.slice.call(arguments);if(e(u[u.length-1])){r=u[u.length-1];var c=u.slice(0,u.length-1);return setTimeout(function(){r.call(a,i[n].apply(a,c))}),this}r=void 0;var l=function(e){return t[n].apply(a,[e].concat(u))};if(this.length>1){for(a=a.transpose();s<a.length;s++)o[s]=l(a[s]);return o}return l(this[0])}})(n[r])}("quantiles percentileOfScore".split(" "))}(n,Math),function(t,n){t.gammaln=function(t){var e,r,o,i=0,s=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],a=1.000000000190015;for(o=(r=e=t)+5.5,o-=(e+.5)*n.log(o);i<6;i++)a+=s[i]/++r;return n.log(2.5066282746310007*a/e)-o},t.loggam=function(t){var e,r,o,i,s,a,u,c=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(e=t,u=0,1==t||2==t)return 0;for(t<=7&&(e=t+(u=n.floor(7-t))),r=1/(e*e),o=2*n.PI,s=c[9],a=8;a>=0;a--)s*=r,s+=c[a];if(i=s/e+.5*n.log(o)+(e-.5)*n.log(e)-e,t<=7)for(a=1;a<=u;a++)i-=n.log(e-1),e-=1;return i},t.gammafn=function(t){var e,r,o,i,s=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],a=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],u=!1,c=0,l=0,f=0,h=t;if(t>171.6243769536076)return 1/0;if(h<=0){if(!(i=h%1+36e-17))return 1/0;u=(1&h?-1:1)*n.PI/n.sin(n.PI*i),h=1-h}for(o=h,r=h<1?h++:(h-=c=(0|h)-1)-1,e=0;e<8;++e)f=(f+s[e])*r,l=l*r+a[e];if(i=f/l+1,o<h)i/=o;else if(o>h)for(e=0;e<c;++e)i*=h,h++;return u&&(i=u/i),i},t.gammap=function(n,e){return t.lowRegGamma(n,e)*t.gammafn(n)},t.lowRegGamma=function(e,r){var o,i=t.gammaln(e),s=e,a=1/e,u=a,c=r+1-e,l=1/1e-30,f=1/c,h=f,m=1,d=-~(8.5*n.log(e>=1?e:1/e)+.4*e+17);if(r<0||e<=0)return NaN;if(r<e+1){for(;m<=d;m++)a+=u*=r/++s;return a*n.exp(-r+e*n.log(r)-i)}for(;m<=d;m++)h*=(f=1/(f=(o=-m*(m-e))*f+(c+=2)))*(l=c+o/l);return 1-h*n.exp(-r+e*n.log(r)-i)},t.factorialln=function(n){return n<0?NaN:t.gammaln(n+1)},t.factorial=function(n){return n<0?NaN:t.gammafn(n+1)},t.combination=function(e,r){return e>170||r>170?n.exp(t.combinationln(e,r)):t.factorial(e)/t.factorial(r)/t.factorial(e-r)},t.combinationln=function(n,e){return t.factorialln(n)-t.factorialln(e)-t.factorialln(n-e)},t.permutation=function(n,e){return t.factorial(n)/t.factorial(n-e)},t.betafn=function(e,r){if(!(e<=0||r<=0))return e+r>170?n.exp(t.betaln(e,r)):t.gammafn(e)*t.gammafn(r)/t.gammafn(e+r)},t.betaln=function(n,e){return t.gammaln(n)+t.gammaln(e)-t.gammaln(n+e)},t.betacf=function(t,e,r){var o,i,s,a,u=1e-30,c=1,l=e+r,f=e+1,h=e-1,m=1,d=1-l*t/f;for(n.abs(d)<u&&(d=u),a=d=1/d;c<=100&&(d=1+(i=c*(r-c)*t/((h+(o=2*c))*(e+o)))*d,n.abs(d)<u&&(d=u),m=1+i/m,n.abs(m)<u&&(m=u),a*=(d=1/d)*m,d=1+(i=-(e+c)*(l+c)*t/((e+o)*(f+o)))*d,n.abs(d)<u&&(d=u),m=1+i/m,n.abs(m)<u&&(m=u),a*=s=(d=1/d)*m,!(n.abs(s-1)<3e-7));c++);return a},t.gammapinv=function(e,r){var o,i,s,a,u,c,l=0,f=r-1,h=t.gammaln(r);if(e>=1)return n.max(100,r+100*n.sqrt(r));if(e<=0)return 0;for(r>1?(u=n.log(f),c=n.exp(f*(u-1)-h),a=e<.5?e:1-e,o=(2.30753+.27061*(i=n.sqrt(-2*n.log(a))))/(1+i*(.99229+.04481*i))-i,e<.5&&(o=-o),o=n.max(.001,r*n.pow(1-1/(9*r)-o/(3*n.sqrt(r)),3))):o=e<(i=1-r*(.253+.12*r))?n.pow(e/i,1/r):1-n.log(1-(e-i)/(1-i));l<12;l++){if(o<=0)return 0;if((o-=i=(s=(t.lowRegGamma(r,o)-e)/(i=r>1?c*n.exp(-(o-f)+f*(n.log(o)-u)):n.exp(-o+f*n.log(o)-h)))/(1-.5*n.min(1,s*((r-1)/o-1))))<=0&&(o=.5*(o+i)),n.abs(i)<1e-8*o)break}return o},t.erf=function(t){var e,r,o,i,s=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],a=s.length-1,u=!1,c=0,l=0;for(t<0&&(t=-t,u=!0),r=4*(e=2/(2+t))-2;a>0;a--)o=c,c=r*c-l+s[a],l=o;return i=e*n.exp(-t*t+.5*(s[0]+r*c)-l),u?i-1:1-i},t.erfc=function(n){return 1-t.erf(n)},t.erfcinv=function(e){var r,o,i,s,a=0;if(e>=2)return-100;if(e<=0)return 100;for(s=e<1?e:2-e,r=-.70711*((2.30753+.27061*(i=n.sqrt(-2*n.log(s/2))))/(1+i*(.99229+.04481*i))-i);a<2;a++)r+=(o=t.erfc(r)-s)/(1.1283791670955126*n.exp(-r*r)-r*o);return e<1?r:-r},t.ibetainv=function(e,r,o){var i,s,a,u,c,l,f,h,m,d,p=r-1,g=o-1,y=0;if(e<=0)return 0;if(e>=1)return 1;for(r>=1&&o>=1?(a=e<.5?e:1-e,l=(2.30753+.27061*(u=n.sqrt(-2*n.log(a))))/(1+u*(.99229+.04481*u))-u,e<.5&&(l=-l),f=(l*l-3)/6,h=2/(1/(2*r-1)+1/(2*o-1)),m=l*n.sqrt(f+h)/h-(1/(2*o-1)-1/(2*r-1))*(f+5/6-2/(3*h)),l=r/(r+o*n.exp(2*m))):(i=n.log(r/(r+o)),s=n.log(o/(r+o)),l=e<(u=n.exp(r*i)/r)/(m=u+(c=n.exp(o*s)/o))?n.pow(r*m*e,1/r):1-n.pow(o*m*(1-e),1/o)),d=-t.gammaln(r)-t.gammaln(o)+t.gammaln(r+o);y<10;y++){if(0===l||1===l)return l;if((l-=u=(c=(t.ibeta(l,r,o)-e)/(u=n.exp(p*n.log(l)+g*n.log(1-l)+d)))/(1-.5*n.min(1,c*(p/l-g/(1-l)))))<=0&&(l=.5*(l+u)),l>=1&&(l=.5*(l+u+1)),n.abs(u)<1e-8*l&&y>0)break}return l},t.ibeta=function(e,r,o){var i=0===e||1===e?0:n.exp(t.gammaln(r+o)-t.gammaln(r)-t.gammaln(o)+r*n.log(e)+o*n.log(1-e));return!(e<0||e>1)&&(e<(r+1)/(r+o+2)?i*t.betacf(e,r,o)/r:1-i*t.betacf(1-e,o,r)/o)},t.randn=function(e,r){var o,i,s,a,u;if(r||(r=e),e)return t.create(e,r,function(){return t.randn()});do{o=t._random_fn(),i=1.7156*(t._random_fn()-.5),u=(s=o-.449871)*s+(a=n.abs(i)+.386595)*(.196*a-.25472*s)}while(u>.27597&&(u>.27846||i*i>-4*n.log(o)*o*o));return i/o},t.randg=function(e,r,o){var i,s,a,u,c,l,f=e;if(o||(o=r),e||(e=1),r)return(l=t.zeros(r,o)).alter(function(){return t.randg(e)}),l;e<1&&(e+=1),i=e-1/3,s=1/n.sqrt(9*i);do{do{u=1+s*(c=t.randn())}while(u<=0);u*=u*u,a=t._random_fn()}while(a>1-.331*n.pow(c,4)&&n.log(a)>.5*c*c+i*(1-u+n.log(u)));if(e==f)return i*u;do{a=t._random_fn()}while(0===a);return n.pow(a,1/f)*i*u},function(n){for(var e=0;e<n.length;e++)(function(n){t.fn[n]=function(){return t(t.map(this,function(e){return t[n](e)}))}})(n[e])}("gammaln gammafn factorial factorialln".split(" ")),function(n){for(var e=0;e<n.length;e++)(function(n){t.fn[n]=function(){return t(t[n].apply(null,arguments))}})(n[e])}("randn".split(" "))}(n,Math),function(t,n){function e(t,e,r,o){for(var i,s=0,a=1,u=1,c=1,l=0,f=0;n.abs((u-f)/u)>o;)f=u,a=c+(i=-(e+l)*(e+r+l)*t/(e+2*l)/(e+2*l+1))*a,u=(s=u+i*s)+(i=(l+=1)*(r-l)*t/(e+2*l-1)/(e+2*l))*u,s/=c=a+i*c,a/=c,u/=c,c=1;return u/e}function r(e,r,o){var i=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],s=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],a=.5*e;if(a>=8)return 1;var u,c=2*t.normal.cdf(a,0,1,1,0)-1;c=c>=n.exp(-50/o)?n.pow(c,o):0;for(var l=a,f=(8-a)/(u=e>3?2:3),h=l+f,m=0,d=o-1,p=1;p<=u;p++){for(var g=0,y=.5*(h+l),v=.5*(h-l),w=1;w<=12;w++){var E,A=y+v*(6<w?i[(E=12-w+1)-1]:-i[(E=w)-1]),C=A*A;if(C>60)break;var _=2*t.normal.cdf(A,0,1,1,0)*.5-2*t.normal.cdf(A,e,1,1,0)*.5;_>=n.exp(-30/d)&&(g+=_=s[E-1]*n.exp(-.5*C)*n.pow(_,d))}m+=g*=2*v*o/n.sqrt(2*n.PI),l=h,h+=f}return(c+=m)<=n.exp(-30/r)?0:(c=n.pow(c,r))>=1?1:c}!function(n){for(var e=0;e<n.length;e++)(function(n){t[n]=function t(n,e,r){return this instanceof t?(this._a=n,this._b=e,this._c=r,this):new t(n,e,r)},t.fn[n]=function(e,r,o){var i=t[n](e,r,o);return i.data=this,i},t[n].prototype.sample=function(e){var r=this._a,o=this._b,i=this._c;return e?t.alter(e,function(){return t[n].sample(r,o,i)}):t[n].sample(r,o,i)},function(e){for(var r=0;r<e.length;r++)(function(e){t[n].prototype[e]=function(r){var o=this._a,i=this._b,s=this._c;return r||0===r||(r=this.data),"number"!=typeof r?t.fn.map.call(r,function(r){return t[n][e](r,o,i,s)}):t[n][e](r,o,i,s)}})(e[r])}("pdf cdf inv".split(" ")),function(e){for(var r=0;r<e.length;r++)(function(e){t[n].prototype[e]=function(){return t[n][e](this._a,this._b,this._c)}})(e[r])}("mean median mode variance".split(" "))})(n[e])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),t.extend(t.beta,{pdf:function(e,r,o){return e>1||e<0?0:1==r&&1==o?1:r<512&&o<512?n.pow(e,r-1)*n.pow(1-e,o-1)/t.betafn(r,o):n.exp((r-1)*n.log(e)+(o-1)*n.log(1-e)-t.betaln(r,o))},cdf:function(n,e,r){return n>1||n<0?1*(n>1):t.ibeta(n,e,r)},inv:function(n,e,r){return t.ibetainv(n,e,r)},mean:function(t,n){return t/(t+n)},median:function(n,e){return t.ibetainv(.5,n,e)},mode:function(t,n){return(t-1)/(t+n-2)},sample:function(n,e){var r=t.randg(n);return r/(r+t.randg(e))},variance:function(t,e){return t*e/(n.pow(t+e,2)*(t+e+1))}}),t.extend(t.centralF,{pdf:function(e,r,o){var i;return e<0?0:r<=2?0===e&&r<2?1/0:0===e&&2===r?1:1/t.betafn(r/2,o/2)*n.pow(r/o,r/2)*n.pow(e,r/2-1)*n.pow(1+r/o*e,-(r+o)/2):(i=r*e/(o+e*r),r*(o/(o+e*r))/2*t.binomial.pdf((r-2)/2,(r+o-2)/2,i))},cdf:function(n,e,r){return n<0?0:t.ibeta(e*n/(e*n+r),e/2,r/2)},inv:function(n,e,r){return r/(e*(1/t.ibetainv(n,e/2,r/2)-1))},mean:function(t,n){return n>2?n/(n-2):void 0},mode:function(t,n){return t>2?n*(t-2)/(t*(n+2)):void 0},sample:function(n,e){return 2*t.randg(n/2)/n/(2*t.randg(e/2)/e)},variance:function(t,n){if(!(n<=4))return 2*n*n*(t+n-2)/(t*(n-2)*(n-2)*(n-4))}}),t.extend(t.cauchy,{pdf:function(t,e,r){return r<0?0:r/(n.pow(t-e,2)+n.pow(r,2))/n.PI},cdf:function(t,e,r){return n.atan((t-e)/r)/n.PI+.5},inv:function(t,e,r){return e+r*n.tan(n.PI*(t-.5))},median:function(t){return t},mode:function(t){return t},sample:function(e,r){return t.randn()*n.sqrt(1/(2*t.randg(.5)))*r+e}}),t.extend(t.chisquare,{pdf:function(e,r){return e<0?0:0===e&&2===r?.5:n.exp((r/2-1)*n.log(e)-e/2-r/2*n.log(2)-t.gammaln(r/2))},cdf:function(n,e){return n<0?0:t.lowRegGamma(e/2,n/2)},inv:function(n,e){return 2*t.gammapinv(n,.5*e)},mean:function(t){return t},median:function(t){return t*n.pow(1-2/(9*t),3)},mode:function(t){return t-2>0?t-2:0},sample:function(n){return 2*t.randg(n/2)},variance:function(t){return 2*t}}),t.extend(t.exponential,{pdf:function(t,e){return t<0?0:e*n.exp(-e*t)},cdf:function(t,e){return t<0?0:1-n.exp(-e*t)},inv:function(t,e){return-n.log(1-t)/e},mean:function(t){return 1/t},median:function(t){return 1/t*n.log(2)},mode:function(){return 0},sample:function(e){return-1/e*n.log(t._random_fn())},variance:function(t){return n.pow(t,-2)}}),t.extend(t.gamma,{pdf:function(e,r,o){return e<0?0:0===e&&1===r?1/o:n.exp((r-1)*n.log(e)-e/o-t.gammaln(r)-r*n.log(o))},cdf:function(n,e,r){return n<0?0:t.lowRegGamma(e,n/r)},inv:function(n,e,r){return t.gammapinv(n,e)*r},mean:function(t,n){return t*n},mode:function(t,n){if(t>1)return(t-1)*n},sample:function(n,e){return t.randg(n)*e},variance:function(t,n){return t*n*n}}),t.extend(t.invgamma,{pdf:function(e,r,o){return e<=0?0:n.exp(-(r+1)*n.log(e)-o/e-t.gammaln(r)+r*n.log(o))},cdf:function(n,e,r){return n<=0?0:1-t.lowRegGamma(e,r/n)},inv:function(n,e,r){return r/t.gammapinv(1-n,e)},mean:function(t,n){return t>1?n/(t-1):void 0},mode:function(t,n){return n/(t+1)},sample:function(n,e){return e/t.randg(n)},variance:function(t,n){if(!(t<=2))return n*n/((t-1)*(t-1)*(t-2))}}),t.extend(t.kumaraswamy,{pdf:function(t,e,r){return 0===t&&1===e?r:1===t&&1===r?e:n.exp(n.log(e)+n.log(r)+(e-1)*n.log(t)+(r-1)*n.log(1-n.pow(t,e)))},cdf:function(t,e,r){return t<0?0:t>1?1:1-n.pow(1-n.pow(t,e),r)},inv:function(t,e,r){return n.pow(1-n.pow(1-t,1/r),1/e)},mean:function(n,e){return e*t.gammafn(1+1/n)*t.gammafn(e)/t.gammafn(1+1/n+e)},median:function(t,e){return n.pow(1-n.pow(2,-1/e),1/t)},mode:function(t,e){if(t>=1&&e>=1&&1!==t&&1!==e)return n.pow((t-1)/(t*e-1),1/t)},variance:function(){throw new Error("variance not yet implemented")}}),t.extend(t.lognormal,{pdf:function(t,e,r){return t<=0?0:n.exp(-n.log(t)-.5*n.log(2*n.PI)-n.log(r)-n.pow(n.log(t)-e,2)/(2*r*r))},cdf:function(e,r,o){return e<0?0:.5+.5*t.erf((n.log(e)-r)/n.sqrt(2*o*o))},inv:function(e,r,o){return n.exp(-1.4142135623730951*o*t.erfcinv(2*e)+r)},mean:function(t,e){return n.exp(t+e*e/2)},median:function(t){return n.exp(t)},mode:function(t,e){return n.exp(t-e*e)},sample:function(e,r){return n.exp(t.randn()*r+e)},variance:function(t,e){return(n.exp(e*e)-1)*n.exp(2*t+e*e)}}),t.extend(t.noncentralt,{pdf:function(e,r,o){return n.abs(o)<1e-14?t.studentt.pdf(e,r):n.abs(e)<1e-14?n.exp(t.gammaln((r+1)/2)-o*o/2-.5*n.log(n.PI*r)-t.gammaln(r/2)):r/e*(t.noncentralt.cdf(e*n.sqrt(1+2/r),r+2,o)-t.noncentralt.cdf(e,r,o))},cdf:function(e,r,o){var i=1e-14;if(n.abs(o)<i)return t.studentt.cdf(e,r);var s=!1;e<0&&(s=!0,o=-o);for(var a=t.normal.cdf(-o,0,1),u=i+1,c=u,l=e*e/(e*e+r),f=0,h=n.exp(-o*o/2),m=n.exp(-o*o/2-.5*n.log(2)-t.gammaln(1.5))*o;f<200||c>i||u>i;)c=u,f>0&&(h*=o*o/(2*f),m*=o*o/(2*(f+.5))),a+=.5*(u=h*t.beta.cdf(l,f+.5,r/2)+m*t.beta.cdf(l,f+1,r/2)),f++;return s?1-a:a}}),t.extend(t.normal,{pdf:function(t,e,r){return n.exp(-.5*n.log(2*n.PI)-n.log(r)-n.pow(t-e,2)/(2*r*r))},cdf:function(e,r,o){return.5*(1+t.erf((e-r)/n.sqrt(2*o*o)))},inv:function(n,e,r){return-1.4142135623730951*r*t.erfcinv(2*n)+e},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},sample:function(n,e){return t.randn()*e+n},variance:function(t,n){return n*n}}),t.extend(t.pareto,{pdf:function(t,e,r){return t<e?0:r*n.pow(e,r)/n.pow(t,r+1)},cdf:function(t,e,r){return t<e?0:1-n.pow(e/t,r)},inv:function(t,e,r){return e/n.pow(1-t,1/r)},mean:function(t,e){if(!(e<=1))return e*n.pow(t,e)/(e-1)},median:function(t,e){return t*(e*n.SQRT2)},mode:function(t){return t},variance:function(t,e){if(!(e<=2))return t*t*e/(n.pow(e-1,2)*(e-2))}}),t.extend(t.studentt,{pdf:function(e,r){return r=r>1e100?1e100:r,1/(n.sqrt(r)*t.betafn(.5,r/2))*n.pow(1+e*e/r,-(r+1)/2)},cdf:function(e,r){var o=r/2;return t.ibeta((e+n.sqrt(e*e+r))/(2*n.sqrt(e*e+r)),o,o)},inv:function(e,r){var o=t.ibetainv(2*n.min(e,1-e),.5*r,.5);return o=n.sqrt(r*(1-o)/o),e>.5?o:-o},mean:function(t){return t>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(e){return t.randn()*n.sqrt(e/(2*t.randg(e/2)))},variance:function(t){return t>2?t/(t-2):t>1?1/0:void 0}}),t.extend(t.weibull,{pdf:function(t,e,r){return t<0||e<0||r<0?0:r/e*n.pow(t/e,r-1)*n.exp(-n.pow(t/e,r))},cdf:function(t,e,r){return t<0?0:1-n.exp(-n.pow(t/e,r))},inv:function(t,e,r){return e*n.pow(-n.log(1-t),1/r)},mean:function(n,e){return n*t.gammafn(1+1/e)},median:function(t,e){return t*n.pow(n.log(2),1/e)},mode:function(t,e){return e<=1?0:t*n.pow((e-1)/e,1/e)},sample:function(e,r){return e*n.pow(-n.log(t._random_fn()),1/r)},variance:function(e,r){return e*e*t.gammafn(1+2/r)-n.pow(t.weibull.mean(e,r),2)}}),t.extend(t.uniform,{pdf:function(t,n,e){return t<n||t>e?0:1/(e-n)},cdf:function(t,n,e){return t<n?0:t<e?(t-n)/(e-n):1},inv:function(t,n,e){return n+t*(e-n)},mean:function(t,n){return.5*(t+n)},median:function(n,e){return t.mean(n,e)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(n,e){return n/2+e/2+(e/2-n/2)*(2*t._random_fn()-1)},variance:function(t,e){return n.pow(e-t,2)/12}}),t.extend(t.binomial,{pdf:function(e,r,o){return 0===o||1===o?r*o===e?1:0:t.combination(r,e)*n.pow(o,e)*n.pow(1-o,r-e)},cdf:function(r,o,i){var s,a=1e-10;if(r<0)return 0;if(r>=o)return 1;if(i<0||i>1||o<=0)return NaN;var u=i,c=(r=n.floor(r))+1,l=o-r,f=c+l,h=n.exp(t.gammaln(f)-t.gammaln(l)-t.gammaln(c)+c*n.log(u)+l*n.log(1-u));return s=u<(c+1)/(f+2)?h*e(u,c,l,a):1-h*e(1-u,l,c,a),n.round(1/a*(1-s))/(1/a)}}),t.extend(t.negbin,{pdf:function(e,r,o){return e===e>>>0&&(e<0?0:t.combination(e+r-1,r-1)*n.pow(1-o,e)*n.pow(o,r))},cdf:function(n,e,r){var o=0,i=0;if(n<0)return 0;for(;i<=n;i++)o+=t.negbin.pdf(i,e,r);return o}}),t.extend(t.hypgeom,{pdf:function(e,r,o,i){if(e!=e|0)return!1;if(e<0||e<o-(r-i))return 0;if(e>i||e>o)return 0;if(2*o>r)return 2*i>r?t.hypgeom.pdf(r-o-i+e,r,r-o,r-i):t.hypgeom.pdf(i-e,r,r-o,i);if(2*i>r)return t.hypgeom.pdf(o-e,r,o,r-i);if(o<i)return t.hypgeom.pdf(e,r,i,o);for(var s=1,a=0,u=0;u<e;u++){for(;s>1&&a<i;)s*=1-o/(r-a),a++;s*=(i-u)*(o-u)/((u+1)*(r-o-i+u+1))}for(;a<i;a++)s*=1-o/(r-a);return n.min(1,n.max(0,s))},cdf:function(e,r,o,i){if(e<0||e<o-(r-i))return 0;if(e>=i||e>=o)return 1;if(2*o>r)return 2*i>r?t.hypgeom.cdf(r-o-i+e,r,r-o,r-i):1-t.hypgeom.cdf(i-e-1,r,r-o,i);if(2*i>r)return 1-t.hypgeom.cdf(o-e-1,r,o,r-i);if(o<i)return t.hypgeom.cdf(e,r,i,o);for(var s=1,a=1,u=0,c=0;c<e;c++){for(;s>1&&u<i;){var l=1-o/(r-u);a*=l,s*=l,u++}s+=a*=(i-c)*(o-c)/((c+1)*(r-o-i+c+1))}for(;u<i;u++)s*=1-o/(r-u);return n.min(1,n.max(0,s))}}),t.extend(t.poisson,{pdf:function(e,r){return r<0||e%1!=0||e<0?0:n.pow(r,e)*n.exp(-r)/t.factorial(e)},cdf:function(n,e){var r=[],o=0;if(n<0)return 0;for(;o<=n;o++)r.push(t.poisson.pdf(o,e));return t.sum(r)},mean:function(t){return t},variance:function(t){return t},sampleSmall:function(e){var r=1,o=0,i=n.exp(-e);do{o++,r*=t._random_fn()}while(r>i);return o-1},sampleLarge:function(e){var r,o,i,s,a,u,c,l,f,h,m=e;for(s=n.sqrt(m),a=n.log(m),u=.02483*(c=.931+2.53*s)-.059,l=1.1239+1.1328/(c-3.4),f=.9277-3.6224/(c-2);;){if(o=n.random()-.5,i=n.random(),h=.5-n.abs(o),r=n.floor((2*u/h+c)*o+m+.43),h>=.07&&i<=f)return r;if(!(r<0||h<.013&&i>h)&&n.log(i)+n.log(l)-n.log(u/(h*h)+c)<=r*a-m-t.loggam(r+1))return r}},sample:function(t){return t<10?this.sampleSmall(t):this.sampleLarge(t)}}),t.extend(t.triangular,{pdf:function(t,n,e,r){return e<=n||r<n||r>e?NaN:t<n||t>e?0:t<r?2*(t-n)/((e-n)*(r-n)):t===r?2/(e-n):2*(e-t)/((e-n)*(e-r))},cdf:function(t,e,r,o){return r<=e||o<e||o>r?NaN:t<=e?0:t>=r?1:t<=o?n.pow(t-e,2)/((r-e)*(o-e)):1-n.pow(r-t,2)/((r-e)*(r-o))},inv:function(t,e,r,o){return r<=e||o<e||o>r?NaN:t<=(o-e)/(r-e)?e+(r-e)*n.sqrt(t*((o-e)/(r-e))):e+(r-e)*(1-n.sqrt((1-t)*(1-(o-e)/(r-e))))},mean:function(t,n,e){return(t+n+e)/3},median:function(t,e,r){return r<=(t+e)/2?e-n.sqrt((e-t)*(e-r))/n.sqrt(2):r>(t+e)/2?t+n.sqrt((e-t)*(r-t))/n.sqrt(2):void 0},mode:function(t,n,e){return e},sample:function(e,r,o){var i=t._random_fn();return i<(o-e)/(r-e)?e+n.sqrt(i*(r-e)*(o-e)):r-n.sqrt((1-i)*(r-e)*(r-o))},variance:function(t,n,e){return(t*t+n*n+e*e-t*n-t*e-n*e)/18}}),t.extend(t.arcsine,{pdf:function(t,e,r){return r<=e?NaN:t<=e||t>=r?0:2/n.PI*n.pow(n.pow(r-e,2)-n.pow(2*t-e-r,2),-.5)},cdf:function(t,e,r){return t<e?0:t<r?2/n.PI*n.asin(n.sqrt((t-e)/(r-e))):1},inv:function(t,e,r){return e+(.5-.5*n.cos(n.PI*t))*(r-e)},mean:function(t,n){return n<=t?NaN:(t+n)/2},median:function(t,n){return n<=t?NaN:(t+n)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(e,r){return(e+r)/2+(r-e)/2*n.sin(2*n.PI*t.uniform.sample(0,1))},variance:function(t,e){return e<=t?NaN:n.pow(e-t,2)/8}}),t.extend(t.laplace,{pdf:function(t,e,r){return r<=0?0:n.exp(-n.abs(t-e)/r)/(2*r)},cdf:function(t,e,r){return r<=0?0:t<e?.5*n.exp((t-e)/r):1-.5*n.exp(-(t-e)/r)},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},variance:function(t,n){return 2*n*n},sample:function(e,r){var o,i=t._random_fn()-.5;return e-r*((o=i)/n.abs(o))*n.log(1-2*n.abs(i))}}),t.extend(t.tukey,{cdf:function(e,o,i){var s=o,a=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],u=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(e<=0)return 0;if(i<2||s<2)return NaN;if(!Number.isFinite(e))return 1;if(i>25e3)return r(e,1,s);var c,l=.5*i,f=l*n.log(i)-i*n.log(2)-t.gammaln(l),h=l-1,m=.25*i;c=i<=100?1:i<=800?.5:i<=5e3?.25:.125,f+=n.log(c);for(var d=0,p=1;p<=50;p++){for(var g=0,y=(2*p-1)*c,v=1;v<=16;v++){var w,E;8<v?(w=v-8-1,E=f+h*n.log(y+a[w]*c)-(a[w]*c+y)*m):(w=v-1,E=f+h*n.log(y-a[w]*c)+(a[w]*c-y)*m),E>=-30&&(g+=r(8<v?e*n.sqrt(.5*(a[w]*c+y)):e*n.sqrt(.5*(-a[w]*c+y)),1,s)*u[w]*n.exp(E))}if(p*c>=1&&g<=1e-14)break;d+=g}if(g>1e-14)throw new Error("tukey.cdf failed to converge");return d>1&&(d=1),d},inv:function(e,r,o){if(o<2||r<2)return NaN;if(e<0||e>1)return NaN;if(0===e)return 0;if(1===e)return 1/0;var i,s=function(t,e,r){var o=.5-.5*t,i=n.sqrt(n.log(1/(o*o))),s=i+((((-453642210148e-16*i-.204231210125)*i-.342242088547)*i-1)*i+.322232421088)/((((.0038560700634*i+.10353775285)*i+.531103462366)*i+.588581570495)*i+.099348462606);r<120&&(s+=(s*s*s+s)/r/4);var a=.8832-.2368*s;return r<120&&(a+=-1.214/r+1.208*s/r),s*(a*n.log(e-1)+1.4142)}(e,r,o),a=t.tukey.cdf(s,r,o)-e;i=a>0?n.max(0,s-1):s+1;for(var u,c=t.tukey.cdf(i,r,o)-e,l=1;l<50;l++)if(u=i-c*(i-s)/(c-a),a=c,s=i,u<0&&(u=0,c=-e),c=t.tukey.cdf(u,r,o)-e,i=u,n.abs(i-s)<1e-4)return u;throw new Error("tukey.inv failed to converge")}})}(n,Math),function(t,n){var e,r,o=Array.prototype.push,i=t.utils.isArray;function s(n){return i(n)||n instanceof t}t.extend({add:function(n,e){return s(e)?(s(e[0])||(e=[e]),t.map(n,function(t,n,r){return t+e[n][r]})):t.map(n,function(t){return t+e})},subtract:function(n,e){return s(e)?(s(e[0])||(e=[e]),t.map(n,function(t,n,r){return t-e[n][r]||0})):t.map(n,function(t){return t-e})},divide:function(n,e){return s(e)?(s(e[0])||(e=[e]),t.multiply(n,t.inv(e))):t.map(n,function(t){return t/e})},multiply:function(n,e){var r,o,i,a,u,c,l,f;if(void 0===n.length&&void 0===e.length)return n*e;if(u=n.length,c=n[0].length,l=t.zeros(u,i=s(e)?e[0].length:c),f=0,s(e)){for(;f<i;f++)for(r=0;r<u;r++){for(a=0,o=0;o<c;o++)a+=n[r][o]*e[o][f];l[r][f]=a}return 1===u&&1===f?l[0][0]:l}return t.map(n,function(t){return t*e})},outer:function(n,e){return t.multiply(n.map(function(t){return[t]}),[e])},dot:function(n,e){s(n[0])||(n=[n]),s(e[0])||(e=[e]);for(var r,o,i=1===n[0].length&&1!==n.length?t.transpose(n):n,a=1===e[0].length&&1!==e.length?t.transpose(e):e,u=[],c=0,l=i.length,f=i[0].length;c<l;c++){for(u[c]=[],r=0,o=0;o<f;o++)r+=i[c][o]*a[c][o];u[c]=r}return 1===u.length?u[0]:u},pow:function(e,r){return t.map(e,function(t){return n.pow(t,r)})},exp:function(e){return t.map(e,function(t){return n.exp(t)})},log:function(e){return t.map(e,function(t){return n.log(t)})},abs:function(e){return t.map(e,function(t){return n.abs(t)})},norm:function(t,e){var r=0,o=0;for(isNaN(e)&&(e=2),s(t[0])&&(t=t[0]);o<t.length;o++)r+=n.pow(n.abs(t[o]),e);return n.pow(r,1/e)},angle:function(e,r){return n.acos(t.dot(e,r)/(t.norm(e)*t.norm(r)))},aug:function(t,n){var e,r=[];for(e=0;e<t.length;e++)r.push(t[e].slice());for(e=0;e<r.length;e++)o.apply(r[e],n[e]);return r},inv:function(n){for(var e,r=n.length,o=n[0].length,i=t.identity(r,o),s=t.gauss_jordan(n,i),a=[],u=0;u<r;u++)for(a[u]=[],e=o;e<s[0].length;e++)a[u][e-o]=s[u][e];return a},det:function t(n){if(2===n.length)return n[0][0]*n[1][1]-n[0][1]*n[1][0];for(var e=0,r=0;r<n.length;r++){for(var o=[],i=1;i<n.length;i++){o[i-1]=[];for(var s=0;s<n.length;s++)s<r?o[i-1][s]=n[i][s]:s>r&&(o[i-1][s-1]=n[i][s])}var a=r%2?-1:1;e+=t(o)*n[0][r]*a}return e},gauss_elimination:function(e,r){var o,i,s,a,u=0,c=0,l=e.length,f=e[0].length,h=1,m=0,d=[];for(o=(e=t.aug(e,r))[0].length,u=0;u<l;u++){for(i=e[u][u],c=u,a=u+1;a<f;a++)i<n.abs(e[a][u])&&(i=e[a][u],c=a);if(c!=u)for(a=0;a<o;a++)s=e[u][a],e[u][a]=e[c][a],e[c][a]=s;for(c=u+1;c<l;c++)for(h=e[c][u]/e[u][u],a=u;a<o;a++)e[c][a]=e[c][a]-h*e[u][a]}for(u=l-1;u>=0;u--){for(m=0,c=u+1;c<=l-1;c++)m+=d[c]*e[u][c];d[u]=(e[u][o-1]-m)/e[u][u]}return d},gauss_jordan:function(e,r){var o,i,s,a=t.aug(e,r),u=a.length,c=a[0].length,l=0;for(i=0;i<u;i++){var f=i;for(s=i+1;s<u;s++)n.abs(a[s][i])>n.abs(a[f][i])&&(f=s);var h=a[i];for(a[i]=a[f],a[f]=h,s=i+1;s<u;s++)for(l=a[s][i]/a[i][i],o=i;o<c;o++)a[s][o]-=a[i][o]*l}for(i=u-1;i>=0;i--){for(l=a[i][i],s=0;s<i;s++)for(o=c-1;o>i-1;o--)a[s][o]-=a[i][o]*a[s][i]/l;for(a[i][i]/=l,o=u;o<c;o++)a[i][o]/=l}return a},triaUpSolve:function(n,e){var r,o=n[0].length,i=t.zeros(1,o)[0],s=!1;return null!=e[0].length&&(e=e.map(function(t){return t[0]}),s=!0),t.arange(o-1,-1,-1).forEach(function(s){r=t.arange(s+1,o).map(function(t){return i[t]*n[s][t]}),i[s]=(e[s]-t.sum(r))/n[s][s]}),s?i.map(function(t){return[t]}):i},triaLowSolve:function(n,e){var r,o=n[0].length,i=t.zeros(1,o)[0],s=!1;return null!=e[0].length&&(e=e.map(function(t){return t[0]}),s=!0),t.arange(o).forEach(function(o){r=t.arange(o).map(function(t){return n[o][t]*i[t]}),i[o]=(e[o]-t.sum(r))/n[o][o]}),s?i.map(function(t){return[t]}):i},lu:function(n){var e,r=n.length,o=t.identity(r),i=t.zeros(n.length,n[0].length);return t.arange(r).forEach(function(t){i[0][t]=n[0][t]}),t.arange(1,r).forEach(function(s){t.arange(s).forEach(function(r){e=t.arange(r).map(function(t){return o[s][t]*i[t][r]}),o[s][r]=(n[s][r]-t.sum(e))/i[r][r]}),t.arange(s,r).forEach(function(r){e=t.arange(s).map(function(t){return o[s][t]*i[t][r]}),i[s][r]=n[e.length][r]-t.sum(e)})}),[o,i]},cholesky:function(e){var r,o=e.length,i=t.zeros(e.length,e[0].length);return t.arange(o).forEach(function(s){r=t.arange(s).map(function(t){return n.pow(i[s][t],2)}),i[s][s]=n.sqrt(e[s][s]-t.sum(r)),t.arange(s+1,o).forEach(function(n){r=t.arange(s).map(function(t){return i[s][t]*i[n][t]}),i[n][s]=(e[s][n]-t.sum(r))/i[s][s]})}),i},gauss_jacobi:function(e,r,o,i){for(var s,a,u,c,l=0,f=0,h=e.length,m=[],d=[],p=[];l<h;l++)for(m[l]=[],d[l]=[],p[l]=[],f=0;f<h;f++)l>f?(m[l][f]=e[l][f],d[l][f]=p[l][f]=0):l<f?(d[l][f]=e[l][f],m[l][f]=p[l][f]=0):(p[l][f]=e[l][f],m[l][f]=d[l][f]=0);for(u=t.multiply(t.multiply(t.inv(p),t.add(m,d)),-1),a=t.multiply(t.inv(p),r),s=o,c=t.add(t.multiply(u,o),a),l=2;n.abs(t.norm(t.subtract(c,s)))>i;)s=c,c=t.add(t.multiply(u,s),a),l++;return c},gauss_seidel:function(e,r,o,i){for(var s,a,u,c,l,f=0,h=e.length,m=[],d=[],p=[];f<h;f++)for(m[f]=[],d[f]=[],p[f]=[],s=0;s<h;s++)f>s?(m[f][s]=e[f][s],d[f][s]=p[f][s]=0):f<s?(d[f][s]=e[f][s],m[f][s]=p[f][s]=0):(p[f][s]=e[f][s],m[f][s]=d[f][s]=0);for(c=t.multiply(t.multiply(t.inv(t.add(p,m)),d),-1),u=t.multiply(t.inv(t.add(p,m)),r),a=o,l=t.add(t.multiply(c,o),u),f=2;n.abs(t.norm(t.subtract(l,a)))>i;)a=l,l=t.add(t.multiply(c,a),u),f+=1;return l},SOR:function(e,r,o,i,s){for(var a,u,c,l,f,h=0,m=e.length,d=[],p=[],g=[];h<m;h++)for(d[h]=[],p[h]=[],g[h]=[],a=0;a<m;a++)h>a?(d[h][a]=e[h][a],p[h][a]=g[h][a]=0):h<a?(p[h][a]=e[h][a],d[h][a]=g[h][a]=0):(g[h][a]=e[h][a],d[h][a]=p[h][a]=0);for(l=t.multiply(t.inv(t.add(g,t.multiply(d,s))),t.subtract(t.multiply(g,1-s),t.multiply(p,s))),c=t.multiply(t.multiply(t.inv(t.add(g,t.multiply(d,s))),r),s),u=o,f=t.add(t.multiply(l,o),c),h=2;n.abs(t.norm(t.subtract(f,u)))>i;)u=f,f=t.add(t.multiply(l,u),c),h++;return f},householder:function(e){for(var r,o,i,s,a=e.length,u=e[0].length,c=0,l=[],f=[];c<a-1;c++){for(r=0,s=c+1;s<u;s++)r+=e[s][c]*e[s][c];for(r=(e[c+1][c]>0?-1:1)*n.sqrt(r),o=n.sqrt((r*r-e[c+1][c]*r)/2),(l=t.zeros(a,1))[c+1][0]=(e[c+1][c]-r)/(2*o),i=c+2;i<a;i++)l[i][0]=e[i][c]/(2*o);f=t.subtract(t.identity(a,u),t.multiply(t.multiply(l,t.transpose(l)),2)),e=t.multiply(f,t.multiply(e,f))}return e},QR:(e=t.sum,r=t.arange,function(o){var i,s,a,u=o.length,c=o[0].length,l=t.zeros(c,c);for(o=t.copy(o),s=0;s<c;s++){for(l[s][s]=n.sqrt(e(r(u).map(function(t){return o[t][s]*o[t][s]}))),i=0;i<u;i++)o[i][s]=o[i][s]/l[s][s];for(a=s+1;a<c;a++)for(l[s][a]=e(r(u).map(function(t){return o[t][s]*o[t][a]})),i=0;i<u;i++)o[i][a]=o[i][a]-o[i][s]*l[s][a]}return[o,l]}),lstsq:function(n,e){var r=!1;void 0===e[0].length&&(e=e.map(function(t){return[t]}),r=!0);var o=t.QR(n),i=o[0],s=o[1],a=n[0].length,u=t.slice(i,{col:{end:a}}),c=function(n){var e=(n=t.copy(n)).length,r=t.identity(e);return t.arange(e-1,-1,-1).forEach(function(e){t.sliceAssign(r,{row:e},t.divide(t.slice(r,{row:e}),n[e][e])),t.sliceAssign(n,{row:e},t.divide(t.slice(n,{row:e}),n[e][e])),t.arange(e).forEach(function(o){var i=t.multiply(n[o][e],-1),s=t.slice(n,{row:o}),a=t.multiply(t.slice(n,{row:e}),i);t.sliceAssign(n,{row:o},t.add(s,a));var u=t.slice(r,{row:o}),c=t.multiply(t.slice(r,{row:e}),i);t.sliceAssign(r,{row:o},t.add(u,c))})}),r}(t.slice(s,{row:{end:a}})),l=t.transpose(u);void 0===l[0].length&&(l=[l]);var f=t.multiply(t.multiply(c,l),e);return void 0===f.length&&(f=[[f]]),r?f.map(function(t){return t[0]}):f},jacobi:function(e){for(var r,o,i,s,a,u,c,l=1,f=e.length,h=t.identity(f,f),m=[];1===l;){for(a=e[0][1],i=0,s=1,r=0;r<f;r++)for(o=0;o<f;o++)r!=o&&a<n.abs(e[r][o])&&(a=n.abs(e[r][o]),i=r,s=o);for(u=e[i][i]===e[s][s]?e[i][s]>0?n.PI/4:-n.PI/4:n.atan(2*e[i][s]/(e[i][i]-e[s][s]))/2,(c=t.identity(f,f))[i][i]=n.cos(u),c[i][s]=-n.sin(u),c[s][i]=n.sin(u),c[s][s]=n.cos(u),h=t.multiply(h,c),e=t.multiply(t.multiply(t.inv(c),e),c),l=0,r=1;r<f;r++)for(o=1;o<f;o++)r!=o&&n.abs(e[r][o])>.001&&(l=1)}for(r=0;r<f;r++)m.push(e[r][r]);return[h,m]},rungekutta:function(t,n,e,r,o,i){var s,a,u;if(2===i)for(;r<=e;)o+=((s=n*t(r,o))+(a=n*t(r+n,o+s)))/2,r+=n;if(4===i)for(;r<=e;)o+=((s=n*t(r,o))+2*(a=n*t(r+n/2,o+s/2))+2*(u=n*t(r+n/2,o+a/2))+n*t(r+n,o+u))/6,r+=n;return o},romberg:function(t,e,r,o){for(var i,s,a,u,c,l=0,f=(r-e)/2,h=[],m=[],d=[];l<o/2;){for(c=t(e),a=e,u=0;a<=r;a+=f,u++)h[u]=a;for(i=h.length,a=1;a<i-1;a++)c+=(a%2!=0?4:2)*t(h[a]);c=f/3*(c+t(r)),d[l]=c,f/=2,l++}for(s=d.length,i=1;1!==s;){for(a=0;a<s-1;a++)m[a]=(n.pow(4,i)*d[a+1]-d[a])/(n.pow(4,i)-1);s=m.length,d=m,m=[],i++}return d},richardson:function(t,e,r,o){function i(t,n){for(var e,r=0,o=t.length;r<o;r++)t[r]===n&&(e=r);return e}for(var s,a,u,c,l,f=n.abs(r-t[i(t,r)+1]),h=0,m=[],d=[];o>=f;)s=i(t,r+o),a=i(t,r),m[h]=(e[s]-2*e[a]+e[2*a-s])/(o*o),o/=2,h++;for(c=m.length,u=1;1!=c;){for(l=0;l<c-1;l++)d[l]=(n.pow(4,u)*m[l+1]-m[l])/(n.pow(4,u)-1);c=d.length,m=d,d=[],u++}return m},simpson:function(t,n,e,r){for(var o,i=(e-n)/r,s=t(n),a=[],u=n,c=0,l=1;u<=e;u+=i,c++)a[c]=u;for(o=a.length;l<o-1;l++)s+=(l%2!=0?4:2)*t(a[l]);return i/3*(s+t(e))},hermite:function(t,n,e,r){for(var o,i=t.length,s=0,a=0,u=[],c=[],l=[],f=[];a<i;a++){for(u[a]=1,o=0;o<i;o++)a!=o&&(u[a]*=(r-t[o])/(t[a]-t[o]));for(c[a]=0,o=0;o<i;o++)a!=o&&(c[a]+=1/(t[a]-t[o]));l[a]=(1-2*(r-t[a])*c[a])*(u[a]*u[a]),f[a]=(r-t[a])*(u[a]*u[a]),s+=l[a]*n[a]+f[a]*e[a]}return s},lagrange:function(t,n,e){for(var r,o,i=0,s=0,a=t.length;s<a;s++){for(o=n[s],r=0;r<a;r++)s!=r&&(o*=(e-t[r])/(t[s]-t[r]));i+=o}return i},cubic_spline:function(n,e,r){for(var o,i,s=n.length,a=0,u=[],c=[],l=[],f=[],h=[],m=[];a<s-1;a++)f[a]=n[a+1]-n[a];for(l[0]=0,a=1;a<s-1;a++)l[a]=3/f[a]*(e[a+1]-e[a])-3/f[a-1]*(e[a]-e[a-1]);for(a=1;a<s-1;a++)u[a]=[],c[a]=[],u[a][a-1]=f[a-1],u[a][a]=2*(f[a-1]+f[a]),u[a][a+1]=f[a],c[a][0]=l[a];for(i=t.multiply(t.inv(u),c),o=0;o<s-1;o++)h[o]=(e[o+1]-e[o])/f[o]-f[o]*(i[o+1][0]+2*i[o][0])/3,m[o]=(i[o+1][0]-i[o][0])/(3*f[o]);for(o=0;o<s&&!(n[o]>r);o++);return e[o-=1]+(r-n[o])*h[o]+t.sq(r-n[o])*i[o]+(r-n[o])*t.sq(r-n[o])*m[o]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(n){var e,r,o,i,s,a=n.length,u=n[0].length,c=0,l=[],f=[],h=[],m=[],d=[],p=[],g=[];for(c=0;c<a;c++)l[c]=t.sum(n[c])/u;for(c=0;c<u;c++)for(d[c]=[],e=0;e<a;e++)d[c][e]=n[e][c]-l[e];for(d=t.transpose(d),c=0;c<a;c++)for(p[c]=[],e=0;e<a;e++)p[c][e]=t.dot([d[c]],[d[e]])/(u-1);for(s=(o=t.jacobi(p))[0],f=o[1],g=t.transpose(s),c=0;c<f.length;c++)for(e=c;e<f.length;e++)f[c]<f[e]&&(r=f[c],f[c]=f[e],f[e]=r,h=g[c],g[c]=g[e],g[e]=h);for(i=t.transpose(d),c=0;c<a;c++)for(m[c]=[],e=0;e<i.length;e++)m[c][e]=t.dot([g[c]],[i[e]]);return[n,f,g,m]}}),function(n){for(var e=0;e<n.length;e++)(function(n){t.fn[n]=function(e,r){var o=this;return r?(setTimeout(function(){r.call(o,t.fn[n].call(o,e))},15),this):"number"==typeof t[n](this,e)?t[n](this,e):t(t[n](this,e))}})(n[e])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(n,Math),function(t,n){var e=[].slice,r=t.utils.isNumber,o=t.utils.isArray;function i(t,e,r,o){if(t>1||r>1||t<=0||r<=0)throw new Error("Proportions should be greater than 0 and less than 1");var i=(t*e+r*o)/(e+o);return(t-r)/n.sqrt(i*(1-i)*(1/e+1/o))}t.extend({zscore:function(){var n=e.call(arguments);return r(n[1])?(n[0]-n[1])/n[2]:(n[0]-t.mean(n[1]))/t.stdev(n[1],n[2])},ztest:function(){var r,i=e.call(arguments);return o(i[1])?(r=t.zscore(i[0],i[1],i[3]),1===i[2]?t.normal.cdf(-n.abs(r),0,1):2*t.normal.cdf(-n.abs(r),0,1)):i.length>2?(r=t.zscore(i[0],i[1],i[2]),1===i[3]?t.normal.cdf(-n.abs(r),0,1):2*t.normal.cdf(-n.abs(r),0,1)):(r=i[0],1===i[1]?t.normal.cdf(-n.abs(r),0,1):2*t.normal.cdf(-n.abs(r),0,1))}}),t.extend(t.fn,{zscore:function(t,n){return(t-this.mean())/this.stdev(n)},ztest:function(e,r,o){var i=n.abs(this.zscore(e,o));return 1===r?t.normal.cdf(-i,0,1):2*t.normal.cdf(-i,0,1)}}),t.extend({tscore:function(){var r=e.call(arguments);return 4===r.length?(r[0]-r[1])/(r[2]/n.sqrt(r[3])):(r[0]-t.mean(r[1]))/(t.stdev(r[1],!0)/n.sqrt(r[1].length))},ttest:function(){var o,i=e.call(arguments);return 5===i.length?(o=n.abs(t.tscore(i[0],i[1],i[2],i[3])),1===i[4]?t.studentt.cdf(-o,i[3]-1):2*t.studentt.cdf(-o,i[3]-1)):r(i[1])?(o=n.abs(i[0]),1==i[2]?t.studentt.cdf(-o,i[1]-1):2*t.studentt.cdf(-o,i[1]-1)):(o=n.abs(t.tscore(i[0],i[1])),1==i[2]?t.studentt.cdf(-o,i[1].length-1):2*t.studentt.cdf(-o,i[1].length-1))}}),t.extend(t.fn,{tscore:function(t){return(t-this.mean())/(this.stdev(!0)/n.sqrt(this.cols()))},ttest:function(e,r){return 1===r?1-t.studentt.cdf(n.abs(this.tscore(e)),this.cols()-1):2*t.studentt.cdf(-n.abs(this.tscore(e)),this.cols()-1)}}),t.extend({anovafscore:function(){var r,o,i,s,a,u,c,l,f=e.call(arguments);if(1===f.length){for(a=new Array(f[0].length),c=0;c<f[0].length;c++)a[c]=f[0][c];f=a}for(o=new Array,c=0;c<f.length;c++)o=o.concat(f[c]);for(i=t.mean(o),r=0,c=0;c<f.length;c++)r+=f[c].length*n.pow(t.mean(f[c])-i,2);for(r/=f.length-1,u=0,c=0;c<f.length;c++)for(s=t.mean(f[c]),l=0;l<f[c].length;l++)u+=n.pow(f[c][l]-s,2);return r/(u/(o.length-f.length))},anovaftest:function(){var n,o,i,s,a=e.call(arguments);if(r(a[0]))return 1-t.centralF.cdf(a[0],a[1],a[2]);var u=t.anovafscore(a);for(n=a.length-1,i=0,s=0;s<a.length;s++)i+=a[s].length;return o=i-n-1,1-t.centralF.cdf(u,n,o)},ftest:function(n,e,r){return 1-t.centralF.cdf(n,e,r)}}),t.extend(t.fn,{anovafscore:function(){return t.anovafscore(this.toArray())},anovaftes:function(){var n,e=0;for(n=0;n<this.length;n++)e+=this[n].length;return t.ftest(this.anovafscore(),this.length-1,e-this.length)}}),t.extend({qscore:function(){var o,i,s,a,u,c=e.call(arguments);return r(c[0])?(o=c[0],i=c[1],s=c[2],a=c[3],u=c[4]):(o=t.mean(c[0]),i=t.mean(c[1]),s=c[0].length,a=c[1].length,u=c[2]),n.abs(o-i)/(u*n.sqrt((1/s+1/a)/2))},qtest:function(){var n,r=e.call(arguments);3===r.length?(n=r[0],r=r.slice(1)):7===r.length?(n=t.qscore(r[0],r[1],r[2],r[3],r[4]),r=r.slice(5)):(n=t.qscore(r[0],r[1],r[2]),r=r.slice(3));var o=r[0],i=r[1];return 1-t.tukey.cdf(n,i,o-i)},tukeyhsd:function(n){for(var e=t.pooledstdev(n),r=n.map(function(n){return t.mean(n)}),o=n.reduce(function(t,n){return t+n.length},0),i=[],s=0;s<n.length;++s)for(var a=s+1;a<n.length;++a){var u=t.qtest(r[s],r[a],n[s].length,n[a].length,e,o,n.length);i.push([[s,a],u])}return i}}),t.extend({normalci:function(){var r,o=e.call(arguments),i=new Array(2);return r=4===o.length?n.abs(t.normal.inv(o[1]/2,0,1)*o[2]/n.sqrt(o[3])):n.abs(t.normal.inv(o[1]/2,0,1)*t.stdev(o[2])/n.sqrt(o[2].length)),i[0]=o[0]-r,i[1]=o[0]+r,i},tci:function(){var r,o=e.call(arguments),i=new Array(2);return r=4===o.length?n.abs(t.studentt.inv(o[1]/2,o[3]-1)*o[2]/n.sqrt(o[3])):n.abs(t.studentt.inv(o[1]/2,o[2].length-1)*t.stdev(o[2],!0)/n.sqrt(o[2].length)),i[0]=o[0]-r,i[1]=o[0]+r,i},significant:function(t,n){return t<n}}),t.extend(t.fn,{normalci:function(n,e){return t.normalci(n,e,this.toArray())},tci:function(n,e){return t.tci(n,e,this.toArray())}}),t.extend(t.fn,{oneSidedDifferenceOfProportions:function(n,e,r,o){var s=i(n,e,r,o);return t.ztest(s,1)},twoSidedDifferenceOfProportions:function(n,e,r,o){var s=i(n,e,r,o);return t.ztest(s,2)}})}(n,Math),n.models=function(){function t(t,e){var r=t.length,o=e[0].length-1,i=r-o-1,s=n.lstsq(e,t),a=n.multiply(e,s.map(function(t){return[t]})).map(function(t){return t[0]}),u=n.subtract(t,a),c=n.mean(t),l=n.sum(a.map(function(t){return Math.pow(t-c,2)})),f=n.sum(t.map(function(t,n){return Math.pow(t-a[n],2)})),h=l+f;return{exog:e,endog:t,nobs:r,df_model:o,df_resid:i,coef:s,predict:a,resid:u,ybar:c,SST:h,SSE:l,SSR:f,R2:l/h}}function e(e){var r,o,i=(r=e.exog,o=r[0].length,n.arange(o).map(function(e){var i=n.arange(o).filter(function(t){return t!==e});return t(n.col(r,e).map(function(t){return t[0]}),n.col(r,i))})),s=Math.sqrt(e.SSR/e.df_resid),a=i.map(function(t){var n=t.SST,e=t.R2;return s/Math.sqrt(n*(1-e))}),u=e.coef.map(function(t,n){return(t-0)/a[n]}),c=u.map(function(t){var r=n.studentt.cdf(t,e.df_resid);return 2*(r>.5?1-r:r)}),l=n.studentt.inv(.975,e.df_resid),f=e.coef.map(function(t,n){var e=l*a[n];return[t-e,t+e]});return{se:a,t:u,p:c,sigmaHat:s,interval95:f}}return{ols:function(r,o){var i=t(r,o),s=e(i),a=function(t){var e,r,o,i=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:i,pvalue:1-(e=i,r=t.df_model,o=t.df_resid,n.beta.cdf(e/(o/r+e),r/2,o/2))}}(i),u=1-(1-i.R2)*((i.nobs-1)/i.df_resid);return i.t=s,i.f=a,i.adjust_R2=u,i}}}(),n.extend({buildxmatrix:function(){for(var t=new Array(arguments.length),e=0;e<arguments.length;e++){t[e]=[1].concat(arguments[e])}return n(t)},builddxmatrix:function(){for(var t=new Array(arguments[0].length),e=0;e<arguments[0].length;e++){t[e]=[1].concat(arguments[0][e])}return n(t)},buildjxmatrix:function(t){for(var e=new Array(t.length),r=0;r<t.length;r++)e[r]=t[r];return n.builddxmatrix(e)},buildymatrix:function(t){return n(t).transpose()},buildjymatrix:function(t){return t.transpose()},matrixmult:function(t,e){var r,o,i,s,a;if(t.cols()==e.rows()){if(e.rows()>1){for(s=[],r=0;r<t.rows();r++)for(s[r]=[],o=0;o<e.cols();o++){for(a=0,i=0;i<t.cols();i++)a+=t.toArray()[r][i]*e.toArray()[i][o];s[r][o]=a}return n(s)}for(s=[],r=0;r<t.rows();r++)for(s[r]=[],o=0;o<e.cols();o++){for(a=0,i=0;i<t.cols();i++)a+=t.toArray()[r][i]*e.toArray()[o];s[r][o]=a}return n(s)}},regress:function(t,e){var r=n.xtranspxinv(t),o=t.transpose(),i=n.matrixmult(n(r),o);return n.matrixmult(i,e)},regresst:function(t,e,r){var o=n.regress(t,e),i={anova:{}},s=n.jMatYBar(t,o);i.yBar=s;var a=e.mean();i.anova.residuals=n.residuals(e,s),i.anova.ssr=n.ssr(s,a),i.anova.msr=i.anova.ssr/(t[0].length-1),i.anova.sse=n.sse(e,s),i.anova.mse=i.anova.sse/(e.length-(t[0].length-1)-1),i.anova.sst=n.sst(e,a),i.anova.mst=i.anova.sst/(e.length-1),i.anova.r2=1-i.anova.sse/i.anova.sst,i.anova.r2<0&&(i.anova.r2=0),i.anova.fratio=i.anova.msr/i.anova.mse,i.anova.pvalue=n.anovaftest(i.anova.fratio,t[0].length-1,e.length-(t[0].length-1)-1),i.anova.rmse=Math.sqrt(i.anova.mse),i.anova.r2adj=1-i.anova.mse/i.anova.mst,i.anova.r2adj<0&&(i.anova.r2adj=0),i.stats=new Array(t[0].length);for(var u,c,l,f=n.xtranspxinv(t),h=0;h<o.length;h++)u=Math.sqrt(i.anova.mse*Math.abs(f[h][h])),c=Math.abs(o[h]/u),l=n.ttest(c,e.length-t[0].length-1,r),i.stats[h]=[o[h],u,c,l];return i.regress=o,i},xtranspx:function(t){return n.matrixmult(t.transpose(),t)},xtranspxinv:function(t){var e=n.matrixmult(t.transpose(),t);return n.inv(e)},jMatYBar:function(t,e){var r=n.matrixmult(t,e);return new n(r)},residuals:function(t,e){return n.matrixsubtract(t,e)},ssr:function(t,n){for(var e=0,r=0;r<t.length;r++)e+=Math.pow(t[r]-n,2);return e},sse:function(t,n){for(var e=0,r=0;r<t.length;r++)e+=Math.pow(t[r]-n[r],2);return e},sst:function(t,n){for(var e=0,r=0;r<t.length;r++)e+=Math.pow(t[r]-n,2);return e},matrixsubtract:function(t,e){for(var r=new Array(t.length),o=0;o<t.length;o++){r[o]=new Array(t[o].length);for(var i=0;i<t[o].length;i++)r[o][i]=t[o][i]-e[o][i]}return n(r)}}),n.jStat=n,n)},9982:function(t,n,e){var r;!function(){var n={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var n=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function e(t,e,r,o,i){for(var s,a,u,c,l,f,h,m,d,p,g,y,v;i>=64;){for(s=e[0],a=e[1],u=e[2],c=e[3],l=e[4],f=e[5],h=e[6],m=e[7],p=0;p<16;p++)g=o+4*p,t[p]=(255&r[g])<<24|(255&r[g+1])<<16|(255&r[g+2])<<8|255&r[g+3];for(p=16;p<64;p++)y=((d=t[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,v=((d=t[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,t[p]=(y+t[p-7]|0)+(v+t[p-16]|0);for(p=0;p<64;p++)y=(((l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&f^~l&h)|0)+(m+(n[p]+t[p]|0)|0)|0,v=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&a^s&u^a&u)|0,m=h,h=f,f=l,l=c+y|0,c=u,u=a,a=s,s=y+v|0;e[0]+=s,e[1]+=a,e[2]+=u,e[3]+=c,e[4]+=l,e[5]+=f,e[6]+=h,e[7]+=m,o+=64,i-=64}return o}var r=function(){function n(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return n.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},n.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},n.prototype.update=function(t,n){if(void 0===n&&(n=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var r=0;if(this.bytesHashed+=n,this.bufferLength>0){for(;this.bufferLength<64&&n>0;)this.buffer[this.bufferLength++]=t[r++],n--;64===this.bufferLength&&(e(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(n>=64&&(r=e(this.temp,this.state,t,r,n),n%=64);n>0;)this.buffer[this.bufferLength++]=t[r++],n--;return this},n.prototype.finish=function(t){if(!this.finished){var n=this.bytesHashed,r=this.bufferLength,o=n/536870912|0,i=n<<3,s=n%64<56?64:128;this.buffer[r]=128;for(var a=r+1;a<s-8;a++)this.buffer[a]=0;this.buffer[s-8]=o>>>24&255,this.buffer[s-7]=o>>>16&255,this.buffer[s-6]=o>>>8&255,this.buffer[s-5]=o>>>0&255,this.buffer[s-4]=i>>>24&255,this.buffer[s-3]=i>>>16&255,this.buffer[s-2]=i>>>8&255,this.buffer[s-1]=i>>>0&255,e(this.temp,this.state,this.buffer,0,s),this.finished=!0}for(a=0;a<8;a++)t[4*a+0]=this.state[a]>>>24&255,t[4*a+1]=this.state[a]>>>16&255,t[4*a+2]=this.state[a]>>>8&255,t[4*a+3]=this.state[a]>>>0&255;return this},n.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},n.prototype._saveState=function(t){for(var n=0;n<this.state.length;n++)t[n]=this.state[n]},n.prototype._restoreState=function(t,n){for(var e=0;e<this.state.length;e++)this.state[e]=t[e];this.bytesHashed=n,this.finished=!1,this.bufferLength=0},n}();t.Hash=r;var o=function(){function t(t){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var n=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new r).update(t).finish(n).clean();else for(var e=0;e<t.length;e++)n[e]=t[e];for(e=0;e<n.length;e++)n[e]^=54;for(this.inner.update(n),e=0;e<n.length;e++)n[e]^=106;for(this.outer.update(n),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),e=0;e<n.length;e++)n[e]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function i(t){var n=(new r).update(t),e=n.digest();return n.clean(),e}function s(t,n){var e=new o(t).update(n),r=e.digest();return e.clean(),r}function a(t,n,e,r){var o=r[0];if(0===o)throw new Error("hkdf: cannot expand more");n.reset(),o>1&&n.update(t),e&&n.update(e),n.update(r),n.finish(t),r[0]++}t.HMAC=o,t.hash=i,t.default=i,t.hmac=s;var u=new Uint8Array(t.digestLength);t.hkdf=function(t,n,e,r){void 0===n&&(n=u),void 0===r&&(r=32);for(var i=new Uint8Array([1]),c=s(n,t),l=new o(c),f=new Uint8Array(l.digestLength),h=f.length,m=new Uint8Array(r),d=0;d<r;d++)h===f.length&&(a(f,l,e,i),h=0),m[d]=f[h++];return l.clean(),f.fill(0),i.fill(0),m},t.pbkdf2=function(t,n,e,r){for(var i=new o(t),s=i.digestLength,a=new Uint8Array(4),u=new Uint8Array(s),c=new Uint8Array(s),l=new Uint8Array(r),f=0;f*s<r;f++){var h=f+1;a[0]=h>>>24&255,a[1]=h>>>16&255,a[2]=h>>>8&255,a[3]=h>>>0&255,i.reset(),i.update(n),i.update(a),i.finish(c);for(var m=0;m<s;m++)u[m]=c[m];for(m=2;m<=e;m++){i.reset(),i.update(c).finish(c);for(var d=0;d<s;d++)u[d]^=c[d]}for(m=0;m<s&&f*s+m<r;m++)l[f*s+m]=u[m]}for(f=0;f<s;f++)u[f]=c[f]=0;for(f=0;f<4;f++)a[f]=0;return i.clean(),l}}(n);var o=n.default;for(var i in n)o[i]=n[i];"object"==typeof t.exports?t.exports=o:void 0===(r=function(){return o}.call(n,e,n,t))||(t.exports=r)}()}},n={};function e(r){var o=n[r];if(void 0!==o)return o.exports;var i=n[r]={id:r,loaded:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}e.m=t,e.amdO={},e.d=(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},e.u=t=>t+".js",e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),e.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),e.o=(t,n)=>Object.prototype.hasOwnProperty.call(t,n),e.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;e.g.importScripts&&(t=e.g.location+"");var n=e.g.document;if(!t&&n&&(n.currentScript&&"SCRIPT"===n.currentScript.tagName.toUpperCase()&&(t=n.currentScript.src),!t)){var r=n.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&(!t||!/^http(s?):/.test(t));)t=r[o--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=t})(),e.b=document.baseURI||self.location.href;var r={};(()=>{"use strict";e.r(r),e.d(r,{_package:()=>Ie,initAutoTests:()=>Oe,test:()=>Me,tests:()=>h});const t=DG,n=grok;e(9982);const o=t.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,');o.columns.add(t.Column.fromList(t.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var i=function(t,n,e,r){return new(e||(e=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(s,a)}u((r=r.apply(t,n||[])).next())})};const s=3e4,a=108e5,u=console.log.bind(console),c=console.info.bind(console),l=console.warn.bind(console),f=console.error.bind(console),h={},m="Auto Tests",d="Demo",p="Detectors",g="Core",y={};let v;var w,E,A,C,_,N,x,b,S,T;!function(t){t.notNull=function(t,n){if(null==t)throw new Error(`${null==n?"Value":n} not defined`)}}(w||(w={}));class I{constructor(t,n){this.catchUnhandled=!0,this.report=!1,void 0!==t&&(this.catchUnhandled=t),void 0!==n&&(this.report=n)}}class M{constructor(n,e,r,o){var a;this.category=n,this.name=e,null!=o||(o={}),null!==(a=o.timeout)&&void 0!==a||(o.timeout=s),this.options=o,this.test=()=>i(this,void 0,void 0,function*(){return new Promise((n,e)=>i(this,void 0,void 0,function*(){var o;let i="";try{t.Test.isInDebug;let n=yield r();try{i=null!==(o=null==n?void 0:n.toString())&&void 0!==o?o:""}catch(t){i="Can't convert test's result to string",console.error(`Can't convert test's result to string in the ${this.category}:${this.name} test`)}}catch(t){e(t)}n(i)}))})}}function O(t,n,e){null==h[v]&&(h[v]={}),null==h[v].tests&&(h[v].tests=[]),h[v].tests.push(new M(v,t,n,e))}function R(t,n=!0,e){if(e=e?`${e}, `:"",t!==n)throw new Error(`${e}Expected "${n}", got "${t}"`)}function L(t,n,e){var r;v=t,n(),h[v]&&(h[v].clear=null===(r=null==e?void 0:e.clear)||void 0===r||r,h[v].timeout=null==e?void 0:e.timeout,h[v].benchmarks=null==e?void 0:e.benchmarks,h[v].stressTests=null==e?void 0:e.stressTests,h[v].owner=null==e?void 0:e.owner)}function P(t,n){return t.replace(new RegExp(n.name,"gi"),n.nqName)}function D(e,r){var u,c,l,f,v,w,E,A,C,_;return i(this,void 0,void 0,function*(){const N=e.id;if(y[N])return;const x=r?r.tests:h;if("DevTools"===e.name||r&&"DevTools"===r._package.name)for(const t of window.dartTests){const n=t.name.split(/\s*\|\s*!/g);let e=null!==(u=n.pop())&&void 0!==u?u:t.name,r=n.length?g+": "+n.join(": "):g,o=e.split(" | ");e=o[o.length-1],o.unshift(r),o.pop(),r=o.join(": "),void 0===x[r]&&(x[r]={tests:[],clear:!0}),x[r].tests.push(new M(r,e,t.test,{isAggregated:!1,timeout:null!==(l=null===(c=t.options)||void 0===c?void 0:c.timeout)&&void 0!==l?l:s,skipReason:null===(f=t.options)||void 0===f?void 0:f.skipReason,owner:null===(v=t.options)||void 0===v?void 0:v.owner,benchmark:null!==(E=null===(w=t.options)||void 0===w?void 0:w.benchmark)&&void 0!==E&&E}))}const b=[],S=[],T=[],I=yield n.dapi.functions.filter(`package.id = "${N}"`).list(),O=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);for(const r of I){const u=r.options.test,c=r.options.demoPath;if(u&&Array.isArray(u)&&u.length)for(let e=0;e<u.length;e++){const o=u[e].matchAll(O),c={};Array.from(o).forEach(t=>{t[0].startsWith("skip")?c.skip=t[1]:t[0].startsWith("wait")?c.wait=parseInt(t[2]):t[0].startsWith("cat")?c.cat=t[3]:t[0].startsWith("timeout")&&(c.timeout=parseInt(t[4]))});const l=new M(null!==(A=c.cat)&&void 0!==A?A:m,1===u.length?r.name:`${r.name} ${e+1}`,()=>i(this,void 0,void 0,function*(){const t=yield n.functions.eval(P(u[e],r));if(c.wait&&(yield H(c.wait)),"boolean"==typeof t&&!t)throw`Failed: ${u[e]}, expected true, got ${t}`}),{skipReason:c.skip,timeout:t.Test.isInBenchmark?null!==(C=c.benchmarkTimeout)&&void 0!==C?C:a:null!==(_=c.timeout)&&void 0!==_?_:s});if(c.cat){const t=c.cat;void 0===x[t]&&(x[t]={tests:[],clear:!0}),x[t].tests||(x[t].tests=[]),x[t].tests.push(l)}else b.push(l)}if(c){const t=r.options.demoWait?parseInt(r.options.demoWait):void 0,e=new M(d,r.friendlyName,()=>i(this,void 0,void 0,function*(){yield H(300),n.shell.clearLastError(),yield r.apply(),yield H(t||2e3);const e=yield n.shell.lastError;if(e)throw new Error(e)}),{skipReason:r.options.demoSkip});S.push(e)}if(r.hasTag("semTypeDetector")){let t=o;r.options.testData&&(t=yield n.data.files.openTable(`System:AppData/${e.nqName}/${r.options.testData}`));const s=new M(p,r.friendlyName,()=>i(this,void 0,void 0,function*(){const n=[];console.log(`System:AppData/${e.nqName}/${r.options.testData}`);for(const e of t.clone().columns){const t=yield r.apply([e]);n.push(t||e.semType)}const o=n.filter(t=>t);R(o.length,1),r.options.testDataColumnName&&R(o[0],r.options.testDataColumnName)}),{skipReason:r.options.skipTest});T.push(s)}}y[N]=!0,b.length>0&&(x[m]={tests:b,clear:!0}),S.length>0&&(x[d]={tests:S,clear:!0}),T.length>0&&(x[p]={tests:T,clear:!1})})}function F(t,e){return i(this,void 0,void 0,function*(){null!=n.shell.reportTest?yield n.shell.reportTest(t,e):yield fetch(`${n.dapi.root}/log/tests/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(e)})})}function U(n){return i(this,void 0,void 0,function*(){return`${n.toString()}\n${n.stack?yield t.Logger.translateStackTrace(n.stack):""}`})}function B(e,r,o,a,c,l){var h,m,d,p,g,y,v,w,E,A,C,_,N,x;return i(this,void 0,void 0,function*(){let i;o.length=0;const b=null!=r&&e.name.toLowerCase()!==r.toLowerCase();let S=(null===(h=e.options)||void 0===h?void 0:h.skipReason)||b,T=b?"skipped":null===(m=e.options)||void 0===m?void 0:m.skipReason;if(console.log(O.name,S),t.Test.isInBenchmark&&!(null===(d=e.options)||void 0===d?void 0:d.benchmark))return void u(`SKIPPED: ${e.category} ${e.name} doesnt available in benchmark mode`);S||u(`Started ${e.category} ${e.name}`);const I=Date.now(),M=new Date(I).toISOString();try{if(S)i={name:e.name,owner:null!==(g=null===(p=e.options)||void 0===p?void 0:p.owner)&&void 0!==g?g:"",category:e.category,logs:"",date:M,success:!0,result:T,ms:0,skipped:!0,package:null!=c?c:"",flaking:t.Test.isReproducing};else{let r=null!=a?a:s;t.Test.isProfiling&&console.profile(`${e.category}: ${e.name}`),i={name:e.name,owner:null!==(v=null===(y=e.options)||void 0===y?void 0:y.owner)&&void 0!==v?v:"",category:e.category,logs:"",date:M,success:!0,result:null!==(w=(yield G(e.test,r)).toString())&&void 0!==w?w:"OK",ms:0,skipped:!1,package:null!=c?c:"",flaking:t.Test.isReproducing},t.Test.isProfiling&&(console.profileEnd(`${e.category}: ${e.name}`),n.shell.info(`Profiling of ${e.category}: ${e.name} finished \n Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`))}}catch(t){f(t),i={name:e.name,owner:null!==(A=null===(E=e.options)||void 0===E?void 0:E.owner)&&void 0!==A?A:"",category:e.category,logs:"",date:M,success:!1,result:yield U(t),ms:0,skipped:!1,package:null!=c?c:"",flaking:!1}}if((null===(C=e.options)||void 0===C?void 0:C.isAggregated)&&i.result.constructor===t.DataFrame){const t=i.result.col("success");if(t&&(i.success=t.stats.sum===t.length),!l){const t=i.result;t.columns.remove("stack"),t.rows.removeWhere(t=>t.get("success")),i.result=t}i.result=i.result.toCsv()}if(i.logs=o.join("\n"),i.ms=Date.now()-I,S||u(`Finished ${e.category} ${e.name} for ${i.ms} ms`),i.category=e.category,i.name=e.name,i.owner=null!==(N=null===(_=e.options)||void 0===_?void 0:_.owner)&&void 0!==N?N:"",!b){let n={success:i.success,result:i.result,ms:i.ms,date:i.date,skipped:i.skipped,category:e.category,name:e.name,logs:i.logs,owner:i.owner,flaking:t.Test.isReproducing&&i.success,package:i.package};if(i.result.constructor==Object){const t=Object.keys(i.result).reduce((t,n)=>Object.assign(Object.assign({},t),{["result."+n]:i.result[n]}),{});n=Object.assign(Object.assign({},n),t)}n.result instanceof t.DataFrame&&(n.result=JSON.stringify(null===(x=n.result)||void 0===x?void 0:x.toJson())||""),yield F("package",n)}return i})}function k(t){const n=t.slice();return n.sort(()=>Math.random()-.5),n}function H(t){return i(this,void 0,void 0,function*(){yield new Promise(n=>setTimeout(n,t))})}function G(t,n,e="EXECUTION TIMEOUT"){return i(this,void 0,void 0,function*(){let r=null;const o=new Promise((t,o)=>{r=setTimeout(()=>{o(e)},n)});try{return yield Promise.race([t(),o])}finally{r&&clearTimeout(r)}})}t.DataFrame.fromColumns([t.Column.fromStrings("col",["val1","val2","val3"])]),function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(E||(E={})),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan String",t.Onehot="One-Hot"}(A||(A={})),function(t){t.Euclidean="Euclidean",t.Manhattan="Manhattan",t.Cosine="Vector Cosine"}(C||(C={})),function(t){t.Tanimoto="Tanimoto",t.Dice="Dice",t.Asymmetric="Asymmetric",t.BraunBlanquet="Braun-Blanquet",t.Cosine="Cosine",t.Kulczynski="Kulczynski",t.McConnaughey="Mc-Connaughey",t.RogotGoldberg="Rogot-Goldberg",t.Russel="Russel",t.Sokal="Sokal",t.Hamming="Hamming",t.Euclidean="Euclidean BitArray"}(_||(_={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(N||(N={})),(T=x||(x={})).Vector="Vector",T.String="String",T.BitArray="BitArray",T.MacroMolecule="MacroMolecule",T.Number="Number",T.IntArray="IntArray",T.NumberArray="NumberArray",function(t){t.Difference="Difference"}(b||(b={})),function(t){t.CommonItems="Common Items"}(S||(S={}));const V=new Uint32Array(65536),q=(t,n)=>{if(t.length<n.length){const e=n;n=t,t=e}return 0===n.length?t.length:t.length<=32?((t,n)=>{const e=t.length,r=n.length,o=1<<e-1;let i=-1,s=0,a=e,u=e;for(;u--;)V[t.charCodeAt(u)]|=1<<u;for(u=0;u<r;u++){let t=V[n.charCodeAt(u)];const e=t|s;t|=(t&i)+i^i,s|=~(t|i),i&=t,s&o&&a++,i&o&&a--,s=s<<1|1,i=i<<1|~(e|s),s&=e}for(u=e;u--;)V[t.charCodeAt(u)]=0;return a})(t,n):((t,n)=>{const e=n.length,r=t.length,o=[],i=[],s=Math.ceil(e/32),a=Math.ceil(r/32);for(let t=0;t<s;t++)i[t]=-1,o[t]=0;let u=0;for(;u<a-1;u++){let s=0,a=-1;const c=32*u,l=Math.min(32,r)+c;for(let n=c;n<l;n++)V[t.charCodeAt(n)]|=1<<n;for(let t=0;t<e;t++){const e=V[n.charCodeAt(t)],r=i[t/32|0]>>>t&1,u=o[t/32|0]>>>t&1,c=e|s,l=((e|u)&a)+a^a|e|u;let f=s|~(l|a),h=a&l;f>>>31^r&&(i[t/32|0]^=1<<t),h>>>31^u&&(o[t/32|0]^=1<<t),f=f<<1|r,h=h<<1|u,a=h|~(c|f),s=f&c}for(let n=c;n<l;n++)V[t.charCodeAt(n)]=0}let c=0,l=-1;const f=32*u,h=Math.min(32,r-f)+f;for(let n=f;n<h;n++)V[t.charCodeAt(n)]|=1<<n;let m=r;for(let t=0;t<e;t++){const e=V[n.charCodeAt(t)],s=i[t/32|0]>>>t&1,a=o[t/32|0]>>>t&1,u=e|c,f=((e|a)&l)+l^l|e|a;let h=c|~(f|l),d=l&f;m+=h>>>r-1&1,m-=d>>>r-1&1,h>>>31^s&&(i[t/32|0]^=1<<t),d>>>31^a&&(o[t/32|0]^=1<<t),h=h<<1|s,d=d<<1|a,l=d|~(u|h),c=h&u}for(let n=f;n<h;n++)V[t.charCodeAt(n)]=0;return m})(t,n)};var W=e(944);class ${constructor(t,n=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof t){const e=t,r=$._createBuffer(e);if(n)for(let t=0;t<r.length;t++)r[t]=-1;this._data=r,this._length=e}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=n}}getRawData(){return this._data}assureGoez(t,n){if(t<0)throw new Error(`${n} should be greater than zero`)}assureInRange(t,n,e,r){if(t<n||t>e)throw new Error(`Argument ${r} (${t}) out of range (${n}, ${e})`)}copy(t,n,e){for(let r=0;r<e;r++)n[r]=t[r]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const n=Math.floor((t+31)/32);if(n>this._data.length||n+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(n);this.copy(this._data,t,n>this._data.length?this._data.length:n),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,n)),this._length=t,this._version++}static fromAnd(t,n){if(t._length!=n._length)throw new Error(`Lengths differ (${t._length} != ${n._length})`);const e=new $(t._length);e._length=t._length,e._data=$._createBuffer(e._length),e._version=0;const r=t.lengthInInts;for(let o=0;o<r;o++)e._data[o]=t._data[o]&n._data[o];return e}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const n=new $(t.length);n._version=0;for(let e=0;e<n._length;e++)t[e]&&(n._data[Math.floor(e/32)]|=1<<(e%32&31));return n}static fromSeq(t,n){const e=new $(t);for(let r=0;r<t;++r)e.setBit(r,n(r));return e._version=0,e}static fromString(t){return $.fromSeq(t.length,n=>"1"==t.charAt(n))}static fromUint32Array(t,n){const e=new $(t);return e._data=n,e}static fromBytes(t){const n=t.length,e=new $(8*n);e._data=new Uint32Array(Math.floor((n+3)/4)),e._length=8*n;let r=0,o=0;for(;n-o>=4;)e._data[r++]=255&t[o]|(255&t[o+1])<<8|(255&t[o+2])<<16|(255&t[o+3])<<24,o+=4;return n-o==3&&(e._data[r]=(255&t[o+2])<<16),n-o==2&&(e._data[r]|=(255&t[o+1])<<8),n-o==1&&(e._data[r]|=255&t[o]),e._version=0,e}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let n=0;n<this._data.length-1;n++)if(this._data[n]!=t._data[n])return!1;for(let n=8*(this._data.length-1);n<this._length;n++)if(this.getBit(n)!=t.getBit(n))return!1;return!0}clone(){const t=new $(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,n){this.setAll(!1,!1);for(let n=0;n<this._length;n++)t(n)&&(this._data[Math.floor(n/32)]|=1<<(n%32&31));return this.incrementVersion(n),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,n=!1){const e=t?-1:0,r=this.lengthInInts;for(let t=0;t<r;t++)this._data[t]=e;this.incrementVersion(n)}setIndexes(t,n=!0,e=!0,r=!0){e&&this.setAll(!n,!1);for(const e of t)this.setFast(e,n);this.incrementVersion(r)}everyIndex(t,n=!0){for(const e of t)if(this.getBit(e)!=n)return!1;return!0}anyIndex(t,n=!0){for(const e of t)if(this.getBit(e)==n)return!0;return!1}setWhere(t,n=!0,e=!0,r=!0,o=!0){if(e&&o&&this.setAll(!n,!1),o)for(let e=0;e<this._length;e++)t(e)&&this.setFast(e,n);else for(let e=0;e<this._length;e++)this.setFast(e,t(e)?n:!n);this.incrementVersion(r)}getRange(t,n){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(n,0,this._length,"to");const e=[];for(let r=t;r<n;++r)e.push(this.getBit(r));return $.fromValues(e)}getRangeAsList(t,n){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(n,0,this._length,"to");const e=[];for(let r=t;r<n;++r)e.push(this.getBit(r));return e}setRange(t,n,e,r=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(n,0,this._length-1,"to");const o=Math.min(t,n),i=Math.max(t,n);if(e)for(let t=o;t<=i;t++)this.setTrue(t);else for(let t=o;t<=i;t++)this.setFalse(t);return this.incrementVersion(r),this}setRandom(t,n,e=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!n),this.setAll(!n);for(let e=0;e<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=n&&(this.setFast(t,n),e++)}this.incrementVersion(e)}and(t,n=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let n=0,e=this.lengthInInts;n<e;n++)this._data[n]&=t._data[n];return this.incrementVersion(n),this}andNot(t,n=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const e=this.lengthInInts;for(let n=0;n<e;n++)this._data[n]&=~t._data[n];return this.incrementVersion(n),this}notAnd(t,n=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let n=0,e=this.lengthInInts;n<e;n++)this._data[n]=~this._data[n]&t._data[n];return this.incrementVersion(n),this}not(t=!0){for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,n=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let n=0,e=this.lengthInInts;n<e;n++)this._data[n]|=t._data[n];return this.incrementVersion(n),this}xor(t,n=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let n=0,e=this.lengthInInts;n<e;n++)this._data[n]^=t._data[n];return this.incrementVersion(n),this}insertAt(t,n,e=!1){if(this.assureInRange(t,0,this._length,"pos"),0==n)return;const r=this._length;this.setLength(this._length+n);for(let e=r-1;e>=t;e--)this.setBit(e+n,this.getBit(e));for(let r=t;r<t+n;r++)this.setBit(r,e)}removeAt(t,n=1){if(n<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-n,"pos"),this.contains(!0))for(let e=t;e<this._length-n;e++)this.setBit(e,this.getBit(e+n));this.setLength(this._length-n)}removeByMask(t,n=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!n)),this.setAll(!n);else{let e=0;for(let r=-1;-1!=(r=t.findNext(r,!n));)this.setFast(e++,this.getBit(r));this._length=e,this._version++}return this}getBit(t){return!!(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,n,e=!0){this.setFast(t,n),this._version++}setFast(t,n){n?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let n=0;for(;n<t-1;n++)for(let t=this._data[n];0!=t;t>>>=8)this._selectedCount+=$._onBitCount[255&t];let e=this._data[n];const r=31&this._length;for(0!=r&&(e&=~(4294967295<<r));0!=e;e>>>=8)this._selectedCount+=$._onBitCount[255&e];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let n=0;if(this.trueCount()==this._length)for(let e=0;e<this._length;e++)n+=t(e)?1:0;else for(let e=-1;-1!=(e=this.findNext(e,!0));)n+=t(e)?1:0;return n}andWithCountBits(t,n){if(0==this._length)return 0;let e=0;const r=this.lengthInInts;let o=0;for(;o<r-1;o++)for(let n=this._data[o]&t._data[o];0!=n;n>>>=8)e+=$._onBitCount[255&n];let i=this._data[o]&t._data[o];const s=31&this._length;for(0!=s&&(i&=~(4294967295<<s));0!=i;i>>>=8)e+=$._onBitCount[255&i];return n?e:this._length-e}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,n=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let e=31&(t=t<0?0:t+1);const r=this.lengthInInts;for(let o=Math.floor(t/32);o<r;o++){let r=n?this._data[o]:~this._data[o];if(0!=e)r&=4294967295<<e&4294967295,e=0;else if(!n&&-4294967296==r)continue;for(let n=0;0!=r;n+=8,r>>>=8){const e=$._firstOnBit[255&r];if(e>=0)return(t=e+32*o+n)>=this._length?-1:t}}return-1}findPrev(t,n=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let e=1+(t=t<0?this._length-1:t-1)&31;for(let r=Math.floor(t/32);r>=0;r--){let t=n?this._data[r]:~this._data[r];0!=e&&(t&=~(4294967295<<e),e=0);for(let n=24;0!=t;n-=8,t<<=8){const e=$._lastOnBit[t>>>24];if(e>=0)return e+32*r+n}}return-1}}function Y(t={}){const n=function(){if(!t||!t.scoringMatrix||!t.alphabetIndexes)return(t,n)=>t===n?0:1;if(t.scoringMatrix.length!==Object.keys(t.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const n=t.alphabetIndexes,e=t.scoringMatrix,r=Math.min(...Object.keys(n).map(t=>t.charCodeAt(0)))+1,o=new Float32Array((e.length+r)*(e.length+r));return Object.entries(n).forEach(([t,r])=>{const i=e[r];Object.entries(n).forEach(([n,r])=>{o[t.charCodeAt(0)*e.length+n.charCodeAt(0)]=i[r]})}),(t,n)=>1-o[t.charCodeAt(0)*e.length+n.charCodeAt(0)]}(),e=t?.threshold??0;return(t,r)=>{let o=0;const i=t.length,s=r.length,a=Math.ceil(Math.max(i,s)*(1-e));i!==s&&(o=Math.abs(i-s));let u=0;for(let e=0;e<Math.min(i,s);e++)if(t[e]!==r[e]&&(u+=n(t[e],r[e]),u>a))return 1;return u+=o,u/=Math.max(i,s),u}}$._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),$._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),$._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7]);const K={gapOpen:1,gapExtend:.6,scoringMatrix:[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]],alphabetIndexes:{A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23}};var j;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(j||(j={}));const z={[j.HAMMING]:Y,[j.LEVENSHTEIN]:function(){return(t,n)=>q(t,n)/Math.max(t.length,n.length)},[j.NEEDLEMANN_WUNSCH]:function(t){const n=new Uint16Array(65536),{gapOpen:e,gapExtend:r,scoringMatrix:o,alphabetIndexes:i}={...K,...t};Object.entries(i).forEach(([t,e])=>n[t.charCodeAt(0)]=e);const s=[new Float32Array(1e4),new Float32Array(1e4)];return(t,i)=>{const a=new Array(t.length+1).fill(!1),u=new Array(t.length+1).fill(!1);let c=0,l=1;for(let n=1;n<t.length+1;n++)s[0][n]=-r-(n-1)*r,s[1][n]=0;s[0][0]=0;for(let f=1;f<i.length+1;f++){s[l][0]=-r-(f-1)*r;for(let h=1;h<t.length+1;h++){const m=s[c][h-1]+o[n[t.charCodeAt(h-1)]][n[i.charCodeAt(f-1)]],d=s[c][h]-(a[h]||1===f||f===i.length?r:e),p=s[l][h-1]-(u[h-1]||1===h||h===t.length?r:e);s[l][h]=Math.max(m,p,d),s[l][h]===m?(a[h]=!1,u[h]=!1):s[l][h]===p?(a[h]=!1,u[h]=!0):(a[h]=!0,u[h]=!1)}c=l,l=(l+1)%2}const f=Math.min(t.length,i.length);return(f-s[c][t.length])/f}},[j.MONOMER_CHEMICAL_DISTANCE]:Y};function X(t,n){const e=t.trueCount()+n.trueCount();if(0==e)return 1;const r=t.andWithCountBits(n,!0);return r/(e-r)}function Q(t){return t<=0?3402823e32:1/t-1}_.Tanimoto,_.Dice,_.Asymmetric,_.BraunBlanquet,_.Cosine,_.Kulczynski,_.McConnaughey,_.RogotGoldberg,_.Russel,_.Sokal,_.Hamming,_.Euclidean,_.Tanimoto,_.Dice,_.Asymmetric,_.BraunBlanquet,_.Cosine,_.Kulczynski,_.McConnaughey,_.RogotGoldberg,_.Russel,_.Sokal,_.Hamming,_.Euclidean,_.Tanimoto,_.Dice,_.Cosine,_.Tanimoto,_.Asymmetric,_.Cosine,_.Sokal,j.HAMMING,j.LEVENSHTEIN,j.MONOMER_CHEMICAL_DISTANCE,j.NEEDLEMANN_WUNSCH;const Z={[C.Euclidean]:function(t,n){let e=0;for(let r=0;r<t.length;r++)e+=Math.pow(t[r]-n[r],2);return Math.sqrt(e)},[C.Manhattan]:function(t,n){let e=0;for(let r=0;r<t.length;r++)e+=Math.abs(t[r]-n[r]);return e},[C.Cosine]:function(t,n){let e=0,r=0,o=0;for(let i=0;i<t.length;i++)e+=t[i]*n[i],r+=t[i]*t[i],o+=n[i]*n[i];return(1-e/(Math.sqrt(r)*Math.sqrt(o)))/2}},J={[A.Levenshtein]:q,[A.JaroWinkler]:W.Vb,[A.Manhattan]:function(t,n){if(t.length!==n.length)return 1;{let e=0;for(let r=1;r<t.length;r++)e+=t[r]==n[r]?0:1;return e/t.length}},[A.Onehot]:function(t,n){return t===n?0:1}},tt={[_.Tanimoto]:function(t,n){return 1-X(t,n)},[_.Dice]:function(t,n){return 1-function(t,n){const e=t.trueCount()+n.trueCount();return 0==e?0:2*t.andWithCountBits(n,!0)/e}(t,n)},[_.Asymmetric]:function(t,n){return 1-function(t,n){const e=Math.min(t.trueCount(),n.trueCount());return 0==e?0:t.andWithCountBits(n,!0)/e}(t,n)},[_.BraunBlanquet]:function(t,n){return Q(function(t,n){const e=Math.max(t.trueCount(),n.trueCount());return 0==e?0:t.andWithCountBits(n,!0)/e}(t,n))},[_.Cosine]:function(t,n){return 1-function(t,n){const e=t.trueCount()*n.trueCount();return 0==e?0:t.andWithCountBits(n,!0)/Math.sqrt(e)}(t,n)},[_.Kulczynski]:function(t,n){return Q(function(t,n){const e=t.trueCount()+n.trueCount(),r=t.trueCount()*n.trueCount();return 0==r?0:t.andWithCountBits(n,!0)*e/(2*r)}(t,n))},[_.McConnaughey]:function(t,n){return Q(function(t,n){const e=t.trueCount()+n.trueCount(),r=t.trueCount()*n.trueCount();return 0==r?0:(t.andWithCountBits(n,!0)*e-r)/r}(t,n))},[_.RogotGoldberg]:function(t,n){return Q(function(t,n){const e=t.andWithCountBits(n,!0),r=t.countBits(!0)+n.countBits(!0),o=t.length,i=o-r+e;return e==o||i==o?1:e/r+i/(2*o-r)}(t,n))},[_.Russel]:function(t,n){return Q(function(t,n){return 0==t.length?0:t.andWithCountBits(n,!0)/t.length}(t,n))},[_.Sokal]:function(t,n){return 1-function(t,n){const e=t.trueCount()+n.trueCount(),r=t.andWithCountBits(n,!0);return r/(2*e-3*r)}(t,n)},[_.Hamming]:function(t,n){return t.trueCount()+n.trueCount()-2*t.andWithCountBits(n,!0)},[_.Euclidean]:function(t,n){return Math.sqrt(t.trueCount()+n.trueCount()-2*t.andWithCountBits(n,!0))}},nt={[N.TanimotoIntArray]:function(t,n){return Q(X(new $(t,32*t.length),new $(n,32*n.length)))}},et={[b.Difference]:function(t){if(t&&null!=t.range&&t.range>0){const n=t.range;return(t,e)=>Math.abs(t-e)/n}return(t,n)=>Math.abs(t-n)}},rt={[S.CommonItems]:function(t){const n=function(t){const n=t?.mostCommon??new Set;return(t,e)=>{const r=t.length,o=e.length;let i=0,s=0,a=0;for(;s<r&&a<o;)t[s]===e[a]?(n?.has(t[s])||++i,++s,++a):t[s]<e[a]?++s:++a;return i}}(t);return(t,e)=>0===e.length||0===t.length?1e4:Math.min(t.length,e.length)/(n(t,e)+1e-4)}},ot={[x.Vector]:{[C.Euclidean]:Z[C.Euclidean],[C.Manhattan]:Z[C.Manhattan],[C.Cosine]:Z[C.Cosine]},[x.String]:{[A.Levenshtein]:J[A.Levenshtein],[A.JaroWinkler]:J[A.JaroWinkler],[A.Manhattan]:J[A.Manhattan],[A.Onehot]:J[A.Onehot]},[x.BitArray]:{[_.Tanimoto]:tt[_.Tanimoto],[_.Dice]:tt[_.Dice],[_.Asymmetric]:tt[_.Asymmetric],[_.BraunBlanquet]:tt[_.BraunBlanquet],[_.Cosine]:tt[_.Cosine],[_.Kulczynski]:tt[_.Kulczynski],[_.McConnaughey]:tt[_.McConnaughey],[_.RogotGoldberg]:tt[_.RogotGoldberg],[_.Russel]:tt[_.Russel],[_.Sokal]:tt[_.Sokal]},[x.MacroMolecule]:{[j.HAMMING]:z[j.HAMMING],[j.LEVENSHTEIN]:z[j.LEVENSHTEIN],[j.NEEDLEMANN_WUNSCH]:z[j.NEEDLEMANN_WUNSCH],[j.MONOMER_CHEMICAL_DISTANCE]:z[j.MONOMER_CHEMICAL_DISTANCE]},[x.Number]:{[b.Difference]:et[b.Difference]},[x.IntArray]:{[N.TanimotoIntArray]:nt[N.TanimotoIntArray]},[x.NumberArray]:{[S.CommonItems]:rt[S.CommonItems]}};Object.keys(ot).reduce((t,n)=>{for(const e of Object.keys(ot[n]))t[e]=n;return t},{});const it=ui,st="bypassLargeDataWarning";var at,ut,ct,lt,ft,ht,mt;e(5540),(ut=at||(at={})).EUCLIDEAN="EUCLIDEAN",ut.MANHATTAN="MANHATTAN",at.EUCLIDEAN,at.MANHATTAN,(lt=ct||(ct={})).HAMMING="Hamming",lt.EUCLIDEAN="Euclidean",lt.VECTOR_COSINE="Vector Cosine",lt.MANHATTAN="Manhattan",lt.TANIMOTO="Tanimoto",lt.LEVENSTEIN="Levenshtein",lt.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",lt.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",lt.SOKAL="Sokal",lt.COSINE="Cosine",lt.ASYMMETRIC="Asymmetric",lt.Difference="Difference",lt.OneHot="One-Hot",ct.HAMMING,ct.EUCLIDEAN,ct.MANHATTAN,ct.VECTOR_COSINE,ct.TANIMOTO,ct.LEVENSTEIN,ct.NEEDLEMAN_WUNSCH,ct.MONOMER_CHEMICAL_DISTANCE,ct.SOKAL,ct.COSINE,ct.ASYMMETRIC,ct.Difference,ct.OneHot,ct.HAMMING,ct.EUCLIDEAN,ct.MANHATTAN,ct.TANIMOTO,ct.SOKAL,ct.COSINE,ct.ASYMMETRIC,ct.LEVENSTEIN,ct.NEEDLEMAN_WUNSCH,ct.MONOMER_CHEMICAL_DISTANCE,ct.Difference,ct.OneHot,ct.VECTOR_COSINE,new Set([ct.HAMMING,ct.LEVENSTEIN,ct.NEEDLEMAN_WUNSCH,ct.MONOMER_CHEMICAL_DISTANCE,ct.OneHot]),new Set([ct.HAMMING,ct.EUCLIDEAN,ct.MANHATTAN,ct.MONOMER_CHEMICAL_DISTANCE,ct.LEVENSTEIN,ct.NEEDLEMAN_WUNSCH,ct.TANIMOTO,ct.COSINE,ct.VECTOR_COSINE,ct.SOKAL,ct.ASYMMETRIC,ct.OneHot,ct.Difference]),new Set([ct.EUCLIDEAN,ct.MANHATTAN,ct.OneHot,ct.Difference,ct.VECTOR_COSINE]),new Set([ct.EUCLIDEAN,ct.MANHATTAN,ct.Difference,ct.VECTOR_COSINE]),new Set([ct.EUCLIDEAN,ct.MANHATTAN,ct.Difference]),new Set([ct.TANIMOTO,ct.COSINE,ct.SOKAL,ct.ASYMMETRIC]),function(t){t.ADD="ADD",t.SUB="SUB",t.MULT="MULT"}(ft||(ft={})),function(t){t.SQUARE="SQUARE",t.INVERSE="INVERSE",t.TRANSPOSE="TRANSPOSE",t.NORM="NORM",t.COLUMN_NORM="COLUMN_NORM"}(ht||(ht={})),function(t){t.SCALARMULT="SCALARMULT",t.SCALARADD="SCALARADD",t.SCALARPOW="SCALARPOW"}(mt||(mt={})),Object.prototype.toString;const dt="dimensionality-reducer-terminate-event";var pt,gt;(gt=pt||(pt={})).EUCLIDEAN="EUCLIDEAN",gt.MANHATTAN="MANHATTAN";const yt=t=>null==t;function vt(t,n){return`${n} (${t.length>4?`${t.length} columns`:t.map(t=>t.name).join(", ")})`}async function wt(r,o,i,s,a,u,c,l=!0,f=!1,h={preprocessingFuncArgs:[]},m={},d=null,p={},g){const y={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(o.length!==s.length||o.length!==u.length||o.length!==a.length||o.length!==h.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const v=l?m.tableView??n.shell.tableView(r.name)??n.shell.addTableView(r):null,w=async()=>{const w=t.TaskBarProgressIndicator.create(`Initializing ${m.scatterPlotName??"dimensionality reduction"} ...`);let E;try{const A=function(t){const n=["Embed_X","Embed_Y"],e=t.columns.names().filter(t=>t.includes(n[0])).length+1;return n.map(t=>`${t}_${e}`)}(r);function C(n,e,s){let a=null,u=null;r.columns.names().includes(A[0])?(a=r.columns.byName(A[0]),u=r.columns.byName(A[1])):(a=r.columns.add(t.Column.float(A[0],r.rowCount)),u=r.columns.add(t.Column.float(A[1],r.rowCount)),l&&!E&&(E=v.scatterPlot({...y,x:A[0],y:A[1],title:m.scatterPlotName??vt(o,i)}))),m["show-scatterplot-progress"]&&(E?.root&&it.setUpdateIndicator(E.root,!1),a.init(t=>s[0]?s[0][t]:void 0),u.init(t=>s[1]?s[1][t]:void 0));const c=n/e*100;w.update(c,`Running ${m.scatterPlotName??"dimensionality reduction"}... ${c.toFixed(0)}%`)}async function _(){r.columns.add(t.Column.float(A[0],r.rowCount)),r.columns.add(t.Column.float(A[1],r.rowCount));let f=null;l&&(E=v.scatterPlot({...y,x:A[0],y:A[1],title:m.scatterPlotName??vt(o,i)}),it.setUpdateIndicator(E.root,!0));const d=n.events.onViewerClosed.subscribe(t=>{const e=t.args.viewer;e?.getOptions()?.look?.title&&E?.getOptions()?.look?.title&&e?.getOptions()?.look?.title===E?.getOptions()?.look?.title&&(n.events.fireCustomEvent(dt,{}),d.unsubscribe(),f?.(),w.close())}),p=new Promise(async(t,l)=>{try{f=t;const l=[];let d=s,p=a,y=c;if(g&&o.every(t=>t.isNumerical)){const t=o.map(t=>t.toList()),n=new Array(r.rowCount).fill(0).map((t,n)=>new Float32Array(o.length));for(let e=0;e<o.length;++e)for(let o=0;o<r.rowCount;++o)n[o][e]=t[e][o];h.distanceFnArgs=[{}],l.push({entries:n,options:{}}),d=[g],p=[1],y="MANHATTAN"}else for(let t=0;t<u.length;++t){const n=u[t];if(h.distanceFnArgs||(h.distanceFnArgs=[]),n){const e=n.inputs[0].name,r=n.inputs[1].name,{entries:i,options:a}=await n.apply({[e]:o[t],[r]:s[t],...h.preprocessingFuncArgs[t]??{}});l.push({entries:i,options:a}),h.distanceFnArgs.push(a)}else{const n=o[t].toList(),e={};l.push({entries:n,options:e}),h.distanceFnArgs.push(e)}}t(await async function(t,r,o,i,s,a,u){let c=await async function(t,r,o,i,s,a,u){if(!a.distanceFnArgs)throw new Error("options.distanceFnArgs must be defined");if(t.length!==r.length||t.length!==a.distanceFnArgs.length||t.length!==i.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise(function(c,l){const f=new Worker(new URL(e.p+e.u(234),e.b));f.postMessage({columnsData:t,distanceMetrics:r,method:o,options:a,weights:i,aggregationMethod:s});const h=n.events.onCustomEvent(dt).subscribe(()=>{try{f?.terminate()}finally{h.unsubscribe()}});f.onmessage=({data:{error:t,embedding:n,epochNum:e,epochsLength:r}})=>{yt(e)||yt(r)?(h.unsubscribe(),t?l(t):c(n),setTimeout(()=>f.terminate(),100)):u&&u(e,r,n)}})}(t,o,r,i,s,a,u);return c=c.map(t=>function(t){const n=t.length;let e=0,r=0;for(let o=0;o<n;++o)e+=t[o],r+=Math.pow(t[o],2);const o=e/n,i=1/Math.sqrt(r/n-Math.pow(o,2));for(let e=0;e<n;++e)t[e]=(t[e]-o)*i;return t}(t)),c}(l.map(t=>t.entries),i,d,p,c,h,m[st]?void 0:C))}catch(t){l(t)}}),_=await p;return w.close(),d.unsubscribe(),_}const N=await _();if(f&&N){const x=t.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const b=await function(t,n,r,o){return i=this,s=void 0,u=function*(){return new Promise(function(i,s){const a=new Worker(new URL(e.p+e.u(682),e.b));a.postMessage({embedX:t,embedY:n,minPts:o,epsilon:r}),a.onmessage=({data:{error:t,clusters:n}})=>{a.terminate(),t?s(t):i(n)}})},new((a=void 0)||(a=Promise))(function(t,n){function e(t){try{o(u.next(t))}catch(t){n(t)}}function r(t){try{o(u.throw(t))}catch(t){n(t)}}function o(n){var o;n.done?t(n.value):(o=n.value,o instanceof a?o:new a(function(t){t(o)})).then(e,r)}o((u=u.apply(i,s||[])).next())});var i,s,a,u}(N[0],N[1],h.dbScanEpsilon??.01,h.dbScanMinPts??4),S=r.columns.getUnusedName("Cluster (DBSCAN)");r.columns.addNewString(S).init(t=>b[t].toString()),E&&(E.props.colorColumnName=S)}catch(T){n.shell.error("Clustering embeddings failed"),console.error(T)}finally{x.close()}}if(N){const I=r.columns.byName(A[0]),M=r.columns.byName(A[1]);if(I.init(t=>N[0][t]),M.init(t=>N[1][t]),d)try{const O=d.inputs[0].name,R=d.inputs[1].name;await d.prepare({[O]:I,[R]:M,...p}).call(!0)}catch(L){n.shell.error("Post-processing failed"),console.error(L)}if(E)return it.setUpdateIndicator(E.root,!1),E.helpUrl="/help/compute/sequence-space",E}}catch(P){n.shell.error("Dimensionality reduction failed"),console.error(P),w.close(),E&&it.setUpdateIndicator(E.root,!1)}};return new Promise(async(t,n)=>{try{if(m.fastRowCount&&r.rowCount>m.fastRowCount&&!m[st])it.dialog().add(it.divText("Analysis might take several minutes. Do you want to continue?")).onOK(async()=>{try{const n=await w();t(n)}catch(t){n(t)}}).onCancel(()=>t(void 0)).show();else{const n=await w();t(n)}}catch(t){n(t)}})}var Et=function(t,n,e,r){return new(e||(e=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(s,a)}u((r=r.apply(t,n||[])).next())})};const At={SUBJ:"subj",STUDY:"study",SITE:"site",AGE:"age",SEX:"sex",RACE:"race",DISEASE:"disease",WEIGHT:"weight",HEIGHT:"height"};function Ct(t,e,r){return Et(this,void 0,void 0,function*(){const o=n.data.demo.demog(100);n.shell.addTableView(o),R(!!(yield wt(o,t.map(t=>o.col(t)),e,r,t.map(()=>1),t.map(()=>{}),"EUCLIDEAN",!0,!0,{preprocessingFuncArgs:t.map(()=>({}))})),!0,"No scatterplot returned");const i=o.columns.names().filter(t=>t.toLowerCase().startsWith("embed"));R(i.length,2,"Wrong number of embeddings added"),R(!!o.columns.names().find(t=>t.toLowerCase().startsWith("cluster")),!0,"No cluster column added");for(const t of i){const n=o.col(t);R(new Array(n.length).fill(null).every((t,e)=>!n.isNone(e)&&!isNaN(n.get(e))),!0,"Embedding column has null-ish values")}yield new Promise(t=>setTimeout(t,500))})}L("Dimensionality reduction: UMAP",()=>{O("Numeric column",()=>Et(void 0,void 0,void 0,function*(){yield Ct([At.AGE],E.UMAP,[b.Difference])}),{timeout:3e4}),O("String column",()=>Et(void 0,void 0,void 0,function*(){yield Ct([At.SEX],E.UMAP,[A.Onehot])}),{timeout:3e4}),O("Numeric and string columns",()=>Et(void 0,void 0,void 0,function*(){yield Ct([At.SEX,At.AGE],E.UMAP,[A.Onehot,b.Difference])})),O("All demog columns",()=>Et(void 0,void 0,void 0,function*(){const e=n.data.demo.demog(10).columns.toList().filter(t=>Object.values(At).includes(t.name)),r=e.map(n=>n.type===t.COLUMN_TYPE.STRING?A.Onehot:b.Difference),o=e.map(t=>t.name);yield Ct(o,E.UMAP,r)}))}),L("Dimensionality reduction: T-SNE",()=>{O("Numeric column",()=>Et(void 0,void 0,void 0,function*(){yield Ct([At.AGE],E.T_SNE,[b.Difference])}),{timeout:3e4}),O("String column",()=>Et(void 0,void 0,void 0,function*(){yield Ct([At.SEX],E.T_SNE,[A.Onehot])}),{timeout:3e4}),O("Numeric and string columns",()=>Et(void 0,void 0,void 0,function*(){yield Ct([At.SEX,At.AGE],E.T_SNE,[A.Onehot,b.Difference])})),O("All demog columns",()=>Et(void 0,void 0,void 0,function*(){const e=n.data.demo.demog(10).columns.toList().filter(t=>Object.values(At).includes(t.name)),r=e.map(n=>n.type===t.COLUMN_TYPE.STRING?A.Onehot:b.Difference),o=e.map(t=>t.name);yield Ct(o,E.T_SNE,r)}))});const _t={i32:"HEAP32",f32:"HEAPF32"},Nt={i32:Int32Array,f32:Float32Array},xt={i32:2,f32:2},bt={i32:DG.Column.fromInt32Array,f32:DG.Column.fromFloat32Array};class St{constructor(t){this.data=t}complementArrOfParams(t){t.push(this.data)}complementArrOfTypes(t){t.push("number")}allocateMemoryForBuffer(t){}isMemoryForBufferAllocated(){return!0}putDataToBuffer(t){}getDataFromBuffer(t){}freeBuffer(t){}}class Tt extends St{constructor(t,n,e=!1){super(t),this.type=n,this.toUpdate=e,this.buf=0,this.numOfRows=t.length}complementArrOfParams(t){t.push(this.buf),t.push(this.numOfRows)}complementArrOfTypes(t){t.push("number"),t.push("number")}allocateMemoryForBuffer(t){this.buf=t._malloc(this.numOfRows*Nt[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const n=this.type,e=xt[n],r=t[_t[n]];let o=null;const i=this.data;o="int"==i.type&&"i32"==n||"double"==i.type&&"f32"==n?i.getRawData():new Nt[n](i.getRawData()),o&&r.set(o,this.buf>>e)}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const n=this.type,e=t[_t[n]],r=this.buf,o=Nt[n].BYTES_PER_ELEMENT,i=this.data.getRawData();for(let t=0;t<this.numOfRows;t++)i[t]=e[r/o+t]}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class It extends Tt{constructor(t,n){super([],t,!0),this.numOfRows=n}putDataToBuffer(t){}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const n=this.type,e=t[_t[n]],r=this.buf,o=bt[n],i=new Nt[n](this.numOfRows);for(let t=0;t<i.length;t++)i[t]=e[r/i.BYTES_PER_ELEMENT+t];this.data=o("name",i)}}}class Mt extends St{constructor(t,n,e=!1){super(t),this.type=n,this.toUpdate=e,this.buf=0,this.numOfColumns=t.length,this.numOfRows=t[0].length}complementArrOfParams(t){t.push(this.buf),t.push(this.numOfRows),t.push(this.numOfColumns)}complementArrOfTypes(t){t.push("number"),t.push("number"),t.push("number")}allocateMemoryForBuffer(t){this.buf=t._malloc(this.numOfRows*this.numOfColumns*Nt[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const n=this.type,e=xt[n],r=t[_t[n]],o=Nt[n].BYTES_PER_ELEMENT;for(let t=0;t<this.numOfColumns;t++){let i=null;const s=this.data[t];i="int"==s.type&&"i32"==n||"double"==s.type&&"f32"==n?s.getRawData():new Nt[n](s.getRawData()),null!=i&&r.set(i,this.buf+t*this.numOfRows*o>>e)}}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const n=this.type,e=t[_t[n]],r=this.numOfRows,o=this.numOfColumns,i=new Nt[n](e.buffer,this.buf,r*o);for(let t=0;t<o;t++){const n=this.data[t].getRawData();for(let e=0;e<r;e++)n[e]=i[e+t*r]}}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class Ot extends Mt{constructor(t,n,e){super([[]],t,!0),this.data=[],this.numOfColumns=e,this.numOfRows=n}putDataToBuffer(t){}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const n=this.type,e=t[_t[n]],r=this.numOfRows,o=this.numOfColumns,i=Nt[n].BYTES_PER_ELEMENT,s=bt[n],a=this.buf;for(let t=0;t<o;t++){const o=new Nt[n](r);for(let n=0;n<r;n++)o[n]=e[a/i+n+t*r];this.data.push(s((t+1).toString(),o))}}}}const Rt={intColumn:t=>new Tt(t,"i32"),newIntColumn:t=>new It("i32",t),intColumns:t=>new Mt(t.toList(),"i32"),newIntColumns:(t,n)=>new Ot("i32",t,n),floatColumn:t=>new Tt(t,"f32"),newFloatColumn:t=>new It("f32",t),floatColumns:t=>new Mt(t.toList(),"f32"),newFloatColumns:(t,n)=>new Ot("f32",t,n),int:t=>new St(t),num:t=>new St(t)},Lt={tableFromColumns:t=>DG.DataFrame.fromColumns(t.data),num:t=>t,int:t=>t,double:t=>t,column:t=>t.data};function Pt(t,n,e){const r=t[n],o=r.arguments,i=[];let s=0;for(const t in o){const n=o[t];if("_callResult"!=t){switch(n.type){case"floatColumns":case"int":case"num":case"floatColumn":case"intColumn":case"intColumns":n.data=Rt[n.type](e[s]),s++;break;case"newFloatColumns":case"newIntColumns":const t=o[n.numOfRows.ref].data[n.numOfRows.value],r=o[n.numOfColumns.ref].data[n.numOfColumns.value];n.data=Rt[n.type](t,r);break;case"newFloatColumn":case"newIntColumn":const i=o[n.numOfRows.ref].data[n.numOfRows.value];n.data=Rt[n.type](i)}i.push(o[t].data)}}const a=function(t,n,e,r){let o;for(const n of r)n.allocateMemoryForBuffer(t);let i=!0;for(const t of r)i&=t.isMemoryForBufferAllocated();if(i){const e=[],i=[];for(const n of r)n.complementArrOfParams(e),n.complementArrOfTypes(i),n.putDataToBuffer(t);const s="number";o=t.ccall(n,s,i,e);for(const n of r)n.getDataFromBuffer(t)}for(const n of r)n.freeBuffer(t);if(null!=o)return o}(t,n,0,i);o._callResult=Rt.num(a);const u=r.output;if("objects"!=u.type)return Lt[u.type](o[u.source].data);const c=[];for(const t of u.source)c.push(o[t].data.data);return c}const Dt="num",Ft="floatColumn",Ut="intColumn",Bt="floatColumns",kt="newFloatColumns",Ht="intColumns",Gt="newIntColumns",Vt="newFloatColumn",qt="newIntColumn",Wt="numOfRows",$t="numOfColumns",Yt="ref",Kt="value",jt="int",zt="double",Xt={intColumn:Int32Array,floatColumn:Float32Array,floatColumns:Float32Array,newFloatColumns:Float32Array,intColumns:Int32Array,newIntColumns:Int32Array,newFloatColumn:Float32Array,newIntColumn:Int32Array};function Qt(t,n){let e,r=[],o=0;for(const i in t){const s=t[i],a=s.type;if("_callResult"!==i){switch(a){case Dt:case jt:case zt:s.data=n[o],o++;break;case Ut:case Ft:let r;const i=n[o],u=i.length;r=i.type===jt&&a===Ut||i.type===zt&&a===Ft?i.getRawData().slice(0,u):new Xt[a](i.getRawData().slice(0,u)),s.data={array:r,numOfRows:u},o++;break;case qt:case Vt:let c=0;e=s[Wt][Yt],c=t[e].type===Dt?t[e].data:t[e].data[s[Wt][Kt]],s.data={numOfRows:c},o++;break;case Ht:case Bt:let l=[];const f=n[o].byIndex(0).length;for(const t of n[o].toList())t.type===jt&&a===Ut||t.type===zt&&a===Ft?l.push(t.getRawData().slice(0,f)):l.push(new Xt[a](t.getRawData().slice(0,f)));s.data={arrays:l,numOfRows:f,numOfColumns:l.length},o++;break;case Gt:case kt:let h=0,m=0;e=s[Wt][Yt],h=t[e].type===Dt?t[e].data:t[e].data[s[Wt][Kt]],e=s[$t][Yt],m=t[e].type===Dt?t[e].data:t[e].data[s[$t][Kt]],s.data={numOfRows:h,numOfColumns:m},o++;break;default:return}r.push(s)}}return r}function Zt(t,n){t.arguments._callResult=n.callResult,function(t,n){const e={newFloatColumns:DG.Column.fromFloat32Array,newIntColumns:DG.Column.fromInt32Array,newFloatColumn:DG.Column.fromFloat32Array,newIntColumn:DG.Column.fromInt32Array};let r=0;for(const o in t){const i=t[o];switch(i.type){case Dt:case jt:case zt:case Ut:case Ft:case Bt:case Ht:break;case Vt:case qt:let t;null==i.name?t=(0).toString():a=i.name,i.column=e[i.type](t,n[r].array);break;case Gt:case kt:let o=[],s=n[r].arrays.length,a=[];if(null==i.names)for(let t=1;t<=s;t++)a.push(t.toString());else a=i.names;for(let t=0;t<s;t++)o.push(e[i.type](a[t],n[r].arrays[t]));i.columns=o}r++}}(t.arguments,n.args);let e=function(t){let n=t.output;const e={newFloatColumns:"columns",newIntColumns:"columns",newFloatColumn:"column",newIntColumn:"column"};switch(n.type){case Dt:case jt:case zt:return t.arguments[n.source];case"column":return t.arguments[n.source].column;case"tableFromColumns":return DG.DataFrame.fromColumns(t.arguments[n.source].columns);case"objects":let r=[];for(let o of n.source){let n=t.arguments[o];r.push(n[e[n.type]])}return r}}(t);return function(t){for(const n in t){const e=t[n];switch(e.type){case Dt:case jt:case zt:case Ut:case Ft:case Ht:case Bt:break;case qt:case Vt:e.column=null;break;case Gt:case kt:e.columns=null}}}(t.arguments),e}async function Jt(t,n,r){return new Promise((t,o)=>{const i=new Worker(new URL(e.p+e.u(128),e.b));i.postMessage(Qt(EDA.principalComponentAnalysisNipals.arguments,[n,r])),i.onmessage=function(n){i.terminate(),t(Zt(EDA.principalComponentAnalysisNipals,n.data))}})}const tn=1e-6;function nn(n){if(n.type!=t.COLUMN_TYPE.FLOAT&&n.type!=t.COLUMN_TYPE.INT)throw new Error("unsupported column type: "+n.type)}function en(t){if(t.stats.missingValueCount>0)throw new Error(`The column '${t.name}' has missing values.`)}function rn(t,n){if(function(t,n){if(n<1)throw new Error("components must be positive.");if(n>t.length)throw new Error("components must not be greater than features count.");for(const n of t)nn(n),en(n)}(t,n),t.length*t.byIndex(0).length>1e8)throw new Error("dataframe is too big.")}function on(t,n,e){return n?e?function(t){const n=t.rowCount;for(const e of t.columns)if(e.isNumerical){const t=e.stats.stdev,r=e.stats.avg,o=e.getRawData();if(t>0)for(let e=0;e<n;++e)o[e]=(o[e]-r)/t;else for(let t=0;t<n;++t)o[t]-=r}return t}(t):function(t){const n=t.rowCount;for(const e of t.columns)if(e.isNumerical){const t=e.stats.avg;if(Math.abs(t)>tn){const r=e.getRawData();for(let e=0;e<n;++e)r[e]-=t}}return t}(t):e?function(t){const n=t.rowCount;for(const e of t.columns)if(e.isNumerical){const t=e.stats.stdev;if(Math.abs(t-1)>tn&&t>0){const r=e.getRawData();for(let e=0;e<n;++e)r[e]/=t}}return t}(t):t}var sn,an,un,cn,ln,fn,hn,mn,dn,pn,gn,yn,vn,wn,En;function An(n,r,o,i,s){return a=this,u=void 0,l=function*(){rn(r,o);const a=n.rowCount,u=function(n){const e=[];for(const t of n)t.stats.stdev>0&&t.stats.missingValueCount<1&&e.push(t);return t.DataFrame.fromColumns(e)}(r),c=u.columns.length;if(0===c){const n=[];for(let e=0;e<o;++e)n.push(t.Column.fromFloat32Array(`${e+1}`,new Float32Array(a).fill(0)));return t.DataFrame.fromColumns(n)}const l=c<o?o-c:0,f=Math.min(o,c);let h;if(c>900)h=yield Jt(0,r,f);else{const t=yield async function(t,n,r){return new Promise((t,o)=>{const i=new Worker(new URL(e.p+e.u(860),e.b));i.postMessage(Qt(EDA.principalComponentAnalysis.arguments,[n,r,1,0])),i.onmessage=function(n){i.terminate(),0===n.data.callResult?t(Zt(EDA.principalComponentAnalysis,n.data)):t(-1)}})}(0,r,f);h=-1!==t?on(t,i,s):yield Jt(0,r,f)}if(void 0===h)throw new Error("Failed to compute PCA");h=on(h,i,s);const m=h.columns,d=m.length;for(let n=0;n<l;++n)m.add(t.Column.fromFloat32Array(`${d+n+1}`,new Float32Array(a).fill(0)));return h},new((c=void 0)||(c=Promise))(function(t,n){function e(t){try{o(l.next(t))}catch(t){n(t)}}function r(t){try{o(l.throw(t))}catch(t){n(t)}}function o(n){var o;n.done?t(n.value):(o=n.value,o instanceof c?o:new c(function(t){t(o)})).then(e,r)}o((l=l.apply(a,u||[])).next())});var a,u,c,l}(En=sn||(sn={}))[En.COMPUTE_COMPONENTS=0]="COMPUTE_COMPONENTS",En[En.PERFORM_MVA=1]="PERFORM_MVA",En[En.DEMO=2]="DEMO",(wn=an||(an={})).NO_DF="No dataframe is opened",wn.NO_COLS="No numeric columns without missing values",wn.ONE_COL="No columns to be used as features (just one numeric columns without missing values)",wn.EMPTY_DF="Dataframe is empty",wn.PREDICT="Predictors must not contain a response variable",wn.ENOUGH="Not enough of features",wn.COMP_LIN_PLS="Components count must be less than the number of features",wn.COMP_QUA_PLS="Too large components count for the quadratic PLS regression",wn.COMPONENTS="Components count must be greater than 1",wn.INV_INP="Invalid inputs",(vn=un||(un={})).PREDICT="Predict",vn.USING="Using",vn.COMPONENTS="Components",vn.PLS="PLS",vn.MVA="Multivariate Analysis (PLS)",vn.RUN="RUN",vn.NAMES="Names",vn.MODEL="Observed vs. Predicted",vn.FEATURE="Feature",vn.REGR_COEFS="Regression Coefficients",vn.XLOADING="x.loading.p",vn.LOADINGS="Loadings",vn.XSCORE="x.score.t",vn.YSCORE="y.score.u",vn.SCORES="Scores",vn.EXPL_VAR="Explained Variance",vn.EXPLORE="Explore",vn.FEATURES="Feature names",vn.BROWSE="Browse",vn.ANALYSIS="Features Analysis",vn.QUADRATIC="Quadratic",(yn=cn||(cn={})).PREDICT="Column with the response variable",yn.FEATURES="Predictors (features)",yn.COMPONENTS="Number of PLS components",yn.PLS="Compute PLS components",yn.MVA="Perform multivariate analysis",yn.NAMES="Names of data samples",yn.QUADRATIC="Specifies whether to include squared terms as additional predictors in the PLS model",(gn=ln||(ln={})).PLS="/help/explore/multivariate-analysis#pls-components",gn.MVA="/help/explore/multivariate-analysis",gn.MODEL="/help/explore/multivariate-analysis#observed-vs-predicted",gn.COEFFS="/help/explore/multivariate-analysis#regression-coefficients",gn.LOADINGS="/help/explore/multivariate-analysis#loadings",gn.EXPL_VARS="/help/explore/multivariate-analysis#explained-variance",gn.SCORES="/help/explore/multivariate-analysis#scores",(pn=fn||(fn={}))[pn.DEFAULT=3]="DEFAULT",pn[pn.MIN=1]="MIN",(dn=hn||(hn={})).PREFIX="PLS",dn.SUFFIX="(predicted)",dn.COMP="component",dn.COMPS="components",function(t){t[t.PREDICTION=0]="PREDICTION",t[t.REGR_COEFFS=1]="REGR_COEFFS",t[t.T_SCORES=2]="T_SCORES",t[t.U_SCORES=3]="U_SCORES",t[t.X_LOADINGS=4]="X_LOADINGS",t[t.Y_LOADINGS=5]="Y_LOADINGS"}(mn||(mn={}));const Cn=[.49,.79,.99];var _n,Nn;(Nn=_n||(_n={})).AXIS="#838383",Nn.CIRCLE="#0000FF",Nn.INVALID="#EB6767",Nn.VALID_TEXT="#4d5261",Nn.VALID_LINE="#dbdcdf",[{caption:un.MODEL,text:"Closer to the line means better price prediction."},{caption:un.SCORES,text:"The latent factor values for each sample reflect the similarities and dissimilarities among observations."},{caption:un.LOADINGS,text:"The impact of each feature on the latent factors: higher loading means stronger influence."},{caption:un.REGR_COEFS,text:"Parameters of the obtained model: features make different contribution to the prediction."},{caption:un.EXPL_VAR,text:"How well the latent components fit source data: closer to one means better fit."}].map(t=>`# ${t.caption}\n\n${t.text}`).join("\n\n"),ln.MVA;function xn(t){return n=this,r=void 0,i=function*(){rn(t.features,t.components),nn(t.predict),en(t.predict);const n=yield async function(t,n,r,o){return new Promise((t,i)=>{const s=new Worker(new URL(e.p+e.u(412),e.b));s.postMessage(Qt(EDA.partialLeastSquareRegression.arguments,[n,r,o])),s.onmessage=function(n){s.terminate(),t(Zt(EDA.partialLeastSquareRegression,n.data))}})}(t.table,t.features,t.predict,t.components);return{prediction:n[mn.PREDICTION],regressionCoefficients:n[mn.REGR_COEFFS],tScores:n[mn.T_SCORES],uScores:n[mn.U_SCORES],xLoadings:n[mn.X_LOADINGS],yLoadings:n[mn.Y_LOADINGS]}},new((o=void 0)||(o=Promise))(function(t,e){function s(t){try{u(i.next(t))}catch(t){e(t)}}function a(t){try{u(i.throw(t))}catch(t){e(t)}}function u(n){var e;n.done?t(n.value):(e=n.value,e instanceof o?e:new o(function(t){t(e)})).then(s,a)}u((i=i.apply(n,r||[])).next())});var n,r,o,i}Math.min,Math.max;var bn=function(t,n,e,r){return new(e||(e=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(s,a)}u((r=r.apply(t,n||[])).next())})};function Sn(n,e){return bn(this,void 0,void 0,function*(){const r=n.length,o=e.length,i=e.stats.avg,s=e.stats.stdev,a=new Float32Array(r+1).fill(0);if(a[r]=i,0===s||1===o)return a;try{const o=[],u=[],c=new Float32Array(r),l=new Float32Array(r);let f=0,h=0;for(const t of n){const n=t.stats;n.stdev>0&&(o.push(f),u.push(t),c[h]=n.avg,l[h]=n.stdev,++h),++f}if(0===h)return a;const m=function(t,n,e,r,o,i,s){return Pt(EDA,"fitLinearRegressionParamsWithDataNormalizing",[t,n,e,r,o,i,s])}(t.DataFrame.fromColumns(u).columns,t.Column.fromFloat32Array("xAvgs",c,h),t.Column.fromFloat32Array("xStdevs",l,h),e,i,s,h+1).getRawData();for(let t=0;t<h;++t)a[o[t]]=m[t];a[r]=m[h]}catch(o){const i=yield function(n,e,r){return bn(this,void 0,void 0,function*(){return(yield xn({table:t.DataFrame.fromColumns([e]),features:n,predict:e,components:r,names:void 0,isQuadratic:!1})).regressionCoefficients.getRawData()})}(n,e,In(n.length,e.length));let s=0;for(let t=0;t<r;++t)a[t]=i[t],s+=i[t]*n.byIndex(t).stats.avg;a[r]-=s}return a})}function Tn(n,e){const r=n.length;if(r!==e.length-1)throw new Error("Incorrect parameters count");const o=n.byIndex(0),i=o.length,s=new Float32Array(i);let a=o.getRawData();const u=e[r];let c=e[0];for(let t=0;t<i;++t)s[t]=u+c*a[t];for(let t=1;t<r;++t){a=n.byIndex(t).getRawData(),c=e[t];for(let t=0;t<i;++t)s[t]+=c*a[t]}return t.Column.fromFloat32Array(n.getUnusedName("prediction"),s,i)}const In=(t,n)=>n<=t?Math.min(10,n):Math.min(10,t);var Mn;!function(t){t[t.MAX_SAMLPES=1e5]="MAX_SAMLPES",t[t.MAX_FEATURES=1e3]="MAX_FEATURES"}(Mn||(Mn={}));class On{static isApplicable(t,n){for(const n of t)if(!n.matches("numerical"))return!1;return!!n.matches("numerical")}static isInteractive(t,n){return t.length<=Mn.MAX_FEATURES&&n.length<=Mn.MAX_SAMLPES}constructor(n){if(this.specn=null,n)try{const e=new Uint32Array(n.buffer,0,2),r=e[0],o=e[1],i=new Uint8Array(n.buffer,8,r),s=t.DataFrame.fromByteArray(i),a=s.rowCount,u=s.columns,c=u.length,l=new Uint8Array(n.buffer,8+r,o),f=t.DataFrame.fromByteArray(l);if(c<3)throw new Error("incorrect columns count");const h=u.byName(un.FEATURES).toList(),m=new Float32Array(a);m.set(u.byName(un.REGR_COEFS).getRawData());const d=c-2,p=new Array(d);for(let t=0;t<d;++t)p[t]=new Float32Array(a),p[t].set(u.byIndex(t+2).getRawData());this.specn={params:m,loadings:p,names:h,dim:a-1,components:c-2,scores:f}}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(n,e,r){return o=this,i=void 0,a=function*(){const o=yield xn({table:t.DataFrame.fromColumns([e]),features:n,predict:e,components:r,names:void 0,isQuadratic:!1}),i=n.names();i.push("_");const s=this.getRegrCoeffs(n,e,o.regressionCoefficients),a=this.getLoadings(r,o.xLoadings);this.specn={names:i,params:s,loadings:a,components:r,dim:n.length,scores:this.getScoresDf(o)},this.computeExplVars(e.length,r,o.yLoadings)},new((s=void 0)||(s=Promise))(function(t,n){function e(t){try{u(a.next(t))}catch(t){n(t)}}function r(t){try{u(a.throw(t))}catch(t){n(t)}}function u(n){var o;n.done?t(n.value):(o=n.value,o instanceof s?o:new s(function(t){t(o)})).then(e,r)}u((a=a.apply(o,i||[])).next())});var o,i,s,a}getLoadings(t,n){const e=Array(t),r=n[0].length+1;for(let o=0;o<t;++o)e[o]=new Float32Array(r),e[o].set(n[o].getRawData());return e}getRegrCoeffs(t,n,e){const r=t.length,o=new Float32Array(r+1),i=e.getRawData();let s=0;for(let n=0;n<r;++n)o[n]=i[n],s+=i[n]*t.byIndex(n).stats.avg;return o[r]=n.stats.avg-s,o}computeExplVars(t,n,e){if(null===this.specn)throw new Error("Failed to compute explained variances");const r=e.getRawData(),o=this.specn.loadings[0].length-1;let i=Math.pow(r[0],2)/t;this.specn.loadings[0][o]=i;for(let e=1;e<n;++e)i+=Math.pow(r[e],2)/t,this.specn.loadings[e][o]=i}toBytes(){if(null===this.specn)throw new Error("Failed to pack untrained model");const n=t.DataFrame.fromColumns([t.Column.fromStrings(un.FEATURES,this.specn.names),t.Column.fromFloat32Array(un.REGR_COEFS,this.specn.params)]);this.specn.loadings.forEach((e,r)=>n.columns.add(t.Column.fromFloat32Array(`${un.XLOADING}${r+1}`,e)));const e=n.toByteArray(),r=e.length,o=this.specn.scores.toByteArray(),i=o.length,s=r+i+8,a=new Uint8Array(64*(Math.ceil(s/64)+1)),u=new Uint32Array(a.buffer,0,2);return u[0]=r,u[1]=i,a.set(e,8),a.set(o,8+r),a}predict(t){if(null===this.specn)throw new Error("Predicting failed: model is not trained");return Tn(t,this.specn.params)}loadingsParamsViewers(){if(null===this.specn)throw new Error("Failed to create loadings and parameters viewers: untrained model");const n=[],e=this.specn.dim,r=t.DataFrame.fromColumns([t.Column.fromStrings(un.FEATURES,this.specn.names.slice(0,-1)),t.Column.fromFloat32Array(un.REGR_COEFS,this.specn.params,e)]),o=r.columns,i=o.length,s=this.specn.components;return this.specn.loadings.forEach((n,o)=>r.columns.add(t.Column.fromFloat32Array(`${un.XLOADING}${o+1}`,n,e))),n.push(t.Viewer.scatterPlot(r,{title:un.LOADINGS,xColumnName:o.byIndex(i).name,yColumnName:o.byIndex(i+(s>1?1:0)).name,markerType:t.MARKER_TYPE.CIRCLE,labelFormColumnNames:[un.FEATURES],help:ln.LOADINGS})),n.push(t.Viewer.barChart(r,{title:un.REGR_COEFS,splitColumnName:un.FEATURES,valueColumnName:un.REGR_COEFS,valueAggrType:t.AGG.AVG,help:ln.COEFFS,showValueSelector:!1,showStackSelector:!1})),n}explVarsViewer(){if(null===this.specn)throw new Error("Failed to create exaplained variances viewer: untrained model");const n=this.specn.components,e=this.specn.dim,r=new Array(n),o=new Float32Array(n);r[0]=`${hn.COMP} 1`,o[0]=this.specn.loadings[0][e];for(let t=1;t<n;++t)r[t]=`${hn.COMPS} ${t+1}`,o[t]=this.specn.loadings[t][e];return t.Viewer.barChart(t.DataFrame.fromColumns([t.Column.fromStrings(hn.COMPS,r),t.Column.fromFloat32Array(un.EXPL_VAR,o)]),{title:un.EXPL_VAR,splitColumnName:hn.COMPS,valueColumnName:un.EXPL_VAR,valueAggrType:t.AGG.AVG,help:ln.EXPL_VARS,showCategorySelector:!1,showStackSelector:!1,showValueSelector:!1})}viewers(){if(null===this.specn)throw new Error("Failed to create viewers: untrained model");const t=this.loadingsParamsViewers();return t.push(this.explVarsViewer(),this.getScoresScatter()),t}getScoresDf(n){const e=n.tScores,r=n.uScores;return e.forEach((t,n)=>t.name=`${un.XSCORE}${n+1}`),r.forEach((t,n)=>t.name=`${un.YSCORE}${n+1}`),t.DataFrame.fromColumns(e.concat(r))}getScoresScatter(){if(null===this.specn)throw new Error("Failed to create scores scatter: untrained model");const n=this.specn.scores.columns.names(),e=t.Viewer.scatterPlot(this.specn.scores,{title:un.SCORES,xColumnName:n[0],yColumnName:n[1],markerType:t.MARKER_TYPE.CIRCLE,help:ln.SCORES,showViewerFormulaLines:!0});return e.meta.formulaLines.addAll(function(t){const n=[],e=(t,e)=>{n.push({type:"line",formula:t,width:1,visible:!0,title:" ",min:-e,max:e,color:_n.CIRCLE})};return t.forEach(r=>{const o="${"+r+"}";n.push({type:"line",formula:`${o} = 0`,width:1,visible:!0,title:" ",color:_n.AXIS}),t.forEach(t=>{const n="${"+t+"}";Cn.forEach(t=>{e(n+` = sqrt(${t*t} - ${o} * ${o})`,t),e(n+` = -sqrt(${t*t} - ${o} * ${o})`,t)})})}),n}(n)),e}}const Rn=["Alpha","Beta","Gamma","Delta"];function Ln(t,n){if(t.length!==n.length)throw new Error(`Non-equal elements count: ${t.length} vs. ${n.length}`)}function Pn(e,r,o){const i=n.data.demo.randomWalk(e,r),s=i.columns,a=new Float32Array(r),u=new Array(r);for(let t=0;t<r;++t)u[t]=s.byIndex(t).getRawData();for(let n=0;n<o;++n){const o=new Float32Array(e);for(let t=0;t<r;++t)a[t]=Math.random();for(let t=0;t<e;++t)for(let n=0;n<r;++n)o[t]+=a[n]*u[n][t];s.add(t.Column.fromFloat32Array(`y${n}`,o))}return i}function Dn(t,n){Ln(t,n);let e=0;const r=t.length,o=t.getRawData(),i=n.getRawData();for(let t=0;t<r;++t)e=Math.max(e,Math.abs(o[t]-i[t]));return e}function Fn(n,e,r){const o=new Array(n),i=new Array(e);for(let t=0;t<e;++t){const e=new Float32Array(n);for(let t=0;t<n;++t)e[t]=Math.random();i[t]=e}const s=t.DataFrame.fromColumns(i.map((n,e)=>t.Column.fromFloat32Array(`#${e}`,n)));for(let t=0;t<n;++t)o[t]=i.slice(0,2).map(n=>n[t]>.5?"A":"B").join("");if(s.columns.add(t.Column.fromStrings("Labels",o)),r)for(let t=0;t<e;++t)for(let e=0;e<n;++e)i[t][e]+=1*(i[t][e]>0?1:-1);return s}function Un(t,n){Ln(t,n);let e=0;const r=t.length;if(r<1)return 1;for(let o=0;o<r;++o)t.get(o)===n.get(o)&&++e;return e/r}var Bn=function(t,n,e,r){return new(e||(e=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(s,a)}u((r=r.apply(t,n||[])).next())})};const kn=100,Hn=9e3,Gn=.1;L("Principal component analysis",()=>{O("Performance: 100K rows, 100 cols, 3 components",()=>Bn(void 0,void 0,void 0,function*(){const t=n.data.demo.randomWalk(1e5,kn);yield An(t,t.columns,3,!1,!1)}),{timeout:Hn,benchmark:!0}),O("Performance: 1K rows, 5K cols, 3 components",()=>Bn(void 0,void 0,void 0,function*(){const t=n.data.demo.randomWalk(1e3,5e3);yield An(t,t.columns,3,!1,!1)}),{timeout:Hn,benchmark:!0}),O("Correctness",()=>Bn(void 0,void 0,void 0,function*(){const t=Pn(100,3,5);R(function(t){let n=0;const e=t.length,r=t.getRawData();for(let t=0;t<e;++t)n=Math.max(n,Math.abs(r[t]));return n}((yield An(t,t.columns,4,!1,!1)).columns.byIndex(3))<Gn,!0,"Incorrect PCA computations")}),{timeout:Hn})}),L("Partial least squares regression",()=>{O("Performance: 100K rows, 100 cols, 3 components",()=>Bn(void 0,void 0,void 0,function*(){const t=n.data.demo.randomWalk(1e5,kn),e=t.columns;yield xn({table:t,features:e,predict:e.byIndex(99),components:3,names:void 0,isQuadratic:!1})}),{timeout:Hn,benchmark:!0}),O("Correctness",()=>Bn(void 0,void 0,void 0,function*(){const t=Pn(100,3,5),n=t.columns,e=n.byIndex(7),r=Dn(e,(yield xn({table:t,features:n,predict:e,components:3,isQuadratic:!1,names:void 0})).prediction);R(r<Gn,!0,`Incorrect PLS computations, error is too big: ${r}; expected: < 0.1`)}),{timeout:Hn}),O("Predictive modeling: 100K samples, 100 features, 3 components",()=>Bn(void 0,void 0,void 0,function*(){const t=Pn(1e5,3,98).columns,n=t.byIndex(kn);t.remove(n.name);const e=new On;yield e.fit(t,n,3);const r=e.toBytes(),o=Dn(n,new On(r).predict(t));R(o<Gn,!0,`Incorrect PLS (ML) computations, error is too big: ${o}; expected: < 0.1`)}),{timeout:Hn,benchmark:!0})}),L("Linear regression",()=>{O("Performance: 100K samples, 100 features",()=>Bn(void 0,void 0,void 0,function*(){const t=Pn(1e5,kn,1).columns,n=t.byIndex(kn),e=yield Sn(t,n),r=new Uint8Array(e.buffer);Tn(t,new Float32Array(r.buffer))}),{timeout:Hn,benchmark:!0}),O("Correctness",()=>Bn(void 0,void 0,void 0,function*(){const t=Pn(100,2,1).columns,n=t.byIndex(2),e=yield Sn(t,n),r=new Uint8Array(e.buffer),o=Tn(t,new Float32Array(r.buffer)),i=Dn(o,o);R(i<Gn,!0,`Incorrect linear regression computations, error is too big: ${i}; expected: < 0.1`)}),{timeout:Hn})});var Vn=function(t,n,e,r){return new(e||(e=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(s,a)}u((r=r.apply(t,n||[])).next())})};const qn="Avg-s",Wn="Stddev-s";var $n;!function(t){t[t.MAX_SAMLPES=5e4]="MAX_SAMLPES",t[t.MAX_FEATURES=100]="MAX_FEATURES"}($n||($n={}));class Yn{static isApplicable(n,e){for(const t of n)if(!t.matches("numerical"))return!1;return e.type===t.COLUMN_TYPE.STRING}static isInteractive(t,n){return t.length<=$n.MAX_FEATURES&&n.length<=$n.MAX_SAMLPES}constructor(n,e){if(this.params=void 0,this.classesCount=1,this.featuresCount=1,void 0!==n){const t=n.featuresCount,e=n.classesCount;if(t<1)throw new Error("Incorrect features count");if(e<1)throw new Error("Incorrect classes count");const r=t+1;this.avgs=new Float32Array(r),this.stdevs=new Float32Array(r),this.categories=new Array(r),this.featuresCount=t,this.classesCount=e}else{if(void 0===e)throw new Error("Softmax classifier not initialized");try{const n=new Uint32Array(e.buffer,0,1)[0],r=new Uint8Array(e.buffer,4,n),o=t.DataFrame.fromByteArray(r),i=o.columns,s=i.length;if(s<3)throw new Error("incorrect columns count");this.classesCount=s-2,this.featuresCount=o.rowCount-1;const a=this.classesCount;this.params=new Array(a),this.categories=new Array(o.rowCount);for(let n=0;n<a;++n){const e=i.byIndex(n);if(this.categories[n]=e.name,e.type!==t.COLUMN_TYPE.FLOAT)throw new Error(`Incorrect input column type. Expected: float, passed: ${e.type}`);this.params[n]=e.getRawData()}const u=i.byName(qn);if(u.type!==t.COLUMN_TYPE.FLOAT)throw new Error("incorrect average values column type");this.avgs=u.getRawData();const c=i.byName(Wn);if(c.type!==t.COLUMN_TYPE.FLOAT)throw new Error("incorrect standard deviations column type");this.stdevs=c.getRawData()}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}}toBytes(){if(void 0===this.params)throw new Error("Non-trained model");const n=this.classesCount,e=new Array(n+2);for(let r=0;r<n;++r)e[r]=t.Column.fromFloat32Array(this.categories[r],this.params[r]);e[n]=t.Column.fromFloat32Array(qn,this.avgs),e[n+1]=t.Column.fromFloat32Array(Wn,this.stdevs);const r=t.DataFrame.fromColumns(e).toByteArray(),o=r.length,i=new Uint8Array(o+4);return new Uint32Array(i.buffer,0,1)[0]=o,i.set(r,4),i}fit(n,e){return Vn(this,arguments,void 0,function*(n,e,r=1,o=100,i=.1,s=.001){if(n.length!==this.featuresCount)throw new Error("Training failes - incorrect features count");if(r<=0||o<1||i<=0||s<=0)throw new Error("Training failes - incorrect fitting hyperparameters");this.extractStats(n);const a=e.length,u=e.categories.length,c=e.categories;for(let t=0;t<u;++t)this.categories[t]=c[t];try{const c=function(t,n,e,r,o,i,s,a,u,c,l){return Pt(EDA,"fitSoftmax",[t,n,e,r,o,i,s,a,u,c,l])}(n,t.Column.fromFloat32Array("avgs",this.avgs,this.featuresCount),t.Column.fromFloat32Array("stdevs",this.stdevs,this.featuresCount),t.Column.fromInt32Array("targets",e.getRawData(),a),u,o,r,i,s,this.featuresCount+1,u).columns;this.params=new Array(u);for(let t=0;t<u;++t)this.params[t]=c.byIndex(t).getRawData()}catch(t){try{this.params=yield this.fitSoftmaxParams(n,e,o,r,i,s)}catch(t){throw new Error("Training failes")}}if(void 0===this.params)throw new Error("Training failes")})}extractStats(n){let e=0;for(const r of n){if(r.type!==t.COLUMN_TYPE.INT&&r.type!==t.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");this.avgs[e]=r.stats.avg,this.stdevs[e]=r.stats.stdev,++e}}normalized(n){const e=n.byIndex(0).length,r=new Array(e);for(let t=0;t<e;++t)r[t]=new Float32Array(this.featuresCount);let o=0;for(const i of n){if(i.type!==t.COLUMN_TYPE.INT&&i.type!==t.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const n=i.getRawData(),s=this.avgs[o],a=this.stdevs[o];if(a>0)for(let t=0;t<e;++t)r[t][o]=(n[t]-s)/a;else for(let t=0;t<e;++t)r[t][o]=0;++o}return r}transposed(n){const e=n.byIndex(0).length,r=this.featuresCount,o=new Array(r);for(let t=0;t<r;++t)o[t]=new Float32Array(e);let i=0;for(const r of n){if(r.type!==t.COLUMN_TYPE.INT&&r.type!==t.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const n=r.getRawData(),s=this.avgs[i],a=this.stdevs[i];if(a>0)for(let t=0;t<e;++t)o[i][t]=(n[t]-s)/a;else for(let t=0;t<e;++t)o[i][t]=0;++i}return o}preprocessedTargets(n){if(n.type!==t.COLUMN_TYPE.STRING)throw new Error("Training failes - incorrect target type");const e=this.classesCount,r=n.length,o=n.getRawData(),i=new Array(r),s=new Uint32Array(e).fill(0);for(let t=0;t<r;++t)i[t]=new Uint8Array(e).fill(0);for(let t=0;t<r;++t)i[t][o[t]]=1,++s[o[t]];return{oneHot:i,weights:s}}predict(n){if(void 0===this.params)throw new Error("Non-trained model");if(n.length!==this.featuresCount)throw new Error("Predcition fails: incorrect features count");const e=this.normalized(n),r=e.length,o=this.featuresCount,i=this.classesCount;let s,a;const u=new Float32Array(i);let c,l,f;const h=new Array(r);for(let t=0;t<r;++t){s=e[t],c=0;for(let t=0;t<i;++t){a=this.params[t],c=a[o];for(let t=0;t<o;++t)c+=a[t]*s[t];u[t]=Math.exp(c)}l=u[0],f=0;for(let t=1;t<i;++t)l<u[t]&&(l=u[t],f=t);h[t]=this.categories[f]}return t.Column.fromStrings("predicted",h)}fitSoftmaxParams(t,n,r,o,i,s){return Vn(this,void 0,void 0,function*(){const a=this.preprocessedTargets(n);return new Promise((u,c)=>{const l=new Worker(new URL(e.p+e.u(501),e.b));l.postMessage({features:this.normalized(t),transposed:this.transposed(t),oneHot:a.oneHot,classesWeights:a.weights,targetRaw:n.getRawData(),iterations:r,rate:o,penalty:i,tolerance:s}),l.onmessage=function(t){l.terminate(),u(t.data.params),console.log(`Loss: ${t.data.loss}`)}})})}}var Kn,jn,zn,Xn;(Xn=Kn||(Kn={}))[Xn.ITERATIONS=20]="ITERATIONS",Xn[Xn.ETA=.3]="ETA",Xn[Xn.MAX_DEPTH=6]="MAX_DEPTH",Xn[Xn.LAMBDA=1]="LAMBDA",Xn[Xn.ALPHA=0]="ALPHA",function(t){t[t.SAMLPES_HIGH=1e5]="SAMLPES_HIGH",t[t.SAMLPES_MID=5e4]="SAMLPES_MID",t[t.SAMPLES_LOW=1e4]="SAMPLES_LOW",t[t.FEATURES_HIGH=10]="FEATURES_HIGH",t[t.FEATURES_MID=20]="FEATURES_MID",t[t.FEATURES_LOW=100]="FEATURES_LOW"}(jn||(jn={})),function(t){t[t.MODEL=1e7]="MODEL",t[t.UTILS=1]="UTILS",t[t.PACK=128]="PACK",t[t.SIZE=4]="SIZE"}(zn||(zn={}));const Qn=t.FLOAT_NULL;var Zn;!function(t){t.PREDICT="Prediction",t.TYPE="Type",t.PARAMS="Params count",t.CATS="Categories",t.CATS_SIZE="Categories size"}(Zn||(Zn={}));class Jn{static isApplicable(t,n){for(const n of t)if(!n.matches("numerical"))return!1;return!(!n.matches("numerical")&&!n.matches("string"))}static isInteractive(t,n){const e=t.length,r=n.length;return r<=jn.SAMPLES_LOW?e<=jn.FEATURES_LOW:r<=jn.SAMLPES_MID?e<=jn.FEATURES_MID:r<=jn.SAMLPES_HIGH&&e<=jn.FEATURES_HIGH}constructor(n){var e;if(this.modelParams=void 0,this.targetType=void 0,this.targetCategories=void 0,n)try{let r=0;const o=new Uint32Array(n.buffer,r,1)[0];r+=zn.SIZE;const i=t.DataFrame.fromByteArray(new Uint8Array(n.buffer,r,o));r+=o,this.targetType=i.get(Zn.TYPE,0);const s=i.get(Zn.PARAMS,0),a=i.get(Zn.CATS_SIZE,0);if(a>0){const o=t.DataFrame.fromByteArray(new Uint8Array(n.buffer,r,a));this.targetCategories=null===(e=o.col(Zn.CATS))||void 0===e?void 0:e.toList()}r+=a,r=4*Math.ceil(r/4),this.modelParams=new Int32Array(n.buffer,r,s)}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(n,r){return o=this,i=arguments,a=function*(n,r,o=Kn.ITERATIONS,i=Kn.ETA,s=Kn.MAX_DEPTH,a=Kn.LAMBDA,u=Kn.ALPHA){this.targetType=r.type,this.targetType===t.COLUMN_TYPE.STRING&&(this.targetCategories=r.categories),this.modelParams=yield async function(t,n,r,o,i,s,a,u,c,l){return new Promise((f,h)=>{const m=n.length,d=t.length,p=new Float32Array(m*d);let g,y;for(let n=0;n<d;++n){y=t.byIndex(n).getRawData(),g=n*m;for(let t=0;t<m;++t)p[t+g]=y[t]}const v=new Worker(new URL(e.p+e.u(990),e.b));v.postMessage({features:p,target:n.getRawData(),samplesCount:m,featuresCount:d,modelReserve:c,utilsLength:l,iterations:o,eta:i,maxDepth:s,lambda:a,alpha:u,missingValue:r}),v.onmessage=function(t){v.terminate(),f(t.data.params)}})}(n,r,Qn,o,i,s,a,u,zn.MODEL,zn.UTILS)},new((s=void 0)||(s=Promise))(function(t,n){function e(t){try{u(a.next(t))}catch(t){n(t)}}function r(t){try{u(a.throw(t))}catch(t){n(t)}}function u(n){var o;n.done?t(n.value):(o=n.value,o instanceof s?o:new s(function(t){t(o)})).then(e,r)}u((a=a.apply(o,i||[])).next())});var o,i,s,a}predict(n){if(void 0===this.modelParams)throw new Error("Failed to apply non-trained model");const e=function(t,n,e){const r=t.byIndex(0).length,o=t.length,i=e.length;let s=XGBoostModule.HEAPF32;const a=XGBoostModule.HEAP32,u=XGBoostModule._malloc(r*o*4),c=XGBoostModule._malloc(4*r),l=XGBoostModule._malloc(4*i);for(let n=0;n<o;++n){const e=t.byIndex(n).getRawData();for(let t=0;t<r;++t)s[u/4+t+n*r]=e[t]}for(let t=0;t<i;++t)a[l/4+t]=e[t];XGBoostModule._predict(u,r,o,n,l,i,c,r),s=XGBoostModule.HEAPF32;const f=new Float32Array(r);for(let t=0;t<r;++t)f[t]=s[c/4+t];return XGBoostModule._free(u),XGBoostModule._free(c),XGBoostModule._free(l),f}(n,Qn,this.modelParams);switch(this.targetType){case t.COLUMN_TYPE.STRING:return this.stringColPrediction(e);case t.COLUMN_TYPE.INT:return this.intColPrediction(e);case t.COLUMN_TYPE.BIG_INT:return this.bigIntColPrediction(e);default:return t.Column.fromFloat32Array(Zn.PREDICT,e)}}toBytes(){if(void 0===this.modelParams||void 0===this.targetType)throw new Error("Failed to pack non-trained model");const n=void 0!==this.targetCategories?t.DataFrame.fromColumns([t.Column.fromList(t.COLUMN_TYPE.STRING,Zn.CATS,this.targetCategories)]).toByteArray():void 0,e=void 0!==n?n.length:0,r=this.modelParams.length*this.modelParams.BYTES_PER_ELEMENT,o=t.DataFrame.fromColumns([t.Column.fromStrings(Zn.TYPE,[this.targetType]),t.Column.fromInt32Array(Zn.PARAMS,new Int32Array([this.modelParams.length])),t.Column.fromInt32Array(Zn.CATS_SIZE,new Int32Array([e]))]).toByteArray(),i=o.length,s=64*Math.ceil((zn.SIZE+i+e+r+zn.PACK)/64),a=new Uint8Array(s);let u=0;return new Uint32Array(a.buffer,u,1)[0]=i,u+=zn.SIZE,a.set(o,u),u+=i,e>0&&a.set(n,u),u+=e,u=4*Math.ceil(u/4),a.set(new Uint8Array(this.modelParams.buffer),u),a}stringColPrediction(n){const e=n.length;if(void 0===this.targetCategories)throw new Error("Predicting fails: undefined categories");const r=new Array(e),o=this.targetCategories.length-1,i=t=>Math.max(0,Math.min(t,o));for(let t=0;t<e;++t)r[t]=this.targetCategories[i(Math.round(n[t]))];return t.Column.fromList(t.COLUMN_TYPE.STRING,Zn.PREDICT,r)}intColPrediction(n){const e=n.length,r=new Int32Array(e);for(let t=0;t<e;++t)r[t]=Math.round(n[t]);return t.Column.fromInt32Array(Zn.PREDICT,r,e)}bigIntColPrediction(n){const e=n.length,r=new BigInt64Array(e);for(let t=0;t<e;++t)r[t]=BigInt(Math.round(n[t]));return t.Column.fromBigInt64Array(Zn.PREDICT,r)}}var te=function(t,n,e,r){return new(e||(e=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(s,a)}u((r=r.apply(t,n||[])).next())})};const ne=100,ee=8e3;var re;L("Softmax",()=>{O("Performance: 50K samples, 100 features",()=>te(void 0,void 0,void 0,function*(){const t=Fn(5e4,ne,!1).columns,n=t.byIndex(ne);t.remove(n.name);const e=new Yn({classesCount:n.categories.length,featuresCount:t.length});yield e.fit(t,n);const r=e.toBytes();new Yn(void 0,r).predict(t)}),{timeout:ee,benchmark:!0}),O("Correctness",()=>te(void 0,void 0,void 0,function*(){const t=Fn(50,2,!0).columns,n=t.byIndex(2);t.remove(n.name);const e=new Yn({classesCount:n.categories.length,featuresCount:t.length});yield e.fit(t,n);const r=e.toBytes(),o=Un(n,new Yn(void 0,r).predict(t));R(o>.9,!0,`Softmax failed, too small accuracy: ${o}; expected: <= 0.9`)}),{timeout:ee})}),L("XGBoost",()=>{O("Performance: 50K samples, 100 features",()=>te(void 0,void 0,void 0,function*(){const t=Fn(5e4,ne,!1).columns,n=t.byIndex(ne);t.remove(n.name);const e=new Jn;yield e.fit(t,n);const r=e.toBytes();new Jn(r).predict(t)}),{timeout:ee,benchmark:!0}),O("Correctness",()=>te(void 0,void 0,void 0,function*(){const t=Fn(50,2,!0).columns,n=t.byIndex(2);t.remove(n.name);const e=new Jn;yield e.fit(t,n);const r=e.toBytes(),o=Un(n,new Jn(r).predict(t));R(o>.9,!0,`XGBoost failed, too small accuracy: ${o}; expected: <= 0.9`)}),{timeout:ee})}),function(t){t.NO_DATAFRAME="No dataframe is opened",t.NO_MISSING_VALUES="No missing values",t.ONE_AVAILABLE_FEATURE="Not enough of feature columns to apply imputation using the KNN method",t.ONE_FEATURE_SELECTED="Imputation cannot be applied to",t.UNSUPPORTED_COLUMN_TYPE="Unsupported column type",t.UNSUPPORTED_IMPUTATION_STRATEGY="Unsupported imputation strategy",t.KNN_CANNOT_BE_APPLIED="KNN imputer cannot be applied: no columns to be used as features",t.KNN_NO_TARGET_COLUMNS="KNN imputer cannot be applied: no columns with missing values",t.KNN_NO_FEATURE_COLUMNS="KNN imputer cannot be applied: no feature columns",t.KNN_NOT_ENOUGH_OF_ROWS="KNN imputer cannot be applied: not enough of rows",t.KNN_IMPOSSIBLE_IMPUTATION="Imputation is impossible, no features can be used",t.INCORRECT_NEIGHBORS="Incorrect number of neighbors",t.KNN_FAILS="KNN IMPUTATION FAILS",t.CORE_ISSUE="Core issue",t.FAILED_TO_IMPUTE="Failed to impute",t.UNSUPPORTED_FILL_VALUE_TYPE="Unsupported fill value type",t.EMPTY_COLUMN="Column contains just null values",t.FAILS_TO_PREDICT_IMPUTATION_FAILS="Failed to predict imputation fails",t.WRONG_PREDICTIONS="wrong evaluation of KNN imputation fails"}(re||(re={}));const oe="copy";var ie,se;!function(t){t.KNN_IMPUTER="k-NN Imputation",t.TABLE="Table",t.IN_PLACE="In-place",t.COLUMNS="Impute",t.FEATURES="Using",t.CANCEL="CANCEL",t.RUN="RUN",t.OK="OK",t.NEIGHBORS="Neighbors",t.DISTANCE="Distance",t.FILL="Fill",t.MARK="Mark",t.SIMPLE_IMPUTER="Simple impute",t.SETTINGS="Settings",t.KEEP_EMPTY="Keep empty"}(ie||(ie={})),function(t){t.TARGET="Columns with missing values that must be filled",t.FEATURES="Columns with features to be used for determining the 'nearest' elements in the k-NN method",t.IN_PLACE="Defines whether to use in-place imputation or add a new column without missing values",t.METRIC="Type of metric between the feature values",t.WEIGHT="Weight",t.NEIGHBORS="Neighbors count used in the KNN method",t.DISTANCE="Type of distance between elements with the specified features",t.METRIC_SETTINGS="Show additional options",t.FILL_FAILED_ITEMS="Impute missing values using a simple approach: mean, median or most frequent",t.MARK_FAILED_ITEMS="Mark missing values cells with a color",t.FILL_VALUE="Fill value",t.IMPUTATION_SETTINGS="Simple imputation settings",t.KEEP_EMPTY="Defines whether to keep empty missing values failed to be imputed OR fill them using simple imputation",t.RUN="Run imputation using the k-NN method"}(se||(se={}));const ae=[t.COLUMN_TYPE.INT,t.COLUMN_TYPE.FLOAT,t.COLUMN_TYPE.STRING,t.COLUMN_TYPE.DATE_TIME,t.COLUMN_TYPE.QNUM];function ue(n){switch(n.type){case t.COLUMN_TYPE.INT:return t.INT_NULL;case t.COLUMN_TYPE.FLOAT:case t.COLUMN_TYPE.QNUM:case t.COLUMN_TYPE.DATE_TIME:return t.FLOAT_NULL;case t.COLUMN_TYPE.STRING:return n.max;default:throw new Error(re.UNSUPPORTED_COLUMN_TYPE)}}var ce,le,fe,he;function me(n){switch(n){case t.COLUMN_TYPE.STRING:case t.COLUMN_TYPE.DATE_TIME:return{defaultWeight:fe.WEIGHT,defaultMetric:ce.ONE_HOT,availableMetrics:[ce.ONE_HOT]};case t.COLUMN_TYPE.INT:case t.COLUMN_TYPE.FLOAT:case t.COLUMN_TYPE.QNUM:return{defaultWeight:fe.WEIGHT,defaultMetric:ce.DIFFERENCE,availableMetrics:[ce.DIFFERENCE,ce.ONE_HOT]};default:throw new Error(re.UNSUPPORTED_COLUMN_TYPE)}}!function(t){t.ONE_HOT="One-hot",t.DIFFERENCE="Difference"}(ce||(ce={})),(he=le||(le={})).EUCLIDEAN="Euclidean",he.MANHATTAN="Manhattan",function(t){t[t.WEIGHT=1]="WEIGHT",t[t.NEIGHBORS=4]="NEIGHBORS",t[t.IN_PLACE=1]="IN_PLACE",t[t.SELECTED=1]="SELECTED",t[t.KEEP_EMPTY=0]="KEEP_EMPTY"}(fe||(fe={}));const de=e=>{O(`${e} dist, 100K rows, 15 cols, 75 missing vals`,()=>{return r=void 0,o=void 0,s=function*(){const r=function(n){const e=Rn.length,r=[];let o=0;const i=new Map;for(let e=0;e<5;++e){const s=new Int32Array(n),a=`int #${e+1}`,u=[];for(let t=0;t<n;++t)s[t]=Math.floor(10*Math.random());for(let e=0;e<5;++e)o=Math.floor(n*Math.random()),s[o]=t.INT_NULL,u.push(o);r.push(t.Column.fromInt32Array(a,s)),i.set(a,u)}for(let e=0;e<5;++e){const s=new Float32Array(n),a=`float #${e+1}`,u=[];for(let t=0;t<n;++t)s[t]=10*Math.random();for(let e=0;e<5;++e)o=Math.floor(n*Math.random()),s[o]=t.FLOAT_NULL,u.push(o);r.push(t.Column.fromFloat32Array(a,s)),i.set(a,u)}for(let s=0;s<5;++s){const a=new Array(n),u=`str #${s+1}`,c=[];for(let t=0;t<n;++t)a[t]=Rn[Math.floor(Math.random()*e)];const l=t.Column.fromStrings(u,a);for(let t=0;t<5;++t)o=Math.floor(n*Math.random()),l.set(o,null),c.push(o);r.push(l),i.set(u,c)}return{df:t.DataFrame.fromColumns(r),misValsIds:i}}(1e5),o=r.df,i=o.columns.names(),s=new Map,a=r.misValsIds;for(const t of o.columns){const n=me(t.type);s.set(t.name,{weight:n.defaultWeight,type:n.defaultMetric})}const u=function(e,r,o,i,s,a,u){if(a<1)throw new Error(re.INCORRECT_NEIGHBORS);if(e.rowCount<2)throw new Error(re.KNN_NOT_ENOUGH_OF_ROWS);if(0===r.length)throw new Error(re.KNN_NO_TARGET_COLUMNS);if(0===o.size)throw new Error(re.KNN_NO_FEATURE_COLUMNS);1===o.size&&r.forEach(t=>{if(o.has(t))throw new Error(`${re.KNN_NO_FEATURE_COLUMNS} can be used for the column '${t}'`)}),r.forEach(t=>{if(!i.has(t))throw new Error(`${re.KNN_FAILS}: ${re.WRONG_PREDICTIONS}`)});const c=e.columns;r.forEach(t=>{if(!ae.includes(c.byName(t).type))throw new Error(re.UNSUPPORTED_COLUMN_TYPE)}),o.forEach((t,n)=>{if(!ae.includes(e.getCol(n).type))throw new Error(re.UNSUPPORTED_COLUMN_TYPE)});const l=new Map;return r.forEach(r=>{const f=c.byName(r),h=ue(f),m=f.length,d=f.getRawData(),p=new Uint16Array(f.categories.length),g=[],y=[],v=[],w=[];o.forEach((t,n)=>{if(n!==f.name){const e=c.byName(n);switch(g.push(e.getRawData()),y.push(ue(e)),t.type){case ce.DIFFERENCE:v.push((n,e)=>t.weight*Math.abs(n-e));break;case ce.ONE_HOT:v.push((n,e)=>t.weight*(n===e?0:1))}}});const E=g.length,A=new Uint32Array(g.length),C=new Float32Array(g.length);let _=0;const N=new Array(a);let x=0,b=0,S=0,T=0,I=0;const M=(t,n)=>{A.forEach((e,r)=>{C[r]=v[e](g[e][t],g[e][n])})},O=s===le.EUCLIDEAN?()=>{let t=0;for(let n=0;n<_;++n)t+=C[n]*C[n];return Math.sqrt(t)}:()=>{let t=0;for(let n=0;n<_;++n)t+=Math.abs(C[n]);return Math.sqrt(t)},R=t=>{if(d[t]===h)return!1;for(let n=0;n<_;++n)if(g[A[n]][t]===y[A[n]])return!1;return!0},L=n=>{if((t=>{_=0;for(let n=0;n<E;++n)g[n][t]!==y[n]&&(A[_]=n,++_)})(n),0===_)throw new Error(`${re.KNN_IMPOSSIBLE_IMPUTATION}: the column "${f.name}", row ${n+1}`);x=0;for(let t=0;t<m;++t)if(R(t)&&t!==n){M(n,t);const e=O();if(x<a)N[x]={index:t,dist:e},++x;else{b=0,S=N[0].dist;for(let t=1;t<x;++t)S<N[t].dist&&(S=N[t].dist,b=t);e<S&&(N[b]={index:t,dist:e})}}if(0===x)throw new Error(`${re.KNN_IMPOSSIBLE_IMPUTATION}: the column "${f.name}", row ${n+1}`);if(f.type===t.COLUMN_TYPE.STRING)return(()=>{p.forEach((t,n,e)=>e[n]=0);let t=0;for(t=0;t<x;++t)++p[d[N[t].index]];let n=p[0],e=0;return p.forEach((t,r)=>{t>n&&(n=t,e=r)}),e})();T=0;for(let t=0;t<x;++t)T+=d[N[t].index];return I=T/x,f.type===t.COLUMN_TYPE.INT?Math.round(I):I};if(u){for(const t of i.get(r))try{d[t]=L(t)}catch(e){w.push(t),e instanceof Error||n.shell.error(re.CORE_ISSUE)}w.length>0&&l.set(r,w),f.set(0,f.get(0))}else{const t=f.clone();let o=1,s=`${r}(${oe})`;for(;e.columns.contains(s);)s=`${r}(${oe} ${o})`,++o;t.name=s;const a=t.getRawData();for(const t of i.get(r))try{a[t]=L(t)}catch(e){w.push(t),e instanceof Error||n.shell.error(re.CORE_ISSUE)}w.length>0&&l.set(s,w),t.set(0,t.get(0)),e.columns.add(t)}}),l}(o,i,s,a,e,5,!0);let c=0;u.forEach((t,n)=>c+=t.length),R(c,0,`Failed to impute ${c} missing values`)},new((i=void 0)||(i=Promise))(function(t,n){function e(t){try{u(s.next(t))}catch(t){n(t)}}function a(t){try{u(s.throw(t))}catch(t){n(t)}}function u(n){var r;n.done?t(n.value):(r=n.value,r instanceof i?r:new i(function(t){t(r)})).then(e,a)}u((s=s.apply(r,o||[])).next())});var r,o,i,s},{timeout:1e4,benchmark:!0})};L("Missing values imputation",()=>{de(le.EUCLIDEAN),de(le.MANHATTAN)});var pe,ge=e(6572);function ye(t){if(t<=0||t>=1)throw new Error(pe.INCORRECT_SIGNIFICANCE_LEVEL)}function ve(t){const n=t.size;return n<=1?0:(t.sumOfSquares-Math.pow(t.sum,2)/n)/(n-1)}function we(t,n,e){ye(e);const r=ve(t),o=ve(n);return 0===r||0===o?r===o:r/o<ge.centralF.inv(1-e,t.size-1,n.size-1)}!function(t){t.NON_EQUAL_FACTORS_VALUES_SIZE="non-equal sizes of factor and values arrays",t.INCORRECT_SIGNIFICANCE_LEVEL="incorrect significance level",t.NON_EQUAL_VARIANCES="non-equal variances",t.NON_NORMAL_DISTRIB="non-normal distribution",t.UNSUPPORTED_COLUMN_TYPE="unsupported feature column type",t.INCORRECT_CATEGORIES_COL_TYPE="incorrect categories column type",t.SINGLE_FACTOR="single category features",t.CATS_EQUAL_SIZE="single value in each category",t.NO_FEATURE_VARIATION="no feature variation",t.NO_FEATURE_VARIATION_WITHIN_GROUPS="no feature variation within groups"}(pe||(pe={}));class Ee{constructor(t,n,e){if(this.nullsCount=0,t.length!==n.length)throw new Error(pe.NON_EQUAL_FACTORS_VALUES_SIZE);if(!(n.stats.stdev>0))throw new Error(pe.NO_FEATURE_VARIATION);this.setStats(t,n,e)}areVarsEqual(t){const n=this.catCount;if(1===n)return!0;const e={sum:this.sums[0],sumOfSquares:this.sumsOfSquares[0],size:this.subSampleSizes[0]};for(let r=1;r<n;++r)if(!we(e,{sum:this.sums[r],sumOfSquares:this.sumsOfSquares[r],size:this.subSampleSizes[r]},t))return!1;return!0}getOneWayAnova(){let t=0,n=0,e=0,r=this.catCount,o=r;for(let i=0;i<r;++i)0!==this.subSampleSizes[i]?(t+=this.sums[i],n+=this.sumsOfSquares[i],e+=Math.pow(this.sums[i],2)/this.subSampleSizes[i]):--o;if(r=o,1===r)throw new Error(pe.SINGLE_FACTOR);const i=this.size-this.nullsCount;if(i===r)throw new Error(pe.CATS_EQUAL_SIZE);const s=n-Math.pow(t,2)/i,a=e-Math.pow(t,2)/i,u=s-a;if(0===u)throw new Error(pe.NO_FEATURE_VARIATION_WITHIN_GROUPS);const c=r-1,l=i-r,f=a/c,h=u/l,m=f/h;return{ssBn:a,ssWn:u,ssTot:s,dfBn:c,dfWn:l,dfTot:i-1,msBn:f,msWn:h,fStat:m,pValue:1-ge.centralF.cdf(m,c,l)}}setStats(n,e,r){const o=e.type,i=e.length,s=ue(e);switch(o){case t.COLUMN_TYPE.INT:case t.COLUMN_TYPE.FLOAT:const o=r;this.catCount=o,this.size=i;const a=e.getRawData(),u=n.getRawData(),c=new Float64Array(o).fill(0),l=new Float64Array(o).fill(0),f=new Int32Array(o).fill(0);let h;if(n.type==t.COLUMN_TYPE.BOOL){let t=0,n=0,e=u[0];const r=8*u.BYTES_PER_ELEMENT-1;for(let o=0;o<i;++o)h=1&e>>n,a[o]!==s?(c[h]+=a[o],l[h]+=Math.pow(a[o],2),++f[h]):++this.nullsCount,++n,n>r&&(n=0,++t,e=u[t])}else{const t=n.stats.missingValueCount>0?ue(n):-1;for(let n=0;n<i;++n)h=u[n],h!==t&&a[n]!==s?(c[h]+=a[n],l[h]+=Math.pow(a[n],2),++f[h]):++this.nullsCount}this.sums=c,this.sumsOfSquares=l,this.subSampleSizes=f;break;default:throw new Error(pe.UNSUPPORTED_COLUMN_TYPE)}}}function Ae(t,n,e,r=!0){ye(e);const o=t.stats.uniqueCount;if(o<2)throw new Error(pe.SINGLE_FACTOR);const i=new Ee(t,n,o);if(r&&!i.areVarsEqual(e))throw new Error(pe.NON_EQUAL_VARIANCES);const s=i.getOneWayAnova();return{anovaTable:s,fCritical:ge.centralF.inv(1-e,s.dfBn,s.dfWn),significance:e}}var Ce=function(t,n,e,r){return new(e||(e=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(s,a)}u((r=r.apply(t,n||[])).next())})};const _e=.05,Ne=!1,xe=t.Column.fromList(t.COLUMN_TYPE.INT,"features",[9,12,4,8,7,4,6,8,2,10,1,3,4,5,2]),be=t.Column.fromStrings("features",["A","A","A","A","A","B","B","B","B","B","C","C","C","C","C"]);var Se;!function(t){t[t.DF_BN=2]="DF_BN",t[t.DF_TOT=14]="DF_TOT",t[t.DF_WN=12]="DF_WN",t[t.SS_BN=63.333]="SS_BN",t[t.SS_TOT=147.333]="SS_TOT",t[t.SS_WN=84]="SS_WN",t[t.MS_BN=31.666]="MS_BN",t[t.MS_WN=7]="MS_WN",t[t.F_STAT=4.523]="F_STAT",t[t.F_CRIT=3.885]="F_CRIT",t[t.P_VAL=.034]="P_VAL"}(Se||(Se={})),L("ANOVA",()=>{O("Performance: 1M rows demog",()=>Ce(void 0,void 0,void 0,function*(){const t=n.data.demo.demog(1e6),e=t.col("race"),r=t.col("height");new Ee(e,r,e.stats.uniqueCount).areVarsEqual(_e),Ae(e,r,_e,Ne)}),{timeout:4e3,benchmark:!0}),O("Correctness",()=>Ce(void 0,void 0,void 0,function*(){const t=Ae(be,xe,_e,Ne),n=t.anovaTable;R(n.dfBn,Se.DF_BN,"Incorrect degrees of freedom: dfBn"),R(n.dfTot,Se.DF_TOT,"Incorrect degrees of freedom: dfTot"),R(n.dfWn,Se.DF_WN,"Incorrect degrees of freedom: dfWn");const e=(t,n)=>Math.abs(t-n)<.01;R(e(n.ssBn,Se.SS_BN),!0,"Incorrect sum of squares: ssBn"),R(e(n.ssTot,Se.SS_TOT),!0,"Incorrect sum of squares: ssTot"),R(e(n.ssWn,Se.SS_WN),!0,"Incorrect sum of squares: ssWn"),R(e(n.msBn,Se.MS_BN),!0,"Incorrect mean squares: msBn"),R(e(n.msWn,Se.MS_WN),!0,"Incorrect mean squares: msWn"),R(e(n.fStat,Se.F_STAT),!0,"Incorrect F-statistics value"),R(e(n.pValue,Se.P_VAL),!0,"Incorrect p-value"),R(e(t.fCritical,Se.F_CRIT),!0,"Incorrect F-critical")}),{timeout:4e3})});var Te=function(t,n,e,r){return new(e||(e=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(s,a)}u((r=r.apply(t,n||[])).next())})};const Ie=new t.Package;function Me(e,r,o){return Te(this,void 0,void 0,function*(){const m=yield function(e){var r,o,m,d,p,g;return i(this,void 0,void 0,function*(){console.log("--------------------");const y=null===(o=null===(r=n.functions.getCurrentCall())||void 0===r?void 0:r.func)||void 0===o?void 0:o.package,v=(null!==(d=(null!==(m=null==y?void 0:y.packageOwner)&&void 0!==m?m:"").match(new RegExp("[^<]*<([^>]*)>")))&&void 0!==d?d:["",""])[1];yield D(y);const w=[];console.log("Running tests"),console.log(e),null!=e||(e={}),null!==(p=(g=e).testContext)&&void 0!==p||(g.testContext=new I),n.shell.clearLastError();const E=function(){const t=[];return console.log=(...n)=>{t.push(...n),u(...n)},console.info=(...n)=>{t.push(...n),c(...n)},console.warn=(...n)=>{t.push(...n),l(...n)},console.error=(...n)=>{t.push(...n),f(...n)},t}();yield function(e,r){var o,s,a,h,m,d,p;return i(this,void 0,void 0,function*(){try{for(const[n,c]of Object.entries(e)){if(!(null==r?void 0:r.category)||(null===(o=r.exclude)||void 0===o?void 0:o.some(t=>n.startsWith(t))))continue;if((!n.toLowerCase().startsWith(`${null==r?void 0:r.category.toLowerCase().trim()} :`)||r.test)&&n.toLowerCase().trim()!==(null==r?void 0:r.category.toLowerCase().trim()))continue;u(`Started ${n} category`);const e=null===(s=c.tests)||void 0===s?void 0:s.every(t=>{var n;return null===(n=t.options)||void 0===n?void 0:n.skipReason});e||(c.beforeStatus=yield A(c.before,null!==(a=r.category)&&void 0!==a?a:""));let l,f=null!==(h=c.tests)&&void 0!==h?h:[];r.stressTest&&(f=f.filter(t=>{var n;return null===(n=t.options)||void 0===n?void 0:n.stressTest}),f=k(f)),(null!==(d=null===(m=r.tags)||void 0===m?void 0:m.length)&&void 0!==d?d:0)>0&&(f=f.filter(t=>{var n,e;return null===(e=null===(n=t.options)||void 0===n?void 0:n.tags)||void 0===e?void 0:e.some(t=>{var n;return(null!==(n=null==r?void 0:r.tags)&&void 0!==n?n:[]).includes(t)})})),c.beforeStatus?(l=Array.from(f.map(e=>({date:(new Date).toISOString(),category:n,name:e.name,success:!1,result:"before() failed",ms:0,skipped:!1,logs:"",owner:null==y?void 0:y.packageOwner,package:y.name,widgetsDifference:0,flaking:t.Test.isReproducing}))),l.forEach(t=>i(this,void 0,void 0,function*(){return F("package",t)}))):l=yield C(c,r);const g=l.filter(t=>"skipped"!=t.result);e||(c.afterStatus=yield A(c.after,null!==(p=r.category)&&void 0!==p?p:"")),c.afterStatus&&g.push({date:(new Date).toISOString(),category:n,name:"after",success:!1,result:c.afterStatus,ms:0,skipped:!1,logs:"",owner:null==y?void 0:y.packageOwner,package:y.name,widgetsDifference:0,flaking:t.Test.isReproducing}),c.beforeStatus&&g.push({date:(new Date).toISOString(),category:n,name:"before",success:!1,result:c.beforeStatus,ms:0,skipped:!1,logs:"",owner:null==y?void 0:y.packageOwner,package:y.name,widgetsDifference:0,flaking:t.Test.isReproducing}),w.push(...g)}}finally{console.log=u,console.info=c,console.warn=l,console.error=f}if(r.testContext.catchUnhandled&&!t.Test.isInBenchmark){yield H(1e3);const e=yield n.shell.lastError,r={logs:"",date:(new Date).toISOString(),category:"Unhandled exceptions",name:"Exception",result:null!=e?e:"",success:!e,ms:0,skipped:!1,owner:null!=v?v:"",package:y.name,widgetsDifference:0};w.push(Object.assign(Object.assign({},r),{flaking:t.Test.isReproducing&&!e})),r.package=y.name,yield F("package",r)}})}(h,e);for(let t of w)t.result=t.result.toString().replace(/"/g,"'"),null!=t.logs&&(t.logs=t.logs.toString().replace(/"/g,"'"));return w;function A(t,n){return i(this,void 0,void 0,function*(){let e;try{void 0!==t&&(yield G(()=>i(this,void 0,void 0,function*(){yield t()}),1e5,`before ${n}: timeout error`))}catch(t){e=yield U(t)}return e})}function C(e,r){var o,u,c,l,f,h,m,d,p,g,w,A,C,N,x,b,S,T;return i(this,void 0,void 0,function*(){let i=null!==(o=e.tests)&&void 0!==o?o:[];const I=[],M=_();if(e.clear)for(let o=0;o<i.length;o++){i[o].options&&void 0===(null===(u=i[o].options)||void 0===u?void 0:u.benchmark)&&(i[o].options||(i[o].options={}),i[o].options.benchmark=null!==(c=e.benchmarks)&&void 0!==c&&c);let A=i[o];if(r.test&&r.test.toLowerCase()!==A.name.toLowerCase())continue;(null==A?void 0:A.options)&&(A.options.owner=null!==(m=null!==(h=null!==(f=null===(l=i[o].options)||void 0===l?void 0:l.owner)&&void 0!==f?f:null==e?void 0:e.owner)&&void 0!==h?h:v)&&void 0!==m?m:"");let C=yield B(A,null==r?void 0:r.test,E,t.Test.isInBenchmark?null!==(p=null===(d=i[o].options)||void 0===d?void 0:d.benchmarkTimeout)&&void 0!==p?p:a:null!==(w=null===(g=i[o].options)||void 0===g?void 0:g.timeout)&&void 0!==w?w:s,y.name,r.verbose);C&&I.push(Object.assign(Object.assign({},C),{widgetsDifference:_()-M})),n.shell.closeAll(),t.Balloon.closeAll()}else for(let n=0;n<i.length;n++){let o=i[n];if(r.test&&r.test.toLowerCase()!==o.name.toLowerCase())continue;(null==o?void 0:o.options)&&(o.options.owner=null!==(x=null!==(N=null!==(C=null===(A=i[n].options)||void 0===A?void 0:A.owner)&&void 0!==C?C:null==e?void 0:e.owner)&&void 0!==N?N:v)&&void 0!==x?x:"");let s=yield B(o,null==r?void 0:r.test,E,t.Test.isInBenchmark?null!==(S=null===(b=i[n].options)||void 0===b?void 0:b.benchmarkTimeout)&&void 0!==S?S:a:null===(T=i[n].options)||void 0===T?void 0:T.timeout,y.name,r.verbose);s&&I.push(Object.assign(Object.assign({},s),{widgetsDifference:_()-M}))}return I})}function _(){var n;let e=-1;try{e=t.Widget.getAll().length}catch(t){console.warn(null!==(n=t.message)&&void 0!==n?n:t)}return e}})}({category:e,test:r,testContext:o});return t.DataFrame.fromObjects(m)})}function Oe(){return Te(this,void 0,void 0,function*(){yield D(Ie,Ie.getModule("package-test.js"))})}})(),eda_test=r})();
|
|
1
|
+
var eda_test;(()=>{var t={517:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Solarize=void 0,e.Solarize=function(t){const e=t.data,n=t.width,r=4*n;let i=t.height;do{const t=(i-1)*r;let o=n;do{const n=t+4*(o-1);let r=e[n],i=e[n+1],a=e[n+2];r>127&&(r=255-r),i>127&&(i=255-i),a>127&&(a=255-a),e[n]=r,e[n+1]=i,e[n+2]=a}while(--o)}while(--i)}},540:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},661:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Threshold=void 0;const r=n(4892),i=n(6536),o=n(5483);e.Threshold=function(t){const e=255*this.threshold(),n=t.data,r=n.length;for(let t=0;t<r;t+=1)n[t]=n[t]<e?0:255},r.Factory.addGetterSetter(i.Node,"threshold",.5,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},680:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Konva=void 0;const r=n(8871),i=n(4060),o=n(6536),a=n(4473),s=n(7324),l=n(6267),c=n(7457),h=n(7949),u=n(1268),d=n(4723),f=n(9696),g=n(8665),p=n(9869),m=n(8604);e.Konva=i.Util._assign(r.Konva,{Util:i.Util,Transform:i.Transform,Node:o.Node,Container:a.Container,Stage:s.Stage,stages:s.stages,Layer:l.Layer,FastLayer:c.FastLayer,Group:h.Group,DD:u.DD,Shape:d.Shape,shapes:d.shapes,Animation:f.Animation,Tween:g.Tween,Easings:g.Easings,Context:p.Context,Canvas:m.Canvas}),e.default=e.Konva},944:(t,e)=>{"use strict";e.Vb=void 0,e.Vb=function(t,e,n){var r=function(t,e,n){if(0===t.length||0===e.length)return 0;if(n&&!n.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var r=0,i=t.length,o=e.length,a=Math.floor(Math.max(i,o)/2)-1,s=new Array(i),l=new Array(o),c=0;c<i;c++)for(var h=Math.max(0,c-a);h<=Math.min(o,c+a+1);h++)if(!s[c]&&!l[h]&&t[c]===e[h]){++r,s[c]=l[h]=!0;break}if(0===r)return 0;var u=0,d=0;for(c=0;c<i;c++)if(s[c]){for(;!l[d];)d++;t.charAt(c)!==e.charAt(d++)&&u++}return(r/i+r/o+(r-(u/=2))/r)/3}(t,e,n),i=0;if(r>.7){for(var o=Math.min(t.length,e.length),a=0;t[a]===e[a]&&a<4&&a<o;)++i,a++;r+=.1*i*(1-r)}return r}},983:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Emboss=void 0;const r=n(4892),i=n(6536),o=n(4060),a=n(5483);e.Emboss=function(t){const e=10*this.embossStrength(),n=255*this.embossWhiteLevel(),r=this.embossDirection(),i=this.embossBlend(),a=t.data,s=t.width,l=t.height,c=4*s;let h=0,u=0,d=l;switch(r){case"top-left":h=-1,u=-1;break;case"top":h=-1,u=0;break;case"top-right":h=-1,u=1;break;case"right":h=0,u=1;break;case"bottom-right":h=1,u=1;break;case"bottom":h=1,u=0;break;case"bottom-left":h=1,u=-1;break;case"left":h=0,u=-1;break;default:o.Util.error("Unknown emboss direction: "+r)}do{const t=(d-1)*c;let r=h;d+r<1&&(r=0),d+r>l&&(r=0);const o=(d-1+r)*s*4;let f=s;do{const r=t+4*(f-1);let l=u;f+l<1&&(l=0),f+l>s&&(l=0);const c=o+4*(f-1+l),h=a[r]-a[c],d=a[r+1]-a[c+1],g=a[r+2]-a[c+2];let p=h;const m=p>0?p:-p;if((d>0?d:-d)>m&&(p=d),(g>0?g:-g)>m&&(p=g),p*=e,i){const t=a[r]+p,e=a[r+1]+p,n=a[r+2]+p;a[r]=t>255?255:t<0?0:t,a[r+1]=e>255?255:e<0?0:e,a[r+2]=n>255?255:n<0?0:n}else{let t=n-p;t<0?t=0:t>255&&(t=255),a[r]=a[r+1]=a[r+2]=t}}while(--f)}while(--d)},r.Factory.addGetterSetter(i.Node,"embossStrength",.5,(0,a.getNumberValidator)(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"embossWhiteLevel",.5,(0,a.getNumberValidator)(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"embossDirection","top-left",void 0,r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"embossBlend",!1,void 0,r.Factory.afterSetFilter)},1113:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},1268:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DD=void 0;const r=n(8871),i=n(4060);e.DD={get isDragging(){let t=!1;return e.DD._dragElements.forEach(e=>{"dragging"===e.dragStatus&&(t=!0)}),t},justDragged:!1,get node(){let t;return e.DD._dragElements.forEach(e=>{t=e.node}),t},_dragElements:new Map,_drag(t){const n=[];e.DD._dragElements.forEach((e,r)=>{const{node:o}=e,a=o.getStage();a.setPointersPositions(t),void 0===e.pointerId&&(e.pointerId=i.Util._getFirstPointerId(t));const s=a._changedPointerPositions.find(t=>t.id===e.pointerId);if(s){if("dragging"!==e.dragStatus){const n=o.dragDistance();if(Math.max(Math.abs(s.x-e.startPointerPos.x),Math.abs(s.y-e.startPointerPos.y))<n)return;if(o.startDrag({evt:t}),!o.isDragging())return}o._setDragPosition(t,e),n.push(o)}}),n.forEach(e=>{e.fire("dragmove",{type:"dragmove",target:e,evt:t},!0)})},_endDragBefore(t){const n=[];e.DD._dragElements.forEach(i=>{const{node:o}=i,a=o.getStage();if(t&&a.setPointersPositions(t),!a._changedPointerPositions.find(t=>t.id===i.pointerId))return;"dragging"!==i.dragStatus&&"stopped"!==i.dragStatus||(e.DD.justDragged=!0,r.Konva._mouseListenClick=!1,r.Konva._touchListenClick=!1,r.Konva._pointerListenClick=!1,i.dragStatus="stopped");const s=i.node.getLayer()||i.node instanceof r.Konva.Stage&&i.node;s&&-1===n.indexOf(s)&&n.push(s)}),n.forEach(t=>{t.draw()})},_endDragAfter(t){e.DD._dragElements.forEach((n,r)=>{"stopped"===n.dragStatus&&n.node.fire("dragend",{type:"dragend",target:n.node,evt:t},!0),"dragging"!==n.dragStatus&&e.DD._dragElements.delete(r)})}},r.Konva.isBrowser&&(window.addEventListener("mouseup",e.DD._endDragBefore,!0),window.addEventListener("touchend",e.DD._endDragBefore,!0),window.addEventListener("touchcancel",e.DD._endDragBefore,!0),window.addEventListener("mousemove",e.DD._drag),window.addEventListener("touchmove",e.DD._drag),window.addEventListener("mouseup",e.DD._endDragAfter,!1),window.addEventListener("touchend",e.DD._endDragAfter,!1),window.addEventListener("touchcancel",e.DD._endDragAfter,!1))},1354:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var r=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(r),o="/*# ".concat(i," */");return[e].concat([o]).join("\n")}return[e].join("\n")}},1486:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Path=void 0;const r=n(4892),i=n(8871),o=n(4723),a=n(5570);class s extends o.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=s.parsePathData(this.data()),this.pathLength=s.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let n=!1;for(let r=0;r<e.length;r++){const i=e[r].command,o=e[r].points;switch(i){case"L":t.lineTo(o[0],o[1]);break;case"M":t.moveTo(o[0],o[1]);break;case"C":t.bezierCurveTo(o[0],o[1],o[2],o[3],o[4],o[5]);break;case"Q":t.quadraticCurveTo(o[0],o[1],o[2],o[3]);break;case"A":const e=o[0],r=o[1],i=o[2],a=o[3],s=o[4],l=o[5],c=o[6],h=o[7],u=i>a?i:a,d=i>a?1:i/a,f=i>a?a/i:1;t.translate(e,r),t.rotate(c),t.scale(d,f),t.arc(0,0,u,s,s+l,1-h),t.scale(1/d,1/f),t.rotate(-c),t.translate(-e,-r);break;case"z":n=!0,t.closePath()}}n||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(e){if("A"===e.command){const n=e.points[4],r=e.points[5],i=e.points[4]+r;let o=Math.PI/180;if(Math.abs(n-i)<o&&(o=Math.abs(n-i)),r<0)for(let r=n-o;r>i;r-=o){const n=s.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],r,0);t.push(n.x,n.y)}else for(let r=n+o;r<i;r+=o){const n=s.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],r,0);t.push(n.x,n.y)}}else if("C"===e.command)for(let n=0;n<=1;n+=.01){const r=s.getPointOnCubicBezier(n,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);t.push(r.x,r.y)}else t=t.concat(e.points)});let e,n,r=t[0],i=t[0],o=t[1],a=t[1];for(let s=0;s<t.length/2;s++)e=t[2*s],n=t[2*s+1],isNaN(e)||(r=Math.min(r,e),i=Math.max(i,e)),isNaN(n)||(o=Math.min(o,n),a=Math.max(a,n));return{x:r,y:o,width:i-r,height:a-o}}getLength(){return this.pathLength}getPointAtLength(t){return s.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,e,n,r){return Math.sqrt((n-t)*(n-t)+(r-e)*(r-e))}static getPathLength(t){let e=0;for(let n=0;n<t.length;++n)e+=t[n].pathLength;return e}static getPointAtLengthOfDataArray(t,e){let n,r=0,i=e.length;if(!i)return null;for(;r<i&&t>e[r].pathLength;)t-=e[r].pathLength,++r;if(r===i)return n=e[r-1].points.slice(-2),{x:n[0],y:n[1]};if(t<.01)return"M"===e[r].command?(n=e[r].points.slice(0,2),{x:n[0],y:n[1]}):{x:e[r].start.x,y:e[r].start.y};const o=e[r],l=o.points;switch(o.command){case"L":return s.getPointOnLine(t,o.start.x,o.start.y,l[0],l[1]);case"C":return s.getPointOnCubicBezier((0,a.t2length)(t,s.getPathLength(e),t=>(0,a.getCubicArcLength)([o.start.x,l[0],l[2],l[4]],[o.start.y,l[1],l[3],l[5]],t)),o.start.x,o.start.y,l[0],l[1],l[2],l[3],l[4],l[5]);case"Q":return s.getPointOnQuadraticBezier((0,a.t2length)(t,s.getPathLength(e),t=>(0,a.getQuadraticArcLength)([o.start.x,l[0],l[2]],[o.start.y,l[1],l[3]],t)),o.start.x,o.start.y,l[0],l[1],l[2],l[3]);case"A":const n=l[0],r=l[1],i=l[2],c=l[3],h=l[5],u=l[6];let d=l[4];return d+=h*t/o.pathLength,s.getPointOnEllipticalArc(n,r,i,c,d,u)}return null}static getPointOnLine(t,e,n,r,i,o,a){o=null!=o?o:e,a=null!=a?a:n;const s=this.getLineLength(e,n,r,i);if(s<1e-10)return{x:e,y:n};if(r===e)return{x:o,y:a+(i>n?t:-t)};const l=(i-n)/(r-e),c=Math.sqrt(t*t/(1+l*l))*(r<e?-1:1),h=l*c;if(Math.abs(a-n-l*(o-e))<1e-10)return{x:o+c,y:a+h};const u=((o-e)*(r-e)+(a-n)*(i-n))/(s*s),d=e+u*(r-e),f=n+u*(i-n),g=this.getLineLength(o,a,d,f),p=Math.sqrt(t*t-g*g),m=Math.sqrt(p*p/(1+l*l))*(r<e?-1:1);return{x:d+m,y:f+l*m}}static getPointOnCubicBezier(t,e,n,r,i,o,a,s,l){function c(t){return t*t*t}function h(t){return 3*t*t*(1-t)}function u(t){return 3*t*(1-t)*(1-t)}function d(t){return(1-t)*(1-t)*(1-t)}return{x:s*c(t)+o*h(t)+r*u(t)+e*d(t),y:l*c(t)+a*h(t)+i*u(t)+n*d(t)}}static getPointOnQuadraticBezier(t,e,n,r,i,o,a){function s(t){return t*t}function l(t){return 2*t*(1-t)}function c(t){return(1-t)*(1-t)}return{x:o*s(t)+r*l(t)+e*c(t),y:a*s(t)+i*l(t)+n*c(t)}}static getPointOnEllipticalArc(t,e,n,r,i,o){const a=Math.cos(o),s=Math.sin(o),l=n*Math.cos(i),c=r*Math.sin(i);return{x:t+(l*a-c*s),y:e+(l*s+c*a)}}static parsePathData(t){if(!t)return[];let e=t;const n=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(let t=0;t<n.length;t++)e=e.replace(new RegExp(n[t],"g"),"|"+n[t]);const r=e.split("|"),i=[],o=[];let a=0,s=0;const l=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let c;for(let t=1;t<r.length;t++){let e=r[t],n=e.charAt(0);for(e=e.slice(1),o.length=0;c=l.exec(e);)o.push(c[0]);const h=[];for(let t=0,e=o.length;t<e;t++){if("00"===o[t]){h.push(0,0);continue}const e=parseFloat(o[t]);isNaN(e)?h.push(0):h.push(e)}for(;h.length>0&&!isNaN(h[0]);){let t="",e=[];const r=a,o=s;let l,c,u,d,f,g,p,m,y,v;switch(n){case"l":a+=h.shift(),s+=h.shift(),t="L",e.push(a,s);break;case"L":a=h.shift(),s=h.shift(),e.push(a,s);break;case"m":const r=h.shift(),o=h.shift();if(a+=r,s+=o,t="M",i.length>2&&"z"===i[i.length-1].command)for(let t=i.length-2;t>=0;t--)if("M"===i[t].command){a=i[t].points[0]+r,s=i[t].points[1]+o;break}e.push(a,s),n="l";break;case"M":a=h.shift(),s=h.shift(),t="M",e.push(a,s),n="L";break;case"h":a+=h.shift(),t="L",e.push(a,s);break;case"H":a=h.shift(),t="L",e.push(a,s);break;case"v":s+=h.shift(),t="L",e.push(a,s);break;case"V":s=h.shift(),t="L",e.push(a,s);break;case"C":e.push(h.shift(),h.shift(),h.shift(),h.shift()),a=h.shift(),s=h.shift(),e.push(a,s);break;case"c":e.push(a+h.shift(),s+h.shift(),a+h.shift(),s+h.shift()),a+=h.shift(),s+=h.shift(),t="C",e.push(a,s);break;case"S":c=a,u=s,l=i[i.length-1],"C"===l.command&&(c=a+(a-l.points[2]),u=s+(s-l.points[3])),e.push(c,u,h.shift(),h.shift()),a=h.shift(),s=h.shift(),t="C",e.push(a,s);break;case"s":c=a,u=s,l=i[i.length-1],"C"===l.command&&(c=a+(a-l.points[2]),u=s+(s-l.points[3])),e.push(c,u,a+h.shift(),s+h.shift()),a+=h.shift(),s+=h.shift(),t="C",e.push(a,s);break;case"Q":e.push(h.shift(),h.shift()),a=h.shift(),s=h.shift(),e.push(a,s);break;case"q":e.push(a+h.shift(),s+h.shift()),a+=h.shift(),s+=h.shift(),t="Q",e.push(a,s);break;case"T":c=a,u=s,l=i[i.length-1],"Q"===l.command&&(c=a+(a-l.points[0]),u=s+(s-l.points[1])),a=h.shift(),s=h.shift(),t="Q",e.push(c,u,a,s);break;case"t":c=a,u=s,l=i[i.length-1],"Q"===l.command&&(c=a+(a-l.points[0]),u=s+(s-l.points[1])),a+=h.shift(),s+=h.shift(),t="Q",e.push(c,u,a,s);break;case"A":d=h.shift(),f=h.shift(),g=h.shift(),p=h.shift(),m=h.shift(),y=a,v=s,a=h.shift(),s=h.shift(),t="A",e=this.convertEndpointToCenterParameterization(y,v,a,s,p,m,d,f,g);break;case"a":d=h.shift(),f=h.shift(),g=h.shift(),p=h.shift(),m=h.shift(),y=a,v=s,a+=h.shift(),s+=h.shift(),t="A",e=this.convertEndpointToCenterParameterization(y,v,a,s,p,m,d,f,g)}i.push({command:t||n,points:e,start:{x:r,y:o},pathLength:this.calcLength(r,o,t||n,e)})}"z"!==n&&"Z"!==n||i.push({command:"z",points:[],start:void 0,pathLength:0})}return i}static calcLength(t,e,n,r){let i,o,l,c;const h=s;switch(n){case"L":return h.getLineLength(t,e,r[0],r[1]);case"C":return(0,a.getCubicArcLength)([t,r[0],r[2],r[4]],[e,r[1],r[3],r[5]],1);case"Q":return(0,a.getQuadraticArcLength)([t,r[0],r[2]],[e,r[1],r[3]],1);case"A":i=0;const n=r[4],s=r[5],u=r[4]+s;let d=Math.PI/180;if(Math.abs(n-u)<d&&(d=Math.abs(n-u)),o=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],n,0),s<0)for(c=n-d;c>u;c-=d)l=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],c,0),i+=h.getLineLength(o.x,o.y,l.x,l.y),o=l;else for(c=n+d;c<u;c+=d)l=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],c,0),i+=h.getLineLength(o.x,o.y,l.x,l.y),o=l;return l=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],u,0),i+=h.getLineLength(o.x,o.y,l.x,l.y),i}return 0}static convertEndpointToCenterParameterization(t,e,n,r,i,o,a,s,l){const c=l*(Math.PI/180),h=Math.cos(c)*(t-n)/2+Math.sin(c)*(e-r)/2,u=-1*Math.sin(c)*(t-n)/2+Math.cos(c)*(e-r)/2,d=h*h/(a*a)+u*u/(s*s);d>1&&(a*=Math.sqrt(d),s*=Math.sqrt(d));let f=Math.sqrt((a*a*(s*s)-a*a*(u*u)-s*s*(h*h))/(a*a*(u*u)+s*s*(h*h)));i===o&&(f*=-1),isNaN(f)&&(f=0);const g=f*a*u/s,p=f*-s*h/a,m=(t+n)/2+Math.cos(c)*g-Math.sin(c)*p,y=(e+r)/2+Math.sin(c)*g+Math.cos(c)*p,v=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},_=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(v(t)*v(e))},w=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(_(t,e))},b=w([1,0],[(h-g)/a,(u-p)/s]),C=[(h-g)/a,(u-p)/s],x=[(-1*h-g)/a,(-1*u-p)/s];let S=w(C,x);return _(C,x)<=-1&&(S=Math.PI),_(C,x)>=1&&(S=0),0===o&&S>0&&(S-=2*Math.PI),1===o&&S<0&&(S+=2*Math.PI),[m,y,a,s,b,S,c,o]}}e.Path=s,s.prototype.className="Path",s.prototype._attrsAffectingSize=["data"],(0,i._registerNode)(s),r.Factory.addGetterSetter(s,"data")},1958:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Text=void 0,e.stringToArray=c;const r=n(4060),i=n(4892),o=n(4723),a=n(8871),s=n(5483),l=n(8871);function c(t){return[...t].reduce((t,e,n,r)=>{if(/\p{Emoji}/u.test(e)){const i=r[n+1];i&&/\p{Emoji_Modifier}|\u200D/u.test(i)?(t.push(e+i),r[n+1]=""):t.push(e)}else/\p{Regional_Indicator}{2}/u.test(e+(r[n+1]||""))?t.push(e+r[n+1]):n>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:e&&t.push(e);return t},[])}const h="auto",u="inherit",d="justify",f="left",g="middle",p="normal",m=" ",y="none",v=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],_=v.length;let w;function b(){return w||(w=r.Util.createCanvasElement().getContext("2d"),w)}class C extends o.Shape{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<_;t++)this.on(v[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){const e=this.textArr,n=e.length;if(!this.text())return;let r,i=this.padding(),o=this.fontSize(),s=this.lineHeight()*o,l=this.verticalAlign(),h=this.direction(),p=0,m=this.align(),y=this.getWidth(),v=this.letterSpacing(),_=this.fill(),w=this.textDecoration(),b=-1!==w.indexOf("underline"),C=-1!==w.indexOf("line-through");h=h===u?t.direction:h;let x=s/2,S=g;if(a.Konva._fixTextRendering){const t=this.measureSize("M");S="alphabetic",x=(t.fontBoundingBoxAscent-t.fontBoundingBoxDescent)/2+s/2}for("rtl"===h&&t.setAttr("direction",h),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",S),t.setAttr("textAlign",f),l===g?p=(this.getHeight()-n*s-2*i)/2:"bottom"===l&&(p=this.getHeight()-n*s-2*i),t.translate(i,p+i),r=0;r<n;r++){let l=0,u=0;const f=e[r],g=f.text,p=f.width,w=f.lastInParagraph;if(t.save(),"right"===m?l+=y-p-2*i:"center"===m&&(l+=(y-p-2*i)/2),b){t.save(),t.beginPath();const e=l,n=x+u+(a.Konva._fixTextRendering?Math.round(o/4):Math.round(o/2));t.moveTo(e,n);const r=m!==d||w?p:y-2*i;t.lineTo(e+Math.round(r),n),t.lineWidth=o/15;const s=this._getLinearGradient();t.strokeStyle=s||_,t.stroke(),t.restore()}if(C){t.save(),t.beginPath();const e=a.Konva._fixTextRendering?-Math.round(o/4):0;t.moveTo(l,x+u+e);const n=m!==d||w?p:y-2*i;t.lineTo(l+Math.round(n),x+u+e),t.lineWidth=o/15;const r=this._getLinearGradient();t.strokeStyle=r||_,t.stroke(),t.restore()}if("rtl"===h||0===v&&m!==d)0!==v&&t.setAttr("letterSpacing",`${v}px`),this._partialTextX=l,this._partialTextY=x+u,this._partialText=g,t.fillStrokeShape(this);else{const e=g.split(" ").length-1,n=c(g);for(let r=0;r<n.length;r++){const o=n[r];" "!==o||w||m!==d||(l+=(y-2*i-p)/e),this._partialTextX=l,this._partialTextY=x+u,this._partialText=o,t.fillStrokeShape(this),l+=this.measureSize(o).width+v}}t.restore(),n>1&&(x+=s)}}_hitFunc(t){const e=this.getWidth(),n=this.getHeight();t.beginPath(),t.rect(0,0,e,n),t.closePath(),t.fillStrokeShape(this)}setText(t){const e=r.Util._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===h||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===h||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return r.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,n,r,i,o,a,s,l,c,h,u;let d,f=b(),g=this.fontSize();f.save(),f.font=this._getContextFont(),d=f.measureText(t),f.restore();const p=g/100;return{actualBoundingBoxAscent:null!==(e=d.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*p,actualBoundingBoxDescent:null!==(n=d.actualBoundingBoxDescent)&&void 0!==n?n:0,actualBoundingBoxLeft:null!==(r=d.actualBoundingBoxLeft)&&void 0!==r?r:-7.421875*p,actualBoundingBoxRight:null!==(i=d.actualBoundingBoxRight)&&void 0!==i?i:75.732421875*p,alphabeticBaseline:null!==(o=d.alphabeticBaseline)&&void 0!==o?o:0,emHeightAscent:null!==(a=d.emHeightAscent)&&void 0!==a?a:100*p,emHeightDescent:null!==(s=d.emHeightDescent)&&void 0!==s?s:-20*p,fontBoundingBoxAscent:null!==(l=d.fontBoundingBoxAscent)&&void 0!==l?l:91*p,fontBoundingBoxDescent:null!==(c=d.fontBoundingBoxDescent)&&void 0!==c?c:21*p,hangingBaseline:null!==(h=d.hangingBaseline)&&void 0!==h?h:72.80000305175781*p,ideographicBaseline:null!==(u=d.ideographicBaseline)&&void 0!==u?u:-21*p,width:d.width,height:g}}_getContextFont(){return this.fontStyle()+m+this.fontVariant()+m+(this.fontSize()+"px ")+this.fontFamily().split(",").map(t=>{const e=(t=t.trim()).indexOf(" ")>=0,n=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!n&&(t=`"${t}"`),t}).join(", ")}_addTextLine(t){this.align()===d&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),n=t.length;return b().measureText(t).width+e*n}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),n=0,r=this.lineHeight()*e,i=this.attrs.width,o=this.attrs.height,a=i!==h&&void 0!==i,s=o!==h&&void 0!==o,l=this.padding(),u=i-2*l,d=o-2*l,f=0,g=this.wrap(),p="char"!==g&&g!==y,v=this.ellipsis();this.textArr=[],b().font=this._getContextFont();const _=v?this._getTextWidth("…"):0;for(let e=0,i=t.length;e<i;++e){let o=t[e],l=this._getTextWidth(o);if(a&&l>u)for(;o.length>0;){let t=0,e=c(o).length,i="",a=0;for(;t<e;){const n=t+e>>>1,l=c(o).slice(0,n+1).join(""),h=this._getTextWidth(l);(v&&s&&f+r>d?h+_:h)<=u?(t=n+1,i=l,a=h):e=n}if(!i)break;if(p){const e=c(o),n=c(i),r=e[n.length];let s;if((r===m||"-"===r)&&a<=u)s=n.length;else{const t=n.lastIndexOf(m),e=n.lastIndexOf("-");s=Math.max(t,e)+1}s>0&&(t=s,i=e.slice(0,t).join(""),a=this._getTextWidth(i))}if(i=i.trimRight(),this._addTextLine(i),n=Math.max(n,a),f+=r,this._shouldHandleEllipsis(f)){this._tryToAddEllipsisToLastLine();break}if(o=c(o).slice(t).join("").trimLeft(),o.length>0&&(l=this._getTextWidth(o),l<=u)){this._addTextLine(o),f+=r,n=Math.max(n,l);break}}else this._addTextLine(o),f+=r,n=Math.max(n,l),this._shouldHandleEllipsis(f)&&e<i-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),s&&f+r>d)break}this.textHeight=e,this.textWidth=n}_shouldHandleEllipsis(t){const e=+this.fontSize(),n=this.lineHeight()*e,r=this.attrs.height,i=r!==h&&void 0!==r,o=r-2*this.padding();return!(this.wrap()!==y)||i&&t+n>o}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==h&&void 0!==t,n=t-2*this.padding(),r=this.ellipsis(),i=this.textArr[this.textArr.length-1];i&&r&&(e&&(this._getTextWidth(i.text+"…")<n||(i.text=i.text.slice(0,i.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(i.text+"…"))}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}}e.Text=C,C.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},C.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},C.prototype.className="Text",C.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,l._registerNode)(C),i.Factory.overWriteSetter(C,"width",(0,s.getNumberOrAutoValidator)()),i.Factory.overWriteSetter(C,"height",(0,s.getNumberOrAutoValidator)()),i.Factory.addGetterSetter(C,"direction",u),i.Factory.addGetterSetter(C,"fontFamily","Arial"),i.Factory.addGetterSetter(C,"fontSize",12,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(C,"fontStyle",p),i.Factory.addGetterSetter(C,"fontVariant",p),i.Factory.addGetterSetter(C,"padding",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(C,"align",f),i.Factory.addGetterSetter(C,"verticalAlign","top"),i.Factory.addGetterSetter(C,"lineHeight",1,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(C,"wrap","word"),i.Factory.addGetterSetter(C,"ellipsis",!1,(0,s.getBooleanValidator)()),i.Factory.addGetterSetter(C,"letterSpacing",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(C,"text","",(0,s.getStringValidator)()),i.Factory.addGetterSetter(C,"textDecoration","")},2512:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Sepia=void 0,e.Sepia=function(t){const e=t.data,n=e.length;for(let t=0;t<n;t+=4){const n=e[t+0],r=e[t+1],i=e[t+2];e[t+0]=Math.min(255,.393*n+.769*r+.189*i),e[t+1]=Math.min(255,.349*n+.686*r+.168*i),e[t+2]=Math.min(255,.272*n+.534*r+.131*i)}}},2650:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Contrast=void 0;const r=n(4892),i=n(6536),o=n(5483);e.Contrast=function(t){const e=Math.pow((this.contrast()+100)/100,2),n=t.data,r=n.length;let i=150,o=150,a=150;for(let t=0;t<r;t+=4)i=n[t],o=n[t+1],a=n[t+2],i/=255,i-=.5,i*=e,i+=.5,i*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,i=i<0?0:i>255?255:i,o=o<0?0:o>255?255:o,a=a<0?0:a>255?255:a,n[t]=i,n[t+1]=o,n[t+2]=a},r.Factory.addGetterSetter(i.Node,"contrast",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},3443:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Line=void 0;const r=n(4892),i=n(8871),o=n(4723),a=n(5483);function s(t,e,n,r,i,o,a){const s=Math.sqrt(Math.pow(n-t,2)+Math.pow(r-e,2)),l=Math.sqrt(Math.pow(i-n,2)+Math.pow(o-r,2)),c=a*s/(s+l),h=a*l/(s+l);return[n-c*(i-t),r-c*(o-e),n+h*(i-t),r+h*(o-e)]}function l(t,e){const n=t.length,r=[];for(let i=2;i<n-2;i+=2){const n=s(t[i-2],t[i-1],t[i],t[i+1],t[i+2],t[i+3],e);isNaN(n[0])||(r.push(n[0]),r.push(n[1]),r.push(t[i]),r.push(t[i+1]),r.push(n[2]),r.push(n[3]))}return r}class c extends o.Shape{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(t){const e=this.points(),n=e.length,r=this.tension(),i=this.closed(),o=this.bezier();if(!n)return;let a=0;if(t.beginPath(),t.moveTo(e[0],e[1]),0!==r&&n>4){const r=this.getTensionPoints(),o=r.length;for(a=i?0:4,i||t.quadraticCurveTo(r[0],r[1],r[2],r[3]);a<o-2;)t.bezierCurveTo(r[a++],r[a++],r[a++],r[a++],r[a++],r[a++]);i||t.quadraticCurveTo(r[o-2],r[o-1],e[n-2],e[n-1])}else if(o)for(a=2;a<n;)t.bezierCurveTo(e[a++],e[a++],e[a++],e[a++],e[a++],e[a++]);else for(a=2;a<n;a+=2)t.lineTo(e[a],e[a+1]);i?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():l(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,n=this.tension(),r=s(t[e-2],t[e-1],t[0],t[1],t[2],t[3],n),i=s(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],n),o=l(t,n);return[r[2],r[3]].concat(o).concat([i[0],i[1],t[e-2],t[e-1],i[2],i[3],r[0],r[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points();let e,n,r=t[0],i=t[0],o=t[1],a=t[1];for(let s=0;s<t.length/2;s++)e=t[2*s],n=t[2*s+1],r=Math.min(r,e),i=Math.max(i,e),o=Math.min(o,n),a=Math.max(a,n);return{x:r,y:o,width:i-r,height:a-o}}}e.Line=c,c.prototype.className="Line",c.prototype._attrsAffectingSize=["points","bezier","tension"],(0,i._registerNode)(c),r.Factory.addGetterSetter(c,"closed",!1),r.Factory.addGetterSetter(c,"bezier",!1),r.Factory.addGetterSetter(c,"tension",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(c,"points",[],(0,a.getNumberArrayValidator)())},3862:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RGBA=void 0;const r=n(4892),i=n(6536),o=n(5483);e.RGBA=function(t){const e=t.data,n=e.length,r=this.red(),i=this.green(),o=this.blue(),a=this.alpha();for(let t=0;t<n;t+=4){const n=1-a;e[t]=r*a+e[t]*n,e[t+1]=i*a+e[t+1]*n,e[t+2]=o*a+e[t+2]*n}},r.Factory.addGetterSetter(i.Node,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),r.Factory.addGetterSetter(i.Node,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),r.Factory.addGetterSetter(i.Node,"blue",0,o.RGBComponent,r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"alpha",1,function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t})},4060:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Util=e.Transform=void 0;const r=n(8871);class i{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new i(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){const e=Math.cos(t),n=Math.sin(t),r=this.m[0]*e+this.m[2]*n,i=this.m[1]*e+this.m[3]*n,o=this.m[0]*-n+this.m[2]*e,a=this.m[1]*-n+this.m[3]*e;return this.m[0]=r,this.m[1]=i,this.m[2]=o,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const n=this.m[0]+this.m[2]*e,r=this.m[1]+this.m[3]*e,i=this.m[2]+this.m[0]*t,o=this.m[3]+this.m[1]*t;return this.m[0]=n,this.m[1]=r,this.m[2]=i,this.m[3]=o,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],n=this.m[1]*t.m[0]+this.m[3]*t.m[1],r=this.m[0]*t.m[2]+this.m[2]*t.m[3],i=this.m[1]*t.m[2]+this.m[3]*t.m[3],o=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=o,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,n=-this.m[1]*t,r=-this.m[2]*t,i=this.m[0]*t,o=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=o,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],n=this.m[1],r=this.m[2],i=this.m[3],o=t*i-n*r,a={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=t||0!=n){const e=Math.sqrt(t*t+n*n);a.rotation=n>0?Math.acos(t/e):-Math.acos(t/e),a.scaleX=e,a.scaleY=o/e,a.skewX=(t*r+n*i)/o,a.skewY=0}else if(0!=r||0!=i){const e=Math.sqrt(r*r+i*i);a.rotation=Math.PI/2-(i>0?Math.acos(-r/e):-Math.acos(r/e)),a.scaleX=o/e,a.scaleY=e,a.skewX=0,a.skewY=(t*r+n*i)/o}return a.rotation=e.Util._getRotation(a.rotation),a}}e.Transform=i;const o=Math.PI/180,a=180/Math.PI,s="Konva error: ",l={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},c=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let h=[];const u="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};e.Util={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;const e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){h.push(t),1===h.length&&u(function(){const t=h;h=[],t.forEach(function(t){t()})})},createCanvasElement(){const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(t,n){const r=e.Util.createImageElement();r.onload=function(){n(r)},r.src=t},_rgbToHex:(t,e,n)=>((1<<24)+(t<<16)+(e<<8)+n).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");const e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){let t=(16777215*Math.random()|0).toString(16);for(;t.length<6;)t="0"+t;return"#"+t},getRGB(t){let e;return t in l?(e=l[t],{r:e[0],g:e[1],b:e[2]}):"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=c.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:t=>(t=t||"black",e.Util._namedColorToRBA(t)||e.Util._hex3ColorToRGBA(t)||e.Util._hex4ColorToRGBA(t)||e.Util._hex6ColorToRGBA(t)||e.Util._hex8ColorToRGBA(t)||e.Util._rgbColorToRGBA(t)||e.Util._rgbaColorToRGBA(t)||e.Util._hslColorToRGBA(t)),_namedColorToRBA(t){const e=l[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){const e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){const e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),r=Number(n[0])/360,i=Number(n[1])/100,o=Number(n[2])/100;let a,s,l;if(0===i)return l=255*o,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};a=o<.5?o*(1+i):o+i-o*i;const c=2*o-a,h=[0,0,0];for(let t=0;t<3;t++)s=r+1/3*-(t-1),s<0&&s++,s>1&&s--,l=6*s<1?c+6*(a-c)*s:2*s<1?a:3*s<2?c+(a-c)*(2/3-s)*6:c,h[t]=255*l;return{r:Math.round(h[0]),g:Math.round(h[1]),b:Math.round(h[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){const e={};for(const n in t)this._isPlainObject(t[n])?e[n]=this.cloneObject(t[n]):this._isArray(t[n])?e[n]=this.cloneArray(t[n]):e[n]=t[n];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*o,radToDeg:t=>t*a,_degToRad:t=>(e.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),e.Util.degToRad(t)),_radToDeg:t=>(e.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),e.Util.radToDeg(t)),_getRotation:t=>r.Konva.angleDeg?e.Util.radToDeg(t):t,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(s+t)},error(t){console.error(s+t)},warn(t){r.Konva.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const n in t)e(n,t[n])},_inRange:(t,e,n)=>e<=t&&t<n,_getProjectionToSegment(t,e,n,r,i,o){let a,s,l;const c=(t-n)*(t-n)+(e-r)*(e-r);if(0==c)a=t,s=e,l=(i-n)*(i-n)+(o-r)*(o-r);else{const h=((i-t)*(n-t)+(o-e)*(r-e))/c;h<0?(a=t,s=e,l=(t-i)*(t-i)+(e-o)*(e-o)):h>1?(a=n,s=r,l=(n-i)*(n-i)+(r-o)*(r-o)):(a=t+h*(n-t),s=e+h*(r-e),l=(a-i)*(a-i)+(s-o)*(s-o))}return[a,s,l]},_getProjectionToLine(t,n,r){const i=e.Util.cloneObject(t);let o=Number.MAX_VALUE;return n.forEach(function(a,s){if(!r&&s===n.length-1)return;const l=n[(s+1)%n.length],c=e.Util._getProjectionToSegment(a.x,a.y,l.x,l.y,t.x,t.y),h=c[0],u=c[1],d=c[2];d<o&&(i.x=h,i.y=u,o=d)}),i},_prepareArrayForTween(t,n,r){const i=[],o=[];if(t.length>n.length){const e=n;n=t,t=e}for(let e=0;e<t.length;e+=2)i.push({x:t[e],y:t[e+1]});for(let t=0;t<n.length;t+=2)o.push({x:n[t],y:n[t+1]});const a=[];return o.forEach(function(t){const n=e.Util._getProjectionToLine(t,i,r);a.push(n.x),a.push(n.y)}),a},_prepareToStringify(t){let n;t.visitedByCircularReferenceRemoval=!0;for(const r in t)if(t.hasOwnProperty(r)&&t[r]&&"object"==typeof t[r])if(n=Object.getOwnPropertyDescriptor(t,r),t[r].visitedByCircularReferenceRemoval||e.Util._isElement(t[r])){if(!n.configurable)return null;delete t[r]}else if(null===e.Util._prepareToStringify(t[r])){if(!n.configurable)return null;delete t[r]}return delete t.visitedByCircularReferenceRemoval,t},_assign(t,e){for(const n in e)t[n]=e[n];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){r.Konva.releaseCanvasOnDestroy&&t.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(t,e,n,r){let i=0,o=0,a=0,s=0;"number"==typeof r?i=o=a=s=Math.min(r,e/2,n/2):(i=Math.min(r[0]||0,e/2,n/2),o=Math.min(r[1]||0,e/2,n/2),s=Math.min(r[2]||0,e/2,n/2),a=Math.min(r[3]||0,e/2,n/2)),t.moveTo(i,0),t.lineTo(e-o,0),t.arc(e-o,o,o,3*Math.PI/2,0,!1),t.lineTo(e,n-s),t.arc(e-s,n-s,s,0,Math.PI/2,!1),t.lineTo(a,n),t.arc(a,n-a,a,Math.PI/2,Math.PI,!1),t.lineTo(0,i),t.arc(i,i,i,Math.PI,3*Math.PI/2,!1)}}},4473:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Container=void 0;const r=n(4892),i=n(6536),o=n(5483);class a extends i.Node{constructor(){super(...arguments),this.children=[]}getChildren(t){const e=this.children||[];return t?e.filter(t):e}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.destroy()}),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(let e=0;e<t.length;e++)this.add(t[e]);return this}const e=t[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.getChildren().length,e.parent=this,e._clearCaches(),this.getChildren().push(e),this._fire("add",{child:e}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){const e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){const n=[];return this._descendants(r=>{const i=r._isMatch(t);return i&&n.push(r),!(!i||!e)}),n}_descendants(t){let e=!1;const n=this.getChildren();for(const r of n){if(e=t(r),e)return!0;if(r.hasChildren()&&(e=r._descendants(t),e))return!0}return!1}toObject(){const t=i.Node.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach(e=>{t.children.push(e.toObject())}),t}isAncestorOf(t){let e=t.getParent();for(;e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){const e=i.Node.prototype.clone.call(this,t);return this.getChildren().forEach(function(t){e.add(t.clone())}),e}getAllIntersections(t){const e=[];return this.find("Shape").forEach(n=>{n.isVisible()&&n.intersects(t)&&e.push(n)}),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach(function(e){e._clearSelfAndDescendantCache(t)})}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach(function(t,e){t.index=e}),this._requestDraw()}drawScene(t,e,n){const r=this.getLayer(),i=t||r&&r.getCanvas(),o=i&&i.getContext(),a=this._getCanvasCache(),s=a&&a.scene,l=i&&i.isCache;if(!this.isVisible()&&!l)return this;if(s){o.save();const t=this.getAbsoluteTransform(e).getMatrix();o.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(o),o.restore()}else this._drawChildren("drawScene",i,e,n);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const n=this.getLayer(),r=t||n&&n.hitCanvas,i=r&&r.getContext(),o=this._getCanvasCache();if(o&&o.hit){i.save();const t=this.getAbsoluteTransform(e).getMatrix();i.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(i),i.restore()}else this._drawChildren("drawHit",r,e);return this}_drawChildren(t,e,n,r){var i;const o=e&&e.getContext(),a=this.clipWidth(),s=this.clipHeight(),l=this.clipFunc(),c="number"==typeof a&&"number"==typeof s||l,h=n===this;if(c){o.save();const t=this.getAbsoluteTransform(n);let e,r=t.getMatrix();if(o.transform(r[0],r[1],r[2],r[3],r[4],r[5]),o.beginPath(),l)e=l.call(this,o,this);else{const t=this.clipX(),e=this.clipY();o.rect(t||0,e||0,a,s)}o.clip.apply(o,e),r=t.copy().invert().getMatrix(),o.transform(r[0],r[1],r[2],r[3],r[4],r[5])}const u=!h&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;u&&(o.save(),o._applyGlobalCompositeOperation(this)),null===(i=this.children)||void 0===i||i.forEach(function(i){i[t](e,n,r)}),u&&o.restore(),c&&o.restore()}getClientRect(t={}){var e;const n=t.skipTransform,r=t.relativeTo;let i,o,a,s,l={x:1/0,y:1/0,width:0,height:0};const c=this;null===(e=this.children)||void 0===e||e.forEach(function(e){if(!e.visible())return;const n=e.getClientRect({relativeTo:c,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===n.width&&0===n.height||(void 0===i?(i=n.x,o=n.y,a=n.x+n.width,s=n.y+n.height):(i=Math.min(i,n.x),o=Math.min(o,n.y),a=Math.max(a,n.x+n.width),s=Math.max(s,n.y+n.height)))});const h=this.find("Shape");let u=!1;for(let t=0;t<h.length;t++)if(h[t]._isVisible(this)){u=!0;break}return l=u&&void 0!==i?{x:i,y:o,width:a-i,height:s-o}:{x:0,y:0,width:0,height:0},n?l:this._transformedRect(l,r)}}e.Container=a,r.Factory.addComponentsGetterSetter(a,"clip",["x","y","width","height"]),r.Factory.addGetterSetter(a,"clipX",void 0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(a,"clipY",void 0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(a,"clipWidth",void 0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(a,"clipHeight",void 0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(a,"clipFunc")},4481:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Star=void 0;const r=n(4892),i=n(4723),o=n(5483),a=n(8871);class s extends i.Shape{_sceneFunc(t){const e=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();t.beginPath(),t.moveTo(0,0-n);for(let i=1;i<2*r;i++){const o=i%2==0?n:e,a=o*Math.sin(i*Math.PI/r),s=-1*o*Math.cos(i*Math.PI/r);t.lineTo(a,s)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}e.Star=s,s.prototype.className="Star",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,a._registerNode)(s),r.Factory.addGetterSetter(s,"numPoints",5,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(s,"innerRadius",0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(s,"outerRadius",0,(0,o.getNumberValidator)())},4723:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Shape=e.shapes=void 0;const r=n(8871),i=n(4060),o=n(4892),a=n(6536),s=n(5483),l=n(8871),c=n(8722),h="hasShadow",u="shadowRGBA",d="patternImage",f="linearGradient",g="radialGradient";let p;function m(){return p||(p=i.Util.createCanvasElement().getContext("2d"),p)}e.shapes={};class y extends a.Node{constructor(t){let n;for(super(t);n=i.Util.getRandomColor(),!n||n in e.shapes;);this.colorKey=n,e.shapes[n]=this}getContext(){return i.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return i.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(h,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(d,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=m().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const e=new i.Transform;e.translate(this.fillPatternX(),this.fillPatternY()),e.rotate(r.Konva.getAngle(this.fillPatternRotation())),e.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),e.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=e.getMatrix(),o="undefined"==typeof DOMMatrix?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);t.setTransform(o)}return t}}_getLinearGradient(){return this._getCache(f,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=m(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),i=e.createLinearGradient(n.x,n.y,r.x,r.y);for(let e=0;e<t.length;e+=2)i.addColorStop(t[e],t[e+1]);return i}}_getRadialGradient(){return this._getCache(g,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=m(),n=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),i=e.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)i.addColorStop(t[e],t[e+1]);return i}}getShadowRGBA(){return this._getCache(u,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=i.Util.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops()))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){const e=this.getStage();if(!e)return!1;const n=e.bufferHitCanvas;return n.getContext().clear(),this.drawHit(n,void 0,!0),n.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return a.Node.prototype.destroy.call(this),delete e.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(null!==(e=this.attrs.perfectDrawEnabled)&&void 0!==e&&!e)return!1;const n=t||this.hasFill(),r=this.hasStroke(),i=1!==this.getAbsoluteOpacity();if(n&&r&&i)return!0;const o=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(n&&r&&o&&a)}setStrokeHitEnabled(t){i.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){const t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){let e=!1,n=this.getParent();for(;n;){if(n.isCached()){e=!0;break}n=n.getParent()}const r=t.skipTransform,i=t.relativeTo||e&&this.getStage()||void 0,o=this.getSelfRect(),a=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,s=o.width+a,l=o.height+a,c=!t.skipShadow&&this.hasShadow(),h=c?this.shadowOffsetX():0,u=c?this.shadowOffsetY():0,d=s+Math.abs(h),f=l+Math.abs(u),g=c&&this.shadowBlur()||0,p={width:d+2*g,height:f+2*g,x:-(a/2+g)+Math.min(h,0)+o.x,y:-(a/2+g)+Math.min(u,0)+o.y};return r?p:this._transformedRect(p,i)}drawScene(t,e,n){const r=this.getLayer(),i=(t||r.getCanvas()).getContext(),o=this._getCanvasCache(),a=this.getSceneFunc(),s=this.hasShadow();let l;const c=e===this;if(!this.isVisible()&&!c)return this;if(o){i.save();const t=this.getAbsoluteTransform(e).getMatrix();return i.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(i),i.restore(),this}if(!a)return this;if(i.save(),this._useBufferCanvas()){l=this.getStage();const t=n||l.bufferCanvas,r=t.getContext();r.clear(),r.save(),r._applyLineJoin(this);const o=this.getAbsoluteTransform(e).getMatrix();r.transform(o[0],o[1],o[2],o[3],o[4],o[5]),a.call(this,r,this),r.restore();const c=t.pixelRatio;s&&i._applyShadow(this),i._applyOpacity(this),i._applyGlobalCompositeOperation(this),i.drawImage(t._canvas,t.x||0,t.y||0,t.width/c,t.height/c)}else{if(i._applyLineJoin(this),!c){const t=this.getAbsoluteTransform(e).getMatrix();i.transform(t[0],t[1],t[2],t[3],t[4],t[5]),i._applyOpacity(this),i._applyGlobalCompositeOperation(this)}s&&i._applyShadow(this),a.call(this,i,this)}return i.restore(),this}drawHit(t,e,n=!1){if(!this.shouldDrawHit(e,n))return this;const r=this.getLayer(),o=t||r.hitCanvas,a=o&&o.getContext(),s=this.hitFunc()||this.sceneFunc(),l=this._getCanvasCache(),c=l&&l.hit;if(this.colorKey||i.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),c){a.save();const t=this.getAbsoluteTransform(e).getMatrix();return a.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(a),a.restore(),this}if(!s)return this;if(a.save(),a._applyLineJoin(this),this!==e){const t=this.getAbsoluteTransform(e).getMatrix();a.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return s.call(this,a,this),a.restore(),this}drawHitFromCache(t=0){const e=this._getCanvasCache(),n=this._getCachedSceneCanvas(),r=e.hit,o=r.getContext(),a=r.getWidth(),s=r.getHeight();o.clear(),o.drawImage(n._canvas,0,0,a,s);try{const e=o.getImageData(0,0,a,s),n=e.data,r=n.length,l=i.Util._hexToRgb(this.colorKey);for(let e=0;e<r;e+=4)n[e+3]>t?(n[e]=l.r,n[e+1]=l.g,n[e+2]=l.b,n[e+3]=255):n[e+3]=0;o.putImageData(e,0,0)}catch(t){i.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return c.hasPointerCapture(t,this)}setPointerCapture(t){c.setPointerCapture(t,this)}releaseCapture(t){c.releaseCapture(t,this)}}e.Shape=y,y.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},y.prototype._strokeFunc=function(t){t.stroke()},y.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},y.prototype._strokeFuncHit=function(t){t.stroke()},y.prototype._centroid=!1,y.prototype.nodeType="Shape",(0,l._registerNode)(y),y.prototype.eventListeners={},y.prototype.on.call(y.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(h)}),y.prototype.on.call(y.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(u)}),y.prototype.on.call(y.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",function(){this._clearCache(d)}),y.prototype.on.call(y.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",function(){this._clearCache(f)}),y.prototype.on.call(y.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",function(){this._clearCache(g)}),o.Factory.addGetterSetter(y,"stroke",void 0,(0,s.getStringOrGradientValidator)()),o.Factory.addGetterSetter(y,"strokeWidth",2,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"fillAfterStrokeEnabled",!1),o.Factory.addGetterSetter(y,"hitStrokeWidth","auto",(0,s.getNumberOrAutoValidator)()),o.Factory.addGetterSetter(y,"strokeHitEnabled",!0,(0,s.getBooleanValidator)()),o.Factory.addGetterSetter(y,"perfectDrawEnabled",!0,(0,s.getBooleanValidator)()),o.Factory.addGetterSetter(y,"shadowForStrokeEnabled",!0,(0,s.getBooleanValidator)()),o.Factory.addGetterSetter(y,"lineJoin"),o.Factory.addGetterSetter(y,"lineCap"),o.Factory.addGetterSetter(y,"sceneFunc"),o.Factory.addGetterSetter(y,"hitFunc"),o.Factory.addGetterSetter(y,"dash"),o.Factory.addGetterSetter(y,"dashOffset",0,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"shadowColor",void 0,(0,s.getStringValidator)()),o.Factory.addGetterSetter(y,"shadowBlur",0,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"shadowOpacity",1,(0,s.getNumberValidator)()),o.Factory.addComponentsGetterSetter(y,"shadowOffset",["x","y"]),o.Factory.addGetterSetter(y,"shadowOffsetX",0,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"shadowOffsetY",0,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"fillPatternImage"),o.Factory.addGetterSetter(y,"fill",void 0,(0,s.getStringOrGradientValidator)()),o.Factory.addGetterSetter(y,"fillPatternX",0,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"fillPatternY",0,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"fillLinearGradientColorStops"),o.Factory.addGetterSetter(y,"strokeLinearGradientColorStops"),o.Factory.addGetterSetter(y,"fillRadialGradientStartRadius",0),o.Factory.addGetterSetter(y,"fillRadialGradientEndRadius",0),o.Factory.addGetterSetter(y,"fillRadialGradientColorStops"),o.Factory.addGetterSetter(y,"fillPatternRepeat","repeat"),o.Factory.addGetterSetter(y,"fillEnabled",!0),o.Factory.addGetterSetter(y,"strokeEnabled",!0),o.Factory.addGetterSetter(y,"shadowEnabled",!0),o.Factory.addGetterSetter(y,"dashEnabled",!0),o.Factory.addGetterSetter(y,"strokeScaleEnabled",!0),o.Factory.addGetterSetter(y,"fillPriority","color"),o.Factory.addComponentsGetterSetter(y,"fillPatternOffset",["x","y"]),o.Factory.addGetterSetter(y,"fillPatternOffsetX",0,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"fillPatternOffsetY",0,(0,s.getNumberValidator)()),o.Factory.addComponentsGetterSetter(y,"fillPatternScale",["x","y"]),o.Factory.addGetterSetter(y,"fillPatternScaleX",1,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"fillPatternScaleY",1,(0,s.getNumberValidator)()),o.Factory.addComponentsGetterSetter(y,"fillLinearGradientStartPoint",["x","y"]),o.Factory.addComponentsGetterSetter(y,"strokeLinearGradientStartPoint",["x","y"]),o.Factory.addGetterSetter(y,"fillLinearGradientStartPointX",0),o.Factory.addGetterSetter(y,"strokeLinearGradientStartPointX",0),o.Factory.addGetterSetter(y,"fillLinearGradientStartPointY",0),o.Factory.addGetterSetter(y,"strokeLinearGradientStartPointY",0),o.Factory.addComponentsGetterSetter(y,"fillLinearGradientEndPoint",["x","y"]),o.Factory.addComponentsGetterSetter(y,"strokeLinearGradientEndPoint",["x","y"]),o.Factory.addGetterSetter(y,"fillLinearGradientEndPointX",0),o.Factory.addGetterSetter(y,"strokeLinearGradientEndPointX",0),o.Factory.addGetterSetter(y,"fillLinearGradientEndPointY",0),o.Factory.addGetterSetter(y,"strokeLinearGradientEndPointY",0),o.Factory.addComponentsGetterSetter(y,"fillRadialGradientStartPoint",["x","y"]),o.Factory.addGetterSetter(y,"fillRadialGradientStartPointX",0),o.Factory.addGetterSetter(y,"fillRadialGradientStartPointY",0),o.Factory.addComponentsGetterSetter(y,"fillRadialGradientEndPoint",["x","y"]),o.Factory.addGetterSetter(y,"fillRadialGradientEndPointX",0),o.Factory.addGetterSetter(y,"fillRadialGradientEndPointY",0),o.Factory.addGetterSetter(y,"fillPatternRotation",0),o.Factory.addGetterSetter(y,"fillRule",void 0,(0,s.getStringValidator)()),o.Factory.backCompat(y,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})},4821:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Arc=void 0;const r=n(4892),i=n(4723),o=n(8871),a=n(5483),s=n(8871);class l extends i.Shape{_sceneFunc(t){const e=o.Konva.getAngle(this.angle()),n=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,n),t.arc(0,0,this.innerRadius(),e,0,!n),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),n=this.clockwise(),r=o.Konva.getAngle(n?360-this.angle():this.angle()),i=Math.cos(Math.min(r,Math.PI)),a=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),s=Math.sin(Math.min(r,Math.PI/2)),l=i*(i>0?t:e),c=a*(a>0?t:e),h=s*(s>0?e:t);return{x:l,y:n?-1*h:c,width:1*e-l,height:h-c}}}e.Arc=l,l.prototype._centroid=!0,l.prototype.className="Arc",l.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],(0,s._registerNode)(l),r.Factory.addGetterSetter(l,"innerRadius",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(l,"outerRadius",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(l,"angle",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(l,"clockwise",!1,(0,a.getBooleanValidator)())},4843:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HSV=void 0;const r=n(4892),i=n(6536),o=n(5483);e.HSV=function(t){const e=t.data,n=e.length,r=Math.pow(2,this.value()),i=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,a=r*i*Math.cos(o*Math.PI/180),s=r*i*Math.sin(o*Math.PI/180),l=.299*r+.701*a+.167*s,c=.587*r-.587*a+.33*s,h=.114*r-.114*a-.497*s,u=.299*r-.299*a-.328*s,d=.587*r+.413*a+.035*s,f=.114*r-.114*a+.293*s,g=.299*r-.3*a+1.25*s,p=.587*r-.586*a-1.05*s,m=.114*r+.886*a-.2*s;for(let t=0;t<n;t+=4){const n=e[t+0],r=e[t+1],i=e[t+2],o=e[t+3];e[t+0]=l*n+c*r+h*i,e[t+1]=u*n+d*r+f*i,e[t+2]=g*n+p*r+m*i,e[t+3]=o}},r.Factory.addGetterSetter(i.Node,"hue",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"saturation",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"value",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},4884:(t,e,n)=>{"use strict";n.d(e,{A:()=>s});var r=n(1354),i=n.n(r),o=n(6314),a=n.n(o)()(i());a.push([t.id,".eda-pmpo-tooltip-line {\n display: flex;\n align-items: center;\n gap: 6px;\n margin-left: 6px;\n}\n\n.eda-pmpo-box {\n width: 10px;\n height: 10px;\n}\n\n.eda-pmpo-input-form {\n padding-left: 10px;\n padding-right: 5px;\n}\n\n.eda-pmpo-title {\n font-size: 14.5px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n pointer-events: none;\n white-space: nowrap;\n}\n\n.eda-pmpo-centered-text {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n width: 100%;\n text-align: center;\n}","",{version:3,sources:["webpack://./css/pmpo.css"],names:[],mappings:"AAAA;EACE,aAAa;EACb,mBAAmB;EACnB,QAAQ;EACR,gBAAgB;AAClB;;AAEA;EACE,WAAW;EACX,YAAY;AACd;;AAEA;EACE,kBAAkB;EAClB,kBAAkB;AACpB;;AAEA;EACE,iBAAiB;EACjB,kBAAkB;EAClB,QAAQ;EACR,SAAS;EACT,gCAAgC;EAChC,oBAAoB;EACpB,mBAAmB;AACrB;;AAEA;EACE,aAAa;EACb,uBAAuB;EACvB,mBAAmB;EACnB,YAAY;EACZ,WAAW;EACX,kBAAkB;AACpB",sourcesContent:[".eda-pmpo-tooltip-line {\n display: flex;\n align-items: center;\n gap: 6px;\n margin-left: 6px;\n}\n\n.eda-pmpo-box {\n width: 10px;\n height: 10px;\n}\n\n.eda-pmpo-input-form {\n padding-left: 10px;\n padding-right: 5px;\n}\n\n.eda-pmpo-title {\n font-size: 14.5px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n pointer-events: none;\n white-space: nowrap;\n}\n\n.eda-pmpo-centered-text {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n width: 100%;\n text-align: center;\n}"],sourceRoot:""}]);const s=a},4892:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Factory=void 0;const r=n(4060),i=n(5483),o="get",a="set";e.Factory={addGetterSetter(t,n,r,i,o){e.Factory.addGetter(t,n,r),e.Factory.addSetter(t,n,i,o),e.Factory.addOverloadedGetterSetter(t,n)},addGetter(t,e,n){const i=o+r.Util._capitalize(e);t.prototype[i]=t.prototype[i]||function(){const t=this.attrs[e];return void 0===t?n:t}},addSetter(t,n,i,o){const s=a+r.Util._capitalize(n);t.prototype[s]||e.Factory.overWriteSetter(t,n,i,o)},overWriteSetter(t,e,n,i){const o=a+r.Util._capitalize(e);t.prototype[o]=function(t){return n&&null!=t&&(t=n.call(this,t,e)),this._setAttr(e,t),i&&i.call(this),this}},addComponentsGetterSetter(t,n,s,l,c){const h=s.length,u=r.Util._capitalize,d=o+u(n),f=a+u(n);t.prototype[d]=function(){const t={};for(let e=0;e<h;e++){const r=s[e];t[r]=this.getAttr(n+u(r))}return t};const g=(0,i.getComponentValidator)(s);t.prototype[f]=function(t){const e=this.attrs[n];l&&(t=l.call(this,t,n)),g&&g.call(this,t,n);for(const e in t)t.hasOwnProperty(e)&&this._setAttr(n+u(e),t[e]);return t||s.forEach(t=>{this._setAttr(n+u(t),void 0)}),this._fireChangeEvent(n,e,t),c&&c.call(this),this},e.Factory.addOverloadedGetterSetter(t,n)},addOverloadedGetterSetter(t,e){const n=r.Util._capitalize(e),i=a+n,s=o+n;t.prototype[e]=function(){return arguments.length?(this[i](arguments[0]),this):this[s]()}},addDeprecatedGetterSetter(t,n,i,a){r.Util.error("Adding deprecated "+n);const s=o+r.Util._capitalize(n),l=n+" property is deprecated and will be removed soon. Look at Konva change log for more information.";t.prototype[s]=function(){r.Util.error(l);const t=this.attrs[n];return void 0===t?i:t},e.Factory.addSetter(t,n,a,function(){r.Util.error(l)}),e.Factory.addOverloadedGetterSetter(t,n)},backCompat(t,e){r.Util.each(e,function(e,n){const i=t.prototype[n],s=o+r.Util._capitalize(e),l=a+r.Util._capitalize(e);function c(){i.apply(this,arguments),r.Util.error('"'+e+'" method is deprecated and will be removed soon. Use ""'+n+'" instead.')}t.prototype[e]=c,t.prototype[s]=c,t.prototype[l]=c})},afterSetFilter(){this._filterUpToDate=!1}}},4943:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Pixelate=void 0;const r=n(4892),i=n(4060),o=n(6536),a=n(5483);e.Pixelate=function(t){let e=Math.ceil(this.pixelSize()),n=t.width,r=t.height,o=Math.ceil(n/e),a=Math.ceil(r/e),s=t.data;if(e<=0)i.Util.error("pixelSize value can not be <= 0");else for(let t=0;t<o;t+=1)for(let i=0;i<a;i+=1){let o=0,a=0,l=0,c=0;const h=t*e,u=h+e,d=i*e,f=d+e;let g=0;for(let t=h;t<u;t+=1)if(!(t>=n))for(let e=d;e<f;e+=1){if(e>=r)continue;const i=4*(n*e+t);o+=s[i+0],a+=s[i+1],l+=s[i+2],c+=s[i+3],g+=1}o/=g,a/=g,l/=g,c/=g;for(let t=h;t<u;t+=1)if(!(t>=n))for(let e=d;e<f;e+=1){if(e>=r)continue;const i=4*(n*e+t);s[i+0]=o,s[i+1]=a,s[i+2]=l,s[i+3]=c}}},r.Factory.addGetterSetter(o.Node,"pixelSize",8,(0,a.getNumberValidator)(),r.Factory.afterSetFilter)},5056:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},5058:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Transformer=void 0;const r=n(4060),i=n(4892),o=n(6536),a=n(4723),s=n(5155),l=n(7949),c=n(8871),h=n(5483),u=n(8871),d="tr-konva",f=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(t=>t+`.${d}`).join(" "),g="nodesRect",p=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],m={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},y="ontouchstart"in c.Konva._global,v=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function _(t,e,n){const r=n.x+(t.x-n.x)*Math.cos(e)-(t.y-n.y)*Math.sin(e),i=n.y+(t.x-n.x)*Math.sin(e)+(t.y-n.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:r,y:i}}let w=0;class b extends l.Group{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(f,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return r.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return d+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter(t=>!t.isAncestorOf(this)||(r.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1));return this._nodes=t=e,1===t.length&&this.useSingleNodeRotation()?this.rotation(t[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()};if(t._attrsAffectingSize.length){const n=t._attrsAffectingSize.map(t=>t+"Change."+this._getEventNamespace()).join(" ");t.on(n,e)}t.on(p.map(t=>t+`.${this._getEventNamespace()}`).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)}),this._resetTransformCache(),!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,n=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(n,!1)}),t.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!e)return;const r=t.getAbsolutePosition(),i=r.x-e.x,o=r.y-e.y;this.nodes().forEach(e=>{if(e===t)return;if(e.isDragging())return;const r=e.getAbsolutePosition();e.setAbsolutePosition({x:r.x+i,y:r.y+o}),e.startDrag(n)}),e=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(t=>{t.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(g),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(g,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),n){const r=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),i=t.getAbsoluteScale(n),o=t.getAbsolutePosition(n),a=r.x*i.x-t.offsetX()*i.x,s=r.y*i.y-t.offsetY()*i.y,l=(c.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return _({x:o.x+a*Math.cos(l)+s*Math.sin(-l),y:o.y+s*Math.cos(l)+a*Math.sin(l),width:r.width*i.x,height:r.height*i.y,rotation:l},-c.Konva.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const t=[];this.nodes().map(e=>{const n=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}],i=e.getAbsoluteTransform();r.forEach(function(e){const n=i.point(e);t.push(n)})});const e=new r.Transform;e.rotate(-c.Konva.getAngle(this.rotation()));let n=1/0,i=1/0,o=-1/0,a=-1/0;t.forEach(function(t){const r=e.point(t);void 0===n&&(n=o=r.x,i=a=r.y),n=Math.min(n,r.x),i=Math.min(i,r.y),o=Math.max(o,r.x),a=Math.max(a,r.y)}),e.invert();const s=e.point({x:n,y:i});return{x:s.x,y:s.y,width:o-n,height:a-i,rotation:c.Konva.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),v.forEach(t=>{this._createAnchor(t)}),this._createAnchor("rotater")}_createAnchor(t){const e=new s.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:y?10:"auto"}),n=this;e.on("mousedown touchstart",function(t){n._handleMouseDown(t)}),e.on("dragstart",t=>{e.stopDrag(),t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),e.on("mouseenter",()=>{const n=c.Konva.getAngle(this.rotation()),i=this.rotateAnchorCursor(),o=function(t,e,n){if("rotater"===t)return n;e+=r.Util.degToRad(m[t]||0);const i=(r.Util.radToDeg(e)%360+360)%360;return r.Util._inRange(i,337.5,360)||r.Util._inRange(i,0,22.5)?"ns-resize":r.Util._inRange(i,22.5,67.5)?"nesw-resize":r.Util._inRange(i,67.5,112.5)?"ew-resize":r.Util._inRange(i,112.5,157.5)?"nwse-resize":r.Util._inRange(i,157.5,202.5)?"ns-resize":r.Util._inRange(i,202.5,247.5)?"nesw-resize":r.Util._inRange(i,247.5,292.5)?"ew-resize":r.Util._inRange(i,292.5,337.5)?"nwse-resize":(r.Util.error("Transformer has unknown angle for cursor detection: "+i),"pointer")}(t,n,i);e.getStage().content&&(e.getStage().content.style.cursor=o),this._cursorChange=!0}),e.on("mouseout",()=>{e.getStage().content&&(e.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(e)}_createBack(){const t=new a.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(t,e){const n=e.getParent(),i=n.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.moveTo(e.width()/2,-i),n.rotateEnabled()&&n.rotateLineVisible()&&t.lineTo(e.width()/2,-n.rotateAnchorOffset()*r.Util._sign(e.height())-i),t.fillStrokeShape(e)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const n=this.padding();t.beginPath(),t.rect(-n,-n,e.width()+2*n,e.height()+2*n),t.fillStrokeShape(e)}});this.add(t),this._proxyDrag(t),t.on("dragstart",t=>{t.cancelBubble=!0}),t.on("dragmove",t=>{t.cancelBubble=!0}),t.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(t){if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const e=this._getNodeRect(),n=e.width,r=e.height,i=Math.sqrt(Math.pow(n,2)+Math.pow(r,2));this.sin=Math.abs(r/i),this.cos=Math.abs(n/i),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const o=t.target.getAbsolutePosition(),a=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:a.x-o.x,y:a.y-o.y},w++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach(e=>{e._fire("transformstart",{evt:t.evt,target:e})})}_handleMouseMove(t){let e,n,r;const i=this.findOne("."+this._movingAnchorName),o=i.getStage();o.setPointersPositions(t);const a=o.getPointerPosition();let s={x:a.x-this._anchorDragOffset.x,y:a.y-this._anchorDragOffset.y};const l=i.getAbsolutePosition();this.anchorDragBoundFunc()&&(s=this.anchorDragBoundFunc()(l,s,t)),i.setAbsolutePosition(s);const h=i.getAbsolutePosition();if(l.x===h.x&&l.y===h.y)return;if("rotater"===this._movingAnchorName){const r=this._getNodeRect();e=i.x()-r.width/2,n=-i.y()+r.height/2;let o=Math.atan2(-n,e)+Math.PI/2;r.height<0&&(o-=Math.PI);const a=c.Konva.getAngle(this.rotation())+o,s=c.Konva.getAngle(this.rotationSnapTolerance()),l=function(t,e,n){let r=e;for(let i=0;i<t.length;i++){const o=c.Konva.getAngle(t[i]),a=Math.abs(o-e)%(2*Math.PI);Math.min(a,2*Math.PI-a)<n&&(r=o)}return r}(this.rotationSnaps(),a,s),h=function(t,e){const n=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return _(t,e,n)}(r,l-r.rotation);return void this._fitNodesInto(h,t)}const u=this.shiftBehavior();let d;d="inverted"===u?this.keepRatio()&&!t.shiftKey:"none"===u?this.keepRatio():this.keepRatio()||t.shiftKey;let f=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(d){const t=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(t.x-i.x(),2)+Math.pow(t.y-i.y(),2));const o=this.findOne(".top-left").x()>t.x?-1:1,a=this.findOne(".top-left").y()>t.y?-1:1;e=r*this.cos*o,n=r*this.sin*a,this.findOne(".top-left").x(t.x-e),this.findOne(".top-left").y(t.y-n)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(i.y());else if("top-right"===this._movingAnchorName){if(d){const t=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(i.x()-t.x,2)+Math.pow(t.y-i.y(),2));const o=this.findOne(".top-right").x()<t.x?-1:1,a=this.findOne(".top-right").y()>t.y?-1:1;e=r*this.cos*o,n=r*this.sin*a,this.findOne(".top-right").x(t.x+e),this.findOne(".top-right").y(t.y-n)}var g=i.position();this.findOne(".top-left").y(g.y),this.findOne(".bottom-right").x(g.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(i.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(i.x());else if("bottom-left"===this._movingAnchorName){if(d){const t=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(t.x-i.x(),2)+Math.pow(i.y()-t.y,2));const o=t.x<i.x()?-1:1,a=i.y()<t.y?-1:1;e=r*this.cos*o,n=r*this.sin*a,i.x(t.x-e),i.y(t.y+n)}g=i.position(),this.findOne(".top-left").x(g.x),this.findOne(".bottom-right").y(g.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(i.y());else if("bottom-right"===this._movingAnchorName){if(d){const t=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(i.x()-t.x,2)+Math.pow(i.y()-t.y,2));const o=this.findOne(".bottom-right").x()<t.x?-1:1,a=this.findOne(".bottom-right").y()<t.y?-1:1;e=r*this.cos*o,n=r*this.sin*a,this.findOne(".bottom-right").x(t.x+e),this.findOne(".bottom-right").y(t.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(f=this.centeredScaling()||t.altKey,f){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),n=t.x(),r=t.y(),i=this.getWidth()-e.x(),o=this.getHeight()-e.y();e.move({x:-n,y:-r}),t.move({x:i,y:o})}const p=this.findOne(".top-left").getAbsolutePosition();e=p.x,n=p.y;const m=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),y=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:n,width:m,height:y,rotation:c.Konva.getAngle(this.rotation())},t)}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const n=this.getNode();w--,this._fire("transformend",{evt:t,target:n}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),n&&this._nodes.forEach(e=>{var n;e._fire("transformend",{evt:t,target:e}),null===(n=e.getLayer())||void 0===n||n.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(t,e){const n=this._getNodeRect();if(r.Util._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(r.Util._inRange(t.height,2*-this.padding()-1,1))return void this.update();const i=new r.Transform;if(i.rotate(c.Konva.getAngle(this.rotation())),this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){const e=i.point({x:2*-this.padding(),y:0});t.x+=e.x,t.y+=e.y,t.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){const e=i.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.width+=2*this.padding()}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){const e=i.point({x:0,y:2*-this.padding()});t.x+=e.x,t.y+=e.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const e=i.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}if(this.boundBoxFunc()){const e=this.boundBoxFunc()(n,t);e?t=e:r.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const o=1e7,a=new r.Transform;a.translate(n.x,n.y),a.rotate(n.rotation),a.scale(n.width/o,n.height/o);const s=new r.Transform,l=t.width/o,h=t.height/o;!1===this.flipEnabled()?(s.translate(t.x,t.y),s.rotate(t.rotation),s.translate(t.width<0?t.width:0,t.height<0?t.height:0),s.scale(Math.abs(l),Math.abs(h))):(s.translate(t.x,t.y),s.rotate(t.rotation),s.scale(l,h));const u=s.multiply(a.invert());this._nodes.forEach(t=>{var e;const n=t.getParent().getAbsoluteTransform(),i=t.getTransform().copy();i.translate(t.offsetX(),t.offsetY());const o=new r.Transform;o.multiply(n.copy().invert()).multiply(u).multiply(n).multiply(i);const a=o.decompose();t.setAttrs(a),null===(e=t.getLayer())||void 0===e||e.batchDraw()}),this.rotation(r.Util._getRotation(t.rotation)),this._nodes.forEach(t=>{this._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var t;const e=this._getNodeRect();this.rotation(r.Util._getRotation(e.rotation));const n=e.width,i=e.height,o=this.enabledAnchors(),a=this.resizeEnabled(),s=this.padding(),l=this.anchorSize(),c=this.find("._anchor");c.forEach(t=>{t.setAttrs({width:l,height:l,offsetX:l/2,offsetY:l/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:l/2+s,offsetY:l/2+s,visible:a&&o.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:l/2+s,visible:a&&o.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:l/2-s,offsetY:l/2+s,visible:a&&o.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:i/2,offsetX:l/2+s,visible:a&&o.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:i/2,offsetX:l/2-s,visible:a&&o.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:i,offsetX:l/2+s,offsetY:l/2-s,visible:a&&o.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:i,offsetY:l/2-s,visible:a&&o.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:i,offsetX:l/2-s,offsetY:l/2-s,visible:a&&o.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:n/2,y:-this.rotateAnchorOffset()*r.Util._sign(i)-s,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:i,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const h=this.anchorStyleFunc();h&&c.forEach(t=>{h(t)}),null===(t=this.getLayer())||void 0===t||t.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),l.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return o.Node.prototype.toObject.call(this)}clone(t){return o.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}e.Transformer=b,b.isTransforming=()=>w>0,b.prototype.className="Transformer",(0,u._registerNode)(b),i.Factory.addGetterSetter(b,"enabledAnchors",v,function(t){return t instanceof Array||r.Util.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach(function(t){-1===v.indexOf(t)&&r.Util.warn("Unknown anchor name: "+t+". Available names are: "+v.join(", "))}),t||[]}),i.Factory.addGetterSetter(b,"flipEnabled",!0,(0,h.getBooleanValidator)()),i.Factory.addGetterSetter(b,"resizeEnabled",!0),i.Factory.addGetterSetter(b,"anchorSize",10,(0,h.getNumberValidator)()),i.Factory.addGetterSetter(b,"rotateEnabled",!0),i.Factory.addGetterSetter(b,"rotateLineVisible",!0),i.Factory.addGetterSetter(b,"rotationSnaps",[]),i.Factory.addGetterSetter(b,"rotateAnchorOffset",50,(0,h.getNumberValidator)()),i.Factory.addGetterSetter(b,"rotateAnchorCursor","crosshair"),i.Factory.addGetterSetter(b,"rotationSnapTolerance",5,(0,h.getNumberValidator)()),i.Factory.addGetterSetter(b,"borderEnabled",!0),i.Factory.addGetterSetter(b,"anchorStroke","rgb(0, 161, 255)"),i.Factory.addGetterSetter(b,"anchorStrokeWidth",1,(0,h.getNumberValidator)()),i.Factory.addGetterSetter(b,"anchorFill","white"),i.Factory.addGetterSetter(b,"anchorCornerRadius",0,(0,h.getNumberValidator)()),i.Factory.addGetterSetter(b,"borderStroke","rgb(0, 161, 255)"),i.Factory.addGetterSetter(b,"borderStrokeWidth",1,(0,h.getNumberValidator)()),i.Factory.addGetterSetter(b,"borderDash"),i.Factory.addGetterSetter(b,"keepRatio",!0),i.Factory.addGetterSetter(b,"shiftBehavior","default"),i.Factory.addGetterSetter(b,"centeredScaling",!1),i.Factory.addGetterSetter(b,"ignoreStroke",!1),i.Factory.addGetterSetter(b,"padding",0,(0,h.getNumberValidator)()),i.Factory.addGetterSetter(b,"nodes"),i.Factory.addGetterSetter(b,"node"),i.Factory.addGetterSetter(b,"boundBoxFunc"),i.Factory.addGetterSetter(b,"anchorDragBoundFunc"),i.Factory.addGetterSetter(b,"anchorStyleFunc"),i.Factory.addGetterSetter(b,"shouldOverdrawWholeArea",!1),i.Factory.addGetterSetter(b,"useSingleNodeRotation",!0),i.Factory.backCompat(b,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"})},5072:t=>{"use strict";var e=[];function n(t){for(var n=-1,r=0;r<e.length;r++)if(e[r].identifier===t){n=r;break}return n}function r(t,r){for(var o={},a=[],s=0;s<t.length;s++){var l=t[s],c=r.base?l[0]+r.base:l[0],h=o[c]||0,u="".concat(c," ").concat(h);o[c]=h+1;var d=n(u),f={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(f);else{var g=i(f,r);r.byIndex=s,e.splice(s,0,{identifier:u,updater:g,references:1})}a.push(u)}return a}function i(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,i){var o=r(t=t||[],i=i||{});return function(t){t=t||[];for(var a=0;a<o.length;a++){var s=n(o[a]);e[s].references--}for(var l=r(t,i),c=0;c<o.length;c++){var h=n(o[c]);0===e[h].references&&(e[h].updater(),e.splice(h,1))}o=l}}},5155:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Rect=void 0;const r=n(4892),i=n(4723),o=n(8871),a=n(4060),s=n(5483);class l extends i.Shape{_sceneFunc(t){const e=this.cornerRadius(),n=this.width(),r=this.height();t.beginPath(),e?a.Util.drawRoundedRectPath(t,n,r,e):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)}}e.Rect=l,l.prototype.className="Rect",(0,o._registerNode)(l),r.Factory.addGetterSetter(l,"cornerRadius",0,(0,s.getNumberOrArrayOfNumbersValidator)(4))},5451:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Ring=void 0;const r=n(4892),i=n(4723),o=n(5483),a=n(8871),s=2*Math.PI;class l extends i.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,s,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),s,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}e.Ring=l,l.prototype.className="Ring",l.prototype._centroid=!0,l.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,a._registerNode)(l),r.Factory.addGetterSetter(l,"innerRadius",0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(l,"outerRadius",0,(0,o.getNumberValidator)())},5461:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HSL=void 0;const r=n(4892),i=n(6536),o=n(5483);r.Factory.addGetterSetter(i.Node,"hue",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"saturation",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"luminance",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter),e.HSL=function(t){const e=t.data,n=e.length,r=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,o=127*this.luminance(),a=1*r*Math.cos(i*Math.PI/180),s=1*r*Math.sin(i*Math.PI/180),l=.299+.701*a+.167*s,c=.587-.587*a+.33*s,h=.114-.114*a-.497*s,u=.299-.299*a-.328*s,d=.587+.413*a+.035*s,f=.114-.114*a+.293*s,g=.299-.3*a+1.25*s,p=.587-.586*a-1.05*s,m=.114+.886*a-.2*s;let y,v,_,w;for(let t=0;t<n;t+=4)y=e[t+0],v=e[t+1],_=e[t+2],w=e[t+3],e[t+0]=l*y+c*v+h*_+o,e[t+1]=u*y+d*v+f*_+o,e[t+2]=g*y+p*v+m*_+o,e[t+3]=w}},5483:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RGBComponent=function(t){return t>255?255:t<0?0:Math.round(t)},e.alphaComponent=function(t){return t>1?1:t<1e-4?1e-4:t},e.getNumberValidator=function(){if(r.Konva.isUnminified)return function(t,e){return i.Util._isNumber(t)||i.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}},e.getNumberOrArrayOfNumbersValidator=function(t){if(r.Konva.isUnminified)return function(e,n){let r=i.Util._isNumber(e),a=i.Util._isArray(e)&&e.length==t;return r||a||i.Util.warn(o(e)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+t+")"),e}},e.getNumberOrAutoValidator=function(){if(r.Konva.isUnminified)return function(t,e){return i.Util._isNumber(t)||"auto"===t||i.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}},e.getStringValidator=function(){if(r.Konva.isUnminified)return function(t,e){return i.Util._isString(t)||i.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}},e.getStringOrGradientValidator=function(){if(r.Konva.isUnminified)return function(t,e){const n=i.Util._isString(t),r="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return n||r||i.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}},e.getFunctionValidator=function(){if(r.Konva.isUnminified)return function(t,e){return i.Util._isFunction(t)||i.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),t}},e.getNumberArrayValidator=function(){if(r.Konva.isUnminified)return function(t,e){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&t instanceof n||(i.Util._isArray(t)?t.forEach(function(t){i.Util._isNumber(t)||i.Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):i.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}},e.getBooleanValidator=function(){if(r.Konva.isUnminified)return function(t,e){return!0===t||!1===t||i.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}},e.getComponentValidator=function(t){if(r.Konva.isUnminified)return function(e,n){return null==e||i.Util.isObject(e)||i.Util.warn(o(e)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+t),e}};const r=n(8871),i=n(4060);function o(t){return i.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||i.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}},5540:(t,e,n)=>{"use strict";t=n.hmd(t);var r,i=(r="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var e,n,i=void 0!==t?t:{};i.ready=new Promise(function(t,r){e=t,n=r});var o,a=Object.assign({},i),s="object"==typeof window,l="function"==typeof importScripts,c=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(s||l)&&(l?c=self.location.href:"undefined"!=typeof document&&document.currentScript&&(c=document.currentScript.src),r&&(c=r),c=0!==c.indexOf("blob:")?c.substr(0,c.replace(/[?#].*/,"").lastIndexOf("/")+1):"",l&&(o=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})),i.print||console.log.bind(console);var h,u,d=i.printErr||console.warn.bind(console);Object.assign(i,a),a=null,i.arguments&&i.arguments,i.thisProgram&&i.thisProgram,i.quit&&i.quit,i.wasmBinary&&(h=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&M("no native wasm support detected");var f,g,p,m=!1;function y(){var t=u.buffer;i.HEAP8=f=new Int8Array(t),i.HEAP16=new Int16Array(t),i.HEAP32=new Int32Array(t),i.HEAPU8=g=new Uint8Array(t),i.HEAPU16=new Uint16Array(t),i.HEAPU32=p=new Uint32Array(t),i.HEAPF32=new Float32Array(t),i.HEAPF64=new Float64Array(t)}var v=[],_=[],w=[];function b(t){v.unshift(t)}function C(t){w.unshift(t)}var x,S,A=0,E=null,T=null;function M(t){i.onAbort&&i.onAbort(t),d(t="Aborted("+t+")"),m=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}function P(t){return t.startsWith("data:application/octet-stream;base64,")}function N(t){try{if(t==x&&h)return new Uint8Array(h);if(o)return o(t);throw"both async and sync fetching of the wasm failed"}catch(t){M(t)}}function O(t,e,n){return function(t){return h||!s&&!l||"function"!=typeof fetch?Promise.resolve().then(function(){return N(t)}):fetch(t,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()}).catch(function(){return N(t)})}(t).then(function(t){return WebAssembly.instantiate(t,e)}).then(function(t){return t}).then(n,function(t){d("failed to asynchronously prepare wasm: "+t),M(t)})}function F(t){for(;t.length>0;)t.shift()(i)}function R(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){p[this.ptr+4>>2]=t},this.get_type=function(){return p[this.ptr+4>>2]},this.set_destructor=function(t){p[this.ptr+8>>2]=t},this.get_destructor=function(){return p[this.ptr+8>>2]},this.set_caught=function(t){t=t?1:0,f[this.ptr+12|0]=t},this.get_caught=function(){return 0!=f[this.ptr+12|0]},this.set_rethrown=function(t){t=t?1:0,f[this.ptr+13|0]=t},this.get_rethrown=function(){return 0!=f[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){p[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return p[this.ptr+16>>2]},this.get_exception_ptr=function(){if(W(this.get_type()))return p[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function I(t){var e=u.buffer;try{return u.grow(t-e.byteLength+65535>>>16),y(),1}catch(t){}}function D(t){return i["_"+t]}P(x="wasmDbscan.wasm")||(S=x,x=i.locateFile?i.locateFile(S,c):c+S);var L="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function k(t,e,n,r,i){var o={string:t=>{var e=0;return null!=t&&0!==t&&(e=function(t){var e=function(t){for(var e=0,n=0;n<t.length;++n){var r=t.charCodeAt(n);r<=127?e++:r<=2047?e+=2:r>=55296&&r<=57343?(e+=4,++n):e+=3}return e}(t)+1,n=H(e);return function(t,e,n){!function(t,e,n,r){if(!(r>0))return 0;for(var i=n+r-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}}e[n]=0}(t,g,e,n)}(t,n,e),n}(t)),e},array:t=>{var e,n,r=H(t.length);return e=t,n=r,f.set(e,n),r}},a=D(t),s=[],l=0;if(r)for(var c=0;c<r.length;c++){var h=o[n[c]];h?(0===l&&(l=B()),s[c]=h(r[c])):s[c]=r[c]}var u=a.apply(null,s);return function(t){return 0!==l&&V(l),function(t){return"string"===e?(n=t)?function(t,e,n){for(var r=e+n,i=e;t[i]&&!(i>=r);)++i;if(i-e>16&&t.buffer&&L)return L.decode(t.subarray(e,i));for(var o="";e<i;){var a=t[e++];if(128&a){var s=63&t[e++];if(192!=(224&a)){var l=63&t[e++];if((a=224==(240&a)?(15&a)<<12|s<<6|l:(7&a)<<18|s<<12|l<<6|63&t[e++])<65536)o+=String.fromCharCode(a);else{var c=a-65536;o+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else o+=String.fromCharCode((31&a)<<6|s)}else o+=String.fromCharCode(a)}return o}(g,n,r):"":"boolean"===e?Boolean(t):t;var n,r}(t)}(u)}var U,G={__cxa_throw:function(t,e,n){throw new R(t).init(e,n),t},abort:function(){M("")},emscripten_memcpy_big:function(t,e,n){g.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e=g.length,n=2147483648;if((t>>>=0)>n)return!1;let r=(t,e)=>t+(e-t%e)%e;for(var i=1;i<=4;i*=2){var o=e*(1+.2/i);if(o=Math.min(o,t+100663296),I(Math.min(n,r(Math.max(t,o),65536))))return!0}return!1}},B=(function(){var t,e,r,o,a={env:G,wasi_snapshot_preview1:G};function s(t,e){var n,r=t.exports;return i.asm=r,u=i.asm.memory,y(),i.asm.__indirect_function_table,n=i.asm.__wasm_call_ctors,_.unshift(n),function(){if(A--,i.monitorRunDependencies&&i.monitorRunDependencies(A),0==A&&(null!==E&&(clearInterval(E),E=null),T)){var t=T;T=null,t()}}(),r}if(A++,i.monitorRunDependencies&&i.monitorRunDependencies(A),i.instantiateWasm)try{return i.instantiateWasm(a,s)}catch(t){d("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=h,e=x,r=a,o=function(t){s(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||P(e)||"function"!=typeof fetch?O(e,r,o):fetch(e,{credentials:"same-origin"}).then(function(t){return WebAssembly.instantiateStreaming(t,r).then(o,function(t){return d("wasm streaming compile failed: "+t),d("falling back to ArrayBuffer instantiation"),O(e,r,o)})})).catch(n)}(),i._dbscan=function(){return(i._dbscan=i.asm.dbscan).apply(null,arguments)},i._malloc=function(){return(i._malloc=i.asm.malloc).apply(null,arguments)},i._free=function(){return(i._free=i.asm.free).apply(null,arguments)},function(){return(B=i.asm.stackSave).apply(null,arguments)}),V=function(){return(V=i.asm.stackRestore).apply(null,arguments)},H=function(){return(H=i.asm.stackAlloc).apply(null,arguments)},W=function(){return(W=i.asm.__cxa_is_pointer_type).apply(null,arguments)};function Y(){function t(){U||(U=!0,i.calledRun=!0,m||(F(_),e(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)C(i.postRun.shift());F(w)}()))}A>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)b(i.preRun.shift());F(v)}(),A>0||(i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),t()},1)):t()))}if(i.ccall=k,i.cwrap=function(t,e,n,r){var i=!n||n.every(t=>"number"===t||"boolean"===t);return"string"!==e&&i&&!r?D(t):function(){return k(t,e,n,arguments)}},T=function t(){U||Y(),U||(T=t)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return Y(),t.ready});"object"==typeof exports?t.exports=i:"function"==typeof define&&n.amdO?define([],function(){return i}):"object"==typeof exports&&(exports.exportCppDbscanLib=i)},5553:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Kaleidoscope=void 0;const r=n(4892),i=n(6536),o=n(4060),a=n(5483);e.Kaleidoscope=function(t){const e=t.width,n=t.height;let r,i,a,s,l,c,h,u,d,f,g=Math.round(this.kaleidoscopePower());const p=Math.round(this.kaleidoscopeAngle()),m=Math.floor(e*(p%360)/360);if(g<1)return;const y=o.Util.createCanvasElement();y.width=e,y.height=n;const v=y.getContext("2d").getImageData(0,0,e,n);o.Util.releaseCanvas(y),function(t,e,n){const r=t.data,i=e.data,o=t.width,a=t.height,s=n.polarCenterX||o/2,l=n.polarCenterY||a/2;let c=Math.sqrt(s*s+l*l),h=o-s,u=a-l;const d=Math.sqrt(h*h+u*u);c=d>c?d:c;const f=a,g=o,p=360/g*Math.PI/180;for(let t=0;t<g;t+=1){const e=Math.sin(t*p),n=Math.cos(t*p);for(let a=0;a<f;a+=1){h=Math.floor(s+c*a/f*n),u=Math.floor(l+c*a/f*e);let d=4*(u*o+h);const g=r[d+0],p=r[d+1],m=r[d+2],y=r[d+3];d=4*(t+a*o),i[d+0]=g,i[d+1]=p,i[d+2]=m,i[d+3]=y}}}(t,v,{polarCenterX:e/2,polarCenterY:n/2});let _=e/Math.pow(2,g);for(;_<=8;)_*=2,g-=1;_=Math.ceil(_);let w=_,b=0,C=w,x=1;for(m+_>e&&(b=w,C=0,x=-1),i=0;i<n;i+=1)for(r=b;r!==C;r+=x)a=Math.round(r+m)%e,d=4*(e*i+a),l=v.data[d+0],c=v.data[d+1],h=v.data[d+2],u=v.data[d+3],f=4*(e*i+r),v.data[f+0]=l,v.data[f+1]=c,v.data[f+2]=h,v.data[f+3]=u;for(i=0;i<n;i+=1)for(w=Math.floor(_),s=0;s<g;s+=1){for(r=0;r<w+1;r+=1)d=4*(e*i+r),l=v.data[d+0],c=v.data[d+1],h=v.data[d+2],u=v.data[d+3],f=4*(e*i+2*w-r-1),v.data[f+0]=l,v.data[f+1]=c,v.data[f+2]=h,v.data[f+3]=u;w*=2}!function(t,e,n){const r=t.data,i=e.data,o=t.width,a=t.height,s=n.polarCenterX||o/2,l=n.polarCenterY||a/2;let c=Math.sqrt(s*s+l*l),h=o-s,u=a-l;const d=Math.sqrt(h*h+u*u);c=d>c?d:c;const f=a,g=o,p=n.polarRotation||0;let m,y;for(h=0;h<o;h+=1)for(u=0;u<a;u+=1){const t=h-s,e=u-l,n=Math.sqrt(t*t+e*e)*f/c;let a=(180*Math.atan2(e,t)/Math.PI+360+p)%360;a=a*g/360,m=Math.floor(a),y=Math.floor(n);let d=4*(y*o+m);const v=r[d+0],_=r[d+1],w=r[d+2],b=r[d+3];d=4*(u*o+h),i[d+0]=v,i[d+1]=_,i[d+2]=w,i[d+3]=b}}(v,t,{polarRotation:0})},r.Factory.addGetterSetter(i.Node,"kaleidoscopePower",2,(0,a.getNumberValidator)(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"kaleidoscopeAngle",0,(0,a.getNumberValidator)(),r.Factory.afterSetFilter)},5570:(t,e)=>{"use strict";function n(t,e,n){const i=r(1,n,t),o=r(1,n,e),a=i*i+o*o;return Math.sqrt(a)}Object.defineProperty(e,"__esModule",{value:!0}),e.t2length=e.getQuadraticArcLength=e.getCubicArcLength=e.binomialCoefficients=e.cValues=e.tValues=void 0,e.tValues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],e.cValues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],e.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]],e.getCubicArcLength=(t,r,i)=>{let o,a;const s=i/2;o=0;for(let i=0;i<20;i++)a=s*e.tValues[20][i]+s,o+=e.cValues[20][i]*n(t,r,a);return s*o},e.getQuadraticArcLength=(t,e,n)=>{void 0===n&&(n=1);const r=t[0]-2*t[1]+t[2],i=e[0]-2*e[1]+e[2],o=2*t[1]-2*t[0],a=2*e[1]-2*e[0],s=4*(r*r+i*i),l=4*(r*o+i*a),c=o*o+a*a;if(0===s)return n*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const h=l/(2*s),u=n+h,d=c/s-h*h,f=u*u+d>0?Math.sqrt(u*u+d):0,g=h*h+d>0?Math.sqrt(h*h+d):0,p=h+Math.sqrt(h*h+d)!==0?d*Math.log(Math.abs((u+f)/(h+g))):0;return Math.sqrt(s)/2*(u*f-h*g+p)};const r=(t,n,i)=>{const o=i.length-1;let a,s;if(0===o)return 0;if(0===t){s=0;for(let t=0;t<=o;t++)s+=e.binomialCoefficients[o][t]*Math.pow(1-n,o-t)*Math.pow(n,t)*i[t];return s}a=new Array(o);for(let t=0;t<o;t++)a[t]=o*(i[t+1]-i[t]);return r(t-1,n,a)};e.t2length=(t,e,n)=>{let r=1,i=t/e,o=(t-n(i))/e,a=0;for(;r>.001;){const s=n(i+o),l=Math.abs(t-s)/e;if(l<r)r=l,i+=o;else{const a=n(i-o),s=Math.abs(t-a)/e;s<r?(r=s,i-=o):o/=2}if(a++,a>500)break}return i}},5778:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(8558);t.exports=r.Konva},5992:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Noise=void 0;const r=n(4892),i=n(6536),o=n(5483);e.Noise=function(t){const e=255*this.noise(),n=t.data,r=n.length,i=e/2;for(let t=0;t<r;t+=4)n[t+0]+=i-2*i*Math.random(),n[t+1]+=i-2*i*Math.random(),n[t+2]+=i-2*i*Math.random()},r.Factory.addGetterSetter(i.Node,"noise",.2,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},6261:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Blur=void 0;const r=n(4892),i=n(6536),o=n(5483);function a(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}const s=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],l=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];e.Blur=function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const n=t.data,r=t.width,i=t.height;let o,c,h,u,d,f,g,p,m,y,v,_,w,b,C,x,S,A,E,T;const M=e+e+1,P=r-1,N=i-1,O=e+1,F=O*(O+1)/2,R=new a,I=s[e],D=l[e];let L=null,k=R,U=null,G=null;for(let t=1;t<M;t++)k=k.next=new a,t===O&&(L=k);k.next=R,h=c=0;for(let t=0;t<i;t++){_=w=b=C=u=d=f=g=0,p=O*(x=n[c]),m=O*(S=n[c+1]),y=O*(A=n[c+2]),v=O*(E=n[c+3]),u+=F*x,d+=F*S,f+=F*A,g+=F*E,k=R;for(let t=0;t<O;t++)k.r=x,k.g=S,k.b=A,k.a=E,k=k.next;for(let t=1;t<O;t++)o=c+((P<t?P:t)<<2),u+=(k.r=x=n[o])*(T=O-t),d+=(k.g=S=n[o+1])*T,f+=(k.b=A=n[o+2])*T,g+=(k.a=E=n[o+3])*T,_+=x,w+=S,b+=A,C+=E,k=k.next;U=R,G=L;for(let t=0;t<r;t++)n[c+3]=E=g*I>>D,0!==E?(E=255/E,n[c]=(u*I>>D)*E,n[c+1]=(d*I>>D)*E,n[c+2]=(f*I>>D)*E):n[c]=n[c+1]=n[c+2]=0,u-=p,d-=m,f-=y,g-=v,p-=U.r,m-=U.g,y-=U.b,v-=U.a,o=h+((o=t+e+1)<P?o:P)<<2,_+=U.r=n[o],w+=U.g=n[o+1],b+=U.b=n[o+2],C+=U.a=n[o+3],u+=_,d+=w,f+=b,g+=C,U=U.next,p+=x=G.r,m+=S=G.g,y+=A=G.b,v+=E=G.a,_-=x,w-=S,b-=A,C-=E,G=G.next,c+=4;h+=r}for(let t=0;t<r;t++){w=b=C=_=d=f=g=u=0,c=t<<2,p=O*(x=n[c]),m=O*(S=n[c+1]),y=O*(A=n[c+2]),v=O*(E=n[c+3]),u+=F*x,d+=F*S,f+=F*A,g+=F*E,k=R;for(let t=0;t<O;t++)k.r=x,k.g=S,k.b=A,k.a=E,k=k.next;let a=r;for(let i=1;i<=e;i++)c=a+t<<2,u+=(k.r=x=n[c])*(T=O-i),d+=(k.g=S=n[c+1])*T,f+=(k.b=A=n[c+2])*T,g+=(k.a=E=n[c+3])*T,_+=x,w+=S,b+=A,C+=E,k=k.next,i<N&&(a+=r);c=t,U=R,G=L;for(let e=0;e<i;e++)o=c<<2,n[o+3]=E=g*I>>D,E>0?(E=255/E,n[o]=(u*I>>D)*E,n[o+1]=(d*I>>D)*E,n[o+2]=(f*I>>D)*E):n[o]=n[o+1]=n[o+2]=0,u-=p,d-=m,f-=y,g-=v,p-=U.r,m-=U.g,y-=U.b,v-=U.a,o=t+((o=e+O)<N?o:N)*r<<2,u+=_+=U.r=n[o],d+=w+=U.g=n[o+1],f+=b+=U.b=n[o+2],g+=C+=U.a=n[o+3],U=U.next,p+=x=G.r,m+=S=G.g,y+=A=G.b,v+=E=G.a,_-=x,w-=S,b-=A,C-=E,G=G.next,c+=r}}(t,e)},r.Factory.addGetterSetter(i.Node,"blurRadius",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},6267:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Layer=void 0;const r=n(4060),i=n(4473),o=n(6536),a=n(4892),s=n(8604),l=n(5483),c=n(4723),h=n(8871),u=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],d=u.length;class f extends i.Container{constructor(t){super(t),this.canvas=new s.SceneCanvas,this.hitCanvas=new s.HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){o.Node.prototype.moveToTop.call(this);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!o.Node.prototype.moveUp.call(this))return!1;const t=this.getStage();return!(!t||!t.content||(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),0))}moveDown(){if(o.Node.prototype.moveDown.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(o.Node.prototype.moveToBottom.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const t=this.getNativeCanvasElement();return o.Node.prototype.remove.call(this),t&&t.parentNode&&r.Util._isInDocument(t)&&t.parentNode.removeChild(t),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&r.Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t=t||{}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),o.Node.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){r.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){r.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,r.Util.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,n=!1;for(;;){for(let r=0;r<d;r++){const i=u[r],o=this._getIntersection({x:t.x+i.x*e,y:t.y+i.y*e}),a=o.shape;if(a)return a;if(n=!!o.antialiased,!o.antialiased)break}if(!n)return null;e+=1}}_getIntersection(t){const e=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(t.x*e),Math.round(t.y*e),1,1).data,i=n[3];if(255===i){const t=r.Util._rgbToHex(n[0],n[1],n[2]),e=c.shapes["#"+t];return e?{shape:e}:{antialiased:!0}}return i>0?{antialiased:!0}:{}}drawScene(t,e,n){const r=this.getLayer(),o=t||r&&r.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&o.getContext().clear(),i.Container.prototype.drawScene.call(this,o,e,n),this._fire("draw",{node:this}),this}drawHit(t,e){const n=this.getLayer(),r=t||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),i.Container.prototype.drawHit.call(this,r,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){r.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return r.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const t=this.parent;this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}destroy(){return r.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}e.Layer=f,f.prototype.nodeType="Layer",(0,h._registerNode)(f),a.Factory.addGetterSetter(f,"imageSmoothingEnabled",!0),a.Factory.addGetterSetter(f,"clearBeforeDraw",!0),a.Factory.addGetterSetter(f,"hitGraphEnabled",!0,(0,l.getBooleanValidator)())},6314:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n="",r=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),r&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),r&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n}).join("")},e.i=function(t,n,r,i,o){"string"==typeof t&&(t=[[null,t,void 0]]);var a={};if(r)for(var s=0;s<this.length;s++){var l=this[s][0];null!=l&&(a[l]=!0)}for(var c=0;c<t.length;c++){var h=[].concat(t[c]);r&&a[h[0]]||(void 0!==o&&(void 0===h[5]||(h[1]="@layer".concat(h[5].length>0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=o),n&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=n):h[2]=n),i&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=i):h[4]="".concat(i)),e.push(h))}},e}},6536:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Node=void 0;const r=n(8604),i=n(1268),o=n(4892),a=n(8871),s=n(4060),l=n(5483),c="absoluteOpacity",h="allEventListeners",u="absoluteTransform",d="absoluteScale",f="canvas",g="listening",p="Shape",m=" ",y="stage",v="transform",_="visible",w=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(m);let b=1;class C{constructor(t){this._id=b++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==v&&t!==u||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let n=this._cache.get(t);return(void 0===n||(t===v||t===u)&&!0===n.dirty)&&(n=e.call(this),this._cache.set(t,n)),n}_calculate(t,e,n){if(!this._attachedDepsListeners.get(t)){const n=e.map(t=>t+"Change.konva").join(m);this.on(n,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,n)}_getCanvasCache(){return this._cache.get(f)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===u&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(f)){const{scene:t,filter:e,hit:n,buffer:r}=this._cache.get(f);s.Util.releaseCanvas(t,e,n,r),this._cache.delete(f)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const e=t||{};let n={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let i=Math.ceil(e.width||n.width),o=Math.ceil(e.height||n.height),a=e.pixelRatio,l=void 0===e.x?Math.floor(n.x):e.x,h=void 0===e.y?Math.floor(n.y):e.y,u=e.offset||0,g=e.drawBorder||!1,p=e.hitCanvasPixelRatio||1;if(!i||!o)return void s.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");i+=2*u+(Math.abs(Math.round(n.x)-l)>.5?1:0),o+=2*u+(Math.abs(Math.round(n.y)-h)>.5?1:0),l-=u,h-=u;const m=new r.SceneCanvas({pixelRatio:a,width:i,height:o}),y=new r.SceneCanvas({pixelRatio:a,width:0,height:0,willReadFrequently:!0}),v=new r.HitCanvas({pixelRatio:p,width:i,height:o}),_=m.getContext(),w=v.getContext(),b=new r.SceneCanvas({width:m.width/m.pixelRatio+Math.abs(l),height:m.height/m.pixelRatio+Math.abs(h),pixelRatio:m.pixelRatio}),C=b.getContext();return v.isCache=!0,m.isCache=!0,this._cache.delete(f),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(m.getContext()._context.imageSmoothingEnabled=!1,y.getContext()._context.imageSmoothingEnabled=!1),_.save(),w.save(),C.save(),_.translate(-l,-h),w.translate(-l,-h),C.translate(-l,-h),b.x=l,b.y=h,this._isUnderCache=!0,this._clearSelfAndDescendantCache(c),this._clearSelfAndDescendantCache(d),this.drawScene(m,this,b),this.drawHit(v,this),this._isUnderCache=!1,_.restore(),w.restore(),g&&(_.save(),_.beginPath(),_.rect(0,0,i,o),_.closePath(),_.setAttr("strokeStyle","red"),_.setAttr("lineWidth",5),_.stroke(),_.restore()),this._cache.set(f,{scene:m,filter:y,hit:v,buffer:b,x:l,y:h}),this._requestDraw(),this}isCached(){return this._cache.has(f)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const n=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let r=1/0,i=1/0,o=-1/0,a=-1/0;const s=this.getAbsoluteTransform(e);return n.forEach(function(t){const e=s.point(t);void 0===r&&(r=o=e.x,i=a=e.y),r=Math.min(r,e.x),i=Math.min(i,e.y),o=Math.max(o,e.x),a=Math.max(a,e.y)}),{x:r,y:i,width:o-r,height:a-i}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const n=this._getCachedSceneCanvas(),r=n.pixelRatio;t.drawImage(n._canvas,0,0,n.width/r,n.height/r),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),n=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(n._canvas,0,0,n.width/n.pixelRatio,n.height/n.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t,e,n,r,i=this.filters(),o=this._getCanvasCache(),a=o.scene,l=o.filter,c=l.getContext();if(i){if(!this._filterUpToDate){const o=a.pixelRatio;l.setSize(a.width/a.pixelRatio,a.height/a.pixelRatio);try{for(t=i.length,c.clear(),c.drawImage(a._canvas,0,0,a.getWidth()/o,a.getHeight()/o),e=c.getImageData(0,0,l.getWidth(),l.getHeight()),n=0;n<t;n++)r=i[n],"function"==typeof r?(r.call(this,e),c.putImageData(e,0,0)):s.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(t){s.Util.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return l}return a}on(t,e){if(this._cache&&this._cache.delete(h),3===arguments.length)return this._delegate.apply(this,arguments);const n=t.split(m);for(let t=0;t<n.length;t++){const r=n[t].split("."),i=r[0],o=r[1]||"";this.eventListeners[i]||(this.eventListeners[i]=[]),this.eventListeners[i].push({name:o,handler:e})}return this}off(t,e){let n,r,i,o,a,s,l=(t||"").split(m),c=l.length;if(this._cache&&this._cache.delete(h),!t)for(r in this.eventListeners)this._off(r);for(n=0;n<c;n++)if(i=l[n],o=i.split("."),a=o[0],s=o[1],a)this.eventListeners[a]&&this._off(a,s,e);else for(r in this.eventListeners)this._off(r,s,e);return this}dispatchEvent(t){const e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,function(t){e.call(this,t.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,e,n){const r=this;this.on(t,function(t){const i=t.target.findAncestors(e,!0,r);for(let e=0;e<i.length;e++)(t=s.Util.cloneObject(t)).currentTarget=i[e],n.call(i[e],t)})}remove(){return this.isDragging()&&this.stopDrag(),i.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(u),this._clearSelfAndDescendantCache(c),this._clearSelfAndDescendantCache(d),this._clearSelfAndDescendantCache(y),this._clearSelfAndDescendantCache(_),this._clearSelfAndDescendantCache(g)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){const e="get"+s.Util._capitalize(t);return s.Util._isFunction(this[e])?this[e]():this.attrs[t]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let e,n;if(!t)return this;for(e in t)"children"!==e&&(n="set"+s.Util._capitalize(e),s.Util._isFunction(this[n])?this[n](t[e]):this._setAttr(e,t[e]))}),this}isListening(){return this._getCache(g,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(_,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);const n=this.getLayer();let r=!1;i.DD._dragElements.forEach(t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===n)&&(r=!0)});const o=!e&&!a.Konva.hitOnDragEnabled&&(r||a.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!o}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,n,r,i=this.getDepth(),o=this,a=0;const s=this.getStage();return"Stage"!==o.nodeType&&s&&function s(l){for(t=[],e=l.length,n=0;n<e;n++)r=l[n],a++,r.nodeType!==p&&(t=t.concat(r.getChildren().slice())),r._id===o._id&&(n=e);t.length>0&&t[0].getDepth()<=i&&s(t)}(s.getChildren()),a}getDepth(){let t=0,e=this.parent;for(;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(v),this._clearSelfAndDescendantCache(u)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges(()=>{this.x(t.x),this.y(t.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const e=t.getPointerPosition();if(!e)return null;const n=this.getAbsoluteTransform().copy();return n.invert(),n.point(e)}getAbsolutePosition(t){let e=!1,n=this.parent;for(;n;){if(n.isCached()){e=!0;break}n=n.parent}e&&!t&&(t=!0);const r=this.getAbsoluteTransform(t).getMatrix(),i=new s.Transform,o=this.offset();return i.m=r.slice(),i.translate(o.x,o.y),i.getTranslation()}setAbsolutePosition(t){const{x:e,y:n,...r}=this._clearTransform();this.attrs.x=e,this.attrs.y=n,this._clearCache(v);const i=this._getAbsoluteTransform().copy();return i.invert(),i.translate(t.x,t.y),t={x:this.attrs.x+i.getTranslation().x,y:this.attrs.y+i.getTranslation().y},this._setTransform(r),this.setPosition({x:t.x,y:t.y}),this._clearCache(v),this._clearSelfAndDescendantCache(u),this}_setTransform(t){let e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let e=t.x,n=t.y,r=this.x(),i=this.y();return void 0!==e&&(r+=e),void 0!==n&&(i+=n),this.setPosition({x:r,y:i}),this}_eachAncestorReverse(t,e){let n,r,i=[],o=this.getParent();if(!e||e._id!==this._id){for(i.unshift(this);o&&(!e||o._id!==e._id);)i.unshift(o),o=o.parent;for(n=i.length,r=0;r<n;r++)t(i[r])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return s.Util.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return s.Util.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return s.Util.warn("Node has no parent. moveDown function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return s.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(t){if(!this.parent)return s.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&s.Util.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(c,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t,e,n,r,i,o=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(t in o)e=o[t],i=s.Util.isObject(e)&&!s.Util._isPlainObject(e)&&!s.Util._isArray(e),i||(n="function"==typeof this[t]&&this[t],delete o[t],r=n?n.call(this):null,o[t]=e,r!==e&&(a.attrs[t]=e));return s.Util._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,n){const r=[];e&&this._isMatch(t)&&r.push(this);let i=this.parent;for(;i;){if(i===n)return r;i._isMatch(t)&&r.push(i),i=i.parent}return r}isAncestorOf(t){return!1}findAncestor(t,e,n){return this.findAncestors(t,e,n)[0]}_isMatch(t){if(!t)return!1;if("function"==typeof t)return t(this);let e,n,r=t.replace(/ /g,"").split(","),i=r.length;for(e=0;e<i;e++)if(n=r[e],s.Util.isValidSelector(n)||(s.Util.warn('Selector "'+n+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),s.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),s.Util.warn("Konva is awesome, right?")),"#"===n.charAt(0)){if(this.id()===n.slice(1))return!0}else if("."===n.charAt(0)){if(this.hasName(n.slice(1)))return!0}else if(this.className===n||this.nodeType===n)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(y,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e={},n){return e.target=e.target||this,n?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(u,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let e;if(t)return e=new s.Transform,this._eachAncestorReverse(function(t){const n=t.transformsEnabled();"all"===n?e.multiply(t.getTransform()):"position"===n&&e.translate(t.x()-t.offsetX(),t.y()-t.offsetY())},t),e;{e=this._cache.get(u)||new s.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset();const t=this.transformsEnabled();if("all"===t)e.multiply(this.getTransform());else if("position"===t){const t=this.attrs.x||0,n=this.attrs.y||0,r=this.attrs.offsetX||0,i=this.attrs.offsetY||0;e.translate(t-r,n-i)}return e.dirty=!1,e}}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const n=this.getAbsoluteTransform(t).decompose();return{x:n.scaleX,y:n.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(v,this._getTransform)}_getTransform(){var t,e;const n=this._cache.get(v)||new s.Transform;n.reset();const r=this.x(),i=this.y(),o=a.Konva.getAngle(this.rotation()),l=null!==(t=this.attrs.scaleX)&&void 0!==t?t:1,c=null!==(e=this.attrs.scaleY)&&void 0!==e?e:1,h=this.attrs.skewX||0,u=this.attrs.skewY||0,d=this.attrs.offsetX||0,f=this.attrs.offsetY||0;return 0===r&&0===i||n.translate(r,i),0!==o&&n.rotate(o),0===h&&0===u||n.skew(h,u),1===l&&1===c||n.scale(l,c),0===d&&0===f||n.translate(-1*d,-1*f),n.dirty=!1,n}clone(t){let e,n,r,i,o,a=s.Util.cloneObject(this.attrs);for(e in t)a[e]=t[e];const l=new this.constructor(a);for(e in this.eventListeners)for(n=this.eventListeners[e],r=n.length,i=0;i<r;i++)o=n[i],o.name.indexOf("konva")<0&&(l.eventListeners[e]||(l.eventListeners[e]=[]),l.eventListeners[e].push(o));return l}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),n=this.getStage(),i=void 0!==t.x?t.x:Math.floor(e.x),o=void 0!==t.y?t.y:Math.floor(e.y),a=t.pixelRatio||1,s=new r.SceneCanvas({width:t.width||Math.ceil(e.width)||(n?n.width():0),height:t.height||Math.ceil(e.height)||(n?n.height():0),pixelRatio:a}),l=s.getContext(),c=new r.SceneCanvas({width:s.width/s.pixelRatio+Math.abs(i),height:s.height/s.pixelRatio+Math.abs(o),pixelRatio:s.pixelRatio});return!1===t.imageSmoothingEnabled&&(l._context.imageSmoothingEnabled=!1),l.save(),(i||o)&&l.translate(-1*i,-1*o),this.drawScene(s,void 0,c),l.restore(),s}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,n=t.quality||null,r=this._toKonvaCanvas(t).toDataURL(e,n);return t.callback&&t.callback(r),r}toImage(t){return new Promise((e,n)=>{try{const n=null==t?void 0:t.callback;n&&delete t.callback,s.Util._urlToImage(this.toDataURL(t),function(t){e(t),null==n||n(t)})}catch(t){n(t)}})}toBlob(t){return new Promise((e,n)=>{try{const n=null==t?void 0:t.callback;n&&delete t.callback,this.toCanvas(t).toBlob(t=>{e(t),null==n||n(t)},null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){n(t)}})}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():a.Konva.dragDistance}_off(t,e,n){let r,i,o,a=this.eventListeners[t];for(r=0;r<a.length;r++)if(i=a[r].name,o=a[r].handler,!("konva"===i&&"konva"!==e||e&&i!==e||n&&n!==o)){if(a.splice(r,1),0===a.length){delete this.eventListeners[t];break}r--}}_fireChangeEvent(t,e,n){this._fire(t+"Change",{oldVal:e,newVal:n})}addName(t){if(!this.hasName(t)){const e=this.name(),n=e?e+" "+t:t;this.name(n)}return this}hasName(t){if(!t)return!1;const e=this.name();return!!e&&-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){const e=(this.name()||"").split(/\s/g),n=e.indexOf(t);return-1!==n&&(e.splice(n,1),this.name(e.join(" "))),this}setAttr(t,e){const n=this["set"+s.Util._capitalize(t)];return s.Util._isFunction(n)?n.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(a.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){const n=this.attrs[t];(n!==e||s.Util.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._shouldFireChangeEvents&&this._fireChangeEvent(t,n,e),this._requestDraw())}_setComponentAttr(t,e,n){let r;void 0!==n&&(r=this.attrs[t],r||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=n,this._fireChangeEvent(t,r,n))}_fireAndBubble(t,e,n){e&&this.nodeType===p&&(e.target=this);const r=["mouseenter","mouseleave","pointerenter","pointerleave","touchenter","touchleave"];if(-1===r.indexOf(t)||!(n&&(this===n||this.isAncestorOf&&this.isAncestorOf(n))||"Stage"===this.nodeType&&!n)){this._fire(t,e);const i=-1!==r.indexOf(t)&&n&&n.isAncestorOf&&n.isAncestorOf(this)&&!n.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!i&&(n&&n.parent?this._fireAndBubble.call(this.parent,t,e,n):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,n,r;const i=null!==(e=this._cache.get(h))&&void 0!==e?e:{};let o=null==i?void 0:i[t];if(void 0===o){o=[];let e=Object.getPrototypeOf(this);for(;e;){const i=null!==(r=null===(n=e.eventListeners)||void 0===n?void 0:n[t])&&void 0!==r?r:[];o.push(...i),e=Object.getPrototypeOf(e)}i[t]=o,this._cache.set(h,i)}return o}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const n=this._getProtoListeners(t);if(n)for(let t=0;t<n.length;t++)n[t].handler.call(this,e);const r=this.eventListeners[t];if(r)for(let t=0;t<r.length;t++)r[t].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,n=this.getStage(),r=this.getAbsolutePosition();if(!n)return;const o=n._getPointerById(e)||n._changedPointerPositions[0]||r;i.DD._dragElements.set(this._id,{node:this,startPointerPos:o,offset:{x:o.x-r.x,y:o.y-r.y},dragStatus:"ready",pointerId:e})}startDrag(t,e=!0){i.DD._dragElements.has(this._id)||this._createDragElement(t),i.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(t,e){const n=this.getStage()._getPointerById(e.pointerId);if(!n)return;let r={x:n.x-e.offset.x,y:n.y-e.offset.y};const i=this.dragBoundFunc();if(void 0!==i){const e=i.call(this,r,t);e?r=e:s.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}stopDrag(t){const e=i.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),i.DD._endDragBefore(t),i.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=i.DD._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(t){if(!(void 0===t.evt.button||a.Konva.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;i.DD._dragElements.forEach(t=>{this.isAncestorOf(t.node)&&(e=!0)}),e||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const t=i.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,n=t&&"ready"===t.dragStatus;e?this.stopDrag():n&&i.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const e=this.getStage();if(!e)return!1;const n={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return s.Util.haveIntersection(n,this.getClientRect())}static create(t,e){return s.Util._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){let n,r,i,o=C.prototype.getClassName.call(t),l=t.children;if(e&&(t.attrs.container=e),a.Konva[o]||(s.Util.warn('Can not find a node with class name "'+o+'". Fallback to "Shape".'),o="Shape"),n=new(0,a.Konva[o])(t.attrs),l)for(r=l.length,i=0;i<r;i++)n.add(C._createNode(l[i]));return n}}e.Node=C,C.prototype.nodeType="Node",C.prototype._attrsAffectingSize=[],C.prototype.eventListeners={},C.prototype.on.call(C.prototype,w,function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(v),this._clearSelfAndDescendantCache(u))}),C.prototype.on.call(C.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(_)}),C.prototype.on.call(C.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(g)}),C.prototype.on.call(C.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(c)});const x=o.Factory.addGetterSetter;x(C,"zIndex"),x(C,"absolutePosition"),x(C,"position"),x(C,"x",0,(0,l.getNumberValidator)()),x(C,"y",0,(0,l.getNumberValidator)()),x(C,"globalCompositeOperation","source-over",(0,l.getStringValidator)()),x(C,"opacity",1,(0,l.getNumberValidator)()),x(C,"name","",(0,l.getStringValidator)()),x(C,"id","",(0,l.getStringValidator)()),x(C,"rotation",0,(0,l.getNumberValidator)()),o.Factory.addComponentsGetterSetter(C,"scale",["x","y"]),x(C,"scaleX",1,(0,l.getNumberValidator)()),x(C,"scaleY",1,(0,l.getNumberValidator)()),o.Factory.addComponentsGetterSetter(C,"skew",["x","y"]),x(C,"skewX",0,(0,l.getNumberValidator)()),x(C,"skewY",0,(0,l.getNumberValidator)()),o.Factory.addComponentsGetterSetter(C,"offset",["x","y"]),x(C,"offsetX",0,(0,l.getNumberValidator)()),x(C,"offsetY",0,(0,l.getNumberValidator)()),x(C,"dragDistance",void 0,(0,l.getNumberValidator)()),x(C,"width",0,(0,l.getNumberValidator)()),x(C,"height",0,(0,l.getNumberValidator)()),x(C,"listening",!0,(0,l.getBooleanValidator)()),x(C,"preventDefault",!0,(0,l.getBooleanValidator)()),x(C,"filters",void 0,function(t){return this._filterUpToDate=!1,t}),x(C,"visible",!0,(0,l.getBooleanValidator)()),x(C,"transformsEnabled","all",(0,l.getStringValidator)()),x(C,"size"),x(C,"dragBoundFunc"),x(C,"draggable",!1,(0,l.getBooleanValidator)()),o.Factory.backCompat(C,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"})},6564:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Invert=void 0,e.Invert=function(t){const e=t.data,n=e.length;for(let t=0;t<n;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]}},6572:function(t){var e;t.exports=(e=function(t,e){var n=Array.prototype.concat,r=Array.prototype.slice,i=Object.prototype.toString;function o(e,n){var r=e>n?e:n;return t.pow(10,17-~~(t.log(r>0?r:-r)*t.LOG10E))}var a=Array.isArray||function(t){return"[object Array]"===i.call(t)};function s(t){return"[object Function]"===i.call(t)}function l(t){return"number"==typeof t&&t-t===0}function c(){return new c._init(arguments)}function h(){return 0}function u(){return 1}function d(t,e){return t===e?1:0}c.fn=c.prototype,c._init=function(t){if(a(t[0]))if(a(t[0][0])){s(t[1])&&(t[0]=c.map(t[0],t[1]));for(var e=0;e<t[0].length;e++)this[e]=t[0][e];this.length=t[0].length}else this[0]=s(t[1])?c.map(t[0],t[1]):t[0],this.length=1;else if(l(t[0]))this[0]=c.seq.apply(null,t),this.length=1;else{if(t[0]instanceof c)return c(t[0].toArray());this[0]=[],this.length=1}return this},c._init.prototype=c.prototype,c._init.constructor=c,c.utils={calcRdx:o,isArray:a,isFunction:s,isNumber:l,toVector:function(t){return n.apply([],t)}},c._random_fn=t.random,c.setRandom=function(t){if("function"!=typeof t)throw new TypeError("fn is not a function");c._random_fn=t},c.extend=function(t){var e,n;if(1===arguments.length){for(n in t)c[n]=t[n];return this}for(e=1;e<arguments.length;e++)for(n in arguments[e])t[n]=arguments[e][n];return t},c.rows=function(t){return t.length||1},c.cols=function(t){return t[0].length||1},c.dimensions=function(t){return{rows:c.rows(t),cols:c.cols(t)}},c.row=function(t,e){return a(e)?e.map(function(e){return c.row(t,e)}):t[e]},c.rowa=function(t,e){return c.row(t,e)},c.col=function(t,e){if(a(e)){var n=c.arange(t.length).map(function(){return new Array(e.length)});return e.forEach(function(e,r){c.arange(t.length).forEach(function(i){n[i][r]=t[i][e]})}),n}for(var r=new Array(t.length),i=0;i<t.length;i++)r[i]=[t[i][e]];return r},c.cola=function(t,e){return c.col(t,e).map(function(t){return t[0]})},c.diag=function(t){for(var e=c.rows(t),n=new Array(e),r=0;r<e;r++)n[r]=[t[r][r]];return n},c.antidiag=function(t){for(var e=c.rows(t)-1,n=new Array(e),r=0;e>=0;e--,r++)n[r]=[t[r][e]];return n},c.transpose=function(t){var e,n,r,i,o,s=[];for(a(t[0])||(t=[t]),n=t.length,r=t[0].length,o=0;o<r;o++){for(e=new Array(n),i=0;i<n;i++)e[i]=t[i][o];s.push(e)}return 1===s.length?s[0]:s},c.map=function(t,e,n){var r,i,o,s,l;for(a(t[0])||(t=[t]),i=t.length,o=t[0].length,s=n?t:new Array(i),r=0;r<i;r++)for(s[r]||(s[r]=new Array(o)),l=0;l<o;l++)s[r][l]=e(t[r][l],r,l);return 1===s.length?s[0]:s},c.cumreduce=function(t,e,n){var r,i,o,s,l;for(a(t[0])||(t=[t]),i=t.length,o=t[0].length,s=n?t:new Array(i),r=0;r<i;r++)for(s[r]||(s[r]=new Array(o)),o>0&&(s[r][0]=t[r][0]),l=1;l<o;l++)s[r][l]=e(s[r][l-1],t[r][l]);return 1===s.length?s[0]:s},c.alter=function(t,e){return c.map(t,e,!0)},c.create=function(t,e,n){var r,i,o=new Array(t);for(s(e)&&(n=e,e=t),r=0;r<t;r++)for(o[r]=new Array(e),i=0;i<e;i++)o[r][i]=n(r,i);return o},c.zeros=function(t,e){return l(e)||(e=t),c.create(t,e,h)},c.ones=function(t,e){return l(e)||(e=t),c.create(t,e,u)},c.rand=function(t,e){return l(e)||(e=t),c.create(t,e,c._random_fn)},c.identity=function(t,e){return l(e)||(e=t),c.create(t,e,d)},c.symmetric=function(t){var e,n,r=t.length;if(t.length!==t[0].length)return!1;for(e=0;e<r;e++)for(n=0;n<r;n++)if(t[n][e]!==t[e][n])return!1;return!0},c.clear=function(t){return c.alter(t,h)},c.seq=function(t,e,n,r){s(r)||(r=!1);var i,a=[],l=o(t,e),c=(e*l-t*l)/((n-1)*l),h=t;for(i=0;h<=e&&i<n;h=(t*l+c*l*++i)/l)a.push(r?r(h,i):h);return a},c.arange=function(t,n,r){var i,o=[];if(r=r||1,n===e&&(n=t,t=0),t===n||0===r)return[];if(t<n&&r<0)return[];if(t>n&&r>0)return[];if(r>0)for(i=t;i<n;i+=r)o.push(i);else for(i=t;i>n;i+=r)o.push(i);return o},c.slice=function(){function t(t,n,r,i){var o,a=[],s=t.length;if(n===e&&r===e&&i===e)return c.copy(t);if(i=i||1,(n=(n=n||0)>=0?n:s+n)===(r=(r=r||t.length)>=0?r:s+r)||0===i)return[];if(n<r&&i<0)return[];if(n>r&&i>0)return[];if(i>0)for(o=n;o<r;o+=i)a.push(t[o]);else for(o=n;o>r;o+=i)a.push(t[o]);return a}return function(e,n){var r,i;return l((n=n||{}).row)?l(n.col)?e[n.row][n.col]:t(c.rowa(e,n.row),(r=n.col||{}).start,r.end,r.step):l(n.col)?t(c.cola(e,n.col),(i=n.row||{}).start,i.end,i.step):(i=n.row||{},r=n.col||{},t(e,i.start,i.end,i.step).map(function(e){return t(e,r.start,r.end,r.step)}))}}(),c.sliceAssign=function(n,r,i){var o,a;if(l(r.row)){if(l(r.col))return n[r.row][r.col]=i;r.col=r.col||{},r.col.start=r.col.start||0,r.col.end=r.col.end||n[0].length,r.col.step=r.col.step||1,o=c.arange(r.col.start,t.min(n.length,r.col.end),r.col.step);var s=r.row;return o.forEach(function(t,e){n[s][t]=i[e]}),n}if(l(r.col)){r.row=r.row||{},r.row.start=r.row.start||0,r.row.end=r.row.end||n.length,r.row.step=r.row.step||1,a=c.arange(r.row.start,t.min(n[0].length,r.row.end),r.row.step);var h=r.col;return a.forEach(function(t,e){n[t][h]=i[e]}),n}return i[0].length===e&&(i=[i]),r.row.start=r.row.start||0,r.row.end=r.row.end||n.length,r.row.step=r.row.step||1,r.col.start=r.col.start||0,r.col.end=r.col.end||n[0].length,r.col.step=r.col.step||1,a=c.arange(r.row.start,t.min(n.length,r.row.end),r.row.step),o=c.arange(r.col.start,t.min(n[0].length,r.col.end),r.col.step),a.forEach(function(t,e){o.forEach(function(r,o){n[t][r]=i[e][o]})}),n},c.diagonal=function(t){var e=c.zeros(t.length,t.length);return t.forEach(function(t,n){e[n][n]=t}),e},c.copy=function(t){return t.map(function(t){return l(t)?t:t.map(function(t){return t})})};var f=c.prototype;return f.length=0,f.push=Array.prototype.push,f.sort=Array.prototype.sort,f.splice=Array.prototype.splice,f.slice=Array.prototype.slice,f.toArray=function(){return this.length>1?r.call(this):r.call(this)[0]},f.map=function(t,e){return c(c.map(this,t,e))},f.cumreduce=function(t,e){return c(c.cumreduce(this,t,e))},f.alter=function(t){return c.alter(this,t),this},function(t){for(var e=0;e<t.length;e++)(function(t){f[t]=function(e){var n,r=this;return e?(setTimeout(function(){e.call(r,f[t].call(r))}),this):(n=c[t](this),a(n)?c(n):n)}})(t[e])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(t){for(var e=0;e<t.length;e++)(function(t){f[t]=function(e,n){var r=this;return n?(setTimeout(function(){n.call(r,f[t].call(r,e))}),this):c(c[t](this,e))}})(t[e])}("row col".split(" ")),function(t){for(var e=0;e<t.length;e++)(function(t){f[t]=function(){return c(c[t].apply(null,arguments))}})(t[e])}("create zeros ones rand identity".split(" ")),c}(Math),function(t,e){var n=t.utils.isFunction;function r(t,e){return t-e}function i(t,n,r){return e.max(n,e.min(t,r))}t.sum=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.sumsqrd=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n]*t[n];return e},t.sumsqerr=function(e){for(var n,r=t.mean(e),i=0,o=e.length;--o>=0;)i+=(n=e[o]-r)*n;return i},t.sumrow=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.product=function(t){for(var e=1,n=t.length;--n>=0;)e*=t[n];return e},t.min=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]<e&&(e=t[n]);return e},t.max=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]>e&&(e=t[n]);return e},t.unique=function(t){for(var e={},n=[],r=0;r<t.length;r++)e[t[r]]||(e[t[r]]=!0,n.push(t[r]));return n},t.mean=function(e){return t.sum(e)/e.length},t.meansqerr=function(e){return t.sumsqerr(e)/e.length},t.geomean=function(n){var r=n.map(e.log),i=t.mean(r);return e.exp(i)},t.median=function(t){var e=t.length,n=t.slice().sort(r);return 1&e?n[e/2|0]:(n[e/2-1]+n[e/2])/2},t.cumsum=function(e){return t.cumreduce(e,function(t,e){return t+e})},t.cumprod=function(e){return t.cumreduce(e,function(t,e){return t*e})},t.diff=function(t){var e,n=[],r=t.length;for(e=1;e<r;e++)n.push(t[e]-t[e-1]);return n},t.rank=function(t){var e,n=[],i={};for(e=0;e<t.length;e++)i[l=t[e]]?i[l]++:(i[l]=1,n.push(l));var o=n.sort(r),a={},s=1;for(e=0;e<o.length;e++){var l,c=i[l=o[e]],h=(s+(s+c-1))/2;a[l]=h,s+=c}return t.map(function(t){return a[t]})},t.mode=function(t){var e,n=t.length,i=t.slice().sort(r),o=1,a=0,s=0,l=[];for(e=0;e<n;e++)i[e]===i[e+1]?o++:(o>a?(l=[i[e]],a=o,s=0):o===a&&(l.push(i[e]),s++),o=1);return 0===s?l[0]:l},t.range=function(e){return t.max(e)-t.min(e)},t.variance=function(e,n){return t.sumsqerr(e)/(e.length-(n?1:0))},t.pooledvariance=function(e){return e.reduce(function(e,n){return e+t.sumsqerr(n)},0)/(e.reduce(function(t,e){return t+e.length},0)-e.length)},t.deviation=function(e){for(var n=t.mean(e),r=e.length,i=new Array(r),o=0;o<r;o++)i[o]=e[o]-n;return i},t.stdev=function(n,r){return e.sqrt(t.variance(n,r))},t.pooledstdev=function(n){return e.sqrt(t.pooledvariance(n))},t.meandev=function(n){for(var r=t.mean(n),i=[],o=n.length-1;o>=0;o--)i.push(e.abs(n[o]-r));return t.mean(i)},t.meddev=function(n){for(var r=t.median(n),i=[],o=n.length-1;o>=0;o--)i.push(e.abs(n[o]-r));return t.median(i)},t.coeffvar=function(e){return t.stdev(e)/t.mean(e)},t.quartiles=function(t){var n=t.length,i=t.slice().sort(r);return[i[e.round(n/4)-1],i[e.round(n/2)-1],i[e.round(3*n/4)-1]]},t.quantiles=function(t,n,o,a){var s,l,c,h,u,d=t.slice().sort(r),f=[n.length],g=t.length;for(void 0===o&&(o=3/8),void 0===a&&(a=3/8),s=0;s<n.length;s++)c=g*(l=n[s])+(o+l*(1-o-a)),h=e.floor(i(c,1,g-1)),u=i(c-h,0,1),f[s]=(1-u)*d[h-1]+u*d[h];return f},t.percentile=function(t,e,n){var i=t.slice().sort(r),o=e*(i.length+(n?1:-1))+(n?0:1),a=parseInt(o),s=o-a;return a+1<i.length?i[a-1]+s*(i[a]-i[a-1]):i[a-1]},t.percentileOfScore=function(t,e,n){var r,i,o=0,a=t.length,s=!1;for("strict"===n&&(s=!0),i=0;i<a;i++)r=t[i],(s&&r<e||!s&&r<=e)&&o++;return o/a},t.histogram=function(n,r){r=r||4;var i,o=t.min(n),a=(t.max(n)-o)/r,s=n.length,l=[];for(i=0;i<r;i++)l[i]=0;for(i=0;i<s;i++)l[e.min(e.floor((n[i]-o)/a),r-1)]+=1;return l},t.covariance=function(e,n){var r,i=t.mean(e),o=t.mean(n),a=e.length,s=new Array(a);for(r=0;r<a;r++)s[r]=(e[r]-i)*(n[r]-o);return t.sum(s)/(a-1)},t.corrcoeff=function(e,n){return t.covariance(e,n)/t.stdev(e,1)/t.stdev(n,1)},t.spearmancoeff=function(e,n){return e=t.rank(e),n=t.rank(n),t.corrcoeff(e,n)},t.stanMoment=function(n,r){for(var i=t.mean(n),o=t.stdev(n),a=n.length,s=0,l=0;l<a;l++)s+=e.pow((n[l]-i)/o,r);return s/n.length},t.skewness=function(e){return t.stanMoment(e,3)},t.kurtosis=function(e){return t.stanMoment(e,4)-3};var o=t.prototype;!function(e){for(var r=0;r<e.length;r++)(function(e){o[e]=function(r,i){var a=[],s=0,l=this;if(n(r)&&(i=r,r=!1),i)return setTimeout(function(){i.call(l,o[e].call(l,r))}),this;if(this.length>1){for(l=!0===r?this:this.transpose();s<l.length;s++)a[s]=t[e](l[s]);return a}return t[e](this[0],r)}})(e[r])}("cumsum cumprod".split(" ")),function(e){for(var r=0;r<e.length;r++)(function(e){o[e]=function(r,i){var a=[],s=0,l=this;if(n(r)&&(i=r,r=!1),i)return setTimeout(function(){i.call(l,o[e].call(l,r))}),this;if(this.length>1){for("sumrow"!==e&&(l=!0===r?this:this.transpose());s<l.length;s++)a[s]=t[e](l[s]);return!0===r?t[e](t.utils.toVector(a)):a}return t[e](this[0],r)}})(e[r])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(e){for(var r=0;r<e.length;r++)(function(e){o[e]=function(){var r,i=[],a=0,s=this,l=Array.prototype.slice.call(arguments);if(n(l[l.length-1])){r=l[l.length-1];var c=l.slice(0,l.length-1);return setTimeout(function(){r.call(s,o[e].apply(s,c))}),this}r=void 0;var h=function(n){return t[e].apply(s,[n].concat(l))};if(this.length>1){for(s=s.transpose();a<s.length;a++)i[a]=h(s[a]);return i}return h(this[0])}})(e[r])}("quantiles percentileOfScore".split(" "))}(e,Math),function(t,e){t.gammaln=function(t){var n,r,i,o=0,a=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],s=1.000000000190015;for(i=(r=n=t)+5.5,i-=(n+.5)*e.log(i);o<6;o++)s+=a[o]/++r;return e.log(2.5066282746310007*s/n)-i},t.loggam=function(t){var n,r,i,o,a,s,l,c=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=t,l=0,1==t||2==t)return 0;for(t<=7&&(n=t+(l=e.floor(7-t))),r=1/(n*n),i=2*e.PI,a=c[9],s=8;s>=0;s--)a*=r,a+=c[s];if(o=a/n+.5*e.log(i)+(n-.5)*e.log(n)-n,t<=7)for(s=1;s<=l;s++)o-=e.log(n-1),n-=1;return o},t.gammafn=function(t){var n,r,i,o,a=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],s=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],l=!1,c=0,h=0,u=0,d=t;if(t>171.6243769536076)return 1/0;if(d<=0){if(!(o=d%1+36e-17))return 1/0;l=(1&d?-1:1)*e.PI/e.sin(e.PI*o),d=1-d}for(i=d,r=d<1?d++:(d-=c=(0|d)-1)-1,n=0;n<8;++n)u=(u+a[n])*r,h=h*r+s[n];if(o=u/h+1,i<d)o/=i;else if(i>d)for(n=0;n<c;++n)o*=d,d++;return l&&(o=l/o),o},t.gammap=function(e,n){return t.lowRegGamma(e,n)*t.gammafn(e)},t.lowRegGamma=function(n,r){var i,o=t.gammaln(n),a=n,s=1/n,l=s,c=r+1-n,h=1/1e-30,u=1/c,d=u,f=1,g=-~(8.5*e.log(n>=1?n:1/n)+.4*n+17);if(r<0||n<=0)return NaN;if(r<n+1){for(;f<=g;f++)s+=l*=r/++a;return s*e.exp(-r+n*e.log(r)-o)}for(;f<=g;f++)d*=(u=1/(u=(i=-f*(f-n))*u+(c+=2)))*(h=c+i/h);return 1-d*e.exp(-r+n*e.log(r)-o)},t.factorialln=function(e){return e<0?NaN:t.gammaln(e+1)},t.factorial=function(e){return e<0?NaN:t.gammafn(e+1)},t.combination=function(n,r){return n>170||r>170?e.exp(t.combinationln(n,r)):t.factorial(n)/t.factorial(r)/t.factorial(n-r)},t.combinationln=function(e,n){return t.factorialln(e)-t.factorialln(n)-t.factorialln(e-n)},t.permutation=function(e,n){return t.factorial(e)/t.factorial(e-n)},t.betafn=function(n,r){if(!(n<=0||r<=0))return n+r>170?e.exp(t.betaln(n,r)):t.gammafn(n)*t.gammafn(r)/t.gammafn(n+r)},t.betaln=function(e,n){return t.gammaln(e)+t.gammaln(n)-t.gammaln(e+n)},t.betacf=function(t,n,r){var i,o,a,s,l=1e-30,c=1,h=n+r,u=n+1,d=n-1,f=1,g=1-h*t/u;for(e.abs(g)<l&&(g=l),s=g=1/g;c<=100&&(g=1+(o=c*(r-c)*t/((d+(i=2*c))*(n+i)))*g,e.abs(g)<l&&(g=l),f=1+o/f,e.abs(f)<l&&(f=l),s*=(g=1/g)*f,g=1+(o=-(n+c)*(h+c)*t/((n+i)*(u+i)))*g,e.abs(g)<l&&(g=l),f=1+o/f,e.abs(f)<l&&(f=l),s*=a=(g=1/g)*f,!(e.abs(a-1)<3e-7));c++);return s},t.gammapinv=function(n,r){var i,o,a,s,l,c,h=0,u=r-1,d=t.gammaln(r);if(n>=1)return e.max(100,r+100*e.sqrt(r));if(n<=0)return 0;for(r>1?(l=e.log(u),c=e.exp(u*(l-1)-d),s=n<.5?n:1-n,i=(2.30753+.27061*(o=e.sqrt(-2*e.log(s))))/(1+o*(.99229+.04481*o))-o,n<.5&&(i=-i),i=e.max(.001,r*e.pow(1-1/(9*r)-i/(3*e.sqrt(r)),3))):i=n<(o=1-r*(.253+.12*r))?e.pow(n/o,1/r):1-e.log(1-(n-o)/(1-o));h<12;h++){if(i<=0)return 0;if((i-=o=(a=(t.lowRegGamma(r,i)-n)/(o=r>1?c*e.exp(-(i-u)+u*(e.log(i)-l)):e.exp(-i+u*e.log(i)-d)))/(1-.5*e.min(1,a*((r-1)/i-1))))<=0&&(i=.5*(i+o)),e.abs(o)<1e-8*i)break}return i},t.erf=function(t){var n,r,i,o,a=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],s=a.length-1,l=!1,c=0,h=0;for(t<0&&(t=-t,l=!0),r=4*(n=2/(2+t))-2;s>0;s--)i=c,c=r*c-h+a[s],h=i;return o=n*e.exp(-t*t+.5*(a[0]+r*c)-h),l?o-1:1-o},t.erfc=function(e){return 1-t.erf(e)},t.erfcinv=function(n){var r,i,o,a,s=0;if(n>=2)return-100;if(n<=0)return 100;for(a=n<1?n:2-n,r=-.70711*((2.30753+.27061*(o=e.sqrt(-2*e.log(a/2))))/(1+o*(.99229+.04481*o))-o);s<2;s++)r+=(i=t.erfc(r)-a)/(1.1283791670955126*e.exp(-r*r)-r*i);return n<1?r:-r},t.ibetainv=function(n,r,i){var o,a,s,l,c,h,u,d,f,g,p=r-1,m=i-1,y=0;if(n<=0)return 0;if(n>=1)return 1;for(r>=1&&i>=1?(s=n<.5?n:1-n,h=(2.30753+.27061*(l=e.sqrt(-2*e.log(s))))/(1+l*(.99229+.04481*l))-l,n<.5&&(h=-h),u=(h*h-3)/6,d=2/(1/(2*r-1)+1/(2*i-1)),f=h*e.sqrt(u+d)/d-(1/(2*i-1)-1/(2*r-1))*(u+5/6-2/(3*d)),h=r/(r+i*e.exp(2*f))):(o=e.log(r/(r+i)),a=e.log(i/(r+i)),h=n<(l=e.exp(r*o)/r)/(f=l+(c=e.exp(i*a)/i))?e.pow(r*f*n,1/r):1-e.pow(i*f*(1-n),1/i)),g=-t.gammaln(r)-t.gammaln(i)+t.gammaln(r+i);y<10;y++){if(0===h||1===h)return h;if((h-=l=(c=(t.ibeta(h,r,i)-n)/(l=e.exp(p*e.log(h)+m*e.log(1-h)+g)))/(1-.5*e.min(1,c*(p/h-m/(1-h)))))<=0&&(h=.5*(h+l)),h>=1&&(h=.5*(h+l+1)),e.abs(l)<1e-8*h&&y>0)break}return h},t.ibeta=function(n,r,i){var o=0===n||1===n?0:e.exp(t.gammaln(r+i)-t.gammaln(r)-t.gammaln(i)+r*e.log(n)+i*e.log(1-n));return!(n<0||n>1)&&(n<(r+1)/(r+i+2)?o*t.betacf(n,r,i)/r:1-o*t.betacf(1-n,i,r)/i)},t.randn=function(n,r){var i,o,a,s,l;if(r||(r=n),n)return t.create(n,r,function(){return t.randn()});do{i=t._random_fn(),o=1.7156*(t._random_fn()-.5),l=(a=i-.449871)*a+(s=e.abs(o)+.386595)*(.196*s-.25472*a)}while(l>.27597&&(l>.27846||o*o>-4*e.log(i)*i*i));return o/i},t.randg=function(n,r,i){var o,a,s,l,c,h,u=n;if(i||(i=r),n||(n=1),r)return(h=t.zeros(r,i)).alter(function(){return t.randg(n)}),h;n<1&&(n+=1),o=n-1/3,a=1/e.sqrt(9*o);do{do{l=1+a*(c=t.randn())}while(l<=0);l*=l*l,s=t._random_fn()}while(s>1-.331*e.pow(c,4)&&e.log(s)>.5*c*c+o*(1-l+e.log(l)));if(n==u)return o*l;do{s=t._random_fn()}while(0===s);return e.pow(s,1/u)*o*l},function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(){return t(t.map(this,function(n){return t[e](n)}))}})(e[n])}("gammaln gammafn factorial factorialln".split(" ")),function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(){return t(t[e].apply(null,arguments))}})(e[n])}("randn".split(" "))}(e,Math),function(t,e){function n(t,n,r,i){for(var o,a=0,s=1,l=1,c=1,h=0,u=0;e.abs((l-u)/l)>i;)u=l,s=c+(o=-(n+h)*(n+r+h)*t/(n+2*h)/(n+2*h+1))*s,l=(a=l+o*a)+(o=(h+=1)*(r-h)*t/(n+2*h-1)/(n+2*h))*l,a/=c=s+o*c,s/=c,l/=c,c=1;return l/n}function r(n,r,i){var o=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],a=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],s=.5*n;if(s>=8)return 1;var l,c=2*t.normal.cdf(s,0,1,1,0)-1;c=c>=e.exp(-50/i)?e.pow(c,i):0;for(var h=s,u=(8-s)/(l=n>3?2:3),d=h+u,f=0,g=i-1,p=1;p<=l;p++){for(var m=0,y=.5*(d+h),v=.5*(d-h),_=1;_<=12;_++){var w,b=y+v*(6<_?o[(w=12-_+1)-1]:-o[(w=_)-1]),C=b*b;if(C>60)break;var x=2*t.normal.cdf(b,0,1,1,0)*.5-2*t.normal.cdf(b,n,1,1,0)*.5;x>=e.exp(-30/g)&&(m+=x=a[w-1]*e.exp(-.5*C)*e.pow(x,g))}f+=m*=2*v*i/e.sqrt(2*e.PI),h=d,d+=u}return(c+=f)<=e.exp(-30/r)?0:(c=e.pow(c,r))>=1?1:c}!function(e){for(var n=0;n<e.length;n++)(function(e){t[e]=function t(e,n,r){return this instanceof t?(this._a=e,this._b=n,this._c=r,this):new t(e,n,r)},t.fn[e]=function(n,r,i){var o=t[e](n,r,i);return o.data=this,o},t[e].prototype.sample=function(n){var r=this._a,i=this._b,o=this._c;return n?t.alter(n,function(){return t[e].sample(r,i,o)}):t[e].sample(r,i,o)},function(n){for(var r=0;r<n.length;r++)(function(n){t[e].prototype[n]=function(r){var i=this._a,o=this._b,a=this._c;return r||0===r||(r=this.data),"number"!=typeof r?t.fn.map.call(r,function(r){return t[e][n](r,i,o,a)}):t[e][n](r,i,o,a)}})(n[r])}("pdf cdf inv".split(" ")),function(n){for(var r=0;r<n.length;r++)(function(n){t[e].prototype[n]=function(){return t[e][n](this._a,this._b,this._c)}})(n[r])}("mean median mode variance".split(" "))})(e[n])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),t.extend(t.beta,{pdf:function(n,r,i){return n>1||n<0?0:1==r&&1==i?1:r<512&&i<512?e.pow(n,r-1)*e.pow(1-n,i-1)/t.betafn(r,i):e.exp((r-1)*e.log(n)+(i-1)*e.log(1-n)-t.betaln(r,i))},cdf:function(e,n,r){return e>1||e<0?1*(e>1):t.ibeta(e,n,r)},inv:function(e,n,r){return t.ibetainv(e,n,r)},mean:function(t,e){return t/(t+e)},median:function(e,n){return t.ibetainv(.5,e,n)},mode:function(t,e){return(t-1)/(t+e-2)},sample:function(e,n){var r=t.randg(e);return r/(r+t.randg(n))},variance:function(t,n){return t*n/(e.pow(t+n,2)*(t+n+1))}}),t.extend(t.centralF,{pdf:function(n,r,i){var o;return n<0?0:r<=2?0===n&&r<2?1/0:0===n&&2===r?1:1/t.betafn(r/2,i/2)*e.pow(r/i,r/2)*e.pow(n,r/2-1)*e.pow(1+r/i*n,-(r+i)/2):(o=r*n/(i+n*r),r*(i/(i+n*r))/2*t.binomial.pdf((r-2)/2,(r+i-2)/2,o))},cdf:function(e,n,r){return e<0?0:t.ibeta(n*e/(n*e+r),n/2,r/2)},inv:function(e,n,r){return r/(n*(1/t.ibetainv(e,n/2,r/2)-1))},mean:function(t,e){return e>2?e/(e-2):void 0},mode:function(t,e){return t>2?e*(t-2)/(t*(e+2)):void 0},sample:function(e,n){return 2*t.randg(e/2)/e/(2*t.randg(n/2)/n)},variance:function(t,e){if(!(e<=4))return 2*e*e*(t+e-2)/(t*(e-2)*(e-2)*(e-4))}}),t.extend(t.cauchy,{pdf:function(t,n,r){return r<0?0:r/(e.pow(t-n,2)+e.pow(r,2))/e.PI},cdf:function(t,n,r){return e.atan((t-n)/r)/e.PI+.5},inv:function(t,n,r){return n+r*e.tan(e.PI*(t-.5))},median:function(t){return t},mode:function(t){return t},sample:function(n,r){return t.randn()*e.sqrt(1/(2*t.randg(.5)))*r+n}}),t.extend(t.chisquare,{pdf:function(n,r){return n<0?0:0===n&&2===r?.5:e.exp((r/2-1)*e.log(n)-n/2-r/2*e.log(2)-t.gammaln(r/2))},cdf:function(e,n){return e<0?0:t.lowRegGamma(n/2,e/2)},inv:function(e,n){return 2*t.gammapinv(e,.5*n)},mean:function(t){return t},median:function(t){return t*e.pow(1-2/(9*t),3)},mode:function(t){return t-2>0?t-2:0},sample:function(e){return 2*t.randg(e/2)},variance:function(t){return 2*t}}),t.extend(t.exponential,{pdf:function(t,n){return t<0?0:n*e.exp(-n*t)},cdf:function(t,n){return t<0?0:1-e.exp(-n*t)},inv:function(t,n){return-e.log(1-t)/n},mean:function(t){return 1/t},median:function(t){return 1/t*e.log(2)},mode:function(){return 0},sample:function(n){return-1/n*e.log(t._random_fn())},variance:function(t){return e.pow(t,-2)}}),t.extend(t.gamma,{pdf:function(n,r,i){return n<0?0:0===n&&1===r?1/i:e.exp((r-1)*e.log(n)-n/i-t.gammaln(r)-r*e.log(i))},cdf:function(e,n,r){return e<0?0:t.lowRegGamma(n,e/r)},inv:function(e,n,r){return t.gammapinv(e,n)*r},mean:function(t,e){return t*e},mode:function(t,e){if(t>1)return(t-1)*e},sample:function(e,n){return t.randg(e)*n},variance:function(t,e){return t*e*e}}),t.extend(t.invgamma,{pdf:function(n,r,i){return n<=0?0:e.exp(-(r+1)*e.log(n)-i/n-t.gammaln(r)+r*e.log(i))},cdf:function(e,n,r){return e<=0?0:1-t.lowRegGamma(n,r/e)},inv:function(e,n,r){return r/t.gammapinv(1-e,n)},mean:function(t,e){return t>1?e/(t-1):void 0},mode:function(t,e){return e/(t+1)},sample:function(e,n){return n/t.randg(e)},variance:function(t,e){if(!(t<=2))return e*e/((t-1)*(t-1)*(t-2))}}),t.extend(t.kumaraswamy,{pdf:function(t,n,r){return 0===t&&1===n?r:1===t&&1===r?n:e.exp(e.log(n)+e.log(r)+(n-1)*e.log(t)+(r-1)*e.log(1-e.pow(t,n)))},cdf:function(t,n,r){return t<0?0:t>1?1:1-e.pow(1-e.pow(t,n),r)},inv:function(t,n,r){return e.pow(1-e.pow(1-t,1/r),1/n)},mean:function(e,n){return n*t.gammafn(1+1/e)*t.gammafn(n)/t.gammafn(1+1/e+n)},median:function(t,n){return e.pow(1-e.pow(2,-1/n),1/t)},mode:function(t,n){if(t>=1&&n>=1&&1!==t&&1!==n)return e.pow((t-1)/(t*n-1),1/t)},variance:function(){throw new Error("variance not yet implemented")}}),t.extend(t.lognormal,{pdf:function(t,n,r){return t<=0?0:e.exp(-e.log(t)-.5*e.log(2*e.PI)-e.log(r)-e.pow(e.log(t)-n,2)/(2*r*r))},cdf:function(n,r,i){return n<0?0:.5+.5*t.erf((e.log(n)-r)/e.sqrt(2*i*i))},inv:function(n,r,i){return e.exp(-1.4142135623730951*i*t.erfcinv(2*n)+r)},mean:function(t,n){return e.exp(t+n*n/2)},median:function(t){return e.exp(t)},mode:function(t,n){return e.exp(t-n*n)},sample:function(n,r){return e.exp(t.randn()*r+n)},variance:function(t,n){return(e.exp(n*n)-1)*e.exp(2*t+n*n)}}),t.extend(t.noncentralt,{pdf:function(n,r,i){return e.abs(i)<1e-14?t.studentt.pdf(n,r):e.abs(n)<1e-14?e.exp(t.gammaln((r+1)/2)-i*i/2-.5*e.log(e.PI*r)-t.gammaln(r/2)):r/n*(t.noncentralt.cdf(n*e.sqrt(1+2/r),r+2,i)-t.noncentralt.cdf(n,r,i))},cdf:function(n,r,i){var o=1e-14;if(e.abs(i)<o)return t.studentt.cdf(n,r);var a=!1;n<0&&(a=!0,i=-i);for(var s=t.normal.cdf(-i,0,1),l=o+1,c=l,h=n*n/(n*n+r),u=0,d=e.exp(-i*i/2),f=e.exp(-i*i/2-.5*e.log(2)-t.gammaln(1.5))*i;u<200||c>o||l>o;)c=l,u>0&&(d*=i*i/(2*u),f*=i*i/(2*(u+.5))),s+=.5*(l=d*t.beta.cdf(h,u+.5,r/2)+f*t.beta.cdf(h,u+1,r/2)),u++;return a?1-s:s}}),t.extend(t.normal,{pdf:function(t,n,r){return e.exp(-.5*e.log(2*e.PI)-e.log(r)-e.pow(t-n,2)/(2*r*r))},cdf:function(n,r,i){return.5*(1+t.erf((n-r)/e.sqrt(2*i*i)))},inv:function(e,n,r){return-1.4142135623730951*r*t.erfcinv(2*e)+n},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},sample:function(e,n){return t.randn()*n+e},variance:function(t,e){return e*e}}),t.extend(t.pareto,{pdf:function(t,n,r){return t<n?0:r*e.pow(n,r)/e.pow(t,r+1)},cdf:function(t,n,r){return t<n?0:1-e.pow(n/t,r)},inv:function(t,n,r){return n/e.pow(1-t,1/r)},mean:function(t,n){if(!(n<=1))return n*e.pow(t,n)/(n-1)},median:function(t,n){return t*(n*e.SQRT2)},mode:function(t){return t},variance:function(t,n){if(!(n<=2))return t*t*n/(e.pow(n-1,2)*(n-2))}}),t.extend(t.studentt,{pdf:function(n,r){return r=r>1e100?1e100:r,1/(e.sqrt(r)*t.betafn(.5,r/2))*e.pow(1+n*n/r,-(r+1)/2)},cdf:function(n,r){var i=r/2;return t.ibeta((n+e.sqrt(n*n+r))/(2*e.sqrt(n*n+r)),i,i)},inv:function(n,r){var i=t.ibetainv(2*e.min(n,1-n),.5*r,.5);return i=e.sqrt(r*(1-i)/i),n>.5?i:-i},mean:function(t){return t>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(n){return t.randn()*e.sqrt(n/(2*t.randg(n/2)))},variance:function(t){return t>2?t/(t-2):t>1?1/0:void 0}}),t.extend(t.weibull,{pdf:function(t,n,r){return t<0||n<0||r<0?0:r/n*e.pow(t/n,r-1)*e.exp(-e.pow(t/n,r))},cdf:function(t,n,r){return t<0?0:1-e.exp(-e.pow(t/n,r))},inv:function(t,n,r){return n*e.pow(-e.log(1-t),1/r)},mean:function(e,n){return e*t.gammafn(1+1/n)},median:function(t,n){return t*e.pow(e.log(2),1/n)},mode:function(t,n){return n<=1?0:t*e.pow((n-1)/n,1/n)},sample:function(n,r){return n*e.pow(-e.log(t._random_fn()),1/r)},variance:function(n,r){return n*n*t.gammafn(1+2/r)-e.pow(t.weibull.mean(n,r),2)}}),t.extend(t.uniform,{pdf:function(t,e,n){return t<e||t>n?0:1/(n-e)},cdf:function(t,e,n){return t<e?0:t<n?(t-e)/(n-e):1},inv:function(t,e,n){return e+t*(n-e)},mean:function(t,e){return.5*(t+e)},median:function(e,n){return t.mean(e,n)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(e,n){return e/2+n/2+(n/2-e/2)*(2*t._random_fn()-1)},variance:function(t,n){return e.pow(n-t,2)/12}}),t.extend(t.binomial,{pdf:function(n,r,i){return 0===i||1===i?r*i===n?1:0:t.combination(r,n)*e.pow(i,n)*e.pow(1-i,r-n)},cdf:function(r,i,o){var a,s=1e-10;if(r<0)return 0;if(r>=i)return 1;if(o<0||o>1||i<=0)return NaN;var l=o,c=(r=e.floor(r))+1,h=i-r,u=c+h,d=e.exp(t.gammaln(u)-t.gammaln(h)-t.gammaln(c)+c*e.log(l)+h*e.log(1-l));return a=l<(c+1)/(u+2)?d*n(l,c,h,s):1-d*n(1-l,h,c,s),e.round(1/s*(1-a))/(1/s)}}),t.extend(t.negbin,{pdf:function(n,r,i){return n===n>>>0&&(n<0?0:t.combination(n+r-1,r-1)*e.pow(1-i,n)*e.pow(i,r))},cdf:function(e,n,r){var i=0,o=0;if(e<0)return 0;for(;o<=e;o++)i+=t.negbin.pdf(o,n,r);return i}}),t.extend(t.hypgeom,{pdf:function(n,r,i,o){if(n!=n|0)return!1;if(n<0||n<i-(r-o))return 0;if(n>o||n>i)return 0;if(2*i>r)return 2*o>r?t.hypgeom.pdf(r-i-o+n,r,r-i,r-o):t.hypgeom.pdf(o-n,r,r-i,o);if(2*o>r)return t.hypgeom.pdf(i-n,r,i,r-o);if(i<o)return t.hypgeom.pdf(n,r,o,i);for(var a=1,s=0,l=0;l<n;l++){for(;a>1&&s<o;)a*=1-i/(r-s),s++;a*=(o-l)*(i-l)/((l+1)*(r-i-o+l+1))}for(;s<o;s++)a*=1-i/(r-s);return e.min(1,e.max(0,a))},cdf:function(n,r,i,o){if(n<0||n<i-(r-o))return 0;if(n>=o||n>=i)return 1;if(2*i>r)return 2*o>r?t.hypgeom.cdf(r-i-o+n,r,r-i,r-o):1-t.hypgeom.cdf(o-n-1,r,r-i,o);if(2*o>r)return 1-t.hypgeom.cdf(i-n-1,r,i,r-o);if(i<o)return t.hypgeom.cdf(n,r,o,i);for(var a=1,s=1,l=0,c=0;c<n;c++){for(;a>1&&l<o;){var h=1-i/(r-l);s*=h,a*=h,l++}a+=s*=(o-c)*(i-c)/((c+1)*(r-i-o+c+1))}for(;l<o;l++)a*=1-i/(r-l);return e.min(1,e.max(0,a))}}),t.extend(t.poisson,{pdf:function(n,r){return r<0||n%1!=0||n<0?0:e.pow(r,n)*e.exp(-r)/t.factorial(n)},cdf:function(e,n){var r=[],i=0;if(e<0)return 0;for(;i<=e;i++)r.push(t.poisson.pdf(i,n));return t.sum(r)},mean:function(t){return t},variance:function(t){return t},sampleSmall:function(n){var r=1,i=0,o=e.exp(-n);do{i++,r*=t._random_fn()}while(r>o);return i-1},sampleLarge:function(n){var r,i,o,a,s,l,c,h,u,d,f=n;for(a=e.sqrt(f),s=e.log(f),l=.02483*(c=.931+2.53*a)-.059,h=1.1239+1.1328/(c-3.4),u=.9277-3.6224/(c-2);;){if(i=e.random()-.5,o=e.random(),d=.5-e.abs(i),r=e.floor((2*l/d+c)*i+f+.43),d>=.07&&o<=u)return r;if(!(r<0||d<.013&&o>d)&&e.log(o)+e.log(h)-e.log(l/(d*d)+c)<=r*s-f-t.loggam(r+1))return r}},sample:function(t){return t<10?this.sampleSmall(t):this.sampleLarge(t)}}),t.extend(t.triangular,{pdf:function(t,e,n,r){return n<=e||r<e||r>n?NaN:t<e||t>n?0:t<r?2*(t-e)/((n-e)*(r-e)):t===r?2/(n-e):2*(n-t)/((n-e)*(n-r))},cdf:function(t,n,r,i){return r<=n||i<n||i>r?NaN:t<=n?0:t>=r?1:t<=i?e.pow(t-n,2)/((r-n)*(i-n)):1-e.pow(r-t,2)/((r-n)*(r-i))},inv:function(t,n,r,i){return r<=n||i<n||i>r?NaN:t<=(i-n)/(r-n)?n+(r-n)*e.sqrt(t*((i-n)/(r-n))):n+(r-n)*(1-e.sqrt((1-t)*(1-(i-n)/(r-n))))},mean:function(t,e,n){return(t+e+n)/3},median:function(t,n,r){return r<=(t+n)/2?n-e.sqrt((n-t)*(n-r))/e.sqrt(2):r>(t+n)/2?t+e.sqrt((n-t)*(r-t))/e.sqrt(2):void 0},mode:function(t,e,n){return n},sample:function(n,r,i){var o=t._random_fn();return o<(i-n)/(r-n)?n+e.sqrt(o*(r-n)*(i-n)):r-e.sqrt((1-o)*(r-n)*(r-i))},variance:function(t,e,n){return(t*t+e*e+n*n-t*e-t*n-e*n)/18}}),t.extend(t.arcsine,{pdf:function(t,n,r){return r<=n?NaN:t<=n||t>=r?0:2/e.PI*e.pow(e.pow(r-n,2)-e.pow(2*t-n-r,2),-.5)},cdf:function(t,n,r){return t<n?0:t<r?2/e.PI*e.asin(e.sqrt((t-n)/(r-n))):1},inv:function(t,n,r){return n+(.5-.5*e.cos(e.PI*t))*(r-n)},mean:function(t,e){return e<=t?NaN:(t+e)/2},median:function(t,e){return e<=t?NaN:(t+e)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(n,r){return(n+r)/2+(r-n)/2*e.sin(2*e.PI*t.uniform.sample(0,1))},variance:function(t,n){return n<=t?NaN:e.pow(n-t,2)/8}}),t.extend(t.laplace,{pdf:function(t,n,r){return r<=0?0:e.exp(-e.abs(t-n)/r)/(2*r)},cdf:function(t,n,r){return r<=0?0:t<n?.5*e.exp((t-n)/r):1-.5*e.exp(-(t-n)/r)},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},variance:function(t,e){return 2*e*e},sample:function(n,r){var i,o=t._random_fn()-.5;return n-r*((i=o)/e.abs(i))*e.log(1-2*e.abs(o))}}),t.extend(t.tukey,{cdf:function(n,i,o){var a=i,s=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],l=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(n<=0)return 0;if(o<2||a<2)return NaN;if(!Number.isFinite(n))return 1;if(o>25e3)return r(n,1,a);var c,h=.5*o,u=h*e.log(o)-o*e.log(2)-t.gammaln(h),d=h-1,f=.25*o;c=o<=100?1:o<=800?.5:o<=5e3?.25:.125,u+=e.log(c);for(var g=0,p=1;p<=50;p++){for(var m=0,y=(2*p-1)*c,v=1;v<=16;v++){var _,w;8<v?(_=v-8-1,w=u+d*e.log(y+s[_]*c)-(s[_]*c+y)*f):(_=v-1,w=u+d*e.log(y-s[_]*c)+(s[_]*c-y)*f),w>=-30&&(m+=r(8<v?n*e.sqrt(.5*(s[_]*c+y)):n*e.sqrt(.5*(-s[_]*c+y)),1,a)*l[_]*e.exp(w))}if(p*c>=1&&m<=1e-14)break;g+=m}if(m>1e-14)throw new Error("tukey.cdf failed to converge");return g>1&&(g=1),g},inv:function(n,r,i){if(i<2||r<2)return NaN;if(n<0||n>1)return NaN;if(0===n)return 0;if(1===n)return 1/0;var o,a=function(t,n,r){var i=.5-.5*t,o=e.sqrt(e.log(1/(i*i))),a=o+((((-453642210148e-16*o-.204231210125)*o-.342242088547)*o-1)*o+.322232421088)/((((.0038560700634*o+.10353775285)*o+.531103462366)*o+.588581570495)*o+.099348462606);r<120&&(a+=(a*a*a+a)/r/4);var s=.8832-.2368*a;return r<120&&(s+=-1.214/r+1.208*a/r),a*(s*e.log(n-1)+1.4142)}(n,r,i),s=t.tukey.cdf(a,r,i)-n;o=s>0?e.max(0,a-1):a+1;for(var l,c=t.tukey.cdf(o,r,i)-n,h=1;h<50;h++)if(l=o-c*(o-a)/(c-s),s=c,a=o,l<0&&(l=0,c=-n),c=t.tukey.cdf(l,r,i)-n,o=l,e.abs(o-a)<1e-4)return l;throw new Error("tukey.inv failed to converge")}})}(e,Math),function(t,e){var n,r,i=Array.prototype.push,o=t.utils.isArray;function a(e){return o(e)||e instanceof t}t.extend({add:function(e,n){return a(n)?(a(n[0])||(n=[n]),t.map(e,function(t,e,r){return t+n[e][r]})):t.map(e,function(t){return t+n})},subtract:function(e,n){return a(n)?(a(n[0])||(n=[n]),t.map(e,function(t,e,r){return t-n[e][r]||0})):t.map(e,function(t){return t-n})},divide:function(e,n){return a(n)?(a(n[0])||(n=[n]),t.multiply(e,t.inv(n))):t.map(e,function(t){return t/n})},multiply:function(e,n){var r,i,o,s,l,c,h,u;if(void 0===e.length&&void 0===n.length)return e*n;if(l=e.length,c=e[0].length,h=t.zeros(l,o=a(n)?n[0].length:c),u=0,a(n)){for(;u<o;u++)for(r=0;r<l;r++){for(s=0,i=0;i<c;i++)s+=e[r][i]*n[i][u];h[r][u]=s}return 1===l&&1===u?h[0][0]:h}return t.map(e,function(t){return t*n})},outer:function(e,n){return t.multiply(e.map(function(t){return[t]}),[n])},dot:function(e,n){a(e[0])||(e=[e]),a(n[0])||(n=[n]);for(var r,i,o=1===e[0].length&&1!==e.length?t.transpose(e):e,s=1===n[0].length&&1!==n.length?t.transpose(n):n,l=[],c=0,h=o.length,u=o[0].length;c<h;c++){for(l[c]=[],r=0,i=0;i<u;i++)r+=o[c][i]*s[c][i];l[c]=r}return 1===l.length?l[0]:l},pow:function(n,r){return t.map(n,function(t){return e.pow(t,r)})},exp:function(n){return t.map(n,function(t){return e.exp(t)})},log:function(n){return t.map(n,function(t){return e.log(t)})},abs:function(n){return t.map(n,function(t){return e.abs(t)})},norm:function(t,n){var r=0,i=0;for(isNaN(n)&&(n=2),a(t[0])&&(t=t[0]);i<t.length;i++)r+=e.pow(e.abs(t[i]),n);return e.pow(r,1/n)},angle:function(n,r){return e.acos(t.dot(n,r)/(t.norm(n)*t.norm(r)))},aug:function(t,e){var n,r=[];for(n=0;n<t.length;n++)r.push(t[n].slice());for(n=0;n<r.length;n++)i.apply(r[n],e[n]);return r},inv:function(e){for(var n,r=e.length,i=e[0].length,o=t.identity(r,i),a=t.gauss_jordan(e,o),s=[],l=0;l<r;l++)for(s[l]=[],n=i;n<a[0].length;n++)s[l][n-i]=a[l][n];return s},det:function t(e){if(2===e.length)return e[0][0]*e[1][1]-e[0][1]*e[1][0];for(var n=0,r=0;r<e.length;r++){for(var i=[],o=1;o<e.length;o++){i[o-1]=[];for(var a=0;a<e.length;a++)a<r?i[o-1][a]=e[o][a]:a>r&&(i[o-1][a-1]=e[o][a])}var s=r%2?-1:1;n+=t(i)*e[0][r]*s}return n},gauss_elimination:function(n,r){var i,o,a,s,l=0,c=0,h=n.length,u=n[0].length,d=1,f=0,g=[];for(i=(n=t.aug(n,r))[0].length,l=0;l<h;l++){for(o=n[l][l],c=l,s=l+1;s<u;s++)o<e.abs(n[s][l])&&(o=n[s][l],c=s);if(c!=l)for(s=0;s<i;s++)a=n[l][s],n[l][s]=n[c][s],n[c][s]=a;for(c=l+1;c<h;c++)for(d=n[c][l]/n[l][l],s=l;s<i;s++)n[c][s]=n[c][s]-d*n[l][s]}for(l=h-1;l>=0;l--){for(f=0,c=l+1;c<=h-1;c++)f+=g[c]*n[l][c];g[l]=(n[l][i-1]-f)/n[l][l]}return g},gauss_jordan:function(n,r){var i,o,a,s=t.aug(n,r),l=s.length,c=s[0].length,h=0;for(o=0;o<l;o++){var u=o;for(a=o+1;a<l;a++)e.abs(s[a][o])>e.abs(s[u][o])&&(u=a);var d=s[o];for(s[o]=s[u],s[u]=d,a=o+1;a<l;a++)for(h=s[a][o]/s[o][o],i=o;i<c;i++)s[a][i]-=s[o][i]*h}for(o=l-1;o>=0;o--){for(h=s[o][o],a=0;a<o;a++)for(i=c-1;i>o-1;i--)s[a][i]-=s[o][i]*s[a][o]/h;for(s[o][o]/=h,i=l;i<c;i++)s[o][i]/=h}return s},triaUpSolve:function(e,n){var r,i=e[0].length,o=t.zeros(1,i)[0],a=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),a=!0),t.arange(i-1,-1,-1).forEach(function(a){r=t.arange(a+1,i).map(function(t){return o[t]*e[a][t]}),o[a]=(n[a]-t.sum(r))/e[a][a]}),a?o.map(function(t){return[t]}):o},triaLowSolve:function(e,n){var r,i=e[0].length,o=t.zeros(1,i)[0],a=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),a=!0),t.arange(i).forEach(function(i){r=t.arange(i).map(function(t){return e[i][t]*o[t]}),o[i]=(n[i]-t.sum(r))/e[i][i]}),a?o.map(function(t){return[t]}):o},lu:function(e){var n,r=e.length,i=t.identity(r),o=t.zeros(e.length,e[0].length);return t.arange(r).forEach(function(t){o[0][t]=e[0][t]}),t.arange(1,r).forEach(function(a){t.arange(a).forEach(function(r){n=t.arange(r).map(function(t){return i[a][t]*o[t][r]}),i[a][r]=(e[a][r]-t.sum(n))/o[r][r]}),t.arange(a,r).forEach(function(r){n=t.arange(a).map(function(t){return i[a][t]*o[t][r]}),o[a][r]=e[n.length][r]-t.sum(n)})}),[i,o]},cholesky:function(n){var r,i=n.length,o=t.zeros(n.length,n[0].length);return t.arange(i).forEach(function(a){r=t.arange(a).map(function(t){return e.pow(o[a][t],2)}),o[a][a]=e.sqrt(n[a][a]-t.sum(r)),t.arange(a+1,i).forEach(function(e){r=t.arange(a).map(function(t){return o[a][t]*o[e][t]}),o[e][a]=(n[a][e]-t.sum(r))/o[a][a]})}),o},gauss_jacobi:function(n,r,i,o){for(var a,s,l,c,h=0,u=0,d=n.length,f=[],g=[],p=[];h<d;h++)for(f[h]=[],g[h]=[],p[h]=[],u=0;u<d;u++)h>u?(f[h][u]=n[h][u],g[h][u]=p[h][u]=0):h<u?(g[h][u]=n[h][u],f[h][u]=p[h][u]=0):(p[h][u]=n[h][u],f[h][u]=g[h][u]=0);for(l=t.multiply(t.multiply(t.inv(p),t.add(f,g)),-1),s=t.multiply(t.inv(p),r),a=i,c=t.add(t.multiply(l,i),s),h=2;e.abs(t.norm(t.subtract(c,a)))>o;)a=c,c=t.add(t.multiply(l,a),s),h++;return c},gauss_seidel:function(n,r,i,o){for(var a,s,l,c,h,u=0,d=n.length,f=[],g=[],p=[];u<d;u++)for(f[u]=[],g[u]=[],p[u]=[],a=0;a<d;a++)u>a?(f[u][a]=n[u][a],g[u][a]=p[u][a]=0):u<a?(g[u][a]=n[u][a],f[u][a]=p[u][a]=0):(p[u][a]=n[u][a],f[u][a]=g[u][a]=0);for(c=t.multiply(t.multiply(t.inv(t.add(p,f)),g),-1),l=t.multiply(t.inv(t.add(p,f)),r),s=i,h=t.add(t.multiply(c,i),l),u=2;e.abs(t.norm(t.subtract(h,s)))>o;)s=h,h=t.add(t.multiply(c,s),l),u+=1;return h},SOR:function(n,r,i,o,a){for(var s,l,c,h,u,d=0,f=n.length,g=[],p=[],m=[];d<f;d++)for(g[d]=[],p[d]=[],m[d]=[],s=0;s<f;s++)d>s?(g[d][s]=n[d][s],p[d][s]=m[d][s]=0):d<s?(p[d][s]=n[d][s],g[d][s]=m[d][s]=0):(m[d][s]=n[d][s],g[d][s]=p[d][s]=0);for(h=t.multiply(t.inv(t.add(m,t.multiply(g,a))),t.subtract(t.multiply(m,1-a),t.multiply(p,a))),c=t.multiply(t.multiply(t.inv(t.add(m,t.multiply(g,a))),r),a),l=i,u=t.add(t.multiply(h,i),c),d=2;e.abs(t.norm(t.subtract(u,l)))>o;)l=u,u=t.add(t.multiply(h,l),c),d++;return u},householder:function(n){for(var r,i,o,a,s=n.length,l=n[0].length,c=0,h=[],u=[];c<s-1;c++){for(r=0,a=c+1;a<l;a++)r+=n[a][c]*n[a][c];for(r=(n[c+1][c]>0?-1:1)*e.sqrt(r),i=e.sqrt((r*r-n[c+1][c]*r)/2),(h=t.zeros(s,1))[c+1][0]=(n[c+1][c]-r)/(2*i),o=c+2;o<s;o++)h[o][0]=n[o][c]/(2*i);u=t.subtract(t.identity(s,l),t.multiply(t.multiply(h,t.transpose(h)),2)),n=t.multiply(u,t.multiply(n,u))}return n},QR:(n=t.sum,r=t.arange,function(i){var o,a,s,l=i.length,c=i[0].length,h=t.zeros(c,c);for(i=t.copy(i),a=0;a<c;a++){for(h[a][a]=e.sqrt(n(r(l).map(function(t){return i[t][a]*i[t][a]}))),o=0;o<l;o++)i[o][a]=i[o][a]/h[a][a];for(s=a+1;s<c;s++)for(h[a][s]=n(r(l).map(function(t){return i[t][a]*i[t][s]})),o=0;o<l;o++)i[o][s]=i[o][s]-i[o][a]*h[a][s]}return[i,h]}),lstsq:function(e,n){var r=!1;void 0===n[0].length&&(n=n.map(function(t){return[t]}),r=!0);var i=t.QR(e),o=i[0],a=i[1],s=e[0].length,l=t.slice(o,{col:{end:s}}),c=function(e){var n=(e=t.copy(e)).length,r=t.identity(n);return t.arange(n-1,-1,-1).forEach(function(n){t.sliceAssign(r,{row:n},t.divide(t.slice(r,{row:n}),e[n][n])),t.sliceAssign(e,{row:n},t.divide(t.slice(e,{row:n}),e[n][n])),t.arange(n).forEach(function(i){var o=t.multiply(e[i][n],-1),a=t.slice(e,{row:i}),s=t.multiply(t.slice(e,{row:n}),o);t.sliceAssign(e,{row:i},t.add(a,s));var l=t.slice(r,{row:i}),c=t.multiply(t.slice(r,{row:n}),o);t.sliceAssign(r,{row:i},t.add(l,c))})}),r}(t.slice(a,{row:{end:s}})),h=t.transpose(l);void 0===h[0].length&&(h=[h]);var u=t.multiply(t.multiply(c,h),n);return void 0===u.length&&(u=[[u]]),r?u.map(function(t){return t[0]}):u},jacobi:function(n){for(var r,i,o,a,s,l,c,h=1,u=n.length,d=t.identity(u,u),f=[];1===h;){for(s=n[0][1],o=0,a=1,r=0;r<u;r++)for(i=0;i<u;i++)r!=i&&s<e.abs(n[r][i])&&(s=e.abs(n[r][i]),o=r,a=i);for(l=n[o][o]===n[a][a]?n[o][a]>0?e.PI/4:-e.PI/4:e.atan(2*n[o][a]/(n[o][o]-n[a][a]))/2,(c=t.identity(u,u))[o][o]=e.cos(l),c[o][a]=-e.sin(l),c[a][o]=e.sin(l),c[a][a]=e.cos(l),d=t.multiply(d,c),n=t.multiply(t.multiply(t.inv(c),n),c),h=0,r=1;r<u;r++)for(i=1;i<u;i++)r!=i&&e.abs(n[r][i])>.001&&(h=1)}for(r=0;r<u;r++)f.push(n[r][r]);return[d,f]},rungekutta:function(t,e,n,r,i,o){var a,s,l;if(2===o)for(;r<=n;)i+=((a=e*t(r,i))+(s=e*t(r+e,i+a)))/2,r+=e;if(4===o)for(;r<=n;)i+=((a=e*t(r,i))+2*(s=e*t(r+e/2,i+a/2))+2*(l=e*t(r+e/2,i+s/2))+e*t(r+e,i+l))/6,r+=e;return i},romberg:function(t,n,r,i){for(var o,a,s,l,c,h=0,u=(r-n)/2,d=[],f=[],g=[];h<i/2;){for(c=t(n),s=n,l=0;s<=r;s+=u,l++)d[l]=s;for(o=d.length,s=1;s<o-1;s++)c+=(s%2!=0?4:2)*t(d[s]);c=u/3*(c+t(r)),g[h]=c,u/=2,h++}for(a=g.length,o=1;1!==a;){for(s=0;s<a-1;s++)f[s]=(e.pow(4,o)*g[s+1]-g[s])/(e.pow(4,o)-1);a=f.length,g=f,f=[],o++}return g},richardson:function(t,n,r,i){function o(t,e){for(var n,r=0,i=t.length;r<i;r++)t[r]===e&&(n=r);return n}for(var a,s,l,c,h,u=e.abs(r-t[o(t,r)+1]),d=0,f=[],g=[];i>=u;)a=o(t,r+i),s=o(t,r),f[d]=(n[a]-2*n[s]+n[2*s-a])/(i*i),i/=2,d++;for(c=f.length,l=1;1!=c;){for(h=0;h<c-1;h++)g[h]=(e.pow(4,l)*f[h+1]-f[h])/(e.pow(4,l)-1);c=g.length,f=g,g=[],l++}return f},simpson:function(t,e,n,r){for(var i,o=(n-e)/r,a=t(e),s=[],l=e,c=0,h=1;l<=n;l+=o,c++)s[c]=l;for(i=s.length;h<i-1;h++)a+=(h%2!=0?4:2)*t(s[h]);return o/3*(a+t(n))},hermite:function(t,e,n,r){for(var i,o=t.length,a=0,s=0,l=[],c=[],h=[],u=[];s<o;s++){for(l[s]=1,i=0;i<o;i++)s!=i&&(l[s]*=(r-t[i])/(t[s]-t[i]));for(c[s]=0,i=0;i<o;i++)s!=i&&(c[s]+=1/(t[s]-t[i]));h[s]=(1-2*(r-t[s])*c[s])*(l[s]*l[s]),u[s]=(r-t[s])*(l[s]*l[s]),a+=h[s]*e[s]+u[s]*n[s]}return a},lagrange:function(t,e,n){for(var r,i,o=0,a=0,s=t.length;a<s;a++){for(i=e[a],r=0;r<s;r++)a!=r&&(i*=(n-t[r])/(t[a]-t[r]));o+=i}return o},cubic_spline:function(e,n,r){for(var i,o,a=e.length,s=0,l=[],c=[],h=[],u=[],d=[],f=[];s<a-1;s++)u[s]=e[s+1]-e[s];for(h[0]=0,s=1;s<a-1;s++)h[s]=3/u[s]*(n[s+1]-n[s])-3/u[s-1]*(n[s]-n[s-1]);for(s=1;s<a-1;s++)l[s]=[],c[s]=[],l[s][s-1]=u[s-1],l[s][s]=2*(u[s-1]+u[s]),l[s][s+1]=u[s],c[s][0]=h[s];for(o=t.multiply(t.inv(l),c),i=0;i<a-1;i++)d[i]=(n[i+1]-n[i])/u[i]-u[i]*(o[i+1][0]+2*o[i][0])/3,f[i]=(o[i+1][0]-o[i][0])/(3*u[i]);for(i=0;i<a&&!(e[i]>r);i++);return n[i-=1]+(r-e[i])*d[i]+t.sq(r-e[i])*o[i]+(r-e[i])*t.sq(r-e[i])*f[i]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(e){var n,r,i,o,a,s=e.length,l=e[0].length,c=0,h=[],u=[],d=[],f=[],g=[],p=[],m=[];for(c=0;c<s;c++)h[c]=t.sum(e[c])/l;for(c=0;c<l;c++)for(g[c]=[],n=0;n<s;n++)g[c][n]=e[n][c]-h[n];for(g=t.transpose(g),c=0;c<s;c++)for(p[c]=[],n=0;n<s;n++)p[c][n]=t.dot([g[c]],[g[n]])/(l-1);for(a=(i=t.jacobi(p))[0],u=i[1],m=t.transpose(a),c=0;c<u.length;c++)for(n=c;n<u.length;n++)u[c]<u[n]&&(r=u[c],u[c]=u[n],u[n]=r,d=m[c],m[c]=m[n],m[n]=d);for(o=t.transpose(g),c=0;c<s;c++)for(f[c]=[],n=0;n<o.length;n++)f[c][n]=t.dot([m[c]],[o[n]]);return[e,u,m,f]}}),function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(n,r){var i=this;return r?(setTimeout(function(){r.call(i,t.fn[e].call(i,n))},15),this):"number"==typeof t[e](this,n)?t[e](this,n):t(t[e](this,n))}})(e[n])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(e,Math),function(t,e){var n=[].slice,r=t.utils.isNumber,i=t.utils.isArray;function o(t,n,r,i){if(t>1||r>1||t<=0||r<=0)throw new Error("Proportions should be greater than 0 and less than 1");var o=(t*n+r*i)/(n+i);return(t-r)/e.sqrt(o*(1-o)*(1/n+1/i))}t.extend({zscore:function(){var e=n.call(arguments);return r(e[1])?(e[0]-e[1])/e[2]:(e[0]-t.mean(e[1]))/t.stdev(e[1],e[2])},ztest:function(){var r,o=n.call(arguments);return i(o[1])?(r=t.zscore(o[0],o[1],o[3]),1===o[2]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1)):o.length>2?(r=t.zscore(o[0],o[1],o[2]),1===o[3]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1)):(r=o[0],1===o[1]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1))}}),t.extend(t.fn,{zscore:function(t,e){return(t-this.mean())/this.stdev(e)},ztest:function(n,r,i){var o=e.abs(this.zscore(n,i));return 1===r?t.normal.cdf(-o,0,1):2*t.normal.cdf(-o,0,1)}}),t.extend({tscore:function(){var r=n.call(arguments);return 4===r.length?(r[0]-r[1])/(r[2]/e.sqrt(r[3])):(r[0]-t.mean(r[1]))/(t.stdev(r[1],!0)/e.sqrt(r[1].length))},ttest:function(){var i,o=n.call(arguments);return 5===o.length?(i=e.abs(t.tscore(o[0],o[1],o[2],o[3])),1===o[4]?t.studentt.cdf(-i,o[3]-1):2*t.studentt.cdf(-i,o[3]-1)):r(o[1])?(i=e.abs(o[0]),1==o[2]?t.studentt.cdf(-i,o[1]-1):2*t.studentt.cdf(-i,o[1]-1)):(i=e.abs(t.tscore(o[0],o[1])),1==o[2]?t.studentt.cdf(-i,o[1].length-1):2*t.studentt.cdf(-i,o[1].length-1))}}),t.extend(t.fn,{tscore:function(t){return(t-this.mean())/(this.stdev(!0)/e.sqrt(this.cols()))},ttest:function(n,r){return 1===r?1-t.studentt.cdf(e.abs(this.tscore(n)),this.cols()-1):2*t.studentt.cdf(-e.abs(this.tscore(n)),this.cols()-1)}}),t.extend({anovafscore:function(){var r,i,o,a,s,l,c,h,u=n.call(arguments);if(1===u.length){for(s=new Array(u[0].length),c=0;c<u[0].length;c++)s[c]=u[0][c];u=s}for(i=new Array,c=0;c<u.length;c++)i=i.concat(u[c]);for(o=t.mean(i),r=0,c=0;c<u.length;c++)r+=u[c].length*e.pow(t.mean(u[c])-o,2);for(r/=u.length-1,l=0,c=0;c<u.length;c++)for(a=t.mean(u[c]),h=0;h<u[c].length;h++)l+=e.pow(u[c][h]-a,2);return r/(l/(i.length-u.length))},anovaftest:function(){var e,i,o,a,s=n.call(arguments);if(r(s[0]))return 1-t.centralF.cdf(s[0],s[1],s[2]);var l=t.anovafscore(s);for(e=s.length-1,o=0,a=0;a<s.length;a++)o+=s[a].length;return i=o-e-1,1-t.centralF.cdf(l,e,i)},ftest:function(e,n,r){return 1-t.centralF.cdf(e,n,r)}}),t.extend(t.fn,{anovafscore:function(){return t.anovafscore(this.toArray())},anovaftes:function(){var e,n=0;for(e=0;e<this.length;e++)n+=this[e].length;return t.ftest(this.anovafscore(),this.length-1,n-this.length)}}),t.extend({qscore:function(){var i,o,a,s,l,c=n.call(arguments);return r(c[0])?(i=c[0],o=c[1],a=c[2],s=c[3],l=c[4]):(i=t.mean(c[0]),o=t.mean(c[1]),a=c[0].length,s=c[1].length,l=c[2]),e.abs(i-o)/(l*e.sqrt((1/a+1/s)/2))},qtest:function(){var e,r=n.call(arguments);3===r.length?(e=r[0],r=r.slice(1)):7===r.length?(e=t.qscore(r[0],r[1],r[2],r[3],r[4]),r=r.slice(5)):(e=t.qscore(r[0],r[1],r[2]),r=r.slice(3));var i=r[0],o=r[1];return 1-t.tukey.cdf(e,o,i-o)},tukeyhsd:function(e){for(var n=t.pooledstdev(e),r=e.map(function(e){return t.mean(e)}),i=e.reduce(function(t,e){return t+e.length},0),o=[],a=0;a<e.length;++a)for(var s=a+1;s<e.length;++s){var l=t.qtest(r[a],r[s],e[a].length,e[s].length,n,i,e.length);o.push([[a,s],l])}return o}}),t.extend({normalci:function(){var r,i=n.call(arguments),o=new Array(2);return r=4===i.length?e.abs(t.normal.inv(i[1]/2,0,1)*i[2]/e.sqrt(i[3])):e.abs(t.normal.inv(i[1]/2,0,1)*t.stdev(i[2])/e.sqrt(i[2].length)),o[0]=i[0]-r,o[1]=i[0]+r,o},tci:function(){var r,i=n.call(arguments),o=new Array(2);return r=4===i.length?e.abs(t.studentt.inv(i[1]/2,i[3]-1)*i[2]/e.sqrt(i[3])):e.abs(t.studentt.inv(i[1]/2,i[2].length-1)*t.stdev(i[2],!0)/e.sqrt(i[2].length)),o[0]=i[0]-r,o[1]=i[0]+r,o},significant:function(t,e){return t<e}}),t.extend(t.fn,{normalci:function(e,n){return t.normalci(e,n,this.toArray())},tci:function(e,n){return t.tci(e,n,this.toArray())}}),t.extend(t.fn,{oneSidedDifferenceOfProportions:function(e,n,r,i){var a=o(e,n,r,i);return t.ztest(a,1)},twoSidedDifferenceOfProportions:function(e,n,r,i){var a=o(e,n,r,i);return t.ztest(a,2)}})}(e,Math),e.models=function(){function t(t,n){var r=t.length,i=n[0].length-1,o=r-i-1,a=e.lstsq(n,t),s=e.multiply(n,a.map(function(t){return[t]})).map(function(t){return t[0]}),l=e.subtract(t,s),c=e.mean(t),h=e.sum(s.map(function(t){return Math.pow(t-c,2)})),u=e.sum(t.map(function(t,e){return Math.pow(t-s[e],2)})),d=h+u;return{exog:n,endog:t,nobs:r,df_model:i,df_resid:o,coef:a,predict:s,resid:l,ybar:c,SST:d,SSE:h,SSR:u,R2:h/d}}function n(n){var r,i,o=(r=n.exog,i=r[0].length,e.arange(i).map(function(n){var o=e.arange(i).filter(function(t){return t!==n});return t(e.col(r,n).map(function(t){return t[0]}),e.col(r,o))})),a=Math.sqrt(n.SSR/n.df_resid),s=o.map(function(t){var e=t.SST,n=t.R2;return a/Math.sqrt(e*(1-n))}),l=n.coef.map(function(t,e){return(t-0)/s[e]}),c=l.map(function(t){var r=e.studentt.cdf(t,n.df_resid);return 2*(r>.5?1-r:r)}),h=e.studentt.inv(.975,n.df_resid),u=n.coef.map(function(t,e){var n=h*s[e];return[t-n,t+n]});return{se:s,t:l,p:c,sigmaHat:a,interval95:u}}return{ols:function(r,i){var o=t(r,i),a=n(o),s=function(t){var n,r,i,o=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:o,pvalue:1-(n=o,r=t.df_model,i=t.df_resid,e.beta.cdf(n/(i/r+n),r/2,i/2))}}(o),l=1-(1-o.R2)*((o.nobs-1)/o.df_resid);return o.t=a,o.f=s,o.adjust_R2=l,o}}}(),e.extend({buildxmatrix:function(){for(var t=new Array(arguments.length),n=0;n<arguments.length;n++){t[n]=[1].concat(arguments[n])}return e(t)},builddxmatrix:function(){for(var t=new Array(arguments[0].length),n=0;n<arguments[0].length;n++){t[n]=[1].concat(arguments[0][n])}return e(t)},buildjxmatrix:function(t){for(var n=new Array(t.length),r=0;r<t.length;r++)n[r]=t[r];return e.builddxmatrix(n)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(t){return t.transpose()},matrixmult:function(t,n){var r,i,o,a,s;if(t.cols()==n.rows()){if(n.rows()>1){for(a=[],r=0;r<t.rows();r++)for(a[r]=[],i=0;i<n.cols();i++){for(s=0,o=0;o<t.cols();o++)s+=t.toArray()[r][o]*n.toArray()[o][i];a[r][i]=s}return e(a)}for(a=[],r=0;r<t.rows();r++)for(a[r]=[],i=0;i<n.cols();i++){for(s=0,o=0;o<t.cols();o++)s+=t.toArray()[r][o]*n.toArray()[i];a[r][i]=s}return e(a)}},regress:function(t,n){var r=e.xtranspxinv(t),i=t.transpose(),o=e.matrixmult(e(r),i);return e.matrixmult(o,n)},regresst:function(t,n,r){var i=e.regress(t,n),o={anova:{}},a=e.jMatYBar(t,i);o.yBar=a;var s=n.mean();o.anova.residuals=e.residuals(n,a),o.anova.ssr=e.ssr(a,s),o.anova.msr=o.anova.ssr/(t[0].length-1),o.anova.sse=e.sse(n,a),o.anova.mse=o.anova.sse/(n.length-(t[0].length-1)-1),o.anova.sst=e.sst(n,s),o.anova.mst=o.anova.sst/(n.length-1),o.anova.r2=1-o.anova.sse/o.anova.sst,o.anova.r2<0&&(o.anova.r2=0),o.anova.fratio=o.anova.msr/o.anova.mse,o.anova.pvalue=e.anovaftest(o.anova.fratio,t[0].length-1,n.length-(t[0].length-1)-1),o.anova.rmse=Math.sqrt(o.anova.mse),o.anova.r2adj=1-o.anova.mse/o.anova.mst,o.anova.r2adj<0&&(o.anova.r2adj=0),o.stats=new Array(t[0].length);for(var l,c,h,u=e.xtranspxinv(t),d=0;d<i.length;d++)l=Math.sqrt(o.anova.mse*Math.abs(u[d][d])),c=Math.abs(i[d]/l),h=e.ttest(c,n.length-t[0].length-1,r),o.stats[d]=[i[d],l,c,h];return o.regress=i,o},xtranspx:function(t){return e.matrixmult(t.transpose(),t)},xtranspxinv:function(t){var n=e.matrixmult(t.transpose(),t);return e.inv(n)},jMatYBar:function(t,n){var r=e.matrixmult(t,n);return new e(r)},residuals:function(t,n){return e.matrixsubtract(t,n)},ssr:function(t,e){for(var n=0,r=0;r<t.length;r++)n+=Math.pow(t[r]-e,2);return n},sse:function(t,e){for(var n=0,r=0;r<t.length;r++)n+=Math.pow(t[r]-e[r],2);return n},sst:function(t,e){for(var n=0,r=0;r<t.length;r++)n+=Math.pow(t[r]-e,2);return n},matrixsubtract:function(t,n){for(var r=new Array(t.length),i=0;i<t.length;i++){r[i]=new Array(t[i].length);for(var o=0;o<t[i].length;o++)r[i][o]=t[i][o]-n[i][o]}return e(r)}}),e.jStat=e,e)},6619:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Tag=e.Label=void 0;const r=n(4892),i=n(4723),o=n(7949),a=n(5483),s=n(8871),l=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],c="up",h="right",u="down",d="left",f=l.length;class g extends o.Group{constructor(t){super(t),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){let e,n=this;const r=function(){n._sync()};for(e=0;e<f;e++)t.on(l[e]+"Change.konva",r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,n,r,i,o,a,s=this.getText(),l=this.getTag();if(s&&l){switch(t=s.width(),e=s.height(),n=l.pointerDirection(),r=l.pointerWidth(),a=l.pointerHeight(),i=0,o=0,n){case c:i=t/2,o=-1*a;break;case h:i=t+r,o=e/2;break;case u:i=t/2,o=e+a;break;case d:i=-1*r,o=e/2}l.setAttrs({x:-1*i,y:-1*o,width:t,height:e}),s.setAttrs({x:-1*i,y:-1*o})}}}e.Label=g,g.prototype.className="Label",(0,s._registerNode)(g);class p extends i.Shape{_sceneFunc(t){const e=this.width(),n=this.height(),r=this.pointerDirection(),i=this.pointerWidth(),o=this.pointerHeight(),a=this.cornerRadius();let s=0,l=0,f=0,g=0;"number"==typeof a?s=l=f=g=Math.min(a,e/2,n/2):(s=Math.min(a[0]||0,e/2,n/2),l=Math.min(a[1]||0,e/2,n/2),g=Math.min(a[2]||0,e/2,n/2),f=Math.min(a[3]||0,e/2,n/2)),t.beginPath(),t.moveTo(s,0),r===c&&(t.lineTo((e-i)/2,0),t.lineTo(e/2,-1*o),t.lineTo((e+i)/2,0)),t.lineTo(e-l,0),t.arc(e-l,l,l,3*Math.PI/2,0,!1),r===h&&(t.lineTo(e,(n-o)/2),t.lineTo(e+i,n/2),t.lineTo(e,(n+o)/2)),t.lineTo(e,n-g),t.arc(e-g,n-g,g,0,Math.PI/2,!1),r===u&&(t.lineTo((e+i)/2,n),t.lineTo(e/2,n+o),t.lineTo((e-i)/2,n)),t.lineTo(f,n),t.arc(f,n-f,f,Math.PI/2,Math.PI,!1),r===d&&(t.lineTo(0,(n+o)/2),t.lineTo(-1*i,n/2),t.lineTo(0,(n-o)/2)),t.lineTo(0,s),t.arc(s,s,s,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,n=this.pointerWidth(),r=this.pointerHeight(),i=this.pointerDirection(),o=this.width(),a=this.height();return i===c?(e-=r,a+=r):i===u?a+=r:i===d?(t-=1.5*n,o+=n):i===h&&(o+=1.5*n),{x:t,y:e,width:o,height:a}}}e.Tag=p,p.prototype.className="Tag",(0,s._registerNode)(p),r.Factory.addGetterSetter(p,"pointerDirection","none"),r.Factory.addGetterSetter(p,"pointerWidth",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(p,"pointerHeight",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(p,"cornerRadius",0,(0,a.getNumberOrArrayOfNumbersValidator)(4))},6627:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Brighten=void 0;const r=n(4892),i=n(6536),o=n(5483);e.Brighten=function(t){const e=255*this.brightness(),n=t.data,r=n.length;for(let t=0;t<r;t+=4)n[t]+=e,n[t+1]+=e,n[t+2]+=e},r.Factory.addGetterSetter(i.Node,"brightness",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},6921:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RGB=void 0;const r=n(4892),i=n(6536),o=n(5483);e.RGB=function(t){const e=t.data,n=e.length,r=this.red(),i=this.green(),o=this.blue();for(let t=0;t<n;t+=4){const n=(.34*e[t]+.5*e[t+1]+.16*e[t+2])/255;e[t]=n*r,e[t+1]=n*i,e[t+2]=n*o,e[t+3]=e[t+3]}},r.Factory.addGetterSetter(i.Node,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),r.Factory.addGetterSetter(i.Node,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),r.Factory.addGetterSetter(i.Node,"blue",0,o.RGBComponent,r.Factory.afterSetFilter)},6955:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Ellipse=void 0;const r=n(4892),i=n(4723),o=n(5483),a=n(8871);class s extends i.Shape{_sceneFunc(t){const e=this.radiusX(),n=this.radiusY();t.beginPath(),t.save(),e!==n&&t.scale(1,n/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}}e.Ellipse=s,s.prototype.className="Ellipse",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,a._registerNode)(s),r.Factory.addComponentsGetterSetter(s,"radius",["x","y"]),r.Factory.addGetterSetter(s,"radiusX",0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(s,"radiusY",0,(0,o.getNumberValidator)())},7019:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Posterize=void 0;const r=n(4892),i=n(6536),o=n(5483);e.Posterize=function(t){const e=Math.round(254*this.levels())+1,n=t.data,r=n.length,i=255/e;for(let t=0;t<r;t+=1)n[t]=Math.floor(n[t]/i)*i},r.Factory.addGetterSetter(i.Node,"levels",.5,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},7241:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Grayscale=void 0,e.Grayscale=function(t){const e=t.data,n=e.length;for(let t=0;t<n;t+=4){const n=.34*e[t]+.5*e[t+1]+.16*e[t+2];e[t]=n,e[t+1]=n,e[t+2]=n}}},7256:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Image=void 0;const r=n(4060),i=n(4892),o=n(4723),a=n(8871),s=n(5483);class l extends o.Shape{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",t=>{this._removeImageLoad(t.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(t){const e=this.getWidth(),n=this.getHeight(),i=this.cornerRadius(),o=this.attrs.image;let a;if(o){const t=this.attrs.cropWidth,r=this.attrs.cropHeight;a=t&&r?[o,this.cropX(),this.cropY(),t,r,0,0,e,n]:[o,0,0,e,n]}(this.hasFill()||this.hasStroke()||i)&&(t.beginPath(),i?r.Util.drawRoundedRectPath(t,e,n,i):t.rect(0,0,e,n),t.closePath(),t.fillStrokeShape(this)),o&&(i&&t.clip(),t.drawImage.apply(t,a))}_hitFunc(t){const e=this.width(),n=this.height(),i=this.cornerRadius();t.beginPath(),i?r.Util.drawRoundedRectPath(t,e,n,i):t.rect(0,0,e,n),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(t,e,n=null){const i=r.Util.createImageElement();i.onload=function(){const t=new l({image:i});e(t)},i.onerror=n,i.crossOrigin="Anonymous",i.src=t}}e.Image=l,l.prototype.className="Image",(0,a._registerNode)(l),i.Factory.addGetterSetter(l,"cornerRadius",0,(0,s.getNumberOrArrayOfNumbersValidator)(4)),i.Factory.addGetterSetter(l,"image"),i.Factory.addComponentsGetterSetter(l,"crop",["x","y","width","height"]),i.Factory.addGetterSetter(l,"cropX",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(l,"cropY",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(l,"cropWidth",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(l,"cropHeight",0,(0,s.getNumberValidator)())},7324:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Stage=e.stages=void 0;const r=n(4060),i=n(4892),o=n(4473),a=n(8871),s=n(8604),l=n(1268),c=n(8871),h=n(8722),u="mouseleave",d="mouseover",f="mouseenter",g="mousemove",p="mousedown",m="mouseup",y="pointermove",v="pointerdown",_="pointerup",w="pointercancel",b="pointerout",C="pointerleave",x="pointerover",S="pointerenter",A="contextmenu",E="touchstart",T="touchend",M="touchmove",P="touchcancel",N="wheel",O=[[f,"_pointerenter"],[p,"_pointerdown"],[g,"_pointermove"],[m,"_pointerup"],[u,"_pointerleave"],[E,"_pointerdown"],[M,"_pointermove"],[T,"_pointerup"],[P,"_pointercancel"],[d,"_pointerover"],[N,"_wheel"],[A,"_contextmenu"],[v,"_pointerdown"],[y,"_pointermove"],[_,"_pointerup"],[w,"_pointercancel"],[C,"_pointerleave"],["lostpointercapture","_lostpointercapture"]],F={mouse:{[b]:"mouseout",[C]:u,[x]:d,[S]:f,[y]:g,[v]:p,[_]:m,[w]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[b]:"touchout",[C]:"touchleave",[x]:"touchover",[S]:"touchenter",[y]:M,[v]:E,[_]:T,[w]:P,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[b]:b,[C]:C,[x]:x,[S]:S,[y]:y,[v]:v,[_]:_,[w]:w,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},R=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",I=t=>{const e=R(t);return"pointer"===e?a.Konva.pointerEventsEnabled&&F.pointer:"touch"===e?F.touch:"mouse"===e?F.mouse:void 0};function D(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&r.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}e.stages=[];class L extends o.Container{constructor(t){super(D(t)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),e.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{D(this.attrs)}),this._checkVisibility()}_validateAdd(t){const e="Layer"===t.getType(),n="FastLayer"===t.getType();e||n||r.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){let e;if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else e="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(e);if(!t)throw"Can not find container in document with id "+e}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const t=this.children,e=t.length;for(let n=0;n<e;n++)t[n].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),o.Container.prototype.clone.call(this,t)}destroy(){super.destroy();const t=this.content;t&&r.Util._isInDocument(t)&&this.container().removeChild(t);const n=e.stages.indexOf(this);return n>-1&&e.stages.splice(n,1),r.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(r.Util.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find(e=>e.id===t)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t=t||{}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();const e=new s.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),n=e.getContext()._context,r=this.children;return(t.x||t.y)&&n.translate(-1*t.x,-1*t.y),r.forEach(function(e){if(!e.isVisible())return;const r=e._toKonvaCanvas(t);n.drawImage(r._canvas,t.x,t.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio())}),e}getIntersection(t){if(!t)return null;const e=this.children;for(let n=e.length-1;n>=0;n--){const r=e[n].getIntersection(t);if(r)return r}return null}_resizeDOM(){const t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach(n=>{n.setSize({width:t,height:e}),n.draw()})}add(t,...e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const n=this.children.length;return n>5&&r.Util.warn("The stage has "+n+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),a.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return h.hasPointerCapture(t,this)}setPointerCapture(t){h.setPointerCapture(t,this)}releaseCapture(t){h.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){a.Konva.isBrowser&&O.forEach(([t,e])=>{this.content.addEventListener(t,t=>{this[e](t)},{passive:!1})})}_pointerenter(t){this.setPointersPositions(t);const e=I(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=I(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=I(t.type),n=R(t.type);if(!e)return;this.setPointersPositions(t);const r=this._getTargetShape(n),i=!(a.Konva.isDragging()||a.Konva.isTransforming())||a.Konva.hitOnDragEnabled;r&&i?(r._fireAndBubble(e.pointerout,{evt:t}),r._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[n+"targetShape"]=null):i&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(t){const e=I(t.type),n=R(t.type);if(!e)return;this.setPointersPositions(t);let r=!1;this._changedPointerPositions.forEach(i=>{const o=this.getIntersection(i);if(l.DD.justDragged=!1,a.Konva["_"+n+"ListenClick"]=!0,!o||!o.isListening())return void(this[n+"ClickStartShape"]=void 0);a.Konva.capturePointerEventsEnabled&&o.setPointerCapture(i.id),this[n+"ClickStartShape"]=o,o._fireAndBubble(e.pointerdown,{evt:t,pointerId:i.id}),r=!0;const s=t.type.indexOf("touch")>=0;o.preventDefault()&&t.cancelable&&s&&t.preventDefault()}),r||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=I(t.type),n=R(t.type);if(!e)return;if(a.Konva.isDragging()&&l.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),(a.Konva.isDragging()||a.Konva.isTransforming())&&!a.Konva.hitOnDragEnabled)return;const r={};let i=!1;const o=this._getTargetShape(n);this._changedPointerPositions.forEach(a=>{const s=h.getCapturedShape(a.id)||this.getIntersection(a),l=a.id,c={evt:t,pointerId:l},u=o!==s;if(u&&o&&(o._fireAndBubble(e.pointerout,{...c},s),o._fireAndBubble(e.pointerleave,{...c},s)),s){if(r[s._id])return;r[s._id]=!0}s&&s.isListening()?(i=!0,u&&(s._fireAndBubble(e.pointerover,{...c},o),s._fireAndBubble(e.pointerenter,{...c},o),this[n+"targetShape"]=s),s._fireAndBubble(e.pointermove,{...c})):o&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:l}),this[n+"targetShape"]=null)}),i||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=I(t.type),n=R(t.type);if(!e)return;this.setPointersPositions(t);const r=this[n+"ClickStartShape"],i=this[n+"ClickEndShape"],o={};let s=!1;this._changedPointerPositions.forEach(c=>{const u=h.getCapturedShape(c.id)||this.getIntersection(c);if(u){if(u.releaseCapture(c.id),o[u._id])return;o[u._id]=!0}const d=c.id,f={evt:t,pointerId:d};let g=!1;a.Konva["_"+n+"InDblClickWindow"]?(g=!0,clearTimeout(this[n+"DblTimeout"])):l.DD.justDragged||(a.Konva["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout(function(){a.Konva["_"+n+"InDblClickWindow"]=!1},a.Konva.dblClickWindow),u&&u.isListening()?(s=!0,this[n+"ClickEndShape"]=u,u._fireAndBubble(e.pointerup,{...f}),a.Konva["_"+n+"ListenClick"]&&r&&r===u&&(u._fireAndBubble(e.pointerclick,{...f}),g&&i&&i===u&&u._fireAndBubble(e.pointerdblclick,{...f}))):(this[n+"ClickEndShape"]=null,a.Konva["_"+n+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:d}),g&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:d}))}),s||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),a.Konva["_"+n+"ListenClick"]=!1,t.cancelable&&"touch"!==n&&"pointer"!==n&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(A,{evt:t}):this._fire(A,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(N,{evt:t}):this._fire(N,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=h.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(_,h.createEvent(t)),h.releaseCapture(t.pointerId)}_lostpointercapture(t){h.releaseCapture(t.pointerId)}setPointersPositions(t){const e=this._getContentPosition();let n=null,i=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})}),Array.prototype.forEach.call(t.changedTouches||t.touches,t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})})):(n=(t.clientX-e.left)/e.scaleX,i=(t.clientY-e.top)/e.scaleY,this.pointerPos={x:n,y:i},this._pointerPositions=[{x:n,y:i,id:r.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:n,y:i,id:r.Util._getFirstPointerId(t)}])}_setPointerPosition(t){r.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new s.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new s.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!a.Konva.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}cache(){return r.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(t){t.batchDraw()}),this}}e.Stage=L,L.prototype.nodeType="Stage",(0,c._registerNode)(L),i.Factory.addGetterSetter(L,"container"),a.Konva.isBrowser&&document.addEventListener("visibilitychange",()=>{e.stages.forEach(t=>{t.batchDraw()})})},7457:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.FastLayer=void 0;const r=n(4060),i=n(6267),o=n(8871);class a extends i.Layer{constructor(t){super(t),this.listening(!1),r.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}e.FastLayer=a,a.prototype.nodeType="FastLayer",(0,o._registerNode)(a)},7659:t=>{"use strict";var e={};t.exports=function(t,n){var r=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},7825:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var i=void 0!==n.layer;i&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,i&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var o=n.sourceMap;o&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(r,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},7928:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Enhance=void 0;const r=n(4892),i=n(6536),o=n(5483);function a(t,e,n,r,i){const o=n-e,a=i-r;if(0===o)return r+a/2;if(0===a)return r;let s=(t-e)/o;return s=a*s+r,s}e.Enhance=function(t){const e=t.data,n=e.length;let r,i,o,s=e[0],l=s,c=e[1],h=c,u=e[2],d=u;const f=this.enhance();if(0===f)return;for(let t=0;t<n;t+=4)r=e[t+0],r<s?s=r:r>l&&(l=r),i=e[t+1],i<c?c=i:i>h&&(h=i),o=e[t+2],o<u?u=o:o>d&&(d=o);let g,p,m,y,v,_;if(l===s&&(l=255,s=0),h===c&&(h=255,c=0),d===u&&(d=255,u=0),f>0)g=l+f*(255-l),p=s-f*(s-0),m=h+f*(255-h),y=c-f*(c-0),v=d+f*(255-d),_=u-f*(u-0);else{const t=.5*(l+s);g=l+f*(l-t),p=s+f*(s-t);const e=.5*(h+c);m=h+f*(h-e),y=c+f*(c-e);const n=.5*(d+u);v=d+f*(d-n),_=u+f*(u-n)}for(let t=0;t<n;t+=4)e[t+0]=a(e[t+0],s,l,p,g),e[t+1]=a(e[t+1],c,h,y,m),e[t+2]=a(e[t+2],u,d,_,v)},r.Factory.addGetterSetter(i.Node,"enhance",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},7949:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Group=void 0;const r=n(4060),i=n(4473),o=n(8871);class a extends i.Container{_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&r.Util.throw("You may only add groups and shapes to groups.")}}e.Group=a,a.prototype.nodeType="Group",(0,o._registerNode)(a)},8001:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Wedge=void 0;const r=n(4892),i=n(4723),o=n(8871),a=n(5483),s=n(8871);class l extends i.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,o.Konva.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}e.Wedge=l,l.prototype.className="Wedge",l.prototype._centroid=!0,l.prototype._attrsAffectingSize=["radius"],(0,s._registerNode)(l),r.Factory.addGetterSetter(l,"radius",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(l,"angle",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(l,"clockwise",!1),r.Factory.backCompat(l,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"})},8137:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TextPath=void 0;const r=n(4060),i=n(4892),o=n(4723),a=n(1486),s=n(1958),l=n(5483),c=n(8871),h="normal";function u(t){t.fillText(this.partialText,0,0)}function d(t){t.strokeText(this.partialText,0,0)}class f extends o.Shape{constructor(t){super(t),this.dummyCanvas=r.Util.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return a.Path.getPathLength(this.dataArray)}_getPointAtLength(t){return this.attrs.data?t-1>this.pathLength?null:a.Path.getPointAtLengthOfDataArray(t,this.dataArray):null}_readDataAttribute(){this.dataArray=a.Path.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();const e=this.textDecoration(),n=this.fill(),r=this.fontSize(),i=this.glyphInfo;"underline"===e&&t.beginPath();for(let n=0;n<i.length;n++){t.save();const o=i[n].p0;t.translate(o.x,o.y),t.rotate(i[n].rotation),this.partialText=i[n].text,t.fillStrokeShape(this),"underline"===e&&(0===n&&t.moveTo(0,r/2+1),t.lineTo(r,r/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=n,t.lineWidth=r/20,t.stroke()),t.restore()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const n=e[0].p0;t.moveTo(n.x,n.y)}for(let n=0;n<e.length;n++){const r=e[n].p1;t.lineTo(r.x,r.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return r.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return s.Text.prototype.setText.call(this,t)}_getContextFont(){return s.Text.prototype._getContextFont.call(this)}_getTextSize(t){const e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();const n=e.measureText(t);return e.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:t,height:e}=this._getTextSize(this.attrs.text);if(this.textWidth=t,this.textHeight=e,this.glyphInfo=[],!this.attrs.data)return null;const n=this.letterSpacing(),r=this.align(),i=this.kerningFunc(),o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*n,0);let l=0;"center"===r&&(l=Math.max(0,this.pathLength/2-o/2)),"right"===r&&(l=Math.max(0,this.pathLength-o));const c=(0,s.stringToArray)(this.text());let h=l;for(let t=0;t<c.length;t++){const e=this._getPointAtLength(h);if(!e)return;let s=this._getTextSize(c[t]).width+n;if(" "===c[t]&&"justify"===r){const t=this.text().split(" ").length-1;s+=(this.pathLength-o)/t}const l=this._getPointAtLength(h+s);if(!l)return;const u=a.Path.getLineLength(e.x,e.y,l.x,l.y);let d=0;if(i)try{d=i(c[t-1],c[t])*this.fontSize()}catch(t){d=0}e.x+=d,l.x+=d,this.textWidth+=d;const f=a.Path.getPointOnLine(d+u/2,e.x,e.y,l.x,l.y),g=Math.atan2(l.y-e.y,l.x-e.x);this.glyphInfo.push({transposeX:f.x,transposeY:f.y,text:c[t],rotation:g,p0:e,p1:l}),h+=s}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const t=[];this.glyphInfo.forEach(function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)});let e,n,r=t[0]||0,i=t[0]||0,o=t[1]||0,a=t[1]||0;for(let s=0;s<t.length/2;s++)e=t[2*s],n=t[2*s+1],r=Math.min(r,e),i=Math.max(i,e),o=Math.min(o,n),a=Math.max(a,n);const s=this.fontSize();return{x:r-s/2,y:o-s/2,width:i-r+s,height:a-o+s}}destroy(){return r.Util.releaseCanvas(this.dummyCanvas),super.destroy()}}e.TextPath=f,f.prototype._fillFunc=u,f.prototype._strokeFunc=d,f.prototype._fillFuncHit=u,f.prototype._strokeFuncHit=d,f.prototype.className="TextPath",f.prototype._attrsAffectingSize=["text","fontSize","data"],(0,c._registerNode)(f),i.Factory.addGetterSetter(f,"data"),i.Factory.addGetterSetter(f,"fontFamily","Arial"),i.Factory.addGetterSetter(f,"fontSize",12,(0,l.getNumberValidator)()),i.Factory.addGetterSetter(f,"fontStyle",h),i.Factory.addGetterSetter(f,"align","left"),i.Factory.addGetterSetter(f,"letterSpacing",0,(0,l.getNumberValidator)()),i.Factory.addGetterSetter(f,"textBaseline","middle"),i.Factory.addGetterSetter(f,"fontVariant",h),i.Factory.addGetterSetter(f,"text",""),i.Factory.addGetterSetter(f,"textDecoration",""),i.Factory.addGetterSetter(f,"kerningFunc",void 0)},8558:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Konva=void 0;const r=n(680),i=n(4821),o=n(9456),a=n(9729),s=n(6955),l=n(7256),c=n(6619),h=n(3443),u=n(1486),d=n(5155),f=n(9131),g=n(5451),p=n(9308),m=n(4481),y=n(1958),v=n(8137),_=n(5058),w=n(8001),b=n(6261),C=n(6627),x=n(2650),S=n(983),A=n(7928),E=n(7241),T=n(5461),M=n(4843),P=n(6564),N=n(5553),O=n(8624),F=n(5992),R=n(4943),I=n(7019),D=n(6921),L=n(3862),k=n(2512),U=n(517),G=n(661);e.Konva=r.Konva.Util._assign(r.Konva,{Arc:i.Arc,Arrow:o.Arrow,Circle:a.Circle,Ellipse:s.Ellipse,Image:l.Image,Label:c.Label,Tag:c.Tag,Line:h.Line,Path:u.Path,Rect:d.Rect,RegularPolygon:f.RegularPolygon,Ring:g.Ring,Sprite:p.Sprite,Star:m.Star,Text:y.Text,TextPath:v.TextPath,Transformer:_.Transformer,Wedge:w.Wedge,Filters:{Blur:b.Blur,Brighten:C.Brighten,Contrast:x.Contrast,Emboss:S.Emboss,Enhance:A.Enhance,Grayscale:E.Grayscale,HSL:T.HSL,HSV:M.HSV,Invert:P.Invert,Kaleidoscope:N.Kaleidoscope,Mask:O.Mask,Noise:F.Noise,Pixelate:R.Pixelate,Posterize:I.Posterize,RGB:D.RGB,RGBA:L.RGBA,Sepia:k.Sepia,Solarize:U.Solarize,Threshold:G.Threshold}})},8604:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HitCanvas=e.SceneCanvas=e.Canvas=void 0;const r=n(4060),i=n(9869),o=n(8871);let a;class s{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const e=(t||{}).pixelRatio||o.Konva.pixelRatio||function(){if(a)return a;const t=r.Util.createCanvasElement(),e=t.getContext("2d");return a=(o.Konva._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),r.Util.releaseCanvas(t),a}();this.pixelRatio=e,this._canvas=r.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){const e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return r.Util.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}e.Canvas=s,e.SceneCanvas=class extends s{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new i.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}},e.HitCanvas=class extends s{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new i.HitContext(this),this.setSize(t.width,t.height)}}},8624:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Mask=void 0;const r=n(4892),i=n(6536),o=n(5483);function a(t,e,n){let r=4*(n*t.width+e);const i=[];return i.push(t.data[r++],t.data[r++],t.data[r++],t.data[r++]),i}function s(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}e.Mask=function(t){let e=function(t,e){const n=a(t,0,0),r=a(t,t.width-1,0),i=a(t,0,t.height-1),o=a(t,t.width-1,t.height-1),l=e||10;if(s(n,r)<l&&s(r,o)<l&&s(o,i)<l&&s(i,n)<l){const e=function(t){const e=[0,0,0];for(let n=0;n<t.length;n++)e[0]+=t[n][0],e[1]+=t[n][1],e[2]+=t[n][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([r,n,o,i]),a=[];for(let n=0;n<t.width*t.height;n++){const r=s(e,[t.data[4*n],t.data[4*n+1],t.data[4*n+2]]);a[n]=r<l?0:255}return a}}(t,this.threshold());return e&&(e=function(t,e,n){const r=[1,1,1,1,0,1,1,1,1],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),a=[];for(let s=0;s<n;s++)for(let l=0;l<e;l++){const c=s*e+l;let h=0;for(let a=0;a<i;a++)for(let c=0;c<i;c++){const u=s+a-o,d=l+c-o;if(u>=0&&u<n&&d>=0&&d<e){const n=r[a*i+c];h+=t[u*e+d]*n}}a[c]=2040===h?255:0}return a}(e,t.width,t.height),e=function(t,e,n){const r=[1,1,1,1,1,1,1,1,1],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),a=[];for(let s=0;s<n;s++)for(let l=0;l<e;l++){const c=s*e+l;let h=0;for(let a=0;a<i;a++)for(let c=0;c<i;c++){const u=s+a-o,d=l+c-o;if(u>=0&&u<n&&d>=0&&d<e){const n=r[a*i+c];h+=t[u*e+d]*n}}a[c]=h>=1020?255:0}return a}(e,t.width,t.height),e=function(t,e,n){const r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),a=[];for(let s=0;s<n;s++)for(let l=0;l<e;l++){const c=s*e+l;let h=0;for(let a=0;a<i;a++)for(let c=0;c<i;c++){const u=s+a-o,d=l+c-o;if(u>=0&&u<n&&d>=0&&d<e){const n=r[a*i+c];h+=t[u*e+d]*n}}a[c]=h}return a}(e,t.width,t.height),function(t,e){for(let n=0;n<t.width*t.height;n++)t.data[4*n+3]=e[n]}(t,e)),t},r.Factory.addGetterSetter(i.Node,"threshold",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},8665:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Easings=e.Tween=void 0;const r=n(4060),i=n(9696),o=n(6536),a=n(8871),s={node:1,duration:1,easing:1,onFinish:1,yoyo:1},l=["fill","stroke","shadowColor"];let c=0;class h{constructor(t,e,n,r,i,o,a){this.prop=t,this.propFunc=e,this.begin=r,this._pos=r,this.duration=o,this._change=0,this.prevPos=0,this.yoyo=a,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=i-this.begin,this.pause()}fire(t){const e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class u{constructor(t){const n=this,o=t.node,l=o._id,d=t.easing||e.Easings.Linear,f=!!t.yoyo;let g,p;g=void 0===t.duration?.3:0===t.duration?.001:t.duration,this.node=o,this._id=c++;const m=o.getLayer()||(o instanceof a.Konva.Stage?o.getLayers():null);for(p in m||r.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new i.Animation(function(){n.tween.onEnterFrame()},m),this.tween=new h(p,function(t){n._tweenFunc(t)},d,0,1,1e3*g,f),this._addListeners(),u.attrs[l]||(u.attrs[l]={}),u.attrs[l][this._id]||(u.attrs[l][this._id]={}),u.tweens[l]||(u.tweens[l]={}),t)void 0===s[p]&&this._addAttr(p,t[p]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,e){const n=this.node,i=n._id;let o,a,s,c,h;const d=u.tweens[i][t];d&&delete u.attrs[i][d][t];let f=n.getAttr(t);if(r.Util._isArray(e))if(o=[],a=Math.max(e.length,f.length),"points"===t&&e.length!==f.length&&(e.length>f.length?(c=f,f=r.Util._prepareArrayForTween(f,e,n.closed())):(s=e,e=r.Util._prepareArrayForTween(e,f,n.closed()))),0===t.indexOf("fill"))for(let t=0;t<a;t++)if(t%2==0)o.push(e[t]-f[t]);else{const n=r.Util.colorToRGBA(f[t]);h=r.Util.colorToRGBA(e[t]),f[t]=n,o.push({r:h.r-n.r,g:h.g-n.g,b:h.b-n.b,a:h.a-n.a})}else for(let t=0;t<a;t++)o.push(e[t]-f[t]);else-1!==l.indexOf(t)?(f=r.Util.colorToRGBA(f),h=r.Util.colorToRGBA(e),o={r:h.r-f.r,g:h.g-f.g,b:h.b-f.b,a:h.a-f.a}):o=e-f;u.attrs[i][this._id][t]={start:f,diff:o,end:e,trueEnd:s,trueStart:c},u.tweens[i][t]=this._id}_tweenFunc(t){const e=this.node,n=u.attrs[e._id][this._id];let i,o,a,s,c,h,d,f;for(i in n){if(o=n[i],a=o.start,s=o.diff,f=o.end,r.Util._isArray(a))if(c=[],d=Math.max(a.length,f.length),0===i.indexOf("fill"))for(h=0;h<d;h++)h%2==0?c.push((a[h]||0)+s[h]*t):c.push("rgba("+Math.round(a[h].r+s[h].r*t)+","+Math.round(a[h].g+s[h].g*t)+","+Math.round(a[h].b+s[h].b*t)+","+(a[h].a+s[h].a*t)+")");else for(h=0;h<d;h++)c.push((a[h]||0)+s[h]*t);else c=-1!==l.indexOf(i)?"rgba("+Math.round(a.r+s.r*t)+","+Math.round(a.g+s.g*t)+","+Math.round(a.b+s.b*t)+","+(a.a+s.a*t)+")":a+s*t;e.setAttr(i,c)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,e=u.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,e=u.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,e=this._id,n=u.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const e in n)delete u.tweens[t][e];delete u.attrs[t][e],u.tweens[t]&&(0===Object.keys(u.tweens[t]).length&&delete u.tweens[t],0===Object.keys(u.attrs[t]).length&&delete u.attrs[t])}}e.Tween=u,u.attrs={},u.tweens={},o.Node.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new u(t).play()},e.Easings={BackEaseIn(t,e,n,r){const i=1.70158;return n*(t/=r)*t*((i+1)*t-i)+e},BackEaseOut(t,e,n,r){const i=1.70158;return n*((t=t/r-1)*t*((i+1)*t+i)+1)+e},BackEaseInOut(t,e,n,r){let i=1.70158;return(t/=r/2)<1?n/2*(t*t*((1+(i*=1.525))*t-i))+e:n/2*((t-=2)*t*((1+(i*=1.525))*t+i)+2)+e},ElasticEaseIn(t,e,n,r,i,o){let a=0;return 0===t?e:1===(t/=r)?e+n:(o||(o=.3*r),!i||i<Math.abs(n)?(i=n,a=o/4):a=o/(2*Math.PI)*Math.asin(n/i),-i*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)+e)},ElasticEaseOut(t,e,n,r,i,o){let a=0;return 0===t?e:1===(t/=r)?e+n:(o||(o=.3*r),!i||i<Math.abs(n)?(i=n,a=o/4):a=o/(2*Math.PI)*Math.asin(n/i),i*Math.pow(2,-10*t)*Math.sin((t*r-a)*(2*Math.PI)/o)+n+e)},ElasticEaseInOut(t,e,n,r,i,o){let a=0;return 0===t?e:2==(t/=r/2)?e+n:(o||(o=r*(.3*1.5)),!i||i<Math.abs(n)?(i=n,a=o/4):a=o/(2*Math.PI)*Math.asin(n/i),t<1?i*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*-.5+e:i*Math.pow(2,-10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*.5+n+e)},BounceEaseOut:(t,e,n,r)=>(t/=r)<1/2.75?n*(7.5625*t*t)+e:t<2/2.75?n*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?n*(7.5625*(t-=2.25/2.75)*t+.9375)+e:n*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(t,n,r,i)=>r-e.Easings.BounceEaseOut(i-t,0,r,i)+n,BounceEaseInOut:(t,n,r,i)=>t<i/2?.5*e.Easings.BounceEaseIn(2*t,0,r,i)+n:.5*e.Easings.BounceEaseOut(2*t-i,0,r,i)+.5*r+n,EaseIn:(t,e,n,r)=>n*(t/=r)*t+e,EaseOut:(t,e,n,r)=>-n*(t/=r)*(t-2)+e,EaseInOut:(t,e,n,r)=>(t/=r/2)<1?n/2*t*t+e:-n/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,n,r)=>n*(t/=r)*t*t*t*t+e,StrongEaseOut:(t,e,n,r)=>n*((t=t/r-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,n,r)=>(t/=r/2)<1?n/2*t*t*t*t*t+e:n/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,n,r)=>n*t/r+e}},8722:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getCapturedShape=function(t){return i.get(t)},e.createEvent=a,e.hasPointerCapture=function(t,e){return i.get(t)===e},e.setPointerCapture=function(t,e){s(t),e.getStage()&&(i.set(t,e),o&&e._fire("gotpointercapture",a(new PointerEvent("gotpointercapture"))))},e.releaseCapture=s;const r=n(8871),i=new Map,o=void 0!==r.Konva._global.PointerEvent;function a(t){return{evt:t,pointerId:t.pointerId}}function s(t,e){const n=i.get(t);if(!n)return;const r=n.getStage();r&&r.content,i.delete(t),o&&n._fire("lostpointercapture",a(new PointerEvent("lostpointercapture")))}},8871:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e._registerNode=e.Konva=e.glob=void 0;const r=Math.PI/180;e.glob=void 0!==n.g?n.g:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},e.Konva={_global:e.glob,version:"9.3.22",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:t=>e.Konva.angleDeg?t*r:t,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>e.Konva.DD.isDragging,isTransforming(){var t;return null===(t=e.Konva.Transformer)||void 0===t?void 0:t.isTransforming()},isDragReady:()=>!!e.Konva.DD.node,releaseCanvasOnDestroy:!0,document:e.glob.document,_injectGlobal(t){e.glob.Konva=t}},e._registerNode=t=>{e.Konva[t.prototype.getClassName()]=t},e.Konva._injectGlobal(e.Konva)},9131:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RegularPolygon=void 0;const r=n(4892),i=n(4723),o=n(5483),a=n(8871);class s extends i.Shape{_sceneFunc(t){const e=this._getPoints();t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let n=1;n<e.length;n++)t.lineTo(e[n].x,e[n].y);t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,n=[];for(let r=0;r<t;r++)n.push({x:e*Math.sin(2*r*Math.PI/t),y:-1*e*Math.cos(2*r*Math.PI/t)});return n}getSelfRect(){const t=this._getPoints();let e=t[0].x,n=t[0].y,r=t[0].x,i=t[0].y;return t.forEach(t=>{e=Math.min(e,t.x),n=Math.max(n,t.x),r=Math.min(r,t.y),i=Math.max(i,t.y)}),{x:e,y:r,width:n-e,height:i-r}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}e.RegularPolygon=s,s.prototype.className="RegularPolygon",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["radius"],(0,a._registerNode)(s),r.Factory.addGetterSetter(s,"radius",0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(s,"sides",0,(0,o.getNumberValidator)())},9308:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Sprite=void 0;const r=n(4892),i=n(4723),o=n(9696),a=n(5483),s=n(8871);class l extends i.Shape{constructor(t){super(t),this._updated=!0,this.anim=new o.Animation(()=>{const t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(t){const e=this.animation(),n=this.frameIndex(),r=4*n,i=this.animations()[e],o=this.frameOffsets(),a=i[r+0],s=i[r+1],l=i[r+2],c=i[r+3],h=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,l,c),t.closePath(),t.fillStrokeShape(this)),h)if(o){const r=o[e],i=2*n;t.drawImage(h,a,s,l,c,r[i+0],r[i+1],l,c)}else t.drawImage(h,a,s,l,c,0,0,l,c)}_hitFunc(t){const e=this.animation(),n=this.frameIndex(),r=4*n,i=this.animations()[e],o=this.frameOffsets(),a=i[r+2],s=i[r+3];if(t.beginPath(),o){const r=o[e],i=2*n;t.rect(r[i+0],r[i+1],a,s)}else t.rect(0,0,a,s);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const t=this;this.interval=setInterval(function(){t._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}}e.Sprite=l,l.prototype.className="Sprite",(0,s._registerNode)(l),r.Factory.addGetterSetter(l,"animation"),r.Factory.addGetterSetter(l,"animations"),r.Factory.addGetterSetter(l,"frameOffsets"),r.Factory.addGetterSetter(l,"image"),r.Factory.addGetterSetter(l,"frameIndex",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(l,"frameRate",17,(0,a.getNumberValidator)()),r.Factory.backCompat(l,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"})},9456:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Arrow=void 0;const r=n(4892),i=n(3443),o=n(5483),a=n(8871),s=n(1486);class l extends i.Line{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,n=this.points();let r=n;const i=0!==this.tension()&&n.length>4;i&&(r=this.getTensionPoints());const o=this.pointerLength(),a=n.length;let l,c;if(i){const t=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[a-2],n[a-1]],e=s.Path.calcLength(r[r.length-4],r[r.length-3],"C",t),i=s.Path.getPointOnQuadraticBezier(Math.min(1,1-o/e),t[0],t[1],t[2],t[3],t[4],t[5]);l=n[a-2]-i.x,c=n[a-1]-i.y}else l=n[a-2]-n[a-4],c=n[a-1]-n[a-3];const h=(Math.atan2(c,l)+e)%e,u=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(n[a-2],n[a-1]),t.rotate(h),t.moveTo(0,0),t.lineTo(-o,u/2),t.lineTo(-o,-u/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(n[0],n[1]),i?(l=(r[0]+r[2])/2-n[0],c=(r[1]+r[3])/2-n[1]):(l=n[2]-n[0],c=n[3]-n[1]),t.rotate((Math.atan2(-c,-l)+e)%e),t.moveTo(0,0),t.lineTo(-o,u/2),t.lineTo(-o,-u/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){const e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x,y:t.y-e,width:t.width,height:t.height+2*e}}}e.Arrow=l,l.prototype.className="Arrow",(0,a._registerNode)(l),r.Factory.addGetterSetter(l,"pointerLength",10,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(l,"pointerWidth",10,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(l,"pointerAtBeginning",!1),r.Factory.addGetterSetter(l,"pointerAtEnding",!0)},9696:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Animation=void 0;const r=n(8871),i=n(4060),o=r.glob.performance&&r.glob.performance.now?function(){return r.glob.performance.now()}:function(){return(new Date).getTime()};class a{constructor(t,e){this.id=a.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:o(),frameRate:0},this.func=t,this.setLayers(e)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,n=e.length;for(let r=0;r<n;r++)if(e[r]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=a.animations,e=t.length;for(let n=0;n<e;n++)if(t[n].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=o(),a._addAnimation(this),this}stop(){return a._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,n=this.animations,r=n.length;for(let t=0;t<r;t++)if(n[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let n=0;n<e.length;n++){const r=e[n],i=r.layers,a=r.func;r._updateFrameObject(o());const s=i.length;let l;if(l=!a||!1!==a.call(r,r.frame),l)for(let e=0;e<s;e++){const n=i[e];void 0!==n._id&&(t[n._id]=n)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const t=a;t.animations.length?(t._runFrames(),i.Util.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,i.Util.requestAnimFrame(this._animationLoop))}}e.Animation=a,a.animations=[],a.animIdCounter=0,a.animRunning=!1},9729:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Circle=void 0;const r=n(4892),i=n(4723),o=n(5483),a=n(8871);class s extends i.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}}e.Circle=s,s.prototype._centroid=!0,s.prototype.className="Circle",s.prototype._attrsAffectingSize=["radius"],(0,a._registerNode)(s),r.Factory.addGetterSetter(s,"radius",0,(0,o.getNumberValidator)())},9869:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HitContext=e.SceneContext=e.Context=void 0;const r=n(4060),i=n(8871),o=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];class a{constructor(t){this.canvas=t,i.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(t,e){let n,i,o,a,s=this.traceArr,l=s.length,c="";for(n=0;n<l;n++)i=s[n],o=i.method,o?(a=i.args,c+=o,t?c+="()":r.Util._isArray(a[0])?c+="(["+a.join(",")+"])":(e&&(a=a.map(t=>"number"==typeof t?Math.floor(t):t)),c+="("+a.join(",")+")")):(c+=i.property,t||(c+="="+i.val)),c+=";";return c}clearTrace(){this.traceArr=[]}_trace(t){let e,n=this.traceArr;n.push(t),e=n.length,e>=100&&n.shift()}reset(){const t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){const e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){const e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}setAttr(t,e){this._context[t]=e}arc(t,e,n,r,i,o){this._context.arc(t,e,n,r,i,o)}arcTo(t,e,n,r,i){this._context.arcTo(t,e,n,r,i)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,n,r,i,o){this._context.bezierCurveTo(t,e,n,r,i,o)}clearRect(t,e,n,r){this._context.clearRect(t,e,n,r)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const n=arguments;return 2===n.length?this._context.createImageData(t,e):1===n.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,n,r){return this._context.createLinearGradient(t,e,n,r)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,n,r,i,o){return this._context.createRadialGradient(t,e,n,r,i,o)}drawImage(t,e,n,r,i,o,a,s,l){const c=arguments,h=this._context;3===c.length?h.drawImage(t,e,n):5===c.length?h.drawImage(t,e,n,r,i):9===c.length&&h.drawImage(t,e,n,r,i,o,a,s,l)}ellipse(t,e,n,r,i,o,a,s){this._context.ellipse(t,e,n,r,i,o,a,s)}isPointInPath(t,e,n,r){return n?this._context.isPointInPath(n,t,e,r):this._context.isPointInPath(t,e,r)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,n,r){this._context.fillRect(t,e,n,r)}strokeRect(t,e,n,r){this._context.strokeRect(t,e,n,r)}fillText(t,e,n,r){r?this._context.fillText(t,e,n,r):this._context.fillText(t,e,n)}measureText(t){return this._context.measureText(t)}getImageData(t,e,n,r){return this._context.getImageData(t,e,n,r)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,n,r){this._context.rect(t,e,n,r)}roundRect(t,e,n,r,i){this._context.roundRect(t,e,n,r,i)}putImageData(t,e,n){this._context.putImageData(t,e,n)}quadraticCurveTo(t,e,n,r){this._context.quadraticCurveTo(t,e,n,r)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,n,r,i,o){this._context.setTransform(t,e,n,r,i,o)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,n,r){this._context.strokeText(t,e,n,r)}transform(t,e,n,r,i,o){this._context.transform(t,e,n,r,i,o)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let t,e,n=this,i=o.length,a=this.setAttr;const s=function(t){let i,o=n[t];n[t]=function(){return e=function(t){const e=[],n=t.length,i=r.Util;for(let r=0;r<n;r++){let n=t[r];i._isNumber(n)?n=Math.round(1e3*n)/1e3:i._isString(n)||(n+=""),e.push(n)}return e}(Array.prototype.slice.call(arguments,0)),i=o.apply(n,arguments),n._trace({method:t,args:e}),i}};for(t=0;t<i;t++)s(o[t]);n.setAttr=function(){a.apply(n,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),n._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}}e.Context=a,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach(function(t){Object.defineProperty(a.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}),e.SceneContext=class extends a{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){const e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){const e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),n=t.getFillPriority();if(e&&"color"===n)return void this._fillColor(t);const r=t.getFillPatternImage();if(r&&"pattern"===n)return void this._fillPattern(t);const i=t.getFillLinearGradientColorStops();if(i&&"linear-gradient"===n)return void this._fillLinearGradient(t);const o=t.getFillRadialGradientColorStops();o&&"radial-gradient"===n?this._fillRadialGradient(t):e?this._fillColor(t):r?this._fillPattern(t):i?this._fillLinearGradient(t):o&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),n=t.getStrokeLinearGradientEndPoint(),r=t.getStrokeLinearGradientColorStops(),i=this.createLinearGradient(e.x,e.y,n.x,n.y);if(r){for(let t=0;t<r.length;t+=2)i.addColorStop(r[t],r[t+1]);this.setAttr("strokeStyle",i)}}_stroke(t){const e=t.dash(),n=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!n){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),n||this.restore()}}_applyShadow(t){var e,n,r;const i=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",o=null!==(n=t.getShadowBlur())&&void 0!==n?n:5,a=null!==(r=t.getShadowOffset())&&void 0!==r?r:{x:0,y:0},s=t.getAbsoluteScale(),l=this.canvas.getPixelRatio(),c=s.x*l,h=s.y*l;this.setAttr("shadowColor",i),this.setAttr("shadowBlur",o*Math.min(Math.abs(c),Math.abs(h))),this.setAttr("shadowOffsetX",a.x*c),this.setAttr("shadowOffsetY",a.y*h)}},e.HitContext=class extends a{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){if(t.hasHitStroke()){const e=t.getStrokeScaleEnabled();if(!e){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t);const n=t.hitStrokeWidth(),r="auto"===n?t.strokeWidth():n;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}}},9982:function(t,e,n){var r;!function(){var e={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t,n,r,i,o){for(var a,s,l,c,h,u,d,f,g,p,m,y,v;o>=64;){for(a=n[0],s=n[1],l=n[2],c=n[3],h=n[4],u=n[5],d=n[6],f=n[7],p=0;p<16;p++)m=i+4*p,t[p]=(255&r[m])<<24|(255&r[m+1])<<16|(255&r[m+2])<<8|255&r[m+3];for(p=16;p<64;p++)y=((g=t[p-2])>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,v=((g=t[p-15])>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,t[p]=(y+t[p-7]|0)+(v+t[p-16]|0);for(p=0;p<64;p++)y=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&u^~h&d)|0)+(f+(e[p]+t[p]|0)|0)|0,v=((a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10))+(a&s^a&l^s&l)|0,f=d,d=u,u=h,h=c+y|0,c=l,l=s,s=a,a=y+v|0;n[0]+=a,n[1]+=s,n[2]+=l,n[3]+=c,n[4]+=h,n[5]+=u,n[6]+=d,n[7]+=f,i+=64,o-=64}return i}var r=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return e.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var r=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[r++],e--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(r=n(this.temp,this.state,t,r,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[r++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,r=this.bufferLength,i=e/536870912|0,o=e<<3,a=e%64<56?64:128;this.buffer[r]=128;for(var s=r+1;s<a-8;s++)this.buffer[s]=0;this.buffer[a-8]=i>>>24&255,this.buffer[a-7]=i>>>16&255,this.buffer[a-6]=i>>>8&255,this.buffer[a-5]=i>>>0&255,this.buffer[a-4]=o>>>24&255,this.buffer[a-3]=o>>>16&255,this.buffer[a-2]=o>>>8&255,this.buffer[a-1]=o>>>0&255,n(this.temp,this.state,this.buffer,0,a),this.finished=!0}for(s=0;s<8;s++)t[4*s+0]=this.state[s]>>>24&255,t[4*s+1]=this.state[s]>>>16&255,t[4*s+2]=this.state[s]>>>8&255,t[4*s+3]=this.state[s]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var n=0;n<this.state.length;n++)this.state[n]=t[n];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=r;var i=function(){function t(t){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new r).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;for(this.inner.update(e),n=0;n<e.length;n++)e[n]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<e.length;n++)e[n]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function o(t){var e=(new r).update(t),n=e.digest();return e.clean(),n}function a(t,e){var n=new i(t).update(e),r=n.digest();return n.clean(),r}function s(t,e,n,r){var i=r[0];if(0===i)throw new Error("hkdf: cannot expand more");e.reset(),i>1&&e.update(t),n&&e.update(n),e.update(r),e.finish(t),r[0]++}t.HMAC=i,t.hash=o,t.default=o,t.hmac=a;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,n,r){void 0===e&&(e=l),void 0===r&&(r=32);for(var o=new Uint8Array([1]),c=a(e,t),h=new i(c),u=new Uint8Array(h.digestLength),d=u.length,f=new Uint8Array(r),g=0;g<r;g++)d===u.length&&(s(u,h,n,o),d=0),f[g]=u[d++];return h.clean(),u.fill(0),o.fill(0),f},t.pbkdf2=function(t,e,n,r){for(var o=new i(t),a=o.digestLength,s=new Uint8Array(4),l=new Uint8Array(a),c=new Uint8Array(a),h=new Uint8Array(r),u=0;u*a<r;u++){var d=u+1;s[0]=d>>>24&255,s[1]=d>>>16&255,s[2]=d>>>8&255,s[3]=d>>>0&255,o.reset(),o.update(e),o.update(s),o.finish(c);for(var f=0;f<a;f++)l[f]=c[f];for(f=2;f<=n;f++){o.reset(),o.update(c).finish(c);for(var g=0;g<a;g++)l[g]^=c[g]}for(f=0;f<a&&u*a+f<r;f++)h[u*a+f]=l[f]}for(u=0;u<a;u++)l[u]=c[u]=0;for(u=0;u<4;u++)s[u]=0;return o.clean(),h}}(e);var i=e.default;for(var o in e)i[o]=e[o];"object"==typeof t.exports?t.exports=i:void 0===(r=function(){return i}.call(e,n,e,t))||(t.exports=r)}()}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.m=t,n.amdO={},n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var i=r.length-1;i>-1&&(!t||!/^http(s?):/.test(t));)t=r[i--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var r={};(()=>{"use strict";n.r(r),n.d(r,{_package:()=>Mi,initAutoTests:()=>Ni,test:()=>Pi,tests:()=>u});const t=DG;n(9982);const e=DG.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,');e.columns.add(DG.Column.fromList(DG.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var i=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const o=3e4,a=108e5,s=console.log.bind(console),l=console.info.bind(console),c=console.warn.bind(console),h=console.error.bind(console),u={},d="Auto Tests",f="Demo",g="Detectors",p="Core",m={};let y;var v;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(v||(v={}));class _{constructor(t,e,n){this.catchUnhandled=!0,this.report=!1,this.returnOnFail=!1,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e),void 0!==n&&(this.returnOnFail=n)}}class w{constructor(t,e,n,r){var a;this.category=t,this.name=e,null!=r||(r={}),null!==(a=r.timeout)&&void 0!==a||(r.timeout=o),this.options=r,this.test=()=>i(this,void 0,void 0,function*(){return new Promise((t,e)=>i(this,void 0,void 0,function*(){var r;let i="";try{DG.Test.isInDebug;let t=yield n();try{i=null!==(r=null==t?void 0:t.toString())&&void 0!==r?r:""}catch(t){i="Can't convert test's result to string",console.error(`Can't convert test's result to string in the ${this.category}:${this.name} test`)}}catch(t){e(t)}t(i)}))})}}function b(t,e,n){null==u[y]&&(u[y]={}),null==u[y].tests&&(u[y].tests=[]),u[y].tests.push(new w(y,t,e,n))}function C(t,e=!0,n){if(n=n?`${n}, `:"",t!==e)throw new Error(`${n}Expected "${e}", got "${t}"`)}function x(t,e,n){var r;y=t,e(),u[y]&&(u[y].clear=null===(r=null==n?void 0:n.clear)||void 0===r||r,u[y].timeout=null==n?void 0:n.timeout,u[y].benchmarks=null==n?void 0:n.benchmarks,u[y].stressTests=null==n?void 0:n.stressTests,u[y].owner=null==n?void 0:n.owner)}function S(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function A(t,n){var r,s,l,c,h,y,v,_,b,x;return i(this,void 0,void 0,function*(){const A=t.id;if(m[A])return;const E=n?n.tests:u;if("DevTools"===t.name||n&&"DevTools"===n._package.name)for(const t of window.dartTests){const e=t.name.split(/\s*\|\s*!/g);let n=null!==(r=e.pop())&&void 0!==r?r:t.name,i=e.length?p+": "+e.join(": "):p,a=n.split(" | ");n=a[a.length-1],a.unshift(i),a.pop(),i=a.join(": "),void 0===E[i]&&(E[i]={tests:[],clear:!0}),E[i].tests.push(new w(i,n,t.test,{isAggregated:!1,timeout:null!==(l=null===(s=t.options)||void 0===s?void 0:s.timeout)&&void 0!==l?l:o,skipReason:null===(c=t.options)||void 0===c?void 0:c.skipReason,owner:null===(h=t.options)||void 0===h?void 0:h.owner,benchmark:null!==(v=null===(y=t.options)||void 0===y?void 0:y.benchmark)&&void 0!==v&&v}))}const T=[],M=[],N=[],O=yield grok.dapi.functions.filter(`package.id = "${A}"`).list(),F=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);for(const n of O){const r=n.options.test,s=n.options.demoPath;if(r&&Array.isArray(r)&&r.length)for(let t=0;t<r.length;t++){const e=r[t].matchAll(F),s={};Array.from(e).forEach(t=>{t[0].startsWith("skip")?s.skip=t[1]:t[0].startsWith("wait")?s.wait=parseInt(t[2]):t[0].startsWith("cat")?s.cat=t[3]:t[0].startsWith("timeout")&&(s.timeout=parseInt(t[4]))});const l=new w(null!==(_=s.cat)&&void 0!==_?_:d,1===r.length?n.name:`${n.name} ${t+1}`,()=>i(this,void 0,void 0,function*(){const e=yield grok.functions.eval(S(r[t],n));if(s.wait&&(yield P(s.wait)),"boolean"==typeof e&&!e)throw`Failed: ${r[t]}, expected true, got ${e}`}),{skipReason:s.skip,timeout:DG.Test.isInBenchmark?null!==(b=s.benchmarkTimeout)&&void 0!==b?b:a:null!==(x=s.timeout)&&void 0!==x?x:o});if(s.cat){const t=s.cat;void 0===E[t]&&(E[t]={tests:[],clear:!0}),E[t].tests||(E[t].tests=[]),E[t].tests.push(l)}else T.push(l)}if(s){const t=n.options.demoWait?parseInt(n.options.demoWait):void 0,e=new w(f,n.friendlyName,()=>i(this,void 0,void 0,function*(){yield P(300),grok.shell.clearLastError(),yield n.apply(),yield P(t||2e3);const e=yield grok.shell.lastError;if(e)throw new Error(e)}),{skipReason:n.options.demoSkip});M.push(e)}if(n.hasTag("semTypeDetector")){let r=e;n.options.testData&&(r=yield grok.data.files.openTable(`System:AppData/${t.nqName}/${n.options.testData}`));const o=new w(g,n.friendlyName,()=>i(this,void 0,void 0,function*(){const e=[];console.log(`System:AppData/${t.nqName}/${n.options.testData}`);for(const t of r.clone().columns){const r=yield n.apply([t]);e.push(r||t.semType)}const i=e.filter(t=>t);C(i.length,1),n.options.testDataColumnName&&C(i[0],n.options.testDataColumnName)}),{skipReason:n.options.skipTest});N.push(o)}}m[A]=!0,T.length>0&&(E[d]={tests:T,clear:!0}),M.length>0&&(E[f]={tests:M,clear:!0}),N.length>0&&(E[g]={tests:N,clear:!1})})}function E(t){return i(this,void 0,void 0,function*(){return`${t.toString()}\n${t.stack?yield DG.Logger.translateStackTrace(t.stack):""}`})}function T(t,e,n,r,a,l){var c,u,d,f,g,p,m,y,v,_,w,b,C,x;return i(this,void 0,void 0,function*(){let i;n.length=0;const S=null!=e&&t.name.toLowerCase()!==e.toLowerCase();let A=(null===(c=t.options)||void 0===c?void 0:c.skipReason)||S,T=S?"skipped":null===(u=t.options)||void 0===u?void 0:u.skipReason;if(DG.Test.isInBenchmark&&!(null===(d=t.options)||void 0===d?void 0:d.benchmark))return void s(`Package testing: Skipped {{${t.category}}} {{${t.name}}} doesnt available in benchmark mode`);A&&!DG.Test.isInBenchmark&&s(`Package testing: Skipped {{${t.category}}} {{${t.name}}}`),A||s(`Package testing: Started {{${t.category}}} {{${t.name}}}`);const M=Date.now(),P=new Date(M).toISOString();try{if(A)i={name:t.name,owner:null!==(g=null===(f=t.options)||void 0===f?void 0:f.owner)&&void 0!==g?g:"",category:t.category,logs:"",date:P,success:!0,result:T,ms:0,skipped:!0,package:null!=a?a:"",flaking:DG.Test.isReproducing};else{let e=null!=r?r:o;DG.Test.isProfiling&&console.profile(`${t.category}: ${t.name}`),i={name:t.name,owner:null!==(m=null===(p=t.options)||void 0===p?void 0:p.owner)&&void 0!==m?m:"",category:t.category,logs:"",date:P,success:!0,result:null!==(y=(yield N(t.test,e)).toString())&&void 0!==y?y:"OK",ms:0,skipped:!1,package:null!=a?a:"",flaking:DG.Test.isReproducing},DG.Test.isProfiling&&(console.profileEnd(`${t.category}: ${t.name}`),grok.shell.info(`Profiling of ${t.category}: ${t.name} finished \n Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`))}}catch(e){h(e),i={name:t.name,owner:null!==(_=null===(v=t.options)||void 0===v?void 0:v.owner)&&void 0!==_?_:"",category:t.category,logs:"",date:P,success:!1,result:yield E(e),ms:0,skipped:!1,package:null!=a?a:"",flaking:!1}}if((null===(w=t.options)||void 0===w?void 0:w.isAggregated)&&i.result.constructor===DG.DataFrame){const t=i.result.col("success");if(t&&(i.success=t.stats.sum===t.length),!l){const t=i.result;t.columns.remove("stack"),t.rows.removeWhere(t=>t.get("success")),i.result=t}i.result=i.result.toCsv()}if(i.logs=n.join("\n"),i.ms=Date.now()-M,A||s(`Package testing: Finished {{${t.category}}} {{${t.name}}} with {{${i.success?"success":"error"}}} for ${i.ms} ms`),i.success||s(`Package testing: Result for {{${t.category}}} {{${t.name}}}: ${i.result}`),i.category=t.category,i.name=t.name,i.owner=null!==(C=null===(b=t.options)||void 0===b?void 0:b.owner)&&void 0!==C?C:"",!S){let e={success:i.success,result:i.result,ms:i.ms,date:i.date,skipped:i.skipped,category:t.category,name:t.name,logs:i.logs,owner:i.owner,flaking:DG.Test.isReproducing&&i.success,package:i.package};if(i.result.constructor==Object){const t=Object.keys(i.result).reduce((t,e)=>Object.assign(Object.assign({},t),{["result."+e]:i.result[e]}),{});e=Object.assign(Object.assign({},e),t)}e.result instanceof DG.DataFrame&&(e.result=JSON.stringify(null===(x=e.result)||void 0===x?void 0:x.toJson())||""),yield grok.shell.reportTest("package",e)}return i})}function M(t){const e=t.slice();return e.sort(()=>Math.random()-.5),e}function P(t){return i(this,void 0,void 0,function*(){yield new Promise(e=>setTimeout(e,t))})}function N(t,e,n="EXECUTION TIMEOUT"){return i(this,void 0,void 0,function*(){let r=null;const i=new Promise((t,i)=>{r=setTimeout(()=>{i(n)},e)});try{return yield Promise.race([t(),i])}finally{r&&clearTimeout(r)}})}DG.DataFrame.fromColumns([DG.Column.fromStrings("col",["val1","val2","val3"])]);const O=grok;var F,R,I,D,L,k,U,G,B;!function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(F||(F={})),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan String",t.Onehot="One-Hot"}(R||(R={})),function(t){t.Euclidean="Euclidean",t.Manhattan="Manhattan",t.Cosine="Vector Cosine"}(I||(I={})),function(t){t.Tanimoto="Tanimoto",t.Dice="Dice",t.Asymmetric="Asymmetric",t.BraunBlanquet="Braun-Blanquet",t.Cosine="Cosine",t.Kulczynski="Kulczynski",t.McConnaughey="Mc-Connaughey",t.RogotGoldberg="Rogot-Goldberg",t.Russel="Russel",t.Sokal="Sokal",t.Hamming="Hamming",t.Euclidean="Euclidean BitArray"}(D||(D={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(L||(L={})),(B=k||(k={})).Vector="Vector",B.String="String",B.BitArray="BitArray",B.MacroMolecule="MacroMolecule",B.Number="Number",B.IntArray="IntArray",B.NumberArray="NumberArray",function(t){t.Difference="Difference"}(U||(U={})),function(t){t.CommonItems="Common Items"}(G||(G={}));const V=new Uint32Array(65536),H=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return 0===e.length?t.length:t.length<=32?((t,e)=>{const n=t.length,r=e.length,i=1<<n-1;let o=-1,a=0,s=n,l=n;for(;l--;)V[t.charCodeAt(l)]|=1<<l;for(l=0;l<r;l++){let t=V[e.charCodeAt(l)];const n=t|a;t|=(t&o)+o^o,a|=~(t|o),o&=t,a&i&&s++,o&i&&s--,a=a<<1|1,o=o<<1|~(n|a),a&=n}for(l=n;l--;)V[t.charCodeAt(l)]=0;return s})(t,e):((t,e)=>{const n=e.length,r=t.length,i=[],o=[],a=Math.ceil(n/32),s=Math.ceil(r/32);for(let t=0;t<a;t++)o[t]=-1,i[t]=0;let l=0;for(;l<s-1;l++){let a=0,s=-1;const c=32*l,h=Math.min(32,r)+c;for(let e=c;e<h;e++)V[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=V[e.charCodeAt(t)],r=o[t/32|0]>>>t&1,l=i[t/32|0]>>>t&1,c=n|a,h=((n|l)&s)+s^s|n|l;let u=a|~(h|s),d=s&h;u>>>31^r&&(o[t/32|0]^=1<<t),d>>>31^l&&(i[t/32|0]^=1<<t),u=u<<1|r,d=d<<1|l,s=d|~(c|u),a=u&c}for(let e=c;e<h;e++)V[t.charCodeAt(e)]=0}let c=0,h=-1;const u=32*l,d=Math.min(32,r-u)+u;for(let e=u;e<d;e++)V[t.charCodeAt(e)]|=1<<e;let f=r;for(let t=0;t<n;t++){const n=V[e.charCodeAt(t)],a=o[t/32|0]>>>t&1,s=i[t/32|0]>>>t&1,l=n|c,u=((n|s)&h)+h^h|n|s;let d=c|~(u|h),g=h&u;f+=d>>>r-1&1,f-=g>>>r-1&1,d>>>31^a&&(o[t/32|0]^=1<<t),g>>>31^s&&(i[t/32|0]^=1<<t),d=d<<1|a,g=g<<1|s,h=g|~(l|d),c=d&l}for(let e=u;e<d;e++)V[t.charCodeAt(e)]=0;return f})(t,e)};var W=n(944);class Y{constructor(t,e=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof t){const n=t,r=Y._createBuffer(n);if(e)for(let t=0;t<r.length;t++)r[t]=-1;this._data=r,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,r){if(t<e||t>n)throw new Error(`Argument ${r} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let r=0;r<n;r++)e[r]=t[r]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new Y(t._length);n._length=t._length,n._data=Y._createBuffer(n._length),n._version=0;const r=t.lengthInInts;for(let i=0;i<r;i++)n._data[i]=t._data[i]&e._data[i];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new Y(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new Y(t);for(let r=0;r<t;++r)n.setBit(r,e(r));return n._version=0,n}static fromString(t){return Y.fromSeq(t.length,e=>"1"==t.charAt(e))}static fromUint32Array(t,e){const n=new Y(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new Y(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let r=0,i=0;for(;e-i>=4;)n._data[r++]=255&t[i]|(255&t[i+1])<<8|(255&t[i+2])<<16|(255&t[i+3])<<24,i+=4;return e-i==3&&(n._data[r]=(255&t[i+2])<<16),e-i==2&&(n._data[r]|=(255&t[i+1])<<8),e-i==1&&(n._data[r]|=255&t[i]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new Y(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,r=this.lengthInInts;for(let t=0;t<r;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,r=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(r)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,r=!0,i=!0){if(n&&i&&this.setAll(!e,!1),i)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(r)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return Y.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return n}setRange(t,e,n,r=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const i=Math.min(t,e),o=Math.max(t,e);if(n)for(let t=i;t<=o;t++)this.setTrue(t);else for(let t=i;t<=o;t++)this.setFalse(t);return this.incrementVersion(r),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const r=this._length;this.setLength(this._length+e);for(let n=r-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let r=t;r<t+e;r++)this.setBit(r,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let r=-1;-1!=(r=t.findNext(r,!e));)this.setFast(n++,this.getBit(r));this._length=n,this._version++}return this}getBit(t){return!!(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=Y._onBitCount[255&t];let n=this._data[e];const r=31&this._length;for(0!=r&&(n&=~(4294967295<<r));0!=n;n>>>=8)this._selectedCount+=Y._onBitCount[255&n];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const r=this.lengthInInts;let i=0;for(;i<r-1;i++)for(let e=this._data[i]&t._data[i];0!=e;e>>>=8)n+=Y._onBitCount[255&e];let o=this._data[i]&t._data[i];const a=31&this._length;for(0!=a&&(o&=~(4294967295<<a));0!=o;o>>>=8)n+=Y._onBitCount[255&o];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const r=this.lengthInInts;for(let i=Math.floor(t/32);i<r;i++){let r=e?this._data[i]:~this._data[i];if(0!=n)r&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==r)continue;for(let e=0;0!=r;e+=8,r>>>=8){const n=Y._firstOnBit[255&r];if(n>=0)return(t=n+32*i+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let r=Math.floor(t/32);r>=0;r--){let t=e?this._data[r]:~this._data[r];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=Y._lastOnBit[t>>>24];if(n>=0)return n+32*r+e}}return-1}}function j(t={}){const e=function(){if(!t||!t.scoringMatrix||!t.alphabetIndexes)return(t,e)=>t===e?0:1;if(t.scoringMatrix.length!==Object.keys(t.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const e=t.alphabetIndexes,n=t.scoringMatrix,r=Math.min(...Object.keys(e).map(t=>t.charCodeAt(0)))+1,i=new Float32Array((n.length+r)*(n.length+r));return Object.entries(e).forEach(([t,r])=>{const o=n[r];Object.entries(e).forEach(([e,r])=>{i[t.charCodeAt(0)*n.length+e.charCodeAt(0)]=o[r]})}),(t,e)=>1-i[t.charCodeAt(0)*n.length+e.charCodeAt(0)]}(),n=t?.threshold??0;return(t,r)=>{let i=0;const o=t.length,a=r.length,s=Math.ceil(Math.max(o,a)*(1-n));o!==a&&(i=Math.abs(o-a));let l=0;for(let n=0;n<Math.min(o,a);n++)if(t[n]!==r[n]&&(l+=e(t[n],r[n]),l>s))return 1;return l+=i,l/=Math.max(o,a),l}}Y._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),Y._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),Y._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7]);const q={gapOpen:1,gapExtend:.6,scoringMatrix:[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]],alphabetIndexes:{A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23}};var K;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(K||(K={}));const z={[K.HAMMING]:j,[K.LEVENSHTEIN]:function(){return(t,e)=>H(t,e)/Math.max(t.length,e.length)},[K.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:r,scoringMatrix:i,alphabetIndexes:o}={...q,...t};Object.entries(o).forEach(([t,n])=>e[t.charCodeAt(0)]=n);const a=[new Float32Array(1e4),new Float32Array(1e4)];return(t,o)=>{const s=new Array(t.length+1).fill(!1),l=new Array(t.length+1).fill(!1);let c=0,h=1;for(let e=1;e<t.length+1;e++)a[0][e]=-r-(e-1)*r,a[1][e]=0;a[0][0]=0;for(let u=1;u<o.length+1;u++){a[h][0]=-r-(u-1)*r;for(let d=1;d<t.length+1;d++){const f=a[c][d-1]+i[e[t.charCodeAt(d-1)]][e[o.charCodeAt(u-1)]],g=a[c][d]-(s[d]||1===u||u===o.length?r:n),p=a[h][d-1]-(l[d-1]||1===d||d===t.length?r:n);a[h][d]=Math.max(f,p,g),a[h][d]===f?(s[d]=!1,l[d]=!1):a[h][d]===p?(s[d]=!1,l[d]=!0):(s[d]=!0,l[d]=!1)}c=h,h=(h+1)%2}const u=Math.min(t.length,o.length);return(u-a[c][t.length])/u}},[K.MONOMER_CHEMICAL_DISTANCE]:j};function $(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const r=t.andWithCountBits(e,!0);return r/(n-r)}function X(t){return t<=0?3402823e32:1/t-1}D.Tanimoto,D.Dice,D.Asymmetric,D.BraunBlanquet,D.Cosine,D.Kulczynski,D.McConnaughey,D.RogotGoldberg,D.Russel,D.Sokal,D.Hamming,D.Euclidean,D.Tanimoto,D.Dice,D.Asymmetric,D.BraunBlanquet,D.Cosine,D.Kulczynski,D.McConnaughey,D.RogotGoldberg,D.Russel,D.Sokal,D.Hamming,D.Euclidean,D.Tanimoto,D.Dice,D.Cosine,D.Tanimoto,D.Asymmetric,D.Cosine,D.Sokal,K.HAMMING,K.LEVENSHTEIN,K.MONOMER_CHEMICAL_DISTANCE,K.NEEDLEMANN_WUNSCH;const Q={[I.Euclidean]:function(t,e){let n=0;for(let r=0;r<t.length;r++)n+=Math.pow(t[r]-e[r],2);return Math.sqrt(n)},[I.Manhattan]:function(t,e){let n=0;for(let r=0;r<t.length;r++)n+=Math.abs(t[r]-e[r]);return n},[I.Cosine]:function(t,e){let n=0,r=0,i=0;for(let o=0;o<t.length;o++)n+=t[o]*e[o],r+=t[o]*t[o],i+=e[o]*e[o];return(1-n/(Math.sqrt(r)*Math.sqrt(i)))/2}},J={[R.Levenshtein]:H,[R.JaroWinkler]:W.Vb,[R.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let n=0;for(let r=1;r<t.length;r++)n+=t[r]==e[r]?0:1;return n/t.length}},[R.Onehot]:function(t,e){return t===e?0:1}},Z={[D.Tanimoto]:function(t,e){return 1-$(t,e)},[D.Dice]:function(t,e){return 1-function(t,e){const n=t.trueCount()+e.trueCount();return 0==n?0:2*t.andWithCountBits(e,!0)/n}(t,e)},[D.Asymmetric]:function(t,e){return 1-function(t,e){const n=Math.min(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e)},[D.BraunBlanquet]:function(t,e){return X(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[D.Cosine]:function(t,e){return 1-function(t,e){const n=t.trueCount()*e.trueCount();return 0==n?0:t.andWithCountBits(e,!0)/Math.sqrt(n)}(t,e)},[D.Kulczynski]:function(t,e){return X(function(t,e){const n=t.trueCount()+e.trueCount(),r=t.trueCount()*e.trueCount();return 0==r?0:t.andWithCountBits(e,!0)*n/(2*r)}(t,e))},[D.McConnaughey]:function(t,e){return X(function(t,e){const n=t.trueCount()+e.trueCount(),r=t.trueCount()*e.trueCount();return 0==r?0:(t.andWithCountBits(e,!0)*n-r)/r}(t,e))},[D.RogotGoldberg]:function(t,e){return X(function(t,e){const n=t.andWithCountBits(e,!0),r=t.countBits(!0)+e.countBits(!0),i=t.length,o=i-r+n;return n==i||o==i?1:n/r+o/(2*i-r)}(t,e))},[D.Russel]:function(t,e){return X(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))},[D.Sokal]:function(t,e){return 1-function(t,e){const n=t.trueCount()+e.trueCount(),r=t.andWithCountBits(e,!0);return r/(2*n-3*r)}(t,e)},[D.Hamming]:function(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)},[D.Euclidean]:function(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}},tt={[L.TanimotoIntArray]:function(t,e){return X($(new Y(t,32*t.length),new Y(e,32*e.length)))}},et={[U.Difference]:function(t){if(t&&null!=t.range&&t.range>0){const e=t.range;return(t,n)=>Math.abs(t-n)/e}return(t,e)=>Math.abs(t-e)}},nt={[G.CommonItems]:function(t){const e=function(t){const e=t?.mostCommon??new Set;return(t,n)=>{const r=t.length,i=n.length;let o=0,a=0,s=0;for(;a<r&&s<i;)t[a]===n[s]?(e?.has(t[a])||++o,++a,++s):t[a]<n[s]?++a:++s;return o}}(t);return(t,n)=>0===n.length||0===t.length?1e4:Math.min(t.length,n.length)/(e(t,n)+1e-4)}},rt={[k.Vector]:{[I.Euclidean]:Q[I.Euclidean],[I.Manhattan]:Q[I.Manhattan],[I.Cosine]:Q[I.Cosine]},[k.String]:{[R.Levenshtein]:J[R.Levenshtein],[R.JaroWinkler]:J[R.JaroWinkler],[R.Manhattan]:J[R.Manhattan],[R.Onehot]:J[R.Onehot]},[k.BitArray]:{[D.Tanimoto]:Z[D.Tanimoto],[D.Dice]:Z[D.Dice],[D.Asymmetric]:Z[D.Asymmetric],[D.BraunBlanquet]:Z[D.BraunBlanquet],[D.Cosine]:Z[D.Cosine],[D.Kulczynski]:Z[D.Kulczynski],[D.McConnaughey]:Z[D.McConnaughey],[D.RogotGoldberg]:Z[D.RogotGoldberg],[D.Russel]:Z[D.Russel],[D.Sokal]:Z[D.Sokal]},[k.MacroMolecule]:{[K.HAMMING]:z[K.HAMMING],[K.LEVENSHTEIN]:z[K.LEVENSHTEIN],[K.NEEDLEMANN_WUNSCH]:z[K.NEEDLEMANN_WUNSCH],[K.MONOMER_CHEMICAL_DISTANCE]:z[K.MONOMER_CHEMICAL_DISTANCE]},[k.Number]:{[U.Difference]:et[U.Difference]},[k.IntArray]:{[L.TanimotoIntArray]:tt[L.TanimotoIntArray]},[k.NumberArray]:{[G.CommonItems]:nt[G.CommonItems]}};Object.keys(rt).reduce((t,e)=>{for(const n of Object.keys(rt[e]))t[n]=e;return t},{});const it=ui,ot="bypassLargeDataWarning";var at,st,lt,ct,ht,ut,dt;n(5540),(st=at||(at={})).EUCLIDEAN="EUCLIDEAN",st.MANHATTAN="MANHATTAN",at.EUCLIDEAN,at.MANHATTAN,(ct=lt||(lt={})).HAMMING="Hamming",ct.EUCLIDEAN="Euclidean",ct.VECTOR_COSINE="Vector Cosine",ct.MANHATTAN="Manhattan",ct.TANIMOTO="Tanimoto",ct.LEVENSTEIN="Levenshtein",ct.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",ct.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",ct.SOKAL="Sokal",ct.COSINE="Cosine",ct.ASYMMETRIC="Asymmetric",ct.Difference="Difference",ct.OneHot="One-Hot",lt.HAMMING,lt.EUCLIDEAN,lt.MANHATTAN,lt.VECTOR_COSINE,lt.TANIMOTO,lt.LEVENSTEIN,lt.NEEDLEMAN_WUNSCH,lt.MONOMER_CHEMICAL_DISTANCE,lt.SOKAL,lt.COSINE,lt.ASYMMETRIC,lt.Difference,lt.OneHot,lt.HAMMING,lt.EUCLIDEAN,lt.MANHATTAN,lt.TANIMOTO,lt.SOKAL,lt.COSINE,lt.ASYMMETRIC,lt.LEVENSTEIN,lt.NEEDLEMAN_WUNSCH,lt.MONOMER_CHEMICAL_DISTANCE,lt.Difference,lt.OneHot,lt.VECTOR_COSINE,new Set([lt.HAMMING,lt.LEVENSTEIN,lt.NEEDLEMAN_WUNSCH,lt.MONOMER_CHEMICAL_DISTANCE,lt.OneHot]),new Set([lt.HAMMING,lt.EUCLIDEAN,lt.MANHATTAN,lt.MONOMER_CHEMICAL_DISTANCE,lt.LEVENSTEIN,lt.NEEDLEMAN_WUNSCH,lt.TANIMOTO,lt.COSINE,lt.VECTOR_COSINE,lt.SOKAL,lt.ASYMMETRIC,lt.OneHot,lt.Difference]),new Set([lt.EUCLIDEAN,lt.MANHATTAN,lt.OneHot,lt.Difference,lt.VECTOR_COSINE]),new Set([lt.EUCLIDEAN,lt.MANHATTAN,lt.Difference,lt.VECTOR_COSINE]),new Set([lt.EUCLIDEAN,lt.MANHATTAN,lt.Difference]),new Set([lt.TANIMOTO,lt.COSINE,lt.SOKAL,lt.ASYMMETRIC]),function(t){t.ADD="ADD",t.SUB="SUB",t.MULT="MULT"}(ht||(ht={})),function(t){t.SQUARE="SQUARE",t.INVERSE="INVERSE",t.TRANSPOSE="TRANSPOSE",t.NORM="NORM",t.COLUMN_NORM="COLUMN_NORM"}(ut||(ut={})),function(t){t.SCALARMULT="SCALARMULT",t.SCALARADD="SCALARADD",t.SCALARPOW="SCALARPOW"}(dt||(dt={})),Object.prototype.toString;const ft="dimensionality-reducer-terminate-event";var gt,pt;(pt=gt||(gt={})).EUCLIDEAN="EUCLIDEAN",pt.MANHATTAN="MANHATTAN";const mt=t=>null==t;function yt(t,e){return`${e} (${t.length>4?`${t.length} columns`:t.map(t=>t.name).join(", ")})`}async function vt(e,r,i,o,a,s,l,c=!0,h=!1,u={preprocessingFuncArgs:[]},d={},f=null,g={},p){const m={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(r.length!==o.length||r.length!==s.length||r.length!==a.length||r.length!==u.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const y=c?d.tableView??O.shell.tableView(e.name)??O.shell.addTableView(e):null,v=async()=>{const v=t.TaskBarProgressIndicator.create(`Initializing ${d.scatterPlotName??"dimensionality reduction"} ...`);let _;try{const w=function(t){const e=["Embed_X","Embed_Y"],n=t.columns.names().filter(t=>t.includes(e[0])).length+1;return e.map(t=>`${t}_${n}`)}(e);function b(n,o,a){let s=null,l=null;e.columns.names().includes(w[0])?(s=e.columns.byName(w[0]),l=e.columns.byName(w[1])):(s=e.columns.add(t.Column.float(w[0],e.rowCount)),l=e.columns.add(t.Column.float(w[1],e.rowCount)),c&&!_&&(_=y.scatterPlot({...m,x:w[0],y:w[1],title:d.scatterPlotName??yt(r,i)}))),d["show-scatterplot-progress"]&&(_?.root&&it.setUpdateIndicator(_.root,!1),s.init(t=>a[0]?a[0][t]:void 0),l.init(t=>a[1]?a[1][t]:void 0));const h=n/o*100;v.update(h,`Running ${d.scatterPlotName??"dimensionality reduction"}... ${h.toFixed(0)}%`)}async function C(){e.columns.add(t.Column.float(w[0],e.rowCount)),e.columns.add(t.Column.float(w[1],e.rowCount));let h=null;c&&(_=y.scatterPlot({...m,x:w[0],y:w[1],title:d.scatterPlotName??yt(r,i)}),it.setUpdateIndicator(_.root,!0));const f=O.events.onViewerClosed.subscribe(t=>{const e=t.args.viewer;e?.getOptions()?.look?.title&&_?.getOptions()?.look?.title&&e?.getOptions()?.look?.title===_?.getOptions()?.look?.title&&(O.events.fireCustomEvent(ft,{}),f.unsubscribe(),h?.(),v.close())}),g=new Promise(async(t,c)=>{try{h=t;const c=[];let f=o,g=a,m=l;if(p&&r.every(t=>t.isNumerical)){const t=r.map(t=>t.toList()),n=new Array(e.rowCount).fill(0).map((t,e)=>new Float32Array(r.length));for(let i=0;i<r.length;++i)for(let r=0;r<e.rowCount;++r)n[r][i]=t[i][r];u.distanceFnArgs=[{}],c.push({entries:n,options:{}}),f=[p],g=[1],m="MANHATTAN"}else for(let t=0;t<s.length;++t){const e=s[t];if(u.distanceFnArgs||(u.distanceFnArgs=[]),e){const n=e.inputs[0].name,i=e.inputs[1].name,{entries:a,options:s}=await e.apply({[n]:r[t],[i]:o[t],...u.preprocessingFuncArgs[t]??{}});c.push({entries:a,options:s}),u.distanceFnArgs.push(s)}else{const e=r[t].toList(),n={};c.push({entries:e,options:n}),u.distanceFnArgs.push(n)}}t(await async function(t,e,r,i,o,a,s){let l=await async function(t,e,r,i,o,a,s){if(!a.distanceFnArgs)throw new Error("options.distanceFnArgs must be defined");if(t.length!==e.length||t.length!==a.distanceFnArgs.length||t.length!==i.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise(function(l,c){const h=new Worker(new URL(n.p+n.u(234),n.b));h.postMessage({columnsData:t,distanceMetrics:e,method:r,options:a,weights:i,aggregationMethod:o});const u=O.events.onCustomEvent(ft).subscribe(()=>{try{h?.terminate()}finally{u.unsubscribe()}});h.onmessage=({data:{error:t,embedding:e,epochNum:n,epochsLength:r}})=>{mt(n)||mt(r)?(u.unsubscribe(),t?c(t):l(e),setTimeout(()=>h.terminate(),100)):s&&s(n,r,e)}})}(t,r,e,i,o,a,s);return l=l.map(t=>function(t){const e=t.length;let n=0,r=0;for(let i=0;i<e;++i)n+=t[i],r+=Math.pow(t[i],2);const i=n/e,o=1/Math.sqrt(r/e-Math.pow(i,2));for(let n=0;n<e;++n)t[n]=(t[n]-i)*o;return t}(t)),l}(c.map(t=>t.entries),i,f,g,l,u,d[ot]?void 0:b))}catch(t){c(t)}}),C=await g;return v.close(),f.unsubscribe(),C}const x=await C();if(h&&x){const S=t.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const A=await function(t,e,r,i){return o=this,a=void 0,l=function*(){return new Promise(function(o,a){const s=new Worker(new URL(n.p+n.u(682),n.b));s.postMessage({embedX:t,embedY:e,minPts:i,epsilon:r}),s.onmessage=({data:{error:t,clusters:e}})=>{s.terminate(),t?a(t):o(e)}})},new((s=void 0)||(s=Promise))(function(t,e){function n(t){try{i(l.next(t))}catch(t){e(t)}}function r(t){try{i(l.throw(t))}catch(t){e(t)}}function i(e){var i;e.done?t(e.value):(i=e.value,i instanceof s?i:new s(function(t){t(i)})).then(n,r)}i((l=l.apply(o,a||[])).next())});var o,a,s,l}(x[0],x[1],u.dbScanEpsilon??.01,u.dbScanMinPts??4),E=e.columns.getUnusedName("Cluster (DBSCAN)");e.columns.addNewString(E).init(t=>A[t].toString()),_&&(_.props.colorColumnName=E)}catch(T){O.shell.error("Clustering embeddings failed"),console.error(T)}finally{S.close()}}if(x){const M=e.columns.byName(w[0]),P=e.columns.byName(w[1]);if(M.init(t=>x[0][t]),P.init(t=>x[1][t]),f)try{const N=f.inputs[0].name,F=f.inputs[1].name;await f.prepare({[N]:M,[F]:P,...g}).call(!0)}catch(R){O.shell.error("Post-processing failed"),console.error(R)}if(_)return it.setUpdateIndicator(_.root,!1),_.helpUrl="/help/compute/sequence-space",_}}catch(I){O.shell.error("Dimensionality reduction failed"),console.error(I),v.close(),_&&it.setUpdateIndicator(_.root,!1)}};return new Promise(async(t,n)=>{try{if(d.fastRowCount&&e.rowCount>d.fastRowCount&&!d[ot])it.dialog().add(it.divText("Analysis might take several minutes. Do you want to continue?")).onOK(async()=>{try{const e=await v();t(e)}catch(t){n(t)}}).onCancel(()=>t(void 0)).show();else{const e=await v();t(e)}}catch(t){n(t)}})}var _t=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const wt={SUBJ:"subj",STUDY:"study",SITE:"site",AGE:"age",SEX:"sex",RACE:"race",DISEASE:"disease",WEIGHT:"weight",HEIGHT:"height"};function bt(t,e,n){return _t(this,void 0,void 0,function*(){const r=O.data.demo.demog(100);O.shell.addTableView(r),C(!!(yield vt(r,t.map(t=>r.col(t)),e,n,t.map(()=>1),t.map(()=>{}),"EUCLIDEAN",!0,!0,{preprocessingFuncArgs:t.map(()=>({}))})),!0,"No scatterplot returned");const i=r.columns.names().filter(t=>t.toLowerCase().startsWith("embed"));C(i.length,2,"Wrong number of embeddings added"),C(!!r.columns.names().find(t=>t.toLowerCase().startsWith("cluster")),!0,"No cluster column added");for(const t of i){const e=r.col(t);C(new Array(e.length).fill(null).every((t,n)=>!e.isNone(n)&&!isNaN(e.get(n))),!0,"Embedding column has null-ish values")}yield new Promise(t=>setTimeout(t,500))})}x("Dimensionality reduction: UMAP",()=>{b("Numeric column",()=>_t(void 0,void 0,void 0,function*(){yield bt([wt.AGE],F.UMAP,[U.Difference])}),{timeout:3e4}),b("String column",()=>_t(void 0,void 0,void 0,function*(){yield bt([wt.SEX],F.UMAP,[R.Onehot])}),{timeout:3e4}),b("Numeric and string columns",()=>_t(void 0,void 0,void 0,function*(){yield bt([wt.SEX,wt.AGE],F.UMAP,[R.Onehot,U.Difference])})),b("All demog columns",()=>_t(void 0,void 0,void 0,function*(){const e=O.data.demo.demog(10).columns.toList().filter(t=>Object.values(wt).includes(t.name)),n=e.map(e=>e.type===t.COLUMN_TYPE.STRING?R.Onehot:U.Difference),r=e.map(t=>t.name);yield bt(r,F.UMAP,n)}))}),x("Dimensionality reduction: T-SNE",()=>{b("Numeric column",()=>_t(void 0,void 0,void 0,function*(){yield bt([wt.AGE],F.T_SNE,[U.Difference])}),{timeout:3e4}),b("String column",()=>_t(void 0,void 0,void 0,function*(){yield bt([wt.SEX],F.T_SNE,[R.Onehot])}),{timeout:3e4}),b("Numeric and string columns",()=>_t(void 0,void 0,void 0,function*(){yield bt([wt.SEX,wt.AGE],F.T_SNE,[R.Onehot,U.Difference])})),b("All demog columns",()=>_t(void 0,void 0,void 0,function*(){const e=O.data.demo.demog(10).columns.toList().filter(t=>Object.values(wt).includes(t.name)),n=e.map(e=>e.type===t.COLUMN_TYPE.STRING?R.Onehot:U.Difference),r=e.map(t=>t.name);yield bt(r,F.T_SNE,n)}))});const Ct={i32:"HEAP32",f32:"HEAPF32"},xt={i32:Int32Array,f32:Float32Array},St={i32:2,f32:2},At={i32:DG.Column.fromInt32Array,f32:DG.Column.fromFloat32Array};class Et{constructor(t){this.data=t}complementArrOfParams(t){t.push(this.data)}complementArrOfTypes(t){t.push("number")}allocateMemoryForBuffer(t){}isMemoryForBufferAllocated(){return!0}putDataToBuffer(t){}getDataFromBuffer(t){}freeBuffer(t){}}class Tt extends Et{constructor(t,e,n=!1){super(t),this.type=e,this.toUpdate=n,this.buf=0,this.numOfRows=t.length}complementArrOfParams(t){t.push(this.buf),t.push(this.numOfRows)}complementArrOfTypes(t){t.push("number"),t.push("number")}allocateMemoryForBuffer(t){this.buf=t._malloc(this.numOfRows*xt[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const e=this.type,n=St[e],r=t[Ct[e]];let i=null;const o=this.data;i="int"==o.type&&"i32"==e||"double"==o.type&&"f32"==e?o.getRawData():new xt[e](o.getRawData()),i&&r.set(i,this.buf>>n)}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[Ct[e]],r=this.buf,i=xt[e].BYTES_PER_ELEMENT,o=this.data.getRawData();for(let t=0;t<this.numOfRows;t++)o[t]=n[r/i+t]}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class Mt extends Tt{constructor(t,e){super([],t,!0),this.numOfRows=e}putDataToBuffer(t){}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[Ct[e]],r=this.buf,i=At[e],o=new xt[e](this.numOfRows);for(let t=0;t<o.length;t++)o[t]=n[r/o.BYTES_PER_ELEMENT+t];this.data=i("name",o)}}}class Pt extends Et{constructor(t,e,n=!1){super(t),this.type=e,this.toUpdate=n,this.buf=0,this.numOfColumns=t.length,this.numOfRows=t[0].length}complementArrOfParams(t){t.push(this.buf),t.push(this.numOfRows),t.push(this.numOfColumns)}complementArrOfTypes(t){t.push("number"),t.push("number"),t.push("number")}allocateMemoryForBuffer(t){this.buf=t._malloc(this.numOfRows*this.numOfColumns*xt[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const e=this.type,n=St[e],r=t[Ct[e]],i=xt[e].BYTES_PER_ELEMENT;for(let t=0;t<this.numOfColumns;t++){let o=null;const a=this.data[t];o="int"==a.type&&"i32"==e||"double"==a.type&&"f32"==e?a.getRawData():new xt[e](a.getRawData()),null!=o&&r.set(o,this.buf+t*this.numOfRows*i>>n)}}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[Ct[e]],r=this.numOfRows,i=this.numOfColumns,o=new xt[e](n.buffer,this.buf,r*i);for(let t=0;t<i;t++){const e=this.data[t].getRawData();for(let n=0;n<r;n++)e[n]=o[n+t*r]}}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class Nt extends Pt{constructor(t,e,n){super([[]],t,!0),this.data=[],this.numOfColumns=n,this.numOfRows=e}putDataToBuffer(t){}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[Ct[e]],r=this.numOfRows,i=this.numOfColumns,o=xt[e].BYTES_PER_ELEMENT,a=At[e],s=this.buf;for(let t=0;t<i;t++){const i=new xt[e](r);for(let e=0;e<r;e++)i[e]=n[s/o+e+t*r];this.data.push(a((t+1).toString(),i))}}}}const Ot={intColumn:t=>new Tt(t,"i32"),newIntColumn:t=>new Mt("i32",t),intColumns:t=>new Pt(t.toList(),"i32"),newIntColumns:(t,e)=>new Nt("i32",t,e),floatColumn:t=>new Tt(t,"f32"),newFloatColumn:t=>new Mt("f32",t),floatColumns:t=>new Pt(t.toList(),"f32"),newFloatColumns:(t,e)=>new Nt("f32",t,e),int:t=>new Et(t),num:t=>new Et(t)},Ft={tableFromColumns:t=>DG.DataFrame.fromColumns(t.data),num:t=>t,int:t=>t,double:t=>t,column:t=>t.data};function Rt(t,e,n){const r=t[e],i=r.arguments,o=[];let a=0;for(const t in i){const e=i[t];if("_callResult"!=t){switch(e.type){case"floatColumns":case"int":case"num":case"floatColumn":case"intColumn":case"intColumns":e.data=Ot[e.type](n[a]),a++;break;case"newFloatColumns":case"newIntColumns":const t=i[e.numOfRows.ref].data[e.numOfRows.value],r=i[e.numOfColumns.ref].data[e.numOfColumns.value];e.data=Ot[e.type](t,r);break;case"newFloatColumn":case"newIntColumn":const o=i[e.numOfRows.ref].data[e.numOfRows.value];e.data=Ot[e.type](o)}o.push(i[t].data)}}const s=function(t,e,n,r){let i;for(const e of r)e.allocateMemoryForBuffer(t);let o=!0;for(const t of r)o&=t.isMemoryForBufferAllocated();if(o){const n=[],o=[];for(const e of r)e.complementArrOfParams(n),e.complementArrOfTypes(o),e.putDataToBuffer(t);const a="number";i=t.ccall(e,a,o,n);for(const e of r)e.getDataFromBuffer(t)}for(const e of r)e.freeBuffer(t);if(null!=i)return i}(t,e,0,o);i._callResult=Ot.num(s);const l=r.output;if("objects"!=l.type)return Ft[l.type](i[l.source].data);const c=[];for(const t of l.source)c.push(i[t].data.data);return c}const It="num",Dt="floatColumn",Lt="intColumn",kt="floatColumns",Ut="newFloatColumns",Gt="intColumns",Bt="newIntColumns",Vt="newFloatColumn",Ht="newIntColumn",Wt="numOfRows",Yt="numOfColumns",jt="ref",qt="value",Kt="int",zt="double",$t={intColumn:Int32Array,floatColumn:Float32Array,floatColumns:Float32Array,newFloatColumns:Float32Array,intColumns:Int32Array,newIntColumns:Int32Array,newFloatColumn:Float32Array,newIntColumn:Int32Array};function Xt(t,e){let n,r=[],i=0;for(const o in t){const a=t[o],s=a.type;if("_callResult"!==o){switch(s){case It:case Kt:case zt:a.data=e[i],i++;break;case Lt:case Dt:let r;const o=e[i],l=o.length;r=o.type===Kt&&s===Lt||o.type===zt&&s===Dt?o.getRawData().slice(0,l):new $t[s](o.getRawData().slice(0,l)),a.data={array:r,numOfRows:l},i++;break;case Ht:case Vt:let c=0;n=a[Wt][jt],c=t[n].type===It?t[n].data:t[n].data[a[Wt][qt]],a.data={numOfRows:c},i++;break;case Gt:case kt:let h=[];const u=e[i].byIndex(0).length;for(const t of e[i].toList())t.type===Kt&&s===Lt||t.type===zt&&s===Dt?h.push(t.getRawData().slice(0,u)):h.push(new $t[s](t.getRawData().slice(0,u)));a.data={arrays:h,numOfRows:u,numOfColumns:h.length},i++;break;case Bt:case Ut:let d=0,f=0;n=a[Wt][jt],d=t[n].type===It?t[n].data:t[n].data[a[Wt][qt]],n=a[Yt][jt],f=t[n].type===It?t[n].data:t[n].data[a[Yt][qt]],a.data={numOfRows:d,numOfColumns:f},i++;break;default:return}r.push(a)}}return r}function Qt(t,e){t.arguments._callResult=e.callResult,function(t,e){const n={newFloatColumns:DG.Column.fromFloat32Array,newIntColumns:DG.Column.fromInt32Array,newFloatColumn:DG.Column.fromFloat32Array,newIntColumn:DG.Column.fromInt32Array};let r=0;for(const i in t){const o=t[i];switch(o.type){case It:case Kt:case zt:case Lt:case Dt:case kt:case Gt:break;case Vt:case Ht:let t;null==o.name?t=(0).toString():s=o.name,o.column=n[o.type](t,e[r].array);break;case Bt:case Ut:let i=[],a=e[r].arrays.length,s=[];if(null==o.names)for(let t=1;t<=a;t++)s.push(t.toString());else s=o.names;for(let t=0;t<a;t++)i.push(n[o.type](s[t],e[r].arrays[t]));o.columns=i}r++}}(t.arguments,e.args);let n=function(t){let e=t.output;const n={newFloatColumns:"columns",newIntColumns:"columns",newFloatColumn:"column",newIntColumn:"column"};switch(e.type){case It:case Kt:case zt:return t.arguments[e.source];case"column":return t.arguments[e.source].column;case"tableFromColumns":return DG.DataFrame.fromColumns(t.arguments[e.source].columns);case"objects":let r=[];for(let i of e.source){let e=t.arguments[i];r.push(e[n[e.type]])}return r}}(t);return function(t){for(const e in t){const n=t[e];switch(n.type){case It:case Kt:case zt:case Lt:case Dt:case Gt:case kt:break;case Ht:case Vt:n.column=null;break;case Bt:case Ut:n.columns=null}}}(t.arguments),n}async function Jt(t,e,r){return new Promise((t,i)=>{const o=new Worker(new URL(n.p+n.u(128),n.b));o.postMessage(Xt(EDA.principalComponentAnalysisNipals.arguments,[e,r])),o.onmessage=function(e){o.terminate(),t(Qt(EDA.principalComponentAnalysisNipals,e.data))}})}const Zt=1e-6;function te(e){if(e.type!=t.COLUMN_TYPE.FLOAT&&e.type!=t.COLUMN_TYPE.INT)throw new Error("unsupported column type: "+e.type)}function ee(t){if(t.stats.missingValueCount>0)throw new Error(`The column '${t.name}' has missing values.`)}function ne(t,e){if(function(t,e){if(e<1)throw new Error("components must be positive.");if(e>t.length)throw new Error("components must not be greater than features count.");for(const e of t)te(e),ee(e)}(t,e),t.length*t.byIndex(0).length>1e8)throw new Error("dataframe is too big.")}function re(t,e,n){return e?n?function(t){const e=t.rowCount;for(const n of t.columns)if(n.isNumerical){const t=n.stats.stdev,r=n.stats.avg,i=n.getRawData();if(t>0)for(let n=0;n<e;++n)i[n]=(i[n]-r)/t;else for(let t=0;t<e;++t)i[t]-=r}return t}(t):function(t){const e=t.rowCount;for(const n of t.columns)if(n.isNumerical){const t=n.stats.avg;if(Math.abs(t)>Zt){const r=n.getRawData();for(let n=0;n<e;++n)r[n]-=t}}return t}(t):n?function(t){const e=t.rowCount;for(const n of t.columns)if(n.isNumerical){const t=n.stats.stdev;if(Math.abs(t-1)>Zt&&t>0){const r=n.getRawData();for(let n=0;n<e;++n)r[n]/=t}}return t}(t):t}var ie,oe,ae,se,le,ce,he,ue,de,fe,ge,pe,me,ye,ve;function _e(e,r,i,o,a){return s=this,l=void 0,h=function*(){ne(r,i);const s=e.rowCount,l=function(e){const n=[];for(const t of e)t.stats.stdev>0&&t.stats.missingValueCount<1&&n.push(t);return t.DataFrame.fromColumns(n)}(r),c=l.columns.length;if(0===c){const e=[];for(let n=0;n<i;++n)e.push(t.Column.fromFloat32Array(`${n+1}`,new Float32Array(s).fill(0)));return t.DataFrame.fromColumns(e)}const h=c<i?i-c:0,u=Math.min(i,c);let d;if(c>900)d=yield Jt(0,r,u);else{const t=yield async function(t,e,r){return new Promise((t,i)=>{const o=new Worker(new URL(n.p+n.u(860),n.b));o.postMessage(Xt(EDA.principalComponentAnalysis.arguments,[e,r,1,0])),o.onmessage=function(e){o.terminate(),0===e.data.callResult?t(Qt(EDA.principalComponentAnalysis,e.data)):t(-1)}})}(0,r,u);d=-1!==t?re(t,o,a):yield Jt(0,r,u)}if(void 0===d)throw new Error("Failed to compute PCA");d=re(d,o,a);const f=d.columns,g=f.length;for(let e=0;e<h;++e)f.add(t.Column.fromFloat32Array(`${g+e+1}`,new Float32Array(s).fill(0)));return d},new((c=void 0)||(c=Promise))(function(t,e){function n(t){try{i(h.next(t))}catch(t){e(t)}}function r(t){try{i(h.throw(t))}catch(t){e(t)}}function i(e){var i;e.done?t(e.value):(i=e.value,i instanceof c?i:new c(function(t){t(i)})).then(n,r)}i((h=h.apply(s,l||[])).next())});var s,l,c,h}(ve=ie||(ie={}))[ve.COMPUTE_COMPONENTS=0]="COMPUTE_COMPONENTS",ve[ve.PERFORM_MVA=1]="PERFORM_MVA",ve[ve.DEMO=2]="DEMO",(ye=oe||(oe={})).NO_DF="No dataframe is opened",ye.NO_COLS="No numeric columns without missing values",ye.ONE_COL="No columns to be used as features (just one numeric columns without missing values)",ye.EMPTY_DF="Dataframe is empty",ye.PREDICT="Predictors must not contain a response variable",ye.ENOUGH="Not enough of features",ye.COMP_LIN_PLS="Components count must be less than the number of features",ye.COMP_QUA_PLS="Too large components count for the quadratic PLS regression",ye.COMPONENTS="Components count must be greater than 1",ye.INV_INP="Invalid inputs",(me=ae||(ae={})).PREDICT="Predict",me.USING="Using",me.COMPONENTS="Components",me.PLS="PLS",me.MVA="Multivariate Analysis (PLS)",me.RUN="RUN",me.NAMES="Names",me.MODEL="Observed vs. Predicted",me.FEATURE="Feature",me.REGR_COEFS="Regression Coefficients",me.XLOADING="x.loading.p",me.LOADINGS="Loadings",me.XSCORE="x.score.t",me.YSCORE="y.score.u",me.SCORES="Scores",me.EXPL_VAR="Explained Variance",me.EXPLORE="Explore",me.FEATURES="Feature names",me.BROWSE="Browse",me.ANALYSIS="Features Analysis",me.QUADRATIC="Quadratic",(pe=se||(se={})).PREDICT="Column with the response variable",pe.FEATURES="Predictors (features)",pe.COMPONENTS="Number of PLS components",pe.PLS="Compute PLS components",pe.MVA="Perform multivariate analysis",pe.NAMES="Names of data samples",pe.QUADRATIC="Specifies whether to include squared terms as additional predictors in the PLS model",(ge=le||(le={})).PLS="/help/explore/multivariate-analysis#pls-components",ge.MVA="/help/explore/multivariate-analysis",ge.MODEL="/help/explore/multivariate-analysis#observed-vs-predicted",ge.COEFFS="/help/explore/multivariate-analysis#regression-coefficients",ge.LOADINGS="/help/explore/multivariate-analysis#loadings",ge.EXPL_VARS="/help/explore/multivariate-analysis#explained-variance",ge.SCORES="/help/explore/multivariate-analysis#scores",(fe=ce||(ce={}))[fe.DEFAULT=3]="DEFAULT",fe[fe.MIN=1]="MIN",(de=he||(he={})).PREFIX="PLS",de.SUFFIX="(predicted)",de.COMP="component",de.COMPS="components",function(t){t[t.PREDICTION=0]="PREDICTION",t[t.REGR_COEFFS=1]="REGR_COEFFS",t[t.T_SCORES=2]="T_SCORES",t[t.U_SCORES=3]="U_SCORES",t[t.X_LOADINGS=4]="X_LOADINGS",t[t.Y_LOADINGS=5]="Y_LOADINGS"}(ue||(ue={}));const we=[.49,.79,.99];var be,Ce;(Ce=be||(be={})).AXIS="#838383",Ce.CIRCLE="#0000FF",Ce.INVALID="#EB6767",Ce.VALID_TEXT="#4d5261",Ce.VALID_LINE="#dbdcdf",[{caption:ae.MODEL,text:"Closer to the line means better price prediction."},{caption:ae.SCORES,text:"The latent factor values for each sample reflect the similarities and dissimilarities among observations."},{caption:ae.LOADINGS,text:"The impact of each feature on the latent factors: higher loading means stronger influence."},{caption:ae.REGR_COEFS,text:"Parameters of the obtained model: features make different contribution to the prediction."},{caption:ae.EXPL_VAR,text:"How well the latent components fit source data: closer to one means better fit."}].map(t=>`# ${t.caption}\n\n${t.text}`).join("\n\n"),le.MVA;function xe(t){return e=this,r=void 0,o=function*(){ne(t.features,t.components),te(t.predict),ee(t.predict);const e=yield async function(t,e,r,i){return new Promise((t,o)=>{const a=new Worker(new URL(n.p+n.u(412),n.b));a.postMessage(Xt(EDA.partialLeastSquareRegression.arguments,[e,r,i])),a.onmessage=function(e){a.terminate(),t(Qt(EDA.partialLeastSquareRegression,e.data))}})}(t.table,t.features,t.predict,t.components);return{prediction:e[ue.PREDICTION],regressionCoefficients:e[ue.REGR_COEFFS],tScores:e[ue.T_SCORES],uScores:e[ue.U_SCORES],xLoadings:e[ue.X_LOADINGS],yLoadings:e[ue.Y_LOADINGS]}},new((i=void 0)||(i=Promise))(function(t,n){function a(t){try{l(o.next(t))}catch(t){n(t)}}function s(t){try{l(o.throw(t))}catch(t){n(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i(function(t){t(n)})).then(a,s)}l((o=o.apply(e,r||[])).next())});var e,r,i,o}Math.min,Math.max;var Se=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};function Ae(e,n){return Se(this,void 0,void 0,function*(){const r=e.length,i=n.length,o=n.stats.avg,a=n.stats.stdev,s=new Float32Array(r+1).fill(0);if(s[r]=o,0===a||1===i)return s;try{const i=[],l=[],c=new Float32Array(r),h=new Float32Array(r);let u=0,d=0;for(const t of e){const e=t.stats;e.stdev>0&&(i.push(u),l.push(t),c[d]=e.avg,h[d]=e.stdev,++d),++u}if(0===d)return s;const f=function(t,e,n,r,i,o,a){return Rt(EDA,"fitLinearRegressionParamsWithDataNormalizing",[t,e,n,r,i,o,a])}(t.DataFrame.fromColumns(l).columns,t.Column.fromFloat32Array("xAvgs",c,d),t.Column.fromFloat32Array("xStdevs",h,d),n,o,a,d+1).getRawData();for(let t=0;t<d;++t)s[i[t]]=f[t];s[r]=f[d]}catch(i){const o=yield function(e,n,r){return Se(this,void 0,void 0,function*(){return(yield xe({table:t.DataFrame.fromColumns([n]),features:e,predict:n,components:r,names:void 0,isQuadratic:!1})).regressionCoefficients.getRawData()})}(e,n,Te(e.length,n.length));let a=0;for(let t=0;t<r;++t)s[t]=o[t],a+=o[t]*e.byIndex(t).stats.avg;s[r]-=a}return s})}function Ee(e,n){const r=e.length;if(r!==n.length-1)throw new Error("Incorrect parameters count");const i=e.byIndex(0),o=i.length,a=new Float32Array(o);let s=i.getRawData();const l=n[r];let c=n[0];for(let t=0;t<o;++t)a[t]=l+c*s[t];for(let t=1;t<r;++t){s=e.byIndex(t).getRawData(),c=n[t];for(let t=0;t<o;++t)a[t]+=c*s[t]}return t.Column.fromFloat32Array(e.getUnusedName("prediction"),a,o)}const Te=(t,e)=>e<=t?Math.min(10,e):Math.min(10,t);var Me;!function(t){t[t.MAX_SAMLPES=1e5]="MAX_SAMLPES",t[t.MAX_FEATURES=1e3]="MAX_FEATURES"}(Me||(Me={}));class Pe{static isApplicable(t,e){for(const e of t)if(!e.matches("numerical"))return!1;return!!e.matches("numerical")}static isInteractive(t,e){return t.length<=Me.MAX_FEATURES&&e.length<=Me.MAX_SAMLPES}constructor(e){if(this.specn=null,e)try{const n=new Uint32Array(e.buffer,0,2),r=n[0],i=n[1],o=new Uint8Array(e.buffer,8,r),a=t.DataFrame.fromByteArray(o),s=a.rowCount,l=a.columns,c=l.length,h=new Uint8Array(e.buffer,8+r,i),u=t.DataFrame.fromByteArray(h);if(c<3)throw new Error("incorrect columns count");const d=l.byName(ae.FEATURES).toList(),f=new Float32Array(s);f.set(l.byName(ae.REGR_COEFS).getRawData());const g=c-2,p=new Array(g);for(let t=0;t<g;++t)p[t]=new Float32Array(s),p[t].set(l.byIndex(t+2).getRawData());this.specn={params:f,loadings:p,names:d,dim:s-1,components:c-2,scores:u}}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(e,n,r){return i=this,o=void 0,s=function*(){const i=yield xe({table:t.DataFrame.fromColumns([n]),features:e,predict:n,components:r,names:void 0,isQuadratic:!1}),o=e.names();o.push("_");const a=this.getRegrCoeffs(e,n,i.regressionCoefficients),s=this.getLoadings(r,i.xLoadings);this.specn={names:o,params:a,loadings:s,components:r,dim:e.length,scores:this.getScoresDf(i)},this.computeExplVars(n.length,r,i.yLoadings)},new((a=void 0)||(a=Promise))(function(t,e){function n(t){try{l(s.next(t))}catch(t){e(t)}}function r(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var i;e.done?t(e.value):(i=e.value,i instanceof a?i:new a(function(t){t(i)})).then(n,r)}l((s=s.apply(i,o||[])).next())});var i,o,a,s}getLoadings(t,e){const n=Array(t),r=e[0].length+1;for(let i=0;i<t;++i)n[i]=new Float32Array(r),n[i].set(e[i].getRawData());return n}getRegrCoeffs(t,e,n){const r=t.length,i=new Float32Array(r+1),o=n.getRawData();let a=0;for(let e=0;e<r;++e)i[e]=o[e],a+=o[e]*t.byIndex(e).stats.avg;return i[r]=e.stats.avg-a,i}computeExplVars(t,e,n){if(null===this.specn)throw new Error("Failed to compute explained variances");const r=n.getRawData(),i=this.specn.loadings[0].length-1;let o=Math.pow(r[0],2)/t;this.specn.loadings[0][i]=o;for(let n=1;n<e;++n)o+=Math.pow(r[n],2)/t,this.specn.loadings[n][i]=o}toBytes(){if(null===this.specn)throw new Error("Failed to pack untrained model");const e=t.DataFrame.fromColumns([t.Column.fromStrings(ae.FEATURES,this.specn.names),t.Column.fromFloat32Array(ae.REGR_COEFS,this.specn.params)]);this.specn.loadings.forEach((n,r)=>e.columns.add(t.Column.fromFloat32Array(`${ae.XLOADING}${r+1}`,n)));const n=e.toByteArray(),r=n.length,i=this.specn.scores.toByteArray(),o=i.length,a=r+o+8,s=new Uint8Array(64*(Math.ceil(a/64)+1)),l=new Uint32Array(s.buffer,0,2);return l[0]=r,l[1]=o,s.set(n,8),s.set(i,8+r),s}predict(t){if(null===this.specn)throw new Error("Predicting failed: model is not trained");return Ee(t,this.specn.params)}loadingsParamsViewers(){if(null===this.specn)throw new Error("Failed to create loadings and parameters viewers: untrained model");const e=[],n=this.specn.dim,r=t.DataFrame.fromColumns([t.Column.fromStrings(ae.FEATURES,this.specn.names.slice(0,-1)),t.Column.fromFloat32Array(ae.REGR_COEFS,this.specn.params,n)]),i=r.columns,o=i.length,a=this.specn.components;return this.specn.loadings.forEach((e,i)=>r.columns.add(t.Column.fromFloat32Array(`${ae.XLOADING}${i+1}`,e,n))),e.push(t.Viewer.scatterPlot(r,{title:ae.LOADINGS,xColumnName:i.byIndex(o).name,yColumnName:i.byIndex(o+(a>1?1:0)).name,markerType:t.MARKER_TYPE.CIRCLE,labelFormColumnNames:[ae.FEATURES],help:le.LOADINGS})),e.push(t.Viewer.barChart(r,{title:ae.REGR_COEFS,splitColumnName:ae.FEATURES,valueColumnName:ae.REGR_COEFS,valueAggrType:t.AGG.AVG,help:le.COEFFS,showValueSelector:!1,showStackSelector:!1})),e}explVarsViewer(){if(null===this.specn)throw new Error("Failed to create exaplained variances viewer: untrained model");const e=this.specn.components,n=this.specn.dim,r=new Array(e),i=new Float32Array(e);r[0]=`${he.COMP} 1`,i[0]=this.specn.loadings[0][n];for(let t=1;t<e;++t)r[t]=`${he.COMPS} ${t+1}`,i[t]=this.specn.loadings[t][n];return t.Viewer.barChart(t.DataFrame.fromColumns([t.Column.fromStrings(he.COMPS,r),t.Column.fromFloat32Array(ae.EXPL_VAR,i)]),{title:ae.EXPL_VAR,splitColumnName:he.COMPS,valueColumnName:ae.EXPL_VAR,valueAggrType:t.AGG.AVG,help:le.EXPL_VARS,showCategorySelector:!1,showStackSelector:!1,showValueSelector:!1})}viewers(){if(null===this.specn)throw new Error("Failed to create viewers: untrained model");const t=this.loadingsParamsViewers();return t.push(this.explVarsViewer(),this.getScoresScatter()),t}getScoresDf(e){const n=e.tScores,r=e.uScores;return n.forEach((t,e)=>t.name=`${ae.XSCORE}${e+1}`),r.forEach((t,e)=>t.name=`${ae.YSCORE}${e+1}`),t.DataFrame.fromColumns(n.concat(r))}getScoresScatter(){if(null===this.specn)throw new Error("Failed to create scores scatter: untrained model");const e=this.specn.scores.columns.names(),n=t.Viewer.scatterPlot(this.specn.scores,{title:ae.SCORES,xColumnName:e[0],yColumnName:e[1],markerType:t.MARKER_TYPE.CIRCLE,help:le.SCORES,showViewerFormulaLines:!0});return n.meta.formulaLines.addAll(function(t){const e=[],n=(t,n)=>{e.push({type:"line",formula:t,width:1,visible:!0,title:" ",min:-n,max:n,color:be.CIRCLE})};return t.forEach(r=>{const i="${"+r+"}";e.push({type:"line",formula:`${i} = 0`,width:1,visible:!0,title:" ",color:be.AXIS}),t.forEach(t=>{const e="${"+t+"}";we.forEach(t=>{n(e+` = sqrt(${t*t} - ${i} * ${i})`,t),n(e+` = -sqrt(${t*t} - ${i} * ${i})`,t)})})}),e}(e)),n}}const Ne=["Alpha","Beta","Gamma","Delta"];function Oe(t,e){if(t.length!==e.length)throw new Error(`Non-equal elements count: ${t.length} vs. ${e.length}`)}function Fe(e,n,r){const i=O.data.demo.randomWalk(e,n),o=i.columns,a=new Float32Array(n),s=new Array(n);for(let t=0;t<n;++t)s[t]=o.byIndex(t).getRawData();for(let i=0;i<r;++i){const r=new Float32Array(e);for(let t=0;t<n;++t)a[t]=Math.random();for(let t=0;t<e;++t)for(let e=0;e<n;++e)r[t]+=a[e]*s[e][t];o.add(t.Column.fromFloat32Array(`y${i}`,r))}return i}function Re(t,e){Oe(t,e);let n=0;const r=t.length,i=t.getRawData(),o=e.getRawData();for(let t=0;t<r;++t)n=Math.max(n,Math.abs(i[t]-o[t]));return n}function Ie(e,n,r){const i=new Array(e),o=new Array(n);for(let t=0;t<n;++t){const n=new Float32Array(e);for(let t=0;t<e;++t)n[t]=Math.random();o[t]=n}const a=t.DataFrame.fromColumns(o.map((e,n)=>t.Column.fromFloat32Array(`#${n}`,e)));for(let t=0;t<e;++t)i[t]=o.slice(0,2).map(e=>e[t]>.5?"A":"B").join("");if(a.columns.add(t.Column.fromStrings("Labels",i)),r)for(let t=0;t<n;++t)for(let n=0;n<e;++n)o[t][n]+=1*(o[t][n]>0?1:-1);return a}function De(t,e){Oe(t,e);let n=0;const r=t.length;if(r<1)return 1;for(let i=0;i<r;++i)t.get(i)===e.get(i)&&++n;return n/r}var Le=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const ke=100,Ue=9e3,Ge=.1;x("Principal component analysis",()=>{b("Performance: 100K rows, 100 cols, 3 components",()=>Le(void 0,void 0,void 0,function*(){const t=O.data.demo.randomWalk(1e5,ke);yield _e(t,t.columns,3,!1,!1)}),{timeout:Ue,benchmark:!0}),b("Performance: 1K rows, 5K cols, 3 components",()=>Le(void 0,void 0,void 0,function*(){const t=O.data.demo.randomWalk(1e3,5e3);yield _e(t,t.columns,3,!1,!1)}),{timeout:Ue,benchmark:!0}),b("Correctness",()=>Le(void 0,void 0,void 0,function*(){const t=Fe(100,3,5);C(function(t){let e=0;const n=t.length,r=t.getRawData();for(let t=0;t<n;++t)e=Math.max(e,Math.abs(r[t]));return e}((yield _e(t,t.columns,4,!1,!1)).columns.byIndex(3))<Ge,!0,"Incorrect PCA computations")}),{timeout:Ue})}),x("Partial least squares regression",()=>{b("Performance: 100K rows, 100 cols, 3 components",()=>Le(void 0,void 0,void 0,function*(){const t=O.data.demo.randomWalk(1e5,ke),e=t.columns;yield xe({table:t,features:e,predict:e.byIndex(99),components:3,names:void 0,isQuadratic:!1})}),{timeout:Ue,benchmark:!0}),b("Correctness",()=>Le(void 0,void 0,void 0,function*(){const t=Fe(100,3,5),e=t.columns,n=e.byIndex(7),r=Re(n,(yield xe({table:t,features:e,predict:n,components:3,isQuadratic:!1,names:void 0})).prediction);C(r<Ge,!0,`Incorrect PLS computations, error is too big: ${r}; expected: < 0.1`)}),{timeout:Ue}),b("Predictive modeling: 100K samples, 100 features, 3 components",()=>Le(void 0,void 0,void 0,function*(){const t=Fe(1e5,3,98).columns,e=t.byIndex(ke);t.remove(e.name);const n=new Pe;yield n.fit(t,e,3);const r=n.toBytes(),i=Re(e,new Pe(r).predict(t));C(i<Ge,!0,`Incorrect PLS (ML) computations, error is too big: ${i}; expected: < 0.1`)}),{timeout:Ue,benchmark:!0})}),x("Linear regression",()=>{b("Performance: 100K samples, 100 features",()=>Le(void 0,void 0,void 0,function*(){const t=Fe(1e5,ke,1).columns,e=t.byIndex(ke),n=yield Ae(t,e),r=new Uint8Array(n.buffer);Ee(t,new Float32Array(r.buffer))}),{timeout:Ue,benchmark:!0}),b("Correctness",()=>Le(void 0,void 0,void 0,function*(){const t=Fe(100,2,1).columns,e=t.byIndex(2),n=yield Ae(t,e),r=new Uint8Array(n.buffer),i=Ee(t,new Float32Array(r.buffer)),o=Re(i,i);C(o<Ge,!0,`Incorrect linear regression computations, error is too big: ${o}; expected: < 0.1`)}),{timeout:Ue})});var Be=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const Ve="Avg-s",He="Stddev-s";var We;!function(t){t[t.MAX_SAMLPES=5e4]="MAX_SAMLPES",t[t.MAX_FEATURES=100]="MAX_FEATURES"}(We||(We={}));class Ye{static isApplicable(e,n){for(const t of e)if(!t.matches("numerical"))return!1;return n.type===t.COLUMN_TYPE.STRING}static isInteractive(t,e){return t.length<=We.MAX_FEATURES&&e.length<=We.MAX_SAMLPES}constructor(e,n){if(this.params=void 0,this.classesCount=1,this.featuresCount=1,void 0!==e){const t=e.featuresCount,n=e.classesCount;if(t<1)throw new Error("Incorrect features count");if(n<1)throw new Error("Incorrect classes count");const r=t+1;this.avgs=new Float32Array(r),this.stdevs=new Float32Array(r),this.categories=new Array(r),this.featuresCount=t,this.classesCount=n}else{if(void 0===n)throw new Error("Softmax classifier not initialized");try{const e=new Uint32Array(n.buffer,0,1)[0],r=new Uint8Array(n.buffer,4,e),i=t.DataFrame.fromByteArray(r),o=i.columns,a=o.length;if(a<3)throw new Error("incorrect columns count");this.classesCount=a-2,this.featuresCount=i.rowCount-1;const s=this.classesCount;this.params=new Array(s),this.categories=new Array(i.rowCount);for(let e=0;e<s;++e){const n=o.byIndex(e);if(this.categories[e]=n.name,n.type!==t.COLUMN_TYPE.FLOAT)throw new Error(`Incorrect input column type. Expected: float, passed: ${n.type}`);this.params[e]=n.getRawData()}const l=o.byName(Ve);if(l.type!==t.COLUMN_TYPE.FLOAT)throw new Error("incorrect average values column type");this.avgs=l.getRawData();const c=o.byName(He);if(c.type!==t.COLUMN_TYPE.FLOAT)throw new Error("incorrect standard deviations column type");this.stdevs=c.getRawData()}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}}toBytes(){if(void 0===this.params)throw new Error("Non-trained model");const e=this.classesCount,n=new Array(e+2);for(let r=0;r<e;++r)n[r]=t.Column.fromFloat32Array(this.categories[r],this.params[r]);n[e]=t.Column.fromFloat32Array(Ve,this.avgs),n[e+1]=t.Column.fromFloat32Array(He,this.stdevs);const r=t.DataFrame.fromColumns(n).toByteArray(),i=r.length,o=new Uint8Array(i+4);return new Uint32Array(o.buffer,0,1)[0]=i,o.set(r,4),o}fit(e,n){return Be(this,arguments,void 0,function*(e,n,r=1,i=100,o=.1,a=.001){if(e.length!==this.featuresCount)throw new Error("Training failes - incorrect features count");if(r<=0||i<1||o<=0||a<=0)throw new Error("Training failes - incorrect fitting hyperparameters");this.extractStats(e);const s=n.length,l=n.categories.length,c=n.categories;for(let t=0;t<l;++t)this.categories[t]=c[t];try{const c=function(t,e,n,r,i,o,a,s,l,c,h){return Rt(EDA,"fitSoftmax",[t,e,n,r,i,o,a,s,l,c,h])}(e,t.Column.fromFloat32Array("avgs",this.avgs,this.featuresCount),t.Column.fromFloat32Array("stdevs",this.stdevs,this.featuresCount),t.Column.fromInt32Array("targets",n.getRawData(),s),l,i,r,o,a,this.featuresCount+1,l).columns;this.params=new Array(l);for(let t=0;t<l;++t)this.params[t]=c.byIndex(t).getRawData()}catch(t){try{this.params=yield this.fitSoftmaxParams(e,n,i,r,o,a)}catch(t){throw new Error("Training failes")}}if(void 0===this.params)throw new Error("Training failes")})}extractStats(e){let n=0;for(const r of e){if(r.type!==t.COLUMN_TYPE.INT&&r.type!==t.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");this.avgs[n]=r.stats.avg,this.stdevs[n]=r.stats.stdev,++n}}normalized(e){const n=e.byIndex(0).length,r=new Array(n);for(let t=0;t<n;++t)r[t]=new Float32Array(this.featuresCount);let i=0;for(const o of e){if(o.type!==t.COLUMN_TYPE.INT&&o.type!==t.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const e=o.getRawData(),a=this.avgs[i],s=this.stdevs[i];if(s>0)for(let t=0;t<n;++t)r[t][i]=(e[t]-a)/s;else for(let t=0;t<n;++t)r[t][i]=0;++i}return r}transposed(e){const n=e.byIndex(0).length,r=this.featuresCount,i=new Array(r);for(let t=0;t<r;++t)i[t]=new Float32Array(n);let o=0;for(const r of e){if(r.type!==t.COLUMN_TYPE.INT&&r.type!==t.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const e=r.getRawData(),a=this.avgs[o],s=this.stdevs[o];if(s>0)for(let t=0;t<n;++t)i[o][t]=(e[t]-a)/s;else for(let t=0;t<n;++t)i[o][t]=0;++o}return i}preprocessedTargets(e){if(e.type!==t.COLUMN_TYPE.STRING)throw new Error("Training failes - incorrect target type");const n=this.classesCount,r=e.length,i=e.getRawData(),o=new Array(r),a=new Uint32Array(n).fill(0);for(let t=0;t<r;++t)o[t]=new Uint8Array(n).fill(0);for(let t=0;t<r;++t)o[t][i[t]]=1,++a[i[t]];return{oneHot:o,weights:a}}predict(e){if(void 0===this.params)throw new Error("Non-trained model");if(e.length!==this.featuresCount)throw new Error("Predcition fails: incorrect features count");const n=this.normalized(e),r=n.length,i=this.featuresCount,o=this.classesCount;let a,s;const l=new Float32Array(o);let c,h,u;const d=new Array(r);for(let t=0;t<r;++t){a=n[t],c=0;for(let t=0;t<o;++t){s=this.params[t],c=s[i];for(let t=0;t<i;++t)c+=s[t]*a[t];l[t]=Math.exp(c)}h=l[0],u=0;for(let t=1;t<o;++t)h<l[t]&&(h=l[t],u=t);d[t]=this.categories[u]}return t.Column.fromStrings("predicted",d)}fitSoftmaxParams(t,e,r,i,o,a){return Be(this,void 0,void 0,function*(){const s=this.preprocessedTargets(e);return new Promise((l,c)=>{const h=new Worker(new URL(n.p+n.u(501),n.b));h.postMessage({features:this.normalized(t),transposed:this.transposed(t),oneHot:s.oneHot,classesWeights:s.weights,targetRaw:e.getRawData(),iterations:r,rate:i,penalty:o,tolerance:a}),h.onmessage=function(t){h.terminate(),l(t.data.params),console.log(`Loss: ${t.data.loss}`)}})})}}var je,qe,Ke,ze;(ze=je||(je={}))[ze.ITERATIONS=20]="ITERATIONS",ze[ze.ETA=.3]="ETA",ze[ze.MAX_DEPTH=6]="MAX_DEPTH",ze[ze.LAMBDA=1]="LAMBDA",ze[ze.ALPHA=0]="ALPHA",function(t){t[t.SAMLPES_HIGH=1e5]="SAMLPES_HIGH",t[t.SAMLPES_MID=5e4]="SAMLPES_MID",t[t.SAMPLES_LOW=1e4]="SAMPLES_LOW",t[t.FEATURES_HIGH=10]="FEATURES_HIGH",t[t.FEATURES_MID=20]="FEATURES_MID",t[t.FEATURES_LOW=100]="FEATURES_LOW"}(qe||(qe={})),function(t){t[t.MODEL=1e7]="MODEL",t[t.UTILS=1]="UTILS",t[t.PACK=128]="PACK",t[t.SIZE=4]="SIZE"}(Ke||(Ke={}));const $e=t.FLOAT_NULL;var Xe;!function(t){t.PREDICT="Prediction",t.TYPE="Type",t.PARAMS="Params count",t.CATS="Categories",t.CATS_SIZE="Categories size"}(Xe||(Xe={}));class Qe{static isApplicable(t,e){for(const e of t)if(!e.matches("numerical"))return!1;return!(!e.matches("numerical")&&!e.matches("string"))}static isInteractive(t,e){const n=t.length,r=e.length;return r<=qe.SAMPLES_LOW?n<=qe.FEATURES_LOW:r<=qe.SAMLPES_MID?n<=qe.FEATURES_MID:r<=qe.SAMLPES_HIGH&&n<=qe.FEATURES_HIGH}constructor(e){var n;if(this.modelParams=void 0,this.targetType=void 0,this.targetCategories=void 0,e)try{let r=0;const i=new Uint32Array(e.buffer,r,1)[0];r+=Ke.SIZE;const o=t.DataFrame.fromByteArray(new Uint8Array(e.buffer,r,i));r+=i,this.targetType=o.get(Xe.TYPE,0);const a=o.get(Xe.PARAMS,0),s=o.get(Xe.CATS_SIZE,0);if(s>0){const i=t.DataFrame.fromByteArray(new Uint8Array(e.buffer,r,s));this.targetCategories=null===(n=i.col(Xe.CATS))||void 0===n?void 0:n.toList()}r+=s,r=4*Math.ceil(r/4),this.modelParams=new Int32Array(e.buffer,r,a)}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(e,r){return i=this,o=arguments,s=function*(e,r,i=je.ITERATIONS,o=je.ETA,a=je.MAX_DEPTH,s=je.LAMBDA,l=je.ALPHA){this.targetType=r.type,this.targetType===t.COLUMN_TYPE.STRING&&(this.targetCategories=r.categories),this.modelParams=yield async function(t,e,r,i,o,a,s,l,c,h){return new Promise((u,d)=>{const f=e.length,g=t.length,p=new Float32Array(f*g);let m,y;for(let e=0;e<g;++e){y=t.byIndex(e).getRawData(),m=e*f;for(let t=0;t<f;++t)p[t+m]=y[t]}const v=new Worker(new URL(n.p+n.u(990),n.b));v.postMessage({features:p,target:e.getRawData(),samplesCount:f,featuresCount:g,modelReserve:c,utilsLength:h,iterations:i,eta:o,maxDepth:a,lambda:s,alpha:l,missingValue:r}),v.onmessage=function(t){v.terminate(),u(t.data.params)}})}(e,r,$e,i,o,a,s,l,Ke.MODEL,Ke.UTILS)},new((a=void 0)||(a=Promise))(function(t,e){function n(t){try{l(s.next(t))}catch(t){e(t)}}function r(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var i;e.done?t(e.value):(i=e.value,i instanceof a?i:new a(function(t){t(i)})).then(n,r)}l((s=s.apply(i,o||[])).next())});var i,o,a,s}predict(e){if(void 0===this.modelParams)throw new Error("Failed to apply non-trained model");const n=function(t,e,n){const r=t.byIndex(0).length,i=t.length,o=n.length;let a=XGBoostModule.HEAPF32;const s=XGBoostModule.HEAP32,l=XGBoostModule._malloc(r*i*4),c=XGBoostModule._malloc(4*r),h=XGBoostModule._malloc(4*o);for(let e=0;e<i;++e){const n=t.byIndex(e).getRawData();for(let t=0;t<r;++t)a[l/4+t+e*r]=n[t]}for(let t=0;t<o;++t)s[h/4+t]=n[t];XGBoostModule._predict(l,r,i,e,h,o,c,r),a=XGBoostModule.HEAPF32;const u=new Float32Array(r);for(let t=0;t<r;++t)u[t]=a[c/4+t];return XGBoostModule._free(l),XGBoostModule._free(c),XGBoostModule._free(h),u}(e,$e,this.modelParams);switch(this.targetType){case t.COLUMN_TYPE.STRING:return this.stringColPrediction(n);case t.COLUMN_TYPE.INT:return this.intColPrediction(n);case t.COLUMN_TYPE.BIG_INT:return this.bigIntColPrediction(n);default:return t.Column.fromFloat32Array(Xe.PREDICT,n)}}toBytes(){if(void 0===this.modelParams||void 0===this.targetType)throw new Error("Failed to pack non-trained model");const e=void 0!==this.targetCategories?t.DataFrame.fromColumns([t.Column.fromList(t.COLUMN_TYPE.STRING,Xe.CATS,this.targetCategories)]).toByteArray():void 0,n=void 0!==e?e.length:0,r=this.modelParams.length*this.modelParams.BYTES_PER_ELEMENT,i=t.DataFrame.fromColumns([t.Column.fromStrings(Xe.TYPE,[this.targetType]),t.Column.fromInt32Array(Xe.PARAMS,new Int32Array([this.modelParams.length])),t.Column.fromInt32Array(Xe.CATS_SIZE,new Int32Array([n]))]).toByteArray(),o=i.length,a=64*Math.ceil((Ke.SIZE+o+n+r+Ke.PACK)/64),s=new Uint8Array(a);let l=0;return new Uint32Array(s.buffer,l,1)[0]=o,l+=Ke.SIZE,s.set(i,l),l+=o,n>0&&s.set(e,l),l+=n,l=4*Math.ceil(l/4),s.set(new Uint8Array(this.modelParams.buffer),l),s}stringColPrediction(e){const n=e.length;if(void 0===this.targetCategories)throw new Error("Predicting fails: undefined categories");const r=new Array(n),i=this.targetCategories.length-1,o=t=>Math.max(0,Math.min(t,i));for(let t=0;t<n;++t)r[t]=this.targetCategories[o(Math.round(e[t]))];return t.Column.fromList(t.COLUMN_TYPE.STRING,Xe.PREDICT,r)}intColPrediction(e){const n=e.length,r=new Int32Array(n);for(let t=0;t<n;++t)r[t]=Math.round(e[t]);return t.Column.fromInt32Array(Xe.PREDICT,r,n)}bigIntColPrediction(e){const n=e.length,r=new BigInt64Array(n);for(let t=0;t<n;++t)r[t]=BigInt(Math.round(e[t]));return t.Column.fromBigInt64Array(Xe.PREDICT,r)}}var Je=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const Ze=100,tn=8e3;var en;x("Softmax",()=>{b("Performance: 50K samples, 100 features",()=>Je(void 0,void 0,void 0,function*(){const t=Ie(5e4,Ze,!1).columns,e=t.byIndex(Ze);t.remove(e.name);const n=new Ye({classesCount:e.categories.length,featuresCount:t.length});yield n.fit(t,e);const r=n.toBytes();new Ye(void 0,r).predict(t)}),{timeout:tn,benchmark:!0}),b("Correctness",()=>Je(void 0,void 0,void 0,function*(){const t=Ie(50,2,!0).columns,e=t.byIndex(2);t.remove(e.name);const n=new Ye({classesCount:e.categories.length,featuresCount:t.length});yield n.fit(t,e);const r=n.toBytes(),i=De(e,new Ye(void 0,r).predict(t));C(i>.9,!0,`Softmax failed, too small accuracy: ${i}; expected: <= 0.9`)}),{timeout:tn})}),x("XGBoost",()=>{b("Performance: 50K samples, 100 features",()=>Je(void 0,void 0,void 0,function*(){const t=Ie(5e4,Ze,!1).columns,e=t.byIndex(Ze);t.remove(e.name);const n=new Qe;yield n.fit(t,e);const r=n.toBytes();new Qe(r).predict(t)}),{timeout:tn,benchmark:!0}),b("Correctness",()=>Je(void 0,void 0,void 0,function*(){const t=Ie(50,2,!0).columns,e=t.byIndex(2);t.remove(e.name);const n=new Qe;yield n.fit(t,e);const r=n.toBytes(),i=De(e,new Qe(r).predict(t));C(i>.9,!0,`XGBoost failed, too small accuracy: ${i}; expected: <= 0.9`)}),{timeout:tn})}),function(t){t.NO_DATAFRAME="No dataframe is opened",t.NO_MISSING_VALUES="No missing values",t.ONE_AVAILABLE_FEATURE="Not enough of feature columns to apply imputation using the KNN method",t.ONE_FEATURE_SELECTED="Imputation cannot be applied to",t.UNSUPPORTED_COLUMN_TYPE="Unsupported column type",t.UNSUPPORTED_IMPUTATION_STRATEGY="Unsupported imputation strategy",t.KNN_CANNOT_BE_APPLIED="KNN imputer cannot be applied: no columns to be used as features",t.KNN_NO_TARGET_COLUMNS="KNN imputer cannot be applied: no columns with missing values",t.KNN_NO_FEATURE_COLUMNS="KNN imputer cannot be applied: no feature columns",t.KNN_NOT_ENOUGH_OF_ROWS="KNN imputer cannot be applied: not enough of rows",t.KNN_IMPOSSIBLE_IMPUTATION="Imputation is impossible, no features can be used",t.INCORRECT_NEIGHBORS="Incorrect number of neighbors",t.KNN_FAILS="KNN IMPUTATION FAILS",t.CORE_ISSUE="Core issue",t.FAILED_TO_IMPUTE="Failed to impute",t.UNSUPPORTED_FILL_VALUE_TYPE="Unsupported fill value type",t.EMPTY_COLUMN="Column contains just null values",t.FAILS_TO_PREDICT_IMPUTATION_FAILS="Failed to predict imputation fails",t.WRONG_PREDICTIONS="wrong evaluation of KNN imputation fails"}(en||(en={}));const nn="copy";var rn,on;!function(t){t.KNN_IMPUTER="k-NN Imputation",t.TABLE="Table",t.IN_PLACE="In-place",t.COLUMNS="Impute",t.FEATURES="Using",t.CANCEL="CANCEL",t.RUN="RUN",t.OK="OK",t.NEIGHBORS="Neighbors",t.DISTANCE="Distance",t.FILL="Fill",t.MARK="Mark",t.SIMPLE_IMPUTER="Simple impute",t.SETTINGS="Settings",t.KEEP_EMPTY="Keep empty"}(rn||(rn={})),function(t){t.TARGET="Columns with missing values that must be filled",t.FEATURES="Columns with features to be used for determining the 'nearest' elements in the k-NN method",t.IN_PLACE="Defines whether to use in-place imputation or add a new column without missing values",t.METRIC="Type of metric between the feature values",t.WEIGHT="Weight",t.NEIGHBORS="Neighbors count used in the KNN method",t.DISTANCE="Type of distance between elements with the specified features",t.METRIC_SETTINGS="Show additional options",t.FILL_FAILED_ITEMS="Impute missing values using a simple approach: mean, median or most frequent",t.MARK_FAILED_ITEMS="Mark missing values cells with a color",t.FILL_VALUE="Fill value",t.IMPUTATION_SETTINGS="Simple imputation settings",t.KEEP_EMPTY="Defines whether to keep empty missing values failed to be imputed OR fill them using simple imputation",t.RUN="Run imputation using the k-NN method"}(on||(on={}));const an=[t.COLUMN_TYPE.INT,t.COLUMN_TYPE.FLOAT,t.COLUMN_TYPE.STRING,t.COLUMN_TYPE.DATE_TIME,t.COLUMN_TYPE.QNUM];function sn(e){switch(e.type){case t.COLUMN_TYPE.INT:return t.INT_NULL;case t.COLUMN_TYPE.FLOAT:case t.COLUMN_TYPE.QNUM:case t.COLUMN_TYPE.DATE_TIME:return t.FLOAT_NULL;case t.COLUMN_TYPE.STRING:return e.max;default:throw new Error(en.UNSUPPORTED_COLUMN_TYPE)}}var ln,cn,hn,un;function dn(e){switch(e){case t.COLUMN_TYPE.STRING:case t.COLUMN_TYPE.DATE_TIME:return{defaultWeight:hn.WEIGHT,defaultMetric:ln.ONE_HOT,availableMetrics:[ln.ONE_HOT]};case t.COLUMN_TYPE.INT:case t.COLUMN_TYPE.FLOAT:case t.COLUMN_TYPE.QNUM:return{defaultWeight:hn.WEIGHT,defaultMetric:ln.DIFFERENCE,availableMetrics:[ln.DIFFERENCE,ln.ONE_HOT]};default:throw new Error(en.UNSUPPORTED_COLUMN_TYPE)}}!function(t){t.ONE_HOT="One-hot",t.DIFFERENCE="Difference"}(ln||(ln={})),(un=cn||(cn={})).EUCLIDEAN="Euclidean",un.MANHATTAN="Manhattan",function(t){t[t.WEIGHT=1]="WEIGHT",t[t.NEIGHBORS=4]="NEIGHBORS",t[t.IN_PLACE=1]="IN_PLACE",t[t.SELECTED=1]="SELECTED",t[t.KEEP_EMPTY=0]="KEEP_EMPTY"}(hn||(hn={}));const fn=e=>{b(`${e} dist, 100K rows, 15 cols, 75 missing vals`,()=>{return n=void 0,r=void 0,o=function*(){const n=function(e){const n=Ne.length,r=[];let i=0;const o=new Map;for(let n=0;n<5;++n){const a=new Int32Array(e),s=`int #${n+1}`,l=[];for(let t=0;t<e;++t)a[t]=Math.floor(10*Math.random());for(let n=0;n<5;++n)i=Math.floor(e*Math.random()),a[i]=t.INT_NULL,l.push(i);r.push(t.Column.fromInt32Array(s,a)),o.set(s,l)}for(let n=0;n<5;++n){const a=new Float32Array(e),s=`float #${n+1}`,l=[];for(let t=0;t<e;++t)a[t]=10*Math.random();for(let n=0;n<5;++n)i=Math.floor(e*Math.random()),a[i]=t.FLOAT_NULL,l.push(i);r.push(t.Column.fromFloat32Array(s,a)),o.set(s,l)}for(let a=0;a<5;++a){const s=new Array(e),l=`str #${a+1}`,c=[];for(let t=0;t<e;++t)s[t]=Ne[Math.floor(Math.random()*n)];const h=t.Column.fromStrings(l,s);for(let t=0;t<5;++t)i=Math.floor(e*Math.random()),h.set(i,null),c.push(i);r.push(h),o.set(l,c)}return{df:t.DataFrame.fromColumns(r),misValsIds:o}}(1e5),r=n.df,i=r.columns.names(),o=new Map,a=n.misValsIds;for(const t of r.columns){const e=dn(t.type);o.set(t.name,{weight:e.defaultWeight,type:e.defaultMetric})}const s=function(e,n,r,i,o,a,s){if(a<1)throw new Error(en.INCORRECT_NEIGHBORS);if(e.rowCount<2)throw new Error(en.KNN_NOT_ENOUGH_OF_ROWS);if(0===n.length)throw new Error(en.KNN_NO_TARGET_COLUMNS);if(0===r.size)throw new Error(en.KNN_NO_FEATURE_COLUMNS);1===r.size&&n.forEach(t=>{if(r.has(t))throw new Error(`${en.KNN_NO_FEATURE_COLUMNS} can be used for the column '${t}'`)}),n.forEach(t=>{if(!i.has(t))throw new Error(`${en.KNN_FAILS}: ${en.WRONG_PREDICTIONS}`)});const l=e.columns;n.forEach(t=>{if(!an.includes(l.byName(t).type))throw new Error(en.UNSUPPORTED_COLUMN_TYPE)}),r.forEach((t,n)=>{if(!an.includes(e.getCol(n).type))throw new Error(en.UNSUPPORTED_COLUMN_TYPE)});const c=new Map;return n.forEach(n=>{const h=l.byName(n),u=sn(h),d=h.length,f=h.getRawData(),g=new Uint16Array(h.categories.length),p=[],m=[],y=[],v=[];r.forEach((t,e)=>{if(e!==h.name){const n=l.byName(e);switch(p.push(n.getRawData()),m.push(sn(n)),t.type){case ln.DIFFERENCE:y.push((e,n)=>t.weight*Math.abs(e-n));break;case ln.ONE_HOT:y.push((e,n)=>t.weight*(e===n?0:1))}}});const _=p.length,w=new Uint32Array(p.length),b=new Float32Array(p.length);let C=0;const x=new Array(a);let S=0,A=0,E=0,T=0,M=0;const P=(t,e)=>{w.forEach((n,r)=>{b[r]=y[n](p[n][t],p[n][e])})},N=o===cn.EUCLIDEAN?()=>{let t=0;for(let e=0;e<C;++e)t+=b[e]*b[e];return Math.sqrt(t)}:()=>{let t=0;for(let e=0;e<C;++e)t+=Math.abs(b[e]);return Math.sqrt(t)},F=t=>{if(f[t]===u)return!1;for(let e=0;e<C;++e)if(p[w[e]][t]===m[w[e]])return!1;return!0},R=e=>{if((t=>{C=0;for(let e=0;e<_;++e)p[e][t]!==m[e]&&(w[C]=e,++C)})(e),0===C)throw new Error(`${en.KNN_IMPOSSIBLE_IMPUTATION}: the column "${h.name}", row ${e+1}`);S=0;for(let t=0;t<d;++t)if(F(t)&&t!==e){P(e,t);const n=N();if(S<a)x[S]={index:t,dist:n},++S;else{A=0,E=x[0].dist;for(let t=1;t<S;++t)E<x[t].dist&&(E=x[t].dist,A=t);n<E&&(x[A]={index:t,dist:n})}}if(0===S)throw new Error(`${en.KNN_IMPOSSIBLE_IMPUTATION}: the column "${h.name}", row ${e+1}`);if(h.type===t.COLUMN_TYPE.STRING)return(()=>{g.forEach((t,e,n)=>n[e]=0);let t=0;for(t=0;t<S;++t)++g[f[x[t].index]];let e=g[0],n=0;return g.forEach((t,r)=>{t>e&&(e=t,n=r)}),n})();T=0;for(let t=0;t<S;++t)T+=f[x[t].index];return M=T/S,h.type===t.COLUMN_TYPE.INT?Math.round(M):M};if(s){for(const t of i.get(n))try{f[t]=R(t)}catch(e){v.push(t),e instanceof Error||O.shell.error(en.CORE_ISSUE)}v.length>0&&c.set(n,v),h.set(0,h.get(0))}else{const t=h.clone();let r=1,o=`${n}(${nn})`;for(;e.columns.contains(o);)o=`${n}(${nn} ${r})`,++r;t.name=o;const a=t.getRawData();for(const t of i.get(n))try{a[t]=R(t)}catch(e){v.push(t),e instanceof Error||O.shell.error(en.CORE_ISSUE)}v.length>0&&c.set(o,v),t.set(0,t.get(0)),e.columns.add(t)}}),c}(r,i,o,a,e,5,!0);let l=0;s.forEach((t,e)=>l+=t.length),C(l,0,`Failed to impute ${l} missing values`)},new((i=void 0)||(i=Promise))(function(t,e){function a(t){try{l(o.next(t))}catch(t){e(t)}}function s(t){try{l(o.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i(function(t){t(n)})).then(a,s)}l((o=o.apply(n,r||[])).next())});var n,r,i,o},{timeout:1e4,benchmark:!0})};x("Missing values imputation",()=>{fn(cn.EUCLIDEAN),fn(cn.MANHATTAN)});var gn,pn=n(6572);function mn(t){if(t<=0||t>=1)throw new Error(gn.INCORRECT_SIGNIFICANCE_LEVEL)}function yn(t){const e=t.size;return e<=1?0:(t.sumOfSquares-Math.pow(t.sum,2)/e)/(e-1)}function vn(t,e,n){mn(n);const r=yn(t),i=yn(e);return 0===r||0===i?r===i:r/i<pn.centralF.inv(1-n,t.size-1,e.size-1)}!function(t){t.NON_EQUAL_FACTORS_VALUES_SIZE="non-equal sizes of factor and values arrays",t.INCORRECT_SIGNIFICANCE_LEVEL="incorrect significance level",t.NON_EQUAL_VARIANCES="non-equal variances",t.NON_NORMAL_DISTRIB="non-normal distribution",t.UNSUPPORTED_COLUMN_TYPE="unsupported feature column type",t.INCORRECT_CATEGORIES_COL_TYPE="incorrect categories column type",t.SINGLE_FACTOR="single category features",t.CATS_EQUAL_SIZE="single value in each category",t.NO_FEATURE_VARIATION="no feature variation",t.NO_FEATURE_VARIATION_WITHIN_GROUPS="no feature variation within groups"}(gn||(gn={}));class _n{constructor(t,e,n){if(this.nullsCount=0,t.length!==e.length)throw new Error(gn.NON_EQUAL_FACTORS_VALUES_SIZE);if(!(e.stats.stdev>0))throw new Error(gn.NO_FEATURE_VARIATION);this.setStats(t,e,n)}areVarsEqual(t){const e=this.catCount;if(1===e)return!0;const n={sum:this.sums[0],sumOfSquares:this.sumsOfSquares[0],size:this.subSampleSizes[0]};for(let r=1;r<e;++r)if(!vn(n,{sum:this.sums[r],sumOfSquares:this.sumsOfSquares[r],size:this.subSampleSizes[r]},t))return!1;return!0}getOneWayAnova(){let t=0,e=0,n=0,r=this.catCount,i=r;for(let o=0;o<r;++o)0!==this.subSampleSizes[o]?(t+=this.sums[o],e+=this.sumsOfSquares[o],n+=Math.pow(this.sums[o],2)/this.subSampleSizes[o]):--i;if(r=i,1===r)throw new Error(gn.SINGLE_FACTOR);const o=this.size-this.nullsCount;if(o===r)throw new Error(gn.CATS_EQUAL_SIZE);const a=e-Math.pow(t,2)/o,s=n-Math.pow(t,2)/o,l=a-s;if(0===l)throw new Error(gn.NO_FEATURE_VARIATION_WITHIN_GROUPS);const c=r-1,h=o-r,u=s/c,d=l/h,f=u/d;return{ssBn:s,ssWn:l,ssTot:a,dfBn:c,dfWn:h,dfTot:o-1,msBn:u,msWn:d,fStat:f,pValue:1-pn.centralF.cdf(f,c,h)}}setStats(e,n,r){const i=n.type,o=n.length,a=sn(n);switch(i){case t.COLUMN_TYPE.INT:case t.COLUMN_TYPE.FLOAT:const i=r;this.catCount=i,this.size=o;const s=n.getRawData(),l=e.getRawData(),c=new Float64Array(i).fill(0),h=new Float64Array(i).fill(0),u=new Int32Array(i).fill(0);let d;if(e.type==t.COLUMN_TYPE.BOOL){let t=0,e=0,n=l[0];const r=8*l.BYTES_PER_ELEMENT-1;for(let i=0;i<o;++i)d=1&n>>e,s[i]!==a?(c[d]+=s[i],h[d]+=Math.pow(s[i],2),++u[d]):++this.nullsCount,++e,e>r&&(e=0,++t,n=l[t])}else{const t=e.stats.missingValueCount>0?sn(e):-1;for(let e=0;e<o;++e)d=l[e],d!==t&&s[e]!==a?(c[d]+=s[e],h[d]+=Math.pow(s[e],2),++u[d]):++this.nullsCount}this.sums=c,this.sumsOfSquares=h,this.subSampleSizes=u;break;default:throw new Error(gn.UNSUPPORTED_COLUMN_TYPE)}}}function wn(t,e,n,r=!0){mn(n);const i=t.stats.uniqueCount;if(i<2)throw new Error(gn.SINGLE_FACTOR);const o=new _n(t,e,i);if(r&&!o.areVarsEqual(n))throw new Error(gn.NON_EQUAL_VARIANCES);const a=o.getOneWayAnova();return{anovaTable:a,fCritical:pn.centralF.inv(1-n,a.dfBn,a.dfWn),significance:n}}var bn=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const Cn=.05,xn=!1,Sn=t.Column.fromList(t.COLUMN_TYPE.INT,"features",[9,12,4,8,7,4,6,8,2,10,1,3,4,5,2]),An=t.Column.fromStrings("features",["A","A","A","A","A","B","B","B","B","B","C","C","C","C","C"]);var En;!function(t){t[t.DF_BN=2]="DF_BN",t[t.DF_TOT=14]="DF_TOT",t[t.DF_WN=12]="DF_WN",t[t.SS_BN=63.333]="SS_BN",t[t.SS_TOT=147.333]="SS_TOT",t[t.SS_WN=84]="SS_WN",t[t.MS_BN=31.666]="MS_BN",t[t.MS_WN=7]="MS_WN",t[t.F_STAT=4.523]="F_STAT",t[t.F_CRIT=3.885]="F_CRIT",t[t.P_VAL=.034]="P_VAL"}(En||(En={})),x("ANOVA",()=>{b("Performance: 1M rows demog",()=>bn(void 0,void 0,void 0,function*(){const t=O.data.demo.demog(1e6),e=t.col("race"),n=t.col("height");new _n(e,n,e.stats.uniqueCount).areVarsEqual(Cn),wn(e,n,Cn,xn)}),{timeout:4e3,benchmark:!0}),b("Correctness",()=>bn(void 0,void 0,void 0,function*(){const t=wn(An,Sn,Cn,xn),e=t.anovaTable;C(e.dfBn,En.DF_BN,"Incorrect degrees of freedom: dfBn"),C(e.dfTot,En.DF_TOT,"Incorrect degrees of freedom: dfTot"),C(e.dfWn,En.DF_WN,"Incorrect degrees of freedom: dfWn");const n=(t,e)=>Math.abs(t-e)<.01;C(n(e.ssBn,En.SS_BN),!0,"Incorrect sum of squares: ssBn"),C(n(e.ssTot,En.SS_TOT),!0,"Incorrect sum of squares: ssTot"),C(n(e.ssWn,En.SS_WN),!0,"Incorrect sum of squares: ssWn"),C(n(e.msBn,En.MS_BN),!0,"Incorrect mean squares: msBn"),C(n(e.msWn,En.MS_WN),!0,"Incorrect mean squares: msWn"),C(n(e.fStat,En.F_STAT),!0,"Incorrect F-statistics value"),C(n(e.pValue,En.P_VAL),!0,"Incorrect p-value"),C(n(t.fCritical,En.F_CRIT),!0,"Incorrect F-critical")}),{timeout:4e3})});var Tn=n(5778),Mn=n.n(Tn);const Pn=rxjs,Nn=10,On=10,Fn=20,Rn=30;class In{constructor(t,e,n){this.root=it.div(),this.onChanged=new Pn.Subject,this._prop=t,this.root.style.width=`${e}px`,this.root.style.height=`${n}px`,this.root.style.position="relative";const r=this;setTimeout(()=>{var i,o;if(!this.root.parentElement)return void console.warn("Konva this.container not attached to DOM yet.");const a=new(Mn().Stage)({container:this.root,width:e,height:n}),s=new(Mn().Layer);a.add(s);const l=null!==(i=t.min)&&void 0!==i?i:Math.min(...t.line.map(t=>t[0])),c=null!==(o=t.max)&&void 0!==o?o:Math.max(...t.line.map(t=>t[0])),h=new(Mn().Line)({points:[Rn,n-Fn,e-On,n-Fn],stroke:"grey",strokeWidth:1}),u=new(Mn().Line)({points:[Rn,Nn,Rn,n-Fn],stroke:"grey",strokeWidth:1});s.add(h,u);const d=new(Mn().Text)({x:Rn,y:n-Fn+3,text:l.toFixed(1),fontSize:9,fill:"grey"}),f=new(Mn().Text)({x:e-On-15,y:n-Fn+3,text:c.toFixed(1),fontSize:9,align:"right",fill:"grey"}),g=new(Mn().Text)({x:10,y:n-Fn-5,text:"0.0",fontSize:9,fill:"grey"}),p=new(Mn().Text)({x:10,y:5,text:"1.0",fontSize:9,fill:"grey"});s.add(d,f,g,p);const m=new(Mn().Line)({points:[],stroke:"#2077b4",strokeWidth:2,lineCap:"round",lineJoin:"round"});s.add(m);const y=new(Mn().Group);function v(i=!0){y.destroyChildren();const o=[];t.line.sort((t,e)=>t[0]-e[0]),t.line.forEach((r,i)=>{const h=Dn(r[0],r[1],l,c,e,n);o.push(h.x,h.y);const u=new(Mn().Circle)({x:h.x,y:h.y,radius:3,fill:"#d72f30",stroke:"black",strokeWidth:1,draggable:!0,hitStrokeWidth:5});u.setAttr("_pointIndex",i),u.on("dragmove",r=>{const i=r.target,o=i.position(),a=i.getAttr("_pointIndex"),h=a>0?t.line[a-1][0]:l,u=a<t.line.length-1?t.line[a+1][0]:c,d=c-l===0?0:.001*(c-l),f=Dn(h+(a>0?d:0),0,l,c,e,n).x,g=Dn(u-(a<t.line.length-1?d:0),0,l,c,e,n).x;o.x=Math.max(f,Math.min(g,o.x));const p=n-Fn;o.y=Math.max(10,Math.min(p,o.y)),i.position(o);const y=Ln(o.x,o.y,l,c,e,n);t.line[a][0]=y.x,t.line[a][1]=y.y;const v=t.line.map((t,r)=>{if(r===a)return[o.x,o.y];{const r=Dn(t[0],t[1],l,c,e,n);return[r.x,r.y]}}).flat();m.points(v),s.batchDraw()}),u.on("dragend",e=>{t.line.sort((t,e)=>t[0]-e[0]),v()}),u.on("contextmenu",e=>{if(e.evt.preventDefault(),t.line.length<=2)return void O.shell.warning("Cannot remove points, minimum of 2 required.");const n=e.target.getAttr("_pointIndex");t.line.splice(n,1),v()}),u.on("mouseenter",t=>{a.container().style.cursor="pointer";const r=t.target.position(),i=Ln(r.x,r.y,l,c,e,n),o=`X: ${i.x.toFixed(2)}, Y: ${i.y.toFixed(2)}<br><br>Drag to move, right-click to delete`;it.tooltip.show(o,t.evt.clientX,t.evt.clientY)}),u.on("mouseleave",t=>{a.container().style.cursor="default",it.tooltip.hide()}),y.add(u)}),m.points(o),s.batchDraw(),i&&r.onChanged.next()}s.add(y),a.on("click tap",r=>{if(r.target instanceof Mn().Circle||0!==r.evt.button)return;const i=a.getPointerPosition();if(!i)return;if(i.x<Rn||i.x>e-On||i.y<Nn||i.y>n-Fn)return;const o=Ln(i.x,i.y,l,c,e,n);t.line.push([o.x,o.y]),v()}),a.on("mouseenter",t=>{if(!(t.target instanceof Mn().Circle)){const t=a.getPointerPosition();t&&t.x>=Rn&&t.x<=e-On&&t.y>=Nn&&t.y<=n-Fn&&(a.container().style.cursor="crosshair")}}),a.on("mouseleave",t=>{t.target instanceof Mn().Circle||(a.container().style.cursor="default")}),a.on("mousemove",t=>{if(!(t.target instanceof Mn().Circle)){const t=a.getPointerPosition();t&&t.x>=Rn&&t.x<=e-On&&t.y>=Nn&&t.y<=n-Fn?a.container().style.cursor="crosshair":a.container().style.cursor="default"}}),a.on("mouseout",t=>it.tooltip.hide()),v(!1)},0)}get line(){return this._prop.line}}function Dn(t,e,n,r,i,o){const a=o-Nn-Fn;return{x:Rn+(t-n)*(r-n===0?1:(i-Rn-On)/(r-n)),y:Nn+a-e*a}}function Ln(t,e,n,r,i,o){const a=o-Nn-Fn;let s=n+(t-Rn)/(r-n===0?1:(i-Rn-On)/(r-n)),l=(Nn+a-e)/a;return s=Math.max(n,Math.min(r,s)),l=Math.max(0,Math.min(1,l)),{x:s,y:l}}class kn{constructor(t){this.root=it.div([]),this.onChanged=new Pn.Subject,this.dataFrame=t,this.setProfile()}getProfile(){return this.profile}setProfile(t){if(this.profile=t,it.empty(this.root),!t)return void this.root.append(it.divText("No profile specified."));const e=it.divH([it.divText("Property",{style:{fontWeight:"bold",width:"150px"}}),it.divText("Weight",{style:{fontWeight:"bold",width:"60px"}}),it.divText("Desirability",{style:{fontWeight:"bold",flexGrow:"1"}})],{style:{marginTop:"10px",paddingBottom:"5px",borderBottom:"1px solid #ccc"}}),n=Object.entries(t.properties).map(([e,n])=>{var r,i,o;const a=new In(n,300,80);a.onChanged.subscribe(t=>this.onChanged.next());const s=it.input.float("",{value:n.weight,min:0,max:1,onValueChanged:n=>{if(t&&t.properties[e]){let r=null!=n?n:0;r=Math.max(0,Math.min(1,r)),t.properties[e].weight=r}}});s.root.style.width="60px",s.root.style.marginTop="21px";const l=this.dataFrame?this.dataFrame.columns.names().find(t=>t.toLowerCase()==e.toLowerCase()):null,c=it.input.choice("",{nullable:!0,items:null!==(o=null===(i=null===(r=this.dataFrame)||void 0===r?void 0:r.columns)||void 0===i?void 0:i.names())&&void 0!==o?o:[""],value:null!=l?l:""}),h=it.divH([it.divV([it.divText(e,{style:{width:"150px",paddingTop:"5px",marginLeft:"4px"}}),this.dataFrame?c.root:null]),s.root,a.root]);return h.style.alignItems="center",h.style.marginBottom="5px",h.style.minHeight="70px",h}).filter(t=>null!==t);n.length>0?(this.root.append(e),this.root.append(it.divV(n))):this.root.append(it.divText("No matching properties found in the table for this template."))}}var Un=n(5072),Gn=n.n(Un),Bn=n(7825),Vn=n.n(Bn),Hn=n(7659),Wn=n.n(Hn),Yn=n(5056),jn=n.n(Yn),qn=n(540),Kn=n.n(qn),zn=n(1113),$n=n.n(zn),Xn=n(4884),Qn={};Qn.styleTagTransform=$n(),Qn.setAttributes=jn(),Qn.insert=Wn().bind(null,"head"),Qn.domAPI=Vn(),Qn.insertStyleElement=Kn(),Gn()(Xn.A,Qn),Xn.A&&Xn.A.locals&&Xn.A.locals;const Jn="pMPO is not applicable",Zn="Failed to compute pMPO parameters",tr="desired",er="non-desired",nr="Mean",rr="p-value",ir=new Map([["desAvg",`${nr}(${tr})`],["desStd",`Std(${tr})`],["nonDesAvg",`${nr}(${er})`],["nonDesStd",`Std(${er})`],["tstat","t-statistics"],["pValue",rr]]),or="Descriptor",ar=or+" Statistics",sr="Selected",lr="Weight",cr="pMPO score",hr="Desirability Curve",ur=.001,dr=.001,fr=.53,gr=.01,pr=.05,mr=.01,yr="0.000";var vr;!function(t){t.SELECTED="rgb(26, 146, 26)",t.SKIPPED="rgb(208, 57, 67)"}(vr||(vr={}));const _r=[0,.25,.5,1,1.5,2,2.5,3,4,5],wr=_r.slice(1).map(t=>-t).reverse().concat(_r),br=_r.concat([.12,.37,.63,.75,.88,1.25,1.75,2.25,2.75]).sort(),Cr=br.slice(1).map(t=>-t).reverse().concat(br),xr="TPR (Sensitivity)",Sr="FPR (1 - Specificity)",Ar=101,Er=new Float32Array(Array.from({length:Ar},(t,e)=>e/100)),Tr="System:AppData/Eda/drugs-props-train.csv",Mr="System:AppData/Eda/drugs-props-train-scores.csv",Pr=new Map([["tolerance",.001],["maxIter",25],["nonZeroParam",1e-4],["initialScale",.02],["scaleReflaction",1],["scaleExpansion",2],["scaleContraction",-.5]]),Nr=new Float32Array([.5,mr]),Or=new Float32Array([1,1]);function Fr(t,e){const n=t.groupBy([e.name]).getGroups();let r,i;for(const t in n)t.toLowerCase().includes("true")?r=n[t]:i=n[t];return{desired:r,nonDesired:i}}function Rr(t,e){const n=t.length,r=e.length;if(n<2||r<2)throw new Error(`Failed to compute the "${t.name}" descriptor statistics: \n both samples must have at least two observations.`);const i=t.stats.avg,o=e.stats.avg,a=t.stats.variance,s=e.stats.variance,l=t.stats.stdev,c=e.stats.stdev,h=Math.sqrt(a/n+s/r);if(0===h)throw new Error(`Failed to compute the "${t.name}" descriptor statistics: \n zero variance.`);const u=(i-o)/h,d=Math.pow(a/n+s/r,2)/(a*a/(n*n*(n-1))+s*s/(r*r*(r-1))),f=2*(1-pn.studentt.cdf(Math.abs(u),d));return{desAvg:i,desStd:l,desLen:n,nonDesAvg:o,nonDesStd:c,nonSesLen:r,min:Math.min(t.stats.min,e.stats.min),max:Math.max(t.stats.max,e.stats.max),tstat:u,pValue:f}}function Ir(e,n,r){if(e.length!==n.length)throw new Error("Failed to compute confusion matrix: columns have different lengths.");if(e.type!==t.COLUMN_TYPE.BOOL)throw new Error("Failed to compute confusion matrix: desirability column must be boolean.");if(!n.isNumerical)throw new Error("Failed to compute confusion matrix: prediction column must be numerical.");let i=0,o=0,a=0,s=0;const l=e.getRawData(),c=n.getRawData();let h=0,u=0,d=l[0];for(let t=0;t<n.length;++t)1==(d>>>u&1)?c[t]>=r?++i:++s:c[t]>=r?++a:++o,++u,u>=32&&(u=0,++h,d=l[h]);return{TP:i,TN:o,FP:a,FN:s}}function Dr(t,e){if(t.length!==e.length)throw new Error("Failed to compute AUC: TPR and FPR arrays have different lengths.");let n=0;for(let r=1;r<t.length;++r)n+=Math.abs(e[r]-e[r-1])*((t[r]+t[r-1])/2);return n}function Lr(t,e){const n=new Float32Array(Ar),r=new Float32Array(Ar);let i=-1,o=-1,a=Er[0];for(let s=0;s<Ar;++s){const l=Ir(t,e,Er[s]);n[s]=l.TP+l.FN>0?l.TP/(l.TP+l.FN):0,r[s]=l.FP+l.TN>0?l.FP/(l.FP+l.TN):0,o=n[s]-r[s],o>i&&(i=o,a=Er[s])}return{auc:Dr(n,r),threshold:a,tpr:n,fpr:r}}var kr,Ur,Gr,Br,Vr;!function(t){t.MIN="minimize",t.MAX="maximize"}(kr||(kr={})),function(t){t.OPTIMAL="optimal",t.NON_OPT="non-optimal"}(Ur||(Ur={})),function(t){t[t.FORM=.15]="FORM",t[t.VIEWER=.5]="VIEWER"}(Gr||(Gr={})),function(t){t.OPT="Pareto optimality",t.SIZE="Pareto size"}(Br||(Br={})),function(t){t[t.OPTIMAL=8]="OPTIMAL",t[t.NON_OPT=4]="NON_OPT"}(Vr||(Vr={}));const Hr=[t.Color.darkGreen,t.Color.yellow,t.Color.darkRed];function Wr(t){return t===kr.MIN?[...Hr]:[...Hr].reverse()}function Yr(e,n=!0){const r=it.label("Color scale:");r.style.paddingRight="7px";const i=[r],o=it.label(n?"min":"worst"),a=it.label(". . ."),s=it.label(n?"max":"best"),l=Wr(e),c=[o,a,s].map((e,n)=>(1!==n&&(e.style.fontWeight="bold",e.style.color=t.Color.toRgb(l[n])),e.style.marginRight="5px",e));return i.push(...c),it.divH(i)}var jr=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};function qr(e){const n=e.size,r=new Map;ir.forEach((t,e)=>{r.set(e,new Float64Array(n))});const i=[...e.keys()],o=[t.Column.fromStrings(or,i),t.Column.fromInt32Array(hr,new Int32Array(n)),t.Column.fromFloat32Array(lr,new Float32Array(n).fill(t.FLOAT_NULL))];i.forEach((t,n)=>{const i=e.get(t);null!=i&&ir.forEach((t,e)=>{const o=i[e];r.get(e)[n]=o})}),ir.forEach((e,n)=>{o.push(t.Column.fromFloat64Array(e,r.get(n)))});const a=t.DataFrame.fromColumns(o);return a.name=ar,a}function Kr(t,e){const n=[],r=t.col(or);if(null==r)throw new Error(`No column "${or} in the table with descriptors statistics.`);const i=r.toList(),o=t.col(rr);if(null==o)throw new Error(`No column "${rr} in the table with descriptors statistics.`);const a=o.getRawData();for(let r=0;r<t.rowCount;++r)a[r]<e&&n.push(i[r]);return n}function zr(t,e,n,r){const i=it.div();i.classList.add("eda-pmpo-tooltip-line");const o=it.div();o.classList.add("eda-pmpo-box"),o.style.backgroundColor=vr.SELECTED;const a=it.span([]);a.textContent=`- ${n}`,i.appendChild(o),i.appendChild(a);const s=it.div();s.classList.add("eda-pmpo-tooltip-line");const l=it.div();l.classList.add("eda-pmpo-box"),l.style.backgroundColor=vr.SKIPPED;const c=it.span([]);return c.textContent=`- ${r}`,s.appendChild(l),s.appendChild(c),it.divV([it.h2(t),it.divText(e),i,s])}function $r(t,e){const n=[];for(let r=0;r<e.length;++r)for(let i=r+1;i<e.length;++i)n.push([e[r],e[i],Math.pow(t.byName(e[r]).stats.corr(t.byName(e[i])),2)]);return n}function Xr(t,e,n,r,i){const o=i.sort((t,e)=>e[2]-t[2]),a=new Set(e);return o.filter(t=>t[2]>r).forEach(t=>{const[e,r,i]=t,o=n.get(e).pValue,s=n.get(r).pValue,l=n.get(e).tstat,c=n.get(r).tstat;o>s?a.delete(e):o<s||Math.abs(l)>Math.abs(c)?a.delete(r):a.delete(e)}),[...a]}function Qr(t,e,n,r){const i=new Map;let o=0;return n.forEach(n=>{const a=t.rowCount,s=e.rowCount,l=t.col(n);if(null==l)throw new Error(Zn+`: no column "${n}" in the desired table.`);const c=e.col(n);if(null==c)throw new Error(Zn+`: no column "${n}" in the non-desired table.`);const h=l.stats.avg,u=l.stats.stdev*Math.sqrt((a-1)/a),d=c.stats.avg,f=c.stats.stdev*Math.sqrt((s-1)/s),g=(m=u,v=f,(p=h)<(y=d)?{cutoff:(y-p)/(m+v)*m+p,cutoffDesired:Math.max(p,y-v),cutoffNotDesired:Math.max(p+m,y)}:{cutoff:(p-y)/(m+v)*v+y,cutoffDesired:Math.min(y+v,p),cutoffNotDesired:Math.max(y,p-m)});var p,m,y,v;const _=Math.exp(-Math.pow(g.cutoff-h,2)/(2*Math.pow(u,2))),w=function(t,e,n,r){const i=1/(2*Math.pow(e,2))-1/(2*Math.pow(r,2)),o=n/Math.pow(r,2)-t/Math.pow(e,2),a=Math.pow(t,2)/(2*Math.pow(e,2))-Math.pow(n,2)/(2*Math.pow(r,2))-Math.log(r/e);if(Math.abs(i)<1e-12)return Math.abs(o)<1e-12?[]:[-a/o];const s=o*o-4*i*a;if(s<0)return[];const l=Math.sqrt(s);return[(-o+l)/(2*i),(-o-l)/(2*i)]}(h,u,d,f),b=Math.pow(_,-1)-1,C=Math.pow(r,-1)-1,x=Math.pow(10,Math.log10(C/b)/(-1*(d-g.cutoff)));let S=null;if(w.length>0){for(const t of w){const e=Math.min(h,d),n=Math.max(h,d);if(e-1e-8<=t&&t<=n+1e-8){S=t;break}}null==S&&(S=w[0])}else S=g.cutoff;const A=g.cutoffNotDesired,E=function(t,e,n,r,i=.05){let o;if(e<=0)o=n===t?1:0;else{const r=1/(e*Math.sqrt(2*Math.PI)),i=-.5*Math.pow((n-t)/e,2);o=r*Math.exp(i)}o=Math.max(o,1e-12);const a=Math.max(1/o-1,1e-12),s=1/i-1,l=r-n;let c;if(Math.abs(l)<1e-12)c=1;else{const t=s/a;if(t<=0)c=1;else try{c=Math.exp(-Math.log(t)/l)}catch(t){c=1}}return{pX0:o,b:a,c}}(h,u,S,A,r),T=Math.abs(h-d)/(u+f);o+=T,i.set(n,{desAvg:h,desStd:u,nonDesAvg:d,nonDesStd:f,min:Math.min(l.stats.min,c.stats.min),max:Math.max(l.stats.max,c.stats.max),cutoff:g.cutoff,cutoffDesired:g.cutoffDesired,cutoffNotDesired:g.cutoffNotDesired,pX0:E.pX0,b,c:x,zScore:T,weight:T,intersections:w,x0:S,xBound:A,inflection:_})}),i.forEach(t=>{t.weight=t.zScore/o}),i}function Jr(t,e,n,r,i){return{type:"MPO Desirability Profile",name:n,description:r,properties:Zr(t,e,i)}}function Zr(t,e,n){const r={};return t.forEach((t,i)=>{const o=ni(t,n);r[i]={weight:t.weight,line:ei(t,e,n),min:Math.min(...o),max:Math.max(...o)}}),r}function ti(t,e,n){return function(t,e,n){return Math.exp(-Math.pow(t-e,2)/(2*Math.pow(n,2)))}(t,e.desAvg,e.desStd)*(n?function(t,e,n,r){return r>0?1/(1+n*Math.pow(r,-(t-e))):1/(1+n)}(t,e.cutoff,e.b,e.c):1)}function ei(t,e,n){return ni(t,n).map(n=>[n,ti(n,t,e)])}function ni(t,e){const n=function(t,e,n){return n?wr.map(n=>t+n*e):Cr.map(n=>t+n*e)}(t.desAvg,t.desStd,e);if(e){const e=Math.min(t.min,t.desAvg-3*t.desStd),r=Math.max(t.max,t.desAvg+3*t.desStd);return n.filter(t=>e<=t&&t<=r).sort()}return n}class ri extends Error{constructor(t){super(t),this.name="PmpoError"}}function ii(t,e,n,r){for(let i=0;i<e;i++){let o=0;for(let t=0;t<e+1;t++)t!=n&&(o+=r[t][i]);t[i]=o/e}}function oi(t,e,n,r,i,o,a,s){for(let l=0;l<o;l++)e[l]=t[l],e[l]+=i*(t[l]-r[n][l]),e[l]<a[l]?e[l]=a[l]:e[l]>s[l]&&(e[l]=s[l])}function ai(t,e,n,r,i,o){return a=this,s=void 0,c=function*(){const a=r.get("tolerance"),s=r.get("maxIter"),l=r.get("scaleReflaction"),c=r.get("scaleExpansion"),h=r.get("scaleContraction"),u=n.length+1,d=n.length,[f,g]=function(t,e,n,r,i){const o=n.length+1,a=n.length,s=e.get("nonZeroParam"),l=e.get("initialScale"),c=new Array(o),h=new Array(o);for(let e=0;e<o;e++){c[e]=new Float32Array(a);for(let t=0;t<a;t++)c[e][t]=n[t],0!=e&&e-1===t&&(0==n[t]?c[e][t]=s:c[e][t]+=l*n[e-1],c[e][t]<r[t]?c[e][t]=r[t]:c[e][t]>i[t]&&(c[e][t]=i[t]));h[e]=t(c[e])}return[c,h]}(e,r,n,i,o),p=new Array(u);for(let t=0;t<u;t++)p[t]=t;const m=p.length-1;let y=0,v=0,_=0,w=0;const b=new Float32Array(d),C=new Float32Array(d),x=new Float32Array(d),S=new Float32Array(d),A=new Array(s);if(u>1){let n=0;for(;p.sort((t,e)=>g[t]-g[e]),n=Math.min(100,Math.floor(100*y/s)),t.update(n,`Optimizing pMPO... (${n}%)`),yield new Promise(t=>setTimeout(t,1)),!(t.canceled||y>s);){if(0==y&&(v=g[0],_=2*g[p[0]]),A[y]=v,++y,v=g[p[0]],_-v>a)w=0;else if(++w,w>2*u)break;_=v,ii(b,d,p[m],f),oi(b,C,p[m],f,l,d,i,o);const t=e(C);if(t<g[p[m]]){oi(b,x,p[m],f,c,d,i,o);const n=e(x);if(n<t){g[p[m]]=n;for(let t=0;t<d;t++)f[p[m]][t]=x[t];continue}g[p[m]]=t;for(let t=0;t<d;t++)f[p[m]][t]=C[t];continue}oi(b,S,p[m],f,h,d,i,o);const n=e(S);if(!(n<g[p[m]]))break;g[p[m]]=n;for(let t=0;t<d;t++)f[p[m]][t]=S[t]}for(let t=y;t<s;t++)A[t]=g[p[0]]}return{optimalPoint:f[p[0]],iterations:y}},new((l=void 0)||(l=Promise))(function(t,e){function n(t){try{i(c.next(t))}catch(t){e(t)}}function r(t){try{i(c.throw(t))}catch(t){e(t)}}function i(e){var i;e.done?t(e.value):(i=e.value,i instanceof l?i:new l(function(t){t(i)})).then(n,r)}i((c=c.apply(a,s||[])).next())});var a,s,l,c}var si=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};class li{static isApplicable(e,n,r,i,o,a=!1){const s=n.length,l=t=>{a&&O.shell.warning(Jn+t)};if(r<dr)return l(`: too small p-value threshold - ${r}, minimum - 0.001`),!1;if(i<gr)return l(`: too small R² threshold - ${i}, minimum - 0.01`),!1;if(o<mr)return l(`: too small q-cutoff - ${o}, minimum - 0.01`),!1;if(s<10)return l(`: not enough of samples - ${s}, minimum - 10`),!1;if(n.type!==t.COLUMN_TYPE.BOOL)return l(`: "${n.name}" must be boolean column.`),!1;if(0===n.stats.stdev)return l(`: "${n.name}" has a single category.`),!1;let c=0;for(const t of e){if(!t.isNumerical)return l(`: "${t.name}" is not numerical.`),!1;if(t.stats.missingValueCount>0)return l(`: "${t.name}" contains missing values.`),!1;t.stats.stdev>0&&++c}return!(c<1&&(l(": not enough of non-constant descriptors."),1))}static isTableValid(e,n=!0){if(e.rowCount<2)return n&&O.shell.warning(Jn+`. Not enough of samples: ${e.rowCount}, minimum: 2.`),!1;let r=0,i=0;for(const n of e.columns)n.isNumerical?n.stats.missingValueCount<1&&n.stats.stdev>0&&++i:n.type==t.COLUMN_TYPE.BOOL&&++r;return r<1?(n&&O.shell.warning(Jn+": no boolean columns."),!1):!(i<1&&(n&&O.shell.warning(Jn+": no numeric columns without missing values and non-zero variance."),1))}static fit(e,n,r,i,o,a,s=!0){if(s&&!li.isApplicable(n,r,i,o,a))throw new Error("Failed to train pMPO model: the method is not applicable to the inputs");const l=n.names(),{desired:c,nonDesired:h}=Fr(e,r),u=new Map;l.forEach(t=>{u.set(t,Rr(c.col(t),h.col(t)))});const d=qr(u);!function(t,e){const n=t.col(rr);if(null==n)return;const r={};r[`<${e}`]=vr.SELECTED,r[`>=${e}`]=vr.SKIPPED,n.meta.colors.setConditional(r)}(d,i);const f=Kr(d,i);if(f.length<1)throw new ri("Cannot train pMPO model: all descriptors have high p-values (not significant).");const g=$r(n,f),p=Xr(0,f,u,o,g);return function(e,n){if(n.length<1)throw new Error("Empty list of selected descriptors.");const r=e.rowCount,i=new Array(r),o=e.col(or);if(null==o)throw new Error(`No column "${or} in the table with descriptors statistics.`);const a=o.toList();let s=!0;const l={};for(let t=0;t<r;++t)s=n.includes(a[t]),i[t]=s,l[a[t]]=s?vr.SELECTED:vr.SKIPPED;o.colors.setCategorical(l),e.columns.add(t.Column.fromList(t.COLUMN_TYPE.BOOL,sr,i))}(d,p),function(e,n,r,i){const o=new Map;n.forEach(e=>{o.set(e,new Float32Array(n.length).fill(t.FLOAT_NULL))});const a=e.col(or).toList();r.forEach(t=>{const[e,n,r]=t;o.get(e)[a.indexOf(n)]=r,o.get(n)[a.indexOf(e)]=r,o.get(e)[a.indexOf(e)]=1,o.get(n)[a.indexOf(n)]=1}),i.forEach(n=>{e.columns.add(t.Column.fromFloat32Array(n,o.get(n)))})}(d,l,g,p),function(t,e,n){e.forEach(e=>{const r=t.col(e);if(null==r)return;const i={};i[`>=${n}`]=vr.SKIPPED,i[`<${n}`]=vr.SELECTED,r.meta.colors.setConditional(i)})}(d,l,o),{params:Qr(c,h,p,a),descrStatsTable:d,selectedByPvalue:f,selectedByCorr:p}}static predict(e,n,r,i){const o=e.rowCount,a=new Float64Array(o).fill(0);return n.forEach((t,n)=>{const i=e.col(n),s=t.b,l=t.c,c=t.cutoff;let h=t.weight;const u=t.desAvg,d=t.desStd,f=1/(2*Math.pow(d,2));if(null==i)throw new Error(`Failed to apply pMPO: inconsistent data, no column "${n}" in the table "${e.name}"`);const g=i.getRawData();if(r)if(l>0)for(let t=0;t<o;++t)a[t]+=h*Math.exp(-Math.pow(g[t]-u,2)*f)/(1+s*Math.pow(l,-(g[t]-c)));else{h/=1+s;for(let t=0;t<o;++t)a[t]+=h*Math.exp(-Math.pow(g[t]-u,2)*f)}else for(let t=0;t<o;++t)a[t]+=h*Math.exp(-Math.pow(g[t]-u,2)*f)}),t.Column.fromFloat64Array(i,a)}constructor(e,n){var r;this.params=null,this.initTable=t.DataFrame.create(),this.statGrid=t.Viewer.grid(this.initTable,{showTitle:!0,title:ar}),this.predictionName=cr,this.boolPredictionName="",this.desirabilityProfileRoots=new Map,this.rocCurve=t.Viewer.scatterPlot(this.initTable,{showTitle:!0,showSizeSelector:!1,showColorSelector:!1}),this.confusionMatrix=t.Viewer.fromType("Confusion matrix",this.initTable,{xColumnName:"control",yColumnName:"control",showTitle:!0,title:"Confusion Matrix",descriptionPosition:"Bottom",description:"Confusion matrix for the predicted vs actual desirability labels.",descriptionVisibilityMode:"Always"}),this.table=e,this.view=null!=n?n:null!==(r=O.shell.tableView(e.name))&&void 0!==r?r:O.shell.addTableView(e),this.boolCols=this.getBoolCols(),this.numericCols=this.getValidNumericCols(),this.predictionName=e.columns.getUnusedName(cr)}setRibbons(){const t=this.view.getRibbonPanels();t.length<1||this.view.setRibbonPanels(t.slice(1))}updateStatisticsGrid(t,e,n,r){const i=this.statGrid;i.dataFrame=t,i.setOptions({showTitle:!0,title:t.name}),i.sort([sr],[!1]),i.col(rr).format="scientific",i.col(or).isTextColorCoded=!0,i.col(rr).isTextColorCoded=!0,e.forEach(t=>{const e=i.col(t);null!=e&&(e.isTextColorCoded=!0,e.format="0.000")}),i.onCellTooltip((t,o,a)=>{if(t.isColHeader){const n=t.tableColumn;if(null==n)return!1;const r=n.name;switch(r){case or:return it.tooltip.show(zr(or,"Use of descriptors in model construction:","selected","excluded"),o,a),!0;case hr:return it.tooltip.show(it.divV([it.h2(hr),it.divText("Desirability profile charts for each descriptor. Only profiles for selected descriptors are shown.")]),o,a),!0;case lr:return it.tooltip.show(it.divV([it.h2(lr),it.divText("Weights of selected descriptors.")]),o,a),!0;case rr:return it.tooltip.show(zr(rr,"Filtering descriptors by p-value:","selected","excluded"),o,a),!0;default:return!!e.includes(r)&&(it.tooltip.show(zr(r,`Correlation of ${r} with other descriptors, measured by R²:`,"weakly correlated","highly correlated"),o,a),!0)}}else if(t.isTableCell){const s=t.tableColumn;if(null==s)return!1;const l=s.name,c=t.value;if(l===or)return r.includes(c)?it.tooltip.show("Selected for model construction.",o,a):n.includes(c)?it.tooltip.show("Excluded due to a high correlation with other descriptors.",o,a):it.tooltip.show("Excluded due to a high p-value.",o,a),!0;{const r=i.cell(or,t.gridRow).value;if(l===lr)return!this.desirabilityProfileRoots.has(r)&&(n.includes(r)?it.tooltip.show(`No weight: <b>${r}</b> is excluded due to a high correlation with other descriptors.`,o,a):it.tooltip.show(`No weight: <b>${r}</b> is excluded due to a high p-value.`,o,a),!0);if(e.includes(l)&&!n.includes(r))return it.tooltip.show(`<b>${r}</b> is excluded due to a high p-value; so correlation with <b>${l}</b> is not needed.`,o,a),!0}return!1}});const o=i.col(hr);i.setOptions({rowHeight:75}),o.width=305,o.cellType="html",i.onCellPrepare(t=>{if(null==t.tableColumn)return;if(null==t.tableColumn)return;if(!t.isTableCell)return;if(t.tableColumn.name!==hr)return;const e=i.cell(or,t.gridRow).value,r=this.desirabilityProfileRoots.get(e);if(null!=r)t.element=r;else{const r=n.includes(e),i=r?"highly correlated with other descriptors":"statistically insignificant",o=r?`No chart shown: <b>${e}</b> is excluded due to a high correlation with other descriptors.`:`No chart shown: <b>${e}</b> is excluded due to a high p-value.`,a=it.divText(i);a.style.color=vr.SKIPPED,a.classList.add("eda-pmpo-centered-text"),it.tooltip.bind(a,o),t.element=a}})}updateGrid(){const t=this.view.grid,e=this.predictionName;t.sort([this.predictionName],[!1]),t.col(e).format="0.0000",t.onCellTooltip((t,n,r)=>{if(t.isColHeader&&t.tableColumn)return t.tableColumn.name===e&&(it.tooltip.show(it.divV([it.h2(cr),it.divText("Scores computed using the trained probabilistic multi-parameter optimization (pMPO) model."),Yr(kr.MAX,!1)]),n,r),!0)})}updateDesirabilityProfileData(t,e){if(null==this.params)return;this.desirabilityProfileRoots.forEach(t=>t.remove()),this.desirabilityProfileRoots.clear();const n=Jr(this.params,e,"","",!0),r=t.col(or).toList(),i=t.col(lr).getRawData(),o=n.properties;for(const t of Object.keys(o))i[r.indexOf(t)]=o[t].weight;const a=new kn;a.setProfile(n);const s=a.root.querySelector("div.d4-flex-col.ui-div");null!=s&&s.querySelectorAll("div.d4-flex-row.ui-div").forEach(t=>{const e=t.children;if(e.length<2)return;const n=e[0].children;if(n.length<1)return;const r=n[0].innerText;this.desirabilityProfileRoots.set(r,e[2])})}updateRocCurve(e,n){const r=Lr(e,n),i=t.DataFrame.fromColumns([t.Column.fromFloat32Array("Threshold",Er),t.Column.fromFloat32Array(Sr,r.fpr),t.Column.fromFloat32Array(xr,r.tpr)]);return i.meta.formulaLines.addLine({title:"Non-informative baseline",formula:`\${${xr}} = \${${Sr}}`,width:1,style:"dashed",min:0,max:1}),this.rocCurve.dataFrame=i,this.rocCurve.setOptions({xColumnName:Sr,yColumnName:xr,linesOrderColumnName:Sr,linesWidth:5,markerType:"dot",title:`ROC Curve (AUC = ${r.auc.toFixed(3)})`}),r.threshold}updateConfusionMatrix(t,e,n){this.confusionMatrix.dataFrame=t,this.confusionMatrix.setOptions({xColumnName:e,yColumnName:this.boolPredictionName,description:`Threshold: ${n.toFixed(3)} (optimized via Youden's J)`,title:e+" Confusion Matrix"})}fitAndUpdateViewers(e,n,r,i,o,a,s){const l=li.fit(e,n,r,i,o,a);this.params=l.params;const c=l.descrStatsTable,h=l.selectedByPvalue,u=l.selectedByCorr,d=n.names(),f=li.predict(e,this.params,s,this.predictionName);f.colors.setLinear(Wr(kr.MAX),{min:f.stats.min,max:f.stats.max}),e.columns.remove(this.predictionName),e.columns.add(f),this.updateGrid(),this.updateDesirabilityProfileData(c,s),this.updateStatisticsGrid(c,d,h,u);const g=this.updateRocCurve(r,f),p=r.name;e.columns.remove(this.boolPredictionName),this.boolPredictionName=e.columns.getUnusedName(p+"(predicted)");const m=function(e,n,r){if(!e.isNumerical)throw new Error("Failed to compute confusion matrix: prediction column must be numerical.");const i=e.length,o=new Array(i),a=e.getRawData();for(let t=0;t<i;++t)o[t]=a[t]>=n;return t.Column.fromList(t.COLUMN_TYPE.BOOL,r,o)}(f,g,this.boolPredictionName);e.columns.add(m),this.updateConfusionMatrix(e,p,g),this.view.dataFrame.selection.setAll(!1,!0)}runTrainingApp(){const e=this.view.dockManager;e.dock(this.getInputForm(!0).form,t.DOCK_TYPE.LEFT,null,void 0,.1);const n=e.findNode(this.view.grid.root);if(null==n)throw new Error("Failed to train pMPO: missing a grid in the table view.");const r=e.dock(this.statGrid,t.DOCK_TYPE.DOWN,n,void 0,.5),i=e.dock(this.rocCurve,t.DOCK_TYPE.RIGHT,r,void 0,.3);e.dock(this.confusionMatrix,t.DOCK_TYPE.RIGHT,i,void 0,.2),this.setRibbons()}getPmpoAppItems(){return{statsGrid:this.statGrid,rocCurve:this.rocCurve,confusionMatrix:this.confusionMatrix,controls:this.getInputForm(!1)}}getInputForm(e){const n=it.form([]);n.append(it.h2("Training data"));const r=this.numericCols.map(t=>t.name),i=()=>{try{this.fitAndUpdateViewers(this.table,t.DataFrame.fromColumns(o.value).columns,this.table.col(a.value),g.value,p.value,m.value,l.value)}catch(t){t instanceof ri?O.shell.warning(t.message):O.shell.error(t instanceof Error?t.message:Zn+": the platform issue.")}},o=it.input.columns("Descriptors",{table:this.table,nullable:!1,available:r,checked:r,tooltipText:"Descriptor columns used for model construction.",onValueChanged:t=>{null!=t&&(h=!1,d())}});n.append(o.root);const a=it.input.choice("Desirability",{nullable:!1,value:this.boolCols[0].name,items:this.boolCols.map(t=>t.name),tooltipText:"Desirability column.",onValueChanged:t=>{null!=t&&(h=!1,d())}});n.append(a.root);const s=it.h2("Settings");n.append(s),it.tooltip.bind(s,"Settings of the pMPO model.");const l=it.input.bool("σ correction",{value:!0,tooltipText:"Use the sigmoidal correction to the weighted Gaussian scores.",onValueChanged:t=>{h=!1,d()}});n.append(l.root);const c=this.table.rowCount<=1e4;let h=!1;const u=()=>si(this,void 0,void 0,function*(){if(!h){const e=yield this.getOptimalSettings(t.DataFrame.fromColumns(o.value).columns,this.table.col(a.value),l.value);e.success?(g.value=Math.max(e.pValTresh,dr),p.value=Math.max(e.r2Tresh,gr),m.value=Math.max(e.qCutoff,mr),h=!0):f.value=!1}i()}),d=()=>{f.value?u():i()},f=it.input.bool("Auto-tuning",{value:!1,tooltipText:"Automatically select optimal p-value, R², and q-cutoff by maximizing AUC.",onValueChanged:t=>si(this,void 0,void 0,function*(){y(!t),h||t&&(yield u())})});n.append(f.root);const g=it.input.float("p-value",{nullable:!1,min:dr,max:1,step:.001,value:ur,format:yr,tooltipText:"P-value threshold. Descriptors with p-values above this threshold are excluded.",onValueChanged:t=>{f.value||(h=!1,null!=t&&t>=dr&&t<=1&&i())}});n.append(g.root);const p=it.input.float("R²",{format:yr,nullable:!1,min:gr,value:fr,max:1,step:.01,tooltipText:"Squared correlation threshold. Descriptors with squared correlation above this threshold are considered highly correlated. Among them, the descriptor with the lower p-value is retained.",onValueChanged:t=>{f.value||(h=!1,null!=t&&t>=gr&&t<=1&&i())}});n.append(p.root);const m=it.input.float("q-cutoff",{format:yr,nullable:!1,min:mr,value:pr,max:1,step:.01,tooltipText:"Q-cutoff for the pMPO model computation.",onValueChanged:t=>{f.value||(h=!1,null!=t&&t>=mr&&t<=1&&i())}});n.append(m.root);const y=t=>{g.enabled=t,p.enabled=t,m.enabled=t};setTimeout(()=>{i(),c?f.value=!0:i()},10);const v=it.button("Save",()=>si(this,void 0,void 0,function*(){null!=this.params?function(t,e,n){jr(this,void 0,void 0,function*(){let r=e;const i=it.input.string("File",{value:r,nullable:!1,onValueChanged:t=>{r=t,d.getButton("Save").disabled=r.length<1||o.length<1}});let o="System:AppData/Chem/mpo";const a=it.input.string("Folder",{value:o,nullable:!1,onValueChanged:t=>{o=t,d.getButton("Save").disabled=r.length<1||o.length<1}}),s=()=>jr(this,void 0,void 0,function*(){const t=`${o}/${r}.json`;try{const e=JSON.stringify(l(),null,2);yield O.dapi.files.writeAsText(t,e),O.shell.info(`Saved to ${t}`)}catch(t){O.shell.error(`Failed to save: ${t instanceof Error?t.message:"the platform issue"}.`)}d.close()}),l=()=>u.value?Jr(t,n,i.value,h.value,!1):{type:"Probabilistic MPO Model",name:i.value,description:h.value,properties:Object.fromEntries(t)},c=it.input.string("Name",{value:e,nullable:!0}),h=it.input.textArea("Description",{value:" ",nullable:!0}),u=it.input.bool("Desirability Profile",{value:!0,tooltipText:"Save the model as an MPO Desirability Profile. If disabled, the model is saved in the pMPO format."}),d=it.dialog({title:"Save model"}).add(it.h2("Path")).add(a).add(i).add(it.h2("Model")).add(c).add(h).add(u).addButton("Save",()=>jr(this,void 0,void 0,function*(){(yield O.dapi.files.exists(`${o}/${r}.json`))?it.dialog({title:"Warning"}).add(it.label("Overwrite existing file?")).onOK(()=>jr(this,void 0,void 0,function*(){return yield s()})).show():yield s()})).show()})}(this.params,this.table.name,l.value):O.shell.warning("Failed to save pMPO model: null parameters.")}),"Save model as platform file.");e&&n.append(v);const _=it.div([n]);return _.classList.add("eda-pmpo-input-form"),{form:_,saveBtn:v}}getBoolCols(){const e=[];for(const n of this.table.columns)n.type===t.COLUMN_TYPE.BOOL&&n.stats.stdev>0&&e.push(n);return e}getValidNumericCols(){const t=[];for(const e of this.table.columns)e.isNumerical&&e.stats.missingValueCount<1&&e.stats.stdev>0&&t.push(e);return t}getOptimalSettings(e,n,r){return si(this,void 0,void 0,function*(){const i={pValTresh:0,r2Tresh:0,qCutoff:0,success:!1},o=e.names(),{desired:a,nonDesired:s}=Fr(this.table,n),l=new Map;o.forEach(t=>{l.set(t,Rr(a.col(t),s.col(t)))});const c=Kr(qr(l),ur);if(c.length<1)return i;const h=$r(e,c),u=t=>{const e=Xr(0,c,l,t[0],h),i=Qr(a,s,e,t[1]),o=li.predict(this.table,i,r,this.predictionName);return 1-Lr(n,o).auc},d=t.TaskBarProgressIndicator.create("Optimizing... ",{cancelable:!0});try{const t=yield ai(d,u,new Float32Array([fr,pr]),Pr,Nr,Or),e=!d.canceled;return d.close(),e?{pValTresh:ur,r2Tresh:t.optimalPoint[0],qCutoff:t.optimalPoint[1],success:!0}:i}catch(t){return d.close(),i}})}}class ci{constructor(t,e,n,r){this.sourceDf=t,this.drugName=e,this.desirabilityColName=n,this.smilesColName=r;const i=t.columns.toList().filter(t=>t.isNumerical).map(t=>t.name),{desired:o,nonDesired:a}=Fr(t,t.col(n));this.descriptorStats=new Map,i.forEach(t=>{this.descriptorStats.set(t,Rr(o.col(t),a.col(t)))}),this.desiredProbability=o.rowCount/t.rowCount}getGenerated(e){if(e<=1)throw new Error("Failed to generate pMPO data: sample count must be greater than 1.");let n;if(e<=this.sourceDf.rowCount){const r=t.BitSet.create(this.sourceDf.rowCount);for(let t=0;t<e;++t)r.set(t,!0);n=this.sourceDf.clone(r)}else n=this.getClonedSourceDfWithFloatNumericCols().append(this.getSyntheticTable(e-this.sourceDf.rowCount));for(const e of n.columns)if(e.type===t.COLUMN_TYPE.BOOL&&0===e.stats.stdev){let t=e.get(0);e.set(0,!t),t=e.get(1),e.set(1,!t)}return n}getSyntheticTable(e){const n=new Array(e);for(let t=0;t<e;++t)n[t]=Math.random()<this.desiredProbability;const r=[this.getDrugColumn(e),this.getSmilesColumn(e),t.Column.fromList(t.COLUMN_TYPE.BOOL,this.desirabilityColName,n)];return this.descriptorStats.forEach((i,o)=>{const a=new Float32Array(e);for(let t=0;t<e;++t)n[t]?a[t]=pn.normal.sample(i.desAvg,i.desStd):a[t]=pn.normal.sample(i.nonDesAvg,i.nonDesStd);r.push(t.Column.fromFloat32Array(o,a))}),t.DataFrame.fromColumns(r)}getDrugColumn(e){return t.Column.fromList(t.COLUMN_TYPE.STRING,this.drugName,Array.from({length:e},(t,e)=>`Synthetic drug ${e+1}`))}getSmilesColumn(e){return t.Column.fromList(t.COLUMN_TYPE.STRING,this.smilesColName,Array.from({length:e},()=>"C"))}getClonedSourceDfWithFloatNumericCols(){const e=[];this.sourceDf.columns.toList().forEach(n=>{n.isNumerical?e.push(n.clone().convertTo(t.COLUMN_TYPE.FLOAT)):e.push(n.clone())});const n=t.DataFrame.fromColumns(e);return n.name=this.sourceDf.name,n}}var hi=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const di="CNS",fi=["TPSA","TPSA_S","HBA","HBD","MW","nAtoms","cLogD_ACD_v15","mapKa","cLogP_Biobyte","mbpKa","cLogP_ACD_v15","ALogP98"],gi="Score",pi="Drug",mi="Sigmoidal",yi=[mi,"Gaussian"];function vi(t,e,n,r){if(0===n)return[];const i=t.length;if(e.length!==i)throw new Error("Sense array length must match number of dimensions");const o=new Uint32Array(n);for(let t=0;t<n;t++)o[t]=t;o.sort((n,r)=>e[0]===kr.MIN?t[0][n]-t[0][r]:t[0][r]-t[0][n]);const a=Array(n).fill(!0),s=[];null==r||r.forEach(t=>a[t]=!1);for(const n of o){if(!a[n])continue;let r=!1;for(const o of s){let a=!0,s=!1;for(let r=0;r<i;r++){const i=t[r][o],l=t[r][n];e[r]===kr.MIN?(i>l&&(a=!1),i<l&&(s=!0)):(i<l&&(a=!1),i>l&&(s=!0))}if(a&&s){r=!0;break}}r?a[n]=!1:s.push(n)}return a}x("Probabilistic MPO",()=>{yi.forEach(e=>{const n=e==mi;b("Correctness: "+e,()=>hi(void 0,void 0,void 0,function*(){let r=null,i=null,o=null,a=[],s=null,l=null,c=null,h=null;try{if(r=yield O.dapi.files.readCsv(Tr),i=yield O.dapi.files.readCsv(Mr),o=r.col(di),a=r.columns.byNames(fi),null==o)throw new Error;const u=li.fit(r,t.DataFrame.fromColumns(a).columns,o,ur,fr,pr),d=li.predict(r,u.params,n,gi);s=r.col(pi),l=i.col(pi),c=i.col(e),h=function(t,e,n,r){let i=0;const o=t.toList(),a=n.toList(),s=e.getRawData(),l=r.getRawData();return o.forEach((t,e)=>{const n=a.indexOf(t);if(n<0)throw new Error(`Failed to compare pMPO scores: the "${t}" drug is missing in the reference data.`);i=Math.max(i,Math.abs(s[e]-l[n]))}),i}(s,d,l,c)}catch(t){O.shell.error(t.message)}C(null!==r,!0,"Failed to load the source data: "+Tr),C(null!==i,!0,"Failed to load the scores data: "+Mr),C(null!==o,!0,"Inconsistent source data: no column "+di),C(a.length,fi.length,"Inconsistent source data: no enough of columns"),C(null!==s,!0,"Inconsistent source data: no column "+pi),C(null!==l,!0,"Inconsistent reference data: no column "+pi),C(null!==c,!0,"Inconsistent reference data: no column "+gi),C(null!==h,!0,"Failed to compare pMPO scores with the reference data"),C(h<1e-6,!0,"Max absolute deviation of pMPO scores exceeds the threshold (0.000001)")}),{timeout:1e4})}),b("Performance: 100K drugs, "+fi.length+" descriptors",()=>hi(void 0,void 0,void 0,function*(){let e=null,n=null,r=[];try{if(e=yield function(){return t=this,e=void 0,r=function*(){const t=yield O.dapi.files.readCsv(Tr);return new ci(t,"Drug","CNS","Smiles").getGenerated(1e5)},new((n=void 0)||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())});var t,e,n,r}(),n=e.col(di),r=e.columns.byNames(fi),null==n)throw new Error;const i=li.fit(e,t.DataFrame.fromColumns(r).columns,n,ur,fr,pr);li.predict(e,i.params,!0,gi)}catch(t){O.shell.error(t.message)}C(null!==e,!0,"Failed to load the source data: "+Tr),C(null!==n,!0,"Inconsistent source data: no column "+di),C(r.length,fi.length,"Inconsistent source data: no enough of columns")}),{timeout:1e4})});var _i=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const wi=5e3,bi=1e6,Ci="1M points, 2D";function xi(t,e,n=42){const r=[];let i=n;const o=()=>(i=(1664525*i+1013904223)%4294967296,i/4294967296);for(let n=0;n<e;n++){const e=new Float32Array(t);for(let r=0;r<t;r++)e[r]=100*o()+10*n;r.push(e)}return r}function Si(t,e){const n=[];for(let r=0;r<t;r++)"all-min"===e?n.push(kr.MIN):"all-max"===e?n.push(kr.MAX):n.push(r%2==0?kr.MIN:kr.MAX);return n}function Ai(t,e){const n=Math.floor(t*e),r=new Set,i=Math.floor(t/n);for(let t=0;t<n;t++)r.add(t*i);return r}function Ei(t,e){if(t.length!==e)throw new Error(`Invalid mask length: expected ${e}, got ${t.length}`);const n=t.filter(t=>t).length;if(0===n)throw new Error("No optimal points found");n===e&&O.shell.warning("All points are optimal - data may be degenerate")}x("Pareto optimization",()=>{b(`Performance: ${Ci}`,()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{e=vi(xi(bi,2),Si(2,"mixed"),bi),Ei(e,bi)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi}),b(`Performance: ${Ci}, all minimize`,()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{e=vi(xi(bi,2),Si(2,"all-min"),bi),Ei(e,bi)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi}),b(`Performance: ${Ci}, all maximize`,()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{e=vi(xi(bi,2),Si(2,"all-max"),bi),Ei(e,bi)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi}),b(`Performance: ${Ci} with 10% null indices`,()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{const t=xi(bi,2),n=Si(2,"mixed"),r=Ai(bi,.1);e=vi(t,n,bi,r),Ei(e,bi)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi}),b(`Performance: ${Ci} with 25% null indices`,()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{const t=xi(bi,2),n=Si(2,"mixed"),r=Ai(bi,.25);e=vi(t,n,bi,r),Ei(e,bi)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi}),b("Edge case: Empty dataset",()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{e=vi([new Float32Array(0),new Float32Array(0)],Si(2,"mixed"),0)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(e.length,0,"Empty dataset should return empty mask"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi}),b("Edge case: Single point",()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{e=vi([new Float32Array([1]),new Float32Array([2])],Si(2,"mixed"),1)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(e.length,1,"Single point dataset should return mask with one element"),C(e[0],!0,"Single point should be optimal"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi}),b("Edge case: All identical points",()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{const t=100;e=vi([new Float32Array(t).fill(5),new Float32Array(t).fill(10)],Si(2,"mixed"),t)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(e.length,100,"Should return mask with correct length"),C(e.filter(t=>t).length>0,!0,"At least some identical points should be optimal"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi})});var Ti=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const Mi=new t.Package;function Pi(e,n,r){return Ti(this,void 0,void 0,function*(){const d=yield function(t){var e,n,r;return i(this,void 0,void 0,function*(){const d=(null==t?void 0:t.nodeOptions)?t.nodeOptions.package:grok.functions.getCurrentCall().func.package;if(!d)throw new Error("Can't run tests outside of the package");const f=null===(e=d.packageOwner)||void 0===e?void 0:e.match(/<([^>]*)>/),g=f?f[1]:"";null!=d&&(yield A(d));const p=[];console.log("Running tests..."),console.log(t),null!=t||(t={}),null!==(n=(r=t).testContext)&&void 0!==n||(r.testContext=new _),grok.shell.clearLastError();const m=function(){const t=[];return console.log=(...e)=>{t.push(...e),s(...e)},console.info=(...e)=>{t.push(...e),l(...e)},console.warn=(...e)=>{t.push(...e),c(...e)},console.error=(...e)=>{t.push(...e),h(...e)},t}();yield function(t,e){var n,r,o,a,u,f;return i(this,void 0,void 0,function*(){try{let l=null!=(null==e?void 0:e.skipToCategory),c=!1;for(const[h,m]of Object.entries(t)){if(null===(n=e.exclude)||void 0===n?void 0:n.some(t=>h.startsWith(t)))continue;if(null!=(null==e?void 0:e.category)&&!h.toLowerCase().startsWith(null==e?void 0:e.category.toLowerCase().trim()))continue;if(l)if(c)l=!1;else{if(null==(null==e?void 0:e.skipToCategory)||h.toLowerCase().trim()!==(null==e?void 0:e.skipToCategory.toLowerCase().trim()))continue;c=!0}const t=null===(r=m.tests)||void 0===r?void 0:r.every(t=>{var n;return(null===(n=t.options)||void 0===n?void 0:n.skipReason)||null!=(null==e?void 0:e.test)&&e.test.toLowerCase()!==t.name.toLowerCase()});if(!t){const t=(null!==(o=m.tests)&&void 0!==o?o:[]).filter(t=>{var n;return(null===(n=t.options)||void 0===n?void 0:n.skipReason)||null!=(null==e?void 0:e.test)&&e.test.toLowerCase()!==t.name.toLowerCase()}).length;s(`Package testing: Started {{${h}}}${t>0?` skipped {{${t}}}`:""}`),m.beforeStatus=yield y(m.before,h)}let _,w=null!==(a=m.tests)&&void 0!==a?a:[];e.stressTest&&(w=w.filter(t=>{var e;return null===(e=t.options)||void 0===e?void 0:e.stressTest}),w=M(w)),(null!==(f=null===(u=e.tags)||void 0===u?void 0:u.length)&&void 0!==f?f:0)>0&&(w=w.filter(t=>{var n,r;return null===(r=null===(n=t.options)||void 0===n?void 0:n.tags)||void 0===r?void 0:r.some(t=>{var n;return(null!==(n=null==e?void 0:e.tags)&&void 0!==n?n:[]).includes(t)})})),m.beforeStatus?(_=Array.from(w.map(t=>({date:(new Date).toISOString(),category:h,name:t.name,success:!1,result:"before() failed",ms:0,skipped:!1,logs:"",owner:g,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing}))),_.forEach(t=>i(this,void 0,void 0,function*(){return yield grok.shell.reportTest("package",t)}))):_=yield v(m,e,l);const b=_.filter(t=>"skipped"!=t.result);if(t||(m.afterStatus=yield y(m.after,h)),m.afterStatus&&(s(`Package testing: Category after() {{${h}}} failed`),s(`Package testing: Result for {{${h}}} after: ${m.afterStatus}`),b.push({date:(new Date).toISOString(),category:h,name:"after",success:!1,result:m.afterStatus,ms:0,skipped:!1,logs:"",owner:g,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),m.beforeStatus&&(s(`Package testing: Category before() {{${h}}} failed`),s(`Package testing: Result for {{${h}}} before: ${m.beforeStatus}`),b.push({date:(new Date).toISOString(),category:h,name:"before",success:!1,result:m.beforeStatus,ms:0,skipped:!1,logs:"",owner:g,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),p.push(...b),e.returnOnFail&&b.some(t=>!t.success&&!t.skipped&&t.name!==e.skipToTest))break}}finally{console.log=s,console.info=l,console.warn=c,console.error=h}if(e.testContext.catchUnhandled&&!DG.Test.isInBenchmark){yield P(1e3);const t=yield grok.shell.lastError;if(null!=t){const e={logs:"",date:(new Date).toISOString(),category:"Unhandled exceptions",name:"Exception",result:null!=t?t:"",success:!t,ms:0,skipped:!1,owner:null!=g?g:"",package:d.name,widgetsDifference:0};s(`Package testing: Unhandled Exception: ${t}`),p.push(Object.assign(Object.assign({},e),{flaking:DG.Test.isReproducing&&!t})),e.package=d.name,yield grok.shell.reportTest("package",e)}}})}(u,t);for(let t of p)t.result=t.result.toString().replace(/"/g,"'"),null!=t.logs&&(t.logs=t.logs.toString().replace(/"/g,"'"));return p;function y(t,e){return i(this,void 0,void 0,function*(){let n;try{void 0!==t&&(yield N(()=>i(this,void 0,void 0,function*(){yield t()}),1e5,`before ${e}: timeout error`))}catch(t){n=yield E(t)}return n})}function v(t,e,n){var r,s,l,c,h,u,f,p,y,v,_,b,C,x,S,A,E,M;return i(this,void 0,void 0,function*(){let i=null!==(r=t.tests)&&void 0!==r?r:[];const P=[],N=w();if(t.clear){let r=n&&null!=e.skipToTest;for(let n=0;n<i.length;n++){i[n].options&&void 0===(null===(s=i[n].options)||void 0===s?void 0:s.benchmark)&&(i[n].options||(i[n].options={}),i[n].options.benchmark=null!==(l=t.benchmarks)&&void 0!==l&&l);let b=i[n];if(e.test&&e.test.toLowerCase()!==b.name.toLowerCase())continue;if(r){if(null==(null==e?void 0:e.skipToTest)||b.name.toLowerCase().trim()!==(null==e?void 0:e.skipToTest.toLowerCase().trim()))continue;r=!1}(null==b?void 0:b.options)&&(b.options.owner=null!==(f=null!==(u=null!==(h=null===(c=i[n].options)||void 0===c?void 0:c.owner)&&void 0!==h?h:null==t?void 0:t.owner)&&void 0!==u?u:g)&&void 0!==f?f:"");let C=yield T(b,null==e?void 0:e.test,m,DG.Test.isInBenchmark?null!==(y=null===(p=i[n].options)||void 0===p?void 0:p.benchmarkTimeout)&&void 0!==y?y:a:null!==(_=null===(v=i[n].options)||void 0===v?void 0:v.timeout)&&void 0!==_?_:o,d.name,e.verbose);if(C&&(P.push(Object.assign(Object.assign({},C),{widgetsDifference:w()-N})),e.returnOnFail&&e.skipToTest!==b.name&&!C.success&&!C.skipped))return P;e.nodeOptions||(grok.shell.closeAll(),DG.Balloon.closeAll())}}else{let r=n&&null!=e.skipToTest;for(let n=0;n<i.length;n++){let o=i[n];if(e.test&&e.test.toLowerCase()!==o.name.toLowerCase())continue;if(r){null!=(null==e?void 0:e.skipToTest)&&o.name.toLowerCase().trim()===(null==e?void 0:e.skipToTest.toLowerCase().trim())&&(r=!1);continue}(null==o?void 0:o.options)&&(o.options.owner=null!==(S=null!==(x=null!==(C=null===(b=i[n].options)||void 0===b?void 0:b.owner)&&void 0!==C?C:null==t?void 0:t.owner)&&void 0!==x?x:g)&&void 0!==S?S:"");let s=yield T(o,null==e?void 0:e.test,m,DG.Test.isInBenchmark?null!==(E=null===(A=i[n].options)||void 0===A?void 0:A.benchmarkTimeout)&&void 0!==E?E:a:null===(M=i[n].options)||void 0===M?void 0:M.timeout,d.name,e.verbose);if(s&&(P.push(Object.assign(Object.assign({},s),{widgetsDifference:w()-N})),e.returnOnFail&&e.skipToTest!==o.name&&!s.success&&!s.skipped))return P}}return P})}function w(){var t;if("undefined"!=typeof process)return 0;let e=-1;try{e=DG.Widget.getAll().length}catch(e){console.warn(null!==(t=e.message)&&void 0!==t?t:e)}return e}})}({category:e,test:n,testContext:r});return t.DataFrame.fromObjects(d)})}function Ni(){return Ti(this,void 0,void 0,function*(){yield A(Mi,Mi.getModule("package-test.js"))})}})(),eda_test=r})();
|
|
2
2
|
//# sourceMappingURL=package-test.js.map
|