@datagrok/curves 1.13.3 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/.grokignore +2 -0
  2. package/.turbo/turbo-build.log +5 -4
  3. package/CHANGELOG.md +18 -0
  4. package/README.md +2 -2
  5. package/bdd/bdd.config.json +1 -0
  6. package/bdd/bindings/curves.ts +28 -0
  7. package/bdd/features/MISSING.md +20 -0
  8. package/bdd/features/data/curve-json-columns.feature +66 -0
  9. package/bdd/features/data/data-to-curves.feature +50 -0
  10. package/bdd/features/data/pzfx-files.feature +25 -0
  11. package/bdd/features/grid/curve-cells.feature +55 -0
  12. package/bdd/features/grid/curve-options.feature +52 -0
  13. package/bdd/features/grid/statistic-columns.feature +47 -0
  14. package/bdd/features/guides/INDEX.md +8 -0
  15. package/bdd/features/guides/curves-legend-cells.feature +37 -0
  16. package/bdd/features/guides/curves-legend.feature +42 -0
  17. package/bdd/features/viewers/curves-in-trellis.feature +90 -0
  18. package/bdd/features/viewers/multi-curve-viewer.feature +92 -0
  19. package/bdd/generated/data/curve-json-columns.test.ts +75 -0
  20. package/bdd/generated/data/data-to-curves.test.ts +45 -0
  21. package/bdd/generated/data/pzfx-files.test.ts +50 -0
  22. package/bdd/generated/grid/curve-cells.test.ts +67 -0
  23. package/bdd/generated/grid/curve-options.test.ts +66 -0
  24. package/bdd/generated/grid/statistic-columns.test.ts +64 -0
  25. package/bdd/generated/guides/curves-legend-cells.test.ts +48 -0
  26. package/bdd/generated/guides/curves-legend.test.ts +48 -0
  27. package/bdd/generated/viewers/curves-in-trellis.test.ts +98 -0
  28. package/bdd/generated/viewers/multi-curve-viewer.test.ts +103 -0
  29. package/bdd/package.json +1 -0
  30. package/bdd/tsconfig.json +13 -0
  31. package/detectors.js +4 -4
  32. package/dist/package-test.js +28 -16
  33. package/dist/package-test.js.map +1 -1
  34. package/dist/package.js +1 -1
  35. package/dist/package.js.map +1 -1
  36. package/package.json +12 -5
  37. package/src/fit/fit-grid-cell-handler.ts +29 -4
  38. package/src/fit/fit-interaction.ts +15 -9
  39. package/src/fit/fit-legend.ts +35 -9
  40. package/src/fit/fit-renderer.ts +24 -9
  41. package/src/fit/multi-curve-viewer.ts +82 -19
  42. package/src/package-test.ts +1 -0
  43. package/src/package.g.ts +1 -0
  44. package/src/package.ts +1 -1
  45. package/src/tests/calculated-columns-tests.ts +3 -3
  46. package/src/tests/curve-data.ts +5 -1
  47. package/src/tests/curves-cell-renderer-tests.ts +10 -10
  48. package/src/tests/data-to-curves-tests.ts +34 -0
  49. package/src/tests/detector-tests.ts +26 -0
  50. package/src/tests/fit-tests.ts +12 -0
  51. package/src/tests/legend-tests.ts +24 -1
  52. package/src/tests/multi-curve-viewer-tests.ts +90 -17
  53. package/src/tests/panel-renderer-tests.ts +75 -30
  54. package/src/tests/project-tests.ts +30 -12
  55. package/test-console-output-1.log +366 -332
  56. package/test-record-1.mp4 +0 -0
@@ -1,4 +1,4 @@
1
- var curves_test;(()=>{var e={397(e){!function(t,n){var r={};n(r);var o=r.default;for(var i in r)o[i]=r[i];"object"==typeof e.exports?e.exports=o:"function"==typeof define&&define.amd?define(function(){return o}):t.sha256=o}(this,function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2]);function n(e,n,r,o,i){for(var l,a,s,u,c,d,f,m,p,h,g,v,y;i>=64;){for(h=0,l=n[0],a=n[1],s=n[2],u=n[3],c=n[4],d=n[5],f=n[6],m=n[7];h<16;h++)g=o+4*h,e[h]=(255&r[g])<<24|(255&r[g+1])<<16|(255&r[g+2])<<8|255&r[g+3];for(h=16;h<64;h++)v=((p=e[h-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,y=((p=e[h-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,e[h]=(v+e[h-7]|0)+(y+e[h-16]|0);for(h=0;h<64;h++)v=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&d^~c&f)|0)+(m+(t[h]+e[h]|0)|0)|0,y=((l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10))+(l&a^l&s^a&s)|0,m=f,f=d,d=c,c=u+v|0,u=s,s=a,a=l,l=v+y|0;n[0]+=l,n[1]+=a,n[2]+=s,n[3]+=u,n[4]+=c,n[5]+=d,n[6]+=f,n[7]+=m,o+=64,i-=64}return o}var r=function(){function t(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return t.prototype.reset=function(){return this.state[0]=0x6a09e667,this.state[1]=0xbb67ae85,this.state[2]=0x3c6ef372,this.state[3]=0xa54ff53a,this.state[4]=0x510e527f,this.state[5]=0x9b05688c,this.state[6]=0x1f83d9ab,this.state[7]=0x5be0cd19,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},t.prototype.clean=function(){for(var e=0;e<this.buffer.length;e++)this.buffer[e]=0;for(var e=0;e<this.temp.length;e++)this.temp[e]=0;this.reset()},t.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this.finished)throw Error("SHA256: can't update because hash was finished.");var r=0;if(this.bytesHashed+=t,this.bufferLength>0){for(;this.bufferLength<64&&t>0;)this.buffer[this.bufferLength++]=e[r++],t--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(t>=64&&(r=n(this.temp,this.state,e,r,t),t%=64);t>0;)this.buffer[this.bufferLength++]=e[r++],t--;return this},t.prototype.finish=function(e){if(!this.finished){var t=this.bytesHashed,r=this.bufferLength,o=t/0x20000000|0,i=t<<3,l=t%64<56?64:128;this.buffer[r]=128;for(var a=r+1;a<l-8;a++)this.buffer[a]=0;this.buffer[l-8]=o>>>24&255,this.buffer[l-7]=o>>>16&255,this.buffer[l-6]=o>>>8&255,this.buffer[l-5]=o>>>0&255,this.buffer[l-4]=i>>>24&255,this.buffer[l-3]=i>>>16&255,this.buffer[l-2]=i>>>8&255,this.buffer[l-1]=i>>>0&255,n(this.temp,this.state,this.buffer,0,l),this.finished=!0}for(var a=0;a<8;a++)e[4*a+0]=this.state[a]>>>24&255,e[4*a+1]=this.state[a]>>>16&255,e[4*a+2]=this.state[a]>>>8&255,e[4*a+3]=this.state[a]>>>0&255;return this},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype._saveState=function(e){for(var t=0;t<this.state.length;t++)e[t]=this.state[t]},t.prototype._restoreState=function(e,t){for(var n=0;n<this.state.length;n++)this.state[n]=e[n];this.bytesHashed=t,this.finished=!1,this.bufferLength=0},t}();e.Hash=r;var o=function(){function e(e){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var t=new Uint8Array(this.blockSize);if(e.length>this.blockSize)new r().update(e).finish(t).clean();else for(var n=0;n<e.length;n++)t[n]=e[n];for(var n=0;n<t.length;n++)t[n]^=54;this.inner.update(t);for(var n=0;n<t.length;n++)t[n]^=106;this.outer.update(t),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var n=0;n<t.length;n++)t[n]=0}return e.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},e.prototype.clean=function(){for(var e=0;e<this.istate.length;e++)this.ostate[e]=this.istate[e]=0;this.inner.clean(),this.outer.clean()},e.prototype.update=function(e){return this.inner.update(e),this},e.prototype.finish=function(e){return this.outer.finished?this.outer.finish(e):(this.inner.finish(e),this.outer.update(e,this.digestLength).finish(e)),this},e.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},e}();function i(e){var t=new r().update(e),n=t.digest();return t.clean(),n}function l(e,t){var n=new o(e).update(t),r=n.digest();return n.clean(),r}e.HMAC=o,e.hash=i,e.default=i,e.hmac=l;var a=new Uint8Array(e.digestLength);e.hkdf=function(e,t,n,r){void 0===t&&(t=a),void 0===r&&(r=32);for(var i=new Uint8Array([1]),s=new o(l(t,e)),u=new Uint8Array(s.digestLength),c=u.length,d=new Uint8Array(r),f=0;f<r;f++)c===u.length&&(!function(e,t,n,r){var o=r[0];if(0===o)throw Error("hkdf: cannot expand more");t.reset(),o>1&&t.update(e),n&&t.update(n),t.update(r),t.finish(e),r[0]++}(u,s,n,i),c=0),d[f]=u[c++];return s.clean(),u.fill(0),i.fill(0),d},e.pbkdf2=function(e,t,n,r){for(var i=new o(e),l=i.digestLength,a=new Uint8Array(4),s=new Uint8Array(l),u=new Uint8Array(l),c=new Uint8Array(r),d=0;d*l<r;d++){var f=d+1;a[0]=f>>>24&255,a[1]=f>>>16&255,a[2]=f>>>8&255,a[3]=f>>>0&255,i.reset(),i.update(t),i.update(a),i.finish(u);for(var m=0;m<l;m++)s[m]=u[m];for(var m=2;m<=n;m++){i.reset(),i.update(u).finish(u);for(var p=0;p<l;p++)s[p]^=u[p]}for(var m=0;m<l&&d*l+m<r;m++)c[d*l+m]=s[m]}for(var d=0;d<l;d++)s[d]=u[d]=0;for(var d=0;d<4;d++)a[d]=0;return i.clean(),c}})},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 i=Array.isArray||function(e){return"[object Array]"===r.call(e)};function l(e){return"[object Function]"===r.call(e)}function a(e){return"number"==typeof e&&e-e==0}function s(){return new s._init(arguments)}function u(){return 0}function c(){return 1}function d(e,t){return+(e===t)}s.fn=s.prototype,s._init=function(e){if(i(e[0]))if(i(e[0][0])){l(e[1])&&(e[0]=s.map(e[0],e[1]));for(var t=0;t<e[0].length;t++)this[t]=e[0][t];this.length=e[0].length}else this[0]=l(e[1])?s.map(e[0],e[1]):e[0],this.length=1;else if(a(e[0]))this[0]=s.seq.apply(null,e),this.length=1;else{if(e[0]instanceof s)return s(e[0].toArray());this[0]=[],this.length=1}return this},s._init.prototype=s.prototype,s._init.constructor=s,s.utils={calcRdx:o,isArray:i,isFunction:l,isNumber:a,toVector:function(e){return t.apply([],e)}},s._random_fn=e.random,s.setRandom=function(e){if("function"!=typeof e)throw TypeError("fn is not a function");s._random_fn=e},s.extend=function(e){var t,n;if(1==arguments.length){for(n in e)s[n]=e[n];return this}for(t=1;t<arguments.length;t++)for(n in arguments[t])e[n]=arguments[t][n];return e},s.rows=function(e){return e.length||1},s.cols=function(e){return e[0].length||1},s.dimensions=function(e){return{rows:s.rows(e),cols:s.cols(e)}},s.row=function(e,t){return i(t)?t.map(function(t){return s.row(e,t)}):e[t]},s.rowa=function(e,t){return s.row(e,t)},s.col=function(e,t){if(i(t)){var n=s.arange(e.length).map(function(){return Array(t.length)});return t.forEach(function(t,r){s.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},s.cola=function(e,t){return s.col(e,t).map(function(e){return e[0]})},s.diag=function(e){for(var t=s.rows(e),n=Array(t),r=0;r<t;r++)n[r]=[e[r][r]];return n},s.antidiag=function(e){for(var t=s.rows(e)-1,n=Array(t),r=0;t>=0;t--,r++)n[r]=[e[r][t]];return n},s.transpose=function(e){var t,n,r,o,l,a=[];for(i(e[0])||(e=[e]),n=e.length,r=e[0].length,l=0;l<r;l++){for(o=0,t=Array(n);o<n;o++)t[o]=e[o][l];a.push(t)}return 1===a.length?a[0]:a},s.map=function(e,t,n){var r,o,l,a,s;for(i(e[0])||(e=[e]),o=e.length,l=e[0].length,a=n?e:Array(o),r=0;r<o;r++)for(a[r]||(a[r]=Array(l)),s=0;s<l;s++)a[r][s]=t(e[r][s],r,s);return 1===a.length?a[0]:a},s.cumreduce=function(e,t,n){var r,o,l,a,s;for(i(e[0])||(e=[e]),o=e.length,l=e[0].length,a=n?e:Array(o),r=0;r<o;r++)for(a[r]||(a[r]=Array(l)),l>0&&(a[r][0]=e[r][0]),s=1;s<l;s++)a[r][s]=t(a[r][s-1],e[r][s]);return 1===a.length?a[0]:a},s.alter=function(e,t){return s.map(e,t,!0)},s.create=function(e,t,n){var r,o,i=Array(e);for(l(t)&&(n=t,t=e),r=0;r<e;r++)for(o=0,i[r]=Array(t);o<t;o++)i[r][o]=n(r,o);return i},s.zeros=function(e,t){return a(t)||(t=e),s.create(e,t,u)},s.ones=function(e,t){return a(t)||(t=e),s.create(e,t,c)},s.rand=function(e,t){return a(t)||(t=e),s.create(e,t,s._random_fn)},s.identity=function(e,t){return a(t)||(t=e),s.create(e,t,d)},s.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},s.clear=function(e){return s.alter(e,u)},s.seq=function(e,t,n,r){l(r)||(r=!1);var i,a=[],s=o(e,t),u=(t*s-e*s)/((n-1)*s),c=e;for(i=0;c<=t&&i<n;c=(e*s+u*s*++i)/s)a.push(r?r(c,i):c);return a},s.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},s.slice=function(){function e(e,t,n,r){var o,i=[],l=e.length;if(void 0===t&&void 0===n&&void 0===r)return s.copy(e);if(t=t||0,n=n||e.length,r=r||1,(t=t>=0?t:l+t)===(n=n>=0?n:l+n)||0===r||t<n&&r<0||t>n&&r>0)return[];if(r>0)for(o=t;o<n;o+=r)i.push(e[o]);else for(o=t;o>n;o+=r)i.push(e[o]);return i}return function(t,n){if(a((n=n||{}).row)){var r,o;if(a(n.col))return t[n.row][n.col];return e(s.rowa(t,n.row),(r=n.col||{}).start,r.end,r.step)}return a(n.col)?e(s.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)}))}}(),s.sliceAssign=function(t,n,r){var o,i;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=s.arange(n.col.start,e.min(t.length,n.col.end),n.col.step);var l=n.row;return o.forEach(function(e,n){t[l][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,i=s.arange(n.row.start,e.min(t[0].length,n.row.end),n.row.step);var u=n.col;return i.forEach(function(e,n){t[e][u]=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,i=s.arange(n.row.start,e.min(t.length,n.row.end),n.row.step),o=s.arange(n.col.start,e.min(t[0].length,n.col.end),n.col.step),i.forEach(function(e,n){o.forEach(function(o,i){t[e][o]=r[n][i]})}),t},s.diagonal=function(e){var t=s.zeros(e.length,e.length);return e.forEach(function(e,n){t[n][n]=e}),t},s.copy=function(e){return e.map(function(e){return a(e)?e:e.map(function(e){return e})})};var f=s.prototype;f.length=0,f.push=Array.prototype.push,f.sort=Array.prototype.sort,f.splice=Array.prototype.splice,f.slice=Array.prototype.slice,f.toArray=function(){return this.length>1?n.call(this):n.call(this)[0]},f.map=function(e,t){return s(s.map(this,e,t))},f.cumreduce=function(e,t){return s(s.cumreduce(this,e,t))},f.alter=function(e){return s.alter(this,e),this};for(var m="transpose clear symmetric rows cols dimensions diag antidiag".split(" "),p=0;p<m.length;p++)!function(e){f[e]=function(t){var n,r=this;return t?(setTimeout(function(){t.call(r,f[e].call(r))}),this):i(n=s[e](this))?s(n):n}}(m[p]);for(var h="row col".split(" "),g=0;g<h.length;g++)!function(e){f[e]=function(t,n){var r=this;return n?(setTimeout(function(){n.call(r,f[e].call(r,t))}),this):s(s[e](this,t))}}(h[g]);for(var v="create zeros ones rand identity".split(" "),y=0;y<v.length;y++)!function(e){f[e]=function(){return s(s[e].apply(null,arguments))}}(v[y]);return s}(Math);!function(e,t){var n=e.utils.isFunction;function r(e,t){return e-t}function o(e,n,r){return t.max(n,t.min(e,r))}e.sum=function(e){for(var t=0,n=e.length;--n>=0;)t+=e[n];return t},e.sumsqrd=function(e){for(var t=0,n=e.length;--n>=0;)t+=e[n]*e[n];return t},e.sumsqerr=function(t){for(var n,r=e.mean(t),o=0,i=t.length;--i>=0;)o+=(n=t[i]-r)*n;return o},e.sumrow=function(e){for(var t=0,n=e.length;--n>=0;)t+=e[n];return t},e.product=function(e){for(var t=1,n=e.length;--n>=0;)t*=e[n];return t},e.min=function(e){for(var t=e[0],n=0;++n<e.length;)e[n]<t&&(t=e[n]);return t},e.max=function(e){for(var t=e[0],n=0;++n<e.length;)e[n]>t&&(t=e[n]);return t},e.unique=function(e){for(var t={},n=[],r=0;r<e.length;r++)t[e[r]]||(t[e[r]]=!0,n.push(e[r]));return n},e.mean=function(t){return e.sum(t)/t.length},e.meansqerr=function(t){return e.sumsqerr(t)/t.length},e.geomean=function(n){var r=n.map(t.log),o=e.mean(r);return t.exp(o)},e.median=function(e){var t=e.length,n=e.slice().sort(r);return 1&t?n[t/2|0]:(n[t/2-1]+n[t/2])/2},e.cumsum=function(t){return e.cumreduce(t,function(e,t){return e+t})},e.cumprod=function(t){return e.cumreduce(t,function(e,t){return e*t})},e.diff=function(e){var t,n=[],r=e.length;for(t=1;t<r;t++)n.push(e[t]-e[t-1]);return n},e.rank=function(e){var t,n=[],o={};for(t=0;t<e.length;t++){var i=e[t];o[i]?o[i]++:(o[i]=1,n.push(i))}var l=n.sort(r),a={},s=1;for(t=0;t<l.length;t++){var i=l[t],u=o[i],c=(s+(s+u-1))/2;a[i]=c,s+=u}return e.map(function(e){return a[e]})},e.mode=function(e){var t,n=e.length,o=e.slice().sort(r),i=1,l=0,a=0,s=[];for(t=0;t<n;t++)o[t]===o[t+1]?i++:(i>l?(s=[o[t]],l=i,a=0):i===l&&(s.push(o[t]),a++),i=1);return 0===a?s[0]:s},e.range=function(t){return e.max(t)-e.min(t)},e.variance=function(t,n){return e.sumsqerr(t)/(t.length-!!n)},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),i=0;i<r;i++)o[i]=t[i]-n;return o},e.stdev=function(n,r){return t.sqrt(e.variance(n,r))},e.pooledstdev=function(n){return t.sqrt(e.pooledvariance(n))},e.meandev=function(n){for(var r=e.mean(n),o=[],i=n.length-1;i>=0;i--)o.push(t.abs(n[i]-r));return e.mean(o)},e.meddev=function(n){for(var r=e.median(n),o=[],i=n.length-1;i>=0;i--)o.push(t.abs(n[i]-r));return e.median(o)},e.coeffvar=function(t){return e.stdev(t)/e.mean(t)},e.quartiles=function(e){var n=e.length,o=e.slice().sort(r);return[o[t.round(n/4)-1],o[t.round(n/2)-1],o[t.round(3*n/4)-1]]},e.quantiles=function(e,n,i,l){var a,s,u,c,d,f,m=e.slice().sort(r),p=[n.length],h=e.length;for(void 0===i&&(i=3/8),void 0===l&&(l=3/8),a=0;a<n.length;a++)u=i+(s=n[a])*(1-i-l),c=h*s+u,d=t.floor(o(c,1,h-1)),f=o(c-d,0,1),p[a]=(1-f)*m[d-1]+f*m[d];return p},e.percentile=function(e,t,n){var o=e.slice().sort(r),i=t*(o.length+(n?1:-1))+ +!n,l=parseInt(i);return l+1<o.length?o[l-1]+(i-l)*(o[l]-o[l-1]):o[l-1]},e.percentileOfScore=function(e,t,n){var r,o,i=0,l=e.length,a=!1;for("strict"===n&&(a=!0),o=0;o<l;o++)r=e[o],(a&&r<t||!a&&r<=t)&&i++;return i/l},e.histogram=function(n,r){r=r||4;var o,i=e.min(n),l=(e.max(n)-i)/r,a=n.length,s=[];for(o=0;o<r;o++)s[o]=0;for(o=0;o<a;o++)s[t.min(t.floor((n[o]-i)/l),r-1)]+=1;return s},e.covariance=function(t,n){var r,o=e.mean(t),i=e.mean(n),l=t.length,a=Array(l);for(r=0;r<l;r++)a[r]=(t[r]-o)*(n[r]-i);return e.sum(a)/(l-1)},e.corrcoeff=function(t,n){return e.covariance(t,n)/e.stdev(t,1)/e.stdev(n,1)},e.spearmancoeff=function(t,n){return t=e.rank(t),n=e.rank(n),e.corrcoeff(t,n)},e.stanMoment=function(n,r){for(var o=e.mean(n),i=e.stdev(n),l=n.length,a=0,s=0;s<l;s++)a+=t.pow((n[s]-o)/i,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 i=e.prototype,l="cumsum cumprod".split(" "),a=0;a<l.length;a++)!function(t){i[t]=function(r,o){var l=[],a=0,s=this;if(n(r)&&(o=r,r=!1),o)return setTimeout(function(){o.call(s,i[t].call(s,r))}),this;if(this.length>1){for(s=!0===r?this:this.transpose();a<s.length;a++)l[a]=e[t](s[a]);return l}return e[t](this[0],r)}}(l[a]);for(var s="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(" "),u=0;u<s.length;u++)!function(t){i[t]=function(r,o){var l=[],a=0,s=this;if(n(r)&&(o=r,r=!1),o)return setTimeout(function(){o.call(s,i[t].call(s,r))}),this;if(this.length>1){for("sumrow"!==t&&(s=!0===r?this:this.transpose());a<s.length;a++)l[a]=e[t](s[a]);return!0===r?e[t](e.utils.toVector(l)):l}return e[t](this[0],r)}}(s[u]);for(var c="quantiles percentileOfScore".split(" "),d=0;d<c.length;d++)!function(t){i[t]=function(){var r,o=[],l=0,a=this,s=Array.prototype.slice.call(arguments);if(n(s[s.length-1])){r=s[s.length-1];var u=s.slice(0,s.length-1);return setTimeout(function(){r.call(a,i[t].apply(a,u))}),this}r=void 0;var c=function(n){return e[t].apply(a,[n].concat(s))};if(this.length>1){for(a=a.transpose();l<a.length;l++)o[l]=c(a[l]);return o}return c(this[0])}}(c[d])}(e,Math);var t=Math;e.gammaln=function(e){var n,r,o=0,i=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],l=1.000000000190015;for(r=(n=e)+5.5,r-=(e+.5)*t.log(r);o<6;o++)l+=i[o]/++n;return t.log(2.5066282746310007*l/e)-r},e.loggam=function(e){var n,r,o,i,l,a,s,u=[.08333333333333333,-.002777777777777778,7936507936507937e-19,-5952380952380952e-19,8417508417508418e-19,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=e,s=0,1==e||2==e)return 0;for(e<=7&&(s=t.floor(7-e),n=e+s),r=1/(n*n),o=2*t.PI,l=u[9],a=8;a>=0;a--)l*=r,l+=u[a];if(i=l/n+.5*t.log(o)+(n-.5)*t.log(n)-n,e<=7)for(a=1;a<=s;a++)i-=t.log(n-1),n-=1;return i},e.gammafn=function(e){var n,r,o,i,l=[-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],s=!1,u=0,c=0,d=0,f=e;if(e>171.6243769536076)return 1/0;if(f<=0){if(!(i=f%1+36e-17))return 1/0;s=(1&f?-1:1)*t.PI/t.sin(t.PI*i),f=1-f}for(n=0,o=f,r=f<1?f++:(f-=u=(0|f)-1)-1;n<8;++n)d=(d+l[n])*r,c=c*r+a[n];if(i=d/c+1,o<f)i/=o;else if(o>f)for(n=0;n<u;++n)i*=f,f++;return s&&(i=s/i),i},e.gammap=function(t,n){return e.lowRegGamma(t,n)*e.gammafn(t)},e.lowRegGamma=function(n,r){var o,i=e.gammaln(n),l=n,a=1/n,s=a,u=r+1-n,c=1/1e-30,d=1/u,f=d,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+=s*=r/++l;return a*t.exp(-r+n*t.log(r)-i)}for(;m<=p;m++)u+=2,f*=(d=1/(d=(o=-m*(m-n))*d+u))*(c=u+o/c);return 1-f*t.exp(-r+n*t.log(r)-i)},e.factorialln=function(t){return t<0?NaN:e.gammaln(t+1)},e.factorial=function(t){return t<0?NaN:e.gammafn(t+1)},e.combination=function(n,r){return n>170||r>170?t.exp(e.combinationln(n,r)):e.factorial(n)/e.factorial(r)/e.factorial(n-r)},e.combinationln=function(t,n){return e.factorialln(t)-e.factorialln(n)-e.factorialln(t-n)},e.permutation=function(t,n){return e.factorial(t)/e.factorial(t-n)},e.betafn=function(n,r){if(!(n<=0)&&!(r<=0))return n+r>170?t.exp(e.betaln(n,r)):e.gammafn(n)*e.gammafn(r)/e.gammafn(n+r)},e.betaln=function(t,n){return e.gammaln(t)+e.gammaln(n)-e.gammaln(t+n)},e.betacf=function(e,n,r){var o,i,l,a,s=1,u=n+r,c=n+1,d=n-1,f=1,m=1-u*e/c;for(1e-30>t.abs(m)&&(m=1e-30),a=m=1/m;s<=100&&(o=2*s,m=1+(i=s*(r-s)*e/((d+o)*(n+o)))*m,1e-30>t.abs(m)&&(m=1e-30),f=1+i/f,1e-30>t.abs(f)&&(f=1e-30),a*=(m=1/m)*f,m=1+(i=-(n+s)*(u+s)*e/((n+o)*(c+o)))*m,1e-30>t.abs(m)&&(m=1e-30),f=1+i/f,1e-30>t.abs(f)&&(f=1e-30),a*=l=(m=1/m)*f,!(3e-7>t.abs(l-1)));s++);return a},e.gammapinv=function(n,r){var o,i,l,a,s,u=0,c=r-1,d=e.gammaln(r);if(n>=1)return t.max(100,r+100*t.sqrt(r));if(n<=0)return 0;for(r>1?(a=t.log(c),s=t.exp(c*(a-1)-d),o=(2.30753+.27061*(i=t.sqrt(-2*t.log(n<.5?n:1-n))))/(1+i*(.99229+.04481*i))-i,n<.5&&(o=-o),o=t.max(.001,r*t.pow(1-1/(9*r)-o/(3*t.sqrt(r)),3))):o=n<(i=1-r*(.253+.12*r))?t.pow(n/i,1/r):1-t.log(1-(n-i)/(1-i));u<12;u++){if(o<=0)return 0;if(l=(e.lowRegGamma(r,o)-n)/(i=r>1?s*t.exp(-(o-c)+c*(t.log(o)-a)):t.exp(-o+c*t.log(o)-d)),(o-=i=l/(1-.5*t.min(1,l*((r-1)/o-1))))<=0&&(o=.5*(o+i)),t.abs(i)<1e-8*o)break}return o},e.erf=function(e){var n,r,o,i,l=[-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=l.length-1,s=!1,u=0,c=0;for(e<0&&(e=-e,s=!0),r=4*(n=2/(2+e))-2;a>0;a--)o=u,u=r*u-c+l[a],c=o;return i=n*t.exp(-e*e+.5*(l[0]+r*u)-c),s?i-1:1-i},e.erfc=function(t){return 1-e.erf(t)},e.erfcinv=function(n){var r,o,i,l,a=0;if(n>=2)return -100;if(n<=0)return 100;for(l=n<1?n:2-n,r=-.70711*((2.30753+.27061*(i=t.sqrt(-2*t.log(l/2))))/(1+i*(.99229+.04481*i))-i);a<2;a++)o=e.erfc(r)-l,r+=o/(1.1283791670955126*t.exp(-r*r)-r*o);return n<1?r:-r},e.ibetainv=function(n,r,o){var i,l,a,s,u,c,d,f,m,p=r-1,h=o-1,g=0;if(n<=0)return 0;if(n>=1)return 1;for(r>=1&&o>=1?(u=(2.30753+.27061*(a=t.sqrt(-2*t.log(n<.5?n:1-n))))/(1+a*(.99229+.04481*a))-a,n<.5&&(u=-u),c=(u*u-3)/6,d=2/(1/(2*r-1)+1/(2*o-1)),f=u*t.sqrt(c+d)/d-(1/(2*o-1)-1/(2*r-1))*(c+5/6-2/(3*d)),u=r/(r+o*t.exp(2*f))):(i=t.log(r/(r+o)),l=t.log(o/(r+o)),f=(a=t.exp(r*i)/r)+(s=t.exp(o*l)/o),u=n<a/f?t.pow(r*f*n,1/r):1-t.pow(o*f*(1-n),1/o)),m=-e.gammaln(r)-e.gammaln(o)+e.gammaln(r+o);g<10&&0!==u&&1!==u&&(s=(e.ibeta(u,r,o)-n)/(a=t.exp(p*t.log(u)+h*t.log(1-u)+m)),(u-=a=s/(1-.5*t.min(1,s*(p/u-h/(1-u)))))<=0&&(u=.5*(u+a)),u>=1&&(u=.5*(u+a+1)),!(t.abs(a)<1e-8*u)||!(g>0));g++);return u},e.ibeta=function(n,r,o){var i=0===n||1===n?0:t.exp(e.gammaln(r+o)-e.gammaln(r)-e.gammaln(o)+r*t.log(n)+o*t.log(1-n));return!(n<0)&&!(n>1)&&(n<(r+1)/(r+o+2)?i*e.betacf(n,r,o)/r:1-i*e.betacf(1-n,o,r)/o)},e.randn=function(n,r){var o,i,l,a,s;if(r||(r=n),n)return e.create(n,r,function(){return e.randn()});do o=e._random_fn(),i=1.7156*(e._random_fn()-.5),s=(l=o-.449871)*l+(a=t.abs(i)+.386595)*(.196*a-.25472*l);while(s>.27597&&(s>.27846||i*i>-4*t.log(o)*o*o));return i/o},e.randg=function(n,r,o){var i,l,a,s,u,c,d=n;if(o||(o=r),n||(n=1),r)return(c=e.zeros(r,o)).alter(function(){return e.randg(n)}),c;n<1&&(n+=1),i=n-1/3,l=1/t.sqrt(9*i);do{do s=1+l*(u=e.randn());while(s<=0);s=s*s*s,a=e._random_fn()}while(a>1-.331*t.pow(u,4)&&t.log(a)>.5*u*u+i*(1-s+t.log(s)));if(n==d)return i*s;do a=e._random_fn();while(0===a);return t.pow(a,1/d)*i*s};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(" "),i=0;i<o.length;i++)!function(t){e.fn[t]=function(){return e(e[t].apply(null,arguments))}}(o[i]);for(var l=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(" "),s=0;s<a.length;s++)!function(t){e[t]=function e(t,n,r){return this instanceof e?(this._a=t,this._b=n,this._c=r,this):new e(t,n,r)},e.fn[t]=function(n,r,o){var i=e[t](n,r,o);return i.data=this,i},e[t].prototype.sample=function(n){var r=this._a,o=this._b,i=this._c;return n?e.alter(n,function(){return e[t].sample(r,o,i)}):e[t].sample(r,o,i)};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,i=this._b,l=this._c;return(r||0===r||(r=this.data),"number"!=typeof r)?e.fn.map.call(r,function(r){return e[t][n](r,o,i,l)}):e[t][n](r,o,i,l)}}(n[r]);for(var o="mean median mode variance".split(" "),i=0;i<o.length;i++)!function(n){e[t].prototype[n]=function(){return e[t][n](this._a,this._b,this._c)}}(o[i])}(a[s]);function u(e,t,n,r){for(var o,i=0,a=1,s=1,u=1,c=0,d=0;l.abs((s-d)/s)>r;)d=s,i=s+(o=-(t+c)*(t+n+c)*e/(t+2*c)/(t+2*c+1))*i,a=u+o*a,c+=1,s=i+(o=c*(n-c)*e/(t+2*c-1)/(t+2*c))*s,i/=u=a+o*u,a/=u,s/=u,u=1;return s/t}function c(t,n,r){var o=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],i=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],a=.5*t;if(a>=8)return 1;var s=2*e.normal.cdf(a,0,1,1,0)-1;s=s>=l.exp(-50/r)?l.pow(s,r):0;for(var u=a,c=(8-a)/(x=t>3?2:3),d=u+c,f=0,m=r-1,p=1;p<=x;p++){for(var h=0,g=.5*(d+u),v=.5*(d-u),y=1;y<=12;y++){var x,C,b=g+v*(6<y?o[(C=12-y+1)-1]:-o[(C=y)-1]),w=b*b;if(w>60)break;var T=.5*(2*e.normal.cdf(b,0,1,1,0))-.5*(2*e.normal.cdf(b,t,1,1,0));T>=l.exp(-30/m)&&(h+=T=i[C-1]*l.exp(-(.5*w))*l.pow(T,m))}h*=2*v*r/l.sqrt(2*l.PI),f+=h,u=d,d+=c}return(s+=f)<=l.exp(-30/n)?0:(s=l.pow(s,n))>=1?1:s}e.extend(e.beta,{pdf:function(t,n,r){return t>1||t<0?0:1==n&&1==r?1:n<512&&r<512?l.pow(t,n-1)*l.pow(1-t,r-1)/e.betafn(n,r):l.exp((n-1)*l.log(t)+(r-1)*l.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/(l.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)*l.pow(n/r,n/2)*l.pow(t,n/2-1)*l.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/(l.pow(e-t,2)+l.pow(n,2))/l.PI},cdf:function(e,t,n){return l.atan((e-t)/n)/l.PI+.5},inv:function(e,t,n){return t+n*l.tan(l.PI*(e-.5))},median:function(e){return e},mode:function(e){return e},sample:function(t,n){return e.randn()*l.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:l.exp((n/2-1)*l.log(t)-t/2-n/2*l.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*l.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*l.exp(-t*e)},cdf:function(e,t){return e<0?0:1-l.exp(-t*e)},inv:function(e,t){return-l.log(1-e)/t},mean:function(e){return 1/e},median:function(e){return 1/e*l.log(2)},mode:function(){return 0},sample:function(t){return -1/t*l.log(e._random_fn())},variance:function(e){return l.pow(e,-2)}}),e.extend(e.gamma,{pdf:function(t,n,r){return t<0?0:0===t&&1===n?1/r:l.exp((n-1)*l.log(t)-t/r-e.gammaln(n)-n*l.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:l.exp(-(n+1)*l.log(t)-r/t-e.gammaln(n)+n*l.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:l.exp(l.log(t)+l.log(n)+(t-1)*l.log(e)+(n-1)*l.log(1-l.pow(e,t)))},cdf:function(e,t,n){return e<0?0:e>1?1:1-l.pow(1-l.pow(e,t),n)},inv:function(e,t,n){return l.pow(1-l.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 l.pow(1-l.pow(2,-1/t),1/e)},mode:function(e,t){if(e>=1&&t>=1&&1!==e&&1!==t)return l.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:l.exp(-l.log(e)-.5*l.log(2*l.PI)-l.log(n)-l.pow(l.log(e)-t,2)/(2*n*n))},cdf:function(t,n,r){return t<0?0:.5+.5*e.erf((l.log(t)-n)/l.sqrt(2*r*r))},inv:function(t,n,r){return l.exp(-1.4142135623730951*r*e.erfcinv(2*t)+n)},mean:function(e,t){return l.exp(e+t*t/2)},median:function(e){return l.exp(e)},mode:function(e,t){return l.exp(e-t*t)},sample:function(t,n){return l.exp(e.randn()*n+t)},variance:function(e,t){return(l.exp(t*t)-1)*l.exp(2*e+t*t)}}),e.extend(e.noncentralt,{pdf:function(t,n,r){return 1e-14>l.abs(r)?e.studentt.pdf(t,n):1e-14>l.abs(t)?l.exp(e.gammaln((n+1)/2)-r*r/2-.5*l.log(l.PI*n)-e.gammaln(n/2)):n/t*(e.noncentralt.cdf(t*l.sqrt(1+2/n),n+2,r)-e.noncentralt.cdf(t,n,r))},cdf:function(t,n,r){if(1e-14>l.abs(r))return e.studentt.cdf(t,n);var o=!1;t<0&&(o=!0,r=-r);for(var i=e.normal.cdf(-r,0,1),a=1e-14+1,s=1e-14+1,u=t*t/(t*t+n),c=0,d=l.exp(-r*r/2),f=l.exp(-r*r/2-.5*l.log(2)-e.gammaln(1.5))*r;c<200||s>1e-14||a>1e-14;)s=a,c>0&&(d*=r*r/(2*c),f*=r*r/(2*(c+.5))),i+=.5*(a=d*e.beta.cdf(u,c+.5,n/2)+f*e.beta.cdf(u,c+1,n/2)),c++;return o?1-i:i}}),e.extend(e.normal,{pdf:function(e,t,n){return l.exp(-.5*l.log(2*l.PI)-l.log(n)-l.pow(e-t,2)/(2*n*n))},cdf:function(t,n,r){return .5*(1+e.erf((t-n)/l.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*l.pow(t,n)/l.pow(e,n+1)},cdf:function(e,t,n){return e<t?0:1-l.pow(t/e,n)},inv:function(e,t,n){return t/l.pow(1-e,1/n)},mean:function(e,t){if(!(t<=1))return t*l.pow(e,t)/(t-1)},median:function(e,t){return e*(t*l.SQRT2)},mode:function(e){return e},variance:function(e,t){if(!(t<=2))return e*e*t/(l.pow(t-1,2)*(t-2))}}),e.extend(e.studentt,{pdf:function(t,n){return n=n>1e100?1e100:n,1/(l.sqrt(n)*e.betafn(.5,n/2))*l.pow(1+t*t/n,-((n+1)/2))},cdf:function(t,n){var r=n/2;return e.ibeta((t+l.sqrt(t*t+n))/(2*l.sqrt(t*t+n)),r,r)},inv:function(t,n){var r=e.ibetainv(2*l.min(t,1-t),.5*n,.5);return r=l.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()*l.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*l.pow(e/t,n-1)*l.exp(-l.pow(e/t,n))},cdf:function(e,t,n){return e<0?0:1-l.exp(-l.pow(e/t,n))},inv:function(e,t,n){return t*l.pow(-l.log(1-e),1/n)},mean:function(t,n){return t*e.gammafn(1+1/n)},median:function(e,t){return e*l.pow(l.log(2),1/t)},mode:function(e,t){return t<=1?0:e*l.pow((t-1)/t,1/t)},sample:function(t,n){return t*l.pow(-l.log(e._random_fn()),1/n)},variance:function(t,n){return t*t*e.gammafn(1+2/n)-l.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 l.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)*l.pow(r,t)*l.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,i=(t=l.floor(t))+1,a=n-t,s=i+a,c=l.exp(e.gammaln(s)-e.gammaln(a)-e.gammaln(i)+i*l.log(r)+a*l.log(1-r));return o=r<(i+1)/(s+2)?c*u(r,i,a,1e-10):1-c*u(1-r,a,i,1e-10),l.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)*l.pow(1-r,t)*l.pow(r,n))},cdf:function(t,n,r){var o=0,i=0;if(t<0)return 0;for(;i<=t;i++)o+=e.negbin.pdf(i,n,r);return o}}),e.extend(e.hypgeom,{pdf:function(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 i=1,a=0,s=0;s<t;s++){for(;i>1&&a<o;)i*=1-r/(n-a),a++;i*=(o-s)*(r-s)/((s+1)*(n-r-o+s+1))}for(;a<o;a++)i*=1-r/(n-a);return l.min(1,l.max(0,i))},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 i=1,a=1,s=0,u=0;u<t;u++){for(;i>1&&s<o;){var c=1-r/(n-s);a*=c,i*=c,s++}a*=(o-u)*(r-u)/((u+1)*(n-r-o+u+1)),i+=a}for(;s<o;s++)i*=1-r/(n-s);return l.min(1,l.max(0,i))}}),e.extend(e.poisson,{pdf:function(t,n){return n<0||t%1!=0||t<0?0:l.pow(n,t)*l.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=l.exp(-t);do r++,n*=e._random_fn();while(n>o);return r-1},sampleLarge:function(t){var n,r,o,i,a,s,u,c,d,f;for(i=l.sqrt(t),a=l.log(t),s=-.059+.02483*(u=.931+2.53*i),c=1.1239+1.1328/(u-3.4),d=.9277-3.6224/(u-2);;){if(r=l.random()-.5,o=l.random(),f=.5-l.abs(r),n=l.floor((2*s/f+u)*r+t+.43),f>=.07&&o<=d)return n;if(!(n<0)&&(!(f<.013)||!(o>f))&&l.log(o)+l.log(c)-l.log(s/(f*f)+u)<=-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?l.pow(e-t,2)/((n-t)*(r-t)):1-l.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)*l.sqrt((r-t)/(n-t)*e):t+(n-t)*(1-l.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-l.sqrt((t-e)*(t-n))/l.sqrt(2):n>(e+t)/2?e+l.sqrt((t-e)*(n-e))/l.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+l.sqrt(o*(n-t)*(r-t)):n-l.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/l.PI*l.pow(l.pow(n-t,2)-l.pow(2*e-t-n,2),-.5)},cdf:function(e,t,n){return e<t?0:e<n?2/l.PI*l.asin(l.sqrt((e-t)/(n-t))):1},inv:function(e,t,n){return t+(.5-.5*l.cos(l.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*l.sin(2*l.PI*e.uniform.sample(0,1))},variance:function(e,t){return t<=e?NaN:l.pow(t-e,2)/8}}),e.extend(e.laplace,{pdf:function(e,t,n){return n<=0?0:l.exp(-l.abs(e-t)/n)/(2*n)},cdf:function(e,t,n){return n<=0?0:e<t?.5*l.exp((e-t)/n):1-.5*l.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/l.abs(r))*l.log(1-2*l.abs(r))}}),e.extend(e.tukey,{cdf:function(t,n,r){var o=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],i=[.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,s=a*l.log(r)-r*l.log(2)-e.gammaln(a),u=a-1,d=.25*r;p=r<=100?1:r<=800?.5:r<=5e3?.25:.125,s+=l.log(p);for(var f=0,m=1;m<=50;m++){for(var p,h,g,v=0,y=(2*m-1)*p,x=1;x<=16;x++)if(8<x?(h=x-8-1,g=s+u*l.log(y+o[h]*p)-(o[h]*p+y)*d):(h=x-1,g=s+u*l.log(y-o[h]*p)+(o[h]*p-y)*d),g>=-30){v+=c(8<x?t*l.sqrt((o[h]*p+y)*.5):t*l.sqrt((-(o[h]*p)+y)*.5),1,n)*i[h]*l.exp(g)}if(m*p>=1&&v<=1e-14)break;f+=v}if(v>1e-14)throw Error("tukey.cdf failed to converge");return f>1&&(f=1),f},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,i,a,s,u,c,d=(a=.5-.5*t,u=(s=l.sqrt(l.log(1/(a*a))))+((((-453642210148e-16*s+-.204231210125)*s+-.342242088547)*s+-1)*s+.322232421088)/((((.0038560700634*s+.10353775285)*s+.531103462366)*s+.588581570495)*s+.099348462606),r<120&&(u+=(u*u*u+u)/r/4),c=.8832-.2368*u,r<120&&(c+=-1.214/r+1.208*u/r),u*(c*l.log(n-1)+1.4142)),f=e.tukey.cdf(d,n,r)-t;o=f>0?l.max(0,d-1):d+1;for(var m=e.tukey.cdf(o,n,r)-t,p=1;p<50;p++)if(i=o-m*(o-d)/(m-f),f=m,d=o,i<0&&(i=0,m=-t),m=e.tukey.cdf(i,n,r)-t,o=i,1e-4>l.abs(o-d))return i;throw Error("tukey.inv failed to converge")}}),function(e,t){var n,r,o=Array.prototype.push,i=e.utils.isArray;function l(t){return i(t)||t instanceof e}e.extend({add:function(t,n){return l(n)?(l(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 l(n)?(l(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 l(n)?(l(n[0])||(n=[n]),e.multiply(t,e.inv(n))):e.map(t,function(e){return e/n})},multiply:function(t,n){var r,o,i,a,s,u,c,d;if(void 0===t.length&&void 0===n.length)return t*n;if(s=t.length,u=t[0].length,c=e.zeros(s,i=l(n)?n[0].length:u),d=0,l(n)){for(;d<i;d++)for(r=0;r<s;r++){for(o=0,a=0;o<u;o++)a+=t[r][o]*n[o][d];c[r][d]=a}return 1===s&&1===d?c[0][0]:c}return e.map(t,function(e){return e*n})},outer:function(t,n){return e.multiply(t.map(function(e){return[e]}),[n])},dot:function(t,n){l(t[0])||(t=[t]),l(n[0])||(n=[n]);for(var r,o,i=1===t[0].length&&1!==t.length?e.transpose(t):t,a=1===n[0].length&&1!==n.length?e.transpose(n):n,s=[],u=0,c=i.length,d=i[0].length;u<c;u++){for(o=0,s[u]=[],r=0;o<d;o++)r+=i[u][o]*a[u][o];s[u]=r}return 1===s.length?s[0]:s},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),l(e[0])&&(e=e[0]);o<e.length;o++)r+=t.pow(t.abs(e[o]),n);return t.pow(r,1/n)},angle:function(n,r){return t.acos(e.dot(n,r)/(e.norm(n)*e.norm(r)))},aug:function(e,t){var n,r=[];for(n=0;n<e.length;n++)r.push(e[n].slice());for(n=0;n<r.length;n++)o.apply(r[n],t[n]);return r},inv:function(t){for(var n,r=t.length,o=t[0].length,i=e.identity(r,o),l=e.gauss_jordan(t,i),a=[],s=0;s<r;s++)for(a[s]=[],n=o;n<l[0].length;n++)a[s][n-o]=l[s][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=[],i=1;i<t.length;i++){o[i-1]=[];for(var l=0;l<t.length;l++)l<r?o[i-1][l]=t[i][l]:l>r&&(o[i-1][l-1]=t[i][l])}var a=r%2?-1:1;n+=e(o)*t[0][r]*a}return n},gauss_elimination:function(n,r){var o,i,l,a,s=0,u=0,c=n.length,d=n[0].length,f=1,m=0,p=[];for(s=0,o=(n=e.aug(n,r))[0].length;s<c;s++){for(i=n[s][s],u=s,a=s+1;a<d;a++)i<t.abs(n[a][s])&&(i=n[a][s],u=a);if(u!=s)for(a=0;a<o;a++)l=n[s][a],n[s][a]=n[u][a],n[u][a]=l;for(u=s+1;u<c;u++)for(f=n[u][s]/n[s][s],a=s;a<o;a++)n[u][a]=n[u][a]-f*n[s][a]}for(s=c-1;s>=0;s--){for(m=0,u=s+1;u<=c-1;u++)m+=p[u]*n[s][u];p[s]=(n[s][o-1]-m)/n[s][s]}return p},gauss_jordan:function(n,r){var o,i,l,a=e.aug(n,r),s=a.length,u=a[0].length,c=0;for(i=0;i<s;i++){var d=i;for(l=i+1;l<s;l++)t.abs(a[l][i])>t.abs(a[d][i])&&(d=l);var f=a[i];for(a[i]=a[d],a[d]=f,l=i+1;l<s;l++)for(c=a[l][i]/a[i][i],o=i;o<u;o++)a[l][o]-=a[i][o]*c}for(i=s-1;i>=0;i--){for(l=0,c=a[i][i];l<i;l++)for(o=u-1;o>i-1;o--)a[l][o]-=a[i][o]*a[l][i]/c;for(a[i][i]/=c,o=s;o<u;o++)a[i][o]/=c}return a},triaUpSolve:function(t,n){var r,o=t[0].length,i=e.zeros(1,o)[0],l=!1;return(void 0!=n[0].length&&(n=n.map(function(e){return e[0]}),l=!0),e.arange(o-1,-1,-1).forEach(function(l){r=e.arange(l+1,o).map(function(e){return i[e]*t[l][e]}),i[l]=(n[l]-e.sum(r))/t[l][l]}),l)?i.map(function(e){return[e]}):i},triaLowSolve:function(t,n){var r,o=t[0].length,i=e.zeros(1,o)[0],l=!1;return(void 0!=n[0].length&&(n=n.map(function(e){return e[0]}),l=!0),e.arange(o).forEach(function(o){r=e.arange(o).map(function(e){return t[o][e]*i[e]}),i[o]=(n[o]-e.sum(r))/t[o][o]}),l)?i.map(function(e){return[e]}):i},lu:function(t){var n,r=t.length,o=e.identity(r),i=e.zeros(t.length,t[0].length);return e.arange(r).forEach(function(e){i[0][e]=t[0][e]}),e.arange(1,r).forEach(function(l){e.arange(l).forEach(function(r){n=e.arange(r).map(function(e){return o[l][e]*i[e][r]}),o[l][r]=(t[l][r]-e.sum(n))/i[r][r]}),e.arange(l,r).forEach(function(r){n=e.arange(l).map(function(e){return o[l][e]*i[e][r]}),i[l][r]=t[n.length][r]-e.sum(n)})}),[o,i]},cholesky:function(n){var r,o=n.length,i=e.zeros(n.length,n[0].length);return e.arange(o).forEach(function(l){r=e.arange(l).map(function(e){return t.pow(i[l][e],2)}),i[l][l]=t.sqrt(n[l][l]-e.sum(r)),e.arange(l+1,o).forEach(function(t){r=e.arange(l).map(function(e){return i[l][e]*i[t][e]}),i[t][l]=(n[l][t]-e.sum(r))/i[l][l]})}),i},gauss_jacobi:function(n,r,o,i){for(var l,a,s,u,c=0,d=0,f=n.length,m=[],p=[],h=[];c<f;c++)for(d=0,m[c]=[],p[c]=[],h[c]=[];d<f;d++)c>d?(m[c][d]=n[c][d],p[c][d]=h[c][d]=0):c<d?(p[c][d]=n[c][d],m[c][d]=h[c][d]=0):(h[c][d]=n[c][d],m[c][d]=p[c][d]=0);for(s=e.multiply(e.multiply(e.inv(h),e.add(m,p)),-1),a=e.multiply(e.inv(h),r),l=o,u=e.add(e.multiply(s,o),a),c=2;t.abs(e.norm(e.subtract(u,l)))>i;)l=u,u=e.add(e.multiply(s,l),a),c++;return u},gauss_seidel:function(n,r,o,i){for(var l,a,s,u,c,d=0,f=n.length,m=[],p=[],h=[];d<f;d++)for(l=0,m[d]=[],p[d]=[],h[d]=[];l<f;l++)d>l?(m[d][l]=n[d][l],p[d][l]=h[d][l]=0):d<l?(p[d][l]=n[d][l],m[d][l]=h[d][l]=0):(h[d][l]=n[d][l],m[d][l]=p[d][l]=0);for(u=e.multiply(e.multiply(e.inv(e.add(h,m)),p),-1),s=e.multiply(e.inv(e.add(h,m)),r),a=o,c=e.add(e.multiply(u,o),s),d=2;t.abs(e.norm(e.subtract(c,a)))>i;)a=c,c=e.add(e.multiply(u,a),s),d+=1;return c},SOR:function(n,r,o,i,l){for(var a,s,u,c,d,f=0,m=n.length,p=[],h=[],g=[];f<m;f++)for(a=0,p[f]=[],h[f]=[],g[f]=[];a<m;a++)f>a?(p[f][a]=n[f][a],h[f][a]=g[f][a]=0):f<a?(h[f][a]=n[f][a],p[f][a]=g[f][a]=0):(g[f][a]=n[f][a],p[f][a]=h[f][a]=0);for(c=e.multiply(e.inv(e.add(g,e.multiply(p,l))),e.subtract(e.multiply(g,1-l),e.multiply(h,l))),u=e.multiply(e.multiply(e.inv(e.add(g,e.multiply(p,l))),r),l),s=o,d=e.add(e.multiply(c,o),u),f=2;t.abs(e.norm(e.subtract(d,s)))>i;)s=d,d=e.add(e.multiply(c,s),u),f++;return d},householder:function(n){for(var r,o,i,l,a=n.length,s=n[0].length,u=0,c=[],d=[];u<a-1;u++){for(r=0,l=u+1;l<s;l++)r+=n[l][u]*n[l][u];for(r=(n[u+1][u]>0?-1:1)*t.sqrt(r),o=t.sqrt((r*r-n[u+1][u]*r)/2),(c=e.zeros(a,1))[u+1][0]=(n[u+1][u]-r)/(2*o),i=u+2;i<a;i++)c[i][0]=n[i][u]/(2*o);d=e.subtract(e.identity(a,s),e.multiply(e.multiply(c,e.transpose(c)),2)),n=e.multiply(d,e.multiply(n,d))}return n},QR:(n=e.sum,r=e.arange,function(o){var i,l,a,s=o.length,u=o[0].length,c=e.zeros(u,u);for(l=0,o=e.copy(o);l<u;l++){for(i=0,c[l][l]=t.sqrt(n(r(s).map(function(e){return o[e][l]*o[e][l]})));i<s;i++)o[i][l]=o[i][l]/c[l][l];for(a=l+1;a<u;a++)for(i=0,c[l][a]=n(r(s).map(function(e){return o[e][l]*o[e][a]}));i<s;i++)o[i][a]=o[i][a]-o[i][l]*c[l][a]}return[o,c]}),lstsq:function(t,n){var r,o,i,l=!1;void 0===n[0].length&&(n=n.map(function(e){return[e]}),l=!0);var a=e.QR(t),s=a[0],u=a[1],c=t[0].length,d=e.slice(s,{col:{end:c}}),f=(r=e.slice(u,{row:{end:c}}),o=(r=e.copy(r)).length,i=e.identity(o),e.arange(o-1,-1,-1).forEach(function(t){e.sliceAssign(i,{row:t},e.divide(e.slice(i,{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),l=e.slice(r,{row:n}),a=e.multiply(e.slice(r,{row:t}),o);e.sliceAssign(r,{row:n},e.add(l,a));var s=e.slice(i,{row:n}),u=e.multiply(e.slice(i,{row:t}),o);e.sliceAssign(i,{row:n},e.add(s,u))})}),i),m=e.transpose(d);void 0===m[0].length&&(m=[m]);var p=e.multiply(e.multiply(f,m),n);return(void 0===p.length&&(p=[[p]]),l)?p.map(function(e){return e[0]}):p},jacobi:function(n){for(var r,o,i,l,a,s,u,c=1,d=n.length,f=e.identity(d,d),m=[];1===c;){for(r=0,a=n[0][1],i=0,l=1;r<d;r++)for(o=0;o<d;o++)r!=o&&a<t.abs(n[r][o])&&(a=t.abs(n[r][o]),i=r,l=o);for(r=1,s=n[i][i]===n[l][l]?n[i][l]>0?t.PI/4:-t.PI/4:t.atan(2*n[i][l]/(n[i][i]-n[l][l]))/2,(u=e.identity(d,d))[i][i]=t.cos(s),u[i][l]=-t.sin(s),u[l][i]=t.sin(s),u[l][l]=t.cos(s),f=e.multiply(f,u),n=e.multiply(e.multiply(e.inv(u),n),u),c=0;r<d;r++)for(o=1;o<d;o++)r!=o&&t.abs(n[r][o])>.001&&(c=1)}for(r=0;r<d;r++)m.push(n[r][r]);return[f,m]},rungekutta:function(e,t,n,r,o,i){var l,a,s,u;if(2===i)for(;r<=n;)l=t*e(r,o),a=t*e(r+t,o+l),o+=(l+a)/2,r+=t;if(4===i)for(;r<=n;)l=t*e(r,o),a=t*e(r+t/2,o+l/2),s=t*e(r+t/2,o+a/2),u=t*e(r+t,o+s),o+=(l+2*a+2*s+u)/6,r+=t;return o},romberg:function(e,n,r,o){for(var i,l,a,s,u,c=0,d=(r-n)/2,f=[],m=[],p=[];c<o/2;){for(u=e(n),a=n,s=0;a<=r;a+=d,s++)f[s]=a;for(a=1,i=f.length;a<i-1;a++)u+=(a%2!=0?4:2)*e(f[a]);u=d/3*(u+e(r)),p[c]=u,d/=2,c++}for(l=p.length,i=1;1!==l;){for(a=0;a<l-1;a++)m[a]=(t.pow(4,i)*p[a+1]-p[a])/(t.pow(4,i)-1);l=m.length,p=m,m=[],i++}return p},richardson:function(e,n,r,o){function i(e,t){for(var n,r=0,o=e.length;r<o;r++)e[r]===t&&(n=r);return n}for(var l,a,s,u,c,d=t.abs(r-e[i(e,r)+1]),f=0,m=[],p=[];o>=d;)l=i(e,r+o),a=i(e,r),m[f]=(n[l]-2*n[a]+n[2*a-l])/(o*o),o/=2,f++;for(u=m.length,s=1;1!=u;){for(c=0;c<u-1;c++)p[c]=(t.pow(4,s)*m[c+1]-m[c])/(t.pow(4,s)-1);u=p.length,m=p,p=[],s++}return m},simpson:function(e,t,n,r){for(var o,i=(n-t)/r,l=e(t),a=[],s=t,u=0,c=1;s<=n;s+=i,u++)a[u]=s;for(o=a.length;c<o-1;c++)l+=(c%2!=0?4:2)*e(a[c]);return i/3*(l+e(n))},hermite:function(e,t,n,r){for(var o,i=e.length,l=0,a=0,s=[],u=[],c=[],d=[];a<i;a++){for(o=0,s[a]=1;o<i;o++)a!=o&&(s[a]*=(r-e[o])/(e[a]-e[o]));for(o=0,u[a]=0;o<i;o++)a!=o&&(u[a]+=1/(e[a]-e[o]));c[a]=(1-2*(r-e[a])*u[a])*(s[a]*s[a]),d[a]=(r-e[a])*(s[a]*s[a]),l+=c[a]*t[a]+d[a]*n[a]}return l},lagrange:function(e,t,n){for(var r,o,i=0,l=0,a=e.length;l<a;l++){for(r=0,o=t[l];r<a;r++)l!=r&&(o*=(n-e[r])/(e[l]-e[r]));i+=o}return i},cubic_spline:function(t,n,r){for(var o,i=t.length,l=0,a=[],s=[],u=[],c=[],d=[],f=[],m=[];l<i-1;l++)d[l]=t[l+1]-t[l];for(l=1,u[0]=0;l<i-1;l++)u[l]=3/d[l]*(n[l+1]-n[l])-3/d[l-1]*(n[l]-n[l-1]);for(l=1;l<i-1;l++)a[l]=[],s[l]=[],a[l][l-1]=d[l-1],a[l][l]=2*(d[l-1]+d[l]),a[l][l+1]=d[l],s[l][0]=u[l];for(o=0,c=e.multiply(e.inv(a),s);o<i-1;o++)f[o]=(n[o+1]-n[o])/d[o]-d[o]*(c[o+1][0]+2*c[o][0])/3,m[o]=(c[o+1][0]-c[o][0])/(3*d[o]);for(o=0;o<i&&!(t[o]>r);o++);return n[o-=1]+(r-t[o])*f[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,i=t[0].length,l=0,a=[],s=[],u=[],c=[],d=[],f=[],m=[],p=[],h=[],g=[];for(l=0;l<o;l++)a[l]=e.sum(t[l])/i;for(l=0;l<i;l++)for(n=0,m[l]=[];n<o;n++)m[l][n]=t[n][l]-a[n];for(l=0,m=e.transpose(m);l<o;l++)for(n=0,p[l]=[];n<o;n++)p[l][n]=e.dot([m[l]],[m[n]])/(i-1);for(l=0,h=(u=e.jacobi(p))[0],s=u[1],g=e.transpose(h);l<s.length;l++)for(n=l;n<s.length;n++)s[l]<s[n]&&(r=s[l],s[l]=s[n],s[n]=r,c=g[l],g[l]=g[n],g[n]=c);for(l=0,f=e.transpose(m);l<o;l++)for(n=0,d[l]=[];n<f.length;n++)d[l][n]=e.dot([g[l]],[f[n]]);return[t,s,g,d]}});for(var a="add divide multiply subtract dot pow exp log abs norm angle".split(" "),s=0;s<a.length;s++)!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[s])}(e,Math);var d=Math,f=[].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)/d.sqrt(o*(1-o)*(1/t+1/r))}return e.extend({zscore:function(){var t=f.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=f.call(arguments);return p(n[1])?(t=e.zscore(n[0],n[1],n[3]),1===n[2]?e.normal.cdf(-d.abs(t),0,1):2*e.normal.cdf(-d.abs(t),0,1)):n.length>2?(t=e.zscore(n[0],n[1],n[2]),1===n[3]?e.normal.cdf(-d.abs(t),0,1):2*e.normal.cdf(-d.abs(t),0,1)):(t=n[0],1===n[1]?e.normal.cdf(-d.abs(t),0,1):2*e.normal.cdf(-d.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=d.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=f.call(arguments);return 4===t.length?(t[0]-t[1])/(t[2]/d.sqrt(t[3])):(t[0]-e.mean(t[1]))/(e.stdev(t[1],!0)/d.sqrt(t[1].length))},ttest:function(){var t,n=f.call(arguments);return 5===n.length?(t=d.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=d.abs(n[0]),1==n[2]?e.studentt.cdf(-t,n[1]-1):2*e.studentt.cdf(-t,n[1]-1)):(t=d.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)/d.sqrt(this.cols()))},ttest:function(t,n){return 1===n?1-e.studentt.cdf(d.abs(this.tscore(t)),this.cols()-1):2*e.studentt.cdf(-d.abs(this.tscore(t)),this.cols()-1)}}),e.extend({anovafscore:function(){var t,n,r,o,i,l,a,s,u=f.call(arguments);if(1===u.length){for(a=0,i=Array(u[0].length);a<u[0].length;a++)i[a]=u[0][a];u=i}for(a=0,n=[];a<u.length;a++)n=n.concat(u[a]);for(a=0,r=e.mean(n),t=0;a<u.length;a++)t+=u[a].length*d.pow(e.mean(u[a])-r,2);for(t/=u.length-1,l=0,a=0;a<u.length;a++)for(s=0,o=e.mean(u[a]);s<u[a].length;s++)l+=d.pow(u[a][s]-o,2);return t/(l/=n.length-u.length)},anovaftest:function(){var t,n,r,o,i=f.call(arguments);if(m(i[0]))return 1-e.centralF.cdf(i[0],i[1],i[2]);var l=e.anovafscore(i);for(o=0,t=i.length-1,r=0;o<i.length;o++)r+=i[o].length;return n=r-t-1,1-e.centralF.cdf(l,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,i,l=f.call(arguments);return m(l[0])?(t=l[0],n=l[1],r=l[2],o=l[3],i=l[4]):(t=e.mean(l[0]),n=e.mean(l[1]),r=l[0].length,o=l[1].length,i=l[2]),d.abs(t-n)/(i*d.sqrt((1/r+1/o)/2))},qtest:function(){var t,n=f.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),i=[],l=0;l<t.length;++l)for(var a=l+1;a<t.length;++a){var s=e.qtest(r[l],r[a],t[l].length,t[a].length,n,o,t.length);i.push([[l,a],s])}return i}}),e.extend({normalci:function(){var t,n=f.call(arguments),r=[,,];return t=4===n.length?d.abs(e.normal.inv(n[1]/2,0,1)*n[2]/d.sqrt(n[3])):d.abs(e.normal.inv(n[1]/2,0,1)*e.stdev(n[2])/d.sqrt(n[2].length)),r[0]=n[0]-t,r[1]=n[0]+t,r},tci:function(){var t,n=f.call(arguments),r=[,,];return t=4===n.length?d.abs(e.studentt.inv(n[1]/2,n[3]-1)*n[2]/d.sqrt(n[3])):d.abs(e.studentt.inv(n[1]/2,n[2].length-1)*e.stdev(n[2],!0)/d.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 i=h(t,n,r,o);return e.ztest(i,1)},twoSidedDifferenceOfProportions:function(t,n,r,o){var i=h(t,n,r,o);return e.ztest(i,2)}}),e.models=function(){function t(t,n){var r=t.length,o=n[0].length-1,i=e.lstsq(n,t),l=e.multiply(n,i.map(function(e){return[e]})).map(function(e){return e[0]}),a=e.subtract(t,l),s=e.mean(t),u=e.sum(l.map(function(e){return Math.pow(e-s,2)})),c=e.sum(t.map(function(e,t){return Math.pow(e-l[t],2)})),d=u+c;return{exog:n,endog:t,nobs:r,df_model:o,df_resid:r-o-1,coef:i,predict:l,resid:a,ybar:s,SST:d,SSE:u,SSR:c,R2:u/d}}return{ols:function(n,r){var o,i,l,a,s,u,c,d,f,m,p,h,g,v,y=t(n,r),x=(i=(o=y.exog)[0].length,l=e.arange(i).map(function(n){var r=e.arange(i).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),s=l.map(function(e){return a/Math.sqrt(e.SST*(1-e.R2))}),c=(u=y.coef.map(function(e,t){return(e-0)/s[t]})).map(function(t){var n=e.studentt.cdf(t,y.df_resid);return(n>.5?1-n:n)*2}),d=e.studentt.inv(.975,y.df_resid),f=y.coef.map(function(e,t){var n=d*s[t];return[e-n,e+n]}),{se:s,t:u,p:c,sigmaHat:a,interval95:f}),C=(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}),b=1-(1-y.R2)*((y.nobs-1)/y.df_resid);return y.t=x,y.f=C,y.adjust_R2=b,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,i,l,a;if(t.cols()==n.rows()){if(n.rows()>1){for(r=0,l=[];r<t.rows();r++)for(o=0,l[r]=[];o<n.cols();o++){for(i=0,a=0;i<t.cols();i++)a+=t.toArray()[r][i]*n.toArray()[i][o];l[r][o]=a}return e(l)}for(r=0,l=[];r<t.rows();r++)for(o=0,l[r]=[];o<n.cols();o++){for(i=0,a=0;i<t.cols();i++)a+=t.toArray()[r][i]*n.toArray()[o];l[r][o]=a}return e(l)}},regress:function(t,n){var r=e.xtranspxinv(t),o=t.transpose(),i=e.matrixmult(e(r),o);return e.matrixmult(i,n)},regresst:function(t,n,r){var o,i,l,a=e.regress(t,n),s={};s.anova={};var u=e.jMatYBar(t,a);s.yBar=u;var c=n.mean();s.anova.residuals=e.residuals(n,u),s.anova.ssr=e.ssr(u,c),s.anova.msr=s.anova.ssr/(t[0].length-1),s.anova.sse=e.sse(n,u),s.anova.mse=s.anova.sse/(n.length-(t[0].length-1)-1),s.anova.sst=e.sst(n,c),s.anova.mst=s.anova.sst/(n.length-1),s.anova.r2=1-s.anova.sse/s.anova.sst,s.anova.r2<0&&(s.anova.r2=0),s.anova.fratio=s.anova.msr/s.anova.mse,s.anova.pvalue=e.anovaftest(s.anova.fratio,t[0].length-1,n.length-(t[0].length-1)-1),s.anova.rmse=Math.sqrt(s.anova.mse),s.anova.r2adj=1-s.anova.mse/s.anova.mst,s.anova.r2adj<0&&(s.anova.r2adj=0),s.stats=Array(t[0].length);for(var d=e.xtranspxinv(t),f=0;f<a.length;f++)o=Math.sqrt(s.anova.mse*Math.abs(d[f][f])),i=Math.abs(a[f]/o),l=e.ttest(i,n.length-t[0].length-1,r),s.stats[f]=[a[f],o,i,l];return s.regress=a,s},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 i=0;i<t[o].length;i++)r[o][i]=t[o][i]-n[o][i]}return e(r)}}),e.jStat=e,e}()},296(e,t,n){var r=n(137),o=n(344),i=n(14),l=n(364),a=n(394),s=n(380),u=n(320);u.alea=r,u.xor128=o,u.xorwow=i,u.xorshift7=l,u.xor4096=a,u.tychei=s,e.exports=u},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),i=t&&t.state,l=o.next;return l.int32=function(){return 0x100000000*o.next()|0},l.double=function(){return l()+(2097152*l()|0)*11102230246251565e-32},l.quick=l,i&&("object"==typeof i&&r(i,o),l.state=function(){return r(o,{})}),l}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),i=t&&t.state,l=function(){return(o.next()>>>0)/0x100000000};return l.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},l.int32=o.next,l.quick=l,i&&("object"==typeof i&&r(i,o),l.state=function(){return r(o,{})}),l}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),i=t&&t.state,l=function(){return(o.next()>>>0)/0x100000000};return l.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},l.int32=o.next,l.quick=l,i&&("object"==typeof i&&r(i,o),l.state=function(){return r(o,{})}),l}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,i=t.i;return t.w=r=r+0x61c88647|0,n=o[i+34&127],e=o[i=i+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=o[i]=n^e,t.i=i,n+(r^r>>>16)|0},!function(e,t){var n,r,o,i,l,a=[],s=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,s=Math.max(s,t.length)),o=0,i=-32;i<s;++i)t&&(r^=t.charCodeAt((i+32)%t.length)),0===i&&(l=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,i>=0&&(l=l+0x61c88647|0,o=0==(n=a[127&i]^=r+l)?o+1:0);for(o>=128&&(a[127&(t&&t.length||0)]=-1),o=127,i=512;i>0;--i)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=l,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),i=t&&t.state,l=function(){return(o.next()>>>0)/0x100000000};return l.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},l.int32=o.next,l.quick=l,i&&(i.X&&r(i,o),l.state=function(){return r(o,{})}),l}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),i=t&&t.state,l=function(){return(o.next()>>>0)/0x100000000};return l.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},l.int32=o.next,l.quick=l,i&&(i.x&&r(i,o),l.state=function(){return r(o,{})}),l}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),i=t&&t.state,l=function(){return(o.next()>>>0)/0x100000000};return l.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},l.int32=o.next,l.quick=l,i&&("object"==typeof i&&r(i,o),l.state=function(){return r(o,{})}),l}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 i,l="random",a=o.pow(256,6),s=o.pow(2,52),u=2*s;function c(e,n,c){var h=[],g=m(function e(t,n){var r,o=[],i=typeof t;if(n&&"object"==i)for(r in t)try{o.push(e(t[r],n-1))}catch(e){}return o.length?o:"string"==i?t:t+"\0"}((n=!0==n?{entropy:!0}:n||{}).entropy?[e,p(r)]:null==e?function(){try{var e;return i&&(e=i.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 d(h),y=function(){for(var e=v.g(6),t=a,n=0;e<s;)e=(e+n)*256,t*=256,n=v.g(1);for(;e>=u;)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&&f(r,v),e.state=function(){return f(v,{})}),n)?(o[l]=e,t):e})(y,g,"global"in n?n.global:this==o,n.state)}function d(e){var t,n=e.length,r=this,o=0,i=r.i=r.j=0,l=r.S=[];for(n||(e=[n++]);o<256;)l[o]=o++;for(o=0;o<256;o++)l[o]=l[i=255&i+e[o%n]+(t=l[o])],l[i]=t;(r.g=function(e){for(var t,n=0,o=r.i,i=r.j,l=r.S;e--;)t=l[o=255&o+1],n=256*n+l[255&(l[o]=l[i=255&i+t])+(l[i]=t)];return r.i=o,r.j=i,n})(256)}function f(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{i=n(562)}catch(e){}}else"function"==typeof define&&define.amd?define(function(){return c}):o["seed"+l]=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,i,l;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]})),i=void 0!==t.mxr&&void 0!==t.hs&&void 0!==t.poi&&void 0!==t.mnr,l={points:o,fitFunction:r.Qx,showFitLine:!0,showPoints:"points",clickToToggle:!0,name:t.rdt?`${t.rdt}`:"Dose-Response",droplines:["IC50"]},i&&(l.parameters=[t.mxr,t.hs,t.poi,t.mnr]),{chartOptions:{xAxisName:t.xu,yAxisName:t.yu,logX:!0},series:[l]}))}},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),i=n(590);let l="xAxis",a="yAxis";function s(e,t){var n;return(null==e||null==(n=e.getAttribute(t))?void 0:n.toLowerCase())==="true"}function u(e){var t,n,l;let a=null==(n=e.getElementsByTagName("params")[0])||null==(t=n.childNodes[0].nodeValue)?void 0:t.split(",").map(Number),u=null==(l=e.getElementsByTagName("function")[0])?void 0:l.getAttribute("type"),c=u&&"sigif"!==u&&u in o.rT?u:i.G7,d=e.getElementsByTagName("settings")[0].getAttribute("markerColor"),f=e.getElementsByTagName("settings")[0].getAttribute("color"),m=s(e.getElementsByTagName("settings")[0],"drawLine"),p={name:e.getAttribute("name"),fitFunction:c,markerType:r.MARKER_TYPE.CIRCLE,pointColor:d,fitLineColor:f,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,i;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(l)[0].getAttribute("min"),minY:+n.getElementsByTagName(a)[0].getAttribute("min"),maxX:+n.getElementsByTagName(l)[0].getAttribute("max"),maxY:+n.getElementsByTagName(a)[0].getAttribute("max"),xAxisName:r.getAttribute("xLabel"),yAxisName:r.getAttribute("yLabel"),logX:s(r,"logX")},null!==r.getAttribute("logY")?{logY:s(r,"logY")}:{}),{chartOptions:o,seriesOptions:u((i=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(","),i=null==(n=e.getElementsByTagName("y")[0].childNodes[0].nodeValue)?void 0:n.split(","),l=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:+i[e],outlier:"0"===l[e]};return a}(e),n=u(e),r={points:t};return Object.assign(r,n),r}(n)}return t}(i)}))}},124(e,t,n){"use strict";n.d(t,{HB:()=>d,XN:()=>m,l8:()=>s,nL:()=>f,p:()=>u});var r=n(82),o=n(788);function i(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}let l=new Map,a=new r.LruCache(2e3);function s(e,t){l.set(e,t)}function u(){var e;return(e=function*(){for(let e of r.Func.find({meta:{role:"curveConverter"}})){let t=e.options.curveFormat;t&&!l.has(t)&&s(t,(yield e.apply()))}},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,s,"next",e)}function s(e){i(l,r,o,a,s,"throw",e)}a(void 0)})})()}function c(e){let t=e.getTag(o.h.TAG_CURVE_FORMAT);return t&&""!==t?t:null}function d(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=l.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 f(e){return null!==c(e)}function m(e){return!f(e)}},53(e,t,n){"use strict";n.d(t,{B3:()=>D,CP:()=>f,G_:()=>F,IY:()=>E,Ig:()=>M,LX:()=>x,RH:()=>T,Th:()=>h,U6:()=>_,Xm:()=>A,ab:()=>p,bZ:()=>c,bc:()=>R,d3:()=>S,g2:()=>m,h8:()=>b,mI:()=>w,uc:()=>d,wU:()=>C});var r=n(82),o=n(590),i=n(165),l=n(869),a=n(774),s=n(788),u=n(124);let c=new r.LruCache(1e3),d=new r.LruCache(1e3),f=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 i,l,a;let s=null==(i=e.explicit)?void 0:i[r];g(n[r],null==(l=n.explicit)?void 0:l[r],o,s),g(t[r],null==(a=t.explicit)?void 0:a[r],o,s)}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 x(e,t=[]){let n,r,o;if(0===e.length)return{};let i=Number.MAX_VALUE,l=Number.MAX_VALUE,a=5e-324,s=5e-324,u=!1,c=!1,d=!1;for(let t of e)null!==t.minX&&void 0!==t.minX&&(i=Math.min(i,t.minX)),null!==t.minY&&void 0!==t.minY&&(l=Math.min(l,t.minY)),null!==t.maxX&&void 0!==t.maxX&&(a=Math.max(a,t.maxX)),null!==t.maxY&&void 0!==t.maxY&&(s=Math.max(s,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&&(u=!0),null!==t.logY&&void 0!==t.logY&&t.logY&&(c=!0),null!==t.allowXZeroes&&void 0!==t.allowXZeroes&&t.allowXZeroes&&(d=!0);for(let e of t)for(let t of e.points)t.x<i&&(i=Number.MAX_VALUE),t.x>a&&(a=5e-324),t.y<l&&(l=Number.MAX_VALUE),t.y>s&&(s=5e-324);return{minX:i===Number.MAX_VALUE?void 0:i,minY:l===Number.MAX_VALUE?void 0:l,maxX:5e-324===a?void 0:a,maxY:5e-324===s?void 0:s,title:o,xAxisName:n,yAxisName:r,logX:u,logY:c,allowXZeroes:d}}function C(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 b(e,t=!0){var n;let r=null==e?void 0:e.column;return t&&r&&e?d.getOrCreate((n=e.rowIndex,`tableId: ${r.dataFrame.id} || tableName: ${r.dataFrame.name} || colName: ${r.name} || colVersion: ${r.version} || rowIdx: ${n}`),()=>O(e)):O(e)}function w(e,t,n){let r=R(t),i=n?M(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,i.chartOptions,e.chartOptions),y(e.chartOptions,r.chartOptions,i.chartOptions),v(e,r,i,p,e.chartOptions),e.series))m(l.IL,e.seriesOptions,t),m(l.IL,r.seriesOptions,t),m(l.IL,i.seriesOptions,t),v(e,r,i,h,t);return e}function T(e){return e.includes("|")?e.replaceAll("|",""):e}function O(e){var t,n,a,s,c;let d=e.value,f=e.column,g=f?f.type===r.TYPE.STRING?(0,u.HB)(d,f):(0,i.Kh)():null!=(t=JSON.parse(null!=(n=T(d))?n:"{}"))?t:{};(null==f?void 0:f.type)!==r.TYPE.STRING||(null==(c=g.series)?void 0:c.length)||(g=(0,u.HB)(T(d),f));let x=e.column?R(e.column):{},C=e.column?M(e.dataFrame):{};for(let e of(null!=(a=g).series||(a.series=[]),null!=(s=g).chartOptions||(s.chartOptions=x.chartOptions),m(o.xs,x.chartOptions,g.chartOptions),m(o.xs,C.chartOptions,g.chartOptions),y(g.chartOptions,x.chartOptions,C.chartOptions),v(g,x,C,p,g.chartOptions),g.series))m(l.IL,g.seriesOptions,e),m(l.IL,x.seriesOptions,e),m(l.IL,C.seriesOptions,e),v(g,x,C,h,e);return g}let S=new r.LruCache(2e3),I=new WeakMap,P=0;function _(e){let t=I.get(e);return void 0===t&&I.set(e,t=++P),t}function N(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 E(e,t,n,r,o,i=!0,a){let s=A(e,t,r,!1,o,i),u=null==o?void 0:o.column;return a?S.getOrCreate(`${a} || logX: ${null==r?void 0:r.logX} || logY: ${null==r?void 0:r.logY}`,()=>(0,l.nT)(e,n,s,r)):i&&u&&o?c.getOrCreate(N(u,o,t,r),()=>(0,l.nT)(e,n,s,r)):(0,l.nT)(e,n,s,r)}function A(e,t,n,r,o,i=!0){let l=null==o?void 0:o.column;return i&&l&&o?f.getOrCreate(`${N(l,o,t,n)} || userParamsFlag: ${r}`,()=>(0,a.Sm)(e,n,r)):(0,a.Sm)(e,n,r)}function L(e){return JSON.parse(e[s.h.TAG_FIT]||e[s.h.TAG_FIT_LEGACY]||JSON.stringify((0,i.Kh)()))}function F(e,t){e[s.h.TAG_FIT]=JSON.stringify(t),delete e[s.h.TAG_FIT_LEGACY]}function M(e){return L(e.tags)}function R(e){return L(e.tags)}function D(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,i=0,l=[];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&&!l.includes(t.points[e].x)&&(l[l.length]=t.points[e].x,i++);if(0===i)continue;let a=Math.log10(r),s=i>1?(Math.log10(o)-a)/(i-1):1,u=Math.pow(10,a-s);for(let e=0;e<t.points.length;e++)0===t.points[e].x&&(t.points[e].x=u)}}},301(e,t,n){"use strict";n.d(t,{Z1:()=>h,kL:()=>m,nO:()=>p,pj:()=>g});var r=n(82),o=n(328),i=n(644),l=n(590),a=n(991),s=n.n(a),u=n(788);function c(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){c(i,r,o,l,a,"next",e)}function a(e){c(i,r,o,l,a,"throw",e)}l(void 0)})}}function f(e,t){return Math.random()*(t-e)+e}function m(e,t,n=1){let r=new Float32Array(e*n),o=new Float32Array(e*n),i=[f(1,2),f(1,2),f(1,2),f(-5,5)],a=0-Math.floor(e/2)*t,s=a+t*(e-1);for(let e=a,u=0;e<=s;e+=t,u++)for(let t=0;t<n;t++){r[u*n+t]=e-a+.1;let s=new Float32Array(4);s.set(i),o[u*n+t]=(0,l.ry)(s,e)}let u=(1===n?.2:.4)*(Math.max(...o)-Math.min(...o)),c=Math.min(...o);for(let e=0;e<r.length;e++)o[e]=-c+o[e]+f(0,u);return{x:r,y:o,params:i}}function p(e,t,n){let o=r.DataFrame.create(e);o.setTag(r.Tags.Id,crypto.randomUUID());for(let l=0;l<t;l++){let t=3===l?5:1,a=o.columns.addNewString(`json chart ${l}`);a.semType=u.h.FIT_SEM_TYPE;let c=l%2==0?n:1;for(let o=0;o<e;o++){let e={series:[],chartOptions:{showStatistics:1===c?["auc"]:[],xAxisName:"Conc.",yAxisName:"Activity",title:"Dose-Response curves"}};for(let o=0;o<c;o++){var i;let a=m(15,.5,t),u=r.Color.toHtml(r.Color.getCategoricalColor(l*n+o));null==(i=e.series)||i.push({parameters:void 0,fitLineColor:u,pointColor:u,showCurveConfidenceInterval:1===c,points:s().count().take(15*t).map(function(e){return{x:a.x[e],y:a.y[e]}}).toArray()})}a.set(o,JSON.stringify(e))}}return o}function h(){return d(function*(){o.shell.windows.showContextPanel=!0;let e=yield o.data.loadTable(`${i._package.webRoot}files/curves-demo.csv`);o.shell.addTableView(e)})()}function g(){return d(function*(){let e=yield o.data.loadTable(`${i._package.webRoot}files/demo/Assay_Curves.csv`);yield e.meta.detectSemanticTypes();let t=yield i._package.files.readAsText("demo/Assay_Curves.layout"),n=r.ViewLayout.fromJson(t);e.selection.set(13,!0),e.selection.set(14,!0);let l=o.shell.addTableView(e);yield r.delay(100),l.loadLayout(n,!0),o.shell.info("Select cells in Trellis plot to see corresponding curves in Multi Curve Viewer.",{timeout:10})})()}},181(e,t,n){"use strict";n.d(t,{e:()=>C,g:()=>v});var r=n(82),o=n(389),i=n(328),l=n(165),a=n(129),s=n(53),u=n(788),c=n(684),d=n(434),f=n(590),m=n(869),p=n(258);function h(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).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 i.shell.error(`Curves: ${t} is not registered`);let l=e.cell.dataFrame,a=e.cell.column.name,s=new Set(l.columns.names());try{yield o.prepare(g({table:l,curveColumn:e.cell.column},n)).call(!1,void 0,{processed:!1})}catch(e){i.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 i=[];for(let e=0;e<o.columns.length;e++){var l;let t=null==(l=o.columns.byIndex(e))?void 0:l.name;t&&i.push(t)}o.columns.setOrder(y(i,t,n))}(e,l.columns.names().filter(e=>!s.has(e)),a)},function(){var e=this,t=arguments;return new Promise(function(n,r){var i=o.apply(e,t);function l(e){h(i,n,r,l,a,"next",e)}function a(e){h(i,n,r,l,a,"throw",e)}l(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 x(e){let t=e.root.querySelector(".ui-input-multi-choice-checks");return t&&(t.style.maxHeight="none",t.style.overflowY="visible"),e}class C extends r.ObjectHandler{get type(){return"GridCell"}isApplicable(e){return e instanceof r.GridCell&&e.cellType===u.h.FIT_CELL_TYPE}renderProperties(e,t=null){var n,i,h,y,C,b,w,T;let O=o.accordion("Curves property panel"),S=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}),I=o.input.forProperty(S);o.tooltip.bind(I.captionLabel,"Controls the level at which properties will be switched");let P=(0,s.h8)(e.cell),_=(0,s.bc)(e.cell.column),N=(0,s.Ig)(e.cell.dataFrame),E={onValueChanged:(t,n)=>(0,p.FC)(e,n,s.Th,I.value)},A={onValueChanged:(t,n)=>(0,p.FC)(e,n,s.ab,I.value)},L=e=>{if(N.seriesOptions&&!(0,c.Yc)(N.seriesOptions[e])&&_.seriesOptions&&!(0,c.Yc)(_.seriesOptions[e])){var t;P.seriesOptions?(0,c.Yc)(P.seriesOptions[e])||(P.seriesOptions[e]=r.Color.toHtml("outlierColor"===e?r.Color.red:r.Color.getCategoricalColor(0))):(null==(t=P.series)?void 0:t.length)&&!(0,c.Yc)(P.series[0][e])&&(P.series[0][e]=r.Color.toHtml("outlierColor"===e?r.Color.red:r.Color.getCategoricalColor(0)))}},F=e.cell;L("pointColor"),L("fitLineColor"),L("outlierColor"),(0,s.g2)(m.IL,_.seriesOptions,P.seriesOptions?P.seriesOptions:P.series&&null!=(n=P.series[0])?n:{}),(0,s.g2)(m.IL,N.seriesOptions,P.seriesOptions?P.seriesOptions:P.series&&null!=(i=P.series[0])?i:{}),(0,s.g2)(f.xs,_.chartOptions,P.chartOptions?P.chartOptions:{}),(0,s.g2)(f.xs,N.chartOptions,P.chartOptions?P.chartOptions:{}),(null==(y=P.chartOptions)?void 0:y.allowXZeroes)&&(null==(C=P.chartOptions)?void 0:C.logX)&&(null==(b=P.series)?void 0:b.some(e=>e.points.some(e=>0===e.x)))&&(0,s.B3)(P);let M=o.form([I]),R=P.seriesOptions?P.seriesOptions:P.series[0],D=R&&"object"==typeof R.fitFunction?R.fitFunction:null,X=(0,p.s9)(P,D).map(e=>{var t,n;if("fitFunction"!==e.name||!D)return x(o.input.forProperty(e,R,E));let r=(t=g({},R),n=n={fitFunction:D.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!==D.name&&(R.fitFunction=e),E.onValueChanged(e,t)}})});o.forms.addGroup(M,"Series options",X),(null==(w=P.chartOptions)?void 0:w.showStatistics)&&(P.chartOptions.showStatistics=(0,p.QA)(P,P.chartOptions.showStatistics)),o.forms.addGroup(M,"Chart options",(0,p.di)(P).map(e=>x(o.input.forProperty(e,P.chartOptions,A)))),O.addPane("Options",()=>M);let Y=(null!=(h=null==(T=P.series)?void 0:T.length)?h:0)>1?["all","aggregated"]:["all"],k=r.Property.js("series",r.TYPE.STRING,{description:"Controls whether to show series statistics or aggregated statistics",defaultValue:"all",choices:Y,nullable:!1}),j=o.input.forProperty(k,null,{onValueChanged:()=>{O.getPane("Fit").root.lastElementChild.replaceChildren(B())}}),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}),V=o.input.forProperty(G,null,{onValueChanged:()=>{O.getPane("Fit").root.lastElementChild.replaceChildren(B())}});function B(){var t,n,r,i,a;let s=(null!=(t=null==(n=P.series)?void 0:n.length)?t:0)>1?"aggregated"===j.stringValue?[j.root,V.root]:[j.root]:null,u=o.divV(s),f=(0,l.s$)(P);if(f.x<=0&&P.chartOptions&&(P.chartOptions.logX=!1),f.y<=0&&P.chartOptions&&(P.chartOptions.logY=!1),"all"===j.stringValue){let t={logX:null==(r=P.chartOptions)?void 0:r.logX,logY:null==(i=P.chartOptions)?void 0:i.logY};for(let n=0;n<P.series.length;n++){let r=P.series[n],i=(0,d.TV)(r,n,t,F),s=(0,c.Z)(r,n,c.mE.FIT_LINE),f=null!=(a=r.name)?a:"series "+n;u.appendChild(o.panel([o.h1(f,{style:{color:s}}),o.input.form(i,(0,l.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,d.JR)(P,V.stringValue,F);u.appendChild(o.panel([o.h1(`series ${V.stringValue}`),o.input.form(t,(0,d.Uc)(P,V.stringValue),{onCreated:t=>t.root.appendChild(o.iconFA("plus",()=>v(e,"curveAggrStatistic",{propName:t.property.name,aggrType:V.stringValue}),`Calculate ${t.property.name} ${V.stringValue} for the whole column`))})]))}return u}let $=r.GridCellWidget.fromGridCell(e);$.canvas.addEventListener("click",e=>$.render());let H=O.addPane("Chart",()=>$.root),q=a.l.inflateScreenBounds(e.bounds);return(q.width<u.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||q.height<u.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT)&&(H.expanded=!0),O.addPane("Fit",()=>B()),O.root}}},476(e,t,n){"use strict";n.d(t,{Fw:()=>g,I4:()=>v,Oz:()=>b,fU:()=>w,hC:()=>C});var r=n(82),o=n(328),i=n(389),l=n(858),a=n(165),s=n(869),u=n(788),c=n(533),d=n(124),f=n(53),m=n(434),p=n(324),h=n(663);function g(e,t,n,r,i){if(t.outlier=!t.outlier,(0,d.XN)(e.cell.column)){let i=JSON.parse(e.cell.value);i.series[n].points[r].outlier=t.outlier,e.cell.column.set(e.cell.rowIndex,JSON.stringify(i),!0),o.events.fireCustomEvent("fit-cell-outlier-toggle",{gridCell:e,series:i.series[n],seriesIdx:n,pointIdx:r})}let l=e.grid.dataFrame.columns.byTags({".sourceColumn":e.cell.column.name});if(l)for(let t of(null!=i||(i=(0,f.h8)(e.cell)),l)){var a,u;let r,o={logX:null==(a=i.chartOptions)?void 0:a.logX,logY:null==(u=i.chartOptions)?void 0:u.logY},l=t.tags[".statistics"];if(null!==t.tags[".seriesAggregation"])r=(0,m.JR)(i,t.tags[".seriesAggregation"],e.cell)[l];else{if(t.tags[".seriesNumber"]!==n.toString())continue;r=(0,s.h5)((0,m.TV)(i.series[n],n,o,e.cell),l)}t.set(e.cell.rowIndex,null!=r?r:null)}}function v(e,t,n=!1){var o,a;if(!e.cell.value)return;let s=r.GridCellWidget.fromGridCell(e);s.root.style.removeProperty("aspectRatio"),s.root.style.height="100%",s.canvas.style.removeProperty("height"),s.canvas.style.removeProperty("width"),s.canvas.style.left="18px",s.canvas.style.top="18px";let u=i.dialog({title:"Edit chart"}).add(s.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});u.getButton("CANCEL").textContent="Close",n&&u.sub((0,l.merge)(e.grid.dataFrame.onDataChanged,e.grid.dataFrame.onMetadataChanged).subscribe(()=>s.render()))}function y(e,t,n){let o=n.xToScreen(t.x),i=n.yToScreen(t.y),l=(t.outlier?u.h.OUTLIER_PX_SIZE:u.h.POINT_PX_SIZE)/2+u.h.OUTLIER_HITBOX_RADIUS;return new r.Rect(o-l,i-l,2*l,2*l).containsPoint(new r.Point(e.x,e.y))}function x(e,t){var n,r,o,i;let l=(0,p.lc)(e,t),s=(0,p.Tv)(e,l.x,l.y,(0,p.ij)(e,t))[0];return new c.L((0,a.s$)(t),s,null!=(n=null==(o=t.chartOptions)?void 0:o.logX)&&n,null!=(r=null==(i=t.chartOptions)?void 0:i.logY)&&r)}function C(e,t){var n;if(!e.cell.value||!e.cell.column)return;let r=(0,f.h8)(e.cell,!1);for(let[e,t]of Object.entries(u.h.CONDITION_MAP))if(t(r.series)){o.shell.o=i.divText(e,{style:{color:"red"}});return}o.shell.o=e;let l=(0,p.fn)(e.bounds),a=x(l,r);for(let o=0;o<(null==(n=r.series)?void 0:n.length);o++)if(!r.series[o].connectDots&&r.series[o].clickToToggle&&"points"===r.series[o].showPoints&&!(l.width<u.h.MIN_AXES_CELL_PX_WIDTH)&&!(l.height<u.h.MIN_AXES_CELL_PX_HEIGHT))for(let n=0;n<r.series[o].points.length;n++){let i=r.series[o].points[n];if((!i.outlier||r.series[o].showOutliers)&&y({x:t.offsetX,y:t.offsetY},i,a))return void g(e,i,o,n,r)}}function b(e,t,n,o){var l,a,s,c,d,f,m;let p=x(t,e),g=(0,h.qd)(e,t)?(0,h.tp)(e,p.screen,o.x,o.y):null;if(null!==g)return i.tooltip.show((0,h.D5)(g),n.x+16,n.y+16),!0;for(let h=0;h<(null==(l=e.series)?void 0:l.length);h++)if("points"===e.series[h].showPoints)for(let l=0;l<e.series[h].points.length;l++){let g=e.series[h].points[l];if((!g.outlier||e.series[h].showOutliers)&&y(o,g,p))return i.tooltip.show(i.divV([i.divText(`${null!=(a=null==(c=e.chartOptions)?void 0:c.xAxisName)?a:"x"}: ${r.format(g.x,!(null==(d=e.chartOptions)?void 0:d.logX)?"#0.000":"scientific")}`),i.divText(`${null!=(s=null==(f=e.chartOptions)?void 0:f.yAxisName)?s:"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>=u.h.MIN_AXES_CELL_PX_WIDTH&&t.height>=u.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<u.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||o.height<u.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT){let r=i.canvas(300,200);n.render(r.getContext("2d"),0,0,300,200,e,null),i.tooltip.show(i.divV([r]),t.x,t.y)}let l=(0,f.h8)(null==e?void 0:e.cell);if(o.width>=u.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH&&o.height>=u.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT){if(b(l,o,t,{x:t.offsetX,y:t.offsetY}))return;i.tooltip.hide()}document.body.style.cursor="default"}},324(e,t,n){"use strict";n.d(t,{Tv:()=>i,W$:()=>d,ZK:()=>c,b1:()=>l,eG:()=>s,fn:()=>o,ij:()=>u,lc:()=>a,m:()=>f});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 i(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 i=n?r.h.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:r.h.AXES_LEFT_PX_MARGIN,l=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,s=r.h.AXES_RIGHT_PX_MARGIN;return[e.cutLeft(i).cutBottom(l).cutTop(a).cutRight(s),e.getBottom(l).getTop(a).cutLeft(i).cutRight(s),e.getLeft(i).getRight(r.h.AXES_RIGHT_PX_MARGIN).cutBottom(l).cutTop(a)]}function l(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 i=e.width>=r.h.MIN_X_AXIS_NAME_VISIBILITY_PX_WIDTH&&e.height>=r.h.MIN_Y_AXIS_NAME_VISIBILITY_PX_HEIGHT;return{x:i&&!!(null==(n=t.chartOptions)?void 0:n.xAxisName),y:i&&!!(null==(o=t.chartOptions)?void 0:o.yAxisName)}}function s(e,t){let n=a(e,t);return n.x||n.y}function u(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 d(e){return e.width>=r.h.MIN_DROPLINE_LABELS_PX_WIDTH&&e.height>=r.h.MIN_DROPLINE_LABELS_PX_HEIGHT}function f(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,{Al:()=>y,D5:()=>b,GU:()=>w,_i:()=>g,bp:()=>d,qd:()=>u,tp:()=>T});var o=n(82),i=n(389),l=n(788),a=n(684),s=n(324);function u(e,t){var n,r;return(null==(n=null==(r=e.chartOptions)?void 0:r.showLegend)||n)&&(0,s.ZK)(t)}let c='11px Roboto, "Roboto Local"';function d(){return Math.max(10,Math.floor(.75*window.innerHeight/l.h.LEGEND_RECORD_PX_HEIGHT))}let f=new WeakMap;function m(e){return null!=r||(r=document.createElement("canvas").getContext("2d")),r.font=c,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){var t,n,r,i;let l=null!=(t=e.series)?t:[],s=[...new Set(l.map(e=>e.columnName))].filter(e=>null!=e),u=[];for(let t of s){let n=l.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:l,idx:s}of((null==(r=e.chartOptions)?void 0:r.showColumnLabel)&&n.length>1&&u.push({text:t,color:"black"}),n))u.push({text:h(l,null==(i=e.chartOptions)?void 0:i.useAuxLegendNames),column:t,color:(0,a.Z)(l,s,a.mE.FIT_LINE),pointColor:(0,a.Z)(l,s,a.mE.POINT),marker:function(e){var t,n,r;let i=(null==(n=e.points)?void 0:n.length)?e.points[0].marker:null,l=(null==(r=e.points)?void 0:r.every(e=>e.marker===i&&null!=e.marker))?i:null;return null!=(t=null!=l?l:e.markerType)?t:o.MARKER_TYPE.CIRCLE}(l)})}let c=new Map;for(let e of u.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 u)void 0!==e.marker&&e.column&&c.get(e.text).size>1&&(e.text=`${e.column}: ${e.text}`);return u}function v(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 y(e,t,n,r,i){let l=[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!=i?i:0;if(!(null==r?void 0:r.length))return{rect:l[a],index:a};let s=l.map(e=>({taken:v(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)}))})),u=0;for(let e=1;e<l.length;e++)(s[e].taken<s[u].taken||s[e].taken===s[u].taken&&s[e].clearance>s[u].clearance)&&(u=e);return s[a].taken<=2||2*s[u].taken>=s[a].taken?{rect:l[a],index:a}:{rect:l[u],index:u}}function x(e){return Math.floor(l.h.POINT_PX_SIZE*e*1.5)+l.h.LEGEND_RECORD_LINE_PX_WIDTH+l.h.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN}function C(e,t,n,r,i){if(void 0===t.marker)return;let a=Math.floor(l.h.POINT_PX_SIZE*i*1.5);e.beginPath(),e.strokeStyle=t.color,e.lineWidth=2*i,e.moveTo(n+a,r),e.lineTo(n+a+l.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,d()),r=n.map(e=>{let n=i.canvas(x(1),l.h.LEGEND_RECORD_PX_HEIGHT);C(n.getContext("2d"),e,0,l.h.LEGEND_RECORD_PX_HEIGHT/2,1);let r=i.divH([n,i.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(i.divText(`+${e.length-n.length} more`)),i.divV(r)}function w(e,t,n,r,i){let a=function(e,t,n,r){let i=f.get(e),a=g(e);if(0===a.length)return{rows:[],hidden:0,entries:a,corner:0,whole:!0};let s=x(n);if(.55*t.width-s<=0)return{rows:[],hidden:0,entries:a,corner:0,whole:!0};let u=Math.floor(.5*t.height/l.h.LEGEND_RECORD_PX_HEIGHT),c=a.length>u?a.slice(0,Math.max(1,u-1)):a,d=a.length-c.length,h=l.h.LEGEND_RECORD_PX_HEIGHT*(c.length+ +(d>0)),C=Math.min(s+Math.max(...c.map(e=>m(e.text)),d>0?m(`+${d} more`):0),t.width-8),b=y(t,C,h,r,null==i?void 0:i.corner),w=(null==i?void 0:i.whole)?12:2,T=v(b.rect,r)<=w,O=T?C:Math.min(C,.55*t.width),S=c.map(e=>p(e.text,O-s)),I=s+Math.max(...S.map(m)),P=T?b:y(t,I,h,r,null==i?void 0:i.corner),_=P.rect,N=c.map((e,t)=>({entry:e,shown:S[t],box:new o.Rect(_.x,_.y+l.h.LEGEND_RECORD_PX_HEIGHT*t,I,l.h.LEGEND_RECORD_PX_HEIGHT)})),E=0===d?void 0:new o.Rect(_.x,_.y+l.h.LEGEND_RECORD_PX_HEIGHT*N.length,I,l.h.LEGEND_RECORD_PX_HEIGHT);return{rows:N,hidden:d,moreBox:E,entries:a,corner:P.index,whole:T}}(t,n,r,i),{rows:s,hidden:u}=a;if(0===s.length)return;f.set(t,{box:n,rows:s,moreBox:a.moreBox,entries:a.entries,corner:a.corner,whole:a.whole}),e.save(),e.font=c,e.textAlign="left";let d=s[0].box,h=l.h.LEGEND_RECORD_PX_HEIGHT*(s.length+ +(u>0));for(let t of(e.fillStyle="rgba(255, 255, 255, 0.75)",e.fillRect(d.x-3,d.y-3,d.width+6,h+6),s)){let n=t.box.maxY-l.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN;C(e,t.entry,t.box.x,n-l.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:x(r)),n)}u>0&&(e.fillStyle="black",e.fillText(`+${u} more`,d.x,s[s.length-1].box.maxY+l.h.LEGEND_RECORD_PX_HEIGHT-l.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN)),e.restore()}function T(e,t,n,r){var o;let i=f.get(e);if(!i||Math.round(i.box.x)!==Math.round(t.x)||Math.round(i.box.width)!==Math.round(t.width))return null;if(null==(o=i.moreBox)?void 0:o.contains(n,r))return i.entries;let l=i.rows.find(e=>e.box.contains(n,r));return l&&l.shown!==l.entry.text?[l.entry]:null}},258(e,t,n){"use strict";n.d(t,{FC:()=>y,QA:()=>m,di:()=>f,s9:()=>p});var r=n(82),o=n(328),i=n(165),l=n(590),a=n(788),s=n(869),u=n(53),c=n(124);let d=["logX","logY","allowXZeroes","fitFunction","errorModel"];function f(e){var t,n,o;let a=[];for(let n of null!=(t=e.series)?t:[])for(let e of(0,i.zB)(n).statisticsProperties)a.includes(e.name)||a.push(e.name);let s=function(e){var t,n,r,o;let i=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:{}))i.includes(e)||i.push(e);return i}(e),u=(null!=(n=null==(o=e.series)?void 0:o.length)?n:0)>1;return l.xs.filter(e=>("showLabels"!==e.name||s.length>0)&&("statisticsMode"!==e.name&&"aggrType"!==e.name||u)).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:s,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,s.Wh)((0,i.zB)(n),o);if(e){t=e.name;break}}n.includes(t)||n.push(t)}return n}function p(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)}),o=[...new Set([...t?[t.name]:[],...Object.keys(s.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:s.hD})})}function h(e,t,n){var r,o,i;let l=null!=(o=(r=null!=(i=e.explicit)?i:e.explicit={})[t])?o:r[t]=[];l.includes(n)||l.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&&s.HM[t]?s.HM[t]:t}function y(e,t,n,r){var i,l,s;let f,m=t.property.name,p=d.includes(m);if("Cell"===r){let r;if(!(0,c.XN)(e.cell.column))return;let i=e.cell.value;if(""===i)return;try{r=null!=(l=JSON.parse(null!=i?i:"{}"))?l:{}}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===u.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,u.Ig)(e.cell.dataFrame):(0,u.bc)(e.cell.column);for(let o of((null!=(i=y[n])?i:y[n]={})[m]=v(m,t.value),h(y,n,m),"Dataframe"===r?((0,u.G_)(e.cell.dataFrame.tags,y),f=e.cell.dataFrame.columns.bySemTypeAll(a.h.FIT_SEM_TYPE)):((0,u.G_)(e.cell.column.tags,y),f=[e.cell.column]),f)){if("Dataframe"===r){let e=(0,u.bc)(o),t=e[n];t&&delete t[m],g(e,n,m),(0,u.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!=(s=JSON.parse(r))?s:{}}catch(e){continue}g(t,n,m)&&o.set(e,JSON.stringify(t),!1)}}}if(p)for(let e of f)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),i=n(533),l=n(165),a=n(788),s=n(684),u=n(663),c=n(434),d=n(53),f=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,f.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,x,C,b,w,T,O,S,I,P,_,N,E,A,L,F,M,R,D,X,Y,k,j,G,V,B;e.save(),e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.clip();let $=(null==o?void 0:o.grid)&&(null==o?void 0:o.grid.dart)&&e.canvas===(null==o||null==(C=o.grid)?void 0:C.canvas)&&!(null==(b=n.chartOptions)?void 0:b.mergeSeries),H=null==o?void 0:o.cell;(null==(w=n.chartOptions)?void 0:w.allowXZeroes)&&(null==(T=n.chartOptions)?void 0:T.logX)&&(null==(O=n.series)?void 0:O.some(e=>e.points.some(e=>0===e.x)))&&(0,d.B3)(n);let q=(0,f.lc)(t,n),[W,J,U]=(0,f.Tv)(t,q.x,q.y,(0,f.ij)(t,n)),z=(0,l.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 Z={logX:null==(S=n.chartOptions)?void 0:S.logX,logY:null==(I=n.chartOptions)?void 0:I.logY},K=[];for(let e=0;e<(null==(P=n.series)?void 0:P.length);e++){let t=n.series[e];if(t.points.some(e=>void 0===e.x||void 0===e.y)||t.points.length<=1){K.push(null);continue}t.points.sort((e,t)=>e.x-t.x);let r=(0,l.zB)(t),o=null,i=t,a=!0;if(!(t.connectDots&&!(null==(k=t.showFitLine)||k)))if(t.parameters)i=(0,l.iK)(t,Z),o=(0,l._T)(i,r);else{let n=(0,d.IY)(t,e,r,Z,H,$,null==m?void 0:m[e]);o=n.fittedCurve,i=h(p({},t),{parameters:[...n.parameters]}),a=!1}K.push({fitFunc:r,curve:o,fitSpaceSeries:i,userParamsFlag:a})}z=function(e,t,n){var o,i;let l=null!=(o=null==n?void 0:n.logX)&&o,a=null!=(i=null==n?void 0:n.logY)&&i,s=e.minY,u=e.maxY;for(let n of t)if(n)for(let t=0;t<=100;t++){let r=t/100,o=l?e.minX*Math.pow(e.maxX/e.minX,r):e.minX+e.width*r,i=n(l?Math.log10(o):o),c=a?Math.pow(10,i):i;isFinite(c)&&(s=Math.min(s,c),u=Math.max(u,c))}if((null==n?void 0:n.minY)!=null&&(s=e.minY),(null==n?void 0:n.maxY)!=null&&(u=e.maxY),s>=e.minY&&u<=e.maxY)return e;if(a&&e.minY>0){let t=(Math.log10(e.maxY)-Math.log10(e.minY))*.15;s=Math.max(s,Math.pow(10,Math.log10(e.minY)-t)),u=Math.min(u,Math.pow(10,Math.log10(e.maxY)+t))}else s=Math.max(s,e.minY-.15*e.height),u=Math.min(u,e.maxY+.15*e.height);if(s>=e.minY&&u<=e.maxY)return e;let c=u-s,d=s<e.minY?a&&s>0?s/1.05:s-.05*c:e.minY,f=u>e.maxY?a?1.05*u:u+.05*c:e.maxY;return new r.Rect(e.x,d,e.width,f-d)}(z,K.map(e=>(null==e?void 0:e.fitFunc.hasAsymptotes)?e.curve:null),n.chartOptions);let Q=new i.L(z,W,null!=(g=null==(_=n.chartOptions)?void 0:_.logX)&&g,null!=(v=null==(N=n.chartOptions)?void 0:N.logY)&&v),ee=Math.min(W.width,W.height),et=ee>100?1:.2+ee/100*.8,en=(0,u.qd)(n,t)?[]:void 0;e.save(),e.font='11px Roboto, "Roboto Local"',Q.drawCoordinateGrid(e,J,U),e.restore();let er=(0,s.S3)(e,null==(E=n.chartOptions)?void 0:E.labels,{names:null==(A=n.chartOptions)?void 0:A.showLabels,color:a.h.PLOT_LABEL_COLOR,dataBox:W,screenBounds:t,startLine:0,drawnAt:en}),eo=(null!=(y=null==(L=n.series)?void 0:L.length)?y:0)>1&&null!=(x=null==(F=n.chartOptions)?void 0:F.statisticsMode)?x:"series",ei=null==(M=n.chartOptions)?void 0:M.showStatistics;if((null==ei?void 0:ei.length)&&"series"!==eo){let r=null!=(j=null==(G=n.chartOptions)?void 0:G.aggrType)?j:"med",o=(0,c.JR)(n,r,H),i=Object.fromEntries(ei.map(e=>[`${r} ${e}`,o[e]]));er+=(0,s.S3)(e,i,{names:Object.keys(i),color:a.h.PLOT_LABEL_COLOR,dataBox:W,screenBounds:t,startLine:er,drawnAt:en})}for(let o=0;o<(null==(R=n.series)?void 0:R.length);o++){let i=n.series[o],l=K[o];if(!l)continue;let{fitFunc:u,curve:c,fitSpaceSeries:m,userParamsFlag:p}=l,h=a.h.POINT_PX_SIZE*et/2,g=W.inflate(h,h);if(e.save(),e.beginPath(),e.rect(g.x,g.y,g.width,g.height),e.clip(),(0,s.qR)(e,i,{viewport:Q,ratio:et,logOptions:Z,showAxes:(0,f.b1)(t),showAxesLabels:(0,f.eG)(t,n),screenBounds:t,curveFunc:c,seriesIdx:o,drawnAt:en}),(0,s.nx)(e,i,{viewport:Q,ratio:et,seriesIdx:o}),(0,s.QW)(e,i,{viewport:Q,ratio:et,screenBounds:t,seriesIdx:o}),en){let e=null;for(let t of i.points){if(t.outlier&&!(null==(B=i.showOutliers)||B))continue;let n=new r.Point(Q.xToScreen(t.x),Q.yToScreen(t.y));if(en.push(n),e){let t=Math.floor(Math.abs(n.x-e.x)/s.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,s.Zk)(e,m,{viewport:Q,logOptions:Z,showAxes:(0,f.b1)(t),showAxesLabels:(0,f.eG)(t,n),screenBounds:t,fitFunc:u,userParamsFlag:p,drawnAt:en,dataPoints:(0,d.Xm)(i,o,Z,p,H,$)}),(0,s.HQ)(e,m,{viewport:Q,ratio:et,showDroplines:(0,f.m)(t),showDroplineLabels:(0,f.W$)(t),fitFunc:u,dataBounds:z,curveFunc:c,logOptions:Z,drawnAt:en}),e.restore(),er+=(0,s.yv)(e,m,{statistics:"aggregated"===eo?[]:ei,fitFunc:u,logOptions:Z,dataBox:W,screenBounds:t,seriesIdx:o,startLine:er,drawnAt:en}),er+=(0,s.S3)(e,i.labels,{names:null==(V=n.chartOptions)?void 0:V.showLabels,color:(0,s.Z)(i,o,s.mE.FIT_LINE),dataBox:W,screenBounds:t,startLine:er,drawnAt:en})}(0,s.zF)(e,{showTitle:(0,f.ij)(t,n),title:null==(D=n.chartOptions)?void 0:D.title,dataBox:W,screenBounds:t}),(0,s.jI)(e,{showTitle:(0,f.ij)(t,n),dataBox:W,screenBounds:t,showAxesLabels:(0,f.eG)(t,n),xAxisName:null==(X=n.chartOptions)?void 0:X.xAxisName,yAxisName:null==(Y=n.chartOptions)?void 0:Y.yAxisName}),en&&(0,u.GU)(e,n,W,et,en),e.restore()}render(e,t,n,o,i,l,s){var u,c,f,m,v,y;if(!l.cell.value||o<a.h.MIN_CELL_RENDERER_PX_WIDTH||i<a.h.MIN_CELL_RENDERER_PX_HEIGHT)return;let x=(null==l?void 0:l.grid)&&(null==l?void 0:l.grid.dart)&&e.canvas===(null==l||null==(u=l.grid)?void 0:u.canvas),C=(0,d.h8)(l.cell,x),b=g.inflateScreenBounds(new r.Rect(t,n,o,i));for(let[t,n]of Object.entries(a.h.CONDITION_MAP))if(n(C.series)){return void(v=e,y=b,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=l.cell.column)?void 0:c.name)&&(null==(f=C.series)||f.forEach(e=>e.columnName=l.cell.column.name)),(null==(m=C.chartOptions)?void 0:m.mergeSeries)&&(C=h(p({},C),{series:[(0,d.wU)(C.series)]})),e.clearRect(b.x,b.y,b.width,b.height),this.renderCurves(e,b,C,l)}}g.fittedCurves=d.bZ,g.parsedCurves=d.uc,g.curvesDataPoints=d.CP,g=function(e,t,n,r){var o,i=arguments.length,l=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(l=(i<3?o(l):i>3?o(t,n,l):o(t,n))||l);return i>3&&l&&Object.defineProperty(t,n,l),l}([o.decorators.cellRenderer({name:"Fit",cellType:"fit",virtual:!0})],g)},434(e,t,n){"use strict";n.d(t,{JR:()=>p,TV:()=>d,Uc:()=>m,bW:()=>g,i4:()=>v});var r=n(82),o=n(165),i=n(590),l=n(869),a=n(53),s=n(124);let u={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 d(e,t,n,r,i=!0,l=!0){var s,u;let c=(0,o.zB)(e),f=e.parameters?(0,o.iK)(e,n):(s=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),u=u={parameters:[...(0,a.IY)(e,t,c,n,r,i).parameters]},Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(u)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(u)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(u,e))}),s),m=(0,o.xS)(f,c,(0,a.Xm)(e,t,n,!1,r,i),n);return l?(0,o.KZ)(m,n):m}let f=new Set(o.GO);function m(e,t){var n;let r=null!=(n=e.series)?n:[];if(!r.length)return i.nK;let l=[...(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));l=l.filter(e=>t.has(e.name))}return void 0===t||c.has(t)||(l=l.filter(e=>!f.has(e.name))),l}function p(e,t,n){var a,s,f;let p={logX:null==(a=e.chartOptions)?void 0:a.logX,logY:null==(s=e.chartOptions)?void 0:s.logY},h=new Map,g=[],v=new Set(m(e,t).map(e=>e.name));for(let t=0;t<(null==(f=e.series)?void 0:f.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 s=d(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,l.h5)(s,e.name)));for(let e of i.Al){if(v.has(e))continue;let t=(0,l.Wh)((0,o.zB)(r),e);t&&t.name!==e||(h.has(e)||h.set(e,[]),h.get(e).push((0,l.h5)(s,e)))}}let y={};for(let[e,n]of h)y[e]=n.some(e=>null==e||isNaN(e))?void 0:r.Stats.fromValues(n)[u[t]];for(let e of(c.has(t)&&(0,o.KZ)(y,p),i.Al))if(void 0===y[e])for(let t of g){let n=(0,l.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,i;let l=e.get(t);if(null==l||""===l)return null;let u=e.dataFrame?e.dataFrame.cell(t,e.name):void 0,c=u?(0,a.h8)(u,!0):(0,a.mI)((0,s.HB)((0,a.RH)(l),e),e,n);return(null==(r=c.chartOptions)?void 0:r.allowXZeroes)&&(null==(o=c.chartOptions)?void 0:o.logX)&&(null==(i=c.series)?void 0:i.some(e=>e.points.some(e=>0===e.x)))&&(0,a.B3)(c),{data:c,cell:u}}function g(e,t,n,r,o){var i,a,s,u;let c=h(e,t,o);if(!c)return null;let f=null==(a=c.data.series)?void 0:a[r];if(!f||f.points.every(e=>e.outlier))return null;let m={logX:null==(s=c.data.chartOptions)?void 0:s.logX,logY:null==(u=c.data.chartOptions)?void 0:u.logY};return null!=(i=(0,l.h5)(d(f,r,m,c.cell,!0),n))?i:null}function v(e,t,n,r,o){var i,l;let a=h(e,t,o);return!a||(null==(l=a.data.series)?void 0:l.every(e=>e.points.every(e=>e.outlier)))?null:null!=(i=p(a.data,r,a.cell)[n])?i:null}},684(e,t,n){"use strict";n.d(t,{zF:()=>A,jI:()=>L,yv:()=>E,Yc:()=>g,dT:()=>f,S3:()=>N,HQ:()=>P,qR:()=>T,Ow:()=>I,QW:()=>x,a:()=>C,Z:()=>v,nx:()=>y,mE:()=>h,Zk:()=>O});var r,o=n(82),i=n(165),l=n(788),a=n(18);let s="u">typeof window?window:n.g.window,u=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2});class c{static getUniqueName(e,t,n){return s.grok_Utils_GetUniqueName(e,t,null==n?void 0:n.auto,null==n?void 0:n.idx,null==n?void 0:n.render,null==n?void 0:n.choices)}static isEmpty(e){return null==e||""==e}static formatNumber(e){return u.format(e)}}var d=n(869);let f=8,m='11px Roboto, "Roboto Local"';function p(e,t,n,r,i){if(!e)return;let l=t.measureText(n).width;for(let t=r;t<=r+l;t+=f)e.push(new o.Point(t,i))}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,i=t.points[n].y,l=r.xToScreen(o),a=r.yToScreen(i);0===n?e.moveTo(l,a):e.lineTo(l,a)}e.stroke()}}function x(e,t,n){var r;let i=n.screenBounds;(i.width<l.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||i.height<l.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,i=l.h.POINT_PX_SIZE*r,a=n.viewport,s=t.connectDots,u=v(t,n.seriesIdx,"pointColor"),c=v(t,n.seriesIdx,"outlierColor");for(let f=0;f<t.points.length;f++){let m=t.points[f];if(m.outlier&&!t.showOutliers)continue;let p=a.xToScreen(m.x),h=a.yToScreen(m.y),g=s?u:m.outlier?m.outlierColor&&o.Color.fromHtml(m.outlierColor)?m.outlierColor:c:m.color&&o.Color.fromHtml(m.color)?m.color:u,v=m.marker?m.marker:t.markerType,y=m.outlierMarker?m.outlierMarker:t.outlierMarkerType,x=Math.min(l.h.OUTLIER_PX_SIZE*r,a.screen.height/10),b=s?i:m.outlier?x:m.size?m.size:i,w=s?v:m.outlier?y:v;if(o.Paint.marker(e,w,p,h,g,b),m.stdev&&!m.outlier){let t=b/2,i=C(h,a.yToScreen(m.y+m.stdev),a.yToScreen(m.y-m.stdev),t);if(i){var d;null==(d=n.drawnAt)||d.push(new o.Point(p,i.top[0]),new o.Point(p,i.bottom[1])),e.strokeStyle=g,e.lineWidth=r,e.beginPath(),e.moveTo(p,i.top[0]),e.lineTo(p,i.top[1]),e.moveTo(p,i.bottom[0]),e.lineTo(p,i.bottom[1]),e.moveTo(p-t,i.top[0]),e.lineTo(p+t,i.top[0]),e.moveTo(p-t,i.bottom[1]),e.lineTo(p+t,i.bottom[1]),e.stroke()}}}}(e,t,n):["candlesticks","both"].includes(t.showPoints)&&function(e,t,n){let r=n.ratio,i=n.viewport,s=v(t,n.seriesIdx,"pointColor");for(let n=0,u=null;n<t.points.length;n++){let c=t.points[n];if(c.outlier)continue;let d=n+1<t.points.length&&t.points[n+1].x===c.x;if(!u&&d)u=n;else if(null!==u&&!d){let d=[];for(let e=u,r=0;e<=n;e++,r++)d[r]=t.points[e].y;let f=(0,a.k)(d);if(e.beginPath(),function(e,t){let n=t.viewport,r=t.x,i=n.xToScreen(r),a=t.boxPlotStats;b(e,r,a.lowerAdjacentValue,n),e.moveTo(i,n.yToScreen(a.lowerAdjacentValue)),e.lineTo(i,n.yToScreen(a.upperAdjacentValue)),b(e,r,a.upperAdjacentValue,n),o.Paint.marker(e,o.MARKER_TYPE.CIRCLE,i,n.yToScreen(a.q2),t.color,l.h.CANDLESTICK_MEDIAN_PX_SIZE*t.ratio)}(e,{viewport:i,ratio:r,x:c.x,boxPlotStats:f,color:s}),e.stroke(),"both"===t.showPoints)for(let t=0;t<d.length;t++)(d[t]<f.lowerAdjacentValue||d[t]>f.upperAdjacentValue)&&o.Paint.marker(e,o.MARKER_TYPE.OUTLIER,i.xToScreen(c.x),i.yToScreen(d[t]),s,l.h.CANDLESTICK_OUTLIER_PX_SIZE*r);u=null}}}(e,t,n))}function C(e,t,n,r){return e-t<=r?null:{top:[t,e-r],bottom:[e+r,n]}}function b(e,t,n,r){let o=r.xToScreen(t),i=r.yToScreen(n);e.moveTo(o-l.h.CANDLESTICK_BORDER_PX_SIZE/2,i),e.lineTo(o+l.h.CANDLESTICK_BORDER_PX_SIZE/2,i)}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 T(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(l.h.LINE_STYLES[t.lineStyle]);let{logX:r,logY:i,xMin:a,xMax:s,viewport:u}=w(n),c=n.curveFunc;for(let t=a;t<=s;t++){let l=r?Math.log10(u.xToWorld(t)):u.xToWorld(t),s=i?u.yToScreen(Math.pow(10,c(l))):u.yToScreen(c(l));n.drawnAt&&t%f==0&&n.drawnAt.push(new o.Point(t,s)),t===a?e.moveTo(t,s):e.lineTo(t,s)}e.stroke(),e.restore()}}function O(e,t,n){var r,o,a,s;if((null==(r=t.showFitLine)||r)&&null!=(o=t.showCurveConfidenceInterval)&&o){e.strokeStyle=null!=(a=t.confidenceIntervalColor)?a:l.h.CONFIDENCE_INTERVAL_STROKE_COLOR,e.fillStyle=null!=(s=t.confidenceIntervalColor)?s:l.h.CONFIDENCE_INTERVAL_FILL_COLOR;let r=n.showAxes,o=n.showAxesLabels,u=n.logOptions,c=n.viewport,d=n.screenBounds,f=n.dataPoints,m=(0,i.fY)(t,n.fitFunc,n.userParamsFlag,f,u);S(e,{viewport:c,logOptions:u,showAxes:r,showAxesLabels:o,screenBounds:d,confidenceIntervals:m,confidenceType:l.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP}),S(e,{viewport:c,logOptions:u,showAxes:r,showAxesLabels:o,screenBounds:d,confidenceIntervals:m,confidenceType:l.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.BOTTOM}),function(e,t){e.beginPath();let{logX:n,logY:r,xMin:o,xMax:i,viewport:l}=w(t),a=t.confidenceIntervals.confidenceTop,s=t.confidenceIntervals.confidenceBottom;for(let t=o;t<=i;t++){let i=n?Math.log10(l.xToWorld(t)):l.xToWorld(t),s=r?l.yToScreen(Math.pow(10,a(i))):l.yToScreen(a(i));t===o?e.moveTo(t,s):e.lineTo(t,s)}for(let t=i;t>=o;t--){let o=n?Math.log10(l.xToWorld(t)):l.xToWorld(t),i=r?l.yToScreen(Math.pow(10,s(o))):l.yToScreen(s(o));e.lineTo(t,i)}e.closePath(),e.fill()}(e,{viewport:c,logOptions:u,showAxes:r,showAxesLabels:o,screenBounds:d,confidenceIntervals:m})}}function S(e,t){e.beginPath();let{logX:n,logY:r,xMin:i,xMax:a,viewport:s}=w(t),u=t.confidenceType===l.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP?t.confidenceIntervals.confidenceTop:t.confidenceIntervals.confidenceBottom;for(let l=i;l<=a;l++){let a=n?Math.log10(s.xToWorld(l)):s.xToWorld(l),c=r?s.yToScreen(Math.pow(10,u(a))):s.yToScreen(u(a));t.drawnAt&&l%f==0&&t.drawnAt.push(new o.Point(l,c)),l===i?e.moveTo(l,c):e.lineTo(l,c)}e.stroke()}function I(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}function P(e,t,n){var r,i;if(!(null==(r=t.showFitLine)||r)||!(null==(i=t.droplines)?void 0:i.length)||!t.parameters||!n.showDroplines)return;e.save(),e.strokeStyle="blue",e.lineWidth=n.ratio,e.beginPath(),e.setLineDash([5,5]);let l=[];for(let r of t.droplines){let i=I(r),a=void 0===i?void 0:n.fitFunc.inverse(Float32Array.from(t.parameters),i),s=void 0===a?null:function(e,t,n){let r=n.logOptions.logX,i=n.logOptions.logY,l=r?Math.pow(10,t):t,a=n.viewport,s=n.dataBounds;if(l<s.minX||l>s.maxX)return null;let u=r?Math.log10(l):l,c=i?Math.pow(10,n.curveFunc(u)):n.curveFunc(u),d=a.xToScreen(l),m=a.yToScreen(c),p=a.xToScreen(s.minX),h=a.yToScreen(s.minY);if(e.moveTo(p,m),e.lineTo(d,m),e.lineTo(d,h),n.drawnAt){for(let e=p;e<=d;e+=f)n.drawnAt.push(new o.Point(e,m));for(let e=m;e<=h;e+=f)n.drawnAt.push(new o.Point(d,e))}return m}(e,a,n);null!==s&&l.push({name:r,screenY:s})}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 l)e.fillText(n.name,t,n.screenY-3)}e.restore()}function _(e){return 0!==e&&(.001>Math.abs(e)||Math.abs(e)>=1e6)?o.format(e,"scientific"):c.formatNumber(e)}function N(e,t,n){var r,o;let i=n.screenBounds,a=i.width<l.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||i.height<l.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT?[]:n.names;if(!t||!a||0===a.length)return 0;let s=n.dataBox;e.font=m;let u=null!=(r=n.startLine)?r:0;for(let r of a){let o=t[r];if(null==o)continue;let i=s.y+15*(u+1);if(i>s.maxY)break;e.fillStyle=n.color,e.textAlign="left";let l=`${r}: ${"number"==typeof o?_(o):o}`;e.fillText(l,s.x+5,i),p(n.drawnAt,e,l,s.x+5,i),u++}return u-(null!=(o=n.startLine)?o:0)}function E(e,t,n){var r,o,a;let s=n.screenBounds,u=s.width<l.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||s.height<l.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT?[]:n.statistics;if(!((null==(r=t.showFitLine)||r)&&u&&u.length>0))return 0;let c=n.dataBox,f=n.dataPoints,h=n.fitFunc,g=(0,i.KZ)((0,i.xS)(t,h,f,n.logOptions),n.logOptions),y=v(t,n.seriesIdx,"fitLineColor");e.font=m;let x=null!=(o=n.startLine)?o:0;for(let t of u){let r=(0,d.h5)(g,t),o=(0,d.Wh)(h,t);if(void 0===r||!o)continue;let i=c.y+15*(x+1);if(i>c.maxY)break;e.fillStyle=y,e.textAlign="left";let l=`${o.friendlyName}: ${_(r)}`;e.fillText(l,c.x+5,i),p(n.drawnAt,e,l,c.x+5,i),x++}return x-(null!=(a=n.startLine)?a:0)}function A(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 L(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-l.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?l.h.AXES_TOP_PX_MARGIN_WITH_TITLE:l.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:()=>f,b6:()=>m,fM:()=>d,rn:()=>c});var r=n(82),o=n(590);function i(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 l(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=l(e,t);return null!=(n=null==o||null==(r=o.textContent)?void 0:r.trim())?n:""}function s(e){let t=i(e,"d"),n=[],r=[];for(let e of t){var o,l;let t=null!=(o=null==(l=e.textContent)?void 0:l.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 u(e){return{title:a(e,"Title"),subcolumns:i(e,"Subcolumn").map(s)}}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:"",d=null!=(r=e.getAttribute("XFormat"))?r:"",f=a(e,"Title"),m="",p=[],h=l(e,"XColumn");if(h){m=a(h,"Title");let e=l(h,"Subcolumn");e&&(p=s(e).values)}return{id:o,title:f,tableType:c,xFormat:d,xTitle:m,xValues:p,yColumns:i(e,"YColumn").map(u)}}(t))}return o}function d(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 i=t.values[n];null!=i&&r.push({x:o,y:i,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 f(e){let t=e.filter(e=>"XY"===e.tableType),n=[],o=[];for(let e of t){let t=d(e);t&&(n.push(e.title||e.id),o.push(JSON.stringify(t)))}let i=r.DataFrame.create(n.length);i.setTag(r.Tags.Id,crypto.randomUUID()),i.name="PZFX Curves";let l=i.columns.addNewString("Table");for(let e=0;e<n.length;e++)l.set(e,n[e]);let a=i.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 i}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,i;if(1===t.subcolumns.length){let e=n.columns.addNewFloat(t.title||"Values"),i=t.subcolumns[0];for(let t=0;t<i.values.length;t++)e.set(t,null!=(o=i.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}`),l=t.subcolumns[e];for(let e=0;e<l.values.length;e++)o.set(e,null!=(i=l.values[e])?i:r.FLOAT_NULL)}}return n}},644(e,t,n){"use strict";n.d(t,{_package:()=>Y});var r=n(82),o=n(389),i=n(328),l=n(53),a=n(590);let s=rxjs.operators;var u=n(858),c=n(788),d=n(129),f=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,l.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 i=this.props.get("mergeCellSeries"),s=[];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,l.h8)(o);if(!a.series||0===a.series.length)continue;let u=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 u)e.auxLegendName=u.length>1?`${c.get(n)} ${e.name}`:`${c.get(n)}`;let d=a.chartOptions;if(null!=d&&(s[s.length]=d),i){let e=(0,l.wU)(u);(null==d?void 0:d.title)!==void 0&&(null==d?void 0:d.title)!==""&&(e.name=null==d?void 0:d.title),u=[e]}let f=(0,l.U6)(a);r.push(...u.map((e,t)=>`${f} || idx: ${i?"merged":t}`)),t.push(...u)}0!==t.length&&(null==(n=this.data.series)||n.push(...JSON.parse(JSON.stringify(this.mergeColumnSeries?[(0,l.wU)(t)]:t))),this.fitIdentities.push(...this.mergeColumnSeries?[void 0]:r))}for(let e of(this.data.chartOptions=(0,l.LX)(s,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,i,l,a,s;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==(s=this.data.series)?void 0:s.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==(i=this.data.series)?void 0:i.length)>10&&(null==(l=this.data.series)?void 0:l.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,i;(null==e?void 0:e.name)==="curvesColumnNames"&&(this.props.set("showColumnLabel",(null==(o=this.curvesColumnNames)?void 0:o.length)>1),this.showColumnLabel=(null==(i=this.curvesColumnNames)?void 0:i.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,u.merge)(this.dataFrame.onCurrentCellChanged,...t?[t.onCellMouseEnter]:[],this.dataFrame.onSelectionChanged).pipe((0,s.debounce)(e=>(0,u.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 i=new r.Rect(0,0,this.canvas.width,this.canvas.height);new d.l().renderCurves(o,i,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,f.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}))}}g=function(e,t,n,r){var o,i=arguments.length,l=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(l=(i<3?o(l):i>3?o(t,n,l):o(t,n))||l);return i>3&&l&&Object.defineProperty(t,n,l),l}([i.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 v=n(181),y=n(434),x=n(301),C=n(190),b=n(287),w=n(305),T=n(124),O=n(869),S=n(991),I=n.n(S);function P(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function _(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){P(i,r,o,l,a,"next",e)}function a(e){P(i,r,o,l,a,"throw",e)}l(void 0)})}}let N="Compound|Assay|Target";function E(e){return e.split("||").filter(e=>""!==e&&"null"!==e&&"undefined"!==e).join(" | ")}function A(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 L=n(886);function F(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function M(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){F(i,r,o,l,a,"next",e)}function a(e){F(i,r,o,l,a,"throw",e)}l(void 0)})}}function R(e,t,n,r){var o,i=arguments.length,l=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(l=(i<3?o(l):i>3?o(t,n,l):o(t,n))||l);return i>3&&l&&Object.defineProperty(t,n,l),l}function D(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function X(e,t){return function(n,r){t(n,r,e)}}let Y=new r.Package,k=".sourceColumn",j=".statistics";class G{static runWhenDone(e){return M(function*(){return G._currentPromise=G._currentPromise.then(()=>M(function*(){try{return yield e()}catch(e){Y.logger.error(e)}})()),G._currentPromise})()}}G._currentPromise=Promise.resolve();class V{static curveFitDemo(){return M(function*(){yield(0,x.Z1)()})()}static assayCurveFitDemo(){return M(function*(){yield(0,x.pj)()})()}static _initCurves(){return M(function*(){r.ObjectHandler.register(new v.e),(0,T.l8)("3dx",C.J),(0,T.l8)("compact-dr",b.G),(0,T.l8)("pzfx",w.R),yield(0,T.p)()})()}static dataToCurves(e,t,n,o,l,s,u,c,d,f,m,p,h,g,v,y,x,C,b){return M(function*(){var w,T,O,S,I;let P=f&&x&&C&&e.col(x)&&f.col(C)?{wellLevelCol:e.col(x),parentLevelCol:f.col(C)}:void 0,A=(null!=b?b:[]).map(t=>e.col(t)).filter(e=>null!=e);return I={table:f,fitParamColumns:(null!=m?m:[]).map(e=>null==f?void 0:f.col(e)).filter(e=>null!=e),reportedIC50Column:p&&null!=(w=null==f?void 0:f.col(p))?w:void 0,reportedQualifiedIC50Column:h&&null!=(T=null==f?void 0:f.col(h))?T:void 0,experimentIDColumn:g&&null!=(O=null==f?void 0:f.col(g))?O:void 0,qualifierColumn:v&&null!=(S=null==f?void 0:f.col(v))?S:void 0,additionalColumns:(null!=y?y:[]).map(e=>null==f?void 0:f.col(e)).filter(e=>null!=e)},_(function*(){var f,m,p,h,g,v,y,x,C,b,w,T,O,S,_,L,F,M,R;if(!t||!n||!o)throw i.shell.warning("Please fill all required fields"),Error("Please fill all required fields");let D={},X=null==l?void 0:l.categories,Y=null==l?void 0:l.getRawData(),k=t.getRawData(),j=n.getRawData(),G=null==o?void 0:o.categories,V=null==o?void 0:o.getRawData(),B=null==u?void 0:u.categories,$=null==u?void 0:u.getRawData(),H=null==s?void 0:s.categories,q=null==s?void 0:s.getRawData(),W=null==c?void 0:c.categories,J=null==c?void 0:c.getRawData(),U=l?e=>X[Y[e]]:()=>"All",z=d?d.getRawData():null,Z=d?d.categories:null,K=d?d.type==r.COLUMN_TYPE.BOOL?e=>!!z[e]:e=>{var t,n,r;return null!=(t=null==(r=Z[z[e]])||null==(n=r.toLowerCase())?void 0:n.includes("exclude"))&&t}:e=>!1,Q=e=>k[e],ee=e=>j[e],et=e=>G[V[e]],en=u?e=>B[$[e]]:()=>null,er=s?e=>H[q[e]]:()=>null,eo=c?e=>W[J[e]]:()=>null,ei=["circle","triangle bottom","star","cross border","diamond","square","triangle left","triangle right","triangle top","asterisk"],el=0,ea={},es=!!((null==P?void 0:P.parentLevelCol)&&(null==P?void 0:P.wellLevelCol)),eu=null==I||null==(f=I.table)?void 0:f.col(u.name),ec=null==I||null==(m=I.table)?void 0:m.col(l.name),ed=null==I||null==(p=I.table)?void 0:p.col(c.name),ef=null==I||null==(h=I.table)?void 0:h.col(s.name),em=e=>`${en(e)}||${U(e)}||${eo(e)}`,ep=e=>`${em(e)}||${er(e)}`,eh=es?e=>`${P.wellLevelCol.get(e)}`:e=>ep(e),eg=es?e=>`${P.parentLevelCol.get(e)}`:eu&&ec&&ed&&ef?e=>{var t,n,r,o;return`${null==(t=I.table)?void 0:t.col(u.name).get(e)}||${null==(n=I.table)?void 0:n.col(l.name).get(e)}||${null==(r=I.table)?void 0:r.col(c.name).get(e)}||${null==(o=I.table)?void 0:o.col(s.name).get(e)}`}:e=>null,ev={};if(I)for(let e=0;e<(null!=(g=null==(v=I.table)?void 0:v.rowCount)?g:0);e++){let t=eg?eg(e):null;t&&!ev[t]&&(ev[t]={fitParams:null!=(y=null==(C=I.fitParamColumns)?void 0:C.map(t=>t.get(e)))?y:[],fitFunction:null!=(x=I.fitFunction)?x:a.Qx,reportedIC50:I.reportedIC50Column?I.reportedIC50Column.get(e):void 0,reportedQualifiedIC50:I.reportedQualifiedIC50Column?I.reportedQualifiedIC50Column.get(e):void 0,experimentID:I.experimentIDColumn?I.experimentIDColumn.get(e):void 0,qualifier:I.qualifierColumn?I.qualifierColumn.get(e):void 0,additionalColumns:I.additionalColumns?Object.fromEntries(I.additionalColumns.map(t=>[t.name,t.get(e)])):void 0})}for(let t=0;t<e.rowCount;t++){let e=U(t),n=et(t),o=Q(t),i=ee(t),l=K(t),a=en(t),s=eo(t),u=null!=(b=er(t))?b:"",c=em(t),d=eh(t),f=ep(t);if(!D[d]){if(D[d]={name:f,x:[],y:[],outliers:[],groupKey:c,runID:u,info:{"Assay Name":e,"Batch ID":n,"Compound ID":a,"Target Entity":s,"Run ID":u,"Max Percent Inhibition":null}},A)for(let e of A){let n=e.name;for(;n in D[d].info;)n=`${n} (1)`;D[d].info[n]=e.get(t)}if(I&&ev[d]){if(D[d].info["Reported IC50"]=ev[d].reportedIC50,D[d].info["Qualified Reported IC50"]=ev[d].reportedQualifiedIC50,D[d].info["Experiment ID"]=ev[d].experimentID,D[d].info.Qualifier=ev[d].qualifier,ev[d].additionalColumns&&Object.assign(D[d].info,ev[d].additionalColumns),ev[d].fitParams&&ev[d].fitParams.length>0)for(let e=0;e<(null!=(T=null==(O=I.fitParamColumns)?void 0:O.length)?T:0);e++){let t=I.fitParamColumns[e].name;D[d].info[t]=ev[d].fitParams[e]}ev[d].groupKey=c}}let m=D[d];m.x.push(o),m.y.push(i),m.outliers.push(l),l||null==i||i==r.FLOAT_NULL||i==r.INT_NULL||(m.info["Max Percent Inhibition"]=Math.max(null!=(w=m.info["Max Percent Inhibition"])?w:-1/0,i))}let ey={},ex=Object.entries(D),eC=[],eb=r.Column.string("Fitted Curve",ex.length);for(let e of(eb.init(e=>{var o,i,l,s,u,c;let[d,f]=ex[e],m=f.x,p=f.y,h=f.outliers,g=f.runID,v=(e=>{if(e in ea)return ea[e];{let t=ei[el];return ea[e]=t,el=(el+1)%ei.length,t}})(g),y=ev[d]?ev[d].fitParams:void 0,x=(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=f.info["Compound ID"])?o:"")+"||"+(null!=(i=f.info["Assay Name"])?i:"")+"||"+(null!=(l=f.info["Target Entity"])?l:"")),C={fitFunction:(null==ev||null==(c=ev[d])?void 0:c.fitFunction)?ev[d].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:x,pointColor:r.Color.toHtml(r.Color.gray)};return JSON.stringify({chartOptions:{xAxisName:t.name,yAxisName:n.name,logX:!0,title:E(`${null!=(s=null!=(u=f.name)?u:d)?s:""}`)},series:[C]})}),eC.push(eb),eb.semType="fit",eb.setTag("cell.renderer","fit"),eC.push(r.Column.fromStrings(N,ex.map(e=>E(e[1].groupKey)))),ex.reduce((e,t)=>(Object.keys(t[1].info).forEach(t=>e.add(t)),e),new Set))){let t=r.Column.fromStrings(e,ex.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:""}));eC.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 ex){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]))),I&&ev[e]&&null!=(S=ev[e].reportedQualifiedIC50))&&S){eT[n].qualifiedIC50s.push(ev[e].reportedQualifiedIC50);let t=ew(I.reportedQualifiedIC50Column?ev[e].reportedQualifiedIC50:ev[e].reportedIC50);if(void 0==t)try{t=r.Qnum.parse(I.reportedQualifiedIC50Column?ev[e].reportedQualifiedIC50:ev[e].reportedIC50)}catch(e){}void 0!=t&&eT[n].reportedIC50s.push(t)}}let eO={};for(let e in eT){let t=eT[e];eO[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==(_=Math.max(...t.maxYs))?void 0:_.toString():null},I&&I.table?{"Number of total results":null==(L=t.qualifiedIC50s.length)?void 0:L.toString(),"Number of reported results":null==(F=t.reportedIC50s.length)?void 0:F.toString(),"Geomean IC50":t.reportedIC50s.length?null==(M=Math.exp(t.reportedIC50s.reduce((e,t)=>e+Math.log(t),0)/t.reportedIC50s.length)||null)?void 0:M.toString():null,"Standard Deviation":t.reportedIC50s.length>1?null==(R=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:R.toString():null,"All Results":t.qualifiedIC50s.join(", ")}:{})}for(let e of Object.keys(eO[Object.keys(eO)[0]])){let t=r.Column.fromStrings(e,ex.map(t=>{var n,r;return null!=(n=null==(r=eO[t[1].groupKey])?void 0:r[e])?n:""}));eC.push(t)}let eS=r.DataFrame.fromColumns(eC);if(eS.name="Fitted Curves",eS.setTag(r.Tags.Id,crypto.randomUUID()),!I||!I.table){let e={interceptX:"IC50",top:"Max",bottom:"Min",slope:"Hill",auc:"AUC"};Object.entries(e).forEach(([e,t])=>{let n={table:eS,colName:eb.name,propName:e,seriesNumber:0};r.Func.find({name:"addStatisticsColumn"})[0].prepare(n).callSync({processed:!1}).getOutputParamValue().name=t}),e.interceptX&&eS.col(e.interceptX)&&(eS.col(e.interceptX).meta.format="scientific")}return eS})()})()}static dataToCurvesTopMenu(){return M(function*(){!function(){let e,t,n,l,a,s,u,c,d,f,m,p,h,g,v,y,x,C,b,w,T,S,P,E,L,F,M=i.shell.tv;if(!M||!M.dataFrame)return i.shell.warning("No open tableview");let R=null,D=null,X=(e=o.divH([],{style:{alignItems:"center"}}),t=null,n=null,l=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,i;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==(i=n.value)?void 0:i.name)?r:null}:null},applyHistory:e=>{e.wellLevelCol&&e.parentLevelCol&&l&&a&&t&&n&&(t.value=l.col(e.wellLevelCol),n.value=a.col(e.parentLevelCol))},onTableChange:(r,i)=>((r,i)=>{if(o.empty(e),!r||!i){t=null,n=null,l=null,a=null;return}l=r,a=i,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:i,nullable:!0,tooltipText:"Column to join on from the parent level data"});let s=I()(i.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==s?void 0:s.col)&&s.score>0){n.value=s.col;let e=s.col.name.toLowerCase(),o=I()(r.columns.categorical).filter(t=>t.name.toLowerCase().includes(e)).toArray()[0];o&&(t.value=o)}let u=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,[u,t.root,n.root])})(r,i)});v=o.input.table("Well Table",{value:i.shell.tv.dataFrame,nullable:!1,tooltipText:"Table with well level data"}),y=o.form([]),(x=()=>{var e,t,n,i,l,a,x,C;let b=v.value;o.empty(y),(()=>{var e,t,n;return X.onTableChange(null!=(e=null==R||null==(n=R.getValues())?void 0:n.table)?e:null,null!=(t=null==D?void 0:D.getTable())?t:null)})(v.value),s=o.input.column("Assay Name",{table:b,nullable:!0,filter:e=>e.isCategorical,tooltipText:"Column with assay names"}),u=o.input.column("Concentration",{table:b,nullable:!1,filter:e=>e.isNumerical,tooltipText:"Column with concentration values"}),c=o.input.column("Readout",{table:b,nullable:!1,filter:e=>e.isNumerical,tooltipText:"Column with readout values"}),d=o.input.column("Outliers",{table:b,nullable:!0,filter:e=>(e.isCategorical||e.type===r.TYPE.BOOL)&&2===e.categories.length,tooltipText:"Column with outliers to exclude from the analysis"}),f=o.input.column("Compound ID",{table:b,nullable:!0,tooltipText:"Column with compound IDs"}),m=o.input.column("Batch ID",{table:b,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:b,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:b,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:b,nullable:!0,tooltipText:"Additional columns to include in the curves data"}),s.value=null!=(e=I()(b.columns.categorical).find(e=>e.name.toLowerCase().includes("assay")&&e.name.toLowerCase().includes("name")))?e:null,u.value=null!=(t=b.columns.firstWhere(e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME&&e.name.toLowerCase().includes("concentration")))?t:null,c.value=null!=(n=b.columns.firstWhere(e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME&&e.name.toLowerCase().includes("inhibition")))?n:null,d.value=null!=(i=b.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"))))?i:null,f.value=null!=(l=b.columns.firstWhere(e=>e.isCategorical&&e.name.toLowerCase().includes("compound_id")||e.name.toLowerCase().includes("compoundid")||e.name.toLowerCase().includes("compound id")))?l:null,m.value=null!=(a=b.columns.firstWhere(e=>e.name.toLowerCase().includes("batch")&&e.name.toLowerCase().includes("id")))?a:null,p.value=null!=(x=b.columns.firstWhere(e=>(e.name.toLowerCase().includes("run")||e.name.toLowerCase().includes("set"))&&e.name.toLowerCase().includes("id")))?x:null,h.value=null!=(C=b.columns.firstWhere(e=>e.isCategorical&&e.name.toLowerCase().includes("target")&&e.name.toLowerCase().includes("entity")))?C:null,g.value=[],o.appendAll(y,[v.root,s.root,m.root,p.root,u.root,c.root,f.root,h.root,d.root,g.root])})(),v.onChanged.subscribe(()=>x()),R={form:y,getValues:()=>{var e;return{table:v.value,assayCol:s.value,batchIDCol:m.value,concentrationCol:u.value,readoutCol:c.value,compoundIDCol:f.value,excludeOutliersCol:d.value,targetEntityCol:h.value,runIDCol:p.value,additionalColumns:null!=(e=g.value)?e:[]}},applyHistory:e=>{var t;let n=v.value;s.value=e.assayCol?n.col(e.assayCol):null,m.value=e.batchIDCol?n.col(e.batchIDCol):null,u.value=e.concentrationCol?n.col(e.concentrationCol):null,c.value=e.readoutCol?n.col(e.readoutCol):null,f.value=e.compoundIDCol?n.col(e.compoundIDCol):null,d.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)}},P=o.input.table("Parent Table",{value:void 0,nullable:!0,tooltipText:"Table with parent data"}),E=o.form([]),L=null,(F=()=>{var e;let t,n,i,l,a,s;if(o.empty(E),E.appendChild(P.root),(()=>{var e,t,n;return X.onTableChange(null!=(e=null==R||null==(n=R.getValues())?void 0:n.table)?e:null,null!=(t=null==D?void 0:D.getTable())?t:null)})(P.value),!P.value){L=null;return}C=o.input.column("Reported IC50",{table:P.value,nullable:!0,tooltipText:"Column with reported IC50 values"}),b=o.input.column("Reported Qualified IC50",{table:P.value,nullable:!0,tooltipText:"Column with reported qualified IC50 values"}),w=o.input.column("Experiment ID",{table:P.value,nullable:!0,tooltipText:"Column with experiment IDs"}),T=o.input.column("Qualifier",{table:P.value,nullable:!0,tooltipText:"Column with qualifier values"}),S=o.input.columns("Additional Columns",{table:P.value,nullable:!0,tooltipText:"Additional columns to include in the curves data"}),A(P.value,C,e=>e.type!==r.COLUMN_TYPE.DATE_TIME,["reported ic50","reported_ic50","reported-ic50"]),A(P.value,b,e=>e.type!==r.COLUMN_TYPE.DATE_TIME,["qualified_reported_ic50","qualified reported ic50","qualified-reported-ic50"]),A(P.value,w,e=>e.isCategorical,["experiment id","experiment_id","experiment-id"]),A(P.value,T,e=>e.isCategorical,["qualifier"]);let u=o.form([C,b,w,T,S]);e=P.value,t=[O.Z2.FOUR_PL_DOSE_RESPONSE,O.Z2.FOUR_PL_REGRESSION],n=o.input.choice("Fit Function",{value:O.Z2.FOUR_PL_DOSE_RESPONSE,items:t,nullable:!1,tooltipText:"Select the fit function to use for the curve fitting"}),i=o.form([]),l=[],(a=o.input.bool("Use Prefit Parameters",{value:!0,tooltipText:"Use selected fit curve parameters instead of fitting the curve from scratch"})).onChanged.subscribe(()=>{l.forEach(e=>e.enabled=a.value)}),n.addOptions(a.captionLabel),n.addOptions(a.input),a.captionLabel.style.color="var(--grey-6)",(s=()=>{o.empty(i);let t=function(e,t){let n=[];switch(t){case O.Z2.FOUR_PL_REGRESSION:case O.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"})),A(e,n[0],e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME,["max"]),A(e,n[1],e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME,["hill"]),A(e,n[2],e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME,["inflection"]),A(e,n[3],e=>e.isNumerical&&e.type!==r.COLUMN_TYPE.DATE_TIME,["min"])}return n}(e,n.value);l=t,o.appendAll(i,[n.root,...t.map(e=>e.root)]),a.fireChanged()})(),n.onChanged.subscribe(()=>s()),L={form:i,getValues:()=>a.value?l.map(e=>e.value):[],getFitFunction:()=>n.value,getHystory:()=>({fitParamCols:l.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==l?void 0:l.length))for(let n=0;n<l.length;n++){let r=e.col(t.fitParamCols[n]);r&&(l[n].value=r)}}},o.appendAll(E,[u,L.form])})(),P.onChanged.subscribe(()=>F()),D={getValue:()=>({fitParamCols:(null==L?void 0:L.getValues)?L.getValues():null,reportedIC50Col:null==C?void 0:C.value,reportedQualifiedIC50Col:null==b?void 0:b.value,experimentIDCol:null==w?void 0:w.value,qualifierCol:null==T?void 0:T.value,additionalColumns:null==S?void 0:S.value,fitFunction:(null==L?void 0:L.getFitFunction)?L.getFitFunction():null}),form:E,getTable:()=>P.value,getHistory:()=>{var e,t,n,r,o,i,l,a,s,u,c,d;return{tableName:null!=(e=null==(l=P.value)?void 0:l.name)?e:null,reportedIC50Col:null!=(t=null==C||null==(a=C.value)?void 0:a.name)?t:null,reportedQualifiedIC50Col:null!=(n=null==b||null==(s=b.value)?void 0:s.name)?n:null,experimentIDCol:null!=(r=null==w||null==(u=w.value)?void 0:u.name)?r:null,qualifierCol:null!=(o=null==T||null==(c=T.value)?void 0:c.name)?o:null,additionalColumns:null!=(i=null==S||null==(d=S.value)?void 0:d.map(e=>e.name))?i:[],fitParams:(null==L?void 0:L.getHystory)?L.getHystory():null}},applyHistory:e=>{if(e.tableName){let t=i.shell.table(e.tableName);t&&(P.value=t)}P.value&&(e.reportedIC50Col&&P.value.col(e.reportedIC50Col)&&(C.value=P.value.col(e.reportedIC50Col)),e.reportedQualifiedIC50Col&&P.value.col(e.reportedQualifiedIC50Col)&&(b.value=P.value.col(e.reportedQualifiedIC50Col)),e.additionalColumns&&(S.value=e.additionalColumns.map(e=>P.value.col(e)).filter(e=>null!=e)),e.experimentIDCol&&P.value.col(e.experimentIDCol)&&(w.value=P.value.col(e.experimentIDCol)),e.qualifierCol&&P.value.col(e.qualifierCol)&&(T.value=P.value.col(e.qualifierCol)),L&&e.fitParams&&L.applyHistory(e.fitParams))}};let Y=o.divH([R.form,D.form],{style:{minWidth:"400px",gap:"20px"}});o.dialog("Data to Curves").add(Y).add(X.form).onOK(()=>_(function*(){var e,t,n,o,l,a,s,u,c,d,f;let m,p=R.getValues(),h=D.getTable(),g=D.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!=(f=g.additionalColumns)?f:[]});let y=X.getValues(),{table:x,assayCol:C,batchIDCol:b,concentrationCol:w,readoutCol:T,compoundIDCol:O,excludeOutliersCol:S,runIDCol:I,targetEntityCol:P,additionalColumns:_}=p,E=r.Func.find({name:"dataToCurves"})[0];if(!E)return void i.shell.error("Function dataToCurves not found");let A=E.prepare({df:x,concentrationCol:w,readoutCol:T,batchIDCol:b,assayCol:C,runIDCol:I,compoundIDCol:O,targetEntityCol:P,excludeOutliersCol:S,wellLevelAdditionalColumns:(null!=_?_:[]).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==(l=m.reportedQualifiedIC50Column)?void 0:l.name,experimentIDColumn:null==m||null==(a=m.experimentIDColumn)?void 0:a.name,qualifierColumn:null==m||null==(s=m.qualifierColumn)?void 0:s.name,additionalColumns:null!=(t=null==m||null==(u=m.additionalColumns)?void 0:u.map(e=>e.name))?t:[],wellLevelJoinCol:null==y||null==(c=y.wellLevelCol)?void 0:c.name,parentLevelJoinCol:null==y||null==(d=y.parentLevelCol)?void 0:d.name}),L=x.tags[r.Tags.CreationScript]&&(!(null==m?void 0:m.table)||m.table.tags[r.Tags.CreationScript]);yield A.call(void 0,void 0,{processed:!L});let F=A.getResultViews()[0];if(F&&F instanceof r.TableView&&F.dataFrame){L||i.shell.addView(F),F.filters();let e=F.trellisPlot({yColumnNames:[N],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:i,concentrationCol:l,readoutCol:a,compoundIDCol:s,excludeOutliersCol:u,runIDCol:c,targetEntityCol:d,additionalColumns:f}=R.getValues();return{wells:JSON.stringify(null!=(t=Object.fromEntries(Object.entries({assayCol:null==o?void 0:o.name,batchIDCol:null==i?void 0:i.name,concentrationCol:null==l?void 0:l.name,readoutCol:null==a?void 0:a.name,compoundIDCol:null==s?void 0:s.name,excludeOutliersCol:null==u?void 0:u.name,runIDCol:null==c?void 0:c.name,targetEntityCol:null==d?void 0:d.name,additionalColumns:null!=(e=null==f?void 0:f.map(e=>e.name))?e:[]}).filter(([e,t])=>!!t)))?t:{}),parent:JSON.stringify(null!=(n=D.getHistory())?n:{}),join:JSON.stringify(null!=(r=X.getHistory())?r:{})}},e=>{var t,n,r;let o=JSON.parse(null!=(t=null==e?void 0:e.wells)?t:"{}"),i=JSON.parse(null!=(n=null==e?void 0:e.parent)?n:"{}");R.applyHistory(o),D.applyHistory(i);let l=JSON.parse(null!=(r=null==e?void 0:e.join)?r:"{}");X.applyHistory(l)})}()})()}static curveStatistic(e,t,n,o){let i=r.Column.float(`${t.name} ${o+1} ${n}`,t.length);return i.init(r=>(0,y.bW)(t,r,n,o,e)),i}static curveAggrStatistic(e,t,n,o){let i=r.Column.float(`${t.name} ${o} ${n}`,t.length);return i.init(r=>(0,y.i4)(t,r,n,o,e)),i}static addStatisticsColumn(e,t,n,o){let i=e.col(t),a=i.name,s=e.columns.getUnusedName(`${t} ${o+1} ${n}`),u=r.Column.float(s,i.length);return u.tags[k]=i.name,u.tags[".seriesNumber"]=null==o?void 0:o.toString(),u.tags[j]=n,u.init(t=>{var r,i,s,u,c,d;let f=e.cell(t,a);if(!f||!f.value)return null;let m=(0,l.h8)(f,!0);if(void 0===m.series[o]||m.series[o].points.every(e=>e.outlier))return null;(null==(i=m.chartOptions)?void 0:i.allowXZeroes)&&(null==(s=m.chartOptions)?void 0:s.logX)&&(null==(u=m.series)?void 0:u.some(e=>e.points.some(e=>0===e.x)))&&(0,l.B3)(m);let p={logX:null==(c=m.chartOptions)?void 0:c.logX,logY:null==(d=m.chartOptions)?void 0:d.logY},h=(0,y.TV)(m.series[o],o,p,f,!0);return null!=(r=(0,O.h5)(h,n))?r:null}),e.columns.insert(u,e.columns.names().indexOf(t)+1),u}static addAggrStatisticsColumn(e,t,n,o){let i=e.col(t),a=`${t} ${o} ${n}`,s=r.Column.float(e.columns.getUnusedName(a),null==i?void 0:i.length);return s.tags[k]=t,s.tags[".seriesAggregation"]=o,s.tags[j]=n,s.init(r=>{var i,a,s,u;let c=e.cell(r,t);if(!c||!c.value)return null;let d=(0,l.h8)(c);return(null==(i=d.series)?void 0:i.every(e=>e.points.every(e=>e.outlier)))?null:((null==(a=d.chartOptions)?void 0:a.allowXZeroes)&&(null==(s=d.chartOptions)?void 0:s.logX)&&(null==(u=d.series)?void 0:u.some(e=>e.points.some(e=>0===e.x)))&&(0,l.B3)(d),(0,y.JR)(d,o,c)[n])}),e.columns.insert(s,e.columns.names().indexOf(t)+1),s}static addCurveStatistic(e,t,n="interceptX",r=0){return V.addStatisticsColumn(e,t.name,n,r)}static addAggrCurveStatistic(e,t,n="interceptX",r="med"){return V.addAggrStatisticsColumn(e,t.name,n,r)}static convertXmlCurveToJsonFunc(){return C.J}static convertCompactDrToJsonFunc(){return b.G}static convertPzfxToJsonFunc(){return w.R}static previewPzfx(e){return M(function*(){let t=r.View.create();t.name=e.name;let n=yield e.readAsString(),o=(0,L.rn)(n),i=o.filter(e=>"XY"===e.tableType);if(0===i.length){for(let e of o.map(L.b6))t.append(r.Viewer.grid(e).root);return t}let l=(0,L.aI)(i),a=r.Viewer.grid(l);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,L.rn)(t),r=[],o=n.filter(e=>"XY"===e.tableType);for(let e of(o.length>0&&r.push((0,L.aI)(o)),n.filter(e=>"XY"!==e.tableType)))r.push((0,L.b6)(e));return r}}R([i.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"}}),D("design:type",Function),D("design:paramtypes",[]),D("design:returntype",Promise)],V,"curveFitDemo",null),R([i.decorators.demo({name:"Assay Curves",description:"Dashboard with curves for multiple compounds, assays and targets",meta:{demoPath:"Curves | Assay Curves"}}),D("design:type",Function),D("design:paramtypes",[]),D("design:returntype",Promise)],V,"assayCurveFitDemo",null),R([i.decorators.init(),D("design:type",Function),D("design:paramtypes",[]),D("design:returntype",Promise)],V,"_initCurves",null),R([i.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."}),X(1,i.decorators.param({type:"column",options:{type:"numerical",nullable:!1,description:"Concentration (dose) column"}})),X(2,i.decorators.param({type:"column",options:{type:"numerical",nullable:!1,description:"Readout (response) column"}})),X(3,i.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Batch identifier column"}})),X(4,i.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Assay name column"}})),X(5,i.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Run identifier column"}})),X(6,i.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Compound identifier column"}})),X(7,i.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Target entity column"}})),X(8,i.decorators.param({type:"column",options:{nullable:!0,description:"Boolean column marking points to exclude as outliers"}})),X(9,i.decorators.param({options:{nullable:!0}})),X(10,i.decorators.param({options:{nullable:!0}})),X(11,i.decorators.param({options:{nullable:!0}})),X(12,i.decorators.param({options:{nullable:!0}})),X(13,i.decorators.param({options:{nullable:!0}})),X(14,i.decorators.param({options:{nullable:!0}})),X(15,i.decorators.param({options:{nullable:!0}})),X(16,i.decorators.param({options:{nullable:!0}})),X(17,i.decorators.param({options:{nullable:!0}})),X(18,i.decorators.param({options:{nullable:!0,optional:!0}})),D("design:type",Function),D("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]),D("design:returntype",Promise)],V,"dataToCurves",null),R([i.decorators.func({"top-menu":"Data | Curves | Data to Curves",outputs:[{name:"result",type:"dynamic"}]}),D("design:type",Function),D("design:paramtypes",[]),D("design:returntype",Promise)],V,"dataToCurvesTopMenu",null),R([i.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)"}}]}),X(1,i.decorators.param({type:"column",options:{semType:"fit",nullable:!1,description:"Curve column to read"}})),X(2,i.decorators.param({options:{nullable:!1,description:"Fit statistic to extract (e.g. ic50, auc, rSquared)"}})),X(3,i.decorators.param({type:"int",options:{nullable:!1,description:"Zero-based index of the curve series"}})),D("design:type",Function),D("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,Number]),D("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],V,"curveStatistic",null),R([i.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)"}}]}),X(1,i.decorators.param({type:"column",options:{semType:"fit",nullable:!1,description:"Curve column to read"}})),X(2,i.decorators.param({options:{nullable:!1,description:"Fit statistic to aggregate"}})),X(3,i.decorators.param({options:{choices:["avg","med","min","max","q1","q2","q3"],initialValue:"med",nullable:!1,description:"Aggregation applied across the series of each curve"}})),D("design:type",Function),D("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,String]),D("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],V,"curveAggrStatistic",null),R([i.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"}}),X(1,i.decorators.param({options:{description:"Name of the curve column to read"}})),X(2,i.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"}})),X(3,i.decorators.param({type:"int",options:{initialValue:"0",description:"Zero-based index of the curve series"}})),D("design:type",Function),D("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,String,String,Number]),D("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],V,"addStatisticsColumn",null),R([i.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"}}),X(1,i.decorators.param({options:{description:"Name of the curve column to read"}})),X(2,i.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"}})),X(3,i.decorators.param({options:{choices:["min","max","avg","med","q1","q2","q3"],initialValue:"med",description:"Aggregation applied across the series of each curve"}})),D("design:type",Function),D("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,String,String,String]),D("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],V,"addAggrStatisticsColumn",null),R([i.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"}}),X(0,i.decorators.param({options:{caption:"Table",nullable:!1}})),X(1,i.decorators.param({type:"column",options:{semType:"fit",caption:"Curves",nullable:!1,description:"Column of fitted curves"}})),X(2,i.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"}})),X(3,i.decorators.param({type:"int",options:{caption:"Series",nullable:!1,initialValue:"0",description:"Zero-based index of the curve series"}})),D("design:type",Function),D("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,Number]),D("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],V,"addCurveStatistic",null),R([i.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"}}),X(0,i.decorators.param({options:{caption:"Table",nullable:!1}})),X(1,i.decorators.param({type:"column",options:{semType:"fit",caption:"Curves",nullable:!1,description:"Column of fitted curves"}})),X(2,i.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"}})),X(3,i.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"}})),D("design:type",Function),D("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,String]),D("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],V,"addAggrCurveStatistic",null),R([i.decorators.func({description:"Returns XML 3DX curve converter function",meta:{role:"curveConverter",curveFormat:"3dx"}}),D("design:type",Function),D("design:paramtypes",[]),D("design:returntype",Function)],V,"convertXmlCurveToJsonFunc",null),R([i.decorators.func({description:"Returns compact dose-response JSON converter function",meta:{role:"curveConverter",curveFormat:"compact-dr"}}),D("design:type",Function),D("design:paramtypes",[]),D("design:returntype",Function)],V,"convertCompactDrToJsonFunc",null),R([i.decorators.func({description:"Returns PZFX curve converter function",meta:{role:"curveConverter",curveFormat:"pzfx"}}),D("design:type",Function),D("design:paramtypes",[]),D("design:returntype",Function)],V,"convertPzfxToJsonFunc",null),R([i.decorators.fileViewer({fileViewer:"pzfx"}),D("design:type",Function),D("design:paramtypes",[void 0===r||void 0===r.FileInfo?Object:r.FileInfo]),D("design:returntype",Promise)],V,"previewPzfx",null),R([i.decorators.fileHandler({ext:"pzfx",description:"Open a GraphPad Prism (.pzfx) file as data tables, fitting XY curve tables."}),X(0,i.decorators.param({type:"list",options:{description:"Raw bytes of the .pzfx file"}})),D("design:type",Function),D("design:paramtypes",["u"<typeof Uint8Array?Object:Uint8Array]),D("design:returntype",Array)],V,"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)],i=t[Math.trunc(3*t.length/4)],l=1.5*(i-n),a=o(t,i+l);a<0&&(a=~a);let s=t[Math.max(0,a-1)];s<i&&(s=i);let u=o(t,n-l);u<0&&(u=~u);let c=t[u];return c>n&&(c=n),{q1:n,q2:r,q3:i,lowerAdjacentValue:c,upperAdjacentValue:s}}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:()=>b,Al:()=>l,EV:()=>w,Ff:()=>f,G7:()=>d,Hr:()=>I,Mi:()=>S,Pf:()=>p,Qx:()=>g,Sm:()=>T,Vd:()=>O,Z5:()=>v,ah:()=>y,dZ:()=>i,h1:()=>a,kC:()=>h,kx:()=>m,nK:()=>u,oH:()=>s,ry:()=>x,sn:()=>C,xs:()=>c});var r=n(82),o=n(353);let i={CONSTANT:"constant",PROPORTIONAL:"proportional",COMBINED:"combined"},l=["rSquared","auc","interceptX","interceptY","slope","top","bottom"],a=["IC10","IC20","IC50","IC80","IC90"];class s{constructor(){this.chartOptions={},this.seriesOptions={},this.series=[]}}let u=[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:u.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"})],d="sigmoid",f="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 x(e,t){let n=e[0],r=e[1],o=e[2],i=e[3];return i+(n-i)/(1+Math.pow(10,(t-o)*r))}function C(e,t){return e[0]*t+e[1]}function b(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],i=e[3];return i+(n-i)/(1+Math.pow(t/o,r))}function O(e,t){let n=e[3];return n+(e[0]-n)/(1+Math.pow(10,e[1]*(e[2]-t)))}function S(e,t){let n=0,r=Math.min(...t.x),o=Math.max(...t.x),i=(o-r)/1e3;for(let t=r;t<o;t+=i)n+=i*e(t);return n}function I(e,t){let n=0,r=0,i=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]-i,2);return 1-n/r}},165(e,t,n){"use strict";n.d(t,{GO:()=>x,KZ:()=>b,Kh:()=>s,VA:()=>g,W$:()=>u,_T:()=>m,fY:()=>p,iK:()=>C,s$:()=>d,xS:()=>h,zB:()=>f});var r=n(82),o=n(590),i=n(869),l=n(774);function a(e){let t={};var n=!0,r=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done);n=!0){let e=i.value;null!==e.defaultValue&&(t[e.name]=e.defaultValue)}}catch(e){r=!0,o=e}finally{try{n||null==l.return||l.return()}finally{if(r)throw o}}return t}function s(){return{chartOptions:a(o.xs),seriesOptions:a(i.IL)}}function u(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,i=e.left,l=e.right,a=e.top,s=e.bottom;if(t.logX)i=i>0?i/(1+o):i,l*=1+o;else{let t=e.width*o;i-=t,l+=t}if(t.logY)a=a>0?a/(1+o):a,s*=1+o;else{let t=e.height*o;a-=t,s+=t}return new r.Rect(i,a,l-i,s-a)}function d(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,i,l,a,s,d=u(e.series[0].points),f=d.xs,m=d.ys,p=r.Rect.fromXYArrays(f,m);for(let t=1;t<e.series.length;t++){let n=u(e.series[t].points),o=n.xs,i=n.ys;o.some(e=>void 0===e)||i.some(e=>void 0===e)||(p=p.union(r.Rect.fromXYArrays(o,i)))}return o?(i=(t=c(n=p,o)).x,l=t.y,a=t.width,s=t.height,null!=o.minX&&o.minX<=n.maxX&&(!o.logX||o.logX&&o.minX>0)&&(a+=i-o.minX,i=o.minX),null!=o.maxX&&o.maxX>=n.minX&&(!o.logX||o.logX&&o.maxX>0)&&(a+=o.maxX-(i+a)),null!=o.minY&&o.minY<=n.maxY&&(!o.logY||o.logY&&o.minY>0)&&(s+=l-o.minY,l=o.minY),null!=o.maxY&&o.maxY>=n.minY&&(!o.logY||o.logY&&o.maxY>0)&&(s+=o.maxY-(l+s)),new r.Rect(i,l,a,s)):c(p,o)}}function f(e){return(0,i.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 s,u;null!=r||(r=(0,l.Sm)(e,a,n));let c=null!=(s=e.parameters)?s:(0,i.nT)(e,t,r).parameters,d=new Float32Array(c.length);return d.set(c),(0,i.O8)(r,d,t.y,.05,null!=(u=e.errorModel)?u:o.dZ.CONSTANT)}function h(e,t,n,r){var a;null!=n||(n=(0,l.Sm)(e,r,!1));let s=null!=(a=e.parameters)?a:(0,i.nT)(e,t,n).parameters,u=new Float32Array(s.length);return u.set(s),t.fillParams({fittedCurve:(0,o.ah)(t.y,u),parameters:u},e,n,r)}function g(e,t,n,r){var o;return o=h(e,t,n,r),{rSquared:(0,i.h5)(o,"rSquared"),auc:(0,i.h5)(o,"auc"),interceptX:(0,i.h5)(o,"interceptX"),interceptY:(0,i.h5)(o,"interceptY"),slope:(0,i.h5)(o,"slope"),top:(0,i.h5)(o,"top"),bottom:(0,i.h5)(o,"bottom")}}let v=["ic50","ec50"],y=[],x=["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=f(e).statisticFields,i=[...e.parameters],l=!1;for(let e=0;e<i.length&&e<o.length;e++)(t.logX&&v.includes(o[e])||t.logY&&y.includes(o[e]))&&i[e]>0&&(i[e]=Math.log10(i[e]),l=!0);return l?(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:i},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 i,l=t[Symbol.iterator]();!(n=(i=l.next()).done);n=!0){let t=i.value;"number"==typeof e[t]&&(e[t]=Math.pow(10,e[t]))}}catch(e){r=!0,o=e}finally{try{n||null==l.return||l.return()}finally{if(r)throw o}}};return(null==t?void 0:t.logX)&&n(v),(null==t?void 0:t.logY)&&n(y),"number"==typeof e.ic50&&e.ic50>0&&(e.pIC50=-Math.log10(e.ic50)),e}},869(e,t,n){"use strict";n.d(t,{nT:()=>U,IL:()=>H,HM:()=>B,hD:()=>V,rT:()=>G,ou:()=>q,TV:()=>J,O8:()=>Z,h5:()=>D,Wh:()=>R,ct:()=>W,JS:()=>$,Z2:()=>y});var r,o,i=n(82),l=n(590),a=n(774),s=n(353);class u 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 d(e,t,n,r,o,i,l,a){for(let s=0;s<i;s++)t[s]=e[s],t[s]+=o*(e[s]-r[n][s]),t[s]<l[s]?t[s]=l[s]:t[s]>a[s]&&(t[s]=a[s])}(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 f=function(e,t,n,r,o){var i;let l=n.tolerance,a=n.maxIter,s=n.scaleReflection,u=n.scaleExpansion,f=n.scaleContraction,m=t.length+1,p=t.length,h=function(e){if(Array.isArray(e))return e}(i=function(e,t,n,r,o){let i=n.length+1,l=n.length,a=t.nonZeroParam,s=t.initialScale,u=Array(i),c=Array(i);for(let t=0;t<i;t++){u[t]=new Float32Array(l);for(let e=0;e<l;e++)u[t][e]=n[e],0!==t&&t-1===e&&(0===n[e]?u[t][e]=a:u[t][e]+=s*n[t-1],u[t][e]<r[e]?u[t][e]=r[e]:u[t][e]>o[e]&&(u[t][e]=o[e]));c[t]=e(u[t]).likelihood}return[u,c]}(e,n,t,r,o))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,l=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(l)throw n}}return o}}(i)||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)}}(i)||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 x=y.length-1,C=0,b=0,w=0,T=0,O=new Float32Array(p),S=new Float32Array(p),I=new Float32Array(p),P=new Float32Array(p),_=Array(a);if(m>1){for(;y.sort((e,t)=>v[e]-v[t]),!(C>a);){if(0===C&&(b=v[0],w=2*v[y[0]]),_[C]=b,++C,w-(b=v[y[0]])>l)T=0;else if(++T>2*m)break;w=b,function(e,t,n,r){for(let o=0;o<t;o++){let i=0;for(let e=0;e<t+1;e++)e!==n&&(i+=r[e][o]);e[o]=i/t}}(O,p,y[x],g),d(O,S,y[x],g,s,p,r,o);let t=e(S).likelihood;if(t<v[y[x]]){d(O,I,y[x],g,u,p,r,o);let n=e(I).likelihood;if(n<t){v[y[x]]=n;for(let e=0;e<p;e++)g[y[x]][e]=I[e];continue}v[y[x]]=t;for(let e=0;e<p;e++)g[y[x]][e]=S[e];continue}d(O,P,y[x],g,f,p,r,o);let n=e(P).likelihood;if(n<v[y[x]]){v[y[x]]=n;for(let e=0;e<p;e++)g[y[x]][e]=P[e];continue}break}for(let e=C;e<a;e++)_[e]=v[y[0]]}return{point:g[y[0]],cost:v[y[0]],iterCosts:_,iterCount:C-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,[...N,...e.map((e,n)=>_(e,t[n])),...void 0===n?[]:n])),this._statisticsProperties}legacyStatisticProperty(e){var t,n;if("interceptY"===e)return M;let r=F[e];if(void 0!==r&&!(r>=this.parameterNames.length))return null!=this._legacyProperties||(this._legacyProperties={}),null!=(t=(n=this._legacyProperties)[e])?t:n[e]=_(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 x{constructor(e,t,n){this.auc=e.auc,this.rSquared=e.rSquared,this.series=t,this.parameters=n}}let C=["auc","rSquared","series","parameters","name"];class b extends x{get name(){return l.Z5}constructor(e,t,n,r,o){let i=void 0===r?[]:r;super(e,t,n);for(let e=0;e<i.length;e++)C.includes(i[e])||(this[i[e]]=n[e]);o&&n.length>2&&void 0===this.interceptY&&(this.interceptY=o(n[2]))}}class w extends x{get name(){return l.Ff}constructor(e,t,n){super(e,t,n),this.slope=e.slope,this.intercept=e.intercept}}class T extends w{get name(){return l.kx}}class O extends x{get name(){return l.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 S extends x{get name(){return l.Pf}constructor(e,t,n){super(e,t,n),this.mantissa=e.mantissa,this.power=e.power}}class I extends x{get name(){return l.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 P extends I{get name(){return l.Qx}constructor(e,t,n){super(e,t,n),this.ic50=e.ec50}}function _(e,t){return i.Property.js(e,i.TYPE.FLOAT,{userEditable:!1,friendlyName:t})}let N=[_("rSquared","R\xb2"),_("auc","AUC")];function E(e){return[_("interceptY",`Y at ${e}`),_("maxY","Max Y"),_("minY","Min Y")]}let A=_("pIC50","pIC50"),L={[l.G7]:{interceptX:"ic50"},[l.kC]:{interceptX:"ec50"},[l.Qx]:{interceptX:"ic50"}},F={top:0,slope:1,interceptX:2,bottom:3},M=_("interceptY","Intercept Y");function R(e,t){var n,r,o;let i=null!=(n=null==(o=L[e.name])?void 0:o[t])?n:t;return null!=(r=e.statisticsProperties.find(e=>e.name===i))?r:e.legacyStatisticProperty(t)}function D(e,t){var n,r,o;let i=null!=(n=null==(r=L[e.name])?void 0:r[t])?n:t,l=e[i];if("number"==typeof l)return l;if("interceptX"===t)return;let a=F[t],s=void 0===a||null==(o=e.parameters)?void 0:o[a];return"number"!=typeof s||isNaN(s)?void 0:s}function X(e,t,n){return null!=t?t:(0,a.Sm)(e,n,!1)}function Y(e,t){return{auc:(0,l.Mi)(e,t),rSquared:(0,l.Hr)(e,t)}}class k extends v{get name(){return l.kC}get hasAsymptotes(){return!0}get parameterNames(){return["Top","Slope","EC50","Bottom"]}get statisticFields(){return["top","slope","ec50","bottom"]}get derivedStatisticsProperties(){return E(this.parameterNames[2])}fitValues(e,t,n,r){return g(h({},Y(e.fittedCurve,X(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 I(this.fitValues(e,t,n,r),t,e.parameters)}y(e,t){return(0,l.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),i=(o-r)/2+r,l=o-r,a=0;for(let n=0;n<e.length;n++){let e=Math.abs(t[n]-i);e<l&&(l=e,a=n)}let s=e[a],u=t[0]>t[t.length-1]?-10:10;return n.set([o,u,s,r]),n}}class j extends v{get statisticFields(){return this._parameterNames.filter(e=>!C.includes(e))}get statisticLabels(){return this.statisticFields}fillParams(e,t,n,r){return new b(Y(e.fittedCurve,X(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 G={linear:new class extends v{get name(){return l.Ff}get parameterNames(){return["Slope","Intercept"]}get statisticFields(){return["slope","intercept"]}fillParams(e,t,n,r){return new w(g(h({},Y(e.fittedCurve,X(t,n,r))),{slope:e.parameters[0],intercept:e.parameters[1]}),t,e.parameters)}y(e,t){return(0,l.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],i=(t[r]-t[n])/o,l=t[r]-i*e[r],a=new Float32Array(2);return a.set([i,l]),a}},sigmoid:new class extends v{get name(){return l.G7}get hasAsymptotes(){return!0}get parameterNames(){return["Top","Slope","IC50","Bottom"]}get statisticFields(){return["top","slope","ic50","bottom"]}get derivedStatisticsProperties(){return[...E(this.parameterNames[2]),A]}fillParams(e,t,n,r){return new O(g(h({},Y(e.fittedCurve,X(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,l.ry)(e,t)}inverse(e,t){return e[2]+Math.log10(t/(1-t))/Math.abs(e[1])}getInitialParameters(e,t){let n=i.Rect.fromXYArrays(e,t),r=(n.maxY-n.minY)/2+n.minY,o=n.maxY-n.minY,l=0;for(let n=0;n<e.length;n++){let e=Math.abs(t[n]-r);e<o&&(o=e,l=n)}let a=e[l],s=t[0]>t[t.length-1]?1:-1,u=new Float32Array(4);return u.set([n.maxY,s,a,n.minY]),u}},"log-linear":new class extends v{get name(){return l.kx}get parameterNames(){return["Slope","Intercept"]}get statisticFields(){return["slope","intercept"]}fillParams(e,t,n,r){return new T(g(h({},Y(e.fittedCurve,X(t,n,r))),{slope:e.parameters[0],intercept:e.parameters[1]}),t,e.parameters)}y(e,t){return(0,l.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 l.Pf}get parameterNames(){return["Mantissa","Power"]}get statisticFields(){return["mantissa","power"]}fillParams(e,t,n,r){return new S(g(h({},Y(e.fittedCurve,X(t,n,r))),{mantissa:e.parameters[0],power:e.parameters[1]}),t,e.parameters)}y(e,t){return(0,l.EV)(e,t)}getInitialParameters(e,t){let n=new Float32Array(2);return n.set([100,-2]),n}},"4pl-regression":new k,"4pl-dose-response":new class extends k{get name(){return l.Qx}get parameterNames(){return["Max","Hill","IC50","Min"]}get statisticFields(){return["top","slope","ic50","bottom"]}get derivedStatisticsProperties(){return[...E(this.parameterNames[2]),A]}fillParams(e,t,n,r){return new P(this.fitValues(e,t,n,r),t,e.parameters)}y(e,t){return(0,l.Vd)(e,t)}inverse(e,t){return e[2]+Math.log10(t/(1-t))/Math.abs(e[1])}}},V="sigmoid",B={};class ${constructor(e){this.points=e}}let H=[i.Property.js("fitFunction",i.TYPE.STRING,{category:"Fitting",choices:Object.keys(G),defaultValue:V}),i.Property.js("pointColor",i.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),i.Property.js("fitLineColor",i.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),i.Property.js("outlierColor",i.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),i.Property.js("errorModel",i.TYPE.STRING,{category:"Fitting",defaultValue:"constant",choices:["constant","proportional","combined"],nullable:!1}),i.Property.js("connectDots",i.TYPE.BOOL,{category:"Fitting",defaultValue:!1}),i.Property.js("clickToToggle",i.TYPE.BOOL,{category:"Fitting",description:"Click on a point to mark it as outlier and refit",nullable:!0,defaultValue:!1}),i.Property.js("showFitLine",i.TYPE.BOOL,{category:"Fitting",defaultValue:!0}),i.Property.js("showPoints",i.TYPE.STRING,{category:"Fitting",description:"Whether points/candlesticks/none should be rendered",defaultValue:"points",choices:["points","candlesticks","both"]}),i.Property.js("showOutliers",i.TYPE.BOOL,{category:"Fitting",defaultValue:!0}),i.Property.js("showCurveConfidenceInterval",i.TYPE.BOOL,{category:"Fitting",description:"Whether confidence intervals should be rendered",defaultValue:!1,friendlyName:"Confidence Interval"}),i.Property.js("markerType",i.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"}),i.Property.js("outlierMarkerType",i.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"}),i.Property.js("lineStyle",i.TYPE.STRING,{category:"Rendering",defaultValue:"solid",choices:["solid","dotted","dashed","dashdotted"],nullable:!1}),i.Property.js("droplines",i.TYPE.STRING_LIST,{description:"Whether specific droplines should be rendered",choices:l.h1,inputType:"MultiChoice"}),i.Property.js("columnName",i.TYPE.STRING,{description:"Column name where the series is stored",defaultValue:""})];function q(e){return G[e]}function W(e,t){return e.name===t}function J(e){var t,n;if(null==e)return G[V];if("string"==typeof e)return null!=(t=G[e])?t:G[V];if(!G[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()),i=new j(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);G[t]=i}return null!=B[n=e.name]||(B[n]=e),G[e.name]}function U(e,t,n,r){var s;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,s,c;let d;null!=n||(n=l.dZ.CONSTANT);let m=t.y,h=t.getInitialParameters(e.x,e.y),g=(a=m,s=e,c=n,e=>{var t;let n=0,r=0,o=0,i=s.y,u=s.x.map(t=>a(e,t)),d=i.map((e,t)=>e-u[t]),f=d.map(e=>Math.pow(e,2));for(let e=0;e<f.length;e++)[l.dZ.CONSTANT,l.dZ.COMBINED].includes(c)?r+=f[e]:c===l.dZ.PROPORTIONAL&&(o+=f[e]/(u[e]*u[e]));r=Math.sqrt(r/f.length),o=Math.sqrt(o/f.length),c===l.dZ.COMBINED&&(r=(t=z(r,o,f,u)).sigmaA,o=t.sigmaB);let m=[];for(let e=0;e<f.length;e++)m[e]=Math.pow(r+o*u[e],2),n+=f[e]/m[e]+Math.log(2*Math.PI*m[e]);return{likelihood:n,residuals:d}}),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 x=i.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,x.set(2*e,!0)),void 0!==r[e].max&&null!==r[e].max&&(y[e]=r[e].max,x.set(2*e+1,!0));let C=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},b=-1,w=0,T=null,O=0;for(;;){d=function(e,t,n,r,o){let l,a=void 0===o?null:o,s=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 i=0;i<r;i++)if(e[i]===t[i])for(let t=0;t<10;t++)o[t][i]=e[i];else{let r=function(e,t,n,r){let o=t-n,i=Array(e);for(let t=0;t<e;t++){let e=r();i[t]=n+e*o}return i}(10,e[i],t[i],n);for(let e=0;e<10;e++)o[e][i]=r[e]}return o}(n,t),c=[],d=[],m=[],h=0,g=null;for(l=0;l<10;++l)try{if(0===l){let t=null===a?s[l]:a,n=new Float32Array(a.length).map(e=>-1/0),o=new Float32Array(a.length).map(e=>Infinity);c.push(f(e,t,r,n,o))}else c.push(f(e,s[l],r,t,n))}catch(e){if(e instanceof u)throw Error(`Inconsistent dataframes: ${e.message}`);++h,d.push(e instanceof Error?e.message:"Platform issue"),m.push(s[l])}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=i.DataFrame.fromColumns(t.map((e,t)=>i.Column.fromFloat32Array(`arg${t}`,e)))).columns.add(i.Column.fromStrings("Issue",d))}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),O=0;for(let e=1;e<d.extremums.length;e++)d.extremums[e].cost<d.extremums[O].cost&&(O=e);let e=C(d.extremums[O]);if(null===T?T=e:e<T?(T=e,w=0):w++,h=d.extremums[O].point,b>40||3===w)break;for(let e=0;e<t.parameterNames.length;e++)x.get(2*e)||(v[e]=h[e]-Math.abs(h[e]*(w+.5))),x.get(2*e+1)||(y[e]=h[e]+Math.abs(h[e]*(w+.5)));b++}return{fittedCurve:(0,l.ah)(m,h),parameters:h}}((0,a.mr)(n),t,null!=(s=e.errorModel)?s:l.dZ.CONSTANT,e.parameterBounds)}function z(e,t,n,r){let o=Number.MAX_VALUE,i=0;for(let t=0;t<=10;t++){let l=0,a=t/10,s=e*a,u=e*(1-a),c=[];for(let e=0;e<n.length;e++)c[e]=Math.pow(s+u*r[e],2),l+=n[e]/c[e]+Math.log(2*Math.PI*c[e]);l<o&&(o=l,i=a)}return t=e*(1-i),{sigmaA:e*=i,sigmaB:t}}function Z(e,t,n,r,o){let i=function(e,t,n,r){var o;let i=0,a=0,s=t.y,u=t.x.map(t=>e(r,t)),c=s.map((e,t)=>e-u[t]),d=c.map(e=>Math.pow(e,2));for(let e=0;e<d.length;e++)[l.dZ.CONSTANT,l.dZ.COMBINED].includes(n)?i+=d[e]:n===l.dZ.PROPORTIONAL&&(a+=Math.pow(c[e]/Math.abs(u[e]),2));return i=Math.sqrt(i/d.length),a=Math.sqrt(a/d.length),n===l.dZ.COMBINED&&(i=(o=z(i,a,d,u)).sigmaA,a=o.sigmaB),{sigmaA:i,sigmaB:a}}(n,e,o,t),a=s.normal.inv(1-(void 0===r?.05:r)/2,0,1);return{confidenceTop:e=>{let r=n(t,e);return r+a*(i.sigmaA+Math.abs(r)*i.sigmaB)},confidenceBottom:e=>{let r=n(t,e);return r-a*(i.sigmaA+Math.abs(r)*i.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 i(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 i=o(n);t.x[t.x.length]=n.x[0],t.y[t.y.length]=i,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 l(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:()=>l,mr:()=>i})},533(e,t,n){"use strict";n.d(t,{L:()=>l});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}},i=new class{screenToWorld(e,t,n,r,o){let i=Math.log(n=n<1e-30?1e-30:n);return Math.exp(i+(Math.log(r)-i)*(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 i=t*Math.log((e=e<1e-30?1e-30:e)/(n=n<1e-30?1e-30:n))/Math.log(r/n);return o?t-i:i}};class l{get xt(){return this.logX?i:o}get yt(){return this.logY?i: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 i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.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);var r={};(()=>{"use strict";let e;n.r(r),n.d(r,{tests:()=>f,test:()=>tO,_package:()=>tT,initAutoTests:()=>tS});var t,o,i,l=n(82);n(397);let a=DG.DataFrame.fromCsv(`countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string
1
+ var curves_test;(()=>{var e={397(e){!function(t,n){var r={};n(r);var o=r.default;for(var i in r)o[i]=r[i];"object"==typeof e.exports?e.exports=o:"function"==typeof define&&define.amd?define(function(){return o}):t.sha256=o}(this,function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2]);function n(e,n,r,o,i){for(var l,a,s,u,c,d,f,m,p,h,g,v,y;i>=64;){for(h=0,l=n[0],a=n[1],s=n[2],u=n[3],c=n[4],d=n[5],f=n[6],m=n[7];h<16;h++)g=o+4*h,e[h]=(255&r[g])<<24|(255&r[g+1])<<16|(255&r[g+2])<<8|255&r[g+3];for(h=16;h<64;h++)v=((p=e[h-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,y=((p=e[h-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,e[h]=(v+e[h-7]|0)+(y+e[h-16]|0);for(h=0;h<64;h++)v=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&d^~c&f)|0)+(m+(t[h]+e[h]|0)|0)|0,y=((l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10))+(l&a^l&s^a&s)|0,m=f,f=d,d=c,c=u+v|0,u=s,s=a,a=l,l=v+y|0;n[0]+=l,n[1]+=a,n[2]+=s,n[3]+=u,n[4]+=c,n[5]+=d,n[6]+=f,n[7]+=m,o+=64,i-=64}return o}var r=function(){function t(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return t.prototype.reset=function(){return this.state[0]=0x6a09e667,this.state[1]=0xbb67ae85,this.state[2]=0x3c6ef372,this.state[3]=0xa54ff53a,this.state[4]=0x510e527f,this.state[5]=0x9b05688c,this.state[6]=0x1f83d9ab,this.state[7]=0x5be0cd19,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},t.prototype.clean=function(){for(var e=0;e<this.buffer.length;e++)this.buffer[e]=0;for(var e=0;e<this.temp.length;e++)this.temp[e]=0;this.reset()},t.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this.finished)throw Error("SHA256: can't update because hash was finished.");var r=0;if(this.bytesHashed+=t,this.bufferLength>0){for(;this.bufferLength<64&&t>0;)this.buffer[this.bufferLength++]=e[r++],t--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(t>=64&&(r=n(this.temp,this.state,e,r,t),t%=64);t>0;)this.buffer[this.bufferLength++]=e[r++],t--;return this},t.prototype.finish=function(e){if(!this.finished){var t=this.bytesHashed,r=this.bufferLength,o=t/0x20000000|0,i=t<<3,l=t%64<56?64:128;this.buffer[r]=128;for(var a=r+1;a<l-8;a++)this.buffer[a]=0;this.buffer[l-8]=o>>>24&255,this.buffer[l-7]=o>>>16&255,this.buffer[l-6]=o>>>8&255,this.buffer[l-5]=o>>>0&255,this.buffer[l-4]=i>>>24&255,this.buffer[l-3]=i>>>16&255,this.buffer[l-2]=i>>>8&255,this.buffer[l-1]=i>>>0&255,n(this.temp,this.state,this.buffer,0,l),this.finished=!0}for(var a=0;a<8;a++)e[4*a+0]=this.state[a]>>>24&255,e[4*a+1]=this.state[a]>>>16&255,e[4*a+2]=this.state[a]>>>8&255,e[4*a+3]=this.state[a]>>>0&255;return this},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype._saveState=function(e){for(var t=0;t<this.state.length;t++)e[t]=this.state[t]},t.prototype._restoreState=function(e,t){for(var n=0;n<this.state.length;n++)this.state[n]=e[n];this.bytesHashed=t,this.finished=!1,this.bufferLength=0},t}();e.Hash=r;var o=function(){function e(e){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var t=new Uint8Array(this.blockSize);if(e.length>this.blockSize)new r().update(e).finish(t).clean();else for(var n=0;n<e.length;n++)t[n]=e[n];for(var n=0;n<t.length;n++)t[n]^=54;this.inner.update(t);for(var n=0;n<t.length;n++)t[n]^=106;this.outer.update(t),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var n=0;n<t.length;n++)t[n]=0}return e.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},e.prototype.clean=function(){for(var e=0;e<this.istate.length;e++)this.ostate[e]=this.istate[e]=0;this.inner.clean(),this.outer.clean()},e.prototype.update=function(e){return this.inner.update(e),this},e.prototype.finish=function(e){return this.outer.finished?this.outer.finish(e):(this.inner.finish(e),this.outer.update(e,this.digestLength).finish(e)),this},e.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},e}();function i(e){var t=new r().update(e),n=t.digest();return t.clean(),n}function l(e,t){var n=new o(e).update(t),r=n.digest();return n.clean(),r}e.HMAC=o,e.hash=i,e.default=i,e.hmac=l;var a=new Uint8Array(e.digestLength);e.hkdf=function(e,t,n,r){void 0===t&&(t=a),void 0===r&&(r=32);for(var i=new Uint8Array([1]),s=new o(l(t,e)),u=new Uint8Array(s.digestLength),c=u.length,d=new Uint8Array(r),f=0;f<r;f++)c===u.length&&(!function(e,t,n,r){var o=r[0];if(0===o)throw Error("hkdf: cannot expand more");t.reset(),o>1&&t.update(e),n&&t.update(n),t.update(r),t.finish(e),r[0]++}(u,s,n,i),c=0),d[f]=u[c++];return s.clean(),u.fill(0),i.fill(0),d},e.pbkdf2=function(e,t,n,r){for(var i=new o(e),l=i.digestLength,a=new Uint8Array(4),s=new Uint8Array(l),u=new Uint8Array(l),c=new Uint8Array(r),d=0;d*l<r;d++){var f=d+1;a[0]=f>>>24&255,a[1]=f>>>16&255,a[2]=f>>>8&255,a[3]=f>>>0&255,i.reset(),i.update(t),i.update(a),i.finish(u);for(var m=0;m<l;m++)s[m]=u[m];for(var m=2;m<=n;m++){i.reset(),i.update(u).finish(u);for(var p=0;p<l;p++)s[p]^=u[p]}for(var m=0;m<l&&d*l+m<r;m++)c[d*l+m]=s[m]}for(var d=0;d<l;d++)s[d]=u[d]=0;for(var d=0;d<4;d++)a[d]=0;return i.clean(),c}})},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 i=Array.isArray||function(e){return"[object Array]"===r.call(e)};function l(e){return"[object Function]"===r.call(e)}function a(e){return"number"==typeof e&&e-e==0}function s(){return new s._init(arguments)}function u(){return 0}function c(){return 1}function d(e,t){return+(e===t)}s.fn=s.prototype,s._init=function(e){if(i(e[0]))if(i(e[0][0])){l(e[1])&&(e[0]=s.map(e[0],e[1]));for(var t=0;t<e[0].length;t++)this[t]=e[0][t];this.length=e[0].length}else this[0]=l(e[1])?s.map(e[0],e[1]):e[0],this.length=1;else if(a(e[0]))this[0]=s.seq.apply(null,e),this.length=1;else{if(e[0]instanceof s)return s(e[0].toArray());this[0]=[],this.length=1}return this},s._init.prototype=s.prototype,s._init.constructor=s,s.utils={calcRdx:o,isArray:i,isFunction:l,isNumber:a,toVector:function(e){return t.apply([],e)}},s._random_fn=e.random,s.setRandom=function(e){if("function"!=typeof e)throw TypeError("fn is not a function");s._random_fn=e},s.extend=function(e){var t,n;if(1==arguments.length){for(n in e)s[n]=e[n];return this}for(t=1;t<arguments.length;t++)for(n in arguments[t])e[n]=arguments[t][n];return e},s.rows=function(e){return e.length||1},s.cols=function(e){return e[0].length||1},s.dimensions=function(e){return{rows:s.rows(e),cols:s.cols(e)}},s.row=function(e,t){return i(t)?t.map(function(t){return s.row(e,t)}):e[t]},s.rowa=function(e,t){return s.row(e,t)},s.col=function(e,t){if(i(t)){var n=s.arange(e.length).map(function(){return Array(t.length)});return t.forEach(function(t,r){s.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},s.cola=function(e,t){return s.col(e,t).map(function(e){return e[0]})},s.diag=function(e){for(var t=s.rows(e),n=Array(t),r=0;r<t;r++)n[r]=[e[r][r]];return n},s.antidiag=function(e){for(var t=s.rows(e)-1,n=Array(t),r=0;t>=0;t--,r++)n[r]=[e[r][t]];return n},s.transpose=function(e){var t,n,r,o,l,a=[];for(i(e[0])||(e=[e]),n=e.length,r=e[0].length,l=0;l<r;l++){for(o=0,t=Array(n);o<n;o++)t[o]=e[o][l];a.push(t)}return 1===a.length?a[0]:a},s.map=function(e,t,n){var r,o,l,a,s;for(i(e[0])||(e=[e]),o=e.length,l=e[0].length,a=n?e:Array(o),r=0;r<o;r++)for(a[r]||(a[r]=Array(l)),s=0;s<l;s++)a[r][s]=t(e[r][s],r,s);return 1===a.length?a[0]:a},s.cumreduce=function(e,t,n){var r,o,l,a,s;for(i(e[0])||(e=[e]),o=e.length,l=e[0].length,a=n?e:Array(o),r=0;r<o;r++)for(a[r]||(a[r]=Array(l)),l>0&&(a[r][0]=e[r][0]),s=1;s<l;s++)a[r][s]=t(a[r][s-1],e[r][s]);return 1===a.length?a[0]:a},s.alter=function(e,t){return s.map(e,t,!0)},s.create=function(e,t,n){var r,o,i=Array(e);for(l(t)&&(n=t,t=e),r=0;r<e;r++)for(o=0,i[r]=Array(t);o<t;o++)i[r][o]=n(r,o);return i},s.zeros=function(e,t){return a(t)||(t=e),s.create(e,t,u)},s.ones=function(e,t){return a(t)||(t=e),s.create(e,t,c)},s.rand=function(e,t){return a(t)||(t=e),s.create(e,t,s._random_fn)},s.identity=function(e,t){return a(t)||(t=e),s.create(e,t,d)},s.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},s.clear=function(e){return s.alter(e,u)},s.seq=function(e,t,n,r){l(r)||(r=!1);var i,a=[],s=o(e,t),u=(t*s-e*s)/((n-1)*s),c=e;for(i=0;c<=t&&i<n;c=(e*s+u*s*++i)/s)a.push(r?r(c,i):c);return a},s.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},s.slice=function(){function e(e,t,n,r){var o,i=[],l=e.length;if(void 0===t&&void 0===n&&void 0===r)return s.copy(e);if(t=t||0,n=n||e.length,r=r||1,(t=t>=0?t:l+t)===(n=n>=0?n:l+n)||0===r||t<n&&r<0||t>n&&r>0)return[];if(r>0)for(o=t;o<n;o+=r)i.push(e[o]);else for(o=t;o>n;o+=r)i.push(e[o]);return i}return function(t,n){if(a((n=n||{}).row)){var r,o;if(a(n.col))return t[n.row][n.col];return e(s.rowa(t,n.row),(r=n.col||{}).start,r.end,r.step)}return a(n.col)?e(s.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)}))}}(),s.sliceAssign=function(t,n,r){var o,i;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=s.arange(n.col.start,e.min(t.length,n.col.end),n.col.step);var l=n.row;return o.forEach(function(e,n){t[l][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,i=s.arange(n.row.start,e.min(t[0].length,n.row.end),n.row.step);var u=n.col;return i.forEach(function(e,n){t[e][u]=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,i=s.arange(n.row.start,e.min(t.length,n.row.end),n.row.step),o=s.arange(n.col.start,e.min(t[0].length,n.col.end),n.col.step),i.forEach(function(e,n){o.forEach(function(o,i){t[e][o]=r[n][i]})}),t},s.diagonal=function(e){var t=s.zeros(e.length,e.length);return e.forEach(function(e,n){t[n][n]=e}),t},s.copy=function(e){return e.map(function(e){return a(e)?e:e.map(function(e){return e})})};var f=s.prototype;f.length=0,f.push=Array.prototype.push,f.sort=Array.prototype.sort,f.splice=Array.prototype.splice,f.slice=Array.prototype.slice,f.toArray=function(){return this.length>1?n.call(this):n.call(this)[0]},f.map=function(e,t){return s(s.map(this,e,t))},f.cumreduce=function(e,t){return s(s.cumreduce(this,e,t))},f.alter=function(e){return s.alter(this,e),this};for(var m="transpose clear symmetric rows cols dimensions diag antidiag".split(" "),p=0;p<m.length;p++)!function(e){f[e]=function(t){var n,r=this;return t?(setTimeout(function(){t.call(r,f[e].call(r))}),this):i(n=s[e](this))?s(n):n}}(m[p]);for(var h="row col".split(" "),g=0;g<h.length;g++)!function(e){f[e]=function(t,n){var r=this;return n?(setTimeout(function(){n.call(r,f[e].call(r,t))}),this):s(s[e](this,t))}}(h[g]);for(var v="create zeros ones rand identity".split(" "),y=0;y<v.length;y++)!function(e){f[e]=function(){return s(s[e].apply(null,arguments))}}(v[y]);return s}(Math);!function(e,t){var n=e.utils.isFunction;function r(e,t){return e-t}function o(e,n,r){return t.max(n,t.min(e,r))}e.sum=function(e){for(var t=0,n=e.length;--n>=0;)t+=e[n];return t},e.sumsqrd=function(e){for(var t=0,n=e.length;--n>=0;)t+=e[n]*e[n];return t},e.sumsqerr=function(t){for(var n,r=e.mean(t),o=0,i=t.length;--i>=0;)o+=(n=t[i]-r)*n;return o},e.sumrow=function(e){for(var t=0,n=e.length;--n>=0;)t+=e[n];return t},e.product=function(e){for(var t=1,n=e.length;--n>=0;)t*=e[n];return t},e.min=function(e){for(var t=e[0],n=0;++n<e.length;)e[n]<t&&(t=e[n]);return t},e.max=function(e){for(var t=e[0],n=0;++n<e.length;)e[n]>t&&(t=e[n]);return t},e.unique=function(e){for(var t={},n=[],r=0;r<e.length;r++)t[e[r]]||(t[e[r]]=!0,n.push(e[r]));return n},e.mean=function(t){return e.sum(t)/t.length},e.meansqerr=function(t){return e.sumsqerr(t)/t.length},e.geomean=function(n){var r=n.map(t.log),o=e.mean(r);return t.exp(o)},e.median=function(e){var t=e.length,n=e.slice().sort(r);return 1&t?n[t/2|0]:(n[t/2-1]+n[t/2])/2},e.cumsum=function(t){return e.cumreduce(t,function(e,t){return e+t})},e.cumprod=function(t){return e.cumreduce(t,function(e,t){return e*t})},e.diff=function(e){var t,n=[],r=e.length;for(t=1;t<r;t++)n.push(e[t]-e[t-1]);return n},e.rank=function(e){var t,n=[],o={};for(t=0;t<e.length;t++){var i=e[t];o[i]?o[i]++:(o[i]=1,n.push(i))}var l=n.sort(r),a={},s=1;for(t=0;t<l.length;t++){var i=l[t],u=o[i],c=(s+(s+u-1))/2;a[i]=c,s+=u}return e.map(function(e){return a[e]})},e.mode=function(e){var t,n=e.length,o=e.slice().sort(r),i=1,l=0,a=0,s=[];for(t=0;t<n;t++)o[t]===o[t+1]?i++:(i>l?(s=[o[t]],l=i,a=0):i===l&&(s.push(o[t]),a++),i=1);return 0===a?s[0]:s},e.range=function(t){return e.max(t)-e.min(t)},e.variance=function(t,n){return e.sumsqerr(t)/(t.length-!!n)},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),i=0;i<r;i++)o[i]=t[i]-n;return o},e.stdev=function(n,r){return t.sqrt(e.variance(n,r))},e.pooledstdev=function(n){return t.sqrt(e.pooledvariance(n))},e.meandev=function(n){for(var r=e.mean(n),o=[],i=n.length-1;i>=0;i--)o.push(t.abs(n[i]-r));return e.mean(o)},e.meddev=function(n){for(var r=e.median(n),o=[],i=n.length-1;i>=0;i--)o.push(t.abs(n[i]-r));return e.median(o)},e.coeffvar=function(t){return e.stdev(t)/e.mean(t)},e.quartiles=function(e){var n=e.length,o=e.slice().sort(r);return[o[t.round(n/4)-1],o[t.round(n/2)-1],o[t.round(3*n/4)-1]]},e.quantiles=function(e,n,i,l){var a,s,u,c,d,f,m=e.slice().sort(r),p=[n.length],h=e.length;for(void 0===i&&(i=3/8),void 0===l&&(l=3/8),a=0;a<n.length;a++)u=i+(s=n[a])*(1-i-l),c=h*s+u,d=t.floor(o(c,1,h-1)),f=o(c-d,0,1),p[a]=(1-f)*m[d-1]+f*m[d];return p},e.percentile=function(e,t,n){var o=e.slice().sort(r),i=t*(o.length+(n?1:-1))+ +!n,l=parseInt(i);return l+1<o.length?o[l-1]+(i-l)*(o[l]-o[l-1]):o[l-1]},e.percentileOfScore=function(e,t,n){var r,o,i=0,l=e.length,a=!1;for("strict"===n&&(a=!0),o=0;o<l;o++)r=e[o],(a&&r<t||!a&&r<=t)&&i++;return i/l},e.histogram=function(n,r){r=r||4;var o,i=e.min(n),l=(e.max(n)-i)/r,a=n.length,s=[];for(o=0;o<r;o++)s[o]=0;for(o=0;o<a;o++)s[t.min(t.floor((n[o]-i)/l),r-1)]+=1;return s},e.covariance=function(t,n){var r,o=e.mean(t),i=e.mean(n),l=t.length,a=Array(l);for(r=0;r<l;r++)a[r]=(t[r]-o)*(n[r]-i);return e.sum(a)/(l-1)},e.corrcoeff=function(t,n){return e.covariance(t,n)/e.stdev(t,1)/e.stdev(n,1)},e.spearmancoeff=function(t,n){return t=e.rank(t),n=e.rank(n),e.corrcoeff(t,n)},e.stanMoment=function(n,r){for(var o=e.mean(n),i=e.stdev(n),l=n.length,a=0,s=0;s<l;s++)a+=t.pow((n[s]-o)/i,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 i=e.prototype,l="cumsum cumprod".split(" "),a=0;a<l.length;a++)!function(t){i[t]=function(r,o){var l=[],a=0,s=this;if(n(r)&&(o=r,r=!1),o)return setTimeout(function(){o.call(s,i[t].call(s,r))}),this;if(this.length>1){for(s=!0===r?this:this.transpose();a<s.length;a++)l[a]=e[t](s[a]);return l}return e[t](this[0],r)}}(l[a]);for(var s="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(" "),u=0;u<s.length;u++)!function(t){i[t]=function(r,o){var l=[],a=0,s=this;if(n(r)&&(o=r,r=!1),o)return setTimeout(function(){o.call(s,i[t].call(s,r))}),this;if(this.length>1){for("sumrow"!==t&&(s=!0===r?this:this.transpose());a<s.length;a++)l[a]=e[t](s[a]);return!0===r?e[t](e.utils.toVector(l)):l}return e[t](this[0],r)}}(s[u]);for(var c="quantiles percentileOfScore".split(" "),d=0;d<c.length;d++)!function(t){i[t]=function(){var r,o=[],l=0,a=this,s=Array.prototype.slice.call(arguments);if(n(s[s.length-1])){r=s[s.length-1];var u=s.slice(0,s.length-1);return setTimeout(function(){r.call(a,i[t].apply(a,u))}),this}r=void 0;var c=function(n){return e[t].apply(a,[n].concat(s))};if(this.length>1){for(a=a.transpose();l<a.length;l++)o[l]=c(a[l]);return o}return c(this[0])}}(c[d])}(e,Math);var t=Math;e.gammaln=function(e){var n,r,o=0,i=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],l=1.000000000190015;for(r=(n=e)+5.5,r-=(e+.5)*t.log(r);o<6;o++)l+=i[o]/++n;return t.log(2.5066282746310007*l/e)-r},e.loggam=function(e){var n,r,o,i,l,a,s,u=[.08333333333333333,-.002777777777777778,7936507936507937e-19,-5952380952380952e-19,8417508417508418e-19,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=e,s=0,1==e||2==e)return 0;for(e<=7&&(s=t.floor(7-e),n=e+s),r=1/(n*n),o=2*t.PI,l=u[9],a=8;a>=0;a--)l*=r,l+=u[a];if(i=l/n+.5*t.log(o)+(n-.5)*t.log(n)-n,e<=7)for(a=1;a<=s;a++)i-=t.log(n-1),n-=1;return i},e.gammafn=function(e){var n,r,o,i,l=[-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],s=!1,u=0,c=0,d=0,f=e;if(e>171.6243769536076)return 1/0;if(f<=0){if(!(i=f%1+36e-17))return 1/0;s=(1&f?-1:1)*t.PI/t.sin(t.PI*i),f=1-f}for(n=0,o=f,r=f<1?f++:(f-=u=(0|f)-1)-1;n<8;++n)d=(d+l[n])*r,c=c*r+a[n];if(i=d/c+1,o<f)i/=o;else if(o>f)for(n=0;n<u;++n)i*=f,f++;return s&&(i=s/i),i},e.gammap=function(t,n){return e.lowRegGamma(t,n)*e.gammafn(t)},e.lowRegGamma=function(n,r){var o,i=e.gammaln(n),l=n,a=1/n,s=a,u=r+1-n,c=1/1e-30,d=1/u,f=d,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+=s*=r/++l;return a*t.exp(-r+n*t.log(r)-i)}for(;m<=p;m++)u+=2,f*=(d=1/(d=(o=-m*(m-n))*d+u))*(c=u+o/c);return 1-f*t.exp(-r+n*t.log(r)-i)},e.factorialln=function(t){return t<0?NaN:e.gammaln(t+1)},e.factorial=function(t){return t<0?NaN:e.gammafn(t+1)},e.combination=function(n,r){return n>170||r>170?t.exp(e.combinationln(n,r)):e.factorial(n)/e.factorial(r)/e.factorial(n-r)},e.combinationln=function(t,n){return e.factorialln(t)-e.factorialln(n)-e.factorialln(t-n)},e.permutation=function(t,n){return e.factorial(t)/e.factorial(t-n)},e.betafn=function(n,r){if(!(n<=0)&&!(r<=0))return n+r>170?t.exp(e.betaln(n,r)):e.gammafn(n)*e.gammafn(r)/e.gammafn(n+r)},e.betaln=function(t,n){return e.gammaln(t)+e.gammaln(n)-e.gammaln(t+n)},e.betacf=function(e,n,r){var o,i,l,a,s=1,u=n+r,c=n+1,d=n-1,f=1,m=1-u*e/c;for(1e-30>t.abs(m)&&(m=1e-30),a=m=1/m;s<=100&&(o=2*s,m=1+(i=s*(r-s)*e/((d+o)*(n+o)))*m,1e-30>t.abs(m)&&(m=1e-30),f=1+i/f,1e-30>t.abs(f)&&(f=1e-30),a*=(m=1/m)*f,m=1+(i=-(n+s)*(u+s)*e/((n+o)*(c+o)))*m,1e-30>t.abs(m)&&(m=1e-30),f=1+i/f,1e-30>t.abs(f)&&(f=1e-30),a*=l=(m=1/m)*f,!(3e-7>t.abs(l-1)));s++);return a},e.gammapinv=function(n,r){var o,i,l,a,s,u=0,c=r-1,d=e.gammaln(r);if(n>=1)return t.max(100,r+100*t.sqrt(r));if(n<=0)return 0;for(r>1?(a=t.log(c),s=t.exp(c*(a-1)-d),o=(2.30753+.27061*(i=t.sqrt(-2*t.log(n<.5?n:1-n))))/(1+i*(.99229+.04481*i))-i,n<.5&&(o=-o),o=t.max(.001,r*t.pow(1-1/(9*r)-o/(3*t.sqrt(r)),3))):o=n<(i=1-r*(.253+.12*r))?t.pow(n/i,1/r):1-t.log(1-(n-i)/(1-i));u<12;u++){if(o<=0)return 0;if(l=(e.lowRegGamma(r,o)-n)/(i=r>1?s*t.exp(-(o-c)+c*(t.log(o)-a)):t.exp(-o+c*t.log(o)-d)),(o-=i=l/(1-.5*t.min(1,l*((r-1)/o-1))))<=0&&(o=.5*(o+i)),t.abs(i)<1e-8*o)break}return o},e.erf=function(e){var n,r,o,i,l=[-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=l.length-1,s=!1,u=0,c=0;for(e<0&&(e=-e,s=!0),r=4*(n=2/(2+e))-2;a>0;a--)o=u,u=r*u-c+l[a],c=o;return i=n*t.exp(-e*e+.5*(l[0]+r*u)-c),s?i-1:1-i},e.erfc=function(t){return 1-e.erf(t)},e.erfcinv=function(n){var r,o,i,l,a=0;if(n>=2)return -100;if(n<=0)return 100;for(l=n<1?n:2-n,r=-.70711*((2.30753+.27061*(i=t.sqrt(-2*t.log(l/2))))/(1+i*(.99229+.04481*i))-i);a<2;a++)o=e.erfc(r)-l,r+=o/(1.1283791670955126*t.exp(-r*r)-r*o);return n<1?r:-r},e.ibetainv=function(n,r,o){var i,l,a,s,u,c,d,f,m,p=r-1,h=o-1,g=0;if(n<=0)return 0;if(n>=1)return 1;for(r>=1&&o>=1?(u=(2.30753+.27061*(a=t.sqrt(-2*t.log(n<.5?n:1-n))))/(1+a*(.99229+.04481*a))-a,n<.5&&(u=-u),c=(u*u-3)/6,d=2/(1/(2*r-1)+1/(2*o-1)),f=u*t.sqrt(c+d)/d-(1/(2*o-1)-1/(2*r-1))*(c+5/6-2/(3*d)),u=r/(r+o*t.exp(2*f))):(i=t.log(r/(r+o)),l=t.log(o/(r+o)),f=(a=t.exp(r*i)/r)+(s=t.exp(o*l)/o),u=n<a/f?t.pow(r*f*n,1/r):1-t.pow(o*f*(1-n),1/o)),m=-e.gammaln(r)-e.gammaln(o)+e.gammaln(r+o);g<10&&0!==u&&1!==u&&(s=(e.ibeta(u,r,o)-n)/(a=t.exp(p*t.log(u)+h*t.log(1-u)+m)),(u-=a=s/(1-.5*t.min(1,s*(p/u-h/(1-u)))))<=0&&(u=.5*(u+a)),u>=1&&(u=.5*(u+a+1)),!(t.abs(a)<1e-8*u)||!(g>0));g++);return u},e.ibeta=function(n,r,o){var i=0===n||1===n?0:t.exp(e.gammaln(r+o)-e.gammaln(r)-e.gammaln(o)+r*t.log(n)+o*t.log(1-n));return!(n<0)&&!(n>1)&&(n<(r+1)/(r+o+2)?i*e.betacf(n,r,o)/r:1-i*e.betacf(1-n,o,r)/o)},e.randn=function(n,r){var o,i,l,a,s;if(r||(r=n),n)return e.create(n,r,function(){return e.randn()});do o=e._random_fn(),i=1.7156*(e._random_fn()-.5),s=(l=o-.449871)*l+(a=t.abs(i)+.386595)*(.196*a-.25472*l);while(s>.27597&&(s>.27846||i*i>-4*t.log(o)*o*o));return i/o},e.randg=function(n,r,o){var i,l,a,s,u,c,d=n;if(o||(o=r),n||(n=1),r)return(c=e.zeros(r,o)).alter(function(){return e.randg(n)}),c;n<1&&(n+=1),i=n-1/3,l=1/t.sqrt(9*i);do{do s=1+l*(u=e.randn());while(s<=0);s=s*s*s,a=e._random_fn()}while(a>1-.331*t.pow(u,4)&&t.log(a)>.5*u*u+i*(1-s+t.log(s)));if(n==d)return i*s;do a=e._random_fn();while(0===a);return t.pow(a,1/d)*i*s};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(" "),i=0;i<o.length;i++)!function(t){e.fn[t]=function(){return e(e[t].apply(null,arguments))}}(o[i]);for(var l=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(" "),s=0;s<a.length;s++)!function(t){e[t]=function e(t,n,r){return this instanceof e?(this._a=t,this._b=n,this._c=r,this):new e(t,n,r)},e.fn[t]=function(n,r,o){var i=e[t](n,r,o);return i.data=this,i},e[t].prototype.sample=function(n){var r=this._a,o=this._b,i=this._c;return n?e.alter(n,function(){return e[t].sample(r,o,i)}):e[t].sample(r,o,i)};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,i=this._b,l=this._c;return(r||0===r||(r=this.data),"number"!=typeof r)?e.fn.map.call(r,function(r){return e[t][n](r,o,i,l)}):e[t][n](r,o,i,l)}}(n[r]);for(var o="mean median mode variance".split(" "),i=0;i<o.length;i++)!function(n){e[t].prototype[n]=function(){return e[t][n](this._a,this._b,this._c)}}(o[i])}(a[s]);function u(e,t,n,r){for(var o,i=0,a=1,s=1,u=1,c=0,d=0;l.abs((s-d)/s)>r;)d=s,i=s+(o=-(t+c)*(t+n+c)*e/(t+2*c)/(t+2*c+1))*i,a=u+o*a,c+=1,s=i+(o=c*(n-c)*e/(t+2*c-1)/(t+2*c))*s,i/=u=a+o*u,a/=u,s/=u,u=1;return s/t}function c(t,n,r){var o=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],i=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],a=.5*t;if(a>=8)return 1;var s=2*e.normal.cdf(a,0,1,1,0)-1;s=s>=l.exp(-50/r)?l.pow(s,r):0;for(var u=a,c=(8-a)/(x=t>3?2:3),d=u+c,f=0,m=r-1,p=1;p<=x;p++){for(var h=0,g=.5*(d+u),v=.5*(d-u),y=1;y<=12;y++){var x,C,b=g+v*(6<y?o[(C=12-y+1)-1]:-o[(C=y)-1]),w=b*b;if(w>60)break;var T=.5*(2*e.normal.cdf(b,0,1,1,0))-.5*(2*e.normal.cdf(b,t,1,1,0));T>=l.exp(-30/m)&&(h+=T=i[C-1]*l.exp(-(.5*w))*l.pow(T,m))}h*=2*v*r/l.sqrt(2*l.PI),f+=h,u=d,d+=c}return(s+=f)<=l.exp(-30/n)?0:(s=l.pow(s,n))>=1?1:s}e.extend(e.beta,{pdf:function(t,n,r){return t>1||t<0?0:1==n&&1==r?1:n<512&&r<512?l.pow(t,n-1)*l.pow(1-t,r-1)/e.betafn(n,r):l.exp((n-1)*l.log(t)+(r-1)*l.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/(l.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)*l.pow(n/r,n/2)*l.pow(t,n/2-1)*l.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/(l.pow(e-t,2)+l.pow(n,2))/l.PI},cdf:function(e,t,n){return l.atan((e-t)/n)/l.PI+.5},inv:function(e,t,n){return t+n*l.tan(l.PI*(e-.5))},median:function(e){return e},mode:function(e){return e},sample:function(t,n){return e.randn()*l.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:l.exp((n/2-1)*l.log(t)-t/2-n/2*l.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*l.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*l.exp(-t*e)},cdf:function(e,t){return e<0?0:1-l.exp(-t*e)},inv:function(e,t){return-l.log(1-e)/t},mean:function(e){return 1/e},median:function(e){return 1/e*l.log(2)},mode:function(){return 0},sample:function(t){return -1/t*l.log(e._random_fn())},variance:function(e){return l.pow(e,-2)}}),e.extend(e.gamma,{pdf:function(t,n,r){return t<0?0:0===t&&1===n?1/r:l.exp((n-1)*l.log(t)-t/r-e.gammaln(n)-n*l.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:l.exp(-(n+1)*l.log(t)-r/t-e.gammaln(n)+n*l.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:l.exp(l.log(t)+l.log(n)+(t-1)*l.log(e)+(n-1)*l.log(1-l.pow(e,t)))},cdf:function(e,t,n){return e<0?0:e>1?1:1-l.pow(1-l.pow(e,t),n)},inv:function(e,t,n){return l.pow(1-l.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 l.pow(1-l.pow(2,-1/t),1/e)},mode:function(e,t){if(e>=1&&t>=1&&1!==e&&1!==t)return l.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:l.exp(-l.log(e)-.5*l.log(2*l.PI)-l.log(n)-l.pow(l.log(e)-t,2)/(2*n*n))},cdf:function(t,n,r){return t<0?0:.5+.5*e.erf((l.log(t)-n)/l.sqrt(2*r*r))},inv:function(t,n,r){return l.exp(-1.4142135623730951*r*e.erfcinv(2*t)+n)},mean:function(e,t){return l.exp(e+t*t/2)},median:function(e){return l.exp(e)},mode:function(e,t){return l.exp(e-t*t)},sample:function(t,n){return l.exp(e.randn()*n+t)},variance:function(e,t){return(l.exp(t*t)-1)*l.exp(2*e+t*t)}}),e.extend(e.noncentralt,{pdf:function(t,n,r){return 1e-14>l.abs(r)?e.studentt.pdf(t,n):1e-14>l.abs(t)?l.exp(e.gammaln((n+1)/2)-r*r/2-.5*l.log(l.PI*n)-e.gammaln(n/2)):n/t*(e.noncentralt.cdf(t*l.sqrt(1+2/n),n+2,r)-e.noncentralt.cdf(t,n,r))},cdf:function(t,n,r){if(1e-14>l.abs(r))return e.studentt.cdf(t,n);var o=!1;t<0&&(o=!0,r=-r);for(var i=e.normal.cdf(-r,0,1),a=1e-14+1,s=1e-14+1,u=t*t/(t*t+n),c=0,d=l.exp(-r*r/2),f=l.exp(-r*r/2-.5*l.log(2)-e.gammaln(1.5))*r;c<200||s>1e-14||a>1e-14;)s=a,c>0&&(d*=r*r/(2*c),f*=r*r/(2*(c+.5))),i+=.5*(a=d*e.beta.cdf(u,c+.5,n/2)+f*e.beta.cdf(u,c+1,n/2)),c++;return o?1-i:i}}),e.extend(e.normal,{pdf:function(e,t,n){return l.exp(-.5*l.log(2*l.PI)-l.log(n)-l.pow(e-t,2)/(2*n*n))},cdf:function(t,n,r){return .5*(1+e.erf((t-n)/l.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*l.pow(t,n)/l.pow(e,n+1)},cdf:function(e,t,n){return e<t?0:1-l.pow(t/e,n)},inv:function(e,t,n){return t/l.pow(1-e,1/n)},mean:function(e,t){if(!(t<=1))return t*l.pow(e,t)/(t-1)},median:function(e,t){return e*(t*l.SQRT2)},mode:function(e){return e},variance:function(e,t){if(!(t<=2))return e*e*t/(l.pow(t-1,2)*(t-2))}}),e.extend(e.studentt,{pdf:function(t,n){return n=n>1e100?1e100:n,1/(l.sqrt(n)*e.betafn(.5,n/2))*l.pow(1+t*t/n,-((n+1)/2))},cdf:function(t,n){var r=n/2;return e.ibeta((t+l.sqrt(t*t+n))/(2*l.sqrt(t*t+n)),r,r)},inv:function(t,n){var r=e.ibetainv(2*l.min(t,1-t),.5*n,.5);return r=l.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()*l.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*l.pow(e/t,n-1)*l.exp(-l.pow(e/t,n))},cdf:function(e,t,n){return e<0?0:1-l.exp(-l.pow(e/t,n))},inv:function(e,t,n){return t*l.pow(-l.log(1-e),1/n)},mean:function(t,n){return t*e.gammafn(1+1/n)},median:function(e,t){return e*l.pow(l.log(2),1/t)},mode:function(e,t){return t<=1?0:e*l.pow((t-1)/t,1/t)},sample:function(t,n){return t*l.pow(-l.log(e._random_fn()),1/n)},variance:function(t,n){return t*t*e.gammafn(1+2/n)-l.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 l.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)*l.pow(r,t)*l.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,i=(t=l.floor(t))+1,a=n-t,s=i+a,c=l.exp(e.gammaln(s)-e.gammaln(a)-e.gammaln(i)+i*l.log(r)+a*l.log(1-r));return o=r<(i+1)/(s+2)?c*u(r,i,a,1e-10):1-c*u(1-r,a,i,1e-10),l.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)*l.pow(1-r,t)*l.pow(r,n))},cdf:function(t,n,r){var o=0,i=0;if(t<0)return 0;for(;i<=t;i++)o+=e.negbin.pdf(i,n,r);return o}}),e.extend(e.hypgeom,{pdf:function(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 i=1,a=0,s=0;s<t;s++){for(;i>1&&a<o;)i*=1-r/(n-a),a++;i*=(o-s)*(r-s)/((s+1)*(n-r-o+s+1))}for(;a<o;a++)i*=1-r/(n-a);return l.min(1,l.max(0,i))},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 i=1,a=1,s=0,u=0;u<t;u++){for(;i>1&&s<o;){var c=1-r/(n-s);a*=c,i*=c,s++}a*=(o-u)*(r-u)/((u+1)*(n-r-o+u+1)),i+=a}for(;s<o;s++)i*=1-r/(n-s);return l.min(1,l.max(0,i))}}),e.extend(e.poisson,{pdf:function(t,n){return n<0||t%1!=0||t<0?0:l.pow(n,t)*l.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=l.exp(-t);do r++,n*=e._random_fn();while(n>o);return r-1},sampleLarge:function(t){var n,r,o,i,a,s,u,c,d,f;for(i=l.sqrt(t),a=l.log(t),s=-.059+.02483*(u=.931+2.53*i),c=1.1239+1.1328/(u-3.4),d=.9277-3.6224/(u-2);;){if(r=l.random()-.5,o=l.random(),f=.5-l.abs(r),n=l.floor((2*s/f+u)*r+t+.43),f>=.07&&o<=d)return n;if(!(n<0)&&(!(f<.013)||!(o>f))&&l.log(o)+l.log(c)-l.log(s/(f*f)+u)<=-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?l.pow(e-t,2)/((n-t)*(r-t)):1-l.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)*l.sqrt((r-t)/(n-t)*e):t+(n-t)*(1-l.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-l.sqrt((t-e)*(t-n))/l.sqrt(2):n>(e+t)/2?e+l.sqrt((t-e)*(n-e))/l.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+l.sqrt(o*(n-t)*(r-t)):n-l.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/l.PI*l.pow(l.pow(n-t,2)-l.pow(2*e-t-n,2),-.5)},cdf:function(e,t,n){return e<t?0:e<n?2/l.PI*l.asin(l.sqrt((e-t)/(n-t))):1},inv:function(e,t,n){return t+(.5-.5*l.cos(l.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*l.sin(2*l.PI*e.uniform.sample(0,1))},variance:function(e,t){return t<=e?NaN:l.pow(t-e,2)/8}}),e.extend(e.laplace,{pdf:function(e,t,n){return n<=0?0:l.exp(-l.abs(e-t)/n)/(2*n)},cdf:function(e,t,n){return n<=0?0:e<t?.5*l.exp((e-t)/n):1-.5*l.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/l.abs(r))*l.log(1-2*l.abs(r))}}),e.extend(e.tukey,{cdf:function(t,n,r){var o=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],i=[.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,s=a*l.log(r)-r*l.log(2)-e.gammaln(a),u=a-1,d=.25*r;p=r<=100?1:r<=800?.5:r<=5e3?.25:.125,s+=l.log(p);for(var f=0,m=1;m<=50;m++){for(var p,h,g,v=0,y=(2*m-1)*p,x=1;x<=16;x++)if(8<x?(h=x-8-1,g=s+u*l.log(y+o[h]*p)-(o[h]*p+y)*d):(h=x-1,g=s+u*l.log(y-o[h]*p)+(o[h]*p-y)*d),g>=-30){v+=c(8<x?t*l.sqrt((o[h]*p+y)*.5):t*l.sqrt((-(o[h]*p)+y)*.5),1,n)*i[h]*l.exp(g)}if(m*p>=1&&v<=1e-14)break;f+=v}if(v>1e-14)throw Error("tukey.cdf failed to converge");return f>1&&(f=1),f},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,i,a,s,u,c,d=(a=.5-.5*t,u=(s=l.sqrt(l.log(1/(a*a))))+((((-453642210148e-16*s+-.204231210125)*s+-.342242088547)*s+-1)*s+.322232421088)/((((.0038560700634*s+.10353775285)*s+.531103462366)*s+.588581570495)*s+.099348462606),r<120&&(u+=(u*u*u+u)/r/4),c=.8832-.2368*u,r<120&&(c+=-1.214/r+1.208*u/r),u*(c*l.log(n-1)+1.4142)),f=e.tukey.cdf(d,n,r)-t;o=f>0?l.max(0,d-1):d+1;for(var m=e.tukey.cdf(o,n,r)-t,p=1;p<50;p++)if(i=o-m*(o-d)/(m-f),f=m,d=o,i<0&&(i=0,m=-t),m=e.tukey.cdf(i,n,r)-t,o=i,1e-4>l.abs(o-d))return i;throw Error("tukey.inv failed to converge")}}),function(e,t){var n,r,o=Array.prototype.push,i=e.utils.isArray;function l(t){return i(t)||t instanceof e}e.extend({add:function(t,n){return l(n)?(l(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 l(n)?(l(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 l(n)?(l(n[0])||(n=[n]),e.multiply(t,e.inv(n))):e.map(t,function(e){return e/n})},multiply:function(t,n){var r,o,i,a,s,u,c,d;if(void 0===t.length&&void 0===n.length)return t*n;if(s=t.length,u=t[0].length,c=e.zeros(s,i=l(n)?n[0].length:u),d=0,l(n)){for(;d<i;d++)for(r=0;r<s;r++){for(o=0,a=0;o<u;o++)a+=t[r][o]*n[o][d];c[r][d]=a}return 1===s&&1===d?c[0][0]:c}return e.map(t,function(e){return e*n})},outer:function(t,n){return e.multiply(t.map(function(e){return[e]}),[n])},dot:function(t,n){l(t[0])||(t=[t]),l(n[0])||(n=[n]);for(var r,o,i=1===t[0].length&&1!==t.length?e.transpose(t):t,a=1===n[0].length&&1!==n.length?e.transpose(n):n,s=[],u=0,c=i.length,d=i[0].length;u<c;u++){for(o=0,s[u]=[],r=0;o<d;o++)r+=i[u][o]*a[u][o];s[u]=r}return 1===s.length?s[0]:s},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),l(e[0])&&(e=e[0]);o<e.length;o++)r+=t.pow(t.abs(e[o]),n);return t.pow(r,1/n)},angle:function(n,r){return t.acos(e.dot(n,r)/(e.norm(n)*e.norm(r)))},aug:function(e,t){var n,r=[];for(n=0;n<e.length;n++)r.push(e[n].slice());for(n=0;n<r.length;n++)o.apply(r[n],t[n]);return r},inv:function(t){for(var n,r=t.length,o=t[0].length,i=e.identity(r,o),l=e.gauss_jordan(t,i),a=[],s=0;s<r;s++)for(a[s]=[],n=o;n<l[0].length;n++)a[s][n-o]=l[s][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=[],i=1;i<t.length;i++){o[i-1]=[];for(var l=0;l<t.length;l++)l<r?o[i-1][l]=t[i][l]:l>r&&(o[i-1][l-1]=t[i][l])}var a=r%2?-1:1;n+=e(o)*t[0][r]*a}return n},gauss_elimination:function(n,r){var o,i,l,a,s=0,u=0,c=n.length,d=n[0].length,f=1,m=0,p=[];for(s=0,o=(n=e.aug(n,r))[0].length;s<c;s++){for(i=n[s][s],u=s,a=s+1;a<d;a++)i<t.abs(n[a][s])&&(i=n[a][s],u=a);if(u!=s)for(a=0;a<o;a++)l=n[s][a],n[s][a]=n[u][a],n[u][a]=l;for(u=s+1;u<c;u++)for(f=n[u][s]/n[s][s],a=s;a<o;a++)n[u][a]=n[u][a]-f*n[s][a]}for(s=c-1;s>=0;s--){for(m=0,u=s+1;u<=c-1;u++)m+=p[u]*n[s][u];p[s]=(n[s][o-1]-m)/n[s][s]}return p},gauss_jordan:function(n,r){var o,i,l,a=e.aug(n,r),s=a.length,u=a[0].length,c=0;for(i=0;i<s;i++){var d=i;for(l=i+1;l<s;l++)t.abs(a[l][i])>t.abs(a[d][i])&&(d=l);var f=a[i];for(a[i]=a[d],a[d]=f,l=i+1;l<s;l++)for(c=a[l][i]/a[i][i],o=i;o<u;o++)a[l][o]-=a[i][o]*c}for(i=s-1;i>=0;i--){for(l=0,c=a[i][i];l<i;l++)for(o=u-1;o>i-1;o--)a[l][o]-=a[i][o]*a[l][i]/c;for(a[i][i]/=c,o=s;o<u;o++)a[i][o]/=c}return a},triaUpSolve:function(t,n){var r,o=t[0].length,i=e.zeros(1,o)[0],l=!1;return(void 0!=n[0].length&&(n=n.map(function(e){return e[0]}),l=!0),e.arange(o-1,-1,-1).forEach(function(l){r=e.arange(l+1,o).map(function(e){return i[e]*t[l][e]}),i[l]=(n[l]-e.sum(r))/t[l][l]}),l)?i.map(function(e){return[e]}):i},triaLowSolve:function(t,n){var r,o=t[0].length,i=e.zeros(1,o)[0],l=!1;return(void 0!=n[0].length&&(n=n.map(function(e){return e[0]}),l=!0),e.arange(o).forEach(function(o){r=e.arange(o).map(function(e){return t[o][e]*i[e]}),i[o]=(n[o]-e.sum(r))/t[o][o]}),l)?i.map(function(e){return[e]}):i},lu:function(t){var n,r=t.length,o=e.identity(r),i=e.zeros(t.length,t[0].length);return e.arange(r).forEach(function(e){i[0][e]=t[0][e]}),e.arange(1,r).forEach(function(l){e.arange(l).forEach(function(r){n=e.arange(r).map(function(e){return o[l][e]*i[e][r]}),o[l][r]=(t[l][r]-e.sum(n))/i[r][r]}),e.arange(l,r).forEach(function(r){n=e.arange(l).map(function(e){return o[l][e]*i[e][r]}),i[l][r]=t[n.length][r]-e.sum(n)})}),[o,i]},cholesky:function(n){var r,o=n.length,i=e.zeros(n.length,n[0].length);return e.arange(o).forEach(function(l){r=e.arange(l).map(function(e){return t.pow(i[l][e],2)}),i[l][l]=t.sqrt(n[l][l]-e.sum(r)),e.arange(l+1,o).forEach(function(t){r=e.arange(l).map(function(e){return i[l][e]*i[t][e]}),i[t][l]=(n[l][t]-e.sum(r))/i[l][l]})}),i},gauss_jacobi:function(n,r,o,i){for(var l,a,s,u,c=0,d=0,f=n.length,m=[],p=[],h=[];c<f;c++)for(d=0,m[c]=[],p[c]=[],h[c]=[];d<f;d++)c>d?(m[c][d]=n[c][d],p[c][d]=h[c][d]=0):c<d?(p[c][d]=n[c][d],m[c][d]=h[c][d]=0):(h[c][d]=n[c][d],m[c][d]=p[c][d]=0);for(s=e.multiply(e.multiply(e.inv(h),e.add(m,p)),-1),a=e.multiply(e.inv(h),r),l=o,u=e.add(e.multiply(s,o),a),c=2;t.abs(e.norm(e.subtract(u,l)))>i;)l=u,u=e.add(e.multiply(s,l),a),c++;return u},gauss_seidel:function(n,r,o,i){for(var l,a,s,u,c,d=0,f=n.length,m=[],p=[],h=[];d<f;d++)for(l=0,m[d]=[],p[d]=[],h[d]=[];l<f;l++)d>l?(m[d][l]=n[d][l],p[d][l]=h[d][l]=0):d<l?(p[d][l]=n[d][l],m[d][l]=h[d][l]=0):(h[d][l]=n[d][l],m[d][l]=p[d][l]=0);for(u=e.multiply(e.multiply(e.inv(e.add(h,m)),p),-1),s=e.multiply(e.inv(e.add(h,m)),r),a=o,c=e.add(e.multiply(u,o),s),d=2;t.abs(e.norm(e.subtract(c,a)))>i;)a=c,c=e.add(e.multiply(u,a),s),d+=1;return c},SOR:function(n,r,o,i,l){for(var a,s,u,c,d,f=0,m=n.length,p=[],h=[],g=[];f<m;f++)for(a=0,p[f]=[],h[f]=[],g[f]=[];a<m;a++)f>a?(p[f][a]=n[f][a],h[f][a]=g[f][a]=0):f<a?(h[f][a]=n[f][a],p[f][a]=g[f][a]=0):(g[f][a]=n[f][a],p[f][a]=h[f][a]=0);for(c=e.multiply(e.inv(e.add(g,e.multiply(p,l))),e.subtract(e.multiply(g,1-l),e.multiply(h,l))),u=e.multiply(e.multiply(e.inv(e.add(g,e.multiply(p,l))),r),l),s=o,d=e.add(e.multiply(c,o),u),f=2;t.abs(e.norm(e.subtract(d,s)))>i;)s=d,d=e.add(e.multiply(c,s),u),f++;return d},householder:function(n){for(var r,o,i,l,a=n.length,s=n[0].length,u=0,c=[],d=[];u<a-1;u++){for(r=0,l=u+1;l<s;l++)r+=n[l][u]*n[l][u];for(r=(n[u+1][u]>0?-1:1)*t.sqrt(r),o=t.sqrt((r*r-n[u+1][u]*r)/2),(c=e.zeros(a,1))[u+1][0]=(n[u+1][u]-r)/(2*o),i=u+2;i<a;i++)c[i][0]=n[i][u]/(2*o);d=e.subtract(e.identity(a,s),e.multiply(e.multiply(c,e.transpose(c)),2)),n=e.multiply(d,e.multiply(n,d))}return n},QR:(n=e.sum,r=e.arange,function(o){var i,l,a,s=o.length,u=o[0].length,c=e.zeros(u,u);for(l=0,o=e.copy(o);l<u;l++){for(i=0,c[l][l]=t.sqrt(n(r(s).map(function(e){return o[e][l]*o[e][l]})));i<s;i++)o[i][l]=o[i][l]/c[l][l];for(a=l+1;a<u;a++)for(i=0,c[l][a]=n(r(s).map(function(e){return o[e][l]*o[e][a]}));i<s;i++)o[i][a]=o[i][a]-o[i][l]*c[l][a]}return[o,c]}),lstsq:function(t,n){var r,o,i,l=!1;void 0===n[0].length&&(n=n.map(function(e){return[e]}),l=!0);var a=e.QR(t),s=a[0],u=a[1],c=t[0].length,d=e.slice(s,{col:{end:c}}),f=(r=e.slice(u,{row:{end:c}}),o=(r=e.copy(r)).length,i=e.identity(o),e.arange(o-1,-1,-1).forEach(function(t){e.sliceAssign(i,{row:t},e.divide(e.slice(i,{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),l=e.slice(r,{row:n}),a=e.multiply(e.slice(r,{row:t}),o);e.sliceAssign(r,{row:n},e.add(l,a));var s=e.slice(i,{row:n}),u=e.multiply(e.slice(i,{row:t}),o);e.sliceAssign(i,{row:n},e.add(s,u))})}),i),m=e.transpose(d);void 0===m[0].length&&(m=[m]);var p=e.multiply(e.multiply(f,m),n);return(void 0===p.length&&(p=[[p]]),l)?p.map(function(e){return e[0]}):p},jacobi:function(n){for(var r,o,i,l,a,s,u,c=1,d=n.length,f=e.identity(d,d),m=[];1===c;){for(r=0,a=n[0][1],i=0,l=1;r<d;r++)for(o=0;o<d;o++)r!=o&&a<t.abs(n[r][o])&&(a=t.abs(n[r][o]),i=r,l=o);for(r=1,s=n[i][i]===n[l][l]?n[i][l]>0?t.PI/4:-t.PI/4:t.atan(2*n[i][l]/(n[i][i]-n[l][l]))/2,(u=e.identity(d,d))[i][i]=t.cos(s),u[i][l]=-t.sin(s),u[l][i]=t.sin(s),u[l][l]=t.cos(s),f=e.multiply(f,u),n=e.multiply(e.multiply(e.inv(u),n),u),c=0;r<d;r++)for(o=1;o<d;o++)r!=o&&t.abs(n[r][o])>.001&&(c=1)}for(r=0;r<d;r++)m.push(n[r][r]);return[f,m]},rungekutta:function(e,t,n,r,o,i){var l,a,s,u;if(2===i)for(;r<=n;)l=t*e(r,o),a=t*e(r+t,o+l),o+=(l+a)/2,r+=t;if(4===i)for(;r<=n;)l=t*e(r,o),a=t*e(r+t/2,o+l/2),s=t*e(r+t/2,o+a/2),u=t*e(r+t,o+s),o+=(l+2*a+2*s+u)/6,r+=t;return o},romberg:function(e,n,r,o){for(var i,l,a,s,u,c=0,d=(r-n)/2,f=[],m=[],p=[];c<o/2;){for(u=e(n),a=n,s=0;a<=r;a+=d,s++)f[s]=a;for(a=1,i=f.length;a<i-1;a++)u+=(a%2!=0?4:2)*e(f[a]);u=d/3*(u+e(r)),p[c]=u,d/=2,c++}for(l=p.length,i=1;1!==l;){for(a=0;a<l-1;a++)m[a]=(t.pow(4,i)*p[a+1]-p[a])/(t.pow(4,i)-1);l=m.length,p=m,m=[],i++}return p},richardson:function(e,n,r,o){function i(e,t){for(var n,r=0,o=e.length;r<o;r++)e[r]===t&&(n=r);return n}for(var l,a,s,u,c,d=t.abs(r-e[i(e,r)+1]),f=0,m=[],p=[];o>=d;)l=i(e,r+o),a=i(e,r),m[f]=(n[l]-2*n[a]+n[2*a-l])/(o*o),o/=2,f++;for(u=m.length,s=1;1!=u;){for(c=0;c<u-1;c++)p[c]=(t.pow(4,s)*m[c+1]-m[c])/(t.pow(4,s)-1);u=p.length,m=p,p=[],s++}return m},simpson:function(e,t,n,r){for(var o,i=(n-t)/r,l=e(t),a=[],s=t,u=0,c=1;s<=n;s+=i,u++)a[u]=s;for(o=a.length;c<o-1;c++)l+=(c%2!=0?4:2)*e(a[c]);return i/3*(l+e(n))},hermite:function(e,t,n,r){for(var o,i=e.length,l=0,a=0,s=[],u=[],c=[],d=[];a<i;a++){for(o=0,s[a]=1;o<i;o++)a!=o&&(s[a]*=(r-e[o])/(e[a]-e[o]));for(o=0,u[a]=0;o<i;o++)a!=o&&(u[a]+=1/(e[a]-e[o]));c[a]=(1-2*(r-e[a])*u[a])*(s[a]*s[a]),d[a]=(r-e[a])*(s[a]*s[a]),l+=c[a]*t[a]+d[a]*n[a]}return l},lagrange:function(e,t,n){for(var r,o,i=0,l=0,a=e.length;l<a;l++){for(r=0,o=t[l];r<a;r++)l!=r&&(o*=(n-e[r])/(e[l]-e[r]));i+=o}return i},cubic_spline:function(t,n,r){for(var o,i=t.length,l=0,a=[],s=[],u=[],c=[],d=[],f=[],m=[];l<i-1;l++)d[l]=t[l+1]-t[l];for(l=1,u[0]=0;l<i-1;l++)u[l]=3/d[l]*(n[l+1]-n[l])-3/d[l-1]*(n[l]-n[l-1]);for(l=1;l<i-1;l++)a[l]=[],s[l]=[],a[l][l-1]=d[l-1],a[l][l]=2*(d[l-1]+d[l]),a[l][l+1]=d[l],s[l][0]=u[l];for(o=0,c=e.multiply(e.inv(a),s);o<i-1;o++)f[o]=(n[o+1]-n[o])/d[o]-d[o]*(c[o+1][0]+2*c[o][0])/3,m[o]=(c[o+1][0]-c[o][0])/(3*d[o]);for(o=0;o<i&&!(t[o]>r);o++);return n[o-=1]+(r-t[o])*f[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,i=t[0].length,l=0,a=[],s=[],u=[],c=[],d=[],f=[],m=[],p=[],h=[],g=[];for(l=0;l<o;l++)a[l]=e.sum(t[l])/i;for(l=0;l<i;l++)for(n=0,m[l]=[];n<o;n++)m[l][n]=t[n][l]-a[n];for(l=0,m=e.transpose(m);l<o;l++)for(n=0,p[l]=[];n<o;n++)p[l][n]=e.dot([m[l]],[m[n]])/(i-1);for(l=0,h=(u=e.jacobi(p))[0],s=u[1],g=e.transpose(h);l<s.length;l++)for(n=l;n<s.length;n++)s[l]<s[n]&&(r=s[l],s[l]=s[n],s[n]=r,c=g[l],g[l]=g[n],g[n]=c);for(l=0,f=e.transpose(m);l<o;l++)for(n=0,d[l]=[];n<f.length;n++)d[l][n]=e.dot([g[l]],[f[n]]);return[t,s,g,d]}});for(var a="add divide multiply subtract dot pow exp log abs norm angle".split(" "),s=0;s<a.length;s++)!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[s])}(e,Math);var d=Math,f=[].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)/d.sqrt(o*(1-o)*(1/t+1/r))}return e.extend({zscore:function(){var t=f.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=f.call(arguments);return p(n[1])?(t=e.zscore(n[0],n[1],n[3]),1===n[2]?e.normal.cdf(-d.abs(t),0,1):2*e.normal.cdf(-d.abs(t),0,1)):n.length>2?(t=e.zscore(n[0],n[1],n[2]),1===n[3]?e.normal.cdf(-d.abs(t),0,1):2*e.normal.cdf(-d.abs(t),0,1)):(t=n[0],1===n[1]?e.normal.cdf(-d.abs(t),0,1):2*e.normal.cdf(-d.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=d.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=f.call(arguments);return 4===t.length?(t[0]-t[1])/(t[2]/d.sqrt(t[3])):(t[0]-e.mean(t[1]))/(e.stdev(t[1],!0)/d.sqrt(t[1].length))},ttest:function(){var t,n=f.call(arguments);return 5===n.length?(t=d.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=d.abs(n[0]),1==n[2]?e.studentt.cdf(-t,n[1]-1):2*e.studentt.cdf(-t,n[1]-1)):(t=d.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)/d.sqrt(this.cols()))},ttest:function(t,n){return 1===n?1-e.studentt.cdf(d.abs(this.tscore(t)),this.cols()-1):2*e.studentt.cdf(-d.abs(this.tscore(t)),this.cols()-1)}}),e.extend({anovafscore:function(){var t,n,r,o,i,l,a,s,u=f.call(arguments);if(1===u.length){for(a=0,i=Array(u[0].length);a<u[0].length;a++)i[a]=u[0][a];u=i}for(a=0,n=[];a<u.length;a++)n=n.concat(u[a]);for(a=0,r=e.mean(n),t=0;a<u.length;a++)t+=u[a].length*d.pow(e.mean(u[a])-r,2);for(t/=u.length-1,l=0,a=0;a<u.length;a++)for(s=0,o=e.mean(u[a]);s<u[a].length;s++)l+=d.pow(u[a][s]-o,2);return t/(l/=n.length-u.length)},anovaftest:function(){var t,n,r,o,i=f.call(arguments);if(m(i[0]))return 1-e.centralF.cdf(i[0],i[1],i[2]);var l=e.anovafscore(i);for(o=0,t=i.length-1,r=0;o<i.length;o++)r+=i[o].length;return n=r-t-1,1-e.centralF.cdf(l,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,i,l=f.call(arguments);return m(l[0])?(t=l[0],n=l[1],r=l[2],o=l[3],i=l[4]):(t=e.mean(l[0]),n=e.mean(l[1]),r=l[0].length,o=l[1].length,i=l[2]),d.abs(t-n)/(i*d.sqrt((1/r+1/o)/2))},qtest:function(){var t,n=f.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),i=[],l=0;l<t.length;++l)for(var a=l+1;a<t.length;++a){var s=e.qtest(r[l],r[a],t[l].length,t[a].length,n,o,t.length);i.push([[l,a],s])}return i}}),e.extend({normalci:function(){var t,n=f.call(arguments),r=[,,];return t=4===n.length?d.abs(e.normal.inv(n[1]/2,0,1)*n[2]/d.sqrt(n[3])):d.abs(e.normal.inv(n[1]/2,0,1)*e.stdev(n[2])/d.sqrt(n[2].length)),r[0]=n[0]-t,r[1]=n[0]+t,r},tci:function(){var t,n=f.call(arguments),r=[,,];return t=4===n.length?d.abs(e.studentt.inv(n[1]/2,n[3]-1)*n[2]/d.sqrt(n[3])):d.abs(e.studentt.inv(n[1]/2,n[2].length-1)*e.stdev(n[2],!0)/d.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 i=h(t,n,r,o);return e.ztest(i,1)},twoSidedDifferenceOfProportions:function(t,n,r,o){var i=h(t,n,r,o);return e.ztest(i,2)}}),e.models=function(){function t(t,n){var r=t.length,o=n[0].length-1,i=e.lstsq(n,t),l=e.multiply(n,i.map(function(e){return[e]})).map(function(e){return e[0]}),a=e.subtract(t,l),s=e.mean(t),u=e.sum(l.map(function(e){return Math.pow(e-s,2)})),c=e.sum(t.map(function(e,t){return Math.pow(e-l[t],2)})),d=u+c;return{exog:n,endog:t,nobs:r,df_model:o,df_resid:r-o-1,coef:i,predict:l,resid:a,ybar:s,SST:d,SSE:u,SSR:c,R2:u/d}}return{ols:function(n,r){var o,i,l,a,s,u,c,d,f,m,p,h,g,v,y=t(n,r),x=(i=(o=y.exog)[0].length,l=e.arange(i).map(function(n){var r=e.arange(i).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),s=l.map(function(e){return a/Math.sqrt(e.SST*(1-e.R2))}),c=(u=y.coef.map(function(e,t){return(e-0)/s[t]})).map(function(t){var n=e.studentt.cdf(t,y.df_resid);return(n>.5?1-n:n)*2}),d=e.studentt.inv(.975,y.df_resid),f=y.coef.map(function(e,t){var n=d*s[t];return[e-n,e+n]}),{se:s,t:u,p:c,sigmaHat:a,interval95:f}),C=(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}),b=1-(1-y.R2)*((y.nobs-1)/y.df_resid);return y.t=x,y.f=C,y.adjust_R2=b,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,i,l,a;if(t.cols()==n.rows()){if(n.rows()>1){for(r=0,l=[];r<t.rows();r++)for(o=0,l[r]=[];o<n.cols();o++){for(i=0,a=0;i<t.cols();i++)a+=t.toArray()[r][i]*n.toArray()[i][o];l[r][o]=a}return e(l)}for(r=0,l=[];r<t.rows();r++)for(o=0,l[r]=[];o<n.cols();o++){for(i=0,a=0;i<t.cols();i++)a+=t.toArray()[r][i]*n.toArray()[o];l[r][o]=a}return e(l)}},regress:function(t,n){var r=e.xtranspxinv(t),o=t.transpose(),i=e.matrixmult(e(r),o);return e.matrixmult(i,n)},regresst:function(t,n,r){var o,i,l,a=e.regress(t,n),s={};s.anova={};var u=e.jMatYBar(t,a);s.yBar=u;var c=n.mean();s.anova.residuals=e.residuals(n,u),s.anova.ssr=e.ssr(u,c),s.anova.msr=s.anova.ssr/(t[0].length-1),s.anova.sse=e.sse(n,u),s.anova.mse=s.anova.sse/(n.length-(t[0].length-1)-1),s.anova.sst=e.sst(n,c),s.anova.mst=s.anova.sst/(n.length-1),s.anova.r2=1-s.anova.sse/s.anova.sst,s.anova.r2<0&&(s.anova.r2=0),s.anova.fratio=s.anova.msr/s.anova.mse,s.anova.pvalue=e.anovaftest(s.anova.fratio,t[0].length-1,n.length-(t[0].length-1)-1),s.anova.rmse=Math.sqrt(s.anova.mse),s.anova.r2adj=1-s.anova.mse/s.anova.mst,s.anova.r2adj<0&&(s.anova.r2adj=0),s.stats=Array(t[0].length);for(var d=e.xtranspxinv(t),f=0;f<a.length;f++)o=Math.sqrt(s.anova.mse*Math.abs(d[f][f])),i=Math.abs(a[f]/o),l=e.ttest(i,n.length-t[0].length-1,r),s.stats[f]=[a[f],o,i,l];return s.regress=a,s},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 i=0;i<t[o].length;i++)r[o][i]=t[o][i]-n[o][i]}return e(r)}}),e.jStat=e,e}()},296(e,t,n){var r=n(137),o=n(344),i=n(14),l=n(364),a=n(394),s=n(380),u=n(320);u.alea=r,u.xor128=o,u.xorwow=i,u.xorshift7=l,u.xor4096=a,u.tychei=s,e.exports=u},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),i=t&&t.state,l=o.next;return l.int32=function(){return 0x100000000*o.next()|0},l.double=function(){return l()+(2097152*l()|0)*11102230246251565e-32},l.quick=l,i&&("object"==typeof i&&r(i,o),l.state=function(){return r(o,{})}),l}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),i=t&&t.state,l=function(){return(o.next()>>>0)/0x100000000};return l.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},l.int32=o.next,l.quick=l,i&&("object"==typeof i&&r(i,o),l.state=function(){return r(o,{})}),l}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),i=t&&t.state,l=function(){return(o.next()>>>0)/0x100000000};return l.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},l.int32=o.next,l.quick=l,i&&("object"==typeof i&&r(i,o),l.state=function(){return r(o,{})}),l}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,i=t.i;return t.w=r=r+0x61c88647|0,n=o[i+34&127],e=o[i=i+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=o[i]=n^e,t.i=i,n+(r^r>>>16)|0},!function(e,t){var n,r,o,i,l,a=[],s=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,s=Math.max(s,t.length)),o=0,i=-32;i<s;++i)t&&(r^=t.charCodeAt((i+32)%t.length)),0===i&&(l=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,i>=0&&(l=l+0x61c88647|0,o=0==(n=a[127&i]^=r+l)?o+1:0);for(o>=128&&(a[127&(t&&t.length||0)]=-1),o=127,i=512;i>0;--i)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=l,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),i=t&&t.state,l=function(){return(o.next()>>>0)/0x100000000};return l.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},l.int32=o.next,l.quick=l,i&&(i.X&&r(i,o),l.state=function(){return r(o,{})}),l}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),i=t&&t.state,l=function(){return(o.next()>>>0)/0x100000000};return l.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},l.int32=o.next,l.quick=l,i&&(i.x&&r(i,o),l.state=function(){return r(o,{})}),l}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),i=t&&t.state,l=function(){return(o.next()>>>0)/0x100000000};return l.double=function(){do var e=((o.next()>>>11)+(o.next()>>>0)/0x100000000)/2097152;while(0===e);return e},l.int32=o.next,l.quick=l,i&&("object"==typeof i&&r(i,o),l.state=function(){return r(o,{})}),l}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 i,l="random",a=o.pow(256,6),s=o.pow(2,52),u=2*s;function c(e,n,c){var h=[],g=m(function e(t,n){var r,o=[],i=typeof t;if(n&&"object"==i)for(r in t)try{o.push(e(t[r],n-1))}catch(e){}return o.length?o:"string"==i?t:t+"\0"}((n=!0==n?{entropy:!0}:n||{}).entropy?[e,p(r)]:null==e?function(){try{var e;return i&&(e=i.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 d(h),y=function(){for(var e=v.g(6),t=a,n=0;e<s;)e=(e+n)*256,t*=256,n=v.g(1);for(;e>=u;)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&&f(r,v),e.state=function(){return f(v,{})}),n)?(o[l]=e,t):e})(y,g,"global"in n?n.global:this==o,n.state)}function d(e){var t,n=e.length,r=this,o=0,i=r.i=r.j=0,l=r.S=[];for(n||(e=[n++]);o<256;)l[o]=o++;for(o=0;o<256;o++)l[o]=l[i=255&i+e[o%n]+(t=l[o])],l[i]=t;(r.g=function(e){for(var t,n=0,o=r.i,i=r.j,l=r.S;e--;)t=l[o=255&o+1],n=256*n+l[255&(l[o]=l[i=255&i+t])+(l[i]=t)];return r.i=o,r.j=i,n})(256)}function f(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{i=n(562)}catch(e){}}else"function"==typeof define&&define.amd?define(function(){return c}):o["seed"+l]=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,i,l;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]})),i=void 0!==t.mxr&&void 0!==t.hs&&void 0!==t.poi&&void 0!==t.mnr,l={points:o,fitFunction:r.Qx,showFitLine:!0,showPoints:"points",clickToToggle:!0,name:t.rdt?`${t.rdt}`:"Dose-Response",droplines:["IC50"]},i&&(l.parameters=[t.mxr,t.hs,t.poi,t.mnr]),{chartOptions:{xAxisName:t.xu,yAxisName:t.yu,logX:!0},series:[l]}))}},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),i=n(590);let l="xAxis",a="yAxis";function s(e,t){var n;return(null==e||null==(n=e.getAttribute(t))?void 0:n.toLowerCase())==="true"}function u(e){var t,n,l;let a=null==(n=e.getElementsByTagName("params")[0])||null==(t=n.childNodes[0].nodeValue)?void 0:t.split(",").map(Number),u=null==(l=e.getElementsByTagName("function")[0])?void 0:l.getAttribute("type"),c=u&&"sigif"!==u&&u in o.rT?u:i.G7,d=e.getElementsByTagName("settings")[0].getAttribute("markerColor"),f=e.getElementsByTagName("settings")[0].getAttribute("color"),m=s(e.getElementsByTagName("settings")[0],"drawLine"),p={name:e.getAttribute("name"),fitFunction:c,markerType:r.MARKER_TYPE.CIRCLE,pointColor:d,fitLineColor:f,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,i;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(l)[0].getAttribute("min"),minY:+n.getElementsByTagName(a)[0].getAttribute("min"),maxX:+n.getElementsByTagName(l)[0].getAttribute("max"),maxY:+n.getElementsByTagName(a)[0].getAttribute("max"),xAxisName:r.getAttribute("xLabel"),yAxisName:r.getAttribute("yLabel"),logX:s(r,"logX")},null!==r.getAttribute("logY")?{logY:s(r,"logY")}:{}),{chartOptions:o,seriesOptions:u((i=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(","),i=null==(n=e.getElementsByTagName("y")[0].childNodes[0].nodeValue)?void 0:n.split(","),l=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:+i[e],outlier:"0"===l[e]};return a}(e),n=u(e),r={points:t};return Object.assign(r,n),r}(n)}return t}(i)}))}},124(e,t,n){"use strict";n.d(t,{HB:()=>d,XN:()=>m,l8:()=>s,nL:()=>f,p:()=>u});var r=n(82),o=n(788);function i(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}let l=new Map,a=new r.LruCache(2e3);function s(e,t){l.set(e,t)}function u(){var e;return(e=function*(){for(let e of r.Func.find({meta:{role:"curveConverter"}})){let t=e.options.curveFormat;t&&!l.has(t)&&s(t,(yield e.apply()))}},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,s,"next",e)}function s(e){i(l,r,o,a,s,"throw",e)}a(void 0)})})()}function c(e){let t=e.getTag(o.h.TAG_CURVE_FORMAT);return t&&""!==t?t:null}function d(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=l.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 f(e){return null!==c(e)}function m(e){return!f(e)}},1(e,t,n){"use strict";n.d(t,{p:()=>g,w:()=>h});var r=n(590),o=n(82),i=n(328),l=n(389),a=n(991),s=n.n(a),u=n(869);function c(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){c(i,r,o,l,a,"next",e)}function a(e){c(i,r,o,l,a,"throw",e)}l(void 0)})}}let f="Compound|Assay|Target";function m(e){return e.split("||").filter(e=>""!==e&&"null"!==e&&"undefined"!==e).join(" | ")}function p(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)}function h(){let e,t,n,r,a,c,m,h,g,v,y,x,C,b,w,T,O,S,I,P,_,A,N,E,L,F,M=i.shell.tv;if(!M||!M.dataFrame)return void i.shell.warning("No open tableview");let R=null,D=null,X=(e=l.divH([],{style:{alignItems:"center"}}),t=null,n=null,r=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,i;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==(i=n.value)?void 0:i.name)?r:null}:null},applyHistory:e=>{e.wellLevelCol&&e.parentLevelCol&&r&&a&&t&&n&&(t.value=r.col(e.wellLevelCol),n.value=a.col(e.parentLevelCol))},onTableChange:(o,i)=>((o,i)=>{if(l.empty(e),!o||!i){t=null,n=null,r=null,a=null;return}r=o,a=i,t=l.input.column("JOIN",{table:o,nullable:!0,tooltipText:"Column to join on from the well level data"}),n=l.input.column("ON",{table:i,nullable:!0,tooltipText:"Column to join on from the parent level data"});let u=s()(i.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(),r=s()(o.columns.categorical).filter(t=>t.name.toLowerCase().includes(e)).toArray()[0];r&&(t.value=r)}let c=l.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.");l.appendAll(e,[c,t.root,n.root])})(o,i)});w=l.input.table("Well Table",{value:i.shell.tv.dataFrame,nullable:!1,tooltipText:"Table with well level data"}),T=l.form([]),(O=()=>{var e,t,n,r,i,a,u,d;let f=w.value;l.empty(T),(()=>{var e,t,n;return X.onTableChange(null!=(e=null==R||null==(n=R.getValues())?void 0:n.table)?e:null,null!=(t=null==D?void 0:D.getTable())?t:null)})(w.value),c=l.input.column("Assay Name",{table:f,nullable:!0,filter:e=>e.isCategorical,tooltipText:"Column with assay names"}),m=l.input.column("Concentration",{table:f,nullable:!1,filter:e=>e.isNumerical,tooltipText:"Column with concentration values"}),h=l.input.column("Readout",{table:f,nullable:!1,filter:e=>e.isNumerical,tooltipText:"Column with readout values"}),g=l.input.column("Outliers",{table:f,nullable:!0,filter:e=>(e.isCategorical||e.type===o.TYPE.BOOL)&&2===e.categories.length,tooltipText:"Column with outliers to exclude from the analysis"}),v=l.input.column("Compound ID",{table:f,nullable:!0,tooltipText:"Column with compound IDs"}),y=l.input.column("Batch ID",{table:f,nullable:!1,tooltipText:"Column with batch IDs. this column along with the Assay column will be used to group the data into curves"}),x=l.input.column("Run ID",{table:f,nullable:!0,tooltipText:"Column with run IDs. this column along with the Assay column will be used to group the data into curves"}),C=l.input.column("Target Entity",{table:f,nullable:!1,filter:e=>e.isCategorical,tooltipText:"Column with target entity names. This column will be used to group the data into curves"}),b=l.input.columns("Additional Columns",{table:f,nullable:!0,tooltipText:"Additional columns to include in the curves data"}),c.value=null!=(e=s()(f.columns.categorical).find(e=>e.name.toLowerCase().includes("assay")&&e.name.toLowerCase().includes("name")))?e:null,m.value=null!=(t=f.columns.firstWhere(e=>e.isNumerical&&e.type!==o.COLUMN_TYPE.DATE_TIME&&e.name.toLowerCase().includes("concentration")))?t:null,h.value=null!=(n=f.columns.firstWhere(e=>e.isNumerical&&e.type!==o.COLUMN_TYPE.DATE_TIME&&e.name.toLowerCase().includes("inhibition")))?n:null,g.value=null!=(r=f.columns.firstWhere(e=>(e.isCategorical||e.type===o.TYPE.BOOL)&&2===e.categories.length&&(e.name.toLowerCase().includes("outlier")||e.name.toLowerCase().includes("include")&&e.name.toLowerCase().includes("exclude"))))?r:null,v.value=null!=(i=f.columns.firstWhere(e=>e.isCategorical&&e.name.toLowerCase().includes("compound_id")||e.name.toLowerCase().includes("compoundid")||e.name.toLowerCase().includes("compound id")))?i:null,y.value=null!=(a=f.columns.firstWhere(e=>e.name.toLowerCase().includes("batch")&&e.name.toLowerCase().includes("id")))?a:null,x.value=null!=(u=f.columns.firstWhere(e=>(e.name.toLowerCase().includes("run")||e.name.toLowerCase().includes("set"))&&e.name.toLowerCase().includes("id")))?u:null,C.value=null!=(d=f.columns.firstWhere(e=>e.isCategorical&&e.name.toLowerCase().includes("target")&&e.name.toLowerCase().includes("entity")))?d:null,b.value=[],l.appendAll(T,[w.root,c.root,y.root,x.root,m.root,h.root,v.root,C.root,g.root,b.root])})(),w.onChanged.subscribe(()=>O()),R={form:T,getValues:()=>{var e;return{table:w.value,assayCol:c.value,batchIDCol:y.value,concentrationCol:m.value,readoutCol:h.value,compoundIDCol:v.value,excludeOutliersCol:g.value,targetEntityCol:C.value,runIDCol:x.value,additionalColumns:null!=(e=b.value)?e:[]}},applyHistory:e=>{var t;let n=w.value;c.value=e.assayCol?n.col(e.assayCol):null,y.value=e.batchIDCol?n.col(e.batchIDCol):null,m.value=e.concentrationCol?n.col(e.concentrationCol):null,h.value=e.readoutCol?n.col(e.readoutCol):null,v.value=e.compoundIDCol?n.col(e.compoundIDCol):null,g.value=e.excludeOutliersCol?n.col(e.excludeOutliersCol):null,x.value=e.runIDCol?n.col(e.runIDCol):null,C.value=e.targetEntityCol?n.col(e.targetEntityCol):null,b.value=null==(t=e.additionalColumns)?void 0:t.map(e=>n.col(e)).filter(e=>null!=e)}},N=l.input.table("Parent Table",{value:void 0,nullable:!0,tooltipText:"Table with parent data"}),E=l.form([]),L=null,(F=()=>{var e;let t,n,r,i,a,s;if(l.empty(E),E.appendChild(N.root),(()=>{var e,t,n;return X.onTableChange(null!=(e=null==R||null==(n=R.getValues())?void 0:n.table)?e:null,null!=(t=null==D?void 0:D.getTable())?t:null)})(N.value),!N.value){L=null;return}S=l.input.column("Reported IC50",{table:N.value,nullable:!0,tooltipText:"Column with reported IC50 values"}),I=l.input.column("Reported Qualified IC50",{table:N.value,nullable:!0,tooltipText:"Column with reported qualified IC50 values"}),P=l.input.column("Experiment ID",{table:N.value,nullable:!0,tooltipText:"Column with experiment IDs"}),_=l.input.column("Qualifier",{table:N.value,nullable:!0,tooltipText:"Column with qualifier values"}),A=l.input.columns("Additional Columns",{table:N.value,nullable:!0,tooltipText:"Additional columns to include in the curves data"}),p(N.value,S,e=>e.type!==o.COLUMN_TYPE.DATE_TIME,["reported ic50","reported_ic50","reported-ic50"]),p(N.value,I,e=>e.type!==o.COLUMN_TYPE.DATE_TIME,["qualified_reported_ic50","qualified reported ic50","qualified-reported-ic50"]),p(N.value,P,e=>e.isCategorical,["experiment id","experiment_id","experiment-id"]),p(N.value,_,e=>e.isCategorical,["qualifier"]);let c=l.form([S,I,P,_,A]);e=N.value,t=[u.Z2.FOUR_PL_DOSE_RESPONSE,u.Z2.FOUR_PL_REGRESSION],n=l.input.choice("Fit Function",{value:u.Z2.FOUR_PL_DOSE_RESPONSE,items:t,nullable:!1,tooltipText:"Select the fit function to use for the curve fitting"}),r=l.form([]),i=[],(a=l.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)",(s=()=>{l.empty(r);let t=function(e,t){let n=[];switch(t){case u.Z2.FOUR_PL_REGRESSION:case u.Z2.FOUR_PL_DOSE_RESPONSE:default:n.push(l.input.column("Max",{table:e,nullable:!1,tooltipText:"Maximum value for the curve"})),n.push(l.input.column("Hill",{table:e,nullable:!1,tooltipText:"Hill coefficient for the curve"})),n.push(l.input.column("Inflection",{table:e,nullable:!1,tooltipText:"Inflection value for the curve"})),n.push(l.input.column("Min",{table:e,nullable:!1,tooltipText:"Minimum value for the curve"})),p(e,n[0],e=>e.isNumerical&&e.type!==o.COLUMN_TYPE.DATE_TIME,["max"]),p(e,n[1],e=>e.isNumerical&&e.type!==o.COLUMN_TYPE.DATE_TIME,["hill"]),p(e,n[2],e=>e.isNumerical&&e.type!==o.COLUMN_TYPE.DATE_TIME,["inflection"]),p(e,n[3],e=>e.isNumerical&&e.type!==o.COLUMN_TYPE.DATE_TIME,["min"])}return n}(e,n.value);i=t,l.appendAll(r,[n.root,...t.map(e=>e.root)]),a.fireChanged()})(),n.onChanged.subscribe(()=>s()),L={form:r,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)}}},l.appendAll(E,[c,L.form])})(),N.onChanged.subscribe(()=>F()),D={getValue:()=>({fitParamCols:(null==L?void 0:L.getValues)?L.getValues():null,reportedIC50Col:null==S?void 0:S.value,reportedQualifiedIC50Col:null==I?void 0:I.value,experimentIDCol:null==P?void 0:P.value,qualifierCol:null==_?void 0:_.value,additionalColumns:null==A?void 0:A.value,fitFunction:(null==L?void 0:L.getFitFunction)?L.getFitFunction():null}),form:E,getTable:()=>N.value,getHistory:()=>{var e,t,n,r,o,i,l,a,s,u,c,d;return{tableName:null!=(e=null==(l=N.value)?void 0:l.name)?e:null,reportedIC50Col:null!=(t=null==S||null==(a=S.value)?void 0:a.name)?t:null,reportedQualifiedIC50Col:null!=(n=null==I||null==(s=I.value)?void 0:s.name)?n:null,experimentIDCol:null!=(r=null==P||null==(u=P.value)?void 0:u.name)?r:null,qualifierCol:null!=(o=null==_||null==(c=_.value)?void 0:c.name)?o:null,additionalColumns:null!=(i=null==A||null==(d=A.value)?void 0:d.map(e=>e.name))?i:[],fitParams:(null==L?void 0:L.getHystory)?L.getHystory():null}},applyHistory:e=>{if(e.tableName){let t=i.shell.table(e.tableName);t&&(N.value=t)}N.value&&(e.reportedIC50Col&&N.value.col(e.reportedIC50Col)&&(S.value=N.value.col(e.reportedIC50Col)),e.reportedQualifiedIC50Col&&N.value.col(e.reportedQualifiedIC50Col)&&(I.value=N.value.col(e.reportedQualifiedIC50Col)),e.additionalColumns&&(A.value=e.additionalColumns.map(e=>N.value.col(e)).filter(e=>null!=e)),e.experimentIDCol&&N.value.col(e.experimentIDCol)&&(P.value=N.value.col(e.experimentIDCol)),e.qualifierCol&&N.value.col(e.qualifierCol)&&(_.value=N.value.col(e.qualifierCol)),L&&e.fitParams&&L.applyHistory(e.fitParams))}};let Y=l.divH([R.form,D.form],{style:{minWidth:"400px",gap:"20px"}});l.dialog("Data to Curves").add(Y).add(X.form).onOK(()=>d(function*(){var e,t,n,r,l,a,s,u,c,d,m;let p,h=R.getValues(),g=D.getTable(),v=D.getValue(),y=v.fitParamCols;g&&y&&y.length>0&&(p={table:g,fitParamColumns:y,fitFunction:v.fitFunction,reportedIC50Column:v.reportedIC50Col,reportedQualifiedIC50Column:v.reportedQualifiedIC50Col,experimentIDColumn:v.experimentIDCol,qualifierColumn:v.qualifierCol,additionalColumns:null!=(m=v.additionalColumns)?m:[]});let x=X.getValues(),{table:C,assayCol:b,batchIDCol:w,concentrationCol:T,readoutCol:O,compoundIDCol:S,excludeOutliersCol:I,runIDCol:P,targetEntityCol:_,additionalColumns:A}=h,N=o.Func.find({name:"dataToCurves"})[0];if(!N)return void i.shell.error("Function dataToCurves not found");let E=N.prepare({df:C,concentrationCol:T,readoutCol:O,batchIDCol:w,assayCol:b,runIDCol:P,compoundIDCol:S,targetEntityCol:_,excludeOutliersCol:I,wellLevelAdditionalColumns:(null!=A?A:[]).map(e=>null==e?void 0:e.name).filter(e=>!!e),parentTable:null==p?void 0:p.table,fitParamColumns:null!=(e=null==p||null==(n=p.fitParamColumns)?void 0:n.map(e=>e.name))?e:[],reportedIC50Column:null==p||null==(r=p.reportedIC50Column)?void 0:r.name,reportedQualifiedIC50Column:null==p||null==(l=p.reportedQualifiedIC50Column)?void 0:l.name,experimentIDColumn:null==p||null==(a=p.experimentIDColumn)?void 0:a.name,qualifierColumn:null==p||null==(s=p.qualifierColumn)?void 0:s.name,additionalColumns:null!=(t=null==p||null==(u=p.additionalColumns)?void 0:u.map(e=>e.name))?t:[],wellLevelJoinCol:null==x||null==(c=x.wellLevelCol)?void 0:c.name,parentLevelJoinCol:null==x||null==(d=x.parentLevelCol)?void 0:d.name}),L=C.tags[o.Tags.CreationScript]&&(!(null==p?void 0:p.table)||p.table.tags[o.Tags.CreationScript]);yield E.call(void 0,void 0,{processed:!L});let F=E.getResultViews()[0];if(F&&F instanceof o.TableView&&F.dataFrame){L||i.shell.addView(F),F.filters();let e=F.trellisPlot({yColumnNames:[f],xColumnNames:[],viewerType:"MultiCurveViewer",showControlPanel:!1,showXLabels:!1,showYLabels:!1,showXSelectors:!1,showYSelectors:!0,packCategories:!0,onClick:"Select"});F.dockManager.dock(e,o.DOCK_TYPE.TOP,F.dockManager.findNode(F.grid.root),"Fitted Curves",.5);let t=F.addViewer(o.VIEWER.GRID,{rowSource:o.RowSet.FilteredSelected,selectedRowsColor:o.Color.white});F.dockManager.dock(t,o.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}),r=F.dockManager.dock(n,o.DOCK_TYPE.FILL,F.dockManager.findNode(t.root));F.dockManager.dock(F.grid,o.DOCK_TYPE.FILL,r),F.grid.props.title="Fitted Curves"}})()).show().history(()=>{var e,t,n,r;let{assayCol:o,batchIDCol:i,concentrationCol:l,readoutCol:a,compoundIDCol:s,excludeOutliersCol:u,runIDCol:c,targetEntityCol:d,additionalColumns:f}=R.getValues();return{wells:JSON.stringify(null!=(t=Object.fromEntries(Object.entries({assayCol:null==o?void 0:o.name,batchIDCol:null==i?void 0:i.name,concentrationCol:null==l?void 0:l.name,readoutCol:null==a?void 0:a.name,compoundIDCol:null==s?void 0:s.name,excludeOutliersCol:null==u?void 0:u.name,runIDCol:null==c?void 0:c.name,targetEntityCol:null==d?void 0:d.name,additionalColumns:null!=(e=null==f?void 0:f.map(e=>e.name))?e:[]}).filter(([e,t])=>!!t)))?t:{}),parent:JSON.stringify(null!=(n=D.getHistory())?n:{}),join:JSON.stringify(null!=(r=X.getHistory())?r:{})}},e=>{var t,n,r;let o=JSON.parse(null!=(t=null==e?void 0:e.wells)?t:"{}"),i=JSON.parse(null!=(n=null==e?void 0:e.parent)?n:"{}");R.applyHistory(o),D.applyHistory(i);let l=JSON.parse(null!=(r=null==e?void 0:e.join)?r:"{}");X.applyHistory(l)})}function g(e,t,n,l,a,s,u,c,p,h,g,v){return d(function*(){var d,y,x,C,b,w,T,O,S,I,P,_,A,N,E,L,F,M,R;if(!t||!n||!l)throw i.shell.warning("Please fill all required fields"),Error("Please fill all required fields");let D={},X=null==a?void 0:a.categories,Y=null==a?void 0:a.getRawData(),k=t.getRawData(),j=n.getRawData(),G=null==l?void 0:l.categories,B=null==l?void 0:l.getRawData(),V=null==u?void 0:u.categories,$=null==u?void 0:u.getRawData(),H=null==s?void 0:s.categories,q=null==s?void 0:s.getRawData(),W=null==c?void 0:c.categories,J=null==c?void 0:c.getRawData(),U=a?e=>X[Y[e]]:()=>"All",z=p?p.getRawData():null,Z=p?p.categories:null,K=p?p.type==o.COLUMN_TYPE.BOOL?e=>!!z[e]:e=>{var t,n,r;return null!=(t=null==(r=Z[z[e]])||null==(n=r.toLowerCase())?void 0:n.includes("exclude"))&&t}:e=>!1,Q=e=>k[e],ee=e=>j[e],et=e=>G[B[e]],en=u?e=>V[$[e]]:()=>null,er=s?e=>H[q[e]]:()=>null,eo=c?e=>W[J[e]]:()=>null,ei=["circle","triangle bottom","star","cross border","diamond","square","triangle left","triangle right","triangle top","asterisk"],el=0,ea={},es=!!((null==g?void 0:g.parentLevelCol)&&(null==g?void 0:g.wellLevelCol)),eu=null==h||null==(d=h.table)?void 0:d.col(u.name),ec=null==h||null==(y=h.table)?void 0:y.col(a.name),ed=null==h||null==(x=h.table)?void 0:x.col(c.name),ef=null==h||null==(C=h.table)?void 0:C.col(s.name),em=e=>`${en(e)}||${U(e)}||${eo(e)}`,ep=e=>`${em(e)}||${er(e)}`,eh=es?e=>`${g.wellLevelCol.get(e)}`:e=>ep(e),eg=es?e=>`${g.parentLevelCol.get(e)}`:eu&&ec&&ed&&ef?e=>{var t,n,r,o;return`${null==(t=h.table)?void 0:t.col(u.name).get(e)}||${null==(n=h.table)?void 0:n.col(a.name).get(e)}||${null==(r=h.table)?void 0:r.col(c.name).get(e)}||${null==(o=h.table)?void 0:o.col(s.name).get(e)}`}:e=>null,ev={};if(h)for(let e=0;e<(null!=(b=null==(w=h.table)?void 0:w.rowCount)?b:0);e++){let t=eg?eg(e):null;t&&!ev[t]&&(ev[t]={fitParams:null!=(T=null==(S=h.fitParamColumns)?void 0:S.map(t=>t.get(e)))?T:[],fitFunction:null!=(O=h.fitFunction)?O:r.Qx,reportedIC50:h.reportedIC50Column?h.reportedIC50Column.get(e):void 0,reportedQualifiedIC50:h.reportedQualifiedIC50Column?h.reportedQualifiedIC50Column.get(e):void 0,experimentID:h.experimentIDColumn?h.experimentIDColumn.get(e):void 0,qualifier:h.qualifierColumn?h.qualifierColumn.get(e):void 0,additionalColumns:h.additionalColumns?Object.fromEntries(h.additionalColumns.map(t=>[t.name,t.get(e)])):void 0})}for(let t=0;t<e.rowCount;t++){let e=U(t),n=et(t),r=Q(t),i=ee(t),l=K(t),a=en(t),s=eo(t),u=null!=(I=er(t))?I:"",c=em(t),d=eh(t),f=ep(t);if(!D[d]){if(D[d]={name:f,x:[],y:[],outliers:[],groupKey:c,runID:u,info:{"Assay Name":e,"Batch ID":n,"Compound ID":a,"Target Entity":s,"Run ID":u,"Max Percent Inhibition":null}},v)for(let e of v){let n=e.name;for(;n in D[d].info;)n=`${n} (1)`;D[d].info[n]=e.get(t)}if(h&&ev[d]){if(D[d].info["Reported IC50"]=ev[d].reportedIC50,D[d].info["Qualified Reported IC50"]=ev[d].reportedQualifiedIC50,D[d].info["Experiment ID"]=ev[d].experimentID,D[d].info.Qualifier=ev[d].qualifier,ev[d].additionalColumns&&Object.assign(D[d].info,ev[d].additionalColumns),ev[d].fitParams&&ev[d].fitParams.length>0)for(let e=0;e<(null!=(_=null==(A=h.fitParamColumns)?void 0:A.length)?_:0);e++){let t=h.fitParamColumns[e].name;D[d].info[t]=ev[d].fitParams[e]}ev[d].groupKey=c}}let m=D[d];m.x.push(r),m.y.push(i),m.outliers.push(l),l||null==i||i==o.FLOAT_NULL||i==o.INT_NULL||(m.info["Max Percent Inhibition"]=Math.max(null!=(P=m.info["Max Percent Inhibition"])?P:-1/0,i))}let ey={},ex=Object.entries(D),eC=[],eb=o.Column.string("Fitted Curve",ex.length);for(let e of(eb.init(e=>{var i,l,a,s,u,c;let[d,f]=ex[e],p=f.x,h=f.y,g=f.outliers,v=f.runID,y=(e=>{if(e in ea)return ea[e];{let t=ei[el];return ea[e]=t,el=(el+1)%ei.length,t}})(v),x=ev[d]?ev[d].fitParams:void 0,C=(e=>{if(ey[e])return ey[e];let t=o.Color.getCategoricalColor(Object.keys(ey).length);return ey[e]=o.Color.toHtml(t),ey[e]})((null!=(i=f.info["Compound ID"])?i:"")+"||"+(null!=(l=f.info["Assay Name"])?l:"")+"||"+(null!=(a=f.info["Target Entity"])?a:"")),b={fitFunction:(null==ev||null==(c=ev[d])?void 0:c.fitFunction)?ev[d].fitFunction:r.Qx,clickToToggle:!0,droplines:["IC50"],name:`${v}`,points:p.map((e,t)=>({x:e,y:h[t],outlier:g[t],marker:y,size:5})).sort((e,t)=>e.x-t.x),parameters:x,fitLineColor:C,pointColor:o.Color.toHtml(o.Color.gray)};return JSON.stringify({chartOptions:{xAxisName:t.name,yAxisName:n.name,logX:!0,title:m(`${null!=(s=null!=(u=f.name)?u:d)?s:""}`)},series:[b]})}),eC.push(eb),eb.semType="fit",eb.setTag("cell.renderer","fit"),eC.push(o.Column.fromStrings(f,ex.map(e=>m(e[1].groupKey)))),ex.reduce((e,t)=>(Object.keys(t[1].info).forEach(t=>e.add(t)),e),new Set))){let t=o.Column.fromStrings(e,ex.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:""}));eC.push(t)}let ew=e=>void 0==e||isNaN(e)?void 0:"number"==typeof e&&e!=o.FLOAT_NULL&&e!=o.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 ex){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]))),h&&ev[e]&&null!=(N=ev[e].reportedQualifiedIC50))&&N){eT[n].qualifiedIC50s.push(ev[e].reportedQualifiedIC50);let t=ew(h.reportedQualifiedIC50Column?ev[e].reportedQualifiedIC50:ev[e].reportedIC50);if(void 0==t)try{t=o.Qnum.parse(h.reportedQualifiedIC50Column?ev[e].reportedQualifiedIC50:ev[e].reportedIC50)}catch(e){}void 0!=t&&eT[n].reportedIC50s.push(t)}}let eO={};for(let e in eT){let t=eT[e];eO[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==(E=Math.max(...t.maxYs))?void 0:E.toString():null},h&&h.table?{"Number of total results":null==(L=t.qualifiedIC50s.length)?void 0:L.toString(),"Number of reported results":null==(F=t.reportedIC50s.length)?void 0:F.toString(),"Geomean IC50":t.reportedIC50s.length?null==(M=Math.exp(t.reportedIC50s.reduce((e,t)=>e+Math.log(t),0)/t.reportedIC50s.length)||null)?void 0:M.toString():null,"Standard Deviation":t.reportedIC50s.length>1?null==(R=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:R.toString():null,"All Results":t.qualifiedIC50s.join(", ")}:{})}for(let e of Object.keys(eO[Object.keys(eO)[0]])){let t=o.Column.fromStrings(e,ex.map(t=>{var n,r;return null!=(n=null==(r=eO[t[1].groupKey])?void 0:r[e])?n:""}));eC.push(t)}let eS=o.DataFrame.fromColumns(eC);if(eS.name="Fitted Curves",eS.setTag(o.Tags.Id,crypto.randomUUID()),!h||!h.table){let e={interceptX:"IC50",top:"Max",bottom:"Min",slope:"Hill",auc:"AUC"};Object.entries(e).forEach(([e,t])=>{let n={table:eS,colName:eb.name,propName:e,seriesNumber:0};o.Func.find({name:"addStatisticsColumn"})[0].prepare(n).callSync({processed:!1}).getOutputParamValue().name=t}),e.interceptX&&eS.col(e.interceptX)&&(eS.col(e.interceptX).meta.format="scientific")}return eS})()}},53(e,t,n){"use strict";n.d(t,{B3:()=>D,CP:()=>f,G_:()=>F,IY:()=>N,Ig:()=>M,LX:()=>x,RH:()=>T,Th:()=>h,U6:()=>_,Xm:()=>E,ab:()=>p,bZ:()=>c,bc:()=>R,d3:()=>S,g2:()=>m,h8:()=>b,mI:()=>w,uc:()=>d,wU:()=>C});var r=n(82),o=n(590),i=n(165),l=n(869),a=n(774),s=n(788),u=n(124);let c=new r.LruCache(1e3),d=new r.LruCache(1e3),f=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 i,l,a;let s=null==(i=e.explicit)?void 0:i[r];g(n[r],null==(l=n.explicit)?void 0:l[r],o,s),g(t[r],null==(a=t.explicit)?void 0:a[r],o,s)}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 x(e,t=[]){let n,r,o;if(0===e.length)return{};let i=Number.MAX_VALUE,l=Number.MAX_VALUE,a=5e-324,s=5e-324,u=!1,c=!1,d=!1;for(let t of e)null!==t.minX&&void 0!==t.minX&&(i=Math.min(i,t.minX)),null!==t.minY&&void 0!==t.minY&&(l=Math.min(l,t.minY)),null!==t.maxX&&void 0!==t.maxX&&(a=Math.max(a,t.maxX)),null!==t.maxY&&void 0!==t.maxY&&(s=Math.max(s,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&&(u=!0),null!==t.logY&&void 0!==t.logY&&t.logY&&(c=!0),null!==t.allowXZeroes&&void 0!==t.allowXZeroes&&t.allowXZeroes&&(d=!0);for(let e of t)for(let t of e.points)t.x<i&&(i=Number.MAX_VALUE),t.x>a&&(a=5e-324),t.y<l&&(l=Number.MAX_VALUE),t.y>s&&(s=5e-324);return{minX:i===Number.MAX_VALUE?void 0:i,minY:l===Number.MAX_VALUE?void 0:l,maxX:5e-324===a?void 0:a,maxY:5e-324===s?void 0:s,title:o,xAxisName:n,yAxisName:r,logX:u,logY:c,allowXZeroes:d}}function C(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 b(e,t=!0){var n;let r=null==e?void 0:e.column;return t&&r&&e?d.getOrCreate((n=e.rowIndex,`tableId: ${r.dataFrame.id} || tableName: ${r.dataFrame.name} || colName: ${r.name} || colVersion: ${r.version} || rowIdx: ${n}`),()=>O(e)):O(e)}function w(e,t,n){let r=R(t),i=n?M(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,i.chartOptions,e.chartOptions),y(e.chartOptions,r.chartOptions,i.chartOptions),v(e,r,i,p,e.chartOptions),e.series))m(l.IL,e.seriesOptions,t),m(l.IL,r.seriesOptions,t),m(l.IL,i.seriesOptions,t),v(e,r,i,h,t);return e}function T(e){return e.includes("|")?e.replaceAll("|",""):e}function O(e){var t,n,a,s,c;let d=e.value,f=e.column,g=f?f.type===r.TYPE.STRING?(0,u.HB)(d,f):(0,i.Kh)():null!=(t=JSON.parse(null!=(n=T(d))?n:"{}"))?t:{};(null==f?void 0:f.type)!==r.TYPE.STRING||(null==(c=g.series)?void 0:c.length)||(g=(0,u.HB)(T(d),f));let x=e.column?R(e.column):{},C=e.column?M(e.dataFrame):{};for(let e of(null!=(a=g).series||(a.series=[]),null!=(s=g).chartOptions||(s.chartOptions=x.chartOptions),m(o.xs,x.chartOptions,g.chartOptions),m(o.xs,C.chartOptions,g.chartOptions),y(g.chartOptions,x.chartOptions,C.chartOptions),v(g,x,C,p,g.chartOptions),g.series))m(l.IL,g.seriesOptions,e),m(l.IL,x.seriesOptions,e),m(l.IL,C.seriesOptions,e),v(g,x,C,h,e);return g}let S=new r.LruCache(2e3),I=new WeakMap,P=0;function _(e){let t=I.get(e);return void 0===t&&I.set(e,t=++P),t}function A(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,i=!0,a){let s=E(e,t,r,!1,o,i),u=null==o?void 0:o.column;return a?S.getOrCreate(`${a} || logX: ${null==r?void 0:r.logX} || logY: ${null==r?void 0:r.logY}`,()=>(0,l.nT)(e,n,s,r)):i&&u&&o?c.getOrCreate(A(u,o,t,r),()=>(0,l.nT)(e,n,s,r)):(0,l.nT)(e,n,s,r)}function E(e,t,n,r,o,i=!0){let l=null==o?void 0:o.column;return i&&l&&o?f.getOrCreate(`${A(l,o,t,n)} || userParamsFlag: ${r}`,()=>(0,a.Sm)(e,n,r)):(0,a.Sm)(e,n,r)}function L(e){return JSON.parse(e[s.h.TAG_FIT]||e[s.h.TAG_FIT_LEGACY]||JSON.stringify((0,i.Kh)()))}function F(e,t){e[s.h.TAG_FIT]=JSON.stringify(t),delete e[s.h.TAG_FIT_LEGACY]}function M(e){return L(e.tags)}function R(e){return L(e.tags)}function D(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,i=0,l=[];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&&!l.includes(t.points[e].x)&&(l[l.length]=t.points[e].x,i++);if(0===i)continue;let a=Math.log10(r),s=i>1?(Math.log10(o)-a)/(i-1):1,u=Math.pow(10,a-s);for(let e=0;e<t.points.length;e++)0===t.points[e].x&&(t.points[e].x=u)}}},301(e,t,n){"use strict";n.d(t,{Z1:()=>h,kL:()=>m,nO:()=>p,pj:()=>g});var r=n(82),o=n(328),i=n(982),l=n(590),a=n(991),s=n.n(a),u=n(788);function c(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){c(i,r,o,l,a,"next",e)}function a(e){c(i,r,o,l,a,"throw",e)}l(void 0)})}}function f(e,t){return Math.random()*(t-e)+e}function m(e,t,n=1){let r=new Float32Array(e*n),o=new Float32Array(e*n),i=[f(1,2),f(1,2),f(1,2),f(-5,5)],a=0-Math.floor(e/2)*t,s=a+t*(e-1);for(let e=a,u=0;e<=s;e+=t,u++)for(let t=0;t<n;t++){r[u*n+t]=e-a+.1;let s=new Float32Array(4);s.set(i),o[u*n+t]=(0,l.ry)(s,e)}let u=(1===n?.2:.4)*(Math.max(...o)-Math.min(...o)),c=Math.min(...o);for(let e=0;e<r.length;e++)o[e]=-c+o[e]+f(0,u);return{x:r,y:o,params:i}}function p(e,t,n){let o=r.DataFrame.create(e);o.setTag(r.Tags.Id,crypto.randomUUID());for(let l=0;l<t;l++){let t=3===l?5:1,a=o.columns.addNewString(`json chart ${l}`);a.semType=u.h.FIT_SEM_TYPE;let c=l%2==0?n:1;for(let o=0;o<e;o++){let e={series:[],chartOptions:{showStatistics:1===c?["auc"]:[],xAxisName:"Conc.",yAxisName:"Activity",title:"Dose-Response curves"}};for(let o=0;o<c;o++){var i;let a=m(15,.5,t),u=r.Color.toHtml(r.Color.getCategoricalColor(l*n+o));null==(i=e.series)||i.push({parameters:void 0,fitLineColor:u,pointColor:u,showCurveConfidenceInterval:1===c,points:s().count().take(15*t).map(function(e){return{x:a.x[e],y:a.y[e]}}).toArray()})}a.set(o,JSON.stringify(e))}}return o}function h(){return d(function*(){o.shell.windows.showContextPanel=!0;let e=yield o.data.loadTable(`${i._package.webRoot}files/curves-demo.csv`);o.shell.addTableView(e)})()}function g(){return d(function*(){let e=yield o.data.loadTable(`${i._package.webRoot}files/demo/Assay_Curves.csv`);yield e.meta.detectSemanticTypes();let t=yield i._package.files.readAsText("demo/Assay_Curves.layout"),n=r.ViewLayout.fromJson(t);e.selection.set(13,!0),e.selection.set(14,!0);let l=o.shell.addTableView(e);yield r.delay(100),l.loadLayout(n,!0),o.shell.info("Select cells in Trellis plot to see corresponding curves in Multi Curve Viewer.",{timeout:10})})()}},181(e,t,n){"use strict";n.d(t,{e:()=>C,g:()=>v});var r=n(82),o=n(389),i=n(328),l=n(165),a=n(129),s=n(53),u=n(788),c=n(684),d=n(434),f=n(590),m=n(869),p=n(258);function h(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).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 i.shell.error(`Curves: ${t} is not registered`);let l=e.cell.dataFrame,a=e.cell.column.name,s=new Set(l.columns.names());try{yield o.prepare(g({table:l,curveColumn:e.cell.column},n)).call(!1,void 0,{processed:!1})}catch(e){i.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 i=[];for(let e=0;e<o.columns.length;e++){var l;let t=null==(l=o.columns.byIndex(e))?void 0:l.name;t&&i.push(t)}o.columns.setOrder(y(i,t,n))}(e,l.columns.names().filter(e=>!s.has(e)),a)},function(){var e=this,t=arguments;return new Promise(function(n,r){var i=o.apply(e,t);function l(e){h(i,n,r,l,a,"next",e)}function a(e){h(i,n,r,l,a,"throw",e)}l(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 x(e){let t=e.root.querySelector(".ui-input-multi-choice-checks");return t&&(t.style.maxHeight="none",t.style.overflowY="visible"),e}class C extends r.ObjectHandler{get type(){return"GridCell"}isApplicable(e){return e instanceof r.GridCell&&e.cellType===u.h.FIT_CELL_TYPE}levelInput(e){let t=e.cell,n=t.column.dart,i=t.rowIndex,l=()=>{var e;return(null==(e=this.levelColumn)?void 0:e.deref())===n&&this.levelRow===i};l()||(this.levelColumn=new WeakRef(n),this.levelRow=i,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}),s=o.input.forProperty(a,null,{onValueChanged:e=>{l()&&(this.manipulationLevel=e)}});return o.tooltip.bind(s.captionLabel,"Controls the level at which properties will be switched"),s}renderProperties(e,t=null){var n,i,h,y,C,b,w,T;let O=o.accordion("Curves property panel"),S=this.levelInput(e),I=(0,s.h8)(e.cell),P=(0,s.bc)(e.cell.column),_=(0,s.Ig)(e.cell.dataFrame),A={onValueChanged:(t,n)=>(0,p.FC)(e,n,s.Th,S.value)},N={onValueChanged:(t,n)=>(0,p.FC)(e,n,s.ab,S.value)},E=e=>{if(_.seriesOptions&&!(0,c.Yc)(_.seriesOptions[e])&&P.seriesOptions&&!(0,c.Yc)(P.seriesOptions[e])){var t;I.seriesOptions?(0,c.Yc)(I.seriesOptions[e])||(I.seriesOptions[e]=r.Color.toHtml("outlierColor"===e?r.Color.red:r.Color.getCategoricalColor(0))):(null==(t=I.series)?void 0:t.length)&&!(0,c.Yc)(I.series[0][e])&&(I.series[0][e]=r.Color.toHtml("outlierColor"===e?r.Color.red:r.Color.getCategoricalColor(0)))}},L=e.cell;E("pointColor"),E("fitLineColor"),E("outlierColor"),(0,s.g2)(m.IL,P.seriesOptions,I.seriesOptions?I.seriesOptions:I.series&&null!=(n=I.series[0])?n:{}),(0,s.g2)(m.IL,_.seriesOptions,I.seriesOptions?I.seriesOptions:I.series&&null!=(i=I.series[0])?i:{}),(0,s.g2)(f.xs,P.chartOptions,I.chartOptions?I.chartOptions:{}),(0,s.g2)(f.xs,_.chartOptions,I.chartOptions?I.chartOptions:{}),(null==(y=I.chartOptions)?void 0:y.allowXZeroes)&&(null==(C=I.chartOptions)?void 0:C.logX)&&(null==(b=I.series)?void 0:b.some(e=>e.points.some(e=>0===e.x)))&&(0,s.B3)(I);let F=o.form([S]),M=I.seriesOptions?I.seriesOptions:I.series[0],R=M&&"object"==typeof M.fitFunction?M.fitFunction:null,D=(0,p.s9)(I,R).map(e=>{var t,n;if("fitFunction"!==e.name||!R)return x(o.input.forProperty(e,M,A));let r=(t=g({},M),n=n={fitFunction:R.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!==R.name&&(M.fitFunction=e),A.onValueChanged(e,t)}})});o.forms.addGroup(F,"Series options",D),(null==(w=I.chartOptions)?void 0:w.showStatistics)&&(I.chartOptions.showStatistics=(0,p.QA)(I,I.chartOptions.showStatistics)),o.forms.addGroup(F,"Chart options",(0,p.di)(I).map(e=>x(o.input.forProperty(e,I.chartOptions,N)))),O.addPane("Options",()=>F);let X=(null!=(h=null==(T=I.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:X,nullable:!1}),k=o.input.forProperty(Y,null,{onValueChanged:()=>{O.getPane("Fit").root.lastElementChild.replaceChildren(B())}}),j=r.Property.js("aggregation type",r.TYPE.STRING,{description:"Controls which aggregation to use on the series statistics",defaultValue:"med",choices:Object.values(r.STATS),nullable:!1}),G=o.input.forProperty(j,null,{onValueChanged:()=>{O.getPane("Fit").root.lastElementChild.replaceChildren(B())}});function B(){var t,n,r,i,a;let s=(null!=(t=null==(n=I.series)?void 0:n.length)?t:0)>1?"aggregated"===k.stringValue?[k.root,G.root]:[k.root]:null,u=o.divV(s),f=(0,l.s$)(I);if(f.x<=0&&I.chartOptions&&(I.chartOptions.logX=!1),f.y<=0&&I.chartOptions&&(I.chartOptions.logY=!1),"all"===k.stringValue){let t={logX:null==(r=I.chartOptions)?void 0:r.logX,logY:null==(i=I.chartOptions)?void 0:i.logY};for(let n=0;n<I.series.length;n++){let r=I.series[n],i=(0,d.TV)(r,n,t,L),s=(0,c.Z)(r,n,c.mE.FIT_LINE),f=null!=(a=r.name)?a:"series "+n;u.appendChild(o.panel([o.h1(f,{style:{color:s}}),o.input.form(i,(0,l.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,d.JR)(I,G.stringValue,L);u.appendChild(o.panel([o.h1(`series ${G.stringValue}`),o.input.form(t,(0,d.Uc)(I,G.stringValue),{onCreated:t=>t.root.appendChild(o.iconFA("plus",()=>v(e,"curveAggrStatistic",{propName:t.property.name,aggrType:G.stringValue}),`Calculate ${t.property.name} ${G.stringValue} for the whole column`))})]))}return u}let V=r.GridCellWidget.fromGridCell(e);V.canvas.addEventListener("click",e=>V.render());let $=O.addPane("Chart",()=>V.root),H=a.l.inflateScreenBounds(e.bounds);return(H.width<u.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||H.height<u.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT)&&($.expanded=!0),O.addPane("Fit",()=>B()),O.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,{Fw:()=>g,I4:()=>v,Oz:()=>w,dA:()=>C,fU:()=>T,hC:()=>b});var r=n(82),o=n(328),i=n(389),l=n(858),a=n(165),s=n(869),u=n(788),c=n(533),d=n(124),f=n(53),m=n(434),p=n(324),h=n(663);function g(e,t,n,r,i){if(t.outlier=!t.outlier,(0,d.XN)(e.cell.column)){let i=JSON.parse(e.cell.value);i.series[n].points[r].outlier=t.outlier,e.cell.column.set(e.cell.rowIndex,JSON.stringify(i),!0),o.events.fireCustomEvent("fit-cell-outlier-toggle",{gridCell:e,series:i.series[n],seriesIdx:n,pointIdx:r})}let l=e.grid.dataFrame.columns.byTags({".sourceColumn":e.cell.column.name});if(l)for(let t of(null!=i||(i=(0,f.h8)(e.cell)),l)){var a,u;let r,o={logX:null==(a=i.chartOptions)?void 0:a.logX,logY:null==(u=i.chartOptions)?void 0:u.logY},l=t.tags[".statistics"];if(null!==t.tags[".seriesAggregation"])r=(0,m.JR)(i,t.tags[".seriesAggregation"],e.cell)[l];else{if(t.tags[".seriesNumber"]!==n.toString())continue;r=(0,s.h5)((0,m.TV)(i.series[n],n,o,e.cell),l)}t.set(e.cell.rowIndex,null!=r?r:null)}}function v(e,t,n=!1){var o,a;if(!e.cell.value)return;let s=r.GridCellWidget.fromGridCell(e);s.root.style.removeProperty("aspectRatio"),s.root.style.height="100%",s.canvas.style.removeProperty("height"),s.canvas.style.removeProperty("width"),s.canvas.style.left="18px",s.canvas.style.top="18px";let u=i.dialog({title:"Edit chart"}).add(s.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});u.getButton("CANCEL").textContent="Close",n&&u.sub((0,l.merge)(e.grid.dataFrame.onDataChanged,e.grid.dataFrame.onMetadataChanged).subscribe(()=>s.render()))}function y(e,t,n){let o=n.xToScreen(t.x),i=n.yToScreen(t.y),l=(t.outlier?u.h.OUTLIER_PX_SIZE:u.h.POINT_PX_SIZE)/2+u.h.OUTLIER_HITBOX_RADIUS;return new r.Rect(o-l,i-l,2*l,2*l).containsPoint(new r.Point(e.x,e.y))}function x(e,t){var n,r,o,i;let l=(0,p.lc)(e,t),s=(0,p.Tv)(e,l.x,l.y,(0,p.ij)(e,t))[0];return new c.L((0,a.s$)(t),s,null!=(n=null==(o=t.chartOptions)?void 0:o.logX)&&n,null!=(r=null==(i=t.chartOptions)?void 0:i.logY)&&r)}function C(e,t=(0,f.h8)(e.cell,!1)){for(let[e,n]of Object.entries(u.h.CONDITION_MAP))if(n(t.series))return i.divText(e,{style:{color:"red"}});return e}function b(e,t){var n;if(!e.cell.value||!e.cell.column)return;let r=(0,f.h8)(e.cell,!1),i=C(e,r);if(o.shell.setCurrentObject(i,!1),i!==e)return;let l=(0,p.fn)(e.bounds),a=x(l,r);for(let o=0;o<(null==(n=r.series)?void 0:n.length);o++)if(!r.series[o].connectDots&&r.series[o].clickToToggle&&"points"===r.series[o].showPoints&&!(l.width<u.h.MIN_AXES_CELL_PX_WIDTH)&&!(l.height<u.h.MIN_AXES_CELL_PX_HEIGHT))for(let n=0;n<r.series[o].points.length;n++){let i=r.series[o].points[n];if((!i.outlier||r.series[o].showOutliers)&&y({x:t.offsetX,y:t.offsetY},i,a))return void g(e,i,o,n,r)}}function w(e,t,n,o){var l,a,s,c,d,f,m;let p=x(t,e),g=(0,h.qd)(e,t)?(0,h.tp)(e,p.screen,o.x,o.y):null;if(null!==g)return i.tooltip.show((0,h.D5)(g),n.x+16,n.y+16),!0;for(let h=0;h<(null==(l=e.series)?void 0:l.length);h++)if("points"===e.series[h].showPoints)for(let l=0;l<e.series[h].points.length;l++){let g=e.series[h].points[l];if((!g.outlier||e.series[h].showOutliers)&&y(o,g,p))return i.tooltip.show(i.divV([i.divText(`${null!=(a=null==(c=e.chartOptions)?void 0:c.xAxisName)?a:"x"}: ${r.format(g.x,!(null==(d=e.chartOptions)?void 0:d.logX)?"#0.000":"scientific")}`),i.divText(`${null!=(s=null==(f=e.chartOptions)?void 0:f.yAxisName)?s:"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>=u.h.MIN_AXES_CELL_PX_WIDTH&&t.height>=u.h.MIN_AXES_CELL_PX_HEIGHT&&(document.body.style.cursor="pointer"),!0}return!1}function T(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<u.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||o.height<u.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT){let r=i.canvas(300,200);n.render(r.getContext("2d"),0,0,300,200,e,null),i.tooltip.show(i.divV([r]),t.x,t.y)}let l=(0,f.h8)(null==e?void 0:e.cell);if(o.width>=u.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH&&o.height>=u.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT){if(w(l,o,t,{x:t.offsetX,y:t.offsetY}))return;i.tooltip.hide()}document.body.style.cursor="default"}},324(e,t,n){"use strict";n.d(t,{Tv:()=>i,W$:()=>d,ZK:()=>c,b1:()=>l,eG:()=>s,fn:()=>o,ij:()=>u,lc:()=>a,m:()=>f});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 i(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 i=n?r.h.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS:r.h.AXES_LEFT_PX_MARGIN,l=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,s=r.h.AXES_RIGHT_PX_MARGIN;return[e.cutLeft(i).cutBottom(l).cutTop(a).cutRight(s),e.getBottom(l).getTop(a).cutLeft(i).cutRight(s),e.getLeft(i).getRight(r.h.AXES_RIGHT_PX_MARGIN).cutBottom(l).cutTop(a)]}function l(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 i=e.width>=r.h.MIN_X_AXIS_NAME_VISIBILITY_PX_WIDTH&&e.height>=r.h.MIN_Y_AXIS_NAME_VISIBILITY_PX_HEIGHT;return{x:i&&!!(null==(n=t.chartOptions)?void 0:n.xAxisName),y:i&&!!(null==(o=t.chartOptions)?void 0:o.yAxisName)}}function s(e,t){let n=a(e,t);return n.x||n.y}function u(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 d(e){return e.width>=r.h.MIN_DROPLINE_LABELS_PX_WIDTH&&e.height>=r.h.MIN_DROPLINE_LABELS_PX_HEIGHT}function f(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,Al:()=>x,D5:()=>w,GU:()=>T,QK:()=>I,_i:()=>v,bp:()=>f,qd:()=>u,tp:()=>O});var o=n(82),i=n(389),l=n(788),a=n(684),s=n(324);function u(e,t){var n,r;return(null==(n=null==(r=e.chartOptions)?void 0:r.showLegend)||n)&&(0,s.ZK)(t)}let c=["top right","top left","bottom right","bottom left"],d='11px Roboto, "Roboto Local"';function f(){return Math.max(10,Math.floor(.75*window.innerHeight/l.h.LEGEND_RECORD_PX_HEIGHT))}let m=new WeakMap;function p(e){return null!=r||(r=document.createElement("canvas").getContext("2d")),r.font=d,r.measureText(e).width}function h(e,t){if(p(e)<=t)return e;let n=e;for(;n.length>1&&p(`${n}…`)>t;)n=n.slice(0,-1);return`${n}…`}function g(e,t){var n;let r=t&&null!=(n=e.auxLegendName)?n:e.name;return""===r||null===r?void 0:r}function v(e){var t,n,r,i;let l=null!=(t=e.series)?t:[],s=[...new Set(l.map(e=>e.columnName))].filter(e=>null!=e),u=[];for(let t of s){let n=l.map((e,t)=>({series:e,idx:t})).filter(({series:n})=>{var r;return n.columnName===t&&g(n,null==(r=e.chartOptions)?void 0:r.useAuxLegendNames)});if(0!==n.length)for(let{series:l,idx:s}of((null==(r=e.chartOptions)?void 0:r.showColumnLabel)&&n.length>1&&u.push({text:t,color:"black"}),n))u.push({text:g(l,null==(i=e.chartOptions)?void 0:i.useAuxLegendNames),column:t,color:(0,a.Z)(l,s,a.mE.FIT_LINE),pointColor:(0,a.Z)(l,s,a.mE.POINT),marker:function(e){var t,n,r;let i=(null==(n=e.points)?void 0:n.length)?e.points[0].marker:null,l=(null==(r=e.points)?void 0:r.every(e=>e.marker===i&&null!=e.marker))?i:null;return null!=(t=null!=l?l:e.markerType)?t:o.MARKER_TYPE.CIRCLE}(l)})}let c=new Map;for(let e of u.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 u)void 0!==e.marker&&e.column&&c.get(e.text).size>1&&(e.text=`${e.column}: ${e.text}`);return u}function y(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 x(e,t,n,r,i){let l=[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!=i?i:0;if(!(null==r?void 0:r.length))return{rect:l[a],index:a};let s=l.map(e=>({taken:y(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)}))})),u=0;for(let e=1;e<l.length;e++)(s[e].taken<s[u].taken||s[e].taken===s[u].taken&&s[e].clearance>s[u].clearance)&&(u=e);return s[a].taken<=2||2*s[u].taken>=s[a].taken?{rect:l[a],index:a}:{rect:l[u],index:u}}function C(e){return Math.floor(l.h.POINT_PX_SIZE*e*1.5)+l.h.LEGEND_RECORD_LINE_PX_WIDTH+l.h.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN}function b(e,t,n,r,i){if(void 0===t.marker)return;let a=Math.floor(l.h.POINT_PX_SIZE*i*1.5);e.beginPath(),e.strokeStyle=t.color,e.lineWidth=2*i,e.moveTo(n+a,r),e.lineTo(n+a+l.h.LEGEND_RECORD_LINE_PX_WIDTH,r),e.stroke(),o.Paint.marker(e,t.marker,n+a/2,r,t.pointColor,a)}function w(e){let t=1===e.length,n=e.slice(0,f()),r=n.map(e=>{let n=i.canvas(C(1),l.h.LEGEND_RECORD_PX_HEIGHT);b(n.getContext("2d"),e,0,l.h.LEGEND_RECORD_PX_HEIGHT/2,1);let r=i.divH([n,i.divText(t?e.text:h(e.text,400),{style:{color:e.color}})]);return r.style.alignItems="center",r});return e.length>n.length&&r.push(i.divText(`+${e.length-n.length} more`)),i.divV(r)}function T(e,t,n,r,i){let a=function(e,t,n,r){let i=m.get(e),a=v(e);if(0===a.length)return{rows:[],hidden:0,entries:a,corner:0,whole:!0};let s=C(n);if(.55*t.width-s<=0)return{rows:[],hidden:0,entries:a,corner:0,whole:!0};let u=Math.floor(.5*t.height/l.h.LEGEND_RECORD_PX_HEIGHT),c=a.length>u?a.slice(0,Math.max(1,u-1)):a,d=a.length-c.length,f=l.h.LEGEND_RECORD_PX_HEIGHT*(c.length+ +(d>0)),g=Math.min(s+Math.max(...c.map(e=>p(e.text)),d>0?p(`+${d} more`):0),t.width-8),b=x(t,g,f,r,null==i?void 0:i.corner),w=(null==i?void 0:i.whole)?12:2,T=y(b.rect,r)<=w,O=T?g:Math.min(g,.55*t.width),S=c.map(e=>h(e.text,O-s)),I=s+Math.max(...S.map(p)),P=T?b:x(t,I,f,r,null==i?void 0:i.corner),_=P.rect,A=c.map((e,t)=>({entry:e,shown:S[t],box:new o.Rect(_.x,_.y+l.h.LEGEND_RECORD_PX_HEIGHT*t,I,l.h.LEGEND_RECORD_PX_HEIGHT)})),N=0===d?void 0:new o.Rect(_.x,_.y+l.h.LEGEND_RECORD_PX_HEIGHT*A.length,I,l.h.LEGEND_RECORD_PX_HEIGHT);return{rows:A,hidden:d,moreBox:N,entries:a,corner:P.index,whole:T}}(t,n,r,i),{rows:s,hidden:u}=a;if(0===s.length)return;m.set(t,{box:n,rows:s,moreBox:a.moreBox,entries:a.entries,corner:a.corner,whole:a.whole}),e.save(),e.font=d,e.textAlign="left";let c=s[0].box,f=l.h.LEGEND_RECORD_PX_HEIGHT*(s.length+ +(u>0));for(let t of(e.fillStyle="rgba(255, 255, 255, 0.75)",e.fillRect(c.x-3,c.y-3,c.width+6,f+6),s)){let n=t.box.maxY-l.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN;b(e,t.entry,t.box.x,n-l.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:C(r)),n)}u>0&&(e.fillStyle="black",e.fillText(`+${u} more`,c.x,s[s.length-1].box.maxY+l.h.LEGEND_RECORD_PX_HEIGHT-l.h.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN)),e.restore()}function O(e,t,n,r){var o;let i=S(e,t);if(!i)return null;if(null==(o=i.moreBox)?void 0:o.contains(n,r))return i.entries;let l=i.rows.find(e=>e.box.contains(n,r));return l&&l.shown!==l.entry.text?[l.entry]:null}function S(e,t){let n=m.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(!u(e,t))return null;let n=(0,s.lc)(t,e);return S(e,(0,s.Tv)(t,n.x,n.y,(0,s.ij)(t,e))[0])}},258(e,t,n){"use strict";n.d(t,{FC:()=>C,QA:()=>h,di:()=>p,s9:()=>g,tS:()=>m});var r,o=n(82),i=n(328),l=n(165),a=n(590),s=n(788),u=n(869),c=n(53),d=n(124);let f=["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 i=[];for(let n of null!=(t=e.series)?t:[])for(let e of(0,l.zB)(n).statisticsProperties)i.includes(e.name)||i.push(e.name);let s=function(e){var t,n,r,o;let i=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:{}))i.includes(e)||i.push(e);return i}(e),u=(null!=(n=null==(r=e.series)?void 0:r.length)?n:0)>1;return a.xs.filter(e=>("showLabels"!==e.name||s.length>0)&&("statisticsMode"!==e.name&&"aggrType"!==e.name||u)).map(e=>"showStatistics"===e.name&&i.length>0?o.Property.js("showStatistics",o.TYPE.STRING_LIST,{description:e.description,choices:i,inputType:"MultiChoice",friendlyName:"Statistics"}):"showLabels"===e.name?o.Property.js("showLabels",o.TYPE.STRING_LIST,{description:e.description,choices:s,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,u.Wh)((0,l.zB)(n),o);if(e){t=e.name;break}}n.includes(t)||n.push(t)}return n}function g(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)}),r=[...new Set([...t?[t.name]:[],...Object.keys(u.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:u.hD})})}function v(e,t,n){var r,o,i;let l=null!=(o=(r=null!=(i=e.explicit)?i:e.explicit={})[t])?o:r[t]=[];l.includes(n)||l.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 x(e,t){return"fitFunction"===e&&"string"==typeof t&&u.HM[t]?u.HM[t]:t}function C(e,t,n,r){var o,l,a;let u,m=t.property.name,p=f.includes(m);if("Cell"===r){let r;if(!(0,d.XN)(e.cell.column))return;let o=e.cell.value;if(""===o)return;try{r=null!=(l=JSON.parse(null!=o?o:"{}"))?l:{}}catch(e){i.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=x(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 i of((null!=(o=h[n])?o:h[n]={})[m]=x(m,t.value),v(h,n,m),"Dataframe"===r?((0,c.G_)(e.cell.dataFrame.tags,h),u=e.cell.dataFrame.columns.bySemTypeAll(s.h.FIT_SEM_TYPE)):((0,c.G_)(e.cell.column.tags,h),u=[e.cell.column]),u)){if("Dataframe"===r){let e=(0,c.bc)(i),t=e[n];t&&delete t[m],y(e,n,m),(0,c.G_)(i.tags,e)}if((0,d.XN)(i))for(let e=0;e<i.length;e++){let t,r=i.get(e);if(""!==r){try{t=null!=(a=JSON.parse(r))?a:{}}catch(e){continue}y(t,n,m)&&i.set(e,JSON.stringify(t),!1)}}}if(p)for(let e of u)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),i=n(533),l=n(165),a=n(788),s=n(684),u=n(663),c=n(434),d=n(53),f=n(324),m=n(476);function p(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).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,f.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 i=t.apply(e,n);function l(e){p(i,r,o,l,a,"next",e)}function a(e){p(i,r,o,l,a,"throw",e)}l(void 0)})})()}layOutChart(e,t,n,o,a){var s,u,c,m,p,v,y,x,C,b,w,T,O;let S=(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),I=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,d.B3)(t);let P=(0,f.lc)(e,t),[_,A,N]=(0,f.Tv)(e,P.x,P.y,(0,f.ij)(e,t)),E=(0,l.s$)(t);(E.x<0&&t.chartOptions||0===E.x&&t.chartOptions&&!t.chartOptions.allowXZeroes)&&(t.chartOptions.logX=!1),E.y<=0&&t.chartOptions&&(t.chartOptions.logY=!1);let L={logX:null==(x=t.chartOptions)?void 0:x.logX,logY:null==(C=t.chartOptions)?void 0:C.logY},F=[];for(let e=0;e<(null==(b=t.series)?void 0:b.length);e++){let n=t.series[e];if(n.points.some(e=>void 0===e.x||void 0===e.y)||n.points.length<=1){F.push(null);continue}n.points.sort((e,t)=>e.x-t.x);let r=(0,l.zB)(n),i=null,a=n,s=!0;if(!(n.connectDots&&!(null==(O=n.showFitLine)||O)))if(n.parameters)a=(0,l.iK)(n,L),i=(0,l._T)(a,r);else{let t=(0,d.IY)(n,e,r,L,I,S,null==o?void 0:o[e]);i=t.fittedCurve,a=g(h({},n),{parameters:[...t.parameters]}),s=!1}F.push({fitFunc:r,curve:i,fitSpaceSeries:a,userParamsFlag:s})}E=function(e,t,n){var o,i;let l=null!=(o=null==n?void 0:n.logX)&&o,a=null!=(i=null==n?void 0:n.logY)&&i,s=e.minY,u=e.maxY;for(let n of t)if(n)for(let t=0;t<=100;t++){let r=t/100,o=l?e.minX*Math.pow(e.maxX/e.minX,r):e.minX+e.width*r,i=n(l?Math.log10(o):o),c=a?Math.pow(10,i):i;isFinite(c)&&(s=Math.min(s,c),u=Math.max(u,c))}if((null==n?void 0:n.minY)!=null&&(s=e.minY),(null==n?void 0:n.maxY)!=null&&(u=e.maxY),s>=e.minY&&u<=e.maxY)return e;if(a&&e.minY>0){let t=(Math.log10(e.maxY)-Math.log10(e.minY))*.15;s=Math.max(s,Math.pow(10,Math.log10(e.minY)-t)),u=Math.min(u,Math.pow(10,Math.log10(e.maxY)+t))}else s=Math.max(s,e.minY-.15*e.height),u=Math.min(u,e.maxY+.15*e.height);if(s>=e.minY&&u<=e.maxY)return e;let c=u-s,d=s<e.minY?a&&s>0?s/1.05:s-.05*c:e.minY,f=u>e.maxY?a?1.05*u:u+.05*c:e.maxY;return new r.Rect(e.x,d,e.width,f-d)}(E,F.map(e=>(null==e?void 0:e.fitFunc.hasAsymptotes)?e.curve:null),t.chartOptions);let M=new i.L(E,_,null!=(s=null==(w=t.chartOptions)?void 0:w.logX)&&s,null!=(u=null==(T=t.chartOptions)?void 0:T.logY)&&u);return{dataBox:_,xAxisBox:A,yAxisBox:N,dataBounds:E,fits:F,chartLogOptions:L,useFitCache:S,tableCell:I,viewport:M}}renderCurves(e,t,n,o,i){var l,m,p,h,g,v,y,x,C,b,w,T,O,S,I;e.save(),e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.clip();let{dataBox:P,xAxisBox:_,yAxisBox:A,dataBounds:N,fits:E,chartLogOptions:L,useFitCache:F,tableCell:M,viewport:R}=this.layOutChart(t,n,o,i,e.canvas),D=Math.min(P.width,P.height),X=D>100?1:.2+D/100*.8,Y=(0,u.qd)(n,t)?[]:void 0;e.save(),e.font='11px Roboto, "Roboto Local"',R.drawCoordinateGrid(e,_,A),e.restore();let k=(0,s.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:P,screenBounds:t,startLine:0,drawnAt:Y}),j=(null!=(l=null==(g=n.series)?void 0:g.length)?l:0)>1&&null!=(m=null==(v=n.chartOptions)?void 0:v.statisticsMode)?m:"series",G=null==(y=n.chartOptions)?void 0:y.showStatistics;if((null==G?void 0:G.length)&&"series"!==j){let r=null!=(T=null==(O=n.chartOptions)?void 0:O.aggrType)?T:"med",o=(0,c.JR)(n,r,M),i=Object.fromEntries(G.map(e=>[`${r} ${e}`,o[e]]));k+=(0,s.S3)(e,i,{names:Object.keys(i),color:a.h.PLOT_LABEL_COLOR,dataBox:P,screenBounds:t,startLine:k,drawnAt:Y})}for(let o=0;o<(null==(x=n.series)?void 0:x.length);o++){let i=n.series[o],l=E[o];if(!l)continue;let{fitFunc:u,curve:c,fitSpaceSeries:m,userParamsFlag:p}=l,h=a.h.POINT_PX_SIZE*X/2,g=P.inflate(h,h);if(e.save(),e.beginPath(),e.rect(g.x,g.y,g.width,g.height),e.clip(),(0,s.qR)(e,i,{viewport:R,ratio:X,logOptions:L,showAxes:(0,f.b1)(t),showAxesLabels:(0,f.eG)(t,n),screenBounds:t,curveFunc:c,seriesIdx:o,drawnAt:Y}),(0,s.nx)(e,i,{viewport:R,ratio:X,seriesIdx:o}),(0,s.QW)(e,i,{viewport:R,ratio:X,screenBounds:t,seriesIdx:o}),Y){let e=null;for(let t of i.points){if(t.outlier&&!(null==(I=i.showOutliers)||I))continue;let n=new r.Point(R.xToScreen(t.x),R.yToScreen(t.y));if(Y.push(n),e){let t=Math.floor(Math.abs(n.x-e.x)/s.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,s.Zk)(e,m,{viewport:R,logOptions:L,showAxes:(0,f.b1)(t),showAxesLabels:(0,f.eG)(t,n),screenBounds:t,fitFunc:u,userParamsFlag:p,drawnAt:Y,dataPoints:(0,d.Xm)(i,o,L,p,M,F)}),(0,s.HQ)(e,m,{viewport:R,ratio:X,showDroplines:(0,f.m)(t),showDroplineLabels:(0,f.W$)(t),fitFunc:u,dataBounds:N,curveFunc:c,logOptions:L,drawnAt:Y}),e.restore(),k+=(0,s.yv)(e,m,{statistics:"aggregated"===j?[]:G,fitFunc:u,logOptions:L,dataBox:P,screenBounds:t,seriesIdx:o,startLine:k,drawnAt:Y}),k+=(0,s.S3)(e,i.labels,{names:null==(S=n.chartOptions)?void 0:S.showLabels,color:(0,s.Z)(i,o,s.mE.FIT_LINE),dataBox:P,screenBounds:t,startLine:k,drawnAt:Y})}(0,s.zF)(e,{showTitle:(0,f.ij)(t,n),title:null==(C=n.chartOptions)?void 0:C.title,dataBox:P,screenBounds:t}),(0,s.jI)(e,{showTitle:(0,f.ij)(t,n),dataBox:P,screenBounds:t,showAxesLabels:(0,f.eG)(t,n),xAxisName:null==(b=n.chartOptions)?void 0:b.xAxisName,yAxisName:null==(w=n.chartOptions)?void 0:w.yAxisName}),Y&&(0,u.GU)(e,n,P,X,Y),e.restore()}render(e,t,n,o,i,l,s){var u,c,f,m,p,y;if(!l.cell.value||o<a.h.MIN_CELL_RENDERER_PX_WIDTH||i<a.h.MIN_CELL_RENDERER_PX_HEIGHT)return;let x=(null==l?void 0:l.grid)&&(null==l?void 0:l.grid.dart)&&e.canvas===(null==l||null==(u=l.grid)?void 0:u.canvas),C=(0,d.h8)(l.cell,x),b=v.inflateScreenBounds(new r.Rect(t,n,o,i));for(let[t,n]of Object.entries(a.h.CONDITION_MAP))if(n(C.series)){return void(p=e,y=b,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=l.cell.column)?void 0:c.name)&&(null==(f=C.series)||f.forEach(e=>e.columnName=l.cell.column.name)),(null==(m=C.chartOptions)?void 0:m.mergeSeries)&&(C=g(h({},C),{series:[(0,d.wU)(C.series)]})),e.clearRect(b.x,b.y,b.width,b.height),this.renderCurves(e,b,C,l)}}v.fittedCurves=d.bZ,v.parsedCurves=d.uc,v.curvesDataPoints=d.CP,v=function(e,t,n,r){var o,i=arguments.length,l=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(l=(i<3?o(l):i>3?o(t,n,l):o(t,n))||l);return i>3&&l&&Object.defineProperty(t,n,l),l}([o.decorators.cellRenderer({name:"Fit",cellType:"fit",virtual:!0})],v)},434(e,t,n){"use strict";n.d(t,{JR:()=>p,TV:()=>d,Uc:()=>m,bW:()=>g,i4:()=>v});var r=n(82),o=n(165),i=n(590),l=n(869),a=n(53),s=n(124);let u={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 d(e,t,n,r,i=!0,l=!0){var s,u;let c=(0,o.zB)(e),f=e.parameters?(0,o.iK)(e,n):(s=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),u=u={parameters:[...(0,a.IY)(e,t,c,n,r,i).parameters]},Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(u)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(u)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(u,e))}),s),m=(0,o.xS)(f,c,(0,a.Xm)(e,t,n,!1,r,i),n);return l?(0,o.KZ)(m,n):m}let f=new Set(o.GO);function m(e,t){var n;let r=null!=(n=e.series)?n:[];if(!r.length)return i.nK;let l=[...(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));l=l.filter(e=>t.has(e.name))}return void 0===t||c.has(t)||(l=l.filter(e=>!f.has(e.name))),l}function p(e,t,n){var a,s,f;let p={logX:null==(a=e.chartOptions)?void 0:a.logX,logY:null==(s=e.chartOptions)?void 0:s.logY},h=new Map,g=[],v=new Set(m(e,t).map(e=>e.name));for(let t=0;t<(null==(f=e.series)?void 0:f.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 s=d(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,l.h5)(s,e.name)));for(let e of i.Al){if(v.has(e))continue;let t=(0,l.Wh)((0,o.zB)(r),e);t&&t.name!==e||(h.has(e)||h.set(e,[]),h.get(e).push((0,l.h5)(s,e)))}}let y={};for(let[e,n]of h)y[e]=n.some(e=>null==e||isNaN(e))?void 0:r.Stats.fromValues(n)[u[t]];for(let e of(c.has(t)&&(0,o.KZ)(y,p),i.Al))if(void 0===y[e])for(let t of g){let n=(0,l.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,i;let l=e.get(t);if(null==l||""===l)return null;let u=e.dataFrame?e.dataFrame.cell(t,e.name):void 0,c=u?(0,a.h8)(u,!0):(0,a.mI)((0,s.HB)((0,a.RH)(l),e),e,n);return(null==(r=c.chartOptions)?void 0:r.allowXZeroes)&&(null==(o=c.chartOptions)?void 0:o.logX)&&(null==(i=c.series)?void 0:i.some(e=>e.points.some(e=>0===e.x)))&&(0,a.B3)(c),{data:c,cell:u}}function g(e,t,n,r,o){var i,a,s,u;let c=h(e,t,o);if(!c)return null;let f=null==(a=c.data.series)?void 0:a[r];if(!f||f.points.every(e=>e.outlier))return null;let m={logX:null==(s=c.data.chartOptions)?void 0:s.logX,logY:null==(u=c.data.chartOptions)?void 0:u.logY};return null!=(i=(0,l.h5)(d(f,r,m,c.cell,!0),n))?i:null}function v(e,t,n,r,o){var i,l;let a=h(e,t,o);return!a||(null==(l=a.data.series)?void 0:l.every(e=>e.points.every(e=>e.outlier)))?null:null!=(i=p(a.data,r,a.cell)[n])?i:null}},684(e,t,n){"use strict";n.d(t,{zF:()=>E,jI:()=>L,yv:()=>N,Yc:()=>g,dT:()=>f,S3:()=>A,HQ:()=>P,qR:()=>T,Ow:()=>I,QW:()=>x,a:()=>C,Z:()=>v,nx:()=>y,mE:()=>h,Zk:()=>O});var r,o=n(82),i=n(165),l=n(788),a=n(18);let s="u">typeof window?window:n.g.window,u=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2});class c{static getUniqueName(e,t,n){return s.grok_Utils_GetUniqueName(e,t,null==n?void 0:n.auto,null==n?void 0:n.idx,null==n?void 0:n.render,null==n?void 0:n.choices)}static escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\\/-]/g,"\\$&")}static isEmpty(e){return null==e||""==e}static formatNumber(e){return u.format(e)}}var d=n(869);let f=8,m='11px Roboto, "Roboto Local"';function p(e,t,n,r,i){if(!e)return;let l=t.measureText(n).width;for(let t=r;t<=r+l;t+=f)e.push(new o.Point(t,i))}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,i=t.points[n].y,l=r.xToScreen(o),a=r.yToScreen(i);0===n?e.moveTo(l,a):e.lineTo(l,a)}e.stroke()}}function x(e,t,n){var r;let i=n.screenBounds;(i.width<l.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||i.height<l.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,i=l.h.POINT_PX_SIZE*r,a=n.viewport,s=t.connectDots,u=v(t,n.seriesIdx,"pointColor"),c=v(t,n.seriesIdx,"outlierColor");for(let f=0;f<t.points.length;f++){let m=t.points[f];if(m.outlier&&!t.showOutliers)continue;let p=a.xToScreen(m.x),h=a.yToScreen(m.y),g=s?u:m.outlier?m.outlierColor&&o.Color.fromHtml(m.outlierColor)?m.outlierColor:c:m.color&&o.Color.fromHtml(m.color)?m.color:u,v=m.marker?m.marker:t.markerType,y=m.outlierMarker?m.outlierMarker:t.outlierMarkerType,x=Math.min(l.h.OUTLIER_PX_SIZE*r,a.screen.height/10),b=s?i:m.outlier?x:m.size?m.size:i,w=s?v:m.outlier?y:v;if(o.Paint.marker(e,w,p,h,g,b),m.stdev&&!m.outlier){let t=b/2,i=C(h,a.yToScreen(m.y+m.stdev),a.yToScreen(m.y-m.stdev),t);if(i){var d;null==(d=n.drawnAt)||d.push(new o.Point(p,i.top[0]),new o.Point(p,i.bottom[1])),e.strokeStyle=g,e.lineWidth=r,e.beginPath(),e.moveTo(p,i.top[0]),e.lineTo(p,i.top[1]),e.moveTo(p,i.bottom[0]),e.lineTo(p,i.bottom[1]),e.moveTo(p-t,i.top[0]),e.lineTo(p+t,i.top[0]),e.moveTo(p-t,i.bottom[1]),e.lineTo(p+t,i.bottom[1]),e.stroke()}}}}(e,t,n):["candlesticks","both"].includes(t.showPoints)&&function(e,t,n){let r=n.ratio,i=n.viewport,s=v(t,n.seriesIdx,"pointColor");for(let n=0,u=null;n<t.points.length;n++){let c=t.points[n];if(c.outlier)continue;let d=n+1<t.points.length&&t.points[n+1].x===c.x;if(!u&&d)u=n;else if(null!==u&&!d){let d=[];for(let e=u,r=0;e<=n;e++,r++)d[r]=t.points[e].y;let f=(0,a.k)(d);if(e.beginPath(),function(e,t){let n=t.viewport,r=t.x,i=n.xToScreen(r),a=t.boxPlotStats;b(e,r,a.lowerAdjacentValue,n),e.moveTo(i,n.yToScreen(a.lowerAdjacentValue)),e.lineTo(i,n.yToScreen(a.upperAdjacentValue)),b(e,r,a.upperAdjacentValue,n),o.Paint.marker(e,o.MARKER_TYPE.CIRCLE,i,n.yToScreen(a.q2),t.color,l.h.CANDLESTICK_MEDIAN_PX_SIZE*t.ratio)}(e,{viewport:i,ratio:r,x:c.x,boxPlotStats:f,color:s}),e.stroke(),"both"===t.showPoints)for(let t=0;t<d.length;t++)(d[t]<f.lowerAdjacentValue||d[t]>f.upperAdjacentValue)&&o.Paint.marker(e,o.MARKER_TYPE.OUTLIER,i.xToScreen(c.x),i.yToScreen(d[t]),s,l.h.CANDLESTICK_OUTLIER_PX_SIZE*r);u=null}}}(e,t,n))}function C(e,t,n,r){return e-t<=r?null:{top:[t,e-r],bottom:[e+r,n]}}function b(e,t,n,r){let o=r.xToScreen(t),i=r.yToScreen(n);e.moveTo(o-l.h.CANDLESTICK_BORDER_PX_SIZE/2,i),e.lineTo(o+l.h.CANDLESTICK_BORDER_PX_SIZE/2,i)}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 T(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(l.h.LINE_STYLES[t.lineStyle]);let{logX:r,logY:i,xMin:a,xMax:s,viewport:u}=w(n),c=n.curveFunc;for(let t=a;t<=s;t++){let l=r?Math.log10(u.xToWorld(t)):u.xToWorld(t),s=i?u.yToScreen(Math.pow(10,c(l))):u.yToScreen(c(l));n.drawnAt&&t%f==0&&n.drawnAt.push(new o.Point(t,s)),t===a?e.moveTo(t,s):e.lineTo(t,s)}e.stroke(),e.restore()}}function O(e,t,n){var r,o,a,s;if((null==(r=t.showFitLine)||r)&&null!=(o=t.showCurveConfidenceInterval)&&o){e.strokeStyle=null!=(a=t.confidenceIntervalColor)?a:l.h.CONFIDENCE_INTERVAL_STROKE_COLOR,e.fillStyle=null!=(s=t.confidenceIntervalColor)?s:l.h.CONFIDENCE_INTERVAL_FILL_COLOR;let r=n.showAxes,o=n.showAxesLabels,u=n.logOptions,c=n.viewport,d=n.screenBounds,f=n.dataPoints,m=(0,i.fY)(t,n.fitFunc,n.userParamsFlag,f,u);S(e,{viewport:c,logOptions:u,showAxes:r,showAxesLabels:o,screenBounds:d,confidenceIntervals:m,confidenceType:l.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP}),S(e,{viewport:c,logOptions:u,showAxes:r,showAxesLabels:o,screenBounds:d,confidenceIntervals:m,confidenceType:l.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.BOTTOM}),function(e,t){e.beginPath();let{logX:n,logY:r,xMin:o,xMax:i,viewport:l}=w(t),a=t.confidenceIntervals.confidenceTop,s=t.confidenceIntervals.confidenceBottom;for(let t=o;t<=i;t++){let i=n?Math.log10(l.xToWorld(t)):l.xToWorld(t),s=r?l.yToScreen(Math.pow(10,a(i))):l.yToScreen(a(i));t===o?e.moveTo(t,s):e.lineTo(t,s)}for(let t=i;t>=o;t--){let o=n?Math.log10(l.xToWorld(t)):l.xToWorld(t),i=r?l.yToScreen(Math.pow(10,s(o))):l.yToScreen(s(o));e.lineTo(t,i)}e.closePath(),e.fill()}(e,{viewport:c,logOptions:u,showAxes:r,showAxesLabels:o,screenBounds:d,confidenceIntervals:m})}}function S(e,t){e.beginPath();let{logX:n,logY:r,xMin:i,xMax:a,viewport:s}=w(t),u=t.confidenceType===l.h.CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP?t.confidenceIntervals.confidenceTop:t.confidenceIntervals.confidenceBottom;for(let l=i;l<=a;l++){let a=n?Math.log10(s.xToWorld(l)):s.xToWorld(l),c=r?s.yToScreen(Math.pow(10,u(a))):s.yToScreen(u(a));t.drawnAt&&l%f==0&&t.drawnAt.push(new o.Point(l,c)),l===i?e.moveTo(l,c):e.lineTo(l,c)}e.stroke()}function I(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}function P(e,t,n){var r,i;if(!(null==(r=t.showFitLine)||r)||!(null==(i=t.droplines)?void 0:i.length)||!t.parameters||!n.showDroplines)return;e.save(),e.strokeStyle="blue",e.lineWidth=n.ratio,e.beginPath(),e.setLineDash([5,5]);let l=[];for(let r of t.droplines){let i=I(r),a=void 0===i?void 0:n.fitFunc.inverse(Float32Array.from(t.parameters),i),s=void 0===a?null:function(e,t,n){let r=n.logOptions.logX,i=n.logOptions.logY,l=r?Math.pow(10,t):t,a=n.viewport,s=n.dataBounds;if(l<s.minX||l>s.maxX)return null;let u=r?Math.log10(l):l,c=i?Math.pow(10,n.curveFunc(u)):n.curveFunc(u),d=a.xToScreen(l),m=a.yToScreen(c),p=a.xToScreen(s.minX),h=a.yToScreen(s.minY);if(e.moveTo(p,m),e.lineTo(d,m),e.lineTo(d,h),n.drawnAt){for(let e=p;e<=d;e+=f)n.drawnAt.push(new o.Point(e,m));for(let e=m;e<=h;e+=f)n.drawnAt.push(new o.Point(d,e))}return m}(e,a,n);null!==s&&l.push({name:r,screenY:s})}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 l)e.fillText(n.name,t,n.screenY-3)}e.restore()}function _(e){return 0!==e&&(.001>Math.abs(e)||Math.abs(e)>=1e6)?o.format(e,"scientific"):c.formatNumber(e)}function A(e,t,n){var r,o;let i=n.screenBounds,a=i.width<l.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||i.height<l.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT?[]:n.names;if(!t||!a||0===a.length)return 0;let s=n.dataBox;e.font=m;let u=null!=(r=n.startLine)?r:0;for(let r of a){let o=t[r];if(null==o)continue;let i=s.y+15*(u+1);if(i>s.maxY)break;e.fillStyle=n.color,e.textAlign="left";let l=`${r}: ${"number"==typeof o?_(o):o}`;e.fillText(l,s.x+5,i),p(n.drawnAt,e,l,s.x+5,i),u++}return u-(null!=(o=n.startLine)?o:0)}function N(e,t,n){var r,o,a;let s=n.screenBounds,u=s.width<l.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH||s.height<l.h.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT?[]:n.statistics;if(!((null==(r=t.showFitLine)||r)&&u&&u.length>0))return 0;let c=n.dataBox,f=n.dataPoints,h=n.fitFunc,g=(0,i.KZ)((0,i.xS)(t,h,f,n.logOptions),n.logOptions),y=v(t,n.seriesIdx,"fitLineColor");e.font=m;let x=null!=(o=n.startLine)?o:0;for(let t of u){let r=(0,d.h5)(g,t),o=(0,d.Wh)(h,t);if(void 0===r||!o)continue;let i=c.y+15*(x+1);if(i>c.maxY)break;e.fillStyle=y,e.textAlign="left";let l=`${o.friendlyName}: ${_(r)}`;e.fillText(l,c.x+5,i),p(n.drawnAt,e,l,c.x+5,i),x++}return x-(null!=(a=n.startLine)?a:0)}function E(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 L(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-l.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?l.h.AXES_TOP_PX_MARGIN_WITH_TITLE:l.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:()=>f,b6:()=>m,fM:()=>d,rn:()=>c});var r=n(82),o=n(590);function i(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 l(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=l(e,t);return null!=(n=null==o||null==(r=o.textContent)?void 0:r.trim())?n:""}function s(e){let t=i(e,"d"),n=[],r=[];for(let e of t){var o,l;let t=null!=(o=null==(l=e.textContent)?void 0:l.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 u(e){return{title:a(e,"Title"),subcolumns:i(e,"Subcolumn").map(s)}}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:"",d=null!=(r=e.getAttribute("XFormat"))?r:"",f=a(e,"Title"),m="",p=[],h=l(e,"XColumn");if(h){m=a(h,"Title");let e=l(h,"Subcolumn");e&&(p=s(e).values)}return{id:o,title:f,tableType:c,xFormat:d,xTitle:m,xValues:p,yColumns:i(e,"YColumn").map(u)}}(t))}return o}function d(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 i=t.values[n];null!=i&&r.push({x:o,y:i,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 f(e){let t=e.filter(e=>"XY"===e.tableType),n=[],o=[];for(let e of t){let t=d(e);t&&(n.push(e.title||e.id),o.push(JSON.stringify(t)))}let i=r.DataFrame.create(n.length);i.setTag(r.Tags.Id,crypto.randomUUID()),i.name="PZFX Curves";let l=i.columns.addNewString("Table");for(let e=0;e<n.length;e++)l.set(e,n[e]);let a=i.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 i}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,i;if(1===t.subcolumns.length){let e=n.columns.addNewFloat(t.title||"Values"),i=t.subcolumns[0];for(let t=0;t<i.values.length;t++)e.set(t,null!=(o=i.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}`),l=t.subcolumns[e];for(let e=0;e<l.values.length;e++)o.set(e,null!=(i=l.values[e])?i:r.FLOAT_NULL)}}return n}},982(e,t,n){"use strict";n.d(t,{_package:()=>M});var r=n(82),o=n(389),i=n(328),l=n(53),a=n(590);let s=rxjs.operators;var u=n(858),c=n(788),d=n(129),f=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,l.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 i=this.props.get("mergeCellSeries"),s=[];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,l.h8)(o);if(!a.series||0===a.series.length)continue;let u=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 u)e.auxLegendName=u.length>1?`${c.get(n)} ${e.name}`:`${c.get(n)}`;let d=a.chartOptions;if(null!=d&&(s[s.length]=d),i){let e=(0,l.wU)(u);(null==d?void 0:d.title)!==void 0&&(null==d?void 0:d.title)!==""&&(e.name=null==d?void 0:d.title),u=[e]}let f=(0,l.U6)(a);r.push(...u.map((e,t)=>`${f} || idx: ${i?"merged":t}`)),t.push(...u)}0!==t.length&&(null==(n=this.data.series)||n.push(...JSON.parse(JSON.stringify(this.mergeColumnSeries?[(0,l.wU)(t)]:t))),this.fitIdentities.push(...this.mergeColumnSeries?[void 0]:r))}for(let e of(this.data.chartOptions=(0,l.LX)(s,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,i,l,a,s;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==(s=this.data.series)?void 0:s.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==(i=this.data.series)?void 0:i.length)>10&&(null==(l=this.data.series)?void 0:l.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,i;(null==e?void 0:e.name)==="curvesColumnNames"&&(this.props.set("showColumnLabel",(null==(o=this.curvesColumnNames)?void 0:o.length)>1),this.showColumnLabel=(null==(i=this.curvesColumnNames)?void 0:i.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,u.merge)(this.dataFrame.onCurrentCellChanged,...t?[t.onCellMouseEnter]:[],this.dataFrame.onSelectionChanged).pipe((0,s.tap)(()=>this.renderPending=!0),(0,s.debounce)(e=>(0,u.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 d.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 i=super.getWidgetStatus(),l=(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===l?null:(0,m.QK)(this.data,this.chartBounds()),s=h(p({},i.values),{curves:l,"legend shown":null!==a}),u=p({},i.hitAreas);if(l>0){let e=new d.l().layOutChart(this.chartBounds(),this.data,void 0,this.fitIdentities).dataBounds,t=e=>Number(e.toPrecision(4));s["x range"]=`${t(e.minX)} .. ${t(e.maxX)}`,s["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};s["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;u[`${o?"":"shortened "}legend row ${e+1}`]=t(r.box),s[`legend row ${e+1}`]=r.shown,o||n.push(e+1)}a.moreBox&&(u["legend more"]=t(a.moreBox)),s["legend corner"]=m.$$[a.corner],s["legend rows"]=a.rows.length,s["legend shortened rows"]=n.join(", "),s["legend hidden"]=a.entries.length-a.rows.length}return h(p({},i),{parts:h(p({},i.parts),{canvas:this.canvas}),hitAreas:u,values:s})}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 u.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,f.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)}}}y=function(e,t,n,r){var o,i=arguments.length,l=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(l=(i<3?o(l):i>3?o(t,n,l):o(t,n))||l);return i>3&&l&&Object.defineProperty(t,n,l),l}([i.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 x=n(181),C=n(434),b=n(301),w=n(190),T=n(287),O=n(305),S=n(124),I=n(869),P=n(1),_=n(886);function A(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function N(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){A(i,r,o,l,a,"next",e)}function a(e){A(i,r,o,l,a,"throw",e)}l(void 0)})}}function E(e,t,n,r){var o,i=arguments.length,l=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(l=(i<3?o(l):i>3?o(t,n,l):o(t,n))||l);return i>3&&l&&Object.defineProperty(t,n,l),l}function L(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function F(e,t){return function(n,r){t(n,r,e)}}let M=new r.Package,R=".sourceColumn",D=".statistics";class X{static runWhenDone(e){return N(function*(){return X._currentPromise=X._currentPromise.then(()=>N(function*(){try{return yield e()}catch(e){M.logger.error(e)}})()),X._currentPromise})()}}X._currentPromise=Promise.resolve();class Y{static curveFitDemo(){return N(function*(){yield(0,b.Z1)()})()}static assayCurveFitDemo(){return N(function*(){yield(0,b.pj)()})()}static _initCurves(){return N(function*(){r.ObjectHandler.register(new x.e),(0,S.l8)("3dx",w.J),(0,S.l8)("compact-dr",T.G),(0,S.l8)("pzfx",O.R),yield(0,S.p)()})()}static dataToCurves(e,t,n,r,o,i,l,a,s,u,c,d,f,m,p,h,g,v,y){return N(function*(){var x,C,b,w;let T=u&&g&&v&&e.col(g)&&u.col(v)?{wellLevelCol:e.col(g),parentLevelCol:u.col(v)}:void 0,O=(null!=y?y:[]).map(t=>e.col(t)).filter(e=>null!=e);return(0,P.p)(e,t,n,r,o,i,l,a,s,{table:u,fitParamColumns:(null!=c?c:[]).map(e=>null==u?void 0:u.col(e)).filter(e=>null!=e),reportedIC50Column:d&&null!=(x=null==u?void 0:u.col(d))?x:void 0,reportedQualifiedIC50Column:f&&null!=(C=null==u?void 0:u.col(f))?C:void 0,experimentIDColumn:m&&null!=(b=null==u?void 0:u.col(m))?b:void 0,qualifierColumn:p&&null!=(w=null==u?void 0:u.col(p))?w:void 0,additionalColumns:(null!=h?h:[]).map(e=>null==u?void 0:u.col(e)).filter(e=>null!=e)},T,O)})()}static dataToCurvesTopMenu(){return N(function*(){(0,P.w)()})()}static curveStatistic(e,t,n,o){let i=r.Column.float(`${t.name} ${o+1} ${n}`,t.length);return i.init(r=>(0,C.bW)(t,r,n,o,e)),i}static curveAggrStatistic(e,t,n,o){let i=r.Column.float(`${t.name} ${o} ${n}`,t.length);return i.init(r=>(0,C.i4)(t,r,n,o,e)),i}static addStatisticsColumn(e,t,n,o){let i=e.col(t),a=i.name,s=e.columns.getUnusedName(`${t} ${o+1} ${n}`),u=r.Column.float(s,i.length);return u.tags[R]=i.name,u.tags[".seriesNumber"]=null==o?void 0:o.toString(),u.tags[D]=n,u.init(t=>{var r,i,s,u,c,d;let f=e.cell(t,a);if(!f||!f.value)return null;let m=(0,l.h8)(f,!0);if(void 0===m.series[o]||m.series[o].points.every(e=>e.outlier))return null;(null==(i=m.chartOptions)?void 0:i.allowXZeroes)&&(null==(s=m.chartOptions)?void 0:s.logX)&&(null==(u=m.series)?void 0:u.some(e=>e.points.some(e=>0===e.x)))&&(0,l.B3)(m);let p={logX:null==(c=m.chartOptions)?void 0:c.logX,logY:null==(d=m.chartOptions)?void 0:d.logY},h=(0,C.TV)(m.series[o],o,p,f,!0);return null!=(r=(0,I.h5)(h,n))?r:null}),e.columns.insert(u,e.columns.names().indexOf(t)+1),u}static addAggrStatisticsColumn(e,t,n,o){let i=e.col(t),a=`${t} ${o} ${n}`,s=r.Column.float(e.columns.getUnusedName(a),null==i?void 0:i.length);return s.tags[R]=t,s.tags[".seriesAggregation"]=o,s.tags[D]=n,s.init(r=>{var i,a,s,u;let c=e.cell(r,t);if(!c||!c.value)return null;let d=(0,l.h8)(c);return(null==(i=d.series)?void 0:i.every(e=>e.points.every(e=>e.outlier)))?null:((null==(a=d.chartOptions)?void 0:a.allowXZeroes)&&(null==(s=d.chartOptions)?void 0:s.logX)&&(null==(u=d.series)?void 0:u.some(e=>e.points.some(e=>0===e.x)))&&(0,l.B3)(d),(0,C.JR)(d,o,c)[n])}),e.columns.insert(s,e.columns.names().indexOf(t)+1),s}static addCurveStatistic(e,t,n="interceptX",r=0){return Y.addStatisticsColumn(e,t.name,n,r)}static addAggrCurveStatistic(e,t,n="interceptX",r="med"){return Y.addAggrStatisticsColumn(e,t.name,n,r)}static convertXmlCurveToJsonFunc(){return w.J}static convertCompactDrToJsonFunc(){return T.G}static convertPzfxToJsonFunc(){return O.R}static previewPzfx(e){return N(function*(){let t=r.View.create();t.name=e.name;let n=yield e.readAsString(),o=(0,_.rn)(n),i=o.filter(e=>"XY"===e.tableType);if(0===i.length){for(let e of o.map(_.b6))t.append(r.Viewer.grid(e).root);return t}let l=(0,_.aI)(i),a=r.Viewer.grid(l);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,_.rn)(t),r=[],o=n.filter(e=>"XY"===e.tableType);for(let e of(o.length>0&&r.push((0,_.aI)(o)),n.filter(e=>"XY"!==e.tableType)))r.push((0,_.b6)(e));return r}}E([i.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"}}),L("design:type",Function),L("design:paramtypes",[]),L("design:returntype",Promise)],Y,"curveFitDemo",null),E([i.decorators.demo({name:"Assay Curves",description:"Dashboard with curves for multiple compounds, assays and targets",meta:{demoPath:"Curves | Assay Curves"}}),L("design:type",Function),L("design:paramtypes",[]),L("design:returntype",Promise)],Y,"assayCurveFitDemo",null),E([i.decorators.init(),L("design:type",Function),L("design:paramtypes",[]),L("design:returntype",Promise)],Y,"_initCurves",null),E([i.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."}),F(1,i.decorators.param({type:"column",options:{type:"numerical",nullable:!1,description:"Concentration (dose) column"}})),F(2,i.decorators.param({type:"column",options:{type:"numerical",nullable:!1,description:"Readout (response) column"}})),F(3,i.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Batch identifier column"}})),F(4,i.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Assay name column"}})),F(5,i.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Run identifier column"}})),F(6,i.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Compound identifier column"}})),F(7,i.decorators.param({type:"column",options:{type:"categorical",nullable:!1,description:"Target entity column"}})),F(8,i.decorators.param({type:"column",options:{nullable:!0,description:"Boolean column marking points to exclude as outliers"}})),F(9,i.decorators.param({options:{nullable:!0}})),F(10,i.decorators.param({options:{nullable:!0}})),F(11,i.decorators.param({options:{nullable:!0}})),F(12,i.decorators.param({options:{nullable:!0}})),F(13,i.decorators.param({options:{nullable:!0}})),F(14,i.decorators.param({options:{nullable:!0}})),F(15,i.decorators.param({options:{nullable:!0}})),F(16,i.decorators.param({options:{nullable:!0}})),F(17,i.decorators.param({options:{nullable:!0}})),F(18,i.decorators.param({options:{nullable:!0,optional:!0}})),L("design:type",Function),L("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]),L("design:returntype",Promise)],Y,"dataToCurves",null),E([i.decorators.func({"top-menu":"Data | Curves | Data to Curves",requiresTableView:!0,outputs:[{name:"result",type:"dynamic"}]}),L("design:type",Function),L("design:paramtypes",[]),L("design:returntype",Promise)],Y,"dataToCurvesTopMenu",null),E([i.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)"}}]}),F(1,i.decorators.param({type:"column",options:{semType:"fit",nullable:!1,description:"Curve column to read"}})),F(2,i.decorators.param({options:{nullable:!1,description:"Fit statistic to extract (e.g. ic50, auc, rSquared)"}})),F(3,i.decorators.param({type:"int",options:{nullable:!1,description:"Zero-based index of the curve series"}})),L("design:type",Function),L("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,Number]),L("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],Y,"curveStatistic",null),E([i.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)"}}]}),F(1,i.decorators.param({type:"column",options:{semType:"fit",nullable:!1,description:"Curve column to read"}})),F(2,i.decorators.param({options:{nullable:!1,description:"Fit statistic to aggregate"}})),F(3,i.decorators.param({options:{choices:["avg","med","min","max","q1","q2","q3"],initialValue:"med",nullable:!1,description:"Aggregation applied across the series of each curve"}})),L("design:type",Function),L("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,String]),L("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],Y,"curveAggrStatistic",null),E([i.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"}}),F(1,i.decorators.param({options:{description:"Name of the curve column to read"}})),F(2,i.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"}})),F(3,i.decorators.param({type:"int",options:{initialValue:"0",description:"Zero-based index of the curve series"}})),L("design:type",Function),L("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,String,String,Number]),L("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],Y,"addStatisticsColumn",null),E([i.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"}}),F(1,i.decorators.param({options:{description:"Name of the curve column to read"}})),F(2,i.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"}})),F(3,i.decorators.param({options:{choices:["min","max","avg","med","q1","q2","q3"],initialValue:"med",description:"Aggregation applied across the series of each curve"}})),L("design:type",Function),L("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,String,String,String]),L("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],Y,"addAggrStatisticsColumn",null),E([i.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"}}),F(0,i.decorators.param({options:{caption:"Table",nullable:!1}})),F(1,i.decorators.param({type:"column",options:{semType:"fit",caption:"Curves",nullable:!1,description:"Column of fitted curves"}})),F(2,i.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"}})),F(3,i.decorators.param({type:"int",options:{caption:"Series",nullable:!1,initialValue:"0",description:"Zero-based index of the curve series"}})),L("design:type",Function),L("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,Number]),L("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],Y,"addCurveStatistic",null),E([i.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"}}),F(0,i.decorators.param({options:{caption:"Table",nullable:!1}})),F(1,i.decorators.param({type:"column",options:{semType:"fit",caption:"Curves",nullable:!1,description:"Column of fitted curves"}})),F(2,i.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"}})),F(3,i.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"}})),L("design:type",Function),L("design:paramtypes",[void 0===r||void 0===r.DataFrame?Object:r.DataFrame,void 0===r||void 0===r.Column?Object:r.Column,String,String]),L("design:returntype",void 0===r||void 0===r.Column?Object:r.Column)],Y,"addAggrCurveStatistic",null),E([i.decorators.func({description:"Returns XML 3DX curve converter function",meta:{role:"curveConverter",curveFormat:"3dx"}}),L("design:type",Function),L("design:paramtypes",[]),L("design:returntype",Function)],Y,"convertXmlCurveToJsonFunc",null),E([i.decorators.func({description:"Returns compact dose-response JSON converter function",meta:{role:"curveConverter",curveFormat:"compact-dr"}}),L("design:type",Function),L("design:paramtypes",[]),L("design:returntype",Function)],Y,"convertCompactDrToJsonFunc",null),E([i.decorators.func({description:"Returns PZFX curve converter function",meta:{role:"curveConverter",curveFormat:"pzfx"}}),L("design:type",Function),L("design:paramtypes",[]),L("design:returntype",Function)],Y,"convertPzfxToJsonFunc",null),E([i.decorators.fileViewer({fileViewer:"pzfx"}),L("design:type",Function),L("design:paramtypes",[void 0===r||void 0===r.FileInfo?Object:r.FileInfo]),L("design:returntype",Promise)],Y,"previewPzfx",null),E([i.decorators.fileHandler({ext:"pzfx",description:"Open a GraphPad Prism (.pzfx) file as data tables, fitting XY curve tables."}),F(0,i.decorators.param({type:"list",options:{description:"Raw bytes of the .pzfx file"}})),L("design:type",Function),L("design:paramtypes",["u"<typeof Uint8Array?Object:Uint8Array]),L("design:returntype",Array)],Y,"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)],i=t[Math.trunc(3*t.length/4)],l=1.5*(i-n),a=o(t,i+l);a<0&&(a=~a);let s=t[Math.max(0,a-1)];s<i&&(s=i);let u=o(t,n-l);u<0&&(u=~u);let c=t[u];return c>n&&(c=n),{q1:n,q2:r,q3:i,lowerAdjacentValue:c,upperAdjacentValue:s}}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:()=>b,Al:()=>l,EV:()=>w,Ff:()=>f,G7:()=>d,Hr:()=>I,Mi:()=>S,Pf:()=>p,Qx:()=>g,Sm:()=>T,Vd:()=>O,Z5:()=>v,ah:()=>y,dZ:()=>i,h1:()=>a,kC:()=>h,kx:()=>m,nK:()=>u,oH:()=>s,ry:()=>x,sn:()=>C,xs:()=>c});var r=n(82),o=n(353);let i={CONSTANT:"constant",PROPORTIONAL:"proportional",COMBINED:"combined"},l=["rSquared","auc","interceptX","interceptY","slope","top","bottom"],a=["IC10","IC20","IC50","IC80","IC90"];class s{constructor(){this.chartOptions={},this.seriesOptions={},this.series=[]}}let u=[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:u.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"})],d="sigmoid",f="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 x(e,t){let n=e[0],r=e[1],o=e[2],i=e[3];return i+(n-i)/(1+Math.pow(10,(t-o)*r))}function C(e,t){return e[0]*t+e[1]}function b(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],i=e[3];return i+(n-i)/(1+Math.pow(t/o,r))}function O(e,t){let n=e[3];return n+(e[0]-n)/(1+Math.pow(10,e[1]*(e[2]-t)))}function S(e,t){let n=0,r=Math.min(...t.x),o=Math.max(...t.x),i=(o-r)/1e3;for(let t=r;t<o;t+=i)n+=i*e(t);return n}function I(e,t){let n=0,r=0,i=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]-i,2);return 1-n/r}},165(e,t,n){"use strict";n.d(t,{GO:()=>x,KZ:()=>b,Kh:()=>s,VA:()=>g,W$:()=>u,_T:()=>m,fY:()=>p,iK:()=>C,s$:()=>d,xS:()=>h,zB:()=>f});var r=n(82),o=n(590),i=n(869),l=n(774);function a(e){let t={};var n=!0,r=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done);n=!0){let e=i.value;null!==e.defaultValue&&(t[e.name]=e.defaultValue)}}catch(e){r=!0,o=e}finally{try{n||null==l.return||l.return()}finally{if(r)throw o}}return t}function s(){return{chartOptions:a(o.xs),seriesOptions:a(i.IL)}}function u(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,i=e.left,l=e.right,a=e.top,s=e.bottom;if(t.logX)i=i>0?i/(1+o):i,l*=1+o;else{let t=e.width*o;i-=t,l+=t}if(t.logY)a=a>0?a/(1+o):a,s*=1+o;else{let t=e.height*o;a-=t,s+=t}return new r.Rect(i,a,l-i,s-a)}function d(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,i,l,a,s,d=u(e.series[0].points),f=d.xs,m=d.ys,p=r.Rect.fromXYArrays(f,m);for(let t=1;t<e.series.length;t++){let n=u(e.series[t].points),o=n.xs,i=n.ys;o.some(e=>void 0===e)||i.some(e=>void 0===e)||(p=p.union(r.Rect.fromXYArrays(o,i)))}return o?(i=(t=c(n=p,o)).x,l=t.y,a=t.width,s=t.height,null!=o.minX&&o.minX<=n.maxX&&(!o.logX||o.logX&&o.minX>0)&&(a+=i-o.minX,i=o.minX),null!=o.maxX&&o.maxX>=n.minX&&(!o.logX||o.logX&&o.maxX>0)&&(a+=o.maxX-(i+a)),null!=o.minY&&o.minY<=n.maxY&&(!o.logY||o.logY&&o.minY>0)&&(s+=l-o.minY,l=o.minY),null!=o.maxY&&o.maxY>=n.minY&&(!o.logY||o.logY&&o.maxY>0)&&(s+=o.maxY-(l+s)),new r.Rect(i,l,a,s)):c(p,o)}}function f(e){return(0,i.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 s,u;null!=r||(r=(0,l.Sm)(e,a,n));let c=null!=(s=e.parameters)?s:(0,i.nT)(e,t,r).parameters,d=new Float32Array(c.length);return d.set(c),(0,i.O8)(r,d,t.y,.05,null!=(u=e.errorModel)?u:o.dZ.CONSTANT)}function h(e,t,n,r){var a;null!=n||(n=(0,l.Sm)(e,r,!1));let s=null!=(a=e.parameters)?a:(0,i.nT)(e,t,n).parameters,u=new Float32Array(s.length);return u.set(s),t.fillParams({fittedCurve:(0,o.ah)(t.y,u),parameters:u},e,n,r)}function g(e,t,n,r){var o;return o=h(e,t,n,r),{rSquared:(0,i.h5)(o,"rSquared"),auc:(0,i.h5)(o,"auc"),interceptX:(0,i.h5)(o,"interceptX"),interceptY:(0,i.h5)(o,"interceptY"),slope:(0,i.h5)(o,"slope"),top:(0,i.h5)(o,"top"),bottom:(0,i.h5)(o,"bottom")}}let v=["ic50","ec50"],y=[],x=["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=f(e).statisticFields,i=[...e.parameters],l=!1;for(let e=0;e<i.length&&e<o.length;e++)(t.logX&&v.includes(o[e])||t.logY&&y.includes(o[e]))&&i[e]>0&&(i[e]=Math.log10(i[e]),l=!0);return l?(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:i},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 i,l=t[Symbol.iterator]();!(n=(i=l.next()).done);n=!0){let t=i.value;"number"==typeof e[t]&&(e[t]=Math.pow(10,e[t]))}}catch(e){r=!0,o=e}finally{try{n||null==l.return||l.return()}finally{if(r)throw o}}};return(null==t?void 0:t.logX)&&n(v),(null==t?void 0:t.logY)&&n(y),"number"==typeof e.ic50&&e.ic50>0&&(e.pIC50=-Math.log10(e.ic50)),e}},869(e,t,n){"use strict";n.d(t,{nT:()=>U,IL:()=>H,HM:()=>V,hD:()=>B,rT:()=>G,ou:()=>q,TV:()=>J,O8:()=>Z,h5:()=>D,Wh:()=>R,ct:()=>W,JS:()=>$,Z2:()=>y});var r,o,i=n(82),l=n(590),a=n(774),s=n(353);class u 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 d(e,t,n,r,o,i,l,a){for(let s=0;s<i;s++)t[s]=e[s],t[s]+=o*(e[s]-r[n][s]),t[s]<l[s]?t[s]=l[s]:t[s]>a[s]&&(t[s]=a[s])}(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 f=function(e,t,n,r,o){var i;let l=n.tolerance,a=n.maxIter,s=n.scaleReflection,u=n.scaleExpansion,f=n.scaleContraction,m=t.length+1,p=t.length,h=function(e){if(Array.isArray(e))return e}(i=function(e,t,n,r,o){let i=n.length+1,l=n.length,a=t.nonZeroParam,s=t.initialScale,u=Array(i),c=Array(i);for(let t=0;t<i;t++){u[t]=new Float32Array(l);for(let e=0;e<l;e++)u[t][e]=n[e],0!==t&&t-1===e&&(0===n[e]?u[t][e]=a:u[t][e]+=s*n[t-1],u[t][e]<r[e]?u[t][e]=r[e]:u[t][e]>o[e]&&(u[t][e]=o[e]));c[t]=e(u[t]).likelihood}return[u,c]}(e,n,t,r,o))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,l=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(l)throw n}}return o}}(i)||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)}}(i)||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 x=y.length-1,C=0,b=0,w=0,T=0,O=new Float32Array(p),S=new Float32Array(p),I=new Float32Array(p),P=new Float32Array(p),_=Array(a);if(m>1){for(;y.sort((e,t)=>v[e]-v[t]),!(C>a);){if(0===C&&(b=v[0],w=2*v[y[0]]),_[C]=b,++C,w-(b=v[y[0]])>l)T=0;else if(++T>2*m)break;w=b,function(e,t,n,r){for(let o=0;o<t;o++){let i=0;for(let e=0;e<t+1;e++)e!==n&&(i+=r[e][o]);e[o]=i/t}}(O,p,y[x],g),d(O,S,y[x],g,s,p,r,o);let t=e(S).likelihood;if(t<v[y[x]]){d(O,I,y[x],g,u,p,r,o);let n=e(I).likelihood;if(n<t){v[y[x]]=n;for(let e=0;e<p;e++)g[y[x]][e]=I[e];continue}v[y[x]]=t;for(let e=0;e<p;e++)g[y[x]][e]=S[e];continue}d(O,P,y[x],g,f,p,r,o);let n=e(P).likelihood;if(n<v[y[x]]){v[y[x]]=n;for(let e=0;e<p;e++)g[y[x]][e]=P[e];continue}break}for(let e=C;e<a;e++)_[e]=v[y[0]]}return{point:g[y[0]],cost:v[y[0]],iterCosts:_,iterCount:C-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,[...A,...e.map((e,n)=>_(e,t[n])),...void 0===n?[]:n])),this._statisticsProperties}legacyStatisticProperty(e){var t,n;if("interceptY"===e)return M;let r=F[e];if(void 0!==r&&!(r>=this.parameterNames.length))return null!=this._legacyProperties||(this._legacyProperties={}),null!=(t=(n=this._legacyProperties)[e])?t:n[e]=_(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 x{constructor(e,t,n){this.auc=e.auc,this.rSquared=e.rSquared,this.series=t,this.parameters=n}}let C=["auc","rSquared","series","parameters","name"];class b extends x{get name(){return l.Z5}constructor(e,t,n,r,o){let i=void 0===r?[]:r;super(e,t,n);for(let e=0;e<i.length;e++)C.includes(i[e])||(this[i[e]]=n[e]);o&&n.length>2&&void 0===this.interceptY&&(this.interceptY=o(n[2]))}}class w extends x{get name(){return l.Ff}constructor(e,t,n){super(e,t,n),this.slope=e.slope,this.intercept=e.intercept}}class T extends w{get name(){return l.kx}}class O extends x{get name(){return l.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 S extends x{get name(){return l.Pf}constructor(e,t,n){super(e,t,n),this.mantissa=e.mantissa,this.power=e.power}}class I extends x{get name(){return l.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 P extends I{get name(){return l.Qx}constructor(e,t,n){super(e,t,n),this.ic50=e.ec50}}function _(e,t){return i.Property.js(e,i.TYPE.FLOAT,{userEditable:!1,friendlyName:t})}let A=[_("rSquared","R\xb2"),_("auc","AUC")];function N(e){return[_("interceptY",`Y at ${e}`),_("maxY","Max Y"),_("minY","Min Y")]}let E=_("pIC50","pIC50"),L={[l.G7]:{interceptX:"ic50"},[l.kC]:{interceptX:"ec50"},[l.Qx]:{interceptX:"ic50"}},F={top:0,slope:1,interceptX:2,bottom:3},M=_("interceptY","Intercept Y");function R(e,t){var n,r,o;let i=null!=(n=null==(o=L[e.name])?void 0:o[t])?n:t;return null!=(r=e.statisticsProperties.find(e=>e.name===i))?r:e.legacyStatisticProperty(t)}function D(e,t){var n,r,o;let i=null!=(n=null==(r=L[e.name])?void 0:r[t])?n:t,l=e[i];if("number"==typeof l)return l;if("interceptX"===t)return;let a=F[t],s=void 0===a||null==(o=e.parameters)?void 0:o[a];return"number"!=typeof s||isNaN(s)?void 0:s}function X(e,t,n){return null!=t?t:(0,a.Sm)(e,n,!1)}function Y(e,t){return{auc:(0,l.Mi)(e,t),rSquared:(0,l.Hr)(e,t)}}class k extends v{get name(){return l.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,X(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 I(this.fitValues(e,t,n,r),t,e.parameters)}y(e,t){return(0,l.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),i=(o-r)/2+r,l=o-r,a=0;for(let n=0;n<e.length;n++){let e=Math.abs(t[n]-i);e<l&&(l=e,a=n)}let s=e[a],u=t[0]>t[t.length-1]?-10:10;return n.set([o,u,s,r]),n}}class j extends v{get statisticFields(){return this._parameterNames.filter(e=>!C.includes(e))}get statisticLabels(){return this.statisticFields}fillParams(e,t,n,r){return new b(Y(e.fittedCurve,X(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 G={linear:new class extends v{get name(){return l.Ff}get parameterNames(){return["Slope","Intercept"]}get statisticFields(){return["slope","intercept"]}fillParams(e,t,n,r){return new w(g(h({},Y(e.fittedCurve,X(t,n,r))),{slope:e.parameters[0],intercept:e.parameters[1]}),t,e.parameters)}y(e,t){return(0,l.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],i=(t[r]-t[n])/o,l=t[r]-i*e[r],a=new Float32Array(2);return a.set([i,l]),a}},sigmoid:new class extends v{get name(){return l.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]),E]}fillParams(e,t,n,r){return new O(g(h({},Y(e.fittedCurve,X(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,l.ry)(e,t)}inverse(e,t){return e[2]+Math.log10(t/(1-t))/Math.abs(e[1])}getInitialParameters(e,t){let n=i.Rect.fromXYArrays(e,t),r=(n.maxY-n.minY)/2+n.minY,o=n.maxY-n.minY,l=0;for(let n=0;n<e.length;n++){let e=Math.abs(t[n]-r);e<o&&(o=e,l=n)}let a=e[l],s=t[0]>t[t.length-1]?1:-1,u=new Float32Array(4);return u.set([n.maxY,s,a,n.minY]),u}},"log-linear":new class extends v{get name(){return l.kx}get parameterNames(){return["Slope","Intercept"]}get statisticFields(){return["slope","intercept"]}fillParams(e,t,n,r){return new T(g(h({},Y(e.fittedCurve,X(t,n,r))),{slope:e.parameters[0],intercept:e.parameters[1]}),t,e.parameters)}y(e,t){return(0,l.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 l.Pf}get parameterNames(){return["Mantissa","Power"]}get statisticFields(){return["mantissa","power"]}fillParams(e,t,n,r){return new S(g(h({},Y(e.fittedCurve,X(t,n,r))),{mantissa:e.parameters[0],power:e.parameters[1]}),t,e.parameters)}y(e,t){return(0,l.EV)(e,t)}getInitialParameters(e,t){let n=new Float32Array(2);return n.set([100,-2]),n}},"4pl-regression":new k,"4pl-dose-response":new class extends k{get name(){return l.Qx}get parameterNames(){return["Max","Hill","IC50","Min"]}get statisticFields(){return["top","slope","ic50","bottom"]}get derivedStatisticsProperties(){return[...N(this.parameterNames[2]),E]}fillParams(e,t,n,r){return new P(this.fitValues(e,t,n,r),t,e.parameters)}y(e,t){return(0,l.Vd)(e,t)}getInitialParameters(e,t){let n=super.getInitialParameters(e,t),r=0,o=0;for(let t=1;t<e.length;t++)e[t]<e[r]&&(r=t),e[t]>e[o]&&(o=t);return n[1]=t[r]>t[o]?-1:1,n}inverse(e,t){return e[2]+Math.log10(t/(1-t))/Math.abs(e[1])}}},B="sigmoid",V={};class ${constructor(e){this.points=e}}let H=[i.Property.js("fitFunction",i.TYPE.STRING,{category:"Fitting",choices:Object.keys(G),defaultValue:B}),i.Property.js("pointColor",i.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),i.Property.js("fitLineColor",i.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),i.Property.js("outlierColor",i.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),i.Property.js("errorModel",i.TYPE.STRING,{category:"Fitting",defaultValue:"constant",choices:["constant","proportional","combined"],nullable:!1}),i.Property.js("connectDots",i.TYPE.BOOL,{category:"Fitting",defaultValue:!1}),i.Property.js("clickToToggle",i.TYPE.BOOL,{category:"Fitting",description:"Click on a point to mark it as outlier and refit",nullable:!0,defaultValue:!1}),i.Property.js("showFitLine",i.TYPE.BOOL,{category:"Fitting",defaultValue:!0}),i.Property.js("showPoints",i.TYPE.STRING,{category:"Fitting",description:"Whether points/candlesticks/none should be rendered",defaultValue:"points",choices:["points","candlesticks","both"]}),i.Property.js("showOutliers",i.TYPE.BOOL,{category:"Fitting",defaultValue:!0}),i.Property.js("showCurveConfidenceInterval",i.TYPE.BOOL,{category:"Fitting",description:"Whether confidence intervals should be rendered",defaultValue:!1,friendlyName:"Confidence Interval"}),i.Property.js("markerType",i.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"}),i.Property.js("outlierMarkerType",i.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"}),i.Property.js("lineStyle",i.TYPE.STRING,{category:"Rendering",defaultValue:"solid",choices:["solid","dotted","dashed","dashdotted"],nullable:!1}),i.Property.js("droplines",i.TYPE.STRING_LIST,{description:"Whether specific droplines should be rendered",choices:l.h1,inputType:"MultiChoice"}),i.Property.js("columnName",i.TYPE.STRING,{description:"Column name where the series is stored",defaultValue:""})];function q(e){return G[e]}function W(e,t){return e.name===t}function J(e){var t,n;if(null==e)return G[B];if("string"==typeof e)return null!=(t=G[e])?t:G[B];if(!G[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()),i=new j(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);G[t]=i}return null!=V[n=e.name]||(V[n]=e),G[e.name]}function U(e,t,n,r){var s;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,s,c;let d;null!=n||(n=l.dZ.CONSTANT);let m=t.y,h=t.getInitialParameters(e.x,e.y),g=(a=m,s=e,c=n,e=>{var t;let n=0,r=0,o=0,i=s.y,u=s.x.map(t=>a(e,t)),d=i.map((e,t)=>e-u[t]),f=d.map(e=>Math.pow(e,2));for(let e=0;e<f.length;e++)[l.dZ.CONSTANT,l.dZ.COMBINED].includes(c)?r+=f[e]:c===l.dZ.PROPORTIONAL&&(o+=f[e]/(u[e]*u[e]));r=Math.sqrt(r/f.length),o=Math.sqrt(o/f.length),c===l.dZ.COMBINED&&(r=(t=z(r,o,f,u)).sigmaA,o=t.sigmaB);let m=[];for(let e=0;e<f.length;e++)m[e]=Math.pow(r+o*u[e],2),n+=f[e]/m[e]+Math.log(2*Math.PI*m[e]);return{likelihood:n,residuals:d}}),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 x=i.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,x.set(2*e,!0)),void 0!==r[e].max&&null!==r[e].max&&(y[e]=r[e].max,x.set(2*e+1,!0));let C=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},b=-1,w=0,T=null,O=0;for(;;){d=function(e,t,n,r,o){let l,a=void 0===o?null:o,s=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 i=0;i<r;i++)if(e[i]===t[i])for(let t=0;t<10;t++)o[t][i]=e[i];else{let r=function(e,t,n,r){let o=t-n,i=Array(e);for(let t=0;t<e;t++){let e=r();i[t]=n+e*o}return i}(10,e[i],t[i],n);for(let e=0;e<10;e++)o[e][i]=r[e]}return o}(n,t),c=[],d=[],m=[],h=0,g=null;for(l=0;l<10;++l)try{if(0===l){let t=null===a?s[l]:a,n=new Float32Array(a.length).map(e=>-1/0),o=new Float32Array(a.length).map(e=>Infinity);c.push(f(e,t,r,n,o))}else c.push(f(e,s[l],r,t,n))}catch(e){if(e instanceof u)throw Error(`Inconsistent dataframes: ${e.message}`);++h,d.push(e instanceof Error?e.message:"Platform issue"),m.push(s[l])}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=i.DataFrame.fromColumns(t.map((e,t)=>i.Column.fromFloat32Array(`arg${t}`,e)))).columns.add(i.Column.fromStrings("Issue",d))}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),O=0;for(let e=1;e<d.extremums.length;e++)d.extremums[e].cost<d.extremums[O].cost&&(O=e);let e=C(d.extremums[O]);if(null===T?T=e:e<T?(T=e,w=0):w++,h=d.extremums[O].point,b>40||3===w)break;for(let e=0;e<t.parameterNames.length;e++)x.get(2*e)||(v[e]=h[e]-Math.abs(h[e]*(w+.5))),x.get(2*e+1)||(y[e]=h[e]+Math.abs(h[e]*(w+.5)));b++}return{fittedCurve:(0,l.ah)(m,h),parameters:h}}((0,a.mr)(n),t,null!=(s=e.errorModel)?s:l.dZ.CONSTANT,e.parameterBounds)}function z(e,t,n,r){let o=Number.MAX_VALUE,i=0;for(let t=0;t<=10;t++){let l=0,a=t/10,s=e*a,u=e*(1-a),c=[];for(let e=0;e<n.length;e++)c[e]=Math.pow(s+u*r[e],2),l+=n[e]/c[e]+Math.log(2*Math.PI*c[e]);l<o&&(o=l,i=a)}return t=e*(1-i),{sigmaA:e*=i,sigmaB:t}}function Z(e,t,n,r,o){let i=function(e,t,n,r){var o;let i=0,a=0,s=t.y,u=t.x.map(t=>e(r,t)),c=s.map((e,t)=>e-u[t]),d=c.map(e=>Math.pow(e,2));for(let e=0;e<d.length;e++)[l.dZ.CONSTANT,l.dZ.COMBINED].includes(n)?i+=d[e]:n===l.dZ.PROPORTIONAL&&(a+=Math.pow(c[e]/Math.abs(u[e]),2));return i=Math.sqrt(i/d.length),a=Math.sqrt(a/d.length),n===l.dZ.COMBINED&&(i=(o=z(i,a,d,u)).sigmaA,a=o.sigmaB),{sigmaA:i,sigmaB:a}}(n,e,o,t),a=s.normal.inv(1-(void 0===r?.05:r)/2,0,1);return{confidenceTop:e=>{let r=n(t,e);return r+a*(i.sigmaA+Math.abs(r)*i.sigmaB)},confidenceBottom:e=>{let r=n(t,e);return r-a*(i.sigmaA+Math.abs(r)*i.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 i(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 i=o(n);t.x[t.x.length]=n.x[0],t.y[t.y.length]=i,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 l(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:()=>l,mr:()=>i})},533(e,t,n){"use strict";n.d(t,{L:()=>l});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}},i=new class{screenToWorld(e,t,n,r,o){let i=Math.log(n=n<1e-30?1e-30:n);return Math.exp(i+(Math.log(r)-i)*(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 i=t*Math.log((e=e<1e-30?1e-30:e)/(n=n<1e-30?1e-30:n))/Math.log(r/n);return o?t-i:i}};class l{get xt(){return this.logX?i:o}get yt(){return this.logY?i: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 i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.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);var r={};(()=>{"use strict";let e;n.r(r),n.d(r,{tests:()=>x,test:()=>tB,_package:()=>tG,initAutoTests:()=>tV});var t,o,i,l=n(82);n(397);let a=DG.DataFrame.fromCsv(`countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string
2
2
  Belgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND
3
3
  ATOM
4
4
  END",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc
@@ -29,14 +29,14 @@ END",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-
29
29
  Switzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND
30
30
  ATOM
31
31
  END",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,
32
- ,,,,,,,,,,,,,,,,,,,,,`);a.columns.add(DG.Column.fromList(DG.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));let s=console.log.bind(console),u=console.info.bind(console),c=console.warn.bind(console),d=console.error.bind(console),f={},m="Auto Tests",p="Demo",h="Detectors",g="Core",v={};(o||(o={})).notNull=function(e,t){if(null==e)throw Error(`${null==t?"Value":t} not defined`)};class y{constructor(e,t,n){this.catchUnhandled=!0,this.report=!1,this.returnOnFail=!1,this.closeAll=!0,void 0!==e&&(this.catchUnhandled=e),void 0!==t&&(this.report=t),void 0!==n&&(this.returnOnFail=n)}}class x{constructor(e,t,n,r){this.category=e,this.name=t,r??(r={}),r.timeout??(r.timeout=3e4),this.options=r,this.test=async()=>new Promise(async(e,t)=>{let r="";try{DG.Test.isInDebug;let e=await n();try{r=e?.toString()??""}catch(e){r="Can't convert test's result to string",console.error(`Can't convert test's result to string in the ${this.category}:${this.name} test`)}}catch(e){t(e)}e(r)})}}function C(t,n,r){void 0==f[e]&&(f[e]={}),void 0==f[e].tests&&(f[e].tests=[]),f[e].tests.push(new x(e,t,n,r))}function b(e,t=!0,n){if(n=n?`${n}, `:"",e!==t)throw Error(`${n}Expected "${t}", got "${e}"`)}function w(e,t,n=.001,r){if(e===1/0&&t===1/0||e===-1/0&&t===-1/0||isNaN(e)&&isNaN(t))return;let o=Math.abs(e-t)<n;if(b(o,!0,`${r??""} (tolerance = ${n}; a = ${e}, e = ${t})`),!o)throw Error(`Expected ${t}, got ${e} (tolerance = ${n})`)}function T(e,t){let n=e.length,r=t.length;if(n!=r)throw Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${r}`);for(let r=0;r<n;r++)if(e[r]instanceof Array&&t[r]instanceof Array)T(e[r],t[r]);else if(e[r]instanceof Object&&t[r]instanceof Object)!function e(t,n){for(let[r,o]of Object.entries(n)){if(!t.hasOwnProperty(r))throw Error(`Expected property "${r}" not found`);let n=t[r];if(n instanceof Array&&o instanceof Array)T(n,o);else if(n instanceof Object&&o instanceof Object)e(n,o);else if(Number.isFinite(n)&&Number.isFinite(o))w(n,o);else if(n!=o)throw Error(`Expected (${o}) for key '${r}', got (${n})`)}}(e[r],t[r]);else if(e[r]!=t[r])throw Error(`Expected ${t[r]} at position ${r}, got ${e[r]}`)}function O(t,n,r){e=t,n(),f[e]&&(f[e].clear=r?.clear??!0,f[e].timeout=r?.timeout,f[e].benchmarks=r?.benchmarks,f[e].stressTests=r?.stressTests,f[e].owner=r?.owner,f[e].node=r?.node)}function S(e,t,n){let r=e.options?.node??t.node??!1;return n.nodeOnly?r:!n.excludeNodeTests||!r}async function I(e,t){let n=e.id;if(v[n])return;let r=t?t.tests:f;if("DevTools"===e.name||t&&"DevTools"===t._package.name)for(let e of window.dartTests){let t=e.name.split(/\s*\|\s*!/g),n=t.pop()??e.name,o=t.length?g+": "+t.join(": "):g,i=n.split(" | ");n=i[i.length-1],i.unshift(o),i.pop(),void 0===r[o=i.join(": ")]&&(r[o]={tests:[],clear:!0}),r[o].tests.push(new x(o,n,e.test,{isAggregated:!1,timeout:e.options?.timeout??3e4,skipReason:e.options?.skipReason,owner:e.options?.owner,benchmark:e.options?.benchmark??!1}))}let o=[],i=[],l=[],s=await grok.dapi.functions.filter(`package.id = "${n}"`).list(),u=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);for(let t of s){let n=t.options.test,s=t.options.demoPath;if(n&&Array.isArray(n)&&n.length)for(let e=0;e<n.length;e++){let i=n[e].matchAll(u),l={};Array.from(i).forEach(e=>{e[0].startsWith("skip")?l.skip=e[1]:e[0].startsWith("wait")?l.wait=parseInt(e[2]):e[0].startsWith("cat")?l.cat=e[3]:e[0].startsWith("timeout")&&(l.timeout=parseInt(e[4]))});let a=new x(l.cat??m,1===n.length?t.name:`${t.name} ${e+1}`,async()=>{var r;let o=await grok.functions.eval((r=n[e],r.replace(RegExp(t.name,"gi"),t.nqName)));if(l.wait&&await E(l.wait),"boolean"==typeof o&&!o)throw`Failed: ${n[e]}, expected true, got ${o}`},{skipReason:l.skip,timeout:DG.Test.isInBenchmark?l.benchmarkTimeout??108e5:l.timeout??3e4,node:t instanceof DG.DataQuery});if(l.cat){let e=l.cat;void 0===r[e]&&(r[e]={tests:[],clear:!0}),r[e].tests||(r[e].tests=[]),r[e].tests.push(a)}else o.push(a)}if(s){let e=t.options.demoWait?parseInt(t.options.demoWait):void 0,n=new x(p,t.friendlyName,async()=>{await E(300),grok.shell.clearLastError(),await t.apply(),await E(e||2e3);let n=await grok.shell.lastError;if(n)throw Error(n)},{skipReason:t.options.demoSkip});i.push(n)}if(t.hasTag("semTypeDetector")){let n=a;t.options.testData&&(n=await grok.data.files.openTable(`System:AppData/${e.nqName}/${t.options.testData}`));let r=new x(h,t.friendlyName,async()=>{let r=[];for(let o of(console.log(`System:AppData/${e.nqName}/${t.options.testData}`),n.clone().columns)){let e=await t.apply([o]);r.push(e||o.semType)}let o=r.filter(e=>e);b(o.length,1),t.options.testDataColumnName&&b(o[0],t.options.testDataColumnName)},{skipReason:t.options.skipTest});l.push(r)}}v[n]=!0,o.length>0&&(r[m]={tests:o,clear:!0}),i.length>0&&(r[p]={tests:i,clear:!0}),l.length>0&&(r[h]={tests:l,clear:!1})}async function P(e){var t;let n,r=e?.nodeOptions?e.nodeOptions.package:grok.functions.getCurrentCall().func.package;if(!r)throw Error("Can't run tests outside of the package");let o=r.packageOwner?.match(/<([^>]*)>/),i=o?o[1]:"";void 0!=r&&await I(r);let l=[];console.log("Running tests..."),console.log(e),e??(e={}),(t=e).testContext??(t.testContext=new y),grok.shell.clearLastError();let a=(n=[],console.log=(...e)=>{n.push(...e),s(...e)},console.info=(...e)=>{n.push(...e),u(...e)},console.warn=(...e)=>{n.push(...e),c(...e)},console.error=(...e)=>{n.push(...e),d(...e)},n);for(let t of(await g(f,e),l))t.result=t.result.toString().replace(/"/g,"'"),void 0!=t.logs&&(t.logs=t.logs.toString().replace(/"/g,"'"));return l;async function m(e,t){let n;try{void 0!==e&&await L(async()=>{await e()},1e5,`before ${t}: timeout error`)}catch(e){n=await _(e)}return n}async function p(e,t,n){let o=(e.tests??[]).filter(n=>S(n,e,t)),l=[],s=h();if(e.clear){let u=n&&void 0!=t.skipToTest;for(let n=0;n<o.length;n++){o[n].options&&o[n].options?.benchmark===void 0&&(o[n].options||(o[n].options={}),o[n].options.benchmark=e.benchmarks??!1);let c=o[n];if(t.test&&t.test.toLowerCase()!==c.name.toLowerCase())continue;if(u)if(t?.skipToTest==void 0||c.name.toLowerCase().trim()!==t?.skipToTest.toLowerCase().trim())continue;else u=!1;c?.options&&(c.options.owner=o[n].options?.owner??e?.owner??i??"");let d=await N(c,t?.test,a,DG.Test.isInBenchmark?o[n].options?.benchmarkTimeout??108e5:o[n].options?.timeout??3e4,r.name,t.verbose);if(!c.options?.skipReason&&window.gc&&await window.gc(),d&&(l.push({...d,widgetsDifference:h()-s}),t.returnOnFail&&t.skipToTest!==c.name&&!d.success&&!d.skipped))break;t.nodeOptions||t.testContext?.closeAll===!1||(grok.shell.closeAll(),DG.Balloon.closeAll())}}else{let u=n&&void 0!=t.skipToTest;for(let n=0;n<o.length;n++){let c=o[n];if(t.test&&t.test.toLowerCase()!==c.name.toLowerCase())continue;if(u){t?.skipToTest!=void 0&&c.name.toLowerCase().trim()===t?.skipToTest.toLowerCase().trim()&&(u=!1);continue}c?.options&&(c.options.owner=o[n].options?.owner??e?.owner??i??"");let d=await N(c,t?.test,a,DG.Test.isInBenchmark?o[n].options?.benchmarkTimeout??108e5:o[n].options?.timeout,r.name,t.verbose);if(!c.options?.skipReason&&window.gc&&await window.gc(),d&&(l.push({...d,widgetsDifference:h()-s}),t.returnOnFail&&t.skipToTest!==c.name&&!d.success&&!d.skipped))break}}return l}function h(){if("u">typeof process)return 0;let e=-1;try{e=DG.Widget.getAll().length}catch(e){console.warn(e.message??e)}return e}async function g(e,t){try{let n=t?.skipToCategory!=void 0,o=!1;for(let[a,u]of Object.entries(e)){let e;if(t.exclude?.some(e=>a.startsWith(e))||t?.category!=null&&!a.toLowerCase().startsWith(t?.category.toLowerCase().trim()))continue;if(n)if(o)n=!1;else{if(t?.skipToCategory==null||a.toLowerCase().trim()!==t?.skipToCategory.toLowerCase().trim())continue;o=!0}let c=(u.tests??[]).filter(e=>S(e,u,t));if((t.nodeOnly||t.excludeNodeTests)&&0===c.length)continue;let d=void 0==u.tests?void 0:c.every(e=>e.options?.skipReason||t?.test!=null&&t.test.toLowerCase()!==e.name.toLowerCase());if(!d){let e=c.filter(e=>e.options?.skipReason||t?.test!=null&&t.test.toLowerCase()!==e.name.toLowerCase()).length;s(`Package testing: Started {{${a}}}${e>0?` skipped {{${e}}}`:""}`),u.beforeStatus=await m(u.before,a)}t.stressTest&&(c=c.filter(e=>e.options?.stressTest),c=function(e){let t=e.slice();return t.sort(()=>Math.random()-.5),t}(c)),(t.tags?.length??0)>0&&(c=c.filter(e=>e.options?.tags?.some(e=>(t?.tags??[]).includes(e)))),u.beforeStatus?(e=Array.from(c.map(e=>({date:new Date().toISOString(),category:a,name:e.name,success:!1,result:"before() failed",ms:0,skipped:!1,logs:"",owner:i,package:r.name,widgetsDifference:0,flaking:DG.Test.isReproducing})))).forEach(async e=>await grok.shell.reportTest("package",e)):e=await p(u,t,n);let f=e.filter(e=>"skipped"!=e.result);if(d||(u.afterStatus=await m(u.after,a)),u.afterStatus&&(s(`Package testing: Category after() {{${a}}} failed`),s(`Package testing: Result for {{${a}}} after: ${u.afterStatus}`),f.push({date:new Date().toISOString(),category:a,name:"after",success:!1,result:u.afterStatus,ms:0,skipped:!1,logs:"",owner:i,package:r.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),u.beforeStatus&&(s(`Package testing: Category before() {{${a}}} failed`),s(`Package testing: Result for {{${a}}} before: ${u.beforeStatus}`),f.push({date:new Date().toISOString(),category:a,name:"before",success:!1,result:u.beforeStatus,ms:0,skipped:!1,logs:"",owner:i,package:r.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),l.push(...f),t.returnOnFail&&f.some(e=>!e.success&&!e.skipped&&e.name!==t.skipToTest))break}}finally{console.log=s,console.info=u,console.warn=c,console.error=d}if(t.testContext.catchUnhandled&&!DG.Test.isInBenchmark){await E(1e3);let e=await grok.shell.lastError;if(void 0!=e){let t={logs:"",date:new Date().toISOString(),category:"Unhandled exceptions",name:"Exception",result:e??"",success:!e,ms:0,skipped:!1,owner:i??"",package:r.name,widgetsDifference:0};s(`Package testing: Unhandled Exception: ${e}`),l.push({...t,flaking:DG.Test.isReproducing&&!e}),t.package=r.name,await grok.shell.reportTest("package",t)}}}}async function _(e){return`${e.toString()}
33
- ${e.stack?await DG.Logger.translateStackTrace(e.stack):""}`}async function N(e,t,n,r,o,i){let l;n.length=0;let a=void 0!=t&&e.name.toLowerCase()!==t.toLowerCase(),u=e.options?.skipReason||a,c=a?"skipped":e.options?.skipReason;if(DG.Test.isInBenchmark&&!e.options?.benchmark)return void s(`Package testing: Skipped {{${e.category}}} {{${e.name}}} doesnt available in benchmark mode`);u&&!DG.Test.isInBenchmark&&s(`Package testing: Skipped {{${e.category}}} {{${e.name}}}`),u||s(`Package testing: Started {{${e.category}}} {{${e.name}}}`);let f=Date.now(),m=new Date(f).toISOString();try{u?l={name:e.name,owner:e.options?.owner??"",category:e.category,logs:"",date:m,success:!0,result:c,ms:0,skipped:!0,package:o??"",flaking:DG.Test.isReproducing}:(DG.Test.isProfiling&&console.profile(`${e.category}: ${e.name}`),l={name:e.name,owner:e.options?.owner??"",category:e.category,logs:"",date:m,success:!0,result:(await L(e.test,r??3e4)).toString()??"OK",ms:0,skipped:!1,package:o??"",flaking:DG.Test.isReproducing},DG.Test.isProfiling&&(console.profileEnd(`${e.category}: ${e.name}`),grok.shell.info(`Profiling of ${e.category}: ${e.name} finished
34
- Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`)))}catch(t){d(t),l={name:e.name,owner:e.options?.owner??"",category:e.category,logs:"",date:m,success:!1,result:await _(t),ms:0,skipped:!1,package:o??"",flaking:!1}}if(e.options?.isAggregated&&l.result.constructor===DG.DataFrame){let e=l.result.col("success");if(e&&(l.success=e.stats.sum===e.length),!i){let e=l.result;e.columns.remove("stack"),e.rows.removeWhere(e=>e.get("success")),l.result=e}l.result=l.result.toCsv()}if(l.logs=n.join("\n"),l.ms=Date.now()-f,u||s(`Package testing: Finished {{${e.category}}} {{${e.name}}} with {{${l.success?"success":"error"}}} for ${l.ms} ms`),l.success||s(`Package testing: Result for {{${e.category}}} {{${e.name}}}: ${l.result}`),l.category=e.category,l.name=e.name,l.owner=e.options?.owner??"",!a){let t={success:l.success,result:l.result,ms:l.ms,date:l.date,skipped:l.skipped,category:e.category,name:e.name,logs:l.logs,owner:l.owner,flaking:DG.Test.isReproducing&&l.success,package:l.package};if(l.result.constructor==Object){let e=Object.keys(l.result).reduce((e,t)=>({...e,["result."+t]:l.result[t]}),{});t={...t,...e}}t.result instanceof DG.DataFrame&&(t.result=JSON.stringify(t.result?.toJson())||""),await grok.shell.reportTest("package",t)}return l}async function E(e){await new Promise(t=>setTimeout(t,e))}async function A(e,t="Timeout exceeded",n=500,r=50){return new Promise((o,i)=>{setTimeout(()=>{clearInterval(l),i(Error(t))},n);let l=setInterval(()=>{e()&&(clearInterval(l),o(null))},r)})}async function L(e,t,n="EXECUTION TIMEOUT"){let r=null,o=new Promise((e,o)=>{r=setTimeout(()=>{o(n)},t)});try{return await Promise.race([e(),o])}finally{r&&clearTimeout(r)}}async function F(e,t){let n=!1,r=!1;try{await e()}catch(e){n=!0,r=!t||t(e)}finally{if(!n)throw Error("An exception is expected but not thrown");if(!r)throw Error("An expected exception is thrown, but it does not satisfy the condition")}}DG.DataFrame.fromColumns([DG.Column.fromStrings("col",["val1","val2","val3"])]);var M=n(328),R=n(788);function D(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function X(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){D(i,r,o,l,a,"next",e)}function a(e){D(i,r,o,l,a,"throw",e)}l(void 0)})}}O("detectors",()=>{C("detectFitCurves",()=>X(function*(){let e=`dataframes,json chart 0,json chart 1,json chart 2
32
+ ,,,,,,,,,,,,,,,,,,,,,`),s=Uint8Array.from(atob("iVBORw0KGgoAAAANSUhEUgAAABgAAAAQCAIAAACDRijCAAAAQElEQVR4nGO8Y2PDQA3ARBVTGKhoEAucpXz4MBn679ra0sxFaDYQBMqoPhh8gc00fA1iQeOTl5oYqOgixuGbaQF0Bgp24E7RmwAAAABJRU5ErkJggg=="),e=>e.charCodeAt(0));function u(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 c(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){c(i,r,o,l,a,"next",e)}function a(e){c(i,r,o,l,a,"throw",e)}l(void 0)})}}function f(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 m(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 p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,a=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){a=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(a)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}a.columns.add(DG.Column.fromList(DG.TYPE.BYTE_ARRAY,"BinaryImage",Array.from({length:11},()=>s)));let h=console.log.bind(console),g=console.info.bind(console),v=console.warn.bind(console),y=console.error.bind(console),x={},C="Auto Tests",b="Demo",w="Detectors",T="Core",O={};(o||(o={})).notNull=function(e,t){if(null==e)throw Error(`${null==t?"Value":t} not defined`)};class S{constructor(e,t,n){this.catchUnhandled=!0,this.report=!1,this.returnOnFail=!1,this.closeAll=!0,void 0!==e&&(this.catchUnhandled=e),void 0!==t&&(this.report=t),void 0!==n&&(this.returnOnFail=n)}}class I{constructor(e,t,n,r){this.category=e,this.name=t,null!=r||(r={}),null!=r.timeout||(r.timeout=3e4),this.options=r,this.test=()=>d(function*(){return new Promise((e,t)=>d(function*(){let r="";try{DG.Test.isInDebug;let e=yield n();try{var o;r=null!=(o=null==e?void 0:e.toString())?o:""}catch(e){r="Can't convert test's result to string",console.error(`Can't convert test's result to string in the ${this.category}:${this.name} test`)}}catch(e){t(e)}e(r)}).call(this))}).call(this)}}function P(t,n,r){void 0==x[e]&&(x[e]={}),void 0==x[e].tests&&(x[e].tests=[]),x[e].tests.push(new I(e,t,n,r))}function _(e,t,n){let r=void 0===t||t;if(n=n?`${n}, `:"",e!==r)throw Error(`${n}Expected "${r}", got "${e}"`)}function A(e,t,n,r){let o=void 0===n?.001:n;if(e===1/0&&t===1/0||e===-1/0&&t===-1/0||isNaN(e)&&isNaN(t))return;let i=Math.abs(e-t)<o;if(_(i,!0,`${null!=r?r:""} (tolerance = ${o}; a = ${e}, e = ${t})`),!i)throw Error(`Expected ${t}, got ${e} (tolerance = ${o})`)}function N(e,t){let n=e.length,r=t.length;if(n!=r)throw Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${r}`);for(let r=0;r<n;r++)if(e[r]instanceof Array&&t[r]instanceof Array)N(e[r],t[r]);else if(e[r]instanceof Object&&t[r]instanceof Object)!function e(t,n){var r=!0,o=!1,i=void 0;try{for(var l,a=Object.entries(n)[Symbol.iterator]();!(r=(l=a.next()).done);r=!0){let n=p(l.value,2),r=n[0],o=n[1];if(!t.hasOwnProperty(r))throw Error(`Expected property "${r}" not found`);let i=t[r];if(i instanceof Array&&o instanceof Array)N(i,o);else if(i instanceof Object&&o instanceof Object)e(i,o);else if(Number.isFinite(i)&&Number.isFinite(o))A(i,o);else if(i!=o)throw Error(`Expected (${o}) for key '${r}', got (${i})`)}}catch(e){o=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}}(e[r],t[r]);else if(e[r]!=t[r])throw Error(`Expected ${t[r]} at position ${r}, got ${e[r]}`)}function E(t,n,r){if(e=t,n(),x[e]){var o;x[e].clear=null==(o=null==r?void 0:r.clear)||o,x[e].timeout=null==r?void 0:r.timeout,x[e].benchmarks=null==r?void 0:r.benchmarks,x[e].stressTests=null==r?void 0:r.stressTests,x[e].owner=null==r?void 0:r.owner,x[e].node=null==r?void 0:r.node}}function L(e,t,n){var r,o,i;let l=null!=(r=null!=(o=null==(i=e.options)?void 0:i.node)?o:t.node)&&r;return n.nodeOnly?l:!n.excludeNodeTests||!l}class F{add(e,t){this.enabled&&(this.sent=this.sent.then(()=>grok.shell.reportTest(e,t)).catch(e=>{var t;return v(`A test result was not reported: ${null!=(t=null==e?void 0:e.message)?t:e}`)}))}constructor(e){this.enabled=void 0===e||e,this.sent=Promise.resolve()}}function M(e){return d(function*(){return`${e.toString()}
33
+ ${e.stack?yield DG.Logger.translateStackTrace(e.stack):""}`})()}function R(e,t,n,r,o,i){return d(function*(e,t,n,r,o,i,l){var a,s,u,c,d,p,g,v,x,C,b,w,T,O;let S,I=void 0===l?new F:l;n.length=0;let P=void 0!=t&&e.name.toLowerCase()!==t.toLowerCase(),_=(null==(s=e.options)?void 0:s.skipReason)||P,A=P?"skipped":null==(u=e.options)?void 0:u.skipReason;if(DG.Test.isInBenchmark&&!(null==(c=e.options)?void 0:c.benchmark))return void h(`Package testing: Skipped {{${e.category}}} {{${e.name}}} doesnt available in benchmark mode`);_&&!DG.Test.isInBenchmark&&h(`Package testing: Skipped {{${e.category}}} {{${e.name}}}`),_||h(`Package testing: Started {{${e.category}}} {{${e.name}}}`);let N=Date.now(),E=new Date(N).toISOString();try{_?S={name:e.name,owner:null!=(g=null==(v=e.options)?void 0:v.owner)?g:"",category:e.category,logs:"",date:E,success:!0,result:A,ms:0,skipped:!0,package:null!=o?o:"",flaking:DG.Test.isReproducing}:(DG.Test.isProfiling&&console.profile(`${e.category}: ${e.name}`),S={name:e.name,owner:null!=(x=null==(b=e.options)?void 0:b.owner)?x:"",category:e.category,logs:"",date:E,success:!0,result:null!=(C=(yield G(e.test,null!=r?r:3e4)).toString())?C:"OK",ms:0,skipped:!1,package:null!=o?o:"",flaking:DG.Test.isReproducing},DG.Test.isProfiling&&(console.profileEnd(`${e.category}: ${e.name}`),grok.shell.info(`Profiling of ${e.category}: ${e.name} finished
34
+ Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`)))}catch(t){y(t),S={name:e.name,owner:null!=(w=null==(T=e.options)?void 0:T.owner)?w:"",category:e.category,logs:"",date:E,success:!1,result:yield M(t),ms:0,skipped:!1,package:null!=o?o:"",flaking:!1}}if((null==(d=e.options)?void 0:d.isAggregated)&&S.result.constructor===DG.DataFrame){let e=S.result.col("success");if(e&&(S.success=e.stats.sum===e.length),!i){let e=S.result;e.columns.remove("stack"),e.rows.removeWhere(e=>e.get("success")),S.result=e}S.result=S.result.toCsv()}if(S.logs=n.join("\n"),S.ms=Date.now()-N,_||h(`Package testing: Finished {{${e.category}}} {{${e.name}}} with {{${S.success?"success":"error"}}} for ${S.ms} ms`),S.success||h(`Package testing: Result for {{${e.category}}} {{${e.name}}}: ${S.result}`),S.category=e.category,S.name=e.name,S.owner=null!=(a=null==(p=e.options)?void 0:p.owner)?a:"",!P){let t={success:S.success,result:S.result,ms:S.ms,date:S.date,skipped:S.skipped,category:e.category,name:e.name,logs:S.logs,owner:S.owner,flaking:DG.Test.isReproducing&&S.success,package:S.package};if(S.result.constructor==Object){let e=Object.keys(S.result).reduce((e,t)=>m(f({},e),{["result."+t]:S.result[t]}),{});t=f({},t,e)}t.result instanceof DG.DataFrame&&(t.result=JSON.stringify(null==(O=t.result)?void 0:O.toJson())||""),I.add("package",t)}return S}).apply(this,arguments)}function D(e){return d(function*(){yield new Promise(t=>setTimeout(t,e))})()}function X(e,t,n,r){let o=void 0===n?1e4:n,i=void 0===r?20:r;return d(function*(){let n=Date.now();for(;!e();){if(Date.now()-n>o)throw Error(`${"string"==typeof t?t:t()} (after ${o} ms)`);yield D(i)}})()}function Y(e,t){let n=void 0===t?1e4:t;return d(function*(){let t=0;yield X(()=>{let n=e.root.getBoundingClientRect();return(t=n.width>0&&n.height>0&&!j(e)?t+1:0)>=2},`${e.type} is still rendering`,n,16)})()}function k(e,t){let n=void 0===t?2e4:t;return d(function*(){if("u">typeof process)return;let t=0;yield X(()=>{var e;return(t=[null==(e=grok.shell.v)?void 0:e.root,...document.querySelectorAll(".d4-dialog")].some(e=>null!=e&&Array.from(e.querySelectorAll('.grok-wait .grok-loader, .d4-update-shadow, [aria-busy="true"]')).some(e=>null!==e.offsetParent))||Array.from(grok.shell.tableViews).some(e=>Array.from(e.viewers).some(e=>null!==e.root.offsetParent&&j(e)))?0:t+1)>=2},`${e}: still loading`,n,16)})()}function j(e){try{return e.isRenderPending}catch(e){return!1}}function G(e,t,n){let r=void 0===n?"EXECUTION TIMEOUT":n;return d(function*(){let n=null,o=new Promise((e,o)=>{n=setTimeout(()=>{o(r)},t)});try{return yield Promise.race([e(),o])}finally{n&&clearTimeout(n)}})()}function B(e,t){return d(function*(){let n=!1,r=!1;try{yield e()}catch(e){n=!0,r=!t||t(e)}finally{if(!n)throw Error("An exception is expected but not thrown");if(!r)throw Error("An expected exception is thrown, but it does not satisfy the condition")}})()}DG.DataFrame.fromColumns([DG.Column.fromStrings("col",["val1","val2","val3"])]);var V=n(328),$=n(788);function H(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function q(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){H(i,r,o,l,a,"next",e)}function a(e){H(i,r,o,l,a,"throw",e)}l(void 0)})}}E("detectors",()=>{P("detectFitCurves",()=>q(function*(){let e=`dataframes,json chart 0,json chart 1,json chart 2
35
35
  "null (15 rows, 2 columns)","{""series"":[{""parameters"":[1.4325498997897106,1.9857091601431633,1.1549088606928581,1.7111330488305754],""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showCurveConfidenceInterval"":false,""points"":[{""x"":0.10000000149011612,""y"":0.04513680189847946},{""x"":0.6000000238418579,""y"":0.05534003674983978},{""x"":1.100000023841858,""y"":0.041759949177503586},{""x"":1.600000023841858,""y"":0.019746985286474228},{""x"":2.0999999046325684,""y"":0.009008238092064857},{""x"":2.5999999046325684,""y"":0.00802786834537983},{""x"":3.0999999046325684,""y"":0.046114228665828705},{""x"":3.5999999046325684,""y"":0.0032935715280473232},{""x"":4.099999904632568,""y"":0.05305013433098793},{""x"":4.599999904632568,""y"":0.11946146935224533},{""x"":5.099999904632568,""y"":0.24304461479187012},{""x"":5.599999904632568,""y"":0.32507050037384033},{""x"":6.099999904632568,""y"":0.30492347478866577},{""x"":6.599999904632568,""y"":0.30675041675567627},{""x"":7.099999904632568,""y"":0.28282707929611206}]},{""fitFunction"":""sigmoid"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showCurveConfidenceInterval"":false,""points"":[{""x"":0.10000000149011612,""y"":0.027537694200873375},{""x"":0.6000000238418579,""y"":0.20163409411907196},{""x"":1.100000023841858,""y"":0.4537210166454315},{""x"":1.600000023841858,""y"":0.1709870994091034},{""x"":2.0999999046325684,""y"":0.35089364647865295},{""x"":2.5999999046325684,""y"":0.30297139286994934},{""x"":3.0999999046325684,""y"":0.3161645829677582},{""x"":3.5999999046325684,""y"":0.460237979888916},{""x"":4.099999904632568,""y"":0.5018354058265686},{""x"":4.599999904632568,""y"":1.2936394214630127},{""x"":5.099999904632568,""y"":2.336543321609497},{""x"":5.599999904632568,""y"":2.353417158126831},{""x"":6.099999904632568,""y"":2.5554966926574707},{""x"":6.599999904632568,""y"":2.7185072898864746},{""x"":7.099999904632568,""y"":2.8088953495025635}]}]}","{""series"":[{""parameters"":[1.4257157458000065,1.587135296876273,1.6780074048516793,4.72187609991688],""fitFunction"":""sigmoid"",""fitLineColor"":""#2ca02c"",""pointColor"":""#2ca02c"",""showCurveConfidenceInterval"":true,""points"":[{""x"":0.10000000149011612,""y"":0.5346568822860718},{""x"":0.6000000238418579,""y"":0.6445727348327637},{""x"":1.100000023841858,""y"":0.08188246190547943},{""x"":1.600000023841858,""y"":0.0516531839966774},{""x"":2.0999999046325684,""y"":0.17018724977970123},{""x"":2.5999999046325684,""y"":0.618033766746521},{""x"":3.0999999046325684,""y"":0.16852399706840515},{""x"":3.5999999046325684,""y"":0.013230039738118649},{""x"":4.099999904632568,""y"":0.6706985831260681},{""x"":4.599999904632568,""y"":0.6293138861656189},{""x"":5.099999904632568,""y"":1.4058887958526611},{""x"":5.599999904632568,""y"":2.6412644386291504},{""x"":6.099999904632568,""y"":3.775967597961426},{""x"":6.599999904632568,""y"":3.3188939094543457},{""x"":7.099999904632568,""y"":3.793793201446533}]}],""chartOptions"":{""showStatistics"":[""auc""]}}","{""series"":[{""parameters"":[1.4518023469757255,1.051351211186544,1.6612723878444138,-0.9253134758193626],""fitFunction"":""sigmoid"",""fitLineColor"":""#9467bd"",""pointColor"":""#9467bd"",""showCurveConfidenceInterval"":true,""points"":[{""x"":0.10000000149011612,""y"":2.5458569526672363},{""x"":0.10000000149011612,""y"":3.0017518997192383},{""x"":0.10000000149011612,""y"":2.4102466106414795},{""x"":0.10000000149011612,""y"":2.7017934322357178},{""x"":0.10000000149011612,""y"":2.8341686725616455},{""x"":0.6000000238418579,""y"":2.9751579761505127},{""x"":0.6000000238418579,""y"":2.8365142345428467},{""x"":0.6000000238418579,""y"":2.898362874984741},{""x"":0.6000000238418579,""y"":2.9964826107025146},{""x"":0.6000000238418579,""y"":2.6708292961120605},{""x"":1.100000023841858,""y"":3.263227939605713},{""x"":1.100000023841858,""y"":3.0655293464660645},{""x"":1.100000023841858,""y"":2.6620445251464844},{""x"":1.100000023841858,""y"":3.002741813659668},{""x"":1.100000023841858,""y"":3.1540098190307617},{""x"":1.600000023841858,""y"":2.8934433460235596},{""x"":1.600000023841858,""y"":2.7970690727233887},{""x"":1.600000023841858,""y"":3.0466723442077637},{""x"":1.600000023841858,""y"":3.179988145828247},{""x"":1.600000023841858,""y"":2.611898899078369},{""x"":2.0999999046325684,""y"":2.497966766357422},{""x"":2.0999999046325684,""y"":2.645627498626709},{""x"":2.0999999046325684,""y"":2.5474727153778076},{""x"":2.0999999046325684,""y"":2.530237913131714},{""x"":2.0999999046325684,""y"":2.9498236179351807},{""x"":2.5999999046325684,""y"":2.7639214992523193},{""x"":2.5999999046325684,""y"":3.007110595703125},{""x"":2.5999999046325684,""y"":2.71816086769104},{""x"":2.5999999046325684,""y"":3.050650119781494},{""x"":2.5999999046325684,""y"":2.591902017593384},{""x"":3.0999999046325684,""y"":2.79219388961792},{""x"":3.0999999046325684,""y"":2.380063056945801},{""x"":3.0999999046325684,""y"":3.2450575828552246},{""x"":3.0999999046325684,""y"":2.6954219341278076},{""x"":3.0999999046325684,""y"":2.368993043899536},{""x"":3.5999999046325684,""y"":3.2338552474975586},{""x"":3.5999999046325684,""y"":3.222881555557251},{""x"":3.5999999046325684,""y"":2.6137502193450928},{""x"":3.5999999046325684,""y"":2.3624353408813477},{""x"":3.5999999046325684,""y"":2.830970525741577},{""x"":4.099999904632568,""y"":2.8000826835632324},{""x"":4.099999904632568,""y"":2.8115334510803223},{""x"":4.099999904632568,""y"":2.8906726837158203},{""x"":4.099999904632568,""y"":2.5641937255859375},{""x"":4.099999904632568,""y"":2.3881938457489014},{""x"":4.599999904632568,""y"":2.076000928878784},{""x"":4.599999904632568,""y"":2.241201400756836},{""x"":4.599999904632568,""y"":2.018866777420044},{""x"":4.599999904632568,""y"":2.7197747230529785},{""x"":4.599999904632568,""y"":2.3649282455444336},{""x"":5.099999904632568,""y"":2.068617105484009},{""x"":5.099999904632568,""y"":2.0637989044189453},{""x"":5.099999904632568,""y"":1.5100634098052979},{""x"":5.099999904632568,""y"":1.9978814125061035},{""x"":5.099999904632568,""y"":2.1007437705993652},{""x"":5.599999904632568,""y"":0.7437329292297363},{""x"":5.599999904632568,""y"":0.8030821681022644},{""x"":5.599999904632568,""y"":1.0766953229904175},{""x"":5.599999904632568,""y"":1.5326048135757446},{""x"":5.599999904632568,""y"":1.5971065759658813},{""x"":6.099999904632568,""y"":0.31388434767723083},{""x"":6.099999904632568,""y"":0.6875622272491455},{""x"":6.099999904632568,""y"":0.855545163154602},{""x"":6.099999904632568,""y"":0.6559354662895203},{""x"":6.099999904632568,""y"":0.3100747764110565},{""x"":6.599999904632568,""y"":0.4792144000530243},{""x"":6.599999904632568,""y"":0.855309009552002},{""x"":6.599999904632568,""y"":0.18937373161315918},{""x"":6.599999904632568,""y"":0.3708323538303375},{""x"":6.599999904632568,""y"":0.08053481578826904},{""x"":7.099999904632568,""y"":0.7577306628227234},{""x"":7.099999904632568,""y"":0.3387751877307892},{""x"":7.099999904632568,""y"":0.1985611915588379},{""x"":7.099999904632568,""y"":0.172195702791214},{""x"":7.099999904632568,""y"":0.13258741796016693}]}],""chartOptions"":{""showStatistics"":[""auc""]}}"
36
- "null (15 rows, 2 columns)","{""series"":[{""parameters"":[1.4030933784862443,1.0245979562516274,1.7428150024861861,-3.5779850370795696],""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showCurveConfidenceInterval"":false,""points"":[{""x"":0.10000000149011612,""y"":5.7036309242248535},{""x"":0.6000000238418579,""y"":5.746265888214111},{""x"":1.100000023841858,""y"":5.299612045288086},{""x"":1.600000023841858,""y"":5.343863487243652},{""x"":2.0999999046325684,""y"":5.506134033203125},{""x"":2.5999999046325684,""y"":5.4817914962768555},{""x"":3.0999999046325684,""y"":5.3505539894104},{""x"":3.5999999046325684,""y"":5.151522159576416},{""x"":4.099999904632568,""y"":5.212680339813232},{""x"":4.599999904632568,""y"":4.80598783493042},{""x"":5.099999904632568,""y"":3.351301431655884},{""x"":5.599999904632568,""y"":2.108116865158081},{""x"":6.099999904632568,""y"":1.246281623840332},{""x"":6.599999904632568,""y"":0.5875148773193359},{""x"":7.099999904632568,""y"":0.6986792683601379}]},{""fitFunction"":""sigmoid"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showCurveConfidenceInterval"":false,""points"":[{""x"":0.10000000149011612,""y"":4.777379035949707},{""x"":0.6000000238418579,""y"":5.265642166137695},{""x"":1.100000023841858,""y"":5.713808059692383},{""x"":1.600000023841858,""y"":5.249830722808838},{""x"":2.0999999046325684,""y"":5.587547779083252},{""x"":2.5999999046325684,""y"":5.36907434463501},{""x"":3.0999999046325684,""y"":4.934175968170166},{""x"":3.5999999046325684,""y"":5.372972011566162},{""x"":4.099999904632568,""y"":5.017283916473389},{""x"":4.599999904632568,""y"":4.6751484870910645},{""x"":5.099999904632568,""y"":3.423663854598999},{""x"":5.599999904632568,""y"":1.594344973564148},{""x"":6.099999904632568,""y"":0.5661525130271912},{""x"":6.599999904632568,""y"":0.19819404184818268},{""x"":7.099999904632568,""y"":0.8421927690505981}]}]}","{""series"":[{""parameters"":[1.5400648543589148,1.7239324972922214,1.4063297934320662,0.33443731185267556],""fitFunction"":""sigmoid"",""fitLineColor"":""#2ca02c"",""pointColor"":""#2ca02c"",""showCurveConfidenceInterval"":true,""points"":[{""x"":0.10000000149011612,""y"":1.27737557888031},{""x"":0.6000000238418579,""y"":1.2780145406723022},{""x"":1.100000023841858,""y"":1.3489571809768677},{""x"":1.600000023841858,""y"":1.3250025510787964},{""x"":2.0999999046325684,""y"":1.309158444404602},{""x"":2.5999999046325684,""y"":1.441296935081482},{""x"":3.0999999046325684,""y"":1.3621265888214111},{""x"":3.5999999046325684,""y"":1.3409022092819214},{""x"":4.099999904632568,""y"":1.2703818082809448},{""x"":4.599999904632568,""y"":1.2195014953613281},{""x"":5.099999904632568,""y"":0.585429310798645},{""x"":5.599999904632568,""y"":0.19421088695526123},{""x"":6.099999904632568,""y"":0.2276361584663391},{""x"":6.599999904632568,""y"":0.03259352594614029},{""x"":7.099999904632568,""y"":0.03811067342758179}]}],""chartOptions"":{""showStatistics"":[""auc""]}}","{""series"":[{""parameters"":[1.3987701446422334,1.0025589776619843,1.950431059109577,1.57489342486818],""fitFunction"":""sigmoid"",""fitLineColor"":""#9467bd"",""pointColor"":""#9467bd"",""showCurveConfidenceInterval"":true,""points"":[{""x"":0.10000000149011612,""y"":0.03612012043595314},{""x"":0.10000000149011612,""y"":0.05706661567091942},{""x"":0.10000000149011612,""y"":0.007174440659582615},{""x"":0.10000000149011612,""y"":0.006656676065176725},{""x"":0.10000000149011612,""y"":0.03480849787592888},{""x"":0.6000000238418579,""y"":0.0665726289153099},{""x"":0.6000000238418579,""y"":0.054525356739759445},{""x"":0.6000000238418579,""y"":0.055943023413419724},{""x"":0.6000000238418579,""y"":0.0544852614402771},{""x"":0.6000000238418579,""y"":0.02734142541885376},{""x"":1.100000023841858,""y"":0.02047267183661461},{""x"":1.100000023841858,""y"":0.04814719781279564},{""x"":1.100000023841858,""y"":0.05629648640751839},{""x"":1.100000023841858,""y"":0.05200682207942009},{""x"":1.100000023841858,""y"":0.046626269817352295},{""x"":1.600000023841858,""y"":0.027950428426265717},{""x"":1.600000023841858,""y"":0.021106986328959465},{""x"":1.600000023841858,""y"":0.011796108447015285},{""x"":1.600000023841858,""y"":0.04013078659772873},{""x"":1.600000023841858,""y"":0.018657365813851357},{""x"":2.0999999046325684,""y"":0.010390376672148705},{""x"":2.0999999046325684,""y"":0.06717702001333237},{""x"":2.0999999046325684,""y"":0.015734216198325157},{""x"":2.0999999046325684,""y"":0.0005020603421144187},{""x"":2.0999999046325684,""y"":0.03601917624473572},{""x"":2.5999999046325684,""y"":0.04580968990921974},{""x"":2.5999999046325684,""y"":0.013811883516609669},{""x"":2.5999999046325684,""y"":0.0347907729446888},{""x"":2.5999999046325684,""y"":0.003400992602109909},{""x"":2.5999999046325684,""y"":0.0658077746629715},{""x"":3.0999999046325684,""y"":0.06470326334238052},{""x"":3.0999999046325684,""y"":0.040105774998664856},{""x"":3.0999999046325684,""y"":0.004536386113613844},{""x"":3.0999999046325684,""y"":0.028299888595938683},{""x"":3.0999999046325684,""y"":0.015297790057957172},{""x"":3.5999999046325684,""y"":0.010205036029219627},{""x"":3.5999999046325684,""y"":0.030351044610142708},{""x"":3.5999999046325684,""y"":0.02823905274271965},{""x"":3.5999999046325684,""y"":0.00543160829693079},{""x"":3.5999999046325684,""y"":0.03528806194663048},{""x"":4.099999904632568,""y"":0.024404611438512802},{""x"":4.099999904632568,""y"":0.021398605778813362},{""x"":4.099999904632568,""y"":0.01746137998998165},{""x"":4.099999904632568,""y"":0.06801135092973709},{""x"":4.099999904632568,""y"":0.02418249472975731},{""x"":4.599999904632568,""y"":0.08065827190876007},{""x"":4.599999904632568,""y"":0.03795705363154411},{""x"":4.599999904632568,""y"":0.03595327213406563},{""x"":4.599999904632568,""y"":0.019490951672196388},{""x"":4.599999904632568,""y"":0.0357535295188427},{""x"":5.099999904632568,""y"":0.06301134079694748},{""x"":5.099999904632568,""y"":0.04880264401435852},{""x"":5.099999904632568,""y"":0.046849530190229416},{""x"":5.099999904632568,""y"":0.046094998717308044},{""x"":5.099999904632568,""y"":0.07735799998044968},{""x"":5.599999904632568,""y"":0.10287926346063614},{""x"":5.599999904632568,""y"":0.15329882502555847},{""x"":5.599999904632568,""y"":0.09895746409893036},{""x"":5.599999904632568,""y"":0.10509312152862549},{""x"":5.599999904632568,""y"":0.10584071278572083},{""x"":6.099999904632568,""y"":0.19464170932769775},{""x"":6.099999904632568,""y"":0.1837087869644165},{""x"":6.099999904632568,""y"":0.19690236449241638},{""x"":6.099999904632568,""y"":0.14827826619148254},{""x"":6.099999904632568,""y"":0.15355728566646576},{""x"":6.599999904632568,""y"":0.21270307898521423},{""x"":6.599999904632568,""y"":0.19529509544372559},{""x"":6.599999904632568,""y"":0.20716492831707},{""x"":6.599999904632568,""y"":0.18739652633666992},{""x"":6.599999904632568,""y"":0.22446008026599884},{""x"":7.099999904632568,""y"":0.18822836875915527},{""x"":7.099999904632568,""y"":0.2324085384607315},{""x"":7.099999904632568,""y"":0.1877404898405075},{""x"":7.099999904632568,""y"":0.19784560799598694},{""x"":7.099999904632568,""y"":0.21554286777973175}]}],""chartOptions"":{""showStatistics"":[""auc""]}}"`,t=l.DataFrame.fromCsv(e),n=t.columns.byName("json chart 0"),r=t.columns.byName("json chart 1"),o=t.columns.byName("json chart 2");yield M.data.detectSemanticTypes(t),b(n.semType,R.h.FIT_SEM_TYPE),b(r.semType,R.h.FIT_SEM_TYPE),b(o.semType,R.h.FIT_SEM_TYPE),b(n.getTag(R.h.TAG_CURVE_FORMAT),null)})()),C("detectXMLCurveChart",()=>X(function*(){let e=`xmlCurveFitChart
37
- "<chart><grid><xAxis min=""0.0"" max=""5"" /><yAxis min=""-100"" max=""100"" /></grid><settings xLabel=""Concentration"" yLabel=""Activity"" logX=""true"" /><seriesCollection><series><x>7.2e-12,7.1e-12,7e-12,6e-8,6e-5,6e-4</x><y>112,115,116,100,123,124</y><fitLine><function type=""sigif""><params>2e-08,-1.5,125,-20</params></function></fitLine><settings color=""Green"" marker=""SquareBorder"" markerColor=""Yellow"" markerBorderColor=""Black"" errorBarColor=""Red"" showErrorBars=""True"" drawLine=""True"" bound=""True"" /></series></seriesCollection></chart>"`,t=l.DataFrame.fromCsv(e),n=t.columns.byName("xmlCurveFitChart");yield M.data.detectSemanticTypes(t),b(n.semType,R.h.FIT_SEM_TYPE),b(n.tags[R.h.TAG_FIT_CHART_FORMAT],R.h.TAG_FIT_CHART_FORMAT_3DX),b(n.getTag(R.h.TAG_CURVE_FORMAT),"3dx")})()),C("detectCompactDoseResponse",()=>X(function*(){let e=`compactDR
36
+ "null (15 rows, 2 columns)","{""series"":[{""parameters"":[1.4030933784862443,1.0245979562516274,1.7428150024861861,-3.5779850370795696],""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showCurveConfidenceInterval"":false,""points"":[{""x"":0.10000000149011612,""y"":5.7036309242248535},{""x"":0.6000000238418579,""y"":5.746265888214111},{""x"":1.100000023841858,""y"":5.299612045288086},{""x"":1.600000023841858,""y"":5.343863487243652},{""x"":2.0999999046325684,""y"":5.506134033203125},{""x"":2.5999999046325684,""y"":5.4817914962768555},{""x"":3.0999999046325684,""y"":5.3505539894104},{""x"":3.5999999046325684,""y"":5.151522159576416},{""x"":4.099999904632568,""y"":5.212680339813232},{""x"":4.599999904632568,""y"":4.80598783493042},{""x"":5.099999904632568,""y"":3.351301431655884},{""x"":5.599999904632568,""y"":2.108116865158081},{""x"":6.099999904632568,""y"":1.246281623840332},{""x"":6.599999904632568,""y"":0.5875148773193359},{""x"":7.099999904632568,""y"":0.6986792683601379}]},{""fitFunction"":""sigmoid"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showCurveConfidenceInterval"":false,""points"":[{""x"":0.10000000149011612,""y"":4.777379035949707},{""x"":0.6000000238418579,""y"":5.265642166137695},{""x"":1.100000023841858,""y"":5.713808059692383},{""x"":1.600000023841858,""y"":5.249830722808838},{""x"":2.0999999046325684,""y"":5.587547779083252},{""x"":2.5999999046325684,""y"":5.36907434463501},{""x"":3.0999999046325684,""y"":4.934175968170166},{""x"":3.5999999046325684,""y"":5.372972011566162},{""x"":4.099999904632568,""y"":5.017283916473389},{""x"":4.599999904632568,""y"":4.6751484870910645},{""x"":5.099999904632568,""y"":3.423663854598999},{""x"":5.599999904632568,""y"":1.594344973564148},{""x"":6.099999904632568,""y"":0.5661525130271912},{""x"":6.599999904632568,""y"":0.19819404184818268},{""x"":7.099999904632568,""y"":0.8421927690505981}]}]}","{""series"":[{""parameters"":[1.5400648543589148,1.7239324972922214,1.4063297934320662,0.33443731185267556],""fitFunction"":""sigmoid"",""fitLineColor"":""#2ca02c"",""pointColor"":""#2ca02c"",""showCurveConfidenceInterval"":true,""points"":[{""x"":0.10000000149011612,""y"":1.27737557888031},{""x"":0.6000000238418579,""y"":1.2780145406723022},{""x"":1.100000023841858,""y"":1.3489571809768677},{""x"":1.600000023841858,""y"":1.3250025510787964},{""x"":2.0999999046325684,""y"":1.309158444404602},{""x"":2.5999999046325684,""y"":1.441296935081482},{""x"":3.0999999046325684,""y"":1.3621265888214111},{""x"":3.5999999046325684,""y"":1.3409022092819214},{""x"":4.099999904632568,""y"":1.2703818082809448},{""x"":4.599999904632568,""y"":1.2195014953613281},{""x"":5.099999904632568,""y"":0.585429310798645},{""x"":5.599999904632568,""y"":0.19421088695526123},{""x"":6.099999904632568,""y"":0.2276361584663391},{""x"":6.599999904632568,""y"":0.03259352594614029},{""x"":7.099999904632568,""y"":0.03811067342758179}]}],""chartOptions"":{""showStatistics"":[""auc""]}}","{""series"":[{""parameters"":[1.3987701446422334,1.0025589776619843,1.950431059109577,1.57489342486818],""fitFunction"":""sigmoid"",""fitLineColor"":""#9467bd"",""pointColor"":""#9467bd"",""showCurveConfidenceInterval"":true,""points"":[{""x"":0.10000000149011612,""y"":0.03612012043595314},{""x"":0.10000000149011612,""y"":0.05706661567091942},{""x"":0.10000000149011612,""y"":0.007174440659582615},{""x"":0.10000000149011612,""y"":0.006656676065176725},{""x"":0.10000000149011612,""y"":0.03480849787592888},{""x"":0.6000000238418579,""y"":0.0665726289153099},{""x"":0.6000000238418579,""y"":0.054525356739759445},{""x"":0.6000000238418579,""y"":0.055943023413419724},{""x"":0.6000000238418579,""y"":0.0544852614402771},{""x"":0.6000000238418579,""y"":0.02734142541885376},{""x"":1.100000023841858,""y"":0.02047267183661461},{""x"":1.100000023841858,""y"":0.04814719781279564},{""x"":1.100000023841858,""y"":0.05629648640751839},{""x"":1.100000023841858,""y"":0.05200682207942009},{""x"":1.100000023841858,""y"":0.046626269817352295},{""x"":1.600000023841858,""y"":0.027950428426265717},{""x"":1.600000023841858,""y"":0.021106986328959465},{""x"":1.600000023841858,""y"":0.011796108447015285},{""x"":1.600000023841858,""y"":0.04013078659772873},{""x"":1.600000023841858,""y"":0.018657365813851357},{""x"":2.0999999046325684,""y"":0.010390376672148705},{""x"":2.0999999046325684,""y"":0.06717702001333237},{""x"":2.0999999046325684,""y"":0.015734216198325157},{""x"":2.0999999046325684,""y"":0.0005020603421144187},{""x"":2.0999999046325684,""y"":0.03601917624473572},{""x"":2.5999999046325684,""y"":0.04580968990921974},{""x"":2.5999999046325684,""y"":0.013811883516609669},{""x"":2.5999999046325684,""y"":0.0347907729446888},{""x"":2.5999999046325684,""y"":0.003400992602109909},{""x"":2.5999999046325684,""y"":0.0658077746629715},{""x"":3.0999999046325684,""y"":0.06470326334238052},{""x"":3.0999999046325684,""y"":0.040105774998664856},{""x"":3.0999999046325684,""y"":0.004536386113613844},{""x"":3.0999999046325684,""y"":0.028299888595938683},{""x"":3.0999999046325684,""y"":0.015297790057957172},{""x"":3.5999999046325684,""y"":0.010205036029219627},{""x"":3.5999999046325684,""y"":0.030351044610142708},{""x"":3.5999999046325684,""y"":0.02823905274271965},{""x"":3.5999999046325684,""y"":0.00543160829693079},{""x"":3.5999999046325684,""y"":0.03528806194663048},{""x"":4.099999904632568,""y"":0.024404611438512802},{""x"":4.099999904632568,""y"":0.021398605778813362},{""x"":4.099999904632568,""y"":0.01746137998998165},{""x"":4.099999904632568,""y"":0.06801135092973709},{""x"":4.099999904632568,""y"":0.02418249472975731},{""x"":4.599999904632568,""y"":0.08065827190876007},{""x"":4.599999904632568,""y"":0.03795705363154411},{""x"":4.599999904632568,""y"":0.03595327213406563},{""x"":4.599999904632568,""y"":0.019490951672196388},{""x"":4.599999904632568,""y"":0.0357535295188427},{""x"":5.099999904632568,""y"":0.06301134079694748},{""x"":5.099999904632568,""y"":0.04880264401435852},{""x"":5.099999904632568,""y"":0.046849530190229416},{""x"":5.099999904632568,""y"":0.046094998717308044},{""x"":5.099999904632568,""y"":0.07735799998044968},{""x"":5.599999904632568,""y"":0.10287926346063614},{""x"":5.599999904632568,""y"":0.15329882502555847},{""x"":5.599999904632568,""y"":0.09895746409893036},{""x"":5.599999904632568,""y"":0.10509312152862549},{""x"":5.599999904632568,""y"":0.10584071278572083},{""x"":6.099999904632568,""y"":0.19464170932769775},{""x"":6.099999904632568,""y"":0.1837087869644165},{""x"":6.099999904632568,""y"":0.19690236449241638},{""x"":6.099999904632568,""y"":0.14827826619148254},{""x"":6.099999904632568,""y"":0.15355728566646576},{""x"":6.599999904632568,""y"":0.21270307898521423},{""x"":6.599999904632568,""y"":0.19529509544372559},{""x"":6.599999904632568,""y"":0.20716492831707},{""x"":6.599999904632568,""y"":0.18739652633666992},{""x"":6.599999904632568,""y"":0.22446008026599884},{""x"":7.099999904632568,""y"":0.18822836875915527},{""x"":7.099999904632568,""y"":0.2324085384607315},{""x"":7.099999904632568,""y"":0.1877404898405075},{""x"":7.099999904632568,""y"":0.19784560799598694},{""x"":7.099999904632568,""y"":0.21554286777973175}]}],""chartOptions"":{""showStatistics"":[""auc""]}}"`,t=l.DataFrame.fromCsv(e),n=t.columns.byName("json chart 0"),r=t.columns.byName("json chart 1"),o=t.columns.byName("json chart 2");yield V.data.detectSemanticTypes(t),_(n.semType,$.h.FIT_SEM_TYPE),_(r.semType,$.h.FIT_SEM_TYPE),_(o.semType,$.h.FIT_SEM_TYPE),_(n.getTag($.h.TAG_CURVE_FORMAT),null)})()),P("detectXMLCurveChart",()=>q(function*(){let e=`xmlCurveFitChart
37
+ "<chart><grid><xAxis min=""0.0"" max=""5"" /><yAxis min=""-100"" max=""100"" /></grid><settings xLabel=""Concentration"" yLabel=""Activity"" logX=""true"" /><seriesCollection><series><x>7.2e-12,7.1e-12,7e-12,6e-8,6e-5,6e-4</x><y>112,115,116,100,123,124</y><fitLine><function type=""sigif""><params>2e-08,-1.5,125,-20</params></function></fitLine><settings color=""Green"" marker=""SquareBorder"" markerColor=""Yellow"" markerBorderColor=""Black"" errorBarColor=""Red"" showErrorBars=""True"" drawLine=""True"" bound=""True"" /></series></seriesCollection></chart>"`,t=l.DataFrame.fromCsv(e),n=t.columns.byName("xmlCurveFitChart");yield V.data.detectSemanticTypes(t),_(n.semType,$.h.FIT_SEM_TYPE),_(n.tags[$.h.TAG_FIT_CHART_FORMAT],$.h.TAG_FIT_CHART_FORMAT_3DX),_(n.getTag($.h.TAG_CURVE_FORMAT),"3dx")})()),P("detectCompactDoseResponse",()=>q(function*(){let e=`compactDR
38
38
  "{""rdt"":""2025-05-31 00:00:00.0"",""mnr"":-4.28,""mxr"":109.134,""yu"":""%"",""hs"":-1.5498,""poi"":0.0064758,""xu"":""uM"",""ctp"":""dose-response"",""p"":[[0.001,3],[0.003,4],[0.01,7],[0.03,15],[0.1,35],[0.3,65],[1,85],[3,98],[10,105]]}"
39
- "{""rdt"":""2025-06-01 00:00:00.0"",""mnr"":2.1,""mxr"":95.5,""yu"":""%"",""hs"":-1.2,""poi"":0.015,""xu"":""uM"",""ctp"":""dose-response"",""p"":[[0.001,5],[0.003,6],[0.01,10],[0.03,20],[0.1,45],[0.3,70],[1,88],[3,94],[10,96]]}"`,t=l.DataFrame.fromCsv(e),n=t.columns.byName("compactDR");yield M.data.detectSemanticTypes(t),b(n.semType,R.h.FIT_SEM_TYPE),b(n.getTag(R.h.TAG_CURVE_FORMAT),"compact-dr")})()),C("detectPzfxCurveChart",()=>X(function*(){let e=`<?xml version="1.0" encoding="UTF-8"?>
39
+ "{""rdt"":""2025-06-01 00:00:00.0"",""mnr"":2.1,""mxr"":95.5,""yu"":""%"",""hs"":-1.2,""poi"":0.015,""xu"":""uM"",""ctp"":""dose-response"",""p"":[[0.001,5],[0.003,6],[0.01,10],[0.03,20],[0.1,45],[0.3,70],[1,88],[3,94],[10,96]]}"`,t=l.DataFrame.fromCsv(e),n=t.columns.byName("compactDR");yield V.data.detectSemanticTypes(t),_(n.semType,$.h.FIT_SEM_TYPE),_(n.getTag($.h.TAG_CURVE_FORMAT),"compact-dr")})()),P("detectPzfxCurveChart",()=>q(function*(){let e=`<?xml version="1.0" encoding="UTF-8"?>
40
40
  <GraphPadPrismFile xmlns="http://graphpad.com/prism/Prism.htm" PrismXMLVersion="5.00">
41
41
  <Table ID="Table0" XFormat="numbers" TableType="XY">
42
42
  <Title>Test</Title>
@@ -49,7 +49,7 @@ ${e.stack?await DG.Logger.translateStackTrace(e.stack):""}`}async function N(e,t
49
49
  <Subcolumn><d>10</d><d>20</d><d>30</d></Subcolumn>
50
50
  </YColumn>
51
51
  </Table>
52
- </GraphPadPrismFile>`,t=l.DataFrame.fromColumns([l.Column.fromStrings("pzfx",[e])]),n=t.columns.byName("pzfx");yield M.data.detectSemanticTypes(t),b(n.semType,R.h.FIT_SEM_TYPE),b(n.getTag(R.h.TAG_CURVE_FORMAT),"pzfx")})())});var Y=n(190),k=n(287),j=n(305),G=n(124);function V(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function B(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){V(i,r,o,l,a,"next",e)}function a(e){V(i,r,o,l,a,"throw",e)}l(void 0)})}}let $='<chart><grid><xAxis min="0.0" max="5" /><yAxis min="-100" max="100" /></grid><settings xLabel="Concentration" yLabel="Activity" logX="true" /><seriesCollection><series name="Series1"><x>7.2e-12,7.1e-12,7e-12,6e-8,6e-5,6e-4</x><y>112,115,116,100,123,124</y><mask>111101</mask><fitLine><function type="sigif"><params>2e-08,-1.5,125,-20</params></function></fitLine><settings color="Green" marker="SquareBorder" markerColor="Yellow" markerBorderColor="Black" errorBarColor="Red" showErrorBars="True" drawLine="True" bound="True" /></series></seriesCollection></chart>',H='{"rdt":"2025-05-31 00:00:00.0","mnr":-4.28,"mxr":109.134,"yu":"%","hs":-1.5498,"poi":0.0064758,"xu":"uM","ctp":"dose-response","p":[[0.001,3],[0.003,4],[0.01,7],[0.03,15],[0.1,35],[0.3,65],[1,85],[3,98],[10,105]]}',q='{"series":[{"fitFunction":"sigmoid","parameters":[100,-1.5,0.01,-5],"fitLineColor":"#1f77b4","pointColor":"#1f77b4","showFitLine":true,"showPoints":"points","points":[{"x":0.001,"y":3},{"x":0.01,"y":7},{"x":0.1,"y":35},{"x":1,"y":85},{"x":10,"y":105}]}],"chartOptions":{"logX":true,"xAxisName":"Concentration","yAxisName":"Response"}}',W=`<?xml version="1.0" encoding="UTF-8"?>
52
+ </GraphPadPrismFile>`,t=l.DataFrame.fromColumns([l.Column.fromStrings("pzfx",[e])]),n=t.columns.byName("pzfx");yield V.data.detectSemanticTypes(t),_(n.semType,$.h.FIT_SEM_TYPE),_(n.getTag($.h.TAG_CURVE_FORMAT),"pzfx")})()),P("curve JSON needs only series with points",()=>q(function*(){let e=JSON.stringify({series:[{points:[{x:.1,y:1},{x:1,y:5},{x:10,y:9}]}]}),t=l.DataFrame.fromColumns([l.Column.fromStrings("curvecol",[e,e])]);yield V.data.detectSemanticTypes(t),_(t.col("curvecol").semType,$.h.FIT_SEM_TYPE)})()),P("curve columns come back whole and detected from an exported CSV",()=>q(function*(){let e=yield V.dapi.files.readCsv("System:AppData/Curves/curves-demo.csv");yield V.data.detectSemanticTypes(e);let t=e.columns.bySemTypeAll($.h.FIT_SEM_TYPE).map(e=>e.name);_(t.length,5,`the demo has five curve columns, found ${t}`);let n=l.DataFrame.fromCsv(e.toCsv());for(let r of(yield V.data.detectSemanticTypes(n),_(n.rowCount,e.rowCount),_(n.columns.names().join(", "),e.columns.names().join(", ")),t)){_(n.col(r).semType,$.h.FIT_SEM_TYPE,`${r} is not a curve column again`);for(let t=0;t<e.rowCount;t++)_(n.get(r,t),e.get(r,t),`${r} changed in row ${t}`)}})())});var W=n(190),J=n(287),U=n(305),z=n(124);function Z(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function K(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){Z(i,r,o,l,a,"next",e)}function a(e){Z(i,r,o,l,a,"throw",e)}l(void 0)})}}let Q='<chart><grid><xAxis min="0.0" max="5" /><yAxis min="-100" max="100" /></grid><settings xLabel="Concentration" yLabel="Activity" logX="true" /><seriesCollection><series name="Series1"><x>7.2e-12,7.1e-12,7e-12,6e-8,6e-5,6e-4</x><y>112,115,116,100,123,124</y><mask>111101</mask><fitLine><function type="sigif"><params>2e-08,-1.5,125,-20</params></function></fitLine><settings color="Green" marker="SquareBorder" markerColor="Yellow" markerBorderColor="Black" errorBarColor="Red" showErrorBars="True" drawLine="True" bound="True" /></series></seriesCollection></chart>',ee='{"rdt":"2025-05-31 00:00:00.0","mnr":-4.28,"mxr":109.134,"yu":"%","hs":-1.5498,"poi":0.0064758,"xu":"uM","ctp":"dose-response","p":[[0.001,3],[0.003,4],[0.01,7],[0.03,15],[0.1,35],[0.3,65],[1,85],[3,98],[10,105]]}',et='{"series":[{"fitFunction":"sigmoid","parameters":[100,-1.5,0.01,-5],"fitLineColor":"#1f77b4","pointColor":"#1f77b4","showFitLine":true,"showPoints":"points","points":[{"x":0.001,"y":3},{"x":0.01,"y":7},{"x":0.1,"y":35},{"x":1,"y":85},{"x":10,"y":105}]}],"chartOptions":{"logX":true,"xAxisName":"Concentration","yAxisName":"Response"}}',en=`<?xml version="1.0" encoding="UTF-8"?>
53
53
  <GraphPadPrismFile xmlns="http://graphpad.com/prism/Prism.htm" PrismXMLVersion="5.00">
54
54
  <Table ID="Table0" XFormat="numbers" TableType="XY">
55
55
  <Title>IC50 Curve</Title>
@@ -74,7 +74,7 @@ ${e.stack?await DG.Logger.translateStackTrace(e.stack):""}`}async function N(e,t
74
74
  </Subcolumn>
75
75
  </YColumn>
76
76
  </Table>
77
- </GraphPadPrismFile>`,J=`<?xml version="1.0" encoding="UTF-8"?>
77
+ </GraphPadPrismFile>`,er=`<?xml version="1.0" encoding="UTF-8"?>
78
78
  <GraphPadPrismFile xmlns="http://graphpad.com/prism/Prism.htm" PrismXMLVersion="5.00">
79
79
  <Table ID="Table0" XFormat="numbers" TableType="XY">
80
80
  <Title>With Outlier</Title>
@@ -91,10 +91,10 @@ ${e.stack?await DG.Logger.translateStackTrace(e.stack):""}`}async function N(e,t
91
91
  </Subcolumn>
92
92
  </YColumn>
93
93
  </Table>
94
- </GraphPadPrismFile>`;O("converters",()=>{C("xmlConverter.basicConversion",()=>B(function*(){var e,t,n;let r=JSON.parse((0,Y.J)($));b(void 0!==r.series&&r.series.length>0,!0),b(r.series[0].points.length,6),b(null==(e=r.chartOptions)?void 0:e.xAxisName,"Concentration"),b(null==(t=r.chartOptions)?void 0:t.yAxisName,"Activity"),b(null==(n=r.chartOptions)?void 0:n.logX,!0)})()),C("xmlConverter.booleanAttributes",()=>B(function*(){var e,t;let n=$.replace('drawLine="True"','drawLine="False"').replace('logX="true"','logX="false"'),r=JSON.parse((0,Y.J)(n));b(r.series[0].showFitLine,!1),b(null==(e=r.chartOptions)?void 0:e.logX,!1);let o=JSON.parse((0,Y.J)($));b(o.series[0].showFitLine,!0),b(null==(t=o.chartOptions)?void 0:t.logX,!0)})()),C("xmlConverter.logYNotInvented",()=>B(function*(){b("logY"in JSON.parse((0,Y.J)($)).chartOptions,!1,"the cell must not own logY when the export omits it");let e=$.replace('logX="true"','logX="true" logY="true"');b(JSON.parse((0,Y.J)(e)).chartOptions.logY,!0)})()),C("xmlConverter.parameterReordering",()=>B(function*(){let e=JSON.parse((0,Y.J)($)).series[0].parameters;b(e[0],125),b(e[1],-1.5),b(e[2],2e-8),b(e[3],-20)})()),C("xmlConverter.outlierMask",()=>B(function*(){let e=JSON.parse((0,Y.J)($));b(e.series[0].points.length,6),b(e.series[0].points[0].outlier,!1),b(e.series[0].points[3].outlier,!1),b(e.series[0].points[4].outlier,!0),b(e.series[0].points[5].outlier,!1)})()),C("compactDrConverter.basicConversion",()=>B(function*(){var e,t,n;let r=JSON.parse((0,k.G)(H));b(void 0!==r.series&&1===r.series.length,!0),b(r.series[0].points.length,9),b(null==(e=r.chartOptions)?void 0:e.xAxisName,"uM"),b(null==(t=r.chartOptions)?void 0:t.yAxisName,"%"),b(null==(n=r.chartOptions)?void 0:n.logX,!0)})()),C("compactDrConverter.parameters",()=>B(function*(){let e=JSON.parse((0,k.G)(H)).series[0].parameters;b(e[0],109.134),b(e[1],-1.5498),b(e[2],.0064758),b(e[3],-4.28)})()),C("compactDrConverter.outlierFlag",()=>B(function*(){let e=JSON.parse((0,k.G)('{"rdt":"2025-05-31 00:00:00.0","mnr":-4.28,"mxr":109.134,"yu":"%","hs":-1.5498,"poi":0.0064758,"xu":"uM","ctp":"dose-response","p":[[0.001,3],[0.003,4],[0.01,7,1],[0.03,15],[0.1,35]]}'));b(e.series[0].points[0].outlier,!1),b(e.series[0].points[1].outlier,!1),b(e.series[0].points[2].outlier,!0),b(e.series[0].points[3].outlier,!1)})()),C("compactDrConverter.fitFunction",()=>B(function*(){let e=JSON.parse((0,k.G)(H));b(e.series[0].fitFunction,"4pl-dose-response"),b(e.series[0].showFitLine,!0),b(e.series[0].showPoints,"points")})()),C("parseCellValue.nativeJson",()=>B(function*(){var e;let t=(0,G.HB)(q,null);b(void 0!==t.series&&1===t.series.length,!0),b(t.series[0].points.length,5),b(null==(e=t.chartOptions)?void 0:e.logX,!0)})()),C("parseCellValue.withConverter",()=>B(function*(){var e;(0,G.l8)("compact-dr",k.G);let t=l.DataFrame.fromColumns([l.Column.fromStrings("curves",[H])]).col("curves");t.setTag(R.h.TAG_CURVE_FORMAT,"compact-dr");let n=(0,G.HB)(H,t);b(void 0!==n.series&&1===n.series.length,!0),b(n.series[0].points.length,9),b(null==(e=n.chartOptions)?void 0:e.logX,!0)})()),C("isNativeFormat.nativeColumn",()=>B(function*(){let e=l.DataFrame.fromColumns([l.Column.fromStrings("curves",[q])]).col("curves");b((0,G.XN)(e),!0),b((0,G.nL)(e),!1)})()),C("isNativeFormat.converterColumn",()=>B(function*(){let e=l.DataFrame.fromColumns([l.Column.fromStrings("curves",[H])]).col("curves");e.setTag(R.h.TAG_CURVE_FORMAT,"compact-dr"),b((0,G.XN)(e),!1),b((0,G.nL)(e),!0)})()),C("parseCellValue.emptyValue",()=>B(function*(){let e=(0,G.HB)("",null);b(void 0!==e.series&&0===e.series.length,!0)})()),C("parseCellValue.malformedJson",()=>B(function*(){let e=(0,G.HB)('{series: [{name: "A", points: [{x:0,y:50}]}]}',null);b(void 0!==e.series&&0===e.series.length,!0)})()),C("converterCaching",()=>B(function*(){(0,G.l8)("compact-dr",k.G);let e=l.DataFrame.fromColumns([l.Column.fromStrings("curves",[H])]).col("curves");e.setTag(R.h.TAG_CURVE_FORMAT,"compact-dr");let t=(0,G.HB)(H,e),n=(0,G.HB)(H,e);b(t.series[0].points.length,n.series[0].points.length)})())}),O("converters: rendering integration",()=>{C("xmlColumnRendering",()=>B(function*(){(0,G.l8)("3dx",Y.J);let e=`xmlCurve
95
- "<chart><grid><xAxis min=""0.0"" max=""5"" /><yAxis min=""-100"" max=""100"" /></grid><settings xLabel=""Concentration"" yLabel=""Activity"" logX=""true"" /><seriesCollection><series name=""S1""><x>7.2e-12,7.1e-12,7e-12,6e-8,6e-5,6e-4</x><y>112,115,116,100,123,124</y><mask>111111</mask><fitLine><function type=""sigif""><params>2e-08,-1.5,125,-20</params></function></fitLine><settings color=""Green"" marker=""SquareBorder"" markerColor=""Yellow"" markerBorderColor=""Black"" errorBarColor=""Red"" showErrorBars=""True"" drawLine=""True"" bound=""True"" /></series></seriesCollection></chart>"`,t=l.DataFrame.fromCsv(e),n=t.columns.byName("xmlCurve");yield M.data.detectSemanticTypes(t),b(n.semType,R.h.FIT_SEM_TYPE);let r=(0,G.HB)(n.get(0),n);b(void 0!==r.series&&r.series.length>0,!0),b(r.series[0].points.length,6)})()),C("compactDrColumnRendering",()=>B(function*(){(0,G.l8)("compact-dr",k.G);let e=`compactDR
96
- "{""rdt"":""2025-05-31 00:00:00.0"",""mnr"":-4.28,""mxr"":109.134,""yu"":""%"",""hs"":-1.5498,""poi"":0.0064758,""xu"":""uM"",""ctp"":""dose-response"",""p"":[[0.001,3],[0.003,4],[0.01,7],[0.03,15],[0.1,35],[0.3,65],[1,85],[3,98],[10,105]]}"`,t=l.DataFrame.fromCsv(e),n=t.columns.byName("compactDR");yield M.data.detectSemanticTypes(t),b(n.semType,R.h.FIT_SEM_TYPE);let r=(0,G.HB)(n.get(0),n);b(void 0!==r.series&&1===r.series.length,!0),b(r.series[0].parameters[0],109.134)})()),C("nativeJsonColumnRendering",()=>B(function*(){let e=`nativeJSON
97
- "${'{"series":[{"fitFunction":"sigmoid","parameters":[100,-1.5,0.01,-5],"fitLineColor":"#1f77b4","pointColor":"#1f77b4","showFitLine":true,"showPoints":"points","points":[{"x":0.001,"y":3},{"x":0.01,"y":7},{"x":0.1,"y":35},{"x":1,"y":85},{"x":10,"y":105}]}],"chartOptions":{"logX":true}}'.replace(/"/g,'""')}"`,t=l.DataFrame.fromCsv(e),n=t.columns.byName("nativeJSON");yield M.data.detectSemanticTypes(t),b(n.semType,R.h.FIT_SEM_TYPE),b((0,G.XN)(n),!0),b((0,G.HB)(n.get(0),n).series[0].points.length,5)})()),C("pzfxColumnRendering",()=>B(function*(){var e;(0,G.l8)("pzfx",j.R);let t=l.DataFrame.fromColumns([l.Column.fromStrings("pzfx",[W])]).col("pzfx");t.setTag(R.h.TAG_CURVE_FORMAT,"pzfx"),t.semType=R.h.FIT_SEM_TYPE;let n=(0,G.HB)(t.get(0),t);b(void 0!==n.series&&1===n.series.length,!0),b(n.series[0].points.length,5),b(null==(e=n.chartOptions)?void 0:e.logX,!0)})())}),O("converters: pzfx",()=>{C("pzfxConverter.basicConversion",()=>B(function*(){var e,t;let n=JSON.parse((0,j.R)(W));b(void 0!==n.series&&1===n.series.length,!0),b(n.series[0].points.length,5),b(n.series[0].name,"Response A"),b(null==(e=n.chartOptions)?void 0:e.xAxisName,"Dose"),b(null==(t=n.chartOptions)?void 0:t.logX,!0)})()),C("pzfxConverter.pointValues",()=>B(function*(){let e=JSON.parse((0,j.R)(W)).series[0].points;b(e[0].x,1e-9),b(e[0].y,5.1),b(e[4].x,1e-5),b(e[4].y,97.2)})()),C("pzfxConverter.outlierExclusion",()=>B(function*(){let e=JSON.parse((0,j.R)(J));b(e.series[0].points.length,3),b(e.series[0].points[0].outlier,!1),b(e.series[0].points[1].outlier,!0),b(e.series[0].points[2].outlier,!1)})()),C("pzfxConverter.withConverterTag",()=>B(function*(){(0,G.l8)("pzfx",j.R);let e=l.DataFrame.fromColumns([l.Column.fromStrings("curves",[W])]).col("curves");e.setTag(R.h.TAG_CURVE_FORMAT,"pzfx");let t=(0,G.HB)(W,e);b(void 0!==t.series&&1===t.series.length,!0),b(t.series[0].points.length,5)})())});var U=n(389),z=n(991),Z=n.n(z),K=n(301),Q=n(129);function ee(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function et(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){ee(i,r,o,l,a,"next",e)}function a(e){ee(i,r,o,l,a,"throw",e)}l(void 0)})}}function en(e){let t={series:[],chartOptions:{showStatistics:["auc"]}},n=(0,K.kL)(e,.5),r=l.Color.toHtml(l.Color.scatterPlotMarker);return t.series[0]={fitLineColor:r,pointColor:r,markerType:l.MARKER_TYPE.CIRCLE,showFitLine:!0,showPoints:"points",showCurveConfidenceInterval:!0,fitFunction:"sigmoid",points:Z().count().take(e).map(function(e){return{x:n.x[e],y:n.y[e]}}).toArray()},t}function er(e,t,n,r){return et(function*(){for(let o=0;o<n;o++)e.dispatchEvent(new WheelEvent("wheel",{deltaY:t})),yield E(r)})()}function eo(e,t){return et(function*(){let n=Date.now();return yield e(t),Date.now().valueOf()-n.valueOf()})()}O("creation",()=>{C("fit curve creation",()=>et(function*(){let e=l.Test.isInBenchmark?1e3:100,t=yield eo(t=>et(function*(){let t=(0,K.nO)(e,5,2);M.shell.addTableView(t)})(),null);return console.log(`Creation took ${t} ms`),`${e} points, took ${t} ms`})(),{benchmark:!0})}),O("rendering",()=>{C("rendering same fitChartData on canvas",()=>et(function*(){let e=U.canvas(160,120);M.shell.newView("canvas",[e]);let t=e.getContext("2d"),n=new Q.l,r=en(l.Test.isInBenchmark?50:15),o=[],i=o=>et(function*(){n.renderCurves(t,Q.l.inflateScreenBounds(new l.Rect(e.clientLeft,e.clientTop,160,120)),r),t.clearRect(0,0,160,120)})();for(let e=1;e<=1e3;e++)o[o.length]=yield eo(i);return`rendering performed 1000 times, max time is ${Math.max(...o)} ms, min time is ${Math.min(...o)} ms, average time is ${o.reduce((e,t)=>e+t,0)/o.length} ms`})(),{benchmark:!0}),C("rendering different fitChartData on canvas",()=>et(function*(){let e=U.canvas(160,120);M.shell.newView("canvas",[e]);let t=e.getContext("2d"),n=new Q.l,r=[],o=r=>et(function*(){n.renderCurves(t,Q.l.inflateScreenBounds(new l.Rect(e.clientLeft,e.clientTop,160,120)),r),t.clearRect(0,0,160,120)})();for(let e=1;e<=1e3;e++){let e=en(l.Test.isInBenchmark?50:15);r[r.length]=yield eo(o,e)}return`rendering performed 1000 times, max time is ${Math.max(...r)} ms, min time is ${Math.min(...r)} ms, average time is ${r.reduce((e,t)=>e+t,0)/r.length} ms`})(),{benchmark:!0}),C("rendering in grid",()=>et(function*(){let e=(0,K.nO)(50,5,5),t=M.shell.addTableView(e);yield E(100);let n=t.grid.root.getElementsByTagName("canvas")[2],r=(yield eo(e=>et(function*(){yield er(n,300,10,1),yield er(n,-300,10,1),yield er(n,300,10,1)})(),null))-30;return console.log(`curves rendering took ${r} ms`),r})(),{benchmark:!0})});var ei=n(533),el=n(324);function ea(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}O("viewport",()=>{C("viewportMethods",()=>{var e;return(e=function*(){let e=Q.l.inflateScreenBounds(new l.Rect(120,20,160,100)),[t]=(0,el.Tv)(e,!1,!1,!1),n=new l.Rect(.1,.06,7,5.94),r=new ei.L(n,t,!1,!1);b(r.xToScreen(1.5),182.4),b(r.yToScreen(2.33),73.01346801346801),b(r.xToWorld(150),-.9652173913043479),b(r.yToWorld(67),2.855294117647059)},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){ea(i,r,o,l,a,"next",e)}function a(e){ea(i,r,o,l,a,"throw",e)}l(void 0)})})()})});var es=n(165),eu=n(774),ec=n(869),ed=n(590),ef=n(18),em=n(684);function ep(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function eh(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){ep(i,r,o,l,a,"next",e)}function a(e){ep(i,r,o,l,a,"throw",e)}l(void 0)})}}function eg(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 ev(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}let ey={fitLineColor:"#1f77b4",pointColor:"#1f77b4",showCurveConfidenceInterval:!1,points:[{x:.10000000149011612,y:1.7412786483764648},{x:.6000000238418579,y:1.8561450242996216},{x:1.100000023841858,y:1.6065685749053955},{x:1.600000023841858,y:1.70476496219635},{x:2.0999999046325684,y:1.5737264156341553},{x:2.5999999046325684,y:1.6007002592086792},{x:3.0999999046325684,y:1.6796687841415405},{x:3.5999999046325684,y:1.656104326248169},{x:4.099999904632568,y:1.782997488975525},{x:4.599999904632568,y:1.530208945274353},{x:5.099999904632568,y:1.1572397947311401},{x:5.599999904632568,y:.8691964745521545},{x:6.099999904632568,y:.3228665590286255},{x:6.599999904632568,y:.2990703880786896},{x:7.099999904632568,y:.23361243307590485}],fitFunction:"sigmoid",clickToToggle:!1,showFitLine:!0,showPoints:"points",parameters:[1.6914372095641517,1.1536998642628853,5.410173358224149,.2089689354045083]},ex={fitLineColor:"#1f77b4",pointColor:"#1f77b4",showCurveConfidenceInterval:!1,points:[{x:.10000000149011612,y:1.5412786483764649},{x:.6000000238418579,y:1.9261450242996216},{x:1.100000023841858,y:1.6065685749053955},{x:1.600000023841858,y:1.70476496219635},{x:2.0999999046325684,y:1.5737264156341553},{x:2.5999999046325684,y:1.6007002592086792},{x:3.0999999046325684,y:1.6796687841415405},{x:3.5999999046325684,y:1.656104326248169},{x:4.099999904632568,y:1.782997488975525},{x:4.599999904632568,y:1.530208945274353},{x:5.099999904632568,y:1.1572397947311401},{x:5.599999904632568,y:.8691964745521545},{x:6.099999904632568,y:.3228665590286255},{x:6.599999904632568,y:.2990703880786896},{x:7.099999904632568,y:.23361243307590485}],fitFunction:"linear",clickToToggle:!1,showFitLine:!0,showPoints:"points",parameters:[-5.45641324,10.456486765]},eC={fitLineColor:"#1f77b4",pointColor:"#1f77b4",showCurveConfidenceInterval:!1,points:[{x:.10000000149011612,y:1.7897127864837648},{x:.6000000238418579,y:1.2101614502429963},{x:1.100000023841858,y:1.7895685749053956},{x:1.600000023841858,y:1.82476496219635},{x:2.0999999046325684,y:1.5737264156341553},{x:2.5999999046325684,y:1.6007002592086792},{x:3.0999999046325684,y:1.6796687841415405},{x:3.5999999046325684,y:1.656104326248169},{x:4.099999904632568,y:1.782997488975525},{x:4.599999904632568,y:1.530208945274353},{x:5.099999904632568,y:1.1572397947311401},{x:5.599999904632568,y:.8691964745521545},{x:6.099999904632568,y:.3228665590286255},{x:6.599999904632568,y:.2990703880786896},{x:7.099999904632568,y:.23361243307590485}],fitFunction:"log-linear",clickToToggle:!1,showFitLine:!0,showPoints:"points",parameters:[-8.45641324,90.4456456486765]},eb={fitLineColor:"#1f77b4",pointColor:"#1f77b4",showCurveConfidenceInterval:!1,points:[{x:.10000000149011612,y:1.7897127864837648},{x:.6000000238418579,y:1.2101614502429963},{x:1.100000023841858,y:1.7895685749053956},{x:1.600000023841858,y:1.82476496219635},{x:2.0999999046325684,y:1.5737264156341553},{x:2.5999999046325684,y:1.6007002592086792},{x:3.0999999046325684,y:1.6796687841415405},{x:3.5999999046325684,y:1.656104326248169},{x:4.099999904632568,y:1.782997488975525},{x:4.599999904632568,y:1.530208945274353},{x:5.099999904632568,y:1.1572397947311401},{x:5.599999904632568,y:.8691964745521545},{x:6.099999904632568,y:.3228665590286255},{x:6.599999904632568,y:.2990703880786896},{x:7.099999904632568,y:.23361243307590485}],fitFunction:"exponential",clickToToggle:!1,showFitLine:!0,showPoints:"points",parameters:[88.45641324,-10.4456456486765]},ew={fitLineColor:"#2ca02c",pointColor:"#2ca02c",showCurveConfidenceInterval:!0,fitFunction:{name:"Polynomial",function:"([p1, p2, p3, p4], x) => p1 * x * x * x + p2 * x * x + p3 * x + p4",getInitialParameters:"(xs, ys) => [0.1, -1, 4, 4]",parameterNames:["Slope","Intercept","Parameter3","Parameter4"]},points:[{x:.10000000149011612,y:7.365033149719238},{x:.6000000238418579,y:6.595034599304199},{x:1.100000023841858,y:7.05179500579834},{x:1.600000023841858,y:7.251461982727051},{x:2.0999999046325684,y:7.775498867034912},{x:2.5999999046325684,y:7.748039722442627},{x:3.0999999046325684,y:6.8391804695129395},{x:3.5999999046325684,y:7.570991516113281},{x:4.099999904632568,y:6.387666702270508},{x:4.599999904632568,y:6.464827537536621},{x:5.099999904632568,y:3.932436227798462},{x:5.599999904632568,y:1.4741199016571045},{x:6.099999904632568,y:.47604307532310486},{x:6.599999904632568,y:.5836760401725769},{x:7.099999904632568,y:1.0317600965499878}],clickToToggle:!1,showFitLine:!0,showPoints:"points",parameters:[.07070206940832963,-1.138666933634074,3.947509109407932,3.9947960440506685]},eT=(0,es.zB)(ey),eO=(0,es.zB)(ex),eS=(0,es.zB)(eC),eI=(0,es.zB)(eb),eP=(0,es.zB)(ew);O("fit",()=>{C("getSeriesFitFunction",()=>eh(function*(){var e;let{xs:t,ys:n}=(0,es.W$)(ey.points),{xs:r,ys:o}=(0,es.W$)(ex.points),{xs:i,ys:l}=(0,es.W$)(eC.points),{xs:a,ys:s}=(0,es.W$)(eb.points),{xs:u,ys:c}=(0,es.W$)(ew.points);b(eT.name,ed.G7),b(eO.name,ed.Ff),b(eS.name,ed.kx),b(eI.name,ed.Pf),b(eP.name,"Polynomial"),T(eT.parameterNames,["Top","Slope","IC50","Bottom"]),T(eO.parameterNames,["Slope","Intercept"]),T(eS.parameterNames,["Slope","Intercept"]),T(eI.parameterNames,["Mantissa","Power"]),T(eP.parameterNames,["Slope","Intercept","Parameter3","Parameter4"]),T(eT.getInitialParameters(t,n),[1.8561450242996216,1,5.099999904632568,.23361243307590485]),T(eO.getInitialParameters(r,o),[-.1868094652891159,1.5599596500396729]),T(eS.getInitialParameters(i,l),[-5,100]),T(eI.getInitialParameters(a,s),[100,-2]),T(eP.getInitialParameters(u,c),[.1,-1,4,4]);let d=new Float32Array(null==(e=ey.parameters)?void 0:e.length);d.set(ey.parameters),b(eT.y(d,1.1),1.6914214561555851),b(eO.y(eO.getInitialParameters(r,o),1.1),1.3544692382216454),b(eS.y(eS.getInitialParameters(i,l),1.1),96.29031327635312),b(eI.y(eI.getInitialParameters(a,s),1.1),11.080315836233387),b(eP.y(eP.getInitialParameters(u,c),1.1),7.3231)})()),C("a series that names no fit function is fitted with the default",()=>eh(function*(){let e=new ec.JS(ey.points);b((0,es.zB)(e).name,ec.hD,"naming none should name the default"),e.fitFunction=null,b((0,es.zB)(e).name,ec.hD,"and so should clearing it"),e.fitFunction="no such fit function",b((0,es.zB)(e).name,ec.hD,"as should naming one that is gone"),b(void 0!==(0,es.zB)(e).hasAsymptotes,!0,"the fit it hands back should be usable, not undefined")})()),C("getCurve",()=>eh(function*(){let e=(0,es._T)(ey,eT),t=(0,es._T)(ex,eO),n=(0,es._T)(eC,eS),r=(0,es._T)(eb,eI),o=(0,es._T)(ew,eP);b(e(2.5),1.690786623428712),b(e(5.8858),.5356638447565519),b(t(2.5),-3.18454647064209),b(t(5.8858),-21.658870516967774),b(n(2.5),79.85176680360948),b(n(5.8858),74.12932588432805),b(r(.01),79.68277758636006),b(r(1345e-8),88.4439865528934),b(o(1.56),7.650264639782428),b(o(3.99876),6.093284856699922)})()),C("fitSeries",()=>eh(function*(){let e=Date.now(),t=(0,ec.nT)(ey,eT),n=(0,ec.nT)(ex,eO),r=(0,ec.nT)(eC,eS),o=(0,ec.nT)(eb,eI),i=(0,ec.nT)(ew,eP),l=Date.now();return b(t.fittedCurve(2.5),1.6903875076701773),b(n.fittedCurve(2.5),1.5348530188202858),b(r.fittedCurve(2.5),1.3696734183366701),b(o.fittedCurve(1345e-8),2.005337264075174),b(i.fittedCurve(3.99876),5.911350894323636),T(t.parameters,[1.690911054611206,1.1880898475646973,5.402130603790283,.22163867950439453]),T(n.parameters,[-.21431826055049896,2.070648670196533]),T(r.parameters,[-.6303421854972839,2.1593427658081055]),T(o.parameters,[2.005340814590454,-.13163800537586212]),T(i.parameters,[.06199381500482559,-.9554166793823242,2.872941017150879,5.736424446105957]),`${l.valueOf()-e.valueOf()} ms`})()),C("fitSeries sigmoid benchmark",()=>eh(function*(){let e=Date.now();(0,ec.nT)(ey,eT);let t=Date.now();return`${t.valueOf()-e.valueOf()} ms`})(),{benchmark:!0}),C("fitSeries linear benchmark",()=>eh(function*(){let e=Date.now();(0,ec.nT)(ex,eO);let t=Date.now();return`${t.valueOf()-e.valueOf()} ms`})(),{benchmark:!0}),C("fitSeries log-linear benchmark",()=>eh(function*(){let e=Date.now();(0,ec.nT)(eC,eS);let t=Date.now();return`${t.valueOf()-e.valueOf()} ms`})(),{benchmark:!0}),C("fitSeries exponential benchmark",()=>eh(function*(){let e=Date.now();(0,ec.nT)(eb,eI);let t=Date.now();return`${t.valueOf()-e.valueOf()} ms`})(),{benchmark:!0}),C("fitSeries polynomial benchmark",()=>eh(function*(){let e=Date.now();(0,ec.nT)(ew,eP);let t=Date.now();return`${t.valueOf()-e.valueOf()} ms`})(),{benchmark:!0}),C("getSeriesConfidenceInterval",()=>eh(function*(){let e=(0,es.fY)(ey,eT,!0),t=(0,es.fY)(ex,eO,!0),n=(0,es.fY)(eC,eS,!0),r=(0,es.fY)(eb,eI,!0),o=(0,es.fY)(ew,eP,!0);b(e.confidenceTop(2.578),1.8540855269320198),b(t.confidenceTop(2.578),26.645777275332037),b(n.confidenceTop(2.578),231.75768109324696),b(r.confidenceTop(1345e-8),103.51168317113999),b(o.confidenceTop(2.3342),10.03522960294218),b(e.confidenceBottom(3.987),1.4949306416468298),b(t.confidenceBottom(3.987),-41.55415698266847),b(n.confidenceBottom(3.987),-75.23471085303483),b(r.confidenceBottom(.01),64.61508096811347),b(o.confidenceBottom(3.8796),4.1686506915250385)})()),C("getSeriesStatistics",()=>eh(function*(){let e=(0,es.VA)(ey,eT),t=(0,es.VA)(ew,eP);b(e.auc,9.335422628533761),b(t.auc,36.525538394763096),b(e.rSquared,.9781915962461156),b(t.rSquared,.846055768956569)})()),C("fillParams",()=>eh(function*(){let e=(0,ec.nT)(ey,eT),t=eT.fillParams(e,ey);b(t.name,ed.G7),b(t.top,e.parameters[0]),b(t.slope,e.parameters[1]),b(t.ic50,e.parameters[2]),b(t.bottom,e.parameters[3]),b(t.interceptY,e.fittedCurve(e.parameters[2]));let n=(0,ec.nT)(ex,eO),r=eO.fillParams(n,ex);b(r.slope,n.parameters[0]),b(r.intercept,n.parameters[1]);let o=(0,ec.nT)(eC,eS),i=eS.fillParams(o,eC);b(i.name,ed.kx),b(i.slope,o.parameters[0]),b(i.intercept,o.parameters[1]);let l=(0,ec.nT)(eb,eI),a=eI.fillParams(l,eb);b(a.mantissa,l.parameters[0]),b(a.power,l.parameters[1])})()),C("fillParams dose-response",()=>eh(function*(){let e=ec.rT[ed.Qx],t=(0,ec.nT)(ey,e),n=e.fillParams(t,ey);b(n.name,ed.Qx),b(n.ic50,t.parameters[2]),b(n.ec50,t.parameters[2]),b(n.top,t.parameters[0]),b(n.bottom,t.parameters[3])})()),C("fillParams custom function",()=>eh(function*(){let e=(0,ec.nT)(ew,eP),t=eP.fillParams(e,ew);T(t.parameters,e.parameters);for(let n=0;n<eP.parameterNames.length;n++)b(t[eP.parameterNames[n]],e.parameters[n])})()),C("fillParams data points",()=>eh(function*(){let e=(0,ec.nT)(ey,eT),t=eT.fillParams(e,ey),n=eT.fillParams(e,ey,(0,eu.Sm)(ey,void 0,!1)),r=eT.fillParams(e,ey,void 0,{logX:!0,logY:!1});b(n.rSquared,t.rSquared),b(n.auc,t.auc),b(r.rSquared===t.rSquared,!1)})()),C("statisticsProperties",()=>eh(function*(){T(eT.statisticsProperties.map(e=>e.name),["rSquared","auc","top","slope","ic50","bottom","interceptY","maxY","minY","pIC50"]),T(eO.statisticsProperties.map(e=>e.name),["rSquared","auc","slope","intercept"]),T(eS.statisticsProperties.map(e=>e.name),["rSquared","auc","slope","intercept"]),T(eI.statisticsProperties.map(e=>e.name),["rSquared","auc","mantissa","power"]),T(ec.rT[ed.Qx].statisticsProperties.map(e=>e.name),["rSquared","auc","top","slope","ic50","bottom","interceptY","maxY","minY","pIC50"]),T(eP.statisticsProperties.map(e=>e.name),["rSquared","auc","Slope","Intercept","Parameter3","Parameter4"])})()),C("statisticsProperties friendly names",()=>eh(function*(){T(eT.statisticsProperties.map(e=>e.friendlyName),["R\xb2","AUC","Top","Slope","IC50","Bottom","Y at IC50","Max Y","Min Y","pIC50"]),T(ec.rT[ed.kC].statisticsProperties.map(e=>e.friendlyName),["R\xb2","AUC","Top","Slope","EC50","Bottom","Y at EC50","Max Y","Min Y"]),T(ec.rT[ed.Qx].statisticsProperties.map(e=>e.friendlyName),["R\xb2","AUC","Max","Hill","IC50","Min","Y at IC50","Max Y","Min Y","pIC50"]),T(eO.statisticsProperties.map(e=>e.friendlyName),["R\xb2","AUC","Slope","Intercept"])})()),C("getStatistic legacy names",()=>eh(function*(){let e=(0,es.xS)(ey,(0,ec.ou)("sigmoid"));b((0,ec.h5)(e,"interceptX"),e.ic50),b((0,ec.h5)(e,"ic50"),e.ic50),b((0,ec.h5)(e,"maxY"),e.maxY),b((0,ec.h5)(e,"minY"),e.minY),b((0,ec.h5)(e,"top"),e.top),b((0,ec.h5)(e,"bottom"),e.bottom),b((0,ec.h5)(e,"slope"),e.slope);let t=(0,es.xS)(ev(eg({},ey),{parameters:void 0}),(0,ec.ou)("4pl-regression"));b((0,ec.h5)(t,"interceptX"),t.ec50);let n=(0,es.xS)(ev(eg({},ey),{parameters:void 0}),(0,ec.ou)("4pl-dose-response"));b((0,ec.h5)(n,"interceptX"),n.ic50);let r=(0,es.xS)(ex,(0,ec.ou)("linear"));b((0,ec.h5)(r,"top"),r.parameters[0]),b(void 0!==(0,ec.Wh)((0,ec.ou)("linear"),"top"),!0),b(void 0===(0,ec.Wh)((0,ec.ou)("linear"),"interceptX"),!0),b(void 0===(0,ec.h5)(r,"interceptX")),b(void 0===(0,ec.h5)(r,"interceptY")),b(void 0===(0,ec.h5)(r,"bottom")),b((0,ec.h5)(r,"slope"),r.slope);let o=(0,es.xS)(ew,(0,es.zB)(ew));b(typeof(0,ec.h5)(o,"interceptY"),"number"),b(void 0!==(0,ec.Wh)((0,es.zB)(ew),"interceptY"),!0),b(void 0===(0,ec.h5)(e,"series")),b(void 0===(0,ec.h5)(e,"parameters")),b(void 0===(0,ec.h5)(e,"name"))})()),C("FitSeries options",()=>eh(function*(){let e=new ec.JS([{x:1,y:2}]);e.name="a",e.fitFunction=ed.G7,e.parameters=[1,2,3,4],e.parameterBounds=[{min:0,max:1}],e.markerType="circle",e.outlierMarkerType="outlier",e.lineStyle="dashed",e.pointColor="#111111",e.fitLineColor="#222222",e.confidenceIntervalColor="#333333",e.outlierColor="#444444",e.connectDots=!1,e.showFitLine=!0,e.showPoints="points",e.showOutliers=!0,e.showCurveConfidenceInterval=!1,e.errorModel="constant",e.clickToToggle=!0,e.labels={batch:"A1"},e.droplines=["IC50"],e.columnName="curve",e.auxLegendName="aux",b(e.name,"a"),b(e.showPoints,"points"),b(e.droplines[0],"IC50"),b(e.auxLegendName,"aux");let t=JSON.parse(JSON.stringify(e));b(t.name,"a"),b(t.columnName,"curve")})()),C("maxY and minY",()=>eh(function*(){let e=(0,es.xS)(ey,(0,ec.ou)("sigmoid"));b(e.maxY,Math.max(e.top,e.bottom)),b(e.minY,Math.min(e.top,e.bottom)),b(e.maxY>=e.minY,!0)})()),C("toDataSpace",()=>eh(function*(){let e={logX:!0,logY:!1},t=(0,es.xS)(ey,(0,ec.ou)("sigmoid"),void 0,e),n=t.ic50,r=t.top,o=(0,es.KZ)(t,e);b(o.ic50,Math.pow(10,n)),b(o.pIC50,-Math.log10(Math.pow(10,n))),b(o.top,r);let i={logX:!1,logY:!0},l=(0,es.xS)(ey,(0,ec.ou)("sigmoid"),void 0,i),a=l.top,s=l.ic50;(0,es.KZ)(l,i),b(l.top,a),b(l.ic50,s);let u=(0,es.xS)(ey,(0,ec.ou)("sigmoid")),c=u.ic50;(0,es.KZ)(u,{logX:!1,logY:!1}),b(u.ic50,c)})()),C("isFit narrowing",()=>eh(function*(){let e=(0,es.xS)(ey,(0,es.zB)(ey));b((0,ec.ct)(e,"sigmoid")),b(!1===(0,ec.ct)(e,"linear")),(0,ec.ct)(e,"sigmoid")&&b(e.ic50,(0,ec.h5)(e,"interceptX"))})()),C("calculateBoxPlotStatistics",()=>eh(function*(){let e=(0,ef.k)([.7654603719711304,.8199243545532227,.8257747292518616,.9558155536651611,.9596694707870483]);b(e.q1,.8199243545532227),b(e.q2,.8257747292518616),b(e.q3,.9558155536651611),b(e.lowerAdjacentValue,.7654603719711304),b(e.upperAdjacentValue,.9596694707870483)})()),C("calculateBoxPlotStatistics sorts numerically",()=>eh(function*(){let e=(0,ef.k)([2,10,1.5]);b(e.q1,1.5),b(e.q2,2),b(e.q3,10);let t=(0,ef.k)([5,4,3,2,1]),n=(0,ef.k)([1,2,3,4,5]);b(t.q1,n.q1),b(t.q3,n.q3),b(n.upperAdjacentValue,5),b(n.lowerAdjacentValue,1)})()),C("calculateBoxPlotStatistics excludes an outlier from the whisker",()=>eh(function*(){let e=(0,ef.k)([1,2,3,4,100]);b(e.q1,2),b(e.q3,4),b(e.upperAdjacentValue,4)})()),C("calculateBoxPlotStatistics leaves the caller array alone",()=>eh(function*(){let e=[3,1,2];(0,ef.k)(e),b(e[0],3),b(e[1],1),b(e[2],2)})()),C("ICxx is the x at that fraction of the curve",()=>eh(function*(){let e=(e,t,n,r,o)=>{let i=(0,ec.ou)(e),l=Float32Array.from(t),a=i.y(l,r),s=i.y(l,o);return(i.y(l,i.inverse(l,n))-a)/(s-a)};for(let t of["sigmoid","4pl-dose-response"])for(let n of[1.2,-1.2])for(let r of[.1,.5,.9])w(e(t,[100,n,-6.5,5],r,-1e6,1e6),r,.001,`${t}, slope ${n}, IC${100*r}`);for(let t of[1.2,-1.2])for(let n of[.1,.5,.9])w(e("4pl-regression",[100,t,3e-7,5],n,1e-30,1e30),n,.001);for(let e of(b((0,ec.ou)("sigmoid").inverse(Float32Array.from([100,1.2,-6.5,5]),.5),-6.5),["linear","log-linear","exponential"]))b(void 0===(0,ec.ou)(e).inverse(Float32Array.from([1,2]),.9),!0,e)})()),C("a dropline name asks for a fraction",()=>eh(function*(){for(let e of(b((0,em.Ow)("IC50"),.5),b((0,em.Ow)("IC90"),.9),b((0,em.Ow)("EC50"),.5),b((0,em.Ow)("ic55"),.55),b((0,em.Ow)("IC12.5"),.125),["IC0","IC100","AUC",""]))b(void 0===(0,em.Ow)(e),!0,e)})()),C("sigmoid",()=>eh(function*(){let e=new Float32Array(4);e.set([2.612687371569039,-1.421800778574126,5.16688669906018,.341788492203575]),b((0,ed.ry)(e,.5),.341789026340178),b((0,ed.ry)(e,2.5),.34215523020636207),b((0,ed.ry)(e,5.678976),2.2548815999597016)})()),C("linear",()=>eh(function*(){let e=new Float32Array(2);e.set([-5.12346546,6.24654654]),b((0,ed.sn)(e,.5),3.684813976287842),b((0,ed.sn)(e,2.5),-6.562117099761963),b((0,ed.sn)(e,5.678976),-22.849491081970214)})()),C("log-linear",()=>eh(function*(){let e=new Float32Array(2);e.set([-5.12346546,91.5465454654]),b((0,ed.AJ)(e,.5),89.46916042777144),b((0,ed.AJ)(e,2.5),85.12805903963536),b((0,ed.AJ)(e,5.678976),81.81726682791052)})()),C("exponential",()=>eh(function*(){let e=new Float32Array(2);e.set([95.12346546,-11.5465454654]),b((0,ed.EV)(e,5e-4),94.57587501550823),b((0,ed.EV)(e,.5),.2957925783034655),b((0,ed.EV)(e,.98746),.0010630898492656174)})()),C("the combined error model fits to fixed values",()=>eh(function*(){let e={fitFunction:"sigmoid",errorModel:"combined",points:[1e-9,3e-9,1e-8,3e-8,1e-7,3e-7,1e-6,3e-6,1e-5,3e-5,1e-4].map((e,t)=>({x:e,y:(5+95/(1+Math.pow(10,Math.log10(e)+6.5)))*(1+.08*Math.sin(2.4*t))}))};T(Array.from((0,ec.nT)(e,(0,es.zB)(e),void 0,{logX:!0,logY:!1}).parameters).map(e=>Number(e.toFixed(6))),[100.771515,.984725,-6.517356,5.065719])})())});var e_=n(353);function eN(e,t,n,r){let o,i,l;if(e.length<=1||t.length<=1)throw Error(`StatisticsError: Wrong sample size; expected at least 2, got ${Math.min(e.length,t.length)})`);let a=e_.mean(e),s=e_.mean(t),u=e_.variance(e,!0),c=e_.variance(t,!0),d=e.length,f=t.length;if(void 0!==n&&n){let e=(a-s)/Math.sqrt(u/d+c/f);o=1-(i=e_.normal.cdf(e,0,1)),l=2*(i<o?i:o)}else if(void 0!==r&&r){let e=d+f-2,t=Math.sqrt(d*f/(d+f))*(a-s)/Math.sqrt((u*(d-1)+c*(f-1))/e);o=1-e_.studentt.cdf(t,e),l=2*((i=e_.studentt.cdf(t,e))<o?i:o)}else{let e=u/d,t=c/f,n=(a-s)/Math.sqrt(e+t),r=Math.pow(e+t,2)/(Math.pow(e,2)/(d-1)+Math.pow(t,2)/(f-1));o=1-(i=e_.studentt.cdf(n,r)),l=2*(i<o?i:o)}return{"p-value":l,"Mean difference":a-s,"p-value more":o,"p-value less":i}}function eE(e,t,n){if(e.length<=1||t.length<=1)throw Error(`StatisticsError: Wrong sample size; expected at least 2, got ${Math.min(e.length,t.length)})`);let r=e.concat(t),o=e.length,i=t.length,l=e_.median(e),a=e_.median(t),s=e_.rank(r),u=e_.sum(s.slice(0,o))-o*(o+1)/2,c=o*i/2,d=o+i,f=Math.sqrt(o*i/12*(d+1-function(e){let t={};e.forEach(e=>{t[e]=(t[e]||0)+1});let n=0;var r=!0,o=!1,i=void 0;try{for(var l,a=Object.values(t)[Symbol.iterator]();!(r=(l=a.next()).done);r=!0){let e=l.value;n+=e*e*e-e}}catch(e){o=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n}(s)/(d*(d-1)))),m=u-c;(void 0===n||n)&&(m=Math.sign(m)*Math.max(0,Math.abs(m)-.5));let p=m/f,h=e_.normal.cdf(p,0,1),g=1-h;return{"p-value":2*(h<g?h:g),"Median difference":l-a,"p-value more":g,"p-value less":h}}(t=i||(i={})).indexesOf=function(e,t){let n=[];for(let r=0;r<e.length;r++)t(e[r])&&n.push(r);return n},t.genRange=function(e,t,n){let r=t-e+ +!(void 0!==n&&n),o=new Int32Array(r);for(let t=0;t<r;++t)o[t]=e+t;return o},t.argSort=function(e,t){let n=void 0!==t&&t?(e,t)=>t[0]-e[0]:(e,t)=>e[0]-t[0];return e.map((e,t)=>[e,t]).sort(n).map(e=>e[1])};let eA={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,min:(e,t)=>e<t?e:t,max:(e,t)=>e>t?e:t};function eL(e,t,n,r){var o,l,a,s,u,c;let d,f,m,p=void 0===t?.05:t,h=void 0===n?"n":n,g=void 0!==r&&r,v=e.length,y=0;if(g)m=new Int32Array(v).fill(0).map((e,t)=>t),f=e;else{let t;t=Array.from(e),o=m=Int32Array.from(i.argSort(t)),f=Float32Array.from(e).map((t,n)=>e[o[n]])}let x=(d=(l=f).length,Float32Array.from(l).map((e,t)=>(t+1)/d));if(["n","negcorr"].includes(h))y=function(e){let t=0;for(let n=0;n<e;++n)t+=1/(n+1);return t}(v),a=x,s=y,x=Float32Array.from(a).map((e,t)=>eA["/"](e,s));else if(!["i","indep","p","poscorr"].includes(h))throw Error("only indep and negcorr implemented");let C=Array(v).fill(!1),b=-1;for(let e=0;e<v;++e)f[e]<=x[e]*p&&(b=e);if(b>=0)for(let e=0;e<=b;++e)C[e]=!0;let w=(u=f,c=x,Float32Array.from(u).map((e,t)=>eA["/"](e,c[t])));w=(function(e){let t=e.length,n=Float32Array.from(e);for(let r=0;r<t;++r)n[r]=e.slice(0,r+1).reduce((e,t,n,r)=>eA.min(e,t));return n})(w.reverse()).reverse();for(let e=0;e<v;++e)w[e]>1&&(w[e]=1);if(!g){let e=function(e,t){let n=Float32Array.from(e);for(let r=0;r<t.length;++r)n[t[r]]=e[r];return n}(w,m);return[function(e,t){let n=Array.from(e);for(let r=0;r<t.length;++r)n[t[r]]=e[r];return n}(C,m),e]}return[C,w]}function eF(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function eM(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){eF(i,r,o,l,a,"next",e)}function a(e){eF(i,r,o,l,a,"throw",e)}l(void 0)})}}let eR=[1,2,3,4,5],eD=[2,4,6,8,10],eX=[.001,.008,.039,.041,.042,.06,.074,.205,.212,.216],eY=[.01,.04,.084,.084,.084,.1,.10571428,.216,.216,.216];O("statistics",()=>{C("tTest: the Welch branch uses the sample variance",()=>eM(function*(){let e=eN(eR,eD);w(e["p-value"],.10753119493044197,1e-12),w(e["p-value less"],.053765597465220985,1e-12),w(e["Mean difference"],-3,1e-12),b(e["p-value"]>.1)})()),C("tTest: the equal-variance branch divides by the pooled standard deviation",()=>eM(function*(){let e=eN(eR,eD,!1,!0);w(e["p-value"],.09434977284244564,1e-12),w(e["p-value less"],.04717488642122282,1e-12)})()),C("tTest: the known-deviation branch reports a tail probability",()=>eM(function*(){let e=eN(eR,eD,!0);w(e["p-value"],.05777957112359733,1e-12),w(e["p-value less"],.028889785561798664,1e-12),w(eN(eD,eR,!0)["p-value less"],1-e["p-value less"],1e-12)})()),C("tTest: the tails complement each other and the two-tailed p is twice the smaller",()=>eM(function*(){for(let e of[eN(eR,eD),eN(eR,eD,!1,!0),eN(eR,eD,!0)])w(e["p-value less"]+e["p-value more"],1,1e-12),w(e["p-value"],2*Math.min(e["p-value less"],e["p-value more"]),1e-12)})()),C("tTest: a sample of fewer than two values is refused",()=>eM(function*(){yield F(()=>eM(function*(){eN([1],eD)})(),e=>`${e}`.includes("Wrong sample size")),yield F(()=>eM(function*(){eN(eR,[])})(),e=>`${e}`.includes("Wrong sample size"))})()),C("uTest: no ties, hand-computable",()=>eM(function*(){let e=eE([1,3,5,7,9],[2,4,6,8,10]);w(e["p-value"],.6761033140231467,1e-12),w(e["p-value less"],.33805165701157336,1e-12),w(e["p-value more"],.6619483429884266,1e-12),w(e["Median difference"],-1,1e-12)})()),C("uTest: ties are corrected with the sum of t^3 - t",()=>eM(function*(){let e=eE([1,2,2,3,5],[2,4,4,6,7]);w(e["p-value"],.1375638939099033,1e-12),w(e["p-value less"],.06878194695495166,1e-12)})()),C("uTest: the one-tailed fields are one-tailed",()=>eM(function*(){let e=eE([1,3,5,7,9],[2,4,6,8,10]);b(e["p-value less"]!==e["p-value more"]),w(e["p-value less"]+e["p-value more"],1,1e-12),w(e["p-value"],2*Math.min(e["p-value less"],e["p-value more"]),1e-12);let t=eE([2,4,6,8,10],[1,3,5,7,9]);w(t["p-value less"],e["p-value more"],1e-12),w(t["p-value more"],e["p-value less"],1e-12),w(t["p-value"],e["p-value"],1e-12)})()),C("uTest: the two-tailed p never exceeds 1",()=>eM(function*(){let e=eE([1,2,3,4],[1,2,3,4]);w(e["p-value"],1,1e-12),w(e["p-value less"],.5,1e-12)})()),C("uTest: a sample of fewer than two values is refused",()=>eM(function*(){yield F(()=>eM(function*(){eE([1],[1,2,3])})(),e=>`${e}`.includes("Wrong sample size")),yield F(()=>eM(function*(){eE([1,2,3],[])})(),e=>`${e}`.includes("Wrong sample size"))})()),C("fdrcorrection: adjusted p-values match Benjamini-Hochberg",()=>eM(function*(){let[,e]=eL(new Float32Array(eX),.05,"i");for(let t=0;t<eX.length;t++)w(e[t],eY[t],1e-6)})()),C("fdrcorrection: every hypothesis at or below the line is rejected",()=>eM(function*(){let[e,t]=eL(new Float32Array(eX),.05,"i");T(e,[!0,!0,!1,!1,!1,!1,!1,!1,!1,!1]);for(let n=0;n<eX.length;n++)b(e[n],t[n]<=.05,`hypothesis ${n}`)})()),C("fdrcorrection: a lone passing hypothesis is rejected",()=>eM(function*(){let[e]=eL(new Float32Array([.001,.9,.9,.9]),.05,"i");T(e,[!0,!1,!1,!1])})()),C("fdrcorrection: rejections come back in the caller order",()=>eM(function*(){let e=[.216,.008,.212,.001,.042,.041,.074,.039,.205,.06],[t,n]=eL(new Float32Array(e),.05,"i");T(t,[!1,!0,!1,!0,!1,!1,!1,!1,!1,!1]);for(let t=0;t<e.length;t++)w(n[t],eY[eX.indexOf(e[t])],1e-6)})()),C("fdrcorrection: nothing is rejected when nothing passes",()=>eM(function*(){let[e]=eL(new Float32Array([.4,.5,.6]),.05,"i");T(e,[!1,!1,!1])})())});var ek=n(886);function ej(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function eG(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){ej(i,r,o,l,a,"next",e)}function a(e){ej(i,r,o,l,a,"throw",e)}l(void 0)})}}let eV=`<?xml version="1.0" encoding="UTF-8"?>
94
+ </GraphPadPrismFile>`;E("converters",()=>{P("xmlConverter.basicConversion",()=>K(function*(){var e,t,n;let r=JSON.parse((0,W.J)(Q));_(void 0!==r.series&&r.series.length>0,!0),_(r.series[0].points.length,6),_(null==(e=r.chartOptions)?void 0:e.xAxisName,"Concentration"),_(null==(t=r.chartOptions)?void 0:t.yAxisName,"Activity"),_(null==(n=r.chartOptions)?void 0:n.logX,!0)})()),P("xmlConverter.booleanAttributes",()=>K(function*(){var e,t;let n=Q.replace('drawLine="True"','drawLine="False"').replace('logX="true"','logX="false"'),r=JSON.parse((0,W.J)(n));_(r.series[0].showFitLine,!1),_(null==(e=r.chartOptions)?void 0:e.logX,!1);let o=JSON.parse((0,W.J)(Q));_(o.series[0].showFitLine,!0),_(null==(t=o.chartOptions)?void 0:t.logX,!0)})()),P("xmlConverter.logYNotInvented",()=>K(function*(){_("logY"in JSON.parse((0,W.J)(Q)).chartOptions,!1,"the cell must not own logY when the export omits it");let e=Q.replace('logX="true"','logX="true" logY="true"');_(JSON.parse((0,W.J)(e)).chartOptions.logY,!0)})()),P("xmlConverter.parameterReordering",()=>K(function*(){let e=JSON.parse((0,W.J)(Q)).series[0].parameters;_(e[0],125),_(e[1],-1.5),_(e[2],2e-8),_(e[3],-20)})()),P("xmlConverter.outlierMask",()=>K(function*(){let e=JSON.parse((0,W.J)(Q));_(e.series[0].points.length,6),_(e.series[0].points[0].outlier,!1),_(e.series[0].points[3].outlier,!1),_(e.series[0].points[4].outlier,!0),_(e.series[0].points[5].outlier,!1)})()),P("compactDrConverter.basicConversion",()=>K(function*(){var e,t,n;let r=JSON.parse((0,J.G)(ee));_(void 0!==r.series&&1===r.series.length,!0),_(r.series[0].points.length,9),_(null==(e=r.chartOptions)?void 0:e.xAxisName,"uM"),_(null==(t=r.chartOptions)?void 0:t.yAxisName,"%"),_(null==(n=r.chartOptions)?void 0:n.logX,!0)})()),P("compactDrConverter.parameters",()=>K(function*(){let e=JSON.parse((0,J.G)(ee)).series[0].parameters;_(e[0],109.134),_(e[1],-1.5498),_(e[2],.0064758),_(e[3],-4.28)})()),P("compactDrConverter.outlierFlag",()=>K(function*(){let e=JSON.parse((0,J.G)('{"rdt":"2025-05-31 00:00:00.0","mnr":-4.28,"mxr":109.134,"yu":"%","hs":-1.5498,"poi":0.0064758,"xu":"uM","ctp":"dose-response","p":[[0.001,3],[0.003,4],[0.01,7,1],[0.03,15],[0.1,35]]}'));_(e.series[0].points[0].outlier,!1),_(e.series[0].points[1].outlier,!1),_(e.series[0].points[2].outlier,!0),_(e.series[0].points[3].outlier,!1)})()),P("compactDrConverter.fitFunction",()=>K(function*(){let e=JSON.parse((0,J.G)(ee));_(e.series[0].fitFunction,"4pl-dose-response"),_(e.series[0].showFitLine,!0),_(e.series[0].showPoints,"points")})()),P("parseCellValue.nativeJson",()=>K(function*(){var e;let t=(0,z.HB)(et,null);_(void 0!==t.series&&1===t.series.length,!0),_(t.series[0].points.length,5),_(null==(e=t.chartOptions)?void 0:e.logX,!0)})()),P("parseCellValue.withConverter",()=>K(function*(){var e;(0,z.l8)("compact-dr",J.G);let t=l.DataFrame.fromColumns([l.Column.fromStrings("curves",[ee])]).col("curves");t.setTag($.h.TAG_CURVE_FORMAT,"compact-dr");let n=(0,z.HB)(ee,t);_(void 0!==n.series&&1===n.series.length,!0),_(n.series[0].points.length,9),_(null==(e=n.chartOptions)?void 0:e.logX,!0)})()),P("isNativeFormat.nativeColumn",()=>K(function*(){let e=l.DataFrame.fromColumns([l.Column.fromStrings("curves",[et])]).col("curves");_((0,z.XN)(e),!0),_((0,z.nL)(e),!1)})()),P("isNativeFormat.converterColumn",()=>K(function*(){let e=l.DataFrame.fromColumns([l.Column.fromStrings("curves",[ee])]).col("curves");e.setTag($.h.TAG_CURVE_FORMAT,"compact-dr"),_((0,z.XN)(e),!1),_((0,z.nL)(e),!0)})()),P("parseCellValue.emptyValue",()=>K(function*(){let e=(0,z.HB)("",null);_(void 0!==e.series&&0===e.series.length,!0)})()),P("parseCellValue.malformedJson",()=>K(function*(){let e=(0,z.HB)('{series: [{name: "A", points: [{x:0,y:50}]}]}',null);_(void 0!==e.series&&0===e.series.length,!0)})()),P("converterCaching",()=>K(function*(){(0,z.l8)("compact-dr",J.G);let e=l.DataFrame.fromColumns([l.Column.fromStrings("curves",[ee])]).col("curves");e.setTag($.h.TAG_CURVE_FORMAT,"compact-dr");let t=(0,z.HB)(ee,e),n=(0,z.HB)(ee,e);_(t.series[0].points.length,n.series[0].points.length)})())}),E("converters: rendering integration",()=>{P("xmlColumnRendering",()=>K(function*(){(0,z.l8)("3dx",W.J);let e=`xmlCurve
95
+ "<chart><grid><xAxis min=""0.0"" max=""5"" /><yAxis min=""-100"" max=""100"" /></grid><settings xLabel=""Concentration"" yLabel=""Activity"" logX=""true"" /><seriesCollection><series name=""S1""><x>7.2e-12,7.1e-12,7e-12,6e-8,6e-5,6e-4</x><y>112,115,116,100,123,124</y><mask>111111</mask><fitLine><function type=""sigif""><params>2e-08,-1.5,125,-20</params></function></fitLine><settings color=""Green"" marker=""SquareBorder"" markerColor=""Yellow"" markerBorderColor=""Black"" errorBarColor=""Red"" showErrorBars=""True"" drawLine=""True"" bound=""True"" /></series></seriesCollection></chart>"`,t=l.DataFrame.fromCsv(e),n=t.columns.byName("xmlCurve");yield V.data.detectSemanticTypes(t),_(n.semType,$.h.FIT_SEM_TYPE);let r=(0,z.HB)(n.get(0),n);_(void 0!==r.series&&r.series.length>0,!0),_(r.series[0].points.length,6)})()),P("compactDrColumnRendering",()=>K(function*(){(0,z.l8)("compact-dr",J.G);let e=`compactDR
96
+ "{""rdt"":""2025-05-31 00:00:00.0"",""mnr"":-4.28,""mxr"":109.134,""yu"":""%"",""hs"":-1.5498,""poi"":0.0064758,""xu"":""uM"",""ctp"":""dose-response"",""p"":[[0.001,3],[0.003,4],[0.01,7],[0.03,15],[0.1,35],[0.3,65],[1,85],[3,98],[10,105]]}"`,t=l.DataFrame.fromCsv(e),n=t.columns.byName("compactDR");yield V.data.detectSemanticTypes(t),_(n.semType,$.h.FIT_SEM_TYPE);let r=(0,z.HB)(n.get(0),n);_(void 0!==r.series&&1===r.series.length,!0),_(r.series[0].parameters[0],109.134)})()),P("nativeJsonColumnRendering",()=>K(function*(){let e=`nativeJSON
97
+ "${'{"series":[{"fitFunction":"sigmoid","parameters":[100,-1.5,0.01,-5],"fitLineColor":"#1f77b4","pointColor":"#1f77b4","showFitLine":true,"showPoints":"points","points":[{"x":0.001,"y":3},{"x":0.01,"y":7},{"x":0.1,"y":35},{"x":1,"y":85},{"x":10,"y":105}]}],"chartOptions":{"logX":true}}'.replace(/"/g,'""')}"`,t=l.DataFrame.fromCsv(e),n=t.columns.byName("nativeJSON");yield V.data.detectSemanticTypes(t),_(n.semType,$.h.FIT_SEM_TYPE),_((0,z.XN)(n),!0),_((0,z.HB)(n.get(0),n).series[0].points.length,5)})()),P("pzfxColumnRendering",()=>K(function*(){var e;(0,z.l8)("pzfx",U.R);let t=l.DataFrame.fromColumns([l.Column.fromStrings("pzfx",[en])]).col("pzfx");t.setTag($.h.TAG_CURVE_FORMAT,"pzfx"),t.semType=$.h.FIT_SEM_TYPE;let n=(0,z.HB)(t.get(0),t);_(void 0!==n.series&&1===n.series.length,!0),_(n.series[0].points.length,5),_(null==(e=n.chartOptions)?void 0:e.logX,!0)})())}),E("converters: pzfx",()=>{P("pzfxConverter.basicConversion",()=>K(function*(){var e,t;let n=JSON.parse((0,U.R)(en));_(void 0!==n.series&&1===n.series.length,!0),_(n.series[0].points.length,5),_(n.series[0].name,"Response A"),_(null==(e=n.chartOptions)?void 0:e.xAxisName,"Dose"),_(null==(t=n.chartOptions)?void 0:t.logX,!0)})()),P("pzfxConverter.pointValues",()=>K(function*(){let e=JSON.parse((0,U.R)(en)).series[0].points;_(e[0].x,1e-9),_(e[0].y,5.1),_(e[4].x,1e-5),_(e[4].y,97.2)})()),P("pzfxConverter.outlierExclusion",()=>K(function*(){let e=JSON.parse((0,U.R)(er));_(e.series[0].points.length,3),_(e.series[0].points[0].outlier,!1),_(e.series[0].points[1].outlier,!0),_(e.series[0].points[2].outlier,!1)})()),P("pzfxConverter.withConverterTag",()=>K(function*(){(0,z.l8)("pzfx",U.R);let e=l.DataFrame.fromColumns([l.Column.fromStrings("curves",[en])]).col("curves");e.setTag($.h.TAG_CURVE_FORMAT,"pzfx");let t=(0,z.HB)(en,e);_(void 0!==t.series&&1===t.series.length,!0),_(t.series[0].points.length,5)})())});var eo=n(389),ei=n(991),el=n.n(ei),ea=n(301),es=n(129);function eu(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function ec(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){eu(i,r,o,l,a,"next",e)}function a(e){eu(i,r,o,l,a,"throw",e)}l(void 0)})}}function ed(e){let t={series:[],chartOptions:{showStatistics:["auc"]}},n=(0,ea.kL)(e,.5),r=l.Color.toHtml(l.Color.scatterPlotMarker);return t.series[0]={fitLineColor:r,pointColor:r,markerType:l.MARKER_TYPE.CIRCLE,showFitLine:!0,showPoints:"points",showCurveConfidenceInterval:!0,fitFunction:"sigmoid",points:el().count().take(e).map(function(e){return{x:n.x[e],y:n.y[e]}}).toArray()},t}function ef(e,t,n,r){return ec(function*(){for(let o=0;o<r;o++)t.dispatchEvent(new WheelEvent("wheel",{deltaY:n})),yield Y(e)})()}function em(e,t){return ec(function*(){let n=Date.now();return yield e(t),Date.now().valueOf()-n.valueOf()})()}E("creation",()=>{P("fit curve creation",()=>ec(function*(){let e=l.Test.isInBenchmark?1e3:100,t=yield em(t=>ec(function*(){let t=(0,ea.nO)(e,5,2);V.shell.addTableView(t)})(),null);return console.log(`Creation took ${t} ms`),`${e} points, took ${t} ms`})(),{benchmark:!0})}),E("rendering",()=>{P("rendering same fitChartData on canvas",()=>ec(function*(){let e=l.Test.isInBenchmark?1e3:100,t=eo.canvas(160,120);V.shell.newView("canvas",[t]);let n=t.getContext("2d"),r=new es.l,o=ed(l.Test.isInBenchmark?50:15),i=[],a=e=>ec(function*(){r.renderCurves(n,es.l.inflateScreenBounds(new l.Rect(t.clientLeft,t.clientTop,160,120)),o),n.clearRect(0,0,160,120)})();for(let t=1;t<=e;t++)i[i.length]=yield em(a);return`rendering performed ${e} times, max time is ${Math.max(...i)} ms, min time is ${Math.min(...i)} ms, average time is ${i.reduce((e,t)=>e+t,0)/i.length} ms`})(),{benchmark:!0}),P("rendering different fitChartData on canvas",()=>ec(function*(){let e=l.Test.isInBenchmark?1e3:100,t=eo.canvas(160,120);V.shell.newView("canvas",[t]);let n=t.getContext("2d"),r=new es.l,o=[],i=e=>ec(function*(){r.renderCurves(n,es.l.inflateScreenBounds(new l.Rect(t.clientLeft,t.clientTop,160,120)),e),n.clearRect(0,0,160,120)})();for(let t=1;t<=e;t++){let e=ed(l.Test.isInBenchmark?50:15);o[o.length]=yield em(i,e)}return`rendering performed ${e} times, max time is ${Math.max(...o)} ms, min time is ${Math.min(...o)} ms, average time is ${o.reduce((e,t)=>e+t,0)/o.length} ms`})(),{benchmark:!0}),P("rendering in grid",()=>ec(function*(){let e=(0,ea.nO)(50,5,5),t=V.shell.addTableView(e);yield Y(t.grid);let n=t.grid.root.getElementsByTagName("canvas")[2],r=yield em(e=>ec(function*(){yield ef(t.grid,n,300,10),yield ef(t.grid,n,-300,10),yield ef(t.grid,n,300,10)})(),null);return console.log(`curves rendering took ${r} ms`),r})(),{benchmark:!0})});var ep=n(533),eh=n(324);function eg(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}E("viewport",()=>{P("viewportMethods",()=>{var e;return(e=function*(){let e=es.l.inflateScreenBounds(new l.Rect(120,20,160,100)),[t]=(0,eh.Tv)(e,!1,!1,!1),n=new l.Rect(.1,.06,7,5.94),r=new ep.L(n,t,!1,!1);_(r.xToScreen(1.5),182.4),_(r.yToScreen(2.33),73.01346801346801),_(r.xToWorld(150),-.9652173913043479),_(r.yToWorld(67),2.855294117647059)},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){eg(i,r,o,l,a,"next",e)}function a(e){eg(i,r,o,l,a,"throw",e)}l(void 0)})})()})});var ev=n(165),ey=n(774),ex=n(869),eC=n(590),eb=n(18),ew=n(684);function eT(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function eO(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){eT(i,r,o,l,a,"next",e)}function a(e){eT(i,r,o,l,a,"throw",e)}l(void 0)})}}function eS(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 eI(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}let eP={fitLineColor:"#1f77b4",pointColor:"#1f77b4",showCurveConfidenceInterval:!1,points:[{x:.10000000149011612,y:1.7412786483764648},{x:.6000000238418579,y:1.8561450242996216},{x:1.100000023841858,y:1.6065685749053955},{x:1.600000023841858,y:1.70476496219635},{x:2.0999999046325684,y:1.5737264156341553},{x:2.5999999046325684,y:1.6007002592086792},{x:3.0999999046325684,y:1.6796687841415405},{x:3.5999999046325684,y:1.656104326248169},{x:4.099999904632568,y:1.782997488975525},{x:4.599999904632568,y:1.530208945274353},{x:5.099999904632568,y:1.1572397947311401},{x:5.599999904632568,y:.8691964745521545},{x:6.099999904632568,y:.3228665590286255},{x:6.599999904632568,y:.2990703880786896},{x:7.099999904632568,y:.23361243307590485}],fitFunction:"sigmoid",clickToToggle:!1,showFitLine:!0,showPoints:"points",parameters:[1.6914372095641517,1.1536998642628853,5.410173358224149,.2089689354045083]},e_={fitLineColor:"#1f77b4",pointColor:"#1f77b4",showCurveConfidenceInterval:!1,points:[{x:.10000000149011612,y:1.5412786483764649},{x:.6000000238418579,y:1.9261450242996216},{x:1.100000023841858,y:1.6065685749053955},{x:1.600000023841858,y:1.70476496219635},{x:2.0999999046325684,y:1.5737264156341553},{x:2.5999999046325684,y:1.6007002592086792},{x:3.0999999046325684,y:1.6796687841415405},{x:3.5999999046325684,y:1.656104326248169},{x:4.099999904632568,y:1.782997488975525},{x:4.599999904632568,y:1.530208945274353},{x:5.099999904632568,y:1.1572397947311401},{x:5.599999904632568,y:.8691964745521545},{x:6.099999904632568,y:.3228665590286255},{x:6.599999904632568,y:.2990703880786896},{x:7.099999904632568,y:.23361243307590485}],fitFunction:"linear",clickToToggle:!1,showFitLine:!0,showPoints:"points",parameters:[-5.45641324,10.456486765]},eA={fitLineColor:"#1f77b4",pointColor:"#1f77b4",showCurveConfidenceInterval:!1,points:[{x:.10000000149011612,y:1.7897127864837648},{x:.6000000238418579,y:1.2101614502429963},{x:1.100000023841858,y:1.7895685749053956},{x:1.600000023841858,y:1.82476496219635},{x:2.0999999046325684,y:1.5737264156341553},{x:2.5999999046325684,y:1.6007002592086792},{x:3.0999999046325684,y:1.6796687841415405},{x:3.5999999046325684,y:1.656104326248169},{x:4.099999904632568,y:1.782997488975525},{x:4.599999904632568,y:1.530208945274353},{x:5.099999904632568,y:1.1572397947311401},{x:5.599999904632568,y:.8691964745521545},{x:6.099999904632568,y:.3228665590286255},{x:6.599999904632568,y:.2990703880786896},{x:7.099999904632568,y:.23361243307590485}],fitFunction:"log-linear",clickToToggle:!1,showFitLine:!0,showPoints:"points",parameters:[-8.45641324,90.4456456486765]},eN={fitLineColor:"#1f77b4",pointColor:"#1f77b4",showCurveConfidenceInterval:!1,points:[{x:.10000000149011612,y:1.7897127864837648},{x:.6000000238418579,y:1.2101614502429963},{x:1.100000023841858,y:1.7895685749053956},{x:1.600000023841858,y:1.82476496219635},{x:2.0999999046325684,y:1.5737264156341553},{x:2.5999999046325684,y:1.6007002592086792},{x:3.0999999046325684,y:1.6796687841415405},{x:3.5999999046325684,y:1.656104326248169},{x:4.099999904632568,y:1.782997488975525},{x:4.599999904632568,y:1.530208945274353},{x:5.099999904632568,y:1.1572397947311401},{x:5.599999904632568,y:.8691964745521545},{x:6.099999904632568,y:.3228665590286255},{x:6.599999904632568,y:.2990703880786896},{x:7.099999904632568,y:.23361243307590485}],fitFunction:"exponential",clickToToggle:!1,showFitLine:!0,showPoints:"points",parameters:[88.45641324,-10.4456456486765]},eE={fitLineColor:"#2ca02c",pointColor:"#2ca02c",showCurveConfidenceInterval:!0,fitFunction:{name:"Polynomial",function:"([p1, p2, p3, p4], x) => p1 * x * x * x + p2 * x * x + p3 * x + p4",getInitialParameters:"(xs, ys) => [0.1, -1, 4, 4]",parameterNames:["Slope","Intercept","Parameter3","Parameter4"]},points:[{x:.10000000149011612,y:7.365033149719238},{x:.6000000238418579,y:6.595034599304199},{x:1.100000023841858,y:7.05179500579834},{x:1.600000023841858,y:7.251461982727051},{x:2.0999999046325684,y:7.775498867034912},{x:2.5999999046325684,y:7.748039722442627},{x:3.0999999046325684,y:6.8391804695129395},{x:3.5999999046325684,y:7.570991516113281},{x:4.099999904632568,y:6.387666702270508},{x:4.599999904632568,y:6.464827537536621},{x:5.099999904632568,y:3.932436227798462},{x:5.599999904632568,y:1.4741199016571045},{x:6.099999904632568,y:.47604307532310486},{x:6.599999904632568,y:.5836760401725769},{x:7.099999904632568,y:1.0317600965499878}],clickToToggle:!1,showFitLine:!0,showPoints:"points",parameters:[.07070206940832963,-1.138666933634074,3.947509109407932,3.9947960440506685]},eL=(0,ev.zB)(eP),eF=(0,ev.zB)(e_),eM=(0,ev.zB)(eA),eR=(0,ev.zB)(eN),eD=(0,ev.zB)(eE);E("fit",()=>{P("getSeriesFitFunction",()=>eO(function*(){var e;let{xs:t,ys:n}=(0,ev.W$)(eP.points),{xs:r,ys:o}=(0,ev.W$)(e_.points),{xs:i,ys:l}=(0,ev.W$)(eA.points),{xs:a,ys:s}=(0,ev.W$)(eN.points),{xs:u,ys:c}=(0,ev.W$)(eE.points);_(eL.name,eC.G7),_(eF.name,eC.Ff),_(eM.name,eC.kx),_(eR.name,eC.Pf),_(eD.name,"Polynomial"),N(eL.parameterNames,["Top","Slope","IC50","Bottom"]),N(eF.parameterNames,["Slope","Intercept"]),N(eM.parameterNames,["Slope","Intercept"]),N(eR.parameterNames,["Mantissa","Power"]),N(eD.parameterNames,["Slope","Intercept","Parameter3","Parameter4"]),N(eL.getInitialParameters(t,n),[1.8561450242996216,1,5.099999904632568,.23361243307590485]),N(eF.getInitialParameters(r,o),[-.1868094652891159,1.5599596500396729]),N(eM.getInitialParameters(i,l),[-5,100]),N(eR.getInitialParameters(a,s),[100,-2]),N(eD.getInitialParameters(u,c),[.1,-1,4,4]);let d=new Float32Array(null==(e=eP.parameters)?void 0:e.length);d.set(eP.parameters),_(eL.y(d,1.1),1.6914214561555851),_(eF.y(eF.getInitialParameters(r,o),1.1),1.3544692382216454),_(eM.y(eM.getInitialParameters(i,l),1.1),96.29031327635312),_(eR.y(eR.getInitialParameters(a,s),1.1),11.080315836233387),_(eD.y(eD.getInitialParameters(u,c),1.1),7.3231)})()),P("a series that names no fit function is fitted with the default",()=>eO(function*(){let e=new ex.JS(eP.points);_((0,ev.zB)(e).name,ex.hD,"naming none should name the default"),e.fitFunction=null,_((0,ev.zB)(e).name,ex.hD,"and so should clearing it"),e.fitFunction="no such fit function",_((0,ev.zB)(e).name,ex.hD,"as should naming one that is gone"),_(void 0!==(0,ev.zB)(e).hasAsymptotes,!0,"the fit it hands back should be usable, not undefined")})()),P("getCurve",()=>eO(function*(){let e=(0,ev._T)(eP,eL),t=(0,ev._T)(e_,eF),n=(0,ev._T)(eA,eM),r=(0,ev._T)(eN,eR),o=(0,ev._T)(eE,eD);_(e(2.5),1.690786623428712),_(e(5.8858),.5356638447565519),_(t(2.5),-3.18454647064209),_(t(5.8858),-21.658870516967774),_(n(2.5),79.85176680360948),_(n(5.8858),74.12932588432805),_(r(.01),79.68277758636006),_(r(1345e-8),88.4439865528934),_(o(1.56),7.650264639782428),_(o(3.99876),6.093284856699922)})()),P("fitSeries",()=>eO(function*(){let e=Date.now(),t=(0,ex.nT)(eP,eL),n=(0,ex.nT)(e_,eF),r=(0,ex.nT)(eA,eM),o=(0,ex.nT)(eN,eR),i=(0,ex.nT)(eE,eD),l=Date.now();return _(t.fittedCurve(2.5),1.6903875076701773),_(n.fittedCurve(2.5),1.5348530188202858),_(r.fittedCurve(2.5),1.3696734183366701),_(o.fittedCurve(1345e-8),2.005337264075174),_(i.fittedCurve(3.99876),5.911350894323636),N(t.parameters,[1.690911054611206,1.1880898475646973,5.402130603790283,.22163867950439453]),N(n.parameters,[-.21431826055049896,2.070648670196533]),N(r.parameters,[-.6303421854972839,2.1593427658081055]),N(o.parameters,[2.005340814590454,-.13163800537586212]),N(i.parameters,[.06199381500482559,-.9554166793823242,2.872941017150879,5.736424446105957]),`${l.valueOf()-e.valueOf()} ms`})()),P("fitSeries sigmoid benchmark",()=>eO(function*(){let e=Date.now();(0,ex.nT)(eP,eL);let t=Date.now();return`${t.valueOf()-e.valueOf()} ms`})(),{benchmark:!0}),P("fitSeries linear benchmark",()=>eO(function*(){let e=Date.now();(0,ex.nT)(e_,eF);let t=Date.now();return`${t.valueOf()-e.valueOf()} ms`})(),{benchmark:!0}),P("fitSeries log-linear benchmark",()=>eO(function*(){let e=Date.now();(0,ex.nT)(eA,eM);let t=Date.now();return`${t.valueOf()-e.valueOf()} ms`})(),{benchmark:!0}),P("fitSeries exponential benchmark",()=>eO(function*(){let e=Date.now();(0,ex.nT)(eN,eR);let t=Date.now();return`${t.valueOf()-e.valueOf()} ms`})(),{benchmark:!0}),P("fitSeries polynomial benchmark",()=>eO(function*(){let e=Date.now();(0,ex.nT)(eE,eD);let t=Date.now();return`${t.valueOf()-e.valueOf()} ms`})(),{benchmark:!0}),P("getSeriesConfidenceInterval",()=>eO(function*(){let e=(0,ev.fY)(eP,eL,!0),t=(0,ev.fY)(e_,eF,!0),n=(0,ev.fY)(eA,eM,!0),r=(0,ev.fY)(eN,eR,!0),o=(0,ev.fY)(eE,eD,!0);_(e.confidenceTop(2.578),1.8540855269320198),_(t.confidenceTop(2.578),26.645777275332037),_(n.confidenceTop(2.578),231.75768109324696),_(r.confidenceTop(1345e-8),103.51168317113999),_(o.confidenceTop(2.3342),10.03522960294218),_(e.confidenceBottom(3.987),1.4949306416468298),_(t.confidenceBottom(3.987),-41.55415698266847),_(n.confidenceBottom(3.987),-75.23471085303483),_(r.confidenceBottom(.01),64.61508096811347),_(o.confidenceBottom(3.8796),4.1686506915250385)})()),P("getSeriesStatistics",()=>eO(function*(){let e=(0,ev.VA)(eP,eL),t=(0,ev.VA)(eE,eD);_(e.auc,9.335422628533761),_(t.auc,36.525538394763096),_(e.rSquared,.9781915962461156),_(t.rSquared,.846055768956569)})()),P("fillParams",()=>eO(function*(){let e=(0,ex.nT)(eP,eL),t=eL.fillParams(e,eP);_(t.name,eC.G7),_(t.top,e.parameters[0]),_(t.slope,e.parameters[1]),_(t.ic50,e.parameters[2]),_(t.bottom,e.parameters[3]),_(t.interceptY,e.fittedCurve(e.parameters[2]));let n=(0,ex.nT)(e_,eF),r=eF.fillParams(n,e_);_(r.slope,n.parameters[0]),_(r.intercept,n.parameters[1]);let o=(0,ex.nT)(eA,eM),i=eM.fillParams(o,eA);_(i.name,eC.kx),_(i.slope,o.parameters[0]),_(i.intercept,o.parameters[1]);let l=(0,ex.nT)(eN,eR),a=eR.fillParams(l,eN);_(a.mantissa,l.parameters[0]),_(a.power,l.parameters[1])})()),P("fillParams dose-response",()=>eO(function*(){let e=ex.rT[eC.Qx],t=(0,ex.nT)(eP,e),n=e.fillParams(t,eP);_(n.name,eC.Qx),_(n.ic50,t.parameters[2]),_(n.ec50,t.parameters[2]),_(n.top,t.parameters[0]),_(n.bottom,t.parameters[3])})()),P("4PL dose-response fits the Hill slope of a dilution series",()=>eO(function*(){let e={fitFunction:eC.Qx,points:Array.from({length:8},(e,t)=>{let n=10/Math.pow(3,t);return{x:n,y:600+3600/(1+Math.pow(n/.3,1.2))}})},t=ex.rT[eC.Qx],n=(0,ex.nT)(e,t,void 0,{logX:!0,logY:!1});A(n.parameters[1],-1.2,.05),A(Math.pow(10,n.parameters[2]),.3,.01)})()),P("fillParams custom function",()=>eO(function*(){let e=(0,ex.nT)(eE,eD),t=eD.fillParams(e,eE);N(t.parameters,e.parameters);for(let n=0;n<eD.parameterNames.length;n++)_(t[eD.parameterNames[n]],e.parameters[n])})()),P("fillParams data points",()=>eO(function*(){let e=(0,ex.nT)(eP,eL),t=eL.fillParams(e,eP),n=eL.fillParams(e,eP,(0,ey.Sm)(eP,void 0,!1)),r=eL.fillParams(e,eP,void 0,{logX:!0,logY:!1});_(n.rSquared,t.rSquared),_(n.auc,t.auc),_(r.rSquared===t.rSquared,!1)})()),P("statisticsProperties",()=>eO(function*(){N(eL.statisticsProperties.map(e=>e.name),["rSquared","auc","top","slope","ic50","bottom","interceptY","maxY","minY","pIC50"]),N(eF.statisticsProperties.map(e=>e.name),["rSquared","auc","slope","intercept"]),N(eM.statisticsProperties.map(e=>e.name),["rSquared","auc","slope","intercept"]),N(eR.statisticsProperties.map(e=>e.name),["rSquared","auc","mantissa","power"]),N(ex.rT[eC.Qx].statisticsProperties.map(e=>e.name),["rSquared","auc","top","slope","ic50","bottom","interceptY","maxY","minY","pIC50"]),N(eD.statisticsProperties.map(e=>e.name),["rSquared","auc","Slope","Intercept","Parameter3","Parameter4"])})()),P("statisticsProperties friendly names",()=>eO(function*(){N(eL.statisticsProperties.map(e=>e.friendlyName),["R\xb2","AUC","Top","Slope","IC50","Bottom","Y at IC50","Max Y","Min Y","pIC50"]),N(ex.rT[eC.kC].statisticsProperties.map(e=>e.friendlyName),["R\xb2","AUC","Top","Slope","EC50","Bottom","Y at EC50","Max Y","Min Y"]),N(ex.rT[eC.Qx].statisticsProperties.map(e=>e.friendlyName),["R\xb2","AUC","Max","Hill","IC50","Min","Y at IC50","Max Y","Min Y","pIC50"]),N(eF.statisticsProperties.map(e=>e.friendlyName),["R\xb2","AUC","Slope","Intercept"])})()),P("getStatistic legacy names",()=>eO(function*(){let e=(0,ev.xS)(eP,(0,ex.ou)("sigmoid"));_((0,ex.h5)(e,"interceptX"),e.ic50),_((0,ex.h5)(e,"ic50"),e.ic50),_((0,ex.h5)(e,"maxY"),e.maxY),_((0,ex.h5)(e,"minY"),e.minY),_((0,ex.h5)(e,"top"),e.top),_((0,ex.h5)(e,"bottom"),e.bottom),_((0,ex.h5)(e,"slope"),e.slope);let t=(0,ev.xS)(eI(eS({},eP),{parameters:void 0}),(0,ex.ou)("4pl-regression"));_((0,ex.h5)(t,"interceptX"),t.ec50);let n=(0,ev.xS)(eI(eS({},eP),{parameters:void 0}),(0,ex.ou)("4pl-dose-response"));_((0,ex.h5)(n,"interceptX"),n.ic50);let r=(0,ev.xS)(e_,(0,ex.ou)("linear"));_((0,ex.h5)(r,"top"),r.parameters[0]),_(void 0!==(0,ex.Wh)((0,ex.ou)("linear"),"top"),!0),_(void 0===(0,ex.Wh)((0,ex.ou)("linear"),"interceptX"),!0),_(void 0===(0,ex.h5)(r,"interceptX")),_(void 0===(0,ex.h5)(r,"interceptY")),_(void 0===(0,ex.h5)(r,"bottom")),_((0,ex.h5)(r,"slope"),r.slope);let o=(0,ev.xS)(eE,(0,ev.zB)(eE));_(typeof(0,ex.h5)(o,"interceptY"),"number"),_(void 0!==(0,ex.Wh)((0,ev.zB)(eE),"interceptY"),!0),_(void 0===(0,ex.h5)(e,"series")),_(void 0===(0,ex.h5)(e,"parameters")),_(void 0===(0,ex.h5)(e,"name"))})()),P("FitSeries options",()=>eO(function*(){let e=new ex.JS([{x:1,y:2}]);e.name="a",e.fitFunction=eC.G7,e.parameters=[1,2,3,4],e.parameterBounds=[{min:0,max:1}],e.markerType="circle",e.outlierMarkerType="outlier",e.lineStyle="dashed",e.pointColor="#111111",e.fitLineColor="#222222",e.confidenceIntervalColor="#333333",e.outlierColor="#444444",e.connectDots=!1,e.showFitLine=!0,e.showPoints="points",e.showOutliers=!0,e.showCurveConfidenceInterval=!1,e.errorModel="constant",e.clickToToggle=!0,e.labels={batch:"A1"},e.droplines=["IC50"],e.columnName="curve",e.auxLegendName="aux",_(e.name,"a"),_(e.showPoints,"points"),_(e.droplines[0],"IC50"),_(e.auxLegendName,"aux");let t=JSON.parse(JSON.stringify(e));_(t.name,"a"),_(t.columnName,"curve")})()),P("maxY and minY",()=>eO(function*(){let e=(0,ev.xS)(eP,(0,ex.ou)("sigmoid"));_(e.maxY,Math.max(e.top,e.bottom)),_(e.minY,Math.min(e.top,e.bottom)),_(e.maxY>=e.minY,!0)})()),P("toDataSpace",()=>eO(function*(){let e={logX:!0,logY:!1},t=(0,ev.xS)(eP,(0,ex.ou)("sigmoid"),void 0,e),n=t.ic50,r=t.top,o=(0,ev.KZ)(t,e);_(o.ic50,Math.pow(10,n)),_(o.pIC50,-Math.log10(Math.pow(10,n))),_(o.top,r);let i={logX:!1,logY:!0},l=(0,ev.xS)(eP,(0,ex.ou)("sigmoid"),void 0,i),a=l.top,s=l.ic50;(0,ev.KZ)(l,i),_(l.top,a),_(l.ic50,s);let u=(0,ev.xS)(eP,(0,ex.ou)("sigmoid")),c=u.ic50;(0,ev.KZ)(u,{logX:!1,logY:!1}),_(u.ic50,c)})()),P("isFit narrowing",()=>eO(function*(){let e=(0,ev.xS)(eP,(0,ev.zB)(eP));_((0,ex.ct)(e,"sigmoid")),_(!1===(0,ex.ct)(e,"linear")),(0,ex.ct)(e,"sigmoid")&&_(e.ic50,(0,ex.h5)(e,"interceptX"))})()),P("calculateBoxPlotStatistics",()=>eO(function*(){let e=(0,eb.k)([.7654603719711304,.8199243545532227,.8257747292518616,.9558155536651611,.9596694707870483]);_(e.q1,.8199243545532227),_(e.q2,.8257747292518616),_(e.q3,.9558155536651611),_(e.lowerAdjacentValue,.7654603719711304),_(e.upperAdjacentValue,.9596694707870483)})()),P("calculateBoxPlotStatistics sorts numerically",()=>eO(function*(){let e=(0,eb.k)([2,10,1.5]);_(e.q1,1.5),_(e.q2,2),_(e.q3,10);let t=(0,eb.k)([5,4,3,2,1]),n=(0,eb.k)([1,2,3,4,5]);_(t.q1,n.q1),_(t.q3,n.q3),_(n.upperAdjacentValue,5),_(n.lowerAdjacentValue,1)})()),P("calculateBoxPlotStatistics excludes an outlier from the whisker",()=>eO(function*(){let e=(0,eb.k)([1,2,3,4,100]);_(e.q1,2),_(e.q3,4),_(e.upperAdjacentValue,4)})()),P("calculateBoxPlotStatistics leaves the caller array alone",()=>eO(function*(){let e=[3,1,2];(0,eb.k)(e),_(e[0],3),_(e[1],1),_(e[2],2)})()),P("ICxx is the x at that fraction of the curve",()=>eO(function*(){let e=(e,t,n,r,o)=>{let i=(0,ex.ou)(e),l=Float32Array.from(t),a=i.y(l,r),s=i.y(l,o);return(i.y(l,i.inverse(l,n))-a)/(s-a)};for(let t of["sigmoid","4pl-dose-response"])for(let n of[1.2,-1.2])for(let r of[.1,.5,.9])A(e(t,[100,n,-6.5,5],r,-1e6,1e6),r,.001,`${t}, slope ${n}, IC${100*r}`);for(let t of[1.2,-1.2])for(let n of[.1,.5,.9])A(e("4pl-regression",[100,t,3e-7,5],n,1e-30,1e30),n,.001);for(let e of(_((0,ex.ou)("sigmoid").inverse(Float32Array.from([100,1.2,-6.5,5]),.5),-6.5),["linear","log-linear","exponential"]))_(void 0===(0,ex.ou)(e).inverse(Float32Array.from([1,2]),.9),!0,e)})()),P("a dropline name asks for a fraction",()=>eO(function*(){for(let e of(_((0,ew.Ow)("IC50"),.5),_((0,ew.Ow)("IC90"),.9),_((0,ew.Ow)("EC50"),.5),_((0,ew.Ow)("ic55"),.55),_((0,ew.Ow)("IC12.5"),.125),["IC0","IC100","AUC",""]))_(void 0===(0,ew.Ow)(e),!0,e)})()),P("sigmoid",()=>eO(function*(){let e=new Float32Array(4);e.set([2.612687371569039,-1.421800778574126,5.16688669906018,.341788492203575]),_((0,eC.ry)(e,.5),.341789026340178),_((0,eC.ry)(e,2.5),.34215523020636207),_((0,eC.ry)(e,5.678976),2.2548815999597016)})()),P("linear",()=>eO(function*(){let e=new Float32Array(2);e.set([-5.12346546,6.24654654]),_((0,eC.sn)(e,.5),3.684813976287842),_((0,eC.sn)(e,2.5),-6.562117099761963),_((0,eC.sn)(e,5.678976),-22.849491081970214)})()),P("log-linear",()=>eO(function*(){let e=new Float32Array(2);e.set([-5.12346546,91.5465454654]),_((0,eC.AJ)(e,.5),89.46916042777144),_((0,eC.AJ)(e,2.5),85.12805903963536),_((0,eC.AJ)(e,5.678976),81.81726682791052)})()),P("exponential",()=>eO(function*(){let e=new Float32Array(2);e.set([95.12346546,-11.5465454654]),_((0,eC.EV)(e,5e-4),94.57587501550823),_((0,eC.EV)(e,.5),.2957925783034655),_((0,eC.EV)(e,.98746),.0010630898492656174)})()),P("the combined error model fits to fixed values",()=>eO(function*(){let e={fitFunction:"sigmoid",errorModel:"combined",points:[1e-9,3e-9,1e-8,3e-8,1e-7,3e-7,1e-6,3e-6,1e-5,3e-5,1e-4].map((e,t)=>({x:e,y:(5+95/(1+Math.pow(10,Math.log10(e)+6.5)))*(1+.08*Math.sin(2.4*t))}))};N(Array.from((0,ex.nT)(e,(0,ev.zB)(e),void 0,{logX:!0,logY:!1}).parameters).map(e=>Number(e.toFixed(6))),[100.771515,.984725,-6.517356,5.065719])})())});var eX=n(353);function eY(e,t,n,r){let o,i,l;if(e.length<=1||t.length<=1)throw Error(`StatisticsError: Wrong sample size; expected at least 2, got ${Math.min(e.length,t.length)})`);let a=eX.mean(e),s=eX.mean(t),u=eX.variance(e,!0),c=eX.variance(t,!0),d=e.length,f=t.length;if(void 0!==n&&n){let e=(a-s)/Math.sqrt(u/d+c/f);o=1-(i=eX.normal.cdf(e,0,1)),l=2*(i<o?i:o)}else if(void 0!==r&&r){let e=d+f-2,t=Math.sqrt(d*f/(d+f))*(a-s)/Math.sqrt((u*(d-1)+c*(f-1))/e);o=1-eX.studentt.cdf(t,e),l=2*((i=eX.studentt.cdf(t,e))<o?i:o)}else{let e=u/d,t=c/f,n=(a-s)/Math.sqrt(e+t),r=Math.pow(e+t,2)/(Math.pow(e,2)/(d-1)+Math.pow(t,2)/(f-1));o=1-(i=eX.studentt.cdf(n,r)),l=2*(i<o?i:o)}return{"p-value":l,"Mean difference":a-s,"p-value more":o,"p-value less":i}}function ek(e,t,n){if(e.length<=1||t.length<=1)throw Error(`StatisticsError: Wrong sample size; expected at least 2, got ${Math.min(e.length,t.length)})`);let r=e.concat(t),o=e.length,i=t.length,l=eX.median(e),a=eX.median(t),s=eX.rank(r),u=eX.sum(s.slice(0,o))-o*(o+1)/2,c=o*i/2,d=o+i,f=Math.sqrt(o*i/12*(d+1-function(e){let t={};e.forEach(e=>{t[e]=(t[e]||0)+1});let n=0;var r=!0,o=!1,i=void 0;try{for(var l,a=Object.values(t)[Symbol.iterator]();!(r=(l=a.next()).done);r=!0){let e=l.value;n+=e*e*e-e}}catch(e){o=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n}(s)/(d*(d-1)))),m=u-c;(void 0===n||n)&&(m=Math.sign(m)*Math.max(0,Math.abs(m)-.5));let p=m/f,h=eX.normal.cdf(p,0,1),g=1-h;return{"p-value":2*(h<g?h:g),"Median difference":l-a,"p-value more":g,"p-value less":h}}(t=i||(i={})).indexesOf=function(e,t){let n=[];for(let r=0;r<e.length;r++)t(e[r])&&n.push(r);return n},t.genRange=function(e,t,n){let r=t-e+ +!(void 0!==n&&n),o=new Int32Array(r);for(let t=0;t<r;++t)o[t]=e+t;return o},t.argSort=function(e,t){let n=void 0!==t&&t?(e,t)=>t[0]-e[0]:(e,t)=>e[0]-t[0];return e.map((e,t)=>[e,t]).sort(n).map(e=>e[1])};let ej={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,min:(e,t)=>e<t?e:t,max:(e,t)=>e>t?e:t};function eG(e,t,n,r){var o,l,a,s,u,c;let d,f,m,p=void 0===t?.05:t,h=void 0===n?"n":n,g=void 0!==r&&r,v=e.length,y=0;if(g)m=new Int32Array(v).fill(0).map((e,t)=>t),f=e;else{let t;t=Array.from(e),o=m=Int32Array.from(i.argSort(t)),f=Float32Array.from(e).map((t,n)=>e[o[n]])}let x=(d=(l=f).length,Float32Array.from(l).map((e,t)=>(t+1)/d));if(["n","negcorr"].includes(h))y=function(e){let t=0;for(let n=0;n<e;++n)t+=1/(n+1);return t}(v),a=x,s=y,x=Float32Array.from(a).map((e,t)=>ej["/"](e,s));else if(!["i","indep","p","poscorr"].includes(h))throw Error("only indep and negcorr implemented");let C=Array(v).fill(!1),b=-1;for(let e=0;e<v;++e)f[e]<=x[e]*p&&(b=e);if(b>=0)for(let e=0;e<=b;++e)C[e]=!0;let w=(u=f,c=x,Float32Array.from(u).map((e,t)=>ej["/"](e,c[t])));w=(function(e){let t=e.length,n=Float32Array.from(e);for(let r=0;r<t;++r)n[r]=e.slice(0,r+1).reduce((e,t,n,r)=>ej.min(e,t));return n})(w.reverse()).reverse();for(let e=0;e<v;++e)w[e]>1&&(w[e]=1);if(!g){let e=function(e,t){let n=Float32Array.from(e);for(let r=0;r<t.length;++r)n[t[r]]=e[r];return n}(w,m);return[function(e,t){let n=Array.from(e);for(let r=0;r<t.length;++r)n[t[r]]=e[r];return n}(C,m),e]}return[C,w]}function eB(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function eV(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){eB(i,r,o,l,a,"next",e)}function a(e){eB(i,r,o,l,a,"throw",e)}l(void 0)})}}let e$=[1,2,3,4,5],eH=[2,4,6,8,10],eq=[.001,.008,.039,.041,.042,.06,.074,.205,.212,.216],eW=[.01,.04,.084,.084,.084,.1,.10571428,.216,.216,.216];E("statistics",()=>{P("tTest: the Welch branch uses the sample variance",()=>eV(function*(){let e=eY(e$,eH);A(e["p-value"],.10753119493044197,1e-12),A(e["p-value less"],.053765597465220985,1e-12),A(e["Mean difference"],-3,1e-12),_(e["p-value"]>.1)})()),P("tTest: the equal-variance branch divides by the pooled standard deviation",()=>eV(function*(){let e=eY(e$,eH,!1,!0);A(e["p-value"],.09434977284244564,1e-12),A(e["p-value less"],.04717488642122282,1e-12)})()),P("tTest: the known-deviation branch reports a tail probability",()=>eV(function*(){let e=eY(e$,eH,!0);A(e["p-value"],.05777957112359733,1e-12),A(e["p-value less"],.028889785561798664,1e-12),A(eY(eH,e$,!0)["p-value less"],1-e["p-value less"],1e-12)})()),P("tTest: the tails complement each other and the two-tailed p is twice the smaller",()=>eV(function*(){for(let e of[eY(e$,eH),eY(e$,eH,!1,!0),eY(e$,eH,!0)])A(e["p-value less"]+e["p-value more"],1,1e-12),A(e["p-value"],2*Math.min(e["p-value less"],e["p-value more"]),1e-12)})()),P("tTest: a sample of fewer than two values is refused",()=>eV(function*(){yield B(()=>eV(function*(){eY([1],eH)})(),e=>`${e}`.includes("Wrong sample size")),yield B(()=>eV(function*(){eY(e$,[])})(),e=>`${e}`.includes("Wrong sample size"))})()),P("uTest: no ties, hand-computable",()=>eV(function*(){let e=ek([1,3,5,7,9],[2,4,6,8,10]);A(e["p-value"],.6761033140231467,1e-12),A(e["p-value less"],.33805165701157336,1e-12),A(e["p-value more"],.6619483429884266,1e-12),A(e["Median difference"],-1,1e-12)})()),P("uTest: ties are corrected with the sum of t^3 - t",()=>eV(function*(){let e=ek([1,2,2,3,5],[2,4,4,6,7]);A(e["p-value"],.1375638939099033,1e-12),A(e["p-value less"],.06878194695495166,1e-12)})()),P("uTest: the one-tailed fields are one-tailed",()=>eV(function*(){let e=ek([1,3,5,7,9],[2,4,6,8,10]);_(e["p-value less"]!==e["p-value more"]),A(e["p-value less"]+e["p-value more"],1,1e-12),A(e["p-value"],2*Math.min(e["p-value less"],e["p-value more"]),1e-12);let t=ek([2,4,6,8,10],[1,3,5,7,9]);A(t["p-value less"],e["p-value more"],1e-12),A(t["p-value more"],e["p-value less"],1e-12),A(t["p-value"],e["p-value"],1e-12)})()),P("uTest: the two-tailed p never exceeds 1",()=>eV(function*(){let e=ek([1,2,3,4],[1,2,3,4]);A(e["p-value"],1,1e-12),A(e["p-value less"],.5,1e-12)})()),P("uTest: a sample of fewer than two values is refused",()=>eV(function*(){yield B(()=>eV(function*(){ek([1],[1,2,3])})(),e=>`${e}`.includes("Wrong sample size")),yield B(()=>eV(function*(){ek([1,2,3],[])})(),e=>`${e}`.includes("Wrong sample size"))})()),P("fdrcorrection: adjusted p-values match Benjamini-Hochberg",()=>eV(function*(){let[,e]=eG(new Float32Array(eq),.05,"i");for(let t=0;t<eq.length;t++)A(e[t],eW[t],1e-6)})()),P("fdrcorrection: every hypothesis at or below the line is rejected",()=>eV(function*(){let[e,t]=eG(new Float32Array(eq),.05,"i");N(e,[!0,!0,!1,!1,!1,!1,!1,!1,!1,!1]);for(let n=0;n<eq.length;n++)_(e[n],t[n]<=.05,`hypothesis ${n}`)})()),P("fdrcorrection: a lone passing hypothesis is rejected",()=>eV(function*(){let[e]=eG(new Float32Array([.001,.9,.9,.9]),.05,"i");N(e,[!0,!1,!1,!1])})()),P("fdrcorrection: rejections come back in the caller order",()=>eV(function*(){let e=[.216,.008,.212,.001,.042,.041,.074,.039,.205,.06],[t,n]=eG(new Float32Array(e),.05,"i");N(t,[!1,!0,!1,!0,!1,!1,!1,!1,!1,!1]);for(let t=0;t<e.length;t++)A(n[t],eW[eq.indexOf(e[t])],1e-6)})()),P("fdrcorrection: nothing is rejected when nothing passes",()=>eV(function*(){let[e]=eG(new Float32Array([.4,.5,.6]),.05,"i");N(e,[!1,!1,!1])})())});var eJ=n(886);function eU(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function ez(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){eU(i,r,o,l,a,"next",e)}function a(e){eU(i,r,o,l,a,"throw",e)}l(void 0)})}}let eZ=`<?xml version="1.0" encoding="UTF-8"?>
98
98
  <GraphPadPrismFile xmlns="http://graphpad.com/prism/Prism.htm" PrismXMLVersion="5.00">
99
99
  <Table ID="Table0" XFormat="numbers" TableType="XY">
100
100
  <Title>Test Dose Response</Title>
@@ -136,7 +136,7 @@ ${e.stack?await DG.Logger.translateStackTrace(e.stack):""}`}async function N(e,t
136
136
  </Subcolumn>
137
137
  </YColumn>
138
138
  </Table>
139
- </GraphPadPrismFile>`,eB=`<?xml version="1.0" encoding="UTF-8"?>
139
+ </GraphPadPrismFile>`,eK=`<?xml version="1.0" encoding="UTF-8"?>
140
140
  <GraphPadPrismFile xmlns="http://graphpad.com/prism/Prism.htm" PrismXMLVersion="5.00">
141
141
  <Table ID="Table0" XFormat="numbers" TableType="XY">
142
142
  <Title>XY Data</Title>
@@ -156,7 +156,7 @@ ${e.stack?await DG.Logger.translateStackTrace(e.stack):""}`}async function N(e,t
156
156
  <Subcolumn><d>5</d><d>6</d><d>7</d></Subcolumn>
157
157
  </YColumn>
158
158
  </Table>
159
- </GraphPadPrismFile>`,e$=`<?xml version="1.0" encoding="UTF-8"?>
159
+ </GraphPadPrismFile>`,eQ=`<?xml version="1.0" encoding="UTF-8"?>
160
160
  <GraphPadPrismFile xmlns="http://graphpad.com/prism/Prism.htm" PrismXMLVersion="5.00">
161
161
  <Table ID="Table0" XFormat="numbers" TableType="XY">
162
162
  <Title>With Exclusions</Title>
@@ -174,5 +174,17 @@ ${e.stack?await DG.Logger.translateStackTrace(e.stack):""}`}async function N(e,t
174
174
  </Subcolumn>
175
175
  </YColumn>
176
176
  </Table>
177
- </GraphPadPrismFile>`;O("PZFX Parser",()=>{C("parsePzfxXml: parses XY table",()=>eG(function*(){let e=(0,ek.rn)(eV);b(e.length,1),b(e[0].tableType,"XY"),b(e[0].title,"Test Dose Response"),b(e[0].xValues.length,5),b(e[0].yColumns.length,2),b(e[0].yColumns[0].title,"Compound X"),b(e[0].yColumns[0].subcolumns.length,2),b(e[0].yColumns[1].title,"Compound Y"),b(e[0].yColumns[1].subcolumns.length,1)})()),C("parsePzfxXml: parses multiple tables",()=>eG(function*(){let e=(0,ek.rn)(eB);b(e.length,2),b(e[0].tableType,"XY"),b(e[1].tableType,"OneWay"),b(e[1].title,"Column Data")})()),C("parsePzfxXml: handles excluded and missing data",()=>eG(function*(){let e=(0,ek.rn)(e$)[0].yColumns[0].subcolumns[0];b(e.values[0],10),b(e.excluded[1],!0),b(e.values[3],null),b(e.excluded[0],!1)})()),C("parsePzfxXml: handles trailing binary data",()=>eG(function*(){b((0,ek.rn)(eV+"\0\x01\x02binary garbage").length,1)})()),C("parsePzfxXml: returns empty for malformed XML",()=>eG(function*(){b((0,ek.rn)("<not valid xml").length,0)})()),C("pzfxTableToFitChartData: converts XY table",()=>eG(function*(){let e=(0,ek.rn)(eV),t=(0,ek.fM)(e[0]);b(null!==t,!0),b(t.series.length,2),b(t.series[0].name,"Compound X"),b(t.series[0].points.length,10),b(t.series[1].points.length,5),b(t.chartOptions.logX,!0)})()),C("pzfxTableToFitChartData: returns null for non-XY",()=>eG(function*(){let e=(0,ek.rn)(eB);b((0,ek.fM)(e[1]),null)})()),C("pzfxTableToFitChartData: maps outliers",()=>eG(function*(){let e=(0,ek.rn)(e$),t=(0,ek.fM)(e[0]);b(null!==t,!0),b(t.series[0].points.length,3),b(t.series[0].points.find(e=>2===e.x).outlier,!0)})()),C("pzfxToFitDataFrame: creates fit DataFrame",()=>eG(function*(){let e=(0,ek.rn)(eV),t=(0,ek.aI)(e);b(t.rowCount,1),b(null!==t.col("Fitted Curve"),!0),b(t.col("Fitted Curve").semType,"fit")})()),C("pzfxTableToDataFrame: creates plain DataFrame",()=>eG(function*(){let e=(0,ek.rn)(eB),t=(0,ek.b6)(e[1]);b(t.rowCount,3),b(null!==t.col("Group A"),!0)})())});var eH=n(434),eq=n(476),eW=n(53);function eJ(e,t,n=400,r=300){let o=l.Column.fromStrings("curve",[e]);o.semType=R.h.FIT_SEM_TYPE;let i=l.DataFrame.fromColumns([o]);i.name=t;let a=[],s=U.canvas(n,r).getContext("2d"),u=s.fillText.bind(s);s.fillText=(e,t,n)=>{a.push({text:e,x:t,y:n}),u(e,t,n)};let c=new l.Rect(0,0,n,r),d=(0,eW.h8)(i.cell(0,"curve"));new Q.l().renderCurves(s,c,d);let f=(0,el.lc)(c,d),m=(0,el.Tv)(c,f.x,f.y,(0,el.ij)(c,d))[0];return{rows:a,data:d,dataBox:m}}function eU(e,t,n=400,r=300){return eJ(e,t,n,r).rows.map(e=>e.text)}let ez=[1e-9,3e-9,1e-8,3e-8,1e-7,3e-7,1e-6,3e-6,1e-5,3e-5,1e-4];function eZ(e){return ez.map(t=>({x:t,y:5+95/(1+Math.pow(10,Math.log10(t)-e))}))}function eK(e){return JSON.stringify({chartOptions:{logX:!0},series:[{fitFunction:"sigmoid",name:"series",points:eZ(e)}]})}function eQ(){return JSON.stringify({chartOptions:{logX:!0},series:[{fitFunction:"sigmoid",name:"series",showCurveConfidenceInterval:!0,points:eZ(-6.5)}]})}function e0(e){return JSON.stringify({chartOptions:{logX:!0},series:e.map((e,t)=>({fitFunction:"sigmoid",name:`series ${t}`,points:eZ(e)}))})}function e9(){return JSON.stringify({chartOptions:{logX:!0,labels:{"Z prime":.72},showLabels:["Z prime","compound"]},series:[{fitFunction:"sigmoid",name:"s0",labels:{compound:"GRK-1"},points:eZ(-6.5)},{fitFunction:"sigmoid",name:"s1",labels:{compound:"GRK-2"},points:eZ(-5.5)}]})}var e1=n(181);function e5(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function e2(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){e5(i,r,o,l,a,"next",e)}function a(e){e5(i,r,o,l,a,"throw",e)}l(void 0)})}}function e6(e){let t=JSON.parse(eK(e));return delete t.chartOptions,JSON.stringify(t)}function e4(e,t){let n=l.Column.fromStrings("curve",t.map(eK));n.semType=R.h.FIT_SEM_TYPE;let r=l.DataFrame.fromColumns([n]);return r.name=e,r}function e3(e,t,n){return e2(function*(){yield l.Func.find({name:t})[0].prepare(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}({table:e,curveColumn:e.col("curve")},n)).call(!1,void 0,{processed:!1})})()}function e8(e){let t=[];for(let r=0;r<e.columns.length;r++){var n;let o=null==(n=e.columns.byIndex(r))?void 0:n.name;o&&t.push(o)}return t}O("calculated columns",()=>{C("the statistic column is added right after the curve column",()=>e2(function*(){let e=e4("calcColPosition",[-6.5]);e.columns.addNewString("trailing").set(0,"x");let t=l.Viewer.grid(e).cell("curve",0);yield(0,e1.g)(t,"curveStatistic",{propName:"ic50",seriesNumber:0}),T(e.columns.names(),["curve","curve 1 ic50","trailing"]),T(e8(t.grid),["curve","curve 1 ic50","trailing"])})()),C("placing the statistic column keeps a manually reordered grid",()=>e2(function*(){let e=e4("calcColGridOrder",[-6.5]);e.columns.addNewString("a").set(0,"x"),e.columns.addNewString("b").set(0,"y");let t=l.Viewer.grid(e);t.columns.setOrder(["b","curve","a"]),yield(0,e1.g)(t.cell("curve",0),"curveStatistic",{propName:"ic50",seriesNumber:0}),T(e8(t),["b","curve","curve 1 ic50","a"]),T(e.columns.names(),["curve","curve 1 ic50","a","b"])})()),C("plot-level labels combine across levels instead of the nearest one winning",()=>e2(function*(){let e=JSON.stringify({chartOptions:{logX:!0,labels:{"Z prime":.72}},series:[{fitFunction:"sigmoid",name:"s",points:ez.map(e=>({x:e,y:e}))}]}),t=l.Column.fromStrings("curve",[e]);t.semType=R.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);n.name="calcColLabels",t.setTag(R.h.TAG_FIT,JSON.stringify({chartOptions:{labels:{assay:"GPCR","Z prime":.1}}}));let r=(0,eW.h8)(n.cell(0,"curve")).chartOptions.labels;b(r.assay,"GPCR","the column-level label did not reach the plot"),w(r["Z prime"],.72,.001)})()),C("curveStatistic adds a calculated column",()=>e2(function*(){let e=e4("calcColAdd",[-6.5,-6.5]);yield e3(e,"curveStatistic",{propName:"ic50",seriesNumber:0});let t=e.col("curve 1 ic50");b(null!==t),b(t.type,l.COLUMN_TYPE.FLOAT),w(Math.log10(t.get(0)),-6.5,.15),b(t.getTag(l.TAGS.FORMULA).includes("Curves:curveStatistic")),b(t.getTag(l.TAGS.FORMULA).includes("${curve}")),b(t.getTag(".%formula-column-is-vector-func"),"true")})()),C("recalculates when the source curve changes",()=>e2(function*(){let e=e4("calcColRecalc",[-6.5,-6.5]);yield e3(e,"curveStatistic",{propName:"ic50",seriesNumber:0});let t=e.col("curve 1 ic50").get(1);e.col("curve").set(1,eK(-5),!0),yield A(()=>e.col("curve 1 ic50").get(1)!==t,"statistic column did not recalculate after the source curve changed",5e3),w(Math.log10(e.col("curve 1 ic50").get(1)),-5,.3),b(e.col("curve 1 ic50").get(0),t,"untouched row must not be recalculated")})()),C("legacy statistic names still resolve",()=>e2(function*(){let e=e4("calcColLegacy",[-6.5]);yield e3(e,"curveStatistic",{propName:"interceptX",seriesNumber:0});let t=e.col("curve 1 interceptX");b(null!==t),w(Math.log10(t.get(0)),-6.5,.15)})()),C("curveAggrStatistic aggregates across series",()=>e2(function*(){let e=e4("calcColAggr",[-6.5,-5.5]);yield e3(e,"curveAggrStatistic",{propName:"ic50",aggrType:"med"});let t=e.col("curve med ic50");b(null!==t),w(Math.log10(t.get(0)),-6.5,.15),w(Math.log10(t.get(1)),-5.5,.15)})()),C("averaging IC50 across series is a geometric mean",()=>e2(function*(){let e=JSON.parse(e0([-7,-5]));w(Math.log10((0,eH.JR)(e,"avg").ic50),-6,.1)})()),C("mixed fit functions only aggregate statistics common to all series",()=>e2(function*(){let e=JSON.parse(e0([-7,-5]));e.series[1].fitFunction="linear";let t=(0,eH.Uc)(e).map(e=>e.name);b(t.includes("ic50"),!1,"ic50 is not viable across a sigmoid and a linear fit"),b(t.includes("rSquared"),!0),b(void 0===(0,eH.JR)(e,"avg").ic50,!0,"ic50 must not be aggregated over a subset")})()),C("repeated calculation does not re-log stored parameters",()=>e2(function*(){let e=JSON.parse(eK(-6.5)).series[0];e.parameters=[100,1,100,5];let t={logX:!0,logY:!1},n=(0,ec.h5)((0,eH.TV)(e,0,t,void 0,!1),"ic50");b(n,(0,ec.h5)((0,eH.TV)(e,0,t,void 0,!1),"ic50"),"stored parameters drifted between calls"),w(n,100,1)})()),C("fitting a series does not write fit-space parameters back onto it",()=>e2(function*(){let e=JSON.parse(e0([2])).series[0],t={logX:!0,logY:!1},n=(0,ec.h5)((0,eH.TV)(e,0,t,void 0,!1),"ic50");b(void 0===e.parameters,!0,"the series must keep its data-space contract"),b(n,(0,ec.h5)((0,eH.TV)(e,0,t,void 0,!1),"ic50"),"the reported IC50 drifted between calls")})()),C("recalculation applies column-level chart options",()=>e2(function*(){let e=l.Column.fromStrings("curve",[e6(-6.5),e6(-6.5)]);e.semType=R.h.FIT_SEM_TYPE,e.setTag(R.h.TAG_FIT,JSON.stringify({chartOptions:{logX:!0}}));let t=l.DataFrame.fromColumns([e]);t.name="calcColColumnOptions",yield e3(t,"curveStatistic",{propName:"ic50",seriesNumber:0});let n=t.col("curve 1 ic50").get(1);t.col("curve").set(1,e6(-5),!0),yield A(()=>t.col("curve 1 ic50").get(1)!==n,"statistic column did not recalculate",5e3),w(Math.log10(t.col("curve 1 ic50").get(1)),-5,.3)})()),C("log-space statistics are not offered for aggregations we do not convert",()=>e2(function*(){let e=JSON.parse(e0([-7,-5])),t=(0,eH.Uc)(e,"count").map(e=>e.name);b(t.includes("pIC50"),!1,"pIC50 is only derived in data space"),b(t.includes("rSquared"),!0,"space-independent statistics stay"),b(t.includes("ic50"),!0,"ic50 must stay available for aggregations we do not convert"),w((0,eH.JR)(e,"avg").ic50,1e-6,1e-7),w((0,eH.JR)(e,"count").ic50,2,.001),w((0,eH.JR)(e,"count").interceptX,2,.001)})()),C("stored parameters round-trip through fit space on both axes",()=>e2(function*(){for(let e of[{logX:!1,logY:!1},{logX:!0,logY:!1},{logX:!1,logY:!0},{logX:!0,logY:!0}]){let t=JSON.parse(eK(-6.5)).series[0];t.parameters=[100,1,1e-6,5];let n=(0,eH.TV)(t,0,e,void 0,!1);w((0,ec.h5)(n,"top"),100,1e-6,`top under ${JSON.stringify(e)}`),w((0,ec.h5)(n,"bottom"),5,1e-6,`bottom under ${JSON.stringify(e)}`),w((0,ec.h5)(n,"ic50"),1e-6,1e-12,`ic50 under ${JSON.stringify(e)}`)}})()),C("a detached column strips the stray pipe like the initial parse does",()=>e2(function*(){let e=l.Column.fromStrings("curve",[eK(-6.5).replace("{","{|")]);e.semType=R.h.FIT_SEM_TYPE,b(null===e.dataFrame||void 0===e.dataFrame,!0,"the column must be detached");let t=(0,eH.bW)(e,0,"ic50",0);b(null!==t,!0,"a pipe in the cell value blanked the row"),w(Math.log10(t),-6.5,.3)})()),C("a legacy statistic reads the same per series and aggregated",()=>e2(function*(){let e=JSON.parse(e0([-6.5]));e.series[0].fitFunction="linear";let t=(0,ec.h5)((0,eH.TV)(e.series[0],0,{logX:!0,logY:!1},void 0,!1),"top"),n=(0,eH.JR)(e,"med").top;b(void 0!==t,!0,"the per-series path lost the fallback"),b(void 0!==n,!0,"the aggregated path drops a statistic the per-series one reports")})()),C("a legacy name and its canonical field agree after aggregation",()=>e2(function*(){let e=JSON.parse(e0([-7,-5])),t=(0,eH.JR)(e,"avg");b(t.interceptX,t.ic50,"interceptX must be reported in the same space as ic50"),w(Math.log10(t.interceptX),-6,.1)})()),C("mergeSeries does not change a statistic",()=>e2(function*(){let e=JSON.parse(e0([-7,-5])),t=JSON.parse(e0([-7,-5]));t.chartOptions.mergeSeries=!0;let n={logX:!0,logY:!1};for(let r of[0,1])b((0,ec.h5)((0,eH.TV)(e.series[r],r,n,void 0,!1),"ic50"),(0,ec.h5)((0,eH.TV)(t.series[r],r,n,void 0,!1),"ic50"),`series ${r} changed when mergeSeries was set`);b((0,eH.JR)(t,"med").ic50,(0,eH.JR)(e,"med").ic50)})()),C("outlier toggle refreshes statistic columns named by the new API",()=>e2(function*(){let e=e4("calcColOutlierToggle",[-6.5]),t=l.Column.float("ic50 col",e.rowCount);t.tags[".sourceColumn"]="curve",t.tags[".seriesNumber"]="0",t.tags[".statistics"]="ic50",t.init(()=>1e-6),e.columns.add(t);let n=l.Viewer.grid(e).cell("curve",0),r=(0,eW.h8)(n.cell,!0);(0,eq.Fw)(n,r.series[0].points[0],0,0,r);let o=e.col("ic50 col").get(0);b(null!=o&&!isNaN(o),!0,"outlier toggle blanked the ic50 column"),w(Math.log10(o),-6.5,.3)})())});var e7=n(258);function te(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function tt(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){te(i,r,o,l,a,"next",e)}function a(e){te(i,r,o,l,a,"throw",e)}l(void 0)})}}function tn(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 tr(e,t,n){var r,o;let i=JSON.stringify((r=tn({},t?{chartOptions:tn({logX:!0},n?{showStatistics:n}:{})}:{}),o=o={series:[{fitFunction:"sigmoid",name:"series",points:eZ(-6.5)}]},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r)),a=l.Column.fromStrings("curve",[i,i]);a.semType=R.h.FIT_SEM_TYPE;let s=l.DataFrame.fromColumns([a]);return s.name=e,s}function to(e,t){return tt(function*(){yield l.Func.find({package:"Curves",name:"curveStatistic"})[0].prepare(tn({table:e,curveColumn:e.col("curve")},t)).call(!1,void 0,{processed:!1})})()}function ti(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function tl(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){ti(i,r,o,l,a,"next",e)}function a(e){ti(i,r,o,l,a,"throw",e)}l(void 0)})}}function ta(e){let t=l.Column.fromStrings("curve",[e0([-7,-5]),e0([-6,-4])]);t.semType=R.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);return n.name=e,n}O("panel and renderer",()=>{C("every registered aggregation input offers only convertible aggregations",()=>tt(function*(){let e=["min","max","avg","med","q1","q2","q3"],t=[];for(let n of l.Func.find({package:"Curves"}))for(let r of n.inputs.filter(e=>/^(aggrType|aggregation)$/.test(e.name)))for(let o of(t.push(n.name),b(void 0!==r.choices&&null!==r.choices,!0,`${n.name} takes a free-text aggregation`),r.choices))b(e.includes(o),!0,`${n.name} offers ${o}`);b(t.length>=3,!0,`expected every aggregation function to be checked, saw ${t}`)})()),C("rendering does not mutate the cached series parameters",()=>tt(function*(){let e={chartOptions:{logX:!0},series:[{fitFunction:"sigmoid",name:"series",parameters:[100,1,100,5],points:eZ(-6.5)}]},t=[...e.series[0].parameters],n=U.canvas(200,120).getContext("2d"),r=new Q.l,o=Q.l.inflateScreenBounds(new l.Rect(0,0,200,120));r.renderCurves(n,o,e),r.renderCurves(n,o,e),T(e.series[0].parameters,t)})()),C("firing values-changed on a curve column recalculates its statistic columns",()=>tt(function*(){let e=tr("panelColumnOption",!1),t=e.col("curve");t.setTag(R.h.TAG_FIT,JSON.stringify({chartOptions:{logX:!0}})),yield to(e,{propName:"ic50",seriesNumber:0});let n=e.col("curve 1 ic50").get(0);w(Math.log10(n),-6.5,.3),t.setTag(R.h.TAG_FIT,JSON.stringify({chartOptions:{logX:!1}})),t.fireValuesChanged(),yield A(()=>e.col("curve 1 ic50").get(0)!==n,"statistic column did not recalculate after the column-level option changed",5e3)})()),C("clearing a cell-level override does not recalculate on its own",()=>tt(function*(){let e=JSON.stringify({chartOptions:{logX:!0},series:[{fitFunction:"sigmoid",name:"series",pointColor:"#ff0000",points:eZ(-6.5)}]}),t=l.Column.fromStrings("curve",[e,e]);t.semType=R.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);n.name="panelNoRecalcOnCosmetic",yield to(n,{propName:"ic50",seriesNumber:0});let r=n.col("curve 1 ic50"),o=r.version;for(let e=0;e<t.length;e++){let n=JSON.parse(t.get(e));delete n.series[0].pointColor,t.set(e,JSON.stringify(n),!1)}yield E(500),b(r.version,o,"a cosmetic rewrite recalculated the statistic column")})()),C("a column-level option overrides a cell-level one, without recalculating",()=>tt(function*(){let e=JSON.stringify({chartOptions:{logX:!0},series:[{fitFunction:"sigmoid",name:"series",pointColor:"#ff0000",points:eZ(-6.5)}]}),t=l.Column.fromStrings("curve",[e,e]);t.semType=R.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);n.name="panelColumnOverridesCell",yield to(n,{propName:"ic50",seriesNumber:0});let r=n.col("curve 1 ic50"),o=r.version,i=l.Viewer.grid(n).cell("curve",0);(0,e7.FC)(i,{property:{name:"pointColor"},value:"#00ff00"},"seriesOptions","Column"),yield E(500),b("#ff0000"===(0,eW.h8)(n.cell(0,"curve")).series[0].pointColor,!1,"the cell-level value still wins after the column-level change"),b(r.version,o,"a cosmetic option change recalculated the statistic column")})()),C("clearing cell overrides marks the table changed without recalculating",()=>tt(function*(){let e=l.Column.fromStrings("curve",[eQ(),eQ()]);e.semType=R.h.FIT_SEM_TYPE;let t=l.DataFrame.fromColumns([e]);t.name="panelMarksTableChanged",yield to(t,{propName:"ic50",seriesNumber:0});let n=t.col("curve 1 ic50"),r=n.version,o=l.Viewer.grid(t).cell("curve",0),i=0,a=t.onValuesChanged.subscribe(()=>i++);(0,e7.FC)(o,{property:{name:"showCurveConfidenceInterval"},value:!1},"seriesOptions","Column"),yield E(500),a.unsubscribe(),b(JSON.parse(e.get(0)).series[0].showCurveConfidenceInterval,!0,"the cell data was mutated"),b((0,eW.h8)(t.cell(0,"curve")).series[0].showCurveConfidenceInterval,!1,"the column-level value did not outrank the value declared in the cell"),b(i>0,!0,"nothing marked the table changed, so the option would not be saved"),b(n.version,r,"a cosmetic option change recalculated the statistic column")})()),C("a column-level change overrides a value set at cell level first",()=>tt(function*(){let e=tr("panelCellThenColumn",!0),t=l.Viewer.grid(e).cell("curve",0),n=e=>({property:{name:"connectDots"},value:e});(0,e7.FC)(t,n(!0),"seriesOptions","Cell"),b(JSON.parse(e.col("curve").get(0)).series[0].connectDots,!0,"cell-level write failed"),b(JSON.parse(e.col("curve").get(0)).explicit.seriesOptions.includes("connectDots"),!0,"a cell-level change did not claim the property"),(0,e7.FC)(t,n(!1),"seriesOptions","Column"),b(JSON.parse(e.col("curve").get(0)).explicit.seriesOptions.includes("connectDots"),!1,"the cell-level claim survived a column-level change"),b((0,eW.h8)(e.cell(0,"curve")).series[0].connectDots,!1,"the column-level value did not reach the cell")})()),C("a column-level option outranks a value the fresh data declares",()=>tt(function*(){let e=l.Column.fromStrings("curve",[eQ(),eQ()]);e.semType=R.h.FIT_SEM_TYPE;let t=l.DataFrame.fromColumns([e]);t.name="panelFreshDataClaim",e.setTag(R.h.TAG_FIT,JSON.stringify({seriesOptions:{showCurveConfidenceInterval:!1},explicit:{seriesOptions:["showCurveConfidenceInterval"]}})),b((0,eW.h8)(t.cell(0,"curve")).series[0].showCurveConfidenceInterval,!1,"the restored column-level option lost to the value the cell declares"),e.setTag(R.h.TAG_FIT,JSON.stringify({seriesOptions:{showCurveConfidenceInterval:!1}})),b((0,eW.h8)(t.cell(1,"curve")).series[0].showCurveConfidenceInterval,!0,"an option nobody set explicitly overrode the data")})()),C("a column-level option survives a layout applied to a fresh table",()=>tt(function*(){let e=e=>{let t=l.Column.fromStrings("curve",[eQ(),eQ()]);t.semType=R.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);return n.name=e,n},t=e("layoutSource"),n=M.shell.addTableView(t),r=e("layoutTarget"),o=M.shell.addTableView(r);try{var i;b((0,eW.h8)(r.cell(0,"curve")).series[0].showCurveConfidenceInterval,!0,"the fresh table should start with the value its data declares"),(0,e7.FC)(n.grid.cell("curve",0),{property:{name:"showCurveConfidenceInterval"},value:!1},"seriesOptions","Column"),(0,e7.FC)(n.grid.cell("curve",0),{property:{name:"statisticsMode"},value:"both"},"chartOptions","Column");let e=n.saveLayout();o.loadLayout(e),yield E(500),b((0,eW.h8)(r.cell(0,"curve")).series[0].showCurveConfidenceInterval,!1,"the column-level option did not survive the layout"),b(null==(i=(0,eW.h8)(r.cell(0,"curve")).chartOptions)?void 0:i.statisticsMode,"both","a chart option did not survive the layout")}finally{n.close(),o.close()}})()),C("options stored under the legacy tag are read, and move onto the layout-carried one when written",()=>tt(function*(){b(R.h.TAG_FIT.startsWith(".%"),!0,"the fit tag is no longer carried by layouts");let e=tr("panelLegacyTag",!1),t=e.col("curve");t.setTag(R.h.TAG_FIT_LEGACY,JSON.stringify({chartOptions:{logX:!0}})),b((0,eW.bc)(t).chartOptions.logX,!0,"options under the legacy tag were ignored"),b(null==t.getTag(R.h.TAG_FIT),!0,"reading the options wrote a tag"),(0,e7.FC)(l.Viewer.grid(e).cell("curve",0),{property:{name:"showCurveConfidenceInterval"},value:!1},"seriesOptions","Column");let n=JSON.parse(t.getTag(R.h.TAG_FIT));b(n.chartOptions.logX,!0,"the legacy options were lost when the column was written"),b(n.seriesOptions.showCurveConfidenceInterval,!1,"the change was not stored"),b(null==t.getTag(R.h.TAG_FIT_LEGACY),!0,"both tags now hold the options")})()),C("the panel offers the label names the cell carries",()=>tt(function*(){let e=JSON.parse(e9());T((0,e7.di)(e).find(e=>"showLabels"===e.name).choices,["Z prime","compound"])})()),C("a plot-level label is drawn once, a per-curve one per curve",()=>tt(function*(){let e=eU(e9(),"panelLabels");b(e.filter(e=>e.startsWith("Z prime")).length,1,"the plot-level label was not drawn once"),b(e.filter(e=>e.startsWith("compound")).length,2,"each curve should carry its own label"),b(e.includes("compound: GRK-1"),!0),b(e.includes("compound: GRK-2"),!0)})()),C("only the labels named in showLabels are drawn",()=>tt(function*(){let e=JSON.parse(e9());e.chartOptions.showLabels=["compound"];let t=eU(JSON.stringify(e),"panelLabelsFiltered");b(t.some(e=>e.startsWith("Z prime")),!1,"a label not named in showLabels was drawn"),b(t.filter(e=>e.startsWith("compound")).length,2)})()),C("an error bar starts at the marker edge and hides when the marker covers it",()=>tt(function*(){let e=(0,em.a)(100,70,130,2);b(null!==e,!0,"a deviation larger than the marker should be drawn"),T(e.top,[70,98]),T(e.bottom,[102,130]),b(null===(0,em.a)(100,70,130,40),!0,"a deviation smaller than the marker must not be drawn inside it"),b(null===(0,em.a)(100,80,120,20),!0),b(null!==(0,em.a)(100,79,121,20),!0)})()),C("one list of statistics, and the mode decides where it is drawn",()=>tt(function*(){let e=JSON.parse(e0([-7,-5]));e.chartOptions.showStatistics=["ic50"],e.chartOptions.statisticsMode="both",e.chartOptions.aggrType="med";let t=eU(JSON.stringify(e),"panelAggrBoth"),n=t.find(e=>e.startsWith("med ic50"));b(void 0!==n,!0,"the aggregated statistic was not drawn"),b(t.filter(e=>e.startsWith("med ic50")).length,1,"it describes the cell, so it is drawn once"),b(t.filter(e=>e.startsWith("IC50")).length,2,"each curve should still show its own"),b(n.includes("1.0")||n.includes("1e-6")||n.includes("9.9"),!0,`unexpected value: ${n}`),e.chartOptions.statisticsMode="aggregated";let r=eU(JSON.stringify(e),"panelAggrOnly");b(r.filter(e=>e.startsWith("med ic50")).length,1),b(r.some(e=>e.startsWith("IC50")),!1,"the per-series values should give way to the summary"),e.chartOptions.statisticsMode="series";let o=eU(JSON.stringify(e),"panelAggrSeries");b(o.some(e=>e.startsWith("med ")),!1,"nothing should be summarised in series mode"),b(o.filter(e=>e.startsWith("IC50")).length,2)})()),C("a single-series cell has nothing to aggregate",()=>tt(function*(){let e=JSON.parse(e0([-6.5]));e.chartOptions.showStatistics=["ic50"],e.chartOptions.statisticsMode="aggregated";let t=eU(JSON.stringify(e),"panelAggrSingle");b(t.some(e=>e.startsWith("med ")),!1,"with one curve the aggregate is that curve, so it should not be drawn"),b(t.some(e=>e.startsWith("IC50")),!0,"the single curve should still show its own")})()),C("the panel offers droplines only for a fit that has asymptotes",()=>tt(function*(){let e=e=>(0,e7.s9)(JSON.parse(e),null).map(e=>e.name);b(e(eK(-6.5)).includes("droplines"),!0,"a sigmoid levels off at both ends");let t=JSON.parse(eK(-6.5));t.series[0].fitFunction="linear",b(e(JSON.stringify(t)).includes("droplines"),!1,"a line has no asymptotes, so an ICxx would never be drawn"),b(e(JSON.stringify(t)).includes("markerType"),!0),b(e(eK(-6.5)).includes("columnName"),!1,"the column a series came from is not a setting")})()),C("a custom fit function is offered once, everywhere, and never an empty one",()=>tt(function*(){let e={name:"TestCustomFit",function:"(params, x) => params[0] * x",getInitialParameters:"(x, y) => new Float32Array([1])",parameterNames:["Slope"]},t=JSON.parse(eK(-6.5));t.series[0].fitFunction=e;try{(0,es.zB)(t.series[0]);let n=(0,e7.s9)(t,e).find(e=>"fitFunction"===e.name).choices;b(n.filter(t=>t===e.name).length,1,"a registered function is named once"),b(n.includes(""),!1,"a series is fitted with something, so none is not a choice");let r=(0,e7.s9)(JSON.parse(eK(-6.5)),null).find(e=>"fitFunction"===e.name).choices;b(r.includes(e.name),!0,"and offered wherever a fit function is picked"),b(r.includes(""),!1,"here too")}finally{delete ec.rT[e.name]}})()),C("picking a custom fit function stores the notation, not a name nothing can resolve",()=>tt(function*(){let e={name:"TestStoredFit",function:"(params, x) => params[0] * x",getInitialParameters:"(x, y) => new Float32Array([1])",parameterNames:["Slope"]};try{let t=JSON.parse(eK(-6.5));t.series[0].fitFunction=e,(0,es.zB)(t.series[0]);let n=eK(-6.5),r=l.Column.fromStrings("curve",[n,n]);r.semType=R.h.FIT_SEM_TYPE;let o=l.DataFrame.fromColumns([r]);o.name="customFitNotationStored";let i=l.Viewer.grid(o).cell("curve",0);(0,e7.FC)(i,{property:{name:"fitFunction"},value:e.name},"seriesOptions","Cell"),yield E(300);let a=JSON.parse(o.col("curve").get(0)).series[0].fitFunction;b(typeof a,"object","the name alone would not resolve in a session that never loaded it"),b(a.name,e.name),b(!!a.function&&!!a.getInitialParameters,!0,"the notation travels with the curve"),(0,e7.FC)(i,{property:{name:"fitFunction"},value:"linear"},"seriesOptions","Cell"),yield E(300),b(JSON.parse(o.col("curve").get(0)).series[0].fitFunction,"linear","a built-in one is always there, so it stays a name")}finally{delete ec.rT[e.name],delete ec.HM[e.name]}})()),C("statistics are written in the plot font, not the one the caller left",()=>tt(function*(){let e=JSON.parse(eK(-6.5));e.chartOptions.showStatistics=["auc","rSquared"];let t=l.Column.fromStrings("curve",[JSON.stringify(e)]);t.semType=R.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);n.name="statisticsFont";let r=e=>{let t=[],r=U.canvas(400,300).getContext("2d"),o=r.fillText.bind(r);return r.fillText=(e,n,i)=>{e.includes(":")&&t.push(r.font),o(e,n,i)},r.font=e,new Q.l().renderCurves(r,new l.Rect(0,0,400,300),(0,eW.h8)(n.cell(0,"curve"))),[...new Set(t)]},o=r("20px Comic Sans MS");b(o.length,1,"every statistic should be written alike"),b(o[0].includes("Comic Sans"),!1,"and not in whatever the caller was using"),b(r('11px Roboto, "Roboto Local"')[0],o[0],"the same font however the canvas reached the renderer")})()),C("several droplines are named, and one off the plot is not drawn",()=>tt(function*(){let e=JSON.parse(eK(-6.5));e.series[0].droplines=["IC50","IC90"];let t=eU(JSON.stringify(e),"droplinesBoth");b(t.filter(e=>"IC50"===e).length,1,"each drawn dropline should be named"),b(t.filter(e=>"IC90"===e).length,1),e.series[0].droplines=["IC50"],b(eU(JSON.stringify(e),"droplinesOne").includes("IC50"),!1,"one dropline needs no caption"),e.series[0].droplines=["IC50","IC90"],b(eU(JSON.stringify(e),"droplinesSmall",200,150).includes("IC50"),!1,"captions should give way when the plot is small");let n=JSON.parse(eK(-5));n.series[0].droplines=["IC50","IC99"];let r=eU(JSON.stringify(n),"droplinesOffPlot");b(r.includes("IC50"),!0),b(r.includes("IC99"),!1,"a dropline off the plot should not be drawn at all")})()),C("property panel renders for a saved legacy statistic",()=>tt(function*(){let e=tr("panelBinding",!0,["interceptX"]),t=l.Viewer.grid(e).cell("curve",0);b(new e1.e().renderProperties(t)instanceof HTMLElement,!0,"the property panel failed to render")})()),C("statistic names stored under a legacy name map onto the current ones",()=>tt(function*(){let e=JSON.parse(JSON.stringify({chartOptions:{logX:!0},series:[{fitFunction:"sigmoid",name:"s",points:eZ(-6.5)}]}));T((0,e7.QA)(e,["interceptX"]),["ic50"]),T((0,e7.QA)(e,["auc","rSquared"]),["auc","rSquared"]),T((0,e7.QA)(e,["interceptX","ic50"]),["ic50"]);let t=(0,e7.di)(e).find(e=>"showStatistics"===e.name).choices;b(t.includes("ic50"),!0),b(t.includes("ec50"),!1,"a sigmoid cell must not offer the 4PL-regression name")})())}),O("multi curve viewer",()=>{C("merging cell series leaves the cell alone, and unmerging comes back",()=>tl(function*(){let e=ta("multiCurveMerge"),t=M.shell.addTableView(e);try{var n,r,o,i,l,a;e.currentRowIdx=0,t.addViewer("MultiCurveViewer",{curvesColumnNames:["curve"]}),yield E(1e3);let s=Array.from(t.viewers).find(e=>"MultiCurveViewer"===e.type);b(void 0!==s,!0,"the viewer was not added"),b(null==(r=s.data)||null==(n=r.series)?void 0:n.length,2,"the current row carries two curves"),s.props.set("mergeCellSeries",!0),yield E(500),b(null==(i=s.data)||null==(o=i.series)?void 0:o.length,1,"merging should leave one curve in the viewer"),b((0,eW.h8)(e.cell(0,"curve")).series.length,2,"the cell itself must still hold both curves"),s.props.set("mergeCellSeries",!1),yield E(500),b(null==(a=s.data)||null==(l=a.series)?void 0:l.length,2,"unmerging should bring both curves back")}finally{t.close()}})(),{timeout:6e4}),C("the viewer names where each of its curves came from",()=>tl(function*(){let e=ta("multiCurveFitIdentities"),t=M.shell.addTableView(e);try{e.currentRowIdx=0,t.addViewer("MultiCurveViewer",{curvesColumnNames:["curve"]}),yield E(1500);let n=Array.from(t.viewers).find(e=>"MultiCurveViewer"===e.type);b(n.fitIdentities.length,n.data.series.length,"every series should carry an identity, in the order they are drawn"),b(n.fitIdentities.every(e=>void 0!==e),!0,"and none of them should be missing")}finally{t.close()}})(),{timeout:6e4}),C("the viewer answers the same hovers the grid does",()=>tl(function*(){let e=Array.from({length:40},(e,t)=>-8+.1*t),t=l.Column.fromStrings("curve",[e0(e)]);t.semType=R.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);n.name="multiCurveHover";let r=M.shell.addTableView(n);try{n.currentRowIdx=0,r.addViewer("MultiCurveViewer",{curvesColumnNames:["curve"]}),yield E(2e3);let e=Array.from(r.viewers).find(e=>"MultiCurveViewer"===e.type);b(e.data.series.length,40,"the current row carries all the curves");let t=e.canvas,o=t.getBoundingClientRect(),i=[];for(let e=10;e<t.width-5&&0===i.length;e+=10)for(let n=6;n<t.height-5;n+=6){t.dispatchEvent(new MouseEvent("mousemove",{bubbles:!0,clientX:o.left+e,clientY:o.top+n}));let r=document.querySelector(".d4-tooltip"),l=(null==r?void 0:r.innerText)?r.innerText.split("\n").filter(e=>e.trim().length>0):[];if(l.some(e=>e.startsWith("series "))){i=l;break}}b(i.length>0,!0,"hovering the legend in the viewer should name a curve")}finally{r.close()}})(),{timeout:9e4})});var ts=n(663);function tu(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function tc(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){tu(i,r,o,l,a,"next",e)}function a(e){tu(i,r,o,l,a,"throw",e)}l(void 0)})}}function td(e,t=!0){let n=[];for(let{column:t,series:r}of e)for(let e of r)n.push({fitFunction:"sigmoid",name:e,columnName:t,points:eZ(-6.5)});return JSON.stringify({chartOptions:{logX:!0,showColumnLabel:t},series:n})}let tf=new l.Rect(0,0,500,400);function tm(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function tp(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){tm(i,r,o,l,a,"next",e)}function a(e){tm(i,r,o,l,a,"throw",e)}l(void 0)})}}function th(e,t=-6.5){let n=l.Column.fromStrings("curve",[eK(t)]);n.semType=R.h.FIT_SEM_TYPE;let r=l.DataFrame.fromColumns([n]);return r.name=e,r.cell(0,"curve")}function tg(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function tv(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){tg(i,r,o,l,a,"next",e)}function a(e){tg(i,r,o,l,a,"throw",e)}l(void 0)})}}O("legend",()=>{C("a column holding one curve does not get a row of its own",()=>tc(function*(){let e=JSON.parse(td([{column:"curve",series:["PF5624 P1_1h"]},{column:"durability_curve",series:["siR-0016_durability"]},{column:"in_vivo_dr_curve",series:["siR-0016_invivo_dr"]},{column:"plasma_stability_curve",series:["siR-0016_plasma_stab"]}]));T((0,ts._i)(e).map(e=>e.text),["PF5624 P1_1h","siR-0016_durability","siR-0016_invivo_dr","siR-0016_plasma_stab"]);let t=JSON.parse(td([{column:"curve",series:["low","high"]}]));T((0,ts._i)(t).map(e=>e.text),["curve","low","high"])})()),C("a name shared by two columns is qualified by the column",()=>tc(function*(){let e=JSON.parse(td([{column:"day 1",series:["control"]},{column:"day 7",series:["control"]}]));T((0,ts._i)(e).map(e=>e.text),["day 1: control","day 7: control"])})()),C("two curves named alike in one column are left as the data has them",()=>tc(function*(){let e=JSON.parse(td([{column:"multiple styled series",series:["Run:2023-08-08","Run:2023-08-08"]}]));T((0,ts._i)(e).map(e=>e.text),["multiple styled series","Run:2023-08-08","Run:2023-08-08"])})()),C("a shortened row says what it stands for when hovered",()=>tc(function*(){let e="Copy of 20250528_NHA Assay_analysis Plate_1 rep 2 run 3 reader B plate map 7 revision 2",t=eJ(JSON.stringify(JSON.parse(td([{column:"curve",series:[e]}]))),"legendHover",500,400),n=t.rows.find(e=>e.text.startsWith("Copy of"));b(void 0!==n,!0,"the curve should be named");let r=(0,ts.tp)(t.data,t.dataBox,n.x+5,n.y-4);b(null==r?void 0:r.length,1,"hovering the row should say one thing"),b(r[0].text,e,"and it should be the whole name"),b(null===(0,ts.tp)(t.data,t.dataBox,t.dataBox.x+5,t.dataBox.maxY-5),!0,"the rest of the plot should say nothing")})()),C("candlesticks and statistics count as ink, not just fit lines",()=>tc(function*(){let e=[];for(let t of[1e-9,1e-8,1e-7,1e-6,1e-5])e.push({x:t,y:100}),e.push({x:t,y:96});e.push({x:1e-4,y:0});let t=eJ(JSON.stringify({chartOptions:{logX:!0},series:[{name:"Run:2023-08-08",columnName:"curve",showPoints:"candlesticks",showFitLine:!1,connectDots:!0,points:e}]}),"legendCandles",500,400),n=t.rows.find(e=>e.text.startsWith("Run:"));b(void 0!==n,!0,"the curve should be named"),b(n.y>t.dataBox.midY,!0,`points fill the top, so the legend belongs below: y=${n.y}`)})()),C("the statistics on the plot are ink the legend keeps clear of",()=>tc(function*(){let e=JSON.parse(td([{column:"curve",series:["Run:2023-08-08"]}]));e.chartOptions.showStatistics=["ic50"];let t=eJ(JSON.stringify(e),"legendStats",500,400),n=t.rows.find(e=>e.text.startsWith("IC50")),r=t.rows.find(e=>e.text.startsWith("Run:"));b(void 0!==n&&void 0!==r,!0,"both should be drawn"),b(Math.abs(r.y-n.y)>10||Math.abs(r.x-n.x)>60,!0,`the legend should not land on the statistics: legend ${r.x},${r.y} vs ${n.x},${n.y}`)})()),C("a curve across the top sends the legend to the bottom",()=>tc(function*(){let e=new l.Rect(0,0,400,300),t=[];for(let n=e.x+10;n<e.maxX-10;n+=8)t.push(new l.Point(n,e.y+30));let n=(0,ts.Al)(e,120,20,t).rect;b(n.y>e.midY,!0,`expected a bottom corner, got y=${n.y}`)})()),C("the legend takes a corner the curves leave free",()=>tc(function*(){let e=new l.Rect(0,0,400,300),t=Array.from({length:30},(t,n)=>new l.Point(e.maxX-10-n,e.y+10+n%20));b((0,ts.Al)(e,120,60,t).rect.x<e.midX,!0,"a crowded top right should push the legend away");let n=[new l.Point(e.maxX-20,e.y+20),new l.Point(e.maxX-30,e.y+30)];b((0,ts.Al)(e,120,60,n).rect.x>e.midX,!0,"it should stay put");let r=[];for(let t of[[e.maxX-20,e.y+20],[e.x+20,e.y+20],[e.maxX-20,e.maxY-20],[e.x+20,e.maxY-20]])for(let e=0;e<30;e++)r.push(new l.Point(t[0],t[1]+e%10));b((0,ts.Al)(e,120,60,r).rect.x>e.midX,!0,"nowhere better means no move"),b((0,ts.Al)(e,120,60).rect.x>e.midX,!0,"and with nothing drawn it is the top right");let o=[...t.slice(0,6),new l.Point(e.x+20,e.maxY-20)];b((0,ts.Al)(e,120,60,o,3).index,3,"it should keep the corner it was in"),b((0,ts.Al)(e,120,60,t,3).index,3,"even when the top right is busy")})()),C("a name is only shortened when it really does not fit",()=>tc(function*(){let e="SigmoidalInhibitionFunction";for(let t of[500,430,380]){let n=eU(td([{column:"curve",series:[e]}]),`legendFits${t}`,t,400);b(n.includes(e),!0,`at ${t}px expected the whole name, got: ${n.filter(e=>e.startsWith("Sigmo"))}`)}})()),C("a name too long for any corner is ellipsized",()=>tc(function*(){let e,t="Copy of 20250528_NHA Assay_analysis Plate_1 rep 2 run 3 reader B plate map 7 revision 2",n=eU(td([{column:"curve",series:[t]}]),"legendEllipsis",500,400).find(e=>e.startsWith("Copy of"));b(void 0!==n,!0,"the curve should be named"),b(n.endsWith("…"),!0,`expected an ellipsis, got: ${n}`),b(n.length<t.length,!0,"the name should be shortened"),b(((e=U.canvas(10,10).getContext("2d")).font='11px Roboto, "Roboto Local"',e.measureText(n).width<=.55*tf.width),!0,"the row must stay within its cap")})()),C("naming the curves can be turned off for the whole plot",()=>tc(function*(){let e=JSON.parse(td([{column:"curve",series:["Run:2023-08-08"]}]));b(eU(JSON.stringify(e),"legendOn",500,400).includes("Run:2023-08-08"),!0),e.chartOptions.showLegend=!1;let t=eU(JSON.stringify(e),"legendOff",500,400);b(t.includes("Run:2023-08-08"),!1,"showLegend: false should leave the curves unnamed"),b(t.some(e=>"Conc."===e||"Activity"===e||e.length>0),!0)})()),C("hovering what did not fit gives the whole legend",()=>tc(function*(){let e=Array.from({length:40},(e,t)=>`series ${t}`),t=eJ(td([{column:"curve",series:e}]),"legendMoreHover",500,400),n=t.rows.find(e=>e.text.startsWith("+")&&e.text.endsWith("more"));b(void 0!==n,!0,"the legend should say how many it left out");let r=(0,ts.tp)(t.data,t.dataBox,n.x+5,n.y-4);b(null==r?void 0:r.length,e.length+1,"the tooltip should carry every row the legend has"),b(r.some(e=>"series 39"===e.text),!0,"including the ones it could not draw"),b(r.every(e=>e.color.length>0),!0,"each named in the colour of its curve")})()),C("a legend short enough to list keeps every row in the tooltip",()=>tc(function*(){let e=JSON.parse(td([{column:"curve",series:Array.from({length:4},(e,t)=>`series ${t}`)}])),t=(0,ts._i)(e),n=(0,ts.D5)(t);b(n.querySelectorAll("canvas").length,t.length,"every row should carry its glyph"),b(n.innerText.includes("more"),!1,"nothing is left to count when it all fits")})()),C("a legend too long for the window is counted rather than listed",()=>tc(function*(){let e=JSON.parse(td([{column:"curve",series:Array.from({length:300},(e,t)=>`series ${t}`)}])),t=(0,ts._i)(e),n=(0,ts.bp)();b(t.length>n,!0,"the fixture should outgrow any window");let r=(0,ts.D5)(t);b(r.querySelectorAll("canvas").length,n,"it lists what the window has room for"),b(r.innerText.trim().endsWith(`+${t.length-n} more`),!0,"and counts the rest")})()),C("a name the plot shortened is given back whole, however long",()=>tc(function*(){let e="x".repeat(2e3),t=JSON.parse(td([{column:"curve",series:[e]}])),n=(0,ts._i)(t);b(n.length,1,"a column holding one curve is named once"),b((0,ts.D5)(n).innerText.includes(e),!0,"hovering that one row is what says the whole of a name")})()),C("names that long are labels once the hover lists several",()=>tc(function*(){let e="x".repeat(2e3),t=JSON.parse(td([{column:"curve",series:[`${e} a`,`${e} b`,`${e} c`]}])),n=(0,ts.D5)((0,ts._i)(t));b(n.innerText.includes(e),!1,"a list of cells of JSON should not be spelled out"),b(n.innerText.includes("…"),!0,"each row should say it was shortened")})()),C("more curves than fit are counted instead of stacked",()=>tc(function*(){let e=Array.from({length:40},(e,t)=>`series ${t}`),t=eU(td([{column:"curve",series:e}]),"legendOverflow",500,400),n=t.find(e=>e.startsWith("+")&&e.endsWith("more"));b(void 0!==n,!0,"the legend should say how many it left out");let r=t.filter(e=>e.startsWith("series ")).length;b(r>0,!0,"it should still draw the curves that fit"),b(r+parseInt(n.slice(1),10),e.length,"drawn names plus the counted ones should cover every curve")})())}),O("fit cache",()=>{C("a curve fitted in log space is not handed to a linear plot",()=>tp(function*(){let e=th("fitCacheLogSpace"),t=(0,eW.h8)(e).series[0],n=(0,es.zB)(t),r=(0,eW.IY)(t,0,n,{logX:!0,logY:!1},e),o=(0,eW.IY)(t,0,n,{logX:!1,logY:!1},e);b(Array.from(r.parameters).toString()!==Array.from(o.parameters).toString(),!0,`the two spaces should fit differently, both gave ${Array.from(r.parameters)}`),b((0,eW.IY)(t,0,n,{logX:!0,logY:!1},e)===r,!0,"asking twice in the same space should come from the cache")})()),C("a viewer fit is reused, and never confused with another cell",()=>tp(function*(){let e=th("fitCacheRowsOne",-7),t=th("fitCacheRowsOther",-5),n=(0,eW.h8)(e),r=(0,eW.h8)(t);b((0,eW.U6)(n)!==(0,eW.U6)(r),!0,"two cells should not share an identity");let o={logX:!0,logY:!1},i=(0,es.zB)(n.series[0]),l=(0,eW.IY)(n.series[0],0,i,o,void 0,!1,`${(0,eW.U6)(n)} || idx: 0`),a=(0,eW.IY)(r.series[0],0,i,o,void 0,!1,`${(0,eW.U6)(r)} || idx: 0`);b(l===a,!1,"two different curves must not answer for each other"),b(Array.from(l.parameters).toString()!==Array.from(a.parameters).toString(),!0,"and they fit differently, so a collision would be visible"),b((0,eW.IY)(n.series[0],0,i,o,void 0,!1,`${(0,eW.U6)(n)} || idx: 0`)===l,!0,"the same curve should be fitted once")})()),C("the viewer cache is kept apart from the grid one, and agrees with it",()=>tp(function*(){let e=th("fitCacheApart"),t=(0,eW.h8)(e),n=t.series[0],r=(0,es.zB)(n),o={logX:!0,logY:!1},i=(0,eW.IY)(n,0,r,o,e),l=(0,eW.IY)(n,0,r,o,e,!0,`${(0,eW.U6)(t)} || idx: 0`);b(i===l,!1,"the two caches must not share storage"),b(Array.from(i.parameters).toString(),Array.from(l.parameters).toString(),"but keeping them apart must not change the answer")})()),C("a render that names its curves fits them once",()=>tp(function*(){let e=JSON.parse(e0([-7,-5])),t=U.canvas(300,200).getContext("2d"),n=new l.Rect(0,0,300,200),r=["probeCell || idx: 0","probeCell || idx: 1"];new Q.l().renderCurves(t,n,e,void 0,r);let o=eW.d3.K.filter(Boolean);b(r.every(e=>o.some(t=>t.startsWith(e))),!0,`the render should have cached a fit per identity, holds ${o.length}`);let i=!1,a=e.chartOptions;eW.d3.getOrCreate(`${r[0]} || logX: ${null==a?void 0:a.logX} || logY: ${null==a?void 0:a.logY}`,()=>(i=!0,null)),b(i,!1,"a second render of the same curve should not fit it again")})()),C("a pipe in a title survives, and one that breaks the value is still stripped",()=>tp(function*(){let e=JSON.parse(eK(-6.5));e.chartOptions.title="compound 10 | Collapse Assay | run 4";let t=l.Column.fromStrings("curve",[JSON.stringify(e),'{"series":|[{"points":[]}]}']);t.semType=R.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);n.name="pipeTitles",b((0,eW.h8)(n.cell(0,"curve")).chartOptions.title,"compound 10 | Collapse Assay | run 4","a pipe inside a title is not part of the value"),b((0,eW.h8)(n.cell(1,"curve")).series.length,1,"stripping should still rescue a value that does not parse as it stands")})()),C("editing a cell retires the fits made from it",()=>tp(function*(){let e=th("fitCacheEdit",-7),t=(0,eW.h8)(e),n=(0,es.zB)(t.series[0]),r={logX:!0,logY:!1},o=(0,eW.IY)(t.series[0],0,n,r,void 0,!1,`${(0,eW.U6)(t)} || idx: 0`);e.column.set(0,eK(-5));let i=(0,eW.h8)(e);b((0,eW.U6)(i)!==(0,eW.U6)(t),!0,"a re-parsed cell should get a new identity"),b(Array.from((0,eW.IY)(i.series[0],0,n,r,void 0,!1,`${(0,eW.U6)(i)} || idx: 0`).parameters).toString()!==Array.from(o.parameters).toString(),!0,"so the edited curve is fitted afresh")})())});let ty="curves-demo.csv",tx="multiple styled series";function tC(e){return tv(function*(){let t;e?(yield l.Func.find({name:"OpenFile"})[0].prepare({fullPath:`System:AppData/Curves/${ty}`}).call(void 0,void 0,{processed:!1}),t=M.shell.tv,yield M.data.detectSemanticTypes(t.dataFrame)):t=yield tv(function*(){let e=yield M.dapi.files.readCsv(`System:AppData/Curves/${ty}`);return e.name=ty.replace(".csv",""),yield M.data.detectSemanticTypes(e),M.shell.addTableView(e)})(),yield E(100);var n,r=t;if(null===r.dataFrame.col(tx))throw Error(`no ${tx} column - the table has: ${r.dataFrame.columns.names().join(", ")}`);(0,e7.FC)(r.grid.cell(tx,0),{property:{name:"showCurveConfidenceInterval"},value:!1},"seriesOptions","Column"),yield E(10),yield(n=t,tv(function*(){let t=l.Project.create();t.name="Curves test project";let r=n.dataFrame.getTableInfo();e&&(r.tags[l.Tags.DataSync]="sync",r.tags[l.Tags.CreationScript]=n.dataFrame.getTag(l.Tags.CreationScript));let o=n.saveLayout();t.addChild(r),t.addChild(o),yield M.dapi.tables.uploadDataFrame(n.dataFrame),yield M.dapi.tables.save(r),yield M.dapi.views.save(o),yield M.dapi.projects.save(t);let i=t.id;yield E(500),M.shell.closeAll(),yield E(500);let a=yield M.dapi.projects.find(i);yield a.open()})()),yield E(10),yield tv(function*(){yield A(()=>{var e,t;return(null==(t=M.shell.tv)||null==(e=t.dataFrame)?void 0:e.col(tx))!=null},`${tx} is missing from the reopened project`,3e4)})(),yield A(()=>{var e;return(null==(e=(0,eW.bc)(M.shell.tv.dataFrame.col(tx)).seriesOptions)?void 0:e.showCurveConfidenceInterval)===!1},"the column tag did not come back with the project",3e4);let o=M.shell.tv.dataFrame;b((0,eW.h8)(o.cell(0,tx)).series[0].showCurveConfidenceInterval,!1,"the column-level option did not outrank the data after reopening")})()}function tb(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function tw(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){tb(i,r,o,l,a,"next",e)}function a(e){tb(i,r,o,l,a,"throw",e)}l(void 0)})}}O("projects",()=>{C("column-level option survives a project",()=>tv(function*(){yield tC(),yield E(100)})(),{timeout:12e4}),C("painting a table leaves its dataframe tags alone, so its layout saves",()=>tv(function*(){let e=yield M.dapi.files.readCsv(`System:AppData/Curves/${ty}`);e.name="curvesPaintedLayout",e.setTag(R.h.TAG_FIT_LEGACY,JSON.stringify((0,es.Kh)())),yield M.data.detectSemanticTypes(e);let t=M.shell.addTableView(e),n=null;try{for(let t of e.columns.bySemTypeAll(R.h.FIT_SEM_TYPE))(0,eW.h8)(e.cell(0,t.name),!1);yield E(500),b(null==e.getTag(R.h.TAG_FIT),!0,"reading the options tagged the dataframe"),n=yield M.dapi.layouts.save(t.saveLayout())}finally{n&&(yield M.dapi.layouts.delete(n)),t.close()}})(),{timeout:6e4}),C("column-level option survives a datasync project",()=>tv(function*(){yield tC(!0),yield E(100)})(),{timeout:12e4})});let tT=new l.Package;function tO(e,t,n){return tw(function*(){let r=yield P({category:e,test:t,testContext:n});return l.DataFrame.fromObjects(r)})()}function tS(){return tw(function*(){})()}})(),curves_test=r})();
177
+ </GraphPadPrismFile>`;E("PZFX Parser",()=>{P("parsePzfxXml: parses XY table",()=>ez(function*(){let e=(0,eJ.rn)(eZ);_(e.length,1),_(e[0].tableType,"XY"),_(e[0].title,"Test Dose Response"),_(e[0].xValues.length,5),_(e[0].yColumns.length,2),_(e[0].yColumns[0].title,"Compound X"),_(e[0].yColumns[0].subcolumns.length,2),_(e[0].yColumns[1].title,"Compound Y"),_(e[0].yColumns[1].subcolumns.length,1)})()),P("parsePzfxXml: parses multiple tables",()=>ez(function*(){let e=(0,eJ.rn)(eK);_(e.length,2),_(e[0].tableType,"XY"),_(e[1].tableType,"OneWay"),_(e[1].title,"Column Data")})()),P("parsePzfxXml: handles excluded and missing data",()=>ez(function*(){let e=(0,eJ.rn)(eQ)[0].yColumns[0].subcolumns[0];_(e.values[0],10),_(e.excluded[1],!0),_(e.values[3],null),_(e.excluded[0],!1)})()),P("parsePzfxXml: handles trailing binary data",()=>ez(function*(){_((0,eJ.rn)(eZ+"\0\x01\x02binary garbage").length,1)})()),P("parsePzfxXml: returns empty for malformed XML",()=>ez(function*(){_((0,eJ.rn)("<not valid xml").length,0)})()),P("pzfxTableToFitChartData: converts XY table",()=>ez(function*(){let e=(0,eJ.rn)(eZ),t=(0,eJ.fM)(e[0]);_(null!==t,!0),_(t.series.length,2),_(t.series[0].name,"Compound X"),_(t.series[0].points.length,10),_(t.series[1].points.length,5),_(t.chartOptions.logX,!0)})()),P("pzfxTableToFitChartData: returns null for non-XY",()=>ez(function*(){let e=(0,eJ.rn)(eK);_((0,eJ.fM)(e[1]),null)})()),P("pzfxTableToFitChartData: maps outliers",()=>ez(function*(){let e=(0,eJ.rn)(eQ),t=(0,eJ.fM)(e[0]);_(null!==t,!0),_(t.series[0].points.length,3),_(t.series[0].points.find(e=>2===e.x).outlier,!0)})()),P("pzfxToFitDataFrame: creates fit DataFrame",()=>ez(function*(){let e=(0,eJ.rn)(eZ),t=(0,eJ.aI)(e);_(t.rowCount,1),_(null!==t.col("Fitted Curve"),!0),_(t.col("Fitted Curve").semType,"fit")})()),P("pzfxTableToDataFrame: creates plain DataFrame",()=>ez(function*(){let e=(0,eJ.rn)(eK),t=(0,eJ.b6)(e[1]);_(t.rowCount,3),_(null!==t.col("Group A"),!0)})())});var e0=n(434),e1=n(476),e9=n(53);function e5(e,t,n=400,r=300){let o=l.Column.fromStrings("curve",[e]);o.semType=$.h.FIT_SEM_TYPE;let i=l.DataFrame.fromColumns([o]);return i.name=t,e2((0,e9.h8)(i.cell(0,"curve")),n,r)}function e2(e,t=400,n=300){let r=[],o=eo.canvas(t,n).getContext("2d"),i=o.fillText.bind(o);o.fillText=(e,t,n)=>{r.push({text:e,x:t,y:n}),i(e,t,n)};let a=new l.Rect(0,0,t,n);new es.l().renderCurves(o,a,e);let s=(0,eh.lc)(a,e),u=(0,eh.Tv)(a,s.x,s.y,(0,eh.ij)(a,e))[0];return{rows:r,data:e,dataBox:u}}function e6(e,t,n=400,r=300){return e5(e,t,n,r).rows.map(e=>e.text)}let e4=[1e-9,3e-9,1e-8,3e-8,1e-7,3e-7,1e-6,3e-6,1e-5,3e-5,1e-4];function e3(e){return e4.map(t=>({x:t,y:5+95/(1+Math.pow(10,Math.log10(t)-e))}))}function e8(e){return JSON.stringify({chartOptions:{logX:!0},series:[{fitFunction:"sigmoid",name:"series",points:e3(e)}]})}function e7(){return JSON.stringify({chartOptions:{logX:!0},series:[{fitFunction:"sigmoid",name:"series",showCurveConfidenceInterval:!0,points:e3(-6.5)}]})}function te(e){return JSON.stringify({chartOptions:{logX:!0},series:e.map((e,t)=>({fitFunction:"sigmoid",name:`series ${t}`,points:e3(e)}))})}function tt(){return JSON.stringify({chartOptions:{logX:!0,labels:{"Z prime":.72},showLabels:["Z prime","compound"]},series:[{fitFunction:"sigmoid",name:"s0",labels:{compound:"GRK-1"},points:e3(-6.5)},{fitFunction:"sigmoid",name:"s1",labels:{compound:"GRK-2"},points:e3(-5.5)}]})}var tn=n(181);function tr(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function to(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){tr(i,r,o,l,a,"next",e)}function a(e){tr(i,r,o,l,a,"throw",e)}l(void 0)})}}function ti(e){let t=JSON.parse(e8(e));return delete t.chartOptions,JSON.stringify(t)}function tl(e,t){let n=l.Column.fromStrings("curve",t.map(e8));n.semType=$.h.FIT_SEM_TYPE;let r=l.DataFrame.fromColumns([n]);return r.name=e,r}function ta(e,t,n){return to(function*(){yield l.Func.find({name:t})[0].prepare(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}({table:e,curveColumn:e.col("curve")},n)).call(!1,void 0,{processed:!1})})()}function ts(e){let t=[];for(let r=0;r<e.columns.length;r++){var n;let o=null==(n=e.columns.byIndex(r))?void 0:n.name;o&&t.push(o)}return t}E("calculated columns",()=>{P("the statistic column is added right after the curve column",()=>to(function*(){let e=tl("calcColPosition",[-6.5]);e.columns.addNewString("trailing").set(0,"x");let t=l.Viewer.grid(e).cell("curve",0);yield(0,tn.g)(t,"curveStatistic",{propName:"ic50",seriesNumber:0}),N(e.columns.names(),["curve","curve 1 ic50","trailing"]),N(ts(t.grid),["curve","curve 1 ic50","trailing"])})()),P("placing the statistic column keeps a manually reordered grid",()=>to(function*(){let e=tl("calcColGridOrder",[-6.5]);e.columns.addNewString("a").set(0,"x"),e.columns.addNewString("b").set(0,"y");let t=l.Viewer.grid(e);t.columns.setOrder(["b","curve","a"]),yield(0,tn.g)(t.cell("curve",0),"curveStatistic",{propName:"ic50",seriesNumber:0}),N(ts(t),["b","curve","curve 1 ic50","a"]),N(e.columns.names(),["curve","curve 1 ic50","a","b"])})()),P("plot-level labels combine across levels instead of the nearest one winning",()=>to(function*(){let e=JSON.stringify({chartOptions:{logX:!0,labels:{"Z prime":.72}},series:[{fitFunction:"sigmoid",name:"s",points:e4.map(e=>({x:e,y:e}))}]}),t=l.Column.fromStrings("curve",[e]);t.semType=$.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);n.name="calcColLabels",t.setTag($.h.TAG_FIT,JSON.stringify({chartOptions:{labels:{assay:"GPCR","Z prime":.1}}}));let r=(0,e9.h8)(n.cell(0,"curve")).chartOptions.labels;_(r.assay,"GPCR","the column-level label did not reach the plot"),A(r["Z prime"],.72,.001)})()),P("curveStatistic adds a calculated column",()=>to(function*(){let e=tl("calcColAdd",[-6.5,-6.5]);yield ta(e,"curveStatistic",{propName:"ic50",seriesNumber:0});let t=e.col("curve 1 ic50");_(null!==t),_(t.type,l.COLUMN_TYPE.FLOAT),A(Math.log10(t.get(0)),-6.5,.15),_(t.getTag(l.TAGS.FORMULA).includes("Curves:curveStatistic")),_(t.getTag(l.TAGS.FORMULA).includes("${curve}")),_(t.getTag(".%formula-column-is-vector-func"),"true")})()),P("recalculates when the source curve changes",()=>to(function*(){let e=tl("calcColRecalc",[-6.5,-6.5]);yield ta(e,"curveStatistic",{propName:"ic50",seriesNumber:0});let t=e.col("curve 1 ic50").get(1);e.col("curve").set(1,e8(-5),!0),yield X(()=>e.col("curve 1 ic50").get(1)!==t,"statistic column did not recalculate after the source curve changed",5e3),A(Math.log10(e.col("curve 1 ic50").get(1)),-5,.3),_(e.col("curve 1 ic50").get(0),t,"untouched row must not be recalculated")})()),P("legacy statistic names still resolve",()=>to(function*(){let e=tl("calcColLegacy",[-6.5]);yield ta(e,"curveStatistic",{propName:"interceptX",seriesNumber:0});let t=e.col("curve 1 interceptX");_(null!==t),A(Math.log10(t.get(0)),-6.5,.15)})()),P("curveAggrStatistic aggregates across series",()=>to(function*(){let e=tl("calcColAggr",[-6.5,-5.5]);yield ta(e,"curveAggrStatistic",{propName:"ic50",aggrType:"med"});let t=e.col("curve med ic50");_(null!==t),A(Math.log10(t.get(0)),-6.5,.15),A(Math.log10(t.get(1)),-5.5,.15)})()),P("averaging IC50 across series is a geometric mean",()=>to(function*(){let e=JSON.parse(te([-7,-5]));A(Math.log10((0,e0.JR)(e,"avg").ic50),-6,.1)})()),P("mixed fit functions only aggregate statistics common to all series",()=>to(function*(){let e=JSON.parse(te([-7,-5]));e.series[1].fitFunction="linear";let t=(0,e0.Uc)(e).map(e=>e.name);_(t.includes("ic50"),!1,"ic50 is not viable across a sigmoid and a linear fit"),_(t.includes("rSquared"),!0),_(void 0===(0,e0.JR)(e,"avg").ic50,!0,"ic50 must not be aggregated over a subset")})()),P("repeated calculation does not re-log stored parameters",()=>to(function*(){let e=JSON.parse(e8(-6.5)).series[0];e.parameters=[100,1,100,5];let t={logX:!0,logY:!1},n=(0,ex.h5)((0,e0.TV)(e,0,t,void 0,!1),"ic50");_(n,(0,ex.h5)((0,e0.TV)(e,0,t,void 0,!1),"ic50"),"stored parameters drifted between calls"),A(n,100,1)})()),P("fitting a series does not write fit-space parameters back onto it",()=>to(function*(){let e=JSON.parse(te([2])).series[0],t={logX:!0,logY:!1},n=(0,ex.h5)((0,e0.TV)(e,0,t,void 0,!1),"ic50");_(void 0===e.parameters,!0,"the series must keep its data-space contract"),_(n,(0,ex.h5)((0,e0.TV)(e,0,t,void 0,!1),"ic50"),"the reported IC50 drifted between calls")})()),P("recalculation applies column-level chart options",()=>to(function*(){let e=l.Column.fromStrings("curve",[ti(-6.5),ti(-6.5)]);e.semType=$.h.FIT_SEM_TYPE,e.setTag($.h.TAG_FIT,JSON.stringify({chartOptions:{logX:!0}}));let t=l.DataFrame.fromColumns([e]);t.name="calcColColumnOptions",yield ta(t,"curveStatistic",{propName:"ic50",seriesNumber:0});let n=t.col("curve 1 ic50").get(1);t.col("curve").set(1,ti(-5),!0),yield X(()=>t.col("curve 1 ic50").get(1)!==n,"statistic column did not recalculate",5e3),A(Math.log10(t.col("curve 1 ic50").get(1)),-5,.3)})()),P("log-space statistics are not offered for aggregations we do not convert",()=>to(function*(){let e=JSON.parse(te([-7,-5])),t=(0,e0.Uc)(e,"count").map(e=>e.name);_(t.includes("pIC50"),!1,"pIC50 is only derived in data space"),_(t.includes("rSquared"),!0,"space-independent statistics stay"),_(t.includes("ic50"),!0,"ic50 must stay available for aggregations we do not convert"),A((0,e0.JR)(e,"avg").ic50,1e-6,1e-7),A((0,e0.JR)(e,"count").ic50,2,.001),A((0,e0.JR)(e,"count").interceptX,2,.001)})()),P("stored parameters round-trip through fit space on both axes",()=>to(function*(){for(let e of[{logX:!1,logY:!1},{logX:!0,logY:!1},{logX:!1,logY:!0},{logX:!0,logY:!0}]){let t=JSON.parse(e8(-6.5)).series[0];t.parameters=[100,1,1e-6,5];let n=(0,e0.TV)(t,0,e,void 0,!1);A((0,ex.h5)(n,"top"),100,1e-6,`top under ${JSON.stringify(e)}`),A((0,ex.h5)(n,"bottom"),5,1e-6,`bottom under ${JSON.stringify(e)}`),A((0,ex.h5)(n,"ic50"),1e-6,1e-12,`ic50 under ${JSON.stringify(e)}`)}})()),P("a detached column strips the stray pipe like the initial parse does",()=>to(function*(){let e=l.Column.fromStrings("curve",[e8(-6.5).replace("{","{|")]);e.semType=$.h.FIT_SEM_TYPE,_(null===e.dataFrame||void 0===e.dataFrame,!0,"the column must be detached");let t=(0,e0.bW)(e,0,"ic50",0);_(null!==t,!0,"a pipe in the cell value blanked the row"),A(Math.log10(t),-6.5,.3)})()),P("a legacy statistic reads the same per series and aggregated",()=>to(function*(){let e=JSON.parse(te([-6.5]));e.series[0].fitFunction="linear";let t=(0,ex.h5)((0,e0.TV)(e.series[0],0,{logX:!0,logY:!1},void 0,!1),"top"),n=(0,e0.JR)(e,"med").top;_(void 0!==t,!0,"the per-series path lost the fallback"),_(void 0!==n,!0,"the aggregated path drops a statistic the per-series one reports")})()),P("a legacy name and its canonical field agree after aggregation",()=>to(function*(){let e=JSON.parse(te([-7,-5])),t=(0,e0.JR)(e,"avg");_(t.interceptX,t.ic50,"interceptX must be reported in the same space as ic50"),A(Math.log10(t.interceptX),-6,.1)})()),P("mergeSeries does not change a statistic",()=>to(function*(){let e=JSON.parse(te([-7,-5])),t=JSON.parse(te([-7,-5]));t.chartOptions.mergeSeries=!0;let n={logX:!0,logY:!1};for(let r of[0,1])_((0,ex.h5)((0,e0.TV)(e.series[r],r,n,void 0,!1),"ic50"),(0,ex.h5)((0,e0.TV)(t.series[r],r,n,void 0,!1),"ic50"),`series ${r} changed when mergeSeries was set`);_((0,e0.JR)(t,"med").ic50,(0,e0.JR)(e,"med").ic50)})()),P("outlier toggle refreshes statistic columns named by the new API",()=>to(function*(){let e=tl("calcColOutlierToggle",[-6.5]),t=l.Column.float("ic50 col",e.rowCount);t.tags[".sourceColumn"]="curve",t.tags[".seriesNumber"]="0",t.tags[".statistics"]="ic50",t.init(()=>1e-6),e.columns.add(t);let n=l.Viewer.grid(e).cell("curve",0),r=(0,e9.h8)(n.cell,!0);(0,e1.Fw)(n,r.series[0].points[0],0,0,r);let o=e.col("ic50 col").get(0);_(null!=o&&!isNaN(o),!0,"outlier toggle blanked the ic50 column"),A(Math.log10(o),-6.5,.3)})())});var tu=n(258);function tc(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function td(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){tc(i,r,o,l,a,"next",e)}function a(e){tc(i,r,o,l,a,"throw",e)}l(void 0)})}}function tf(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 tm(e,t,n){var r,o;let i=JSON.stringify((r=tf({},t?{chartOptions:tf({logX:!0},n?{showStatistics:n}:{})}:{}),o=o={series:[{fitFunction:"sigmoid",name:"series",points:e3(-6.5)}]},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r)),a=l.Column.fromStrings("curve",[i,i]);a.semType=$.h.FIT_SEM_TYPE;let s=l.DataFrame.fromColumns([a]);return s.name=e,s}function tp(e,t){return td(function*(){yield l.Func.find({package:"Curves",name:"curveStatistic"})[0].prepare(tf({table:e,curveColumn:e.col("curve")},t)).call(!1,void 0,{processed:!1})})()}function th(e,t){let n=[],r=e.onValuesChanged.subscribe(e=>{var t,r,o;return n.push(null!=(t=null==e||null==(o=e.args)||null==(r=o.column)?void 0:r.name)?t:"")});try{t()}finally{r.unsubscribe()}return n}function tg(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function tv(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){tg(i,r,o,l,a,"next",e)}function a(e){tg(i,r,o,l,a,"throw",e)}l(void 0)})}}function ty(e){let t=l.Column.fromStrings("curve",[te([-7,-5]),te([-6,-4])]);t.semType=$.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);return n.name=e,n}function tx(e,t){return tv(function*(){let n=yield e.dataFrame.plot.fromType("MultiCurveViewer",{curvesColumnNames:t});return e.dockManager.dock(n,l.DOCK_TYPE.FILL,null,"Curves"),yield X(()=>n.root.clientWidth>0&&n.canvas.width===n.root.clientWidth&&n.canvas.height===n.root.clientHeight,"the multi curve viewer did not take the size of its panel"),yield Y(n),n})()}E("panel and renderer",()=>{P("every registered aggregation input offers only convertible aggregations",()=>td(function*(){let e=["min","max","avg","med","q1","q2","q3"],t=[];for(let n of l.Func.find({package:"Curves"}))for(let r of n.inputs.filter(e=>/^(aggrType|aggregation)$/.test(e.name)))for(let o of(t.push(n.name),_(void 0!==r.choices&&null!==r.choices,!0,`${n.name} takes a free-text aggregation`),r.choices))_(e.includes(o),!0,`${n.name} offers ${o}`);_(t.length>=3,!0,`expected every aggregation function to be checked, saw ${t}`)})()),P("rendering does not mutate the cached series parameters",()=>td(function*(){let e={chartOptions:{logX:!0},series:[{fitFunction:"sigmoid",name:"series",parameters:[100,1,100,5],points:e3(-6.5)}]},t=[...e.series[0].parameters],n=eo.canvas(200,120).getContext("2d"),r=new es.l,o=es.l.inflateScreenBounds(new l.Rect(0,0,200,120));r.renderCurves(n,o,e),r.renderCurves(n,o,e),N(e.series[0].parameters,t)})()),P("firing values-changed on a curve column recalculates its statistic columns",()=>td(function*(){let e=tm("panelColumnOption",!1),t=e.col("curve");t.setTag($.h.TAG_FIT,JSON.stringify({chartOptions:{logX:!0}})),yield tp(e,{propName:"ic50",seriesNumber:0});let n=e.col("curve 1 ic50").get(0);A(Math.log10(n),-6.5,.3),t.setTag($.h.TAG_FIT,JSON.stringify({chartOptions:{logX:!1}})),t.fireValuesChanged(),yield X(()=>e.col("curve 1 ic50").get(0)!==n,"statistic column did not recalculate after the column-level option changed",5e3)})()),P("clearing a cell-level override does not recalculate on its own",()=>td(function*(){let e=JSON.stringify({chartOptions:{logX:!0},series:[{fitFunction:"sigmoid",name:"series",pointColor:"#ff0000",points:e3(-6.5)}]}),t=l.Column.fromStrings("curve",[e,e]);t.semType=$.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);n.name="panelNoRecalcOnCosmetic",yield tp(n,{propName:"ic50",seriesNumber:0}),_(th(n,()=>{for(let e=0;e<t.length;e++){let n=JSON.parse(t.get(e));delete n.series[0].pointColor,t.set(e,JSON.stringify(n),!1)}}).includes("curve"),!1,"a cosmetic rewrite recalculates the statistic column")})()),P("a column-level option overrides a cell-level one, without recalculating",()=>td(function*(){let e=JSON.stringify({chartOptions:{logX:!0},series:[{fitFunction:"sigmoid",name:"series",pointColor:"#ff0000",points:e3(-6.5)}]}),t=l.Column.fromStrings("curve",[e,e]);t.semType=$.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);n.name="panelColumnOverridesCell",yield tp(n,{propName:"ic50",seriesNumber:0});let r=l.Viewer.grid(n).cell("curve",0),o={property:{name:"pointColor"},value:"#00ff00"},i=th(n,()=>(0,tu.FC)(r,o,"seriesOptions","Column"));_("#ff0000"===(0,e9.h8)(n.cell(0,"curve")).series[0].pointColor,!1,"the cell-level value still wins after the column-level change"),_(i.includes("curve"),!1,"a cosmetic option change recalculates the statistic column")})()),P("clearing cell overrides marks the table changed without recalculating",()=>td(function*(){let e=l.Column.fromStrings("curve",[e7(),e7()]);e.semType=$.h.FIT_SEM_TYPE;let t=l.DataFrame.fromColumns([e]);t.name="panelMarksTableChanged",yield tp(t,{propName:"ic50",seriesNumber:0});let n=l.Viewer.grid(t).cell("curve",0),r=th(t,()=>(0,tu.FC)(n,{property:{name:"showCurveConfidenceInterval"},value:!1},"seriesOptions","Column"));_(JSON.parse(e.get(0)).series[0].showCurveConfidenceInterval,!0,"the cell data was mutated"),_((0,e9.h8)(t.cell(0,"curve")).series[0].showCurveConfidenceInterval,!1,"the column-level value did not outrank the value declared in the cell"),_(r.length>0,!0,"nothing marked the table changed, so the option would not be saved"),_(r.includes("curve"),!1,"a cosmetic option change recalculates the statistic column")})()),P("a column-level change overrides a value set at cell level first",()=>td(function*(){let e=tm("panelCellThenColumn",!0),t=l.Viewer.grid(e).cell("curve",0),n=e=>({property:{name:"connectDots"},value:e});(0,tu.FC)(t,n(!0),"seriesOptions","Cell"),_(JSON.parse(e.col("curve").get(0)).series[0].connectDots,!0,"cell-level write failed"),_(JSON.parse(e.col("curve").get(0)).explicit.seriesOptions.includes("connectDots"),!0,"a cell-level change did not claim the property"),(0,tu.FC)(t,n(!1),"seriesOptions","Column"),_(JSON.parse(e.col("curve").get(0)).explicit.seriesOptions.includes("connectDots"),!1,"the cell-level claim survived a column-level change"),_((0,e9.h8)(e.cell(0,"curve")).series[0].connectDots,!1,"the column-level value did not reach the cell")})()),P("a column-level option outranks a value the fresh data declares",()=>td(function*(){let e=l.Column.fromStrings("curve",[e7(),e7()]);e.semType=$.h.FIT_SEM_TYPE;let t=l.DataFrame.fromColumns([e]);t.name="panelFreshDataClaim",e.setTag($.h.TAG_FIT,JSON.stringify({seriesOptions:{showCurveConfidenceInterval:!1},explicit:{seriesOptions:["showCurveConfidenceInterval"]}})),_((0,e9.h8)(t.cell(0,"curve")).series[0].showCurveConfidenceInterval,!1,"the restored column-level option lost to the value the cell declares"),e.setTag($.h.TAG_FIT,JSON.stringify({seriesOptions:{showCurveConfidenceInterval:!1}})),_((0,e9.h8)(t.cell(1,"curve")).series[0].showCurveConfidenceInterval,!0,"an option nobody set explicitly overrode the data")})()),P("a column-level option survives a layout applied to a fresh table",()=>td(function*(){let e=e=>{let t=l.Column.fromStrings("curve",[e7(),e7()]);t.semType=$.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);return n.name=e,n},t=e("layoutSource"),n=V.shell.addTableView(t),r=e("layoutTarget"),o=V.shell.addTableView(r);try{var i;_((0,e9.h8)(r.cell(0,"curve")).series[0].showCurveConfidenceInterval,!0,"the fresh table should start with the value its data declares"),(0,tu.FC)(n.grid.cell("curve",0),{property:{name:"showCurveConfidenceInterval"},value:!1},"seriesOptions","Column"),(0,tu.FC)(n.grid.cell("curve",0),{property:{name:"statisticsMode"},value:"both"},"chartOptions","Column");let e=n.saveLayout();o.loadLayout(e),_((0,e9.h8)(r.cell(0,"curve")).series[0].showCurveConfidenceInterval,!1,"the column-level option did not survive the layout"),_(null==(i=(0,e9.h8)(r.cell(0,"curve")).chartOptions)?void 0:i.statisticsMode,"both","a chart option did not survive the layout")}finally{n.close(),o.close()}})()),P("options stored under the legacy tag are read, and move onto the layout-carried one when written",()=>td(function*(){_($.h.TAG_FIT.startsWith(".%"),!0,"the fit tag is no longer carried by layouts");let e=tm("panelLegacyTag",!1),t=e.col("curve");t.setTag($.h.TAG_FIT_LEGACY,JSON.stringify({chartOptions:{logX:!0}})),_((0,e9.bc)(t).chartOptions.logX,!0,"options under the legacy tag were ignored"),_(null==t.getTag($.h.TAG_FIT),!0,"reading the options wrote a tag"),(0,tu.FC)(l.Viewer.grid(e).cell("curve",0),{property:{name:"showCurveConfidenceInterval"},value:!1},"seriesOptions","Column");let n=JSON.parse(t.getTag($.h.TAG_FIT));_(n.chartOptions.logX,!0,"the legacy options were lost when the column was written"),_(n.seriesOptions.showCurveConfidenceInterval,!1,"the change was not stored"),_(null==t.getTag($.h.TAG_FIT_LEGACY),!0,"both tags now hold the options")})()),P("the panel offers the label names the cell carries",()=>td(function*(){let e=JSON.parse(tt());N((0,tu.di)(e).find(e=>"showLabels"===e.name).choices,["Z prime","compound"])})()),P("a plot-level label is drawn once, a per-curve one per curve",()=>td(function*(){let e=e6(tt(),"panelLabels");_(e.filter(e=>e.startsWith("Z prime")).length,1,"the plot-level label was not drawn once"),_(e.filter(e=>e.startsWith("compound")).length,2,"each curve should carry its own label"),_(e.includes("compound: GRK-1"),!0),_(e.includes("compound: GRK-2"),!0)})()),P("only the labels named in showLabels are drawn",()=>td(function*(){let e=JSON.parse(tt());e.chartOptions.showLabels=["compound"];let t=e6(JSON.stringify(e),"panelLabelsFiltered");_(t.some(e=>e.startsWith("Z prime")),!1,"a label not named in showLabels was drawn"),_(t.filter(e=>e.startsWith("compound")).length,2)})()),P("an error bar starts at the marker edge and hides when the marker covers it",()=>td(function*(){let e=(0,ew.a)(100,70,130,2);_(null!==e,!0,"a deviation larger than the marker should be drawn"),N(e.top,[70,98]),N(e.bottom,[102,130]),_(null===(0,ew.a)(100,70,130,40),!0,"a deviation smaller than the marker must not be drawn inside it"),_(null===(0,ew.a)(100,80,120,20),!0),_(null!==(0,ew.a)(100,79,121,20),!0)})()),P("one list of statistics, and the mode decides where it is drawn",()=>td(function*(){let e=JSON.parse(te([-7,-5]));e.chartOptions.showStatistics=["ic50"],e.chartOptions.statisticsMode="both",e.chartOptions.aggrType="med";let t=e6(JSON.stringify(e),"panelAggrBoth"),n=t.find(e=>e.startsWith("med ic50"));_(void 0!==n,!0,"the aggregated statistic was not drawn"),_(t.filter(e=>e.startsWith("med ic50")).length,1,"it describes the cell, so it is drawn once"),_(t.filter(e=>e.startsWith("IC50")).length,2,"each curve should still show its own"),_(n.includes("1.0")||n.includes("1e-6")||n.includes("9.9"),!0,`unexpected value: ${n}`),e.chartOptions.statisticsMode="aggregated";let r=e6(JSON.stringify(e),"panelAggrOnly");_(r.filter(e=>e.startsWith("med ic50")).length,1),_(r.some(e=>e.startsWith("IC50")),!1,"the per-series values should give way to the summary"),e.chartOptions.statisticsMode="series";let o=e6(JSON.stringify(e),"panelAggrSeries");_(o.some(e=>e.startsWith("med ")),!1,"nothing should be summarised in series mode"),_(o.filter(e=>e.startsWith("IC50")).length,2)})()),P("a single-series cell has nothing to aggregate",()=>td(function*(){let e=JSON.parse(te([-6.5]));e.chartOptions.showStatistics=["ic50"],e.chartOptions.statisticsMode="aggregated";let t=e6(JSON.stringify(e),"panelAggrSingle");_(t.some(e=>e.startsWith("med ")),!1,"with one curve the aggregate is that curve, so it should not be drawn"),_(t.some(e=>e.startsWith("IC50")),!0,"the single curve should still show its own");let n=e=>(0,tu.di)(JSON.parse(te(e))).map(e=>e.name);_(n([-6.5]).some(e=>"statisticsMode"===e||"aggrType"===e),!1,"the Options pane of a one-curve cell should offer no summary"),_(n([-7,-5]).includes("statisticsMode")&&n([-7,-5]).includes("aggrType"),!0,"the one of a two-curve cell should")})()),P("a click on a second curve cell right after the first makes that one current",()=>td(function*(){let e=V.shell.addTableView(tm("panelSecondClick",!0));try{let t=new es.l;t.onClick(e.grid.cell("curve",0),new MouseEvent("click")),t.onClick(e.grid.cell("curve",1),new MouseEvent("click"));let n=V.shell.o;_(n instanceof l.GridCell&&1===n.gridRow,!0,`the second cell should be current, not ${n}`)}finally{e.close()}})()),P("the panel offers droplines only for a fit that has asymptotes",()=>td(function*(){let e=e=>(0,tu.s9)(JSON.parse(e),null).map(e=>e.name);_(e(e8(-6.5)).includes("droplines"),!0,"a sigmoid levels off at both ends");let t=JSON.parse(e8(-6.5));t.series[0].fitFunction="linear",_(e(JSON.stringify(t)).includes("droplines"),!1,"a line has no asymptotes, so an ICxx would never be drawn"),_(e(JSON.stringify(t)).includes("markerType"),!0),_(e(e8(-6.5)).includes("columnName"),!1,"the column a series came from is not a setting")})()),P("a custom fit function is offered once, everywhere, and never an empty one",()=>td(function*(){let e={name:"TestCustomFit",function:"(params, x) => params[0] * x",getInitialParameters:"(x, y) => new Float32Array([1])",parameterNames:["Slope"]},t=JSON.parse(e8(-6.5));t.series[0].fitFunction=e;try{(0,ev.zB)(t.series[0]);let n=(0,tu.s9)(t,e).find(e=>"fitFunction"===e.name).choices;_(n.filter(t=>t===e.name).length,1,"a registered function is named once"),_(n.includes(""),!1,"a series is fitted with something, so none is not a choice");let r=(0,tu.s9)(JSON.parse(e8(-6.5)),null).find(e=>"fitFunction"===e.name).choices;_(r.includes(e.name),!0,"and offered wherever a fit function is picked"),_(r.includes(""),!1,"here too")}finally{delete ex.rT[e.name]}})()),P("picking a custom fit function stores the notation, not a name nothing can resolve",()=>td(function*(){let e={name:"TestStoredFit",function:"(params, x) => params[0] * x",getInitialParameters:"(x, y) => new Float32Array([1])",parameterNames:["Slope"]};try{let t=JSON.parse(e8(-6.5));t.series[0].fitFunction=e,(0,ev.zB)(t.series[0]);let n=e8(-6.5),r=l.Column.fromStrings("curve",[n,n]);r.semType=$.h.FIT_SEM_TYPE;let o=l.DataFrame.fromColumns([r]);o.name="customFitNotationStored";let i=l.Viewer.grid(o).cell("curve",0);(0,tu.FC)(i,{property:{name:"fitFunction"},value:e.name},"seriesOptions","Cell");let a=JSON.parse(o.col("curve").get(0)).series[0].fitFunction;_(typeof a,"object","the name alone would not resolve in a session that never loaded it"),_(a.name,e.name),_(!!a.function&&!!a.getInitialParameters,!0,"the notation travels with the curve"),(0,tu.FC)(i,{property:{name:"fitFunction"},value:"linear"},"seriesOptions","Cell"),_(JSON.parse(o.col("curve").get(0)).series[0].fitFunction,"linear","a built-in one is always there, so it stays a name")}finally{delete ex.rT[e.name],delete ex.HM[e.name]}})()),P("statistics are written in the plot font, not the one the caller left",()=>td(function*(){let e=JSON.parse(e8(-6.5));e.chartOptions.showStatistics=["auc","rSquared"];let t=l.Column.fromStrings("curve",[JSON.stringify(e)]);t.semType=$.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);n.name="statisticsFont";let r=e=>{let t=[],r=eo.canvas(400,300).getContext("2d"),o=r.fillText.bind(r);return r.fillText=(e,n,i)=>{e.includes(":")&&t.push(r.font),o(e,n,i)},r.font=e,new es.l().renderCurves(r,new l.Rect(0,0,400,300),(0,e9.h8)(n.cell(0,"curve"))),[...new Set(t)]},o=r("20px Comic Sans MS");_(o.length,1,"every statistic should be written alike"),_(o[0].includes("Comic Sans"),!1,"and not in whatever the caller was using"),_(r('11px Roboto, "Roboto Local"')[0],o[0],"the same font however the canvas reached the renderer")})()),P("several droplines are named, and one off the plot is not drawn",()=>td(function*(){let e=JSON.parse(e8(-6.5));e.series[0].droplines=["IC50","IC90"];let t=e6(JSON.stringify(e),"droplinesBoth");_(t.filter(e=>"IC50"===e).length,1,"each drawn dropline should be named"),_(t.filter(e=>"IC90"===e).length,1),e.series[0].droplines=["IC50"],_(e6(JSON.stringify(e),"droplinesOne").includes("IC50"),!1,"one dropline needs no caption"),e.series[0].droplines=["IC50","IC90"],_(e6(JSON.stringify(e),"droplinesSmall",200,150).includes("IC50"),!1,"captions should give way when the plot is small");let n=JSON.parse(e8(-5));n.series[0].droplines=["IC50","IC99"];let r=e6(JSON.stringify(n),"droplinesOffPlot");_(r.includes("IC50"),!0),_(r.includes("IC99"),!1,"a dropline off the plot should not be drawn at all")})()),P("property panel renders for a saved legacy statistic",()=>td(function*(){let e=tm("panelBinding",!0,["interceptX"]),t=l.Viewer.grid(e).cell("curve",0);_(new tn.e().renderProperties(t)instanceof HTMLElement,!0,"the property panel failed to render")})()),P("a level survives the panel being rebuilt for the same cell",()=>td(function*(){var e,t;let n=tm("levelRebuilt",!0),r=l.Viewer.grid(n),o=new tn.e,i=e=>o.levelInput(r.cell("curve",e));_(i(0).value,"Column"),i(0).stringValue="Cell",yield X(()=>"Cell"===i(0).value,"a rebuilt panel fell back to the default level"),(0,tu.FC)(r.cell("curve",0),{property:{name:"title"},value:"Only this one"},"chartOptions",i(0).value),_(null==(e=(0,e9.h8)(r.cell("curve",0).cell).chartOptions)?void 0:e.title,"Only this one"),_((null==(t=(0,e9.h8)(r.cell("curve",1).cell).chartOptions)?void 0:t.title)==="Only this one",!1,"a Cell level option reached another cell");let a=l.Viewer.grid(tm("levelRebuilt",!0));_(o.levelInput(a.cell("curve",0)).value,"Column","a table of the same name starts from the default"),i(0).stringValue="Cell",_(i(1).value,"Column","another cell starts from the default")})()),P("statistic names stored under a legacy name map onto the current ones",()=>td(function*(){let e=JSON.parse(JSON.stringify({chartOptions:{logX:!0},series:[{fitFunction:"sigmoid",name:"s",points:e3(-6.5)}]}));N((0,tu.QA)(e,["interceptX"]),["ic50"]),N((0,tu.QA)(e,["auc","rSquared"]),["auc","rSquared"]),N((0,tu.QA)(e,["interceptX","ic50"]),["ic50"]);let t=(0,tu.di)(e).find(e=>"showStatistics"===e.name).choices;_(t.includes("ic50"),!0),_(t.includes("ec50"),!1,"a sigmoid cell must not offer the 4PL-regression name")})())}),E("multi curve viewer",()=>{P("merging cell series leaves the cell alone, and unmerging comes back",()=>tv(function*(){let e=ty("multiCurveMerge"),t=V.shell.addTableView(e);try{var n,r,o,i,l,a;e.currentRowIdx=0;let s=yield tx(t,["curve"]);_(null==(r=s.data)||null==(n=r.series)?void 0:n.length,2,"the current row carries two curves"),s.props.set("mergeCellSeries",!0),_(null==(i=s.data)||null==(o=i.series)?void 0:o.length,1,"merging should leave one curve in the viewer"),_((0,e9.h8)(e.cell(0,"curve")).series.length,2,"the cell itself must still hold both curves"),s.props.set("mergeCellSeries",!1),_(null==(a=s.data)||null==(l=a.series)?void 0:l.length,2,"unmerging should bring both curves back")}finally{t.close()}})(),{timeout:6e4}),P("the viewer names where each of its curves came from",()=>tv(function*(){let e=ty("multiCurveFitIdentities"),t=V.shell.addTableView(e);try{e.currentRowIdx=0;let n=yield tx(t,["curve"]);_(n.fitIdentities.length,n.data.series.length,"every series should carry an identity, in the order they are drawn"),_(n.fitIdentities.every(e=>void 0!==e),!0,"and none of them should be missing")}finally{t.close()}})(),{timeout:6e4}),P("the viewer answers the same hovers the grid does",()=>tv(function*(){let e=Array.from({length:40},(e,t)=>-8+.1*t),t=l.Column.fromStrings("curve",[te(e)]);t.semType=$.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);n.name="multiCurveHover";let r=V.shell.addTableView(n);try{n.currentRowIdx=0;let e=yield tx(r,["curve"]);_(e.data.series.length,40,"the current row carries all the curves");let t=e.canvas,o=t.getBoundingClientRect(),i=[];for(let e=10;e<t.width-5&&0===i.length;e+=10)for(let n=6;n<t.height-5;n+=6){t.dispatchEvent(new MouseEvent("mousemove",{bubbles:!0,clientX:o.left+e,clientY:o.top+n}));let r=document.querySelector(".d4-tooltip"),l=(null==r?void 0:r.innerText)?r.innerText.split("\n").filter(e=>e.trim().length>0):[];if(l.some(e=>e.startsWith("series "))){i=l;break}}_(i.length>0,!0,"hovering the legend in the viewer should name a curve")}finally{r.close()}})(),{timeout:9e4}),P("the axes take in every point, whatever range one cell declares for its own chart",()=>tv(function*(){let e=(e,t)=>{let n=l.Column.fromStrings(e,[JSON.stringify(t)]);return n.semType=$.h.FIT_SEM_TYPE,n},t=l.DataFrame.fromColumns([e("narrow",{chartOptions:{minY:0,maxY:10},series:[{points:[{x:.1,y:1},{x:1,y:5},{x:10,y:9}]}]}),e("tall",{series:[{points:[{x:.1,y:10},{x:1,y:50},{x:10,y:100}]}]})]);t.name="multiCurveAxes";let n=V.shell.addTableView(t);try{t.currentRowIdx=0;let e=(yield tx(n,["narrow","tall"])).getWidgetStatus().values;_(e.curves,2),_(e["points outside the axes"],0,`the axes span ${e["y range"]}`)}finally{n.close()}})()),P("the viewer reports the legend it drew, and a render still on its way",()=>tv(function*(){let e=l.Column.fromStrings("curve",[te(Array.from({length:40},(e,t)=>-8+.1*t))]);e.semType=$.h.FIT_SEM_TYPE;let t=l.DataFrame.fromColumns([e]);t.name="multiCurveStatus";let n=V.shell.addTableView(t);try{var r,o;t.currentRowIdx=0;let e=yield tx(n,["curve"]),i=e.getWidgetStatus();_(i.parts.canvas===e.canvas,!0,"the canvas is the part the hit areas are on"),_(i.values.curves,40),_(i.values["legend shown"],!0),_(e.props.get("showLegend"),!0,"Show Legend should read on while the legend is drawn"),_(i.values["legend rows"]+i.values["legend hidden"],40,"the rows drawn and the ones counted should cover every curve");let l=i.hitAreas["legend more"];_(void 0!==l,!0,"forty curves do not fit, so the rest is counted");let a=e.canvas.getBoundingClientRect();e.canvas.dispatchEvent(new MouseEvent("mousemove",{bubbles:!0,clientX:a.left+l.x+l.width/2,clientY:a.top+l.y+l.height/2}));let s=null!=(r=null==(o=document.querySelector(".d4-tooltip"))?void 0:o.querySelectorAll("canvas").length)?r:0;eo.tooltip.hide(),_(s>1,!0,`hovering "legend more" should list the curves, it listed ${s}`),e.props.set("showLegend",!1),i=e.getWidgetStatus(),_(i.values["legend shown"],!1,"Show Legend off should leave the curves unnamed"),_(Object.keys(i.hitAreas).some(e=>e.includes("legend")),!1,"and no legend row to point at");let u=!1,c=t.onSelectionChanged.subscribe(()=>u=e.isRenderPending);try{yield function(e,t,n){return d(function*(e,t,n,r,o){let i=void 0===r?0:r,l=void 0===o?"timeout":o;return new Promise((r,o)=>{let a=e.subscribe(e=>{try{t(e),r("OK")}catch(e){o(e)}finally{a.unsubscribe(),clearTimeout(s)}}),s=setTimeout(()=>{a.unsubscribe(),o(l)},i);n()})}).apply(this,arguments)}(e.onRendered,()=>_(e.isRenderPending,!1,"a render landed"),()=>t.selection.set(0,!0),5e3)}finally{c.unsubscribe()}_(u,!0,"a selection change should say a render is on its way")}finally{n.close()}})(),{timeout:9e4})});var tC=n(663);function tb(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function tw(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){tb(i,r,o,l,a,"next",e)}function a(e){tb(i,r,o,l,a,"throw",e)}l(void 0)})}}function tT(e,t=!0){let n=[];for(let{column:t,series:r}of e)for(let e of r)n.push({fitFunction:"sigmoid",name:e,columnName:t,points:e3(-6.5)});return JSON.stringify({chartOptions:{logX:!0,showColumnLabel:t},series:n})}let tO=new l.Rect(0,0,500,400);function tS(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function tI(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){tS(i,r,o,l,a,"next",e)}function a(e){tS(i,r,o,l,a,"throw",e)}l(void 0)})}}function tP(e,t=-6.5){let n=l.Column.fromStrings("curve",[e8(t)]);n.semType=$.h.FIT_SEM_TYPE;let r=l.DataFrame.fromColumns([n]);return r.name=e,r.cell(0,"curve")}function t_(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function tA(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){t_(i,r,o,l,a,"next",e)}function a(e){t_(i,r,o,l,a,"throw",e)}l(void 0)})}}E("legend",()=>{P("a column holding one curve does not get a row of its own",()=>tw(function*(){let e=JSON.parse(tT([{column:"curve",series:["PF5624 P1_1h"]},{column:"durability_curve",series:["siR-0016_durability"]},{column:"in_vivo_dr_curve",series:["siR-0016_invivo_dr"]},{column:"plasma_stability_curve",series:["siR-0016_plasma_stab"]}]));N((0,tC._i)(e).map(e=>e.text),["PF5624 P1_1h","siR-0016_durability","siR-0016_invivo_dr","siR-0016_plasma_stab"]);let t=JSON.parse(tT([{column:"curve",series:["low","high"]}]));N((0,tC._i)(t).map(e=>e.text),["curve","low","high"])})()),P("a name shared by two columns is qualified by the column",()=>tw(function*(){let e=JSON.parse(tT([{column:"day 1",series:["control"]},{column:"day 7",series:["control"]}]));N((0,tC._i)(e).map(e=>e.text),["day 1: control","day 7: control"])})()),P("two curves named alike in one column are left as the data has them",()=>tw(function*(){let e=JSON.parse(tT([{column:"multiple styled series",series:["Run:2023-08-08","Run:2023-08-08"]}]));N((0,tC._i)(e).map(e=>e.text),["multiple styled series","Run:2023-08-08","Run:2023-08-08"])})()),P("a shortened row says what it stands for when hovered",()=>tw(function*(){let e="Copy of 20250528_NHA Assay_analysis Plate_1 rep 2 run 3 reader B plate map 7 revision 2",t=e5(JSON.stringify(JSON.parse(tT([{column:"curve",series:[e]}]))),"legendHover",500,400),n=t.rows.find(e=>e.text.startsWith("Copy of"));_(void 0!==n,!0,"the curve should be named");let r=(0,tC.tp)(t.data,t.dataBox,n.x+5,n.y-4);_(null==r?void 0:r.length,1,"hovering the row should say one thing"),_(r[0].text,e,"and it should be the whole name"),_(null===(0,tC.tp)(t.data,t.dataBox,t.dataBox.x+5,t.dataBox.maxY-5),!0,"the rest of the plot should say nothing")})()),P("candlesticks and statistics count as ink, not just fit lines",()=>tw(function*(){let e=[];for(let t of[1e-9,1e-8,1e-7,1e-6,1e-5])e.push({x:t,y:100}),e.push({x:t,y:96});e.push({x:1e-4,y:0});let t=e5(JSON.stringify({chartOptions:{logX:!0},series:[{name:"Run:2023-08-08",columnName:"curve",showPoints:"candlesticks",showFitLine:!1,connectDots:!0,points:e}]}),"legendCandles",500,400),n=t.rows.find(e=>e.text.startsWith("Run:"));_(void 0!==n,!0,"the curve should be named"),_(n.y>t.dataBox.midY,!0,`points fill the top, so the legend belongs below: y=${n.y}`)})()),P("the statistics on the plot are ink the legend keeps clear of",()=>tw(function*(){let e=JSON.parse(tT([{column:"curve",series:["Run:2023-08-08"]}]));e.chartOptions.showStatistics=["ic50"];let t=e5(JSON.stringify(e),"legendStats",500,400),n=t.rows.find(e=>e.text.startsWith("IC50")),r=t.rows.find(e=>e.text.startsWith("Run:"));_(void 0!==n&&void 0!==r,!0,"both should be drawn"),_(Math.abs(r.y-n.y)>10||Math.abs(r.x-n.x)>60,!0,`the legend should not land on the statistics: legend ${r.x},${r.y} vs ${n.x},${n.y}`)})()),P("a curve across the top sends the legend to the bottom",()=>tw(function*(){let e=new l.Rect(0,0,400,300),t=[];for(let n=e.x+10;n<e.maxX-10;n+=8)t.push(new l.Point(n,e.y+30));let n=(0,tC.Al)(e,120,20,t).rect;_(n.y>e.midY,!0,`expected a bottom corner, got y=${n.y}`)})()),P("the legend takes a corner the curves leave free",()=>tw(function*(){let e=new l.Rect(0,0,400,300),t=Array.from({length:30},(t,n)=>new l.Point(e.maxX-10-n,e.y+10+n%20));_((0,tC.Al)(e,120,60,t).rect.x<e.midX,!0,"a crowded top right should push the legend away");let n=[new l.Point(e.maxX-20,e.y+20),new l.Point(e.maxX-30,e.y+30)];_((0,tC.Al)(e,120,60,n).rect.x>e.midX,!0,"it should stay put");let r=[];for(let t of[[e.maxX-20,e.y+20],[e.x+20,e.y+20],[e.maxX-20,e.maxY-20],[e.x+20,e.maxY-20]])for(let e=0;e<30;e++)r.push(new l.Point(t[0],t[1]+e%10));_((0,tC.Al)(e,120,60,r).rect.x>e.midX,!0,"nowhere better means no move"),_((0,tC.Al)(e,120,60).rect.x>e.midX,!0,"and with nothing drawn it is the top right");let o=[...t.slice(0,6),new l.Point(e.x+20,e.maxY-20)];_((0,tC.Al)(e,120,60,o,3).index,3,"it should keep the corner it was in"),_((0,tC.Al)(e,120,60,t,3).index,3,"even when the top right is busy")})()),P("a name is only shortened when it really does not fit",()=>tw(function*(){let e="SigmoidalInhibitionFunction";for(let t of[500,430,380]){let n=e6(tT([{column:"curve",series:[e]}]),`legendFits${t}`,t,400);_(n.includes(e),!0,`at ${t}px expected the whole name, got: ${n.filter(e=>e.startsWith("Sigmo"))}`)}})()),P("a name too long for any corner is ellipsized",()=>tw(function*(){let e,t="Copy of 20250528_NHA Assay_analysis Plate_1 rep 2 run 3 reader B plate map 7 revision 2",n=e6(tT([{column:"curve",series:[t]}]),"legendEllipsis",500,400).find(e=>e.startsWith("Copy of"));_(void 0!==n,!0,"the curve should be named"),_(n.endsWith("…"),!0,`expected an ellipsis, got: ${n}`),_(n.length<t.length,!0,"the name should be shortened"),_(((e=eo.canvas(10,10).getContext("2d")).font='11px Roboto, "Roboto Local"',e.measureText(n).width<=.55*tO.width),!0,"the row must stay within its cap")})()),P("naming the curves can be turned off for the whole plot",()=>tw(function*(){let e=JSON.parse(tT([{column:"curve",series:["Run:2023-08-08"]}]));_(e6(JSON.stringify(e),"legendOn",500,400).includes("Run:2023-08-08"),!0),e.chartOptions.showLegend=!1;let t=e6(JSON.stringify(e),"legendOff",500,400);_(t.includes("Run:2023-08-08"),!1,"showLegend: false should leave the curves unnamed"),_(t.some(e=>"Conc."===e||"Activity"===e||e.length>0),!0)})()),P("Show Legend set for the column names no curve, set for one cell names that one again",()=>tw(function*(){let e=tT([{column:"curve",series:["Run:2023-08-08"]}],!1),t=l.Column.fromStrings("curve",[e,e]);t.semType=$.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);n.name="legendLevels";let r=l.Viewer.grid(n),o=e=>({property:{name:"showLegend"},value:e}),i=e=>e2((0,e9.h8)(n.cell(e,"curve")),500,400).rows.some(e=>"Run:2023-08-08"===e.text);_(i(0)&&i(1),!0,"every cell names its curve to begin with"),(0,tu.FC)(r.cell("curve",0),o(!1),"chartOptions","Column"),_(i(0)||i(1),!1,"off for the column, no cell names its curve"),(0,tu.FC)(r.cell("curve",1),o(!0),"chartOptions","Cell"),_(i(1),!0,"on for one cell, that cell names its curve"),_(i(0),!1,"and the rest of the column stays as the column says")})()),P("hovering what did not fit gives the whole legend",()=>tw(function*(){let e=Array.from({length:40},(e,t)=>`series ${t}`),t=e5(tT([{column:"curve",series:e}]),"legendMoreHover",500,400),n=t.rows.find(e=>e.text.startsWith("+")&&e.text.endsWith("more"));_(void 0!==n,!0,"the legend should say how many it left out");let r=(0,tC.tp)(t.data,t.dataBox,n.x+5,n.y-4);_(null==r?void 0:r.length,e.length+1,"the tooltip should carry every row the legend has"),_(r.some(e=>"series 39"===e.text),!0,"including the ones it could not draw"),_(r.every(e=>e.color.length>0),!0,"each named in the colour of its curve")})()),P("a legend short enough to list keeps every row in the tooltip",()=>tw(function*(){let e=JSON.parse(tT([{column:"curve",series:Array.from({length:4},(e,t)=>`series ${t}`)}])),t=(0,tC._i)(e),n=(0,tC.D5)(t);_(n.querySelectorAll("canvas").length,t.length,"every row should carry its glyph"),_(n.innerText.includes("more"),!1,"nothing is left to count when it all fits")})()),P("a legend too long for the window is counted rather than listed",()=>tw(function*(){let e=JSON.parse(tT([{column:"curve",series:Array.from({length:300},(e,t)=>`series ${t}`)}])),t=(0,tC._i)(e),n=(0,tC.bp)();_(t.length>n,!0,"the fixture should outgrow any window");let r=(0,tC.D5)(t);_(r.querySelectorAll("canvas").length,n,"it lists what the window has room for"),_(r.innerText.trim().endsWith(`+${t.length-n} more`),!0,"and counts the rest")})()),P("a name the plot shortened is given back whole, however long",()=>tw(function*(){let e="x".repeat(2e3),t=JSON.parse(tT([{column:"curve",series:[e]}])),n=(0,tC._i)(t);_(n.length,1,"a column holding one curve is named once"),_((0,tC.D5)(n).innerText.includes(e),!0,"hovering that one row is what says the whole of a name")})()),P("names that long are labels once the hover lists several",()=>tw(function*(){let e="x".repeat(2e3),t=JSON.parse(tT([{column:"curve",series:[`${e} a`,`${e} b`,`${e} c`]}])),n=(0,tC.D5)((0,tC._i)(t));_(n.innerText.includes(e),!1,"a list of cells of JSON should not be spelled out"),_(n.innerText.includes("…"),!0,"each row should say it was shortened")})()),P("more curves than fit are counted instead of stacked",()=>tw(function*(){let e=Array.from({length:40},(e,t)=>`series ${t}`),t=e6(tT([{column:"curve",series:e}]),"legendOverflow",500,400),n=t.find(e=>e.startsWith("+")&&e.endsWith("more"));_(void 0!==n,!0,"the legend should say how many it left out");let r=t.filter(e=>e.startsWith("series ")).length;_(r>0,!0,"it should still draw the curves that fit"),_(r+parseInt(n.slice(1),10),e.length,"drawn names plus the counted ones should cover every curve")})())}),E("fit cache",()=>{P("a curve fitted in log space is not handed to a linear plot",()=>tI(function*(){let e=tP("fitCacheLogSpace"),t=(0,e9.h8)(e).series[0],n=(0,ev.zB)(t),r=(0,e9.IY)(t,0,n,{logX:!0,logY:!1},e),o=(0,e9.IY)(t,0,n,{logX:!1,logY:!1},e);_(Array.from(r.parameters).toString()!==Array.from(o.parameters).toString(),!0,`the two spaces should fit differently, both gave ${Array.from(r.parameters)}`),_((0,e9.IY)(t,0,n,{logX:!0,logY:!1},e)===r,!0,"asking twice in the same space should come from the cache")})()),P("a viewer fit is reused, and never confused with another cell",()=>tI(function*(){let e=tP("fitCacheRowsOne",-7),t=tP("fitCacheRowsOther",-5),n=(0,e9.h8)(e),r=(0,e9.h8)(t);_((0,e9.U6)(n)!==(0,e9.U6)(r),!0,"two cells should not share an identity");let o={logX:!0,logY:!1},i=(0,ev.zB)(n.series[0]),l=(0,e9.IY)(n.series[0],0,i,o,void 0,!1,`${(0,e9.U6)(n)} || idx: 0`),a=(0,e9.IY)(r.series[0],0,i,o,void 0,!1,`${(0,e9.U6)(r)} || idx: 0`);_(l===a,!1,"two different curves must not answer for each other"),_(Array.from(l.parameters).toString()!==Array.from(a.parameters).toString(),!0,"and they fit differently, so a collision would be visible"),_((0,e9.IY)(n.series[0],0,i,o,void 0,!1,`${(0,e9.U6)(n)} || idx: 0`)===l,!0,"the same curve should be fitted once")})()),P("the viewer cache is kept apart from the grid one, and agrees with it",()=>tI(function*(){let e=tP("fitCacheApart"),t=(0,e9.h8)(e),n=t.series[0],r=(0,ev.zB)(n),o={logX:!0,logY:!1},i=(0,e9.IY)(n,0,r,o,e),l=(0,e9.IY)(n,0,r,o,e,!0,`${(0,e9.U6)(t)} || idx: 0`);_(i===l,!1,"the two caches must not share storage"),_(Array.from(i.parameters).toString(),Array.from(l.parameters).toString(),"but keeping them apart must not change the answer")})()),P("a render that names its curves fits them once",()=>tI(function*(){let e=JSON.parse(te([-7,-5])),t=eo.canvas(300,200).getContext("2d"),n=new l.Rect(0,0,300,200),r=["probeCell || idx: 0","probeCell || idx: 1"];new es.l().renderCurves(t,n,e,void 0,r);let o=e9.d3.K.filter(Boolean);_(r.every(e=>o.some(t=>t.startsWith(e))),!0,`the render should have cached a fit per identity, holds ${o.length}`);let i=!1,a=e.chartOptions;e9.d3.getOrCreate(`${r[0]} || logX: ${null==a?void 0:a.logX} || logY: ${null==a?void 0:a.logY}`,()=>(i=!0,null)),_(i,!1,"a second render of the same curve should not fit it again")})()),P("a pipe in a title survives, and one that breaks the value is still stripped",()=>tI(function*(){let e=JSON.parse(e8(-6.5));e.chartOptions.title="compound 10 | Collapse Assay | run 4";let t=l.Column.fromStrings("curve",[JSON.stringify(e),'{"series":|[{"points":[]}]}']);t.semType=$.h.FIT_SEM_TYPE;let n=l.DataFrame.fromColumns([t]);n.name="pipeTitles",_((0,e9.h8)(n.cell(0,"curve")).chartOptions.title,"compound 10 | Collapse Assay | run 4","a pipe inside a title is not part of the value"),_((0,e9.h8)(n.cell(1,"curve")).series.length,1,"stripping should still rescue a value that does not parse as it stands")})()),P("editing a cell retires the fits made from it",()=>tI(function*(){let e=tP("fitCacheEdit",-7),t=(0,e9.h8)(e),n=(0,ev.zB)(t.series[0]),r={logX:!0,logY:!1},o=(0,e9.IY)(t.series[0],0,n,r,void 0,!1,`${(0,e9.U6)(t)} || idx: 0`);e.column.set(0,e8(-5));let i=(0,e9.h8)(e);_((0,e9.U6)(i)!==(0,e9.U6)(t),!0,"a re-parsed cell should get a new identity"),_(Array.from((0,e9.IY)(i.series[0],0,n,r,void 0,!1,`${(0,e9.U6)(i)} || idx: 0`).parameters).toString()!==Array.from(o.parameters).toString(),!0,"so the edited curve is fitted afresh")})())});let tN="curves-demo.csv",tE="multiple styled series";function tL(e){return tA(function*(){let t=yield V.dapi.files.readCsv(`System:AppData/Curves/${e}`);return t.name=e.replace(".csv",""),yield V.data.detectSemanticTypes(t),V.shell.addTableView(t)})()}let tF=[];function tM(e,t){return tA(function*(){let n=l.Project.create();n.name="Curves test project";let r=e.dataFrame.getTableInfo();t&&(r.tags[l.Tags.DataSync]="sync",r.tags[l.Tags.CreationScript]=e.dataFrame.getTag(l.Tags.CreationScript));let o=e.saveLayout();n.addChild(r),n.addChild(o),yield V.dapi.tables.uploadDataFrame(e.dataFrame),yield V.dapi.tables.save(r),yield V.dapi.views.save(o),tF.push((yield V.dapi.projects.save(n)));let i=n.id;yield Y(e.grid),V.shell.closeAll();let a=yield V.dapi.projects.find(i);yield a.open()})()}function tR(e){return tA(function*(){let t;e?(yield l.Func.find({name:"OpenFile"})[0].prepare({fullPath:`System:AppData/Curves/${tN}`}).call(void 0,void 0,{processed:!1}),t=V.shell.tv,yield V.data.detectSemanticTypes(t.dataFrame)):t=yield tL(tN);var n=t;if(null===n.dataFrame.col(tE))throw Error(`no ${tE} column - the table has: ${n.dataFrame.columns.names().join(", ")}`);(0,tu.FC)(n.grid.cell(tE,0),{property:{name:"showCurveConfidenceInterval"},value:!1},"seriesOptions","Column"),yield tM(t,e),yield tA(function*(){yield X(()=>{var e,t;return(null==(t=V.shell.tv)||null==(e=t.dataFrame)?void 0:e.col(tE))!=null},`${tE} is missing from the reopened project`,3e4)})(),yield X(()=>{var e;return(null==(e=(0,e9.bc)(V.shell.tv.dataFrame.col(tE)).seriesOptions)?void 0:e.showCurveConfidenceInterval)===!1},"the column tag did not come back with the project",3e4);let r=V.shell.tv.dataFrame;_((0,e9.h8)(r.cell(0,tE)).series[0].showCurveConfidenceInterval,!1,"the column-level option did not outrank the data after reopening")})()}E("projects",()=>{void 0==x[e]&&(x[e]={}),x[e].after=()=>tA(function*(){for(let e of tF)yield V.dapi.projects.delete(e)})(),P("column-level option survives a project",()=>tA(function*(){yield tR()})(),{timeout:12e4}),P("painting a table leaves its dataframe tags alone, so its layout saves",()=>tA(function*(){let e=yield V.dapi.files.readCsv(`System:AppData/Curves/${tN}`);e.name="curvesPaintedLayout",e.setTag($.h.TAG_FIT_LEGACY,JSON.stringify((0,ev.Kh)())),yield V.data.detectSemanticTypes(e);let t=V.shell.addTableView(e),n=null;try{for(let t of e.columns.bySemTypeAll($.h.FIT_SEM_TYPE))(0,e9.h8)(e.cell(0,t.name),!1);yield Y(t.grid),_(null==e.getTag($.h.TAG_FIT),!0,"reading the options tagged the dataframe"),n=yield V.dapi.layouts.save(t.saveLayout())}finally{n&&(yield V.dapi.layouts.delete(n)),t.close()}})(),{timeout:6e4}),P("curve columns are curves again in a reopened project",()=>tA(function*(){let e=yield tL(tN),t=e.dataFrame.columns.bySemTypeAll($.h.FIT_SEM_TYPE).map(e=>e.name);_(t.length,5,`the demo has five curve columns, found ${t}`),yield tM(e);try{yield X(()=>t.every(e=>{var t,n,r;return(null==(r=V.shell.tv)||null==(n=r.dataFrame)||null==(t=n.col(e))?void 0:t.semType)===$.h.FIT_SEM_TYPE}),`the reopened project lost a curve column: ${t}`,3e4)}finally{yield Y(V.shell.tv.grid),V.shell.closeAll()}})(),{timeout:12e4}),P("column-level option survives a datasync project",()=>tA(function*(){yield tR(!0)})(),{timeout:12e4})});var tD=n(1);function tX(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}let tY=`compound_id,assay_name,target_entity,batch_id,run_id,concentration_uM,inhibition
178
+ C1,A,T,B1,R1,0.1,5
179
+ C1,A,T,B1,R1,1,20
180
+ C1,A,T,B1,R1,10,60
181
+ C1,A,T,B1,R1,100,95
182
+ C1,A,T,B1,R2,0.1,4
183
+ C1,A,T,B1,R2,1,25
184
+ C1,A,T,B1,R2,10,55
185
+ C1,A,T,B1,R2,100,90
186
+ C2,A,T,B2,R1,0.1,2
187
+ C2,A,T,B2,R1,1,10
188
+ C2,A,T,B2,R1,10,30
189
+ C2,A,T,B2,R1,100,50`;function tk(e,t,n,r,o,i,l){try{var a=e[i](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,o)}function tj(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){tk(i,r,o,l,a,"next",e)}function a(e){tk(i,r,o,l,a,"throw",e)}l(void 0)})}}E("Data to Curves",()=>{P("wells group into one curve per compound, assay, target and run",()=>{var e;return(e=function*(){let e=l.DataFrame.fromCsv(tY),t=yield(0,tD.p)(e,e.col("concentration_uM"),e.col("inhibition"),e.col("batch_id"),e.col("assay_name"),e.col("run_id"),e.col("compound_id"),e.col("target_entity")),n=e=>t.col(e).toList().join(", ");_(t.rowCount,3),_(t.col("Fitted Curve").semType,"fit"),_(n("Compound|Assay|Target"),"C1 | A | T, C1 | A | T, C2 | A | T"),_(n("Run ID"),"R1, R2, R1"),_(n("Max Percent Inhibition"),"95, 90, 50"),_(n("Max Percent Inhibition (Compound | Assay | Target)"),"95, 95, 50")},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){tX(i,r,o,l,a,"next",e)}function a(e){tX(i,r,o,l,a,"throw",e)}l(void 0)})})()})});let tG=new l.Package;function tB(e,t,n){return tj(function*(){var r;let o=yield(r={category:e,test:t,testContext:n},d(function*(){let e,t=(null==r?void 0:r.nodeOptions)?r.nodeOptions.package:grok.functions.getCurrentCall().func.package;if(!t)throw Error("Can't run tests outside of the package");let n=null==(Y=t.packageOwner)?void 0:Y.match(/<([^>]*)>/),o=n?n[1]:"";void 0!=t&&(yield d(function*(){let e=t.id;if(O[e])return;if("DevTools"===t.name){var n=!0,r=!1,o=void 0;try{for(var i,l,s,u,c,f,m,p,h=window.dartTests[Symbol.iterator]();!(n=(p=h.next()).done);n=!0){let e=p.value,t=e.name.split(/\s*\|\s*!/g),n=null!=(i=t.pop())?i:e.name,r=t.length?T+": "+t.join(": "):T,o=n.split(" | ");n=o[o.length-1],o.unshift(r),o.pop(),r=o.join(": "),void 0===x[r]&&(x[r]={tests:[],clear:!0}),x[r].tests.push(new I(r,n,e.test,{isAggregated:!1,timeout:null!=(l=null==(u=e.options)?void 0:u.timeout)?l:3e4,skipReason:null==(c=e.options)?void 0:c.skipReason,owner:null==(f=e.options)?void 0:f.owner,benchmark:null!=(s=null==(m=e.options)?void 0:m.benchmark)&&s}))}}catch(e){r=!0,o=e}finally{try{n||null==h.return||h.return()}finally{if(r)throw o}}}let g=[],v=[],y=null,S=[],P=yield grok.dapi.functions.filter(`package.id = "${e}"`).list(),A=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);var N=!0,E=!1,L=void 0;try{for(var F,M,R,D,X=P[Symbol.iterator]();!(N=(D=X.next()).done);N=!0){let e=D.value,n=e.options.test,r=e.options.demoPath;if(n&&Array.isArray(n)&&n.length)for(let t=0;t<n.length;t++){let r=n[t].matchAll(A),o={};Array.from(r).forEach(e=>{e[0].startsWith("skip")?o.skip=e[1]:e[0].startsWith("wait")?o.wait=parseInt(e[2]):e[0].startsWith("cat")?o.cat=e[3]:e[0].startsWith("timeout")&&(o.timeout=parseInt(e[4]))});let i=new I(null!=(F=o.cat)?F:C,1===n.length?e.name:`${e.name} ${t+1}`,()=>d(function*(){var r;let i=yield grok.functions.eval((r=n[t],r.replace(RegExp(e.name,"gi"),e.nqName)));if(o.wait&&(yield k(e.name)),"boolean"==typeof i&&!i)throw`Failed: ${n[t]}, expected true, got ${i}`})(),{skipReason:o.skip,timeout:DG.Test.isInBenchmark?null!=(M=o.benchmarkTimeout)?M:108e5:null!=(R=o.timeout)?R:3e4,node:e instanceof DG.DataQuery});if(o.cat){let e=o.cat;void 0===x[e]&&(x[e]={tests:[],clear:!0}),x[e].tests||(x[e].tests=[]),x[e].tests.push(i)}else g.push(i)}if(r){let t=new I(b,e.friendlyName,()=>d(function*(){yield k("the views the previous test closed");let t=y?yield grok.shell.lastError:null;if(grok.shell.clearLastError(),t)throw Error(`${y} raised an error after it finished: ${t}`);y=e.friendlyName,yield e.apply(),yield k(e.friendlyName);let n=yield grok.shell.lastError;if(grok.shell.clearLastError(),n)throw Error(n)})(),{skipReason:e.options.demoSkip});v.push(t)}if(e.hasTag("semTypeDetector")){let n=a;e.options.testData&&(n=yield grok.data.files.openTable(`System:AppData/${t.nqName}/${e.options.testData}`));let r=new I(w,e.friendlyName,()=>d(function*(){let r=[];console.log(`System:AppData/${t.nqName}/${e.options.testData}`);var o=!0,i=!1,l=void 0;try{for(var a,s=n.clone().columns[Symbol.iterator]();!(o=(a=s.next()).done);o=!0){let t=a.value,n=yield e.apply([t]);r.push(n||t.semType)}}catch(e){i=!0,l=e}finally{try{o||null==s.return||s.return()}finally{if(i)throw l}}let u=r.filter(e=>e);_(u.length,1),e.options.testDataColumnName&&_(u[0],e.options.testDataColumnName)})(),{skipReason:e.options.skipTest});S.push(r)}}}catch(e){E=!0,L=e}finally{try{N||null==X.return||X.return()}finally{if(E)throw L}}O[e]=!0,g.length>0&&(x[C]={tests:g,clear:!0}),v.length>0&&(x[b]={tests:v,clear:!0}),S.length>0&&(x[w]={tests:S,clear:!1})})());let i=[],l=Date.now(),s=new F(!(null==r?void 0:r.stressTest));console.log("Running tests..."),console.log(r),null!=r||(r={}),null!=(j=r).testContext||(j.testContext=new S),grok.shell.clearLastError();let u=(e=[],console.log=(...t)=>{e.push(...t),h(...t)},console.info=(...t)=>{e.push(...t),g(...t)},console.warn=(...t)=>{e.push(...t),v(...t)},console.error=(...t)=>{e.push(...t),y(...t)},e);yield(N=x,E=r,d(function*(){try{let g=(null==E?void 0:E.skipToCategory)!=void 0,v=!1;var e=!0,n=!1,r=void 0;try{for(var l,a,c,x,C,b=Object.entries(N)[Symbol.iterator]();!(e=(C=b.next()).done);e=!0){let e,n=p(C.value,2),r=n[0],y=n[1];if((null==(c=E.exclude)?void 0:c.some(e=>r.startsWith(e)))||(null==E?void 0:E.category)!=null&&!r.toLowerCase().startsWith(null==E?void 0:E.category.toLowerCase().trim()))continue;if(g)if(v)g=!1;else{if((null==E?void 0:E.skipToCategory)==null||r.toLowerCase().trim()!==(null==E?void 0:E.skipToCategory.toLowerCase().trim()))continue;v=!0}let b=(null!=(l=y.tests)?l:[]).filter(e=>L(e,y,E));if((E.nodeOnly||E.excludeNodeTests)&&0===b.length||DG.Test.isInBenchmark&&!b.some(e=>{var t,n,r;return null!=(t=null!=(n=null==(r=e.options)?void 0:r.benchmark)?n:y.benchmarks)&&t}))continue;let w=void 0==y.tests?void 0:b.every(e=>{var t;return(null==(t=e.options)?void 0:t.skipReason)||(null==E?void 0:E.test)!=null&&E.test.toLowerCase()!==e.name.toLowerCase()});if(!w){let e=b.filter(e=>{var t;return(null==(t=e.options)?void 0:t.skipReason)||(null==E?void 0:E.test)!=null&&E.test.toLowerCase()!==e.name.toLowerCase()}).length;h(`Package testing: Started {{${r}}}${e>0?` skipped {{${e}}}`:""}`),y.beforeStatus=yield $(y.before,r)}if(E.stressTest&&(b=b.filter(e=>{var t;return null==(t=e.options)?void 0:t.stressTest}),b=function(e){let t=e.slice();return t.sort(()=>Math.random()-.5),t}(b)),(null!=(a=null==(x=E.tags)?void 0:x.length)?a:0)>0&&(b=b.filter(e=>{var t,n;return null==(n=e.options)||null==(t=n.tags)?void 0:t.some(e=>{var t;return(null!=(t=null==E?void 0:E.tags)?t:[]).includes(e)})})),y.beforeStatus){let n=y.beforeStatus.split("\n")[0].trim();(e=Array.from(b.map(e=>({date:new Date().toISOString(),category:r,name:e.name,success:!1,result:n?`before() failed: ${n}`:"before() failed",ms:0,skipped:!1,logs:"",owner:o,package:t.name,widgetsDifference:0,flaking:DG.Test.isReproducing})))).forEach(e=>s.add("package",e))}else e=yield function(e,n,r){return d(function*(){var i,l,a,c,d,p,h,g,v,y,x,C,b,w,T,O,S,I,P;let _=(null!=(i=e.tests)?i:[]).filter(t=>L(t,e,n)),A=[],N=q();if(e.clear){let i=r&&void 0!=n.skipToTest;for(let r=0;r<_.length;r++){_[r].options&&(null==(h=_[r].options)?void 0:h.benchmark)===void 0&&(_[r].options||(_[r].options={}),_[r].options.benchmark=null!=(g=e.benchmarks)&&g);let b=_[r];if(n.test&&n.test.toLowerCase()!==b.name.toLowerCase())continue;if(i)if((null==n?void 0:n.skipToTest)==void 0||b.name.toLowerCase().trim()!==(null==n?void 0:n.skipToTest.toLowerCase().trim()))continue;else i=!1;(null==b?void 0:b.options)&&(b.options.owner=null!=(v=null!=(y=null!=(x=null==(C=_[r].options)?void 0:C.owner)?x:null==e?void 0:e.owner)?y:o)?v:"");let w=yield R(b,null==n?void 0:n.test,u,DG.Test.isInBenchmark?null!=(l=null==(c=_[r].options)?void 0:c.benchmarkTimeout)?l:108e5:null!=(a=null==(d=_[r].options)?void 0:d.timeout)?a:3e4,t.name,n.verbose,s);if(w&&!w.skipped&&(yield H()),w&&(A.push(m(f({},w),{widgetsDifference:q()-N})),n.returnOnFail&&n.skipToTest!==b.name&&!w.success&&!w.skipped))break;n.nodeOptions||(null==(p=n.testContext)?void 0:p.closeAll)===!1||(grok.shell.closeAll(),DG.Balloon.closeAll())}}else{let i=r&&void 0!=n.skipToTest;for(let r=0;r<_.length;r++){let l=_[r];if(n.test&&n.test.toLowerCase()!==l.name.toLowerCase())continue;if(i){(null==n?void 0:n.skipToTest)!=void 0&&l.name.toLowerCase().trim()===(null==n?void 0:n.skipToTest.toLowerCase().trim())&&(i=!1);continue}(null==l?void 0:l.options)&&(l.options.owner=null!=(O=null!=(S=null!=(I=null==(P=_[r].options)?void 0:P.owner)?I:null==e?void 0:e.owner)?S:o)?O:"");let a=yield R(l,null==n?void 0:n.test,u,DG.Test.isInBenchmark?null!=(b=null==(w=_[r].options)?void 0:w.benchmarkTimeout)?b:108e5:null==(T=_[r].options)?void 0:T.timeout,t.name,n.verbose,s);if(a&&!a.skipped&&(yield H()),a&&(A.push(m(f({},a),{widgetsDifference:q()-N})),n.returnOnFail&&n.skipToTest!==l.name&&!a.success&&!a.skipped))break}}return A})()}(y,E,g);let T=e.filter(e=>"skipped"!=e.result);if(w||(y.afterStatus=yield $(y.after,r)),y.afterStatus&&(h(`Package testing: Category after() {{${r}}} failed`),h(`Package testing: Result for {{${r}}} after: ${y.afterStatus}`),T.push({date:new Date().toISOString(),category:r,name:"after",success:!1,result:y.afterStatus,ms:0,skipped:!1,logs:"",owner:o,package:t.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),y.beforeStatus&&(h(`Package testing: Category before() {{${r}}} failed`),h(`Package testing: Result for {{${r}}} before: ${y.beforeStatus}`),T.push({date:new Date().toISOString(),category:r,name:"before",success:!1,result:y.beforeStatus,ms:0,skipped:!1,logs:"",owner:o,package:t.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),i.push(...T),E.returnOnFail&&T.some(e=>!e.success&&!e.skipped&&e.name!==E.skipToTest))break}}catch(e){n=!0,r=e}finally{try{e||null==b.return||b.return()}finally{if(n)throw r}}}finally{console.log=h,console.info=g,console.warn=v,console.error=y}if(E.testContext.catchUnhandled&&!DG.Test.isInBenchmark){let e;try{yield k("the last test"),e=yield grok.shell.lastError}catch(t){e=t.message}if(void 0!=e){let n={logs:"",date:new Date().toISOString(),category:"Unhandled exceptions",name:"Exception",result:null!=e?e:"",success:!e,ms:0,skipped:!1,owner:null!=o?o:"",package:t.name,widgetsDifference:0};h(`Package testing: Unhandled Exception: ${e}`),i.push(m(f({},n),{flaking:DG.Test.isReproducing&&!e})),n.package=t.name,s.add("package",n)}}})()),yield Promise.race([s.sent,D(6e4)]);var c=!0,P=!1,A=void 0;try{for(var N,E,X,Y,j,B,V=i[Symbol.iterator]();!(c=(B=V.next()).done);c=!0){let e=B.value;e.result=e.result.toString().replace(/"/g,"'"),void 0!=e.logs&&(e.logs=e.logs.toString().replace(/"/g,"'"))}}catch(e){P=!0,A=e}finally{try{c||null==V.return||V.return()}finally{if(P)throw A}}return i;function $(e,t){return d(function*(){let n;try{void 0!==e&&(yield G(()=>d(function*(){yield e()})(),1e5,`before ${t}: timeout error`))}catch(e){n=yield M(e)}return n})()}function H(){return d(function*(){let e=globalThis.gc;!e||Date.now()-l<5e3||(yield e(),l=Date.now())})()}function q(){if("u">typeof process)return 0;let e=-1;try{e=DG.Widget.getAll().length}catch(e){var t;console.warn(null!=(t=e.message)?t:e)}return e}})());return l.DataFrame.fromObjects(o)})()}function tV(){return tj(function*(){})()}})(),curves_test=r})();
178
190
  //# sourceMappingURL=package-test.js.map