@datagrok/eda 1.4.11 → 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 +15 -0
- package/CLAUDE.md +185 -0
- package/README.md +8 -0
- package/css/pmpo.css +35 -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 +45 -0
- package/files/drugs-props-test.csv +126 -0
- package/files/drugs-props-train-scores.csv +664 -0
- package/files/drugs-props-train.csv +664 -0
- package/package.json +9 -3
- package/src/anova/anova-tools.ts +1 -1
- package/src/anova/anova-ui.ts +1 -1
- package/src/package-api.ts +18 -0
- package/src/package-test.ts +4 -1
- package/src/package.g.ts +25 -0
- package/src/package.ts +55 -15
- package/src/pareto-optimization/pareto-computations.ts +6 -0
- package/src/pareto-optimization/utils.ts +6 -4
- 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 +218 -0
- package/src/probabilistic-scoring/pmpo-utils.ts +603 -0
- package/src/probabilistic-scoring/prob-scoring.ts +991 -0
- package/src/probabilistic-scoring/stat-tools.ts +303 -0
- package/src/softmax-classifier.ts +1 -1
- 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 +175 -209
- package/test-record-1.mp4 +0 -0
package/dist/package.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var eda;(()=>{var t={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}},934:function(t){t.exports=function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}function n(t){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}function r(t,e){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},r(t,e)}function i(t,e,n){return i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,n){var i=[null];i.push.apply(i,e);var o=new(Function.bind.apply(t,i));return n&&r(o,n.prototype),o},i.apply(null,arguments)}function o(t){var e="function"==typeof Map?new Map:void 0;return o=function(t){if(null===t||(o=t,-1===Function.toString.call(o).indexOf("[native code]")))return t;var o;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,a)}function a(){return i(t,arguments,n(this).constructor)}return a.prototype=Object.create(t.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),r(a,t)},o(t)}function a(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var s=function(){for(var t=arguments[0],e=1,n=arguments.length;e<n;e++)if(arguments[e])for(var r in arguments[e])t[r]=arguments[e][r];return t};function u(t,e,n,r){var i=t._nodes.get(e),o=null;return i?o="mixed"===r?i.out&&i.out[n]||i.undirected&&i.undirected[n]:"directed"===r?i.out&&i.out[n]:i.undirected&&i.undirected[n]:o}function c(e){return"object"===t(e)&&null!==e}function l(t){var e;for(e in t)return!1;return!0}function h(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function d(t,e,n){var r={enumerable:!0,configurable:!0};"function"==typeof n?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(t,e,r)}function f(t){return!(!c(t)||t.attributes&&!Array.isArray(t.attributes))}"function"==typeof Object.assign&&(s=Object.assign);var p,m={exports:{}},g="object"==typeof Reflect?Reflect:null,y=g&&"function"==typeof g.apply?g.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};p=g&&"function"==typeof g.ownKeys?g.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var v=Number.isNaN||function(t){return t!=t};function w(){w.init.call(this)}m.exports=w,m.exports.once=function(t,e){return new Promise(function(n,r){function i(n){t.removeListener(e,o),r(n)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),n([].slice.call(arguments))}P(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&P(t,"error",e,{once:!0})}(t,i)})},w.EventEmitter=w,w.prototype._events=void 0,w.prototype._eventsCount=0,w.prototype._maxListeners=void 0;var b=10;function A(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function C(t){return void 0===t._maxListeners?w.defaultMaxListeners:t._maxListeners}function E(t,e,n,r){var i,o,a,s;if(A(n),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),a=o[e]),void 0===a)a=o[e]=n,++t._eventsCount;else if("function"==typeof a?a=o[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(i=C(t))>0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return t}function S(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function N(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=S.bind(r);return i.listener=n,r.wrapFn=i,i}function _(t,e,n){var r=t._events;if(void 0===r)return[];var i=r[e];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(i):I(i,i.length)}function M(t){var e=this._events;if(void 0!==e){var n=e[t];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function I(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function P(t,e,n,r){if("function"==typeof t.on)r.once?t.once(e,n):t.on(e,n);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function i(o){r.once&&t.removeEventListener(e,i),n(o)})}}function L(t){if("function"!=typeof t)throw new Error("obliterator/iterator: expecting a function!");this.next=t}Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return b},set:function(t){if("number"!=typeof t||t<0||v(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");b=t}}),w.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},w.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||v(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},w.prototype.getMaxListeners=function(){return C(this)},w.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var r="error"===t,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var o;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var s=i[t];if(void 0===s)return!1;if("function"==typeof s)y(s,this,e);else{var u=s.length,c=I(s,u);for(n=0;n<u;++n)y(c[n],this,e)}return!0},w.prototype.addListener=function(t,e){return E(this,t,e,!1)},w.prototype.on=w.prototype.addListener,w.prototype.prependListener=function(t,e){return E(this,t,e,!0)},w.prototype.once=function(t,e){return A(e),this.on(t,N(this,t,e)),this},w.prototype.prependOnceListener=function(t,e){return A(e),this.prependListener(t,N(this,t,e)),this},w.prototype.removeListener=function(t,e){var n,r,i,o,a;if(A(e),void 0===(r=this._events))return this;if(void 0===(n=r[t]))return this;if(n===e||n.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===e||n[o].listener===e){a=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(n,i),1===n.length&&(r[t]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",t,a||e)}return this},w.prototype.off=w.prototype.removeListener,w.prototype.removeAllListeners=function(t){var e,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[t]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(void 0!==e)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this},w.prototype.listeners=function(t){return _(this,t,!0)},w.prototype.rawListeners=function(t){return _(this,t,!1)},w.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):M.call(t,e)},w.prototype.listenerCount=M,w.prototype.eventNames=function(){return this._eventsCount>0?p(this._events):[]},"undefined"!=typeof Symbol&&(L.prototype[Symbol.iterator]=function(){return this}),L.of=function(){var t=arguments,e=t.length,n=0;return new L(function(){return n>=e?{done:!0}:{done:!1,value:t[n++]}})},L.empty=function(){return new L(function(){return{done:!0}})},L.fromSequence=function(t){var e=0,n=t.length;return new L(function(){return e>=n?{done:!0}:{done:!1,value:t[e++]}})},L.is=function(t){return t instanceof L||"object"==typeof t&&null!==t&&"function"==typeof t.next};var T=L,O={};O.ARRAY_BUFFER_SUPPORT="undefined"!=typeof ArrayBuffer,O.SYMBOL_SUPPORT="undefined"!=typeof Symbol;var F=T,x=O,R=x.ARRAY_BUFFER_SUPPORT,D=x.SYMBOL_SUPPORT,k=function(t){var e=function(t){return"string"==typeof t||Array.isArray(t)||R&&ArrayBuffer.isView(t)?F.fromSequence(t):"object"!=typeof t||null===t?null:D&&"function"==typeof t[Symbol.iterator]?t[Symbol.iterator]():"function"==typeof t.next?t:null}(t);if(!e)throw new Error("obliterator: target is not iterable nor a valid iterator.");return e},U=k,G=function(t,e){for(var n,r=arguments.length>1?e:1/0,i=r!==1/0?new Array(r):[],o=0,a=U(t);;){if(o===r)return i;if((n=a.next()).done)return o!==e&&(i.length=o),i;i[o++]=n.value}},V=function(t){function n(e){var n;return(n=t.call(this)||this).name="GraphError",n.message=e,n}return e(n,t),n}(o(Error)),B=function(t){function n(e){var r;return(r=t.call(this,e)||this).name="InvalidArgumentsGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a(r),n.prototype.constructor),r}return e(n,t),n}(V),z=function(t){function n(e){var r;return(r=t.call(this,e)||this).name="NotFoundGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a(r),n.prototype.constructor),r}return e(n,t),n}(V),W=function(t){function n(e){var r;return(r=t.call(this,e)||this).name="UsageGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a(r),n.prototype.constructor),r}return e(n,t),n}(V);function j(t,e){this.key=t,this.attributes=e,this.clear()}function H(t,e){this.key=t,this.attributes=e,this.clear()}function K(t,e){this.key=t,this.attributes=e,this.clear()}function q(t,e,n,r,i){this.key=e,this.attributes=i,this.undirected=t,this.source=n,this.target=r}function Y(t,e,n,r,i,o,a){var s,u,c,l;if(r=""+r,0===n){if(!(s=t._nodes.get(r)))throw new z("Graph.".concat(e,': could not find the "').concat(r,'" node in the graph.'));c=i,l=o}else if(3===n){if(i=""+i,!(u=t._edges.get(i)))throw new z("Graph.".concat(e,': could not find the "').concat(i,'" edge in the graph.'));var h=u.source.key,d=u.target.key;if(r===h)s=u.target;else{if(r!==d)throw new z("Graph.".concat(e,': the "').concat(r,'" node is not attached to the "').concat(i,'" edge (').concat(h,", ").concat(d,")."));s=u.source}c=o,l=a}else{if(!(u=t._edges.get(r)))throw new z("Graph.".concat(e,': could not find the "').concat(r,'" edge in the graph.'));s=1===n?u.source:u.target,c=i,l=o}return[s,c,l]}j.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},H.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},K.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},q.prototype.attach=function(){var t="out",e="in";this.undirected&&(t=e="undirected");var n=this.source.key,r=this.target.key;this.source[t][r]=this,this.undirected&&n===r||(this.target[e][n]=this)},q.prototype.attachMulti=function(){var t="out",e="in",n=this.source.key,r=this.target.key;this.undirected&&(t=e="undirected");var i=this.source[t],o=i[r];if(void 0===o)return i[r]=this,void(this.undirected&&n===r||(this.target[e][n]=this));o.previous=this,this.next=o,i[r]=this,this.target[e][n]=this},q.prototype.detach=function(){var t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][e],delete this.target[r][t]},q.prototype.detachMulti=function(){var t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),void 0===this.previous?void 0===this.next?(delete this.source[n][e],delete this.target[r][t]):(this.next.previous=void 0,this.source[n][e]=this.next,this.target[r][t]=this.next):(this.previous.next=this.next,void 0!==this.next&&(this.next.previous=this.previous))};var $=[{name:function(t){return"get".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],s=o[1];return a.attributes[s]}}},{name:function(t){return"get".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){return Y(this,e,n,t,r)[0].attributes}}},{name:function(t){return"has".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],s=o[1];return a.attributes.hasOwnProperty(s)}}},{name:function(t){return"set".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i,o){var a=Y(this,e,n,t,r,i,o),s=a[0],u=a[1],c=a[2];return s.attributes[u]=c,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}},{name:function(t){return"update".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i,o){var a=Y(this,e,n,t,r,i,o),s=a[0],u=a[1],c=a[2];if("function"!=typeof c)throw new B("Graph.".concat(e,": updater should be a function."));var l=s.attributes,h=c(l[u]);return l[u]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}},{name:function(t){return"remove".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],s=o[1];return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}},{name:function(t){return"replace".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],s=o[1];if(!c(s))throw new B("Graph.".concat(e,": provided attributes are not a plain object."));return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}},{name:function(t){return"merge".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],u=o[1];if(!c(u))throw new B("Graph.".concat(e,": provided attributes are not a plain object."));return s(a.attributes,u),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:u}),this}}},{name:function(t){return"update".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],s=o[1];if("function"!=typeof s)throw new B("Graph.".concat(e,": provided updater is not a function."));return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}}],X=[{name:function(t){return"get".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return i.attributes[r]}}},{name:function(t){return"get".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var i=""+t,o=""+arguments[1];if(!(r=u(this,i,o,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(i,'" - "').concat(o,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(r=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return r.attributes}}},{name:function(t){return"has".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return i.attributes.hasOwnProperty(r)}}},{name:function(t){return"set".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var a=""+t,s=""+r;if(r=arguments[2],i=arguments[3],!(o=u(this,a,s,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(a,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(o=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return o.attributes[r]=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:r}),this}}},{name:function(t){return"update".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var a=""+t,s=""+r;if(r=arguments[2],i=arguments[3],!(o=u(this,a,s,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(a,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(o=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if("function"!=typeof i)throw new B("Graph.".concat(e,": updater should be a function."));return o.attributes[r]=i(o.attributes[r]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:r}),this}}},{name:function(t){return"remove".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return delete i.attributes[r],this.emit("edgeAttributesUpdated",{key:i.key,type:"remove",attributes:i.attributes,name:r}),this}}},{name:function(t){return"replace".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if(!c(r))throw new B("Graph.".concat(e,": provided attributes are not a plain object."));return i.attributes=r,this.emit("edgeAttributesUpdated",{key:i.key,type:"replace",attributes:i.attributes}),this}}},{name:function(t){return"merge".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if(!c(r))throw new B("Graph.".concat(e,": provided attributes are not a plain object."));return s(i.attributes,r),this.emit("edgeAttributesUpdated",{key:i.key,type:"merge",attributes:i.attributes,data:r}),this}}},{name:function(t){return"update".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if("function"!=typeof r)throw new B("Graph.".concat(e,": provided updater is not a function."));return i.attributes=r(i.attributes),this.emit("edgeAttributesUpdated",{key:i.key,type:"update",attributes:i.attributes}),this}}}],Q=T,J=k,Z=function(){var t=arguments,e=null,n=-1;return new Q(function(){for(var r=null;;){if(null===e){if(++n>=t.length)return{done:!0};e=J(t[n])}if(!0!==(r=e.next()).done)break;e=null}return r})},tt=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function et(t,e,n,r){var i=!1;for(var o in e)if(o!==r){var a=e[o];if(i=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),t&&i)return a.key}}function nt(t,e,n,r){var i,o,a,s=!1;for(var u in e)if(u!==r){i=e[u];do{if(o=i.source,a=i.target,s=n(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected),t&&s)return i.key;i=i.next}while(void 0!==i)}}function rt(t,e){var n,r=Object.keys(t),i=r.length,o=0;return new T(function(){do{if(n)n=n.next;else{if(o>=i)return{done:!0};var a=r[o++];if(a===e){n=void 0;continue}n=t[a]}}while(!n);return{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}}})}function it(t,e,n,r){var i=e[n];if(i){var o=i.source,a=i.target;return r(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected)&&t?i.key:void 0}}function ot(t,e,n,r){var i=e[n];if(i){var o=!1;do{if(o=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),t&&o)return i.key;i=i.next}while(void 0!==i)}}function at(t,e){var n=t[e];return void 0!==n.next?new T(function(){if(!n)return{done:!0};var t={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:t}}):T.of({edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected})}function st(t,e,n,r){if(0!==e.size)for(var i,o,a="mixed"!==n&&n!==e.type,s="undirected"===n,u=!1,c=e._edges.values();!0!==(i=c.next()).done;)if(o=i.value,!a||o.undirected===s){var l=o,h=l.key,d=l.attributes,f=l.source,p=l.target;if(u=r(h,d,f.key,p.key,f.attributes,p.attributes,o.undirected),t&&u)return h}}function ut(t,e,n,r,i,o){var a,s=e?nt:et;if("undirected"!==n){if("out"!==r&&(a=s(t,i.in,o),t&&a))return a;if("in"!==r&&(a=s(t,i.out,o,r?void 0:i.key),t&&a))return a}if("directed"!==n&&(a=s(t,i.undirected,o),t&&a))return a}function ct(t,e,n,r,i,o,a){var s,u=n?ot:it;if("undirected"!==e){if(void 0!==i.in&&"out"!==r&&(s=u(t,i.in,o,a),t&&s))return s;if(void 0!==i.out&&"in"!==r&&(r||i.key!==o)&&(s=u(t,i.out,o,a),t&&s))return s}if("directed"!==e&&void 0!==i.undirected&&(s=u(t,i.undirected,o,a),t&&s))return s}var lt=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function ht(){this.A=null,this.B=null}function dt(t,e,n,r,i){for(var o in r){var a=r[o],s=a.source,u=a.target,c=s===n?u:s;if(!e||!e.has(c.key)){var l=i(c.key,c.attributes);if(t&&l)return c.key}}}function ft(t,e,n,r,i){if("mixed"!==e){if("undirected"===e)return dt(t,null,r,r.undirected,i);if("string"==typeof n)return dt(t,null,r,r[n],i)}var o,a=new ht;if("undirected"!==e){if("out"!==n){if(o=dt(t,null,r,r.in,i),t&&o)return o;a.wrap(r.in)}if("in"!==n){if(o=dt(t,a,r,r.out,i),t&&o)return o;a.wrap(r.out)}}if("directed"!==e&&(o=dt(t,a,r,r.undirected,i),t&&o))return o}function pt(t,e,n){var r=Object.keys(n),i=r.length,o=0;return new T(function(){var a=null;do{if(o>=i)return t&&t.wrap(n),{done:!0};var s=n[r[o++]],u=s.source,c=s.target;a=u===e?c:u,t&&t.has(a.key)&&(a=null)}while(null===a);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}})}function mt(t,e,n,r,i){for(var o,a,s,u,c,l,h,d=r._nodes.values(),f=r.type;!0!==(o=d.next()).done;){var p=!1;if(a=o.value,"undirected"!==f)for(s in u=a.out){c=u[s];do{if(l=c.target,p=!0,h=i(a.key,l.key,a.attributes,l.attributes,c.key,c.attributes,c.undirected),t&&h)return c;c=c.next}while(c)}if("directed"!==f)for(s in u=a.undirected)if(!(e&&a.key>s)){c=u[s];do{if((l=c.target).key!==s&&(l=c.source),p=!0,h=i(a.key,l.key,a.attributes,l.attributes,c.key,c.attributes,c.undirected),t&&h)return c;c=c.next}while(c)}if(n&&!p&&(h=i(a.key,null,a.attributes,null,null,null,null),t&&h))return null}}function gt(t){if(!c(t))throw new B('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in t))throw new B("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new B("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function yt(t){if(!c(t))throw new B('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in t))throw new B("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new B("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new B("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&"boolean"!=typeof t.undirected)throw new B("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}ht.prototype.wrap=function(t){null===this.A?this.A=t:null===this.B&&(this.B=t)},ht.prototype.has=function(t){return null!==this.A&&t in this.A||null!==this.B&&t in this.B};var vt,wt=(vt=255&Math.floor(256*Math.random()),function(){return vt++}),bt=new Set(["directed","undirected","mixed"]),At=new Set(["domain","_events","_eventsCount","_maxListeners"]),Ct={allowSelfLoops:!0,multi:!1,type:"mixed"};function Et(t,e,n){var r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function St(t,e,n,r,i,o,a,s){if(!r&&"undirected"===t.type)throw new W("Graph.".concat(e,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(r&&"directed"===t.type)throw new W("Graph.".concat(e,": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead."));if(s&&!c(s))throw new B("Graph.".concat(e,': invalid attributes. Expecting an object but got "').concat(s,'"'));if(o=""+o,a=""+a,s=s||{},!t.allowSelfLoops&&o===a)throw new W("Graph.".concat(e,': source & target are the same ("').concat(o,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var u=t._nodes.get(o),l=t._nodes.get(a);if(!u)throw new z("Graph.".concat(e,': source node "').concat(o,'" not found.'));if(!l)throw new z("Graph.".concat(e,': target node "').concat(a,'" not found.'));var h={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new W("Graph.".concat(e,': the "').concat(i,'" edge already exists in the graph.'));if(!t.multi&&(r?void 0!==u.undirected[a]:void 0!==u.out[a]))throw new W("Graph.".concat(e,': an edge linking "').concat(o,'" to "').concat(a,"\" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option."));var d=new q(r,i,u,l,s);t._edges.set(i,d);var f=o===a;return r?(u.undirectedDegree++,l.undirectedDegree++,f&&(u.undirectedLoops++,t._undirectedSelfLoopCount++)):(u.outDegree++,l.inDegree++,f&&(u.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),r?t._undirectedSize++:t._directedSize++,h.key=i,t.emit("edgeAdded",h),i}function Nt(t,e,n,r,i,o,a,u,l){if(!r&&"undirected"===t.type)throw new W("Graph.".concat(e,": you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead."));if(r&&"directed"===t.type)throw new W("Graph.".concat(e,": you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead."));if(u)if(l){if("function"!=typeof u)throw new B("Graph.".concat(e,': invalid updater function. Expecting a function but got "').concat(u,'"'))}else if(!c(u))throw new B("Graph.".concat(e,': invalid attributes. Expecting an object but got "').concat(u,'"'));var h;if(o=""+o,a=""+a,l&&(h=u,u=void 0),!t.allowSelfLoops&&o===a)throw new W("Graph.".concat(e,': source & target are the same ("').concat(o,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var d,f,p=t._nodes.get(o),m=t._nodes.get(a);if(!n&&(d=t._edges.get(i))){if(!(d.source.key===o&&d.target.key===a||r&&d.source.key===a&&d.target.key===o))throw new W("Graph.".concat(e,': inconsistency detected when attempting to merge the "').concat(i,'" edge with "').concat(o,'" source & "').concat(a,'" target vs. ("').concat(d.source.key,'", "').concat(d.target.key,'").'));f=d}if(f||t.multi||!p||(f=r?p.undirected[a]:p.out[a]),f){var g=[f.key,!1,!1,!1];if(l?!h:!u)return g;if(l){var y=f.attributes;f.attributes=h(y),t.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else s(f.attributes,u),t.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:u});return g}u=u||{},l&&h&&(u=h(u));var v={key:null,undirected:r,source:o,target:a,attributes:u};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new W("Graph.".concat(e,': the "').concat(i,'" edge already exists in the graph.'));var w=!1,b=!1;p||(p=Et(t,o,{}),w=!0,o===a&&(m=p,b=!0)),m||(m=Et(t,a,{}),b=!0),d=new q(r,i,p,m,u),t._edges.set(i,d);var A=o===a;return r?(p.undirectedDegree++,m.undirectedDegree++,A&&(p.undirectedLoops++,t._undirectedSelfLoopCount++)):(p.outDegree++,m.inDegree++,A&&(p.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),r?t._undirectedSize++:t._directedSize++,v.key=i,t.emit("edgeAdded",v),[i,!0,w,b]}function _t(t,e){t._edges.delete(e.key);var n=e.source,r=e.target,i=e.attributes,o=e.undirected,a=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,t._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),o?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:i,source:n.key,target:r.key,undirected:o})}var Mt=function(n){function r(t){var e;if(e=n.call(this)||this,"boolean"!=typeof(t=s({},Ct,t)).multi)throw new B("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \"".concat(t.multi,'".'));if(!bt.has(t.type))throw new B('Graph.constructor: invalid \'type\' option. Should be one of "mixed", "directed" or "undirected" but got "'.concat(t.type,'".'));if("boolean"!=typeof t.allowSelfLoops)throw new B("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \"".concat(t.allowSelfLoops,'".'));var r="mixed"===t.type?j:"directed"===t.type?H:K;h(a(e),"NodeDataClass",r);var i="geid_"+wt()+"_",o=0;return h(a(e),"_attributes",{}),h(a(e),"_nodes",new Map),h(a(e),"_edges",new Map),h(a(e),"_directedSize",0),h(a(e),"_undirectedSize",0),h(a(e),"_directedSelfLoopCount",0),h(a(e),"_undirectedSelfLoopCount",0),h(a(e),"_edgeKeyGenerator",function(){var t;do{t=i+o++}while(e._edges.has(t));return t}),h(a(e),"_options",t),At.forEach(function(t){return h(a(e),t,e[t])}),d(a(e),"order",function(){return e._nodes.size}),d(a(e),"size",function(){return e._edges.size}),d(a(e),"directedSize",function(){return e._directedSize}),d(a(e),"undirectedSize",function(){return e._undirectedSize}),d(a(e),"selfLoopCount",function(){return e._directedSelfLoopCount+e._undirectedSelfLoopCount}),d(a(e),"directedSelfLoopCount",function(){return e._directedSelfLoopCount}),d(a(e),"undirectedSelfLoopCount",function(){return e._undirectedSelfLoopCount}),d(a(e),"multi",e._options.multi),d(a(e),"type",e._options.type),d(a(e),"allowSelfLoops",e._options.allowSelfLoops),d(a(e),"implementation",function(){return"graphology"}),e}e(r,n);var i=r.prototype;return i._resetInstanceCounters=function(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0},i.hasNode=function(t){return this._nodes.has(""+t)},i.hasDirectedEdge=function(t,e){if("undirected"===this.type)return!1;if(1===arguments.length){var n=""+t,r=this._edges.get(n);return!!r&&!r.undirected}if(2===arguments.length){t=""+t,e=""+e;var i=this._nodes.get(t);return!!i&&i.out.hasOwnProperty(e)}throw new B("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},i.hasUndirectedEdge=function(t,e){if("directed"===this.type)return!1;if(1===arguments.length){var n=""+t,r=this._edges.get(n);return!!r&&r.undirected}if(2===arguments.length){t=""+t,e=""+e;var i=this._nodes.get(t);return!!i&&i.undirected.hasOwnProperty(e)}throw new B("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},i.hasEdge=function(t,e){if(1===arguments.length){var n=""+t;return this._edges.has(n)}if(2===arguments.length){t=""+t,e=""+e;var r=this._nodes.get(t);return!!r&&(void 0!==r.out&&r.out.hasOwnProperty(e)||void 0!==r.undirected&&r.undirected.hasOwnProperty(e))}throw new B("Graph.hasEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},i.directedEdge=function(t,e){if("undirected"!==this.type){if(t=""+t,e=""+e,this.multi)throw new W("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");var n=this._nodes.get(t);if(!n)throw new z('Graph.directedEdge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new z('Graph.directedEdge: could not find the "'.concat(e,'" target node in the graph.'));var r=n.out&&n.out[e]||void 0;return r?r.key:void 0}},i.undirectedEdge=function(t,e){if("directed"!==this.type){if(t=""+t,e=""+e,this.multi)throw new W("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");var n=this._nodes.get(t);if(!n)throw new z('Graph.undirectedEdge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new z('Graph.undirectedEdge: could not find the "'.concat(e,'" target node in the graph.'));var r=n.undirected&&n.undirected[e]||void 0;return r?r.key:void 0}},i.edge=function(t,e){if(this.multi)throw new W("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.edge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new z('Graph.edge: could not find the "'.concat(e,'" target node in the graph.'));var r=n.out&&n.out[e]||n.undirected&&n.undirected[e]||void 0;if(r)return r.key},i.areDirectedNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.areDirectedNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&(e in n.in||e in n.out)},i.areOutNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.areOutNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.out},i.areInNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.areInNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.in},i.areUndirectedNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.areUndirectedNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"directed"!==this.type&&e in n.undirected},i.areNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.areNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&(e in n.in||e in n.out)||"directed"!==this.type&&e in n.undirected},i.areInboundNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.areInboundNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.in||"directed"!==this.type&&e in n.undirected},i.areOutboundNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.areOutboundNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.out||"directed"!==this.type&&e in n.undirected},i.inDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.inDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree},i.outDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.outDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.outDegree},i.directedDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.directedDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree+e.outDegree},i.undirectedDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.undirectedDegree: could not find the "'.concat(t,'" node in the graph.'));return"directed"===this.type?0:e.undirectedDegree},i.inboundDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.inboundDegree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.inDegree),n},i.outboundDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.outboundDegree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.outDegree),n},i.degree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.degree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.inDegree+e.outDegree),n},i.inDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.inDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree-e.directedLoops},i.outDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.outDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.outDegree-e.directedLoops},i.directedDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.directedDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree+e.outDegree-2*e.directedLoops},i.undirectedDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.undirectedDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"directed"===this.type?0:e.undirectedDegree-2*e.undirectedLoops},i.inboundDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.inboundDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,r=0;return"directed"!==this.type&&(n+=e.undirectedDegree,r+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.inDegree,r+=e.directedLoops),n-r},i.outboundDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.outboundDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,r=0;return"directed"!==this.type&&(n+=e.undirectedDegree,r+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.outDegree,r+=e.directedLoops),n-r},i.degreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.degreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,r=0;return"directed"!==this.type&&(n+=e.undirectedDegree,r+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.inDegree+e.outDegree,r+=2*e.directedLoops),n-r},i.source=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new z('Graph.source: could not find the "'.concat(t,'" edge in the graph.'));return e.source.key},i.target=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new z('Graph.target: could not find the "'.concat(t,'" edge in the graph.'));return e.target.key},i.extremities=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new z('Graph.extremities: could not find the "'.concat(t,'" edge in the graph.'));return[e.source.key,e.target.key]},i.opposite=function(t,e){t=""+t,e=""+e;var n=this._edges.get(e);if(!n)throw new z('Graph.opposite: could not find the "'.concat(e,'" edge in the graph.'));var r=n.source.key,i=n.target.key;if(t===r)return i;if(t===i)return r;throw new z('Graph.opposite: the "'.concat(t,'" node is not attached to the "').concat(e,'" edge (').concat(r,", ").concat(i,")."))},i.hasExtremity=function(t,e){t=""+t,e=""+e;var n=this._edges.get(t);if(!n)throw new z('Graph.hasExtremity: could not find the "'.concat(t,'" edge in the graph.'));return n.source.key===e||n.target.key===e},i.isUndirected=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new z('Graph.isUndirected: could not find the "'.concat(t,'" edge in the graph.'));return e.undirected},i.isDirected=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new z('Graph.isDirected: could not find the "'.concat(t,'" edge in the graph.'));return!e.undirected},i.isSelfLoop=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new z('Graph.isSelfLoop: could not find the "'.concat(t,'" edge in the graph.'));return e.source===e.target},i.addNode=function(t,e){var n=function(t,e,n){if(n&&!c(n))throw new B('Graph.addNode: invalid attributes. Expecting an object but got "'.concat(n,'"'));if(e=""+e,n=n||{},t._nodes.has(e))throw new W('Graph.addNode: the "'.concat(e,'" node already exist in the graph.'));var r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}(this,t,e);return n.key},i.mergeNode=function(t,e){if(e&&!c(e))throw new B('Graph.mergeNode: invalid attributes. Expecting an object but got "'.concat(e,'"'));t=""+t,e=e||{};var n=this._nodes.get(t);return n?(e&&(s(n.attributes,e),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:n.attributes,data:e})),[t,!1]):(n=new this.NodeDataClass(t,e),this._nodes.set(t,n),this.emit("nodeAdded",{key:t,attributes:e}),[t,!0])},i.updateNode=function(t,e){if(e&&"function"!=typeof e)throw new B('Graph.updateNode: invalid updater function. Expecting a function but got "'.concat(e,'"'));t=""+t;var n=this._nodes.get(t);if(n){if(e){var r=n.attributes;n.attributes=e(r),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:n.attributes})}return[t,!1]}var i=e?e({}):{};return n=new this.NodeDataClass(t,i),this._nodes.set(t,n),this.emit("nodeAdded",{key:t,attributes:i}),[t,!0]},i.dropNode=function(t){t=""+t;var e,n=this._nodes.get(t);if(!n)throw new z('Graph.dropNode: could not find the "'.concat(t,'" node in the graph.'));if("undirected"!==this.type){for(var r in n.out){e=n.out[r];do{_t(this,e),e=e.next}while(e)}for(var i in n.in){e=n.in[i];do{_t(this,e),e=e.next}while(e)}}if("directed"!==this.type)for(var o in n.undirected){e=n.undirected[o];do{_t(this,e),e=e.next}while(e)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})},i.dropEdge=function(t){var e;if(arguments.length>1){var n=""+arguments[0],r=""+arguments[1];if(!(e=u(this,n,r,this.type)))throw new z('Graph.dropEdge: could not find the "'.concat(n,'" -> "').concat(r,'" edge in the graph.'))}else if(t=""+t,!(e=this._edges.get(t)))throw new z('Graph.dropEdge: could not find the "'.concat(t,'" edge in the graph.'));return _t(this,e),this},i.dropDirectedEdge=function(t,e){if(arguments.length<2)throw new W("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new W("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=u(this,t=""+t,e=""+e,"directed");if(!n)throw new z('Graph.dropDirectedEdge: could not find a "'.concat(t,'" -> "').concat(e,'" edge in the graph.'));return _t(this,n),this},i.dropUndirectedEdge=function(t,e){if(arguments.length<2)throw new W("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new W("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=u(this,t,e,"undirected");if(!n)throw new z('Graph.dropUndirectedEdge: could not find a "'.concat(t,'" -> "').concat(e,'" edge in the graph.'));return _t(this,n),this},i.clear=function(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")},i.clearEdges=function(){for(var t,e=this._nodes.values();!0!==(t=e.next()).done;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")},i.getAttribute=function(t){return this._attributes[t]},i.getAttributes=function(){return this._attributes},i.hasAttribute=function(t){return this._attributes.hasOwnProperty(t)},i.setAttribute=function(t,e){return this._attributes[t]=e,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this},i.updateAttribute=function(t,e){if("function"!=typeof e)throw new B("Graph.updateAttribute: updater should be a function.");var n=this._attributes[t];return this._attributes[t]=e(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this},i.removeAttribute=function(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this},i.replaceAttributes=function(t){if(!c(t))throw new B("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},i.mergeAttributes=function(t){if(!c(t))throw new B("Graph.mergeAttributes: provided attributes are not a plain object.");return s(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this},i.updateAttributes=function(t){if("function"!=typeof t)throw new B("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this},i.updateEachNodeAttributes=function(t,e){if("function"!=typeof t)throw new B("Graph.updateEachNodeAttributes: expecting an updater function.");if(e&&!f(e))throw new B("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,r,i=this._nodes.values();!0!==(n=i.next()).done;)(r=n.value).attributes=t(r.key,r.attributes);this.emit("eachNodeAttributesUpdated",{hints:e||null})},i.updateEachEdgeAttributes=function(t,e){if("function"!=typeof t)throw new B("Graph.updateEachEdgeAttributes: expecting an updater function.");if(e&&!f(e))throw new B("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,r,i,o,a=this._edges.values();!0!==(n=a.next()).done;)i=(r=n.value).source,o=r.target,r.attributes=t(r.key,r.attributes,i.key,o.key,i.attributes,o.attributes,r.undirected);this.emit("eachEdgeAttributesUpdated",{hints:e||null})},i.forEachAdjacencyEntry=function(t){if("function"!=typeof t)throw new B("Graph.forEachAdjacencyEntry: expecting a callback.");mt(!1,!1,!1,this,t)},i.forEachAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new B("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");mt(!1,!1,!0,this,t)},i.forEachAssymetricAdjacencyEntry=function(t){if("function"!=typeof t)throw new B("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");mt(!1,!0,!1,this,t)},i.forEachAssymetricAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new B("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");mt(!1,!0,!0,this,t)},i.nodes=function(){return"function"==typeof Array.from?Array.from(this._nodes.keys()):G(this._nodes.keys(),this._nodes.size)},i.forEachNode=function(t){if("function"!=typeof t)throw new B("Graph.forEachNode: expecting a callback.");for(var e,n,r=this._nodes.values();!0!==(e=r.next()).done;)t((n=e.value).key,n.attributes)},i.findNode=function(t){if("function"!=typeof t)throw new B("Graph.findNode: expecting a callback.");for(var e,n,r=this._nodes.values();!0!==(e=r.next()).done;)if(t((n=e.value).key,n.attributes))return n.key},i.mapNodes=function(t){if("function"!=typeof t)throw new B("Graph.mapNode: expecting a callback.");for(var e,n,r=this._nodes.values(),i=new Array(this.order),o=0;!0!==(e=r.next()).done;)n=e.value,i[o++]=t(n.key,n.attributes);return i},i.someNode=function(t){if("function"!=typeof t)throw new B("Graph.someNode: expecting a callback.");for(var e,n,r=this._nodes.values();!0!==(e=r.next()).done;)if(t((n=e.value).key,n.attributes))return!0;return!1},i.everyNode=function(t){if("function"!=typeof t)throw new B("Graph.everyNode: expecting a callback.");for(var e,n,r=this._nodes.values();!0!==(e=r.next()).done;)if(!t((n=e.value).key,n.attributes))return!1;return!0},i.filterNodes=function(t){if("function"!=typeof t)throw new B("Graph.filterNodes: expecting a callback.");for(var e,n,r=this._nodes.values(),i=[];!0!==(e=r.next()).done;)t((n=e.value).key,n.attributes)&&i.push(n.key);return i},i.reduceNodes=function(t,e){if("function"!=typeof t)throw new B("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new B("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");for(var n,r,i=e,o=this._nodes.values();!0!==(n=o.next()).done;)i=t(i,(r=n.value).key,r.attributes);return i},i.nodeEntries=function(){var t=this._nodes.values();return new T(function(){var e=t.next();if(e.done)return e;var n=e.value;return{value:{node:n.key,attributes:n.attributes},done:!1}})},i.export=function(){var t=this,e=new Array(this._nodes.size),n=0;this._nodes.forEach(function(t,r){e[n++]=function(t,e){var n={key:t};return l(e.attributes)||(n.attributes=s({},e.attributes)),n}(r,t)});var r=new Array(this._edges.size);return n=0,this._edges.forEach(function(e,i){r[n++]=function(t,e,n){var r={key:e,source:n.source.key,target:n.target.key};return l(n.attributes)||(r.attributes=s({},n.attributes)),"mixed"===t&&n.undirected&&(r.undirected=!0),r}(t.type,i,e)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:r}},i.import=function(t){var e,n,i,o,a,s=this,u=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t instanceof r)return t.forEachNode(function(t,e){u?s.mergeNode(t,e):s.addNode(t,e)}),t.forEachEdge(function(t,e,n,r,i,o,a){u?a?s.mergeUndirectedEdgeWithKey(t,n,r,e):s.mergeDirectedEdgeWithKey(t,n,r,e):a?s.addUndirectedEdgeWithKey(t,n,r,e):s.addDirectedEdgeWithKey(t,n,r,e)}),this;if(!c(t))throw new B("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!c(t.attributes))throw new B("Graph.import: invalid attributes. Expecting a plain object.");u?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}if(t.nodes){if(i=t.nodes,!Array.isArray(i))throw new B("Graph.import: invalid nodes. Expecting an array.");for(e=0,n=i.length;e<n;e++){gt(o=i[e]);var l=o,h=l.key,d=l.attributes;u?this.mergeNode(h,d):this.addNode(h,d)}}if(t.edges){var f=!1;if("undirected"===this.type&&(f=!0),i=t.edges,!Array.isArray(i))throw new B("Graph.import: invalid edges. Expecting an array.");for(e=0,n=i.length;e<n;e++){yt(a=i[e]);var p=a,m=p.source,g=p.target,y=p.attributes,v=p.undirected,w=void 0===v?f:v;"key"in a?(u?w?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:w?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey).call(this,a.key,m,g,y):(u?w?this.mergeUndirectedEdge:this.mergeDirectedEdge:w?this.addUndirectedEdge:this.addDirectedEdge).call(this,m,g,y)}}return this},i.nullCopy=function(t){var e=new r(s({},this._options,t));return e.replaceAttributes(s({},this.getAttributes())),e},i.emptyCopy=function(t){var e=this.nullCopy(t);return this._nodes.forEach(function(t,n){var r=s({},t.attributes);t=new e.NodeDataClass(n,r),e._nodes.set(n,t)}),e},i.copy=function(t){if("string"==typeof(t=t||{}).type&&t.type!==this.type&&"mixed"!==t.type)throw new W('Graph.copy: cannot create an incompatible copy from "'.concat(this.type,'" type to "').concat(t.type,'" because this would mean losing information about the current graph.'));if("boolean"==typeof t.multi&&t.multi!==this.multi&&!0!==t.multi)throw new W("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if("boolean"==typeof t.allowSelfLoops&&t.allowSelfLoops!==this.allowSelfLoops&&!0!==t.allowSelfLoops)throw new W("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");for(var e,n,r=this.emptyCopy(t),i=this._edges.values();!0!==(e=i.next()).done;)St(r,"copy",!1,(n=e.value).undirected,n.key,n.source.key,n.target.key,s({},n.attributes));return r},i.toJSON=function(){return this.export()},i.toString=function(){return"[object Graph]"},i.inspect=function(){var e=this,n={};this._nodes.forEach(function(t,e){n[e]=t.attributes});var r={},i={};this._edges.forEach(function(t,n){var o,a=t.undirected?"--":"->",s="",u=t.source.key,c=t.target.key;t.undirected&&u>c&&(o=u,u=c,c=o);var l="(".concat(u,")").concat(a,"(").concat(c,")");n.startsWith("geid_")?e.multi&&(void 0===i[l]?i[l]=0:i[l]++,s+="".concat(i[l],". ")):s+="[".concat(n,"]: "),r[s+=l]=t.attributes});var o={};for(var a in this)this.hasOwnProperty(a)&&!At.has(a)&&"function"!=typeof this[a]&&"symbol"!==t(a)&&(o[a]=this[a]);return o.attributes=this._attributes,o.nodes=n,o.edges=r,h(o,"constructor",this.constructor),o},r}(m.exports.EventEmitter);"undefined"!=typeof Symbol&&(Mt.prototype[Symbol.for("nodejs.util.inspect.custom")]=Mt.prototype.inspect),[{name:function(t){return"".concat(t,"Edge")},generateKey:!0},{name:function(t){return"".concat(t,"DirectedEdge")},generateKey:!0,type:"directed"},{name:function(t){return"".concat(t,"UndirectedEdge")},generateKey:!0,type:"undirected"},{name:function(t){return"".concat(t,"EdgeWithKey")}},{name:function(t){return"".concat(t,"DirectedEdgeWithKey")},type:"directed"},{name:function(t){return"".concat(t,"UndirectedEdgeWithKey")},type:"undirected"}].forEach(function(t){["add","merge","update"].forEach(function(e){var n=t.name(e),r="add"===e?St:Nt;t.generateKey?Mt.prototype[n]=function(i,o,a){return r(this,n,!0,"undirected"===(t.type||this.type),null,i,o,a,"update"===e)}:Mt.prototype[n]=function(i,o,a,s){return r(this,n,!1,"undirected"===(t.type||this.type),i,o,a,s,"update"===e)}})}),function(t){$.forEach(function(e){var n=e.name,r=e.attacher;r(t,n("Node"),0),r(t,n("Source"),1),r(t,n("Target"),2),r(t,n("Opposite"),3)})}(Mt),function(t){X.forEach(function(e){var n=e.name,r=e.attacher;r(t,n("Edge"),"mixed"),r(t,n("DirectedEdge"),"directed"),r(t,n("UndirectedEdge"),"undirected")})}(Mt),function(t){tt.forEach(function(e){!function(t,e){var n=e.name,r=e.type,i=e.direction;t.prototype[n]=function(t,e){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return[];if(!arguments.length)return function(t,e){if(0===t.size)return[];if("mixed"===e||e===t.type)return"function"==typeof Array.from?Array.from(t._edges.keys()):G(t._edges.keys(),t._edges.size);for(var n,r,i="undirected"===e?t.undirectedSize:t.directedSize,o=new Array(i),a="undirected"===e,s=t._edges.values(),u=0;!0!==(n=s.next()).done;)(r=n.value).undirected===a&&(o[u++]=r.key);return o}(this,r);if(1===arguments.length){t=""+t;var o=this._nodes.get(t);if(void 0===o)throw new z("Graph.".concat(n,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n,r){var i=[];return ut(!1,t,e,n,r,function(t){i.push(t)}),i}(this.multi,"mixed"===r?this.type:r,i,o)}if(2===arguments.length){t=""+t,e=""+e;var a=this._nodes.get(t);if(!a)throw new z("Graph.".concat(n,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new z("Graph.".concat(n,': could not find the "').concat(e,'" target node in the graph.'));return function(t,e,n,r,i){var o=[];return ct(!1,t,e,n,r,i,function(t){o.push(t)}),o}(r,this.multi,i,a,e)}throw new B("Graph.".concat(n,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(t,e,n){if("mixed"===r||"mixed"===this.type||r===this.type){if(1===arguments.length)return st(!1,this,r,n=t);if(2===arguments.length){t=""+t,n=e;var a=this._nodes.get(t);if(void 0===a)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return ut(!1,this.multi,"mixed"===r?this.type:r,i,a,n)}if(3===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new z("Graph.".concat(o,': could not find the "').concat(e,'" target node in the graph.'));return ct(!1,r,this.multi,i,s,e,n)}throw new B("Graph.".concat(o,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))}};var a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(){var t,e=Array.prototype.slice.call(arguments),n=e.pop();if(0===e.length){var i=0;"directed"!==r&&(i+=this.undirectedSize),"undirected"!==r&&(i+=this.directedSize),t=new Array(i);var a=0;e.push(function(e,r,i,o,s,u,c){t[a++]=n(e,r,i,o,s,u,c)})}else t=[],e.push(function(e,r,i,o,a,s,u){t.push(n(e,r,i,o,a,s,u))});return this[o].apply(this,e),t};var s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),n=[];return t.push(function(t,r,i,o,a,s,u){e(t,r,i,o,a,s,u)&&n.push(t)}),this[o].apply(this,t),n};var u="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[u]=function(){var t,e,n=Array.prototype.slice.call(arguments);if(n.length<2||n.length>4)throw new B("Graph.".concat(u,": invalid number of arguments (expecting 2, 3 or 4 and got ").concat(n.length,")."));if("function"==typeof n[n.length-1]&&"function"!=typeof n[n.length-2])throw new B("Graph.".concat(u,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));2===n.length?(t=n[0],e=n[1],n=[]):3===n.length?(t=n[1],e=n[2],n=[n[0]]):4===n.length&&(t=n[2],e=n[3],n=[n[0],n[1]]);var r=e;return n.push(function(e,n,i,o,a,s,u){r=t(r,e,n,i,o,a,s,u)}),this[o].apply(this,n),r}}(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o="find"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(t,e,n){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return!1;if(1===arguments.length)return st(!0,this,r,n=t);if(2===arguments.length){t=""+t,n=e;var a=this._nodes.get(t);if(void 0===a)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return ut(!0,this.multi,"mixed"===r?this.type:r,i,a,n)}if(3===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new z("Graph.".concat(o,': could not find the "').concat(e,'" target node in the graph.'));return ct(!0,r,this.multi,i,s,e,n)}throw new B("Graph.".concat(o,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))};var a="some"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[a]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop();return t.push(function(t,n,r,i,o,a,s){return e(t,n,r,i,o,a,s)}),!!this[o].apply(this,t)};var s="every"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[s]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop();return t.push(function(t,n,r,i,o,a,s){return!e(t,n,r,i,o,a,s)}),!this[o].apply(this,t)}}(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(t,e){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return T.empty();if(!arguments.length)return function(t,e){if(0===t.size)return T.empty();var n="mixed"!==e&&e!==t.type,r="undirected"===e,i=t._edges.values();return new T(function(){for(var t,e;;){if((t=i.next()).done)return t;if(e=t.value,!n||e.undirected===r)break}return{value:{edge:e.key,attributes:e.attributes,source:e.source.key,target:e.target.key,sourceAttributes:e.source.attributes,targetAttributes:e.target.attributes,undirected:e.undirected},done:!1}})}(this,r);if(1===arguments.length){t=""+t;var n=this._nodes.get(t);if(!n)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){var r=T.empty();return"undirected"!==t&&("out"!==e&&void 0!==n.in&&(r=Z(r,rt(n.in))),"in"!==e&&void 0!==n.out&&(r=Z(r,rt(n.out,e?void 0:n.key)))),"directed"!==t&&void 0!==n.undirected&&(r=Z(r,rt(n.undirected))),r}(r,i,n)}if(2===arguments.length){t=""+t,e=""+e;var a=this._nodes.get(t);if(!a)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new z("Graph.".concat(o,': could not find the "').concat(e,'" target node in the graph.'));return function(t,e,n,r){var i=T.empty();return"undirected"!==t&&(void 0!==n.in&&"out"!==e&&r in n.in&&(i=Z(i,at(n.in,r))),void 0!==n.out&&"in"!==e&&r in n.out&&(e||n.key!==r)&&(i=Z(i,at(n.out,r)))),"directed"!==t&&void 0!==n.undirected&&r in n.undirected&&(i=Z(i,at(n.undirected,r))),i}(r,i,a,e)}throw new B("Graph.".concat(o,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(t,e)})}(Mt),function(t){lt.forEach(function(e){(function(t,e){var n=e.name,r=e.type,i=e.direction;t.prototype[n]=function(t){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return[];t=""+t;var e=this._nodes.get(t);if(void 0===e)throw new z("Graph.".concat(n,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){if("mixed"!==t){if("undirected"===t)return Object.keys(n.undirected);if("string"==typeof e)return Object.keys(n[e])}var r=[];return ft(!1,t,e,n,function(t){r.push(t)}),r}("mixed"===r?this.type:r,i,e)}})(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(t,e){if("mixed"===r||"mixed"===this.type||r===this.type){t=""+t;var n=this._nodes.get(t);if(void 0===n)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));ft(!1,"mixed"===r?this.type:r,i,n,e)}};var a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(t,e){var n=[];return this[o](t,function(t,r){n.push(e(t,r))}),n};var s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(t,e){var n=[];return this[o](t,function(t,r){e(t,r)&&n.push(t)}),n};var u="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[u]=function(t,e,n){if(arguments.length<3)throw new B("Graph.".concat(u,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));var r=n;return this[o](t,function(t,n){r=e(r,t,n)}),r}}(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o=n[0].toUpperCase()+n.slice(1,-1),a="find"+o;t.prototype[a]=function(t,e){if("mixed"===r||"mixed"===this.type||r===this.type){t=""+t;var n=this._nodes.get(t);if(void 0===n)throw new z("Graph.".concat(a,': could not find the "').concat(t,'" node in the graph.'));return ft(!0,"mixed"===r?this.type:r,i,n,e)}};var s="some"+o;t.prototype[s]=function(t,e){return!!this[a](t,e)};var u="every"+o;t.prototype[u]=function(t,e){return!this[a](t,function(t,n){return!e(t,n)})}}(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(t){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return T.empty();t=""+t;var e=this._nodes.get(t);if(void 0===e)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){if("mixed"!==t){if("undirected"===t)return pt(null,n,n.undirected);if("string"==typeof e)return pt(null,n,n[e])}var r=T.empty(),i=new ht;return"undirected"!==t&&("out"!==e&&(r=Z(r,pt(i,n,n.in))),"in"!==e&&(r=Z(r,pt(i,n,n.out)))),"directed"!==t&&(r=Z(r,pt(i,n,n.undirected))),r}("mixed"===r?this.type:r,i,e)}}(t,e)})}(Mt);var It=function(t){function n(e){var n=s({type:"directed"},e);if("multi"in n&&!1!==n.multi)throw new B("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("directed"!==n.type)throw new B('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Mt),Pt=function(t){function n(e){var n=s({type:"undirected"},e);if("multi"in n&&!1!==n.multi)throw new B("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("undirected"!==n.type)throw new B('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Mt),Lt=function(t){function n(e){var n=s({multi:!0},e);if("multi"in n&&!0!==n.multi)throw new B("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return t.call(this,n)||this}return e(n,t),n}(Mt),Tt=function(t){function n(e){var n=s({type:"directed",multi:!0},e);if("multi"in n&&!0!==n.multi)throw new B("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("directed"!==n.type)throw new B('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Mt),Ot=function(t){function n(e){var n=s({type:"undirected",multi:!0},e);if("multi"in n&&!0!==n.multi)throw new B("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("undirected"!==n.type)throw new B('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Mt);function Ft(t){t.from=function(e,n){var r=s({},e.options,n),i=new t(r);return i.import(e),i}}return Ft(Mt),Ft(It),Ft(Pt),Ft(Lt),Ft(Tt),Ft(Ot),Mt.Graph=Mt,Mt.DirectedGraph=It,Mt.UndirectedGraph=Pt,Mt.MultiGraph=Lt,Mt.MultiDirectedGraph=Tt,Mt.MultiUndirectedGraph=Ot,Mt.InvalidArgumentsGraphError=B,Mt.NotFoundGraphError=z,Mt.UsageGraphError=W,Mt}()},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),u=new Array(o),c=0;c<i;c++)for(var l=Math.max(0,c-a);l<=Math.min(o,c+a+1);l++)if(!s[c]&&!u[l]&&t[c]===e[l]){++r,s[c]=u[l]=!0;break}if(0===r)return 0;var h=0,d=0;for(c=0;c<i;c++)if(s[c]){for(;!u[d];)d++;t.charAt(c)!==e.charAt(d++)&&h++}return(r/i+r/o+(r-(h/=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}},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))}}},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")}},1736:t=>{t.exports=function(t){return null!==t&&"object"==typeof t&&"function"==typeof t.addUndirectedEdgeWithKey&&"function"==typeof t.dropNode&&"boolean"==typeof t.multi}},1782:(t,e)=>{e.assign=function(t){t=t||{};var e,n,r,i=Array.prototype.slice.call(arguments).slice(1);for(e=0,r=i.length;e<r;e++)if(i[e])for(n in i[e])t[n]=i[e][n];return t},e.validateSettings=function(t){return"linLogMode"in t&&"boolean"!=typeof t.linLogMode?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&"boolean"!=typeof t.outboundAttractionDistribution?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&"boolean"!=typeof t.adjustSizes?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&"number"!=typeof t.edgeWeightInfluence?{message:"the `edgeWeightInfluence` setting should be a number."}:!("scalingRatio"in t)||"number"==typeof t.scalingRatio&&t.scalingRatio>=0?"strongGravityMode"in t&&"boolean"!=typeof t.strongGravityMode?{message:"the `strongGravityMode` setting should be a boolean."}:!("gravity"in t)||"number"==typeof t.gravity&&t.gravity>=0?"slowDown"in t&&!("number"==typeof t.slowDown||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&"boolean"!=typeof t.barnesHutOptimize?{message:"the `barnesHutOptimize` setting should be a boolean."}:!("barnesHutTheta"in t)||"number"==typeof t.barnesHutTheta&&t.barnesHutTheta>=0?null:{message:"the `barnesHutTheta` setting should be a number >= 0."}:{message:"the `gravity` setting should be a number >= 0."}:{message:"the `scalingRatio` setting should be a number >= 0."}},e.graphToByteArrays=function(t,e){var n,r=t.order,i=t.size,o={},a=new Float32Array(10*r),s=new Float32Array(3*i);return n=0,t.forEachNode(function(t,e){o[t]=n,a[n]=e.x,a[n+1]=e.y,a[n+2]=0,a[n+3]=0,a[n+4]=0,a[n+5]=0,a[n+6]=1,a[n+7]=1,a[n+8]=e.size||1,a[n+9]=e.fixed?1:0,n+=10}),n=0,t.forEachEdge(function(t,r,i,u,c,l,h){var d=o[i],f=o[u],p=e(t,r,i,u,c,l,h);a[d+6]+=p,a[f+6]+=p,s[n]=d,s[n+1]=f,s[n+2]=p,n+=3}),{nodes:a,edges:s}},e.assignLayoutChanges=function(t,e,n){var r=0;t.updateEachNodeAttributes(function(t,i){return i.x=e[r],i.y=e[r+1],r+=10,n?n(t,i):i})},e.readGraphPositions=function(t,e){var n=0;t.forEachNode(function(t,r){e[n]=r.x,e[n+1]=r.y,n+=10})},e.collectLayoutChanges=function(t,e,n){for(var r=t.nodes(),i={},o=0,a=0,s=e.length;o<s;o+=10){if(n){var u=Object.assign({},t.getNodeAttributes(r[a]));u.x=e[o],u.y=e[o+1],u=n(r[a],u),i[r[a]]={x:u.x,y:u.y}}else i[r[a]]={x:e[o],y:e[o+1]};a++}return i},e.createWorker=function(t){var e=window.URL||window.webkitURL,n=t.toString(),r=e.createObjectURL(new Blob(["("+n+").call(this);"],{type:"text/javascript"})),i=new Worker(r);return e.revokeObjectURL(r),i}},2561:t=>{var e=10;t.exports=function(t,n,r){var i,o,a,s,u,c,l,h,d,f,p,m,g,y,v,w,b,A,C,E,S,N,_,M=n.length,I=r.length,P=t.adjustSizes,L=t.barnesHutTheta*t.barnesHutTheta,T=[];for(a=0;a<M;a+=e)n[a+4]=n[a+2],n[a+5]=n[a+3],n[a+2]=0,n[a+3]=0;if(t.outboundAttractionDistribution){for(p=0,a=0;a<M;a+=e)p+=n[a+6];p/=M/e}if(t.barnesHutOptimize){var O,F,x,R=1/0,D=-1/0,k=1/0,U=-1/0;for(a=0;a<M;a+=e)R=Math.min(R,n[a+0]),D=Math.max(D,n[a+0]),k=Math.min(k,n[a+1]),U=Math.max(U,n[a+1]);var G=D-R,V=U-k;for(G>V?U=(k-=(G-V)/2)+G:D=(R-=(V-G)/2)+V,T[0]=-1,T[1]=(R+D)/2,T[2]=(k+U)/2,T[3]=Math.max(D-R,U-k),T[4]=-1,T[5]=-1,T[6]=0,T[7]=0,T[8]=0,i=1,a=0;a<M;a+=e)for(o=0,x=3;;){if(!(T[o+5]>=0)){if(T[o+0]<0){T[o+0]=a;break}if(T[o+5]=9*i,h=T[o+3]/2,T[(d=T[o+5])+0]=-1,T[d+1]=T[o+1]-h,T[d+2]=T[o+2]-h,T[d+3]=h,T[d+4]=d+9,T[d+5]=-1,T[d+6]=0,T[d+7]=0,T[d+8]=0,T[(d+=9)+0]=-1,T[d+1]=T[o+1]-h,T[d+2]=T[o+2]+h,T[d+3]=h,T[d+4]=d+9,T[d+5]=-1,T[d+6]=0,T[d+7]=0,T[d+8]=0,T[(d+=9)+0]=-1,T[d+1]=T[o+1]+h,T[d+2]=T[o+2]-h,T[d+3]=h,T[d+4]=d+9,T[d+5]=-1,T[d+6]=0,T[d+7]=0,T[d+8]=0,T[(d+=9)+0]=-1,T[d+1]=T[o+1]+h,T[d+2]=T[o+2]+h,T[d+3]=h,T[d+4]=T[o+4],T[d+5]=-1,T[d+6]=0,T[d+7]=0,T[d+8]=0,i+=4,O=n[T[o+0]+0]<T[o+1]?n[T[o+0]+1]<T[o+2]?T[o+5]:T[o+5]+9:n[T[o+0]+1]<T[o+2]?T[o+5]+18:T[o+5]+27,T[o+6]=n[T[o+0]+6],T[o+7]=n[T[o+0]+0],T[o+8]=n[T[o+0]+1],T[O+0]=T[o+0],T[o+0]=-1,O===(F=n[a+0]<T[o+1]?n[a+1]<T[o+2]?T[o+5]:T[o+5]+9:n[a+1]<T[o+2]?T[o+5]+18:T[o+5]+27)){if(x--){o=O;continue}x=3;break}T[F+0]=a;break}O=n[a+0]<T[o+1]?n[a+1]<T[o+2]?T[o+5]:T[o+5]+9:n[a+1]<T[o+2]?T[o+5]+18:T[o+5]+27,T[o+7]=(T[o+7]*T[o+6]+n[a+0]*n[a+6])/(T[o+6]+n[a+6]),T[o+8]=(T[o+8]*T[o+6]+n[a+1]*n[a+6])/(T[o+6]+n[a+6]),T[o+6]+=n[a+6],o=O}}if(t.barnesHutOptimize){for(m=t.scalingRatio,a=0;a<M;a+=e)for(o=0;;)if(T[o+5]>=0){if(w=Math.pow(n[a+0]-T[o+7],2)+Math.pow(n[a+1]-T[o+8],2),4*(f=T[o+3])*f/w<L){if(g=n[a+0]-T[o+7],y=n[a+1]-T[o+8],!0===P?w>0?(b=m*n[a+6]*T[o+6]/w,n[a+2]+=g*b,n[a+3]+=y*b):w<0&&(b=-m*n[a+6]*T[o+6]/Math.sqrt(w),n[a+2]+=g*b,n[a+3]+=y*b):w>0&&(b=m*n[a+6]*T[o+6]/w,n[a+2]+=g*b,n[a+3]+=y*b),(o=T[o+4])<0)break;continue}o=T[o+5]}else if((c=T[o+0])>=0&&c!==a&&(w=(g=n[a+0]-n[c+0])*g+(y=n[a+1]-n[c+1])*y,!0===P?w>0?(b=m*n[a+6]*n[c+6]/w,n[a+2]+=g*b,n[a+3]+=y*b):w<0&&(b=-m*n[a+6]*n[c+6]/Math.sqrt(w),n[a+2]+=g*b,n[a+3]+=y*b):w>0&&(b=m*n[a+6]*n[c+6]/w,n[a+2]+=g*b,n[a+3]+=y*b)),(o=T[o+4])<0)break}else for(m=t.scalingRatio,s=0;s<M;s+=e)for(u=0;u<s;u+=e)g=n[s+0]-n[u+0],y=n[s+1]-n[u+1],!0===P?(w=Math.sqrt(g*g+y*y)-n[s+8]-n[u+8])>0?(b=m*n[s+6]*n[u+6]/w/w,n[s+2]+=g*b,n[s+3]+=y*b,n[u+2]-=g*b,n[u+3]-=y*b):w<0&&(b=100*m*n[s+6]*n[u+6],n[s+2]+=g*b,n[s+3]+=y*b,n[u+2]-=g*b,n[u+3]-=y*b):(w=Math.sqrt(g*g+y*y))>0&&(b=m*n[s+6]*n[u+6]/w/w,n[s+2]+=g*b,n[s+3]+=y*b,n[u+2]-=g*b,n[u+3]-=y*b);for(d=t.gravity/t.scalingRatio,m=t.scalingRatio,a=0;a<M;a+=e)b=0,g=n[a+0],y=n[a+1],w=Math.sqrt(Math.pow(g,2)+Math.pow(y,2)),t.strongGravityMode?w>0&&(b=m*n[a+6]*d):w>0&&(b=m*n[a+6]*d/w),n[a+2]-=g*b,n[a+3]-=y*b;for(m=1*(t.outboundAttractionDistribution?p:1),l=0;l<I;l+=3)s=r[l+0],u=r[l+1],h=r[l+2],v=Math.pow(h,t.edgeWeightInfluence),g=n[s+0]-n[u+0],y=n[s+1]-n[u+1],!0===P?(w=Math.sqrt(g*g+y*y)-n[s+8]-n[u+8],t.linLogMode?t.outboundAttractionDistribution?w>0&&(b=-m*v*Math.log(1+w)/w/n[s+6]):w>0&&(b=-m*v*Math.log(1+w)/w):t.outboundAttractionDistribution?w>0&&(b=-m*v/n[s+6]):w>0&&(b=-m*v)):(w=Math.sqrt(Math.pow(g,2)+Math.pow(y,2)),t.linLogMode?t.outboundAttractionDistribution?w>0&&(b=-m*v*Math.log(1+w)/w/n[s+6]):w>0&&(b=-m*v*Math.log(1+w)/w):t.outboundAttractionDistribution?(w=1,b=-m*v/n[s+6]):(w=1,b=-m*v)),w>0&&(n[s+2]+=g*b,n[s+3]+=y*b,n[u+2]-=g*b,n[u+3]-=y*b);if(!0===P)for(a=0;a<M;a+=e)1!==n[a+9]&&((A=Math.sqrt(Math.pow(n[a+2],2)+Math.pow(n[a+3],2)))>10&&(n[a+2]=10*n[a+2]/A,n[a+3]=10*n[a+3]/A),C=n[a+6]*Math.sqrt((n[a+4]-n[a+2])*(n[a+4]-n[a+2])+(n[a+5]-n[a+3])*(n[a+5]-n[a+3])),E=Math.sqrt((n[a+4]+n[a+2])*(n[a+4]+n[a+2])+(n[a+5]+n[a+3])*(n[a+5]+n[a+3]))/2,S=.1*Math.log(1+E)/(1+Math.sqrt(C)),N=n[a+0]+n[a+2]*(S/t.slowDown),n[a+0]=N,_=n[a+1]+n[a+3]*(S/t.slowDown),n[a+1]=_);else for(a=0;a<M;a+=e)1!==n[a+9]&&(C=n[a+6]*Math.sqrt((n[a+4]-n[a+2])*(n[a+4]-n[a+2])+(n[a+5]-n[a+3])*(n[a+5]-n[a+3])),E=Math.sqrt((n[a+4]+n[a+2])*(n[a+4]+n[a+2])+(n[a+5]+n[a+3])*(n[a+5]+n[a+3]))/2,S=n[a+7]*Math.log(1+E)/(1+Math.sqrt(C)),n[a+7]=Math.min(1,Math.sqrt(S*(Math.pow(n[a+2],2)+Math.pow(n[a+3],2))/(1+Math.sqrt(C)))),N=n[a+0]+n[a+2]*(S/t.slowDown),n[a+0]=N,_=n[a+1]+n[a+3]*(S/t.slowDown),n[a+1]=_);return{}}},5056:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},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 u=t[s],c=r.base?u[0]+r.base:u[0],l=o[c]||0,h="".concat(c," ").concat(l);o[c]=l+1;var d=n(h),f={css:u[1],media:u[2],sourceMap:u[3],supports:u[4],layer:u[5]};if(-1!==d)e[d].references++,e[d].updater(f);else{var p=i(f,r);r.byIndex=s,e.splice(s,0,{identifier:h,updater:p,references:1})}a.push(h)}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 u=r(t,i),c=0;c<o.length;c++){var l=n(o[c]);0===e[l].references&&(e[l].updater(),e.splice(l,1))}o=u}}},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,u="function"==typeof importScripts,c=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(s||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&&(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 l,h,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&&(l=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&I("no native wasm support detected");var f,p,m,g=!1;function y(){var t=h.buffer;i.HEAP8=f=new Int8Array(t),i.HEAP16=new Int16Array(t),i.HEAP32=new Int32Array(t),i.HEAPU8=p=new Uint8Array(t),i.HEAPU16=new Uint16Array(t),i.HEAPU32=m=new Uint32Array(t),i.HEAPF32=new Float32Array(t),i.HEAPF64=new Float64Array(t)}var v=[],w=[],b=[];function A(t){v.unshift(t)}function C(t){b.unshift(t)}var E,S,N=0,_=null,M=null;function I(t){i.onAbort&&i.onAbort(t),d(t="Aborted("+t+")"),g=!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 L(t){try{if(t==E&&l)return new Uint8Array(l);if(o)return o(t);throw"both async and sync fetching of the wasm failed"}catch(t){I(t)}}function T(t,e,n){return function(t){return l||!s&&!u||"function"!=typeof fetch?Promise.resolve().then(function(){return L(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 L(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),I(t)})}function O(t){for(;t.length>0;)t.shift()(i)}function F(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){m[this.ptr+4>>2]=t},this.get_type=function(){return m[this.ptr+4>>2]},this.set_destructor=function(t){m[this.ptr+8>>2]=t},this.get_destructor=function(){return m[this.ptr+8>>2]},this.set_caught=function(t){t=t?1:0,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){m[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return m[this.ptr+16>>2]},this.get_exception_ptr=function(){if(W(this.get_type()))return m[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function x(t){var e=h.buffer;try{return h.grow(t-e.byteLength+65535>>>16),y(),1}catch(t){}}function R(t){return i["_"+t]}P(E="wasmDbscan.wasm")||(S=E,E=i.locateFile?i.locateFile(S,c):c+S);var D="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=z(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,p,e,n)}(t,n,e),n}(t)),e},array:t=>{var e,n,r=z(t.length);return e=t,n=r,f.set(e,n),r}},a=R(t),s=[],u=0;if(r)for(var c=0;c<r.length;c++){var l=o[n[c]];l?(0===u&&(u=V()),s[c]=l(r[c])):s[c]=r[c]}var h=a.apply(null,s);return function(t){return 0!==u&&B(u),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&&D)return D.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 u=63&t[e++];if((a=224==(240&a)?(15&a)<<12|s<<6|u:(7&a)<<18|s<<12|u<<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}(p,n,r):"":"boolean"===e?Boolean(t):t;var n,r}(t)}(h)}var U,G={__cxa_throw:function(t,e,n){throw new F(t).init(e,n),t},abort:function(){I("")},emscripten_memcpy_big:function(t,e,n){p.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e=p.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),x(Math.min(n,r(Math.max(t,o),65536))))return!0}return!1}},V=(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,h=i.asm.memory,y(),i.asm.__indirect_function_table,n=i.asm.__wasm_call_ctors,w.unshift(n),function(){if(N--,i.monitorRunDependencies&&i.monitorRunDependencies(N),0==N&&(null!==_&&(clearInterval(_),_=null),M)){var t=M;M=null,t()}}(),r}if(N++,i.monitorRunDependencies&&i.monitorRunDependencies(N),i.instantiateWasm)try{return i.instantiateWasm(a,s)}catch(t){d("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=l,e=E,r=a,o=function(t){s(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||P(e)||"function"!=typeof fetch?T(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"),T(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(V=i.asm.stackSave).apply(null,arguments)}),B=function(){return(B=i.asm.stackRestore).apply(null,arguments)},z=function(){return(z=i.asm.stackAlloc).apply(null,arguments)},W=function(){return(W=i.asm.__cxa_is_pointer_type).apply(null,arguments)};function j(){function t(){U||(U=!0,i.calledRun=!0,g||(O(w),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());O(b)}()))}N>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)A(i.preRun.shift());O(v)}(),N>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?R(t):function(){return k(t,e,n,arguments)}},M=function t(){U||j(),U||(M=t)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return j(),t.ready});"object"==typeof exports?t.exports=i:"function"==typeof define&&n.amdO?define([],function(){return i}):"object"==typeof exports&&(exports.exportCppDbscanLib=i)},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 u=this[s][0];null!=u&&(a[u]=!0)}for(var c=0;c<t.length;c++){var l=[].concat(t[c]);r&&a[l[0]]||(void 0!==o&&(void 0===l[5]||(l[1]="@layer".concat(l[5].length>0?" ".concat(l[5]):""," {").concat(l[1],"}")),l[5]=o),n&&(l[2]?(l[1]="@media ".concat(l[2]," {").concat(l[1],"}"),l[2]=n):l[2]=n),i&&(l[4]?(l[1]="@supports (".concat(l[4],") {").concat(l[1],"}"),l[4]=i):l[4]="".concat(i)),e.push(l))}},e}},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 u(t){return"number"==typeof t&&t-t===0}function c(){return new c._init(arguments)}function l(){return 0}function h(){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(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:o,isArray:a,isFunction:s,isNumber:u,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,u;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)),u=0;u<o;u++)s[r][u]=e(t[r][u],r,u);return 1===s.length?s[0]:s},c.cumreduce=function(t,e,n){var r,i,o,s,u;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]),u=1;u<o;u++)s[r][u]=e(s[r][u-1],t[r][u]);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 u(e)||(e=t),c.create(t,e,l)},c.ones=function(t,e){return u(e)||(e=t),c.create(t,e,h)},c.rand=function(t,e){return u(e)||(e=t),c.create(t,e,c._random_fn)},c.identity=function(t,e){return u(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,l)},c.seq=function(t,e,n,r){s(r)||(r=!1);var i,a=[],u=o(t,e),c=(e*u-t*u)/((n-1)*u),l=t;for(i=0;l<=e&&i<n;l=(t*u+c*u*++i)/u)a.push(r?r(l,i):l);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 u((n=n||{}).row)?u(n.col)?e[n.row][n.col]:t(c.rowa(e,n.row),(r=n.col||{}).start,r.end,r.step):u(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(u(r.row)){if(u(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(u(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 l=r.col;return a.forEach(function(t,e){n[t][l]=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 u(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[u=t[e]]?i[u]++:(i[u]=1,n.push(u));var o=n.sort(r),a={},s=1;for(e=0;e<o.length;e++){var u,c=i[u=o[e]],l=(s+(s+c-1))/2;a[u]=l,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,u=[];for(e=0;e<n;e++)i[e]===i[e+1]?o++:(o>a?(u=[i[e]],a=o,s=0):o===a&&(u.push(i[e]),s++),o=1);return 0===s?u[0]:u},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,u,c,l,h,d=t.slice().sort(r),f=[n.length],p=t.length;for(void 0===o&&(o=3/8),void 0===a&&(a=3/8),s=0;s<n.length;s++)c=p*(u=n[s])+(o+u*(1-o-a)),l=e.floor(i(c,1,p-1)),h=i(c-l,0,1),f[s]=(1-h)*d[l-1]+h*d[l];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,u=[];for(i=0;i<r;i++)u[i]=0;for(i=0;i<s;i++)u[e.min(e.floor((n[i]-o)/a),r-1)]+=1;return u},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,u=0;u<a;u++)s+=e.pow((n[u]-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,u=this;if(n(r)&&(i=r,r=!1),i)return setTimeout(function(){i.call(u,o[e].call(u,r))}),this;if(this.length>1){for(u=!0===r?this:this.transpose();s<u.length;s++)a[s]=t[e](u[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,u=this;if(n(r)&&(i=r,r=!1),i)return setTimeout(function(){i.call(u,o[e].call(u,r))}),this;if(this.length>1){for("sumrow"!==e&&(u=!0===r?this:this.transpose());s<u.length;s++)a[s]=t[e](u[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,u=Array.prototype.slice.call(arguments);if(n(u[u.length-1])){r=u[u.length-1];var c=u.slice(0,u.length-1);return setTimeout(function(){r.call(s,o[e].apply(s,c))}),this}r=void 0;var l=function(n){return t[e].apply(s,[n].concat(u))};if(this.length>1){for(s=s.transpose();a<s.length;a++)i[a]=l(s[a]);return i}return l(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,u,c=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=t,u=0,1==t||2==t)return 0;for(t<=7&&(n=t+(u=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<=u;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],u=!1,c=0,l=0,h=0,d=t;if(t>171.6243769536076)return 1/0;if(d<=0){if(!(o=d%1+36e-17))return 1/0;u=(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)h=(h+a[n])*r,l=l*r+s[n];if(o=h/l+1,i<d)o/=i;else if(i>d)for(n=0;n<c;++n)o*=d,d++;return u&&(o=u/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,u=s,c=r+1-n,l=1/1e-30,h=1/c,d=h,f=1,p=-~(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<=p;f++)s+=u*=r/++a;return s*e.exp(-r+n*e.log(r)-o)}for(;f<=p;f++)d*=(h=1/(h=(i=-f*(f-n))*h+(c+=2)))*(l=c+i/l);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,u=1e-30,c=1,l=n+r,h=n+1,d=n-1,f=1,p=1-l*t/h;for(e.abs(p)<u&&(p=u),s=p=1/p;c<=100&&(p=1+(o=c*(r-c)*t/((d+(i=2*c))*(n+i)))*p,e.abs(p)<u&&(p=u),f=1+o/f,e.abs(f)<u&&(f=u),s*=(p=1/p)*f,p=1+(o=-(n+c)*(l+c)*t/((n+i)*(h+i)))*p,e.abs(p)<u&&(p=u),f=1+o/f,e.abs(f)<u&&(f=u),s*=a=(p=1/p)*f,!(e.abs(a-1)<3e-7));c++);return s},t.gammapinv=function(n,r){var i,o,a,s,u,c,l=0,h=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?(u=e.log(h),c=e.exp(h*(u-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));l<12;l++){if(i<=0)return 0;if((i-=o=(a=(t.lowRegGamma(r,i)-n)/(o=r>1?c*e.exp(-(i-h)+h*(e.log(i)-u)):e.exp(-i+h*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,u=!1,c=0,l=0;for(t<0&&(t=-t,u=!0),r=4*(n=2/(2+t))-2;s>0;s--)i=c,c=r*c-l+a[s],l=i;return o=n*e.exp(-t*t+.5*(a[0]+r*c)-l),u?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,u,c,l,h,d,f,p,m=r-1,g=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,l=(2.30753+.27061*(u=e.sqrt(-2*e.log(s))))/(1+u*(.99229+.04481*u))-u,n<.5&&(l=-l),h=(l*l-3)/6,d=2/(1/(2*r-1)+1/(2*i-1)),f=l*e.sqrt(h+d)/d-(1/(2*i-1)-1/(2*r-1))*(h+5/6-2/(3*d)),l=r/(r+i*e.exp(2*f))):(o=e.log(r/(r+i)),a=e.log(i/(r+i)),l=n<(u=e.exp(r*o)/r)/(f=u+(c=e.exp(i*a)/i))?e.pow(r*f*n,1/r):1-e.pow(i*f*(1-n),1/i)),p=-t.gammaln(r)-t.gammaln(i)+t.gammaln(r+i);y<10;y++){if(0===l||1===l)return l;if((l-=u=(c=(t.ibeta(l,r,i)-n)/(u=e.exp(m*e.log(l)+g*e.log(1-l)+p)))/(1-.5*e.min(1,c*(m/l-g/(1-l)))))<=0&&(l=.5*(l+u)),l>=1&&(l=.5*(l+u+1)),e.abs(u)<1e-8*l&&y>0)break}return l},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,u;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),u=(a=i-.449871)*a+(s=e.abs(o)+.386595)*(.196*s-.25472*a)}while(u>.27597&&(u>.27846||o*o>-4*e.log(i)*i*i));return o/i},t.randg=function(n,r,i){var o,a,s,u,c,l,h=n;if(i||(i=r),n||(n=1),r)return(l=t.zeros(r,i)).alter(function(){return t.randg(n)}),l;n<1&&(n+=1),o=n-1/3,a=1/e.sqrt(9*o);do{do{u=1+a*(c=t.randn())}while(u<=0);u*=u*u,s=t._random_fn()}while(s>1-.331*e.pow(c,4)&&e.log(s)>.5*c*c+o*(1-u+e.log(u)));if(n==h)return o*u;do{s=t._random_fn()}while(0===s);return e.pow(s,1/h)*o*u},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,u=1,c=1,l=0,h=0;e.abs((u-h)/u)>i;)h=u,s=c+(o=-(n+l)*(n+r+l)*t/(n+2*l)/(n+2*l+1))*s,u=(a=u+o*a)+(o=(l+=1)*(r-l)*t/(n+2*l-1)/(n+2*l))*u,a/=c=s+o*c,s/=c,u/=c,c=1;return u/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 u,c=2*t.normal.cdf(s,0,1,1,0)-1;c=c>=e.exp(-50/i)?e.pow(c,i):0;for(var l=s,h=(8-s)/(u=n>3?2:3),d=l+h,f=0,p=i-1,m=1;m<=u;m++){for(var g=0,y=.5*(d+l),v=.5*(d-l),w=1;w<=12;w++){var b,A=y+v*(6<w?o[(b=12-w+1)-1]:-o[(b=w)-1]),C=A*A;if(C>60)break;var E=2*t.normal.cdf(A,0,1,1,0)*.5-2*t.normal.cdf(A,n,1,1,0)*.5;E>=e.exp(-30/p)&&(g+=E=a[b-1]*e.exp(-.5*C)*e.pow(E,p))}f+=g*=2*v*i/e.sqrt(2*e.PI),l=d,d+=h}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),u=o+1,c=u,l=n*n/(n*n+r),h=0,d=e.exp(-i*i/2),f=e.exp(-i*i/2-.5*e.log(2)-t.gammaln(1.5))*i;h<200||c>o||u>o;)c=u,h>0&&(d*=i*i/(2*h),f*=i*i/(2*(h+.5))),s+=.5*(u=d*t.beta.cdf(l,h+.5,r/2)+f*t.beta.cdf(l,h+1,r/2)),h++;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 u=o,c=(r=e.floor(r))+1,l=i-r,h=c+l,d=e.exp(t.gammaln(h)-t.gammaln(l)-t.gammaln(c)+c*e.log(u)+l*e.log(1-u));return a=u<(c+1)/(h+2)?d*n(u,c,l,s):1-d*n(1-u,l,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,u=0;u<n;u++){for(;a>1&&s<o;)a*=1-i/(r-s),s++;a*=(o-u)*(i-u)/((u+1)*(r-i-o+u+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,u=0,c=0;c<n;c++){for(;a>1&&u<o;){var l=1-i/(r-u);s*=l,a*=l,u++}a+=s*=(o-c)*(i-c)/((c+1)*(r-i-o+c+1))}for(;u<o;u++)a*=1-i/(r-u);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,u,c,l,h,d,f=n;for(a=e.sqrt(f),s=e.log(f),u=.02483*(c=.931+2.53*a)-.059,l=1.1239+1.1328/(c-3.4),h=.9277-3.6224/(c-2);;){if(i=e.random()-.5,o=e.random(),d=.5-e.abs(i),r=e.floor((2*u/d+c)*i+f+.43),d>=.07&&o<=h)return r;if(!(r<0||d<.013&&o>d)&&e.log(o)+e.log(l)-e.log(u/(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],u=[.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,l=.5*o,h=l*e.log(o)-o*e.log(2)-t.gammaln(l),d=l-1,f=.25*o;c=o<=100?1:o<=800?.5:o<=5e3?.25:.125,h+=e.log(c);for(var p=0,m=1;m<=50;m++){for(var g=0,y=(2*m-1)*c,v=1;v<=16;v++){var w,b;8<v?(w=v-8-1,b=h+d*e.log(y+s[w]*c)-(s[w]*c+y)*f):(w=v-1,b=h+d*e.log(y-s[w]*c)+(s[w]*c-y)*f),b>=-30&&(g+=r(8<v?n*e.sqrt(.5*(s[w]*c+y)):n*e.sqrt(.5*(-s[w]*c+y)),1,a)*u[w]*e.exp(b))}if(m*c>=1&&g<=1e-14)break;p+=g}if(g>1e-14)throw new Error("tukey.cdf failed to converge");return p>1&&(p=1),p},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 u,c=t.tukey.cdf(o,r,i)-n,l=1;l<50;l++)if(u=o-c*(o-a)/(c-s),s=c,a=o,u<0&&(u=0,c=-n),c=t.tukey.cdf(u,r,i)-n,o=u,e.abs(o-a)<1e-4)return u;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,u,c,l,h;if(void 0===e.length&&void 0===n.length)return e*n;if(u=e.length,c=e[0].length,l=t.zeros(u,o=a(n)?n[0].length:c),h=0,a(n)){for(;h<o;h++)for(r=0;r<u;r++){for(s=0,i=0;i<c;i++)s+=e[r][i]*n[i][h];l[r][h]=s}return 1===u&&1===h?l[0][0]:l}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,u=[],c=0,l=o.length,h=o[0].length;c<l;c++){for(u[c]=[],r=0,i=0;i<h;i++)r+=o[c][i]*s[c][i];u[c]=r}return 1===u.length?u[0]:u},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=[],u=0;u<r;u++)for(s[u]=[],n=i;n<a[0].length;n++)s[u][n-i]=a[u][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,u=0,c=0,l=n.length,h=n[0].length,d=1,f=0,p=[];for(i=(n=t.aug(n,r))[0].length,u=0;u<l;u++){for(o=n[u][u],c=u,s=u+1;s<h;s++)o<e.abs(n[s][u])&&(o=n[s][u],c=s);if(c!=u)for(s=0;s<i;s++)a=n[u][s],n[u][s]=n[c][s],n[c][s]=a;for(c=u+1;c<l;c++)for(d=n[c][u]/n[u][u],s=u;s<i;s++)n[c][s]=n[c][s]-d*n[u][s]}for(u=l-1;u>=0;u--){for(f=0,c=u+1;c<=l-1;c++)f+=p[c]*n[u][c];p[u]=(n[u][i-1]-f)/n[u][u]}return p},gauss_jordan:function(n,r){var i,o,a,s=t.aug(n,r),u=s.length,c=s[0].length,l=0;for(o=0;o<u;o++){var h=o;for(a=o+1;a<u;a++)e.abs(s[a][o])>e.abs(s[h][o])&&(h=a);var d=s[o];for(s[o]=s[h],s[h]=d,a=o+1;a<u;a++)for(l=s[a][o]/s[o][o],i=o;i<c;i++)s[a][i]-=s[o][i]*l}for(o=u-1;o>=0;o--){for(l=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]/l;for(s[o][o]/=l,i=u;i<c;i++)s[o][i]/=l}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,u,c,l=0,h=0,d=n.length,f=[],p=[],m=[];l<d;l++)for(f[l]=[],p[l]=[],m[l]=[],h=0;h<d;h++)l>h?(f[l][h]=n[l][h],p[l][h]=m[l][h]=0):l<h?(p[l][h]=n[l][h],f[l][h]=m[l][h]=0):(m[l][h]=n[l][h],f[l][h]=p[l][h]=0);for(u=t.multiply(t.multiply(t.inv(m),t.add(f,p)),-1),s=t.multiply(t.inv(m),r),a=i,c=t.add(t.multiply(u,i),s),l=2;e.abs(t.norm(t.subtract(c,a)))>o;)a=c,c=t.add(t.multiply(u,a),s),l++;return c},gauss_seidel:function(n,r,i,o){for(var a,s,u,c,l,h=0,d=n.length,f=[],p=[],m=[];h<d;h++)for(f[h]=[],p[h]=[],m[h]=[],a=0;a<d;a++)h>a?(f[h][a]=n[h][a],p[h][a]=m[h][a]=0):h<a?(p[h][a]=n[h][a],f[h][a]=m[h][a]=0):(m[h][a]=n[h][a],f[h][a]=p[h][a]=0);for(c=t.multiply(t.multiply(t.inv(t.add(m,f)),p),-1),u=t.multiply(t.inv(t.add(m,f)),r),s=i,l=t.add(t.multiply(c,i),u),h=2;e.abs(t.norm(t.subtract(l,s)))>o;)s=l,l=t.add(t.multiply(c,s),u),h+=1;return l},SOR:function(n,r,i,o,a){for(var s,u,c,l,h,d=0,f=n.length,p=[],m=[],g=[];d<f;d++)for(p[d]=[],m[d]=[],g[d]=[],s=0;s<f;s++)d>s?(p[d][s]=n[d][s],m[d][s]=g[d][s]=0):d<s?(m[d][s]=n[d][s],p[d][s]=g[d][s]=0):(g[d][s]=n[d][s],p[d][s]=m[d][s]=0);for(l=t.multiply(t.inv(t.add(g,t.multiply(p,a))),t.subtract(t.multiply(g,1-a),t.multiply(m,a))),c=t.multiply(t.multiply(t.inv(t.add(g,t.multiply(p,a))),r),a),u=i,h=t.add(t.multiply(l,i),c),d=2;e.abs(t.norm(t.subtract(h,u)))>o;)u=h,h=t.add(t.multiply(l,u),c),d++;return h},householder:function(n){for(var r,i,o,a,s=n.length,u=n[0].length,c=0,l=[],h=[];c<s-1;c++){for(r=0,a=c+1;a<u;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),(l=t.zeros(s,1))[c+1][0]=(n[c+1][c]-r)/(2*i),o=c+2;o<s;o++)l[o][0]=n[o][c]/(2*i);h=t.subtract(t.identity(s,u),t.multiply(t.multiply(l,t.transpose(l)),2)),n=t.multiply(h,t.multiply(n,h))}return n},QR:(n=t.sum,r=t.arange,function(i){var o,a,s,u=i.length,c=i[0].length,l=t.zeros(c,c);for(i=t.copy(i),a=0;a<c;a++){for(l[a][a]=e.sqrt(n(r(u).map(function(t){return i[t][a]*i[t][a]}))),o=0;o<u;o++)i[o][a]=i[o][a]/l[a][a];for(s=a+1;s<c;s++)for(l[a][s]=n(r(u).map(function(t){return i[t][a]*i[t][s]})),o=0;o<u;o++)i[o][s]=i[o][s]-i[o][a]*l[a][s]}return[i,l]}),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,u=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 u=t.slice(r,{row:i}),c=t.multiply(t.slice(r,{row:n}),o);t.sliceAssign(r,{row:i},t.add(u,c))})}),r}(t.slice(a,{row:{end:s}})),l=t.transpose(u);void 0===l[0].length&&(l=[l]);var h=t.multiply(t.multiply(c,l),n);return void 0===h.length&&(h=[[h]]),r?h.map(function(t){return t[0]}):h},jacobi:function(n){for(var r,i,o,a,s,u,c,l=1,h=n.length,d=t.identity(h,h),f=[];1===l;){for(s=n[0][1],o=0,a=1,r=0;r<h;r++)for(i=0;i<h;i++)r!=i&&s<e.abs(n[r][i])&&(s=e.abs(n[r][i]),o=r,a=i);for(u=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(h,h))[o][o]=e.cos(u),c[o][a]=-e.sin(u),c[a][o]=e.sin(u),c[a][a]=e.cos(u),d=t.multiply(d,c),n=t.multiply(t.multiply(t.inv(c),n),c),l=0,r=1;r<h;r++)for(i=1;i<h;i++)r!=i&&e.abs(n[r][i])>.001&&(l=1)}for(r=0;r<h;r++)f.push(n[r][r]);return[d,f]},rungekutta:function(t,e,n,r,i,o){var a,s,u;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*(u=e*t(r+e/2,i+s/2))+e*t(r+e,i+u))/6,r+=e;return i},romberg:function(t,n,r,i){for(var o,a,s,u,c,l=0,h=(r-n)/2,d=[],f=[],p=[];l<i/2;){for(c=t(n),s=n,u=0;s<=r;s+=h,u++)d[u]=s;for(o=d.length,s=1;s<o-1;s++)c+=(s%2!=0?4:2)*t(d[s]);c=h/3*(c+t(r)),p[l]=c,h/=2,l++}for(a=p.length,o=1;1!==a;){for(s=0;s<a-1;s++)f[s]=(e.pow(4,o)*p[s+1]-p[s])/(e.pow(4,o)-1);a=f.length,p=f,f=[],o++}return p},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,u,c,l,h=e.abs(r-t[o(t,r)+1]),d=0,f=[],p=[];i>=h;)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,u=1;1!=c;){for(l=0;l<c-1;l++)p[l]=(e.pow(4,u)*f[l+1]-f[l])/(e.pow(4,u)-1);c=p.length,f=p,p=[],u++}return f},simpson:function(t,e,n,r){for(var i,o=(n-e)/r,a=t(e),s=[],u=e,c=0,l=1;u<=n;u+=o,c++)s[c]=u;for(i=s.length;l<i-1;l++)a+=(l%2!=0?4:2)*t(s[l]);return o/3*(a+t(n))},hermite:function(t,e,n,r){for(var i,o=t.length,a=0,s=0,u=[],c=[],l=[],h=[];s<o;s++){for(u[s]=1,i=0;i<o;i++)s!=i&&(u[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]));l[s]=(1-2*(r-t[s])*c[s])*(u[s]*u[s]),h[s]=(r-t[s])*(u[s]*u[s]),a+=l[s]*e[s]+h[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,u=[],c=[],l=[],h=[],d=[],f=[];s<a-1;s++)h[s]=e[s+1]-e[s];for(l[0]=0,s=1;s<a-1;s++)l[s]=3/h[s]*(n[s+1]-n[s])-3/h[s-1]*(n[s]-n[s-1]);for(s=1;s<a-1;s++)u[s]=[],c[s]=[],u[s][s-1]=h[s-1],u[s][s]=2*(h[s-1]+h[s]),u[s][s+1]=h[s],c[s][0]=l[s];for(o=t.multiply(t.inv(u),c),i=0;i<a-1;i++)d[i]=(n[i+1]-n[i])/h[i]-h[i]*(o[i+1][0]+2*o[i][0])/3,f[i]=(o[i+1][0]-o[i][0])/(3*h[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,u=e[0].length,c=0,l=[],h=[],d=[],f=[],p=[],m=[],g=[];for(c=0;c<s;c++)l[c]=t.sum(e[c])/u;for(c=0;c<u;c++)for(p[c]=[],n=0;n<s;n++)p[c][n]=e[n][c]-l[n];for(p=t.transpose(p),c=0;c<s;c++)for(m[c]=[],n=0;n<s;n++)m[c][n]=t.dot([p[c]],[p[n]])/(u-1);for(a=(i=t.jacobi(m))[0],h=i[1],g=t.transpose(a),c=0;c<h.length;c++)for(n=c;n<h.length;n++)h[c]<h[n]&&(r=h[c],h[c]=h[n],h[n]=r,d=g[c],g[c]=g[n],g[n]=d);for(o=t.transpose(p),c=0;c<s;c++)for(f[c]=[],n=0;n<o.length;n++)f[c][n]=t.dot([g[c]],[o[n]]);return[e,h,g,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,u,c,l,h=n.call(arguments);if(1===h.length){for(s=new Array(h[0].length),c=0;c<h[0].length;c++)s[c]=h[0][c];h=s}for(i=new Array,c=0;c<h.length;c++)i=i.concat(h[c]);for(o=t.mean(i),r=0,c=0;c<h.length;c++)r+=h[c].length*e.pow(t.mean(h[c])-o,2);for(r/=h.length-1,u=0,c=0;c<h.length;c++)for(a=t.mean(h[c]),l=0;l<h[c].length;l++)u+=e.pow(h[c][l]-a,2);return r/(u/(i.length-h.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 u=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(u,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,u,c=n.call(arguments);return r(c[0])?(i=c[0],o=c[1],a=c[2],s=c[3],u=c[4]):(i=t.mean(c[0]),o=t.mean(c[1]),a=c[0].length,s=c[1].length,u=c[2]),e.abs(i-o)/(u*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 u=t.qtest(r[a],r[s],e[a].length,e[s].length,n,i,e.length);o.push([[a,s],u])}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]}),u=e.subtract(t,s),c=e.mean(t),l=e.sum(s.map(function(t){return Math.pow(t-c,2)})),h=e.sum(t.map(function(t,e){return Math.pow(t-s[e],2)})),d=l+h;return{exog:n,endog:t,nobs:r,df_model:i,df_resid:o,coef:a,predict:s,resid:u,ybar:c,SST:d,SSE:l,SSR:h,R2:l/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))}),u=n.coef.map(function(t,e){return(t-0)/s[e]}),c=u.map(function(t){var r=e.studentt.cdf(t,n.df_resid);return 2*(r>.5?1-r:r)}),l=e.studentt.inv(.975,n.df_resid),h=n.coef.map(function(t,e){var n=l*s[e];return[t-n,t+n]});return{se:s,t:u,p:c,sigmaHat:a,interval95:h}}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),u=1-(1-o.R2)*((o.nobs-1)/o.df_resid);return o.t=a,o.f=s,o.adjust_R2=u,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 u,c,l,h=e.xtranspxinv(t),d=0;d<i.length;d++)u=Math.sqrt(o.anova.mse*Math.abs(h[d][d])),c=Math.abs(i[d]/u),l=e.ttest(c,n.length-t[0].length-1,r),o.stats[d]=[i[d],u,c,l];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)},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)}}}},7939:(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,".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,WAAW;AACf;;AAEA;IACI,4BAA4B;IAC5B,yBAAyB;IACzB,eAAe;AACnB;;AAEA;GACG,mBAAmB;AACtB;;AAEA;IACI,eAAe;IACf,kBAAkB;IAClB,YAAY;AAChB;;AAEA;IACI,WAAW;AACf;AACA;IACI,gBAAgB;AACpB;;AAEA;IACI,wBAAwB;AAC5B;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,oBAAoB;AACxB;;AAEA;IACI,aAAa;IACb,mBAAmB;IACnB,mBAAmB;IACnB,8BAA8B;IAC9B,uBAAuB;AAC3B;;AAEA;IACI,uBAAuB;IACvB,gBAAgB;AACpB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,kBAAkB;AACtB",sourcesContent:[".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}"],sourceRoot:""}]);const s=a},8103:(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,".pareto-input-form {\n padding-left: 12px;\n overflow-y: scroll;\n padding-right: 4px;\n}","",{version:3,sources:["webpack://./css/pareto.css"],names:[],mappings:"AAAA;EACE,kBAAkB;EAClB,kBAAkB;EAClB,kBAAkB;AACpB",sourcesContent:[".pareto-input-form {\n padding-left: 12px;\n overflow-y: scroll;\n padding-right: 4px;\n}"],sourceRoot:""}]);const s=a},8153:(t,e)=>{function n(t){return"number"!=typeof t||isNaN(t)?1:t}e.Fd=function(t){return function(t,e){var n={},r=function(t){return void 0===t?e:t};"function"==typeof e&&(r=e);var i=function(e){return r(e[t])},o=function(){return r(void 0)};return"string"==typeof t?(n.fromAttributes=i,n.fromGraph=function(t,e){return i(t.getEdgeAttributes(e))},n.fromEntry=function(t,e){return i(e)},n.fromPartialEntry=n.fromEntry,n.fromMinimalEntry=n.fromEntry):"function"==typeof t?(n.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},n.fromGraph=function(e,n){var i=e.extremities(n);return r(t(n,e.getEdgeAttributes(n),i[0],i[1],e.getNodeAttributes(i[0]),e.getNodeAttributes(i[1]),e.isUndirected(n)))},n.fromEntry=function(e,n,i,o,a,s,u){return r(t(e,n,i,o,a,s,u))},n.fromPartialEntry=function(e,n,i,o){return r(t(e,n,i,o))},n.fromMinimalEntry=function(e,n){return r(t(e,n))}):(n.fromAttributes=o,n.fromGraph=o,n.fromEntry=o,n.fromMinimalEntry=o),n}(t,n)}},8903:(t,e,n)=>{var r=n(1736),i=n(8153).Fd,o=n(2561),a=n(1782),s=n(9937);function u(t,e,n){if(!r(e))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");"number"==typeof n&&(n={iterations:n});var u=n.iterations;if("number"!=typeof u)throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(u<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var c=i("getEdgeWeight"in n?n.getEdgeWeight:"weight").fromEntry,l="function"==typeof n.outputReducer?n.outputReducer:null,h=a.assign({},s,n.settings),d=a.validateSettings(h);if(d)throw new Error("graphology-layout-forceatlas2: "+d.message);var f,p=a.graphToByteArrays(e,c);for(f=0;f<u;f++)o(h,p.nodes,p.edges);if(!t)return a.collectLayoutChanges(e,p.nodes);a.assignLayoutChanges(e,p.nodes,l)}var c=u.bind(null,!1);c.assign=u.bind(null,!0),c.inferSettings=function(t){var e="number"==typeof t?t:t.order;return{barnesHutOptimize:e>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(e)}},t.exports=c},9937:t=>{t.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}}},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,{GetMCLEditor:()=>Hn,MCLClustering:()=>Kn,MVA:()=>Xn,PCA:()=>Vn,PLS:()=>Yn,PackageFunctions:()=>Hr,_package:()=>jr,anova:()=>vr,applyLinearKernelSVM:()=>Zn,applyLinearRegression:()=>Cr,applyPLSRegression:()=>Lr,applyPolynomialKernelSVM:()=>cr,applyRBFkernelSVM:()=>ir,applySigmoidKernelSVM:()=>pr,applySoftmax:()=>_r,applyXGBooster:()=>Rr,dbScan:()=>Gn,dbscanPostProcessingFunction:()=>Bn,demoMultivariateAnalysis:()=>Qn,info:()=>kn,init:()=>Un,isApplicableLinearKernelSVM:()=>tr,isApplicableLinearRegression:()=>Er,isApplicablePLSRegression:()=>Tr,isApplicablePolynomialKernelSVM:()=>lr,isApplicableRBFkernelSVM:()=>or,isApplicableSigmoidKernelSVM:()=>mr,isApplicableSoftmax:()=>Mr,isApplicableXGBooster:()=>kr,isInteractiveLinearKernelSVM:()=>er,isInteractiveLinearRegression:()=>Sr,isInteractivePLSRegression:()=>Fr,isInteractivePolynomialKernelSVM:()=>hr,isInteractiveRBFkernelSVM:()=>ar,isInteractiveSigmoidKernelSVM:()=>gr,isInteractiveSoftmax:()=>Ir,isInteractiveXGBooster:()=>Dr,kNNImputation:()=>wr,kNNImputationForTable:()=>br,markovClusteringViewer:()=>qn,numberPreprocessingFunction:()=>zn,paretoFront:()=>Ur,paretoFrontViewer:()=>Gr,reduceDimensionality:()=>jn,stringPreprocessingFunction:()=>Wn,topMenuPLS:()=>$n,trainLinearKernelSVM:()=>Jn,trainLinearRegression:()=>Ar,trainPLSRegression:()=>Pr,trainPolynomialKernelSVM:()=>ur,trainRBFkernelSVM:()=>rr,trainSigmoidKernelSVM:()=>fr,trainSoftmax:()=>Nr,trainXGBooster:()=>xr,visualizeLinearKernelSVM:()=>nr,visualizePLSRegression:()=>Or,visualizePolynomialKernelSVM:()=>dr,visualizeRBFkernelSVM:()=>sr,visualizeSigmoidKernelSVM:()=>yr});const t=grok,e=ui,i=DG,o={i32:"HEAP32",f32:"HEAPF32"},a={i32:Int32Array,f32:Float32Array},s={i32:2,f32:2},u={i32:DG.Column.fromInt32Array,f32:DG.Column.fromFloat32Array};class c{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 l extends c{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*a[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const e=this.type,n=s[e],r=t[o[e]];let i=null;const u=this.data;i="int"==u.type&&"i32"==e||"double"==u.type&&"f32"==e?u.getRawData():new a[e](u.getRawData()),i&&r.set(i,this.buf>>n)}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[o[e]],r=this.buf,i=a[e].BYTES_PER_ELEMENT,s=this.data.getRawData();for(let t=0;t<this.numOfRows;t++)s[t]=n[r/i+t]}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class h extends l{constructor(t,e){super([],t,!0),this.numOfRows=e}putDataToBuffer(t){}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[o[e]],r=this.buf,i=u[e],s=new a[e](this.numOfRows);for(let t=0;t<s.length;t++)s[t]=n[r/s.BYTES_PER_ELEMENT+t];this.data=i("name",s)}}}class d extends c{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*a[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const e=this.type,n=s[e],r=t[o[e]],i=a[e].BYTES_PER_ELEMENT;for(let t=0;t<this.numOfColumns;t++){let o=null;const s=this.data[t];o="int"==s.type&&"i32"==e||"double"==s.type&&"f32"==e?s.getRawData():new a[e](s.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[o[e]],r=this.numOfRows,i=this.numOfColumns,s=new a[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]=s[n+t*r]}}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class f extends d{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[o[e]],r=this.numOfRows,i=this.numOfColumns,s=a[e].BYTES_PER_ELEMENT,c=u[e],l=this.buf;for(let t=0;t<i;t++){const i=new a[e](r);for(let e=0;e<r;e++)i[e]=n[l/s+e+t*r];this.data.push(c((t+1).toString(),i))}}}}const p={intColumn:t=>new l(t,"i32"),newIntColumn:t=>new h("i32",t),intColumns:t=>new d(t.toList(),"i32"),newIntColumns:(t,e)=>new f("i32",t,e),floatColumn:t=>new l(t,"f32"),newFloatColumn:t=>new h("f32",t),floatColumns:t=>new d(t.toList(),"f32"),newFloatColumns:(t,e)=>new f("f32",t,e),int:t=>new c(t),num:t=>new c(t)},m={tableFromColumns:t=>DG.DataFrame.fromColumns(t.data),num:t=>t,int:t=>t,double:t=>t,column:t=>t.data};function g(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=p[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=p[e.type](t,r);break;case"newFloatColumn":case"newIntColumn":const o=i[e.numOfRows.ref].data[e.numOfRows.value];e.data=p[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=p.num(s);const u=r.output;if("objects"!=u.type)return m[u.type](i[u.source].data);const c=[];for(const t of u.source)c.push(i[t].data.data);return c}const y="num",v="floatColumn",w="intColumn",b="floatColumns",A="newFloatColumns",C="intColumns",E="newIntColumns",S="newFloatColumn",N="newIntColumn",_="numOfRows",M="numOfColumns",I="ref",P="value",L="int",T="double",O={intColumn:Int32Array,floatColumn:Float32Array,floatColumns:Float32Array,newFloatColumns:Float32Array,intColumns:Int32Array,newIntColumns:Int32Array,newFloatColumn:Float32Array,newIntColumn:Int32Array};function F(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 y:case L:case T:a.data=e[i],i++;break;case w:case v:let r;const o=e[i],u=o.length;r=o.type===L&&s===w||o.type===T&&s===v?o.getRawData().slice(0,u):new O[s](o.getRawData().slice(0,u)),a.data={array:r,numOfRows:u},i++;break;case N:case S:let c=0;n=a[_][I],c=t[n].type===y?t[n].data:t[n].data[a[_][P]],a.data={numOfRows:c},i++;break;case C:case b:let l=[];const h=e[i].byIndex(0).length;for(const t of e[i].toList())t.type===L&&s===w||t.type===T&&s===v?l.push(t.getRawData().slice(0,h)):l.push(new O[s](t.getRawData().slice(0,h)));a.data={arrays:l,numOfRows:h,numOfColumns:l.length},i++;break;case E:case A:let d=0,f=0;n=a[_][I],d=t[n].type===y?t[n].data:t[n].data[a[_][P]],n=a[M][I],f=t[n].type===y?t[n].data:t[n].data[a[M][P]],a.data={numOfRows:d,numOfColumns:f},i++;break;default:return}r.push(a)}}return r}function x(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 y:case L:case T:case w:case v:case b:case C:break;case S:case N:let t;null==o.name?t=(0).toString():s=o.name,o.column=n[o.type](t,e[r].array);break;case E:case A: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 y:case L:case T: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 y:case L:case T:case w:case v:case C:case b:break;case N:case S:n.column=null;break;case E:case A:n.columns=null}}}(t.arguments),n}async function R(t,e,r){return new Promise((t,i)=>{const o=new Worker(new URL(n.p+n.u(128),n.b));o.postMessage(F(EDA.principalComponentAnalysisNipals.arguments,[e,r])),o.onmessage=function(e){o.terminate(),t(x(EDA.principalComponentAnalysisNipals,e.data))}})}const D=1e-6;function k(t){if(t.type!=i.COLUMN_TYPE.FLOAT&&t.type!=i.COLUMN_TYPE.INT)throw new Error("unsupported column type: "+t.type)}function U(t){if(t.stats.missingValueCount>0)throw new Error(`The column '${t.name}' has missing values.`)}function G(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)k(e),U(e)}(t,e),t.length*t.byIndex(0).length>1e8)throw new Error("dataframe is too big.")}function V(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)>D){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)>D&&t>0){const r=n.getRawData();for(let n=0;n<e;++n)r[n]/=t}}return t}(t):t}function B(t,e,r,o,a){return s=this,u=void 0,l=function*(){G(e,r);const s=t.rowCount,u=function(t){const e=[];for(const n of t)n.stats.stdev>0&&n.stats.missingValueCount<1&&e.push(n);return i.DataFrame.fromColumns(e)}(e),c=u.columns.length;if(0===c){const t=[];for(let e=0;e<r;++e)t.push(i.Column.fromFloat32Array(`${e+1}`,new Float32Array(s).fill(0)));return i.DataFrame.fromColumns(t)}const l=c<r?r-c:0,h=Math.min(r,c);let d;if(c>900)d=yield R(0,e,h);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(F(EDA.principalComponentAnalysis.arguments,[e,r,1,0])),o.onmessage=function(e){o.terminate(),0===e.data.callResult?t(x(EDA.principalComponentAnalysis,e.data)):t(-1)}})}(0,e,h);d=-1!==t?V(t,o,a):yield R(0,e,h)}if(void 0===d)throw new Error("Failed to compute PCA");d=V(d,o,a);const f=d.columns,p=f.length;for(let t=0;t<l;++t)f.add(i.Column.fromFloat32Array(`${p+t+1}`,new Float32Array(s).fill(0)));return d},new((c=void 0)||(c=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 c?i:new c(function(t){t(i)})).then(n,r)}i((l=l.apply(s,u||[])).next())});var s,u,c,l}var z=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};const W="incorrect kernel.",j="mean",H="std dev",K="alpha",q="weight",Y="Kernel params",$=["linear","polynomial","RBF","sigmoid"];function X(t,e,r){return z(this,void 0,void 0,function*(){const o=e.columns;if(2!=r.categories.length)throw new Error("labels must be strings of two categories.");const a=i.Column.float(r.name,r.length);for(let t=0;t<r.length;t++)a.set(t,r.get(t)==r.categories[0]?-1:1,!1);const s=yield function(t,e,r){return z(this,void 0,void 0,function*(){!function(t){if(t.gamma<=0)throw new Error("gamma must be strictly positive.");switch(t.kernel){case 0:case 3:return;case 2:if(t.sigma<=0)throw new Error("sigma must be strictly positive.");return;case 1:if(t.cParam<=0)throw new Error("c must be strictly positive.");if(t.dParam<=0)throw new Error("d must be strictly positive.");return;default:throw new Error(W)}}(t);const o=[0,0];switch(t.kernel){case 0:break;case 2:o[0]=t.sigma;break;case 1:o[0]=t.cParam,o[1]=t.dParam;break;case 3:o[0]=t.kappa,o[1]=t.theta;break;default:throw new Error(W)}const a=i.Column.fromList("double",Y,o),s=e.toList(),u=s[0].length+1,c=s.length+1;let l;const h=async function(t,e,r,i,o,a,s,u){return new Promise((a,c)=>{const l=new Worker(new URL(n.p+n.u(656),n.b));l.postMessage(F(EDA.trainAndAnalyzeLSSVM.arguments,[t,e,r,i,o,4,s,u])),l.onmessage=function(t){l.terminate(),a(x(EDA.trainAndAnalyzeLSSVM,t.data))}})}(t.gamma,t.kernel,a,u,c,0,e,r);yield h.then(t=>{l=t},t=>{throw new Error(`Error: ${t}`)}),l[1].name=j,l[2].name=H,l[3].name=K,l[4].name=q,l[5].name="predicted",l[6].name="correctness",l[7].name="Confusion matrix";const d={trainGamma:t.gamma,kernelType:t.kernel,kernelParams:a,trainLabels:r,normalizedTrainData:i.DataFrame.fromColumns(l[0]),means:l[1],stdDevs:l[2],modelParams:l[3],modelWeights:l[4],predictedLabels:l[5],correctness:l[6],confusionMatrix:l[7],trainError:void 0,featuresCount:s.length,trainSamplesCount:s[0].length};return function(t){const e=t.confusionMatrix.getRawData(),n=e[0],r=e[3],i=e[2],o=e[1],a=n+o,s=i+r,u=n/a,c=r/s,l=n/(n+i),h=r/(r+o),d=(n+r)/(a+s),f=(u+c)/2;t.sensitivity=u,t.specificity=c,t.balancedAccuracy=f,t.positivePredicitveValue=l,t.negativePredicitveValue=h,t.trainError=100*(1-d)}(d),d})}(t,o,a);return s.realLabels=r,s})}function Q(t,e){const n=Z(e);return i.Viewer.form(n.modelInfo,{showNavigation:!1}).root}function J(t){const e=t.normalizedTrainData.columns,n=t.trainSamplesCount,r=t.featuresCount,o=i.DataFrame.fromColumns([t.realLabels]).toByteArray(),a=4+o.length+4-o.length%4,s=function(t){const e=t.kernelParams.getRawData();return i.DataFrame.fromColumns([i.Column.fromList("double","Gamma",[t.trainGamma]),i.Column.fromStrings("Kernel",[$[t.kernelType]]),i.Column.fromList("double","Kernel parameter 1",[e[0]]),i.Column.fromList("double","Kernel parameter 2",[e[1]]),i.Column.fromList("double","Features count",[t.featuresCount]),i.Column.fromList("double","Train samples count",[t.trainSamplesCount]),i.Column.fromList("double","Train error, %",[t.trainError]),i.Column.fromList("double","Balanced accuracy",[t.balancedAccuracy]),i.Column.fromList("double","Sensitivity",[t.sensitivity]),i.Column.fromList("double","Specificity",[t.specificity]),i.Column.fromList("double","Positive predicitve value",[t.positivePredicitveValue]),i.Column.fromList("double","Negative predicitve value",[t.negativePredicitveValue])])}(t).toByteArray(),u=4+s.length+4-s.length%4,c=new Uint8Array(4*(5+n+r+r+n+1+r+1+r*n)+a+u),l=c.buffer;let h=0,d=new Int32Array(l,h,3);d[0]=t.kernelType,d[1]=n,d[2]=r,h+=12;let f=new Float32Array(l,h,2);f.set(t.kernelParams.getRawData()),h+=8,f=new Float32Array(l,h,n),f.set(t.trainLabels.getRawData()),h+=4*n,f=new Float32Array(l,h,r),f.set(t.means.getRawData()),h+=4*r,f=new Float32Array(l,h,r),f.set(t.stdDevs.getRawData()),h+=4*r,f=new Float32Array(l,h,n+1),f.set(t.modelParams.getRawData()),h+=4*(n+1),f=new Float32Array(l,h,r+1),f.set(t.modelWeights.getRawData()),h+=4*(r+1);for(const t of e)f=new Float32Array(l,h,r),f.set(t.getRawData()),h+=4*r;return d=new Int32Array(l,h,1),d[0]=o.length,c.set(o,h+4),h+=a,d=new Int32Array(l,h,1),d[0]=s.length,c.set(s,h+4),h+=u,c}function Z(t){const e=t.buffer;let n=0;const r=new Int32Array(e,n,3);n+=12;const o=r[1],a=r[2],s=i.Column.fromFloat32Array(Y,new Float32Array(e,n,2));n+=8;const u=i.Column.fromFloat32Array("Labels",new Float32Array(e,n,o));n+=4*o;const c=i.Column.fromFloat32Array(j,new Float32Array(e,n,a));n+=4*a;const l=i.Column.fromFloat32Array(H,new Float32Array(e,n,a));n+=4*a;const h=i.Column.fromFloat32Array(K,new Float32Array(e,n,o+1));n+=4*(o+1);const d=i.Column.fromFloat32Array(q,new Float32Array(e,n,a+1));n+=4*(a+1);const f=[];for(let t=0;t<o;t++)f.push(i.Column.fromFloat32Array(t.toString(),new Float32Array(e,n,a))),n+=4*a;const p=i.DataFrame.fromColumns(f),m=new Int32Array(e,n,1)[0],g=m+4-m%4;n+=4;const y=i.DataFrame.fromByteArray(new Uint8Array(e,n,m)).columns.byIndex(0);n+=g;const v=new Int32Array(e,n,1)[0],w=v+4-v%4;n+=4;const b=i.DataFrame.fromByteArray(new Uint8Array(e,n,v));return n+=w,{kernelType:r[0],kernelParams:s,trainLabels:u,realLabels:y,means:c,stdDevs:l,modelParams:h,modelWeights:d,normalizedTrainData:p,modelInfo:b}}function tt(t,e){return z(this,void 0,void 0,function*(){const r=Z(new Uint8Array(e)),o=yield function(t,e){return z(this,void 0,void 0,function*(){let r;const i=async function(t,e,r,i,o,a,s,u,c){return new Promise((l,h)=>{const d=new Worker(new URL(n.p+n.u(763),n.b));d.postMessage(F(EDA.predictByLSSVM.arguments,[t,e,r,i,o,a,s,u,c])),d.onmessage=function(t){d.terminate(),l(x(EDA.predictByLSSVM,t.data))}})}(t.kernelType,t.kernelParams,t.normalizedTrainData.columns,t.trainLabels,t.means,t.stdDevs,t.modelParams,t.modelWeights,e);return yield i.then(t=>{r=t},t=>{throw new Error(`Error: ${t}`)}),r})}(r,t.columns),a=i.Column.string("prediction",o.length),s=r.realLabels.categories;for(let t=0;t<a.length;t++)a.set(t,-1==o.get(t)?s[0]:s[1]);return i.DataFrame.fromColumns([a])})}function et(t,e){const n=t.columns;if(!e.matches("categorical")||e.categories.length>2)return!1;let r=!0;for(let t=0;t<n.length;t++)r=r&&n.byIndex(t).matches("numerical");return r}function nt(t,e){return t.rowCount<=1e3}var rt,it,ot,at,st,ut,ct,lt;!function(t){t[t.COMPUTE_COMPONENTS=0]="COMPUTE_COMPONENTS",t[t.PERFORM_MVA=1]="PERFORM_MVA",t[t.DEMO=2]="DEMO"}(rt||(rt={})),function(t){t.NO_DF="No dataframe is opened",t.NO_COLS="No numeric columns without missing values",t.ONE_COL="No columns to be used as features (just one numeric columns without missing values)",t.EMPTY_DF="Dataframe is empty",t.PREDICT="Predictors must not contain a response variable",t.ENOUGH="Not enough of features",t.COMP_LIN_PLS="Components count must be less than the number of features",t.COMP_QUA_PLS="Too large components count for the quadratic PLS regression",t.COMPONENTS="Components count must be greater than 1",t.INV_INP="Invalid inputs"}(it||(it={})),function(t){t.PREDICT="Predict",t.USING="Using",t.COMPONENTS="Components",t.PLS="PLS",t.MVA="Multivariate Analysis (PLS)",t.RUN="RUN",t.NAMES="Names",t.MODEL="Observed vs. Predicted",t.FEATURE="Feature",t.REGR_COEFS="Regression Coefficients",t.XLOADING="x.loading.p",t.LOADINGS="Loadings",t.XSCORE="x.score.t",t.YSCORE="y.score.u",t.SCORES="Scores",t.EXPL_VAR="Explained Variance",t.EXPLORE="Explore",t.FEATURES="Feature names",t.BROWSE="Browse",t.ANALYSIS="Features Analysis",t.QUADRATIC="Quadratic"}(ot||(ot={})),function(t){t.PREDICT="Column with the response variable",t.FEATURES="Predictors (features)",t.COMPONENTS="Number of PLS components",t.PLS="Compute PLS components",t.MVA="Perform multivariate analysis",t.NAMES="Names of data samples",t.QUADRATIC="Specifies whether to include squared terms as additional predictors in the PLS model"}(at||(at={})),function(t){t.PLS="/help/explore/multivariate-analysis#pls-components",t.MVA="/help/explore/multivariate-analysis",t.MODEL="/help/explore/multivariate-analysis#observed-vs-predicted",t.COEFFS="/help/explore/multivariate-analysis#regression-coefficients",t.LOADINGS="/help/explore/multivariate-analysis#loadings",t.EXPL_VARS="/help/explore/multivariate-analysis#explained-variance",t.SCORES="/help/explore/multivariate-analysis#scores"}(st||(st={})),function(t){t[t.DEFAULT=3]="DEFAULT",t[t.MIN=1]="MIN"}(ut||(ut={})),function(t){t.PREFIX="PLS",t.SUFFIX="(predicted)",t.COMP="component",t.COMPS="components"}(ct||(ct={})),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"}(lt||(lt={}));const ht=[.49,.79,.99];var dt;!function(t){t.AXIS="#838383",t.CIRCLE="#0000FF",t.INVALID="#EB6767",t.VALID_TEXT="#4d5261",t.VALID_LINE="#dbdcdf"}(dt||(dt={}));const ft=[{caption:ot.MODEL,text:"Closer to the line means better price prediction."},{caption:ot.SCORES,text:"The latent factor values for each sample reflect the similarities and dissimilarities among observations."},{caption:ot.LOADINGS,text:"The impact of each feature on the latent factors: higher loading means stronger influence."},{caption:ot.REGR_COEFS,text:"Parameters of the obtained model: features make different contribution to the prediction."},{caption:ot.EXPL_VAR,text:"How well the latent components fit source data: closer to one means better fit."}],pt=ft.map(t=>`# ${t.caption}\n\n${t.text}`).join("\n\n")+`\n\n# Learn more\n \n * [Multivariate analysis](${st.MVA}),\n * [ANOVA](https://datagrok.ai/help/explore/anova)`;var mt=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};const gt=Math.min;function yt(t){const e=[],n=(t,n)=>{e.push({type:"line",formula:t,width:1,visible:!0,title:" ",min:-n,max:n,color:dt.CIRCLE})};return t.forEach(r=>{const i="${"+r+"}";e.push({type:"line",formula:`${i} = 0`,width:1,visible:!0,title:" ",color:dt.AXIS}),t.forEach(t=>{const e="${"+t+"}";ht.forEach(t=>{n(e+` = sqrt(${t*t} - ${i} * ${i})`,t),n(e+` = -sqrt(${t*t} - ${i} * ${i})`,t)})})}),e}function vt(t){return mt(this,void 0,void 0,function*(){G(t.features,t.components),k(t.predict),U(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(F(EDA.partialLeastSquareRegression.arguments,[e,r,i])),a.onmessage=function(e){a.terminate(),t(x(EDA.partialLeastSquareRegression,e.data))}})}(t.table,t.features,t.predict,t.components);return{prediction:e[lt.PREDICTION],regressionCoefficients:e[lt.REGR_COEFFS],tScores:e[lt.T_SCORES],uScores:e[lt.U_SCORES],xLoadings:e[lt.X_LOADINGS],yLoadings:e[lt.Y_LOADINGS]}})}function wt(n){return mt(this,void 0,void 0,function*(){const r=t.shell.t;if(null===r)return void t.shell.warning(it.NO_DF);if(0===r.rowCount)return void t.shell.warning(it.EMPTY_DF);const o=[],a=[],s=[],u=t=>(t.type===i.COLUMN_TYPE.INT||t.type===i.COLUMN_TYPE.FLOAT)&&0===t.stats.missingValueCount;if(r.columns.toList().forEach(t=>{u(t)?(o.push(t.name),a.push(t)):t.type===i.COLUMN_TYPE.STRING&&s.push(t)}),0===o.length)return void t.shell.warning(it.NO_COLS);if(1===o.length)return void t.shell.warning(it.ONE_COL);let c=a.slice(0,a.length-1),l=a[a.length-1],h=gt(o.length-1,ut.DEFAULT),d=!1;const f=e.input.column(ot.PREDICT,{table:r,value:l,nullable:!1,onValueChanged:t=>{l=t,b()},filter:t=>u(t),tooltipText:at.PREDICT}),p=e.input.columns(ot.USING,{table:r,available:o,value:c,onValueChanged:t=>{c=t,b()},tooltipText:at.FEATURES}),m=e.input.int(ot.COMPONENTS,{value:h,showPlusMinus:!0,onValueChanged:t=>{h=t,b()},tooltipText:at.COMPONENTS});let g,y,v;n===rt.COMPUTE_COMPONENTS?(g=ot.PLS,y=st.PLS,v=at.PLS):(g=ot.MVA,y=st.MVA,v=at.MVA);const w=(t,n,r,i)=>{t?(n.style.color=dt.VALID_TEXT,n.style.borderBottomColor=dt.VALID_LINE,e.tooltip.bind(n,r)):(n.style.color=dt.INVALID,n.style.borderBottomColor=dt.INVALID,e.tooltip.bind(n,()=>{const t=e.label(r),n=e.label(i);return n.style.color=dt.INVALID,e.divV([t,n])}))},b=()=>{const t=(()=>{for(const t of c)if(t.name===l.name)return!1;return!0})();let e;if(t?(w(!0,f.input,at.PREDICT,""),w(!0,p.input,at.FEATURES,"")):(w(!1,f.input,at.PREDICT,it.PREDICT),w(!1,p.input,at.FEATURES,it.PREDICT)),h<1)w(!1,m.input,at.COMPONENTS,it.COMPONENTS),e=!1;else if(e=(()=>{if(h<1)return!1;const t=c.length;return d?h<=(t+1)*t/2+t:h<=t})(),e)w(!0,m.input,at.COMPONENTS,""),t&&w(!0,p.input,at.FEATURES,"");else{const t=d?it.COMP_QUA_PLS:it.COMP_LIN_PLS;w(!1,m.input,at.COMPONENTS,t),w(!1,p.input,at.FEATURES,it.ENOUGH)}const n=t&&e;return S.getButton(ot.RUN).disabled=!n,n};let A=s.length>0?s[0]:void 0;const C=e.input.column(ot.NAMES,{table:r,value:A,onValueChanged:t=>A=null!=t?t:void 0,filter:t=>t.type===i.COLUMN_TYPE.STRING});C.setTooltip(at.NAMES),C.root.hidden=0===s.length||n===rt.COMPUTE_COMPONENTS;const E=e.input.bool(ot.QUADRATIC,{value:d,tooltipText:at.QUADRATIC,onValueChanged:t=>{d=t,b()}}),S=e.dialog({title:g,helpUrl:y}).add(e.form([f,p,m,E,C])).addButton(ot.RUN,()=>mt(this,void 0,void 0,function*(){S.close(),yield function(n,r){return mt(this,void 0,void 0,function*(){var o,a;const s=n.table;n.isQuadratic&&(n=function(t){if(!t.isQuadratic)return t;const e=t.features.toList(),n=e.length,r=t.table.rowCount,o=[];let a,s,u,c,l;for(let t=0;t<n;++t){a=e[t],s=a.getRawData();for(let h=t;h<n;++h){u=e[h],c=u.getRawData(),l=new Float32Array(r);for(let t=0;t<r;++t)l[t]=s[t]*c[t];const t=i.Column.fromFloat32Array(`${a.name} x ${u.name}`,l);t.stats.stdev>0&&o.push(t)}}const h=i.DataFrame.fromColumns(e.concat(o));return{table:h,features:h.columns,isQuadratic:!0,names:t.names,predict:t.predict,components:t.components}}(n));const u=yield vt(n),c=u.tScores,l=s.columns,h=n.features,d=h.names(),f=r===rt.COMPUTE_COMPONENTS?ct.PREFIX:ot.XSCORE;if(c.forEach((t,e)=>{t.name=l.getUnusedName(`${f}${e+1}`),l.add(t)}),r===rt.COMPUTE_COMPONENTS)return;const p=t.shell.tableView(s.name),m=i.DataFrame.fromColumns([i.Column.fromStrings(ot.FEATURE,d),u.regressionCoefficients]);m.name=`${s.name}(${ot.ANALYSIS})`,t.shell.addTable(m),u.xLoadings.forEach((t,e)=>{t.name=m.columns.getUnusedName(`${ot.XLOADING}${e+1}`),m.columns.add(t)});const g=function(t,e,n,r){const o=n.length,a=t.length,s=e.getRawData(),u=new Float32Array(o),c=r.getRawData();let l=n.stats.avg;for(let e=0;e<a;++e)l-=s[e]*t.byIndex(e).stats.avg;for(let t=0;t<o;++t)u[t]=l+c[t];return i.Column.fromFloat32Array("Debiased",u,o)}(h,u.regressionCoefficients,n.predict,u.prediction);g.name=l.getUnusedName(`${n.predict.name} ${ct.SUFFIX}`),l.add(g);const y=p.addViewer(i.Viewer.scatterPlot(s,{title:ot.MODEL,xColumnName:n.predict.name,yColumnName:g.name,showRegressionLine:!0,markerType:i.MARKER_TYPE.CIRCLE,showLabels:"Always",help:st.MODEL}));void 0!==n.names&&null!==n.names&&y.setOptions({labelColumnNames:[null===(o=n.names)||void 0===o?void 0:o.name]}),u.regressionCoefficients.name=ot.REGR_COEFS;const v=p.addViewer(i.Viewer.barChart(m,{table:m.name,title:ot.REGR_COEFS,splitColumnName:ot.FEATURE,valueColumnName:u.regressionCoefficients.name,valueAggrType:i.AGG.AVG,help:st.COEFFS,showValueSelector:!1,showStackSelector:!1}));u.xLoadings.forEach((t,e)=>t.name=`${ot.XLOADING}${e+1}`);const w=p.addViewer(i.Viewer.scatterPlot(m,{table:m.name,title:ot.LOADINGS,xColumnName:`${ot.XLOADING}1`,yColumnName:`${ot.XLOADING}${u.xLoadings.length>1?"2":"1"}`,markerType:i.MARKER_TYPE.CIRCLE,labelColumnNames:[ot.FEATURE],help:st.LOADINGS})),b=c.map(t=>t.name);u.uScores.forEach((t,e)=>{t.name=l.getUnusedName(`${ot.YSCORE}${e+1}`),l.add(t),b.push(t.name)});const A=i.Viewer.scatterPlot(s,{title:ot.SCORES,xColumnName:c[0].name,yColumnName:c.length>1?c[1].name:u.uScores[0].name,markerType:i.MARKER_TYPE.CIRCLE,help:st.SCORES,showViewerFormulaLines:!0,labelColumnNames:void 0!==n.names&&null!==n.names?[null===(a=n.names)||void 0===a?void 0:a.name]:void 0});p.addViewer(A),A.meta.formulaLines.addAll(yt(b));const C=u.yLoadings.getRawData(),E=u.xLoadings.map(t=>t.getRawData()),S=s.rowCount,N=d.length,_=n.components,M=new Float32Array(_),I=[],P=[];for(let t=0;t<N;++t)P.push(new Float32Array(_));M[0]=Math.pow(C[0],2)/S,I.push(`1 ${ct.COMP}`),P.forEach((t,e)=>{t[0]=Math.pow(E[0][e],2)/S});for(let t=1;t<_;++t)M[t]=M[t-1]+Math.pow(C[t],2)/S,P.forEach((e,n)=>e[t]=e[t-1]+Math.pow(E[t][n],2)/S),I.push(`${t+1} ${ct.COMPS}`);const L=i.DataFrame.fromColumns([i.Column.fromStrings(ot.COMPONENTS,I),i.Column.fromFloat32Array(n.predict.name,M)]);L.name=`${s.name}(${ot.EXPL_VAR})`,t.shell.addTable(L),P.forEach((t,e)=>L.columns.add(i.Column.fromFloat32Array(d[e],t)));const T=p.addViewer(i.Viewer.barChart(L,{table:L.name,title:ot.EXPL_VAR,splitColumnName:ot.COMPONENTS,valueColumnName:n.predict.name,valueAggrType:i.AGG.AVG,help:st.EXPL_VARS,showCategorySelector:!1,showStackSelector:!1}));r===rt.DEMO&&(t.shell.windows.help.showHelp(e.markdown(pt)),function(t,n,r){if(t.length!==n.length)throw new Error("Non-equal size of viewer roots and descriptions");let i,o,a,s=0;const u=e.button("next",()=>{a.remove(),++s,d()},"Go to the next viewer"),c=e.button("prev",()=>{s-=1,a.remove(),d()},"Go to the previous viewer"),l=e.button("done",()=>a.remove(),"Go to the next step"),h=e.divH([c,u,l]);h.style.marginLeft="auto",h.style.marginRight="0px";const d=()=>{s<t.length&&(o=e.divV([e.markdown(n[s]),h]),a=e.hints.addHint(t[s],o,r[s]),l.hidden=s<t.length-1,u.hidden=s===t.length-1,c.hidden=s<1,i=a.querySelector("i"),i.onclick=()=>l.click())};d()}([y,A,w,v,T].map(t=>t.root),ft.map(t=>`<b>${t.caption}</b>\n\n${t.text}`),["left","left","right","right","left"]))})}({table:r,features:i.DataFrame.fromColumns(c).columns,predict:l,components:h,isQuadratic:d,names:A},n)}),void 0,v).show({x:200,y:200});setTimeout(()=>{p.value=a.filter(t=>t!==l),c=p.value},6),t.shell.v.append(S.root)})}Math.max;var bt,At=n(6572);!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"}(bt||(bt={}));const Ct="copy";var Et,St;!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"}(Et||(Et={})),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"}(St||(St={}));const Nt=[i.COLUMN_TYPE.INT,i.COLUMN_TYPE.FLOAT,i.COLUMN_TYPE.STRING,i.COLUMN_TYPE.DATE_TIME,i.COLUMN_TYPE.QNUM];function _t(t){switch(t.type){case i.COLUMN_TYPE.INT:return i.INT_NULL;case i.COLUMN_TYPE.FLOAT:case i.COLUMN_TYPE.QNUM:case i.COLUMN_TYPE.DATE_TIME:return i.FLOAT_NULL;case i.COLUMN_TYPE.STRING:return t.max;default:throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}}var Mt,It,Pt,Lt;function Tt(t){const e=new Map;for(const n of t){if(!Nt.includes(n.type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE);if(0===n.stats.missingValueCount)continue;const t=[],r=_t(n);n.getRawData().forEach((e,n)=>{e===r&&t.push(n)}),e.set(n.name,t)}return e}function Ot(t,e,n){for(const t of e)if(!n.has(t))return!1;for(const r of t){const t=n.get(r);if(void 0===t)throw new Error(bt.FAILS_TO_PREDICT_IMPUTATION_FAILS);for(const r of t){let t=!0;for(const i of e){const e=n.get(i);if(void 0===e)throw new Error(bt.FAILS_TO_PREDICT_IMPUTATION_FAILS);if(!e.includes(r)){t=!1;break}}if(t)return!0}}return!1}function Ft(t){if(t<=0||t>=1)throw new Error(Lt.INCORRECT_SIGNIFICANCE_LEVEL)}function xt(t){const e=t.size;return e<=1?0:(t.sumOfSquares-Math.pow(t.sum,2)/e)/(e-1)}function Rt(t,e,n){Ft(n);const r=xt(t),i=xt(e);return 0===r||0===i?r===i:r/i<At.centralF.inv(1-n,t.size-1,e.size-1)}!function(t){t.ONE_HOT="One-hot",t.DIFFERENCE="Difference"}(Mt||(Mt={})),function(t){t.EUCLIDEAN="Euclidean",t.MANHATTAN="Manhattan"}(It||(It={})),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"}(Pt||(Pt={})),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"}(Lt||(Lt={}));class Dt{constructor(t,e,n){if(this.nullsCount=0,t.length!==e.length)throw new Error(Lt.NON_EQUAL_FACTORS_VALUES_SIZE);if(!(e.stats.stdev>0))throw new Error(Lt.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(!Rt(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(Lt.SINGLE_FACTOR);const o=this.size-this.nullsCount;if(o===r)throw new Error(Lt.CATS_EQUAL_SIZE);const a=e-Math.pow(t,2)/o,s=n-Math.pow(t,2)/o,u=a-s;if(0===u)throw new Error(Lt.NO_FEATURE_VARIATION_WITHIN_GROUPS);const c=r-1,l=o-r,h=s/c,d=u/l,f=h/d;return{ssBn:s,ssWn:u,ssTot:a,dfBn:c,dfWn:l,dfTot:o-1,msBn:h,msWn:d,fStat:f,pValue:1-At.centralF.cdf(f,c,l)}}setStats(t,e,n){const r=e.type,o=e.length,a=_t(e);switch(r){case i.COLUMN_TYPE.INT:case i.COLUMN_TYPE.FLOAT:const r=n;this.catCount=r,this.size=o;const s=e.getRawData(),u=t.getRawData(),c=new Float64Array(r).fill(0),l=new Float64Array(r).fill(0),h=new Int32Array(r).fill(0);let d;if(t.type==i.COLUMN_TYPE.BOOL){let t=0,e=0,n=u[0];const r=8*u.BYTES_PER_ELEMENT-1;for(let i=0;i<o;++i)d=1&n>>e,s[i]!==a?(c[d]+=s[i],l[d]+=Math.pow(s[i],2),++h[d]):++this.nullsCount,++e,e>r&&(e=0,++t,n=u[t])}else{const e=t.stats.missingValueCount>0?_t(t):-1;for(let t=0;t<o;++t)d=u[t],d!==e&&s[t]!==a?(c[d]+=s[t],l[d]+=Math.pow(s[t],2),++h[d]):++this.nullsCount}this.sums=c,this.sumsOfSquares=l,this.subSampleSizes=h;break;default:throw new Error(Lt.UNSUPPORTED_COLUMN_TYPE)}}}const kt=[i.COLUMN_TYPE.INT,i.COLUMN_TYPE.FLOAT],Ut=[i.COLUMN_TYPE.STRING,i.COLUMN_TYPE.BOOL],Gt="/help/explore/anova";var Vt,Bt;function zt(){const n=t.shell.t;if(null===n)return void t.shell.warning("No dataframe is opened");const r=n.columns,o=[],a=[];for(const t of r)kt.includes(t.type)?a.push(t.name):Ut.includes(t.type)&&o.push(t.name);const s=o.length;if(s<1)return void t.shell.warning(e.markdown(`No acceptable factor columns:\n\n - type: ${Ut.join(", ")} \n - at least two categories`));let u=n.col(Bt.FACTOR);if(null===u){let t,e=0,n=r.byName(o[0]).categories.length;for(let i=1;i<s;++i)t=r.byName(o[i]).categories.length,t<n&&(n=t,e=i);u=r.byName(o[e])}if(a.length<1)return void t.shell.warning(e.markdown(`No acceptable feature columns:\n \n - type: ${kt.join(", ")}`));const c=e.input.column("Category",{table:n,value:u,tooltipText:"Column with factor values",onValueChanged:t=>u=t,filter:t=>o.includes(t.name),nullable:!1});let l=n.col(Bt.FEATURE);null===l&&(l=r.byName(a[0]));const h=e.input.column("Feature",{table:n,value:l,tooltipText:"Column with feature values",onValueChanged:t=>l=t,filter:t=>a.includes(t.name),nullable:!1});let d=Vt.DEFAULT;const f=e.input.float("Alpha",{min:Vt.MIN,max:Vt.MAX,value:d,nullable:!1,tooltipText:"Significance level",onValueChanged:t=>{d=t,g.disabled=d<=Vt.INFIMUM||d>=Vt.SUPREMUM}}),p=e.dialog({title:"ANOVA",helpUrl:Gt}),m=t.shell.getTableView(n.name);m.root.appendChild(p.root),p.addButton("Run",()=>{p.close();try{const r=function(t,e,n,r=!0){Ft(n);const i=t.stats.uniqueCount;if(i<2)throw new Error(Lt.SINGLE_FACTOR);const o=new Dt(t,e,i);if(r&&!o.areVarsEqual(n))throw new Error(Lt.NON_EQUAL_VARIANCES);const a=o.getOneWayAnova();return{anovaTable:a,fCritical:At.centralF.inv(1-n,a.dfBn,a.dfWn),significance:n}}(u,l,d);!function(n,r,o,a){const s=t.shell.getTableView(n.name);t.shell.v=s;const u=a.anovaTable.fStat>a.fCritical,c=u?`"${r}" affects the "${o}"`:`"${r}" doesn't affect the "${o}"`,l=i.Viewer.boxPlot(n,{categoryColumnNames:[r],valueColumnName:o,showPValue:!1,showStatistics:!1,description:c,showColorSelector:!1,autoLayout:!1});let h=s.dockManager.dock(l,i.DOCK_TYPE.RIGHT,null,"ANOVA");const d=e.markdown("**Null Hypothesis:** all group means are equal.");e.tooltip.bind(d,`The "${r}" factor does not produce a significant difference in the "${o}" feature.`);const f=e.markdown("**Alternative Hypothesis:** at least one group mean differs significantly.");e.tooltip.bind(f,`The "${r}" factor produces a significant difference in the "${o}" feature.`);const p=e.markdown("**Conclusion:** "+(u?"significant differences exist between groups.":"no significant differences detected.")),m=u?e.divV([e.p(`Reject the null hypothesis, since F > F-critical: \n ${a.anovaTable.fStat.toFixed(2)} > ${a.fCritical.toFixed(2)}.`),e.h2("There is a significant difference among sample averages.")]):e.divV([e.p(`Fail to reject the null hypothesis, since F < F-critical: \n ${a.anovaTable.fStat.toFixed(2)} < ${a.fCritical.toFixed(2)}.`),e.h2("There is no significant difference among sample averages.")]);e.tooltip.bind(p,()=>m);const g=e.divV([d,f,p,e.link("Learn more",()=>window.open("https://en.wikipedia.org/wiki/F-test","_blank"),"Click to open in a new tab.")]);g.style.marginLeft="20px";const y=function(t){const n=t.anovaTable,r=i.Viewer.grid(i.DataFrame.fromColumns([i.Column.fromStrings("Source of variance",["Between groups","Within groups","Total"]),i.Column.fromList(i.COLUMN_TYPE.FLOAT,"SS",[n.ssBn,n.ssWn,n.ssTot]),i.Column.fromList(i.COLUMN_TYPE.INT,"DF",[n.dfBn,n.dfWn,n.dfTot]),i.Column.fromList(i.COLUMN_TYPE.FLOAT,"MS",[n.msBn,n.msWn,null]),i.Column.fromList(i.COLUMN_TYPE.FLOAT,"F",[n.fStat,null,null]),i.Column.fromList(i.COLUMN_TYPE.FLOAT,"F-critical",[t.fCritical,null,null]),i.Column.fromList(i.COLUMN_TYPE.FLOAT,"p-value",[n.pValue,null,null])])),o=new Map([["Source of variance","List of the explored variation sources."],["SS","Sum of squares (SS). Measure of total variation in the data."],["DF","Degrees of freedom (DF). Number of independent values that can vary."],["MS","Mean square (MS). Sum of squares divided by degrees of freedom."],["F","F-statistics (F). Ratio of between-group to within-group variance."],["F-critical",`${t.significance}-critical value of F-statistics.`],["p-value","Probability of observing this result if groups have equal means."]]);return r.onCellTooltip(function(t,n,r){if(t.isColHeader)return e.tooltip.show(e.divV([e.p(o.get(t.tableColumn.name))]),n,r),!0}),r.helpUrl=Gt,r}(a),v=e.tabControl({Analysis:e.panel([y.root]),"F-test":e.panel([g])});e.tooltip.bind(v.getPane("Analysis").header,"ANOVA results summary."),e.tooltip.bind(v.getPane("F-test").header,"Null hypothesis testing."),s.dockManager.dock(v.root,i.DOCK_TYPE.DOWN,h,"",.25),y.root.style.width="100%"}(n,u.name,l.name,r)}catch(n){n instanceof Error?(t.shell.warning((r=n.message,e.divV([e.markdown(`ANOVA cannot be performed:\n \n ${r}`),e.link("Learn more",()=>window.open("https://en.wikipedia.org/wiki/Analysis_of_variance#Assumptions","_blank"),"Click to open in a new tab")]))),m.addViewer(i.VIEWER.BOX_PLOT,{categoryColumnNames:[u.name],valueColumnName:l.name,showStatistics:!1,showPValue:!1})):t.shell.error("ANOVA fails: the platform issue")}var r},void 0,"Perform analysis of variances");const g=p.getButton("Run");p.add(c).add(h).add(f).show()}!function(t){t[t.DEFAULT=.05]="DEFAULT",t[t.MIN=.01]="MIN",t[t.MAX=.99]="MAX",t[t.INFIMUM=0]="INFIMUM",t[t.SUPREMUM=1]="SUPREMUM"}(Vt||(Vt={})),function(t){t.FACTOR="race",t.FEATURE="age"}(Bt||(Bt={}));function Wt(t,e,r,i){return o=this,a=void 0,u=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(u.next(t))}catch(t){e(t)}}function r(t){try{i(u.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((u=u.apply(o,a||[])).next())});var o,a,s,u}n(5540);let jt=null;function Ht(){return t=this,e=void 0,r=function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!jt&&(jt=yield navigator.gpu.requestAdapter(),null==jt))return null;let t=null;return"info"in jt&&(t=jt.info),t?Kt(t.description,Kt(t.vendor,"No GPU description available")):"No GPU description available"},new((n=void 0)||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())});var t,e,n,r}function Kt(t,e){return t&&""!=t?t:e}var qt,Yt,$t,Xt,Qt,Jt,Zt,te,ee;(Yt=qt||(qt={})).EUCLIDEAN="EUCLIDEAN",Yt.MANHATTAN="MANHATTAN",qt.EUCLIDEAN,qt.MANHATTAN,(Xt=$t||($t={})).HAMMING="Hamming",Xt.EUCLIDEAN="Euclidean",Xt.VECTOR_COSINE="Vector Cosine",Xt.MANHATTAN="Manhattan",Xt.TANIMOTO="Tanimoto",Xt.LEVENSTEIN="Levenshtein",Xt.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",Xt.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",Xt.SOKAL="Sokal",Xt.COSINE="Cosine",Xt.ASYMMETRIC="Asymmetric",Xt.Difference="Difference",Xt.OneHot="One-Hot",$t.HAMMING,$t.EUCLIDEAN,$t.MANHATTAN,$t.VECTOR_COSINE,$t.TANIMOTO,$t.LEVENSTEIN,$t.NEEDLEMAN_WUNSCH,$t.MONOMER_CHEMICAL_DISTANCE,$t.SOKAL,$t.COSINE,$t.ASYMMETRIC,$t.Difference,$t.OneHot,$t.HAMMING,$t.EUCLIDEAN,$t.MANHATTAN,$t.TANIMOTO,$t.SOKAL,$t.COSINE,$t.ASYMMETRIC,$t.LEVENSTEIN,$t.NEEDLEMAN_WUNSCH,$t.MONOMER_CHEMICAL_DISTANCE,$t.Difference,$t.OneHot,$t.VECTOR_COSINE,new Set([$t.HAMMING,$t.LEVENSTEIN,$t.NEEDLEMAN_WUNSCH,$t.MONOMER_CHEMICAL_DISTANCE,$t.OneHot]),new Set([$t.HAMMING,$t.EUCLIDEAN,$t.MANHATTAN,$t.MONOMER_CHEMICAL_DISTANCE,$t.LEVENSTEIN,$t.NEEDLEMAN_WUNSCH,$t.TANIMOTO,$t.COSINE,$t.VECTOR_COSINE,$t.SOKAL,$t.ASYMMETRIC,$t.OneHot,$t.Difference]),new Set([$t.EUCLIDEAN,$t.MANHATTAN,$t.OneHot,$t.Difference,$t.VECTOR_COSINE]),new Set([$t.EUCLIDEAN,$t.MANHATTAN,$t.Difference,$t.VECTOR_COSINE]),new Set([$t.EUCLIDEAN,$t.MANHATTAN,$t.Difference]),new Set([$t.TANIMOTO,$t.COSINE,$t.SOKAL,$t.ASYMMETRIC]),function(t){t.ADD="ADD",t.SUB="SUB",t.MULT="MULT"}(Qt||(Qt={})),function(t){t.SQUARE="SQUARE",t.INVERSE="INVERSE",t.TRANSPOSE="TRANSPOSE",t.NORM="NORM",t.COLUMN_NORM="COLUMN_NORM"}(Jt||(Jt={})),function(t){t.SCALARMULT="SCALARMULT",t.SCALARADD="SCALARADD",t.SCALARPOW="SCALARPOW"}(Zt||(Zt={})),Object.prototype.toString,(ee=te||(te={})).UMAP="UMAP",ee.T_SNE="t-SNE",Promise.resolve(),n(934),n(8903);const ne=2;i.SEMTYPE.MOLECULE,i.SEMTYPE.MACROMOLECULE;class re{constructor(){this.epsilon={uiName:"Epsilon",value:.01,tooltip:"Minimum distance between cluster points",min:0,max:2,step:.005},this.minPts={uiName:"Minimum points",value:4,tooltip:"Minimum number of points in cluster",min:1,max:1e3,step:1}}}const ie="bypassLargeDataWarning";var oe,ae;(ae=oe||(oe={})).EUCLIDEAN="EUCLIDEAN",ae.MANHATTAN="MANHATTAN";const se=rxjs;var ue,ce,le,he,de,fe,pe,me,ge=n(5072),ye=n.n(ge),ve=n(7825),we=n.n(ve),be=n(7659),Ae=n.n(be),Ce=n(5056),Ee=n.n(Ce),Se=n(540),Ne=n.n(Se),_e=n(1113),Me=n.n(_e),Ie=n(7939),Pe={};Pe.styleTagTransform=Me(),Pe.setAttributes=Ee(),Pe.insert=Ae().bind(null,"head"),Pe.domAPI=we(),Pe.insertStyleElement=Ne(),ye()(Ie.A,Pe),Ie.A&&Ie.A.locals&&Ie.A.locals,function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan String",t.Onehot="One-Hot"}(ue||(ue={})),function(t){t.Euclidean="Euclidean",t.Manhattan="Manhattan",t.Cosine="Vector Cosine"}(ce||(ce={})),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"}(le||(le={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(he||(he={})),(me=de||(de={})).Vector="Vector",me.String="String",me.BitArray="BitArray",me.MacroMolecule="MacroMolecule",me.Number="Number",me.IntArray="IntArray",me.NumberArray="NumberArray",function(t){t.Difference="Difference"}(fe||(fe={})),function(t){t.CommonItems="Common Items"}(pe||(pe={}));const Le=new Uint32Array(65536),Te=(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,u=n;for(;u--;)Le[t.charCodeAt(u)]|=1<<u;for(u=0;u<r;u++){let t=Le[e.charCodeAt(u)];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(u=n;u--;)Le[t.charCodeAt(u)]=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 u=0;for(;u<s-1;u++){let a=0,s=-1;const c=32*u,l=Math.min(32,r)+c;for(let e=c;e<l;e++)Le[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=Le[e.charCodeAt(t)],r=o[t/32|0]>>>t&1,u=i[t/32|0]>>>t&1,c=n|a,l=((n|u)&s)+s^s|n|u;let h=a|~(l|s),d=s&l;h>>>31^r&&(o[t/32|0]^=1<<t),d>>>31^u&&(i[t/32|0]^=1<<t),h=h<<1|r,d=d<<1|u,s=d|~(c|h),a=h&c}for(let e=c;e<l;e++)Le[t.charCodeAt(e)]=0}let c=0,l=-1;const h=32*u,d=Math.min(32,r-h)+h;for(let e=h;e<d;e++)Le[t.charCodeAt(e)]|=1<<e;let f=r;for(let t=0;t<n;t++){const n=Le[e.charCodeAt(t)],a=o[t/32|0]>>>t&1,s=i[t/32|0]>>>t&1,u=n|c,h=((n|s)&l)+l^l|n|s;let d=c|~(h|l),p=l&h;f+=d>>>r-1&1,f-=p>>>r-1&1,d>>>31^a&&(o[t/32|0]^=1<<t),p>>>31^s&&(i[t/32|0]^=1<<t),d=d<<1|a,p=p<<1|s,l=p|~(u|d),c=d&u}for(let e=h;e<d;e++)Le[t.charCodeAt(e)]=0;return f})(t,e)};var Oe=n(944);class Fe{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=Fe._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 Fe(t._length);n._length=t._length,n._data=Fe._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 Fe(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 Fe(t);for(let r=0;r<t;++r)n.setBit(r,e(r));return n._version=0,n}static fromString(t){return Fe.fromSeq(t.length,e=>"1"==t.charAt(e))}static fromUint32Array(t,e){const n=new Fe(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new Fe(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 Fe(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 Fe.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+=Fe._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+=Fe._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+=Fe._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+=Fe._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=Fe._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=Fe._lastOnBit[t>>>24];if(n>=0)return n+32*r+e}}return-1}}function xe(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 u=0;for(let n=0;n<Math.min(o,a);n++)if(t[n]!==r[n]&&(u+=e(t[n],r[n]),u>s))return 1;return u+=i,u/=Math.max(o,a),u}}Fe._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]),Fe._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]),Fe._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 Re={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 De;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(De||(De={}));const ke={[De.HAMMING]:xe,[De.LEVENSHTEIN]:function(){return(t,e)=>Te(t,e)/Math.max(t.length,e.length)},[De.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:r,scoringMatrix:i,alphabetIndexes:o}={...Re,...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),u=new Array(t.length+1).fill(!1);let c=0,l=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 h=1;h<o.length+1;h++){a[l][0]=-r-(h-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(h-1)]],p=a[c][d]-(s[d]||1===h||h===o.length?r:n),m=a[l][d-1]-(u[d-1]||1===d||d===t.length?r:n);a[l][d]=Math.max(f,m,p),a[l][d]===f?(s[d]=!1,u[d]=!1):a[l][d]===m?(s[d]=!1,u[d]=!0):(s[d]=!0,u[d]=!1)}c=l,l=(l+1)%2}const h=Math.min(t.length,o.length);return(h-a[c][t.length])/h}},[De.MONOMER_CHEMICAL_DISTANCE]:xe};function Ue(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const r=t.andWithCountBits(e,!0);return r/(n-r)}function Ge(t){return t<=0?3402823e32:1/t-1}le.Tanimoto,le.Dice,le.Asymmetric,le.BraunBlanquet,le.Cosine,le.Kulczynski,le.McConnaughey,le.RogotGoldberg,le.Russel,le.Sokal,le.Hamming,le.Euclidean,le.Tanimoto,le.Dice,le.Asymmetric,le.BraunBlanquet,le.Cosine,le.Kulczynski,le.McConnaughey,le.RogotGoldberg,le.Russel,le.Sokal,le.Hamming,le.Euclidean,le.Tanimoto,le.Dice,le.Cosine,le.Tanimoto,le.Asymmetric,le.Cosine,le.Sokal,De.HAMMING,De.LEVENSHTEIN,De.MONOMER_CHEMICAL_DISTANCE,De.NEEDLEMANN_WUNSCH;const Ve={[ce.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)},[ce.Manhattan]:function(t,e){let n=0;for(let r=0;r<t.length;r++)n+=Math.abs(t[r]-e[r]);return n},[ce.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}},Be={[ue.Levenshtein]:Te,[ue.JaroWinkler]:Oe.Vb,[ue.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}},[ue.Onehot]:function(t,e){return t===e?0:1}},ze={[le.Tanimoto]:function(t,e){return 1-Ue(t,e)},[le.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)},[le.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)},[le.BraunBlanquet]:function(t,e){return Ge(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[le.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)},[le.Kulczynski]:function(t,e){return Ge(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))},[le.McConnaughey]:function(t,e){return Ge(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))},[le.RogotGoldberg]:function(t,e){return Ge(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))},[le.Russel]:function(t,e){return Ge(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))},[le.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)},[le.Hamming]:function(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)},[le.Euclidean]:function(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}},We={[he.TanimotoIntArray]:function(t,e){return Ge(Ue(new Fe(t,32*t.length),new Fe(e,32*e.length)))}},je={[fe.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)}},He={[pe.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)}},Ke={[de.Vector]:{[ce.Euclidean]:Ve[ce.Euclidean],[ce.Manhattan]:Ve[ce.Manhattan],[ce.Cosine]:Ve[ce.Cosine]},[de.String]:{[ue.Levenshtein]:Be[ue.Levenshtein],[ue.JaroWinkler]:Be[ue.JaroWinkler],[ue.Manhattan]:Be[ue.Manhattan],[ue.Onehot]:Be[ue.Onehot]},[de.BitArray]:{[le.Tanimoto]:ze[le.Tanimoto],[le.Dice]:ze[le.Dice],[le.Asymmetric]:ze[le.Asymmetric],[le.BraunBlanquet]:ze[le.BraunBlanquet],[le.Cosine]:ze[le.Cosine],[le.Kulczynski]:ze[le.Kulczynski],[le.McConnaughey]:ze[le.McConnaughey],[le.RogotGoldberg]:ze[le.RogotGoldberg],[le.Russel]:ze[le.Russel],[le.Sokal]:ze[le.Sokal]},[de.MacroMolecule]:{[De.HAMMING]:ke[De.HAMMING],[De.LEVENSHTEIN]:ke[De.LEVENSHTEIN],[De.NEEDLEMANN_WUNSCH]:ke[De.NEEDLEMANN_WUNSCH],[De.MONOMER_CHEMICAL_DISTANCE]:ke[De.MONOMER_CHEMICAL_DISTANCE]},[de.Number]:{[fe.Difference]:je[fe.Difference]},[de.IntArray]:{[he.TanimotoIntArray]:We[he.TanimotoIntArray]},[de.NumberArray]:{[pe.CommonItems]:He[pe.CommonItems]}};Object.keys(Ke).reduce((t,e)=>{for(const n of Object.keys(Ke[e]))t[n]=e;return t},{});class qe{constructor(){this.learningRate={uiName:"Learninig Rate",value:1,tooltip:"The initial learning rate for the embedding optimization"},this.nEpochs={uiName:"Epochs",value:0,tooltip:"The number of epochs to optimize embeddings via SGD. Computed automatically if set to 0"},this.nNeighbors={uiName:"Neighbors",value:15,tooltip:"The number of nearest neighbors to construct the fuzzy manifold"},this.spread={uiName:"Spread",value:1,tooltip:"The effective scale of embedded points, used with min distance to control \n the clumped/dispersed nature of the embedding"},this.minDist={uiName:"Min Distance",value:.1,tooltip:"The effective minimum distance between embedded points, \n used with spread to control the clumped/dispersed nature of the embedding"},this.randomSeed={uiName:"Random Seed",value:null,tooltip:"Random seed",type:"string"},this.useWebGPU={uiName:"Use WebGPU",value:!1,tooltip:"Use WebGPU for Distance and UMAP computations",type:"boolean",disableTooltip:"WebGPU is not available"},Ht().then(t=>{t?(this.useWebGPU.tooltip+=` (${t})`,this.useWebGPU.value=!0):(this.useWebGPU.value=!1,this.useWebGPU.disable=!0)})}}class Ye{constructor(){this.epsilon={uiName:"Epsilon",value:10,tooltip:"Epsilon is learning rate"},this.perplexity={uiName:"Perplexity",value:30,tooltip:"Roughly how many neighbors each point influences"}}}class $e{constructor(n={}){this.editorSettings={},this.columnOptEditors=[],this.columnOptEditorsRoot=e.div(),this.columnParamsEditorRoot=e.div(),this.columnFunctionsMap={},this.methodsParams={[te.UMAP]:new qe,[te.T_SNE]:new Ye},this.dbScanParams=new re,this.methodSettingsDivs=[],this.supportedFunctions={},this.methodSettingsAnchor=e.div(),this.plotEmbeddingsInput=e.input.bool("Plot Embeddings",{value:!0}),this.aggregationMethodInput=e.input.choice("Aggregation",{value:oe.EUCLIDEAN,items:[oe.EUCLIDEAN,oe.MANHATTAN]}),this.vectorDistanceInput=e.input.choice("Distance metric",{value:ce.Euclidean,items:[ce.Euclidean,ce.Manhattan,ce.Cosine]}),this.aggregationMethodInput.setTooltip("Aggregation method for combining distances between columns"),this.vectorDistanceInput.root.style.display="none",this.onColumnsChanged=new se.Subject,this.editorSettings=n,this.columnParamsEditorAccordion=e.accordion(),i.Func.find({tags:["dim-red-preprocessing-function"]}).forEach(t=>{const e=t.options.get("supportedSemTypes")??"",n=t.friendlyName??t.name,r=t.options.get("supportedTypes")??"",i=t.options.get("supportedUnits")??"",o=t.options.get("supportedDistanceFunctions")??"";this.editorSettings.semtype&&!e.includes(this.editorSettings.semtype)||this.editorSettings.type&&!r.includes(this.editorSettings.type)||this.editorSettings.units&&!i.includes(this.editorSettings.units)||(this.supportedFunctions[n]={func:t,semTypes:e?e.split(","):[],types:r?r.split(","):[],units:i?i.split(","):[],distanceFunctions:o?o.split(","):[]})}),this.postProcessingEditor=new Je,this.tableInput=e.input.table("Table",{value:t.shell.tv.dataFrame,items:t.shell.tables,onValueChanged:()=>{this.onTableInputChanged()}}),this.onTableInputChanged();let r=!1;this.methodInput=e.input.choice("Method",{value:te.UMAP,items:[te.UMAP,te.T_SNE],onValueChanged:t=>{r&&this.createAlgorithmSettingsDiv(this.methodsParams[t])}}),this.methodSettingsIcon=e.icons.settings(()=>{r=!r,r?this.createAlgorithmSettingsDiv(this.methodsParams[this.methodInput.value]):(this.methodSettingsDivs.forEach(t=>t.remove()),this.methodSettingsDivs=[])},"Modify methods parameters"),this.methodInput.root.classList.add("ml-dim-reduction-settings-input"),this.methodInput.root.prepend(this.methodSettingsIcon),this.columnParamsEditorAccordion.addPane("Column options",()=>this.columnOptEditorsRoot,!0,null,!1),this.columnParamsEditorAccordion.root.style.display="none",this.columnParamsEditorRoot.appendChild(this.columnParamsEditorAccordion.root),this.columnParamsEditorRoot.appendChild(this.vectorDistanceInput.root)}onTableInputChanged(){const t=this.tableInput.value;if(!t)return;e.empty(this.columnOptEditorsRoot),this.columnFunctionsMap={},t.columns.toList().forEach(t=>{Object.keys(this.supportedFunctions).forEach(e=>{const n=this.supportedFunctions[e].semTypes,r=this.supportedFunctions[e].types,i=this.supportedFunctions[e].units,o=!n.length||t.semType&&n.includes(t.semType),a=!r.length||r.includes(t.type),s=!i.length||t.meta.units&&i.includes(t.meta.units);o&&a&&s&&(this.columnFunctionsMap[t.name]||(this.columnFunctionsMap[t.name]=[]),this.columnFunctionsMap[t.name].push(e))})});const n=Object.keys(this.columnFunctionsMap),r=e.input.columns("Columns",{table:t,onValueChanged:t=>{if(this.onColumnsChanged.next(),e.empty(this.columnOptEditorsRoot),this.aggregationMethodInput.root.style.display=!t||t?.length<2?"none":"flex",!t||0===t.length)return void(this.columnParamsEditorAccordion.root.style.display="none");this.columnOptEditors=t.map(t=>new Xe(t,this.columnFunctionsMap[t.name].map(t=>this.supportedFunctions[t])));const n=e.divV([],{style:{maxHeight:"400px",overflow:"auto"}});this.columnOptEditors.forEach(t=>{n.appendChild(t.accordionDiv)});const r=new Array(2*this.columnOptEditors.length).fill(null).map((t,e)=>e%2==0?this.columnOptEditors[e/2].colOptEditors:[]);let i=0;const o=e.table(r,t=>(i++,t&&t.length>0?t:[this.columnOptEditors[Math.floor((i-1)/2)].preprocessingFuncSettingsDiv=e.div([]),e.div(),e.div(),e.div()]),["Column","Encoding function","Similarity metric","Weight"]);this.columnOptEditors.forEach(t=>{t.preprocessingFuncSettingsDiv?.parentElement?.setAttribute("colspan","4"),t.preprocessingFuncSettingsDiv?.parentElement?.parentElement?.style?.setProperty("height","unset")}),this.columnOptEditors.length>0&&(this.columnParamsEditorAccordion.root.style.display="flex"),o.classList.add("ml-dim-reduction-column-editor-table-root"),this.columnOptEditorsRoot.appendChild(o),t.every(t=>t.isNumerical)?(this.aggregationMethodInput.root.style.display="none",this.columnParamsEditorAccordion.root.style.display="none",this.vectorDistanceInput.root.style.display="flex"):this.vectorDistanceInput.root.style.display="none"},available:n});r.fireChanged(),this.columnsInputRoot?(e.empty(this.columnsInputRoot),this.columnsInput=r,Array.from(this.columnsInput.root.children).forEach(t=>this.columnsInputRoot.appendChild(t))):(this.columnsInputRoot=r.root,this.columnsInput=r)}createAlgorithmSettingsDiv(t){this.methodSettingsDivs.forEach(t=>t.remove()),this.methodSettingsDivs=[];const n=this.methodSettingsAnchor,r=n.parentElement;r&&Object.keys(t).forEach(i=>{const o=t[i],a="string"===o.type?e.input.string(o.uiName,{value:o.value??"",onValueChanged:t=>{o.value=t}}):"boolean"===o.type?e.input.bool(o.uiName,{value:o.value??!1,onValueChanged:t=>{o.value=t}}):e.input.float(o.uiName,{value:o.value,onValueChanged:t=>{o.value=t}});o.disable?(a.enabled=!1,e.tooltip.bind(a.input??a.root,o.disableTooltip??"")):e.tooltip.bind(a.input??a.root,o.tooltip),r.insertBefore(a.root,n),this.methodSettingsDivs.push(a.root)})}get algorithmOptions(){const t=this.methodsParams[this.methodInput.value],e={};return Object.keys(t).forEach(n=>{null!=t[n].value&&(e[n]=t[n].value)}),e}get dbScanOptions(){return{dbScanEpsilon:this.dbScanParams.epsilon.value??.01,dbScanMinPts:this.dbScanParams.minPts.value??4}}getEditor(){return e.div([this.tableInput.root,this.columnsInputRoot,this.columnParamsEditorRoot,this.aggregationMethodInput.root,this.methodInput.root,this.methodSettingsAnchor,this.plotEmbeddingsInput,this.postProcessingEditor.root],{style:{minWidth:"420px"},classes:"dim-reduction-dialog-form"})}getParams(){return{table:this.tableInput.value,columns:this.columnsInput.value,methodName:this.methodInput.value,preprocessingFunctions:this.columnOptEditors.map(t=>t.preProcessingFunction),distanceMetrics:this.columnOptEditors.map(t=>t.similarityMetricInput.value),weights:this.columnOptEditors.map(t=>t.weight??1),options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.columnOptEditors.map(t=>t.preprocessingFunctionSettings)},plotEmbeddings:this.plotEmbeddingsInput.value,clusterEmbeddings:!1,postProcessingFunction:this.postProcessingEditor.postProcessingFunction,postProcessingFunctionArgs:this.postProcessingEditor.args,aggreaggregationMethod:this.aggregationMethodInput.value,vectorDistanceMetric:this.vectorDistanceInput.value}}getInput(){return{columns:this.columnsInput.value.map(t=>t.name),method:this.methodInput.value,preprocessingFunctions:this.columnOptEditors.map(t=>t.preprocessingFunctionInput.value),distanceMetrics:this.columnOptEditors.map(t=>t.similarityMetricInput.value),weights:this.columnOptEditors.map(t=>t.weight??1),options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.columnOptEditors.map(t=>t.preprocessingFunctionSettings)},plotEmbeddings:this.plotEmbeddingsInput.value,postProcessingFunction:this.postProcessingEditor.postProcessingFunctionInput.value??null,postProcessingFunctionArgs:this.postProcessingEditor.args,aggreaggregationMethod:this.aggregationMethodInput.value,vectorDistanceMetric:this.vectorDistanceInput.value}}getStringInput(){return JSON.stringify(this.getInput())}async applyStringInput(e){try{const t=JSON.parse(e);await this.applyInput(t)}catch(e){t.shell.error("Error applying input from history"),console.error(e)}}async applyInput(e){try{const t=e.columns.map(t=>this.tableInput.value.col(t));if(t.some(t=>!t))throw new Error("Some columns are not found");this.columnsInput.value=t,this.columnsInput.fireChanged(),this.methodInput.value=e.method,this.columnOptEditors.forEach((t,n)=>{t.preprocessingFunctionInput.value=e.preprocessingFunctions[n],t.similarityMetricInput.value=e.distanceMetrics[n],t.weightInput.value=e.weights[n],t.preprocessingFunctionSettings=e.options.preprocessingFuncArgs[n]}),this.plotEmbeddingsInput.value=e.plotEmbeddings,this.postProcessingEditor.postProcessingFunctionInput.value=e.postProcessingFunction,await this.postProcessingEditor._prevChangePromise,this.postProcessingEditor._postProcessingArgs=e.postProcessingFunctionArgs,this.aggregationMethodInput.value=e.aggreaggregationMethod;const n={};Object.keys(this.methodsParams[e.method]).forEach(t=>{n[t]=e.options[t]}),Object.keys(this.methodsParams[e.method]).forEach(t=>{this.methodsParams[e.method][t].value=n[t]});const r=this.methodSettingsDivs.length>0;this.createAlgorithmSettingsDiv(this.methodsParams[e.method]),r||(this.methodSettingsDivs.forEach(t=>t.remove()),this.methodSettingsDivs=[]),await this.postProcessingEditor.onFunctionChanged(e.postProcessingFunctionArgs),this.vectorDistanceInput.value=e.vectorDistanceMetric}catch(e){t.shell.error("Error applying input from history"),console.error(e)}}}class Xe{constructor(t,n){this.preprocessingFuncSettingsDiv=e.div([]),this.preprocessingFunctionSettings={},this.editorDiv=e.div([]),this.hasExtraSettings=!0,this.functionsMap={},this.needsConfiguration=!1,this.weight=1,this.colOptEditors=[],this.weightInput=e.input.float("Weight",{value:1,onValueChanged:t=>{this.weight=t??1}}),this.column=t,this.supportedFunctions=n.sort((t,e)=>0!==t.units.length&&0!==e.units.length||t.units.length===e.units.length?t.units.length!==e.units.length?t.units.length-e.units.length:0===t.semTypes.length||0===e.semTypes.length?e.semTypes.length-t.semTypes.length:t.semTypes.length!==e.semTypes.length?t.semTypes.length-e.semTypes.length:t.types.length-e.types.length:e.units.length-t.units.length),this.supportedFunctions.forEach(t=>{this.functionsMap[Qe(t.func)]=t.func}),this.preprocessingFunctionInput=e.input.choice("Encoding function",{value:Qe(this.supportedFunctions[0].func),items:this.supportedFunctions.map(t=>Qe(t.func)),onValueChanged:t=>{const n=this.functionsMap[t];this.preprocessingFunctionSettings={},this.hasExtraSettings=n.inputs.length>2;const i=this.supportedFunctions.find(e=>Qe(e.func)===t);this.getSimilarityMetricInput(i),e.empty(this.preprocessingFuncSettingsDiv),r=!1,this.hasExtraSettings?this.preprocessingFuncSettingsIcon.style.display="flex":this.preprocessingFuncSettingsIcon.style.display="none"}}),this.preprocessingFunctionInput.root.style.display="flex",this.createSettingsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[0].func).then(()=>{e.empty(this.preprocessingFuncSettingsDiv)}),this.getSimilarityMetricInput(this.supportedFunctions[0]),this.hasExtraSettings=this.supportedFunctions[0].func.inputs.length>2;let r=!1;this.preprocessingFuncSettingsIcon=e.icons.settings(async()=>{r=!r,r?await this.createSettingsDiv(this.preprocessingFuncSettingsDiv,this.functionsMap[this.preprocessingFunctionInput.value]):e.empty(this.preprocessingFuncSettingsDiv)},"Modify encoding function parameters"),this.preprocessingFunctionInput.root.classList.add("ml-dim-reduction-settings-input"),this.preprocessingFunctionInput.root.prepend(this.preprocessingFuncSettingsIcon),this.hasExtraSettings?this.preprocessingFuncSettingsIcon.style.display="flex":this.preprocessingFuncSettingsIcon.style.display="none",this.needsConfiguration=!(n.length<2&&!this.hasExtraSettings&&n[0].distanceFunctions.length<2);const i=e.h3(this.column.name,{classes:"ml-dim-reduction-column-editor-column-title"});this.colOptEditors=[i,this.preprocessingFunctionInput.root,this.similarityMetricInputRoot,this.weightInput.root],e.tooltip.bind(i,this.column.name),this.colOptEditors.forEach(t=>t.classList.add("ml-dim-reduction-column-editor-input-root"));const o=e.divH(this.colOptEditors,{classes:"ml-dim-reduction-column-editor-root"});this.accordionDiv=e.divV([]),this.editorDiv.appendChild(o),this.editorDiv.appendChild(this.preprocessingFuncSettingsDiv),this.accordionDiv.appendChild(this.editorDiv)}getSimilarityMetricInput(t){const n=e.input.choice("Similarity metric",{value:t.distanceFunctions[0],items:t.distanceFunctions});this.similarityMetricInputRoot?(e.empty(this.similarityMetricInputRoot),this.similarityMetricInput=n,Array.from(this.similarityMetricInput.root.children).forEach(t=>this.similarityMetricInputRoot.appendChild(t))):(this.similarityMetricInputRoot=n.root,this.similarityMetricInput=n)}get preProcessingFunction(){return this.functionsMap[this.preprocessingFunctionInput.value]}async createSettingsDiv(t,n){if(e.empty(t),n.inputs.length<3)return e.div();const r=n.prepare(),i=await r.buildEditor(e.div());for(let e=2;e<n.inputs.length;e++){const o=n.inputs[e],a=this.preprocessingFunctionSettings[o.name]||r.inputParams[n.inputs[e].name].value||o.defaultValue;a&&(this.preprocessingFunctionSettings[o.name]=a);const s=i.find(t=>t.property.name===o.name);s&&(null!==this.preprocessingFunctionSettings[o.name]&&void 0!==this.preprocessingFunctionSettings[o.name]&&(s.value=this.preprocessingFunctionSettings[o.name]),s.onChanged.subscribe(t=>{this.preprocessingFunctionSettings[o.name]=t}),t.append(s.root))}return t.style.marginBottom="10px",t}}function Qe(t){return t.friendlyName??t.name}class Je{constructor(){this.postProcessingFunctionsMap={},this._root=e.div([]),this._postProcessingArgs={},this._argsElement=e.div([]),this._settingsOpened=!1,this._prevChangePromise=Promise.resolve(),this._settingsIcon=e.icons.settings(async()=>{this._settingsOpened=!this._settingsOpened,this._settingsOpened?this._argsElement.style.display="block":this._argsElement.style.display="none"}),this._argsElement.style.display="none",i.Func.find({tags:["dim-red-postprocessing-function"]}).filter(t=>t.inputs.length>=2).forEach(t=>{const e=t.friendlyName??t.name;this.postProcessingFunctionsMap[e]=t}),this.postProcessingFunctionsMap.None=null;const t=Object.keys(this.postProcessingFunctionsMap).find(t=>!!this.postProcessingFunctionsMap[t]?.options?.defaultPostProcessingFunction)??"None";this.postProcessingFunctionInput=e.input.choice("Postprocessing",{value:t,items:Object.keys(this.postProcessingFunctionsMap),onValueChanged:async()=>{await this.onFunctionChanged()},nullable:!1}),this.onFunctionChanged(),this.postProcessingFunctionInput.nullable=!1,this.postProcessingFunctionInput.classList.add("ml-dim-reduction-settings-input"),this.postProcessingFunctionInput.root.prepend(this._settingsIcon),this._root.appendChild(this.postProcessingFunctionInput.root),this._root.appendChild(this._argsElement)}get postProcessingFunction(){return this.postProcessingFunctionInput.value?this.postProcessingFunctionsMap[this.postProcessingFunctionInput.value]:null}async onFunctionChanged(n={}){let r;await this._prevChangePromise,this._prevChangePromise=new Promise(t=>r=t);try{const t=this.postProcessingFunction;if(e.empty(this._argsElement),this._postProcessingArgs={},!t||t.inputs.length<3)return void(this._settingsIcon.style.display="none");this._settingsIcon.style.display="flex";const r=t.prepare(n),i=await r.buildEditor(e.div());for(let e=2;e<t.inputs.length;e++){const n=t.inputs[e],o=this._postProcessingArgs[n.name]||r.inputParams[t.inputs[e].name].value||n.defaultValue;o&&(this._postProcessingArgs[n.name]=o);const a=i.find(t=>t.property.name===n.name);a&&(a.onChanged.subscribe(t=>{this._postProcessingArgs[n.name]=t}),this._argsElement.append(a.root))}}catch(e){t.shell.error("Error applying postprocessing function"),console.error(e)}finally{r()}}get root(){return this._root}get args(){return this._postProcessingArgs}}const Ze="dimensionality-reducer-terminate-event",tn=t=>null==t;function en(t,e){return`${e} (${t.length>4?`${t.length} columns`:t.map(t=>t.name).join(", ")})`}function nn(n){return r=this,o=void 0,s=function*(){if(null!=n||(n=t.shell.t),null===n)return void t.shell.warning(bt.NO_DATAFRAME);const r=[],o=[],a=[];n.columns.toList().filter(t=>Nt.includes(t.type)).forEach(t=>{const e=t.stats.missingValueCount;e!==t.length&&(a.push(t.name),e>0&&(r.push(t),o.push(t.name)))});const s=Tt(r);if(0===r.length)return void t.shell.info(bt.NO_MISSING_VALUES);if(1===a.length)return void t.shell.error(bt.ONE_AVAILABLE_FEATURE);let u=Pt.IN_PLACE>0;const c=e.input.bool(Et.IN_PLACE,{value:u,onValueChanged:t=>{u=null!=t&&t}});c.setTooltip(St.IN_PLACE);let l=Pt.KEEP_EMPTY>0;const h=e.input.bool(Et.KEEP_EMPTY,{value:l,onValueChanged:t=>{l=null!=t&&t}});h.setTooltip(St.KEEP_EMPTY);let d=Pt.NEIGHBORS;const f=e.input.int(Et.NEIGHBORS,{value:d,showPlusMinus:!0,min:1,nullable:!1,onValueChanged:t=>{null!==t&&t>=1&&(d=t),A()}});f.setTooltip(St.NEIGHBORS);let p=It.EUCLIDEAN;const m=e.input.choice(Et.DISTANCE,{value:p,items:[It.EUCLIDEAN,It.MANHATTAN],onValueChanged:t=>p=null!=t?t:It.EUCLIDEAN});m.setTooltip(St.DISTANCE);let g=r.map(t=>t.name);const y=e.input.columns(Et.COLUMNS,{table:n,value:n.columns.byNames(o),onValueChanged:t=>{g=t.map(t=>t.name),A()},available:o});y.setTooltip(St.TARGET);let v=a;const w=e.input.columns(Et.FEATURES,{value:n.columns.byNames(a),table:n,onValueChanged:t=>{v=t.map(t=>t.name),v.length>0?(A(),E.forEach((t,e)=>t.hidden=!v.includes(e))):b()},available:a});w.setTooltip(St.FEATURES);const b=()=>{N.getButton(Et.RUN).disabled=!0,c.root.hidden=!0,h.root.hidden=!0,f.root.hidden=!0,M.hidden=!0,S.hidden=!0},A=()=>{N.getButton(Et.RUN).disabled=null===f.value||f.value<1,M.hidden=!1,c.root.hidden=!1,f.root.hidden=!1,m.root.hidden=!1,h.root.hidden=!Ot(g,v,s),1===v.length&&g.forEach(e=>{v[0]===e&&(b(),t.shell.warning(`${bt.ONE_FEATURE_SELECTED} the column '${e}'`))}),g.length<1&&b()},C=new Map,E=new Map,S=e.divV([]);S.style.overflow="auto",a.forEach(t=>{const r=function(t){switch(t){case i.COLUMN_TYPE.STRING:case i.COLUMN_TYPE.DATE_TIME:return{defaultWeight:Pt.WEIGHT,defaultMetric:Mt.ONE_HOT,availableMetrics:[Mt.ONE_HOT]};case i.COLUMN_TYPE.INT:case i.COLUMN_TYPE.FLOAT:case i.COLUMN_TYPE.QNUM:return{defaultWeight:Pt.WEIGHT,defaultMetric:Mt.DIFFERENCE,availableMetrics:[Mt.DIFFERENCE,Mt.ONE_HOT]};default:throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}}(n.col(t).type);C.set(t,{weight:r.defaultWeight,type:r.defaultMetric});const o=e.input.choice(t,{value:r.defaultMetric,items:r.availableMetrics,onValueChanged:e=>{var n;const i=null!==(n=C.get(t))&&void 0!==n?n:{weight:r.defaultWeight,type:r.defaultMetric};i.type=null!=e?e:r.defaultMetric,C.set(t,i)}});o.root.style.width="50%",o.setTooltip(St.METRIC),o.root.hidden=!0;const a=i.Property.fromOptions({name:t.length<15?t:t.slice(0,15).concat("..."),inputType:"Float",min:0,max:10,showSlider:!0,step:1}),s=e.input.forProperty(a);s.value=r.defaultWeight,s.onChanged.subscribe(e=>{var n;const i=null!==(n=C.get(t))&&void 0!==n?n:{weight:r.defaultWeight,type:r.defaultMetric};i.weight=null!=e?e:r.defaultWeight,C.set(t,i)}),e.tooltip.bind(s.captionLabel,t),e.tooltip.bind(s.input,St.WEIGHT),E.set(t,s.root),S.append(s.root)});const N=e.dialog({title:Et.KNN_IMPUTER,helpUrl:"/help/explore/missing-values-imputation#the-k-nn-method"});t.shell.v.root.appendChild(N.root),S.hidden=!0,h.root.hidden=!Ot(g,v,s);const _=e.icons.settings(()=>{S.hidden=!S.hidden},St.METRIC_SETTINGS),M=e.divH([m.root,_]);let I,P,L=!1;const T=new Promise((t,e)=>{I=t,P=e});return N.addButton(Et.RUN,()=>{L=!0,N.close(),a.filter(t=>!v.includes(t)).forEach(t=>C.delete(t));try{const e=function(e,n,r,o,a,s,u){if(s<1)throw new Error(bt.INCORRECT_NEIGHBORS);if(e.rowCount<2)throw new Error(bt.KNN_NOT_ENOUGH_OF_ROWS);if(0===n.length)throw new Error(bt.KNN_NO_TARGET_COLUMNS);if(0===r.size)throw new Error(bt.KNN_NO_FEATURE_COLUMNS);1===r.size&&n.forEach(t=>{if(r.has(t))throw new Error(`${bt.KNN_NO_FEATURE_COLUMNS} can be used for the column '${t}'`)}),n.forEach(t=>{if(!o.has(t))throw new Error(`${bt.KNN_FAILS}: ${bt.WRONG_PREDICTIONS}`)});const c=e.columns;n.forEach(t=>{if(!Nt.includes(c.byName(t).type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}),r.forEach((t,n)=>{if(!Nt.includes(e.getCol(n).type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)});const l=new Map;return n.forEach(n=>{const h=c.byName(n),d=_t(h),f=h.length,p=h.getRawData(),m=new Uint16Array(h.categories.length),g=[],y=[],v=[],w=[];r.forEach((t,e)=>{if(e!==h.name){const n=c.byName(e);switch(g.push(n.getRawData()),y.push(_t(n)),t.type){case Mt.DIFFERENCE:v.push((e,n)=>t.weight*Math.abs(e-n));break;case Mt.ONE_HOT:v.push((e,n)=>t.weight*(e===n?0:1))}}});const b=g.length,A=new Uint32Array(g.length),C=new Float32Array(g.length);let E=0;const S=new Array(s);let N=0,_=0,M=0,I=0,P=0;const L=(t,e)=>{A.forEach((n,r)=>{C[r]=v[n](g[n][t],g[n][e])})},T=a===It.EUCLIDEAN?()=>{let t=0;for(let e=0;e<E;++e)t+=C[e]*C[e];return Math.sqrt(t)}:()=>{let t=0;for(let e=0;e<E;++e)t+=Math.abs(C[e]);return Math.sqrt(t)},O=t=>{if(p[t]===d)return!1;for(let e=0;e<E;++e)if(g[A[e]][t]===y[A[e]])return!1;return!0},F=t=>{if((t=>{E=0;for(let e=0;e<b;++e)g[e][t]!==y[e]&&(A[E]=e,++E)})(t),0===E)throw new Error(`${bt.KNN_IMPOSSIBLE_IMPUTATION}: the column "${h.name}", row ${t+1}`);N=0;for(let e=0;e<f;++e)if(O(e)&&e!==t){L(t,e);const n=T();if(N<s)S[N]={index:e,dist:n},++N;else{_=0,M=S[0].dist;for(let t=1;t<N;++t)M<S[t].dist&&(M=S[t].dist,_=t);n<M&&(S[_]={index:e,dist:n})}}if(0===N)throw new Error(`${bt.KNN_IMPOSSIBLE_IMPUTATION}: the column "${h.name}", row ${t+1}`);if(h.type===i.COLUMN_TYPE.STRING)return(()=>{m.forEach((t,e,n)=>n[e]=0);let t=0;for(t=0;t<N;++t)++m[p[S[t].index]];let e=m[0],n=0;return m.forEach((t,r)=>{t>e&&(e=t,n=r)}),n})();I=0;for(let t=0;t<N;++t)I+=p[S[t].index];return P=I/N,h.type===i.COLUMN_TYPE.INT?Math.round(P):P};if(u){for(const e of o.get(n))try{p[e]=F(e)}catch(n){w.push(e),n instanceof Error||t.shell.error(bt.CORE_ISSUE)}w.length>0&&l.set(n,w),h.set(0,h.get(0))}else{const r=h.clone();let i=1,a=`${n}(${Ct})`;for(;e.columns.contains(a);)a=`${n}(${Ct} ${i})`,++i;r.name=a;const s=r.getRawData();for(const e of o.get(n))try{s[e]=F(e)}catch(n){w.push(e),n instanceof Error||t.shell.error(bt.CORE_ISSUE)}w.length>0&&l.set(a,w),r.set(0,r.get(0)),e.columns.add(r)}}),l}(n,g,C,s,p,d,u);l||function(t,e){e.forEach((e,n)=>{const r=t.col(n);if(null!==r){if(!Nt.includes(r.type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE);const t=function(t){switch(t.type){case i.COLUMN_TYPE.STRING:case i.COLUMN_TYPE.DATE_TIME:return function(t){const e=_t(t),n=t.getRawData(),r=n.length;for(let i=0;i<r;++i)if(n[i]!==e)return t.get(i);throw new Error(bt.EMPTY_COLUMN)}(t);case i.COLUMN_TYPE.INT:case i.COLUMN_TYPE.FLOAT:case i.COLUMN_TYPE.QNUM:return t.stats.avg;default:throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}}(r);e.forEach(e=>r.set(e,t))}})}(n,e),I()}catch(e){e instanceof Error?t.shell.error(`${bt.KNN_FAILS}: ${e.message}`):t.shell.error(`${bt.KNN_FAILS}: ${bt.CORE_ISSUE}`),P(e)}},void 0,St.RUN),N.add(y).add(w).add(M).add(S).add(f).add(c).add(h).show().onClose.subscribe(()=>!L&&I()),T},new((a=void 0)||(a=Promise))(function(t,e){function n(t){try{u(s.next(t))}catch(t){e(t)}}function i(t){try{u(s.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof a?r:new a(function(t){t(r)})).then(n,i)}u((s=s.apply(r,o||[])).next())});var r,o,a,s}class rn extends $e{constructor(t={}){super(t),this.similarityThresholdInput=e.input.int("Similarity Threshold",{value:80}),this.maxIterationsInput=e.input.int("Max Iterations",{value:5}),this.useWebGPUInput=e.input.bool("Use WebGPU",{value:!1}),this.inflateInput=e.input.float("Inflation Factor",{value:ne}),this.minClusterSizeInput=e.input.int("Min Cluster Size",{value:5}),Ht().then(t=>{t?(this.useWebGPUInput.setTooltip(`Use webGPU for MCL calculation (${t})`),this.useWebGPUInput.value=!0):(this.useWebGPUInput.value=!1,this.useWebGPUInput.setTooltip("WebGPU is not available"),this.useWebGPUInput.enabled=!1)})}getEditor(){return e.div([this.tableInput.root,this.columnsInputRoot,this.columnParamsEditorRoot,this.aggregationMethodInput.root,this.similarityThresholdInput.root,this.inflateInput.root,this.maxIterationsInput.root,this.minClusterSizeInput.root,this.useWebGPUInput.root],{style:{minWidth:"420px"},classes:"ui-form"})}getInput(){const t=super.getInput();return t.similarityThreshold=this.similarityThresholdInput.value,t.maxIterations=this.maxIterationsInput.value,t.useWebGPU=this.useWebGPUInput.value??!1,t.inflateFactor=this.inflateInput.value??ne,t.minClusterSize=this.minClusterSizeInput.value??5,t}async applyInput(t){await super.applyInput(t),this.similarityThresholdInput.value=t.similarityThreshold,this.maxIterationsInput.value=t.maxIterations,this.useWebGPUInput.value=t.useWebGPU,this.inflateInput.value=t.inflateFactor,this.minClusterSizeInput.value=t.minClusterSize}get params(){return{table:this.tableInput.value,columns:this.columnsInput.value,methodName:this.methodInput.value,preprocessingFunctions:this.columnOptEditors.map(t=>t.preProcessingFunction),distanceMetrics:this.columnOptEditors.map(t=>t.similarityMetricInput.value),weights:this.columnOptEditors.map(t=>t.weight),preprocessingFuncArgs:this.columnOptEditors.map(t=>t.preprocessingFunctionSettings),aggreaggregationMethod:this.aggregationMethodInput.value,threshold:this.similarityThresholdInput.value,maxIterations:this.maxIterationsInput.value??5,useWebGPU:this.useWebGPUInput.value??!1,inflateFactor:this.inflateInput.value??ne,minClusterSize:this.minClusterSizeInput.value??5}}}class on{constructor(t,e,n,r,o,a){this.sc=t,this.from=e,this.to=n,this.shortLineThreshold=r,this.width=o,this.color=a,this.renderFlag=!1,this.renderSub=i.debounce(t.onAfterDrawScene,200).subscribe(()=>{if(this.renderFlag)return void(this.renderFlag=!1);this.renderFlag=!0;const e=t.onBeforeDrawScene.subscribe(t=>{this.render(),e.unsubscribe()});setTimeout(()=>{this.sc.invalidateCanvas()})}),t.subs.push(this.renderSub)}render(){const t=this.sc.dataFrame.getCol(this.sc.props.xColumnName),e=this.sc.dataFrame.getCol(this.sc.props.yColumnName),n=this.sc.filter,r=new Array(this.sc.dataFrame.rowCount).fill(null).map((r,i)=>t.isNone(i)||e.isNone(i)||!n.get(i)?null:this.sc.pointToScreen(i)),i=this.sc.canvas.getContext("2d");if(!i)return;i.strokeStyle=`rgba(${this.color}, 0.3)`,i.lineWidth=this.width;const o=this.shortLineThreshold*this.shortLineThreshold;for(let t=0;t<this.from.length;t++){i.beginPath();const e=this.from[t],n=this.to[t];if(r[e]&&r[n]){const t=r[e],a=r[n],s=a.x-t.x,u=a.y-t.y;if(s*s+u*u<o)continue;i.moveTo(t.x,t.y),i.lineTo(a.x,a.y),i.stroke(),i.closePath()}}}destroy(){this.renderSub.unsubscribe()}}class an extends i.JsViewer{constructor(){super(),this.initPromise=Promise.resolve(),this.initialized=!1,this.reseolver=()=>{},this.scratchCallTimer=null,this.mclProps=this.string("mclProps",null,{includeInLayout:!1,userEditable:!1,nullable:!0}),this.lines=this.string("lines",null,{includeInLayout:!1,userEditable:!1,nullable:!0}),this.scProps=this.string("scProps",null,{includeInLayout:!1,userEditable:!1,nullable:!0}),this.initPromise=new Promise(t=>{this.reseolver=t})}onFrameAttached(e){this.sc=e.plot.scatter({showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1,title:"MCL"}),this.root.appendChild(this.sc.root),this.subs.push(t.events.onCurrentObjectChanged.subscribe(e=>{this.sc&&t.shell.o===this&&setTimeout(()=>{t.shell.o=this.sc})})),this.subs.push(i.debounce(this.sc.onPropertyValueChanged,1e3).subscribe(t=>{this.sc&&this.getProperty("scProps").set(this,JSON.stringify(Object.assign({},this.sc.props)))}))}setScProps(){if(!this.sc)return;const t=this.scProps;if(!t)return;const e=this.sc.props;if(t===JSON.stringify(Object.assign({},e)))return;const n=JSON.parse(t);Object.entries(n).forEach(([t,n])=>{e.hasProperty(t)&&e[t]!==n&&(this.sc.props[t]=n)})}onPropertyChanged(t){null!==t&&("scProps"===t.name?this.setScProps():"lines"===t.name?this.decodeLines():"mclProps"===t.name&&(this.scratchCallTimer&&clearTimeout(this.scratchCallTimer),this.scratchCallTimer=setTimeout(()=>{this.initFromScratch()},300)))}isDataFrameSavable(){return null!=this.dataFrame&&this.dataFrame.rowCount<65534}async initFromScratch(){if(!this.mclProps||!this.sc||!this.dataFrame||this.initialized)return;if(this.lines)return void this.decodeLines();const r=JSON.parse(this.mclProps),o=r.cols.map(t=>this.dataFrame.columns.byName(t)),a=r.preprocessingFuncs.map(t=>t?i.Func.byName(t):null),s=await async function(r,o,a,s,u,c,l,h=80,d=10,f=!1,p=2,m=5,g){let y=null,v=g;v||(y=t.shell.tableView(r.name)??t.shell.addTableView(r),v=y.scatterPlot({showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1,title:"MCL"})),e.setUpdateIndicator(v.root,!0);const w=[],b=[];for(let t=0;t<c.length;++t){const e=c[t];if(e){const n=e.inputs[0].name,r=e.inputs[1].name,{entries:i,options:s}=await e.apply({[n]:o[t],[r]:a[t],...l[t]??{}});b.push({entries:i,options:s}),w.push(s??{})}else{const e=o[t].toList(),n={};b.push({entries:e,options:n}),w.push(n)}}const A=function(t,e,r,i,o,a,s=10,u=!1,c=2){const l=new Worker(new URL(n.p+n.u(980),n.b));let h;return l.postMessage({data:t,threshold:e,weights:r,aggregationMethod:i,distanceFns:o,distanceFnArgs:a,maxIterations:s,useWebGPU:u,inflate:c}),{promise:new Promise((t,e)=>{h=t,l.onmessage=e=>{setTimeout(()=>l.terminate(),100),t(e.data.res)},l.onerror=t=>{setTimeout(()=>l.terminate(),100),e(t)}}),terminate:()=>{try{h(null),l.terminate()}catch(t){console.error(t)}}}}(b.map(t=>t.entries),h,s,u,a,w,d,f,p),C=t.events.onViewerClosed.subscribe(t=>{const e=t?.args?.viewer?.root;e&&(v.root===e||e.contains(v.root))&&(C.unsubscribe(),A.terminate())}),E=await A.promise;if(!E)return;const S=r.columns.getUnusedName("Cluster (MCL)"),N=r.columns.getUnusedName("EmbedX (MCL)"),_=r.columns.getUnusedName("EmbedY (MCL)"),M={};E.clusters.forEach(t=>{M[t]||(M[t]=0),M[t]++});const I=new Uint32Array(E.embedX.length);for(let t=0;t<E.is.length;t++)I[E.is[t]]++,I[E.js[t]]++;const P=r.columns.getUnusedName("Cluster size (MCL)"),L=r.columns.getUnusedName("Connectivity (MCL)"),T=r.columns.addNewFloat(N);T.init(t=>E.embedX[t]);const O=r.columns.addNewFloat(_);O.init(t=>E.embedY[t]);const F=r.columns.addNewString(S);F.init(t=>M[E.clusters[t]]>=m?E.clusters[t].toString():"-1");const x={"-1":i.Color.setAlpha(i.Color.lightBlue,100)};F.setTag(i.TAGS.COLOR_CODING_CATEGORICAL,JSON.stringify(x)),F.temp[i.TAGS.COLOR_CODING_CATEGORICAL]=x;const R=r.columns.addNewInt(P);R.init(t=>M[E.clusters[t]]);const D=r.columns.addNewInt(L);D.init(t=>I[t]),v.props.xColumnName=N,v.props.yColumnName=_,v.props.colorColumnName=S,v.props.markerDefaultSize=6,C.unsubscribe();const k=[],U=[],G=new Map;for(let t=0;t<E.is.length;t++){let e=E.clusters[E.is[t]],n=E.clusters[E.js[t]];if(e===n){k.push(E.is[t]),U.push(E.js[t]);continue}if(e>n){const t=e;e=n,n=t}let r=G.get(e);r||(r=new Map,G.set(e,r));let i=r.get(n);i||(i=0),i>=20||(i++,r.set(n,i),k.push(E.is[t]),U.push(E.js[t]))}return e.setUpdateIndicator(v.root,!1),{sc:v,embedXCol:T,embedYCol:O,clusterCol:F,clusterCounterCol:R,connectivityCol:D,i:k,j:U}}(this.dataFrame,o,r.metrics,r.weights,r.aggregationMethod,a,r.preprocessingFuncArgs,r.threshold,r.maxIterations,r.useWebGPU,r.inflate,r.minClusterSize,this.sc);if(s)return this.dataFrame.getTag(".script")||!this.isDataFrameSavable()?(this.linesRenderer?.destroy(),this.linesRenderer=new on(this.sc,s.i,s.j,6,.75,"128,128,128"),this.initialized=!0,void this.reseolver()):void this.encodeLines(s.i,s.j);this.reseolver()}decodeLines(){if(!this.lines)return;const t=this.lines.length;if(t%2!=0)throw new Error("Invalid lines string");const e=new Array(t/2).fill(null).map((t,e)=>this.lines.charCodeAt(2*e)),n=new Array(t/2).fill(null).map((t,e)=>this.lines.charCodeAt(2*e+1));this.linesRenderer?.destroy(),this.linesRenderer=new on(this.sc,e,n,6,.75,"128,128,128"),this.initialized=!0,this.reseolver()}encodeLines(t,e){const n=new Array(t.length).fill(null).map((n,r)=>`${String.fromCharCode(t[r])}${String.fromCharCode(e[r])}`).join("");this.getProperty("lines").set(this,n)}}var sn=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};function un(t,e){const n=t.length;if(n!==e.length-1)throw new Error("Incorrect parameters count");const r=t.byIndex(0),o=r.length,a=new Float32Array(o);let s=r.getRawData();const u=e[n];let c=e[0];for(let t=0;t<o;++t)a[t]=u+c*s[t];for(let r=1;r<n;++r){s=t.byIndex(r).getRawData(),c=e[r];for(let t=0;t<o;++t)a[t]+=c*s[t]}return i.Column.fromFloat32Array(t.getUnusedName("prediction"),a,o)}const cn=(t,e)=>e<=t?Math.min(10,e):Math.min(10,t);var ln;!function(t){t[t.MAX_SAMLPES=1e5]="MAX_SAMLPES",t[t.MAX_FEATURES=1e3]="MAX_FEATURES"}(ln||(ln={}));class hn{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<=ln.MAX_FEATURES&&e.length<=ln.MAX_SAMLPES}constructor(t){if(this.specn=null,t)try{const e=new Uint32Array(t.buffer,0,2),n=e[0],r=e[1],o=new Uint8Array(t.buffer,8,n),a=i.DataFrame.fromByteArray(o),s=a.rowCount,u=a.columns,c=u.length,l=new Uint8Array(t.buffer,8+n,r),h=i.DataFrame.fromByteArray(l);if(c<3)throw new Error("incorrect columns count");const d=u.byName(ot.FEATURES).toList(),f=new Float32Array(s);f.set(u.byName(ot.REGR_COEFS).getRawData());const p=c-2,m=new Array(p);for(let t=0;t<p;++t)m[t]=new Float32Array(s),m[t].set(u.byIndex(t+2).getRawData());this.specn={params:f,loadings:m,names:d,dim:s-1,components:c-2,scores:h}}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(t,e,n){return r=this,o=void 0,s=function*(){const r=yield vt({table:i.DataFrame.fromColumns([e]),features:t,predict:e,components:n,names:void 0,isQuadratic:!1}),o=t.names();o.push("_");const a=this.getRegrCoeffs(t,e,r.regressionCoefficients),s=this.getLoadings(n,r.xLoadings);this.specn={names:o,params:a,loadings:s,components:n,dim:t.length,scores:this.getScoresDf(r)},this.computeExplVars(e.length,n,r.yLoadings)},new((a=void 0)||(a=Promise))(function(t,e){function n(t){try{u(s.next(t))}catch(t){e(t)}}function i(t){try{u(s.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof a?r:new a(function(t){t(r)})).then(n,i)}u((s=s.apply(r,o||[])).next())});var r,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 t=i.DataFrame.fromColumns([i.Column.fromStrings(ot.FEATURES,this.specn.names),i.Column.fromFloat32Array(ot.REGR_COEFS,this.specn.params)]);this.specn.loadings.forEach((e,n)=>t.columns.add(i.Column.fromFloat32Array(`${ot.XLOADING}${n+1}`,e)));const e=t.toByteArray(),n=e.length,r=this.specn.scores.toByteArray(),o=r.length,a=n+o+8,s=new Uint8Array(64*(Math.ceil(a/64)+1)),u=new Uint32Array(s.buffer,0,2);return u[0]=n,u[1]=o,s.set(e,8),s.set(r,8+n),s}predict(t){if(null===this.specn)throw new Error("Predicting failed: model is not trained");return un(t,this.specn.params)}loadingsParamsViewers(){if(null===this.specn)throw new Error("Failed to create loadings and parameters viewers: untrained model");const t=[],e=this.specn.dim,n=i.DataFrame.fromColumns([i.Column.fromStrings(ot.FEATURES,this.specn.names.slice(0,-1)),i.Column.fromFloat32Array(ot.REGR_COEFS,this.specn.params,e)]),r=n.columns,o=r.length,a=this.specn.components;return this.specn.loadings.forEach((t,r)=>n.columns.add(i.Column.fromFloat32Array(`${ot.XLOADING}${r+1}`,t,e))),t.push(i.Viewer.scatterPlot(n,{title:ot.LOADINGS,xColumnName:r.byIndex(o).name,yColumnName:r.byIndex(o+(a>1?1:0)).name,markerType:i.MARKER_TYPE.CIRCLE,labelFormColumnNames:[ot.FEATURES],help:st.LOADINGS})),t.push(i.Viewer.barChart(n,{title:ot.REGR_COEFS,splitColumnName:ot.FEATURES,valueColumnName:ot.REGR_COEFS,valueAggrType:i.AGG.AVG,help:st.COEFFS,showValueSelector:!1,showStackSelector:!1})),t}explVarsViewer(){if(null===this.specn)throw new Error("Failed to create exaplained variances viewer: untrained model");const t=this.specn.components,e=this.specn.dim,n=new Array(t),r=new Float32Array(t);n[0]=`${ct.COMP} 1`,r[0]=this.specn.loadings[0][e];for(let i=1;i<t;++i)n[i]=`${ct.COMPS} ${i+1}`,r[i]=this.specn.loadings[i][e];return i.Viewer.barChart(i.DataFrame.fromColumns([i.Column.fromStrings(ct.COMPS,n),i.Column.fromFloat32Array(ot.EXPL_VAR,r)]),{title:ot.EXPL_VAR,splitColumnName:ct.COMPS,valueColumnName:ot.EXPL_VAR,valueAggrType:i.AGG.AVG,help:st.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(t){const e=t.tScores,n=t.uScores;return e.forEach((t,e)=>t.name=`${ot.XSCORE}${e+1}`),n.forEach((t,e)=>t.name=`${ot.YSCORE}${e+1}`),i.DataFrame.fromColumns(e.concat(n))}getScoresScatter(){if(null===this.specn)throw new Error("Failed to create scores scatter: untrained model");const t=this.specn.scores.columns.names(),e=i.Viewer.scatterPlot(this.specn.scores,{title:ot.SCORES,xColumnName:t[0],yColumnName:t[1],markerType:i.MARKER_TYPE.CIRCLE,help:st.SCORES,showViewerFormulaLines:!0});return e.meta.formulaLines.addAll(yt(t)),e}}var dn=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};const fn="Avg-s",pn="Stddev-s";var mn;!function(t){t[t.MAX_SAMLPES=5e4]="MAX_SAMLPES",t[t.MAX_FEATURES=100]="MAX_FEATURES"}(mn||(mn={}));class gn{static isApplicable(t,e){for(const e of t)if(!e.matches("numerical"))return!1;return e.type===i.COLUMN_TYPE.STRING}static isInteractive(t,e){return t.length<=mn.MAX_FEATURES&&e.length<=mn.MAX_SAMLPES}constructor(t,e){if(this.params=void 0,this.classesCount=1,this.featuresCount=1,void 0!==t){const e=t.featuresCount,n=t.classesCount;if(e<1)throw new Error("Incorrect features count");if(n<1)throw new Error("Incorrect classes count");const r=e+1;this.avgs=new Float32Array(r),this.stdevs=new Float32Array(r),this.categories=new Array(r),this.featuresCount=e,this.classesCount=n}else{if(void 0===e)throw new Error("Softmax classifier not initialized");try{const t=new Uint32Array(e.buffer,0,1)[0],n=new Uint8Array(e.buffer,4,t),r=i.DataFrame.fromByteArray(n),o=r.columns,a=o.length;if(a<3)throw new Error("incorrect columns count");this.classesCount=a-2,this.featuresCount=r.rowCount-1;const s=this.classesCount;this.params=new Array(s),this.categories=new Array(r.rowCount);for(let t=0;t<s;++t){const e=o.byIndex(t);if(this.categories[t]=e.name,e.type!==i.COLUMN_TYPE.FLOAT)throw new Error(`Incorrect input column type. Expected: float, passed: ${e.type}`);this.params[t]=e.getRawData()}const u=o.byName(fn);if(u.type!==i.COLUMN_TYPE.FLOAT)throw new Error("incorrect average values column type");this.avgs=u.getRawData();const c=o.byName(pn);if(c.type!==i.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 t=this.classesCount,e=new Array(t+2);for(let n=0;n<t;++n)e[n]=i.Column.fromFloat32Array(this.categories[n],this.params[n]);e[t]=i.Column.fromFloat32Array(fn,this.avgs),e[t+1]=i.Column.fromFloat32Array(pn,this.stdevs);const n=i.DataFrame.fromColumns(e).toByteArray(),r=n.length,o=new Uint8Array(r+4);return new Uint32Array(o.buffer,0,1)[0]=r,o.set(n,4),o}fit(t,e){return dn(this,arguments,void 0,function*(t,e,n=1,r=100,o=.1,a=.001){if(t.length!==this.featuresCount)throw new Error("Training failes - incorrect features count");if(n<=0||r<1||o<=0||a<=0)throw new Error("Training failes - incorrect fitting hyperparameters");this.extractStats(t);const s=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,e,n,r,i,o,a,s,u,c,l){return g(EDA,"fitSoftmax",[t,e,n,r,i,o,a,s,u,c,l])}(t,i.Column.fromFloat32Array("avgs",this.avgs,this.featuresCount),i.Column.fromFloat32Array("stdevs",this.stdevs,this.featuresCount),i.Column.fromInt32Array("targets",e.getRawData(),s),u,r,n,o,a,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(i){try{this.params=yield this.fitSoftmaxParams(t,e,r,n,o,a)}catch(t){throw new Error("Training failes")}}if(void 0===this.params)throw new Error("Training failes")})}extractStats(t){let e=0;for(const n of t){if(n.type!==i.COLUMN_TYPE.INT&&n.type!==i.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");this.avgs[e]=n.stats.avg,this.stdevs[e]=n.stats.stdev,++e}}normalized(t){const e=t.byIndex(0).length,n=new Array(e);for(let t=0;t<e;++t)n[t]=new Float32Array(this.featuresCount);let r=0;for(const o of t){if(o.type!==i.COLUMN_TYPE.INT&&o.type!==i.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const t=o.getRawData(),a=this.avgs[r],s=this.stdevs[r];if(s>0)for(let i=0;i<e;++i)n[i][r]=(t[i]-a)/s;else for(let t=0;t<e;++t)n[t][r]=0;++r}return n}transposed(t){const e=t.byIndex(0).length,n=this.featuresCount,r=new Array(n);for(let t=0;t<n;++t)r[t]=new Float32Array(e);let o=0;for(const n of t){if(n.type!==i.COLUMN_TYPE.INT&&n.type!==i.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const t=n.getRawData(),a=this.avgs[o],s=this.stdevs[o];if(s>0)for(let n=0;n<e;++n)r[o][n]=(t[n]-a)/s;else for(let t=0;t<e;++t)r[o][t]=0;++o}return r}preprocessedTargets(t){if(t.type!==i.COLUMN_TYPE.STRING)throw new Error("Training failes - incorrect target type");const e=this.classesCount,n=t.length,r=t.getRawData(),o=new Array(n),a=new Uint32Array(e).fill(0);for(let t=0;t<n;++t)o[t]=new Uint8Array(e).fill(0);for(let t=0;t<n;++t)o[t][r[t]]=1,++a[r[t]];return{oneHot:o,weights:a}}predict(t){if(void 0===this.params)throw new Error("Non-trained model");if(t.length!==this.featuresCount)throw new Error("Predcition fails: incorrect features count");const e=this.normalized(t),n=e.length,r=this.featuresCount,o=this.classesCount;let a,s;const u=new Float32Array(o);let c,l,h;const d=new Array(n);for(let t=0;t<n;++t){a=e[t],c=0;for(let t=0;t<o;++t){s=this.params[t],c=s[r];for(let t=0;t<r;++t)c+=s[t]*a[t];u[t]=Math.exp(c)}l=u[0],h=0;for(let t=1;t<o;++t)l<u[t]&&(l=u[t],h=t);d[t]=this.categories[h]}return i.Column.fromStrings("predicted",d)}fitSoftmaxParams(t,e,r,i,o,a){return dn(this,void 0,void 0,function*(){const s=this.preprocessedTargets(e);return new Promise((u,c)=>{const l=new Worker(new URL(n.p+n.u(501),n.b));l.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}),l.onmessage=function(t){l.terminate(),u(t.data.params),console.log(`Loss: ${t.data.loss}`)}})})}}var yn,vn,wn;!function(t){t[t.ITERATIONS=20]="ITERATIONS",t[t.ETA=.3]="ETA",t[t.MAX_DEPTH=6]="MAX_DEPTH",t[t.LAMBDA=1]="LAMBDA",t[t.ALPHA=0]="ALPHA"}(yn||(yn={})),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"}(vn||(vn={})),function(t){t[t.MODEL=1e7]="MODEL",t[t.UTILS=1]="UTILS",t[t.PACK=128]="PACK",t[t.SIZE=4]="SIZE"}(wn||(wn={}));const bn=i.FLOAT_NULL;var An;!function(t){t.PREDICT="Prediction",t.TYPE="Type",t.PARAMS="Params count",t.CATS="Categories",t.CATS_SIZE="Categories size"}(An||(An={}));class Cn{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<=vn.SAMPLES_LOW?n<=vn.FEATURES_LOW:r<=vn.SAMLPES_MID?n<=vn.FEATURES_MID:r<=vn.SAMLPES_HIGH&&n<=vn.FEATURES_HIGH}constructor(t){var e;if(this.modelParams=void 0,this.targetType=void 0,this.targetCategories=void 0,t)try{let n=0;const r=new Uint32Array(t.buffer,n,1)[0];n+=wn.SIZE;const o=i.DataFrame.fromByteArray(new Uint8Array(t.buffer,n,r));n+=r,this.targetType=o.get(An.TYPE,0);const a=o.get(An.PARAMS,0),s=o.get(An.CATS_SIZE,0);if(s>0){const r=i.DataFrame.fromByteArray(new Uint8Array(t.buffer,n,s));this.targetCategories=null===(e=r.col(An.CATS))||void 0===e?void 0:e.toList()}n+=s,n=4*Math.ceil(n/4),this.modelParams=new Int32Array(t.buffer,n,a)}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(t,e){return r=this,o=arguments,s=function*(t,e,r=yn.ITERATIONS,o=yn.ETA,a=yn.MAX_DEPTH,s=yn.LAMBDA,u=yn.ALPHA){this.targetType=e.type,this.targetType===i.COLUMN_TYPE.STRING&&(this.targetCategories=e.categories),this.modelParams=yield async function(t,e,r,i,o,a,s,u,c,l){return new Promise((h,d)=>{const f=e.length,p=t.length,m=new Float32Array(f*p);let g,y;for(let e=0;e<p;++e){y=t.byIndex(e).getRawData(),g=e*f;for(let t=0;t<f;++t)m[t+g]=y[t]}const v=new Worker(new URL(n.p+n.u(990),n.b));v.postMessage({features:m,target:e.getRawData(),samplesCount:f,featuresCount:p,modelReserve:c,utilsLength:l,iterations:i,eta:o,maxDepth:a,lambda:s,alpha:u,missingValue:r}),v.onmessage=function(t){v.terminate(),h(t.data.params)}})}(t,e,bn,r,o,a,s,u,wn.MODEL,wn.UTILS)},new((a=void 0)||(a=Promise))(function(t,e){function n(t){try{u(s.next(t))}catch(t){e(t)}}function i(t){try{u(s.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof a?r:new a(function(t){t(r)})).then(n,i)}u((s=s.apply(r,o||[])).next())});var r,o,a,s}predict(t){if(void 0===this.modelParams)throw new Error("Failed to apply non-trained model");const e=function(t,e,n){const r=t.byIndex(0).length,i=t.length,o=n.length;let a=XGBoostModule.HEAPF32;const s=XGBoostModule.HEAP32,u=XGBoostModule._malloc(r*i*4),c=XGBoostModule._malloc(4*r),l=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[u/4+t+e*r]=n[t]}for(let t=0;t<o;++t)s[l/4+t]=n[t];XGBoostModule._predict(u,r,i,e,l,o,c,r),a=XGBoostModule.HEAPF32;const h=new Float32Array(r);for(let t=0;t<r;++t)h[t]=a[c/4+t];return XGBoostModule._free(u),XGBoostModule._free(c),XGBoostModule._free(l),h}(t,bn,this.modelParams);switch(this.targetType){case i.COLUMN_TYPE.STRING:return this.stringColPrediction(e);case i.COLUMN_TYPE.INT:return this.intColPrediction(e);case i.COLUMN_TYPE.BIG_INT:return this.bigIntColPrediction(e);default:return i.Column.fromFloat32Array(An.PREDICT,e)}}toBytes(){if(void 0===this.modelParams||void 0===this.targetType)throw new Error("Failed to pack non-trained model");const t=void 0!==this.targetCategories?i.DataFrame.fromColumns([i.Column.fromList(i.COLUMN_TYPE.STRING,An.CATS,this.targetCategories)]).toByteArray():void 0,e=void 0!==t?t.length:0,n=this.modelParams.length*this.modelParams.BYTES_PER_ELEMENT,r=i.DataFrame.fromColumns([i.Column.fromStrings(An.TYPE,[this.targetType]),i.Column.fromInt32Array(An.PARAMS,new Int32Array([this.modelParams.length])),i.Column.fromInt32Array(An.CATS_SIZE,new Int32Array([e]))]).toByteArray(),o=r.length,a=64*Math.ceil((wn.SIZE+o+e+n+wn.PACK)/64),s=new Uint8Array(a);let u=0;return new Uint32Array(s.buffer,u,1)[0]=o,u+=wn.SIZE,s.set(r,u),u+=o,e>0&&s.set(t,u),u+=e,u=4*Math.ceil(u/4),s.set(new Uint8Array(this.modelParams.buffer),u),s}stringColPrediction(t){const e=t.length;if(void 0===this.targetCategories)throw new Error("Predicting fails: undefined categories");const n=new Array(e),r=this.targetCategories.length-1,o=t=>Math.max(0,Math.min(t,r));for(let r=0;r<e;++r)n[r]=this.targetCategories[o(Math.round(t[r]))];return i.Column.fromList(i.COLUMN_TYPE.STRING,An.PREDICT,n)}intColPrediction(t){const e=t.length,n=new Int32Array(e);for(let r=0;r<e;++r)n[r]=Math.round(t[r]);return i.Column.fromInt32Array(An.PREDICT,n,e)}bigIntColPrediction(t){const e=t.length,n=new BigInt64Array(e);for(let r=0;r<e;++r)n[r]=BigInt(Math.round(t[r]));return i.Column.fromBigInt64Array(An.PREDICT,n)}}var En,Sn,Nn,_n,Mn,In=n(8103),Pn={};Pn.styleTagTransform=Me(),Pn.setAttributes=Ee(),Pn.insert=Ae().bind(null,"head"),Pn.domAPI=we(),Pn.insertStyleElement=Ne(),ye()(In.A,Pn),In.A&&In.A.locals&&In.A.locals,function(t){t.MIN="minimize",t.MAX="maximize"}(En||(En={})),function(t){t.OPTIMAL="optimal",t.NON_OPT="non-optimal"}(Sn||(Sn={})),function(t){t[t.FORM=.15]="FORM",t[t.VIEWER=.5]="VIEWER"}(Nn||(Nn={})),function(t){t.OPT="Pareto optimality",t.SIZE="Pareto size"}(_n||(_n={})),function(t){t[t.OPTIMAL=8]="OPTIMAL",t[t.NON_OPT=4]="NON_OPT"}(Mn||(Mn={}));const Ln=!0,Tn=!0,On=[i.Color.darkGreen,i.Color.yellow,i.Color.darkRed];function Fn(t){return t===En.MIN?[...On]:[...On].reverse()}class xn{constructor(e){var n;this.numColNames=[],this.features=new Map,this.toUpdatePcCols=!1,this.intervalId=null,this.inputsMap=new Map,this.pcPlotNode=null,this.inputFormNode=null,this.toChangeParetoViewerOptions=!0,this.df=e;const r=e.columns.toList();this.numCols=r.filter(t=>t.isNumerical),this.numColNames=this.numCols.map(t=>t.name),this.numColsCount=this.numCols.length,this.rowCount=e.rowCount,this.view=t.shell.getTableView(e.name),this.paretoFrontViewer=i.Viewer.fromType("Pareto front",e);const o=this.view.dockManager.dock(this.paretoFrontViewer,i.DOCK_TYPE.RIGHT,null,void 0,Nn.VIEWER);this.pcPlot=i.Viewer.pcPlot(e,{legendPosition:"Top"});const a=null!==(n=this.view.dockManager.findNode(this.view.grid.root))&&void 0!==n?n:o;this.pcPlotNode=this.view.dockManager.dock(this.pcPlot,i.DOCK_TYPE.DOWN,a,void 0,Nn.VIEWER),this.toUpdatePcCols=this.numColNames.length>10,this.resultColName=this.df.columns.getUnusedName(_n.OPT),this.showResultOptCol(),this.view.subs.push(...this.getSubscriptions())}isApplicable(){return this.rowCount<1?(t.shell.warning("Cannot compute Pareto front: the table is empty."),!1):!(this.numColsCount<2&&(t.shell.warning("Cannot compute Pareto front: at least two numeric columns are required."),1))}run(){this.isApplicable()&&(this.buildInputsForm(),this.computeParetoFront(),this.updateVisualization())}getSubscriptions(){return[this.paretoFrontViewer.onDetached.subscribe(()=>{null!==this.pcPlotNode&&(this.view.dockManager.close(this.pcPlotNode),this.pcPlotNode=null),null!==this.inputFormNode&&(this.view.dockManager.close(this.inputFormNode),this.inputFormNode=null),this.numCols.forEach(t=>t.colors.setDisabled()),this.features.clear()})]}buildInputsForm(){const t=e.form([]);t.classList.add("pareto-input-form"),t.append(e.h1("Optimize")),this.numCols.forEach((n,r)=>{const i={toOptimize:this.numColsCount-r-1<2,optType:En.MIN},o=n.name,a=e.input.choice(o,{value:i.toOptimize?i.optType:null,nullable:!0,items:[null,En.MIN,En.MAX],onValueChanged:t=>{null==t?i.toOptimize=!1:(i.toOptimize=!0,i.optType=t),this.computeParetoFront(),this.updateVisualization()}});e.tooltip.bind(a.input,()=>i.toOptimize?e.markdown(`M${i.optType.slice(1)} **${o}** during Pareto optimization`):e.markdown(`Ignore **${o}** during Pareto optimization`)),this.inputsMap.set(o,a),t.append(a.root),this.features.set(o,i)}),this.inputFormNode=this.view.dockManager.dock(t,i.DOCK_TYPE.LEFT,null,void 0,Nn.FORM)}computeParetoFront(){if(!this.toChangeParetoViewerOptions)return;const t=this.getMinMaxFeatureNames();this.paretoFrontViewer.setOptions({minimizeColumnNames:t.toMin,maximizeColumnNames:t.toMax})}updatePcPlot(t,e){if(this.pcPlot.setOptions(e),this.toUpdatePcCols){const e=this.pcPlot.getOptions().look.columnNames;let n=!1;if(t.forEach(t=>{e.includes(t)||(n=!0)}),n){const e=[...t],n=this.numColNames.filter(t=>!e.includes(t));e.push(...n.slice(0,10-t.length)),this.pcPlot.setOptions({columnNames:e})}}}updateVisualization(){const t=[];this.features.forEach((e,n)=>{e.toOptimize&&t.push(n)});const e={colorColumnName:t.length>0?this.resultColName:void 0};this.updatePcPlot(t,e),this.markOptColsWithColor(),this.updateTooltips()}showResultOptCol(){this.intervalId=setInterval(()=>{const t=this.view.grid.columns.byName(this.resultColName);null!==t&&(t.visible=!0,this.stopChecking())},1e3)}stopChecking(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null)}markOptColsWithColor(){this.numCols.forEach(t=>t.colors.setDisabled()),this.features.forEach((t,e)=>{if(!t.toOptimize)return;const n=this.df.col(e);null!=n&&n.colors.setLinear(Fn(t.optType),{min:n.stats.min,max:n.stats.max})})}updateTooltips(){const t=this.features;this.view.grid.onCellTooltip(function(n,r,o){if(n.isColHeader&&n.tableColumn){const a=n.tableColumn.name,s=t.get(a);if(void 0!==s){const t=[e.markdown(`**${a}**`)];return s.toOptimize&&(t.push(e.markdown(`This feature is **${s.optType}d** during Pareto optimization.`)),t.push(function(t){const n=e.label("Color scale:");n.style.paddingRight="7px";const r=[n],o=e.label("min"),a=e.label(". . ."),s=e.label("max"),u=Fn(t),c=[o,a,s].map((t,e)=>(1!==e&&(t.style.fontWeight="bold",t.style.color=i.Color.toRgb(u[e])),t.style.marginRight="5px",t));return r.push(...c),e.divH(r)}(s.optType))),e.tooltip.show(e.divV(t),r,o),!0}return!1}})}getMinMaxFeatureNames(){const t=[],e=[];return this.features.forEach((n,r)=>{n.toOptimize&&(n.optType===En.MIN?t.push(r):e.push(r))}),{toMin:t,toMax:e}}}class Rn extends i.JsViewer{get type(){return"ParetoFrontViewer"}constructor(){super(),this.autoLabelColNames=[],this.autoLabelsSelection=!0,this.toChangeAutoLabelsSelection=!0,this.toChangeAutoAxesSelection=!0,this.toChangeScatterMarkerSize=!1,this.colorColumnName=null,this.scatter=null,this.numCols=[],this.numColNames=[],this.numColsCount=0,this.rowCount=0,this.isApplicable=!1,this.errMsg="",this.resultColName="",this.sizeColName="",this.optimizedColNames=[],this.hasCommonMinMaxNames=!1,this.errDiv=null,this.missingValsIndices=new Map,this.toChangeScatterOptions=!0,this.title=this.string("title","Pareto front"),this.showTitle=this.bool("showTitle",!1,{category:"Description"}),this.description=this.string("description"),this.descriptionPosition=this.string("descriptionPosition","Top",{choices:["Left","Right","Top","Bottom"]}),this.descriptionVisibilityMode=this.string("descriptionVisibilityMode","Auto",{choices:["Auto","Always","Never"]}),this.minimizeColumnNames=this.addProperty("minimizeColumnNames",i.TYPE.COLUMN_LIST,null,{columnTypeFilter:i.TYPE.NUMERICAL,category:"Objectives",description:"Columns with features to be minimized during Pareto optimization."}),this.maximizeColumnNames=this.addProperty("maximizeColumnNames",i.TYPE.COLUMN_LIST,null,{columnTypeFilter:i.TYPE.NUMERICAL,category:"Objectives",description:"Columns with features to be maximized during Pareto optimization."}),this.xAxisColumnName=this.string("xAxisColumnName",null,{category:"Axes",description:"A column to be used on the X axis of the scatter plot.",nullable:!1}),this.yAxisColumnName=this.string("yAxisColumnName",null,{category:"Axes",description:"A column to be used on the Y axis of the scatter plot.",nullable:!1}),this.autoAxesSelection=this.bool("autoAxesSelection",Ln,{defaultValue:Ln,category:"Axes",description:"If checked, axes are selected automatically based on the optimized features. If unchecked, custom coordinate axes are used."}),this.labelColumnsColumnNames=this.addProperty("labelColumnsColumnNames",i.TYPE.COLUMN_LIST,null,{category:"Labels",description:"Label columns to show next to the markers."}),this.autoLabelsSelection=this.bool("autoLabelsSelection",Tn,{category:"Labels",description:"Select legend columns automatically; labels show unique categories.",defaultValue:Tn}),this.displayLabels=this.string("displayLabels","Auto",{choices:["Auto","Always","Never"],category:"Labels"}),this.legendVisibility=this.string("legendVisibility","Auto",{choices:["Auto","Always","Never"]}),this.legendPosition=this.string("legendPosition","Top",{choices:["Auto","Left","Right","Top","Bottom","RightTop","RightBottom","LeftTop","LeftBottom"]})}initializeData(){this.rowCount=this.dataFrame.rowCount;const t=this.dataFrame.columns,e=t.toList();this.numCols=e.filter(t=>t.isNumerical&&t.stats.missingValueCount<this.rowCount),this.numColNames=this.numCols.map(t=>t.name),this.numColsCount=this.numCols.length,this.isApplicable=this._testColumns(),this.isApplicable?(this.toChangeScatterMarkerSize=this.rowCount>5e3,this.resultColName=t.getUnusedName(_n.OPT),this.sizeColName=t.getUnusedName(_n.SIZE),this.missingValsIndices=Tt(this.numCols)):this._showErrorMessage(this.errMsg)}computeParetoFront(){if(!this.isApplicable)return;const t=[],e=[],n=new Set,r=(r,i)=>{null!=r&&r.forEach(r=>{t.push(this.dataFrame.col(r).getRawData()),e.push(i);const o=this.missingValsIndices.get(r);null!=o&&o.forEach(t=>n.add(t))})};r(this.minimizeColumnNames,En.MIN),r(this.maximizeColumnNames,En.MAX);const o=this.dataFrame.col(this.sizeColName);let a=this.dataFrame.col(this.resultColName);if(t.length>0){const r=function(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]===En.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],u=t[r][n];e[r]===En.MIN?(i>u&&(a=!1),i<u&&(s=!0)):(i<u&&(a=!1),i>u&&(s=!0))}if(a&&s){r=!0;break}}r?a[n]=!1:s.push(n)}return a}(t,e,this.rowCount,n),s=i.Column.fromStrings(this.resultColName,r.map(t=>t?Sn.OPTIMAL:Sn.NON_OPT));if(null==a)this.dataFrame.columns.add(s),a=s,this.hideCol(this.resultColName);else{const t=s.categories,e=s.getRawData(),n=a.getRawData(),r=a.categories,i=t.map(t=>r.indexOf(t));for(let t=0;t<this.rowCount;++t)n[t]=i[e[t]]}if(this.markResColWithColor(a),this.toChangeScatterMarkerSize)if(null==o)this.dataFrame.columns.add(i.Column.fromInt32Array(this.sizeColName,new Int32Array(r.map(t=>t?Mn.OPTIMAL:Mn.NON_OPT)))),this.hideCol(this.sizeColName);else{const t=o.getRawData();for(let e=0;e<this.rowCount;++e)t[e]=r[e]?Mn.OPTIMAL:Mn.NON_OPT}}else{if(null!=o){const t=o.getRawData();for(let e=0;e<this.rowCount;++e)t[e]=Mn.NON_OPT}if(null!=a){const t=a.getRawData(),e=a.categories.indexOf(Sn.NON_OPT);for(let n=0;n<this.rowCount;++n)t[n]=e}}}markResColWithColor(t){t.colors.setCategorical({optimal:"#2ca02c","non-optimal":"#e3e3e3"})}removeErrDiv(){null!=this.errDiv&&(this.root.removeChild(this.errDiv),this.errDiv=null)}_showErrorMessage(t){this.removeErrDiv(),this.errDiv=this.root.appendChild(e.divText(t,"d4-viewer-error"))}_testColumns(){return this.rowCount<1?(this.errMsg="Cannot compute Pareto front: the table is empty.",!1):!(this.numColsCount<2&&(this.errMsg="Cannot compute Pareto front: at least two non-empty numeric columns are required.",1))}setScatterOptions(){null!=this.scatter&&this.toChangeScatterOptions&&(this.toChangeScatterMarkerSize&&this.scatter.setOptions({markerMinSize:Mn.NON_OPT,markerMaxSize:Mn.OPTIMAL}),this.scatter.setOptions({title:this.title,showTitle:this.showTitle,legendVisibility:this.legendVisibility,legendPosition:this.legendPosition,colorColumnName:this.colorColumnName,displayLabels:this.displayLabels,sizeColumnName:this.toChangeScatterMarkerSize?this.sizeColName:null}),null!=this.labelColumnsColumnNames&&this.scatter.setOptions({labelColumnNames:this.labelColumnsColumnNames}))}onTableAttached(){if(this.initializeData(),this.isApplicable){this.scatter=i.Viewer.scatterPlot(this.dataFrame,{showColorSelector:!1,showSizeSelector:!1,autoLayout:!1,showLabels:"Always",markerType:i.MARKER_TYPE.CIRCLE}),this.root.append(this.scatter.root),this.autoLabelColNames=this.getLabelColNames(),this.subs.push(this.scatter.onDartPropertyChanged.subscribe(()=>this.checkScatterAxes()));const t=this.numColNames.filter((t,e)=>this.numColsCount-e-1<2);this.setOptions({maximizeColumnNames:[],minimizeColumnNames:t,xAxisColumnName:t[0],yAxisColumnName:t[1],autoAxesSelection:Ln,autoLabelsSelection:Tn})}this.subs.push(this.onDetached.subscribe(()=>this.removeResultingCols()))}checkScatterAxes(){if(null==this.scatter)return;let t=this.scatter.getOptions().look.xColumnName;t!==this.xAxisColumnName&&(this.toChangeScatterOptions=!1,this.setOptions({xAxisColumnName:t}),this.toChangeScatterOptions=!0),t=this.scatter.getOptions().look.yColumnName,t!==this.yAxisColumnName&&(this.toChangeScatterOptions=!1,this.setOptions({yAxisColumnName:t}),this.toChangeScatterOptions=!0)}removeResultingCols(){this.dataFrame.columns.remove(this.resultColName),this.dataFrame.columns.remove(this.sizeColName)}hideCol(t){const e=this.tableView;if(null==e)return;const n=e.grid.columns.byName(t);null!==n&&(n.visible=!1)}detach(){this.subs.forEach(t=>t.unsubscribe()),super.detach()}updateAutoAxesSelection(){this.toChangeAutoAxesSelection&&this.setOptions({autoAxesSelection:null}),this.toChangeAutoAxesSelection=!0}onPropertyChanged(t){var e,n;if(this.isApplicable){switch(t.name){case"minimizeColumnNames":case"maximizeColumnNames":this.updateCommonMinMaxFeatures();break;case"xAxisColumnName":null===(e=this.scatter)||void 0===e||e.setOptions({xColumnName:this.xAxisColumnName}),this.updateAutoAxesSelection();break;case"yAxisColumnName":null===(n=this.scatter)||void 0===n||n.setOptions({yColumnName:this.yAxisColumnName}),this.updateAutoAxesSelection();break;case"autoAxesSelection":this.updateAxesColumnOptions();break;case"autoLabelsSelection":this.updateLabelColumnOptions();break;case"labelColumnsColumnNames":this.toChangeAutoLabelsSelection&&this.setOptions({autoLabelsSelection:null}),this.toChangeAutoLabelsSelection=!0}this.render("minimizeColumnNames"===t.name||"maximizeColumnNames"===t.name)}}render(t=!1){if(!this.isApplicable||this.hasCommonMinMaxNames)return null!=this.scatter&&(this.scatter.root.hidden=!0),void this._showErrorMessage(this.errMsg);this.removeErrDiv(),t&&(this.computeParetoFront(),this.updateOptimizedColNames(),this.updateAxesColumnOptions(),this.colorColumnName=this.optimizedColNames.length<1?null:_n.OPT),this.setScatterOptions(),null!=this.scatter&&(this.scatter.root.hidden=!1)}updateCommonMinMaxFeatures(){if(null==this.minimizeColumnNames||null==this.maximizeColumnNames)return void(this.hasCommonMinMaxNames=!1);const t=this.minimizeColumnNames.filter(t=>this.maximizeColumnNames.includes(t));if(t.length>0){this.hasCommonMinMaxNames=!0;const e=t.map(t=>`"${t}"`).join(", ");this.errMsg=`Cannot minimize and maximize features at the same time: ${e}.`}else this.hasCommonMinMaxNames=!1}updateOptimizedColNames(){this.optimizedColNames=[],null!=this.minimizeColumnNames&&this.optimizedColNames.push(...this.minimizeColumnNames),null!=this.maximizeColumnNames&&this.optimizedColNames.push(...this.maximizeColumnNames)}updateAxesColumnOptions(){if(!this.autoAxesSelection)return;const t=this.optimizedColNames.length;if(t<1)return;const e=this.optimizedColNames.indexOf(this.xAxisColumnName),n=this.optimizedColNames.indexOf(this.yAxisColumnName);t>1?(e<0&&(this.toChangeAutoAxesSelection=!1,this.setOptions({xAxisColumnName:this.optimizedColNames[0!==n?0:1]})),n<0&&(this.toChangeAutoAxesSelection=!1,this.setOptions({yAxisColumnName:this.optimizedColNames[1!==e?1:0]}))):e<0&&n<0&&(this.toChangeAutoAxesSelection=!1,this.setOptions({xAxisColumnName:this.optimizedColNames[0]}))}updateLabelColumnOptions(){this.autoLabelsSelection&&(this.toChangeAutoLabelsSelection=!1,this.setOptions({labelColumnsColumnNames:[...this.autoLabelColNames]}))}getLabelColNames(){return this.dataFrame.columns.toList().filter(t=>t.type===i.COLUMN_TYPE.STRING&&t.categories.length===this.rowCount).map(t=>t.name)}}var Dn=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};function kn(){Hr.info()}function Un(){return Dn(this,void 0,void 0,function*(){yield Hr.init()})}function Gn(t,e,n,r,i){return Dn(this,void 0,void 0,function*(){return yield Hr.dbScan(t,e,n,r,i)})}function Vn(t,e,n,r,i){return Dn(this,void 0,void 0,function*(){yield Hr.PCA(t,e,n,r,i)})}function Bn(t,e,n,r){return Dn(this,void 0,void 0,function*(){yield Hr.dbscanPostProcessingFunction(t,e,n,r)})}function zn(t,e){return Hr.numberPreprocessingFunction(t,e)}function Wn(t,e){return Hr.stringPreprocessingFunction(t,e)}function jn(){return Dn(this,void 0,void 0,function*(){yield Hr.reduceDimensionality()})}function Hn(t){Hr.GetMCLEditor(t)}function Kn(t,e,n,r,i,o,a,s,u,c,l,h){return Dn(this,void 0,void 0,function*(){return yield Hr.MCLClustering(t,e,n,r,i,o,a,s,u,c,l,h)})}function qn(){return Hr.markovClusteringViewer()}function Yn(t,e,n,r,i){return Dn(this,void 0,void 0,function*(){return yield Hr.PLS(t,e,n,r,i)})}function $n(){return Dn(this,void 0,void 0,function*(){yield Hr.topMenuPLS()})}function Xn(){return Dn(this,void 0,void 0,function*(){yield Hr.MVA()})}function Qn(){return Dn(this,void 0,void 0,function*(){yield Hr.demoMultivariateAnalysis()})}function Jn(t,e,n){return Dn(this,void 0,void 0,function*(){return yield Hr.trainLinearKernelSVM(t,e,n)})}function Zn(t,e){return Dn(this,void 0,void 0,function*(){return yield Hr.applyLinearKernelSVM(t,e)})}function tr(t,e){return Dn(this,void 0,void 0,function*(){return yield Hr.isApplicableLinearKernelSVM(t,e)})}function er(t,e){return Dn(this,void 0,void 0,function*(){return yield Hr.isInteractiveLinearKernelSVM(t,e)})}function nr(t,e,n,r){return Dn(this,void 0,void 0,function*(){return yield Hr.visualizeLinearKernelSVM(t,e,n,r)})}function rr(t,e,n,r){return Dn(this,void 0,void 0,function*(){return yield Hr.trainRBFkernelSVM(t,e,n,r)})}function ir(t,e){return Dn(this,void 0,void 0,function*(){return yield Hr.applyRBFkernelSVM(t,e)})}function or(t,e){return Dn(this,void 0,void 0,function*(){return yield Hr.isApplicableRBFkernelSVM(t,e)})}function ar(t,e){return Dn(this,void 0,void 0,function*(){return yield Hr.isInteractiveRBFkernelSVM(t,e)})}function sr(t,e,n,r){return Dn(this,void 0,void 0,function*(){return yield Hr.visualizeRBFkernelSVM(t,e,n,r)})}function ur(t,e,n,r,i){return Dn(this,void 0,void 0,function*(){return yield Hr.trainPolynomialKernelSVM(t,e,n,r,i)})}function cr(t,e){return Dn(this,void 0,void 0,function*(){return yield Hr.applyPolynomialKernelSVM(t,e)})}function lr(t,e){return Dn(this,void 0,void 0,function*(){return yield Hr.isApplicablePolynomialKernelSVM(t,e)})}function hr(t,e){return Dn(this,void 0,void 0,function*(){return yield Hr.isInteractivePolynomialKernelSVM(t,e)})}function dr(t,e,n,r){return Dn(this,void 0,void 0,function*(){return yield Hr.visualizePolynomialKernelSVM(t,e,n,r)})}function fr(t,e,n,r,i){return Dn(this,void 0,void 0,function*(){return yield Hr.trainSigmoidKernelSVM(t,e,n,r,i)})}function pr(t,e){return Dn(this,void 0,void 0,function*(){return yield Hr.applySigmoidKernelSVM(t,e)})}function mr(t,e){return Dn(this,void 0,void 0,function*(){return yield Hr.isApplicableSigmoidKernelSVM(t,e)})}function gr(t,e){return Dn(this,void 0,void 0,function*(){return yield Hr.isInteractiveSigmoidKernelSVM(t,e)})}function yr(t,e,n,r){return Dn(this,void 0,void 0,function*(){return yield Hr.visualizeSigmoidKernelSVM(t,e,n,r)})}function vr(){Hr.anova()}function wr(){Hr.kNNImputation()}function br(t){return Dn(this,void 0,void 0,function*(){yield Hr.kNNImputationForTable(t)})}function Ar(t,e){return Dn(this,void 0,void 0,function*(){return yield Hr.trainLinearRegression(t,e)})}function Cr(t,e){return Hr.applyLinearRegression(t,e)}function Er(t,e){return Hr.isApplicableLinearRegression(t,e)}function Sr(t,e){return Hr.isInteractiveLinearRegression(t,e)}function Nr(t,e,n,r,i,o){return Dn(this,void 0,void 0,function*(){return yield Hr.trainSoftmax(t,e,n,r,i,o)})}function _r(t,e){return Hr.applySoftmax(t,e)}function Mr(t,e){return Hr.isApplicableSoftmax(t,e)}function Ir(t,e){return Hr.isInteractiveSoftmax(t,e)}function Pr(t,e,n){return Dn(this,void 0,void 0,function*(){return yield Hr.trainPLSRegression(t,e,n)})}function Lr(t,e){return Hr.applyPLSRegression(t,e)}function Tr(t,e){return Hr.isApplicablePLSRegression(t,e)}function Or(t,e,n,r){return Dn(this,void 0,void 0,function*(){return yield Hr.visualizePLSRegression(t,e,n,r)})}function Fr(t,e){return Hr.isInteractivePLSRegression(t,e)}function xr(t,e,n,r,i,o,a){return Dn(this,void 0,void 0,function*(){return yield Hr.trainXGBooster(t,e,n,r,i,o,a)})}function Rr(t,e){return Hr.applyXGBooster(t,e)}function Dr(t,e){return Hr.isInteractiveXGBooster(t,e)}function kr(t,e){return Hr.isApplicableXGBooster(t,e)}function Ur(){Hr.paretoFront()}function Gr(){return Hr.paretoFrontViewer()}var Vr=function(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a},Br=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},zr=function(t,e){return function(n,r){e(n,r,t)}},Wr=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};const jr=new i.Package;class Hr{static info(){t.shell.info(jr.webRoot)}static init(){return Wr(this,void 0,void 0,function*(){yield async function(){await initEDA()}(),yield async function(){await initXGBoostModule()}()})}static dbScan(t,e,n,r,o){return Wr(this,void 0,void 0,function*(){const a=e.getRawData(),s=n.getRawData(),u=yield Wt(a,s,r,o),c=t.columns.getUnusedName("Cluster (DBSCAN)"),l=i.Column.fromInt32Array(c,u);return t.columns.add(l),l})}static PCA(e,n,r,i,o){return Wr(this,void 0,void 0,function*(){try{const a=yield B(e,n,r,i,o);if(function(t,e){for(const t of e.toList())t.name="PC"+t.name}(0,a.columns),null===e.id)t.shell.addTableView(a);else{const t=e.columns,n=a.columns.toList();for(const e of n)a.columns.remove(e.name),e.name=t.getUnusedName(e.name),t.add(e)}}catch(e){t.shell.warning(`Failed to compute PCA: ${e instanceof Error?e.message:"platform issue"}`)}})}static dbscanPostProcessingFunction(e,n,r,o){return Wr(this,void 0,void 0,function*(){const a=e.dataFrame;if(null===a)return;const s=yield Hr.dbScan(a,e,n,r,o);a.changeColumnType(s,"string");const u=[e.name,n.name],c=t.shell.tableView(a.name);if(c)for(const t of c.viewers)if(t instanceof i.ScatterPlotViewer&&u.includes(t.props.xColumnName)&&u.includes(t.props.yColumnName))return void(t.props.colorColumnName=s.name)})}static numberPreprocessingFunction(t,e){const n=t.stats.max-t.stats.min;return{entries:t.toList(),options:{range:n}}}static stringPreprocessingFunction(t,e){return{entries:t.toList(),options:{}}}static reduceDimensionality(){return Wr(this,void 0,void 0,function*(){const r=new $e,o=e.dialog("Reduce Dimensionality").add(r.getEditor()).onOK(()=>Wr(this,void 0,void 0,function*(){const o=r.getParams();0!==o.columns.length&&(yield async function(r,o,a,s,u,c,l,h=!0,d=!1,f={preprocessingFuncArgs:[]},p={},m=null,g={},y){const v={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(o.length!==s.length||o.length!==c.length||o.length!==u.length||o.length!==f.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const w=h?p.tableView??t.shell.tableView(r.name)??t.shell.addTableView(r):null,b=async()=>{const b=i.TaskBarProgressIndicator.create(`Initializing ${p.scatterPlotName??"dimensionality reduction"} ...`);let A;try{const C=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}`)}(r);function E(t,n,s){let u=null,c=null;r.columns.names().includes(C[0])?(u=r.columns.byName(C[0]),c=r.columns.byName(C[1])):(u=r.columns.add(i.Column.float(C[0],r.rowCount)),c=r.columns.add(i.Column.float(C[1],r.rowCount)),h&&!A&&(A=w.scatterPlot({...v,x:C[0],y:C[1],title:p.scatterPlotName??en(o,a)}))),p["show-scatterplot-progress"]&&(A?.root&&e.setUpdateIndicator(A.root,!1),u.init(t=>s[0]?s[0][t]:void 0),c.init(t=>s[1]?s[1][t]:void 0));const l=t/n*100;b.update(l,`Running ${p.scatterPlotName??"dimensionality reduction"}... ${l.toFixed(0)}%`)}async function S(){r.columns.add(i.Column.float(C[0],r.rowCount)),r.columns.add(i.Column.float(C[1],r.rowCount));let d=null;h&&(A=w.scatterPlot({...v,x:C[0],y:C[1],title:p.scatterPlotName??en(o,a)}),e.setUpdateIndicator(A.root,!0));const m=t.events.onViewerClosed.subscribe(e=>{const n=e.args.viewer;n?.getOptions()?.look?.title&&A?.getOptions()?.look?.title&&n?.getOptions()?.look?.title===A?.getOptions()?.look?.title&&(t.events.fireCustomEvent(Ze,{}),m.unsubscribe(),d?.(),b.close())}),g=new Promise(async(e,i)=>{try{d=e;const i=[];let h=s,m=u,g=l;if(y&&o.every(t=>t.isNumerical)){const t=o.map(t=>t.toList()),e=new Array(r.rowCount).fill(0).map((t,e)=>new Float32Array(o.length));for(let n=0;n<o.length;++n)for(let i=0;i<r.rowCount;++i)e[i][n]=t[n][i];f.distanceFnArgs=[{}],i.push({entries:e,options:{}}),h=[y],m=[1],g="MANHATTAN"}else for(let t=0;t<c.length;++t){const e=c[t];if(f.distanceFnArgs||(f.distanceFnArgs=[]),e){const n=e.inputs[0].name,r=e.inputs[1].name,{entries:a,options:u}=await e.apply({[n]:o[t],[r]:s[t],...f.preprocessingFuncArgs[t]??{}});i.push({entries:a,options:u}),f.distanceFnArgs.push(u)}else{const e=o[t].toList(),n={};i.push({entries:e,options:n}),f.distanceFnArgs.push(n)}}e(await async function(e,r,i,o,a,s,u){let c=await async function(e,r,i,o,a,s,u){if(!s.distanceFnArgs)throw new Error("options.distanceFnArgs must be defined");if(e.length!==r.length||e.length!==s.distanceFnArgs.length||e.length!==o.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise(function(c,l){const h=new Worker(new URL(n.p+n.u(234),n.b));h.postMessage({columnsData:e,distanceMetrics:r,method:i,options:s,weights:o,aggregationMethod:a});const d=t.events.onCustomEvent(Ze).subscribe(()=>{try{h?.terminate()}finally{d.unsubscribe()}});h.onmessage=({data:{error:t,embedding:e,epochNum:n,epochsLength:r}})=>{tn(n)||tn(r)?(d.unsubscribe(),t?l(t):c(e),setTimeout(()=>h.terminate(),100)):u&&u(n,r,e)}})}(e,i,r,o,a,s,u);return c=c.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)),c}(i.map(t=>t.entries),a,h,m,l,f,p[ie]?void 0:E))}catch(t){i(t)}}),S=await g;return b.close(),m.unsubscribe(),S}const N=await S();if(d&&N){const _=i.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const M=await Wt(N[0],N[1],f.dbScanEpsilon??.01,f.dbScanMinPts??4),I=r.columns.getUnusedName("Cluster (DBSCAN)");r.columns.addNewString(I).init(t=>M[t].toString()),A&&(A.props.colorColumnName=I)}catch(P){t.shell.error("Clustering embeddings failed"),console.error(P)}finally{_.close()}}if(N){const L=r.columns.byName(C[0]),T=r.columns.byName(C[1]);if(L.init(t=>N[0][t]),T.init(t=>N[1][t]),m)try{const O=m.inputs[0].name,F=m.inputs[1].name;await m.prepare({[O]:L,[F]:T,...g}).call(!0)}catch(x){t.shell.error("Post-processing failed"),console.error(x)}if(A)return e.setUpdateIndicator(A.root,!1),A.helpUrl="/help/compute/sequence-space",A}}catch(R){t.shell.error("Dimensionality reduction failed"),console.error(R),b.close(),A&&e.setUpdateIndicator(A.root,!1)}};return new Promise(async(t,n)=>{try{if(p.fastRowCount&&r.rowCount>p.fastRowCount&&!p[ie])e.dialog().add(e.divText("Analysis might take several minutes. Do you want to continue?")).onOK(async()=>{try{const e=await b();t(e)}catch(t){n(t)}}).onCancel(()=>t(void 0)).show();else{const e=await b();t(e)}}catch(t){n(t)}})}(o.table,o.columns,o.methodName,o.distanceMetrics,o.weights,o.preprocessingFunctions,o.aggreaggregationMethod,!!o.plotEmbeddings,!!o.clusterEmbeddings,o.options,{fastRowCount:1e4},o.postProcessingFunction,o.postProcessingFunctionArgs,o.vectorDistanceMetric))})).show();o.helpUrl="https://datagrok.ai/help/explore/dim-reduction.md";const a=()=>{const t=r.columnsInput.value,e=o.getButton("OK");e&&(t&&0!==t.length?e.classList.remove("disabled"):e.classList.add("disabled"))};o.history(()=>({editorSettings:r.getStringInput()}),t=>r.applyStringInput(t.editorSettings)),r.onColumnsChanged.subscribe(()=>{try{a()}catch(t){console.error(t)}}),a()})}static GetMCLEditor(n){try{const t=new rn;e.dialog("Markov clustering").add(t.getEditor()).onOK(()=>Wr(this,void 0,void 0,function*(){const e=t.params;return n.func.prepare({df:e.table,cols:e.columns,metrics:e.distanceMetrics,weights:e.weights,aggregationMethod:e.aggreaggregationMethod,preprocessingFuncs:e.preprocessingFunctions,preprocessingFuncArgs:e.preprocessingFuncArgs,threshold:e.threshold,maxIterations:e.maxIterations,useWebGPU:e.useWebGPU,inflate:e.inflateFactor,minClusterSize:e.minClusterSize}).call(!0)})).show().history(()=>({editorSettings:t.getStringInput()}),e=>t.applyStringInput(e.editorSettings))}catch(e){const n=e instanceof Error?e.message:e.toString(),r=e instanceof Error?e.stack:void 0;t.shell.error(`Get region editor error: ${n}`),jr.logger.error(n,void 0,r)}}static MCLClustering(e,n,r,i,o,a,s){return Wr(this,arguments,void 0,function*(e,n,r,i,o,a,s,u=80,c=10,l=!1,h=0,d=5){var f;const p=null!==(f=t.shell.tableView(e.name))&&void 0!==f?f:t.shell.addTableView(e),m=JSON.stringify({cols:n.map(t=>t.name),metrics:r,weights:i,aggregationMethod:o,preprocessingFuncs:a.map(t=>{var e;return null!==(e=null==t?void 0:t.name)&&void 0!==e?e:null}),preprocessingFuncArgs:s,threshold:u,maxIterations:c,useWebGPU:l,inflate:h,minClusterSize:null!=d?d:5});return p.addViewer("MCL",{mclProps:m})})}static markovClusteringViewer(){return new an}static PLS(t,e,n,r,i){return Wr(this,void 0,void 0,function*(){return yield vt({table:t,features:e,predict:n,components:r,isQuadratic:!1,names:i})})}static topMenuPLS(){return Wr(this,void 0,void 0,function*(){yield wt(rt.COMPUTE_COMPONENTS)})}static MVA(){return Wr(this,void 0,void 0,function*(){yield wt(rt.PERFORM_MVA)})}static demoMultivariateAnalysis(){return Wr(this,void 0,void 0,function*(){yield function(){return mt(this,void 0,void 0,function*(){t.shell.addTableView(i.DataFrame.fromColumns([i.Column.fromStrings("model",["alfaromeo","audi","bmw","chevrolet","dodge1","dodge2","honda1","honda2","isuzu","jaguar","mazda","mercedes","mercury","mitsubishi","nissan1","nissan2","peugot","plymouth","porsche","saab","subaru","toyota1","toyota2","toyota3","toyota4","volkswagen1","volkswagen2","volvo1","volvo2","volvo3"]),i.Column.fromInt32Array("diesel",new Int32Array([0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,1,0,0,0,1])),i.Column.fromInt32Array("turbo",new Int32Array([0,0,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,1])),i.Column.fromInt32Array("two.doors",new Int32Array([1,0,1,0,1,0,1,0,0,0,0,0,1,1,0,1,0,0,1,0,0,1,0,1,0,1,0,0,0,0])),i.Column.fromInt32Array("hatchback",new Int32Array([1,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0])),i.Column.fromFloat32Array("wheel.base",new Float32Array([94.5,105.80000305175781,101.19999694824219,94.5,93.69999694824219,93.69999694824219,93.69999694824219,96.5,94.30000305175781,113,93.0999984741211,115.5999984741211,102.69999694824219,93.69999694824219,94.5,94.5,93.69999694824219,114.19999694824219,89.5,99.0999984741211,97.19999694824219,95.69999694824219,95.69999694824219,98.4000015258789,102.4000015258789,97.30000305175781,100.4000015258789,104.30000305175781,109.0999984741211,109.0999984741211])),i.Column.fromFloat32Array("length",new Float32Array([171.1999969482422,192.6999969482422,176.8000030517578,158.8000030517578,157.3000030517578,157.3000030517578,150,175.39999389648438,170.6999969482422,199.60000610351562,166.8000030517578,202.60000610351562,178.39999389648438,157.3000030517578,170.1999969482422,165.3000030517578,157.3000030517578,198.89999389648438,168.89999389648438,186.60000610351562,172,158.6999969482422,166.3000030517578,176.1999969482422,175.60000610351562,171.6999969482422,180.1999969482422,188.8000030517578,188.8000030517578,188.8000030517578])),i.Column.fromFloat32Array("width",new Float32Array([65.5,71.4000015258789,64.80000305175781,63.599998474121094,63.79999923706055,63.79999923706055,64,65.19999694824219,61.79999923706055,69.5999984741211,64.19999694824219,71.69999694824219,68,64.4000015258789,63.79999923706055,63.79999923706055,63.79999923706055,68.4000015258789,65,66.5,65.4000015258789,63.599998474121094,64.4000015258789,65.5999984741211,66.5,65.5,66.9000015258789,67.19999694824219,68.80000305175781,68.9000015258789])),i.Column.fromFloat32Array("height",new Float32Array([52.400001525878906,55.70000076293945,54.29999923706055,52,50.79999923706055,50.599998474121094,52.599998474121094,54.099998474121094,53.5,52.79999923706055,54.099998474121094,56.29999923706055,54.79999923706055,50.79999923706055,53.5,54.5,50.599998474121094,58.70000076293945,51.599998474121094,56.099998474121094,52.5,54.5,53,52,54.900001525878906,55.70000076293945,55.099998474121094,56.20000076293945,55.5,55.5])),i.Column.fromInt32Array("curb.weight",new Int32Array([2823,2844,2395,1909,2128,1967,1956,2304,2337,4066,1950,3770,2910,1918,2024,1951,1967,3430,2800,2695,2190,1985,2275,2551,2480,2261,2661,2912,3049,3217])),i.Column.fromInt32Array("eng.size",new Int32Array([152,136,108,90,98,90,92,110,111,258,91,183,140,92,97,97,90,152,194,121,108,92,110,146,110,97,136,141,141,145])),i.Column.fromInt32Array("horsepower",new Int32Array([154,110,101,70,102,68,76,86,78,176,68,123,175,68,69,69,68,95,207,110,82,62,56,116,73,52,110,114,160,106])),i.Column.fromInt32Array("peak.rpm",new Int32Array([5e3,5500,5800,5400,5500,5500,6e3,5800,4800,4750,5e3,4350,5e3,5500,5200,5200,5500,4150,5900,5250,4400,4800,4500,4800,4500,4800,5500,5400,5300,4800])),i.Column.fromInt32Array("symbol",new Int32Array([1,1,2,0,1,1,1,0,0,0,1,-1,1,2,1,1,1,0,3,2,0,1,0,2,-1,2,0,-2,-1,-1])),i.Column.fromInt32Array("city.mpg",new Int32Array([19,19,23,38,24,31,30,27,24,15,31,22,19,37,31,31,31,25,17,21,28,35,34,24,30,37,19,23,19,26])),i.Column.fromInt32Array("highway.mpg",new Int32Array([26,25,29,43,30,38,34,33,29,19,38,25,24,41,37,37,38,25,25,28,33,39,36,30,33,46,24,28,25,27])),i.Column.fromInt32Array("price",new Int32Array([16500,17710,16430,6575,7957,6229,7129,8845,6785,35550,7395,31600,16503,5389,7349,7299,6229,13860,37028,12170,7775,5348,7898,9989,10698,7775,13295,12940,19045,22470]))])),t.shell.windows.help.visible=!0,t.shell.windows.help.showHelp(e.markdown("# Data\nEach car has many features - patterns extraction is complicated.\n\n# Model\nPredict car price by its other features.\n\n# Try\nPress 'RUN' to perform multivariate analysis using partial least squares\n([PLS](https://en.wikipedia.org/wiki/Partial_least_squares_regression)) regression.\n\n# Essence\nThe method finds the latent factors that\n\n* capture the maximum variance in the features\n* maximize correlation with the response variable")),t.shell.windows.showContextPanel=!1,t.shell.windows.showProperties=!1,yield wt(rt.DEMO)})}()})}static trainLinearKernelSVM(t,e,n){return Wr(this,void 0,void 0,function*(){return J(yield X({gamma:n,kernel:0},t,e))})}static applyLinearKernelSVM(t,e){return Wr(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicableLinearKernelSVM(t,e){return Wr(this,void 0,void 0,function*(){return et(t,e)})}static isInteractiveLinearKernelSVM(t,e){return Wr(this,void 0,void 0,function*(){return nt(t)})}static visualizeLinearKernelSVM(t,e,n,r){return Wr(this,void 0,void 0,function*(){return Q(0,r)})}static trainRBFkernelSVM(t,e,n,r){return Wr(this,void 0,void 0,function*(){return J(yield X({gamma:n,kernel:2,sigma:r},t,e))})}static applyRBFkernelSVM(t,e){return Wr(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicableRBFkernelSVM(t,e){return Wr(this,void 0,void 0,function*(){return et(t,e)})}static isInteractiveRBFkernelSVM(t,e){return Wr(this,void 0,void 0,function*(){return nt(t)})}static visualizeRBFkernelSVM(t,e,n,r){return Wr(this,void 0,void 0,function*(){return Q(0,r)})}static trainPolynomialKernelSVM(t,e,n,r,i){return Wr(this,void 0,void 0,function*(){return J(yield X({gamma:n,kernel:1,cParam:r,dParam:i},t,e))})}static applyPolynomialKernelSVM(t,e){return Wr(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicablePolynomialKernelSVM(t,e){return Wr(this,void 0,void 0,function*(){return et(t,e)})}static isInteractivePolynomialKernelSVM(t,e){return Wr(this,void 0,void 0,function*(){return nt(t)})}static visualizePolynomialKernelSVM(t,e,n,r){return Wr(this,void 0,void 0,function*(){return Q(0,r)})}static trainSigmoidKernelSVM(t,e,n,r,i){return Wr(this,void 0,void 0,function*(){return J(yield X({gamma:n,kernel:3,kappa:r,theta:i},t,e))})}static applySigmoidKernelSVM(t,e){return Wr(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicableSigmoidKernelSVM(t,e){return Wr(this,void 0,void 0,function*(){return et(t,e)})}static isInteractiveSigmoidKernelSVM(t,e){return Wr(this,void 0,void 0,function*(){return nt(t)})}static visualizeSigmoidKernelSVM(t,e,n,r){return Wr(this,void 0,void 0,function*(){return Q(0,r)})}static anova(){zt()}static kNNImputation(){nn()}static kNNImputationForTable(t){return Wr(this,void 0,void 0,function*(){yield nn(t)})}static trainLinearRegression(t,e){return Wr(this,void 0,void 0,function*(){const n=t.columns,r=yield function(t,e){return sn(this,void 0,void 0,function*(){const n=t.length,r=e.length,o=e.stats.avg,a=e.stats.stdev,s=new Float32Array(n+1).fill(0);if(s[n]=o,0===a||1===r)return s;try{const r=[],u=[],c=new Float32Array(n),l=new Float32Array(n);let h=0,d=0;for(const e of t){const t=e.stats;t.stdev>0&&(r.push(h),u.push(e),c[d]=t.avg,l[d]=t.stdev,++d),++h}if(0===d)return s;const f=function(t,e,n,r,i,o,a){return g(EDA,"fitLinearRegressionParamsWithDataNormalizing",[t,e,n,r,i,o,a])}(i.DataFrame.fromColumns(u).columns,i.Column.fromFloat32Array("xAvgs",c,d),i.Column.fromFloat32Array("xStdevs",l,d),e,o,a,d+1).getRawData();for(let t=0;t<d;++t)s[r[t]]=f[t];s[n]=f[d]}catch(r){const o=yield function(t,e,n){return sn(this,void 0,void 0,function*(){return(yield vt({table:i.DataFrame.fromColumns([e]),features:t,predict:e,components:n,names:void 0,isQuadratic:!1})).regressionCoefficients.getRawData()})}(t,e,cn(t.length,e.length));let a=0;for(let e=0;e<n;++e)s[e]=o[e],a+=o[e]*t.byIndex(e).stats.avg;s[n]-=a}return s})}(n,e);return new Uint8Array(r.buffer)})}static applyLinearRegression(t,e){const n=t.columns,r=new Float32Array(e.buffer);return i.DataFrame.fromColumns([un(n,r)])}static isApplicableLinearRegression(t,e){for(const e of t.columns)if(!e.matches("numerical"))return!1;return e.matches("numerical")}static isInteractiveLinearRegression(t,e){return t.rowCount<=1e5}static trainSoftmax(t,e,n,r,i,o){return Wr(this,void 0,void 0,function*(){const a=t.columns,s=new gn({classesCount:e.categories.length,featuresCount:a.length});return yield s.fit(a,e,n,r,i,o),s.toBytes()})}static applySoftmax(t,e){const n=t.columns,r=new gn(void 0,e);return i.DataFrame.fromColumns([r.predict(n)])}static isApplicableSoftmax(t,e){return gn.isApplicable(t.columns,e)}static isInteractiveSoftmax(t,e){return gn.isInteractive(t.columns,e)}static trainPLSRegression(t,e,n){return Wr(this,void 0,void 0,function*(){const r=t.columns,i=new hn;return yield i.fit(r,e,Math.min(n,r.length)),i.toBytes()})}static applyPLSRegression(t,e){const n=new hn(e);return i.DataFrame.fromColumns([n.predict(t.columns)])}static isApplicablePLSRegression(t,e){return hn.isApplicable(t.columns,e)}static visualizePLSRegression(t,e,n,r){return Wr(this,void 0,void 0,function*(){return new hn(r).viewers().map(t=>t.root)})}static isInteractivePLSRegression(t,e){return hn.isInteractive(t.columns,e)}static trainXGBooster(t,e,n,r,i,o,a){return Wr(this,void 0,void 0,function*(){const s=t.columns,u=new Cn;return yield u.fit(s,e,n,r,i,o,a),u.toBytes()})}static applyXGBooster(t,e){const n=new Cn(e);return i.DataFrame.fromColumns([n.predict(t.columns)])}static isInteractiveXGBooster(t,e){return Cn.isInteractive(t.columns,e)}static isApplicableXGBooster(t,e){return Cn.isApplicable(t.columns,e)}static paretoFront(){const e=t.shell.t;null!==e?new xn(e).run():t.shell.warning("No dataframe is opened")}static paretoFrontViewer(){return new Rn}}Vr([t.decorators.func({name:"info"}),Br("design:type",Function),Br("design:paramtypes",[]),Br("design:returntype",void 0)],Hr,"info",null),Vr([t.decorators.init({}),Br("design:type",Function),Br("design:paramtypes",[]),Br("design:returntype",Promise)],Hr,"init",null),Vr([t.decorators.func({"top-menu":"ML | Cluster | DBSCAN...",name:"DBSCAN",description:"Density-based spatial clustering of applications with noise (DBSCAN)"}),zr(1,t.decorators.param({type:"column",options:{type:"numerical"}})),zr(2,t.decorators.param({type:"column",options:{type:"numerical"}})),zr(3,t.decorators.param({options:{caption:"Epsilon",initialValue:"0.02",description:"The maximum distance between two samples for them to be considered as in the same neighborhood."}})),zr(4,t.decorators.param({type:"int",options:{caption:"Minimum points",initialValue:"4",description:"The number of samples (or total weight) in a neighborhood for a point to be considered as a core point."}})),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column,i.Column,Number,Number]),Br("design:returntype",Promise)],Hr,"dbScan",null),Vr([t.decorators.func({"top-menu":"ML | Analyze | PCA...",description:"Principal component analysis (PCA)",helpUrl:"/help/explore/dim-reduction#pca"}),zr(0,t.decorators.param({type:"dataframe",options:{caption:"Table"}})),zr(1,t.decorators.param({type:"column_list",options:{type:"numerical",nullable:!1}})),zr(2,t.decorators.param({type:"int",options:{showPlusMinus:!0,caption:"Components",nullable:!1,min:"1",initialValue:"2",description:"Number of components."}})),zr(3,t.decorators.param({type:"bool",options:{caption:"Center",initialValue:"false",description:"Indicating whether the variables should be shifted to be zero centered."}})),zr(4,t.decorators.param({type:"bool",options:{caption:"Scale",initialValue:"false",description:"Indicating whether the variables should be scaled to have unit variance."}})),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.ColumnList,Number,Boolean,Boolean]),Br("design:returntype",Promise)],Hr,"PCA",null),Vr([t.decorators.func({meta:{defaultPostProcessingFunction:"true"},tags:["dim-red-postprocessing-function"],name:"DBSCAN clustering"}),zr(2,t.decorators.param({options:{initialValue:"0.01",description:"Minimum distance between two points to be considered as in the same neighborhood."}})),zr(3,t.decorators.param({type:"int",options:{initialValue:"5",description:"Minimum number of points to form a dense region."}})),Br("design:type",Function),Br("design:paramtypes",[i.Column,i.Column,Number,Number]),Br("design:returntype",Promise)],Hr,"dbscanPostProcessingFunction",null),Vr([t.decorators.func({meta:{supportedTypes:"int,float,double,qnum",supportedDistanceFunctions:"Difference"},tags:["dim-red-preprocessing-function"],name:"None (number)",outputs:[{name:"result",type:"object"}]}),zr(1,t.decorators.param({options:{optional:!0}})),Br("design:type",Function),Br("design:paramtypes",[i.Column,String]),Br("design:returntype",void 0)],Hr,"numberPreprocessingFunction",null),Vr([t.decorators.func({meta:{supportedTypes:"string",supportedDistanceFunctions:"One-Hot,Levenshtein,Hamming"},tags:["dim-red-preprocessing-function"],name:"None (string)",outputs:[{name:"result",type:"object"}]}),zr(1,t.decorators.param({options:{optional:!0}})),Br("design:type",Function),Br("design:paramtypes",[i.Column,String]),Br("design:returntype",void 0)],Hr,"stringPreprocessingFunction",null),Vr([t.decorators.func({"top-menu":"ML | Reduce Dimensionality...",name:"Multi Column Dimensionality Reduction"}),Br("design:type",Function),Br("design:paramtypes",[]),Br("design:returntype",Promise)],Hr,"reduceDimensionality",null),Vr([t.decorators.editor(),Br("design:type",Function),Br("design:paramtypes",[i.FuncCall]),Br("design:returntype",void 0)],Hr,"GetMCLEditor",null),Vr([t.decorators.func({"top-menu":"ML | Cluster | MCL...",name:"MCLClustering",description:"Markov clustering (MCL) is an unsupervised clustering algorithm for graphs based on simulation of stochastic flow.",editor:"EDA:GetMCLEditor",outputs:[]}),zr(2,t.decorators.param({type:"list<string>"})),zr(4,t.decorators.param({type:"string"})),zr(5,t.decorators.param({type:"list<func>"})),zr(6,t.decorators.param({type:"object"})),zr(7,t.decorators.param({type:"int",options:{initialValue:"80"}})),zr(8,t.decorators.param({type:"int",options:{initialValue:"10"}})),zr(9,t.decorators.param({type:"bool",options:{initialValue:"false"}})),zr(10,t.decorators.param({type:"double",options:{initialValue:"2"}})),zr(11,t.decorators.param({type:"int",options:{initialValue:"5"}})),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,Array,Array,Array,String,Array,Array,Number,Number,Boolean,Number,Number]),Br("design:returntype",Promise)],Hr,"MCLClustering",null),Vr([t.decorators.func({outputs:[{name:"result",type:"viewer"}],tags:["viewer"],meta:{showInGallery:"false"},name:"MCL",description:"Markov clustering viewer"}),Br("design:type",Function),Br("design:paramtypes",[]),Br("design:returntype",an)],Hr,"markovClusteringViewer",null),Vr([t.decorators.func({outputs:[{name:"plsResults",type:"object"}],description:"Compute partial least squares (PLS) regression analysis components: prediction, regression coefficients, T- & U-scores, X-loadings."}),zr(1,t.decorators.param({type:"column_list",options:{type:"numerical"}})),zr(2,t.decorators.param({type:"column",options:{type:"numerical"}})),zr(3,t.decorators.param({type:"int",options:{initialValue:"3"}})),zr(4,t.decorators.param({type:"column",options:{type:"string"}})),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.ColumnList,i.Column,Number,i.Column]),Br("design:returntype",Promise)],Hr,"PLS",null),Vr([t.decorators.func({"top-menu":"ML | Analyze | PLS...",description:"Compute partial least squares (PLS) regression components. They maximally summarize the variation of the predictors while maximizing correlation with the response variable."}),Br("design:type",Function),Br("design:paramtypes",[]),Br("design:returntype",Promise)],Hr,"topMenuPLS",null),Vr([t.decorators.func({"top-menu":"ML | Analyze | Multivariate Analysis...",name:"multivariateAnalysis",description:"Multidimensional data analysis using partial least squares (PLS) regression."}),Br("design:type",Function),Br("design:paramtypes",[]),Br("design:returntype",Promise)],Hr,"MVA",null),Vr([t.decorators.func({meta:{demoPath:"Compute | Multivariate Analysis"},name:"MVA demo",description:"Multidimensional data analysis using partial least squares (PLS) regression. It identifies latent factors and constructs a linear model based on them."}),Br("design:type",Function),Br("design:paramtypes",[]),Br("design:returntype",Promise)],Hr,"demoMultivariateAnalysis",null),Vr([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"train"}}),zr(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column,Number]),Br("design:returntype",Promise)],Hr,"trainLinearKernelSVM",null),Vr([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"apply"}}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,Object]),Br("design:returntype",Promise)],Hr,"applyLinearKernelSVM",null),Vr([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"isApplicable"}}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Promise)],Hr,"isApplicableLinearKernelSVM",null),Vr([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"isInteractive"}}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Promise)],Hr,"isInteractiveLinearKernelSVM",null),Vr([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"visualize"}}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column,i.Column,Object]),Br("design:returntype",Promise)],Hr,"visualizeLinearKernelSVM",null),Vr([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"train"}}),zr(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),zr(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.5"}})),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column,Number,Number]),Br("design:returntype",Promise)],Hr,"trainRBFkernelSVM",null),Vr([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"apply"}}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,Object]),Br("design:returntype",Promise)],Hr,"applyRBFkernelSVM",null),Vr([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"isApplicable"}}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Promise)],Hr,"isApplicableRBFkernelSVM",null),Vr([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"isInteractive"}}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Promise)],Hr,"isInteractiveRBFkernelSVM",null),Vr([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"visualize"}}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column,i.Column,Object]),Br("design:returntype",Promise)],Hr,"visualizeRBFkernelSVM",null),Vr([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"train"}}),zr(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),zr(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1"}})),zr(4,t.decorators.param({options:{category:"Hyperparameters",initialValue:"2"}})),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column,Number,Number,Number]),Br("design:returntype",Promise)],Hr,"trainPolynomialKernelSVM",null),Vr([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"apply"}}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,Object]),Br("design:returntype",Promise)],Hr,"applyPolynomialKernelSVM",null),Vr([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"isApplicable"}}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Promise)],Hr,"isApplicablePolynomialKernelSVM",null),Vr([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"isInteractive"}}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Promise)],Hr,"isInteractivePolynomialKernelSVM",null),Vr([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"visualize"},outputs:[{name:"widget",type:"dynamic"}],name:"visualizePolynomialKernelSVM"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column,i.Column,Object]),Br("design:returntype",Promise)],Hr,"visualizePolynomialKernelSVM",null),Vr([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"train"},name:"trainSigmoidKernelSVM"}),zr(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),zr(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1"}})),zr(4,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1"}})),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column,Number,Number,Number]),Br("design:returntype",Promise)],Hr,"trainSigmoidKernelSVM",null),Vr([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"apply"},name:"applySigmoidKernelSVM"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,Object]),Br("design:returntype",Promise)],Hr,"applySigmoidKernelSVM",null),Vr([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"isApplicable"},name:"isApplicableSigmoidKernelSVM"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Promise)],Hr,"isApplicableSigmoidKernelSVM",null),Vr([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"isInteractive"},name:"isInteractiveSigmoidKernelSVM"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Promise)],Hr,"isInteractiveSigmoidKernelSVM",null),Vr([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"visualize"},name:"visualizeSigmoidKernelSVM"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column,i.Column,Object]),Br("design:returntype",Promise)],Hr,"visualizeSigmoidKernelSVM",null),Vr([t.decorators.func({"top-menu":"ML | Analyze | ANOVA...",name:"ANOVA",description:"One-way analysis of variances (ANOVA) determines whether the examined factor has a significant impact on the explored feature."}),Br("design:type",Function),Br("design:paramtypes",[]),Br("design:returntype",void 0)],Hr,"anova",null),Vr([t.decorators.func({"top-menu":"ML | Impute Missing Values...",name:"KNN impute",description:"Missing values imputation using the k-nearest neighbors method (KNN)"}),Br("design:type",Function),Br("design:paramtypes",[]),Br("design:returntype",void 0)],Hr,"kNNImputation",null),Vr([t.decorators.func({name:"KNN imputation for a table",description:"Missing values imputation using the k-nearest neighbors method"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame]),Br("design:returntype",Promise)],Hr,"kNNImputationForTable",null),Vr([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"train"},name:"trainLinearRegression",outputs:[{type:"dynamic",name:"model"}]}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Promise)],Hr,"trainLinearRegression",null),Vr([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"apply"},name:"applyLinearRegression"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,Object]),Br("design:returntype",i.DataFrame)],Hr,"applyLinearRegression",null),Vr([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"isApplicable"},name:"isApplicableLinearRegression"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Boolean)],Hr,"isApplicableLinearRegression",null),Vr([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"isInteractive"},name:"isInteractiveLinearRegression"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Boolean)],Hr,"isInteractiveLinearRegression",null),Vr([t.decorators.func({meta:{mlname:"Softmax",mlrole:"train"},name:"trainSoftmax",outputs:[{type:"dynamic",name:"model"}]}),zr(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0",min:"0.001",max:"20",description:"Learning rate."}})),zr(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"100",min:"1",max:"10000",step:"10",description:"Fitting iterations count"}})),zr(4,t.decorators.param({options:{category:"Hyperparameters",initialValue:"0.1",min:"0.0001",max:"1",description:"Regularization rate."}})),zr(5,t.decorators.param({options:{category:"Hyperparameters",initialValue:"0.001",min:"0.00001",max:"0.1",description:"Fitting tolerance."}})),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column,Number,Number,Number,Number]),Br("design:returntype",Promise)],Hr,"trainSoftmax",null),Vr([t.decorators.func({meta:{mlname:"Softmax",mlrole:"apply"},name:"applySoftmax"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,Object]),Br("design:returntype",i.DataFrame)],Hr,"applySoftmax",null),Vr([t.decorators.func({meta:{mlname:"Softmax",mlrole:"isApplicable"},name:"isApplicableSoftmax"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Boolean)],Hr,"isApplicableSoftmax",null),Vr([t.decorators.func({meta:{mlname:"Softmax",mlrole:"isInteractive"},name:"isInteractiveSoftmax"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Boolean)],Hr,"isInteractiveSoftmax",null),Vr([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"train"},name:"trainPLSRegression",outputs:[{name:"model",type:"dynamic"}]}),zr(2,t.decorators.param({type:"int",options:{min:"1",max:"10",initialValue:"3",description:"Number of latent components."}})),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column,Number]),Br("design:returntype",Promise)],Hr,"trainPLSRegression",null),Vr([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"apply"},name:"applyPLSRegression"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,Object]),Br("design:returntype",i.DataFrame)],Hr,"applyPLSRegression",null),Vr([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"isApplicable"},name:"isApplicablePLSRegression"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Boolean)],Hr,"isApplicablePLSRegression",null),Vr([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"visualize"},name:"visualizePLSRegression"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column,i.Column,Object]),Br("design:returntype",Promise)],Hr,"visualizePLSRegression",null),Vr([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"isInteractive"},name:"isInteractivePLSRegression"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Boolean)],Hr,"isInteractivePLSRegression",null),Vr([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"train"},name:"trainXGBooster",outputs:[{name:"model",type:"dynamic"}]}),zr(2,t.decorators.param({type:"int",options:{min:"1",max:"100",initialValue:"20",description:"Number of training iterations."}})),zr(3,t.decorators.param({type:"double",options:{caption:"Rate",min:"0",max:"1",initialValue:"0.3",description:"Learning rate."}})),zr(4,t.decorators.param({type:"int",options:{min:"0",max:"20",initialValue:"6",description:"Maximum depth of a tree."}})),zr(5,t.decorators.param({type:"double",options:{min:"0",max:"100",initialValue:"1",description:"L2 regularization term."}})),zr(6,t.decorators.param({type:"double",options:{min:"0",max:"100",initialValue:"0",description:"L1 regularization term."}})),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column,Number,Number,Number,Number,Number]),Br("design:returntype",Promise)],Hr,"trainXGBooster",null),Vr([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"apply"},name:"applyXGBooster"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,Object]),Br("design:returntype",i.DataFrame)],Hr,"applyXGBooster",null),Vr([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"isInteractive"},name:"isInteractiveXGBooster"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Boolean)],Hr,"isInteractiveXGBooster",null),Vr([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"isApplicable"},name:"isApplicableXGBooster"}),Br("design:type",Function),Br("design:paramtypes",[i.DataFrame,i.Column]),Br("design:returntype",Boolean)],Hr,"isApplicableXGBooster",null),Vr([t.decorators.func({"top-menu":"ML | Pareto Front...",name:"Pareto Front",description:"Perform optimization across multiple objectives: analyze trade-offs between conflicting objectives and identify Pareto-optimal points."}),Br("design:type",Function),Br("design:paramtypes",[]),Br("design:returntype",void 0)],Hr,"paretoFront",null),Vr([t.decorators.func({name:"Pareto front",description:"Pareto front viewer",tags:["viewer"],outputs:[{name:"result",type:"viewer"}],meta:{icon:"icons/pareto-front-viewer.svg"}}),Br("design:type",Function),Br("design:paramtypes",[]),Br("design:returntype",i.Viewer)],Hr,"paretoFrontViewer",null)})(),eda=r})();
|
|
1
|
+
var eda;(()=>{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,i=4*n;let r=t.height;do{const t=(r-1)*i;let o=n;do{const n=t+4*(o-1);let i=e[n],r=e[n+1],a=e[n+2];i>127&&(i=255-i),r>127&&(r=255-r),a>127&&(a=255-a),e[n]=i,e[n+1]=r,e[n+2]=a}while(--o)}while(--r)}},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 i=n(4892),r=n(6536),o=n(5483);e.Threshold=function(t){const e=255*this.threshold(),n=t.data,i=n.length;for(let t=0;t<i;t+=1)n[t]=n[t]<e?0:255},i.Factory.addGetterSetter(r.Node,"threshold",.5,(0,o.getNumberValidator)(),i.Factory.afterSetFilter)},680:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Konva=void 0;const i=n(8871),r=n(4060),o=n(6536),a=n(4473),s=n(7324),l=n(6267),c=n(7457),u=n(7949),h=n(1268),d=n(4723),f=n(9696),p=n(8665),g=n(9869),m=n(8604);e.Konva=r.Util._assign(i.Konva,{Util:r.Util,Transform:r.Transform,Node:o.Node,Container:a.Container,Stage:s.Stage,stages:s.stages,Layer:l.Layer,FastLayer:c.FastLayer,Group:u.Group,DD:h.DD,Shape:d.Shape,shapes:d.shapes,Animation:f.Animation,Tween:p.Tween,Easings:p.Easings,Context:g.Context,Canvas:m.Canvas}),e.default=e.Konva},934:function(t){t.exports=function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,i(t,e)}function n(t){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function r(t,e,n){return r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&i(o,n.prototype),o},r.apply(null,arguments)}function o(t){var e="function"==typeof Map?new Map:void 0;return o=function(t){if(null===t||(o=t,-1===Function.toString.call(o).indexOf("[native code]")))return t;var o;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,a)}function a(){return r(t,arguments,n(this).constructor)}return a.prototype=Object.create(t.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),i(a,t)},o(t)}function a(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var s=function(){for(var t=arguments[0],e=1,n=arguments.length;e<n;e++)if(arguments[e])for(var i in arguments[e])t[i]=arguments[e][i];return t};function l(t,e,n,i){var r=t._nodes.get(e),o=null;return r?o="mixed"===i?r.out&&r.out[n]||r.undirected&&r.undirected[n]:"directed"===i?r.out&&r.out[n]:r.undirected&&r.undirected[n]:o}function c(e){return"object"===t(e)&&null!==e}function u(t){var e;for(e in t)return!1;return!0}function h(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function d(t,e,n){var i={enumerable:!0,configurable:!0};"function"==typeof n?i.get=n:(i.value=n,i.writable=!1),Object.defineProperty(t,e,i)}function f(t){return!(!c(t)||t.attributes&&!Array.isArray(t.attributes))}"function"==typeof Object.assign&&(s=Object.assign);var p,g={exports:{}},m="object"==typeof Reflect?Reflect:null,y=m&&"function"==typeof m.apply?m.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};p=m&&"function"==typeof m.ownKeys?m.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var v=Number.isNaN||function(t){return t!=t};function w(){w.init.call(this)}g.exports=w,g.exports.once=function(t,e){return new Promise(function(n,i){function r(n){t.removeListener(e,o),i(n)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",r),n([].slice.call(arguments))}N(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&N(t,"error",e,{once:!0})}(t,r)})},w.EventEmitter=w,w.prototype._events=void 0,w.prototype._eventsCount=0,w.prototype._maxListeners=void 0;var b=10;function C(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function _(t){return void 0===t._maxListeners?w.defaultMaxListeners:t._maxListeners}function A(t,e,n,i){var r,o,a,s;if(C(n),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),a=o[e]),void 0===a)a=o[e]=n,++t._eventsCount;else if("function"==typeof a?a=o[e]=i?[n,a]:[a,n]:i?a.unshift(n):a.push(n),(r=_(t))>0&&a.length>r&&!a.warned){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=a.length,s=l,console&&console.warn&&console.warn(s)}return t}function S(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function E(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},r=S.bind(i);return r.listener=n,i.wrapFn=r,r}function x(t,e,n){var i=t._events;if(void 0===i)return[];var r=i[e];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(r):P(r,r.length)}function M(t){var e=this._events;if(void 0!==e){var n=e[t];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function P(t,e){for(var n=new Array(e),i=0;i<e;++i)n[i]=t[i];return n}function N(t,e,n,i){if("function"==typeof t.on)i.once?t.once(e,n):t.on(e,n);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function r(o){i.once&&t.removeEventListener(e,r),n(o)})}}function T(t){if("function"!=typeof t)throw new Error("obliterator/iterator: expecting a function!");this.next=t}Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return b},set:function(t){if("number"!=typeof t||t<0||v(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");b=t}}),w.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},w.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||v(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},w.prototype.getMaxListeners=function(){return _(this)},w.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var i="error"===t,r=this._events;if(void 0!==r)i=i&&void 0===r.error;else if(!i)return!1;if(i){var o;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var s=r[t];if(void 0===s)return!1;if("function"==typeof s)y(s,this,e);else{var l=s.length,c=P(s,l);for(n=0;n<l;++n)y(c[n],this,e)}return!0},w.prototype.addListener=function(t,e){return A(this,t,e,!1)},w.prototype.on=w.prototype.addListener,w.prototype.prependListener=function(t,e){return A(this,t,e,!0)},w.prototype.once=function(t,e){return C(e),this.on(t,E(this,t,e)),this},w.prototype.prependOnceListener=function(t,e){return C(e),this.prependListener(t,E(this,t,e)),this},w.prototype.removeListener=function(t,e){var n,i,r,o,a;if(C(e),void 0===(i=this._events))return this;if(void 0===(n=i[t]))return this;if(n===e||n.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(r=-1,o=n.length-1;o>=0;o--)if(n[o]===e||n[o].listener===e){a=n[o].listener,r=o;break}if(r<0)return this;0===r?n.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(n,r),1===n.length&&(i[t]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",t,a||e)}return this},w.prototype.off=w.prototype.removeListener,w.prototype.removeAllListeners=function(t){var e,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[t]),this;if(0===arguments.length){var r,o=Object.keys(n);for(i=0;i<o.length;++i)"removeListener"!==(r=o[i])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(void 0!==e)for(i=e.length-1;i>=0;i--)this.removeListener(t,e[i]);return this},w.prototype.listeners=function(t){return x(this,t,!0)},w.prototype.rawListeners=function(t){return x(this,t,!1)},w.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):M.call(t,e)},w.prototype.listenerCount=M,w.prototype.eventNames=function(){return this._eventsCount>0?p(this._events):[]},"undefined"!=typeof Symbol&&(T.prototype[Symbol.iterator]=function(){return this}),T.of=function(){var t=arguments,e=t.length,n=0;return new T(function(){return n>=e?{done:!0}:{done:!1,value:t[n++]}})},T.empty=function(){return new T(function(){return{done:!0}})},T.fromSequence=function(t){var e=0,n=t.length;return new T(function(){return e>=n?{done:!0}:{done:!1,value:t[e++]}})},T.is=function(t){return t instanceof T||"object"==typeof t&&null!==t&&"function"==typeof t.next};var F=T,I={};I.ARRAY_BUFFER_SUPPORT="undefined"!=typeof ArrayBuffer,I.SYMBOL_SUPPORT="undefined"!=typeof Symbol;var L=F,O=I,R=O.ARRAY_BUFFER_SUPPORT,D=O.SYMBOL_SUPPORT,k=function(t){var e=function(t){return"string"==typeof t||Array.isArray(t)||R&&ArrayBuffer.isView(t)?L.fromSequence(t):"object"!=typeof t||null===t?null:D&&"function"==typeof t[Symbol.iterator]?t[Symbol.iterator]():"function"==typeof t.next?t:null}(t);if(!e)throw new Error("obliterator: target is not iterable nor a valid iterator.");return e},G=k,U=function(t,e){for(var n,i=arguments.length>1?e:1/0,r=i!==1/0?new Array(i):[],o=0,a=G(t);;){if(o===i)return r;if((n=a.next()).done)return o!==e&&(r.length=o),r;r[o++]=n.value}},B=function(t){function n(e){var n;return(n=t.call(this)||this).name="GraphError",n.message=e,n}return e(n,t),n}(o(Error)),V=function(t){function n(e){var i;return(i=t.call(this,e)||this).name="InvalidArgumentsGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a(i),n.prototype.constructor),i}return e(n,t),n}(B),z=function(t){function n(e){var i;return(i=t.call(this,e)||this).name="NotFoundGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a(i),n.prototype.constructor),i}return e(n,t),n}(B),W=function(t){function n(e){var i;return(i=t.call(this,e)||this).name="UsageGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a(i),n.prototype.constructor),i}return e(n,t),n}(B);function H(t,e){this.key=t,this.attributes=e,this.clear()}function j(t,e){this.key=t,this.attributes=e,this.clear()}function K(t,e){this.key=t,this.attributes=e,this.clear()}function Y(t,e,n,i,r){this.key=e,this.attributes=r,this.undirected=t,this.source=n,this.target=i}function q(t,e,n,i,r,o,a){var s,l,c,u;if(i=""+i,0===n){if(!(s=t._nodes.get(i)))throw new z("Graph.".concat(e,': could not find the "').concat(i,'" node in the graph.'));c=r,u=o}else if(3===n){if(r=""+r,!(l=t._edges.get(r)))throw new z("Graph.".concat(e,': could not find the "').concat(r,'" edge in the graph.'));var h=l.source.key,d=l.target.key;if(i===h)s=l.target;else{if(i!==d)throw new z("Graph.".concat(e,': the "').concat(i,'" node is not attached to the "').concat(r,'" edge (').concat(h,", ").concat(d,")."));s=l.source}c=o,u=a}else{if(!(l=t._edges.get(i)))throw new z("Graph.".concat(e,': could not find the "').concat(i,'" edge in the graph.'));s=1===n?l.source:l.target,c=r,u=o}return[s,c,u]}H.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},j.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},K.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},Y.prototype.attach=function(){var t="out",e="in";this.undirected&&(t=e="undirected");var n=this.source.key,i=this.target.key;this.source[t][i]=this,this.undirected&&n===i||(this.target[e][n]=this)},Y.prototype.attachMulti=function(){var t="out",e="in",n=this.source.key,i=this.target.key;this.undirected&&(t=e="undirected");var r=this.source[t],o=r[i];if(void 0===o)return r[i]=this,void(this.undirected&&n===i||(this.target[e][n]=this));o.previous=this,this.next=o,r[i]=this,this.target[e][n]=this},Y.prototype.detach=function(){var t=this.source.key,e=this.target.key,n="out",i="in";this.undirected&&(n=i="undirected"),delete this.source[n][e],delete this.target[i][t]},Y.prototype.detachMulti=function(){var t=this.source.key,e=this.target.key,n="out",i="in";this.undirected&&(n=i="undirected"),void 0===this.previous?void 0===this.next?(delete this.source[n][e],delete this.target[i][t]):(this.next.previous=void 0,this.source[n][e]=this.next,this.target[i][t]=this.next):(this.previous.next=this.next,void 0!==this.next&&(this.next.previous=this.previous))};var X=[{name:function(t){return"get".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,r){var o=q(this,e,n,t,i,r),a=o[0],s=o[1];return a.attributes[s]}}},{name:function(t){return"get".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i){return q(this,e,n,t,i)[0].attributes}}},{name:function(t){return"has".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,r){var o=q(this,e,n,t,i,r),a=o[0],s=o[1];return a.attributes.hasOwnProperty(s)}}},{name:function(t){return"set".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,r,o){var a=q(this,e,n,t,i,r,o),s=a[0],l=a[1],c=a[2];return s.attributes[l]=c,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}},{name:function(t){return"update".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,r,o){var a=q(this,e,n,t,i,r,o),s=a[0],l=a[1],c=a[2];if("function"!=typeof c)throw new V("Graph.".concat(e,": updater should be a function."));var u=s.attributes,h=c(u[l]);return u[l]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}},{name:function(t){return"remove".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,r){var o=q(this,e,n,t,i,r),a=o[0],s=o[1];return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}},{name:function(t){return"replace".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i,r){var o=q(this,e,n,t,i,r),a=o[0],s=o[1];if(!c(s))throw new V("Graph.".concat(e,": provided attributes are not a plain object."));return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}},{name:function(t){return"merge".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i,r){var o=q(this,e,n,t,i,r),a=o[0],l=o[1];if(!c(l))throw new V("Graph.".concat(e,": provided attributes are not a plain object."));return s(a.attributes,l),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:l}),this}}},{name:function(t){return"update".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i,r){var o=q(this,e,n,t,i,r),a=o[0],s=o[1];if("function"!=typeof s)throw new V("Graph.".concat(e,": provided updater is not a function."));return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}}],$=[{name:function(t){return"get".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+i;if(i=arguments[2],!(r=l(this,o,a,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(r=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return r.attributes[i]}}},{name:function(t){return"get".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var r=""+t,o=""+arguments[1];if(!(i=l(this,r,o,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(r,'" - "').concat(o,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return i.attributes}}},{name:function(t){return"has".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+i;if(i=arguments[2],!(r=l(this,o,a,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(r=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return r.attributes.hasOwnProperty(i)}}},{name:function(t){return"set".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var a=""+t,s=""+i;if(i=arguments[2],r=arguments[3],!(o=l(this,a,s,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(a,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(o=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return o.attributes[i]=r,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}},{name:function(t){return"update".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var a=""+t,s=""+i;if(i=arguments[2],r=arguments[3],!(o=l(this,a,s,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(a,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(o=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if("function"!=typeof r)throw new V("Graph.".concat(e,": updater should be a function."));return o.attributes[i]=r(o.attributes[i]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}},{name:function(t){return"remove".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+i;if(i=arguments[2],!(r=l(this,o,a,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(r=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return delete r.attributes[i],this.emit("edgeAttributesUpdated",{key:r.key,type:"remove",attributes:r.attributes,name:i}),this}}},{name:function(t){return"replace".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+i;if(i=arguments[2],!(r=l(this,o,a,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(r=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if(!c(i))throw new V("Graph.".concat(e,": provided attributes are not a plain object."));return r.attributes=i,this.emit("edgeAttributesUpdated",{key:r.key,type:"replace",attributes:r.attributes}),this}}},{name:function(t){return"merge".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+i;if(i=arguments[2],!(r=l(this,o,a,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(r=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if(!c(i))throw new V("Graph.".concat(e,": provided attributes are not a plain object."));return s(r.attributes,i),this.emit("edgeAttributesUpdated",{key:r.key,type:"merge",attributes:r.attributes,data:i}),this}}},{name:function(t){return"update".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,i){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new W("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+i;if(i=arguments[2],!(r=l(this,o,a,n)))throw new z("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new W("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(r=this._edges.get(t)))throw new z("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if("function"!=typeof i)throw new V("Graph.".concat(e,": provided updater is not a function."));return r.attributes=i(r.attributes),this.emit("edgeAttributesUpdated",{key:r.key,type:"update",attributes:r.attributes}),this}}}],Q=F,J=k,Z=function(){var t=arguments,e=null,n=-1;return new Q(function(){for(var i=null;;){if(null===e){if(++n>=t.length)return{done:!0};e=J(t[n])}if(!0!==(i=e.next()).done)break;e=null}return i})},tt=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function et(t,e,n,i){var r=!1;for(var o in e)if(o!==i){var a=e[o];if(r=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),t&&r)return a.key}}function nt(t,e,n,i){var r,o,a,s=!1;for(var l in e)if(l!==i){r=e[l];do{if(o=r.source,a=r.target,s=n(r.key,r.attributes,o.key,a.key,o.attributes,a.attributes,r.undirected),t&&s)return r.key;r=r.next}while(void 0!==r)}}function it(t,e){var n,i=Object.keys(t),r=i.length,o=0;return new F(function(){do{if(n)n=n.next;else{if(o>=r)return{done:!0};var a=i[o++];if(a===e){n=void 0;continue}n=t[a]}}while(!n);return{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}}})}function rt(t,e,n,i){var r=e[n];if(r){var o=r.source,a=r.target;return i(r.key,r.attributes,o.key,a.key,o.attributes,a.attributes,r.undirected)&&t?r.key:void 0}}function ot(t,e,n,i){var r=e[n];if(r){var o=!1;do{if(o=i(r.key,r.attributes,r.source.key,r.target.key,r.source.attributes,r.target.attributes,r.undirected),t&&o)return r.key;r=r.next}while(void 0!==r)}}function at(t,e){var n=t[e];return void 0!==n.next?new F(function(){if(!n)return{done:!0};var t={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:t}}):F.of({edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected})}function st(t,e,n,i){if(0!==e.size)for(var r,o,a="mixed"!==n&&n!==e.type,s="undirected"===n,l=!1,c=e._edges.values();!0!==(r=c.next()).done;)if(o=r.value,!a||o.undirected===s){var u=o,h=u.key,d=u.attributes,f=u.source,p=u.target;if(l=i(h,d,f.key,p.key,f.attributes,p.attributes,o.undirected),t&&l)return h}}function lt(t,e,n,i,r,o){var a,s=e?nt:et;if("undirected"!==n){if("out"!==i&&(a=s(t,r.in,o),t&&a))return a;if("in"!==i&&(a=s(t,r.out,o,i?void 0:r.key),t&&a))return a}if("directed"!==n&&(a=s(t,r.undirected,o),t&&a))return a}function ct(t,e,n,i,r,o,a){var s,l=n?ot:rt;if("undirected"!==e){if(void 0!==r.in&&"out"!==i&&(s=l(t,r.in,o,a),t&&s))return s;if(void 0!==r.out&&"in"!==i&&(i||r.key!==o)&&(s=l(t,r.out,o,a),t&&s))return s}if("directed"!==e&&void 0!==r.undirected&&(s=l(t,r.undirected,o,a),t&&s))return s}var ut=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function ht(){this.A=null,this.B=null}function dt(t,e,n,i,r){for(var o in i){var a=i[o],s=a.source,l=a.target,c=s===n?l:s;if(!e||!e.has(c.key)){var u=r(c.key,c.attributes);if(t&&u)return c.key}}}function ft(t,e,n,i,r){if("mixed"!==e){if("undirected"===e)return dt(t,null,i,i.undirected,r);if("string"==typeof n)return dt(t,null,i,i[n],r)}var o,a=new ht;if("undirected"!==e){if("out"!==n){if(o=dt(t,null,i,i.in,r),t&&o)return o;a.wrap(i.in)}if("in"!==n){if(o=dt(t,a,i,i.out,r),t&&o)return o;a.wrap(i.out)}}if("directed"!==e&&(o=dt(t,a,i,i.undirected,r),t&&o))return o}function pt(t,e,n){var i=Object.keys(n),r=i.length,o=0;return new F(function(){var a=null;do{if(o>=r)return t&&t.wrap(n),{done:!0};var s=n[i[o++]],l=s.source,c=s.target;a=l===e?c:l,t&&t.has(a.key)&&(a=null)}while(null===a);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}})}function gt(t,e,n,i,r){for(var o,a,s,l,c,u,h,d=i._nodes.values(),f=i.type;!0!==(o=d.next()).done;){var p=!1;if(a=o.value,"undirected"!==f)for(s in l=a.out){c=l[s];do{if(u=c.target,p=!0,h=r(a.key,u.key,a.attributes,u.attributes,c.key,c.attributes,c.undirected),t&&h)return c;c=c.next}while(c)}if("directed"!==f)for(s in l=a.undirected)if(!(e&&a.key>s)){c=l[s];do{if((u=c.target).key!==s&&(u=c.source),p=!0,h=r(a.key,u.key,a.attributes,u.attributes,c.key,c.attributes,c.undirected),t&&h)return c;c=c.next}while(c)}if(n&&!p&&(h=r(a.key,null,a.attributes,null,null,null,null),t&&h))return null}}function mt(t){if(!c(t))throw new V('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in t))throw new V("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new V("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function yt(t){if(!c(t))throw new V('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in t))throw new V("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new V("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new V("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&"boolean"!=typeof t.undirected)throw new V("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}ht.prototype.wrap=function(t){null===this.A?this.A=t:null===this.B&&(this.B=t)},ht.prototype.has=function(t){return null!==this.A&&t in this.A||null!==this.B&&t in this.B};var vt,wt=(vt=255&Math.floor(256*Math.random()),function(){return vt++}),bt=new Set(["directed","undirected","mixed"]),Ct=new Set(["domain","_events","_eventsCount","_maxListeners"]),_t={allowSelfLoops:!0,multi:!1,type:"mixed"};function At(t,e,n){var i=new t.NodeDataClass(e,n);return t._nodes.set(e,i),t.emit("nodeAdded",{key:e,attributes:n}),i}function St(t,e,n,i,r,o,a,s){if(!i&&"undirected"===t.type)throw new W("Graph.".concat(e,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(i&&"directed"===t.type)throw new W("Graph.".concat(e,": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead."));if(s&&!c(s))throw new V("Graph.".concat(e,': invalid attributes. Expecting an object but got "').concat(s,'"'));if(o=""+o,a=""+a,s=s||{},!t.allowSelfLoops&&o===a)throw new W("Graph.".concat(e,': source & target are the same ("').concat(o,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var l=t._nodes.get(o),u=t._nodes.get(a);if(!l)throw new z("Graph.".concat(e,': source node "').concat(o,'" not found.'));if(!u)throw new z("Graph.".concat(e,': target node "').concat(a,'" not found.'));var h={key:null,undirected:i,source:o,target:a,attributes:s};if(n)r=t._edgeKeyGenerator();else if(r=""+r,t._edges.has(r))throw new W("Graph.".concat(e,': the "').concat(r,'" edge already exists in the graph.'));if(!t.multi&&(i?void 0!==l.undirected[a]:void 0!==l.out[a]))throw new W("Graph.".concat(e,': an edge linking "').concat(o,'" to "').concat(a,"\" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option."));var d=new Y(i,r,l,u,s);t._edges.set(r,d);var f=o===a;return i?(l.undirectedDegree++,u.undirectedDegree++,f&&(l.undirectedLoops++,t._undirectedSelfLoopCount++)):(l.outDegree++,u.inDegree++,f&&(l.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),i?t._undirectedSize++:t._directedSize++,h.key=r,t.emit("edgeAdded",h),r}function Et(t,e,n,i,r,o,a,l,u){if(!i&&"undirected"===t.type)throw new W("Graph.".concat(e,": you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead."));if(i&&"directed"===t.type)throw new W("Graph.".concat(e,": you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead."));if(l)if(u){if("function"!=typeof l)throw new V("Graph.".concat(e,': invalid updater function. Expecting a function but got "').concat(l,'"'))}else if(!c(l))throw new V("Graph.".concat(e,': invalid attributes. Expecting an object but got "').concat(l,'"'));var h;if(o=""+o,a=""+a,u&&(h=l,l=void 0),!t.allowSelfLoops&&o===a)throw new W("Graph.".concat(e,': source & target are the same ("').concat(o,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var d,f,p=t._nodes.get(o),g=t._nodes.get(a);if(!n&&(d=t._edges.get(r))){if(!(d.source.key===o&&d.target.key===a||i&&d.source.key===a&&d.target.key===o))throw new W("Graph.".concat(e,': inconsistency detected when attempting to merge the "').concat(r,'" edge with "').concat(o,'" source & "').concat(a,'" target vs. ("').concat(d.source.key,'", "').concat(d.target.key,'").'));f=d}if(f||t.multi||!p||(f=i?p.undirected[a]:p.out[a]),f){var m=[f.key,!1,!1,!1];if(u?!h:!l)return m;if(u){var y=f.attributes;f.attributes=h(y),t.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else s(f.attributes,l),t.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:l});return m}l=l||{},u&&h&&(l=h(l));var v={key:null,undirected:i,source:o,target:a,attributes:l};if(n)r=t._edgeKeyGenerator();else if(r=""+r,t._edges.has(r))throw new W("Graph.".concat(e,': the "').concat(r,'" edge already exists in the graph.'));var w=!1,b=!1;p||(p=At(t,o,{}),w=!0,o===a&&(g=p,b=!0)),g||(g=At(t,a,{}),b=!0),d=new Y(i,r,p,g,l),t._edges.set(r,d);var C=o===a;return i?(p.undirectedDegree++,g.undirectedDegree++,C&&(p.undirectedLoops++,t._undirectedSelfLoopCount++)):(p.outDegree++,g.inDegree++,C&&(p.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),i?t._undirectedSize++:t._directedSize++,v.key=r,t.emit("edgeAdded",v),[r,!0,w,b]}function xt(t,e){t._edges.delete(e.key);var n=e.source,i=e.target,r=e.attributes,o=e.undirected,a=n===i;o?(n.undirectedDegree--,i.undirectedDegree--,a&&(n.undirectedLoops--,t._undirectedSelfLoopCount--)):(n.outDegree--,i.inDegree--,a&&(n.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),o?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:r,source:n.key,target:i.key,undirected:o})}var Mt=function(n){function i(t){var e;if(e=n.call(this)||this,"boolean"!=typeof(t=s({},_t,t)).multi)throw new V("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \"".concat(t.multi,'".'));if(!bt.has(t.type))throw new V('Graph.constructor: invalid \'type\' option. Should be one of "mixed", "directed" or "undirected" but got "'.concat(t.type,'".'));if("boolean"!=typeof t.allowSelfLoops)throw new V("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \"".concat(t.allowSelfLoops,'".'));var i="mixed"===t.type?H:"directed"===t.type?j:K;h(a(e),"NodeDataClass",i);var r="geid_"+wt()+"_",o=0;return h(a(e),"_attributes",{}),h(a(e),"_nodes",new Map),h(a(e),"_edges",new Map),h(a(e),"_directedSize",0),h(a(e),"_undirectedSize",0),h(a(e),"_directedSelfLoopCount",0),h(a(e),"_undirectedSelfLoopCount",0),h(a(e),"_edgeKeyGenerator",function(){var t;do{t=r+o++}while(e._edges.has(t));return t}),h(a(e),"_options",t),Ct.forEach(function(t){return h(a(e),t,e[t])}),d(a(e),"order",function(){return e._nodes.size}),d(a(e),"size",function(){return e._edges.size}),d(a(e),"directedSize",function(){return e._directedSize}),d(a(e),"undirectedSize",function(){return e._undirectedSize}),d(a(e),"selfLoopCount",function(){return e._directedSelfLoopCount+e._undirectedSelfLoopCount}),d(a(e),"directedSelfLoopCount",function(){return e._directedSelfLoopCount}),d(a(e),"undirectedSelfLoopCount",function(){return e._undirectedSelfLoopCount}),d(a(e),"multi",e._options.multi),d(a(e),"type",e._options.type),d(a(e),"allowSelfLoops",e._options.allowSelfLoops),d(a(e),"implementation",function(){return"graphology"}),e}e(i,n);var r=i.prototype;return r._resetInstanceCounters=function(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0},r.hasNode=function(t){return this._nodes.has(""+t)},r.hasDirectedEdge=function(t,e){if("undirected"===this.type)return!1;if(1===arguments.length){var n=""+t,i=this._edges.get(n);return!!i&&!i.undirected}if(2===arguments.length){t=""+t,e=""+e;var r=this._nodes.get(t);return!!r&&r.out.hasOwnProperty(e)}throw new V("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},r.hasUndirectedEdge=function(t,e){if("directed"===this.type)return!1;if(1===arguments.length){var n=""+t,i=this._edges.get(n);return!!i&&i.undirected}if(2===arguments.length){t=""+t,e=""+e;var r=this._nodes.get(t);return!!r&&r.undirected.hasOwnProperty(e)}throw new V("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},r.hasEdge=function(t,e){if(1===arguments.length){var n=""+t;return this._edges.has(n)}if(2===arguments.length){t=""+t,e=""+e;var i=this._nodes.get(t);return!!i&&(void 0!==i.out&&i.out.hasOwnProperty(e)||void 0!==i.undirected&&i.undirected.hasOwnProperty(e))}throw new V("Graph.hasEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},r.directedEdge=function(t,e){if("undirected"!==this.type){if(t=""+t,e=""+e,this.multi)throw new W("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");var n=this._nodes.get(t);if(!n)throw new z('Graph.directedEdge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new z('Graph.directedEdge: could not find the "'.concat(e,'" target node in the graph.'));var i=n.out&&n.out[e]||void 0;return i?i.key:void 0}},r.undirectedEdge=function(t,e){if("directed"!==this.type){if(t=""+t,e=""+e,this.multi)throw new W("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");var n=this._nodes.get(t);if(!n)throw new z('Graph.undirectedEdge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new z('Graph.undirectedEdge: could not find the "'.concat(e,'" target node in the graph.'));var i=n.undirected&&n.undirected[e]||void 0;return i?i.key:void 0}},r.edge=function(t,e){if(this.multi)throw new W("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.edge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new z('Graph.edge: could not find the "'.concat(e,'" target node in the graph.'));var i=n.out&&n.out[e]||n.undirected&&n.undirected[e]||void 0;if(i)return i.key},r.areDirectedNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.areDirectedNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&(e in n.in||e in n.out)},r.areOutNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.areOutNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.out},r.areInNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.areInNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.in},r.areUndirectedNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.areUndirectedNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"directed"!==this.type&&e in n.undirected},r.areNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.areNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&(e in n.in||e in n.out)||"directed"!==this.type&&e in n.undirected},r.areInboundNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.areInboundNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.in||"directed"!==this.type&&e in n.undirected},r.areOutboundNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new z('Graph.areOutboundNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.out||"directed"!==this.type&&e in n.undirected},r.inDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.inDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree},r.outDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.outDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.outDegree},r.directedDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.directedDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree+e.outDegree},r.undirectedDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.undirectedDegree: could not find the "'.concat(t,'" node in the graph.'));return"directed"===this.type?0:e.undirectedDegree},r.inboundDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.inboundDegree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.inDegree),n},r.outboundDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.outboundDegree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.outDegree),n},r.degree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.degree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.inDegree+e.outDegree),n},r.inDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.inDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree-e.directedLoops},r.outDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.outDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.outDegree-e.directedLoops},r.directedDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.directedDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree+e.outDegree-2*e.directedLoops},r.undirectedDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.undirectedDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"directed"===this.type?0:e.undirectedDegree-2*e.undirectedLoops},r.inboundDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.inboundDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=e.undirectedDegree,i+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.inDegree,i+=e.directedLoops),n-i},r.outboundDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.outboundDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=e.undirectedDegree,i+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.outDegree,i+=e.directedLoops),n-i},r.degreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new z('Graph.degreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,i=0;return"directed"!==this.type&&(n+=e.undirectedDegree,i+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.inDegree+e.outDegree,i+=2*e.directedLoops),n-i},r.source=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new z('Graph.source: could not find the "'.concat(t,'" edge in the graph.'));return e.source.key},r.target=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new z('Graph.target: could not find the "'.concat(t,'" edge in the graph.'));return e.target.key},r.extremities=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new z('Graph.extremities: could not find the "'.concat(t,'" edge in the graph.'));return[e.source.key,e.target.key]},r.opposite=function(t,e){t=""+t,e=""+e;var n=this._edges.get(e);if(!n)throw new z('Graph.opposite: could not find the "'.concat(e,'" edge in the graph.'));var i=n.source.key,r=n.target.key;if(t===i)return r;if(t===r)return i;throw new z('Graph.opposite: the "'.concat(t,'" node is not attached to the "').concat(e,'" edge (').concat(i,", ").concat(r,")."))},r.hasExtremity=function(t,e){t=""+t,e=""+e;var n=this._edges.get(t);if(!n)throw new z('Graph.hasExtremity: could not find the "'.concat(t,'" edge in the graph.'));return n.source.key===e||n.target.key===e},r.isUndirected=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new z('Graph.isUndirected: could not find the "'.concat(t,'" edge in the graph.'));return e.undirected},r.isDirected=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new z('Graph.isDirected: could not find the "'.concat(t,'" edge in the graph.'));return!e.undirected},r.isSelfLoop=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new z('Graph.isSelfLoop: could not find the "'.concat(t,'" edge in the graph.'));return e.source===e.target},r.addNode=function(t,e){var n=function(t,e,n){if(n&&!c(n))throw new V('Graph.addNode: invalid attributes. Expecting an object but got "'.concat(n,'"'));if(e=""+e,n=n||{},t._nodes.has(e))throw new W('Graph.addNode: the "'.concat(e,'" node already exist in the graph.'));var i=new t.NodeDataClass(e,n);return t._nodes.set(e,i),t.emit("nodeAdded",{key:e,attributes:n}),i}(this,t,e);return n.key},r.mergeNode=function(t,e){if(e&&!c(e))throw new V('Graph.mergeNode: invalid attributes. Expecting an object but got "'.concat(e,'"'));t=""+t,e=e||{};var n=this._nodes.get(t);return n?(e&&(s(n.attributes,e),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:n.attributes,data:e})),[t,!1]):(n=new this.NodeDataClass(t,e),this._nodes.set(t,n),this.emit("nodeAdded",{key:t,attributes:e}),[t,!0])},r.updateNode=function(t,e){if(e&&"function"!=typeof e)throw new V('Graph.updateNode: invalid updater function. Expecting a function but got "'.concat(e,'"'));t=""+t;var n=this._nodes.get(t);if(n){if(e){var i=n.attributes;n.attributes=e(i),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:n.attributes})}return[t,!1]}var r=e?e({}):{};return n=new this.NodeDataClass(t,r),this._nodes.set(t,n),this.emit("nodeAdded",{key:t,attributes:r}),[t,!0]},r.dropNode=function(t){t=""+t;var e,n=this._nodes.get(t);if(!n)throw new z('Graph.dropNode: could not find the "'.concat(t,'" node in the graph.'));if("undirected"!==this.type){for(var i in n.out){e=n.out[i];do{xt(this,e),e=e.next}while(e)}for(var r in n.in){e=n.in[r];do{xt(this,e),e=e.next}while(e)}}if("directed"!==this.type)for(var o in n.undirected){e=n.undirected[o];do{xt(this,e),e=e.next}while(e)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})},r.dropEdge=function(t){var e;if(arguments.length>1){var n=""+arguments[0],i=""+arguments[1];if(!(e=l(this,n,i,this.type)))throw new z('Graph.dropEdge: could not find the "'.concat(n,'" -> "').concat(i,'" edge in the graph.'))}else if(t=""+t,!(e=this._edges.get(t)))throw new z('Graph.dropEdge: could not find the "'.concat(t,'" edge in the graph.'));return xt(this,e),this},r.dropDirectedEdge=function(t,e){if(arguments.length<2)throw new W("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new W("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=l(this,t=""+t,e=""+e,"directed");if(!n)throw new z('Graph.dropDirectedEdge: could not find a "'.concat(t,'" -> "').concat(e,'" edge in the graph.'));return xt(this,n),this},r.dropUndirectedEdge=function(t,e){if(arguments.length<2)throw new W("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new W("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=l(this,t,e,"undirected");if(!n)throw new z('Graph.dropUndirectedEdge: could not find a "'.concat(t,'" -> "').concat(e,'" edge in the graph.'));return xt(this,n),this},r.clear=function(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")},r.clearEdges=function(){for(var t,e=this._nodes.values();!0!==(t=e.next()).done;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")},r.getAttribute=function(t){return this._attributes[t]},r.getAttributes=function(){return this._attributes},r.hasAttribute=function(t){return this._attributes.hasOwnProperty(t)},r.setAttribute=function(t,e){return this._attributes[t]=e,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this},r.updateAttribute=function(t,e){if("function"!=typeof e)throw new V("Graph.updateAttribute: updater should be a function.");var n=this._attributes[t];return this._attributes[t]=e(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this},r.removeAttribute=function(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this},r.replaceAttributes=function(t){if(!c(t))throw new V("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},r.mergeAttributes=function(t){if(!c(t))throw new V("Graph.mergeAttributes: provided attributes are not a plain object.");return s(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this},r.updateAttributes=function(t){if("function"!=typeof t)throw new V("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this},r.updateEachNodeAttributes=function(t,e){if("function"!=typeof t)throw new V("Graph.updateEachNodeAttributes: expecting an updater function.");if(e&&!f(e))throw new V("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,i,r=this._nodes.values();!0!==(n=r.next()).done;)(i=n.value).attributes=t(i.key,i.attributes);this.emit("eachNodeAttributesUpdated",{hints:e||null})},r.updateEachEdgeAttributes=function(t,e){if("function"!=typeof t)throw new V("Graph.updateEachEdgeAttributes: expecting an updater function.");if(e&&!f(e))throw new V("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,i,r,o,a=this._edges.values();!0!==(n=a.next()).done;)r=(i=n.value).source,o=i.target,i.attributes=t(i.key,i.attributes,r.key,o.key,r.attributes,o.attributes,i.undirected);this.emit("eachEdgeAttributesUpdated",{hints:e||null})},r.forEachAdjacencyEntry=function(t){if("function"!=typeof t)throw new V("Graph.forEachAdjacencyEntry: expecting a callback.");gt(!1,!1,!1,this,t)},r.forEachAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new V("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");gt(!1,!1,!0,this,t)},r.forEachAssymetricAdjacencyEntry=function(t){if("function"!=typeof t)throw new V("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");gt(!1,!0,!1,this,t)},r.forEachAssymetricAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new V("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");gt(!1,!0,!0,this,t)},r.nodes=function(){return"function"==typeof Array.from?Array.from(this._nodes.keys()):U(this._nodes.keys(),this._nodes.size)},r.forEachNode=function(t){if("function"!=typeof t)throw new V("Graph.forEachNode: expecting a callback.");for(var e,n,i=this._nodes.values();!0!==(e=i.next()).done;)t((n=e.value).key,n.attributes)},r.findNode=function(t){if("function"!=typeof t)throw new V("Graph.findNode: expecting a callback.");for(var e,n,i=this._nodes.values();!0!==(e=i.next()).done;)if(t((n=e.value).key,n.attributes))return n.key},r.mapNodes=function(t){if("function"!=typeof t)throw new V("Graph.mapNode: expecting a callback.");for(var e,n,i=this._nodes.values(),r=new Array(this.order),o=0;!0!==(e=i.next()).done;)n=e.value,r[o++]=t(n.key,n.attributes);return r},r.someNode=function(t){if("function"!=typeof t)throw new V("Graph.someNode: expecting a callback.");for(var e,n,i=this._nodes.values();!0!==(e=i.next()).done;)if(t((n=e.value).key,n.attributes))return!0;return!1},r.everyNode=function(t){if("function"!=typeof t)throw new V("Graph.everyNode: expecting a callback.");for(var e,n,i=this._nodes.values();!0!==(e=i.next()).done;)if(!t((n=e.value).key,n.attributes))return!1;return!0},r.filterNodes=function(t){if("function"!=typeof t)throw new V("Graph.filterNodes: expecting a callback.");for(var e,n,i=this._nodes.values(),r=[];!0!==(e=i.next()).done;)t((n=e.value).key,n.attributes)&&r.push(n.key);return r},r.reduceNodes=function(t,e){if("function"!=typeof t)throw new V("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new V("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");for(var n,i,r=e,o=this._nodes.values();!0!==(n=o.next()).done;)r=t(r,(i=n.value).key,i.attributes);return r},r.nodeEntries=function(){var t=this._nodes.values();return new F(function(){var e=t.next();if(e.done)return e;var n=e.value;return{value:{node:n.key,attributes:n.attributes},done:!1}})},r.export=function(){var t=this,e=new Array(this._nodes.size),n=0;this._nodes.forEach(function(t,i){e[n++]=function(t,e){var n={key:t};return u(e.attributes)||(n.attributes=s({},e.attributes)),n}(i,t)});var i=new Array(this._edges.size);return n=0,this._edges.forEach(function(e,r){i[n++]=function(t,e,n){var i={key:e,source:n.source.key,target:n.target.key};return u(n.attributes)||(i.attributes=s({},n.attributes)),"mixed"===t&&n.undirected&&(i.undirected=!0),i}(t.type,r,e)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:i}},r.import=function(t){var e,n,r,o,a,s=this,l=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t instanceof i)return t.forEachNode(function(t,e){l?s.mergeNode(t,e):s.addNode(t,e)}),t.forEachEdge(function(t,e,n,i,r,o,a){l?a?s.mergeUndirectedEdgeWithKey(t,n,i,e):s.mergeDirectedEdgeWithKey(t,n,i,e):a?s.addUndirectedEdgeWithKey(t,n,i,e):s.addDirectedEdgeWithKey(t,n,i,e)}),this;if(!c(t))throw new V("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!c(t.attributes))throw new V("Graph.import: invalid attributes. Expecting a plain object.");l?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}if(t.nodes){if(r=t.nodes,!Array.isArray(r))throw new V("Graph.import: invalid nodes. Expecting an array.");for(e=0,n=r.length;e<n;e++){mt(o=r[e]);var u=o,h=u.key,d=u.attributes;l?this.mergeNode(h,d):this.addNode(h,d)}}if(t.edges){var f=!1;if("undirected"===this.type&&(f=!0),r=t.edges,!Array.isArray(r))throw new V("Graph.import: invalid edges. Expecting an array.");for(e=0,n=r.length;e<n;e++){yt(a=r[e]);var p=a,g=p.source,m=p.target,y=p.attributes,v=p.undirected,w=void 0===v?f:v;"key"in a?(l?w?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:w?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey).call(this,a.key,g,m,y):(l?w?this.mergeUndirectedEdge:this.mergeDirectedEdge:w?this.addUndirectedEdge:this.addDirectedEdge).call(this,g,m,y)}}return this},r.nullCopy=function(t){var e=new i(s({},this._options,t));return e.replaceAttributes(s({},this.getAttributes())),e},r.emptyCopy=function(t){var e=this.nullCopy(t);return this._nodes.forEach(function(t,n){var i=s({},t.attributes);t=new e.NodeDataClass(n,i),e._nodes.set(n,t)}),e},r.copy=function(t){if("string"==typeof(t=t||{}).type&&t.type!==this.type&&"mixed"!==t.type)throw new W('Graph.copy: cannot create an incompatible copy from "'.concat(this.type,'" type to "').concat(t.type,'" because this would mean losing information about the current graph.'));if("boolean"==typeof t.multi&&t.multi!==this.multi&&!0!==t.multi)throw new W("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if("boolean"==typeof t.allowSelfLoops&&t.allowSelfLoops!==this.allowSelfLoops&&!0!==t.allowSelfLoops)throw new W("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");for(var e,n,i=this.emptyCopy(t),r=this._edges.values();!0!==(e=r.next()).done;)St(i,"copy",!1,(n=e.value).undirected,n.key,n.source.key,n.target.key,s({},n.attributes));return i},r.toJSON=function(){return this.export()},r.toString=function(){return"[object Graph]"},r.inspect=function(){var e=this,n={};this._nodes.forEach(function(t,e){n[e]=t.attributes});var i={},r={};this._edges.forEach(function(t,n){var o,a=t.undirected?"--":"->",s="",l=t.source.key,c=t.target.key;t.undirected&&l>c&&(o=l,l=c,c=o);var u="(".concat(l,")").concat(a,"(").concat(c,")");n.startsWith("geid_")?e.multi&&(void 0===r[u]?r[u]=0:r[u]++,s+="".concat(r[u],". ")):s+="[".concat(n,"]: "),i[s+=u]=t.attributes});var o={};for(var a in this)this.hasOwnProperty(a)&&!Ct.has(a)&&"function"!=typeof this[a]&&"symbol"!==t(a)&&(o[a]=this[a]);return o.attributes=this._attributes,o.nodes=n,o.edges=i,h(o,"constructor",this.constructor),o},i}(g.exports.EventEmitter);"undefined"!=typeof Symbol&&(Mt.prototype[Symbol.for("nodejs.util.inspect.custom")]=Mt.prototype.inspect),[{name:function(t){return"".concat(t,"Edge")},generateKey:!0},{name:function(t){return"".concat(t,"DirectedEdge")},generateKey:!0,type:"directed"},{name:function(t){return"".concat(t,"UndirectedEdge")},generateKey:!0,type:"undirected"},{name:function(t){return"".concat(t,"EdgeWithKey")}},{name:function(t){return"".concat(t,"DirectedEdgeWithKey")},type:"directed"},{name:function(t){return"".concat(t,"UndirectedEdgeWithKey")},type:"undirected"}].forEach(function(t){["add","merge","update"].forEach(function(e){var n=t.name(e),i="add"===e?St:Et;t.generateKey?Mt.prototype[n]=function(r,o,a){return i(this,n,!0,"undirected"===(t.type||this.type),null,r,o,a,"update"===e)}:Mt.prototype[n]=function(r,o,a,s){return i(this,n,!1,"undirected"===(t.type||this.type),r,o,a,s,"update"===e)}})}),function(t){X.forEach(function(e){var n=e.name,i=e.attacher;i(t,n("Node"),0),i(t,n("Source"),1),i(t,n("Target"),2),i(t,n("Opposite"),3)})}(Mt),function(t){$.forEach(function(e){var n=e.name,i=e.attacher;i(t,n("Edge"),"mixed"),i(t,n("DirectedEdge"),"directed"),i(t,n("UndirectedEdge"),"undirected")})}(Mt),function(t){tt.forEach(function(e){!function(t,e){var n=e.name,i=e.type,r=e.direction;t.prototype[n]=function(t,e){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return[];if(!arguments.length)return function(t,e){if(0===t.size)return[];if("mixed"===e||e===t.type)return"function"==typeof Array.from?Array.from(t._edges.keys()):U(t._edges.keys(),t._edges.size);for(var n,i,r="undirected"===e?t.undirectedSize:t.directedSize,o=new Array(r),a="undirected"===e,s=t._edges.values(),l=0;!0!==(n=s.next()).done;)(i=n.value).undirected===a&&(o[l++]=i.key);return o}(this,i);if(1===arguments.length){t=""+t;var o=this._nodes.get(t);if(void 0===o)throw new z("Graph.".concat(n,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n,i){var r=[];return lt(!1,t,e,n,i,function(t){r.push(t)}),r}(this.multi,"mixed"===i?this.type:i,r,o)}if(2===arguments.length){t=""+t,e=""+e;var a=this._nodes.get(t);if(!a)throw new z("Graph.".concat(n,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new z("Graph.".concat(n,': could not find the "').concat(e,'" target node in the graph.'));return function(t,e,n,i,r){var o=[];return ct(!1,t,e,n,i,r,function(t){o.push(t)}),o}(i,this.multi,r,a,e)}throw new V("Graph.".concat(n,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(t,e),function(t,e){var n=e.name,i=e.type,r=e.direction,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(t,e,n){if("mixed"===i||"mixed"===this.type||i===this.type){if(1===arguments.length)return st(!1,this,i,n=t);if(2===arguments.length){t=""+t,n=e;var a=this._nodes.get(t);if(void 0===a)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return lt(!1,this.multi,"mixed"===i?this.type:i,r,a,n)}if(3===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new z("Graph.".concat(o,': could not find the "').concat(e,'" target node in the graph.'));return ct(!1,i,this.multi,r,s,e,n)}throw new V("Graph.".concat(o,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))}};var a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(){var t,e=Array.prototype.slice.call(arguments),n=e.pop();if(0===e.length){var r=0;"directed"!==i&&(r+=this.undirectedSize),"undirected"!==i&&(r+=this.directedSize),t=new Array(r);var a=0;e.push(function(e,i,r,o,s,l,c){t[a++]=n(e,i,r,o,s,l,c)})}else t=[],e.push(function(e,i,r,o,a,s,l){t.push(n(e,i,r,o,a,s,l))});return this[o].apply(this,e),t};var s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),n=[];return t.push(function(t,i,r,o,a,s,l){e(t,i,r,o,a,s,l)&&n.push(t)}),this[o].apply(this,t),n};var l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(){var t,e,n=Array.prototype.slice.call(arguments);if(n.length<2||n.length>4)throw new V("Graph.".concat(l,": invalid number of arguments (expecting 2, 3 or 4 and got ").concat(n.length,")."));if("function"==typeof n[n.length-1]&&"function"!=typeof n[n.length-2])throw new V("Graph.".concat(l,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));2===n.length?(t=n[0],e=n[1],n=[]):3===n.length?(t=n[1],e=n[2],n=[n[0]]):4===n.length&&(t=n[2],e=n[3],n=[n[0],n[1]]);var i=e;return n.push(function(e,n,r,o,a,s,l){i=t(i,e,n,r,o,a,s,l)}),this[o].apply(this,n),i}}(t,e),function(t,e){var n=e.name,i=e.type,r=e.direction,o="find"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(t,e,n){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return!1;if(1===arguments.length)return st(!0,this,i,n=t);if(2===arguments.length){t=""+t,n=e;var a=this._nodes.get(t);if(void 0===a)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return lt(!0,this.multi,"mixed"===i?this.type:i,r,a,n)}if(3===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new z("Graph.".concat(o,': could not find the "').concat(e,'" target node in the graph.'));return ct(!0,i,this.multi,r,s,e,n)}throw new V("Graph.".concat(o,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))};var a="some"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[a]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop();return t.push(function(t,n,i,r,o,a,s){return e(t,n,i,r,o,a,s)}),!!this[o].apply(this,t)};var s="every"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[s]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop();return t.push(function(t,n,i,r,o,a,s){return!e(t,n,i,r,o,a,s)}),!this[o].apply(this,t)}}(t,e),function(t,e){var n=e.name,i=e.type,r=e.direction,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(t,e){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return F.empty();if(!arguments.length)return function(t,e){if(0===t.size)return F.empty();var n="mixed"!==e&&e!==t.type,i="undirected"===e,r=t._edges.values();return new F(function(){for(var t,e;;){if((t=r.next()).done)return t;if(e=t.value,!n||e.undirected===i)break}return{value:{edge:e.key,attributes:e.attributes,source:e.source.key,target:e.target.key,sourceAttributes:e.source.attributes,targetAttributes:e.target.attributes,undirected:e.undirected},done:!1}})}(this,i);if(1===arguments.length){t=""+t;var n=this._nodes.get(t);if(!n)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){var i=F.empty();return"undirected"!==t&&("out"!==e&&void 0!==n.in&&(i=Z(i,it(n.in))),"in"!==e&&void 0!==n.out&&(i=Z(i,it(n.out,e?void 0:n.key)))),"directed"!==t&&void 0!==n.undirected&&(i=Z(i,it(n.undirected))),i}(i,r,n)}if(2===arguments.length){t=""+t,e=""+e;var a=this._nodes.get(t);if(!a)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new z("Graph.".concat(o,': could not find the "').concat(e,'" target node in the graph.'));return function(t,e,n,i){var r=F.empty();return"undirected"!==t&&(void 0!==n.in&&"out"!==e&&i in n.in&&(r=Z(r,at(n.in,i))),void 0!==n.out&&"in"!==e&&i in n.out&&(e||n.key!==i)&&(r=Z(r,at(n.out,i)))),"directed"!==t&&void 0!==n.undirected&&i in n.undirected&&(r=Z(r,at(n.undirected,i))),r}(i,r,a,e)}throw new V("Graph.".concat(o,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(t,e)})}(Mt),function(t){ut.forEach(function(e){(function(t,e){var n=e.name,i=e.type,r=e.direction;t.prototype[n]=function(t){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return[];t=""+t;var e=this._nodes.get(t);if(void 0===e)throw new z("Graph.".concat(n,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){if("mixed"!==t){if("undirected"===t)return Object.keys(n.undirected);if("string"==typeof e)return Object.keys(n[e])}var i=[];return ft(!1,t,e,n,function(t){i.push(t)}),i}("mixed"===i?this.type:i,r,e)}})(t,e),function(t,e){var n=e.name,i=e.type,r=e.direction,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(t,e){if("mixed"===i||"mixed"===this.type||i===this.type){t=""+t;var n=this._nodes.get(t);if(void 0===n)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));ft(!1,"mixed"===i?this.type:i,r,n,e)}};var a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(t,e){var n=[];return this[o](t,function(t,i){n.push(e(t,i))}),n};var s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(t,e){var n=[];return this[o](t,function(t,i){e(t,i)&&n.push(t)}),n};var l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(t,e,n){if(arguments.length<3)throw new V("Graph.".concat(l,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));var i=n;return this[o](t,function(t,n){i=e(i,t,n)}),i}}(t,e),function(t,e){var n=e.name,i=e.type,r=e.direction,o=n[0].toUpperCase()+n.slice(1,-1),a="find"+o;t.prototype[a]=function(t,e){if("mixed"===i||"mixed"===this.type||i===this.type){t=""+t;var n=this._nodes.get(t);if(void 0===n)throw new z("Graph.".concat(a,': could not find the "').concat(t,'" node in the graph.'));return ft(!0,"mixed"===i?this.type:i,r,n,e)}};var s="some"+o;t.prototype[s]=function(t,e){return!!this[a](t,e)};var l="every"+o;t.prototype[l]=function(t,e){return!this[a](t,function(t,n){return!e(t,n)})}}(t,e),function(t,e){var n=e.name,i=e.type,r=e.direction,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(t){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return F.empty();t=""+t;var e=this._nodes.get(t);if(void 0===e)throw new z("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){if("mixed"!==t){if("undirected"===t)return pt(null,n,n.undirected);if("string"==typeof e)return pt(null,n,n[e])}var i=F.empty(),r=new ht;return"undirected"!==t&&("out"!==e&&(i=Z(i,pt(r,n,n.in))),"in"!==e&&(i=Z(i,pt(r,n,n.out)))),"directed"!==t&&(i=Z(i,pt(r,n,n.undirected))),i}("mixed"===i?this.type:i,r,e)}}(t,e)})}(Mt);var Pt=function(t){function n(e){var n=s({type:"directed"},e);if("multi"in n&&!1!==n.multi)throw new V("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("directed"!==n.type)throw new V('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Mt),Nt=function(t){function n(e){var n=s({type:"undirected"},e);if("multi"in n&&!1!==n.multi)throw new V("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("undirected"!==n.type)throw new V('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Mt),Tt=function(t){function n(e){var n=s({multi:!0},e);if("multi"in n&&!0!==n.multi)throw new V("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return t.call(this,n)||this}return e(n,t),n}(Mt),Ft=function(t){function n(e){var n=s({type:"directed",multi:!0},e);if("multi"in n&&!0!==n.multi)throw new V("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("directed"!==n.type)throw new V('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Mt),It=function(t){function n(e){var n=s({type:"undirected",multi:!0},e);if("multi"in n&&!0!==n.multi)throw new V("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("undirected"!==n.type)throw new V('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Mt);function Lt(t){t.from=function(e,n){var i=s({},e.options,n),r=new t(i);return r.import(e),r}}return Lt(Mt),Lt(Pt),Lt(Nt),Lt(Tt),Lt(Ft),Lt(It),Mt.Graph=Mt,Mt.DirectedGraph=Pt,Mt.UndirectedGraph=Nt,Mt.MultiGraph=Tt,Mt.MultiDirectedGraph=Ft,Mt.MultiUndirectedGraph=It,Mt.InvalidArgumentsGraphError=V,Mt.NotFoundGraphError=z,Mt.UsageGraphError=W,Mt}()},944:(t,e)=>{"use strict";e.Vb=void 0,e.Vb=function(t,e,n){var i=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 i=0,r=t.length,o=e.length,a=Math.floor(Math.max(r,o)/2)-1,s=new Array(r),l=new Array(o),c=0;c<r;c++)for(var u=Math.max(0,c-a);u<=Math.min(o,c+a+1);u++)if(!s[c]&&!l[u]&&t[c]===e[u]){++i,s[c]=l[u]=!0;break}if(0===i)return 0;var h=0,d=0;for(c=0;c<r;c++)if(s[c]){for(;!l[d];)d++;t.charAt(c)!==e.charAt(d++)&&h++}return(i/r+i/o+(i-(h/=2))/i)/3}(t,e,n),r=0;if(i>.7){for(var o=Math.min(t.length,e.length),a=0;t[a]===e[a]&&a<4&&a<o;)++r,a++;i+=.1*r*(1-i)}return i}},983:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Emboss=void 0;const i=n(4892),r=n(6536),o=n(4060),a=n(5483);e.Emboss=function(t){const e=10*this.embossStrength(),n=255*this.embossWhiteLevel(),i=this.embossDirection(),r=this.embossBlend(),a=t.data,s=t.width,l=t.height,c=4*s;let u=0,h=0,d=l;switch(i){case"top-left":u=-1,h=-1;break;case"top":u=-1,h=0;break;case"top-right":u=-1,h=1;break;case"right":u=0,h=1;break;case"bottom-right":u=1,h=1;break;case"bottom":u=1,h=0;break;case"bottom-left":u=1,h=-1;break;case"left":u=0,h=-1;break;default:o.Util.error("Unknown emboss direction: "+i)}do{const t=(d-1)*c;let i=u;d+i<1&&(i=0),d+i>l&&(i=0);const o=(d-1+i)*s*4;let f=s;do{const i=t+4*(f-1);let l=h;f+l<1&&(l=0),f+l>s&&(l=0);const c=o+4*(f-1+l),u=a[i]-a[c],d=a[i+1]-a[c+1],p=a[i+2]-a[c+2];let g=u;const m=g>0?g:-g;if((d>0?d:-d)>m&&(g=d),(p>0?p:-p)>m&&(g=p),g*=e,r){const t=a[i]+g,e=a[i+1]+g,n=a[i+2]+g;a[i]=t>255?255:t<0?0:t,a[i+1]=e>255?255:e<0?0:e,a[i+2]=n>255?255:n<0?0:n}else{let t=n-g;t<0?t=0:t>255&&(t=255),a[i]=a[i+1]=a[i+2]=t}}while(--f)}while(--d)},i.Factory.addGetterSetter(r.Node,"embossStrength",.5,(0,a.getNumberValidator)(),i.Factory.afterSetFilter),i.Factory.addGetterSetter(r.Node,"embossWhiteLevel",.5,(0,a.getNumberValidator)(),i.Factory.afterSetFilter),i.Factory.addGetterSetter(r.Node,"embossDirection","top-left",void 0,i.Factory.afterSetFilter),i.Factory.addGetterSetter(r.Node,"embossBlend",!1,void 0,i.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 i=n(8871),r=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,i)=>{const{node:o}=e,a=o.getStage();a.setPointersPositions(t),void 0===e.pointerId&&(e.pointerId=r.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(r=>{const{node:o}=r,a=o.getStage();if(t&&a.setPointersPositions(t),!a._changedPointerPositions.find(t=>t.id===r.pointerId))return;"dragging"!==r.dragStatus&&"stopped"!==r.dragStatus||(e.DD.justDragged=!0,i.Konva._mouseListenClick=!1,i.Konva._touchListenClick=!1,i.Konva._pointerListenClick=!1,r.dragStatus="stopped");const s=r.node.getLayer()||r.node instanceof i.Konva.Stage&&r.node;s&&-1===n.indexOf(s)&&n.push(s)}),n.forEach(t=>{t.draw()})},_endDragAfter(t){e.DD._dragElements.forEach((n,i)=>{"stopped"===n.dragStatus&&n.node.fire("dragend",{type:"dragend",target:n.node,evt:t},!0),"dragging"!==n.dragStatus&&e.DD._dragElements.delete(i)})}},i.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 i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),r="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),o="/*# ".concat(r," */");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 i=n(4892),r=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 i=0;i<e.length;i++){const r=e[i].command,o=e[i].points;switch(r){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],i=o[1],r=o[2],a=o[3],s=o[4],l=o[5],c=o[6],u=o[7],h=r>a?r:a,d=r>a?1:r/a,f=r>a?a/r:1;t.translate(e,i),t.rotate(c),t.scale(d,f),t.arc(0,0,h,s,s+l,1-u),t.scale(1/d,1/f),t.rotate(-c),t.translate(-e,-i);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],i=e.points[5],r=e.points[4]+i;let o=Math.PI/180;if(Math.abs(n-r)<o&&(o=Math.abs(n-r)),i<0)for(let i=n-o;i>r;i-=o){const n=s.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],i,0);t.push(n.x,n.y)}else for(let i=n+o;i<r;i+=o){const n=s.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],i,0);t.push(n.x,n.y)}}else if("C"===e.command)for(let n=0;n<=1;n+=.01){const i=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(i.x,i.y)}else t=t.concat(e.points)});let e,n,i=t[0],r=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)||(i=Math.min(i,e),r=Math.max(r,e)),isNaN(n)||(o=Math.min(o,n),a=Math.max(a,n));return{x:i,y:o,width:r-i,height:a-o}}getLength(){return this.pathLength}getPointAtLength(t){return s.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,e,n,i){return Math.sqrt((n-t)*(n-t)+(i-e)*(i-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,i=0,r=e.length;if(!r)return null;for(;i<r&&t>e[i].pathLength;)t-=e[i].pathLength,++i;if(i===r)return n=e[i-1].points.slice(-2),{x:n[0],y:n[1]};if(t<.01)return"M"===e[i].command?(n=e[i].points.slice(0,2),{x:n[0],y:n[1]}):{x:e[i].start.x,y:e[i].start.y};const o=e[i],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],i=l[1],r=l[2],c=l[3],u=l[5],h=l[6];let d=l[4];return d+=u*t/o.pathLength,s.getPointOnEllipticalArc(n,i,r,c,d,h)}return null}static getPointOnLine(t,e,n,i,r,o,a){o=null!=o?o:e,a=null!=a?a:n;const s=this.getLineLength(e,n,i,r);if(s<1e-10)return{x:e,y:n};if(i===e)return{x:o,y:a+(r>n?t:-t)};const l=(r-n)/(i-e),c=Math.sqrt(t*t/(1+l*l))*(i<e?-1:1),u=l*c;if(Math.abs(a-n-l*(o-e))<1e-10)return{x:o+c,y:a+u};const h=((o-e)*(i-e)+(a-n)*(r-n))/(s*s),d=e+h*(i-e),f=n+h*(r-n),p=this.getLineLength(o,a,d,f),g=Math.sqrt(t*t-p*p),m=Math.sqrt(g*g/(1+l*l))*(i<e?-1:1);return{x:d+m,y:f+l*m}}static getPointOnCubicBezier(t,e,n,i,r,o,a,s,l){function c(t){return t*t*t}function u(t){return 3*t*t*(1-t)}function h(t){return 3*t*(1-t)*(1-t)}function d(t){return(1-t)*(1-t)*(1-t)}return{x:s*c(t)+o*u(t)+i*h(t)+e*d(t),y:l*c(t)+a*u(t)+r*h(t)+n*d(t)}}static getPointOnQuadraticBezier(t,e,n,i,r,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)+i*l(t)+e*c(t),y:a*s(t)+r*l(t)+n*c(t)}}static getPointOnEllipticalArc(t,e,n,i,r,o){const a=Math.cos(o),s=Math.sin(o),l=n*Math.cos(r),c=i*Math.sin(r);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 i=e.split("|"),r=[],o=[];let a=0,s=0;const l=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let c;for(let t=1;t<i.length;t++){let e=i[t],n=e.charAt(0);for(e=e.slice(1),o.length=0;c=l.exec(e);)o.push(c[0]);const u=[];for(let t=0,e=o.length;t<e;t++){if("00"===o[t]){u.push(0,0);continue}const e=parseFloat(o[t]);isNaN(e)?u.push(0):u.push(e)}for(;u.length>0&&!isNaN(u[0]);){let t="",e=[];const i=a,o=s;let l,c,h,d,f,p,g,m,y,v;switch(n){case"l":a+=u.shift(),s+=u.shift(),t="L",e.push(a,s);break;case"L":a=u.shift(),s=u.shift(),e.push(a,s);break;case"m":const i=u.shift(),o=u.shift();if(a+=i,s+=o,t="M",r.length>2&&"z"===r[r.length-1].command)for(let t=r.length-2;t>=0;t--)if("M"===r[t].command){a=r[t].points[0]+i,s=r[t].points[1]+o;break}e.push(a,s),n="l";break;case"M":a=u.shift(),s=u.shift(),t="M",e.push(a,s),n="L";break;case"h":a+=u.shift(),t="L",e.push(a,s);break;case"H":a=u.shift(),t="L",e.push(a,s);break;case"v":s+=u.shift(),t="L",e.push(a,s);break;case"V":s=u.shift(),t="L",e.push(a,s);break;case"C":e.push(u.shift(),u.shift(),u.shift(),u.shift()),a=u.shift(),s=u.shift(),e.push(a,s);break;case"c":e.push(a+u.shift(),s+u.shift(),a+u.shift(),s+u.shift()),a+=u.shift(),s+=u.shift(),t="C",e.push(a,s);break;case"S":c=a,h=s,l=r[r.length-1],"C"===l.command&&(c=a+(a-l.points[2]),h=s+(s-l.points[3])),e.push(c,h,u.shift(),u.shift()),a=u.shift(),s=u.shift(),t="C",e.push(a,s);break;case"s":c=a,h=s,l=r[r.length-1],"C"===l.command&&(c=a+(a-l.points[2]),h=s+(s-l.points[3])),e.push(c,h,a+u.shift(),s+u.shift()),a+=u.shift(),s+=u.shift(),t="C",e.push(a,s);break;case"Q":e.push(u.shift(),u.shift()),a=u.shift(),s=u.shift(),e.push(a,s);break;case"q":e.push(a+u.shift(),s+u.shift()),a+=u.shift(),s+=u.shift(),t="Q",e.push(a,s);break;case"T":c=a,h=s,l=r[r.length-1],"Q"===l.command&&(c=a+(a-l.points[0]),h=s+(s-l.points[1])),a=u.shift(),s=u.shift(),t="Q",e.push(c,h,a,s);break;case"t":c=a,h=s,l=r[r.length-1],"Q"===l.command&&(c=a+(a-l.points[0]),h=s+(s-l.points[1])),a+=u.shift(),s+=u.shift(),t="Q",e.push(c,h,a,s);break;case"A":d=u.shift(),f=u.shift(),p=u.shift(),g=u.shift(),m=u.shift(),y=a,v=s,a=u.shift(),s=u.shift(),t="A",e=this.convertEndpointToCenterParameterization(y,v,a,s,g,m,d,f,p);break;case"a":d=u.shift(),f=u.shift(),p=u.shift(),g=u.shift(),m=u.shift(),y=a,v=s,a+=u.shift(),s+=u.shift(),t="A",e=this.convertEndpointToCenterParameterization(y,v,a,s,g,m,d,f,p)}r.push({command:t||n,points:e,start:{x:i,y:o},pathLength:this.calcLength(i,o,t||n,e)})}"z"!==n&&"Z"!==n||r.push({command:"z",points:[],start:void 0,pathLength:0})}return r}static calcLength(t,e,n,i){let r,o,l,c;const u=s;switch(n){case"L":return u.getLineLength(t,e,i[0],i[1]);case"C":return(0,a.getCubicArcLength)([t,i[0],i[2],i[4]],[e,i[1],i[3],i[5]],1);case"Q":return(0,a.getQuadraticArcLength)([t,i[0],i[2]],[e,i[1],i[3]],1);case"A":r=0;const n=i[4],s=i[5],h=i[4]+s;let d=Math.PI/180;if(Math.abs(n-h)<d&&(d=Math.abs(n-h)),o=u.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],n,0),s<0)for(c=n-d;c>h;c-=d)l=u.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],c,0),r+=u.getLineLength(o.x,o.y,l.x,l.y),o=l;else for(c=n+d;c<h;c+=d)l=u.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],c,0),r+=u.getLineLength(o.x,o.y,l.x,l.y),o=l;return l=u.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],h,0),r+=u.getLineLength(o.x,o.y,l.x,l.y),r}return 0}static convertEndpointToCenterParameterization(t,e,n,i,r,o,a,s,l){const c=l*(Math.PI/180),u=Math.cos(c)*(t-n)/2+Math.sin(c)*(e-i)/2,h=-1*Math.sin(c)*(t-n)/2+Math.cos(c)*(e-i)/2,d=u*u/(a*a)+h*h/(s*s);d>1&&(a*=Math.sqrt(d),s*=Math.sqrt(d));let f=Math.sqrt((a*a*(s*s)-a*a*(h*h)-s*s*(u*u))/(a*a*(h*h)+s*s*(u*u)));r===o&&(f*=-1),isNaN(f)&&(f=0);const p=f*a*h/s,g=f*-s*u/a,m=(t+n)/2+Math.cos(c)*p-Math.sin(c)*g,y=(e+i)/2+Math.sin(c)*p+Math.cos(c)*g,v=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},w=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(v(t)*v(e))},b=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(w(t,e))},C=b([1,0],[(u-p)/a,(h-g)/s]),_=[(u-p)/a,(h-g)/s],A=[(-1*u-p)/a,(-1*h-g)/s];let S=b(_,A);return w(_,A)<=-1&&(S=Math.PI),w(_,A)>=1&&(S=0),0===o&&S>0&&(S-=2*Math.PI),1===o&&S<0&&(S+=2*Math.PI),[m,y,a,s,C,S,c,o]}}e.Path=s,s.prototype.className="Path",s.prototype._attrsAffectingSize=["data"],(0,r._registerNode)(s),i.Factory.addGetterSetter(s,"data")},1736:t=>{t.exports=function(t){return null!==t&&"object"==typeof t&&"function"==typeof t.addUndirectedEdgeWithKey&&"function"==typeof t.dropNode&&"boolean"==typeof t.multi}},1782:(t,e)=>{e.assign=function(t){t=t||{};var e,n,i,r=Array.prototype.slice.call(arguments).slice(1);for(e=0,i=r.length;e<i;e++)if(r[e])for(n in r[e])t[n]=r[e][n];return t},e.validateSettings=function(t){return"linLogMode"in t&&"boolean"!=typeof t.linLogMode?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&"boolean"!=typeof t.outboundAttractionDistribution?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&"boolean"!=typeof t.adjustSizes?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&"number"!=typeof t.edgeWeightInfluence?{message:"the `edgeWeightInfluence` setting should be a number."}:!("scalingRatio"in t)||"number"==typeof t.scalingRatio&&t.scalingRatio>=0?"strongGravityMode"in t&&"boolean"!=typeof t.strongGravityMode?{message:"the `strongGravityMode` setting should be a boolean."}:!("gravity"in t)||"number"==typeof t.gravity&&t.gravity>=0?"slowDown"in t&&!("number"==typeof t.slowDown||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&"boolean"!=typeof t.barnesHutOptimize?{message:"the `barnesHutOptimize` setting should be a boolean."}:!("barnesHutTheta"in t)||"number"==typeof t.barnesHutTheta&&t.barnesHutTheta>=0?null:{message:"the `barnesHutTheta` setting should be a number >= 0."}:{message:"the `gravity` setting should be a number >= 0."}:{message:"the `scalingRatio` setting should be a number >= 0."}},e.graphToByteArrays=function(t,e){var n,i=t.order,r=t.size,o={},a=new Float32Array(10*i),s=new Float32Array(3*r);return n=0,t.forEachNode(function(t,e){o[t]=n,a[n]=e.x,a[n+1]=e.y,a[n+2]=0,a[n+3]=0,a[n+4]=0,a[n+5]=0,a[n+6]=1,a[n+7]=1,a[n+8]=e.size||1,a[n+9]=e.fixed?1:0,n+=10}),n=0,t.forEachEdge(function(t,i,r,l,c,u,h){var d=o[r],f=o[l],p=e(t,i,r,l,c,u,h);a[d+6]+=p,a[f+6]+=p,s[n]=d,s[n+1]=f,s[n+2]=p,n+=3}),{nodes:a,edges:s}},e.assignLayoutChanges=function(t,e,n){var i=0;t.updateEachNodeAttributes(function(t,r){return r.x=e[i],r.y=e[i+1],i+=10,n?n(t,r):r})},e.readGraphPositions=function(t,e){var n=0;t.forEachNode(function(t,i){e[n]=i.x,e[n+1]=i.y,n+=10})},e.collectLayoutChanges=function(t,e,n){for(var i=t.nodes(),r={},o=0,a=0,s=e.length;o<s;o+=10){if(n){var l=Object.assign({},t.getNodeAttributes(i[a]));l.x=e[o],l.y=e[o+1],l=n(i[a],l),r[i[a]]={x:l.x,y:l.y}}else r[i[a]]={x:e[o],y:e[o+1]};a++}return r},e.createWorker=function(t){var e=window.URL||window.webkitURL,n=t.toString(),i=e.createObjectURL(new Blob(["("+n+").call(this);"],{type:"text/javascript"})),r=new Worker(i);return e.revokeObjectURL(i),r}},1958:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Text=void 0,e.stringToArray=c;const i=n(4060),r=n(4892),o=n(4723),a=n(8871),s=n(5483),l=n(8871);function c(t){return[...t].reduce((t,e,n,i)=>{if(/\p{Emoji}/u.test(e)){const r=i[n+1];r&&/\p{Emoji_Modifier}|\u200D/u.test(r)?(t.push(e+r),i[n+1]=""):t.push(e)}else/\p{Regional_Indicator}{2}/u.test(e+(i[n+1]||""))?t.push(e+i[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 u="auto",h="inherit",d="justify",f="left",p="middle",g="normal",m=" ",y="none",v=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],w=v.length;let b;function C(){return b||(b=i.Util.createCanvasElement().getContext("2d"),b)}class _ 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<w;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 i,r=this.padding(),o=this.fontSize(),s=this.lineHeight()*o,l=this.verticalAlign(),u=this.direction(),g=0,m=this.align(),y=this.getWidth(),v=this.letterSpacing(),w=this.fill(),b=this.textDecoration(),C=-1!==b.indexOf("underline"),_=-1!==b.indexOf("line-through");u=u===h?t.direction:u;let A=s/2,S=p;if(a.Konva._fixTextRendering){const t=this.measureSize("M");S="alphabetic",A=(t.fontBoundingBoxAscent-t.fontBoundingBoxDescent)/2+s/2}for("rtl"===u&&t.setAttr("direction",u),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",S),t.setAttr("textAlign",f),l===p?g=(this.getHeight()-n*s-2*r)/2:"bottom"===l&&(g=this.getHeight()-n*s-2*r),t.translate(r,g+r),i=0;i<n;i++){let l=0,h=0;const f=e[i],p=f.text,g=f.width,b=f.lastInParagraph;if(t.save(),"right"===m?l+=y-g-2*r:"center"===m&&(l+=(y-g-2*r)/2),C){t.save(),t.beginPath();const e=l,n=A+h+(a.Konva._fixTextRendering?Math.round(o/4):Math.round(o/2));t.moveTo(e,n);const i=m!==d||b?g:y-2*r;t.lineTo(e+Math.round(i),n),t.lineWidth=o/15;const s=this._getLinearGradient();t.strokeStyle=s||w,t.stroke(),t.restore()}if(_){t.save(),t.beginPath();const e=a.Konva._fixTextRendering?-Math.round(o/4):0;t.moveTo(l,A+h+e);const n=m!==d||b?g:y-2*r;t.lineTo(l+Math.round(n),A+h+e),t.lineWidth=o/15;const i=this._getLinearGradient();t.strokeStyle=i||w,t.stroke(),t.restore()}if("rtl"===u||0===v&&m!==d)0!==v&&t.setAttr("letterSpacing",`${v}px`),this._partialTextX=l,this._partialTextY=A+h,this._partialText=p,t.fillStrokeShape(this);else{const e=p.split(" ").length-1,n=c(p);for(let i=0;i<n.length;i++){const o=n[i];" "!==o||b||m!==d||(l+=(y-2*r-g)/e),this._partialTextX=l,this._partialTextY=A+h,this._partialText=o,t.fillStrokeShape(this),l+=this.measureSize(o).width+v}}t.restore(),n>1&&(A+=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=i.Util._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===u||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===u||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return i.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,i,r,o,a,s,l,c,u,h;let d,f=C(),p=this.fontSize();f.save(),f.font=this._getContextFont(),d=f.measureText(t),f.restore();const g=p/100;return{actualBoundingBoxAscent:null!==(e=d.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*g,actualBoundingBoxDescent:null!==(n=d.actualBoundingBoxDescent)&&void 0!==n?n:0,actualBoundingBoxLeft:null!==(i=d.actualBoundingBoxLeft)&&void 0!==i?i:-7.421875*g,actualBoundingBoxRight:null!==(r=d.actualBoundingBoxRight)&&void 0!==r?r:75.732421875*g,alphabeticBaseline:null!==(o=d.alphabeticBaseline)&&void 0!==o?o:0,emHeightAscent:null!==(a=d.emHeightAscent)&&void 0!==a?a:100*g,emHeightDescent:null!==(s=d.emHeightDescent)&&void 0!==s?s:-20*g,fontBoundingBoxAscent:null!==(l=d.fontBoundingBoxAscent)&&void 0!==l?l:91*g,fontBoundingBoxDescent:null!==(c=d.fontBoundingBoxDescent)&&void 0!==c?c:21*g,hangingBaseline:null!==(u=d.hangingBaseline)&&void 0!==u?u:72.80000305175781*g,ideographicBaseline:null!==(h=d.ideographicBaseline)&&void 0!==h?h:-21*g,width:d.width,height:p}}_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 C().measureText(t).width+e*n}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),n=0,i=this.lineHeight()*e,r=this.attrs.width,o=this.attrs.height,a=r!==u&&void 0!==r,s=o!==u&&void 0!==o,l=this.padding(),h=r-2*l,d=o-2*l,f=0,p=this.wrap(),g="char"!==p&&p!==y,v=this.ellipsis();this.textArr=[],C().font=this._getContextFont();const w=v?this._getTextWidth("…"):0;for(let e=0,r=t.length;e<r;++e){let o=t[e],l=this._getTextWidth(o);if(a&&l>h)for(;o.length>0;){let t=0,e=c(o).length,r="",a=0;for(;t<e;){const n=t+e>>>1,l=c(o).slice(0,n+1).join(""),u=this._getTextWidth(l);(v&&s&&f+i>d?u+w:u)<=h?(t=n+1,r=l,a=u):e=n}if(!r)break;if(g){const e=c(o),n=c(r),i=e[n.length];let s;if((i===m||"-"===i)&&a<=h)s=n.length;else{const t=n.lastIndexOf(m),e=n.lastIndexOf("-");s=Math.max(t,e)+1}s>0&&(t=s,r=e.slice(0,t).join(""),a=this._getTextWidth(r))}if(r=r.trimRight(),this._addTextLine(r),n=Math.max(n,a),f+=i,this._shouldHandleEllipsis(f)){this._tryToAddEllipsisToLastLine();break}if(o=c(o).slice(t).join("").trimLeft(),o.length>0&&(l=this._getTextWidth(o),l<=h)){this._addTextLine(o),f+=i,n=Math.max(n,l);break}}else this._addTextLine(o),f+=i,n=Math.max(n,l),this._shouldHandleEllipsis(f)&&e<r-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),s&&f+i>d)break}this.textHeight=e,this.textWidth=n}_shouldHandleEllipsis(t){const e=+this.fontSize(),n=this.lineHeight()*e,i=this.attrs.height,r=i!==u&&void 0!==i,o=i-2*this.padding();return!(this.wrap()!==y)||r&&t+n>o}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==u&&void 0!==t,n=t-2*this.padding(),i=this.ellipsis(),r=this.textArr[this.textArr.length-1];r&&i&&(e&&(this._getTextWidth(r.text+"…")<n||(r.text=r.text.slice(0,r.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(r.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=_,_.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},_.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},_.prototype.className="Text",_.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,l._registerNode)(_),r.Factory.overWriteSetter(_,"width",(0,s.getNumberOrAutoValidator)()),r.Factory.overWriteSetter(_,"height",(0,s.getNumberOrAutoValidator)()),r.Factory.addGetterSetter(_,"direction",h),r.Factory.addGetterSetter(_,"fontFamily","Arial"),r.Factory.addGetterSetter(_,"fontSize",12,(0,s.getNumberValidator)()),r.Factory.addGetterSetter(_,"fontStyle",g),r.Factory.addGetterSetter(_,"fontVariant",g),r.Factory.addGetterSetter(_,"padding",0,(0,s.getNumberValidator)()),r.Factory.addGetterSetter(_,"align",f),r.Factory.addGetterSetter(_,"verticalAlign","top"),r.Factory.addGetterSetter(_,"lineHeight",1,(0,s.getNumberValidator)()),r.Factory.addGetterSetter(_,"wrap","word"),r.Factory.addGetterSetter(_,"ellipsis",!1,(0,s.getBooleanValidator)()),r.Factory.addGetterSetter(_,"letterSpacing",0,(0,s.getNumberValidator)()),r.Factory.addGetterSetter(_,"text","",(0,s.getStringValidator)()),r.Factory.addGetterSetter(_,"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],i=e[t+1],r=e[t+2];e[t+0]=Math.min(255,.393*n+.769*i+.189*r),e[t+1]=Math.min(255,.349*n+.686*i+.168*r),e[t+2]=Math.min(255,.272*n+.534*i+.131*r)}}},2561:t=>{var e=10;t.exports=function(t,n,i){var r,o,a,s,l,c,u,h,d,f,p,g,m,y,v,w,b,C,_,A,S,E,x,M=n.length,P=i.length,N=t.adjustSizes,T=t.barnesHutTheta*t.barnesHutTheta,F=[];for(a=0;a<M;a+=e)n[a+4]=n[a+2],n[a+5]=n[a+3],n[a+2]=0,n[a+3]=0;if(t.outboundAttractionDistribution){for(p=0,a=0;a<M;a+=e)p+=n[a+6];p/=M/e}if(t.barnesHutOptimize){var I,L,O,R=1/0,D=-1/0,k=1/0,G=-1/0;for(a=0;a<M;a+=e)R=Math.min(R,n[a+0]),D=Math.max(D,n[a+0]),k=Math.min(k,n[a+1]),G=Math.max(G,n[a+1]);var U=D-R,B=G-k;for(U>B?G=(k-=(U-B)/2)+U:D=(R-=(B-U)/2)+B,F[0]=-1,F[1]=(R+D)/2,F[2]=(k+G)/2,F[3]=Math.max(D-R,G-k),F[4]=-1,F[5]=-1,F[6]=0,F[7]=0,F[8]=0,r=1,a=0;a<M;a+=e)for(o=0,O=3;;){if(!(F[o+5]>=0)){if(F[o+0]<0){F[o+0]=a;break}if(F[o+5]=9*r,h=F[o+3]/2,F[(d=F[o+5])+0]=-1,F[d+1]=F[o+1]-h,F[d+2]=F[o+2]-h,F[d+3]=h,F[d+4]=d+9,F[d+5]=-1,F[d+6]=0,F[d+7]=0,F[d+8]=0,F[(d+=9)+0]=-1,F[d+1]=F[o+1]-h,F[d+2]=F[o+2]+h,F[d+3]=h,F[d+4]=d+9,F[d+5]=-1,F[d+6]=0,F[d+7]=0,F[d+8]=0,F[(d+=9)+0]=-1,F[d+1]=F[o+1]+h,F[d+2]=F[o+2]-h,F[d+3]=h,F[d+4]=d+9,F[d+5]=-1,F[d+6]=0,F[d+7]=0,F[d+8]=0,F[(d+=9)+0]=-1,F[d+1]=F[o+1]+h,F[d+2]=F[o+2]+h,F[d+3]=h,F[d+4]=F[o+4],F[d+5]=-1,F[d+6]=0,F[d+7]=0,F[d+8]=0,r+=4,I=n[F[o+0]+0]<F[o+1]?n[F[o+0]+1]<F[o+2]?F[o+5]:F[o+5]+9:n[F[o+0]+1]<F[o+2]?F[o+5]+18:F[o+5]+27,F[o+6]=n[F[o+0]+6],F[o+7]=n[F[o+0]+0],F[o+8]=n[F[o+0]+1],F[I+0]=F[o+0],F[o+0]=-1,I===(L=n[a+0]<F[o+1]?n[a+1]<F[o+2]?F[o+5]:F[o+5]+9:n[a+1]<F[o+2]?F[o+5]+18:F[o+5]+27)){if(O--){o=I;continue}O=3;break}F[L+0]=a;break}I=n[a+0]<F[o+1]?n[a+1]<F[o+2]?F[o+5]:F[o+5]+9:n[a+1]<F[o+2]?F[o+5]+18:F[o+5]+27,F[o+7]=(F[o+7]*F[o+6]+n[a+0]*n[a+6])/(F[o+6]+n[a+6]),F[o+8]=(F[o+8]*F[o+6]+n[a+1]*n[a+6])/(F[o+6]+n[a+6]),F[o+6]+=n[a+6],o=I}}if(t.barnesHutOptimize){for(g=t.scalingRatio,a=0;a<M;a+=e)for(o=0;;)if(F[o+5]>=0){if(w=Math.pow(n[a+0]-F[o+7],2)+Math.pow(n[a+1]-F[o+8],2),4*(f=F[o+3])*f/w<T){if(m=n[a+0]-F[o+7],y=n[a+1]-F[o+8],!0===N?w>0?(b=g*n[a+6]*F[o+6]/w,n[a+2]+=m*b,n[a+3]+=y*b):w<0&&(b=-g*n[a+6]*F[o+6]/Math.sqrt(w),n[a+2]+=m*b,n[a+3]+=y*b):w>0&&(b=g*n[a+6]*F[o+6]/w,n[a+2]+=m*b,n[a+3]+=y*b),(o=F[o+4])<0)break;continue}o=F[o+5]}else if((c=F[o+0])>=0&&c!==a&&(w=(m=n[a+0]-n[c+0])*m+(y=n[a+1]-n[c+1])*y,!0===N?w>0?(b=g*n[a+6]*n[c+6]/w,n[a+2]+=m*b,n[a+3]+=y*b):w<0&&(b=-g*n[a+6]*n[c+6]/Math.sqrt(w),n[a+2]+=m*b,n[a+3]+=y*b):w>0&&(b=g*n[a+6]*n[c+6]/w,n[a+2]+=m*b,n[a+3]+=y*b)),(o=F[o+4])<0)break}else for(g=t.scalingRatio,s=0;s<M;s+=e)for(l=0;l<s;l+=e)m=n[s+0]-n[l+0],y=n[s+1]-n[l+1],!0===N?(w=Math.sqrt(m*m+y*y)-n[s+8]-n[l+8])>0?(b=g*n[s+6]*n[l+6]/w/w,n[s+2]+=m*b,n[s+3]+=y*b,n[l+2]-=m*b,n[l+3]-=y*b):w<0&&(b=100*g*n[s+6]*n[l+6],n[s+2]+=m*b,n[s+3]+=y*b,n[l+2]-=m*b,n[l+3]-=y*b):(w=Math.sqrt(m*m+y*y))>0&&(b=g*n[s+6]*n[l+6]/w/w,n[s+2]+=m*b,n[s+3]+=y*b,n[l+2]-=m*b,n[l+3]-=y*b);for(d=t.gravity/t.scalingRatio,g=t.scalingRatio,a=0;a<M;a+=e)b=0,m=n[a+0],y=n[a+1],w=Math.sqrt(Math.pow(m,2)+Math.pow(y,2)),t.strongGravityMode?w>0&&(b=g*n[a+6]*d):w>0&&(b=g*n[a+6]*d/w),n[a+2]-=m*b,n[a+3]-=y*b;for(g=1*(t.outboundAttractionDistribution?p:1),u=0;u<P;u+=3)s=i[u+0],l=i[u+1],h=i[u+2],v=Math.pow(h,t.edgeWeightInfluence),m=n[s+0]-n[l+0],y=n[s+1]-n[l+1],!0===N?(w=Math.sqrt(m*m+y*y)-n[s+8]-n[l+8],t.linLogMode?t.outboundAttractionDistribution?w>0&&(b=-g*v*Math.log(1+w)/w/n[s+6]):w>0&&(b=-g*v*Math.log(1+w)/w):t.outboundAttractionDistribution?w>0&&(b=-g*v/n[s+6]):w>0&&(b=-g*v)):(w=Math.sqrt(Math.pow(m,2)+Math.pow(y,2)),t.linLogMode?t.outboundAttractionDistribution?w>0&&(b=-g*v*Math.log(1+w)/w/n[s+6]):w>0&&(b=-g*v*Math.log(1+w)/w):t.outboundAttractionDistribution?(w=1,b=-g*v/n[s+6]):(w=1,b=-g*v)),w>0&&(n[s+2]+=m*b,n[s+3]+=y*b,n[l+2]-=m*b,n[l+3]-=y*b);if(!0===N)for(a=0;a<M;a+=e)1!==n[a+9]&&((C=Math.sqrt(Math.pow(n[a+2],2)+Math.pow(n[a+3],2)))>10&&(n[a+2]=10*n[a+2]/C,n[a+3]=10*n[a+3]/C),_=n[a+6]*Math.sqrt((n[a+4]-n[a+2])*(n[a+4]-n[a+2])+(n[a+5]-n[a+3])*(n[a+5]-n[a+3])),A=Math.sqrt((n[a+4]+n[a+2])*(n[a+4]+n[a+2])+(n[a+5]+n[a+3])*(n[a+5]+n[a+3]))/2,S=.1*Math.log(1+A)/(1+Math.sqrt(_)),E=n[a+0]+n[a+2]*(S/t.slowDown),n[a+0]=E,x=n[a+1]+n[a+3]*(S/t.slowDown),n[a+1]=x);else for(a=0;a<M;a+=e)1!==n[a+9]&&(_=n[a+6]*Math.sqrt((n[a+4]-n[a+2])*(n[a+4]-n[a+2])+(n[a+5]-n[a+3])*(n[a+5]-n[a+3])),A=Math.sqrt((n[a+4]+n[a+2])*(n[a+4]+n[a+2])+(n[a+5]+n[a+3])*(n[a+5]+n[a+3]))/2,S=n[a+7]*Math.log(1+A)/(1+Math.sqrt(_)),n[a+7]=Math.min(1,Math.sqrt(S*(Math.pow(n[a+2],2)+Math.pow(n[a+3],2))/(1+Math.sqrt(_)))),E=n[a+0]+n[a+2]*(S/t.slowDown),n[a+0]=E,x=n[a+1]+n[a+3]*(S/t.slowDown),n[a+1]=x);return{}}},2650:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Contrast=void 0;const i=n(4892),r=n(6536),o=n(5483);e.Contrast=function(t){const e=Math.pow((this.contrast()+100)/100,2),n=t.data,i=n.length;let r=150,o=150,a=150;for(let t=0;t<i;t+=4)r=n[t],o=n[t+1],a=n[t+2],r/=255,r-=.5,r*=e,r+=.5,r*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,r=r<0?0:r>255?255:r,o=o<0?0:o>255?255:o,a=a<0?0:a>255?255:a,n[t]=r,n[t+1]=o,n[t+2]=a},i.Factory.addGetterSetter(r.Node,"contrast",0,(0,o.getNumberValidator)(),i.Factory.afterSetFilter)},3443:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Line=void 0;const i=n(4892),r=n(8871),o=n(4723),a=n(5483);function s(t,e,n,i,r,o,a){const s=Math.sqrt(Math.pow(n-t,2)+Math.pow(i-e,2)),l=Math.sqrt(Math.pow(r-n,2)+Math.pow(o-i,2)),c=a*s/(s+l),u=a*l/(s+l);return[n-c*(r-t),i-c*(o-e),n+u*(r-t),i+u*(o-e)]}function l(t,e){const n=t.length,i=[];for(let r=2;r<n-2;r+=2){const n=s(t[r-2],t[r-1],t[r],t[r+1],t[r+2],t[r+3],e);isNaN(n[0])||(i.push(n[0]),i.push(n[1]),i.push(t[r]),i.push(t[r+1]),i.push(n[2]),i.push(n[3]))}return i}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,i=this.tension(),r=this.closed(),o=this.bezier();if(!n)return;let a=0;if(t.beginPath(),t.moveTo(e[0],e[1]),0!==i&&n>4){const i=this.getTensionPoints(),o=i.length;for(a=r?0:4,r||t.quadraticCurveTo(i[0],i[1],i[2],i[3]);a<o-2;)t.bezierCurveTo(i[a++],i[a++],i[a++],i[a++],i[a++],i[a++]);r||t.quadraticCurveTo(i[o-2],i[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]);r?(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(),i=s(t[e-2],t[e-1],t[0],t[1],t[2],t[3],n),r=s(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],n),o=l(t,n);return[i[2],i[3]].concat(o).concat([r[0],r[1],t[e-2],t[e-1],r[2],r[3],i[0],i[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,i=t[0],r=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],i=Math.min(i,e),r=Math.max(r,e),o=Math.min(o,n),a=Math.max(a,n);return{x:i,y:o,width:r-i,height:a-o}}}e.Line=c,c.prototype.className="Line",c.prototype._attrsAffectingSize=["points","bezier","tension"],(0,r._registerNode)(c),i.Factory.addGetterSetter(c,"closed",!1),i.Factory.addGetterSetter(c,"bezier",!1),i.Factory.addGetterSetter(c,"tension",0,(0,a.getNumberValidator)()),i.Factory.addGetterSetter(c,"points",[],(0,a.getNumberArrayValidator)())},3862:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RGBA=void 0;const i=n(4892),r=n(6536),o=n(5483);e.RGBA=function(t){const e=t.data,n=e.length,i=this.red(),r=this.green(),o=this.blue(),a=this.alpha();for(let t=0;t<n;t+=4){const n=1-a;e[t]=i*a+e[t]*n,e[t+1]=r*a+e[t+1]*n,e[t+2]=o*a+e[t+2]*n}},i.Factory.addGetterSetter(r.Node,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),i.Factory.addGetterSetter(r.Node,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),i.Factory.addGetterSetter(r.Node,"blue",0,o.RGBComponent,i.Factory.afterSetFilter),i.Factory.addGetterSetter(r.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 i=n(8871);class r{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 r(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),i=this.m[0]*e+this.m[2]*n,r=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]=i,this.m[1]=r,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,i=this.m[1]+this.m[3]*e,r=this.m[2]+this.m[0]*t,o=this.m[3]+this.m[1]*t;return this.m[0]=n,this.m[1]=i,this.m[2]=r,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],i=this.m[0]*t.m[2]+this.m[2]*t.m[3],r=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]=i,this.m[3]=r,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,i=-this.m[2]*t,r=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]=i,this.m[3]=r,this.m[4]=o,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],n=this.m[1],i=this.m[2],r=this.m[3],o=t*r-n*i,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*i+n*r)/o,a.skewY=0}else if(0!=i||0!=r){const e=Math.sqrt(i*i+r*r);a.rotation=Math.PI/2-(r>0?Math.acos(-i/e):-Math.acos(i/e)),a.scaleX=o/e,a.scaleY=e,a.skewX=0,a.skewY=(t*i+n*r)/o}return a.rotation=e.Util._getRotation(a.rotation),a}}e.Transform=r;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 u=[];const h="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){u.push(t),1===u.length&&h(function(){const t=u;u=[],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 i=e.Util.createImageElement();i.onload=function(){n(i)},i.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),i=Number(n[0])/360,r=Number(n[1])/100,o=Number(n[2])/100;let a,s,l;if(0===r)return l=255*o,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};a=o<.5?o*(1+r):o+r-o*r;const c=2*o-a,u=[0,0,0];for(let t=0;t<3;t++)s=i+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,u[t]=255*l;return{r:Math.round(u[0]),g:Math.round(u[1]),b:Math.round(u[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=>i.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){i.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,i,r,o){let a,s,l;const c=(t-n)*(t-n)+(e-i)*(e-i);if(0==c)a=t,s=e,l=(r-n)*(r-n)+(o-i)*(o-i);else{const u=((r-t)*(n-t)+(o-e)*(i-e))/c;u<0?(a=t,s=e,l=(t-r)*(t-r)+(e-o)*(e-o)):u>1?(a=n,s=i,l=(n-r)*(n-r)+(i-o)*(i-o)):(a=t+u*(n-t),s=e+u*(i-e),l=(a-r)*(a-r)+(s-o)*(s-o))}return[a,s,l]},_getProjectionToLine(t,n,i){const r=e.Util.cloneObject(t);let o=Number.MAX_VALUE;return n.forEach(function(a,s){if(!i&&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),u=c[0],h=c[1],d=c[2];d<o&&(r.x=u,r.y=h,o=d)}),r},_prepareArrayForTween(t,n,i){const r=[],o=[];if(t.length>n.length){const e=n;n=t,t=e}for(let e=0;e<t.length;e+=2)r.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,r,i);a.push(n.x),a.push(n.y)}),a},_prepareToStringify(t){let n;t.visitedByCircularReferenceRemoval=!0;for(const i in t)if(t.hasOwnProperty(i)&&t[i]&&"object"==typeof t[i])if(n=Object.getOwnPropertyDescriptor(t,i),t[i].visitedByCircularReferenceRemoval||e.Util._isElement(t[i])){if(!n.configurable)return null;delete t[i]}else if(null===e.Util._prepareToStringify(t[i])){if(!n.configurable)return null;delete t[i]}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){i.Konva.releaseCanvasOnDestroy&&t.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(t,e,n,i){let r=0,o=0,a=0,s=0;"number"==typeof i?r=o=a=s=Math.min(i,e/2,n/2):(r=Math.min(i[0]||0,e/2,n/2),o=Math.min(i[1]||0,e/2,n/2),s=Math.min(i[2]||0,e/2,n/2),a=Math.min(i[3]||0,e/2,n/2)),t.moveTo(r,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,r),t.arc(r,r,r,Math.PI,3*Math.PI/2,!1)}}},4473:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Container=void 0;const i=n(4892),r=n(6536),o=n(5483);class a extends r.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(i=>{const r=i._isMatch(t);return r&&n.push(i),!(!r||!e)}),n}_descendants(t){let e=!1;const n=this.getChildren();for(const i of n){if(e=t(i),e)return!0;if(i.hasChildren()&&(e=i._descendants(t),e))return!0}return!1}toObject(){const t=r.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=r.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 i=this.getLayer(),r=t||i&&i.getCanvas(),o=r&&r.getContext(),a=this._getCanvasCache(),s=a&&a.scene,l=r&&r.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",r,e,n);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const n=this.getLayer(),i=t||n&&n.hitCanvas,r=i&&i.getContext(),o=this._getCanvasCache();if(o&&o.hit){r.save();const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(r),r.restore()}else this._drawChildren("drawHit",i,e);return this}_drawChildren(t,e,n,i){var r;const o=e&&e.getContext(),a=this.clipWidth(),s=this.clipHeight(),l=this.clipFunc(),c="number"==typeof a&&"number"==typeof s||l,u=n===this;if(c){o.save();const t=this.getAbsoluteTransform(n);let e,i=t.getMatrix();if(o.transform(i[0],i[1],i[2],i[3],i[4],i[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),i=t.copy().invert().getMatrix(),o.transform(i[0],i[1],i[2],i[3],i[4],i[5])}const h=!u&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;h&&(o.save(),o._applyGlobalCompositeOperation(this)),null===(r=this.children)||void 0===r||r.forEach(function(r){r[t](e,n,i)}),h&&o.restore(),c&&o.restore()}getClientRect(t={}){var e;const n=t.skipTransform,i=t.relativeTo;let r,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===r?(r=n.x,o=n.y,a=n.x+n.width,s=n.y+n.height):(r=Math.min(r,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 u=this.find("Shape");let h=!1;for(let t=0;t<u.length;t++)if(u[t]._isVisible(this)){h=!0;break}return l=h&&void 0!==r?{x:r,y:o,width:a-r,height:s-o}:{x:0,y:0,width:0,height:0},n?l:this._transformedRect(l,i)}}e.Container=a,i.Factory.addComponentsGetterSetter(a,"clip",["x","y","width","height"]),i.Factory.addGetterSetter(a,"clipX",void 0,(0,o.getNumberValidator)()),i.Factory.addGetterSetter(a,"clipY",void 0,(0,o.getNumberValidator)()),i.Factory.addGetterSetter(a,"clipWidth",void 0,(0,o.getNumberValidator)()),i.Factory.addGetterSetter(a,"clipHeight",void 0,(0,o.getNumberValidator)()),i.Factory.addGetterSetter(a,"clipFunc")},4481:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Star=void 0;const i=n(4892),r=n(4723),o=n(5483),a=n(8871);class s extends r.Shape{_sceneFunc(t){const e=this.innerRadius(),n=this.outerRadius(),i=this.numPoints();t.beginPath(),t.moveTo(0,0-n);for(let r=1;r<2*i;r++){const o=r%2==0?n:e,a=o*Math.sin(r*Math.PI/i),s=-1*o*Math.cos(r*Math.PI/i);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),i.Factory.addGetterSetter(s,"numPoints",5,(0,o.getNumberValidator)()),i.Factory.addGetterSetter(s,"innerRadius",0,(0,o.getNumberValidator)()),i.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 i=n(8871),r=n(4060),o=n(4892),a=n(6536),s=n(5483),l=n(8871),c=n(8722),u="hasShadow",h="shadowRGBA",d="patternImage",f="linearGradient",p="radialGradient";let g;function m(){return g||(g=r.Util.createCanvasElement().getContext("2d"),g)}e.shapes={};class y extends a.Node{constructor(t){let n;for(super(t);n=r.Util.getRandomColor(),!n||n in e.shapes;);this.colorKey=n,e.shapes[n]=this}getContext(){return r.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return r.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(u,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 r.Transform;e.translate(this.fillPatternX(),this.fillPatternY()),e.rotate(i.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(),i=this.fillLinearGradientEndPoint(),r=e.createLinearGradient(n.x,n.y,i.x,i.y);for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}_getRadialGradient(){return this._getCache(p,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=m(),n=this.fillRadialGradientStartPoint(),i=this.fillRadialGradientEndPoint(),r=e.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),i.x,i.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}getShadowRGBA(){return this._getCache(h,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=r.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(),i=this.hasStroke(),r=1!==this.getAbsoluteOpacity();if(n&&i&&r)return!0;const o=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(n&&i&&o&&a)}setStrokeHitEnabled(t){r.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 i=t.skipTransform,r=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(),u=c?this.shadowOffsetX():0,h=c?this.shadowOffsetY():0,d=s+Math.abs(u),f=l+Math.abs(h),p=c&&this.shadowBlur()||0,g={width:d+2*p,height:f+2*p,x:-(a/2+p)+Math.min(u,0)+o.x,y:-(a/2+p)+Math.min(h,0)+o.y};return i?g:this._transformedRect(g,r)}drawScene(t,e,n){const i=this.getLayer(),r=(t||i.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){r.save();const t=this.getAbsoluteTransform(e).getMatrix();return r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(r),r.restore(),this}if(!a)return this;if(r.save(),this._useBufferCanvas()){l=this.getStage();const t=n||l.bufferCanvas,i=t.getContext();i.clear(),i.save(),i._applyLineJoin(this);const o=this.getAbsoluteTransform(e).getMatrix();i.transform(o[0],o[1],o[2],o[3],o[4],o[5]),a.call(this,i,this),i.restore();const c=t.pixelRatio;s&&r._applyShadow(this),r._applyOpacity(this),r._applyGlobalCompositeOperation(this),r.drawImage(t._canvas,t.x||0,t.y||0,t.width/c,t.height/c)}else{if(r._applyLineJoin(this),!c){const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),r._applyOpacity(this),r._applyGlobalCompositeOperation(this)}s&&r._applyShadow(this),a.call(this,r,this)}return r.restore(),this}drawHit(t,e,n=!1){if(!this.shouldDrawHit(e,n))return this;const i=this.getLayer(),o=t||i.hitCanvas,a=o&&o.getContext(),s=this.hitFunc()||this.sceneFunc(),l=this._getCanvasCache(),c=l&&l.hit;if(this.colorKey||r.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(),i=e.hit,o=i.getContext(),a=i.getWidth(),s=i.getHeight();o.clear(),o.drawImage(n._canvas,0,0,a,s);try{const e=o.getImageData(0,0,a,s),n=e.data,i=n.length,l=r.Util._hexToRgb(this.colorKey);for(let e=0;e<i;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){r.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(u)}),y.prototype.on.call(y.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(h)}),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(p)}),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 i=n(4892),r=n(4723),o=n(8871),a=n(5483),s=n(8871);class l extends r.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(),i=o.Konva.getAngle(n?360-this.angle():this.angle()),r=Math.cos(Math.min(i,Math.PI)),a=Math.sin(Math.min(Math.max(Math.PI,i),3*Math.PI/2)),s=Math.sin(Math.min(i,Math.PI/2)),l=r*(r>0?t:e),c=a*(a>0?t:e),u=s*(s>0?e:t);return{x:l,y:n?-1*u:c,width:1*e-l,height:u-c}}}e.Arc=l,l.prototype._centroid=!0,l.prototype.className="Arc",l.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],(0,s._registerNode)(l),i.Factory.addGetterSetter(l,"innerRadius",0,(0,a.getNumberValidator)()),i.Factory.addGetterSetter(l,"outerRadius",0,(0,a.getNumberValidator)()),i.Factory.addGetterSetter(l,"angle",0,(0,a.getNumberValidator)()),i.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 i=n(4892),r=n(6536),o=n(5483);e.HSV=function(t){const e=t.data,n=e.length,i=Math.pow(2,this.value()),r=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,a=i*r*Math.cos(o*Math.PI/180),s=i*r*Math.sin(o*Math.PI/180),l=.299*i+.701*a+.167*s,c=.587*i-.587*a+.33*s,u=.114*i-.114*a-.497*s,h=.299*i-.299*a-.328*s,d=.587*i+.413*a+.035*s,f=.114*i-.114*a+.293*s,p=.299*i-.3*a+1.25*s,g=.587*i-.586*a-1.05*s,m=.114*i+.886*a-.2*s;for(let t=0;t<n;t+=4){const n=e[t+0],i=e[t+1],r=e[t+2],o=e[t+3];e[t+0]=l*n+c*i+u*r,e[t+1]=h*n+d*i+f*r,e[t+2]=p*n+g*i+m*r,e[t+3]=o}},i.Factory.addGetterSetter(r.Node,"hue",0,(0,o.getNumberValidator)(),i.Factory.afterSetFilter),i.Factory.addGetterSetter(r.Node,"saturation",0,(0,o.getNumberValidator)(),i.Factory.afterSetFilter),i.Factory.addGetterSetter(r.Node,"value",0,(0,o.getNumberValidator)(),i.Factory.afterSetFilter)},4884:(t,e,n)=>{"use strict";n.d(e,{A:()=>s});var i=n(1354),r=n.n(i),o=n(6314),a=n.n(o)()(r());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 i=n(4060),r=n(5483),o="get",a="set";e.Factory={addGetterSetter(t,n,i,r,o){e.Factory.addGetter(t,n,i),e.Factory.addSetter(t,n,r,o),e.Factory.addOverloadedGetterSetter(t,n)},addGetter(t,e,n){const r=o+i.Util._capitalize(e);t.prototype[r]=t.prototype[r]||function(){const t=this.attrs[e];return void 0===t?n:t}},addSetter(t,n,r,o){const s=a+i.Util._capitalize(n);t.prototype[s]||e.Factory.overWriteSetter(t,n,r,o)},overWriteSetter(t,e,n,r){const o=a+i.Util._capitalize(e);t.prototype[o]=function(t){return n&&null!=t&&(t=n.call(this,t,e)),this._setAttr(e,t),r&&r.call(this),this}},addComponentsGetterSetter(t,n,s,l,c){const u=s.length,h=i.Util._capitalize,d=o+h(n),f=a+h(n);t.prototype[d]=function(){const t={};for(let e=0;e<u;e++){const i=s[e];t[i]=this.getAttr(n+h(i))}return t};const p=(0,r.getComponentValidator)(s);t.prototype[f]=function(t){const e=this.attrs[n];l&&(t=l.call(this,t,n)),p&&p.call(this,t,n);for(const e in t)t.hasOwnProperty(e)&&this._setAttr(n+h(e),t[e]);return t||s.forEach(t=>{this._setAttr(n+h(t),void 0)}),this._fireChangeEvent(n,e,t),c&&c.call(this),this},e.Factory.addOverloadedGetterSetter(t,n)},addOverloadedGetterSetter(t,e){const n=i.Util._capitalize(e),r=a+n,s=o+n;t.prototype[e]=function(){return arguments.length?(this[r](arguments[0]),this):this[s]()}},addDeprecatedGetterSetter(t,n,r,a){i.Util.error("Adding deprecated "+n);const s=o+i.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(){i.Util.error(l);const t=this.attrs[n];return void 0===t?r:t},e.Factory.addSetter(t,n,a,function(){i.Util.error(l)}),e.Factory.addOverloadedGetterSetter(t,n)},backCompat(t,e){i.Util.each(e,function(e,n){const r=t.prototype[n],s=o+i.Util._capitalize(e),l=a+i.Util._capitalize(e);function c(){r.apply(this,arguments),i.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 i=n(4892),r=n(4060),o=n(6536),a=n(5483);e.Pixelate=function(t){let e=Math.ceil(this.pixelSize()),n=t.width,i=t.height,o=Math.ceil(n/e),a=Math.ceil(i/e),s=t.data;if(e<=0)r.Util.error("pixelSize value can not be <= 0");else for(let t=0;t<o;t+=1)for(let r=0;r<a;r+=1){let o=0,a=0,l=0,c=0;const u=t*e,h=u+e,d=r*e,f=d+e;let p=0;for(let t=u;t<h;t+=1)if(!(t>=n))for(let e=d;e<f;e+=1){if(e>=i)continue;const r=4*(n*e+t);o+=s[r+0],a+=s[r+1],l+=s[r+2],c+=s[r+3],p+=1}o/=p,a/=p,l/=p,c/=p;for(let t=u;t<h;t+=1)if(!(t>=n))for(let e=d;e<f;e+=1){if(e>=i)continue;const r=4*(n*e+t);s[r+0]=o,s[r+1]=a,s[r+2]=l,s[r+3]=c}}},i.Factory.addGetterSetter(o.Node,"pixelSize",8,(0,a.getNumberValidator)(),i.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 i=n(4060),r=n(4892),o=n(6536),a=n(4723),s=n(5155),l=n(7949),c=n(8871),u=n(5483),h=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(" "),p="nodesRect",g=["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 w(t,e,n){const i=n.x+(t.x-n.x)*Math.cos(e)-(t.y-n.y)*Math.sin(e),r=n.y+(t.x-n.x)*Math.sin(e)+(t.y-n.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:i,y:r}}let b=0;class C 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 i.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)||(i.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(g.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 i=t.getAbsolutePosition(),r=i.x-e.x,o=i.y-e.y;this.nodes().forEach(e=>{if(e===t)return;if(e.isDragging())return;const i=e.getAbsolutePosition();e.setAbsolutePosition({x:i.x+r,y:i.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(p),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(p,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),n){const i=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=t.getAbsoluteScale(n),o=t.getAbsolutePosition(n),a=i.x*r.x-t.offsetX()*r.x,s=i.y*r.y-t.offsetY()*r.y,l=(c.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return w({x:o.x+a*Math.cos(l)+s*Math.sin(-l),y:o.y+s*Math.cos(l)+a*Math.sin(l),width:i.width*r.x,height:i.height*r.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()}),i=[{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}],r=e.getAbsoluteTransform();i.forEach(function(e){const n=r.point(e);t.push(n)})});const e=new i.Transform;e.rotate(-c.Konva.getAngle(this.rotation()));let n=1/0,r=1/0,o=-1/0,a=-1/0;t.forEach(function(t){const i=e.point(t);void 0===n&&(n=o=i.x,r=a=i.y),n=Math.min(n,i.x),r=Math.min(r,i.y),o=Math.max(o,i.x),a=Math.max(a,i.y)}),e.invert();const s=e.point({x:n,y:r});return{x:s.x,y:s.y,width:o-n,height:a-r,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()),r=this.rotateAnchorCursor(),o=function(t,e,n){if("rotater"===t)return n;e+=i.Util.degToRad(m[t]||0);const r=(i.Util.radToDeg(e)%360+360)%360;return i.Util._inRange(r,337.5,360)||i.Util._inRange(r,0,22.5)?"ns-resize":i.Util._inRange(r,22.5,67.5)?"nesw-resize":i.Util._inRange(r,67.5,112.5)?"ew-resize":i.Util._inRange(r,112.5,157.5)?"nwse-resize":i.Util._inRange(r,157.5,202.5)?"ns-resize":i.Util._inRange(r,202.5,247.5)?"nesw-resize":i.Util._inRange(r,247.5,292.5)?"ew-resize":i.Util._inRange(r,292.5,337.5)?"nwse-resize":(i.Util.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}(t,n,r);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(),r=n.padding();t.beginPath(),t.rect(-r,-r,e.width()+2*r,e.height()+2*r),t.moveTo(e.width()/2,-r),n.rotateEnabled()&&n.rotateLineVisible()&&t.lineTo(e.width()/2,-n.rotateAnchorOffset()*i.Util._sign(e.height())-r),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,i=e.height,r=Math.sqrt(Math.pow(n,2)+Math.pow(i,2));this.sin=Math.abs(i/r),this.cos=Math.abs(n/r),"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},b++,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,i;const r=this.findOne("."+this._movingAnchorName),o=r.getStage();o.setPointersPositions(t);const a=o.getPointerPosition();let s={x:a.x-this._anchorDragOffset.x,y:a.y-this._anchorDragOffset.y};const l=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(s=this.anchorDragBoundFunc()(l,s,t)),r.setAbsolutePosition(s);const u=r.getAbsolutePosition();if(l.x===u.x&&l.y===u.y)return;if("rotater"===this._movingAnchorName){const i=this._getNodeRect();e=r.x()-i.width/2,n=-r.y()+i.height/2;let o=Math.atan2(-n,e)+Math.PI/2;i.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 i=e;for(let r=0;r<t.length;r++){const o=c.Konva.getAngle(t[r]),a=Math.abs(o-e)%(2*Math.PI);Math.min(a,2*Math.PI-a)<n&&(i=o)}return i}(this.rotationSnaps(),a,s),u=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 w(t,e,n)}(i,l-i.rotation);return void this._fitNodesInto(u,t)}const h=this.shiftBehavior();let d;d="inverted"===h?this.keepRatio()&&!t.shiftKey:"none"===h?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()};i=Math.sqrt(Math.pow(t.x-r.x(),2)+Math.pow(t.y-r.y(),2));const o=this.findOne(".top-left").x()>t.x?-1:1,a=this.findOne(".top-left").y()>t.y?-1:1;e=i*this.cos*o,n=i*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(r.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()};i=Math.sqrt(Math.pow(r.x()-t.x,2)+Math.pow(t.y-r.y(),2));const o=this.findOne(".top-right").x()<t.x?-1:1,a=this.findOne(".top-right").y()>t.y?-1:1;e=i*this.cos*o,n=i*this.sin*a,this.findOne(".top-right").x(t.x+e),this.findOne(".top-right").y(t.y-n)}var p=r.position();this.findOne(".top-left").y(p.y),this.findOne(".bottom-right").x(p.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(r.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(r.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()};i=Math.sqrt(Math.pow(t.x-r.x(),2)+Math.pow(r.y()-t.y,2));const o=t.x<r.x()?-1:1,a=r.y()<t.y?-1:1;e=i*this.cos*o,n=i*this.sin*a,r.x(t.x-e),r.y(t.y+n)}p=r.position(),this.findOne(".top-left").x(p.x),this.findOne(".bottom-right").y(p.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(r.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()};i=Math.sqrt(Math.pow(r.x()-t.x,2)+Math.pow(r.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=i*this.cos*o,n=i*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(),i=t.y(),r=this.getWidth()-e.x(),o=this.getHeight()-e.y();e.move({x:-n,y:-i}),t.move({x:r,y:o})}const g=this.findOne(".top-left").getAbsolutePosition();e=g.x,n=g.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();b--,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(i.Util._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(i.Util._inRange(t.height,2*-this.padding()-1,1))return void this.update();const r=new i.Transform;if(r.rotate(c.Konva.getAngle(this.rotation())),this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){const e=r.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=r.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=r.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=r.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:i.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const o=1e7,a=new i.Transform;a.translate(n.x,n.y),a.rotate(n.rotation),a.scale(n.width/o,n.height/o);const s=new i.Transform,l=t.width/o,u=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(u))):(s.translate(t.x,t.y),s.rotate(t.rotation),s.scale(l,u));const h=s.multiply(a.invert());this._nodes.forEach(t=>{var e;const n=t.getParent().getAbsoluteTransform(),r=t.getTransform().copy();r.translate(t.offsetX(),t.offsetY());const o=new i.Transform;o.multiply(n.copy().invert()).multiply(h).multiply(n).multiply(r);const a=o.decompose();t.setAttrs(a),null===(e=t.getLayer())||void 0===e||e.batchDraw()}),this.rotation(i.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(i.Util._getRotation(e.rotation));const n=e.width,r=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:r/2,offsetX:l/2+s,visible:a&&o.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:l/2-s,visible:a&&o.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:l/2+s,offsetY:l/2-s,visible:a&&o.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:l/2-s,visible:a&&o.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:l/2-s,offsetY:l/2-s,visible:a&&o.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:n/2,y:-this.rotateAnchorOffset()*i.Util._sign(r)-s,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const u=this.anchorStyleFunc();u&&c.forEach(t=>{u(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=C,C.isTransforming=()=>b>0,C.prototype.className="Transformer",(0,h._registerNode)(C),r.Factory.addGetterSetter(C,"enabledAnchors",v,function(t){return t instanceof Array||i.Util.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach(function(t){-1===v.indexOf(t)&&i.Util.warn("Unknown anchor name: "+t+". Available names are: "+v.join(", "))}),t||[]}),r.Factory.addGetterSetter(C,"flipEnabled",!0,(0,u.getBooleanValidator)()),r.Factory.addGetterSetter(C,"resizeEnabled",!0),r.Factory.addGetterSetter(C,"anchorSize",10,(0,u.getNumberValidator)()),r.Factory.addGetterSetter(C,"rotateEnabled",!0),r.Factory.addGetterSetter(C,"rotateLineVisible",!0),r.Factory.addGetterSetter(C,"rotationSnaps",[]),r.Factory.addGetterSetter(C,"rotateAnchorOffset",50,(0,u.getNumberValidator)()),r.Factory.addGetterSetter(C,"rotateAnchorCursor","crosshair"),r.Factory.addGetterSetter(C,"rotationSnapTolerance",5,(0,u.getNumberValidator)()),r.Factory.addGetterSetter(C,"borderEnabled",!0),r.Factory.addGetterSetter(C,"anchorStroke","rgb(0, 161, 255)"),r.Factory.addGetterSetter(C,"anchorStrokeWidth",1,(0,u.getNumberValidator)()),r.Factory.addGetterSetter(C,"anchorFill","white"),r.Factory.addGetterSetter(C,"anchorCornerRadius",0,(0,u.getNumberValidator)()),r.Factory.addGetterSetter(C,"borderStroke","rgb(0, 161, 255)"),r.Factory.addGetterSetter(C,"borderStrokeWidth",1,(0,u.getNumberValidator)()),r.Factory.addGetterSetter(C,"borderDash"),r.Factory.addGetterSetter(C,"keepRatio",!0),r.Factory.addGetterSetter(C,"shiftBehavior","default"),r.Factory.addGetterSetter(C,"centeredScaling",!1),r.Factory.addGetterSetter(C,"ignoreStroke",!1),r.Factory.addGetterSetter(C,"padding",0,(0,u.getNumberValidator)()),r.Factory.addGetterSetter(C,"nodes"),r.Factory.addGetterSetter(C,"node"),r.Factory.addGetterSetter(C,"boundBoxFunc"),r.Factory.addGetterSetter(C,"anchorDragBoundFunc"),r.Factory.addGetterSetter(C,"anchorStyleFunc"),r.Factory.addGetterSetter(C,"shouldOverdrawWholeArea",!1),r.Factory.addGetterSetter(C,"useSingleNodeRotation",!0),r.Factory.backCompat(C,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"})},5072:t=>{"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var o={},a=[],s=0;s<t.length;s++){var l=t[s],c=i.base?l[0]+i.base:l[0],u=o[c]||0,h="".concat(c," ").concat(u);o[c]=u+1;var d=n(h),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 p=r(f,i);i.byIndex=s,e.splice(s,0,{identifier:h,updater:p,references:1})}a.push(h)}return a}function r(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,r){var o=i(t=t||[],r=r||{});return function(t){t=t||[];for(var a=0;a<o.length;a++){var s=n(o[a]);e[s].references--}for(var l=i(t,r),c=0;c<o.length;c++){var u=n(o[c]);0===e[u].references&&(e[u].updater(),e.splice(u,1))}o=l}}},5155:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Rect=void 0;const i=n(4892),r=n(4723),o=n(8871),a=n(4060),s=n(5483);class l extends r.Shape{_sceneFunc(t){const e=this.cornerRadius(),n=this.width(),i=this.height();t.beginPath(),e?a.Util.drawRoundedRectPath(t,n,i,e):t.rect(0,0,n,i),t.closePath(),t.fillStrokeShape(this)}}e.Rect=l,l.prototype.className="Rect",(0,o._registerNode)(l),i.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 i=n(4892),r=n(4723),o=n(5483),a=n(8871),s=2*Math.PI;class l extends r.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),i.Factory.addGetterSetter(l,"innerRadius",0,(0,o.getNumberValidator)()),i.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 i=n(4892),r=n(6536),o=n(5483);i.Factory.addGetterSetter(r.Node,"hue",0,(0,o.getNumberValidator)(),i.Factory.afterSetFilter),i.Factory.addGetterSetter(r.Node,"saturation",0,(0,o.getNumberValidator)(),i.Factory.afterSetFilter),i.Factory.addGetterSetter(r.Node,"luminance",0,(0,o.getNumberValidator)(),i.Factory.afterSetFilter),e.HSL=function(t){const e=t.data,n=e.length,i=Math.pow(2,this.saturation()),r=Math.abs(this.hue()+360)%360,o=127*this.luminance(),a=1*i*Math.cos(r*Math.PI/180),s=1*i*Math.sin(r*Math.PI/180),l=.299+.701*a+.167*s,c=.587-.587*a+.33*s,u=.114-.114*a-.497*s,h=.299-.299*a-.328*s,d=.587+.413*a+.035*s,f=.114-.114*a+.293*s,p=.299-.3*a+1.25*s,g=.587-.586*a-1.05*s,m=.114+.886*a-.2*s;let y,v,w,b;for(let t=0;t<n;t+=4)y=e[t+0],v=e[t+1],w=e[t+2],b=e[t+3],e[t+0]=l*y+c*v+u*w+o,e[t+1]=h*y+d*v+f*w+o,e[t+2]=p*y+g*v+m*w+o,e[t+3]=b}},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(i.Konva.isUnminified)return function(t,e){return r.Util._isNumber(t)||r.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}},e.getNumberOrArrayOfNumbersValidator=function(t){if(i.Konva.isUnminified)return function(e,n){let i=r.Util._isNumber(e),a=r.Util._isArray(e)&&e.length==t;return i||a||r.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(i.Konva.isUnminified)return function(t,e){return r.Util._isNumber(t)||"auto"===t||r.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(i.Konva.isUnminified)return function(t,e){return r.Util._isString(t)||r.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}},e.getStringOrGradientValidator=function(){if(i.Konva.isUnminified)return function(t,e){const n=r.Util._isString(t),i="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return n||i||r.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(i.Konva.isUnminified)return function(t,e){return r.Util._isFunction(t)||r.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),t}},e.getNumberArrayValidator=function(){if(i.Konva.isUnminified)return function(t,e){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&t instanceof n||(r.Util._isArray(t)?t.forEach(function(t){r.Util._isNumber(t)||r.Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):r.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(i.Konva.isUnminified)return function(t,e){return!0===t||!1===t||r.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}},e.getComponentValidator=function(t){if(i.Konva.isUnminified)return function(e,n){return null==e||r.Util.isObject(e)||r.Util.warn(o(e)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+t),e}};const i=n(8871),r=n(4060);function o(t){return r.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||r.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}},5540:(t,e,n)=>{"use strict";t=n.hmd(t);var i,r=(i="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var e,n,r=void 0!==t?t:{};r.ready=new Promise(function(t,i){e=t,n=i});var o,a=Object.assign({},r),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),i&&(c=i),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)})),r.print||console.log.bind(console);var u,h,d=r.printErr||console.warn.bind(console);Object.assign(r,a),a=null,r.arguments&&r.arguments,r.thisProgram&&r.thisProgram,r.quit&&r.quit,r.wasmBinary&&(u=r.wasmBinary),r.noExitRuntime,"object"!=typeof WebAssembly&&P("no native wasm support detected");var f,p,g,m=!1;function y(){var t=h.buffer;r.HEAP8=f=new Int8Array(t),r.HEAP16=new Int16Array(t),r.HEAP32=new Int32Array(t),r.HEAPU8=p=new Uint8Array(t),r.HEAPU16=new Uint16Array(t),r.HEAPU32=g=new Uint32Array(t),r.HEAPF32=new Float32Array(t),r.HEAPF64=new Float64Array(t)}var v=[],w=[],b=[];function C(t){v.unshift(t)}function _(t){b.unshift(t)}var A,S,E=0,x=null,M=null;function P(t){r.onAbort&&r.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 N(t){return t.startsWith("data:application/octet-stream;base64,")}function T(t){try{if(t==A&&u)return new Uint8Array(u);if(o)return o(t);throw"both async and sync fetching of the wasm failed"}catch(t){P(t)}}function F(t,e,n){return function(t){return u||!s&&!l||"function"!=typeof fetch?Promise.resolve().then(function(){return T(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 T(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),P(t)})}function I(t){for(;t.length>0;)t.shift()(r)}function L(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){g[this.ptr+4>>2]=t},this.get_type=function(){return g[this.ptr+4>>2]},this.set_destructor=function(t){g[this.ptr+8>>2]=t},this.get_destructor=function(){return g[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){g[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return g[this.ptr+16>>2]},this.get_exception_ptr=function(){if(W(this.get_type()))return g[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function O(t){var e=h.buffer;try{return h.grow(t-e.byteLength+65535>>>16),y(),1}catch(t){}}function R(t){return r["_"+t]}N(A="wasmDbscan.wasm")||(S=A,A=r.locateFile?r.locateFile(S,c):c+S);var D="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function k(t,e,n,i,r){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 i=t.charCodeAt(n);i<=127?e++:i<=2047?e+=2:i>=55296&&i<=57343?(e+=4,++n):e+=3}return e}(t)+1,n=z(e);return function(t,e,n){!function(t,e,n,i){if(!(i>0))return 0;for(var r=n+i-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>=r)break;e[n++]=a}else if(a<=2047){if(n+1>=r)break;e[n++]=192|a>>6,e[n++]=128|63&a}else if(a<=65535){if(n+2>=r)break;e[n++]=224|a>>12,e[n++]=128|a>>6&63,e[n++]=128|63&a}else{if(n+3>=r)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,p,e,n)}(t,n,e),n}(t)),e},array:t=>{var e,n,i=z(t.length);return e=t,n=i,f.set(e,n),i}},a=R(t),s=[],l=0;if(i)for(var c=0;c<i.length;c++){var u=o[n[c]];u?(0===l&&(l=B()),s[c]=u(i[c])):s[c]=i[c]}var h=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 i=e+n,r=e;t[r]&&!(r>=i);)++r;if(r-e>16&&t.buffer&&D)return D.decode(t.subarray(e,r));for(var o="";e<r;){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}(p,n,i):"":"boolean"===e?Boolean(t):t;var n,i}(t)}(h)}var G,U={__cxa_throw:function(t,e,n){throw new L(t).init(e,n),t},abort:function(){P("")},emscripten_memcpy_big:function(t,e,n){p.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e=p.length,n=2147483648;if((t>>>=0)>n)return!1;let i=(t,e)=>t+(e-t%e)%e;for(var r=1;r<=4;r*=2){var o=e*(1+.2/r);if(o=Math.min(o,t+100663296),O(Math.min(n,i(Math.max(t,o),65536))))return!0}return!1}},B=(function(){var t,e,i,o,a={env:U,wasi_snapshot_preview1:U};function s(t,e){var n,i=t.exports;return r.asm=i,h=r.asm.memory,y(),r.asm.__indirect_function_table,n=r.asm.__wasm_call_ctors,w.unshift(n),function(){if(E--,r.monitorRunDependencies&&r.monitorRunDependencies(E),0==E&&(null!==x&&(clearInterval(x),x=null),M)){var t=M;M=null,t()}}(),i}if(E++,r.monitorRunDependencies&&r.monitorRunDependencies(E),r.instantiateWasm)try{return r.instantiateWasm(a,s)}catch(t){d("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=u,e=A,i=a,o=function(t){s(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||N(e)||"function"!=typeof fetch?F(e,i,o):fetch(e,{credentials:"same-origin"}).then(function(t){return WebAssembly.instantiateStreaming(t,i).then(o,function(t){return d("wasm streaming compile failed: "+t),d("falling back to ArrayBuffer instantiation"),F(e,i,o)})})).catch(n)}(),r._dbscan=function(){return(r._dbscan=r.asm.dbscan).apply(null,arguments)},r._malloc=function(){return(r._malloc=r.asm.malloc).apply(null,arguments)},r._free=function(){return(r._free=r.asm.free).apply(null,arguments)},function(){return(B=r.asm.stackSave).apply(null,arguments)}),V=function(){return(V=r.asm.stackRestore).apply(null,arguments)},z=function(){return(z=r.asm.stackAlloc).apply(null,arguments)},W=function(){return(W=r.asm.__cxa_is_pointer_type).apply(null,arguments)};function H(){function t(){G||(G=!0,r.calledRun=!0,m||(I(w),e(r),r.onRuntimeInitialized&&r.onRuntimeInitialized(),function(){if(r.postRun)for("function"==typeof r.postRun&&(r.postRun=[r.postRun]);r.postRun.length;)_(r.postRun.shift());I(b)}()))}E>0||(function(){if(r.preRun)for("function"==typeof r.preRun&&(r.preRun=[r.preRun]);r.preRun.length;)C(r.preRun.shift());I(v)}(),E>0||(r.setStatus?(r.setStatus("Running..."),setTimeout(function(){setTimeout(function(){r.setStatus("")},1),t()},1)):t()))}if(r.ccall=k,r.cwrap=function(t,e,n,i){var r=!n||n.every(t=>"number"===t||"boolean"===t);return"string"!==e&&r&&!i?R(t):function(){return k(t,e,n,arguments)}},M=function t(){G||H(),G||(M=t)},r.preInit)for("function"==typeof r.preInit&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return H(),t.ready});"object"==typeof exports?t.exports=r:"function"==typeof define&&n.amdO?define([],function(){return r}):"object"==typeof exports&&(exports.exportCppDbscanLib=r)},5553:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Kaleidoscope=void 0;const i=n(4892),r=n(6536),o=n(4060),a=n(5483);e.Kaleidoscope=function(t){const e=t.width,n=t.height;let i,r,a,s,l,c,u,h,d,f,p=Math.round(this.kaleidoscopePower());const g=Math.round(this.kaleidoscopeAngle()),m=Math.floor(e*(g%360)/360);if(p<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 i=t.data,r=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),u=o-s,h=a-l;const d=Math.sqrt(u*u+h*h);c=d>c?d:c;const f=a,p=o,g=360/p*Math.PI/180;for(let t=0;t<p;t+=1){const e=Math.sin(t*g),n=Math.cos(t*g);for(let a=0;a<f;a+=1){u=Math.floor(s+c*a/f*n),h=Math.floor(l+c*a/f*e);let d=4*(h*o+u);const p=i[d+0],g=i[d+1],m=i[d+2],y=i[d+3];d=4*(t+a*o),r[d+0]=p,r[d+1]=g,r[d+2]=m,r[d+3]=y}}}(t,v,{polarCenterX:e/2,polarCenterY:n/2});let w=e/Math.pow(2,p);for(;w<=8;)w*=2,p-=1;w=Math.ceil(w);let b=w,C=0,_=b,A=1;for(m+w>e&&(C=b,_=0,A=-1),r=0;r<n;r+=1)for(i=C;i!==_;i+=A)a=Math.round(i+m)%e,d=4*(e*r+a),l=v.data[d+0],c=v.data[d+1],u=v.data[d+2],h=v.data[d+3],f=4*(e*r+i),v.data[f+0]=l,v.data[f+1]=c,v.data[f+2]=u,v.data[f+3]=h;for(r=0;r<n;r+=1)for(b=Math.floor(w),s=0;s<p;s+=1){for(i=0;i<b+1;i+=1)d=4*(e*r+i),l=v.data[d+0],c=v.data[d+1],u=v.data[d+2],h=v.data[d+3],f=4*(e*r+2*b-i-1),v.data[f+0]=l,v.data[f+1]=c,v.data[f+2]=u,v.data[f+3]=h;b*=2}!function(t,e,n){const i=t.data,r=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),u=o-s,h=a-l;const d=Math.sqrt(u*u+h*h);c=d>c?d:c;const f=a,p=o,g=n.polarRotation||0;let m,y;for(u=0;u<o;u+=1)for(h=0;h<a;h+=1){const t=u-s,e=h-l,n=Math.sqrt(t*t+e*e)*f/c;let a=(180*Math.atan2(e,t)/Math.PI+360+g)%360;a=a*p/360,m=Math.floor(a),y=Math.floor(n);let d=4*(y*o+m);const v=i[d+0],w=i[d+1],b=i[d+2],C=i[d+3];d=4*(h*o+u),r[d+0]=v,r[d+1]=w,r[d+2]=b,r[d+3]=C}}(v,t,{polarRotation:0})},i.Factory.addGetterSetter(r.Node,"kaleidoscopePower",2,(0,a.getNumberValidator)(),i.Factory.afterSetFilter),i.Factory.addGetterSetter(r.Node,"kaleidoscopeAngle",0,(0,a.getNumberValidator)(),i.Factory.afterSetFilter)},5570:(t,e)=>{"use strict";function n(t,e,n){const r=i(1,n,t),o=i(1,n,e),a=r*r+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,i,r)=>{let o,a;const s=r/2;o=0;for(let r=0;r<20;r++)a=s*e.tValues[20][r]+s,o+=e.cValues[20][r]*n(t,i,a);return s*o},e.getQuadraticArcLength=(t,e,n)=>{void 0===n&&(n=1);const i=t[0]-2*t[1]+t[2],r=e[0]-2*e[1]+e[2],o=2*t[1]-2*t[0],a=2*e[1]-2*e[0],s=4*(i*i+r*r),l=4*(i*o+r*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 u=l/(2*s),h=n+u,d=c/s-u*u,f=h*h+d>0?Math.sqrt(h*h+d):0,p=u*u+d>0?Math.sqrt(u*u+d):0,g=u+Math.sqrt(u*u+d)!==0?d*Math.log(Math.abs((h+f)/(u+p))):0;return Math.sqrt(s)/2*(h*f-u*p+g)};const i=(t,n,r)=>{const o=r.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)*r[t];return s}a=new Array(o);for(let t=0;t<o;t++)a[t]=o*(r[t+1]-r[t]);return i(t-1,n,a)};e.t2length=(t,e,n)=>{let i=1,r=t/e,o=(t-n(r))/e,a=0;for(;i>.001;){const s=n(r+o),l=Math.abs(t-s)/e;if(l<i)i=l,r+=o;else{const a=n(r-o),s=Math.abs(t-a)/e;s<i?(i=s,r-=o):o/=2}if(a++,a>500)break}return r}},5778:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(8558);t.exports=i.Konva},5992:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Noise=void 0;const i=n(4892),r=n(6536),o=n(5483);e.Noise=function(t){const e=255*this.noise(),n=t.data,i=n.length,r=e/2;for(let t=0;t<i;t+=4)n[t+0]+=r-2*r*Math.random(),n[t+1]+=r-2*r*Math.random(),n[t+2]+=r-2*r*Math.random()},i.Factory.addGetterSetter(r.Node,"noise",.2,(0,o.getNumberValidator)(),i.Factory.afterSetFilter)},6261:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Blur=void 0;const i=n(4892),r=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,i=t.width,r=t.height;let o,c,u,h,d,f,p,g,m,y,v,w,b,C,_,A,S,E,x,M;const P=e+e+1,N=i-1,T=r-1,F=e+1,I=F*(F+1)/2,L=new a,O=s[e],R=l[e];let D=null,k=L,G=null,U=null;for(let t=1;t<P;t++)k=k.next=new a,t===F&&(D=k);k.next=L,u=c=0;for(let t=0;t<r;t++){w=b=C=_=h=d=f=p=0,g=F*(A=n[c]),m=F*(S=n[c+1]),y=F*(E=n[c+2]),v=F*(x=n[c+3]),h+=I*A,d+=I*S,f+=I*E,p+=I*x,k=L;for(let t=0;t<F;t++)k.r=A,k.g=S,k.b=E,k.a=x,k=k.next;for(let t=1;t<F;t++)o=c+((N<t?N:t)<<2),h+=(k.r=A=n[o])*(M=F-t),d+=(k.g=S=n[o+1])*M,f+=(k.b=E=n[o+2])*M,p+=(k.a=x=n[o+3])*M,w+=A,b+=S,C+=E,_+=x,k=k.next;G=L,U=D;for(let t=0;t<i;t++)n[c+3]=x=p*O>>R,0!==x?(x=255/x,n[c]=(h*O>>R)*x,n[c+1]=(d*O>>R)*x,n[c+2]=(f*O>>R)*x):n[c]=n[c+1]=n[c+2]=0,h-=g,d-=m,f-=y,p-=v,g-=G.r,m-=G.g,y-=G.b,v-=G.a,o=u+((o=t+e+1)<N?o:N)<<2,w+=G.r=n[o],b+=G.g=n[o+1],C+=G.b=n[o+2],_+=G.a=n[o+3],h+=w,d+=b,f+=C,p+=_,G=G.next,g+=A=U.r,m+=S=U.g,y+=E=U.b,v+=x=U.a,w-=A,b-=S,C-=E,_-=x,U=U.next,c+=4;u+=i}for(let t=0;t<i;t++){b=C=_=w=d=f=p=h=0,c=t<<2,g=F*(A=n[c]),m=F*(S=n[c+1]),y=F*(E=n[c+2]),v=F*(x=n[c+3]),h+=I*A,d+=I*S,f+=I*E,p+=I*x,k=L;for(let t=0;t<F;t++)k.r=A,k.g=S,k.b=E,k.a=x,k=k.next;let a=i;for(let r=1;r<=e;r++)c=a+t<<2,h+=(k.r=A=n[c])*(M=F-r),d+=(k.g=S=n[c+1])*M,f+=(k.b=E=n[c+2])*M,p+=(k.a=x=n[c+3])*M,w+=A,b+=S,C+=E,_+=x,k=k.next,r<T&&(a+=i);c=t,G=L,U=D;for(let e=0;e<r;e++)o=c<<2,n[o+3]=x=p*O>>R,x>0?(x=255/x,n[o]=(h*O>>R)*x,n[o+1]=(d*O>>R)*x,n[o+2]=(f*O>>R)*x):n[o]=n[o+1]=n[o+2]=0,h-=g,d-=m,f-=y,p-=v,g-=G.r,m-=G.g,y-=G.b,v-=G.a,o=t+((o=e+F)<T?o:T)*i<<2,h+=w+=G.r=n[o],d+=b+=G.g=n[o+1],f+=C+=G.b=n[o+2],p+=_+=G.a=n[o+3],G=G.next,g+=A=U.r,m+=S=U.g,y+=E=U.b,v+=x=U.a,w-=A,b-=S,C-=E,_-=x,U=U.next,c+=i}}(t,e)},i.Factory.addGetterSetter(r.Node,"blurRadius",0,(0,o.getNumberValidator)(),i.Factory.afterSetFilter)},6267:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Layer=void 0;const i=n(4060),r=n(4473),o=n(6536),a=n(4892),s=n(8604),l=n(5483),c=n(4723),u=n(8871),h=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],d=h.length;class f extends r.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&&i.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&&i.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(){i.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){i.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,i.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 i=0;i<d;i++){const r=h[i],o=this._getIntersection({x:t.x+r.x*e,y:t.y+r.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,r=n[3];if(255===r){const t=i.Util._rgbToHex(n[0],n[1],n[2]),e=c.shapes["#"+t];return e?{shape:e}:{antialiased:!0}}return r>0?{antialiased:!0}:{}}drawScene(t,e,n){const i=this.getLayer(),o=t||i&&i.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&o.getContext().clear(),r.Container.prototype.drawScene.call(this,o,e,n),this._fire("draw",{node:this}),this}drawHit(t,e){const n=this.getLayer(),i=t||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),r.Container.prototype.drawHit.call(this,i,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){i.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return i.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 i.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}e.Layer=f,f.prototype.nodeType="Layer",(0,u._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="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n}).join("")},e.i=function(t,n,i,r,o){"string"==typeof t&&(t=[[null,t,void 0]]);var a={};if(i)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 u=[].concat(t[c]);i&&a[u[0]]||(void 0!==o&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=o),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),r&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=r):u[4]="".concat(r)),e.push(u))}},e}},6536:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Node=void 0;const i=n(8604),r=n(1268),o=n(4892),a=n(8871),s=n(4060),l=n(5483),c="absoluteOpacity",u="allEventListeners",h="absoluteTransform",d="absoluteScale",f="canvas",p="listening",g="Shape",m=" ",y="stage",v="transform",w="visible",b=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(m);let C=1;class _{constructor(t){this._id=C++,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!==h||!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===h)&&!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===h&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(f)){const{scene:t,filter:e,hit:n,buffer:i}=this._cache.get(f);s.Util.releaseCanvas(t,e,n,i),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 r=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,u=void 0===e.y?Math.floor(n.y):e.y,h=e.offset||0,p=e.drawBorder||!1,g=e.hitCanvasPixelRatio||1;if(!r||!o)return void s.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");r+=2*h+(Math.abs(Math.round(n.x)-l)>.5?1:0),o+=2*h+(Math.abs(Math.round(n.y)-u)>.5?1:0),l-=h,u-=h;const m=new i.SceneCanvas({pixelRatio:a,width:r,height:o}),y=new i.SceneCanvas({pixelRatio:a,width:0,height:0,willReadFrequently:!0}),v=new i.HitCanvas({pixelRatio:g,width:r,height:o}),w=m.getContext(),b=v.getContext(),C=new i.SceneCanvas({width:m.width/m.pixelRatio+Math.abs(l),height:m.height/m.pixelRatio+Math.abs(u),pixelRatio:m.pixelRatio}),_=C.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),w.save(),b.save(),_.save(),w.translate(-l,-u),b.translate(-l,-u),_.translate(-l,-u),C.x=l,C.y=u,this._isUnderCache=!0,this._clearSelfAndDescendantCache(c),this._clearSelfAndDescendantCache(d),this.drawScene(m,this,C),this.drawHit(v,this),this._isUnderCache=!1,w.restore(),b.restore(),p&&(w.save(),w.beginPath(),w.rect(0,0,r,o),w.closePath(),w.setAttr("strokeStyle","red"),w.setAttr("lineWidth",5),w.stroke(),w.restore()),this._cache.set(f,{scene:m,filter:y,hit:v,buffer:C,x:l,y:u}),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 i=1/0,r=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===i&&(i=o=e.x,r=a=e.y),i=Math.min(i,e.x),r=Math.min(r,e.y),o=Math.max(o,e.x),a=Math.max(a,e.y)}),{x:i,y:r,width:o-i,height:a-r}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const n=this._getCachedSceneCanvas(),i=n.pixelRatio;t.drawImage(n._canvas,0,0,n.width/i,n.height/i),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,i,r=this.filters(),o=this._getCanvasCache(),a=o.scene,l=o.filter,c=l.getContext();if(r){if(!this._filterUpToDate){const o=a.pixelRatio;l.setSize(a.width/a.pixelRatio,a.height/a.pixelRatio);try{for(t=r.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++)i=r[n],"function"==typeof i?(i.call(this,e),c.putImageData(e,0,0)):s.Util.error("Filter should be type of function, but got "+typeof i+" 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(u),3===arguments.length)return this._delegate.apply(this,arguments);const n=t.split(m);for(let t=0;t<n.length;t++){const i=n[t].split("."),r=i[0],o=i[1]||"";this.eventListeners[r]||(this.eventListeners[r]=[]),this.eventListeners[r].push({name:o,handler:e})}return this}off(t,e){let n,i,r,o,a,s,l=(t||"").split(m),c=l.length;if(this._cache&&this._cache.delete(u),!t)for(i in this.eventListeners)this._off(i);for(n=0;n<c;n++)if(r=l[n],o=r.split("."),a=o[0],s=o[1],a)this.eventListeners[a]&&this._off(a,s,e);else for(i in this.eventListeners)this._off(i,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 i=this;this.on(t,function(t){const r=t.target.findAncestors(e,!0,i);for(let e=0;e<r.length;e++)(t=s.Util.cloneObject(t)).currentTarget=r[e],n.call(r[e],t)})}remove(){return this.isDragging()&&this.stopDrag(),r.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(h),this._clearSelfAndDescendantCache(c),this._clearSelfAndDescendantCache(d),this._clearSelfAndDescendantCache(y),this._clearSelfAndDescendantCache(w),this._clearSelfAndDescendantCache(p)}_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(p,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(w,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 i=!1;r.DD._dragElements.forEach(t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===n)&&(i=!0)});const o=!e&&!a.Konva.hitOnDragEnabled&&(i||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,i,r=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++)i=l[n],a++,i.nodeType!==g&&(t=t.concat(i.getChildren().slice())),i._id===o._id&&(n=e);t.length>0&&t[0].getDepth()<=r&&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(h)),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 i=this.getAbsoluteTransform(t).getMatrix(),r=new s.Transform,o=this.offset();return r.m=i.slice(),r.translate(o.x,o.y),r.getTranslation()}setAbsolutePosition(t){const{x:e,y:n,...i}=this._clearTransform();this.attrs.x=e,this.attrs.y=n,this._clearCache(v);const r=this._getAbsoluteTransform().copy();return r.invert(),r.translate(t.x,t.y),t={x:this.attrs.x+r.getTranslation().x,y:this.attrs.y+r.getTranslation().y},this._setTransform(i),this.setPosition({x:t.x,y:t.y}),this._clearCache(v),this._clearSelfAndDescendantCache(h),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,i=this.x(),r=this.y();return void 0!==e&&(i+=e),void 0!==n&&(r+=n),this.setPosition({x:i,y:r}),this}_eachAncestorReverse(t,e){let n,i,r=[],o=this.getParent();if(!e||e._id!==this._id){for(r.unshift(this);o&&(!e||o._id!==e._id);)r.unshift(o),o=o.parent;for(n=r.length,i=0;i<n;i++)t(r[i])}}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,i,r,o=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(t in o)e=o[t],r=s.Util.isObject(e)&&!s.Util._isPlainObject(e)&&!s.Util._isArray(e),r||(n="function"==typeof this[t]&&this[t],delete o[t],i=n?n.call(this):null,o[t]=e,i!==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 i=[];e&&this._isMatch(t)&&i.push(this);let r=this.parent;for(;r;){if(r===n)return i;r._isMatch(t)&&i.push(r),r=r.parent}return i}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,i=t.replace(/ /g,"").split(","),r=i.length;for(e=0;e<r;e++)if(n=i[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(h,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(h)||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,i=this.attrs.offsetX||0,r=this.attrs.offsetY||0;e.translate(t-i,n-r)}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 i=this.x(),r=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,u=this.attrs.skewX||0,h=this.attrs.skewY||0,d=this.attrs.offsetX||0,f=this.attrs.offsetY||0;return 0===i&&0===r||n.translate(i,r),0!==o&&n.rotate(o),0===u&&0===h||n.skew(u,h),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,i,r,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],i=n.length,r=0;r<i;r++)o=n[r],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(),r=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 i.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 i.SceneCanvas({width:s.width/s.pixelRatio+Math.abs(r),height:s.height/s.pixelRatio+Math.abs(o),pixelRatio:s.pixelRatio});return!1===t.imageSmoothingEnabled&&(l._context.imageSmoothingEnabled=!1),l.save(),(r||o)&&l.translate(-1*r,-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,i=this._toKonvaCanvas(t).toDataURL(e,n);return t.callback&&t.callback(i),i}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 i,r,o,a=this.eventListeners[t];for(i=0;i<a.length;i++)if(r=a[i].name,o=a[i].handler,!("konva"===r&&"konva"!==e||e&&r!==e||n&&n!==o)){if(a.splice(i,1),0===a.length){delete this.eventListeners[t];break}i--}}_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 i;void 0!==n&&(i=this.attrs[t],i||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=n,this._fireChangeEvent(t,i,n))}_fireAndBubble(t,e,n){e&&this.nodeType===g&&(e.target=this);const i=["mouseenter","mouseleave","pointerenter","pointerleave","touchenter","touchleave"];if(-1===i.indexOf(t)||!(n&&(this===n||this.isAncestorOf&&this.isAncestorOf(n))||"Stage"===this.nodeType&&!n)){this._fire(t,e);const r=-1!==i.indexOf(t)&&n&&n.isAncestorOf&&n.isAncestorOf(this)&&!n.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!r&&(n&&n.parent?this._fireAndBubble.call(this.parent,t,e,n):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,n,i;const r=null!==(e=this._cache.get(u))&&void 0!==e?e:{};let o=null==r?void 0:r[t];if(void 0===o){o=[];let e=Object.getPrototypeOf(this);for(;e;){const r=null!==(i=null===(n=e.eventListeners)||void 0===n?void 0:n[t])&&void 0!==i?i:[];o.push(...r),e=Object.getPrototypeOf(e)}r[t]=o,this._cache.set(u,r)}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 i=this.eventListeners[t];if(i)for(let t=0;t<i.length;t++)i[t].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,n=this.getStage(),i=this.getAbsolutePosition();if(!n)return;const o=n._getPointerById(e)||n._changedPointerPositions[0]||i;r.DD._dragElements.set(this._id,{node:this,startPointerPos:o,offset:{x:o.x-i.x,y:o.y-i.y},dragStatus:"ready",pointerId:e})}startDrag(t,e=!0){r.DD._dragElements.has(this._id)||this._createDragElement(t),r.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 i={x:n.x-e.offset.x,y:n.y-e.offset.y};const r=this.dragBoundFunc();if(void 0!==r){const e=r.call(this,i,t);e?i=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===i.x&&this._lastPos.y===i.y||(this.setAbsolutePosition(i),this._requestDraw()),this._lastPos=i}stopDrag(t){const e=r.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),r.DD._endDragBefore(t),r.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=r.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;r.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=r.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,n=t&&"ready"===t.dragStatus;e?this.stopDrag():n&&r.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,i,r,o=_.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(i=l.length,r=0;r<i;r++)n.add(_._createNode(l[r]));return n}}e.Node=_,_.prototype.nodeType="Node",_.prototype._attrsAffectingSize=[],_.prototype.eventListeners={},_.prototype.on.call(_.prototype,b,function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(v),this._clearSelfAndDescendantCache(h))}),_.prototype.on.call(_.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(w)}),_.prototype.on.call(_.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(p)}),_.prototype.on.call(_.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(c)});const A=o.Factory.addGetterSetter;A(_,"zIndex"),A(_,"absolutePosition"),A(_,"position"),A(_,"x",0,(0,l.getNumberValidator)()),A(_,"y",0,(0,l.getNumberValidator)()),A(_,"globalCompositeOperation","source-over",(0,l.getStringValidator)()),A(_,"opacity",1,(0,l.getNumberValidator)()),A(_,"name","",(0,l.getStringValidator)()),A(_,"id","",(0,l.getStringValidator)()),A(_,"rotation",0,(0,l.getNumberValidator)()),o.Factory.addComponentsGetterSetter(_,"scale",["x","y"]),A(_,"scaleX",1,(0,l.getNumberValidator)()),A(_,"scaleY",1,(0,l.getNumberValidator)()),o.Factory.addComponentsGetterSetter(_,"skew",["x","y"]),A(_,"skewX",0,(0,l.getNumberValidator)()),A(_,"skewY",0,(0,l.getNumberValidator)()),o.Factory.addComponentsGetterSetter(_,"offset",["x","y"]),A(_,"offsetX",0,(0,l.getNumberValidator)()),A(_,"offsetY",0,(0,l.getNumberValidator)()),A(_,"dragDistance",void 0,(0,l.getNumberValidator)()),A(_,"width",0,(0,l.getNumberValidator)()),A(_,"height",0,(0,l.getNumberValidator)()),A(_,"listening",!0,(0,l.getBooleanValidator)()),A(_,"preventDefault",!0,(0,l.getBooleanValidator)()),A(_,"filters",void 0,function(t){return this._filterUpToDate=!1,t}),A(_,"visible",!0,(0,l.getBooleanValidator)()),A(_,"transformsEnabled","all",(0,l.getStringValidator)()),A(_,"size"),A(_,"dragBoundFunc"),A(_,"draggable",!1,(0,l.getBooleanValidator)()),o.Factory.backCompat(_,{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,i=Array.prototype.slice,r=Object.prototype.toString;function o(e,n){var i=e>n?e:n;return t.pow(10,17-~~(t.log(i>0?i:-i)*t.LOG10E))}var a=Array.isArray||function(t){return"[object Array]"===r.call(t)};function s(t){return"[object Function]"===r.call(t)}function l(t){return"number"==typeof t&&t-t===0}function c(){return new c._init(arguments)}function u(){return 0}function h(){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,i){c.arange(t.length).forEach(function(r){n[r][i]=t[r][e]})}),n}for(var i=new Array(t.length),r=0;r<t.length;r++)i[r]=[t[r][e]];return i},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),i=0;i<e;i++)n[i]=[t[i][i]];return n},c.antidiag=function(t){for(var e=c.rows(t)-1,n=new Array(e),i=0;e>=0;e--,i++)n[i]=[t[i][e]];return n},c.transpose=function(t){var e,n,i,r,o,s=[];for(a(t[0])||(t=[t]),n=t.length,i=t[0].length,o=0;o<i;o++){for(e=new Array(n),r=0;r<n;r++)e[r]=t[r][o];s.push(e)}return 1===s.length?s[0]:s},c.map=function(t,e,n){var i,r,o,s,l;for(a(t[0])||(t=[t]),r=t.length,o=t[0].length,s=n?t:new Array(r),i=0;i<r;i++)for(s[i]||(s[i]=new Array(o)),l=0;l<o;l++)s[i][l]=e(t[i][l],i,l);return 1===s.length?s[0]:s},c.cumreduce=function(t,e,n){var i,r,o,s,l;for(a(t[0])||(t=[t]),r=t.length,o=t[0].length,s=n?t:new Array(r),i=0;i<r;i++)for(s[i]||(s[i]=new Array(o)),o>0&&(s[i][0]=t[i][0]),l=1;l<o;l++)s[i][l]=e(s[i][l-1],t[i][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 i,r,o=new Array(t);for(s(e)&&(n=e,e=t),i=0;i<t;i++)for(o[i]=new Array(e),r=0;r<e;r++)o[i][r]=n(i,r);return o},c.zeros=function(t,e){return l(e)||(e=t),c.create(t,e,u)},c.ones=function(t,e){return l(e)||(e=t),c.create(t,e,h)},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,i=t.length;if(t.length!==t[0].length)return!1;for(e=0;e<i;e++)for(n=0;n<i;n++)if(t[n][e]!==t[e][n])return!1;return!0},c.clear=function(t){return c.alter(t,u)},c.seq=function(t,e,n,i){s(i)||(i=!1);var r,a=[],l=o(t,e),c=(e*l-t*l)/((n-1)*l),u=t;for(r=0;u<=e&&r<n;u=(t*l+c*l*++r)/l)a.push(i?i(u,r):u);return a},c.arange=function(t,n,i){var r,o=[];if(i=i||1,n===e&&(n=t,t=0),t===n||0===i)return[];if(t<n&&i<0)return[];if(t>n&&i>0)return[];if(i>0)for(r=t;r<n;r+=i)o.push(r);else for(r=t;r>n;r+=i)o.push(r);return o},c.slice=function(){function t(t,n,i,r){var o,a=[],s=t.length;if(n===e&&i===e&&r===e)return c.copy(t);if(r=r||1,(n=(n=n||0)>=0?n:s+n)===(i=(i=i||t.length)>=0?i:s+i)||0===r)return[];if(n<i&&r<0)return[];if(n>i&&r>0)return[];if(r>0)for(o=n;o<i;o+=r)a.push(t[o]);else for(o=n;o>i;o+=r)a.push(t[o]);return a}return function(e,n){var i,r;return l((n=n||{}).row)?l(n.col)?e[n.row][n.col]:t(c.rowa(e,n.row),(i=n.col||{}).start,i.end,i.step):l(n.col)?t(c.cola(e,n.col),(r=n.row||{}).start,r.end,r.step):(r=n.row||{},i=n.col||{},t(e,r.start,r.end,r.step).map(function(e){return t(e,i.start,i.end,i.step)}))}}(),c.sliceAssign=function(n,i,r){var o,a;if(l(i.row)){if(l(i.col))return n[i.row][i.col]=r;i.col=i.col||{},i.col.start=i.col.start||0,i.col.end=i.col.end||n[0].length,i.col.step=i.col.step||1,o=c.arange(i.col.start,t.min(n.length,i.col.end),i.col.step);var s=i.row;return o.forEach(function(t,e){n[s][t]=r[e]}),n}if(l(i.col)){i.row=i.row||{},i.row.start=i.row.start||0,i.row.end=i.row.end||n.length,i.row.step=i.row.step||1,a=c.arange(i.row.start,t.min(n[0].length,i.row.end),i.row.step);var u=i.col;return a.forEach(function(t,e){n[t][u]=r[e]}),n}return r[0].length===e&&(r=[r]),i.row.start=i.row.start||0,i.row.end=i.row.end||n.length,i.row.step=i.row.step||1,i.col.start=i.col.start||0,i.col.end=i.col.end||n[0].length,i.col.step=i.col.step||1,a=c.arange(i.row.start,t.min(n.length,i.row.end),i.row.step),o=c.arange(i.col.start,t.min(n[0].length,i.col.end),i.col.step),a.forEach(function(t,e){o.forEach(function(i,o){n[t][i]=r[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?i.call(this):i.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,i=this;return e?(setTimeout(function(){e.call(i,f[t].call(i))}),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 i=this;return n?(setTimeout(function(){n.call(i,f[t].call(i,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 i(t,e){return t-e}function r(t,n,i){return e.max(n,e.min(t,i))}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,i=t.mean(e),r=0,o=e.length;--o>=0;)r+=(n=e[o]-i)*n;return r},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=[],i=0;i<t.length;i++)e[t[i]]||(e[t[i]]=!0,n.push(t[i]));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 i=n.map(e.log),r=t.mean(i);return e.exp(r)},t.median=function(t){var e=t.length,n=t.slice().sort(i);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=[],i=t.length;for(e=1;e<i;e++)n.push(t[e]-t[e-1]);return n},t.rank=function(t){var e,n=[],r={};for(e=0;e<t.length;e++)r[l=t[e]]?r[l]++:(r[l]=1,n.push(l));var o=n.sort(i),a={},s=1;for(e=0;e<o.length;e++){var l,c=r[l=o[e]],u=(s+(s+c-1))/2;a[l]=u,s+=c}return t.map(function(t){return a[t]})},t.mode=function(t){var e,n=t.length,r=t.slice().sort(i),o=1,a=0,s=0,l=[];for(e=0;e<n;e++)r[e]===r[e+1]?o++:(o>a?(l=[r[e]],a=o,s=0):o===a&&(l.push(r[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),i=e.length,r=new Array(i),o=0;o<i;o++)r[o]=e[o]-n;return r},t.stdev=function(n,i){return e.sqrt(t.variance(n,i))},t.pooledstdev=function(n){return e.sqrt(t.pooledvariance(n))},t.meandev=function(n){for(var i=t.mean(n),r=[],o=n.length-1;o>=0;o--)r.push(e.abs(n[o]-i));return t.mean(r)},t.meddev=function(n){for(var i=t.median(n),r=[],o=n.length-1;o>=0;o--)r.push(e.abs(n[o]-i));return t.median(r)},t.coeffvar=function(e){return t.stdev(e)/t.mean(e)},t.quartiles=function(t){var n=t.length,r=t.slice().sort(i);return[r[e.round(n/4)-1],r[e.round(n/2)-1],r[e.round(3*n/4)-1]]},t.quantiles=function(t,n,o,a){var s,l,c,u,h,d=t.slice().sort(i),f=[n.length],p=t.length;for(void 0===o&&(o=3/8),void 0===a&&(a=3/8),s=0;s<n.length;s++)c=p*(l=n[s])+(o+l*(1-o-a)),u=e.floor(r(c,1,p-1)),h=r(c-u,0,1),f[s]=(1-h)*d[u-1]+h*d[u];return f},t.percentile=function(t,e,n){var r=t.slice().sort(i),o=e*(r.length+(n?1:-1))+(n?0:1),a=parseInt(o),s=o-a;return a+1<r.length?r[a-1]+s*(r[a]-r[a-1]):r[a-1]},t.percentileOfScore=function(t,e,n){var i,r,o=0,a=t.length,s=!1;for("strict"===n&&(s=!0),r=0;r<a;r++)i=t[r],(s&&i<e||!s&&i<=e)&&o++;return o/a},t.histogram=function(n,i){i=i||4;var r,o=t.min(n),a=(t.max(n)-o)/i,s=n.length,l=[];for(r=0;r<i;r++)l[r]=0;for(r=0;r<s;r++)l[e.min(e.floor((n[r]-o)/a),i-1)]+=1;return l},t.covariance=function(e,n){var i,r=t.mean(e),o=t.mean(n),a=e.length,s=new Array(a);for(i=0;i<a;i++)s[i]=(e[i]-r)*(n[i]-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,i){for(var r=t.mean(n),o=t.stdev(n),a=n.length,s=0,l=0;l<a;l++)s+=e.pow((n[l]-r)/o,i);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 i=0;i<e.length;i++)(function(e){o[e]=function(i,r){var a=[],s=0,l=this;if(n(i)&&(r=i,i=!1),r)return setTimeout(function(){r.call(l,o[e].call(l,i))}),this;if(this.length>1){for(l=!0===i?this:this.transpose();s<l.length;s++)a[s]=t[e](l[s]);return a}return t[e](this[0],i)}})(e[i])}("cumsum cumprod".split(" ")),function(e){for(var i=0;i<e.length;i++)(function(e){o[e]=function(i,r){var a=[],s=0,l=this;if(n(i)&&(r=i,i=!1),r)return setTimeout(function(){r.call(l,o[e].call(l,i))}),this;if(this.length>1){for("sumrow"!==e&&(l=!0===i?this:this.transpose());s<l.length;s++)a[s]=t[e](l[s]);return!0===i?t[e](t.utils.toVector(a)):a}return t[e](this[0],i)}})(e[i])}("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 i=0;i<e.length;i++)(function(e){o[e]=function(){var i,r=[],a=0,s=this,l=Array.prototype.slice.call(arguments);if(n(l[l.length-1])){i=l[l.length-1];var c=l.slice(0,l.length-1);return setTimeout(function(){i.call(s,o[e].apply(s,c))}),this}i=void 0;var u=function(n){return t[e].apply(s,[n].concat(l))};if(this.length>1){for(s=s.transpose();a<s.length;a++)r[a]=u(s[a]);return r}return u(this[0])}})(e[i])}("quantiles percentileOfScore".split(" "))}(e,Math),function(t,e){t.gammaln=function(t){var n,i,r,o=0,a=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],s=1.000000000190015;for(r=(i=n=t)+5.5,r-=(n+.5)*e.log(r);o<6;o++)s+=a[o]/++i;return e.log(2.5066282746310007*s/n)-r},t.loggam=function(t){var n,i,r,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))),i=1/(n*n),r=2*e.PI,a=c[9],s=8;s>=0;s--)a*=i,a+=c[s];if(o=a/n+.5*e.log(r)+(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,i,r,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,u=0,h=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(r=d,i=d<1?d++:(d-=c=(0|d)-1)-1,n=0;n<8;++n)h=(h+a[n])*i,u=u*i+s[n];if(o=h/u+1,r<d)o/=r;else if(r>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,i){var r,o=t.gammaln(n),a=n,s=1/n,l=s,c=i+1-n,u=1/1e-30,h=1/c,d=h,f=1,p=-~(8.5*e.log(n>=1?n:1/n)+.4*n+17);if(i<0||n<=0)return NaN;if(i<n+1){for(;f<=p;f++)s+=l*=i/++a;return s*e.exp(-i+n*e.log(i)-o)}for(;f<=p;f++)d*=(h=1/(h=(r=-f*(f-n))*h+(c+=2)))*(u=c+r/u);return 1-d*e.exp(-i+n*e.log(i)-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,i){return n>170||i>170?e.exp(t.combinationln(n,i)):t.factorial(n)/t.factorial(i)/t.factorial(n-i)},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,i){if(!(n<=0||i<=0))return n+i>170?e.exp(t.betaln(n,i)):t.gammafn(n)*t.gammafn(i)/t.gammafn(n+i)},t.betaln=function(e,n){return t.gammaln(e)+t.gammaln(n)-t.gammaln(e+n)},t.betacf=function(t,n,i){var r,o,a,s,l=1e-30,c=1,u=n+i,h=n+1,d=n-1,f=1,p=1-u*t/h;for(e.abs(p)<l&&(p=l),s=p=1/p;c<=100&&(p=1+(o=c*(i-c)*t/((d+(r=2*c))*(n+r)))*p,e.abs(p)<l&&(p=l),f=1+o/f,e.abs(f)<l&&(f=l),s*=(p=1/p)*f,p=1+(o=-(n+c)*(u+c)*t/((n+r)*(h+r)))*p,e.abs(p)<l&&(p=l),f=1+o/f,e.abs(f)<l&&(f=l),s*=a=(p=1/p)*f,!(e.abs(a-1)<3e-7));c++);return s},t.gammapinv=function(n,i){var r,o,a,s,l,c,u=0,h=i-1,d=t.gammaln(i);if(n>=1)return e.max(100,i+100*e.sqrt(i));if(n<=0)return 0;for(i>1?(l=e.log(h),c=e.exp(h*(l-1)-d),s=n<.5?n:1-n,r=(2.30753+.27061*(o=e.sqrt(-2*e.log(s))))/(1+o*(.99229+.04481*o))-o,n<.5&&(r=-r),r=e.max(.001,i*e.pow(1-1/(9*i)-r/(3*e.sqrt(i)),3))):r=n<(o=1-i*(.253+.12*i))?e.pow(n/o,1/i):1-e.log(1-(n-o)/(1-o));u<12;u++){if(r<=0)return 0;if((r-=o=(a=(t.lowRegGamma(i,r)-n)/(o=i>1?c*e.exp(-(r-h)+h*(e.log(r)-l)):e.exp(-r+h*e.log(r)-d)))/(1-.5*e.min(1,a*((i-1)/r-1))))<=0&&(r=.5*(r+o)),e.abs(o)<1e-8*r)break}return r},t.erf=function(t){var n,i,r,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,u=0;for(t<0&&(t=-t,l=!0),i=4*(n=2/(2+t))-2;s>0;s--)r=c,c=i*c-u+a[s],u=r;return o=n*e.exp(-t*t+.5*(a[0]+i*c)-u),l?o-1:1-o},t.erfc=function(e){return 1-t.erf(e)},t.erfcinv=function(n){var i,r,o,a,s=0;if(n>=2)return-100;if(n<=0)return 100;for(a=n<1?n:2-n,i=-.70711*((2.30753+.27061*(o=e.sqrt(-2*e.log(a/2))))/(1+o*(.99229+.04481*o))-o);s<2;s++)i+=(r=t.erfc(i)-a)/(1.1283791670955126*e.exp(-i*i)-i*r);return n<1?i:-i},t.ibetainv=function(n,i,r){var o,a,s,l,c,u,h,d,f,p,g=i-1,m=r-1,y=0;if(n<=0)return 0;if(n>=1)return 1;for(i>=1&&r>=1?(s=n<.5?n:1-n,u=(2.30753+.27061*(l=e.sqrt(-2*e.log(s))))/(1+l*(.99229+.04481*l))-l,n<.5&&(u=-u),h=(u*u-3)/6,d=2/(1/(2*i-1)+1/(2*r-1)),f=u*e.sqrt(h+d)/d-(1/(2*r-1)-1/(2*i-1))*(h+5/6-2/(3*d)),u=i/(i+r*e.exp(2*f))):(o=e.log(i/(i+r)),a=e.log(r/(i+r)),u=n<(l=e.exp(i*o)/i)/(f=l+(c=e.exp(r*a)/r))?e.pow(i*f*n,1/i):1-e.pow(r*f*(1-n),1/r)),p=-t.gammaln(i)-t.gammaln(r)+t.gammaln(i+r);y<10;y++){if(0===u||1===u)return u;if((u-=l=(c=(t.ibeta(u,i,r)-n)/(l=e.exp(g*e.log(u)+m*e.log(1-u)+p)))/(1-.5*e.min(1,c*(g/u-m/(1-u)))))<=0&&(u=.5*(u+l)),u>=1&&(u=.5*(u+l+1)),e.abs(l)<1e-8*u&&y>0)break}return u},t.ibeta=function(n,i,r){var o=0===n||1===n?0:e.exp(t.gammaln(i+r)-t.gammaln(i)-t.gammaln(r)+i*e.log(n)+r*e.log(1-n));return!(n<0||n>1)&&(n<(i+1)/(i+r+2)?o*t.betacf(n,i,r)/i:1-o*t.betacf(1-n,r,i)/r)},t.randn=function(n,i){var r,o,a,s,l;if(i||(i=n),n)return t.create(n,i,function(){return t.randn()});do{r=t._random_fn(),o=1.7156*(t._random_fn()-.5),l=(a=r-.449871)*a+(s=e.abs(o)+.386595)*(.196*s-.25472*a)}while(l>.27597&&(l>.27846||o*o>-4*e.log(r)*r*r));return o/r},t.randg=function(n,i,r){var o,a,s,l,c,u,h=n;if(r||(r=i),n||(n=1),i)return(u=t.zeros(i,r)).alter(function(){return t.randg(n)}),u;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==h)return o*l;do{s=t._random_fn()}while(0===s);return e.pow(s,1/h)*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,i,r){for(var o,a=0,s=1,l=1,c=1,u=0,h=0;e.abs((l-h)/l)>r;)h=l,s=c+(o=-(n+u)*(n+i+u)*t/(n+2*u)/(n+2*u+1))*s,l=(a=l+o*a)+(o=(u+=1)*(i-u)*t/(n+2*u-1)/(n+2*u))*l,a/=c=s+o*c,s/=c,l/=c,c=1;return l/n}function i(n,i,r){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/r)?e.pow(c,r):0;for(var u=s,h=(8-s)/(l=n>3?2:3),d=u+h,f=0,p=r-1,g=1;g<=l;g++){for(var m=0,y=.5*(d+u),v=.5*(d-u),w=1;w<=12;w++){var b,C=y+v*(6<w?o[(b=12-w+1)-1]:-o[(b=w)-1]),_=C*C;if(_>60)break;var A=2*t.normal.cdf(C,0,1,1,0)*.5-2*t.normal.cdf(C,n,1,1,0)*.5;A>=e.exp(-30/p)&&(m+=A=a[b-1]*e.exp(-.5*_)*e.pow(A,p))}f+=m*=2*v*r/e.sqrt(2*e.PI),u=d,d+=h}return(c+=f)<=e.exp(-30/i)?0:(c=e.pow(c,i))>=1?1:c}!function(e){for(var n=0;n<e.length;n++)(function(e){t[e]=function t(e,n,i){return this instanceof t?(this._a=e,this._b=n,this._c=i,this):new t(e,n,i)},t.fn[e]=function(n,i,r){var o=t[e](n,i,r);return o.data=this,o},t[e].prototype.sample=function(n){var i=this._a,r=this._b,o=this._c;return n?t.alter(n,function(){return t[e].sample(i,r,o)}):t[e].sample(i,r,o)},function(n){for(var i=0;i<n.length;i++)(function(n){t[e].prototype[n]=function(i){var r=this._a,o=this._b,a=this._c;return i||0===i||(i=this.data),"number"!=typeof i?t.fn.map.call(i,function(i){return t[e][n](i,r,o,a)}):t[e][n](i,r,o,a)}})(n[i])}("pdf cdf inv".split(" ")),function(n){for(var i=0;i<n.length;i++)(function(n){t[e].prototype[n]=function(){return t[e][n](this._a,this._b,this._c)}})(n[i])}("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,i,r){return n>1||n<0?0:1==i&&1==r?1:i<512&&r<512?e.pow(n,i-1)*e.pow(1-n,r-1)/t.betafn(i,r):e.exp((i-1)*e.log(n)+(r-1)*e.log(1-n)-t.betaln(i,r))},cdf:function(e,n,i){return e>1||e<0?1*(e>1):t.ibeta(e,n,i)},inv:function(e,n,i){return t.ibetainv(e,n,i)},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 i=t.randg(e);return i/(i+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,i,r){var o;return n<0?0:i<=2?0===n&&i<2?1/0:0===n&&2===i?1:1/t.betafn(i/2,r/2)*e.pow(i/r,i/2)*e.pow(n,i/2-1)*e.pow(1+i/r*n,-(i+r)/2):(o=i*n/(r+n*i),i*(r/(r+n*i))/2*t.binomial.pdf((i-2)/2,(i+r-2)/2,o))},cdf:function(e,n,i){return e<0?0:t.ibeta(n*e/(n*e+i),n/2,i/2)},inv:function(e,n,i){return i/(n*(1/t.ibetainv(e,n/2,i/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,i){return i<0?0:i/(e.pow(t-n,2)+e.pow(i,2))/e.PI},cdf:function(t,n,i){return e.atan((t-n)/i)/e.PI+.5},inv:function(t,n,i){return n+i*e.tan(e.PI*(t-.5))},median:function(t){return t},mode:function(t){return t},sample:function(n,i){return t.randn()*e.sqrt(1/(2*t.randg(.5)))*i+n}}),t.extend(t.chisquare,{pdf:function(n,i){return n<0?0:0===n&&2===i?.5:e.exp((i/2-1)*e.log(n)-n/2-i/2*e.log(2)-t.gammaln(i/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,i,r){return n<0?0:0===n&&1===i?1/r:e.exp((i-1)*e.log(n)-n/r-t.gammaln(i)-i*e.log(r))},cdf:function(e,n,i){return e<0?0:t.lowRegGamma(n,e/i)},inv:function(e,n,i){return t.gammapinv(e,n)*i},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,i,r){return n<=0?0:e.exp(-(i+1)*e.log(n)-r/n-t.gammaln(i)+i*e.log(r))},cdf:function(e,n,i){return e<=0?0:1-t.lowRegGamma(n,i/e)},inv:function(e,n,i){return i/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,i){return 0===t&&1===n?i:1===t&&1===i?n:e.exp(e.log(n)+e.log(i)+(n-1)*e.log(t)+(i-1)*e.log(1-e.pow(t,n)))},cdf:function(t,n,i){return t<0?0:t>1?1:1-e.pow(1-e.pow(t,n),i)},inv:function(t,n,i){return e.pow(1-e.pow(1-t,1/i),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,i){return t<=0?0:e.exp(-e.log(t)-.5*e.log(2*e.PI)-e.log(i)-e.pow(e.log(t)-n,2)/(2*i*i))},cdf:function(n,i,r){return n<0?0:.5+.5*t.erf((e.log(n)-i)/e.sqrt(2*r*r))},inv:function(n,i,r){return e.exp(-1.4142135623730951*r*t.erfcinv(2*n)+i)},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,i){return e.exp(t.randn()*i+n)},variance:function(t,n){return(e.exp(n*n)-1)*e.exp(2*t+n*n)}}),t.extend(t.noncentralt,{pdf:function(n,i,r){return e.abs(r)<1e-14?t.studentt.pdf(n,i):e.abs(n)<1e-14?e.exp(t.gammaln((i+1)/2)-r*r/2-.5*e.log(e.PI*i)-t.gammaln(i/2)):i/n*(t.noncentralt.cdf(n*e.sqrt(1+2/i),i+2,r)-t.noncentralt.cdf(n,i,r))},cdf:function(n,i,r){var o=1e-14;if(e.abs(r)<o)return t.studentt.cdf(n,i);var a=!1;n<0&&(a=!0,r=-r);for(var s=t.normal.cdf(-r,0,1),l=o+1,c=l,u=n*n/(n*n+i),h=0,d=e.exp(-r*r/2),f=e.exp(-r*r/2-.5*e.log(2)-t.gammaln(1.5))*r;h<200||c>o||l>o;)c=l,h>0&&(d*=r*r/(2*h),f*=r*r/(2*(h+.5))),s+=.5*(l=d*t.beta.cdf(u,h+.5,i/2)+f*t.beta.cdf(u,h+1,i/2)),h++;return a?1-s:s}}),t.extend(t.normal,{pdf:function(t,n,i){return e.exp(-.5*e.log(2*e.PI)-e.log(i)-e.pow(t-n,2)/(2*i*i))},cdf:function(n,i,r){return.5*(1+t.erf((n-i)/e.sqrt(2*r*r)))},inv:function(e,n,i){return-1.4142135623730951*i*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,i){return t<n?0:i*e.pow(n,i)/e.pow(t,i+1)},cdf:function(t,n,i){return t<n?0:1-e.pow(n/t,i)},inv:function(t,n,i){return n/e.pow(1-t,1/i)},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,i){return i=i>1e100?1e100:i,1/(e.sqrt(i)*t.betafn(.5,i/2))*e.pow(1+n*n/i,-(i+1)/2)},cdf:function(n,i){var r=i/2;return t.ibeta((n+e.sqrt(n*n+i))/(2*e.sqrt(n*n+i)),r,r)},inv:function(n,i){var r=t.ibetainv(2*e.min(n,1-n),.5*i,.5);return r=e.sqrt(i*(1-r)/r),n>.5?r:-r},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,i){return t<0||n<0||i<0?0:i/n*e.pow(t/n,i-1)*e.exp(-e.pow(t/n,i))},cdf:function(t,n,i){return t<0?0:1-e.exp(-e.pow(t/n,i))},inv:function(t,n,i){return n*e.pow(-e.log(1-t),1/i)},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,i){return n*e.pow(-e.log(t._random_fn()),1/i)},variance:function(n,i){return n*n*t.gammafn(1+2/i)-e.pow(t.weibull.mean(n,i),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,i,r){return 0===r||1===r?i*r===n?1:0:t.combination(i,n)*e.pow(r,n)*e.pow(1-r,i-n)},cdf:function(i,r,o){var a,s=1e-10;if(i<0)return 0;if(i>=r)return 1;if(o<0||o>1||r<=0)return NaN;var l=o,c=(i=e.floor(i))+1,u=r-i,h=c+u,d=e.exp(t.gammaln(h)-t.gammaln(u)-t.gammaln(c)+c*e.log(l)+u*e.log(1-l));return a=l<(c+1)/(h+2)?d*n(l,c,u,s):1-d*n(1-l,u,c,s),e.round(1/s*(1-a))/(1/s)}}),t.extend(t.negbin,{pdf:function(n,i,r){return n===n>>>0&&(n<0?0:t.combination(n+i-1,i-1)*e.pow(1-r,n)*e.pow(r,i))},cdf:function(e,n,i){var r=0,o=0;if(e<0)return 0;for(;o<=e;o++)r+=t.negbin.pdf(o,n,i);return r}}),t.extend(t.hypgeom,{pdf:function(n,i,r,o){if(n!=n|0)return!1;if(n<0||n<r-(i-o))return 0;if(n>o||n>r)return 0;if(2*r>i)return 2*o>i?t.hypgeom.pdf(i-r-o+n,i,i-r,i-o):t.hypgeom.pdf(o-n,i,i-r,o);if(2*o>i)return t.hypgeom.pdf(r-n,i,r,i-o);if(r<o)return t.hypgeom.pdf(n,i,o,r);for(var a=1,s=0,l=0;l<n;l++){for(;a>1&&s<o;)a*=1-r/(i-s),s++;a*=(o-l)*(r-l)/((l+1)*(i-r-o+l+1))}for(;s<o;s++)a*=1-r/(i-s);return e.min(1,e.max(0,a))},cdf:function(n,i,r,o){if(n<0||n<r-(i-o))return 0;if(n>=o||n>=r)return 1;if(2*r>i)return 2*o>i?t.hypgeom.cdf(i-r-o+n,i,i-r,i-o):1-t.hypgeom.cdf(o-n-1,i,i-r,o);if(2*o>i)return 1-t.hypgeom.cdf(r-n-1,i,r,i-o);if(r<o)return t.hypgeom.cdf(n,i,o,r);for(var a=1,s=1,l=0,c=0;c<n;c++){for(;a>1&&l<o;){var u=1-r/(i-l);s*=u,a*=u,l++}a+=s*=(o-c)*(r-c)/((c+1)*(i-r-o+c+1))}for(;l<o;l++)a*=1-r/(i-l);return e.min(1,e.max(0,a))}}),t.extend(t.poisson,{pdf:function(n,i){return i<0||n%1!=0||n<0?0:e.pow(i,n)*e.exp(-i)/t.factorial(n)},cdf:function(e,n){var i=[],r=0;if(e<0)return 0;for(;r<=e;r++)i.push(t.poisson.pdf(r,n));return t.sum(i)},mean:function(t){return t},variance:function(t){return t},sampleSmall:function(n){var i=1,r=0,o=e.exp(-n);do{r++,i*=t._random_fn()}while(i>o);return r-1},sampleLarge:function(n){var i,r,o,a,s,l,c,u,h,d,f=n;for(a=e.sqrt(f),s=e.log(f),l=.02483*(c=.931+2.53*a)-.059,u=1.1239+1.1328/(c-3.4),h=.9277-3.6224/(c-2);;){if(r=e.random()-.5,o=e.random(),d=.5-e.abs(r),i=e.floor((2*l/d+c)*r+f+.43),d>=.07&&o<=h)return i;if(!(i<0||d<.013&&o>d)&&e.log(o)+e.log(u)-e.log(l/(d*d)+c)<=i*s-f-t.loggam(i+1))return i}},sample:function(t){return t<10?this.sampleSmall(t):this.sampleLarge(t)}}),t.extend(t.triangular,{pdf:function(t,e,n,i){return n<=e||i<e||i>n?NaN:t<e||t>n?0:t<i?2*(t-e)/((n-e)*(i-e)):t===i?2/(n-e):2*(n-t)/((n-e)*(n-i))},cdf:function(t,n,i,r){return i<=n||r<n||r>i?NaN:t<=n?0:t>=i?1:t<=r?e.pow(t-n,2)/((i-n)*(r-n)):1-e.pow(i-t,2)/((i-n)*(i-r))},inv:function(t,n,i,r){return i<=n||r<n||r>i?NaN:t<=(r-n)/(i-n)?n+(i-n)*e.sqrt(t*((r-n)/(i-n))):n+(i-n)*(1-e.sqrt((1-t)*(1-(r-n)/(i-n))))},mean:function(t,e,n){return(t+e+n)/3},median:function(t,n,i){return i<=(t+n)/2?n-e.sqrt((n-t)*(n-i))/e.sqrt(2):i>(t+n)/2?t+e.sqrt((n-t)*(i-t))/e.sqrt(2):void 0},mode:function(t,e,n){return n},sample:function(n,i,r){var o=t._random_fn();return o<(r-n)/(i-n)?n+e.sqrt(o*(i-n)*(r-n)):i-e.sqrt((1-o)*(i-n)*(i-r))},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,i){return i<=n?NaN:t<=n||t>=i?0:2/e.PI*e.pow(e.pow(i-n,2)-e.pow(2*t-n-i,2),-.5)},cdf:function(t,n,i){return t<n?0:t<i?2/e.PI*e.asin(e.sqrt((t-n)/(i-n))):1},inv:function(t,n,i){return n+(.5-.5*e.cos(e.PI*t))*(i-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,i){return(n+i)/2+(i-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,i){return i<=0?0:e.exp(-e.abs(t-n)/i)/(2*i)},cdf:function(t,n,i){return i<=0?0:t<n?.5*e.exp((t-n)/i):1-.5*e.exp(-(t-n)/i)},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,i){var r,o=t._random_fn()-.5;return n-i*((r=o)/e.abs(r))*e.log(1-2*e.abs(o))}}),t.extend(t.tukey,{cdf:function(n,r,o){var a=r,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 i(n,1,a);var c,u=.5*o,h=u*e.log(o)-o*e.log(2)-t.gammaln(u),d=u-1,f=.25*o;c=o<=100?1:o<=800?.5:o<=5e3?.25:.125,h+=e.log(c);for(var p=0,g=1;g<=50;g++){for(var m=0,y=(2*g-1)*c,v=1;v<=16;v++){var w,b;8<v?(w=v-8-1,b=h+d*e.log(y+s[w]*c)-(s[w]*c+y)*f):(w=v-1,b=h+d*e.log(y-s[w]*c)+(s[w]*c-y)*f),b>=-30&&(m+=i(8<v?n*e.sqrt(.5*(s[w]*c+y)):n*e.sqrt(.5*(-s[w]*c+y)),1,a)*l[w]*e.exp(b))}if(g*c>=1&&m<=1e-14)break;p+=m}if(m>1e-14)throw new Error("tukey.cdf failed to converge");return p>1&&(p=1),p},inv:function(n,i,r){if(r<2||i<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,i){var r=.5-.5*t,o=e.sqrt(e.log(1/(r*r))),a=o+((((-453642210148e-16*o-.204231210125)*o-.342242088547)*o-1)*o+.322232421088)/((((.0038560700634*o+.10353775285)*o+.531103462366)*o+.588581570495)*o+.099348462606);i<120&&(a+=(a*a*a+a)/i/4);var s=.8832-.2368*a;return i<120&&(s+=-1.214/i+1.208*a/i),a*(s*e.log(n-1)+1.4142)}(n,i,r),s=t.tukey.cdf(a,i,r)-n;o=s>0?e.max(0,a-1):a+1;for(var l,c=t.tukey.cdf(o,i,r)-n,u=1;u<50;u++)if(l=o-c*(o-a)/(c-s),s=c,a=o,l<0&&(l=0,c=-n),c=t.tukey.cdf(l,i,r)-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,i,r=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,i){return t+n[e][i]})):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,i){return t-n[e][i]||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 i,r,o,s,l,c,u,h;if(void 0===e.length&&void 0===n.length)return e*n;if(l=e.length,c=e[0].length,u=t.zeros(l,o=a(n)?n[0].length:c),h=0,a(n)){for(;h<o;h++)for(i=0;i<l;i++){for(s=0,r=0;r<c;r++)s+=e[i][r]*n[r][h];u[i][h]=s}return 1===l&&1===h?u[0][0]:u}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 i,r,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,u=o.length,h=o[0].length;c<u;c++){for(l[c]=[],i=0,r=0;r<h;r++)i+=o[c][r]*s[c][r];l[c]=i}return 1===l.length?l[0]:l},pow:function(n,i){return t.map(n,function(t){return e.pow(t,i)})},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 i=0,r=0;for(isNaN(n)&&(n=2),a(t[0])&&(t=t[0]);r<t.length;r++)i+=e.pow(e.abs(t[r]),n);return e.pow(i,1/n)},angle:function(n,i){return e.acos(t.dot(n,i)/(t.norm(n)*t.norm(i)))},aug:function(t,e){var n,i=[];for(n=0;n<t.length;n++)i.push(t[n].slice());for(n=0;n<i.length;n++)r.apply(i[n],e[n]);return i},inv:function(e){for(var n,i=e.length,r=e[0].length,o=t.identity(i,r),a=t.gauss_jordan(e,o),s=[],l=0;l<i;l++)for(s[l]=[],n=r;n<a[0].length;n++)s[l][n-r]=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,i=0;i<e.length;i++){for(var r=[],o=1;o<e.length;o++){r[o-1]=[];for(var a=0;a<e.length;a++)a<i?r[o-1][a]=e[o][a]:a>i&&(r[o-1][a-1]=e[o][a])}var s=i%2?-1:1;n+=t(r)*e[0][i]*s}return n},gauss_elimination:function(n,i){var r,o,a,s,l=0,c=0,u=n.length,h=n[0].length,d=1,f=0,p=[];for(r=(n=t.aug(n,i))[0].length,l=0;l<u;l++){for(o=n[l][l],c=l,s=l+1;s<h;s++)o<e.abs(n[s][l])&&(o=n[s][l],c=s);if(c!=l)for(s=0;s<r;s++)a=n[l][s],n[l][s]=n[c][s],n[c][s]=a;for(c=l+1;c<u;c++)for(d=n[c][l]/n[l][l],s=l;s<r;s++)n[c][s]=n[c][s]-d*n[l][s]}for(l=u-1;l>=0;l--){for(f=0,c=l+1;c<=u-1;c++)f+=p[c]*n[l][c];p[l]=(n[l][r-1]-f)/n[l][l]}return p},gauss_jordan:function(n,i){var r,o,a,s=t.aug(n,i),l=s.length,c=s[0].length,u=0;for(o=0;o<l;o++){var h=o;for(a=o+1;a<l;a++)e.abs(s[a][o])>e.abs(s[h][o])&&(h=a);var d=s[o];for(s[o]=s[h],s[h]=d,a=o+1;a<l;a++)for(u=s[a][o]/s[o][o],r=o;r<c;r++)s[a][r]-=s[o][r]*u}for(o=l-1;o>=0;o--){for(u=s[o][o],a=0;a<o;a++)for(r=c-1;r>o-1;r--)s[a][r]-=s[o][r]*s[a][o]/u;for(s[o][o]/=u,r=l;r<c;r++)s[o][r]/=u}return s},triaUpSolve:function(e,n){var i,r=e[0].length,o=t.zeros(1,r)[0],a=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),a=!0),t.arange(r-1,-1,-1).forEach(function(a){i=t.arange(a+1,r).map(function(t){return o[t]*e[a][t]}),o[a]=(n[a]-t.sum(i))/e[a][a]}),a?o.map(function(t){return[t]}):o},triaLowSolve:function(e,n){var i,r=e[0].length,o=t.zeros(1,r)[0],a=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),a=!0),t.arange(r).forEach(function(r){i=t.arange(r).map(function(t){return e[r][t]*o[t]}),o[r]=(n[r]-t.sum(i))/e[r][r]}),a?o.map(function(t){return[t]}):o},lu:function(e){var n,i=e.length,r=t.identity(i),o=t.zeros(e.length,e[0].length);return t.arange(i).forEach(function(t){o[0][t]=e[0][t]}),t.arange(1,i).forEach(function(a){t.arange(a).forEach(function(i){n=t.arange(i).map(function(t){return r[a][t]*o[t][i]}),r[a][i]=(e[a][i]-t.sum(n))/o[i][i]}),t.arange(a,i).forEach(function(i){n=t.arange(a).map(function(t){return r[a][t]*o[t][i]}),o[a][i]=e[n.length][i]-t.sum(n)})}),[r,o]},cholesky:function(n){var i,r=n.length,o=t.zeros(n.length,n[0].length);return t.arange(r).forEach(function(a){i=t.arange(a).map(function(t){return e.pow(o[a][t],2)}),o[a][a]=e.sqrt(n[a][a]-t.sum(i)),t.arange(a+1,r).forEach(function(e){i=t.arange(a).map(function(t){return o[a][t]*o[e][t]}),o[e][a]=(n[a][e]-t.sum(i))/o[a][a]})}),o},gauss_jacobi:function(n,i,r,o){for(var a,s,l,c,u=0,h=0,d=n.length,f=[],p=[],g=[];u<d;u++)for(f[u]=[],p[u]=[],g[u]=[],h=0;h<d;h++)u>h?(f[u][h]=n[u][h],p[u][h]=g[u][h]=0):u<h?(p[u][h]=n[u][h],f[u][h]=g[u][h]=0):(g[u][h]=n[u][h],f[u][h]=p[u][h]=0);for(l=t.multiply(t.multiply(t.inv(g),t.add(f,p)),-1),s=t.multiply(t.inv(g),i),a=r,c=t.add(t.multiply(l,r),s),u=2;e.abs(t.norm(t.subtract(c,a)))>o;)a=c,c=t.add(t.multiply(l,a),s),u++;return c},gauss_seidel:function(n,i,r,o){for(var a,s,l,c,u,h=0,d=n.length,f=[],p=[],g=[];h<d;h++)for(f[h]=[],p[h]=[],g[h]=[],a=0;a<d;a++)h>a?(f[h][a]=n[h][a],p[h][a]=g[h][a]=0):h<a?(p[h][a]=n[h][a],f[h][a]=g[h][a]=0):(g[h][a]=n[h][a],f[h][a]=p[h][a]=0);for(c=t.multiply(t.multiply(t.inv(t.add(g,f)),p),-1),l=t.multiply(t.inv(t.add(g,f)),i),s=r,u=t.add(t.multiply(c,r),l),h=2;e.abs(t.norm(t.subtract(u,s)))>o;)s=u,u=t.add(t.multiply(c,s),l),h+=1;return u},SOR:function(n,i,r,o,a){for(var s,l,c,u,h,d=0,f=n.length,p=[],g=[],m=[];d<f;d++)for(p[d]=[],g[d]=[],m[d]=[],s=0;s<f;s++)d>s?(p[d][s]=n[d][s],g[d][s]=m[d][s]=0):d<s?(g[d][s]=n[d][s],p[d][s]=m[d][s]=0):(m[d][s]=n[d][s],p[d][s]=g[d][s]=0);for(u=t.multiply(t.inv(t.add(m,t.multiply(p,a))),t.subtract(t.multiply(m,1-a),t.multiply(g,a))),c=t.multiply(t.multiply(t.inv(t.add(m,t.multiply(p,a))),i),a),l=r,h=t.add(t.multiply(u,r),c),d=2;e.abs(t.norm(t.subtract(h,l)))>o;)l=h,h=t.add(t.multiply(u,l),c),d++;return h},householder:function(n){for(var i,r,o,a,s=n.length,l=n[0].length,c=0,u=[],h=[];c<s-1;c++){for(i=0,a=c+1;a<l;a++)i+=n[a][c]*n[a][c];for(i=(n[c+1][c]>0?-1:1)*e.sqrt(i),r=e.sqrt((i*i-n[c+1][c]*i)/2),(u=t.zeros(s,1))[c+1][0]=(n[c+1][c]-i)/(2*r),o=c+2;o<s;o++)u[o][0]=n[o][c]/(2*r);h=t.subtract(t.identity(s,l),t.multiply(t.multiply(u,t.transpose(u)),2)),n=t.multiply(h,t.multiply(n,h))}return n},QR:(n=t.sum,i=t.arange,function(r){var o,a,s,l=r.length,c=r[0].length,u=t.zeros(c,c);for(r=t.copy(r),a=0;a<c;a++){for(u[a][a]=e.sqrt(n(i(l).map(function(t){return r[t][a]*r[t][a]}))),o=0;o<l;o++)r[o][a]=r[o][a]/u[a][a];for(s=a+1;s<c;s++)for(u[a][s]=n(i(l).map(function(t){return r[t][a]*r[t][s]})),o=0;o<l;o++)r[o][s]=r[o][s]-r[o][a]*u[a][s]}return[r,u]}),lstsq:function(e,n){var i=!1;void 0===n[0].length&&(n=n.map(function(t){return[t]}),i=!0);var r=t.QR(e),o=r[0],a=r[1],s=e[0].length,l=t.slice(o,{col:{end:s}}),c=function(e){var n=(e=t.copy(e)).length,i=t.identity(n);return t.arange(n-1,-1,-1).forEach(function(n){t.sliceAssign(i,{row:n},t.divide(t.slice(i,{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(r){var o=t.multiply(e[r][n],-1),a=t.slice(e,{row:r}),s=t.multiply(t.slice(e,{row:n}),o);t.sliceAssign(e,{row:r},t.add(a,s));var l=t.slice(i,{row:r}),c=t.multiply(t.slice(i,{row:n}),o);t.sliceAssign(i,{row:r},t.add(l,c))})}),i}(t.slice(a,{row:{end:s}})),u=t.transpose(l);void 0===u[0].length&&(u=[u]);var h=t.multiply(t.multiply(c,u),n);return void 0===h.length&&(h=[[h]]),i?h.map(function(t){return t[0]}):h},jacobi:function(n){for(var i,r,o,a,s,l,c,u=1,h=n.length,d=t.identity(h,h),f=[];1===u;){for(s=n[0][1],o=0,a=1,i=0;i<h;i++)for(r=0;r<h;r++)i!=r&&s<e.abs(n[i][r])&&(s=e.abs(n[i][r]),o=i,a=r);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(h,h))[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),u=0,i=1;i<h;i++)for(r=1;r<h;r++)i!=r&&e.abs(n[i][r])>.001&&(u=1)}for(i=0;i<h;i++)f.push(n[i][i]);return[d,f]},rungekutta:function(t,e,n,i,r,o){var a,s,l;if(2===o)for(;i<=n;)r+=((a=e*t(i,r))+(s=e*t(i+e,r+a)))/2,i+=e;if(4===o)for(;i<=n;)r+=((a=e*t(i,r))+2*(s=e*t(i+e/2,r+a/2))+2*(l=e*t(i+e/2,r+s/2))+e*t(i+e,r+l))/6,i+=e;return r},romberg:function(t,n,i,r){for(var o,a,s,l,c,u=0,h=(i-n)/2,d=[],f=[],p=[];u<r/2;){for(c=t(n),s=n,l=0;s<=i;s+=h,l++)d[l]=s;for(o=d.length,s=1;s<o-1;s++)c+=(s%2!=0?4:2)*t(d[s]);c=h/3*(c+t(i)),p[u]=c,h/=2,u++}for(a=p.length,o=1;1!==a;){for(s=0;s<a-1;s++)f[s]=(e.pow(4,o)*p[s+1]-p[s])/(e.pow(4,o)-1);a=f.length,p=f,f=[],o++}return p},richardson:function(t,n,i,r){function o(t,e){for(var n,i=0,r=t.length;i<r;i++)t[i]===e&&(n=i);return n}for(var a,s,l,c,u,h=e.abs(i-t[o(t,i)+1]),d=0,f=[],p=[];r>=h;)a=o(t,i+r),s=o(t,i),f[d]=(n[a]-2*n[s]+n[2*s-a])/(r*r),r/=2,d++;for(c=f.length,l=1;1!=c;){for(u=0;u<c-1;u++)p[u]=(e.pow(4,l)*f[u+1]-f[u])/(e.pow(4,l)-1);c=p.length,f=p,p=[],l++}return f},simpson:function(t,e,n,i){for(var r,o=(n-e)/i,a=t(e),s=[],l=e,c=0,u=1;l<=n;l+=o,c++)s[c]=l;for(r=s.length;u<r-1;u++)a+=(u%2!=0?4:2)*t(s[u]);return o/3*(a+t(n))},hermite:function(t,e,n,i){for(var r,o=t.length,a=0,s=0,l=[],c=[],u=[],h=[];s<o;s++){for(l[s]=1,r=0;r<o;r++)s!=r&&(l[s]*=(i-t[r])/(t[s]-t[r]));for(c[s]=0,r=0;r<o;r++)s!=r&&(c[s]+=1/(t[s]-t[r]));u[s]=(1-2*(i-t[s])*c[s])*(l[s]*l[s]),h[s]=(i-t[s])*(l[s]*l[s]),a+=u[s]*e[s]+h[s]*n[s]}return a},lagrange:function(t,e,n){for(var i,r,o=0,a=0,s=t.length;a<s;a++){for(r=e[a],i=0;i<s;i++)a!=i&&(r*=(n-t[i])/(t[a]-t[i]));o+=r}return o},cubic_spline:function(e,n,i){for(var r,o,a=e.length,s=0,l=[],c=[],u=[],h=[],d=[],f=[];s<a-1;s++)h[s]=e[s+1]-e[s];for(u[0]=0,s=1;s<a-1;s++)u[s]=3/h[s]*(n[s+1]-n[s])-3/h[s-1]*(n[s]-n[s-1]);for(s=1;s<a-1;s++)l[s]=[],c[s]=[],l[s][s-1]=h[s-1],l[s][s]=2*(h[s-1]+h[s]),l[s][s+1]=h[s],c[s][0]=u[s];for(o=t.multiply(t.inv(l),c),r=0;r<a-1;r++)d[r]=(n[r+1]-n[r])/h[r]-h[r]*(o[r+1][0]+2*o[r][0])/3,f[r]=(o[r+1][0]-o[r][0])/(3*h[r]);for(r=0;r<a&&!(e[r]>i);r++);return n[r-=1]+(i-e[r])*d[r]+t.sq(i-e[r])*o[r]+(i-e[r])*t.sq(i-e[r])*f[r]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(e){var n,i,r,o,a,s=e.length,l=e[0].length,c=0,u=[],h=[],d=[],f=[],p=[],g=[],m=[];for(c=0;c<s;c++)u[c]=t.sum(e[c])/l;for(c=0;c<l;c++)for(p[c]=[],n=0;n<s;n++)p[c][n]=e[n][c]-u[n];for(p=t.transpose(p),c=0;c<s;c++)for(g[c]=[],n=0;n<s;n++)g[c][n]=t.dot([p[c]],[p[n]])/(l-1);for(a=(r=t.jacobi(g))[0],h=r[1],m=t.transpose(a),c=0;c<h.length;c++)for(n=c;n<h.length;n++)h[c]<h[n]&&(i=h[c],h[c]=h[n],h[n]=i,d=m[c],m[c]=m[n],m[n]=d);for(o=t.transpose(p),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,h,m,f]}}),function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(n,i){var r=this;return i?(setTimeout(function(){i.call(r,t.fn[e].call(r,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,i=t.utils.isNumber,r=t.utils.isArray;function o(t,n,i,r){if(t>1||i>1||t<=0||i<=0)throw new Error("Proportions should be greater than 0 and less than 1");var o=(t*n+i*r)/(n+r);return(t-i)/e.sqrt(o*(1-o)*(1/n+1/r))}t.extend({zscore:function(){var e=n.call(arguments);return i(e[1])?(e[0]-e[1])/e[2]:(e[0]-t.mean(e[1]))/t.stdev(e[1],e[2])},ztest:function(){var i,o=n.call(arguments);return r(o[1])?(i=t.zscore(o[0],o[1],o[3]),1===o[2]?t.normal.cdf(-e.abs(i),0,1):2*t.normal.cdf(-e.abs(i),0,1)):o.length>2?(i=t.zscore(o[0],o[1],o[2]),1===o[3]?t.normal.cdf(-e.abs(i),0,1):2*t.normal.cdf(-e.abs(i),0,1)):(i=o[0],1===o[1]?t.normal.cdf(-e.abs(i),0,1):2*t.normal.cdf(-e.abs(i),0,1))}}),t.extend(t.fn,{zscore:function(t,e){return(t-this.mean())/this.stdev(e)},ztest:function(n,i,r){var o=e.abs(this.zscore(n,r));return 1===i?t.normal.cdf(-o,0,1):2*t.normal.cdf(-o,0,1)}}),t.extend({tscore:function(){var i=n.call(arguments);return 4===i.length?(i[0]-i[1])/(i[2]/e.sqrt(i[3])):(i[0]-t.mean(i[1]))/(t.stdev(i[1],!0)/e.sqrt(i[1].length))},ttest:function(){var r,o=n.call(arguments);return 5===o.length?(r=e.abs(t.tscore(o[0],o[1],o[2],o[3])),1===o[4]?t.studentt.cdf(-r,o[3]-1):2*t.studentt.cdf(-r,o[3]-1)):i(o[1])?(r=e.abs(o[0]),1==o[2]?t.studentt.cdf(-r,o[1]-1):2*t.studentt.cdf(-r,o[1]-1)):(r=e.abs(t.tscore(o[0],o[1])),1==o[2]?t.studentt.cdf(-r,o[1].length-1):2*t.studentt.cdf(-r,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,i){return 1===i?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 i,r,o,a,s,l,c,u,h=n.call(arguments);if(1===h.length){for(s=new Array(h[0].length),c=0;c<h[0].length;c++)s[c]=h[0][c];h=s}for(r=new Array,c=0;c<h.length;c++)r=r.concat(h[c]);for(o=t.mean(r),i=0,c=0;c<h.length;c++)i+=h[c].length*e.pow(t.mean(h[c])-o,2);for(i/=h.length-1,l=0,c=0;c<h.length;c++)for(a=t.mean(h[c]),u=0;u<h[c].length;u++)l+=e.pow(h[c][u]-a,2);return i/(l/(r.length-h.length))},anovaftest:function(){var e,r,o,a,s=n.call(arguments);if(i(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 r=o-e-1,1-t.centralF.cdf(l,e,r)},ftest:function(e,n,i){return 1-t.centralF.cdf(e,n,i)}}),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 r,o,a,s,l,c=n.call(arguments);return i(c[0])?(r=c[0],o=c[1],a=c[2],s=c[3],l=c[4]):(r=t.mean(c[0]),o=t.mean(c[1]),a=c[0].length,s=c[1].length,l=c[2]),e.abs(r-o)/(l*e.sqrt((1/a+1/s)/2))},qtest:function(){var e,i=n.call(arguments);3===i.length?(e=i[0],i=i.slice(1)):7===i.length?(e=t.qscore(i[0],i[1],i[2],i[3],i[4]),i=i.slice(5)):(e=t.qscore(i[0],i[1],i[2]),i=i.slice(3));var r=i[0],o=i[1];return 1-t.tukey.cdf(e,o,r-o)},tukeyhsd:function(e){for(var n=t.pooledstdev(e),i=e.map(function(e){return t.mean(e)}),r=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(i[a],i[s],e[a].length,e[s].length,n,r,e.length);o.push([[a,s],l])}return o}}),t.extend({normalci:function(){var i,r=n.call(arguments),o=new Array(2);return i=4===r.length?e.abs(t.normal.inv(r[1]/2,0,1)*r[2]/e.sqrt(r[3])):e.abs(t.normal.inv(r[1]/2,0,1)*t.stdev(r[2])/e.sqrt(r[2].length)),o[0]=r[0]-i,o[1]=r[0]+i,o},tci:function(){var i,r=n.call(arguments),o=new Array(2);return i=4===r.length?e.abs(t.studentt.inv(r[1]/2,r[3]-1)*r[2]/e.sqrt(r[3])):e.abs(t.studentt.inv(r[1]/2,r[2].length-1)*t.stdev(r[2],!0)/e.sqrt(r[2].length)),o[0]=r[0]-i,o[1]=r[0]+i,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,i,r){var a=o(e,n,i,r);return t.ztest(a,1)},twoSidedDifferenceOfProportions:function(e,n,i,r){var a=o(e,n,i,r);return t.ztest(a,2)}})}(e,Math),e.models=function(){function t(t,n){var i=t.length,r=n[0].length-1,o=i-r-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),u=e.sum(s.map(function(t){return Math.pow(t-c,2)})),h=e.sum(t.map(function(t,e){return Math.pow(t-s[e],2)})),d=u+h;return{exog:n,endog:t,nobs:i,df_model:r,df_resid:o,coef:a,predict:s,resid:l,ybar:c,SST:d,SSE:u,SSR:h,R2:u/d}}function n(n){var i,r,o=(i=n.exog,r=i[0].length,e.arange(r).map(function(n){var o=e.arange(r).filter(function(t){return t!==n});return t(e.col(i,n).map(function(t){return t[0]}),e.col(i,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 i=e.studentt.cdf(t,n.df_resid);return 2*(i>.5?1-i:i)}),u=e.studentt.inv(.975,n.df_resid),h=n.coef.map(function(t,e){var n=u*s[e];return[t-n,t+n]});return{se:s,t:l,p:c,sigmaHat:a,interval95:h}}return{ols:function(i,r){var o=t(i,r),a=n(o),s=function(t){var n,i,r,o=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:o,pvalue:1-(n=o,i=t.df_model,r=t.df_resid,e.beta.cdf(n/(r/i+n),i/2,r/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),i=0;i<t.length;i++)n[i]=t[i];return e.builddxmatrix(n)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(t){return t.transpose()},matrixmult:function(t,n){var i,r,o,a,s;if(t.cols()==n.rows()){if(n.rows()>1){for(a=[],i=0;i<t.rows();i++)for(a[i]=[],r=0;r<n.cols();r++){for(s=0,o=0;o<t.cols();o++)s+=t.toArray()[i][o]*n.toArray()[o][r];a[i][r]=s}return e(a)}for(a=[],i=0;i<t.rows();i++)for(a[i]=[],r=0;r<n.cols();r++){for(s=0,o=0;o<t.cols();o++)s+=t.toArray()[i][o]*n.toArray()[r];a[i][r]=s}return e(a)}},regress:function(t,n){var i=e.xtranspxinv(t),r=t.transpose(),o=e.matrixmult(e(i),r);return e.matrixmult(o,n)},regresst:function(t,n,i){var r=e.regress(t,n),o={anova:{}},a=e.jMatYBar(t,r);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,u,h=e.xtranspxinv(t),d=0;d<r.length;d++)l=Math.sqrt(o.anova.mse*Math.abs(h[d][d])),c=Math.abs(r[d]/l),u=e.ttest(c,n.length-t[0].length-1,i),o.stats[d]=[r[d],l,c,u];return o.regress=r,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 i=e.matrixmult(t,n);return new e(i)},residuals:function(t,n){return e.matrixsubtract(t,n)},ssr:function(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e,2);return n},sse:function(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return n},sst:function(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e,2);return n},matrixsubtract:function(t,n){for(var i=new Array(t.length),r=0;r<t.length;r++){i[r]=new Array(t[r].length);for(var o=0;o<t[r].length;o++)i[r][o]=t[r][o]-n[r][o]}return e(i)}}),e.jStat=e,e)},6619:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Tag=e.Label=void 0;const i=n(4892),r=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",u="right",h="down",d="left",f=l.length;class p 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 i=function(){n._sync()};for(e=0;e<f;e++)t.on(l[e]+"Change.konva",i)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,n,i,r,o,a,s=this.getText(),l=this.getTag();if(s&&l){switch(t=s.width(),e=s.height(),n=l.pointerDirection(),i=l.pointerWidth(),a=l.pointerHeight(),r=0,o=0,n){case c:r=t/2,o=-1*a;break;case u:r=t+i,o=e/2;break;case h:r=t/2,o=e+a;break;case d:r=-1*i,o=e/2}l.setAttrs({x:-1*r,y:-1*o,width:t,height:e}),s.setAttrs({x:-1*r,y:-1*o})}}}e.Label=p,p.prototype.className="Label",(0,s._registerNode)(p);class g extends r.Shape{_sceneFunc(t){const e=this.width(),n=this.height(),i=this.pointerDirection(),r=this.pointerWidth(),o=this.pointerHeight(),a=this.cornerRadius();let s=0,l=0,f=0,p=0;"number"==typeof a?s=l=f=p=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),p=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),i===c&&(t.lineTo((e-r)/2,0),t.lineTo(e/2,-1*o),t.lineTo((e+r)/2,0)),t.lineTo(e-l,0),t.arc(e-l,l,l,3*Math.PI/2,0,!1),i===u&&(t.lineTo(e,(n-o)/2),t.lineTo(e+r,n/2),t.lineTo(e,(n+o)/2)),t.lineTo(e,n-p),t.arc(e-p,n-p,p,0,Math.PI/2,!1),i===h&&(t.lineTo((e+r)/2,n),t.lineTo(e/2,n+o),t.lineTo((e-r)/2,n)),t.lineTo(f,n),t.arc(f,n-f,f,Math.PI/2,Math.PI,!1),i===d&&(t.lineTo(0,(n+o)/2),t.lineTo(-1*r,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(),i=this.pointerHeight(),r=this.pointerDirection(),o=this.width(),a=this.height();return r===c?(e-=i,a+=i):r===h?a+=i:r===d?(t-=1.5*n,o+=n):r===u&&(o+=1.5*n),{x:t,y:e,width:o,height:a}}}e.Tag=g,g.prototype.className="Tag",(0,s._registerNode)(g),i.Factory.addGetterSetter(g,"pointerDirection","none"),i.Factory.addGetterSetter(g,"pointerWidth",0,(0,a.getNumberValidator)()),i.Factory.addGetterSetter(g,"pointerHeight",0,(0,a.getNumberValidator)()),i.Factory.addGetterSetter(g,"cornerRadius",0,(0,a.getNumberOrArrayOfNumbersValidator)(4))},6627:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Brighten=void 0;const i=n(4892),r=n(6536),o=n(5483);e.Brighten=function(t){const e=255*this.brightness(),n=t.data,i=n.length;for(let t=0;t<i;t+=4)n[t]+=e,n[t+1]+=e,n[t+2]+=e},i.Factory.addGetterSetter(r.Node,"brightness",0,(0,o.getNumberValidator)(),i.Factory.afterSetFilter)},6921:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RGB=void 0;const i=n(4892),r=n(6536),o=n(5483);e.RGB=function(t){const e=t.data,n=e.length,i=this.red(),r=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*i,e[t+1]=n*r,e[t+2]=n*o,e[t+3]=e[t+3]}},i.Factory.addGetterSetter(r.Node,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),i.Factory.addGetterSetter(r.Node,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),i.Factory.addGetterSetter(r.Node,"blue",0,o.RGBComponent,i.Factory.afterSetFilter)},6955:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Ellipse=void 0;const i=n(4892),r=n(4723),o=n(5483),a=n(8871);class s extends r.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),i.Factory.addComponentsGetterSetter(s,"radius",["x","y"]),i.Factory.addGetterSetter(s,"radiusX",0,(0,o.getNumberValidator)()),i.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 i=n(4892),r=n(6536),o=n(5483);e.Posterize=function(t){const e=Math.round(254*this.levels())+1,n=t.data,i=n.length,r=255/e;for(let t=0;t<i;t+=1)n[t]=Math.floor(n[t]/r)*r},i.Factory.addGetterSetter(r.Node,"levels",.5,(0,o.getNumberValidator)(),i.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 i=n(4060),r=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(),r=this.cornerRadius(),o=this.attrs.image;let a;if(o){const t=this.attrs.cropWidth,i=this.attrs.cropHeight;a=t&&i?[o,this.cropX(),this.cropY(),t,i,0,0,e,n]:[o,0,0,e,n]}(this.hasFill()||this.hasStroke()||r)&&(t.beginPath(),r?i.Util.drawRoundedRectPath(t,e,n,r):t.rect(0,0,e,n),t.closePath(),t.fillStrokeShape(this)),o&&(r&&t.clip(),t.drawImage.apply(t,a))}_hitFunc(t){const e=this.width(),n=this.height(),r=this.cornerRadius();t.beginPath(),r?i.Util.drawRoundedRectPath(t,e,n,r):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 r=i.Util.createImageElement();r.onload=function(){const t=new l({image:r});e(t)},r.onerror=n,r.crossOrigin="Anonymous",r.src=t}}e.Image=l,l.prototype.className="Image",(0,a._registerNode)(l),r.Factory.addGetterSetter(l,"cornerRadius",0,(0,s.getNumberOrArrayOfNumbersValidator)(4)),r.Factory.addGetterSetter(l,"image"),r.Factory.addComponentsGetterSetter(l,"crop",["x","y","width","height"]),r.Factory.addGetterSetter(l,"cropX",0,(0,s.getNumberValidator)()),r.Factory.addGetterSetter(l,"cropY",0,(0,s.getNumberValidator)()),r.Factory.addGetterSetter(l,"cropWidth",0,(0,s.getNumberValidator)()),r.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 i=n(4060),r=n(4892),o=n(4473),a=n(8871),s=n(8604),l=n(1268),c=n(8871),u=n(8722),h="mouseleave",d="mouseover",f="mouseenter",p="mousemove",g="mousedown",m="mouseup",y="pointermove",v="pointerdown",w="pointerup",b="pointercancel",C="pointerout",_="pointerleave",A="pointerover",S="pointerenter",E="contextmenu",x="touchstart",M="touchend",P="touchmove",N="touchcancel",T="wheel",F=[[f,"_pointerenter"],[g,"_pointerdown"],[p,"_pointermove"],[m,"_pointerup"],[h,"_pointerleave"],[x,"_pointerdown"],[P,"_pointermove"],[M,"_pointerup"],[N,"_pointercancel"],[d,"_pointerover"],[T,"_wheel"],[E,"_contextmenu"],[v,"_pointerdown"],[y,"_pointermove"],[w,"_pointerup"],[b,"_pointercancel"],[_,"_pointerleave"],["lostpointercapture","_lostpointercapture"]],I={mouse:{[C]:"mouseout",[_]:h,[A]:d,[S]:f,[y]:p,[v]:g,[w]:m,[b]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[C]:"touchout",[_]:"touchleave",[A]:"touchover",[S]:"touchenter",[y]:P,[v]:x,[w]:M,[b]:N,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[C]:C,[_]:_,[A]:A,[S]:S,[y]:y,[v]:v,[w]:w,[b]:b,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},L=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",O=t=>{const e=L(t);return"pointer"===e?a.Konva.pointerEventsEnabled&&I.pointer:"touch"===e?I.touch:"mouse"===e?I.mouse:void 0};function R(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&i.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}e.stages=[];class D extends o.Container{constructor(t){super(R(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",()=>{R(this.attrs)}),this._checkVisibility()}_validateAdd(t){const e="Layer"===t.getType(),n="FastLayer"===t.getType();e||n||i.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&&i.Util._isInDocument(t)&&this.container().removeChild(t);const n=e.stages.indexOf(this);return n>-1&&e.stages.splice(n,1),i.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}:(i.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,i=this.children;return(t.x||t.y)&&n.translate(-1*t.x,-1*t.y),i.forEach(function(e){if(!e.isVisible())return;const i=e._toKonvaCanvas(t);n.drawImage(i._canvas,t.x,t.y,i.getWidth()/i.getPixelRatio(),i.getHeight()/i.getPixelRatio())}),e}getIntersection(t){if(!t)return null;const e=this.children;for(let n=e.length-1;n>=0;n--){const i=e[n].getIntersection(t);if(i)return i}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&&i.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 u.hasPointerCapture(t,this)}setPointerCapture(t){u.setPointerCapture(t,this)}releaseCapture(t){u.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){a.Konva.isBrowser&&F.forEach(([t,e])=>{this.content.addEventListener(t,t=>{this[e](t)},{passive:!1})})}_pointerenter(t){this.setPointersPositions(t);const e=O(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=O(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=O(t.type),n=L(t.type);if(!e)return;this.setPointersPositions(t);const i=this._getTargetShape(n),r=!(a.Konva.isDragging()||a.Konva.isTransforming())||a.Konva.hitOnDragEnabled;i&&r?(i._fireAndBubble(e.pointerout,{evt:t}),i._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[n+"targetShape"]=null):r&&(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=O(t.type),n=L(t.type);if(!e)return;this.setPointersPositions(t);let i=!1;this._changedPointerPositions.forEach(r=>{const o=this.getIntersection(r);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(r.id),this[n+"ClickStartShape"]=o,o._fireAndBubble(e.pointerdown,{evt:t,pointerId:r.id}),i=!0;const s=t.type.indexOf("touch")>=0;o.preventDefault()&&t.cancelable&&s&&t.preventDefault()}),i||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=O(t.type),n=L(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 i={};let r=!1;const o=this._getTargetShape(n);this._changedPointerPositions.forEach(a=>{const s=u.getCapturedShape(a.id)||this.getIntersection(a),l=a.id,c={evt:t,pointerId:l},h=o!==s;if(h&&o&&(o._fireAndBubble(e.pointerout,{...c},s),o._fireAndBubble(e.pointerleave,{...c},s)),s){if(i[s._id])return;i[s._id]=!0}s&&s.isListening()?(r=!0,h&&(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)}),r||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=O(t.type),n=L(t.type);if(!e)return;this.setPointersPositions(t);const i=this[n+"ClickStartShape"],r=this[n+"ClickEndShape"],o={};let s=!1;this._changedPointerPositions.forEach(c=>{const h=u.getCapturedShape(c.id)||this.getIntersection(c);if(h){if(h.releaseCapture(c.id),o[h._id])return;o[h._id]=!0}const d=c.id,f={evt:t,pointerId:d};let p=!1;a.Konva["_"+n+"InDblClickWindow"]?(p=!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),h&&h.isListening()?(s=!0,this[n+"ClickEndShape"]=h,h._fireAndBubble(e.pointerup,{...f}),a.Konva["_"+n+"ListenClick"]&&i&&i===h&&(h._fireAndBubble(e.pointerclick,{...f}),p&&r&&r===h&&h._fireAndBubble(e.pointerdblclick,{...f}))):(this[n+"ClickEndShape"]=null,a.Konva["_"+n+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:d}),p&&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(E,{evt:t}):this._fire(E,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(T,{evt:t}):this._fire(T,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=u.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(w,u.createEvent(t)),u.releaseCapture(t.pointerId)}_lostpointercapture(t){u.releaseCapture(t.pointerId)}setPointersPositions(t){const e=this._getContentPosition();let n=null,r=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,r=(t.clientY-e.top)/e.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:i.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:n,y:r,id:i.Util._getFirstPointerId(t)}])}_setPointerPosition(t){i.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 i.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=D,D.prototype.nodeType="Stage",(0,c._registerNode)(D),r.Factory.addGetterSetter(D,"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 i=n(4060),r=n(6267),o=n(8871);class a extends r.Layer{constructor(t){super(t),this.listening(!1),i.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 i=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(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.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 i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var r=void 0!==n.layer;r&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,r&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var o=n.sourceMap;o&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(i,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 i=n(4892),r=n(6536),o=n(5483);function a(t,e,n,i,r){const o=n-e,a=r-i;if(0===o)return i+a/2;if(0===a)return i;let s=(t-e)/o;return s=a*s+i,s}e.Enhance=function(t){const e=t.data,n=e.length;let i,r,o,s=e[0],l=s,c=e[1],u=c,h=e[2],d=h;const f=this.enhance();if(0===f)return;for(let t=0;t<n;t+=4)i=e[t+0],i<s?s=i:i>l&&(l=i),r=e[t+1],r<c?c=r:r>u&&(u=r),o=e[t+2],o<h?h=o:o>d&&(d=o);let p,g,m,y,v,w;if(l===s&&(l=255,s=0),u===c&&(u=255,c=0),d===h&&(d=255,h=0),f>0)p=l+f*(255-l),g=s-f*(s-0),m=u+f*(255-u),y=c-f*(c-0),v=d+f*(255-d),w=h-f*(h-0);else{const t=.5*(l+s);p=l+f*(l-t),g=s+f*(s-t);const e=.5*(u+c);m=u+f*(u-e),y=c+f*(c-e);const n=.5*(d+h);v=d+f*(d-n),w=h+f*(h-n)}for(let t=0;t<n;t+=4)e[t+0]=a(e[t+0],s,l,g,p),e[t+1]=a(e[t+1],c,u,y,m),e[t+2]=a(e[t+2],h,d,w,v)},i.Factory.addGetterSetter(r.Node,"enhance",0,(0,o.getNumberValidator)(),i.Factory.afterSetFilter)},7939:(t,e,n)=>{"use strict";n.d(e,{A:()=>s});var i=n(1354),r=n.n(i),o=n(6314),a=n.n(o)()(r());a.push([t.id,".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,WAAW;AACf;;AAEA;IACI,4BAA4B;IAC5B,yBAAyB;IACzB,eAAe;AACnB;;AAEA;GACG,mBAAmB;AACtB;;AAEA;IACI,eAAe;IACf,kBAAkB;IAClB,YAAY;AAChB;;AAEA;IACI,WAAW;AACf;AACA;IACI,gBAAgB;AACpB;;AAEA;IACI,wBAAwB;AAC5B;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,oBAAoB;AACxB;;AAEA;IACI,aAAa;IACb,mBAAmB;IACnB,mBAAmB;IACnB,8BAA8B;IAC9B,uBAAuB;AAC3B;;AAEA;IACI,uBAAuB;IACvB,gBAAgB;AACpB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,kBAAkB;AACtB",sourcesContent:[".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}"],sourceRoot:""}]);const s=a},7949:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Group=void 0;const i=n(4060),r=n(4473),o=n(8871);class a extends r.Container{_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&i.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 i=n(4892),r=n(4723),o=n(8871),a=n(5483),s=n(8871);class l extends r.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),i.Factory.addGetterSetter(l,"radius",0,(0,a.getNumberValidator)()),i.Factory.addGetterSetter(l,"angle",0,(0,a.getNumberValidator)()),i.Factory.addGetterSetter(l,"clockwise",!1),i.Factory.backCompat(l,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"})},8103:(t,e,n)=>{"use strict";n.d(e,{A:()=>s});var i=n(1354),r=n.n(i),o=n(6314),a=n.n(o)()(r());a.push([t.id,".pareto-input-form {\n padding-left: 12px;\n overflow-y: scroll;\n padding-right: 4px;\n}","",{version:3,sources:["webpack://./css/pareto.css"],names:[],mappings:"AAAA;EACE,kBAAkB;EAClB,kBAAkB;EAClB,kBAAkB;AACpB",sourcesContent:[".pareto-input-form {\n padding-left: 12px;\n overflow-y: scroll;\n padding-right: 4px;\n}"],sourceRoot:""}]);const s=a},8137:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TextPath=void 0;const i=n(4060),r=n(4892),o=n(4723),a=n(1486),s=n(1958),l=n(5483),c=n(8871),u="normal";function h(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=i.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(),i=this.fontSize(),r=this.glyphInfo;"underline"===e&&t.beginPath();for(let n=0;n<r.length;n++){t.save();const o=r[n].p0;t.translate(o.x,o.y),t.rotate(r[n].rotation),this.partialText=r[n].text,t.fillStrokeShape(this),"underline"===e&&(0===n&&t.moveTo(0,i/2+1),t.lineTo(i,i/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=n,t.lineWidth=i/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 i=e[n].p1;t.lineTo(i.x,i.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return i.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(),i=this.align(),r=this.kerningFunc(),o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*n,0);let l=0;"center"===i&&(l=Math.max(0,this.pathLength/2-o/2)),"right"===i&&(l=Math.max(0,this.pathLength-o));const c=(0,s.stringToArray)(this.text());let u=l;for(let t=0;t<c.length;t++){const e=this._getPointAtLength(u);if(!e)return;let s=this._getTextSize(c[t]).width+n;if(" "===c[t]&&"justify"===i){const t=this.text().split(" ").length-1;s+=(this.pathLength-o)/t}const l=this._getPointAtLength(u+s);if(!l)return;const h=a.Path.getLineLength(e.x,e.y,l.x,l.y);let d=0;if(r)try{d=r(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+h/2,e.x,e.y,l.x,l.y),p=Math.atan2(l.y-e.y,l.x-e.x);this.glyphInfo.push({transposeX:f.x,transposeY:f.y,text:c[t],rotation:p,p0:e,p1:l}),u+=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,i=t[0]||0,r=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],i=Math.min(i,e),r=Math.max(r,e),o=Math.min(o,n),a=Math.max(a,n);const s=this.fontSize();return{x:i-s/2,y:o-s/2,width:r-i+s,height:a-o+s}}destroy(){return i.Util.releaseCanvas(this.dummyCanvas),super.destroy()}}e.TextPath=f,f.prototype._fillFunc=h,f.prototype._strokeFunc=d,f.prototype._fillFuncHit=h,f.prototype._strokeFuncHit=d,f.prototype.className="TextPath",f.prototype._attrsAffectingSize=["text","fontSize","data"],(0,c._registerNode)(f),r.Factory.addGetterSetter(f,"data"),r.Factory.addGetterSetter(f,"fontFamily","Arial"),r.Factory.addGetterSetter(f,"fontSize",12,(0,l.getNumberValidator)()),r.Factory.addGetterSetter(f,"fontStyle",u),r.Factory.addGetterSetter(f,"align","left"),r.Factory.addGetterSetter(f,"letterSpacing",0,(0,l.getNumberValidator)()),r.Factory.addGetterSetter(f,"textBaseline","middle"),r.Factory.addGetterSetter(f,"fontVariant",u),r.Factory.addGetterSetter(f,"text",""),r.Factory.addGetterSetter(f,"textDecoration",""),r.Factory.addGetterSetter(f,"kerningFunc",void 0)},8153:(t,e)=>{function n(t){return"number"!=typeof t||isNaN(t)?1:t}e.Fd=function(t){return function(t,e){var n={},i=function(t){return void 0===t?e:t};"function"==typeof e&&(i=e);var r=function(e){return i(e[t])},o=function(){return i(void 0)};return"string"==typeof t?(n.fromAttributes=r,n.fromGraph=function(t,e){return r(t.getEdgeAttributes(e))},n.fromEntry=function(t,e){return r(e)},n.fromPartialEntry=n.fromEntry,n.fromMinimalEntry=n.fromEntry):"function"==typeof t?(n.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},n.fromGraph=function(e,n){var r=e.extremities(n);return i(t(n,e.getEdgeAttributes(n),r[0],r[1],e.getNodeAttributes(r[0]),e.getNodeAttributes(r[1]),e.isUndirected(n)))},n.fromEntry=function(e,n,r,o,a,s,l){return i(t(e,n,r,o,a,s,l))},n.fromPartialEntry=function(e,n,r,o){return i(t(e,n,r,o))},n.fromMinimalEntry=function(e,n){return i(t(e,n))}):(n.fromAttributes=o,n.fromGraph=o,n.fromEntry=o,n.fromMinimalEntry=o),n}(t,n)}},8558:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Konva=void 0;const i=n(680),r=n(4821),o=n(9456),a=n(9729),s=n(6955),l=n(7256),c=n(6619),u=n(3443),h=n(1486),d=n(5155),f=n(9131),p=n(5451),g=n(9308),m=n(4481),y=n(1958),v=n(8137),w=n(5058),b=n(8001),C=n(6261),_=n(6627),A=n(2650),S=n(983),E=n(7928),x=n(7241),M=n(5461),P=n(4843),N=n(6564),T=n(5553),F=n(8624),I=n(5992),L=n(4943),O=n(7019),R=n(6921),D=n(3862),k=n(2512),G=n(517),U=n(661);e.Konva=i.Konva.Util._assign(i.Konva,{Arc:r.Arc,Arrow:o.Arrow,Circle:a.Circle,Ellipse:s.Ellipse,Image:l.Image,Label:c.Label,Tag:c.Tag,Line:u.Line,Path:h.Path,Rect:d.Rect,RegularPolygon:f.RegularPolygon,Ring:p.Ring,Sprite:g.Sprite,Star:m.Star,Text:y.Text,TextPath:v.TextPath,Transformer:w.Transformer,Wedge:b.Wedge,Filters:{Blur:C.Blur,Brighten:_.Brighten,Contrast:A.Contrast,Emboss:S.Emboss,Enhance:E.Enhance,Grayscale:x.Grayscale,HSL:M.HSL,HSV:P.HSV,Invert:N.Invert,Kaleidoscope:T.Kaleidoscope,Mask:F.Mask,Noise:I.Noise,Pixelate:L.Pixelate,Posterize:O.Posterize,RGB:R.RGB,RGBA:D.RGBA,Sepia:k.Sepia,Solarize:G.Solarize,Threshold:U.Threshold}})},8604:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HitCanvas=e.SceneCanvas=e.Canvas=void 0;const i=n(4060),r=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=i.Util.createCanvasElement(),e=t.getContext("2d");return a=(o.Konva._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),i.Util.releaseCanvas(t),a}();this.pixelRatio=e,this._canvas=i.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 i.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 r.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 r.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 i=n(4892),r=n(6536),o=n(5483);function a(t,e,n){let i=4*(n*t.width+e);const r=[];return r.push(t.data[i++],t.data[i++],t.data[i++],t.data[i++]),r}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),i=a(t,t.width-1,0),r=a(t,0,t.height-1),o=a(t,t.width-1,t.height-1),l=e||10;if(s(n,i)<l&&s(i,o)<l&&s(o,r)<l&&s(r,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}([i,n,o,r]),a=[];for(let n=0;n<t.width*t.height;n++){const i=s(e,[t.data[4*n],t.data[4*n+1],t.data[4*n+2]]);a[n]=i<l?0:255}return a}}(t,this.threshold());return e&&(e=function(t,e,n){const i=[1,1,1,1,0,1,1,1,1],r=Math.round(Math.sqrt(i.length)),o=Math.floor(r/2),a=[];for(let s=0;s<n;s++)for(let l=0;l<e;l++){const c=s*e+l;let u=0;for(let a=0;a<r;a++)for(let c=0;c<r;c++){const h=s+a-o,d=l+c-o;if(h>=0&&h<n&&d>=0&&d<e){const n=i[a*r+c];u+=t[h*e+d]*n}}a[c]=2040===u?255:0}return a}(e,t.width,t.height),e=function(t,e,n){const i=[1,1,1,1,1,1,1,1,1],r=Math.round(Math.sqrt(i.length)),o=Math.floor(r/2),a=[];for(let s=0;s<n;s++)for(let l=0;l<e;l++){const c=s*e+l;let u=0;for(let a=0;a<r;a++)for(let c=0;c<r;c++){const h=s+a-o,d=l+c-o;if(h>=0&&h<n&&d>=0&&d<e){const n=i[a*r+c];u+=t[h*e+d]*n}}a[c]=u>=1020?255:0}return a}(e,t.width,t.height),e=function(t,e,n){const i=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],r=Math.round(Math.sqrt(i.length)),o=Math.floor(r/2),a=[];for(let s=0;s<n;s++)for(let l=0;l<e;l++){const c=s*e+l;let u=0;for(let a=0;a<r;a++)for(let c=0;c<r;c++){const h=s+a-o,d=l+c-o;if(h>=0&&h<n&&d>=0&&d<e){const n=i[a*r+c];u+=t[h*e+d]*n}}a[c]=u}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},i.Factory.addGetterSetter(r.Node,"threshold",0,(0,o.getNumberValidator)(),i.Factory.afterSetFilter)},8665:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Easings=e.Tween=void 0;const i=n(4060),r=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 u{constructor(t,e,n,i,r,o,a){this.prop=t,this.propFunc=e,this.begin=i,this._pos=i,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=r-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 h{constructor(t){const n=this,o=t.node,l=o._id,d=t.easing||e.Easings.Linear,f=!!t.yoyo;let p,g;p=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(g in m||i.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new r.Animation(function(){n.tween.onEnterFrame()},m),this.tween=new u(g,function(t){n._tweenFunc(t)},d,0,1,1e3*p,f),this._addListeners(),h.attrs[l]||(h.attrs[l]={}),h.attrs[l][this._id]||(h.attrs[l][this._id]={}),h.tweens[l]||(h.tweens[l]={}),t)void 0===s[g]&&this._addAttr(g,t[g]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,e){const n=this.node,r=n._id;let o,a,s,c,u;const d=h.tweens[r][t];d&&delete h.attrs[r][d][t];let f=n.getAttr(t);if(i.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=i.Util._prepareArrayForTween(f,e,n.closed())):(s=e,e=i.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=i.Util.colorToRGBA(f[t]);u=i.Util.colorToRGBA(e[t]),f[t]=n,o.push({r:u.r-n.r,g:u.g-n.g,b:u.b-n.b,a:u.a-n.a})}else for(let t=0;t<a;t++)o.push(e[t]-f[t]);else-1!==l.indexOf(t)?(f=i.Util.colorToRGBA(f),u=i.Util.colorToRGBA(e),o={r:u.r-f.r,g:u.g-f.g,b:u.b-f.b,a:u.a-f.a}):o=e-f;h.attrs[r][this._id][t]={start:f,diff:o,end:e,trueEnd:s,trueStart:c},h.tweens[r][t]=this._id}_tweenFunc(t){const e=this.node,n=h.attrs[e._id][this._id];let r,o,a,s,c,u,d,f;for(r in n){if(o=n[r],a=o.start,s=o.diff,f=o.end,i.Util._isArray(a))if(c=[],d=Math.max(a.length,f.length),0===r.indexOf("fill"))for(u=0;u<d;u++)u%2==0?c.push((a[u]||0)+s[u]*t):c.push("rgba("+Math.round(a[u].r+s[u].r*t)+","+Math.round(a[u].g+s[u].g*t)+","+Math.round(a[u].b+s[u].b*t)+","+(a[u].a+s[u].a*t)+")");else for(u=0;u<d;u++)c.push((a[u]||0)+s[u]*t);else c=-1!==l.indexOf(r)?"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(r,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=h.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=h.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=h.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const e in n)delete h.tweens[t][e];delete h.attrs[t][e],h.tweens[t]&&(0===Object.keys(h.tweens[t]).length&&delete h.tweens[t],0===Object.keys(h.attrs[t]).length&&delete h.attrs[t])}}e.Tween=h,h.attrs={},h.tweens={},o.Node.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new h(t).play()},e.Easings={BackEaseIn(t,e,n,i){const r=1.70158;return n*(t/=i)*t*((r+1)*t-r)+e},BackEaseOut(t,e,n,i){const r=1.70158;return n*((t=t/i-1)*t*((r+1)*t+r)+1)+e},BackEaseInOut(t,e,n,i){let r=1.70158;return(t/=i/2)<1?n/2*(t*t*((1+(r*=1.525))*t-r))+e:n/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},ElasticEaseIn(t,e,n,i,r,o){let a=0;return 0===t?e:1===(t/=i)?e+n:(o||(o=.3*i),!r||r<Math.abs(n)?(r=n,a=o/4):a=o/(2*Math.PI)*Math.asin(n/r),-r*Math.pow(2,10*(t-=1))*Math.sin((t*i-a)*(2*Math.PI)/o)+e)},ElasticEaseOut(t,e,n,i,r,o){let a=0;return 0===t?e:1===(t/=i)?e+n:(o||(o=.3*i),!r||r<Math.abs(n)?(r=n,a=o/4):a=o/(2*Math.PI)*Math.asin(n/r),r*Math.pow(2,-10*t)*Math.sin((t*i-a)*(2*Math.PI)/o)+n+e)},ElasticEaseInOut(t,e,n,i,r,o){let a=0;return 0===t?e:2==(t/=i/2)?e+n:(o||(o=i*(.3*1.5)),!r||r<Math.abs(n)?(r=n,a=o/4):a=o/(2*Math.PI)*Math.asin(n/r),t<1?r*Math.pow(2,10*(t-=1))*Math.sin((t*i-a)*(2*Math.PI)/o)*-.5+e:r*Math.pow(2,-10*(t-=1))*Math.sin((t*i-a)*(2*Math.PI)/o)*.5+n+e)},BounceEaseOut:(t,e,n,i)=>(t/=i)<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,i,r)=>i-e.Easings.BounceEaseOut(r-t,0,i,r)+n,BounceEaseInOut:(t,n,i,r)=>t<r/2?.5*e.Easings.BounceEaseIn(2*t,0,i,r)+n:.5*e.Easings.BounceEaseOut(2*t-r,0,i,r)+.5*i+n,EaseIn:(t,e,n,i)=>n*(t/=i)*t+e,EaseOut:(t,e,n,i)=>-n*(t/=i)*(t-2)+e,EaseInOut:(t,e,n,i)=>(t/=i/2)<1?n/2*t*t+e:-n/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,n,i)=>n*(t/=i)*t*t*t*t+e,StrongEaseOut:(t,e,n,i)=>n*((t=t/i-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,n,i)=>(t/=i/2)<1?n/2*t*t*t*t*t+e:n/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,n,i)=>n*t/i+e}},8722:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getCapturedShape=function(t){return r.get(t)},e.createEvent=a,e.hasPointerCapture=function(t,e){return r.get(t)===e},e.setPointerCapture=function(t,e){s(t),e.getStage()&&(r.set(t,e),o&&e._fire("gotpointercapture",a(new PointerEvent("gotpointercapture"))))},e.releaseCapture=s;const i=n(8871),r=new Map,o=void 0!==i.Konva._global.PointerEvent;function a(t){return{evt:t,pointerId:t.pointerId}}function s(t,e){const n=r.get(t);if(!n)return;const i=n.getStage();i&&i.content,r.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 i=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*i: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)},8903:(t,e,n)=>{var i=n(1736),r=n(8153).Fd,o=n(2561),a=n(1782),s=n(9937);function l(t,e,n){if(!i(e))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");"number"==typeof n&&(n={iterations:n});var l=n.iterations;if("number"!=typeof l)throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(l<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var c=r("getEdgeWeight"in n?n.getEdgeWeight:"weight").fromEntry,u="function"==typeof n.outputReducer?n.outputReducer:null,h=a.assign({},s,n.settings),d=a.validateSettings(h);if(d)throw new Error("graphology-layout-forceatlas2: "+d.message);var f,p=a.graphToByteArrays(e,c);for(f=0;f<l;f++)o(h,p.nodes,p.edges);if(!t)return a.collectLayoutChanges(e,p.nodes);a.assignLayoutChanges(e,p.nodes,u)}var c=l.bind(null,!1);c.assign=l.bind(null,!0),c.inferSettings=function(t){var e="number"==typeof t?t:t.order;return{barnesHutOptimize:e>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(e)}},t.exports=c},9131:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RegularPolygon=void 0;const i=n(4892),r=n(4723),o=n(5483),a=n(8871);class s extends r.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 i=0;i<t;i++)n.push({x:e*Math.sin(2*i*Math.PI/t),y:-1*e*Math.cos(2*i*Math.PI/t)});return n}getSelfRect(){const t=this._getPoints();let e=t[0].x,n=t[0].y,i=t[0].x,r=t[0].y;return t.forEach(t=>{e=Math.min(e,t.x),n=Math.max(n,t.x),i=Math.min(i,t.y),r=Math.max(r,t.y)}),{x:e,y:i,width:n-e,height:r-i}}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),i.Factory.addGetterSetter(s,"radius",0,(0,o.getNumberValidator)()),i.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 i=n(4892),r=n(4723),o=n(9696),a=n(5483),s=n(8871);class l extends r.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(),i=4*n,r=this.animations()[e],o=this.frameOffsets(),a=r[i+0],s=r[i+1],l=r[i+2],c=r[i+3],u=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,l,c),t.closePath(),t.fillStrokeShape(this)),u)if(o){const i=o[e],r=2*n;t.drawImage(u,a,s,l,c,i[r+0],i[r+1],l,c)}else t.drawImage(u,a,s,l,c,0,0,l,c)}_hitFunc(t){const e=this.animation(),n=this.frameIndex(),i=4*n,r=this.animations()[e],o=this.frameOffsets(),a=r[i+2],s=r[i+3];if(t.beginPath(),o){const i=o[e],r=2*n;t.rect(i[r+0],i[r+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),i.Factory.addGetterSetter(l,"animation"),i.Factory.addGetterSetter(l,"animations"),i.Factory.addGetterSetter(l,"frameOffsets"),i.Factory.addGetterSetter(l,"image"),i.Factory.addGetterSetter(l,"frameIndex",0,(0,a.getNumberValidator)()),i.Factory.addGetterSetter(l,"frameRate",17,(0,a.getNumberValidator)()),i.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 i=n(4892),r=n(3443),o=n(5483),a=n(8871),s=n(1486);class l extends r.Line{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,n=this.points();let i=n;const r=0!==this.tension()&&n.length>4;r&&(i=this.getTensionPoints());const o=this.pointerLength(),a=n.length;let l,c;if(r){const t=[i[i.length-4],i[i.length-3],i[i.length-2],i[i.length-1],n[a-2],n[a-1]],e=s.Path.calcLength(i[i.length-4],i[i.length-3],"C",t),r=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]-r.x,c=n[a-1]-r.y}else l=n[a-2]-n[a-4],c=n[a-1]-n[a-3];const u=(Math.atan2(c,l)+e)%e,h=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(n[a-2],n[a-1]),t.rotate(u),t.moveTo(0,0),t.lineTo(-o,h/2),t.lineTo(-o,-h/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(n[0],n[1]),r?(l=(i[0]+i[2])/2-n[0],c=(i[1]+i[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,h/2),t.lineTo(-o,-h/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),i.Factory.addGetterSetter(l,"pointerLength",10,(0,o.getNumberValidator)()),i.Factory.addGetterSetter(l,"pointerWidth",10,(0,o.getNumberValidator)()),i.Factory.addGetterSetter(l,"pointerAtBeginning",!1),i.Factory.addGetterSetter(l,"pointerAtEnding",!0)},9696:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Animation=void 0;const i=n(8871),r=n(4060),o=i.glob.performance&&i.glob.performance.now?function(){return i.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 i=0;i<n;i++)if(e[i]._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,i=n.length;for(let t=0;t<i;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 i=e[n],r=i.layers,a=i.func;i._updateFrameObject(o());const s=r.length;let l;if(l=!a||!1!==a.call(i,i.frame),l)for(let e=0;e<s;e++){const n=r[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(),r.Util.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,r.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 i=n(4892),r=n(4723),o=n(5483),a=n(8871);class s extends r.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),i.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 i=n(4060),r=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,r.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,r,o,a,s=this.traceArr,l=s.length,c="";for(n=0;n<l;n++)r=s[n],o=r.method,o?(a=r.args,c+=o,t?c+="()":i.Util._isArray(a[0])?c+="(["+a.join(",")+"])":(e&&(a=a.map(t=>"number"==typeof t?Math.floor(t):t)),c+="("+a.join(",")+")")):(c+=r.property,t||(c+="="+r.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,i,r,o){this._context.arc(t,e,n,i,r,o)}arcTo(t,e,n,i,r){this._context.arcTo(t,e,n,i,r)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,n,i,r,o){this._context.bezierCurveTo(t,e,n,i,r,o)}clearRect(t,e,n,i){this._context.clearRect(t,e,n,i)}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,i){return this._context.createLinearGradient(t,e,n,i)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,n,i,r,o){return this._context.createRadialGradient(t,e,n,i,r,o)}drawImage(t,e,n,i,r,o,a,s,l){const c=arguments,u=this._context;3===c.length?u.drawImage(t,e,n):5===c.length?u.drawImage(t,e,n,i,r):9===c.length&&u.drawImage(t,e,n,i,r,o,a,s,l)}ellipse(t,e,n,i,r,o,a,s){this._context.ellipse(t,e,n,i,r,o,a,s)}isPointInPath(t,e,n,i){return n?this._context.isPointInPath(n,t,e,i):this._context.isPointInPath(t,e,i)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,n,i){this._context.fillRect(t,e,n,i)}strokeRect(t,e,n,i){this._context.strokeRect(t,e,n,i)}fillText(t,e,n,i){i?this._context.fillText(t,e,n,i):this._context.fillText(t,e,n)}measureText(t){return this._context.measureText(t)}getImageData(t,e,n,i){return this._context.getImageData(t,e,n,i)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,n,i){this._context.rect(t,e,n,i)}roundRect(t,e,n,i,r){this._context.roundRect(t,e,n,i,r)}putImageData(t,e,n){this._context.putImageData(t,e,n)}quadraticCurveTo(t,e,n,i){this._context.quadraticCurveTo(t,e,n,i)}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,i,r,o){this._context.setTransform(t,e,n,i,r,o)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,n,i){this._context.strokeText(t,e,n,i)}transform(t,e,n,i,r,o){this._context.transform(t,e,n,i,r,o)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let t,e,n=this,r=o.length,a=this.setAttr;const s=function(t){let r,o=n[t];n[t]=function(){return e=function(t){const e=[],n=t.length,r=i.Util;for(let i=0;i<n;i++){let n=t[i];r._isNumber(n)?n=Math.round(1e3*n)/1e3:r._isString(n)||(n+=""),e.push(n)}return e}(Array.prototype.slice.call(arguments,0)),r=o.apply(n,arguments),n._trace({method:t,args:e}),r}};for(t=0;t<r;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 i=t.getFillPatternImage();if(i&&"pattern"===n)return void this._fillPattern(t);const r=t.getFillLinearGradientColorStops();if(r&&"linear-gradient"===n)return void this._fillLinearGradient(t);const o=t.getFillRadialGradientColorStops();o&&"radial-gradient"===n?this._fillRadialGradient(t):e?this._fillColor(t):i?this._fillPattern(t):r?this._fillLinearGradient(t):o&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),n=t.getStrokeLinearGradientEndPoint(),i=t.getStrokeLinearGradientColorStops(),r=this.createLinearGradient(e.x,e.y,n.x,n.y);if(i){for(let t=0;t<i.length;t+=2)r.addColorStop(i[t],i[t+1]);this.setAttr("strokeStyle",r)}}_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,i;const r=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",o=null!==(n=t.getShadowBlur())&&void 0!==n?n:5,a=null!==(i=t.getShadowOffset())&&void 0!==i?i:{x:0,y:0},s=t.getAbsoluteScale(),l=this.canvas.getPixelRatio(),c=s.x*l,u=s.y*l;this.setAttr("shadowColor",r),this.setAttr("shadowBlur",o*Math.min(Math.abs(c),Math.abs(u))),this.setAttr("shadowOffsetX",a.x*c),this.setAttr("shadowOffsetY",a.y*u)}},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(),i="auto"===n?t.strokeWidth():n;this.setAttr("lineWidth",i),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}}},9937:t=>{t.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={id:i,loaded:!1,exports:{}};return t[i].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 i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},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 i=e.getElementsByTagName("script");if(i.length)for(var r=i.length-1;r>-1&&(!t||!/^http(s?):/.test(t));)t=i[r--].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 i={};(()=>{"use strict";n.r(i),n.d(i,{GetMCLEditor:()=>or,MCLClustering:()=>ar,MVA:()=>ur,PCA:()=>tr,PLS:()=>lr,PackageFunctions:()=>lo,_package:()=>so,anova:()=>Ir,applyLinearKernelSVM:()=>fr,applyLinearRegression:()=>Dr,applyPLSRegression:()=>Hr,applyPolynomialKernelSVM:()=>Ar,applyRBFkernelSVM:()=>vr,applySigmoidKernelSVM:()=>Pr,applySoftmax:()=>Br,applyXGBooster:()=>Xr,dbScan:()=>Zi,dbscanPostProcessingFunction:()=>er,demoMultivariateAnalysis:()=>hr,generatePmpoDataset:()=>no,getPmpoAppItems:()=>eo,info:()=>Qi,init:()=>Ji,isApplicableLinearKernelSVM:()=>pr,isApplicableLinearRegression:()=>kr,isApplicablePLSRegression:()=>jr,isApplicablePolynomialKernelSVM:()=>Sr,isApplicableRBFkernelSVM:()=>wr,isApplicableSigmoidKernelSVM:()=>Nr,isApplicableSoftmax:()=>Vr,isApplicableXGBooster:()=>Qr,isInteractiveLinearKernelSVM:()=>gr,isInteractiveLinearRegression:()=>Gr,isInteractivePLSRegression:()=>Yr,isInteractivePolynomialKernelSVM:()=>Er,isInteractiveRBFkernelSVM:()=>br,isInteractiveSigmoidKernelSVM:()=>Tr,isInteractiveSoftmax:()=>zr,isInteractiveXGBooster:()=>$r,kNNImputation:()=>Lr,kNNImputationForTable:()=>Or,markovClusteringViewer:()=>sr,numberPreprocessingFunction:()=>nr,paretoFront:()=>Jr,paretoFrontViewer:()=>Zr,reduceDimensionality:()=>rr,stringPreprocessingFunction:()=>ir,topMenuPLS:()=>cr,trainLinearKernelSVM:()=>dr,trainLinearRegression:()=>Rr,trainPLSRegression:()=>Wr,trainPmpo:()=>to,trainPolynomialKernelSVM:()=>_r,trainRBFkernelSVM:()=>yr,trainSigmoidKernelSVM:()=>Mr,trainSoftmax:()=>Ur,trainXGBooster:()=>qr,visualizeLinearKernelSVM:()=>mr,visualizePLSRegression:()=>Kr,visualizePolynomialKernelSVM:()=>xr,visualizeRBFkernelSVM:()=>Cr,visualizeSigmoidKernelSVM:()=>Fr});const t=grok,e=ui,r=DG,o={i32:"HEAP32",f32:"HEAPF32"},a={i32:Int32Array,f32:Float32Array},s={i32:2,f32:2},l={i32:DG.Column.fromInt32Array,f32:DG.Column.fromFloat32Array};class c{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 u extends c{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*a[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const e=this.type,n=s[e],i=t[o[e]];let r=null;const l=this.data;r="int"==l.type&&"i32"==e||"double"==l.type&&"f32"==e?l.getRawData():new a[e](l.getRawData()),r&&i.set(r,this.buf>>n)}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[o[e]],i=this.buf,r=a[e].BYTES_PER_ELEMENT,s=this.data.getRawData();for(let t=0;t<this.numOfRows;t++)s[t]=n[i/r+t]}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class h extends u{constructor(t,e){super([],t,!0),this.numOfRows=e}putDataToBuffer(t){}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[o[e]],i=this.buf,r=l[e],s=new a[e](this.numOfRows);for(let t=0;t<s.length;t++)s[t]=n[i/s.BYTES_PER_ELEMENT+t];this.data=r("name",s)}}}class d extends c{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*a[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const e=this.type,n=s[e],i=t[o[e]],r=a[e].BYTES_PER_ELEMENT;for(let t=0;t<this.numOfColumns;t++){let o=null;const s=this.data[t];o="int"==s.type&&"i32"==e||"double"==s.type&&"f32"==e?s.getRawData():new a[e](s.getRawData()),null!=o&&i.set(o,this.buf+t*this.numOfRows*r>>n)}}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[o[e]],i=this.numOfRows,r=this.numOfColumns,s=new a[e](n.buffer,this.buf,i*r);for(let t=0;t<r;t++){const e=this.data[t].getRawData();for(let n=0;n<i;n++)e[n]=s[n+t*i]}}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class f extends d{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[o[e]],i=this.numOfRows,r=this.numOfColumns,s=a[e].BYTES_PER_ELEMENT,c=l[e],u=this.buf;for(let t=0;t<r;t++){const r=new a[e](i);for(let e=0;e<i;e++)r[e]=n[u/s+e+t*i];this.data.push(c((t+1).toString(),r))}}}}const p={intColumn:t=>new u(t,"i32"),newIntColumn:t=>new h("i32",t),intColumns:t=>new d(t.toList(),"i32"),newIntColumns:(t,e)=>new f("i32",t,e),floatColumn:t=>new u(t,"f32"),newFloatColumn:t=>new h("f32",t),floatColumns:t=>new d(t.toList(),"f32"),newFloatColumns:(t,e)=>new f("f32",t,e),int:t=>new c(t),num:t=>new c(t)},g={tableFromColumns:t=>DG.DataFrame.fromColumns(t.data),num:t=>t,int:t=>t,double:t=>t,column:t=>t.data};function m(t,e,n){const i=t[e],r=i.arguments,o=[];let a=0;for(const t in r){const e=r[t];if("_callResult"!=t){switch(e.type){case"floatColumns":case"int":case"num":case"floatColumn":case"intColumn":case"intColumns":e.data=p[e.type](n[a]),a++;break;case"newFloatColumns":case"newIntColumns":const t=r[e.numOfRows.ref].data[e.numOfRows.value],i=r[e.numOfColumns.ref].data[e.numOfColumns.value];e.data=p[e.type](t,i);break;case"newFloatColumn":case"newIntColumn":const o=r[e.numOfRows.ref].data[e.numOfRows.value];e.data=p[e.type](o)}o.push(r[t].data)}}const s=function(t,e,n,i){let r;for(const e of i)e.allocateMemoryForBuffer(t);let o=!0;for(const t of i)o&=t.isMemoryForBufferAllocated();if(o){const n=[],o=[];for(const e of i)e.complementArrOfParams(n),e.complementArrOfTypes(o),e.putDataToBuffer(t);const a="number";r=t.ccall(e,a,o,n);for(const e of i)e.getDataFromBuffer(t)}for(const e of i)e.freeBuffer(t);if(null!=r)return r}(t,e,0,o);r._callResult=p.num(s);const l=i.output;if("objects"!=l.type)return g[l.type](r[l.source].data);const c=[];for(const t of l.source)c.push(r[t].data.data);return c}const y="num",v="floatColumn",w="intColumn",b="floatColumns",C="newFloatColumns",_="intColumns",A="newIntColumns",S="newFloatColumn",E="newIntColumn",x="numOfRows",M="numOfColumns",P="ref",N="value",T="int",F="double",I={intColumn:Int32Array,floatColumn:Float32Array,floatColumns:Float32Array,newFloatColumns:Float32Array,intColumns:Int32Array,newIntColumns:Int32Array,newFloatColumn:Float32Array,newIntColumn:Int32Array};function L(t,e){let n,i=[],r=0;for(const o in t){const a=t[o],s=a.type;if("_callResult"!==o){switch(s){case y:case T:case F:a.data=e[r],r++;break;case w:case v:let i;const o=e[r],l=o.length;i=o.type===T&&s===w||o.type===F&&s===v?o.getRawData().slice(0,l):new I[s](o.getRawData().slice(0,l)),a.data={array:i,numOfRows:l},r++;break;case E:case S:let c=0;n=a[x][P],c=t[n].type===y?t[n].data:t[n].data[a[x][N]],a.data={numOfRows:c},r++;break;case _:case b:let u=[];const h=e[r].byIndex(0).length;for(const t of e[r].toList())t.type===T&&s===w||t.type===F&&s===v?u.push(t.getRawData().slice(0,h)):u.push(new I[s](t.getRawData().slice(0,h)));a.data={arrays:u,numOfRows:h,numOfColumns:u.length},r++;break;case A:case C:let d=0,f=0;n=a[x][P],d=t[n].type===y?t[n].data:t[n].data[a[x][N]],n=a[M][P],f=t[n].type===y?t[n].data:t[n].data[a[M][N]],a.data={numOfRows:d,numOfColumns:f},r++;break;default:return}i.push(a)}}return i}function O(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 i=0;for(const r in t){const o=t[r];switch(o.type){case y:case T:case F:case w:case v:case b:case _:break;case S:case E:let t;null==o.name?t=(0).toString():s=o.name,o.column=n[o.type](t,e[i].array);break;case A:case C:let r=[],a=e[i].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++)r.push(n[o.type](s[t],e[i].arrays[t]));o.columns=r}i++}}(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 y:case T:case F: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 i=[];for(let r of e.source){let e=t.arguments[r];i.push(e[n[e.type]])}return i}}(t);return function(t){for(const e in t){const n=t[e];switch(n.type){case y:case T:case F:case w:case v:case _:case b:break;case E:case S:n.column=null;break;case A:case C:n.columns=null}}}(t.arguments),n}async function R(t,e,i){return new Promise((t,r)=>{const o=new Worker(new URL(n.p+n.u(128),n.b));o.postMessage(L(EDA.principalComponentAnalysisNipals.arguments,[e,i])),o.onmessage=function(e){o.terminate(),t(O(EDA.principalComponentAnalysisNipals,e.data))}})}const D=1e-6;function k(t){if(t.type!=r.COLUMN_TYPE.FLOAT&&t.type!=r.COLUMN_TYPE.INT)throw new Error("unsupported column type: "+t.type)}function G(t){if(t.stats.missingValueCount>0)throw new Error(`The column '${t.name}' has missing values.`)}function U(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)k(e),G(e)}(t,e),t.length*t.byIndex(0).length>1e8)throw new Error("dataframe is too big.")}function B(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,i=n.stats.avg,r=n.getRawData();if(t>0)for(let n=0;n<e;++n)r[n]=(r[n]-i)/t;else for(let t=0;t<e;++t)r[t]-=i}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)>D){const i=n.getRawData();for(let n=0;n<e;++n)i[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)>D&&t>0){const i=n.getRawData();for(let n=0;n<e;++n)i[n]/=t}}return t}(t):t}function V(t,e,i,o,a){return s=this,l=void 0,u=function*(){U(e,i);const s=t.rowCount,l=function(t){const e=[];for(const n of t)n.stats.stdev>0&&n.stats.missingValueCount<1&&e.push(n);return r.DataFrame.fromColumns(e)}(e),c=l.columns.length;if(0===c){const t=[];for(let e=0;e<i;++e)t.push(r.Column.fromFloat32Array(`${e+1}`,new Float32Array(s).fill(0)));return r.DataFrame.fromColumns(t)}const u=c<i?i-c:0,h=Math.min(i,c);let d;if(c>900)d=yield R(0,e,h);else{const t=yield async function(t,e,i){return new Promise((t,r)=>{const o=new Worker(new URL(n.p+n.u(860),n.b));o.postMessage(L(EDA.principalComponentAnalysis.arguments,[e,i,1,0])),o.onmessage=function(e){o.terminate(),0===e.data.callResult?t(O(EDA.principalComponentAnalysis,e.data)):t(-1)}})}(0,e,h);d=-1!==t?B(t,o,a):yield R(0,e,h)}if(void 0===d)throw new Error("Failed to compute PCA");d=B(d,o,a);const f=d.columns,p=f.length;for(let t=0;t<u;++t)f.add(r.Column.fromFloat32Array(`${p+t+1}`,new Float32Array(s).fill(0)));return d},new((c=void 0)||(c=Promise))(function(t,e){function n(t){try{r(u.next(t))}catch(t){e(t)}}function i(t){try{r(u.throw(t))}catch(t){e(t)}}function r(e){var r;e.done?t(e.value):(r=e.value,r instanceof c?r:new c(function(t){t(r)})).then(n,i)}r((u=u.apply(s,l||[])).next())});var s,l,c,u}var z=function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((i=i.apply(t,e||[])).next())})};const W="incorrect kernel.",H="mean",j="std dev",K="alpha",Y="weight",q="Kernel params",X=["linear","polynomial","RBF","sigmoid"];function $(t,e,i){return z(this,void 0,void 0,function*(){const o=e.columns;if(2!=i.categories.length)throw new Error("labels must be strings of two categories.");const a=r.Column.float(i.name,i.length);for(let t=0;t<i.length;t++)a.set(t,i.get(t)==i.categories[0]?-1:1,!1);const s=yield function(t,e,i){return z(this,void 0,void 0,function*(){!function(t){if(t.gamma<=0)throw new Error("gamma must be strictly positive.");switch(t.kernel){case 0:case 3:return;case 2:if(t.sigma<=0)throw new Error("sigma must be strictly positive.");return;case 1:if(t.cParam<=0)throw new Error("c must be strictly positive.");if(t.dParam<=0)throw new Error("d must be strictly positive.");return;default:throw new Error(W)}}(t);const o=[0,0];switch(t.kernel){case 0:break;case 2:o[0]=t.sigma;break;case 1:o[0]=t.cParam,o[1]=t.dParam;break;case 3:o[0]=t.kappa,o[1]=t.theta;break;default:throw new Error(W)}const a=r.Column.fromList("double",q,o),s=e.toList(),l=s[0].length+1,c=s.length+1;let u;const h=async function(t,e,i,r,o,a,s,l){return new Promise((a,c)=>{const u=new Worker(new URL(n.p+n.u(656),n.b));u.postMessage(L(EDA.trainAndAnalyzeLSSVM.arguments,[t,e,i,r,o,4,s,l])),u.onmessage=function(t){u.terminate(),a(O(EDA.trainAndAnalyzeLSSVM,t.data))}})}(t.gamma,t.kernel,a,l,c,0,e,i);yield h.then(t=>{u=t},t=>{throw new Error(`Error: ${t}`)}),u[1].name=H,u[2].name=j,u[3].name=K,u[4].name=Y,u[5].name="predicted",u[6].name="correctness",u[7].name="Confusion matrix";const d={trainGamma:t.gamma,kernelType:t.kernel,kernelParams:a,trainLabels:i,normalizedTrainData:r.DataFrame.fromColumns(u[0]),means:u[1],stdDevs:u[2],modelParams:u[3],modelWeights:u[4],predictedLabels:u[5],correctness:u[6],confusionMatrix:u[7],trainError:void 0,featuresCount:s.length,trainSamplesCount:s[0].length};return function(t){const e=t.confusionMatrix.getRawData(),n=e[0],i=e[3],r=e[2],o=e[1],a=n+o,s=r+i,l=n/a,c=i/s,u=n/(n+r),h=i/(i+o),d=(n+i)/(a+s),f=(l+c)/2;t.sensitivity=l,t.specificity=c,t.balancedAccuracy=f,t.positivePredicitveValue=u,t.negativePredicitveValue=h,t.trainError=100*(1-d)}(d),d})}(t,o,a);return s.realLabels=i,s})}function Q(t,e){const n=Z(e);return r.Viewer.form(n.modelInfo,{showNavigation:!1}).root}function J(t){const e=t.normalizedTrainData.columns,n=t.trainSamplesCount,i=t.featuresCount,o=r.DataFrame.fromColumns([t.realLabels]).toByteArray(),a=4+o.length+4-o.length%4,s=function(t){const e=t.kernelParams.getRawData();return r.DataFrame.fromColumns([r.Column.fromList("double","Gamma",[t.trainGamma]),r.Column.fromStrings("Kernel",[X[t.kernelType]]),r.Column.fromList("double","Kernel parameter 1",[e[0]]),r.Column.fromList("double","Kernel parameter 2",[e[1]]),r.Column.fromList("double","Features count",[t.featuresCount]),r.Column.fromList("double","Train samples count",[t.trainSamplesCount]),r.Column.fromList("double","Train error, %",[t.trainError]),r.Column.fromList("double","Balanced accuracy",[t.balancedAccuracy]),r.Column.fromList("double","Sensitivity",[t.sensitivity]),r.Column.fromList("double","Specificity",[t.specificity]),r.Column.fromList("double","Positive predicitve value",[t.positivePredicitveValue]),r.Column.fromList("double","Negative predicitve value",[t.negativePredicitveValue])])}(t).toByteArray(),l=4+s.length+4-s.length%4,c=new Uint8Array(4*(5+n+i+i+n+1+i+1+i*n)+a+l),u=c.buffer;let h=0,d=new Int32Array(u,h,3);d[0]=t.kernelType,d[1]=n,d[2]=i,h+=12;let f=new Float32Array(u,h,2);f.set(t.kernelParams.getRawData()),h+=8,f=new Float32Array(u,h,n),f.set(t.trainLabels.getRawData()),h+=4*n,f=new Float32Array(u,h,i),f.set(t.means.getRawData()),h+=4*i,f=new Float32Array(u,h,i),f.set(t.stdDevs.getRawData()),h+=4*i,f=new Float32Array(u,h,n+1),f.set(t.modelParams.getRawData()),h+=4*(n+1),f=new Float32Array(u,h,i+1),f.set(t.modelWeights.getRawData()),h+=4*(i+1);for(const t of e)f=new Float32Array(u,h,i),f.set(t.getRawData()),h+=4*i;return d=new Int32Array(u,h,1),d[0]=o.length,c.set(o,h+4),h+=a,d=new Int32Array(u,h,1),d[0]=s.length,c.set(s,h+4),h+=l,c}function Z(t){const e=t.buffer;let n=0;const i=new Int32Array(e,n,3);n+=12;const o=i[1],a=i[2],s=r.Column.fromFloat32Array(q,new Float32Array(e,n,2));n+=8;const l=r.Column.fromFloat32Array("Labels",new Float32Array(e,n,o));n+=4*o;const c=r.Column.fromFloat32Array(H,new Float32Array(e,n,a));n+=4*a;const u=r.Column.fromFloat32Array(j,new Float32Array(e,n,a));n+=4*a;const h=r.Column.fromFloat32Array(K,new Float32Array(e,n,o+1));n+=4*(o+1);const d=r.Column.fromFloat32Array(Y,new Float32Array(e,n,a+1));n+=4*(a+1);const f=[];for(let t=0;t<o;t++)f.push(r.Column.fromFloat32Array(t.toString(),new Float32Array(e,n,a))),n+=4*a;const p=r.DataFrame.fromColumns(f),g=new Int32Array(e,n,1)[0],m=g+4-g%4;n+=4;const y=r.DataFrame.fromByteArray(new Uint8Array(e,n,g)).columns.byIndex(0);n+=m;const v=new Int32Array(e,n,1)[0],w=v+4-v%4;n+=4;const b=r.DataFrame.fromByteArray(new Uint8Array(e,n,v));return n+=w,{kernelType:i[0],kernelParams:s,trainLabels:l,realLabels:y,means:c,stdDevs:u,modelParams:h,modelWeights:d,normalizedTrainData:p,modelInfo:b}}function tt(t,e){return z(this,void 0,void 0,function*(){const i=Z(new Uint8Array(e)),o=yield function(t,e){return z(this,void 0,void 0,function*(){let i;const r=async function(t,e,i,r,o,a,s,l,c){return new Promise((u,h)=>{const d=new Worker(new URL(n.p+n.u(763),n.b));d.postMessage(L(EDA.predictByLSSVM.arguments,[t,e,i,r,o,a,s,l,c])),d.onmessage=function(t){d.terminate(),u(O(EDA.predictByLSSVM,t.data))}})}(t.kernelType,t.kernelParams,t.normalizedTrainData.columns,t.trainLabels,t.means,t.stdDevs,t.modelParams,t.modelWeights,e);return yield r.then(t=>{i=t},t=>{throw new Error(`Error: ${t}`)}),i})}(i,t.columns),a=r.Column.string("prediction",o.length),s=i.realLabels.categories;for(let t=0;t<a.length;t++)a.set(t,-1==o.get(t)?s[0]:s[1]);return r.DataFrame.fromColumns([a])})}function et(t,e){const n=t.columns;if(!e.matches("categorical")||e.categories.length>2)return!1;let i=!0;for(let t=0;t<n.length;t++)i=i&&n.byIndex(t).matches("numerical");return i}function nt(t,e){return t.rowCount<=1e3}var it,rt,ot,at,st,lt,ct,ut;!function(t){t[t.COMPUTE_COMPONENTS=0]="COMPUTE_COMPONENTS",t[t.PERFORM_MVA=1]="PERFORM_MVA",t[t.DEMO=2]="DEMO"}(it||(it={})),function(t){t.NO_DF="No dataframe is opened",t.NO_COLS="No numeric columns without missing values",t.ONE_COL="No columns to be used as features (just one numeric columns without missing values)",t.EMPTY_DF="Dataframe is empty",t.PREDICT="Predictors must not contain a response variable",t.ENOUGH="Not enough of features",t.COMP_LIN_PLS="Components count must be less than the number of features",t.COMP_QUA_PLS="Too large components count for the quadratic PLS regression",t.COMPONENTS="Components count must be greater than 1",t.INV_INP="Invalid inputs"}(rt||(rt={})),function(t){t.PREDICT="Predict",t.USING="Using",t.COMPONENTS="Components",t.PLS="PLS",t.MVA="Multivariate Analysis (PLS)",t.RUN="RUN",t.NAMES="Names",t.MODEL="Observed vs. Predicted",t.FEATURE="Feature",t.REGR_COEFS="Regression Coefficients",t.XLOADING="x.loading.p",t.LOADINGS="Loadings",t.XSCORE="x.score.t",t.YSCORE="y.score.u",t.SCORES="Scores",t.EXPL_VAR="Explained Variance",t.EXPLORE="Explore",t.FEATURES="Feature names",t.BROWSE="Browse",t.ANALYSIS="Features Analysis",t.QUADRATIC="Quadratic"}(ot||(ot={})),function(t){t.PREDICT="Column with the response variable",t.FEATURES="Predictors (features)",t.COMPONENTS="Number of PLS components",t.PLS="Compute PLS components",t.MVA="Perform multivariate analysis",t.NAMES="Names of data samples",t.QUADRATIC="Specifies whether to include squared terms as additional predictors in the PLS model"}(at||(at={})),function(t){t.PLS="/help/explore/multivariate-analysis#pls-components",t.MVA="/help/explore/multivariate-analysis",t.MODEL="/help/explore/multivariate-analysis#observed-vs-predicted",t.COEFFS="/help/explore/multivariate-analysis#regression-coefficients",t.LOADINGS="/help/explore/multivariate-analysis#loadings",t.EXPL_VARS="/help/explore/multivariate-analysis#explained-variance",t.SCORES="/help/explore/multivariate-analysis#scores"}(st||(st={})),function(t){t[t.DEFAULT=3]="DEFAULT",t[t.MIN=1]="MIN"}(lt||(lt={})),function(t){t.PREFIX="PLS",t.SUFFIX="(predicted)",t.COMP="component",t.COMPS="components"}(ct||(ct={})),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"}(ut||(ut={}));const ht=[.49,.79,.99];var dt;!function(t){t.AXIS="#838383",t.CIRCLE="#0000FF",t.INVALID="#EB6767",t.VALID_TEXT="#4d5261",t.VALID_LINE="#dbdcdf"}(dt||(dt={}));const ft=[{caption:ot.MODEL,text:"Closer to the line means better price prediction."},{caption:ot.SCORES,text:"The latent factor values for each sample reflect the similarities and dissimilarities among observations."},{caption:ot.LOADINGS,text:"The impact of each feature on the latent factors: higher loading means stronger influence."},{caption:ot.REGR_COEFS,text:"Parameters of the obtained model: features make different contribution to the prediction."},{caption:ot.EXPL_VAR,text:"How well the latent components fit source data: closer to one means better fit."}],pt=ft.map(t=>`# ${t.caption}\n\n${t.text}`).join("\n\n")+`\n\n# Learn more\n \n * [Multivariate analysis](${st.MVA}),\n * [ANOVA](https://datagrok.ai/help/explore/anova)`;var gt=function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((i=i.apply(t,e||[])).next())})};const mt=Math.min;function yt(t){const e=[],n=(t,n)=>{e.push({type:"line",formula:t,width:1,visible:!0,title:" ",min:-n,max:n,color:dt.CIRCLE})};return t.forEach(i=>{const r="${"+i+"}";e.push({type:"line",formula:`${r} = 0`,width:1,visible:!0,title:" ",color:dt.AXIS}),t.forEach(t=>{const e="${"+t+"}";ht.forEach(t=>{n(e+` = sqrt(${t*t} - ${r} * ${r})`,t),n(e+` = -sqrt(${t*t} - ${r} * ${r})`,t)})})}),e}function vt(t){return gt(this,void 0,void 0,function*(){U(t.features,t.components),k(t.predict),G(t.predict);const e=yield async function(t,e,i,r){return new Promise((t,o)=>{const a=new Worker(new URL(n.p+n.u(412),n.b));a.postMessage(L(EDA.partialLeastSquareRegression.arguments,[e,i,r])),a.onmessage=function(e){a.terminate(),t(O(EDA.partialLeastSquareRegression,e.data))}})}(t.table,t.features,t.predict,t.components);return{prediction:e[ut.PREDICTION],regressionCoefficients:e[ut.REGR_COEFFS],tScores:e[ut.T_SCORES],uScores:e[ut.U_SCORES],xLoadings:e[ut.X_LOADINGS],yLoadings:e[ut.Y_LOADINGS]}})}function wt(n){return gt(this,void 0,void 0,function*(){const i=t.shell.t;if(null===i)return void t.shell.warning(rt.NO_DF);if(0===i.rowCount)return void t.shell.warning(rt.EMPTY_DF);const o=[],a=[],s=[],l=t=>(t.type===r.COLUMN_TYPE.INT||t.type===r.COLUMN_TYPE.FLOAT)&&0===t.stats.missingValueCount;if(i.columns.toList().forEach(t=>{l(t)?(o.push(t.name),a.push(t)):t.type===r.COLUMN_TYPE.STRING&&s.push(t)}),0===o.length)return void t.shell.warning(rt.NO_COLS);if(1===o.length)return void t.shell.warning(rt.ONE_COL);let c=a.slice(0,a.length-1),u=a[a.length-1],h=mt(o.length-1,lt.DEFAULT),d=!1;const f=e.input.column(ot.PREDICT,{table:i,value:u,nullable:!1,onValueChanged:t=>{u=t,b()},filter:t=>l(t),tooltipText:at.PREDICT}),p=e.input.columns(ot.USING,{table:i,available:o,value:c,onValueChanged:t=>{c=t,b()},tooltipText:at.FEATURES}),g=e.input.int(ot.COMPONENTS,{value:h,showPlusMinus:!0,onValueChanged:t=>{h=t,b()},tooltipText:at.COMPONENTS});let m,y,v;n===it.COMPUTE_COMPONENTS?(m=ot.PLS,y=st.PLS,v=at.PLS):(m=ot.MVA,y=st.MVA,v=at.MVA);const w=(t,n,i,r)=>{t?(n.style.color=dt.VALID_TEXT,n.style.borderBottomColor=dt.VALID_LINE,e.tooltip.bind(n,i)):(n.style.color=dt.INVALID,n.style.borderBottomColor=dt.INVALID,e.tooltip.bind(n,()=>{const t=e.label(i),n=e.label(r);return n.style.color=dt.INVALID,e.divV([t,n])}))},b=()=>{const t=(()=>{for(const t of c)if(t.name===u.name)return!1;return!0})();let e;if(t?(w(!0,f.input,at.PREDICT,""),w(!0,p.input,at.FEATURES,"")):(w(!1,f.input,at.PREDICT,rt.PREDICT),w(!1,p.input,at.FEATURES,rt.PREDICT)),h<1)w(!1,g.input,at.COMPONENTS,rt.COMPONENTS),e=!1;else if(e=(()=>{if(h<1)return!1;const t=c.length;return d?h<=(t+1)*t/2+t:h<=t})(),e)w(!0,g.input,at.COMPONENTS,""),t&&w(!0,p.input,at.FEATURES,"");else{const t=d?rt.COMP_QUA_PLS:rt.COMP_LIN_PLS;w(!1,g.input,at.COMPONENTS,t),w(!1,p.input,at.FEATURES,rt.ENOUGH)}const n=t&&e;return S.getButton(ot.RUN).disabled=!n,n};let C=s.length>0?s[0]:void 0;const _=e.input.column(ot.NAMES,{table:i,value:C,onValueChanged:t=>C=null!=t?t:void 0,filter:t=>t.type===r.COLUMN_TYPE.STRING});_.setTooltip(at.NAMES),_.root.hidden=0===s.length||n===it.COMPUTE_COMPONENTS;const A=e.input.bool(ot.QUADRATIC,{value:d,tooltipText:at.QUADRATIC,onValueChanged:t=>{d=t,b()}}),S=e.dialog({title:m,helpUrl:y}).add(e.form([f,p,g,A,_])).addButton(ot.RUN,()=>gt(this,void 0,void 0,function*(){S.close(),yield function(n,i){return gt(this,void 0,void 0,function*(){var o,a;const s=n.table;n.isQuadratic&&(n=function(t){if(!t.isQuadratic)return t;const e=t.features.toList(),n=e.length,i=t.table.rowCount,o=[];let a,s,l,c,u;for(let t=0;t<n;++t){a=e[t],s=a.getRawData();for(let h=t;h<n;++h){l=e[h],c=l.getRawData(),u=new Float32Array(i);for(let t=0;t<i;++t)u[t]=s[t]*c[t];const t=r.Column.fromFloat32Array(`${a.name} x ${l.name}`,u);t.stats.stdev>0&&o.push(t)}}const h=r.DataFrame.fromColumns(e.concat(o));return{table:h,features:h.columns,isQuadratic:!0,names:t.names,predict:t.predict,components:t.components}}(n));const l=yield vt(n),c=l.tScores,u=s.columns,h=n.features,d=h.names(),f=i===it.COMPUTE_COMPONENTS?ct.PREFIX:ot.XSCORE;if(c.forEach((t,e)=>{t.name=u.getUnusedName(`${f}${e+1}`),u.add(t)}),i===it.COMPUTE_COMPONENTS)return;const p=t.shell.tableView(s.name),g=r.DataFrame.fromColumns([r.Column.fromStrings(ot.FEATURE,d),l.regressionCoefficients]);g.name=`${s.name}(${ot.ANALYSIS})`,t.shell.addTable(g),l.xLoadings.forEach((t,e)=>{t.name=g.columns.getUnusedName(`${ot.XLOADING}${e+1}`),g.columns.add(t)});const m=function(t,e,n,i){const o=n.length,a=t.length,s=e.getRawData(),l=new Float32Array(o),c=i.getRawData();let u=n.stats.avg;for(let e=0;e<a;++e)u-=s[e]*t.byIndex(e).stats.avg;for(let t=0;t<o;++t)l[t]=u+c[t];return r.Column.fromFloat32Array("Debiased",l,o)}(h,l.regressionCoefficients,n.predict,l.prediction);m.name=u.getUnusedName(`${n.predict.name} ${ct.SUFFIX}`),u.add(m);const y=p.addViewer(r.Viewer.scatterPlot(s,{title:ot.MODEL,xColumnName:n.predict.name,yColumnName:m.name,showRegressionLine:!0,markerType:r.MARKER_TYPE.CIRCLE,showLabels:"Always",help:st.MODEL}));void 0!==n.names&&null!==n.names&&y.setOptions({labelColumnNames:[null===(o=n.names)||void 0===o?void 0:o.name]}),l.regressionCoefficients.name=ot.REGR_COEFS;const v=p.addViewer(r.Viewer.barChart(g,{table:g.name,title:ot.REGR_COEFS,splitColumnName:ot.FEATURE,valueColumnName:l.regressionCoefficients.name,valueAggrType:r.AGG.AVG,help:st.COEFFS,showValueSelector:!1,showStackSelector:!1}));l.xLoadings.forEach((t,e)=>t.name=`${ot.XLOADING}${e+1}`);const w=p.addViewer(r.Viewer.scatterPlot(g,{table:g.name,title:ot.LOADINGS,xColumnName:`${ot.XLOADING}1`,yColumnName:`${ot.XLOADING}${l.xLoadings.length>1?"2":"1"}`,markerType:r.MARKER_TYPE.CIRCLE,labelColumnNames:[ot.FEATURE],help:st.LOADINGS})),b=c.map(t=>t.name);l.uScores.forEach((t,e)=>{t.name=u.getUnusedName(`${ot.YSCORE}${e+1}`),u.add(t),b.push(t.name)});const C=r.Viewer.scatterPlot(s,{title:ot.SCORES,xColumnName:c[0].name,yColumnName:c.length>1?c[1].name:l.uScores[0].name,markerType:r.MARKER_TYPE.CIRCLE,help:st.SCORES,showViewerFormulaLines:!0,labelColumnNames:void 0!==n.names&&null!==n.names?[null===(a=n.names)||void 0===a?void 0:a.name]:void 0});p.addViewer(C),C.meta.formulaLines.addAll(yt(b));const _=l.yLoadings.getRawData(),A=l.xLoadings.map(t=>t.getRawData()),S=s.rowCount,E=d.length,x=n.components,M=new Float32Array(x),P=[],N=[];for(let t=0;t<E;++t)N.push(new Float32Array(x));M[0]=Math.pow(_[0],2)/S,P.push(`1 ${ct.COMP}`),N.forEach((t,e)=>{t[0]=Math.pow(A[0][e],2)/S});for(let t=1;t<x;++t)M[t]=M[t-1]+Math.pow(_[t],2)/S,N.forEach((e,n)=>e[t]=e[t-1]+Math.pow(A[t][n],2)/S),P.push(`${t+1} ${ct.COMPS}`);const T=r.DataFrame.fromColumns([r.Column.fromStrings(ot.COMPONENTS,P),r.Column.fromFloat32Array(n.predict.name,M)]);T.name=`${s.name}(${ot.EXPL_VAR})`,t.shell.addTable(T),N.forEach((t,e)=>T.columns.add(r.Column.fromFloat32Array(d[e],t)));const F=p.addViewer(r.Viewer.barChart(T,{table:T.name,title:ot.EXPL_VAR,splitColumnName:ot.COMPONENTS,valueColumnName:n.predict.name,valueAggrType:r.AGG.AVG,help:st.EXPL_VARS,showCategorySelector:!1,showStackSelector:!1}));i===it.DEMO&&(t.shell.windows.help.showHelp(e.markdown(pt)),function(t,n,i){if(t.length!==n.length)throw new Error("Non-equal size of viewer roots and descriptions");let r,o,a,s=0;const l=e.button("next",()=>{a.remove(),++s,d()},"Go to the next viewer"),c=e.button("prev",()=>{s-=1,a.remove(),d()},"Go to the previous viewer"),u=e.button("done",()=>a.remove(),"Go to the next step"),h=e.divH([c,l,u]);h.style.marginLeft="auto",h.style.marginRight="0px";const d=()=>{s<t.length&&(o=e.divV([e.markdown(n[s]),h]),a=e.hints.addHint(t[s],o,i[s]),u.hidden=s<t.length-1,l.hidden=s===t.length-1,c.hidden=s<1,r=a.querySelector("i"),r.onclick=()=>u.click())};d()}([y,C,w,v,F].map(t=>t.root),ft.map(t=>`<b>${t.caption}</b>\n\n${t.text}`),["left","left","right","right","left"]))})}({table:i,features:r.DataFrame.fromColumns(c).columns,predict:u,components:h,isQuadratic:d,names:C},n)}),void 0,v).show({x:200,y:200});setTimeout(()=>{p.value=a.filter(t=>t!==u),c=p.value},6),t.shell.v.append(S.root)})}Math.max;var bt,Ct=n(6572);!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"}(bt||(bt={}));const _t="copy";var At,St;!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"}(At||(At={})),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"}(St||(St={}));const Et=[r.COLUMN_TYPE.INT,r.COLUMN_TYPE.FLOAT,r.COLUMN_TYPE.STRING,r.COLUMN_TYPE.DATE_TIME,r.COLUMN_TYPE.QNUM];function xt(t){switch(t.type){case r.COLUMN_TYPE.INT:return r.INT_NULL;case r.COLUMN_TYPE.FLOAT:case r.COLUMN_TYPE.QNUM:case r.COLUMN_TYPE.DATE_TIME:return r.FLOAT_NULL;case r.COLUMN_TYPE.STRING:return t.max;default:throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}}var Mt,Pt,Nt,Tt;function Ft(t){const e=new Map;for(const n of t){if(!Et.includes(n.type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE);if(0===n.stats.missingValueCount)continue;const t=[],i=xt(n);n.getRawData().forEach((e,n)=>{e===i&&t.push(n)}),e.set(n.name,t)}return e}function It(t,e,n){for(const t of e)if(!n.has(t))return!1;for(const i of t){const t=n.get(i);if(void 0===t)throw new Error(bt.FAILS_TO_PREDICT_IMPUTATION_FAILS);for(const i of t){let t=!0;for(const r of e){const e=n.get(r);if(void 0===e)throw new Error(bt.FAILS_TO_PREDICT_IMPUTATION_FAILS);if(!e.includes(i)){t=!1;break}}if(t)return!0}}return!1}function Lt(t){if(t<=0||t>=1)throw new Error(Tt.INCORRECT_SIGNIFICANCE_LEVEL)}function Ot(t){const e=t.size;return e<=1?0:(t.sumOfSquares-Math.pow(t.sum,2)/e)/(e-1)}function Rt(t,e,n){Lt(n);const i=Ot(t),r=Ot(e);return 0===i||0===r?i===r:i/r<Ct.centralF.inv(1-n,t.size-1,e.size-1)}!function(t){t.ONE_HOT="One-hot",t.DIFFERENCE="Difference"}(Mt||(Mt={})),function(t){t.EUCLIDEAN="Euclidean",t.MANHATTAN="Manhattan"}(Pt||(Pt={})),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"}(Nt||(Nt={})),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"}(Tt||(Tt={}));class Dt{constructor(t,e,n){if(this.nullsCount=0,t.length!==e.length)throw new Error(Tt.NON_EQUAL_FACTORS_VALUES_SIZE);if(!(e.stats.stdev>0))throw new Error(Tt.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 i=1;i<e;++i)if(!Rt(n,{sum:this.sums[i],sumOfSquares:this.sumsOfSquares[i],size:this.subSampleSizes[i]},t))return!1;return!0}getOneWayAnova(){let t=0,e=0,n=0,i=this.catCount,r=i;for(let o=0;o<i;++o)0!==this.subSampleSizes[o]?(t+=this.sums[o],e+=this.sumsOfSquares[o],n+=Math.pow(this.sums[o],2)/this.subSampleSizes[o]):--r;if(i=r,1===i)throw new Error(Tt.SINGLE_FACTOR);const o=this.size-this.nullsCount;if(o===i)throw new Error(Tt.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(Tt.NO_FEATURE_VARIATION_WITHIN_GROUPS);const c=i-1,u=o-i,h=s/c,d=l/u,f=h/d;return{ssBn:s,ssWn:l,ssTot:a,dfBn:c,dfWn:u,dfTot:o-1,msBn:h,msWn:d,fStat:f,pValue:1-Ct.centralF.cdf(f,c,u)}}setStats(t,e,n){const i=e.type,o=e.length,a=xt(e);switch(i){case r.COLUMN_TYPE.INT:case r.COLUMN_TYPE.FLOAT:const i=n;this.catCount=i,this.size=o;const s=e.getRawData(),l=t.getRawData(),c=new Float64Array(i).fill(0),u=new Float64Array(i).fill(0),h=new Int32Array(i).fill(0);let d;if(t.type==r.COLUMN_TYPE.BOOL){let t=0,e=0,n=l[0];const i=8*l.BYTES_PER_ELEMENT-1;for(let r=0;r<o;++r)d=1&n>>e,s[r]!==a?(c[d]+=s[r],u[d]+=Math.pow(s[r],2),++h[d]):++this.nullsCount,++e,e>i&&(e=0,++t,n=l[t])}else{const e=t.stats.missingValueCount>0?xt(t):-1;for(let t=0;t<o;++t)d=l[t],d!==e&&s[t]!==a?(c[d]+=s[t],u[d]+=Math.pow(s[t],2),++h[d]):++this.nullsCount}this.sums=c,this.sumsOfSquares=u,this.subSampleSizes=h;break;default:throw new Error(Tt.UNSUPPORTED_COLUMN_TYPE)}}}const kt=[r.COLUMN_TYPE.INT,r.COLUMN_TYPE.FLOAT],Gt=[r.COLUMN_TYPE.STRING,r.COLUMN_TYPE.BOOL],Ut="/help/explore/anova";var Bt,Vt;function zt(){const n=t.shell.t;if(null===n)return void t.shell.warning("No dataframe is opened");const i=n.columns,o=[],a=[];for(const t of i)kt.includes(t.type)?a.push(t.name):Gt.includes(t.type)&&o.push(t.name);const s=o.length;if(s<1)return void t.shell.warning(e.markdown(`No acceptable factor columns:\n\n - type: ${Gt.join(", ")} \n - at least two categories`));let l=n.col(Vt.FACTOR);if(null===l){let t,e=0,n=i.byName(o[0]).categories.length;for(let r=1;r<s;++r)t=i.byName(o[r]).categories.length,t<n&&(n=t,e=r);l=i.byName(o[e])}if(a.length<1)return void t.shell.warning(e.markdown(`No acceptable feature columns:\n \n - type: ${kt.join(", ")}`));const c=e.input.column("Category",{table:n,value:l,tooltipText:"Column with factor values",onValueChanged:t=>l=t,filter:t=>o.includes(t.name),nullable:!1});let u=n.col(Vt.FEATURE);null===u&&(u=i.byName(a[0]));const h=e.input.column("Feature",{table:n,value:u,tooltipText:"Column with feature values",onValueChanged:t=>u=t,filter:t=>a.includes(t.name),nullable:!1});let d=Bt.DEFAULT;const f=e.input.float("Alpha",{min:Bt.MIN,max:Bt.MAX,value:d,nullable:!1,tooltipText:"Significance level",onValueChanged:t=>{d=t,m.disabled=d<=Bt.INFIMUM||d>=Bt.SUPREMUM}}),p=e.dialog({title:"ANOVA",helpUrl:Ut}),g=t.shell.getTableView(n.name);g.root.appendChild(p.root),p.addButton("Run",()=>{p.close();try{const i=function(t,e,n,i=!0){Lt(n);const r=t.stats.uniqueCount;if(r<2)throw new Error(Tt.SINGLE_FACTOR);const o=new Dt(t,e,r);if(i&&!o.areVarsEqual(n))throw new Error(Tt.NON_EQUAL_VARIANCES);const a=o.getOneWayAnova();return{anovaTable:a,fCritical:Ct.centralF.inv(1-n,a.dfBn,a.dfWn),significance:n}}(l,u,d);!function(n,i,o,a){const s=t.shell.getTableView(n.name);t.shell.v=s;const l=a.anovaTable.fStat>a.fCritical,c=l?`"${i}" affects the "${o}"`:`"${i}" doesn't affect the "${o}"`,u=r.Viewer.boxPlot(n,{categoryColumnNames:[i],valueColumnName:o,showPValue:!1,showStatistics:!1,description:c,showColorSelector:!1,autoLayout:!1});let h=s.dockManager.dock(u,r.DOCK_TYPE.RIGHT,null,"ANOVA");const d=e.markdown("**Null Hypothesis:** all group means are equal.");e.tooltip.bind(d,`The "${i}" factor does not produce a significant difference in the "${o}" feature.`);const f=e.markdown("**Alternative Hypothesis:** at least one group mean differs significantly.");e.tooltip.bind(f,`The "${i}" factor produces a significant difference in the "${o}" feature.`);const p=e.markdown("**Conclusion:** "+(l?"significant differences exist between groups.":"no significant differences detected.")),g=l?e.divV([e.p(`Reject the null hypothesis, since F > F-critical: \n ${a.anovaTable.fStat.toFixed(2)} > ${a.fCritical.toFixed(2)}.`),e.h2("There is a significant difference among sample averages.")]):e.divV([e.p(`Fail to reject the null hypothesis, since F < F-critical: \n ${a.anovaTable.fStat.toFixed(2)} < ${a.fCritical.toFixed(2)}.`),e.h2("There is no significant difference among sample averages.")]);e.tooltip.bind(p,()=>g);const m=e.divV([d,f,p,e.link("Learn more",()=>window.open("https://en.wikipedia.org/wiki/F-test","_blank"),"Click to open in a new tab.")]);m.style.marginLeft="20px";const y=function(t){const n=t.anovaTable,i=r.Viewer.grid(r.DataFrame.fromColumns([r.Column.fromStrings("Source of variance",["Between groups","Within groups","Total"]),r.Column.fromList(r.COLUMN_TYPE.FLOAT,"SS",[n.ssBn,n.ssWn,n.ssTot]),r.Column.fromList(r.COLUMN_TYPE.INT,"DF",[n.dfBn,n.dfWn,n.dfTot]),r.Column.fromList(r.COLUMN_TYPE.FLOAT,"MS",[n.msBn,n.msWn,null]),r.Column.fromList(r.COLUMN_TYPE.FLOAT,"F",[n.fStat,null,null]),r.Column.fromList(r.COLUMN_TYPE.FLOAT,"F-critical",[t.fCritical,null,null]),r.Column.fromList(r.COLUMN_TYPE.FLOAT,"p-value",[n.pValue,null,null])])),o=new Map([["Source of variance","List of the explored variation sources."],["SS","Sum of squares (SS). Measure of total variation in the data."],["DF","Degrees of freedom (DF). Number of independent values that can vary."],["MS","Mean square (MS). Sum of squares divided by degrees of freedom."],["F","F-statistics (F). Ratio of between-group to within-group variance."],["F-critical",`${t.significance}-critical value of F-statistics.`],["p-value","Probability of observing this result if groups have equal means."]]);return i.onCellTooltip(function(t,n,i){if(t.isColHeader)return e.tooltip.show(e.divV([e.p(o.get(t.tableColumn.name))]),n,i),!0}),i.helpUrl=Ut,i}(a),v=e.tabControl({Analysis:e.panel([y.root]),"F-test":e.panel([m])});e.tooltip.bind(v.getPane("Analysis").header,"ANOVA results summary."),e.tooltip.bind(v.getPane("F-test").header,"Null hypothesis testing."),s.dockManager.dock(v.root,r.DOCK_TYPE.DOWN,h,"",.25),y.root.style.width="100%"}(n,l.name,u.name,i)}catch(n){n instanceof Error?(t.shell.warning((i=n.message,e.divV([e.markdown(`ANOVA cannot be performed:\n \n ${i}`),e.link("Learn more",()=>window.open("https://en.wikipedia.org/wiki/Analysis_of_variance#Assumptions","_blank"),"Click to open in a new tab")]))),g.addViewer(r.VIEWER.BOX_PLOT,{categoryColumnNames:[l.name],valueColumnName:u.name,showStatistics:!1,showPValue:!1})):t.shell.error("ANOVA fails: the platform issue")}var i},void 0,"Perform analysis of variances");const m=p.getButton("Run");p.add(c).add(h).add(f).show()}!function(t){t[t.DEFAULT=.05]="DEFAULT",t[t.MIN=.01]="MIN",t[t.MAX=.99]="MAX",t[t.INFIMUM=0]="INFIMUM",t[t.SUPREMUM=1]="SUPREMUM"}(Bt||(Bt={})),function(t){t.FACTOR="race",t.FEATURE="age"}(Vt||(Vt={}));function Wt(t,e,i,r){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:r,epsilon:i}),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{r(l.next(t))}catch(t){e(t)}}function i(t){try{r(l.throw(t))}catch(t){e(t)}}function r(e){var r;e.done?t(e.value):(r=e.value,r instanceof s?r:new s(function(t){t(r)})).then(n,i)}r((l=l.apply(o,a||[])).next())});var o,a,s,l}n(5540);let Ht=null;function jt(){return t=this,e=void 0,i=function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!Ht&&(Ht=yield navigator.gpu.requestAdapter(),null==Ht))return null;let t=null;return"info"in Ht&&(t=Ht.info),t?Kt(t.description,Kt(t.vendor,"No GPU description available")):"No GPU description available"},new((n=void 0)||(n=Promise))(function(r,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((i=i.apply(t,e||[])).next())});var t,e,n,i}function Kt(t,e){return t&&""!=t?t:e}var Yt,qt,Xt,$t,Qt,Jt,Zt,te,ee;(qt=Yt||(Yt={})).EUCLIDEAN="EUCLIDEAN",qt.MANHATTAN="MANHATTAN",Yt.EUCLIDEAN,Yt.MANHATTAN,($t=Xt||(Xt={})).HAMMING="Hamming",$t.EUCLIDEAN="Euclidean",$t.VECTOR_COSINE="Vector Cosine",$t.MANHATTAN="Manhattan",$t.TANIMOTO="Tanimoto",$t.LEVENSTEIN="Levenshtein",$t.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",$t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",$t.SOKAL="Sokal",$t.COSINE="Cosine",$t.ASYMMETRIC="Asymmetric",$t.Difference="Difference",$t.OneHot="One-Hot",Xt.HAMMING,Xt.EUCLIDEAN,Xt.MANHATTAN,Xt.VECTOR_COSINE,Xt.TANIMOTO,Xt.LEVENSTEIN,Xt.NEEDLEMAN_WUNSCH,Xt.MONOMER_CHEMICAL_DISTANCE,Xt.SOKAL,Xt.COSINE,Xt.ASYMMETRIC,Xt.Difference,Xt.OneHot,Xt.HAMMING,Xt.EUCLIDEAN,Xt.MANHATTAN,Xt.TANIMOTO,Xt.SOKAL,Xt.COSINE,Xt.ASYMMETRIC,Xt.LEVENSTEIN,Xt.NEEDLEMAN_WUNSCH,Xt.MONOMER_CHEMICAL_DISTANCE,Xt.Difference,Xt.OneHot,Xt.VECTOR_COSINE,new Set([Xt.HAMMING,Xt.LEVENSTEIN,Xt.NEEDLEMAN_WUNSCH,Xt.MONOMER_CHEMICAL_DISTANCE,Xt.OneHot]),new Set([Xt.HAMMING,Xt.EUCLIDEAN,Xt.MANHATTAN,Xt.MONOMER_CHEMICAL_DISTANCE,Xt.LEVENSTEIN,Xt.NEEDLEMAN_WUNSCH,Xt.TANIMOTO,Xt.COSINE,Xt.VECTOR_COSINE,Xt.SOKAL,Xt.ASYMMETRIC,Xt.OneHot,Xt.Difference]),new Set([Xt.EUCLIDEAN,Xt.MANHATTAN,Xt.OneHot,Xt.Difference,Xt.VECTOR_COSINE]),new Set([Xt.EUCLIDEAN,Xt.MANHATTAN,Xt.Difference,Xt.VECTOR_COSINE]),new Set([Xt.EUCLIDEAN,Xt.MANHATTAN,Xt.Difference]),new Set([Xt.TANIMOTO,Xt.COSINE,Xt.SOKAL,Xt.ASYMMETRIC]),function(t){t.ADD="ADD",t.SUB="SUB",t.MULT="MULT"}(Qt||(Qt={})),function(t){t.SQUARE="SQUARE",t.INVERSE="INVERSE",t.TRANSPOSE="TRANSPOSE",t.NORM="NORM",t.COLUMN_NORM="COLUMN_NORM"}(Jt||(Jt={})),function(t){t.SCALARMULT="SCALARMULT",t.SCALARADD="SCALARADD",t.SCALARPOW="SCALARPOW"}(Zt||(Zt={})),Object.prototype.toString,(ee=te||(te={})).UMAP="UMAP",ee.T_SNE="t-SNE",Promise.resolve(),n(934),n(8903);const ne=2;r.SEMTYPE.MOLECULE,r.SEMTYPE.MACROMOLECULE;class ie{constructor(){this.epsilon={uiName:"Epsilon",value:.01,tooltip:"Minimum distance between cluster points",min:0,max:2,step:.005},this.minPts={uiName:"Minimum points",value:4,tooltip:"Minimum number of points in cluster",min:1,max:1e3,step:1}}}const re="bypassLargeDataWarning";var oe,ae;(ae=oe||(oe={})).EUCLIDEAN="EUCLIDEAN",ae.MANHATTAN="MANHATTAN";const se=rxjs;var le,ce,ue,he,de,fe,pe,ge,me=n(5072),ye=n.n(me),ve=n(7825),we=n.n(ve),be=n(7659),Ce=n.n(be),_e=n(5056),Ae=n.n(_e),Se=n(540),Ee=n.n(Se),xe=n(1113),Me=n.n(xe),Pe=n(7939),Ne={};Ne.styleTagTransform=Me(),Ne.setAttributes=Ae(),Ne.insert=Ce().bind(null,"head"),Ne.domAPI=we(),Ne.insertStyleElement=Ee(),ye()(Pe.A,Ne),Pe.A&&Pe.A.locals&&Pe.A.locals,function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan String",t.Onehot="One-Hot"}(le||(le={})),function(t){t.Euclidean="Euclidean",t.Manhattan="Manhattan",t.Cosine="Vector Cosine"}(ce||(ce={})),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"}(ue||(ue={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(he||(he={})),(ge=de||(de={})).Vector="Vector",ge.String="String",ge.BitArray="BitArray",ge.MacroMolecule="MacroMolecule",ge.Number="Number",ge.IntArray="IntArray",ge.NumberArray="NumberArray",function(t){t.Difference="Difference"}(fe||(fe={})),function(t){t.CommonItems="Common Items"}(pe||(pe={}));const Te=new Uint32Array(65536),Fe=(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,i=e.length,r=1<<n-1;let o=-1,a=0,s=n,l=n;for(;l--;)Te[t.charCodeAt(l)]|=1<<l;for(l=0;l<i;l++){let t=Te[e.charCodeAt(l)];const n=t|a;t|=(t&o)+o^o,a|=~(t|o),o&=t,a&r&&s++,o&r&&s--,a=a<<1|1,o=o<<1|~(n|a),a&=n}for(l=n;l--;)Te[t.charCodeAt(l)]=0;return s})(t,e):((t,e)=>{const n=e.length,i=t.length,r=[],o=[],a=Math.ceil(n/32),s=Math.ceil(i/32);for(let t=0;t<a;t++)o[t]=-1,r[t]=0;let l=0;for(;l<s-1;l++){let a=0,s=-1;const c=32*l,u=Math.min(32,i)+c;for(let e=c;e<u;e++)Te[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=Te[e.charCodeAt(t)],i=o[t/32|0]>>>t&1,l=r[t/32|0]>>>t&1,c=n|a,u=((n|l)&s)+s^s|n|l;let h=a|~(u|s),d=s&u;h>>>31^i&&(o[t/32|0]^=1<<t),d>>>31^l&&(r[t/32|0]^=1<<t),h=h<<1|i,d=d<<1|l,s=d|~(c|h),a=h&c}for(let e=c;e<u;e++)Te[t.charCodeAt(e)]=0}let c=0,u=-1;const h=32*l,d=Math.min(32,i-h)+h;for(let e=h;e<d;e++)Te[t.charCodeAt(e)]|=1<<e;let f=i;for(let t=0;t<n;t++){const n=Te[e.charCodeAt(t)],a=o[t/32|0]>>>t&1,s=r[t/32|0]>>>t&1,l=n|c,h=((n|s)&u)+u^u|n|s;let d=c|~(h|u),p=u&h;f+=d>>>i-1&1,f-=p>>>i-1&1,d>>>31^a&&(o[t/32|0]^=1<<t),p>>>31^s&&(r[t/32|0]^=1<<t),d=d<<1|a,p=p<<1|s,u=p|~(l|d),c=d&l}for(let e=h;e<d;e++)Te[t.charCodeAt(e)]=0;return f})(t,e)};var Ie=n(944);class Le{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,i=Le._createBuffer(n);if(e)for(let t=0;t<i.length;t++)i[t]=-1;this._data=i,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,i){if(t<e||t>n)throw new Error(`Argument ${i} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let i=0;i<n;i++)e[i]=t[i]}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 Le(t._length);n._length=t._length,n._data=Le._createBuffer(n._length),n._version=0;const i=t.lengthInInts;for(let r=0;r<i;r++)n._data[r]=t._data[r]&e._data[r];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new Le(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 Le(t);for(let i=0;i<t;++i)n.setBit(i,e(i));return n._version=0,n}static fromString(t){return Le.fromSeq(t.length,e=>"1"==t.charAt(e))}static fromUint32Array(t,e){const n=new Le(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new Le(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let i=0,r=0;for(;e-r>=4;)n._data[i++]=255&t[r]|(255&t[r+1])<<8|(255&t[r+2])<<16|(255&t[r+3])<<24,r+=4;return e-r==3&&(n._data[i]=(255&t[r+2])<<16),e-r==2&&(n._data[i]|=(255&t[r+1])<<8),e-r==1&&(n._data[i]|=255&t[r]),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 Le(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,i=this.lengthInInts;for(let t=0;t<i;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,i=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(i)}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,i=!0,r=!0){if(n&&r&&this.setAll(!e,!1),r)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(i)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return Le.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return n}setRange(t,e,n,i=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const r=Math.min(t,e),o=Math.max(t,e);if(n)for(let t=r;t<=o;t++)this.setTrue(t);else for(let t=r;t<=o;t++)this.setFalse(t);return this.incrementVersion(i),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 i=this._length;this.setLength(this._length+e);for(let n=i-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let i=t;i<t+e;i++)this.setBit(i,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 i=-1;-1!=(i=t.findNext(i,!e));)this.setFast(n++,this.getBit(i));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+=Le._onBitCount[255&t];let n=this._data[e];const i=31&this._length;for(0!=i&&(n&=~(4294967295<<i));0!=n;n>>>=8)this._selectedCount+=Le._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 i=this.lengthInInts;let r=0;for(;r<i-1;r++)for(let e=this._data[r]&t._data[r];0!=e;e>>>=8)n+=Le._onBitCount[255&e];let o=this._data[r]&t._data[r];const a=31&this._length;for(0!=a&&(o&=~(4294967295<<a));0!=o;o>>>=8)n+=Le._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 i=this.lengthInInts;for(let r=Math.floor(t/32);r<i;r++){let i=e?this._data[r]:~this._data[r];if(0!=n)i&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==i)continue;for(let e=0;0!=i;e+=8,i>>>=8){const n=Le._firstOnBit[255&i];if(n>=0)return(t=n+32*r+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 i=Math.floor(t/32);i>=0;i--){let t=e?this._data[i]:~this._data[i];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=Le._lastOnBit[t>>>24];if(n>=0)return n+32*i+e}}return-1}}function Oe(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,i=Math.min(...Object.keys(e).map(t=>t.charCodeAt(0)))+1,r=new Float32Array((n.length+i)*(n.length+i));return Object.entries(e).forEach(([t,i])=>{const o=n[i];Object.entries(e).forEach(([e,i])=>{r[t.charCodeAt(0)*n.length+e.charCodeAt(0)]=o[i]})}),(t,e)=>1-r[t.charCodeAt(0)*n.length+e.charCodeAt(0)]}(),n=t?.threshold??0;return(t,i)=>{let r=0;const o=t.length,a=i.length,s=Math.ceil(Math.max(o,a)*(1-n));o!==a&&(r=Math.abs(o-a));let l=0;for(let n=0;n<Math.min(o,a);n++)if(t[n]!==i[n]&&(l+=e(t[n],i[n]),l>s))return 1;return l+=r,l/=Math.max(o,a),l}}Le._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]),Le._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]),Le._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 Re={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 De;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(De||(De={}));const ke={[De.HAMMING]:Oe,[De.LEVENSHTEIN]:function(){return(t,e)=>Fe(t,e)/Math.max(t.length,e.length)},[De.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:i,scoringMatrix:r,alphabetIndexes:o}={...Re,...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,u=1;for(let e=1;e<t.length+1;e++)a[0][e]=-i-(e-1)*i,a[1][e]=0;a[0][0]=0;for(let h=1;h<o.length+1;h++){a[u][0]=-i-(h-1)*i;for(let d=1;d<t.length+1;d++){const f=a[c][d-1]+r[e[t.charCodeAt(d-1)]][e[o.charCodeAt(h-1)]],p=a[c][d]-(s[d]||1===h||h===o.length?i:n),g=a[u][d-1]-(l[d-1]||1===d||d===t.length?i:n);a[u][d]=Math.max(f,g,p),a[u][d]===f?(s[d]=!1,l[d]=!1):a[u][d]===g?(s[d]=!1,l[d]=!0):(s[d]=!0,l[d]=!1)}c=u,u=(u+1)%2}const h=Math.min(t.length,o.length);return(h-a[c][t.length])/h}},[De.MONOMER_CHEMICAL_DISTANCE]:Oe};function Ge(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const i=t.andWithCountBits(e,!0);return i/(n-i)}function Ue(t){return t<=0?3402823e32:1/t-1}ue.Tanimoto,ue.Dice,ue.Asymmetric,ue.BraunBlanquet,ue.Cosine,ue.Kulczynski,ue.McConnaughey,ue.RogotGoldberg,ue.Russel,ue.Sokal,ue.Hamming,ue.Euclidean,ue.Tanimoto,ue.Dice,ue.Asymmetric,ue.BraunBlanquet,ue.Cosine,ue.Kulczynski,ue.McConnaughey,ue.RogotGoldberg,ue.Russel,ue.Sokal,ue.Hamming,ue.Euclidean,ue.Tanimoto,ue.Dice,ue.Cosine,ue.Tanimoto,ue.Asymmetric,ue.Cosine,ue.Sokal,De.HAMMING,De.LEVENSHTEIN,De.MONOMER_CHEMICAL_DISTANCE,De.NEEDLEMANN_WUNSCH;const Be={[ce.Euclidean]:function(t,e){let n=0;for(let i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return Math.sqrt(n)},[ce.Manhattan]:function(t,e){let n=0;for(let i=0;i<t.length;i++)n+=Math.abs(t[i]-e[i]);return n},[ce.Cosine]:function(t,e){let n=0,i=0,r=0;for(let o=0;o<t.length;o++)n+=t[o]*e[o],i+=t[o]*t[o],r+=e[o]*e[o];return(1-n/(Math.sqrt(i)*Math.sqrt(r)))/2}},Ve={[le.Levenshtein]:Fe,[le.JaroWinkler]:Ie.Vb,[le.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let n=0;for(let i=1;i<t.length;i++)n+=t[i]==e[i]?0:1;return n/t.length}},[le.Onehot]:function(t,e){return t===e?0:1}},ze={[ue.Tanimoto]:function(t,e){return 1-Ge(t,e)},[ue.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)},[ue.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)},[ue.BraunBlanquet]:function(t,e){return Ue(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[ue.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)},[ue.Kulczynski]:function(t,e){return Ue(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:t.andWithCountBits(e,!0)*n/(2*i)}(t,e))},[ue.McConnaughey]:function(t,e){return Ue(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:(t.andWithCountBits(e,!0)*n-i)/i}(t,e))},[ue.RogotGoldberg]:function(t,e){return Ue(function(t,e){const n=t.andWithCountBits(e,!0),i=t.countBits(!0)+e.countBits(!0),r=t.length,o=r-i+n;return n==r||o==r?1:n/i+o/(2*r-i)}(t,e))},[ue.Russel]:function(t,e){return Ue(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))},[ue.Sokal]:function(t,e){return 1-function(t,e){const n=t.trueCount()+e.trueCount(),i=t.andWithCountBits(e,!0);return i/(2*n-3*i)}(t,e)},[ue.Hamming]:function(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)},[ue.Euclidean]:function(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}},We={[he.TanimotoIntArray]:function(t,e){return Ue(Ge(new Le(t,32*t.length),new Le(e,32*e.length)))}},He={[fe.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)}},je={[pe.CommonItems]:function(t){const e=function(t){const e=t?.mostCommon??new Set;return(t,n)=>{const i=t.length,r=n.length;let o=0,a=0,s=0;for(;a<i&&s<r;)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)}},Ke={[de.Vector]:{[ce.Euclidean]:Be[ce.Euclidean],[ce.Manhattan]:Be[ce.Manhattan],[ce.Cosine]:Be[ce.Cosine]},[de.String]:{[le.Levenshtein]:Ve[le.Levenshtein],[le.JaroWinkler]:Ve[le.JaroWinkler],[le.Manhattan]:Ve[le.Manhattan],[le.Onehot]:Ve[le.Onehot]},[de.BitArray]:{[ue.Tanimoto]:ze[ue.Tanimoto],[ue.Dice]:ze[ue.Dice],[ue.Asymmetric]:ze[ue.Asymmetric],[ue.BraunBlanquet]:ze[ue.BraunBlanquet],[ue.Cosine]:ze[ue.Cosine],[ue.Kulczynski]:ze[ue.Kulczynski],[ue.McConnaughey]:ze[ue.McConnaughey],[ue.RogotGoldberg]:ze[ue.RogotGoldberg],[ue.Russel]:ze[ue.Russel],[ue.Sokal]:ze[ue.Sokal]},[de.MacroMolecule]:{[De.HAMMING]:ke[De.HAMMING],[De.LEVENSHTEIN]:ke[De.LEVENSHTEIN],[De.NEEDLEMANN_WUNSCH]:ke[De.NEEDLEMANN_WUNSCH],[De.MONOMER_CHEMICAL_DISTANCE]:ke[De.MONOMER_CHEMICAL_DISTANCE]},[de.Number]:{[fe.Difference]:He[fe.Difference]},[de.IntArray]:{[he.TanimotoIntArray]:We[he.TanimotoIntArray]},[de.NumberArray]:{[pe.CommonItems]:je[pe.CommonItems]}};Object.keys(Ke).reduce((t,e)=>{for(const n of Object.keys(Ke[e]))t[n]=e;return t},{});class Ye{constructor(){this.learningRate={uiName:"Learninig Rate",value:1,tooltip:"The initial learning rate for the embedding optimization"},this.nEpochs={uiName:"Epochs",value:0,tooltip:"The number of epochs to optimize embeddings via SGD. Computed automatically if set to 0"},this.nNeighbors={uiName:"Neighbors",value:15,tooltip:"The number of nearest neighbors to construct the fuzzy manifold"},this.spread={uiName:"Spread",value:1,tooltip:"The effective scale of embedded points, used with min distance to control \n the clumped/dispersed nature of the embedding"},this.minDist={uiName:"Min Distance",value:.1,tooltip:"The effective minimum distance between embedded points, \n used with spread to control the clumped/dispersed nature of the embedding"},this.randomSeed={uiName:"Random Seed",value:null,tooltip:"Random seed",type:"string"},this.useWebGPU={uiName:"Use WebGPU",value:!1,tooltip:"Use WebGPU for Distance and UMAP computations",type:"boolean",disableTooltip:"WebGPU is not available"},jt().then(t=>{t?(this.useWebGPU.tooltip+=` (${t})`,this.useWebGPU.value=!0):(this.useWebGPU.value=!1,this.useWebGPU.disable=!0)})}}class qe{constructor(){this.epsilon={uiName:"Epsilon",value:10,tooltip:"Epsilon is learning rate"},this.perplexity={uiName:"Perplexity",value:30,tooltip:"Roughly how many neighbors each point influences"}}}class Xe{constructor(n={}){this.editorSettings={},this.columnOptEditors=[],this.columnOptEditorsRoot=e.div(),this.columnParamsEditorRoot=e.div(),this.columnFunctionsMap={},this.methodsParams={[te.UMAP]:new Ye,[te.T_SNE]:new qe},this.dbScanParams=new ie,this.methodSettingsDivs=[],this.supportedFunctions={},this.methodSettingsAnchor=e.div(),this.plotEmbeddingsInput=e.input.bool("Plot Embeddings",{value:!0}),this.aggregationMethodInput=e.input.choice("Aggregation",{value:oe.EUCLIDEAN,items:[oe.EUCLIDEAN,oe.MANHATTAN]}),this.vectorDistanceInput=e.input.choice("Distance metric",{value:ce.Euclidean,items:[ce.Euclidean,ce.Manhattan,ce.Cosine]}),this.aggregationMethodInput.setTooltip("Aggregation method for combining distances between columns"),this.vectorDistanceInput.root.style.display="none",this.onColumnsChanged=new se.Subject,this.editorSettings=n,this.columnParamsEditorAccordion=e.accordion(),r.Func.find({tags:["dim-red-preprocessing-function"]}).forEach(t=>{const e=t.options.get("supportedSemTypes")??"",n=t.friendlyName??t.name,i=t.options.get("supportedTypes")??"",r=t.options.get("supportedUnits")??"",o=t.options.get("supportedDistanceFunctions")??"";this.editorSettings.semtype&&!e.includes(this.editorSettings.semtype)||this.editorSettings.type&&!i.includes(this.editorSettings.type)||this.editorSettings.units&&!r.includes(this.editorSettings.units)||(this.supportedFunctions[n]={func:t,semTypes:e?e.split(","):[],types:i?i.split(","):[],units:r?r.split(","):[],distanceFunctions:o?o.split(","):[]})}),this.postProcessingEditor=new Je,this.tableInput=e.input.table("Table",{value:t.shell.tv.dataFrame,items:t.shell.tables,onValueChanged:()=>{this.onTableInputChanged()}}),this.onTableInputChanged();let i=!1;this.methodInput=e.input.choice("Method",{value:te.UMAP,items:[te.UMAP,te.T_SNE],onValueChanged:t=>{i&&this.createAlgorithmSettingsDiv(this.methodsParams[t])}}),this.methodSettingsIcon=e.icons.settings(()=>{i=!i,i?this.createAlgorithmSettingsDiv(this.methodsParams[this.methodInput.value]):(this.methodSettingsDivs.forEach(t=>t.remove()),this.methodSettingsDivs=[])},"Modify methods parameters"),this.methodInput.root.classList.add("ml-dim-reduction-settings-input"),this.methodInput.root.prepend(this.methodSettingsIcon),this.columnParamsEditorAccordion.addPane("Column options",()=>this.columnOptEditorsRoot,!0,null,!1),this.columnParamsEditorAccordion.root.style.display="none",this.columnParamsEditorRoot.appendChild(this.columnParamsEditorAccordion.root),this.columnParamsEditorRoot.appendChild(this.vectorDistanceInput.root)}onTableInputChanged(){const t=this.tableInput.value;if(!t)return;e.empty(this.columnOptEditorsRoot),this.columnFunctionsMap={},t.columns.toList().forEach(t=>{Object.keys(this.supportedFunctions).forEach(e=>{const n=this.supportedFunctions[e].semTypes,i=this.supportedFunctions[e].types,r=this.supportedFunctions[e].units,o=!n.length||t.semType&&n.includes(t.semType),a=!i.length||i.includes(t.type),s=!r.length||t.meta.units&&r.includes(t.meta.units);o&&a&&s&&(this.columnFunctionsMap[t.name]||(this.columnFunctionsMap[t.name]=[]),this.columnFunctionsMap[t.name].push(e))})});const n=Object.keys(this.columnFunctionsMap),i=e.input.columns("Columns",{table:t,onValueChanged:t=>{if(this.onColumnsChanged.next(),e.empty(this.columnOptEditorsRoot),this.aggregationMethodInput.root.style.display=!t||t?.length<2?"none":"flex",!t||0===t.length)return void(this.columnParamsEditorAccordion.root.style.display="none");this.columnOptEditors=t.map(t=>new $e(t,this.columnFunctionsMap[t.name].map(t=>this.supportedFunctions[t])));const n=e.divV([],{style:{maxHeight:"400px",overflow:"auto"}});this.columnOptEditors.forEach(t=>{n.appendChild(t.accordionDiv)});const i=new Array(2*this.columnOptEditors.length).fill(null).map((t,e)=>e%2==0?this.columnOptEditors[e/2].colOptEditors:[]);let r=0;const o=e.table(i,t=>(r++,t&&t.length>0?t:[this.columnOptEditors[Math.floor((r-1)/2)].preprocessingFuncSettingsDiv=e.div([]),e.div(),e.div(),e.div()]),["Column","Encoding function","Similarity metric","Weight"]);this.columnOptEditors.forEach(t=>{t.preprocessingFuncSettingsDiv?.parentElement?.setAttribute("colspan","4"),t.preprocessingFuncSettingsDiv?.parentElement?.parentElement?.style?.setProperty("height","unset")}),this.columnOptEditors.length>0&&(this.columnParamsEditorAccordion.root.style.display="flex"),o.classList.add("ml-dim-reduction-column-editor-table-root"),this.columnOptEditorsRoot.appendChild(o),t.every(t=>t.isNumerical)?(this.aggregationMethodInput.root.style.display="none",this.columnParamsEditorAccordion.root.style.display="none",this.vectorDistanceInput.root.style.display="flex"):this.vectorDistanceInput.root.style.display="none"},available:n});i.fireChanged(),this.columnsInputRoot?(e.empty(this.columnsInputRoot),this.columnsInput=i,Array.from(this.columnsInput.root.children).forEach(t=>this.columnsInputRoot.appendChild(t))):(this.columnsInputRoot=i.root,this.columnsInput=i)}createAlgorithmSettingsDiv(t){this.methodSettingsDivs.forEach(t=>t.remove()),this.methodSettingsDivs=[];const n=this.methodSettingsAnchor,i=n.parentElement;i&&Object.keys(t).forEach(r=>{const o=t[r],a="string"===o.type?e.input.string(o.uiName,{value:o.value??"",onValueChanged:t=>{o.value=t}}):"boolean"===o.type?e.input.bool(o.uiName,{value:o.value??!1,onValueChanged:t=>{o.value=t}}):e.input.float(o.uiName,{value:o.value,onValueChanged:t=>{o.value=t}});o.disable?(a.enabled=!1,e.tooltip.bind(a.input??a.root,o.disableTooltip??"")):e.tooltip.bind(a.input??a.root,o.tooltip),i.insertBefore(a.root,n),this.methodSettingsDivs.push(a.root)})}get algorithmOptions(){const t=this.methodsParams[this.methodInput.value],e={};return Object.keys(t).forEach(n=>{null!=t[n].value&&(e[n]=t[n].value)}),e}get dbScanOptions(){return{dbScanEpsilon:this.dbScanParams.epsilon.value??.01,dbScanMinPts:this.dbScanParams.minPts.value??4}}getEditor(){return e.div([this.tableInput.root,this.columnsInputRoot,this.columnParamsEditorRoot,this.aggregationMethodInput.root,this.methodInput.root,this.methodSettingsAnchor,this.plotEmbeddingsInput,this.postProcessingEditor.root],{style:{minWidth:"420px"},classes:"dim-reduction-dialog-form"})}getParams(){return{table:this.tableInput.value,columns:this.columnsInput.value,methodName:this.methodInput.value,preprocessingFunctions:this.columnOptEditors.map(t=>t.preProcessingFunction),distanceMetrics:this.columnOptEditors.map(t=>t.similarityMetricInput.value),weights:this.columnOptEditors.map(t=>t.weight??1),options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.columnOptEditors.map(t=>t.preprocessingFunctionSettings)},plotEmbeddings:this.plotEmbeddingsInput.value,clusterEmbeddings:!1,postProcessingFunction:this.postProcessingEditor.postProcessingFunction,postProcessingFunctionArgs:this.postProcessingEditor.args,aggreaggregationMethod:this.aggregationMethodInput.value,vectorDistanceMetric:this.vectorDistanceInput.value}}getInput(){return{columns:this.columnsInput.value.map(t=>t.name),method:this.methodInput.value,preprocessingFunctions:this.columnOptEditors.map(t=>t.preprocessingFunctionInput.value),distanceMetrics:this.columnOptEditors.map(t=>t.similarityMetricInput.value),weights:this.columnOptEditors.map(t=>t.weight??1),options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.columnOptEditors.map(t=>t.preprocessingFunctionSettings)},plotEmbeddings:this.plotEmbeddingsInput.value,postProcessingFunction:this.postProcessingEditor.postProcessingFunctionInput.value??null,postProcessingFunctionArgs:this.postProcessingEditor.args,aggreaggregationMethod:this.aggregationMethodInput.value,vectorDistanceMetric:this.vectorDistanceInput.value}}getStringInput(){return JSON.stringify(this.getInput())}async applyStringInput(e){try{const t=JSON.parse(e);await this.applyInput(t)}catch(e){t.shell.error("Error applying input from history"),console.error(e)}}async applyInput(e){try{const t=e.columns.map(t=>this.tableInput.value.col(t));if(t.some(t=>!t))throw new Error("Some columns are not found");this.columnsInput.value=t,this.columnsInput.fireChanged(),this.methodInput.value=e.method,this.columnOptEditors.forEach((t,n)=>{t.preprocessingFunctionInput.value=e.preprocessingFunctions[n],t.similarityMetricInput.value=e.distanceMetrics[n],t.weightInput.value=e.weights[n],t.preprocessingFunctionSettings=e.options.preprocessingFuncArgs[n]}),this.plotEmbeddingsInput.value=e.plotEmbeddings,this.postProcessingEditor.postProcessingFunctionInput.value=e.postProcessingFunction,await this.postProcessingEditor._prevChangePromise,this.postProcessingEditor._postProcessingArgs=e.postProcessingFunctionArgs,this.aggregationMethodInput.value=e.aggreaggregationMethod;const n={};Object.keys(this.methodsParams[e.method]).forEach(t=>{n[t]=e.options[t]}),Object.keys(this.methodsParams[e.method]).forEach(t=>{this.methodsParams[e.method][t].value=n[t]});const i=this.methodSettingsDivs.length>0;this.createAlgorithmSettingsDiv(this.methodsParams[e.method]),i||(this.methodSettingsDivs.forEach(t=>t.remove()),this.methodSettingsDivs=[]),await this.postProcessingEditor.onFunctionChanged(e.postProcessingFunctionArgs),this.vectorDistanceInput.value=e.vectorDistanceMetric}catch(e){t.shell.error("Error applying input from history"),console.error(e)}}}class $e{constructor(t,n){this.preprocessingFuncSettingsDiv=e.div([]),this.preprocessingFunctionSettings={},this.editorDiv=e.div([]),this.hasExtraSettings=!0,this.functionsMap={},this.needsConfiguration=!1,this.weight=1,this.colOptEditors=[],this.weightInput=e.input.float("Weight",{value:1,onValueChanged:t=>{this.weight=t??1}}),this.column=t,this.supportedFunctions=n.sort((t,e)=>0!==t.units.length&&0!==e.units.length||t.units.length===e.units.length?t.units.length!==e.units.length?t.units.length-e.units.length:0===t.semTypes.length||0===e.semTypes.length?e.semTypes.length-t.semTypes.length:t.semTypes.length!==e.semTypes.length?t.semTypes.length-e.semTypes.length:t.types.length-e.types.length:e.units.length-t.units.length),this.supportedFunctions.forEach(t=>{this.functionsMap[Qe(t.func)]=t.func}),this.preprocessingFunctionInput=e.input.choice("Encoding function",{value:Qe(this.supportedFunctions[0].func),items:this.supportedFunctions.map(t=>Qe(t.func)),onValueChanged:t=>{const n=this.functionsMap[t];this.preprocessingFunctionSettings={},this.hasExtraSettings=n.inputs.length>2;const r=this.supportedFunctions.find(e=>Qe(e.func)===t);this.getSimilarityMetricInput(r),e.empty(this.preprocessingFuncSettingsDiv),i=!1,this.hasExtraSettings?this.preprocessingFuncSettingsIcon.style.display="flex":this.preprocessingFuncSettingsIcon.style.display="none"}}),this.preprocessingFunctionInput.root.style.display="flex",this.createSettingsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[0].func).then(()=>{e.empty(this.preprocessingFuncSettingsDiv)}),this.getSimilarityMetricInput(this.supportedFunctions[0]),this.hasExtraSettings=this.supportedFunctions[0].func.inputs.length>2;let i=!1;this.preprocessingFuncSettingsIcon=e.icons.settings(async()=>{i=!i,i?await this.createSettingsDiv(this.preprocessingFuncSettingsDiv,this.functionsMap[this.preprocessingFunctionInput.value]):e.empty(this.preprocessingFuncSettingsDiv)},"Modify encoding function parameters"),this.preprocessingFunctionInput.root.classList.add("ml-dim-reduction-settings-input"),this.preprocessingFunctionInput.root.prepend(this.preprocessingFuncSettingsIcon),this.hasExtraSettings?this.preprocessingFuncSettingsIcon.style.display="flex":this.preprocessingFuncSettingsIcon.style.display="none",this.needsConfiguration=!(n.length<2&&!this.hasExtraSettings&&n[0].distanceFunctions.length<2);const r=e.h3(this.column.name,{classes:"ml-dim-reduction-column-editor-column-title"});this.colOptEditors=[r,this.preprocessingFunctionInput.root,this.similarityMetricInputRoot,this.weightInput.root],e.tooltip.bind(r,this.column.name),this.colOptEditors.forEach(t=>t.classList.add("ml-dim-reduction-column-editor-input-root"));const o=e.divH(this.colOptEditors,{classes:"ml-dim-reduction-column-editor-root"});this.accordionDiv=e.divV([]),this.editorDiv.appendChild(o),this.editorDiv.appendChild(this.preprocessingFuncSettingsDiv),this.accordionDiv.appendChild(this.editorDiv)}getSimilarityMetricInput(t){const n=e.input.choice("Similarity metric",{value:t.distanceFunctions[0],items:t.distanceFunctions});this.similarityMetricInputRoot?(e.empty(this.similarityMetricInputRoot),this.similarityMetricInput=n,Array.from(this.similarityMetricInput.root.children).forEach(t=>this.similarityMetricInputRoot.appendChild(t))):(this.similarityMetricInputRoot=n.root,this.similarityMetricInput=n)}get preProcessingFunction(){return this.functionsMap[this.preprocessingFunctionInput.value]}async createSettingsDiv(t,n){if(e.empty(t),n.inputs.length<3)return e.div();const i=n.prepare(),r=await i.buildEditor(e.div());for(let e=2;e<n.inputs.length;e++){const o=n.inputs[e],a=this.preprocessingFunctionSettings[o.name]||i.inputParams[n.inputs[e].name].value||o.defaultValue;a&&(this.preprocessingFunctionSettings[o.name]=a);const s=r.find(t=>t.property.name===o.name);s&&(null!==this.preprocessingFunctionSettings[o.name]&&void 0!==this.preprocessingFunctionSettings[o.name]&&(s.value=this.preprocessingFunctionSettings[o.name]),s.onChanged.subscribe(t=>{this.preprocessingFunctionSettings[o.name]=t}),t.append(s.root))}return t.style.marginBottom="10px",t}}function Qe(t){return t.friendlyName??t.name}class Je{constructor(){this.postProcessingFunctionsMap={},this._root=e.div([]),this._postProcessingArgs={},this._argsElement=e.div([]),this._settingsOpened=!1,this._prevChangePromise=Promise.resolve(),this._settingsIcon=e.icons.settings(async()=>{this._settingsOpened=!this._settingsOpened,this._settingsOpened?this._argsElement.style.display="block":this._argsElement.style.display="none"}),this._argsElement.style.display="none",r.Func.find({tags:["dim-red-postprocessing-function"]}).filter(t=>t.inputs.length>=2).forEach(t=>{const e=t.friendlyName??t.name;this.postProcessingFunctionsMap[e]=t}),this.postProcessingFunctionsMap.None=null;const t=Object.keys(this.postProcessingFunctionsMap).find(t=>!!this.postProcessingFunctionsMap[t]?.options?.defaultPostProcessingFunction)??"None";this.postProcessingFunctionInput=e.input.choice("Postprocessing",{value:t,items:Object.keys(this.postProcessingFunctionsMap),onValueChanged:async()=>{await this.onFunctionChanged()},nullable:!1}),this.onFunctionChanged(),this.postProcessingFunctionInput.nullable=!1,this.postProcessingFunctionInput.classList.add("ml-dim-reduction-settings-input"),this.postProcessingFunctionInput.root.prepend(this._settingsIcon),this._root.appendChild(this.postProcessingFunctionInput.root),this._root.appendChild(this._argsElement)}get postProcessingFunction(){return this.postProcessingFunctionInput.value?this.postProcessingFunctionsMap[this.postProcessingFunctionInput.value]:null}async onFunctionChanged(n={}){let i;await this._prevChangePromise,this._prevChangePromise=new Promise(t=>i=t);try{const t=this.postProcessingFunction;if(e.empty(this._argsElement),this._postProcessingArgs={},!t||t.inputs.length<3)return void(this._settingsIcon.style.display="none");this._settingsIcon.style.display="flex";const i=t.prepare(n),r=await i.buildEditor(e.div());for(let e=2;e<t.inputs.length;e++){const n=t.inputs[e],o=this._postProcessingArgs[n.name]||i.inputParams[t.inputs[e].name].value||n.defaultValue;o&&(this._postProcessingArgs[n.name]=o);const a=r.find(t=>t.property.name===n.name);a&&(a.onChanged.subscribe(t=>{this._postProcessingArgs[n.name]=t}),this._argsElement.append(a.root))}}catch(e){t.shell.error("Error applying postprocessing function"),console.error(e)}finally{i()}}get root(){return this._root}get args(){return this._postProcessingArgs}}const Ze="dimensionality-reducer-terminate-event",tn=t=>null==t;function en(t,e){return`${e} (${t.length>4?`${t.length} columns`:t.map(t=>t.name).join(", ")})`}function nn(n){return i=this,o=void 0,s=function*(){if(null!=n||(n=t.shell.t),null===n)return void t.shell.warning(bt.NO_DATAFRAME);const i=[],o=[],a=[];n.columns.toList().filter(t=>Et.includes(t.type)).forEach(t=>{const e=t.stats.missingValueCount;e!==t.length&&(a.push(t.name),e>0&&(i.push(t),o.push(t.name)))});const s=Ft(i);if(0===i.length)return void t.shell.info(bt.NO_MISSING_VALUES);if(1===a.length)return void t.shell.error(bt.ONE_AVAILABLE_FEATURE);let l=Nt.IN_PLACE>0;const c=e.input.bool(At.IN_PLACE,{value:l,onValueChanged:t=>{l=null!=t&&t}});c.setTooltip(St.IN_PLACE);let u=Nt.KEEP_EMPTY>0;const h=e.input.bool(At.KEEP_EMPTY,{value:u,onValueChanged:t=>{u=null!=t&&t}});h.setTooltip(St.KEEP_EMPTY);let d=Nt.NEIGHBORS;const f=e.input.int(At.NEIGHBORS,{value:d,showPlusMinus:!0,min:1,nullable:!1,onValueChanged:t=>{null!==t&&t>=1&&(d=t),C()}});f.setTooltip(St.NEIGHBORS);let p=Pt.EUCLIDEAN;const g=e.input.choice(At.DISTANCE,{value:p,items:[Pt.EUCLIDEAN,Pt.MANHATTAN],onValueChanged:t=>p=null!=t?t:Pt.EUCLIDEAN});g.setTooltip(St.DISTANCE);let m=i.map(t=>t.name);const y=e.input.columns(At.COLUMNS,{table:n,value:n.columns.byNames(o),onValueChanged:t=>{m=t.map(t=>t.name),C()},available:o});y.setTooltip(St.TARGET);let v=a;const w=e.input.columns(At.FEATURES,{value:n.columns.byNames(a),table:n,onValueChanged:t=>{v=t.map(t=>t.name),v.length>0?(C(),A.forEach((t,e)=>t.hidden=!v.includes(e))):b()},available:a});w.setTooltip(St.FEATURES);const b=()=>{E.getButton(At.RUN).disabled=!0,c.root.hidden=!0,h.root.hidden=!0,f.root.hidden=!0,M.hidden=!0,S.hidden=!0},C=()=>{E.getButton(At.RUN).disabled=null===f.value||f.value<1,M.hidden=!1,c.root.hidden=!1,f.root.hidden=!1,g.root.hidden=!1,h.root.hidden=!It(m,v,s),1===v.length&&m.forEach(e=>{v[0]===e&&(b(),t.shell.warning(`${bt.ONE_FEATURE_SELECTED} the column '${e}'`))}),m.length<1&&b()},_=new Map,A=new Map,S=e.divV([]);S.style.overflow="auto",a.forEach(t=>{const i=function(t){switch(t){case r.COLUMN_TYPE.STRING:case r.COLUMN_TYPE.DATE_TIME:return{defaultWeight:Nt.WEIGHT,defaultMetric:Mt.ONE_HOT,availableMetrics:[Mt.ONE_HOT]};case r.COLUMN_TYPE.INT:case r.COLUMN_TYPE.FLOAT:case r.COLUMN_TYPE.QNUM:return{defaultWeight:Nt.WEIGHT,defaultMetric:Mt.DIFFERENCE,availableMetrics:[Mt.DIFFERENCE,Mt.ONE_HOT]};default:throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}}(n.col(t).type);_.set(t,{weight:i.defaultWeight,type:i.defaultMetric});const o=e.input.choice(t,{value:i.defaultMetric,items:i.availableMetrics,onValueChanged:e=>{var n;const r=null!==(n=_.get(t))&&void 0!==n?n:{weight:i.defaultWeight,type:i.defaultMetric};r.type=null!=e?e:i.defaultMetric,_.set(t,r)}});o.root.style.width="50%",o.setTooltip(St.METRIC),o.root.hidden=!0;const a=r.Property.fromOptions({name:t.length<15?t:t.slice(0,15).concat("..."),inputType:"Float",min:0,max:10,showSlider:!0,step:1}),s=e.input.forProperty(a);s.value=i.defaultWeight,s.onChanged.subscribe(e=>{var n;const r=null!==(n=_.get(t))&&void 0!==n?n:{weight:i.defaultWeight,type:i.defaultMetric};r.weight=null!=e?e:i.defaultWeight,_.set(t,r)}),e.tooltip.bind(s.captionLabel,t),e.tooltip.bind(s.input,St.WEIGHT),A.set(t,s.root),S.append(s.root)});const E=e.dialog({title:At.KNN_IMPUTER,helpUrl:"/help/explore/missing-values-imputation#the-k-nn-method"});t.shell.v.root.appendChild(E.root),S.hidden=!0,h.root.hidden=!It(m,v,s);const x=e.icons.settings(()=>{S.hidden=!S.hidden},St.METRIC_SETTINGS),M=e.divH([g.root,x]);let P,N,T=!1;const F=new Promise((t,e)=>{P=t,N=e});return E.addButton(At.RUN,()=>{T=!0,E.close(),a.filter(t=>!v.includes(t)).forEach(t=>_.delete(t));try{const e=function(e,n,i,o,a,s,l){if(s<1)throw new Error(bt.INCORRECT_NEIGHBORS);if(e.rowCount<2)throw new Error(bt.KNN_NOT_ENOUGH_OF_ROWS);if(0===n.length)throw new Error(bt.KNN_NO_TARGET_COLUMNS);if(0===i.size)throw new Error(bt.KNN_NO_FEATURE_COLUMNS);1===i.size&&n.forEach(t=>{if(i.has(t))throw new Error(`${bt.KNN_NO_FEATURE_COLUMNS} can be used for the column '${t}'`)}),n.forEach(t=>{if(!o.has(t))throw new Error(`${bt.KNN_FAILS}: ${bt.WRONG_PREDICTIONS}`)});const c=e.columns;n.forEach(t=>{if(!Et.includes(c.byName(t).type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}),i.forEach((t,n)=>{if(!Et.includes(e.getCol(n).type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)});const u=new Map;return n.forEach(n=>{const h=c.byName(n),d=xt(h),f=h.length,p=h.getRawData(),g=new Uint16Array(h.categories.length),m=[],y=[],v=[],w=[];i.forEach((t,e)=>{if(e!==h.name){const n=c.byName(e);switch(m.push(n.getRawData()),y.push(xt(n)),t.type){case Mt.DIFFERENCE:v.push((e,n)=>t.weight*Math.abs(e-n));break;case Mt.ONE_HOT:v.push((e,n)=>t.weight*(e===n?0:1))}}});const b=m.length,C=new Uint32Array(m.length),_=new Float32Array(m.length);let A=0;const S=new Array(s);let E=0,x=0,M=0,P=0,N=0;const T=(t,e)=>{C.forEach((n,i)=>{_[i]=v[n](m[n][t],m[n][e])})},F=a===Pt.EUCLIDEAN?()=>{let t=0;for(let e=0;e<A;++e)t+=_[e]*_[e];return Math.sqrt(t)}:()=>{let t=0;for(let e=0;e<A;++e)t+=Math.abs(_[e]);return Math.sqrt(t)},I=t=>{if(p[t]===d)return!1;for(let e=0;e<A;++e)if(m[C[e]][t]===y[C[e]])return!1;return!0},L=t=>{if((t=>{A=0;for(let e=0;e<b;++e)m[e][t]!==y[e]&&(C[A]=e,++A)})(t),0===A)throw new Error(`${bt.KNN_IMPOSSIBLE_IMPUTATION}: the column "${h.name}", row ${t+1}`);E=0;for(let e=0;e<f;++e)if(I(e)&&e!==t){T(t,e);const n=F();if(E<s)S[E]={index:e,dist:n},++E;else{x=0,M=S[0].dist;for(let t=1;t<E;++t)M<S[t].dist&&(M=S[t].dist,x=t);n<M&&(S[x]={index:e,dist:n})}}if(0===E)throw new Error(`${bt.KNN_IMPOSSIBLE_IMPUTATION}: the column "${h.name}", row ${t+1}`);if(h.type===r.COLUMN_TYPE.STRING)return(()=>{g.forEach((t,e,n)=>n[e]=0);let t=0;for(t=0;t<E;++t)++g[p[S[t].index]];let e=g[0],n=0;return g.forEach((t,i)=>{t>e&&(e=t,n=i)}),n})();P=0;for(let t=0;t<E;++t)P+=p[S[t].index];return N=P/E,h.type===r.COLUMN_TYPE.INT?Math.round(N):N};if(l){for(const e of o.get(n))try{p[e]=L(e)}catch(n){w.push(e),n instanceof Error||t.shell.error(bt.CORE_ISSUE)}w.length>0&&u.set(n,w),h.set(0,h.get(0))}else{const i=h.clone();let r=1,a=`${n}(${_t})`;for(;e.columns.contains(a);)a=`${n}(${_t} ${r})`,++r;i.name=a;const s=i.getRawData();for(const e of o.get(n))try{s[e]=L(e)}catch(n){w.push(e),n instanceof Error||t.shell.error(bt.CORE_ISSUE)}w.length>0&&u.set(a,w),i.set(0,i.get(0)),e.columns.add(i)}}),u}(n,m,_,s,p,d,l);u||function(t,e){e.forEach((e,n)=>{const i=t.col(n);if(null!==i){if(!Et.includes(i.type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE);const t=function(t){switch(t.type){case r.COLUMN_TYPE.STRING:case r.COLUMN_TYPE.DATE_TIME:return function(t){const e=xt(t),n=t.getRawData(),i=n.length;for(let r=0;r<i;++r)if(n[r]!==e)return t.get(r);throw new Error(bt.EMPTY_COLUMN)}(t);case r.COLUMN_TYPE.INT:case r.COLUMN_TYPE.FLOAT:case r.COLUMN_TYPE.QNUM:return t.stats.avg;default:throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}}(i);e.forEach(e=>i.set(e,t))}})}(n,e),P()}catch(e){e instanceof Error?t.shell.error(`${bt.KNN_FAILS}: ${e.message}`):t.shell.error(`${bt.KNN_FAILS}: ${bt.CORE_ISSUE}`),N(e)}},void 0,St.RUN),E.add(y).add(w).add(M).add(S).add(f).add(c).add(h).show().onClose.subscribe(()=>!T&&P()),F},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}class rn extends Xe{constructor(t={}){super(t),this.similarityThresholdInput=e.input.int("Similarity Threshold",{value:80}),this.maxIterationsInput=e.input.int("Max Iterations",{value:5}),this.useWebGPUInput=e.input.bool("Use WebGPU",{value:!1}),this.inflateInput=e.input.float("Inflation Factor",{value:ne}),this.minClusterSizeInput=e.input.int("Min Cluster Size",{value:5}),jt().then(t=>{t?(this.useWebGPUInput.setTooltip(`Use webGPU for MCL calculation (${t})`),this.useWebGPUInput.value=!0):(this.useWebGPUInput.value=!1,this.useWebGPUInput.setTooltip("WebGPU is not available"),this.useWebGPUInput.enabled=!1)})}getEditor(){return e.div([this.tableInput.root,this.columnsInputRoot,this.columnParamsEditorRoot,this.aggregationMethodInput.root,this.similarityThresholdInput.root,this.inflateInput.root,this.maxIterationsInput.root,this.minClusterSizeInput.root,this.useWebGPUInput.root],{style:{minWidth:"420px"},classes:"ui-form"})}getInput(){const t=super.getInput();return t.similarityThreshold=this.similarityThresholdInput.value,t.maxIterations=this.maxIterationsInput.value,t.useWebGPU=this.useWebGPUInput.value??!1,t.inflateFactor=this.inflateInput.value??ne,t.minClusterSize=this.minClusterSizeInput.value??5,t}async applyInput(t){await super.applyInput(t),this.similarityThresholdInput.value=t.similarityThreshold,this.maxIterationsInput.value=t.maxIterations,this.useWebGPUInput.value=t.useWebGPU,this.inflateInput.value=t.inflateFactor,this.minClusterSizeInput.value=t.minClusterSize}get params(){return{table:this.tableInput.value,columns:this.columnsInput.value,methodName:this.methodInput.value,preprocessingFunctions:this.columnOptEditors.map(t=>t.preProcessingFunction),distanceMetrics:this.columnOptEditors.map(t=>t.similarityMetricInput.value),weights:this.columnOptEditors.map(t=>t.weight),preprocessingFuncArgs:this.columnOptEditors.map(t=>t.preprocessingFunctionSettings),aggreaggregationMethod:this.aggregationMethodInput.value,threshold:this.similarityThresholdInput.value,maxIterations:this.maxIterationsInput.value??5,useWebGPU:this.useWebGPUInput.value??!1,inflateFactor:this.inflateInput.value??ne,minClusterSize:this.minClusterSizeInput.value??5}}}class on{constructor(t,e,n,i,o,a){this.sc=t,this.from=e,this.to=n,this.shortLineThreshold=i,this.width=o,this.color=a,this.renderFlag=!1,this.renderSub=r.debounce(t.onAfterDrawScene,200).subscribe(()=>{if(this.renderFlag)return void(this.renderFlag=!1);this.renderFlag=!0;const e=t.onBeforeDrawScene.subscribe(t=>{this.render(),e.unsubscribe()});setTimeout(()=>{this.sc.invalidateCanvas()})}),t.subs.push(this.renderSub)}render(){const t=this.sc.dataFrame.getCol(this.sc.props.xColumnName),e=this.sc.dataFrame.getCol(this.sc.props.yColumnName),n=this.sc.filter,i=new Array(this.sc.dataFrame.rowCount).fill(null).map((i,r)=>t.isNone(r)||e.isNone(r)||!n.get(r)?null:this.sc.pointToScreen(r)),r=this.sc.canvas.getContext("2d");if(!r)return;r.strokeStyle=`rgba(${this.color}, 0.3)`,r.lineWidth=this.width;const o=this.shortLineThreshold*this.shortLineThreshold;for(let t=0;t<this.from.length;t++){r.beginPath();const e=this.from[t],n=this.to[t];if(i[e]&&i[n]){const t=i[e],a=i[n],s=a.x-t.x,l=a.y-t.y;if(s*s+l*l<o)continue;r.moveTo(t.x,t.y),r.lineTo(a.x,a.y),r.stroke(),r.closePath()}}}destroy(){this.renderSub.unsubscribe()}}class an extends r.JsViewer{constructor(){super(),this.initPromise=Promise.resolve(),this.initialized=!1,this.reseolver=()=>{},this.scratchCallTimer=null,this.mclProps=this.string("mclProps",null,{includeInLayout:!1,userEditable:!1,nullable:!0}),this.lines=this.string("lines",null,{includeInLayout:!1,userEditable:!1,nullable:!0}),this.scProps=this.string("scProps",null,{includeInLayout:!1,userEditable:!1,nullable:!0}),this.initPromise=new Promise(t=>{this.reseolver=t})}onFrameAttached(e){this.sc=e.plot.scatter({showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1,title:"MCL"}),this.root.appendChild(this.sc.root),this.subs.push(t.events.onCurrentObjectChanged.subscribe(e=>{this.sc&&t.shell.o===this&&setTimeout(()=>{t.shell.o=this.sc})})),this.subs.push(r.debounce(this.sc.onPropertyValueChanged,1e3).subscribe(t=>{this.sc&&this.getProperty("scProps").set(this,JSON.stringify(Object.assign({},this.sc.props)))}))}setScProps(){if(!this.sc)return;const t=this.scProps;if(!t)return;const e=this.sc.props;if(t===JSON.stringify(Object.assign({},e)))return;const n=JSON.parse(t);Object.entries(n).forEach(([t,n])=>{e.hasProperty(t)&&e[t]!==n&&(this.sc.props[t]=n)})}onPropertyChanged(t){null!==t&&("scProps"===t.name?this.setScProps():"lines"===t.name?this.decodeLines():"mclProps"===t.name&&(this.scratchCallTimer&&clearTimeout(this.scratchCallTimer),this.scratchCallTimer=setTimeout(()=>{this.initFromScratch()},300)))}isDataFrameSavable(){return null!=this.dataFrame&&this.dataFrame.rowCount<65534}async initFromScratch(){if(!this.mclProps||!this.sc||!this.dataFrame||this.initialized)return;if(this.lines)return void this.decodeLines();const i=JSON.parse(this.mclProps),o=i.cols.map(t=>this.dataFrame.columns.byName(t)),a=i.preprocessingFuncs.map(t=>t?r.Func.byName(t):null),s=await async function(i,o,a,s,l,c,u,h=80,d=10,f=!1,p=2,g=5,m){let y=null,v=m;v||(y=t.shell.tableView(i.name)??t.shell.addTableView(i),v=y.scatterPlot({showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1,title:"MCL"})),e.setUpdateIndicator(v.root,!0);const w=[],b=[];for(let t=0;t<c.length;++t){const e=c[t];if(e){const n=e.inputs[0].name,i=e.inputs[1].name,{entries:r,options:s}=await e.apply({[n]:o[t],[i]:a[t],...u[t]??{}});b.push({entries:r,options:s}),w.push(s??{})}else{const e=o[t].toList(),n={};b.push({entries:e,options:n}),w.push(n)}}const C=function(t,e,i,r,o,a,s=10,l=!1,c=2){const u=new Worker(new URL(n.p+n.u(980),n.b));let h;return u.postMessage({data:t,threshold:e,weights:i,aggregationMethod:r,distanceFns:o,distanceFnArgs:a,maxIterations:s,useWebGPU:l,inflate:c}),{promise:new Promise((t,e)=>{h=t,u.onmessage=e=>{setTimeout(()=>u.terminate(),100),t(e.data.res)},u.onerror=t=>{setTimeout(()=>u.terminate(),100),e(t)}}),terminate:()=>{try{h(null),u.terminate()}catch(t){console.error(t)}}}}(b.map(t=>t.entries),h,s,l,a,w,d,f,p),_=t.events.onViewerClosed.subscribe(t=>{const e=t?.args?.viewer?.root;e&&(v.root===e||e.contains(v.root))&&(_.unsubscribe(),C.terminate())}),A=await C.promise;if(!A)return;const S=i.columns.getUnusedName("Cluster (MCL)"),E=i.columns.getUnusedName("EmbedX (MCL)"),x=i.columns.getUnusedName("EmbedY (MCL)"),M={};A.clusters.forEach(t=>{M[t]||(M[t]=0),M[t]++});const P=new Uint32Array(A.embedX.length);for(let t=0;t<A.is.length;t++)P[A.is[t]]++,P[A.js[t]]++;const N=i.columns.getUnusedName("Cluster size (MCL)"),T=i.columns.getUnusedName("Connectivity (MCL)"),F=i.columns.addNewFloat(E);F.init(t=>A.embedX[t]);const I=i.columns.addNewFloat(x);I.init(t=>A.embedY[t]);const L=i.columns.addNewString(S);L.init(t=>M[A.clusters[t]]>=g?A.clusters[t].toString():"-1");const O={"-1":r.Color.setAlpha(r.Color.lightBlue,100)};L.setTag(r.TAGS.COLOR_CODING_CATEGORICAL,JSON.stringify(O)),L.temp[r.TAGS.COLOR_CODING_CATEGORICAL]=O;const R=i.columns.addNewInt(N);R.init(t=>M[A.clusters[t]]);const D=i.columns.addNewInt(T);D.init(t=>P[t]),v.props.xColumnName=E,v.props.yColumnName=x,v.props.colorColumnName=S,v.props.markerDefaultSize=6,_.unsubscribe();const k=[],G=[],U=new Map;for(let t=0;t<A.is.length;t++){let e=A.clusters[A.is[t]],n=A.clusters[A.js[t]];if(e===n){k.push(A.is[t]),G.push(A.js[t]);continue}if(e>n){const t=e;e=n,n=t}let i=U.get(e);i||(i=new Map,U.set(e,i));let r=i.get(n);r||(r=0),r>=20||(r++,i.set(n,r),k.push(A.is[t]),G.push(A.js[t]))}return e.setUpdateIndicator(v.root,!1),{sc:v,embedXCol:F,embedYCol:I,clusterCol:L,clusterCounterCol:R,connectivityCol:D,i:k,j:G}}(this.dataFrame,o,i.metrics,i.weights,i.aggregationMethod,a,i.preprocessingFuncArgs,i.threshold,i.maxIterations,i.useWebGPU,i.inflate,i.minClusterSize,this.sc);if(s)return this.dataFrame.getTag(".script")||!this.isDataFrameSavable()?(this.linesRenderer?.destroy(),this.linesRenderer=new on(this.sc,s.i,s.j,6,.75,"128,128,128"),this.initialized=!0,void this.reseolver()):void this.encodeLines(s.i,s.j);this.reseolver()}decodeLines(){if(!this.lines)return;const t=this.lines.length;if(t%2!=0)throw new Error("Invalid lines string");const e=new Array(t/2).fill(null).map((t,e)=>this.lines.charCodeAt(2*e)),n=new Array(t/2).fill(null).map((t,e)=>this.lines.charCodeAt(2*e+1));this.linesRenderer?.destroy(),this.linesRenderer=new on(this.sc,e,n,6,.75,"128,128,128"),this.initialized=!0,this.reseolver()}encodeLines(t,e){const n=new Array(t.length).fill(null).map((n,i)=>`${String.fromCharCode(t[i])}${String.fromCharCode(e[i])}`).join("");this.getProperty("lines").set(this,n)}}var sn=function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((i=i.apply(t,e||[])).next())})};function ln(t,e){const n=t.length;if(n!==e.length-1)throw new Error("Incorrect parameters count");const i=t.byIndex(0),o=i.length,a=new Float32Array(o);let s=i.getRawData();const l=e[n];let c=e[0];for(let t=0;t<o;++t)a[t]=l+c*s[t];for(let i=1;i<n;++i){s=t.byIndex(i).getRawData(),c=e[i];for(let t=0;t<o;++t)a[t]+=c*s[t]}return r.Column.fromFloat32Array(t.getUnusedName("prediction"),a,o)}const cn=(t,e)=>e<=t?Math.min(10,e):Math.min(10,t);var un;!function(t){t[t.MAX_SAMLPES=1e5]="MAX_SAMLPES",t[t.MAX_FEATURES=1e3]="MAX_FEATURES"}(un||(un={}));class hn{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<=un.MAX_FEATURES&&e.length<=un.MAX_SAMLPES}constructor(t){if(this.specn=null,t)try{const e=new Uint32Array(t.buffer,0,2),n=e[0],i=e[1],o=new Uint8Array(t.buffer,8,n),a=r.DataFrame.fromByteArray(o),s=a.rowCount,l=a.columns,c=l.length,u=new Uint8Array(t.buffer,8+n,i),h=r.DataFrame.fromByteArray(u);if(c<3)throw new Error("incorrect columns count");const d=l.byName(ot.FEATURES).toList(),f=new Float32Array(s);f.set(l.byName(ot.REGR_COEFS).getRawData());const p=c-2,g=new Array(p);for(let t=0;t<p;++t)g[t]=new Float32Array(s),g[t].set(l.byIndex(t+2).getRawData());this.specn={params:f,loadings:g,names:d,dim:s-1,components:c-2,scores:h}}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(t,e,n){return i=this,o=void 0,s=function*(){const i=yield vt({table:r.DataFrame.fromColumns([e]),features:t,predict:e,components:n,names:void 0,isQuadratic:!1}),o=t.names();o.push("_");const a=this.getRegrCoeffs(t,e,i.regressionCoefficients),s=this.getLoadings(n,i.xLoadings);this.specn={names:o,params:a,loadings:s,components:n,dim:t.length,scores:this.getScoresDf(i)},this.computeExplVars(e.length,n,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),i=e[0].length+1;for(let r=0;r<t;++r)n[r]=new Float32Array(i),n[r].set(e[r].getRawData());return n}getRegrCoeffs(t,e,n){const i=t.length,r=new Float32Array(i+1),o=n.getRawData();let a=0;for(let e=0;e<i;++e)r[e]=o[e],a+=o[e]*t.byIndex(e).stats.avg;return r[i]=e.stats.avg-a,r}computeExplVars(t,e,n){if(null===this.specn)throw new Error("Failed to compute explained variances");const i=n.getRawData(),r=this.specn.loadings[0].length-1;let o=Math.pow(i[0],2)/t;this.specn.loadings[0][r]=o;for(let n=1;n<e;++n)o+=Math.pow(i[n],2)/t,this.specn.loadings[n][r]=o}toBytes(){if(null===this.specn)throw new Error("Failed to pack untrained model");const t=r.DataFrame.fromColumns([r.Column.fromStrings(ot.FEATURES,this.specn.names),r.Column.fromFloat32Array(ot.REGR_COEFS,this.specn.params)]);this.specn.loadings.forEach((e,n)=>t.columns.add(r.Column.fromFloat32Array(`${ot.XLOADING}${n+1}`,e)));const e=t.toByteArray(),n=e.length,i=this.specn.scores.toByteArray(),o=i.length,a=n+o+8,s=new Uint8Array(64*(Math.ceil(a/64)+1)),l=new Uint32Array(s.buffer,0,2);return l[0]=n,l[1]=o,s.set(e,8),s.set(i,8+n),s}predict(t){if(null===this.specn)throw new Error("Predicting failed: model is not trained");return ln(t,this.specn.params)}loadingsParamsViewers(){if(null===this.specn)throw new Error("Failed to create loadings and parameters viewers: untrained model");const t=[],e=this.specn.dim,n=r.DataFrame.fromColumns([r.Column.fromStrings(ot.FEATURES,this.specn.names.slice(0,-1)),r.Column.fromFloat32Array(ot.REGR_COEFS,this.specn.params,e)]),i=n.columns,o=i.length,a=this.specn.components;return this.specn.loadings.forEach((t,i)=>n.columns.add(r.Column.fromFloat32Array(`${ot.XLOADING}${i+1}`,t,e))),t.push(r.Viewer.scatterPlot(n,{title:ot.LOADINGS,xColumnName:i.byIndex(o).name,yColumnName:i.byIndex(o+(a>1?1:0)).name,markerType:r.MARKER_TYPE.CIRCLE,labelFormColumnNames:[ot.FEATURES],help:st.LOADINGS})),t.push(r.Viewer.barChart(n,{title:ot.REGR_COEFS,splitColumnName:ot.FEATURES,valueColumnName:ot.REGR_COEFS,valueAggrType:r.AGG.AVG,help:st.COEFFS,showValueSelector:!1,showStackSelector:!1})),t}explVarsViewer(){if(null===this.specn)throw new Error("Failed to create exaplained variances viewer: untrained model");const t=this.specn.components,e=this.specn.dim,n=new Array(t),i=new Float32Array(t);n[0]=`${ct.COMP} 1`,i[0]=this.specn.loadings[0][e];for(let r=1;r<t;++r)n[r]=`${ct.COMPS} ${r+1}`,i[r]=this.specn.loadings[r][e];return r.Viewer.barChart(r.DataFrame.fromColumns([r.Column.fromStrings(ct.COMPS,n),r.Column.fromFloat32Array(ot.EXPL_VAR,i)]),{title:ot.EXPL_VAR,splitColumnName:ct.COMPS,valueColumnName:ot.EXPL_VAR,valueAggrType:r.AGG.AVG,help:st.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(t){const e=t.tScores,n=t.uScores;return e.forEach((t,e)=>t.name=`${ot.XSCORE}${e+1}`),n.forEach((t,e)=>t.name=`${ot.YSCORE}${e+1}`),r.DataFrame.fromColumns(e.concat(n))}getScoresScatter(){if(null===this.specn)throw new Error("Failed to create scores scatter: untrained model");const t=this.specn.scores.columns.names(),e=r.Viewer.scatterPlot(this.specn.scores,{title:ot.SCORES,xColumnName:t[0],yColumnName:t[1],markerType:r.MARKER_TYPE.CIRCLE,help:st.SCORES,showViewerFormulaLines:!0});return e.meta.formulaLines.addAll(yt(t)),e}}var dn=function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((i=i.apply(t,e||[])).next())})};const fn="Avg-s",pn="Stddev-s";var gn;!function(t){t[t.MAX_SAMLPES=5e4]="MAX_SAMLPES",t[t.MAX_FEATURES=100]="MAX_FEATURES"}(gn||(gn={}));class mn{static isApplicable(t,e){for(const e of t)if(!e.matches("numerical"))return!1;return e.type===r.COLUMN_TYPE.STRING}static isInteractive(t,e){return t.length<=gn.MAX_FEATURES&&e.length<=gn.MAX_SAMLPES}constructor(t,e){if(this.params=void 0,this.classesCount=1,this.featuresCount=1,void 0!==t){const e=t.featuresCount,n=t.classesCount;if(e<1)throw new Error("Incorrect features count");if(n<1)throw new Error("Incorrect classes count");const i=e+1;this.avgs=new Float32Array(i),this.stdevs=new Float32Array(i),this.categories=new Array(i),this.featuresCount=e,this.classesCount=n}else{if(void 0===e)throw new Error("Softmax classifier not initialized");try{const t=new Uint32Array(e.buffer,0,1)[0],n=new Uint8Array(e.buffer,4,t),i=r.DataFrame.fromByteArray(n),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 t=0;t<s;++t){const e=o.byIndex(t);if(this.categories[t]=e.name,e.type!==r.COLUMN_TYPE.FLOAT)throw new Error(`Incorrect input column type. Expected: float, passed: ${e.type}`);this.params[t]=e.getRawData()}const l=o.byName(fn);if(l.type!==r.COLUMN_TYPE.FLOAT)throw new Error("incorrect average values column type");this.avgs=l.getRawData();const c=o.byName(pn);if(c.type!==r.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 t=this.classesCount,e=new Array(t+2);for(let n=0;n<t;++n)e[n]=r.Column.fromFloat32Array(this.categories[n],this.params[n]);e[t]=r.Column.fromFloat32Array(fn,this.avgs),e[t+1]=r.Column.fromFloat32Array(pn,this.stdevs);const n=r.DataFrame.fromColumns(e).toByteArray(),i=n.length,o=new Uint8Array(i+4);return new Uint32Array(o.buffer,0,1)[0]=i,o.set(n,4),o}fit(t,e){return dn(this,arguments,void 0,function*(t,e,n=1,i=100,o=.1,a=.001){if(t.length!==this.featuresCount)throw new Error("Training failes - incorrect features count");if(n<=0||i<1||o<=0||a<=0)throw new Error("Training failes - incorrect fitting hyperparameters");this.extractStats(t);const s=e.length,l=e.categories.length,c=e.categories;for(let t=0;t<l;++t)this.categories[t]=c[t];try{const c=function(t,e,n,i,r,o,a,s,l,c,u){return m(EDA,"fitSoftmax",[t,e,n,i,r,o,a,s,l,c,u])}(t,r.Column.fromFloat32Array("avgs",this.avgs,this.featuresCount),r.Column.fromFloat32Array("stdevs",this.stdevs,this.featuresCount),r.Column.fromInt32Array("targets",e.getRawData(),s),l,i,n,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(r){try{this.params=yield this.fitSoftmaxParams(t,e,i,n,o,a)}catch(t){throw new Error("Training failes")}}if(void 0===this.params)throw new Error("Training failes")})}extractStats(t){let e=0;for(const n of t){if(n.type!==r.COLUMN_TYPE.INT&&n.type!==r.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");this.avgs[e]=n.stats.avg,this.stdevs[e]=n.stats.stdev,++e}}normalized(t){const e=t.byIndex(0).length,n=new Array(e);for(let t=0;t<e;++t)n[t]=new Float32Array(this.featuresCount);let i=0;for(const o of t){if(o.type!==r.COLUMN_TYPE.INT&&o.type!==r.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const t=o.getRawData(),a=this.avgs[i],s=this.stdevs[i];if(s>0)for(let r=0;r<e;++r)n[r][i]=(t[r]-a)/s;else for(let t=0;t<e;++t)n[t][i]=0;++i}return n}transposed(t){const e=t.byIndex(0).length,n=this.featuresCount,i=new Array(n);for(let t=0;t<n;++t)i[t]=new Float32Array(e);let o=0;for(const n of t){if(n.type!==r.COLUMN_TYPE.INT&&n.type!==r.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const t=n.getRawData(),a=this.avgs[o],s=this.stdevs[o];if(s>0)for(let n=0;n<e;++n)i[o][n]=(t[n]-a)/s;else for(let t=0;t<e;++t)i[o][t]=0;++o}return i}preprocessedTargets(t){if(t.type!==r.COLUMN_TYPE.STRING)throw new Error("Training failes - incorrect target type");const e=this.classesCount,n=t.length,i=t.getRawData(),o=new Array(n),a=new Uint32Array(e).fill(0);for(let t=0;t<n;++t)o[t]=new Uint8Array(e).fill(0);for(let t=0;t<n;++t)o[t][i[t]]=1,++a[i[t]];return{oneHot:o,weights:a}}predict(t){if(void 0===this.params)throw new Error("Non-trained model");if(t.length!==this.featuresCount)throw new Error("Predcition fails: incorrect features count");const e=this.normalized(t),n=e.length,i=this.featuresCount,o=this.classesCount;let a,s;const l=new Float32Array(o);let c,u,h;const d=new Array(n);for(let t=0;t<n;++t){a=e[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)}u=l[0],h=0;for(let t=1;t<o;++t)u<l[t]&&(u=l[t],h=t);d[t]=this.categories[h]}return r.Column.fromStrings("predicted",d)}fitSoftmaxParams(t,e,i,r,o,a){return dn(this,void 0,void 0,function*(){const s=this.preprocessedTargets(e);return new Promise((l,c)=>{const u=new Worker(new URL(n.p+n.u(501),n.b));u.postMessage({features:this.normalized(t),transposed:this.transposed(t),oneHot:s.oneHot,classesWeights:s.weights,targetRaw:e.getRawData(),iterations:i,rate:r,penalty:o,tolerance:a}),u.onmessage=function(t){u.terminate(),l(t.data.params),console.log(`Loss: ${t.data.loss}`)}})})}}var yn,vn,wn;!function(t){t[t.ITERATIONS=20]="ITERATIONS",t[t.ETA=.3]="ETA",t[t.MAX_DEPTH=6]="MAX_DEPTH",t[t.LAMBDA=1]="LAMBDA",t[t.ALPHA=0]="ALPHA"}(yn||(yn={})),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"}(vn||(vn={})),function(t){t[t.MODEL=1e7]="MODEL",t[t.UTILS=1]="UTILS",t[t.PACK=128]="PACK",t[t.SIZE=4]="SIZE"}(wn||(wn={}));const bn=r.FLOAT_NULL;var Cn;!function(t){t.PREDICT="Prediction",t.TYPE="Type",t.PARAMS="Params count",t.CATS="Categories",t.CATS_SIZE="Categories size"}(Cn||(Cn={}));class _n{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,i=e.length;return i<=vn.SAMPLES_LOW?n<=vn.FEATURES_LOW:i<=vn.SAMLPES_MID?n<=vn.FEATURES_MID:i<=vn.SAMLPES_HIGH&&n<=vn.FEATURES_HIGH}constructor(t){var e;if(this.modelParams=void 0,this.targetType=void 0,this.targetCategories=void 0,t)try{let n=0;const i=new Uint32Array(t.buffer,n,1)[0];n+=wn.SIZE;const o=r.DataFrame.fromByteArray(new Uint8Array(t.buffer,n,i));n+=i,this.targetType=o.get(Cn.TYPE,0);const a=o.get(Cn.PARAMS,0),s=o.get(Cn.CATS_SIZE,0);if(s>0){const i=r.DataFrame.fromByteArray(new Uint8Array(t.buffer,n,s));this.targetCategories=null===(e=i.col(Cn.CATS))||void 0===e?void 0:e.toList()}n+=s,n=4*Math.ceil(n/4),this.modelParams=new Int32Array(t.buffer,n,a)}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(t,e){return i=this,o=arguments,s=function*(t,e,i=yn.ITERATIONS,o=yn.ETA,a=yn.MAX_DEPTH,s=yn.LAMBDA,l=yn.ALPHA){this.targetType=e.type,this.targetType===r.COLUMN_TYPE.STRING&&(this.targetCategories=e.categories),this.modelParams=yield async function(t,e,i,r,o,a,s,l,c,u){return new Promise((h,d)=>{const f=e.length,p=t.length,g=new Float32Array(f*p);let m,y;for(let e=0;e<p;++e){y=t.byIndex(e).getRawData(),m=e*f;for(let t=0;t<f;++t)g[t+m]=y[t]}const v=new Worker(new URL(n.p+n.u(990),n.b));v.postMessage({features:g,target:e.getRawData(),samplesCount:f,featuresCount:p,modelReserve:c,utilsLength:u,iterations:r,eta:o,maxDepth:a,lambda:s,alpha:l,missingValue:i}),v.onmessage=function(t){v.terminate(),h(t.data.params)}})}(t,e,bn,i,o,a,s,l,wn.MODEL,wn.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(t){if(void 0===this.modelParams)throw new Error("Failed to apply non-trained model");const e=function(t,e,n){const i=t.byIndex(0).length,r=t.length,o=n.length;let a=XGBoostModule.HEAPF32;const s=XGBoostModule.HEAP32,l=XGBoostModule._malloc(i*r*4),c=XGBoostModule._malloc(4*i),u=XGBoostModule._malloc(4*o);for(let e=0;e<r;++e){const n=t.byIndex(e).getRawData();for(let t=0;t<i;++t)a[l/4+t+e*i]=n[t]}for(let t=0;t<o;++t)s[u/4+t]=n[t];XGBoostModule._predict(l,i,r,e,u,o,c,i),a=XGBoostModule.HEAPF32;const h=new Float32Array(i);for(let t=0;t<i;++t)h[t]=a[c/4+t];return XGBoostModule._free(l),XGBoostModule._free(c),XGBoostModule._free(u),h}(t,bn,this.modelParams);switch(this.targetType){case r.COLUMN_TYPE.STRING:return this.stringColPrediction(e);case r.COLUMN_TYPE.INT:return this.intColPrediction(e);case r.COLUMN_TYPE.BIG_INT:return this.bigIntColPrediction(e);default:return r.Column.fromFloat32Array(Cn.PREDICT,e)}}toBytes(){if(void 0===this.modelParams||void 0===this.targetType)throw new Error("Failed to pack non-trained model");const t=void 0!==this.targetCategories?r.DataFrame.fromColumns([r.Column.fromList(r.COLUMN_TYPE.STRING,Cn.CATS,this.targetCategories)]).toByteArray():void 0,e=void 0!==t?t.length:0,n=this.modelParams.length*this.modelParams.BYTES_PER_ELEMENT,i=r.DataFrame.fromColumns([r.Column.fromStrings(Cn.TYPE,[this.targetType]),r.Column.fromInt32Array(Cn.PARAMS,new Int32Array([this.modelParams.length])),r.Column.fromInt32Array(Cn.CATS_SIZE,new Int32Array([e]))]).toByteArray(),o=i.length,a=64*Math.ceil((wn.SIZE+o+e+n+wn.PACK)/64),s=new Uint8Array(a);let l=0;return new Uint32Array(s.buffer,l,1)[0]=o,l+=wn.SIZE,s.set(i,l),l+=o,e>0&&s.set(t,l),l+=e,l=4*Math.ceil(l/4),s.set(new Uint8Array(this.modelParams.buffer),l),s}stringColPrediction(t){const e=t.length;if(void 0===this.targetCategories)throw new Error("Predicting fails: undefined categories");const n=new Array(e),i=this.targetCategories.length-1,o=t=>Math.max(0,Math.min(t,i));for(let i=0;i<e;++i)n[i]=this.targetCategories[o(Math.round(t[i]))];return r.Column.fromList(r.COLUMN_TYPE.STRING,Cn.PREDICT,n)}intColPrediction(t){const e=t.length,n=new Int32Array(e);for(let i=0;i<e;++i)n[i]=Math.round(t[i]);return r.Column.fromInt32Array(Cn.PREDICT,n,e)}bigIntColPrediction(t){const e=t.length,n=new BigInt64Array(e);for(let i=0;i<e;++i)n[i]=BigInt(Math.round(t[i]));return r.Column.fromBigInt64Array(Cn.PREDICT,n)}}var An,Sn,En,xn,Mn,Pn=n(8103),Nn={};Nn.styleTagTransform=Me(),Nn.setAttributes=Ae(),Nn.insert=Ce().bind(null,"head"),Nn.domAPI=we(),Nn.insertStyleElement=Ee(),ye()(Pn.A,Nn),Pn.A&&Pn.A.locals&&Pn.A.locals,function(t){t.MIN="minimize",t.MAX="maximize"}(An||(An={})),function(t){t.OPTIMAL="optimal",t.NON_OPT="non-optimal"}(Sn||(Sn={})),function(t){t[t.FORM=.15]="FORM",t[t.VIEWER=.5]="VIEWER"}(En||(En={})),function(t){t.OPT="Pareto optimality",t.SIZE="Pareto size"}(xn||(xn={})),function(t){t[t.OPTIMAL=8]="OPTIMAL",t[t.NON_OPT=4]="NON_OPT"}(Mn||(Mn={}));const Tn=!0,Fn=!0,In=[r.Color.darkGreen,r.Color.yellow,r.Color.darkRed];function Ln(t){return t===An.MIN?[...In]:[...In].reverse()}function On(t,n=!0){const i=e.label("Color scale:");i.style.paddingRight="7px";const o=[i],a=e.label(n?"min":"worst"),s=e.label(". . ."),l=e.label(n?"max":"best"),c=Ln(t),u=[a,s,l].map((t,e)=>(1!==e&&(t.style.fontWeight="bold",t.style.color=r.Color.toRgb(c[e])),t.style.marginRight="5px",t));return o.push(...u),e.divH(o)}class Rn{constructor(e){var n;this.numColNames=[],this.features=new Map,this.toUpdatePcCols=!1,this.intervalId=null,this.inputsMap=new Map,this.pcPlotNode=null,this.inputFormNode=null,this.toChangeParetoViewerOptions=!0,this.df=e;const i=e.columns.toList();this.numCols=i.filter(t=>t.isNumerical),this.numColNames=this.numCols.map(t=>t.name),this.numColsCount=this.numCols.length,this.rowCount=e.rowCount,this.view=t.shell.getTableView(e.name),this.paretoFrontViewer=r.Viewer.fromType("Pareto front",e);const o=this.view.dockManager.dock(this.paretoFrontViewer,r.DOCK_TYPE.RIGHT,null,void 0,En.VIEWER);this.pcPlot=r.Viewer.pcPlot(e,{legendPosition:"Top"});const a=null!==(n=this.view.dockManager.findNode(this.view.grid.root))&&void 0!==n?n:o;this.pcPlotNode=this.view.dockManager.dock(this.pcPlot,r.DOCK_TYPE.DOWN,a,void 0,En.VIEWER),this.toUpdatePcCols=this.numColNames.length>10,this.resultColName=this.df.columns.getUnusedName(xn.OPT),this.showResultOptCol(),this.view.subs.push(...this.getSubscriptions())}isApplicable(){return this.rowCount<1?(t.shell.warning("Cannot compute Pareto front: the table is empty."),!1):!(this.numColsCount<2&&(t.shell.warning("Cannot compute Pareto front: at least two numeric columns are required."),1))}run(){this.isApplicable()&&(this.buildInputsForm(),this.computeParetoFront(),this.updateVisualization())}getSubscriptions(){return[this.paretoFrontViewer.onDetached.subscribe(()=>{null!==this.pcPlotNode&&(this.view.dockManager.close(this.pcPlotNode),this.pcPlotNode=null),null!==this.inputFormNode&&(this.view.dockManager.close(this.inputFormNode),this.inputFormNode=null),this.numCols.forEach(t=>t.colors.setDisabled()),this.features.clear()})]}buildInputsForm(){const t=e.form([]);t.classList.add("pareto-input-form"),t.append(e.h1("Optimize")),this.numCols.forEach((n,i)=>{const r={toOptimize:this.numColsCount-i-1<2,optType:An.MIN},o=n.name,a=e.input.choice(o,{value:r.toOptimize?r.optType:null,nullable:!0,items:[null,An.MIN,An.MAX],onValueChanged:t=>{null==t?r.toOptimize=!1:(r.toOptimize=!0,r.optType=t),this.computeParetoFront(),this.updateVisualization()}});e.tooltip.bind(a.input,()=>r.toOptimize?e.markdown(`M${r.optType.slice(1)} **${o}** during Pareto optimization`):e.markdown(`Ignore **${o}** during Pareto optimization`)),this.inputsMap.set(o,a),t.append(a.root),this.features.set(o,r)}),this.inputFormNode=this.view.dockManager.dock(t,r.DOCK_TYPE.LEFT,null,void 0,En.FORM)}computeParetoFront(){if(!this.toChangeParetoViewerOptions)return;const t=this.getMinMaxFeatureNames();this.paretoFrontViewer.setOptions({minimizeColumnNames:t.toMin,maximizeColumnNames:t.toMax})}updatePcPlot(t,e){if(this.pcPlot.setOptions(e),this.toUpdatePcCols){const e=this.pcPlot.getOptions().look.columnNames;let n=!1;if(t.forEach(t=>{e.includes(t)||(n=!0)}),n){const e=[...t],n=this.numColNames.filter(t=>!e.includes(t));e.push(...n.slice(0,10-t.length)),this.pcPlot.setOptions({columnNames:e})}}}updateVisualization(){const t=[];this.features.forEach((e,n)=>{e.toOptimize&&t.push(n)});const e={colorColumnName:t.length>0?this.resultColName:void 0};this.updatePcPlot(t,e),this.markOptColsWithColor(),this.updateTooltips()}showResultOptCol(){this.intervalId=setInterval(()=>{const t=this.view.grid.columns.byName(this.resultColName);null!==t&&(t.visible=!0,this.stopChecking())},1e3)}stopChecking(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null)}markOptColsWithColor(){this.numCols.forEach(t=>t.colors.setDisabled()),this.features.forEach((t,e)=>{if(!t.toOptimize)return;const n=this.df.col(e);null!=n&&n.colors.setLinear(Ln(t.optType),{min:n.stats.min,max:n.stats.max})})}updateTooltips(){const t=this.features;this.view.grid.onCellTooltip(function(n,i,r){if(n.isColHeader&&n.tableColumn){const o=n.tableColumn.name,a=t.get(o);if(void 0!==a){const t=[e.markdown(`**${o}**`)];return a.toOptimize&&(t.push(e.markdown(`This feature is **${a.optType}d** during Pareto optimization.`)),t.push(On(a.optType))),e.tooltip.show(e.divV(t),i,r),!0}return!1}})}getMinMaxFeatureNames(){const t=[],e=[];return this.features.forEach((n,i)=>{n.toOptimize&&(n.optType===An.MIN?t.push(i):e.push(i))}),{toMin:t,toMax:e}}}class Dn extends r.JsViewer{get type(){return"ParetoFrontViewer"}constructor(){super(),this.autoLabelColNames=[],this.autoLabelsSelection=!0,this.toChangeAutoLabelsSelection=!0,this.toChangeAutoAxesSelection=!0,this.toChangeScatterMarkerSize=!1,this.colorColumnName=null,this.scatter=null,this.numCols=[],this.numColNames=[],this.numColsCount=0,this.rowCount=0,this.isApplicable=!1,this.errMsg="",this.resultColName="",this.sizeColName="",this.optimizedColNames=[],this.hasCommonMinMaxNames=!1,this.errDiv=null,this.missingValsIndices=new Map,this.toChangeScatterOptions=!0,this.title=this.string("title","Pareto front"),this.showTitle=this.bool("showTitle",!1,{category:"Description"}),this.description=this.string("description"),this.descriptionPosition=this.string("descriptionPosition","Top",{choices:["Left","Right","Top","Bottom"]}),this.descriptionVisibilityMode=this.string("descriptionVisibilityMode","Auto",{choices:["Auto","Always","Never"]}),this.minimizeColumnNames=this.addProperty("minimizeColumnNames",r.TYPE.COLUMN_LIST,null,{columnTypeFilter:r.TYPE.NUMERICAL,category:"Objectives",description:"Columns with features to be minimized during Pareto optimization."}),this.maximizeColumnNames=this.addProperty("maximizeColumnNames",r.TYPE.COLUMN_LIST,null,{columnTypeFilter:r.TYPE.NUMERICAL,category:"Objectives",description:"Columns with features to be maximized during Pareto optimization."}),this.xAxisColumnName=this.string("xAxisColumnName",null,{category:"Axes",description:"A column to be used on the X axis of the scatter plot.",nullable:!1}),this.yAxisColumnName=this.string("yAxisColumnName",null,{category:"Axes",description:"A column to be used on the Y axis of the scatter plot.",nullable:!1}),this.autoAxesSelection=this.bool("autoAxesSelection",Tn,{defaultValue:Tn,category:"Axes",description:"If checked, axes are selected automatically based on the optimized features. If unchecked, custom coordinate axes are used."}),this.labelColumnsColumnNames=this.addProperty("labelColumnsColumnNames",r.TYPE.COLUMN_LIST,null,{category:"Labels",description:"Label columns to show next to the markers."}),this.autoLabelsSelection=this.bool("autoLabelsSelection",Fn,{category:"Labels",description:"Select legend columns automatically; labels show unique categories.",defaultValue:Fn}),this.displayLabels=this.string("displayLabels","Auto",{choices:["Auto","Always","Never"],category:"Labels"}),this.legendVisibility=this.string("legendVisibility","Auto",{choices:["Auto","Always","Never"]}),this.legendPosition=this.string("legendPosition","Top",{choices:["Auto","Left","Right","Top","Bottom","RightTop","RightBottom","LeftTop","LeftBottom"]})}initializeData(){this.rowCount=this.dataFrame.rowCount;const t=this.dataFrame.columns,e=t.toList();this.numCols=e.filter(t=>t.isNumerical&&t.stats.missingValueCount<this.rowCount),this.numColNames=this.numCols.map(t=>t.name),this.numColsCount=this.numCols.length,this.isApplicable=this._testColumns(),this.isApplicable?(this.toChangeScatterMarkerSize=this.rowCount>5e3,this.resultColName=t.getUnusedName(xn.OPT),this.sizeColName=t.getUnusedName(xn.SIZE),this.missingValsIndices=Ft(this.numCols)):this._showErrorMessage(this.errMsg)}computeParetoFront(){if(!this.isApplicable)return;const t=[],e=[],n=new Set,i=(i,r)=>{null!=i&&i.forEach(i=>{t.push(this.dataFrame.col(i).getRawData()),e.push(r);const o=this.missingValsIndices.get(i);null!=o&&o.forEach(t=>n.add(t))})};i(this.minimizeColumnNames,An.MIN),i(this.maximizeColumnNames,An.MAX);const o=this.dataFrame.col(this.sizeColName);let a=this.dataFrame.col(this.resultColName);if(t.length>0){const i=function(t,e,n,i){if(0===n)return[];const r=t.length;if(e.length!==r)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,i)=>e[0]===An.MIN?t[0][n]-t[0][i]:t[0][i]-t[0][n]);const a=Array(n).fill(!0),s=[];null==i||i.forEach(t=>a[t]=!1);for(const n of o){if(!a[n])continue;let i=!1;for(const o of s){let a=!0,s=!1;for(let i=0;i<r;i++){const r=t[i][o],l=t[i][n];e[i]===An.MIN?(r>l&&(a=!1),r<l&&(s=!0)):(r<l&&(a=!1),r>l&&(s=!0))}if(a&&s){i=!0;break}}i?a[n]=!1:s.push(n)}return a}(t,e,this.rowCount,n),s=r.Column.fromStrings(this.resultColName,i.map(t=>t?Sn.OPTIMAL:Sn.NON_OPT));if(null==a)this.dataFrame.columns.add(s),a=s,this.hideCol(this.resultColName);else{const t=s.categories,e=s.getRawData(),n=a.getRawData(),i=a.categories,r=t.map(t=>i.indexOf(t));for(let t=0;t<this.rowCount;++t)n[t]=r[e[t]]}if(this.markResColWithColor(a),this.toChangeScatterMarkerSize)if(null==o)this.dataFrame.columns.add(r.Column.fromInt32Array(this.sizeColName,new Int32Array(i.map(t=>t?Mn.OPTIMAL:Mn.NON_OPT)))),this.hideCol(this.sizeColName);else{const t=o.getRawData();for(let e=0;e<this.rowCount;++e)t[e]=i[e]?Mn.OPTIMAL:Mn.NON_OPT}}else{if(null!=o){const t=o.getRawData();for(let e=0;e<this.rowCount;++e)t[e]=Mn.NON_OPT}if(null!=a){const t=a.getRawData(),e=a.categories.indexOf(Sn.NON_OPT);for(let n=0;n<this.rowCount;++n)t[n]=e}}}markResColWithColor(t){t.colors.setCategorical({optimal:"#2ca02c","non-optimal":"#e3e3e3"})}removeErrDiv(){null!=this.errDiv&&(this.root.removeChild(this.errDiv),this.errDiv=null)}_showErrorMessage(t){this.removeErrDiv(),this.errDiv=this.root.appendChild(e.divText(t,"d4-viewer-error"))}_testColumns(){return this.rowCount<1?(this.errMsg="Cannot compute Pareto front: the table is empty.",!1):!(this.numColsCount<2&&(this.errMsg="Cannot compute Pareto front: at least two non-empty numeric columns are required.",1))}setScatterOptions(){null!=this.scatter&&this.toChangeScatterOptions&&(this.toChangeScatterMarkerSize&&this.scatter.setOptions({markerMinSize:Mn.NON_OPT,markerMaxSize:Mn.OPTIMAL}),this.scatter.setOptions({title:this.title,showTitle:this.showTitle,legendVisibility:this.legendVisibility,legendPosition:this.legendPosition,colorColumnName:this.colorColumnName,displayLabels:this.displayLabels,sizeColumnName:this.toChangeScatterMarkerSize?this.sizeColName:null}),null!=this.labelColumnsColumnNames&&this.scatter.setOptions({labelColumnNames:this.labelColumnsColumnNames}))}onTableAttached(){if(this.initializeData(),this.isApplicable){this.scatter=r.Viewer.scatterPlot(this.dataFrame,{showColorSelector:!1,showSizeSelector:!1,autoLayout:!1,showLabels:"Always",markerType:r.MARKER_TYPE.CIRCLE}),this.root.append(this.scatter.root),this.autoLabelColNames=this.getLabelColNames(),this.subs.push(this.scatter.onDartPropertyChanged.subscribe(()=>this.checkScatterAxes()));const t=this.numColNames.filter((t,e)=>this.numColsCount-e-1<2);this.setOptions({maximizeColumnNames:[],minimizeColumnNames:t,xAxisColumnName:t[0],yAxisColumnName:t[1],autoAxesSelection:Tn,autoLabelsSelection:Fn})}this.subs.push(this.onDetached.subscribe(()=>this.removeResultingCols()))}checkScatterAxes(){if(null==this.scatter)return;let t=this.scatter.getOptions().look.xColumnName;t!==this.xAxisColumnName&&(this.toChangeScatterOptions=!1,this.setOptions({xAxisColumnName:t}),this.toChangeScatterOptions=!0),t=this.scatter.getOptions().look.yColumnName,t!==this.yAxisColumnName&&(this.toChangeScatterOptions=!1,this.setOptions({yAxisColumnName:t}),this.toChangeScatterOptions=!0)}removeResultingCols(){this.dataFrame.columns.remove(this.resultColName),this.dataFrame.columns.remove(this.sizeColName)}hideCol(t){const e=this.tableView;if(null==e)return;const n=e.grid.columns.byName(t);null!==n&&(n.visible=!1)}detach(){this.subs.forEach(t=>t.unsubscribe()),super.detach()}updateAutoAxesSelection(){this.toChangeAutoAxesSelection&&this.setOptions({autoAxesSelection:null}),this.toChangeAutoAxesSelection=!0}onPropertyChanged(t){var e,n;if(this.isApplicable){switch(t.name){case"minimizeColumnNames":case"maximizeColumnNames":this.updateCommonMinMaxFeatures();break;case"xAxisColumnName":null===(e=this.scatter)||void 0===e||e.setOptions({xColumnName:this.xAxisColumnName}),this.updateAutoAxesSelection();break;case"yAxisColumnName":null===(n=this.scatter)||void 0===n||n.setOptions({yColumnName:this.yAxisColumnName}),this.updateAutoAxesSelection();break;case"autoAxesSelection":this.updateAxesColumnOptions();break;case"autoLabelsSelection":this.updateLabelColumnOptions();break;case"labelColumnsColumnNames":this.toChangeAutoLabelsSelection&&this.setOptions({autoLabelsSelection:null}),this.toChangeAutoLabelsSelection=!0}this.render("minimizeColumnNames"===t.name||"maximizeColumnNames"===t.name)}}render(t=!1){if(!this.isApplicable||this.hasCommonMinMaxNames)return null!=this.scatter&&(this.scatter.root.hidden=!0),void this._showErrorMessage(this.errMsg);this.removeErrDiv(),t&&(this.computeParetoFront(),this.updateOptimizedColNames(),this.updateAxesColumnOptions(),this.colorColumnName=this.optimizedColNames.length<1?null:xn.OPT),this.setScatterOptions(),null!=this.scatter&&(this.scatter.root.hidden=!1)}updateCommonMinMaxFeatures(){if(null==this.minimizeColumnNames||null==this.maximizeColumnNames)return void(this.hasCommonMinMaxNames=!1);const t=this.minimizeColumnNames.filter(t=>this.maximizeColumnNames.includes(t));if(t.length>0){this.hasCommonMinMaxNames=!0;const e=t.map(t=>`"${t}"`).join(", ");this.errMsg=`Cannot minimize and maximize features at the same time: ${e}.`}else this.hasCommonMinMaxNames=!1}updateOptimizedColNames(){this.optimizedColNames=[],null!=this.minimizeColumnNames&&this.optimizedColNames.push(...this.minimizeColumnNames),null!=this.maximizeColumnNames&&this.optimizedColNames.push(...this.maximizeColumnNames)}updateAxesColumnOptions(){if(!this.autoAxesSelection)return;const t=this.optimizedColNames.length;if(t<1)return;const e=this.optimizedColNames.indexOf(this.xAxisColumnName),n=this.optimizedColNames.indexOf(this.yAxisColumnName);t>1?(e<0&&(this.toChangeAutoAxesSelection=!1,this.setOptions({xAxisColumnName:this.optimizedColNames[0!==n?0:1]})),n<0&&(this.toChangeAutoAxesSelection=!1,this.setOptions({yAxisColumnName:this.optimizedColNames[1!==e?1:0]}))):e<0&&n<0&&(this.toChangeAutoAxesSelection=!1,this.setOptions({xAxisColumnName:this.optimizedColNames[0]}))}updateLabelColumnOptions(){this.autoLabelsSelection&&(this.toChangeAutoLabelsSelection=!1,this.setOptions({labelColumnsColumnNames:[...this.autoLabelColNames]}))}getLabelColNames(){return this.dataFrame.columns.toList().filter(t=>t.type===r.COLUMN_TYPE.STRING&&t.categories.length===this.rowCount).map(t=>t.name)}}var kn=n(5778),Gn=n.n(kn);const Un=10,Bn=10,Vn=20,zn=30;class Wn{constructor(n,i,r){this.root=e.div(),this.onChanged=new se.Subject,this._prop=n,this.root.style.width=`${i}px`,this.root.style.height=`${r}px`,this.root.style.position="relative";const o=this;setTimeout(()=>{var a,s;if(!this.root.parentElement)return void console.warn("Konva this.container not attached to DOM yet.");const l=new(Gn().Stage)({container:this.root,width:i,height:r}),c=new(Gn().Layer);l.add(c);const u=null!==(a=n.min)&&void 0!==a?a:Math.min(...n.line.map(t=>t[0])),h=null!==(s=n.max)&&void 0!==s?s:Math.max(...n.line.map(t=>t[0])),d=new(Gn().Line)({points:[zn,r-Vn,i-Bn,r-Vn],stroke:"grey",strokeWidth:1}),f=new(Gn().Line)({points:[zn,Un,zn,r-Vn],stroke:"grey",strokeWidth:1});c.add(d,f);const p=new(Gn().Text)({x:zn,y:r-Vn+3,text:u.toFixed(1),fontSize:9,fill:"grey"}),g=new(Gn().Text)({x:i-Bn-15,y:r-Vn+3,text:h.toFixed(1),fontSize:9,align:"right",fill:"grey"}),m=new(Gn().Text)({x:10,y:r-Vn-5,text:"0.0",fontSize:9,fill:"grey"}),y=new(Gn().Text)({x:10,y:5,text:"1.0",fontSize:9,fill:"grey"});c.add(p,g,m,y);const v=new(Gn().Line)({points:[],stroke:"#2077b4",strokeWidth:2,lineCap:"round",lineJoin:"round"});c.add(v);const w=new(Gn().Group);function b(a=!0){w.destroyChildren();const s=[];n.line.sort((t,e)=>t[0]-e[0]),n.line.forEach((o,a)=>{const d=Hn(o[0],o[1],u,h,i,r);s.push(d.x,d.y);const f=new(Gn().Circle)({x:d.x,y:d.y,radius:3,fill:"#d72f30",stroke:"black",strokeWidth:1,draggable:!0,hitStrokeWidth:5});f.setAttr("_pointIndex",a),f.on("dragmove",t=>{const e=t.target,o=e.position(),a=e.getAttr("_pointIndex"),s=a>0?n.line[a-1][0]:u,l=a<n.line.length-1?n.line[a+1][0]:h,d=h-u===0?0:.001*(h-u),f=Hn(s+(a>0?d:0),0,u,h,i,r).x,p=Hn(l-(a<n.line.length-1?d:0),0,u,h,i,r).x;o.x=Math.max(f,Math.min(p,o.x));const g=r-Vn;o.y=Math.max(10,Math.min(g,o.y)),e.position(o);const m=jn(o.x,o.y,u,h,i,r);n.line[a][0]=m.x,n.line[a][1]=m.y;const y=n.line.map((t,e)=>{if(e===a)return[o.x,o.y];{const e=Hn(t[0],t[1],u,h,i,r);return[e.x,e.y]}}).flat();v.points(y),c.batchDraw()}),f.on("dragend",t=>{n.line.sort((t,e)=>t[0]-e[0]),b()}),f.on("contextmenu",e=>{if(e.evt.preventDefault(),n.line.length<=2)return void t.shell.warning("Cannot remove points, minimum of 2 required.");const i=e.target.getAttr("_pointIndex");n.line.splice(i,1),b()}),f.on("mouseenter",t=>{l.container().style.cursor="pointer";const n=t.target.position(),o=jn(n.x,n.y,u,h,i,r),a=`X: ${o.x.toFixed(2)}, Y: ${o.y.toFixed(2)}<br><br>Drag to move, right-click to delete`;e.tooltip.show(a,t.evt.clientX,t.evt.clientY)}),f.on("mouseleave",t=>{l.container().style.cursor="default",e.tooltip.hide()}),w.add(f)}),v.points(s),c.batchDraw(),a&&o.onChanged.next()}c.add(w),l.on("click tap",t=>{if(t.target instanceof Gn().Circle||0!==t.evt.button)return;const e=l.getPointerPosition();if(!e)return;if(e.x<zn||e.x>i-Bn||e.y<Un||e.y>r-Vn)return;const o=jn(e.x,e.y,u,h,i,r);n.line.push([o.x,o.y]),b()}),l.on("mouseenter",t=>{if(!(t.target instanceof Gn().Circle)){const t=l.getPointerPosition();t&&t.x>=zn&&t.x<=i-Bn&&t.y>=Un&&t.y<=r-Vn&&(l.container().style.cursor="crosshair")}}),l.on("mouseleave",t=>{t.target instanceof Gn().Circle||(l.container().style.cursor="default")}),l.on("mousemove",t=>{if(!(t.target instanceof Gn().Circle)){const t=l.getPointerPosition();t&&t.x>=zn&&t.x<=i-Bn&&t.y>=Un&&t.y<=r-Vn?l.container().style.cursor="crosshair":l.container().style.cursor="default"}}),l.on("mouseout",t=>e.tooltip.hide()),b(!1)},0)}get line(){return this._prop.line}}function Hn(t,e,n,i,r,o){const a=o-Un-Vn;return{x:zn+(t-n)*(i-n===0?1:(r-zn-Bn)/(i-n)),y:Un+a-e*a}}function jn(t,e,n,i,r,o){const a=o-Un-Vn;let s=n+(t-zn)/(i-n===0?1:(r-zn-Bn)/(i-n)),l=(Un+a-e)/a;return s=Math.max(n,Math.min(i,s)),l=Math.max(0,Math.min(1,l)),{x:s,y:l}}class Kn{constructor(t){this.root=e.div([]),this.onChanged=new se.Subject,this.dataFrame=t,this.setProfile()}getProfile(){return this.profile}setProfile(t){if(this.profile=t,e.empty(this.root),!t)return void this.root.append(e.divText("No profile specified."));const n=e.divH([e.divText("Property",{style:{fontWeight:"bold",width:"150px"}}),e.divText("Weight",{style:{fontWeight:"bold",width:"60px"}}),e.divText("Desirability",{style:{fontWeight:"bold",flexGrow:"1"}})],{style:{marginTop:"10px",paddingBottom:"5px",borderBottom:"1px solid #ccc"}}),i=Object.entries(t.properties).map(([n,i])=>{var r,o,a;const s=new Wn(i,300,80);s.onChanged.subscribe(t=>this.onChanged.next());const l=e.input.float("",{value:i.weight,min:0,max:1,onValueChanged:e=>{if(t&&t.properties[n]){let i=null!=e?e:0;i=Math.max(0,Math.min(1,i)),t.properties[n].weight=i}}});l.root.style.width="60px",l.root.style.marginTop="21px";const c=this.dataFrame?this.dataFrame.columns.names().find(t=>t.toLowerCase()==n.toLowerCase()):null,u=e.input.choice("",{nullable:!0,items:null!==(a=null===(o=null===(r=this.dataFrame)||void 0===r?void 0:r.columns)||void 0===o?void 0:o.names())&&void 0!==a?a:[""],value:null!=c?c:""}),h=e.divH([e.divV([e.divText(n,{style:{width:"150px",paddingTop:"5px",marginLeft:"4px"}}),this.dataFrame?u.root:null]),l.root,s.root]);return h.style.alignItems="center",h.style.marginBottom="5px",h.style.minHeight="70px",h}).filter(t=>null!==t);i.length>0?(this.root.append(n),this.root.append(e.divV(i))):this.root.append(e.divText("No matching properties found in the table for this template."))}}var Yn=n(4884),qn={};qn.styleTagTransform=Me(),qn.setAttributes=Ae(),qn.insert=Ce().bind(null,"head"),qn.domAPI=we(),qn.insertStyleElement=Ee(),ye()(Yn.A,qn),Yn.A&&Yn.A.locals&&Yn.A.locals;const Xn="pMPO is not applicable",$n="Failed to compute pMPO parameters",Qn="desired",Jn="non-desired",Zn="Mean",ti="p-value",ei=new Map([["desAvg",`${Zn}(${Qn})`],["desStd",`Std(${Qn})`],["nonDesAvg",`${Zn}(${Jn})`],["nonDesStd",`Std(${Jn})`],["tstat","t-statistics"],["pValue",ti]]),ni="Descriptor",ii=ni+" Statistics",ri="Selected",oi="Weight",ai="pMPO score",si="Desirability Curve",li=.001,ci=.001,hi=.01,di=.01,fi="0.000";var pi;!function(t){t.SELECTED="rgb(26, 146, 26)",t.SKIPPED="rgb(208, 57, 67)"}(pi||(pi={}));const gi=[0,.25,.5,1,1.5,2,2.5,3,4,5],mi=gi.slice(1).map(t=>-t).reverse().concat(gi),yi=gi.concat([.12,.37,.63,.75,.88,1.25,1.75,2.25,2.75]).sort(),vi=yi.slice(1).map(t=>-t).reverse().concat(yi),wi="TPR (Sensitivity)",bi="FPR (1 - Specificity)",Ci=101,_i=new Float32Array(Array.from({length:Ci},(t,e)=>e/100)),Ai=new Map([["tolerance",.001],["maxIter",25],["nonZeroParam",1e-4],["initialScale",.02],["scaleReflaction",1],["scaleExpansion",2],["scaleContraction",-.5]]),Si=new Float32Array([.5,di]),Ei=new Float32Array([1,1]);function xi(t,e){const n=t.groupBy([e.name]).getGroups();let i,r;for(const t in n)t.toLowerCase().includes("true")?i=n[t]:r=n[t];return{desired:i,nonDesired:r}}function Mi(t,e){const n=t.length,i=e.length;if(n<2||i<2)throw new Error(`Failed to compute the "${t.name}" descriptor statistics: \n both samples must have at least two observations.`);const r=t.stats.avg,o=e.stats.avg,a=t.stats.variance,s=e.stats.variance,l=t.stats.stdev,c=e.stats.stdev,u=Math.sqrt(a/n+s/i);if(0===u)throw new Error(`Failed to compute the "${t.name}" descriptor statistics: \n zero variance.`);const h=(r-o)/u,d=Math.pow(a/n+s/i,2)/(a*a/(n*n*(n-1))+s*s/(i*i*(i-1))),f=2*(1-Ct.studentt.cdf(Math.abs(h),d));return{desAvg:r,desStd:l,desLen:n,nonDesAvg:o,nonDesStd:c,nonSesLen:i,min:Math.min(t.stats.min,e.stats.min),max:Math.max(t.stats.max,e.stats.max),tstat:h,pValue:f}}function Pi(t,e,n){if(t.length!==e.length)throw new Error("Failed to compute confusion matrix: columns have different lengths.");if(t.type!==r.COLUMN_TYPE.BOOL)throw new Error("Failed to compute confusion matrix: desirability column must be boolean.");if(!e.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=t.getRawData(),c=e.getRawData();let u=0,h=0,d=l[0];for(let t=0;t<e.length;++t)1==(d>>>h&1)?c[t]>=n?++i:++s:c[t]>=n?++a:++o,++h,h>=32&&(h=0,++u,d=l[u]);return{TP:i,TN:o,FP:a,FN:s}}function Ni(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 i=1;i<t.length;++i)n+=Math.abs(e[i]-e[i-1])*((t[i]+t[i-1])/2);return n}function Ti(t,e){const n=new Float32Array(Ci),i=new Float32Array(Ci);let r=-1,o=-1,a=_i[0];for(let s=0;s<Ci;++s){const l=Pi(t,e,_i[s]);n[s]=l.TP+l.FN>0?l.TP/(l.TP+l.FN):0,i[s]=l.FP+l.TN>0?l.FP/(l.FP+l.TN):0,o=n[s]-i[s],o>r&&(r=o,a=_i[s])}return{auc:Ni(n,i),threshold:a,tpr:n,fpr:i}}var Fi=function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((i=i.apply(t,e||[])).next())})};function Ii(t){const e=t.size,n=new Map;ei.forEach((t,i)=>{n.set(i,new Float64Array(e))});const i=[...t.keys()],o=[r.Column.fromStrings(ni,i),r.Column.fromInt32Array(si,new Int32Array(e)),r.Column.fromFloat32Array(oi,new Float32Array(e).fill(r.FLOAT_NULL))];i.forEach((e,i)=>{const r=t.get(e);null!=r&&ei.forEach((t,e)=>{const o=r[e];n.get(e)[i]=o})}),ei.forEach((t,e)=>{o.push(r.Column.fromFloat64Array(t,n.get(e)))});const a=r.DataFrame.fromColumns(o);return a.name=ii,a}function Li(t,e){const n=[],i=t.col(ni);if(null==i)throw new Error(`No column "${ni} in the table with descriptors statistics.`);const r=i.toList(),o=t.col(ti);if(null==o)throw new Error(`No column "${ti} in the table with descriptors statistics.`);const a=o.getRawData();for(let i=0;i<t.rowCount;++i)a[i]<e&&n.push(r[i]);return n}function Oi(t,n,i,r){const o=e.div();o.classList.add("eda-pmpo-tooltip-line");const a=e.div();a.classList.add("eda-pmpo-box"),a.style.backgroundColor=pi.SELECTED;const s=e.span([]);s.textContent=`- ${i}`,o.appendChild(a),o.appendChild(s);const l=e.div();l.classList.add("eda-pmpo-tooltip-line");const c=e.div();c.classList.add("eda-pmpo-box"),c.style.backgroundColor=pi.SKIPPED;const u=e.span([]);return u.textContent=`- ${r}`,l.appendChild(c),l.appendChild(u),e.divV([e.h2(t),e.divText(n),o,l])}function Ri(t,e){const n=[];for(let i=0;i<e.length;++i)for(let r=i+1;r<e.length;++r)n.push([e[i],e[r],Math.pow(t.byName(e[i]).stats.corr(t.byName(e[r])),2)]);return n}function Di(t,e,n,i,r){const o=r.sort((t,e)=>e[2]-t[2]),a=new Set(e);return o.filter(t=>t[2]>i).forEach(t=>{const[e,i,r]=t,o=n.get(e).pValue,s=n.get(i).pValue,l=n.get(e).tstat,c=n.get(i).tstat;o>s?a.delete(e):o<s||Math.abs(l)>Math.abs(c)?a.delete(i):a.delete(e)}),[...a]}function ki(t,e,n,i){const r=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($n+`: no column "${n}" in the desired table.`);const c=e.col(n);if(null==c)throw new Error($n+`: no column "${n}" in the non-desired table.`);const u=l.stats.avg,h=l.stats.stdev*Math.sqrt((a-1)/a),d=c.stats.avg,f=c.stats.stdev*Math.sqrt((s-1)/s),p=(m=h,v=f,(g=u)<(y=d)?{cutoff:(y-g)/(m+v)*m+g,cutoffDesired:Math.max(g,y-v),cutoffNotDesired:Math.max(g+m,y)}:{cutoff:(g-y)/(m+v)*v+y,cutoffDesired:Math.min(y+v,g),cutoffNotDesired:Math.max(y,g-m)});var g,m,y,v;const w=Math.exp(-Math.pow(p.cutoff-u,2)/(2*Math.pow(h,2))),b=function(t,e,n,i){const r=1/(2*Math.pow(e,2))-1/(2*Math.pow(i,2)),o=n/Math.pow(i,2)-t/Math.pow(e,2),a=Math.pow(t,2)/(2*Math.pow(e,2))-Math.pow(n,2)/(2*Math.pow(i,2))-Math.log(i/e);if(Math.abs(r)<1e-12)return Math.abs(o)<1e-12?[]:[-a/o];const s=o*o-4*r*a;if(s<0)return[];const l=Math.sqrt(s);return[(-o+l)/(2*r),(-o-l)/(2*r)]}(u,h,d,f),C=Math.pow(w,-1)-1,_=Math.pow(i,-1)-1,A=Math.pow(10,Math.log10(_/C)/(-1*(d-p.cutoff)));let S=null;if(b.length>0){for(const t of b){const e=Math.min(u,d),n=Math.max(u,d);if(e-1e-8<=t&&t<=n+1e-8){S=t;break}}null==S&&(S=b[0])}else S=p.cutoff;const E=p.cutoffNotDesired,x=function(t,e,n,i,r=.05){let o;if(e<=0)o=n===t?1:0;else{const i=1/(e*Math.sqrt(2*Math.PI)),r=-.5*Math.pow((n-t)/e,2);o=i*Math.exp(r)}o=Math.max(o,1e-12);const a=Math.max(1/o-1,1e-12),s=1/r-1,l=i-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}}(u,h,S,E,i),M=Math.abs(u-d)/(h+f);o+=M,r.set(n,{desAvg:u,desStd:h,nonDesAvg:d,nonDesStd:f,min:Math.min(l.stats.min,c.stats.min),max:Math.max(l.stats.max,c.stats.max),cutoff:p.cutoff,cutoffDesired:p.cutoffDesired,cutoffNotDesired:p.cutoffNotDesired,pX0:x.pX0,b:C,c:A,zScore:M,weight:M,intersections:b,x0:S,xBound:E,inflection:w})}),r.forEach(t=>{t.weight=t.zScore/o}),r}function Gi(t,e,n,i,r){return{type:"MPO Desirability Profile",name:n,description:i,properties:Ui(t,e,r)}}function Ui(t,e,n){const i={};return t.forEach((t,r)=>{const o=zi(t,n);i[r]={weight:t.weight,line:Vi(t,e,n),min:Math.min(...o),max:Math.max(...o)}}),i}function Bi(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,i){return i>0?1/(1+n*Math.pow(i,-(t-e))):1/(1+n)}(t,e.cutoff,e.b,e.c):1)}function Vi(t,e,n){return zi(t,n).map(n=>[n,Bi(n,t,e)])}function zi(t,e){const n=function(t,e,n){return n?mi.map(n=>t+n*e):vi.map(n=>t+n*e)}(t.desAvg,t.desStd,e);if(e){const e=Math.min(t.min,t.desAvg-3*t.desStd),i=Math.max(t.max,t.desAvg+3*t.desStd);return n.filter(t=>e<=t&&t<=i).sort()}return n}class Wi extends Error{constructor(t){super(t),this.name="PmpoError"}}function Hi(t,e,n,i){for(let r=0;r<e;r++){let o=0;for(let t=0;t<e+1;t++)t!=n&&(o+=i[t][r]);t[r]=o/e}}function ji(t,e,n,i,r,o,a,s){for(let l=0;l<o;l++)e[l]=t[l],e[l]+=r*(t[l]-i[n][l]),e[l]<a[l]?e[l]=a[l]:e[l]>s[l]&&(e[l]=s[l])}function Ki(t,e,n,i,r,o){return a=this,s=void 0,c=function*(){const a=i.get("tolerance"),s=i.get("maxIter"),l=i.get("scaleReflaction"),c=i.get("scaleExpansion"),u=i.get("scaleContraction"),h=n.length+1,d=n.length,[f,p]=function(t,e,n,i,r){const o=n.length+1,a=n.length,s=e.get("nonZeroParam"),l=e.get("initialScale"),c=new Array(o),u=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]<i[t]?c[e][t]=i[t]:c[e][t]>r[t]&&(c[e][t]=r[t]));u[e]=t(c[e])}return[c,u]}(e,i,n,r,o),g=new Array(h);for(let t=0;t<h;t++)g[t]=t;const m=g.length-1;let y=0,v=0,w=0,b=0;const C=new Float32Array(d),_=new Float32Array(d),A=new Float32Array(d),S=new Float32Array(d),E=new Array(s);if(h>1){let n=0;for(;g.sort((t,e)=>p[t]-p[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=p[0],w=2*p[g[0]]),E[y]=v,++y,v=p[g[0]],w-v>a)b=0;else if(++b,b>2*h)break;w=v,Hi(C,d,g[m],f),ji(C,_,g[m],f,l,d,r,o);const t=e(_);if(t<p[g[m]]){ji(C,A,g[m],f,c,d,r,o);const n=e(A);if(n<t){p[g[m]]=n;for(let t=0;t<d;t++)f[g[m]][t]=A[t];continue}p[g[m]]=t;for(let t=0;t<d;t++)f[g[m]][t]=_[t];continue}ji(C,S,g[m],f,u,d,r,o);const n=e(S);if(!(n<p[g[m]]))break;p[g[m]]=n;for(let t=0;t<d;t++)f[g[m]][t]=S[t]}for(let t=y;t<s;t++)E[t]=p[g[0]]}return{optimalPoint:f[g[0]],iterations:y}},new((l=void 0)||(l=Promise))(function(t,e){function n(t){try{r(c.next(t))}catch(t){e(t)}}function i(t){try{r(c.throw(t))}catch(t){e(t)}}function r(e){var r;e.done?t(e.value):(r=e.value,r instanceof l?r:new l(function(t){t(r)})).then(n,i)}r((c=c.apply(a,s||[])).next())});var a,s,l,c}var Yi=function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((i=i.apply(t,e||[])).next())})};class qi{static isApplicable(e,n,i,o,a,s=!1){const l=n.length,c=e=>{s&&t.shell.warning(Xn+e)};if(i<ci)return c(`: too small p-value threshold - ${i}, minimum - 0.001`),!1;if(o<hi)return c(`: too small R² threshold - ${o}, minimum - 0.01`),!1;if(a<di)return c(`: too small q-cutoff - ${a}, minimum - 0.01`),!1;if(l<10)return c(`: not enough of samples - ${l}, minimum - 10`),!1;if(n.type!==r.COLUMN_TYPE.BOOL)return c(`: "${n.name}" must be boolean column.`),!1;if(0===n.stats.stdev)return c(`: "${n.name}" has a single category.`),!1;let u=0;for(const t of e){if(!t.isNumerical)return c(`: "${t.name}" is not numerical.`),!1;if(t.stats.missingValueCount>0)return c(`: "${t.name}" contains missing values.`),!1;t.stats.stdev>0&&++u}return!(u<1&&(c(": not enough of non-constant descriptors."),1))}static isTableValid(e,n=!0){if(e.rowCount<2)return n&&t.shell.warning(Xn+`. Not enough of samples: ${e.rowCount}, minimum: 2.`),!1;let i=0,o=0;for(const t of e.columns)t.isNumerical?t.stats.missingValueCount<1&&t.stats.stdev>0&&++o:t.type==r.COLUMN_TYPE.BOOL&&++i;return i<1?(n&&t.shell.warning(Xn+": no boolean columns."),!1):!(o<1&&(n&&t.shell.warning(Xn+": no numeric columns without missing values and non-zero variance."),1))}static fit(t,e,n,i,o,a,s=!0){if(s&&!qi.isApplicable(e,n,i,o,a))throw new Error("Failed to train pMPO model: the method is not applicable to the inputs");const l=e.names(),{desired:c,nonDesired:u}=xi(t,n),h=new Map;l.forEach(t=>{h.set(t,Mi(c.col(t),u.col(t)))});const d=Ii(h);!function(t,e){const n=t.col(ti);if(null==n)return;const i={};i[`<${e}`]=pi.SELECTED,i[`>=${e}`]=pi.SKIPPED,n.meta.colors.setConditional(i)}(d,i);const f=Li(d,i);if(f.length<1)throw new Wi("Cannot train pMPO model: all descriptors have high p-values (not significant).");const p=Ri(e,f),g=Di(0,f,h,o,p);return function(t,e){if(e.length<1)throw new Error("Empty list of selected descriptors.");const n=t.rowCount,i=new Array(n),o=t.col(ni);if(null==o)throw new Error(`No column "${ni} in the table with descriptors statistics.`);const a=o.toList();let s=!0;const l={};for(let t=0;t<n;++t)s=e.includes(a[t]),i[t]=s,l[a[t]]=s?pi.SELECTED:pi.SKIPPED;o.colors.setCategorical(l),t.columns.add(r.Column.fromList(r.COLUMN_TYPE.BOOL,ri,i))}(d,g),function(t,e,n,i){const o=new Map;e.forEach(t=>{o.set(t,new Float32Array(e.length).fill(r.FLOAT_NULL))});const a=t.col(ni).toList();n.forEach(t=>{const[e,n,i]=t;o.get(e)[a.indexOf(n)]=i,o.get(n)[a.indexOf(e)]=i,o.get(e)[a.indexOf(e)]=1,o.get(n)[a.indexOf(n)]=1}),i.forEach(e=>{t.columns.add(r.Column.fromFloat32Array(e,o.get(e)))})}(d,l,p,g),function(t,e,n){e.forEach(e=>{const i=t.col(e);if(null==i)return;const r={};r[`>=${n}`]=pi.SKIPPED,r[`<${n}`]=pi.SELECTED,i.meta.colors.setConditional(r)})}(d,l,o),{params:ki(c,u,g,a),descrStatsTable:d,selectedByPvalue:f,selectedByCorr:g}}static predict(t,e,n,i){const o=t.rowCount,a=new Float64Array(o).fill(0);return e.forEach((e,i)=>{const r=t.col(i),s=e.b,l=e.c,c=e.cutoff;let u=e.weight;const h=e.desAvg,d=e.desStd,f=1/(2*Math.pow(d,2));if(null==r)throw new Error(`Failed to apply pMPO: inconsistent data, no column "${i}" in the table "${t.name}"`);const p=r.getRawData();if(n)if(l>0)for(let t=0;t<o;++t)a[t]+=u*Math.exp(-Math.pow(p[t]-h,2)*f)/(1+s*Math.pow(l,-(p[t]-c)));else{u/=1+s;for(let t=0;t<o;++t)a[t]+=u*Math.exp(-Math.pow(p[t]-h,2)*f)}else for(let t=0;t<o;++t)a[t]+=u*Math.exp(-Math.pow(p[t]-h,2)*f)}),r.Column.fromFloat64Array(i,a)}constructor(e,n){var i;this.params=null,this.initTable=r.DataFrame.create(),this.statGrid=r.Viewer.grid(this.initTable,{showTitle:!0,title:ii}),this.predictionName=ai,this.boolPredictionName="",this.desirabilityProfileRoots=new Map,this.rocCurve=r.Viewer.scatterPlot(this.initTable,{showTitle:!0,showSizeSelector:!1,showColorSelector:!1}),this.confusionMatrix=r.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!==(i=t.shell.tableView(e.name))&&void 0!==i?i:t.shell.addTableView(e),this.boolCols=this.getBoolCols(),this.numericCols=this.getValidNumericCols(),this.predictionName=e.columns.getUnusedName(ai)}setRibbons(){const t=this.view.getRibbonPanels();t.length<1||this.view.setRibbonPanels(t.slice(1))}updateStatisticsGrid(t,n,i,r){const o=this.statGrid;o.dataFrame=t,o.setOptions({showTitle:!0,title:t.name}),o.sort([ri],[!1]),o.col(ti).format="scientific",o.col(ni).isTextColorCoded=!0,o.col(ti).isTextColorCoded=!0,n.forEach(t=>{const e=o.col(t);null!=e&&(e.isTextColorCoded=!0,e.format="0.000")}),o.onCellTooltip((t,a,s)=>{if(t.isColHeader){const i=t.tableColumn;if(null==i)return!1;const r=i.name;switch(r){case ni:return e.tooltip.show(Oi(ni,"Use of descriptors in model construction:","selected","excluded"),a,s),!0;case si:return e.tooltip.show(e.divV([e.h2(si),e.divText("Desirability profile charts for each descriptor. Only profiles for selected descriptors are shown.")]),a,s),!0;case oi:return e.tooltip.show(e.divV([e.h2(oi),e.divText("Weights of selected descriptors.")]),a,s),!0;case ti:return e.tooltip.show(Oi(ti,"Filtering descriptors by p-value:","selected","excluded"),a,s),!0;default:return!!n.includes(r)&&(e.tooltip.show(Oi(r,`Correlation of ${r} with other descriptors, measured by R²:`,"weakly correlated","highly correlated"),a,s),!0)}}else if(t.isTableCell){const l=t.tableColumn;if(null==l)return!1;const c=l.name,u=t.value;if(c===ni)return r.includes(u)?e.tooltip.show("Selected for model construction.",a,s):i.includes(u)?e.tooltip.show("Excluded due to a high correlation with other descriptors.",a,s):e.tooltip.show("Excluded due to a high p-value.",a,s),!0;{const r=o.cell(ni,t.gridRow).value;if(c===oi)return!this.desirabilityProfileRoots.has(r)&&(i.includes(r)?e.tooltip.show(`No weight: <b>${r}</b> is excluded due to a high correlation with other descriptors.`,a,s):e.tooltip.show(`No weight: <b>${r}</b> is excluded due to a high p-value.`,a,s),!0);if(n.includes(c)&&!i.includes(r))return e.tooltip.show(`<b>${r}</b> is excluded due to a high p-value; so correlation with <b>${c}</b> is not needed.`,a,s),!0}return!1}});const a=o.col(si);o.setOptions({rowHeight:75}),a.width=305,a.cellType="html",o.onCellPrepare(t=>{if(null==t.tableColumn)return;if(null==t.tableColumn)return;if(!t.isTableCell)return;if(t.tableColumn.name!==si)return;const n=o.cell(ni,t.gridRow).value,r=this.desirabilityProfileRoots.get(n);if(null!=r)t.element=r;else{const r=i.includes(n),o=r?"highly correlated with other descriptors":"statistically insignificant",a=r?`No chart shown: <b>${n}</b> is excluded due to a high correlation with other descriptors.`:`No chart shown: <b>${n}</b> is excluded due to a high p-value.`,s=e.divText(o);s.style.color=pi.SKIPPED,s.classList.add("eda-pmpo-centered-text"),e.tooltip.bind(s,a),t.element=s}})}updateGrid(){const t=this.view.grid,n=this.predictionName;t.sort([this.predictionName],[!1]),t.col(n).format="0.0000",t.onCellTooltip((t,i,r)=>{if(t.isColHeader&&t.tableColumn)return t.tableColumn.name===n&&(e.tooltip.show(e.divV([e.h2(ai),e.divText("Scores computed using the trained probabilistic multi-parameter optimization (pMPO) model."),On(An.MAX,!1)]),i,r),!0)})}updateDesirabilityProfileData(t,e){if(null==this.params)return;this.desirabilityProfileRoots.forEach(t=>t.remove()),this.desirabilityProfileRoots.clear();const n=Gi(this.params,e,"","",!0),i=t.col(ni).toList(),r=t.col(oi).getRawData(),o=n.properties;for(const t of Object.keys(o))r[i.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 i=n[0].innerText;this.desirabilityProfileRoots.set(i,e[2])})}updateRocCurve(t,e){const n=Ti(t,e),i=r.DataFrame.fromColumns([r.Column.fromFloat32Array("Threshold",_i),r.Column.fromFloat32Array(bi,n.fpr),r.Column.fromFloat32Array(wi,n.tpr)]);return i.meta.formulaLines.addLine({title:"Non-informative baseline",formula:`\${${wi}} = \${${bi}}`,width:1,style:"dashed",min:0,max:1}),this.rocCurve.dataFrame=i,this.rocCurve.setOptions({xColumnName:bi,yColumnName:wi,linesOrderColumnName:bi,linesWidth:5,markerType:"dot",title:`ROC Curve (AUC = ${n.auc.toFixed(3)})`}),n.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(t,e,n,i,o,a,s){const l=qi.fit(t,e,n,i,o,a);this.params=l.params;const c=l.descrStatsTable,u=l.selectedByPvalue,h=l.selectedByCorr,d=e.names(),f=qi.predict(t,this.params,s,this.predictionName);f.colors.setLinear(Ln(An.MAX),{min:f.stats.min,max:f.stats.max}),t.columns.remove(this.predictionName),t.columns.add(f),this.updateGrid(),this.updateDesirabilityProfileData(c,s),this.updateStatisticsGrid(c,d,u,h);const p=this.updateRocCurve(n,f),g=n.name;t.columns.remove(this.boolPredictionName),this.boolPredictionName=t.columns.getUnusedName(g+"(predicted)");const m=function(t,e,n){if(!t.isNumerical)throw new Error("Failed to compute confusion matrix: prediction column must be numerical.");const i=t.length,o=new Array(i),a=t.getRawData();for(let t=0;t<i;++t)o[t]=a[t]>=e;return r.Column.fromList(r.COLUMN_TYPE.BOOL,n,o)}(f,p,this.boolPredictionName);t.columns.add(m),this.updateConfusionMatrix(t,g,p),this.view.dataFrame.selection.setAll(!1,!0)}runTrainingApp(){const t=this.view.dockManager;t.dock(this.getInputForm(!0).form,r.DOCK_TYPE.LEFT,null,void 0,.1);const e=t.findNode(this.view.grid.root);if(null==e)throw new Error("Failed to train pMPO: missing a grid in the table view.");const n=t.dock(this.statGrid,r.DOCK_TYPE.DOWN,e,void 0,.5),i=t.dock(this.rocCurve,r.DOCK_TYPE.RIGHT,n,void 0,.3);t.dock(this.confusionMatrix,r.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(n){const i=e.form([]);i.append(e.h2("Training data"));const o=this.numericCols.map(t=>t.name),a=()=>{try{this.fitAndUpdateViewers(this.table,r.DataFrame.fromColumns(s.value).columns,this.table.col(l.value),m.value,y.value,v.value,u.value)}catch(e){e instanceof Wi?t.shell.warning(e.message):t.shell.error(e instanceof Error?e.message:$n+": the platform issue.")}},s=e.input.columns("Descriptors",{table:this.table,nullable:!1,available:o,checked:o,tooltipText:"Descriptor columns used for model construction.",onValueChanged:t=>{null!=t&&(d=!1,p())}});i.append(s.root);const l=e.input.choice("Desirability",{nullable:!1,value:this.boolCols[0].name,items:this.boolCols.map(t=>t.name),tooltipText:"Desirability column.",onValueChanged:t=>{null!=t&&(d=!1,p())}});i.append(l.root);const c=e.h2("Settings");i.append(c),e.tooltip.bind(c,"Settings of the pMPO model.");const u=e.input.bool("σ correction",{value:!0,tooltipText:"Use the sigmoidal correction to the weighted Gaussian scores.",onValueChanged:t=>{d=!1,p()}});i.append(u.root);const h=this.table.rowCount<=1e4;let d=!1;const f=()=>Yi(this,void 0,void 0,function*(){if(!d){const t=yield this.getOptimalSettings(r.DataFrame.fromColumns(s.value).columns,this.table.col(l.value),u.value);t.success?(m.value=Math.max(t.pValTresh,ci),y.value=Math.max(t.r2Tresh,hi),v.value=Math.max(t.qCutoff,di),d=!0):g.value=!1}a()}),p=()=>{g.value?f():a()},g=e.input.bool("Auto-tuning",{value:!1,tooltipText:"Automatically select optimal p-value, R², and q-cutoff by maximizing AUC.",onValueChanged:t=>Yi(this,void 0,void 0,function*(){w(!t),d||t&&(yield f())})});i.append(g.root);const m=e.input.float("p-value",{nullable:!1,min:ci,max:1,step:.001,value:li,format:fi,tooltipText:"P-value threshold. Descriptors with p-values above this threshold are excluded.",onValueChanged:t=>{g.value||(d=!1,null!=t&&t>=ci&&t<=1&&a())}});i.append(m.root);const y=e.input.float("R²",{format:fi,nullable:!1,min:hi,value:.53,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=>{g.value||(d=!1,null!=t&&t>=hi&&t<=1&&a())}});i.append(y.root);const v=e.input.float("q-cutoff",{format:fi,nullable:!1,min:di,value:.05,max:1,step:.01,tooltipText:"Q-cutoff for the pMPO model computation.",onValueChanged:t=>{g.value||(d=!1,null!=t&&t>=di&&t<=1&&a())}});i.append(v.root);const w=t=>{m.enabled=t,y.enabled=t,v.enabled=t};setTimeout(()=>{a(),h?g.value=!0:a()},10);const b=e.button("Save",()=>Yi(this,void 0,void 0,function*(){null!=this.params?function(n,i,r){Fi(this,void 0,void 0,function*(){let o=i;const a=e.input.string("File",{value:o,nullable:!1,onValueChanged:t=>{o=t,p.getButton("Save").disabled=o.length<1||s.length<1}});let s="System:AppData/Chem/mpo";const l=e.input.string("Folder",{value:s,nullable:!1,onValueChanged:t=>{s=t,p.getButton("Save").disabled=o.length<1||s.length<1}}),c=()=>Fi(this,void 0,void 0,function*(){const e=`${s}/${o}.json`;try{const n=JSON.stringify(u(),null,2);yield t.dapi.files.writeAsText(e,n),t.shell.info(`Saved to ${e}`)}catch(e){t.shell.error(`Failed to save: ${e instanceof Error?e.message:"the platform issue"}.`)}p.close()}),u=()=>f.value?Gi(n,r,a.value,d.value,!1):{type:"Probabilistic MPO Model",name:a.value,description:d.value,properties:Object.fromEntries(n)},h=e.input.string("Name",{value:i,nullable:!0}),d=e.input.textArea("Description",{value:" ",nullable:!0}),f=e.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."}),p=e.dialog({title:"Save model"}).add(e.h2("Path")).add(l).add(a).add(e.h2("Model")).add(h).add(d).add(f).addButton("Save",()=>Fi(this,void 0,void 0,function*(){(yield t.dapi.files.exists(`${s}/${o}.json`))?e.dialog({title:"Warning"}).add(e.label("Overwrite existing file?")).onOK(()=>Fi(this,void 0,void 0,function*(){return yield c()})).show():yield c()})).show()})}(this.params,this.table.name,u.value):t.shell.warning("Failed to save pMPO model: null parameters.")}),"Save model as platform file.");n&&i.append(b);const C=e.div([i]);return C.classList.add("eda-pmpo-input-form"),{form:C,saveBtn:b}}getBoolCols(){const t=[];for(const e of this.table.columns)e.type===r.COLUMN_TYPE.BOOL&&e.stats.stdev>0&&t.push(e);return t}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(t,e,n){return Yi(this,void 0,void 0,function*(){const i={pValTresh:0,r2Tresh:0,qCutoff:0,success:!1},o=t.names(),{desired:a,nonDesired:s}=xi(this.table,e),l=new Map;o.forEach(t=>{l.set(t,Mi(a.col(t),s.col(t)))});const c=Li(Ii(l),li);if(c.length<1)return i;const u=Ri(t,c),h=t=>{const i=Di(0,c,l,t[0],u),r=ki(a,s,i,t[1]),o=qi.predict(this.table,r,n,this.predictionName);return 1-Ti(e,o).auc},d=r.TaskBarProgressIndicator.create("Optimizing... ",{cancelable:!0});try{const t=yield Ki(d,h,new Float32Array([.53,.05]),Ai,Si,Ei),e=!d.canceled;return d.close(),e?{pValTresh:li,r2Tresh:t.optimalPoint[0],qCutoff:t.optimalPoint[1],success:!0}:i}catch(t){return d.close(),i}})}}class Xi{constructor(t,e,n,i){this.sourceDf=t,this.drugName=e,this.desirabilityColName=n,this.smilesColName=i;const r=t.columns.toList().filter(t=>t.isNumerical).map(t=>t.name),{desired:o,nonDesired:a}=xi(t,t.col(n));this.descriptorStats=new Map,r.forEach(t=>{this.descriptorStats.set(t,Mi(o.col(t),a.col(t)))}),this.desiredProbability=o.rowCount/t.rowCount}getGenerated(t){if(t<=1)throw new Error("Failed to generate pMPO data: sample count must be greater than 1.");let e;if(t<=this.sourceDf.rowCount){const n=r.BitSet.create(this.sourceDf.rowCount);for(let e=0;e<t;++e)n.set(e,!0);e=this.sourceDf.clone(n)}else e=this.getClonedSourceDfWithFloatNumericCols().append(this.getSyntheticTable(t-this.sourceDf.rowCount));for(const t of e.columns)if(t.type===r.COLUMN_TYPE.BOOL&&0===t.stats.stdev){let e=t.get(0);t.set(0,!e),e=t.get(1),t.set(1,!e)}return e}getSyntheticTable(t){const e=new Array(t);for(let n=0;n<t;++n)e[n]=Math.random()<this.desiredProbability;const n=[this.getDrugColumn(t),this.getSmilesColumn(t),r.Column.fromList(r.COLUMN_TYPE.BOOL,this.desirabilityColName,e)];return this.descriptorStats.forEach((i,o)=>{const a=new Float32Array(t);for(let n=0;n<t;++n)e[n]?a[n]=Ct.normal.sample(i.desAvg,i.desStd):a[n]=Ct.normal.sample(i.nonDesAvg,i.nonDesStd);n.push(r.Column.fromFloat32Array(o,a))}),r.DataFrame.fromColumns(n)}getDrugColumn(t){return r.Column.fromList(r.COLUMN_TYPE.STRING,this.drugName,Array.from({length:t},(t,e)=>`Synthetic drug ${e+1}`))}getSmilesColumn(t){return r.Column.fromList(r.COLUMN_TYPE.STRING,this.smilesColName,Array.from({length:t},()=>"C"))}getClonedSourceDfWithFloatNumericCols(){const t=[];this.sourceDf.columns.toList().forEach(e=>{e.isNumerical?t.push(e.clone().convertTo(r.COLUMN_TYPE.FLOAT)):t.push(e.clone())});const e=r.DataFrame.fromColumns(t);return e.name=this.sourceDf.name,e}}var $i=function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((i=i.apply(t,e||[])).next())})};function Qi(){lo.info()}function Ji(){return $i(this,void 0,void 0,function*(){yield lo.init()})}function Zi(t,e,n,i,r){return $i(this,void 0,void 0,function*(){return yield lo.dbScan(t,e,n,i,r)})}function tr(t,e,n,i,r){return $i(this,void 0,void 0,function*(){yield lo.PCA(t,e,n,i,r)})}function er(t,e,n,i){return $i(this,void 0,void 0,function*(){yield lo.dbscanPostProcessingFunction(t,e,n,i)})}function nr(t,e){return lo.numberPreprocessingFunction(t,e)}function ir(t,e){return lo.stringPreprocessingFunction(t,e)}function rr(){return $i(this,void 0,void 0,function*(){yield lo.reduceDimensionality()})}function or(t){lo.GetMCLEditor(t)}function ar(t,e,n,i,r,o,a,s,l,c,u,h){return $i(this,void 0,void 0,function*(){return yield lo.MCLClustering(t,e,n,i,r,o,a,s,l,c,u,h)})}function sr(){return lo.markovClusteringViewer()}function lr(t,e,n,i,r){return $i(this,void 0,void 0,function*(){return yield lo.PLS(t,e,n,i,r)})}function cr(){return $i(this,void 0,void 0,function*(){yield lo.topMenuPLS()})}function ur(){return $i(this,void 0,void 0,function*(){yield lo.MVA()})}function hr(){return $i(this,void 0,void 0,function*(){yield lo.demoMultivariateAnalysis()})}function dr(t,e,n){return $i(this,void 0,void 0,function*(){return yield lo.trainLinearKernelSVM(t,e,n)})}function fr(t,e){return $i(this,void 0,void 0,function*(){return yield lo.applyLinearKernelSVM(t,e)})}function pr(t,e){return $i(this,void 0,void 0,function*(){return yield lo.isApplicableLinearKernelSVM(t,e)})}function gr(t,e){return $i(this,void 0,void 0,function*(){return yield lo.isInteractiveLinearKernelSVM(t,e)})}function mr(t,e,n,i){return $i(this,void 0,void 0,function*(){return yield lo.visualizeLinearKernelSVM(t,e,n,i)})}function yr(t,e,n,i){return $i(this,void 0,void 0,function*(){return yield lo.trainRBFkernelSVM(t,e,n,i)})}function vr(t,e){return $i(this,void 0,void 0,function*(){return yield lo.applyRBFkernelSVM(t,e)})}function wr(t,e){return $i(this,void 0,void 0,function*(){return yield lo.isApplicableRBFkernelSVM(t,e)})}function br(t,e){return $i(this,void 0,void 0,function*(){return yield lo.isInteractiveRBFkernelSVM(t,e)})}function Cr(t,e,n,i){return $i(this,void 0,void 0,function*(){return yield lo.visualizeRBFkernelSVM(t,e,n,i)})}function _r(t,e,n,i,r){return $i(this,void 0,void 0,function*(){return yield lo.trainPolynomialKernelSVM(t,e,n,i,r)})}function Ar(t,e){return $i(this,void 0,void 0,function*(){return yield lo.applyPolynomialKernelSVM(t,e)})}function Sr(t,e){return $i(this,void 0,void 0,function*(){return yield lo.isApplicablePolynomialKernelSVM(t,e)})}function Er(t,e){return $i(this,void 0,void 0,function*(){return yield lo.isInteractivePolynomialKernelSVM(t,e)})}function xr(t,e,n,i){return $i(this,void 0,void 0,function*(){return yield lo.visualizePolynomialKernelSVM(t,e,n,i)})}function Mr(t,e,n,i,r){return $i(this,void 0,void 0,function*(){return yield lo.trainSigmoidKernelSVM(t,e,n,i,r)})}function Pr(t,e){return $i(this,void 0,void 0,function*(){return yield lo.applySigmoidKernelSVM(t,e)})}function Nr(t,e){return $i(this,void 0,void 0,function*(){return yield lo.isApplicableSigmoidKernelSVM(t,e)})}function Tr(t,e){return $i(this,void 0,void 0,function*(){return yield lo.isInteractiveSigmoidKernelSVM(t,e)})}function Fr(t,e,n,i){return $i(this,void 0,void 0,function*(){return yield lo.visualizeSigmoidKernelSVM(t,e,n,i)})}function Ir(){lo.anova()}function Lr(){lo.kNNImputation()}function Or(t){return $i(this,void 0,void 0,function*(){yield lo.kNNImputationForTable(t)})}function Rr(t,e){return $i(this,void 0,void 0,function*(){return yield lo.trainLinearRegression(t,e)})}function Dr(t,e){return lo.applyLinearRegression(t,e)}function kr(t,e){return lo.isApplicableLinearRegression(t,e)}function Gr(t,e){return lo.isInteractiveLinearRegression(t,e)}function Ur(t,e,n,i,r,o){return $i(this,void 0,void 0,function*(){return yield lo.trainSoftmax(t,e,n,i,r,o)})}function Br(t,e){return lo.applySoftmax(t,e)}function Vr(t,e){return lo.isApplicableSoftmax(t,e)}function zr(t,e){return lo.isInteractiveSoftmax(t,e)}function Wr(t,e,n){return $i(this,void 0,void 0,function*(){return yield lo.trainPLSRegression(t,e,n)})}function Hr(t,e){return lo.applyPLSRegression(t,e)}function jr(t,e){return lo.isApplicablePLSRegression(t,e)}function Kr(t,e,n,i){return $i(this,void 0,void 0,function*(){return yield lo.visualizePLSRegression(t,e,n,i)})}function Yr(t,e){return lo.isInteractivePLSRegression(t,e)}function qr(t,e,n,i,r,o,a){return $i(this,void 0,void 0,function*(){return yield lo.trainXGBooster(t,e,n,i,r,o,a)})}function Xr(t,e){return lo.applyXGBooster(t,e)}function $r(t,e){return lo.isInteractiveXGBooster(t,e)}function Qr(t,e){return lo.isApplicableXGBooster(t,e)}function Jr(){lo.paretoFront()}function Zr(){return lo.paretoFrontViewer()}function to(){lo.trainPmpo()}function eo(t){return lo.getPmpoAppItems(t)}function no(t){return $i(this,void 0,void 0,function*(){return yield lo.generatePmpoDataset(t)})}var io=function(t,e,n,i){var r,o=arguments.length,a=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,i);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(a=(o<3?r(a):o>3?r(e,n,a):r(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a},ro=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},oo=function(t,e){return function(n,i){e(n,i,t)}},ao=function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((i=i.apply(t,e||[])).next())})};const so=new r.Package;class lo{static info(){t.shell.info(so.webRoot)}static init(){return ao(this,void 0,void 0,function*(){yield async function(){await initEDA()}(),yield async function(){await initXGBoostModule()}()})}static dbScan(t,e,n,i,o){return ao(this,void 0,void 0,function*(){const a=e.getRawData(),s=n.getRawData(),l=yield Wt(a,s,i,o),c=t.columns.getUnusedName("Cluster (DBSCAN)"),u=r.Column.fromInt32Array(c,l);return t.columns.add(u),u})}static PCA(e,n,i,r,o){return ao(this,void 0,void 0,function*(){try{const a=yield V(e,n,i,r,o);if(function(t,e){for(const t of e.toList())t.name="PC"+t.name}(0,a.columns),null===e.id)t.shell.addTableView(a);else{const t=e.columns,n=a.columns.toList();for(const e of n)a.columns.remove(e.name),e.name=t.getUnusedName(e.name),t.add(e)}}catch(e){t.shell.warning(`Failed to compute PCA: ${e instanceof Error?e.message:"platform issue"}`)}})}static dbscanPostProcessingFunction(e,n,i,o){return ao(this,void 0,void 0,function*(){const a=e.dataFrame;if(null===a)return;const s=yield lo.dbScan(a,e,n,i,o);a.changeColumnType(s,"string");const l=[e.name,n.name],c=t.shell.tableView(a.name);if(c)for(const t of c.viewers)if(t instanceof r.ScatterPlotViewer&&l.includes(t.props.xColumnName)&&l.includes(t.props.yColumnName))return void(t.props.colorColumnName=s.name)})}static numberPreprocessingFunction(t,e){const n=t.stats.max-t.stats.min;return{entries:t.toList(),options:{range:n}}}static stringPreprocessingFunction(t,e){return{entries:t.toList(),options:{}}}static reduceDimensionality(){return ao(this,void 0,void 0,function*(){const i=new Xe,o=e.dialog("Reduce Dimensionality").add(i.getEditor()).onOK(()=>ao(this,void 0,void 0,function*(){const o=i.getParams();0!==o.columns.length&&(yield async function(i,o,a,s,l,c,u,h=!0,d=!1,f={preprocessingFuncArgs:[]},p={},g=null,m={},y){const v={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(o.length!==s.length||o.length!==c.length||o.length!==l.length||o.length!==f.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const w=h?p.tableView??t.shell.tableView(i.name)??t.shell.addTableView(i):null,b=async()=>{const b=r.TaskBarProgressIndicator.create(`Initializing ${p.scatterPlotName??"dimensionality reduction"} ...`);let C;try{const _=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}`)}(i);function A(t,n,s){let l=null,c=null;i.columns.names().includes(_[0])?(l=i.columns.byName(_[0]),c=i.columns.byName(_[1])):(l=i.columns.add(r.Column.float(_[0],i.rowCount)),c=i.columns.add(r.Column.float(_[1],i.rowCount)),h&&!C&&(C=w.scatterPlot({...v,x:_[0],y:_[1],title:p.scatterPlotName??en(o,a)}))),p["show-scatterplot-progress"]&&(C?.root&&e.setUpdateIndicator(C.root,!1),l.init(t=>s[0]?s[0][t]:void 0),c.init(t=>s[1]?s[1][t]:void 0));const u=t/n*100;b.update(u,`Running ${p.scatterPlotName??"dimensionality reduction"}... ${u.toFixed(0)}%`)}async function S(){i.columns.add(r.Column.float(_[0],i.rowCount)),i.columns.add(r.Column.float(_[1],i.rowCount));let d=null;h&&(C=w.scatterPlot({...v,x:_[0],y:_[1],title:p.scatterPlotName??en(o,a)}),e.setUpdateIndicator(C.root,!0));const g=t.events.onViewerClosed.subscribe(e=>{const n=e.args.viewer;n?.getOptions()?.look?.title&&C?.getOptions()?.look?.title&&n?.getOptions()?.look?.title===C?.getOptions()?.look?.title&&(t.events.fireCustomEvent(Ze,{}),g.unsubscribe(),d?.(),b.close())}),m=new Promise(async(e,r)=>{try{d=e;const r=[];let h=s,g=l,m=u;if(y&&o.every(t=>t.isNumerical)){const t=o.map(t=>t.toList()),e=new Array(i.rowCount).fill(0).map((t,e)=>new Float32Array(o.length));for(let n=0;n<o.length;++n)for(let r=0;r<i.rowCount;++r)e[r][n]=t[n][r];f.distanceFnArgs=[{}],r.push({entries:e,options:{}}),h=[y],g=[1],m="MANHATTAN"}else for(let t=0;t<c.length;++t){const e=c[t];if(f.distanceFnArgs||(f.distanceFnArgs=[]),e){const n=e.inputs[0].name,i=e.inputs[1].name,{entries:a,options:l}=await e.apply({[n]:o[t],[i]:s[t],...f.preprocessingFuncArgs[t]??{}});r.push({entries:a,options:l}),f.distanceFnArgs.push(l)}else{const e=o[t].toList(),n={};r.push({entries:e,options:n}),f.distanceFnArgs.push(n)}}e(await async function(e,i,r,o,a,s,l){let c=await async function(e,i,r,o,a,s,l){if(!s.distanceFnArgs)throw new Error("options.distanceFnArgs must be defined");if(e.length!==i.length||e.length!==s.distanceFnArgs.length||e.length!==o.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise(function(c,u){const h=new Worker(new URL(n.p+n.u(234),n.b));h.postMessage({columnsData:e,distanceMetrics:i,method:r,options:s,weights:o,aggregationMethod:a});const d=t.events.onCustomEvent(Ze).subscribe(()=>{try{h?.terminate()}finally{d.unsubscribe()}});h.onmessage=({data:{error:t,embedding:e,epochNum:n,epochsLength:i}})=>{tn(n)||tn(i)?(d.unsubscribe(),t?u(t):c(e),setTimeout(()=>h.terminate(),100)):l&&l(n,i,e)}})}(e,r,i,o,a,s,l);return c=c.map(t=>function(t){const e=t.length;let n=0,i=0;for(let r=0;r<e;++r)n+=t[r],i+=Math.pow(t[r],2);const r=n/e,o=1/Math.sqrt(i/e-Math.pow(r,2));for(let n=0;n<e;++n)t[n]=(t[n]-r)*o;return t}(t)),c}(r.map(t=>t.entries),a,h,g,u,f,p[re]?void 0:A))}catch(t){r(t)}}),S=await m;return b.close(),g.unsubscribe(),S}const E=await S();if(d&&E){const x=r.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const M=await Wt(E[0],E[1],f.dbScanEpsilon??.01,f.dbScanMinPts??4),P=i.columns.getUnusedName("Cluster (DBSCAN)");i.columns.addNewString(P).init(t=>M[t].toString()),C&&(C.props.colorColumnName=P)}catch(N){t.shell.error("Clustering embeddings failed"),console.error(N)}finally{x.close()}}if(E){const T=i.columns.byName(_[0]),F=i.columns.byName(_[1]);if(T.init(t=>E[0][t]),F.init(t=>E[1][t]),g)try{const I=g.inputs[0].name,L=g.inputs[1].name;await g.prepare({[I]:T,[L]:F,...m}).call(!0)}catch(O){t.shell.error("Post-processing failed"),console.error(O)}if(C)return e.setUpdateIndicator(C.root,!1),C.helpUrl="/help/compute/sequence-space",C}}catch(R){t.shell.error("Dimensionality reduction failed"),console.error(R),b.close(),C&&e.setUpdateIndicator(C.root,!1)}};return new Promise(async(t,n)=>{try{if(p.fastRowCount&&i.rowCount>p.fastRowCount&&!p[re])e.dialog().add(e.divText("Analysis might take several minutes. Do you want to continue?")).onOK(async()=>{try{const e=await b();t(e)}catch(t){n(t)}}).onCancel(()=>t(void 0)).show();else{const e=await b();t(e)}}catch(t){n(t)}})}(o.table,o.columns,o.methodName,o.distanceMetrics,o.weights,o.preprocessingFunctions,o.aggreaggregationMethod,!!o.plotEmbeddings,!!o.clusterEmbeddings,o.options,{fastRowCount:1e4},o.postProcessingFunction,o.postProcessingFunctionArgs,o.vectorDistanceMetric))})).show();o.helpUrl="https://datagrok.ai/help/explore/dim-reduction.md";const a=()=>{const t=i.columnsInput.value,e=o.getButton("OK");e&&(t&&0!==t.length?e.classList.remove("disabled"):e.classList.add("disabled"))};o.history(()=>({editorSettings:i.getStringInput()}),t=>i.applyStringInput(t.editorSettings)),i.onColumnsChanged.subscribe(()=>{try{a()}catch(t){console.error(t)}}),a()})}static GetMCLEditor(n){try{const t=new rn;e.dialog("Markov clustering").add(t.getEditor()).onOK(()=>ao(this,void 0,void 0,function*(){const e=t.params;return n.func.prepare({df:e.table,cols:e.columns,metrics:e.distanceMetrics,weights:e.weights,aggregationMethod:e.aggreaggregationMethod,preprocessingFuncs:e.preprocessingFunctions,preprocessingFuncArgs:e.preprocessingFuncArgs,threshold:e.threshold,maxIterations:e.maxIterations,useWebGPU:e.useWebGPU,inflate:e.inflateFactor,minClusterSize:e.minClusterSize}).call(!0)})).show().history(()=>({editorSettings:t.getStringInput()}),e=>t.applyStringInput(e.editorSettings))}catch(e){const n=e instanceof Error?e.message:e.toString(),i=e instanceof Error?e.stack:void 0;t.shell.error(`Get region editor error: ${n}`),so.logger.error(n,void 0,i)}}static MCLClustering(e,n,i,r,o,a,s){return ao(this,arguments,void 0,function*(e,n,i,r,o,a,s,l=80,c=10,u=!1,h=0,d=5){var f;const p=null!==(f=t.shell.tableView(e.name))&&void 0!==f?f:t.shell.addTableView(e),g=JSON.stringify({cols:n.map(t=>t.name),metrics:i,weights:r,aggregationMethod:o,preprocessingFuncs:a.map(t=>{var e;return null!==(e=null==t?void 0:t.name)&&void 0!==e?e:null}),preprocessingFuncArgs:s,threshold:l,maxIterations:c,useWebGPU:u,inflate:h,minClusterSize:null!=d?d:5});return p.addViewer("MCL",{mclProps:g})})}static markovClusteringViewer(){return new an}static PLS(t,e,n,i,r){return ao(this,void 0,void 0,function*(){return yield vt({table:t,features:e,predict:n,components:i,isQuadratic:!1,names:r})})}static topMenuPLS(){return ao(this,void 0,void 0,function*(){yield wt(it.COMPUTE_COMPONENTS)})}static MVA(){return ao(this,void 0,void 0,function*(){yield wt(it.PERFORM_MVA)})}static demoMultivariateAnalysis(){return ao(this,void 0,void 0,function*(){yield function(){return gt(this,void 0,void 0,function*(){t.shell.addTableView(r.DataFrame.fromColumns([r.Column.fromStrings("model",["alfaromeo","audi","bmw","chevrolet","dodge1","dodge2","honda1","honda2","isuzu","jaguar","mazda","mercedes","mercury","mitsubishi","nissan1","nissan2","peugot","plymouth","porsche","saab","subaru","toyota1","toyota2","toyota3","toyota4","volkswagen1","volkswagen2","volvo1","volvo2","volvo3"]),r.Column.fromInt32Array("diesel",new Int32Array([0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,1,0,0,0,1])),r.Column.fromInt32Array("turbo",new Int32Array([0,0,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,1])),r.Column.fromInt32Array("two.doors",new Int32Array([1,0,1,0,1,0,1,0,0,0,0,0,1,1,0,1,0,0,1,0,0,1,0,1,0,1,0,0,0,0])),r.Column.fromInt32Array("hatchback",new Int32Array([1,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0])),r.Column.fromFloat32Array("wheel.base",new Float32Array([94.5,105.80000305175781,101.19999694824219,94.5,93.69999694824219,93.69999694824219,93.69999694824219,96.5,94.30000305175781,113,93.0999984741211,115.5999984741211,102.69999694824219,93.69999694824219,94.5,94.5,93.69999694824219,114.19999694824219,89.5,99.0999984741211,97.19999694824219,95.69999694824219,95.69999694824219,98.4000015258789,102.4000015258789,97.30000305175781,100.4000015258789,104.30000305175781,109.0999984741211,109.0999984741211])),r.Column.fromFloat32Array("length",new Float32Array([171.1999969482422,192.6999969482422,176.8000030517578,158.8000030517578,157.3000030517578,157.3000030517578,150,175.39999389648438,170.6999969482422,199.60000610351562,166.8000030517578,202.60000610351562,178.39999389648438,157.3000030517578,170.1999969482422,165.3000030517578,157.3000030517578,198.89999389648438,168.89999389648438,186.60000610351562,172,158.6999969482422,166.3000030517578,176.1999969482422,175.60000610351562,171.6999969482422,180.1999969482422,188.8000030517578,188.8000030517578,188.8000030517578])),r.Column.fromFloat32Array("width",new Float32Array([65.5,71.4000015258789,64.80000305175781,63.599998474121094,63.79999923706055,63.79999923706055,64,65.19999694824219,61.79999923706055,69.5999984741211,64.19999694824219,71.69999694824219,68,64.4000015258789,63.79999923706055,63.79999923706055,63.79999923706055,68.4000015258789,65,66.5,65.4000015258789,63.599998474121094,64.4000015258789,65.5999984741211,66.5,65.5,66.9000015258789,67.19999694824219,68.80000305175781,68.9000015258789])),r.Column.fromFloat32Array("height",new Float32Array([52.400001525878906,55.70000076293945,54.29999923706055,52,50.79999923706055,50.599998474121094,52.599998474121094,54.099998474121094,53.5,52.79999923706055,54.099998474121094,56.29999923706055,54.79999923706055,50.79999923706055,53.5,54.5,50.599998474121094,58.70000076293945,51.599998474121094,56.099998474121094,52.5,54.5,53,52,54.900001525878906,55.70000076293945,55.099998474121094,56.20000076293945,55.5,55.5])),r.Column.fromInt32Array("curb.weight",new Int32Array([2823,2844,2395,1909,2128,1967,1956,2304,2337,4066,1950,3770,2910,1918,2024,1951,1967,3430,2800,2695,2190,1985,2275,2551,2480,2261,2661,2912,3049,3217])),r.Column.fromInt32Array("eng.size",new Int32Array([152,136,108,90,98,90,92,110,111,258,91,183,140,92,97,97,90,152,194,121,108,92,110,146,110,97,136,141,141,145])),r.Column.fromInt32Array("horsepower",new Int32Array([154,110,101,70,102,68,76,86,78,176,68,123,175,68,69,69,68,95,207,110,82,62,56,116,73,52,110,114,160,106])),r.Column.fromInt32Array("peak.rpm",new Int32Array([5e3,5500,5800,5400,5500,5500,6e3,5800,4800,4750,5e3,4350,5e3,5500,5200,5200,5500,4150,5900,5250,4400,4800,4500,4800,4500,4800,5500,5400,5300,4800])),r.Column.fromInt32Array("symbol",new Int32Array([1,1,2,0,1,1,1,0,0,0,1,-1,1,2,1,1,1,0,3,2,0,1,0,2,-1,2,0,-2,-1,-1])),r.Column.fromInt32Array("city.mpg",new Int32Array([19,19,23,38,24,31,30,27,24,15,31,22,19,37,31,31,31,25,17,21,28,35,34,24,30,37,19,23,19,26])),r.Column.fromInt32Array("highway.mpg",new Int32Array([26,25,29,43,30,38,34,33,29,19,38,25,24,41,37,37,38,25,25,28,33,39,36,30,33,46,24,28,25,27])),r.Column.fromInt32Array("price",new Int32Array([16500,17710,16430,6575,7957,6229,7129,8845,6785,35550,7395,31600,16503,5389,7349,7299,6229,13860,37028,12170,7775,5348,7898,9989,10698,7775,13295,12940,19045,22470]))])),t.shell.windows.help.visible=!0,t.shell.windows.help.showHelp(e.markdown("# Data\nEach car has many features - patterns extraction is complicated.\n\n# Model\nPredict car price by its other features.\n\n# Try\nPress 'RUN' to perform multivariate analysis using partial least squares\n([PLS](https://en.wikipedia.org/wiki/Partial_least_squares_regression)) regression.\n\n# Essence\nThe method finds the latent factors that\n\n* capture the maximum variance in the features\n* maximize correlation with the response variable")),t.shell.windows.showContextPanel=!1,t.shell.windows.showProperties=!1,yield wt(it.DEMO)})}()})}static trainLinearKernelSVM(t,e,n){return ao(this,void 0,void 0,function*(){return J(yield $({gamma:n,kernel:0},t,e))})}static applyLinearKernelSVM(t,e){return ao(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicableLinearKernelSVM(t,e){return ao(this,void 0,void 0,function*(){return et(t,e)})}static isInteractiveLinearKernelSVM(t,e){return ao(this,void 0,void 0,function*(){return nt(t)})}static visualizeLinearKernelSVM(t,e,n,i){return ao(this,void 0,void 0,function*(){return Q(0,i)})}static trainRBFkernelSVM(t,e,n,i){return ao(this,void 0,void 0,function*(){return J(yield $({gamma:n,kernel:2,sigma:i},t,e))})}static applyRBFkernelSVM(t,e){return ao(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicableRBFkernelSVM(t,e){return ao(this,void 0,void 0,function*(){return et(t,e)})}static isInteractiveRBFkernelSVM(t,e){return ao(this,void 0,void 0,function*(){return nt(t)})}static visualizeRBFkernelSVM(t,e,n,i){return ao(this,void 0,void 0,function*(){return Q(0,i)})}static trainPolynomialKernelSVM(t,e,n,i,r){return ao(this,void 0,void 0,function*(){return J(yield $({gamma:n,kernel:1,cParam:i,dParam:r},t,e))})}static applyPolynomialKernelSVM(t,e){return ao(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicablePolynomialKernelSVM(t,e){return ao(this,void 0,void 0,function*(){return et(t,e)})}static isInteractivePolynomialKernelSVM(t,e){return ao(this,void 0,void 0,function*(){return nt(t)})}static visualizePolynomialKernelSVM(t,e,n,i){return ao(this,void 0,void 0,function*(){return Q(0,i)})}static trainSigmoidKernelSVM(t,e,n,i,r){return ao(this,void 0,void 0,function*(){return J(yield $({gamma:n,kernel:3,kappa:i,theta:r},t,e))})}static applySigmoidKernelSVM(t,e){return ao(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicableSigmoidKernelSVM(t,e){return ao(this,void 0,void 0,function*(){return et(t,e)})}static isInteractiveSigmoidKernelSVM(t,e){return ao(this,void 0,void 0,function*(){return nt(t)})}static visualizeSigmoidKernelSVM(t,e,n,i){return ao(this,void 0,void 0,function*(){return Q(0,i)})}static anova(){zt()}static kNNImputation(){nn()}static kNNImputationForTable(t){return ao(this,void 0,void 0,function*(){yield nn(t)})}static trainLinearRegression(t,e){return ao(this,void 0,void 0,function*(){const n=t.columns,i=yield function(t,e){return sn(this,void 0,void 0,function*(){const n=t.length,i=e.length,o=e.stats.avg,a=e.stats.stdev,s=new Float32Array(n+1).fill(0);if(s[n]=o,0===a||1===i)return s;try{const i=[],l=[],c=new Float32Array(n),u=new Float32Array(n);let h=0,d=0;for(const e of t){const t=e.stats;t.stdev>0&&(i.push(h),l.push(e),c[d]=t.avg,u[d]=t.stdev,++d),++h}if(0===d)return s;const f=function(t,e,n,i,r,o,a){return m(EDA,"fitLinearRegressionParamsWithDataNormalizing",[t,e,n,i,r,o,a])}(r.DataFrame.fromColumns(l).columns,r.Column.fromFloat32Array("xAvgs",c,d),r.Column.fromFloat32Array("xStdevs",u,d),e,o,a,d+1).getRawData();for(let t=0;t<d;++t)s[i[t]]=f[t];s[n]=f[d]}catch(i){const o=yield function(t,e,n){return sn(this,void 0,void 0,function*(){return(yield vt({table:r.DataFrame.fromColumns([e]),features:t,predict:e,components:n,names:void 0,isQuadratic:!1})).regressionCoefficients.getRawData()})}(t,e,cn(t.length,e.length));let a=0;for(let e=0;e<n;++e)s[e]=o[e],a+=o[e]*t.byIndex(e).stats.avg;s[n]-=a}return s})}(n,e);return new Uint8Array(i.buffer)})}static applyLinearRegression(t,e){const n=t.columns,i=new Float32Array(e.buffer);return r.DataFrame.fromColumns([ln(n,i)])}static isApplicableLinearRegression(t,e){for(const e of t.columns)if(!e.matches("numerical"))return!1;return e.matches("numerical")}static isInteractiveLinearRegression(t,e){return t.rowCount<=1e5}static trainSoftmax(t,e,n,i,r,o){return ao(this,void 0,void 0,function*(){const a=t.columns,s=new mn({classesCount:e.categories.length,featuresCount:a.length});return yield s.fit(a,e,n,i,r,o),s.toBytes()})}static applySoftmax(t,e){const n=t.columns,i=new mn(void 0,e);return r.DataFrame.fromColumns([i.predict(n)])}static isApplicableSoftmax(t,e){return mn.isApplicable(t.columns,e)}static isInteractiveSoftmax(t,e){return mn.isInteractive(t.columns,e)}static trainPLSRegression(t,e,n){return ao(this,void 0,void 0,function*(){const i=t.columns,r=new hn;return yield r.fit(i,e,Math.min(n,i.length)),r.toBytes()})}static applyPLSRegression(t,e){const n=new hn(e);return r.DataFrame.fromColumns([n.predict(t.columns)])}static isApplicablePLSRegression(t,e){return hn.isApplicable(t.columns,e)}static visualizePLSRegression(t,e,n,i){return ao(this,void 0,void 0,function*(){return new hn(i).viewers().map(t=>t.root)})}static isInteractivePLSRegression(t,e){return hn.isInteractive(t.columns,e)}static trainXGBooster(t,e,n,i,r,o,a){return ao(this,void 0,void 0,function*(){const s=t.columns,l=new _n;return yield l.fit(s,e,n,i,r,o,a),l.toBytes()})}static applyXGBooster(t,e){const n=new _n(e);return r.DataFrame.fromColumns([n.predict(t.columns)])}static isInteractiveXGBooster(t,e){return _n.isInteractive(t.columns,e)}static isApplicableXGBooster(t,e){return _n.isApplicable(t.columns,e)}static paretoFront(){const e=t.shell.t;null!==e?new Rn(e).run():t.shell.warning("No dataframe is opened")}static paretoFrontViewer(){return new Dn}static trainPmpo(){const e=t.shell.t;null!==e?qi.isTableValid(e)&&new qi(e).runTrainingApp():t.shell.warning("No dataframe is opened")}static getPmpoAppItems(t){const e=t.dataFrame;return qi.isTableValid(e)?new qi(e,t).getPmpoAppItems():null}static generatePmpoDataset(e){return ao(this,void 0,void 0,function*(){const n=yield function(e){return n=this,i=void 0,o=function*(){const n=yield t.dapi.files.readCsv("System:AppData/Eda/drugs-props-train.csv");return new Xi(n,"Drug","CNS","Smiles").getGenerated(e)},new((r=void 0)||(r=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 r?n:new r(function(t){t(n)})).then(a,s)}l((o=o.apply(n,i||[])).next())});var n,i,r,o}(e);return n.name="Synthetic",n})}}io([t.decorators.func({name:"info"}),ro("design:type",Function),ro("design:paramtypes",[]),ro("design:returntype",void 0)],lo,"info",null),io([t.decorators.init({tags:["init"]}),ro("design:type",Function),ro("design:paramtypes",[]),ro("design:returntype",Promise)],lo,"init",null),io([t.decorators.func({"top-menu":"ML | Cluster | DBSCAN...",name:"DBSCAN",description:"Density-based spatial clustering of applications with noise (DBSCAN)"}),oo(1,t.decorators.param({type:"column",options:{type:"numerical"}})),oo(2,t.decorators.param({type:"column",options:{type:"numerical"}})),oo(3,t.decorators.param({options:{caption:"Epsilon",initialValue:"0.02",description:"The maximum distance between two samples for them to be considered as in the same neighborhood."}})),oo(4,t.decorators.param({type:"int",options:{caption:"Minimum points",initialValue:"4",description:"The number of samples (or total weight) in a neighborhood for a point to be considered as a core point."}})),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column,r.Column,Number,Number]),ro("design:returntype",Promise)],lo,"dbScan",null),io([t.decorators.func({"top-menu":"ML | Analyze | PCA...",description:"Principal component analysis (PCA)",helpUrl:"/help/explore/dim-reduction#pca"}),oo(0,t.decorators.param({type:"dataframe",options:{caption:"Table"}})),oo(1,t.decorators.param({type:"column_list",options:{type:"numerical",nullable:!1}})),oo(2,t.decorators.param({type:"int",options:{showPlusMinus:!0,caption:"Components",nullable:!1,min:"1",initialValue:"2",description:"Number of components."}})),oo(3,t.decorators.param({type:"bool",options:{caption:"Center",initialValue:"false",description:"Indicating whether the variables should be shifted to be zero centered."}})),oo(4,t.decorators.param({type:"bool",options:{caption:"Scale",initialValue:"false",description:"Indicating whether the variables should be scaled to have unit variance."}})),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.ColumnList,Number,Boolean,Boolean]),ro("design:returntype",Promise)],lo,"PCA",null),io([t.decorators.func({meta:{defaultPostProcessingFunction:"true",role:"dim-red-postprocessing-function"},name:"DBSCAN clustering",tags:["dim-red-postprocessing-function"]}),oo(2,t.decorators.param({options:{initialValue:"0.01",description:"Minimum distance between two points to be considered as in the same neighborhood."}})),oo(3,t.decorators.param({type:"int",options:{initialValue:"5",description:"Minimum number of points to form a dense region."}})),ro("design:type",Function),ro("design:paramtypes",[r.Column,r.Column,Number,Number]),ro("design:returntype",Promise)],lo,"dbscanPostProcessingFunction",null),io([t.decorators.func({meta:{supportedTypes:"int,float,double,qnum",supportedDistanceFunctions:"Difference",role:"dim-red-preprocessing-function"},name:"None (number)",tags:["dim-red-preprocessing-function"],outputs:[{name:"result",type:"object"}]}),oo(1,t.decorators.param({options:{optional:!0}})),ro("design:type",Function),ro("design:paramtypes",[r.Column,String]),ro("design:returntype",void 0)],lo,"numberPreprocessingFunction",null),io([t.decorators.func({meta:{supportedTypes:"string",supportedDistanceFunctions:"One-Hot,Levenshtein,Hamming",role:"dim-red-preprocessing-function"},tags:["dim-red-preprocessing-function"],name:"None (string)",outputs:[{name:"result",type:"object"}]}),oo(1,t.decorators.param({options:{optional:!0}})),ro("design:type",Function),ro("design:paramtypes",[r.Column,String]),ro("design:returntype",void 0)],lo,"stringPreprocessingFunction",null),io([t.decorators.func({"top-menu":"ML | Reduce Dimensionality...",name:"Multi Column Dimensionality Reduction"}),ro("design:type",Function),ro("design:paramtypes",[]),ro("design:returntype",Promise)],lo,"reduceDimensionality",null),io([t.decorators.editor({tags:["editor"]}),ro("design:type",Function),ro("design:paramtypes",[r.FuncCall]),ro("design:returntype",void 0)],lo,"GetMCLEditor",null),io([t.decorators.func({"top-menu":"ML | Cluster | MCL...",name:"MCLClustering",description:"Markov clustering (MCL) is an unsupervised clustering algorithm for graphs based on simulation of stochastic flow.",editor:"EDA:GetMCLEditor",outputs:[]}),oo(2,t.decorators.param({type:"list<string>"})),oo(4,t.decorators.param({type:"string"})),oo(5,t.decorators.param({type:"list<func>"})),oo(6,t.decorators.param({type:"object"})),oo(7,t.decorators.param({type:"int",options:{initialValue:"80"}})),oo(8,t.decorators.param({type:"int",options:{initialValue:"10"}})),oo(9,t.decorators.param({type:"bool",options:{initialValue:"false"}})),oo(10,t.decorators.param({type:"double",options:{initialValue:"2"}})),oo(11,t.decorators.param({type:"int",options:{initialValue:"5"}})),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,Array,Array,Array,String,Array,Array,Number,Number,Boolean,Number,Number]),ro("design:returntype",Promise)],lo,"MCLClustering",null),io([t.decorators.func({outputs:[{name:"result",type:"viewer"}],meta:{showInGallery:"false",role:"viewer"},tags:["viewer"],name:"MCL",description:"Markov clustering viewer"}),ro("design:type",Function),ro("design:paramtypes",[]),ro("design:returntype",an)],lo,"markovClusteringViewer",null),io([t.decorators.func({outputs:[{name:"plsResults",type:"object"}],description:"Compute partial least squares (PLS) regression analysis components: prediction, regression coefficients, T- & U-scores, X-loadings."}),oo(1,t.decorators.param({type:"column_list",options:{type:"numerical"}})),oo(2,t.decorators.param({type:"column",options:{type:"numerical"}})),oo(3,t.decorators.param({type:"int",options:{initialValue:"3"}})),oo(4,t.decorators.param({type:"column",options:{type:"string"}})),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.ColumnList,r.Column,Number,r.Column]),ro("design:returntype",Promise)],lo,"PLS",null),io([t.decorators.func({"top-menu":"ML | Analyze | PLS...",description:"Compute partial least squares (PLS) regression components. They maximally summarize the variation of the predictors while maximizing correlation with the response variable."}),ro("design:type",Function),ro("design:paramtypes",[]),ro("design:returntype",Promise)],lo,"topMenuPLS",null),io([t.decorators.func({"top-menu":"ML | Analyze | Multivariate Analysis...",name:"multivariateAnalysis",description:"Multidimensional data analysis using partial least squares (PLS) regression."}),ro("design:type",Function),ro("design:paramtypes",[]),ro("design:returntype",Promise)],lo,"MVA",null),io([t.decorators.func({meta:{demoPath:"Compute | Multivariate Analysis"},name:"MVA demo",description:"Multidimensional data analysis using partial least squares (PLS) regression. It identifies latent factors and constructs a linear model based on them."}),ro("design:type",Function),ro("design:paramtypes",[]),ro("design:returntype",Promise)],lo,"demoMultivariateAnalysis",null),io([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"train"}}),oo(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column,Number]),ro("design:returntype",Promise)],lo,"trainLinearKernelSVM",null),io([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"apply"}}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,Object]),ro("design:returntype",Promise)],lo,"applyLinearKernelSVM",null),io([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"isApplicable"}}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Promise)],lo,"isApplicableLinearKernelSVM",null),io([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"isInteractive"}}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Promise)],lo,"isInteractiveLinearKernelSVM",null),io([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"visualize"}}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column,r.Column,Object]),ro("design:returntype",Promise)],lo,"visualizeLinearKernelSVM",null),io([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"train"}}),oo(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),oo(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.5"}})),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column,Number,Number]),ro("design:returntype",Promise)],lo,"trainRBFkernelSVM",null),io([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"apply"}}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,Object]),ro("design:returntype",Promise)],lo,"applyRBFkernelSVM",null),io([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"isApplicable"}}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Promise)],lo,"isApplicableRBFkernelSVM",null),io([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"isInteractive"}}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Promise)],lo,"isInteractiveRBFkernelSVM",null),io([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"visualize"}}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column,r.Column,Object]),ro("design:returntype",Promise)],lo,"visualizeRBFkernelSVM",null),io([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"train"}}),oo(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),oo(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1"}})),oo(4,t.decorators.param({options:{category:"Hyperparameters",initialValue:"2"}})),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column,Number,Number,Number]),ro("design:returntype",Promise)],lo,"trainPolynomialKernelSVM",null),io([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"apply"}}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,Object]),ro("design:returntype",Promise)],lo,"applyPolynomialKernelSVM",null),io([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"isApplicable"}}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Promise)],lo,"isApplicablePolynomialKernelSVM",null),io([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"isInteractive"}}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Promise)],lo,"isInteractivePolynomialKernelSVM",null),io([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"visualize"},outputs:[{name:"widget",type:"dynamic"}],name:"visualizePolynomialKernelSVM"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column,r.Column,Object]),ro("design:returntype",Promise)],lo,"visualizePolynomialKernelSVM",null),io([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"train"},name:"trainSigmoidKernelSVM"}),oo(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),oo(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1"}})),oo(4,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1"}})),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column,Number,Number,Number]),ro("design:returntype",Promise)],lo,"trainSigmoidKernelSVM",null),io([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"apply"},name:"applySigmoidKernelSVM"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,Object]),ro("design:returntype",Promise)],lo,"applySigmoidKernelSVM",null),io([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"isApplicable"},name:"isApplicableSigmoidKernelSVM"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Promise)],lo,"isApplicableSigmoidKernelSVM",null),io([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"isInteractive"},name:"isInteractiveSigmoidKernelSVM"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Promise)],lo,"isInteractiveSigmoidKernelSVM",null),io([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"visualize"},name:"visualizeSigmoidKernelSVM"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column,r.Column,Object]),ro("design:returntype",Promise)],lo,"visualizeSigmoidKernelSVM",null),io([t.decorators.func({"top-menu":"ML | Analyze | ANOVA...",name:"ANOVA",description:"One-way analysis of variances (ANOVA) determines whether the examined factor has a significant impact on the explored feature."}),ro("design:type",Function),ro("design:paramtypes",[]),ro("design:returntype",void 0)],lo,"anova",null),io([t.decorators.func({"top-menu":"ML | Impute Missing Values...",name:"KNN impute",description:"Missing values imputation using the k-nearest neighbors method (KNN)"}),ro("design:type",Function),ro("design:paramtypes",[]),ro("design:returntype",void 0)],lo,"kNNImputation",null),io([t.decorators.func({name:"KNN imputation for a table",description:"Missing values imputation using the k-nearest neighbors method"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame]),ro("design:returntype",Promise)],lo,"kNNImputationForTable",null),io([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"train"},name:"trainLinearRegression",outputs:[{type:"dynamic",name:"model"}]}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Promise)],lo,"trainLinearRegression",null),io([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"apply"},name:"applyLinearRegression"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,Object]),ro("design:returntype",r.DataFrame)],lo,"applyLinearRegression",null),io([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"isApplicable"},name:"isApplicableLinearRegression"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Boolean)],lo,"isApplicableLinearRegression",null),io([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"isInteractive"},name:"isInteractiveLinearRegression"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Boolean)],lo,"isInteractiveLinearRegression",null),io([t.decorators.func({meta:{mlname:"Softmax",mlrole:"train"},name:"trainSoftmax",outputs:[{type:"dynamic",name:"model"}]}),oo(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0",min:"0.001",max:"20",description:"Learning rate."}})),oo(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"100",min:"1",max:"10000",step:"10",description:"Fitting iterations count"}})),oo(4,t.decorators.param({options:{category:"Hyperparameters",initialValue:"0.1",min:"0.0001",max:"1",description:"Regularization rate."}})),oo(5,t.decorators.param({options:{category:"Hyperparameters",initialValue:"0.001",min:"0.00001",max:"0.1",description:"Fitting tolerance."}})),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column,Number,Number,Number,Number]),ro("design:returntype",Promise)],lo,"trainSoftmax",null),io([t.decorators.func({meta:{mlname:"Softmax",mlrole:"apply"},name:"applySoftmax"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,Object]),ro("design:returntype",r.DataFrame)],lo,"applySoftmax",null),io([t.decorators.func({meta:{mlname:"Softmax",mlrole:"isApplicable"},name:"isApplicableSoftmax"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Boolean)],lo,"isApplicableSoftmax",null),io([t.decorators.func({meta:{mlname:"Softmax",mlrole:"isInteractive"},name:"isInteractiveSoftmax"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Boolean)],lo,"isInteractiveSoftmax",null),io([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"train"},name:"trainPLSRegression",outputs:[{name:"model",type:"dynamic"}]}),oo(2,t.decorators.param({type:"int",options:{min:"1",max:"10",initialValue:"3",description:"Number of latent components."}})),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column,Number]),ro("design:returntype",Promise)],lo,"trainPLSRegression",null),io([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"apply"},name:"applyPLSRegression"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,Object]),ro("design:returntype",r.DataFrame)],lo,"applyPLSRegression",null),io([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"isApplicable"},name:"isApplicablePLSRegression"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Boolean)],lo,"isApplicablePLSRegression",null),io([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"visualize"},name:"visualizePLSRegression"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column,r.Column,Object]),ro("design:returntype",Promise)],lo,"visualizePLSRegression",null),io([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"isInteractive"},name:"isInteractivePLSRegression"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Boolean)],lo,"isInteractivePLSRegression",null),io([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"train"},name:"trainXGBooster",outputs:[{name:"model",type:"dynamic"}]}),oo(2,t.decorators.param({type:"int",options:{min:"1",max:"100",initialValue:"20",description:"Number of training iterations."}})),oo(3,t.decorators.param({type:"double",options:{caption:"Rate",min:"0",max:"1",initialValue:"0.3",description:"Learning rate."}})),oo(4,t.decorators.param({type:"int",options:{min:"0",max:"20",initialValue:"6",description:"Maximum depth of a tree."}})),oo(5,t.decorators.param({type:"double",options:{min:"0",max:"100",initialValue:"1",description:"L2 regularization term."}})),oo(6,t.decorators.param({type:"double",options:{min:"0",max:"100",initialValue:"0",description:"L1 regularization term."}})),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column,Number,Number,Number,Number,Number]),ro("design:returntype",Promise)],lo,"trainXGBooster",null),io([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"apply"},name:"applyXGBooster"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,Object]),ro("design:returntype",r.DataFrame)],lo,"applyXGBooster",null),io([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"isInteractive"},name:"isInteractiveXGBooster"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Boolean)],lo,"isInteractiveXGBooster",null),io([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"isApplicable"},name:"isApplicableXGBooster"}),ro("design:type",Function),ro("design:paramtypes",[r.DataFrame,r.Column]),ro("design:returntype",Boolean)],lo,"isApplicableXGBooster",null),io([t.decorators.func({"top-menu":"ML | Pareto Front...",name:"Pareto Front",description:"Perform optimization across multiple objectives: analyze trade-offs between conflicting objectives and identify Pareto-optimal points."}),ro("design:type",Function),ro("design:paramtypes",[]),ro("design:returntype",void 0)],lo,"paretoFront",null),io([t.decorators.func({name:"Pareto front",description:"Pareto front viewer",outputs:[{name:"result",type:"viewer"}],meta:{icon:"icons/pareto-front-viewer.svg",role:"viewer"},tags:["viewer"]}),ro("design:type",Function),ro("design:paramtypes",[]),ro("design:returntype",r.Viewer)],lo,"paretoFrontViewer",null),io([t.decorators.func({name:"trainPmpo",description:"Train probabilistic multi-parameter optimization (pMPO) model"}),ro("design:type",Function),ro("design:paramtypes",[]),ro("design:returntype",void 0)],lo,"trainPmpo",null),io([t.decorators.func({name:"getPmpoAppItems",outputs:[{name:"result",type:"object"}]}),oo(0,t.decorators.param({type:"view"})),ro("design:type",Function),ro("design:paramtypes",[r.TableView]),ro("design:returntype",Object)],lo,"getPmpoAppItems",null),io([t.decorators.func({name:"generatePmpoDataset",description:"Generates syntethetic dataset oriented on the pMPO modeling",outputs:[{name:"Synthetic",type:"dataframe"}]}),oo(0,t.decorators.param({type:"int"})),ro("design:type",Function),ro("design:paramtypes",[Number]),ro("design:returntype",Promise)],lo,"generatePmpoDataset",null)})(),eda=i})();
|
|
2
2
|
//# sourceMappingURL=package.js.map
|