@datagrok/curves 1.3.1 → 1.4.0
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/CHANGELOG.md +17 -0
- package/README.md +2 -3
- 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/package.json +2 -2
- package/src/fit/const.ts +17 -41
- package/src/fit/fit-demo.ts +6 -3
- package/src/fit/fit-grid-cell-handler.ts +36 -22
- package/src/fit/fit-renderer.ts +15 -6
- package/src/fit/multi-curve-viewer.ts +3 -3
- package/src/fit/render-utils.ts +50 -96
- package/src/tests/detector-tests.ts +4 -5
- package/src/tests/fit-tests.ts +24 -20
package/dist/package.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var curves;(()=>{var __webpack_modules__={78:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";function copyInto(e,r){for(var n=0;n<r.length;n++)e[n]=r[n]}function limitedMemoryBFGS(e,r){var n=+new Date,t=r.length,o=numeric.rep([t],0);e.getGradient(r,o);var i=numeric.clone(o),a=numeric.clone(r),u=numeric.clone(o);numeric.diveq(u,numeric.norm2(u));var s=[],c=[],l=[],f=(backtrackingLineSearch(e,u,o,r),e.getValue(r));o=e.getGradient(r,o);for(var m=f,h=0;h<100;h++){var d;if(new Date,s.length<4)s.unshift(numeric.sub(r,a)),c.unshift(numeric.sub(o,i));else{for(var p=s.pop(),g=c.pop(),v=0;v<t;v++)p[v]=r[v]-a[v],g[v]=o[v]-i[v];s.unshift(p),c.unshift(g)}copyInto(a,r),copyInto(i,o);var y=0,_=0;for(v=0;v<t;v++)y+=s[0][v]*c[0][v],_+=c[0][v]*c[0][v];var x=y/_;l.unshift(1/y),copyInto(u,o);for(var w=[],T=0;T<s.length;T++){var b=0;for(v=0;v<t;v++)b+=s[T][v]*u[v];for(b*=l[T],w.push(b),v=0;v<t;v++)u[v]+=c[T][v]*-b}for(v=0;v<t;v++)u[v]*=x;for(T=s.length-1;T>=0;T--){var A=0;for(v=0;v<t;v++)A+=c[T][v]*u[v];for(A*=l[T],b=w[T],v=0;v<t;v++)u[v]+=s[T][v]*(b-A)}for(v=0;v<t;v++)u[v]=-u[v];if(backtrackingLineSearch(e,u,o,r),f=e.getValue(r),o=e.getGradient(r,o),2*(f-m)<=1e-4*(Math.abs(f)+Math.abs(m)+1e-5))return d=+new Date,!0;var I=numeric.norm2(o);if(I<.001)return d=+new Date,!0;if(0==I)return d=+new Date,!0;m=f}return d=+new Date,console.log("Finished iterations "+(d-n)),!0}function backtrackingLineSearch(e,r,n,t){var o=t.length,i=0,a=1,u=0,s=e.getValue(t),c=s,l=numeric.norm2(r);l>100&&numeric.muleq(r,100/l);for(var f=0,m=0;m<o;m++)f+=n[m]*r[m];var h=0;for(m=0;m<o;m++){var d=Math.abs(r[m]/Math.max(Math.abs(t[m]),1));d>h&&(h=d)}for(var p=1e-4/h,g=0;g<25;g++){for(m=0;m<o;m++)t[m]+=(a-i)*r[m];if(a<p)return 0;var v=e.getValue(t);if(v>=s+1e-4*a*f)return a;if(isFinite(v))if(1==a)u=-f/(2*(v-s-f));else{var y=v-s-a*f,_=c-s-i*f,x=1/(a*a),w=1/(i*i),T=1/(a-i),b=T*(y*x-_*w),A=T*(-y*i*x+_*a*w);if(0==b)u=-f/(2*A);else{var I=A*A-3*b*f;u=I<0?.5*a:A<=0?(-A+Math.sqrt(I))/(3*b):-f/(A+Math.sqrt(I))}u>.5*a&&(u=.5*a)}else u=.2*a;c=v,i=a,a=Math.max(u,.1*a)}}__webpack_require__.d(__webpack_exports__,{U:()=>limitedMemoryBFGS});var quadratic={getValue:function(e){var r=e[0],n=e[1];return-3*r*r-4*n*n+2*r-4*n+18},getGradient:function(e,r){return r[0]=-6*e[0]+2,r[1]=-8*e[1]-4,r}};function doubleExp(e){for(var r=Array(e),n=0;n<e;n++)r[n]=Math.log(Math.random())*(Math.random()>.5?1:-1);return r}var ridgeRegression={covariates:[],responses:[],originalParameters:doubleExp(100),sample:function(e,r){for(var n=0;n<e;n++){var t=doubleExp(100);this.responses.push(numeric.dot(t,this.originalParameters)+r()),this.covariates.push(t)}},getValue:function(e){for(var r=0,n=0;n<this.covariates.length;n++){var t=this.responses[n]-numeric.dot(this.covariates[n],e);r+=-.5*t*t}return r},getGradient:function(e,r){for(var n=0;n<this.covariates.length;n++){var t=this.responses[n]-numeric.dot(this.covariates[n],e);numeric.addeq(r,numeric.mul(this.covariates[n],t))}return r}},numeric="undefined"==typeof exports?function(){}:exports;void 0!==__webpack_require__.g&&(__webpack_require__.g.numeric=numeric),numeric.version="1.2.6",numeric.bench=function(e,r){var n,t,o;for(void 0===r&&(r=15),t=.5,n=new Date;;){for(o=t*=2;o>3;o-=4)e(),e(),e(),e();for(;o>0;)e(),o--;if(new Date-n>r)break}for(o=t;o>3;o-=4)e(),e(),e(),e();for(;o>0;)e(),o--;return 1e3*(3*t-1)/(new Date-n)},numeric._myIndexOf=function(e){var r,n=this.length;for(r=0;r<n;++r)if(this[r]===e)return r;return-1},numeric.myIndexOf=Array.prototype.indexOf?Array.prototype.indexOf:numeric._myIndexOf,numeric.Function=Function,numeric.precision=4,numeric.largeArray=50,numeric.prettyPrint=function(e){function r(e){if(0===e)return"0";if(isNaN(e))return"NaN";if(e<0)return"-"+r(-e);if(isFinite(e)){var n=Math.floor(Math.log(e)/Math.log(10)),t=e/Math.pow(10,n),o=t.toPrecision(numeric.precision);return 10===parseFloat(o)&&(n++,o=(t=1).toPrecision(numeric.precision)),parseFloat(o).toString()+"e"+n.toString()}return"Infinity"}var n=[];return function e(t){var o;if(void 0===t)return n.push(Array(numeric.precision+8).join(" ")),!1;if("string"==typeof t)return n.push('"'+t+'"'),!1;if("boolean"==typeof t)return n.push(t.toString()),!1;if("number"==typeof t){var i=r(t),a=t.toPrecision(numeric.precision),u=parseFloat(t.toString()).toString(),s=[i,a,u,parseFloat(a).toString(),parseFloat(u).toString()];for(o=1;o<s.length;o++)s[o].length<i.length&&(i=s[o]);return n.push(Array(numeric.precision+8-i.length).join(" ")+i),!1}if(null===t)return n.push("null"),!1;if("function"==typeof t){n.push(t.toString());var c=!1;for(o in t)t.hasOwnProperty(o)&&(c?n.push(",\n"):n.push("\n{"),c=!0,n.push(o),n.push(": \n"),e(t[o]));return c&&n.push("}\n"),!0}if(t instanceof Array){if(t.length>numeric.largeArray)return n.push("...Large Array..."),!0;for(c=!1,n.push("["),o=0;o<t.length;o++)o>0&&(n.push(","),c&&n.push("\n ")),c=e(t[o]);return n.push("]"),!0}for(o in n.push("{"),c=!1,t)t.hasOwnProperty(o)&&(c&&n.push(",\n"),c=!0,n.push(o),n.push(": \n"),e(t[o]));return n.push("}"),!0}(e),n.join("")},numeric.parseDate=function(e){return function e(r){if("string"==typeof r)return Date.parse(r.replace(/-/g,"/"));if(r instanceof Array){var n,t=[];for(n=0;n<r.length;n++)t[n]=e(r[n]);return t}throw new Error("parseDate: parameter must be arrays of strings")}(e)},numeric.parseFloat=function(e){return function e(r){if("string"==typeof r)return parseFloat(r);if(r instanceof Array){var n,t=[];for(n=0;n<r.length;n++)t[n]=e(r[n]);return t}throw new Error("parseFloat: parameter must be arrays of strings")}(e)},numeric.parseCSV=function(e){var r,n,t,o=e.split("\n"),i=[],a=/(([^'",]*)|('[^']*')|("[^"]*")),/g,u=/^\s*(([+-]?[0-9]+(\.[0-9]*)?(e[+-]?[0-9]+)?)|([+-]?[0-9]*(\.[0-9]+)?(e[+-]?[0-9]+)?))\s*$/,s=0;for(n=0;n<o.length;n++){var c,l=(o[n]+",").match(a);if(l.length>0){for(i[s]=[],r=0;r<l.length;r++)c=(t=l[r]).substr(0,t.length-1),u.test(c)?i[s][r]=parseFloat(c):i[s][r]=c;s++}}return i},numeric.toCSV=function(e){var r,n,t,o,i,a=numeric.dim(e);for(t=a[0],a[1],i=[],r=0;r<t;r++){for(o=[],n=0;n<t;n++)o[n]=e[r][n].toString();i[r]=o.join(", ")}return i.join("\n")+"\n"},numeric.getURL=function(e){var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(),r},numeric.imageURL=function(e){function r(e,r,n){void 0===r&&(r=0),void 0===n&&(n=e.length);var t,o=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],i=-1;for(e.length,t=r;t<n;t++)i=i>>>8^o[255&(i^e[t])];return-1^i}var n,t,o,i,a,u,s,c,l,f,m=e[0].length,h=e[0][0].length,d=[137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,h>>24&255,h>>16&255,h>>8&255,255&h,m>>24&255,m>>16&255,m>>8&255,255&m,8,2,0,0,0,-1,-2,-3,-4,-5,-6,-7,-8,73,68,65,84,8,29];for(f=r(d,12,29),d[29]=f>>24&255,d[30]=f>>16&255,d[31]=f>>8&255,d[32]=255&f,n=1,t=0,s=0;s<m;s++){for(s<m-1?d.push(0):d.push(1),a=3*h+1+(0===s)&255,u=3*h+1+(0===s)>>8&255,d.push(a),d.push(u),d.push(255&~a),d.push(255&~u),0===s&&d.push(0),c=0;c<h;c++)for(o=0;o<3;o++)t=(t+(n=(n+(a=(a=e[o][s][c])>255?255:a<0?0:Math.round(a)))%65521))%65521,d.push(a);d.push(0)}return l=(t<<16)+n,d.push(l>>24&255),d.push(l>>16&255),d.push(l>>8&255),d.push(255&l),i=d.length-41,d[33]=i>>24&255,d[34]=i>>16&255,d[35]=i>>8&255,d[36]=255&i,f=r(d,37),d.push(f>>24&255),d.push(f>>16&255),d.push(f>>8&255),d.push(255&f),d.push(0),d.push(0),d.push(0),d.push(0),d.push(73),d.push(69),d.push(78),d.push(68),d.push(174),d.push(66),d.push(96),d.push(130),"data:image/png;base64,"+function(e){var r,n,t,o,i,a,u,s=e.length,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="";for(r=0;r<s;r+=3)i=((3&(n=e[r]))<<4)+((t=e[r+1])>>4),a=((15&t)<<2)+((o=e[r+2])>>6),u=63&o,r+1>=s?a=u=64:r+2>=s&&(u=64),l+=c.charAt(n>>2)+c.charAt(i)+c.charAt(a)+c.charAt(u);return l}(d)},numeric._dim=function(e){for(var r=[];"object"==typeof e;)r.push(e.length),e=e[0];return r},numeric.dim=function(e){var r;return"object"==typeof e?"object"==typeof(r=e[0])?"object"==typeof r[0]?numeric._dim(e):[e.length,r.length]:[e.length]:[]},numeric.mapreduce=function(e,r){return Function("x","accum","_s","_k",'if(typeof accum === "undefined") accum = '+r+';\nif(typeof x === "number") { var xi = x; '+e+'; return accum; }\nif(typeof _s === "undefined") _s = numeric.dim(x);\nif(typeof _k === "undefined") _k = 0;\nvar _n = _s[_k];\nvar i,xi;\nif(_k < _s.length-1) {\n for(i=_n-1;i>=0;i--) {\n accum = arguments.callee(x[i],accum,_s,_k+1);\n } return accum;\n}\nfor(i=_n-1;i>=1;i-=2) { \n xi = x[i];\n '+e+";\n xi = x[i-1];\n "+e+";\n}\nif(i === 0) {\n xi = x[i];\n "+e+"\n}\nreturn accum;")},numeric.mapreduce2=function(e,r){return Function("x","var n = x.length;\nvar i,xi;\n"+r+";\nfor(i=n-1;i!==-1;--i) { \n xi = x[i];\n "+e+";\n}\nreturn accum;")},numeric.same=function e(r,n){var t,o;if(r instanceof Array&&n instanceof Array){if((o=r.length)!==n.length)return!1;for(t=0;t<o;t++)if(r[t]!==n[t]){if("object"!=typeof r[t])return!1;if(!e(r[t],n[t]))return!1}return!0}return!1},numeric.rep=function(e,r,n){void 0===n&&(n=0);var t,o=e[n],i=Array(o);if(n===e.length-1){for(t=o-2;t>=0;t-=2)i[t+1]=r,i[t]=r;return-1===t&&(i[0]=r),i}for(t=o-1;t>=0;t--)i[t]=numeric.rep(e,r,n+1);return i},numeric.dotMMsmall=function(e,r){var n,t,o,i,a,u,s,c,l,f,m;for(i=e.length,a=r.length,u=r[0].length,s=Array(i),n=i-1;n>=0;n--){for(c=Array(u),l=e[n],o=u-1;o>=0;o--){for(f=l[a-1]*r[a-1][o],t=a-2;t>=1;t-=2)m=t-1,f+=l[t]*r[t][o]+l[m]*r[m][o];0===t&&(f+=l[0]*r[0][o]),c[o]=f}s[n]=c}return s},numeric._getCol=function(e,r,n){var t;for(t=e.length-1;t>0;--t)n[t]=e[t][r],n[--t]=e[t][r];0===t&&(n[0]=e[0][r])},numeric.dotMMbig=function(e,r){var n,t,o,i=numeric._getCol,a=r.length,u=Array(a),s=e.length,c=r[0].length,l=new Array(s),f=numeric.dotVV;for(--a,t=--s;-1!==t;--t)l[t]=Array(c);for(t=--c;-1!==t;--t)for(i(r,t,u),o=s;-1!==o;--o)n=e[o],l[o][t]=f(n,u);return l},numeric.dotMV=function(e,r){var n,t=e.length,o=(r.length,Array(t)),i=numeric.dotVV;for(n=t-1;n>=0;n--)o[n]=i(e[n],r);return o},numeric.dotVM=function(e,r){var n,t,o,i,a,u,s;for(o=e.length,i=r[0].length,a=Array(i),t=i-1;t>=0;t--){for(u=e[o-1]*r[o-1][t],n=o-2;n>=1;n-=2)s=n-1,u+=e[n]*r[n][t]+e[s]*r[s][t];0===n&&(u+=e[0]*r[0][t]),a[t]=u}return a},numeric.dotVV=function(e,r){var n,t,o=e.length,i=e[o-1]*r[o-1];for(n=o-2;n>=1;n-=2)t=n-1,i+=e[n]*r[n]+e[t]*r[t];return 0===n&&(i+=e[0]*r[0]),i},numeric.dot=function(e,r){var n=numeric.dim;switch(1e3*n(e).length+n(r).length){case 2002:return r.length<10?numeric.dotMMsmall(e,r):numeric.dotMMbig(e,r);case 2001:return numeric.dotMV(e,r);case 1002:return numeric.dotVM(e,r);case 1001:return numeric.dotVV(e,r);case 1e3:return numeric.mulVS(e,r);case 1:return numeric.mulSV(e,r);case 0:return e*r;default:throw new Error("numeric.dot only works on vectors and matrices")}},numeric.diag=function(e){var r,n,t,o,i=e.length,a=Array(i);for(r=i-1;r>=0;r--){for(o=Array(i),n=r+2,t=i-1;t>=n;t-=2)o[t]=0,o[t-1]=0;for(t>r&&(o[t]=0),o[r]=e[r],t=r-1;t>=1;t-=2)o[t]=0,o[t-1]=0;0===t&&(o[0]=0),a[r]=o}return a},numeric.getDiag=function(e){var r,n=Math.min(e.length,e[0].length),t=Array(n);for(r=n-1;r>=1;--r)t[r]=e[r][r],t[--r]=e[r][r];return 0===r&&(t[0]=e[0][0]),t},numeric.identity=function(e){return numeric.diag(numeric.rep([e],1))},numeric.pointwise=function(e,r,n){void 0===n&&(n="");var t,o,i=[],a=/\[i\]$/,u="",s=!1;for(t=0;t<e.length;t++)a.test(e[t])?u=o=e[t].substring(0,e[t].length-3):o=e[t],"ret"===o&&(s=!0),i.push(o);return i[e.length]="_s",i[e.length+1]="_k",i[e.length+2]='if(typeof _s === "undefined") _s = numeric.dim('+u+');\nif(typeof _k === "undefined") _k = 0;\nvar _n = _s[_k];\nvar i'+(s?"":", ret = Array(_n)")+";\nif(_k < _s.length-1) {\n for(i=_n-1;i>=0;i--) ret[i] = arguments.callee("+e.join(",")+",_s,_k+1);\n return ret;\n}\n"+n+"\nfor(i=_n-1;i!==-1;--i) {\n "+r+"\n}\nreturn ret;",Function.apply(null,i)},numeric.pointwise2=function(e,r,n){void 0===n&&(n="");var t,o,i=[],a=/\[i\]$/,u="",s=!1;for(t=0;t<e.length;t++)a.test(e[t])?u=o=e[t].substring(0,e[t].length-3):o=e[t],"ret"===o&&(s=!0),i.push(o);return i[e.length]="var _n = "+u+".length;\nvar i"+(s?"":", ret = Array(_n)")+";\n"+n+"\nfor(i=_n-1;i!==-1;--i) {\n"+r+"\n}\nreturn ret;",Function.apply(null,i)},numeric._biforeach=function e(r,n,t,o,i){var a;if(o!==t.length-1)for(a=t[o]-1;a>=0;a--)e("object"==typeof r?r[a]:r,"object"==typeof n?n[a]:n,t,o+1,i);else i(r,n)},numeric._biforeach2=function e(r,n,t,o,i){if(o===t.length-1)return i(r,n);var a,u=t[o],s=Array(u);for(a=u-1;a>=0;--a)s[a]=e("object"==typeof r?r[a]:r,"object"==typeof n?n[a]:n,t,o+1,i);return s},numeric._foreach=function e(r,n,t,o){var i;if(t!==n.length-1)for(i=n[t]-1;i>=0;i--)e(r[i],n,t+1,o);else o(r)},numeric._foreach2=function e(r,n,t,o){if(t===n.length-1)return o(r);var i,a=n[t],u=Array(a);for(i=a-1;i>=0;i--)u[i]=e(r[i],n,t+1,o);return u},numeric.ops2={add:"+",sub:"-",mul:"*",div:"/",mod:"%",and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">=",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"},numeric.opseq={addeq:"+=",subeq:"-=",muleq:"*=",diveq:"/=",modeq:"%=",lshifteq:"<<=",rshifteq:">>=",rrshifteq:">>>=",bandeq:"&=",boreq:"|=",bxoreq:"^="},numeric.mathfuns=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan","isNaN","isFinite"],numeric.mathfuns2=["atan2","pow","max","min"],numeric.ops1={neg:"-",not:"!",bnot:"~",clone:""},numeric.mapreducers={any:["if(xi) return true;","var accum = false;"],all:["if(!xi) return false;","var accum = true;"],sum:["accum += xi;","var accum = 0;"],prod:["accum *= xi;","var accum = 1;"],norm2Squared:["accum += xi*xi;","var accum = 0;"],norminf:["accum = max(accum,abs(xi));","var accum = 0, max = Math.max, abs = Math.abs;"],norm1:["accum += abs(xi)","var accum = 0, abs = Math.abs;"],sup:["accum = max(accum,xi);","var accum = -Infinity, max = Math.max;"],inf:["accum = min(accum,xi);","var accum = Infinity, min = Math.min;"]},function(){var e,r;for(e=0;e<numeric.mathfuns2.length;++e)r=numeric.mathfuns2[e],numeric.ops2[r]=r;for(e in numeric.ops2)if(numeric.ops2.hasOwnProperty(e)){r=numeric.ops2[e];var n,t,o="";-1!==numeric.myIndexOf.call(numeric.mathfuns2,e)?(o="var "+r+" = Math."+r+";\n",n=function(e,n,t){return e+" = "+r+"("+n+","+t+")"},t=function(e,n){return e+" = "+r+"("+e+","+n+")"}):(n=function(e,n,t){return e+" = "+n+" "+r+" "+t},t=numeric.opseq.hasOwnProperty(e+"eq")?function(e,n){return e+" "+r+"= "+n}:function(e,n){return e+" = "+e+" "+r+" "+n}),numeric[e+"VV"]=numeric.pointwise2(["x[i]","y[i]"],n("ret[i]","x[i]","y[i]"),o),numeric[e+"SV"]=numeric.pointwise2(["x","y[i]"],n("ret[i]","x","y[i]"),o),numeric[e+"VS"]=numeric.pointwise2(["x[i]","y"],n("ret[i]","x[i]","y"),o),numeric[e]=Function("var n = arguments.length, i, x = arguments[0], y;\nvar VV = numeric."+e+"VV, VS = numeric."+e+"VS, SV = numeric."+e+'SV;\nvar dim = numeric.dim;\nfor(i=1;i!==n;++i) { \n y = arguments[i];\n if(typeof x === "object") {\n if(typeof y === "object") x = numeric._biforeach2(x,y,dim(x),0,VV);\n else x = numeric._biforeach2(x,y,dim(x),0,VS);\n } else if(typeof y === "object") x = numeric._biforeach2(x,y,dim(y),0,SV);\n else '+t("x","y")+"\n}\nreturn x;\n"),numeric[r]=numeric[e],numeric[e+"eqV"]=numeric.pointwise2(["ret[i]","x[i]"],t("ret[i]","x[i]"),o),numeric[e+"eqS"]=numeric.pointwise2(["ret[i]","x"],t("ret[i]","x"),o),numeric[e+"eq"]=Function("var n = arguments.length, i, x = arguments[0], y;\nvar V = numeric."+e+"eqV, S = numeric."+e+'eqS\nvar s = numeric.dim(x);\nfor(i=1;i!==n;++i) { \n y = arguments[i];\n if(typeof y === "object") numeric._biforeach(x,y,s,0,V);\n else numeric._biforeach(x,y,s,0,S);\n}\nreturn x;\n')}for(e=0;e<numeric.mathfuns2.length;++e)r=numeric.mathfuns2[e],delete numeric.ops2[r];for(e=0;e<numeric.mathfuns.length;++e)r=numeric.mathfuns[e],numeric.ops1[r]=r;for(e in numeric.ops1)numeric.ops1.hasOwnProperty(e)&&(o="",r=numeric.ops1[e],-1!==numeric.myIndexOf.call(numeric.mathfuns,e)&&Math.hasOwnProperty(r)&&(o="var "+r+" = Math."+r+";\n"),numeric[e+"eqV"]=numeric.pointwise2(["ret[i]"],"ret[i] = "+r+"(ret[i]);",o),numeric[e+"eq"]=Function("x",'if(typeof x !== "object") return '+r+"x\nvar i;\nvar V = numeric."+e+"eqV;\nvar s = numeric.dim(x);\nnumeric._foreach(x,s,0,V);\nreturn x;\n"),numeric[e+"V"]=numeric.pointwise2(["x[i]"],"ret[i] = "+r+"(x[i]);",o),numeric[e]=Function("x",'if(typeof x !== "object") return '+r+"(x)\nvar i;\nvar V = numeric."+e+"V;\nvar s = numeric.dim(x);\nreturn numeric._foreach2(x,s,0,V);\n"));for(e=0;e<numeric.mathfuns.length;++e)r=numeric.mathfuns[e],delete numeric.ops1[r];for(e in numeric.mapreducers)numeric.mapreducers.hasOwnProperty(e)&&(r=numeric.mapreducers[e],numeric[e+"V"]=numeric.mapreduce2(r[0],r[1]),numeric[e]=Function("x","s","k",r[1]+'if(typeof x !== "object") { xi = x;\n'+r[0]+';\n return accum;\n}if(typeof s === "undefined") s = numeric.dim(x);\nif(typeof k === "undefined") k = 0;\nif(k === s.length-1) return numeric.'+e+"V(x);\nvar xi;\nvar n = x.length, i;\nfor(i=n-1;i!==-1;--i) {\n xi = arguments.callee(x[i]);\n"+r[0]+";\n}\nreturn accum;\n"))}(),numeric.truncVV=numeric.pointwise(["x[i]","y[i]"],"ret[i] = round(x[i]/y[i])*y[i];","var round = Math.round;"),numeric.truncVS=numeric.pointwise(["x[i]","y"],"ret[i] = round(x[i]/y)*y;","var round = Math.round;"),numeric.truncSV=numeric.pointwise(["x","y[i]"],"ret[i] = round(x/y[i])*y[i];","var round = Math.round;"),numeric.trunc=function(e,r){return"object"==typeof e?"object"==typeof r?numeric.truncVV(e,r):numeric.truncVS(e,r):"object"==typeof r?numeric.truncSV(e,r):Math.round(e/r)*r},numeric.inv=function(e){var r,n,t,o,i,a,u,s=numeric.dim(e),c=Math.abs,l=s[0],f=s[1],m=numeric.clone(e),h=numeric.identity(l);for(a=0;a<f;++a){var d=-1,p=-1;for(i=a;i!==l;++i)(u=c(m[i][a]))>p&&(d=i,p=u);for(n=m[d],m[d]=m[a],m[a]=n,o=h[d],h[d]=h[a],h[a]=o,e=n[a],u=a;u!==f;++u)n[u]/=e;for(u=f-1;-1!==u;--u)o[u]/=e;for(i=l-1;-1!==i;--i)if(i!==a){for(r=m[i],t=h[i],e=r[a],u=a+1;u!==f;++u)r[u]-=n[u]*e;for(u=f-1;u>0;--u)t[u]-=o[u]*e,t[--u]-=o[u]*e;0===u&&(t[0]-=o[0]*e)}}return h},numeric.det=function(e){var r=numeric.dim(e);if(2!==r.length||r[0]!==r[1])throw new Error("numeric: det() only works on square matrices");var n,t,o,i,a,u,s,c,l=r[0],f=1,m=numeric.clone(e);for(t=0;t<l-1;t++){for(o=t,n=t+1;n<l;n++)Math.abs(m[n][t])>Math.abs(m[o][t])&&(o=n);for(o!==t&&(s=m[o],m[o]=m[t],m[t]=s,f*=-1),i=m[t],n=t+1;n<l;n++){for(u=(a=m[n])[t]/i[t],o=t+1;o<l-1;o+=2)c=o+1,a[o]-=i[o]*u,a[c]-=i[c]*u;o!==l&&(a[o]-=i[o]*u)}if(0===i[t])return 0;f*=i[t]}return f*m[t][t]},numeric.transpose=function(e){var r,n,t,o,i,a=e.length,u=e[0].length,s=Array(u);for(n=0;n<u;n++)s[n]=Array(a);for(r=a-1;r>=1;r-=2){for(o=e[r],t=e[r-1],n=u-1;n>=1;--n)(i=s[n])[r]=o[n],i[r-1]=t[n],(i=s[--n])[r]=o[n],i[r-1]=t[n];0===n&&((i=s[0])[r]=o[0],i[r-1]=t[0])}if(0===r){for(t=e[0],n=u-1;n>=1;--n)s[n][0]=t[n],s[--n][0]=t[n];0===n&&(s[0][0]=t[0])}return s},numeric.negtranspose=function(e){var r,n,t,o,i,a=e.length,u=e[0].length,s=Array(u);for(n=0;n<u;n++)s[n]=Array(a);for(r=a-1;r>=1;r-=2){for(o=e[r],t=e[r-1],n=u-1;n>=1;--n)(i=s[n])[r]=-o[n],i[r-1]=-t[n],(i=s[--n])[r]=-o[n],i[r-1]=-t[n];0===n&&((i=s[0])[r]=-o[0],i[r-1]=-t[0])}if(0===r){for(t=e[0],n=u-1;n>=1;--n)s[n][0]=-t[n],s[--n][0]=-t[n];0===n&&(s[0][0]=-t[0])}return s},numeric._random=function e(r,n){var t,o,i=r[n],a=Array(i);if(n===r.length-1){for(o=Math.random,t=i-1;t>=1;t-=2)a[t]=o(),a[t-1]=o();return 0===t&&(a[0]=o()),a}for(t=i-1;t>=0;t--)a[t]=e(r,n+1);return a},numeric.random=function(e){return numeric._random(e,0)},numeric.norm2=function(e){return Math.sqrt(numeric.norm2Squared(e))},numeric.linspace=function(e,r,n){if(void 0===n&&(n=Math.max(Math.round(r-e)+1,1)),n<2)return 1===n?[e]:[];var t,o=Array(n);for(t=--n;t>=0;t--)o[t]=(t*r+(n-t)*e)/n;return o},numeric.getBlock=function(e,r,n){var t=numeric.dim(e);return function e(o,i){var a,u=r[i],s=n[i]-u,c=Array(s);if(i===t.length-1){for(a=s;a>=0;a--)c[a]=o[a+u];return c}for(a=s;a>=0;a--)c[a]=e(o[a+u],i+1);return c}(e,0)},numeric.setBlock=function(e,r,n,t){var o=numeric.dim(e);return function e(t,i,a){var u,s=r[a],c=n[a]-s;if(a===o.length-1)for(u=c;u>=0;u--)t[u+s]=i[u];for(u=c;u>=0;u--)e(t[u+s],i[u],a+1)}(e,t,0),e},numeric.getRange=function(e,r,n){var t,o,i,a,u=r.length,s=n.length,c=Array(u);for(t=u-1;-1!==t;--t)for(c[t]=Array(s),i=c[t],a=e[r[t]],o=s-1;-1!==o;--o)i[o]=a[n[o]];return c},numeric.blockMatrix=function(e){var r=numeric.dim(e);if(r.length<4)return numeric.blockMatrix([e]);var n,t,o,i,a,u=r[0],s=r[1];for(n=0,t=0,o=0;o<u;++o)n+=e[o][0].length;for(i=0;i<s;++i)t+=e[0][i][0].length;var c=Array(n);for(o=0;o<n;++o)c[o]=Array(t);var l,f,m,h,d,p=0;for(o=0;o<u;++o){for(l=t,i=s-1;-1!==i;--i)for(l-=(a=e[o][i])[0].length,m=a.length-1;-1!==m;--m)for(d=a[m],f=c[p+m],h=d.length-1;-1!==h;--h)f[l+h]=d[h];p+=e[o][0].length}return c},numeric.tensor=function(e,r){if("number"==typeof e||"number"==typeof r)return numeric.mul(e,r);var n=numeric.dim(e),t=numeric.dim(r);if(1!==n.length||1!==t.length)throw new Error("numeric: tensor product is only defined for vectors");var o,i,a,u,s=n[0],c=t[0],l=Array(s);for(i=s-1;i>=0;i--){for(o=Array(c),u=e[i],a=c-1;a>=3;--a)o[a]=u*r[a],o[--a]=u*r[a],o[--a]=u*r[a],o[--a]=u*r[a];for(;a>=0;)o[a]=u*r[a],--a;l[i]=o}return l},numeric.T=function(e,r){this.x=e,this.y=r},numeric.t=function(e,r){return new numeric.T(e,r)},numeric.Tbinop=function(e,r,n,t,o){var i;if(numeric.indexOf,"string"!=typeof o)for(i in o="",numeric)numeric.hasOwnProperty(i)&&(e.indexOf(i)>=0||r.indexOf(i)>=0||n.indexOf(i)>=0||t.indexOf(i)>=0)&&i.length>1&&(o+="var "+i+" = numeric."+i+";\n");return Function(["y"],"var x = this;\nif(!(y instanceof numeric.T)) { y = new numeric.T(y); }\n"+o+"\nif(x.y) { if(y.y) { return new numeric.T("+t+");\n }\n return new numeric.T("+n+");\n}\nif(y.y) {\n return new numeric.T("+r+");\n}\nreturn new numeric.T("+e+");\n")},numeric.T.prototype.add=numeric.Tbinop("add(x.x,y.x)","add(x.x,y.x),y.y","add(x.x,y.x),x.y","add(x.x,y.x),add(x.y,y.y)"),numeric.T.prototype.sub=numeric.Tbinop("sub(x.x,y.x)","sub(x.x,y.x),neg(y.y)","sub(x.x,y.x),x.y","sub(x.x,y.x),sub(x.y,y.y)"),numeric.T.prototype.mul=numeric.Tbinop("mul(x.x,y.x)","mul(x.x,y.x),mul(x.x,y.y)","mul(x.x,y.x),mul(x.y,y.x)","sub(mul(x.x,y.x),mul(x.y,y.y)),add(mul(x.x,y.y),mul(x.y,y.x))"),numeric.T.prototype.reciprocal=function(){var e=numeric.mul,r=numeric.div;if(this.y){var n=numeric.add(e(this.x,this.x),e(this.y,this.y));return new numeric.T(r(this.x,n),r(numeric.neg(this.y),n))}return new T(r(1,this.x))},numeric.T.prototype.div=function(e){if(e instanceof numeric.T||(e=new numeric.T(e)),e.y)return this.mul(e.reciprocal());var r=numeric.div;return this.y?new numeric.T(r(this.x,e.x),r(this.y,e.x)):new numeric.T(r(this.x,e.x))},numeric.T.prototype.dot=numeric.Tbinop("dot(x.x,y.x)","dot(x.x,y.x),dot(x.x,y.y)","dot(x.x,y.x),dot(x.y,y.x)","sub(dot(x.x,y.x),dot(x.y,y.y)),add(dot(x.x,y.y),dot(x.y,y.x))"),numeric.T.prototype.transpose=function(){var e=numeric.transpose,r=this.x,n=this.y;return n?new numeric.T(e(r),e(n)):new numeric.T(e(r))},numeric.T.prototype.transjugate=function(){var e=numeric.transpose,r=this.x,n=this.y;return n?new numeric.T(e(r),numeric.negtranspose(n)):new numeric.T(e(r))},numeric.Tunop=function(e,r,n){return"string"!=typeof n&&(n=""),Function("var x = this;\n"+n+"\nif(x.y) { "+r+";\n}\n"+e+";\n")},numeric.T.prototype.exp=numeric.Tunop("return new numeric.T(ex)","return new numeric.T(mul(cos(x.y),ex),mul(sin(x.y),ex))","var ex = numeric.exp(x.x), cos = numeric.cos, sin = numeric.sin, mul = numeric.mul;"),numeric.T.prototype.conj=numeric.Tunop("return new numeric.T(x.x);","return new numeric.T(x.x,numeric.neg(x.y));"),numeric.T.prototype.neg=numeric.Tunop("return new numeric.T(neg(x.x));","return new numeric.T(neg(x.x),neg(x.y));","var neg = numeric.neg;"),numeric.T.prototype.sin=numeric.Tunop("return new numeric.T(numeric.sin(x.x))","return x.exp().sub(x.neg().exp()).div(new numeric.T(0,2));"),numeric.T.prototype.cos=numeric.Tunop("return new numeric.T(numeric.cos(x.x))","return x.exp().add(x.neg().exp()).div(2);"),numeric.T.prototype.abs=numeric.Tunop("return new numeric.T(numeric.abs(x.x));","return new numeric.T(numeric.sqrt(numeric.add(mul(x.x,x.x),mul(x.y,x.y))));","var mul = numeric.mul;"),numeric.T.prototype.log=numeric.Tunop("return new numeric.T(numeric.log(x.x));","var theta = new numeric.T(numeric.atan2(x.y,x.x)), r = x.abs();\nreturn new numeric.T(numeric.log(r.x),theta.x);"),numeric.T.prototype.norm2=numeric.Tunop("return numeric.norm2(x.x);","var f = numeric.norm2Squared;\nreturn Math.sqrt(f(x.x)+f(x.y));"),numeric.T.prototype.inv=function(){var e=this;if(void 0===e.y)return new numeric.T(numeric.inv(e.x));var r,n,t,o,i,a,u,s,c,l,f,m,h,d,p,g,v,y,_=e.x.length,x=numeric.identity(_),w=numeric.rep([_,_],0),T=numeric.clone(e.x),b=numeric.clone(e.y);for(c=0;c<_;c++){for(m=(d=T[c][c])*d+(p=b[c][c])*p,f=c,l=c+1;l<_;l++)(h=(d=T[l][c])*d+(p=b[l][c])*p)>m&&(f=l,m=h);for(f!==c&&(y=T[c],T[c]=T[f],T[f]=y,y=b[c],b[c]=b[f],b[f]=y,y=x[c],x[c]=x[f],x[f]=y,y=w[c],w[c]=w[f],w[f]=y),r=T[c],n=b[c],i=x[c],a=w[c],d=r[c],p=n[c],l=c+1;l<_;l++)g=r[l],v=n[l],r[l]=(g*d+v*p)/m,n[l]=(v*d-g*p)/m;for(l=0;l<_;l++)g=i[l],v=a[l],i[l]=(g*d+v*p)/m,a[l]=(v*d-g*p)/m;for(l=c+1;l<_;l++){for(t=T[l],o=b[l],u=x[l],s=w[l],d=t[c],p=o[c],f=c+1;f<_;f++)g=r[f],v=n[f],t[f]-=g*d-v*p,o[f]-=v*d+g*p;for(f=0;f<_;f++)g=i[f],v=a[f],u[f]-=g*d-v*p,s[f]-=v*d+g*p}}for(c=_-1;c>0;c--)for(i=x[c],a=w[c],l=c-1;l>=0;l--)for(u=x[l],s=w[l],d=T[l][c],p=b[l][c],f=_-1;f>=0;f--)g=i[f],v=a[f],u[f]-=d*g-p*v,s[f]-=d*v+p*g;return new numeric.T(x,w)},numeric.T.prototype.get=function(e){var r,n=this.x,t=this.y,o=0,i=e.length;if(t){for(;o<i;)n=n[r=e[o]],t=t[r],o++;return new numeric.T(n,t)}for(;o<i;)n=n[r=e[o]],o++;return new numeric.T(n)},numeric.T.prototype.set=function(e,r){var n,t=this.x,o=this.y,i=0,a=e.length,u=r.x,s=r.y;if(0===a)return s?this.y=s:o&&(this.y=void 0),this.x=t,this;if(s){for(o||(o=numeric.rep(numeric.dim(t),0),this.y=o);i<a-1;)t=t[n=e[i]],o=o[n],i++;return t[n=e[i]]=u,o[n]=s,this}if(o){for(;i<a-1;)t=t[n=e[i]],o=o[n],i++;return t[n=e[i]]=u,o[n]=u instanceof Array?numeric.rep(numeric.dim(u),0):0,this}for(;i<a-1;)t=t[n=e[i]],i++;return t[n=e[i]]=u,this},numeric.T.prototype.getRows=function(e,r){var n,t,o=r-e+1,i=Array(o),a=this.x,u=this.y;for(n=e;n<=r;n++)i[n-e]=a[n];if(u){for(t=Array(o),n=e;n<=r;n++)t[n-e]=u[n];return new numeric.T(i,t)}return new numeric.T(i)},numeric.T.prototype.setRows=function(e,r,n){var t,o=this.x,i=this.y,a=n.x,u=n.y;for(t=e;t<=r;t++)o[t]=a[t-e];if(u)for(i||(i=numeric.rep(numeric.dim(o),0),this.y=i),t=e;t<=r;t++)i[t]=u[t-e];else if(i)for(t=e;t<=r;t++)i[t]=numeric.rep([a[t-e].length],0);return this},numeric.T.prototype.getRow=function(e){var r=this.x,n=this.y;return n?new numeric.T(r[e],n[e]):new numeric.T(r[e])},numeric.T.prototype.setRow=function(e,r){var n=this.x,t=this.y,o=r.x,i=r.y;return n[e]=o,i?(t||(t=numeric.rep(numeric.dim(n),0),this.y=t),t[e]=i):t&&(t=numeric.rep([o.length],0)),this},numeric.T.prototype.getBlock=function(e,r){var n=this.x,t=this.y,o=numeric.getBlock;return t?new numeric.T(o(n,e,r),o(t,e,r)):new numeric.T(o(n,e,r))},numeric.T.prototype.setBlock=function(e,r,n){n instanceof numeric.T||(n=new numeric.T(n));var t=this.x,o=this.y,i=numeric.setBlock,a=n.x,u=n.y;if(u)return o||(this.y=numeric.rep(numeric.dim(this),0),o=this.y),i(t,e,r,a),i(o,e,r,u),this;i(t,e,r,a),o&&i(o,e,r,numeric.rep(numeric.dim(a),0))},numeric.T.rep=function(e,r){var n=numeric.T;r instanceof n||(r=new n(r));var t=r.x,o=r.y,i=numeric.rep;return o?new n(i(e,t),i(e,o)):new n(i(e,t))},numeric.T.diag=function(e){e instanceof numeric.T||(e=new numeric.T(e));var r=e.x,n=e.y,t=numeric.diag;return n?new numeric.T(t(r),t(n)):new numeric.T(t(r))},numeric.T.eig=function(){if(this.y)throw new Error("eig: not implemented for complex matrices.");return numeric.eig(this.x)},numeric.T.identity=function(e){return new numeric.T(numeric.identity(e))},numeric.T.prototype.getDiag=function(){var e=numeric,r=this.x,n=this.y;return n?new e.T(e.getDiag(r),e.getDiag(n)):new e.T(e.getDiag(r))},numeric.house=function(e){var r=numeric.clone(e),n=(e[0]>=0?1:-1)*numeric.norm2(e);r[0]+=n;var t=numeric.norm2(r);if(0===t)throw new Error("eig: internal error");return numeric.div(r,t)},numeric.toUpperHessenberg=function(e){var r=numeric.dim(e);if(2!==r.length||r[0]!==r[1])throw new Error("numeric: toUpperHessenberg() only works on square matrices");var n,t,o,i,a,u,s,c,l,f,m=r[0],h=numeric.clone(e),d=numeric.identity(m);for(t=0;t<m-2;t++){for(i=Array(m-t-1),n=t+1;n<m;n++)i[n-t-1]=h[n][t];if(numeric.norm2(i)>0){for(a=numeric.house(i),u=numeric.getBlock(h,[t+1,t],[m-1,m-1]),s=numeric.tensor(a,numeric.dot(a,u)),n=t+1;n<m;n++)for(c=h[n],l=s[n-t-1],o=t;o<m;o++)c[o]-=2*l[o-t];for(u=numeric.getBlock(h,[0,t+1],[m-1,m-1]),s=numeric.tensor(numeric.dot(u,a),a),n=0;n<m;n++)for(c=h[n],l=s[n],o=t+1;o<m;o++)c[o]-=2*l[o-t-1];for(u=Array(m-t-1),n=t+1;n<m;n++)u[n-t-1]=d[n];for(s=numeric.tensor(a,numeric.dot(a,u)),n=t+1;n<m;n++)for(f=d[n],l=s[n-t-1],o=0;o<m;o++)f[o]-=2*l[o]}}return{H:h,Q:d}},numeric.epsilon=2220446049250313e-31,numeric.QRFrancis=function(e,r){void 0===r&&(r=1e4),e=numeric.clone(e),numeric.clone(e);var n,t,o,i,a,u,s,c,l,f,m,h,d,p,g,v,y,_,x=numeric.dim(e)[0],w=numeric.identity(x);if(x<3)return{Q:w,B:[[0,x-1]]};var T=numeric.epsilon;for(_=0;_<r;_++){for(v=0;v<x-1;v++)if(Math.abs(e[v+1][v])<T*(Math.abs(e[v][v])+Math.abs(e[v+1][v+1]))){var b=numeric.QRFrancis(numeric.getBlock(e,[0,0],[v,v]),r),A=numeric.QRFrancis(numeric.getBlock(e,[v+1,v+1],[x-1,x-1]),r);for(h=Array(v+1),g=0;g<=v;g++)h[g]=w[g];for(d=numeric.dot(b.Q,h),g=0;g<=v;g++)w[g]=d[g];for(h=Array(x-v-1),g=v+1;g<x;g++)h[g-v-1]=w[g];for(d=numeric.dot(A.Q,h),g=v+1;g<x;g++)w[g]=d[g-v-1];return{Q:w,B:b.B.concat(numeric.add(A.B,v+1))}}var I,E,S;for(o=e[x-2][x-2],i=e[x-2][x-1],a=e[x-1][x-2],c=o+(u=e[x-1][x-1]),s=o*u-i*a,l=numeric.getBlock(e,[0,0],[2,2]),c*c>=4*s?(I=.5*(c+Math.sqrt(c*c-4*s)),E=.5*(c-Math.sqrt(c*c-4*s)),l=numeric.add(numeric.sub(numeric.dot(l,l),numeric.mul(l,I+E)),numeric.diag(numeric.rep([3],I*E)))):l=numeric.add(numeric.sub(numeric.dot(l,l),numeric.mul(l,c)),numeric.diag(numeric.rep([3],s))),n=[l[0][0],l[1][0],l[2][0]],t=numeric.house(n),h=[e[0],e[1],e[2]],d=numeric.tensor(t,numeric.dot(t,h)),g=0;g<3;g++)for(m=e[g],p=d[g],y=0;y<x;y++)m[y]-=2*p[y];for(h=numeric.getBlock(e,[0,0],[x-1,2]),d=numeric.tensor(numeric.dot(h,t),t),g=0;g<x;g++)for(m=e[g],p=d[g],y=0;y<3;y++)m[y]-=2*p[y];for(h=[w[0],w[1],w[2]],d=numeric.tensor(t,numeric.dot(t,h)),g=0;g<3;g++)for(f=w[g],p=d[g],y=0;y<x;y++)f[y]-=2*p[y];for(v=0;v<x-2;v++){for(y=v;y<=v+1;y++)if(Math.abs(e[y+1][y])<T*(Math.abs(e[y][y])+Math.abs(e[y+1][y+1]))){for(b=numeric.QRFrancis(numeric.getBlock(e,[0,0],[y,y]),r),A=numeric.QRFrancis(numeric.getBlock(e,[y+1,y+1],[x-1,x-1]),r),h=Array(y+1),g=0;g<=y;g++)h[g]=w[g];for(d=numeric.dot(b.Q,h),g=0;g<=y;g++)w[g]=d[g];for(h=Array(x-y-1),g=y+1;g<x;g++)h[g-y-1]=w[g];for(d=numeric.dot(A.Q,h),g=y+1;g<x;g++)w[g]=d[g-y-1];return{Q:w,B:b.B.concat(numeric.add(A.B,y+1))}}for(S=Math.min(x-1,v+3),n=Array(S-v),g=v+1;g<=S;g++)n[g-v-1]=e[g][v];for(t=numeric.house(n),h=numeric.getBlock(e,[v+1,v],[S,x-1]),d=numeric.tensor(t,numeric.dot(t,h)),g=v+1;g<=S;g++)for(m=e[g],p=d[g-v-1],y=v;y<x;y++)m[y]-=2*p[y-v];for(h=numeric.getBlock(e,[0,v+1],[x-1,S]),d=numeric.tensor(numeric.dot(h,t),t),g=0;g<x;g++)for(m=e[g],p=d[g],y=v+1;y<=S;y++)m[y]-=2*p[y-v-1];for(h=Array(S-v),g=v+1;g<=S;g++)h[g-v-1]=w[g];for(d=numeric.tensor(t,numeric.dot(t,h)),g=v+1;g<=S;g++)for(f=w[g],p=d[g-v-1],y=0;y<x;y++)f[y]-=2*p[y]}}throw new Error("numeric: eigenvalue iteration does not converge -- increase maxiter?")},numeric.eig=function(e,r){var n,t,o,i,a,u,s,c,l,f,m,h,d,p,g,v,y=numeric.toUpperHessenberg(e),_=numeric.QRFrancis(y.H,r),x=numeric.T,w=e.length,T=_.B,b=numeric.dot(_.Q,numeric.dot(y.H,numeric.transpose(_.Q))),A=new x(numeric.dot(_.Q,y.Q)),I=T.length,E=Math.sqrt;for(t=0;t<I;t++)if((n=T[t][0])!==T[t][1]){if(i=n+1,a=b[n][n],u=b[n][i],s=b[i][n],c=b[i][i],0===u&&0===s)continue;(f=(l=-a-c)*l-4*(a*c-u*s))>=0?((g=(a-(m=l<0?-.5*(l-E(f)):-.5*(l+E(f))))*(a-m)+u*u)>(v=s*s+(c-m)*(c-m))?(d=(a-m)/(g=E(g)),p=u/g):(d=s/(v=E(v)),p=(c-m)/v),o=new x([[p,-d],[d,p]]),A.setRows(n,i,o.dot(A.getRows(n,i)))):(m=-.5*l,h=.5*E(-f),(g=(a-m)*(a-m)+u*u)>(v=s*s+(c-m)*(c-m))?(d=(a-m)/(g=E(g+h*h)),p=u/g,m=0,h/=g):(d=s/(v=E(v+h*h)),p=(c-m)/v,m=h/v,h=0),o=new x([[p,-d],[d,p]],[[m,h],[h,-m]]),A.setRows(n,i,o.dot(A.getRows(n,i))))}var S=A.dot(e).dot(A.transjugate()),M=(w=e.length,numeric.T.identity(w));for(i=0;i<w;i++)if(i>0)for(t=i-1;t>=0;t--){var N=S.get([t,t]),C=S.get([i,i]);numeric.neq(N.x,C.x)||numeric.neq(N.y,C.y)?(m=S.getRow(t).getBlock([t],[i-1]),h=M.getRow(i).getBlock([t],[i-1]),M.set([i,t],S.get([t,i]).neg().sub(m.dot(h)).div(N.sub(C)))):M.setRow(i,M.getRow(t))}for(i=0;i<w;i++)m=M.getRow(i),M.setRow(i,m.div(m.norm2()));return M=M.transpose(),M=A.transjugate().dot(M),{lambda:S.getDiag(),E:M}},numeric.ccsSparse=function(e){var r,n,t,o=e.length,i=[];for(n=o-1;-1!==n;--n)for(t in r=e[n]){for(t=parseInt(t);t>=i.length;)i[i.length]=0;0!==r[t]&&i[t]++}var a=i.length,u=Array(a+1);for(u[0]=0,n=0;n<a;++n)u[n+1]=u[n]+i[n];var s=Array(u[a]),c=Array(u[a]);for(n=o-1;-1!==n;--n)for(t in r=e[n])0!==r[t]&&(i[t]--,s[u[t]+i[t]]=n,c[u[t]+i[t]]=r[t]);return[u,s,c]},numeric.ccsFull=function(e){var r,n,t,o,i=e[0],a=e[1],u=e[2],s=numeric.ccsDim(e),c=s[0],l=s[1],f=numeric.rep([c,l],0);for(r=0;r<l;r++)for(t=i[r],o=i[r+1],n=t;n<o;++n)f[a[n]][r]=u[n];return f},numeric.ccsTSolve=function(e,r,n,t,o){function i(e){var r;if(0===n[e]){for(n[e]=1,r=h[e];r<h[e+1];++r)i(d[r]);o[y]=e,++y}}var a,u,s,c,l,f,m,h=e[0],d=e[1],p=e[2],g=h.length-1,v=Math.max,y=0;for(void 0===t&&(n=numeric.rep([g],0)),void 0===t&&(t=numeric.linspace(0,n.length-1)),void 0===o&&(o=[]),a=t.length-1;-1!==a;--a)i(t[a]);for(o.length=y,a=o.length-1;-1!==a;--a)n[o[a]]=0;for(a=t.length-1;-1!==a;--a)u=t[a],n[u]=r[u];for(a=o.length-1;-1!==a;--a){for(u=o[a],s=h[u],c=v(h[u+1],s),l=s;l!==c;++l)if(d[l]===u){n[u]/=p[l];break}for(m=n[u],l=s;l!==c;++l)(f=d[l])!==u&&(n[f]-=m*p[l])}return n},numeric.ccsDFS=function(e){this.k=Array(e),this.k1=Array(e),this.j=Array(e)},numeric.ccsDFS.prototype.dfs=function(e,r,n,t,o,i){var a,u,s,c=0,l=o.length,f=this.k,m=this.k1,h=this.j;if(0===t[e])for(t[e]=1,h[0]=e,f[0]=u=r[e],m[0]=s=r[e+1];;)if(u>=s){if(o[l]=h[c],0===c)return;++l,u=f[--c],s=m[c]}else 0===t[a=i[n[u]]]?(t[a]=1,f[c]=u,h[++c]=a,u=r[a],m[c]=s=r[a+1]):++u},numeric.ccsLPSolve=function(e,r,n,t,o,i,a){var u,s,c,l,f,m,h,d,p,g=e[0],v=e[1],y=e[2],_=(g.length,r[0]),x=r[1],w=r[2];for(s=_[o],c=_[o+1],t.length=0,u=s;u<c;++u)a.dfs(i[x[u]],g,v,n,t,i);for(u=t.length-1;-1!==u;--u)n[t[u]]=0;for(u=s;u!==c;++u)n[l=i[x[u]]]=w[u];for(u=t.length-1;-1!==u;--u){for(f=g[l=t[u]],m=g[l+1],h=f;h<m;++h)if(i[v[h]]===l){n[l]/=y[h];break}for(p=n[l],h=f;h<m;++h)(d=i[v[h]])!==l&&(n[d]-=p*y[h])}return n},numeric.ccsLUP1=function(e,r){var n,t,o,i,a,u,s,c=e[0].length-1,l=[numeric.rep([c+1],0),[],[]],f=[numeric.rep([c+1],0),[],[]],m=l[0],h=l[1],d=l[2],p=f[0],g=f[1],v=f[2],y=numeric.rep([c],0),_=numeric.rep([c],0),x=numeric.ccsLPSolve,w=(Math.max,Math.abs),T=numeric.linspace(0,c-1),b=numeric.linspace(0,c-1),A=new numeric.ccsDFS(c);for(void 0===r&&(r=1),n=0;n<c;++n){for(x(l,e,y,_,n,b,A),i=-1,a=-1,t=_.length-1;-1!==t;--t)(o=_[t])<=n||(u=w(y[o]))>i&&(a=o,i=u);for(w(y[n])<r*i&&(t=T[n],i=T[a],T[n]=i,b[i]=n,T[a]=t,b[t]=a,i=y[n],y[n]=y[a],y[a]=i),i=m[n],a=p[n],s=y[n],h[i]=T[n],d[i]=1,++i,t=_.length-1;-1!==t;--t)u=y[o=_[t]],_[t]=0,y[o]=0,o<=n?(g[a]=o,v[a]=u,++a):(h[i]=T[o],d[i]=u/s,++i);m[n+1]=i,p[n+1]=a}for(t=h.length-1;-1!==t;--t)h[t]=b[h[t]];return{L:l,U:f,P:T,Pinv:b}},numeric.ccsDFS0=function(e){this.k=Array(e),this.k1=Array(e),this.j=Array(e)},numeric.ccsDFS0.prototype.dfs=function(e,r,n,t,o,i,a){var u,s,c,l=0,f=o.length,m=this.k,h=this.k1,d=this.j;if(0===t[e])for(t[e]=1,d[0]=e,m[0]=s=r[i[e]],h[0]=c=r[i[e]+1];;){if(isNaN(s))throw new Error("Ow!");if(s>=c){if(o[f]=i[d[l]],0===l)return;++f,s=m[--l],c=h[l]}else 0===t[u=n[s]]?(t[u]=1,m[l]=s,d[++l]=u,s=r[u=i[u]],h[l]=c=r[u+1]):++s}},numeric.ccsLPSolve0=function(e,r,n,t,o,i,a,u){var s,c,l,f,m,h,d,p,g,v=e[0],y=e[1],_=e[2],x=(v.length,r[0]),w=r[1],T=r[2];for(c=x[o],l=x[o+1],t.length=0,s=c;s<l;++s)u.dfs(w[s],v,y,n,t,i,a);for(s=t.length-1;-1!==s;--s)n[a[f=t[s]]]=0;for(s=c;s!==l;++s)n[f=w[s]]=T[s];for(s=t.length-1;-1!==s;--s){for(p=a[f=t[s]],m=v[f],h=v[f+1],d=m;d<h;++d)if(y[d]===p){n[p]/=_[d];break}for(g=n[p],d=m;d<h;++d)n[y[d]]-=g*_[d];n[p]=g}},numeric.ccsLUP0=function(e,r){var n,t,o,i,a,u,s,c=e[0].length-1,l=[numeric.rep([c+1],0),[],[]],f=[numeric.rep([c+1],0),[],[]],m=l[0],h=l[1],d=l[2],p=f[0],g=f[1],v=f[2],y=numeric.rep([c],0),_=numeric.rep([c],0),x=numeric.ccsLPSolve0,w=(Math.max,Math.abs),T=numeric.linspace(0,c-1),b=numeric.linspace(0,c-1),A=new numeric.ccsDFS0(c);for(void 0===r&&(r=1),n=0;n<c;++n){for(x(l,e,y,_,n,b,T,A),i=-1,a=-1,t=_.length-1;-1!==t;--t)(o=_[t])<=n||(u=w(y[T[o]]))>i&&(a=o,i=u);for(w(y[T[n]])<r*i&&(t=T[n],i=T[a],T[n]=i,b[i]=n,T[a]=t,b[t]=a),i=m[n],a=p[n],s=y[T[n]],h[i]=T[n],d[i]=1,++i,t=_.length-1;-1!==t;--t)u=y[T[o=_[t]]],_[t]=0,y[T[o]]=0,o<=n?(g[a]=o,v[a]=u,++a):(h[i]=T[o],d[i]=u/s,++i);m[n+1]=i,p[n+1]=a}for(t=h.length-1;-1!==t;--t)h[t]=b[h[t]];return{L:l,U:f,P:T,Pinv:b}},numeric.ccsLUP=numeric.ccsLUP0,numeric.ccsDim=function(e){return[numeric.sup(e[1])+1,e[0].length-1]},numeric.ccsGetBlock=function(e,r,n){var t=numeric.ccsDim(e),o=t[0],i=t[1];void 0===r?r=numeric.linspace(0,o-1):"number"==typeof r&&(r=[r]),void 0===n?n=numeric.linspace(0,i-1):"number"==typeof n&&(n=[n]);var a,u,s,c,l=r.length,f=n.length,m=numeric.rep([i],0),h=[],d=[],p=[m,h,d],g=e[0],v=e[1],y=e[2],_=numeric.rep([o],0),x=0,w=numeric.rep([o],0);for(u=0;u<f;++u){var T=g[c=n[u]],b=g[c+1];for(a=T;a<b;++a)w[s=v[a]]=1,_[s]=y[a];for(a=0;a<l;++a)w[r[a]]&&(h[x]=a,d[x]=_[r[a]],++x);for(a=T;a<b;++a)w[s=v[a]]=0;m[u+1]=x}return p},numeric.ccsDot=function(e,r){var n,t,o,i,a,u,s,c,l,f,m,h=e[0],d=e[1],p=e[2],g=r[0],v=r[1],y=r[2],_=numeric.ccsDim(e),x=numeric.ccsDim(r),w=_[0],T=(_[1],x[1]),b=numeric.rep([w],0),A=numeric.rep([w],0),I=Array(w),E=numeric.rep([T],0),S=[],M=[],N=[E,S,M];for(o=0;o!==T;++o){for(i=g[o],a=g[o+1],l=0,t=i;t<a;++t)for(f=v[t],m=y[t],u=h[f],s=h[f+1],n=u;n<s;++n)0===A[c=d[n]]&&(I[l]=c,A[c]=1,l+=1),b[c]=b[c]+p[n]*m;for(a=(i=E[o])+l,E[o+1]=a,t=l-1;-1!==t;--t)m=i+t,n=I[t],S[m]=n,M[m]=b[n],A[n]=0,b[n]=0;E[o+1]=E[o]+l}return N},numeric.ccsLUPSolve=function(e,r){var n=e.L,t=e.U,o=(e.P,r[0]),i=!1;"object"!=typeof o&&(o=(r=[[0,r.length],numeric.linspace(0,r.length-1),r])[0],i=!0);var a,u,s,c,l,f,m=r[1],h=r[2],d=n[0].length-1,p=o.length-1,g=numeric.rep([d],0),v=Array(d),y=numeric.rep([d],0),_=Array(d),x=numeric.rep([p+1],0),w=[],T=[],b=numeric.ccsTSolve,A=0;for(a=0;a<p;++a){for(l=0,s=o[a],c=o[a+1],u=s;u<c;++u)f=e.Pinv[m[u]],_[l]=f,y[f]=h[u],++l;for(_.length=l,b(n,y,g,_,v),u=_.length-1;-1!==u;--u)y[_[u]]=0;if(b(t,g,y,v,_),i)return y;for(u=v.length-1;-1!==u;--u)g[v[u]]=0;for(u=_.length-1;-1!==u;--u)f=_[u],w[A]=f,T[A]=y[f],y[f]=0,++A;x[a+1]=A}return[x,w,T]},numeric.ccsbinop=function(e,r){return void 0===r&&(r=""),Function("X","Y","var Xi = X[0], Xj = X[1], Xv = X[2];\nvar Yi = Y[0], Yj = Y[1], Yv = Y[2];\nvar n = Xi.length-1,m = Math.max(numeric.sup(Xj),numeric.sup(Yj))+1;\nvar Zi = numeric.rep([n+1],0), Zj = [], Zv = [];\nvar x = numeric.rep([m],0),y = numeric.rep([m],0);\nvar xk,yk,zk;\nvar i,j,j0,j1,k,p=0;\n"+r+"for(i=0;i<n;++i) {\n j0 = Xi[i]; j1 = Xi[i+1];\n for(j=j0;j!==j1;++j) {\n k = Xj[j];\n x[k] = 1;\n Zj[p] = k;\n ++p;\n }\n j0 = Yi[i]; j1 = Yi[i+1];\n for(j=j0;j!==j1;++j) {\n k = Yj[j];\n y[k] = Yv[j];\n if(x[k] === 0) {\n Zj[p] = k;\n ++p;\n }\n }\n Zi[i+1] = p;\n j0 = Xi[i]; j1 = Xi[i+1];\n for(j=j0;j!==j1;++j) x[Xj[j]] = Xv[j];\n j0 = Zi[i]; j1 = Zi[i+1];\n for(j=j0;j!==j1;++j) {\n k = Zj[j];\n xk = x[k];\n yk = y[k];\n"+e+"\n Zv[j] = zk;\n }\n j0 = Xi[i]; j1 = Xi[i+1];\n for(j=j0;j!==j1;++j) x[Xj[j]] = 0;\n j0 = Yi[i]; j1 = Yi[i+1];\n for(j=j0;j!==j1;++j) y[Yj[j]] = 0;\n}\nreturn [Zi,Zj,Zv];")},function(){var k,A,B,C;for(k in numeric.ops2)A=isFinite(eval("1"+numeric.ops2[k]+"0"))?"[Y[0],Y[1],numeric."+k+"(X,Y[2])]":"NaN",B=isFinite(eval("0"+numeric.ops2[k]+"1"))?"[X[0],X[1],numeric."+k+"(X[2],Y)]":"NaN",C=isFinite(eval("1"+numeric.ops2[k]+"0"))&&isFinite(eval("0"+numeric.ops2[k]+"1"))?"numeric.ccs"+k+"MM(X,Y)":"NaN",numeric["ccs"+k+"MM"]=numeric.ccsbinop("zk = xk "+numeric.ops2[k]+"yk;"),numeric["ccs"+k]=Function("X","Y",'if(typeof X === "number") return '+A+';\nif(typeof Y === "number") return '+B+";\nreturn "+C+";\n")}(),numeric.ccsScatter=function(e){var r,n=e[0],t=e[1],o=e[2],i=numeric.sup(t)+1,a=n.length,u=numeric.rep([i],0),s=Array(a),c=Array(a),l=numeric.rep([i],0);for(r=0;r<a;++r)l[t[r]]++;for(r=0;r<i;++r)u[r+1]=u[r]+l[r];var f,m,h=u.slice(0);for(r=0;r<a;++r)s[f=h[m=t[r]]]=n[r],c[f]=o[r],h[m]=h[m]+1;return[u,s,c]},numeric.ccsGather=function(e){var r,n,t,o,i,a=e[0],u=e[1],s=e[2],c=a.length-1,l=u.length,f=Array(l),m=Array(l),h=Array(l);for(i=0,r=0;r<c;++r)for(t=a[r],o=a[r+1],n=t;n!==o;++n)m[i]=r,f[i]=u[n],h[i]=s[n],++i;return[f,m,h]},numeric.sdim=function e(r,n,t){if(void 0===n&&(n=[]),"object"!=typeof r)return n;var o;for(o in void 0===t&&(t=0),t in n||(n[t]=0),r.length>n[t]&&(n[t]=r.length),r)r.hasOwnProperty(o)&&e(r[o],n,t+1);return n},numeric.sclone=function e(r,n,t){void 0===n&&(n=0),void 0===t&&(t=numeric.sdim(r).length);var o,i=Array(r.length);if(n===t-1){for(o in r)r.hasOwnProperty(o)&&(i[o]=r[o]);return i}for(o in r)r.hasOwnProperty(o)&&(i[o]=e(r[o],n+1,t));return i},numeric.sdiag=function(e){var r,n,t=e.length,o=Array(t);for(r=t-1;r>=1;r-=2)n=r-1,o[r]=[],o[r][r]=e[r],o[n]=[],o[n][n]=e[n];return 0===r&&(o[0]=[],o[0][0]=e[r]),o},numeric.sidentity=function(e){return numeric.sdiag(numeric.rep([e],1))},numeric.stranspose=function(e){var r,n,t,o=[];for(r in e.length,e)if(e.hasOwnProperty(r))for(n in t=e[r])t.hasOwnProperty(n)&&("object"!=typeof o[n]&&(o[n]=[]),o[n][r]=t[n]);return o},numeric.sLUP=function(e,r){throw new Error("The function numeric.sLUP had a bug in it and has been removed. Please use the new numeric.ccsLUP function instead.")},numeric.sdotMM=function(e,r){var n,t,o,i,a,u,s,c=e.length,l=(r.length,numeric.stranspose(r)),f=l.length,m=Array(c);for(o=c-1;o>=0;o--){for(s=[],n=e[o],a=f-1;a>=0;a--){for(i in u=0,t=l[a],n)n.hasOwnProperty(i)&&i in t&&(u+=n[i]*t[i]);u&&(s[a]=u)}m[o]=s}return m},numeric.sdotMV=function(e,r){var n,t,o,i,a=e.length,u=Array(a);for(t=a-1;t>=0;t--){for(o in i=0,n=e[t])n.hasOwnProperty(o)&&r[o]&&(i+=n[o]*r[o]);i&&(u[t]=i)}return u},numeric.sdotVM=function(e,r){var n,t,o,i,a=[];for(n in e)if(e.hasOwnProperty(n))for(t in o=r[n],i=e[n],o)o.hasOwnProperty(t)&&(a[t]||(a[t]=0),a[t]+=i*o[t]);return a},numeric.sdotVV=function(e,r){var n,t=0;for(n in e)e[n]&&r[n]&&(t+=e[n]*r[n]);return t},numeric.sdot=function(e,r){var n=numeric.sdim(e).length,t=numeric.sdim(r).length;switch(1e3*n+t){case 0:return e*r;case 1001:return numeric.sdotVV(e,r);case 2001:return numeric.sdotMV(e,r);case 1002:return numeric.sdotVM(e,r);case 2002:return numeric.sdotMM(e,r);default:throw new Error("numeric.sdot not implemented for tensors of order "+n+" and "+t)}},numeric.sscatter=function(e){var r,n,t,o,i=e[0].length,a=e.length,u=[];for(n=i-1;n>=0;--n)if(e[a-1][n]){for(o=u,t=0;t<a-2;t++)o[r=e[t][n]]||(o[r]=[]),o=o[r];o[e[t][n]]=e[t+1][n]}return u},numeric.sgather=function e(r,n,t){var o,i,a;for(i in void 0===n&&(n=[]),void 0===t&&(t=[]),o=t.length,r)if(r.hasOwnProperty(i))if(t[o]=parseInt(i),"number"==typeof(a=r[i])){if(a){if(0===n.length)for(i=o+1;i>=0;--i)n[i]=[];for(i=o;i>=0;--i)n[i].push(t[i]);n[o+1].push(a)}}else e(a,n,t);return t.length>o&&t.pop(),n},numeric.cLU=function(e){var r,n,t,o,i,a,u=e[0],s=e[1],c=e[2],l=u.length,f=0;for(r=0;r<l;r++)u[r]>f&&(f=u[r]);f++;var m,h=Array(f),d=Array(f),p=numeric.rep([f],1/0),g=numeric.rep([f],-1/0);for(t=0;t<l;t++)r=u[t],(n=s[t])<p[r]&&(p[r]=n),n>g[r]&&(g[r]=n);for(r=0;r<f-1;r++)g[r]>g[r+1]&&(g[r+1]=g[r]);for(r=f-1;r>=1;r--)p[r]<p[r-1]&&(p[r-1]=p[r]);for(r=0;r<f;r++)d[r]=numeric.rep([g[r]-p[r]+1],0),h[r]=numeric.rep([r-p[r]],0),p[r],g[r];for(t=0;t<l;t++)d[r=u[t]][s[t]-p[r]]=c[t];for(r=0;r<f-1;r++)for(o=r-p[r],_=d[r],n=r+1;p[n]<=r&&n<f;n++)if(i=r-p[n],a=g[r]-r,m=(x=d[n])[i]/_[o]){for(t=1;t<=a;t++)x[t+i]-=m*_[t+o];h[n][r-p[n]]=m}var v,y,_=[],x=[],w=[],T=[],b=[],A=[];for(l=0,v=0,r=0;r<f;r++){for(o=p[r],i=g[r],y=d[r],n=r;n<=i;n++)y[n-o]&&(_[l]=r,x[l]=n,w[l]=y[n-o],l++);for(y=h[r],n=o;n<r;n++)y[n-o]&&(T[v]=r,b[v]=n,A[v]=y[n-o],v++);T[v]=r,b[v]=r,A[v]=1,v++}return{U:[_,x,w],L:[T,b,A]}},numeric.cLUsolve=function(e,r){var n,t,o=e.L,i=e.U,a=numeric.clone(r),u=o[0],s=o[1],c=o[2],l=i[0],f=i[1],m=i[2],h=l.length,d=(u.length,a.length);for(t=0,n=0;n<d;n++){for(;s[t]<n;)a[n]-=c[t]*a[s[t]],t++;t++}for(t=h-1,n=d-1;n>=0;n--){for(;f[t]>n;)a[n]-=m[t]*a[f[t]],t--;a[n]/=m[t],t--}return a},numeric.cgrid=function(e,r){"number"==typeof e&&(e=[e,e]);var n,t,o,i=numeric.rep(e,-1);for("function"!=typeof r&&(r="L"===r?function(r,n){return r>=e[0]/2||n<e[1]/2}:function(e,r){return!0}),o=0,n=1;n<e[0]-1;n++)for(t=1;t<e[1]-1;t++)r(n,t)&&(i[n][t]=o,o++);return i},numeric.cdelsq=function(e){var r,n,t,o,i,a=[[-1,0],[0,-1],[0,1],[1,0]],u=numeric.dim(e),s=u[0],c=u[1],l=[],f=[],m=[];for(r=1;r<s-1;r++)for(n=1;n<c-1;n++)if(!(e[r][n]<0)){for(t=0;t<4;t++)o=r+a[t][0],i=n+a[t][1],e[o][i]<0||(l.push(e[r][n]),f.push(e[o][i]),m.push(-1));l.push(e[r][n]),f.push(e[r][n]),m.push(4)}return[l,f,m]},numeric.cdotMV=function(e,r){var n,t,o,i=e[0],a=e[1],u=e[2],s=i.length;for(o=0,t=0;t<s;t++)i[t]>o&&(o=i[t]);for(o++,n=numeric.rep([o],0),t=0;t<s;t++)n[i[t]]+=u[t]*r[a[t]];return n},numeric.Spline=function(e,r,n,t,o){this.x=e,this.yl=r,this.yr=n,this.kl=t,this.kr=o},numeric.Spline.prototype._at=function(e,r){var n,t,o,i=this.x,a=this.yl,u=this.yr,s=this.kl,c=this.kr,l=numeric.add,f=numeric.sub,m=numeric.mul;n=f(m(s[r],i[r+1]-i[r]),f(u[r+1],a[r])),t=l(m(c[r+1],i[r]-i[r+1]),f(u[r+1],a[r]));var h=(o=(e-i[r])/(i[r+1]-i[r]))*(1-o);return l(l(l(m(1-o,a[r]),m(o,u[r+1])),m(n,h*(1-o))),m(t,h*o))},numeric.Spline.prototype.at=function(e){if("number"==typeof e){var r,n,t,o=this.x,i=o.length,a=Math.floor;for(r=0,n=i-1;n-r>1;)o[t=a((r+n)/2)]<=e?r=t:n=t;return this._at(e,r)}i=e.length;var u,s=Array(i);for(u=i-1;-1!==u;--u)s[u]=this.at(e[u]);return s},numeric.Spline.prototype.diff=function(){var e,r,n,t=this.x,o=this.yl,i=this.yr,a=this.kl,u=this.kr,s=o.length,c=a,l=u,f=Array(s),m=Array(s),h=numeric.add,d=numeric.mul,p=numeric.div,g=numeric.sub;for(e=s-1;-1!==e;--e)r=t[e+1]-t[e],n=g(i[e+1],o[e]),f[e]=p(h(d(n,6),d(a[e],-4*r),d(u[e+1],-2*r)),r*r),m[e+1]=p(h(d(n,-6),d(a[e],2*r),d(u[e+1],4*r)),r*r);return new numeric.Spline(t,c,l,f,m)},numeric.Spline.prototype.roots=function(){var e=[],r=this.x,n=this.yl,t=this.yr,o=this.kl,i=this.kr;"number"==typeof n[0]&&(n=[n],t=[t],o=[o],i=[i]);var a,u,s,c,l,f,m,h,d,p,g,v,y,_,x,w,T,b,A,I,E,S,M,N,C=n.length,P=r.length-1,O=(e=Array(C),Math.sqrt);for(a=0;a!==C;++a){for(c=n[a],l=t[a],f=o[a],m=i[a],h=[],u=0;u!==P;u++){for(u>0&&l[u]*c[u]<0&&h.push(r[u]),w=r[u+1]-r[u],r[u],g=c[u],v=l[u+1],d=f[u]/w,y=(p=m[u+1]/w)+3*g+2*d-3*v,_=3*(p+d+2*(g-v)),(x=(N=d-p+3*(g-v))*N+12*p*g)<=0?T=(b=y/_)>r[u]&&b<r[u+1]?[r[u],b,r[u+1]]:[r[u],r[u+1]]:(b=(y-O(x))/_,A=(y+O(x))/_,T=[r[u]],b>r[u]&&b<r[u+1]&&T.push(b),A>r[u]&&A<r[u+1]&&T.push(A),T.push(r[u+1])),E=T[0],b=this._at(E,u),s=0;s<T.length-1;s++)if(S=T[s+1],A=this._at(S,u),0!==b)if(0===A||b*A>0)E=S,b=A;else{for(var L=0;!((M=(b*S-A*E)/(b-A))<=E||M>=S);)if((I=this._at(M,u))*A>0)S=M,A=I,-1===L&&(b*=.5),L=-1;else{if(!(I*b>0))break;E=M,b=I,1===L&&(A*=.5),L=1}h.push(M),E=T[s+1],b=this._at(E,u)}else h.push(E),E=S,b=A;0===A&&h.push(S)}e[a]=h}return"number"==typeof this.yl[0]?e[0]:e},numeric.spline=function(e,r,n,t){var o,i=e.length,a=[],u=[],s=[],c=numeric.sub,l=numeric.mul,f=numeric.add;for(o=i-2;o>=0;o--)u[o]=e[o+1]-e[o],s[o]=c(r[o+1],r[o]);"string"!=typeof n&&"string"!=typeof t||(n=t="periodic");var m=[[],[],[]];switch(typeof n){case"undefined":a[0]=l(3/(u[0]*u[0]),s[0]),m[0].push(0,0),m[1].push(0,1),m[2].push(2/u[0],1/u[0]);break;case"string":a[0]=f(l(3/(u[i-2]*u[i-2]),s[i-2]),l(3/(u[0]*u[0]),s[0])),m[0].push(0,0,0),m[1].push(i-2,0,1),m[2].push(1/u[i-2],2/u[i-2]+2/u[0],1/u[0]);break;default:a[0]=n,m[0].push(0),m[1].push(0),m[2].push(1)}for(o=1;o<i-1;o++)a[o]=f(l(3/(u[o-1]*u[o-1]),s[o-1]),l(3/(u[o]*u[o]),s[o])),m[0].push(o,o,o),m[1].push(o-1,o,o+1),m[2].push(1/u[o-1],2/u[o-1]+2/u[o],1/u[o]);switch(typeof t){case"undefined":a[i-1]=l(3/(u[i-2]*u[i-2]),s[i-2]),m[0].push(i-1,i-1),m[1].push(i-2,i-1),m[2].push(1/u[i-2],2/u[i-2]);break;case"string":m[1][m[1].length-1]=0;break;default:a[i-1]=t,m[0].push(i-1),m[1].push(i-1),m[2].push(1)}a="number"!=typeof a[0]?numeric.transpose(a):[a];var h=Array(a.length);if("string"==typeof n)for(o=h.length-1;-1!==o;--o)h[o]=numeric.ccsLUPSolve(numeric.ccsLUP(numeric.ccsScatter(m)),a[o]),h[o][i-1]=h[o][0];else for(o=h.length-1;-1!==o;--o)h[o]=numeric.cLUsolve(numeric.cLU(m),a[o]);return h="number"==typeof r[0]?h[0]:numeric.transpose(h),new numeric.Spline(e,r,r,h,h)},numeric.fftpow2=function e(r,n){var t=r.length;if(1!==t){var o,i,a=Math.cos,u=Math.sin,s=Array(t/2),c=Array(t/2),l=Array(t/2),f=Array(t/2);for(i=t/2,o=t-1;-1!==o;--o)l[--i]=r[o],f[i]=n[o],--o,s[i]=r[o],c[i]=n[o];e(s,c),e(l,f),i=t/2;var m,h,d,p=-6.283185307179586/t;for(o=t-1;-1!==o;--o)-1==--i&&(i=t/2-1),h=a(m=p*o),d=u(m),r[o]=s[i]+h*l[i]-d*f[i],n[o]=c[i]+h*f[i]+d*l[i]}},numeric._ifftpow2=function e(r,n){var t=r.length;if(1!==t){var o,i,a=Math.cos,u=Math.sin,s=Array(t/2),c=Array(t/2),l=Array(t/2),f=Array(t/2);for(i=t/2,o=t-1;-1!==o;--o)l[--i]=r[o],f[i]=n[o],--o,s[i]=r[o],c[i]=n[o];e(s,c),e(l,f),i=t/2;var m,h,d,p=6.283185307179586/t;for(o=t-1;-1!==o;--o)-1==--i&&(i=t/2-1),h=a(m=p*o),d=u(m),r[o]=s[i]+h*l[i]-d*f[i],n[o]=c[i]+h*f[i]+d*l[i]}},numeric.ifftpow2=function(e,r){numeric._ifftpow2(e,r),numeric.diveq(e,e.length),numeric.diveq(r,r.length)},numeric.convpow2=function(e,r,n,t){var o,i,a,u,s;for(numeric.fftpow2(e,r),numeric.fftpow2(n,t),o=e.length-1;-1!==o;--o)i=e[o],u=r[o],a=n[o],s=t[o],e[o]=i*a-u*s,r[o]=i*s+u*a;numeric.ifftpow2(e,r)},numeric.T.prototype.fft=function(){var e,r,n=this.x,t=this.y,o=n.length,i=Math.log,a=i(2),u=Math.ceil(i(2*o-1)/a),s=Math.pow(2,u),c=numeric.rep([s],0),l=numeric.rep([s],0),f=Math.cos,m=Math.sin,h=-3.141592653589793/o,d=numeric.rep([s],0),p=numeric.rep([s],0);for(Math.floor(o/2),e=0;e<o;e++)d[e]=n[e];if(void 0!==t)for(e=0;e<o;e++)p[e]=t[e];for(c[0]=1,e=1;e<=s/2;e++)r=h*e*e,c[e]=f(r),l[e]=m(r),c[s-e]=f(r),l[s-e]=m(r);var g=new numeric.T(d,p),v=new numeric.T(c,l);return g=g.mul(v),numeric.convpow2(g.x,g.y,numeric.clone(v.x),numeric.neg(v.y)),(g=g.mul(v)).x.length=o,g.y.length=o,g},numeric.T.prototype.ifft=function(){var e,r,n=this.x,t=this.y,o=n.length,i=Math.log,a=i(2),u=Math.ceil(i(2*o-1)/a),s=Math.pow(2,u),c=numeric.rep([s],0),l=numeric.rep([s],0),f=Math.cos,m=Math.sin,h=3.141592653589793/o,d=numeric.rep([s],0),p=numeric.rep([s],0);for(Math.floor(o/2),e=0;e<o;e++)d[e]=n[e];if(void 0!==t)for(e=0;e<o;e++)p[e]=t[e];for(c[0]=1,e=1;e<=s/2;e++)r=h*e*e,c[e]=f(r),l[e]=m(r),c[s-e]=f(r),l[s-e]=m(r);var g=new numeric.T(d,p),v=new numeric.T(c,l);return g=g.mul(v),numeric.convpow2(g.x,g.y,numeric.clone(v.x),numeric.neg(v.y)),(g=g.mul(v)).x.length=o,g.y.length=o,g.div(o)},numeric.gradient=function(e,r){var n=r.length,t=e(r);if(isNaN(t))throw new Error("gradient: f(x) is a NaN!");var o,i,a,u,s,c,l,f,m,h=Math.max,d=numeric.clone(r),p=Array(n),g=(numeric.div,numeric.sub,h=Math.max,Math.abs),v=Math.min,y=0;for(o=0;o<n;o++)for(var _=h(1e-6*t,1e-8);;){if(++y>20)throw new Error("Numerical gradient fails");if(d[o]=r[o]+_,i=e(d),d[o]=r[o]-_,a=e(d),d[o]=r[o],isNaN(i)||isNaN(a))_/=16;else{if(p[o]=(i-a)/(2*_),u=r[o]-_,s=r[o],c=r[o]+_,l=(i-t)/_,f=(t-a)/_,m=h(g(p[o]),g(t),g(i),g(a),g(u),g(s),g(c),1e-8),!(v(h(g(l-p[o]),g(f-p[o]),g(l-f))/m,_/m)>.001))break;_/=16}}return p},numeric.uncmin=function(e,r,n,t,o,i,a){var u=numeric.gradient;void 0===a&&(a={}),void 0===n&&(n=1e-8),void 0===t&&(t=function(r){return u(e,r)}),void 0===o&&(o=1e3);var s,c,l=(r=numeric.clone(r)).length,f=e(r);if(isNaN(f))throw new Error("uncmin: f(x0) is a NaN!");var m=Math.max,h=numeric.norm2;n=m(n,numeric.epsilon);var d,p,g,v,y,_,x,w,T,b,A=a.Hinv||numeric.identity(l),I=numeric.dot,E=(numeric.inv,numeric.sub),S=numeric.add,M=numeric.tensor,N=numeric.div,C=numeric.mul,P=numeric.all,O=numeric.isFinite,L=numeric.neg,X=0,R="";for(p=t(r);X<o;){if("function"==typeof i&&i(X,r,f,p,A)){R="Callback returned true";break}if(!P(O(p))){R="Gradient has Infinity or NaN";break}if(!P(O(d=L(I(A,p))))){R="Search direction has Infinity or NaN";break}if((b=h(d))<n){R="Newton step smaller than tol";break}for(T=1,c=I(p,d),y=r;X<o&&!(T*b<n)&&(y=S(r,v=C(d,T)),(s=e(y))-f>=.1*T*c||isNaN(s));)T*=.5,++X;if(T*b<n){R="Line search step size smaller than tol";break}if(X===o){R="maxit reached during line search";break}w=I(_=E(g=t(y),p),v),x=I(A,_),A=E(S(A,C((w+I(_,x))/(w*w),M(v,v))),N(S(M(x,v),M(v,x)),w)),r=y,f=s,p=g,++X}return{solution:r,f,gradient:p,invHessian:A,iterations:X,message:R}},numeric.Dopri=function(e,r,n,t,o,i,a){this.x=e,this.y=r,this.f=n,this.ymid=t,this.iterations=o,this.events=a,this.message=i},numeric.Dopri.prototype._at=function(e,r){function n(e){return e*e}var t,o,i,a,u,s,c,l,f,m=this,h=m.x,d=m.y,p=m.f,g=m.ymid,v=(h.length,Math.floor,numeric.add),y=numeric.mul,_=numeric.sub;return t=h[r],o=h[r+1],a=d[r],u=d[r+1],i=t+.5*(o-t),s=g[r],c=_(p[r],y(a,1/(t-i)+2/(t-o))),l=_(p[r+1],y(u,1/(o-i)+2/(o-t))),v(v(v(v(y(a,(f=[n(e-o)*(e-i)/n(t-o)/(t-i),n(e-t)*n(e-o)/n(t-i)/n(o-i),n(e-t)*(e-i)/n(o-t)/(o-i),(e-t)*n(e-o)*(e-i)/n(t-o)/(t-i),(e-o)*n(e-t)*(e-i)/n(t-o)/(o-i)])[0]),y(s,f[1])),y(u,f[2])),y(c,f[3])),y(l,f[4]))},numeric.Dopri.prototype.at=function(e){var r,n,t,o=Math.floor;if("number"!=typeof e){var i=e.length,a=Array(i);for(r=i-1;-1!==r;--r)a[r]=this.at(e[r]);return a}var u=this.x;for(r=0,n=u.length-1;n-r>1;)u[t=o(.5*(r+n))]<=e?r=t:n=t;return this._at(e,r)},numeric.dopri=function(e,r,n,t,o,i,a){void 0===o&&(o=1e-6),void 0===i&&(i=1e3);var u,s,c,l,f,m,h,d,p,g,v,y,_,x=[e],w=[n],T=[t(e,n)],b=[],A=[.075,.225],I=[44/45,-56/15,32/9],E=[19372/6561,-25360/2187,64448/6561,-212/729],S=[9017/3168,-355/33,46732/5247,49/176,-5103/18656],M=[35/384,0,500/1113,125/192,-2187/6784,11/84],N=[.10013431883002395,0,.3918321794184259,-.02982460176594817,.05893268337240795,-.04497888809104361,.023904308236133973],C=[.2,.3,.8,8/9,1,1],P=[-71/57600,0,71/16695,-71/1920,17253/339200,-22/525,.025],O=0,L=(r-e)/10,X=0,R=numeric.add,k=numeric.mul,F=(Math.max,Math.min),D=Math.abs,G=numeric.norminf,j=Math.pow,q=numeric.any,Y=numeric.lt,B=numeric.and,V=(numeric.sub,new numeric.Dopri(x,w,T,b,-1,""));for("function"==typeof a&&(v=a(e,n));e<r&&X<i;)if(++X,e+L>r&&(L=r-e),u=t(e+C[0]*L,R(n,k(.2*L,T[O]))),s=t(e+C[1]*L,R(R(n,k(A[0]*L,T[O])),k(A[1]*L,u))),c=t(e+C[2]*L,R(R(R(n,k(I[0]*L,T[O])),k(I[1]*L,u)),k(I[2]*L,s))),l=t(e+C[3]*L,R(R(R(R(n,k(E[0]*L,T[O])),k(E[1]*L,u)),k(E[2]*L,s)),k(E[3]*L,c))),f=t(e+C[4]*L,R(R(R(R(R(n,k(S[0]*L,T[O])),k(S[1]*L,u)),k(S[2]*L,s)),k(S[3]*L,c)),k(S[4]*L,l))),m=t(e+L,p=R(R(R(R(R(n,k(T[O],L*M[0])),k(s,L*M[2])),k(c,L*M[3])),k(l,L*M[4])),k(f,L*M[5]))),(g="number"==typeof(h=R(R(R(R(R(k(T[O],L*P[0]),k(s,L*P[2])),k(c,L*P[3])),k(l,L*P[4])),k(f,L*P[5])),k(m,L*P[6])))?D(h):G(h))>o){if(e+(L=.2*L*j(o/g,.25))===e){V.msg="Step size became too small";break}}else{if(b[O]=R(R(R(R(R(R(n,k(T[O],L*N[0])),k(s,L*N[2])),k(c,L*N[3])),k(l,L*N[4])),k(f,L*N[5])),k(m,L*N[6])),x[++O]=e+L,w[O]=p,T[O]=m,"function"==typeof a){var H,W,U=e,Z=e+.5*L;if(y=a(Z,b[O-1]),q(_=B(Y(v,0),Y(0,y)))||(U=Z,v=y,y=a(Z=e+L,p),_=B(Y(v,0),Y(0,y))),q(_)){for(var $,z,K=0,Q=1,J=1;;){if("number"==typeof v)W=(J*y*U-Q*v*Z)/(J*y-Q*v);else for(W=Z,d=v.length-1;-1!==d;--d)v[d]<0&&y[d]>0&&(W=F(W,(J*y[d]*U-Q*v[d]*Z)/(J*y[d]-Q*v[d])));if(W<=U||W>=Z)break;z=a(W,H=V._at(W,O-1)),q($=B(Y(v,0),Y(0,z)))?(Z=W,y=z,_=$,J=1,-1===K?Q*=.5:Q=1,K=-1):(U=W,v=z,Q=1,1===K?J*=.5:J=1,K=1)}return p=V._at(.5*(e+W),O-1),V.f[O]=t(W,H),V.x[O]=W,V.y[O]=H,V.ymid[O-1]=p,V.events=_,V.iterations=X,V}}e+=L,n=p,v=y,L=F(.8*L*j(o/g,.25),4*L)}return V.iterations=X,V},numeric.LU=function(e,r){r=r||!1;var n,t,o,i,a,u,s,c,l,f=Math.abs,m=e.length,h=m-1,d=new Array(m);for(r||(e=numeric.clone(e)),o=0;o<m;++o){for(s=o,l=f((u=e[o])[o]),t=o+1;t<m;++t)l<(i=f(e[t][o]))&&(l=i,s=t);for(d[o]=s,s!=o&&(e[o]=e[s],e[s]=u,u=e[o]),a=u[o],n=o+1;n<m;++n)e[n][o]/=a;for(n=o+1;n<m;++n){for(c=e[n],t=o+1;t<h;++t)c[t]-=c[o]*u[t],c[++t]-=c[o]*u[t];t===h&&(c[t]-=c[o]*u[t])}}return{LU:e,P:d}},numeric.LUsolve=function(e,r){var n,t,o,i,a,u=e.LU,s=u.length,c=numeric.clone(r),l=e.P;for(n=s-1;-1!==n;--n)c[n]=r[n];for(n=0;n<s;++n)for(o=l[n],l[n]!==n&&(a=c[n],c[n]=c[o],c[o]=a),i=u[n],t=0;t<n;++t)c[n]-=c[t]*i[t];for(n=s-1;n>=0;--n){for(i=u[n],t=n+1;t<s;++t)c[n]-=c[t]*i[t];c[n]/=i[n]}return c},numeric.solve=function(e,r,n){return numeric.LUsolve(numeric.LU(e,n),r)},numeric.echelonize=function(e){var r,n,t,o,i,a,u,s,c=numeric.dim(e),l=c[0],f=c[1],m=numeric.identity(l),h=Array(l),d=Math.abs,p=numeric.diveq;for(e=numeric.clone(e),r=0;r<l;++r){for(t=0,i=e[r],a=m[r],n=1;n<f;++n)d(i[t])<d(i[n])&&(t=n);for(h[r]=t,p(a,i[t]),p(i,i[t]),n=0;n<l;++n)if(n!==r){for(s=(u=e[n])[t],o=f-1;-1!==o;--o)u[o]-=i[o]*s;for(u=m[n],o=l-1;-1!==o;--o)u[o]-=a[o]*s}}return{I:m,A:e,P:h}},numeric.__solveLP=function(e,r,n,t,o,i,a){var u,s,c,l,f=numeric.sum,m=(numeric.log,numeric.mul),h=numeric.sub,d=numeric.dot,p=numeric.div,g=numeric.add,v=e.length,y=n.length,_=!1,x=1,w=(numeric.transpose(r),numeric.svd,numeric.transpose),T=(numeric.leq,Math.sqrt),b=Math.abs,A=(numeric.muleq,numeric.norminf,numeric.any,Math.min),I=numeric.all,E=numeric.gt,S=Array(v),M=Array(y),N=(numeric.rep([y],1),numeric.solve),C=h(n,d(r,i)),P=d(e,e);for(c=0;c<o;++c){var O,L;for(O=y-1;-1!==O;--O)M[O]=p(r[O],C[O]);var X=w(M);for(O=v-1;-1!==O;--O)S[O]=f(X[O]);x=.25*b(P/d(e,S));var R=100*T(P/d(S,S));for((!isFinite(x)||x>R)&&(x=R),l=g(e,m(x,S)),s=d(X,M),O=v-1;-1!==O;--O)s[O][O]+=1;L=N(s,p(l,x),!0);var k=p(C,d(r,L)),F=1;for(O=y-1;-1!==O;--O)k[O]<0&&(F=A(F,-.999*k[O]));if(u=h(i,m(L,F)),!I(E(C=h(n,d(r,u)),0)))return{solution:i,message:"",iterations:c};if(i=u,x<t)return{solution:u,message:"",iterations:c};if(a){var D=d(e,l),G=d(r,l);for(_=!0,O=y-1;-1!==O;--O)if(D*G[O]<0){_=!1;break}}else _=!(i[v-1]>=0);if(_)return{solution:u,message:"Unbounded",iterations:c}}return{solution:i,message:"maximum iteration count exceeded",iterations:c}},numeric._solveLP=function(e,r,n,t,o){var i=e.length,a=n.length,u=(numeric.sum,numeric.log,numeric.mul,numeric.sub),s=numeric.dot,c=(numeric.div,numeric.add,numeric.rep([i],0).concat([1])),l=numeric.rep([a,1],-1),f=numeric.blockMatrix([[r,l]]),m=n,h=numeric.rep([i],0).concat(Math.max(0,numeric.sup(numeric.neg(n)))+1),d=numeric.__solveLP(c,f,m,t,o,h,!1),p=numeric.clone(d.solution);if(p.length=i,numeric.inf(u(n,s(r,p)))<0)return{solution:NaN,message:"Infeasible",iterations:d.iterations};var g=numeric.__solveLP(e,r,n,t,o-d.iterations,p,!0);return g.iterations+=d.iterations,g},numeric.solveLP=function(e,r,n,t,o,i,a){if(void 0===a&&(a=1e3),void 0===i&&(i=numeric.epsilon),void 0===t)return numeric._solveLP(e,r,n,i,a);var u,s=t.length,c=t[0].length,l=r.length,f=numeric.echelonize(t),m=numeric.rep([c],0),h=f.P,d=[];for(u=h.length-1;-1!==u;--u)m[h[u]]=1;for(u=c-1;-1!==u;--u)0===m[u]&&d.push(u);var p=numeric.getRange,g=numeric.linspace(0,s-1),v=numeric.linspace(0,l-1),y=p(t,g,d),_=p(r,v,h),x=p(r,v,d),w=numeric.dot,T=numeric.sub,b=w(_,f.I),A=T(x,w(b,y)),I=T(n,w(b,o)),E=Array(h.length),S=Array(d.length);for(u=h.length-1;-1!==u;--u)E[u]=e[h[u]];for(u=d.length-1;-1!==u;--u)S[u]=e[d[u]];var M=T(S,w(E,w(f.I,y))),N=numeric._solveLP(M,A,I,i,a),C=N.solution;if(C!=C)return N;var P=w(f.I,T(o,w(y,C))),O=Array(e.length);for(u=h.length-1;-1!==u;--u)O[h[u]]=P[u];for(u=d.length-1;-1!==u;--u)O[d[u]]=C[u];return{solution:O,message:N.message,iterations:N.iterations}},numeric.MPStoLP=function(e){function r(r){throw new Error("MPStoLP: "+r+"\nLine "+n+": "+e[n]+"\nCurrent state: "+u[a]+"\n")}e instanceof String&&e.split("\n");var n,t,o,i,a=0,u=["Initial state","NAME","ROWS","COLUMNS","RHS","BOUNDS","ENDATA"],s=e.length,c=0,l={},f=[],m=0,h={},d=0,p=[],g=[],v=[];for(n=0;n<s;++n){var y=(o=e[n]).match(/\S*/g),_=[];for(t=0;t<y.length;++t)""!==y[t]&&_.push(y[t]);if(0!==_.length){for(t=0;t<u.length&&o.substr(0,u[t].length)!==u[t];++t);if(t<u.length){if(a=t,1===t&&(i=_[1]),6===t)return{name:i,c:p,A:numeric.transpose(g),b:v,rows:l,vars:h}}else switch(a){case 0:case 1:r("Unexpected line");case 2:switch(_[0]){case"N":0===c?c=_[1]:r("Two or more N rows");break;case"L":l[_[1]]=m,f[m]=1,v[m]=0,++m;break;case"G":l[_[1]]=m,f[m]=-1,v[m]=0,++m;break;case"E":l[_[1]]=m,f[m]=0,v[m]=0,++m;break;default:r("Parse error "+numeric.prettyPrint(_))}break;case 3:h.hasOwnProperty(_[0])||(h[_[0]]=d,p[d]=0,g[d]=numeric.rep([m],0),++d);var x=h[_[0]];for(t=1;t<_.length;t+=2)if(_[t]!==c){var w=l[_[t]];g[x][w]=(f[w]<0?-1:1)*parseFloat(_[t+1])}else p[x]=parseFloat(_[t+1]);break;case 4:for(t=1;t<_.length;t+=2)v[l[_[t]]]=(f[l[_[t]]]<0?-1:1)*parseFloat(_[t+1]);break;case 5:break;case 6:r("Internal error")}}}r("Reached end of file without ENDATA")},numeric.seedrandom={pow:Math.pow,random:Math.random},function(e,r,n,t,o,i,a){function u(e){var r,t,o=this,i=e.length,a=0,u=o.i=o.j=o.m=0;for(o.S=[],o.c=[],i||(e=[i++]);a<n;)o.S[a]=a++;for(a=0;a<n;a++)u=l(u+(r=o.S[a])+e[a%i]),t=o.S[u],o.S[a]=t,o.S[u]=r;o.g=function(e){var r=o.S,t=l(o.i+1),i=r[t],a=l(o.j+i),u=r[a];r[t]=u,r[a]=i;for(var s=r[l(i+u)];--e;)t=l(t+1),u=r[a=l(a+(i=r[t]))],r[t]=u,r[a]=i,s=s*n+r[l(i+u)];return o.i=t,o.j=a,s},o.g(n)}function s(e,r,n,t,o){if(n=[],o=typeof e,r&&"object"==o)for(t in e)if(t.indexOf("S")<5)try{n.push(s(e[t],r-1))}catch(e){}return n.length?n:e+("string"!=o?"\0":"")}function c(e,r,n,t){for(e+="",n=0,t=0;t<e.length;t++)r[l(t)]=l((n^=19*r[l(t)])+e.charCodeAt(t));for(t in e="",r)e+=String.fromCharCode(r[t]);return e}function l(e){return e&n-1}r.seedrandom=function(t,l){var f,m=[];return t=c(s(l?[t,e]:arguments.length?t:[(new Date).getTime(),e,window],3),m),c((f=new u(m)).S,e),r.random=function(){for(var e=f.g(6),r=a,t=0;e<o;)e=(e+t)*n,r*=n,t=f.g(1);for(;e>=i;)e/=2,r/=2,t>>>=1;return(e+t)/r},t},a=r.pow(n,6),o=r.pow(2,o),i=2*o,c(r.random(),e)}([],numeric.seedrandom,256,0,52),function(e){function r(e){if("object"!=typeof e)return e;var n,t=[],o=e.length;for(n=0;n<o;n++)t[n+1]=r(e[n]);return t}function n(e){if("object"!=typeof e)return e;var r,t=[],o=e.length;for(r=1;r<o;r++)t[r-1]=n(e[r]);return t}e.solveQP=function(e,t,o,i,a,u){e=r(e),t=r(t),o=r(o);var s,c,l,f,m,h=[],d=[],p=[],g=[],v=[];if(a=a||0,u=u?r(u):[void 0,0],i=i?r(i):[],c=e.length-1,l=o[1].length-1,!i)for(s=1;s<=l;s+=1)i[s]=0;for(s=1;s<=l;s+=1)d[s]=0;for(f=Math.min(c,l),s=1;s<=c;s+=1)p[s]=0;for(h[1]=0,s=1;s<=2*c+f*(f+5)/2+2*l+1;s+=1)g[s]=0;for(s=1;s<=2;s+=1)v[s]=0;return function(e,r,n,t,o,i,a,u,s,c,l,f,m,h,d,p){function g(){for(h[1]=h[1]+1,b=C,w=1;w<=c;w+=1){for(b+=1,k=-u[w],T=1;T<=t;T+=1)k+=a[T][w]*o[T];if(Math.abs(k)<V&&(k=0),w>l)d[b]=k;else if(d[b]=-Math.abs(k),k>0){for(T=1;T<=t;T+=1)a[T][w]=-a[T][w];u[w]=-u[w]}}for(w=1;w<=m;w+=1)d[C+f[w]]=0;for(O=0,R=0,w=1;w<=c;w+=1)d[C+w]<R*d[X+w]&&(O=w,R=d[C+w]/d[X+w]);return 0===O?999:0}function v(){for(w=1;w<=t;w+=1){for(k=0,T=1;T<=t;T+=1)k+=e[T][w]*a[T][O];d[w]=k}for(A=S,w=1;w<=t;w+=1)d[A+w]=0;for(T=m+1;T<=t;T+=1)for(w=1;w<=t;w+=1)d[A+w]=d[A+w]+e[w][T]*d[T];for(Y=!0,w=m;w>=1;w-=1){for(k=d[w],A=(b=N+w*(w+3)/2)-w,T=w+1;T<=m;T+=1)k-=d[b]*d[M+T],b+=T;if(k/=d[A],d[M+w]=k,f[w]<l)break;if(k<0)break;Y=!1,E=w}if(!Y)for(F=d[P+E]/d[M+E],w=1;w<=m&&!(f[w]<l)&&!(d[M+w]<0);w+=1)(R=d[P+w]/d[M+w])<F&&(F=R,E=w);for(k=0,w=S+1;w<=S+t;w+=1)k+=d[w]*d[w];if(Math.abs(k)<=V){if(Y)return p[1]=1,999;for(w=1;w<=m;w+=1)d[P+w]=d[P+w]-F*d[M+w];return d[P+m+1]=d[P+m+1]+F,700}for(k=0,w=1;w<=t;w+=1)k+=d[S+w]*a[w][O];for(D=-d[C+O]/k,B=!0,Y||F<D&&(D=F,B=!1),w=1;w<=t;w+=1)o[w]=o[w]+D*d[S+w],Math.abs(o[w])<V&&(o[w]=0);for(i[1]=i[1]+D*k*(D/2+d[P+m+1]),w=1;w<=m;w+=1)d[P+w]=d[P+w]-D*d[M+w];if(d[P+m+1]=d[P+m+1]+D,!B){for(k=-u[O],T=1;T<=t;T+=1)k+=o[T]*a[T][O];if(O>l)d[C+O]=k;else if(d[C+O]=-Math.abs(k),k>0){for(T=1;T<=t;T+=1)a[T][O]=-a[T][O];u[O]=-u[O]}return 700}for(f[m+=1]=O,b=N+(m-1)*m/2+1,w=1;w<=m-1;w+=1)d[b]=d[w],b+=1;if(m===t)d[b]=d[t];else{for(w=t;w>=m+1&&0!==d[w]&&(G=Math.max(Math.abs(d[w-1]),Math.abs(d[w])),j=Math.min(Math.abs(d[w-1]),Math.abs(d[w])),R=d[w-1]>=0?Math.abs(G*Math.sqrt(1+j*j/(G*G))):-Math.abs(G*Math.sqrt(1+j*j/(G*G))),G=d[w-1]/R,j=d[w]/R,1!==G);w-=1)if(0===G)for(d[w-1]=j*R,T=1;T<=t;T+=1)R=e[T][w-1],e[T][w-1]=e[T][w],e[T][w]=R;else for(d[w-1]=R,q=j/(1+G),T=1;T<=t;T+=1)R=G*e[T][w-1]+j*e[T][w],e[T][w]=q*(e[T][w-1]+R)-e[T][w],e[T][w-1]=R;d[b]=d[m]}return 0}function y(){if(0===d[A=(b=N+E*(E+1)/2+1)+E])return 798;if(G=Math.max(Math.abs(d[A-1]),Math.abs(d[A])),j=Math.min(Math.abs(d[A-1]),Math.abs(d[A])),R=d[A-1]>=0?Math.abs(G*Math.sqrt(1+j*j/(G*G))):-Math.abs(G*Math.sqrt(1+j*j/(G*G))),G=d[A-1]/R,j=d[A]/R,1===G)return 798;if(0===G){for(w=E+1;w<=m;w+=1)R=d[A-1],d[A-1]=d[A],d[A]=R,A+=w;for(w=1;w<=t;w+=1)R=e[w][E],e[w][E]=e[w][E+1],e[w][E+1]=R}else{for(q=j/(1+G),w=E+1;w<=m;w+=1)R=G*d[A-1]+j*d[A],d[A]=q*(d[A-1]+R)-d[A],d[A-1]=R,A+=w;for(w=1;w<=t;w+=1)R=G*e[w][E]+j*e[w][E+1],e[w][E+1]=q*(e[w][E]+R)-e[w][E+1],e[w][E]=R}return 0}function _(){for(A=b-E,w=1;w<=E;w+=1)d[A]=d[b],b+=1,A+=1;return d[P+E]=d[P+E+1],f[E]=f[E+1],(E+=1)<m?797:0}function x(){return d[P+m]=d[P+m+1],d[P+m+1]=0,f[m]=0,m-=1,h[2]=h[2]+1,0}var w,T,b,A,I,E,S,M,N,C,P,O,L,X,R,k,F,D,G,j,q,Y,B,V,H,W,U;L=Math.min(t,c),b=2*t+L*(L+5)/2+2*c+1,V=1e-60;do{H=1+.1*(V+=V),W=1+.2*V}while(H<=1||W<=1);for(w=1;w<=t;w+=1)d[w]=r[w];for(w=t+1;w<=b;w+=1)d[w]=0;for(w=1;w<=c;w+=1)f[w]=0;if(I=[],0===p[1]){if(function(e,r,n,t){var o,i,a,u,s,c;for(i=1;i<=n;i+=1){if(t[1]=i,c=0,(a=i-1)<1){if((c=e[i][i]-c)<=0)break;e[i][i]=Math.sqrt(c)}else{for(u=1;u<=a;u+=1){for(s=e[u][i],o=1;o<u;o+=1)s-=e[o][i]*e[o][u];s/=e[u][u],e[u][i]=s,c+=s*s}if((c=e[i][i]-c)<=0)break;e[i][i]=Math.sqrt(c)}t[1]=0}}(e,0,t,I),0!==I[1])return void(p[1]=2);(function(e,r,n,t){var o,i,a,u;for(i=1;i<=n;i+=1){for(u=0,o=1;o<i;o+=1)u+=e[o][i]*t[o];t[i]=(t[i]-u)/e[i][i]}for(a=1;a<=n;a+=1)for(t[i=n+1-a]=t[i]/e[i][i],u=-t[i],o=1;o<i;o+=1)t[o]=t[o]+u*e[o][i]})(e,0,t,r),function(e,r,n){var t,o,i,a,u;for(i=1;i<=n;i+=1){for(e[i][i]=1/e[i][i],u=-e[i][i],t=1;t<i;t+=1)e[t][i]=u*e[t][i];if(n<(a=i+1))break;for(o=a;o<=n;o+=1)for(u=e[i][o],e[i][o]=0,t=1;t<=i;t+=1)e[t][o]=e[t][o]+u*e[t][i]}}(e,0,t)}else{for(T=1;T<=t;T+=1)for(o[T]=0,w=1;w<=T;w+=1)o[T]=o[T]+e[w][T]*r[w];for(T=1;T<=t;T+=1)for(r[T]=0,w=T;w<=t;w+=1)r[T]=r[T]+e[T][w]*o[w]}for(i[1]=0,T=1;T<=t;T+=1)for(o[T]=r[T],i[1]=i[1]+d[T]*o[T],d[T]=0,w=T+1;w<=t;w+=1)e[w][T]=0;for(i[1]=-i[1]/2,p[1]=0,X=(C=(N=(P=(M=(S=t)+t)+L)+L+1)+L*(L+1)/2)+c,w=1;w<=c;w+=1){for(k=0,T=1;T<=t;T+=1)k+=a[T][w]*a[T][w];d[X+w]=Math.sqrt(k)}for(m=0,h[1]=0,h[2]=0,U=0;;){if(999===(U=g()))return;for(;0!==(U=v());){if(999===U)return;if(700===U)if(E===m)x();else{for(;y(),797===(U=_()););x()}}}}(e,t,0,c,p,h,o,i,0,l,a,d,0,v,g,u),m="",1===u[1]&&(m="constraints are inconsistent, no solution!"),2===u[1]&&(m="matrix D in quadratic function is not positive definite!"),{solution:n(p),value:n(h),unconstrained_solution:n(t),iterations:n(v),iact:n(d),message:m}}}(numeric),numeric.svd=function(e){function r(e,r){return(e=Math.abs(e))>(r=Math.abs(r))?e*Math.sqrt(1+r*r/e/e):0==r?e:r*Math.sqrt(1+e*e/r/r)}var n,t=numeric.epsilon,o=1e-64/t,i=0,a=0,u=0,s=0,c=0,l=numeric.clone(e),f=l.length,m=l[0].length;if(f<m)throw"Need more rows than columns";var h=new Array(m),d=new Array(m);for(a=0;a<m;a++)h[a]=d[a]=0;var p=numeric.rep([m,m],0),g=0,v=0,y=0,_=0,x=0,w=0,T=0;for(a=0;a<m;a++){for(h[a]=v,T=0,c=a+1,u=a;u<f;u++)T+=l[u][a]*l[u][a];if(T<=o)v=0;else for(g=l[a][a],v=Math.sqrt(T),g>=0&&(v=-v),y=g*v-T,l[a][a]=g-v,u=c;u<m;u++){for(T=0,s=a;s<f;s++)T+=l[s][a]*l[s][u];for(g=T/y,s=a;s<f;s++)l[s][u]+=g*l[s][a]}for(d[a]=v,T=0,u=c;u<m;u++)T+=l[a][u]*l[a][u];if(T<=o)v=0;else{for(g=l[a][a+1],v=Math.sqrt(T),g>=0&&(v=-v),y=g*v-T,l[a][a+1]=g-v,u=c;u<m;u++)h[u]=l[a][u]/y;for(u=c;u<f;u++){for(T=0,s=c;s<m;s++)T+=l[u][s]*l[a][s];for(s=c;s<m;s++)l[u][s]+=T*h[s]}}(x=Math.abs(d[a])+Math.abs(h[a]))>_&&(_=x)}for(a=m-1;-1!=a;a+=-1){if(0!=v){for(y=v*l[a][a+1],u=c;u<m;u++)p[u][a]=l[a][u]/y;for(u=c;u<m;u++){for(T=0,s=c;s<m;s++)T+=l[a][s]*p[s][u];for(s=c;s<m;s++)p[s][u]+=T*p[s][a]}}for(u=c;u<m;u++)p[a][u]=0,p[u][a]=0;p[a][a]=1,v=h[a],c=a}for(a=m-1;-1!=a;a+=-1){for(c=a+1,v=d[a],u=c;u<m;u++)l[a][u]=0;if(0!=v){for(y=l[a][a]*v,u=c;u<m;u++){for(T=0,s=c;s<f;s++)T+=l[s][a]*l[s][u];for(g=T/y,s=a;s<f;s++)l[s][u]+=g*l[s][a]}for(u=a;u<f;u++)l[u][a]=l[u][a]/v}else for(u=a;u<f;u++)l[u][a]=0;l[a][a]+=1}for(t*=_,s=m-1;-1!=s;s+=-1)for(var b=0;b<50;b++){var A=!1;for(c=s;-1!=c;c+=-1){if(Math.abs(h[c])<=t){A=!0;break}if(Math.abs(d[c-1])<=t)break}if(!A){i=0,T=1;var I=c-1;for(a=c;a<s+1&&(g=T*h[a],h[a]=i*h[a],!(Math.abs(g)<=t));a++)for(y=r(g,v=d[a]),d[a]=y,i=v/y,T=-g/y,u=0;u<f;u++)x=l[u][I],w=l[u][a],l[u][I]=x*i+w*T,l[u][a]=-x*T+w*i}if(w=d[s],c==s){if(w<0)for(d[s]=-w,u=0;u<m;u++)p[u][s]=-p[u][s];break}if(b>=49)throw"Error: no convergence.";for(_=d[c],v=r(g=(((x=d[s-1])-w)*(x+w)+((v=h[s-1])-(y=h[s]))*(v+y))/(2*y*x),1),g=g<0?((_-w)*(_+w)+y*(x/(g-v)-y))/_:((_-w)*(_+w)+y*(x/(g+v)-y))/_,i=1,T=1,a=c+1;a<s+1;a++){for(v=h[a],x=d[a],y=T*v,v*=i,w=r(g,y),h[a-1]=w,g=_*(i=g/w)+v*(T=y/w),v=-_*T+v*i,y=x*T,x*=i,u=0;u<m;u++)_=p[u][a-1],w=p[u][a],p[u][a-1]=_*i+w*T,p[u][a]=-_*T+w*i;for(w=r(g,y),d[a-1]=w,g=(i=g/w)*v+(T=y/w)*x,_=-T*v+i*x,u=0;u<f;u++)x=l[u][a-1],w=l[u][a],l[u][a-1]=x*i+w*T,l[u][a]=-x*T+w*i}h[c]=0,h[s]=g,d[s]=_}for(a=0;a<d.length;a++)d[a]<t&&(d[a]=0);for(a=0;a<m;a++)for(u=a-1;u>=0;u--)if(d[u]<d[a]){for(i=d[u],d[u]=d[a],d[a]=i,s=0;s<l.length;s++)n=l[s][a],l[s][a]=l[s][u],l[s][u]=n;for(s=0;s<p.length;s++)n=p[s][a],p[s][a]=p[s][u],p[s][u]=n;a=u}return{U:l,S:d,V:p}}},111:(e,r,n)=>{"use strict";function t(e){e.sort();const r=e[Math.trunc(e.length/4)],n=e.length%2==0?(e[Math.trunc(e.length/2)]+e[Math.trunc(e.length/2)-1])/2:e[Math.trunc(e.length/2)],t=e[Math.trunc(3*e.length/4)],i=1.5*(t-r);let a=o(e,t+i);a<0&&(a=~a);let u=e[Math.max(0,a-1)];u<t&&(u=t);let s=o(e,r-i);s<0&&(s=~s);let c=e[s];return c>r&&(c=r),{q1:r,q2:n,q3:t,lowerAdjacentValue:c,upperAdjacentValue:u}}function o(e,r,n=0,t){if(0===e.length)return-1;if(void 0===t&&(t=e.length-1),r<e[n])return-1;if(r>e[t])return-(t+1);for(;t-n>1;){const o=Math.trunc((t+n)/2);if(r===e[o])return o;r<e[o]?t=o:n=o}return e[n]===r?n:0===e[t]?t:r<e[n]?-(n+1):-(t+1)}n.d(r,{G:()=>t})},875:(e,r,n)=>{"use strict";n.d(r,{K0:()=>g,Kp:()=>c,Qc:()=>l,XD:()=>f,ZY:()=>b,aC:()=>S,cY:()=>h,d8:()=>s,hR:()=>I,iC:()=>A,j2:()=>u,js:()=>a,kW:()=>p,sw:()=>d,ue:()=>E,vK:()=>m,yB:()=>v});var t=n(976),o=n(78),i=n(162);const a={CONSTANT:"constant",PROPORTIONAL:"proportional"},u="fit",s="fit",c=".fit",l="rgba(255,191,63,0.4)",f="rgba(255,238,204,0.3)",m={TOP:"top",BOTTOM:"bottom"};class h{constructor(){this.chartOptions={},this.seriesOptions={},this.series=[]}}const d=[t.Property.js("rSquared",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("auc",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("interceptY",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("interceptX",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("slope",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("top",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("bottom",t.TYPE.FLOAT,{userEditable:!1})],p=[t.Property.js("minX",t.TYPE.FLOAT,{description:"Minimum value of the X axis",nullable:!0}),t.Property.js("minY",t.TYPE.FLOAT,{description:"Minimum value of the Y axis",nullable:!0}),t.Property.js("maxX",t.TYPE.FLOAT,{description:"Maximum value of the X axis",nullable:!0}),t.Property.js("maxY",t.TYPE.FLOAT,{description:"Maximum value of the Y axis",nullable:!0}),t.Property.js("title",t.TYPE.STRING,{nullable:!0}),t.Property.js("xAxisName",t.TYPE.STRING,{description:"Label to show on the X axis. If not specified, corresponding data column name is used",nullable:!0}),t.Property.js("yAxisName",t.TYPE.STRING,{description:"Label to show on the Y axis. If not specified, corresponding data column name is used",nullable:!0}),t.Property.js("logX",t.TYPE.BOOL,{description:"Whether the X axis should be logarithmic",defaultValue:!1}),t.Property.js("logY",t.TYPE.BOOL,{description:"Whether the Y axis should be logarithmic",defaultValue:!1}),t.Property.js("allowXZeroes",t.TYPE.BOOL,{description:"Whether x zeroes allowed for logarithmic data or not",defaultValue:!0}),t.Property.js("mergeSeries",t.TYPE.BOOL,{description:"Whether to merge series or not",defaultValue:!1}),t.Property.js("showColumnLabel",t.TYPE.BOOL,{description:"Whether to show the column label in the legend or not",defaultValue:!1}),t.Property.js("showStatistics",t.TYPE.STRING_LIST,{description:"Whether specific statistics should be rendered",choices:d.map((e=>e.name)),inputType:"MultiChoice",friendlyName:"Statistics"})],g=[t.Property.js("fitFunction",t.TYPE.STRING,{category:"Fitting",choices:["sigmoid","linear"],defaultValue:"sigmoid"}),t.Property.js("pointColor",t.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),t.Property.js("fitLineColor",t.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),t.Property.js("outlierColor",t.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),t.Property.js("errorModel",t.TYPE.STRING,{category:"Fitting",defaultValue:"constant",choices:["constant","proportional"],nullable:!1}),t.Property.js("connectDots",t.TYPE.BOOL,{category:"Fitting",defaultValue:!1}),t.Property.js("clickToToggle",t.TYPE.BOOL,{category:"Fitting",description:"Click on a point to mark it as outlier and refit",nullable:!0,defaultValue:!1}),t.Property.js("showFitLine",t.TYPE.BOOL,{category:"Fitting",defaultValue:!0}),t.Property.js("showPoints",t.TYPE.STRING,{category:"Fitting",description:"Whether points/candlesticks/none should be rendered",defaultValue:"points",choices:["points","candlesticks","both"]}),t.Property.js("showCurveConfidenceInterval",t.TYPE.BOOL,{category:"Fitting",description:"Whether confidence intervals should be rendered",defaultValue:!1,friendlyName:"Confidence Interval"}),t.Property.js("markerType",t.TYPE.STRING,{category:"Rendering",defaultValue:"circle",choices:["asterisk","circle","cross border","diamond","square","star","triangle bottom","triangle left","triangle right","triangle top"],nullable:!1}),t.Property.js("lineStyle",t.TYPE.STRING,{category:"Rendering",defaultValue:"solid",choices:["solid","dotted","dashed","dashdotted"],nullable:!1}),t.Property.js("droplines",t.TYPE.STRING_LIST,{description:"Whether specific droplines should be rendered",choices:["IC50"],inputType:"MultiChoice"}),t.Property.js("columnName",t.TYPE.STRING,{description:"Column name where the series is stored",defaultValue:""})],v="sigmoid";class y{}class _ extends y{constructor(e,r,n,t){super(),this._name=e,this._parameterNames=t,this.y=r,this.getInitialParameters=n}get name(){return this._name}get parameterNames(){return this._parameterNames}y(e,r){throw new Error("Not implemented")}getInitialParameters(e,r){throw new Error("Not implemented")}}const x={linear:new class extends y{get name(){return"linear"}get parameterNames(){return["Slope","Intercept"]}y(e,r){return function(e,r){return e[0]*r+e[1]}(e,r)}getInitialParameters(e,r){let n=0,t=0;for(let r=1;r<e.length;r++)e[r]<e[n]&&(n=r),e[r]>e[t]&&(t=r);const o=e[t]-e[n],i=(r[t]-r[n])/o;return[i,r[t]-i*e[t]]}},sigmoid:new class extends y{get name(){return v}get parameterNames(){return["Top","Bottom","Slope","IC50"]}y(e,r){return function(e,r){const n=e[0],t=e[1],o=e[2],i=e[3];return i+(n-i)/(1+Math.pow(10,(r-o)*t))}(e,r)}getInitialParameters(e,r){const n=t.Rect.fromXYArrays(e,r),o=(n.bottom-n.top)/2+n.top;let i=n.bottom-n.top,a=0;for(let n=0;n<e.length;n++){const e=Math.abs(r[n]-o);e<i&&(i=e,a=n)}const u=e[a],s=r[0]>r[r.length-1]?1:-1;return[n.bottom,s,u,n.top]}}};function w(e){let r;switch(e){case a.CONSTANT:r=P;break;case a.PROPORTIONAL:r=O;break;default:r=P}return r}function T(e,r,n,t){return{getValue:t=>n(r,e,t).value,getGradient:(o,i)=>{for(let a=0;a<o.length;a++)i[a]=t.includes(a)?0:C(n,r,e,o,a);return i}}}function b(e){if("string"==typeof e)return x[e];if(!x[e.name]){const r=e.name,n=e.parameterNames,t=e.function.split("=>").map((e=>e.trim())),o=e.getInitialParameters.split("=>").map((e=>e.trim())),i=new Function(t[0].slice(1,t[0].length-1),`${t[1].includes(";")?"":"return "}${t[1]}`),a=new Function(o[0].slice(1,o[0].length-1),`return ${o[1]}`),u=new _(r,i,a,n);x[r]=u}return x[e.name]}function A(e,r,n,t){var i,a;const u=r.y,s=r.getInitialParameters(e.x,e.y),c=w(n),l=[];let f=!0;for(;f;){const r=T(e,u,c,l);if((0,o.U)(r,s),(0,o.U)(r,s),f=!1,!t)break;for(let e=0;e<t.length;e++){if(void 0!==(null===(i=t[e])||void 0===i?void 0:i.max)&&s[e]>t[e].max){f=!0,l.push(e),s[e]=t[e].max;break}if(void 0!==(null===(a=t[e])||void 0===a?void 0:a.min)&&s[e]<t[e].min){f=!0,l.push(e),s[e]=t[e].min;break}}}return{fittedCurve:I(u,s),parameters:s}}function I(e,r){return n=>e(r,n)}function E(e,r,n,t=.05,o){const u=w(o),s=o===a.PROPORTIONAL?u(n,e,r).mult:u(n,e,r).const,c=i.normal.inv(1-t/2,0,1);return{confidenceTop:e=>{const t=n(r,e);return o===a.CONSTANT?t+c*s:t+c*Math.abs(t)*s},confidenceBottom:e=>{const t=n(r,e);return o===a.CONSTANT?t-c*s:t-c*Math.abs(t)*s}}}function S(e,r,n,t=!0){const o=I(n,r);return{rSquared:t?N(o,e):void 0,auc:t?M(o,e):void 0,interceptX:r[2],interceptY:o(r[2]),slope:r[1],top:r[0],bottom:r[3]}}function M(e,r){let n=0;const t=Math.min(...r.x),o=Math.max(...r.x),i=(o-t)/1e3;for(let r=t;r<o;r+=i)n+=i*e(r);return n}function N(e,r){let n=0,t=0;const o=i.mean(r.y);for(let i=0;i<r.x.length;i++)n+=Math.pow(r.y[i]-e(r.x[i]),2),t+=Math.pow(r.y[i]-o,2);return 1-n/t}function C(e,r,n,t,o){const i=1e-4*t[o]==0?.001:1e-4*t[o],a=[],u=[];for(let e=0;e<t.length;e++)e===o?(a.push(t[e]+i),u.push(t[e]-i)):(a.push(t[e]),u.push(t[e]));return(e(r,n,a).value-e(r,n,u).value)/(2*i)}function P(e,r,n){const t=Math.PI;let o=0,i=0,a=0;const u=new Float32Array(r.x.length);for(let t=0;t<r.x.length;t++){const o=r.y[t],i=e(n,r.x[t]);u[t]=Math.pow(o-i,2)}for(let e=0;e<u.length;e++)i+=u[e];i/=u.length,o=Math.sqrt(i);for(let e=0;e<u.length;e++)a+=u[e]/i+Math.log(2*t*i);return{value:-a,const:o,mult:0}}function O(e,r,n){const t=Math.PI;let o=0,i=0,a=0;const u=new Float32Array(r.x.length);for(let t=0;t<r.x.length;t++){const o=r.y[t],i=e(n,r.x[t]);u[t]=Math.pow(o-i,2)}for(let e=0;e<u.length;e++)i+=u[e];i/=u.length,o=Math.sqrt(i);for(let e=0;e<u.length;e++)a+=u[e]/i+Math.log(2*t*i);return{value:-a,const:0,mult:o}}},416:(e,r,n)=>{"use strict";n.d(r,{LC:()=>p,PK:()=>d,TL:()=>a,Y6:()=>m,dU:()=>f,hq:()=>s,jG:()=>u,kG:()=>h,tq:()=>g});var t=n(976),o=n(875);function i(e){const r={};for(const n of e)null!==n.defaultValue&&(r[n.name]=n.defaultValue);return r}function a(){return{chartOptions:i(o.kW),seriesOptions:i(o.K0)}}function u(e){var r,n;return JSON.parse(null!==(r=(n=e.tags)[o.Kp])&&void 0!==r?r:n[o.Kp]=JSON.stringify(a()))}function s(e){var r,n;return JSON.parse(null!==(r=(n=e.tags)[o.Kp])&&void 0!==r?r:n[o.Kp]=JSON.stringify(a()))}function c(e){const r=[],n=[];for(let t=0;t<e.length;t++)r[t]=e[t].x,n[t]=e[t].y;return{xs:r,ys:n}}function l(e){const r=Math.floor(e.y.length/2),n=e.y.sort(((e,r)=>e-r));return n.length%2==0?(n[r-1]+n[r])/2:n[r]}function f(e){var r;const n=e.chartOptions;if((null===(r=e.series)||void 0===r?void 0:r.length)&&0!==e.series.length){const{xs:r,ys:o}=c(e.series[0].points);let i=t.Rect.fromXYArrays(r,o);for(let r=1;r<e.series.length;r++){const{xs:n,ys:o}=c(e.series[r].points);n.some((e=>void 0===e))||o.some((e=>void 0===e))||(i=i.union(t.Rect.fromXYArrays(n,o)))}return n?function(e,r){let n=e.x,o=e.y,i=e.width,a=e.height;return void 0!==r.minX&&null!==r.minX&&(!r.logX||r.logX&&r.minX>0)&&(i+=n-r.minX,n=r.minX),void 0!==r.maxX&&null!==r.maxX&&(!r.logX||r.logX&&r.maxX>0)&&(i+=r.maxX-(n+i)),void 0!==r.minY&&null!==r.minY&&(!r.logY||r.logY&&r.minY>0)&&(a+=o-r.minY,o=r.minY),void 0!==r.maxY&&null!==r.maxY&&(!r.logY||r.logY&&r.maxY>0)&&(a+=r.maxY-(o+a)),new t.Rect(n,o,i,a)}(i,n):i}return new t.Rect(0,0,1,1)}function m(e){return(0,o.ZY)(e.fitFunction)}function h(e,r){return(0,o.hR)(r.y,e.parameters)}function d(e,r,n){var t;const i={x:e.points.filter((e=>!e.outlier)).map((e=>(null==n?void 0:n.logX)?Math.log10(e.x):e.x)),y:e.points.filter((e=>!e.outlier)).map((e=>(null==n?void 0:n.logY)?Math.log10(e.y):e.y))};var a;return e.parameterBounds&&(null==n?void 0:n.logX)&&(e.parameterBounds[2]=((a=e.parameterBounds[2])&&(void 0!==a.max&&(a.max=Math.log10(a.max)),void 0!==a.min&&(a.min=0===a.min?-Number.MAX_VALUE:Math.log10(a.min))),a)),(0,o.iC)(function(e){const r={x:[],y:[]},n={x:[e.x[0]],y:[e.y[0]]};for(let t=1;t<e.x.length;t++){if(e.x[t]===n.x[0]){n.x[n.x.length]=e.x[t],n.y[n.y.length]=e.y[t];continue}const o=l(n);r.x[r.x.length]=n.x[0],r.y[r.y.length]=o,n.x=[e.x[t]],n.y=[e.y[t]]}const t=l(n);return r.x[r.x.length]=n.x[0],r.y[r.y.length]=t,r}(i),r,null!==(t=e.errorModel)&&void 0!==t?t:o.js.CONSTANT,e.parameterBounds)}function p(e,r,n,t){var i;const a=n?{x:e.points.map((e=>(null==t?void 0:t.logX)?Math.log10(e.x):e.x)),y:e.points.map((e=>(null==t?void 0:t.logY)?Math.log10(e.y):e.y))}:{x:e.points.filter((e=>!e.outlier)).map((e=>(null==t?void 0:t.logX)?Math.log10(e.x):e.x)),y:e.points.filter((e=>!e.outlier)).map((e=>(null==t?void 0:t.logY)?Math.log10(e.y):e.y))};return e.parameters||(e.parameters=d(e,r).parameters),(0,o.ue)(a,e.parameters,r.y,.05,null!==(i=e.errorModel)&&void 0!==i?i:o.js.CONSTANT)}function g(e,r,n){const t={x:e.points.filter((e=>!e.outlier)).map((e=>(null==n?void 0:n.logX)?Math.log10(e.x):e.x)),y:e.points.filter((e=>!e.outlier)).map((e=>(null==n?void 0:n.logY)?Math.log10(e.y):e.y))};return e.parameters||(e.parameters=d(e,r).parameters),(0,o.aC)(t,e.parameters,r.y,!0)}},766:(e,r,n)=>{"use strict";n.d(r,{l:()=>u});var t=n(976);const o=1e-30,i=new class{screenToWorld(e,r,n,t,o){return n+(o?1-e/r:e/r)*(t-n)}worldToScreen(e,r,n,t,o){return o?(1-(e-n)/(t-n))*r:(e-n)/(t-n)*r}},a=new class{screenToWorld(e,r,n,t,i){n=n<o?o:n;const a=Math.log(t),u=Math.log(n);return Math.exp(u+(a-u)*(i?r-e:e)/r)}worldToScreen(e,r,n,t,i){if(e<=0)return NaN;if(Math.abs(e-n)<o)return i?r:0;if(Math.abs(e-t)<o)return i?0:r;n=n<o?o:n,e=e<o?o:e;const a=r*Math.log(e/n)/Math.log(t/n);return i?r-a:a}};class u{get xt(){return this.logX?a:i}get yt(){return this.logY?a:i}constructor(e,r,n=!1,t=!1){this.logX=!1,this.logY=!1,this.inverseX=!1,this.inverseY=!1,this.world=e,this.screen=r,this.logX=n,this.logY=t}xToScreen(e){return this.screen.left+this.xt.worldToScreen(e,this.screen.width,this.world.minX,this.world.maxX,this.inverseX)}yToScreen(e){return this.screen.top+this.yt.worldToScreen(e,this.screen.height,this.world.minY,this.world.maxY,!this.inverseY)}xToWorld(e){return this.xt.screenToWorld(e-this.screen.left,this.screen.width,this.world.minX,this.world.maxX,this.inverseX)}yToWorld(e){return this.yt.screenToWorld(e-this.screen.top,this.screen.height,this.world.minY,this.world.maxY,!this.inverseY)}toScreen(e){return new t.Point(this.xToScreen(e.x),this.yToScreen(e.y))}toWorld(e){return new t.Point(this.xToWorld(e.x),this.yToWorld(e.y))}drawCoordinateGrid(e,r,n){r&&t.Paint.horzAxis(e,this.world.minX,this.world.maxX,r.x,r.y,r.width,r.height,this.logX,this.inverseX),n&&t.Paint.vertAxis(e,this.world.minY,this.world.maxY,n.x,n.y,n.width,n.height,this.logY,this.inverseY)}}},162:function(e){var r;e.exports=(r=function(e,r){var n=Array.prototype.concat,t=Array.prototype.slice,o=Object.prototype.toString;function i(r,n){var t=r>n?r:n;return e.pow(10,17-~~(e.log(t>0?t:-t)*e.LOG10E))}var a=Array.isArray||function(e){return"[object Array]"===o.call(e)};function u(e){return"[object Function]"===o.call(e)}function s(e){return"number"==typeof e&&e-e==0}function c(){return new c._init(arguments)}function l(){return 0}function f(){return 1}function m(e,r){return e===r?1:0}c.fn=c.prototype,c._init=function(e){if(a(e[0]))if(a(e[0][0])){u(e[1])&&(e[0]=c.map(e[0],e[1]));for(var r=0;r<e[0].length;r++)this[r]=e[0][r];this.length=e[0].length}else this[0]=u(e[1])?c.map(e[0],e[1]):e[0],this.length=1;else if(s(e[0]))this[0]=c.seq.apply(null,e),this.length=1;else{if(e[0]instanceof c)return c(e[0].toArray());this[0]=[],this.length=1}return this},c._init.prototype=c.prototype,c._init.constructor=c,c.utils={calcRdx:i,isArray:a,isFunction:u,isNumber:s,toVector:function(e){return n.apply([],e)}},c._random_fn=e.random,c.setRandom=function(e){if("function"!=typeof e)throw new TypeError("fn is not a function");c._random_fn=e},c.extend=function(e){var r,n;if(1===arguments.length){for(n in e)c[n]=e[n];return this}for(r=1;r<arguments.length;r++)for(n in arguments[r])e[n]=arguments[r][n];return e},c.rows=function(e){return e.length||1},c.cols=function(e){return e[0].length||1},c.dimensions=function(e){return{rows:c.rows(e),cols:c.cols(e)}},c.row=function(e,r){return a(r)?r.map((function(r){return c.row(e,r)})):e[r]},c.rowa=function(e,r){return c.row(e,r)},c.col=function(e,r){if(a(r)){var n=c.arange(e.length).map((function(){return new Array(r.length)}));return r.forEach((function(r,t){c.arange(e.length).forEach((function(o){n[o][t]=e[o][r]}))})),n}for(var t=new Array(e.length),o=0;o<e.length;o++)t[o]=[e[o][r]];return t},c.cola=function(e,r){return c.col(e,r).map((function(e){return e[0]}))},c.diag=function(e){for(var r=c.rows(e),n=new Array(r),t=0;t<r;t++)n[t]=[e[t][t]];return n},c.antidiag=function(e){for(var r=c.rows(e)-1,n=new Array(r),t=0;r>=0;r--,t++)n[t]=[e[t][r]];return n},c.transpose=function(e){var r,n,t,o,i,u=[];for(a(e[0])||(e=[e]),n=e.length,t=e[0].length,i=0;i<t;i++){for(r=new Array(n),o=0;o<n;o++)r[o]=e[o][i];u.push(r)}return 1===u.length?u[0]:u},c.map=function(e,r,n){var t,o,i,u,s;for(a(e[0])||(e=[e]),o=e.length,i=e[0].length,u=n?e:new Array(o),t=0;t<o;t++)for(u[t]||(u[t]=new Array(i)),s=0;s<i;s++)u[t][s]=r(e[t][s],t,s);return 1===u.length?u[0]:u},c.cumreduce=function(e,r,n){var t,o,i,u,s;for(a(e[0])||(e=[e]),o=e.length,i=e[0].length,u=n?e:new Array(o),t=0;t<o;t++)for(u[t]||(u[t]=new Array(i)),i>0&&(u[t][0]=e[t][0]),s=1;s<i;s++)u[t][s]=r(u[t][s-1],e[t][s]);return 1===u.length?u[0]:u},c.alter=function(e,r){return c.map(e,r,!0)},c.create=function(e,r,n){var t,o,i=new Array(e);for(u(r)&&(n=r,r=e),t=0;t<e;t++)for(i[t]=new Array(r),o=0;o<r;o++)i[t][o]=n(t,o);return i},c.zeros=function(e,r){return s(r)||(r=e),c.create(e,r,l)},c.ones=function(e,r){return s(r)||(r=e),c.create(e,r,f)},c.rand=function(e,r){return s(r)||(r=e),c.create(e,r,c._random_fn)},c.identity=function(e,r){return s(r)||(r=e),c.create(e,r,m)},c.symmetric=function(e){var r,n,t=e.length;if(e.length!==e[0].length)return!1;for(r=0;r<t;r++)for(n=0;n<t;n++)if(e[n][r]!==e[r][n])return!1;return!0},c.clear=function(e){return c.alter(e,l)},c.seq=function(e,r,n,t){u(t)||(t=!1);var o,a=[],s=i(e,r),c=(r*s-e*s)/((n-1)*s),l=e;for(o=0;l<=r&&o<n;l=(e*s+c*s*++o)/s)a.push(t?t(l,o):l);return a},c.arange=function(e,n,t){var o,i=[];if(t=t||1,n===r&&(n=e,e=0),e===n||0===t)return[];if(e<n&&t<0)return[];if(e>n&&t>0)return[];if(t>0)for(o=e;o<n;o+=t)i.push(o);else for(o=e;o>n;o+=t)i.push(o);return i},c.slice=function(){function e(e,n,t,o){var i,a=[],u=e.length;if(n===r&&t===r&&o===r)return c.copy(e);if(o=o||1,(n=(n=n||0)>=0?n:u+n)===(t=(t=t||e.length)>=0?t:u+t)||0===o)return[];if(n<t&&o<0)return[];if(n>t&&o>0)return[];if(o>0)for(i=n;i<t;i+=o)a.push(e[i]);else for(i=n;i>t;i+=o)a.push(e[i]);return a}return function(r,n){var t,o;return s((n=n||{}).row)?s(n.col)?r[n.row][n.col]:e(c.rowa(r,n.row),(t=n.col||{}).start,t.end,t.step):s(n.col)?e(c.cola(r,n.col),(o=n.row||{}).start,o.end,o.step):(o=n.row||{},t=n.col||{},e(r,o.start,o.end,o.step).map((function(r){return e(r,t.start,t.end,t.step)})))}}(),c.sliceAssign=function(n,t,o){var i,a;if(s(t.row)){if(s(t.col))return n[t.row][t.col]=o;t.col=t.col||{},t.col.start=t.col.start||0,t.col.end=t.col.end||n[0].length,t.col.step=t.col.step||1,i=c.arange(t.col.start,e.min(n.length,t.col.end),t.col.step);var u=t.row;return i.forEach((function(e,r){n[u][e]=o[r]})),n}if(s(t.col)){t.row=t.row||{},t.row.start=t.row.start||0,t.row.end=t.row.end||n.length,t.row.step=t.row.step||1,a=c.arange(t.row.start,e.min(n[0].length,t.row.end),t.row.step);var l=t.col;return a.forEach((function(e,r){n[e][l]=o[r]})),n}return o[0].length===r&&(o=[o]),t.row.start=t.row.start||0,t.row.end=t.row.end||n.length,t.row.step=t.row.step||1,t.col.start=t.col.start||0,t.col.end=t.col.end||n[0].length,t.col.step=t.col.step||1,a=c.arange(t.row.start,e.min(n.length,t.row.end),t.row.step),i=c.arange(t.col.start,e.min(n[0].length,t.col.end),t.col.step),a.forEach((function(e,r){i.forEach((function(t,i){n[e][t]=o[r][i]}))})),n},c.diagonal=function(e){var r=c.zeros(e.length,e.length);return e.forEach((function(e,n){r[n][n]=e})),r},c.copy=function(e){return e.map((function(e){return s(e)?e:e.map((function(e){return e}))}))};var h=c.prototype;return h.length=0,h.push=Array.prototype.push,h.sort=Array.prototype.sort,h.splice=Array.prototype.splice,h.slice=Array.prototype.slice,h.toArray=function(){return this.length>1?t.call(this):t.call(this)[0]},h.map=function(e,r){return c(c.map(this,e,r))},h.cumreduce=function(e,r){return c(c.cumreduce(this,e,r))},h.alter=function(e){return c.alter(this,e),this},function(e){for(var r=0;r<e.length;r++)!function(e){h[e]=function(r){var n,t=this;return r?(setTimeout((function(){r.call(t,h[e].call(t))})),this):(n=c[e](this),a(n)?c(n):n)}}(e[r])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(e){for(var r=0;r<e.length;r++)!function(e){h[e]=function(r,n){var t=this;return n?(setTimeout((function(){n.call(t,h[e].call(t,r))})),this):c(c[e](this,r))}}(e[r])}("row col".split(" ")),function(e){for(var r=0;r<e.length;r++)!function(e){h[e]=function(){return c(c[e].apply(null,arguments))}}(e[r])}("create zeros ones rand identity".split(" ")),c}(Math),function(e,r){var n=e.utils.isFunction;function t(e,r){return e-r}function o(e,n,t){return r.max(n,r.min(e,t))}e.sum=function(e){for(var r=0,n=e.length;--n>=0;)r+=e[n];return r},e.sumsqrd=function(e){for(var r=0,n=e.length;--n>=0;)r+=e[n]*e[n];return r},e.sumsqerr=function(r){for(var n,t=e.mean(r),o=0,i=r.length;--i>=0;)o+=(n=r[i]-t)*n;return o},e.sumrow=function(e){for(var r=0,n=e.length;--n>=0;)r+=e[n];return r},e.product=function(e){for(var r=1,n=e.length;--n>=0;)r*=e[n];return r},e.min=function(e){for(var r=e[0],n=0;++n<e.length;)e[n]<r&&(r=e[n]);return r},e.max=function(e){for(var r=e[0],n=0;++n<e.length;)e[n]>r&&(r=e[n]);return r},e.unique=function(e){for(var r={},n=[],t=0;t<e.length;t++)r[e[t]]||(r[e[t]]=!0,n.push(e[t]));return n},e.mean=function(r){return e.sum(r)/r.length},e.meansqerr=function(r){return e.sumsqerr(r)/r.length},e.geomean=function(n){var t=n.map(r.log),o=e.mean(t);return r.exp(o)},e.median=function(e){var r=e.length,n=e.slice().sort(t);return 1&r?n[r/2|0]:(n[r/2-1]+n[r/2])/2},e.cumsum=function(r){return e.cumreduce(r,(function(e,r){return e+r}))},e.cumprod=function(r){return e.cumreduce(r,(function(e,r){return e*r}))},e.diff=function(e){var r,n=[],t=e.length;for(r=1;r<t;r++)n.push(e[r]-e[r-1]);return n},e.rank=function(e){var r,n=[],o={};for(r=0;r<e.length;r++)o[s=e[r]]?o[s]++:(o[s]=1,n.push(s));var i=n.sort(t),a={},u=1;for(r=0;r<i.length;r++){var s,c=o[s=i[r]],l=(u+(u+c-1))/2;a[s]=l,u+=c}return e.map((function(e){return a[e]}))},e.mode=function(e){var r,n=e.length,o=e.slice().sort(t),i=1,a=0,u=0,s=[];for(r=0;r<n;r++)o[r]===o[r+1]?i++:(i>a?(s=[o[r]],a=i,u=0):i===a&&(s.push(o[r]),u++),i=1);return 0===u?s[0]:s},e.range=function(r){return e.max(r)-e.min(r)},e.variance=function(r,n){return e.sumsqerr(r)/(r.length-(n?1:0))},e.pooledvariance=function(r){return r.reduce((function(r,n){return r+e.sumsqerr(n)}),0)/(r.reduce((function(e,r){return e+r.length}),0)-r.length)},e.deviation=function(r){for(var n=e.mean(r),t=r.length,o=new Array(t),i=0;i<t;i++)o[i]=r[i]-n;return o},e.stdev=function(n,t){return r.sqrt(e.variance(n,t))},e.pooledstdev=function(n){return r.sqrt(e.pooledvariance(n))},e.meandev=function(n){for(var t=e.mean(n),o=[],i=n.length-1;i>=0;i--)o.push(r.abs(n[i]-t));return e.mean(o)},e.meddev=function(n){for(var t=e.median(n),o=[],i=n.length-1;i>=0;i--)o.push(r.abs(n[i]-t));return e.median(o)},e.coeffvar=function(r){return e.stdev(r)/e.mean(r)},e.quartiles=function(e){var n=e.length,o=e.slice().sort(t);return[o[r.round(n/4)-1],o[r.round(n/2)-1],o[r.round(3*n/4)-1]]},e.quantiles=function(e,n,i,a){var u,s,c,l,f,m=e.slice().sort(t),h=[n.length],d=e.length;for(void 0===i&&(i=3/8),void 0===a&&(a=3/8),u=0;u<n.length;u++)c=d*(s=n[u])+(i+s*(1-i-a)),l=r.floor(o(c,1,d-1)),f=o(c-l,0,1),h[u]=(1-f)*m[l-1]+f*m[l];return h},e.percentile=function(e,r,n){var o=e.slice().sort(t),i=r*(o.length+(n?1:-1))+(n?0:1),a=parseInt(i),u=i-a;return a+1<o.length?o[a-1]+u*(o[a]-o[a-1]):o[a-1]},e.percentileOfScore=function(e,r,n){var t,o,i=0,a=e.length,u=!1;for("strict"===n&&(u=!0),o=0;o<a;o++)t=e[o],(u&&t<r||!u&&t<=r)&&i++;return i/a},e.histogram=function(n,t){t=t||4;var o,i=e.min(n),a=(e.max(n)-i)/t,u=n.length,s=[];for(o=0;o<t;o++)s[o]=0;for(o=0;o<u;o++)s[r.min(r.floor((n[o]-i)/a),t-1)]+=1;return s},e.covariance=function(r,n){var t,o=e.mean(r),i=e.mean(n),a=r.length,u=new Array(a);for(t=0;t<a;t++)u[t]=(r[t]-o)*(n[t]-i);return e.sum(u)/(a-1)},e.corrcoeff=function(r,n){return e.covariance(r,n)/e.stdev(r,1)/e.stdev(n,1)},e.spearmancoeff=function(r,n){return r=e.rank(r),n=e.rank(n),e.corrcoeff(r,n)},e.stanMoment=function(n,t){for(var o=e.mean(n),i=e.stdev(n),a=n.length,u=0,s=0;s<a;s++)u+=r.pow((n[s]-o)/i,t);return u/n.length},e.skewness=function(r){return e.stanMoment(r,3)},e.kurtosis=function(r){return e.stanMoment(r,4)-3};var i=e.prototype;!function(r){for(var t=0;t<r.length;t++)!function(r){i[r]=function(t,o){var a=[],u=0,s=this;if(n(t)&&(o=t,t=!1),o)return setTimeout((function(){o.call(s,i[r].call(s,t))})),this;if(this.length>1){for(s=!0===t?this:this.transpose();u<s.length;u++)a[u]=e[r](s[u]);return a}return e[r](this[0],t)}}(r[t])}("cumsum cumprod".split(" ")),function(r){for(var t=0;t<r.length;t++)!function(r){i[r]=function(t,o){var a=[],u=0,s=this;if(n(t)&&(o=t,t=!1),o)return setTimeout((function(){o.call(s,i[r].call(s,t))})),this;if(this.length>1){for("sumrow"!==r&&(s=!0===t?this:this.transpose());u<s.length;u++)a[u]=e[r](s[u]);return!0===t?e[r](e.utils.toVector(a)):a}return e[r](this[0],t)}}(r[t])}("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(r){for(var t=0;t<r.length;t++)!function(r){i[r]=function(){var t,o=[],a=0,u=this,s=Array.prototype.slice.call(arguments);if(n(s[s.length-1])){t=s[s.length-1];var c=s.slice(0,s.length-1);return setTimeout((function(){t.call(u,i[r].apply(u,c))})),this}t=void 0;var l=function(n){return e[r].apply(u,[n].concat(s))};if(this.length>1){for(u=u.transpose();a<u.length;a++)o[a]=l(u[a]);return o}return l(this[0])}}(r[t])}("quantiles percentileOfScore".split(" "))}(r,Math),function(e,r){e.gammaln=function(e){var n,t,o,i=0,a=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],u=1.000000000190015;for(o=(t=n=e)+5.5,o-=(n+.5)*r.log(o);i<6;i++)u+=a[i]/++t;return r.log(2.5066282746310007*u/n)-o},e.loggam=function(e){var n,t,o,i,a,u,s,c=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=e,s=0,1==e||2==e)return 0;for(e<=7&&(n=e+(s=r.floor(7-e))),t=1/(n*n),o=2*r.PI,a=c[9],u=8;u>=0;u--)a*=t,a+=c[u];if(i=a/n+.5*r.log(o)+(n-.5)*r.log(n)-n,e<=7)for(u=1;u<=s;u++)i-=r.log(n-1),n-=1;return i},e.gammafn=function(e){var n,t,o,i,a=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],u=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],s=!1,c=0,l=0,f=0,m=e;if(e>171.6243769536076)return 1/0;if(m<=0){if(!(i=m%1+36e-17))return 1/0;s=(1&m?-1:1)*r.PI/r.sin(r.PI*i),m=1-m}for(o=m,t=m<1?m++:(m-=c=(0|m)-1)-1,n=0;n<8;++n)f=(f+a[n])*t,l=l*t+u[n];if(i=f/l+1,o<m)i/=o;else if(o>m)for(n=0;n<c;++n)i*=m,m++;return s&&(i=s/i),i},e.gammap=function(r,n){return e.lowRegGamma(r,n)*e.gammafn(r)},e.lowRegGamma=function(n,t){var o,i=e.gammaln(n),a=n,u=1/n,s=u,c=t+1-n,l=1/1e-30,f=1/c,m=f,h=1,d=-~(8.5*r.log(n>=1?n:1/n)+.4*n+17);if(t<0||n<=0)return NaN;if(t<n+1){for(;h<=d;h++)u+=s*=t/++a;return u*r.exp(-t+n*r.log(t)-i)}for(;h<=d;h++)m*=(f=1/(f=(o=-h*(h-n))*f+(c+=2)))*(l=c+o/l);return 1-m*r.exp(-t+n*r.log(t)-i)},e.factorialln=function(r){return r<0?NaN:e.gammaln(r+1)},e.factorial=function(r){return r<0?NaN:e.gammafn(r+1)},e.combination=function(n,t){return n>170||t>170?r.exp(e.combinationln(n,t)):e.factorial(n)/e.factorial(t)/e.factorial(n-t)},e.combinationln=function(r,n){return e.factorialln(r)-e.factorialln(n)-e.factorialln(r-n)},e.permutation=function(r,n){return e.factorial(r)/e.factorial(r-n)},e.betafn=function(n,t){if(!(n<=0||t<=0))return n+t>170?r.exp(e.betaln(n,t)):e.gammafn(n)*e.gammafn(t)/e.gammafn(n+t)},e.betaln=function(r,n){return e.gammaln(r)+e.gammaln(n)-e.gammaln(r+n)},e.betacf=function(e,n,t){var o,i,a,u,s=1e-30,c=1,l=n+t,f=n+1,m=n-1,h=1,d=1-l*e/f;for(r.abs(d)<s&&(d=s),u=d=1/d;c<=100&&(d=1+(i=c*(t-c)*e/((m+(o=2*c))*(n+o)))*d,r.abs(d)<s&&(d=s),h=1+i/h,r.abs(h)<s&&(h=s),u*=(d=1/d)*h,d=1+(i=-(n+c)*(l+c)*e/((n+o)*(f+o)))*d,r.abs(d)<s&&(d=s),h=1+i/h,r.abs(h)<s&&(h=s),u*=a=(d=1/d)*h,!(r.abs(a-1)<3e-7));c++);return u},e.gammapinv=function(n,t){var o,i,a,u,s,c,l=0,f=t-1,m=e.gammaln(t);if(n>=1)return r.max(100,t+100*r.sqrt(t));if(n<=0)return 0;for(t>1?(s=r.log(f),c=r.exp(f*(s-1)-m),u=n<.5?n:1-n,o=(2.30753+.27061*(i=r.sqrt(-2*r.log(u))))/(1+i*(.99229+.04481*i))-i,n<.5&&(o=-o),o=r.max(.001,t*r.pow(1-1/(9*t)-o/(3*r.sqrt(t)),3))):o=n<(i=1-t*(.253+.12*t))?r.pow(n/i,1/t):1-r.log(1-(n-i)/(1-i));l<12;l++){if(o<=0)return 0;if((o-=i=(a=(e.lowRegGamma(t,o)-n)/(i=t>1?c*r.exp(-(o-f)+f*(r.log(o)-s)):r.exp(-o+f*r.log(o)-m)))/(1-.5*r.min(1,a*((t-1)/o-1))))<=0&&(o=.5*(o+i)),r.abs(i)<1e-8*o)break}return o},e.erf=function(e){var n,t,o,i,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],u=a.length-1,s=!1,c=0,l=0;for(e<0&&(e=-e,s=!0),t=4*(n=2/(2+e))-2;u>0;u--)o=c,c=t*c-l+a[u],l=o;return i=n*r.exp(-e*e+.5*(a[0]+t*c)-l),s?i-1:1-i},e.erfc=function(r){return 1-e.erf(r)},e.erfcinv=function(n){var t,o,i,a,u=0;if(n>=2)return-100;if(n<=0)return 100;for(a=n<1?n:2-n,t=-.70711*((2.30753+.27061*(i=r.sqrt(-2*r.log(a/2))))/(1+i*(.99229+.04481*i))-i);u<2;u++)t+=(o=e.erfc(t)-a)/(1.1283791670955126*r.exp(-t*t)-t*o);return n<1?t:-t},e.ibetainv=function(n,t,o){var i,a,u,s,c,l,f,m,h,d,p=t-1,g=o-1,v=0;if(n<=0)return 0;if(n>=1)return 1;for(t>=1&&o>=1?(u=n<.5?n:1-n,l=(2.30753+.27061*(s=r.sqrt(-2*r.log(u))))/(1+s*(.99229+.04481*s))-s,n<.5&&(l=-l),f=(l*l-3)/6,m=2/(1/(2*t-1)+1/(2*o-1)),h=l*r.sqrt(f+m)/m-(1/(2*o-1)-1/(2*t-1))*(f+5/6-2/(3*m)),l=t/(t+o*r.exp(2*h))):(i=r.log(t/(t+o)),a=r.log(o/(t+o)),l=n<(s=r.exp(t*i)/t)/(h=s+(c=r.exp(o*a)/o))?r.pow(t*h*n,1/t):1-r.pow(o*h*(1-n),1/o)),d=-e.gammaln(t)-e.gammaln(o)+e.gammaln(t+o);v<10;v++){if(0===l||1===l)return l;if((l-=s=(c=(e.ibeta(l,t,o)-n)/(s=r.exp(p*r.log(l)+g*r.log(1-l)+d)))/(1-.5*r.min(1,c*(p/l-g/(1-l)))))<=0&&(l=.5*(l+s)),l>=1&&(l=.5*(l+s+1)),r.abs(s)<1e-8*l&&v>0)break}return l},e.ibeta=function(n,t,o){var i=0===n||1===n?0:r.exp(e.gammaln(t+o)-e.gammaln(t)-e.gammaln(o)+t*r.log(n)+o*r.log(1-n));return!(n<0||n>1)&&(n<(t+1)/(t+o+2)?i*e.betacf(n,t,o)/t:1-i*e.betacf(1-n,o,t)/o)},e.randn=function(n,t){var o,i,a,u,s;if(t||(t=n),n)return e.create(n,t,(function(){return e.randn()}));do{o=e._random_fn(),i=1.7156*(e._random_fn()-.5),s=(a=o-.449871)*a+(u=r.abs(i)+.386595)*(.196*u-.25472*a)}while(s>.27597&&(s>.27846||i*i>-4*r.log(o)*o*o));return i/o},e.randg=function(n,t,o){var i,a,u,s,c,l,f=n;if(o||(o=t),n||(n=1),t)return(l=e.zeros(t,o)).alter((function(){return e.randg(n)})),l;n<1&&(n+=1),i=n-1/3,a=1/r.sqrt(9*i);do{do{s=1+a*(c=e.randn())}while(s<=0);s*=s*s,u=e._random_fn()}while(u>1-.331*r.pow(c,4)&&r.log(u)>.5*c*c+i*(1-s+r.log(s)));if(n==f)return i*s;do{u=e._random_fn()}while(0===u);return r.pow(u,1/f)*i*s},function(r){for(var n=0;n<r.length;n++)!function(r){e.fn[r]=function(){return e(e.map(this,(function(n){return e[r](n)})))}}(r[n])}("gammaln gammafn factorial factorialln".split(" ")),function(r){for(var n=0;n<r.length;n++)!function(r){e.fn[r]=function(){return e(e[r].apply(null,arguments))}}(r[n])}("randn".split(" "))}(r,Math),function(e,r){function n(e,n,t,o){for(var i,a=0,u=1,s=1,c=1,l=0,f=0;r.abs((s-f)/s)>o;)f=s,u=c+(i=-(n+l)*(n+t+l)*e/(n+2*l)/(n+2*l+1))*u,s=(a=s+i*a)+(i=(l+=1)*(t-l)*e/(n+2*l-1)/(n+2*l))*s,a/=c=u+i*c,u/=c,s/=c,c=1;return s/n}function t(n,t,o){var i=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],a=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],u=.5*n;if(u>=8)return 1;var s,c=2*e.normal.cdf(u,0,1,1,0)-1;c=c>=r.exp(-50/o)?r.pow(c,o):0;for(var l=u,f=(8-u)/(s=n>3?2:3),m=l+f,h=0,d=o-1,p=1;p<=s;p++){for(var g=0,v=.5*(m+l),y=.5*(m-l),_=1;_<=12;_++){var x,w=v+y*(6<_?i[(x=12-_+1)-1]:-i[(x=_)-1]),T=w*w;if(T>60)break;var b=2*e.normal.cdf(w,0,1,1,0)*.5-2*e.normal.cdf(w,n,1,1,0)*.5;b>=r.exp(-30/d)&&(g+=b=a[x-1]*r.exp(-.5*T)*r.pow(b,d))}h+=g*=2*y*o/r.sqrt(2*r.PI),l=m,m+=f}return(c+=h)<=r.exp(-30/t)?0:(c=r.pow(c,t))>=1?1:c}!function(r){for(var n=0;n<r.length;n++)!function(r){e[r]=function e(r,n,t){return this instanceof e?(this._a=r,this._b=n,this._c=t,this):new e(r,n,t)},e.fn[r]=function(n,t,o){var i=e[r](n,t,o);return i.data=this,i},e[r].prototype.sample=function(n){var t=this._a,o=this._b,i=this._c;return n?e.alter(n,(function(){return e[r].sample(t,o,i)})):e[r].sample(t,o,i)},function(n){for(var t=0;t<n.length;t++)!function(n){e[r].prototype[n]=function(t){var o=this._a,i=this._b,a=this._c;return t||0===t||(t=this.data),"number"!=typeof t?e.fn.map.call(t,(function(t){return e[r][n](t,o,i,a)})):e[r][n](t,o,i,a)}}(n[t])}("pdf cdf inv".split(" ")),function(n){for(var t=0;t<n.length;t++)!function(n){e[r].prototype[n]=function(){return e[r][n](this._a,this._b,this._c)}}(n[t])}("mean median mode variance".split(" "))}(r[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(" ")),e.extend(e.beta,{pdf:function(n,t,o){return n>1||n<0?0:1==t&&1==o?1:t<512&&o<512?r.pow(n,t-1)*r.pow(1-n,o-1)/e.betafn(t,o):r.exp((t-1)*r.log(n)+(o-1)*r.log(1-n)-e.betaln(t,o))},cdf:function(r,n,t){return r>1||r<0?1*(r>1):e.ibeta(r,n,t)},inv:function(r,n,t){return e.ibetainv(r,n,t)},mean:function(e,r){return e/(e+r)},median:function(r,n){return e.ibetainv(.5,r,n)},mode:function(e,r){return(e-1)/(e+r-2)},sample:function(r,n){var t=e.randg(r);return t/(t+e.randg(n))},variance:function(e,n){return e*n/(r.pow(e+n,2)*(e+n+1))}}),e.extend(e.centralF,{pdf:function(n,t,o){var i;return n<0?0:t<=2?0===n&&t<2?1/0:0===n&&2===t?1:1/e.betafn(t/2,o/2)*r.pow(t/o,t/2)*r.pow(n,t/2-1)*r.pow(1+t/o*n,-(t+o)/2):(i=t*n/(o+n*t),t*(o/(o+n*t))/2*e.binomial.pdf((t-2)/2,(t+o-2)/2,i))},cdf:function(r,n,t){return r<0?0:e.ibeta(n*r/(n*r+t),n/2,t/2)},inv:function(r,n,t){return t/(n*(1/e.ibetainv(r,n/2,t/2)-1))},mean:function(e,r){return r>2?r/(r-2):void 0},mode:function(e,r){return e>2?r*(e-2)/(e*(r+2)):void 0},sample:function(r,n){return 2*e.randg(r/2)/r/(2*e.randg(n/2)/n)},variance:function(e,r){if(!(r<=4))return 2*r*r*(e+r-2)/(e*(r-2)*(r-2)*(r-4))}}),e.extend(e.cauchy,{pdf:function(e,n,t){return t<0?0:t/(r.pow(e-n,2)+r.pow(t,2))/r.PI},cdf:function(e,n,t){return r.atan((e-n)/t)/r.PI+.5},inv:function(e,n,t){return n+t*r.tan(r.PI*(e-.5))},median:function(e){return e},mode:function(e){return e},sample:function(n,t){return e.randn()*r.sqrt(1/(2*e.randg(.5)))*t+n}}),e.extend(e.chisquare,{pdf:function(n,t){return n<0?0:0===n&&2===t?.5:r.exp((t/2-1)*r.log(n)-n/2-t/2*r.log(2)-e.gammaln(t/2))},cdf:function(r,n){return r<0?0:e.lowRegGamma(n/2,r/2)},inv:function(r,n){return 2*e.gammapinv(r,.5*n)},mean:function(e){return e},median:function(e){return e*r.pow(1-2/(9*e),3)},mode:function(e){return e-2>0?e-2:0},sample:function(r){return 2*e.randg(r/2)},variance:function(e){return 2*e}}),e.extend(e.exponential,{pdf:function(e,n){return e<0?0:n*r.exp(-n*e)},cdf:function(e,n){return e<0?0:1-r.exp(-n*e)},inv:function(e,n){return-r.log(1-e)/n},mean:function(e){return 1/e},median:function(e){return 1/e*r.log(2)},mode:function(){return 0},sample:function(n){return-1/n*r.log(e._random_fn())},variance:function(e){return r.pow(e,-2)}}),e.extend(e.gamma,{pdf:function(n,t,o){return n<0?0:0===n&&1===t?1/o:r.exp((t-1)*r.log(n)-n/o-e.gammaln(t)-t*r.log(o))},cdf:function(r,n,t){return r<0?0:e.lowRegGamma(n,r/t)},inv:function(r,n,t){return e.gammapinv(r,n)*t},mean:function(e,r){return e*r},mode:function(e,r){if(e>1)return(e-1)*r},sample:function(r,n){return e.randg(r)*n},variance:function(e,r){return e*r*r}}),e.extend(e.invgamma,{pdf:function(n,t,o){return n<=0?0:r.exp(-(t+1)*r.log(n)-o/n-e.gammaln(t)+t*r.log(o))},cdf:function(r,n,t){return r<=0?0:1-e.lowRegGamma(n,t/r)},inv:function(r,n,t){return t/e.gammapinv(1-r,n)},mean:function(e,r){return e>1?r/(e-1):void 0},mode:function(e,r){return r/(e+1)},sample:function(r,n){return n/e.randg(r)},variance:function(e,r){if(!(e<=2))return r*r/((e-1)*(e-1)*(e-2))}}),e.extend(e.kumaraswamy,{pdf:function(e,n,t){return 0===e&&1===n?t:1===e&&1===t?n:r.exp(r.log(n)+r.log(t)+(n-1)*r.log(e)+(t-1)*r.log(1-r.pow(e,n)))},cdf:function(e,n,t){return e<0?0:e>1?1:1-r.pow(1-r.pow(e,n),t)},inv:function(e,n,t){return r.pow(1-r.pow(1-e,1/t),1/n)},mean:function(r,n){return n*e.gammafn(1+1/r)*e.gammafn(n)/e.gammafn(1+1/r+n)},median:function(e,n){return r.pow(1-r.pow(2,-1/n),1/e)},mode:function(e,n){if(e>=1&&n>=1&&1!==e&&1!==n)return r.pow((e-1)/(e*n-1),1/e)},variance:function(){throw new Error("variance not yet implemented")}}),e.extend(e.lognormal,{pdf:function(e,n,t){return e<=0?0:r.exp(-r.log(e)-.5*r.log(2*r.PI)-r.log(t)-r.pow(r.log(e)-n,2)/(2*t*t))},cdf:function(n,t,o){return n<0?0:.5+.5*e.erf((r.log(n)-t)/r.sqrt(2*o*o))},inv:function(n,t,o){return r.exp(-1.4142135623730951*o*e.erfcinv(2*n)+t)},mean:function(e,n){return r.exp(e+n*n/2)},median:function(e){return r.exp(e)},mode:function(e,n){return r.exp(e-n*n)},sample:function(n,t){return r.exp(e.randn()*t+n)},variance:function(e,n){return(r.exp(n*n)-1)*r.exp(2*e+n*n)}}),e.extend(e.noncentralt,{pdf:function(n,t,o){return r.abs(o)<1e-14?e.studentt.pdf(n,t):r.abs(n)<1e-14?r.exp(e.gammaln((t+1)/2)-o*o/2-.5*r.log(r.PI*t)-e.gammaln(t/2)):t/n*(e.noncentralt.cdf(n*r.sqrt(1+2/t),t+2,o)-e.noncentralt.cdf(n,t,o))},cdf:function(n,t,o){var i=1e-14;if(r.abs(o)<i)return e.studentt.cdf(n,t);var a=!1;n<0&&(a=!0,o=-o);for(var u=e.normal.cdf(-o,0,1),s=i+1,c=s,l=n*n/(n*n+t),f=0,m=r.exp(-o*o/2),h=r.exp(-o*o/2-.5*r.log(2)-e.gammaln(1.5))*o;f<200||c>i||s>i;)c=s,f>0&&(m*=o*o/(2*f),h*=o*o/(2*(f+.5))),u+=.5*(s=m*e.beta.cdf(l,f+.5,t/2)+h*e.beta.cdf(l,f+1,t/2)),f++;return a?1-u:u}}),e.extend(e.normal,{pdf:function(e,n,t){return r.exp(-.5*r.log(2*r.PI)-r.log(t)-r.pow(e-n,2)/(2*t*t))},cdf:function(n,t,o){return.5*(1+e.erf((n-t)/r.sqrt(2*o*o)))},inv:function(r,n,t){return-1.4142135623730951*t*e.erfcinv(2*r)+n},mean:function(e){return e},median:function(e){return e},mode:function(e){return e},sample:function(r,n){return e.randn()*n+r},variance:function(e,r){return r*r}}),e.extend(e.pareto,{pdf:function(e,n,t){return e<n?0:t*r.pow(n,t)/r.pow(e,t+1)},cdf:function(e,n,t){return e<n?0:1-r.pow(n/e,t)},inv:function(e,n,t){return n/r.pow(1-e,1/t)},mean:function(e,n){if(!(n<=1))return n*r.pow(e,n)/(n-1)},median:function(e,n){return e*(n*r.SQRT2)},mode:function(e){return e},variance:function(e,n){if(!(n<=2))return e*e*n/(r.pow(n-1,2)*(n-2))}}),e.extend(e.studentt,{pdf:function(n,t){return t=t>1e100?1e100:t,1/(r.sqrt(t)*e.betafn(.5,t/2))*r.pow(1+n*n/t,-(t+1)/2)},cdf:function(n,t){var o=t/2;return e.ibeta((n+r.sqrt(n*n+t))/(2*r.sqrt(n*n+t)),o,o)},inv:function(n,t){var o=e.ibetainv(2*r.min(n,1-n),.5*t,.5);return o=r.sqrt(t*(1-o)/o),n>.5?o:-o},mean:function(e){return e>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(n){return e.randn()*r.sqrt(n/(2*e.randg(n/2)))},variance:function(e){return e>2?e/(e-2):e>1?1/0:void 0}}),e.extend(e.weibull,{pdf:function(e,n,t){return e<0||n<0||t<0?0:t/n*r.pow(e/n,t-1)*r.exp(-r.pow(e/n,t))},cdf:function(e,n,t){return e<0?0:1-r.exp(-r.pow(e/n,t))},inv:function(e,n,t){return n*r.pow(-r.log(1-e),1/t)},mean:function(r,n){return r*e.gammafn(1+1/n)},median:function(e,n){return e*r.pow(r.log(2),1/n)},mode:function(e,n){return n<=1?0:e*r.pow((n-1)/n,1/n)},sample:function(n,t){return n*r.pow(-r.log(e._random_fn()),1/t)},variance:function(n,t){return n*n*e.gammafn(1+2/t)-r.pow(e.weibull.mean(n,t),2)}}),e.extend(e.uniform,{pdf:function(e,r,n){return e<r||e>n?0:1/(n-r)},cdf:function(e,r,n){return e<r?0:e<n?(e-r)/(n-r):1},inv:function(e,r,n){return r+e*(n-r)},mean:function(e,r){return.5*(e+r)},median:function(r,n){return e.mean(r,n)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(r,n){return r/2+n/2+(n/2-r/2)*(2*e._random_fn()-1)},variance:function(e,n){return r.pow(n-e,2)/12}}),e.extend(e.binomial,{pdf:function(n,t,o){return 0===o||1===o?t*o===n?1:0:e.combination(t,n)*r.pow(o,n)*r.pow(1-o,t-n)},cdf:function(t,o,i){var a,u=1e-10;if(t<0)return 0;if(t>=o)return 1;if(i<0||i>1||o<=0)return NaN;var s=i,c=(t=r.floor(t))+1,l=o-t,f=c+l,m=r.exp(e.gammaln(f)-e.gammaln(l)-e.gammaln(c)+c*r.log(s)+l*r.log(1-s));return a=s<(c+1)/(f+2)?m*n(s,c,l,u):1-m*n(1-s,l,c,u),r.round(1/u*(1-a))/(1/u)}}),e.extend(e.negbin,{pdf:function(n,t,o){return n===n>>>0&&(n<0?0:e.combination(n+t-1,t-1)*r.pow(1-o,n)*r.pow(o,t))},cdf:function(r,n,t){var o=0,i=0;if(r<0)return 0;for(;i<=r;i++)o+=e.negbin.pdf(i,n,t);return o}}),e.extend(e.hypgeom,{pdf:function(n,t,o,i){if(n!=n|0)return!1;if(n<0||n<o-(t-i))return 0;if(n>i||n>o)return 0;if(2*o>t)return 2*i>t?e.hypgeom.pdf(t-o-i+n,t,t-o,t-i):e.hypgeom.pdf(i-n,t,t-o,i);if(2*i>t)return e.hypgeom.pdf(o-n,t,o,t-i);if(o<i)return e.hypgeom.pdf(n,t,i,o);for(var a=1,u=0,s=0;s<n;s++){for(;a>1&&u<i;)a*=1-o/(t-u),u++;a*=(i-s)*(o-s)/((s+1)*(t-o-i+s+1))}for(;u<i;u++)a*=1-o/(t-u);return r.min(1,r.max(0,a))},cdf:function(n,t,o,i){if(n<0||n<o-(t-i))return 0;if(n>=i||n>=o)return 1;if(2*o>t)return 2*i>t?e.hypgeom.cdf(t-o-i+n,t,t-o,t-i):1-e.hypgeom.cdf(i-n-1,t,t-o,i);if(2*i>t)return 1-e.hypgeom.cdf(o-n-1,t,o,t-i);if(o<i)return e.hypgeom.cdf(n,t,i,o);for(var a=1,u=1,s=0,c=0;c<n;c++){for(;a>1&&s<i;){var l=1-o/(t-s);u*=l,a*=l,s++}a+=u*=(i-c)*(o-c)/((c+1)*(t-o-i+c+1))}for(;s<i;s++)a*=1-o/(t-s);return r.min(1,r.max(0,a))}}),e.extend(e.poisson,{pdf:function(n,t){return t<0||n%1!=0||n<0?0:r.pow(t,n)*r.exp(-t)/e.factorial(n)},cdf:function(r,n){var t=[],o=0;if(r<0)return 0;for(;o<=r;o++)t.push(e.poisson.pdf(o,n));return e.sum(t)},mean:function(e){return e},variance:function(e){return e},sampleSmall:function(n){var t=1,o=0,i=r.exp(-n);do{o++,t*=e._random_fn()}while(t>i);return o-1},sampleLarge:function(n){var t,o,i,a,u,s,c,l,f,m,h=n;for(a=r.sqrt(h),u=r.log(h),s=.02483*(c=.931+2.53*a)-.059,l=1.1239+1.1328/(c-3.4),f=.9277-3.6224/(c-2);;){if(o=r.random()-.5,i=r.random(),m=.5-r.abs(o),t=r.floor((2*s/m+c)*o+h+.43),m>=.07&&i<=f)return t;if(!(t<0||m<.013&&i>m)&&r.log(i)+r.log(l)-r.log(s/(m*m)+c)<=t*u-h-e.loggam(t+1))return t}},sample:function(e){return e<10?this.sampleSmall(e):this.sampleLarge(e)}}),e.extend(e.triangular,{pdf:function(e,r,n,t){return n<=r||t<r||t>n?NaN:e<r||e>n?0:e<t?2*(e-r)/((n-r)*(t-r)):e===t?2/(n-r):2*(n-e)/((n-r)*(n-t))},cdf:function(e,n,t,o){return t<=n||o<n||o>t?NaN:e<=n?0:e>=t?1:e<=o?r.pow(e-n,2)/((t-n)*(o-n)):1-r.pow(t-e,2)/((t-n)*(t-o))},inv:function(e,n,t,o){return t<=n||o<n||o>t?NaN:e<=(o-n)/(t-n)?n+(t-n)*r.sqrt(e*((o-n)/(t-n))):n+(t-n)*(1-r.sqrt((1-e)*(1-(o-n)/(t-n))))},mean:function(e,r,n){return(e+r+n)/3},median:function(e,n,t){return t<=(e+n)/2?n-r.sqrt((n-e)*(n-t))/r.sqrt(2):t>(e+n)/2?e+r.sqrt((n-e)*(t-e))/r.sqrt(2):void 0},mode:function(e,r,n){return n},sample:function(n,t,o){var i=e._random_fn();return i<(o-n)/(t-n)?n+r.sqrt(i*(t-n)*(o-n)):t-r.sqrt((1-i)*(t-n)*(t-o))},variance:function(e,r,n){return(e*e+r*r+n*n-e*r-e*n-r*n)/18}}),e.extend(e.arcsine,{pdf:function(e,n,t){return t<=n?NaN:e<=n||e>=t?0:2/r.PI*r.pow(r.pow(t-n,2)-r.pow(2*e-n-t,2),-.5)},cdf:function(e,n,t){return e<n?0:e<t?2/r.PI*r.asin(r.sqrt((e-n)/(t-n))):1},inv:function(e,n,t){return n+(.5-.5*r.cos(r.PI*e))*(t-n)},mean:function(e,r){return r<=e?NaN:(e+r)/2},median:function(e,r){return r<=e?NaN:(e+r)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(n,t){return(n+t)/2+(t-n)/2*r.sin(2*r.PI*e.uniform.sample(0,1))},variance:function(e,n){return n<=e?NaN:r.pow(n-e,2)/8}}),e.extend(e.laplace,{pdf:function(e,n,t){return t<=0?0:r.exp(-r.abs(e-n)/t)/(2*t)},cdf:function(e,n,t){return t<=0?0:e<n?.5*r.exp((e-n)/t):1-.5*r.exp(-(e-n)/t)},mean:function(e){return e},median:function(e){return e},mode:function(e){return e},variance:function(e,r){return 2*r*r},sample:function(n,t){var o,i=e._random_fn()-.5;return n-t*((o=i)/r.abs(o))*r.log(1-2*r.abs(i))}}),e.extend(e.tukey,{cdf:function(n,o,i){var a=o,u=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],s=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(n<=0)return 0;if(i<2||a<2)return NaN;if(!Number.isFinite(n))return 1;if(i>25e3)return t(n,1,a);var c,l=.5*i,f=l*r.log(i)-i*r.log(2)-e.gammaln(l),m=l-1,h=.25*i;c=i<=100?1:i<=800?.5:i<=5e3?.25:.125,f+=r.log(c);for(var d=0,p=1;p<=50;p++){for(var g=0,v=(2*p-1)*c,y=1;y<=16;y++){var _,x;8<y?(_=y-8-1,x=f+m*r.log(v+u[_]*c)-(u[_]*c+v)*h):(_=y-1,x=f+m*r.log(v-u[_]*c)+(u[_]*c-v)*h),x>=-30&&(g+=t(8<y?n*r.sqrt(.5*(u[_]*c+v)):n*r.sqrt(.5*(-u[_]*c+v)),1,a)*s[_]*r.exp(x))}if(p*c>=1&&g<=1e-14)break;d+=g}if(g>1e-14)throw new Error("tukey.cdf failed to converge");return d>1&&(d=1),d},inv:function(n,t,o){if(o<2||t<2)return NaN;if(n<0||n>1)return NaN;if(0===n)return 0;if(1===n)return 1/0;var i,a=function(e,n,t){var o=.5-.5*e,i=r.sqrt(r.log(1/(o*o))),a=i+((((-453642210148e-16*i-.204231210125)*i-.342242088547)*i-1)*i+.322232421088)/((((.0038560700634*i+.10353775285)*i+.531103462366)*i+.588581570495)*i+.099348462606);t<120&&(a+=(a*a*a+a)/t/4);var u=.8832-.2368*a;return t<120&&(u+=-1.214/t+1.208*a/t),a*(u*r.log(n-1)+1.4142)}(n,t,o),u=e.tukey.cdf(a,t,o)-n;i=u>0?r.max(0,a-1):a+1;for(var s,c=e.tukey.cdf(i,t,o)-n,l=1;l<50;l++)if(s=i-c*(i-a)/(c-u),u=c,a=i,s<0&&(s=0,c=-n),c=e.tukey.cdf(s,t,o)-n,i=s,r.abs(i-a)<1e-4)return s;throw new Error("tukey.inv failed to converge")}})}(r,Math),function(e,r){var n,t,o=Array.prototype.push,i=e.utils.isArray;function a(r){return i(r)||r instanceof e}e.extend({add:function(r,n){return a(n)?(a(n[0])||(n=[n]),e.map(r,(function(e,r,t){return e+n[r][t]}))):e.map(r,(function(e){return e+n}))},subtract:function(r,n){return a(n)?(a(n[0])||(n=[n]),e.map(r,(function(e,r,t){return e-n[r][t]||0}))):e.map(r,(function(e){return e-n}))},divide:function(r,n){return a(n)?(a(n[0])||(n=[n]),e.multiply(r,e.inv(n))):e.map(r,(function(e){return e/n}))},multiply:function(r,n){var t,o,i,u,s,c,l,f;if(void 0===r.length&&void 0===n.length)return r*n;if(s=r.length,c=r[0].length,l=e.zeros(s,i=a(n)?n[0].length:c),f=0,a(n)){for(;f<i;f++)for(t=0;t<s;t++){for(u=0,o=0;o<c;o++)u+=r[t][o]*n[o][f];l[t][f]=u}return 1===s&&1===f?l[0][0]:l}return e.map(r,(function(e){return e*n}))},outer:function(r,n){return e.multiply(r.map((function(e){return[e]})),[n])},dot:function(r,n){a(r[0])||(r=[r]),a(n[0])||(n=[n]);for(var t,o,i=1===r[0].length&&1!==r.length?e.transpose(r):r,u=1===n[0].length&&1!==n.length?e.transpose(n):n,s=[],c=0,l=i.length,f=i[0].length;c<l;c++){for(s[c]=[],t=0,o=0;o<f;o++)t+=i[c][o]*u[c][o];s[c]=t}return 1===s.length?s[0]:s},pow:function(n,t){return e.map(n,(function(e){return r.pow(e,t)}))},exp:function(n){return e.map(n,(function(e){return r.exp(e)}))},log:function(n){return e.map(n,(function(e){return r.log(e)}))},abs:function(n){return e.map(n,(function(e){return r.abs(e)}))},norm:function(e,n){var t=0,o=0;for(isNaN(n)&&(n=2),a(e[0])&&(e=e[0]);o<e.length;o++)t+=r.pow(r.abs(e[o]),n);return r.pow(t,1/n)},angle:function(n,t){return r.acos(e.dot(n,t)/(e.norm(n)*e.norm(t)))},aug:function(e,r){var n,t=[];for(n=0;n<e.length;n++)t.push(e[n].slice());for(n=0;n<t.length;n++)o.apply(t[n],r[n]);return t},inv:function(r){for(var n,t=r.length,o=r[0].length,i=e.identity(t,o),a=e.gauss_jordan(r,i),u=[],s=0;s<t;s++)for(u[s]=[],n=o;n<a[0].length;n++)u[s][n-o]=a[s][n];return u},det:function e(r){if(2===r.length)return r[0][0]*r[1][1]-r[0][1]*r[1][0];for(var n=0,t=0;t<r.length;t++){for(var o=[],i=1;i<r.length;i++){o[i-1]=[];for(var a=0;a<r.length;a++)a<t?o[i-1][a]=r[i][a]:a>t&&(o[i-1][a-1]=r[i][a])}var u=t%2?-1:1;n+=e(o)*r[0][t]*u}return n},gauss_elimination:function(n,t){var o,i,a,u,s=0,c=0,l=n.length,f=n[0].length,m=1,h=0,d=[];for(o=(n=e.aug(n,t))[0].length,s=0;s<l;s++){for(i=n[s][s],c=s,u=s+1;u<f;u++)i<r.abs(n[u][s])&&(i=n[u][s],c=u);if(c!=s)for(u=0;u<o;u++)a=n[s][u],n[s][u]=n[c][u],n[c][u]=a;for(c=s+1;c<l;c++)for(m=n[c][s]/n[s][s],u=s;u<o;u++)n[c][u]=n[c][u]-m*n[s][u]}for(s=l-1;s>=0;s--){for(h=0,c=s+1;c<=l-1;c++)h+=d[c]*n[s][c];d[s]=(n[s][o-1]-h)/n[s][s]}return d},gauss_jordan:function(n,t){var o,i,a,u=e.aug(n,t),s=u.length,c=u[0].length,l=0;for(i=0;i<s;i++){var f=i;for(a=i+1;a<s;a++)r.abs(u[a][i])>r.abs(u[f][i])&&(f=a);var m=u[i];for(u[i]=u[f],u[f]=m,a=i+1;a<s;a++)for(l=u[a][i]/u[i][i],o=i;o<c;o++)u[a][o]-=u[i][o]*l}for(i=s-1;i>=0;i--){for(l=u[i][i],a=0;a<i;a++)for(o=c-1;o>i-1;o--)u[a][o]-=u[i][o]*u[a][i]/l;for(u[i][i]/=l,o=s;o<c;o++)u[i][o]/=l}return u},triaUpSolve:function(r,n){var t,o=r[0].length,i=e.zeros(1,o)[0],a=!1;return null!=n[0].length&&(n=n.map((function(e){return e[0]})),a=!0),e.arange(o-1,-1,-1).forEach((function(a){t=e.arange(a+1,o).map((function(e){return i[e]*r[a][e]})),i[a]=(n[a]-e.sum(t))/r[a][a]})),a?i.map((function(e){return[e]})):i},triaLowSolve:function(r,n){var t,o=r[0].length,i=e.zeros(1,o)[0],a=!1;return null!=n[0].length&&(n=n.map((function(e){return e[0]})),a=!0),e.arange(o).forEach((function(o){t=e.arange(o).map((function(e){return r[o][e]*i[e]})),i[o]=(n[o]-e.sum(t))/r[o][o]})),a?i.map((function(e){return[e]})):i},lu:function(r){var n,t=r.length,o=e.identity(t),i=e.zeros(r.length,r[0].length);return e.arange(t).forEach((function(e){i[0][e]=r[0][e]})),e.arange(1,t).forEach((function(a){e.arange(a).forEach((function(t){n=e.arange(t).map((function(e){return o[a][e]*i[e][t]})),o[a][t]=(r[a][t]-e.sum(n))/i[t][t]})),e.arange(a,t).forEach((function(t){n=e.arange(a).map((function(e){return o[a][e]*i[e][t]})),i[a][t]=r[n.length][t]-e.sum(n)}))})),[o,i]},cholesky:function(n){var t,o=n.length,i=e.zeros(n.length,n[0].length);return e.arange(o).forEach((function(a){t=e.arange(a).map((function(e){return r.pow(i[a][e],2)})),i[a][a]=r.sqrt(n[a][a]-e.sum(t)),e.arange(a+1,o).forEach((function(r){t=e.arange(a).map((function(e){return i[a][e]*i[r][e]})),i[r][a]=(n[a][r]-e.sum(t))/i[a][a]}))})),i},gauss_jacobi:function(n,t,o,i){for(var a,u,s,c,l=0,f=0,m=n.length,h=[],d=[],p=[];l<m;l++)for(h[l]=[],d[l]=[],p[l]=[],f=0;f<m;f++)l>f?(h[l][f]=n[l][f],d[l][f]=p[l][f]=0):l<f?(d[l][f]=n[l][f],h[l][f]=p[l][f]=0):(p[l][f]=n[l][f],h[l][f]=d[l][f]=0);for(s=e.multiply(e.multiply(e.inv(p),e.add(h,d)),-1),u=e.multiply(e.inv(p),t),a=o,c=e.add(e.multiply(s,o),u),l=2;r.abs(e.norm(e.subtract(c,a)))>i;)a=c,c=e.add(e.multiply(s,a),u),l++;return c},gauss_seidel:function(n,t,o,i){for(var a,u,s,c,l,f=0,m=n.length,h=[],d=[],p=[];f<m;f++)for(h[f]=[],d[f]=[],p[f]=[],a=0;a<m;a++)f>a?(h[f][a]=n[f][a],d[f][a]=p[f][a]=0):f<a?(d[f][a]=n[f][a],h[f][a]=p[f][a]=0):(p[f][a]=n[f][a],h[f][a]=d[f][a]=0);for(c=e.multiply(e.multiply(e.inv(e.add(p,h)),d),-1),s=e.multiply(e.inv(e.add(p,h)),t),u=o,l=e.add(e.multiply(c,o),s),f=2;r.abs(e.norm(e.subtract(l,u)))>i;)u=l,l=e.add(e.multiply(c,u),s),f+=1;return l},SOR:function(n,t,o,i,a){for(var u,s,c,l,f,m=0,h=n.length,d=[],p=[],g=[];m<h;m++)for(d[m]=[],p[m]=[],g[m]=[],u=0;u<h;u++)m>u?(d[m][u]=n[m][u],p[m][u]=g[m][u]=0):m<u?(p[m][u]=n[m][u],d[m][u]=g[m][u]=0):(g[m][u]=n[m][u],d[m][u]=p[m][u]=0);for(l=e.multiply(e.inv(e.add(g,e.multiply(d,a))),e.subtract(e.multiply(g,1-a),e.multiply(p,a))),c=e.multiply(e.multiply(e.inv(e.add(g,e.multiply(d,a))),t),a),s=o,f=e.add(e.multiply(l,o),c),m=2;r.abs(e.norm(e.subtract(f,s)))>i;)s=f,f=e.add(e.multiply(l,s),c),m++;return f},householder:function(n){for(var t,o,i,a,u=n.length,s=n[0].length,c=0,l=[],f=[];c<u-1;c++){for(t=0,a=c+1;a<s;a++)t+=n[a][c]*n[a][c];for(t=(n[c+1][c]>0?-1:1)*r.sqrt(t),o=r.sqrt((t*t-n[c+1][c]*t)/2),(l=e.zeros(u,1))[c+1][0]=(n[c+1][c]-t)/(2*o),i=c+2;i<u;i++)l[i][0]=n[i][c]/(2*o);f=e.subtract(e.identity(u,s),e.multiply(e.multiply(l,e.transpose(l)),2)),n=e.multiply(f,e.multiply(n,f))}return n},QR:(n=e.sum,t=e.arange,function(o){var i,a,u,s=o.length,c=o[0].length,l=e.zeros(c,c);for(o=e.copy(o),a=0;a<c;a++){for(l[a][a]=r.sqrt(n(t(s).map((function(e){return o[e][a]*o[e][a]})))),i=0;i<s;i++)o[i][a]=o[i][a]/l[a][a];for(u=a+1;u<c;u++)for(l[a][u]=n(t(s).map((function(e){return o[e][a]*o[e][u]}))),i=0;i<s;i++)o[i][u]=o[i][u]-o[i][a]*l[a][u]}return[o,l]}),lstsq:function(r,n){var t=!1;void 0===n[0].length&&(n=n.map((function(e){return[e]})),t=!0);var o=e.QR(r),i=o[0],a=o[1],u=r[0].length,s=e.slice(i,{col:{end:u}}),c=function(r){var n=(r=e.copy(r)).length,t=e.identity(n);return e.arange(n-1,-1,-1).forEach((function(n){e.sliceAssign(t,{row:n},e.divide(e.slice(t,{row:n}),r[n][n])),e.sliceAssign(r,{row:n},e.divide(e.slice(r,{row:n}),r[n][n])),e.arange(n).forEach((function(o){var i=e.multiply(r[o][n],-1),a=e.slice(r,{row:o}),u=e.multiply(e.slice(r,{row:n}),i);e.sliceAssign(r,{row:o},e.add(a,u));var s=e.slice(t,{row:o}),c=e.multiply(e.slice(t,{row:n}),i);e.sliceAssign(t,{row:o},e.add(s,c))}))})),t}(e.slice(a,{row:{end:u}})),l=e.transpose(s);void 0===l[0].length&&(l=[l]);var f=e.multiply(e.multiply(c,l),n);return void 0===f.length&&(f=[[f]]),t?f.map((function(e){return e[0]})):f},jacobi:function(n){for(var t,o,i,a,u,s,c,l=1,f=n.length,m=e.identity(f,f),h=[];1===l;){for(u=n[0][1],i=0,a=1,t=0;t<f;t++)for(o=0;o<f;o++)t!=o&&u<r.abs(n[t][o])&&(u=r.abs(n[t][o]),i=t,a=o);for(s=n[i][i]===n[a][a]?n[i][a]>0?r.PI/4:-r.PI/4:r.atan(2*n[i][a]/(n[i][i]-n[a][a]))/2,(c=e.identity(f,f))[i][i]=r.cos(s),c[i][a]=-r.sin(s),c[a][i]=r.sin(s),c[a][a]=r.cos(s),m=e.multiply(m,c),n=e.multiply(e.multiply(e.inv(c),n),c),l=0,t=1;t<f;t++)for(o=1;o<f;o++)t!=o&&r.abs(n[t][o])>.001&&(l=1)}for(t=0;t<f;t++)h.push(n[t][t]);return[m,h]},rungekutta:function(e,r,n,t,o,i){var a,u,s;if(2===i)for(;t<=n;)o+=((a=r*e(t,o))+(u=r*e(t+r,o+a)))/2,t+=r;if(4===i)for(;t<=n;)o+=((a=r*e(t,o))+2*(u=r*e(t+r/2,o+a/2))+2*(s=r*e(t+r/2,o+u/2))+r*e(t+r,o+s))/6,t+=r;return o},romberg:function(e,n,t,o){for(var i,a,u,s,c,l=0,f=(t-n)/2,m=[],h=[],d=[];l<o/2;){for(c=e(n),u=n,s=0;u<=t;u+=f,s++)m[s]=u;for(i=m.length,u=1;u<i-1;u++)c+=(u%2!=0?4:2)*e(m[u]);c=f/3*(c+e(t)),d[l]=c,f/=2,l++}for(a=d.length,i=1;1!==a;){for(u=0;u<a-1;u++)h[u]=(r.pow(4,i)*d[u+1]-d[u])/(r.pow(4,i)-1);a=h.length,d=h,h=[],i++}return d},richardson:function(e,n,t,o){function i(e,r){for(var n,t=0,o=e.length;t<o;t++)e[t]===r&&(n=t);return n}for(var a,u,s,c,l,f=r.abs(t-e[i(e,t)+1]),m=0,h=[],d=[];o>=f;)a=i(e,t+o),u=i(e,t),h[m]=(n[a]-2*n[u]+n[2*u-a])/(o*o),o/=2,m++;for(c=h.length,s=1;1!=c;){for(l=0;l<c-1;l++)d[l]=(r.pow(4,s)*h[l+1]-h[l])/(r.pow(4,s)-1);c=d.length,h=d,d=[],s++}return h},simpson:function(e,r,n,t){for(var o,i=(n-r)/t,a=e(r),u=[],s=r,c=0,l=1;s<=n;s+=i,c++)u[c]=s;for(o=u.length;l<o-1;l++)a+=(l%2!=0?4:2)*e(u[l]);return i/3*(a+e(n))},hermite:function(e,r,n,t){for(var o,i=e.length,a=0,u=0,s=[],c=[],l=[],f=[];u<i;u++){for(s[u]=1,o=0;o<i;o++)u!=o&&(s[u]*=(t-e[o])/(e[u]-e[o]));for(c[u]=0,o=0;o<i;o++)u!=o&&(c[u]+=1/(e[u]-e[o]));l[u]=(1-2*(t-e[u])*c[u])*(s[u]*s[u]),f[u]=(t-e[u])*(s[u]*s[u]),a+=l[u]*r[u]+f[u]*n[u]}return a},lagrange:function(e,r,n){for(var t,o,i=0,a=0,u=e.length;a<u;a++){for(o=r[a],t=0;t<u;t++)a!=t&&(o*=(n-e[t])/(e[a]-e[t]));i+=o}return i},cubic_spline:function(r,n,t){for(var o,i,a=r.length,u=0,s=[],c=[],l=[],f=[],m=[],h=[];u<a-1;u++)f[u]=r[u+1]-r[u];for(l[0]=0,u=1;u<a-1;u++)l[u]=3/f[u]*(n[u+1]-n[u])-3/f[u-1]*(n[u]-n[u-1]);for(u=1;u<a-1;u++)s[u]=[],c[u]=[],s[u][u-1]=f[u-1],s[u][u]=2*(f[u-1]+f[u]),s[u][u+1]=f[u],c[u][0]=l[u];for(i=e.multiply(e.inv(s),c),o=0;o<a-1;o++)m[o]=(n[o+1]-n[o])/f[o]-f[o]*(i[o+1][0]+2*i[o][0])/3,h[o]=(i[o+1][0]-i[o][0])/(3*f[o]);for(o=0;o<a&&!(r[o]>t);o++);return n[o-=1]+(t-r[o])*m[o]+e.sq(t-r[o])*i[o]+(t-r[o])*e.sq(t-r[o])*h[o]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(r){var n,t,o,i,a,u=r.length,s=r[0].length,c=0,l=[],f=[],m=[],h=[],d=[],p=[],g=[];for(c=0;c<u;c++)l[c]=e.sum(r[c])/s;for(c=0;c<s;c++)for(d[c]=[],n=0;n<u;n++)d[c][n]=r[n][c]-l[n];for(d=e.transpose(d),c=0;c<u;c++)for(p[c]=[],n=0;n<u;n++)p[c][n]=e.dot([d[c]],[d[n]])/(s-1);for(a=(o=e.jacobi(p))[0],f=o[1],g=e.transpose(a),c=0;c<f.length;c++)for(n=c;n<f.length;n++)f[c]<f[n]&&(t=f[c],f[c]=f[n],f[n]=t,m=g[c],g[c]=g[n],g[n]=m);for(i=e.transpose(d),c=0;c<u;c++)for(h[c]=[],n=0;n<i.length;n++)h[c][n]=e.dot([g[c]],[i[n]]);return[r,f,g,h]}}),function(r){for(var n=0;n<r.length;n++)!function(r){e.fn[r]=function(n,t){var o=this;return t?(setTimeout((function(){t.call(o,e.fn[r].call(o,n))}),15),this):"number"==typeof e[r](this,n)?e[r](this,n):e(e[r](this,n))}}(r[n])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(r,Math),function(e,r){var n=[].slice,t=e.utils.isNumber,o=e.utils.isArray;function i(e,n,t,o){if(e>1||t>1||e<=0||t<=0)throw new Error("Proportions should be greater than 0 and less than 1");var i=(e*n+t*o)/(n+o);return(e-t)/r.sqrt(i*(1-i)*(1/n+1/o))}e.extend({zscore:function(){var r=n.call(arguments);return t(r[1])?(r[0]-r[1])/r[2]:(r[0]-e.mean(r[1]))/e.stdev(r[1],r[2])},ztest:function(){var t,i=n.call(arguments);return o(i[1])?(t=e.zscore(i[0],i[1],i[3]),1===i[2]?e.normal.cdf(-r.abs(t),0,1):2*e.normal.cdf(-r.abs(t),0,1)):i.length>2?(t=e.zscore(i[0],i[1],i[2]),1===i[3]?e.normal.cdf(-r.abs(t),0,1):2*e.normal.cdf(-r.abs(t),0,1)):(t=i[0],1===i[1]?e.normal.cdf(-r.abs(t),0,1):2*e.normal.cdf(-r.abs(t),0,1))}}),e.extend(e.fn,{zscore:function(e,r){return(e-this.mean())/this.stdev(r)},ztest:function(n,t,o){var i=r.abs(this.zscore(n,o));return 1===t?e.normal.cdf(-i,0,1):2*e.normal.cdf(-i,0,1)}}),e.extend({tscore:function(){var t=n.call(arguments);return 4===t.length?(t[0]-t[1])/(t[2]/r.sqrt(t[3])):(t[0]-e.mean(t[1]))/(e.stdev(t[1],!0)/r.sqrt(t[1].length))},ttest:function(){var o,i=n.call(arguments);return 5===i.length?(o=r.abs(e.tscore(i[0],i[1],i[2],i[3])),1===i[4]?e.studentt.cdf(-o,i[3]-1):2*e.studentt.cdf(-o,i[3]-1)):t(i[1])?(o=r.abs(i[0]),1==i[2]?e.studentt.cdf(-o,i[1]-1):2*e.studentt.cdf(-o,i[1]-1)):(o=r.abs(e.tscore(i[0],i[1])),1==i[2]?e.studentt.cdf(-o,i[1].length-1):2*e.studentt.cdf(-o,i[1].length-1))}}),e.extend(e.fn,{tscore:function(e){return(e-this.mean())/(this.stdev(!0)/r.sqrt(this.cols()))},ttest:function(n,t){return 1===t?1-e.studentt.cdf(r.abs(this.tscore(n)),this.cols()-1):2*e.studentt.cdf(-r.abs(this.tscore(n)),this.cols()-1)}}),e.extend({anovafscore:function(){var t,o,i,a,u,s,c,l,f=n.call(arguments);if(1===f.length){for(u=new Array(f[0].length),c=0;c<f[0].length;c++)u[c]=f[0][c];f=u}for(o=new Array,c=0;c<f.length;c++)o=o.concat(f[c]);for(i=e.mean(o),t=0,c=0;c<f.length;c++)t+=f[c].length*r.pow(e.mean(f[c])-i,2);for(t/=f.length-1,s=0,c=0;c<f.length;c++)for(a=e.mean(f[c]),l=0;l<f[c].length;l++)s+=r.pow(f[c][l]-a,2);return t/(s/(o.length-f.length))},anovaftest:function(){var r,o,i,a,u=n.call(arguments);if(t(u[0]))return 1-e.centralF.cdf(u[0],u[1],u[2]);var s=e.anovafscore(u);for(r=u.length-1,i=0,a=0;a<u.length;a++)i+=u[a].length;return o=i-r-1,1-e.centralF.cdf(s,r,o)},ftest:function(r,n,t){return 1-e.centralF.cdf(r,n,t)}}),e.extend(e.fn,{anovafscore:function(){return e.anovafscore(this.toArray())},anovaftes:function(){var r,n=0;for(r=0;r<this.length;r++)n+=this[r].length;return e.ftest(this.anovafscore(),this.length-1,n-this.length)}}),e.extend({qscore:function(){var o,i,a,u,s,c=n.call(arguments);return t(c[0])?(o=c[0],i=c[1],a=c[2],u=c[3],s=c[4]):(o=e.mean(c[0]),i=e.mean(c[1]),a=c[0].length,u=c[1].length,s=c[2]),r.abs(o-i)/(s*r.sqrt((1/a+1/u)/2))},qtest:function(){var r,t=n.call(arguments);3===t.length?(r=t[0],t=t.slice(1)):7===t.length?(r=e.qscore(t[0],t[1],t[2],t[3],t[4]),t=t.slice(5)):(r=e.qscore(t[0],t[1],t[2]),t=t.slice(3));var o=t[0],i=t[1];return 1-e.tukey.cdf(r,i,o-i)},tukeyhsd:function(r){for(var n=e.pooledstdev(r),t=r.map((function(r){return e.mean(r)})),o=r.reduce((function(e,r){return e+r.length}),0),i=[],a=0;a<r.length;++a)for(var u=a+1;u<r.length;++u){var s=e.qtest(t[a],t[u],r[a].length,r[u].length,n,o,r.length);i.push([[a,u],s])}return i}}),e.extend({normalci:function(){var t,o=n.call(arguments),i=new Array(2);return t=4===o.length?r.abs(e.normal.inv(o[1]/2,0,1)*o[2]/r.sqrt(o[3])):r.abs(e.normal.inv(o[1]/2,0,1)*e.stdev(o[2])/r.sqrt(o[2].length)),i[0]=o[0]-t,i[1]=o[0]+t,i},tci:function(){var t,o=n.call(arguments),i=new Array(2);return t=4===o.length?r.abs(e.studentt.inv(o[1]/2,o[3]-1)*o[2]/r.sqrt(o[3])):r.abs(e.studentt.inv(o[1]/2,o[2].length-1)*e.stdev(o[2],!0)/r.sqrt(o[2].length)),i[0]=o[0]-t,i[1]=o[0]+t,i},significant:function(e,r){return e<r}}),e.extend(e.fn,{normalci:function(r,n){return e.normalci(r,n,this.toArray())},tci:function(r,n){return e.tci(r,n,this.toArray())}}),e.extend(e.fn,{oneSidedDifferenceOfProportions:function(r,n,t,o){var a=i(r,n,t,o);return e.ztest(a,1)},twoSidedDifferenceOfProportions:function(r,n,t,o){var a=i(r,n,t,o);return e.ztest(a,2)}})}(r,Math),r.models=function(){function e(e,n){var t=e.length,o=n[0].length-1,i=t-o-1,a=r.lstsq(n,e),u=r.multiply(n,a.map((function(e){return[e]}))).map((function(e){return e[0]})),s=r.subtract(e,u),c=r.mean(e),l=r.sum(u.map((function(e){return Math.pow(e-c,2)}))),f=r.sum(e.map((function(e,r){return Math.pow(e-u[r],2)}))),m=l+f;return{exog:n,endog:e,nobs:t,df_model:o,df_resid:i,coef:a,predict:u,resid:s,ybar:c,SST:m,SSE:l,SSR:f,R2:l/m}}function n(n){var t,o,i=(t=n.exog,o=t[0].length,r.arange(o).map((function(n){var i=r.arange(o).filter((function(e){return e!==n}));return e(r.col(t,n).map((function(e){return e[0]})),r.col(t,i))}))),a=Math.sqrt(n.SSR/n.df_resid),u=i.map((function(e){var r=e.SST,n=e.R2;return a/Math.sqrt(r*(1-n))})),s=n.coef.map((function(e,r){return(e-0)/u[r]})),c=s.map((function(e){var t=r.studentt.cdf(e,n.df_resid);return 2*(t>.5?1-t:t)})),l=r.studentt.inv(.975,n.df_resid),f=n.coef.map((function(e,r){var n=l*u[r];return[e-n,e+n]}));return{se:u,t:s,p:c,sigmaHat:a,interval95:f}}return{ols:function(t,o){var i=e(t,o),a=n(i),u=function(e){var n,t,o,i=e.R2/e.df_model/((1-e.R2)/e.df_resid);return{F_statistic:i,pvalue:1-(n=i,t=e.df_model,o=e.df_resid,r.beta.cdf(n/(o/t+n),t/2,o/2))}}(i),s=1-(1-i.R2)*((i.nobs-1)/i.df_resid);return i.t=a,i.f=u,i.adjust_R2=s,i}}}(),r.extend({buildxmatrix:function(){for(var e=new Array(arguments.length),n=0;n<arguments.length;n++)e[n]=[1].concat(arguments[n]);return r(e)},builddxmatrix:function(){for(var e=new Array(arguments[0].length),n=0;n<arguments[0].length;n++)e[n]=[1].concat(arguments[0][n]);return r(e)},buildjxmatrix:function(e){for(var n=new Array(e.length),t=0;t<e.length;t++)n[t]=e[t];return r.builddxmatrix(n)},buildymatrix:function(e){return r(e).transpose()},buildjymatrix:function(e){return e.transpose()},matrixmult:function(e,n){var t,o,i,a,u;if(e.cols()==n.rows()){if(n.rows()>1){for(a=[],t=0;t<e.rows();t++)for(a[t]=[],o=0;o<n.cols();o++){for(u=0,i=0;i<e.cols();i++)u+=e.toArray()[t][i]*n.toArray()[i][o];a[t][o]=u}return r(a)}for(a=[],t=0;t<e.rows();t++)for(a[t]=[],o=0;o<n.cols();o++){for(u=0,i=0;i<e.cols();i++)u+=e.toArray()[t][i]*n.toArray()[o];a[t][o]=u}return r(a)}},regress:function(e,n){var t=r.xtranspxinv(e),o=e.transpose(),i=r.matrixmult(r(t),o);return r.matrixmult(i,n)},regresst:function(e,n,t){var o=r.regress(e,n),i={anova:{}},a=r.jMatYBar(e,o);i.yBar=a;var u=n.mean();i.anova.residuals=r.residuals(n,a),i.anova.ssr=r.ssr(a,u),i.anova.msr=i.anova.ssr/(e[0].length-1),i.anova.sse=r.sse(n,a),i.anova.mse=i.anova.sse/(n.length-(e[0].length-1)-1),i.anova.sst=r.sst(n,u),i.anova.mst=i.anova.sst/(n.length-1),i.anova.r2=1-i.anova.sse/i.anova.sst,i.anova.r2<0&&(i.anova.r2=0),i.anova.fratio=i.anova.msr/i.anova.mse,i.anova.pvalue=r.anovaftest(i.anova.fratio,e[0].length-1,n.length-(e[0].length-1)-1),i.anova.rmse=Math.sqrt(i.anova.mse),i.anova.r2adj=1-i.anova.mse/i.anova.mst,i.anova.r2adj<0&&(i.anova.r2adj=0),i.stats=new Array(e[0].length);for(var s,c,l,f=r.xtranspxinv(e),m=0;m<o.length;m++)s=Math.sqrt(i.anova.mse*Math.abs(f[m][m])),c=Math.abs(o[m]/s),l=r.ttest(c,n.length-e[0].length-1,t),i.stats[m]=[o[m],s,c,l];return i.regress=o,i},xtranspx:function(e){return r.matrixmult(e.transpose(),e)},xtranspxinv:function(e){var n=r.matrixmult(e.transpose(),e);return r.inv(n)},jMatYBar:function(e,n){var t=r.matrixmult(e,n);return new r(t)},residuals:function(e,n){return r.matrixsubtract(e,n)},ssr:function(e,r){for(var n=0,t=0;t<e.length;t++)n+=Math.pow(e[t]-r,2);return n},sse:function(e,r){for(var n=0,t=0;t<e.length;t++)n+=Math.pow(e[t]-r[t],2);return n},sst:function(e,r){for(var n=0,t=0;t<e.length;t++)n+=Math.pow(e[t]-r,2);return n},matrixsubtract:function(e,n){for(var t=new Array(e.length),o=0;o<e.length;o++){t[o]=new Array(e[o].length);for(var i=0;i<e[o].length;i++)t[o][i]=e[o][i]-n[o][i]}return r(t)}}),r.jStat=r,r)},184:(e,r,n)=>{"use strict";n.d(r,{$:()=>a});var t=n(976),o=n(870),i=n(874);class a extends t.JsViewer{constructor(e){super(),this.canvas=o.canvas(),this.gridCellStyle=t.GridCellStyle.create(),this.renderer=e,this.root.append(this.canvas),this.canvas.style.width="100%",this.canvas.style.height="100%",o.tools.handleResize(this.canvas,((e,r)=>{this.canvas.width=e,this.canvas.height=r,this.render()}));const r=e=>r=>{this.gridCell&&e(this.gridCell,r)};this.canvas.onmousemove=r(this.renderer.onMouseMove),this.canvas.onmouseenter=r(this.renderer.onMouseEnter),this.canvas.onmouseleave=r(this.renderer.onMouseLeave)}static fromGridCell(e){const r=new a(new i.cv);return r.gridCell=e,r.render(),r}render(){if(!this.gridCell)return;const e=this.canvas.getContext("2d");e.clearRect(0,0,this.canvas.width,this.canvas.height),this.renderer.renderInternal(e,0,0,this.canvas.width,this.canvas.height,this.gridCell.dart,this.gridCellStyle)}}},638:(e,r,n)=>{"use strict";n.d(r,{d:()=>t});class t{}t.CELL_DEFAULT_WIDTH=230,t.CELL_DEFAULT_HEIGHT=160,t.TAG_FIT_CHART_FORMAT=".fitChartFormat",t.TAG_FIT_CHART_FORMAT_3DX="3dx",t.MIN_CELL_RENDERER_PX_WIDTH=20,t.MIN_CELL_RENDERER_PX_HEIGHT=10,t.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH=70,t.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT=45,t.OUTLIER_PX_SIZE=12,t.POINT_PX_SIZE=4,t.OUTLIER_HITBOX_RADIUS=2,t.MIN_AXES_CELL_PX_WIDTH=100,t.MIN_AXES_CELL_PX_HEIGHT=55,t.MIN_TITLE_PX_WIDTH=275,t.MIN_TITLE_PX_HEIGHT=225,t.MIN_X_AXIS_NAME_VISIBILITY_PX_WIDTH=180,t.MIN_Y_AXIS_NAME_VISIBILITY_PX_HEIGHT=140,t.MIN_LEGEND_PX_WIDTH=325,t.MIN_LEGEND_PX_HEIGHT=275,t.MIN_DROPLINES_VISIBILITY_PX_WIDTH=120,t.MIN_DROPLINES_VISIBILITY_PX_HEIGHT=110,t.AXES_LEFT_PX_MARGIN=38,t.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS=45,t.AXES_TOP_PX_MARGIN=5,t.AXES_TOP_PX_MARGIN_WITH_TITLE=25,t.AXES_RIGHT_PX_MARGIN=18,t.AXES_BOTTOM_PX_MARGIN=15,t.AXES_BOTTOM_PX_MARGIN_WITH_AXES_LABELS=30,t.X_AXIS_LABEL_BOTTOM_PX_MARGIN=4,t.CANDLESTICK_BORDER_PX_SIZE=4,t.CANDLESTICK_MEDIAN_PX_SIZE=3.5,t.CANDLESTICK_OUTLIER_PX_SIZE=6,t.INFLATE_SIZE=-6,t.LEGEND_TOP_PX_MARGIN=10,t.LEGEND_RECORD_PX_HEIGHT=18,t.LEGEND_RECORD_LINE_PX_WIDTH=20,t.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN=5,t.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN=4,t.LINE_STYLES={solid:[],dotted:[1,1],dashed:[5,5],dashdotted:[5,5,2,5]},t.CONDITION_MAP={"No series to show":e=>void 0===e||0===(null==e?void 0:e.length),"There were series with no points":e=>e.some((e=>{var r;return 0===(null===(r=e.points)||void 0===r?void 0:r.length)})),"There were series with all x zeroes":e=>e.some((e=>{var r;return null===(r=e.points)||void 0===r?void 0:r.every((e=>0===e.x))})),"There were series with all y zeroes":e=>e.some((e=>{var r;return null===(r=e.points)||void 0===r?void 0:r.every((e=>0===e.y))}))}},840:(e,r,n)=>{"use strict";n.d(r,{DI:()=>a}),n(976);var t=n(469),o=n(363),i=(n(875),n(414),function(e,r,n,t){return new(n||(n=Promise))((function(o,i){function a(e){try{s(t.next(e))}catch(e){i(e)}}function u(e){try{s(t.throw(e))}catch(e){i(e)}}function s(e){var r;e.done?o(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(a,u)}s((t=t.apply(e,r||[])).next())}))});function a(){return i(this,void 0,void 0,(function*(){t.shell.windows.showContextPanel=!0;const e=yield t.data.loadTable(`${o._package.webRoot}files/curves-demo.csv`);t.shell.addTableView(e)}))}},188:(e,r,n)=>{"use strict";n.d(r,{No:()=>v,Z:()=>x,hS:()=>g});var t=n(976),o=n(870),i=n(416),a=n(875),u=n(874),s=n(184),c=n(711),l=n(638),f=function(e,r,n,t){return new(n||(n=Promise))((function(o,i){function a(e){try{s(t.next(e))}catch(e){i(e)}}function u(e){try{s(t.throw(e))}catch(e){i(e)}}function s(e){var r;e.done?o(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(a,u)}s((t=t.apply(e,r||[])).next())}))};const m="chartOptions",h="seriesOptions";var d;!function(e){e.DATAFRAME="Dataframe",e.COLUMN="Column",e.CELL="Cell"}(d||(d={}));const p={count:"totalCount",nulls:"missingValueCount",unique:"uniqueCount",values:"valueCount",min:"min",max:"max",sum:"sum",avg:"avg",stdev:"stdev",variance:"variance",skew:"skew",kurt:"kurt",med:"med",q1:"q1",q2:"q2",q3:"q3"};function g(e,r){const n=(0,i.Y6)(e);return e.parameters?r.logX&&e.parameters[2]>0&&(e.parameters[2]=Math.log10(e.parameters[2])):e.parameters=(0,i.PK)(e,n,r).parameters,(0,i.tq)(e,n,r)}function v(e,r){var n,o,i;const a={logX:null===(n=e.chartOptions)||void 0===n?void 0:n.logX,logY:null===(o=e.chartOptions)||void 0===o?void 0:o.logY},u=[],s=[],c=[],l=[],f=[],m=[],h=[];for(let r=0,n=0;r<(null===(i=e.series)||void 0===i?void 0:i.length);r++){if(e.series[r].points.every((e=>e.outlier)))continue;const t=g(e.series[r],a);u[n]=t.rSquared,s[n]=t.auc,c[n]=t.interceptX,l[n]=t.interceptY,f[n]=t.slope,m[n]=t.top,h[n]=t.bottom,n++}return{rSquared:t.Stats.fromValues(u)[p[r]],auc:t.Stats.fromValues(s)[p[r]],interceptX:t.Stats.fromValues(c)[p[r]],interceptY:t.Stats.fromValues(l)[p[r]],slope:t.Stats.fromValues(f)[p[r]],top:t.Stats.fromValues(m)[p[r]],bottom:t.Stats.fromValues(h)[p[r]]}}function y(e){for(let r=0;r<e.length;r++){const n=e.get(r);if(""===n)continue;const t=(0,c.f)(n);e.set(r,JSON.stringify(t))}e.setTag(l.d.TAG_FIT_CHART_FORMAT,"")}function _(e,r,n,t){var o;void 0===e.cell.column.temp[`${m}-custom-title`]&&function(e){var r,n;const t=e.columns.bySemTypeAll(a.j2);for(let e=0;e<t.length;e++){a.kW.map((r=>{t[e].temp[`${m}-custom-${r.name}`]=!1})),a.K0.map((r=>{t[e].temp[`${h}-custom-${r.name}`]=!1})),t[e].getTag(l.d.TAG_FIT_CHART_FORMAT)===l.d.TAG_FIT_CHART_FORMAT_3DX&&y(t[e]);for(let o=0;o<t[e].length;o++){if(""===t[e].get(o))continue;const i=null!==(n=JSON.parse(null!==(r=t[e].get(o))&&void 0!==r?r:"{}"))&&void 0!==n?n:{};a.kW.map((r=>{i.chartOptions&&void 0!==i.chartOptions[r.name]&&(t[e].temp[`${m}-custom-${r.name}`]=!0)})),a.K0.map((r=>{if(i.series)for(const n of i.series)void 0!==n[r.name]&&(t[e].temp[`${h}-custom-${r.name}`]=!0)}))}}}(e.cell.dataFrame);const u=r.property.name,s=t===d.DATAFRAME?(0,i.jG)(e.cell.dataFrame):(0,i.hq)(e.cell.column);if(n===m?s.chartOptions[u]=r.value:n===h&&(s.seriesOptions[u]=r.value),t===d.CELL){const t=e.cell.value;if(""===t)return;const i=null!==(o=JSON.parse(null!=t?t:"{}"))&&void 0!==o?o:{};!function(e,r,n){const t=r.property.name;if(n===m){if(void 0===e.chartOptions)return;e.chartOptions[t]=r.value}else if(n===h){if(void 0===e.series)return;for(let n=0;n<e.series.length;n++)e.series[n][t]=r.value}}(i,r,n),e.cell.value=JSON.stringify(i)}else{let r;t===d.DATAFRAME?(e.cell.dataFrame.tags[a.Kp]=JSON.stringify(s),r=e.cell.dataFrame.columns.bySemTypeAll(a.j2)):(e.cell.column.tags[a.Kp]=JSON.stringify(s),r=[e.cell.column]);for(let e=0;e<r.length;e++){if(t===d.DATAFRAME){const t=(0,i.hq)(r[e]);n===m?delete t.chartOptions[u]:delete t.seriesOptions[u],r[e].tags[a.Kp]=JSON.stringify(t)}!1!==r[e].temp[`${n}-custom-${u}`]&&(r[e].init((t=>{var o,i;const a=r[e].get(t);if(""===a)return a;const s=null!==(i=JSON.parse(null!==(o=r[e].get(t))&&void 0!==o?o:"{}"))&&void 0!==i?i:{};if(n===m){if(void 0===s.chartOptions)return a;if(void 0===s.chartOptions[u])return a;delete s.chartOptions[u]}else{if(void 0===s.series)return a;let e=!1;for(const r of s.series)void 0!==r[u]&&(delete r[u],e=!0);if(s.seriesOptions&&delete s.seriesOptions[u],!e)return a}return JSON.stringify(s)})),r[e].temp[`${n}-custom-${u}`]=!1)}}e.grid.invalidate()}class x extends t.ObjectHandler{get type(){return"GridCell"}isApplicable(e){return e instanceof t.GridCell&&e.cellType===a.d8}renderProperties(e,r=null){var n,c,l,d,p,y,x,w,T,b,A;const I=o.accordion("Curves property panel"),E=t.Property.js("level",t.TYPE.STRING,{description:"Controls the level at which properties will be switched",defaultValue:"Column",choices:["Dataframe","Column","Cell"],nullable:!1}),S=o.input.forProperty(E);o.tooltip.bind(S.captionLabel,"Controls the level at which properties will be switched");const M=(0,u.W$)(e),N=(0,i.hq)(e.cell.column),C=(0,i.jG)(e.cell.dataFrame),P={onValueChanged:r=>_(e,r,h,S.value)},O={onValueChanged:r=>_(e,r,m,S.value)};(0,u.fi)(null===(n=C.seriesOptions)||void 0===n?void 0:n.pointColor)||(0,u.fi)(null===(c=N.seriesOptions)||void 0===c?void 0:c.pointColor)||(M.seriesOptions?(0,u.fi)(M.seriesOptions.pointColor)||(M.seriesOptions.pointColor=t.Color.toHtml(t.Color.getCategoricalColor(0))):(0,u.fi)(M.series?M.series[0].pointColor:"")||(M.series[0].pointColor=t.Color.toHtml(t.Color.getCategoricalColor(0)))),(0,u.fi)(null===(l=C.seriesOptions)||void 0===l?void 0:l.fitLineColor)||(0,u.fi)(null===(d=N.seriesOptions)||void 0===d?void 0:d.fitLineColor)||(M.seriesOptions?(0,u.fi)(M.seriesOptions.fitLineColor)||(M.seriesOptions.fitLineColor=t.Color.toHtml(t.Color.getCategoricalColor(0))):(0,u.fi)(M.series?M.series[0].fitLineColor:"")||(M.series[0].fitLineColor=t.Color.toHtml(t.Color.getCategoricalColor(0)))),(0,u.fi)(null===(p=C.seriesOptions)||void 0===p?void 0:p.outlierColor)||(0,u.fi)(null===(y=N.seriesOptions)||void 0===y?void 0:y.outlierColor)||(M.seriesOptions?(0,u.fi)(M.seriesOptions.outlierColor)||(M.seriesOptions.outlierColor=t.Color.toHtml(t.Color.red)):(0,u.fi)(M.series?M.series[0].outlierColor:"")||(M.series[0].outlierColor=t.Color.toHtml(t.Color.red))),(0,u.BI)(a.K0,N.seriesOptions,M.seriesOptions?M.seriesOptions:M.series&&null!==(x=M.series[0])&&void 0!==x?x:{}),(0,u.BI)(a.K0,C.seriesOptions,M.seriesOptions?M.seriesOptions:M.series&&null!==(w=M.series[0])&&void 0!==w?w:{}),(0,u.BI)(a.kW,N.chartOptions,M.chartOptions?M.chartOptions:{}),(0,u.BI)(a.kW,C.chartOptions,M.chartOptions?M.chartOptions:{}),(null===(T=M.chartOptions)||void 0===T?void 0:T.allowXZeroes)&&(null===(b=M.chartOptions)||void 0===b?void 0:b.logX)&&(null===(A=M.series)||void 0===A?void 0:A.some((e=>e.points.some((e=>0===e.x)))))&&(0,u.kb)(M);const L=o.form([S]),X=a.K0.map((e=>o.input.forProperty(e,M.seriesOptions?M.seriesOptions:M.series[0],P)));o.forms.addGroup(L,"Series options",X),o.forms.addGroup(L,"Chart options",a.kW.map((e=>o.input.forProperty(e,M.chartOptions,O)))),I.addPane("Options",(()=>L));const R=t.Property.js("series",t.TYPE.STRING,{description:"Controls whether to show series statistics or aggregated statistics",defaultValue:"All",choices:["all","aggregated"],nullable:!1}),k=o.input.forProperty(R,null,{onValueChanged(e){I.getPane("Fit").root.lastElementChild.replaceChildren(G())}}),F=t.Property.js("aggregation type",t.TYPE.STRING,{description:"Controls which aggregation to use on the series statistics",defaultValue:"med",choices:Object.values(t.STATS),nullable:!1}),D=o.input.forProperty(F,null,{onValueChanged(e){I.getPane("Fit").root.lastElementChild.replaceChildren(G())}});function G(){var r,n,u;const s=o.divV("aggregated"===k.stringValue?[k.root,D.root]:[k.root]),c=(0,i.dU)(M);if(c.x<=0&&M.chartOptions&&(M.chartOptions.logX=!1),c.y<=0&&M.chartOptions&&(M.chartOptions.logY=!1),"all"===k.stringValue){const i={logX:null===(r=M.chartOptions)||void 0===r?void 0:r.logX,logY:null===(n=M.chartOptions)||void 0===n?void 0:n.logY};for(let r=0;r<M.series.length;r++){const n=M.series[r],c=g(n,i),l=n.fitLineColor&&t.Color.fromHtml(n.fitLineColor)?n.fitLineColor:t.Color.toHtml(t.Color.getCategoricalColor(r));s.appendChild(o.panel([o.h1(null!==(u=n.name)&&void 0!==u?u:"series "+r,{style:{color:l}}),o.input.form(c,a.sw,{onCreated:i=>i.root.appendChild(o.iconFA("plus",(()=>f(this,void 0,void 0,(function*(){const o={df:e.cell.dataFrame,colName:e.gridColumn.name,propName:i.property.name,seriesName:n.name,seriesNumber:r};yield t.Func.find({name:"addStatisticsColumn"})[0].prepare(o).call(void 0,void 0,{processed:!1})}))),`Calculate ${i.property.name} for the whole column`))})]))}}else{const r=v(M,D.stringValue);s.appendChild(o.panel([o.h1(`series ${D.stringValue}`),o.input.form(r,a.sw,{onCreated:r=>r.root.appendChild(o.iconFA("plus",(()=>f(this,void 0,void 0,(function*(){const n={df:e.cell.dataFrame,colName:e.gridColumn.name,propName:r.property.name,aggrType:D.stringValue};yield t.Func.find({name:"addAggrStatisticsColumn"})[0].prepare(n).call(void 0,void 0,{processed:!1})}))),`Calculate ${r.property.name} ${D.stringValue} for the whole column`))})]))}return s}return I.addPane("Fit",(()=>G())),I.addPane("Chart",(()=>s.$.fromGridCell(e).root)),I.root}}},711:(e,r,n)=>{"use strict";n.d(r,{f:()=>c});var t=n(976),o=n(875);const i={x:"xAxis",y:"yAxis"},a={min:"min",max:"max"};function u(e){var r,n,i;const a=null===(n=null===(r=e.getElementsByTagName("params")[0])||void 0===r?void 0:r.childNodes[0].nodeValue)||void 0===n?void 0:n.split(",").map(Number);let u=null===(i=e.getElementsByTagName("function")[0])||void 0===i?void 0:i.getAttribute("type");u=u&&"sigif"!==u?u:o.yB;const s=e.getElementsByTagName("settings")[0].getAttribute("markerColor"),c=e.getElementsByTagName("settings")[0].getAttribute("color"),l=!!e.getElementsByTagName("settings")[0].getAttribute("drawLine"),f={name:e.getAttribute("name"),fitFunction:u,markerType:t.MARKER_TYPE.CIRCLE,pointColor:s,fitLineColor:c,showFitLine:l,showPoints:"points",showCurveConfidenceInterval:!1,clickToToggle:!1};return a&&(f.parameters=[a[2],a[1],a[0],a[3]]),f}function s(e){const r=function(e){var r,n,t;const o=null===(r=e.getElementsByTagName("x")[0].childNodes[0].nodeValue)||void 0===r?void 0:r.split(","),i=null===(n=e.getElementsByTagName("y")[0].childNodes[0].nodeValue)||void 0===n?void 0:n.split(","),a=null===(t=e.getElementsByTagName("mask")[0].childNodes[0].nodeValue)||void 0===t?void 0:t.split(""),u=[];for(let e=0;e<o.length;e++)u[e]={x:+o[e],y:+i[e],outlier:!Boolean(a[e])};return u}(e),n=u(e),t={points:r};return Object.assign(t,n),t}function c(e){const r=(new DOMParser).parseFromString(e,"text/xml"),n=r.getElementsByTagName("grid")[0],t=(c=r.getElementsByTagName("settings")[0],{minX:+(o=n).getElementsByTagName(i.x)[0].getAttribute(a.min),minY:+o.getElementsByTagName(i.y)[0].getAttribute(a.min),maxX:+o.getElementsByTagName(i.x)[0].getAttribute(a.max),maxY:+o.getElementsByTagName(i.y)[0].getAttribute(a.max),xAxisName:c.getAttribute("xLabel"),yAxisName:c.getAttribute("yLabel"),logX:!!c.getAttribute("logX")});var o,c;const l=r.getElementsByTagName("seriesCollection")[0],f=u(l.getElementsByTagName("series")[0]),m=function(e){const r=[],n=e.getElementsByTagName("series").length;for(let t=0;t<n;t++){const n=e.getElementsByTagName("series")[t];r[t]=s(n)}return r}(l);return{chartOptions:t,seriesOptions:f,series:m}}},874:(e,r,n)=>{"use strict";n.d(r,{cv:()=>k,W$:()=>O,fi:()=>X,l$:()=>C,BI:()=>N,Qp:()=>P,kb:()=>R});var t=n(976),o=n(469),i=n(870),a=n(875),u=n(766),s=n(416),c=n(711),l=n(184),f=n(188),m=n(638),h=n(111);const d=window,p=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2});class g{static getUniqueName(e,r,n){return d.grok_Utils_GetUniqueName(e,r,null==n?void 0:n.auto,null==n?void 0:n.idx,null==n?void 0:n.render,null==n?void 0:n.choices)}static isEmpty(e){return null==e||""==e}static formatNumber(e){return p.format(e)}}function v(e,r){const n=e.pointColor&&t.Color.fromHtml(e.pointColor)?e.pointColor:t.Color.toHtml(t.Color.getCategoricalColor(r)),o=e.outlierColor&&t.Color.fromHtml(e.outlierColor)?e.outlierColor:t.Color.toHtml(t.Color.red),i=e.fitLineColor&&t.Color.fromHtml(e.fitLineColor)?e.fitLineColor:t.Color.toHtml(t.Color.getCategoricalColor(r));e.pointColor=n,e.outlierColor=o,e.fitLineColor=i}function y(e,r,n){var t;if(null!==(t=r.connectDots)&&void 0!==t&&t){e.strokeStyle=r.pointColor,e.lineWidth=2*n.ratio,e.beginPath();for(let t=0;t<r.points.length;t++){const o=r.points[t].x,i=r.points[t].y,a=n.viewport.xToScreen(o),u=n.viewport.yToScreen(i);0===t?e.moveTo(a,u):e.lineTo(a,u)}e.stroke()}}function _(e,r,n){var o;(null===(o=r.showPoints)||void 0===o||o)&&(e.strokeStyle=r.pointColor,r.connectDots&&""!==r.showPoints||"points"===r.showPoints?function(e,r,n){for(let o=0;o<r.points.length;o++){const i=r.points[o],a=r.connectDots?r.pointColor:i.outlier?i.outlierColor&&t.Color.fromHtml(i.outlierColor)?i.outlierColor:r.outlierColor:i.color&&t.Color.fromHtml(i.color)?i.color:r.pointColor,u=i.marker?i.marker:r.markerType,s=r.connectDots?m.d.POINT_PX_SIZE*n.ratio:i.outlier?m.d.OUTLIER_PX_SIZE*n.ratio:i.size?i.size:m.d.POINT_PX_SIZE*n.ratio;t.Paint.marker(e,r.connectDots?u:i.outlier?t.MARKER_TYPE.OUTLIER:u,n.viewport.xToScreen(i.x),n.viewport.yToScreen(i.y),a,s),i.stdev&&!i.outlier&&(e.strokeStyle=a,e.beginPath(),e.moveTo(n.viewport.xToScreen(i.x),n.viewport.yToScreen(i.y+i.stdev)),e.lineTo(n.viewport.xToScreen(i.x),n.viewport.yToScreen(i.y-i.stdev)),e.stroke())}}(e,r,n):["candlesticks","both"].includes(r.showPoints)&&function(e,r,n){for(let o=0,i=null;o<r.points.length;o++){const a=r.points[o];if(a.outlier)continue;const u=o+1<r.points.length&&r.points[o+1].x===a.x;if(!i&&u)i=o;else if(null!==i&&!u){const u=[];for(let e=i,n=0;e<=o;e++,n++)u[n]=r.points[e].y;const s=(0,h.G)(u);if(e.beginPath(),x(e,{viewport:n.viewport,ratio:n.ratio,x:a.x,boxPlotStats:s,color:r.pointColor}),e.stroke(),"both"===r.showPoints)for(let o=0;o<u.length;o++)(u[o]<s.lowerAdjacentValue||u[o]>s.upperAdjacentValue)&&t.Paint.marker(e,t.MARKER_TYPE.OUTLIER,n.viewport.xToScreen(a.x),n.viewport.yToScreen(u[o]),r.pointColor,m.d.CANDLESTICK_OUTLIER_PX_SIZE*n.ratio);i=null}}}(e,r,n))}function x(e,r){w(e,r.x,r.boxPlotStats.lowerAdjacentValue,r.viewport),e.moveTo(r.viewport.xToScreen(r.x),r.viewport.yToScreen(r.boxPlotStats.lowerAdjacentValue)),e.lineTo(r.viewport.xToScreen(r.x),r.viewport.yToScreen(r.boxPlotStats.upperAdjacentValue)),w(e,r.x,r.boxPlotStats.upperAdjacentValue,r.viewport),t.Paint.marker(e,t.MARKER_TYPE.CIRCLE,r.viewport.xToScreen(r.x),r.viewport.yToScreen(r.boxPlotStats.q2),r.color,m.d.CANDLESTICK_MEDIAN_PX_SIZE*r.ratio)}function w(e,r,n,t){e.moveTo(t.xToScreen(r)-m.d.CANDLESTICK_BORDER_PX_SIZE/2,t.yToScreen(n)),e.lineTo(t.xToScreen(r)+m.d.CANDLESTICK_BORDER_PX_SIZE/2,t.yToScreen(n))}function T(e,r,n){var t;if(null===(t=r.showFitLine)||void 0===t||t){e.save(),e.strokeStyle=r.fitLineColor,e.lineWidth=2*n.ratio,e.beginPath(),r.lineStyle&&e.setLineDash(m.d.LINE_STYLES[r.lineStyle]);const t=n.showAxes?n.showAxesLabels?m.d.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:m.d.AXES_LEFT_PX_MARGIN:0,o=n.showAxes?m.d.AXES_RIGHT_PX_MARGIN:0;for(let r=t;r<=n.screenBounds.width-o;r++){const o=n.screenBounds.x+r,i=n.logOptions.logX?Math.log10(n.viewport.xToWorld(o)):n.viewport.xToWorld(o),a=n.logOptions.logY?n.viewport.yToScreen(Math.pow(10,n.curveFunc(i))):n.viewport.yToScreen(n.curveFunc(i));r===t?e.moveTo(o,a):e.lineTo(o,a)}e.stroke(),e.restore()}}function b(e,r,n){var t,o,i,u;if((null===(t=r.showFitLine)||void 0===t||t)&&null!==(o=r.showCurveConfidenceInterval)&&void 0!==o&&o){e.strokeStyle=null!==(i=r.confidenceIntervalColor)&&void 0!==i?i:a.Qc,e.fillStyle=null!==(u=r.confidenceIntervalColor)&&void 0!==u?u:a.XD;const t=(0,s.LC)(r,n.fitFunc,n.userParamsFlag,n.logOptions);A(e,{viewport:n.viewport,logOptions:n.logOptions,showAxes:n.showAxes,showAxesLabels:n.showAxesLabels,screenBounds:n.screenBounds,confidenceIntervals:t,confidenceType:a.vK.TOP}),A(e,{viewport:n.viewport,logOptions:n.logOptions,showAxes:n.showAxes,showAxesLabels:n.showAxesLabels,screenBounds:n.screenBounds,confidenceIntervals:t,confidenceType:a.vK.BOTTOM}),function(e,r){e.beginPath();const n=r.showAxes?r.showAxesLabels?m.d.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:m.d.AXES_LEFT_PX_MARGIN:0,t=r.showAxes?m.d.AXES_RIGHT_PX_MARGIN:0;for(let o=n;o<=r.screenBounds.width-t;o++){const t=r.screenBounds.x+o,i=r.logOptions.logX?Math.log10(r.viewport.xToWorld(t)):r.viewport.xToWorld(t),a=r.logOptions.logY?r.viewport.yToScreen(Math.pow(10,r.confidenceIntervals.confidenceTop(i))):r.viewport.yToScreen(r.confidenceIntervals.confidenceTop(i));o===n?e.moveTo(t,a):e.lineTo(t,a)}for(let o=r.screenBounds.width-t;o>=n;o--){const n=r.screenBounds.x+o,t=r.logOptions.logX?Math.log10(r.viewport.xToWorld(n)):r.viewport.xToWorld(n),i=r.logOptions.logY?r.viewport.yToScreen(Math.pow(10,r.confidenceIntervals.confidenceBottom(t))):r.viewport.yToScreen(r.confidenceIntervals.confidenceBottom(t));e.lineTo(n,i)}e.closePath(),e.fill()}(e,{viewport:n.viewport,logOptions:n.logOptions,showAxes:n.showAxes,showAxesLabels:n.showAxesLabels,screenBounds:n.screenBounds,confidenceIntervals:t})}}function A(e,r){e.beginPath();const n=r.showAxes?r.showAxesLabels?m.d.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:m.d.AXES_LEFT_PX_MARGIN:0,t=r.showAxes?m.d.AXES_RIGHT_PX_MARGIN:0,o=r.confidenceType===a.vK.TOP?r.confidenceIntervals.confidenceTop:r.confidenceIntervals.confidenceBottom;for(let i=n;i<=r.screenBounds.width-t;i++){const t=r.screenBounds.x+i,a=r.logOptions.logX?Math.log10(r.viewport.xToWorld(t)):r.viewport.xToWorld(t),u=r.logOptions.logY?r.viewport.yToScreen(Math.pow(10,o(a))):r.viewport.yToScreen(o(a));i===n?e.moveTo(t,u):e.lineTo(t,u)}e.stroke()}function I(e,r,n){var t;if((null===(t=r.showFitLine)||void 0===t||t)&&r.droplines&&n.showDroplines){e.save(),e.strokeStyle="blue",e.lineWidth=n.ratio,e.beginPath(),e.setLineDash([5,5]);for(let t=0;t<r.droplines.length;t++)"IC50"===r.droplines[t]&&E(e,{viewport:n.viewport,xValue:r.parameters[2],dataBounds:n.dataBounds,curveFunc:n.curveFunc,logOptions:n.logOptions});e.stroke(),e.restore()}}function E(e,r){r.logOptions.logX&&(r.xValue=Math.pow(10,r.xValue));const n=r.logOptions.logX?Math.log10(r.xValue):r.xValue,t=r.logOptions.logY?Math.pow(10,r.curveFunc(n)):r.curveFunc(n);e.moveTo(r.viewport.xToScreen(r.dataBounds.minX),r.viewport.yToScreen(t)),e.lineTo(r.viewport.xToScreen(r.xValue),r.viewport.yToScreen(t)),e.lineTo(r.viewport.xToScreen(r.xValue),r.viewport.yToScreen(r.dataBounds.minY))}function S(e,r,n){var t;if((null===(t=r.showFitLine)||void 0===t||t)&&n.statistics){const t=(0,s.tq)(r,n.fitFunc,n.logOptions);for(let o=0;o<n.statistics.length;o++){const i=n.statistics[o],u=a.sw.find((e=>e.name===i));if(u){const i=g.formatNumber(u.get(t));e.fillStyle=r.fitLineColor,e.textAlign="left",e.fillText(u.name+": "+i,n.dataBox.x+5,n.dataBox.y+20+20*o)}}}}function M(e,r){var n;t.Paint.marker(e,t.MARKER_TYPE.OUTLIER,r.midX,r.midY,t.Color.red,(n=.8*Math.min(r.width,r.height),0,30,Math.min(Math.max(n,0),30)))}function N(e,r,n){if(r&&n)for(const t of e)!(t.name in n)&&t.name in r&&(n[t.name]=r[t.name])}function C(e){if(0===e.length)return{};let r,n,t,o=Number.MAX_VALUE,i=Number.MAX_VALUE,a=Number.MIN_VALUE,u=Number.MIN_VALUE,s=!1,c=!1,l=!1;for(const f of e)null!==f.minX&&void 0!==f.minX&&(o=Math.min(o,f.minX)),null!==f.minY&&void 0!==f.minY&&(i=Math.min(i,f.minY)),null!==f.maxX&&void 0!==f.maxX&&(a=Math.max(a,f.maxX)),null!==f.maxY&&void 0!==f.maxY&&(u=Math.max(u,f.maxY)),null!==f.title&&void 0!==f.title&&(null!=t||(t=f.title)),null!==f.xAxisName&&void 0!==f.xAxisName&&(null!=r||(r=f.xAxisName)),null!==f.yAxisName&&void 0!==f.yAxisName&&(null!=n||(n=f.yAxisName)),null!==f.logX&&void 0!==f.logX&&f.logX&&(s=!0),null!==f.logY&&void 0!==f.logY&&f.logY&&(c=!0),null!==f.allowXZeroes&&void 0!==f.allowXZeroes&&f.allowXZeroes&&(l=!0);return{minX:o===Number.MAX_VALUE?void 0:o,minY:i===Number.MAX_VALUE?void 0:i,maxX:a===Number.MIN_VALUE?void 0:a,maxY:u===Number.MIN_VALUE?void 0:u,title:t,xAxisName:r,yAxisName:n,logX:s,logY:c,allowXZeroes:l}}function P(e){if(0===e.length)return null;const r={points:[],name:e[0].name,fitFunction:e[0].fitFunction,markerType:e[0].markerType,lineStyle:e[0].lineStyle,pointColor:e[0].pointColor,fitLineColor:e[0].fitLineColor,confidenceIntervalColor:e[0].confidenceIntervalColor,outlierColor:e[0].outlierColor,connectDots:e[0].connectDots,showFitLine:e[0].showFitLine,showPoints:e[0].showPoints,showCurveConfidenceInterval:e[0].showCurveConfidenceInterval,errorModel:e[0].errorModel,clickToToggle:e[0].clickToToggle,labels:e[0].labels,droplines:e[0].droplines,columnName:e[0].columnName};for(const n of e)r.points=[...r.points,...n.points];return r}function O(e){var r,n,o,i,u;let l=e.cell.value;l.includes("|")&&(l=l.replaceAll("|",""));const f=(null===(n=null===(r=e.cell)||void 0===r?void 0:r.column)||void 0===n?void 0:n.type)===t.TYPE.STRING?e.cell.column.getTag(m.d.TAG_FIT_CHART_FORMAT)===m.d.TAG_FIT_CHART_FORMAT_3DX?(0,c.f)(l):null!==(o=JSON.parse(null!=l?l:"{}"))&&void 0!==o?o:{}:(0,s.TL)(),h=e.cell.column?(0,s.hq)(e.cell.column):{},d=e.cell.column?(0,s.jG)(e.cell.dataFrame):{};null!==(i=f.series)&&void 0!==i||(f.series=[]),null!==(u=f.chartOptions)&&void 0!==u||(f.chartOptions=h.chartOptions),N(a.kW,h.chartOptions,f.chartOptions),N(a.kW,d.chartOptions,f.chartOptions);for(const e of f.series)N(a.K0,h.seriesOptions,e),N(a.K0,d.seriesOptions,e);return f}function L(e,r,n){if(e.width<m.d.MIN_AXES_CELL_PX_WIDTH||e.height<m.d.MIN_AXES_CELL_PX_HEIGHT)return[e,void 0,void 0];const t=r?m.d.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:m.d.AXES_LEFT_PX_MARGIN,o=r?m.d.AXES_BOTTOM_PX_MARGIN_WITH_AXES_LABELS:m.d.AXES_BOTTOM_PX_MARGIN,i=n?m.d.AXES_TOP_PX_MARGIN_WITH_TITLE:m.d.AXES_TOP_PX_MARGIN;return[e.cutLeft(t).cutBottom(o).cutTop(i).cutRight(m.d.AXES_RIGHT_PX_MARGIN),e.getBottom(o).getTop(i).cutLeft(t).cutRight(m.d.AXES_RIGHT_PX_MARGIN),e.getLeft(t).getRight(m.d.AXES_RIGHT_PX_MARGIN).cutBottom(o).cutTop(i)]}function X(e){return null!=e&&""!==e&&void 0!==t.Color.fromHtml(e)}function R(e){var r;for(let n=0;n<(null===(r=e.series)||void 0===r?void 0:r.length);n++){const r=e.series[n];if(r.points.every((e=>0!==e.x)))continue;let t=Number.MAX_VALUE,o=0,i=0;const a=[];for(let e=0;e<r.points.length;e++)r.points[e].x<t&&0!==r.points[e].x&&(t=r.points[e].x),r.points[e].x>o&&0!==r.points[e].x&&(o=r.points[e].x),a.includes(r.points[e].x)||(a[a.length]=r.points[e].x,i++);const u=Math.pow(10,Math.log10(t)-(Math.log10(o)-Math.log10(t)/(i-1)));for(let e=0;e<r.points.length;e++)0===r.points[e].x&&(r.points[e].x=u)}}class k extends t.GridCellRenderer{get name(){return a.d8}get cellType(){return a.d8}getDefaultSize(e){return{width:m.d.CELL_DEFAULT_WIDTH,height:m.d.CELL_DEFAULT_HEIGHT}}onClick(e,r){var n,t,a,l,h,d,p;if(!e.cell.value)return;const g=e.cell.column.getTag(m.d.TAG_FIT_CHART_FORMAT)===m.d.TAG_FIT_CHART_FORMAT_3DX?(0,c.f)(e.cell.value):O(e);for(const[e,r]of Object.entries(m.d.CONDITION_MAP))if(r(g.series))return void(o.shell.o=i.divText(e,{style:{color:"red"}}));o.shell.o=e;const v=e.bounds.inflate(m.d.INFLATE_SIZE,m.d.INFLATE_SIZE),y=L(v,this.areAxesLabelsShown(v,g),this.isTitleShown(v,g))[0],_=(0,s.dU)(g),x=new u.l(_,y,null!==(t=null===(n=g.chartOptions)||void 0===n?void 0:n.logX)&&void 0!==t&&t,null!==(l=null===(a=g.chartOptions)||void 0===a?void 0:a.logY)&&void 0!==l&&l);for(let n=0;n<(null===(h=g.series)||void 0===h?void 0:h.length);n++)if(!(g.series[n].connectDots||!g.series[n].clickToToggle||"points"!==g.series[n].showPoints||v.width<m.d.MIN_AXES_CELL_PX_WIDTH||v.height<m.d.MIN_AXES_CELL_PX_HEIGHT))for(let t=0;t<g.series[n].points.length;t++){const o=g.series[n].points[t];if(this.hitTest(r,o,x)){o.outlier=!o.outlier;const r=e.grid.dataFrame.columns.byTags({".sourceColumn":e.cell.column.name});if(r)for(const t of r){const r={logX:null===(d=g.chartOptions)||void 0===d?void 0:d.logX,logY:null===(p=g.chartOptions)||void 0===p?void 0:p.logY},o=null!==t.tags[".seriesAggregation"]?(0,f.No)(g,t.tags[".seriesAggregation"]):t.tags[".seriesNumber"]===n?(0,f.hS)(g.series[n],r):null;null!==o&&t.set(e.cell.rowIndex,o[t.tags[".statistics"]])}if(e.cell.column.getTag(m.d.TAG_FIT_CHART_FORMAT)!==m.d.TAG_FIT_CHART_FORMAT_3DX){const r=JSON.parse(e.cell.value);r.series[n].points[t].outlier=o.outlier,e.cell.value=JSON.stringify(r)}return}}}onDoubleClick(e,r){if(!e.cell.value)return;const n=l.$.fromGridCell(e),t=i.dialog({title:"Edit chart"}).add(n.root).show({resizable:!0}).root.getElementsByClassName("d4-dialog-contents dlg-edit-chart")[0].firstChild;n.canvas.width=t.clientWidth,n.canvas.height=t.clientHeight,n.render(),t.style.width="100%",t.style.height="100%",i.tools.handleResize(t,((e,r)=>{n.canvas.width=e,n.canvas.height=r,n.render()}))}areAxesShown(e){return e.width>=m.d.MIN_AXES_CELL_PX_WIDTH&&e.height>=m.d.MIN_AXES_CELL_PX_HEIGHT}areAxesLabelsShown(e,r){var n;return e.width>=m.d.MIN_X_AXIS_NAME_VISIBILITY_PX_WIDTH&&e.height>=m.d.MIN_Y_AXIS_NAME_VISIBILITY_PX_HEIGHT&&!!(null===(n=r.chartOptions)||void 0===n?void 0:n.xAxisName)&&!!r.chartOptions.yAxisName}isTitleShown(e,r){var n;return e.width>=m.d.MIN_TITLE_PX_WIDTH&&e.height>=m.d.MIN_TITLE_PX_HEIGHT&&!!(null===(n=r.chartOptions)||void 0===n?void 0:n.title)}isLegendShown(e){return e.width>=m.d.MIN_LEGEND_PX_WIDTH&&e.height>=m.d.MIN_LEGEND_PX_HEIGHT}areDroplinesShown(e){return e.width>=m.d.MIN_DROPLINES_VISIBILITY_PX_WIDTH&&e.height>=m.d.MIN_DROPLINES_VISIBILITY_PX_HEIGHT}renderCurves(e,r,n){var o,i,a,c,l,f,h,d,p,g,x,w,A,E,M;e.save(),e.beginPath(),e.rect(r.x,r.y,r.width,r.height),e.clip(),(null===(o=n.chartOptions)||void 0===o?void 0:o.allowXZeroes)&&(null===(i=n.chartOptions)||void 0===i?void 0:i.logX)&&(null===(a=n.series)||void 0===a?void 0:a.some((e=>e.points.some((e=>0===e.x)))))&&R(n);const[N,C,P]=L(r,this.areAxesLabelsShown(r,n),this.isTitleShown(r,n)),O=(0,s.dU)(n);(O.x<0&&n.chartOptions||0===O.x&&n.chartOptions&&!n.chartOptions.allowXZeroes)&&(n.chartOptions.logX=!1),O.y<=0&&n.chartOptions&&(n.chartOptions.logY=!1);const X=new u.l(O,N,null!==(l=null===(c=n.chartOptions)||void 0===c?void 0:c.logX)&&void 0!==l&&l,null!==(h=null===(f=n.chartOptions)||void 0===f?void 0:f.logY)&&void 0!==h&&h),k=Math.min(N.width,N.height),F=k>100?1:.2+k/100*.8,D={logX:null===(d=n.chartOptions)||void 0===d?void 0:d.logX,logY:null===(p=n.chartOptions)||void 0===p?void 0:p.logY};e.save(),e.font='11px Roboto, "Roboto Local"',X.drawCoordinateGrid(e,C,P),e.restore();for(let t=0;t<(null===(g=n.series)||void 0===g?void 0:g.length);t++){const o=n.series[t];if(o.points.some((e=>void 0===e.x||void 0===e.y)))continue;(r.width<m.d.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||r.height<m.d.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT)&&(o.showPoints="",n.chartOptions&&(n.chartOptions.showStatistics=[])),o.points.sort(((e,r)=>e.x-r.x));let i=!0;const a=(0,s.Y6)(o);let u=null;if(!o.connectDots||o.showFitLine)if(o.parameters)(null===(x=n.chartOptions)||void 0===x?void 0:x.logX)&&o.parameters[2]>0&&(o.parameters[2]=Math.log10(o.parameters[2])),u=(0,s.kG)(o,a);else{const e=(0,s.PK)(o,a,D);u=e.fittedCurve,o.parameters=e.parameters,i=!1}v(o,t),y(e,o,{viewport:X,ratio:F}),_(e,o,{viewport:X,ratio:F}),T(e,o,{viewport:X,ratio:F,logOptions:D,showAxes:this.areAxesShown(r),showAxesLabels:this.areAxesLabelsShown(r,n),screenBounds:r,curveFunc:u}),b(e,o,{viewport:X,logOptions:D,showAxes:this.areAxesShown(r),showAxesLabels:this.areAxesLabelsShown(r,n),screenBounds:r,fitFunc:a,userParamsFlag:i}),I(e,o,{viewport:X,ratio:F,showDroplines:this.areDroplinesShown(r),xValue:o.parameters[2],dataBounds:O,curveFunc:u,logOptions:D}),S(e,o,{statistics:null===(w=n.chartOptions)||void 0===w?void 0:w.showStatistics,fitFunc:a,logOptions:D,dataBox:N})}!function(e,r){r.showTitle&&(e.font='12px Roboto, "Roboto Local"',e.textAlign="center",e.fillStyle="black",e.fillText(r.title,r.dataBox.midX-5,r.screenBounds.y+15))}(e,{showTitle:this.isTitleShown(r,n),title:null===(A=n.chartOptions)||void 0===A?void 0:A.title,dataBox:N,screenBounds:r}),function(e,r){if(r.showAxesLabels){e.font='11px Roboto, "Roboto Local"',e.textAlign="center",e.fillStyle="black",e.fillText(r.xAxisName,r.dataBox.midX-5,r.screenBounds.maxY-m.d.X_AXIS_LABEL_BOTTOM_PX_MARGIN),e.translate(r.screenBounds.x,r.screenBounds.y),e.rotate(-Math.PI/2);const n=r.showTitle?m.d.AXES_TOP_PX_MARGIN_WITH_TITLE:m.d.AXES_TOP_PX_MARGIN;e.fillText(r.yAxisName,-(r.dataBox.height/2+n+15),15),e.restore()}}(e,{showTitle:this.isTitleShown(r,n),dataBox:N,screenBounds:r,showAxesLabels:this.areAxesLabelsShown(r,n),xAxisName:null===(E=n.chartOptions)||void 0===E?void 0:E.xAxisName,yAxisName:null===(M=n.chartOptions)||void 0===M?void 0:M.yAxisName}),function(e,r,n){var o,i,a,u,s,c,l;if(n.showLegend){e.font='11px Roboto, "Roboto Local"';const f=[...new Set(null===(o=r.series)||void 0===o?void 0:o.map((e=>e.columnName)))].filter((e=>null!=e));let h=0;for(let o=0;o<f.length;o++){const d=f[o];if(null===(i=r.chartOptions)||void 0===i?void 0:i.showColumnLabel){e.beginPath(),e.fillStyle="black";const r=e.measureText(d).width;e.fillText(d,n.dataBox.maxX-r,n.dataBox.y+m.d.LEGEND_TOP_PX_MARGIN+(o*m.d.LEGEND_RECORD_PX_HEIGHT+m.d.LEGEND_RECORD_PX_HEIGHT*h))}const p=null===(a=r.series)||void 0===a?void 0:a.filter((e=>e.columnName===d));for(let i=0;i<(null==p?void 0:p.length);i++){const a=p[i];if(""===a.name||null===a.name||void 0===a.name)continue;e.beginPath(),e.strokeStyle=a.fitLineColor,e.lineWidth=2*n.ratio;const f=e.measureText(a.name).width;e.moveTo(n.dataBox.maxX-f-m.d.LEGEND_RECORD_LINE_PX_WIDTH-m.d.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN,n.dataBox.y+m.d.LEGEND_TOP_PX_MARGIN-m.d.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN+((null===(u=r.chartOptions)||void 0===u?void 0:u.showColumnLabel)?m.d.LEGEND_RECORD_PX_HEIGHT*(o+1):0)+m.d.LEGEND_RECORD_PX_HEIGHT*h),e.lineTo(n.dataBox.maxX-f-m.d.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN,n.dataBox.y+m.d.LEGEND_TOP_PX_MARGIN-m.d.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN+((null===(s=r.chartOptions)||void 0===s?void 0:s.showColumnLabel)?m.d.LEGEND_RECORD_PX_HEIGHT*(o+1):0)+m.d.LEGEND_RECORD_PX_HEIGHT*h);const d=a.markerType?a.markerType:t.MARKER_TYPE.CIRCLE;t.Paint.marker(e,d,n.dataBox.maxX-f-m.d.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN-m.d.LEGEND_RECORD_LINE_PX_WIDTH/2,n.dataBox.y+m.d.LEGEND_TOP_PX_MARGIN-m.d.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN+((null===(c=r.chartOptions)||void 0===c?void 0:c.showColumnLabel)?m.d.LEGEND_RECORD_PX_HEIGHT*(o+1):0)+m.d.LEGEND_RECORD_PX_HEIGHT*h,a.pointColor,m.d.POINT_PX_SIZE*n.ratio),e.fillStyle=a.fitLineColor,e.fillText(a.name,n.dataBox.maxX-f,n.dataBox.y+m.d.LEGEND_TOP_PX_MARGIN+((null===(l=r.chartOptions)||void 0===l?void 0:l.showColumnLabel)?m.d.LEGEND_RECORD_PX_HEIGHT*(o+1):0)+m.d.LEGEND_RECORD_PX_HEIGHT*h),e.stroke(),h++}}e.restore()}}(e,n,{showLegend:this.isLegendShown(r),dataBox:N,ratio:F}),e.restore()}render(e,r,n,o,i,a,u){var s,l,f;if(!a.cell.value)return;if(o<m.d.MIN_CELL_RENDERER_PX_WIDTH||i<m.d.MIN_CELL_RENDERER_PX_HEIGHT)return;const h=(null===(s=a.cell.column)||void 0===s?void 0:s.getTag(m.d.TAG_FIT_CHART_FORMAT))===m.d.TAG_FIT_CHART_FORMAT_3DX?(0,c.f)(a.cell.value):O(a),d=new t.Rect(r,n,o,i).inflate(m.d.INFLATE_SIZE,m.d.INFLATE_SIZE);for(const[r,n]of Object.entries(m.d.CONDITION_MAP))if(n(h.series))return void M(e,d);null===(l=h.series)||void 0===l||l.forEach((e=>e.columnName=a.cell.column.name)),(null===(f=h.chartOptions)||void 0===f?void 0:f.mergeSeries)&&(h.series=[P(h.series)]),this.renderCurves(e,d,h)}hitTest(e,r,n){const o=n.xToScreen(r.x),i=n.yToScreen(r.y),a=(r.outlier?m.d.OUTLIER_PX_SIZE:m.d.POINT_PX_SIZE)/2+m.d.OUTLIER_HITBOX_RADIUS;return new t.Rect(o-a,i-a,2*a,2*a).containsPoint(new t.Point(e.offsetX,e.offsetY))}onMouseMove(e,r){var n,o,a,l,f;if(!e.cell.value)return;const h=e.bounds.inflate(m.d.INFLATE_SIZE,m.d.INFLATE_SIZE);if(h.width<m.d.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||h.height<m.d.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT){const n=i.canvas(300,200);this.render(n.getContext("2d"),0,0,300,200,e,null);const t=i.divV([n]);i.tooltip.show(t,r.x,r.y)}const d=e.cell.column.getTag(m.d.TAG_FIT_CHART_FORMAT)===m.d.TAG_FIT_CHART_FORMAT_3DX?(0,c.f)(e.cell.value):O(e);if(h.width>=m.d.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH&&h.height>=m.d.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT){const e=L(h,this.areAxesLabelsShown(h,d),this.isTitleShown(h,d))[0],c=(0,s.dU)(d),p=new u.l(c,e,null!==(o=null===(n=d.chartOptions)||void 0===n?void 0:n.logX)&&void 0!==o&&o,null!==(l=null===(a=d.chartOptions)||void 0===a?void 0:a.logY)&&void 0!==l&&l);for(let e=0;e<(null===(f=d.series)||void 0===f?void 0:f.length);e++)if("points"===d.series[e].showPoints)for(let n=0;n<d.series[e].points.length;n++){const o=d.series[e].points[n];if(this.hitTest(r,o,p))return i.tooltip.show(i.divV([i.divText(`x: ${t.format(o.x,"#0.000")}`),i.divText(`y: ${t.format(o.y,"#0.000")}`)]),r.x+16,r.y+16),void(!d.series[e].connectDots&&d.series[e].clickToToggle&&h.width>=m.d.MIN_AXES_CELL_PX_WIDTH&&h.height>=m.d.MIN_AXES_CELL_PX_HEIGHT&&(document.body.style.cursor="pointer"))}i.tooltip.hide()}document.body.style.cursor="default"}}},363:(e,r,n)=>{"use strict";n.r(r),n.d(r,{_FitViewer:()=>T,_initCurves:()=>A,_package:()=>g,addAggrStatisticsColumn:()=>E,addStatisticsColumn:()=>I,curveFitDemo:()=>b,fitCellRenderer:()=>w});var t=n(976),o=n(188),i=n(874),a=n(870),u=n(184),s=n(875);const c=rxjs.operators,l=rxjs;var f=n(638);class m extends u.${constructor(){super(new i.cv),this.curvesColumnNames=[],this.showSelectedRowsCurves=!1,this.showCurrentRowCurve=!0,this.showMouseOverRowCurve=!0,this.mergeColumnSeries=!1,this.rows=[],this.data=new s.cY,this.curvesColumnNames=this.addProperty("curvesColumnNames",t.TYPE.COLUMN_LIST,[],{semType:s.j2}),this.showSelectedRowsCurves=this.bool("showSelectedRowsCurves",!1,{description:"Adds curves from the selected rows"}),this.showCurrentRowCurve=this.bool("showCurrentRowCurve",!0),this.showMouseOverRowCurve=this.bool("showMouseOverRowCurve",!0),this.mergeColumnSeries=this.bool("mergeColumnSeries",!1);for(const e of s.kW)this.addProperty("mergeSeries"===e.name?"mergeCellSeries":e.name,e.propertyType,e.defaultValue,e.options)}static fromChartData(e){let r=new m;return r.data=e,r.render(),r}applyViewerProperties(){(0,i.BI)(s.kW,this,this.data.chartOptions)}mergeViewerChartOptions(){for(const e of s.kW)if(["logX","logY","allowXZeroes","mergeCellSeries","showColumnLabel"].includes("mergeSeries"===e.name?"mergeCellSeries":e.name)?void 0!==this["mergeSeries"===e.name?"mergeCellSeries":e.name]:void 0!==this.props.get(e.name)&&this.props.get(e.name)!==e.defaultValue){if(["title","xAxisName","yAxisName"].includes(e.name)&&""===this.props.get(e.name))continue;["logX","logY","allowXZeroes","mergeCellSeries","showColumnLabel"].includes("mergeSeries"===e.name?"mergeCellSeries":e.name)?this.data.chartOptions[e.name]=this[e.name]:this.data.chartOptions[e.name]=this.props.get(e.name)}}createChartData(){var e,r,n,o,a,u;if(0===(null===(e=this.curvesColumnNames)||void 0===e?void 0:e.length))return;this.rows.length=0;let c=-1;this.showCurrentRowCurve&&-1!==this.dataFrame.currentRowIdx&&this.rows.push(this.dataFrame.currentRowIdx),this.showMouseOverRowCurve&&-1!==this.dataFrame.mouseOverRowIdx&&this.rows.push(this.dataFrame.mouseOverRowIdx),this.showSelectedRowsCurves&&-1!==this.dataFrame.mouseOverRowIdx&&(c=this.rows.length,this.rows.push(...this.dataFrame.selection.getSelectedIndexes())),this.data=new s.cY;const l=null===(r=this.tableView)||void 0===r?void 0:r.grid,f=this.props.get("mergeCellSeries"),m=[];for(const e of this.curvesColumnNames){const r=[];for(const t of new Set(this.rows)){const o=l.cell(e,l.tableRowToGrid(t));if(""===o.cell.value)continue;const a=(0,i.W$)(o);null===(n=a.series)||void 0===n||n.forEach((e=>e.columnName=o.cell.column.name));const u=a.chartOptions;if(null!=u&&(m[m.length]=u),f){const e=(0,i.Qp)(a.series);void 0!==(null==u?void 0:u.title)&&""!==(null==u?void 0:u.title)&&(e.name=null==u?void 0:u.title),a.series=[e]}r.push(...a.series)}this.mergeColumnSeries?null===(o=this.data.series)||void 0===o||o.push((0,i.Qp)(r)):null===(a=this.data.series)||void 0===a||a.push(...r)}this.data.chartOptions=(0,i.l$)(m),this.mergeViewerChartOptions(),null===(u=this.data.series)||void 0===u||u.forEach(((e,r)=>{var n,o,i,a,u;if(e.pointColor=t.Color.toHtml(t.Color.getCategoricalColor((null===(n=this.data.series)||void 0===n?void 0:n.length)>20?0:r)),e.fitLineColor=t.Color.toHtml(t.Color.getCategoricalColor((null===(o=this.data.series)||void 0===o?void 0:o.length)>20?0:r)),e.showCurveConfidenceInterval=!1,e.droplines=[],(null===(i=this.data.series)||void 0===i?void 0:i.length)>20&&(e.showPoints="",e.lineStyle="solid"),(null===(a=this.data.series)||void 0===a?void 0:a.length)>10&&(null===(u=this.data.series)||void 0===u?void 0:u.length)<100&&r>=c){const r=t.Color.fromHtml(e.fitLineColor);e.fitLineColor=`rgba(${t.Color.r(r)}, ${t.Color.g(r)}, ${t.Color.b(r)}, 0.2)`}}))}onPropertyChanged(e){var r,n,t,o,i;"curvesColumnNames"===(null==e?void 0:e.name)&&(this.props.set("showColumnLabel",(null===(r=this.curvesColumnNames)||void 0===r?void 0:r.length)>1),this.showColumnLabel=(null===(n=this.curvesColumnNames)||void 0===n?void 0:n.length)>1),["logX","logY","allowXZeroes","mergeCellSeries","showColumnLabel"].includes("mergeSeries"===(null==e?void 0:e.name)?"mergeCellSeries":null!==(t=null==e?void 0:e.name)&&void 0!==t?t:"")&&(this["mergeSeries"===(null==e?void 0:e.name)?"mergeCellSeries":null!==(o=null==e?void 0:e.name)&&void 0!==o?o:""]=this[null!==(i=null==e?void 0:e.name)&&void 0!==i?i:""]),this.applyViewerProperties(),this.createChartData(),this.render()}onTableAttached(){var e;const r=null===(e=this.tableView)||void 0===e?void 0:e.grid,n=this.dataFrame.columns.bySemType(s.j2);null!==n&&(this.curvesColumnNames=[n.name]),(0,l.merge)(this.dataFrame.onCurrentCellChanged,r.onCellMouseEnter,this.dataFrame.onSelectionChanged).pipe((0,c.debounce)((e=>(0,l.interval)(50)))).subscribe((e=>{this.createChartData(),this.render()}))}_showErrorMessage(e){this.root.appendChild(a.divText(e,"d4-viewer-error"))}_removeErrorMessage(){const e=this.root.getElementsByClassName("d4-viewer-error")[0];e&&this.root.removeChild(e)}render(){var e;const r=this.canvas.getContext("2d");r.clearRect(0,0,this.canvas.width,this.canvas.height),0!==(null===(e=this.curvesColumnNames)||void 0===e?void 0:e.length)?(this._removeErrorMessage(),this.renderer.renderCurves(r,new t.Rect(0,0,this.canvas.width,this.canvas.height).inflate(f.d.INFLATE_SIZE,f.d.INFLATE_SIZE),this.data)):this._showErrorMessage("The MultiCurveViewer viewer requires a minimum of 1 curves column.")}}var h=n(840),d=n(711),p=function(e,r,n,t){return new(n||(n=Promise))((function(o,i){function a(e){try{s(t.next(e))}catch(e){i(e)}}function u(e){try{s(t.throw(e))}catch(e){i(e)}}function s(e){var r;e.done?o(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(a,u)}s((t=t.apply(e,r||[])).next())}))};const g=new t.Package,v=".sourceColumn",y=".seriesNumber",_=".seriesAggregation",x=".statistics";function w(){return new i.cv}function T(){return new m}function b(){return p(this,void 0,void 0,(function*(){yield(0,h.DI)()}))}function A(){t.ObjectHandler.register(new o.Z)}function I(e,r,n,a,u){var s;const c=t.Viewer.grid(e),l=c.col(r),m=t.Column.float(`${r}_${a}_${n}`,null===(s=l.column)||void 0===s?void 0:s.length);m.tags[v]=r,m.tags[y]=u,m.tags[x]=n,m.init((e=>{var a,s,l,m,h;const p=t.GridCell.fromColumnRow(c,r,c.tableRowToGrid(e));if(""===p.cell.value)return null;const g=p.cell.column.getTag(f.d.TAG_FIT_CHART_FORMAT)===f.d.TAG_FIT_CHART_FORMAT_3DX?(0,d.f)(p.cell.value):(0,i.W$)(p);if(void 0===g.series[u]||g.series[u].points.every((e=>e.outlier)))return null;(null===(a=g.chartOptions)||void 0===a?void 0:a.allowXZeroes)&&(null===(s=g.chartOptions)||void 0===s?void 0:s.logX)&&(null===(l=g.series)||void 0===l?void 0:l.some((e=>e.points.some((e=>0===e.x)))))&&(0,i.kb)(g);const v={logX:null===(m=g.chartOptions)||void 0===m?void 0:m.logX,logY:null===(h=g.chartOptions)||void 0===h?void 0:h.logY};return(0,o.hS)(g.series[u],v)[n]})),e.columns.insert(m,l.idx)}function E(e,r,n,a){var u;const s=t.Viewer.grid(e),c=s.col(r),l=t.Column.float(`${r}_${a}_${n}`,null===(u=c.column)||void 0===u?void 0:u.length);l.tags[v]=r,l.tags[_]=a,l.tags[x]=n,l.init((e=>{var u,c,l,m;const h=t.GridCell.fromColumnRow(s,r,s.tableRowToGrid(e));if(""===h.cell.value)return null;const p=h.cell.column.getTag(f.d.TAG_FIT_CHART_FORMAT)===f.d.TAG_FIT_CHART_FORMAT_3DX?(0,d.f)(h.cell.value):(0,i.W$)(h);return(null===(u=p.series)||void 0===u?void 0:u.every((e=>e.points.every((e=>e.outlier)))))?null:((null===(c=p.chartOptions)||void 0===c?void 0:c.allowXZeroes)&&(null===(l=p.chartOptions)||void 0===l?void 0:l.logX)&&(null===(m=p.series)||void 0===m?void 0:m.some((e=>e.points.some((e=>0===e.x)))))&&(0,i.kb)(p),(0,o.No)(p,a)[n])})),e.columns.insert(l,c.idx)}},976:e=>{"use strict";e.exports=DG},469:e=>{"use strict";e.exports=grok},870:e=>{"use strict";e.exports=ui},414:e=>{"use strict";e.exports=wu}},__webpack_module_cache__={};function __webpack_require__(e){var r=__webpack_module_cache__[e];if(void 0!==r)return r.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(r,{a:r}),r},__webpack_require__.d=(e,r)=>{for(var n in r)__webpack_require__.o(r,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(363);curves=__webpack_exports__})();
|
|
1
|
+
var curves;(()=>{var e={111:(e,t,n)=>{"use strict";function r(e){e.sort();const t=e[Math.trunc(e.length/4)],n=e.length%2==0?(e[Math.trunc(e.length/2)]+e[Math.trunc(e.length/2)-1])/2:e[Math.trunc(e.length/2)],r=e[Math.trunc(3*e.length/4)],i=1.5*(r-t);let a=o(e,r+i);a<0&&(a=~a);let s=e[Math.max(0,a-1)];s<r&&(s=r);let l=o(e,t-i);l<0&&(l=~l);let u=e[l];return u>t&&(u=t),{q1:t,q2:n,q3:r,lowerAdjacentValue:u,upperAdjacentValue:s}}function o(e,t,n=0,r){if(0===e.length)return-1;if(void 0===r&&(r=e.length-1),t<e[n])return-1;if(t>e[r])return-(r+1);for(;r-n>1;){const o=Math.trunc((r+n)/2);if(t===e[o])return o;t<e[o]?r=o:n=o}return e[n]===t?n:0===e[r]?r:t<e[n]?-(n+1):-(r+1)}n.d(t,{G:()=>r})},102:(e,t,n)=>{"use strict";n.d(t,{yB:()=>T,cY:()=>d,js:()=>f,kW:()=>v,iC:()=>I,K0:()=>_,ue:()=>x,hR:()=>y,ZY:()=>E,aC:()=>A,sw:()=>g});var r,o=n(976),i=n(162);class a extends Error{constructor(e){super(e)}}function s(e,t,n,r){for(let o=0;o<t;o++){let i=0;for(let e=0;e<t+1;e++)e!==n&&(i+=r[e][o]);e[o]=i/t}}function l(e,t,n,r,o,i,a,s){for(let l=0;l<i;l++)t[l]=e[l],t[l]+=o*(e[l]-r[n][l]),t[l]<a[l]?t[l]=a[l]:t[l]>s[l]&&(t[l]=s[l])}!function(e){e[e.TOLERANCE=.01]="TOLERANCE",e[e.MAX_ITER=20]="MAX_ITER",e[e.NON_ZERO_PARAM=1e-4]="NON_ZERO_PARAM",e[e.INITIAL_SCALE=.02]="INITIAL_SCALE",e[e.SCALE_REFLECTION=1]="SCALE_REFLECTION",e[e.SCALE_EXPANSION=2]="SCALE_EXPANSION",e[e.SCALE_CONTRACTION=-.5]="SCALE_CONTRACTION"}(r||(r={})),new Map([["tolerance","Tolerance"],["maxIter","Max iterations"],["nonZeroParam","Non-zero param"],["initialScale","Initial scale"],["scaleReflection","Scale reflection"],["scaleExpansion","Scale expansion"],["scaleContraction","Scale contraction"]]);const u=function(e,t,n,r,o){const i=n.tolerance,a=n.maxIter,u=n.scaleReflection,c=n.scaleExpansion,f=n.scaleContraction,d=t.length+1,h=t.length,[m,p]=function(e,t,n,r,o){const i=n.length+1,a=n.length,s=t.nonZeroParam,l=t.initialScale,u=new Array(i),c=new Array(i);for(let t=0;t<i;t++){u[t]=new Float32Array(a);for(let e=0;e<a;e++)u[t][e]=n[e],0!==t&&t-1===e&&(0===n[e]?u[t][e]=s:u[t][e]+=l*n[t-1],u[t][e]<r[e]?u[t][e]=r[e]:u[t][e]>o[e]&&(u[t][e]=o[e]));c[t]=e(u[t])}return[u,c]}(e,n,t,r,o),g=new Array(d);for(let e=0;e<d;e++)g[e]=e;const v=g.length-1;let _=0,T=0,w=0,E=0;const I=new Float32Array(h),y=new Float32Array(h),x=new Float32Array(h),A=new Float32Array(h),C=new Array(a);if(d>1){for(;g.sort(((e,t)=>p[e]-p[t])),!(_>a);){if(0===_&&(T=p[0],w=2*p[g[0]]),C[_]=T,++_,T=p[g[0]],w-T>i)E=0;else if(++E,E>2*d)break;w=T,s(I,h,g[v],m),l(I,y,g[v],m,u,h,r,o);const t=e(y);if(t<p[g[v]]){l(I,x,g[v],m,c,h,r,o);const n=e(x);if(n<t){p[g[v]]=n;for(let e=0;e<h;e++)m[g[v]][e]=x[e];continue}p[g[v]]=t;for(let e=0;e<h;e++)m[g[v]][e]=y[e];continue}l(I,A,g[v],m,f,h,r,o);const n=e(A);if(!(n<p[g[v]]))break;p[g[v]]=n;for(let e=0;e<h;e++)m[g[v]][e]=A[e]}for(let e=_;e<a;e++)C[e]=p[g[0]]}return{point:m[g[0]],cost:p[g[0]],iterCosts:C,iterCount:_-1}};function c(e,t,n){const r=t-n,o=new Array(e);for(let t=0;t<e;t++){const e=Math.random();o[t]=n+e*r}return o}const f={CONSTANT:"constant",PROPORTIONAL:"proportional",COMBINED:"combined"};class d{constructor(){this.chartOptions={},this.seriesOptions={},this.series=[]}}class h{}class m extends h{constructor(e,t,n,r){super(),this._name=e,this._parameterNames=r,this.y=t,this.getInitialParameters=n}get name(){return this._name}get parameterNames(){return this._parameterNames}y(e,t){throw new Error("Not implemented")}getInitialParameters(e,t){throw new Error("Not implemented")}}const p={linear:new class extends h{get name(){return w}get parameterNames(){return["Slope","Intercept"]}y(e,t){return function(e,t){return e[0]*t+e[1]}(e,t)}getInitialParameters(e,t){let n=0,r=0;for(let t=1;t<e.length;t++)e[t]<e[n]&&(n=t),e[t]>e[r]&&(r=t);const o=e[r]-e[n],i=(t[r]-t[n])/o,a=t[r]-i*e[r],s=new Float32Array(2);return s.set([i,a]),s}},sigmoid:new class extends h{get name(){return T}get parameterNames(){return["Top","Bottom","Slope","IC50"]}y(e,t){return function(e,t){const n=e[0],r=e[1],o=e[2],i=e[3];return i+(n-i)/(1+Math.pow(10,(t-o)*r))}(e,t)}getInitialParameters(e,t){const n=o.Rect.fromXYArrays(e,t),r=(n.bottom-n.top)/2+n.top;let i=n.bottom-n.top,a=0;for(let n=0;n<e.length;n++){const e=Math.abs(t[n]-r);e<i&&(i=e,a=n)}const s=e[a],l=t[0]>t[t.length-1]?1:-1,u=new Float32Array(4);return u.set([n.bottom,l,s,n.top]),u}}},g=[o.Property.js("rSquared",o.TYPE.FLOAT,{userEditable:!1}),o.Property.js("auc",o.TYPE.FLOAT,{userEditable:!1}),o.Property.js("interceptY",o.TYPE.FLOAT,{userEditable:!1}),o.Property.js("interceptX",o.TYPE.FLOAT,{userEditable:!1}),o.Property.js("slope",o.TYPE.FLOAT,{userEditable:!1}),o.Property.js("top",o.TYPE.FLOAT,{userEditable:!1}),o.Property.js("bottom",o.TYPE.FLOAT,{userEditable:!1})],v=[o.Property.js("minX",o.TYPE.FLOAT,{nullable:!0}),o.Property.js("minY",o.TYPE.FLOAT,{nullable:!0}),o.Property.js("maxX",o.TYPE.FLOAT,{nullable:!0}),o.Property.js("maxY",o.TYPE.FLOAT,{nullable:!0}),o.Property.js("title",o.TYPE.STRING,{nullable:!0}),o.Property.js("xAxisName",o.TYPE.STRING,{description:"Label to show on the X axis. If not specified, corresponding data column name is used",nullable:!0}),o.Property.js("yAxisName",o.TYPE.STRING,{description:"Label to show on the Y axis. If not specified, corresponding data column name is used",nullable:!0}),o.Property.js("logX",o.TYPE.BOOL,{description:"Whether the X axis should be logarithmic",defaultValue:!1}),o.Property.js("logY",o.TYPE.BOOL,{description:"Whether the Y axis should be logarithmic",defaultValue:!1}),o.Property.js("allowXZeroes",o.TYPE.BOOL,{description:"Whether x zeroes allowed for logarithmic data or not",defaultValue:!0}),o.Property.js("mergeSeries",o.TYPE.BOOL,{description:"Merges all series within one cell into one series",defaultValue:!1}),o.Property.js("showColumnLabel",o.TYPE.BOOL,{description:"Whether to show the column label in the legend or not",defaultValue:!1}),o.Property.js("showStatistics",o.TYPE.STRING_LIST,{description:"Whether specific statistics should be rendered",choices:g.map((e=>e.name)),inputType:"MultiChoice",friendlyName:"Statistics"})],_=[o.Property.js("fitFunction",o.TYPE.STRING,{category:"Fitting",choices:Object.keys(p),defaultValue:"sigmoid"}),o.Property.js("pointColor",o.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),o.Property.js("fitLineColor",o.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),o.Property.js("outlierColor",o.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),o.Property.js("errorModel",o.TYPE.STRING,{category:"Fitting",defaultValue:"constant",choices:["constant","proportional","combined"],nullable:!1}),o.Property.js("connectDots",o.TYPE.BOOL,{category:"Fitting",defaultValue:!1}),o.Property.js("clickToToggle",o.TYPE.BOOL,{category:"Fitting",description:"Click on a point to mark it as outlier and refit",nullable:!0,defaultValue:!1}),o.Property.js("showFitLine",o.TYPE.BOOL,{category:"Fitting",defaultValue:!0}),o.Property.js("showPoints",o.TYPE.STRING,{category:"Fitting",description:"Whether points/candlesticks/none should be rendered",defaultValue:"points",choices:["points","candlesticks","both"]}),o.Property.js("showCurveConfidenceInterval",o.TYPE.BOOL,{category:"Fitting",description:"Whether confidence intervals should be rendered",defaultValue:!1,friendlyName:"Confidence Interval"}),o.Property.js("markerType",o.TYPE.STRING,{category:"Rendering",defaultValue:"circle",choices:["asterisk","circle","cross border","diamond","square","star","triangle bottom","triangle left","triangle right","triangle top"],nullable:!1}),o.Property.js("lineStyle",o.TYPE.STRING,{category:"Rendering",defaultValue:"solid",choices:["solid","dotted","dashed","dashdotted"],nullable:!1}),o.Property.js("droplines",o.TYPE.STRING_LIST,{description:"Whether specific droplines should be rendered",choices:["IC50"],inputType:"MultiChoice"}),o.Property.js("columnName",o.TYPE.STRING,{description:"Column name where the series is stored",defaultValue:""})],T="sigmoid",w="linear";function E(e){if("string"==typeof e)return p[e];if(!p[e.name]){const t=e.name,n=e.parameterNames,r=e.function.split("=>").map((e=>e.trim())),o=e.getInitialParameters.split("=>").map((e=>e.trim())),i=new Function(r[0].slice(1,r[0].length-1),`${r[1].includes(";")?"":"return "}${r[1]}`),a=new Function(o[0].slice(1,o[0].length-1),`return ${o[1]}`),s=new m(t,i,a,n);p[t]=s}return p[e.name]}function I(e,t,n,i){const s=t.y;let l=t.getInitialParameters(e.x,e.y);const d=function(e,t,n){return r=>{let o=0,i=0,a=0;const s=t.y,l=t.x.map((t=>e(r,t))),u=s.map(((e,t)=>e-l[t])).map((e=>Math.pow(e,2)));for(let e=0;e<u.length;e++)[f.CONSTANT,f.COMBINED].includes(n)?i+=u[e]:n===f.PROPORTIONAL&&(a+=u[e]/(l[e]*l[e]));i=Math.sqrt(i/u.length),a=Math.sqrt(a/u.length),n===f.COMBINED&&({sigmaA:i,sigmaB:a}=O(i,a,u,l));const c=[];for(let e=0;e<u.length;e++)c[e]=Math.pow(i+a*l[e],2),o+=u[e]/c[e]+Math.log(2*Math.PI*c[e]);return o}}(s,e,n);let h=new Float32Array(t.parameterNames.length),m=new Float32Array(t.parameterNames.length);for(let e=0;e<t.parameterNames.length;e++)h[e]=0===l[e]?-1:l[e]-Math.abs(.5*l[e]),m[e]=0===l[e]?1:l[e]+Math.abs(.5*l[e]);return i&&0!==i.length&&(h=new Float32Array(i.length),h.set(i.map((e=>e.min))),m=new Float32Array(i.length),m.set(i.map((e=>e.max)))),l=function(e,t,n,r,i=1,s=null,l=!0){const f=function(e,t,n){const r=t.length,o=new Array(e);for(let t=0;t<e;t++)o[t]=new Float32Array(r);for(let i=0;i<r;i++)if(t[i]===n[i])for(let n=0;n<e;n++)o[n][i]=t[i];else{const r=c(e,t[i],n[i]);for(let t=0;t<e;t++)o[t][i]=r[t]}return o}(i,n,t);null!==s&&(f[0]=s);const d=[],h=[],m=[];let p,g=0,v=null;for(p=0;p<i;++p)try{if(0===p&&l){const t=new Float32Array(s.length).map((e=>-1/0)),n=new Float32Array(s.length).map((e=>1/0));d.push(u(e,f[p],r,t,n))}else d.push(u(e,f[p],r,t,n))}catch(e){if(e instanceof a)throw new Error(`Inconsistent dataframes: ${e.message}`);++g,h.push(e instanceof Error?e.message:"Platform issue"),m.push(f[p])}if(g>0){const e=n.length,t=new Array(e);for(let n=0;n<e;++n)t[n]=new Float32Array(g);m.forEach(((e,n)=>e.forEach(((e,r)=>t[r][n]=e)))),v=o.DataFrame.fromColumns(t.map(((e,t)=>o.Column.fromFloat32Array(`arg${t}`,e)))),v.columns.add(o.Column.fromStrings("Issue",h))}return{extremums:d,fails:v}}(d,h,m,{tolerance:r.TOLERANCE,maxIter:r.MAX_ITER,nonZeroParam:r.NON_ZERO_PARAM,initialScale:r.INITIAL_SCALE,scaleReflection:r.SCALE_REFLECTION,scaleExpansion:r.SCALE_EXPANSION,scaleContraction:r.SCALE_CONTRACTION},1,l).extremums[0].point,{fittedCurve:y(s,l),parameters:l}}function y(e,t){return n=>e(t,n)}function x(e,t,n,r=.05,o){const a=function(e,t,n,r){let o=0,i=0;const a=t.y,s=t.x.map((t=>e(r,t))),l=a.map(((e,t)=>e-s[t])),u=l.map((e=>Math.pow(e,2)));for(let e=0;e<u.length;e++)[f.CONSTANT,f.COMBINED].includes(n)?o+=u[e]:n===f.PROPORTIONAL&&(i+=Math.pow(l[e]/Math.abs(s[e]),2));return o=Math.sqrt(o/u.length),i=Math.sqrt(i/u.length),n===f.COMBINED&&({sigmaA:o,sigmaB:i}=O(o,i,u,s)),{sigmaA:o,sigmaB:i}}(n,e,o,t),s=i.normal.inv(1-r/2,0,1);return{confidenceTop:e=>{const r=n(t,e);return r+s*(a.sigmaA+Math.abs(r)*a.sigmaB)},confidenceBottom:e=>{const r=n(t,e);return r-s*(a.sigmaA+Math.abs(r)*a.sigmaB)}}}function A(e,t,n,r=!0){const o=y(n,t);return{rSquared:r?N(o,e):void 0,auc:r?C(o,e):void 0,interceptX:t[2],interceptY:o(t[2]),slope:t[1],top:t[0],bottom:t[3]}}function C(e,t){let n=0;const r=Math.min(...t.x),o=Math.max(...t.x),i=(o-r)/1e3;for(let t=r;t<o;t+=i)n+=i*e(t);return n}function N(e,t){let n=0,r=0;const o=i.mean(t.y);for(let i=0;i<t.x.length;i++)n+=Math.pow(t.y[i]-e(t.x[i]),2),r+=Math.pow(t.y[i]-o,2);return 1-n/r}function O(e,t,n,r){let o=Number.MAX_VALUE,i=0;for(let t=0;t<=10;t++){let a=0;const s=t/10,l=e*s,u=e*(1-s),c=[];for(let e=0;e<n.length;e++)c[e]=Math.pow(l+u*r[e],2),a+=n[e]/c[e]+Math.log(2*Math.PI*c[e]);a<o&&(o=a,i=s)}return t=e*(1-i),{sigmaA:e*=i,sigmaB:t}}},416:(e,t,n)=>{"use strict";n.d(t,{LC:()=>h,PK:()=>d,TL:()=>a,Y6:()=>c,dU:()=>u,kG:()=>f,tq:()=>m});var r=n(976),o=n(102);function i(e){const t={};for(const n of e)null!==n.defaultValue&&(t[n.name]=n.defaultValue);return t}function a(){return{chartOptions:i(o.kW),seriesOptions:i(o.K0)}}function s(e){const t=[],n=[];for(let r=0;r<e.length;r++)t[r]=e[r].x,n[r]=e[r].y;return{xs:t,ys:n}}function l(e){const t=Math.floor(e.y.length/2),n=e.y.sort(((e,t)=>e-t));return n.length%2==0?(n[t-1]+n[t])/2:n[t]}function u(e){var t;const n=e.chartOptions;if((null===(t=e.series)||void 0===t?void 0:t.length)&&0!==e.series.length){const{xs:t,ys:o}=s(e.series[0].points);let i=r.Rect.fromXYArrays(t,o);for(let t=1;t<e.series.length;t++){const{xs:n,ys:o}=s(e.series[t].points);n.some((e=>void 0===e))||o.some((e=>void 0===e))||(i=i.union(r.Rect.fromXYArrays(n,o)))}return n?function(e,t){let n=e.x,o=e.y,i=e.width,a=e.height;return void 0!==t.minX&&null!==t.minX&&(!t.logX||t.logX&&t.minX>0)&&(i+=n-t.minX,n=t.minX),void 0!==t.maxX&&null!==t.maxX&&(!t.logX||t.logX&&t.maxX>0)&&(i+=t.maxX-(n+i)),void 0!==t.minY&&null!==t.minY&&(!t.logY||t.logY&&t.minY>0)&&(a+=o-t.minY,o=t.minY),void 0!==t.maxY&&null!==t.maxY&&(!t.logY||t.logY&&t.maxY>0)&&(a+=t.maxY-(o+a)),new r.Rect(n,o,i,a)}(i,n):i}return new r.Rect(0,0,1,1)}function c(e){return(0,o.ZY)(e.fitFunction)}function f(e,t){var n;const r=new Float32Array(null===(n=e.parameters)||void 0===n?void 0:n.length);return r.set(e.parameters),(0,o.hR)(t.y,r)}function d(e,t,n){var r;const i={x:e.points.filter((e=>!e.outlier)).map((e=>(null==n?void 0:n.logX)?Math.log10(e.x):e.x)),y:e.points.filter((e=>!e.outlier)).map((e=>(null==n?void 0:n.logY)?Math.log10(e.y):e.y))};var a;return e.parameterBounds&&(null==n?void 0:n.logX)&&(e.parameterBounds[2]=((a=e.parameterBounds[2])&&(void 0!==a.max&&(a.max=Math.log10(a.max)),void 0!==a.min&&(a.min=0===a.min?-Number.MAX_VALUE:Math.log10(a.min))),a)),(0,o.iC)(function(e){const t={x:[],y:[]},n={x:[e.x[0]],y:[e.y[0]]};for(let r=1;r<e.x.length;r++){if(e.x[r]===n.x[0]){n.x[n.x.length]=e.x[r],n.y[n.y.length]=e.y[r];continue}const o=l(n);t.x[t.x.length]=n.x[0],t.y[t.y.length]=o,n.x=[e.x[r]],n.y=[e.y[r]]}const r=l(n);return t.x[t.x.length]=n.x[0],t.y[t.y.length]=r,t}(i),t,null!==(r=e.errorModel)&&void 0!==r?r:o.js.CONSTANT,e.parameterBounds)}function h(e,t,n,r){var i,a;const s=n?{x:e.points.map((e=>(null==r?void 0:r.logX)?Math.log10(e.x):e.x)),y:e.points.map((e=>(null==r?void 0:r.logY)?Math.log10(e.y):e.y))}:{x:e.points.filter((e=>!e.outlier)).map((e=>(null==r?void 0:r.logX)?Math.log10(e.x):e.x)),y:e.points.filter((e=>!e.outlier)).map((e=>(null==r?void 0:r.logY)?Math.log10(e.y):e.y))};if(!e.parameters){const n=d(e,t).parameters;e.parameters=[...n]}const l=new Float32Array(null===(i=e.parameters)||void 0===i?void 0:i.length);return l.set(e.parameters),(0,o.ue)(s,l,t.y,.05,null!==(a=e.errorModel)&&void 0!==a?a:o.js.CONSTANT)}function m(e,t,n){var r;const i={x:e.points.filter((e=>!e.outlier)).map((e=>(null==n?void 0:n.logX)?Math.log10(e.x):e.x)),y:e.points.filter((e=>!e.outlier)).map((e=>(null==n?void 0:n.logY)?Math.log10(e.y):e.y))};if(!e.parameters){const n=d(e,t).parameters;e.parameters=[...n]}const a=new Float32Array(null===(r=e.parameters)||void 0===r?void 0:r.length);return a.set(e.parameters),(0,o.aC)(i,a,t.y,!0)}},766:(e,t,n)=>{"use strict";n.d(t,{l:()=>s});var r=n(976);const o=1e-30,i=new class{screenToWorld(e,t,n,r,o){return n+(o?1-e/t:e/t)*(r-n)}worldToScreen(e,t,n,r,o){return o?(1-(e-n)/(r-n))*t:(e-n)/(r-n)*t}},a=new class{screenToWorld(e,t,n,r,i){n=n<o?o:n;const a=Math.log(r),s=Math.log(n);return Math.exp(s+(a-s)*(i?t-e:e)/t)}worldToScreen(e,t,n,r,i){if(e<=0)return NaN;if(Math.abs(e-n)<o)return i?t:0;if(Math.abs(e-r)<o)return i?0:t;n=n<o?o:n,e=e<o?o:e;const a=t*Math.log(e/n)/Math.log(r/n);return i?t-a:a}};class s{get xt(){return this.logX?a:i}get yt(){return this.logY?a:i}constructor(e,t,n=!1,r=!1){this.logX=!1,this.logY=!1,this.inverseX=!1,this.inverseY=!1,this.world=e,this.screen=t,this.logX=n,this.logY=r}xToScreen(e){return this.screen.left+this.xt.worldToScreen(e,this.screen.width,this.world.minX,this.world.maxX,this.inverseX)}yToScreen(e){return this.screen.top+this.yt.worldToScreen(e,this.screen.height,this.world.minY,this.world.maxY,!this.inverseY)}xToWorld(e){return this.xt.screenToWorld(e-this.screen.left,this.screen.width,this.world.minX,this.world.maxX,this.inverseX)}yToWorld(e){return this.yt.screenToWorld(e-this.screen.top,this.screen.height,this.world.minY,this.world.maxY,!this.inverseY)}toScreen(e){return new r.Point(this.xToScreen(e.x),this.yToScreen(e.y))}toWorld(e){return new r.Point(this.xToWorld(e.x),this.yToWorld(e.y))}drawCoordinateGrid(e,t,n){t&&r.Paint.horzAxis(e,this.world.minX,this.world.maxX,t.x,t.y,t.width,t.height,this.logX,this.inverseX),n&&r.Paint.vertAxis(e,this.world.minY,this.world.maxY,n.x,n.y,n.width,n.height,this.logY,this.inverseY)}}},162:function(e){var t;e.exports=(t=function(e,t){var n=Array.prototype.concat,r=Array.prototype.slice,o=Object.prototype.toString;function i(t,n){var r=t>n?t:n;return e.pow(10,17-~~(e.log(r>0?r:-r)*e.LOG10E))}var a=Array.isArray||function(e){return"[object Array]"===o.call(e)};function s(e){return"[object Function]"===o.call(e)}function l(e){return"number"==typeof e&&e-e==0}function u(){return new u._init(arguments)}function c(){return 0}function f(){return 1}function d(e,t){return e===t?1:0}u.fn=u.prototype,u._init=function(e){if(a(e[0]))if(a(e[0][0])){s(e[1])&&(e[0]=u.map(e[0],e[1]));for(var t=0;t<e[0].length;t++)this[t]=e[0][t];this.length=e[0].length}else this[0]=s(e[1])?u.map(e[0],e[1]):e[0],this.length=1;else if(l(e[0]))this[0]=u.seq.apply(null,e),this.length=1;else{if(e[0]instanceof u)return u(e[0].toArray());this[0]=[],this.length=1}return this},u._init.prototype=u.prototype,u._init.constructor=u,u.utils={calcRdx:i,isArray:a,isFunction:s,isNumber:l,toVector:function(e){return n.apply([],e)}},u._random_fn=e.random,u.setRandom=function(e){if("function"!=typeof e)throw new TypeError("fn is not a function");u._random_fn=e},u.extend=function(e){var t,n;if(1===arguments.length){for(n in e)u[n]=e[n];return this}for(t=1;t<arguments.length;t++)for(n in arguments[t])e[n]=arguments[t][n];return e},u.rows=function(e){return e.length||1},u.cols=function(e){return e[0].length||1},u.dimensions=function(e){return{rows:u.rows(e),cols:u.cols(e)}},u.row=function(e,t){return a(t)?t.map((function(t){return u.row(e,t)})):e[t]},u.rowa=function(e,t){return u.row(e,t)},u.col=function(e,t){if(a(t)){var n=u.arange(e.length).map((function(){return new Array(t.length)}));return t.forEach((function(t,r){u.arange(e.length).forEach((function(o){n[o][r]=e[o][t]}))})),n}for(var r=new Array(e.length),o=0;o<e.length;o++)r[o]=[e[o][t]];return r},u.cola=function(e,t){return u.col(e,t).map((function(e){return e[0]}))},u.diag=function(e){for(var t=u.rows(e),n=new Array(t),r=0;r<t;r++)n[r]=[e[r][r]];return n},u.antidiag=function(e){for(var t=u.rows(e)-1,n=new Array(t),r=0;t>=0;t--,r++)n[r]=[e[r][t]];return n},u.transpose=function(e){var t,n,r,o,i,s=[];for(a(e[0])||(e=[e]),n=e.length,r=e[0].length,i=0;i<r;i++){for(t=new Array(n),o=0;o<n;o++)t[o]=e[o][i];s.push(t)}return 1===s.length?s[0]:s},u.map=function(e,t,n){var r,o,i,s,l;for(a(e[0])||(e=[e]),o=e.length,i=e[0].length,s=n?e:new Array(o),r=0;r<o;r++)for(s[r]||(s[r]=new Array(i)),l=0;l<i;l++)s[r][l]=t(e[r][l],r,l);return 1===s.length?s[0]:s},u.cumreduce=function(e,t,n){var r,o,i,s,l;for(a(e[0])||(e=[e]),o=e.length,i=e[0].length,s=n?e:new Array(o),r=0;r<o;r++)for(s[r]||(s[r]=new Array(i)),i>0&&(s[r][0]=e[r][0]),l=1;l<i;l++)s[r][l]=t(s[r][l-1],e[r][l]);return 1===s.length?s[0]:s},u.alter=function(e,t){return u.map(e,t,!0)},u.create=function(e,t,n){var r,o,i=new Array(e);for(s(t)&&(n=t,t=e),r=0;r<e;r++)for(i[r]=new Array(t),o=0;o<t;o++)i[r][o]=n(r,o);return i},u.zeros=function(e,t){return l(t)||(t=e),u.create(e,t,c)},u.ones=function(e,t){return l(t)||(t=e),u.create(e,t,f)},u.rand=function(e,t){return l(t)||(t=e),u.create(e,t,u._random_fn)},u.identity=function(e,t){return l(t)||(t=e),u.create(e,t,d)},u.symmetric=function(e){var t,n,r=e.length;if(e.length!==e[0].length)return!1;for(t=0;t<r;t++)for(n=0;n<r;n++)if(e[n][t]!==e[t][n])return!1;return!0},u.clear=function(e){return u.alter(e,c)},u.seq=function(e,t,n,r){s(r)||(r=!1);var o,a=[],l=i(e,t),u=(t*l-e*l)/((n-1)*l),c=e;for(o=0;c<=t&&o<n;c=(e*l+u*l*++o)/l)a.push(r?r(c,o):c);return a},u.arange=function(e,n,r){var o,i=[];if(r=r||1,n===t&&(n=e,e=0),e===n||0===r)return[];if(e<n&&r<0)return[];if(e>n&&r>0)return[];if(r>0)for(o=e;o<n;o+=r)i.push(o);else for(o=e;o>n;o+=r)i.push(o);return i},u.slice=function(){function e(e,n,r,o){var i,a=[],s=e.length;if(n===t&&r===t&&o===t)return u.copy(e);if(o=o||1,(n=(n=n||0)>=0?n:s+n)===(r=(r=r||e.length)>=0?r:s+r)||0===o)return[];if(n<r&&o<0)return[];if(n>r&&o>0)return[];if(o>0)for(i=n;i<r;i+=o)a.push(e[i]);else for(i=n;i>r;i+=o)a.push(e[i]);return a}return function(t,n){var r,o;return l((n=n||{}).row)?l(n.col)?t[n.row][n.col]:e(u.rowa(t,n.row),(r=n.col||{}).start,r.end,r.step):l(n.col)?e(u.cola(t,n.col),(o=n.row||{}).start,o.end,o.step):(o=n.row||{},r=n.col||{},e(t,o.start,o.end,o.step).map((function(t){return e(t,r.start,r.end,r.step)})))}}(),u.sliceAssign=function(n,r,o){var i,a;if(l(r.row)){if(l(r.col))return n[r.row][r.col]=o;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,i=u.arange(r.col.start,e.min(n.length,r.col.end),r.col.step);var s=r.row;return i.forEach((function(e,t){n[s][e]=o[t]})),n}if(l(r.col)){r.row=r.row||{},r.row.start=r.row.start||0,r.row.end=r.row.end||n.length,r.row.step=r.row.step||1,a=u.arange(r.row.start,e.min(n[0].length,r.row.end),r.row.step);var c=r.col;return a.forEach((function(e,t){n[e][c]=o[t]})),n}return o[0].length===t&&(o=[o]),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=u.arange(r.row.start,e.min(n.length,r.row.end),r.row.step),i=u.arange(r.col.start,e.min(n[0].length,r.col.end),r.col.step),a.forEach((function(e,t){i.forEach((function(r,i){n[e][r]=o[t][i]}))})),n},u.diagonal=function(e){var t=u.zeros(e.length,e.length);return e.forEach((function(e,n){t[n][n]=e})),t},u.copy=function(e){return e.map((function(e){return l(e)?e:e.map((function(e){return e}))}))};var h=u.prototype;return h.length=0,h.push=Array.prototype.push,h.sort=Array.prototype.sort,h.splice=Array.prototype.splice,h.slice=Array.prototype.slice,h.toArray=function(){return this.length>1?r.call(this):r.call(this)[0]},h.map=function(e,t){return u(u.map(this,e,t))},h.cumreduce=function(e,t){return u(u.cumreduce(this,e,t))},h.alter=function(e){return u.alter(this,e),this},function(e){for(var t=0;t<e.length;t++)!function(e){h[e]=function(t){var n,r=this;return t?(setTimeout((function(){t.call(r,h[e].call(r))})),this):(n=u[e](this),a(n)?u(n):n)}}(e[t])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(e){for(var t=0;t<e.length;t++)!function(e){h[e]=function(t,n){var r=this;return n?(setTimeout((function(){n.call(r,h[e].call(r,t))})),this):u(u[e](this,t))}}(e[t])}("row col".split(" ")),function(e){for(var t=0;t<e.length;t++)!function(e){h[e]=function(){return u(u[e].apply(null,arguments))}}(e[t])}("create zeros ones rand identity".split(" ")),u}(Math),function(e,t){var n=e.utils.isFunction;function r(e,t){return e-t}function o(e,n,r){return t.max(n,t.min(e,r))}e.sum=function(e){for(var t=0,n=e.length;--n>=0;)t+=e[n];return t},e.sumsqrd=function(e){for(var t=0,n=e.length;--n>=0;)t+=e[n]*e[n];return t},e.sumsqerr=function(t){for(var n,r=e.mean(t),o=0,i=t.length;--i>=0;)o+=(n=t[i]-r)*n;return o},e.sumrow=function(e){for(var t=0,n=e.length;--n>=0;)t+=e[n];return t},e.product=function(e){for(var t=1,n=e.length;--n>=0;)t*=e[n];return t},e.min=function(e){for(var t=e[0],n=0;++n<e.length;)e[n]<t&&(t=e[n]);return t},e.max=function(e){for(var t=e[0],n=0;++n<e.length;)e[n]>t&&(t=e[n]);return t},e.unique=function(e){for(var t={},n=[],r=0;r<e.length;r++)t[e[r]]||(t[e[r]]=!0,n.push(e[r]));return n},e.mean=function(t){return e.sum(t)/t.length},e.meansqerr=function(t){return e.sumsqerr(t)/t.length},e.geomean=function(n){var r=n.map(t.log),o=e.mean(r);return t.exp(o)},e.median=function(e){var t=e.length,n=e.slice().sort(r);return 1&t?n[t/2|0]:(n[t/2-1]+n[t/2])/2},e.cumsum=function(t){return e.cumreduce(t,(function(e,t){return e+t}))},e.cumprod=function(t){return e.cumreduce(t,(function(e,t){return e*t}))},e.diff=function(e){var t,n=[],r=e.length;for(t=1;t<r;t++)n.push(e[t]-e[t-1]);return n},e.rank=function(e){var t,n=[],o={};for(t=0;t<e.length;t++)o[l=e[t]]?o[l]++:(o[l]=1,n.push(l));var i=n.sort(r),a={},s=1;for(t=0;t<i.length;t++){var l,u=o[l=i[t]],c=(s+(s+u-1))/2;a[l]=c,s+=u}return e.map((function(e){return a[e]}))},e.mode=function(e){var t,n=e.length,o=e.slice().sort(r),i=1,a=0,s=0,l=[];for(t=0;t<n;t++)o[t]===o[t+1]?i++:(i>a?(l=[o[t]],a=i,s=0):i===a&&(l.push(o[t]),s++),i=1);return 0===s?l[0]:l},e.range=function(t){return e.max(t)-e.min(t)},e.variance=function(t,n){return e.sumsqerr(t)/(t.length-(n?1:0))},e.pooledvariance=function(t){return t.reduce((function(t,n){return t+e.sumsqerr(n)}),0)/(t.reduce((function(e,t){return e+t.length}),0)-t.length)},e.deviation=function(t){for(var n=e.mean(t),r=t.length,o=new Array(r),i=0;i<r;i++)o[i]=t[i]-n;return o},e.stdev=function(n,r){return t.sqrt(e.variance(n,r))},e.pooledstdev=function(n){return t.sqrt(e.pooledvariance(n))},e.meandev=function(n){for(var r=e.mean(n),o=[],i=n.length-1;i>=0;i--)o.push(t.abs(n[i]-r));return e.mean(o)},e.meddev=function(n){for(var r=e.median(n),o=[],i=n.length-1;i>=0;i--)o.push(t.abs(n[i]-r));return e.median(o)},e.coeffvar=function(t){return e.stdev(t)/e.mean(t)},e.quartiles=function(e){var n=e.length,o=e.slice().sort(r);return[o[t.round(n/4)-1],o[t.round(n/2)-1],o[t.round(3*n/4)-1]]},e.quantiles=function(e,n,i,a){var s,l,u,c,f,d=e.slice().sort(r),h=[n.length],m=e.length;for(void 0===i&&(i=3/8),void 0===a&&(a=3/8),s=0;s<n.length;s++)u=m*(l=n[s])+(i+l*(1-i-a)),c=t.floor(o(u,1,m-1)),f=o(u-c,0,1),h[s]=(1-f)*d[c-1]+f*d[c];return h},e.percentile=function(e,t,n){var o=e.slice().sort(r),i=t*(o.length+(n?1:-1))+(n?0:1),a=parseInt(i),s=i-a;return a+1<o.length?o[a-1]+s*(o[a]-o[a-1]):o[a-1]},e.percentileOfScore=function(e,t,n){var r,o,i=0,a=e.length,s=!1;for("strict"===n&&(s=!0),o=0;o<a;o++)r=e[o],(s&&r<t||!s&&r<=t)&&i++;return i/a},e.histogram=function(n,r){r=r||4;var o,i=e.min(n),a=(e.max(n)-i)/r,s=n.length,l=[];for(o=0;o<r;o++)l[o]=0;for(o=0;o<s;o++)l[t.min(t.floor((n[o]-i)/a),r-1)]+=1;return l},e.covariance=function(t,n){var r,o=e.mean(t),i=e.mean(n),a=t.length,s=new Array(a);for(r=0;r<a;r++)s[r]=(t[r]-o)*(n[r]-i);return e.sum(s)/(a-1)},e.corrcoeff=function(t,n){return e.covariance(t,n)/e.stdev(t,1)/e.stdev(n,1)},e.spearmancoeff=function(t,n){return t=e.rank(t),n=e.rank(n),e.corrcoeff(t,n)},e.stanMoment=function(n,r){for(var o=e.mean(n),i=e.stdev(n),a=n.length,s=0,l=0;l<a;l++)s+=t.pow((n[l]-o)/i,r);return s/n.length},e.skewness=function(t){return e.stanMoment(t,3)},e.kurtosis=function(t){return e.stanMoment(t,4)-3};var i=e.prototype;!function(t){for(var r=0;r<t.length;r++)!function(t){i[t]=function(r,o){var a=[],s=0,l=this;if(n(r)&&(o=r,r=!1),o)return setTimeout((function(){o.call(l,i[t].call(l,r))})),this;if(this.length>1){for(l=!0===r?this:this.transpose();s<l.length;s++)a[s]=e[t](l[s]);return a}return e[t](this[0],r)}}(t[r])}("cumsum cumprod".split(" ")),function(t){for(var r=0;r<t.length;r++)!function(t){i[t]=function(r,o){var a=[],s=0,l=this;if(n(r)&&(o=r,r=!1),o)return setTimeout((function(){o.call(l,i[t].call(l,r))})),this;if(this.length>1){for("sumrow"!==t&&(l=!0===r?this:this.transpose());s<l.length;s++)a[s]=e[t](l[s]);return!0===r?e[t](e.utils.toVector(a)):a}return e[t](this[0],r)}}(t[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(t){for(var r=0;r<t.length;r++)!function(t){i[t]=function(){var r,o=[],a=0,s=this,l=Array.prototype.slice.call(arguments);if(n(l[l.length-1])){r=l[l.length-1];var u=l.slice(0,l.length-1);return setTimeout((function(){r.call(s,i[t].apply(s,u))})),this}r=void 0;var c=function(n){return e[t].apply(s,[n].concat(l))};if(this.length>1){for(s=s.transpose();a<s.length;a++)o[a]=c(s[a]);return o}return c(this[0])}}(t[r])}("quantiles percentileOfScore".split(" "))}(t,Math),function(e,t){e.gammaln=function(e){var n,r,o,i=0,a=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],s=1.000000000190015;for(o=(r=n=e)+5.5,o-=(n+.5)*t.log(o);i<6;i++)s+=a[i]/++r;return t.log(2.5066282746310007*s/n)-o},e.loggam=function(e){var n,r,o,i,a,s,l,u=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=e,l=0,1==e||2==e)return 0;for(e<=7&&(n=e+(l=t.floor(7-e))),r=1/(n*n),o=2*t.PI,a=u[9],s=8;s>=0;s--)a*=r,a+=u[s];if(i=a/n+.5*t.log(o)+(n-.5)*t.log(n)-n,e<=7)for(s=1;s<=l;s++)i-=t.log(n-1),n-=1;return i},e.gammafn=function(e){var n,r,o,i,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,u=0,c=0,f=0,d=e;if(e>171.6243769536076)return 1/0;if(d<=0){if(!(i=d%1+36e-17))return 1/0;l=(1&d?-1:1)*t.PI/t.sin(t.PI*i),d=1-d}for(o=d,r=d<1?d++:(d-=u=(0|d)-1)-1,n=0;n<8;++n)f=(f+a[n])*r,c=c*r+s[n];if(i=f/c+1,o<d)i/=o;else if(o>d)for(n=0;n<u;++n)i*=d,d++;return l&&(i=l/i),i},e.gammap=function(t,n){return e.lowRegGamma(t,n)*e.gammafn(t)},e.lowRegGamma=function(n,r){var o,i=e.gammaln(n),a=n,s=1/n,l=s,u=r+1-n,c=1/1e-30,f=1/u,d=f,h=1,m=-~(8.5*t.log(n>=1?n:1/n)+.4*n+17);if(r<0||n<=0)return NaN;if(r<n+1){for(;h<=m;h++)s+=l*=r/++a;return s*t.exp(-r+n*t.log(r)-i)}for(;h<=m;h++)d*=(f=1/(f=(o=-h*(h-n))*f+(u+=2)))*(c=u+o/c);return 1-d*t.exp(-r+n*t.log(r)-i)},e.factorialln=function(t){return t<0?NaN:e.gammaln(t+1)},e.factorial=function(t){return t<0?NaN:e.gammafn(t+1)},e.combination=function(n,r){return n>170||r>170?t.exp(e.combinationln(n,r)):e.factorial(n)/e.factorial(r)/e.factorial(n-r)},e.combinationln=function(t,n){return e.factorialln(t)-e.factorialln(n)-e.factorialln(t-n)},e.permutation=function(t,n){return e.factorial(t)/e.factorial(t-n)},e.betafn=function(n,r){if(!(n<=0||r<=0))return n+r>170?t.exp(e.betaln(n,r)):e.gammafn(n)*e.gammafn(r)/e.gammafn(n+r)},e.betaln=function(t,n){return e.gammaln(t)+e.gammaln(n)-e.gammaln(t+n)},e.betacf=function(e,n,r){var o,i,a,s,l=1e-30,u=1,c=n+r,f=n+1,d=n-1,h=1,m=1-c*e/f;for(t.abs(m)<l&&(m=l),s=m=1/m;u<=100&&(m=1+(i=u*(r-u)*e/((d+(o=2*u))*(n+o)))*m,t.abs(m)<l&&(m=l),h=1+i/h,t.abs(h)<l&&(h=l),s*=(m=1/m)*h,m=1+(i=-(n+u)*(c+u)*e/((n+o)*(f+o)))*m,t.abs(m)<l&&(m=l),h=1+i/h,t.abs(h)<l&&(h=l),s*=a=(m=1/m)*h,!(t.abs(a-1)<3e-7));u++);return s},e.gammapinv=function(n,r){var o,i,a,s,l,u,c=0,f=r-1,d=e.gammaln(r);if(n>=1)return t.max(100,r+100*t.sqrt(r));if(n<=0)return 0;for(r>1?(l=t.log(f),u=t.exp(f*(l-1)-d),s=n<.5?n:1-n,o=(2.30753+.27061*(i=t.sqrt(-2*t.log(s))))/(1+i*(.99229+.04481*i))-i,n<.5&&(o=-o),o=t.max(.001,r*t.pow(1-1/(9*r)-o/(3*t.sqrt(r)),3))):o=n<(i=1-r*(.253+.12*r))?t.pow(n/i,1/r):1-t.log(1-(n-i)/(1-i));c<12;c++){if(o<=0)return 0;if((o-=i=(a=(e.lowRegGamma(r,o)-n)/(i=r>1?u*t.exp(-(o-f)+f*(t.log(o)-l)):t.exp(-o+f*t.log(o)-d)))/(1-.5*t.min(1,a*((r-1)/o-1))))<=0&&(o=.5*(o+i)),t.abs(i)<1e-8*o)break}return o},e.erf=function(e){var n,r,o,i,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,u=0,c=0;for(e<0&&(e=-e,l=!0),r=4*(n=2/(2+e))-2;s>0;s--)o=u,u=r*u-c+a[s],c=o;return i=n*t.exp(-e*e+.5*(a[0]+r*u)-c),l?i-1:1-i},e.erfc=function(t){return 1-e.erf(t)},e.erfcinv=function(n){var r,o,i,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*(i=t.sqrt(-2*t.log(a/2))))/(1+i*(.99229+.04481*i))-i);s<2;s++)r+=(o=e.erfc(r)-a)/(1.1283791670955126*t.exp(-r*r)-r*o);return n<1?r:-r},e.ibetainv=function(n,r,o){var i,a,s,l,u,c,f,d,h,m,p=r-1,g=o-1,v=0;if(n<=0)return 0;if(n>=1)return 1;for(r>=1&&o>=1?(s=n<.5?n:1-n,c=(2.30753+.27061*(l=t.sqrt(-2*t.log(s))))/(1+l*(.99229+.04481*l))-l,n<.5&&(c=-c),f=(c*c-3)/6,d=2/(1/(2*r-1)+1/(2*o-1)),h=c*t.sqrt(f+d)/d-(1/(2*o-1)-1/(2*r-1))*(f+5/6-2/(3*d)),c=r/(r+o*t.exp(2*h))):(i=t.log(r/(r+o)),a=t.log(o/(r+o)),c=n<(l=t.exp(r*i)/r)/(h=l+(u=t.exp(o*a)/o))?t.pow(r*h*n,1/r):1-t.pow(o*h*(1-n),1/o)),m=-e.gammaln(r)-e.gammaln(o)+e.gammaln(r+o);v<10;v++){if(0===c||1===c)return c;if((c-=l=(u=(e.ibeta(c,r,o)-n)/(l=t.exp(p*t.log(c)+g*t.log(1-c)+m)))/(1-.5*t.min(1,u*(p/c-g/(1-c)))))<=0&&(c=.5*(c+l)),c>=1&&(c=.5*(c+l+1)),t.abs(l)<1e-8*c&&v>0)break}return c},e.ibeta=function(n,r,o){var i=0===n||1===n?0:t.exp(e.gammaln(r+o)-e.gammaln(r)-e.gammaln(o)+r*t.log(n)+o*t.log(1-n));return!(n<0||n>1)&&(n<(r+1)/(r+o+2)?i*e.betacf(n,r,o)/r:1-i*e.betacf(1-n,o,r)/o)},e.randn=function(n,r){var o,i,a,s,l;if(r||(r=n),n)return e.create(n,r,(function(){return e.randn()}));do{o=e._random_fn(),i=1.7156*(e._random_fn()-.5),l=(a=o-.449871)*a+(s=t.abs(i)+.386595)*(.196*s-.25472*a)}while(l>.27597&&(l>.27846||i*i>-4*t.log(o)*o*o));return i/o},e.randg=function(n,r,o){var i,a,s,l,u,c,f=n;if(o||(o=r),n||(n=1),r)return(c=e.zeros(r,o)).alter((function(){return e.randg(n)})),c;n<1&&(n+=1),i=n-1/3,a=1/t.sqrt(9*i);do{do{l=1+a*(u=e.randn())}while(l<=0);l*=l*l,s=e._random_fn()}while(s>1-.331*t.pow(u,4)&&t.log(s)>.5*u*u+i*(1-l+t.log(l)));if(n==f)return i*l;do{s=e._random_fn()}while(0===s);return t.pow(s,1/f)*i*l},function(t){for(var n=0;n<t.length;n++)!function(t){e.fn[t]=function(){return e(e.map(this,(function(n){return e[t](n)})))}}(t[n])}("gammaln gammafn factorial factorialln".split(" ")),function(t){for(var n=0;n<t.length;n++)!function(t){e.fn[t]=function(){return e(e[t].apply(null,arguments))}}(t[n])}("randn".split(" "))}(t,Math),function(e,t){function n(e,n,r,o){for(var i,a=0,s=1,l=1,u=1,c=0,f=0;t.abs((l-f)/l)>o;)f=l,s=u+(i=-(n+c)*(n+r+c)*e/(n+2*c)/(n+2*c+1))*s,l=(a=l+i*a)+(i=(c+=1)*(r-c)*e/(n+2*c-1)/(n+2*c))*l,a/=u=s+i*u,s/=u,l/=u,u=1;return l/n}function r(n,r,o){var i=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],a=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],s=.5*n;if(s>=8)return 1;var l,u=2*e.normal.cdf(s,0,1,1,0)-1;u=u>=t.exp(-50/o)?t.pow(u,o):0;for(var c=s,f=(8-s)/(l=n>3?2:3),d=c+f,h=0,m=o-1,p=1;p<=l;p++){for(var g=0,v=.5*(d+c),_=.5*(d-c),T=1;T<=12;T++){var w,E=v+_*(6<T?i[(w=12-T+1)-1]:-i[(w=T)-1]),I=E*E;if(I>60)break;var y=2*e.normal.cdf(E,0,1,1,0)*.5-2*e.normal.cdf(E,n,1,1,0)*.5;y>=t.exp(-30/m)&&(g+=y=a[w-1]*t.exp(-.5*I)*t.pow(y,m))}h+=g*=2*_*o/t.sqrt(2*t.PI),c=d,d+=f}return(u+=h)<=t.exp(-30/r)?0:(u=t.pow(u,r))>=1?1:u}!function(t){for(var n=0;n<t.length;n++)!function(t){e[t]=function e(t,n,r){return this instanceof e?(this._a=t,this._b=n,this._c=r,this):new e(t,n,r)},e.fn[t]=function(n,r,o){var i=e[t](n,r,o);return i.data=this,i},e[t].prototype.sample=function(n){var r=this._a,o=this._b,i=this._c;return n?e.alter(n,(function(){return e[t].sample(r,o,i)})):e[t].sample(r,o,i)},function(n){for(var r=0;r<n.length;r++)!function(n){e[t].prototype[n]=function(r){var o=this._a,i=this._b,a=this._c;return r||0===r||(r=this.data),"number"!=typeof r?e.fn.map.call(r,(function(r){return e[t][n](r,o,i,a)})):e[t][n](r,o,i,a)}}(n[r])}("pdf cdf inv".split(" ")),function(n){for(var r=0;r<n.length;r++)!function(n){e[t].prototype[n]=function(){return e[t][n](this._a,this._b,this._c)}}(n[r])}("mean median mode variance".split(" "))}(t[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(" ")),e.extend(e.beta,{pdf:function(n,r,o){return n>1||n<0?0:1==r&&1==o?1:r<512&&o<512?t.pow(n,r-1)*t.pow(1-n,o-1)/e.betafn(r,o):t.exp((r-1)*t.log(n)+(o-1)*t.log(1-n)-e.betaln(r,o))},cdf:function(t,n,r){return t>1||t<0?1*(t>1):e.ibeta(t,n,r)},inv:function(t,n,r){return e.ibetainv(t,n,r)},mean:function(e,t){return e/(e+t)},median:function(t,n){return e.ibetainv(.5,t,n)},mode:function(e,t){return(e-1)/(e+t-2)},sample:function(t,n){var r=e.randg(t);return r/(r+e.randg(n))},variance:function(e,n){return e*n/(t.pow(e+n,2)*(e+n+1))}}),e.extend(e.centralF,{pdf:function(n,r,o){var i;return n<0?0:r<=2?0===n&&r<2?1/0:0===n&&2===r?1:1/e.betafn(r/2,o/2)*t.pow(r/o,r/2)*t.pow(n,r/2-1)*t.pow(1+r/o*n,-(r+o)/2):(i=r*n/(o+n*r),r*(o/(o+n*r))/2*e.binomial.pdf((r-2)/2,(r+o-2)/2,i))},cdf:function(t,n,r){return t<0?0:e.ibeta(n*t/(n*t+r),n/2,r/2)},inv:function(t,n,r){return r/(n*(1/e.ibetainv(t,n/2,r/2)-1))},mean:function(e,t){return t>2?t/(t-2):void 0},mode:function(e,t){return e>2?t*(e-2)/(e*(t+2)):void 0},sample:function(t,n){return 2*e.randg(t/2)/t/(2*e.randg(n/2)/n)},variance:function(e,t){if(!(t<=4))return 2*t*t*(e+t-2)/(e*(t-2)*(t-2)*(t-4))}}),e.extend(e.cauchy,{pdf:function(e,n,r){return r<0?0:r/(t.pow(e-n,2)+t.pow(r,2))/t.PI},cdf:function(e,n,r){return t.atan((e-n)/r)/t.PI+.5},inv:function(e,n,r){return n+r*t.tan(t.PI*(e-.5))},median:function(e){return e},mode:function(e){return e},sample:function(n,r){return e.randn()*t.sqrt(1/(2*e.randg(.5)))*r+n}}),e.extend(e.chisquare,{pdf:function(n,r){return n<0?0:0===n&&2===r?.5:t.exp((r/2-1)*t.log(n)-n/2-r/2*t.log(2)-e.gammaln(r/2))},cdf:function(t,n){return t<0?0:e.lowRegGamma(n/2,t/2)},inv:function(t,n){return 2*e.gammapinv(t,.5*n)},mean:function(e){return e},median:function(e){return e*t.pow(1-2/(9*e),3)},mode:function(e){return e-2>0?e-2:0},sample:function(t){return 2*e.randg(t/2)},variance:function(e){return 2*e}}),e.extend(e.exponential,{pdf:function(e,n){return e<0?0:n*t.exp(-n*e)},cdf:function(e,n){return e<0?0:1-t.exp(-n*e)},inv:function(e,n){return-t.log(1-e)/n},mean:function(e){return 1/e},median:function(e){return 1/e*t.log(2)},mode:function(){return 0},sample:function(n){return-1/n*t.log(e._random_fn())},variance:function(e){return t.pow(e,-2)}}),e.extend(e.gamma,{pdf:function(n,r,o){return n<0?0:0===n&&1===r?1/o:t.exp((r-1)*t.log(n)-n/o-e.gammaln(r)-r*t.log(o))},cdf:function(t,n,r){return t<0?0:e.lowRegGamma(n,t/r)},inv:function(t,n,r){return e.gammapinv(t,n)*r},mean:function(e,t){return e*t},mode:function(e,t){if(e>1)return(e-1)*t},sample:function(t,n){return e.randg(t)*n},variance:function(e,t){return e*t*t}}),e.extend(e.invgamma,{pdf:function(n,r,o){return n<=0?0:t.exp(-(r+1)*t.log(n)-o/n-e.gammaln(r)+r*t.log(o))},cdf:function(t,n,r){return t<=0?0:1-e.lowRegGamma(n,r/t)},inv:function(t,n,r){return r/e.gammapinv(1-t,n)},mean:function(e,t){return e>1?t/(e-1):void 0},mode:function(e,t){return t/(e+1)},sample:function(t,n){return n/e.randg(t)},variance:function(e,t){if(!(e<=2))return t*t/((e-1)*(e-1)*(e-2))}}),e.extend(e.kumaraswamy,{pdf:function(e,n,r){return 0===e&&1===n?r:1===e&&1===r?n:t.exp(t.log(n)+t.log(r)+(n-1)*t.log(e)+(r-1)*t.log(1-t.pow(e,n)))},cdf:function(e,n,r){return e<0?0:e>1?1:1-t.pow(1-t.pow(e,n),r)},inv:function(e,n,r){return t.pow(1-t.pow(1-e,1/r),1/n)},mean:function(t,n){return n*e.gammafn(1+1/t)*e.gammafn(n)/e.gammafn(1+1/t+n)},median:function(e,n){return t.pow(1-t.pow(2,-1/n),1/e)},mode:function(e,n){if(e>=1&&n>=1&&1!==e&&1!==n)return t.pow((e-1)/(e*n-1),1/e)},variance:function(){throw new Error("variance not yet implemented")}}),e.extend(e.lognormal,{pdf:function(e,n,r){return e<=0?0:t.exp(-t.log(e)-.5*t.log(2*t.PI)-t.log(r)-t.pow(t.log(e)-n,2)/(2*r*r))},cdf:function(n,r,o){return n<0?0:.5+.5*e.erf((t.log(n)-r)/t.sqrt(2*o*o))},inv:function(n,r,o){return t.exp(-1.4142135623730951*o*e.erfcinv(2*n)+r)},mean:function(e,n){return t.exp(e+n*n/2)},median:function(e){return t.exp(e)},mode:function(e,n){return t.exp(e-n*n)},sample:function(n,r){return t.exp(e.randn()*r+n)},variance:function(e,n){return(t.exp(n*n)-1)*t.exp(2*e+n*n)}}),e.extend(e.noncentralt,{pdf:function(n,r,o){return t.abs(o)<1e-14?e.studentt.pdf(n,r):t.abs(n)<1e-14?t.exp(e.gammaln((r+1)/2)-o*o/2-.5*t.log(t.PI*r)-e.gammaln(r/2)):r/n*(e.noncentralt.cdf(n*t.sqrt(1+2/r),r+2,o)-e.noncentralt.cdf(n,r,o))},cdf:function(n,r,o){var i=1e-14;if(t.abs(o)<i)return e.studentt.cdf(n,r);var a=!1;n<0&&(a=!0,o=-o);for(var s=e.normal.cdf(-o,0,1),l=i+1,u=l,c=n*n/(n*n+r),f=0,d=t.exp(-o*o/2),h=t.exp(-o*o/2-.5*t.log(2)-e.gammaln(1.5))*o;f<200||u>i||l>i;)u=l,f>0&&(d*=o*o/(2*f),h*=o*o/(2*(f+.5))),s+=.5*(l=d*e.beta.cdf(c,f+.5,r/2)+h*e.beta.cdf(c,f+1,r/2)),f++;return a?1-s:s}}),e.extend(e.normal,{pdf:function(e,n,r){return t.exp(-.5*t.log(2*t.PI)-t.log(r)-t.pow(e-n,2)/(2*r*r))},cdf:function(n,r,o){return.5*(1+e.erf((n-r)/t.sqrt(2*o*o)))},inv:function(t,n,r){return-1.4142135623730951*r*e.erfcinv(2*t)+n},mean:function(e){return e},median:function(e){return e},mode:function(e){return e},sample:function(t,n){return e.randn()*n+t},variance:function(e,t){return t*t}}),e.extend(e.pareto,{pdf:function(e,n,r){return e<n?0:r*t.pow(n,r)/t.pow(e,r+1)},cdf:function(e,n,r){return e<n?0:1-t.pow(n/e,r)},inv:function(e,n,r){return n/t.pow(1-e,1/r)},mean:function(e,n){if(!(n<=1))return n*t.pow(e,n)/(n-1)},median:function(e,n){return e*(n*t.SQRT2)},mode:function(e){return e},variance:function(e,n){if(!(n<=2))return e*e*n/(t.pow(n-1,2)*(n-2))}}),e.extend(e.studentt,{pdf:function(n,r){return r=r>1e100?1e100:r,1/(t.sqrt(r)*e.betafn(.5,r/2))*t.pow(1+n*n/r,-(r+1)/2)},cdf:function(n,r){var o=r/2;return e.ibeta((n+t.sqrt(n*n+r))/(2*t.sqrt(n*n+r)),o,o)},inv:function(n,r){var o=e.ibetainv(2*t.min(n,1-n),.5*r,.5);return o=t.sqrt(r*(1-o)/o),n>.5?o:-o},mean:function(e){return e>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(n){return e.randn()*t.sqrt(n/(2*e.randg(n/2)))},variance:function(e){return e>2?e/(e-2):e>1?1/0:void 0}}),e.extend(e.weibull,{pdf:function(e,n,r){return e<0||n<0||r<0?0:r/n*t.pow(e/n,r-1)*t.exp(-t.pow(e/n,r))},cdf:function(e,n,r){return e<0?0:1-t.exp(-t.pow(e/n,r))},inv:function(e,n,r){return n*t.pow(-t.log(1-e),1/r)},mean:function(t,n){return t*e.gammafn(1+1/n)},median:function(e,n){return e*t.pow(t.log(2),1/n)},mode:function(e,n){return n<=1?0:e*t.pow((n-1)/n,1/n)},sample:function(n,r){return n*t.pow(-t.log(e._random_fn()),1/r)},variance:function(n,r){return n*n*e.gammafn(1+2/r)-t.pow(e.weibull.mean(n,r),2)}}),e.extend(e.uniform,{pdf:function(e,t,n){return e<t||e>n?0:1/(n-t)},cdf:function(e,t,n){return e<t?0:e<n?(e-t)/(n-t):1},inv:function(e,t,n){return t+e*(n-t)},mean:function(e,t){return.5*(e+t)},median:function(t,n){return e.mean(t,n)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(t,n){return t/2+n/2+(n/2-t/2)*(2*e._random_fn()-1)},variance:function(e,n){return t.pow(n-e,2)/12}}),e.extend(e.binomial,{pdf:function(n,r,o){return 0===o||1===o?r*o===n?1:0:e.combination(r,n)*t.pow(o,n)*t.pow(1-o,r-n)},cdf:function(r,o,i){var a,s=1e-10;if(r<0)return 0;if(r>=o)return 1;if(i<0||i>1||o<=0)return NaN;var l=i,u=(r=t.floor(r))+1,c=o-r,f=u+c,d=t.exp(e.gammaln(f)-e.gammaln(c)-e.gammaln(u)+u*t.log(l)+c*t.log(1-l));return a=l<(u+1)/(f+2)?d*n(l,u,c,s):1-d*n(1-l,c,u,s),t.round(1/s*(1-a))/(1/s)}}),e.extend(e.negbin,{pdf:function(n,r,o){return n===n>>>0&&(n<0?0:e.combination(n+r-1,r-1)*t.pow(1-o,n)*t.pow(o,r))},cdf:function(t,n,r){var o=0,i=0;if(t<0)return 0;for(;i<=t;i++)o+=e.negbin.pdf(i,n,r);return o}}),e.extend(e.hypgeom,{pdf:function(n,r,o,i){if(n!=n|0)return!1;if(n<0||n<o-(r-i))return 0;if(n>i||n>o)return 0;if(2*o>r)return 2*i>r?e.hypgeom.pdf(r-o-i+n,r,r-o,r-i):e.hypgeom.pdf(i-n,r,r-o,i);if(2*i>r)return e.hypgeom.pdf(o-n,r,o,r-i);if(o<i)return e.hypgeom.pdf(n,r,i,o);for(var a=1,s=0,l=0;l<n;l++){for(;a>1&&s<i;)a*=1-o/(r-s),s++;a*=(i-l)*(o-l)/((l+1)*(r-o-i+l+1))}for(;s<i;s++)a*=1-o/(r-s);return t.min(1,t.max(0,a))},cdf:function(n,r,o,i){if(n<0||n<o-(r-i))return 0;if(n>=i||n>=o)return 1;if(2*o>r)return 2*i>r?e.hypgeom.cdf(r-o-i+n,r,r-o,r-i):1-e.hypgeom.cdf(i-n-1,r,r-o,i);if(2*i>r)return 1-e.hypgeom.cdf(o-n-1,r,o,r-i);if(o<i)return e.hypgeom.cdf(n,r,i,o);for(var a=1,s=1,l=0,u=0;u<n;u++){for(;a>1&&l<i;){var c=1-o/(r-l);s*=c,a*=c,l++}a+=s*=(i-u)*(o-u)/((u+1)*(r-o-i+u+1))}for(;l<i;l++)a*=1-o/(r-l);return t.min(1,t.max(0,a))}}),e.extend(e.poisson,{pdf:function(n,r){return r<0||n%1!=0||n<0?0:t.pow(r,n)*t.exp(-r)/e.factorial(n)},cdf:function(t,n){var r=[],o=0;if(t<0)return 0;for(;o<=t;o++)r.push(e.poisson.pdf(o,n));return e.sum(r)},mean:function(e){return e},variance:function(e){return e},sampleSmall:function(n){var r=1,o=0,i=t.exp(-n);do{o++,r*=e._random_fn()}while(r>i);return o-1},sampleLarge:function(n){var r,o,i,a,s,l,u,c,f,d,h=n;for(a=t.sqrt(h),s=t.log(h),l=.02483*(u=.931+2.53*a)-.059,c=1.1239+1.1328/(u-3.4),f=.9277-3.6224/(u-2);;){if(o=t.random()-.5,i=t.random(),d=.5-t.abs(o),r=t.floor((2*l/d+u)*o+h+.43),d>=.07&&i<=f)return r;if(!(r<0||d<.013&&i>d)&&t.log(i)+t.log(c)-t.log(l/(d*d)+u)<=r*s-h-e.loggam(r+1))return r}},sample:function(e){return e<10?this.sampleSmall(e):this.sampleLarge(e)}}),e.extend(e.triangular,{pdf:function(e,t,n,r){return n<=t||r<t||r>n?NaN:e<t||e>n?0:e<r?2*(e-t)/((n-t)*(r-t)):e===r?2/(n-t):2*(n-e)/((n-t)*(n-r))},cdf:function(e,n,r,o){return r<=n||o<n||o>r?NaN:e<=n?0:e>=r?1:e<=o?t.pow(e-n,2)/((r-n)*(o-n)):1-t.pow(r-e,2)/((r-n)*(r-o))},inv:function(e,n,r,o){return r<=n||o<n||o>r?NaN:e<=(o-n)/(r-n)?n+(r-n)*t.sqrt(e*((o-n)/(r-n))):n+(r-n)*(1-t.sqrt((1-e)*(1-(o-n)/(r-n))))},mean:function(e,t,n){return(e+t+n)/3},median:function(e,n,r){return r<=(e+n)/2?n-t.sqrt((n-e)*(n-r))/t.sqrt(2):r>(e+n)/2?e+t.sqrt((n-e)*(r-e))/t.sqrt(2):void 0},mode:function(e,t,n){return n},sample:function(n,r,o){var i=e._random_fn();return i<(o-n)/(r-n)?n+t.sqrt(i*(r-n)*(o-n)):r-t.sqrt((1-i)*(r-n)*(r-o))},variance:function(e,t,n){return(e*e+t*t+n*n-e*t-e*n-t*n)/18}}),e.extend(e.arcsine,{pdf:function(e,n,r){return r<=n?NaN:e<=n||e>=r?0:2/t.PI*t.pow(t.pow(r-n,2)-t.pow(2*e-n-r,2),-.5)},cdf:function(e,n,r){return e<n?0:e<r?2/t.PI*t.asin(t.sqrt((e-n)/(r-n))):1},inv:function(e,n,r){return n+(.5-.5*t.cos(t.PI*e))*(r-n)},mean:function(e,t){return t<=e?NaN:(e+t)/2},median:function(e,t){return t<=e?NaN:(e+t)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(n,r){return(n+r)/2+(r-n)/2*t.sin(2*t.PI*e.uniform.sample(0,1))},variance:function(e,n){return n<=e?NaN:t.pow(n-e,2)/8}}),e.extend(e.laplace,{pdf:function(e,n,r){return r<=0?0:t.exp(-t.abs(e-n)/r)/(2*r)},cdf:function(e,n,r){return r<=0?0:e<n?.5*t.exp((e-n)/r):1-.5*t.exp(-(e-n)/r)},mean:function(e){return e},median:function(e){return e},mode:function(e){return e},variance:function(e,t){return 2*t*t},sample:function(n,r){var o,i=e._random_fn()-.5;return n-r*((o=i)/t.abs(o))*t.log(1-2*t.abs(i))}}),e.extend(e.tukey,{cdf:function(n,o,i){var a=o,s=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],l=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(n<=0)return 0;if(i<2||a<2)return NaN;if(!Number.isFinite(n))return 1;if(i>25e3)return r(n,1,a);var u,c=.5*i,f=c*t.log(i)-i*t.log(2)-e.gammaln(c),d=c-1,h=.25*i;u=i<=100?1:i<=800?.5:i<=5e3?.25:.125,f+=t.log(u);for(var m=0,p=1;p<=50;p++){for(var g=0,v=(2*p-1)*u,_=1;_<=16;_++){var T,w;8<_?(T=_-8-1,w=f+d*t.log(v+s[T]*u)-(s[T]*u+v)*h):(T=_-1,w=f+d*t.log(v-s[T]*u)+(s[T]*u-v)*h),w>=-30&&(g+=r(8<_?n*t.sqrt(.5*(s[T]*u+v)):n*t.sqrt(.5*(-s[T]*u+v)),1,a)*l[T]*t.exp(w))}if(p*u>=1&&g<=1e-14)break;m+=g}if(g>1e-14)throw new Error("tukey.cdf failed to converge");return m>1&&(m=1),m},inv:function(n,r,o){if(o<2||r<2)return NaN;if(n<0||n>1)return NaN;if(0===n)return 0;if(1===n)return 1/0;var i,a=function(e,n,r){var o=.5-.5*e,i=t.sqrt(t.log(1/(o*o))),a=i+((((-453642210148e-16*i-.204231210125)*i-.342242088547)*i-1)*i+.322232421088)/((((.0038560700634*i+.10353775285)*i+.531103462366)*i+.588581570495)*i+.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*t.log(n-1)+1.4142)}(n,r,o),s=e.tukey.cdf(a,r,o)-n;i=s>0?t.max(0,a-1):a+1;for(var l,u=e.tukey.cdf(i,r,o)-n,c=1;c<50;c++)if(l=i-u*(i-a)/(u-s),s=u,a=i,l<0&&(l=0,u=-n),u=e.tukey.cdf(l,r,o)-n,i=l,t.abs(i-a)<1e-4)return l;throw new Error("tukey.inv failed to converge")}})}(t,Math),function(e,t){var n,r,o=Array.prototype.push,i=e.utils.isArray;function a(t){return i(t)||t instanceof e}e.extend({add:function(t,n){return a(n)?(a(n[0])||(n=[n]),e.map(t,(function(e,t,r){return e+n[t][r]}))):e.map(t,(function(e){return e+n}))},subtract:function(t,n){return a(n)?(a(n[0])||(n=[n]),e.map(t,(function(e,t,r){return e-n[t][r]||0}))):e.map(t,(function(e){return e-n}))},divide:function(t,n){return a(n)?(a(n[0])||(n=[n]),e.multiply(t,e.inv(n))):e.map(t,(function(e){return e/n}))},multiply:function(t,n){var r,o,i,s,l,u,c,f;if(void 0===t.length&&void 0===n.length)return t*n;if(l=t.length,u=t[0].length,c=e.zeros(l,i=a(n)?n[0].length:u),f=0,a(n)){for(;f<i;f++)for(r=0;r<l;r++){for(s=0,o=0;o<u;o++)s+=t[r][o]*n[o][f];c[r][f]=s}return 1===l&&1===f?c[0][0]:c}return e.map(t,(function(e){return e*n}))},outer:function(t,n){return e.multiply(t.map((function(e){return[e]})),[n])},dot:function(t,n){a(t[0])||(t=[t]),a(n[0])||(n=[n]);for(var r,o,i=1===t[0].length&&1!==t.length?e.transpose(t):t,s=1===n[0].length&&1!==n.length?e.transpose(n):n,l=[],u=0,c=i.length,f=i[0].length;u<c;u++){for(l[u]=[],r=0,o=0;o<f;o++)r+=i[u][o]*s[u][o];l[u]=r}return 1===l.length?l[0]:l},pow:function(n,r){return e.map(n,(function(e){return t.pow(e,r)}))},exp:function(n){return e.map(n,(function(e){return t.exp(e)}))},log:function(n){return e.map(n,(function(e){return t.log(e)}))},abs:function(n){return e.map(n,(function(e){return t.abs(e)}))},norm:function(e,n){var r=0,o=0;for(isNaN(n)&&(n=2),a(e[0])&&(e=e[0]);o<e.length;o++)r+=t.pow(t.abs(e[o]),n);return t.pow(r,1/n)},angle:function(n,r){return t.acos(e.dot(n,r)/(e.norm(n)*e.norm(r)))},aug:function(e,t){var n,r=[];for(n=0;n<e.length;n++)r.push(e[n].slice());for(n=0;n<r.length;n++)o.apply(r[n],t[n]);return r},inv:function(t){for(var n,r=t.length,o=t[0].length,i=e.identity(r,o),a=e.gauss_jordan(t,i),s=[],l=0;l<r;l++)for(s[l]=[],n=o;n<a[0].length;n++)s[l][n-o]=a[l][n];return s},det:function e(t){if(2===t.length)return t[0][0]*t[1][1]-t[0][1]*t[1][0];for(var n=0,r=0;r<t.length;r++){for(var o=[],i=1;i<t.length;i++){o[i-1]=[];for(var a=0;a<t.length;a++)a<r?o[i-1][a]=t[i][a]:a>r&&(o[i-1][a-1]=t[i][a])}var s=r%2?-1:1;n+=e(o)*t[0][r]*s}return n},gauss_elimination:function(n,r){var o,i,a,s,l=0,u=0,c=n.length,f=n[0].length,d=1,h=0,m=[];for(o=(n=e.aug(n,r))[0].length,l=0;l<c;l++){for(i=n[l][l],u=l,s=l+1;s<f;s++)i<t.abs(n[s][l])&&(i=n[s][l],u=s);if(u!=l)for(s=0;s<o;s++)a=n[l][s],n[l][s]=n[u][s],n[u][s]=a;for(u=l+1;u<c;u++)for(d=n[u][l]/n[l][l],s=l;s<o;s++)n[u][s]=n[u][s]-d*n[l][s]}for(l=c-1;l>=0;l--){for(h=0,u=l+1;u<=c-1;u++)h+=m[u]*n[l][u];m[l]=(n[l][o-1]-h)/n[l][l]}return m},gauss_jordan:function(n,r){var o,i,a,s=e.aug(n,r),l=s.length,u=s[0].length,c=0;for(i=0;i<l;i++){var f=i;for(a=i+1;a<l;a++)t.abs(s[a][i])>t.abs(s[f][i])&&(f=a);var d=s[i];for(s[i]=s[f],s[f]=d,a=i+1;a<l;a++)for(c=s[a][i]/s[i][i],o=i;o<u;o++)s[a][o]-=s[i][o]*c}for(i=l-1;i>=0;i--){for(c=s[i][i],a=0;a<i;a++)for(o=u-1;o>i-1;o--)s[a][o]-=s[i][o]*s[a][i]/c;for(s[i][i]/=c,o=l;o<u;o++)s[i][o]/=c}return s},triaUpSolve:function(t,n){var r,o=t[0].length,i=e.zeros(1,o)[0],a=!1;return null!=n[0].length&&(n=n.map((function(e){return e[0]})),a=!0),e.arange(o-1,-1,-1).forEach((function(a){r=e.arange(a+1,o).map((function(e){return i[e]*t[a][e]})),i[a]=(n[a]-e.sum(r))/t[a][a]})),a?i.map((function(e){return[e]})):i},triaLowSolve:function(t,n){var r,o=t[0].length,i=e.zeros(1,o)[0],a=!1;return null!=n[0].length&&(n=n.map((function(e){return e[0]})),a=!0),e.arange(o).forEach((function(o){r=e.arange(o).map((function(e){return t[o][e]*i[e]})),i[o]=(n[o]-e.sum(r))/t[o][o]})),a?i.map((function(e){return[e]})):i},lu:function(t){var n,r=t.length,o=e.identity(r),i=e.zeros(t.length,t[0].length);return e.arange(r).forEach((function(e){i[0][e]=t[0][e]})),e.arange(1,r).forEach((function(a){e.arange(a).forEach((function(r){n=e.arange(r).map((function(e){return o[a][e]*i[e][r]})),o[a][r]=(t[a][r]-e.sum(n))/i[r][r]})),e.arange(a,r).forEach((function(r){n=e.arange(a).map((function(e){return o[a][e]*i[e][r]})),i[a][r]=t[n.length][r]-e.sum(n)}))})),[o,i]},cholesky:function(n){var r,o=n.length,i=e.zeros(n.length,n[0].length);return e.arange(o).forEach((function(a){r=e.arange(a).map((function(e){return t.pow(i[a][e],2)})),i[a][a]=t.sqrt(n[a][a]-e.sum(r)),e.arange(a+1,o).forEach((function(t){r=e.arange(a).map((function(e){return i[a][e]*i[t][e]})),i[t][a]=(n[a][t]-e.sum(r))/i[a][a]}))})),i},gauss_jacobi:function(n,r,o,i){for(var a,s,l,u,c=0,f=0,d=n.length,h=[],m=[],p=[];c<d;c++)for(h[c]=[],m[c]=[],p[c]=[],f=0;f<d;f++)c>f?(h[c][f]=n[c][f],m[c][f]=p[c][f]=0):c<f?(m[c][f]=n[c][f],h[c][f]=p[c][f]=0):(p[c][f]=n[c][f],h[c][f]=m[c][f]=0);for(l=e.multiply(e.multiply(e.inv(p),e.add(h,m)),-1),s=e.multiply(e.inv(p),r),a=o,u=e.add(e.multiply(l,o),s),c=2;t.abs(e.norm(e.subtract(u,a)))>i;)a=u,u=e.add(e.multiply(l,a),s),c++;return u},gauss_seidel:function(n,r,o,i){for(var a,s,l,u,c,f=0,d=n.length,h=[],m=[],p=[];f<d;f++)for(h[f]=[],m[f]=[],p[f]=[],a=0;a<d;a++)f>a?(h[f][a]=n[f][a],m[f][a]=p[f][a]=0):f<a?(m[f][a]=n[f][a],h[f][a]=p[f][a]=0):(p[f][a]=n[f][a],h[f][a]=m[f][a]=0);for(u=e.multiply(e.multiply(e.inv(e.add(p,h)),m),-1),l=e.multiply(e.inv(e.add(p,h)),r),s=o,c=e.add(e.multiply(u,o),l),f=2;t.abs(e.norm(e.subtract(c,s)))>i;)s=c,c=e.add(e.multiply(u,s),l),f+=1;return c},SOR:function(n,r,o,i,a){for(var s,l,u,c,f,d=0,h=n.length,m=[],p=[],g=[];d<h;d++)for(m[d]=[],p[d]=[],g[d]=[],s=0;s<h;s++)d>s?(m[d][s]=n[d][s],p[d][s]=g[d][s]=0):d<s?(p[d][s]=n[d][s],m[d][s]=g[d][s]=0):(g[d][s]=n[d][s],m[d][s]=p[d][s]=0);for(c=e.multiply(e.inv(e.add(g,e.multiply(m,a))),e.subtract(e.multiply(g,1-a),e.multiply(p,a))),u=e.multiply(e.multiply(e.inv(e.add(g,e.multiply(m,a))),r),a),l=o,f=e.add(e.multiply(c,o),u),d=2;t.abs(e.norm(e.subtract(f,l)))>i;)l=f,f=e.add(e.multiply(c,l),u),d++;return f},householder:function(n){for(var r,o,i,a,s=n.length,l=n[0].length,u=0,c=[],f=[];u<s-1;u++){for(r=0,a=u+1;a<l;a++)r+=n[a][u]*n[a][u];for(r=(n[u+1][u]>0?-1:1)*t.sqrt(r),o=t.sqrt((r*r-n[u+1][u]*r)/2),(c=e.zeros(s,1))[u+1][0]=(n[u+1][u]-r)/(2*o),i=u+2;i<s;i++)c[i][0]=n[i][u]/(2*o);f=e.subtract(e.identity(s,l),e.multiply(e.multiply(c,e.transpose(c)),2)),n=e.multiply(f,e.multiply(n,f))}return n},QR:(n=e.sum,r=e.arange,function(o){var i,a,s,l=o.length,u=o[0].length,c=e.zeros(u,u);for(o=e.copy(o),a=0;a<u;a++){for(c[a][a]=t.sqrt(n(r(l).map((function(e){return o[e][a]*o[e][a]})))),i=0;i<l;i++)o[i][a]=o[i][a]/c[a][a];for(s=a+1;s<u;s++)for(c[a][s]=n(r(l).map((function(e){return o[e][a]*o[e][s]}))),i=0;i<l;i++)o[i][s]=o[i][s]-o[i][a]*c[a][s]}return[o,c]}),lstsq:function(t,n){var r=!1;void 0===n[0].length&&(n=n.map((function(e){return[e]})),r=!0);var o=e.QR(t),i=o[0],a=o[1],s=t[0].length,l=e.slice(i,{col:{end:s}}),u=function(t){var n=(t=e.copy(t)).length,r=e.identity(n);return e.arange(n-1,-1,-1).forEach((function(n){e.sliceAssign(r,{row:n},e.divide(e.slice(r,{row:n}),t[n][n])),e.sliceAssign(t,{row:n},e.divide(e.slice(t,{row:n}),t[n][n])),e.arange(n).forEach((function(o){var i=e.multiply(t[o][n],-1),a=e.slice(t,{row:o}),s=e.multiply(e.slice(t,{row:n}),i);e.sliceAssign(t,{row:o},e.add(a,s));var l=e.slice(r,{row:o}),u=e.multiply(e.slice(r,{row:n}),i);e.sliceAssign(r,{row:o},e.add(l,u))}))})),r}(e.slice(a,{row:{end:s}})),c=e.transpose(l);void 0===c[0].length&&(c=[c]);var f=e.multiply(e.multiply(u,c),n);return void 0===f.length&&(f=[[f]]),r?f.map((function(e){return e[0]})):f},jacobi:function(n){for(var r,o,i,a,s,l,u,c=1,f=n.length,d=e.identity(f,f),h=[];1===c;){for(s=n[0][1],i=0,a=1,r=0;r<f;r++)for(o=0;o<f;o++)r!=o&&s<t.abs(n[r][o])&&(s=t.abs(n[r][o]),i=r,a=o);for(l=n[i][i]===n[a][a]?n[i][a]>0?t.PI/4:-t.PI/4:t.atan(2*n[i][a]/(n[i][i]-n[a][a]))/2,(u=e.identity(f,f))[i][i]=t.cos(l),u[i][a]=-t.sin(l),u[a][i]=t.sin(l),u[a][a]=t.cos(l),d=e.multiply(d,u),n=e.multiply(e.multiply(e.inv(u),n),u),c=0,r=1;r<f;r++)for(o=1;o<f;o++)r!=o&&t.abs(n[r][o])>.001&&(c=1)}for(r=0;r<f;r++)h.push(n[r][r]);return[d,h]},rungekutta:function(e,t,n,r,o,i){var a,s,l;if(2===i)for(;r<=n;)o+=((a=t*e(r,o))+(s=t*e(r+t,o+a)))/2,r+=t;if(4===i)for(;r<=n;)o+=((a=t*e(r,o))+2*(s=t*e(r+t/2,o+a/2))+2*(l=t*e(r+t/2,o+s/2))+t*e(r+t,o+l))/6,r+=t;return o},romberg:function(e,n,r,o){for(var i,a,s,l,u,c=0,f=(r-n)/2,d=[],h=[],m=[];c<o/2;){for(u=e(n),s=n,l=0;s<=r;s+=f,l++)d[l]=s;for(i=d.length,s=1;s<i-1;s++)u+=(s%2!=0?4:2)*e(d[s]);u=f/3*(u+e(r)),m[c]=u,f/=2,c++}for(a=m.length,i=1;1!==a;){for(s=0;s<a-1;s++)h[s]=(t.pow(4,i)*m[s+1]-m[s])/(t.pow(4,i)-1);a=h.length,m=h,h=[],i++}return m},richardson:function(e,n,r,o){function i(e,t){for(var n,r=0,o=e.length;r<o;r++)e[r]===t&&(n=r);return n}for(var a,s,l,u,c,f=t.abs(r-e[i(e,r)+1]),d=0,h=[],m=[];o>=f;)a=i(e,r+o),s=i(e,r),h[d]=(n[a]-2*n[s]+n[2*s-a])/(o*o),o/=2,d++;for(u=h.length,l=1;1!=u;){for(c=0;c<u-1;c++)m[c]=(t.pow(4,l)*h[c+1]-h[c])/(t.pow(4,l)-1);u=m.length,h=m,m=[],l++}return h},simpson:function(e,t,n,r){for(var o,i=(n-t)/r,a=e(t),s=[],l=t,u=0,c=1;l<=n;l+=i,u++)s[u]=l;for(o=s.length;c<o-1;c++)a+=(c%2!=0?4:2)*e(s[c]);return i/3*(a+e(n))},hermite:function(e,t,n,r){for(var o,i=e.length,a=0,s=0,l=[],u=[],c=[],f=[];s<i;s++){for(l[s]=1,o=0;o<i;o++)s!=o&&(l[s]*=(r-e[o])/(e[s]-e[o]));for(u[s]=0,o=0;o<i;o++)s!=o&&(u[s]+=1/(e[s]-e[o]));c[s]=(1-2*(r-e[s])*u[s])*(l[s]*l[s]),f[s]=(r-e[s])*(l[s]*l[s]),a+=c[s]*t[s]+f[s]*n[s]}return a},lagrange:function(e,t,n){for(var r,o,i=0,a=0,s=e.length;a<s;a++){for(o=t[a],r=0;r<s;r++)a!=r&&(o*=(n-e[r])/(e[a]-e[r]));i+=o}return i},cubic_spline:function(t,n,r){for(var o,i,a=t.length,s=0,l=[],u=[],c=[],f=[],d=[],h=[];s<a-1;s++)f[s]=t[s+1]-t[s];for(c[0]=0,s=1;s<a-1;s++)c[s]=3/f[s]*(n[s+1]-n[s])-3/f[s-1]*(n[s]-n[s-1]);for(s=1;s<a-1;s++)l[s]=[],u[s]=[],l[s][s-1]=f[s-1],l[s][s]=2*(f[s-1]+f[s]),l[s][s+1]=f[s],u[s][0]=c[s];for(i=e.multiply(e.inv(l),u),o=0;o<a-1;o++)d[o]=(n[o+1]-n[o])/f[o]-f[o]*(i[o+1][0]+2*i[o][0])/3,h[o]=(i[o+1][0]-i[o][0])/(3*f[o]);for(o=0;o<a&&!(t[o]>r);o++);return n[o-=1]+(r-t[o])*d[o]+e.sq(r-t[o])*i[o]+(r-t[o])*e.sq(r-t[o])*h[o]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(t){var n,r,o,i,a,s=t.length,l=t[0].length,u=0,c=[],f=[],d=[],h=[],m=[],p=[],g=[];for(u=0;u<s;u++)c[u]=e.sum(t[u])/l;for(u=0;u<l;u++)for(m[u]=[],n=0;n<s;n++)m[u][n]=t[n][u]-c[n];for(m=e.transpose(m),u=0;u<s;u++)for(p[u]=[],n=0;n<s;n++)p[u][n]=e.dot([m[u]],[m[n]])/(l-1);for(a=(o=e.jacobi(p))[0],f=o[1],g=e.transpose(a),u=0;u<f.length;u++)for(n=u;n<f.length;n++)f[u]<f[n]&&(r=f[u],f[u]=f[n],f[n]=r,d=g[u],g[u]=g[n],g[n]=d);for(i=e.transpose(m),u=0;u<s;u++)for(h[u]=[],n=0;n<i.length;n++)h[u][n]=e.dot([g[u]],[i[n]]);return[t,f,g,h]}}),function(t){for(var n=0;n<t.length;n++)!function(t){e.fn[t]=function(n,r){var o=this;return r?(setTimeout((function(){r.call(o,e.fn[t].call(o,n))}),15),this):"number"==typeof e[t](this,n)?e[t](this,n):e(e[t](this,n))}}(t[n])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(t,Math),function(e,t){var n=[].slice,r=e.utils.isNumber,o=e.utils.isArray;function i(e,n,r,o){if(e>1||r>1||e<=0||r<=0)throw new Error("Proportions should be greater than 0 and less than 1");var i=(e*n+r*o)/(n+o);return(e-r)/t.sqrt(i*(1-i)*(1/n+1/o))}e.extend({zscore:function(){var t=n.call(arguments);return r(t[1])?(t[0]-t[1])/t[2]:(t[0]-e.mean(t[1]))/e.stdev(t[1],t[2])},ztest:function(){var r,i=n.call(arguments);return o(i[1])?(r=e.zscore(i[0],i[1],i[3]),1===i[2]?e.normal.cdf(-t.abs(r),0,1):2*e.normal.cdf(-t.abs(r),0,1)):i.length>2?(r=e.zscore(i[0],i[1],i[2]),1===i[3]?e.normal.cdf(-t.abs(r),0,1):2*e.normal.cdf(-t.abs(r),0,1)):(r=i[0],1===i[1]?e.normal.cdf(-t.abs(r),0,1):2*e.normal.cdf(-t.abs(r),0,1))}}),e.extend(e.fn,{zscore:function(e,t){return(e-this.mean())/this.stdev(t)},ztest:function(n,r,o){var i=t.abs(this.zscore(n,o));return 1===r?e.normal.cdf(-i,0,1):2*e.normal.cdf(-i,0,1)}}),e.extend({tscore:function(){var r=n.call(arguments);return 4===r.length?(r[0]-r[1])/(r[2]/t.sqrt(r[3])):(r[0]-e.mean(r[1]))/(e.stdev(r[1],!0)/t.sqrt(r[1].length))},ttest:function(){var o,i=n.call(arguments);return 5===i.length?(o=t.abs(e.tscore(i[0],i[1],i[2],i[3])),1===i[4]?e.studentt.cdf(-o,i[3]-1):2*e.studentt.cdf(-o,i[3]-1)):r(i[1])?(o=t.abs(i[0]),1==i[2]?e.studentt.cdf(-o,i[1]-1):2*e.studentt.cdf(-o,i[1]-1)):(o=t.abs(e.tscore(i[0],i[1])),1==i[2]?e.studentt.cdf(-o,i[1].length-1):2*e.studentt.cdf(-o,i[1].length-1))}}),e.extend(e.fn,{tscore:function(e){return(e-this.mean())/(this.stdev(!0)/t.sqrt(this.cols()))},ttest:function(n,r){return 1===r?1-e.studentt.cdf(t.abs(this.tscore(n)),this.cols()-1):2*e.studentt.cdf(-t.abs(this.tscore(n)),this.cols()-1)}}),e.extend({anovafscore:function(){var r,o,i,a,s,l,u,c,f=n.call(arguments);if(1===f.length){for(s=new Array(f[0].length),u=0;u<f[0].length;u++)s[u]=f[0][u];f=s}for(o=new Array,u=0;u<f.length;u++)o=o.concat(f[u]);for(i=e.mean(o),r=0,u=0;u<f.length;u++)r+=f[u].length*t.pow(e.mean(f[u])-i,2);for(r/=f.length-1,l=0,u=0;u<f.length;u++)for(a=e.mean(f[u]),c=0;c<f[u].length;c++)l+=t.pow(f[u][c]-a,2);return r/(l/(o.length-f.length))},anovaftest:function(){var t,o,i,a,s=n.call(arguments);if(r(s[0]))return 1-e.centralF.cdf(s[0],s[1],s[2]);var l=e.anovafscore(s);for(t=s.length-1,i=0,a=0;a<s.length;a++)i+=s[a].length;return o=i-t-1,1-e.centralF.cdf(l,t,o)},ftest:function(t,n,r){return 1-e.centralF.cdf(t,n,r)}}),e.extend(e.fn,{anovafscore:function(){return e.anovafscore(this.toArray())},anovaftes:function(){var t,n=0;for(t=0;t<this.length;t++)n+=this[t].length;return e.ftest(this.anovafscore(),this.length-1,n-this.length)}}),e.extend({qscore:function(){var o,i,a,s,l,u=n.call(arguments);return r(u[0])?(o=u[0],i=u[1],a=u[2],s=u[3],l=u[4]):(o=e.mean(u[0]),i=e.mean(u[1]),a=u[0].length,s=u[1].length,l=u[2]),t.abs(o-i)/(l*t.sqrt((1/a+1/s)/2))},qtest:function(){var t,r=n.call(arguments);3===r.length?(t=r[0],r=r.slice(1)):7===r.length?(t=e.qscore(r[0],r[1],r[2],r[3],r[4]),r=r.slice(5)):(t=e.qscore(r[0],r[1],r[2]),r=r.slice(3));var o=r[0],i=r[1];return 1-e.tukey.cdf(t,i,o-i)},tukeyhsd:function(t){for(var n=e.pooledstdev(t),r=t.map((function(t){return e.mean(t)})),o=t.reduce((function(e,t){return e+t.length}),0),i=[],a=0;a<t.length;++a)for(var s=a+1;s<t.length;++s){var l=e.qtest(r[a],r[s],t[a].length,t[s].length,n,o,t.length);i.push([[a,s],l])}return i}}),e.extend({normalci:function(){var r,o=n.call(arguments),i=new Array(2);return r=4===o.length?t.abs(e.normal.inv(o[1]/2,0,1)*o[2]/t.sqrt(o[3])):t.abs(e.normal.inv(o[1]/2,0,1)*e.stdev(o[2])/t.sqrt(o[2].length)),i[0]=o[0]-r,i[1]=o[0]+r,i},tci:function(){var r,o=n.call(arguments),i=new Array(2);return r=4===o.length?t.abs(e.studentt.inv(o[1]/2,o[3]-1)*o[2]/t.sqrt(o[3])):t.abs(e.studentt.inv(o[1]/2,o[2].length-1)*e.stdev(o[2],!0)/t.sqrt(o[2].length)),i[0]=o[0]-r,i[1]=o[0]+r,i},significant:function(e,t){return e<t}}),e.extend(e.fn,{normalci:function(t,n){return e.normalci(t,n,this.toArray())},tci:function(t,n){return e.tci(t,n,this.toArray())}}),e.extend(e.fn,{oneSidedDifferenceOfProportions:function(t,n,r,o){var a=i(t,n,r,o);return e.ztest(a,1)},twoSidedDifferenceOfProportions:function(t,n,r,o){var a=i(t,n,r,o);return e.ztest(a,2)}})}(t,Math),t.models=function(){function e(e,n){var r=e.length,o=n[0].length-1,i=r-o-1,a=t.lstsq(n,e),s=t.multiply(n,a.map((function(e){return[e]}))).map((function(e){return e[0]})),l=t.subtract(e,s),u=t.mean(e),c=t.sum(s.map((function(e){return Math.pow(e-u,2)}))),f=t.sum(e.map((function(e,t){return Math.pow(e-s[t],2)}))),d=c+f;return{exog:n,endog:e,nobs:r,df_model:o,df_resid:i,coef:a,predict:s,resid:l,ybar:u,SST:d,SSE:c,SSR:f,R2:c/d}}function n(n){var r,o,i=(r=n.exog,o=r[0].length,t.arange(o).map((function(n){var i=t.arange(o).filter((function(e){return e!==n}));return e(t.col(r,n).map((function(e){return e[0]})),t.col(r,i))}))),a=Math.sqrt(n.SSR/n.df_resid),s=i.map((function(e){var t=e.SST,n=e.R2;return a/Math.sqrt(t*(1-n))})),l=n.coef.map((function(e,t){return(e-0)/s[t]})),u=l.map((function(e){var r=t.studentt.cdf(e,n.df_resid);return 2*(r>.5?1-r:r)})),c=t.studentt.inv(.975,n.df_resid),f=n.coef.map((function(e,t){var n=c*s[t];return[e-n,e+n]}));return{se:s,t:l,p:u,sigmaHat:a,interval95:f}}return{ols:function(r,o){var i=e(r,o),a=n(i),s=function(e){var n,r,o,i=e.R2/e.df_model/((1-e.R2)/e.df_resid);return{F_statistic:i,pvalue:1-(n=i,r=e.df_model,o=e.df_resid,t.beta.cdf(n/(o/r+n),r/2,o/2))}}(i),l=1-(1-i.R2)*((i.nobs-1)/i.df_resid);return i.t=a,i.f=s,i.adjust_R2=l,i}}}(),t.extend({buildxmatrix:function(){for(var e=new Array(arguments.length),n=0;n<arguments.length;n++)e[n]=[1].concat(arguments[n]);return t(e)},builddxmatrix:function(){for(var e=new Array(arguments[0].length),n=0;n<arguments[0].length;n++)e[n]=[1].concat(arguments[0][n]);return t(e)},buildjxmatrix:function(e){for(var n=new Array(e.length),r=0;r<e.length;r++)n[r]=e[r];return t.builddxmatrix(n)},buildymatrix:function(e){return t(e).transpose()},buildjymatrix:function(e){return e.transpose()},matrixmult:function(e,n){var r,o,i,a,s;if(e.cols()==n.rows()){if(n.rows()>1){for(a=[],r=0;r<e.rows();r++)for(a[r]=[],o=0;o<n.cols();o++){for(s=0,i=0;i<e.cols();i++)s+=e.toArray()[r][i]*n.toArray()[i][o];a[r][o]=s}return t(a)}for(a=[],r=0;r<e.rows();r++)for(a[r]=[],o=0;o<n.cols();o++){for(s=0,i=0;i<e.cols();i++)s+=e.toArray()[r][i]*n.toArray()[o];a[r][o]=s}return t(a)}},regress:function(e,n){var r=t.xtranspxinv(e),o=e.transpose(),i=t.matrixmult(t(r),o);return t.matrixmult(i,n)},regresst:function(e,n,r){var o=t.regress(e,n),i={anova:{}},a=t.jMatYBar(e,o);i.yBar=a;var s=n.mean();i.anova.residuals=t.residuals(n,a),i.anova.ssr=t.ssr(a,s),i.anova.msr=i.anova.ssr/(e[0].length-1),i.anova.sse=t.sse(n,a),i.anova.mse=i.anova.sse/(n.length-(e[0].length-1)-1),i.anova.sst=t.sst(n,s),i.anova.mst=i.anova.sst/(n.length-1),i.anova.r2=1-i.anova.sse/i.anova.sst,i.anova.r2<0&&(i.anova.r2=0),i.anova.fratio=i.anova.msr/i.anova.mse,i.anova.pvalue=t.anovaftest(i.anova.fratio,e[0].length-1,n.length-(e[0].length-1)-1),i.anova.rmse=Math.sqrt(i.anova.mse),i.anova.r2adj=1-i.anova.mse/i.anova.mst,i.anova.r2adj<0&&(i.anova.r2adj=0),i.stats=new Array(e[0].length);for(var l,u,c,f=t.xtranspxinv(e),d=0;d<o.length;d++)l=Math.sqrt(i.anova.mse*Math.abs(f[d][d])),u=Math.abs(o[d]/l),c=t.ttest(u,n.length-e[0].length-1,r),i.stats[d]=[o[d],l,u,c];return i.regress=o,i},xtranspx:function(e){return t.matrixmult(e.transpose(),e)},xtranspxinv:function(e){var n=t.matrixmult(e.transpose(),e);return t.inv(n)},jMatYBar:function(e,n){var r=t.matrixmult(e,n);return new t(r)},residuals:function(e,n){return t.matrixsubtract(e,n)},ssr:function(e,t){for(var n=0,r=0;r<e.length;r++)n+=Math.pow(e[r]-t,2);return n},sse:function(e,t){for(var n=0,r=0;r<e.length;r++)n+=Math.pow(e[r]-t[r],2);return n},sst:function(e,t){for(var n=0,r=0;r<e.length;r++)n+=Math.pow(e[r]-t,2);return n},matrixsubtract:function(e,n){for(var r=new Array(e.length),o=0;o<e.length;o++){r[o]=new Array(e[o].length);for(var i=0;i<e[o].length;i++)r[o][i]=e[o][i]-n[o][i]}return t(r)}}),t.jStat=t,t)},184:(e,t,n)=>{"use strict";n.d(t,{$:()=>a});var r=n(976),o=n(870),i=n(874);class a extends r.JsViewer{constructor(e){super(),this.canvas=o.canvas(),this.gridCellStyle=r.GridCellStyle.create(),this.renderer=e,this.root.append(this.canvas),this.canvas.style.width="100%",this.canvas.style.height="100%",o.tools.handleResize(this.canvas,((e,t)=>{this.canvas.width=e,this.canvas.height=t,this.render()}));const t=e=>t=>{this.gridCell&&e(this.gridCell,t)};this.canvas.onmousemove=t(this.renderer.onMouseMove),this.canvas.onmouseenter=t(this.renderer.onMouseEnter),this.canvas.onmouseleave=t(this.renderer.onMouseLeave)}static fromGridCell(e){const t=new a(new i.cv);return t.gridCell=e,t.render(),t}render(){if(!this.gridCell)return;const e=this.canvas.getContext("2d");e.clearRect(0,0,this.canvas.width,this.canvas.height),this.renderer.renderInternal(e,0,0,this.canvas.width,this.canvas.height,this.gridCell.dart,this.gridCellStyle)}}},638:(e,t,n)=>{"use strict";n.d(t,{d:()=>r});class r{}r.TAG_FIT_CHART_FORMAT=".fitChartFormat",r.TAG_FIT_CHART_FORMAT_3DX="3dx",r.FIT_SEM_TYPE="fit",r.FIT_CELL_TYPE="fit",r.TAG_FIT=".fit",r.CELL_DEFAULT_WIDTH=230,r.CELL_DEFAULT_HEIGHT=160,r.MIN_CELL_RENDERER_PX_WIDTH=20,r.MIN_CELL_RENDERER_PX_HEIGHT=10,r.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH=70,r.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT=45,r.MIN_AXES_CELL_PX_WIDTH=100,r.MIN_AXES_CELL_PX_HEIGHT=55,r.MIN_TITLE_PX_WIDTH=275,r.MIN_TITLE_PX_HEIGHT=225,r.MIN_X_AXIS_NAME_VISIBILITY_PX_WIDTH=180,r.MIN_Y_AXIS_NAME_VISIBILITY_PX_HEIGHT=140,r.MIN_LEGEND_PX_WIDTH=325,r.MIN_LEGEND_PX_HEIGHT=275,r.MIN_DROPLINES_VISIBILITY_PX_WIDTH=120,r.MIN_DROPLINES_VISIBILITY_PX_HEIGHT=110,r.AXES_LEFT_PX_MARGIN=38,r.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS=45,r.AXES_TOP_PX_MARGIN=5,r.AXES_TOP_PX_MARGIN_WITH_TITLE=25,r.AXES_RIGHT_PX_MARGIN=18,r.AXES_BOTTOM_PX_MARGIN=15,r.AXES_BOTTOM_PX_MARGIN_WITH_AXES_LABELS=30,r.X_AXIS_LABEL_BOTTOM_PX_MARGIN=4,r.LEGEND_TOP_PX_MARGIN=10,r.OUTLIER_PX_SIZE=12,r.POINT_PX_SIZE=4,r.OUTLIER_HITBOX_RADIUS=2,r.CANDLESTICK_BORDER_PX_SIZE=4,r.CANDLESTICK_MEDIAN_PX_SIZE=3.5,r.CANDLESTICK_OUTLIER_PX_SIZE=6,r.INFLATE_SIZE=-6,r.LEGEND_RECORD_PX_HEIGHT=18,r.LEGEND_RECORD_LINE_PX_WIDTH=20,r.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN=5,r.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN=4,r.LINE_STYLES={solid:[],dotted:[1,1],dashed:[5,5],dashdotted:[5,5,2,5]},r.CURVE_CONFIDENCE_INTERVAL_BOUNDS={TOP:"top",BOTTOM:"bottom"},r.CONFIDENCE_INTERVAL_STROKE_COLOR="rgba(255,191,63,0.4)",r.CONFIDENCE_INTERVAL_FILL_COLOR="rgba(255,238,204,0.3)",r.CONDITION_MAP={"No series to show":e=>void 0===e||0===(null==e?void 0:e.length),"There were series with no points":e=>e.some((e=>{var t;return 0===(null===(t=e.points)||void 0===t?void 0:t.length)})),"There were series with all x zeroes":e=>e.some((e=>{var t;return null===(t=e.points)||void 0===t?void 0:t.every((e=>0===e.x))})),"There were series with all y zeroes":e=>e.some((e=>{var t;return null===(t=e.points)||void 0===t?void 0:t.every((e=>0===e.y))}))}},840:(e,t,n)=>{"use strict";n.d(t,{DI:()=>a}),n(976);var r=n(469),o=n(363),i=(n(102),n(414),n(638),function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))});function a(){return i(this,void 0,void 0,(function*(){r.shell.windows.showContextPanel=!0;const e=yield r.data.loadTable(`${o._package.webRoot}files/curves-demo.csv`);r.shell.addTableView(e)}))}},188:(e,t,n)=>{"use strict";n.d(t,{No:()=>v,Z:()=>w,hS:()=>g});var r=n(976),o=n(870),i=n(416),a=n(102),s=n(874),l=n(184),u=n(711),c=n(638),f=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))};const d="chartOptions",h="seriesOptions";var m;!function(e){e.DATAFRAME="Dataframe",e.COLUMN="Column",e.CELL="Cell"}(m||(m={}));const p={count:"totalCount",nulls:"missingValueCount",unique:"uniqueCount",values:"valueCount",min:"min",max:"max",sum:"sum",avg:"avg",stdev:"stdev",variance:"variance",skew:"skew",kurt:"kurt",med:"med",q1:"q1",q2:"q2",q3:"q3"};function g(e,t){const n=(0,i.Y6)(e);if(e.parameters)t.logX&&e.parameters[2]>0&&(e.parameters[2]=Math.log10(e.parameters[2]));else{const r=(0,i.PK)(e,n,t).parameters;e.parameters=[...r]}return(0,i.tq)(e,n,t)}function v(e,t){var n,o,i;const a={logX:null===(n=e.chartOptions)||void 0===n?void 0:n.logX,logY:null===(o=e.chartOptions)||void 0===o?void 0:o.logY},s=[],l=[],u=[],c=[],f=[],d=[],h=[];for(let t=0,n=0;t<(null===(i=e.series)||void 0===i?void 0:i.length);t++){if(e.series[t].points.every((e=>e.outlier)))continue;const r=g(e.series[t],a);s[n]=r.rSquared,l[n]=r.auc,u[n]=r.interceptX,c[n]=r.interceptY,f[n]=r.slope,d[n]=r.top,h[n]=r.bottom,n++}return{rSquared:s.some((e=>null==e))?void 0:r.Stats.fromValues(s)[p[t]],auc:l.some((e=>null==e))?void 0:r.Stats.fromValues(l)[p[t]],interceptX:u.some((e=>null==e))?void 0:r.Stats.fromValues(u)[p[t]],interceptY:c.some((e=>null==e))?void 0:r.Stats.fromValues(c)[p[t]],slope:f.some((e=>null==e))?void 0:r.Stats.fromValues(f)[p[t]],top:d.some((e=>null==e))?void 0:r.Stats.fromValues(d)[p[t]],bottom:h.some((e=>null==e))?void 0:r.Stats.fromValues(h)[p[t]]}}function _(e){for(let t=0;t<e.length;t++){const n=e.get(t);if(""===n)continue;const r=(0,u.f)(n);e.set(t,JSON.stringify(r))}e.setTag(c.d.TAG_FIT_CHART_FORMAT,"")}function T(e,t,n,r){var o;void 0===e.cell.column.temp[`${d}-custom-title`]&&function(e){var t,n;const r=e.columns.bySemTypeAll(c.d.FIT_SEM_TYPE);for(let e=0;e<r.length;e++){a.kW.map((t=>{r[e].temp[`${d}-custom-${t.name}`]=!1})),a.K0.map((t=>{r[e].temp[`${h}-custom-${t.name}`]=!1})),r[e].getTag(c.d.TAG_FIT_CHART_FORMAT)===c.d.TAG_FIT_CHART_FORMAT_3DX&&_(r[e]);for(let o=0;o<r[e].length;o++){if(""===r[e].get(o))continue;const i=null!==(n=JSON.parse(null!==(t=r[e].get(o))&&void 0!==t?t:"{}"))&&void 0!==n?n:{};a.kW.map((t=>{i.chartOptions&&void 0!==i.chartOptions[t.name]&&(r[e].temp[`${d}-custom-${t.name}`]=!0)})),a.K0.map((t=>{if(i.series)for(const n of i.series)void 0!==n[t.name]&&(r[e].temp[`${h}-custom-${t.name}`]=!0)}))}}}(e.cell.dataFrame);const i=t.property.name,l=r===m.DATAFRAME?(0,s.jG)(e.cell.dataFrame):(0,s.hq)(e.cell.column);if(n===d?l.chartOptions[i]=t.value:n===h&&(l.seriesOptions[i]=t.value),r===m.CELL){const r=e.cell.value;if(""===r)return;const i=null!==(o=JSON.parse(null!=r?r:"{}"))&&void 0!==o?o:{};!function(e,t,n){const r=t.property.name;if(n===d){if(void 0===e.chartOptions)return;e.chartOptions[r]=t.value}else if(n===h){if(void 0===e.series)return;for(let n=0;n<e.series.length;n++)e.series[n][r]=t.value}}(i,t,n),e.cell.value=JSON.stringify(i)}else{let t;r===m.DATAFRAME?(e.cell.dataFrame.tags[c.d.TAG_FIT]=JSON.stringify(l),t=e.cell.dataFrame.columns.bySemTypeAll(c.d.FIT_SEM_TYPE)):(e.cell.column.tags[c.d.TAG_FIT]=JSON.stringify(l),t=[e.cell.column]);for(let e=0;e<t.length;e++){if(r===m.DATAFRAME){const r=(0,s.hq)(t[e]);n===d?delete r.chartOptions[i]:delete r.seriesOptions[i],t[e].tags[c.d.TAG_FIT]=JSON.stringify(r)}!1!==t[e].temp[`${n}-custom-${i}`]&&(t[e].init((r=>{var o,a;const s=t[e].get(r);if(""===s)return s;const l=null!==(a=JSON.parse(null!==(o=t[e].get(r))&&void 0!==o?o:"{}"))&&void 0!==a?a:{};if(n===d){if(void 0===l.chartOptions)return s;if(void 0===l.chartOptions[i])return s;delete l.chartOptions[i]}else{if(void 0===l.series)return s;let e=!1;for(const t of l.series)void 0!==t[i]&&(delete t[i],e=!0);if(l.seriesOptions&&delete l.seriesOptions[i],!e)return s}return JSON.stringify(l)})),t[e].temp[`${n}-custom-${i}`]=!1)}}e.grid.invalidate()}class w extends r.ObjectHandler{get type(){return"GridCell"}isApplicable(e){return e instanceof r.GridCell&&e.cellType===c.d.FIT_CELL_TYPE}renderProperties(e,t=null){var n,u,c,m,p,_,w,E,I,y,x;const A=o.accordion("Curves property panel"),C=r.Property.js("level",r.TYPE.STRING,{description:"Controls the level at which properties will be switched",defaultValue:"Column",choices:["Dataframe","Column","Cell"],nullable:!1}),N=o.input.forProperty(C);o.tooltip.bind(N.captionLabel,"Controls the level at which properties will be switched");const O=(0,s.W$)(e),S=(0,s.hq)(e.cell.column),L=(0,s.jG)(e.cell.dataFrame),P={onValueChanged:t=>T(e,t,h,N.value)},b={onValueChanged:t=>T(e,t,d,N.value)};(0,s.fi)(null===(n=L.seriesOptions)||void 0===n?void 0:n.pointColor)||(0,s.fi)(null===(u=S.seriesOptions)||void 0===u?void 0:u.pointColor)||(O.seriesOptions?(0,s.fi)(O.seriesOptions.pointColor)||(O.seriesOptions.pointColor=r.Color.toHtml(r.Color.getCategoricalColor(0))):(0,s.fi)(O.series?O.series[0].pointColor:"")||(O.series[0].pointColor=r.Color.toHtml(r.Color.getCategoricalColor(0)))),(0,s.fi)(null===(c=L.seriesOptions)||void 0===c?void 0:c.fitLineColor)||(0,s.fi)(null===(m=S.seriesOptions)||void 0===m?void 0:m.fitLineColor)||(O.seriesOptions?(0,s.fi)(O.seriesOptions.fitLineColor)||(O.seriesOptions.fitLineColor=r.Color.toHtml(r.Color.getCategoricalColor(0))):(0,s.fi)(O.series?O.series[0].fitLineColor:"")||(O.series[0].fitLineColor=r.Color.toHtml(r.Color.getCategoricalColor(0)))),(0,s.fi)(null===(p=L.seriesOptions)||void 0===p?void 0:p.outlierColor)||(0,s.fi)(null===(_=S.seriesOptions)||void 0===_?void 0:_.outlierColor)||(O.seriesOptions?(0,s.fi)(O.seriesOptions.outlierColor)||(O.seriesOptions.outlierColor=r.Color.toHtml(r.Color.red)):(0,s.fi)(O.series?O.series[0].outlierColor:"")||(O.series[0].outlierColor=r.Color.toHtml(r.Color.red))),(0,s.BI)(a.K0,S.seriesOptions,O.seriesOptions?O.seriesOptions:O.series&&null!==(w=O.series[0])&&void 0!==w?w:{}),(0,s.BI)(a.K0,L.seriesOptions,O.seriesOptions?O.seriesOptions:O.series&&null!==(E=O.series[0])&&void 0!==E?E:{}),(0,s.BI)(a.kW,S.chartOptions,O.chartOptions?O.chartOptions:{}),(0,s.BI)(a.kW,L.chartOptions,O.chartOptions?O.chartOptions:{}),(null===(I=O.chartOptions)||void 0===I?void 0:I.allowXZeroes)&&(null===(y=O.chartOptions)||void 0===y?void 0:y.logX)&&(null===(x=O.series)||void 0===x?void 0:x.some((e=>e.points.some((e=>0===e.x)))))&&(0,s.kb)(O);const R=o.form([N]),X=a.K0.map((e=>o.input.forProperty(e,O.seriesOptions?O.seriesOptions:O.series[0],P)));o.forms.addGroup(R,"Series options",X),o.forms.addGroup(R,"Chart options",a.kW.map((e=>o.input.forProperty(e,O.chartOptions,b)))),A.addPane("Options",(()=>R));const M=r.Property.js("series",r.TYPE.STRING,{description:"Controls whether to show series statistics or aggregated statistics",defaultValue:"All",choices:["all","aggregated"],nullable:!1}),F=o.input.forProperty(M,null,{onValueChanged(e){A.getPane("Fit").root.lastElementChild.replaceChildren(Y())}}),G=r.Property.js("aggregation type",r.TYPE.STRING,{description:"Controls which aggregation to use on the series statistics",defaultValue:"med",choices:Object.values(r.STATS),nullable:!1}),D=o.input.forProperty(G,null,{onValueChanged(e){A.getPane("Fit").root.lastElementChild.replaceChildren(Y())}});function Y(){var t,n,s;const l=o.divV("aggregated"===F.stringValue?[F.root,D.root]:[F.root]),u=(0,i.dU)(O);if(u.x<=0&&O.chartOptions&&(O.chartOptions.logX=!1),u.y<=0&&O.chartOptions&&(O.chartOptions.logY=!1),"all"===F.stringValue){const i={logX:null===(t=O.chartOptions)||void 0===t?void 0:t.logX,logY:null===(n=O.chartOptions)||void 0===n?void 0:n.logY};for(let t=0;t<O.series.length;t++){const n=O.series[t],u=g(n,i),c=n.fitLineColor&&r.Color.fromHtml(n.fitLineColor)?n.fitLineColor:r.Color.toHtml(r.Color.getCategoricalColor(t));l.appendChild(o.panel([o.h1(null!==(s=n.name)&&void 0!==s?s:"series "+t,{style:{color:c}}),o.input.form(u,a.sw,{onCreated:i=>i.root.appendChild(o.iconFA("plus",(()=>f(this,void 0,void 0,(function*(){const o={df:e.cell.dataFrame,colName:e.gridColumn.name,propName:i.property.name,seriesName:n.name,seriesNumber:t};yield r.Func.find({name:"addStatisticsColumn"})[0].prepare(o).call(void 0,void 0,{processed:!1})}))),`Calculate ${i.property.name} for the whole column`))})]))}}else{const t=v(O,D.stringValue);l.appendChild(o.panel([o.h1(`series ${D.stringValue}`),o.input.form(t,a.sw,{onCreated:t=>t.root.appendChild(o.iconFA("plus",(()=>f(this,void 0,void 0,(function*(){const n={df:e.cell.dataFrame,colName:e.gridColumn.name,propName:t.property.name,aggrType:D.stringValue};yield r.Func.find({name:"addAggrStatisticsColumn"})[0].prepare(n).call(void 0,void 0,{processed:!1})}))),`Calculate ${t.property.name} ${D.stringValue} for the whole column`))})]))}return l}return A.addPane("Fit",(()=>Y())),A.addPane("Chart",(()=>l.$.fromGridCell(e).root)),A.root}}},711:(e,t,n)=>{"use strict";n.d(t,{f:()=>u});var r=n(976),o=n(102);const i={x:"xAxis",y:"yAxis"},a={min:"min",max:"max"};function s(e){var t,n,i;const a=null===(n=null===(t=e.getElementsByTagName("params")[0])||void 0===t?void 0:t.childNodes[0].nodeValue)||void 0===n?void 0:n.split(",").map(Number);let s=null===(i=e.getElementsByTagName("function")[0])||void 0===i?void 0:i.getAttribute("type");s=s&&"sigif"!==s?s:o.yB;const l=e.getElementsByTagName("settings")[0].getAttribute("markerColor"),u=e.getElementsByTagName("settings")[0].getAttribute("color"),c=!!e.getElementsByTagName("settings")[0].getAttribute("drawLine"),f={name:e.getAttribute("name"),fitFunction:s,markerType:r.MARKER_TYPE.CIRCLE,pointColor:l,fitLineColor:u,showFitLine:c,showPoints:"points",showCurveConfidenceInterval:!1,clickToToggle:!1};return a&&(f.parameters=[a[2],a[1],a[0],a[3]]),f}function l(e){const t=function(e){var t,n,r;const o=null===(t=e.getElementsByTagName("x")[0].childNodes[0].nodeValue)||void 0===t?void 0:t.split(","),i=null===(n=e.getElementsByTagName("y")[0].childNodes[0].nodeValue)||void 0===n?void 0:n.split(","),a=null===(r=e.getElementsByTagName("mask")[0].childNodes[0].nodeValue)||void 0===r?void 0:r.split(""),s=[];for(let e=0;e<o.length;e++)s[e]={x:+o[e],y:+i[e],outlier:!Boolean(a[e])};return s}(e),n=s(e),r={points:t};return Object.assign(r,n),r}function u(e){const t=(new DOMParser).parseFromString(e,"text/xml"),n=t.getElementsByTagName("grid")[0],r=(u=t.getElementsByTagName("settings")[0],{minX:+(o=n).getElementsByTagName(i.x)[0].getAttribute(a.min),minY:+o.getElementsByTagName(i.y)[0].getAttribute(a.min),maxX:+o.getElementsByTagName(i.x)[0].getAttribute(a.max),maxY:+o.getElementsByTagName(i.y)[0].getAttribute(a.max),xAxisName:u.getAttribute("xLabel"),yAxisName:u.getAttribute("yLabel"),logX:!!u.getAttribute("logX")});var o,u;const c=t.getElementsByTagName("seriesCollection")[0],f=s(c.getElementsByTagName("series")[0]),d=function(e){const t=[],n=e.getElementsByTagName("series").length;for(let r=0;r<n;r++){const n=e.getElementsByTagName("series")[r];t[r]=l(n)}return t}(c);return{chartOptions:r,seriesOptions:f,series:d}}},874:(e,t,n)=>{"use strict";n.d(t,{cv:()=>B,W$:()=>X,hq:()=>F,jG:()=>M,fi:()=>D,l$:()=>b,BI:()=>P,Qp:()=>R,kb:()=>Y});var r=n(976),o=n(469),i=n(870),a=n(102),s=n(766),l=n(416),u=n(711),c=n(184),f=n(188),d=n(638),h=n(111);const m=window,p=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2});class g{static getUniqueName(e,t,n){return m.grok_Utils_GetUniqueName(e,t,null==n?void 0:n.auto,null==n?void 0:n.idx,null==n?void 0:n.render,null==n?void 0:n.choices)}static isEmpty(e){return null==e||""==e}static formatNumber(e){return p.format(e)}}function v(e,t){const n=e.pointColor&&r.Color.fromHtml(e.pointColor)?e.pointColor:r.Color.toHtml(r.Color.getCategoricalColor(t)),o=e.outlierColor&&r.Color.fromHtml(e.outlierColor)?e.outlierColor:r.Color.toHtml(r.Color.red),i=e.fitLineColor&&r.Color.fromHtml(e.fitLineColor)?e.fitLineColor:r.Color.toHtml(r.Color.getCategoricalColor(t));e.pointColor=n,e.outlierColor=o,e.fitLineColor=i}function _(e,t,n){var r;if(null!==(r=t.connectDots)&&void 0!==r&&r){e.strokeStyle=t.pointColor,e.lineWidth=2*n.ratio,e.beginPath();for(let r=0;r<t.points.length;r++){const o=t.points[r].x,i=t.points[r].y,a=n.viewport.xToScreen(o),s=n.viewport.yToScreen(i);0===r?e.moveTo(a,s):e.lineTo(a,s)}e.stroke()}}function T(e,t,n){var o;(null===(o=t.showPoints)||void 0===o||o)&&(e.strokeStyle=t.pointColor,t.connectDots&&""!==t.showPoints||"points"===t.showPoints?function(e,t,n){for(let o=0;o<t.points.length;o++){const i=t.points[o],a=t.connectDots?t.pointColor:i.outlier?i.outlierColor&&r.Color.fromHtml(i.outlierColor)?i.outlierColor:t.outlierColor:i.color&&r.Color.fromHtml(i.color)?i.color:t.pointColor,s=i.marker?i.marker:t.markerType,l=t.connectDots?d.d.POINT_PX_SIZE*n.ratio:i.outlier?d.d.OUTLIER_PX_SIZE*n.ratio:i.size?i.size:d.d.POINT_PX_SIZE*n.ratio;r.Paint.marker(e,t.connectDots?s:i.outlier?r.MARKER_TYPE.OUTLIER:s,n.viewport.xToScreen(i.x),n.viewport.yToScreen(i.y),a,l),i.stdev&&!i.outlier&&(e.strokeStyle=a,e.beginPath(),e.moveTo(n.viewport.xToScreen(i.x),n.viewport.yToScreen(i.y+i.stdev)),e.lineTo(n.viewport.xToScreen(i.x),n.viewport.yToScreen(i.y-i.stdev)),e.stroke())}}(e,t,n):["candlesticks","both"].includes(t.showPoints)&&function(e,t,n){for(let o=0,i=null;o<t.points.length;o++){const a=t.points[o];if(a.outlier)continue;const s=o+1<t.points.length&&t.points[o+1].x===a.x;if(!i&&s)i=o;else if(null!==i&&!s){const s=[];for(let e=i,n=0;e<=o;e++,n++)s[n]=t.points[e].y;const l=(0,h.G)(s);if(e.beginPath(),w(e,{viewport:n.viewport,ratio:n.ratio,x:a.x,boxPlotStats:l,color:t.pointColor}),e.stroke(),"both"===t.showPoints)for(let o=0;o<s.length;o++)(s[o]<l.lowerAdjacentValue||s[o]>l.upperAdjacentValue)&&r.Paint.marker(e,r.MARKER_TYPE.OUTLIER,n.viewport.xToScreen(a.x),n.viewport.yToScreen(s[o]),t.pointColor,d.d.CANDLESTICK_OUTLIER_PX_SIZE*n.ratio);i=null}}}(e,t,n))}function w(e,t){E(e,t.x,t.boxPlotStats.lowerAdjacentValue,t.viewport),e.moveTo(t.viewport.xToScreen(t.x),t.viewport.yToScreen(t.boxPlotStats.lowerAdjacentValue)),e.lineTo(t.viewport.xToScreen(t.x),t.viewport.yToScreen(t.boxPlotStats.upperAdjacentValue)),E(e,t.x,t.boxPlotStats.upperAdjacentValue,t.viewport),r.Paint.marker(e,r.MARKER_TYPE.CIRCLE,t.viewport.xToScreen(t.x),t.viewport.yToScreen(t.boxPlotStats.q2),t.color,d.d.CANDLESTICK_MEDIAN_PX_SIZE*t.ratio)}function E(e,t,n,r){e.moveTo(r.xToScreen(t)-d.d.CANDLESTICK_BORDER_PX_SIZE/2,r.yToScreen(n)),e.lineTo(r.xToScreen(t)+d.d.CANDLESTICK_BORDER_PX_SIZE/2,r.yToScreen(n))}function I(e,t,n){var r;if(null===(r=t.showFitLine)||void 0===r||r){e.save(),e.strokeStyle=t.fitLineColor,e.lineWidth=2*n.ratio,e.beginPath(),t.lineStyle&&e.setLineDash(d.d.LINE_STYLES[t.lineStyle]);const r=n.showAxes?n.showAxesLabels?d.d.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:d.d.AXES_LEFT_PX_MARGIN:0,o=n.showAxes?d.d.AXES_RIGHT_PX_MARGIN:0;for(let t=r;t<=n.screenBounds.width-o;t++){const o=n.screenBounds.x+t,i=n.logOptions.logX?Math.log10(n.viewport.xToWorld(o)):n.viewport.xToWorld(o),a=n.logOptions.logY?n.viewport.yToScreen(Math.pow(10,n.curveFunc(i))):n.viewport.yToScreen(n.curveFunc(i));t===r?e.moveTo(o,a):e.lineTo(o,a)}e.stroke(),e.restore()}}function y(e,t,n){var r,o,i,a;if((null===(r=t.showFitLine)||void 0===r||r)&&null!==(o=t.showCurveConfidenceInterval)&&void 0!==o&&o){e.strokeStyle=null!==(i=t.confidenceIntervalColor)&&void 0!==i?i:d.d.CONFIDENCE_INTERVAL_STROKE_COLOR,e.fillStyle=null!==(a=t.confidenceIntervalColor)&&void 0!==a?a:d.d.CONFIDENCE_INTERVAL_FILL_COLOR;const r=(0,l.LC)(t,n.fitFunc,n.userParamsFlag,n.logOptions);x(e,{viewport:n.viewport,logOptions:n.logOptions,showAxes:n.showAxes,showAxesLabels:n.showAxesLabels,screenBounds:n.screenBounds,confidenceIntervals:r,confidenceType:d.d.CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP}),x(e,{viewport:n.viewport,logOptions:n.logOptions,showAxes:n.showAxes,showAxesLabels:n.showAxesLabels,screenBounds:n.screenBounds,confidenceIntervals:r,confidenceType:d.d.CURVE_CONFIDENCE_INTERVAL_BOUNDS.BOTTOM}),function(e,t){e.beginPath();const n=t.showAxes?t.showAxesLabels?d.d.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:d.d.AXES_LEFT_PX_MARGIN:0,r=t.showAxes?d.d.AXES_RIGHT_PX_MARGIN:0;for(let o=n;o<=t.screenBounds.width-r;o++){const r=t.screenBounds.x+o,i=t.logOptions.logX?Math.log10(t.viewport.xToWorld(r)):t.viewport.xToWorld(r),a=t.logOptions.logY?t.viewport.yToScreen(Math.pow(10,t.confidenceIntervals.confidenceTop(i))):t.viewport.yToScreen(t.confidenceIntervals.confidenceTop(i));o===n?e.moveTo(r,a):e.lineTo(r,a)}for(let o=t.screenBounds.width-r;o>=n;o--){const n=t.screenBounds.x+o,r=t.logOptions.logX?Math.log10(t.viewport.xToWorld(n)):t.viewport.xToWorld(n),i=t.logOptions.logY?t.viewport.yToScreen(Math.pow(10,t.confidenceIntervals.confidenceBottom(r))):t.viewport.yToScreen(t.confidenceIntervals.confidenceBottom(r));e.lineTo(n,i)}e.closePath(),e.fill()}(e,{viewport:n.viewport,logOptions:n.logOptions,showAxes:n.showAxes,showAxesLabels:n.showAxesLabels,screenBounds:n.screenBounds,confidenceIntervals:r})}}function x(e,t){e.beginPath();const n=t.showAxes?t.showAxesLabels?d.d.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:d.d.AXES_LEFT_PX_MARGIN:0,r=t.showAxes?d.d.AXES_RIGHT_PX_MARGIN:0,o=t.confidenceType===d.d.CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP?t.confidenceIntervals.confidenceTop:t.confidenceIntervals.confidenceBottom;for(let i=n;i<=t.screenBounds.width-r;i++){const r=t.screenBounds.x+i,a=t.logOptions.logX?Math.log10(t.viewport.xToWorld(r)):t.viewport.xToWorld(r),s=t.logOptions.logY?t.viewport.yToScreen(Math.pow(10,o(a))):t.viewport.yToScreen(o(a));i===n?e.moveTo(r,s):e.lineTo(r,s)}e.stroke()}function A(e,t,n){var r;if((null===(r=t.showFitLine)||void 0===r||r)&&t.droplines&&n.showDroplines){e.save(),e.strokeStyle="blue",e.lineWidth=n.ratio,e.beginPath(),e.setLineDash([5,5]);for(let r=0;r<t.droplines.length;r++)"IC50"===t.droplines[r]&&C(e,{viewport:n.viewport,xValue:t.parameters[2],dataBounds:n.dataBounds,curveFunc:n.curveFunc,logOptions:n.logOptions});e.stroke(),e.restore()}}function C(e,t){t.logOptions.logX&&(t.xValue=Math.pow(10,t.xValue));const n=t.logOptions.logX?Math.log10(t.xValue):t.xValue,r=t.logOptions.logY?Math.pow(10,t.curveFunc(n)):t.curveFunc(n);e.moveTo(t.viewport.xToScreen(t.dataBounds.minX),t.viewport.yToScreen(r)),e.lineTo(t.viewport.xToScreen(t.xValue),t.viewport.yToScreen(r)),e.lineTo(t.viewport.xToScreen(t.xValue),t.viewport.yToScreen(t.dataBounds.minY))}function N(e,t,n){var r;if((null===(r=t.showFitLine)||void 0===r||r)&&n.statistics){const r=(0,l.tq)(t,n.fitFunc,n.logOptions);for(let o=0;o<n.statistics.length;o++){const i=n.statistics[o],s=a.sw.find((e=>e.name===i));if(s){const i=g.formatNumber(s.get(r));e.fillStyle=t.fitLineColor,e.textAlign="left",e.fillText(s.name+": "+i,n.dataBox.x+5,n.dataBox.y+20+20*o)}}}}function O(e,t,n){e.beginPath(),e.fillStyle="black";const r=e.measureText(t).width;e.fillText(t,n.dataBox.maxX-r,n.dataBox.y+d.d.LEGEND_TOP_PX_MARGIN+(n.columnIdx*d.d.LEGEND_RECORD_PX_HEIGHT+d.d.LEGEND_RECORD_PX_HEIGHT*n.drawnCurvesInLegend))}function S(e,t,n){e.beginPath(),e.strokeStyle=t.fitLineColor,e.lineWidth=2*n.ratio;const o=e.measureText(t.name).width;e.moveTo(n.dataBox.maxX-o-d.d.LEGEND_RECORD_LINE_PX_WIDTH-d.d.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN,n.dataBox.y+d.d.LEGEND_TOP_PX_MARGIN-d.d.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN+(n.showColumnLabel?d.d.LEGEND_RECORD_PX_HEIGHT*(n.columnIdx+1):0)+d.d.LEGEND_RECORD_PX_HEIGHT*n.drawnCurvesInLegend),e.lineTo(n.dataBox.maxX-o-d.d.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN,n.dataBox.y+d.d.LEGEND_TOP_PX_MARGIN-d.d.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN+(n.showColumnLabel?d.d.LEGEND_RECORD_PX_HEIGHT*(n.columnIdx+1):0)+d.d.LEGEND_RECORD_PX_HEIGHT*n.drawnCurvesInLegend);const i=t.markerType?t.markerType:r.MARKER_TYPE.CIRCLE;r.Paint.marker(e,i,n.dataBox.maxX-o-d.d.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN-d.d.LEGEND_RECORD_LINE_PX_WIDTH/2,n.dataBox.y+d.d.LEGEND_TOP_PX_MARGIN-d.d.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN+(n.showColumnLabel?d.d.LEGEND_RECORD_PX_HEIGHT*(n.columnIdx+1):0)+d.d.LEGEND_RECORD_PX_HEIGHT*n.drawnCurvesInLegend,t.pointColor,d.d.POINT_PX_SIZE*n.ratio),e.fillStyle=t.fitLineColor,e.fillText(t.name,n.dataBox.maxX-o,n.dataBox.y+d.d.LEGEND_TOP_PX_MARGIN+(n.showColumnLabel?d.d.LEGEND_RECORD_PX_HEIGHT*(n.columnIdx+1):0)+d.d.LEGEND_RECORD_PX_HEIGHT*n.drawnCurvesInLegend),e.stroke()}function L(e,t){var n;r.Paint.marker(e,r.MARKER_TYPE.OUTLIER,t.midX,t.midY,r.Color.red,(n=.8*Math.min(t.width,t.height),0,30,Math.min(Math.max(n,0),30)))}function P(e,t,n){if(t&&n)for(const r of e)!(r.name in n)&&r.name in t&&(n[r.name]=t[r.name])}function b(e){if(0===e.length)return{};let t,n,r,o=Number.MAX_VALUE,i=Number.MAX_VALUE,a=Number.MIN_VALUE,s=Number.MIN_VALUE,l=!1,u=!1,c=!1;for(const f of e)null!==f.minX&&void 0!==f.minX&&(o=Math.min(o,f.minX)),null!==f.minY&&void 0!==f.minY&&(i=Math.min(i,f.minY)),null!==f.maxX&&void 0!==f.maxX&&(a=Math.max(a,f.maxX)),null!==f.maxY&&void 0!==f.maxY&&(s=Math.max(s,f.maxY)),null!==f.title&&void 0!==f.title&&(null!=r||(r=f.title)),null!==f.xAxisName&&void 0!==f.xAxisName&&(null!=t||(t=f.xAxisName)),null!==f.yAxisName&&void 0!==f.yAxisName&&(null!=n||(n=f.yAxisName)),null!==f.logX&&void 0!==f.logX&&f.logX&&(l=!0),null!==f.logY&&void 0!==f.logY&&f.logY&&(u=!0),null!==f.allowXZeroes&&void 0!==f.allowXZeroes&&f.allowXZeroes&&(c=!0);return{minX:o===Number.MAX_VALUE?void 0:o,minY:i===Number.MAX_VALUE?void 0:i,maxX:a===Number.MIN_VALUE?void 0:a,maxY:s===Number.MIN_VALUE?void 0:s,title:r,xAxisName:t,yAxisName:n,logX:l,logY:u,allowXZeroes:c}}function R(e){if(0===e.length)return null;const t={points:[],name:e[0].name,fitFunction:e[0].fitFunction,markerType:e[0].markerType,lineStyle:e[0].lineStyle,pointColor:e[0].pointColor,fitLineColor:e[0].fitLineColor,confidenceIntervalColor:e[0].confidenceIntervalColor,outlierColor:e[0].outlierColor,connectDots:e[0].connectDots,showFitLine:e[0].showFitLine,showPoints:e[0].showPoints,showCurveConfidenceInterval:e[0].showCurveConfidenceInterval,errorModel:e[0].errorModel,clickToToggle:e[0].clickToToggle,labels:e[0].labels,droplines:e[0].droplines,columnName:e[0].columnName};for(const n of e)t.points=[...t.points,...n.points];return t}function X(e){var t,n,o,i,s;let c=e.cell.value;c.includes("|")&&(c=c.replaceAll("|",""));const f=(null===(n=null===(t=e.cell)||void 0===t?void 0:t.column)||void 0===n?void 0:n.type)===r.TYPE.STRING?e.cell.column.getTag(d.d.TAG_FIT_CHART_FORMAT)===d.d.TAG_FIT_CHART_FORMAT_3DX?(0,u.f)(c):null!==(o=JSON.parse(null!=c?c:"{}"))&&void 0!==o?o:{}:(0,l.TL)(),h=e.cell.column?F(e.cell.column):{},m=e.cell.column?M(e.cell.dataFrame):{};null!==(i=f.series)&&void 0!==i||(f.series=[]),null!==(s=f.chartOptions)&&void 0!==s||(f.chartOptions=h.chartOptions),P(a.kW,h.chartOptions,f.chartOptions),P(a.kW,m.chartOptions,f.chartOptions);for(const e of f.series)P(a.K0,f.seriesOptions,e),P(a.K0,h.seriesOptions,e),P(a.K0,m.seriesOptions,e);return f}function M(e){var t,n,r;return JSON.parse(null!==(t=(n=e.tags)[r=d.d.TAG_FIT])&&void 0!==t?t:n[r]=JSON.stringify((0,l.TL)()))}function F(e){var t,n,r;return JSON.parse(null!==(t=(n=e.tags)[r=d.d.TAG_FIT])&&void 0!==t?t:n[r]=JSON.stringify((0,l.TL)()))}function G(e,t,n){if(e.width<d.d.MIN_AXES_CELL_PX_WIDTH||e.height<d.d.MIN_AXES_CELL_PX_HEIGHT)return[e,void 0,void 0];const r=t?d.d.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:d.d.AXES_LEFT_PX_MARGIN,o=t?d.d.AXES_BOTTOM_PX_MARGIN_WITH_AXES_LABELS:d.d.AXES_BOTTOM_PX_MARGIN,i=n?d.d.AXES_TOP_PX_MARGIN_WITH_TITLE:d.d.AXES_TOP_PX_MARGIN;return[e.cutLeft(r).cutBottom(o).cutTop(i).cutRight(d.d.AXES_RIGHT_PX_MARGIN),e.getBottom(o).getTop(i).cutLeft(r).cutRight(d.d.AXES_RIGHT_PX_MARGIN),e.getLeft(r).getRight(d.d.AXES_RIGHT_PX_MARGIN).cutBottom(o).cutTop(i)]}function D(e){return null!=e&&""!==e&&void 0!==r.Color.fromHtml(e)}function Y(e){var t;for(let n=0;n<(null===(t=e.series)||void 0===t?void 0:t.length);n++){const t=e.series[n];if(t.points.every((e=>0!==e.x)))continue;let r=Number.MAX_VALUE,o=0,i=0;const a=[];for(let e=0;e<t.points.length;e++)t.points[e].x<r&&0!==t.points[e].x&&(r=t.points[e].x),t.points[e].x>o&&0!==t.points[e].x&&(o=t.points[e].x),a.includes(t.points[e].x)||(a[a.length]=t.points[e].x,i++);const s=Math.pow(10,Math.log10(r)-(Math.log10(o)-Math.log10(r)/(i-1)));for(let e=0;e<t.points.length;e++)0===t.points[e].x&&(t.points[e].x=s)}}class B extends r.GridCellRenderer{get name(){return d.d.FIT_CELL_TYPE}get cellType(){return d.d.FIT_CELL_TYPE}getDefaultSize(e){return{width:d.d.CELL_DEFAULT_WIDTH,height:d.d.CELL_DEFAULT_HEIGHT}}onClick(e,t){var n,r,a,c,h,m,p;if(!e.cell.value)return;const g=e.cell.column.getTag(d.d.TAG_FIT_CHART_FORMAT)===d.d.TAG_FIT_CHART_FORMAT_3DX?(0,u.f)(e.cell.value):X(e);for(const[e,t]of Object.entries(d.d.CONDITION_MAP))if(t(g.series))return void(o.shell.o=i.divText(e,{style:{color:"red"}}));o.shell.o=e;const v=e.bounds.inflate(d.d.INFLATE_SIZE,d.d.INFLATE_SIZE),_=G(v,this.areAxesLabelsShown(v,g),this.isTitleShown(v,g))[0],T=(0,l.dU)(g),w=new s.l(T,_,null!==(r=null===(n=g.chartOptions)||void 0===n?void 0:n.logX)&&void 0!==r&&r,null!==(c=null===(a=g.chartOptions)||void 0===a?void 0:a.logY)&&void 0!==c&&c);for(let n=0;n<(null===(h=g.series)||void 0===h?void 0:h.length);n++)if(!(g.series[n].connectDots||!g.series[n].clickToToggle||"points"!==g.series[n].showPoints||v.width<d.d.MIN_AXES_CELL_PX_WIDTH||v.height<d.d.MIN_AXES_CELL_PX_HEIGHT))for(let r=0;r<g.series[n].points.length;r++){const o=g.series[n].points[r];if(this.hitTest(t,o,w)){o.outlier=!o.outlier;const t=e.grid.dataFrame.columns.byTags({".sourceColumn":e.cell.column.name});if(t)for(const r of t){const t={logX:null===(m=g.chartOptions)||void 0===m?void 0:m.logX,logY:null===(p=g.chartOptions)||void 0===p?void 0:p.logY},o=null!==r.tags[".seriesAggregation"]?(0,f.No)(g,r.tags[".seriesAggregation"]):r.tags[".seriesNumber"]===n?(0,f.hS)(g.series[n],t):null;null!==o&&r.set(e.cell.rowIndex,o[r.tags[".statistics"]])}if(e.cell.column.getTag(d.d.TAG_FIT_CHART_FORMAT)!==d.d.TAG_FIT_CHART_FORMAT_3DX){const t=JSON.parse(e.cell.value);t.series[n].points[r].outlier=o.outlier,e.cell.value=JSON.stringify(t)}return}}}onDoubleClick(e,t){if(!e.cell.value)return;const n=c.$.fromGridCell(e),r=i.dialog({title:"Edit chart"}).add(n.root).show({resizable:!0}).root.getElementsByClassName("d4-dialog-contents dlg-edit-chart")[0].firstChild;n.canvas.width=r.clientWidth,n.canvas.height=r.clientHeight,n.render(),r.style.width="100%",r.style.height="100%",i.tools.handleResize(r,((e,t)=>{n.canvas.width=e,n.canvas.height=t,n.render()}))}areAxesShown(e){return e.width>=d.d.MIN_AXES_CELL_PX_WIDTH&&e.height>=d.d.MIN_AXES_CELL_PX_HEIGHT}areAxesLabelsShown(e,t){var n;return e.width>=d.d.MIN_X_AXIS_NAME_VISIBILITY_PX_WIDTH&&e.height>=d.d.MIN_Y_AXIS_NAME_VISIBILITY_PX_HEIGHT&&!!(null===(n=t.chartOptions)||void 0===n?void 0:n.xAxisName)&&!!t.chartOptions.yAxisName}isTitleShown(e,t){var n;return e.width>=d.d.MIN_TITLE_PX_WIDTH&&e.height>=d.d.MIN_TITLE_PX_HEIGHT&&!!(null===(n=t.chartOptions)||void 0===n?void 0:n.title)}isLegendShown(e){return e.width>=d.d.MIN_LEGEND_PX_WIDTH&&e.height>=d.d.MIN_LEGEND_PX_HEIGHT}areDroplinesShown(e){return e.width>=d.d.MIN_DROPLINES_VISIBILITY_PX_WIDTH&&e.height>=d.d.MIN_DROPLINES_VISIBILITY_PX_HEIGHT}renderCurves(e,t,n){var r,o,i,a,u,c,f,h,m,p,g,w,E,x,C;e.save(),e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.clip(),(null===(r=n.chartOptions)||void 0===r?void 0:r.allowXZeroes)&&(null===(o=n.chartOptions)||void 0===o?void 0:o.logX)&&(null===(i=n.series)||void 0===i?void 0:i.some((e=>e.points.some((e=>0===e.x)))))&&Y(n);const[L,P,b]=G(t,this.areAxesLabelsShown(t,n),this.isTitleShown(t,n)),R=(0,l.dU)(n);(R.x<0&&n.chartOptions||0===R.x&&n.chartOptions&&!n.chartOptions.allowXZeroes)&&(n.chartOptions.logX=!1),R.y<=0&&n.chartOptions&&(n.chartOptions.logY=!1);const X=new s.l(R,L,null!==(u=null===(a=n.chartOptions)||void 0===a?void 0:a.logX)&&void 0!==u&&u,null!==(f=null===(c=n.chartOptions)||void 0===c?void 0:c.logY)&&void 0!==f&&f),M=Math.min(L.width,L.height),F=M>100?1:.2+M/100*.8,D={logX:null===(h=n.chartOptions)||void 0===h?void 0:h.logX,logY:null===(m=n.chartOptions)||void 0===m?void 0:m.logY};e.save(),e.font='11px Roboto, "Roboto Local"',X.drawCoordinateGrid(e,P,b),e.restore();for(let r=0;r<(null===(p=n.series)||void 0===p?void 0:p.length);r++){const o=n.series[r];if(o.points.some((e=>void 0===e.x||void 0===e.y)))continue;(t.width<d.d.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||t.height<d.d.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT)&&(o.showPoints="",n.chartOptions&&(n.chartOptions.showStatistics=[])),o.points.sort(((e,t)=>e.x-t.x));let i=!0;const a=(0,l.Y6)(o);let s=null;if(!o.connectDots||o.showFitLine)if(o.parameters)(null===(g=n.chartOptions)||void 0===g?void 0:g.logX)&&o.parameters[2]>0&&(o.parameters[2]=Math.log10(o.parameters[2])),s=(0,l.kG)(o,a);else{const e=(0,l.PK)(o,a,D);s=e.fittedCurve;const t=[...e.parameters];o.parameters=t,i=!1}v(o,r),_(e,o,{viewport:X,ratio:F}),T(e,o,{viewport:X,ratio:F}),I(e,o,{viewport:X,ratio:F,logOptions:D,showAxes:this.areAxesShown(t),showAxesLabels:this.areAxesLabelsShown(t,n),screenBounds:t,curveFunc:s}),y(e,o,{viewport:X,logOptions:D,showAxes:this.areAxesShown(t),showAxesLabels:this.areAxesLabelsShown(t,n),screenBounds:t,fitFunc:a,userParamsFlag:i}),A(e,o,{viewport:X,ratio:F,showDroplines:this.areDroplinesShown(t),xValue:o.parameters[2],dataBounds:R,curveFunc:s,logOptions:D}),N(e,o,{statistics:null===(w=n.chartOptions)||void 0===w?void 0:w.showStatistics,fitFunc:a,logOptions:D,dataBox:L})}!function(e,t){t.showTitle&&(e.font='12px Roboto, "Roboto Local"',e.textAlign="center",e.fillStyle="black",e.fillText(t.title,t.dataBox.midX-5,t.screenBounds.y+15))}(e,{showTitle:this.isTitleShown(t,n),title:null===(E=n.chartOptions)||void 0===E?void 0:E.title,dataBox:L,screenBounds:t}),function(e,t){if(t.showAxesLabels){e.font='11px Roboto, "Roboto Local"',e.textAlign="center",e.fillStyle="black",e.fillText(t.xAxisName,t.dataBox.midX-5,t.screenBounds.maxY-d.d.X_AXIS_LABEL_BOTTOM_PX_MARGIN),e.translate(t.screenBounds.x,t.screenBounds.y),e.rotate(-Math.PI/2);const n=t.showTitle?d.d.AXES_TOP_PX_MARGIN_WITH_TITLE:d.d.AXES_TOP_PX_MARGIN;e.fillText(t.yAxisName,-(t.dataBox.height/2+n+15),15),e.restore()}}(e,{showTitle:this.isTitleShown(t,n),dataBox:L,screenBounds:t,showAxesLabels:this.areAxesLabelsShown(t,n),xAxisName:null===(x=n.chartOptions)||void 0===x?void 0:x.xAxisName,yAxisName:null===(C=n.chartOptions)||void 0===C?void 0:C.yAxisName}),function(e,t,n){var r,o,i,a;if(n.showLegend){e.font='11px Roboto, "Roboto Local"';const s=[...new Set(null===(r=t.series)||void 0===r?void 0:r.map((e=>e.columnName)))].filter((e=>null!=e));let l=0;for(let r=0;r<s.length;r++){const u=s[r];(null===(o=t.chartOptions)||void 0===o?void 0:o.showColumnLabel)&&O(e,u,{dataBox:n.dataBox,columnIdx:r,drawnCurvesInLegend:l});const c=null===(i=t.series)||void 0===i?void 0:i.filter((e=>e.columnName===u));for(let o=0;o<(null==c?void 0:c.length);o++){const i=c[o];""!==i.name&&null!==i.name&&void 0!==i.name&&(S(e,i,{dataBox:n.dataBox,ratio:n.ratio,columnIdx:r,drawnCurvesInLegend:l,showColumnLabel:null===(a=t.chartOptions)||void 0===a?void 0:a.showColumnLabel}),l++)}}e.restore()}}(e,n,{showLegend:this.isLegendShown(t),dataBox:L,ratio:F}),e.restore()}render(e,t,n,o,i,a,s){var l,c,f;if(!a.cell.value)return;if(o<d.d.MIN_CELL_RENDERER_PX_WIDTH||i<d.d.MIN_CELL_RENDERER_PX_HEIGHT)return;const h=(null===(l=a.cell.column)||void 0===l?void 0:l.getTag(d.d.TAG_FIT_CHART_FORMAT))===d.d.TAG_FIT_CHART_FORMAT_3DX?(0,u.f)(a.cell.value):X(a),m=new r.Rect(t,n,o,i).inflate(d.d.INFLATE_SIZE,d.d.INFLATE_SIZE);for(const[t,n]of Object.entries(d.d.CONDITION_MAP))if(n(h.series))return void L(e,m);null===(c=h.series)||void 0===c||c.forEach((e=>e.columnName=a.cell.column.name)),(null===(f=h.chartOptions)||void 0===f?void 0:f.mergeSeries)&&(h.series=[R(h.series)]),this.renderCurves(e,m,h)}hitTest(e,t,n){const o=n.xToScreen(t.x),i=n.yToScreen(t.y),a=(t.outlier?d.d.OUTLIER_PX_SIZE:d.d.POINT_PX_SIZE)/2+d.d.OUTLIER_HITBOX_RADIUS;return new r.Rect(o-a,i-a,2*a,2*a).containsPoint(new r.Point(e.offsetX,e.offsetY))}onMouseMove(e,t){var n,o,a,c,f;if(!e.cell.value)return;const h=e.bounds.inflate(d.d.INFLATE_SIZE,d.d.INFLATE_SIZE);if(h.width<d.d.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||h.height<d.d.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT){const n=i.canvas(300,200);this.render(n.getContext("2d"),0,0,300,200,e,null);const r=i.divV([n]);i.tooltip.show(r,t.x,t.y)}const m=e.cell.column.getTag(d.d.TAG_FIT_CHART_FORMAT)===d.d.TAG_FIT_CHART_FORMAT_3DX?(0,u.f)(e.cell.value):X(e);if(h.width>=d.d.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH&&h.height>=d.d.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT){const e=G(h,this.areAxesLabelsShown(h,m),this.isTitleShown(h,m))[0],u=(0,l.dU)(m),p=new s.l(u,e,null!==(o=null===(n=m.chartOptions)||void 0===n?void 0:n.logX)&&void 0!==o&&o,null!==(c=null===(a=m.chartOptions)||void 0===a?void 0:a.logY)&&void 0!==c&&c);for(let e=0;e<(null===(f=m.series)||void 0===f?void 0:f.length);e++)if("points"===m.series[e].showPoints)for(let n=0;n<m.series[e].points.length;n++){const o=m.series[e].points[n];if(this.hitTest(t,o,p))return i.tooltip.show(i.divV([i.divText(`x: ${r.format(o.x,"#0.000")}`),i.divText(`y: ${r.format(o.y,"#0.000")}`)]),t.x+16,t.y+16),void(!m.series[e].connectDots&&m.series[e].clickToToggle&&h.width>=d.d.MIN_AXES_CELL_PX_WIDTH&&h.height>=d.d.MIN_AXES_CELL_PX_HEIGHT&&(document.body.style.cursor="pointer"))}i.tooltip.hide()}document.body.style.cursor="default"}}},363:(e,t,n)=>{"use strict";n.r(t),n.d(t,{_FitViewer:()=>I,_initCurves:()=>x,_package:()=>g,addAggrStatisticsColumn:()=>C,addStatisticsColumn:()=>A,curveFitDemo:()=>y,fitCellRenderer:()=>E});var r=n(976),o=n(188),i=n(874),a=n(870),s=n(184),l=n(102);const u=rxjs.operators,c=rxjs;var f=n(638);class d extends s.${constructor(){super(new i.cv),this.curvesColumnNames=[],this.showSelectedRowsCurves=!1,this.showCurrentRowCurve=!0,this.showMouseOverRowCurve=!0,this.mergeColumnSeries=!1,this.rows=[],this.data=new l.cY,this.curvesColumnNames=this.addProperty("curvesColumnNames",r.TYPE.COLUMN_LIST,[],{semType:f.d.FIT_SEM_TYPE}),this.showSelectedRowsCurves=this.bool("showSelectedRowsCurves",!1,{description:"Adds curves from the selected rows"}),this.showCurrentRowCurve=this.bool("showCurrentRowCurve",!0),this.showMouseOverRowCurve=this.bool("showMouseOverRowCurve",!0),this.mergeColumnSeries=this.bool("mergeColumnSeries",!1);for(const e of l.kW)this.addProperty("mergeSeries"===e.name?"mergeCellSeries":e.name,e.propertyType,e.defaultValue,e.options)}static fromChartData(e){let t=new d;return t.data=e,t.render(),t}applyViewerProperties(){(0,i.BI)(l.kW,this,this.data.chartOptions)}mergeViewerChartOptions(){for(const e of l.kW)if(["logX","logY","allowXZeroes","mergeCellSeries","showColumnLabel"].includes("mergeSeries"===e.name?"mergeCellSeries":e.name)?void 0!==this["mergeSeries"===e.name?"mergeCellSeries":e.name]:void 0!==this.props.get(e.name)&&this.props.get(e.name)!==e.defaultValue){if(["title","xAxisName","yAxisName"].includes(e.name)&&""===this.props.get(e.name))continue;["logX","logY","allowXZeroes","mergeCellSeries","showColumnLabel"].includes("mergeSeries"===e.name?"mergeCellSeries":e.name)?this.data.chartOptions[e.name]=this[e.name]:this.data.chartOptions[e.name]=this.props.get(e.name)}}createChartData(){var e,t,n,o,a,s;if(0===(null===(e=this.curvesColumnNames)||void 0===e?void 0:e.length))return;this.rows.length=0;let u=-1;this.showCurrentRowCurve&&-1!==this.dataFrame.currentRowIdx&&this.rows.push(this.dataFrame.currentRowIdx),this.showMouseOverRowCurve&&-1!==this.dataFrame.mouseOverRowIdx&&this.rows.push(this.dataFrame.mouseOverRowIdx),this.showSelectedRowsCurves&&-1!==this.dataFrame.mouseOverRowIdx&&(u=this.rows.length,this.rows.push(...this.dataFrame.selection.getSelectedIndexes())),this.data=new l.cY;const c=null===(t=this.tableView)||void 0===t?void 0:t.grid,f=this.props.get("mergeCellSeries"),d=[];for(const e of this.curvesColumnNames){const t=[];for(const r of new Set(this.rows)){const o=c.cell(e,c.tableRowToGrid(r));if(""===o.cell.value)continue;const a=(0,i.W$)(o);null===(n=a.series)||void 0===n||n.forEach((e=>e.columnName=o.cell.column.name));const s=a.chartOptions;if(null!=s&&(d[d.length]=s),f){const e=(0,i.Qp)(a.series);void 0!==(null==s?void 0:s.title)&&""!==(null==s?void 0:s.title)&&(e.name=null==s?void 0:s.title),a.series=[e]}t.push(...a.series)}this.mergeColumnSeries?null===(o=this.data.series)||void 0===o||o.push((0,i.Qp)(t)):null===(a=this.data.series)||void 0===a||a.push(...t)}this.data.chartOptions=(0,i.l$)(d),this.mergeViewerChartOptions(),null===(s=this.data.series)||void 0===s||s.forEach(((e,t)=>{var n,o,i,a,s;if(e.pointColor=r.Color.toHtml(r.Color.getCategoricalColor((null===(n=this.data.series)||void 0===n?void 0:n.length)>20?0:t)),e.fitLineColor=r.Color.toHtml(r.Color.getCategoricalColor((null===(o=this.data.series)||void 0===o?void 0:o.length)>20?0:t)),e.showCurveConfidenceInterval=!1,e.droplines=[],(null===(i=this.data.series)||void 0===i?void 0:i.length)>20&&(e.showPoints="",e.lineStyle="solid"),(null===(a=this.data.series)||void 0===a?void 0:a.length)>10&&(null===(s=this.data.series)||void 0===s?void 0:s.length)<100&&t>=u){const t=r.Color.fromHtml(e.fitLineColor);e.fitLineColor=`rgba(${r.Color.r(t)}, ${r.Color.g(t)}, ${r.Color.b(t)}, 0.2)`}}))}onPropertyChanged(e){var t,n,r,o,i;"curvesColumnNames"===(null==e?void 0:e.name)&&(this.props.set("showColumnLabel",(null===(t=this.curvesColumnNames)||void 0===t?void 0:t.length)>1),this.showColumnLabel=(null===(n=this.curvesColumnNames)||void 0===n?void 0:n.length)>1),["logX","logY","allowXZeroes","mergeCellSeries","showColumnLabel"].includes("mergeSeries"===(null==e?void 0:e.name)?"mergeCellSeries":null!==(r=null==e?void 0:e.name)&&void 0!==r?r:"")&&(this["mergeSeries"===(null==e?void 0:e.name)?"mergeCellSeries":null!==(o=null==e?void 0:e.name)&&void 0!==o?o:""]=this[null!==(i=null==e?void 0:e.name)&&void 0!==i?i:""]),this.applyViewerProperties(),this.createChartData(),this.render()}onTableAttached(){var e;const t=null===(e=this.tableView)||void 0===e?void 0:e.grid,n=this.dataFrame.columns.bySemType(f.d.FIT_SEM_TYPE);null!==n&&(this.curvesColumnNames=[n.name]),(0,c.merge)(this.dataFrame.onCurrentCellChanged,t.onCellMouseEnter,this.dataFrame.onSelectionChanged).pipe((0,u.debounce)((e=>(0,c.interval)(50)))).subscribe((e=>{this.createChartData(),this.render()}))}_showErrorMessage(e){this.root.appendChild(a.divText(e,"d4-viewer-error"))}_removeErrorMessage(){const e=this.root.getElementsByClassName("d4-viewer-error")[0];e&&this.root.removeChild(e)}render(){var e;const t=this.canvas.getContext("2d");t.clearRect(0,0,this.canvas.width,this.canvas.height),0!==(null===(e=this.curvesColumnNames)||void 0===e?void 0:e.length)?(this._removeErrorMessage(),this.renderer.renderCurves(t,new r.Rect(0,0,this.canvas.width,this.canvas.height).inflate(f.d.INFLATE_SIZE,f.d.INFLATE_SIZE),this.data)):this._showErrorMessage("The MultiCurveViewer viewer requires a minimum of 1 curves column.")}}var h=n(840),m=n(711),p=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))};const g=new r.Package,v=".sourceColumn",_=".seriesNumber",T=".seriesAggregation",w=".statistics";function E(){return new i.cv}function I(){return new d}function y(){return p(this,void 0,void 0,(function*(){yield(0,h.DI)()}))}function x(){r.ObjectHandler.register(new o.Z)}function A(e,t,n,a,s){var l;const u=r.Viewer.grid(e),c=u.col(t),d=r.Column.float(`${t}_${a}_${n}`,null===(l=c.column)||void 0===l?void 0:l.length);d.tags[v]=t,d.tags[_]=s,d.tags[w]=n,d.init((e=>{var a,l,c,d,h;const p=r.GridCell.fromColumnRow(u,t,u.tableRowToGrid(e));if(""===p.cell.value)return null;const g=p.cell.column.getTag(f.d.TAG_FIT_CHART_FORMAT)===f.d.TAG_FIT_CHART_FORMAT_3DX?(0,m.f)(p.cell.value):(0,i.W$)(p);if(void 0===g.series[s]||g.series[s].points.every((e=>e.outlier)))return null;(null===(a=g.chartOptions)||void 0===a?void 0:a.allowXZeroes)&&(null===(l=g.chartOptions)||void 0===l?void 0:l.logX)&&(null===(c=g.series)||void 0===c?void 0:c.some((e=>e.points.some((e=>0===e.x)))))&&(0,i.kb)(g);const v={logX:null===(d=g.chartOptions)||void 0===d?void 0:d.logX,logY:null===(h=g.chartOptions)||void 0===h?void 0:h.logY};return(0,o.hS)(g.series[s],v)[n]})),e.columns.insert(d,c.idx)}function C(e,t,n,a){var s;const l=r.Viewer.grid(e),u=l.col(t),c=r.Column.float(`${t}_${a}_${n}`,null===(s=u.column)||void 0===s?void 0:s.length);c.tags[v]=t,c.tags[T]=a,c.tags[w]=n,c.init((e=>{var s,u,c,d;const h=r.GridCell.fromColumnRow(l,t,l.tableRowToGrid(e));if(""===h.cell.value)return null;const p=h.cell.column.getTag(f.d.TAG_FIT_CHART_FORMAT)===f.d.TAG_FIT_CHART_FORMAT_3DX?(0,m.f)(h.cell.value):(0,i.W$)(h);return(null===(s=p.series)||void 0===s?void 0:s.every((e=>e.points.every((e=>e.outlier)))))?null:((null===(u=p.chartOptions)||void 0===u?void 0:u.allowXZeroes)&&(null===(c=p.chartOptions)||void 0===c?void 0:c.logX)&&(null===(d=p.series)||void 0===d?void 0:d.some((e=>e.points.some((e=>0===e.x)))))&&(0,i.kb)(p),(0,o.No)(p,a)[n])})),e.columns.insert(c,u.idx)}},976:e=>{"use strict";e.exports=DG},469:e=>{"use strict";e.exports=grok},870:e=>{"use strict";e.exports=ui},414:e=>{"use strict";e.exports=wu}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r=n(363);curves=r})();
|
|
2
2
|
//# sourceMappingURL=package.js.map
|