@datagrok/curves 1.5.0 → 1.8.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/README.md +36 -8
- 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/img/plate-dose-response-series.gif +0 -0
- package/img/plate-readers.gif +0 -0
- package/package.json +13 -11
- package/src/fit/const.ts +3 -2
- package/src/fit/fit-grid-cell-handler.ts +64 -59
- package/src/fit/fit-renderer.ts +142 -79
- package/src/fit/multi-curve-viewer.ts +32 -11
- package/src/fit/render-utils.ts +196 -138
- package/src/package-test.ts +7 -1
- package/src/package.g.ts +8 -0
- package/src/package.ts +253 -10
- package/src/plate/excel-plates.ts +112 -0
- package/src/plate/plate-cell-renderer.ts +40 -0
- package/src/plate/plate-reader.ts +28 -0
- package/src/plate/plate-widget.ts +478 -0
- package/src/plate/plate.ts +446 -0
- package/src/plate/readers/bmg-pherastar-96.ts +42 -0
- package/src/plate/readers/delfia-envision-96-max-rlu.ts +15 -0
- package/src/plate/readers/delfia-envision-by-row.ts +18 -0
- package/src/plate/readers/spectramax.ts +43 -0
- package/src/plate/utils.ts +129 -0
- package/src/tests/curves-cell-renderer-tests.ts +41 -22
- package/src/tests/fit-tests.ts +46 -11
- package/src/tests/plate-tests.ts +154 -0
- package/src/tests/transform-tests.ts +2 -2
- package/src/fit/cell-render-viewer.ts +0 -54
package/dist/package.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var curves;(()=>{var e={368:(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,{k:()=>r})},71:(e,t,n)=>{"use strict";n.d(t,{G7:()=>y,oH:()=>p,dZ:()=>m,xs:()=>T,W6:()=>N,IL:()=>x,O8:()=>S,ah:()=>O,TV:()=>C,mW:()=>b,nK:()=>w});var r,o=n(82),i=n(572);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]).likelihood}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,w=0,T=0,x=0;const y=new Float32Array(h),E=new Float32Array(h),I=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===_&&(w=p[0],T=2*p[g[0]]),C[_]=w,++_,w=p[g[0]],T-w>i)x=0;else if(++x,x>2*d)break;T=w,s(y,h,g[v],m),l(y,E,g[v],m,u,h,r,o);const t=e(E).likelihood;if(t<p[g[v]]){l(y,I,g[v],m,c,h,r,o);const n=e(I).likelihood;if(n<t){p[g[v]]=n;for(let e=0;e<h;e++)m[g[v]][e]=I[e];continue}p[g[v]]=t;for(let e=0;e<h;e++)m[g[v]][e]=E[e];continue}l(y,A,g[v],m,f,h,r,o);const n=e(A).likelihood;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}};var c=n(391),f=n.n(c);function d(e,t,n,r){const o=t-n,i=new Array(e);for(let t=0;t<e;t++){const e=r();i[t]=n+e*o}return i}function h(e,t,n,r,i=1,s=null,l=!0){const c=function(e,t,n){const r=f()("12345"),o=t.length,i=new Array(e);for(let t=0;t<e;t++)i[t]=new Float32Array(o);for(let a=0;a<o;a++)if(t[a]===n[a])for(let n=0;n<e;n++)i[n][a]=t[a];else{const o=d(e,t[a],n[a],r);for(let t=0;t<e;t++)i[t][a]=o[t]}return i}(i,n,t),h=[],m=[],p=[];let g,v=0,_=null;for(g=0;g<i;++g)try{if(0===g&&l){const t=new Float32Array(s.length).map((e=>-1/0)),n=new Float32Array(s.length).map((e=>1/0));h.push(u(e,c[g],r,t,n))}else h.push(u(e,c[g],r,t,n))}catch(e){if(e instanceof a)throw new Error(`Inconsistent dataframes: ${e.message}`);++v,m.push(e instanceof Error?e.message:"Platform issue"),p.push(c[g])}if(v>0){const e=n.length,t=new Array(e);for(let n=0;n<e;++n)t[n]=new Float32Array(v);p.forEach(((e,n)=>e.forEach(((e,r)=>t[r][n]=e)))),_=o.DataFrame.fromColumns(t.map(((e,t)=>o.Column.fromFloat32Array(`arg${t}`,e)))),_.columns.add(o.Column.fromStrings("Issue",m))}return{extremums:h,fails:_}}const m={CONSTANT:"constant",PROPORTIONAL:"proportional",COMBINED:"combined"};class p{constructor(){this.chartOptions={},this.seriesOptions={},this.series=[]}}class g{}class v extends g{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 _={linear:new class extends g{get name(){return E}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 g{get name(){return y}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}},"log-linear":new class extends g{get name(){return I}get parameterNames(){return["Slope","Intercept"]}y(e,t){return function(e,t){const n=e[0],r=e[1];return n*Math.log(t+1)+r}(e,t)}getInitialParameters(e,t){const n=new Float32Array(2);return n.set([-5,100]),n}},exponential:new class extends g{get name(){return A}get parameterNames(){return["Mantissa","Power"]}y(e,t){return function(e,t){const n=e[0],r=e[1];return n*Math.exp(t*r)}(e,t)}getInitialParameters(e,t){const n=new Float32Array(2);return n.set([100,-2]),n}}},w=[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})],T=[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:w.map((e=>e.name)),inputType:"MultiChoice",friendlyName:"Statistics"})],x=[o.Property.js("fitFunction",o.TYPE.STRING,{category:"Fitting",choices:Object.keys(_),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,friendlyName:"Marker"}),o.Property.js("outlierMarkerType",o.TYPE.STRING,{category:"Rendering",defaultValue:"outlier",choices:["asterisk","circle","cross border","diamond","outlier","square","star","triangle bottom","triangle left","triangle right","triangle top"],nullable:!1,friendlyName:"Outlier Marker"}),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:""})],y="sigmoid",E="linear",I="log-linear",A="exponential";function C(e){if("string"==typeof e)return _[e];if(!_[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 v(t,i,a,n);_[t]=s}return _[e.name]}function N(e,t,n,i){const a=t.y;let s=t.getInitialParameters(e.x,e.y);const l=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])),c=u.map((e=>Math.pow(e,2)));for(let e=0;e<c.length;e++)[m.CONSTANT,m.COMBINED].includes(n)?i+=c[e]:n===m.PROPORTIONAL&&(a+=c[e]/(l[e]*l[e]));i=Math.sqrt(i/c.length),a=Math.sqrt(a/c.length),n===m.COMBINED&&({sigmaA:i,sigmaB:a}=R(i,a,c,l));const f=[];for(let e=0;e<c.length;e++)f[e]=Math.pow(i+a*l[e],2),o+=c[e]/f[e]+Math.log(2*Math.PI*f[e]);return{likelihood:o,residuals:u}}}(a,e,n),u=new Float32Array(t.parameterNames.length),c=new Float32Array(t.parameterNames.length);for(let e=0;e<t.parameterNames.length;e++)u[e]=0===s[e]?-1:s[e]-Math.abs(.5*s[e]),c[e]=0===s[e]?1:s[e]+Math.abs(.5*s[e]);const f=o.BitSet.create(2*t.parameterNames.length);if(i&&0!==i.length)for(let e=0;e<i.length;e++)void 0!==i[e].min&&null!==i[e].min&&(u[e]=i[e].min,f.set(2*e,!0)),void 0!==i[e].max&&null!==i[e].max&&(c[e]=i[e].max,f.set(2*e+1,!0));const d=e=>{const t=l(e.point).residuals;let n=0,r=0;for(let e=0;e<t.length;e++)t.length/4>e?n+=Math.pow(t[e],2):3*t.length/4>e?r+=Math.pow(t[e],2):n+=Math.pow(t[e],2);return n/r};let p,g=-1,v=0,_=null,w=0;for(;;){p=h(l,u,c,{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},10,s),w=0;for(let e=1;e<p.extremums.length;e++)p.extremums[e].cost<p.extremums[w].cost&&(w=e);const e=d(p.extremums[w]);if(null===_?_=e:e<_?(_=e,v=0):v++,-1===g){if(_<=2)break;g++}if(g>40)break;if(3===v)break;for(let e=0;e<t.parameterNames.length;e++)f.get(2*e)||(u[e]=s[e]-Math.abs(p.extremums[w].point[e]*(v+1.5))),f.get(2*e+1)||(c[e]=s[e]+Math.abs(p.extremums[w].point[e]*(v+1.5)))}return s=p.extremums[w].point,{fittedCurve:O(a,s),parameters:s}}function O(e,t){return n=>e(t,n)}function S(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++)[m.CONSTANT,m.COMBINED].includes(n)?o+=u[e]:n===m.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===m.COMBINED&&({sigmaA:o,sigmaB:i}=R(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 b(e,t,n,r=!0){const o=O(n,t);return{rSquared:r?P(o,e):void 0,auc:r?L(o,e):void 0,interceptX:t[2],interceptY:o(t[2]),slope:t[1],top:t[0],bottom:t[3]}}function L(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 P(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 R(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}}},999:(e,t,n)=>{"use strict";n.d(t,{Kh:()=>a,VA:()=>m,_T:()=>f,fY:()=>h,nT:()=>d,s$:()=>u,zB:()=>c});var r=n(82),o=n(71);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.xs),seriesOptions:i(o.IL)}}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.TV)(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.ah)(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.W6)(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.dZ.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.O8)(s,l,t.y,.05,null!==(a=e.errorModel)&&void 0!==a?a:o.dZ.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.mW)(i,a,t.y,!0)}},293:(e,t,n)=>{"use strict";n.d(t,{L:()=>s});var r=n(82);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)}}},572: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),w=1;w<=12;w++){var T,x=v+_*(6<w?i[(T=12-w+1)-1]:-i[(T=w)-1]),y=x*x;if(y>60)break;var E=2*e.normal.cdf(x,0,1,1,0)*.5-2*e.normal.cdf(x,n,1,1,0)*.5;E>=t.exp(-30/m)&&(g+=E=a[T-1]*t.exp(-.5*y)*t.pow(E,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 w,T;8<_?(w=_-8-1,T=f+d*t.log(v+s[w]*u)-(s[w]*u+v)*h):(w=_-1,T=f+d*t.log(v-s[w]*u)+(s[w]*u-v)*h),T>=-30&&(g+=r(8<_?n*t.sqrt(.5*(s[w]*u+v)):n*t.sqrt(.5*(-s[w]*u+v)),1,a)*l[w]*t.exp(T))}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)},391:(e,t,n)=>{var r=n(180),o=n(181),i=n(31),a=n(67),s=n(833),l=n(717),u=n(801);u.alea=r,u.xor128=o,u.xorwow=i,u.xorshift7=a,u.xor4096=s,u.tychei=l,e.exports=u},180:function(e,t,n){var r;!function(e,o){function i(e){var t,n=this,r=(t=4022871197,function(e){e=String(e);for(var n=0;n<e.length;n++){var r=.02519603282416938*(t+=e.charCodeAt(n));r-=t=r>>>0,t=(r*=t)>>>0,t+=4294967296*(r-=t)}return 2.3283064365386963e-10*(t>>>0)});n.next=function(){var e=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=e-(n.c=0|e)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(e),n.s0<0&&(n.s0+=1),n.s1-=r(e),n.s1<0&&(n.s1+=1),n.s2-=r(e),n.s2<0&&(n.s2+=1),r=null}function a(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function s(e,t){var n=new i(e),r=t&&t.state,o=n.next;return o.int32=function(){return 4294967296*n.next()|0},o.double=function(){return o()+11102230246251565e-32*(2097152*o()|0)},o.quick=o,r&&("object"==typeof r&&a(r,n),o.state=function(){return a(n,{})}),o}o&&o.exports?o.exports=s:n.amdD&&n.amdO?void 0===(r=function(){return s}.call(t,n,t,o))||(o.exports=r):this.alea=s}(0,e=n.nmd(e),n.amdD)},717:function(e,t,n){var r;!function(e,o){function i(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,o=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^o,o=o-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^o,t.a=o-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var r=0;r<n.length+20;r++)t.b^=0|n.charCodeAt(r),t.next()}function a(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function s(e,t){var n=new i(e),r=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,r&&("object"==typeof r&&a(r,n),o.state=function(){return a(n,{})}),o}o&&o.exports?o.exports=s:n.amdD&&n.amdO?void 0===(r=function(){return s}.call(t,n,t,o))||(o.exports=r):this.tychei=s}(0,e=n.nmd(e),n.amdD)},181:function(e,t,n){var r;!function(e,o){function i(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=0|n.charCodeAt(r),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function s(e,t){var n=new i(e),r=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,r&&("object"==typeof r&&a(r,n),o.state=function(){return a(n,{})}),o}o&&o.exports?o.exports=s:n.amdD&&n.amdO?void 0===(r=function(){return s}.call(t,n,t,o))||(o.exports=r):this.xor128=s}(0,e=n.nmd(e),n.amdD)},833:function(e,t,n){var r;!function(e,o){function i(e){var t=this;t.next=function(){var e,n,r=t.w,o=t.X,i=t.i;return t.w=r=r+1640531527|0,n=o[i+34&127],e=o[i=i+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=o[i]=n^e,t.i=i,n+(r^r>>>16)|0},function(e,t){var n,r,o,i,a,s=[],l=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,l=Math.max(l,t.length)),o=0,i=-32;i<l;++i)t&&(r^=t.charCodeAt((i+32)%t.length)),0===i&&(a=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,i>=0&&(a=a+1640531527|0,o=0==(n=s[127&i]^=r+a)?o+1:0);for(o>=128&&(s[127&(t&&t.length||0)]=-1),o=127,i=512;i>0;--i)r=s[o+34&127],n=s[o=o+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[o]=r^n;e.w=a,e.X=s,e.i=o}(t,e)}function a(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function s(e,t){null==e&&(e=+new Date);var n=new i(e),r=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,r&&(r.X&&a(r,n),o.state=function(){return a(n,{})}),o}o&&o.exports?o.exports=s:n.amdD&&n.amdO?void 0===(r=function(){return s}.call(t,n,t,o))||(o.exports=r):this.xor4096=s}(0,e=n.nmd(e),n.amdD)},67:function(e,t,n){var r;!function(e,o){function i(e){var t=this;t.next=function(){var e,n,r=t.x,o=t.i;return e=r[o],n=(e^=e>>>7)^e<<24,n^=(e=r[o+1&7])^e>>>10,n^=(e=r[o+3&7])^e>>>3,n^=(e=r[o+4&7])^e<<7,e=r[o+7&7],n^=(e^=e<<13)^e<<9,r[o]=n,t.i=o+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n<t.length;++n)r[7&n]=r[7&n]<<15^t.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n?r[7]=-1:r[n],e.x=r,e.i=0,n=256;n>0;--n)e.next()}(t,e)}function a(e,t){return t.x=e.x.slice(),t.i=e.i,t}function s(e,t){null==e&&(e=+new Date);var n=new i(e),r=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,r&&(r.x&&a(r,n),o.state=function(){return a(n,{})}),o}o&&o.exports?o.exports=s:n.amdD&&n.amdO?void 0===(r=function(){return s}.call(t,n,t,o))||(o.exports=r):this.xorshift7=s}(0,e=n.nmd(e),n.amdD)},31:function(e,t,n){var r;!function(e,o){function i(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=0|n.charCodeAt(r),r==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function s(e,t){var n=new i(e),r=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,r&&("object"==typeof r&&a(r,n),o.state=function(){return a(n,{})}),o}o&&o.exports?o.exports=s:n.amdD&&n.amdO?void 0===(r=function(){return s}.call(t,n,t,o))||(o.exports=r):this.xorwow=s}(0,e=n.nmd(e),n.amdD)},801:function(e,t,n){var r;!function(o,i,a){var s,l=256,u=a.pow(l,6),c=a.pow(2,52),f=2*c,d=l-1;function h(e,t,n){var r=[],d=v(g((t=1==t?{entropy:!0}:t||{}).entropy?[e,_(i)]:null==e?function(){try{var e;return s&&(e=s.randomBytes)?e=e(l):(e=new Uint8Array(l),(o.crypto||o.msCrypto).getRandomValues(e)),_(e)}catch(e){var t=o.navigator,n=t&&t.plugins;return[+new Date,o,n,o.screen,_(i)]}}():e,3),r),h=new m(r),w=function(){for(var e=h.g(6),t=u,n=0;e<c;)e=(e+n)*l,t*=l,n=h.g(1);for(;e>=f;)e/=2,t/=2,n>>>=1;return(e+n)/t};return w.int32=function(){return 0|h.g(4)},w.quick=function(){return h.g(4)/4294967296},w.double=w,v(_(h.S),i),(t.pass||n||function(e,t,n,r){return r&&(r.S&&p(r,h),e.state=function(){return p(h,{})}),n?(a.random=e,t):e})(w,d,"global"in t?t.global:this==a,t.state)}function m(e){var t,n=e.length,r=this,o=0,i=r.i=r.j=0,a=r.S=[];for(n||(e=[n++]);o<l;)a[o]=o++;for(o=0;o<l;o++)a[o]=a[i=d&i+e[o%n]+(t=a[o])],a[i]=t;(r.g=function(e){for(var t,n=0,o=r.i,i=r.j,a=r.S;e--;)t=a[o=d&o+1],n=n*l+a[d&(a[o]=a[i=d&i+t])+(a[i]=t)];return r.i=o,r.j=i,n})(l)}function p(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function g(e,t){var n,r=[],o=typeof e;if(t&&"object"==o)for(n in e)try{r.push(g(e[n],t-1))}catch(e){}return r.length?r:"string"==o?e:e+"\0"}function v(e,t){for(var n,r=e+"",o=0;o<r.length;)t[d&o]=d&(n^=19*t[d&o])+r.charCodeAt(o++);return _(t)}function _(e){return String.fromCharCode.apply(0,e)}if(v(a.random(),i),e.exports){e.exports=h;try{s=n(234)}catch(e){}}else void 0===(r=function(){return h}.call(t,n,t,e))||(e.exports=r)}("undefined"!=typeof self?self:this,[],Math)},326:(e,t,n)=>{"use strict";n.d(t,{D:()=>a});var r=n(82),o=n(389),i=n(755);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.lR);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)}}},95:(e,t,n)=>{"use strict";n.d(t,{h:()=>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))}))}},471:(e,t,n)=>{"use strict";n.d(t,{Z1:()=>a}),n(82);var r=n(328),o=n(860),i=(n(71),n(991),n(95),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)}))}},48:(e,t,n)=>{"use strict";n.d(t,{JR:()=>v,VK:()=>g,e4:()=>T});var r=n(82),o=n(389),i=n(999),a=n(71),s=n(755),l=n(326),u=n(283),c=n(95),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.zB)(e);if(e.parameters)t.logX&&e.parameters[2]>0&&(e.parameters[2]=Math.log10(e.parameters[2]));else{const r=(0,i.nT)(e,n,t).parameters;e.parameters=[...r]}return(0,i.VA)(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.K)(n);e.set(t,JSON.stringify(r))}e.setTag(c.h.TAG_FIT_CHART_FORMAT,"")}function w(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.h.FIT_SEM_TYPE);for(let e=0;e<r.length;e++){a.xs.map((t=>{r[e].temp[`${d}-custom-${t.name}`]=!1})),a.IL.map((t=>{r[e].temp[`${h}-custom-${t.name}`]=!1})),r[e].getTag(c.h.TAG_FIT_CHART_FORMAT)===c.h.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.xs.map((t=>{i.chartOptions&&void 0!==i.chartOptions[t.name]&&(r[e].temp[`${d}-custom-${t.name}`]=!0)})),a.IL.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.Ig)(e.cell.dataFrame):(0,s.bc)(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.h.TAG_FIT]=JSON.stringify(l),t=e.cell.dataFrame.columns.bySemTypeAll(c.h.FIT_SEM_TYPE)):(e.cell.column.tags[c.h.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.bc)(t[e]);n===d?delete r.chartOptions[i]:delete r.seriesOptions[i],t[e].tags[c.h.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 T extends r.ObjectHandler{get type(){return"GridCell"}isApplicable(e){return e instanceof r.GridCell&&e.cellType===c.h.FIT_CELL_TYPE}renderProperties(e,t=null){var n,u,c,m,p,_,T,x,y,E,I;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.j$)(e),S=(0,s.bc)(e.cell.column),b=(0,s.Ig)(e.cell.dataFrame),L={onValueChanged:t=>w(e,t,h,N.value)},P={onValueChanged:t=>w(e,t,d,N.value)};(0,s.Yc)(null===(n=b.seriesOptions)||void 0===n?void 0:n.pointColor)||(0,s.Yc)(null===(u=S.seriesOptions)||void 0===u?void 0:u.pointColor)||(O.seriesOptions?(0,s.Yc)(O.seriesOptions.pointColor)||(O.seriesOptions.pointColor=r.Color.toHtml(r.Color.getCategoricalColor(0))):(0,s.Yc)(O.series?O.series[0].pointColor:"")||(O.series[0].pointColor=r.Color.toHtml(r.Color.getCategoricalColor(0)))),(0,s.Yc)(null===(c=b.seriesOptions)||void 0===c?void 0:c.fitLineColor)||(0,s.Yc)(null===(m=S.seriesOptions)||void 0===m?void 0:m.fitLineColor)||(O.seriesOptions?(0,s.Yc)(O.seriesOptions.fitLineColor)||(O.seriesOptions.fitLineColor=r.Color.toHtml(r.Color.getCategoricalColor(0))):(0,s.Yc)(O.series?O.series[0].fitLineColor:"")||(O.series[0].fitLineColor=r.Color.toHtml(r.Color.getCategoricalColor(0)))),(0,s.Yc)(null===(p=b.seriesOptions)||void 0===p?void 0:p.outlierColor)||(0,s.Yc)(null===(_=S.seriesOptions)||void 0===_?void 0:_.outlierColor)||(O.seriesOptions?(0,s.Yc)(O.seriesOptions.outlierColor)||(O.seriesOptions.outlierColor=r.Color.toHtml(r.Color.red)):(0,s.Yc)(O.series?O.series[0].outlierColor:"")||(O.series[0].outlierColor=r.Color.toHtml(r.Color.red))),(0,s.g2)(a.IL,S.seriesOptions,O.seriesOptions?O.seriesOptions:O.series&&null!==(T=O.series[0])&&void 0!==T?T:{}),(0,s.g2)(a.IL,b.seriesOptions,O.seriesOptions?O.seriesOptions:O.series&&null!==(x=O.series[0])&&void 0!==x?x:{}),(0,s.g2)(a.xs,S.chartOptions,O.chartOptions?O.chartOptions:{}),(0,s.g2)(a.xs,b.chartOptions,O.chartOptions?O.chartOptions:{}),(null===(y=O.chartOptions)||void 0===y?void 0:y.allowXZeroes)&&(null===(E=O.chartOptions)||void 0===E?void 0:E.logX)&&(null===(I=O.series)||void 0===I?void 0:I.some((e=>e.points.some((e=>0===e.x)))))&&(0,s.B3)(O);const R=o.form([N]),X=a.IL.map((e=>o.input.forProperty(e,O.seriesOptions?O.seriesOptions:O.series[0],L)));o.forms.addGroup(R,"Series options",X),o.forms.addGroup(R,"Chart options",a.xs.map((e=>o.input.forProperty(e,O.chartOptions,P)))),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())}}),D=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}),G=o.input.forProperty(D,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,G.root]:[F.root]),u=(0,i.s$)(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.nK,{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,G.stringValue);l.appendChild(o.panel([o.h1(`series ${G.stringValue}`),o.input.form(t,a.nK,{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:G.stringValue};yield r.Func.find({name:"addAggrStatisticsColumn"})[0].prepare(n).call(void 0,void 0,{processed:!1})}))),`Calculate ${t.property.name} ${G.stringValue} for the whole column`))})]))}return l}return A.addPane("Fit",(()=>Y())),A.addPane("Chart",(()=>l.D.fromGridCell(e).root)),A.root}}},283:(e,t,n)=>{"use strict";n.d(t,{K:()=>u});var r=n(82),o=n(71);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.G7;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}}},755:(e,t,n)=>{"use strict";n.d(t,{lR:()=>B,j$:()=>X,bc:()=>F,Ig:()=>M,Yc:()=>G,LX:()=>P,g2:()=>L,wU:()=>R,B3:()=>Y});var r=n(82),o=n(328),i=n(389),a=n(71),s=n(293),l=n(999),u=n(283),c=n(326),f=n(48),d=n(95),h=n(368);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 w(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=i.outlierMarker?i.outlierMarker:t.outlierMarkerType,u=t.connectDots?d.h.POINT_PX_SIZE*n.ratio:i.outlier?d.h.OUTLIER_PX_SIZE*n.ratio:i.size?i.size:d.h.POINT_PX_SIZE*n.ratio;r.Paint.marker(e,t.connectDots?s:i.outlier?l:s,n.viewport.xToScreen(i.x),n.viewport.yToScreen(i.y),a,u),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.k)(s);if(e.beginPath(),T(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.h.CANDLESTICK_OUTLIER_PX_SIZE*n.ratio);i=null}}}(e,t,n))}function T(e,t){x(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)),x(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.h.CANDLESTICK_MEDIAN_PX_SIZE*t.ratio)}function x(e,t,n,r){e.moveTo(r.xToScreen(t)-d.h.CANDLESTICK_BORDER_PX_SIZE/2,r.yToScreen(n)),e.lineTo(r.xToScreen(t)+d.h.CANDLESTICK_BORDER_PX_SIZE/2,r.yToScreen(n))}function y(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.h.LINE_STYLES[t.lineStyle]);const r=n.showAxes?n.showAxesLabels?d.h.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:d.h.AXES_LEFT_PX_MARGIN:0,o=n.showAxes?d.h.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 E(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.h.CONFIDENCE_INTERVAL_STROKE_COLOR,e.fillStyle=null!==(a=t.confidenceIntervalColor)&&void 0!==a?a:d.h.CONFIDENCE_INTERVAL_FILL_COLOR;const r=(0,l.fY)(t,n.fitFunc,n.userParamsFlag,n.logOptions);I(e,{viewport:n.viewport,logOptions:n.logOptions,showAxes:n.showAxes,showAxesLabels:n.showAxesLabels,screenBounds:n.screenBounds,confidenceIntervals:r,confidenceType:d.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP}),I(e,{viewport:n.viewport,logOptions:n.logOptions,showAxes:n.showAxes,showAxesLabels:n.showAxesLabels,screenBounds:n.screenBounds,confidenceIntervals:r,confidenceType:d.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.BOTTOM}),function(e,t){e.beginPath();const n=t.showAxes?t.showAxesLabels?d.h.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:d.h.AXES_LEFT_PX_MARGIN:0,r=t.showAxes?d.h.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 I(e,t){e.beginPath();const n=t.showAxes?t.showAxesLabels?d.h.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:d.h.AXES_LEFT_PX_MARGIN:0,r=t.showAxes?d.h.AXES_RIGHT_PX_MARGIN:0,o=t.confidenceType===d.h.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.VA)(t,n.fitFunc,n.logOptions);for(let o=0;o<n.statistics.length;o++){const i=n.statistics[o],s=a.nK.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.h.LEGEND_TOP_PX_MARGIN+(n.columnIdx*d.h.LEGEND_RECORD_PX_HEIGHT+d.h.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.h.LEGEND_RECORD_LINE_PX_WIDTH-d.h.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN,n.dataBox.y+d.h.LEGEND_TOP_PX_MARGIN-d.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN+(n.showColumnLabel?d.h.LEGEND_RECORD_PX_HEIGHT*(n.columnIdx+1):0)+d.h.LEGEND_RECORD_PX_HEIGHT*n.drawnCurvesInLegend),e.lineTo(n.dataBox.maxX-o-d.h.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN,n.dataBox.y+d.h.LEGEND_TOP_PX_MARGIN-d.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN+(n.showColumnLabel?d.h.LEGEND_RECORD_PX_HEIGHT*(n.columnIdx+1):0)+d.h.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.h.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN-d.h.LEGEND_RECORD_LINE_PX_WIDTH/2,n.dataBox.y+d.h.LEGEND_TOP_PX_MARGIN-d.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN+(n.showColumnLabel?d.h.LEGEND_RECORD_PX_HEIGHT*(n.columnIdx+1):0)+d.h.LEGEND_RECORD_PX_HEIGHT*n.drawnCurvesInLegend,t.pointColor,d.h.POINT_PX_SIZE*n.ratio),e.fillStyle=t.fitLineColor,e.fillText(t.name,n.dataBox.maxX-o,n.dataBox.y+d.h.LEGEND_TOP_PX_MARGIN+(n.showColumnLabel?d.h.LEGEND_RECORD_PX_HEIGHT*(n.columnIdx+1):0)+d.h.LEGEND_RECORD_PX_HEIGHT*n.drawnCurvesInLegend),e.stroke()}function b(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),Math.min(Math.max(n,0),30)))}function L(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 P(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.h.TAG_FIT_CHART_FORMAT)===d.h.TAG_FIT_CHART_FORMAT_3DX?(0,u.K)(c):null!==(o=JSON.parse(null!=c?c:"{}"))&&void 0!==o?o:{}:(0,l.Kh)(),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),L(a.xs,h.chartOptions,f.chartOptions),L(a.xs,m.chartOptions,f.chartOptions);for(const e of f.series)L(a.IL,f.seriesOptions,e),L(a.IL,h.seriesOptions,e),L(a.IL,m.seriesOptions,e);return f}function M(e){var t,n,r;return JSON.parse(null!==(t=(n=e.tags)[r=d.h.TAG_FIT])&&void 0!==t?t:n[r]=JSON.stringify((0,l.Kh)()))}function F(e){var t,n,r;return JSON.parse(null!==(t=(n=e.tags)[r=d.h.TAG_FIT])&&void 0!==t?t:n[r]=JSON.stringify((0,l.Kh)()))}function D(e,t,n){if(e.width<d.h.MIN_AXES_CELL_PX_WIDTH||e.height<d.h.MIN_AXES_CELL_PX_HEIGHT)return[e,void 0,void 0];const r=t?d.h.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:d.h.AXES_LEFT_PX_MARGIN,o=t?d.h.AXES_BOTTOM_PX_MARGIN_WITH_AXES_LABELS:d.h.AXES_BOTTOM_PX_MARGIN,i=n?d.h.AXES_TOP_PX_MARGIN_WITH_TITLE:d.h.AXES_TOP_PX_MARGIN;return[e.cutLeft(r).cutBottom(o).cutTop(i).cutRight(d.h.AXES_RIGHT_PX_MARGIN),e.getBottom(o).getTop(i).cutLeft(r).cutRight(d.h.AXES_RIGHT_PX_MARGIN),e.getLeft(r).getRight(d.h.AXES_RIGHT_PX_MARGIN).cutBottom(o).cutTop(i)]}function G(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)}}let B=class extends r.GridCellRenderer{get name(){return d.h.FIT_CELL_TYPE}get cellType(){return d.h.FIT_CELL_TYPE}getDefaultSize(e){return{width:d.h.CELL_DEFAULT_WIDTH,height:d.h.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.h.TAG_FIT_CHART_FORMAT)===d.h.TAG_FIT_CHART_FORMAT_3DX?(0,u.K)(e.cell.value):X(e);for(const[e,t]of Object.entries(d.h.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.h.INFLATE_SIZE,d.h.INFLATE_SIZE),_=D(v,this.areAxesLabelsShown(v,g),this.isTitleShown(v,g))[0],w=(0,l.s$)(g),T=new s.L(w,_,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.h.MIN_AXES_CELL_PX_WIDTH||v.height<d.h.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,T)){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.JR)(g,r.tags[".seriesAggregation"]):r.tags[".seriesNumber"]===n?(0,f.VK)(g.series[n],t):null;null!==o&&r.set(e.cell.rowIndex,o[r.tags[".statistics"]])}if(e.cell.column.getTag(d.h.TAG_FIT_CHART_FORMAT)!==d.h.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.D.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.h.MIN_AXES_CELL_PX_WIDTH&&e.height>=d.h.MIN_AXES_CELL_PX_HEIGHT}areAxesLabelsShown(e,t){var n;return e.width>=d.h.MIN_X_AXIS_NAME_VISIBILITY_PX_WIDTH&&e.height>=d.h.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.h.MIN_TITLE_PX_WIDTH&&e.height>=d.h.MIN_TITLE_PX_HEIGHT&&!!(null===(n=t.chartOptions)||void 0===n?void 0:n.title)}isLegendShown(e){return e.width>=d.h.MIN_LEGEND_PX_WIDTH&&e.height>=d.h.MIN_LEGEND_PX_HEIGHT}areDroplinesShown(e){return e.width>=d.h.MIN_DROPLINES_VISIBILITY_PX_WIDTH&&e.height>=d.h.MIN_DROPLINES_VISIBILITY_PX_HEIGHT}renderCurves(e,t,n){var r,o,i,a,u,c,f,h,m,p,g,T,x,I,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[b,L,P]=D(t,this.areAxesLabelsShown(t,n),this.isTitleShown(t,n)),R=(0,l.s$)(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,b,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(b.width,b.height),F=M>100?1:.2+M/100*.8,G={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,L,P),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.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||t.height<d.h.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.zB)(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._T)(o,a);else{const e=(0,l.nT)(o,a,G);s=e.fittedCurve;const t=[...e.parameters];o.parameters=t,i=!1}v(o,r),_(e,o,{viewport:X,ratio:F}),w(e,o,{viewport:X,ratio:F}),y(e,o,{viewport:X,ratio:F,logOptions:G,showAxes:this.areAxesShown(t),showAxesLabels:this.areAxesLabelsShown(t,n),screenBounds:t,curveFunc:s}),E(e,o,{viewport:X,logOptions:G,showAxes:this.areAxesShown(t),showAxesLabels:this.areAxesLabelsShown(t,n),screenBounds:t,fitFunc:a,userParamsFlag:i}),o.parameters&&A(e,o,{viewport:X,ratio:F,showDroplines:this.areDroplinesShown(t),xValue:o.parameters[2],dataBounds:R,curveFunc:s,logOptions:G}),N(e,o,{statistics:null===(T=n.chartOptions)||void 0===T?void 0:T.showStatistics,fitFunc:a,logOptions:G,dataBox:b})}!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===(x=n.chartOptions)||void 0===x?void 0:x.title,dataBox:b,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.h.X_AXIS_LABEL_BOTTOM_PX_MARGIN),e.translate(t.screenBounds.x,t.screenBounds.y),e.rotate(-Math.PI/2);const n=t.showTitle?d.h.AXES_TOP_PX_MARGIN_WITH_TITLE:d.h.AXES_TOP_PX_MARGIN;e.fillText(t.yAxisName,-(t.dataBox.height/2+n+15),15),e.restore()}}(e,{showTitle:this.isTitleShown(t,n),dataBox:b,screenBounds:t,showAxesLabels:this.areAxesLabelsShown(t,n),xAxisName:null===(I=n.chartOptions)||void 0===I?void 0:I.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:b,ratio:F}),e.restore()}render(e,t,n,o,i,a,s){var l,c,f;if(!a.cell.value)return;if(o<d.h.MIN_CELL_RENDERER_PX_WIDTH||i<d.h.MIN_CELL_RENDERER_PX_HEIGHT)return;const h=(null===(l=a.cell.column)||void 0===l?void 0:l.getTag(d.h.TAG_FIT_CHART_FORMAT))===d.h.TAG_FIT_CHART_FORMAT_3DX?(0,u.K)(a.cell.value):X(a),m=new r.Rect(t,n,o,i).inflate(d.h.INFLATE_SIZE,d.h.INFLATE_SIZE);for(const[t,n]of Object.entries(d.h.CONDITION_MAP))if(n(h.series))return void b(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.h.OUTLIER_PX_SIZE:d.h.POINT_PX_SIZE)/2+d.h.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.h.INFLATE_SIZE,d.h.INFLATE_SIZE);if(h.width<d.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||h.height<d.h.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.h.TAG_FIT_CHART_FORMAT)===d.h.TAG_FIT_CHART_FORMAT_3DX?(0,u.K)(e.cell.value):X(e);if(h.width>=d.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH&&h.height>=d.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT){const e=D(h,this.areAxesLabelsShown(h,m),this.isTitleShown(h,m))[0],u=(0,l.s$)(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.h.MIN_AXES_CELL_PX_WIDTH&&h.height>=d.h.MIN_AXES_CELL_PX_HEIGHT&&(document.body.style.cursor="pointer"))}i.tooltip.hide()}document.body.style.cursor="default"}};B=function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}([o.decorators.cellRenderer({name:"Fit",cellType:"fit",virtual:!0})],B)},860:(e,t,n)=>{"use strict";n.r(t),n.d(t,{_FitChartCellRenderer:()=>m,_MultiCurveViewer:()=>p,_initCurves:()=>C,_package:()=>T,addAggrStatisticsColumn:()=>O,addStatisticsColumn:()=>N,curveFitDemo:()=>A});var r=n(755),o=n(82),i=n(389),a=n(328),s=n(326),l=n(71);const u=rxjs.operators,c=rxjs;var f,d=n(95);let h=f=class extends s.D{constructor(){super(new r.lR),this.curvesColumnNames=[],this.showSelectedRowsCurves=!1,this.showCurrentRowCurve=!0,this.showMouseOverRowCurve=!0,this.mergeColumnSeries=!1,this.rows=[],this.data=new l.oH,this.curvesColumnNames=this.addProperty("curvesColumnNames",o.TYPE.COLUMN_LIST,[],{semType:d.h.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.xs)this.addProperty("mergeSeries"===e.name?"mergeCellSeries":e.name,e.propertyType,e.defaultValue,e.options)}static fromChartData(e){let t=new f;return t.data=e,t.render(),t}applyViewerProperties(){(0,r.g2)(l.xs,this,this.data.chartOptions)}mergeViewerChartOptions(){for(const e of l.xs)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,i,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.oH;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 o of new Set(this.rows)){const i=c.cell(e,c.tableRowToGrid(o));if(""===i.cell.value)continue;const a=(0,r.j$)(i);null===(n=a.series)||void 0===n||n.forEach((e=>e.columnName=i.cell.column.name));const s=a.chartOptions;if(null!=s&&(d[d.length]=s),f){const e=(0,r.wU)(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===(i=this.data.series)||void 0===i||i.push((0,r.wU)(t)):null===(a=this.data.series)||void 0===a||a.push(...t)}this.data.chartOptions=(0,r.LX)(d),this.mergeViewerChartOptions(),null===(s=this.data.series)||void 0===s||s.forEach(((e,t)=>{var n,r,i,a,s;if(e.pointColor=o.Color.toHtml(o.Color.getCategoricalColor((null===(n=this.data.series)||void 0===n?void 0:n.length)>20?0:t)),e.fitLineColor=o.Color.toHtml(o.Color.getCategoricalColor((null===(r=this.data.series)||void 0===r?void 0:r.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=o.Color.fromHtml(e.fitLineColor);e.fitLineColor=`rgba(${o.Color.r(t)}, ${o.Color.g(t)}, ${o.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(d.h.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(i.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 o.Rect(0,0,this.canvas.width,this.canvas.height).inflate(d.h.INFLATE_SIZE,d.h.INFLATE_SIZE),this.data)):this._showErrorMessage("The MultiCurveViewer viewer requires a minimum of 1 curves column.")}};function m(){return new r.lR}function p(){return new h}h=f=function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}([a.decorators.viewer({name:"MultiCurveViewer",description:"A viewer that superimposes multiple in-cell curves on one chart",icon:"icons/multi-curve-viewer.png"}),function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}("design:paramtypes",[])],h);var g=n(48),v=n(471),_=n(283),w=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 T=new o.Package,x=".sourceColumn",y=".seriesNumber",E=".seriesAggregation",I=".statistics";function A(){return w(this,void 0,void 0,(function*(){yield(0,v.Z1)()}))}function C(){o.ObjectHandler.register(new g.e4)}function N(e,t,n,i,a){var s;const l=o.Viewer.grid(e),u=l.col(t),c=o.Column.float(`${t}_${i}_${n}`,null===(s=u.column)||void 0===s?void 0:s.length);c.tags[x]=t,c.tags[y]=a,c.tags[I]=n,c.init((e=>{var i,s,u,c,f;const h=o.GridCell.fromColumnRow(l,t,l.tableRowToGrid(e));if(""===h.cell.value)return null;const m=h.cell.column.getTag(d.h.TAG_FIT_CHART_FORMAT)===d.h.TAG_FIT_CHART_FORMAT_3DX?(0,_.K)(h.cell.value):(0,r.j$)(h);if(void 0===m.series[a]||m.series[a].points.every((e=>e.outlier)))return null;(null===(i=m.chartOptions)||void 0===i?void 0:i.allowXZeroes)&&(null===(s=m.chartOptions)||void 0===s?void 0:s.logX)&&(null===(u=m.series)||void 0===u?void 0:u.some((e=>e.points.some((e=>0===e.x)))))&&(0,r.B3)(m);const p={logX:null===(c=m.chartOptions)||void 0===c?void 0:c.logX,logY:null===(f=m.chartOptions)||void 0===f?void 0:f.logY};return(0,g.VK)(m.series[a],p)[n]})),e.columns.insert(c,u.idx)}function O(e,t,n,i){var a;const s=o.Viewer.grid(e),l=s.col(t),u=o.Column.float(`${t}_${i}_${n}`,null===(a=l.column)||void 0===a?void 0:a.length);u.tags[x]=t,u.tags[E]=i,u.tags[I]=n,u.init((e=>{var a,l,u,c;const f=o.GridCell.fromColumnRow(s,t,s.tableRowToGrid(e));if(""===f.cell.value)return null;const h=f.cell.column.getTag(d.h.TAG_FIT_CHART_FORMAT)===d.h.TAG_FIT_CHART_FORMAT_3DX?(0,_.K)(f.cell.value):(0,r.j$)(f);return(null===(a=h.series)||void 0===a?void 0:a.every((e=>e.points.every((e=>e.outlier)))))?null:((null===(l=h.chartOptions)||void 0===l?void 0:l.allowXZeroes)&&(null===(u=h.chartOptions)||void 0===u?void 0:u.logX)&&(null===(c=h.series)||void 0===c?void 0:c.some((e=>e.points.some((e=>0===e.x)))))&&(0,r.B3)(h),(0,g.JR)(h,i)[n])})),e.columns.insert(u,l.idx)}},82:e=>{"use strict";e.exports=DG},328:e=>{"use strict";e.exports=grok},389:e=>{"use strict";e.exports=ui},991:e=>{"use strict";e.exports=wu},234:()=>{}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.amdD=function(){throw new Error("define cannot be used indirect")},n.amdO={},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})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var r=n(860);curves=r})();
|
|
1
|
+
var curves;(()=>{var e={368:(e,t,n)=>{"use strict";function o(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)],o=e[Math.trunc(3*e.length/4)],i=1.5*(o-t);let a=r(e,o+i);a<0&&(a=~a);let l=e[Math.max(0,a-1)];l<o&&(l=o);let s=r(e,t-i);s<0&&(s=~s);let u=e[s];return u>t&&(u=t),{q1:t,q2:n,q3:o,lowerAdjacentValue:u,upperAdjacentValue:l}}function r(e,t,n=0,o){if(0===e.length)return-1;if(void 0===o&&(o=e.length-1),t<e[n])return-1;if(t>e[o])return-(o+1);for(;o-n>1;){const r=Math.trunc((o+n)/2);if(t===e[r])return r;t<e[r]?o=r:n=r}return e[n]===t?n:0===e[o]?o:t<e[n]?-(n+1):-(o+1)}n.d(t,{k:()=>o})},71:(e,t,n)=>{"use strict";n.d(t,{kC:()=>A,Pf:()=>E,Ff:()=>y,kx:()=>I,G7:()=>x,oH:()=>p,dZ:()=>h,EV:()=>X,xs:()=>T,W6:()=>b,IL:()=>_,Sm:()=>F,Mi:()=>D,O8:()=>S,Hr:()=>G,ah:()=>O,TV:()=>N,mW:()=>P,sn:()=>R,AJ:()=>M,ry:()=>L,nK:()=>w});var o,r=n(82),i=n(572);class a extends Error{constructor(e){super(e)}}function l(e,t,n,o){for(let r=0;r<t;r++){let i=0;for(let e=0;e<t+1;e++)e!==n&&(i+=o[e][r]);e[r]=i/t}}function s(e,t,n,o,r,i,a,l){for(let s=0;s<i;s++)t[s]=e[s],t[s]+=r*(e[s]-o[n][s]),t[s]<a[s]?t[s]=a[s]:t[s]>l[s]&&(t[s]=l[s])}!function(e){e[e.TOLERANCE=.01]="TOLERANCE",e[e.MAX_ITER=30]="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"}(o||(o={})),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,o,r){const i=n.tolerance,a=n.maxIter,u=n.scaleReflection,c=n.scaleExpansion,d=n.scaleContraction,m=t.length+1,f=t.length,[h,p]=function(e,t,n,o,r){const i=n.length+1,a=n.length,l=t.nonZeroParam,s=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]=l:u[t][e]+=s*n[t-1],u[t][e]<o[e]?u[t][e]=o[e]:u[t][e]>r[e]&&(u[t][e]=r[e]));c[t]=e(u[t]).likelihood}return[u,c]}(e,n,t,o,r),g=new Array(m);for(let e=0;e<m;e++)g[e]=e;const v=g.length-1;let C=0,w=0,T=0,_=0;const x=new Float32Array(f),y=new Float32Array(f),I=new Float32Array(f),E=new Float32Array(f),A=new Array(a);if(m>1){for(;g.sort(((e,t)=>p[e]-p[t])),!(C>a);){if(0===C&&(w=p[0],T=2*p[g[0]]),A[C]=w,++C,w=p[g[0]],T-w>i)_=0;else if(++_,_>2*m)break;T=w,l(x,f,g[v],h),s(x,y,g[v],h,u,f,o,r);const t=e(y).likelihood;if(t<p[g[v]]){s(x,I,g[v],h,c,f,o,r);const n=e(I).likelihood;if(n<t){p[g[v]]=n;for(let e=0;e<f;e++)h[g[v]][e]=I[e];continue}p[g[v]]=t;for(let e=0;e<f;e++)h[g[v]][e]=y[e];continue}s(x,E,g[v],h,d,f,o,r);const n=e(E).likelihood;if(!(n<p[g[v]]))break;p[g[v]]=n;for(let e=0;e<f;e++)h[g[v]][e]=E[e]}for(let e=C;e<a;e++)A[e]=p[g[0]]}return{point:h[g[0]],cost:p[g[0]],iterCosts:A,iterCount:C-1}};var c=n(391),d=n.n(c);function m(e,t,n,o){const r=t-n,i=new Array(e);for(let t=0;t<e;t++){const e=o();i[t]=n+e*r}return i}function f(e,t,n,o,i=1,l=null,s=!0){const c=function(e,t,n){const o=d()("12345"),r=t.length,i=new Array(e);for(let t=0;t<e;t++)i[t]=new Float32Array(r);for(let a=0;a<r;a++)if(t[a]===n[a])for(let n=0;n<e;n++)i[n][a]=t[a];else{const r=m(e,t[a],n[a],o);for(let t=0;t<e;t++)i[t][a]=r[t]}return i}(i,n,t),f=[],h=[],p=[];let g,v=0,C=null;for(g=0;g<i;++g)try{if(0===g&&s){const t=null===l?c[g]:l,n=new Float32Array(l.length).map((e=>-1/0)),r=new Float32Array(l.length).map((e=>1/0));f.push(u(e,t,o,n,r))}else f.push(u(e,c[g],o,t,n))}catch(e){if(e instanceof a)throw new Error(`Inconsistent dataframes: ${e.message}`);++v,h.push(e instanceof Error?e.message:"Platform issue"),p.push(c[g])}if(v>0){const e=n.length,t=new Array(e);for(let n=0;n<e;++n)t[n]=new Float32Array(v);p.forEach(((e,n)=>e.forEach(((e,o)=>t[o][n]=e)))),C=r.DataFrame.fromColumns(t.map(((e,t)=>r.Column.fromFloat32Array(`arg${t}`,e)))),C.columns.add(r.Column.fromStrings("Issue",h))}return{extremums:f,fails:C}}const h={CONSTANT:"constant",PROPORTIONAL:"proportional",COMBINED:"combined"};class p{constructor(){this.chartOptions={},this.seriesOptions={},this.series=[]}}class g{}class v extends g{constructor(e,t,n,o){super(),this._name=e,this._parameterNames=o,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 C={linear:new class extends g{get name(){return y}get parameterNames(){return["Slope","Intercept"]}y(e,t){return R(e,t)}getInitialParameters(e,t){let n=0,o=0;for(let t=1;t<e.length;t++)e[t]<e[n]&&(n=t),e[t]>e[o]&&(o=t);const r=e[o]-e[n],i=(t[o]-t[n])/r,a=t[o]-i*e[o],l=new Float32Array(2);return l.set([i,a]),l}},sigmoid:new class extends g{get name(){return x}get parameterNames(){return["Top","Slope","IC50","Bottom"]}y(e,t){return L(e,t)}getInitialParameters(e,t){const n=r.Rect.fromXYArrays(e,t),o=(n.maxY-n.minY)/2+n.minY;let i=n.maxY-n.minY,a=0;for(let n=0;n<e.length;n++){const e=Math.abs(t[n]-o);e<i&&(i=e,a=n)}const l=e[a],s=t[0]>t[t.length-1]?1:-1,u=new Float32Array(4);return u.set([n.maxY,s,l,n.minY]),u}},"log-linear":new class extends g{get name(){return I}get parameterNames(){return["Slope","Intercept"]}y(e,t){return M(e,t)}getInitialParameters(e,t){const n=new Float32Array(2);return n.set([-5,100]),n}},exponential:new class extends g{get name(){return E}get parameterNames(){return["Mantissa","Power"]}y(e,t){return X(e,t)}getInitialParameters(e,t){const n=new Float32Array(2);return n.set([100,-2]),n}},"4pl-regression":new class extends g{get name(){return A}get parameterNames(){return["Top","Slope","EC50","Bottom"]}y(e,t){return F(e,t)}getInitialParameters(e,t){const n=new Float32Array(4),o=Math.min(...t),r=Math.max(...t),i=(r-o)/2+o;let a=r-o,l=0;for(let n=0;n<e.length;n++){const e=Math.abs(t[n]-i);e<a&&(a=e,l=n)}const s=e[l],u=t[0]>t[t.length-1]?-10:10;return n.set([r,u,s,o]),n}}},w=[r.Property.js("rSquared",r.TYPE.FLOAT,{userEditable:!1}),r.Property.js("auc",r.TYPE.FLOAT,{userEditable:!1,friendlyName:"AUC"}),r.Property.js("interceptY",r.TYPE.FLOAT,{userEditable:!1}),r.Property.js("interceptX",r.TYPE.FLOAT,{userEditable:!1}),r.Property.js("slope",r.TYPE.FLOAT,{userEditable:!1}),r.Property.js("top",r.TYPE.FLOAT,{userEditable:!1,friendlyName:"Max Y"}),r.Property.js("bottom",r.TYPE.FLOAT,{userEditable:!1,friendlyName:"Min Y"})],T=[r.Property.js("minX",r.TYPE.FLOAT,{nullable:!0}),r.Property.js("minY",r.TYPE.FLOAT,{nullable:!0}),r.Property.js("maxX",r.TYPE.FLOAT,{nullable:!0}),r.Property.js("maxY",r.TYPE.FLOAT,{nullable:!0}),r.Property.js("title",r.TYPE.STRING,{nullable:!0}),r.Property.js("xAxisName",r.TYPE.STRING,{description:"Label to show on the X axis. If not specified, corresponding data column name is used",nullable:!0}),r.Property.js("yAxisName",r.TYPE.STRING,{description:"Label to show on the Y axis. If not specified, corresponding data column name is used",nullable:!0}),r.Property.js("logX",r.TYPE.BOOL,{description:"Whether the X axis should be logarithmic",defaultValue:!1}),r.Property.js("logY",r.TYPE.BOOL,{description:"Whether the Y axis should be logarithmic",defaultValue:!1}),r.Property.js("allowXZeroes",r.TYPE.BOOL,{description:"Whether x zeroes allowed for logarithmic data or not",defaultValue:!0}),r.Property.js("mergeSeries",r.TYPE.BOOL,{description:"Merges all series within one cell into one series",defaultValue:!1}),r.Property.js("showColumnLabel",r.TYPE.BOOL,{description:"Whether to show the column label in the legend or not",defaultValue:!1}),r.Property.js("showStatistics",r.TYPE.STRING_LIST,{description:"Whether specific statistics should be rendered",choices:w.map((e=>e.name)),inputType:"MultiChoice",friendlyName:"Statistics"})],_=[r.Property.js("fitFunction",r.TYPE.STRING,{category:"Fitting",choices:Object.keys(C),defaultValue:"sigmoid"}),r.Property.js("pointColor",r.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),r.Property.js("fitLineColor",r.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),r.Property.js("outlierColor",r.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),r.Property.js("errorModel",r.TYPE.STRING,{category:"Fitting",defaultValue:"constant",choices:["constant","proportional","combined"],nullable:!1}),r.Property.js("connectDots",r.TYPE.BOOL,{category:"Fitting",defaultValue:!1}),r.Property.js("clickToToggle",r.TYPE.BOOL,{category:"Fitting",description:"Click on a point to mark it as outlier and refit",nullable:!0,defaultValue:!1}),r.Property.js("showFitLine",r.TYPE.BOOL,{category:"Fitting",defaultValue:!0}),r.Property.js("showPoints",r.TYPE.STRING,{category:"Fitting",description:"Whether points/candlesticks/none should be rendered",defaultValue:"points",choices:["points","candlesticks","both"]}),r.Property.js("showCurveConfidenceInterval",r.TYPE.BOOL,{category:"Fitting",description:"Whether confidence intervals should be rendered",defaultValue:!1,friendlyName:"Confidence Interval"}),r.Property.js("markerType",r.TYPE.STRING,{category:"Rendering",defaultValue:"circle",choices:["asterisk","circle","cross border","diamond","square","star","triangle bottom","triangle left","triangle right","triangle top"],nullable:!1,friendlyName:"Marker"}),r.Property.js("outlierMarkerType",r.TYPE.STRING,{category:"Rendering",defaultValue:"outlier",choices:["asterisk","circle","cross border","diamond","outlier","square","star","triangle bottom","triangle left","triangle right","triangle top"],nullable:!1,friendlyName:"Outlier Marker"}),r.Property.js("lineStyle",r.TYPE.STRING,{category:"Rendering",defaultValue:"solid",choices:["solid","dotted","dashed","dashdotted"],nullable:!1}),r.Property.js("droplines",r.TYPE.STRING_LIST,{description:"Whether specific droplines should be rendered",choices:["IC50"],inputType:"MultiChoice"}),r.Property.js("columnName",r.TYPE.STRING,{description:"Column name where the series is stored",defaultValue:""})],x="sigmoid",y="linear",I="log-linear",E="exponential",A="4pl-regression";function N(e){if("string"==typeof e)return C[e];if(!C[e.name]){const t=e.name,n=e.parameterNames,o=e.function.split("=>").map((e=>e.trim())),r=e.getInitialParameters.split("=>").map((e=>e.trim())),i=new Function(o[0].slice(1,o[0].length-1),`${o[1].includes(";")?"":"return "}${o[1]}`),a=new Function(r[0].slice(1,r[0].length-1),`return ${r[1]}`),l=new v(t,i,a,n);C[t]=l}return C[e.name]}function b(e,t,n,i){null!=n||(n=h.CONSTANT);const a=t.y;let l=t.getInitialParameters(e.x,e.y);const s=function(e,t,n){return o=>{let r=0,i=0,a=0;const l=t.y,s=t.x.map((t=>e(o,t))),u=l.map(((e,t)=>e-s[t])),c=u.map((e=>Math.pow(e,2)));for(let e=0;e<c.length;e++)[h.CONSTANT,h.COMBINED].includes(n)?i+=c[e]:n===h.PROPORTIONAL&&(a+=c[e]/(s[e]*s[e]));i=Math.sqrt(i/c.length),a=Math.sqrt(a/c.length),n===h.COMBINED&&({sigmaA:i,sigmaB:a}=Y(i,a,c,s));const d=[];for(let e=0;e<c.length;e++)d[e]=Math.pow(i+a*s[e],2),r+=c[e]/d[e]+Math.log(2*Math.PI*d[e]);return{likelihood:r,residuals:u}}}(a,e,n),u=new Float32Array(t.parameterNames.length),c=new Float32Array(t.parameterNames.length);for(let e=0;e<t.parameterNames.length;e++)u[e]=0===l[e]?-1:l[e]-Math.abs(.5*l[e]),c[e]=0===l[e]?1:l[e]+Math.abs(.5*l[e]);const d=r.BitSet.create(2*t.parameterNames.length);if(i&&0!==i.length)for(let e=0;e<i.length;e++)void 0!==i[e].min&&null!==i[e].min&&(u[e]=i[e].min,d.set(2*e,!0)),void 0!==i[e].max&&null!==i[e].max&&(c[e]=i[e].max,d.set(2*e+1,!0));const m=e=>{const t=s(e.point).residuals;let n=0,o=0;for(let e=0;e<t.length;e++)t.length/4>e?n+=Math.pow(t[e],2):3*t.length/4>e?o+=Math.pow(t[e],2):n+=Math.pow(t[e],2);return n/o};let p,g=-1,v=0,C=null,w=0;for(;;){p=f(s,u,c,{tolerance:o.TOLERANCE,maxIter:o.MAX_ITER,nonZeroParam:o.NON_ZERO_PARAM,initialScale:o.INITIAL_SCALE,scaleReflection:o.SCALE_REFLECTION,scaleExpansion:o.SCALE_EXPANSION,scaleContraction:o.SCALE_CONTRACTION},10,l),w=0;for(let e=1;e<p.extremums.length;e++)p.extremums[e].cost<p.extremums[w].cost&&(w=e);const e=m(p.extremums[w]);if(null===C?C=e:e<C?(C=e,v=0):v++,l=p.extremums[w].point,g>40||3===v)break;for(let e=0;e<t.parameterNames.length;e++)d.get(2*e)||(u[e]=l[e]-Math.abs(l[e]*(v+.5))),d.get(2*e+1)||(c[e]=l[e]+Math.abs(l[e]*(v+.5)));g++}return{fittedCurve:O(a,l),parameters:l}}function O(e,t){return n=>e(t,n)}function S(e,t,n,o=.05,r){const a=function(e,t,n,o){let r=0,i=0;const a=t.y,l=t.x.map((t=>e(o,t))),s=a.map(((e,t)=>e-l[t])),u=s.map((e=>Math.pow(e,2)));for(let e=0;e<u.length;e++)[h.CONSTANT,h.COMBINED].includes(n)?r+=u[e]:n===h.PROPORTIONAL&&(i+=Math.pow(s[e]/Math.abs(l[e]),2));return r=Math.sqrt(r/u.length),i=Math.sqrt(i/u.length),n===h.COMBINED&&({sigmaA:r,sigmaB:i}=Y(r,i,u,l)),{sigmaA:r,sigmaB:i}}(n,e,r,t),l=i.normal.inv(1-o/2,0,1);return{confidenceTop:e=>{const o=n(t,e);return o+l*(a.sigmaA+Math.abs(o)*a.sigmaB)},confidenceBottom:e=>{const o=n(t,e);return o-l*(a.sigmaA+Math.abs(o)*a.sigmaB)}}}function P(e,t,n,o=!0){const r=O(n,t);return{rSquared:o?G(r,e):void 0,auc:o?D(r,e):void 0,interceptX:t[2],interceptY:r(t[2]),slope:t[1],top:t[0],bottom:t[3]}}function L(e,t){const n=e[0],o=e[1],r=e[2],i=e[3];return i+(n-i)/(1+Math.pow(10,(t-r)*o))}function R(e,t){return e[0]*t+e[1]}function M(e,t){const n=e[0],o=e[1];return n*Math.log(t+1)+o}function X(e,t){const n=e[0],o=e[1];return n*Math.exp(t*o)}function F(e,t){const n=e[0],o=e[1],r=e[2],i=e[3];return i+(n-i)/(1+Math.pow(t/r,o))}function D(e,t){let n=0;const o=Math.min(...t.x),r=Math.max(...t.x),i=(r-o)/1e3;for(let t=o;t<r;t+=i)n+=i*e(t);return n}function G(e,t){let n=0,o=0;const r=i.mean(t.y);for(let i=0;i<t.x.length;i++)n+=Math.pow(t.y[i]-e(t.x[i]),2),o+=Math.pow(t.y[i]-r,2);return 1-n/o}function Y(e,t,n,o){let r=Number.MAX_VALUE,i=0;for(let t=0;t<=10;t++){let a=0;const l=t/10,s=e*l,u=e*(1-l),c=[];for(let e=0;e<n.length;e++)c[e]=Math.pow(s+u*o[e],2),a+=n[e]/c[e]+Math.log(2*Math.PI*c[e]);a<r&&(r=a,i=l)}return t=e*(1-i),{sigmaA:e*=i,sigmaB:t}}},999:(e,t,n)=>{"use strict";n.d(t,{Kh:()=>a,Sm:()=>m,VA:()=>p,_T:()=>d,fY:()=>h,nT:()=>f,s$:()=>u,zB:()=>c});var o=n(82),r=n(71);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(r.xs),seriesOptions:i(r.IL)}}function l(e){const t=[],n=[];for(let o=0;o<e.length;o++)t[o]=e[o].x,n[o]=e[o].y;return{xs:t,ys:n}}function s(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:r}=l(e.series[0].points);let i=o.Rect.fromXYArrays(t,r);for(let t=1;t<e.series.length;t++){const{xs:n,ys:r}=l(e.series[t].points);n.some((e=>void 0===e))||r.some((e=>void 0===e))||(i=i.union(o.Rect.fromXYArrays(n,r)))}return n?function(e,t){let n=e.x,r=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+=r-t.minY,r=t.minY),void 0!==t.maxY&&null!==t.maxY&&(!t.logY||t.logY&&t.maxY>0)&&(a+=t.maxY-(r+a)),new o.Rect(n,r,i,a)}(i,n):i}return new o.Rect(0,0,1,1)}function c(e){return(0,r.TV)(e.fitFunction)}function d(e,t){var n;const o=new Float32Array(null===(n=e.parameters)||void 0===n?void 0:n.length);return o.set(e.parameters),(0,r.ah)(t.y,o)}function m(e,t,n){const o=n?e.points:e.points.filter((e=>!e.outlier));return{x:o.map((e=>(null==t?void 0:t.logX)?Math.log10(e.x):e.x)),y:o.map((e=>(null==t?void 0:t.logY)?Math.log10(e.y):e.y))}}function f(e,t,n,o){var i,a;return null!=n||(n=m(e,o,!1)),e.parameterBounds&&(null==o?void 0:o.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,r.W6)(function(e){const t={x:[],y:[]},n={x:[e.x[0]],y:[e.y[0]]};for(let o=1;o<e.x.length;o++){if(e.x[o]===n.x[0]){n.x[n.x.length]=e.x[o],n.y[n.y.length]=e.y[o];continue}const r=s(n);t.x[t.x.length]=n.x[0],t.y[t.y.length]=r,n.x=[e.x[o]],n.y=[e.y[o]]}const o=s(n);return t.x[t.x.length]=n.x[0],t.y[t.y.length]=o,t}(n),t,null!==(i=e.errorModel)&&void 0!==i?i:r.dZ.CONSTANT,e.parameterBounds)}function h(e,t,n,o,i){var a,l;if(null!=o||(o=m(e,i,n)),!e.parameters){const n=f(e,t,o).parameters;e.parameters=[...n]}const s=new Float32Array(null===(a=e.parameters)||void 0===a?void 0:a.length);return s.set(e.parameters),(0,r.O8)(o,s,t.y,.05,null!==(l=e.errorModel)&&void 0!==l?l:r.dZ.CONSTANT)}function p(e,t,n,o){var i;if(null!=n||(n=m(e,o,!1)),!e.parameters){const o=f(e,t,n).parameters;e.parameters=[...o]}const a=new Float32Array(null===(i=e.parameters)||void 0===i?void 0:i.length);return a.set(e.parameters),(0,r.mW)(n,a,t.y,!0)}},293:(e,t,n)=>{"use strict";n.d(t,{L:()=>l});var o=n(82);const r=1e-30,i=new class{screenToWorld(e,t,n,o,r){return n+(r?1-e/t:e/t)*(o-n)}worldToScreen(e,t,n,o,r){return r?(1-(e-n)/(o-n))*t:(e-n)/(o-n)*t}},a=new class{screenToWorld(e,t,n,o,i){n=n<r?r:n;const a=Math.log(o),l=Math.log(n);return Math.exp(l+(a-l)*(i?t-e:e)/t)}worldToScreen(e,t,n,o,i){if(e<=0)return NaN;if(Math.abs(e-n)<r)return i?t:0;if(Math.abs(e-o)<r)return i?0:t;n=n<r?r:n,e=e<r?r:e;const a=t*Math.log(e/n)/Math.log(o/n);return i?t-a:a}};class l{get xt(){return this.logX?a:i}get yt(){return this.logY?a:i}constructor(e,t,n=!1,o=!1){this.logX=!1,this.logY=!1,this.inverseX=!1,this.inverseY=!1,this.world=e,this.screen=t,this.logX=n,this.logY=o}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 o.Point(this.xToScreen(e.x),this.yToScreen(e.y))}toWorld(e){return new o.Point(this.xToWorld(e.x),this.yToWorld(e.y))}drawCoordinateGrid(e,t,n){t&&o.Paint.horzAxis(e,this.world.minX,this.world.maxX,t.x,t.y,t.width,t.height,this.logX,this.inverseX),n&&o.Paint.vertAxis(e,this.world.minY,this.world.maxY,n.x,n.y,n.width,n.height,this.logY,this.inverseY)}}},572:function(e){var t;e.exports=(t=function(e,t){var n=Array.prototype.concat,o=Array.prototype.slice,r=Object.prototype.toString;function i(t,n){var o=t>n?t:n;return e.pow(10,17-~~(e.log(o>0?o:-o)*e.LOG10E))}var a=Array.isArray||function(e){return"[object Array]"===r.call(e)};function l(e){return"[object Function]"===r.call(e)}function s(e){return"number"==typeof e&&e-e==0}function u(){return new u._init(arguments)}function c(){return 0}function d(){return 1}function m(e,t){return e===t?1:0}u.fn=u.prototype,u._init=function(e){if(a(e[0]))if(a(e[0][0])){l(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]=l(e[1])?u.map(e[0],e[1]):e[0],this.length=1;else if(s(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:l,isNumber:s,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,o){u.arange(e.length).forEach((function(r){n[r][o]=e[r][t]}))})),n}for(var o=new Array(e.length),r=0;r<e.length;r++)o[r]=[e[r][t]];return o},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),o=0;o<t;o++)n[o]=[e[o][o]];return n},u.antidiag=function(e){for(var t=u.rows(e)-1,n=new Array(t),o=0;t>=0;t--,o++)n[o]=[e[o][t]];return n},u.transpose=function(e){var t,n,o,r,i,l=[];for(a(e[0])||(e=[e]),n=e.length,o=e[0].length,i=0;i<o;i++){for(t=new Array(n),r=0;r<n;r++)t[r]=e[r][i];l.push(t)}return 1===l.length?l[0]:l},u.map=function(e,t,n){var o,r,i,l,s;for(a(e[0])||(e=[e]),r=e.length,i=e[0].length,l=n?e:new Array(r),o=0;o<r;o++)for(l[o]||(l[o]=new Array(i)),s=0;s<i;s++)l[o][s]=t(e[o][s],o,s);return 1===l.length?l[0]:l},u.cumreduce=function(e,t,n){var o,r,i,l,s;for(a(e[0])||(e=[e]),r=e.length,i=e[0].length,l=n?e:new Array(r),o=0;o<r;o++)for(l[o]||(l[o]=new Array(i)),i>0&&(l[o][0]=e[o][0]),s=1;s<i;s++)l[o][s]=t(l[o][s-1],e[o][s]);return 1===l.length?l[0]:l},u.alter=function(e,t){return u.map(e,t,!0)},u.create=function(e,t,n){var o,r,i=new Array(e);for(l(t)&&(n=t,t=e),o=0;o<e;o++)for(i[o]=new Array(t),r=0;r<t;r++)i[o][r]=n(o,r);return i},u.zeros=function(e,t){return s(t)||(t=e),u.create(e,t,c)},u.ones=function(e,t){return s(t)||(t=e),u.create(e,t,d)},u.rand=function(e,t){return s(t)||(t=e),u.create(e,t,u._random_fn)},u.identity=function(e,t){return s(t)||(t=e),u.create(e,t,m)},u.symmetric=function(e){var t,n,o=e.length;if(e.length!==e[0].length)return!1;for(t=0;t<o;t++)for(n=0;n<o;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,o){l(o)||(o=!1);var r,a=[],s=i(e,t),u=(t*s-e*s)/((n-1)*s),c=e;for(r=0;c<=t&&r<n;c=(e*s+u*s*++r)/s)a.push(o?o(c,r):c);return a},u.arange=function(e,n,o){var r,i=[];if(o=o||1,n===t&&(n=e,e=0),e===n||0===o)return[];if(e<n&&o<0)return[];if(e>n&&o>0)return[];if(o>0)for(r=e;r<n;r+=o)i.push(r);else for(r=e;r>n;r+=o)i.push(r);return i},u.slice=function(){function e(e,n,o,r){var i,a=[],l=e.length;if(n===t&&o===t&&r===t)return u.copy(e);if(r=r||1,(n=(n=n||0)>=0?n:l+n)===(o=(o=o||e.length)>=0?o:l+o)||0===r)return[];if(n<o&&r<0)return[];if(n>o&&r>0)return[];if(r>0)for(i=n;i<o;i+=r)a.push(e[i]);else for(i=n;i>o;i+=r)a.push(e[i]);return a}return function(t,n){var o,r;return s((n=n||{}).row)?s(n.col)?t[n.row][n.col]:e(u.rowa(t,n.row),(o=n.col||{}).start,o.end,o.step):s(n.col)?e(u.cola(t,n.col),(r=n.row||{}).start,r.end,r.step):(r=n.row||{},o=n.col||{},e(t,r.start,r.end,r.step).map((function(t){return e(t,o.start,o.end,o.step)})))}}(),u.sliceAssign=function(n,o,r){var i,a;if(s(o.row)){if(s(o.col))return n[o.row][o.col]=r;o.col=o.col||{},o.col.start=o.col.start||0,o.col.end=o.col.end||n[0].length,o.col.step=o.col.step||1,i=u.arange(o.col.start,e.min(n.length,o.col.end),o.col.step);var l=o.row;return i.forEach((function(e,t){n[l][e]=r[t]})),n}if(s(o.col)){o.row=o.row||{},o.row.start=o.row.start||0,o.row.end=o.row.end||n.length,o.row.step=o.row.step||1,a=u.arange(o.row.start,e.min(n[0].length,o.row.end),o.row.step);var c=o.col;return a.forEach((function(e,t){n[e][c]=r[t]})),n}return r[0].length===t&&(r=[r]),o.row.start=o.row.start||0,o.row.end=o.row.end||n.length,o.row.step=o.row.step||1,o.col.start=o.col.start||0,o.col.end=o.col.end||n[0].length,o.col.step=o.col.step||1,a=u.arange(o.row.start,e.min(n.length,o.row.end),o.row.step),i=u.arange(o.col.start,e.min(n[0].length,o.col.end),o.col.step),a.forEach((function(e,t){i.forEach((function(o,i){n[e][o]=r[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 s(e)?e:e.map((function(e){return e}))}))};var f=u.prototype;return f.length=0,f.push=Array.prototype.push,f.sort=Array.prototype.sort,f.splice=Array.prototype.splice,f.slice=Array.prototype.slice,f.toArray=function(){return this.length>1?o.call(this):o.call(this)[0]},f.map=function(e,t){return u(u.map(this,e,t))},f.cumreduce=function(e,t){return u(u.cumreduce(this,e,t))},f.alter=function(e){return u.alter(this,e),this},function(e){for(var t=0;t<e.length;t++)!function(e){f[e]=function(t){var n,o=this;return t?(setTimeout((function(){t.call(o,f[e].call(o))})),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){f[e]=function(t,n){var o=this;return n?(setTimeout((function(){n.call(o,f[e].call(o,t))})),this):u(u[e](this,t))}}(e[t])}("row col".split(" ")),function(e){for(var t=0;t<e.length;t++)!function(e){f[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 o(e,t){return e-t}function r(e,n,o){return t.max(n,t.min(e,o))}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,o=e.mean(t),r=0,i=t.length;--i>=0;)r+=(n=t[i]-o)*n;return r},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=[],o=0;o<e.length;o++)t[e[o]]||(t[e[o]]=!0,n.push(e[o]));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 o=n.map(t.log),r=e.mean(o);return t.exp(r)},e.median=function(e){var t=e.length,n=e.slice().sort(o);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=[],o=e.length;for(t=1;t<o;t++)n.push(e[t]-e[t-1]);return n},e.rank=function(e){var t,n=[],r={};for(t=0;t<e.length;t++)r[s=e[t]]?r[s]++:(r[s]=1,n.push(s));var i=n.sort(o),a={},l=1;for(t=0;t<i.length;t++){var s,u=r[s=i[t]],c=(l+(l+u-1))/2;a[s]=c,l+=u}return e.map((function(e){return a[e]}))},e.mode=function(e){var t,n=e.length,r=e.slice().sort(o),i=1,a=0,l=0,s=[];for(t=0;t<n;t++)r[t]===r[t+1]?i++:(i>a?(s=[r[t]],a=i,l=0):i===a&&(s.push(r[t]),l++),i=1);return 0===l?s[0]:s},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),o=t.length,r=new Array(o),i=0;i<o;i++)r[i]=t[i]-n;return r},e.stdev=function(n,o){return t.sqrt(e.variance(n,o))},e.pooledstdev=function(n){return t.sqrt(e.pooledvariance(n))},e.meandev=function(n){for(var o=e.mean(n),r=[],i=n.length-1;i>=0;i--)r.push(t.abs(n[i]-o));return e.mean(r)},e.meddev=function(n){for(var o=e.median(n),r=[],i=n.length-1;i>=0;i--)r.push(t.abs(n[i]-o));return e.median(r)},e.coeffvar=function(t){return e.stdev(t)/e.mean(t)},e.quartiles=function(e){var n=e.length,r=e.slice().sort(o);return[r[t.round(n/4)-1],r[t.round(n/2)-1],r[t.round(3*n/4)-1]]},e.quantiles=function(e,n,i,a){var l,s,u,c,d,m=e.slice().sort(o),f=[n.length],h=e.length;for(void 0===i&&(i=3/8),void 0===a&&(a=3/8),l=0;l<n.length;l++)u=h*(s=n[l])+(i+s*(1-i-a)),c=t.floor(r(u,1,h-1)),d=r(u-c,0,1),f[l]=(1-d)*m[c-1]+d*m[c];return f},e.percentile=function(e,t,n){var r=e.slice().sort(o),i=t*(r.length+(n?1:-1))+(n?0:1),a=parseInt(i),l=i-a;return a+1<r.length?r[a-1]+l*(r[a]-r[a-1]):r[a-1]},e.percentileOfScore=function(e,t,n){var o,r,i=0,a=e.length,l=!1;for("strict"===n&&(l=!0),r=0;r<a;r++)o=e[r],(l&&o<t||!l&&o<=t)&&i++;return i/a},e.histogram=function(n,o){o=o||4;var r,i=e.min(n),a=(e.max(n)-i)/o,l=n.length,s=[];for(r=0;r<o;r++)s[r]=0;for(r=0;r<l;r++)s[t.min(t.floor((n[r]-i)/a),o-1)]+=1;return s},e.covariance=function(t,n){var o,r=e.mean(t),i=e.mean(n),a=t.length,l=new Array(a);for(o=0;o<a;o++)l[o]=(t[o]-r)*(n[o]-i);return e.sum(l)/(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,o){for(var r=e.mean(n),i=e.stdev(n),a=n.length,l=0,s=0;s<a;s++)l+=t.pow((n[s]-r)/i,o);return l/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 o=0;o<t.length;o++)!function(t){i[t]=function(o,r){var a=[],l=0,s=this;if(n(o)&&(r=o,o=!1),r)return setTimeout((function(){r.call(s,i[t].call(s,o))})),this;if(this.length>1){for(s=!0===o?this:this.transpose();l<s.length;l++)a[l]=e[t](s[l]);return a}return e[t](this[0],o)}}(t[o])}("cumsum cumprod".split(" ")),function(t){for(var o=0;o<t.length;o++)!function(t){i[t]=function(o,r){var a=[],l=0,s=this;if(n(o)&&(r=o,o=!1),r)return setTimeout((function(){r.call(s,i[t].call(s,o))})),this;if(this.length>1){for("sumrow"!==t&&(s=!0===o?this:this.transpose());l<s.length;l++)a[l]=e[t](s[l]);return!0===o?e[t](e.utils.toVector(a)):a}return e[t](this[0],o)}}(t[o])}("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 o=0;o<t.length;o++)!function(t){i[t]=function(){var o,r=[],a=0,l=this,s=Array.prototype.slice.call(arguments);if(n(s[s.length-1])){o=s[s.length-1];var u=s.slice(0,s.length-1);return setTimeout((function(){o.call(l,i[t].apply(l,u))})),this}o=void 0;var c=function(n){return e[t].apply(l,[n].concat(s))};if(this.length>1){for(l=l.transpose();a<l.length;a++)r[a]=c(l[a]);return r}return c(this[0])}}(t[o])}("quantiles percentileOfScore".split(" "))}(t,Math),function(e,t){e.gammaln=function(e){var n,o,r,i=0,a=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],l=1.000000000190015;for(r=(o=n=e)+5.5,r-=(n+.5)*t.log(r);i<6;i++)l+=a[i]/++o;return t.log(2.5066282746310007*l/n)-r},e.loggam=function(e){var n,o,r,i,a,l,s,u=[.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=t.floor(7-e))),o=1/(n*n),r=2*t.PI,a=u[9],l=8;l>=0;l--)a*=o,a+=u[l];if(i=a/n+.5*t.log(r)+(n-.5)*t.log(n)-n,e<=7)for(l=1;l<=s;l++)i-=t.log(n-1),n-=1;return i},e.gammafn=function(e){var n,o,r,i,a=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],l=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],s=!1,u=0,c=0,d=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)*t.PI/t.sin(t.PI*i),m=1-m}for(r=m,o=m<1?m++:(m-=u=(0|m)-1)-1,n=0;n<8;++n)d=(d+a[n])*o,c=c*o+l[n];if(i=d/c+1,r<m)i/=r;else if(r>m)for(n=0;n<u;++n)i*=m,m++;return s&&(i=s/i),i},e.gammap=function(t,n){return e.lowRegGamma(t,n)*e.gammafn(t)},e.lowRegGamma=function(n,o){var r,i=e.gammaln(n),a=n,l=1/n,s=l,u=o+1-n,c=1/1e-30,d=1/u,m=d,f=1,h=-~(8.5*t.log(n>=1?n:1/n)+.4*n+17);if(o<0||n<=0)return NaN;if(o<n+1){for(;f<=h;f++)l+=s*=o/++a;return l*t.exp(-o+n*t.log(o)-i)}for(;f<=h;f++)m*=(d=1/(d=(r=-f*(f-n))*d+(u+=2)))*(c=u+r/c);return 1-m*t.exp(-o+n*t.log(o)-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,o){return n>170||o>170?t.exp(e.combinationln(n,o)):e.factorial(n)/e.factorial(o)/e.factorial(n-o)},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,o){if(!(n<=0||o<=0))return n+o>170?t.exp(e.betaln(n,o)):e.gammafn(n)*e.gammafn(o)/e.gammafn(n+o)},e.betaln=function(t,n){return e.gammaln(t)+e.gammaln(n)-e.gammaln(t+n)},e.betacf=function(e,n,o){var r,i,a,l,s=1e-30,u=1,c=n+o,d=n+1,m=n-1,f=1,h=1-c*e/d;for(t.abs(h)<s&&(h=s),l=h=1/h;u<=100&&(h=1+(i=u*(o-u)*e/((m+(r=2*u))*(n+r)))*h,t.abs(h)<s&&(h=s),f=1+i/f,t.abs(f)<s&&(f=s),l*=(h=1/h)*f,h=1+(i=-(n+u)*(c+u)*e/((n+r)*(d+r)))*h,t.abs(h)<s&&(h=s),f=1+i/f,t.abs(f)<s&&(f=s),l*=a=(h=1/h)*f,!(t.abs(a-1)<3e-7));u++);return l},e.gammapinv=function(n,o){var r,i,a,l,s,u,c=0,d=o-1,m=e.gammaln(o);if(n>=1)return t.max(100,o+100*t.sqrt(o));if(n<=0)return 0;for(o>1?(s=t.log(d),u=t.exp(d*(s-1)-m),l=n<.5?n:1-n,r=(2.30753+.27061*(i=t.sqrt(-2*t.log(l))))/(1+i*(.99229+.04481*i))-i,n<.5&&(r=-r),r=t.max(.001,o*t.pow(1-1/(9*o)-r/(3*t.sqrt(o)),3))):r=n<(i=1-o*(.253+.12*o))?t.pow(n/i,1/o):1-t.log(1-(n-i)/(1-i));c<12;c++){if(r<=0)return 0;if((r-=i=(a=(e.lowRegGamma(o,r)-n)/(i=o>1?u*t.exp(-(r-d)+d*(t.log(r)-s)):t.exp(-r+d*t.log(r)-m)))/(1-.5*t.min(1,a*((o-1)/r-1))))<=0&&(r=.5*(r+i)),t.abs(i)<1e-8*r)break}return r},e.erf=function(e){var n,o,r,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],l=a.length-1,s=!1,u=0,c=0;for(e<0&&(e=-e,s=!0),o=4*(n=2/(2+e))-2;l>0;l--)r=u,u=o*u-c+a[l],c=r;return i=n*t.exp(-e*e+.5*(a[0]+o*u)-c),s?i-1:1-i},e.erfc=function(t){return 1-e.erf(t)},e.erfcinv=function(n){var o,r,i,a,l=0;if(n>=2)return-100;if(n<=0)return 100;for(a=n<1?n:2-n,o=-.70711*((2.30753+.27061*(i=t.sqrt(-2*t.log(a/2))))/(1+i*(.99229+.04481*i))-i);l<2;l++)o+=(r=e.erfc(o)-a)/(1.1283791670955126*t.exp(-o*o)-o*r);return n<1?o:-o},e.ibetainv=function(n,o,r){var i,a,l,s,u,c,d,m,f,h,p=o-1,g=r-1,v=0;if(n<=0)return 0;if(n>=1)return 1;for(o>=1&&r>=1?(l=n<.5?n:1-n,c=(2.30753+.27061*(s=t.sqrt(-2*t.log(l))))/(1+s*(.99229+.04481*s))-s,n<.5&&(c=-c),d=(c*c-3)/6,m=2/(1/(2*o-1)+1/(2*r-1)),f=c*t.sqrt(d+m)/m-(1/(2*r-1)-1/(2*o-1))*(d+5/6-2/(3*m)),c=o/(o+r*t.exp(2*f))):(i=t.log(o/(o+r)),a=t.log(r/(o+r)),c=n<(s=t.exp(o*i)/o)/(f=s+(u=t.exp(r*a)/r))?t.pow(o*f*n,1/o):1-t.pow(r*f*(1-n),1/r)),h=-e.gammaln(o)-e.gammaln(r)+e.gammaln(o+r);v<10;v++){if(0===c||1===c)return c;if((c-=s=(u=(e.ibeta(c,o,r)-n)/(s=t.exp(p*t.log(c)+g*t.log(1-c)+h)))/(1-.5*t.min(1,u*(p/c-g/(1-c)))))<=0&&(c=.5*(c+s)),c>=1&&(c=.5*(c+s+1)),t.abs(s)<1e-8*c&&v>0)break}return c},e.ibeta=function(n,o,r){var i=0===n||1===n?0:t.exp(e.gammaln(o+r)-e.gammaln(o)-e.gammaln(r)+o*t.log(n)+r*t.log(1-n));return!(n<0||n>1)&&(n<(o+1)/(o+r+2)?i*e.betacf(n,o,r)/o:1-i*e.betacf(1-n,r,o)/r)},e.randn=function(n,o){var r,i,a,l,s;if(o||(o=n),n)return e.create(n,o,(function(){return e.randn()}));do{r=e._random_fn(),i=1.7156*(e._random_fn()-.5),s=(a=r-.449871)*a+(l=t.abs(i)+.386595)*(.196*l-.25472*a)}while(s>.27597&&(s>.27846||i*i>-4*t.log(r)*r*r));return i/r},e.randg=function(n,o,r){var i,a,l,s,u,c,d=n;if(r||(r=o),n||(n=1),o)return(c=e.zeros(o,r)).alter((function(){return e.randg(n)})),c;n<1&&(n+=1),i=n-1/3,a=1/t.sqrt(9*i);do{do{s=1+a*(u=e.randn())}while(s<=0);s*=s*s,l=e._random_fn()}while(l>1-.331*t.pow(u,4)&&t.log(l)>.5*u*u+i*(1-s+t.log(s)));if(n==d)return i*s;do{l=e._random_fn()}while(0===l);return t.pow(l,1/d)*i*s},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,o,r){for(var i,a=0,l=1,s=1,u=1,c=0,d=0;t.abs((s-d)/s)>r;)d=s,l=u+(i=-(n+c)*(n+o+c)*e/(n+2*c)/(n+2*c+1))*l,s=(a=s+i*a)+(i=(c+=1)*(o-c)*e/(n+2*c-1)/(n+2*c))*s,a/=u=l+i*u,l/=u,s/=u,u=1;return s/n}function o(n,o,r){var i=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],a=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],l=.5*n;if(l>=8)return 1;var s,u=2*e.normal.cdf(l,0,1,1,0)-1;u=u>=t.exp(-50/r)?t.pow(u,r):0;for(var c=l,d=(8-l)/(s=n>3?2:3),m=c+d,f=0,h=r-1,p=1;p<=s;p++){for(var g=0,v=.5*(m+c),C=.5*(m-c),w=1;w<=12;w++){var T,_=v+C*(6<w?i[(T=12-w+1)-1]:-i[(T=w)-1]),x=_*_;if(x>60)break;var y=2*e.normal.cdf(_,0,1,1,0)*.5-2*e.normal.cdf(_,n,1,1,0)*.5;y>=t.exp(-30/h)&&(g+=y=a[T-1]*t.exp(-.5*x)*t.pow(y,h))}f+=g*=2*C*r/t.sqrt(2*t.PI),c=m,m+=d}return(u+=f)<=t.exp(-30/o)?0:(u=t.pow(u,o))>=1?1:u}!function(t){for(var n=0;n<t.length;n++)!function(t){e[t]=function e(t,n,o){return this instanceof e?(this._a=t,this._b=n,this._c=o,this):new e(t,n,o)},e.fn[t]=function(n,o,r){var i=e[t](n,o,r);return i.data=this,i},e[t].prototype.sample=function(n){var o=this._a,r=this._b,i=this._c;return n?e.alter(n,(function(){return e[t].sample(o,r,i)})):e[t].sample(o,r,i)},function(n){for(var o=0;o<n.length;o++)!function(n){e[t].prototype[n]=function(o){var r=this._a,i=this._b,a=this._c;return o||0===o||(o=this.data),"number"!=typeof o?e.fn.map.call(o,(function(o){return e[t][n](o,r,i,a)})):e[t][n](o,r,i,a)}}(n[o])}("pdf cdf inv".split(" ")),function(n){for(var o=0;o<n.length;o++)!function(n){e[t].prototype[n]=function(){return e[t][n](this._a,this._b,this._c)}}(n[o])}("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,o,r){return n>1||n<0?0:1==o&&1==r?1:o<512&&r<512?t.pow(n,o-1)*t.pow(1-n,r-1)/e.betafn(o,r):t.exp((o-1)*t.log(n)+(r-1)*t.log(1-n)-e.betaln(o,r))},cdf:function(t,n,o){return t>1||t<0?1*(t>1):e.ibeta(t,n,o)},inv:function(t,n,o){return e.ibetainv(t,n,o)},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 o=e.randg(t);return o/(o+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,o,r){var i;return n<0?0:o<=2?0===n&&o<2?1/0:0===n&&2===o?1:1/e.betafn(o/2,r/2)*t.pow(o/r,o/2)*t.pow(n,o/2-1)*t.pow(1+o/r*n,-(o+r)/2):(i=o*n/(r+n*o),o*(r/(r+n*o))/2*e.binomial.pdf((o-2)/2,(o+r-2)/2,i))},cdf:function(t,n,o){return t<0?0:e.ibeta(n*t/(n*t+o),n/2,o/2)},inv:function(t,n,o){return o/(n*(1/e.ibetainv(t,n/2,o/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,o){return o<0?0:o/(t.pow(e-n,2)+t.pow(o,2))/t.PI},cdf:function(e,n,o){return t.atan((e-n)/o)/t.PI+.5},inv:function(e,n,o){return n+o*t.tan(t.PI*(e-.5))},median:function(e){return e},mode:function(e){return e},sample:function(n,o){return e.randn()*t.sqrt(1/(2*e.randg(.5)))*o+n}}),e.extend(e.chisquare,{pdf:function(n,o){return n<0?0:0===n&&2===o?.5:t.exp((o/2-1)*t.log(n)-n/2-o/2*t.log(2)-e.gammaln(o/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,o,r){return n<0?0:0===n&&1===o?1/r:t.exp((o-1)*t.log(n)-n/r-e.gammaln(o)-o*t.log(r))},cdf:function(t,n,o){return t<0?0:e.lowRegGamma(n,t/o)},inv:function(t,n,o){return e.gammapinv(t,n)*o},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,o,r){return n<=0?0:t.exp(-(o+1)*t.log(n)-r/n-e.gammaln(o)+o*t.log(r))},cdf:function(t,n,o){return t<=0?0:1-e.lowRegGamma(n,o/t)},inv:function(t,n,o){return o/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,o){return 0===e&&1===n?o:1===e&&1===o?n:t.exp(t.log(n)+t.log(o)+(n-1)*t.log(e)+(o-1)*t.log(1-t.pow(e,n)))},cdf:function(e,n,o){return e<0?0:e>1?1:1-t.pow(1-t.pow(e,n),o)},inv:function(e,n,o){return t.pow(1-t.pow(1-e,1/o),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,o){return e<=0?0:t.exp(-t.log(e)-.5*t.log(2*t.PI)-t.log(o)-t.pow(t.log(e)-n,2)/(2*o*o))},cdf:function(n,o,r){return n<0?0:.5+.5*e.erf((t.log(n)-o)/t.sqrt(2*r*r))},inv:function(n,o,r){return t.exp(-1.4142135623730951*r*e.erfcinv(2*n)+o)},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,o){return t.exp(e.randn()*o+n)},variance:function(e,n){return(t.exp(n*n)-1)*t.exp(2*e+n*n)}}),e.extend(e.noncentralt,{pdf:function(n,o,r){return t.abs(r)<1e-14?e.studentt.pdf(n,o):t.abs(n)<1e-14?t.exp(e.gammaln((o+1)/2)-r*r/2-.5*t.log(t.PI*o)-e.gammaln(o/2)):o/n*(e.noncentralt.cdf(n*t.sqrt(1+2/o),o+2,r)-e.noncentralt.cdf(n,o,r))},cdf:function(n,o,r){var i=1e-14;if(t.abs(r)<i)return e.studentt.cdf(n,o);var a=!1;n<0&&(a=!0,r=-r);for(var l=e.normal.cdf(-r,0,1),s=i+1,u=s,c=n*n/(n*n+o),d=0,m=t.exp(-r*r/2),f=t.exp(-r*r/2-.5*t.log(2)-e.gammaln(1.5))*r;d<200||u>i||s>i;)u=s,d>0&&(m*=r*r/(2*d),f*=r*r/(2*(d+.5))),l+=.5*(s=m*e.beta.cdf(c,d+.5,o/2)+f*e.beta.cdf(c,d+1,o/2)),d++;return a?1-l:l}}),e.extend(e.normal,{pdf:function(e,n,o){return t.exp(-.5*t.log(2*t.PI)-t.log(o)-t.pow(e-n,2)/(2*o*o))},cdf:function(n,o,r){return.5*(1+e.erf((n-o)/t.sqrt(2*r*r)))},inv:function(t,n,o){return-1.4142135623730951*o*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,o){return e<n?0:o*t.pow(n,o)/t.pow(e,o+1)},cdf:function(e,n,o){return e<n?0:1-t.pow(n/e,o)},inv:function(e,n,o){return n/t.pow(1-e,1/o)},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,o){return o=o>1e100?1e100:o,1/(t.sqrt(o)*e.betafn(.5,o/2))*t.pow(1+n*n/o,-(o+1)/2)},cdf:function(n,o){var r=o/2;return e.ibeta((n+t.sqrt(n*n+o))/(2*t.sqrt(n*n+o)),r,r)},inv:function(n,o){var r=e.ibetainv(2*t.min(n,1-n),.5*o,.5);return r=t.sqrt(o*(1-r)/r),n>.5?r:-r},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,o){return e<0||n<0||o<0?0:o/n*t.pow(e/n,o-1)*t.exp(-t.pow(e/n,o))},cdf:function(e,n,o){return e<0?0:1-t.exp(-t.pow(e/n,o))},inv:function(e,n,o){return n*t.pow(-t.log(1-e),1/o)},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,o){return n*t.pow(-t.log(e._random_fn()),1/o)},variance:function(n,o){return n*n*e.gammafn(1+2/o)-t.pow(e.weibull.mean(n,o),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,o,r){return 0===r||1===r?o*r===n?1:0:e.combination(o,n)*t.pow(r,n)*t.pow(1-r,o-n)},cdf:function(o,r,i){var a,l=1e-10;if(o<0)return 0;if(o>=r)return 1;if(i<0||i>1||r<=0)return NaN;var s=i,u=(o=t.floor(o))+1,c=r-o,d=u+c,m=t.exp(e.gammaln(d)-e.gammaln(c)-e.gammaln(u)+u*t.log(s)+c*t.log(1-s));return a=s<(u+1)/(d+2)?m*n(s,u,c,l):1-m*n(1-s,c,u,l),t.round(1/l*(1-a))/(1/l)}}),e.extend(e.negbin,{pdf:function(n,o,r){return n===n>>>0&&(n<0?0:e.combination(n+o-1,o-1)*t.pow(1-r,n)*t.pow(r,o))},cdf:function(t,n,o){var r=0,i=0;if(t<0)return 0;for(;i<=t;i++)r+=e.negbin.pdf(i,n,o);return r}}),e.extend(e.hypgeom,{pdf:function(n,o,r,i){if(n!=n|0)return!1;if(n<0||n<r-(o-i))return 0;if(n>i||n>r)return 0;if(2*r>o)return 2*i>o?e.hypgeom.pdf(o-r-i+n,o,o-r,o-i):e.hypgeom.pdf(i-n,o,o-r,i);if(2*i>o)return e.hypgeom.pdf(r-n,o,r,o-i);if(r<i)return e.hypgeom.pdf(n,o,i,r);for(var a=1,l=0,s=0;s<n;s++){for(;a>1&&l<i;)a*=1-r/(o-l),l++;a*=(i-s)*(r-s)/((s+1)*(o-r-i+s+1))}for(;l<i;l++)a*=1-r/(o-l);return t.min(1,t.max(0,a))},cdf:function(n,o,r,i){if(n<0||n<r-(o-i))return 0;if(n>=i||n>=r)return 1;if(2*r>o)return 2*i>o?e.hypgeom.cdf(o-r-i+n,o,o-r,o-i):1-e.hypgeom.cdf(i-n-1,o,o-r,i);if(2*i>o)return 1-e.hypgeom.cdf(r-n-1,o,r,o-i);if(r<i)return e.hypgeom.cdf(n,o,i,r);for(var a=1,l=1,s=0,u=0;u<n;u++){for(;a>1&&s<i;){var c=1-r/(o-s);l*=c,a*=c,s++}a+=l*=(i-u)*(r-u)/((u+1)*(o-r-i+u+1))}for(;s<i;s++)a*=1-r/(o-s);return t.min(1,t.max(0,a))}}),e.extend(e.poisson,{pdf:function(n,o){return o<0||n%1!=0||n<0?0:t.pow(o,n)*t.exp(-o)/e.factorial(n)},cdf:function(t,n){var o=[],r=0;if(t<0)return 0;for(;r<=t;r++)o.push(e.poisson.pdf(r,n));return e.sum(o)},mean:function(e){return e},variance:function(e){return e},sampleSmall:function(n){var o=1,r=0,i=t.exp(-n);do{r++,o*=e._random_fn()}while(o>i);return r-1},sampleLarge:function(n){var o,r,i,a,l,s,u,c,d,m,f=n;for(a=t.sqrt(f),l=t.log(f),s=.02483*(u=.931+2.53*a)-.059,c=1.1239+1.1328/(u-3.4),d=.9277-3.6224/(u-2);;){if(r=t.random()-.5,i=t.random(),m=.5-t.abs(r),o=t.floor((2*s/m+u)*r+f+.43),m>=.07&&i<=d)return o;if(!(o<0||m<.013&&i>m)&&t.log(i)+t.log(c)-t.log(s/(m*m)+u)<=o*l-f-e.loggam(o+1))return o}},sample:function(e){return e<10?this.sampleSmall(e):this.sampleLarge(e)}}),e.extend(e.triangular,{pdf:function(e,t,n,o){return n<=t||o<t||o>n?NaN:e<t||e>n?0:e<o?2*(e-t)/((n-t)*(o-t)):e===o?2/(n-t):2*(n-e)/((n-t)*(n-o))},cdf:function(e,n,o,r){return o<=n||r<n||r>o?NaN:e<=n?0:e>=o?1:e<=r?t.pow(e-n,2)/((o-n)*(r-n)):1-t.pow(o-e,2)/((o-n)*(o-r))},inv:function(e,n,o,r){return o<=n||r<n||r>o?NaN:e<=(r-n)/(o-n)?n+(o-n)*t.sqrt(e*((r-n)/(o-n))):n+(o-n)*(1-t.sqrt((1-e)*(1-(r-n)/(o-n))))},mean:function(e,t,n){return(e+t+n)/3},median:function(e,n,o){return o<=(e+n)/2?n-t.sqrt((n-e)*(n-o))/t.sqrt(2):o>(e+n)/2?e+t.sqrt((n-e)*(o-e))/t.sqrt(2):void 0},mode:function(e,t,n){return n},sample:function(n,o,r){var i=e._random_fn();return i<(r-n)/(o-n)?n+t.sqrt(i*(o-n)*(r-n)):o-t.sqrt((1-i)*(o-n)*(o-r))},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,o){return o<=n?NaN:e<=n||e>=o?0:2/t.PI*t.pow(t.pow(o-n,2)-t.pow(2*e-n-o,2),-.5)},cdf:function(e,n,o){return e<n?0:e<o?2/t.PI*t.asin(t.sqrt((e-n)/(o-n))):1},inv:function(e,n,o){return n+(.5-.5*t.cos(t.PI*e))*(o-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,o){return(n+o)/2+(o-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,o){return o<=0?0:t.exp(-t.abs(e-n)/o)/(2*o)},cdf:function(e,n,o){return o<=0?0:e<n?.5*t.exp((e-n)/o):1-.5*t.exp(-(e-n)/o)},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,o){var r,i=e._random_fn()-.5;return n-o*((r=i)/t.abs(r))*t.log(1-2*t.abs(i))}}),e.extend(e.tukey,{cdf:function(n,r,i){var a=r,l=[.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 o(n,1,a);var u,c=.5*i,d=c*t.log(i)-i*t.log(2)-e.gammaln(c),m=c-1,f=.25*i;u=i<=100?1:i<=800?.5:i<=5e3?.25:.125,d+=t.log(u);for(var h=0,p=1;p<=50;p++){for(var g=0,v=(2*p-1)*u,C=1;C<=16;C++){var w,T;8<C?(w=C-8-1,T=d+m*t.log(v+l[w]*u)-(l[w]*u+v)*f):(w=C-1,T=d+m*t.log(v-l[w]*u)+(l[w]*u-v)*f),T>=-30&&(g+=o(8<C?n*t.sqrt(.5*(l[w]*u+v)):n*t.sqrt(.5*(-l[w]*u+v)),1,a)*s[w]*t.exp(T))}if(p*u>=1&&g<=1e-14)break;h+=g}if(g>1e-14)throw new Error("tukey.cdf failed to converge");return h>1&&(h=1),h},inv:function(n,o,r){if(r<2||o<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,o){var r=.5-.5*e,i=t.sqrt(t.log(1/(r*r))),a=i+((((-453642210148e-16*i-.204231210125)*i-.342242088547)*i-1)*i+.322232421088)/((((.0038560700634*i+.10353775285)*i+.531103462366)*i+.588581570495)*i+.099348462606);o<120&&(a+=(a*a*a+a)/o/4);var l=.8832-.2368*a;return o<120&&(l+=-1.214/o+1.208*a/o),a*(l*t.log(n-1)+1.4142)}(n,o,r),l=e.tukey.cdf(a,o,r)-n;i=l>0?t.max(0,a-1):a+1;for(var s,u=e.tukey.cdf(i,o,r)-n,c=1;c<50;c++)if(s=i-u*(i-a)/(u-l),l=u,a=i,s<0&&(s=0,u=-n),u=e.tukey.cdf(s,o,r)-n,i=s,t.abs(i-a)<1e-4)return s;throw new Error("tukey.inv failed to converge")}})}(t,Math),function(e,t){var n,o,r=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,o){return e+n[t][o]}))):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,o){return e-n[t][o]||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 o,r,i,l,s,u,c,d;if(void 0===t.length&&void 0===n.length)return t*n;if(s=t.length,u=t[0].length,c=e.zeros(s,i=a(n)?n[0].length:u),d=0,a(n)){for(;d<i;d++)for(o=0;o<s;o++){for(l=0,r=0;r<u;r++)l+=t[o][r]*n[r][d];c[o][d]=l}return 1===s&&1===d?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 o,r,i=1===t[0].length&&1!==t.length?e.transpose(t):t,l=1===n[0].length&&1!==n.length?e.transpose(n):n,s=[],u=0,c=i.length,d=i[0].length;u<c;u++){for(s[u]=[],o=0,r=0;r<d;r++)o+=i[u][r]*l[u][r];s[u]=o}return 1===s.length?s[0]:s},pow:function(n,o){return e.map(n,(function(e){return t.pow(e,o)}))},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 o=0,r=0;for(isNaN(n)&&(n=2),a(e[0])&&(e=e[0]);r<e.length;r++)o+=t.pow(t.abs(e[r]),n);return t.pow(o,1/n)},angle:function(n,o){return t.acos(e.dot(n,o)/(e.norm(n)*e.norm(o)))},aug:function(e,t){var n,o=[];for(n=0;n<e.length;n++)o.push(e[n].slice());for(n=0;n<o.length;n++)r.apply(o[n],t[n]);return o},inv:function(t){for(var n,o=t.length,r=t[0].length,i=e.identity(o,r),a=e.gauss_jordan(t,i),l=[],s=0;s<o;s++)for(l[s]=[],n=r;n<a[0].length;n++)l[s][n-r]=a[s][n];return l},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,o=0;o<t.length;o++){for(var r=[],i=1;i<t.length;i++){r[i-1]=[];for(var a=0;a<t.length;a++)a<o?r[i-1][a]=t[i][a]:a>o&&(r[i-1][a-1]=t[i][a])}var l=o%2?-1:1;n+=e(r)*t[0][o]*l}return n},gauss_elimination:function(n,o){var r,i,a,l,s=0,u=0,c=n.length,d=n[0].length,m=1,f=0,h=[];for(r=(n=e.aug(n,o))[0].length,s=0;s<c;s++){for(i=n[s][s],u=s,l=s+1;l<d;l++)i<t.abs(n[l][s])&&(i=n[l][s],u=l);if(u!=s)for(l=0;l<r;l++)a=n[s][l],n[s][l]=n[u][l],n[u][l]=a;for(u=s+1;u<c;u++)for(m=n[u][s]/n[s][s],l=s;l<r;l++)n[u][l]=n[u][l]-m*n[s][l]}for(s=c-1;s>=0;s--){for(f=0,u=s+1;u<=c-1;u++)f+=h[u]*n[s][u];h[s]=(n[s][r-1]-f)/n[s][s]}return h},gauss_jordan:function(n,o){var r,i,a,l=e.aug(n,o),s=l.length,u=l[0].length,c=0;for(i=0;i<s;i++){var d=i;for(a=i+1;a<s;a++)t.abs(l[a][i])>t.abs(l[d][i])&&(d=a);var m=l[i];for(l[i]=l[d],l[d]=m,a=i+1;a<s;a++)for(c=l[a][i]/l[i][i],r=i;r<u;r++)l[a][r]-=l[i][r]*c}for(i=s-1;i>=0;i--){for(c=l[i][i],a=0;a<i;a++)for(r=u-1;r>i-1;r--)l[a][r]-=l[i][r]*l[a][i]/c;for(l[i][i]/=c,r=s;r<u;r++)l[i][r]/=c}return l},triaUpSolve:function(t,n){var o,r=t[0].length,i=e.zeros(1,r)[0],a=!1;return null!=n[0].length&&(n=n.map((function(e){return e[0]})),a=!0),e.arange(r-1,-1,-1).forEach((function(a){o=e.arange(a+1,r).map((function(e){return i[e]*t[a][e]})),i[a]=(n[a]-e.sum(o))/t[a][a]})),a?i.map((function(e){return[e]})):i},triaLowSolve:function(t,n){var o,r=t[0].length,i=e.zeros(1,r)[0],a=!1;return null!=n[0].length&&(n=n.map((function(e){return e[0]})),a=!0),e.arange(r).forEach((function(r){o=e.arange(r).map((function(e){return t[r][e]*i[e]})),i[r]=(n[r]-e.sum(o))/t[r][r]})),a?i.map((function(e){return[e]})):i},lu:function(t){var n,o=t.length,r=e.identity(o),i=e.zeros(t.length,t[0].length);return e.arange(o).forEach((function(e){i[0][e]=t[0][e]})),e.arange(1,o).forEach((function(a){e.arange(a).forEach((function(o){n=e.arange(o).map((function(e){return r[a][e]*i[e][o]})),r[a][o]=(t[a][o]-e.sum(n))/i[o][o]})),e.arange(a,o).forEach((function(o){n=e.arange(a).map((function(e){return r[a][e]*i[e][o]})),i[a][o]=t[n.length][o]-e.sum(n)}))})),[r,i]},cholesky:function(n){var o,r=n.length,i=e.zeros(n.length,n[0].length);return e.arange(r).forEach((function(a){o=e.arange(a).map((function(e){return t.pow(i[a][e],2)})),i[a][a]=t.sqrt(n[a][a]-e.sum(o)),e.arange(a+1,r).forEach((function(t){o=e.arange(a).map((function(e){return i[a][e]*i[t][e]})),i[t][a]=(n[a][t]-e.sum(o))/i[a][a]}))})),i},gauss_jacobi:function(n,o,r,i){for(var a,l,s,u,c=0,d=0,m=n.length,f=[],h=[],p=[];c<m;c++)for(f[c]=[],h[c]=[],p[c]=[],d=0;d<m;d++)c>d?(f[c][d]=n[c][d],h[c][d]=p[c][d]=0):c<d?(h[c][d]=n[c][d],f[c][d]=p[c][d]=0):(p[c][d]=n[c][d],f[c][d]=h[c][d]=0);for(s=e.multiply(e.multiply(e.inv(p),e.add(f,h)),-1),l=e.multiply(e.inv(p),o),a=r,u=e.add(e.multiply(s,r),l),c=2;t.abs(e.norm(e.subtract(u,a)))>i;)a=u,u=e.add(e.multiply(s,a),l),c++;return u},gauss_seidel:function(n,o,r,i){for(var a,l,s,u,c,d=0,m=n.length,f=[],h=[],p=[];d<m;d++)for(f[d]=[],h[d]=[],p[d]=[],a=0;a<m;a++)d>a?(f[d][a]=n[d][a],h[d][a]=p[d][a]=0):d<a?(h[d][a]=n[d][a],f[d][a]=p[d][a]=0):(p[d][a]=n[d][a],f[d][a]=h[d][a]=0);for(u=e.multiply(e.multiply(e.inv(e.add(p,f)),h),-1),s=e.multiply(e.inv(e.add(p,f)),o),l=r,c=e.add(e.multiply(u,r),s),d=2;t.abs(e.norm(e.subtract(c,l)))>i;)l=c,c=e.add(e.multiply(u,l),s),d+=1;return c},SOR:function(n,o,r,i,a){for(var l,s,u,c,d,m=0,f=n.length,h=[],p=[],g=[];m<f;m++)for(h[m]=[],p[m]=[],g[m]=[],l=0;l<f;l++)m>l?(h[m][l]=n[m][l],p[m][l]=g[m][l]=0):m<l?(p[m][l]=n[m][l],h[m][l]=g[m][l]=0):(g[m][l]=n[m][l],h[m][l]=p[m][l]=0);for(c=e.multiply(e.inv(e.add(g,e.multiply(h,a))),e.subtract(e.multiply(g,1-a),e.multiply(p,a))),u=e.multiply(e.multiply(e.inv(e.add(g,e.multiply(h,a))),o),a),s=r,d=e.add(e.multiply(c,r),u),m=2;t.abs(e.norm(e.subtract(d,s)))>i;)s=d,d=e.add(e.multiply(c,s),u),m++;return d},householder:function(n){for(var o,r,i,a,l=n.length,s=n[0].length,u=0,c=[],d=[];u<l-1;u++){for(o=0,a=u+1;a<s;a++)o+=n[a][u]*n[a][u];for(o=(n[u+1][u]>0?-1:1)*t.sqrt(o),r=t.sqrt((o*o-n[u+1][u]*o)/2),(c=e.zeros(l,1))[u+1][0]=(n[u+1][u]-o)/(2*r),i=u+2;i<l;i++)c[i][0]=n[i][u]/(2*r);d=e.subtract(e.identity(l,s),e.multiply(e.multiply(c,e.transpose(c)),2)),n=e.multiply(d,e.multiply(n,d))}return n},QR:(n=e.sum,o=e.arange,function(r){var i,a,l,s=r.length,u=r[0].length,c=e.zeros(u,u);for(r=e.copy(r),a=0;a<u;a++){for(c[a][a]=t.sqrt(n(o(s).map((function(e){return r[e][a]*r[e][a]})))),i=0;i<s;i++)r[i][a]=r[i][a]/c[a][a];for(l=a+1;l<u;l++)for(c[a][l]=n(o(s).map((function(e){return r[e][a]*r[e][l]}))),i=0;i<s;i++)r[i][l]=r[i][l]-r[i][a]*c[a][l]}return[r,c]}),lstsq:function(t,n){var o=!1;void 0===n[0].length&&(n=n.map((function(e){return[e]})),o=!0);var r=e.QR(t),i=r[0],a=r[1],l=t[0].length,s=e.slice(i,{col:{end:l}}),u=function(t){var n=(t=e.copy(t)).length,o=e.identity(n);return e.arange(n-1,-1,-1).forEach((function(n){e.sliceAssign(o,{row:n},e.divide(e.slice(o,{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(r){var i=e.multiply(t[r][n],-1),a=e.slice(t,{row:r}),l=e.multiply(e.slice(t,{row:n}),i);e.sliceAssign(t,{row:r},e.add(a,l));var s=e.slice(o,{row:r}),u=e.multiply(e.slice(o,{row:n}),i);e.sliceAssign(o,{row:r},e.add(s,u))}))})),o}(e.slice(a,{row:{end:l}})),c=e.transpose(s);void 0===c[0].length&&(c=[c]);var d=e.multiply(e.multiply(u,c),n);return void 0===d.length&&(d=[[d]]),o?d.map((function(e){return e[0]})):d},jacobi:function(n){for(var o,r,i,a,l,s,u,c=1,d=n.length,m=e.identity(d,d),f=[];1===c;){for(l=n[0][1],i=0,a=1,o=0;o<d;o++)for(r=0;r<d;r++)o!=r&&l<t.abs(n[o][r])&&(l=t.abs(n[o][r]),i=o,a=r);for(s=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(d,d))[i][i]=t.cos(s),u[i][a]=-t.sin(s),u[a][i]=t.sin(s),u[a][a]=t.cos(s),m=e.multiply(m,u),n=e.multiply(e.multiply(e.inv(u),n),u),c=0,o=1;o<d;o++)for(r=1;r<d;r++)o!=r&&t.abs(n[o][r])>.001&&(c=1)}for(o=0;o<d;o++)f.push(n[o][o]);return[m,f]},rungekutta:function(e,t,n,o,r,i){var a,l,s;if(2===i)for(;o<=n;)r+=((a=t*e(o,r))+(l=t*e(o+t,r+a)))/2,o+=t;if(4===i)for(;o<=n;)r+=((a=t*e(o,r))+2*(l=t*e(o+t/2,r+a/2))+2*(s=t*e(o+t/2,r+l/2))+t*e(o+t,r+s))/6,o+=t;return r},romberg:function(e,n,o,r){for(var i,a,l,s,u,c=0,d=(o-n)/2,m=[],f=[],h=[];c<r/2;){for(u=e(n),l=n,s=0;l<=o;l+=d,s++)m[s]=l;for(i=m.length,l=1;l<i-1;l++)u+=(l%2!=0?4:2)*e(m[l]);u=d/3*(u+e(o)),h[c]=u,d/=2,c++}for(a=h.length,i=1;1!==a;){for(l=0;l<a-1;l++)f[l]=(t.pow(4,i)*h[l+1]-h[l])/(t.pow(4,i)-1);a=f.length,h=f,f=[],i++}return h},richardson:function(e,n,o,r){function i(e,t){for(var n,o=0,r=e.length;o<r;o++)e[o]===t&&(n=o);return n}for(var a,l,s,u,c,d=t.abs(o-e[i(e,o)+1]),m=0,f=[],h=[];r>=d;)a=i(e,o+r),l=i(e,o),f[m]=(n[a]-2*n[l]+n[2*l-a])/(r*r),r/=2,m++;for(u=f.length,s=1;1!=u;){for(c=0;c<u-1;c++)h[c]=(t.pow(4,s)*f[c+1]-f[c])/(t.pow(4,s)-1);u=h.length,f=h,h=[],s++}return f},simpson:function(e,t,n,o){for(var r,i=(n-t)/o,a=e(t),l=[],s=t,u=0,c=1;s<=n;s+=i,u++)l[u]=s;for(r=l.length;c<r-1;c++)a+=(c%2!=0?4:2)*e(l[c]);return i/3*(a+e(n))},hermite:function(e,t,n,o){for(var r,i=e.length,a=0,l=0,s=[],u=[],c=[],d=[];l<i;l++){for(s[l]=1,r=0;r<i;r++)l!=r&&(s[l]*=(o-e[r])/(e[l]-e[r]));for(u[l]=0,r=0;r<i;r++)l!=r&&(u[l]+=1/(e[l]-e[r]));c[l]=(1-2*(o-e[l])*u[l])*(s[l]*s[l]),d[l]=(o-e[l])*(s[l]*s[l]),a+=c[l]*t[l]+d[l]*n[l]}return a},lagrange:function(e,t,n){for(var o,r,i=0,a=0,l=e.length;a<l;a++){for(r=t[a],o=0;o<l;o++)a!=o&&(r*=(n-e[o])/(e[a]-e[o]));i+=r}return i},cubic_spline:function(t,n,o){for(var r,i,a=t.length,l=0,s=[],u=[],c=[],d=[],m=[],f=[];l<a-1;l++)d[l]=t[l+1]-t[l];for(c[0]=0,l=1;l<a-1;l++)c[l]=3/d[l]*(n[l+1]-n[l])-3/d[l-1]*(n[l]-n[l-1]);for(l=1;l<a-1;l++)s[l]=[],u[l]=[],s[l][l-1]=d[l-1],s[l][l]=2*(d[l-1]+d[l]),s[l][l+1]=d[l],u[l][0]=c[l];for(i=e.multiply(e.inv(s),u),r=0;r<a-1;r++)m[r]=(n[r+1]-n[r])/d[r]-d[r]*(i[r+1][0]+2*i[r][0])/3,f[r]=(i[r+1][0]-i[r][0])/(3*d[r]);for(r=0;r<a&&!(t[r]>o);r++);return n[r-=1]+(o-t[r])*m[r]+e.sq(o-t[r])*i[r]+(o-t[r])*e.sq(o-t[r])*f[r]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(t){var n,o,r,i,a,l=t.length,s=t[0].length,u=0,c=[],d=[],m=[],f=[],h=[],p=[],g=[];for(u=0;u<l;u++)c[u]=e.sum(t[u])/s;for(u=0;u<s;u++)for(h[u]=[],n=0;n<l;n++)h[u][n]=t[n][u]-c[n];for(h=e.transpose(h),u=0;u<l;u++)for(p[u]=[],n=0;n<l;n++)p[u][n]=e.dot([h[u]],[h[n]])/(s-1);for(a=(r=e.jacobi(p))[0],d=r[1],g=e.transpose(a),u=0;u<d.length;u++)for(n=u;n<d.length;n++)d[u]<d[n]&&(o=d[u],d[u]=d[n],d[n]=o,m=g[u],g[u]=g[n],g[n]=m);for(i=e.transpose(h),u=0;u<l;u++)for(f[u]=[],n=0;n<i.length;n++)f[u][n]=e.dot([g[u]],[i[n]]);return[t,d,g,f]}}),function(t){for(var n=0;n<t.length;n++)!function(t){e.fn[t]=function(n,o){var r=this;return o?(setTimeout((function(){o.call(r,e.fn[t].call(r,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,o=e.utils.isNumber,r=e.utils.isArray;function i(e,n,o,r){if(e>1||o>1||e<=0||o<=0)throw new Error("Proportions should be greater than 0 and less than 1");var i=(e*n+o*r)/(n+r);return(e-o)/t.sqrt(i*(1-i)*(1/n+1/r))}e.extend({zscore:function(){var t=n.call(arguments);return o(t[1])?(t[0]-t[1])/t[2]:(t[0]-e.mean(t[1]))/e.stdev(t[1],t[2])},ztest:function(){var o,i=n.call(arguments);return r(i[1])?(o=e.zscore(i[0],i[1],i[3]),1===i[2]?e.normal.cdf(-t.abs(o),0,1):2*e.normal.cdf(-t.abs(o),0,1)):i.length>2?(o=e.zscore(i[0],i[1],i[2]),1===i[3]?e.normal.cdf(-t.abs(o),0,1):2*e.normal.cdf(-t.abs(o),0,1)):(o=i[0],1===i[1]?e.normal.cdf(-t.abs(o),0,1):2*e.normal.cdf(-t.abs(o),0,1))}}),e.extend(e.fn,{zscore:function(e,t){return(e-this.mean())/this.stdev(t)},ztest:function(n,o,r){var i=t.abs(this.zscore(n,r));return 1===o?e.normal.cdf(-i,0,1):2*e.normal.cdf(-i,0,1)}}),e.extend({tscore:function(){var o=n.call(arguments);return 4===o.length?(o[0]-o[1])/(o[2]/t.sqrt(o[3])):(o[0]-e.mean(o[1]))/(e.stdev(o[1],!0)/t.sqrt(o[1].length))},ttest:function(){var r,i=n.call(arguments);return 5===i.length?(r=t.abs(e.tscore(i[0],i[1],i[2],i[3])),1===i[4]?e.studentt.cdf(-r,i[3]-1):2*e.studentt.cdf(-r,i[3]-1)):o(i[1])?(r=t.abs(i[0]),1==i[2]?e.studentt.cdf(-r,i[1]-1):2*e.studentt.cdf(-r,i[1]-1)):(r=t.abs(e.tscore(i[0],i[1])),1==i[2]?e.studentt.cdf(-r,i[1].length-1):2*e.studentt.cdf(-r,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,o){return 1===o?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 o,r,i,a,l,s,u,c,d=n.call(arguments);if(1===d.length){for(l=new Array(d[0].length),u=0;u<d[0].length;u++)l[u]=d[0][u];d=l}for(r=new Array,u=0;u<d.length;u++)r=r.concat(d[u]);for(i=e.mean(r),o=0,u=0;u<d.length;u++)o+=d[u].length*t.pow(e.mean(d[u])-i,2);for(o/=d.length-1,s=0,u=0;u<d.length;u++)for(a=e.mean(d[u]),c=0;c<d[u].length;c++)s+=t.pow(d[u][c]-a,2);return o/(s/(r.length-d.length))},anovaftest:function(){var t,r,i,a,l=n.call(arguments);if(o(l[0]))return 1-e.centralF.cdf(l[0],l[1],l[2]);var s=e.anovafscore(l);for(t=l.length-1,i=0,a=0;a<l.length;a++)i+=l[a].length;return r=i-t-1,1-e.centralF.cdf(s,t,r)},ftest:function(t,n,o){return 1-e.centralF.cdf(t,n,o)}}),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 r,i,a,l,s,u=n.call(arguments);return o(u[0])?(r=u[0],i=u[1],a=u[2],l=u[3],s=u[4]):(r=e.mean(u[0]),i=e.mean(u[1]),a=u[0].length,l=u[1].length,s=u[2]),t.abs(r-i)/(s*t.sqrt((1/a+1/l)/2))},qtest:function(){var t,o=n.call(arguments);3===o.length?(t=o[0],o=o.slice(1)):7===o.length?(t=e.qscore(o[0],o[1],o[2],o[3],o[4]),o=o.slice(5)):(t=e.qscore(o[0],o[1],o[2]),o=o.slice(3));var r=o[0],i=o[1];return 1-e.tukey.cdf(t,i,r-i)},tukeyhsd:function(t){for(var n=e.pooledstdev(t),o=t.map((function(t){return e.mean(t)})),r=t.reduce((function(e,t){return e+t.length}),0),i=[],a=0;a<t.length;++a)for(var l=a+1;l<t.length;++l){var s=e.qtest(o[a],o[l],t[a].length,t[l].length,n,r,t.length);i.push([[a,l],s])}return i}}),e.extend({normalci:function(){var o,r=n.call(arguments),i=new Array(2);return o=4===r.length?t.abs(e.normal.inv(r[1]/2,0,1)*r[2]/t.sqrt(r[3])):t.abs(e.normal.inv(r[1]/2,0,1)*e.stdev(r[2])/t.sqrt(r[2].length)),i[0]=r[0]-o,i[1]=r[0]+o,i},tci:function(){var o,r=n.call(arguments),i=new Array(2);return o=4===r.length?t.abs(e.studentt.inv(r[1]/2,r[3]-1)*r[2]/t.sqrt(r[3])):t.abs(e.studentt.inv(r[1]/2,r[2].length-1)*e.stdev(r[2],!0)/t.sqrt(r[2].length)),i[0]=r[0]-o,i[1]=r[0]+o,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,o,r){var a=i(t,n,o,r);return e.ztest(a,1)},twoSidedDifferenceOfProportions:function(t,n,o,r){var a=i(t,n,o,r);return e.ztest(a,2)}})}(t,Math),t.models=function(){function e(e,n){var o=e.length,r=n[0].length-1,i=o-r-1,a=t.lstsq(n,e),l=t.multiply(n,a.map((function(e){return[e]}))).map((function(e){return e[0]})),s=t.subtract(e,l),u=t.mean(e),c=t.sum(l.map((function(e){return Math.pow(e-u,2)}))),d=t.sum(e.map((function(e,t){return Math.pow(e-l[t],2)}))),m=c+d;return{exog:n,endog:e,nobs:o,df_model:r,df_resid:i,coef:a,predict:l,resid:s,ybar:u,SST:m,SSE:c,SSR:d,R2:c/m}}function n(n){var o,r,i=(o=n.exog,r=o[0].length,t.arange(r).map((function(n){var i=t.arange(r).filter((function(e){return e!==n}));return e(t.col(o,n).map((function(e){return e[0]})),t.col(o,i))}))),a=Math.sqrt(n.SSR/n.df_resid),l=i.map((function(e){var t=e.SST,n=e.R2;return a/Math.sqrt(t*(1-n))})),s=n.coef.map((function(e,t){return(e-0)/l[t]})),u=s.map((function(e){var o=t.studentt.cdf(e,n.df_resid);return 2*(o>.5?1-o:o)})),c=t.studentt.inv(.975,n.df_resid),d=n.coef.map((function(e,t){var n=c*l[t];return[e-n,e+n]}));return{se:l,t:s,p:u,sigmaHat:a,interval95:d}}return{ols:function(o,r){var i=e(o,r),a=n(i),l=function(e){var n,o,r,i=e.R2/e.df_model/((1-e.R2)/e.df_resid);return{F_statistic:i,pvalue:1-(n=i,o=e.df_model,r=e.df_resid,t.beta.cdf(n/(r/o+n),o/2,r/2))}}(i),s=1-(1-i.R2)*((i.nobs-1)/i.df_resid);return i.t=a,i.f=l,i.adjust_R2=s,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),o=0;o<e.length;o++)n[o]=e[o];return t.builddxmatrix(n)},buildymatrix:function(e){return t(e).transpose()},buildjymatrix:function(e){return e.transpose()},matrixmult:function(e,n){var o,r,i,a,l;if(e.cols()==n.rows()){if(n.rows()>1){for(a=[],o=0;o<e.rows();o++)for(a[o]=[],r=0;r<n.cols();r++){for(l=0,i=0;i<e.cols();i++)l+=e.toArray()[o][i]*n.toArray()[i][r];a[o][r]=l}return t(a)}for(a=[],o=0;o<e.rows();o++)for(a[o]=[],r=0;r<n.cols();r++){for(l=0,i=0;i<e.cols();i++)l+=e.toArray()[o][i]*n.toArray()[r];a[o][r]=l}return t(a)}},regress:function(e,n){var o=t.xtranspxinv(e),r=e.transpose(),i=t.matrixmult(t(o),r);return t.matrixmult(i,n)},regresst:function(e,n,o){var r=t.regress(e,n),i={anova:{}},a=t.jMatYBar(e,r);i.yBar=a;var l=n.mean();i.anova.residuals=t.residuals(n,a),i.anova.ssr=t.ssr(a,l),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,l),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 s,u,c,d=t.xtranspxinv(e),m=0;m<r.length;m++)s=Math.sqrt(i.anova.mse*Math.abs(d[m][m])),u=Math.abs(r[m]/s),c=t.ttest(u,n.length-e[0].length-1,o),i.stats[m]=[r[m],s,u,c];return i.regress=r,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 o=t.matrixmult(e,n);return new t(o)},residuals:function(e,n){return t.matrixsubtract(e,n)},ssr:function(e,t){for(var n=0,o=0;o<e.length;o++)n+=Math.pow(e[o]-t,2);return n},sse:function(e,t){for(var n=0,o=0;o<e.length;o++)n+=Math.pow(e[o]-t[o],2);return n},sst:function(e,t){for(var n=0,o=0;o<e.length;o++)n+=Math.pow(e[o]-t,2);return n},matrixsubtract:function(e,n){for(var o=new Array(e.length),r=0;r<e.length;r++){o[r]=new Array(e[r].length);for(var i=0;i<e[r].length;i++)o[r][i]=e[r][i]-n[r][i]}return t(o)}}),t.jStat=t,t)},391:(e,t,n)=>{var o=n(180),r=n(181),i=n(31),a=n(67),l=n(833),s=n(717),u=n(801);u.alea=o,u.xor128=r,u.xorwow=i,u.xorshift7=a,u.xor4096=l,u.tychei=s,e.exports=u},180:function(e,t,n){var o;!function(e,r){function i(e){var t,n=this,o=(t=4022871197,function(e){e=String(e);for(var n=0;n<e.length;n++){var o=.02519603282416938*(t+=e.charCodeAt(n));o-=t=o>>>0,t=(o*=t)>>>0,t+=4294967296*(o-=t)}return 2.3283064365386963e-10*(t>>>0)});n.next=function(){var e=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=e-(n.c=0|e)},n.c=1,n.s0=o(" "),n.s1=o(" "),n.s2=o(" "),n.s0-=o(e),n.s0<0&&(n.s0+=1),n.s1-=o(e),n.s1<0&&(n.s1+=1),n.s2-=o(e),n.s2<0&&(n.s2+=1),o=null}function a(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function l(e,t){var n=new i(e),o=t&&t.state,r=n.next;return r.int32=function(){return 4294967296*n.next()|0},r.double=function(){return r()+11102230246251565e-32*(2097152*r()|0)},r.quick=r,o&&("object"==typeof o&&a(o,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=l:n.amdD&&n.amdO?void 0===(o=function(){return l}.call(t,n,t,r))||(r.exports=o):this.alea=l}(0,e=n.nmd(e),n.amdD)},717:function(e,t,n){var o;!function(e,r){function i(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,o=t.d,r=t.a;return e=e<<25^e>>>7^n,n=n-o|0,o=o<<24^o>>>8^r,r=r-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-o|0,t.d=o<<16^n>>>16^r,t.a=r-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var o=0;o<n.length+20;o++)t.b^=0|n.charCodeAt(o),t.next()}function a(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function l(e,t){var n=new i(e),o=t&&t.state,r=function(){return(n.next()>>>0)/4294967296};return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,o&&("object"==typeof o&&a(o,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=l:n.amdD&&n.amdO?void 0===(o=function(){return l}.call(t,n,t,r))||(r.exports=o):this.tychei=l}(0,e=n.nmd(e),n.amdD)},181:function(e,t,n){var o;!function(e,r){function i(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var o=0;o<n.length+64;o++)t.x^=0|n.charCodeAt(o),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function l(e,t){var n=new i(e),o=t&&t.state,r=function(){return(n.next()>>>0)/4294967296};return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,o&&("object"==typeof o&&a(o,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=l:n.amdD&&n.amdO?void 0===(o=function(){return l}.call(t,n,t,r))||(r.exports=o):this.xor128=l}(0,e=n.nmd(e),n.amdD)},833:function(e,t,n){var o;!function(e,r){function i(e){var t=this;t.next=function(){var e,n,o=t.w,r=t.X,i=t.i;return t.w=o=o+1640531527|0,n=r[i+34&127],e=r[i=i+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=r[i]=n^e,t.i=i,n+(o^o>>>16)|0},function(e,t){var n,o,r,i,a,l=[],s=128;for(t===(0|t)?(o=t,t=null):(t+="\0",o=0,s=Math.max(s,t.length)),r=0,i=-32;i<s;++i)t&&(o^=t.charCodeAt((i+32)%t.length)),0===i&&(a=o),o^=o<<10,o^=o>>>15,o^=o<<4,o^=o>>>13,i>=0&&(a=a+1640531527|0,r=0==(n=l[127&i]^=o+a)?r+1:0);for(r>=128&&(l[127&(t&&t.length||0)]=-1),r=127,i=512;i>0;--i)o=l[r+34&127],n=l[r=r+1&127],o^=o<<13,n^=n<<17,o^=o>>>15,n^=n>>>12,l[r]=o^n;e.w=a,e.X=l,e.i=r}(t,e)}function a(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function l(e,t){null==e&&(e=+new Date);var n=new i(e),o=t&&t.state,r=function(){return(n.next()>>>0)/4294967296};return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,o&&(o.X&&a(o,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=l:n.amdD&&n.amdO?void 0===(o=function(){return l}.call(t,n,t,r))||(r.exports=o):this.xor4096=l}(0,e=n.nmd(e),n.amdD)},67:function(e,t,n){var o;!function(e,r){function i(e){var t=this;t.next=function(){var e,n,o=t.x,r=t.i;return e=o[r],n=(e^=e>>>7)^e<<24,n^=(e=o[r+1&7])^e>>>10,n^=(e=o[r+3&7])^e>>>3,n^=(e=o[r+4&7])^e<<7,e=o[r+7&7],n^=(e^=e<<13)^e<<9,o[r]=n,t.i=r+1&7,n},function(e,t){var n,o=[];if(t===(0|t))o[0]=t;else for(t=""+t,n=0;n<t.length;++n)o[7&n]=o[7&n]<<15^t.charCodeAt(n)+o[n+1&7]<<13;for(;o.length<8;)o.push(0);for(n=0;n<8&&0===o[n];++n);for(8==n?o[7]=-1:o[n],e.x=o,e.i=0,n=256;n>0;--n)e.next()}(t,e)}function a(e,t){return t.x=e.x.slice(),t.i=e.i,t}function l(e,t){null==e&&(e=+new Date);var n=new i(e),o=t&&t.state,r=function(){return(n.next()>>>0)/4294967296};return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,o&&(o.x&&a(o,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=l:n.amdD&&n.amdO?void 0===(o=function(){return l}.call(t,n,t,r))||(r.exports=o):this.xorshift7=l}(0,e=n.nmd(e),n.amdD)},31:function(e,t,n){var o;!function(e,r){function i(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var o=0;o<n.length+64;o++)t.x^=0|n.charCodeAt(o),o==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function l(e,t){var n=new i(e),o=t&&t.state,r=function(){return(n.next()>>>0)/4294967296};return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,o&&("object"==typeof o&&a(o,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=l:n.amdD&&n.amdO?void 0===(o=function(){return l}.call(t,n,t,r))||(r.exports=o):this.xorwow=l}(0,e=n.nmd(e),n.amdD)},801:function(e,t,n){var o;!function(r,i,a){var l,s=256,u=a.pow(s,6),c=a.pow(2,52),d=2*c,m=s-1;function f(e,t,n){var o=[],m=v(g((t=1==t?{entropy:!0}:t||{}).entropy?[e,C(i)]:null==e?function(){try{var e;return l&&(e=l.randomBytes)?e=e(s):(e=new Uint8Array(s),(r.crypto||r.msCrypto).getRandomValues(e)),C(e)}catch(e){var t=r.navigator,n=t&&t.plugins;return[+new Date,r,n,r.screen,C(i)]}}():e,3),o),f=new h(o),w=function(){for(var e=f.g(6),t=u,n=0;e<c;)e=(e+n)*s,t*=s,n=f.g(1);for(;e>=d;)e/=2,t/=2,n>>>=1;return(e+n)/t};return w.int32=function(){return 0|f.g(4)},w.quick=function(){return f.g(4)/4294967296},w.double=w,v(C(f.S),i),(t.pass||n||function(e,t,n,o){return o&&(o.S&&p(o,f),e.state=function(){return p(f,{})}),n?(a.random=e,t):e})(w,m,"global"in t?t.global:this==a,t.state)}function h(e){var t,n=e.length,o=this,r=0,i=o.i=o.j=0,a=o.S=[];for(n||(e=[n++]);r<s;)a[r]=r++;for(r=0;r<s;r++)a[r]=a[i=m&i+e[r%n]+(t=a[r])],a[i]=t;(o.g=function(e){for(var t,n=0,r=o.i,i=o.j,a=o.S;e--;)t=a[r=m&r+1],n=n*s+a[m&(a[r]=a[i=m&i+t])+(a[i]=t)];return o.i=r,o.j=i,n})(s)}function p(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function g(e,t){var n,o=[],r=typeof e;if(t&&"object"==r)for(n in e)try{o.push(g(e[n],t-1))}catch(e){}return o.length?o:"string"==r?e:e+"\0"}function v(e,t){for(var n,o=e+"",r=0;r<o.length;)t[m&r]=m&(n^=19*t[m&r])+o.charCodeAt(r++);return C(t)}function C(e){return String.fromCharCode.apply(0,e)}if(v(a.random(),i),e.exports){e.exports=f;try{l=n(234)}catch(e){}}else void 0===(o=function(){return f}.call(t,n,t,e))||(e.exports=o)}("undefined"!=typeof self?self:this,[],Math)},95:(e,t,n)=>{"use strict";n.d(t,{h:()=>o});class o{}o.TAG_FIT_CHART_FORMAT=".fitChartFormat",o.TAG_FIT_CHART_FORMAT_3DX="3dx",o.FIT_SEM_TYPE="fit",o.FIT_CELL_TYPE="fit",o.TAG_FIT=".fit",o.CELL_DEFAULT_WIDTH=230,o.CELL_DEFAULT_HEIGHT=160,o.MIN_CELL_RENDERER_PX_WIDTH=10,o.MIN_CELL_RENDERER_PX_HEIGHT=5,o.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH=70,o.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT=45,o.MIN_AXES_CELL_PX_WIDTH=100,o.MIN_AXES_CELL_PX_HEIGHT=55,o.MIN_TITLE_PX_WIDTH=275,o.MIN_TITLE_PX_HEIGHT=225,o.MIN_X_AXIS_NAME_VISIBILITY_PX_WIDTH=180,o.MIN_Y_AXIS_NAME_VISIBILITY_PX_HEIGHT=140,o.MIN_LEGEND_PX_WIDTH=325,o.MIN_LEGEND_PX_HEIGHT=275,o.MIN_DROPLINES_VISIBILITY_PX_WIDTH=120,o.MIN_DROPLINES_VISIBILITY_PX_HEIGHT=110,o.AXES_LEFT_PX_MARGIN=38,o.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS=45,o.AXES_TOP_PX_MARGIN=5,o.AXES_TOP_PX_MARGIN_WITH_TITLE=25,o.AXES_RIGHT_PX_MARGIN=18,o.AXES_BOTTOM_PX_MARGIN=15,o.AXES_BOTTOM_PX_MARGIN_WITH_AXES_LABELS=30,o.X_AXIS_LABEL_BOTTOM_PX_MARGIN=4,o.LEGEND_TOP_PX_MARGIN=10,o.OUTLIER_PX_SIZE=12,o.POINT_PX_SIZE=4,o.OUTLIER_HITBOX_RADIUS=2,o.CANDLESTICK_BORDER_PX_SIZE=4,o.CANDLESTICK_MEDIAN_PX_SIZE=3.5,o.CANDLESTICK_OUTLIER_PX_SIZE=6,o.INFLATE_SIZE=-6,o.MIN_INFLATE_SIZE=-2,o.LEGEND_RECORD_PX_HEIGHT=18,o.LEGEND_RECORD_LINE_PX_WIDTH=20,o.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN=5,o.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN=4,o.LINE_STYLES={solid:[],dotted:[1,1],dashed:[5,5],dashdotted:[5,5,2,5]},o.CURVE_CONFIDENCE_INTERVAL_BOUNDS={TOP:"top",BOTTOM:"bottom"},o.CONFIDENCE_INTERVAL_STROKE_COLOR="rgba(255,191,63,0.4)",o.CONFIDENCE_INTERVAL_FILL_COLOR="rgba(255,238,204,0.3)",o.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))}))}},471:(e,t,n)=>{"use strict";n.d(t,{Z1:()=>a}),n(82);var o=n(328),r=n(48),i=(n(71),n(991),n(95),function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function l(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}s((o=o.apply(e,t||[])).next())}))});function a(){return i(this,void 0,void 0,(function*(){o.shell.windows.showContextPanel=!0;const e=yield o.data.loadTable(`${r._package.webRoot}files/curves-demo.csv`);o.shell.addTableView(e)}))}},667:(e,t,n)=>{"use strict";n.d(t,{JR:()=>v,VK:()=>g,e4:()=>T});var o=n(82),r=n(389),i=n(999),a=n(71),l=n(407),s=n(283),u=n(95),c=n(672),d=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function l(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}s((o=o.apply(e,t||[])).next())}))};const m="chartOptions",f="seriesOptions";var h;!function(e){e.DATAFRAME="Dataframe",e.COLUMN="Column",e.CELL="Cell"}(h||(h={}));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,n,o){const r=(0,i.zB)(e);if(e.parameters)n.logX&&e.parameters[2]>0&&(e.parameters[2]=Math.log10(e.parameters[2]));else{const i=(0,l.IY)(e,t,r,n,o).parameters;e.parameters=[...i]}const s=(0,i.VA)(e,r,(0,l.Xm)(e,t,n,!1,o),n);return[a.kC,a.G7].includes(r.name)&&n.logX&&void 0!==s.interceptX&&s.interceptX<0&&(s.interceptX=Math.pow(10,s.interceptX)),s}function v(e,t,n){var r,i,a;const l={logX:null===(r=e.chartOptions)||void 0===r?void 0:r.logX,logY:null===(i=e.chartOptions)||void 0===i?void 0:i.logY},s=[],u=[],c=[],d=[],m=[],f=[],h=[];for(let t=0,o=0;t<(null===(a=e.series)||void 0===a?void 0:a.length);t++){if(e.series[t].points.every((e=>e.outlier)))continue;const r=g(e.series[t],t,l,n);s[o]=r.rSquared,u[o]=r.auc,c[o]=r.interceptX,d[o]=r.interceptY,m[o]=r.slope,f[o]=r.top,h[o]=r.bottom,o++}return{rSquared:s.some((e=>null==e))?void 0:o.Stats.fromValues(s)[p[t]],auc:u.some((e=>null==e))?void 0:o.Stats.fromValues(u)[p[t]],interceptX:c.some((e=>null==e))?void 0:o.Stats.fromValues(c)[p[t]],interceptY:d.some((e=>null==e))?void 0:o.Stats.fromValues(d)[p[t]],slope:m.some((e=>null==e))?void 0:o.Stats.fromValues(m)[p[t]],top:f.some((e=>null==e))?void 0:o.Stats.fromValues(f)[p[t]],bottom:h.some((e=>null==e))?void 0:o.Stats.fromValues(h)[p[t]]}}function C(e){for(let t=0;t<e.length;t++){const n=e.get(t);if(""===n)continue;const o=(0,s.K)(n);e.set(t,JSON.stringify(o))}e.setTag(u.h.TAG_FIT_CHART_FORMAT,"")}function w(e,t,n,o){var r;void 0===e.cell.column.temp[`${m}-custom-title`]&&function(e){var t,n;const o=e.columns.bySemTypeAll(u.h.FIT_SEM_TYPE);for(let e=0;e<o.length;e++){a.xs.map((t=>{o[e].temp[`${m}-custom-${t.name}`]=!1})),a.IL.map((t=>{o[e].temp[`${f}-custom-${t.name}`]=!1})),o[e].getTag(u.h.TAG_FIT_CHART_FORMAT)===u.h.TAG_FIT_CHART_FORMAT_3DX&&C(o[e]);for(let r=0;r<o[e].length;r++){if(""===o[e].get(r))continue;const i=null!==(n=JSON.parse(null!==(t=o[e].get(r))&&void 0!==t?t:"{}"))&&void 0!==n?n:{};a.xs.map((t=>{i.chartOptions&&void 0!==i.chartOptions[t.name]&&(o[e].temp[`${m}-custom-${t.name}`]=!0)})),a.IL.map((t=>{if(i.series)for(const n of i.series)void 0!==n[t.name]&&(o[e].temp[`${f}-custom-${t.name}`]=!0)}))}}}(e.cell.dataFrame);const i=t.property.name,s=o===h.DATAFRAME?(0,l.Ig)(e.cell.dataFrame):(0,l.bc)(e.cell.column);if(n===m?s.chartOptions[i]=t.value:n===f&&(s.seriesOptions[i]=t.value),o===h.CELL){const o=e.cell.value;if(""===o)return;const i=null!==(r=JSON.parse(null!=o?o:"{}"))&&void 0!==r?r:{};!function(e,t,n){const o=t.property.name;if(n===m){if(void 0===e.chartOptions)return;e.chartOptions[o]=t.value}else if(n===f){if(void 0===e.series)return;for(let n=0;n<e.series.length;n++)e.series[n][o]=t.value}}(i,t,n),e.cell.value=JSON.stringify(i)}else{let t;o===h.DATAFRAME?(e.cell.dataFrame.tags[u.h.TAG_FIT]=JSON.stringify(s),t=e.cell.dataFrame.columns.bySemTypeAll(u.h.FIT_SEM_TYPE)):(e.cell.column.tags[u.h.TAG_FIT]=JSON.stringify(s),t=[e.cell.column]);for(let e=0;e<t.length;e++){if(o===h.DATAFRAME){const o=(0,l.bc)(t[e]);n===m?delete o.chartOptions[i]:delete o.seriesOptions[i],t[e].tags[u.h.TAG_FIT]=JSON.stringify(o)}!1!==t[e].temp[`${n}-custom-${i}`]&&(t[e].init((o=>{var r,a;const l=t[e].get(o);if(""===l)return l;const s=null!==(a=JSON.parse(null!==(r=t[e].get(o))&&void 0!==r?r:"{}"))&&void 0!==a?a:{};if(n===m){if(void 0===s.chartOptions)return l;if(void 0===s.chartOptions[i])return l;delete s.chartOptions[i]}else{if(void 0===s.series)return l;let e=!1;for(const t of s.series)void 0!==t[i]&&(delete t[i],e=!0);if(s.seriesOptions&&delete s.seriesOptions[i],!e)return l}return JSON.stringify(s)})),t[e].temp[`${n}-custom-${i}`]=!1)}}e.grid.invalidate()}class T extends o.ObjectHandler{get type(){return"GridCell"}isApplicable(e){return e instanceof o.GridCell&&e.cellType===u.h.FIT_CELL_TYPE}renderProperties(e,t=null){var n,s,h,p,C,T,_;const x=r.accordion("Curves property panel"),y=o.Property.js("level",o.TYPE.STRING,{description:"Controls the level at which properties will be switched",defaultValue:"Column",choices:["Dataframe","Column","Cell"],nullable:!1}),I=r.input.forProperty(y);r.tooltip.bind(I.captionLabel,"Controls the level at which properties will be switched");const E=(0,l.h8)(e),A=(0,l.bc)(e.cell.column),N=(0,l.Ig)(e.cell.dataFrame),b={onValueChanged:(t,n)=>w(e,n,f,I.value)},O={onValueChanged:(t,n)=>w(e,n,m,I.value)},S=e=>{N.seriesOptions&&!(0,l.Yc)(N.seriesOptions[e])&&A.seriesOptions&&!(0,l.Yc)(A.seriesOptions[e])&&(E.seriesOptions?(0,l.Yc)(E.seriesOptions[e])||(E.seriesOptions[e]=o.Color.toHtml("outlierColor"===e?o.Color.red:o.Color.getCategoricalColor(0))):(0,l.Yc)(E.series?E.series[0][e]:"")||(E.series[0][e]=o.Color.toHtml("outlierColor"===e?o.Color.red:o.Color.getCategoricalColor(0))))};S("pointColor"),S("fitLineColor"),S("outlierColor"),(0,l.g2)(a.IL,A.seriesOptions,E.seriesOptions?E.seriesOptions:E.series&&null!==(n=E.series[0])&&void 0!==n?n:{}),(0,l.g2)(a.IL,N.seriesOptions,E.seriesOptions?E.seriesOptions:E.series&&null!==(s=E.series[0])&&void 0!==s?s:{}),(0,l.g2)(a.xs,A.chartOptions,E.chartOptions?E.chartOptions:{}),(0,l.g2)(a.xs,N.chartOptions,E.chartOptions?E.chartOptions:{}),(null===(h=E.chartOptions)||void 0===h?void 0:h.allowXZeroes)&&(null===(p=E.chartOptions)||void 0===p?void 0:p.logX)&&(null===(C=E.series)||void 0===C?void 0:C.some((e=>e.points.some((e=>0===e.x)))))&&(0,l.B3)(E);const P=r.form([I]),L=a.IL.map((e=>r.input.forProperty(e,E.seriesOptions?E.seriesOptions:E.series[0],b)));r.forms.addGroup(P,"Series options",L),r.forms.addGroup(P,"Chart options",a.xs.map((e=>r.input.forProperty(e,E.chartOptions,O)))),x.addPane("Options",(()=>P));const R=(null!==(_=null===(T=E.series)||void 0===T?void 0:T.length)&&void 0!==_?_:0)>1?["all","aggregated"]:["all"],M=o.Property.js("series",o.TYPE.STRING,{description:"Controls whether to show series statistics or aggregated statistics",defaultValue:"all",choices:R,nullable:!1}),X=r.input.forProperty(M,null,{onValueChanged:()=>{x.getPane("Fit").root.lastElementChild.replaceChildren(G())}}),F=o.Property.js("aggregation type",o.TYPE.STRING,{description:"Controls which aggregation to use on the series statistics",defaultValue:"med",choices:Object.values(o.STATS),nullable:!1}),D=r.input.forProperty(F,null,{onValueChanged:()=>{x.getPane("Fit").root.lastElementChild.replaceChildren(G())}});function G(){var t,n,l,s,u;const m=(null!==(n=null===(t=E.series)||void 0===t?void 0:t.length)&&void 0!==n?n:0)>1?"aggregated"===X.stringValue?[X.root,D.root]:[X.root]:null,f=r.divV(m),h=(0,i.s$)(E);if(h.x<=0&&E.chartOptions&&(E.chartOptions.logX=!1),h.y<=0&&E.chartOptions&&(E.chartOptions.logY=!1),"all"===X.stringValue){const t={logX:null===(l=E.chartOptions)||void 0===l?void 0:l.logX,logY:null===(s=E.chartOptions)||void 0===s?void 0:s.logY};for(let n=0;n<E.series.length;n++){const i=E.series[n],l=g(i,n,t,e),s=(0,c.Z)(i,n,c.mE.FIT_LINE),m=null!==(u=i.name)&&void 0!==u?u:"series "+n;f.appendChild(r.panel([r.h1(m,{style:{color:s}}),r.input.form(l,a.nK,{onCreated:t=>t.root.appendChild(r.iconFA("plus",(()=>d(this,void 0,void 0,(function*(){const r={df:e.cell.dataFrame,colName:e.gridColumn.name,propName:t.property.name,seriesName:m,seriesNumber:n};yield o.Func.find({name:"addStatisticsColumn"})[0].prepare(r).call(void 0,void 0,{processed:!1})}))),`Calculate ${t.property.name} for the whole column`))})]))}}else{const t=v(E,D.stringValue,e);f.appendChild(r.panel([r.h1(`series ${D.stringValue}`),r.input.form(t,a.nK,{onCreated:t=>t.root.appendChild(r.iconFA("plus",(()=>d(this,void 0,void 0,(function*(){const n={df:e.cell.dataFrame,colName:e.gridColumn.name,propName:t.property.name,aggrType:D.stringValue};yield o.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 f}const Y=x.addPane("Chart",(()=>o.GridCellWidget.fromGridCell(e).root)),H=l.lR.inflateScreenBounds(e.bounds);return(H.width<u.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||H.height<u.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT)&&(Y.expanded=!0),x.addPane("Fit",(()=>G())),x.root}}},283:(e,t,n)=>{"use strict";n.d(t,{K:()=>u});var o=n(82),r=n(71);const i={x:"xAxis",y:"yAxis"},a={min:"min",max:"max"};function l(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 l=null===(i=e.getElementsByTagName("function")[0])||void 0===i?void 0:i.getAttribute("type");l=l&&"sigif"!==l?l:r.G7;const s=e.getElementsByTagName("settings")[0].getAttribute("markerColor"),u=e.getElementsByTagName("settings")[0].getAttribute("color"),c=!!e.getElementsByTagName("settings")[0].getAttribute("drawLine"),d={name:e.getAttribute("name"),fitFunction:l,markerType:o.MARKER_TYPE.CIRCLE,pointColor:s,fitLineColor:u,showFitLine:c,showPoints:"points",showCurveConfidenceInterval:!1,clickToToggle:!1};return a&&(d.parameters=[a[2],a[1],a[0],a[3]]),d}function s(e){const t=function(e){var t,n,o;const r=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===(o=e.getElementsByTagName("mask")[0].childNodes[0].nodeValue)||void 0===o?void 0:o.split(""),l=[];for(let e=0;e<r.length;e++)l[e]={x:+r[e],y:+i[e],outlier:!Boolean(a[e])};return l}(e),n=l(e),o={points:t};return Object.assign(o,n),o}function u(e){const t=(new DOMParser).parseFromString(e,"text/xml"),n=t.getElementsByTagName("grid")[0],o=(u=t.getElementsByTagName("settings")[0],{minX:+(r=n).getElementsByTagName(i.x)[0].getAttribute(a.min),minY:+r.getElementsByTagName(i.y)[0].getAttribute(a.min),maxX:+r.getElementsByTagName(i.x)[0].getAttribute(a.max),maxY:+r.getElementsByTagName(i.y)[0].getAttribute(a.max),xAxisName:u.getAttribute("xLabel"),yAxisName:u.getAttribute("yLabel"),logX:!!u.getAttribute("logX")});var r,u;const c=t.getElementsByTagName("seriesCollection")[0],d=l(c.getElementsByTagName("series")[0]),m=function(e){const t=[],n=e.getElementsByTagName("series").length;for(let o=0;o<n;o++){const n=e.getElementsByTagName("series")[o];t[o]=s(n)}return t}(c);return{chartOptions:o,seriesOptions:d,series:m}}},407:(e,t,n)=>{"use strict";n.d(t,{B3:()=>N,Fw:()=>b,I4:()=>O,IY:()=>_,Ig:()=>y,LX:()=>v,Xm:()=>x,Yc:()=>A,bc:()=>I,g2:()=>g,h8:()=>w,lR:()=>S,wU:()=>C});var o,r=n(82),i=n(328),a=n(389),l=n(71),s=n(293),u=n(999),c=n(283),d=n(667),m=n(95),f=n(672),h=n(858);function p(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),Math.min(Math.max(n,0),30)))}function g(e,t,n){if(t&&n)for(const o of e)!(o.name in n)&&o.name in t&&(n[o.name]=t[o.name])}function v(e){if(0===e.length)return{};let t,n,o,r=Number.MAX_VALUE,i=Number.MAX_VALUE,a=Number.MIN_VALUE,l=Number.MIN_VALUE,s=!1,u=!1,c=!1;for(const d of e)null!==d.minX&&void 0!==d.minX&&(r=Math.min(r,d.minX)),null!==d.minY&&void 0!==d.minY&&(i=Math.min(i,d.minY)),null!==d.maxX&&void 0!==d.maxX&&(a=Math.max(a,d.maxX)),null!==d.maxY&&void 0!==d.maxY&&(l=Math.max(l,d.maxY)),null!==d.title&&void 0!==d.title&&(null!=o||(o=d.title)),null!==d.xAxisName&&void 0!==d.xAxisName&&(null!=t||(t=d.xAxisName)),null!==d.yAxisName&&void 0!==d.yAxisName&&(null!=n||(n=d.yAxisName)),null!==d.logX&&void 0!==d.logX&&d.logX&&(s=!0),null!==d.logY&&void 0!==d.logY&&d.logY&&(u=!0),null!==d.allowXZeroes&&void 0!==d.allowXZeroes&&d.allowXZeroes&&(c=!0);return{minX:r===Number.MAX_VALUE?void 0:r,minY:i===Number.MAX_VALUE?void 0:i,maxX:a===Number.MIN_VALUE?void 0:a,maxY:l===Number.MIN_VALUE?void 0:l,title:o,xAxisName:t,yAxisName:n,logX:s,logY:u,allowXZeroes:c}}function C(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 w(e,t=!0){var n;const o=null===(n=null==e?void 0:e.cell)||void 0===n?void 0:n.column;return t&&o&&(null==e?void 0:e.cell)?S.parsedCurves.getOrCreate(`tableId: ${o.dataFrame.id} || tableName: ${o.dataFrame.name} || colName: ${o.name} || colVersion: ${o.version} || rowIdx: ${null==e?void 0:e.tableRowIndex}`,(()=>T(e))):T(e)}function T(e){var t,n,o,i;let a=e.cell.value;a.includes("|")&&(a=a.replaceAll("|",""));const s=e.cell.column,d=s?s.type===r.TYPE.STRING?s.getTag(m.h.TAG_FIT_CHART_FORMAT)===m.h.TAG_FIT_CHART_FORMAT_3DX?(0,c.K)(a):null!==(t=JSON.parse(null!=a?a:"{}"))&&void 0!==t?t:{}:(0,u.Kh)():null!==(n=JSON.parse(null!=a?a:"{}"))&&void 0!==n?n:{},f=e.cell.column?I(e.cell.column):{},h=e.cell.column?y(e.cell.dataFrame):{};null!==(o=d.series)&&void 0!==o||(d.series=[]),null!==(i=d.chartOptions)&&void 0!==i||(d.chartOptions=f.chartOptions),g(l.xs,f.chartOptions,d.chartOptions),g(l.xs,h.chartOptions,d.chartOptions);for(const e of d.series)g(l.IL,d.seriesOptions,e),g(l.IL,f.seriesOptions,e),g(l.IL,h.seriesOptions,e);return d}function _(e,t,n,o,r,i=!0){var a;const l=x(e,t,o,!1,r,i),s=null===(a=null==r?void 0:r.cell)||void 0===a?void 0:a.column;return i&&s&&(null==r?void 0:r.cell)?S.fittedCurves.getOrCreate(`tableId: ${s.dataFrame.id} || tableName: ${s.dataFrame.name} || colName: ${s.name} || colVersion: ${s.version} || rowIdx: ${null==r?void 0:r.tableRowIndex}`,(()=>(0,u.nT)(e,n,l,o))):(0,u.nT)(e,n,l,o)}function x(e,t,n,o,r,i=!0){var a;const l=null===(a=null==r?void 0:r.cell)||void 0===a?void 0:a.column;return i&&l&&(null==r?void 0:r.cell)?S.curvesDataPoints.getOrCreate(`tableId: ${l.dataFrame.id} || tableName: ${l.dataFrame.name} || colName: ${l.name} || colVersion: ${l.version} || rowIdx: ${null==r?void 0:r.tableRowIndex} || idx: ${t} || userParamsFlag: ${o}`,(()=>(0,u.Sm)(e,n,o))):(0,u.Sm)(e,n,o)}function y(e){var t,n,o;return JSON.parse(null!==(t=(n=e.tags)[o=m.h.TAG_FIT])&&void 0!==t?t:n[o]=JSON.stringify((0,u.Kh)()))}function I(e){var t,n,o;return JSON.parse(null!==(t=(n=e.tags)[o=m.h.TAG_FIT])&&void 0!==t?t:n[o]=JSON.stringify((0,u.Kh)()))}function E(e,t,n){if(e.width<m.h.MIN_AXES_CELL_PX_WIDTH||e.height<m.h.MIN_AXES_CELL_PX_HEIGHT)return[e,void 0,void 0];const o=t?m.h.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:m.h.AXES_LEFT_PX_MARGIN,r=t?m.h.AXES_BOTTOM_PX_MARGIN_WITH_AXES_LABELS:m.h.AXES_BOTTOM_PX_MARGIN,i=n?m.h.AXES_TOP_PX_MARGIN_WITH_TITLE:m.h.AXES_TOP_PX_MARGIN;return[e.cutLeft(o).cutBottom(r).cutTop(i).cutRight(m.h.AXES_RIGHT_PX_MARGIN),e.getBottom(r).getTop(i).cutLeft(o).cutRight(m.h.AXES_RIGHT_PX_MARGIN),e.getLeft(o).getRight(m.h.AXES_RIGHT_PX_MARGIN).cutBottom(r).cutTop(i)]}function A(e){return null!=e&&""!==e&&void 0!==r.Color.fromHtml(e)}function N(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 o=Number.MAX_VALUE,r=0,i=0;const a=[];for(let e=0;e<t.points.length;e++)t.points[e].x<o&&0!==t.points[e].x&&(o=t.points[e].x),t.points[e].x>r&&0!==t.points[e].x&&(r=t.points[e].x),a.includes(t.points[e].x)||(a[a.length]=t.points[e].x,i++);const l=Math.pow(10,Math.log10(o)-(Math.log10(r)-Math.log10(o)/(i-1)));for(let e=0;e<t.points.length;e++)0===t.points[e].x&&(t.points[e].x=l)}}function b(e,t,n,o,r){var a,l;if(null!=r||(r=e.cell.column.getTag(m.h.TAG_FIT_CHART_FORMAT)===m.h.TAG_FIT_CHART_FORMAT_3DX?(0,c.K)(e.cell.value):w(e)),t.outlier=!t.outlier,e.cell.column.getTag(m.h.TAG_FIT_CHART_FORMAT)!==m.h.TAG_FIT_CHART_FORMAT_3DX){const r=JSON.parse(e.cell.value);r.series[n].points[o].outlier=t.outlier,e.cell.column.set(e.cell.rowIndex,JSON.stringify(r),!1),i.events.fireCustomEvent("fit-cell-outlier-toggle",{gridCell:e,series:r.series[n],seriesIdx:n,pointIdx:o});const a=e.grid.canvas.getContext("2d");e.render({context:a,bounds:e.bounds})}const s=e.grid.dataFrame.columns.byTags({".sourceColumn":e.cell.column.name});if(s)for(const t of s){const o={logX:null===(a=r.chartOptions)||void 0===a?void 0:a.logX,logY:null===(l=r.chartOptions)||void 0===l?void 0:l.logY},i=null!==t.tags[".seriesAggregation"]?(0,d.JR)(r,t.tags[".seriesAggregation"],e):t.tags[".seriesNumber"]===n?(0,d.VK)(r.series[n],n,o,e):null;null!==i&&t.set(e.cell.rowIndex,i[t.tags[".statistics"]])}}function O(e,t,n=!1){var o,i;if(!e.cell.value)return;const l=r.GridCellWidget.fromGridCell(e);l.root.style.removeProperty("aspectRatio"),l.root.style.height="100%",l.canvas.style.removeProperty("height"),l.canvas.style.removeProperty("width"),l.canvas.style.left="18px",l.canvas.style.top="18px";const s=a.dialog({title:"Edit chart"}).add(l.root).show({resizable:!0,width:null!==(o=null==t?void 0:t.width)&&void 0!==o?o:350,height:null!==(i=null==t?void 0:t.height)&&void 0!==i?i:300});n&&s.sub((0,h.merge)(e.grid.dataFrame.onDataChanged,e.grid.dataFrame.onMetadataChanged).subscribe((()=>l.render())))}let S=o=class extends r.GridCellRenderer{get name(){return m.h.FIT_CELL_TYPE}get cellType(){return m.h.FIT_CELL_TYPE}get defaultHeight(){return m.h.CELL_DEFAULT_HEIGHT}get defaultWidth(){return m.h.CELL_DEFAULT_WIDTH}getDefaultSize(e){return{width:m.h.CELL_DEFAULT_WIDTH,height:m.h.CELL_DEFAULT_HEIGHT}}static inflateScreenBounds(e){return e.inflate(e.width<m.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH?m.h.MIN_INFLATE_SIZE:m.h.INFLATE_SIZE,e.height<m.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT?m.h.MIN_INFLATE_SIZE:m.h.INFLATE_SIZE)}onClick(e,t){var n,r,l,d,f;if(!e.cell.value)return;const h=e.cell.column.getTag(m.h.TAG_FIT_CHART_FORMAT)===m.h.TAG_FIT_CHART_FORMAT_3DX?(0,c.K)(e.cell.value):w(e);for(const[e,t]of Object.entries(m.h.CONDITION_MAP))if(t(h.series))return void(i.shell.o=a.divText(e,{style:{color:"red"}}));i.shell.o=e;const p=o.inflateScreenBounds(e.bounds),g=E(p,this.areAxesLabelsShown(p,h),this.isTitleShown(p,h))[0],v=(0,u.s$)(h),C=new s.L(v,g,null!==(r=null===(n=h.chartOptions)||void 0===n?void 0:n.logX)&&void 0!==r&&r,null!==(d=null===(l=h.chartOptions)||void 0===l?void 0:l.logY)&&void 0!==d&&d);for(let n=0;n<(null===(f=h.series)||void 0===f?void 0:f.length);n++)if(!(h.series[n].connectDots||!h.series[n].clickToToggle||"points"!==h.series[n].showPoints||p.width<m.h.MIN_AXES_CELL_PX_WIDTH||p.height<m.h.MIN_AXES_CELL_PX_HEIGHT))for(let o=0;o<h.series[n].points.length;o++){const r=h.series[n].points[o];if(this.hitTest(t,r,C))return void b(e,r,n,o,h)}}onDoubleClick(e,t){O(e)}areAxesShown(e){return e.width>=m.h.MIN_AXES_CELL_PX_WIDTH&&e.height>=m.h.MIN_AXES_CELL_PX_HEIGHT}areAxesLabelsShown(e,t){var n;return e.width>=m.h.MIN_X_AXIS_NAME_VISIBILITY_PX_WIDTH&&e.height>=m.h.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>=m.h.MIN_TITLE_PX_WIDTH&&e.height>=m.h.MIN_TITLE_PX_HEIGHT&&!!(null===(n=t.chartOptions)||void 0===n?void 0:n.title)}isLegendShown(e){return e.width>=m.h.MIN_LEGEND_PX_WIDTH&&e.height>=m.h.MIN_LEGEND_PX_HEIGHT}areDroplinesShown(e){return e.width>=m.h.MIN_DROPLINES_VISIBILITY_PX_WIDTH&&e.height>=m.h.MIN_DROPLINES_VISIBILITY_PX_HEIGHT}renderCurves(e,t,n,o){var r,i,a,l,c,d,m,h,p,g,v,C,w,T,y,I;e.save(),e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.clip();const A=(null==o?void 0:o.grid)&&(null==o?void 0:o.grid.dart)&&e.canvas===(null===(r=null==o?void 0:o.grid)||void 0===r?void 0:r.canvas);(null===(i=n.chartOptions)||void 0===i?void 0:i.allowXZeroes)&&(null===(a=n.chartOptions)||void 0===a?void 0:a.logX)&&(null===(l=n.series)||void 0===l?void 0:l.some((e=>e.points.some((e=>0===e.x)))))&&N(n);const[b,O,S]=E(t,this.areAxesLabelsShown(t,n),this.isTitleShown(t,n)),P=(0,u.s$)(n);(P.x<0&&n.chartOptions||0===P.x&&n.chartOptions&&!n.chartOptions.allowXZeroes)&&(n.chartOptions.logX=!1),P.y<=0&&n.chartOptions&&(n.chartOptions.logY=!1);const L=new s.L(P,b,null!==(d=null===(c=n.chartOptions)||void 0===c?void 0:c.logX)&&void 0!==d&&d,null!==(h=null===(m=n.chartOptions)||void 0===m?void 0:m.logY)&&void 0!==h&&h),R=Math.min(b.width,b.height),M=R>100?1:.2+R/100*.8,X={logX:null===(p=n.chartOptions)||void 0===p?void 0:p.logX,logY:null===(g=n.chartOptions)||void 0===g?void 0:g.logY};e.save(),e.font='11px Roboto, "Roboto Local"',L.drawCoordinateGrid(e,O,S),e.restore();for(let r=0;r<(null===(v=n.series)||void 0===v?void 0:v.length);r++){const i=n.series[r],a=i.parameters&&i.parameters.length>0;if(i.points.some((e=>void 0===e.x||void 0===e.y)))continue;i.points.sort(((e,t)=>e.x-t.x));let l=!0;const s=(0,u.zB)(i);let c=null;if(!i.connectDots||i.showFitLine)if(i.parameters)(null===(C=n.chartOptions)||void 0===C?void 0:C.logX)&&i.parameters[2]>0&&(i.parameters[2]=Math.log10(i.parameters[2])),c=(0,u._T)(i,s);else{const e=_(i,r,s,X,o,A);c=e.fittedCurve;const t=[...e.parameters];i.parameters=t,l=!1}(0,f.qR)(e,i,{viewport:L,ratio:M,logOptions:X,showAxes:this.areAxesShown(t),showAxesLabels:this.areAxesLabelsShown(t,n),screenBounds:t,curveFunc:c,seriesIdx:r}),(0,f.nx)(e,i,{viewport:L,ratio:M,seriesIdx:r}),(0,f.QW)(e,i,{viewport:L,ratio:M,screenBounds:t,seriesIdx:r}),(0,f.Zk)(e,i,{viewport:L,logOptions:X,showAxes:this.areAxesShown(t),showAxesLabels:this.areAxesLabelsShown(t,n),screenBounds:t,fitFunc:s,userParamsFlag:l,dataPoints:x(i,r,X,l,o,A)}),i.parameters&&(0,f.HQ)(e,i,{viewport:L,ratio:M,showDroplines:this.areDroplinesShown(t),xValue:i.parameters[2],dataBounds:P,curveFunc:c,logOptions:X}),(0,f.yv)(e,i,{statistics:null===(w=n.chartOptions)||void 0===w?void 0:w.showStatistics,fitFunc:s,logOptions:X,dataBox:b,screenBounds:t,seriesIdx:r}),a||delete i.parameters}(0,f.zF)(e,{showTitle:this.isTitleShown(t,n),title:null===(T=n.chartOptions)||void 0===T?void 0:T.title,dataBox:b,screenBounds:t}),(0,f.jI)(e,{showTitle:this.isTitleShown(t,n),dataBox:b,screenBounds:t,showAxesLabels:this.areAxesLabelsShown(t,n),xAxisName:null===(y=n.chartOptions)||void 0===y?void 0:y.xAxisName,yAxisName:null===(I=n.chartOptions)||void 0===I?void 0:I.yAxisName}),(0,f.GU)(e,n,{showLegend:this.isLegendShown(t),dataBox:b,ratio:M}),e.restore()}render(e,t,n,i,a,l,s){var u,d,f,h,g;if(!l.cell.value)return;if(i<m.h.MIN_CELL_RENDERER_PX_WIDTH||a<m.h.MIN_CELL_RENDERER_PX_HEIGHT)return;const v=(null==l?void 0:l.grid)&&(null==l?void 0:l.grid.dart)&&e.canvas===(null===(u=null==l?void 0:l.grid)||void 0===u?void 0:u.canvas),T=(null===(d=l.cell.column)||void 0===d?void 0:d.getTag(m.h.TAG_FIT_CHART_FORMAT))===m.h.TAG_FIT_CHART_FORMAT_3DX?(0,c.K)(l.cell.value):w(l,v),_=o.inflateScreenBounds(new r.Rect(t,n,i,a));for(const[t,n]of Object.entries(m.h.CONDITION_MAP))if(n(T.series))return void p(e,_);(null===(f=l.cell.column)||void 0===f?void 0:f.name)&&(null===(h=T.series)||void 0===h||h.forEach((e=>e.columnName=l.cell.column.name))),(null===(g=T.chartOptions)||void 0===g?void 0:g.mergeSeries)&&(T.series=[C(T.series)]),e.clearRect(_.x,_.y,_.width,_.height),this.renderCurves(e,_,T,l)}hitTest(e,t,n){const o=n.xToScreen(t.x),i=n.yToScreen(t.y),a=(t.outlier?m.h.OUTLIER_PX_SIZE:m.h.POINT_PX_SIZE)/2+m.h.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,i,l,d,f,h,p,g,v,C,T,_;if(!e.cell.value)return;const x=o.inflateScreenBounds(e.bounds);if(x.width<m.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||x.height<m.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT){const n=a.canvas(300,200);this.render(n.getContext("2d"),0,0,300,200,e,null);const o=a.divV([n]);a.tooltip.show(o,t.x,t.y)}const y=(null===(n=e.cell.column)||void 0===n?void 0:n.getTag(m.h.TAG_FIT_CHART_FORMAT))===m.h.TAG_FIT_CHART_FORMAT_3DX?(0,c.K)(e.cell.value):w(e);if(x.width>=m.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH&&x.height>=m.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT){const e=E(x,this.areAxesLabelsShown(x,y),this.isTitleShown(x,y))[0],n=(0,u.s$)(y),o=new s.L(n,e,null!==(l=null===(i=y.chartOptions)||void 0===i?void 0:i.logX)&&void 0!==l&&l,null!==(f=null===(d=y.chartOptions)||void 0===d?void 0:d.logY)&&void 0!==f&&f);for(let e=0;e<(null===(h=y.series)||void 0===h?void 0:h.length);e++)if("points"===y.series[e].showPoints)for(let n=0;n<y.series[e].points.length;n++){const i=y.series[e].points[n];if(this.hitTest(t,i,o))return a.tooltip.show(a.divV([a.divText(`${null!==(g=null===(p=y.chartOptions)||void 0===p?void 0:p.xAxisName)&&void 0!==g?g:"x"}: ${r.format(i.x,(null===(v=y.chartOptions)||void 0===v?void 0:v.logX)?"scientific":"#0.000")}`),a.divText(`${null!==(T=null===(C=y.chartOptions)||void 0===C?void 0:C.yAxisName)&&void 0!==T?T:"y"}: ${r.format(i.y,(null===(_=y.chartOptions)||void 0===_?void 0:_.logY)?"scientific":"#0.000")}`)]),t.x+16,t.y+16),void(!y.series[e].connectDots&&y.series[e].clickToToggle&&x.width>=m.h.MIN_AXES_CELL_PX_WIDTH&&x.height>=m.h.MIN_AXES_CELL_PX_HEIGHT&&(document.body.style.cursor="pointer"))}a.tooltip.hide()}document.body.style.cursor="default"}};S.fittedCurves=new r.LruCache(1e3),S.parsedCurves=new r.LruCache(1e3),S.curvesDataPoints=new r.LruCache(2e3),S=o=function(e,t,n,o){var r,i=arguments.length,a=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,o);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}([i.decorators.cellRenderer({name:"Fit",cellType:"fit",virtual:!0})],S)},672:(e,t,n)=>{"use strict";n.d(t,{mE:()=>d,Z:()=>m,jI:()=>E,Zk:()=>w,nx:()=>f,HQ:()=>_,qR:()=>C,GU:()=>A,QW:()=>h,yv:()=>y,zF:()=>I});var o=n(82),r=n(71),i=n(999),a=n(95),l=n(368);const s=window,u=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2});class c{static getUniqueName(e,t,n){return s.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 u.format(e)}}var d;function m(e,t,n){const r=o.Color.toHtml("outlierColor"===n?o.Color.red:o.Color.getCategoricalColor(t));return e[n]&&o.Color.fromHtml(e[n])?e[n]:r}function f(e,t,n){var o;if(null!==(o=t.connectDots)&&void 0!==o&&o){const o=n.viewport;e.strokeStyle=m(t,n.seriesIdx,"pointColor"),e.lineWidth=2*n.ratio,e.beginPath();for(let n=0;n<t.points.length;n++){const r=t.points[n].x,i=t.points[n].y,a=o.xToScreen(r),l=o.yToScreen(i);0===n?e.moveTo(a,l):e.lineTo(a,l)}e.stroke()}}function h(e,t,n){var r;const i=n.screenBounds;!(i.width<a.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||i.height<a.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT)&&(null===(r=t.showPoints)||void 0===r||r)&&(e.strokeStyle=m(t,n.seriesIdx,d.POINT),t.connectDots&&""!==t.showPoints||"points"===t.showPoints?function(e,t,n){const r=n.ratio,i=a.h.POINT_PX_SIZE*r,l=n.viewport,s=t.connectDots,u=m(t,n.seriesIdx,d.POINT),c=m(t,n.seriesIdx,d.OUTLIER);for(let n=0;n<t.points.length;n++){const d=t.points[n],m=l.xToScreen(d.x),f=l.yToScreen(d.y),h=s?u:d.outlier?d.outlierColor&&o.Color.fromHtml(d.outlierColor)?d.outlierColor:c:d.color&&o.Color.fromHtml(d.color)?d.color:u,p=d.marker?d.marker:t.markerType,g=d.outlierMarker?d.outlierMarker:t.outlierMarkerType,v=s?i:d.outlier?a.h.OUTLIER_PX_SIZE*r:d.size?d.size:i,C=s?p:d.outlier?g:p;o.Paint.marker(e,C,m,f,h,v),d.stdev&&!d.outlier&&(e.strokeStyle=h,e.beginPath(),e.moveTo(m,l.yToScreen(d.y+d.stdev)),e.lineTo(m,l.yToScreen(d.y-d.stdev)),e.stroke())}}(e,t,n):["candlesticks","both"].includes(t.showPoints)&&function(e,t,n){const r=n.ratio,i=n.viewport,s=m(t,n.seriesIdx,d.POINT);for(let n=0,u=null;n<t.points.length;n++){const c=t.points[n];if(c.outlier)continue;const d=n+1<t.points.length&&t.points[n+1].x===c.x;if(!u&&d)u=n;else if(null!==u&&!d){const d=[];for(let e=u,o=0;e<=n;e++,o++)d[o]=t.points[e].y;const m=(0,l.k)(d);if(e.beginPath(),p(e,{viewport:i,ratio:r,x:c.x,boxPlotStats:m,color:s}),e.stroke(),"both"===t.showPoints)for(let t=0;t<d.length;t++)(d[t]<m.lowerAdjacentValue||d[t]>m.upperAdjacentValue)&&o.Paint.marker(e,o.MARKER_TYPE.OUTLIER,i.xToScreen(c.x),i.yToScreen(d[t]),s,a.h.CANDLESTICK_OUTLIER_PX_SIZE*r);u=null}}}(e,t,n))}function p(e,t){const n=t.viewport,r=t.x,i=n.xToScreen(r),l=t.boxPlotStats;g(e,r,l.lowerAdjacentValue,n),e.moveTo(i,n.yToScreen(l.lowerAdjacentValue)),e.lineTo(i,n.yToScreen(l.upperAdjacentValue)),g(e,r,l.upperAdjacentValue,n),o.Paint.marker(e,o.MARKER_TYPE.CIRCLE,i,n.yToScreen(l.q2),t.color,a.h.CANDLESTICK_MEDIAN_PX_SIZE*t.ratio)}function g(e,t,n,o){const r=o.xToScreen(t),i=o.yToScreen(n);e.moveTo(r-a.h.CANDLESTICK_BORDER_PX_SIZE/2,i),e.lineTo(r+a.h.CANDLESTICK_BORDER_PX_SIZE/2,i)}function v(e){const t=e.logOptions.logX,n=e.logOptions.logY,o=e.screenBounds,r=e.showAxes?e.showAxesLabels?a.h.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:a.h.AXES_LEFT_PX_MARGIN:0,i=e.showAxes?a.h.AXES_RIGHT_PX_MARGIN:0;return{logX:t,logY:n,xMin:o.x+r,xMax:o.x+o.width-i,viewport:e.viewport}}function C(e,t,n){var o;if(null===(o=t.showFitLine)||void 0===o||o){e.save(),e.strokeStyle=m(t,n.seriesIdx,d.FIT_LINE),e.lineWidth=2*n.ratio,e.beginPath(),t.lineStyle&&e.setLineDash(a.h.LINE_STYLES[t.lineStyle]);const{logX:o,logY:r,xMin:i,xMax:l,viewport:s}=v(n),u=n.curveFunc;for(let t=i;t<=l;t++){const n=o?Math.log10(s.xToWorld(t)):s.xToWorld(t),a=r?s.yToScreen(Math.pow(10,u(n))):s.yToScreen(u(n));t===i?e.moveTo(t,a):e.lineTo(t,a)}e.stroke(),e.restore()}}function w(e,t,n){var o,r,l,s;if((null===(o=t.showFitLine)||void 0===o||o)&&null!==(r=t.showCurveConfidenceInterval)&&void 0!==r&&r){e.strokeStyle=null!==(l=t.confidenceIntervalColor)&&void 0!==l?l:a.h.CONFIDENCE_INTERVAL_STROKE_COLOR,e.fillStyle=null!==(s=t.confidenceIntervalColor)&&void 0!==s?s:a.h.CONFIDENCE_INTERVAL_FILL_COLOR;const o=n.showAxes,r=n.showAxesLabels,u=n.logOptions,c=n.viewport,d=n.screenBounds,m=t.dataPoints,f=(0,i.fY)(t,n.fitFunc,n.userParamsFlag,m,u);T(e,{viewport:c,logOptions:u,showAxes:o,showAxesLabels:r,screenBounds:d,confidenceIntervals:f,confidenceType:a.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP}),T(e,{viewport:c,logOptions:u,showAxes:o,showAxesLabels:r,screenBounds:d,confidenceIntervals:f,confidenceType:a.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.BOTTOM}),function(e,t){e.beginPath();const{logX:n,logY:o,xMin:r,xMax:i,viewport:a}=v(t),l=t.confidenceIntervals.confidenceTop,s=t.confidenceIntervals.confidenceBottom;for(let t=r;t<=i;t++){const i=n?Math.log10(a.xToWorld(t)):a.xToWorld(t),s=o?a.yToScreen(Math.pow(10,l(i))):a.yToScreen(l(i));t===r?e.moveTo(t,s):e.lineTo(t,s)}for(let t=i;t>=r;t--){const r=n?Math.log10(a.xToWorld(t)):a.xToWorld(t),i=o?a.yToScreen(Math.pow(10,s(r))):a.yToScreen(s(r));e.lineTo(t,i)}e.closePath(),e.fill()}(e,{viewport:c,logOptions:u,showAxes:o,showAxesLabels:r,screenBounds:d,confidenceIntervals:f})}}function T(e,t){e.beginPath();const{logX:n,logY:o,xMin:r,xMax:i,viewport:l}=v(t),s=t.confidenceType===a.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP?t.confidenceIntervals.confidenceTop:t.confidenceIntervals.confidenceBottom;for(let t=r;t<=i;t++){const i=n?Math.log10(l.xToWorld(t)):l.xToWorld(t),a=o?l.yToScreen(Math.pow(10,s(i))):l.yToScreen(s(i));t===r?e.moveTo(t,a):e.lineTo(t,a)}e.stroke()}function _(e,t,n){var o;if((null===(o=t.showFitLine)||void 0===o||o)&&t.droplines&&n.showDroplines){e.save(),e.strokeStyle="blue",e.lineWidth=n.ratio,e.beginPath(),e.setLineDash([5,5]);const o=n.viewport,r=n.dataBounds,i=n.curveFunc,a=n.logOptions;for(let n=0;n<t.droplines.length;n++)"IC50"===t.droplines[n]&&x(e,{viewport:o,xValue:t.parameters[2],dataBounds:r,curveFunc:i,logOptions:a});e.stroke(),e.restore()}}function x(e,t){const n=t.logOptions.logX,o=t.logOptions.logY,r=n?Math.pow(10,t.xValue):t.xValue,i=t.viewport,a=t.dataBounds,l=n?Math.log10(r):r,s=o?Math.pow(10,t.curveFunc(l)):t.curveFunc(l),u=i.xToScreen(r),c=i.yToScreen(s);e.moveTo(i.xToScreen(a.minX),c),e.lineTo(u,c),e.lineTo(u,i.yToScreen(a.minY))}function y(e,t,n){var o;const l=n.screenBounds,s=l.width<a.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||l.height<a.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT?[]:n.statistics;if((null===(o=t.showFitLine)||void 0===o||o)&&s&&s.length>0){const o=n.dataBox,a=n.dataPoints,l=(0,i.VA)(t,n.fitFunc,a,n.logOptions),u=m(t,n.seriesIdx,d.FIT_LINE);for(let t=0;t<s.length;t++){const n=s[t],i=r.nK.find((e=>e.name===n));if(i){const n=c.formatNumber(i.get(l));e.fillStyle=u,e.textAlign="left",e.fillText(i.name+": "+n,o.x+5,o.y+20+20*t)}}}}function I(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))}function E(e,t){if(t.showAxesLabels){const n=t.screenBounds,o=t.dataBox;e.font='11px Roboto, "Roboto Local"',e.textAlign="center",e.fillStyle="black",e.fillText(t.xAxisName,o.midX-5,n.maxY-a.h.X_AXIS_LABEL_BOTTOM_PX_MARGIN),e.translate(n.x,n.y),e.rotate(-Math.PI/2);const r=t.showTitle?a.h.AXES_TOP_PX_MARGIN_WITH_TITLE:a.h.AXES_TOP_PX_MARGIN;e.fillText(t.yAxisName,-(o.height/2+r+15),15),e.restore()}}function A(e,t,n){var o,r,i,a;if(n.showLegend){const l=n.dataBox,s=n.ratio;e.font='11px Roboto, "Roboto Local"';const u=[...new Set(null===(o=t.series)||void 0===o?void 0:o.map((e=>e.columnName)))].filter((e=>null!=e));let c=0;for(let n=0;n<u.length;n++){const o=u[n];(null===(r=t.chartOptions)||void 0===r?void 0:r.showColumnLabel)&&N(e,o,{dataBox:l,columnIdx:n,drawnCurvesInLegend:c});const d=null===(i=t.series)||void 0===i?void 0:i.filter((e=>e.columnName===o));for(let o=0;o<(null==d?void 0:d.length);o++){const r=d[o];""!==r.name&&null!==r.name&&void 0!==r.name&&(b(e,r,{dataBox:l,ratio:s,columnIdx:n,drawnCurvesInLegend:c,showColumnLabel:null===(a=t.chartOptions)||void 0===a?void 0:a.showColumnLabel,seriesIdx:o}),c++)}}e.restore()}}function N(e,t,n){const o=n.dataBox;e.beginPath(),e.fillStyle="black";const r=e.measureText(t).width;e.fillText(t,o.maxX-r,o.y+a.h.LEGEND_TOP_PX_MARGIN+(n.columnIdx*a.h.LEGEND_RECORD_PX_HEIGHT+a.h.LEGEND_RECORD_PX_HEIGHT*n.drawnCurvesInLegend))}function b(e,t,n){const r=n.dataBox,i=n.columnIdx,l=n.ratio,s=n.showColumnLabel,u=n.drawnCurvesInLegend,c=m(t,n.seriesIdx,d.POINT),f=m(t,n.seriesIdx,d.FIT_LINE);e.beginPath(),e.strokeStyle=f,e.lineWidth=2*l;const h=e.measureText(t.name).width;e.moveTo(r.maxX-h-a.h.LEGEND_RECORD_LINE_PX_WIDTH-a.h.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN,r.y+a.h.LEGEND_TOP_PX_MARGIN-a.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN+(s?a.h.LEGEND_RECORD_PX_HEIGHT*(i+1):0)+a.h.LEGEND_RECORD_PX_HEIGHT*u),e.lineTo(r.maxX-h-a.h.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN,r.y+a.h.LEGEND_TOP_PX_MARGIN-a.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN+(s?a.h.LEGEND_RECORD_PX_HEIGHT*(i+1):0)+a.h.LEGEND_RECORD_PX_HEIGHT*u);const p=t.markerType?t.markerType:o.MARKER_TYPE.CIRCLE;o.Paint.marker(e,p,r.maxX-h-a.h.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN-a.h.LEGEND_RECORD_LINE_PX_WIDTH/2,r.y+a.h.LEGEND_TOP_PX_MARGIN-a.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN+(s?a.h.LEGEND_RECORD_PX_HEIGHT*(i+1):0)+a.h.LEGEND_RECORD_PX_HEIGHT*u,c,a.h.POINT_PX_SIZE*l),e.fillStyle=f,e.fillText(t.name,r.maxX-h,r.y+a.h.LEGEND_TOP_PX_MARGIN+(s?a.h.LEGEND_RECORD_PX_HEIGHT*(i+1):0)+a.h.LEGEND_RECORD_PX_HEIGHT*u),e.stroke()}!function(e){e.POINT="pointColor",e.OUTLIER="outlierColor",e.FIT_LINE="fitLineColor"}(d||(d={}))},48:(e,t,n)=>{"use strict";n.r(t),n.d(t,{_FitChartCellRenderer:()=>g,_MultiCurveViewer:()=>v,_PlateGridCellRenderer:()=>C,_initCurves:()=>X,_package:()=>N,addAggrStatisticsColumn:()=>D,addStatisticsColumn:()=>F,assayPlatesDemo:()=>M,autostart:()=>L,checkExcelIsPlate:()=>k,checkFileIsPlate:()=>q,curveFitDemo:()=>R,importPlate:()=>H,importPlateXlsx:()=>B,platesFolderPreview:()=>G,previewPlate:()=>Y,previewPlateXlsx:()=>V});var o=n(407),r=n(82),i=n(389),a=n(328),l=n(71);const s=rxjs.operators;var u,c=n(858),d=n(95);let m=u=class extends r.JsViewer{constructor(){super(),this.curvesColumnNames=[],this.showSelectedRowsCurves=!1,this.showCurrentRowCurve=!0,this.showMouseOverRowCurve=!0,this.mergeColumnSeries=!1,this.rows=[],this.data=new l.oH,this.gridCellWidget=r.GridCellWidget.fromGridCell(this.createGridCell("")),this.canvas=this.gridCellWidget.canvas,this.root.append(this.gridCellWidget.canvas),i.tools.handleResize(this.root,((e,t)=>{this.canvas.width=e,this.canvas.height=t,this.render()})),this.curvesColumnNames=this.addProperty("curvesColumnNames",r.TYPE.COLUMN_LIST,[],{semType:d.h.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.xs)this.addProperty("mergeSeries"===e.name?"mergeCellSeries":e.name,e.propertyType,e.defaultValue,e.options)}static fromChartData(e){let t=new u;return t.data=e,t.render(),t}createGridCell(e){const t=r.GridCell.fromValue(e);return t.cellType=d.h.FIT_CELL_TYPE,t}applyViewerProperties(){(0,o.g2)(l.xs,this,this.data.chartOptions)}mergeViewerChartOptions(){for(const e of l.xs)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,i,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.oH;const c=null===(t=this.tableView)||void 0===t?void 0:t.grid,d=this.props.get("mergeCellSeries"),m=[];for(const e of this.curvesColumnNames){const t=[];for(const r of new Set(this.rows)){const i=c.cell(e,c.tableRowToGrid(r));if(""===i.cell.value)continue;const a=(0,o.h8)(i);null===(n=a.series)||void 0===n||n.forEach((e=>e.columnName=i.cell.column.name));const l=a.chartOptions;if(null!=l&&(m[m.length]=l),d){const e=(0,o.wU)(a.series);void 0!==(null==l?void 0:l.title)&&""!==(null==l?void 0:l.title)&&(e.name=null==l?void 0:l.title),a.series=[e]}t.push(...a.series)}this.mergeColumnSeries?null===(i=this.data.series)||void 0===i||i.push((0,o.wU)(t)):null===(a=this.data.series)||void 0===a||a.push(...JSON.parse(JSON.stringify(t)))}this.data.chartOptions=(0,o.LX)(m),this.mergeViewerChartOptions(),null===(s=this.data.series)||void 0===s||s.forEach(((e,t)=>{var n,o,i,a,l;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===(l=this.data.series)||void 0===l?void 0:l.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,o,r,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!==(o=null==e?void 0:e.name)&&void 0!==o?o:"")&&(this["mergeSeries"===(null==e?void 0:e.name)?"mergeCellSeries":null!==(r=null==e?void 0:e.name)&&void 0!==r?r:""]=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(d.h.FIT_SEM_TYPE);null!==n&&(this.curvesColumnNames=[n.name]),(0,c.merge)(this.dataFrame.onCurrentCellChanged,t.onCellMouseEnter,this.dataFrame.onSelectionChanged).pipe((0,s.debounce)((e=>(0,c.interval)(50)))).subscribe((e=>{this.dataFrame&&(this.createChartData(),this.render())}))}_showErrorMessage(e){this.root.appendChild(i.divText(e,"d4-viewer-error"))}_removeErrorMessage(){const e=this.root.getElementsByClassName("d4-viewer-error")[0];e&&this.root.removeChild(e)}render(){var e,t,n;this.canvas.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this._removeErrorMessage(),0!==(null===(e=this.curvesColumnNames)||void 0===e?void 0:e.length)?0!==(null===(n=null===(t=this.data)||void 0===t?void 0:t.series)||void 0===n?void 0:n.length)?this.gridCellWidget.gridCell=this.createGridCell(JSON.stringify(this.data)):this._showErrorMessage("No data to show."):this._showErrorMessage("The MultiCurveViewer viewer requires a minimum of 1 curves column.")}};m=u=function(e,t,n,o){var r,i=arguments.length,a=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,o);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}([a.decorators.viewer({name:"MultiCurveViewer",description:"A viewer that superimposes multiple in-cell curves on one chart",icon:"icons/multi-curve-viewer.png"}),function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}("design:paramtypes",[])],m);var f=n(140);class h extends r.ObjectHandler{get type(){return"Plate"}isApplicable(e){return e instanceof r.GridCell&&"Plate"===e.cellType}getGridCellRenderer(){return new p}}let p=class extends r.GridCellRenderer{constructor(){super(...arguments),this.plate=new f.Xe}get name(){return"Plate"}get cellType(){return"Plate"}getDefaultSize(e){return{width:120,height:80}}render(e,t,n,o,i,a,l){this.plate.plateData=a.value,this.plate.grid.props.colHeaderHeight=i>120?16:0,this.plate.grid.props.showRowHeader=o>100,this.plate.grid.render(e,new r.Rect(t,n,o,i).cutTop(Math.min(i/20,5)).cutRight(Math.min(o/20,5)))}onClick(e,t){a.shell.o=f.Xe.detailedView(e.value).root}};function g(){return new o.lR}function v(){return new m}function C(){return new p}p=function(e,t,n,o){var r,i=arguments.length,a=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,o);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}([a.decorators.cellRenderer({cellType:"Plate"})],p);var w=n(667),T=n(471),_=n(283),x=n(973),y=n(572),I=n(358);class E{static getReader(e){var t;return null!==(t=this.readers.find((t=>t.isApplicable(e))))&&void 0!==t?t:null}static read(e){var t,n;return null!==(n=null===(t=this.getReader(e))||void 0===t?void 0:t.read(e))&&void 0!==n?n:null}}E.readers=[new class{isApplicable(e){return e.startsWith("Plate information")&&e.includes("DELFIA")&&e.includes("Number of the wells in the plate,,,,96")}read(e){const t=e.indexOf(",01,02,03,04,05,06,07,08,09,10,11,12,");let n=e.indexOf("\n\n",t+1);return n=-1!=n?n:e.indexOf("\r\n\r\n",t+1),x.T6.fromCsv(e.substring(t,n))}},new class{isApplicable(e){return e.includes("PltRpt=1")&&e.includes("Group=1")}read(e){let t=e.indexOf("\n\n");t=-1==t?e.indexOf("\r\n\r\n"):t;const n=e.substring(e.indexOf("\n")+1,t),o=r.DataFrame.fromCsv(n,{delimiter:"\t"});return x.T6.fromTableByRow(o)}},new class{isApplicable(e){return e.includes("No. of Channels / Multichromatics:")&&e.includes("No. of Cycles:")}read(e){const t=e.indexOf("A01;");if(-1===t)throw new Error("Data section not found");const n=e.substring(t).split("\n").map((e=>e.trim())).filter((e=>e.length>0)).map((e=>e.split(";").map((e=>e.trim())))),o=x.T6.autoSize(n.map((e=>(0,I.cx)(e[0])))),r=o.data.columns.addNewFloat("Channel A"),i=o.data.columns.addNewFloat("Channel B");for(const e of n){const[t,n,a]=e;if(!t||3!==t.length)continue;const[l,s]=(0,I.cx)(t),u=o._idx(l,s);r.set(u,parseFloat(n),!1),i.set(u,parseFloat(a),!1)}return o}},new class{isApplicable(e){return e.includes("Plate:")&&e.includes("##BLOCKS=")}read(e){const t=e.split(/\r\n|\r|\n/),n=t[2].split("\t").filter((e=>""!==e)),o=parseInt(t[1].split("\t")[8]),r=n.filter(((e,t)=>""==e&&t<5||!/^-?\d+$/.test(e))),i=n.filter((e=>/^-?\d+$/.test(e))).length,a=2*i/3,l=[];for(let e=0;e<o;e++){const n=new x.T6(a,i),o=t[e*(a+1)+3].split("\t"),s=r.map(((e,t)=>e+": "+o[t])).filter(((e,t)=>""!=e)).join(", "),u=n.data.columns.addNewFloat(s);for(let n=0;n<a;n++){const o=t[e*(a+1)+3+n].split("\t");for(let e=0;e<i;e++)u.set(n*i+e,parseFloat(o[e+2].replace(",",".")),!1)}l.push(n)}return x.T6.fromPlates(l)}}];var A=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function l(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}s((o=o.apply(e,t||[])).next())}))};const N=new r.Package,b=".sourceColumn",O=".seriesNumber",S=".seriesAggregation",P=".statistics";function L(){window.PlateWidget=f.Xe,window.Plate=x.T6;const e="col 1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24\nA,,,,,,,,,,,,,,,,,,,,,,,,\nB,,0.00001,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,\nC,,0.00000,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,\nD,,0.00001,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,\nE,,0.00000,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,\nF,,0.00001,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,\nG,,0.00000,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,\nH,,0.00001,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,\nI,,0.00000,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,\nJ,,0.00001,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,\nK,,0.00000,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,\nL,,0.00001,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,\nM,,0.00000,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,\nN,,0.00001,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,\nO,,0.00000,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,\nP,,,,,,,,,,,,,,,,,,,,,,,,",t="col 1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24\nA,,,,,,,,,,,,,,,,,,,,,,,,\nB,,Low Control,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,High Control,\nC,,High Control,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Low Control,\nD,,Low Control,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,High Control,\nE,,High Control,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Low Control,\nF,,Low Control,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,High Control,\nG,,High Control,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Low Control,\nH,,Low Control,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,High Control,\nI,,High Control,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Low Control,\nJ,,Low Control,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,High Control,\nK,,High Control,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Low Control,\nL,,Low Control,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,High Control,\nM,,High Control,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Low Control,\nN,,Low Control,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,High Control,\nO,,High Control,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Low Control,\nP,,,,,,,,,,,,,,,,,,,,,,,,",n="col 1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24\nA,,,,,,,,,,,,,,,,,,,,,,,,\nB,,0.07219099668,0.06947737465,0.07019976172,0.07263956168,0.07334269904,0.07654089128,0.07628940202,0.08834969214,0.13557287840,0.1486864679,0.1503697113,0.15200083420,0.15061775480,0.15309907440,0.15286653780,0.15379914010,0.15155727890,0.15232794460,0.15298766400,0.1538730651,0.1542393465,0.15071555580,\nC,,0.14996855360,0.07212290660,0.06957076093,0.07069321642,0.07227733865,0.07664359412,0.07918610560,0.07808503586,0.12496495030,0.1378908893,0.1465698921,0.15578283900,0.15186884230,0.15151635070,0.15141401530,0.15052587190,0.15486747600,0.15294037650,0.15241116130,0.1546532344,0.1537365814,0.07231605295,\nD,,0.07023863668,0.07030474895,0.07086594623,0.07378772619,0.07813099195,0.08443275691,0.10024937710,0.11821695280,0.14031173800,0.1505845411,0.1505987702,0.07099481653,0.07322787956,0.07588648236,0.08377558210,0.09888790085,0.11395358370,0.12947949180,0.14055841590,0.1493699333,0.1540055735,0.15226875140,\nE,,0.14929130930,0.06932695867,0.07157716491,0.07214187679,0.07721194315,0.08504549754,0.10174360480,0.11748417490,0.13321393730,0.1456650512,0.1483001297,0.07167267085,0.07383087952,0.07670410142,0.08204578635,0.09386326869,0.11296832520,0.30900000000,0.13807843210,0.1487301787,0.1519785410,0.07219836243,\nF,,0.07063914398,0.07039007372,0.07078597316,0.07132027961,0.07222210814,0.07442561862,0.08135627908,0.09196745273,0.11146019360,0.1364485205,0.1450632971,0.08126099235,0.09318398047,0.10961914380,0.12860206080,0.14110717340,0.14655533300,0.15212245890,0.15233422070,0.1521740437,0.1539843278,0.15514745160,\nG,,0.15147635060,0.07238581078,0.06968522213,0.07128524617,0.07252406181,0.07567350355,0.07943235275,0.09117074615,0.10537654310,0.1344820888,0.1400224330,0.08242500433,0.09563371204,0.10936069820,0.12848949680,0.14108995770,0.14405660970,0.15031406210,0.15131600980,0.1522018720,0.1534152011,0.07219962790,\nH,,0.07201551934,0.14139074650,0.10970399700,0.14927003800,0.15153471030,0.15239784500,0.15275285200,0.15300022370,0.15204696770,0.1499048651,0.1522479639,0.08013306126,0.08511773454,0.09873312909,0.11965236570,0.13423325770,0.14790643020,0.14787378410,0.15121033310,0.1516832849,0.1546688514,0.15391338010,\nI,,0.15106747120,0.14298828240,0.14478508750,0.14400005770,0.12812788070,0.15020659840,0.15070640480,0.14981230230,0.15107167610,0.1525554191,0.1492535524,0.08018720930,0.08601155699,0.09880353225,0.11672648890,0.13325225690,0.14354164670,0.14463708830,0.15318329890,0.1521327032,0.1512182552,0.07244861048,\nJ,,0.07134151692,0.07106139536,0.07290563639,0.07320964199,0.07531163459,0.08077714646,0.08726929940,0.10068593880,0.11914215450,0.1418191958,0.1443463920,0.07247201272,0.06999750950,0.07076991276,0.07228675508,0.07237591892,0.07201251723,0.07741640477,0.08773368972,0.1219768071,0.1387552698,0.15192226570,\nK,,0.15000436380,0.07156625599,0.07087075250,0.07123659002,0.07345421874,0.07832545577,0.08734304748,0.09985159477,0.11591447310,0.1397237122,0.1459823861,0.07214517236,0.07005683091,0.07016838344,0.07131776580,0.07200174821,0.07350492337,0.07785311421,0.08866229169,0.1234911377,0.1371697196,0.07064796366,\nL,,0.07054096934,0.07004726921,0.07201825002,0.07179815990,0.07268889103,0.07379454514,0.07427085340,0.07982570255,0.08854676858,0.1198873673,0.1322562498,0.07034679393,0.07523627163,0.07582258339,0.08392782907,0.09669262374,0.11261560310,0.12874291890,0.14171585180,0.1491004443,0.1502214336,0.15198125010,\nM,,0.15232172270,0.07166689716,0.07099964730,0.07172948942,0.07140356089,0.07359647053,0.07391627346,0.07872536050,0.08793247921,0.1177668597,0.1316288144,0.06733039177,0.07260462946,0.07516068933,0.08359475310,0.09611904399,0.11364151330,0.12772328380,0.14070692820,0.1486696188,0.1541842928,0.07174453270,\nN,,0.07126884935,0.07332587669,0.07786873273,0.08482253378,0.10140499840,0.11854947500,0.13401382360,0.14613488070,0.15066237370,0.1545757395,0.1510962397,0.07286614211,0.07215169457,0.07227939024,0.07337505876,0.07530546981,0.08265249465,0.09167518260,0.11122719660,0.1391977320,0.1459690588,0.15291802550,\nO,,0.15243482930,0.07280165939,0.07688708790,0.31500000000,0.09886803400,0.11454911710,0.12960429510,0.14047477320,0.14718270040,0.1509524590,0.1501338551,0.07212897291,0.07072700474,0.07059273173,0.07088234657,0.07421414395,0.08105493058,0.09094554089,0.10660934950,0.1358113503,0.1432621746,0.07009305748,\nP,,,,,,,,,,,,,,,,,,,,,,,,";window.readoutCsv=n,window.concentrationCsv=e,window.layoutCsv=t,window.getPlate=function(){const o=x.T6.fromCsvTable(e,"concentration"),r=x.T6.fromCsvTable(t,"role"),i=x.T6.fromCsvTable(n,"readout");return x.T6.fromPlates([o,r,i])},window.jStat=y}function R(){return A(this,void 0,void 0,(function*(){yield(0,T.Z1)()}))}function M(){return A(this,void 0,void 0,(function*(){const e=(yield a.dapi.files.list("System:DemoFiles/hts/xlsx_plates"))[0];a.shell.addView(yield V(e))}))}function X(){r.ObjectHandler.register(new w.e4),r.ObjectHandler.register(new h)}function F(e,t,n,i,a,l){var s;const u=r.Viewer.grid(e),c=u.col(t),m=r.Column.float(null!=l?l:`${t} ${i} ${n}`,null===(s=c.column)||void 0===s?void 0:s.length);m.tags[b]=t,m.tags[O]=a,m.tags[P]=n,m.init((e=>{var i,l,s,c,m;const f=r.GridCell.fromColumnRow(u,t,u.tableRowToGrid(e));if(""===f.cell.value)return null;const h=f.cell.column.getTag(d.h.TAG_FIT_CHART_FORMAT)===d.h.TAG_FIT_CHART_FORMAT_3DX?(0,_.K)(f.cell.value):(0,o.h8)(f);if(void 0===h.series[a]||h.series[a].points.every((e=>e.outlier)))return null;(null===(i=h.chartOptions)||void 0===i?void 0:i.allowXZeroes)&&(null===(l=h.chartOptions)||void 0===l?void 0:l.logX)&&(null===(s=h.series)||void 0===s?void 0:s.some((e=>e.points.some((e=>0===e.x)))))&&(0,o.B3)(h);const p={logX:null===(c=h.chartOptions)||void 0===c?void 0:c.logX,logY:null===(m=h.chartOptions)||void 0===m?void 0:m.logY};return(0,w.VK)(h.series[a],a,p,f)[n]})),e.columns.insert(m,c.idx)}function D(e,t,n,i){var a;const l=r.Viewer.grid(e),s=l.col(t),u=r.Column.float(`${t} ${i} ${n}`,null===(a=s.column)||void 0===a?void 0:a.length);u.tags[b]=t,u.tags[S]=i,u.tags[P]=n,u.init((e=>{var a,s,u,c;const m=r.GridCell.fromColumnRow(l,t,l.tableRowToGrid(e));if(""===m.cell.value)return null;const f=m.cell.column.getTag(d.h.TAG_FIT_CHART_FORMAT)===d.h.TAG_FIT_CHART_FORMAT_3DX?(0,_.K)(m.cell.value):(0,o.h8)(m);return(null===(a=f.series)||void 0===a?void 0:a.every((e=>e.points.every((e=>e.outlier)))))?null:((null===(s=f.chartOptions)||void 0===s?void 0:s.allowXZeroes)&&(null===(u=f.chartOptions)||void 0===u?void 0:u.logX)&&(null===(c=f.series)||void 0===c?void 0:c.some((e=>e.points.some((e=>0===e.x)))))&&(0,o.B3)(f),(0,w.JR)(f,i,m)[n])})),e.columns.insert(u,s.idx)}function G(e,t){return A(this,void 0,void 0,(function*(){var n;const o=null===(n=e.name)||void 0===n?void 0:n.toLowerCase();if(null==o?void 0:o.includes("plate"))return(0,f._$)(t)}))}function Y(e){const t=r.View.create();return t.name=e.name,e.readAsString().then((e=>{const n=E.read(e);null!==n&&t.root.appendChild(f.Xe.fromPlate(n).root)})),t}function H(e){return A(this,void 0,void 0,(function*(){const t=E.read(e),n=r.View.create();return null!==t&&n.root.appendChild(f.Xe.fromPlate(t).root),n.name="Plate",a.shell.addView(n),[]}))}function B(e){return A(this,void 0,void 0,(function*(){const t=r.View.create(),n=yield j(e);return t.root.appendChild(f.Xe.analysisView(n).root),t.name="Plate",a.shell.addView(t),[]}))}function V(e){return A(this,void 0,void 0,(function*(){const t=r.View.create();t.name=e.friendlyName;const n=yield j(yield e.readAsBytes());return t.root.appendChild(f.Xe.analysisView(n).root),t}))}function k(e){return A(this,void 0,void 0,(function*(){try{return!(e.length>1e6)&&null!==(yield j(e))}catch(e){return!1}}))}function j(e,t){return A(this,void 0,void 0,(function*(){if("string"==typeof e){const n=new Blob([e],{type:"application/octet-binary"}),o=yield n.arrayBuffer();return yield x.T6.fromExcel(new Uint8Array(o),t)}return yield x.T6.fromExcel(e,t)}))}function q(e){return!(e.length>1e6)&&null!=E.getReader(e)}},140:(e,t,n)=>{"use strict";n.d(t,{Xe:()=>p,_$:()=>g});var o=n(82),r=n(389),i=n(328),a=n(358),l=n(973),s=n(71),u=n(95),c=n(407),d=n(48),m=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function l(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}s((o=o.apply(e,t||[])).next())}))};const f=[o.Color.white,o.Color.gray],h=new Map([[96,{rows:8,cols:12}],[384,{rows:16,cols:24}],[1536,{rows:32,cols:48}]]);class p extends o.Widget{constructor(){super(r.div([],"curves-plate-widget")),this._plateData=o.DataFrame.create(),this.grid=o.Viewer.heatMap(this._plateData),this._posToRow=new Map,this.rows=0,this.cols=0,this.colorColumnName="",this.mapFromRowFunc=a.FH,this.root.appendChild(this.grid.root),this.subs.push(this.grid.onAfterDrawContent.subscribe((()=>{this.grid.root.querySelectorAll(".d4-range-selector").forEach((e=>e.style.display="none"))}))),this.grid.onCellRender.subscribe((e=>this.renderCell(e)))}static fromPlate(e){return p.detailedView(e.data)}static detailedView(e){const t=new p;return t.grid.root.style.width="100%",t.plateData=e,t.colorSelector=r.input.column("Color by",{table:e,value:t._colorColumn,onValueChanged:e=>{t._colorColumn=e,t.grid.invalidate()}}),t.detailsDiv=r.divV([]),t.wellDetailsDiv=(0,r.div)(),t.detailsDiv.appendChild(t.wellDetailsDiv),t.grid.onCurrentCellChanged.subscribe((e=>{r.empty(t.wellDetailsDiv);const n=t.dataRow(e);null!=n&&n>=0&&t.wellDetailsDiv.appendChild(r.tableFromMap(t.mapFromRowFunc(t.plateData.rows.get(n))))})),t.root.prepend(t.colorSelector.root),t.root.append(t.detailsDiv),t}static analysisView(e,t){const n=p.detailedView(e.data),d=n.grid.root,m=n.detailsDiv;n.plateActionsDiv=r.div(),n.plateDetailsDiv=r.div(),m.prepend(n.plateDetailsDiv),m.append(n.plateActionsDiv);const f={roleName:"layout",concentrationName:"concentration",valueName:"readout",normalize:!0,controlColumns:["High Control","Low Control"],autoFilterOutliers:!0,categorizeFormula:"${rSquared} > 0.8 && ${Hill} > 0.25 && ${Max} > 80 && ${Max} < 120",statisticsColumns:["Min","Max","rSquared","Hill","IC50","AUC"]};if(Object.entries({concentrationName:["conc","dose","conc.","dilution","concentrations"],valueName:["response","value","signal","raw data","raw signal","raw","response","values"],roleName:["role","plate layout","plate positions","group","compound","well"]}).forEach((([t,n])=>{const o=f[t];if(e.data.columns.contains(o))return;const r=n.find((t=>e.data.columns.contains(t)));r&&(f[t]=r)})),e.data.columns.contains(f.roleName)&&!f.controlColumns.every((t=>e.data.col(f.roleName).categories.includes(t)))){const t=e.data.col(f.roleName).categories.filter((e=>e.toLowerCase().includes("control")));f.controlColumns=t.slice(0,2)}const h=Object.assign(Object.assign({},f),t),g={rSquared:["rsquared","r2","r squared","r^2"],slope:["slope","hill","steepness","hill slope"],bottom:["bottom","min","minimum","miny","min y"],top:["top","max","maximum","maxy","max y"],interceptX:["interceptx","intercept x","ic50","ic 50","ic-50","ic_50","ic 50 value","ic50 value","ic50value","ec50","ec 50","ec-50","ec_50","ec 50 value","ec50 value","ec50value"],auc:["auc","area under the curve","area under curve","area"]},v={};if(h.statisticsColumns.forEach((e=>{const t=Object.entries(g).find((([t,n])=>n.includes(e.toLowerCase())));t&&(v[t[0]]=e)})),!d||!m)return n;const C=r.divH([d,m]);n.root.appendChild(C),m.style.flex="0 0 min(250px, 25%)",d.style.flexGrow="1",d.style.removeProperty("width");const w={exclude:{[h.roleName]:h.controlColumns}};let T=!1;if(h.normalize&&2===h.controlColumns.length){const[t,i]=h.controlColumns.map((t=>e.getStatistics(h.valueName,["mean","std"],{match:{[h.roleName]:t}}))).sort(((e,t)=>e.mean-t.mean));f.plateStatistics={"Z Prime":e=>1-3*(i.std+t.std)/Math.abs(i.mean-t.mean),"Signal to background":e=>i.mean/t.mean},h.plateStatistics||(h.plateStatistics=f.plateStatistics),h.normalizedColName=e.normalize(h.valueName,(e=>(i.mean-e)/(i.mean-t.mean)*100)).name,T=!0;const a={};Object.entries(h.plateStatistics).forEach((([t,n])=>{const r=n(e);a[t]="number"==typeof r?o.format(r,"#0.0000"):r}));const l=r.tableFromMap(a);n.plateDetailsDiv.appendChild(l),h.autoFilterOutliers&&e.markOutliersWhere(h.normalizedColName,(e=>e>106||e<-6),w)}const _=e.doseResponseSeries(Object.assign(Object.assign({},w),{value:T?h.normalizedColName:h.valueName,concentration:h.concentrationName,groupBy:h.roleName})),x=Object.entries(_),y=T?{minY:-10,maxY:110}:0,I=o.Column.string(h.roleName,x.length),E=o.Column.string("Curve",x.length);E.init((e=>JSON.stringify({chartOptions:Object.assign({xAxisName:h.concentrationName,yAxisName:T?`norm(${h.valueName})`:h.valueName,logX:!0,title:`${x[e][0]}`},y),series:[Object.assign(Object.assign({},x[e][1]),{fit:void 0,fitFunction:s.kC,clickToToggle:!0,droplines:["IC50"],name:x[e][0]})]}))),I.init((e=>x[e][0]));const A=o.DataFrame.fromColumns([I,E]);A.name=n.plateData.name,A.id=(0,l.rH)(),E.semType="fit";const N=A.plot.grid();Object.entries(v).forEach((([e,t])=>{const n={df:A,colName:E.name,propName:e,seriesName:"series 0",seriesNumber:0,newColName:t};o.Func.find({name:"addStatisticsColumn"})[0].prepare(n).callSync({processed:!1})})),v.interceptX&&A.col(v.interceptX)&&(A.col(v.interceptX).meta.format="scientific");const b=A.columns.addNewString(A.columns.getUnusedName("Criteria"));b.applyFormula(`if(${h.categorizeFormula}, "Qualified", "Fails Criteria")`,"string"),b.meta.colors.setCategorical({"Fails Criteria":4294922560,Qualified:4283477800}),N.root.style.width="100%",n.root.style.display="flex",n.root.style.flexDirection="column",n.root.style.height="100%",n.root.appendChild(N.root);let O=null;n.mapFromRowFunc=t=>(0,a.FH)(t,((t,o)=>{e._markOutlier(t,o),O&&O.curvesGridCell&&(0,c.Fw)(O.curvesGridCell,{x:0,y:0,outlier:!o},0,O.pointIndex),n.grid.invalidate()})),n.subs.push(n.grid.onCurrentCellChanged.subscribe((e=>{var t,r,i,a,l;if(function(){var e,t;try{if(!O||(null!==(e=O.seriesIndex)&&void 0!==e?e:-1)<0)return;const n=E.get(O.seriesIndex);if(!n)return;const o=JSON.parse(n),r=null===(t=o.series[0])||void 0===t?void 0:t.points;r&&r.length&&r.length>O.pointIndex&&(r[O.pointIndex].marker=O.markerType,r[O.pointIndex].size=O.markerSize,r[O.pointIndex].color=O.markerColor,E.set(O.seriesIndex,JSON.stringify(o)))}catch(e){console.error(e)}finally{O=null}}(),null==(null==e?void 0:e.gridRow)||-1==(null==e?void 0:e.gridRow)||!(null==e?void 0:e.gridColumn)||0==(null==e?void 0:e.gridColumn.idx))return;const s=n.dataRow(e);if(null==s||s<0)return;const c=null===(t=n.plateData.get(h.roleName,s))||void 0===t?void 0:t.toLowerCase();if(!c)return;const d=x.findIndex((([e,t])=>(null==e?void 0:e.toLowerCase())===c));if(d<0)return;const m=n.plateData.get(h.concentrationName,s),f=n.plateData.get(T?h.normalizedColName:h.valueName,s),p=x[d][1].points.findIndex((e=>e.x===m&&e.y===f));if(p<0)return;O={seriesIndex:d,pointIndex:p,markerType:null!==(r=x[d][1].points[p].marker)&&void 0!==r?r:o.MARKER_TYPE.CIRCLE,markerSize:null!==(i=x[d][1].points[p].size)&&void 0!==i?i:u.h.POINT_PX_SIZE,markerColor:null!==(a=x[d][1].points[p].color)&&void 0!==a?a:o.Color.toHtml(o.Color.getCategoricalColor(0))};const g=JSON.parse(E.get(d)),v=null===(l=g.series[0])||void 0===l?void 0:l.points;v&&v.length&&v.length>p&&(v[p].marker=o.MARKER_TYPE.SQUARE,v[p].size=2*u.h.POINT_PX_SIZE,v[p].color=o.Color.toHtml(o.Color.green),E.set(d,JSON.stringify(g)));const C=N.tableRowToGrid(d);O.curvesGridCell=N.cell(E.name,C),O.curvesGridCell&&N.scrollToCell(E.name,C)}))),n.subs.push(i.events.onCustomEvent("fit-cell-outlier-toggle").subscribe((t=>{if(!t||!t.gridCell||!t.series||null==t.pointIdx||t.gridCell.cell.column!==E)return;const o=t.series.points[t.pointIdx];null!==o.meta&&(e._markOutlier(o.meta,!!o.outlier),n.grid.invalidate())})));const S=o.debounce(N.onAfterDrawContent,300).subscribe((()=>{S.unsubscribe(),N.col(E.name)&&(N.col(E.name).width=400),N.props.rowHeight=200}));if(h.submitAction){const t=r.button("Save to ELN",(()=>h.submitAction(e,A)));n.plateActionsDiv.appendChild(t)}return n}get plateData(){return this._plateData}set plateData(e){var t,n,r,i,a,l,s,u,c,d;this._plateData=e,this._colorColumn=null!==(i=null!==(r=null!==(n=null!==(t=e.columns.firstWhere((e=>"activity"==e.name&&e.type==o.TYPE.FLOAT)))&&void 0!==t?t:e.columns.firstWhere((e=>("concentration"==e.name||"concentrations"==e.name)&&e.type==o.TYPE.FLOAT)))&&void 0!==n?n:e.columns.firstWhere((e=>"row"!=e.name&&"col"!=e.name&&e.type==o.TYPE.FLOAT)))&&void 0!==r?r:e.columns.firstWhere((e=>e.type==o.TYPE.FLOAT)))&&void 0!==i?i:e.columns.byIndex(0);let m=this._plateData.col("row"),f=this._plateData.col("col");if(this.rows=null!==(l=null===(a=null==m?void 0:m.stats)||void 0===a?void 0:a.max)&&void 0!==l?l:null===(s=h.get(e.rowCount))||void 0===s?void 0:s.rows,this.cols=null!==(c=null===(u=null==f?void 0:f.stats)||void 0===u?void 0:u.max)&&void 0!==c?c:null===(d=h.get(e.rowCount))||void 0===d?void 0:d.cols,null==this.rows||null==this.cols)throw"Row/col columns not found, and dataframe length is not of the recognized sizes (96, 384, 1536)";for(let e=0;e<this._plateData.rowCount;e++)m&&f?this._posToRow.set(`${m.get(e)}:${f.get(e)}`,e):this._posToRow.set(`${Math.floor(e/this.cols)}:${e%this.cols+1}`,e);this.grid.dataFrame=o.DataFrame.create(this.rows),this.grid.columns.clear();for(let e=0;e<=this.cols;e++)this.grid.columns.add({gridColumnName:e.toString(),cellType:"string"});this.grid.invalidate()}dataRow(e){return this._posToRow.get(`${e.gridRow}:${e.gridColumn.idx}`)}renderCell(e){var t,n,r;const i=e.cell;e.g.fillStyle="grey",e.g.strokeStyle="grey",e.g.lineWidth=1;let a=e.g,s=e.bounds.x,u=e.bounds.y,c=e.bounds.width,d=e.bounds.height;const m=this.dataRow(i);a.textAlign="center",a.textBaseline="middle",a.font=`${Math.ceil(Math.min(16,c-1,d-1))}px Roboto, Roboto Local`;const f=null===(r=null===(n=null===(t=this._colorColumn)||void 0===t?void 0:t.name)||void 0===n?void 0:n.toLowerCase())||void 0===r?void 0:r.includes("conc");if(i.isColHeader&&i.gridColumn.idx>0)a.fillText(""+i.gridColumn.idx,s+c/2,u+d/2);else if(0==i.gridColumn.idx&&i.gridRow>=0){const e=i.gridRow>25?"A":"";a.fillText(e+String.fromCharCode(65+i.gridRow%26),s+c/2,u+d/2)}else if(d>0&&null!=m){a.beginPath();const e=.8*Math.min(d/2,c/2);if(a.ellipse(s+c/2,u+d/2,e,e,0,0,2*Math.PI),this._colorColumn){this._colorColumn.isCategorical&&this._colorColumn.meta.colors.getType()!==o.COLOR_CODING_TYPE.CATEGORICAL&&this._colorColumn.meta.colors.setCategorical();const t=this._colorColumn.isNone(m)?o.Color.white:this._colorColumn.isNumerical?this.getColor(m,f):this._colorColumn.meta.colors.getColor(m);a.fillStyle=o.Color.toHtml(t),a.fill();const n=this.plateData.col(l.bP);(null==n?void 0:n.get(m))&&(a.strokeStyle=o.Color.toHtml(o.Color.red),a.lineWidth=2,a.moveTo(s+c/2-e,u+d/2-e),a.lineTo(s+c/2+e,u+d/2+e),a.moveTo(s+c/2+e,u+d/2-e),a.lineTo(s+c/2-e,u+d/2+e),a.stroke())}a.stroke()}e.preventDefault()}getColor(e,t){const n=this._colorColumn.get(e),r=t?(0,a.Ei)(1e9*(n-this._colorColumn.min)):n,i=t?(0,a.Ei)(Math.max(this._colorColumn.min,1)):this._colorColumn.min,l=t?(0,a.Ei)(1e9*(this._colorColumn.max-this._colorColumn.min)):this._colorColumn.max;return o.Color.scaleColor(r,i,l,void 0,f)}}function g(e){return m(this,void 0,void 0,(function*(){const t=e.filter((e=>{var t,n;return null===(n=null===(t=null==e?void 0:e.name)||void 0===t?void 0:t.toLowerCase())||void 0===n?void 0:n.endsWith(".csv")}));let n;if(t.length>2){const o=l.T6.fromPlates(yield Promise.all(t.map((e=>m(this,void 0,void 0,(function*(){return yield l.T6.fromCsvTableFile(e.fullPath,e.name.toLowerCase().substring(0,e.name.length-4))}))))));if(n=p.analysisView(o,{submitAction:()=>{i.shell.info("Plate Submitted")}}),o.data.name=`${t.map((e=>e.name.slice(0,e.name.length-4))).join("_")}.csv`,t.length===e.length)return n}const r=new o.MultiView({viewFactories:{}});n&&r.addView("Plate 1",(()=>o.View.fromRoot(n.root)),!0);const a=e.filter((e=>{var t,n,o;return(null===(n=null===(t=null==e?void 0:e.name)||void 0===t?void 0:t.toLowerCase())||void 0===n?void 0:n.endsWith(".xlsx"))&&(null===(o=null==e?void 0:e.name)||void 0===o?void 0:o.toLowerCase().includes("plate"))}));if(0==a.length)return n;for(const e of a)try{const t=yield l.T6.fromExcelFileInfo(e),n=p.analysisView(t,{submitAction:()=>{i.shell.info("Plate Submitted")}}),a=o.View.fromRoot(n.root);a.name=e.name.substring(0,e.name.length-5),r.addView(a.name,(()=>a),!0)}catch(e){d._package.logger.error(e)}return setTimeout((()=>{const e=r.root.querySelector(".d4-tab-header-stripe");if(!e)return;e.style.overflow="scroll";const t=e.querySelectorAll(".d4-tab-header");null==t||t.forEach((e=>e.style.whiteSpace="nowrap"))}),300),r}))}},973:(e,t,n)=>{"use strict";n.d(t,{bP:()=>E,T6:()=>N,rH:()=>A});var o=n(82),r=n(328),i=n(389),a=n(991),l=n.n(a),s=n(358),u=n(71),c=n(999);class d{}class m{constructor(e,t){this.auc=e.auc,this.rSquared=e.rSquared,this.series=t}}class f extends m{get name(){return u.Ff}constructor(e,t){super(e,t),this.slope=e.slope,this.intercept=e.intercept}}class h extends f{get name(){return u.kx}}class p extends m{get name(){return u.G7}constructor(e,t){super(e,t),this.top=e.top,this.slope=e.slope,this.ic50=e.ic50,this.bottom=e.bottom}}class g extends m{get name(){return u.Pf}constructor(e,t){super(e,t),this.mantissa=e.mantissa,this.power=e.power}}class v extends m{get name(){return u.kC}constructor(e,t){super(e,t),this.top=e.top,this.bottom=e.bottom,this.slope=e.slope,this.ec50=e.ec50}}function C(e,t){return{auc:(0,u.Mi)(e,t),rSquared:(0,u.Hr)(e,t)}}const w={linear:new class extends d{get name(){return u.Ff}get parameterNames(){return["Slope","Intercept"]}fillParams(e,t){return new f({...C(e.fittedCurve,(0,c.Sm)(t)),slope:e.parameters[0],intercept:e.parameters[1]},t)}y(e,t){return(0,u.sn)(e,t)}getInitialParameters(e,t){let n=0,o=0;for(let t=1;t<e.length;t++)e[t]<e[n]&&(n=t),e[t]>e[o]&&(o=t);const r=e[o]-e[n],i=(t[o]-t[n])/r,a=t[o]-i*e[o],l=new Float32Array(2);return l.set([i,a]),l}},sigmoid:new class extends d{get name(){return u.G7}get parameterNames(){return["Top","Slope","IC50","Bottom"]}fillParams(e,t){return new p({...C(e.fittedCurve,(0,c.Sm)(t)),top:e.parameters[0],slope:e.parameters[1],ic50:e.parameters[2],bottom:e.parameters[3]},t)}y(e,t){return(0,u.ry)(e,t)}getInitialParameters(e,t){const n=o.Rect.fromXYArrays(e,t),r=(n.maxY-n.minY)/2+n.minY;let i=n.maxY-n.minY,a=0;for(let n=0;n<e.length;n++){const e=Math.abs(t[n]-r);e<i&&(i=e,a=n)}const l=e[a],s=t[0]>t[t.length-1]?1:-1,u=new Float32Array(4);return u.set([n.maxY,s,l,n.minY]),u}},"log-linear":new class extends d{get name(){return u.kx}get parameterNames(){return["Slope","Intercept"]}fillParams(e,t){return new h({...C(e.fittedCurve,(0,c.Sm)(t)),slope:e.parameters[0],intercept:e.parameters[1]},t)}y(e,t){return(0,u.AJ)(e,t)}getInitialParameters(e,t){const n=new Float32Array(2);return n.set([-5,100]),n}},exponential:new class extends d{get name(){return u.Pf}get parameterNames(){return["Mantissa","Power"]}fillParams(e,t){return new g({...C(e.fittedCurve,(0,c.Sm)(t)),mantissa:e.parameters[0],power:e.parameters[1]},t)}y(e,t){return(0,u.EV)(e,t)}getInitialParameters(e,t){const n=new Float32Array(2);return n.set([100,-2]),n}},"4pl-regression":new class extends d{get name(){return u.kC}get parameterNames(){return["Top","Slope","EC50","Bottom"]}fillParams(e,t){return new v({...C(e.fittedCurve,(0,c.Sm)(t)),top:e.parameters[0],slope:e.parameters[1],ec50:e.parameters[2],bottom:e.parameters[3]},t)}y(e,t){return(0,u.Sm)(e,t)}getInitialParameters(e,t){const n=new Float32Array(4),o=Math.min(...t),r=Math.max(...t),i=(r-o)/2+o;let a=r-o,l=0;for(let n=0;n<e.length;n++){const e=Math.abs(t[n]-i);e<a&&(a=e,l=n)}const s=e[l],u=t[0]>t[t.length-1]?-10:10;return n.set([r,u,s,o]),n}}};class T{constructor(e){this.series=e}linear(){return w[u.Ff].fillParams((0,c.nT)(this.series,w[u.Ff]),this.series)}logLinear(){return w[u.kx].fillParams((0,c.nT)(this.series,w[u.kx]),this.series)}sigmoid(){return w[u.G7].fillParams((0,c.nT)(this.series,w[u.G7]),this.series)}exponential(){return w[u.Pf].fillParams((0,c.nT)(this.series,w[u.Pf]),this.series)}fourPL(){return w[u.kC].fillParams((0,c.nT)(this.series,w[u.kC]),this.series)}}class _{constructor(e){this.points=e,this.fit=new T(this)}}new _([{x:0,y:0},{x:1,y:.5},{x:2,y:1},{x:3,y:10,outlier:!0},{x:4,y:0}]);var x=n(140),y=n(407),I=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function l(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}s((o=o.apply(e,t||[])).next())}))};const E="Outlier";function A(){return`${Math.random()}-${Math.random()}-${Math.random()}-${Math.random()}-${Math.random()}-${Math.random()}-${Math.random()}-${Math.random()}`}class N{constructor(e,t){this.rows=8,this.cols=12,this.data=o.DataFrame.create(e*t),this.rows=e,this.cols=t}static autoSize(e){const[t,n]=(0,s.au)((0,s.OQ)(e));return new N(t,n)}_idx(e,t){return e*this.cols+t}_markOutlier(e,t=!0){this.data.columns.getOrCreate(E,o.TYPE.BOOL).set(e,t)}markOutlier(e,t,n=!0){this._markOutlier(this._idx(e,t),n)}_isOutlier(e){return this.data.columns.getOrCreate(E,o.TYPE.BOOL).get(e)}isOutlier(e,t){return this._isOutlier(this._idx(e,t))}markOutliersWhere(e,t,n){this.values([e],n).forEach((n=>{t(n[e])&&this._markOutlier(n.innerDfRow,!0)}))}static fromTable(e,t){var n,r,i;const a=e.rowCount,u=l()(e.columns).filter((e=>!function(e){return e.type==o.TYPE.STRING&&o.range(a).every((t=>(0,s.JG)(t)==e.get(t).toUpperCase()))}(e))).toArray(),c=u.length,d=new N(a,c),m=u.filter((e=>e.stats.missingValueCount!=a)),f=m.length>0&&-1!=m.findIndex((e=>e.type!=m[0].type))?o.TYPE.STRING:null!==(r=null===(n=(0,s.U1)(u,(e=>e.stats.missingValueCount!=a)))||void 0===n?void 0:n.type)&&void 0!==r?r:o.TYPE.STRING,h=d.data.columns.addNew(null!==(i=e.name)&&void 0!==i?i:t,f);for(let e=0;e<u.length;e++)if(u[e].stats.missingValueCount!=a)for(let t=0;t<a;t++)h.set(d._idx(t,e),f!=o.TYPE.STRING?u[e].get(t):u[e].getString(t),!1);return d}static fromTableByRow(e,t){const n=l()(e.columns).find((e=>e.type==o.TYPE.STRING&&/^([A-Za-z]+)(\d+)$/.test(e.get(0))));if(!n)throw"Column with well positions not found";const[r,i]=(0,s.au)((0,s.OQ)(l()(n.values()).map(s.cx))),a=new N(r,i);for(const t of e.columns){if(t.isEmpty||t==n)continue;const e=a.data.columns.addNew(t.name,t.type);for(let o=0;o<t.length;o++){const[r,a]=(0,s.cx)(n.get(o));e.set(r*i+a,t.get(o),!1)}}return a}static fromCsvTableFile(e,t,n){return I(this,void 0,void 0,(function*(){return this.fromTable(yield r.dapi.files.readCsv(e,n),t)}))}static fromCsvTable(e,t,n){return this.fromTable(o.DataFrame.fromCsv(e,n),t)}static fromCsv(e,t){var n,r;const i=o.DataFrame.fromCsv(e);return o.range(i.rowCount).every((e=>i.col(0).get(e)==String.fromCharCode(65+e)))&&i.columns.remove(i.columns.byIndex(0).name),(13==i.columns.length||25==i.columns.length||49==i.columns.length&&(null===(n=i.col(i.columns.length-1))||void 0===n?void 0:n.isEmpty))&&i.columns.remove(i.columns.length-1),this.fromTable(i,null!==(r=null==t?void 0:t.field)&&void 0!==r?r:"value")}static fromPlates(e,t){(0,s.yO)(e.length>0,"Array is empty."),(0,s.yO)(e.every((t=>t.rows==e[0].rows&&t.cols==e[0].cols)),"Plate dimensions differ.");const n=e.reduce(((e,t)=>e?e.merge(t):t.clone()));return null!=t&&(n.data.name=t),n}static fromExcelFileInfo(e){return I(this,void 0,void 0,(function*(){return e.data&&e.data.length?yield N.fromExcel(e.data,e.friendlyName):yield N.fromExcelPath(e.fullPath,e.friendlyName)}))}static fromExcelPath(e,t){return I(this,void 0,void 0,(function*(){const n=yield r.dapi.files.readAsBytes(e);return this.fromExcel(n,t)}))}static fromExcel(e,t){return I(this,void 0,void 0,(function*(){yield o.Utils.loadJsCss(["/js/common/exceljs.min.js"]);const n=new window.ExcelJS.Workbook,r=function(e){const t=[],n="A".charCodeAt(0);return e.eachSheet((e=>{var o;if("desired outputs"===(null===(o=e.name)||void 0===o?void 0:o.toLowerCase()))return;const r=[];e.eachRow(((e,t)=>{r[t]=[],e.eachCell(((e,n)=>{r[t][n]=e.value}))}));let i=-1,a=-1,l=0;for(let e=1;e<r.length;e++){const t=r[e]||[];let n=0,o=-1;for(let e=1;e<t.length;e++)if("number"==typeof t[e]&&Number.isInteger(t[e])&&t[e]===n+1)0===n&&(o=e),n++;else if(n>0)break;if(n>=12){i=e,a=o,l=n;break}}let s=-1,u=-1,c=0;if(-1!==i)for(let e=1;e<a;e++){let t=0,o=-1;for(let a=i+1;a<r.length;a++){if(!r[a])continue;const i=r[a][e];if("string"==typeof i&&/^[A-Za-z]{1,2}$/.test(i)){const e=(t>25?"A":"")+String.fromCharCode(n+t%26);if((null==i?void 0:i.toLowerCase())!==(null==e?void 0:e.toLowerCase()))break;0===t&&(o=a),t++}else if(t>0)break}if(t>=8){s=e,u=o,c=t;break}}-1!==i&&-1!==s&&t.push({sheet:e,startRow:i,startCol:s,rows:c,cols:l})})),t}(yield n.xlsx.load(e));if(0==r.length)throw'Plates not found in "${excelPath}"';const i=r[0];if(!r.every((e=>e.rows==i.rows||e.cols==i.cols)))throw`Plate sizes differ in "${t}"`;return N.fromPlates(r.map((e=>function(e){const t=o.DataFrame.create(e.rows);for(let n=e.startCol+1;n<=e.startCol+e.cols;n++){const r=o.range(e.rows).map((t=>e.sheet.getCell(e.startRow+t+1,n).toString())).toArray();t.columns.add(o.Column.fromStrings(""+(n-e.startCol+1),r))}return N.fromTable(t,e.sheet.name)}(e))),t)}))}get wells(){const e=this;return function*(){for(let t=0;t<e.rows;t++)for(let n=0;n<e.cols;n++){const o={row:t,col:n};for(const r of e.data.columns)r.isNone(e._idx(t,n))||(o[r.name]=r.get(e._idx(t,n)));yield o}}()}get(e,t,n){if((0,s.yO)(null!=this.data.columns.byName(e),`Field does not exist: ${e}`),"number"==typeof t&&!n)throw"Column not defined";const[o,r]="string"==typeof t?(0,s.cx)(t):[t,n];return this.data.columns.byName(e).get(this._idx(o,r))}normalize(e,t,n=!1){const o=this.data.getCol(e),r=n?o:this.data.columns.addNewFloat(this.data.columns.getUnusedName(`${e}_normalized`));return r.init((e=>o.isNone(e)?null:t(o.get(e)))),r}matches(e,t){const n=this.data.columns,o=t.match?Object.entries(t.match).reduce(((e,[t,n])=>(e[t]=Array.isArray(n)?n:[n],e)),{}):null,r=t.exclude?Object.entries(t.exclude).reduce(((e,[t,n])=>(e[t]=Array.isArray(n)?n:[n],e)),{}):null;return!t||!o&&!r||Object.keys(null!=o?o:{}).filter((e=>n.contains(e))).every((t=>o[t].some((n=>this.data.columns.byName(t).get(e)===n))))&&Object.keys(null!=r?r:{}).filter((e=>n.contains(e))).every((t=>r[t].every((n=>this.data.columns.byName(t).get(e)!==n))))}count(e){if(!e)return this.rows*this.cols;let t=0;for(let n=0;n<this.rows*this.cols;n++)this.matches(n,e)&&t++;return t}values(e,t){var n;const o=e.map((e=>this.data.columns.byName(e)));(0,s.yO)(o.every((e=>null!=e)),`Field does not exist: ${e.find(((e,t)=>null==o[t]))}`);const r={};for(let t=0;t<e.length;t++)r[e[t]]=o[t];const i=[];for(let a=0;a<this.rows*this.cols;a++)if((null!==(n=null==t?void 0:t.includeEmpty)&&void 0!==n&&n||o.every((e=>!e.isNone(a))))&&(!t||this.matches(a,t))){const t=e.reduce(((e,t)=>(e[t]=r[t].isNone(a)?null:r[t].get(a),e)),{});t.innerDfRow=a,i.push(t)}return i}getStatistics(e,t,n){const o=this.fieldValues(e,n),r={};for(const e of t)r[e]=s.IB[e](o);return r}fieldValues(e,t){return this.values([e],t).map((t=>t[e]))}static inspectSeriesByName(e,t,n){t&&n&&N.inspectSeries(e[t],n)}static inspectSeries(e,t){var n;const i=null!==(n=null==e?void 0:e.name)&&void 0!==n?n:"Series";if(!e||!t)return;const a=o.Column.string("Curve",1);a.set(0,JSON.stringify({chartOptions:{logX:!0,title:i},series:[Object.assign(Object.assign({},e),{fit:void 0,fitFunction:t,clickToToggle:!0,droplines:["IC50"],name:i})]}),!1);const l=o.DataFrame.fromColumns([a]);l.name=i,l.id=A(),a.semType="fit",a.tags[o.Tags.CellRenderer]="fit";const s=o.Viewer.grid(l).cell("Curve",0);r.shell.windows.showContextPanel=!0,r.shell.o=s,(0,y.I4)(s,{width:480,height:370},!0)}doseResponseSeries(e){var t,n,o,r;const i={includeEmpty:null!==(t=null==e?void 0:e.includeEmpty)&&void 0!==t&&t,exclude:null!==(n=null==e?void 0:e.exclude)&&void 0!==n?n:{role:["High Control","Low Control"]}},a=null!==(o=null==e?void 0:e.concentration)&&void 0!==o?o:"concentration",l=null!==(r=null==e?void 0:e.value)&&void 0!==r?r:"value",s=this.values([a,l,...(null==e?void 0:e.groupBy)?[e.groupBy]:[]],i),u={};for(const t of s){const n=(null==e?void 0:e.groupBy)?t[e.groupBy]:"0";u[n]||(u[n]={x:[],y:[],meta:[],outlier:[]}),u[n].x.push(t[a]),u[n].y.push(t[l]),u[n].meta.push(t.innerDfRow),u[n].outlier.push(this._isOutlier(t.innerDfRow))}return Object.fromEntries(Object.entries(u).map((([e,t])=>{const n=new _(t.x.map(((e,n)=>({x:t.x[n],y:t.y[n],outlier:t.outlier[n],meta:t.meta[n]}))).sort(((e,t)=>e.x-t.x)));return n.name=e,[e,n]})))}getAnalysisDialog(e){i.dialog("Plate Analysis").add(x.Xe.analysisView(this,e)).showModal(!0)}getAnalysisView(e){const t=o.View.fromRoot(x.Xe.analysisView(this,e).root);return t.name="Plate Analysis",r.shell.addView(t)}merge(e){for(const t of e.data.columns)this.data.columns.add(t.clone());return this}clone(){const e=new N(this.rows,this.cols);return e.data=this.data.clone(),e}print(){for(const e of this.data.columns){console.log(),console.log(e.name),console.log(o.range(this.cols+1).map((e=>0==e?"":`${e}`)).toArray().join("\t"));for(let t=0;t<this.rows;t++)console.log((0,s.JG)(t)+"\t"+o.range(this.cols).map((n=>e.getString(this._idx(t,n)))).toArray().join(",\t"))}}}},358:(e,t,n)=>{"use strict";n.d(t,{Ei:()=>h,FH:()=>p,IB:()=>g,JG:()=>c,OQ:()=>m,U1:()=>u,au:()=>f,cx:()=>d,yO:()=>s});var o=n(82),r=n(973),i=n(991),a=n.n(i),l=n(572);function s(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function u(e,t){for(const n of e)if(t(n))return n;return null}function c(e){s(e>=0,"Column number cannot be negative"),s(e<701,"Column number too large - would require more than 2 letters");const t="A".charCodeAt(0);if(e<24)return String.fromCharCode(t+e);const n=Math.floor(e/26),o=e%26;return String.fromCharCode(t+n-1)+String.fromCharCode(t+o)}function d(e){const t=e.match(/^([A-Za-z]+)(\d+)$/);if(!t)throw new Error("Invalid cell format. Expected format like 'A3'.");return[function(e){let t=0;for(let n=0;n<e.length;n++)t=26*t+(e.charCodeAt(n)-64);return t-1}(t[1].toUpperCase()),parseInt(t[2])-1]}function m(e){return a()(e).reduce(((e,[t,n])=>[Math.max(e[0],t),Math.max(e[1],n)]),[0,0])}function f([e,t]){if(e<=8&&t<=12)return[8,12];if(e<=16&&t<=24)return[16,24];if(e<=32&&t<=48)return[32,48];throw`${e}x${t} exceeds maximum plate size 32x48`}function h(e){return e<=0?0:Math.log10(e)}function p(e,t){var n;if(!e||null==e.idx||e.idx<0||!e.table)return{};const i={},a=e.idx;for(const s of e.table.columns)if((null===(n=s.name)||void 0===n?void 0:n.toLowerCase())===(null===r.bP||void 0===r.bP?void 0:r.bP.toLowerCase())&&s.type===o.COLUMN_TYPE.BOOL&&t){const n=!s.isNone(a)&&s.get(a),o=document.createElement("input");o.type="checkbox",o.checked=o.value=n,o.onchange=n=>t(e.idx,o.checked),i[s.name]=o}else i[s.name]=s.isNone(a)?"No data":s.isNumerical&&s.type!==o.COLUMN_TYPE.DATE_TIME?0===(l=s.get(a))?"0":Math.abs(l)<.001?o.format(l,"scientific"):Math.abs(l)<1?o.format(l,"0.0000"):l:s.get(a);var l;return i}const g={mean:l.mean,median:l.median,std:l.stdev,min:l.min,max:l.max,meansqerr:l.meansqerr,geomean:l.geomean}},82:e=>{"use strict";e.exports=DG},328:e=>{"use strict";e.exports=grok},858:e=>{"use strict";e.exports=rxjs},389:e=>{"use strict";e.exports=ui},991:e=>{"use strict";e.exports=wu},234:()=>{}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={id:o,loaded:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.amdD=function(){throw new Error("define cannot be used indirect")},n.amdO={},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},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})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var o=n(48);curves=o})();
|
|
2
2
|
//# sourceMappingURL=package.js.map
|