@datagrok/curves 1.13.2 → 1.13.4

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.
Files changed (50) hide show
  1. package/.turbo/turbo-build.log +5 -7
  2. package/CHANGELOG.md +13 -1
  3. package/README.md +2 -2
  4. package/bdd/bdd.config.json +1 -0
  5. package/bdd/bindings/curves.ts +34 -0
  6. package/bdd/features/MISSING.md +18 -0
  7. package/bdd/features/data/curve-json-columns.feature +66 -0
  8. package/bdd/features/data/pzfx-files.feature +25 -0
  9. package/bdd/features/grid/curve-cells.feature +55 -0
  10. package/bdd/features/grid/curve-options.feature +52 -0
  11. package/bdd/features/grid/statistic-columns.feature +47 -0
  12. package/bdd/features/guides/INDEX.md +8 -0
  13. package/bdd/features/guides/curves-legend-cells.feature +37 -0
  14. package/bdd/features/guides/curves-legend.feature +42 -0
  15. package/bdd/features/viewers/curves-in-trellis.feature +90 -0
  16. package/bdd/features/viewers/multi-curve-viewer.feature +92 -0
  17. package/bdd/generated/data/curve-json-columns.test.ts +75 -0
  18. package/bdd/generated/data/pzfx-files.test.ts +50 -0
  19. package/bdd/generated/grid/curve-cells.test.ts +67 -0
  20. package/bdd/generated/grid/curve-options.test.ts +66 -0
  21. package/bdd/generated/grid/statistic-columns.test.ts +64 -0
  22. package/bdd/generated/guides/curves-legend-cells.test.ts +47 -0
  23. package/bdd/generated/guides/curves-legend.test.ts +48 -0
  24. package/bdd/generated/viewers/curves-in-trellis.test.ts +98 -0
  25. package/bdd/generated/viewers/multi-curve-viewer.test.ts +103 -0
  26. package/bdd/package.json +1 -0
  27. package/bdd/tsconfig.json +13 -0
  28. package/dist/package-test.js +16 -16
  29. package/dist/package-test.js.map +1 -1
  30. package/dist/package.js +1 -1
  31. package/dist/package.js.map +1 -1
  32. package/package.json +10 -3
  33. package/src/fit/fit-grid-cell-handler.ts +29 -4
  34. package/src/fit/fit-interaction.ts +15 -9
  35. package/src/fit/fit-legend.ts +35 -9
  36. package/src/fit/fit-renderer.ts +24 -9
  37. package/src/fit/multi-curve-viewer.ts +82 -19
  38. package/src/package.g.ts +1 -0
  39. package/src/package.ts +1 -1
  40. package/src/tests/calculated-columns-tests.ts +3 -3
  41. package/src/tests/curve-data.ts +5 -1
  42. package/src/tests/curves-cell-renderer-tests.ts +10 -10
  43. package/src/tests/detector-tests.ts +26 -0
  44. package/src/tests/legend-tests.ts +24 -1
  45. package/src/tests/multi-curve-viewer-tests.ts +90 -17
  46. package/src/tests/panel-renderer-tests.ts +75 -30
  47. package/src/tests/project-tests.ts +30 -12
  48. package/test-console-output-1.log +193 -169
  49. package/test-record-1.mp4 +0 -0
  50. package/webpack.config.js +3 -0
package/dist/package.js CHANGED
@@ -1,2 +1,2 @@
1
- var curves;(()=>{var e={353(e){e.exports=function(){var e=function(e){var t=Array.prototype.concat,n=Array.prototype.slice,r=Object.prototype.toString;function o(t,n){var r=t>n?t:n;return e.pow(10,17-~~(e.log(r>0?r:-r)*e.LOG10E))}var l=Array.isArray||function(e){return"[object Array]"===r.call(e)};function i(e){return"[object Function]"===r.call(e)}function a(e){return"number"==typeof e&&e-e==0}function u(){return new u._init(arguments)}function s(){return 0}function c(){return 1}function f(e,t){return+(e===t)}u.fn=u.prototype,u._init=function(e){if(l(e[0]))if(l(e[0][0])){i(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]=i(e[1])?u.map(e[0],e[1]):e[0],this.length=1;else if(a(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:o,isArray:l,isFunction:i,isNumber:a,toVector:function(e){return t.apply([],e)}},u._random_fn=e.random,u.setRandom=function(e){if("function"!=typeof e)throw 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 l(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(l(t)){var n=u.arange(e.length).map(function(){return 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=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=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=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,a=[];for(l(e[0])||(e=[e]),n=e.length,r=e[0].length,i=0;i<r;i++){for(o=0,t=Array(n);o<n;o++)t[o]=e[o][i];a.push(t)}return 1===a.length?a[0]:a},u.map=function(e,t,n){var r,o,i,a,u;for(l(e[0])||(e=[e]),o=e.length,i=e[0].length,a=n?e:Array(o),r=0;r<o;r++)for(a[r]||(a[r]=Array(i)),u=0;u<i;u++)a[r][u]=t(e[r][u],r,u);return 1===a.length?a[0]:a},u.cumreduce=function(e,t,n){var r,o,i,a,u;for(l(e[0])||(e=[e]),o=e.length,i=e[0].length,a=n?e:Array(o),r=0;r<o;r++)for(a[r]||(a[r]=Array(i)),i>0&&(a[r][0]=e[r][0]),u=1;u<i;u++)a[r][u]=t(a[r][u-1],e[r][u]);return 1===a.length?a[0]:a},u.alter=function(e,t){return u.map(e,t,!0)},u.create=function(e,t,n){var r,o,l=Array(e);for(i(t)&&(n=t,t=e),r=0;r<e;r++)for(o=0,l[r]=Array(t);o<t;o++)l[r][o]=n(r,o);return l},u.zeros=function(e,t){return a(t)||(t=e),u.create(e,t,s)},u.ones=function(e,t){return a(t)||(t=e),u.create(e,t,c)},u.rand=function(e,t){return a(t)||(t=e),u.create(e,t,u._random_fn)},u.identity=function(e,t){return a(t)||(t=e),u.create(e,t,f)},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,s)},u.seq=function(e,t,n,r){i(r)||(r=!1);var l,a=[],u=o(e,t),s=(t*u-e*u)/((n-1)*u),c=e;for(l=0;c<=t&&l<n;c=(e*u+s*u*++l)/u)a.push(r?r(c,l):c);return a},u.arange=function(e,t,n){var r,o=[];if(n=n||1,void 0===t&&(t=e,e=0),e===t||0===n||e<t&&n<0||e>t&&n>0)return[];if(n>0)for(r=e;r<t;r+=n)o.push(r);else for(r=e;r>t;r+=n)o.push(r);return o},u.slice=function(){function e(e,t,n,r){var o,l=[],i=e.length;if(void 0===t&&void 0===n&&void 0===r)return u.copy(e);if(t=t||0,n=n||e.length,r=r||1,(t=t>=0?t:i+t)===(n=n>=0?n:i+n)||0===r||t<n&&r<0||t>n&&r>0)return[];if(r>0)for(o=t;o<n;o+=r)l.push(e[o]);else for(o=t;o>n;o+=r)l.push(e[o]);return l}return function(t,n){if(a((n=n||{}).row)){var r,o;if(a(n.col))return t[n.row][n.col];return e(u.rowa(t,n.row),(r=n.col||{}).start,r.end,r.step)}return a(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(t,n,r){var o,l;if(a(n.row)){if(a(n.col))return t[n.row][n.col]=r;n.col=n.col||{},n.col.start=n.col.start||0,n.col.end=n.col.end||t[0].length,n.col.step=n.col.step||1,o=u.arange(n.col.start,e.min(t.length,n.col.end),n.col.step);var i=n.row;return o.forEach(function(e,n){t[i][e]=r[n]}),t}if(a(n.col)){n.row=n.row||{},n.row.start=n.row.start||0,n.row.end=n.row.end||t.length,n.row.step=n.row.step||1,l=u.arange(n.row.start,e.min(t[0].length,n.row.end),n.row.step);var s=n.col;return l.forEach(function(e,n){t[e][s]=r[n]}),t}return void 0===r[0].length&&(r=[r]),n.row.start=n.row.start||0,n.row.end=n.row.end||t.length,n.row.step=n.row.step||1,n.col.start=n.col.start||0,n.col.end=n.col.end||t[0].length,n.col.step=n.col.step||1,l=u.arange(n.row.start,e.min(t.length,n.row.end),n.row.step),o=u.arange(n.col.start,e.min(t[0].length,n.col.end),n.col.step),l.forEach(function(e,n){o.forEach(function(o,l){t[e][o]=r[n][l]})}),t},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 a(e)?e:e.map(function(e){return e})})};var d=u.prototype;d.length=0,d.push=Array.prototype.push,d.sort=Array.prototype.sort,d.splice=Array.prototype.splice,d.slice=Array.prototype.slice,d.toArray=function(){return this.length>1?n.call(this):n.call(this)[0]},d.map=function(e,t){return u(u.map(this,e,t))},d.cumreduce=function(e,t){return u(u.cumreduce(this,e,t))},d.alter=function(e){return u.alter(this,e),this};for(var m="transpose clear symmetric rows cols dimensions diag antidiag".split(" "),p=0;p<m.length;p++)!function(e){d[e]=function(t){var n,r=this;return t?(setTimeout(function(){t.call(r,d[e].call(r))}),this):l(n=u[e](this))?u(n):n}}(m[p]);for(var h="row col".split(" "),g=0;g<h.length;g++)!function(e){d[e]=function(t,n){var r=this;return n?(setTimeout(function(){n.call(r,d[e].call(r,t))}),this):u(u[e](this,t))}}(h[g]);for(var v="create zeros ones rand identity".split(" "),y=0;y<v.length;y++)!function(e){d[e]=function(){return u(u[e].apply(null,arguments))}}(v[y]);return 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,l=t.length;--l>=0;)o+=(n=t[l]-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++){var l=e[t];o[l]?o[l]++:(o[l]=1,n.push(l))}var i=n.sort(r),a={},u=1;for(t=0;t<i.length;t++){var l=i[t],s=o[l],c=(u+(u+s-1))/2;a[l]=c,u+=s}return e.map(function(e){return a[e]})},e.mode=function(e){var t,n=e.length,o=e.slice().sort(r),l=1,i=0,a=0,u=[];for(t=0;t<n;t++)o[t]===o[t+1]?l++:(l>i?(u=[o[t]],i=l,a=0):l===i&&(u.push(o[t]),a++),l=1);return 0===a?u[0]:u},e.range=function(t){return e.max(t)-e.min(t)},e.variance=function(t,n){return e.sumsqerr(t)/(t.length-!!n)},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=Array(r),l=0;l<r;l++)o[l]=t[l]-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=[],l=n.length-1;l>=0;l--)o.push(t.abs(n[l]-r));return e.mean(o)},e.meddev=function(n){for(var r=e.median(n),o=[],l=n.length-1;l>=0;l--)o.push(t.abs(n[l]-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,l,i){var a,u,s,c,f,d,m=e.slice().sort(r),p=[n.length],h=e.length;for(void 0===l&&(l=3/8),void 0===i&&(i=3/8),a=0;a<n.length;a++)s=l+(u=n[a])*(1-l-i),c=h*u+s,f=t.floor(o(c,1,h-1)),d=o(c-f,0,1),p[a]=(1-d)*m[f-1]+d*m[f];return p},e.percentile=function(e,t,n){var o=e.slice().sort(r),l=t*(o.length+(n?1:-1))+ +!n,i=parseInt(l);return i+1<o.length?o[i-1]+(l-i)*(o[i]-o[i-1]):o[i-1]},e.percentileOfScore=function(e,t,n){var r,o,l=0,i=e.length,a=!1;for("strict"===n&&(a=!0),o=0;o<i;o++)r=e[o],(a&&r<t||!a&&r<=t)&&l++;return l/i},e.histogram=function(n,r){r=r||4;var o,l=e.min(n),i=(e.max(n)-l)/r,a=n.length,u=[];for(o=0;o<r;o++)u[o]=0;for(o=0;o<a;o++)u[t.min(t.floor((n[o]-l)/i),r-1)]+=1;return u},e.covariance=function(t,n){var r,o=e.mean(t),l=e.mean(n),i=t.length,a=Array(i);for(r=0;r<i;r++)a[r]=(t[r]-o)*(n[r]-l);return e.sum(a)/(i-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),l=e.stdev(n),i=n.length,a=0,u=0;u<i;u++)a+=t.pow((n[u]-o)/l,r);return a/n.length},e.skewness=function(t){return e.stanMoment(t,3)},e.kurtosis=function(t){return e.stanMoment(t,4)-3};for(var l=e.prototype,i="cumsum cumprod".split(" "),a=0;a<i.length;a++)!function(t){l[t]=function(r,o){var i=[],a=0,u=this;if(n(r)&&(o=r,r=!1),o)return setTimeout(function(){o.call(u,l[t].call(u,r))}),this;if(this.length>1){for(u=!0===r?this:this.transpose();a<u.length;a++)i[a]=e[t](u[a]);return i}return e[t](this[0],r)}}(i[a]);for(var u="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(" "),s=0;s<u.length;s++)!function(t){l[t]=function(r,o){var i=[],a=0,u=this;if(n(r)&&(o=r,r=!1),o)return setTimeout(function(){o.call(u,l[t].call(u,r))}),this;if(this.length>1){for("sumrow"!==t&&(u=!0===r?this:this.transpose());a<u.length;a++)i[a]=e[t](u[a]);return!0===r?e[t](e.utils.toVector(i)):i}return e[t](this[0],r)}}(u[s]);for(var c="quantiles percentileOfScore".split(" "),f=0;f<c.length;f++)!function(t){l[t]=function(){var r,o=[],i=0,a=this,u=Array.prototype.slice.call(arguments);if(n(u[u.length-1])){r=u[u.length-1];var s=u.slice(0,u.length-1);return setTimeout(function(){r.call(a,l[t].apply(a,s))}),this}r=void 0;var c=function(n){return e[t].apply(a,[n].concat(u))};if(this.length>1){for(a=a.transpose();i<a.length;i++)o[i]=c(a[i]);return o}return c(this[0])}}(c[f])}(e,Math);var t=Math;e.gammaln=function(e){var n,r,o=0,l=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],i=1.000000000190015;for(r=(n=e)+5.5,r-=(e+.5)*t.log(r);o<6;o++)i+=l[o]/++n;return t.log(2.5066282746310007*i/e)-r},e.loggam=function(e){var n,r,o,l,i,a,u,s=[.08333333333333333,-.002777777777777778,7936507936507937e-19,-5952380952380952e-19,8417508417508418e-19,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=e,u=0,1==e||2==e)return 0;for(e<=7&&(u=t.floor(7-e),n=e+u),r=1/(n*n),o=2*t.PI,i=s[9],a=8;a>=0;a--)i*=r,i+=s[a];if(l=i/n+.5*t.log(o)+(n-.5)*t.log(n)-n,e<=7)for(a=1;a<=u;a++)l-=t.log(n-1),n-=1;return l},e.gammafn=function(e){var n,r,o,l,i=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],a=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],u=!1,s=0,c=0,f=0,d=e;if(e>171.6243769536076)return 1/0;if(d<=0){if(!(l=d%1+36e-17))return 1/0;u=(1&d?-1:1)*t.PI/t.sin(t.PI*l),d=1-d}for(n=0,o=d,r=d<1?d++:(d-=s=(0|d)-1)-1;n<8;++n)f=(f+i[n])*r,c=c*r+a[n];if(l=f/c+1,o<d)l/=o;else if(o>d)for(n=0;n<s;++n)l*=d,d++;return u&&(l=u/l),l},e.gammap=function(t,n){return e.lowRegGamma(t,n)*e.gammafn(t)},e.lowRegGamma=function(n,r){var o,l=e.gammaln(n),i=n,a=1/n,u=a,s=r+1-n,c=1/1e-30,f=1/s,d=f,m=1,p=-~(8.5*t.log(n>=1?n:1/n)+.4*n+17);if(r<0||n<=0)return NaN;if(r<n+1){for(;m<=p;m++)a+=u*=r/++i;return a*t.exp(-r+n*t.log(r)-l)}for(;m<=p;m++)s+=2,d*=(f=1/(f=(o=-m*(m-n))*f+s))*(c=s+o/c);return 1-d*t.exp(-r+n*t.log(r)-l)},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,l,i,a,u=1,s=n+r,c=n+1,f=n-1,d=1,m=1-s*e/c;for(1e-30>t.abs(m)&&(m=1e-30),a=m=1/m;u<=100&&(o=2*u,m=1+(l=u*(r-u)*e/((f+o)*(n+o)))*m,1e-30>t.abs(m)&&(m=1e-30),d=1+l/d,1e-30>t.abs(d)&&(d=1e-30),a*=(m=1/m)*d,m=1+(l=-(n+u)*(s+u)*e/((n+o)*(c+o)))*m,1e-30>t.abs(m)&&(m=1e-30),d=1+l/d,1e-30>t.abs(d)&&(d=1e-30),a*=i=(m=1/m)*d,!(3e-7>t.abs(i-1)));u++);return a},e.gammapinv=function(n,r){var o,l,i,a,u,s=0,c=r-1,f=e.gammaln(r);if(n>=1)return t.max(100,r+100*t.sqrt(r));if(n<=0)return 0;for(r>1?(a=t.log(c),u=t.exp(c*(a-1)-f),o=(2.30753+.27061*(l=t.sqrt(-2*t.log(n<.5?n:1-n))))/(1+l*(.99229+.04481*l))-l,n<.5&&(o=-o),o=t.max(.001,r*t.pow(1-1/(9*r)-o/(3*t.sqrt(r)),3))):o=n<(l=1-r*(.253+.12*r))?t.pow(n/l,1/r):1-t.log(1-(n-l)/(1-l));s<12;s++){if(o<=0)return 0;if(i=(e.lowRegGamma(r,o)-n)/(l=r>1?u*t.exp(-(o-c)+c*(t.log(o)-a)):t.exp(-o+c*t.log(o)-f)),(o-=l=i/(1-.5*t.min(1,i*((r-1)/o-1))))<=0&&(o=.5*(o+l)),t.abs(l)<1e-8*o)break}return o},e.erf=function(e){var n,r,o,l,i=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-946595344482036e-18,366839497852761e-18,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],a=i.length-1,u=!1,s=0,c=0;for(e<0&&(e=-e,u=!0),r=4*(n=2/(2+e))-2;a>0;a--)o=s,s=r*s-c+i[a],c=o;return l=n*t.exp(-e*e+.5*(i[0]+r*s)-c),u?l-1:1-l},e.erfc=function(t){return 1-e.erf(t)},e.erfcinv=function(n){var r,o,l,i,a=0;if(n>=2)return -100;if(n<=0)return 100;for(i=n<1?n:2-n,r=-.70711*((2.30753+.27061*(l=t.sqrt(-2*t.log(i/2))))/(1+l*(.99229+.04481*l))-l);a<2;a++)o=e.erfc(r)-i,r+=o/(1.1283791670955126*t.exp(-r*r)-r*o);return n<1?r:-r},e.ibetainv=function(n,r,o){var l,i,a,u,s,c,f,d,m,p=r-1,h=o-1,g=0;if(n<=0)return 0;if(n>=1)return 1;for(r>=1&&o>=1?(s=(2.30753+.27061*(a=t.sqrt(-2*t.log(n<.5?n:1-n))))/(1+a*(.99229+.04481*a))-a,n<.5&&(s=-s),c=(s*s-3)/6,f=2/(1/(2*r-1)+1/(2*o-1)),d=s*t.sqrt(c+f)/f-(1/(2*o-1)-1/(2*r-1))*(c+5/6-2/(3*f)),s=r/(r+o*t.exp(2*d))):(l=t.log(r/(r+o)),i=t.log(o/(r+o)),d=(a=t.exp(r*l)/r)+(u=t.exp(o*i)/o),s=n<a/d?t.pow(r*d*n,1/r):1-t.pow(o*d*(1-n),1/o)),m=-e.gammaln(r)-e.gammaln(o)+e.gammaln(r+o);g<10&&0!==s&&1!==s&&(u=(e.ibeta(s,r,o)-n)/(a=t.exp(p*t.log(s)+h*t.log(1-s)+m)),(s-=a=u/(1-.5*t.min(1,u*(p/s-h/(1-s)))))<=0&&(s=.5*(s+a)),s>=1&&(s=.5*(s+a+1)),!(t.abs(a)<1e-8*s)||!(g>0));g++);return s},e.ibeta=function(n,r,o){var l=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)?l*e.betacf(n,r,o)/r:1-l*e.betacf(1-n,o,r)/o)},e.randn=function(n,r){var o,l,i,a,u;if(r||(r=n),n)return e.create(n,r,function(){return e.randn()});do o=e._random_fn(),l=1.7156*(e._random_fn()-.5),u=(i=o-.449871)*i+(a=t.abs(l)+.386595)*(.196*a-.25472*i);while(u>.27597&&(u>.27846||l*l>-4*t.log(o)*o*o));return l/o},e.randg=function(n,r,o){var l,i,a,u,s,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),l=n-1/3,i=1/t.sqrt(9*l);do{do u=1+i*(s=e.randn());while(u<=0);u=u*u*u,a=e._random_fn()}while(a>1-.331*t.pow(s,4)&&t.log(a)>.5*s*s+l*(1-u+t.log(u)));if(n==f)return l*u;do a=e._random_fn();while(0===a);return t.pow(a,1/f)*l*u};for(var n="gammaln gammafn factorial factorialln".split(" "),r=0;r<n.length;r++)!function(t){e.fn[t]=function(){return e(e.map(this,function(n){return e[t](n)}))}}(n[r]);for(var o="randn".split(" "),l=0;l<o.length;l++)!function(t){e.fn[t]=function(){return e(e[t].apply(null,arguments))}}(o[l]);for(var i=Math,a="beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" "),u=0;u<a.length;u++)!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 l=e[t](n,r,o);return l.data=this,l},e[t].prototype.sample=function(n){var r=this._a,o=this._b,l=this._c;return n?e.alter(n,function(){return e[t].sample(r,o,l)}):e[t].sample(r,o,l)};for(var n="pdf cdf inv".split(" "),r=0;r<n.length;r++)!function(n){e[t].prototype[n]=function(r){var o=this._a,l=this._b,i=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,l,i)}):e[t][n](r,o,l,i)}}(n[r]);for(var o="mean median mode variance".split(" "),l=0;l<o.length;l++)!function(n){e[t].prototype[n]=function(){return e[t][n](this._a,this._b,this._c)}}(o[l])}(a[u]);function s(e,t,n,r){for(var o,l=0,a=1,u=1,s=1,c=0,f=0;i.abs((u-f)/u)>r;)f=u,l=u+(o=-(t+c)*(t+n+c)*e/(t+2*c)/(t+2*c+1))*l,a=s+o*a,c+=1,u=l+(o=c*(n-c)*e/(t+2*c-1)/(t+2*c))*u,l/=s=a+o*s,a/=s,u/=s,s=1;return u/t}function c(t,n,r){var o=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],l=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],a=.5*t;if(a>=8)return 1;var u=2*e.normal.cdf(a,0,1,1,0)-1;u=u>=i.exp(-50/r)?i.pow(u,r):0;for(var s=a,c=(8-a)/(C=t>3?2:3),f=s+c,d=0,m=r-1,p=1;p<=C;p++){for(var h=0,g=.5*(f+s),v=.5*(f-s),y=1;y<=12;y++){var C,b,w=g+v*(6<y?o[(b=12-y+1)-1]:-o[(b=y)-1]),x=w*w;if(x>60)break;var T=.5*(2*e.normal.cdf(w,0,1,1,0))-.5*(2*e.normal.cdf(w,t,1,1,0));T>=i.exp(-30/m)&&(h+=T=l[b-1]*i.exp(-(.5*x))*i.pow(T,m))}h*=2*v*r/i.sqrt(2*i.PI),d+=h,s=f,f+=c}return(u+=d)<=i.exp(-30/n)?0:(u=i.pow(u,n))>=1?1:u}e.extend(e.beta,{pdf:function(t,n,r){return t>1||t<0?0:1==n&&1==r?1:n<512&&r<512?i.pow(t,n-1)*i.pow(1-t,r-1)/e.betafn(n,r):i.exp((n-1)*i.log(t)+(r-1)*i.log(1-t)-e.betaln(n,r))},cdf:function(t,n,r){return t>1||t<0?(t>1)*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,t){return e*t/(i.pow(e+t,2)*(e+t+1))}}),e.extend(e.centralF,{pdf:function(t,n,r){var o;return t<0?0:n<=2?0===t&&n<2?1/0:0===t&&2===n?1:1/e.betafn(n/2,r/2)*i.pow(n/r,n/2)*i.pow(t,n/2-1)*i.pow(1+n/r*t,-(n+r)/2):(o=r/(r+t*n),n*o/2*e.binomial.pdf((n-2)/2,(n+r-2)/2,n*t/(r+t*n)))},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,t,n){return n<0?0:n/(i.pow(e-t,2)+i.pow(n,2))/i.PI},cdf:function(e,t,n){return i.atan((e-t)/n)/i.PI+.5},inv:function(e,t,n){return t+n*i.tan(i.PI*(e-.5))},median:function(e){return e},mode:function(e){return e},sample:function(t,n){return e.randn()*i.sqrt(1/(2*e.randg(.5)))*n+t}}),e.extend(e.chisquare,{pdf:function(t,n){return t<0?0:0===t&&2===n?.5:i.exp((n/2-1)*i.log(t)-t/2-n/2*i.log(2)-e.gammaln(n/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*i.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,t){return e<0?0:t*i.exp(-t*e)},cdf:function(e,t){return e<0?0:1-i.exp(-t*e)},inv:function(e,t){return-i.log(1-e)/t},mean:function(e){return 1/e},median:function(e){return 1/e*i.log(2)},mode:function(){return 0},sample:function(t){return -1/t*i.log(e._random_fn())},variance:function(e){return i.pow(e,-2)}}),e.extend(e.gamma,{pdf:function(t,n,r){return t<0?0:0===t&&1===n?1/r:i.exp((n-1)*i.log(t)-t/r-e.gammaln(n)-n*i.log(r))},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(t,n,r){return t<=0?0:i.exp(-(n+1)*i.log(t)-r/t-e.gammaln(n)+n*i.log(r))},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,t,n){return 0===e&&1===t?n:1===e&&1===n?t:i.exp(i.log(t)+i.log(n)+(t-1)*i.log(e)+(n-1)*i.log(1-i.pow(e,t)))},cdf:function(e,t,n){return e<0?0:e>1?1:1-i.pow(1-i.pow(e,t),n)},inv:function(e,t,n){return i.pow(1-i.pow(1-e,1/n),1/t)},mean:function(t,n){return n*e.gammafn(1+1/t)*e.gammafn(n)/e.gammafn(1+1/t+n)},median:function(e,t){return i.pow(1-i.pow(2,-1/t),1/e)},mode:function(e,t){if(e>=1&&t>=1&&1!==e&&1!==t)return i.pow((e-1)/(e*t-1),1/e)},variance:function(){throw Error("variance not yet implemented")}}),e.extend(e.lognormal,{pdf:function(e,t,n){return e<=0?0:i.exp(-i.log(e)-.5*i.log(2*i.PI)-i.log(n)-i.pow(i.log(e)-t,2)/(2*n*n))},cdf:function(t,n,r){return t<0?0:.5+.5*e.erf((i.log(t)-n)/i.sqrt(2*r*r))},inv:function(t,n,r){return i.exp(-1.4142135623730951*r*e.erfcinv(2*t)+n)},mean:function(e,t){return i.exp(e+t*t/2)},median:function(e){return i.exp(e)},mode:function(e,t){return i.exp(e-t*t)},sample:function(t,n){return i.exp(e.randn()*n+t)},variance:function(e,t){return(i.exp(t*t)-1)*i.exp(2*e+t*t)}}),e.extend(e.noncentralt,{pdf:function(t,n,r){return 1e-14>i.abs(r)?e.studentt.pdf(t,n):1e-14>i.abs(t)?i.exp(e.gammaln((n+1)/2)-r*r/2-.5*i.log(i.PI*n)-e.gammaln(n/2)):n/t*(e.noncentralt.cdf(t*i.sqrt(1+2/n),n+2,r)-e.noncentralt.cdf(t,n,r))},cdf:function(t,n,r){if(1e-14>i.abs(r))return e.studentt.cdf(t,n);var o=!1;t<0&&(o=!0,r=-r);for(var l=e.normal.cdf(-r,0,1),a=1e-14+1,u=1e-14+1,s=t*t/(t*t+n),c=0,f=i.exp(-r*r/2),d=i.exp(-r*r/2-.5*i.log(2)-e.gammaln(1.5))*r;c<200||u>1e-14||a>1e-14;)u=a,c>0&&(f*=r*r/(2*c),d*=r*r/(2*(c+.5))),l+=.5*(a=f*e.beta.cdf(s,c+.5,n/2)+d*e.beta.cdf(s,c+1,n/2)),c++;return o?1-l:l}}),e.extend(e.normal,{pdf:function(e,t,n){return i.exp(-.5*i.log(2*i.PI)-i.log(n)-i.pow(e-t,2)/(2*n*n))},cdf:function(t,n,r){return .5*(1+e.erf((t-n)/i.sqrt(2*r*r)))},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,t,n){return e<t?0:n*i.pow(t,n)/i.pow(e,n+1)},cdf:function(e,t,n){return e<t?0:1-i.pow(t/e,n)},inv:function(e,t,n){return t/i.pow(1-e,1/n)},mean:function(e,t){if(!(t<=1))return t*i.pow(e,t)/(t-1)},median:function(e,t){return e*(t*i.SQRT2)},mode:function(e){return e},variance:function(e,t){if(!(t<=2))return e*e*t/(i.pow(t-1,2)*(t-2))}}),e.extend(e.studentt,{pdf:function(t,n){return n=n>1e100?1e100:n,1/(i.sqrt(n)*e.betafn(.5,n/2))*i.pow(1+t*t/n,-((n+1)/2))},cdf:function(t,n){var r=n/2;return e.ibeta((t+i.sqrt(t*t+n))/(2*i.sqrt(t*t+n)),r,r)},inv:function(t,n){var r=e.ibetainv(2*i.min(t,1-t),.5*n,.5);return r=i.sqrt(n*(1-r)/r),t>.5?r:-r},mean:function(e){return e>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(t){return e.randn()*i.sqrt(t/(2*e.randg(t/2)))},variance:function(e){return e>2?e/(e-2):e>1?1/0:void 0}}),e.extend(e.weibull,{pdf:function(e,t,n){return e<0||t<0||n<0?0:n/t*i.pow(e/t,n-1)*i.exp(-i.pow(e/t,n))},cdf:function(e,t,n){return e<0?0:1-i.exp(-i.pow(e/t,n))},inv:function(e,t,n){return t*i.pow(-i.log(1-e),1/n)},mean:function(t,n){return t*e.gammafn(1+1/n)},median:function(e,t){return e*i.pow(i.log(2),1/t)},mode:function(e,t){return t<=1?0:e*i.pow((t-1)/t,1/t)},sample:function(t,n){return t*i.pow(-i.log(e._random_fn()),1/n)},variance:function(t,n){return t*t*e.gammafn(1+2/n)-i.pow(e.weibull.mean(t,n),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 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,t){return i.pow(t-e,2)/12}}),e.extend(e.binomial,{pdf:function(t,n,r){return 0===r||1===r?+(n*r===t):e.combination(n,t)*i.pow(r,t)*i.pow(1-r,n-t)},cdf:function(t,n,r){if(t<0)return 0;if(t>=n)return 1;if(r<0||r>1||n<=0)return NaN;var o,l=(t=i.floor(t))+1,a=n-t,u=l+a,c=i.exp(e.gammaln(u)-e.gammaln(a)-e.gammaln(l)+l*i.log(r)+a*i.log(1-r));return o=r<(l+1)/(u+2)?c*s(r,l,a,1e-10):1-c*s(1-r,a,l,1e-10),i.round(1e10*(1-o))/1e10}}),e.extend(e.negbin,{pdf:function(t,n,r){return t===t>>>0&&(t<0?0:e.combination(t+n-1,n-1)*i.pow(1-r,t)*i.pow(r,n))},cdf:function(t,n,r){var o=0,l=0;if(t<0)return 0;for(;l<=t;l++)o+=e.negbin.pdf(l,n,r);return o}}),e.extend(e.hypgeom,{pdf:function(t,n,r,o){if(t!=t|0)return!1;if(t<0||t<r-(n-o))return 0;if(t>o||t>r)return 0;if(2*r>n)if(2*o>n)return e.hypgeom.pdf(n-r-o+t,n,n-r,n-o);else return e.hypgeom.pdf(o-t,n,n-r,o);if(2*o>n)return e.hypgeom.pdf(r-t,n,r,n-o);if(r<o)return e.hypgeom.pdf(t,n,o,r);for(var l=1,a=0,u=0;u<t;u++){for(;l>1&&a<o;)l*=1-r/(n-a),a++;l*=(o-u)*(r-u)/((u+1)*(n-r-o+u+1))}for(;a<o;a++)l*=1-r/(n-a);return i.min(1,i.max(0,l))},cdf:function(t,n,r,o){if(t<0||t<r-(n-o))return 0;if(t>=o||t>=r)return 1;if(2*r>n)if(2*o>n)return e.hypgeom.cdf(n-r-o+t,n,n-r,n-o);else return 1-e.hypgeom.cdf(o-t-1,n,n-r,o);if(2*o>n)return 1-e.hypgeom.cdf(r-t-1,n,r,n-o);if(r<o)return e.hypgeom.cdf(t,n,o,r);for(var l=1,a=1,u=0,s=0;s<t;s++){for(;l>1&&u<o;){var c=1-r/(n-u);a*=c,l*=c,u++}a*=(o-s)*(r-s)/((s+1)*(n-r-o+s+1)),l+=a}for(;u<o;u++)l*=1-r/(n-u);return i.min(1,i.max(0,l))}}),e.extend(e.poisson,{pdf:function(t,n){return n<0||t%1!=0||t<0?0:i.pow(n,t)*i.exp(-n)/e.factorial(t)},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(t){var n=1,r=0,o=i.exp(-t);do r++,n*=e._random_fn();while(n>o);return r-1},sampleLarge:function(t){var n,r,o,l,a,u,s,c,f,d;for(l=i.sqrt(t),a=i.log(t),u=-.059+.02483*(s=.931+2.53*l),c=1.1239+1.1328/(s-3.4),f=.9277-3.6224/(s-2);;){if(r=i.random()-.5,o=i.random(),d=.5-i.abs(r),n=i.floor((2*u/d+s)*r+t+.43),d>=.07&&o<=f)return n;if(!(n<0)&&(!(d<.013)||!(o>d))&&i.log(o)+i.log(c)-i.log(u/(d*d)+s)<=-t+n*a-e.loggam(n+1))return n}},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,t,n,r){return n<=t||r<t||r>n?NaN:e<=t?0:e>=n?1:e<=r?i.pow(e-t,2)/((n-t)*(r-t)):1-i.pow(n-e,2)/((n-t)*(n-r))},inv:function(e,t,n,r){return n<=t||r<t||r>n?NaN:e<=(r-t)/(n-t)?t+(n-t)*i.sqrt((r-t)/(n-t)*e):t+(n-t)*(1-i.sqrt((1-e)*(1-(r-t)/(n-t))))},mean:function(e,t,n){return(e+t+n)/3},median:function(e,t,n){return n<=(e+t)/2?t-i.sqrt((t-e)*(t-n))/i.sqrt(2):n>(e+t)/2?e+i.sqrt((t-e)*(n-e))/i.sqrt(2):void 0},mode:function(e,t,n){return n},sample:function(t,n,r){var o=e._random_fn();return o<(r-t)/(n-t)?t+i.sqrt(o*(n-t)*(r-t)):n-i.sqrt((1-o)*(n-t)*(n-r))},variance:function(e,t,n){return(e*e+t*t+n*n-e*t-e*n-t*n)/18}}),e.extend(e.arcsine,{pdf:function(e,t,n){return n<=t?NaN:e<=t||e>=n?0:2/i.PI*i.pow(i.pow(n-t,2)-i.pow(2*e-t-n,2),-.5)},cdf:function(e,t,n){return e<t?0:e<n?2/i.PI*i.asin(i.sqrt((e-t)/(n-t))):1},inv:function(e,t,n){return t+(.5-.5*i.cos(i.PI*e))*(n-t)},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 Error("mode is not yet implemented")},sample:function(t,n){return(t+n)/2+(n-t)/2*i.sin(2*i.PI*e.uniform.sample(0,1))},variance:function(e,t){return t<=e?NaN:i.pow(t-e,2)/8}}),e.extend(e.laplace,{pdf:function(e,t,n){return n<=0?0:i.exp(-i.abs(e-t)/n)/(2*n)},cdf:function(e,t,n){return n<=0?0:e<t?.5*i.exp((e-t)/n):1-.5*i.exp(-(e-t)/n)},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(t,n){var r=e._random_fn()-.5;return t-n*(r/i.abs(r))*i.log(1-2*i.abs(r))}}),e.extend(e.tukey,{cdf:function(t,n,r){var o=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],l=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(t<=0)return 0;if(r<2||n<2)return NaN;if(!Number.isFinite(t))return 1;if(r>25e3)return c(t,1,n);var a=.5*r,u=a*i.log(r)-r*i.log(2)-e.gammaln(a),s=a-1,f=.25*r;p=r<=100?1:r<=800?.5:r<=5e3?.25:.125,u+=i.log(p);for(var d=0,m=1;m<=50;m++){for(var p,h,g,v=0,y=(2*m-1)*p,C=1;C<=16;C++)if(8<C?(h=C-8-1,g=u+s*i.log(y+o[h]*p)-(o[h]*p+y)*f):(h=C-1,g=u+s*i.log(y-o[h]*p)+(o[h]*p-y)*f),g>=-30){v+=c(8<C?t*i.sqrt((o[h]*p+y)*.5):t*i.sqrt((-(o[h]*p)+y)*.5),1,n)*l[h]*i.exp(g)}if(m*p>=1&&v<=1e-14)break;d+=v}if(v>1e-14)throw Error("tukey.cdf failed to converge");return d>1&&(d=1),d},inv:function(t,n,r){if(r<2||n<2||t<0||t>1)return NaN;if(0===t)return 0;if(1===t)return 1/0;var o,l,a,u,s,c,f=(a=.5-.5*t,s=(u=i.sqrt(i.log(1/(a*a))))+((((-453642210148e-16*u+-.204231210125)*u+-.342242088547)*u+-1)*u+.322232421088)/((((.0038560700634*u+.10353775285)*u+.531103462366)*u+.588581570495)*u+.099348462606),r<120&&(s+=(s*s*s+s)/r/4),c=.8832-.2368*s,r<120&&(c+=-1.214/r+1.208*s/r),s*(c*i.log(n-1)+1.4142)),d=e.tukey.cdf(f,n,r)-t;o=d>0?i.max(0,f-1):f+1;for(var m=e.tukey.cdf(o,n,r)-t,p=1;p<50;p++)if(l=o-m*(o-f)/(m-d),d=m,f=o,l<0&&(l=0,m=-t),m=e.tukey.cdf(l,n,r)-t,o=l,1e-4>i.abs(o-f))return l;throw Error("tukey.inv failed to converge")}}),function(e,t){var n,r,o=Array.prototype.push,l=e.utils.isArray;function i(t){return l(t)||t instanceof e}e.extend({add:function(t,n){return i(n)?(i(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 i(n)?(i(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 i(n)?(i(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,l,a,u,s,c,f;if(void 0===t.length&&void 0===n.length)return t*n;if(u=t.length,s=t[0].length,c=e.zeros(u,l=i(n)?n[0].length:s),f=0,i(n)){for(;f<l;f++)for(r=0;r<u;r++){for(o=0,a=0;o<s;o++)a+=t[r][o]*n[o][f];c[r][f]=a}return 1===u&&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){i(t[0])||(t=[t]),i(n[0])||(n=[n]);for(var r,o,l=1===t[0].length&&1!==t.length?e.transpose(t):t,a=1===n[0].length&&1!==n.length?e.transpose(n):n,u=[],s=0,c=l.length,f=l[0].length;s<c;s++){for(o=0,u[s]=[],r=0;o<f;o++)r+=l[s][o]*a[s][o];u[s]=r}return 1===u.length?u[0]:u},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),i(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,l=e.identity(r,o),i=e.gauss_jordan(t,l),a=[],u=0;u<r;u++)for(a[u]=[],n=o;n<i[0].length;n++)a[u][n-o]=i[u][n];return a},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=[],l=1;l<t.length;l++){o[l-1]=[];for(var i=0;i<t.length;i++)i<r?o[l-1][i]=t[l][i]:i>r&&(o[l-1][i-1]=t[l][i])}var a=r%2?-1:1;n+=e(o)*t[0][r]*a}return n},gauss_elimination:function(n,r){var o,l,i,a,u=0,s=0,c=n.length,f=n[0].length,d=1,m=0,p=[];for(u=0,o=(n=e.aug(n,r))[0].length;u<c;u++){for(l=n[u][u],s=u,a=u+1;a<f;a++)l<t.abs(n[a][u])&&(l=n[a][u],s=a);if(s!=u)for(a=0;a<o;a++)i=n[u][a],n[u][a]=n[s][a],n[s][a]=i;for(s=u+1;s<c;s++)for(d=n[s][u]/n[u][u],a=u;a<o;a++)n[s][a]=n[s][a]-d*n[u][a]}for(u=c-1;u>=0;u--){for(m=0,s=u+1;s<=c-1;s++)m+=p[s]*n[u][s];p[u]=(n[u][o-1]-m)/n[u][u]}return p},gauss_jordan:function(n,r){var o,l,i,a=e.aug(n,r),u=a.length,s=a[0].length,c=0;for(l=0;l<u;l++){var f=l;for(i=l+1;i<u;i++)t.abs(a[i][l])>t.abs(a[f][l])&&(f=i);var d=a[l];for(a[l]=a[f],a[f]=d,i=l+1;i<u;i++)for(c=a[i][l]/a[l][l],o=l;o<s;o++)a[i][o]-=a[l][o]*c}for(l=u-1;l>=0;l--){for(i=0,c=a[l][l];i<l;i++)for(o=s-1;o>l-1;o--)a[i][o]-=a[l][o]*a[i][l]/c;for(a[l][l]/=c,o=u;o<s;o++)a[l][o]/=c}return a},triaUpSolve:function(t,n){var r,o=t[0].length,l=e.zeros(1,o)[0],i=!1;return(void 0!=n[0].length&&(n=n.map(function(e){return e[0]}),i=!0),e.arange(o-1,-1,-1).forEach(function(i){r=e.arange(i+1,o).map(function(e){return l[e]*t[i][e]}),l[i]=(n[i]-e.sum(r))/t[i][i]}),i)?l.map(function(e){return[e]}):l},triaLowSolve:function(t,n){var r,o=t[0].length,l=e.zeros(1,o)[0],i=!1;return(void 0!=n[0].length&&(n=n.map(function(e){return e[0]}),i=!0),e.arange(o).forEach(function(o){r=e.arange(o).map(function(e){return t[o][e]*l[e]}),l[o]=(n[o]-e.sum(r))/t[o][o]}),i)?l.map(function(e){return[e]}):l},lu:function(t){var n,r=t.length,o=e.identity(r),l=e.zeros(t.length,t[0].length);return e.arange(r).forEach(function(e){l[0][e]=t[0][e]}),e.arange(1,r).forEach(function(i){e.arange(i).forEach(function(r){n=e.arange(r).map(function(e){return o[i][e]*l[e][r]}),o[i][r]=(t[i][r]-e.sum(n))/l[r][r]}),e.arange(i,r).forEach(function(r){n=e.arange(i).map(function(e){return o[i][e]*l[e][r]}),l[i][r]=t[n.length][r]-e.sum(n)})}),[o,l]},cholesky:function(n){var r,o=n.length,l=e.zeros(n.length,n[0].length);return e.arange(o).forEach(function(i){r=e.arange(i).map(function(e){return t.pow(l[i][e],2)}),l[i][i]=t.sqrt(n[i][i]-e.sum(r)),e.arange(i+1,o).forEach(function(t){r=e.arange(i).map(function(e){return l[i][e]*l[t][e]}),l[t][i]=(n[i][t]-e.sum(r))/l[i][i]})}),l},gauss_jacobi:function(n,r,o,l){for(var i,a,u,s,c=0,f=0,d=n.length,m=[],p=[],h=[];c<d;c++)for(f=0,m[c]=[],p[c]=[],h[c]=[];f<d;f++)c>f?(m[c][f]=n[c][f],p[c][f]=h[c][f]=0):c<f?(p[c][f]=n[c][f],m[c][f]=h[c][f]=0):(h[c][f]=n[c][f],m[c][f]=p[c][f]=0);for(u=e.multiply(e.multiply(e.inv(h),e.add(m,p)),-1),a=e.multiply(e.inv(h),r),i=o,s=e.add(e.multiply(u,o),a),c=2;t.abs(e.norm(e.subtract(s,i)))>l;)i=s,s=e.add(e.multiply(u,i),a),c++;return s},gauss_seidel:function(n,r,o,l){for(var i,a,u,s,c,f=0,d=n.length,m=[],p=[],h=[];f<d;f++)for(i=0,m[f]=[],p[f]=[],h[f]=[];i<d;i++)f>i?(m[f][i]=n[f][i],p[f][i]=h[f][i]=0):f<i?(p[f][i]=n[f][i],m[f][i]=h[f][i]=0):(h[f][i]=n[f][i],m[f][i]=p[f][i]=0);for(s=e.multiply(e.multiply(e.inv(e.add(h,m)),p),-1),u=e.multiply(e.inv(e.add(h,m)),r),a=o,c=e.add(e.multiply(s,o),u),f=2;t.abs(e.norm(e.subtract(c,a)))>l;)a=c,c=e.add(e.multiply(s,a),u),f+=1;return c},SOR:function(n,r,o,l,i){for(var a,u,s,c,f,d=0,m=n.length,p=[],h=[],g=[];d<m;d++)for(a=0,p[d]=[],h[d]=[],g[d]=[];a<m;a++)d>a?(p[d][a]=n[d][a],h[d][a]=g[d][a]=0):d<a?(h[d][a]=n[d][a],p[d][a]=g[d][a]=0):(g[d][a]=n[d][a],p[d][a]=h[d][a]=0);for(c=e.multiply(e.inv(e.add(g,e.multiply(p,i))),e.subtract(e.multiply(g,1-i),e.multiply(h,i))),s=e.multiply(e.multiply(e.inv(e.add(g,e.multiply(p,i))),r),i),u=o,f=e.add(e.multiply(c,o),s),d=2;t.abs(e.norm(e.subtract(f,u)))>l;)u=f,f=e.add(e.multiply(c,u),s),d++;return f},householder:function(n){for(var r,o,l,i,a=n.length,u=n[0].length,s=0,c=[],f=[];s<a-1;s++){for(r=0,i=s+1;i<u;i++)r+=n[i][s]*n[i][s];for(r=(n[s+1][s]>0?-1:1)*t.sqrt(r),o=t.sqrt((r*r-n[s+1][s]*r)/2),(c=e.zeros(a,1))[s+1][0]=(n[s+1][s]-r)/(2*o),l=s+2;l<a;l++)c[l][0]=n[l][s]/(2*o);f=e.subtract(e.identity(a,u),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 l,i,a,u=o.length,s=o[0].length,c=e.zeros(s,s);for(i=0,o=e.copy(o);i<s;i++){for(l=0,c[i][i]=t.sqrt(n(r(u).map(function(e){return o[e][i]*o[e][i]})));l<u;l++)o[l][i]=o[l][i]/c[i][i];for(a=i+1;a<s;a++)for(l=0,c[i][a]=n(r(u).map(function(e){return o[e][i]*o[e][a]}));l<u;l++)o[l][a]=o[l][a]-o[l][i]*c[i][a]}return[o,c]}),lstsq:function(t,n){var r,o,l,i=!1;void 0===n[0].length&&(n=n.map(function(e){return[e]}),i=!0);var a=e.QR(t),u=a[0],s=a[1],c=t[0].length,f=e.slice(u,{col:{end:c}}),d=(r=e.slice(s,{row:{end:c}}),o=(r=e.copy(r)).length,l=e.identity(o),e.arange(o-1,-1,-1).forEach(function(t){e.sliceAssign(l,{row:t},e.divide(e.slice(l,{row:t}),r[t][t])),e.sliceAssign(r,{row:t},e.divide(e.slice(r,{row:t}),r[t][t])),e.arange(t).forEach(function(n){var o=e.multiply(r[n][t],-1),i=e.slice(r,{row:n}),a=e.multiply(e.slice(r,{row:t}),o);e.sliceAssign(r,{row:n},e.add(i,a));var u=e.slice(l,{row:n}),s=e.multiply(e.slice(l,{row:t}),o);e.sliceAssign(l,{row:n},e.add(u,s))})}),l),m=e.transpose(f);void 0===m[0].length&&(m=[m]);var p=e.multiply(e.multiply(d,m),n);return(void 0===p.length&&(p=[[p]]),i)?p.map(function(e){return e[0]}):p},jacobi:function(n){for(var r,o,l,i,a,u,s,c=1,f=n.length,d=e.identity(f,f),m=[];1===c;){for(r=0,a=n[0][1],l=0,i=1;r<f;r++)for(o=0;o<f;o++)r!=o&&a<t.abs(n[r][o])&&(a=t.abs(n[r][o]),l=r,i=o);for(r=1,u=n[l][l]===n[i][i]?n[l][i]>0?t.PI/4:-t.PI/4:t.atan(2*n[l][i]/(n[l][l]-n[i][i]))/2,(s=e.identity(f,f))[l][l]=t.cos(u),s[l][i]=-t.sin(u),s[i][l]=t.sin(u),s[i][i]=t.cos(u),d=e.multiply(d,s),n=e.multiply(e.multiply(e.inv(s),n),s),c=0;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++)m.push(n[r][r]);return[d,m]},rungekutta:function(e,t,n,r,o,l){var i,a,u,s;if(2===l)for(;r<=n;)i=t*e(r,o),a=t*e(r+t,o+i),o+=(i+a)/2,r+=t;if(4===l)for(;r<=n;)i=t*e(r,o),a=t*e(r+t/2,o+i/2),u=t*e(r+t/2,o+a/2),s=t*e(r+t,o+u),o+=(i+2*a+2*u+s)/6,r+=t;return o},romberg:function(e,n,r,o){for(var l,i,a,u,s,c=0,f=(r-n)/2,d=[],m=[],p=[];c<o/2;){for(s=e(n),a=n,u=0;a<=r;a+=f,u++)d[u]=a;for(a=1,l=d.length;a<l-1;a++)s+=(a%2!=0?4:2)*e(d[a]);s=f/3*(s+e(r)),p[c]=s,f/=2,c++}for(i=p.length,l=1;1!==i;){for(a=0;a<i-1;a++)m[a]=(t.pow(4,l)*p[a+1]-p[a])/(t.pow(4,l)-1);i=m.length,p=m,m=[],l++}return p},richardson:function(e,n,r,o){function l(e,t){for(var n,r=0,o=e.length;r<o;r++)e[r]===t&&(n=r);return n}for(var i,a,u,s,c,f=t.abs(r-e[l(e,r)+1]),d=0,m=[],p=[];o>=f;)i=l(e,r+o),a=l(e,r),m[d]=(n[i]-2*n[a]+n[2*a-i])/(o*o),o/=2,d++;for(s=m.length,u=1;1!=s;){for(c=0;c<s-1;c++)p[c]=(t.pow(4,u)*m[c+1]-m[c])/(t.pow(4,u)-1);s=p.length,m=p,p=[],u++}return m},simpson:function(e,t,n,r){for(var o,l=(n-t)/r,i=e(t),a=[],u=t,s=0,c=1;u<=n;u+=l,s++)a[s]=u;for(o=a.length;c<o-1;c++)i+=(c%2!=0?4:2)*e(a[c]);return l/3*(i+e(n))},hermite:function(e,t,n,r){for(var o,l=e.length,i=0,a=0,u=[],s=[],c=[],f=[];a<l;a++){for(o=0,u[a]=1;o<l;o++)a!=o&&(u[a]*=(r-e[o])/(e[a]-e[o]));for(o=0,s[a]=0;o<l;o++)a!=o&&(s[a]+=1/(e[a]-e[o]));c[a]=(1-2*(r-e[a])*s[a])*(u[a]*u[a]),f[a]=(r-e[a])*(u[a]*u[a]),i+=c[a]*t[a]+f[a]*n[a]}return i},lagrange:function(e,t,n){for(var r,o,l=0,i=0,a=e.length;i<a;i++){for(r=0,o=t[i];r<a;r++)i!=r&&(o*=(n-e[r])/(e[i]-e[r]));l+=o}return l},cubic_spline:function(t,n,r){for(var o,l=t.length,i=0,a=[],u=[],s=[],c=[],f=[],d=[],m=[];i<l-1;i++)f[i]=t[i+1]-t[i];for(i=1,s[0]=0;i<l-1;i++)s[i]=3/f[i]*(n[i+1]-n[i])-3/f[i-1]*(n[i]-n[i-1]);for(i=1;i<l-1;i++)a[i]=[],u[i]=[],a[i][i-1]=f[i-1],a[i][i]=2*(f[i-1]+f[i]),a[i][i+1]=f[i],u[i][0]=s[i];for(o=0,c=e.multiply(e.inv(a),u);o<l-1;o++)d[o]=(n[o+1]-n[o])/f[o]-f[o]*(c[o+1][0]+2*c[o][0])/3,m[o]=(c[o+1][0]-c[o][0])/(3*f[o]);for(o=0;o<l&&!(t[o]>r);o++);return n[o-=1]+(r-t[o])*d[o]+e.sq(r-t[o])*c[o]+(r-t[o])*e.sq(r-t[o])*m[o]},gauss_quadrature:function(){throw Error("gauss_quadrature not yet implemented")},PCA:function(t){var n,r,o=t.length,l=t[0].length,i=0,a=[],u=[],s=[],c=[],f=[],d=[],m=[],p=[],h=[],g=[];for(i=0;i<o;i++)a[i]=e.sum(t[i])/l;for(i=0;i<l;i++)for(n=0,m[i]=[];n<o;n++)m[i][n]=t[n][i]-a[n];for(i=0,m=e.transpose(m);i<o;i++)for(n=0,p[i]=[];n<o;n++)p[i][n]=e.dot([m[i]],[m[n]])/(l-1);for(i=0,h=(s=e.jacobi(p))[0],u=s[1],g=e.transpose(h);i<u.length;i++)for(n=i;n<u.length;n++)u[i]<u[n]&&(r=u[i],u[i]=u[n],u[n]=r,c=g[i],g[i]=g[n],g[n]=c);for(i=0,d=e.transpose(m);i<o;i++)for(n=0,f[i]=[];n<d.length;n++)f[i][n]=e.dot([g[i]],[d[n]]);return[t,u,g,f]}});for(var a="add divide multiply subtract dot pow exp log abs norm angle".split(" "),u=0;u<a.length;u++)!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))}}(a[u])}(e,Math);var f=Math,d=[].slice,m=e.utils.isNumber,p=e.utils.isArray;function h(e,t,n,r){if(e>1||n>1||e<=0||n<=0)throw Error("Proportions should be greater than 0 and less than 1");var o=(e*t+n*r)/(t+r);return(e-n)/f.sqrt(o*(1-o)*(1/t+1/r))}return e.extend({zscore:function(){var t=d.call(arguments);return m(t[1])?(t[0]-t[1])/t[2]:(t[0]-e.mean(t[1]))/e.stdev(t[1],t[2])},ztest:function(){var t,n=d.call(arguments);return p(n[1])?(t=e.zscore(n[0],n[1],n[3]),1===n[2]?e.normal.cdf(-f.abs(t),0,1):2*e.normal.cdf(-f.abs(t),0,1)):n.length>2?(t=e.zscore(n[0],n[1],n[2]),1===n[3]?e.normal.cdf(-f.abs(t),0,1):2*e.normal.cdf(-f.abs(t),0,1)):(t=n[0],1===n[1]?e.normal.cdf(-f.abs(t),0,1):2*e.normal.cdf(-f.abs(t),0,1))}}),e.extend(e.fn,{zscore:function(e,t){return(e-this.mean())/this.stdev(t)},ztest:function(t,n,r){var o=f.abs(this.zscore(t,r));return 1===n?e.normal.cdf(-o,0,1):2*e.normal.cdf(-o,0,1)}}),e.extend({tscore:function(){var t=d.call(arguments);return 4===t.length?(t[0]-t[1])/(t[2]/f.sqrt(t[3])):(t[0]-e.mean(t[1]))/(e.stdev(t[1],!0)/f.sqrt(t[1].length))},ttest:function(){var t,n=d.call(arguments);return 5===n.length?(t=f.abs(e.tscore(n[0],n[1],n[2],n[3])),1===n[4]?e.studentt.cdf(-t,n[3]-1):2*e.studentt.cdf(-t,n[3]-1)):m(n[1])?(t=f.abs(n[0]),1==n[2]?e.studentt.cdf(-t,n[1]-1):2*e.studentt.cdf(-t,n[1]-1)):(t=f.abs(e.tscore(n[0],n[1])),1==n[2]?e.studentt.cdf(-t,n[1].length-1):2*e.studentt.cdf(-t,n[1].length-1))}}),e.extend(e.fn,{tscore:function(e){return(e-this.mean())/(this.stdev(!0)/f.sqrt(this.cols()))},ttest:function(t,n){return 1===n?1-e.studentt.cdf(f.abs(this.tscore(t)),this.cols()-1):2*e.studentt.cdf(-f.abs(this.tscore(t)),this.cols()-1)}}),e.extend({anovafscore:function(){var t,n,r,o,l,i,a,u,s=d.call(arguments);if(1===s.length){for(a=0,l=Array(s[0].length);a<s[0].length;a++)l[a]=s[0][a];s=l}for(a=0,n=[];a<s.length;a++)n=n.concat(s[a]);for(a=0,r=e.mean(n),t=0;a<s.length;a++)t+=s[a].length*f.pow(e.mean(s[a])-r,2);for(t/=s.length-1,i=0,a=0;a<s.length;a++)for(u=0,o=e.mean(s[a]);u<s[a].length;u++)i+=f.pow(s[a][u]-o,2);return t/(i/=n.length-s.length)},anovaftest:function(){var t,n,r,o,l=d.call(arguments);if(m(l[0]))return 1-e.centralF.cdf(l[0],l[1],l[2]);var i=e.anovafscore(l);for(o=0,t=l.length-1,r=0;o<l.length;o++)r+=l[o].length;return n=r-t-1,1-e.centralF.cdf(i,t,n)},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 t,n,r,o,l,i=d.call(arguments);return m(i[0])?(t=i[0],n=i[1],r=i[2],o=i[3],l=i[4]):(t=e.mean(i[0]),n=e.mean(i[1]),r=i[0].length,o=i[1].length,l=i[2]),f.abs(t-n)/(l*f.sqrt((1/r+1/o)/2))},qtest:function(){var t,n=d.call(arguments);3===n.length?(t=n[0],n=n.slice(1)):7===n.length?(t=e.qscore(n[0],n[1],n[2],n[3],n[4]),n=n.slice(5)):(t=e.qscore(n[0],n[1],n[2]),n=n.slice(3));var r=n[0],o=n[1];return 1-e.tukey.cdf(t,o,r-o)},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),l=[],i=0;i<t.length;++i)for(var a=i+1;a<t.length;++a){var u=e.qtest(r[i],r[a],t[i].length,t[a].length,n,o,t.length);l.push([[i,a],u])}return l}}),e.extend({normalci:function(){var t,n=d.call(arguments),r=[,,];return t=4===n.length?f.abs(e.normal.inv(n[1]/2,0,1)*n[2]/f.sqrt(n[3])):f.abs(e.normal.inv(n[1]/2,0,1)*e.stdev(n[2])/f.sqrt(n[2].length)),r[0]=n[0]-t,r[1]=n[0]+t,r},tci:function(){var t,n=d.call(arguments),r=[,,];return t=4===n.length?f.abs(e.studentt.inv(n[1]/2,n[3]-1)*n[2]/f.sqrt(n[3])):f.abs(e.studentt.inv(n[1]/2,n[2].length-1)*e.stdev(n[2],!0)/f.sqrt(n[2].length)),r[0]=n[0]-t,r[1]=n[0]+t,r},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 l=h(t,n,r,o);return e.ztest(l,1)},twoSidedDifferenceOfProportions:function(t,n,r,o){var l=h(t,n,r,o);return e.ztest(l,2)}}),e.models=function(){function t(t,n){var r=t.length,o=n[0].length-1,l=e.lstsq(n,t),i=e.multiply(n,l.map(function(e){return[e]})).map(function(e){return e[0]}),a=e.subtract(t,i),u=e.mean(t),s=e.sum(i.map(function(e){return Math.pow(e-u,2)})),c=e.sum(t.map(function(e,t){return Math.pow(e-i[t],2)})),f=s+c;return{exog:n,endog:t,nobs:r,df_model:o,df_resid:r-o-1,coef:l,predict:i,resid:a,ybar:u,SST:f,SSE:s,SSR:c,R2:s/f}}return{ols:function(n,r){var o,l,i,a,u,s,c,f,d,m,p,h,g,v,y=t(n,r),C=(l=(o=y.exog)[0].length,i=e.arange(l).map(function(n){var r=e.arange(l).filter(function(e){return e!==n});return t(e.col(o,n).map(function(e){return e[0]}),e.col(o,r))}),a=Math.sqrt(y.SSR/y.df_resid),u=i.map(function(e){return a/Math.sqrt(e.SST*(1-e.R2))}),c=(s=y.coef.map(function(e,t){return(e-0)/u[t]})).map(function(t){var n=e.studentt.cdf(t,y.df_resid);return(n>.5?1-n:n)*2}),f=e.studentt.inv(.975,y.df_resid),d=y.coef.map(function(e,t){var n=f*u[t];return[e-n,e+n]}),{se:u,t:s,p:c,sigmaHat:a,interval95:d}),b=(v=1-(p=m=y.R2/y.df_model/((1-y.R2)/y.df_resid),h=y.df_model,g=y.df_resid,e.beta.cdf(p/(g/h+p),h/2,g/2)),{F_statistic:m,pvalue:v}),w=1-(1-y.R2)*((y.nobs-1)/y.df_resid);return y.t=C,y.f=b,y.adjust_R2=w,y}}}(),e.extend({buildxmatrix:function(){for(var t=Array(arguments.length),n=0;n<arguments.length;n++){var r=[1];t[n]=r.concat(arguments[n])}return e(t)},builddxmatrix:function(){for(var t=Array(arguments[0].length),n=0;n<arguments[0].length;n++){var r=[1];t[n]=r.concat(arguments[0][n])}return e(t)},buildjxmatrix:function(t){for(var n=Array(t.length),r=0;r<t.length;r++)n[r]=t[r];return e.builddxmatrix(n)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(e){return e.transpose()},matrixmult:function(t,n){var r,o,l,i,a;if(t.cols()==n.rows()){if(n.rows()>1){for(r=0,i=[];r<t.rows();r++)for(o=0,i[r]=[];o<n.cols();o++){for(l=0,a=0;l<t.cols();l++)a+=t.toArray()[r][l]*n.toArray()[l][o];i[r][o]=a}return e(i)}for(r=0,i=[];r<t.rows();r++)for(o=0,i[r]=[];o<n.cols();o++){for(l=0,a=0;l<t.cols();l++)a+=t.toArray()[r][l]*n.toArray()[o];i[r][o]=a}return e(i)}},regress:function(t,n){var r=e.xtranspxinv(t),o=t.transpose(),l=e.matrixmult(e(r),o);return e.matrixmult(l,n)},regresst:function(t,n,r){var o,l,i,a=e.regress(t,n),u={};u.anova={};var s=e.jMatYBar(t,a);u.yBar=s;var c=n.mean();u.anova.residuals=e.residuals(n,s),u.anova.ssr=e.ssr(s,c),u.anova.msr=u.anova.ssr/(t[0].length-1),u.anova.sse=e.sse(n,s),u.anova.mse=u.anova.sse/(n.length-(t[0].length-1)-1),u.anova.sst=e.sst(n,c),u.anova.mst=u.anova.sst/(n.length-1),u.anova.r2=1-u.anova.sse/u.anova.sst,u.anova.r2<0&&(u.anova.r2=0),u.anova.fratio=u.anova.msr/u.anova.mse,u.anova.pvalue=e.anovaftest(u.anova.fratio,t[0].length-1,n.length-(t[0].length-1)-1),u.anova.rmse=Math.sqrt(u.anova.mse),u.anova.r2adj=1-u.anova.mse/u.anova.mst,u.anova.r2adj<0&&(u.anova.r2adj=0),u.stats=Array(t[0].length);for(var f=e.xtranspxinv(t),d=0;d<a.length;d++)o=Math.sqrt(u.anova.mse*Math.abs(f[d][d])),l=Math.abs(a[d]/o),i=e.ttest(l,n.length-t[0].length-1,r),u.stats[d]=[a[d],o,l,i];return u.regress=a,u},xtranspx:function(t){return e.matrixmult(t.transpose(),t)},xtranspxinv:function(t){var n=e.matrixmult(t.transpose(),t);return e.inv(n)},jMatYBar:function(t,n){var r=e.matrixmult(t,n);return new e(r)},residuals:function(t,n){return e.matrixsubtract(t,n)},ssr:function(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(t,n){for(var r=Array(t.length),o=0;o<t.length;o++){r[o]=Array(t[o].length);for(var l=0;l<t[o].length;l++)r[o][l]=t[o][l]-n[o][l]}return e(r)}}),e.jStat=e,e}()},296(e,t,n){var r=n(137),o=n(344),l=n(14),i=n(364),a=n(394),u=n(380),s=n(320);s.alea=r,s.xor128=o,s.xorwow=l,s.xorshift7=i,s.xor4096=a,s.tychei=u,e.exports=s},137(e,t,n){!function(e,t){function n(e){var t,n=this,r=(t=0xefc8249d,function(e){e=String(e);for(var n=0;n<e.length;n++){var r=.02519603282416938*(t+=e.charCodeAt(n));t=r>>>0,r-=t,r*=t,t=r>>>0,r-=t,t+=0x100000000*r}return(t>>>0)*23283064365386963e-26});n.next=function(){var e=2091639*n.s0+23283064365386963e-26*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)}function r(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function o(e,t){var o=new n(e),l=t&&t.state,i=o.next;return i.int32=function(){return 0x100000000*o.next()|0},i.double=function(){return i()+(2097152*i()|0)*11102230246251565e-32},i.quick=i,l&&("object"==typeof l&&r(l,o),i.state=function(){return r(o,{})}),i}e&&e.exports?e.exports=o:t&&t.amd?t(function(){return o}):this.alea=o}(e=n.nmd(e),"function"==typeof define&&define)},380(e,t,n){!function(e,t){function n(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=-0x61c88647,t.d=0x517cc1b7,e===Math.floor(e)?(t.a=e/0x100000000|0,t.b=0|e):n+=e;for(var r=0;r<n.length+20;r++)t.b^=n.charCodeAt(r),t.next()}function r(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function o(e,t){var o=new n(e),l=t&&t.state,i=function(){return(o.next()>>>0)/0x100000000};return i.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},i.int32=o.next,i.quick=i,l&&("object"==typeof l&&r(l,o),i.state=function(){return r(o,{})}),i}e&&e.exports?e.exports=o:t&&t.amd?t(function(){return o}):this.tychei=o}(e=n.nmd(e),"function"==typeof define&&define)},344(e,t,n){!function(e,t){function n(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^=n.charCodeAt(r),t.next()}function r(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function o(e,t){var o=new n(e),l=t&&t.state,i=function(){return(o.next()>>>0)/0x100000000};return i.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},i.int32=o.next,i.quick=i,l&&("object"==typeof l&&r(l,o),i.state=function(){return r(o,{})}),i}e&&e.exports?e.exports=o:t&&t.amd?t(function(){return o}):this.xor128=o}(e=n.nmd(e),"function"==typeof define&&define)},394(e,t,n){!function(e,t){function n(e){var t=this;t.next=function(){var e,n,r=t.w,o=t.X,l=t.i;return t.w=r=r+0x61c88647|0,n=o[l+34&127],e=o[l=l+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=o[l]=n^e,t.i=l,n+(r^r>>>16)|0},!function(e,t){var n,r,o,l,i,a=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),o=0,l=-32;l<u;++l)t&&(r^=t.charCodeAt((l+32)%t.length)),0===l&&(i=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,l>=0&&(i=i+0x61c88647|0,o=0==(n=a[127&l]^=r+i)?o+1:0);for(o>=128&&(a[127&(t&&t.length||0)]=-1),o=127,l=512;l>0;--l)r=a[o+34&127],n=a[o=o+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,a[o]=r^n;e.w=i,e.X=a,e.i=o}(t,e)}function r(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function o(e,t){null==e&&(e=+new Date);var o=new n(e),l=t&&t.state,i=function(){return(o.next()>>>0)/0x100000000};return i.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},i.int32=o.next,i.quick=i,l&&(l.X&&r(l,o),i.state=function(){return r(o,{})}),i}e&&e.exports?e.exports=o:t&&t.amd?t(function(){return o}):this.xor4096=o}(e=n.nmd(e),"function"==typeof define&&define)},364(e,t,n){!function(e,t){function n(e){var t=this;t.next=function(){var e,n,r=t.x,o=t.i;return e=r[o],e^=e>>>7,n=e^e<<24^((e=r[o+1&7])^e>>>10)^((e=r[o+3&7])^e>>>3)^((e=r[o+4&7])^e<<7),e=r[o+7&7],e^=e<<13,n^=e^e<<9,r[o]=n,t.i=o+1&7,n};var n,r=e,o=[];if(r===(0|r))o[0]=r;else for(n=0,r=""+r;n<r.length;++n)o[7&n]=o[7&n]<<15^r.charCodeAt(n)+o[n+1&7]<<13;for(;o.length<8;)o.push(0);for(n=0;n<8&&0===o[n];++n);for(8==n?o[7]=-1:o[n],t.x=o,t.i=0,n=256;n>0;--n)t.next()}function r(e,t){return t.x=e.x.slice(),t.i=e.i,t}function o(e,t){null==e&&(e=+new Date);var o=new n(e),l=t&&t.state,i=function(){return(o.next()>>>0)/0x100000000};return i.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},i.int32=o.next,i.quick=i,l&&(l.x&&r(l,o),i.state=function(){return r(o,{})}),i}e&&e.exports?e.exports=o:t&&t.amd?t(function(){return o}):this.xorshift7=o}(e=n.nmd(e),"function"==typeof define&&define)},14(e,t,n){!function(e,t){function n(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^=n.charCodeAt(r),r==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function r(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 o(e,t){var o=new n(e),l=t&&t.state,i=function(){return(o.next()>>>0)/0x100000000};return i.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},i.int32=o.next,i.quick=i,l&&("object"==typeof l&&r(l,o),i.state=function(){return r(o,{})}),i}e&&e.exports?e.exports=o:t&&t.amd?t(function(){return o}):this.xorwow=o}(e=n.nmd(e),"function"==typeof define&&define)},320(e,t,n){!function(t,r,o){var l,i="random",a=o.pow(256,6),u=o.pow(2,52),s=2*u;function c(e,n,c){var h=[],g=m(function e(t,n){var r,o=[],l=typeof t;if(n&&"object"==l)for(r in t)try{o.push(e(t[r],n-1))}catch(e){}return o.length?o:"string"==l?t:t+"\0"}((n=!0==n?{entropy:!0}:n||{}).entropy?[e,p(r)]:null==e?function(){try{var e;return l&&(e=l.randomBytes)?e=e(256):(e=new Uint8Array(256),(t.crypto||t.msCrypto).getRandomValues(e)),p(e)}catch(e){var n=t.navigator,o=n&&n.plugins;return[+new Date,t,o,t.screen,p(r)]}}():e,3),h),v=new f(h),y=function(){for(var e=v.g(6),t=a,n=0;e<u;)e=(e+n)*256,t*=256,n=v.g(1);for(;e>=s;)e/=2,t/=2,n>>>=1;return(e+n)/t};return y.int32=function(){return 0|v.g(4)},y.quick=function(){return v.g(4)/0x100000000},y.double=y,m(p(v.S),r),(n.pass||c||function(e,t,n,r){return(r&&(r.S&&d(r,v),e.state=function(){return d(v,{})}),n)?(o[i]=e,t):e})(y,g,"global"in n?n.global:this==o,n.state)}function f(e){var t,n=e.length,r=this,o=0,l=r.i=r.j=0,i=r.S=[];for(n||(e=[n++]);o<256;)i[o]=o++;for(o=0;o<256;o++)i[o]=i[l=255&l+e[o%n]+(t=i[o])],i[l]=t;(r.g=function(e){for(var t,n=0,o=r.i,l=r.j,i=r.S;e--;)t=i[o=255&o+1],n=256*n+i[255&(i[o]=i[l=255&l+t])+(i[l]=t)];return r.i=o,r.j=l,n})(256)}function d(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function m(e,t){for(var n,r=e+"",o=0;o<r.length;)t[255&o]=255&(n^=19*t[255&o])+r.charCodeAt(o++);return p(t)}function p(e){return String.fromCharCode.apply(0,e)}if(m(o.random(),r),e.exports){e.exports=c;try{l=n(562)}catch(e){}}else"function"==typeof define&&define.amd?define(function(){return c}):o["seed"+i]=c}("u">typeof self?self:this,[],Math)},287(e,t,n){"use strict";n.d(t,{G:()=>o});var r=n(590);function o(e){var t,n;let o,l,i;return JSON.stringify((o=(null!=(n=(t=JSON.parse(e)).p)?n:[]).map(e=>({x:e[0],y:e[1],outlier:e.length>2&&1===e[2]})),l=void 0!==t.mxr&&void 0!==t.hs&&void 0!==t.poi&&void 0!==t.mnr,i={points:o,fitFunction:r.Qx,showFitLine:!0,showPoints:"points",clickToToggle:!0,name:t.rdt?`${t.rdt}`:"Dose-Response",droplines:["IC50"]},l&&(i.parameters=[t.mxr,t.hs,t.poi,t.mnr]),{chartOptions:{xAxisName:t.xu,yAxisName:t.yu,logX:!0},series:[i]}))}},305(e,t,n){"use strict";n.d(t,{R:()=>o});var r=n(886);function o(e){let t=(0,r.rn)(e).find(e=>"XY"===e.tableType);if(!t)return JSON.stringify({series:[]});let n=(0,r.fM)(t);return JSON.stringify(null!=n?n:{series:[]})}},190(e,t,n){"use strict";n.d(t,{J:()=>c});var r=n(82),o=n(869),l=n(590);let i="xAxis",a="yAxis";function u(e,t){var n;return(null==e||null==(n=e.getAttribute(t))?void 0:n.toLowerCase())==="true"}function s(e){var t,n,i;let a=null==(n=e.getElementsByTagName("params")[0])||null==(t=n.childNodes[0].nodeValue)?void 0:t.split(",").map(Number),s=null==(i=e.getElementsByTagName("function")[0])?void 0:i.getAttribute("type"),c=s&&"sigif"!==s&&s in o.rT?s:l.G7,f=e.getElementsByTagName("settings")[0].getAttribute("markerColor"),d=e.getElementsByTagName("settings")[0].getAttribute("color"),m=u(e.getElementsByTagName("settings")[0],"drawLine"),p={name:e.getAttribute("name"),fitFunction:c,markerType:r.MARKER_TYPE.CIRCLE,pointColor:f,fitLineColor:d,showFitLine:m,showPoints:"points",showCurveConfidenceInterval:!1,clickToToggle:!1};return a&&(p.parameters=[a[2],a[1],a[0],a[3]]),p}function c(e){let t,n,r,o,l;return JSON.stringify((n=(t=new DOMParser().parseFromString(e,"text/xml")).getElementsByTagName("grid")[0],r=t.getElementsByTagName("settings")[0],o=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({minX:+n.getElementsByTagName(i)[0].getAttribute("min"),minY:+n.getElementsByTagName(a)[0].getAttribute("min"),maxX:+n.getElementsByTagName(i)[0].getAttribute("max"),maxY:+n.getElementsByTagName(a)[0].getAttribute("max"),xAxisName:r.getAttribute("xLabel"),yAxisName:r.getAttribute("yLabel"),logX:u(r,"logX")},null!==r.getAttribute("logY")?{logY:u(r,"logY")}:{}),{chartOptions:o,seriesOptions:s((l=t.getElementsByTagName("seriesCollection")[0]).getElementsByTagName("series")[0]),series:function(e){let t=[],n=e.getElementsByTagName("series").length;for(let r=0;r<n;r++){let n=e.getElementsByTagName("series")[r];t[r]=function(e){let t=function(e){var t,n,r;let o=null==(t=e.getElementsByTagName("x")[0].childNodes[0].nodeValue)?void 0:t.split(","),l=null==(n=e.getElementsByTagName("y")[0].childNodes[0].nodeValue)?void 0:n.split(","),i=null==(r=e.getElementsByTagName("mask")[0].childNodes[0].nodeValue)?void 0:r.split(""),a=[];for(let e=0;e<o.length;e++)a[e]={x:+o[e],y:+l[e],outlier:"0"===i[e]};return a}(e),n=s(e),r={points:t};return Object.assign(r,n),r}(n)}return t}(l)}))}},124(e,t,n){"use strict";n.d(t,{HB:()=>f,XN:()=>d,l8:()=>u,p:()=>s});var r=n(82),o=n(788);function l(e,t,n,r,o,l,i){try{var a=e[l](i),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}let i=new Map,a=new r.LruCache(2e3);function u(e,t){i.set(e,t)}function s(){var e;return(e=function*(){for(let e of r.Func.find({meta:{role:"curveConverter"}})){let t=e.options.curveFormat;t&&!i.has(t)&&u(t,(yield e.apply()))}},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){l(i,r,o,a,u,"next",e)}function u(e){l(i,r,o,a,u,"throw",e)}a(void 0)})})()}function c(e){let t=e.getTag(o.h.TAG_CURVE_FORMAT);return t&&""!==t?t:null}function f(e,t){if(!e||""===e)return{series:[]};let n=t?function(e,t){let n=c(t);if(!n)return e;let r=`${n}||${e}`;return a.getOrCreate(r,()=>{let t=i.get(n);return t?t(e):(console.warn(`Curve converter for format '${n}' not found in registry.`),e)})}(e,t):e;try{var r;return null!=(r=JSON.parse(null!=n?n:"{}"))?r:{}}catch(e){return{series:[]}}}function d(e){return null===c(e)}},53(e,t,n){"use strict";n.d(t,{B3:()=>X,CP:()=>d,G_:()=>M,IY:()=>N,Ig:()=>R,LX:()=>C,RH:()=>T,Th:()=>h,U6:()=>P,Xm:()=>A,ab:()=>p,bZ:()=>c,bc:()=>F,g2:()=>m,h8:()=>w,mI:()=>x,uc:()=>f,wU:()=>b});var r=n(82),o=n(590),l=n(165),i=n(869),a=n(774),u=n(788),s=n(124);let c=new r.LruCache(1e3),f=new r.LruCache(1e3),d=new r.LruCache(2e3);function m(e,t,n){if(t&&n)for(let r of e)!(r.name in n)&&r.name in t&&(n[r.name]=t[r.name])}let p="chartOptions",h="seriesOptions";function g(e,t,n,r){if(e&&n&&t)for(let o of t)o in e&&!(null==r?void 0:r.includes(o))&&(n[o]=e[o])}function v(e,t,n,r,o){var l,i,a;let u=null==(l=e.explicit)?void 0:l[r];g(n[r],null==(i=n.explicit)?void 0:i[r],o,u),g(t[r],null==(a=t.explicit)?void 0:a[r],o,u)}function y(e,...t){if(e)for(let n of t)(null==n?void 0:n.labels)&&(e.labels=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},n.labels,e.labels))}function C(e,t=[]){let n,r,o;if(0===e.length)return{};let l=Number.MAX_VALUE,i=Number.MAX_VALUE,a=5e-324,u=5e-324,s=!1,c=!1,f=!1;for(let t of e)null!==t.minX&&void 0!==t.minX&&(l=Math.min(l,t.minX)),null!==t.minY&&void 0!==t.minY&&(i=Math.min(i,t.minY)),null!==t.maxX&&void 0!==t.maxX&&(a=Math.max(a,t.maxX)),null!==t.maxY&&void 0!==t.maxY&&(u=Math.max(u,t.maxY)),null!==t.title&&void 0!==t.title&&(null!=o||(o=t.title)),null!==t.xAxisName&&void 0!==t.xAxisName&&(null!=n||(n=t.xAxisName)),null!==t.yAxisName&&void 0!==t.yAxisName&&(null!=r||(r=t.yAxisName)),null!==t.logX&&void 0!==t.logX&&t.logX&&(s=!0),null!==t.logY&&void 0!==t.logY&&t.logY&&(c=!0),null!==t.allowXZeroes&&void 0!==t.allowXZeroes&&t.allowXZeroes&&(f=!0);for(let e of t)for(let t of e.points)t.x<l&&(l=Number.MAX_VALUE),t.x>a&&(a=5e-324),t.y<i&&(i=Number.MAX_VALUE),t.y>u&&(u=5e-324);return{minX:l===Number.MAX_VALUE?void 0:l,minY:i===Number.MAX_VALUE?void 0:i,maxX:5e-324===a?void 0:a,maxY:5e-324===u?void 0:u,title:o,xAxisName:n,yAxisName:r,logX:s,logY:c,allowXZeroes:f}}function b(e){if(0===e.length)return null;let 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,showOutliers:e[0].showOutliers,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(let n of e)t.points=[...t.points,...n.points];return t}function w(e,t=!0){var n;let r=null==e?void 0:e.column;return t&&r&&e?f.getOrCreate((n=e.rowIndex,`tableId: ${r.dataFrame.id} || tableName: ${r.dataFrame.name} || colName: ${r.name} || colVersion: ${r.version} || rowIdx: ${n}`),()=>I(e)):I(e)}function x(e,t,n){let r=F(t),l=n?R(n):{};for(let t of(null!=e.series||(e.series=[]),null!=e.chartOptions||(e.chartOptions=r.chartOptions),m(o.xs,r.chartOptions,e.chartOptions),m(o.xs,l.chartOptions,e.chartOptions),y(e.chartOptions,r.chartOptions,l.chartOptions),v(e,r,l,p,e.chartOptions),e.series))m(i.IL,e.seriesOptions,t),m(i.IL,r.seriesOptions,t),m(i.IL,l.seriesOptions,t),v(e,r,l,h,t);return e}function T(e){return e.includes("|")?e.replaceAll("|",""):e}function I(e){var t,n,a,u,c;let f=e.value,d=e.column,g=d?d.type===r.TYPE.STRING?(0,s.HB)(f,d):(0,l.Kh)():null!=(t=JSON.parse(null!=(n=T(f))?n:"{}"))?t:{};(null==d?void 0:d.type)!==r.TYPE.STRING||(null==(c=g.series)?void 0:c.length)||(g=(0,s.HB)(T(f),d));let C=e.column?F(e.column):{},b=e.column?R(e.dataFrame):{};for(let e of(null!=(a=g).series||(a.series=[]),null!=(u=g).chartOptions||(u.chartOptions=C.chartOptions),m(o.xs,C.chartOptions,g.chartOptions),m(o.xs,b.chartOptions,g.chartOptions),y(g.chartOptions,C.chartOptions,b.chartOptions),v(g,C,b,p,g.chartOptions),g.series))m(i.IL,g.seriesOptions,e),m(i.IL,C.seriesOptions,e),m(i.IL,b.seriesOptions,e),v(g,C,b,h,e);return g}let _=new r.LruCache(2e3),O=new WeakMap,E=0;function P(e){let t=O.get(e);return void 0===t&&O.set(e,t=++E),t}function S(e,t,n,r){return`tableId: ${e.dataFrame.id} || tableName: ${e.dataFrame.name} || colName: ${e.name} || colVersion: ${e.version} || rowIdx: ${t.rowIndex} || idx: ${n} || logX: ${null==r?void 0:r.logX} || logY: ${null==r?void 0:r.logY}`}function N(e,t,n,r,o,l=!0,a){let u=A(e,t,r,!1,o,l),s=null==o?void 0:o.column;return a?_.getOrCreate(`${a} || logX: ${null==r?void 0:r.logX} || logY: ${null==r?void 0:r.logY}`,()=>(0,i.nT)(e,n,u,r)):l&&s&&o?c.getOrCreate(S(s,o,t,r),()=>(0,i.nT)(e,n,u,r)):(0,i.nT)(e,n,u,r)}function A(e,t,n,r,o,l=!0){let i=null==o?void 0:o.column;return l&&i&&o?d.getOrCreate(`${S(i,o,t,n)} || userParamsFlag: ${r}`,()=>(0,a.Sm)(e,n,r)):(0,a.Sm)(e,n,r)}function L(e){return JSON.parse(e[u.h.TAG_FIT]||e[u.h.TAG_FIT_LEGACY]||JSON.stringify((0,l.Kh)()))}function M(e,t){e[u.h.TAG_FIT]=JSON.stringify(t),delete e[u.h.TAG_FIT_LEGACY]}function R(e){return L(e.tags)}function F(e){return L(e.tags)}function X(e){var t;for(let n=0;n<(null==(t=e.series)?void 0:t.length);n++){let t=e.series[n];if(t.points.every(e=>0!==e.x))continue;let r=Number.MAX_VALUE,o=0,l=0,i=[];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),0!==t.points[e].x&&!i.includes(t.points[e].x)&&(i[i.length]=t.points[e].x,l++);if(0===l)continue;let a=Math.log10(r),u=l>1?(Math.log10(o)-a)/(l-1):1,s=Math.pow(10,a-u);for(let e=0;e<t.points.length;e++)0===t.points[e].x&&(t.points[e].x=s)}}},301(e,t,n){"use strict";n.d(t,{Z1:()=>u,pj:()=>s});var r=n(82),o=n(328),l=n(644);function i(e,t,n,r,o,l,i){try{var a=e[l](i),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function a(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){i(l,r,o,a,u,"next",e)}function u(e){i(l,r,o,a,u,"throw",e)}a(void 0)})}}function u(){return a(function*(){o.shell.windows.showContextPanel=!0;let e=yield o.data.loadTable(`${l._package.webRoot}files/curves-demo.csv`);o.shell.addTableView(e)})()}function s(){return a(function*(){let e=yield o.data.loadTable(`${l._package.webRoot}files/demo/Assay_Curves.csv`);yield e.meta.detectSemanticTypes();let t=yield l._package.files.readAsText("demo/Assay_Curves.layout"),n=r.ViewLayout.fromJson(t);e.selection.set(13,!0),e.selection.set(14,!0);let i=o.shell.addTableView(e);yield r.delay(100),i.loadLayout(n,!0),o.shell.info("Select cells in Trellis plot to see corresponding curves in Multi Curve Viewer.",{timeout:10})})()}n(590),n(991),n(788)},181(e,t,n){"use strict";n.d(t,{e:()=>b});var r=n(82),o=n(389),l=n(328),i=n(165),a=n(129),u=n(53),s=n(788),c=n(684),f=n(434),d=n(590),m=n(869),p=n(258);function h(e,t,n,r,o,l,i){try{var a=e[l](i),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function g(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function v(e,t,n){var o;return(o=function*(){let o=r.Func.find({package:"Curves",name:t})[0];if(!o)return void l.shell.error(`Curves: ${t} is not registered`);let i=e.cell.dataFrame,a=e.cell.column.name,u=new Set(i.columns.names());try{yield o.prepare(g({table:i,curveColumn:e.cell.column},n)).call(!1,void 0,{processed:!1})}catch(e){l.shell.error(`Could not add the statistic column: ${e}`);return}!function(e,t,n){if(0===t.length)return;let r=e.cell.dataFrame;r.columns.setOrder(y(r.columns.names(),t,n));let o=e.grid;if(!o)return;let l=[];for(let e=0;e<o.columns.length;e++){var i;let t=null==(i=o.columns.byIndex(e))?void 0:i.name;t&&l.push(t)}o.columns.setOrder(y(l,t,n))}(e,i.columns.names().filter(e=>!u.has(e)),a)},function(){var e=this,t=arguments;return new Promise(function(n,r){var l=o.apply(e,t);function i(e){h(l,n,r,i,a,"next",e)}function a(e){h(l,n,r,i,a,"throw",e)}i(void 0)})})()}function y(e,t,n){let r=e.filter(e=>!t.includes(e)),o=r.indexOf(n)+1;return[...r.slice(0,o),...t,...r.slice(o)]}function C(e){let t=e.root.querySelector(".ui-input-multi-choice-checks");return t&&(t.style.maxHeight="none",t.style.overflowY="visible"),e}class b extends r.ObjectHandler{get type(){return"GridCell"}isApplicable(e){return e instanceof r.GridCell&&e.cellType===s.h.FIT_CELL_TYPE}renderProperties(e,t=null){var n,l,h,y,b,w,x,T;let I=o.accordion("Curves property panel"),_=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}),O=o.input.forProperty(_);o.tooltip.bind(O.captionLabel,"Controls the level at which properties will be switched");let E=(0,u.h8)(e.cell),P=(0,u.bc)(e.cell.column),S=(0,u.Ig)(e.cell.dataFrame),N={onValueChanged:(t,n)=>(0,p.FC)(e,n,u.Th,O.value)},A={onValueChanged:(t,n)=>(0,p.FC)(e,n,u.ab,O.value)},L=e=>{if(S.seriesOptions&&!(0,c.Yc)(S.seriesOptions[e])&&P.seriesOptions&&!(0,c.Yc)(P.seriesOptions[e])){var t;E.seriesOptions?(0,c.Yc)(E.seriesOptions[e])||(E.seriesOptions[e]=r.Color.toHtml("outlierColor"===e?r.Color.red:r.Color.getCategoricalColor(0))):(null==(t=E.series)?void 0:t.length)&&!(0,c.Yc)(E.series[0][e])&&(E.series[0][e]=r.Color.toHtml("outlierColor"===e?r.Color.red:r.Color.getCategoricalColor(0)))}},M=e.cell;L("pointColor"),L("fitLineColor"),L("outlierColor"),(0,u.g2)(m.IL,P.seriesOptions,E.seriesOptions?E.seriesOptions:E.series&&null!=(n=E.series[0])?n:{}),(0,u.g2)(m.IL,S.seriesOptions,E.seriesOptions?E.seriesOptions:E.series&&null!=(l=E.series[0])?l:{}),(0,u.g2)(d.xs,P.chartOptions,E.chartOptions?E.chartOptions:{}),(0,u.g2)(d.xs,S.chartOptions,E.chartOptions?E.chartOptions:{}),(null==(y=E.chartOptions)?void 0:y.allowXZeroes)&&(null==(b=E.chartOptions)?void 0:b.logX)&&(null==(w=E.series)?void 0:w.some(e=>e.points.some(e=>0===e.x)))&&(0,u.B3)(E);let R=o.form([O]),F=E.seriesOptions?E.seriesOptions:E.series[0],X=F&&"object"==typeof F.fitFunction?F.fitFunction:null,D=(0,p.s9)(E,X).map(e=>{var t,n;if("fitFunction"!==e.name||!X)return C(o.input.forProperty(e,F,N));let r=(t=g({},F),n=n={fitFunction:X.name},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t);return o.input.forProperty(e,r,{onValueChanged:(e,t)=>{e!==X.name&&(F.fitFunction=e),N.onValueChanged(e,t)}})});o.forms.addGroup(R,"Series options",D),(null==(x=E.chartOptions)?void 0:x.showStatistics)&&(E.chartOptions.showStatistics=(0,p.QA)(E,E.chartOptions.showStatistics)),o.forms.addGroup(R,"Chart options",(0,p.di)(E).map(e=>C(o.input.forProperty(e,E.chartOptions,A)))),I.addPane("Options",()=>R);let Y=(null!=(h=null==(T=E.series)?void 0:T.length)?h:0)>1?["all","aggregated"]:["all"],j=r.Property.js("series",r.TYPE.STRING,{description:"Controls whether to show series statistics or aggregated statistics",defaultValue:"all",choices:Y,nullable:!1}),G=o.input.forProperty(j,null,{onValueChanged:()=>{I.getPane("Fit").root.lastElementChild.replaceChildren(V())}}),H=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}),k=o.input.forProperty(H,null,{onValueChanged:()=>{I.getPane("Fit").root.lastElementChild.replaceChildren(V())}});function V(){var t,n,r,l,a;let u=(null!=(t=null==(n=E.series)?void 0:n.length)?t:0)>1?"aggregated"===G.stringValue?[G.root,k.root]:[G.root]:null,s=o.divV(u),d=(0,i.s$)(E);if(d.x<=0&&E.chartOptions&&(E.chartOptions.logX=!1),d.y<=0&&E.chartOptions&&(E.chartOptions.logY=!1),"all"===G.stringValue){let t={logX:null==(r=E.chartOptions)?void 0:r.logX,logY:null==(l=E.chartOptions)?void 0:l.logY};for(let n=0;n<E.series.length;n++){let r=E.series[n],l=(0,f.TV)(r,n,t,M),u=(0,c.Z)(r,n,c.mE.FIT_LINE),d=null!=(a=r.name)?a:"series "+n;s.appendChild(o.panel([o.h1(d,{style:{color:u}}),o.input.form(l,(0,i.zB)(r).statisticsProperties,{onCreated:t=>t.root.appendChild(o.iconFA("plus",()=>v(e,"curveStatistic",{propName:t.property.name,seriesNumber:n}),`Calculate ${t.property.name} for the whole column`))})]))}}else{let t=(0,f.JR)(E,k.stringValue,M);s.appendChild(o.panel([o.h1(`series ${k.stringValue}`),o.input.form(t,(0,f.Uc)(E,k.stringValue),{onCreated:t=>t.root.appendChild(o.iconFA("plus",()=>v(e,"curveAggrStatistic",{propName:t.property.name,aggrType:k.stringValue}),`Calculate ${t.property.name} ${k.stringValue} for the whole column`))})]))}return s}let q=r.GridCellWidget.fromGridCell(e);q.canvas.addEventListener("click",e=>q.render());let B=I.addPane("Chart",()=>q.root),W=a.l.inflateScreenBounds(e.bounds);return(W.width<s.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||W.height<s.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT)&&(B.expanded=!0),I.addPane("Fit",()=>V()),I.root}}},476(e,t,n){"use strict";n.d(t,{I4:()=>g,Oz:()=>b,fU:()=>w,hC:()=>C});var r=n(82),o=n(328),l=n(389),i=n(858),a=n(165),u=n(869),s=n(788),c=n(533),f=n(124),d=n(53),m=n(434),p=n(324),h=n(663);function g(e,t,n=!1){var o,a;if(!e.cell.value)return;let u=r.GridCellWidget.fromGridCell(e);u.root.style.removeProperty("aspectRatio"),u.root.style.height="100%",u.canvas.style.removeProperty("height"),u.canvas.style.removeProperty("width"),u.canvas.style.left="18px",u.canvas.style.top="18px";let s=l.dialog({title:"Edit chart"}).add(u.root).show({resizable:!0,width:null!=(o=null==t?void 0:t.width)?o:500,height:null!=(a=null==t?void 0:t.height)?a:430});s.getButton("CANCEL").textContent="Close",n&&s.sub((0,i.merge)(e.grid.dataFrame.onDataChanged,e.grid.dataFrame.onMetadataChanged).subscribe(()=>u.render()))}function v(e,t,n){let o=n.xToScreen(t.x),l=n.yToScreen(t.y),i=(t.outlier?s.h.OUTLIER_PX_SIZE:s.h.POINT_PX_SIZE)/2+s.h.OUTLIER_HITBOX_RADIUS;return new r.Rect(o-i,l-i,2*i,2*i).containsPoint(new r.Point(e.x,e.y))}function y(e,t){var n,r,o,l;let i=(0,p.lc)(e,t),u=(0,p.Tv)(e,i.x,i.y,(0,p.ij)(e,t))[0];return new c.L((0,a.s$)(t),u,null!=(n=null==(o=t.chartOptions)?void 0:o.logX)&&n,null!=(r=null==(l=t.chartOptions)?void 0:l.logY)&&r)}function C(e,t){var n;if(!e.cell.value||!e.cell.column)return;let r=(0,d.h8)(e.cell,!1);for(let[e,t]of Object.entries(s.h.CONDITION_MAP))if(t(r.series)){o.shell.o=l.divText(e,{style:{color:"red"}});return}o.shell.o=e;let i=(0,p.fn)(e.bounds),a=y(i,r);for(let l=0;l<(null==(n=r.series)?void 0:n.length);l++)if(!r.series[l].connectDots&&r.series[l].clickToToggle&&"points"===r.series[l].showPoints&&!(i.width<s.h.MIN_AXES_CELL_PX_WIDTH)&&!(i.height<s.h.MIN_AXES_CELL_PX_HEIGHT))for(let n=0;n<r.series[l].points.length;n++){let i=r.series[l].points[n];if((!i.outlier||r.series[l].showOutliers)&&v({x:t.offsetX,y:t.offsetY},i,a))return void function(e,t,n,r,l){if(t.outlier=!t.outlier,(0,f.XN)(e.cell.column)){let l=JSON.parse(e.cell.value);l.series[n].points[r].outlier=t.outlier,e.cell.column.set(e.cell.rowIndex,JSON.stringify(l),!0),o.events.fireCustomEvent("fit-cell-outlier-toggle",{gridCell:e,series:l.series[n],seriesIdx:n,pointIdx:r})}let i=e.grid.dataFrame.columns.byTags({".sourceColumn":e.cell.column.name});if(i)for(let t of(null!=l||(l=(0,d.h8)(e.cell)),i)){var a,s;let r,o={logX:null==(a=l.chartOptions)?void 0:a.logX,logY:null==(s=l.chartOptions)?void 0:s.logY},i=t.tags[".statistics"];if(null!==t.tags[".seriesAggregation"])r=(0,m.JR)(l,t.tags[".seriesAggregation"],e.cell)[i];else{if(t.tags[".seriesNumber"]!==n.toString())continue;r=(0,u.h5)((0,m.TV)(l.series[n],n,o,e.cell),i)}t.set(e.cell.rowIndex,null!=r?r:null)}}(e,i,l,n,r)}}function b(e,t,n,o){var i,a,u,c,f,d,m;let p=y(t,e),g=(0,h.qd)(e,t)?(0,h.tp)(e,p.screen,o.x,o.y):null;if(null!==g)return l.tooltip.show((0,h.D5)(g),n.x+16,n.y+16),!0;for(let h=0;h<(null==(i=e.series)?void 0:i.length);h++)if("points"===e.series[h].showPoints)for(let i=0;i<e.series[h].points.length;i++){let g=e.series[h].points[i];if((!g.outlier||e.series[h].showOutliers)&&v(o,g,p))return l.tooltip.show(l.divV([l.divText(`${null!=(a=null==(c=e.chartOptions)?void 0:c.xAxisName)?a:"x"}: ${r.format(g.x,!(null==(f=e.chartOptions)?void 0:f.logX)?"#0.000":"scientific")}`),l.divText(`${null!=(u=null==(d=e.chartOptions)?void 0:d.yAxisName)?u:"y"}: ${r.format(g.y,!(null==(m=e.chartOptions)?void 0:m.logY)?"#0.000":"scientific")}`)]),n.x+16,n.y+16),!e.series[h].connectDots&&e.series[h].clickToToggle&&t.width>=s.h.MIN_AXES_CELL_PX_WIDTH&&t.height>=s.h.MIN_AXES_CELL_PX_HEIGHT&&(document.body.style.cursor="pointer"),!0}return!1}function w(e,t,n){var r;if(!(null==e||null==(r=e.cell)?void 0:r.value))return;let o=(0,p.fn)(e.bounds);if(o.width<s.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||o.height<s.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT){let r=l.canvas(300,200);n.render(r.getContext("2d"),0,0,300,200,e,null),l.tooltip.show(l.divV([r]),t.x,t.y)}let i=(0,d.h8)(null==e?void 0:e.cell);if(o.width>=s.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH&&o.height>=s.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT){if(b(i,o,t,{x:t.offsetX,y:t.offsetY}))return;l.tooltip.hide()}document.body.style.cursor="default"}},324(e,t,n){"use strict";n.d(t,{Tv:()=>l,W$:()=>f,ZK:()=>c,b1:()=>i,eG:()=>u,fn:()=>o,ij:()=>s,lc:()=>a,m:()=>d});var r=n(788);function o(e){return e.inflate(e.width<r.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH?r.h.MIN_INFLATE_SIZE:r.h.INFLATE_SIZE,e.height<r.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT?r.h.MIN_INFLATE_SIZE:r.h.INFLATE_SIZE)}function l(e,t,n,o){if(e.width<r.h.MIN_AXES_CELL_PX_WIDTH||e.height<r.h.MIN_AXES_CELL_PX_HEIGHT)return[e,void 0,void 0];let l=n?r.h.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:r.h.AXES_LEFT_PX_MARGIN,i=t?r.h.AXES_BOTTOM_PX_MARGIN_WITH_AXES_LABELS:r.h.AXES_BOTTOM_PX_MARGIN,a=o?r.h.AXES_TOP_PX_MARGIN_WITH_TITLE:r.h.AXES_TOP_PX_MARGIN,u=r.h.AXES_RIGHT_PX_MARGIN;return[e.cutLeft(l).cutBottom(i).cutTop(a).cutRight(u),e.getBottom(i).getTop(a).cutLeft(l).cutRight(u),e.getLeft(l).getRight(r.h.AXES_RIGHT_PX_MARGIN).cutBottom(i).cutTop(a)]}function i(e){return e.width>=r.h.MIN_AXES_CELL_PX_WIDTH&&e.height>=r.h.MIN_AXES_CELL_PX_HEIGHT}function a(e,t){var n,o;let l=e.width>=r.h.MIN_X_AXIS_NAME_VISIBILITY_PX_WIDTH&&e.height>=r.h.MIN_Y_AXIS_NAME_VISIBILITY_PX_HEIGHT;return{x:l&&!!(null==(n=t.chartOptions)?void 0:n.xAxisName),y:l&&!!(null==(o=t.chartOptions)?void 0:o.yAxisName)}}function u(e,t){let n=a(e,t);return n.x||n.y}function s(e,t){var n;return e.width>=r.h.MIN_TITLE_PX_WIDTH&&e.height>=r.h.MIN_TITLE_PX_HEIGHT&&!!(null==(n=t.chartOptions)?void 0:n.title)}function c(e){return e.width>=r.h.MIN_LEGEND_PX_WIDTH&&e.height>=r.h.MIN_LEGEND_PX_HEIGHT}function f(e){return e.width>=r.h.MIN_DROPLINE_LABELS_PX_WIDTH&&e.height>=r.h.MIN_DROPLINE_LABELS_PX_HEIGHT}function d(e){return e.width>=r.h.MIN_DROPLINES_VISIBILITY_PX_WIDTH&&e.height>=r.h.MIN_DROPLINES_VISIBILITY_PX_HEIGHT}},663(e,t,n){"use strict";let r;n.d(t,{D5:()=>C,GU:()=>b,qd:()=>s,tp:()=>w});var o=n(82),l=n(389),i=n(788),a=n(684),u=n(324);function s(e,t){var n,r;return(null==(n=null==(r=e.chartOptions)?void 0:r.showLegend)||n)&&(0,u.ZK)(t)}let c='11px Roboto, "Roboto Local"',f=new WeakMap;function d(e){return null!=r||(r=document.createElement("canvas").getContext("2d")),r.font=c,r.measureText(e).width}function m(e,t){if(d(e)<=t)return e;let n=e;for(;n.length>1&&d(`${n}…`)>t;)n=n.slice(0,-1);return`${n}…`}function p(e,t){var n;let r=t&&null!=(n=e.auxLegendName)?n:e.name;return""===r||null===r?void 0:r}function h(e,t){if(!(null==t?void 0:t.length))return 0;let n=e.inflate(14,14);return t.filter(e=>n.contains(e.x,e.y)).length}function g(e,t,n,r,l){let i=[new o.Rect(e.maxX-t-4,e.y+4,t,n),new o.Rect(e.x+4,e.y+4,t,n),new o.Rect(e.maxX-t-4,e.maxY-n-4,t,n),new o.Rect(e.x+4,e.maxY-n-4,t,n)],a=null!=l?l:0;if(!(null==r?void 0:r.length))return{rect:i[a],index:a};let u=i.map(e=>({taken:h(e,r),clearance:Math.min(...r.map(t=>{let n,r;return n=Math.max(e.x-t.x,0,t.x-e.maxX),Math.sqrt(n*n+(r=Math.max(e.y-t.y,0,t.y-e.maxY))*r)}))})),s=0;for(let e=1;e<i.length;e++)(u[e].taken<u[s].taken||u[e].taken===u[s].taken&&u[e].clearance>u[s].clearance)&&(s=e);return u[a].taken<=2||2*u[s].taken>=u[a].taken?{rect:i[a],index:a}:{rect:i[s],index:s}}function v(e){return Math.floor(i.h.POINT_PX_SIZE*e*1.5)+i.h.LEGEND_RECORD_LINE_PX_WIDTH+i.h.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN}function y(e,t,n,r,l){if(void 0===t.marker)return;let a=Math.floor(i.h.POINT_PX_SIZE*l*1.5);e.beginPath(),e.strokeStyle=t.color,e.lineWidth=2*l,e.moveTo(n+a,r),e.lineTo(n+a+i.h.LEGEND_RECORD_LINE_PX_WIDTH,r),e.stroke(),o.Paint.marker(e,t.marker,n+a/2,r,t.pointColor,a)}function C(e){let t=1===e.length,n=e.slice(0,Math.max(10,Math.floor(.75*window.innerHeight/i.h.LEGEND_RECORD_PX_HEIGHT))),r=n.map(e=>{let n=l.canvas(v(1),i.h.LEGEND_RECORD_PX_HEIGHT);y(n.getContext("2d"),e,0,i.h.LEGEND_RECORD_PX_HEIGHT/2,1);let r=l.divH([n,l.divText(t?e.text:m(e.text,400),{style:{color:e.color}})]);return r.style.alignItems="center",r});return e.length>n.length&&r.push(l.divText(`+${e.length-n.length} more`)),l.divV(r)}function b(e,t,n,r,l){let u=function(e,t,n,r){let l=f.get(e),u=function(e){var t,n,r,l;let i=null!=(t=e.series)?t:[],u=[...new Set(i.map(e=>e.columnName))].filter(e=>null!=e),s=[];for(let t of u){let n=i.map((e,t)=>({series:e,idx:t})).filter(({series:n})=>{var r;return n.columnName===t&&p(n,null==(r=e.chartOptions)?void 0:r.useAuxLegendNames)});if(0!==n.length)for(let{series:i,idx:u}of((null==(r=e.chartOptions)?void 0:r.showColumnLabel)&&n.length>1&&s.push({text:t,color:"black"}),n))s.push({text:p(i,null==(l=e.chartOptions)?void 0:l.useAuxLegendNames),column:t,color:(0,a.Z)(i,u,a.mE.FIT_LINE),pointColor:(0,a.Z)(i,u,a.mE.POINT),marker:function(e){var t,n,r;let l=(null==(n=e.points)?void 0:n.length)?e.points[0].marker:null,i=(null==(r=e.points)?void 0:r.every(e=>e.marker===l&&null!=e.marker))?l:null;return null!=(t=null!=i?i:e.markerType)?t:o.MARKER_TYPE.CIRCLE}(i)})}let c=new Map;for(let e of s.filter(e=>void 0!==e.marker&&e.column))(null!=(n=c.get(e.text))?n:c.set(e.text,new Set).get(e.text)).add(e.column);for(let e of s)void 0!==e.marker&&e.column&&c.get(e.text).size>1&&(e.text=`${e.column}: ${e.text}`);return s}(e);if(0===u.length)return{rows:[],hidden:0,entries:u,corner:0,whole:!0};let s=v(n);if(.55*t.width-s<=0)return{rows:[],hidden:0,entries:u,corner:0,whole:!0};let c=Math.floor(.5*t.height/i.h.LEGEND_RECORD_PX_HEIGHT),y=u.length>c?u.slice(0,Math.max(1,c-1)):u,C=u.length-y.length,b=i.h.LEGEND_RECORD_PX_HEIGHT*(y.length+ +(C>0)),w=Math.min(s+Math.max(...y.map(e=>d(e.text)),C>0?d(`+${C} more`):0),t.width-8),x=g(t,w,b,r,null==l?void 0:l.corner),T=(null==l?void 0:l.whole)?12:2,I=h(x.rect,r)<=T,_=I?w:Math.min(w,.55*t.width),O=y.map(e=>m(e.text,_-s)),E=s+Math.max(...O.map(d)),P=I?x:g(t,E,b,r,null==l?void 0:l.corner),S=P.rect,N=y.map((e,t)=>({entry:e,shown:O[t],box:new o.Rect(S.x,S.y+i.h.LEGEND_RECORD_PX_HEIGHT*t,E,i.h.LEGEND_RECORD_PX_HEIGHT)})),A=0===C?void 0:new o.Rect(S.x,S.y+i.h.LEGEND_RECORD_PX_HEIGHT*N.length,E,i.h.LEGEND_RECORD_PX_HEIGHT);return{rows:N,hidden:C,moreBox:A,entries:u,corner:P.index,whole:I}}(t,n,r,l),{rows:s,hidden:C}=u;if(0===s.length)return;f.set(t,{box:n,rows:s,moreBox:u.moreBox,entries:u.entries,corner:u.corner,whole:u.whole}),e.save(),e.font=c,e.textAlign="left";let b=s[0].box,w=i.h.LEGEND_RECORD_PX_HEIGHT*(s.length+ +(C>0));for(let t of(e.fillStyle="rgba(255, 255, 255, 0.75)",e.fillRect(b.x-3,b.y-3,b.width+6,w+6),s)){let n=t.box.maxY-i.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN;y(e,t.entry,t.box.x,n-i.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN,r),e.fillStyle=t.entry.color,e.fillText(t.shown,t.box.x+(void 0===t.entry.marker?0:v(r)),n)}C>0&&(e.fillStyle="black",e.fillText(`+${C} more`,b.x,s[s.length-1].box.maxY+i.h.LEGEND_RECORD_PX_HEIGHT-i.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN)),e.restore()}function w(e,t,n,r){var o;let l=f.get(e);if(!l||Math.round(l.box.x)!==Math.round(t.x)||Math.round(l.box.width)!==Math.round(t.width))return null;if(null==(o=l.moreBox)?void 0:o.contains(n,r))return l.entries;let i=l.rows.find(e=>e.box.contains(n,r));return i&&i.shown!==i.entry.text?[i.entry]:null}},258(e,t,n){"use strict";n.d(t,{FC:()=>y,QA:()=>m,di:()=>d,s9:()=>p});var r=n(82),o=n(328),l=n(165),i=n(590),a=n(788),u=n(869),s=n(53),c=n(124);let f=["logX","logY","allowXZeroes","fitFunction","errorModel"];function d(e){var t,n,o;let a=[];for(let n of null!=(t=e.series)?t:[])for(let e of(0,l.zB)(n).statisticsProperties)a.includes(e.name)||a.push(e.name);let u=function(e){var t,n,r,o;let l=Object.keys(null!=(t=null==(r=e.chartOptions)?void 0:r.labels)?t:{});for(let t of null!=(n=e.series)?n:[])for(let e of Object.keys(null!=(o=t.labels)?o:{}))l.includes(e)||l.push(e);return l}(e),s=(null!=(n=null==(o=e.series)?void 0:o.length)?n:0)>1;return i.xs.filter(e=>("showLabels"!==e.name||u.length>0)&&("statisticsMode"!==e.name&&"aggrType"!==e.name||s)).map(e=>"showStatistics"===e.name&&a.length>0?r.Property.js("showStatistics",r.TYPE.STRING_LIST,{description:e.description,choices:a,inputType:"MultiChoice",friendlyName:"Statistics"}):"showLabels"===e.name?r.Property.js("showLabels",r.TYPE.STRING_LIST,{description:e.description,choices:u,inputType:"MultiChoice",friendlyName:"Labels"}):e)}function m(e,t){let n=[];for(let o of t){var r;let t=o;for(let n of null!=(r=e.series)?r:[]){let e=(0,u.Wh)((0,l.zB)(n),o);if(e){t=e.name;break}}n.includes(t)||n.push(t)}return n}function p(e,t){let n=u.IL.filter(e=>"columnName"!==e.name).filter(t=>{var n;return"droplines"!==t.name||(null!=(n=e.series)?n:[]).some(e=>(0,l.zB)(e).hasAsymptotes)}),o=[...new Set([...t?[t.name]:[],...Object.keys(u.rT)])];return n.map(e=>{var n;return"fitFunction"!==e.name?e:r.Property.js("fitFunction",r.TYPE.STRING,{category:"Fitting",choices:o,nullable:!1,defaultValue:null!=(n=null==t?void 0:t.name)?n:u.hD})})}function h(e,t,n){var r,o,l;let i=null!=(o=(r=null!=(l=e.explicit)?l:e.explicit={})[t])?o:r[t]=[];i.includes(n)||i.push(n)}function g(e,t,n){var r;let o=null==(r=e.explicit)?void 0:r[t];return!!(null==o?void 0:o.includes(n))&&(o.splice(o.indexOf(n),1),!0)}function v(e,t){return"fitFunction"===e&&"string"==typeof t&&u.HM[t]?u.HM[t]:t}function y(e,t,n,r){var l,i,u;let d,m=t.property.name,p=f.includes(m);if("Cell"===r){let r;if(!(0,c.XN)(e.cell.column))return;let l=e.cell.value;if(""===l)return;try{r=null!=(i=JSON.parse(null!=l?l:"{}"))?i:{}}catch(e){o.shell.error(`Curves: this cell holds malformed data, so the option was not applied: ${e}`);return}!function(e,t,n){let r=t.property.name,o=v(r,t.value);if(n===s.ab){if(void 0===e.chartOptions)return;e.chartOptions[r]=o}else{if(void 0===e.series)return;for(let t of e.series)t[r]=o}h(e,n,r)}(r,t,n),e.cell.column.set(e.cell.rowIndex,JSON.stringify(r),p),p||e.cell.dataFrame.fireValuesChanged(),e.grid.invalidate();return}let y="Dataframe"===r?(0,s.Ig)(e.cell.dataFrame):(0,s.bc)(e.cell.column);for(let o of((null!=(l=y[n])?l:y[n]={})[m]=v(m,t.value),h(y,n,m),"Dataframe"===r?((0,s.G_)(e.cell.dataFrame.tags,y),d=e.cell.dataFrame.columns.bySemTypeAll(a.h.FIT_SEM_TYPE)):((0,s.G_)(e.cell.column.tags,y),d=[e.cell.column]),d)){if("Dataframe"===r){let e=(0,s.bc)(o),t=e[n];t&&delete t[m],g(e,n,m),(0,s.G_)(o.tags,e)}if((0,c.XN)(o))for(let e=0;e<o.length;e++){let t,r=o.get(e);if(""!==r){try{t=null!=(u=JSON.parse(r))?u:{}}catch(e){continue}g(t,n,m)&&o.set(e,JSON.stringify(t),!1)}}}if(p)for(let e of d)e.fireValuesChanged();p||e.cell.dataFrame.fireValuesChanged(),e.grid.invalidate()}},129(e,t,n){"use strict";n.d(t,{l:()=>g});var r=n(82),o=n(328),l=n(533),i=n(165),a=n(788),u=n(684),s=n(663),c=n(434),f=n(53),d=n(324),m=n(476);function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function h(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}class g extends r.GridCellRenderer{get name(){return a.h.FIT_CELL_TYPE}get cellType(){return a.h.FIT_CELL_TYPE}get defaultHeight(){return a.h.CELL_DEFAULT_HEIGHT}get defaultWidth(){return a.h.CELL_DEFAULT_WIDTH}getDefaultSize(e){return{width:a.h.CELL_DEFAULT_WIDTH,height:a.h.CELL_DEFAULT_HEIGHT}}static inflateScreenBounds(e){return(0,d.fn)(e)}onClick(e,t){(0,m.hC)(e,t)}onDoubleClick(e,t){(0,m.I4)(e,void 0,!0),t.preventDefault(),t.stopPropagation()}onMouseMove(e,t){(0,m.fU)(e,t,this)}renderCurves(e,t,n,o,m){var g,v,y,C,b,w,x,T,I,_,O,E,P,S,N,A,L,M,R,F,X,D,Y,j,G,H,k,V;e.save(),e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.clip();let q=(null==o?void 0:o.grid)&&(null==o?void 0:o.grid.dart)&&e.canvas===(null==o||null==(b=o.grid)?void 0:b.canvas)&&!(null==(w=n.chartOptions)?void 0:w.mergeSeries),B=null==o?void 0:o.cell;(null==(x=n.chartOptions)?void 0:x.allowXZeroes)&&(null==(T=n.chartOptions)?void 0:T.logX)&&(null==(I=n.series)?void 0:I.some(e=>e.points.some(e=>0===e.x)))&&(0,f.B3)(n);let W=(0,d.lc)(t,n),[$,U,Z]=(0,d.Tv)(t,W.x,W.y,(0,d.ij)(t,n)),z=(0,i.s$)(n);(z.x<0&&n.chartOptions||0===z.x&&n.chartOptions&&!n.chartOptions.allowXZeroes)&&(n.chartOptions.logX=!1),z.y<=0&&n.chartOptions&&(n.chartOptions.logY=!1);let J={logX:null==(_=n.chartOptions)?void 0:_.logX,logY:null==(O=n.chartOptions)?void 0:O.logY},Q=[];for(let e=0;e<(null==(E=n.series)?void 0:E.length);e++){let t=n.series[e];if(t.points.some(e=>void 0===e.x||void 0===e.y)||t.points.length<=1){Q.push(null);continue}t.points.sort((e,t)=>e.x-t.x);let r=(0,i.zB)(t),o=null,l=t,a=!0;if(!(t.connectDots&&!(null==(j=t.showFitLine)||j)))if(t.parameters)l=(0,i.iK)(t,J),o=(0,i._T)(l,r);else{let n=(0,f.IY)(t,e,r,J,B,q,null==m?void 0:m[e]);o=n.fittedCurve,l=h(p({},t),{parameters:[...n.parameters]}),a=!1}Q.push({fitFunc:r,curve:o,fitSpaceSeries:l,userParamsFlag:a})}z=function(e,t,n){var o,l;let i=null!=(o=null==n?void 0:n.logX)&&o,a=null!=(l=null==n?void 0:n.logY)&&l,u=e.minY,s=e.maxY;for(let n of t)if(n)for(let t=0;t<=100;t++){let r=t/100,o=i?e.minX*Math.pow(e.maxX/e.minX,r):e.minX+e.width*r,l=n(i?Math.log10(o):o),c=a?Math.pow(10,l):l;isFinite(c)&&(u=Math.min(u,c),s=Math.max(s,c))}if((null==n?void 0:n.minY)!=null&&(u=e.minY),(null==n?void 0:n.maxY)!=null&&(s=e.maxY),u>=e.minY&&s<=e.maxY)return e;if(a&&e.minY>0){let t=(Math.log10(e.maxY)-Math.log10(e.minY))*.15;u=Math.max(u,Math.pow(10,Math.log10(e.minY)-t)),s=Math.min(s,Math.pow(10,Math.log10(e.maxY)+t))}else u=Math.max(u,e.minY-.15*e.height),s=Math.min(s,e.maxY+.15*e.height);if(u>=e.minY&&s<=e.maxY)return e;let c=s-u,f=u<e.minY?a&&u>0?u/1.05:u-.05*c:e.minY,d=s>e.maxY?a?1.05*s:s+.05*c:e.maxY;return new r.Rect(e.x,f,e.width,d-f)}(z,Q.map(e=>(null==e?void 0:e.fitFunc.hasAsymptotes)?e.curve:null),n.chartOptions);let K=new l.L(z,$,null!=(g=null==(P=n.chartOptions)?void 0:P.logX)&&g,null!=(v=null==(S=n.chartOptions)?void 0:S.logY)&&v),ee=Math.min($.width,$.height),et=ee>100?1:.2+ee/100*.8,en=(0,s.qd)(n,t)?[]:void 0;e.save(),e.font='11px Roboto, "Roboto Local"',K.drawCoordinateGrid(e,U,Z),e.restore();let er=(0,u.S3)(e,null==(N=n.chartOptions)?void 0:N.labels,{names:null==(A=n.chartOptions)?void 0:A.showLabels,color:a.h.PLOT_LABEL_COLOR,dataBox:$,screenBounds:t,startLine:0,drawnAt:en}),eo=(null!=(y=null==(L=n.series)?void 0:L.length)?y:0)>1&&null!=(C=null==(M=n.chartOptions)?void 0:M.statisticsMode)?C:"series",el=null==(R=n.chartOptions)?void 0:R.showStatistics;if((null==el?void 0:el.length)&&"series"!==eo){let r=null!=(G=null==(H=n.chartOptions)?void 0:H.aggrType)?G:"med",o=(0,c.JR)(n,r,B),l=Object.fromEntries(el.map(e=>[`${r} ${e}`,o[e]]));er+=(0,u.S3)(e,l,{names:Object.keys(l),color:a.h.PLOT_LABEL_COLOR,dataBox:$,screenBounds:t,startLine:er,drawnAt:en})}for(let o=0;o<(null==(F=n.series)?void 0:F.length);o++){let l=n.series[o],i=Q[o];if(!i)continue;let{fitFunc:s,curve:c,fitSpaceSeries:m,userParamsFlag:p}=i,h=a.h.POINT_PX_SIZE*et/2,g=$.inflate(h,h);if(e.save(),e.beginPath(),e.rect(g.x,g.y,g.width,g.height),e.clip(),(0,u.qR)(e,l,{viewport:K,ratio:et,logOptions:J,showAxes:(0,d.b1)(t),showAxesLabels:(0,d.eG)(t,n),screenBounds:t,curveFunc:c,seriesIdx:o,drawnAt:en}),(0,u.nx)(e,l,{viewport:K,ratio:et,seriesIdx:o}),(0,u.QW)(e,l,{viewport:K,ratio:et,screenBounds:t,seriesIdx:o}),en){let e=null;for(let t of l.points){if(t.outlier&&!(null==(V=l.showOutliers)||V))continue;let n=new r.Point(K.xToScreen(t.x),K.yToScreen(t.y));if(en.push(n),e){let t=Math.floor(Math.abs(n.x-e.x)/u.dT);for(let o=1;o<t;o++)en.push(new r.Point(e.x+(n.x-e.x)*o/t,e.y+(n.y-e.y)*o/t))}e=n}}(0,u.Zk)(e,m,{viewport:K,logOptions:J,showAxes:(0,d.b1)(t),showAxesLabels:(0,d.eG)(t,n),screenBounds:t,fitFunc:s,userParamsFlag:p,drawnAt:en,dataPoints:(0,f.Xm)(l,o,J,p,B,q)}),(0,u.HQ)(e,m,{viewport:K,ratio:et,showDroplines:(0,d.m)(t),showDroplineLabels:(0,d.W$)(t),fitFunc:s,dataBounds:z,curveFunc:c,logOptions:J,drawnAt:en}),e.restore(),er+=(0,u.yv)(e,m,{statistics:"aggregated"===eo?[]:el,fitFunc:s,logOptions:J,dataBox:$,screenBounds:t,seriesIdx:o,startLine:er,drawnAt:en}),er+=(0,u.S3)(e,l.labels,{names:null==(k=n.chartOptions)?void 0:k.showLabels,color:(0,u.Z)(l,o,u.mE.FIT_LINE),dataBox:$,screenBounds:t,startLine:er,drawnAt:en})}(0,u.zF)(e,{showTitle:(0,d.ij)(t,n),title:null==(X=n.chartOptions)?void 0:X.title,dataBox:$,screenBounds:t}),(0,u.jI)(e,{showTitle:(0,d.ij)(t,n),dataBox:$,screenBounds:t,showAxesLabels:(0,d.eG)(t,n),xAxisName:null==(D=n.chartOptions)?void 0:D.xAxisName,yAxisName:null==(Y=n.chartOptions)?void 0:Y.yAxisName}),en&&(0,s.GU)(e,n,$,et,en),e.restore()}render(e,t,n,o,l,i,u){var s,c,d,m,v,y;if(!i.cell.value||o<a.h.MIN_CELL_RENDERER_PX_WIDTH||l<a.h.MIN_CELL_RENDERER_PX_HEIGHT)return;let C=(null==i?void 0:i.grid)&&(null==i?void 0:i.grid.dart)&&e.canvas===(null==i||null==(s=i.grid)?void 0:s.canvas),b=(0,f.h8)(i.cell,C),w=g.inflateScreenBounds(new r.Rect(t,n,o,l));for(let[t,n]of Object.entries(a.h.CONDITION_MAP))if(n(b.series)){return void(v=e,y=w,r.Paint.marker(v,r.MARKER_TYPE.OUTLIER,y.midX,y.midY,r.Color.red,Math.min(Math.max(.8*Math.min(y.width,y.height),0),30)))}(null==(c=i.cell.column)?void 0:c.name)&&(null==(d=b.series)||d.forEach(e=>e.columnName=i.cell.column.name)),(null==(m=b.chartOptions)?void 0:m.mergeSeries)&&(b=h(p({},b),{series:[(0,f.wU)(b.series)]})),e.clearRect(w.x,w.y,w.width,w.height),this.renderCurves(e,w,b,i)}}g.fittedCurves=f.bZ,g.parsedCurves=f.uc,g.curvesDataPoints=f.CP,g=function(e,t,n,r){var o,l=arguments.length,i=l<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(l<3?o(i):l>3?o(t,n,i):o(t,n))||i);return l>3&&i&&Object.defineProperty(t,n,i),i}([o.decorators.cellRenderer({name:"Fit",cellType:"fit",virtual:!0})],g)},434(e,t,n){"use strict";n.d(t,{JR:()=>p,TV:()=>f,Uc:()=>m,bW:()=>g,i4:()=>v});var r=n(82),o=n(165),l=n(590),i=n(869),a=n(53),u=n(124);let s={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"},c=new Set(["min","max","avg","med","q1","q2","q3"]);function f(e,t,n,r,l=!0,i=!0){var u,s;let c=(0,o.zB)(e),d=e.parameters?(0,o.iK)(e,n):(u=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e),s=s={parameters:[...(0,a.IY)(e,t,c,n,r,l).parameters]},Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(s)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(s)).forEach(function(e){Object.defineProperty(u,e,Object.getOwnPropertyDescriptor(s,e))}),u),m=(0,o.xS)(d,c,(0,a.Xm)(e,t,n,!1,r,l),n);return i?(0,o.KZ)(m,n):m}let d=new Set(o.GO);function m(e,t){var n;let r=null!=(n=e.series)?n:[];if(!r.length)return l.nK;let i=[...(0,o.zB)(r[0]).statisticsProperties];for(let e=1;e<r.length;e++){let t=new Set((0,o.zB)(r[e]).statisticsProperties.map(e=>e.name));i=i.filter(e=>t.has(e.name))}return void 0===t||c.has(t)||(i=i.filter(e=>!d.has(e.name))),i}function p(e,t,n){var a,u,d;let p={logX:null==(a=e.chartOptions)?void 0:a.logX,logY:null==(u=e.chartOptions)?void 0:u.logY},h=new Map,g=[],v=new Set(m(e,t).map(e=>e.name));for(let t=0;t<(null==(d=e.series)?void 0:d.length);t++){let r=e.series[t];if(r.points.every(e=>e.outlier))continue;let a=(0,o.zB)(r);g.push(a);let u=f(r,t,p,n,!0,!1);for(let e of a.statisticsProperties)v.has(e.name)&&(h.has(e.name)||h.set(e.name,[]),h.get(e.name).push((0,i.h5)(u,e.name)));for(let e of l.Al){if(v.has(e))continue;let t=(0,i.Wh)((0,o.zB)(r),e);t&&t.name!==e||(h.has(e)||h.set(e,[]),h.get(e).push((0,i.h5)(u,e)))}}let y={};for(let[e,n]of h)y[e]=n.some(e=>null==e||isNaN(e))?void 0:r.Stats.fromValues(n)[s[t]];for(let e of(c.has(t)&&(0,o.KZ)(y,p),l.Al))if(void 0===y[e])for(let t of g){let n=(0,i.Wh)(t,e);if(n&&void 0!==y[n.name]){y[e]=y[n.name];break}}return y}function h(e,t,n){var r,o,l;let i=e.get(t);if(null==i||""===i)return null;let s=e.dataFrame?e.dataFrame.cell(t,e.name):void 0,c=s?(0,a.h8)(s,!0):(0,a.mI)((0,u.HB)((0,a.RH)(i),e),e,n);return(null==(r=c.chartOptions)?void 0:r.allowXZeroes)&&(null==(o=c.chartOptions)?void 0:o.logX)&&(null==(l=c.series)?void 0:l.some(e=>e.points.some(e=>0===e.x)))&&(0,a.B3)(c),{data:c,cell:s}}function g(e,t,n,r,o){var l,a,u,s;let c=h(e,t,o);if(!c)return null;let d=null==(a=c.data.series)?void 0:a[r];if(!d||d.points.every(e=>e.outlier))return null;let m={logX:null==(u=c.data.chartOptions)?void 0:u.logX,logY:null==(s=c.data.chartOptions)?void 0:s.logY};return null!=(l=(0,i.h5)(f(d,r,m,c.cell,!0),n))?l:null}function v(e,t,n,r,o){var l,i;let a=h(e,t,o);return!a||(null==(i=a.data.series)?void 0:i.every(e=>e.points.every(e=>e.outlier)))?null:null!=(l=p(a.data,r,a.cell)[n])?l:null}},684(e,t,n){"use strict";n.d(t,{S3:()=>E,QW:()=>C,zF:()=>S,jI:()=>N,Z:()=>v,yv:()=>P,Yc:()=>g,dT:()=>d,mE:()=>h,nx:()=>y,HQ:()=>_,Zk:()=>T,qR:()=>x});var r,o=n(82),l=n(165),i=n(788),a=n(18);let u="u">typeof window?window:n.g.window,s=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2});class c{static getUniqueName(e,t,n){return u.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 s.format(e)}}var f=n(869);let d=8,m='11px Roboto, "Roboto Local"';function p(e,t,n,r,l){if(!e)return;let i=t.measureText(n).width;for(let t=r;t<=r+i;t+=d)e.push(new o.Point(t,l))}var h=((r={}).POINT="pointColor",r.OUTLIER="outlierColor",r.FIT_LINE="fitLineColor",r);function g(e){return null!=e&&""!==e&&void 0!==o.Color.fromHtml(e)}function v(e,t,n){let r=o.Color.toHtml("outlierColor"===n?o.Color.red:o.Color.getCategoricalColor(t));return e[n]&&o.Color.fromHtml(e[n])?e[n]:r}function y(e,t,n){var r;if(null!=(r=t.connectDots)&&r){let r=n.viewport;e.strokeStyle=v(t,n.seriesIdx,"pointColor"),e.lineWidth=2*n.ratio,e.beginPath();for(let n=0;n<t.points.length;n++){let o=t.points[n].x,l=t.points[n].y,i=r.xToScreen(o),a=r.yToScreen(l);0===n?e.moveTo(i,a):e.lineTo(i,a)}e.stroke()}}function C(e,t,n){var r;let l=n.screenBounds;(l.width<i.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||l.height<i.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT?"":null!=(r=t.showPoints)?r:"points")&&(e.strokeStyle=v(t,n.seriesIdx,"pointColor"),t.connectDots||"points"===t.showPoints?function(e,t,n){let r=n.ratio,l=i.h.POINT_PX_SIZE*r,a=n.viewport,u=t.connectDots,s=v(t,n.seriesIdx,"pointColor"),c=v(t,n.seriesIdx,"outlierColor");for(let p=0;p<t.points.length;p++){let h=t.points[p];if(h.outlier&&!t.showOutliers)continue;let g=a.xToScreen(h.x),v=a.yToScreen(h.y),y=u?s:h.outlier?h.outlierColor&&o.Color.fromHtml(h.outlierColor)?h.outlierColor:c:h.color&&o.Color.fromHtml(h.color)?h.color:s,C=h.marker?h.marker:t.markerType,b=h.outlierMarker?h.outlierMarker:t.outlierMarkerType,w=Math.min(i.h.OUTLIER_PX_SIZE*r,a.screen.height/10),x=u?l:h.outlier?w:h.size?h.size:l,T=u?C:h.outlier?b:C;if(o.Paint.marker(e,T,g,v,y,x),h.stdev&&!h.outlier){var f,d,m;let t=x/2,l=(f=a.yToScreen(h.y+h.stdev),d=a.yToScreen(h.y-h.stdev),v-f<=t?null:{top:[f,v-t],bottom:[v+t,d]});l&&(null==(m=n.drawnAt)||m.push(new o.Point(g,l.top[0]),new o.Point(g,l.bottom[1])),e.strokeStyle=y,e.lineWidth=r,e.beginPath(),e.moveTo(g,l.top[0]),e.lineTo(g,l.top[1]),e.moveTo(g,l.bottom[0]),e.lineTo(g,l.bottom[1]),e.moveTo(g-t,l.top[0]),e.lineTo(g+t,l.top[0]),e.moveTo(g-t,l.bottom[1]),e.lineTo(g+t,l.bottom[1]),e.stroke())}}}(e,t,n):["candlesticks","both"].includes(t.showPoints)&&function(e,t,n){let r=n.ratio,l=n.viewport,u=v(t,n.seriesIdx,"pointColor");for(let n=0,s=null;n<t.points.length;n++){let c=t.points[n];if(c.outlier)continue;let f=n+1<t.points.length&&t.points[n+1].x===c.x;if(!s&&f)s=n;else if(null!==s&&!f){let f=[];for(let e=s,r=0;e<=n;e++,r++)f[r]=t.points[e].y;let d=(0,a.k)(f);if(e.beginPath(),function(e,t){let n=t.viewport,r=t.x,l=n.xToScreen(r),a=t.boxPlotStats;b(e,r,a.lowerAdjacentValue,n),e.moveTo(l,n.yToScreen(a.lowerAdjacentValue)),e.lineTo(l,n.yToScreen(a.upperAdjacentValue)),b(e,r,a.upperAdjacentValue,n),o.Paint.marker(e,o.MARKER_TYPE.CIRCLE,l,n.yToScreen(a.q2),t.color,i.h.CANDLESTICK_MEDIAN_PX_SIZE*t.ratio)}(e,{viewport:l,ratio:r,x:c.x,boxPlotStats:d,color:u}),e.stroke(),"both"===t.showPoints)for(let t=0;t<f.length;t++)(f[t]<d.lowerAdjacentValue||f[t]>d.upperAdjacentValue)&&o.Paint.marker(e,o.MARKER_TYPE.OUTLIER,l.xToScreen(c.x),l.yToScreen(f[t]),u,i.h.CANDLESTICK_OUTLIER_PX_SIZE*r);s=null}}}(e,t,n))}function b(e,t,n,r){let o=r.xToScreen(t),l=r.yToScreen(n);e.moveTo(o-i.h.CANDLESTICK_BORDER_PX_SIZE/2,l),e.lineTo(o+i.h.CANDLESTICK_BORDER_PX_SIZE/2,l)}function w(e){let t=e.logOptions.logX,n=e.logOptions.logY,r=e.viewport;return{logX:t,logY:n,xMin:r.screen.left,xMax:r.screen.maxX,viewport:r}}function x(e,t,n){var r;if(null==(r=t.showFitLine)||r){e.save(),e.strokeStyle=v(t,n.seriesIdx,"fitLineColor"),e.lineWidth=2*n.ratio,e.beginPath(),t.lineStyle&&e.setLineDash(i.h.LINE_STYLES[t.lineStyle]);let{logX:r,logY:l,xMin:a,xMax:u,viewport:s}=w(n),c=n.curveFunc;for(let t=a;t<=u;t++){let i=r?Math.log10(s.xToWorld(t)):s.xToWorld(t),u=l?s.yToScreen(Math.pow(10,c(i))):s.yToScreen(c(i));n.drawnAt&&t%d==0&&n.drawnAt.push(new o.Point(t,u)),t===a?e.moveTo(t,u):e.lineTo(t,u)}e.stroke(),e.restore()}}function T(e,t,n){var r,o,a,u;if((null==(r=t.showFitLine)||r)&&null!=(o=t.showCurveConfidenceInterval)&&o){e.strokeStyle=null!=(a=t.confidenceIntervalColor)?a:i.h.CONFIDENCE_INTERVAL_STROKE_COLOR,e.fillStyle=null!=(u=t.confidenceIntervalColor)?u:i.h.CONFIDENCE_INTERVAL_FILL_COLOR;let r=n.showAxes,o=n.showAxesLabels,s=n.logOptions,c=n.viewport,f=n.screenBounds,d=n.dataPoints,m=(0,l.fY)(t,n.fitFunc,n.userParamsFlag,d,s);I(e,{viewport:c,logOptions:s,showAxes:r,showAxesLabels:o,screenBounds:f,confidenceIntervals:m,confidenceType:i.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP}),I(e,{viewport:c,logOptions:s,showAxes:r,showAxesLabels:o,screenBounds:f,confidenceIntervals:m,confidenceType:i.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.BOTTOM}),function(e,t){e.beginPath();let{logX:n,logY:r,xMin:o,xMax:l,viewport:i}=w(t),a=t.confidenceIntervals.confidenceTop,u=t.confidenceIntervals.confidenceBottom;for(let t=o;t<=l;t++){let l=n?Math.log10(i.xToWorld(t)):i.xToWorld(t),u=r?i.yToScreen(Math.pow(10,a(l))):i.yToScreen(a(l));t===o?e.moveTo(t,u):e.lineTo(t,u)}for(let t=l;t>=o;t--){let o=n?Math.log10(i.xToWorld(t)):i.xToWorld(t),l=r?i.yToScreen(Math.pow(10,u(o))):i.yToScreen(u(o));e.lineTo(t,l)}e.closePath(),e.fill()}(e,{viewport:c,logOptions:s,showAxes:r,showAxesLabels:o,screenBounds:f,confidenceIntervals:m})}}function I(e,t){e.beginPath();let{logX:n,logY:r,xMin:l,xMax:a,viewport:u}=w(t),s=t.confidenceType===i.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP?t.confidenceIntervals.confidenceTop:t.confidenceIntervals.confidenceBottom;for(let i=l;i<=a;i++){let a=n?Math.log10(u.xToWorld(i)):u.xToWorld(i),c=r?u.yToScreen(Math.pow(10,s(a))):u.yToScreen(s(a));t.drawnAt&&i%d==0&&t.drawnAt.push(new o.Point(i,c)),i===l?e.moveTo(i,c):e.lineTo(i,c)}e.stroke()}function _(e,t,n){var r,l;if(!(null==(r=t.showFitLine)||r)||!(null==(l=t.droplines)?void 0:l.length)||!t.parameters||!n.showDroplines)return;e.save(),e.strokeStyle="blue",e.lineWidth=n.ratio,e.beginPath(),e.setLineDash([5,5]);let i=[];for(let r of t.droplines){let l=function(e){let t=/^(?:IC|EC)(\d{1,2}(?:\.\d+)?)$/i.exec(e),n=t?parseFloat(t[1]):NaN;return n>0&&n<100?n/100:void 0}(r),a=void 0===l?void 0:n.fitFunc.inverse(Float32Array.from(t.parameters),l),u=void 0===a?null:function(e,t,n){let r=n.logOptions.logX,l=n.logOptions.logY,i=r?Math.pow(10,t):t,a=n.viewport,u=n.dataBounds;if(i<u.minX||i>u.maxX)return null;let s=r?Math.log10(i):i,c=l?Math.pow(10,n.curveFunc(s)):n.curveFunc(s),f=a.xToScreen(i),m=a.yToScreen(c),p=a.xToScreen(u.minX),h=a.yToScreen(u.minY);if(e.moveTo(p,m),e.lineTo(f,m),e.lineTo(f,h),n.drawnAt){for(let e=p;e<=f;e+=d)n.drawnAt.push(new o.Point(e,m));for(let e=m;e<=h;e+=d)n.drawnAt.push(new o.Point(f,e))}return m}(e,a,n);null!==u&&i.push({name:r,screenY:u})}if(e.stroke(),t.droplines.length>1&&n.showDroplineLabels){e.setLineDash([]),e.fillStyle="blue",e.font='10px Roboto, "Roboto Local"',e.textAlign="left";let t=n.viewport.xToScreen(n.dataBounds.minX)+2;for(let n of i)e.fillText(n.name,t,n.screenY-3)}e.restore()}function O(e){return 0!==e&&(.001>Math.abs(e)||Math.abs(e)>=1e6)?o.format(e,"scientific"):c.formatNumber(e)}function E(e,t,n){var r,o;let l=n.screenBounds,a=l.width<i.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||l.height<i.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT?[]:n.names;if(!t||!a||0===a.length)return 0;let u=n.dataBox;e.font=m;let s=null!=(r=n.startLine)?r:0;for(let r of a){let o=t[r];if(null==o)continue;let l=u.y+15*(s+1);if(l>u.maxY)break;e.fillStyle=n.color,e.textAlign="left";let i=`${r}: ${"number"==typeof o?O(o):o}`;e.fillText(i,u.x+5,l),p(n.drawnAt,e,i,u.x+5,l),s++}return s-(null!=(o=n.startLine)?o:0)}function P(e,t,n){var r,o,a;let u=n.screenBounds,s=u.width<i.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||u.height<i.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT?[]:n.statistics;if(!((null==(r=t.showFitLine)||r)&&s&&s.length>0))return 0;let c=n.dataBox,d=n.dataPoints,h=n.fitFunc,g=(0,l.KZ)((0,l.xS)(t,h,d,n.logOptions),n.logOptions),y=v(t,n.seriesIdx,"fitLineColor");e.font=m;let C=null!=(o=n.startLine)?o:0;for(let t of s){let r=(0,f.h5)(g,t),o=(0,f.Wh)(h,t);if(void 0===r||!o)continue;let l=c.y+15*(C+1);if(l>c.maxY)break;e.fillStyle=y,e.textAlign="left";let i=`${o.friendlyName}: ${O(r)}`;e.fillText(i,c.x+5,l),p(n.drawnAt,e,i,c.x+5,l),C++}return C-(null!=(a=n.startLine)?a:0)}function S(e,t){t.showTitle&&(e.font='12px Roboto, "Roboto Local"',e.textAlign="center",e.fillStyle="black",e.fillText(t.title,t.dataBox.midX-5,t.screenBounds.y+15))}function N(e,t){if(t.showAxesLabels){let n=t.screenBounds,r=t.dataBox;if(e.font='11px Roboto, "Roboto Local"',e.textAlign="center",e.fillStyle="black",t.xAxisName&&e.fillText(t.xAxisName,r.midX,n.maxY-i.h.X_AXIS_LABEL_BOTTOM_PX_MARGIN),t.yAxisName){e.save(),e.translate(n.x,n.y),e.rotate(-Math.PI/2);let o=t.showTitle?i.h.AXES_TOP_PX_MARGIN_WITH_TITLE:i.h.AXES_TOP_PX_MARGIN;e.fillText(t.yAxisName,-(r.height/2+o),15),e.restore()}}}},886(e,t,n){"use strict";n.d(t,{aI:()=>d,b6:()=>m,fM:()=>f,rn:()=>c});var r=n(82),o=n(590);function l(e,t){let n=[];for(let r=0;r<e.children.length;r++){let o=e.children[r];o.localName===t&&n.push(o)}return n}function i(e,t){for(let n=0;n<e.children.length;n++)if(e.children[n].localName===t)return e.children[n];return null}function a(e,t){var n,r;let o=i(e,t);return null!=(n=null==o||null==(r=o.textContent)?void 0:r.trim())?n:""}function u(e){let t=l(e,"d"),n=[],r=[];for(let e of t){var o,i;let t=null!=(o=null==(i=e.textContent)?void 0:i.trim())?o:"";""===t?(n.push(null),r.push(!1)):(n.push(parseFloat(t)),r.push("1"===e.getAttribute("Excluded")))}return{values:n,excluded:r}}function s(e){return{title:a(e,"Title"),subcolumns:l(e,"Subcolumn").map(u)}}function c(e){let t="</GraphPadPrismFile>",n=e.indexOf(t);-1!==n&&(e=e.substring(0,n+t.length));let r=new DOMParser().parseFromString(e,"text/xml").documentElement;if("parsererror"===r.nodeName)return[];let o=[];for(let e=0;e<r.children.length;e++){let t=r.children[e];("Table"===t.localName||"HugeTable"===t.localName)&&o.push(function(e){var t,n,r;let o=null!=(t=e.getAttribute("ID"))?t:"",c=null!=(n=e.getAttribute("TableType"))?n:"",f=null!=(r=e.getAttribute("XFormat"))?r:"",d=a(e,"Title"),m="",p=[],h=i(e,"XColumn");if(h){m=a(h,"Title");let e=i(h,"Subcolumn");e&&(p=u(e).values)}return{id:o,title:d,tableType:c,xFormat:f,xTitle:m,xValues:p,yColumns:l(e,"YColumn").map(s)}}(t))}return o}function f(e){if("XY"!==e.tableType||0===e.xValues.length)return null;let t=[];for(let n of e.yColumns){let r=[];for(let t of n.subcolumns)for(let n=0;n<e.xValues.length;n++){let o=e.xValues[n];if(null==o||n>=t.values.length)continue;let l=t.values[n];null!=l&&r.push({x:o,y:l,outlier:t.excluded[n]||!1})}0!==r.length&&t.push({name:n.title,fitFunction:o.G7,showFitLine:!0,showPoints:"points",clickToToggle:!0,droplines:["IC50"],points:r})}return 0===t.length?null:{chartOptions:{logX:!0,xAxisName:e.xTitle||"Concentration",yAxisName:"Response",title:e.title},series:t}}function d(e){let t=e.filter(e=>"XY"===e.tableType),n=[],o=[];for(let e of t){let t=f(e);t&&(n.push(e.title||e.id),o.push(JSON.stringify(t)))}let l=r.DataFrame.create(n.length);l.setTag(r.Tags.Id,crypto.randomUUID()),l.name="PZFX Curves";let i=l.columns.addNewString("Table");for(let e=0;e<n.length;e++)i.set(e,n[e]);let a=l.columns.addNewString("Fitted Curve");a.semType="fit",a.meta.cellRenderer="fit";for(let e=0;e<o.length;e++)a.set(e,o[e]);return l}function m(e){let t=Math.max(...e.yColumns.map(e=>Math.max(...e.subcolumns.map(e=>e.values.length),0)),0),n=r.DataFrame.create(t);for(let t of(n.setTag(r.Tags.Id,crypto.randomUUID()),n.name=e.title||e.id,e.yColumns)){var o,l;if(1===t.subcolumns.length){let e=n.columns.addNewFloat(t.title||"Values"),l=t.subcolumns[0];for(let t=0;t<l.values.length;t++)e.set(t,null!=(o=l.values[t])?o:r.FLOAT_NULL)}else for(let e=0;e<t.subcolumns.length;e++){let o=n.columns.addNewFloat(`${t.title}_${e+1}`),i=t.subcolumns[e];for(let e=0;e<i.values.length;e++)o.set(e,null!=(l=i.values[e])?l:r.FLOAT_NULL)}}return n}},644(e,t,n){"use strict";n.r(t),n.d(t,{dataToCurvesTopMenu:()=>_,previewPzfx:()=>F,convertPzfxToJsonFunc:()=>R,addStatisticsColumn:()=>P,addCurveStatistic:()=>N,curveStatistic:()=>O,_initCurves:()=>T,convertCompactDrToJsonFunc:()=>M,addAggrStatisticsColumn:()=>S,dataToCurves:()=>I,Sync:()=>ea,pzfxFileHandler:()=>X,assayCurveFitDemo:()=>x,curveAggrStatistic:()=>E,curveFitDemo:()=>w,_MultiCurveViewer:()=>b,convertXmlCurveToJsonFunc:()=>L,_package:()=>eo,addAggrCurveStatistic:()=>A,PackageFunctions:()=>eu,_FitChartCellRenderer:()=>C});var r=n(82),o=n(389),l=n(328),i=n(53),a=n(590);let u=rxjs.operators;var s=n(858),c=n(788),f=n(129),d=n(476);function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function p(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function h(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}class g extends r.JsViewer{get trellisProperties(){return["mergeColumnSeries","logX","logY"]}isInTrellis(){let e=this.root,t=0;for(;e&&t<7;){if(e.classList.contains("d4-trellis-plot-cell"))return!0;e=e.parentElement,t++}return!1}static fromChartData(e){let t=new g;return t.data=e,t.render(),t}createGridCell(e){let t=r.GridCell.fromValue(e);return t.cellType=c.h.FIT_CELL_TYPE,t}applyViewerProperties(){(0,i.g2)(a.xs,this,this.data.chartOptions)}mergeViewerChartOptions(){for(let e of a.xs)(["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)&&(["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;if((null==(e=this.curvesColumnNames)?void 0:e.length)===0)return;this.rows.length=0;let o=-1;this.isInTrellis()?this.rows.push(...this.dataFrame.filter.getSelectedIndexes()):(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&&(o=this.rows.length,this.rows.push(...this.dataFrame.selection.clone().and(this.dataFrame.filter).getSelectedIndexes()))),this.data=new a.oH;let l=this.props.get("mergeCellSeries"),u=[];for(let e of(this.fitIdentities=[],this.curvesColumnNames)){let t=[],r=[];for(let n of new Set(this.rows)){let o=this.dataFrame.cell(n,e);if(!o||!o.value)continue;let a=(0,i.h8)(o);if(!a.series||0===a.series.length)continue;let s=a.series.map(e=>p(m({},e),{columnName:o.column.name})),c=this.legendColumnName&&this.dataFrame.col(this.legendColumnName)?this.dataFrame.col(this.legendColumnName):null;if(c)for(let e of s)e.auxLegendName=s.length>1?`${c.get(n)} ${e.name}`:`${c.get(n)}`;let f=a.chartOptions;if(null!=f&&(u[u.length]=f),l){let e=(0,i.wU)(s);(null==f?void 0:f.title)!==void 0&&(null==f?void 0:f.title)!==""&&(e.name=null==f?void 0:f.title),s=[e]}let d=(0,i.U6)(a);r.push(...s.map((e,t)=>`${d} || idx: ${l?"merged":t}`)),t.push(...s)}0!==t.length&&(null==(n=this.data.series)||n.push(...JSON.parse(JSON.stringify(this.mergeColumnSeries?[(0,i.wU)(t)]:t))),this.fitIdentities.push(...this.mergeColumnSeries?[void 0]:r))}for(let e of(this.data.chartOptions=(0,i.LX)(u,this.data.series),this.data.chartOptions.useAuxLegendNames=!0,this.mergeViewerChartOptions(),["title","xAxisName","yAxisName"]))void 0===this[e]&&void 0!==this.data.chartOptions[e]&&(this[e]=this.data.chartOptions[e]);null==(t=this.data.series)||t.forEach((e,t)=>{var n,l,i,a,u;if(e.fitLineColor||e.pointColor||(e.pointColor=r.Color.toHtml(r.Color.getCategoricalColor((null==(a=this.data.series)?void 0:a.length)>20?0:t)),e.fitLineColor=r.Color.toHtml(r.Color.getCategoricalColor((null==(u=this.data.series)?void 0:u.length)>20?0:t))),e.showOutliers=this.showOutliers,e.showCurveConfidenceInterval=!1,e.droplines=[],(null==(n=this.data.series)?void 0:n.length)>20&&(e.showPoints="",e.lineStyle="solid"),(null==(l=this.data.series)?void 0:l.length)>10&&(null==(i=this.data.series)?void 0:i.length)<100&&t>=o){let t=r.Color.fromHtml(e.fitLineColor);e.fitLineColor=`rgba(${r.Color.r(t)}, ${r.Color.g(t)}, ${r.Color.b(t)}, 0.2)`}})}onPropertyChanged(e){var t,n,r,o,l;(null==e?void 0:e.name)==="curvesColumnNames"&&(this.props.set("showColumnLabel",(null==(o=this.curvesColumnNames)?void 0:o.length)>1),this.showColumnLabel=(null==(l=this.curvesColumnNames)?void 0:l.length)>1),["logX","logY","allowXZeroes","mergeCellSeries","showColumnLabel"].includes((null==e?void 0:e.name)==="mergeSeries"?"mergeCellSeries":null!=(t=null==e?void 0:e.name)?t:"")&&(this[(null==e?void 0:e.name)==="mergeSeries"?"mergeCellSeries":null!=(n=null==e?void 0:e.name)?n:""]=this[null!=(r=null==e?void 0:e.name)?r:""]),this.applyViewerProperties(),this.createChartData(),this.render()}onTableAttached(){var e;let t=null==(e=this.tableView)?void 0:e.grid,n=this.dataFrame.columns.bySemType(c.h.FIT_SEM_TYPE);null!==n&&(this.curvesColumnNames=[n.name]),this.subs.push((0,s.merge)(this.dataFrame.onCurrentCellChanged,...t?[t.onCellMouseEnter]:[],this.dataFrame.onSelectionChanged).pipe((0,u.debounce)(e=>(0,s.interval)(50))).subscribe(e=>{this.dataFrame&&(this.createChartData(),this.render())})),this.createChartData(),this.isInTrellis()||this.render()}_showErrorMessage(e){this.root.appendChild(o.divText(e,"d4-viewer-error"))}_removeErrorMessage(){let e=this.root.getElementsByClassName("d4-viewer-error")[0];e&&this.root.removeChild(e)}render(){var e,t,n;let o=this.canvas.getContext("2d");if(o.clearRect(0,0,this.canvas.width,this.canvas.height),this._removeErrorMessage(),(null==(e=this.curvesColumnNames)?void 0:e.length)===0)return void this._showErrorMessage("The MultiCurveViewer viewer requires a minimum of 1 curves column.");if((null==(n=this.data)||null==(t=n.series)?void 0:t.length)===0)return void this._showErrorMessage("No data to show.");let l=new r.Rect(0,0,this.canvas.width,this.canvas.height);new f.l().renderCurves(o,l,this.data,void 0,this.fitIdentities)}constructor(){for(const e of(super(),this.curvesColumnNames=[],this.showSelectedRowsCurves=!0,this.showCurrentRowCurve=!0,this.showMouseOverRowCurve=!0,this.mergeColumnSeries=!1,this.showOutliers=!0,this.rows=[],this.data=new a.oH,this.fitIdentities=[],this.gridCellWidget=r.GridCellWidget.fromGridCell(this.createGridCell("")),this.canvas=this.gridCellWidget.canvas,this.root.append(this.gridCellWidget.canvas),o.tools.handleResize(this.root,(e,t)=>{this.canvas.width=e,this.canvas.height=t,this.render()}),this.canvas.addEventListener("mousemove",e=>{var t,n;(null!=(t=null==(n=this.data.series)?void 0:n.length)?t:0)>0&&!(0,d.Oz)(this.data,new r.Rect(0,0,this.canvas.width,this.canvas.height),e,{x:e.offsetX,y:e.offsetY})&&o.tooltip.hide()}),this.canvas.addEventListener("mouseleave",()=>o.tooltip.hide()),this.curvesColumnNames=this.addProperty("curvesColumnNames",r.TYPE.COLUMN_LIST,[],{semType:c.h.FIT_SEM_TYPE}),this.legendColumnName=this.addProperty("legendColumnName",r.TYPE.STRING,"",{description:"Column to be used for curves names"}),this.showSelectedRowsCurves=this.bool("showSelectedRowsCurves",!0,{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),this.showOutliers=this.bool("showOutliers",!0),a.xs))this.addProperty("mergeSeries"===e.name?"mergeCellSeries":e.name,e.propertyType,e.defaultValue,p(m({},e.options),{showSlider:!1}))}}function v(e,t,n,r,o,l,i){try{var a=e[l](i),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function y(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function i(e){v(l,r,o,i,a,"next",e)}function a(e){v(l,r,o,i,a,"throw",e)}i(void 0)})}}function C(){return new f.l}function b(){return new g}function w(){return y(function*(){yield eu.curveFitDemo()})()}function x(){return y(function*(){yield eu.assayCurveFitDemo()})()}function T(){return y(function*(){yield eu._initCurves()})()}function I(e,t,n,r,o,l,i,a,u,s,c,f,d,m,p,h,g,v,C){return y(function*(){return yield eu.dataToCurves(e,t,n,r,o,l,i,a,u,s,c,f,d,m,p,h,g,v,C)})()}function _(){return y(function*(){return yield eu.dataToCurvesTopMenu()})()}function O(e,t,n,r){return eu.curveStatistic(e,t,n,r)}function E(e,t,n,r){return eu.curveAggrStatistic(e,t,n,r)}function P(e,t,n,r){return eu.addStatisticsColumn(e,t,n,r)}function S(e,t,n,r){return eu.addAggrStatisticsColumn(e,t,n,r)}function N(e,t,n,r){return eu.addCurveStatistic(e,t,n,r)}function A(e,t,n,r){return eu.addAggrCurveStatistic(e,t,n,r)}function L(){return eu.convertXmlCurveToJsonFunc()}function M(){return eu.convertCompactDrToJsonFunc()}function R(){return eu.convertPzfxToJsonFunc()}function F(e){return y(function*(){return yield eu.previewPzfx(e)})()}function X(e){return eu.pzfxFileHandler(e)}g=function(e,t,n,r){var o,l=arguments.length,i=l<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(l<3?o(i):l>3?o(t,n,i):o(t,n))||i);return l>3&&i&&Object.defineProperty(t,n,i),i}([l.decorators.viewer({name:"MultiCurveViewer",description:"A viewer that superimposes multiple in-cell curves on one chart",icon:"icons/multi-curve-viewer.png",trellisable:!0}),h("design:type",Function),h("design:paramtypes",[])],g);var D=n(181),Y=n(434),j=n(301),G=n(190),H=n(287),k=n(305),V=n(124),q=n(869),B=n(991),W=n.n(B);function $(e,t,n,r,o,l,i){try{var a=e[l](i),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function U(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function i(e){$(l,r,o,i,a,"next",e)}function a(e){$(l,r,o,i,a,"throw",e)}i(void 0)})}}let Z="Compound|Assay|Target";function z(e){return e.split("||").filter(e=>""!==e&&"null"!==e&&"undefined"!==e).join(" | ")}function J(e,t,n,r){let o=e.columns.toList().filter(e=>n(e)).sort((e,t)=>e.name.length-t.name.length).find(e=>r.some(t=>e.name.toLowerCase().includes(t)));o&&(t.value=o)}var Q=n(886);function K(e,t,n,r,o,l,i){try{var a=e[l](i),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function ee(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function i(e){K(l,r,o,i,a,"next",e)}function a(e){K(l,r,o,i,a,"throw",e)}i(void 0)})}}function et(e,t,n,r){var o,l=arguments.length,i=l<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(l<3?o(i):l>3?o(t,n,i):o(t,n))||i);return l>3&&i&&Object.defineProperty(t,n,i),i}function en(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function er(e,t){return function(n,r){t(n,r,e)}}let eo=new r.Package,el=".sourceColumn",ei=".statistics";class ea{static runWhenDone(e){return ee(function*(){return ea._currentPromise=ea._currentPromise.then(()=>ee(function*(){try{return yield e()}catch(e){eo.logger.error(e)}})()),ea._currentPromise})()}}ea._currentPromise=Promise.resolve();class eu{static curveFitDemo(){return ee(function*(){yield(0,j.Z1)()})()}static assayCurveFitDemo(){return ee(function*(){yield(0,j.pj)()})()}static _initCurves(){return ee(function*(){r.ObjectHandler.register(new D.e),(0,V.l8)("3dx",G.J),(0,V.l8)("compact-dr",H.G),(0,V.l8)("pzfx",k.R),yield(0,V.p)()})()}static dataToCurves(e,t,n,o,i,u,s,c,f,d,m,p,h,g,v,y,C,b,w){return ee(function*(){var x,T,I,_,O;let E=d&&C&&b&&e.col(C)&&d.col(b)?{wellLevelCol:e.col(C),parentLevelCol:d.col(b)}:void 0,P=(null!=w?w:[]).map(t=>e.col(t)).filter(e=>null!=e);return O={table:d,fitParamColumns:(null!=m?m:[]).map(e=>null==d?void 0:d.col(e)).filter(e=>null!=e),reportedIC50Column:p&&null!=(x=null==d?void 0:d.col(p))?x:void 0,reportedQualifiedIC50Column:h&&null!=(T=null==d?void 0:d.col(h))?T:void 0,experimentIDColumn:g&&null!=(I=null==d?void 0:d.col(g))?I:void 0,qualifierColumn:v&&null!=(_=null==d?void 0:d.col(v))?_:void 0,additionalColumns:(null!=y?y:[]).map(e=>null==d?void 0:d.col(e)).filter(e=>null!=e)},U(function*(){var d,m,p,h,g,v,y,C,b,w,x,T,I,_,S,N,A,L,M;if(!t||!n||!o)throw l.shell.warning("Please fill all required fields"),Error("Please fill all required fields");let R={},F=null==i?void 0:i.categories,X=null==i?void 0:i.getRawData(),D=t.getRawData(),Y=n.getRawData(),j=null==o?void 0:o.categories,G=null==o?void 0:o.getRawData(),H=null==s?void 0:s.categories,k=null==s?void 0:s.getRawData(),V=null==u?void 0:u.categories,q=null==u?void 0:u.getRawData(),B=null==c?void 0:c.categories,W=null==c?void 0:c.getRawData(),$=i?e=>F[X[e]]:()=>"All",U=f?f.getRawData():null,J=f?f.categories:null,Q=f?f.type==r.COLUMN_TYPE.BOOL?e=>!!U[e]:e=>{var t,n,r;return null!=(t=null==(r=J[U[e]])||null==(n=r.toLowerCase())?void 0:n.includes("exclude"))&&t}:e=>!1,K=e=>D[e],ee=e=>Y[e],et=e=>j[G[e]],en=s?e=>H[k[e]]:()=>null,er=u?e=>V[q[e]]:()=>null,eo=c?e=>B[W[e]]:()=>null,el=["circle","triangle bottom","star","cross border","diamond","square","triangle left","triangle right","triangle top","asterisk"],ei=0,ea={},eu=!!((null==E?void 0:E.parentLevelCol)&&(null==E?void 0:E.wellLevelCol)),es=null==O||null==(d=O.table)?void 0:d.col(s.name),ec=null==O||null==(m=O.table)?void 0:m.col(i.name),ef=null==O||null==(p=O.table)?void 0:p.col(c.name),ed=null==O||null==(h=O.table)?void 0:h.col(u.name),em=e=>`${en(e)}||${$(e)}||${eo(e)}`,ep=e=>`${em(e)}||${er(e)}`,eh=eu?e=>`${E.wellLevelCol.get(e)}`:e=>ep(e),eg=eu?e=>`${E.parentLevelCol.get(e)}`:es&&ec&&ef&&ed?e=>{var t,n,r,o;return`${null==(t=O.table)?void 0:t.col(s.name).get(e)}||${null==(n=O.table)?void 0:n.col(i.name).get(e)}||${null==(r=O.table)?void 0:r.col(c.name).get(e)}||${null==(o=O.table)?void 0:o.col(u.name).get(e)}`}:e=>null,ev={};if(O)for(let e=0;e<(null!=(g=null==(v=O.table)?void 0:v.rowCount)?g:0);e++){let t=eg?eg(e):null;t&&!ev[t]&&(ev[t]={fitParams:null!=(y=null==(b=O.fitParamColumns)?void 0:b.map(t=>t.get(e)))?y:[],fitFunction:null!=(C=O.fitFunction)?C:a.Qx,reportedIC50:O.reportedIC50Column?O.reportedIC50Column.get(e):void 0,reportedQualifiedIC50:O.reportedQualifiedIC50Column?O.reportedQualifiedIC50Column.get(e):void 0,experimentID:O.experimentIDColumn?O.experimentIDColumn.get(e):void 0,qualifier:O.qualifierColumn?O.qualifierColumn.get(e):void 0,additionalColumns:O.additionalColumns?Object.fromEntries(O.additionalColumns.map(t=>[t.name,t.get(e)])):void 0})}for(let t=0;t<e.rowCount;t++){let e=$(t),n=et(t),o=K(t),l=ee(t),i=Q(t),a=en(t),u=eo(t),s=null!=(w=er(t))?w:"",c=em(t),f=eh(t),d=ep(t);if(!R[f]){if(R[f]={name:d,x:[],y:[],outliers:[],groupKey:c,runID:s,info:{"Assay Name":e,"Batch ID":n,"Compound ID":a,"Target Entity":u,"Run ID":s,"Max Percent Inhibition":null}},P)for(let e of P){let n=e.name;for(;n in R[f].info;)n=`${n} (1)`;R[f].info[n]=e.get(t)}if(O&&ev[f]){if(R[f].info["Reported IC50"]=ev[f].reportedIC50,R[f].info["Qualified Reported IC50"]=ev[f].reportedQualifiedIC50,R[f].info["Experiment ID"]=ev[f].experimentID,R[f].info.Qualifier=ev[f].qualifier,ev[f].additionalColumns&&Object.assign(R[f].info,ev[f].additionalColumns),ev[f].fitParams&&ev[f].fitParams.length>0)for(let e=0;e<(null!=(T=null==(I=O.fitParamColumns)?void 0:I.length)?T:0);e++){let t=O.fitParamColumns[e].name;R[f].info[t]=ev[f].fitParams[e]}ev[f].groupKey=c}}let m=R[f];m.x.push(o),m.y.push(l),m.outliers.push(i),i||null==l||l==r.FLOAT_NULL||l==r.INT_NULL||(m.info["Max Percent Inhibition"]=Math.max(null!=(x=m.info["Max Percent Inhibition"])?x:-1/0,l))}let ey={},eC=Object.entries(R),eb=[],ew=r.Column.string("Fitted Curve",eC.length);for(let e of(ew.init(e=>{var o,l,i,u,s,c;let[f,d]=eC[e],m=d.x,p=d.y,h=d.outliers,g=d.runID,v=(e=>{if(e in ea)return ea[e];{let t=el[ei];return ea[e]=t,ei=(ei+1)%el.length,t}})(g),y=ev[f]?ev[f].fitParams:void 0,C=(e=>{if(ey[e])return ey[e];let t=r.Color.getCategoricalColor(Object.keys(ey).length);return ey[e]=r.Color.toHtml(t),ey[e]})((null!=(o=d.info["Compound ID"])?o:"")+"||"+(null!=(l=d.info["Assay Name"])?l:"")+"||"+(null!=(i=d.info["Target Entity"])?i:"")),b={fitFunction:(null==ev||null==(c=ev[f])?void 0:c.fitFunction)?ev[f].fitFunction:a.Qx,clickToToggle:!0,droplines:["IC50"],name:`${g}`,points:m.map((e,t)=>({x:e,y:p[t],outlier:h[t],marker:v,size:5})).sort((e,t)=>e.x-t.x),parameters:y,fitLineColor:C,pointColor:r.Color.toHtml(r.Color.gray)};return JSON.stringify({chartOptions:{xAxisName:t.name,yAxisName:n.name,logX:!0,title:z(`${null!=(u=null!=(s=d.name)?s:f)?u:""}`)},series:[b]})}),eb.push(ew),ew.semType="fit",ew.setTag("cell.renderer","fit"),eb.push(r.Column.fromStrings(Z,eC.map(e=>z(e[1].groupKey)))),eC.reduce((e,t)=>(Object.keys(t[1].info).forEach(t=>e.add(t)),e),new Set))){let t=r.Column.fromStrings(e,eC.map(t=>{var n,r,o;return null!=(n=null==(o=t[1].info[e])||null==(r=o.toString)?void 0:r.call(o))?n:""}));eb.push(t)}let ex=e=>void 0==e||isNaN(e)?void 0:"number"==typeof e&&e!=r.FLOAT_NULL&&e!=r.INT_NULL?e:"string"==typeof e?void 0==Number.parseFloat(e)||isNaN(Number.parseFloat(e))?void 0:Number.parseFloat(e):void 0,eT={};for(let[e,t]of eC){let n=t.groupKey;if(n&&(n in eT||(eT[n]={maxYs:[],reportedIC50s:[],qualifiedIC50s:[]}),eT[n].maxYs.push(Math.max(...t.y.filter((e,n)=>!t.outliers[n]))),O&&ev[e]&&null!=(_=ev[e].reportedQualifiedIC50))&&_){eT[n].qualifiedIC50s.push(ev[e].reportedQualifiedIC50);let t=ex(O.reportedQualifiedIC50Column?ev[e].reportedQualifiedIC50:ev[e].reportedIC50);if(void 0==t)try{t=r.Qnum.parse(O.reportedQualifiedIC50Column?ev[e].reportedQualifiedIC50:ev[e].reportedIC50)}catch(e){}void 0!=t&&eT[n].reportedIC50s.push(t)}}let eI={};for(let e in eT){let t=eT[e];eI[e]=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({"Max Percent Inhibition (Compound | Assay | Target)":t.maxYs.length?null==(S=Math.max(...t.maxYs))?void 0:S.toString():null},O&&O.table?{"Number of total results":null==(N=t.qualifiedIC50s.length)?void 0:N.toString(),"Number of reported results":null==(A=t.reportedIC50s.length)?void 0:A.toString(),"Geomean IC50":t.reportedIC50s.length?null==(L=Math.exp(t.reportedIC50s.reduce((e,t)=>e+Math.log(t),0)/t.reportedIC50s.length)||null)?void 0:L.toString():null,"Standard Deviation":t.reportedIC50s.length>1?null==(M=Math.sqrt(t.reportedIC50s.reduce((e,n)=>e+Math.pow(n-t.reportedIC50s.reduce((e,t)=>e+t,0)/t.reportedIC50s.length,2),0)/(t.reportedIC50s.length-1)))?void 0:M.toString():null,"All Results":t.qualifiedIC50s.join(", ")}:{})}for(let e of Object.keys(eI[Object.keys(eI)[0]])){let t=r.Column.fromStrings(e,eC.map(t=>{var n,r;return null!=(n=null==(r=eI[t[1].groupKey])?void 0:r[e])?n:""}));eb.push(t)}let e_=r.DataFrame.fromColumns(eb);if(e_.name="Fitted Curves",e_.setTag(r.Tags.Id,crypto.randomUUID()),!O||!O.table){let e={interceptX:"IC50",top:"Max",bottom:"Min",slope:"Hill",auc:"AUC"};Object.entries(e).forEach(([e,t])=>{let n={table:e_,colName:ew.name,propName:e,seriesNumber:0};r.Func.find({name:"addStatisticsColumn"})[0].prepare(n).callSync({processed:!1}).getOutputParamValue().name=t}),e.interceptX&&e_.col(e.interceptX)&&(e_.col(e.interceptX).meta.format="scientific")}return e_})()})()}static dataToCurvesTopMenu(){return ee(function*(){!function(){let e,t,n,i,a,u,s,c,f,d,m,p,h,g,v,y,C,b,w,x,T,I,_,O,E,P,S=l.shell.tv;if(!S||!S.dataFrame)return l.shell.warning("No open tableview");let N=null,A=null,L=(e=o.divH([],{style:{alignItems:"center"}}),t=null,n=null,i=null,a=null,{form:e,getValues:()=>(null==t?void 0:t.value)&&(null==n?void 0:n.value)?{wellLevelCol:null==t?void 0:t.value,parentLevelCol:null==n?void 0:n.value}:null,getHistory:()=>{var e,r,o,l;return(null==t?void 0:t.value)&&(null==n?void 0:n.value)?{wellLevelCol:null!=(e=null==t||null==(o=t.value)?void 0:o.name)?e:null,parentLevelCol:null!=(r=null==n||null==(l=n.value)?void 0:l.name)?r:null}:null},applyHistory:e=>{e.wellLevelCol&&e.parentLevelCol&&i&&a&&t&&n&&(t.value=i.col(e.wellLevelCol),n.value=a.col(e.parentLevelCol))},onTableChange:(r,l)=>((r,l)=>{if(o.empty(e),!r||!l){t=null,n=null,i=null,a=null;return}i=r,a=l,t=o.input.column("JOIN",{table:r,nullable:!0,tooltipText:"Column to join on from the well level data"}),n=o.input.column("ON",{table:l,nullable:!0,tooltipText:"Column to join on from the parent level data"});let u=W()(l.columns.categorical).map(e=>{let t=e.categories.length;return e.name.toLowerCase().includes("id")&&(t+=10),e.name.toLowerCase().includes("unique")&&(t+=15),{col:e,score:t}}).toArray().sort((e,t)=>t.score-e.score)[0];if((null==u?void 0:u.col)&&u.score>0){n.value=u.col;let e=u.col.name.toLowerCase(),o=W()(r.columns.categorical).filter(t=>t.name.toLowerCase().includes(e)).toArray()[0];o&&(t.value=o)}let s=o.icons.info(()=>{},"Specify the columns that will be used to join the well level data with the parent level data. if not specified, combination of the compound ID, assay name, target entity and run ID will be used for joining.");o.appendAll(e,[s,t.root,n.root])})(r,l)});v=o.input.table("Well Table",{value:l.shell.tv.dataFrame,nullable:!1,tooltipText:"Table with well level data"}),y=o.form([]),(C=()=>{var e,t,n,l,i,a,C,b;let w=v.value;o.empty(y),(()=>{var e,t,n;return L.onTableChange(null!=(e=null==N||null==(n=N.getValues())?void 0:n.table)?e:null,null!=(t=null==A?void 0:A.getTable())?t:null)})(v.value),u=o.input.column("Assay Name",{table:w,nullable:!0,filter:e=>e.isCategorical,tooltipText:"Column with assay names"}),s=o.input.column("Concentration",{table:w,nullable:!1,filter:e=>e.isNumerical,tooltipText:"Column with concentration values"}),c=o.input.column("Readout",{table:w,nullable:!1,filter:e=>e.isNumerical,tooltipText:"Column with readout values"}),f=o.input.column("Outliers",{table:w,nullable:!0,filter:e=>(e.isCategorical||e.type===r.TYPE.BOOL)&&2===e.categories.length,tooltipText:"Column with outliers to exclude from the analysis"}),d=o.input.column("Compound ID",{table:w,nullable:!0,tooltipText:"Column with compound IDs"}),m=o.input.column("Batch ID",{table:w,nullable:!1,tooltipText:"Column with batch IDs. this column along with the Assay column will be used to group the data into curves"}),p=o.input.column("Run ID",{table:w,nullable:!0,tooltipText:"Column with run IDs. this column along with the Assay column will be used to group the data into curves"}),h=o.input.column("Target Entity",{table:w,nullable:!1,filter:e=>e.isCategorical,tooltipText:"Column with target entity names. This column will be used to group the data into curves"}),g=o.input.columns("Additional Columns",{table:w,nullable:!0,tooltipText:"Additional columns to include in the curves data"}),u.value=null!=(e=W()(w.columns.categorical).find(e=>e.name.toLowerCase().includes("assay")&&e.name.toLowerCase().includes("name")))?e:null,s.value=null!=(t=w.columns.firstWhere(e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME&&e.name.toLowerCase().includes("concentration")))?t:null,c.value=null!=(n=w.columns.firstWhere(e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME&&e.name.toLowerCase().includes("inhibition")))?n:null,f.value=null!=(l=w.columns.firstWhere(e=>(e.isCategorical||e.type===r.TYPE.BOOL)&&2===e.categories.length&&(e.name.toLowerCase().includes("outlier")||e.name.toLowerCase().includes("include")&&e.name.toLowerCase().includes("exclude"))))?l:null,d.value=null!=(i=w.columns.firstWhere(e=>e.isCategorical&&e.name.toLowerCase().includes("compound_id")||e.name.toLowerCase().includes("compoundid")||e.name.toLowerCase().includes("compound id")))?i:null,m.value=null!=(a=w.columns.firstWhere(e=>e.name.toLowerCase().includes("batch")&&e.name.toLowerCase().includes("id")))?a:null,p.value=null!=(C=w.columns.firstWhere(e=>(e.name.toLowerCase().includes("run")||e.name.toLowerCase().includes("set"))&&e.name.toLowerCase().includes("id")))?C:null,h.value=null!=(b=w.columns.firstWhere(e=>e.isCategorical&&e.name.toLowerCase().includes("target")&&e.name.toLowerCase().includes("entity")))?b:null,g.value=[],o.appendAll(y,[v.root,u.root,m.root,p.root,s.root,c.root,d.root,h.root,f.root,g.root])})(),v.onChanged.subscribe(()=>C()),N={form:y,getValues:()=>{var e;return{table:v.value,assayCol:u.value,batchIDCol:m.value,concentrationCol:s.value,readoutCol:c.value,compoundIDCol:d.value,excludeOutliersCol:f.value,targetEntityCol:h.value,runIDCol:p.value,additionalColumns:null!=(e=g.value)?e:[]}},applyHistory:e=>{var t;let n=v.value;u.value=e.assayCol?n.col(e.assayCol):null,m.value=e.batchIDCol?n.col(e.batchIDCol):null,s.value=e.concentrationCol?n.col(e.concentrationCol):null,c.value=e.readoutCol?n.col(e.readoutCol):null,d.value=e.compoundIDCol?n.col(e.compoundIDCol):null,f.value=e.excludeOutliersCol?n.col(e.excludeOutliersCol):null,p.value=e.runIDCol?n.col(e.runIDCol):null,h.value=e.targetEntityCol?n.col(e.targetEntityCol):null,g.value=null==(t=e.additionalColumns)?void 0:t.map(e=>n.col(e)).filter(e=>null!=e)}},_=o.input.table("Parent Table",{value:void 0,nullable:!0,tooltipText:"Table with parent data"}),O=o.form([]),E=null,(P=()=>{var e;let t,n,l,i,a,u;if(o.empty(O),O.appendChild(_.root),(()=>{var e,t,n;return L.onTableChange(null!=(e=null==N||null==(n=N.getValues())?void 0:n.table)?e:null,null!=(t=null==A?void 0:A.getTable())?t:null)})(_.value),!_.value){E=null;return}b=o.input.column("Reported IC50",{table:_.value,nullable:!0,tooltipText:"Column with reported IC50 values"}),w=o.input.column("Reported Qualified IC50",{table:_.value,nullable:!0,tooltipText:"Column with reported qualified IC50 values"}),x=o.input.column("Experiment ID",{table:_.value,nullable:!0,tooltipText:"Column with experiment IDs"}),T=o.input.column("Qualifier",{table:_.value,nullable:!0,tooltipText:"Column with qualifier values"}),I=o.input.columns("Additional Columns",{table:_.value,nullable:!0,tooltipText:"Additional columns to include in the curves data"}),J(_.value,b,e=>e.type!==r.COLUMN_TYPE.DATE_TIME,["reported ic50","reported_ic50","reported-ic50"]),J(_.value,w,e=>e.type!==r.COLUMN_TYPE.DATE_TIME,["qualified_reported_ic50","qualified reported ic50","qualified-reported-ic50"]),J(_.value,x,e=>e.isCategorical,["experiment id","experiment_id","experiment-id"]),J(_.value,T,e=>e.isCategorical,["qualifier"]);let s=o.form([b,w,x,T,I]);e=_.value,t=[q.Z2.FOUR_PL_DOSE_RESPONSE,q.Z2.FOUR_PL_REGRESSION],n=o.input.choice("Fit Function",{value:q.Z2.FOUR_PL_DOSE_RESPONSE,items:t,nullable:!1,tooltipText:"Select the fit function to use for the curve fitting"}),l=o.form([]),i=[],(a=o.input.bool("Use Prefit Parameters",{value:!0,tooltipText:"Use selected fit curve parameters instead of fitting the curve from scratch"})).onChanged.subscribe(()=>{i.forEach(e=>e.enabled=a.value)}),n.addOptions(a.captionLabel),n.addOptions(a.input),a.captionLabel.style.color="var(--grey-6)",(u=()=>{o.empty(l);let t=function(e,t){let n=[];switch(t){case q.Z2.FOUR_PL_REGRESSION:case q.Z2.FOUR_PL_DOSE_RESPONSE:default:n.push(o.input.column("Max",{table:e,nullable:!1,tooltipText:"Maximum value for the curve"})),n.push(o.input.column("Hill",{table:e,nullable:!1,tooltipText:"Hill coefficient for the curve"})),n.push(o.input.column("Inflection",{table:e,nullable:!1,tooltipText:"Inflection value for the curve"})),n.push(o.input.column("Min",{table:e,nullable:!1,tooltipText:"Minimum value for the curve"})),J(e,n[0],e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME,["max"]),J(e,n[1],e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME,["hill"]),J(e,n[2],e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME,["inflection"]),J(e,n[3],e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME,["min"])}return n}(e,n.value);i=t,o.appendAll(l,[n.root,...t.map(e=>e.root)]),a.fireChanged()})(),n.onChanged.subscribe(()=>u()),E={form:l,getValues:()=>a.value?i.map(e=>e.value):[],getFitFunction:()=>n.value,getHystory:()=>({fitParamCols:i.map(e=>{var t,n;return null!=(t=null==(n=e.value)?void 0:n.name)?t:""}),fitFunction:n.value,useFitParamCols:a.value}),applyHistory:t=>{var r;if(n.value=t.fitFunction,a.value=t.useFitParamCols,(null==(r=t.fitParamCols)?void 0:r.length)===(null==i?void 0:i.length))for(let n=0;n<i.length;n++){let r=e.col(t.fitParamCols[n]);r&&(i[n].value=r)}}},o.appendAll(O,[s,E.form])})(),_.onChanged.subscribe(()=>P()),A={getValue:()=>({fitParamCols:(null==E?void 0:E.getValues)?E.getValues():null,reportedIC50Col:null==b?void 0:b.value,reportedQualifiedIC50Col:null==w?void 0:w.value,experimentIDCol:null==x?void 0:x.value,qualifierCol:null==T?void 0:T.value,additionalColumns:null==I?void 0:I.value,fitFunction:(null==E?void 0:E.getFitFunction)?E.getFitFunction():null}),form:O,getTable:()=>_.value,getHistory:()=>{var e,t,n,r,o,l,i,a,u,s,c,f;return{tableName:null!=(e=null==(i=_.value)?void 0:i.name)?e:null,reportedIC50Col:null!=(t=null==b||null==(a=b.value)?void 0:a.name)?t:null,reportedQualifiedIC50Col:null!=(n=null==w||null==(u=w.value)?void 0:u.name)?n:null,experimentIDCol:null!=(r=null==x||null==(s=x.value)?void 0:s.name)?r:null,qualifierCol:null!=(o=null==T||null==(c=T.value)?void 0:c.name)?o:null,additionalColumns:null!=(l=null==I||null==(f=I.value)?void 0:f.map(e=>e.name))?l:[],fitParams:(null==E?void 0:E.getHystory)?E.getHystory():null}},applyHistory:e=>{if(e.tableName){let t=l.shell.table(e.tableName);t&&(_.value=t)}_.value&&(e.reportedIC50Col&&_.value.col(e.reportedIC50Col)&&(b.value=_.value.col(e.reportedIC50Col)),e.reportedQualifiedIC50Col&&_.value.col(e.reportedQualifiedIC50Col)&&(w.value=_.value.col(e.reportedQualifiedIC50Col)),e.additionalColumns&&(I.value=e.additionalColumns.map(e=>_.value.col(e)).filter(e=>null!=e)),e.experimentIDCol&&_.value.col(e.experimentIDCol)&&(x.value=_.value.col(e.experimentIDCol)),e.qualifierCol&&_.value.col(e.qualifierCol)&&(T.value=_.value.col(e.qualifierCol)),E&&e.fitParams&&E.applyHistory(e.fitParams))}};let M=o.divH([N.form,A.form],{style:{minWidth:"400px",gap:"20px"}});o.dialog("Data to Curves").add(M).add(L.form).onOK(()=>U(function*(){var e,t,n,o,i,a,u,s,c,f,d;let m,p=N.getValues(),h=A.getTable(),g=A.getValue(),v=g.fitParamCols;h&&v&&v.length>0&&(m={table:h,fitParamColumns:v,fitFunction:g.fitFunction,reportedIC50Column:g.reportedIC50Col,reportedQualifiedIC50Column:g.reportedQualifiedIC50Col,experimentIDColumn:g.experimentIDCol,qualifierColumn:g.qualifierCol,additionalColumns:null!=(d=g.additionalColumns)?d:[]});let y=L.getValues(),{table:C,assayCol:b,batchIDCol:w,concentrationCol:x,readoutCol:T,compoundIDCol:I,excludeOutliersCol:_,runIDCol:O,targetEntityCol:E,additionalColumns:P}=p,S=r.Func.find({name:"dataToCurves"})[0];if(!S)return void l.shell.error("Function dataToCurves not found");let M=S.prepare({df:C,concentrationCol:x,readoutCol:T,batchIDCol:w,assayCol:b,runIDCol:O,compoundIDCol:I,targetEntityCol:E,excludeOutliersCol:_,wellLevelAdditionalColumns:(null!=P?P:[]).map(e=>null==e?void 0:e.name).filter(e=>!!e),parentTable:null==m?void 0:m.table,fitParamColumns:null!=(e=null==m||null==(n=m.fitParamColumns)?void 0:n.map(e=>e.name))?e:[],reportedIC50Column:null==m||null==(o=m.reportedIC50Column)?void 0:o.name,reportedQualifiedIC50Column:null==m||null==(i=m.reportedQualifiedIC50Column)?void 0:i.name,experimentIDColumn:null==m||null==(a=m.experimentIDColumn)?void 0:a.name,qualifierColumn:null==m||null==(u=m.qualifierColumn)?void 0:u.name,additionalColumns:null!=(t=null==m||null==(s=m.additionalColumns)?void 0:s.map(e=>e.name))?t:[],wellLevelJoinCol:null==y||null==(c=y.wellLevelCol)?void 0:c.name,parentLevelJoinCol:null==y||null==(f=y.parentLevelCol)?void 0:f.name}),R=C.tags[r.Tags.CreationScript]&&(!(null==m?void 0:m.table)||m.table.tags[r.Tags.CreationScript]);yield M.call(void 0,void 0,{processed:!R});let F=M.getResultViews()[0];if(F&&F instanceof r.TableView&&F.dataFrame){R||l.shell.addView(F),F.filters();let e=F.trellisPlot({yColumnNames:[Z],xColumnNames:[],viewerType:"MultiCurveViewer",showControlPanel:!1,showXLabels:!1,showYLabels:!1,showXSelectors:!1,showYSelectors:!0,packCategories:!0,onClick:"Select"});F.dockManager.dock(e,r.DOCK_TYPE.TOP,F.dockManager.findNode(F.grid.root),"Fitted Curves",.5);let t=F.addViewer(r.VIEWER.GRID,{rowSource:r.RowSet.FilteredSelected,selectedRowsColor:r.Color.white});F.dockManager.dock(t,r.DOCK_TYPE.FILL,F.dockManager.findNode(F.grid.root),"Selected Curves"),t.props.title="Selected Curves";let n=F.addViewer("MultiCurveViewer",{showCurrentRowCurve:!1,showMouseOverRowCurve:!1,showSelectedRowsCurves:!0}),o=F.dockManager.dock(n,r.DOCK_TYPE.FILL,F.dockManager.findNode(t.root));F.dockManager.dock(F.grid,r.DOCK_TYPE.FILL,o),F.grid.props.title="Fitted Curves"}})()).show().history(()=>{var e,t,n,r;let{assayCol:o,batchIDCol:l,concentrationCol:i,readoutCol:a,compoundIDCol:u,excludeOutliersCol:s,runIDCol:c,targetEntityCol:f,additionalColumns:d}=N.getValues();return{wells:JSON.stringify(null!=(t=Object.fromEntries(Object.entries({assayCol:null==o?void 0:o.name,batchIDCol:null==l?void 0:l.name,concentrationCol:null==i?void 0:i.name,readoutCol:null==a?void 0:a.name,compoundIDCol:null==u?void 0:u.name,excludeOutliersCol:null==s?void 0:s.name,runIDCol:null==c?void 0:c.name,targetEntityCol:null==f?void 0:f.name,additionalColumns:null!=(e=null==d?void 0:d.map(e=>e.name))?e:[]}).filter(([e,t])=>!!t)))?t:{}),parent:JSON.stringify(null!=(n=A.getHistory())?n:{}),join:JSON.stringify(null!=(r=L.getHistory())?r:{})}},e=>{var t,n,r;let o=JSON.parse(null!=(t=null==e?void 0:e.wells)?t:"{}"),l=JSON.parse(null!=(n=null==e?void 0:e.parent)?n:"{}");N.applyHistory(o),A.applyHistory(l);let i=JSON.parse(null!=(r=null==e?void 0:e.join)?r:"{}");L.applyHistory(i)})}()})()}static curveStatistic(e,t,n,o){let l=r.Column.float(`${t.name} ${o+1} ${n}`,t.length);return l.init(r=>(0,Y.bW)(t,r,n,o,e)),l}static curveAggrStatistic(e,t,n,o){let l=r.Column.float(`${t.name} ${o} ${n}`,t.length);return l.init(r=>(0,Y.i4)(t,r,n,o,e)),l}static addStatisticsColumn(e,t,n,o){let l=e.col(t),a=l.name,u=e.columns.getUnusedName(`${t} ${o+1} ${n}`),s=r.Column.float(u,l.length);return s.tags[el]=l.name,s.tags[".seriesNumber"]=null==o?void 0:o.toString(),s.tags[ei]=n,s.init(t=>{var r,l,u,s,c,f;let d=e.cell(t,a);if(!d||!d.value)return null;let m=(0,i.h8)(d,!0);if(void 0===m.series[o]||m.series[o].points.every(e=>e.outlier))return null;(null==(l=m.chartOptions)?void 0:l.allowXZeroes)&&(null==(u=m.chartOptions)?void 0:u.logX)&&(null==(s=m.series)?void 0:s.some(e=>e.points.some(e=>0===e.x)))&&(0,i.B3)(m);let p={logX:null==(c=m.chartOptions)?void 0:c.logX,logY:null==(f=m.chartOptions)?void 0:f.logY},h=(0,Y.TV)(m.series[o],o,p,d,!0);return null!=(r=(0,q.h5)(h,n))?r:null}),e.columns.insert(s,e.columns.names().indexOf(t)+1),s}static addAggrStatisticsColumn(e,t,n,o){let l=e.col(t),a=`${t} ${o} ${n}`,u=r.Column.float(e.columns.getUnusedName(a),null==l?void 0:l.length);return u.tags[el]=t,u.tags[".seriesAggregation"]=o,u.tags[ei]=n,u.init(r=>{var l,a,u,s;let c=e.cell(r,t);if(!c||!c.value)return null;let f=(0,i.h8)(c);return(null==(l=f.series)?void 0:l.every(e=>e.points.every(e=>e.outlier)))?null:((null==(a=f.chartOptions)?void 0:a.allowXZeroes)&&(null==(u=f.chartOptions)?void 0:u.logX)&&(null==(s=f.series)?void 0:s.some(e=>e.points.some(e=>0===e.x)))&&(0,i.B3)(f),(0,Y.JR)(f,o,c)[n])}),e.columns.insert(u,e.columns.names().indexOf(t)+1),u}static addCurveStatistic(e,t,n="interceptX",r=0){return eu.addStatisticsColumn(e,t.name,n,r)}static addAggrCurveStatistic(e,t,n="interceptX",r="med"){return eu.addAggrStatisticsColumn(e,t.name,n,r)}static convertXmlCurveToJsonFunc(){return G.J}static convertCompactDrToJsonFunc(){return H.G}static convertPzfxToJsonFunc(){return k.R}static previewPzfx(e){return ee(function*(){let t=r.View.create();t.name=e.name;let n=yield e.readAsString(),o=(0,Q.rn)(n),l=o.filter(e=>"XY"===e.tableType);if(0===l.length){for(let e of o.map(Q.b6))t.append(r.Viewer.grid(e).root);return t}let i=(0,Q.aI)(l),a=r.Viewer.grid(i);return a.root.style.width="100%",a.root.style.height="100%",t.append(a.root),t})()}static pzfxFileHandler(e){let t=new TextDecoder().decode(new Uint8Array(e)),n=(0,Q.rn)(t),r=[],o=n.filter(e=>"XY"===e.tableType);for(let e of(o.length>0&&r.push((0,Q.aI)(o)),n.filter(e=>"XY"!==e.tableType)))r.push((0,Q.b6)(e));return r}}et([l.decorators.demo({name:"Curve fitting",description:"Curve fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points",meta:{demoPath:"Curves | Curve Fitting"},test:{test:"curveFitDemo()",wait:"2000"}}),en("design:type",Function),en("design:paramtypes",[]),en("design:returntype",Promise)],eu,"curveFitDemo",null),et([l.decorators.demo({name:"Assay Curves",description:"Dashboard with curves for multiple compounds, assays and targets",meta:{demoPath:"Curves | Assay Curves"}}),en("design:type",Function),en("design:paramtypes",[]),en("design:returntype",Promise)],eu,"assayCurveFitDemo",null),et([l.decorators.init(),en("design:type",Function),en("design:paramtypes",[]),en("design:returntype",Promise)],eu,"_initCurves",null),et([l.decorators.func({name:"Fit Dose-Response Curves",description:"Group well-level assay data by compound, assay, target, and run, then fit a dose-response curve per group."}),er(1,l.decorators.param({type:"column",options:{type:"numerical",nullable:!1,description:"Concentration (dose) column"}})),er(2,l.decorators.param({type:"column",options:{type:"numerical",nullable:!1,description:"Readout (response) column"}})),er(3,l.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Batch identifier column"}})),er(4,l.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Assay name column"}})),er(5,l.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Run identifier column"}})),er(6,l.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Compound identifier column"}})),er(7,l.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Target entity column"}})),er(8,l.decorators.param({type:"column",options:{nullable:!0,description:"Boolean column marking points to exclude as outliers"}})),er(9,l.decorators.param({options:{nullable:!0}})),er(10,l.decorators.param({options:{nullable:!0}})),er(11,l.decorators.param({options:{nullable:!0}})),er(12,l.decorators.param({options:{nullable:!0}})),er(13,l.decorators.param({options:{nullable:!0}})),er(14,l.decorators.param({options:{nullable:!0}})),er(15,l.decorators.param({options:{nullable:!0}})),er(16,l.decorators.param({options:{nullable:!0}})),er(17,l.decorators.param({options:{nullable:!0}})),er(18,l.decorators.param({options:{nullable:!0,optional:!0}})),en("design:type",Function),en("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.DataFrame?Object:r.DataFrame,Array,String,String,String,String,Array,String,String,Array]),en("design:returntype",Promise)],eu,"dataToCurves",null),et([l.decorators.func({"top-menu":"Data | Curves | Data to Curves",outputs:[{name:"result",type:"dynamic"}]}),en("design:type",Function),en("design:paramtypes",[]),en("design:returntype",Promise)],eu,"dataToCurvesTopMenu",null),et([l.decorators.func({name:"curveStatistic",description:"Extract a fit statistic (e.g. IC50, AUC, R\xb2) from a curve series into a calculated column.",meta:{vectorFunc:"true"},outputs:[{name:"result",type:"column",options:{action:"join(table)"}}]}),er(1,l.decorators.param({type:"column",options:{semType:"fit",nullable:!1,description:"Curve column to read"}})),er(2,l.decorators.param({options:{nullable:!1,description:"Fit statistic to extract (e.g. ic50, auc, rSquared)"}})),er(3,l.decorators.param({type:"int",options:{nullable:!1,description:"Zero-based index of the curve series"}})),en("design:type",Function),en("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,Number]),en("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],eu,"curveStatistic",null),et([l.decorators.func({name:"curveAggrStatistic",description:"Aggregate a fit statistic across all series of a curve into a calculated column.",meta:{vectorFunc:"true"},outputs:[{name:"result",type:"column",options:{action:"join(table)"}}]}),er(1,l.decorators.param({type:"column",options:{semType:"fit",nullable:!1,description:"Curve column to read"}})),er(2,l.decorators.param({options:{nullable:!1,description:"Fit statistic to aggregate"}})),er(3,l.decorators.param({options:{choices:["avg","med","min","max","q1","q2","q3"],initialValue:"med",nullable:!1,description:"Aggregation applied across the series of each curve"}})),en("design:type",Function),en("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,String]),en("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],eu,"curveAggrStatistic",null),et([l.decorators.func({name:"Add Curve Statistic Column",description:"Extract a fit statistic (e.g. IC50, AUC, R\xb2) from a specific curve series into a new column.",meta:{vectorFunc:"true",role:"transform"}}),er(1,l.decorators.param({options:{description:"Name of the curve column to read"}})),er(2,l.decorators.param({options:{choices:["rSquared","auc","interceptX","interceptY","slope","top","bottom"],initialValue:"interceptX",description:"Fit statistic to extract. interceptX is IC50, top and bottom are max/min Y"}})),er(3,l.decorators.param({type:"int",options:{initialValue:"0",description:"Zero-based index of the curve series"}})),en("design:type",Function),en("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,String,String,Number]),en("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],eu,"addStatisticsColumn",null),et([l.decorators.func({name:"Add Aggregated Curve Statistic Column",description:"Aggregate a fit statistic across all series of a curve into a new column.",meta:{vectorFunc:"true",role:"transform"}}),er(1,l.decorators.param({options:{description:"Name of the curve column to read"}})),er(2,l.decorators.param({options:{choices:["rSquared","auc","interceptX","interceptY","slope","top","bottom"],initialValue:"interceptX",description:"Fit statistic to aggregate. interceptX is IC50, top and bottom are max/min Y"}})),er(3,l.decorators.param({options:{choices:["min","max","avg","med","q1","q2","q3"],initialValue:"med",description:"Aggregation applied across the series of each curve"}})),en("design:type",Function),en("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,String,String,String]),en("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],eu,"addAggrStatisticsColumn",null),et([l.decorators.func({name:"Add Curve Statistic",description:"Extracts a fit statistic from one series of a curve column into a new column.",outputs:[{name:"result",type:"column"}],meta:{vectorFunc:"true",role:"transform"}}),er(0,l.decorators.param({options:{caption:"Table",nullable:!1}})),er(1,l.decorators.param({type:"column",options:{semType:"fit",caption:"Curves",nullable:!1,description:"Column of fitted curves"}})),er(2,l.decorators.param({type:"string",options:{caption:"Statistic",nullable:!1,choices:["rSquared","auc","interceptX","interceptY","slope","top","bottom"],initialValue:"interceptX",description:"interceptX is IC50, top and bottom are max/min Y"}})),er(3,l.decorators.param({type:"int",options:{caption:"Series",nullable:!1,initialValue:"0",description:"Zero-based index of the curve series"}})),en("design:type",Function),en("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,Number]),en("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],eu,"addCurveStatistic",null),et([l.decorators.func({name:"Add Aggregated Curve Statistic",description:"Aggregates a fit statistic across all series of a curve column into a new column.",outputs:[{name:"result",type:"column"}],meta:{vectorFunc:"true",role:"transform"}}),er(0,l.decorators.param({options:{caption:"Table",nullable:!1}})),er(1,l.decorators.param({type:"column",options:{semType:"fit",caption:"Curves",nullable:!1,description:"Column of fitted curves"}})),er(2,l.decorators.param({type:"string",options:{caption:"Statistic",nullable:!1,choices:["rSquared","auc","interceptX","interceptY","slope","top","bottom"],initialValue:"interceptX",description:"interceptX is IC50, top and bottom are max/min Y"}})),er(3,l.decorators.param({type:"string",options:{caption:"Aggregation",nullable:!1,choices:["med","avg","min","max","q1","q2","q3"],initialValue:"med",description:"Applied across the series of each curve"}})),en("design:type",Function),en("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,String]),en("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],eu,"addAggrCurveStatistic",null),et([l.decorators.func({description:"Returns XML 3DX curve converter function",meta:{role:"curveConverter",curveFormat:"3dx"}}),en("design:type",Function),en("design:paramtypes",[]),en("design:returntype",Function)],eu,"convertXmlCurveToJsonFunc",null),et([l.decorators.func({description:"Returns compact dose-response JSON converter function",meta:{role:"curveConverter",curveFormat:"compact-dr"}}),en("design:type",Function),en("design:paramtypes",[]),en("design:returntype",Function)],eu,"convertCompactDrToJsonFunc",null),et([l.decorators.func({description:"Returns PZFX curve converter function",meta:{role:"curveConverter",curveFormat:"pzfx"}}),en("design:type",Function),en("design:paramtypes",[]),en("design:returntype",Function)],eu,"convertPzfxToJsonFunc",null),et([l.decorators.fileViewer({fileViewer:"pzfx"}),en("design:type",Function),en("design:paramtypes",[void 0===r||void 0===r.FileInfo?Object:r.FileInfo]),en("design:returntype",Promise)],eu,"previewPzfx",null),et([l.decorators.fileHandler({ext:"pzfx",description:"Open a GraphPad Prism (.pzfx) file as data tables, fitting XY curve tables."}),er(0,l.decorators.param({type:"list",options:{description:"Raw bytes of the .pzfx file"}})),en("design:type",Function),en("design:paramtypes",["u"<typeof Uint8Array?Object:Uint8Array]),en("design:returntype",Array)],eu,"pzfxFileHandler",null)},18(e,t,n){"use strict";function r(e){let t=e.slice().sort((e,t)=>e-t),n=t[Math.trunc(t.length/4)],r=t.length%2==0?(t[Math.trunc(t.length/2)]+t[Math.trunc(t.length/2)-1])/2:t[Math.trunc(t.length/2)],l=t[Math.trunc(3*t.length/4)],i=1.5*(l-n),a=o(t,l+i);a<0&&(a=~a);let u=t[Math.max(0,a-1)];u<l&&(u=l);let s=o(t,n-i);s<0&&(s=~s);let c=t[s];return c>n&&(c=n),{q1:n,q2:r,q3:l,lowerAdjacentValue:c,upperAdjacentValue:u}}function o(e,t,n,r){let o=void 0===n?0:n;if(0===e.length||(void 0===r&&(r=e.length-1),t<e[o]))return -1;if(t>e[r])return-(r+2);for(;r-o>1;){let n=Math.trunc((r+o)/2);if(t===e[n])return n;t<e[n]?r=n:o=n}return e[o]===t?o:e[r]===t?r:t<e[o]?-(o+1):-(r+1)}n.d(t,{k:()=>r})},788(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.TAG_CURVE_FORMAT=".%curve-format",r.FIT_SEM_TYPE="fit",r.FIT_CELL_TYPE="fit",r.TAG_FIT=".%fit",r.TAG_FIT_LEGACY=".fit",r.PLOT_LABEL_COLOR="#4A4A4A",r.CELL_DEFAULT_WIDTH=230,r.CELL_DEFAULT_HEIGHT=160,r.MIN_CELL_RENDERER_PX_WIDTH=10,r.MIN_CELL_RENDERER_PX_HEIGHT=5,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_DROPLINE_LABELS_PX_WIDTH=250,r.MIN_DROPLINE_LABELS_PX_HEIGHT=200,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.MIN_INFLATE_SIZE=-2,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||(null==e?void 0:e.length)===0,"There were series with no points":e=>e.some(e=>{var t;return(null==(t=e.points)?void 0:t.length)===0}),"There were series with all x zeroes":e=>e.some(e=>{var t;return null==(t=e.points)?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.every(e=>0===e.y)})}},590(e,t,n){"use strict";n.d(t,{AJ:()=>w,Al:()=>i,EV:()=>x,Ff:()=>d,G7:()=>f,Hr:()=>O,Mi:()=>_,Pf:()=>p,Qx:()=>g,Sm:()=>T,Vd:()=>I,Z5:()=>v,ah:()=>y,dZ:()=>l,h1:()=>a,kC:()=>h,kx:()=>m,nK:()=>s,oH:()=>u,ry:()=>C,sn:()=>b,xs:()=>c});var r=n(82),o=n(353);let l={CONSTANT:"constant",PROPORTIONAL:"proportional",COMBINED:"combined"},i=["rSquared","auc","interceptX","interceptY","slope","top","bottom"],a=["IC10","IC20","IC50","IC80","IC90"];class u{constructor(){this.chartOptions={},this.seriesOptions={},this.series=[]}}let s=[r.Property.js("rSquared",r.TYPE.FLOAT,{userEditable:!1}),r.Property.js("auc",r.TYPE.FLOAT,{userEditable:!1,friendlyName:"AUC"}),r.Property.js("interceptY",r.TYPE.FLOAT,{userEditable:!1}),r.Property.js("interceptX",r.TYPE.FLOAT,{userEditable:!1}),r.Property.js("slope",r.TYPE.FLOAT,{userEditable:!1}),r.Property.js("top",r.TYPE.FLOAT,{userEditable:!1}),r.Property.js("bottom",r.TYPE.FLOAT,{userEditable:!1})],c=[r.Property.js("minX",r.TYPE.FLOAT,{nullable:!0}),r.Property.js("minY",r.TYPE.FLOAT,{nullable:!0}),r.Property.js("maxX",r.TYPE.FLOAT,{nullable:!0}),r.Property.js("maxY",r.TYPE.FLOAT,{nullable:!0}),r.Property.js("title",r.TYPE.STRING,{nullable:!0}),r.Property.js("xAxisName",r.TYPE.STRING,{description:"Label to show on the X axis. If not specified, corresponding data column name is used",nullable:!0}),r.Property.js("yAxisName",r.TYPE.STRING,{description:"Label to show on the Y axis. If not specified, corresponding data column name is used",nullable:!0}),r.Property.js("logX",r.TYPE.BOOL,{description:"Whether the X axis should be logarithmic",defaultValue:!1}),r.Property.js("logY",r.TYPE.BOOL,{description:"Whether the Y axis should be logarithmic",defaultValue:!1}),r.Property.js("allowXZeroes",r.TYPE.BOOL,{description:"Whether x zeroes allowed for logarithmic data or not",defaultValue:!0}),r.Property.js("mergeSeries",r.TYPE.BOOL,{description:"Merges all series within one cell into one series",defaultValue:!1}),r.Property.js("showLegend",r.TYPE.BOOL,{description:"Whether to name the curves on the plot",defaultValue:!0}),r.Property.js("showColumnLabel",r.TYPE.BOOL,{description:"Whether to show the column label in the legend or not",defaultValue:!1}),r.Property.js("showStatistics",r.TYPE.STRING_LIST,{description:"Whether specific statistics should be rendered",choices:s.map(e=>e.name),inputType:"MultiChoice",friendlyName:"Statistics"}),r.Property.js("showLabels",r.TYPE.STRING_LIST,{description:"Whether specific labels should be rendered",choices:[],inputType:"MultiChoice",friendlyName:"Labels"}),r.Property.js("statisticsMode",r.TYPE.STRING,{description:"Whether the statistics are drawn for each series, summarised across them, or both",defaultValue:"series",choices:["series","aggregated","both"],nullable:!1,friendlyName:"Statistics mode"}),r.Property.js("aggrType",r.TYPE.STRING,{description:"The aggregation used when summarising the statistics",defaultValue:"med",choices:Object.values(r.STATS),nullable:!1,friendlyName:"Aggregation"})],f="sigmoid",d="linear",m="log-linear",p="exponential",h="4pl-regression",g="4pl-dose-response",v="js-function";function y(e,t){return n=>e(t,n)}function C(e,t){let n=e[0],r=e[1],o=e[2],l=e[3];return l+(n-l)/(1+Math.pow(10,(t-o)*r))}function b(e,t){return e[0]*t+e[1]}function w(e,t){return e[0]*Math.log(t+1)+e[1]}function x(e,t){return e[0]*Math.exp(t*e[1])}function T(e,t){let n=e[0],r=e[1],o=e[2],l=e[3];return l+(n-l)/(1+Math.pow(t/o,r))}function I(e,t){let n=e[3];return n+(e[0]-n)/(1+Math.pow(10,e[1]*(e[2]-t)))}function _(e,t){let n=0,r=Math.min(...t.x),o=Math.max(...t.x),l=(o-r)/1e3;for(let t=r;t<o;t+=l)n+=l*e(t);return n}function O(e,t){let n=0,r=0,l=o.mean(t.y);for(let o=0;o<t.x.length;o++)n+=Math.pow(t.y[o]-e(t.x[o]),2),r+=Math.pow(t.y[o]-l,2);return 1-n/r}},165(e,t,n){"use strict";n.d(t,{GO:()=>y,KZ:()=>b,Kh:()=>u,_T:()=>m,fY:()=>p,iK:()=>C,s$:()=>f,xS:()=>h,zB:()=>d});var r=n(82),o=n(590),l=n(869),i=n(774);function a(e){let t={};var n=!0,r=!1,o=void 0;try{for(var l,i=e[Symbol.iterator]();!(n=(l=i.next()).done);n=!0){let e=l.value;null!==e.defaultValue&&(t[e.name]=e.defaultValue)}}catch(e){r=!0,o=e}finally{try{n||null==i.return||i.return()}finally{if(r)throw o}}return t}function u(){return{chartOptions:a(o.xs),seriesOptions:a(l.IL)}}function s(e){let 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 c(e,t,n){let o=void 0===n?.05:n,l=e.left,i=e.right,a=e.top,u=e.bottom;if(t.logX)l=l>0?l/(1+o):l,i*=1+o;else{let t=e.width*o;l-=t,i+=t}if(t.logY)a=a>0?a/(1+o):a,u*=1+o;else{let t=e.height*o;a-=t,u+=t}return new r.Rect(l,a,i-l,u-a)}function f(e){var t,n;let o=e.chartOptions;if(!(null==(t=e.series)?void 0:t.length)||0===e.series.length)return new r.Rect(0,0,1,1);{let t,l,i,a,u,f=s(e.series[0].points),d=f.xs,m=f.ys,p=r.Rect.fromXYArrays(d,m);for(let t=1;t<e.series.length;t++){let n=s(e.series[t].points),o=n.xs,l=n.ys;o.some(e=>void 0===e)||l.some(e=>void 0===e)||(p=p.union(r.Rect.fromXYArrays(o,l)))}return o?(l=(t=c(n=p,o)).x,i=t.y,a=t.width,u=t.height,null!=o.minX&&o.minX<=n.maxX&&(!o.logX||o.logX&&o.minX>0)&&(a+=l-o.minX,l=o.minX),null!=o.maxX&&o.maxX>=n.minX&&(!o.logX||o.logX&&o.maxX>0)&&(a+=o.maxX-(l+a)),null!=o.minY&&o.minY<=n.maxY&&(!o.logY||o.logY&&o.minY>0)&&(u+=i-o.minY,i=o.minY),null!=o.maxY&&o.maxY>=n.minY&&(!o.logY||o.logY&&o.maxY>0)&&(u+=o.maxY-(i+u)),new r.Rect(l,i,a,u)):c(p,o)}}function d(e){return(0,l.TV)(e.fitFunction)}function m(e,t){var n;let r=new Float32Array(null==(n=e.parameters)?void 0:n.length);return r.set(e.parameters),(0,o.ah)(t.y,r)}function p(e,t,n,r,a){var u,s;null!=r||(r=(0,i.Sm)(e,a,n));let c=null!=(u=e.parameters)?u:(0,l.nT)(e,t,r).parameters,f=new Float32Array(c.length);return f.set(c),(0,l.O8)(r,f,t.y,.05,null!=(s=e.errorModel)?s:o.dZ.CONSTANT)}function h(e,t,n,r){var a;null!=n||(n=(0,i.Sm)(e,r,!1));let u=null!=(a=e.parameters)?a:(0,l.nT)(e,t,n).parameters,s=new Float32Array(u.length);return s.set(u),t.fillParams({fittedCurve:(0,o.ah)(t.y,s),parameters:s},e,n,r)}let g=["ic50","ec50"],v=[],y=["pIC50"];function C(e,t){var n,r;if(!e.parameters||!(null==t?void 0:t.logX)&&!(null==t?void 0:t.logY))return e;let o=d(e).statisticFields,l=[...e.parameters],i=!1;for(let e=0;e<l.length&&e<o.length;e++)(t.logX&&g.includes(o[e])||t.logY&&v.includes(o[e]))&&l[e]>0&&(l[e]=Math.log10(l[e]),i=!0);return i?(n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e),r=r={parameters:l},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n):e}function b(e,t){let n=t=>{var n=!0,r=!1,o=void 0;try{for(var l,i=t[Symbol.iterator]();!(n=(l=i.next()).done);n=!0){let t=l.value;"number"==typeof e[t]&&(e[t]=Math.pow(10,e[t]))}}catch(e){r=!0,o=e}finally{try{n||null==i.return||i.return()}finally{if(r)throw o}}};return(null==t?void 0:t.logX)&&n(g),(null==t?void 0:t.logY)&&n(v),"number"==typeof e.ic50&&e.ic50>0&&(e.pIC50=-Math.log10(e.ic50)),e}},869(e,t,n){"use strict";n.d(t,{nT:()=>W,IL:()=>q,HM:()=>V,hD:()=>k,rT:()=>H,TV:()=>B,h5:()=>X,O8:()=>U,Wh:()=>F,Z2:()=>y});var r,o,l=n(82),i=n(590),a=n(774),u=n(353);class s extends Error{constructor(e){super(e)}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function f(e,t,n,r,o,l,i,a){for(let u=0;u<l;u++)t[u]=e[u],t[u]+=o*(e[u]-r[n][u]),t[u]<i[u]?t[u]=i[u]:t[u]>a[u]&&(t[u]=a[u])}(r=o||(o={}))[r.TOLERANCE=.01]="TOLERANCE",r[r.MAX_ITER=30]="MAX_ITER",r[r.NON_ZERO_PARAM=1e-4]="NON_ZERO_PARAM",r[r.INITIAL_SCALE=.02]="INITIAL_SCALE",r[r.SCALE_REFLECTION=1]="SCALE_REFLECTION",r[r.SCALE_EXPANSION=2]="SCALE_EXPANSION",r[r.SCALE_CONTRACTION=-.5]="SCALE_CONTRACTION";let d=function(e,t,n,r,o){var l;let i=n.tolerance,a=n.maxIter,u=n.scaleReflection,s=n.scaleExpansion,d=n.scaleContraction,m=t.length+1,p=t.length,h=function(e){if(Array.isArray(e))return e}(l=function(e,t,n,r,o){let l=n.length+1,i=n.length,a=t.nonZeroParam,u=t.initialScale,s=Array(l),c=Array(l);for(let t=0;t<l;t++){s[t]=new Float32Array(i);for(let e=0;e<i;e++)s[t][e]=n[e],0!==t&&t-1===e&&(0===n[e]?s[t][e]=a:s[t][e]+=u*n[t-1],s[t][e]<r[e]?s[t][e]=r[e]:s[t][e]>o[e]&&(s[t][e]=o[e]));c[t]=e(s[t]).likelihood}return[s,c]}(e,n,t,r,o))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],l=!0,i=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(i)throw n}}return o}}(l)||function(e){if(e){if("string"==typeof e)return c(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return c(e,2)}}(l)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),g=h[0],v=h[1],y=Array(m);for(let e=0;e<m;e++)y[e]=e;let C=y.length-1,b=0,w=0,x=0,T=0,I=new Float32Array(p),_=new Float32Array(p),O=new Float32Array(p),E=new Float32Array(p),P=Array(a);if(m>1){for(;y.sort((e,t)=>v[e]-v[t]),!(b>a);){if(0===b&&(w=v[0],x=2*v[y[0]]),P[b]=w,++b,x-(w=v[y[0]])>i)T=0;else if(++T>2*m)break;x=w,function(e,t,n,r){for(let o=0;o<t;o++){let l=0;for(let e=0;e<t+1;e++)e!==n&&(l+=r[e][o]);e[o]=l/t}}(I,p,y[C],g),f(I,_,y[C],g,u,p,r,o);let t=e(_).likelihood;if(t<v[y[C]]){f(I,O,y[C],g,s,p,r,o);let n=e(O).likelihood;if(n<t){v[y[C]]=n;for(let e=0;e<p;e++)g[y[C]][e]=O[e];continue}v[y[C]]=t;for(let e=0;e<p;e++)g[y[C]][e]=_[e];continue}f(I,E,y[C],g,d,p,r,o);let n=e(E).likelihood;if(n<v[y[C]]){v[y[C]]=n;for(let e=0;e<p;e++)g[y[C]][e]=E[e];continue}break}for(let e=b;e<a;e++)P[e]=v[y[0]]}return{point:g[y[0]],cost:v[y[0]],iterCosts:P,iterCount:b-1}};var m=n(296),p=n.n(m);function h(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function g(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}class v{get derivedStatisticsProperties(){return[]}get statisticLabels(){return this.parameterNames}get statisticsProperties(){var e,t,n;return null!=this._statisticsProperties||(this._statisticsProperties=(e=this.statisticFields,t=this.statisticLabels,n=this.derivedStatisticsProperties,[...S,...e.map((e,n)=>P(e,t[n])),...void 0===n?[]:n])),this._statisticsProperties}legacyStatisticProperty(e){var t,n;if("interceptY"===e)return R;let r=M[e];if(void 0!==r&&!(r>=this.parameterNames.length))return null!=this._legacyProperties||(this._legacyProperties={}),null!=(t=(n=this._legacyProperties)[e])?t:n[e]=P(e,this.parameterNames[r])}get hasAsymptotes(){return!1}inverse(e,t){}}let y={SIGMOID:"sigmoid",LINEAR:"linear",LOG_LINEAR:"log-linear",EXPONENTIAL:"exponential",FOUR_PL_REGRESSION:"4pl-regression",FOUR_PL_DOSE_RESPONSE:"4pl-dose-response"};class C{constructor(e,t,n){this.auc=e.auc,this.rSquared=e.rSquared,this.series=t,this.parameters=n}}let b=["auc","rSquared","series","parameters","name"];class w extends C{get name(){return i.Z5}constructor(e,t,n,r,o){let l=void 0===r?[]:r;super(e,t,n);for(let e=0;e<l.length;e++)b.includes(l[e])||(this[l[e]]=n[e]);o&&n.length>2&&void 0===this.interceptY&&(this.interceptY=o(n[2]))}}class x extends C{get name(){return i.Ff}constructor(e,t,n){super(e,t,n),this.slope=e.slope,this.intercept=e.intercept}}class T extends x{get name(){return i.kx}}class I extends C{get name(){return i.G7}constructor(e,t,n){super(e,t,n),this.top=e.top,this.slope=e.slope,this.ic50=e.ic50,this.bottom=e.bottom,this.interceptY=e.interceptY,this.maxY=Math.max(e.top,e.bottom),this.minY=Math.min(e.top,e.bottom)}}class _ extends C{get name(){return i.Pf}constructor(e,t,n){super(e,t,n),this.mantissa=e.mantissa,this.power=e.power}}class O extends C{get name(){return i.kC}constructor(e,t,n){super(e,t,n),this.top=e.top,this.bottom=e.bottom,this.slope=e.slope,this.ec50=e.ec50,this.interceptY=e.interceptY,this.maxY=Math.max(e.top,e.bottom),this.minY=Math.min(e.top,e.bottom)}}class E extends O{get name(){return i.Qx}constructor(e,t,n){super(e,t,n),this.ic50=e.ec50}}function P(e,t){return l.Property.js(e,l.TYPE.FLOAT,{userEditable:!1,friendlyName:t})}let S=[P("rSquared","R\xb2"),P("auc","AUC")];function N(e){return[P("interceptY",`Y at ${e}`),P("maxY","Max Y"),P("minY","Min Y")]}let A=P("pIC50","pIC50"),L={[i.G7]:{interceptX:"ic50"},[i.kC]:{interceptX:"ec50"},[i.Qx]:{interceptX:"ic50"}},M={top:0,slope:1,interceptX:2,bottom:3},R=P("interceptY","Intercept Y");function F(e,t){var n,r,o;let l=null!=(n=null==(o=L[e.name])?void 0:o[t])?n:t;return null!=(r=e.statisticsProperties.find(e=>e.name===l))?r:e.legacyStatisticProperty(t)}function X(e,t){var n,r,o;let l=null!=(n=null==(r=L[e.name])?void 0:r[t])?n:t,i=e[l];if("number"==typeof i)return i;if("interceptX"===t)return;let a=M[t],u=void 0===a||null==(o=e.parameters)?void 0:o[a];return"number"!=typeof u||isNaN(u)?void 0:u}function D(e,t,n){return null!=t?t:(0,a.Sm)(e,n,!1)}function Y(e,t){return{auc:(0,i.Mi)(e,t),rSquared:(0,i.Hr)(e,t)}}class j extends v{get name(){return i.kC}get hasAsymptotes(){return!0}get parameterNames(){return["Top","Slope","EC50","Bottom"]}get statisticFields(){return["top","slope","ec50","bottom"]}get derivedStatisticsProperties(){return N(this.parameterNames[2])}fitValues(e,t,n,r){return g(h({},Y(e.fittedCurve,D(t,n,r))),{top:e.parameters[0],slope:e.parameters[1],ec50:e.parameters[2],bottom:e.parameters[3],interceptY:e.fittedCurve(e.parameters[2])})}fillParams(e,t,n,r){return new O(this.fitValues(e,t,n,r),t,e.parameters)}y(e,t){return(0,i.Sm)(e,t)}inverse(e,t){return e[2]*Math.pow(t/(1-t),1/Math.abs(e[1]))}getInitialParameters(e,t){let n=new Float32Array(4),r=Math.min(...t),o=Math.max(...t),l=(o-r)/2+r,i=o-r,a=0;for(let n=0;n<e.length;n++){let e=Math.abs(t[n]-l);e<i&&(i=e,a=n)}let u=e[a],s=t[0]>t[t.length-1]?-10:10;return n.set([o,s,u,r]),n}}class G extends v{get statisticFields(){return this._parameterNames.filter(e=>!b.includes(e))}get statisticLabels(){return this.statisticFields}fillParams(e,t,n,r){return new w(Y(e.fittedCurve,D(t,n,r)),t,e.parameters,this._parameterNames,e.fittedCurve)}get name(){return this._name}get parameterNames(){return this._parameterNames}y(e,t){throw Error("Not implemented")}getInitialParameters(e,t){throw Error("Not implemented")}constructor(e,t,n,r){super(),this._name=e,this._parameterNames=r,this.y=t,this.getInitialParameters=n}}let H={linear:new class extends v{get name(){return i.Ff}get parameterNames(){return["Slope","Intercept"]}get statisticFields(){return["slope","intercept"]}fillParams(e,t,n,r){return new x(g(h({},Y(e.fittedCurve,D(t,n,r))),{slope:e.parameters[0],intercept:e.parameters[1]}),t,e.parameters)}y(e,t){return(0,i.sn)(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);let o=e[r]-e[n],l=(t[r]-t[n])/o,i=t[r]-l*e[r],a=new Float32Array(2);return a.set([l,i]),a}},sigmoid:new class extends v{get name(){return i.G7}get hasAsymptotes(){return!0}get parameterNames(){return["Top","Slope","IC50","Bottom"]}get statisticFields(){return["top","slope","ic50","bottom"]}get derivedStatisticsProperties(){return[...N(this.parameterNames[2]),A]}fillParams(e,t,n,r){return new I(g(h({},Y(e.fittedCurve,D(t,n,r))),{top:e.parameters[0],slope:e.parameters[1],ic50:e.parameters[2],bottom:e.parameters[3],interceptY:e.fittedCurve(e.parameters[2])}),t,e.parameters)}y(e,t){return(0,i.ry)(e,t)}inverse(e,t){return e[2]+Math.log10(t/(1-t))/Math.abs(e[1])}getInitialParameters(e,t){let n=l.Rect.fromXYArrays(e,t),r=(n.maxY-n.minY)/2+n.minY,o=n.maxY-n.minY,i=0;for(let n=0;n<e.length;n++){let e=Math.abs(t[n]-r);e<o&&(o=e,i=n)}let a=e[i],u=t[0]>t[t.length-1]?1:-1,s=new Float32Array(4);return s.set([n.maxY,u,a,n.minY]),s}},"log-linear":new class extends v{get name(){return i.kx}get parameterNames(){return["Slope","Intercept"]}get statisticFields(){return["slope","intercept"]}fillParams(e,t,n,r){return new T(g(h({},Y(e.fittedCurve,D(t,n,r))),{slope:e.parameters[0],intercept:e.parameters[1]}),t,e.parameters)}y(e,t){return(0,i.AJ)(e,t)}getInitialParameters(e,t){let n=new Float32Array(2);return n.set([-5,100]),n}},exponential:new class extends v{get name(){return i.Pf}get parameterNames(){return["Mantissa","Power"]}get statisticFields(){return["mantissa","power"]}fillParams(e,t,n,r){return new _(g(h({},Y(e.fittedCurve,D(t,n,r))),{mantissa:e.parameters[0],power:e.parameters[1]}),t,e.parameters)}y(e,t){return(0,i.EV)(e,t)}getInitialParameters(e,t){let n=new Float32Array(2);return n.set([100,-2]),n}},"4pl-regression":new j,"4pl-dose-response":new class extends j{get name(){return i.Qx}get parameterNames(){return["Max","Hill","IC50","Min"]}get statisticFields(){return["top","slope","ic50","bottom"]}get derivedStatisticsProperties(){return[...N(this.parameterNames[2]),A]}fillParams(e,t,n,r){return new E(this.fitValues(e,t,n,r),t,e.parameters)}y(e,t){return(0,i.Vd)(e,t)}inverse(e,t){return e[2]+Math.log10(t/(1-t))/Math.abs(e[1])}}},k="sigmoid",V={},q=[l.Property.js("fitFunction",l.TYPE.STRING,{category:"Fitting",choices:Object.keys(H),defaultValue:k}),l.Property.js("pointColor",l.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),l.Property.js("fitLineColor",l.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),l.Property.js("outlierColor",l.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),l.Property.js("errorModel",l.TYPE.STRING,{category:"Fitting",defaultValue:"constant",choices:["constant","proportional","combined"],nullable:!1}),l.Property.js("connectDots",l.TYPE.BOOL,{category:"Fitting",defaultValue:!1}),l.Property.js("clickToToggle",l.TYPE.BOOL,{category:"Fitting",description:"Click on a point to mark it as outlier and refit",nullable:!0,defaultValue:!1}),l.Property.js("showFitLine",l.TYPE.BOOL,{category:"Fitting",defaultValue:!0}),l.Property.js("showPoints",l.TYPE.STRING,{category:"Fitting",description:"Whether points/candlesticks/none should be rendered",defaultValue:"points",choices:["points","candlesticks","both"]}),l.Property.js("showOutliers",l.TYPE.BOOL,{category:"Fitting",defaultValue:!0}),l.Property.js("showCurveConfidenceInterval",l.TYPE.BOOL,{category:"Fitting",description:"Whether confidence intervals should be rendered",defaultValue:!1,friendlyName:"Confidence Interval"}),l.Property.js("markerType",l.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"}),l.Property.js("outlierMarkerType",l.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"}),l.Property.js("lineStyle",l.TYPE.STRING,{category:"Rendering",defaultValue:"solid",choices:["solid","dotted","dashed","dashdotted"],nullable:!1}),l.Property.js("droplines",l.TYPE.STRING_LIST,{description:"Whether specific droplines should be rendered",choices:i.h1,inputType:"MultiChoice"}),l.Property.js("columnName",l.TYPE.STRING,{description:"Column name where the series is stored",defaultValue:""})];function B(e){var t,n;if(null==e)return H[k];if("string"==typeof e)return null!=(t=H[e])?t:H[k];if(!H[e.name]){let t=e.name,n=e.parameterNames,r=e.function.split("=>").map(e=>e.trim()),o=e.getInitialParameters.split("=>").map(e=>e.trim()),l=new G(t,Function(r[0].slice(1,r[0].length-1),`${r[1].includes(";")?"":"return "}${r[1]}`),Function(o[0].slice(1,o[0].length-1),`return ${o[1]}`),n);H[t]=l}return null!=V[n=e.name]||(V[n]=e),H[e.name]}function W(e,t,n,r){var u;return null!=n||(n=(0,a.Sm)(e,r,!1)),e.parameterBounds&&(null==r?void 0:r.logX)&&(e.parameterBounds[2]=(0,a.Yq)(e.parameterBounds[2])),function(e,t,n,r){var a,u,c;let f;null!=n||(n=i.dZ.CONSTANT);let m=t.y,h=t.getInitialParameters(e.x,e.y),g=(a=m,u=e,c=n,e=>{var t;let n=0,r=0,o=0,l=u.y,s=u.x.map(t=>a(e,t)),f=l.map((e,t)=>e-s[t]),d=f.map(e=>Math.pow(e,2));for(let e=0;e<d.length;e++)[i.dZ.CONSTANT,i.dZ.COMBINED].includes(c)?r+=d[e]:c===i.dZ.PROPORTIONAL&&(o+=d[e]/(s[e]*s[e]));r=Math.sqrt(r/d.length),o=Math.sqrt(o/d.length),c===i.dZ.COMBINED&&(r=(t=$(r,o,d,s)).sigmaA,o=t.sigmaB);let m=[];for(let e=0;e<d.length;e++)m[e]=Math.pow(r+o*s[e],2),n+=d[e]/m[e]+Math.log(2*Math.PI*m[e]);return{likelihood:n,residuals:f}}),v=new Float32Array(t.parameterNames.length),y=new Float32Array(t.parameterNames.length);for(let e=0;e<t.parameterNames.length;e++)v[e]=0===h[e]?-1:h[e]-Math.abs(.5*h[e]),y[e]=0===h[e]?1:h[e]+Math.abs(.5*h[e]);let C=l.BitSet.create(2*t.parameterNames.length);if(r&&0!==r.length)for(let e=0;e<r.length;e++)void 0!==r[e].min&&null!==r[e].min&&(v[e]=r[e].min,C.set(2*e,!0)),void 0!==r[e].max&&null!==r[e].max&&(y[e]=r[e].max,C.set(2*e+1,!0));let b=e=>{let t=g(e.point).residuals,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},w=-1,x=0,T=null,I=0;for(;;){f=function(e,t,n,r,o){let i,a=void 0===o?null:o,u=function(e,t){let n=p()("12345"),r=e.length,o=Array(10);for(let e=0;e<10;e++)o[e]=new Float32Array(r);for(let l=0;l<r;l++)if(e[l]===t[l])for(let t=0;t<10;t++)o[t][l]=e[l];else{let r=function(e,t,n,r){let o=t-n,l=Array(e);for(let t=0;t<e;t++){let e=r();l[t]=n+e*o}return l}(10,e[l],t[l],n);for(let e=0;e<10;e++)o[e][l]=r[e]}return o}(n,t),c=[],f=[],m=[],h=0,g=null;for(i=0;i<10;++i)try{if(0===i){let t=null===a?u[i]:a,n=new Float32Array(a.length).map(e=>-1/0),o=new Float32Array(a.length).map(e=>Infinity);c.push(d(e,t,r,n,o))}else c.push(d(e,u[i],r,t,n))}catch(e){if(e instanceof s)throw Error(`Inconsistent dataframes: ${e.message}`);++h,f.push(e instanceof Error?e.message:"Platform issue"),m.push(u[i])}if(h>0){let e=n.length,t=Array(e);for(let n=0;n<e;++n)t[n]=new Float32Array(h);m.forEach((e,n)=>e.forEach((e,r)=>t[r][n]=e)),(g=l.DataFrame.fromColumns(t.map((e,t)=>l.Column.fromFloat32Array(`arg${t}`,e)))).columns.add(l.Column.fromStrings("Issue",f))}return{extremums:c,fails:g}}(g,v,y,{tolerance:o.TOLERANCE,maxIter:o.MAX_ITER,nonZeroParam:o.NON_ZERO_PARAM,initialScale:o.INITIAL_SCALE,scaleReflection:o.SCALE_REFLECTION,scaleExpansion:o.SCALE_EXPANSION,scaleContraction:o.SCALE_CONTRACTION},h),I=0;for(let e=1;e<f.extremums.length;e++)f.extremums[e].cost<f.extremums[I].cost&&(I=e);let e=b(f.extremums[I]);if(null===T?T=e:e<T?(T=e,x=0):x++,h=f.extremums[I].point,w>40||3===x)break;for(let e=0;e<t.parameterNames.length;e++)C.get(2*e)||(v[e]=h[e]-Math.abs(h[e]*(x+.5))),C.get(2*e+1)||(y[e]=h[e]+Math.abs(h[e]*(x+.5)));w++}return{fittedCurve:(0,i.ah)(m,h),parameters:h}}((0,a.mr)(n),t,null!=(u=e.errorModel)?u:i.dZ.CONSTANT,e.parameterBounds)}function $(e,t,n,r){let o=Number.MAX_VALUE,l=0;for(let t=0;t<=10;t++){let i=0,a=t/10,u=e*a,s=e*(1-a),c=[];for(let e=0;e<n.length;e++)c[e]=Math.pow(u+s*r[e],2),i+=n[e]/c[e]+Math.log(2*Math.PI*c[e]);i<o&&(o=i,l=a)}return t=e*(1-l),{sigmaA:e*=l,sigmaB:t}}function U(e,t,n,r,o){let l=function(e,t,n,r){var o;let l=0,a=0,u=t.y,s=t.x.map(t=>e(r,t)),c=u.map((e,t)=>e-s[t]),f=c.map(e=>Math.pow(e,2));for(let e=0;e<f.length;e++)[i.dZ.CONSTANT,i.dZ.COMBINED].includes(n)?l+=f[e]:n===i.dZ.PROPORTIONAL&&(a+=Math.pow(c[e]/Math.abs(s[e]),2));return l=Math.sqrt(l/f.length),a=Math.sqrt(a/f.length),n===i.dZ.COMBINED&&(l=(o=$(l,a,f,s)).sigmaA,a=o.sigmaB),{sigmaA:l,sigmaB:a}}(n,e,o,t),a=u.normal.inv(1-(void 0===r?.05:r)/2,0,1);return{confidenceTop:e=>{let r=n(t,e);return r+a*(l.sigmaA+Math.abs(r)*l.sigmaB)},confidenceBottom:e=>{let r=n(t,e);return r-a*(l.sigmaA+Math.abs(r)*l.sigmaB)}}}},774(e,t,n){"use strict";function r(e,t,n){let r=n?e.points:e.points.filter(e=>!e.outlier);return{x:r.map(e=>(null==t?void 0:t.logX)?Math.log10(e.x):e.x),y:r.map(e=>(null==t?void 0:t.logY)?Math.log10(e.y):e.y)}}function o(e){let 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 l(e){let 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}let l=o(n);t.x[t.x.length]=n.x[0],t.y[t.y.length]=l,n.x=[e.x[r]],n.y=[e.y[r]]}let r=o(n);return t.x[t.x.length]=n.x[0],t.y[t.y.length]=r,t}function i(e){return e&&(void 0!==e.max&&(e.max=Math.log10(e.max)),void 0!==e.min&&(e.min=0===e.min?-Number.MAX_VALUE:Math.log10(e.min))),e}n.d(t,{Sm:()=>r,Yq:()=>i,mr:()=>l})},533(e,t,n){"use strict";n.d(t,{L:()=>i});var r=n(82);let o=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}},l=new class{screenToWorld(e,t,n,r,o){let l=Math.log(n=n<1e-30?1e-30:n);return Math.exp(l+(Math.log(r)-l)*(o?t-e:e)/t)}worldToScreen(e,t,n,r,o){if(e<=0)return NaN;if(1e-30>Math.abs(e-n))return o?t:0;if(1e-30>Math.abs(e-r))return o?0:t;let l=t*Math.log((e=e<1e-30?1e-30:e)/(n=n<1e-30?1e-30:n))/Math.log(r/n);return o?t-l:l}};class i{get xt(){return this.logX?l:o}get yt(){return this.logY?l:o}xToScreen(e){return this.screen.left+this.xt.worldToScreen(e,this.screen.width,this.world.minX,this.world.maxX,this.inverseX)}yToScreen(e){return this.screen.top+this.yt.worldToScreen(e,this.screen.height,this.world.minY,this.world.maxY,!this.inverseY)}xToWorld(e){return this.xt.screenToWorld(e-this.screen.left,this.screen.width,this.world.minX,this.world.maxX,this.inverseX)}yToWorld(e){return this.yt.screenToWorld(e-this.screen.top,this.screen.height,this.world.minY,this.world.maxY,!this.inverseY)}toScreen(e){return new 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)}constructor(e,t,n,r){this.logX=!1,this.logY=!1,this.inverseX=!1,this.inverseY=!1,this.world=e,this.screen=t,this.logX=void 0!==n&&n,this.logY=void 0!==r&&r}}},82(e){"use strict";e.exports=DG},328(e){"use strict";e.exports=grok},858(e){"use strict";e.exports=rxjs},389(e){"use strict";e.exports=ui},991(e){"use strict";e.exports=wu},562(){}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var l=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(l.exports,l,l.exports,n),l.loaded=!0,l.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"u">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),curves=n(644)})();
1
+ var curves;(()=>{var e={353(e){e.exports=function(){var e=function(e){var t=Array.prototype.concat,n=Array.prototype.slice,r=Object.prototype.toString;function o(t,n){var r=t>n?t:n;return e.pow(10,17-~~(e.log(r>0?r:-r)*e.LOG10E))}var l=Array.isArray||function(e){return"[object Array]"===r.call(e)};function i(e){return"[object Function]"===r.call(e)}function a(e){return"number"==typeof e&&e-e==0}function u(){return new u._init(arguments)}function s(){return 0}function c(){return 1}function f(e,t){return+(e===t)}u.fn=u.prototype,u._init=function(e){if(l(e[0]))if(l(e[0][0])){i(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]=i(e[1])?u.map(e[0],e[1]):e[0],this.length=1;else if(a(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:o,isArray:l,isFunction:i,isNumber:a,toVector:function(e){return t.apply([],e)}},u._random_fn=e.random,u.setRandom=function(e){if("function"!=typeof e)throw 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 l(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(l(t)){var n=u.arange(e.length).map(function(){return 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=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=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=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,a=[];for(l(e[0])||(e=[e]),n=e.length,r=e[0].length,i=0;i<r;i++){for(o=0,t=Array(n);o<n;o++)t[o]=e[o][i];a.push(t)}return 1===a.length?a[0]:a},u.map=function(e,t,n){var r,o,i,a,u;for(l(e[0])||(e=[e]),o=e.length,i=e[0].length,a=n?e:Array(o),r=0;r<o;r++)for(a[r]||(a[r]=Array(i)),u=0;u<i;u++)a[r][u]=t(e[r][u],r,u);return 1===a.length?a[0]:a},u.cumreduce=function(e,t,n){var r,o,i,a,u;for(l(e[0])||(e=[e]),o=e.length,i=e[0].length,a=n?e:Array(o),r=0;r<o;r++)for(a[r]||(a[r]=Array(i)),i>0&&(a[r][0]=e[r][0]),u=1;u<i;u++)a[r][u]=t(a[r][u-1],e[r][u]);return 1===a.length?a[0]:a},u.alter=function(e,t){return u.map(e,t,!0)},u.create=function(e,t,n){var r,o,l=Array(e);for(i(t)&&(n=t,t=e),r=0;r<e;r++)for(o=0,l[r]=Array(t);o<t;o++)l[r][o]=n(r,o);return l},u.zeros=function(e,t){return a(t)||(t=e),u.create(e,t,s)},u.ones=function(e,t){return a(t)||(t=e),u.create(e,t,c)},u.rand=function(e,t){return a(t)||(t=e),u.create(e,t,u._random_fn)},u.identity=function(e,t){return a(t)||(t=e),u.create(e,t,f)},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,s)},u.seq=function(e,t,n,r){i(r)||(r=!1);var l,a=[],u=o(e,t),s=(t*u-e*u)/((n-1)*u),c=e;for(l=0;c<=t&&l<n;c=(e*u+s*u*++l)/u)a.push(r?r(c,l):c);return a},u.arange=function(e,t,n){var r,o=[];if(n=n||1,void 0===t&&(t=e,e=0),e===t||0===n||e<t&&n<0||e>t&&n>0)return[];if(n>0)for(r=e;r<t;r+=n)o.push(r);else for(r=e;r>t;r+=n)o.push(r);return o},u.slice=function(){function e(e,t,n,r){var o,l=[],i=e.length;if(void 0===t&&void 0===n&&void 0===r)return u.copy(e);if(t=t||0,n=n||e.length,r=r||1,(t=t>=0?t:i+t)===(n=n>=0?n:i+n)||0===r||t<n&&r<0||t>n&&r>0)return[];if(r>0)for(o=t;o<n;o+=r)l.push(e[o]);else for(o=t;o>n;o+=r)l.push(e[o]);return l}return function(t,n){if(a((n=n||{}).row)){var r,o;if(a(n.col))return t[n.row][n.col];return e(u.rowa(t,n.row),(r=n.col||{}).start,r.end,r.step)}return a(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(t,n,r){var o,l;if(a(n.row)){if(a(n.col))return t[n.row][n.col]=r;n.col=n.col||{},n.col.start=n.col.start||0,n.col.end=n.col.end||t[0].length,n.col.step=n.col.step||1,o=u.arange(n.col.start,e.min(t.length,n.col.end),n.col.step);var i=n.row;return o.forEach(function(e,n){t[i][e]=r[n]}),t}if(a(n.col)){n.row=n.row||{},n.row.start=n.row.start||0,n.row.end=n.row.end||t.length,n.row.step=n.row.step||1,l=u.arange(n.row.start,e.min(t[0].length,n.row.end),n.row.step);var s=n.col;return l.forEach(function(e,n){t[e][s]=r[n]}),t}return void 0===r[0].length&&(r=[r]),n.row.start=n.row.start||0,n.row.end=n.row.end||t.length,n.row.step=n.row.step||1,n.col.start=n.col.start||0,n.col.end=n.col.end||t[0].length,n.col.step=n.col.step||1,l=u.arange(n.row.start,e.min(t.length,n.row.end),n.row.step),o=u.arange(n.col.start,e.min(t[0].length,n.col.end),n.col.step),l.forEach(function(e,n){o.forEach(function(o,l){t[e][o]=r[n][l]})}),t},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 a(e)?e:e.map(function(e){return e})})};var d=u.prototype;d.length=0,d.push=Array.prototype.push,d.sort=Array.prototype.sort,d.splice=Array.prototype.splice,d.slice=Array.prototype.slice,d.toArray=function(){return this.length>1?n.call(this):n.call(this)[0]},d.map=function(e,t){return u(u.map(this,e,t))},d.cumreduce=function(e,t){return u(u.cumreduce(this,e,t))},d.alter=function(e){return u.alter(this,e),this};for(var m="transpose clear symmetric rows cols dimensions diag antidiag".split(" "),p=0;p<m.length;p++)!function(e){d[e]=function(t){var n,r=this;return t?(setTimeout(function(){t.call(r,d[e].call(r))}),this):l(n=u[e](this))?u(n):n}}(m[p]);for(var h="row col".split(" "),g=0;g<h.length;g++)!function(e){d[e]=function(t,n){var r=this;return n?(setTimeout(function(){n.call(r,d[e].call(r,t))}),this):u(u[e](this,t))}}(h[g]);for(var v="create zeros ones rand identity".split(" "),y=0;y<v.length;y++)!function(e){d[e]=function(){return u(u[e].apply(null,arguments))}}(v[y]);return 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,l=t.length;--l>=0;)o+=(n=t[l]-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++){var l=e[t];o[l]?o[l]++:(o[l]=1,n.push(l))}var i=n.sort(r),a={},u=1;for(t=0;t<i.length;t++){var l=i[t],s=o[l],c=(u+(u+s-1))/2;a[l]=c,u+=s}return e.map(function(e){return a[e]})},e.mode=function(e){var t,n=e.length,o=e.slice().sort(r),l=1,i=0,a=0,u=[];for(t=0;t<n;t++)o[t]===o[t+1]?l++:(l>i?(u=[o[t]],i=l,a=0):l===i&&(u.push(o[t]),a++),l=1);return 0===a?u[0]:u},e.range=function(t){return e.max(t)-e.min(t)},e.variance=function(t,n){return e.sumsqerr(t)/(t.length-!!n)},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=Array(r),l=0;l<r;l++)o[l]=t[l]-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=[],l=n.length-1;l>=0;l--)o.push(t.abs(n[l]-r));return e.mean(o)},e.meddev=function(n){for(var r=e.median(n),o=[],l=n.length-1;l>=0;l--)o.push(t.abs(n[l]-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,l,i){var a,u,s,c,f,d,m=e.slice().sort(r),p=[n.length],h=e.length;for(void 0===l&&(l=3/8),void 0===i&&(i=3/8),a=0;a<n.length;a++)s=l+(u=n[a])*(1-l-i),c=h*u+s,f=t.floor(o(c,1,h-1)),d=o(c-f,0,1),p[a]=(1-d)*m[f-1]+d*m[f];return p},e.percentile=function(e,t,n){var o=e.slice().sort(r),l=t*(o.length+(n?1:-1))+ +!n,i=parseInt(l);return i+1<o.length?o[i-1]+(l-i)*(o[i]-o[i-1]):o[i-1]},e.percentileOfScore=function(e,t,n){var r,o,l=0,i=e.length,a=!1;for("strict"===n&&(a=!0),o=0;o<i;o++)r=e[o],(a&&r<t||!a&&r<=t)&&l++;return l/i},e.histogram=function(n,r){r=r||4;var o,l=e.min(n),i=(e.max(n)-l)/r,a=n.length,u=[];for(o=0;o<r;o++)u[o]=0;for(o=0;o<a;o++)u[t.min(t.floor((n[o]-l)/i),r-1)]+=1;return u},e.covariance=function(t,n){var r,o=e.mean(t),l=e.mean(n),i=t.length,a=Array(i);for(r=0;r<i;r++)a[r]=(t[r]-o)*(n[r]-l);return e.sum(a)/(i-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),l=e.stdev(n),i=n.length,a=0,u=0;u<i;u++)a+=t.pow((n[u]-o)/l,r);return a/n.length},e.skewness=function(t){return e.stanMoment(t,3)},e.kurtosis=function(t){return e.stanMoment(t,4)-3};for(var l=e.prototype,i="cumsum cumprod".split(" "),a=0;a<i.length;a++)!function(t){l[t]=function(r,o){var i=[],a=0,u=this;if(n(r)&&(o=r,r=!1),o)return setTimeout(function(){o.call(u,l[t].call(u,r))}),this;if(this.length>1){for(u=!0===r?this:this.transpose();a<u.length;a++)i[a]=e[t](u[a]);return i}return e[t](this[0],r)}}(i[a]);for(var u="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(" "),s=0;s<u.length;s++)!function(t){l[t]=function(r,o){var i=[],a=0,u=this;if(n(r)&&(o=r,r=!1),o)return setTimeout(function(){o.call(u,l[t].call(u,r))}),this;if(this.length>1){for("sumrow"!==t&&(u=!0===r?this:this.transpose());a<u.length;a++)i[a]=e[t](u[a]);return!0===r?e[t](e.utils.toVector(i)):i}return e[t](this[0],r)}}(u[s]);for(var c="quantiles percentileOfScore".split(" "),f=0;f<c.length;f++)!function(t){l[t]=function(){var r,o=[],i=0,a=this,u=Array.prototype.slice.call(arguments);if(n(u[u.length-1])){r=u[u.length-1];var s=u.slice(0,u.length-1);return setTimeout(function(){r.call(a,l[t].apply(a,s))}),this}r=void 0;var c=function(n){return e[t].apply(a,[n].concat(u))};if(this.length>1){for(a=a.transpose();i<a.length;i++)o[i]=c(a[i]);return o}return c(this[0])}}(c[f])}(e,Math);var t=Math;e.gammaln=function(e){var n,r,o=0,l=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],i=1.000000000190015;for(r=(n=e)+5.5,r-=(e+.5)*t.log(r);o<6;o++)i+=l[o]/++n;return t.log(2.5066282746310007*i/e)-r},e.loggam=function(e){var n,r,o,l,i,a,u,s=[.08333333333333333,-.002777777777777778,7936507936507937e-19,-5952380952380952e-19,8417508417508418e-19,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=e,u=0,1==e||2==e)return 0;for(e<=7&&(u=t.floor(7-e),n=e+u),r=1/(n*n),o=2*t.PI,i=s[9],a=8;a>=0;a--)i*=r,i+=s[a];if(l=i/n+.5*t.log(o)+(n-.5)*t.log(n)-n,e<=7)for(a=1;a<=u;a++)l-=t.log(n-1),n-=1;return l},e.gammafn=function(e){var n,r,o,l,i=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],a=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],u=!1,s=0,c=0,f=0,d=e;if(e>171.6243769536076)return 1/0;if(d<=0){if(!(l=d%1+36e-17))return 1/0;u=(1&d?-1:1)*t.PI/t.sin(t.PI*l),d=1-d}for(n=0,o=d,r=d<1?d++:(d-=s=(0|d)-1)-1;n<8;++n)f=(f+i[n])*r,c=c*r+a[n];if(l=f/c+1,o<d)l/=o;else if(o>d)for(n=0;n<s;++n)l*=d,d++;return u&&(l=u/l),l},e.gammap=function(t,n){return e.lowRegGamma(t,n)*e.gammafn(t)},e.lowRegGamma=function(n,r){var o,l=e.gammaln(n),i=n,a=1/n,u=a,s=r+1-n,c=1/1e-30,f=1/s,d=f,m=1,p=-~(8.5*t.log(n>=1?n:1/n)+.4*n+17);if(r<0||n<=0)return NaN;if(r<n+1){for(;m<=p;m++)a+=u*=r/++i;return a*t.exp(-r+n*t.log(r)-l)}for(;m<=p;m++)s+=2,d*=(f=1/(f=(o=-m*(m-n))*f+s))*(c=s+o/c);return 1-d*t.exp(-r+n*t.log(r)-l)},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,l,i,a,u=1,s=n+r,c=n+1,f=n-1,d=1,m=1-s*e/c;for(1e-30>t.abs(m)&&(m=1e-30),a=m=1/m;u<=100&&(o=2*u,m=1+(l=u*(r-u)*e/((f+o)*(n+o)))*m,1e-30>t.abs(m)&&(m=1e-30),d=1+l/d,1e-30>t.abs(d)&&(d=1e-30),a*=(m=1/m)*d,m=1+(l=-(n+u)*(s+u)*e/((n+o)*(c+o)))*m,1e-30>t.abs(m)&&(m=1e-30),d=1+l/d,1e-30>t.abs(d)&&(d=1e-30),a*=i=(m=1/m)*d,!(3e-7>t.abs(i-1)));u++);return a},e.gammapinv=function(n,r){var o,l,i,a,u,s=0,c=r-1,f=e.gammaln(r);if(n>=1)return t.max(100,r+100*t.sqrt(r));if(n<=0)return 0;for(r>1?(a=t.log(c),u=t.exp(c*(a-1)-f),o=(2.30753+.27061*(l=t.sqrt(-2*t.log(n<.5?n:1-n))))/(1+l*(.99229+.04481*l))-l,n<.5&&(o=-o),o=t.max(.001,r*t.pow(1-1/(9*r)-o/(3*t.sqrt(r)),3))):o=n<(l=1-r*(.253+.12*r))?t.pow(n/l,1/r):1-t.log(1-(n-l)/(1-l));s<12;s++){if(o<=0)return 0;if(i=(e.lowRegGamma(r,o)-n)/(l=r>1?u*t.exp(-(o-c)+c*(t.log(o)-a)):t.exp(-o+c*t.log(o)-f)),(o-=l=i/(1-.5*t.min(1,i*((r-1)/o-1))))<=0&&(o=.5*(o+l)),t.abs(l)<1e-8*o)break}return o},e.erf=function(e){var n,r,o,l,i=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-946595344482036e-18,366839497852761e-18,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],a=i.length-1,u=!1,s=0,c=0;for(e<0&&(e=-e,u=!0),r=4*(n=2/(2+e))-2;a>0;a--)o=s,s=r*s-c+i[a],c=o;return l=n*t.exp(-e*e+.5*(i[0]+r*s)-c),u?l-1:1-l},e.erfc=function(t){return 1-e.erf(t)},e.erfcinv=function(n){var r,o,l,i,a=0;if(n>=2)return -100;if(n<=0)return 100;for(i=n<1?n:2-n,r=-.70711*((2.30753+.27061*(l=t.sqrt(-2*t.log(i/2))))/(1+l*(.99229+.04481*l))-l);a<2;a++)o=e.erfc(r)-i,r+=o/(1.1283791670955126*t.exp(-r*r)-r*o);return n<1?r:-r},e.ibetainv=function(n,r,o){var l,i,a,u,s,c,f,d,m,p=r-1,h=o-1,g=0;if(n<=0)return 0;if(n>=1)return 1;for(r>=1&&o>=1?(s=(2.30753+.27061*(a=t.sqrt(-2*t.log(n<.5?n:1-n))))/(1+a*(.99229+.04481*a))-a,n<.5&&(s=-s),c=(s*s-3)/6,f=2/(1/(2*r-1)+1/(2*o-1)),d=s*t.sqrt(c+f)/f-(1/(2*o-1)-1/(2*r-1))*(c+5/6-2/(3*f)),s=r/(r+o*t.exp(2*d))):(l=t.log(r/(r+o)),i=t.log(o/(r+o)),d=(a=t.exp(r*l)/r)+(u=t.exp(o*i)/o),s=n<a/d?t.pow(r*d*n,1/r):1-t.pow(o*d*(1-n),1/o)),m=-e.gammaln(r)-e.gammaln(o)+e.gammaln(r+o);g<10&&0!==s&&1!==s&&(u=(e.ibeta(s,r,o)-n)/(a=t.exp(p*t.log(s)+h*t.log(1-s)+m)),(s-=a=u/(1-.5*t.min(1,u*(p/s-h/(1-s)))))<=0&&(s=.5*(s+a)),s>=1&&(s=.5*(s+a+1)),!(t.abs(a)<1e-8*s)||!(g>0));g++);return s},e.ibeta=function(n,r,o){var l=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)?l*e.betacf(n,r,o)/r:1-l*e.betacf(1-n,o,r)/o)},e.randn=function(n,r){var o,l,i,a,u;if(r||(r=n),n)return e.create(n,r,function(){return e.randn()});do o=e._random_fn(),l=1.7156*(e._random_fn()-.5),u=(i=o-.449871)*i+(a=t.abs(l)+.386595)*(.196*a-.25472*i);while(u>.27597&&(u>.27846||l*l>-4*t.log(o)*o*o));return l/o},e.randg=function(n,r,o){var l,i,a,u,s,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),l=n-1/3,i=1/t.sqrt(9*l);do{do u=1+i*(s=e.randn());while(u<=0);u=u*u*u,a=e._random_fn()}while(a>1-.331*t.pow(s,4)&&t.log(a)>.5*s*s+l*(1-u+t.log(u)));if(n==f)return l*u;do a=e._random_fn();while(0===a);return t.pow(a,1/f)*l*u};for(var n="gammaln gammafn factorial factorialln".split(" "),r=0;r<n.length;r++)!function(t){e.fn[t]=function(){return e(e.map(this,function(n){return e[t](n)}))}}(n[r]);for(var o="randn".split(" "),l=0;l<o.length;l++)!function(t){e.fn[t]=function(){return e(e[t].apply(null,arguments))}}(o[l]);for(var i=Math,a="beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" "),u=0;u<a.length;u++)!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 l=e[t](n,r,o);return l.data=this,l},e[t].prototype.sample=function(n){var r=this._a,o=this._b,l=this._c;return n?e.alter(n,function(){return e[t].sample(r,o,l)}):e[t].sample(r,o,l)};for(var n="pdf cdf inv".split(" "),r=0;r<n.length;r++)!function(n){e[t].prototype[n]=function(r){var o=this._a,l=this._b,i=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,l,i)}):e[t][n](r,o,l,i)}}(n[r]);for(var o="mean median mode variance".split(" "),l=0;l<o.length;l++)!function(n){e[t].prototype[n]=function(){return e[t][n](this._a,this._b,this._c)}}(o[l])}(a[u]);function s(e,t,n,r){for(var o,l=0,a=1,u=1,s=1,c=0,f=0;i.abs((u-f)/u)>r;)f=u,l=u+(o=-(t+c)*(t+n+c)*e/(t+2*c)/(t+2*c+1))*l,a=s+o*a,c+=1,u=l+(o=c*(n-c)*e/(t+2*c-1)/(t+2*c))*u,l/=s=a+o*s,a/=s,u/=s,s=1;return u/t}function c(t,n,r){var o=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],l=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],a=.5*t;if(a>=8)return 1;var u=2*e.normal.cdf(a,0,1,1,0)-1;u=u>=i.exp(-50/r)?i.pow(u,r):0;for(var s=a,c=(8-a)/(C=t>3?2:3),f=s+c,d=0,m=r-1,p=1;p<=C;p++){for(var h=0,g=.5*(f+s),v=.5*(f-s),y=1;y<=12;y++){var C,b,x=g+v*(6<y?o[(b=12-y+1)-1]:-o[(b=y)-1]),w=x*x;if(w>60)break;var T=.5*(2*e.normal.cdf(x,0,1,1,0))-.5*(2*e.normal.cdf(x,t,1,1,0));T>=i.exp(-30/m)&&(h+=T=l[b-1]*i.exp(-(.5*w))*i.pow(T,m))}h*=2*v*r/i.sqrt(2*i.PI),d+=h,s=f,f+=c}return(u+=d)<=i.exp(-30/n)?0:(u=i.pow(u,n))>=1?1:u}e.extend(e.beta,{pdf:function(t,n,r){return t>1||t<0?0:1==n&&1==r?1:n<512&&r<512?i.pow(t,n-1)*i.pow(1-t,r-1)/e.betafn(n,r):i.exp((n-1)*i.log(t)+(r-1)*i.log(1-t)-e.betaln(n,r))},cdf:function(t,n,r){return t>1||t<0?(t>1)*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,t){return e*t/(i.pow(e+t,2)*(e+t+1))}}),e.extend(e.centralF,{pdf:function(t,n,r){var o;return t<0?0:n<=2?0===t&&n<2?1/0:0===t&&2===n?1:1/e.betafn(n/2,r/2)*i.pow(n/r,n/2)*i.pow(t,n/2-1)*i.pow(1+n/r*t,-(n+r)/2):(o=r/(r+t*n),n*o/2*e.binomial.pdf((n-2)/2,(n+r-2)/2,n*t/(r+t*n)))},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,t,n){return n<0?0:n/(i.pow(e-t,2)+i.pow(n,2))/i.PI},cdf:function(e,t,n){return i.atan((e-t)/n)/i.PI+.5},inv:function(e,t,n){return t+n*i.tan(i.PI*(e-.5))},median:function(e){return e},mode:function(e){return e},sample:function(t,n){return e.randn()*i.sqrt(1/(2*e.randg(.5)))*n+t}}),e.extend(e.chisquare,{pdf:function(t,n){return t<0?0:0===t&&2===n?.5:i.exp((n/2-1)*i.log(t)-t/2-n/2*i.log(2)-e.gammaln(n/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*i.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,t){return e<0?0:t*i.exp(-t*e)},cdf:function(e,t){return e<0?0:1-i.exp(-t*e)},inv:function(e,t){return-i.log(1-e)/t},mean:function(e){return 1/e},median:function(e){return 1/e*i.log(2)},mode:function(){return 0},sample:function(t){return -1/t*i.log(e._random_fn())},variance:function(e){return i.pow(e,-2)}}),e.extend(e.gamma,{pdf:function(t,n,r){return t<0?0:0===t&&1===n?1/r:i.exp((n-1)*i.log(t)-t/r-e.gammaln(n)-n*i.log(r))},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(t,n,r){return t<=0?0:i.exp(-(n+1)*i.log(t)-r/t-e.gammaln(n)+n*i.log(r))},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,t,n){return 0===e&&1===t?n:1===e&&1===n?t:i.exp(i.log(t)+i.log(n)+(t-1)*i.log(e)+(n-1)*i.log(1-i.pow(e,t)))},cdf:function(e,t,n){return e<0?0:e>1?1:1-i.pow(1-i.pow(e,t),n)},inv:function(e,t,n){return i.pow(1-i.pow(1-e,1/n),1/t)},mean:function(t,n){return n*e.gammafn(1+1/t)*e.gammafn(n)/e.gammafn(1+1/t+n)},median:function(e,t){return i.pow(1-i.pow(2,-1/t),1/e)},mode:function(e,t){if(e>=1&&t>=1&&1!==e&&1!==t)return i.pow((e-1)/(e*t-1),1/e)},variance:function(){throw Error("variance not yet implemented")}}),e.extend(e.lognormal,{pdf:function(e,t,n){return e<=0?0:i.exp(-i.log(e)-.5*i.log(2*i.PI)-i.log(n)-i.pow(i.log(e)-t,2)/(2*n*n))},cdf:function(t,n,r){return t<0?0:.5+.5*e.erf((i.log(t)-n)/i.sqrt(2*r*r))},inv:function(t,n,r){return i.exp(-1.4142135623730951*r*e.erfcinv(2*t)+n)},mean:function(e,t){return i.exp(e+t*t/2)},median:function(e){return i.exp(e)},mode:function(e,t){return i.exp(e-t*t)},sample:function(t,n){return i.exp(e.randn()*n+t)},variance:function(e,t){return(i.exp(t*t)-1)*i.exp(2*e+t*t)}}),e.extend(e.noncentralt,{pdf:function(t,n,r){return 1e-14>i.abs(r)?e.studentt.pdf(t,n):1e-14>i.abs(t)?i.exp(e.gammaln((n+1)/2)-r*r/2-.5*i.log(i.PI*n)-e.gammaln(n/2)):n/t*(e.noncentralt.cdf(t*i.sqrt(1+2/n),n+2,r)-e.noncentralt.cdf(t,n,r))},cdf:function(t,n,r){if(1e-14>i.abs(r))return e.studentt.cdf(t,n);var o=!1;t<0&&(o=!0,r=-r);for(var l=e.normal.cdf(-r,0,1),a=1e-14+1,u=1e-14+1,s=t*t/(t*t+n),c=0,f=i.exp(-r*r/2),d=i.exp(-r*r/2-.5*i.log(2)-e.gammaln(1.5))*r;c<200||u>1e-14||a>1e-14;)u=a,c>0&&(f*=r*r/(2*c),d*=r*r/(2*(c+.5))),l+=.5*(a=f*e.beta.cdf(s,c+.5,n/2)+d*e.beta.cdf(s,c+1,n/2)),c++;return o?1-l:l}}),e.extend(e.normal,{pdf:function(e,t,n){return i.exp(-.5*i.log(2*i.PI)-i.log(n)-i.pow(e-t,2)/(2*n*n))},cdf:function(t,n,r){return .5*(1+e.erf((t-n)/i.sqrt(2*r*r)))},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,t,n){return e<t?0:n*i.pow(t,n)/i.pow(e,n+1)},cdf:function(e,t,n){return e<t?0:1-i.pow(t/e,n)},inv:function(e,t,n){return t/i.pow(1-e,1/n)},mean:function(e,t){if(!(t<=1))return t*i.pow(e,t)/(t-1)},median:function(e,t){return e*(t*i.SQRT2)},mode:function(e){return e},variance:function(e,t){if(!(t<=2))return e*e*t/(i.pow(t-1,2)*(t-2))}}),e.extend(e.studentt,{pdf:function(t,n){return n=n>1e100?1e100:n,1/(i.sqrt(n)*e.betafn(.5,n/2))*i.pow(1+t*t/n,-((n+1)/2))},cdf:function(t,n){var r=n/2;return e.ibeta((t+i.sqrt(t*t+n))/(2*i.sqrt(t*t+n)),r,r)},inv:function(t,n){var r=e.ibetainv(2*i.min(t,1-t),.5*n,.5);return r=i.sqrt(n*(1-r)/r),t>.5?r:-r},mean:function(e){return e>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(t){return e.randn()*i.sqrt(t/(2*e.randg(t/2)))},variance:function(e){return e>2?e/(e-2):e>1?1/0:void 0}}),e.extend(e.weibull,{pdf:function(e,t,n){return e<0||t<0||n<0?0:n/t*i.pow(e/t,n-1)*i.exp(-i.pow(e/t,n))},cdf:function(e,t,n){return e<0?0:1-i.exp(-i.pow(e/t,n))},inv:function(e,t,n){return t*i.pow(-i.log(1-e),1/n)},mean:function(t,n){return t*e.gammafn(1+1/n)},median:function(e,t){return e*i.pow(i.log(2),1/t)},mode:function(e,t){return t<=1?0:e*i.pow((t-1)/t,1/t)},sample:function(t,n){return t*i.pow(-i.log(e._random_fn()),1/n)},variance:function(t,n){return t*t*e.gammafn(1+2/n)-i.pow(e.weibull.mean(t,n),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 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,t){return i.pow(t-e,2)/12}}),e.extend(e.binomial,{pdf:function(t,n,r){return 0===r||1===r?+(n*r===t):e.combination(n,t)*i.pow(r,t)*i.pow(1-r,n-t)},cdf:function(t,n,r){if(t<0)return 0;if(t>=n)return 1;if(r<0||r>1||n<=0)return NaN;var o,l=(t=i.floor(t))+1,a=n-t,u=l+a,c=i.exp(e.gammaln(u)-e.gammaln(a)-e.gammaln(l)+l*i.log(r)+a*i.log(1-r));return o=r<(l+1)/(u+2)?c*s(r,l,a,1e-10):1-c*s(1-r,a,l,1e-10),i.round(1e10*(1-o))/1e10}}),e.extend(e.negbin,{pdf:function(t,n,r){return t===t>>>0&&(t<0?0:e.combination(t+n-1,n-1)*i.pow(1-r,t)*i.pow(r,n))},cdf:function(t,n,r){var o=0,l=0;if(t<0)return 0;for(;l<=t;l++)o+=e.negbin.pdf(l,n,r);return o}}),e.extend(e.hypgeom,{pdf:function(t,n,r,o){if(t!=t|0)return!1;if(t<0||t<r-(n-o))return 0;if(t>o||t>r)return 0;if(2*r>n)if(2*o>n)return e.hypgeom.pdf(n-r-o+t,n,n-r,n-o);else return e.hypgeom.pdf(o-t,n,n-r,o);if(2*o>n)return e.hypgeom.pdf(r-t,n,r,n-o);if(r<o)return e.hypgeom.pdf(t,n,o,r);for(var l=1,a=0,u=0;u<t;u++){for(;l>1&&a<o;)l*=1-r/(n-a),a++;l*=(o-u)*(r-u)/((u+1)*(n-r-o+u+1))}for(;a<o;a++)l*=1-r/(n-a);return i.min(1,i.max(0,l))},cdf:function(t,n,r,o){if(t<0||t<r-(n-o))return 0;if(t>=o||t>=r)return 1;if(2*r>n)if(2*o>n)return e.hypgeom.cdf(n-r-o+t,n,n-r,n-o);else return 1-e.hypgeom.cdf(o-t-1,n,n-r,o);if(2*o>n)return 1-e.hypgeom.cdf(r-t-1,n,r,n-o);if(r<o)return e.hypgeom.cdf(t,n,o,r);for(var l=1,a=1,u=0,s=0;s<t;s++){for(;l>1&&u<o;){var c=1-r/(n-u);a*=c,l*=c,u++}a*=(o-s)*(r-s)/((s+1)*(n-r-o+s+1)),l+=a}for(;u<o;u++)l*=1-r/(n-u);return i.min(1,i.max(0,l))}}),e.extend(e.poisson,{pdf:function(t,n){return n<0||t%1!=0||t<0?0:i.pow(n,t)*i.exp(-n)/e.factorial(t)},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(t){var n=1,r=0,o=i.exp(-t);do r++,n*=e._random_fn();while(n>o);return r-1},sampleLarge:function(t){var n,r,o,l,a,u,s,c,f,d;for(l=i.sqrt(t),a=i.log(t),u=-.059+.02483*(s=.931+2.53*l),c=1.1239+1.1328/(s-3.4),f=.9277-3.6224/(s-2);;){if(r=i.random()-.5,o=i.random(),d=.5-i.abs(r),n=i.floor((2*u/d+s)*r+t+.43),d>=.07&&o<=f)return n;if(!(n<0)&&(!(d<.013)||!(o>d))&&i.log(o)+i.log(c)-i.log(u/(d*d)+s)<=-t+n*a-e.loggam(n+1))return n}},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,t,n,r){return n<=t||r<t||r>n?NaN:e<=t?0:e>=n?1:e<=r?i.pow(e-t,2)/((n-t)*(r-t)):1-i.pow(n-e,2)/((n-t)*(n-r))},inv:function(e,t,n,r){return n<=t||r<t||r>n?NaN:e<=(r-t)/(n-t)?t+(n-t)*i.sqrt((r-t)/(n-t)*e):t+(n-t)*(1-i.sqrt((1-e)*(1-(r-t)/(n-t))))},mean:function(e,t,n){return(e+t+n)/3},median:function(e,t,n){return n<=(e+t)/2?t-i.sqrt((t-e)*(t-n))/i.sqrt(2):n>(e+t)/2?e+i.sqrt((t-e)*(n-e))/i.sqrt(2):void 0},mode:function(e,t,n){return n},sample:function(t,n,r){var o=e._random_fn();return o<(r-t)/(n-t)?t+i.sqrt(o*(n-t)*(r-t)):n-i.sqrt((1-o)*(n-t)*(n-r))},variance:function(e,t,n){return(e*e+t*t+n*n-e*t-e*n-t*n)/18}}),e.extend(e.arcsine,{pdf:function(e,t,n){return n<=t?NaN:e<=t||e>=n?0:2/i.PI*i.pow(i.pow(n-t,2)-i.pow(2*e-t-n,2),-.5)},cdf:function(e,t,n){return e<t?0:e<n?2/i.PI*i.asin(i.sqrt((e-t)/(n-t))):1},inv:function(e,t,n){return t+(.5-.5*i.cos(i.PI*e))*(n-t)},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 Error("mode is not yet implemented")},sample:function(t,n){return(t+n)/2+(n-t)/2*i.sin(2*i.PI*e.uniform.sample(0,1))},variance:function(e,t){return t<=e?NaN:i.pow(t-e,2)/8}}),e.extend(e.laplace,{pdf:function(e,t,n){return n<=0?0:i.exp(-i.abs(e-t)/n)/(2*n)},cdf:function(e,t,n){return n<=0?0:e<t?.5*i.exp((e-t)/n):1-.5*i.exp(-(e-t)/n)},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(t,n){var r=e._random_fn()-.5;return t-n*(r/i.abs(r))*i.log(1-2*i.abs(r))}}),e.extend(e.tukey,{cdf:function(t,n,r){var o=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],l=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(t<=0)return 0;if(r<2||n<2)return NaN;if(!Number.isFinite(t))return 1;if(r>25e3)return c(t,1,n);var a=.5*r,u=a*i.log(r)-r*i.log(2)-e.gammaln(a),s=a-1,f=.25*r;p=r<=100?1:r<=800?.5:r<=5e3?.25:.125,u+=i.log(p);for(var d=0,m=1;m<=50;m++){for(var p,h,g,v=0,y=(2*m-1)*p,C=1;C<=16;C++)if(8<C?(h=C-8-1,g=u+s*i.log(y+o[h]*p)-(o[h]*p+y)*f):(h=C-1,g=u+s*i.log(y-o[h]*p)+(o[h]*p-y)*f),g>=-30){v+=c(8<C?t*i.sqrt((o[h]*p+y)*.5):t*i.sqrt((-(o[h]*p)+y)*.5),1,n)*l[h]*i.exp(g)}if(m*p>=1&&v<=1e-14)break;d+=v}if(v>1e-14)throw Error("tukey.cdf failed to converge");return d>1&&(d=1),d},inv:function(t,n,r){if(r<2||n<2||t<0||t>1)return NaN;if(0===t)return 0;if(1===t)return 1/0;var o,l,a,u,s,c,f=(a=.5-.5*t,s=(u=i.sqrt(i.log(1/(a*a))))+((((-453642210148e-16*u+-.204231210125)*u+-.342242088547)*u+-1)*u+.322232421088)/((((.0038560700634*u+.10353775285)*u+.531103462366)*u+.588581570495)*u+.099348462606),r<120&&(s+=(s*s*s+s)/r/4),c=.8832-.2368*s,r<120&&(c+=-1.214/r+1.208*s/r),s*(c*i.log(n-1)+1.4142)),d=e.tukey.cdf(f,n,r)-t;o=d>0?i.max(0,f-1):f+1;for(var m=e.tukey.cdf(o,n,r)-t,p=1;p<50;p++)if(l=o-m*(o-f)/(m-d),d=m,f=o,l<0&&(l=0,m=-t),m=e.tukey.cdf(l,n,r)-t,o=l,1e-4>i.abs(o-f))return l;throw Error("tukey.inv failed to converge")}}),function(e,t){var n,r,o=Array.prototype.push,l=e.utils.isArray;function i(t){return l(t)||t instanceof e}e.extend({add:function(t,n){return i(n)?(i(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 i(n)?(i(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 i(n)?(i(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,l,a,u,s,c,f;if(void 0===t.length&&void 0===n.length)return t*n;if(u=t.length,s=t[0].length,c=e.zeros(u,l=i(n)?n[0].length:s),f=0,i(n)){for(;f<l;f++)for(r=0;r<u;r++){for(o=0,a=0;o<s;o++)a+=t[r][o]*n[o][f];c[r][f]=a}return 1===u&&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){i(t[0])||(t=[t]),i(n[0])||(n=[n]);for(var r,o,l=1===t[0].length&&1!==t.length?e.transpose(t):t,a=1===n[0].length&&1!==n.length?e.transpose(n):n,u=[],s=0,c=l.length,f=l[0].length;s<c;s++){for(o=0,u[s]=[],r=0;o<f;o++)r+=l[s][o]*a[s][o];u[s]=r}return 1===u.length?u[0]:u},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),i(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,l=e.identity(r,o),i=e.gauss_jordan(t,l),a=[],u=0;u<r;u++)for(a[u]=[],n=o;n<i[0].length;n++)a[u][n-o]=i[u][n];return a},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=[],l=1;l<t.length;l++){o[l-1]=[];for(var i=0;i<t.length;i++)i<r?o[l-1][i]=t[l][i]:i>r&&(o[l-1][i-1]=t[l][i])}var a=r%2?-1:1;n+=e(o)*t[0][r]*a}return n},gauss_elimination:function(n,r){var o,l,i,a,u=0,s=0,c=n.length,f=n[0].length,d=1,m=0,p=[];for(u=0,o=(n=e.aug(n,r))[0].length;u<c;u++){for(l=n[u][u],s=u,a=u+1;a<f;a++)l<t.abs(n[a][u])&&(l=n[a][u],s=a);if(s!=u)for(a=0;a<o;a++)i=n[u][a],n[u][a]=n[s][a],n[s][a]=i;for(s=u+1;s<c;s++)for(d=n[s][u]/n[u][u],a=u;a<o;a++)n[s][a]=n[s][a]-d*n[u][a]}for(u=c-1;u>=0;u--){for(m=0,s=u+1;s<=c-1;s++)m+=p[s]*n[u][s];p[u]=(n[u][o-1]-m)/n[u][u]}return p},gauss_jordan:function(n,r){var o,l,i,a=e.aug(n,r),u=a.length,s=a[0].length,c=0;for(l=0;l<u;l++){var f=l;for(i=l+1;i<u;i++)t.abs(a[i][l])>t.abs(a[f][l])&&(f=i);var d=a[l];for(a[l]=a[f],a[f]=d,i=l+1;i<u;i++)for(c=a[i][l]/a[l][l],o=l;o<s;o++)a[i][o]-=a[l][o]*c}for(l=u-1;l>=0;l--){for(i=0,c=a[l][l];i<l;i++)for(o=s-1;o>l-1;o--)a[i][o]-=a[l][o]*a[i][l]/c;for(a[l][l]/=c,o=u;o<s;o++)a[l][o]/=c}return a},triaUpSolve:function(t,n){var r,o=t[0].length,l=e.zeros(1,o)[0],i=!1;return(void 0!=n[0].length&&(n=n.map(function(e){return e[0]}),i=!0),e.arange(o-1,-1,-1).forEach(function(i){r=e.arange(i+1,o).map(function(e){return l[e]*t[i][e]}),l[i]=(n[i]-e.sum(r))/t[i][i]}),i)?l.map(function(e){return[e]}):l},triaLowSolve:function(t,n){var r,o=t[0].length,l=e.zeros(1,o)[0],i=!1;return(void 0!=n[0].length&&(n=n.map(function(e){return e[0]}),i=!0),e.arange(o).forEach(function(o){r=e.arange(o).map(function(e){return t[o][e]*l[e]}),l[o]=(n[o]-e.sum(r))/t[o][o]}),i)?l.map(function(e){return[e]}):l},lu:function(t){var n,r=t.length,o=e.identity(r),l=e.zeros(t.length,t[0].length);return e.arange(r).forEach(function(e){l[0][e]=t[0][e]}),e.arange(1,r).forEach(function(i){e.arange(i).forEach(function(r){n=e.arange(r).map(function(e){return o[i][e]*l[e][r]}),o[i][r]=(t[i][r]-e.sum(n))/l[r][r]}),e.arange(i,r).forEach(function(r){n=e.arange(i).map(function(e){return o[i][e]*l[e][r]}),l[i][r]=t[n.length][r]-e.sum(n)})}),[o,l]},cholesky:function(n){var r,o=n.length,l=e.zeros(n.length,n[0].length);return e.arange(o).forEach(function(i){r=e.arange(i).map(function(e){return t.pow(l[i][e],2)}),l[i][i]=t.sqrt(n[i][i]-e.sum(r)),e.arange(i+1,o).forEach(function(t){r=e.arange(i).map(function(e){return l[i][e]*l[t][e]}),l[t][i]=(n[i][t]-e.sum(r))/l[i][i]})}),l},gauss_jacobi:function(n,r,o,l){for(var i,a,u,s,c=0,f=0,d=n.length,m=[],p=[],h=[];c<d;c++)for(f=0,m[c]=[],p[c]=[],h[c]=[];f<d;f++)c>f?(m[c][f]=n[c][f],p[c][f]=h[c][f]=0):c<f?(p[c][f]=n[c][f],m[c][f]=h[c][f]=0):(h[c][f]=n[c][f],m[c][f]=p[c][f]=0);for(u=e.multiply(e.multiply(e.inv(h),e.add(m,p)),-1),a=e.multiply(e.inv(h),r),i=o,s=e.add(e.multiply(u,o),a),c=2;t.abs(e.norm(e.subtract(s,i)))>l;)i=s,s=e.add(e.multiply(u,i),a),c++;return s},gauss_seidel:function(n,r,o,l){for(var i,a,u,s,c,f=0,d=n.length,m=[],p=[],h=[];f<d;f++)for(i=0,m[f]=[],p[f]=[],h[f]=[];i<d;i++)f>i?(m[f][i]=n[f][i],p[f][i]=h[f][i]=0):f<i?(p[f][i]=n[f][i],m[f][i]=h[f][i]=0):(h[f][i]=n[f][i],m[f][i]=p[f][i]=0);for(s=e.multiply(e.multiply(e.inv(e.add(h,m)),p),-1),u=e.multiply(e.inv(e.add(h,m)),r),a=o,c=e.add(e.multiply(s,o),u),f=2;t.abs(e.norm(e.subtract(c,a)))>l;)a=c,c=e.add(e.multiply(s,a),u),f+=1;return c},SOR:function(n,r,o,l,i){for(var a,u,s,c,f,d=0,m=n.length,p=[],h=[],g=[];d<m;d++)for(a=0,p[d]=[],h[d]=[],g[d]=[];a<m;a++)d>a?(p[d][a]=n[d][a],h[d][a]=g[d][a]=0):d<a?(h[d][a]=n[d][a],p[d][a]=g[d][a]=0):(g[d][a]=n[d][a],p[d][a]=h[d][a]=0);for(c=e.multiply(e.inv(e.add(g,e.multiply(p,i))),e.subtract(e.multiply(g,1-i),e.multiply(h,i))),s=e.multiply(e.multiply(e.inv(e.add(g,e.multiply(p,i))),r),i),u=o,f=e.add(e.multiply(c,o),s),d=2;t.abs(e.norm(e.subtract(f,u)))>l;)u=f,f=e.add(e.multiply(c,u),s),d++;return f},householder:function(n){for(var r,o,l,i,a=n.length,u=n[0].length,s=0,c=[],f=[];s<a-1;s++){for(r=0,i=s+1;i<u;i++)r+=n[i][s]*n[i][s];for(r=(n[s+1][s]>0?-1:1)*t.sqrt(r),o=t.sqrt((r*r-n[s+1][s]*r)/2),(c=e.zeros(a,1))[s+1][0]=(n[s+1][s]-r)/(2*o),l=s+2;l<a;l++)c[l][0]=n[l][s]/(2*o);f=e.subtract(e.identity(a,u),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 l,i,a,u=o.length,s=o[0].length,c=e.zeros(s,s);for(i=0,o=e.copy(o);i<s;i++){for(l=0,c[i][i]=t.sqrt(n(r(u).map(function(e){return o[e][i]*o[e][i]})));l<u;l++)o[l][i]=o[l][i]/c[i][i];for(a=i+1;a<s;a++)for(l=0,c[i][a]=n(r(u).map(function(e){return o[e][i]*o[e][a]}));l<u;l++)o[l][a]=o[l][a]-o[l][i]*c[i][a]}return[o,c]}),lstsq:function(t,n){var r,o,l,i=!1;void 0===n[0].length&&(n=n.map(function(e){return[e]}),i=!0);var a=e.QR(t),u=a[0],s=a[1],c=t[0].length,f=e.slice(u,{col:{end:c}}),d=(r=e.slice(s,{row:{end:c}}),o=(r=e.copy(r)).length,l=e.identity(o),e.arange(o-1,-1,-1).forEach(function(t){e.sliceAssign(l,{row:t},e.divide(e.slice(l,{row:t}),r[t][t])),e.sliceAssign(r,{row:t},e.divide(e.slice(r,{row:t}),r[t][t])),e.arange(t).forEach(function(n){var o=e.multiply(r[n][t],-1),i=e.slice(r,{row:n}),a=e.multiply(e.slice(r,{row:t}),o);e.sliceAssign(r,{row:n},e.add(i,a));var u=e.slice(l,{row:n}),s=e.multiply(e.slice(l,{row:t}),o);e.sliceAssign(l,{row:n},e.add(u,s))})}),l),m=e.transpose(f);void 0===m[0].length&&(m=[m]);var p=e.multiply(e.multiply(d,m),n);return(void 0===p.length&&(p=[[p]]),i)?p.map(function(e){return e[0]}):p},jacobi:function(n){for(var r,o,l,i,a,u,s,c=1,f=n.length,d=e.identity(f,f),m=[];1===c;){for(r=0,a=n[0][1],l=0,i=1;r<f;r++)for(o=0;o<f;o++)r!=o&&a<t.abs(n[r][o])&&(a=t.abs(n[r][o]),l=r,i=o);for(r=1,u=n[l][l]===n[i][i]?n[l][i]>0?t.PI/4:-t.PI/4:t.atan(2*n[l][i]/(n[l][l]-n[i][i]))/2,(s=e.identity(f,f))[l][l]=t.cos(u),s[l][i]=-t.sin(u),s[i][l]=t.sin(u),s[i][i]=t.cos(u),d=e.multiply(d,s),n=e.multiply(e.multiply(e.inv(s),n),s),c=0;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++)m.push(n[r][r]);return[d,m]},rungekutta:function(e,t,n,r,o,l){var i,a,u,s;if(2===l)for(;r<=n;)i=t*e(r,o),a=t*e(r+t,o+i),o+=(i+a)/2,r+=t;if(4===l)for(;r<=n;)i=t*e(r,o),a=t*e(r+t/2,o+i/2),u=t*e(r+t/2,o+a/2),s=t*e(r+t,o+u),o+=(i+2*a+2*u+s)/6,r+=t;return o},romberg:function(e,n,r,o){for(var l,i,a,u,s,c=0,f=(r-n)/2,d=[],m=[],p=[];c<o/2;){for(s=e(n),a=n,u=0;a<=r;a+=f,u++)d[u]=a;for(a=1,l=d.length;a<l-1;a++)s+=(a%2!=0?4:2)*e(d[a]);s=f/3*(s+e(r)),p[c]=s,f/=2,c++}for(i=p.length,l=1;1!==i;){for(a=0;a<i-1;a++)m[a]=(t.pow(4,l)*p[a+1]-p[a])/(t.pow(4,l)-1);i=m.length,p=m,m=[],l++}return p},richardson:function(e,n,r,o){function l(e,t){for(var n,r=0,o=e.length;r<o;r++)e[r]===t&&(n=r);return n}for(var i,a,u,s,c,f=t.abs(r-e[l(e,r)+1]),d=0,m=[],p=[];o>=f;)i=l(e,r+o),a=l(e,r),m[d]=(n[i]-2*n[a]+n[2*a-i])/(o*o),o/=2,d++;for(s=m.length,u=1;1!=s;){for(c=0;c<s-1;c++)p[c]=(t.pow(4,u)*m[c+1]-m[c])/(t.pow(4,u)-1);s=p.length,m=p,p=[],u++}return m},simpson:function(e,t,n,r){for(var o,l=(n-t)/r,i=e(t),a=[],u=t,s=0,c=1;u<=n;u+=l,s++)a[s]=u;for(o=a.length;c<o-1;c++)i+=(c%2!=0?4:2)*e(a[c]);return l/3*(i+e(n))},hermite:function(e,t,n,r){for(var o,l=e.length,i=0,a=0,u=[],s=[],c=[],f=[];a<l;a++){for(o=0,u[a]=1;o<l;o++)a!=o&&(u[a]*=(r-e[o])/(e[a]-e[o]));for(o=0,s[a]=0;o<l;o++)a!=o&&(s[a]+=1/(e[a]-e[o]));c[a]=(1-2*(r-e[a])*s[a])*(u[a]*u[a]),f[a]=(r-e[a])*(u[a]*u[a]),i+=c[a]*t[a]+f[a]*n[a]}return i},lagrange:function(e,t,n){for(var r,o,l=0,i=0,a=e.length;i<a;i++){for(r=0,o=t[i];r<a;r++)i!=r&&(o*=(n-e[r])/(e[i]-e[r]));l+=o}return l},cubic_spline:function(t,n,r){for(var o,l=t.length,i=0,a=[],u=[],s=[],c=[],f=[],d=[],m=[];i<l-1;i++)f[i]=t[i+1]-t[i];for(i=1,s[0]=0;i<l-1;i++)s[i]=3/f[i]*(n[i+1]-n[i])-3/f[i-1]*(n[i]-n[i-1]);for(i=1;i<l-1;i++)a[i]=[],u[i]=[],a[i][i-1]=f[i-1],a[i][i]=2*(f[i-1]+f[i]),a[i][i+1]=f[i],u[i][0]=s[i];for(o=0,c=e.multiply(e.inv(a),u);o<l-1;o++)d[o]=(n[o+1]-n[o])/f[o]-f[o]*(c[o+1][0]+2*c[o][0])/3,m[o]=(c[o+1][0]-c[o][0])/(3*f[o]);for(o=0;o<l&&!(t[o]>r);o++);return n[o-=1]+(r-t[o])*d[o]+e.sq(r-t[o])*c[o]+(r-t[o])*e.sq(r-t[o])*m[o]},gauss_quadrature:function(){throw Error("gauss_quadrature not yet implemented")},PCA:function(t){var n,r,o=t.length,l=t[0].length,i=0,a=[],u=[],s=[],c=[],f=[],d=[],m=[],p=[],h=[],g=[];for(i=0;i<o;i++)a[i]=e.sum(t[i])/l;for(i=0;i<l;i++)for(n=0,m[i]=[];n<o;n++)m[i][n]=t[n][i]-a[n];for(i=0,m=e.transpose(m);i<o;i++)for(n=0,p[i]=[];n<o;n++)p[i][n]=e.dot([m[i]],[m[n]])/(l-1);for(i=0,h=(s=e.jacobi(p))[0],u=s[1],g=e.transpose(h);i<u.length;i++)for(n=i;n<u.length;n++)u[i]<u[n]&&(r=u[i],u[i]=u[n],u[n]=r,c=g[i],g[i]=g[n],g[n]=c);for(i=0,d=e.transpose(m);i<o;i++)for(n=0,f[i]=[];n<d.length;n++)f[i][n]=e.dot([g[i]],[d[n]]);return[t,u,g,f]}});for(var a="add divide multiply subtract dot pow exp log abs norm angle".split(" "),u=0;u<a.length;u++)!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))}}(a[u])}(e,Math);var f=Math,d=[].slice,m=e.utils.isNumber,p=e.utils.isArray;function h(e,t,n,r){if(e>1||n>1||e<=0||n<=0)throw Error("Proportions should be greater than 0 and less than 1");var o=(e*t+n*r)/(t+r);return(e-n)/f.sqrt(o*(1-o)*(1/t+1/r))}return e.extend({zscore:function(){var t=d.call(arguments);return m(t[1])?(t[0]-t[1])/t[2]:(t[0]-e.mean(t[1]))/e.stdev(t[1],t[2])},ztest:function(){var t,n=d.call(arguments);return p(n[1])?(t=e.zscore(n[0],n[1],n[3]),1===n[2]?e.normal.cdf(-f.abs(t),0,1):2*e.normal.cdf(-f.abs(t),0,1)):n.length>2?(t=e.zscore(n[0],n[1],n[2]),1===n[3]?e.normal.cdf(-f.abs(t),0,1):2*e.normal.cdf(-f.abs(t),0,1)):(t=n[0],1===n[1]?e.normal.cdf(-f.abs(t),0,1):2*e.normal.cdf(-f.abs(t),0,1))}}),e.extend(e.fn,{zscore:function(e,t){return(e-this.mean())/this.stdev(t)},ztest:function(t,n,r){var o=f.abs(this.zscore(t,r));return 1===n?e.normal.cdf(-o,0,1):2*e.normal.cdf(-o,0,1)}}),e.extend({tscore:function(){var t=d.call(arguments);return 4===t.length?(t[0]-t[1])/(t[2]/f.sqrt(t[3])):(t[0]-e.mean(t[1]))/(e.stdev(t[1],!0)/f.sqrt(t[1].length))},ttest:function(){var t,n=d.call(arguments);return 5===n.length?(t=f.abs(e.tscore(n[0],n[1],n[2],n[3])),1===n[4]?e.studentt.cdf(-t,n[3]-1):2*e.studentt.cdf(-t,n[3]-1)):m(n[1])?(t=f.abs(n[0]),1==n[2]?e.studentt.cdf(-t,n[1]-1):2*e.studentt.cdf(-t,n[1]-1)):(t=f.abs(e.tscore(n[0],n[1])),1==n[2]?e.studentt.cdf(-t,n[1].length-1):2*e.studentt.cdf(-t,n[1].length-1))}}),e.extend(e.fn,{tscore:function(e){return(e-this.mean())/(this.stdev(!0)/f.sqrt(this.cols()))},ttest:function(t,n){return 1===n?1-e.studentt.cdf(f.abs(this.tscore(t)),this.cols()-1):2*e.studentt.cdf(-f.abs(this.tscore(t)),this.cols()-1)}}),e.extend({anovafscore:function(){var t,n,r,o,l,i,a,u,s=d.call(arguments);if(1===s.length){for(a=0,l=Array(s[0].length);a<s[0].length;a++)l[a]=s[0][a];s=l}for(a=0,n=[];a<s.length;a++)n=n.concat(s[a]);for(a=0,r=e.mean(n),t=0;a<s.length;a++)t+=s[a].length*f.pow(e.mean(s[a])-r,2);for(t/=s.length-1,i=0,a=0;a<s.length;a++)for(u=0,o=e.mean(s[a]);u<s[a].length;u++)i+=f.pow(s[a][u]-o,2);return t/(i/=n.length-s.length)},anovaftest:function(){var t,n,r,o,l=d.call(arguments);if(m(l[0]))return 1-e.centralF.cdf(l[0],l[1],l[2]);var i=e.anovafscore(l);for(o=0,t=l.length-1,r=0;o<l.length;o++)r+=l[o].length;return n=r-t-1,1-e.centralF.cdf(i,t,n)},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 t,n,r,o,l,i=d.call(arguments);return m(i[0])?(t=i[0],n=i[1],r=i[2],o=i[3],l=i[4]):(t=e.mean(i[0]),n=e.mean(i[1]),r=i[0].length,o=i[1].length,l=i[2]),f.abs(t-n)/(l*f.sqrt((1/r+1/o)/2))},qtest:function(){var t,n=d.call(arguments);3===n.length?(t=n[0],n=n.slice(1)):7===n.length?(t=e.qscore(n[0],n[1],n[2],n[3],n[4]),n=n.slice(5)):(t=e.qscore(n[0],n[1],n[2]),n=n.slice(3));var r=n[0],o=n[1];return 1-e.tukey.cdf(t,o,r-o)},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),l=[],i=0;i<t.length;++i)for(var a=i+1;a<t.length;++a){var u=e.qtest(r[i],r[a],t[i].length,t[a].length,n,o,t.length);l.push([[i,a],u])}return l}}),e.extend({normalci:function(){var t,n=d.call(arguments),r=[,,];return t=4===n.length?f.abs(e.normal.inv(n[1]/2,0,1)*n[2]/f.sqrt(n[3])):f.abs(e.normal.inv(n[1]/2,0,1)*e.stdev(n[2])/f.sqrt(n[2].length)),r[0]=n[0]-t,r[1]=n[0]+t,r},tci:function(){var t,n=d.call(arguments),r=[,,];return t=4===n.length?f.abs(e.studentt.inv(n[1]/2,n[3]-1)*n[2]/f.sqrt(n[3])):f.abs(e.studentt.inv(n[1]/2,n[2].length-1)*e.stdev(n[2],!0)/f.sqrt(n[2].length)),r[0]=n[0]-t,r[1]=n[0]+t,r},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 l=h(t,n,r,o);return e.ztest(l,1)},twoSidedDifferenceOfProportions:function(t,n,r,o){var l=h(t,n,r,o);return e.ztest(l,2)}}),e.models=function(){function t(t,n){var r=t.length,o=n[0].length-1,l=e.lstsq(n,t),i=e.multiply(n,l.map(function(e){return[e]})).map(function(e){return e[0]}),a=e.subtract(t,i),u=e.mean(t),s=e.sum(i.map(function(e){return Math.pow(e-u,2)})),c=e.sum(t.map(function(e,t){return Math.pow(e-i[t],2)})),f=s+c;return{exog:n,endog:t,nobs:r,df_model:o,df_resid:r-o-1,coef:l,predict:i,resid:a,ybar:u,SST:f,SSE:s,SSR:c,R2:s/f}}return{ols:function(n,r){var o,l,i,a,u,s,c,f,d,m,p,h,g,v,y=t(n,r),C=(l=(o=y.exog)[0].length,i=e.arange(l).map(function(n){var r=e.arange(l).filter(function(e){return e!==n});return t(e.col(o,n).map(function(e){return e[0]}),e.col(o,r))}),a=Math.sqrt(y.SSR/y.df_resid),u=i.map(function(e){return a/Math.sqrt(e.SST*(1-e.R2))}),c=(s=y.coef.map(function(e,t){return(e-0)/u[t]})).map(function(t){var n=e.studentt.cdf(t,y.df_resid);return(n>.5?1-n:n)*2}),f=e.studentt.inv(.975,y.df_resid),d=y.coef.map(function(e,t){var n=f*u[t];return[e-n,e+n]}),{se:u,t:s,p:c,sigmaHat:a,interval95:d}),b=(v=1-(p=m=y.R2/y.df_model/((1-y.R2)/y.df_resid),h=y.df_model,g=y.df_resid,e.beta.cdf(p/(g/h+p),h/2,g/2)),{F_statistic:m,pvalue:v}),x=1-(1-y.R2)*((y.nobs-1)/y.df_resid);return y.t=C,y.f=b,y.adjust_R2=x,y}}}(),e.extend({buildxmatrix:function(){for(var t=Array(arguments.length),n=0;n<arguments.length;n++){var r=[1];t[n]=r.concat(arguments[n])}return e(t)},builddxmatrix:function(){for(var t=Array(arguments[0].length),n=0;n<arguments[0].length;n++){var r=[1];t[n]=r.concat(arguments[0][n])}return e(t)},buildjxmatrix:function(t){for(var n=Array(t.length),r=0;r<t.length;r++)n[r]=t[r];return e.builddxmatrix(n)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(e){return e.transpose()},matrixmult:function(t,n){var r,o,l,i,a;if(t.cols()==n.rows()){if(n.rows()>1){for(r=0,i=[];r<t.rows();r++)for(o=0,i[r]=[];o<n.cols();o++){for(l=0,a=0;l<t.cols();l++)a+=t.toArray()[r][l]*n.toArray()[l][o];i[r][o]=a}return e(i)}for(r=0,i=[];r<t.rows();r++)for(o=0,i[r]=[];o<n.cols();o++){for(l=0,a=0;l<t.cols();l++)a+=t.toArray()[r][l]*n.toArray()[o];i[r][o]=a}return e(i)}},regress:function(t,n){var r=e.xtranspxinv(t),o=t.transpose(),l=e.matrixmult(e(r),o);return e.matrixmult(l,n)},regresst:function(t,n,r){var o,l,i,a=e.regress(t,n),u={};u.anova={};var s=e.jMatYBar(t,a);u.yBar=s;var c=n.mean();u.anova.residuals=e.residuals(n,s),u.anova.ssr=e.ssr(s,c),u.anova.msr=u.anova.ssr/(t[0].length-1),u.anova.sse=e.sse(n,s),u.anova.mse=u.anova.sse/(n.length-(t[0].length-1)-1),u.anova.sst=e.sst(n,c),u.anova.mst=u.anova.sst/(n.length-1),u.anova.r2=1-u.anova.sse/u.anova.sst,u.anova.r2<0&&(u.anova.r2=0),u.anova.fratio=u.anova.msr/u.anova.mse,u.anova.pvalue=e.anovaftest(u.anova.fratio,t[0].length-1,n.length-(t[0].length-1)-1),u.anova.rmse=Math.sqrt(u.anova.mse),u.anova.r2adj=1-u.anova.mse/u.anova.mst,u.anova.r2adj<0&&(u.anova.r2adj=0),u.stats=Array(t[0].length);for(var f=e.xtranspxinv(t),d=0;d<a.length;d++)o=Math.sqrt(u.anova.mse*Math.abs(f[d][d])),l=Math.abs(a[d]/o),i=e.ttest(l,n.length-t[0].length-1,r),u.stats[d]=[a[d],o,l,i];return u.regress=a,u},xtranspx:function(t){return e.matrixmult(t.transpose(),t)},xtranspxinv:function(t){var n=e.matrixmult(t.transpose(),t);return e.inv(n)},jMatYBar:function(t,n){var r=e.matrixmult(t,n);return new e(r)},residuals:function(t,n){return e.matrixsubtract(t,n)},ssr:function(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(t,n){for(var r=Array(t.length),o=0;o<t.length;o++){r[o]=Array(t[o].length);for(var l=0;l<t[o].length;l++)r[o][l]=t[o][l]-n[o][l]}return e(r)}}),e.jStat=e,e}()},296(e,t,n){var r=n(137),o=n(344),l=n(14),i=n(364),a=n(394),u=n(380),s=n(320);s.alea=r,s.xor128=o,s.xorwow=l,s.xorshift7=i,s.xor4096=a,s.tychei=u,e.exports=s},137(e,t,n){!function(e,t){function n(e){var t,n=this,r=(t=0xefc8249d,function(e){e=String(e);for(var n=0;n<e.length;n++){var r=.02519603282416938*(t+=e.charCodeAt(n));t=r>>>0,r-=t,r*=t,t=r>>>0,r-=t,t+=0x100000000*r}return(t>>>0)*23283064365386963e-26});n.next=function(){var e=2091639*n.s0+23283064365386963e-26*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)}function r(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function o(e,t){var o=new n(e),l=t&&t.state,i=o.next;return i.int32=function(){return 0x100000000*o.next()|0},i.double=function(){return i()+(2097152*i()|0)*11102230246251565e-32},i.quick=i,l&&("object"==typeof l&&r(l,o),i.state=function(){return r(o,{})}),i}e&&e.exports?e.exports=o:t&&t.amd?t(function(){return o}):this.alea=o}(e=n.nmd(e),"function"==typeof define&&define)},380(e,t,n){!function(e,t){function n(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=-0x61c88647,t.d=0x517cc1b7,e===Math.floor(e)?(t.a=e/0x100000000|0,t.b=0|e):n+=e;for(var r=0;r<n.length+20;r++)t.b^=n.charCodeAt(r),t.next()}function r(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function o(e,t){var o=new n(e),l=t&&t.state,i=function(){return(o.next()>>>0)/0x100000000};return i.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},i.int32=o.next,i.quick=i,l&&("object"==typeof l&&r(l,o),i.state=function(){return r(o,{})}),i}e&&e.exports?e.exports=o:t&&t.amd?t(function(){return o}):this.tychei=o}(e=n.nmd(e),"function"==typeof define&&define)},344(e,t,n){!function(e,t){function n(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^=n.charCodeAt(r),t.next()}function r(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function o(e,t){var o=new n(e),l=t&&t.state,i=function(){return(o.next()>>>0)/0x100000000};return i.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},i.int32=o.next,i.quick=i,l&&("object"==typeof l&&r(l,o),i.state=function(){return r(o,{})}),i}e&&e.exports?e.exports=o:t&&t.amd?t(function(){return o}):this.xor128=o}(e=n.nmd(e),"function"==typeof define&&define)},394(e,t,n){!function(e,t){function n(e){var t=this;t.next=function(){var e,n,r=t.w,o=t.X,l=t.i;return t.w=r=r+0x61c88647|0,n=o[l+34&127],e=o[l=l+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=o[l]=n^e,t.i=l,n+(r^r>>>16)|0},!function(e,t){var n,r,o,l,i,a=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),o=0,l=-32;l<u;++l)t&&(r^=t.charCodeAt((l+32)%t.length)),0===l&&(i=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,l>=0&&(i=i+0x61c88647|0,o=0==(n=a[127&l]^=r+i)?o+1:0);for(o>=128&&(a[127&(t&&t.length||0)]=-1),o=127,l=512;l>0;--l)r=a[o+34&127],n=a[o=o+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,a[o]=r^n;e.w=i,e.X=a,e.i=o}(t,e)}function r(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function o(e,t){null==e&&(e=+new Date);var o=new n(e),l=t&&t.state,i=function(){return(o.next()>>>0)/0x100000000};return i.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},i.int32=o.next,i.quick=i,l&&(l.X&&r(l,o),i.state=function(){return r(o,{})}),i}e&&e.exports?e.exports=o:t&&t.amd?t(function(){return o}):this.xor4096=o}(e=n.nmd(e),"function"==typeof define&&define)},364(e,t,n){!function(e,t){function n(e){var t=this;t.next=function(){var e,n,r=t.x,o=t.i;return e=r[o],e^=e>>>7,n=e^e<<24^((e=r[o+1&7])^e>>>10)^((e=r[o+3&7])^e>>>3)^((e=r[o+4&7])^e<<7),e=r[o+7&7],e^=e<<13,n^=e^e<<9,r[o]=n,t.i=o+1&7,n};var n,r=e,o=[];if(r===(0|r))o[0]=r;else for(n=0,r=""+r;n<r.length;++n)o[7&n]=o[7&n]<<15^r.charCodeAt(n)+o[n+1&7]<<13;for(;o.length<8;)o.push(0);for(n=0;n<8&&0===o[n];++n);for(8==n?o[7]=-1:o[n],t.x=o,t.i=0,n=256;n>0;--n)t.next()}function r(e,t){return t.x=e.x.slice(),t.i=e.i,t}function o(e,t){null==e&&(e=+new Date);var o=new n(e),l=t&&t.state,i=function(){return(o.next()>>>0)/0x100000000};return i.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},i.int32=o.next,i.quick=i,l&&(l.x&&r(l,o),i.state=function(){return r(o,{})}),i}e&&e.exports?e.exports=o:t&&t.amd?t(function(){return o}):this.xorshift7=o}(e=n.nmd(e),"function"==typeof define&&define)},14(e,t,n){!function(e,t){function n(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^=n.charCodeAt(r),r==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function r(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 o(e,t){var o=new n(e),l=t&&t.state,i=function(){return(o.next()>>>0)/0x100000000};return i.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},i.int32=o.next,i.quick=i,l&&("object"==typeof l&&r(l,o),i.state=function(){return r(o,{})}),i}e&&e.exports?e.exports=o:t&&t.amd?t(function(){return o}):this.xorwow=o}(e=n.nmd(e),"function"==typeof define&&define)},320(e,t,n){!function(t,r,o){var l,i="random",a=o.pow(256,6),u=o.pow(2,52),s=2*u;function c(e,n,c){var h=[],g=m(function e(t,n){var r,o=[],l=typeof t;if(n&&"object"==l)for(r in t)try{o.push(e(t[r],n-1))}catch(e){}return o.length?o:"string"==l?t:t+"\0"}((n=!0==n?{entropy:!0}:n||{}).entropy?[e,p(r)]:null==e?function(){try{var e;return l&&(e=l.randomBytes)?e=e(256):(e=new Uint8Array(256),(t.crypto||t.msCrypto).getRandomValues(e)),p(e)}catch(e){var n=t.navigator,o=n&&n.plugins;return[+new Date,t,o,t.screen,p(r)]}}():e,3),h),v=new f(h),y=function(){for(var e=v.g(6),t=a,n=0;e<u;)e=(e+n)*256,t*=256,n=v.g(1);for(;e>=s;)e/=2,t/=2,n>>>=1;return(e+n)/t};return y.int32=function(){return 0|v.g(4)},y.quick=function(){return v.g(4)/0x100000000},y.double=y,m(p(v.S),r),(n.pass||c||function(e,t,n,r){return(r&&(r.S&&d(r,v),e.state=function(){return d(v,{})}),n)?(o[i]=e,t):e})(y,g,"global"in n?n.global:this==o,n.state)}function f(e){var t,n=e.length,r=this,o=0,l=r.i=r.j=0,i=r.S=[];for(n||(e=[n++]);o<256;)i[o]=o++;for(o=0;o<256;o++)i[o]=i[l=255&l+e[o%n]+(t=i[o])],i[l]=t;(r.g=function(e){for(var t,n=0,o=r.i,l=r.j,i=r.S;e--;)t=i[o=255&o+1],n=256*n+i[255&(i[o]=i[l=255&l+t])+(i[l]=t)];return r.i=o,r.j=l,n})(256)}function d(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function m(e,t){for(var n,r=e+"",o=0;o<r.length;)t[255&o]=255&(n^=19*t[255&o])+r.charCodeAt(o++);return p(t)}function p(e){return String.fromCharCode.apply(0,e)}if(m(o.random(),r),e.exports){e.exports=c;try{l=n(562)}catch(e){}}else"function"==typeof define&&define.amd?define(function(){return c}):o["seed"+i]=c}("u">typeof self?self:this,[],Math)},287(e,t,n){"use strict";n.d(t,{G:()=>o});var r=n(590);function o(e){var t,n;let o,l,i;return JSON.stringify((o=(null!=(n=(t=JSON.parse(e)).p)?n:[]).map(e=>({x:e[0],y:e[1],outlier:e.length>2&&1===e[2]})),l=void 0!==t.mxr&&void 0!==t.hs&&void 0!==t.poi&&void 0!==t.mnr,i={points:o,fitFunction:r.Qx,showFitLine:!0,showPoints:"points",clickToToggle:!0,name:t.rdt?`${t.rdt}`:"Dose-Response",droplines:["IC50"]},l&&(i.parameters=[t.mxr,t.hs,t.poi,t.mnr]),{chartOptions:{xAxisName:t.xu,yAxisName:t.yu,logX:!0},series:[i]}))}},305(e,t,n){"use strict";n.d(t,{R:()=>o});var r=n(886);function o(e){let t=(0,r.rn)(e).find(e=>"XY"===e.tableType);if(!t)return JSON.stringify({series:[]});let n=(0,r.fM)(t);return JSON.stringify(null!=n?n:{series:[]})}},190(e,t,n){"use strict";n.d(t,{J:()=>c});var r=n(82),o=n(869),l=n(590);let i="xAxis",a="yAxis";function u(e,t){var n;return(null==e||null==(n=e.getAttribute(t))?void 0:n.toLowerCase())==="true"}function s(e){var t,n,i;let a=null==(n=e.getElementsByTagName("params")[0])||null==(t=n.childNodes[0].nodeValue)?void 0:t.split(",").map(Number),s=null==(i=e.getElementsByTagName("function")[0])?void 0:i.getAttribute("type"),c=s&&"sigif"!==s&&s in o.rT?s:l.G7,f=e.getElementsByTagName("settings")[0].getAttribute("markerColor"),d=e.getElementsByTagName("settings")[0].getAttribute("color"),m=u(e.getElementsByTagName("settings")[0],"drawLine"),p={name:e.getAttribute("name"),fitFunction:c,markerType:r.MARKER_TYPE.CIRCLE,pointColor:f,fitLineColor:d,showFitLine:m,showPoints:"points",showCurveConfidenceInterval:!1,clickToToggle:!1};return a&&(p.parameters=[a[2],a[1],a[0],a[3]]),p}function c(e){let t,n,r,o,l;return JSON.stringify((n=(t=new DOMParser().parseFromString(e,"text/xml")).getElementsByTagName("grid")[0],r=t.getElementsByTagName("settings")[0],o=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({minX:+n.getElementsByTagName(i)[0].getAttribute("min"),minY:+n.getElementsByTagName(a)[0].getAttribute("min"),maxX:+n.getElementsByTagName(i)[0].getAttribute("max"),maxY:+n.getElementsByTagName(a)[0].getAttribute("max"),xAxisName:r.getAttribute("xLabel"),yAxisName:r.getAttribute("yLabel"),logX:u(r,"logX")},null!==r.getAttribute("logY")?{logY:u(r,"logY")}:{}),{chartOptions:o,seriesOptions:s((l=t.getElementsByTagName("seriesCollection")[0]).getElementsByTagName("series")[0]),series:function(e){let t=[],n=e.getElementsByTagName("series").length;for(let r=0;r<n;r++){let n=e.getElementsByTagName("series")[r];t[r]=function(e){let t=function(e){var t,n,r;let o=null==(t=e.getElementsByTagName("x")[0].childNodes[0].nodeValue)?void 0:t.split(","),l=null==(n=e.getElementsByTagName("y")[0].childNodes[0].nodeValue)?void 0:n.split(","),i=null==(r=e.getElementsByTagName("mask")[0].childNodes[0].nodeValue)?void 0:r.split(""),a=[];for(let e=0;e<o.length;e++)a[e]={x:+o[e],y:+l[e],outlier:"0"===i[e]};return a}(e),n=s(e),r={points:t};return Object.assign(r,n),r}(n)}return t}(l)}))}},124(e,t,n){"use strict";n.d(t,{HB:()=>f,XN:()=>d,l8:()=>u,p:()=>s});var r=n(82),o=n(788);function l(e,t,n,r,o,l,i){try{var a=e[l](i),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}let i=new Map,a=new r.LruCache(2e3);function u(e,t){i.set(e,t)}function s(){var e;return(e=function*(){for(let e of r.Func.find({meta:{role:"curveConverter"}})){let t=e.options.curveFormat;t&&!i.has(t)&&u(t,(yield e.apply()))}},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){l(i,r,o,a,u,"next",e)}function u(e){l(i,r,o,a,u,"throw",e)}a(void 0)})})()}function c(e){let t=e.getTag(o.h.TAG_CURVE_FORMAT);return t&&""!==t?t:null}function f(e,t){if(!e||""===e)return{series:[]};let n=t?function(e,t){let n=c(t);if(!n)return e;let r=`${n}||${e}`;return a.getOrCreate(r,()=>{let t=i.get(n);return t?t(e):(console.warn(`Curve converter for format '${n}' not found in registry.`),e)})}(e,t):e;try{var r;return null!=(r=JSON.parse(null!=n?n:"{}"))?r:{}}catch(e){return{series:[]}}}function d(e){return null===c(e)}},53(e,t,n){"use strict";n.d(t,{B3:()=>X,CP:()=>d,G_:()=>M,IY:()=>N,Ig:()=>R,LX:()=>C,RH:()=>T,Th:()=>h,U6:()=>P,Xm:()=>A,ab:()=>p,bZ:()=>c,bc:()=>F,g2:()=>m,h8:()=>x,mI:()=>w,uc:()=>f,wU:()=>b});var r=n(82),o=n(590),l=n(165),i=n(869),a=n(774),u=n(788),s=n(124);let c=new r.LruCache(1e3),f=new r.LruCache(1e3),d=new r.LruCache(2e3);function m(e,t,n){if(t&&n)for(let r of e)!(r.name in n)&&r.name in t&&(n[r.name]=t[r.name])}let p="chartOptions",h="seriesOptions";function g(e,t,n,r){if(e&&n&&t)for(let o of t)o in e&&!(null==r?void 0:r.includes(o))&&(n[o]=e[o])}function v(e,t,n,r,o){var l,i,a;let u=null==(l=e.explicit)?void 0:l[r];g(n[r],null==(i=n.explicit)?void 0:i[r],o,u),g(t[r],null==(a=t.explicit)?void 0:a[r],o,u)}function y(e,...t){if(e)for(let n of t)(null==n?void 0:n.labels)&&(e.labels=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},n.labels,e.labels))}function C(e,t=[]){let n,r,o;if(0===e.length)return{};let l=Number.MAX_VALUE,i=Number.MAX_VALUE,a=5e-324,u=5e-324,s=!1,c=!1,f=!1;for(let t of e)null!==t.minX&&void 0!==t.minX&&(l=Math.min(l,t.minX)),null!==t.minY&&void 0!==t.minY&&(i=Math.min(i,t.minY)),null!==t.maxX&&void 0!==t.maxX&&(a=Math.max(a,t.maxX)),null!==t.maxY&&void 0!==t.maxY&&(u=Math.max(u,t.maxY)),null!==t.title&&void 0!==t.title&&(null!=o||(o=t.title)),null!==t.xAxisName&&void 0!==t.xAxisName&&(null!=n||(n=t.xAxisName)),null!==t.yAxisName&&void 0!==t.yAxisName&&(null!=r||(r=t.yAxisName)),null!==t.logX&&void 0!==t.logX&&t.logX&&(s=!0),null!==t.logY&&void 0!==t.logY&&t.logY&&(c=!0),null!==t.allowXZeroes&&void 0!==t.allowXZeroes&&t.allowXZeroes&&(f=!0);for(let e of t)for(let t of e.points)t.x<l&&(l=Number.MAX_VALUE),t.x>a&&(a=5e-324),t.y<i&&(i=Number.MAX_VALUE),t.y>u&&(u=5e-324);return{minX:l===Number.MAX_VALUE?void 0:l,minY:i===Number.MAX_VALUE?void 0:i,maxX:5e-324===a?void 0:a,maxY:5e-324===u?void 0:u,title:o,xAxisName:n,yAxisName:r,logX:s,logY:c,allowXZeroes:f}}function b(e){if(0===e.length)return null;let 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,showOutliers:e[0].showOutliers,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(let n of e)t.points=[...t.points,...n.points];return t}function x(e,t=!0){var n;let r=null==e?void 0:e.column;return t&&r&&e?f.getOrCreate((n=e.rowIndex,`tableId: ${r.dataFrame.id} || tableName: ${r.dataFrame.name} || colName: ${r.name} || colVersion: ${r.version} || rowIdx: ${n}`),()=>I(e)):I(e)}function w(e,t,n){let r=F(t),l=n?R(n):{};for(let t of(null!=e.series||(e.series=[]),null!=e.chartOptions||(e.chartOptions=r.chartOptions),m(o.xs,r.chartOptions,e.chartOptions),m(o.xs,l.chartOptions,e.chartOptions),y(e.chartOptions,r.chartOptions,l.chartOptions),v(e,r,l,p,e.chartOptions),e.series))m(i.IL,e.seriesOptions,t),m(i.IL,r.seriesOptions,t),m(i.IL,l.seriesOptions,t),v(e,r,l,h,t);return e}function T(e){return e.includes("|")?e.replaceAll("|",""):e}function I(e){var t,n,a,u,c;let f=e.value,d=e.column,g=d?d.type===r.TYPE.STRING?(0,s.HB)(f,d):(0,l.Kh)():null!=(t=JSON.parse(null!=(n=T(f))?n:"{}"))?t:{};(null==d?void 0:d.type)!==r.TYPE.STRING||(null==(c=g.series)?void 0:c.length)||(g=(0,s.HB)(T(f),d));let C=e.column?F(e.column):{},b=e.column?R(e.dataFrame):{};for(let e of(null!=(a=g).series||(a.series=[]),null!=(u=g).chartOptions||(u.chartOptions=C.chartOptions),m(o.xs,C.chartOptions,g.chartOptions),m(o.xs,b.chartOptions,g.chartOptions),y(g.chartOptions,C.chartOptions,b.chartOptions),v(g,C,b,p,g.chartOptions),g.series))m(i.IL,g.seriesOptions,e),m(i.IL,C.seriesOptions,e),m(i.IL,b.seriesOptions,e),v(g,C,b,h,e);return g}let _=new r.LruCache(2e3),O=new WeakMap,E=0;function P(e){let t=O.get(e);return void 0===t&&O.set(e,t=++E),t}function S(e,t,n,r){return`tableId: ${e.dataFrame.id} || tableName: ${e.dataFrame.name} || colName: ${e.name} || colVersion: ${e.version} || rowIdx: ${t.rowIndex} || idx: ${n} || logX: ${null==r?void 0:r.logX} || logY: ${null==r?void 0:r.logY}`}function N(e,t,n,r,o,l=!0,a){let u=A(e,t,r,!1,o,l),s=null==o?void 0:o.column;return a?_.getOrCreate(`${a} || logX: ${null==r?void 0:r.logX} || logY: ${null==r?void 0:r.logY}`,()=>(0,i.nT)(e,n,u,r)):l&&s&&o?c.getOrCreate(S(s,o,t,r),()=>(0,i.nT)(e,n,u,r)):(0,i.nT)(e,n,u,r)}function A(e,t,n,r,o,l=!0){let i=null==o?void 0:o.column;return l&&i&&o?d.getOrCreate(`${S(i,o,t,n)} || userParamsFlag: ${r}`,()=>(0,a.Sm)(e,n,r)):(0,a.Sm)(e,n,r)}function L(e){return JSON.parse(e[u.h.TAG_FIT]||e[u.h.TAG_FIT_LEGACY]||JSON.stringify((0,l.Kh)()))}function M(e,t){e[u.h.TAG_FIT]=JSON.stringify(t),delete e[u.h.TAG_FIT_LEGACY]}function R(e){return L(e.tags)}function F(e){return L(e.tags)}function X(e){var t;for(let n=0;n<(null==(t=e.series)?void 0:t.length);n++){let t=e.series[n];if(t.points.every(e=>0!==e.x))continue;let r=Number.MAX_VALUE,o=0,l=0,i=[];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),0!==t.points[e].x&&!i.includes(t.points[e].x)&&(i[i.length]=t.points[e].x,l++);if(0===l)continue;let a=Math.log10(r),u=l>1?(Math.log10(o)-a)/(l-1):1,s=Math.pow(10,a-u);for(let e=0;e<t.points.length;e++)0===t.points[e].x&&(t.points[e].x=s)}}},301(e,t,n){"use strict";n.d(t,{Z1:()=>u,pj:()=>s});var r=n(82),o=n(328),l=n(644);function i(e,t,n,r,o,l,i){try{var a=e[l](i),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function a(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){i(l,r,o,a,u,"next",e)}function u(e){i(l,r,o,a,u,"throw",e)}a(void 0)})}}function u(){return a(function*(){o.shell.windows.showContextPanel=!0;let e=yield o.data.loadTable(`${l._package.webRoot}files/curves-demo.csv`);o.shell.addTableView(e)})()}function s(){return a(function*(){let e=yield o.data.loadTable(`${l._package.webRoot}files/demo/Assay_Curves.csv`);yield e.meta.detectSemanticTypes();let t=yield l._package.files.readAsText("demo/Assay_Curves.layout"),n=r.ViewLayout.fromJson(t);e.selection.set(13,!0),e.selection.set(14,!0);let i=o.shell.addTableView(e);yield r.delay(100),i.loadLayout(n,!0),o.shell.info("Select cells in Trellis plot to see corresponding curves in Multi Curve Viewer.",{timeout:10})})()}n(590),n(991),n(788)},181(e,t,n){"use strict";n.d(t,{e:()=>b});var r=n(82),o=n(389),l=n(328),i=n(165),a=n(129),u=n(53),s=n(788),c=n(684),f=n(434),d=n(590),m=n(869),p=n(258);function h(e,t,n,r,o,l,i){try{var a=e[l](i),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function g(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function v(e,t,n){var o;return(o=function*(){let o=r.Func.find({package:"Curves",name:t})[0];if(!o)return void l.shell.error(`Curves: ${t} is not registered`);let i=e.cell.dataFrame,a=e.cell.column.name,u=new Set(i.columns.names());try{yield o.prepare(g({table:i,curveColumn:e.cell.column},n)).call(!1,void 0,{processed:!1})}catch(e){l.shell.error(`Could not add the statistic column: ${e}`);return}!function(e,t,n){if(0===t.length)return;let r=e.cell.dataFrame;r.columns.setOrder(y(r.columns.names(),t,n));let o=e.grid;if(!o)return;let l=[];for(let e=0;e<o.columns.length;e++){var i;let t=null==(i=o.columns.byIndex(e))?void 0:i.name;t&&l.push(t)}o.columns.setOrder(y(l,t,n))}(e,i.columns.names().filter(e=>!u.has(e)),a)},function(){var e=this,t=arguments;return new Promise(function(n,r){var l=o.apply(e,t);function i(e){h(l,n,r,i,a,"next",e)}function a(e){h(l,n,r,i,a,"throw",e)}i(void 0)})})()}function y(e,t,n){let r=e.filter(e=>!t.includes(e)),o=r.indexOf(n)+1;return[...r.slice(0,o),...t,...r.slice(o)]}function C(e){let t=e.root.querySelector(".ui-input-multi-choice-checks");return t&&(t.style.maxHeight="none",t.style.overflowY="visible"),e}class b extends r.ObjectHandler{get type(){return"GridCell"}isApplicable(e){return e instanceof r.GridCell&&e.cellType===s.h.FIT_CELL_TYPE}levelInput(e){let t=e.cell,n=t.column.dart,l=t.rowIndex,i=()=>{var e;return(null==(e=this.levelColumn)?void 0:e.deref())===n&&this.levelRow===l};i()||(this.levelColumn=new WeakRef(n),this.levelRow=l,this.manipulationLevel=p.tS.COLUMN);let a=r.Property.js("level",r.TYPE.STRING,{description:"Controls the level at which properties will be switched",defaultValue:this.manipulationLevel,choices:["Dataframe","Column","Cell"],nullable:!1}),u=o.input.forProperty(a,null,{onValueChanged:e=>{i()&&(this.manipulationLevel=e)}});return o.tooltip.bind(u.captionLabel,"Controls the level at which properties will be switched"),u}renderProperties(e,t=null){var n,l,h,y,b,x,w,T;let I=o.accordion("Curves property panel"),_=this.levelInput(e),O=(0,u.h8)(e.cell),E=(0,u.bc)(e.cell.column),P=(0,u.Ig)(e.cell.dataFrame),S={onValueChanged:(t,n)=>(0,p.FC)(e,n,u.Th,_.value)},N={onValueChanged:(t,n)=>(0,p.FC)(e,n,u.ab,_.value)},A=e=>{if(P.seriesOptions&&!(0,c.Yc)(P.seriesOptions[e])&&E.seriesOptions&&!(0,c.Yc)(E.seriesOptions[e])){var t;O.seriesOptions?(0,c.Yc)(O.seriesOptions[e])||(O.seriesOptions[e]=r.Color.toHtml("outlierColor"===e?r.Color.red:r.Color.getCategoricalColor(0))):(null==(t=O.series)?void 0:t.length)&&!(0,c.Yc)(O.series[0][e])&&(O.series[0][e]=r.Color.toHtml("outlierColor"===e?r.Color.red:r.Color.getCategoricalColor(0)))}},L=e.cell;A("pointColor"),A("fitLineColor"),A("outlierColor"),(0,u.g2)(m.IL,E.seriesOptions,O.seriesOptions?O.seriesOptions:O.series&&null!=(n=O.series[0])?n:{}),(0,u.g2)(m.IL,P.seriesOptions,O.seriesOptions?O.seriesOptions:O.series&&null!=(l=O.series[0])?l:{}),(0,u.g2)(d.xs,E.chartOptions,O.chartOptions?O.chartOptions:{}),(0,u.g2)(d.xs,P.chartOptions,O.chartOptions?O.chartOptions:{}),(null==(y=O.chartOptions)?void 0:y.allowXZeroes)&&(null==(b=O.chartOptions)?void 0:b.logX)&&(null==(x=O.series)?void 0:x.some(e=>e.points.some(e=>0===e.x)))&&(0,u.B3)(O);let M=o.form([_]),R=O.seriesOptions?O.seriesOptions:O.series[0],F=R&&"object"==typeof R.fitFunction?R.fitFunction:null,X=(0,p.s9)(O,F).map(e=>{var t,n;if("fitFunction"!==e.name||!F)return C(o.input.forProperty(e,R,S));let r=(t=g({},R),n=n={fitFunction:F.name},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t);return o.input.forProperty(e,r,{onValueChanged:(e,t)=>{e!==F.name&&(R.fitFunction=e),S.onValueChanged(e,t)}})});o.forms.addGroup(M,"Series options",X),(null==(w=O.chartOptions)?void 0:w.showStatistics)&&(O.chartOptions.showStatistics=(0,p.QA)(O,O.chartOptions.showStatistics)),o.forms.addGroup(M,"Chart options",(0,p.di)(O).map(e=>C(o.input.forProperty(e,O.chartOptions,N)))),I.addPane("Options",()=>M);let D=(null!=(h=null==(T=O.series)?void 0:T.length)?h:0)>1?["all","aggregated"]:["all"],Y=r.Property.js("series",r.TYPE.STRING,{description:"Controls whether to show series statistics or aggregated statistics",defaultValue:"all",choices:D,nullable:!1}),j=o.input.forProperty(Y,null,{onValueChanged:()=>{I.getPane("Fit").root.lastElementChild.replaceChildren(k())}}),G=r.Property.js("aggregation type",r.TYPE.STRING,{description:"Controls which aggregation to use on the series statistics",defaultValue:"med",choices:Object.values(r.STATS),nullable:!1}),H=o.input.forProperty(G,null,{onValueChanged:()=>{I.getPane("Fit").root.lastElementChild.replaceChildren(k())}});function k(){var t,n,r,l,a;let u=(null!=(t=null==(n=O.series)?void 0:n.length)?t:0)>1?"aggregated"===j.stringValue?[j.root,H.root]:[j.root]:null,s=o.divV(u),d=(0,i.s$)(O);if(d.x<=0&&O.chartOptions&&(O.chartOptions.logX=!1),d.y<=0&&O.chartOptions&&(O.chartOptions.logY=!1),"all"===j.stringValue){let t={logX:null==(r=O.chartOptions)?void 0:r.logX,logY:null==(l=O.chartOptions)?void 0:l.logY};for(let n=0;n<O.series.length;n++){let r=O.series[n],l=(0,f.TV)(r,n,t,L),u=(0,c.Z)(r,n,c.mE.FIT_LINE),d=null!=(a=r.name)?a:"series "+n;s.appendChild(o.panel([o.h1(d,{style:{color:u}}),o.input.form(l,(0,i.zB)(r).statisticsProperties,{onCreated:t=>t.root.appendChild(o.iconFA("plus",()=>v(e,"curveStatistic",{propName:t.property.name,seriesNumber:n}),`Calculate ${t.property.name} for the whole column`))})]))}}else{let t=(0,f.JR)(O,H.stringValue,L);s.appendChild(o.panel([o.h1(`series ${H.stringValue}`),o.input.form(t,(0,f.Uc)(O,H.stringValue),{onCreated:t=>t.root.appendChild(o.iconFA("plus",()=>v(e,"curveAggrStatistic",{propName:t.property.name,aggrType:H.stringValue}),`Calculate ${t.property.name} ${H.stringValue} for the whole column`))})]))}return s}let V=r.GridCellWidget.fromGridCell(e);V.canvas.addEventListener("click",e=>V.render());let B=I.addPane("Chart",()=>V.root),q=a.l.inflateScreenBounds(e.bounds);return(q.width<s.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||q.height<s.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT)&&(B.expanded=!0),I.addPane("Fit",()=>k()),I.root}constructor(...e){super(...e),this.levelColumn=null,this.levelRow=-1,this.manipulationLevel=p.tS.COLUMN}}},476(e,t,n){"use strict";n.d(t,{I4:()=>g,Oz:()=>x,dA:()=>C,fU:()=>w,hC:()=>b});var r=n(82),o=n(328),l=n(389),i=n(858),a=n(165),u=n(869),s=n(788),c=n(533),f=n(124),d=n(53),m=n(434),p=n(324),h=n(663);function g(e,t,n=!1){var o,a;if(!e.cell.value)return;let u=r.GridCellWidget.fromGridCell(e);u.root.style.removeProperty("aspectRatio"),u.root.style.height="100%",u.canvas.style.removeProperty("height"),u.canvas.style.removeProperty("width"),u.canvas.style.left="18px",u.canvas.style.top="18px";let s=l.dialog({title:"Edit chart"}).add(u.root).show({resizable:!0,width:null!=(o=null==t?void 0:t.width)?o:500,height:null!=(a=null==t?void 0:t.height)?a:430});s.getButton("CANCEL").textContent="Close",n&&s.sub((0,i.merge)(e.grid.dataFrame.onDataChanged,e.grid.dataFrame.onMetadataChanged).subscribe(()=>u.render()))}function v(e,t,n){let o=n.xToScreen(t.x),l=n.yToScreen(t.y),i=(t.outlier?s.h.OUTLIER_PX_SIZE:s.h.POINT_PX_SIZE)/2+s.h.OUTLIER_HITBOX_RADIUS;return new r.Rect(o-i,l-i,2*i,2*i).containsPoint(new r.Point(e.x,e.y))}function y(e,t){var n,r,o,l;let i=(0,p.lc)(e,t),u=(0,p.Tv)(e,i.x,i.y,(0,p.ij)(e,t))[0];return new c.L((0,a.s$)(t),u,null!=(n=null==(o=t.chartOptions)?void 0:o.logX)&&n,null!=(r=null==(l=t.chartOptions)?void 0:l.logY)&&r)}function C(e,t=(0,d.h8)(e.cell,!1)){for(let[e,n]of Object.entries(s.h.CONDITION_MAP))if(n(t.series))return l.divText(e,{style:{color:"red"}});return e}function b(e,t){var n;if(!e.cell.value||!e.cell.column)return;let r=(0,d.h8)(e.cell,!1),l=C(e,r);if(o.shell.setCurrentObject(l,!1),l!==e)return;let i=(0,p.fn)(e.bounds),a=y(i,r);for(let l=0;l<(null==(n=r.series)?void 0:n.length);l++)if(!r.series[l].connectDots&&r.series[l].clickToToggle&&"points"===r.series[l].showPoints&&!(i.width<s.h.MIN_AXES_CELL_PX_WIDTH)&&!(i.height<s.h.MIN_AXES_CELL_PX_HEIGHT))for(let n=0;n<r.series[l].points.length;n++){let i=r.series[l].points[n];if((!i.outlier||r.series[l].showOutliers)&&v({x:t.offsetX,y:t.offsetY},i,a))return void function(e,t,n,r,l){if(t.outlier=!t.outlier,(0,f.XN)(e.cell.column)){let l=JSON.parse(e.cell.value);l.series[n].points[r].outlier=t.outlier,e.cell.column.set(e.cell.rowIndex,JSON.stringify(l),!0),o.events.fireCustomEvent("fit-cell-outlier-toggle",{gridCell:e,series:l.series[n],seriesIdx:n,pointIdx:r})}let i=e.grid.dataFrame.columns.byTags({".sourceColumn":e.cell.column.name});if(i)for(let t of(null!=l||(l=(0,d.h8)(e.cell)),i)){var a,s;let r,o={logX:null==(a=l.chartOptions)?void 0:a.logX,logY:null==(s=l.chartOptions)?void 0:s.logY},i=t.tags[".statistics"];if(null!==t.tags[".seriesAggregation"])r=(0,m.JR)(l,t.tags[".seriesAggregation"],e.cell)[i];else{if(t.tags[".seriesNumber"]!==n.toString())continue;r=(0,u.h5)((0,m.TV)(l.series[n],n,o,e.cell),i)}t.set(e.cell.rowIndex,null!=r?r:null)}}(e,i,l,n,r)}}function x(e,t,n,o){var i,a,u,c,f,d,m;let p=y(t,e),g=(0,h.qd)(e,t)?(0,h.tp)(e,p.screen,o.x,o.y):null;if(null!==g)return l.tooltip.show((0,h.D5)(g),n.x+16,n.y+16),!0;for(let h=0;h<(null==(i=e.series)?void 0:i.length);h++)if("points"===e.series[h].showPoints)for(let i=0;i<e.series[h].points.length;i++){let g=e.series[h].points[i];if((!g.outlier||e.series[h].showOutliers)&&v(o,g,p))return l.tooltip.show(l.divV([l.divText(`${null!=(a=null==(c=e.chartOptions)?void 0:c.xAxisName)?a:"x"}: ${r.format(g.x,!(null==(f=e.chartOptions)?void 0:f.logX)?"#0.000":"scientific")}`),l.divText(`${null!=(u=null==(d=e.chartOptions)?void 0:d.yAxisName)?u:"y"}: ${r.format(g.y,!(null==(m=e.chartOptions)?void 0:m.logY)?"#0.000":"scientific")}`)]),n.x+16,n.y+16),!e.series[h].connectDots&&e.series[h].clickToToggle&&t.width>=s.h.MIN_AXES_CELL_PX_WIDTH&&t.height>=s.h.MIN_AXES_CELL_PX_HEIGHT&&(document.body.style.cursor="pointer"),!0}return!1}function w(e,t,n){var r;if(!(null==e||null==(r=e.cell)?void 0:r.value))return;let o=(0,p.fn)(e.bounds);if(o.width<s.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||o.height<s.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT){let r=l.canvas(300,200);n.render(r.getContext("2d"),0,0,300,200,e,null),l.tooltip.show(l.divV([r]),t.x,t.y)}let i=(0,d.h8)(null==e?void 0:e.cell);if(o.width>=s.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH&&o.height>=s.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT){if(x(i,o,t,{x:t.offsetX,y:t.offsetY}))return;l.tooltip.hide()}document.body.style.cursor="default"}},324(e,t,n){"use strict";n.d(t,{Tv:()=>l,W$:()=>f,ZK:()=>c,b1:()=>i,eG:()=>u,fn:()=>o,ij:()=>s,lc:()=>a,m:()=>d});var r=n(788);function o(e){return e.inflate(e.width<r.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH?r.h.MIN_INFLATE_SIZE:r.h.INFLATE_SIZE,e.height<r.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT?r.h.MIN_INFLATE_SIZE:r.h.INFLATE_SIZE)}function l(e,t,n,o){if(e.width<r.h.MIN_AXES_CELL_PX_WIDTH||e.height<r.h.MIN_AXES_CELL_PX_HEIGHT)return[e,void 0,void 0];let l=n?r.h.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:r.h.AXES_LEFT_PX_MARGIN,i=t?r.h.AXES_BOTTOM_PX_MARGIN_WITH_AXES_LABELS:r.h.AXES_BOTTOM_PX_MARGIN,a=o?r.h.AXES_TOP_PX_MARGIN_WITH_TITLE:r.h.AXES_TOP_PX_MARGIN,u=r.h.AXES_RIGHT_PX_MARGIN;return[e.cutLeft(l).cutBottom(i).cutTop(a).cutRight(u),e.getBottom(i).getTop(a).cutLeft(l).cutRight(u),e.getLeft(l).getRight(r.h.AXES_RIGHT_PX_MARGIN).cutBottom(i).cutTop(a)]}function i(e){return e.width>=r.h.MIN_AXES_CELL_PX_WIDTH&&e.height>=r.h.MIN_AXES_CELL_PX_HEIGHT}function a(e,t){var n,o;let l=e.width>=r.h.MIN_X_AXIS_NAME_VISIBILITY_PX_WIDTH&&e.height>=r.h.MIN_Y_AXIS_NAME_VISIBILITY_PX_HEIGHT;return{x:l&&!!(null==(n=t.chartOptions)?void 0:n.xAxisName),y:l&&!!(null==(o=t.chartOptions)?void 0:o.yAxisName)}}function u(e,t){let n=a(e,t);return n.x||n.y}function s(e,t){var n;return e.width>=r.h.MIN_TITLE_PX_WIDTH&&e.height>=r.h.MIN_TITLE_PX_HEIGHT&&!!(null==(n=t.chartOptions)?void 0:n.title)}function c(e){return e.width>=r.h.MIN_LEGEND_PX_WIDTH&&e.height>=r.h.MIN_LEGEND_PX_HEIGHT}function f(e){return e.width>=r.h.MIN_DROPLINE_LABELS_PX_WIDTH&&e.height>=r.h.MIN_DROPLINE_LABELS_PX_HEIGHT}function d(e){return e.width>=r.h.MIN_DROPLINES_VISIBILITY_PX_WIDTH&&e.height>=r.h.MIN_DROPLINES_VISIBILITY_PX_HEIGHT}},663(e,t,n){"use strict";let r;n.d(t,{$$:()=>c,D5:()=>b,GU:()=>x,QK:()=>I,qd:()=>s,tp:()=>w});var o=n(82),l=n(389),i=n(788),a=n(684),u=n(324);function s(e,t){var n,r;return(null==(n=null==(r=e.chartOptions)?void 0:r.showLegend)||n)&&(0,u.ZK)(t)}let c=["top right","top left","bottom right","bottom left"],f='11px Roboto, "Roboto Local"',d=new WeakMap;function m(e){return null!=r||(r=document.createElement("canvas").getContext("2d")),r.font=f,r.measureText(e).width}function p(e,t){if(m(e)<=t)return e;let n=e;for(;n.length>1&&m(`${n}…`)>t;)n=n.slice(0,-1);return`${n}…`}function h(e,t){var n;let r=t&&null!=(n=e.auxLegendName)?n:e.name;return""===r||null===r?void 0:r}function g(e,t){if(!(null==t?void 0:t.length))return 0;let n=e.inflate(14,14);return t.filter(e=>n.contains(e.x,e.y)).length}function v(e,t,n,r,l){let i=[new o.Rect(e.maxX-t-4,e.y+4,t,n),new o.Rect(e.x+4,e.y+4,t,n),new o.Rect(e.maxX-t-4,e.maxY-n-4,t,n),new o.Rect(e.x+4,e.maxY-n-4,t,n)],a=null!=l?l:0;if(!(null==r?void 0:r.length))return{rect:i[a],index:a};let u=i.map(e=>({taken:g(e,r),clearance:Math.min(...r.map(t=>{let n,r;return n=Math.max(e.x-t.x,0,t.x-e.maxX),Math.sqrt(n*n+(r=Math.max(e.y-t.y,0,t.y-e.maxY))*r)}))})),s=0;for(let e=1;e<i.length;e++)(u[e].taken<u[s].taken||u[e].taken===u[s].taken&&u[e].clearance>u[s].clearance)&&(s=e);return u[a].taken<=2||2*u[s].taken>=u[a].taken?{rect:i[a],index:a}:{rect:i[s],index:s}}function y(e){return Math.floor(i.h.POINT_PX_SIZE*e*1.5)+i.h.LEGEND_RECORD_LINE_PX_WIDTH+i.h.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN}function C(e,t,n,r,l){if(void 0===t.marker)return;let a=Math.floor(i.h.POINT_PX_SIZE*l*1.5);e.beginPath(),e.strokeStyle=t.color,e.lineWidth=2*l,e.moveTo(n+a,r),e.lineTo(n+a+i.h.LEGEND_RECORD_LINE_PX_WIDTH,r),e.stroke(),o.Paint.marker(e,t.marker,n+a/2,r,t.pointColor,a)}function b(e){let t=1===e.length,n=e.slice(0,Math.max(10,Math.floor(.75*window.innerHeight/i.h.LEGEND_RECORD_PX_HEIGHT))),r=n.map(e=>{let n=l.canvas(y(1),i.h.LEGEND_RECORD_PX_HEIGHT);C(n.getContext("2d"),e,0,i.h.LEGEND_RECORD_PX_HEIGHT/2,1);let r=l.divH([n,l.divText(t?e.text:p(e.text,400),{style:{color:e.color}})]);return r.style.alignItems="center",r});return e.length>n.length&&r.push(l.divText(`+${e.length-n.length} more`)),l.divV(r)}function x(e,t,n,r,l){let u=function(e,t,n,r){let l=d.get(e),u=function(e){var t,n,r,l;let i=null!=(t=e.series)?t:[],u=[...new Set(i.map(e=>e.columnName))].filter(e=>null!=e),s=[];for(let t of u){let n=i.map((e,t)=>({series:e,idx:t})).filter(({series:n})=>{var r;return n.columnName===t&&h(n,null==(r=e.chartOptions)?void 0:r.useAuxLegendNames)});if(0!==n.length)for(let{series:i,idx:u}of((null==(r=e.chartOptions)?void 0:r.showColumnLabel)&&n.length>1&&s.push({text:t,color:"black"}),n))s.push({text:h(i,null==(l=e.chartOptions)?void 0:l.useAuxLegendNames),column:t,color:(0,a.Z)(i,u,a.mE.FIT_LINE),pointColor:(0,a.Z)(i,u,a.mE.POINT),marker:function(e){var t,n,r;let l=(null==(n=e.points)?void 0:n.length)?e.points[0].marker:null,i=(null==(r=e.points)?void 0:r.every(e=>e.marker===l&&null!=e.marker))?l:null;return null!=(t=null!=i?i:e.markerType)?t:o.MARKER_TYPE.CIRCLE}(i)})}let c=new Map;for(let e of s.filter(e=>void 0!==e.marker&&e.column))(null!=(n=c.get(e.text))?n:c.set(e.text,new Set).get(e.text)).add(e.column);for(let e of s)void 0!==e.marker&&e.column&&c.get(e.text).size>1&&(e.text=`${e.column}: ${e.text}`);return s}(e);if(0===u.length)return{rows:[],hidden:0,entries:u,corner:0,whole:!0};let s=y(n);if(.55*t.width-s<=0)return{rows:[],hidden:0,entries:u,corner:0,whole:!0};let c=Math.floor(.5*t.height/i.h.LEGEND_RECORD_PX_HEIGHT),f=u.length>c?u.slice(0,Math.max(1,c-1)):u,C=u.length-f.length,b=i.h.LEGEND_RECORD_PX_HEIGHT*(f.length+ +(C>0)),x=Math.min(s+Math.max(...f.map(e=>m(e.text)),C>0?m(`+${C} more`):0),t.width-8),w=v(t,x,b,r,null==l?void 0:l.corner),T=(null==l?void 0:l.whole)?12:2,I=g(w.rect,r)<=T,_=I?x:Math.min(x,.55*t.width),O=f.map(e=>p(e.text,_-s)),E=s+Math.max(...O.map(m)),P=I?w:v(t,E,b,r,null==l?void 0:l.corner),S=P.rect,N=f.map((e,t)=>({entry:e,shown:O[t],box:new o.Rect(S.x,S.y+i.h.LEGEND_RECORD_PX_HEIGHT*t,E,i.h.LEGEND_RECORD_PX_HEIGHT)})),A=0===C?void 0:new o.Rect(S.x,S.y+i.h.LEGEND_RECORD_PX_HEIGHT*N.length,E,i.h.LEGEND_RECORD_PX_HEIGHT);return{rows:N,hidden:C,moreBox:A,entries:u,corner:P.index,whole:I}}(t,n,r,l),{rows:s,hidden:c}=u;if(0===s.length)return;d.set(t,{box:n,rows:s,moreBox:u.moreBox,entries:u.entries,corner:u.corner,whole:u.whole}),e.save(),e.font=f,e.textAlign="left";let b=s[0].box,x=i.h.LEGEND_RECORD_PX_HEIGHT*(s.length+ +(c>0));for(let t of(e.fillStyle="rgba(255, 255, 255, 0.75)",e.fillRect(b.x-3,b.y-3,b.width+6,x+6),s)){let n=t.box.maxY-i.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN;C(e,t.entry,t.box.x,n-i.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN,r),e.fillStyle=t.entry.color,e.fillText(t.shown,t.box.x+(void 0===t.entry.marker?0:y(r)),n)}c>0&&(e.fillStyle="black",e.fillText(`+${c} more`,b.x,s[s.length-1].box.maxY+i.h.LEGEND_RECORD_PX_HEIGHT-i.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN)),e.restore()}function w(e,t,n,r){var o;let l=T(e,t);if(!l)return null;if(null==(o=l.moreBox)?void 0:o.contains(n,r))return l.entries;let i=l.rows.find(e=>e.box.contains(n,r));return i&&i.shown!==i.entry.text?[i.entry]:null}function T(e,t){let n=d.get(e);return n&&Math.round(n.box.x)===Math.round(t.x)&&Math.round(n.box.width)===Math.round(t.width)?n:null}function I(e,t){if(!s(e,t))return null;let n=(0,u.lc)(t,e);return T(e,(0,u.Tv)(t,n.x,n.y,(0,u.ij)(t,e))[0])}},258(e,t,n){"use strict";n.d(t,{FC:()=>b,QA:()=>h,di:()=>p,s9:()=>g,tS:()=>m});var r,o=n(82),l=n(328),i=n(165),a=n(590),u=n(788),s=n(869),c=n(53),f=n(124);let d=["logX","logY","allowXZeroes","fitFunction","errorModel"];var m=((r={}).DATAFRAME="Dataframe",r.COLUMN="Column",r.CELL="Cell",r);function p(e){var t,n,r;let l=[];for(let n of null!=(t=e.series)?t:[])for(let e of(0,i.zB)(n).statisticsProperties)l.includes(e.name)||l.push(e.name);let u=function(e){var t,n,r,o;let l=Object.keys(null!=(t=null==(r=e.chartOptions)?void 0:r.labels)?t:{});for(let t of null!=(n=e.series)?n:[])for(let e of Object.keys(null!=(o=t.labels)?o:{}))l.includes(e)||l.push(e);return l}(e),s=(null!=(n=null==(r=e.series)?void 0:r.length)?n:0)>1;return a.xs.filter(e=>("showLabels"!==e.name||u.length>0)&&("statisticsMode"!==e.name&&"aggrType"!==e.name||s)).map(e=>"showStatistics"===e.name&&l.length>0?o.Property.js("showStatistics",o.TYPE.STRING_LIST,{description:e.description,choices:l,inputType:"MultiChoice",friendlyName:"Statistics"}):"showLabels"===e.name?o.Property.js("showLabels",o.TYPE.STRING_LIST,{description:e.description,choices:u,inputType:"MultiChoice",friendlyName:"Labels"}):e)}function h(e,t){let n=[];for(let o of t){var r;let t=o;for(let n of null!=(r=e.series)?r:[]){let e=(0,s.Wh)((0,i.zB)(n),o);if(e){t=e.name;break}}n.includes(t)||n.push(t)}return n}function g(e,t){let n=s.IL.filter(e=>"columnName"!==e.name).filter(t=>{var n;return"droplines"!==t.name||(null!=(n=e.series)?n:[]).some(e=>(0,i.zB)(e).hasAsymptotes)}),r=[...new Set([...t?[t.name]:[],...Object.keys(s.rT)])];return n.map(e=>{var n;return"fitFunction"!==e.name?e:o.Property.js("fitFunction",o.TYPE.STRING,{category:"Fitting",choices:r,nullable:!1,defaultValue:null!=(n=null==t?void 0:t.name)?n:s.hD})})}function v(e,t,n){var r,o,l;let i=null!=(o=(r=null!=(l=e.explicit)?l:e.explicit={})[t])?o:r[t]=[];i.includes(n)||i.push(n)}function y(e,t,n){var r;let o=null==(r=e.explicit)?void 0:r[t];return!!(null==o?void 0:o.includes(n))&&(o.splice(o.indexOf(n),1),!0)}function C(e,t){return"fitFunction"===e&&"string"==typeof t&&s.HM[t]?s.HM[t]:t}function b(e,t,n,r){var o,i,a;let s,m=t.property.name,p=d.includes(m);if("Cell"===r){let r;if(!(0,f.XN)(e.cell.column))return;let o=e.cell.value;if(""===o)return;try{r=null!=(i=JSON.parse(null!=o?o:"{}"))?i:{}}catch(e){l.shell.error(`Curves: this cell holds malformed data, so the option was not applied: ${e}`);return}!function(e,t,n){let r=t.property.name,o=C(r,t.value);if(n===c.ab){if(void 0===e.chartOptions)return;e.chartOptions[r]=o}else{if(void 0===e.series)return;for(let t of e.series)t[r]=o}v(e,n,r)}(r,t,n),e.cell.column.set(e.cell.rowIndex,JSON.stringify(r),p),p||e.cell.dataFrame.fireValuesChanged(),e.grid.invalidate();return}let h="Dataframe"===r?(0,c.Ig)(e.cell.dataFrame):(0,c.bc)(e.cell.column);for(let l of((null!=(o=h[n])?o:h[n]={})[m]=C(m,t.value),v(h,n,m),"Dataframe"===r?((0,c.G_)(e.cell.dataFrame.tags,h),s=e.cell.dataFrame.columns.bySemTypeAll(u.h.FIT_SEM_TYPE)):((0,c.G_)(e.cell.column.tags,h),s=[e.cell.column]),s)){if("Dataframe"===r){let e=(0,c.bc)(l),t=e[n];t&&delete t[m],y(e,n,m),(0,c.G_)(l.tags,e)}if((0,f.XN)(l))for(let e=0;e<l.length;e++){let t,r=l.get(e);if(""!==r){try{t=null!=(a=JSON.parse(r))?a:{}}catch(e){continue}y(t,n,m)&&l.set(e,JSON.stringify(t),!1)}}}if(p)for(let e of s)e.fireValuesChanged();p||e.cell.dataFrame.fireValuesChanged(),e.grid.invalidate()}},129(e,t,n){"use strict";n.d(t,{l:()=>v});var r=n(82),o=n(328),l=n(533),i=n(165),a=n(788),u=n(684),s=n(663),c=n(434),f=n(53),d=n(324),m=n(476);function p(e,t,n,r,o,l,i){try{var a=e[l](i),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function h(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function g(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}class v extends r.GridCellRenderer{get name(){return a.h.FIT_CELL_TYPE}get cellType(){return a.h.FIT_CELL_TYPE}get defaultHeight(){return a.h.CELL_DEFAULT_HEIGHT}get defaultWidth(){return a.h.CELL_DEFAULT_WIDTH}getDefaultSize(e){return{width:a.h.CELL_DEFAULT_WIDTH,height:a.h.CELL_DEFAULT_HEIGHT}}static inflateScreenBounds(e){return(0,d.fn)(e)}onClick(e,t){(0,m.hC)(e,t)}onDoubleClick(e,t){(0,m.I4)(e,void 0,!0),t.preventDefault(),t.stopPropagation()}onMouseMove(e,t){(0,m.fU)(e,t,this)}hasContextValue(e){return!!e.cell.value}getContextValue(e){var t;return(t=function*(){return(0,m.dA)(e)},function(){var e=this,n=arguments;return new Promise(function(r,o){var l=t.apply(e,n);function i(e){p(l,r,o,i,a,"next",e)}function a(e){p(l,r,o,i,a,"throw",e)}i(void 0)})})()}layOutChart(e,t,n,o,a){var u,s,c,m,p,v,y,C,b,x,w,T,I;let _=(null==n?void 0:n.grid)&&(null==n?void 0:n.grid.dart)&&a===(null==n||null==(c=n.grid)?void 0:c.canvas)&&!(null==(m=t.chartOptions)?void 0:m.mergeSeries),O=null==n?void 0:n.cell;(null==(p=t.chartOptions)?void 0:p.allowXZeroes)&&(null==(v=t.chartOptions)?void 0:v.logX)&&(null==(y=t.series)?void 0:y.some(e=>e.points.some(e=>0===e.x)))&&(0,f.B3)(t);let E=(0,d.lc)(e,t),[P,S,N]=(0,d.Tv)(e,E.x,E.y,(0,d.ij)(e,t)),A=(0,i.s$)(t);(A.x<0&&t.chartOptions||0===A.x&&t.chartOptions&&!t.chartOptions.allowXZeroes)&&(t.chartOptions.logX=!1),A.y<=0&&t.chartOptions&&(t.chartOptions.logY=!1);let L={logX:null==(C=t.chartOptions)?void 0:C.logX,logY:null==(b=t.chartOptions)?void 0:b.logY},M=[];for(let e=0;e<(null==(x=t.series)?void 0:x.length);e++){let n=t.series[e];if(n.points.some(e=>void 0===e.x||void 0===e.y)||n.points.length<=1){M.push(null);continue}n.points.sort((e,t)=>e.x-t.x);let r=(0,i.zB)(n),l=null,a=n,u=!0;if(!(n.connectDots&&!(null==(I=n.showFitLine)||I)))if(n.parameters)a=(0,i.iK)(n,L),l=(0,i._T)(a,r);else{let t=(0,f.IY)(n,e,r,L,O,_,null==o?void 0:o[e]);l=t.fittedCurve,a=g(h({},n),{parameters:[...t.parameters]}),u=!1}M.push({fitFunc:r,curve:l,fitSpaceSeries:a,userParamsFlag:u})}A=function(e,t,n){var o,l;let i=null!=(o=null==n?void 0:n.logX)&&o,a=null!=(l=null==n?void 0:n.logY)&&l,u=e.minY,s=e.maxY;for(let n of t)if(n)for(let t=0;t<=100;t++){let r=t/100,o=i?e.minX*Math.pow(e.maxX/e.minX,r):e.minX+e.width*r,l=n(i?Math.log10(o):o),c=a?Math.pow(10,l):l;isFinite(c)&&(u=Math.min(u,c),s=Math.max(s,c))}if((null==n?void 0:n.minY)!=null&&(u=e.minY),(null==n?void 0:n.maxY)!=null&&(s=e.maxY),u>=e.minY&&s<=e.maxY)return e;if(a&&e.minY>0){let t=(Math.log10(e.maxY)-Math.log10(e.minY))*.15;u=Math.max(u,Math.pow(10,Math.log10(e.minY)-t)),s=Math.min(s,Math.pow(10,Math.log10(e.maxY)+t))}else u=Math.max(u,e.minY-.15*e.height),s=Math.min(s,e.maxY+.15*e.height);if(u>=e.minY&&s<=e.maxY)return e;let c=s-u,f=u<e.minY?a&&u>0?u/1.05:u-.05*c:e.minY,d=s>e.maxY?a?1.05*s:s+.05*c:e.maxY;return new r.Rect(e.x,f,e.width,d-f)}(A,M.map(e=>(null==e?void 0:e.fitFunc.hasAsymptotes)?e.curve:null),t.chartOptions);let R=new l.L(A,P,null!=(u=null==(w=t.chartOptions)?void 0:w.logX)&&u,null!=(s=null==(T=t.chartOptions)?void 0:T.logY)&&s);return{dataBox:P,xAxisBox:S,yAxisBox:N,dataBounds:A,fits:M,chartLogOptions:L,useFitCache:_,tableCell:O,viewport:R}}renderCurves(e,t,n,o,l){var i,m,p,h,g,v,y,C,b,x,w,T,I,_,O;e.save(),e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.clip();let{dataBox:E,xAxisBox:P,yAxisBox:S,dataBounds:N,fits:A,chartLogOptions:L,useFitCache:M,tableCell:R,viewport:F}=this.layOutChart(t,n,o,l,e.canvas),X=Math.min(E.width,E.height),D=X>100?1:.2+X/100*.8,Y=(0,s.qd)(n,t)?[]:void 0;e.save(),e.font='11px Roboto, "Roboto Local"',F.drawCoordinateGrid(e,P,S),e.restore();let j=(0,u.S3)(e,null==(p=n.chartOptions)?void 0:p.labels,{names:null==(h=n.chartOptions)?void 0:h.showLabels,color:a.h.PLOT_LABEL_COLOR,dataBox:E,screenBounds:t,startLine:0,drawnAt:Y}),G=(null!=(i=null==(g=n.series)?void 0:g.length)?i:0)>1&&null!=(m=null==(v=n.chartOptions)?void 0:v.statisticsMode)?m:"series",H=null==(y=n.chartOptions)?void 0:y.showStatistics;if((null==H?void 0:H.length)&&"series"!==G){let r=null!=(T=null==(I=n.chartOptions)?void 0:I.aggrType)?T:"med",o=(0,c.JR)(n,r,R),l=Object.fromEntries(H.map(e=>[`${r} ${e}`,o[e]]));j+=(0,u.S3)(e,l,{names:Object.keys(l),color:a.h.PLOT_LABEL_COLOR,dataBox:E,screenBounds:t,startLine:j,drawnAt:Y})}for(let o=0;o<(null==(C=n.series)?void 0:C.length);o++){let l=n.series[o],i=A[o];if(!i)continue;let{fitFunc:s,curve:c,fitSpaceSeries:m,userParamsFlag:p}=i,h=a.h.POINT_PX_SIZE*D/2,g=E.inflate(h,h);if(e.save(),e.beginPath(),e.rect(g.x,g.y,g.width,g.height),e.clip(),(0,u.qR)(e,l,{viewport:F,ratio:D,logOptions:L,showAxes:(0,d.b1)(t),showAxesLabels:(0,d.eG)(t,n),screenBounds:t,curveFunc:c,seriesIdx:o,drawnAt:Y}),(0,u.nx)(e,l,{viewport:F,ratio:D,seriesIdx:o}),(0,u.QW)(e,l,{viewport:F,ratio:D,screenBounds:t,seriesIdx:o}),Y){let e=null;for(let t of l.points){if(t.outlier&&!(null==(O=l.showOutliers)||O))continue;let n=new r.Point(F.xToScreen(t.x),F.yToScreen(t.y));if(Y.push(n),e){let t=Math.floor(Math.abs(n.x-e.x)/u.dT);for(let o=1;o<t;o++)Y.push(new r.Point(e.x+(n.x-e.x)*o/t,e.y+(n.y-e.y)*o/t))}e=n}}(0,u.Zk)(e,m,{viewport:F,logOptions:L,showAxes:(0,d.b1)(t),showAxesLabels:(0,d.eG)(t,n),screenBounds:t,fitFunc:s,userParamsFlag:p,drawnAt:Y,dataPoints:(0,f.Xm)(l,o,L,p,R,M)}),(0,u.HQ)(e,m,{viewport:F,ratio:D,showDroplines:(0,d.m)(t),showDroplineLabels:(0,d.W$)(t),fitFunc:s,dataBounds:N,curveFunc:c,logOptions:L,drawnAt:Y}),e.restore(),j+=(0,u.yv)(e,m,{statistics:"aggregated"===G?[]:H,fitFunc:s,logOptions:L,dataBox:E,screenBounds:t,seriesIdx:o,startLine:j,drawnAt:Y}),j+=(0,u.S3)(e,l.labels,{names:null==(_=n.chartOptions)?void 0:_.showLabels,color:(0,u.Z)(l,o,u.mE.FIT_LINE),dataBox:E,screenBounds:t,startLine:j,drawnAt:Y})}(0,u.zF)(e,{showTitle:(0,d.ij)(t,n),title:null==(b=n.chartOptions)?void 0:b.title,dataBox:E,screenBounds:t}),(0,u.jI)(e,{showTitle:(0,d.ij)(t,n),dataBox:E,screenBounds:t,showAxesLabels:(0,d.eG)(t,n),xAxisName:null==(x=n.chartOptions)?void 0:x.xAxisName,yAxisName:null==(w=n.chartOptions)?void 0:w.yAxisName}),Y&&(0,s.GU)(e,n,E,D,Y),e.restore()}render(e,t,n,o,l,i,u){var s,c,d,m,p,y;if(!i.cell.value||o<a.h.MIN_CELL_RENDERER_PX_WIDTH||l<a.h.MIN_CELL_RENDERER_PX_HEIGHT)return;let C=(null==i?void 0:i.grid)&&(null==i?void 0:i.grid.dart)&&e.canvas===(null==i||null==(s=i.grid)?void 0:s.canvas),b=(0,f.h8)(i.cell,C),x=v.inflateScreenBounds(new r.Rect(t,n,o,l));for(let[t,n]of Object.entries(a.h.CONDITION_MAP))if(n(b.series)){return void(p=e,y=x,r.Paint.marker(p,r.MARKER_TYPE.OUTLIER,y.midX,y.midY,r.Color.red,Math.min(Math.max(.8*Math.min(y.width,y.height),0),30)))}(null==(c=i.cell.column)?void 0:c.name)&&(null==(d=b.series)||d.forEach(e=>e.columnName=i.cell.column.name)),(null==(m=b.chartOptions)?void 0:m.mergeSeries)&&(b=g(h({},b),{series:[(0,f.wU)(b.series)]})),e.clearRect(x.x,x.y,x.width,x.height),this.renderCurves(e,x,b,i)}}v.fittedCurves=f.bZ,v.parsedCurves=f.uc,v.curvesDataPoints=f.CP,v=function(e,t,n,r){var o,l=arguments.length,i=l<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(l<3?o(i):l>3?o(t,n,i):o(t,n))||i);return l>3&&i&&Object.defineProperty(t,n,i),i}([o.decorators.cellRenderer({name:"Fit",cellType:"fit",virtual:!0})],v)},434(e,t,n){"use strict";n.d(t,{JR:()=>p,TV:()=>f,Uc:()=>m,bW:()=>g,i4:()=>v});var r=n(82),o=n(165),l=n(590),i=n(869),a=n(53),u=n(124);let s={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"},c=new Set(["min","max","avg","med","q1","q2","q3"]);function f(e,t,n,r,l=!0,i=!0){var u,s;let c=(0,o.zB)(e),d=e.parameters?(0,o.iK)(e,n):(u=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e),s=s={parameters:[...(0,a.IY)(e,t,c,n,r,l).parameters]},Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(s)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(s)).forEach(function(e){Object.defineProperty(u,e,Object.getOwnPropertyDescriptor(s,e))}),u),m=(0,o.xS)(d,c,(0,a.Xm)(e,t,n,!1,r,l),n);return i?(0,o.KZ)(m,n):m}let d=new Set(o.GO);function m(e,t){var n;let r=null!=(n=e.series)?n:[];if(!r.length)return l.nK;let i=[...(0,o.zB)(r[0]).statisticsProperties];for(let e=1;e<r.length;e++){let t=new Set((0,o.zB)(r[e]).statisticsProperties.map(e=>e.name));i=i.filter(e=>t.has(e.name))}return void 0===t||c.has(t)||(i=i.filter(e=>!d.has(e.name))),i}function p(e,t,n){var a,u,d;let p={logX:null==(a=e.chartOptions)?void 0:a.logX,logY:null==(u=e.chartOptions)?void 0:u.logY},h=new Map,g=[],v=new Set(m(e,t).map(e=>e.name));for(let t=0;t<(null==(d=e.series)?void 0:d.length);t++){let r=e.series[t];if(r.points.every(e=>e.outlier))continue;let a=(0,o.zB)(r);g.push(a);let u=f(r,t,p,n,!0,!1);for(let e of a.statisticsProperties)v.has(e.name)&&(h.has(e.name)||h.set(e.name,[]),h.get(e.name).push((0,i.h5)(u,e.name)));for(let e of l.Al){if(v.has(e))continue;let t=(0,i.Wh)((0,o.zB)(r),e);t&&t.name!==e||(h.has(e)||h.set(e,[]),h.get(e).push((0,i.h5)(u,e)))}}let y={};for(let[e,n]of h)y[e]=n.some(e=>null==e||isNaN(e))?void 0:r.Stats.fromValues(n)[s[t]];for(let e of(c.has(t)&&(0,o.KZ)(y,p),l.Al))if(void 0===y[e])for(let t of g){let n=(0,i.Wh)(t,e);if(n&&void 0!==y[n.name]){y[e]=y[n.name];break}}return y}function h(e,t,n){var r,o,l;let i=e.get(t);if(null==i||""===i)return null;let s=e.dataFrame?e.dataFrame.cell(t,e.name):void 0,c=s?(0,a.h8)(s,!0):(0,a.mI)((0,u.HB)((0,a.RH)(i),e),e,n);return(null==(r=c.chartOptions)?void 0:r.allowXZeroes)&&(null==(o=c.chartOptions)?void 0:o.logX)&&(null==(l=c.series)?void 0:l.some(e=>e.points.some(e=>0===e.x)))&&(0,a.B3)(c),{data:c,cell:s}}function g(e,t,n,r,o){var l,a,u,s;let c=h(e,t,o);if(!c)return null;let d=null==(a=c.data.series)?void 0:a[r];if(!d||d.points.every(e=>e.outlier))return null;let m={logX:null==(u=c.data.chartOptions)?void 0:u.logX,logY:null==(s=c.data.chartOptions)?void 0:s.logY};return null!=(l=(0,i.h5)(f(d,r,m,c.cell,!0),n))?l:null}function v(e,t,n,r,o){var l,i;let a=h(e,t,o);return!a||(null==(i=a.data.series)?void 0:i.every(e=>e.points.every(e=>e.outlier)))?null:null!=(l=p(a.data,r,a.cell)[n])?l:null}},684(e,t,n){"use strict";n.d(t,{S3:()=>E,QW:()=>C,zF:()=>S,jI:()=>N,Z:()=>v,yv:()=>P,Yc:()=>g,dT:()=>d,mE:()=>h,nx:()=>y,HQ:()=>_,Zk:()=>T,qR:()=>w});var r,o=n(82),l=n(165),i=n(788),a=n(18);let u="u">typeof window?window:n.g.window,s=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2});class c{static getUniqueName(e,t,n){return u.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 escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\\/-]/g,"\\$&")}static isEmpty(e){return null==e||""==e}static formatNumber(e){return s.format(e)}}var f=n(869);let d=8,m='11px Roboto, "Roboto Local"';function p(e,t,n,r,l){if(!e)return;let i=t.measureText(n).width;for(let t=r;t<=r+i;t+=d)e.push(new o.Point(t,l))}var h=((r={}).POINT="pointColor",r.OUTLIER="outlierColor",r.FIT_LINE="fitLineColor",r);function g(e){return null!=e&&""!==e&&void 0!==o.Color.fromHtml(e)}function v(e,t,n){let r=o.Color.toHtml("outlierColor"===n?o.Color.red:o.Color.getCategoricalColor(t));return e[n]&&o.Color.fromHtml(e[n])?e[n]:r}function y(e,t,n){var r;if(null!=(r=t.connectDots)&&r){let r=n.viewport;e.strokeStyle=v(t,n.seriesIdx,"pointColor"),e.lineWidth=2*n.ratio,e.beginPath();for(let n=0;n<t.points.length;n++){let o=t.points[n].x,l=t.points[n].y,i=r.xToScreen(o),a=r.yToScreen(l);0===n?e.moveTo(i,a):e.lineTo(i,a)}e.stroke()}}function C(e,t,n){var r;let l=n.screenBounds;(l.width<i.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||l.height<i.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT?"":null!=(r=t.showPoints)?r:"points")&&(e.strokeStyle=v(t,n.seriesIdx,"pointColor"),t.connectDots||"points"===t.showPoints?function(e,t,n){let r=n.ratio,l=i.h.POINT_PX_SIZE*r,a=n.viewport,u=t.connectDots,s=v(t,n.seriesIdx,"pointColor"),c=v(t,n.seriesIdx,"outlierColor");for(let p=0;p<t.points.length;p++){let h=t.points[p];if(h.outlier&&!t.showOutliers)continue;let g=a.xToScreen(h.x),v=a.yToScreen(h.y),y=u?s:h.outlier?h.outlierColor&&o.Color.fromHtml(h.outlierColor)?h.outlierColor:c:h.color&&o.Color.fromHtml(h.color)?h.color:s,C=h.marker?h.marker:t.markerType,b=h.outlierMarker?h.outlierMarker:t.outlierMarkerType,x=Math.min(i.h.OUTLIER_PX_SIZE*r,a.screen.height/10),w=u?l:h.outlier?x:h.size?h.size:l,T=u?C:h.outlier?b:C;if(o.Paint.marker(e,T,g,v,y,w),h.stdev&&!h.outlier){var f,d,m;let t=w/2,l=(f=a.yToScreen(h.y+h.stdev),d=a.yToScreen(h.y-h.stdev),v-f<=t?null:{top:[f,v-t],bottom:[v+t,d]});l&&(null==(m=n.drawnAt)||m.push(new o.Point(g,l.top[0]),new o.Point(g,l.bottom[1])),e.strokeStyle=y,e.lineWidth=r,e.beginPath(),e.moveTo(g,l.top[0]),e.lineTo(g,l.top[1]),e.moveTo(g,l.bottom[0]),e.lineTo(g,l.bottom[1]),e.moveTo(g-t,l.top[0]),e.lineTo(g+t,l.top[0]),e.moveTo(g-t,l.bottom[1]),e.lineTo(g+t,l.bottom[1]),e.stroke())}}}(e,t,n):["candlesticks","both"].includes(t.showPoints)&&function(e,t,n){let r=n.ratio,l=n.viewport,u=v(t,n.seriesIdx,"pointColor");for(let n=0,s=null;n<t.points.length;n++){let c=t.points[n];if(c.outlier)continue;let f=n+1<t.points.length&&t.points[n+1].x===c.x;if(!s&&f)s=n;else if(null!==s&&!f){let f=[];for(let e=s,r=0;e<=n;e++,r++)f[r]=t.points[e].y;let d=(0,a.k)(f);if(e.beginPath(),function(e,t){let n=t.viewport,r=t.x,l=n.xToScreen(r),a=t.boxPlotStats;b(e,r,a.lowerAdjacentValue,n),e.moveTo(l,n.yToScreen(a.lowerAdjacentValue)),e.lineTo(l,n.yToScreen(a.upperAdjacentValue)),b(e,r,a.upperAdjacentValue,n),o.Paint.marker(e,o.MARKER_TYPE.CIRCLE,l,n.yToScreen(a.q2),t.color,i.h.CANDLESTICK_MEDIAN_PX_SIZE*t.ratio)}(e,{viewport:l,ratio:r,x:c.x,boxPlotStats:d,color:u}),e.stroke(),"both"===t.showPoints)for(let t=0;t<f.length;t++)(f[t]<d.lowerAdjacentValue||f[t]>d.upperAdjacentValue)&&o.Paint.marker(e,o.MARKER_TYPE.OUTLIER,l.xToScreen(c.x),l.yToScreen(f[t]),u,i.h.CANDLESTICK_OUTLIER_PX_SIZE*r);s=null}}}(e,t,n))}function b(e,t,n,r){let o=r.xToScreen(t),l=r.yToScreen(n);e.moveTo(o-i.h.CANDLESTICK_BORDER_PX_SIZE/2,l),e.lineTo(o+i.h.CANDLESTICK_BORDER_PX_SIZE/2,l)}function x(e){let t=e.logOptions.logX,n=e.logOptions.logY,r=e.viewport;return{logX:t,logY:n,xMin:r.screen.left,xMax:r.screen.maxX,viewport:r}}function w(e,t,n){var r;if(null==(r=t.showFitLine)||r){e.save(),e.strokeStyle=v(t,n.seriesIdx,"fitLineColor"),e.lineWidth=2*n.ratio,e.beginPath(),t.lineStyle&&e.setLineDash(i.h.LINE_STYLES[t.lineStyle]);let{logX:r,logY:l,xMin:a,xMax:u,viewport:s}=x(n),c=n.curveFunc;for(let t=a;t<=u;t++){let i=r?Math.log10(s.xToWorld(t)):s.xToWorld(t),u=l?s.yToScreen(Math.pow(10,c(i))):s.yToScreen(c(i));n.drawnAt&&t%d==0&&n.drawnAt.push(new o.Point(t,u)),t===a?e.moveTo(t,u):e.lineTo(t,u)}e.stroke(),e.restore()}}function T(e,t,n){var r,o,a,u;if((null==(r=t.showFitLine)||r)&&null!=(o=t.showCurveConfidenceInterval)&&o){e.strokeStyle=null!=(a=t.confidenceIntervalColor)?a:i.h.CONFIDENCE_INTERVAL_STROKE_COLOR,e.fillStyle=null!=(u=t.confidenceIntervalColor)?u:i.h.CONFIDENCE_INTERVAL_FILL_COLOR;let r=n.showAxes,o=n.showAxesLabels,s=n.logOptions,c=n.viewport,f=n.screenBounds,d=n.dataPoints,m=(0,l.fY)(t,n.fitFunc,n.userParamsFlag,d,s);I(e,{viewport:c,logOptions:s,showAxes:r,showAxesLabels:o,screenBounds:f,confidenceIntervals:m,confidenceType:i.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP}),I(e,{viewport:c,logOptions:s,showAxes:r,showAxesLabels:o,screenBounds:f,confidenceIntervals:m,confidenceType:i.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.BOTTOM}),function(e,t){e.beginPath();let{logX:n,logY:r,xMin:o,xMax:l,viewport:i}=x(t),a=t.confidenceIntervals.confidenceTop,u=t.confidenceIntervals.confidenceBottom;for(let t=o;t<=l;t++){let l=n?Math.log10(i.xToWorld(t)):i.xToWorld(t),u=r?i.yToScreen(Math.pow(10,a(l))):i.yToScreen(a(l));t===o?e.moveTo(t,u):e.lineTo(t,u)}for(let t=l;t>=o;t--){let o=n?Math.log10(i.xToWorld(t)):i.xToWorld(t),l=r?i.yToScreen(Math.pow(10,u(o))):i.yToScreen(u(o));e.lineTo(t,l)}e.closePath(),e.fill()}(e,{viewport:c,logOptions:s,showAxes:r,showAxesLabels:o,screenBounds:f,confidenceIntervals:m})}}function I(e,t){e.beginPath();let{logX:n,logY:r,xMin:l,xMax:a,viewport:u}=x(t),s=t.confidenceType===i.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP?t.confidenceIntervals.confidenceTop:t.confidenceIntervals.confidenceBottom;for(let i=l;i<=a;i++){let a=n?Math.log10(u.xToWorld(i)):u.xToWorld(i),c=r?u.yToScreen(Math.pow(10,s(a))):u.yToScreen(s(a));t.drawnAt&&i%d==0&&t.drawnAt.push(new o.Point(i,c)),i===l?e.moveTo(i,c):e.lineTo(i,c)}e.stroke()}function _(e,t,n){var r,l;if(!(null==(r=t.showFitLine)||r)||!(null==(l=t.droplines)?void 0:l.length)||!t.parameters||!n.showDroplines)return;e.save(),e.strokeStyle="blue",e.lineWidth=n.ratio,e.beginPath(),e.setLineDash([5,5]);let i=[];for(let r of t.droplines){let l=function(e){let t=/^(?:IC|EC)(\d{1,2}(?:\.\d+)?)$/i.exec(e),n=t?parseFloat(t[1]):NaN;return n>0&&n<100?n/100:void 0}(r),a=void 0===l?void 0:n.fitFunc.inverse(Float32Array.from(t.parameters),l),u=void 0===a?null:function(e,t,n){let r=n.logOptions.logX,l=n.logOptions.logY,i=r?Math.pow(10,t):t,a=n.viewport,u=n.dataBounds;if(i<u.minX||i>u.maxX)return null;let s=r?Math.log10(i):i,c=l?Math.pow(10,n.curveFunc(s)):n.curveFunc(s),f=a.xToScreen(i),m=a.yToScreen(c),p=a.xToScreen(u.minX),h=a.yToScreen(u.minY);if(e.moveTo(p,m),e.lineTo(f,m),e.lineTo(f,h),n.drawnAt){for(let e=p;e<=f;e+=d)n.drawnAt.push(new o.Point(e,m));for(let e=m;e<=h;e+=d)n.drawnAt.push(new o.Point(f,e))}return m}(e,a,n);null!==u&&i.push({name:r,screenY:u})}if(e.stroke(),t.droplines.length>1&&n.showDroplineLabels){e.setLineDash([]),e.fillStyle="blue",e.font='10px Roboto, "Roboto Local"',e.textAlign="left";let t=n.viewport.xToScreen(n.dataBounds.minX)+2;for(let n of i)e.fillText(n.name,t,n.screenY-3)}e.restore()}function O(e){return 0!==e&&(.001>Math.abs(e)||Math.abs(e)>=1e6)?o.format(e,"scientific"):c.formatNumber(e)}function E(e,t,n){var r,o;let l=n.screenBounds,a=l.width<i.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||l.height<i.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT?[]:n.names;if(!t||!a||0===a.length)return 0;let u=n.dataBox;e.font=m;let s=null!=(r=n.startLine)?r:0;for(let r of a){let o=t[r];if(null==o)continue;let l=u.y+15*(s+1);if(l>u.maxY)break;e.fillStyle=n.color,e.textAlign="left";let i=`${r}: ${"number"==typeof o?O(o):o}`;e.fillText(i,u.x+5,l),p(n.drawnAt,e,i,u.x+5,l),s++}return s-(null!=(o=n.startLine)?o:0)}function P(e,t,n){var r,o,a;let u=n.screenBounds,s=u.width<i.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||u.height<i.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT?[]:n.statistics;if(!((null==(r=t.showFitLine)||r)&&s&&s.length>0))return 0;let c=n.dataBox,d=n.dataPoints,h=n.fitFunc,g=(0,l.KZ)((0,l.xS)(t,h,d,n.logOptions),n.logOptions),y=v(t,n.seriesIdx,"fitLineColor");e.font=m;let C=null!=(o=n.startLine)?o:0;for(let t of s){let r=(0,f.h5)(g,t),o=(0,f.Wh)(h,t);if(void 0===r||!o)continue;let l=c.y+15*(C+1);if(l>c.maxY)break;e.fillStyle=y,e.textAlign="left";let i=`${o.friendlyName}: ${O(r)}`;e.fillText(i,c.x+5,l),p(n.drawnAt,e,i,c.x+5,l),C++}return C-(null!=(a=n.startLine)?a:0)}function S(e,t){t.showTitle&&(e.font='12px Roboto, "Roboto Local"',e.textAlign="center",e.fillStyle="black",e.fillText(t.title,t.dataBox.midX-5,t.screenBounds.y+15))}function N(e,t){if(t.showAxesLabels){let n=t.screenBounds,r=t.dataBox;if(e.font='11px Roboto, "Roboto Local"',e.textAlign="center",e.fillStyle="black",t.xAxisName&&e.fillText(t.xAxisName,r.midX,n.maxY-i.h.X_AXIS_LABEL_BOTTOM_PX_MARGIN),t.yAxisName){e.save(),e.translate(n.x,n.y),e.rotate(-Math.PI/2);let o=t.showTitle?i.h.AXES_TOP_PX_MARGIN_WITH_TITLE:i.h.AXES_TOP_PX_MARGIN;e.fillText(t.yAxisName,-(r.height/2+o),15),e.restore()}}}},886(e,t,n){"use strict";n.d(t,{aI:()=>d,b6:()=>m,fM:()=>f,rn:()=>c});var r=n(82),o=n(590);function l(e,t){let n=[];for(let r=0;r<e.children.length;r++){let o=e.children[r];o.localName===t&&n.push(o)}return n}function i(e,t){for(let n=0;n<e.children.length;n++)if(e.children[n].localName===t)return e.children[n];return null}function a(e,t){var n,r;let o=i(e,t);return null!=(n=null==o||null==(r=o.textContent)?void 0:r.trim())?n:""}function u(e){let t=l(e,"d"),n=[],r=[];for(let e of t){var o,i;let t=null!=(o=null==(i=e.textContent)?void 0:i.trim())?o:"";""===t?(n.push(null),r.push(!1)):(n.push(parseFloat(t)),r.push("1"===e.getAttribute("Excluded")))}return{values:n,excluded:r}}function s(e){return{title:a(e,"Title"),subcolumns:l(e,"Subcolumn").map(u)}}function c(e){let t="</GraphPadPrismFile>",n=e.indexOf(t);-1!==n&&(e=e.substring(0,n+t.length));let r=new DOMParser().parseFromString(e,"text/xml").documentElement;if("parsererror"===r.nodeName)return[];let o=[];for(let e=0;e<r.children.length;e++){let t=r.children[e];("Table"===t.localName||"HugeTable"===t.localName)&&o.push(function(e){var t,n,r;let o=null!=(t=e.getAttribute("ID"))?t:"",c=null!=(n=e.getAttribute("TableType"))?n:"",f=null!=(r=e.getAttribute("XFormat"))?r:"",d=a(e,"Title"),m="",p=[],h=i(e,"XColumn");if(h){m=a(h,"Title");let e=i(h,"Subcolumn");e&&(p=u(e).values)}return{id:o,title:d,tableType:c,xFormat:f,xTitle:m,xValues:p,yColumns:l(e,"YColumn").map(s)}}(t))}return o}function f(e){if("XY"!==e.tableType||0===e.xValues.length)return null;let t=[];for(let n of e.yColumns){let r=[];for(let t of n.subcolumns)for(let n=0;n<e.xValues.length;n++){let o=e.xValues[n];if(null==o||n>=t.values.length)continue;let l=t.values[n];null!=l&&r.push({x:o,y:l,outlier:t.excluded[n]||!1})}0!==r.length&&t.push({name:n.title,fitFunction:o.G7,showFitLine:!0,showPoints:"points",clickToToggle:!0,droplines:["IC50"],points:r})}return 0===t.length?null:{chartOptions:{logX:!0,xAxisName:e.xTitle||"Concentration",yAxisName:"Response",title:e.title},series:t}}function d(e){let t=e.filter(e=>"XY"===e.tableType),n=[],o=[];for(let e of t){let t=f(e);t&&(n.push(e.title||e.id),o.push(JSON.stringify(t)))}let l=r.DataFrame.create(n.length);l.setTag(r.Tags.Id,crypto.randomUUID()),l.name="PZFX Curves";let i=l.columns.addNewString("Table");for(let e=0;e<n.length;e++)i.set(e,n[e]);let a=l.columns.addNewString("Fitted Curve");a.semType="fit",a.meta.cellRenderer="fit";for(let e=0;e<o.length;e++)a.set(e,o[e]);return l}function m(e){let t=Math.max(...e.yColumns.map(e=>Math.max(...e.subcolumns.map(e=>e.values.length),0)),0),n=r.DataFrame.create(t);for(let t of(n.setTag(r.Tags.Id,crypto.randomUUID()),n.name=e.title||e.id,e.yColumns)){var o,l;if(1===t.subcolumns.length){let e=n.columns.addNewFloat(t.title||"Values"),l=t.subcolumns[0];for(let t=0;t<l.values.length;t++)e.set(t,null!=(o=l.values[t])?o:r.FLOAT_NULL)}else for(let e=0;e<t.subcolumns.length;e++){let o=n.columns.addNewFloat(`${t.title}_${e+1}`),i=t.subcolumns[e];for(let e=0;e<i.values.length;e++)o.set(e,null!=(l=i.values[e])?l:r.FLOAT_NULL)}}return n}},644(e,t,n){"use strict";n.r(t),n.d(t,{dataToCurvesTopMenu:()=>E,previewPzfx:()=>D,convertPzfxToJsonFunc:()=>X,addStatisticsColumn:()=>N,addCurveStatistic:()=>L,curveStatistic:()=>P,_initCurves:()=>_,convertCompactDrToJsonFunc:()=>F,addAggrStatisticsColumn:()=>A,dataToCurves:()=>O,Sync:()=>es,pzfxFileHandler:()=>Y,assayCurveFitDemo:()=>I,curveAggrStatistic:()=>S,curveFitDemo:()=>T,_MultiCurveViewer:()=>w,convertXmlCurveToJsonFunc:()=>R,_package:()=>ei,addAggrCurveStatistic:()=>M,PackageFunctions:()=>ec,_FitChartCellRenderer:()=>x});var r=n(82),o=n(389),l=n(328),i=n(53),a=n(590);let u=rxjs.operators;var s=n(858),c=n(788),f=n(129),d=n(476),m=n(663);function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function h(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function g(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}let v=["logX","logY","allowXZeroes","mergeCellSeries","showColumnLabel"];class y extends r.JsViewer{get onRendered(){return this.rendered}get isRenderPending(){return this.renderPending}get trellisProperties(){return["mergeColumnSeries","logX","logY"]}isInTrellis(){let e=this.root,t=0;for(;e&&t<7;){if(e.classList.contains("d4-trellis-plot-cell"))return!0;e=e.parentElement,t++}return!1}static fromChartData(e){let t=new y;return t.data=e,t.render(),t}createGridCell(e){let t=r.GridCell.fromValue(e);return t.cellType=c.h.FIT_CELL_TYPE,t}applyViewerProperties(){(0,i.g2)(a.xs,this,this.data.chartOptions)}mergeViewerChartOptions(){for(let e of a.xs)(v.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)&&(v.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;if((null==(e=this.curvesColumnNames)?void 0:e.length)===0)return;this.rows.length=0;let o=-1;this.isInTrellis()?this.rows.push(...this.dataFrame.filter.getSelectedIndexes()):(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&&(o=this.rows.length,this.rows.push(...this.dataFrame.selection.clone().and(this.dataFrame.filter).getSelectedIndexes()))),this.data=new a.oH;let l=this.props.get("mergeCellSeries"),u=[];for(let e of(this.fitIdentities=[],this.curvesColumnNames)){let t=[],r=[];for(let n of new Set(this.rows)){let o=this.dataFrame.cell(n,e);if(!o||!o.value)continue;let a=(0,i.h8)(o);if(!a.series||0===a.series.length)continue;let s=a.series.map(e=>h(p({},e),{columnName:o.column.name})),c=this.legendColumnName&&this.dataFrame.col(this.legendColumnName)?this.dataFrame.col(this.legendColumnName):null;if(c)for(let e of s)e.auxLegendName=s.length>1?`${c.get(n)} ${e.name}`:`${c.get(n)}`;let f=a.chartOptions;if(null!=f&&(u[u.length]=f),l){let e=(0,i.wU)(s);(null==f?void 0:f.title)!==void 0&&(null==f?void 0:f.title)!==""&&(e.name=null==f?void 0:f.title),s=[e]}let d=(0,i.U6)(a);r.push(...s.map((e,t)=>`${d} || idx: ${l?"merged":t}`)),t.push(...s)}0!==t.length&&(null==(n=this.data.series)||n.push(...JSON.parse(JSON.stringify(this.mergeColumnSeries?[(0,i.wU)(t)]:t))),this.fitIdentities.push(...this.mergeColumnSeries?[void 0]:r))}for(let e of(this.data.chartOptions=(0,i.LX)(u,this.data.series),this.data.chartOptions.useAuxLegendNames=!0,this.mergeViewerChartOptions(),["title","xAxisName","yAxisName"]))void 0===this[e]&&void 0!==this.data.chartOptions[e]&&(this[e]=this.data.chartOptions[e]);null==(t=this.data.series)||t.forEach((e,t)=>{var n,l,i,a,u;if(e.fitLineColor||e.pointColor||(e.pointColor=r.Color.toHtml(r.Color.getCategoricalColor((null==(a=this.data.series)?void 0:a.length)>20?0:t)),e.fitLineColor=r.Color.toHtml(r.Color.getCategoricalColor((null==(u=this.data.series)?void 0:u.length)>20?0:t))),e.showOutliers=this.showOutliers,e.showCurveConfidenceInterval=!1,e.droplines=[],(null==(n=this.data.series)?void 0:n.length)>20&&(e.showPoints="",e.lineStyle="solid"),(null==(l=this.data.series)?void 0:l.length)>10&&(null==(i=this.data.series)?void 0:i.length)<100&&t>=o){let t=r.Color.fromHtml(e.fitLineColor);e.fitLineColor=`rgba(${r.Color.r(t)}, ${r.Color.g(t)}, ${r.Color.b(t)}, 0.2)`}})}onPropertyChanged(e){var t,n,r,o,l;(null==e?void 0:e.name)==="curvesColumnNames"&&(this.props.set("showColumnLabel",(null==(o=this.curvesColumnNames)?void 0:o.length)>1),this.showColumnLabel=(null==(l=this.curvesColumnNames)?void 0:l.length)>1),v.includes((null==e?void 0:e.name)==="mergeSeries"?"mergeCellSeries":null!=(t=null==e?void 0:e.name)?t:"")&&(this[(null==e?void 0:e.name)==="mergeSeries"?"mergeCellSeries":null!=(n=null==e?void 0:e.name)?n:""]=this[null!=(r=null==e?void 0:e.name)?r:""]),this.applyViewerProperties(),this.createChartData(),this.render()}onTableAttached(){var e;let t=null==(e=this.tableView)?void 0:e.grid,n=this.dataFrame.columns.bySemType(c.h.FIT_SEM_TYPE);null!==n&&(this.curvesColumnNames=[n.name]),this.subs.push((0,s.merge)(this.dataFrame.onCurrentCellChanged,...t?[t.onCellMouseEnter]:[],this.dataFrame.onSelectionChanged).pipe((0,u.tap)(()=>this.renderPending=!0),(0,u.debounce)(e=>(0,s.interval)(50))).subscribe(e=>{this.renderPending=!1,this.dataFrame&&(this.createChartData(),this.render())})),this.createChartData(),this.isInTrellis()||this.render()}_showErrorMessage(e){this.root.appendChild(o.divText(e,"d4-viewer-error"))}_removeErrorMessage(){let e=this.root.getElementsByClassName("d4-viewer-error")[0];e&&this.root.removeChild(e)}render(){var e,t,n;let r=this.canvas.getContext("2d");r.clearRect(0,0,this.canvas.width,this.canvas.height),this._removeErrorMessage(),(null==(e=this.curvesColumnNames)?void 0:e.length)===0?this._showErrorMessage("The MultiCurveViewer viewer requires a minimum of 1 curves column."):(null==(n=this.data)||null==(t=n.series)?void 0:t.length)===0?this._showErrorMessage("No data to show."):new f.l().renderCurves(r,this.chartBounds(),this.data,void 0,this.fitIdentities),this.rendered.next()}chartBounds(){return new r.Rect(0,0,this.canvas.width,this.canvas.height)}getWidgetStatus(){var e,t,n,r,o;let l=super.getWidgetStatus(),i=(null==(t=this.curvesColumnNames)?void 0:t.length)===0?0:null!=(e=null==(r=this.data)||null==(n=r.series)?void 0:n.length)?e:0,a=0===i?null:(0,m.QK)(this.data,this.chartBounds()),u=h(p({},l.values),{curves:i,"legend shown":null!==a}),s=p({},l.hitAreas);if(i>0){let e=new f.l().layOutChart(this.chartBounds(),this.data,void 0,this.fitIdentities).dataBounds,t=e=>Number(e.toPrecision(4));u["x range"]=`${t(e.minX)} .. ${t(e.maxX)}`,u["y range"]=`${t(e.minY)} .. ${t(e.maxY)}`;let n=(e,t,n)=>{let r=1e-9*Math.max(Math.abs(n-t),Math.abs(t),Math.abs(n));return e<t-r||e>n+r};u["points outside the axes"]=(null!=(o=this.data.series)?o:[]).reduce((t,r)=>t+r.points.filter(t=>n(t.x,e.minX,e.maxX)||n(t.y,e.minY,e.maxY)).length,0)}if(a){let e=this.canvas.width>0?this.canvas.getBoundingClientRect().width/this.canvas.width:1,t=t=>({x:t.x*e,y:t.y*e,width:t.width*e,height:t.height*e}),n=[];for(let[e,r]of a.rows.entries()){let o=r.shown===r.entry.text;s[`${o?"":"shortened "}legend row ${e+1}`]=t(r.box),u[`legend row ${e+1}`]=r.shown,o||n.push(e+1)}a.moreBox&&(s["legend more"]=t(a.moreBox)),u["legend corner"]=m.$$[a.corner],u["legend rows"]=a.rows.length,u["legend shortened rows"]=n.join(", "),u["legend hidden"]=a.entries.length-a.rows.length}return h(p({},l),{parts:h(p({},l.parts),{canvas:this.canvas}),hitAreas:s,values:u})}constructor(){for(const e of(super(),this.curvesColumnNames=[],this.showSelectedRowsCurves=!0,this.showCurrentRowCurve=!0,this.showMouseOverRowCurve=!0,this.mergeColumnSeries=!1,this.showOutliers=!0,this.rows=[],this.data=new a.oH,this.fitIdentities=[],this.renderPending=!1,this.rendered=new s.Subject,this.gridCellWidget=r.GridCellWidget.fromGridCell(this.createGridCell("")),this.canvas=this.gridCellWidget.canvas,this.root.append(this.gridCellWidget.canvas),o.tools.handleResize(this.root,(e,t)=>{this.canvas.width=e,this.canvas.height=t,this.render()}),this.canvas.addEventListener("mousemove",e=>{var t,n;(null!=(t=null==(n=this.data.series)?void 0:n.length)?t:0)>0&&!(0,d.Oz)(this.data,this.chartBounds(),e,{x:e.offsetX,y:e.offsetY})&&o.tooltip.hide()}),this.canvas.addEventListener("mouseleave",()=>o.tooltip.hide()),this.curvesColumnNames=this.addProperty("curvesColumnNames",r.TYPE.COLUMN_LIST,[],{semType:c.h.FIT_SEM_TYPE}),this.legendColumnName=this.addProperty("legendColumnName",r.TYPE.STRING,"",{description:"Column to be used for curves names"}),this.showSelectedRowsCurves=this.bool("showSelectedRowsCurves",!0,{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),this.showOutliers=this.bool("showOutliers",!0),a.xs)){const t="mergeSeries"===e.name?"mergeCellSeries":e.name,n=this.addProperty(t,e.propertyType,e.defaultValue,h(p({},e.options),{showSlider:!1}));null==n||v.includes(t)||(this[t]=n)}}}function C(e,t,n,r,o,l,i){try{var a=e[l](i),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function b(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function i(e){C(l,r,o,i,a,"next",e)}function a(e){C(l,r,o,i,a,"throw",e)}i(void 0)})}}function x(){return new f.l}function w(){return new y}function T(){return b(function*(){yield ec.curveFitDemo()})()}function I(){return b(function*(){yield ec.assayCurveFitDemo()})()}function _(){return b(function*(){yield ec._initCurves()})()}function O(e,t,n,r,o,l,i,a,u,s,c,f,d,m,p,h,g,v,y){return b(function*(){return yield ec.dataToCurves(e,t,n,r,o,l,i,a,u,s,c,f,d,m,p,h,g,v,y)})()}function E(){return b(function*(){return yield ec.dataToCurvesTopMenu()})()}function P(e,t,n,r){return ec.curveStatistic(e,t,n,r)}function S(e,t,n,r){return ec.curveAggrStatistic(e,t,n,r)}function N(e,t,n,r){return ec.addStatisticsColumn(e,t,n,r)}function A(e,t,n,r){return ec.addAggrStatisticsColumn(e,t,n,r)}function L(e,t,n,r){return ec.addCurveStatistic(e,t,n,r)}function M(e,t,n,r){return ec.addAggrCurveStatistic(e,t,n,r)}function R(){return ec.convertXmlCurveToJsonFunc()}function F(){return ec.convertCompactDrToJsonFunc()}function X(){return ec.convertPzfxToJsonFunc()}function D(e){return b(function*(){return yield ec.previewPzfx(e)})()}function Y(e){return ec.pzfxFileHandler(e)}y=function(e,t,n,r){var o,l=arguments.length,i=l<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(l<3?o(i):l>3?o(t,n,i):o(t,n))||i);return l>3&&i&&Object.defineProperty(t,n,i),i}([l.decorators.viewer({name:"MultiCurveViewer",description:"A viewer that superimposes multiple in-cell curves on one chart",icon:"icons/multi-curve-viewer.png",trellisable:!0}),g("design:type",Function),g("design:paramtypes",[])],y);var j=n(181),G=n(434),H=n(301),k=n(190),V=n(287),B=n(305),q=n(124),$=n(869),W=n(991),U=n.n(W);function Z(e,t,n,r,o,l,i){try{var a=e[l](i),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function z(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function i(e){Z(l,r,o,i,a,"next",e)}function a(e){Z(l,r,o,i,a,"throw",e)}i(void 0)})}}let J="Compound|Assay|Target";function Q(e){return e.split("||").filter(e=>""!==e&&"null"!==e&&"undefined"!==e).join(" | ")}function K(e,t,n,r){let o=e.columns.toList().filter(e=>n(e)).sort((e,t)=>e.name.length-t.name.length).find(e=>r.some(t=>e.name.toLowerCase().includes(t)));o&&(t.value=o)}var ee=n(886);function et(e,t,n,r,o,l,i){try{var a=e[l](i),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function en(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function i(e){et(l,r,o,i,a,"next",e)}function a(e){et(l,r,o,i,a,"throw",e)}i(void 0)})}}function er(e,t,n,r){var o,l=arguments.length,i=l<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(l<3?o(i):l>3?o(t,n,i):o(t,n))||i);return l>3&&i&&Object.defineProperty(t,n,i),i}function eo(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function el(e,t){return function(n,r){t(n,r,e)}}let ei=new r.Package,ea=".sourceColumn",eu=".statistics";class es{static runWhenDone(e){return en(function*(){return es._currentPromise=es._currentPromise.then(()=>en(function*(){try{return yield e()}catch(e){ei.logger.error(e)}})()),es._currentPromise})()}}es._currentPromise=Promise.resolve();class ec{static curveFitDemo(){return en(function*(){yield(0,H.Z1)()})()}static assayCurveFitDemo(){return en(function*(){yield(0,H.pj)()})()}static _initCurves(){return en(function*(){r.ObjectHandler.register(new j.e),(0,q.l8)("3dx",k.J),(0,q.l8)("compact-dr",V.G),(0,q.l8)("pzfx",B.R),yield(0,q.p)()})()}static dataToCurves(e,t,n,o,i,u,s,c,f,d,m,p,h,g,v,y,C,b,x){return en(function*(){var w,T,I,_,O;let E=d&&C&&b&&e.col(C)&&d.col(b)?{wellLevelCol:e.col(C),parentLevelCol:d.col(b)}:void 0,P=(null!=x?x:[]).map(t=>e.col(t)).filter(e=>null!=e);return O={table:d,fitParamColumns:(null!=m?m:[]).map(e=>null==d?void 0:d.col(e)).filter(e=>null!=e),reportedIC50Column:p&&null!=(w=null==d?void 0:d.col(p))?w:void 0,reportedQualifiedIC50Column:h&&null!=(T=null==d?void 0:d.col(h))?T:void 0,experimentIDColumn:g&&null!=(I=null==d?void 0:d.col(g))?I:void 0,qualifierColumn:v&&null!=(_=null==d?void 0:d.col(v))?_:void 0,additionalColumns:(null!=y?y:[]).map(e=>null==d?void 0:d.col(e)).filter(e=>null!=e)},z(function*(){var d,m,p,h,g,v,y,C,b,x,w,T,I,_,S,N,A,L,M;if(!t||!n||!o)throw l.shell.warning("Please fill all required fields"),Error("Please fill all required fields");let R={},F=null==i?void 0:i.categories,X=null==i?void 0:i.getRawData(),D=t.getRawData(),Y=n.getRawData(),j=null==o?void 0:o.categories,G=null==o?void 0:o.getRawData(),H=null==s?void 0:s.categories,k=null==s?void 0:s.getRawData(),V=null==u?void 0:u.categories,B=null==u?void 0:u.getRawData(),q=null==c?void 0:c.categories,$=null==c?void 0:c.getRawData(),W=i?e=>F[X[e]]:()=>"All",U=f?f.getRawData():null,Z=f?f.categories:null,z=f?f.type==r.COLUMN_TYPE.BOOL?e=>!!U[e]:e=>{var t,n,r;return null!=(t=null==(r=Z[U[e]])||null==(n=r.toLowerCase())?void 0:n.includes("exclude"))&&t}:e=>!1,K=e=>D[e],ee=e=>Y[e],et=e=>j[G[e]],en=s?e=>H[k[e]]:()=>null,er=u?e=>V[B[e]]:()=>null,eo=c?e=>q[$[e]]:()=>null,el=["circle","triangle bottom","star","cross border","diamond","square","triangle left","triangle right","triangle top","asterisk"],ei=0,ea={},eu=!!((null==E?void 0:E.parentLevelCol)&&(null==E?void 0:E.wellLevelCol)),es=null==O||null==(d=O.table)?void 0:d.col(s.name),ec=null==O||null==(m=O.table)?void 0:m.col(i.name),ef=null==O||null==(p=O.table)?void 0:p.col(c.name),ed=null==O||null==(h=O.table)?void 0:h.col(u.name),em=e=>`${en(e)}||${W(e)}||${eo(e)}`,ep=e=>`${em(e)}||${er(e)}`,eh=eu?e=>`${E.wellLevelCol.get(e)}`:e=>ep(e),eg=eu?e=>`${E.parentLevelCol.get(e)}`:es&&ec&&ef&&ed?e=>{var t,n,r,o;return`${null==(t=O.table)?void 0:t.col(s.name).get(e)}||${null==(n=O.table)?void 0:n.col(i.name).get(e)}||${null==(r=O.table)?void 0:r.col(c.name).get(e)}||${null==(o=O.table)?void 0:o.col(u.name).get(e)}`}:e=>null,ev={};if(O)for(let e=0;e<(null!=(g=null==(v=O.table)?void 0:v.rowCount)?g:0);e++){let t=eg?eg(e):null;t&&!ev[t]&&(ev[t]={fitParams:null!=(y=null==(b=O.fitParamColumns)?void 0:b.map(t=>t.get(e)))?y:[],fitFunction:null!=(C=O.fitFunction)?C:a.Qx,reportedIC50:O.reportedIC50Column?O.reportedIC50Column.get(e):void 0,reportedQualifiedIC50:O.reportedQualifiedIC50Column?O.reportedQualifiedIC50Column.get(e):void 0,experimentID:O.experimentIDColumn?O.experimentIDColumn.get(e):void 0,qualifier:O.qualifierColumn?O.qualifierColumn.get(e):void 0,additionalColumns:O.additionalColumns?Object.fromEntries(O.additionalColumns.map(t=>[t.name,t.get(e)])):void 0})}for(let t=0;t<e.rowCount;t++){let e=W(t),n=et(t),o=K(t),l=ee(t),i=z(t),a=en(t),u=eo(t),s=null!=(x=er(t))?x:"",c=em(t),f=eh(t),d=ep(t);if(!R[f]){if(R[f]={name:d,x:[],y:[],outliers:[],groupKey:c,runID:s,info:{"Assay Name":e,"Batch ID":n,"Compound ID":a,"Target Entity":u,"Run ID":s,"Max Percent Inhibition":null}},P)for(let e of P){let n=e.name;for(;n in R[f].info;)n=`${n} (1)`;R[f].info[n]=e.get(t)}if(O&&ev[f]){if(R[f].info["Reported IC50"]=ev[f].reportedIC50,R[f].info["Qualified Reported IC50"]=ev[f].reportedQualifiedIC50,R[f].info["Experiment ID"]=ev[f].experimentID,R[f].info.Qualifier=ev[f].qualifier,ev[f].additionalColumns&&Object.assign(R[f].info,ev[f].additionalColumns),ev[f].fitParams&&ev[f].fitParams.length>0)for(let e=0;e<(null!=(T=null==(I=O.fitParamColumns)?void 0:I.length)?T:0);e++){let t=O.fitParamColumns[e].name;R[f].info[t]=ev[f].fitParams[e]}ev[f].groupKey=c}}let m=R[f];m.x.push(o),m.y.push(l),m.outliers.push(i),i||null==l||l==r.FLOAT_NULL||l==r.INT_NULL||(m.info["Max Percent Inhibition"]=Math.max(null!=(w=m.info["Max Percent Inhibition"])?w:-1/0,l))}let ey={},eC=Object.entries(R),eb=[],ex=r.Column.string("Fitted Curve",eC.length);for(let e of(ex.init(e=>{var o,l,i,u,s,c;let[f,d]=eC[e],m=d.x,p=d.y,h=d.outliers,g=d.runID,v=(e=>{if(e in ea)return ea[e];{let t=el[ei];return ea[e]=t,ei=(ei+1)%el.length,t}})(g),y=ev[f]?ev[f].fitParams:void 0,C=(e=>{if(ey[e])return ey[e];let t=r.Color.getCategoricalColor(Object.keys(ey).length);return ey[e]=r.Color.toHtml(t),ey[e]})((null!=(o=d.info["Compound ID"])?o:"")+"||"+(null!=(l=d.info["Assay Name"])?l:"")+"||"+(null!=(i=d.info["Target Entity"])?i:"")),b={fitFunction:(null==ev||null==(c=ev[f])?void 0:c.fitFunction)?ev[f].fitFunction:a.Qx,clickToToggle:!0,droplines:["IC50"],name:`${g}`,points:m.map((e,t)=>({x:e,y:p[t],outlier:h[t],marker:v,size:5})).sort((e,t)=>e.x-t.x),parameters:y,fitLineColor:C,pointColor:r.Color.toHtml(r.Color.gray)};return JSON.stringify({chartOptions:{xAxisName:t.name,yAxisName:n.name,logX:!0,title:Q(`${null!=(u=null!=(s=d.name)?s:f)?u:""}`)},series:[b]})}),eb.push(ex),ex.semType="fit",ex.setTag("cell.renderer","fit"),eb.push(r.Column.fromStrings(J,eC.map(e=>Q(e[1].groupKey)))),eC.reduce((e,t)=>(Object.keys(t[1].info).forEach(t=>e.add(t)),e),new Set))){let t=r.Column.fromStrings(e,eC.map(t=>{var n,r,o;return null!=(n=null==(o=t[1].info[e])||null==(r=o.toString)?void 0:r.call(o))?n:""}));eb.push(t)}let ew=e=>void 0==e||isNaN(e)?void 0:"number"==typeof e&&e!=r.FLOAT_NULL&&e!=r.INT_NULL?e:"string"==typeof e?void 0==Number.parseFloat(e)||isNaN(Number.parseFloat(e))?void 0:Number.parseFloat(e):void 0,eT={};for(let[e,t]of eC){let n=t.groupKey;if(n&&(n in eT||(eT[n]={maxYs:[],reportedIC50s:[],qualifiedIC50s:[]}),eT[n].maxYs.push(Math.max(...t.y.filter((e,n)=>!t.outliers[n]))),O&&ev[e]&&null!=(_=ev[e].reportedQualifiedIC50))&&_){eT[n].qualifiedIC50s.push(ev[e].reportedQualifiedIC50);let t=ew(O.reportedQualifiedIC50Column?ev[e].reportedQualifiedIC50:ev[e].reportedIC50);if(void 0==t)try{t=r.Qnum.parse(O.reportedQualifiedIC50Column?ev[e].reportedQualifiedIC50:ev[e].reportedIC50)}catch(e){}void 0!=t&&eT[n].reportedIC50s.push(t)}}let eI={};for(let e in eT){let t=eT[e];eI[e]=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({"Max Percent Inhibition (Compound | Assay | Target)":t.maxYs.length?null==(S=Math.max(...t.maxYs))?void 0:S.toString():null},O&&O.table?{"Number of total results":null==(N=t.qualifiedIC50s.length)?void 0:N.toString(),"Number of reported results":null==(A=t.reportedIC50s.length)?void 0:A.toString(),"Geomean IC50":t.reportedIC50s.length?null==(L=Math.exp(t.reportedIC50s.reduce((e,t)=>e+Math.log(t),0)/t.reportedIC50s.length)||null)?void 0:L.toString():null,"Standard Deviation":t.reportedIC50s.length>1?null==(M=Math.sqrt(t.reportedIC50s.reduce((e,n)=>e+Math.pow(n-t.reportedIC50s.reduce((e,t)=>e+t,0)/t.reportedIC50s.length,2),0)/(t.reportedIC50s.length-1)))?void 0:M.toString():null,"All Results":t.qualifiedIC50s.join(", ")}:{})}for(let e of Object.keys(eI[Object.keys(eI)[0]])){let t=r.Column.fromStrings(e,eC.map(t=>{var n,r;return null!=(n=null==(r=eI[t[1].groupKey])?void 0:r[e])?n:""}));eb.push(t)}let e_=r.DataFrame.fromColumns(eb);if(e_.name="Fitted Curves",e_.setTag(r.Tags.Id,crypto.randomUUID()),!O||!O.table){let e={interceptX:"IC50",top:"Max",bottom:"Min",slope:"Hill",auc:"AUC"};Object.entries(e).forEach(([e,t])=>{let n={table:e_,colName:ex.name,propName:e,seriesNumber:0};r.Func.find({name:"addStatisticsColumn"})[0].prepare(n).callSync({processed:!1}).getOutputParamValue().name=t}),e.interceptX&&e_.col(e.interceptX)&&(e_.col(e.interceptX).meta.format="scientific")}return e_})()})()}static dataToCurvesTopMenu(){return en(function*(){!function(){let e,t,n,i,a,u,s,c,f,d,m,p,h,g,v,y,C,b,x,w,T,I,_,O,E,P,S=l.shell.tv;if(!S||!S.dataFrame)return l.shell.warning("No open tableview");let N=null,A=null,L=(e=o.divH([],{style:{alignItems:"center"}}),t=null,n=null,i=null,a=null,{form:e,getValues:()=>(null==t?void 0:t.value)&&(null==n?void 0:n.value)?{wellLevelCol:null==t?void 0:t.value,parentLevelCol:null==n?void 0:n.value}:null,getHistory:()=>{var e,r,o,l;return(null==t?void 0:t.value)&&(null==n?void 0:n.value)?{wellLevelCol:null!=(e=null==t||null==(o=t.value)?void 0:o.name)?e:null,parentLevelCol:null!=(r=null==n||null==(l=n.value)?void 0:l.name)?r:null}:null},applyHistory:e=>{e.wellLevelCol&&e.parentLevelCol&&i&&a&&t&&n&&(t.value=i.col(e.wellLevelCol),n.value=a.col(e.parentLevelCol))},onTableChange:(r,l)=>((r,l)=>{if(o.empty(e),!r||!l){t=null,n=null,i=null,a=null;return}i=r,a=l,t=o.input.column("JOIN",{table:r,nullable:!0,tooltipText:"Column to join on from the well level data"}),n=o.input.column("ON",{table:l,nullable:!0,tooltipText:"Column to join on from the parent level data"});let u=U()(l.columns.categorical).map(e=>{let t=e.categories.length;return e.name.toLowerCase().includes("id")&&(t+=10),e.name.toLowerCase().includes("unique")&&(t+=15),{col:e,score:t}}).toArray().sort((e,t)=>t.score-e.score)[0];if((null==u?void 0:u.col)&&u.score>0){n.value=u.col;let e=u.col.name.toLowerCase(),o=U()(r.columns.categorical).filter(t=>t.name.toLowerCase().includes(e)).toArray()[0];o&&(t.value=o)}let s=o.icons.info(()=>{},"Specify the columns that will be used to join the well level data with the parent level data. if not specified, combination of the compound ID, assay name, target entity and run ID will be used for joining.");o.appendAll(e,[s,t.root,n.root])})(r,l)});v=o.input.table("Well Table",{value:l.shell.tv.dataFrame,nullable:!1,tooltipText:"Table with well level data"}),y=o.form([]),(C=()=>{var e,t,n,l,i,a,C,b;let x=v.value;o.empty(y),(()=>{var e,t,n;return L.onTableChange(null!=(e=null==N||null==(n=N.getValues())?void 0:n.table)?e:null,null!=(t=null==A?void 0:A.getTable())?t:null)})(v.value),u=o.input.column("Assay Name",{table:x,nullable:!0,filter:e=>e.isCategorical,tooltipText:"Column with assay names"}),s=o.input.column("Concentration",{table:x,nullable:!1,filter:e=>e.isNumerical,tooltipText:"Column with concentration values"}),c=o.input.column("Readout",{table:x,nullable:!1,filter:e=>e.isNumerical,tooltipText:"Column with readout values"}),f=o.input.column("Outliers",{table:x,nullable:!0,filter:e=>(e.isCategorical||e.type===r.TYPE.BOOL)&&2===e.categories.length,tooltipText:"Column with outliers to exclude from the analysis"}),d=o.input.column("Compound ID",{table:x,nullable:!0,tooltipText:"Column with compound IDs"}),m=o.input.column("Batch ID",{table:x,nullable:!1,tooltipText:"Column with batch IDs. this column along with the Assay column will be used to group the data into curves"}),p=o.input.column("Run ID",{table:x,nullable:!0,tooltipText:"Column with run IDs. this column along with the Assay column will be used to group the data into curves"}),h=o.input.column("Target Entity",{table:x,nullable:!1,filter:e=>e.isCategorical,tooltipText:"Column with target entity names. This column will be used to group the data into curves"}),g=o.input.columns("Additional Columns",{table:x,nullable:!0,tooltipText:"Additional columns to include in the curves data"}),u.value=null!=(e=U()(x.columns.categorical).find(e=>e.name.toLowerCase().includes("assay")&&e.name.toLowerCase().includes("name")))?e:null,s.value=null!=(t=x.columns.firstWhere(e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME&&e.name.toLowerCase().includes("concentration")))?t:null,c.value=null!=(n=x.columns.firstWhere(e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME&&e.name.toLowerCase().includes("inhibition")))?n:null,f.value=null!=(l=x.columns.firstWhere(e=>(e.isCategorical||e.type===r.TYPE.BOOL)&&2===e.categories.length&&(e.name.toLowerCase().includes("outlier")||e.name.toLowerCase().includes("include")&&e.name.toLowerCase().includes("exclude"))))?l:null,d.value=null!=(i=x.columns.firstWhere(e=>e.isCategorical&&e.name.toLowerCase().includes("compound_id")||e.name.toLowerCase().includes("compoundid")||e.name.toLowerCase().includes("compound id")))?i:null,m.value=null!=(a=x.columns.firstWhere(e=>e.name.toLowerCase().includes("batch")&&e.name.toLowerCase().includes("id")))?a:null,p.value=null!=(C=x.columns.firstWhere(e=>(e.name.toLowerCase().includes("run")||e.name.toLowerCase().includes("set"))&&e.name.toLowerCase().includes("id")))?C:null,h.value=null!=(b=x.columns.firstWhere(e=>e.isCategorical&&e.name.toLowerCase().includes("target")&&e.name.toLowerCase().includes("entity")))?b:null,g.value=[],o.appendAll(y,[v.root,u.root,m.root,p.root,s.root,c.root,d.root,h.root,f.root,g.root])})(),v.onChanged.subscribe(()=>C()),N={form:y,getValues:()=>{var e;return{table:v.value,assayCol:u.value,batchIDCol:m.value,concentrationCol:s.value,readoutCol:c.value,compoundIDCol:d.value,excludeOutliersCol:f.value,targetEntityCol:h.value,runIDCol:p.value,additionalColumns:null!=(e=g.value)?e:[]}},applyHistory:e=>{var t;let n=v.value;u.value=e.assayCol?n.col(e.assayCol):null,m.value=e.batchIDCol?n.col(e.batchIDCol):null,s.value=e.concentrationCol?n.col(e.concentrationCol):null,c.value=e.readoutCol?n.col(e.readoutCol):null,d.value=e.compoundIDCol?n.col(e.compoundIDCol):null,f.value=e.excludeOutliersCol?n.col(e.excludeOutliersCol):null,p.value=e.runIDCol?n.col(e.runIDCol):null,h.value=e.targetEntityCol?n.col(e.targetEntityCol):null,g.value=null==(t=e.additionalColumns)?void 0:t.map(e=>n.col(e)).filter(e=>null!=e)}},_=o.input.table("Parent Table",{value:void 0,nullable:!0,tooltipText:"Table with parent data"}),O=o.form([]),E=null,(P=()=>{var e;let t,n,l,i,a,u;if(o.empty(O),O.appendChild(_.root),(()=>{var e,t,n;return L.onTableChange(null!=(e=null==N||null==(n=N.getValues())?void 0:n.table)?e:null,null!=(t=null==A?void 0:A.getTable())?t:null)})(_.value),!_.value){E=null;return}b=o.input.column("Reported IC50",{table:_.value,nullable:!0,tooltipText:"Column with reported IC50 values"}),x=o.input.column("Reported Qualified IC50",{table:_.value,nullable:!0,tooltipText:"Column with reported qualified IC50 values"}),w=o.input.column("Experiment ID",{table:_.value,nullable:!0,tooltipText:"Column with experiment IDs"}),T=o.input.column("Qualifier",{table:_.value,nullable:!0,tooltipText:"Column with qualifier values"}),I=o.input.columns("Additional Columns",{table:_.value,nullable:!0,tooltipText:"Additional columns to include in the curves data"}),K(_.value,b,e=>e.type!==r.COLUMN_TYPE.DATE_TIME,["reported ic50","reported_ic50","reported-ic50"]),K(_.value,x,e=>e.type!==r.COLUMN_TYPE.DATE_TIME,["qualified_reported_ic50","qualified reported ic50","qualified-reported-ic50"]),K(_.value,w,e=>e.isCategorical,["experiment id","experiment_id","experiment-id"]),K(_.value,T,e=>e.isCategorical,["qualifier"]);let s=o.form([b,x,w,T,I]);e=_.value,t=[$.Z2.FOUR_PL_DOSE_RESPONSE,$.Z2.FOUR_PL_REGRESSION],n=o.input.choice("Fit Function",{value:$.Z2.FOUR_PL_DOSE_RESPONSE,items:t,nullable:!1,tooltipText:"Select the fit function to use for the curve fitting"}),l=o.form([]),i=[],(a=o.input.bool("Use Prefit Parameters",{value:!0,tooltipText:"Use selected fit curve parameters instead of fitting the curve from scratch"})).onChanged.subscribe(()=>{i.forEach(e=>e.enabled=a.value)}),n.addOptions(a.captionLabel),n.addOptions(a.input),a.captionLabel.style.color="var(--grey-6)",(u=()=>{o.empty(l);let t=function(e,t){let n=[];switch(t){case $.Z2.FOUR_PL_REGRESSION:case $.Z2.FOUR_PL_DOSE_RESPONSE:default:n.push(o.input.column("Max",{table:e,nullable:!1,tooltipText:"Maximum value for the curve"})),n.push(o.input.column("Hill",{table:e,nullable:!1,tooltipText:"Hill coefficient for the curve"})),n.push(o.input.column("Inflection",{table:e,nullable:!1,tooltipText:"Inflection value for the curve"})),n.push(o.input.column("Min",{table:e,nullable:!1,tooltipText:"Minimum value for the curve"})),K(e,n[0],e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME,["max"]),K(e,n[1],e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME,["hill"]),K(e,n[2],e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME,["inflection"]),K(e,n[3],e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME,["min"])}return n}(e,n.value);i=t,o.appendAll(l,[n.root,...t.map(e=>e.root)]),a.fireChanged()})(),n.onChanged.subscribe(()=>u()),E={form:l,getValues:()=>a.value?i.map(e=>e.value):[],getFitFunction:()=>n.value,getHystory:()=>({fitParamCols:i.map(e=>{var t,n;return null!=(t=null==(n=e.value)?void 0:n.name)?t:""}),fitFunction:n.value,useFitParamCols:a.value}),applyHistory:t=>{var r;if(n.value=t.fitFunction,a.value=t.useFitParamCols,(null==(r=t.fitParamCols)?void 0:r.length)===(null==i?void 0:i.length))for(let n=0;n<i.length;n++){let r=e.col(t.fitParamCols[n]);r&&(i[n].value=r)}}},o.appendAll(O,[s,E.form])})(),_.onChanged.subscribe(()=>P()),A={getValue:()=>({fitParamCols:(null==E?void 0:E.getValues)?E.getValues():null,reportedIC50Col:null==b?void 0:b.value,reportedQualifiedIC50Col:null==x?void 0:x.value,experimentIDCol:null==w?void 0:w.value,qualifierCol:null==T?void 0:T.value,additionalColumns:null==I?void 0:I.value,fitFunction:(null==E?void 0:E.getFitFunction)?E.getFitFunction():null}),form:O,getTable:()=>_.value,getHistory:()=>{var e,t,n,r,o,l,i,a,u,s,c,f;return{tableName:null!=(e=null==(i=_.value)?void 0:i.name)?e:null,reportedIC50Col:null!=(t=null==b||null==(a=b.value)?void 0:a.name)?t:null,reportedQualifiedIC50Col:null!=(n=null==x||null==(u=x.value)?void 0:u.name)?n:null,experimentIDCol:null!=(r=null==w||null==(s=w.value)?void 0:s.name)?r:null,qualifierCol:null!=(o=null==T||null==(c=T.value)?void 0:c.name)?o:null,additionalColumns:null!=(l=null==I||null==(f=I.value)?void 0:f.map(e=>e.name))?l:[],fitParams:(null==E?void 0:E.getHystory)?E.getHystory():null}},applyHistory:e=>{if(e.tableName){let t=l.shell.table(e.tableName);t&&(_.value=t)}_.value&&(e.reportedIC50Col&&_.value.col(e.reportedIC50Col)&&(b.value=_.value.col(e.reportedIC50Col)),e.reportedQualifiedIC50Col&&_.value.col(e.reportedQualifiedIC50Col)&&(x.value=_.value.col(e.reportedQualifiedIC50Col)),e.additionalColumns&&(I.value=e.additionalColumns.map(e=>_.value.col(e)).filter(e=>null!=e)),e.experimentIDCol&&_.value.col(e.experimentIDCol)&&(w.value=_.value.col(e.experimentIDCol)),e.qualifierCol&&_.value.col(e.qualifierCol)&&(T.value=_.value.col(e.qualifierCol)),E&&e.fitParams&&E.applyHistory(e.fitParams))}};let M=o.divH([N.form,A.form],{style:{minWidth:"400px",gap:"20px"}});o.dialog("Data to Curves").add(M).add(L.form).onOK(()=>z(function*(){var e,t,n,o,i,a,u,s,c,f,d;let m,p=N.getValues(),h=A.getTable(),g=A.getValue(),v=g.fitParamCols;h&&v&&v.length>0&&(m={table:h,fitParamColumns:v,fitFunction:g.fitFunction,reportedIC50Column:g.reportedIC50Col,reportedQualifiedIC50Column:g.reportedQualifiedIC50Col,experimentIDColumn:g.experimentIDCol,qualifierColumn:g.qualifierCol,additionalColumns:null!=(d=g.additionalColumns)?d:[]});let y=L.getValues(),{table:C,assayCol:b,batchIDCol:x,concentrationCol:w,readoutCol:T,compoundIDCol:I,excludeOutliersCol:_,runIDCol:O,targetEntityCol:E,additionalColumns:P}=p,S=r.Func.find({name:"dataToCurves"})[0];if(!S)return void l.shell.error("Function dataToCurves not found");let M=S.prepare({df:C,concentrationCol:w,readoutCol:T,batchIDCol:x,assayCol:b,runIDCol:O,compoundIDCol:I,targetEntityCol:E,excludeOutliersCol:_,wellLevelAdditionalColumns:(null!=P?P:[]).map(e=>null==e?void 0:e.name).filter(e=>!!e),parentTable:null==m?void 0:m.table,fitParamColumns:null!=(e=null==m||null==(n=m.fitParamColumns)?void 0:n.map(e=>e.name))?e:[],reportedIC50Column:null==m||null==(o=m.reportedIC50Column)?void 0:o.name,reportedQualifiedIC50Column:null==m||null==(i=m.reportedQualifiedIC50Column)?void 0:i.name,experimentIDColumn:null==m||null==(a=m.experimentIDColumn)?void 0:a.name,qualifierColumn:null==m||null==(u=m.qualifierColumn)?void 0:u.name,additionalColumns:null!=(t=null==m||null==(s=m.additionalColumns)?void 0:s.map(e=>e.name))?t:[],wellLevelJoinCol:null==y||null==(c=y.wellLevelCol)?void 0:c.name,parentLevelJoinCol:null==y||null==(f=y.parentLevelCol)?void 0:f.name}),R=C.tags[r.Tags.CreationScript]&&(!(null==m?void 0:m.table)||m.table.tags[r.Tags.CreationScript]);yield M.call(void 0,void 0,{processed:!R});let F=M.getResultViews()[0];if(F&&F instanceof r.TableView&&F.dataFrame){R||l.shell.addView(F),F.filters();let e=F.trellisPlot({yColumnNames:[J],xColumnNames:[],viewerType:"MultiCurveViewer",showControlPanel:!1,showXLabels:!1,showYLabels:!1,showXSelectors:!1,showYSelectors:!0,packCategories:!0,onClick:"Select"});F.dockManager.dock(e,r.DOCK_TYPE.TOP,F.dockManager.findNode(F.grid.root),"Fitted Curves",.5);let t=F.addViewer(r.VIEWER.GRID,{rowSource:r.RowSet.FilteredSelected,selectedRowsColor:r.Color.white});F.dockManager.dock(t,r.DOCK_TYPE.FILL,F.dockManager.findNode(F.grid.root),"Selected Curves"),t.props.title="Selected Curves";let n=F.addViewer("MultiCurveViewer",{showCurrentRowCurve:!1,showMouseOverRowCurve:!1,showSelectedRowsCurves:!0}),o=F.dockManager.dock(n,r.DOCK_TYPE.FILL,F.dockManager.findNode(t.root));F.dockManager.dock(F.grid,r.DOCK_TYPE.FILL,o),F.grid.props.title="Fitted Curves"}})()).show().history(()=>{var e,t,n,r;let{assayCol:o,batchIDCol:l,concentrationCol:i,readoutCol:a,compoundIDCol:u,excludeOutliersCol:s,runIDCol:c,targetEntityCol:f,additionalColumns:d}=N.getValues();return{wells:JSON.stringify(null!=(t=Object.fromEntries(Object.entries({assayCol:null==o?void 0:o.name,batchIDCol:null==l?void 0:l.name,concentrationCol:null==i?void 0:i.name,readoutCol:null==a?void 0:a.name,compoundIDCol:null==u?void 0:u.name,excludeOutliersCol:null==s?void 0:s.name,runIDCol:null==c?void 0:c.name,targetEntityCol:null==f?void 0:f.name,additionalColumns:null!=(e=null==d?void 0:d.map(e=>e.name))?e:[]}).filter(([e,t])=>!!t)))?t:{}),parent:JSON.stringify(null!=(n=A.getHistory())?n:{}),join:JSON.stringify(null!=(r=L.getHistory())?r:{})}},e=>{var t,n,r;let o=JSON.parse(null!=(t=null==e?void 0:e.wells)?t:"{}"),l=JSON.parse(null!=(n=null==e?void 0:e.parent)?n:"{}");N.applyHistory(o),A.applyHistory(l);let i=JSON.parse(null!=(r=null==e?void 0:e.join)?r:"{}");L.applyHistory(i)})}()})()}static curveStatistic(e,t,n,o){let l=r.Column.float(`${t.name} ${o+1} ${n}`,t.length);return l.init(r=>(0,G.bW)(t,r,n,o,e)),l}static curveAggrStatistic(e,t,n,o){let l=r.Column.float(`${t.name} ${o} ${n}`,t.length);return l.init(r=>(0,G.i4)(t,r,n,o,e)),l}static addStatisticsColumn(e,t,n,o){let l=e.col(t),a=l.name,u=e.columns.getUnusedName(`${t} ${o+1} ${n}`),s=r.Column.float(u,l.length);return s.tags[ea]=l.name,s.tags[".seriesNumber"]=null==o?void 0:o.toString(),s.tags[eu]=n,s.init(t=>{var r,l,u,s,c,f;let d=e.cell(t,a);if(!d||!d.value)return null;let m=(0,i.h8)(d,!0);if(void 0===m.series[o]||m.series[o].points.every(e=>e.outlier))return null;(null==(l=m.chartOptions)?void 0:l.allowXZeroes)&&(null==(u=m.chartOptions)?void 0:u.logX)&&(null==(s=m.series)?void 0:s.some(e=>e.points.some(e=>0===e.x)))&&(0,i.B3)(m);let p={logX:null==(c=m.chartOptions)?void 0:c.logX,logY:null==(f=m.chartOptions)?void 0:f.logY},h=(0,G.TV)(m.series[o],o,p,d,!0);return null!=(r=(0,$.h5)(h,n))?r:null}),e.columns.insert(s,e.columns.names().indexOf(t)+1),s}static addAggrStatisticsColumn(e,t,n,o){let l=e.col(t),a=`${t} ${o} ${n}`,u=r.Column.float(e.columns.getUnusedName(a),null==l?void 0:l.length);return u.tags[ea]=t,u.tags[".seriesAggregation"]=o,u.tags[eu]=n,u.init(r=>{var l,a,u,s;let c=e.cell(r,t);if(!c||!c.value)return null;let f=(0,i.h8)(c);return(null==(l=f.series)?void 0:l.every(e=>e.points.every(e=>e.outlier)))?null:((null==(a=f.chartOptions)?void 0:a.allowXZeroes)&&(null==(u=f.chartOptions)?void 0:u.logX)&&(null==(s=f.series)?void 0:s.some(e=>e.points.some(e=>0===e.x)))&&(0,i.B3)(f),(0,G.JR)(f,o,c)[n])}),e.columns.insert(u,e.columns.names().indexOf(t)+1),u}static addCurveStatistic(e,t,n="interceptX",r=0){return ec.addStatisticsColumn(e,t.name,n,r)}static addAggrCurveStatistic(e,t,n="interceptX",r="med"){return ec.addAggrStatisticsColumn(e,t.name,n,r)}static convertXmlCurveToJsonFunc(){return k.J}static convertCompactDrToJsonFunc(){return V.G}static convertPzfxToJsonFunc(){return B.R}static previewPzfx(e){return en(function*(){let t=r.View.create();t.name=e.name;let n=yield e.readAsString(),o=(0,ee.rn)(n),l=o.filter(e=>"XY"===e.tableType);if(0===l.length){for(let e of o.map(ee.b6))t.append(r.Viewer.grid(e).root);return t}let i=(0,ee.aI)(l),a=r.Viewer.grid(i);return a.root.style.width="100%",a.root.style.height="100%",t.append(a.root),t})()}static pzfxFileHandler(e){let t=new TextDecoder().decode(new Uint8Array(e)),n=(0,ee.rn)(t),r=[],o=n.filter(e=>"XY"===e.tableType);for(let e of(o.length>0&&r.push((0,ee.aI)(o)),n.filter(e=>"XY"!==e.tableType)))r.push((0,ee.b6)(e));return r}}er([l.decorators.demo({name:"Curve fitting",description:"Curve fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points",meta:{demoPath:"Curves | Curve Fitting"},test:{test:"curveFitDemo()",wait:"2000"}}),eo("design:type",Function),eo("design:paramtypes",[]),eo("design:returntype",Promise)],ec,"curveFitDemo",null),er([l.decorators.demo({name:"Assay Curves",description:"Dashboard with curves for multiple compounds, assays and targets",meta:{demoPath:"Curves | Assay Curves"}}),eo("design:type",Function),eo("design:paramtypes",[]),eo("design:returntype",Promise)],ec,"assayCurveFitDemo",null),er([l.decorators.init(),eo("design:type",Function),eo("design:paramtypes",[]),eo("design:returntype",Promise)],ec,"_initCurves",null),er([l.decorators.func({name:"Fit Dose-Response Curves",description:"Group well-level assay data by compound, assay, target, and run, then fit a dose-response curve per group."}),el(1,l.decorators.param({type:"column",options:{type:"numerical",nullable:!1,description:"Concentration (dose) column"}})),el(2,l.decorators.param({type:"column",options:{type:"numerical",nullable:!1,description:"Readout (response) column"}})),el(3,l.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Batch identifier column"}})),el(4,l.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Assay name column"}})),el(5,l.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Run identifier column"}})),el(6,l.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Compound identifier column"}})),el(7,l.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Target entity column"}})),el(8,l.decorators.param({type:"column",options:{nullable:!0,description:"Boolean column marking points to exclude as outliers"}})),el(9,l.decorators.param({options:{nullable:!0}})),el(10,l.decorators.param({options:{nullable:!0}})),el(11,l.decorators.param({options:{nullable:!0}})),el(12,l.decorators.param({options:{nullable:!0}})),el(13,l.decorators.param({options:{nullable:!0}})),el(14,l.decorators.param({options:{nullable:!0}})),el(15,l.decorators.param({options:{nullable:!0}})),el(16,l.decorators.param({options:{nullable:!0}})),el(17,l.decorators.param({options:{nullable:!0}})),el(18,l.decorators.param({options:{nullable:!0,optional:!0}})),eo("design:type",Function),eo("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.Column?Object:r.Column,void 0===r||void 0===r.DataFrame?Object:r.DataFrame,Array,String,String,String,String,Array,String,String,Array]),eo("design:returntype",Promise)],ec,"dataToCurves",null),er([l.decorators.func({"top-menu":"Data | Curves | Data to Curves",requiresTableView:!0,outputs:[{name:"result",type:"dynamic"}]}),eo("design:type",Function),eo("design:paramtypes",[]),eo("design:returntype",Promise)],ec,"dataToCurvesTopMenu",null),er([l.decorators.func({name:"curveStatistic",description:"Extract a fit statistic (e.g. IC50, AUC, R\xb2) from a curve series into a calculated column.",meta:{vectorFunc:"true"},outputs:[{name:"result",type:"column",options:{action:"join(table)"}}]}),el(1,l.decorators.param({type:"column",options:{semType:"fit",nullable:!1,description:"Curve column to read"}})),el(2,l.decorators.param({options:{nullable:!1,description:"Fit statistic to extract (e.g. ic50, auc, rSquared)"}})),el(3,l.decorators.param({type:"int",options:{nullable:!1,description:"Zero-based index of the curve series"}})),eo("design:type",Function),eo("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,Number]),eo("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],ec,"curveStatistic",null),er([l.decorators.func({name:"curveAggrStatistic",description:"Aggregate a fit statistic across all series of a curve into a calculated column.",meta:{vectorFunc:"true"},outputs:[{name:"result",type:"column",options:{action:"join(table)"}}]}),el(1,l.decorators.param({type:"column",options:{semType:"fit",nullable:!1,description:"Curve column to read"}})),el(2,l.decorators.param({options:{nullable:!1,description:"Fit statistic to aggregate"}})),el(3,l.decorators.param({options:{choices:["avg","med","min","max","q1","q2","q3"],initialValue:"med",nullable:!1,description:"Aggregation applied across the series of each curve"}})),eo("design:type",Function),eo("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,String]),eo("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],ec,"curveAggrStatistic",null),er([l.decorators.func({name:"Add Curve Statistic Column",description:"Extract a fit statistic (e.g. IC50, AUC, R\xb2) from a specific curve series into a new column.",meta:{vectorFunc:"true",role:"transform"}}),el(1,l.decorators.param({options:{description:"Name of the curve column to read"}})),el(2,l.decorators.param({options:{choices:["rSquared","auc","interceptX","interceptY","slope","top","bottom"],initialValue:"interceptX",description:"Fit statistic to extract. interceptX is IC50, top and bottom are max/min Y"}})),el(3,l.decorators.param({type:"int",options:{initialValue:"0",description:"Zero-based index of the curve series"}})),eo("design:type",Function),eo("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,String,String,Number]),eo("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],ec,"addStatisticsColumn",null),er([l.decorators.func({name:"Add Aggregated Curve Statistic Column",description:"Aggregate a fit statistic across all series of a curve into a new column.",meta:{vectorFunc:"true",role:"transform"}}),el(1,l.decorators.param({options:{description:"Name of the curve column to read"}})),el(2,l.decorators.param({options:{choices:["rSquared","auc","interceptX","interceptY","slope","top","bottom"],initialValue:"interceptX",description:"Fit statistic to aggregate. interceptX is IC50, top and bottom are max/min Y"}})),el(3,l.decorators.param({options:{choices:["min","max","avg","med","q1","q2","q3"],initialValue:"med",description:"Aggregation applied across the series of each curve"}})),eo("design:type",Function),eo("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,String,String,String]),eo("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],ec,"addAggrStatisticsColumn",null),er([l.decorators.func({name:"Add Curve Statistic",description:"Extracts a fit statistic from one series of a curve column into a new column.",outputs:[{name:"result",type:"column"}],meta:{vectorFunc:"true",role:"transform"}}),el(0,l.decorators.param({options:{caption:"Table",nullable:!1}})),el(1,l.decorators.param({type:"column",options:{semType:"fit",caption:"Curves",nullable:!1,description:"Column of fitted curves"}})),el(2,l.decorators.param({type:"string",options:{caption:"Statistic",nullable:!1,choices:["rSquared","auc","interceptX","interceptY","slope","top","bottom"],initialValue:"interceptX",description:"interceptX is IC50, top and bottom are max/min Y"}})),el(3,l.decorators.param({type:"int",options:{caption:"Series",nullable:!1,initialValue:"0",description:"Zero-based index of the curve series"}})),eo("design:type",Function),eo("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,Number]),eo("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],ec,"addCurveStatistic",null),er([l.decorators.func({name:"Add Aggregated Curve Statistic",description:"Aggregates a fit statistic across all series of a curve column into a new column.",outputs:[{name:"result",type:"column"}],meta:{vectorFunc:"true",role:"transform"}}),el(0,l.decorators.param({options:{caption:"Table",nullable:!1}})),el(1,l.decorators.param({type:"column",options:{semType:"fit",caption:"Curves",nullable:!1,description:"Column of fitted curves"}})),el(2,l.decorators.param({type:"string",options:{caption:"Statistic",nullable:!1,choices:["rSquared","auc","interceptX","interceptY","slope","top","bottom"],initialValue:"interceptX",description:"interceptX is IC50, top and bottom are max/min Y"}})),el(3,l.decorators.param({type:"string",options:{caption:"Aggregation",nullable:!1,choices:["med","avg","min","max","q1","q2","q3"],initialValue:"med",description:"Applied across the series of each curve"}})),eo("design:type",Function),eo("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,String]),eo("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],ec,"addAggrCurveStatistic",null),er([l.decorators.func({description:"Returns XML 3DX curve converter function",meta:{role:"curveConverter",curveFormat:"3dx"}}),eo("design:type",Function),eo("design:paramtypes",[]),eo("design:returntype",Function)],ec,"convertXmlCurveToJsonFunc",null),er([l.decorators.func({description:"Returns compact dose-response JSON converter function",meta:{role:"curveConverter",curveFormat:"compact-dr"}}),eo("design:type",Function),eo("design:paramtypes",[]),eo("design:returntype",Function)],ec,"convertCompactDrToJsonFunc",null),er([l.decorators.func({description:"Returns PZFX curve converter function",meta:{role:"curveConverter",curveFormat:"pzfx"}}),eo("design:type",Function),eo("design:paramtypes",[]),eo("design:returntype",Function)],ec,"convertPzfxToJsonFunc",null),er([l.decorators.fileViewer({fileViewer:"pzfx"}),eo("design:type",Function),eo("design:paramtypes",[void 0===r||void 0===r.FileInfo?Object:r.FileInfo]),eo("design:returntype",Promise)],ec,"previewPzfx",null),er([l.decorators.fileHandler({ext:"pzfx",description:"Open a GraphPad Prism (.pzfx) file as data tables, fitting XY curve tables."}),el(0,l.decorators.param({type:"list",options:{description:"Raw bytes of the .pzfx file"}})),eo("design:type",Function),eo("design:paramtypes",["u"<typeof Uint8Array?Object:Uint8Array]),eo("design:returntype",Array)],ec,"pzfxFileHandler",null)},18(e,t,n){"use strict";function r(e){let t=e.slice().sort((e,t)=>e-t),n=t[Math.trunc(t.length/4)],r=t.length%2==0?(t[Math.trunc(t.length/2)]+t[Math.trunc(t.length/2)-1])/2:t[Math.trunc(t.length/2)],l=t[Math.trunc(3*t.length/4)],i=1.5*(l-n),a=o(t,l+i);a<0&&(a=~a);let u=t[Math.max(0,a-1)];u<l&&(u=l);let s=o(t,n-i);s<0&&(s=~s);let c=t[s];return c>n&&(c=n),{q1:n,q2:r,q3:l,lowerAdjacentValue:c,upperAdjacentValue:u}}function o(e,t,n,r){let o=void 0===n?0:n;if(0===e.length||(void 0===r&&(r=e.length-1),t<e[o]))return -1;if(t>e[r])return-(r+2);for(;r-o>1;){let n=Math.trunc((r+o)/2);if(t===e[n])return n;t<e[n]?r=n:o=n}return e[o]===t?o:e[r]===t?r:t<e[o]?-(o+1):-(r+1)}n.d(t,{k:()=>r})},788(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.TAG_CURVE_FORMAT=".%curve-format",r.FIT_SEM_TYPE="fit",r.FIT_CELL_TYPE="fit",r.TAG_FIT=".%fit",r.TAG_FIT_LEGACY=".fit",r.PLOT_LABEL_COLOR="#4A4A4A",r.CELL_DEFAULT_WIDTH=230,r.CELL_DEFAULT_HEIGHT=160,r.MIN_CELL_RENDERER_PX_WIDTH=10,r.MIN_CELL_RENDERER_PX_HEIGHT=5,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_DROPLINE_LABELS_PX_WIDTH=250,r.MIN_DROPLINE_LABELS_PX_HEIGHT=200,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.MIN_INFLATE_SIZE=-2,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||(null==e?void 0:e.length)===0,"There were series with no points":e=>e.some(e=>{var t;return(null==(t=e.points)?void 0:t.length)===0}),"There were series with all x zeroes":e=>e.some(e=>{var t;return null==(t=e.points)?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.every(e=>0===e.y)})}},590(e,t,n){"use strict";n.d(t,{AJ:()=>x,Al:()=>i,EV:()=>w,Ff:()=>d,G7:()=>f,Hr:()=>O,Mi:()=>_,Pf:()=>p,Qx:()=>g,Sm:()=>T,Vd:()=>I,Z5:()=>v,ah:()=>y,dZ:()=>l,h1:()=>a,kC:()=>h,kx:()=>m,nK:()=>s,oH:()=>u,ry:()=>C,sn:()=>b,xs:()=>c});var r=n(82),o=n(353);let l={CONSTANT:"constant",PROPORTIONAL:"proportional",COMBINED:"combined"},i=["rSquared","auc","interceptX","interceptY","slope","top","bottom"],a=["IC10","IC20","IC50","IC80","IC90"];class u{constructor(){this.chartOptions={},this.seriesOptions={},this.series=[]}}let s=[r.Property.js("rSquared",r.TYPE.FLOAT,{userEditable:!1}),r.Property.js("auc",r.TYPE.FLOAT,{userEditable:!1,friendlyName:"AUC"}),r.Property.js("interceptY",r.TYPE.FLOAT,{userEditable:!1}),r.Property.js("interceptX",r.TYPE.FLOAT,{userEditable:!1}),r.Property.js("slope",r.TYPE.FLOAT,{userEditable:!1}),r.Property.js("top",r.TYPE.FLOAT,{userEditable:!1}),r.Property.js("bottom",r.TYPE.FLOAT,{userEditable:!1})],c=[r.Property.js("minX",r.TYPE.FLOAT,{nullable:!0}),r.Property.js("minY",r.TYPE.FLOAT,{nullable:!0}),r.Property.js("maxX",r.TYPE.FLOAT,{nullable:!0}),r.Property.js("maxY",r.TYPE.FLOAT,{nullable:!0}),r.Property.js("title",r.TYPE.STRING,{nullable:!0}),r.Property.js("xAxisName",r.TYPE.STRING,{description:"Label to show on the X axis. If not specified, corresponding data column name is used",nullable:!0}),r.Property.js("yAxisName",r.TYPE.STRING,{description:"Label to show on the Y axis. If not specified, corresponding data column name is used",nullable:!0}),r.Property.js("logX",r.TYPE.BOOL,{description:"Whether the X axis should be logarithmic",defaultValue:!1}),r.Property.js("logY",r.TYPE.BOOL,{description:"Whether the Y axis should be logarithmic",defaultValue:!1}),r.Property.js("allowXZeroes",r.TYPE.BOOL,{description:"Whether x zeroes allowed for logarithmic data or not",defaultValue:!0}),r.Property.js("mergeSeries",r.TYPE.BOOL,{description:"Merges all series within one cell into one series",defaultValue:!1}),r.Property.js("showLegend",r.TYPE.BOOL,{description:"Whether to name the curves on the plot",defaultValue:!0}),r.Property.js("showColumnLabel",r.TYPE.BOOL,{description:"Whether to show the column label in the legend or not",defaultValue:!1}),r.Property.js("showStatistics",r.TYPE.STRING_LIST,{description:"Whether specific statistics should be rendered",choices:s.map(e=>e.name),inputType:"MultiChoice",friendlyName:"Statistics"}),r.Property.js("showLabels",r.TYPE.STRING_LIST,{description:"Whether specific labels should be rendered",choices:[],inputType:"MultiChoice",friendlyName:"Labels"}),r.Property.js("statisticsMode",r.TYPE.STRING,{description:"Whether the statistics are drawn for each series, summarised across them, or both",defaultValue:"series",choices:["series","aggregated","both"],nullable:!1,friendlyName:"Statistics mode"}),r.Property.js("aggrType",r.TYPE.STRING,{description:"The aggregation used when summarising the statistics",defaultValue:"med",choices:Object.values(r.STATS),nullable:!1,friendlyName:"Aggregation"})],f="sigmoid",d="linear",m="log-linear",p="exponential",h="4pl-regression",g="4pl-dose-response",v="js-function";function y(e,t){return n=>e(t,n)}function C(e,t){let n=e[0],r=e[1],o=e[2],l=e[3];return l+(n-l)/(1+Math.pow(10,(t-o)*r))}function b(e,t){return e[0]*t+e[1]}function x(e,t){return e[0]*Math.log(t+1)+e[1]}function w(e,t){return e[0]*Math.exp(t*e[1])}function T(e,t){let n=e[0],r=e[1],o=e[2],l=e[3];return l+(n-l)/(1+Math.pow(t/o,r))}function I(e,t){let n=e[3];return n+(e[0]-n)/(1+Math.pow(10,e[1]*(e[2]-t)))}function _(e,t){let n=0,r=Math.min(...t.x),o=Math.max(...t.x),l=(o-r)/1e3;for(let t=r;t<o;t+=l)n+=l*e(t);return n}function O(e,t){let n=0,r=0,l=o.mean(t.y);for(let o=0;o<t.x.length;o++)n+=Math.pow(t.y[o]-e(t.x[o]),2),r+=Math.pow(t.y[o]-l,2);return 1-n/r}},165(e,t,n){"use strict";n.d(t,{GO:()=>y,KZ:()=>b,Kh:()=>u,_T:()=>m,fY:()=>p,iK:()=>C,s$:()=>f,xS:()=>h,zB:()=>d});var r=n(82),o=n(590),l=n(869),i=n(774);function a(e){let t={};var n=!0,r=!1,o=void 0;try{for(var l,i=e[Symbol.iterator]();!(n=(l=i.next()).done);n=!0){let e=l.value;null!==e.defaultValue&&(t[e.name]=e.defaultValue)}}catch(e){r=!0,o=e}finally{try{n||null==i.return||i.return()}finally{if(r)throw o}}return t}function u(){return{chartOptions:a(o.xs),seriesOptions:a(l.IL)}}function s(e){let 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 c(e,t,n){let o=void 0===n?.05:n,l=e.left,i=e.right,a=e.top,u=e.bottom;if(t.logX)l=l>0?l/(1+o):l,i*=1+o;else{let t=e.width*o;l-=t,i+=t}if(t.logY)a=a>0?a/(1+o):a,u*=1+o;else{let t=e.height*o;a-=t,u+=t}return new r.Rect(l,a,i-l,u-a)}function f(e){var t,n;let o=e.chartOptions;if(!(null==(t=e.series)?void 0:t.length)||0===e.series.length)return new r.Rect(0,0,1,1);{let t,l,i,a,u,f=s(e.series[0].points),d=f.xs,m=f.ys,p=r.Rect.fromXYArrays(d,m);for(let t=1;t<e.series.length;t++){let n=s(e.series[t].points),o=n.xs,l=n.ys;o.some(e=>void 0===e)||l.some(e=>void 0===e)||(p=p.union(r.Rect.fromXYArrays(o,l)))}return o?(l=(t=c(n=p,o)).x,i=t.y,a=t.width,u=t.height,null!=o.minX&&o.minX<=n.maxX&&(!o.logX||o.logX&&o.minX>0)&&(a+=l-o.minX,l=o.minX),null!=o.maxX&&o.maxX>=n.minX&&(!o.logX||o.logX&&o.maxX>0)&&(a+=o.maxX-(l+a)),null!=o.minY&&o.minY<=n.maxY&&(!o.logY||o.logY&&o.minY>0)&&(u+=i-o.minY,i=o.minY),null!=o.maxY&&o.maxY>=n.minY&&(!o.logY||o.logY&&o.maxY>0)&&(u+=o.maxY-(i+u)),new r.Rect(l,i,a,u)):c(p,o)}}function d(e){return(0,l.TV)(e.fitFunction)}function m(e,t){var n;let r=new Float32Array(null==(n=e.parameters)?void 0:n.length);return r.set(e.parameters),(0,o.ah)(t.y,r)}function p(e,t,n,r,a){var u,s;null!=r||(r=(0,i.Sm)(e,a,n));let c=null!=(u=e.parameters)?u:(0,l.nT)(e,t,r).parameters,f=new Float32Array(c.length);return f.set(c),(0,l.O8)(r,f,t.y,.05,null!=(s=e.errorModel)?s:o.dZ.CONSTANT)}function h(e,t,n,r){var a;null!=n||(n=(0,i.Sm)(e,r,!1));let u=null!=(a=e.parameters)?a:(0,l.nT)(e,t,n).parameters,s=new Float32Array(u.length);return s.set(u),t.fillParams({fittedCurve:(0,o.ah)(t.y,s),parameters:s},e,n,r)}let g=["ic50","ec50"],v=[],y=["pIC50"];function C(e,t){var n,r;if(!e.parameters||!(null==t?void 0:t.logX)&&!(null==t?void 0:t.logY))return e;let o=d(e).statisticFields,l=[...e.parameters],i=!1;for(let e=0;e<l.length&&e<o.length;e++)(t.logX&&g.includes(o[e])||t.logY&&v.includes(o[e]))&&l[e]>0&&(l[e]=Math.log10(l[e]),i=!0);return i?(n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e),r=r={parameters:l},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n):e}function b(e,t){let n=t=>{var n=!0,r=!1,o=void 0;try{for(var l,i=t[Symbol.iterator]();!(n=(l=i.next()).done);n=!0){let t=l.value;"number"==typeof e[t]&&(e[t]=Math.pow(10,e[t]))}}catch(e){r=!0,o=e}finally{try{n||null==i.return||i.return()}finally{if(r)throw o}}};return(null==t?void 0:t.logX)&&n(g),(null==t?void 0:t.logY)&&n(v),"number"==typeof e.ic50&&e.ic50>0&&(e.pIC50=-Math.log10(e.ic50)),e}},869(e,t,n){"use strict";n.d(t,{nT:()=>$,IL:()=>B,HM:()=>V,hD:()=>k,rT:()=>H,TV:()=>q,h5:()=>X,O8:()=>U,Wh:()=>F,Z2:()=>y});var r,o,l=n(82),i=n(590),a=n(774),u=n(353);class s extends Error{constructor(e){super(e)}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function f(e,t,n,r,o,l,i,a){for(let u=0;u<l;u++)t[u]=e[u],t[u]+=o*(e[u]-r[n][u]),t[u]<i[u]?t[u]=i[u]:t[u]>a[u]&&(t[u]=a[u])}(r=o||(o={}))[r.TOLERANCE=.01]="TOLERANCE",r[r.MAX_ITER=30]="MAX_ITER",r[r.NON_ZERO_PARAM=1e-4]="NON_ZERO_PARAM",r[r.INITIAL_SCALE=.02]="INITIAL_SCALE",r[r.SCALE_REFLECTION=1]="SCALE_REFLECTION",r[r.SCALE_EXPANSION=2]="SCALE_EXPANSION",r[r.SCALE_CONTRACTION=-.5]="SCALE_CONTRACTION";let d=function(e,t,n,r,o){var l;let i=n.tolerance,a=n.maxIter,u=n.scaleReflection,s=n.scaleExpansion,d=n.scaleContraction,m=t.length+1,p=t.length,h=function(e){if(Array.isArray(e))return e}(l=function(e,t,n,r,o){let l=n.length+1,i=n.length,a=t.nonZeroParam,u=t.initialScale,s=Array(l),c=Array(l);for(let t=0;t<l;t++){s[t]=new Float32Array(i);for(let e=0;e<i;e++)s[t][e]=n[e],0!==t&&t-1===e&&(0===n[e]?s[t][e]=a:s[t][e]+=u*n[t-1],s[t][e]<r[e]?s[t][e]=r[e]:s[t][e]>o[e]&&(s[t][e]=o[e]));c[t]=e(s[t]).likelihood}return[s,c]}(e,n,t,r,o))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],l=!0,i=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(i)throw n}}return o}}(l)||function(e){if(e){if("string"==typeof e)return c(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return c(e,2)}}(l)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),g=h[0],v=h[1],y=Array(m);for(let e=0;e<m;e++)y[e]=e;let C=y.length-1,b=0,x=0,w=0,T=0,I=new Float32Array(p),_=new Float32Array(p),O=new Float32Array(p),E=new Float32Array(p),P=Array(a);if(m>1){for(;y.sort((e,t)=>v[e]-v[t]),!(b>a);){if(0===b&&(x=v[0],w=2*v[y[0]]),P[b]=x,++b,w-(x=v[y[0]])>i)T=0;else if(++T>2*m)break;w=x,function(e,t,n,r){for(let o=0;o<t;o++){let l=0;for(let e=0;e<t+1;e++)e!==n&&(l+=r[e][o]);e[o]=l/t}}(I,p,y[C],g),f(I,_,y[C],g,u,p,r,o);let t=e(_).likelihood;if(t<v[y[C]]){f(I,O,y[C],g,s,p,r,o);let n=e(O).likelihood;if(n<t){v[y[C]]=n;for(let e=0;e<p;e++)g[y[C]][e]=O[e];continue}v[y[C]]=t;for(let e=0;e<p;e++)g[y[C]][e]=_[e];continue}f(I,E,y[C],g,d,p,r,o);let n=e(E).likelihood;if(n<v[y[C]]){v[y[C]]=n;for(let e=0;e<p;e++)g[y[C]][e]=E[e];continue}break}for(let e=b;e<a;e++)P[e]=v[y[0]]}return{point:g[y[0]],cost:v[y[0]],iterCosts:P,iterCount:b-1}};var m=n(296),p=n.n(m);function h(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function g(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}class v{get derivedStatisticsProperties(){return[]}get statisticLabels(){return this.parameterNames}get statisticsProperties(){var e,t,n;return null!=this._statisticsProperties||(this._statisticsProperties=(e=this.statisticFields,t=this.statisticLabels,n=this.derivedStatisticsProperties,[...S,...e.map((e,n)=>P(e,t[n])),...void 0===n?[]:n])),this._statisticsProperties}legacyStatisticProperty(e){var t,n;if("interceptY"===e)return R;let r=M[e];if(void 0!==r&&!(r>=this.parameterNames.length))return null!=this._legacyProperties||(this._legacyProperties={}),null!=(t=(n=this._legacyProperties)[e])?t:n[e]=P(e,this.parameterNames[r])}get hasAsymptotes(){return!1}inverse(e,t){}}let y={SIGMOID:"sigmoid",LINEAR:"linear",LOG_LINEAR:"log-linear",EXPONENTIAL:"exponential",FOUR_PL_REGRESSION:"4pl-regression",FOUR_PL_DOSE_RESPONSE:"4pl-dose-response"};class C{constructor(e,t,n){this.auc=e.auc,this.rSquared=e.rSquared,this.series=t,this.parameters=n}}let b=["auc","rSquared","series","parameters","name"];class x extends C{get name(){return i.Z5}constructor(e,t,n,r,o){let l=void 0===r?[]:r;super(e,t,n);for(let e=0;e<l.length;e++)b.includes(l[e])||(this[l[e]]=n[e]);o&&n.length>2&&void 0===this.interceptY&&(this.interceptY=o(n[2]))}}class w extends C{get name(){return i.Ff}constructor(e,t,n){super(e,t,n),this.slope=e.slope,this.intercept=e.intercept}}class T extends w{get name(){return i.kx}}class I extends C{get name(){return i.G7}constructor(e,t,n){super(e,t,n),this.top=e.top,this.slope=e.slope,this.ic50=e.ic50,this.bottom=e.bottom,this.interceptY=e.interceptY,this.maxY=Math.max(e.top,e.bottom),this.minY=Math.min(e.top,e.bottom)}}class _ extends C{get name(){return i.Pf}constructor(e,t,n){super(e,t,n),this.mantissa=e.mantissa,this.power=e.power}}class O extends C{get name(){return i.kC}constructor(e,t,n){super(e,t,n),this.top=e.top,this.bottom=e.bottom,this.slope=e.slope,this.ec50=e.ec50,this.interceptY=e.interceptY,this.maxY=Math.max(e.top,e.bottom),this.minY=Math.min(e.top,e.bottom)}}class E extends O{get name(){return i.Qx}constructor(e,t,n){super(e,t,n),this.ic50=e.ec50}}function P(e,t){return l.Property.js(e,l.TYPE.FLOAT,{userEditable:!1,friendlyName:t})}let S=[P("rSquared","R\xb2"),P("auc","AUC")];function N(e){return[P("interceptY",`Y at ${e}`),P("maxY","Max Y"),P("minY","Min Y")]}let A=P("pIC50","pIC50"),L={[i.G7]:{interceptX:"ic50"},[i.kC]:{interceptX:"ec50"},[i.Qx]:{interceptX:"ic50"}},M={top:0,slope:1,interceptX:2,bottom:3},R=P("interceptY","Intercept Y");function F(e,t){var n,r,o;let l=null!=(n=null==(o=L[e.name])?void 0:o[t])?n:t;return null!=(r=e.statisticsProperties.find(e=>e.name===l))?r:e.legacyStatisticProperty(t)}function X(e,t){var n,r,o;let l=null!=(n=null==(r=L[e.name])?void 0:r[t])?n:t,i=e[l];if("number"==typeof i)return i;if("interceptX"===t)return;let a=M[t],u=void 0===a||null==(o=e.parameters)?void 0:o[a];return"number"!=typeof u||isNaN(u)?void 0:u}function D(e,t,n){return null!=t?t:(0,a.Sm)(e,n,!1)}function Y(e,t){return{auc:(0,i.Mi)(e,t),rSquared:(0,i.Hr)(e,t)}}class j extends v{get name(){return i.kC}get hasAsymptotes(){return!0}get parameterNames(){return["Top","Slope","EC50","Bottom"]}get statisticFields(){return["top","slope","ec50","bottom"]}get derivedStatisticsProperties(){return N(this.parameterNames[2])}fitValues(e,t,n,r){return g(h({},Y(e.fittedCurve,D(t,n,r))),{top:e.parameters[0],slope:e.parameters[1],ec50:e.parameters[2],bottom:e.parameters[3],interceptY:e.fittedCurve(e.parameters[2])})}fillParams(e,t,n,r){return new O(this.fitValues(e,t,n,r),t,e.parameters)}y(e,t){return(0,i.Sm)(e,t)}inverse(e,t){return e[2]*Math.pow(t/(1-t),1/Math.abs(e[1]))}getInitialParameters(e,t){let n=new Float32Array(4),r=Math.min(...t),o=Math.max(...t),l=(o-r)/2+r,i=o-r,a=0;for(let n=0;n<e.length;n++){let e=Math.abs(t[n]-l);e<i&&(i=e,a=n)}let u=e[a],s=t[0]>t[t.length-1]?-10:10;return n.set([o,s,u,r]),n}}class G extends v{get statisticFields(){return this._parameterNames.filter(e=>!b.includes(e))}get statisticLabels(){return this.statisticFields}fillParams(e,t,n,r){return new x(Y(e.fittedCurve,D(t,n,r)),t,e.parameters,this._parameterNames,e.fittedCurve)}get name(){return this._name}get parameterNames(){return this._parameterNames}y(e,t){throw Error("Not implemented")}getInitialParameters(e,t){throw Error("Not implemented")}constructor(e,t,n,r){super(),this._name=e,this._parameterNames=r,this.y=t,this.getInitialParameters=n}}let H={linear:new class extends v{get name(){return i.Ff}get parameterNames(){return["Slope","Intercept"]}get statisticFields(){return["slope","intercept"]}fillParams(e,t,n,r){return new w(g(h({},Y(e.fittedCurve,D(t,n,r))),{slope:e.parameters[0],intercept:e.parameters[1]}),t,e.parameters)}y(e,t){return(0,i.sn)(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);let o=e[r]-e[n],l=(t[r]-t[n])/o,i=t[r]-l*e[r],a=new Float32Array(2);return a.set([l,i]),a}},sigmoid:new class extends v{get name(){return i.G7}get hasAsymptotes(){return!0}get parameterNames(){return["Top","Slope","IC50","Bottom"]}get statisticFields(){return["top","slope","ic50","bottom"]}get derivedStatisticsProperties(){return[...N(this.parameterNames[2]),A]}fillParams(e,t,n,r){return new I(g(h({},Y(e.fittedCurve,D(t,n,r))),{top:e.parameters[0],slope:e.parameters[1],ic50:e.parameters[2],bottom:e.parameters[3],interceptY:e.fittedCurve(e.parameters[2])}),t,e.parameters)}y(e,t){return(0,i.ry)(e,t)}inverse(e,t){return e[2]+Math.log10(t/(1-t))/Math.abs(e[1])}getInitialParameters(e,t){let n=l.Rect.fromXYArrays(e,t),r=(n.maxY-n.minY)/2+n.minY,o=n.maxY-n.minY,i=0;for(let n=0;n<e.length;n++){let e=Math.abs(t[n]-r);e<o&&(o=e,i=n)}let a=e[i],u=t[0]>t[t.length-1]?1:-1,s=new Float32Array(4);return s.set([n.maxY,u,a,n.minY]),s}},"log-linear":new class extends v{get name(){return i.kx}get parameterNames(){return["Slope","Intercept"]}get statisticFields(){return["slope","intercept"]}fillParams(e,t,n,r){return new T(g(h({},Y(e.fittedCurve,D(t,n,r))),{slope:e.parameters[0],intercept:e.parameters[1]}),t,e.parameters)}y(e,t){return(0,i.AJ)(e,t)}getInitialParameters(e,t){let n=new Float32Array(2);return n.set([-5,100]),n}},exponential:new class extends v{get name(){return i.Pf}get parameterNames(){return["Mantissa","Power"]}get statisticFields(){return["mantissa","power"]}fillParams(e,t,n,r){return new _(g(h({},Y(e.fittedCurve,D(t,n,r))),{mantissa:e.parameters[0],power:e.parameters[1]}),t,e.parameters)}y(e,t){return(0,i.EV)(e,t)}getInitialParameters(e,t){let n=new Float32Array(2);return n.set([100,-2]),n}},"4pl-regression":new j,"4pl-dose-response":new class extends j{get name(){return i.Qx}get parameterNames(){return["Max","Hill","IC50","Min"]}get statisticFields(){return["top","slope","ic50","bottom"]}get derivedStatisticsProperties(){return[...N(this.parameterNames[2]),A]}fillParams(e,t,n,r){return new E(this.fitValues(e,t,n,r),t,e.parameters)}y(e,t){return(0,i.Vd)(e,t)}inverse(e,t){return e[2]+Math.log10(t/(1-t))/Math.abs(e[1])}}},k="sigmoid",V={},B=[l.Property.js("fitFunction",l.TYPE.STRING,{category:"Fitting",choices:Object.keys(H),defaultValue:k}),l.Property.js("pointColor",l.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),l.Property.js("fitLineColor",l.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),l.Property.js("outlierColor",l.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),l.Property.js("errorModel",l.TYPE.STRING,{category:"Fitting",defaultValue:"constant",choices:["constant","proportional","combined"],nullable:!1}),l.Property.js("connectDots",l.TYPE.BOOL,{category:"Fitting",defaultValue:!1}),l.Property.js("clickToToggle",l.TYPE.BOOL,{category:"Fitting",description:"Click on a point to mark it as outlier and refit",nullable:!0,defaultValue:!1}),l.Property.js("showFitLine",l.TYPE.BOOL,{category:"Fitting",defaultValue:!0}),l.Property.js("showPoints",l.TYPE.STRING,{category:"Fitting",description:"Whether points/candlesticks/none should be rendered",defaultValue:"points",choices:["points","candlesticks","both"]}),l.Property.js("showOutliers",l.TYPE.BOOL,{category:"Fitting",defaultValue:!0}),l.Property.js("showCurveConfidenceInterval",l.TYPE.BOOL,{category:"Fitting",description:"Whether confidence intervals should be rendered",defaultValue:!1,friendlyName:"Confidence Interval"}),l.Property.js("markerType",l.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"}),l.Property.js("outlierMarkerType",l.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"}),l.Property.js("lineStyle",l.TYPE.STRING,{category:"Rendering",defaultValue:"solid",choices:["solid","dotted","dashed","dashdotted"],nullable:!1}),l.Property.js("droplines",l.TYPE.STRING_LIST,{description:"Whether specific droplines should be rendered",choices:i.h1,inputType:"MultiChoice"}),l.Property.js("columnName",l.TYPE.STRING,{description:"Column name where the series is stored",defaultValue:""})];function q(e){var t,n;if(null==e)return H[k];if("string"==typeof e)return null!=(t=H[e])?t:H[k];if(!H[e.name]){let t=e.name,n=e.parameterNames,r=e.function.split("=>").map(e=>e.trim()),o=e.getInitialParameters.split("=>").map(e=>e.trim()),l=new G(t,Function(r[0].slice(1,r[0].length-1),`${r[1].includes(";")?"":"return "}${r[1]}`),Function(o[0].slice(1,o[0].length-1),`return ${o[1]}`),n);H[t]=l}return null!=V[n=e.name]||(V[n]=e),H[e.name]}function $(e,t,n,r){var u;return null!=n||(n=(0,a.Sm)(e,r,!1)),e.parameterBounds&&(null==r?void 0:r.logX)&&(e.parameterBounds[2]=(0,a.Yq)(e.parameterBounds[2])),function(e,t,n,r){var a,u,c;let f;null!=n||(n=i.dZ.CONSTANT);let m=t.y,h=t.getInitialParameters(e.x,e.y),g=(a=m,u=e,c=n,e=>{var t;let n=0,r=0,o=0,l=u.y,s=u.x.map(t=>a(e,t)),f=l.map((e,t)=>e-s[t]),d=f.map(e=>Math.pow(e,2));for(let e=0;e<d.length;e++)[i.dZ.CONSTANT,i.dZ.COMBINED].includes(c)?r+=d[e]:c===i.dZ.PROPORTIONAL&&(o+=d[e]/(s[e]*s[e]));r=Math.sqrt(r/d.length),o=Math.sqrt(o/d.length),c===i.dZ.COMBINED&&(r=(t=W(r,o,d,s)).sigmaA,o=t.sigmaB);let m=[];for(let e=0;e<d.length;e++)m[e]=Math.pow(r+o*s[e],2),n+=d[e]/m[e]+Math.log(2*Math.PI*m[e]);return{likelihood:n,residuals:f}}),v=new Float32Array(t.parameterNames.length),y=new Float32Array(t.parameterNames.length);for(let e=0;e<t.parameterNames.length;e++)v[e]=0===h[e]?-1:h[e]-Math.abs(.5*h[e]),y[e]=0===h[e]?1:h[e]+Math.abs(.5*h[e]);let C=l.BitSet.create(2*t.parameterNames.length);if(r&&0!==r.length)for(let e=0;e<r.length;e++)void 0!==r[e].min&&null!==r[e].min&&(v[e]=r[e].min,C.set(2*e,!0)),void 0!==r[e].max&&null!==r[e].max&&(y[e]=r[e].max,C.set(2*e+1,!0));let b=e=>{let t=g(e.point).residuals,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},x=-1,w=0,T=null,I=0;for(;;){f=function(e,t,n,r,o){let i,a=void 0===o?null:o,u=function(e,t){let n=p()("12345"),r=e.length,o=Array(10);for(let e=0;e<10;e++)o[e]=new Float32Array(r);for(let l=0;l<r;l++)if(e[l]===t[l])for(let t=0;t<10;t++)o[t][l]=e[l];else{let r=function(e,t,n,r){let o=t-n,l=Array(e);for(let t=0;t<e;t++){let e=r();l[t]=n+e*o}return l}(10,e[l],t[l],n);for(let e=0;e<10;e++)o[e][l]=r[e]}return o}(n,t),c=[],f=[],m=[],h=0,g=null;for(i=0;i<10;++i)try{if(0===i){let t=null===a?u[i]:a,n=new Float32Array(a.length).map(e=>-1/0),o=new Float32Array(a.length).map(e=>Infinity);c.push(d(e,t,r,n,o))}else c.push(d(e,u[i],r,t,n))}catch(e){if(e instanceof s)throw Error(`Inconsistent dataframes: ${e.message}`);++h,f.push(e instanceof Error?e.message:"Platform issue"),m.push(u[i])}if(h>0){let e=n.length,t=Array(e);for(let n=0;n<e;++n)t[n]=new Float32Array(h);m.forEach((e,n)=>e.forEach((e,r)=>t[r][n]=e)),(g=l.DataFrame.fromColumns(t.map((e,t)=>l.Column.fromFloat32Array(`arg${t}`,e)))).columns.add(l.Column.fromStrings("Issue",f))}return{extremums:c,fails:g}}(g,v,y,{tolerance:o.TOLERANCE,maxIter:o.MAX_ITER,nonZeroParam:o.NON_ZERO_PARAM,initialScale:o.INITIAL_SCALE,scaleReflection:o.SCALE_REFLECTION,scaleExpansion:o.SCALE_EXPANSION,scaleContraction:o.SCALE_CONTRACTION},h),I=0;for(let e=1;e<f.extremums.length;e++)f.extremums[e].cost<f.extremums[I].cost&&(I=e);let e=b(f.extremums[I]);if(null===T?T=e:e<T?(T=e,w=0):w++,h=f.extremums[I].point,x>40||3===w)break;for(let e=0;e<t.parameterNames.length;e++)C.get(2*e)||(v[e]=h[e]-Math.abs(h[e]*(w+.5))),C.get(2*e+1)||(y[e]=h[e]+Math.abs(h[e]*(w+.5)));x++}return{fittedCurve:(0,i.ah)(m,h),parameters:h}}((0,a.mr)(n),t,null!=(u=e.errorModel)?u:i.dZ.CONSTANT,e.parameterBounds)}function W(e,t,n,r){let o=Number.MAX_VALUE,l=0;for(let t=0;t<=10;t++){let i=0,a=t/10,u=e*a,s=e*(1-a),c=[];for(let e=0;e<n.length;e++)c[e]=Math.pow(u+s*r[e],2),i+=n[e]/c[e]+Math.log(2*Math.PI*c[e]);i<o&&(o=i,l=a)}return t=e*(1-l),{sigmaA:e*=l,sigmaB:t}}function U(e,t,n,r,o){let l=function(e,t,n,r){var o;let l=0,a=0,u=t.y,s=t.x.map(t=>e(r,t)),c=u.map((e,t)=>e-s[t]),f=c.map(e=>Math.pow(e,2));for(let e=0;e<f.length;e++)[i.dZ.CONSTANT,i.dZ.COMBINED].includes(n)?l+=f[e]:n===i.dZ.PROPORTIONAL&&(a+=Math.pow(c[e]/Math.abs(s[e]),2));return l=Math.sqrt(l/f.length),a=Math.sqrt(a/f.length),n===i.dZ.COMBINED&&(l=(o=W(l,a,f,s)).sigmaA,a=o.sigmaB),{sigmaA:l,sigmaB:a}}(n,e,o,t),a=u.normal.inv(1-(void 0===r?.05:r)/2,0,1);return{confidenceTop:e=>{let r=n(t,e);return r+a*(l.sigmaA+Math.abs(r)*l.sigmaB)},confidenceBottom:e=>{let r=n(t,e);return r-a*(l.sigmaA+Math.abs(r)*l.sigmaB)}}}},774(e,t,n){"use strict";function r(e,t,n){let r=n?e.points:e.points.filter(e=>!e.outlier);return{x:r.map(e=>(null==t?void 0:t.logX)?Math.log10(e.x):e.x),y:r.map(e=>(null==t?void 0:t.logY)?Math.log10(e.y):e.y)}}function o(e){let 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 l(e){let 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}let l=o(n);t.x[t.x.length]=n.x[0],t.y[t.y.length]=l,n.x=[e.x[r]],n.y=[e.y[r]]}let r=o(n);return t.x[t.x.length]=n.x[0],t.y[t.y.length]=r,t}function i(e){return e&&(void 0!==e.max&&(e.max=Math.log10(e.max)),void 0!==e.min&&(e.min=0===e.min?-Number.MAX_VALUE:Math.log10(e.min))),e}n.d(t,{Sm:()=>r,Yq:()=>i,mr:()=>l})},533(e,t,n){"use strict";n.d(t,{L:()=>i});var r=n(82);let o=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}},l=new class{screenToWorld(e,t,n,r,o){let l=Math.log(n=n<1e-30?1e-30:n);return Math.exp(l+(Math.log(r)-l)*(o?t-e:e)/t)}worldToScreen(e,t,n,r,o){if(e<=0)return NaN;if(1e-30>Math.abs(e-n))return o?t:0;if(1e-30>Math.abs(e-r))return o?0:t;let l=t*Math.log((e=e<1e-30?1e-30:e)/(n=n<1e-30?1e-30:n))/Math.log(r/n);return o?t-l:l}};class i{get xt(){return this.logX?l:o}get yt(){return this.logY?l:o}xToScreen(e){return this.screen.left+this.xt.worldToScreen(e,this.screen.width,this.world.minX,this.world.maxX,this.inverseX)}yToScreen(e){return this.screen.top+this.yt.worldToScreen(e,this.screen.height,this.world.minY,this.world.maxY,!this.inverseY)}xToWorld(e){return this.xt.screenToWorld(e-this.screen.left,this.screen.width,this.world.minX,this.world.maxX,this.inverseX)}yToWorld(e){return this.yt.screenToWorld(e-this.screen.top,this.screen.height,this.world.minY,this.world.maxY,!this.inverseY)}toScreen(e){return new 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)}constructor(e,t,n,r){this.logX=!1,this.logY=!1,this.inverseX=!1,this.inverseY=!1,this.world=e,this.screen=t,this.logX=void 0!==n&&n,this.logY=void 0!==r&&r}}},82(e){"use strict";e.exports=DG},328(e){"use strict";e.exports=grok},858(e){"use strict";e.exports=rxjs},389(e){"use strict";e.exports=ui},991(e){"use strict";e.exports=wu},562(){}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var l=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(l.exports,l,l.exports,n),l.loaded=!0,l.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"u">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),curves=n(644)})();
2
2
  //# sourceMappingURL=package.js.map