@datagrok/curves 1.5.0 → 1.6.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/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 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,n)=>w(e,n,h,N.value)},P={onValueChanged:(t,n)=>w(e,n,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:()=>{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:()=>{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})();
2
2
  //# sourceMappingURL=package.js.map