@datagrok/compute 1.44.5 → 1.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -1
- package/README.md +5 -7
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +11 -8
- package/scripts/lorenz-attractor.js +1 -1
- package/src/package-api.ts +5 -31
- package/src/package-test.ts +1 -1
- package/src/package.g.ts +9 -55
- package/src/package.ts +7 -150
- package/dist/148.js +0 -2
- package/dist/148.js.map +0 -1
- package/dist/377.js +0 -2
- package/dist/377.js.map +0 -1
- package/dist/508.js +0 -2
- package/dist/508.js.map +0 -1
package/dist/package.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var compute;(()=>{var t={237:(t,e,n)=>{"use strict";var i;n.d(e,{FL:()=>o,KN:()=>i,Q2:()=>c,TR:()=>a,YU:()=>u,be:()=>r,dV:()=>l}),function(t){t[t.COR_PLOT=.5]="COR_PLOT",t[t.PC_PLOT=.6]="PC_PLOT",t[t.GRAPH=.6]="GRAPH",t[t.BAR_CHART=.2]="BAR_CHART"}(i||(i={}));const o=25;var s;!function(t){t.METHOD="`Method`",t.SAMPLES="`Samples`"}(s||(s={}));const r="https://datagrok.ai/help/compute/function-analysis#sensitivity-analysis",a=`# Sensitivity Analysis\n\nSensitivity Analysis runs the computation multiple times with varying inputs, \nand analyzes the relationship between inputs and outputs.\n\nUse one of the following methods:\n\n* **Monte Carlo** explores a function \nat randomly taken points\n\n* **Sobol** decomposes output variance into fractions, which can be attributed to inputs\n\n* **Grid** studies a function at the points of a grid with the specified step\n\n## Monte Carlo\n\nOnce you've chosen it in ${s.METHOD}\n\n* Set in ${s.SAMPLES} the number of random points \n\n* Use switchers to specify varied inputs and outputs to be analyzed\n\n* Press **Run** or <i class="fas fa-play"></i> on the top panel. You will get \n\n * [Correlation plot](https://datagrok.ai/help/visualize/viewers/correlation-plot) for exploring\ncorrelations between varied inputs and the specified outputs\n\n * [PC plot](https://datagrok.ai/help/visualize/viewers/pc-plot) visualizing multivariate data\nand providing variations of the selected inputs & outputs\n\n * [Line chart](https://datagrok.ai/help/visualize/viewers/line-chart) or \n[Scatterplot](https://datagrok.ai/help/visualize/viewers/scatter-plot) (dependently on the varied\ninputs count) showing a behavior of each output separately\n\n * [Grid](https://datagrok.ai/help/visualize/viewers/grid) containing inputs and outputs values \nof each function evaluation\n\n* Press **?** on the top panel to learn more about [Sensitivity Analysis](${r})\n\n## Sobol\n\nThis method performs \n[variance-based sensitivity analysis](https://en.wikipedia.org/wiki/Variance-based_sensitivity_analysis). \nIt provides the same visualizations \nas **Monte Carlo** and [bar charts](https://datagrok.ai/help/visualize/viewers/bar-chart) showing \nSobol' indices:\n\n* First-order indices indicate the contribution to the output variance of varying each input alone\n\n* Total-order indices measure the contribution to the output variance of each input,\n including all variance caused by its interactions with any other inputs\n \n ## Grid\n \n This method provides the same visualization as the previous ones. Unlike them, it evaluates a function \n at the points of uniform grid within the specified ranges.`,l=0,u=-1,c=0},241:(t,e,n)=>{"use strict";n.d(e,{L:()=>o,t:()=>a});var i=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const o=new Map([["tolerance",{default:1e-6,min:1e-20,max:.1,caption:"tolerance",tooltipText:"How precise the result should be. Lower value = more accurate result, but longer computation",inputType:"Float"}],["maxIter",{default:50,min:1,max:1e4,caption:"max iterations",tooltipText:"Maximum number of iterations. Higher = better fit",inputType:"Int"}],["nonZeroParam",{default:1e-4,min:1e-20,max:.1,caption:"non-zero param",tooltipText:"Minimum parameter value (to avoid zero values)",inputType:"Float"}],["initialScale",{default:.02,min:1e-20,max:.1,caption:"initial scale",tooltipText:"Size of the initial search area. Higher value = wider search area",inputType:"Float"}],["scaleReflaction",{default:1,min:1,max:2,caption:"scale reflection",tooltipText:"How far the algorithm 'bounces back' from failed attempts",inputType:"Float"}],["scaleExpansion",{default:2,min:1,max:2,caption:"scale expansion",tooltipText:"How much the algorithm expands search in a promising direction",inputType:"Float"}],["scaleContraction",{default:-.5,min:-.5,max:0,caption:"scale contraction",tooltipText:"How much the algorithm narrows the search area when approaching the result",inputType:"Float"}]]);function s(t,e,n,i){for(let o=0;o<e;o++){let s=0;for(let t=0;t<e+1;t++)t!=n&&(s+=i[t][o]);t[o]=s/e}}function r(t,e,n,i,o,s){for(let r=0;r<s;r++)e[r]=t[r],e[r]+=o*(t[r]-i[n][r])}const a=function(t,e,n,o){return i(this,void 0,void 0,function*(){var a,l,u,c;const d=n.get("tolerance"),p=n.get("maxIter"),h=n.get("scaleReflaction"),f=n.get("scaleExpansion"),m=n.get("scaleContraction"),v=e.length+1,g=e.length,y=2*(null!==(a=yield t(e))&&void 0!==a?a:1/0),[b,A]=yield function(t,e,n,o){return i(this,void 0,void 0,function*(){var i;const s=n.length+1,r=n.length,a=e.get("nonZeroParam"),l=e.get("initialScale"),u=new Array(s),c=new Array(s);for(let e=0;e<s;e++){u[e]=new Float64Array(r);for(let t=0;t<r;t++)u[e][t]=n[t],0!=e&&e-1===t&&(0==n[t]?u[e][t]=a:u[e][t]+=l*n[e-1]);c[e]=null!==(i=yield t(u[e]))&&void 0!==i?i:o}return[u,c]})}(t,n,e,y),w=new Array(v);for(let t=0;t<v;t++)w[t]=t;const C=w.length-1;let I=0,T=0,E=0,S=0;const x=new Float64Array(g),R=new Float64Array(g),O=new Float64Array(g),N=new Float64Array(g),F=new Array(p);if(v>1){for(;w.sort((t,e)=>A[t]-A[e]),!(I>p);){if(0==I&&(T=A[0],E=2*A[w[0]]),F[I]=T,++I,T=A[w[0]],E-T>d)S=0;else if(++S,S>2*v)break;if(null!=o&&T<=o)break;E=T,s(x,g,w[C],b),r(x,R,w[C],b,h,g);const e=null!==(l=yield t(R))&&void 0!==l?l:y;if(e<A[w[C]]){r(x,O,w[C],b,f,g);const n=null!==(u=yield t(O))&&void 0!==u?u:y;if(n<e){A[w[C]]=n;for(let t=0;t<g;t++)b[w[C]][t]=O[t];continue}A[w[C]]=e;for(let t=0;t<g;t++)b[w[C]][t]=R[t];continue}r(x,N,w[C],b,m,g);const n=null!==(c=yield t(N))&&void 0!==c?c:y;if(!(n<A[w[C]]))break;A[w[C]]=n;for(let t=0;t<g;t++)b[w[C]][t]=N[t]}for(let t=I;t<p;t++)F[t]=A[w[0]]}return{point:b[w[0]],cost:A[w[0]],iterCosts:F,iterCount:I-1}})}},392:(t,e,n)=>{"use strict";n.d(e,{I3:()=>m,a8:()=>c,jd:()=>d,lp:()=>p,v_:()=>f});var i=n(4328),o=n(7389),s=n(6082),r=n(9713),a=n(9939),l=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};function u(t){const{viewName:e,funcName:n,_package:i,ViewClass:o}=t;let r=o.findModelCatalogView(e);if(!r){const t=s.Func.find({package:i.name,name:n})[0].prepare();t.callSync({processed:!0,report:!1}),r=t.getOutputParamValue()}return r}function c(t){const{ViewClass:e}=t;i.events.onAccordionConstructed.subscribe(t=>{const e=t.context;null!=e&&"script"==e.type&&(t.getPane("REST")||t.addPane("REST",()=>o.wait(()=>l(this,void 0,void 0,function*(){return(yield p(e)).root}))))}),i.functions.onBeforeRunAction.subscribe(n=>{var i,o;if(n.func.hasTag("model")){const i=u(t);e.bindModel(i,n)}else if((null===(o=null===(i=n.inputs)||void 0===i?void 0:i.call)||void 0===o?void 0:o.func)instanceof s.Func&&n.inputs.call.func.hasTag("model")){const i=u(t);e.bindModel(i,n.inputs.call)}}),i.events.onCurrentViewChanged.subscribe(()=>l(this,void 0,void 0,function*(){var e;let n=!0;(null===(e=i.shell.v)||void 0===e?void 0:e.name)===t.viewName?(n=i.shell.windows.help.syncCurrentObject,i.shell.windows.help.syncCurrentObject=!1):i.shell.windows.help.syncCurrentObject=n}))}function d(){s.ObjectHandler.list().find(t=>"Model"===t.type)||s.ObjectHandler.register(new a.s)}function p(t){return l(this,void 0,void 0,function*(){const e={};t.inputs.forEach(t=>e[t.name]=null);const n=`\ncurl --location --request POST '${i.settings.apiUrl}/v1/func/${t.nqName}/run' \\\n--header 'Authorization: ${h("auth")}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '${JSON.stringify(e)}'`,r=`\nvar myHeaders = new Headers();\nmyHeaders.append("Authorization", "${h("auth")}");\nmyHeaders.append("Content-Type", "applicati4on/json");\n\nvar raw = JSON.stringify(${JSON.stringify(e)});\n\nvar requestOptions = {\n method: 'POST',\n headers: myHeaders,\n body: raw,\n redirect: 'follow'\n};\n\nfetch("${i.settings.apiUrl}/v1/func/${t.nqName}/run", requestOptions)\n .then(response => response.text())\n .then(result => console.log(result))\n .catch(error => console.log('error', error));`,a=o.tabControl({CURL:o.div([o.divText(n)]),JS:o.div([o.divText(r)])});return s.Widget.fromRoot(a.root)})}function h(t){const e=document.cookie.match(new RegExp("(?:^|; )"+t.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):void 0}function f(t){const{segment:e,viewName:n,ViewClass:o,setStartUriLoaded:r,getStartUriLoaded:u}=t,c=o.findOrCreateCatalogView(n);return function(t,e){const{funcName:n,_package:i}=e;if(!t.parentCall){const e=s.Func.find({package:i.name,name:n})[0].prepare();t.parentCall=e}}(c,t),u()||(r(),setTimeout(()=>l(this,void 0,void 0,function*(){return yield function(t){return l(this,void 0,void 0,function*(){const e=new URL(i.shell.startUri).pathname.split("/"),n=e.findIndex(e=>e.toLocaleLowerCase()===t.toLocaleLowerCase());if(n>0&&n+1<e.length){const t=e[n+1],o=yield i.dapi.functions.filter(`shortName = "${t}" and #model`).list();if(1==o.length){const t=o[0],e=yield a.s.getUserGroups(),n=a.s.getMissingGroups(t,e);(null==n?void 0:n.length)?i.shell.error(`User is not a part of the following user groups: ${n.map(t=>t.name).join(",")}`):a.s.openModel(t)}}})}(e)}))),c}function m(t){return l(this,void 0,void 0,function*(){const e="Uncategorized",n=yield i.dapi.functions.filter("(#model)").list(),o=n.reduce((t,n)=>(n.options.department?t.add(n.options.department):t.add(e),t),new Set([])),s=n.reduce((t,n)=>(n.options.HL_process?t.add(n.options.HL_process):t.add(e),t),new Set([])),a=n.reduce((t,n)=>(n.options.process?t.add(n.options.process):t.add(e),t),new Set([]));for(const l of o){const o=l!==e?l:void 0;if(!n.find(t=>t.options.department===o))continue;const u=t.getOrCreateGroup(l,null,!1);for(const t of s){const s=t!==e?t:void 0;if(!n.find(t=>t.options.department===o&&t.options.HL_process===s))continue;const c=t!==e?u.getOrCreateGroup(t,null,!1):u;for(const u of a){const a=u!==e?u:void 0;if(!n.find(t=>t.options.department===o&&t.options.HL_process===s&&t.options.process===a))continue;const d=u!==e?c.getOrCreateGroup(u,null,!1):c;d.onNodeExpanding.pipe((0,r.take)(1)).subscribe(()=>{const n=`(${["(#model)",l===e?"(options.department = null)":`(options.department in ("${l}"))`,t===e?"(options.HL_process = null)":`(options.HL_process in ("${t}"))`,u===e?"(options.process = null)":`(options.process in ("${u}"))`].join(" and ")})`;d.loadSources(i.dapi.functions.filter(n))})}}}})}},428:(t,e,n)=>{"use strict";n.d(e,{T:()=>i});class i{constructor(t){this.parent=t}}},500:(t,e,n)=>{"use strict";n.d(e,{No:()=>u,ex:()=>l});var i=n(4328),o=n(6082);const s="Unsupported output type.",r="Funccall array is empty.";function a(t,e){const n=t.rowCount,s=e.value.row;if(null!==s)return t.columns.names().map(t=>({idx:s,columnName:t}));const r=t.col(e.value.colName);if(null===r)return i.shell.warning(`Output dataframe "${t.name}" doesn't contain the "${e.value.colName}" column. The last row is analyzed.`),t.columns.names().map(t=>({idx:n-1,columnName:t}));if(r.type!==o.COLUMN_TYPE.INT&&r.type!==o.COLUMN_TYPE.FLOAT)return i.shell.warning(`Non-supported type of the "${e.value.colName}" column: ${r.type}. Last row of the output dataframe "${t.name}" is analyzed.`),t.columns.names().map(t=>({idx:n-1,columnName:t}));const a=r.getRawData(),l=e.value.colValue;let u,c=0,d=Math.abs(a[0]-l);for(let t=1;t<n;++t)u=Math.abs(a[t]-l),u<d&&(d=u,c=t);return t.columns.names().map(t=>({idx:c,columnName:t}))}function l(t,e){var n,i,l;if(t.length<1)throw new Error(r);const u=t.length,c=function(t,e){const n=[];for(const i of e)i.prop.propertyType==o.TYPE.DATA_FRAME?n.push({prop:i.prop,elements:a(t.outputs[i.prop.name],i)}):n.push({prop:i.prop,elements:[]});return n}(t[0],e),d=function(t,e,n){var i;const r=[];for(const a of e){const e=a.prop,l=e.name;switch(e.propertyType){case o.TYPE.BIG_INT:case o.TYPE.INT:case o.TYPE.FLOAT:r.push(o.Column.fromType(e.propertyType,l,n));break;case o.TYPE.DATA_FRAME:const u=t.outputs[l];if(a.elements)for(const t of a.elements)r.push(o.Column.fromType(null===(i=u.col(t.columnName))||void 0===i?void 0:i.type,t.columnName,n));break;default:throw new Error(s)}}return o.DataFrame.fromColumns(r)}(t[0],c,u);for(let e=0;e<u;++e)for(const r of c){const a=r.prop,u=a.name,c=t[e];switch(a.propertyType){case o.TYPE.BIG_INT:case o.TYPE.INT:case o.TYPE.FLOAT:null===(n=d.col(u))||void 0===n||n.set(e,c.outputs[u]);break;case o.TYPE.DATA_FRAME:const t=c.outputs[u],a=t.rowCount-1;if(r.elements)for(const n of r.elements)null===(i=d.col(n.columnName))||void 0===i||i.set(e,null===(l=t.col(n.columnName))||void 0===l?void 0:l.get(-1!==n.idx?n.idx:a));break;default:throw new Error(s)}}return d}function u(t,e){const n=function(t,e){return e.forEach(e=>{t.forEach(t=>{t.name===e.name&&(t.name=`${t.name} (input)`,e.name=`${e.name} (output)`)})}),t.concat(e)}(t,e),i=n.length;if(0===i)return o.DataFrame.create();const s=o.DataFrame.fromColumns([n[0]]);for(let t=1;t<i;++t)n[t].name=s.columns.getUnusedName(n[t].name),s.columns.add(n[t]);return s}},508:(t,e,n)=>{"use strict";n.d(e,{AK:()=>i.AK,S3:()=>i.S3}),n(1511),n(6873),n(9373),n(4214);var i=n(3188)},559:(t,e,n)=>{"use strict";n(4570),n(3763);var i=n(581);n(6657),i.H},581:(t,e,n)=>{"use strict";n.d(e,{H:()=>o});var i=n(3763);class o{constructor(t){this.ivp=t,this.outputNames=(0,i.A)(t)}}},804:(t,e,n)=>{"use strict";n.d(e,{$Q:()=>o,UK:()=>r,XR:()=>a,a4:()=>s,xu:()=>l});const i=1;function o(t,e,n){return t<e?e:t>n?n:t}function s(t,e){let n=0;const i=t.length;for(let o=0;o<i;++o)n+=Math.pow(t[o]-e[o],2);return Math.sqrt(n)}function r(t){const e=Math.floor(Math.random()*t.length);let n;do{n=Math.floor(Math.random()*t.length)}while(n===e);return[t[e],t[n]]}function a(t,e){const n=new Array(t);for(let i=0;i<t;++i)n[i]=new Float32Array(e);return n}function l(t){return!!Number.isInteger(t)&&t>=i}},810:(t,e,n)=>{"use strict";n.d(e,{Bu:()=>d,ZD:()=>p,fo:()=>h});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(4260),u=n(1599),c=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const d=t=>{var e,n;if(null===(e=t.options)||void 0===e?void 0:e.default)return JSON.parse(null===(n=t.options)||void 0===n?void 0:n.default);const i=t.defaultValue;return t.propertyType===s.TYPE.STRING&&i?i.substring(1,i.length-1):i};function p(t,e){e?(a()(t).addClass("ui-box").css({width:"auto",height:"auto"}),o.setUpdateIndicator(t,!0)):(o.setUpdateIndicator(t,!1),a()(t).removeClass("ui-box"))}const h=(t,e,n={parentView:void 0,parentCall:void 0})=>{var r,d;const p=e,h=[...p.inputs,...p.outputs].map(t=>(0,u.jJ)(t)).reduce((t,e)=>(t[e.name]?t[e.name].push(...e.config):t[e.name]=e.config,t),{}),f=e=>{var n;if(e.propertyType===s.TYPE.DATA_FRAME){const n=h[e.name].map(n=>{var i;let o=null!==(i=e.caption)&&void 0!==i?i:e.name;const r=s.Column.fromType(s.TYPE.DATA_FRAME,o,t.length);r.init(n=>{var i;return null!==(i=t[n].inputs[e.name])&&void 0!==i?i:t[n].outputs[e.name]});const a=m.columns.getUnusedName(`${r.name} (${n.type})`);return r.name=a,o=a,r.temp[l.NT]=n,m.columns.add(r),r});return n}{let i=null!==(n=e.caption)&&void 0!==n?n:e.name;const o=s.Column.fromType(e.propertyType,i,t.length);o.init(n=>{var i;return null!==(i=t[n].inputs[e.name])&&void 0!==i?i:t[n].outputs[e.name]});const r=m.columns.getUnusedName(o.name);return o.name=r,i=r,m.columns.add(o),[o]}},m=s.DataFrame.create(t.length),v=[];return t.forEach(t=>{var e;let n=null!==(e=t.options.title)&&void 0!==e?e:`${t.func.name} - ${(0,u.eK)(t)}`,i=2;for(;v.includes(n);)n=`${t.func.name} - ${(0,u.eK)(t)})\n .toLocaleString('en-us', {month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric'})} - ${i}`,i++;v.push(n)}),m.columns.add(s.Column.fromStrings(l._W,v)),m.name=(null===(r=n.parentCall)||void 0===r?void 0:r.func.name)?`${null===(d=n.parentCall)||void 0===d?void 0:d.func.name} - comparison`:`${e.name} - comparison`,p.inputs.forEach(t=>f(t)),p.outputs.forEach(t=>f(t)),i.events.onCurrentObjectChanged.subscribe(({sender:t})=>{if(t instanceof s.Column&&t.type===s.TYPE.DATA_FRAME&&i.shell.tv&&i.shell.tv.temp.isComparison&&[s.VIEWER.LINE_CHART,s.VIEWER.SCATTER_PLOT,s.VIEWER.HISTOGRAM,s.VIEWER.BOX_PLOT].includes(t.temp[l.NT].type)){i.shell.windows.showProperties=!0;const e=t=>{const e=t.get(0).clone();e.columns.addNew(l.eX,s.TYPE.STRING).init(t.dataFrame.get(l._W,0));for(let n=1;n<t.length;n++){const i=t.get(n).clone();i.columns.addNew(l.eX,s.TYPE.STRING).init(t.dataFrame.get(l._W,n));const o=[s.COLUMN_TYPE.INT,s.COLUMN_TYPE.FLOAT];for(let t=0;t<i.columns.length;t++){const n=i.columns.byIndex(t),r=e.columns.byIndex(t);n.type!==r.type&&o.includes(n.type)&&o.includes(r.type)&&(n.type!==s.COLUMN_TYPE.FLOAT&&i.columns.replace(n,n.convertTo(s.COLUMN_TYPE.FLOAT)),r.type!==s.COLUMN_TYPE.FLOAT&&e.columns.replace(r,r.convertTo(s.COLUMN_TYPE.FLOAT)))}e.append(i,!0)}return e},n=t.temp[l.NT].look;setTimeout(()=>{switch(t.temp[l.NT].type){case s.VIEWER.LINE_CHART:const r=o.waitBox(()=>c(void 0,void 0,void 0,function*(){var i;const o=null!==(i=t.temp.unitedDf)&&void 0!==i?i:e(t);return t.temp.unitedDf=o,o.plot.line(Object.assign(Object.assign({},n),{split:l.eX})).root}));a()(r).css({width:"100%"}),i.shell.o=r;break;case s.VIEWER.SCATTER_PLOT:const u=o.waitBox(()=>c(void 0,void 0,void 0,function*(){var i;const o=null!==(i=t.temp.unitedDf)&&void 0!==i?i:e(t);return t.temp.unitedDf=o,o.plot.scatter(Object.assign(Object.assign({},n),{color:l.eX})).root}));i.shell.o=u,a()(u).css({width:"100%"});break;case s.VIEWER.HISTOGRAM:const d=o.waitBox(()=>c(void 0,void 0,void 0,function*(){var i;const o=null!==(i=t.temp.unitedDf)&&void 0!==i?i:e(t);return t.temp.unitedDf=o,o.plot.histogram(Object.assign(Object.assign({},n),{split:l.eX})).root}));i.shell.o=d,a()(d).css({width:"100%"});break;case s.VIEWER.BOX_PLOT:const p=o.waitBox(()=>c(void 0,void 0,void 0,function*(){var i;const o=null!==(i=t.temp.unitedDf)&&void 0!==i?i:e(t);return t.temp.unitedDf=o,o.plot.box(Object.assign(Object.assign({},n),{category:l.eX})).root}));i.shell.o=p,a()(p).css({width:"100%"})}})}}),m}},847:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(5516),o=n.n(i),s=n(1364),r=n.n(s)()(o());r.push([t.id,'.model-catalog-view .d4-gallery-card.entity-model i.grok-icon {\n height: 64px;\n width: 64px;\n position: initial;\n flex-shrink: 0;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model .d4-link-label i.grok-icon + label {\n margin-left: 6px;\n align-items: center;\n display: inline-flex;\n white-space: normal;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model {\n padding: 0 8px;\n align-items: center;\n display: flex;\n margin: 0;\n height: 94px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid {\n flex-direction: row!important;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label i.grok-icon {\n width: 32px;\n height: 32px;\n position: initial;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label label {\n margin-left: 8px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid .d4-link-label {\n min-width: 250px;\n margin-bottom: 9px;\n color: var(--grey-6);\n padding: 10px;\n width: initial;\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 20px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 16px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group .d4-tree-view-node {\n font-size: 14px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-video {\n width: 80%;\n height: 0;\n padding-bottom: 50%;\n margin: 10px 10px 0 0;\n border: 1px solid var(--grey-2);\n position: relative;\n background-size: cover;\n background-repeat: no-repeat;\n}\n\n.model-catalog-video i {\n position: absolute;\n right: 0;\n left: 0;\n bottom: 0;\n top: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-weight: 600;\n color: var(--grey-2);\n font-size: 42px;\n}\n\n.model-catalog-video i:hover {\n color: var(--grey-1);\n}\n\n.model-catalog-description {\n padding: 10px 0 0 0;\n}',"",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/model-catalog/css/model-card.css"],names:[],mappings:"AAAA;IACI,YAAY;IACZ,WAAW;IACX,iBAAiB;IACjB,cAAc;AAClB;;AAEA;IACI,gBAAgB;IAChB,mBAAmB;IACnB,oBAAoB;IACpB,mBAAmB;AACvB;;AAEA;IACI,cAAc;IACd,mBAAmB;IACnB,aAAa;IACb,SAAS;IACT,YAAY;AAChB;;AAEA;IACI,6BAA6B;AACjC;;AAEA;IACI,WAAW;IACX,YAAY;IACZ,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;AACpB;;AAEA;IACI,gBAAgB;IAChB,kBAAkB;IAClB,oBAAoB;IACpB,aAAa;IACb,cAAc;AAClB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,oBAAoB;AACxB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,oBAAoB;AACxB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,oBAAoB;AACxB;;AAEA;IACI,UAAU;IACV,SAAS;IACT,mBAAmB;IACnB,qBAAqB;IACrB,+BAA+B;IAC/B,kBAAkB;IAClB,sBAAsB;IACtB,4BAA4B;AAChC;;AAEA;IACI,kBAAkB;IAClB,QAAQ;IACR,OAAO;IACP,SAAS;IACT,MAAM;IACN,aAAa;IACb,mBAAmB;IACnB,uBAAuB;IACvB,gBAAgB;IAChB,oBAAoB;IACpB,eAAe;AACnB;;AAEA;IACI,oBAAoB;AACxB;;AAEA;IACI,mBAAmB;AACvB",sourcesContent:['.model-catalog-view .d4-gallery-card.entity-model i.grok-icon {\n height: 64px;\n width: 64px;\n position: initial;\n flex-shrink: 0;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model .d4-link-label i.grok-icon + label {\n margin-left: 6px;\n align-items: center;\n display: inline-flex;\n white-space: normal;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model {\n padding: 0 8px;\n align-items: center;\n display: flex;\n margin: 0;\n height: 94px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid {\n flex-direction: row!important;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label i.grok-icon {\n width: 32px;\n height: 32px;\n position: initial;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label label {\n margin-left: 8px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid .d4-link-label {\n min-width: 250px;\n margin-bottom: 9px;\n color: var(--grey-6);\n padding: 10px;\n width: initial;\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 20px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 16px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group .d4-tree-view-node {\n font-size: 14px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-video {\n width: 80%;\n height: 0;\n padding-bottom: 50%;\n margin: 10px 10px 0 0;\n border: 1px solid var(--grey-2);\n position: relative;\n background-size: cover;\n background-repeat: no-repeat;\n}\n\n.model-catalog-video i {\n position: absolute;\n right: 0;\n left: 0;\n bottom: 0;\n top: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-weight: 600;\n color: var(--grey-2);\n font-size: 42px;\n}\n\n.model-catalog-video i:hover {\n color: var(--grey-1);\n}\n\n.model-catalog-description {\n padding: 10px 0 0 0;\n}'],sourceRoot:""}]);const a=r},873:(t,e,n)=>{"use strict";n.d(e,{E:()=>M});var i=n(4328),o=n(7389),s=n(6082),r=n(3508),a=n.n(r),l=n(1991),u=n.n(l),c=n(1757),d=n.n(c),p=n(1858),h=n(9713),f=n(1927),m=n(4260),v=n(7375),g=(n(5940),n(2244)),y=n(1491),b=n(984),A=n(3902),w=n(5092),C=n(7722),I=n(8920),T=n(4795),E=n(5355),S=n(810),x=n(1599),R=n(3143),O=n(4386),N=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const F=()=>o.divText("[No data to display]",{style:{"text-align":"center","align-content":"center",width:"100%",height:"100%"}});class M extends g.s{static fromFuncCall(t,e={historyEnabled:!0,isTabbed:!1}){return new this(t,e)}constructor(t,e={historyEnabled:!0,isTabbed:!1}){super(t,e),this.options=e,this.inputValidationRequests=new p.Subject,this.outputValidationRequests=new p.Subject,this.inputValidationUpdates=new p.Subject,this.outputValidationUpdates=new p.Subject,this.runRequests=new p.Subject,this.isRunning=new p.BehaviorSubject(!1),this.isUploadMode=new p.BehaviorSubject(!1),this.inputsOverride={},this.inputsMap={},this.outputValidationSigns={},this.inputValidators={},this.outputValidators={},this.inputValidationState={},this.outputValidationState={},this.externalValidatorsUpdates=new p.Subject,this.externalValidatorsState={},this.pendingInputValidations=this.inputValidationUpdates.pipe((0,h.startWith)(null),(0,h.map)(()=>this.inputValidationState)),this._isOutputOutdated=new p.BehaviorSubject(!0),this.isOutputOutdated=this._isOutputOutdated.pipe((0,h.distinctUntilChanged)()),this.blockRuns=new p.BehaviorSubject(!1),this.prevOpenedTab=null,this.beforeInputPropertyRender=new p.Subject,this.afterInputPropertyRender=new p.Subject,this.afterOutputPropertyRender=new p.Subject,this.afterOutputSacalarTableRender=new p.Subject,this.formButtons=o.div(),this.additionalBtns=[],this.navBtns=[],this.tabsElem=o.tabControl(),this.dfToViewerMapping={},this.focusedInput=null,this.foldedCategoryInputs={},this.richFunctionExport=t=>N(this,void 0,void 0,function*(){if(!this.lastCall)throw new Error("Function was not called");if(!this.exportConfig.supportedFormats.includes(t))throw new Error(`Format "${t}" is not supported.`);if(!this.func)throw new Error("The correspoding function is not specified");const[e]=yield(0,O.aK)(t,this.func,this.lastCall,this.dfToViewerMapping);return e}),this.exportConfig={supportedExtensions:this.richFunctionViewExportExtensions(),supportedFormats:this.richFunctionViewSupportedFormats(),export:this.richFunctionExport,filename:this.defaultExportFilename}}onFuncCallReady(){const t=Object.create(null,{onFuncCallReady:{get:()=>super.onFuncCallReady}});return N(this,void 0,void 0,function*(){yield this.loadInputsOverrides(),yield this.loadValidators(I.bZ.INPUTS),yield this.loadValidators(I.bZ.OUTPUTS),yield t.onFuncCallReady.call(this);const e=this.funcCallReplaced.subscribe(()=>{this.inputValidationRequests.next({isRevalidation:!1}),this.outputValidationRequests.next({isRevalidation:!1})});this.subs.push(e);const n=t=>(0,h.mergeMap)(e=>e.pipe((0,h.tap)(e=>{t===I.bZ.INPUTS?this.setInputValidationPending(e.field):this.setOutputValidationPending(e.field)}),(0,h.switchMap)(e=>{const n=new AbortController,i=n.signal;let o=!1;return new p.Observable(s=>{const r=(0,p.from)(this.runValidation(Object.assign({},e),i,t)).subscribe(t=>{o=!0,s.next(t)});return()=>{o||n.abort(),r.unsubscribe()}}).pipe((0,h.tap)(n=>{t===I.bZ.INPUTS?this.setInputValidationResults(n):this.setOutputValidationResults(n),this.runRevalidations(e,n,t),t===I.bZ.INPUTS?this.inputValidationUpdates.next(null):this.outputValidationUpdates.next(null)}),(0,h.mapTo)(e))}))),s=this.inputValidationRequests.pipe((0,h.groupBy)(t=>t.field),n(I.bZ.INPUTS)).subscribe(t=>{t.field&&this.runningOnInput&&this.isRunnable()&&this.doRun()});this.subs.push(s);const r=this.outputValidationRequests.pipe((0,h.groupBy)(t=>t.field),n(I.bZ.OUTPUTS)).subscribe();this.subs.push(r);const a=this.externalValidatorsUpdates.subscribe(t=>{this.updateInputValidationResults(t)});this.subs.push(a);const l=(0,p.combineLatest)([this.runRequests.pipe((0,h.switchMap)(()=>(0,p.of)(!1).pipe((0,h.delay)(500),(0,h.startWith)(!0)))),this.inputValidationUpdates.pipe((0,h.debounceTime)(0))]).pipe((0,h.filter)(([t])=>t&&this.isRunnable())).subscribe(()=>this.doRun());this.subs.push(l);const u=this.options.isTabbed?null:yield this.loadLastInputs();if(u)i.shell.info(o.div([o.divText("Do you want to load last inputs?"),o.divH([o.bigButton("Load",()=>{for(const[t,e]of Object.entries(u)){const n=this.getInput(t);n.notify=!1,n.value=e,n.notify=!0,this.funcCall.inputs[t]=e,this.inputValidationRequests.next({field:t,isRevalidation:!1})}i.shell.info(o.divText("Change the loaded inputs to run computations"))})])]));else{const t=new AbortController,e=yield this.runValidation({isRevalidation:!1},t.signal);this.setInputValidationResults(e),this.runRevalidations({isRevalidation:!1},e),this.inputValidationUpdates.next(null),this.runningOnStart&&this.isRunnable()&&(yield this.doRun())}})}onBeforeRun(){return this.tabsElem.currentPane&&(this.prevOpenedTab=this.inputTabsLabels.includes(this.tabsElem.currentPane.name)?null:this.tabsElem.currentPane),Promise.resolve()}onAfterRun(){if(this.showOutput(),this.tabsElem.panes.forEach(t=>{d()(t.header).show()}),this.prevOpenedTab)return this.tabsElem.currentPane=this.prevOpenedTab,Promise.resolve();const t=this.tabsElem.panes.find(t=>this.outputTabsLabels.includes(t.name));return t&&(this.tabsElem.currentPane=t),Promise.resolve()}getRunButton(t="Run"){var e;const n=o.bigButton(null!==(e=(0,T.O0)(this.func))&&void 0!==e?e:t,()=>N(this,void 0,void 0,function*(){return yield this.doRun()})),i=(0,p.merge)(this.inputValidationUpdates,this.externalValidatorsUpdates,this.isRunning,this.blockRuns).subscribe(()=>{const t=this.isRunnable();n.disabled=!t});return this.subs.push(i),n}loadInputsOverrides(){return N(this,void 0,void 0,function*(){const t=[...this.funcCall.inputParams.values()];yield Promise.all(t.map(t=>N(this,void 0,void 0,function*(){if(t.property.options.input){const e=s.Func.byName(t.property.options.input).prepare({params:JSON.parse(t.property.options.inputOptions||"{}")});yield e.call(),this.inputsOverride[t.name]=e.outputs.input}})))})}loadValidators(){return N(this,arguments,void 0,function*(t=I.bZ.INPUTS){const e=yield(0,T.QL)(this.funcCall,t);t===I.bZ.INPUTS?this.inputValidators=e:this.outputValidators=e})}keepOutput(){var t;return"true"===(null===(t=this.func)||void 0===t?void 0:t.options.keepOutput)}getSaveButton(t="Save"){const e=o.bigButton(t,()=>N(this,void 0,void 0,function*(){return yield this.saveExperimentalRun(this.funcCall)}),"Save uploaded data"),n=this.isUploadMode.subscribe(t=>{this.buildRibbonPanels(),t?d()(e).show():d()(e).hide()});return this.subs.push(n),e}getStandardButtons(){const t=this.getRunButton(),e=o.div([t]);o.tooltip.bind(e,()=>t.disabled?this.isRunning.value?"Computations are in progress":this.getValidationMessage():"");const n=this.getSaveButton();return[...this.isHistoryEnabled&&!this.options.isTabbed?[n]:[],...this.runningOnInput?[]:[e]]}buildFormButtons(){var t;const e=this.getStandardButtons(),n=o.buttonsInput();return d()(n.firstChild).css({display:"none"}),null===(t=n.lastChild)||void 0===t||t.replaceWith(o.div([...this.navBtns,...this.additionalBtns,...e],"ui-input-editor")),d()(n).addClass("rfv-buttons"),d()(n).css({"max-width":"100%"}),this.formButtons.replaceWith(n),this.formButtons=n,n}setAdditionalButtons(t){this.additionalBtns=t,this.buildFormButtons()}setNavigationButtons(t){this.navBtns=t,this.buildFormButtons()}buildIO(){const{inputBlock:t,inputForm:e,outputForm:n,controlsWrapper:i}=this.buildInputBlock(),s=[...Array.from(e.childNodes),...this.isUploadMode.value?[Array.from(n.childNodes)]:[]];o.tools.handleResize(t,()=>{d()(t).width()<300?(d()(e).addClass("ui-form-condensed"),d()(n).addClass("ui-form-condensed"),d()(i).addClass("ui-form-condensed"),s.forEach(t=>d()(t).css("min-width","100px"))):(d()(e).removeClass("ui-form-condensed"),d()(n).removeClass("ui-form-condensed"),d()(i).removeClass("ui-form-condensed"),s.forEach(t=>d()(t).css("min-width","100%")))});const r=this.buildOutputBlock();r.style.height="100%",r.style.width="100%",this.hideOutput();const a=o.splitH([t,o.panel([r],{style:{paddingTop:"0px"}})],null,!0);return a.style.padding="0 12px",t.style.maxWidth="360px",a}buildInputBlock(){const t=this.renderInputForm(),e=this.renderOutputForm();this.buildFormButtons();const n=o.div(this.formButtons,"ui-form ui-form-wide");d()(n).css({"padding-left":"0px","padding-bottom":"0px","padding-right":"6px","max-width":"100%","min-height":"50px"});const i=o.input.toggle("",{value:this.isUploadMode.value,onValueChanged:t=>this.isUploadMode.next(t)}),s=this.isUploadMode.subscribe(t=>{i.notify=!1,i.value=t,i.notify=!0,t?d()(e).show():d()(e).hide()});return this.subs.push(s),{inputBlock:o.divV([t,...this.hasUploadMode&&!this.uploadFunc?[o.divH([o.h2("Experimental data"),i.root],{style:{flexGrow:"0"}}),e]:[],n],"ui-box rfv-form"),inputForm:t,outputForm:e,controlsWrapper:n}}processCustomDataUpload(){return N(this,void 0,void 0,function*(){const t=()=>{const t=s.Dialog.create({title:"Select to compare"}),e=new E.H(u.length>0?u:[...this.historyBlock.history.values()],{fallbackText:"No historical runs found",showActions:!(u.length>0),showBatchActions:!(u.length>0)}),n=new E.H(l,{fallbackText:"No runs uploaded",showActions:!1,showBatchActions:!1});t.add(o.divV([o.divV([o.label("Uploaded runs"),o.element("div","splitbar-horizontal"),n.root],{style:{height:"50%",overflowY:"hidden"}}),o.divV([o.label(u.length>0?"Simulated":"History",{style:{padding:"0px 10px 0px 9px"}}),o.element("div","splitbar-horizontal"),e.root],{style:{height:"50%",overflowY:"hidden"}})],{style:{justifyContent:"space-between",gap:"10px",overflowY:"scroll",height:"100%"}})),d()(t.root.querySelector(".d4-dialog-contents")).removeClass("ui-form");const i="Compare selected";return 0===u.length?t.addButton(i,()=>N(this,void 0,void 0,function*(){const i=yield Promise.all([...e.selected].map(t=>w.W.loadRun(t.id)));this.onComparisonLaunch([...i,...n.selected.values()]),t.close()})):t.addButton(i,()=>N(this,void 0,void 0,function*(){this.onComparisonLaunch([...e.selected.values(),...n.selected.values()]),t.close()})),t.getButton(i).disabled=!0,this.subs.push((0,p.merge)(e.onSelectedChanged,n.onSelectedChanged).subscribe(()=>{e.selected.size+n.selected.size>1?t.getButton(i).disabled=!1:t.getButton(i).disabled=!0})),this.isHistorical.value&&t.addButton(g,()=>N(this,void 0,void 0,function*(){this.onComparisonLaunch([this.funcCall,...n.selected.values()]),t.close()})),d()(t.getButton("CANCEL")).hide(),t},e=s.Func.byName(this.uploadFunc),n=yield e.prepare({params:{func:this.func}}).call(),r=n.outputs.uploadWidget,a=n.outputs.uploadFuncCall;let l=[],u=[];const c=s.Dialog.create({title:"Upload"});d()(c.root.querySelector(".d4-dialog-contents")).removeClass("ui-form");const f=s.Dialog.create({title:"Review uploaded runs"});d()(f.root.querySelector(".d4-dialog-contents")).removeClass("ui-form");const v="Save to history",g="Compare w/ current";c.add(r.root),c.addButton(v,()=>N(this,void 0,void 0,function*(){return(0,S.ZD)(c.root,!0),l.forEach(t=>{t.options.immutable_tags?t.options.immutable_tags.push(m.ec):t.options.immutable_tags=[m.ec]}),Promise.all(l.map(t=>N(this,void 0,void 0,function*(){const e=yield this.getValidExpRun(t);return w.W.saveRun(e)}))).then(t=>Promise.all(t.map(t=>w.W.loadRun(t.id)))).then(t=>{t.forEach(t=>this.historyBlock.addRun(t))}).catch(t=>{i.shell.error(t)}).finally(()=>{(0,S.ZD)(c.root,!1),c.close();const t=new E.H(l,{fallbackText:"No runs uploaded",showActions:!0,showBatchActions:!0});f.add(t),f.show({modal:!0,fullScreen:!0})})})),c.addButton("Next",()=>{c.close(),l.forEach(t=>{t.options.immutable_tags?t.options.immutable_tags.push(m.ec):t.options.immutable_tags=[m.ec]});const t=new E.H(l,{fallbackText:"No runs uploaded",showActions:!0,showBatchActions:!0});f.add(t.root),f.show({modal:!0,fullScreen:!0})}),d()(c.getButton("CANCEL")).hide(),c.getButton(v).disabled=!0,c.getButton("Next").disabled=!0,d()(f.getButton("CANCEL")).hide(),f.addButton("Simulate w/ same inputs",()=>{(0,S.ZD)(c.root,!0),Promise.all(l.map(t=>N(this,void 0,void 0,function*(){return(yield(0,T.Hs)(t)).call()}))).then(e=>{u=e,f.close(),t().show({modal:!0,fullScreen:!0})}).catch(t=>{i.shell.error(t)}).finally(()=>{(0,S.ZD)(c.root,!1)})}),f.addButton("Compare w/ history",()=>{f.close(),t().show({modal:!0,fullScreen:!0})});const y=i.functions.onAfterRunAction.pipe((0,h.filter)(t=>t.id===a.id)).subscribe(()=>{l=a.outputs.uploadedCalls,c.getButton(v).disabled=!1,c.getButton("Next").disabled=!1}),b=c.onClose.subscribe(()=>{this.isUploadMode.next(!1)});c.subs.push(b,y),c.show({modal:!0,center:!0,resizable:!0})})}onSaveClick(){return N(this,void 0,void 0,function*(){this.isUploadMode.value?yield this.saveExperimentalRun(this.funcCall):yield this.saveRun(this.funcCall)})}buildRibbonPanels(){super.buildRibbonPanels();const t=o.iconFA("play",()=>N(this,void 0,void 0,function*(){return yield this.doRun()}),"Run computations");t.classList.add("fas");const e=o.iconFA("arrow-to-top",()=>N(this,void 0,void 0,function*(){this.uploadFunc?yield this.processCustomDataUpload():(this.isUploadMode.next(!this.isUploadMode.value),e.classList.toggle("d4-current"))}),"Upload experimental data");e.classList.add("d4-toggle-button",...this.isUploadMode.value?["d4-current"]:[]);const n=(0,C.LC)();n.onclick=()=>N(this,void 0,void 0,function*(){return yield this.onSALaunch()});const s=(0,C.MP)();s.onclick=()=>N(this,void 0,void 0,function*(){return yield this.onFittingLaunch()});const r=(0,C.hk)();r.onclick=()=>N(this,void 0,void 0,function*(){return yield this.onOptimizationLaunch()});const a=o.iconFA("info",()=>N(this,void 0,void 0,function*(){this.hasContextHelp&&(i.shell.windows.help.visible=!0,yield new Promise(t=>setTimeout(t,100)),i.shell.windows.help.showHelp(o.markdown(yield this.getContextHelp())))})),l=[[...super.buildRibbonPanels().flat(),...this.runningOnInput||this.options.isTabbed?[]:[t],...this.hasUploadMode?[e]:[],...this.isFittingEnabled?[s]:[],...this.isSaEnabled?[n]:[],...this.isOptimizationEnabled?[r]:[],...!this.options.isTabbed&&this.hasContextHelp?[a]:[]]];return this.setRibbonPanels(l),l}showOutput(){o.setDisplay(this.tabsElem.root,!0),this._isOutputOutdated.next(!1)}getViewers(t){return this.dfToViewerMapping[t]}buildOutputBlock(){this.tabsElem.root.style.width="100%",this.tabsLabels.forEach(t=>{const[e,n]=this.categoryToDfParamMap.outputs[t]?[this.categoryToDfParamMap.outputs[t],!1]:[this.categoryToDfParamMap.inputs[t],!0],r=e.filter(t=>t.propertyType===s.TYPE.DATA_FRAME||t.propertyType===s.TYPE.GRAPHICS),a=e.filter(t=>t.propertyType!==s.TYPE.DATA_FRAME&&t.propertyType!==s.TYPE.GRAPHICS),l=r.map(t=>(0,x.jJ)(t).config);let u="";const c=r.reduce((t,e,r)=>{var a,c;this.dfToViewerMapping[e.name]=[];const p=l[r].map((t,n)=>N(this,void 0,void 0,function*(){var n,r,a,l;const u=null!==(l=null!==(r=null===(n=this.funcCall.outputs[e.name])||void 0===n?void 0:n.value)&&void 0!==r?r:null===(a=this.funcCall.inputParams[e.name])||void 0===a?void 0:a.value)&&void 0!==l?l:i.data.demo.demog(0),c=t.type,d=Object.values(m.CB).includes(c)?s.Viewer.fromType(c,u):yield u.plot.fromType(c);d.setOptions(t),this.dfToViewerMapping[e.name].push(d),this.afterOutputPropertyRender.next({prop:e,output:d});const p=F();return 0===u.rowCount&&"demog 0"===u.name&&(o.setDisplay(d.root,!1),o.setDisplay(p,!0)),{viewer:d,stub:p}})),v=p.map((t,n)=>t.then(({viewer:t,stub:i})=>{const s=this.funcCallReplaced.pipe((0,h.startWith)(null),(0,h.switchMap)(()=>{var t;return(null!==(t=this.funcCall.outputParams[e.name])&&void 0!==t?t:this.funcCall.inputParams[e.name]).onChanged.pipe((0,h.startWith)(null))}),(0,h.skip)(1)).subscribe(()=>N(this,void 0,void 0,function*(){var s;const a=null!==(s=this.funcCall.outputParams[e.name])&&void 0!==s?s:this.funcCall.inputParams[e.name];if(a.value){if(o.setDisplay(t.root,!0),o.setDisplay(i,!1),Object.values(m.CB).includes(t.type))t.dataFrame=a.value;else{const e=yield a.value.plot.fromType(t.type);t.root.replaceWith(e.root),t=e}Object.keys(l[r][n]).includes("color")&&t.setOptions({color:l[r][n].color}),this.afterOutputPropertyRender.next({prop:e,output:t})}else o.setDisplay(t.root,!1),o.setDisplay(i,!0)}));return this.subs.push(s),{loadedViewer:t,stub:i}})),g=u!==(null!==(a=e.options.caption)&&void 0!==a?a:e.name)?null!==(c=e.options.caption)&&void 0!==c?c:e.name:" ";if(u=g,n){const t=this.funcCallReplaced.pipe((0,h.switchMap)(()=>{var t;return(null!==(t=this.funcCall.outputParams[e.name])&&void 0!==t?t:this.funcCall.inputParams[e.name]).onChanged})).subscribe(()=>{this.showOutput(),this.inputTabsLabels.forEach(t=>{d()(this.tabsElem.getPane(t).header).show()})});this.subs.push(t)}const y=v.map((t,n)=>{const i=l[r][n].block,s=o.wait(()=>N(this,void 0,void 0,function*(){const e=yield t;return d()(e.loadedViewer.root).css({height:"100%",width:"100%"}),o.divV([e.loadedViewer.root,e.stub],{style:{width:"100%"}})}));d()(s).css({"min-height":"300px","flex-grow":"1"});const a=(0,f.JC)();return this.outputValidationSigns[e.name]=a,o.divV([o.divH([o.h2(0===n?g:" ",{style:{whiteSpace:"pre"}}),...0===n?[o.div([this.outputValidationSigns[e.name][0],this.outputValidationSigns[e.name][1]],{style:{margin:"10.79px"}})]:[]]),s],{style:Object.assign({},i?{width:`${i}%`,"max-width":`${i}%`,"max-height":"100%"}:{"flex-grow":"1"})})});if(e.propertyType===s.TYPE.GRAPHICS){const n=e.options.block,i=F();i.classList.add("grok-scripting-image-container");const s=o.divV([o.h2(g,{style:{whiteSpace:"pre"}}),i],{style:Object.assign({},n?{width:`${n}%`,"max-width":`${n}%`,"max-height":"100%"}:{"flex-grow":"1"})}),r=()=>{var t;const n=null!==(t=this.funcCall.outputParams[e.name])&&void 0!==t?t:this.funcCall.inputParams[e.name];n.value?(i.style.backgroundImage=`url("data:image/png;base64,${n.value}")`,i.textContent=""):(i.style.removeProperty("background-image"),i.textContent="[No data to display]")},a=this.funcCallReplaced.pipe((0,h.startWith)(null),(0,h.switchMap)(()=>{var t;return(null!==(t=this.funcCall.outputParams[e.name])&&void 0!==t?t:this.funcCall.inputParams[e.name]).onChanged.pipe((0,h.startWith)(null))}),(0,h.skip)(1)).subscribe(r);this.subs.push(a),t.append(s)}return t.append(...y),t},o.divH([],{style:{flexWrap:"wrap",flexGrow:"1",maxHeight:"100%"}}));a.forEach(t=>{const e=(0,f.JC)();this.outputValidationSigns[t.name]=e});const v=()=>{const t=s.HtmlTable.create(a,t=>{var e;const n=t.options.precision,i=n&&t.propertyType===s.TYPE.FLOAT&&this.funcCall.outputs[t.name]?this.funcCall.outputs[t.name].toPrecision(n):this.funcCall.outputs[t.name],r=t.options.units?` [${t.options.units}]`:"";return[`${null!==(e=t.caption)&&void 0!==e?e:t.name}${r}`,null!=i?i:"[No value]",o.div([this.outputValidationSigns[t.name][0],this.outputValidationSigns[t.name][1]])]}).root;return d()(t).addClass("rfv-scalar-table"),this.afterOutputSacalarTableRender.next(t),t};let g=v();const y=(0,p.merge)(this.funcCallReplaced,this.isRunning.pipe((0,h.filter)(t=>!1===t),(0,h.skip)(1))).subscribe(()=>{const e=v();g.replaceWith(e),g=e,d()(this.tabsElem.getPane(t).header).show()});this.subs.push(y),this.tabsElem.addPane(t,()=>o.divV([...r.length?[c]:[],...a.length?[g]:[]]))});const t=o.box();return t.append(this.tabsElem.root),t}onAfterLoadRun(t){return N(this,void 0,void 0,function*(){this.showOutput()})}get tabsLabels(){return[...this.inputTabsLabels,...this.outputTabsLabels]}get outputTabsLabels(){return Object.keys(this.categoryToDfParamMap.outputs)}get inputTabsLabels(){return Object.keys(this.categoryToDfParamMap.inputs)}get categoryToDfParamMap(){return(0,T.r6)(this.funcCall.func)}get inputsStorage(){return`RFV_LastInputs_${this.funcCall.func.name}`}saveLastInputs(){return N(this,void 0,void 0,function*(){try{const t=u()(this.funcCall.inputParams.values()).reduce((t,e)=>{const n=e.property.propertyType!==s.TYPE.DATA_FRAME?this.funcCall.inputs[e.name]:Array.from(this.funcCall.inputs[e.name].toByteArray());return Object.assign(Object.assign({},t),{[e.name]:n})},{});return localStorage.setItem(this.inputsStorage,JSON.stringify(t))}catch(t){i.shell.error(t.toString())}})}loadLastInputs(){return N(this,void 0,void 0,function*(){var t;try{const e=JSON.parse(null!==(t=localStorage.getItem(this.inputsStorage))&&void 0!==t?t:"{}");return 0===Object.keys(e).length?null:u()(this.funcCall.inputParams.values()).reduce((t,n)=>{const i=n.property.propertyType!==s.TYPE.DATA_FRAME?e[n.name]:s.DataFrame.fromByteArray(new Uint8Array(e[n.name]));return Object.assign(Object.assign({},t),{[n.name]:i})},{})}catch(t){i.shell.error(t.toString())}})}deleteLastInputs(){return N(this,void 0,void 0,function*(){try{return localStorage.removeItem(this.inputsStorage)}catch(t){i.shell.error(t.toString())}})}doRun(){return N(this,void 0,void 0,function*(){this.isRunning.next(!0);try{this.options.isTabbed||(yield this.saveLastInputs()),yield this.run(),this.options.isTabbed||(yield this.deleteLastInputs())}catch(t){i.shell.error(t.toString()),console.log(t)}finally{this.isRunning.next(!1),this.inputValidationRequests.next({isRevalidation:!1,isNewOutput:!0}),this.outputValidationRequests.next({isRevalidation:!1})}})}setExternalValidationResults(t,e){this.externalValidatorsState[t]=e,this.externalValidatorsUpdates.next(t)}saveInputLockState(t,e,n){"restricted"===n&&(this.funcCall.options[I.AY]=Object.assign(Object.assign({},this.funcCall.options[I.AY]),{[t]:e})),n&&(this.funcCall.options[I.Jl]=Object.assign(Object.assign({},this.funcCall.options[I.Jl]),{[t]:n})),this.updateConsistencyState()}getInputLockState(t){var e;return null===(e=this.funcCall.options[I.Jl])||void 0===e?void 0:e[t]}updateConsistencyState(){const t=Object.values(this.funcCall.options[I.Jl]).some(t=>"inconsistent"===t);this.consistencyState.next(t?"inconsistent":"consistent")}getInput(t){return this.inputsMap[t]}setInput(t,e,n){const i=this.getInput(t);if(!i)throw new Error(`No input named ${t}`);if(this.funcCall.inputParams[t].property.propertyType===s.TYPE.DATA_FRAME&&"restricted"===n)throw new Error(`Param ${t} is dataframe. Restricted state is not supported for them.`);n||(n=this.funcCall.inputParams[t].property.propertyType===s.TYPE.DATA_FRAME?"disabled":"restricted"),this.funcCall.inputs[t]=e,this.setInputLockState(i,t,e,n)}getParamChanges(t){return this.funcCallReplaced.pipe((0,h.startWith)(null),(0,h.filter)(()=>!!this.funcCall),(0,h.map)(()=>this.funcCall.inputParams[t]?"inputParams":"outputParams"),(0,h.switchMap)(e=>this.funcCall[e][t].onChanged.pipe((0,h.startWith)(null),(0,h.map)(()=>this.funcCall[e][t].value))))}getParamValue(t){var e,n;const i=(null===(e=this.funcCall)||void 0===e?void 0:e.inputParams[t])?"inputParams":"outputParams";return null===(n=this.funcCall)||void 0===n?void 0:n[i][t].value}setInputLockState(t,e,n,i){i&&this.saveInputLockState(e,n,i),(0,v.gD)(t)&&("disabled"===i&&t.setDisabled(),"restricted"===i&&t.setRestricted(),"restricted unlocked"===i&&t.setRestrictedUnlocked(),"inconsistent"===i&&t.setInconsistent(),"user input"===i&&t.setUserInput())}getRestrictedValue(t){var e;return null===(e=this.funcCall.options[I.AY])||void 0===e?void 0:e[t]}renderOutputForm(){return this.renderIOForm(I.bZ.OUTPUTS)}onSALaunch(){return N(this,void 0,void 0,function*(){yield y.n.fromEmpty(this.func)})}onFittingLaunch(){return N(this,void 0,void 0,function*(){yield A.v.fromEmpty(this.func)})}onOptimizationLaunch(){return N(this,void 0,void 0,function*(){yield b.$.fromEmpty(this.func)})}renderInputForm(){return this.renderIOForm(I.bZ.INPUTS)}renderIOForm(t){const e=o.divH([],"ui-form ui-form-wide");d()(e).css({"flex-wrap":"wrap","flex-grow":"0","padding-right":"12px","padding-top":"0px","padding-left":"0px","max-width":"100%",gap:"4px"});let n="Misc";const i=this.funcCall[I.wl[t]].values();return u()(i).filter(t=>!!t).forEach(i=>{const o=i.property;this.beforeInputPropertyRender.next(o);const s=this.getInputForVal(i);s?(this.inputsMap[i.property.name]=s,t===I.bZ.INPUTS&&(this.syncInput(i,s,t),this.checkForMapping(i,s),this.runningOnInput||this.disableInputsOnRun(i.property.name,s),this.bindOnHotkey(s)),this.renderCategory(e,i.property.category,n),this.renderInput(e,i,s),this.afterInputPropertyRender.next({prop:o,input:s}),n=o.category):n=o.category}),Object.keys(this.foldedCategoryInputs).forEach(t=>this.foldedCategoryInputs[t].forEach(t=>d()(t.input.root).hide())),e.classList.remove("ui-panel"),e}saveFocusedElement(t){this.focusedInput=t}restoreFocusedElement(){var t;null===(t=this.focusedInput)||void 0===t||t.focus()}disableInputsOnRun(t,e){const n=this.isRunning.subscribe(n=>{"user input"!==this.getInputLockState(t)&&this.getInputLockState(t)||(n?((0,T.KL)(e)&&d()(e.input).is(":focus")&&this.saveFocusedElement(e.input),e.enabled=!1):(e.enabled=!0,(0,T.KL)(e)&&this.restoreFocusedElement()))});this.subs.push(n)}checkForMapping(t,e){if(!e.hasOwnProperty("_chosenRun"))return;const n=t.property.options.funccallMapping;if(!n)return;const i=JSON.parse(n),o=this.funcCallReplaced.pipe((0,h.startWith)(!0),(0,h.switchMap)(()=>this.funcCall.inputParams[t.property.name].onChanged)).subscribe(()=>{Object.entries(i).forEach(([t,n])=>this.setInput(t,e.chosenRun?(t=>{var n,i,o,s,r,a;return null!==(a=null!==(s=null!==(i=null===(n=e.chosenRun)||void 0===n?void 0:n.inputs[t])&&void 0!==i?i:null===(o=e.chosenRun)||void 0===o?void 0:o.outputs[t])&&void 0!==s?s:null===(r=e.chosenRun)||void 0===r?void 0:r.options[t])&&void 0!==a?a:null})(n):(0,S.Bu)(this.funcCall.inputParams[t].property),e.chosenRun?"restricted":"user input"))});this.subs.push(o)}getInputForVal(t){var e,n;const i=t.property;if(this.inputsOverride[t.property.name])return this.inputsOverride[t.property.name];if(i.propertyType===s.TYPE.STRING&&i.options.choices&&!i.options.propagateChoice)return o.input.choice(null!==(e=i.caption)&&void 0!==e?e:i.name,{value:(0,S.Bu)(i),items:JSON.parse(i.options.choices),nullable:i.nullable});switch(i.propertyType){case"file":return R.A.fileInput(null!==(n=i.caption)&&void 0!==n?n:i.name,null,null,null);case s.TYPE.FLOAT:const t=o.input.forProperty(i),e=i.options.format;return e&&(t.format=e),t;default:return o.input.forProperty(i)}}bindOnHotkey(t){(0,T.KL)(t)&&(t.input.onkeydown=t=>N(this,void 0,void 0,function*(){"Enter"==t.key&&this.runRequests.next()}))}get foldedCategories(){var t;return JSON.parse(null!==(t=this.func.options.foldedCategories)&&void 0!==t?t:"[]")}getCategoryWarningIcon(t){const e=o.iconFA("exclamation-circle",null,"This category has inconsistent inputs");d()(e).css({color:"var(--orange-2)","padding-left":"5px"}).hide();const n=this.funcCallReplaced.subscribe(()=>{this.foldedCategoryInputs[t].some(t=>"inconsistent"===this.getInputLockState(t.paramName)&&t.input.value!==this.getRestrictedValue(t.paramName))?d()(e).show():d()(e).hide()});return this.subs.push(n),e}renderCategory(t,e,n){if(e!==n)if(this.foldedCategories.includes(e)){const n=this.getCategoryWarningIcon(e),i=o.iconFA("chevron-right",()=>{var t;d()(s).show(),d()(i).hide(),d()(n).hide(),(null!==(t=this.foldedCategoryInputs[e])&&void 0!==t?t:[]).forEach(t=>d()(t.input.root).css({display:""}))},"Open category");d()(i).css("padding-right","5px");const s=o.iconFA("chevron-down",()=>{var t;d()(s).hide(),d()(i).show(),this.foldedCategoryInputs[e].some(t=>"inconsistent"===this.getInputLockState(t.paramName))?d()(n).show():d()(n).hide(),(null!==(t=this.foldedCategoryInputs[e])&&void 0!==t?t:[]).forEach(t=>d()(t.input.root).hide())},"Close category");d()(s).css("padding-right","5px"),t.append(o.h2([i,s,o.h2(e,{style:{display:"inline"}}),n],{style:{width:"100%"}})),d()(s).hide()}else t.append(o.h2(e,{style:{width:"100%"}}))}renderInput(t,e,n){var i;const o=e.property;this.foldedCategories.includes(o.category)&&(this.foldedCategoryInputs[o.category]=[...null!==(i=this.foldedCategoryInputs[o.category])&&void 0!==i?i:[],{paramName:e.property.name,input:n}]),this.injectLockIcons(e,n),(0,T.JU)(n),(0,T.KL)(n)&&((0,T.hg)(e,n),this.bindTooltips(e,n),(0,T._t)(n)),t.append(n.root)}bindTooltips(t,e){const n=t.property.name,i=()=>{var e,i;const s=`${null!==(i=null!==(e=t.property.description)&&void 0!==e?e:t.property.caption)&&void 0!==i?i:t.property.name}.`,r=(()=>"disabled"===this.getInputLockState(n)?"Input is disabled to prevent inconsistency.":"inconsistent"===this.getInputLockState(n)?"The entered value is inconsistent to the computed value.":"restricted"===this.getInputLockState(n)?"The value is dependent and computed automatically. Click to edit":null)();return s||r?o.divV([...s?[o.divText(s)]:[],...r?[o.divText(r)]:[]],{style:{maxWidth:"300px"}}):null};o.tooltip.bind(e.captionLabel,i),o.tooltip.bind(e.input,i)}injectLockIcons(t,e){const n=t.property.name;e.root.addEventListener("click",()=>{"restricted"===this.getInputLockState(n)&&this.setInputLockState(e,t.name,t.value,"restricted unlocked")});const i=o.iconFA("lock");d()(i).addClass("rfv-icon-lock"),d()(i).css({color:"var(--grey-2)"});const r=o.iconFA("lock-open");d()(r).addClass("rfv-icon-unlock"),d()(r).css({color:"var(--grey-2)"});const a=o.iconFA("undo",e=>{this.setInput(t.name,this.getRestrictedValue(n),"restricted"),e.stopPropagation()},"Reset value to computed value");d()(a).addClass("rfv-icon-undo"),d()(a).css({color:"var(--blue-2)"});const l=o.iconFA("exclamation-circle",null);o.tooltip.bind(l,()=>`Current value is incosistent. Computed value was ${s.TYPES_SCALAR.has(t.property.propertyType)?this.getRestrictedValue(n):"different"}`),d()(l).addClass("rfv-icon-warning"),d()(l).css({color:"var(--orange-2)"});const u=e;u.placeLockStateIcons||(u.placeLockStateIcons=function(t,n,i,o){(0,T.KL)(e)&&(e.addOptions(t),e.addOptions(n),e.addOptions(i),e.addOptions(o))}),u.placeLockStateIcons(i,r,a,l)}syncInput(t,e,n){const i=t.name;let o=!1;const r=this.funcCallReplaced.pipe((0,h.startWith)(!0)).subscribe(()=>{var t,o;const s=this.funcCall[I.wl[n]][i],r=null!==(o=null!==(t=this.funcCall[n][i])&&void 0!==t?t:(0,S.Bu)(s.property))&&void 0!==o?o:null;e.notify=!1,e.value=r,e.notify=!0,this.funcCall[n][i]=r,this.setInputLockState(e,i,r,this.getInputLockState(i))});this.subs.push(r);const a=this.funcCallReplaced.pipe((0,h.startWith)(!0),(0,h.switchMap)(()=>{const t=this.funcCall[I.wl[n]][i];return t.onChanged.pipe((0,h.mapTo)(t))})).subscribe(t=>{const i=this.funcCall[n][t.name];if(o||(e.notify=!1,e.value=i,e.notify=!0),n===I.bZ.INPUTS){this.isHistorical.next(!1),this.hideOutput(),this.inputValidationRequests.next({field:t.name,isRevalidation:!1});const n=this.getInputLockState(t.name);"restricted unlocked"!==n&&"inconsistent"!==n||this.setInputLockState(e,t.name,i,i===this.getRestrictedValue(t.name)?"restricted unlocked":"inconsistent")}});this.subs.push(a);const l=this.funcCallReplaced.pipe((0,h.startWith)(!0),(0,h.switchMap)(()=>{const t=this.funcCall[I.wl[n]][i];return t.onChanged.pipe((0,h.mapTo)(t),(0,h.startWith)(t))}),(0,h.filter)(t=>t.property.propertyType===s.TYPE.DATA_FRAME&&t.value),(0,h.switchMap)(t=>t.value.onDataChanged.pipe((0,h.mapTo)(t)))).subscribe(t=>{n===I.bZ.INPUTS?this.inputValidationRequests.next({field:t.name,isRevalidation:!1}):this.outputValidationRequests.next({field:t.name,isRevalidation:!1})});this.subs.push(l);const u=((0,T.KL)(e)?e.onInput:(0,T.Gb)(e.onInput.bind(e))).pipe((0,h.debounceTime)(250)).subscribe(()=>{try{o=!0,this.funcCall[n][t.name]=e.value}finally{o=!1}});this.subs.push(u)}isRunnable(){return!this.isRunning.value&&!this.blockRuns.value&&this.isValid()}isValid(){for(const[t,e]of Object.entries(this.inputValidationState))if(!(0,f.Aw)(e))return!1;for(const[t,e]of Object.entries(this.externalValidatorsState))if(!(0,f.Aw)(e))return!1;return!0}getValidationState(){return this.inputValidationState}getValidationMessage(){const t=[];for(const[e,n]of Object.entries(this.inputValidationState))(0,f.Aw)(n)||t.push(`${e}: ${(0,f.u1)(n)}`);return t.join("\n")}runValidation(t,e){return N(this,arguments,void 0,function*(t,e,n=I.bZ.INPUTS){const i=t.field,o=this.getValidatedNames(i,n);return(0,T.tf)(t,o,e,n,{view:this,funcCall:this.funcCall,lastCall:this.lastCall},n===I.bZ.INPUTS?this.inputValidators:this.outputValidators)})}setInputValidationPending(t){const e=this.getValidatedNames(t);for(const t of e){this.inputValidationState[t]=(0,f.Ur)();const e=this.inputsMap[t];(0,v.LB)(e)&&e.setValidation((0,f.Ur)())}this.inputValidationUpdates.next(null)}setOutputValidationPending(t){const e=this.getValidatedNames(t,I.bZ.OUTPUTS);for(const t of e){this.outputValidationState[t]=(0,f.Ur)();const e=this.outputValidationSigns[t];if(e){const n=(0,f.JC)((0,f.Ur)());e[0].replaceWith(n[0]),e[1].replaceWith(n[1]),this.outputValidationSigns[t]=n}}this.outputValidationUpdates.next(null)}setInputValidationResults(t){for(const[e,n]of Object.entries(t))this.inputValidationState[e]=n,this.updateInputValidationResults(e)}setOutputValidationResults(t){for(const[e,n]of Object.entries(t))this.outputValidationState[e]=n,this.updateOutputValidationResults(e)}updateOutputValidationResults(t){const e=this.outputValidationState[t],n=this.outputValidationSigns[t];n&&(this.outputValidationSigns[t]=(0,T.Fd)(n,e))}updateInputValidationResults(t){const e=(0,f.uD)(this.inputValidationState[t],this.externalValidatorsState[t]),n=this.inputsMap[t];(0,v.LB)(n)&&n.setValidation(e)}runRevalidations(t,e,n=I.bZ.INPUTS){if(!t.isRevalidation)for(const[,t]of Object.entries(e))if(null==t?void 0:t.revalidate)for(const e of t.revalidate)n===I.bZ.INPUTS?this.inputValidationRequests.next({field:e,context:t.context,isRevalidation:!0}):this.outputValidationRequests.next({field:e,context:t.context,isRevalidation:!0})}getValidatedNames(t,e=I.bZ.INPUTS){return t?[t]:[...e===I.bZ.INPUTS?this.funcCall.inputs.keys():this.funcCall.outputs.keys()]}getValidExpRun(t){return N(this,void 0,void 0,function*(){t.started=a()();const e=t.options.immutable_tags||[];return t.options.immutable_tags=e.includes(m.ec)?e:[...e,m.ec],t.newId(),t})}saveExperimentalRun(t){return N(this,void 0,void 0,function*(){const e=yield this.getValidExpRun(t);yield this.saveRun(e)})}hideOutput(){if(this._isOutputOutdated.next(!0),this.keepOutput())return;this.outputTabsLabels.forEach(t=>{var e;return d()(null===(e=this.tabsElem.getPane(t))||void 0===e?void 0:e.header).hide()});const t=this.tabsElem.panes.find(t=>this.inputTabsLabels.includes(t.name));t?this.tabsElem.currentPane=t:d()(this.tabsElem.root).hide()}richFunctionViewSupportedFormats(){return["Excel"]}richFunctionViewExportExtensions(){return{Excel:"xlsx"}}}},984:(t,e,n)=>{"use strict";n.d(e,{$:()=>C});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(1858),u=n(8476),c=n(9713),d=(n(8870),n(4260)),p=n(810),h=n(7722),f=n(1159),m=n(8405),v=n(5909),g=n(804),y=n(1005),b=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const A=[s.TYPE.INT,s.TYPE.BIG_INT,s.TYPE.FLOAT,s.TYPE.DATA_FRAME],w=()=>o.div([],"sa-switch-input");class C{static fromEmpty(t){return b(this,arguments,void 0,function*(t,e={parentView:void 0,parentCall:void 0,inputsLookup:void 0,ranges:void 0,targets:void 0,acceptMode:!1,diffGrok:void 0}){const n=[...i.shell.views].find(t=>t.type===d.sk),o=yield u.S.fromComparedRuns([],t,{parentView:n,parentCall:e.parentCall});return i.shell.addView(o),new this(t,o,e)})}constructor(t,e,n={parentView:void 0,parentCall:void 0,configFunc:void 0,inputsLookup:void 0,ranges:void 0,targets:void 0,acceptMode:!1,diffGrok:void 0}){this.func=t,this.options=n,this.generateInputFields=t=>{const e=(t,e)=>{var n;const i=null===(n=this.options.ranges)||void 0===n?void 0:n[t.name];return null!=(null==i?void 0:i[e])?i[e]:void 0===t.options[e]?(0,p.Bu)(t):Number(t.options[e])},n=(t,e,n=!0)=>{const i=o.input.toggle(" ",{value:t,onValueChanged:t=>e(t)});return a()(i.root).addClass("sa-switch-input"),a()(i.captionLabel).hide(),o.tooltip.bind(i.root,()=>n?i.value?"Set the input as constant":"Set the input as variable":i.value?"Mark the output as not an objective":"Mark the output as an objective"),i};return{inputs:t.inputs.reduce((t,i)=>{var r;const u=e(i,"default");if(i.propertyType===s.TYPE.FLOAT){const s=n(!1,t=>{h.isChanging.next(t),this.updateApplicabilityState()}),c=n(!1,t=>{h.isChanging.next(t),this.updateApplicabilityState()}),d=null!==(r=i.caption)&&void 0!==r?r:i.name,p={type:i.propertyType,prop:i,const:{input:(()=>{const t=o.input.float(d,{value:u,onValueChanged:t=>{h.const.value=t,this.updateApplicabilityState()}});return t.root.insertBefore(c.root,t.captionLabel),t.addPostfix(i.options.units),t.setTooltip(`Value of '${d}'`),t.nullable=!1,t})(),value:u},min:{input:(()=>{const t=o.input.float(`${d} (min)`,{value:e(i,"min"),onValueChanged:t=>{h.min.value=t,this.updateApplicabilityState()}});return t.addValidator(t=>Number(t)>p.max.value?"Greater than max":null),t.root.insertBefore(s.root,t.captionLabel),t.addPostfix(i.options.units),t.setTooltip(`Min value '${d}'`),t.nullable=!1,t})(),value:e(i,"min")},max:{input:(()=>{const t=o.input.float(`${d} (max)`,{value:e(i,"max"),onValueChanged:t=>{h.max.value=t,this.updateApplicabilityState()}});return t.addValidator(t=>Number(t)<p.min.value?"Smaller than min":null),t.addPostfix(i.options.units),t.setTooltip(`Max value of '${d}'`),t.nullable=!1,t})(),value:e(i,"max")},isChanging:new l.BehaviorSubject(!1)};[p.max.input].forEach(t=>{t.root.insertBefore(w(),t.captionLabel),a()(t.root).removeProp("display")}),t[i.name]=Object.assign(Object.assign({},p),{constForm:[p.const.input],saForm:[p.min.input,p.max.input]});const h=t[i.name];h.isChanging.subscribe(t=>{s.notify=!1,s.value=t,s.notify=!0,c.notify=!1,c.value=t,c.notify=!0}),(0,l.combineLatest)([p.isChanging]).subscribe(([t])=>{t?(h.constForm.forEach(t=>a()(t.root).hide()),h.saForm.forEach(t=>a()(t.root).css("display","flex"))):(h.constForm.forEach(t=>a()(t.root).css("display","flex")),h.saForm.forEach(t=>a()(t.root).hide()))})}else{const e=w(),n={input:(()=>{var t;const s=o.input.forProperty(i);return s.caption=null!==(t=i.caption)&&void 0!==t?t:i.name,s.onInput.subscribe(()=>{n.value=s.value,this.updateApplicabilityState()}),s.root.insertBefore(e,s.captionLabel),s.addPostfix(i.options.units),s.nullable=!1,s})(),value:u};n.input.value=u,t[i.name]={const:n,constForm:[n.input],saForm:[],type:i.propertyType,prop:i,isChanging:new l.BehaviorSubject(!1)}}return t},{}),outputs:t.outputs.filter(t=>A.includes(t.propertyType)).reduce((t,e)=>{const i={prop:e,input:(()=>{var t,r,a;const l=o.input.int(null!==(t=e.caption)&&void 0!==t?t:e.name);l.setTooltip(e.propertyType===s.TYPE.DATA_FRAME?"Target dataframe":"Target scalar"),o.tooltip.bind(l.captionLabel,e.propertyType===s.TYPE.DATA_FRAME?"Dataframe":"Scalar"),null!=(null===(a=null===(r=this.options.targets)||void 0===r?void 0:r[e.name])||void 0===a?void 0:a.default)&&setTimeout(()=>{var t,n;return l.value=null===(n=null===(t=this.options.targets)||void 0===t?void 0:t[e.name])||void 0===n?void 0:n.default},0);const u=n(!0,t=>{i.isInterest.next(t),this.updateApplicabilityState()},!1).root;return l.root.insertBefore(u,l.captionLabel),l.input.hidden=!0,l})(),isInterest:new l.BehaviorSubject(!0),target:e.propertyType!==s.TYPE.DATA_FRAME?0:null};return t[e.name]=i,t},{})}},this.openedViewers=[],this.readyToRun=!1,this.isOptimizationRunning=!1,this.optTypeInput=(0,m.wV)(),this.progressIndicator=void 0,this.runIcon=o.iconFA("play",()=>b(this,void 0,void 0,function*(){this.readyToRun&&(this.isOptimizationRunning=!0,this.updateApplicabilityState(),this.updateRunIconDisabledTooltip("In progress..."),this.progressIndicator=s.TaskBarProgressIndicator.create("Optimization...",{cancelable:!0}),yield this.runOptimization(),this.progressIndicator.close(),this.isOptimizationRunning=!1,this.updateApplicabilityState())})),this.acceptIcon=o.iconFA("ballot-check",()=>b(this,void 0,void 0,function*(){const t=Array.from({length:this.currentFuncCalls.length},(t,e)=>e+1);let e=-1;const n=o.input.choice("Select optimization",{items:t,onValueChanged:t=>e=t});if(!(yield new Promise((t,e)=>{o.dialog({title:"Accept optimization"}).add(o.div([n])).onOK(()=>t(!0)).onCancel(()=>t(!1)).show({modal:!0,fullScreen:!0,width:600,height:200,center:!0})}))||e<0)return;this.acceptIcon.remove();const i=this.currentFuncCalls[e-1];this.isFittingAccepted=!0,this.acceptedFitting$.next(i)})),this.helpIcon=(0,m.VW)(),this.gridClickSubscription=null,this.gridCellChangeSubscription=null,this.helpDN=void 0,this.store=this.generateInputFields(this.func),this.diffGrok=void 0,this.currentFuncCalls=[],this.isFittingAccepted=!1,this.acceptedFitting$=new l.Subject,this.method=m.Mx.MOEAD,this.methodInput=o.input.choice(m.ly.METHOD,{value:m.Mx.MOEAD,nullable:!1,items:[m.Mx.MOEAD],tooltipText:m.k5.get(m.Mx.MOEAD),onValueChanged:t=>{var e;this.method=t,this.methodInput.setTooltip(null!==(e=m.k5.get(t))&&void 0!==e?e:""),this.updateMetSetInputs(),this.updateApplicabilityState()}}),this.optManagers=new Map([[m.Mx.MOEAD,new v.a(this)]]),this.optSetInps=new Map,this.settingsHeader=o.h1(m.ly.SET),this.areSettingsInputsShown=!1,this.fittingSettingsIcon=o.iconFA("cog",()=>{this.areSettingsInputsShown=!this.areSettingsInputsShown,this.updateMetSetInputs()}),i.events.onViewRemoved.pipe((0,c.filter)(t=>t.id===e.id),(0,c.take)(1)).subscribe(()=>{n.acceptMode&&!this.isFittingAccepted&&(this.acceptedFitting$.next(null),this.isFittingAccepted=!0)}),this.buildForm(n.inputsLookup).then(t=>{this.comparisonView=e,this.comparisonView.dockManager.dock(t,s.DOCK_TYPE.LEFT,null,`${this.func.name} - Optimization`,.25),this.comparisonView.grid.columns.byName("Run name").visible=!1;const n=[[this.helpIcon,this.runIcon,...this.options.acceptMode?[this.acceptIcon]:[]]];this.comparisonView.setRibbonPanels(n),this.comparisonView.name=this.comparisonView.name.replace("comparison","optimization"),this.comparisonView.helpUrl=m.W8;const i=o.markdown(m.TR);i.style.padding="10px",i.style.overflow="auto",this.helpDN=this.comparisonView.dockManager.dock(i,s.DOCK_TYPE.FILL,this.comparisonView.dockManager.findNode(this.comparisonView.grid.root),"About"),this.updateRunIconStyle(),this.runIcon.classList.add("fas"),this.updateApplicabilityState()}),this.diffGrok=n.diffGrok}areMethodSettingsCorrect(){return!0}getLookupElement(t){return b(this,void 0,void 0,function*(){if(void 0===t)return null;const e=new Map;Object.keys(this.store.inputs).forEach(t=>e.set(t,this.store.inputs[t].constForm[0]));const n=yield(0,f.c)(t,e);return null!==n&&n.input.root.insertBefore(w(),n.input.captionLabel),n})}buildForm(t){return b(this,void 0,void 0,function*(){const e=o.div([this.optTypeInput],{style:{overflowY:"scroll",width:"100%"}});let n="Misc";Object.values(this.store.outputs).reduce((t,e)=>{const i=e.prop;return i.category!==n&&(t.append(o.h3(i.category)),n=i.category),t.append(e.input.root),t},e);const i=o.h1(m.ly.CONSTR);o.tooltip.bind(i,"Set inputs constraints");const s=new Map([["Misc",[]]]);Object.values(this.store.inputs).forEach(t=>{const e=t.prop.category,n=[...t.constForm.map(t=>t.root),...t.saForm.map(t=>t.root)];s.has(e)?s.get(e).push(...n):s.set(e,n)}),e.append(i);const r=yield this.getLookupElement(t);let l=null;if(null!==r){const t=s.get(r.category);l=r.category,void 0!==t?s.set(l,[r.input.root].concat(t)):s.set(l,[r.input.root])}if(s.size>1){if(null!==l){const t=s.get(l);e.append((0,h.FB)(l,t)),e.append(...t)}if(s.forEach((t,n)=>{"Misc"!==n&&n!==l&&(e.append((0,h.FB)(n,t)),e.append(...t))}),"Misc"!==l&&s.get("Misc").length>0){const t=s.get("Misc");e.append((0,h.FB)("Misc",t)),e.append(...t)}}else e.append(...s.get("Misc"));let u=!1;for(const t of Object.keys(this.store.outputs))if(!0===this.store.outputs[t].isInterest.value){u=!0;break}return u||this.store.outputs[Object.keys(this.store.outputs)[0]].isInterest.next(!0),e.append(o.h1(m.ly.USING)),this.fittingSettingsIcon.style.minWidth="50px",this.methodInput.root.insertBefore(this.fittingSettingsIcon,this.methodInput.captionLabel),e.append(this.methodInput.root),e.append(this.settingsHeader),this.optManagers.forEach((t,n)=>{const i=t.getInputs();i.forEach(t=>{t.root.insertBefore(w(),t.captionLabel),e.append(t.root)}),this.optSetInps.set(n,i.map(t=>t.root))}),this.updateMetSetInputs(),a()(e).addClass("ui-form"),this.updateApplicabilityState(),a()(e).css({"padding-left":"12px","overflow-y":"scroll","padding-right":"4px",position:"relative","z-index":"2","background-color":"white"}),e})}updateMetSetInputs(){this.updateSettingsIconsHint(),this.settingsHeader.hidden=!this.areSettingsInputsShown,this.optSetInps.forEach((t,e)=>{t.forEach(t=>t.hidden=!(e===this.method&&this.areSettingsInputsShown))})}updateSettingsIconsHint(){o.tooltip.bind(this.fittingSettingsIcon,this.areSettingsInputsShown?"Hide settings":"Modify settings of the method")}updateRunIconDisabledTooltip(t){o.tooltip.bind(this.runIcon,()=>{const e=o.label(t);return e.style.color="#FF0000",e})}updateApplicabilityState(){this.readyToRun=this.canOptimizationBeRun()&&!this.isOptimizationRunning,this.updateRunIconStyle()}updateRunIconStyle(){this.readyToRun?(this.runIcon.style.color="var(--green-2)",o.tooltip.bind(this.runIcon,"Run optimization")):this.runIcon.style.color="var(--grey-3)"}areInputsReady(){var t;let e,n=!1,i=!0;for(const o of Object.keys(this.store.inputs)){const s=this.store.inputs[o],r=null!==(t=s.prop.caption)&&void 0!==t?t:s.prop.name;if(!0===s.isChanging.value){n=!0;const t=s.min.input,o=s.max.input,a=t.value,l=o.value;e=null!=a&&void 0!==l&&void 0!==l,e?a>l?(e=!1,this.updateRunIconDisabledTooltip(`Invalid min & max of "${r}"`),t.input.classList.add("d4-invalid"),o.input.classList.add("d4-invalid")):(t.input.classList.remove("d4-invalid"),o.input.classList.remove("d4-invalid")):this.updateRunIconDisabledTooltip(`Incomplete "${r}"`),i=i&&e}else{e=null!=s.const.input.value,e||this.updateRunIconDisabledTooltip(`Incomplete "${r}"`),i=i&&e}}return n||this.updateRunIconDisabledTooltip("No inputs selected as variable"),n&&i}areOutputsSelected(){for(const t of Object.keys(this.store.outputs))if(!0===this.store.outputs[t].isInterest.value)return!0;return this.updateRunIconDisabledTooltip("No objectives selected to be optimized"),!1}areSettingsOfMethodValid(){const t=this.optManagers.get(this.method);if(void 0===t)return this.updateRunIconDisabledTooltip("Invalid method"),!0;const e=t.areSettingsValid();return!!e.res||(this.updateRunIconDisabledTooltip(e.msg),!1)}canOptimizationBeRun(){return this.areSettingsOfMethodValid()&&this.areInputsReady()&&this.areOutputsSelected()&&this.areMethodSettingsCorrect()}getFixedInputs(){return Object.keys(this.store.inputs).filter(t=>!this.store.inputs[t].isChanging.value)}getVariadInputs(){return Object.keys(this.store.inputs).filter(t=>this.store.inputs[t].type===s.TYPE.FLOAT&&this.store.inputs[t].isChanging.value)}runOptimization(){return b(this,void 0,void 0,function*(){try{if(!this.canOptimizationBeRun())return;const t={};this.getFixedInputs().forEach(e=>t[e]=this.store.inputs[e].const.value);const e=this.getVariadInputs(),n=e.length,r=[],a=new Float32Array(n),l=new Float32Array(n),u=new Array(n),c=new Array(n);e.forEach((t,e)=>{var n,i,o;const s=this.store.inputs[t];a[e]=null!==(n=s.min.value)&&void 0!==n?n:0,l[e]=null!==(i=s.max.value)&&void 0!==i?i:0,r.push(t),u[e]=null!==(o=s.prop.caption)&&void 0!==o?o:s.prop.name,c[e]=s.prop.propertyType});const d=this.getOutputsOfInterest();if(d.length<1)return void i.shell.error("No output is selected for optimization.");let p=0;const h=[];a.forEach((e,n)=>t[r[n]]=e);const f=this.func.prepare(t),v=yield f.call(void 0,void 0,{processed:!0,report:!1});d.forEach(t=>{var e;const n=null!==(e=t.prop.caption)&&void 0!==e?e:t.prop.name;if(t.prop.propertyType!==s.TYPE.DATA_FRAME)h.push({caption:n,hint:`**Objective**\n\nValues of the output scalar **"${n}"**`}),++p;else{const e=v.getParamValue(t.prop.name),i=e.rowCount;for(const t of e.columns)if(t.isNumerical)for(let e=0;e<i;++e)h.push({caption:`${n}["${t.name}", ${e+1}]`,hint:`**Objective**\n\nValues of the output dataframe **"${n}"**:\n\n - column: "${t.name}"\n\n - row: ${e+1}`}),++p}});const A=this.optTypeInput.value,w=A===y.RF.MIN?1:-1,C=e=>b(this,void 0,void 0,function*(){e.forEach((e,n)=>t[r[n]]=e);const n=this.func.prepare(t),i=yield n.call(void 0,void 0,{processed:!0,report:!1}),o=new Float32Array(p);let a=0;if(d.forEach(t=>{if(t.prop.propertyType!==s.TYPE.DATA_FRAME)o[a]=w*i.getParamValue(t.prop.name),++a;else{const e=i.getParamValue(t.prop.name),n=e.rowCount;for(const t of e.columns){if(!t.isNumerical)continue;const e=t.getRawData();for(let t=0;t<n;++t)o[a]=w*e[t],++a}}}),p!==a)throw new Error("Inconsistent outputs: dataframes must be of the same size");return new Float32Array(o)}),I=this.optManagers.get(this.method);if(void 0===I)throw new Error("Non-supported method");const T=yield I.perform(C,{dim:n,mins:a,maxs:l},p,this.progressIndicator);this.clearPrev();const E=T.length,S=(0,g.XR)(n,E),x=(0,g.XR)(p,E);for(let t=0;t<E;++t){const e=T[t];for(let i=0;i<n;++i)S[i][t]=e[i];const i=yield C(e);for(let e=0;e<p;++e)x[e][t]=i[e]*w}const R=s.DataFrame.fromColumns(S.map((t,e)=>s.Column.fromFloat32Array(`inp ${e}`,t,E)).concat(x.map((t,e)=>s.Column.fromFloat32Array(`out ${e}`,t,E)))),O=new Map,N=R.columns;u.forEach((t,e)=>{const n=N.getUnusedName(t);N.byName(`inp ${e}`).name=n,O.set(n,{msg:`**Decision variable**\n\nValues of the input scalar **"${t}"**`,isInput:!0})}),h.forEach((t,e)=>{const n=N.byName(`out ${e}`),i=N.getUnusedName(t.caption);n.name=i,O.set(i,{msg:t.hint,isInput:!1})}),this.comparisonView.dataFrame=R,this.comparisonView.grid.onCellTooltip(function(t,e,n){var i;if(t.isColHeader&&t.tableColumn){const s=null!==(i=O.get(t.tableColumn.name))&&void 0!==i?i:{msg:"",isInput:!0},r=[o.markdown(s.msg)];return s.isInput||r.push((0,m.HE)(A)),o.tooltip.show(o.divV(r),e,n),!0}}),this.openedViewers=I.visualize(this.comparisonView,n,p,A)}catch(t){i.shell.error(t instanceof Error?t.message:"The platform issue")}})}getOutputsOfInterest(){const t=[];for(const e of Object.keys(this.store.outputs)){const n=this.store.outputs[e];n.isInterest.value&&t.push(n)}return t}clearPrev(){for(const t of this.openedViewers)t.close();this.openedViewers.splice(0),void 0!==this.helpDN&&(this.comparisonView.dockManager.close(this.helpDN),this.helpDN=void 0),this.gridClickSubscription&&(this.gridClickSubscription.unsubscribe(),this.gridClickSubscription=null),this.gridCellChangeSubscription&&(this.gridCellChangeSubscription.unsubscribe(),this.gridCellChangeSubscription=null),this.comparisonView.grid.sort([],[])}}},1005:(t,e,n)=>{"use strict";var i;n.d(e,{RF:()=>r,a$:()=>o,cp:()=>s}),function(t){t[t.N_WEIGHTS=99]="N_WEIGHTS",t[t.GENERATIONS=10]="GENERATIONS",t[t.NEIGHBORS=10]="NEIGHBORS",t[t.MUTATION_RATE=.2]="MUTATION_RATE"}(i||(i={}));const o={nWeights:i.N_WEIGHTS,generations:i.GENERATIONS,neighbors:i.NEIGHBORS,mutationRate:i.MUTATION_RATE},s=5;var r;!function(t){t.MIN="Minimize",t.MAX="Maximize"}(r||(r={}))},1027:(t,e,n)=>{"use strict";var i;n.d(e,{e5:()=>o}),function(t){t[t.K1=7.89e-10]="K1",t[t.K2=113e7]="K2",t[t.K3=11e6]="K3",t[t.K4=1130]="K4"}(i||(i={}));const o={name:"E5",arg:{name:"t",start:0,finish:1e13,step:25e7},initial:[.00176,0,0,0],func:(t,e,n)=>{const o=e[0],s=e[1],r=e[2],a=e[3];n[0]=-i.K1*o-i.K3*o*r,n[1]=i.K1*o-i.K2*s*r,n[2]=i.K1*o-i.K2*s*r-i.K3*o*r+i.K4*a,n[3]=i.K3*o*r-i.K4*a},tolerance:1e-6,solutionColNames:["y1","y2","y3","y4"]}},1059:(t,e,n)=>{"use strict";n.d(e,{H:()=>o});var i=n(2244);class o extends i.s{}},1159:(t,e,n)=>{"use strict";n.d(e,{c:()=>d});var i,o,s,r=n(4328),a=n(7389),l=n(6082),u=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};function c(t,e){if(null==e)return t;if(e.includes("E")||e.includes("e"))return t;const n=e.length-2;return n<1||n>20?t:Number(t.toPrecision(n))}function d(t,e){return u(this,void 0,void 0,function*(){var n;if(void 0===t)return null;const d=function(t){var e,n,i,o,a;const l=new Map,u=t.indexOf("{"),c=t.indexOf("}");if(u<0)return r.shell.warning('Missing "{"'),null;if(c<0)return r.shell.warning('Missing "}"'),null;l.set(s.NAME,t.slice(0,u).replaceAll(" ",""));const d=t.slice(u+1,c).split(";");let p;for(const t of d){if(p=t.indexOf(":"),p<0)return r.shell.warning('Missing ":"'),null;l.set(t.slice(0,p).trim(),t.slice(p+1).trim())}const h=t.indexOf("[");if(h>0){const e=t.indexOf("]");if(e<0)return r.shell.warning('Missing "]"'),null;l.set(s.TOOLTIP,t.slice(h+1,e))}return void 0===l.get(s.CHOICES)?(r.shell.warning(`Missing "${s.CHOICES}"-expression`),null):{name:null!==(e=l.get(s.NAME))&&void 0!==e?e:"",caption:null!==(n=l.get(s.CAPTION))&&void 0!==n?n:null!==(i=l.get(s.NAME))&&void 0!==i?i:"",category:null!==(o=l.get(s.CATEGORY))&&void 0!==o?o:s.MISC,tooltip:null!==(a=l.get(s.TOOLTIP))&&void 0!==a?a:"",choices:l.get(s.CHOICES)}}(t);if(null===d||void 0===d.choices)return null;const p=yield function(t){return u(this,void 0,void 0,function*(){try{const e=yield function(t){return u(this,void 0,void 0,function*(){const e=r.functions.parse(t);if(!(e instanceof l.FuncCall))return r.shell.warning(`${i.LOAD}, ${i.FUNCTION}`),null;const n=(yield e.call(void 0,void 0,{processed:!0,report:!1})).getOutputParamValue();return n instanceof l.DataFrame?n:(r.shell.warning(`${i.LOAD}, ${i.NO_DF}`),null)})}(t);if(function(t){if(null===t)return!1;const e=t.columns;if(t.rowCount<o.MIN_ROWS_COUNT)return r.shell.warning(`${i.LOAD}${i.INCORRECT}${i.ROWS}`),!1;let n=0;for(const t of e){if(t.stats.missingValueCount>0)return r.shell.warning(`${i.LOAD}${i.INCORRECT}${i.NULLS}`),!1;t.isNumerical&&++n}return 0===n?(r.shell.warning(`${i.LOAD}${i.INCORRECT}${i.NUMS}`),!1):e.byIndex(o.INP_NAMES_IDX).type===l.COLUMN_TYPE.STRING||(r.shell.warning(`${i.LOAD}${i.INCORRECT}${i.CHOICES}`),!1)}(e))return e}catch(e){const n=e instanceof Error?e.message:`check ${t}`;r.shell.warning(`${i.LOAD} ${n}`)}return null})}(d.choices);if(null===p)return null;const h=p.columns,f=p.rowCount,m=h.byIndex(o.INPUT_SETS_COL_IDX).toList(),v=[i.DEFAULT].concat(m),g=new Map;e.forEach((t,e)=>g.set(e,t.value));const y=new Map,b=new Map;for(const t of h)t.isNumerical&&b.set(t.name,{arr:t.getRawData(),format:t.meta.format});for(let t=0;t<f;++t){const e=new Map;b.forEach((n,i)=>e.set(i,c(n.arr[t],n.format))),y.set(m[t],e)}const A=a.input.choice(d.caption,{items:v,nullable:!1,value:v[0],tooltipText:d.tooltip,onValueChanged:t=>{if(t===i.DEFAULT)e.forEach((t,e)=>t.value=g.get(e));else{const n=y.get(t);e.forEach((t,e)=>{var i;return t.value=null!==(i=n.get(e))&&void 0!==i?i:t.value})}}});return{input:A,category:null!==(n=d.category)&&void 0!==n?n:"Misc"}})}!function(t){t.LOAD="Failed to load lookup table: ",t.PLATFORM="the platform issue",t.FUNCTION="incorrect function",t.NO_DF="no dataframe",t.INCORRECT="incorrect dataframe, ",t.ROWS="at least one row is needed.",t.NULLS="missing values are not allowed.",t.NUMS="no numerical columns.",t.CHOICES="first column must contain strings.",t.DEFAULT="Default"}(i||(i={})),function(t){t[t.MIN_ROWS_COUNT=1]="MIN_ROWS_COUNT",t[t.INP_NAMES_IDX=0]="INP_NAMES_IDX",t[t.INPUT_SETS_COL_IDX=0]="INPUT_SETS_COL_IDX"}(o||(o={})),function(t){t.CHOICES="choices",t.NAME="name",t.CATEGORY="category",t.CAPTION="caption",t.TOOLTIP="tooltip",t.MISC="Misc"}(s||(s={}))},1179:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(5516),o=n.n(i),s=n(1364),r=n.n(s)()(o());r.push([t.id,".ui-form .ui-input-root.ui-input-buttons.rfv-buttons {\n margin-top: 0px;\n position: sticky;\n align-items: flex-start;\n}\n\n.ui-form .ui-input-buttons.rfv-buttons .ui-input-editor {\n flex-wrap: wrap;\n}\n\n.ui-input-root.rfv-restricted-input.d4-disabled {\n pointer-events: all;\n cursor: pointer!important;\n}\n\n/* Hide all state icons by default */\n.ui-input-root > .ui-input-options .rfv-icon-lock,\n.ui-input-root > .ui-input-options .rfv-icon-unlock,\n.ui-input-root > .ui-input-options .rfv-icon-undo,\n.ui-input-root > .ui-input-options .rfv-icon-warning {\n display: none;\n}\n\n/* Show warning icon if input is on warning state */\n.ui-input-root.rfv-inconsistent-input > .ui-input-options .rfv-icon-warning {\n display: inherit;\n}\n\n/* Show undo icon if input is on inconstent state and hovered */\n.ui-input-root.rfv-restricted-unlocked-input:hover .rfv-icon-undo, .ui-input-root.rfv-inconsistent-input:hover .rfv-icon-undo {\n display: inherit;\n}\n\n/* Show/hide lock-unlock icons on input hover */\n.ui-input-root.rfv-restricted-input:hover .rfv-icon-lock {\n display: none;\n}\n.ui-input-root.rfv-restricted-input .rfv-icon-lock {\n display: inherit;\n}\n.ui-input-root.rfv-restricted-input .rfv-icon-unlock {\n display: none;\n}\n.ui-input-root.rfv-restricted-input:hover .rfv-icon-unlock {\n display: inherit;\n}\n\n.ui-form-condensed .rfv-buttons > .ui-label {\n margin-right: 0px!important;\n}\n\n.rfv-form .ui-form .rfv-buttons > .ui-input-editor {\n gap: 5px;\n justify-content: flex-end;\n}\n\ndiv.ui-box > div.ui-box.rfv-form > div.ui-div {\n overflow: visible!important;\n}\n\n.rfv-scalar-table {\n border-collapse: collapse;\n margin: 10px;\n}\n\n.rfv-scalar-table td {\n width: max-content;\n white-space: nowrap;\n}\n\n.rfv-scalar-table tr{\n min-height: 30px;\n border-bottom: 1pt solid var(--grey-12);\n}\n\n.rfv-scalar-table tr:nth-child(odd) {\n background-color: var(--grey-1);\n}\n\n.rfv-scalar-table td:last-child {\n width: 100%;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/old-views/css/rich-function-view.css"],names:[],mappings:"AAAA;IACI,eAAe;IACf,gBAAgB;IAChB,uBAAuB;AAC3B;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,mBAAmB;IACnB,yBAAyB;AAC7B;;AAEA,oCAAoC;AACpC;;;;IAII,aAAa;AACjB;;AAEA,mDAAmD;AACnD;IACI,gBAAgB;AACpB;;AAEA,+DAA+D;AAC/D;IACI,gBAAgB;AACpB;;AAEA,+CAA+C;AAC/C;IACI,aAAa;AACjB;AACA;IACI,gBAAgB;AACpB;AACA;IACI,aAAa;AACjB;AACA;IACI,gBAAgB;AACpB;;AAEA;IACI,2BAA2B;AAC/B;;AAEA;IACI,QAAQ;IACR,yBAAyB;AAC7B;;AAEA;IACI,2BAA2B;AAC/B;;AAEA;IACI,yBAAyB;IACzB,YAAY;AAChB;;AAEA;IACI,kBAAkB;IAClB,mBAAmB;AACvB;;AAEA;IACI,gBAAgB;IAChB,uCAAuC;AAC3C;;AAEA;IACI,+BAA+B;AACnC;;AAEA;IACI,WAAW;AACf",sourcesContent:[".ui-form .ui-input-root.ui-input-buttons.rfv-buttons {\n margin-top: 0px;\n position: sticky;\n align-items: flex-start;\n}\n\n.ui-form .ui-input-buttons.rfv-buttons .ui-input-editor {\n flex-wrap: wrap;\n}\n\n.ui-input-root.rfv-restricted-input.d4-disabled {\n pointer-events: all;\n cursor: pointer!important;\n}\n\n/* Hide all state icons by default */\n.ui-input-root > .ui-input-options .rfv-icon-lock,\n.ui-input-root > .ui-input-options .rfv-icon-unlock,\n.ui-input-root > .ui-input-options .rfv-icon-undo,\n.ui-input-root > .ui-input-options .rfv-icon-warning {\n display: none;\n}\n\n/* Show warning icon if input is on warning state */\n.ui-input-root.rfv-inconsistent-input > .ui-input-options .rfv-icon-warning {\n display: inherit;\n}\n\n/* Show undo icon if input is on inconstent state and hovered */\n.ui-input-root.rfv-restricted-unlocked-input:hover .rfv-icon-undo, .ui-input-root.rfv-inconsistent-input:hover .rfv-icon-undo {\n display: inherit;\n}\n\n/* Show/hide lock-unlock icons on input hover */\n.ui-input-root.rfv-restricted-input:hover .rfv-icon-lock {\n display: none;\n}\n.ui-input-root.rfv-restricted-input .rfv-icon-lock {\n display: inherit;\n}\n.ui-input-root.rfv-restricted-input .rfv-icon-unlock {\n display: none;\n}\n.ui-input-root.rfv-restricted-input:hover .rfv-icon-unlock {\n display: inherit;\n}\n\n.ui-form-condensed .rfv-buttons > .ui-label {\n margin-right: 0px!important;\n}\n\n.rfv-form .ui-form .rfv-buttons > .ui-input-editor {\n gap: 5px;\n justify-content: flex-end;\n}\n\ndiv.ui-box > div.ui-box.rfv-form > div.ui-div {\n overflow: visible!important;\n}\n\n.rfv-scalar-table {\n border-collapse: collapse;\n margin: 10px;\n}\n\n.rfv-scalar-table td {\n width: max-content;\n white-space: nowrap;\n}\n\n.rfv-scalar-table tr{\n min-height: 30px;\n border-bottom: 1pt solid var(--grey-12);\n}\n\n.rfv-scalar-table tr:nth-child(odd) {\n background-color: var(--grey-1);\n}\n\n.rfv-scalar-table td:last-child {\n width: 100%;\n}"],sourceRoot:""}]);const a=r},1261:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(5516),o=n.n(i),s=n(1364),r=n.n(s)()(o());r.push([t.id,".hp-no-elements-label {\n margin: 12px;\n}\n\n.grok-icon.hp-disabled {\n pointer-events: none;\n opacity: 0.6;\n}\n\n.hp-funccall-card-hover-icon {\n display: none;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-hover-icon {\n display: flex;\n margin: 0px 0px 0px 5px;\n}\n\n.hp-funccall-card {\n margin: 2px 1px;\n padding: 5px;\n justify-content: space-between;\n}\n\n.hp-funccall-card .hp-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.hp-funccall-card .hp-card-content * {\n margin-bottom: 3px;\n}\n\n.hp-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.hp-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/old-components/css/history-panel.css"],names:[],mappings:"AAAA;IACI,YAAY;AAChB;;AAEA;IACI,oBAAoB;IACpB,YAAY;AAChB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,aAAa;IACb,uBAAuB;AAC3B;;AAEA;IACI,eAAe;IACf,YAAY;IACZ,8BAA8B;AAClC;;AAEA;IACI,6BAA6B;IAC7B,gBAAgB;AACpB;;AAEA;IACI,kBAAkB;AACtB;;AAEA;IACI,kBAAkB;IAClB,oBAAoB;AACxB;;AAEA;IACI,oBAAoB;IACpB,gBAAgB;AACpB",sourcesContent:[".hp-no-elements-label {\n margin: 12px;\n}\n\n.grok-icon.hp-disabled {\n pointer-events: none;\n opacity: 0.6;\n}\n\n.hp-funccall-card-hover-icon {\n display: none;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-hover-icon {\n display: flex;\n margin: 0px 0px 0px 5px;\n}\n\n.hp-funccall-card {\n margin: 2px 1px;\n padding: 5px;\n justify-content: space-between;\n}\n\n.hp-funccall-card .hp-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.hp-funccall-card .hp-card-content * {\n margin-bottom: 3px;\n}\n\n.hp-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.hp-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}\n"],sourceRoot:""}]);const a=r},1340:(t,e,n)=>{"use strict";var i,o,s;!function(t){t.NAME="#name",t.TAGS="#tags",t.DESCR="#description",t.DIF_EQ="#equations",t.EXPR="#expressions",t.ARG="#argument",t.INITS="#inits",t.CONSTS="#constants",t.PARAMS="#parameters",t.TOL="#tolerance",t.LOOP="#loop",t.UPDATE="#update",t.RUN_ON_OPEN="#meta.runOnOpen",t.RUN_ON_INPUT="#meta.runOnInput",t.OUTPUT="#output",t.COMMENT="#comment",t.SOLVER="#meta.solver",t.INPUTS="#meta.inputs"}(i||(i={})),function(t){t[t.MIN_LINES_COUNT=1]="MIN_LINES_COUNT",t[t.COUNT_IDX=0]="COUNT_IDX",t.COUNT_NAME="_count",t[t.MIN_COUNT=1]="MIN_COUNT"}(o||(o={})),function(t){t[t.MIN_LINES_COUNT=1]="MIN_LINES_COUNT",t[t.DURATION_IDX=0]="DURATION_IDX",t.DURATION="_duration"}(s||(s={})),new Map([["maxTime",{min:1,max:1e4}],["scale",{min:.5,max:1}]])},1364:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n}).join("")},e.i=function(t,n,i,o,s){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var u=0;u<t.length;u++){var c=[].concat(t[u]);i&&r[c[0]]||(void 0!==s&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=s),n&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=n):c[2]=n),o&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=o):c[4]="".concat(o)),e.push(c))}},e}},1491:(t,e,n)=>{"use strict";n.d(e,{n:()=>S});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(1858),u=n(810),c=n(7600),d=n(4038),p=n(7149),h=n(8476),f=(n(8870),n(4260)),m=n(237),v=n(1159),g=n(7722),y=n(6307),b=n(1599),A=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const w=[s.TYPE.INT,s.TYPE.BIG_INT,s.TYPE.FLOAT,s.TYPE.BOOL,s.TYPE.DATA_FRAME],C=[s.TYPE.INT,s.TYPE.BIG_INT,s.TYPE.FLOAT,s.TYPE.BOOL,s.TYPE.DATA_FRAME];var I,T;!function(t){t.GRID_ANALYSIS="Grid",t.RANDOM_ANALYSIS="Monte Carlo",t.SOBOL_ANALYSIS="Sobol"}(I||(I={})),function(t){t.LAST_ROW="Last row",t.FIRST_ROW="First row",t.ALL_COLUMNS="",t.BY_COL_VAL="By value in column"}(T||(T={}));const E=()=>o.div([],"sa-switch-input");class S{static fromEmpty(t){return A(this,arguments,void 0,function*(t,e={parentView:void 0,parentCall:void 0,inputsLookup:void 0,ranges:void 0,diffGrok:void 0}){const n=[...i.shell.views].find(t=>t.type===f.sk),o=yield h.S.fromComparedRuns([],t,{parentView:n,parentCall:e.parentCall});i.shell.addView(o),new this(t,o,e)})}constructor(t,e,n={parentView:void 0,parentCall:void 0,configFunc:void 0,inputsLookup:void 0,ranges:void 0,diffGrok:void 0}){this.func=t,this.options=n,this.generateInputFields=t=>{const e={analysisType:{input:o.input.choice("Method",{value:I.RANDOM_ANALYSIS,items:[I.RANDOM_ANALYSIS,I.SOBOL_ANALYSIS,I.GRID_ANALYSIS],onValueChanged:t=>{e.analysisType.value.next(t),this.updateApplicabilityState(),this.setAnalysisInputTooltip(),this.store.analysisInputs.samplesCount.input.setTooltip(this.samplesCountTooltip())}}),value:new l.BehaviorSubject(I.RANDOM_ANALYSIS)},samplesCount:{input:o.input.int("Samples",{value:10,onValueChanged:t=>{e.samplesCount.value=t,this.updateApplicabilityState()},min:1}),value:10}};e.analysisType.input.root.insertBefore(E(),e.analysisType.input.captionLabel),e.samplesCount.input.root.insertBefore(E(),e.samplesCount.input.captionLabel);const n=(t,e)=>{var n;const i=null===(n=this.options.ranges)||void 0===n?void 0:n[t.name];return null!=(null==i?void 0:i[e])?i[e]:void 0===t.options[e]?(0,u.Bu)(t):Number(t.options[e])},i=t=>{var e;const n=null===(e=this.options.ranges)||void 0===e?void 0:e[t.name];return null!=(null==n?void 0:n.default)?n.default:(0,u.Bu)(t)},r=(t,e,n=!0)=>{const i=o.input.toggle(" ",{value:t,onValueChanged:t=>e(t)});return a()(i.root).addClass("sa-switch-input"),a()(i.captionLabel).hide(),o.tooltip.bind(i.root,()=>n?i.value?"Switch to mark input as immutable":"Switch to mark input as mutable":i.value?"Switch to mark output as not requiring analysis":"Switch to mark output as requiring analysis"),i},c=t.inputs.reduce((t,u)=>{const c=n(u,"default");switch(u.propertyType){case s.TYPE.INT:case s.TYPE.BIG_INT:case s.TYPE.FLOAT:const d=r(!1,t=>{m.isChanging.next(t),this.updateApplicabilityState()}),p=r(!1,t=>{m.isChanging.next(t),this.updateApplicabilityState()}),h={type:u.propertyType,prop:u,const:{input:(()=>{var t;const e=o.input.float(null!==(t=u.caption)&&void 0!==t?t:u.name,{value:i(u),onValueChanged:t=>m.const.value=t});return e.root.insertBefore(p.root,e.captionLabel),e.addPostfix(u.options.units),e})(),value:i(u)},min:{input:(()=>{var t;const e=o.input.float(`${null!==(t=u.caption)&&void 0!==t?t:u.name} min`,{value:n(u,"min"),onValueChanged:t=>m.min.value=t});return e.root.insertBefore(d.root,e.captionLabel),e.addPostfix(u.options.units),e})(),value:n(u,"min")},max:{input:(()=>{var t;const e=o.input.float(`${null!==(t=u.caption)&&void 0!==t?t:u.name} max`,{value:n(u,"max"),onValueChanged:t=>m.max.value=t});return e.addPostfix(u.options.units),e})(),value:n(u,"max")},lvl:{input:o.input.int("Samples",{value:3,onValueChanged:t=>{m.lvl.value=t,this.updateApplicabilityState()},min:1}),value:3},isChanging:new l.BehaviorSubject(!1)};[h.max.input,h.lvl.input].forEach(t=>{t.root.insertBefore(E(),t.captionLabel),a()(t.root).removeProp("display")});const f=[h.lvl.input];t[u.name]=Object.assign(Object.assign({},h),{constForm:[h.const.input],saForm:[h.min.input,h.max.input,...f]});const m=t[u.name];m.isChanging.subscribe(t=>{d.notify=!1,d.value=t,d.notify=!0,p.notify=!1,p.value=t,p.notify=!0}),(0,l.combineLatest)([h.isChanging,e.analysisType.value]).subscribe(([t,e])=>{t?(m.constForm.forEach(t=>a()(t.root).hide()),m.saForm.forEach(t=>a()(t.root).css("display","flex")),f.forEach(t=>e===I.GRID_ANALYSIS?a()(t.root).css("display","flex"):a()(t.root).hide())):(m.constForm.forEach(t=>a()(t.root).css("display","flex")),m.saForm.forEach(t=>a()(t.root).hide()))});break;case s.TYPE.BOOL:const v=r(!1,t=>{y.isChanging.next(t),this.updateApplicabilityState()}),g={type:u.propertyType,prop:u,const:{input:(()=>{var t,e;const n=o.input.bool(`${null!==(t=u.caption)&&void 0!==t?t:u.name}`,{value:null!==(e=i(u))&&void 0!==e&&e,onValueChanged:t=>y.const.value=t});return n.root.insertBefore(v.root,n.captionLabel),n})(),value:c},isChanging:new l.BehaviorSubject(!1),lvl:1};t[u.name]=Object.assign(Object.assign({},g),{constForm:[g.const.input],saForm:[]});const y=t[u.name];y.isChanging.subscribe(t=>{y.lvl=t?2:1});break;default:const b=E(),A={input:(()=>{const t=o.input.forProperty(u,void 0,{onValueChanged:t=>A.value=t});return t.root.insertBefore(b,t.captionLabel),t.addPostfix(u.options.units),t})(),value:i(u)};t[u.name]={const:A,constForm:[A.input],saForm:[],type:u.propertyType,prop:u,isChanging:new l.BehaviorSubject(!1)}}return t},{}),d=t.outputs.reduce((t,e)=>{const n={prop:e,input:(()=>{var t;const i=null!==(t=e.caption)&&void 0!==t?t:e.name;let a;e.propertyType===s.TYPE.DATA_FRAME?(a=o.input.choice(i,{value:T.LAST_ROW,items:[T.LAST_ROW,T.FIRST_ROW,T.BY_COL_VAL],onValueChanged:t=>{n.value.returning=t,n.analysisInputs.forEach(e=>{e.root.hidden=t!==T.BY_COL_VAL}),a.setTooltip(this.getOutputTooltip(i,t))}}),a.setTooltip(this.getOutputTooltip(i,T.LAST_ROW))):(a=o.input.forProperty(e),a.setTooltip("Scalar")),a.addCaption(i);const l=C.includes(e.propertyType)?r(!0,t=>{n.isInterest.next(t),n.analysisInputs.forEach(t=>{t.root.hidden=n.value.returning!==T.BY_COL_VAL}),this.updateApplicabilityState(),e.propertyType===s.TYPE.DATA_FRAME&&a.setTooltip(t?this.getOutputTooltip(i,T.LAST_ROW):"Dataframe")},!1).root:E();return a.root.insertBefore(l,a.captionLabel),a})(),analysisInputs:e.propertyType===s.TYPE.DATA_FRAME?[(()=>{var t;const i=o.input.string("Column",{value:T.ALL_COLUMNS,onValueChanged:t=>{n.value.colName=t}});return i.root.insertBefore(E(),i.captionLabel),i.root.hidden=!0,i.setTooltip(`Name of column of the '${null!==(t=e.caption)&&void 0!==t?t:e.name}' dataframe`),i})(),(()=>{var t;const i=o.input.float("Value",{value:0,onValueChanged:t=>{n.value.colValue=t}});return i.root.insertBefore(E(),i.captionLabel),i.root.hidden=!0,i.setTooltip(`Value specifying the '${null!==(t=e.caption)&&void 0!==t?t:e.name}' dataframe row`),i})()]:[],value:{returning:T.LAST_ROW,colName:T.ALL_COLUMNS,colValue:0},isInterest:new l.BehaviorSubject(!0)};return a()(n.input.input).css("visibility","hidden"),n.prop.propertyType===s.TYPE.DATA_FRAME&&n.isInterest.subscribe(t=>{n.analysisInputs.forEach(e=>t?a()(e.root).show():a()(e.root).hide()),a()(n.input.input).css("visibility",t?"visible":"hidden")}),t[e.name]=n,t},{});return{analysisInputs:e,inputs:c,outputs:d}},this.openedViewers=[],this.readyToRun=!1,this.isRunning=!1,this.runIcon=o.iconFA("play",()=>A(this,void 0,void 0,function*(){this.isRunning||(this.isRunning=!0,this.updateApplicabilityState(),this.updateRunIconDisabledTooltip("In progress..."),yield this.runAnalysis(),this.isRunning=!1,this.updateApplicabilityState())})),this.helpIcon=(0,p.VW)(),this.gridClickSubscription=null,this.gridCellChangeSubscription=null,this.store=this.generateInputFields(this.func),this.diffGrok=void 0,this.runIcon.style.color="var(--green-2)",this.runIcon.classList.add("fas"),this.buildFormWithBtn(n.inputsLookup).then(t=>{this.updateApplicabilityState(),this.addTooltips(),this.comparisonView=e,this.comparisonView.dockManager.dock(t,s.DOCK_TYPE.LEFT,null,`${this.func.name} - Sensitivity Analysis`,.25),this.comparisonView.grid.columns.byName("Run name").visible=!1,this.comparisonView.setRibbonPanels([[this.helpIcon,this.runIcon]]),this.comparisonView.helpUrl="/help/function-analysis.md#sensitivity-analysis",this.tableDockNode=this.comparisonView.dockManager.findNode(this.comparisonView.grid.root);const n=o.markdown(m.TR);n.style.padding="10px",n.style.overflow="auto",this.helpMdNode=this.comparisonView.dockManager.dock(n,s.DOCK_TYPE.FILL,this.tableDockNode,"About")}),this.diffGrok=n.diffGrok}clearPrev(){for(const t of this.openedViewers)t.close();this.openedViewers.splice(0),this.helpMdNode&&(this.helpMdNode.detachFromParent(),this.helpMdNode.container.destroy(),this.helpMdNode=void 0),this.gridClickSubscription&&(this.gridClickSubscription.unsubscribe(),this.gridClickSubscription=null),this.gridCellChangeSubscription&&(this.gridCellChangeSubscription.unsubscribe(),this.gridCellChangeSubscription=null)}updateRunIconDisabledTooltip(t){o.tooltip.bind(this.runIcon,()=>{const e=o.label(t);return e.style.color="#FF0000",e})}updateApplicabilityState(){this.readyToRun=this.canEvaluationBeRun()&&!this.isRunning,this.updateRunIconStyle()}updateRunIconStyle(){this.readyToRun?(this.runIcon.style.color="var(--green-2)",o.tooltip.bind(this.runIcon,`Run sensitivity analysis: ${this.getFuncCallCountAsString()}`)):this.runIcon.style.color="var(--grey-3)"}getFuncCallCount(t,e){let n=0;switch(t.analysisType.value.value){case I.GRID_ANALYSIS:let i=1;const o=t=>t.type===s.TYPE.INT||t.type===s.TYPE.BIG_INT||t.type===s.TYPE.FLOAT;for(const t of Object.values(e))t.isChanging.value&&(i*=o(t)?t.lvl.value:t.lvl,++n);return 0===n?0:i;case I.RANDOM_ANALYSIS:return t.samplesCount.value;case I.SOBOL_ANALYSIS:for(const t of Object.keys(e))e[t].isChanging.value&&++n;return 0===n?0:(n+2)*t.samplesCount.value;default:return 0}}getFuncCallCountAsString(){if(!this.canEvaluationBeRun())return"0";const t=this.getFuncCallCount(this.store.analysisInputs,this.store.inputs);return 1===t?"a single evaluation of the model":t<1e3?String(t)+" evaluations of the model":t<1e6?String(Math.ceil(t/10)/100)+"K evaluations of the model":t<1e9?String(Math.ceil(t/1e4)/100)+"M evaluations of the model":String(Math.ceil(t/1e7)/100)+"B evaluations of the model"}getLookupElement(t){return A(this,void 0,void 0,function*(){if(void 0===t)return null;const e=new Map;Object.keys(this.store.inputs).forEach(t=>e.set(t,this.store.inputs[t].constForm[0]));const n=yield(0,v.c)(t,e);return null!==n&&n.input.root.insertBefore(E(),n.input.captionLabel),n})}buildFormWithBtn(t){return A(this,void 0,void 0,function*(){const e=new Map([["Misc",[]]]);Object.values(this.store.inputs).forEach(t=>{const n=t.prop.category,i=[...t.constForm.map(t=>t.root),...t.saForm.map(t=>t.root)];e.has(n)?e.get(n).push(...i):e.set(n,i)});const n=o.div([this.store.analysisInputs.analysisType.input,this.store.analysisInputs.samplesCount.input],{style:{overflowY:"scroll",width:"100%"}}),i=yield this.getLookupElement(t);let s=null;if(null!==i){const t=e.get(i.category);s=i.category,void 0!==t?e.set(s,[i.input.root].concat(t)):e.set(s,[i.input.root])}if(e.size>1){if(null!==s){const t=e.get(s);n.append((0,g.FB)(s,t)),n.append(...t)}if(e.forEach((t,e)=>{"Misc"!==e&&e!==s&&(n.append((0,g.FB)(e,t)),n.append(...t))}),"Misc"!==s){const t=e.get("Misc");t.length>0&&(n.append((0,g.FB)("Misc",t)),n.append(...t))}}else n.append(...e.get("Misc"));a()(n).addClass("ui-form");const r=o.h2("Outputs");n.appendChild(r);let l="Misc";const u=Object.values(this.store.outputs).reduce((t,e)=>{const n=e.prop;return n.category!==l&&(t.append(o.h2(n.category)),l=n.category),t.append(e.input.root,...e.analysisInputs.map(t=>t.root)),t},n);this.store.analysisInputs.analysisType.value.subscribe(t=>{t===I.GRID_ANALYSIS?a()(this.store.analysisInputs.samplesCount.input.root).hide():(a()(r).show(),a()(u).show(),a()(this.store.analysisInputs.samplesCount.input.root).show())});let c=!1;for(const t of Object.keys(this.store.outputs))if(this.store.outputs[t].isInterest.value){c=!0;break}return c||this.store.outputs[Object.keys(this.store.outputs)[0]].isInterest.next(!0),this.updateApplicabilityState(),a()(n).css({"padding-left":"12px","overflow-y":"scroll","padding-right":"4px"}),n})}setAnalysisInputTooltip(){let t;switch(this.store.analysisInputs.analysisType.value.value){case I.GRID_ANALYSIS:t="Grid analysis: the function is evaluated with respect to the selected inputs varying within the specified ranges";break;case I.RANDOM_ANALYSIS:t="Monte Carlo simulation: the function is evaluated with respect to random variation of the selected inputs within the specified ranges";break;case I.SOBOL_ANALYSIS:t="Variance-based sensitivity analysis: the Sobol' indices are computed";break;default:t="Unknown method!"}this.store.analysisInputs.analysisType.input.setTooltip(t)}getOutputTooltip(t,e){switch(e){case T.FIRST_ROW:return`To analyze first row of the '${t}' dataframe`;case T.LAST_ROW:return`To analyze last row of the '${t}' dataframe`;case T.BY_COL_VAL:return`To analyze "${t}"'s row defined by custom value in column`;default:return""}}samplesCountTooltip(){switch(this.store.analysisInputs.analysisType.value.value){case I.RANDOM_ANALYSIS:return"Input sets count";case I.SOBOL_ANALYSIS:return"Sample size for the Sobol' indices computation";default:return"Unknown method!"}}addTooltips(){var t;this.setAnalysisInputTooltip(),this.store.analysisInputs.samplesCount.input.setTooltip(this.samplesCountTooltip());for(const e of Object.keys(this.store.inputs)){if(this.store.inputs[e].prop.propertyType!==s.TYPE.FLOAT)continue;const n=this.store.inputs[e],i=null!==(t=n.prop.caption)&&void 0!==t?t:n.prop.name;n.const.input.setTooltip(`'${i}' value`),n.min.input.setTooltip(`Min value of '${i}'`),n.max.input.setTooltip(`Max value of '${i}'`),n.lvl.input.setTooltip(`Number of samples along the axis '${i}'`)}}isAnyInputSelected(){for(const t of Object.keys(this.store.inputs))if(this.store.inputs[t].isChanging.value)return!0;return!1}isAnyOutputSelected(){for(const t of Object.keys(this.store.outputs))if(this.store.outputs[t].isInterest.value)return!0;return!1}isRunsCountValid(){return!(this.getFuncCallCount(this.store.analysisInputs,this.store.inputs)<1)}canEvaluationBeRun(){return this.isRunsCountValid()?this.isAnyInputSelected()?!!this.isAnyOutputSelected()||(this.updateRunIconDisabledTooltip("No outputs selected"),!1):(this.updateRunIconDisabledTooltip("No inputs selected"),!1):(this.updateRunIconDisabledTooltip("Invalid number of the model evaluations"),!1)}runAnalysis(){return A(this,void 0,void 0,function*(){if(this.canEvaluationBeRun())switch(this.store.analysisInputs.analysisType.value.value){case I.GRID_ANALYSIS:yield this.runGridAnalysis();break;case I.RANDOM_ANALYSIS:yield this.runRandomAnalysis();break;case I.SOBOL_ANALYSIS:yield this.runSobolAnalysis()}})}getFixedInputColumns(t){return Object.values(this.store.inputs).filter(t=>!w.includes(t.type)||!t.isChanging.value).map(e=>{var n;return s.Column.fromList(e.type,null!==(n=e.prop.caption)&&void 0!==n?n:e.prop.name,Array(t).fill(e.const.value))})}runSobolAnalysis(){return A(this,void 0,void 0,function*(){try{const t={func:this.func,fixedInputs:this.getFixedInputs().map(t=>({name:t,value:this.store.inputs[t].const.value})),variedInputs:this.getVariedInputs().map(t=>{const e=this.store.inputs[t];return{prop:e.prop,min:e.min.value,max:e.max.value}}),samplesCount:this.store.analysisInputs.samplesCount.value||1},e=this.getOutputsOfInterest(),n=new c.o(t.func,t.fixedInputs,t.variedInputs,e,t.samplesCount,this.diffGrok),r=yield n.perform();this.clearPrev();const l=r.funcEvalResults,u=r.funcInputs,d=r.firstOrderSobolIndices,p=r.totalOrderSobolIndices,h=d.columns.names();this.comparisonView.dataFrame=l;const f=l.columns.names(),v=this.getFixedInputColumns(l.rowCount);for(const t of v)t.name=l.columns.getUnusedName(`${t.name} (fixed)`),l.columns.add(t);this.comparisonView.grid.columns.setVisible([f[0]]),this.comparisonView.grid.columns.setVisible(f),this.comparisonView.grid.props.rowHeight=m.FL;const g=s.Viewer.correlationPlot(l,{xColumnNames:f,yColumnNames:f}),y=this.comparisonView.dockManager.dock(g,s.DOCK_TYPE.LEFT,this.tableDockNode,"",m.KN.COR_PLOT);this.openedViewers.push(g);const w=s.Viewer.pcPlot(l,{columnNames:f});this.comparisonView.dockManager.dock(w,s.DOCK_TYPE.DOWN,y,"",m.KN.PC_PLOT),this.openedViewers.push(w);const C=this.getOutputNameForScatterPlot(f,l,t.variedInputs.length),I=1===t.variedInputs.length?s.Viewer.lineChart(l,this.getLineChartOpt(f)):s.Viewer.scatterPlot(l,this.getScatterOpt(f,C));this.openedViewers.push(I),this.comparisonView.dockManager.dock(I,s.DOCK_TYPE.DOWN,this.tableDockNode,"",m.KN.GRAPH);const T=s.Viewer.barChart(d,this.getBarChartOpt(d.name,h[0],C)),E=this.comparisonView.dockManager.dock(T,s.DOCK_TYPE.RIGHT,void 0,"",m.KN.BAR_CHART),S=s.Viewer.barChart(p,this.getBarChartOpt(p.name,h[0],C));this.comparisonView.dockManager.dock(S,s.DOCK_TYPE.DOWN,E),this.openedViewers=this.openedViewers.concat([T,S]);const x=t=>A(this,void 0,void 0,function*(){var e;if(null==t||void 0===u)return;const n=u[null!==(e=t.tableRowIndex)&&void 0!==e?e:0],r=this.func.prepare(n),l=yield r.call(void 0,void 0,{processed:!0,report:!1}),c=[...l.outputParams.values()].filter(t=>s.TYPES_SCALAR.has(t.property.propertyType)),d=s.HtmlTable.create(c,t=>{var e;return[null!==(e=t.property.caption)&&void 0!==e?e:t.property.name,l.outputs[t.property.name],t.property.options.units]}).root,p=[...l.outputParams.values()].filter(t=>t.property.propertyType===s.TYPE.DATA_FRAME).reduce((t,e)=>{var n;const i=(0,b.jJ)(e.property).config,o=l.outputs[e.name],r=null!==(n=e.property.caption)&&void 0!==n?n:e.property.name;return i.map(e=>{const n=e.type,i=s.Viewer.fromType(n,o);i.setOptions(e),a()(i.root).css({width:"100%"}),t[r]?t[r].push(i.root):t[r]=[i.root]}),t},{});let h,f;c.length>0?(f=1,h=Object.assign({"Output scalars":[d]},p)):(f=0,h=Object.assign({},p));const m=o.accordion();a()(m.root).css({width:"100%"}),Object.entries(h).map(t=>{m.addPane(t[0],()=>o.divV(t[1]))}),m.panes[f].expanded=!0,i.shell.o=m.root});this.gridClickSubscription=this.comparisonView.grid.onCellClick.subscribe(x),this.gridCellChangeSubscription=this.comparisonView.grid.onCurrentCellChanged.subscribe(x)}catch(t){i.shell.error(t instanceof Error?t.message:"The platform issue")}})}getFixedInputs(){return Object.keys(this.store.inputs).filter(t=>!w.includes(this.store.inputs[t].type)||!this.store.inputs[t].isChanging.value)}getVariedInputs(){return Object.keys(this.store.inputs).filter(t=>!!w.includes(this.store.inputs[t].type)&&this.store.inputs[t].isChanging.value)}runRandomAnalysis(){return A(this,void 0,void 0,function*(){try{const t={func:this.func,fixedInputs:this.getFixedInputs().map(t=>({name:t,value:this.store.inputs[t].const.value})),variedInputs:this.getVariedInputs().map(t=>{const e=this.store.inputs[t];return{prop:e.prop,min:e.min.value,max:e.max.value}}),samplesCount:this.store.analysisInputs.samplesCount.value||1},e=this.getOutputsOfInterest(),n=new d.M(t.func,t.fixedInputs,t.variedInputs,e,t.samplesCount,this.diffGrok),r=yield n.perform(),l=r.funcEvalResults,u=r.funcInputs;this.clearPrev(),this.comparisonView.dataFrame=l;const c=l.columns.names(),p=this.getFixedInputColumns(l.rowCount);for(const t of p)t.name=l.columns.getUnusedName(`${t.name} (fixed)`),l.columns.add(t);this.comparisonView.grid.columns.setVisible([c[0]]),this.comparisonView.grid.columns.setVisible(c),this.comparisonView.grid.props.rowHeight=m.FL;const h=s.Viewer.correlationPlot(l,{xColumnNames:c,yColumnNames:c}),f=this.comparisonView.dockManager.dock(h,s.DOCK_TYPE.LEFT,this.tableDockNode,"",m.KN.COR_PLOT);this.openedViewers.push(h);const v=s.Viewer.pcPlot(l,{columnNames:c});this.comparisonView.dockManager.dock(v,s.DOCK_TYPE.DOWN,f,"",m.KN.PC_PLOT),this.openedViewers.push(v);const g=this.getOutputNameForScatterPlot(c,l,t.variedInputs.length),y=1===t.variedInputs.length?s.Viewer.lineChart(l,this.getLineChartOpt(c)):s.Viewer.scatterPlot(l,this.getScatterOpt(c,g));this.openedViewers.push(y),this.comparisonView.dockManager.dock(y,s.DOCK_TYPE.DOWN,this.tableDockNode,"",m.KN.GRAPH);const w=t=>A(this,void 0,void 0,function*(){var e;if(null==t||void 0===u)return;const n=u[null!==(e=t.tableRowIndex)&&void 0!==e?e:0],r=this.func.prepare(n),l=yield r.call(void 0,void 0,{processed:!0,report:!1}),c=[...l.outputParams.values()].filter(t=>s.TYPES_SCALAR.has(t.property.propertyType)),d=s.HtmlTable.create(c,t=>{var e;return[null!==(e=t.property.caption)&&void 0!==e?e:t.property.name,l.outputs[t.property.name],t.property.options.units]}).root,p=[...l.outputParams.values()].filter(t=>t.property.propertyType===s.TYPE.DATA_FRAME).reduce((t,e)=>{var n;const i=(0,b.jJ)(e.property).config,o=l.outputs[e.name],r=null!==(n=e.property.caption)&&void 0!==n?n:e.property.name;return i.map(e=>{const n=e.type,i=s.Viewer.fromType(n,o);i.setOptions(e),a()(i.root).css({width:"100%"}),t[r]?t[r].push(i.root):t[r]=[i.root]}),t},{});let h,f;c.length>0?(f=1,h=Object.assign({"Output scalars":[d]},p)):(f=0,h=Object.assign({},p));const m=o.accordion();a()(m.root).css({width:"100%"}),Object.entries(h).map(t=>{m.addPane(t[0],()=>o.divV(t[1]))}),m.panes[f].expanded=!0,i.shell.o=m.root});this.gridClickSubscription=this.comparisonView.grid.onCellClick.subscribe(w),this.gridCellChangeSubscription=this.comparisonView.grid.onCurrentCellChanged.subscribe(w)}catch(t){i.shell.error(t instanceof Error?t.message:"The platform issue")}})}runGridAnalysis(){return A(this,void 0,void 0,function*(){try{const t=Object.keys(this.store.inputs).reduce((t,e)=>{switch(this.store.inputs[e].type){case s.TYPE.INT:case s.TYPE.BIG_INT:const n=this.store.inputs[e],i=(n.max.value-n.min.value)/(n.lvl.value-1);t[e]=n.isChanging.value?Array.from({length:n.lvl.value},(t,e)=>Math.round(n.min.value+e*i)):[n.const.value];break;case s.TYPE.FLOAT:const o=this.store.inputs[e],r=(o.max.value-o.min.value)/(o.lvl.value-1);t[e]=o.isChanging.value?Array.from({length:o.lvl.value},(t,e)=>o.min.value+e*r):[o.const.value];break;case s.TYPE.BOOL:const a=this.store.inputs[e];t[e]=a.isChanging.value?[a.const.value,!a.const.value]:[a.const.value];break;default:const l=this.store.inputs[e];t[e]=[l.const.value]}return t},{});let e=Object.values(t)[0].map(t=>[t]);for(let n=1;n<Object.values(t).length;n++){const i=Object.values(t)[n],o=[];for(const t of e)for(const e of i)o.push([...t,e]);e=o}const n=e.map(t=>this.func.inputs.map((t,e)=>({name:t.name,idx:e})).reduce((e,{name:n,idx:i})=>(e[n]=t[i],e),{})),r=this.getVariedInputs().map(t=>{var e;const n=this.store.inputs[t].prop;return{name:t,caption:null!==(e=n.caption)&&void 0!==e?e:t,type:n.propertyType}}),l=this.getOutputsOfInterest(),u=new y.R(this.func,n,r,l,this.diffGrok),c=yield u.perform();this.clearPrev(),this.comparisonView.dataFrame=c;const d=c.columns.names(),p=this.getFixedInputColumns(c.rowCount);for(const t of p)t.name=c.columns.getUnusedName(`${t.name} (fixed)`),c.columns.add(t);this.comparisonView.grid.columns.setVisible([d[0]]),this.comparisonView.grid.columns.setVisible(d),this.comparisonView.grid.props.rowHeight=m.FL;const h=s.Viewer.correlationPlot(c,{xColumnNames:d,yColumnNames:d}),f=this.comparisonView.dockManager.dock(h,s.DOCK_TYPE.LEFT,this.tableDockNode,"",m.KN.COR_PLOT);this.openedViewers.push(h);const v=s.Viewer.pcPlot(c,{columnNames:d});this.comparisonView.dockManager.dock(v,s.DOCK_TYPE.DOWN,f,"",m.KN.PC_PLOT),this.openedViewers.push(v);const g=this.getOutputNameForScatterPlot(d,c,r.length),w=1===r.length?s.Viewer.lineChart(c,this.getLineChartOpt(d)):s.Viewer.scatterPlot(c,this.getScatterOpt(d,g));this.openedViewers.push(w),this.comparisonView.dockManager.dock(w,s.DOCK_TYPE.DOWN,this.tableDockNode,"",m.KN.GRAPH);const C=t=>A(this,void 0,void 0,function*(){var e;if(null==t||void 0===n)return;const r=n[null!==(e=t.tableRowIndex)&&void 0!==e?e:0],l=this.func.prepare(r),u=yield l.call(void 0,void 0,{processed:!0,report:!1}),c=[...u.outputParams.values()].filter(t=>s.TYPES_SCALAR.has(t.property.propertyType)),d=s.HtmlTable.create(c,t=>{var e;return[null!==(e=t.property.caption)&&void 0!==e?e:t.property.name,u.outputs[t.property.name],t.property.options.units]}).root,p=[...u.outputParams.values()].filter(t=>t.property.propertyType===s.TYPE.DATA_FRAME).reduce((t,e)=>{var n;const i=(0,b.jJ)(e.property).config,o=u.outputs[e.name],r=null!==(n=e.property.caption)&&void 0!==n?n:e.property.name;return i.map(e=>{const n=e.type,i=s.Viewer.fromType(n,o);i.setOptions(e),a()(i.root).css({width:"100%"}),t[r]?t[r].push(i.root):t[r]=[i.root]}),t},{});let h,f;c.length>0?(f=1,h=Object.assign({"Output scalars":[d]},p)):(f=0,h=Object.assign({},p));const m=o.accordion();a()(m.root).css({width:"100%"}),Object.entries(h).map(t=>{m.addPane(t[0],()=>o.divV(t[1]))}),m.panes[f].expanded=!0,i.shell.o=m.root});this.gridClickSubscription=this.comparisonView.grid.onCellClick.subscribe(C),this.gridCellChangeSubscription=this.comparisonView.grid.onCurrentCellChanged.subscribe(C)}catch(t){i.shell.error(t instanceof Error?t.message:"The platform issue")}})}getOutputNameForScatterPlot(t,e,n){var i,o,s,r;for(let a=n;a<t.length;++a)if((null!==(o=null===(i=e.col(t[a]))||void 0===i?void 0:i.min)&&void 0!==o?o:0)<(null!==(r=null===(s=e.col(t[a]))||void 0===s?void 0:s.max)&&void 0!==r?r:0))return t[a];return t[n]}getOutputsOfInterest(){const t=[];for(const e of Object.keys(this.store.outputs)){const n=this.store.outputs[e];if(n.isInterest.value){let e;switch(n.value.returning){case T.LAST_ROW:e=m.YU;break;case T.FIRST_ROW:e=m.Q2;break;default:e=null}t.push({prop:n.prop,value:{row:e,colName:n.value.colName,colValue:n.value.colValue}})}}return t}getScatterOpt(t,e){return{xColumnName:t[0],yColumnName:t[1],colorColumnName:e,sizeColumnName:e,markerMaxSize:12,jitterSize:5}}getLineChartOpt(t){return{xColumnName:t[0],yColumnNames:t.slice(1,Math.min(t.length,8)),markerSize:1,markerType:s.MARKER_TYPE.GRADIENT,multiAxis:!0}}getBarChartOpt(t,e,n){return{description:t,splitColumnName:e,valueColumnName:n,valueAggrType:s.AGG.AVG,showTitle:!1,showCategorySelector:!1,showStackSelector:!1,showValueAxis:!1}}}},1511:(t,e,n)=>{"use strict";n(2158),n(9225),n(1799),n(8501),n(9687)},1599:(t,e,n)=>{"use strict";n.d(e,{A4:()=>y,HP:()=>p,Ne:()=>g,Yj:()=>v,cb:()=>w,eK:()=>A,i:()=>f,jJ:()=>b,vk:()=>h,x$:()=>m,zF:()=>d});var i=n(4328),o=n(6082),s=n(1991),r=n.n(s),a=n(4260),l=n(5520),u=n(4778);const c=new o.LruCache,d=t=>{return e=void 0,n=void 0,s=function*(){var e;const n=null!==(e=t.options.help)&&void 0!==e?e:t.options.readme;if(!n)return;if(c.get(t.id))return c.get(t.id);const o=`System:AppData/${t.package.name}/${n}`;if(yield i.dapi.files.exists(o)){const e=yield i.dapi.files.readAsText(o);return c.set(t.id,e),e}const s=`${i.shell.user.name}.home/${n}`;if(yield i.dapi.files.exists(s)){const e=yield i.dapi.files.readAsText(s);return c.set(t.id,e),e}},new((o=void 0)||(o=Promise))(function(t,i){function r(t){try{l(s.next(t))}catch(t){i(t)}}function a(t){try{l(s.throw(t))}catch(t){i(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o(function(t){t(n)})).then(r,a)}l((s=s.apply(e,n||[])).next())});var e,n,o,s},p=t=>{var e;return!!(null===(e=null==t?void 0:t.options)||void 0===e?void 0:e.help)},h=t=>"true"===t.options.runOnInput,f=t=>{var e;return JSON.parse(null!==(e=t.options.features)&&void 0!==e?e:"{}")},m=(t,e,n)=>{var i;return t instanceof Array?t.includes(e):t instanceof Object&&null!==(i=t[e])&&void 0!==i?i:n},v=t=>{try{return null==t?void 0:t.started}catch(t){return}},g=t=>{var e;return(0,l.iu)(null!==(e=t.options[u.fj])&&void 0!==e?e:"false")||!v(t)||!t.id},y=t=>{const e=o.Func.byName(t.func.nqName).prepare();e.id=t.id,t.options.forEach(n=>e.options[n]=t.options[n]);const n=r()(e.outputParams.values()).filter(e=>null!=t.outputs[e.name]);for(const i of n)i.property.propertyType===o.TYPE.DATA_FRAME?e.outputs[i.name]=t.outputs[i.name].clone():e.outputs[i.name]=t.outputs[i.name];const i=r()(e.inputParams.values()).filter(e=>null!=t.inputs[e.name]);for(const n of i)n.property.propertyType===o.TYPE.DATA_FRAME?e.inputs[n.name]=t.inputs[n.name].clone():e.inputs[n.name]=t.inputs[n.name];return v(t)&&(e.started=t.started),e},b=t=>{const e=t.options[a.NT];return e?{name:t.name,config:JSON.parse(e,(t,e)=>{if("true"===e)return!0;if("false"===e)return!1;if("type"===t)return a.CB[e]||e;if(!t.toLowerCase().includes("color")){const t=Number.parseFloat(e);if(!Number.isNaN(t))return t}return e})}:{name:t.name,config:[]}},A=t=>{try{return t.started.toDate().toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}catch(t){return"Not completed"}},w=t=>new Promise(e=>setTimeout(e,t))},1757:t=>{"use strict";t.exports=$},1799:(t,e,n)=>{"use strict";n(8501)},1825:(t,e,n)=>{"use strict";n.d(e,{Fo:()=>m,SM:()=>p});const i="function"==typeof Buffer,o=("function"==typeof TextDecoder&&new TextDecoder,"function"==typeof TextEncoder&&new TextEncoder,Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")),s=(t=>{let e={};return t.forEach((t,n)=>e[t]=n),e})(o),r=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,a=String.fromCharCode.bind(String),l="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):t=>new Uint8Array(Array.prototype.slice.call(t,0)),u=t=>t.replace(/[^A-Za-z0-9\+\/]/g,""),c="function"==typeof btoa?t=>btoa(t):i?t=>Buffer.from(t,"binary").toString("base64"):t=>{let e,n,i,s,r="";const a=t.length%3;for(let a=0;a<t.length;){if((n=t.charCodeAt(a++))>255||(i=t.charCodeAt(a++))>255||(s=t.charCodeAt(a++))>255)throw new TypeError("invalid character found");e=n<<16|i<<8|s,r+=o[e>>18&63]+o[e>>12&63]+o[e>>6&63]+o[63&e]}return a?r.slice(0,a-3)+"===".substring(a):r},d=i?t=>Buffer.from(t).toString("base64"):t=>{let e=[];for(let n=0,i=t.length;n<i;n+=4096)e.push(a.apply(null,t.subarray(n,n+4096)));return c(e.join(""))},p=(t,e=!1)=>e?d(t).replace(/=/g,"").replace(/[+\/]/g,t=>"+"==t?"-":"_"):d(t),h="function"==typeof atob?t=>atob(u(t)):i?t=>Buffer.from(t,"base64").toString("binary"):t=>{if(t=t.replace(/\s+/g,""),!r.test(t))throw new TypeError("malformed base64.");let e,n,i;t+="==".slice(2-(3&t.length));let o=[];for(let r=0;r<t.length;)e=s[t.charAt(r++)]<<18|s[t.charAt(r++)]<<12|(n=s[t.charAt(r++)])<<6|(i=s[t.charAt(r++)]),64===n?o.push(a(e>>16&255)):64===i?o.push(a(e>>16&255,e>>8&255)):o.push(a(e>>16&255,e>>8&255,255&e));return o.join("")},f=i?t=>l(Buffer.from(t,"base64")):t=>l(h(t).split("").map(t=>t.charCodeAt(0))),m=t=>f(v(t)),v=t=>u(t.replace(/[-_]/g,t=>"-"==t?"+":"/"))},1858:t=>{"use strict";t.exports=rxjs},1927:(t,e,n)=>{"use strict";n.d(e,{Aw:()=>o,B5:()=>s,JC:()=>p,Td:()=>d,Ur:()=>u,ZS:()=>a,dQ:()=>c,u1:()=>r,uD:()=>l});var i=n(7389);function o(t){var e;return!(null===(e=null==t?void 0:t.errors)||void 0===e?void 0:e.length)&&!(null==t?void 0:t.pending)}function s(t,e){return{description:t,actions:e}}function r(t){if(null==t?void 0:t.errors)return t.errors.map(t=>t.description).join("; ")}function a(t){var e,n,i;const o=t=>"string"==typeof t?s(t):t;return{errors:null===(e=null==t?void 0:t.errors)||void 0===e?void 0:e.map(t=>o(t)),warnings:null===(n=null==t?void 0:t.warnings)||void 0===n?void 0:n.map(t=>o(t)),notifications:null===(i=null==t?void 0:t.notifications)||void 0===i?void 0:i.map(t=>o(t))}}function l(...t){var e,n,i,o,s;const r=[],a=[],l=[],u=[];let c={};for(const d of t)d&&(r.push(...null!==(e=d.errors)&&void 0!==e?e:[]),a.push(...null!==(n=d.warnings)&&void 0!==n?n:[]),l.push(...null!==(i=d.notifications)&&void 0!==i?i:[]),u.push(...null!==(o=d.revalidate)&&void 0!==o?o:[]),c=Object.assign(Object.assign({},c),null!==(s=d.context)&&void 0!==s?s:{}));return{errors:r,warnings:a,notifications:l,revalidate:u,context:c}}function u(){return{pending:!0}}function c(t,e,n){return Object.assign({revalidate:t,context:e},n)}const d=t=>{return e=void 0,n=void 0,o=function*(){if(null==t)return a({errors:["Missing value"]})},new((i=void 0)||(i=Promise))(function(t,s){function r(t){try{l(o.next(t))}catch(t){s(t)}}function a(t){try{l(o.throw(t))}catch(t){s(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i(function(t){t(n)})).then(r,a)}l((o=o.apply(e,n||[])).next())});var e,n,i,o};function p(t){let e,n;return(null==t?void 0:t.pending)&&(n=i.iconFA("spinner",()=>{h(t,n,e)}),n.classList.add("fa-spin")),(null==t?void 0:t.errors)&&t.errors.length?(n=i.iconFA("exclamation-circle",()=>{h(t,n,e)}),n.style.color="var(--red-3)"):(null==t?void 0:t.warnings)&&t.warnings.length?(n=i.iconFA("exclamation-circle",()=>{h(t,n,e)}),n.style.color="var(--orange-2)"):(null==t?void 0:t.notifications)&&t.notifications.length&&(n=i.iconFA("info-circle",()=>{h(t,n,e)}),n.style.color="var(--blue-1)"),n&&(n.classList.remove("fal"),n.classList.add("far"),e=function(t){const e=i.div([],"d4-tooltip");return function(t){t.popover="auto",t.style.fontStyle="normal",t.style.pointerEvents="all",t.style.maxWidth="300px",t.style.textWrap="pretty"}(e),t.appendChild(e),e}(n)),[null!=n?n:i.div(),null!=e?e:i.div()]}function h(t,e,n){if(n&&e){for(function(t,e){const n=t.getBoundingClientRect().toJSON();e.style.inset="unset",e.style.top=n.y+"px",e.style.left=n.x+20+"px"}(e,n);n.firstChild&&n.removeChild(n.firstChild););const o=function(t){var e;const n=i.divV([],{style:{gap:"10px"}});for(const o of["errors","warnings","notifications"]){const s=t[o];if(null==s?void 0:s.length)for(const t of s){const s=f(o);s.style.marginRight="4px",n.appendChild(i.divV([i.divH([s,i.span([t.description])]),...(null!==(e=t.actions)&&void 0!==e?e:[]).map(t=>i.link(t.actionName,t.action,void 0,{style:{paddingLeft:"20px"}}))]))}}return n}(t);n.appendChild(o),n.showPopover()}}function f(t){let e;return"errors"===t?(e=i.iconFA("exclamation-circle"),e.style.color="var(--red-3)"):"warnings"===t?(e=i.iconFA("exclamation-circle"),e.style.color="var(--orange-2)"):"notifications"===t&&(e=i.iconFA("info-circle"),e.style.color="var(--blue-1)"),e&&(e.classList.remove("fal"),e.classList.add("far")),e}},1988:(t,e,n)=>{"use strict";n(4570),n(3763);var i=n(581);n(6657),i.H},1991:t=>{"use strict";t.exports=wu},2155:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var s=n.sourceMap;s&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},2158:(t,e,n)=>{"use strict";n(8501),Math.sqrt(2),Math.sqrt(2)},2228:(t,e,n)=>{"use strict";n(3763),n(581).H},2244:(t,e,n)=>{"use strict";n.d(e,{s:()=>E});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=n(1757),l=n.n(a),u=n(3508),c=n.n(u),d=n(5092),p=n(4260),h=n(1599),f=n(5520),m=n(8476),v=n(3143),g=n(810),y=n(9713),b=n(4795),A=n(9879),w=n(6318),C=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const I=new URL(i.shell.startUri),T=()=>C(void 0,void 0,void 0,function*(){const t=yield navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,selfBrowserSurface:"include"}),e=new MediaRecorder(t),n=[];e.ondataavailable=t=>n.push(t.data),e.onstop=()=>{const e=new Blob(n,{type:n[0].type});t.getVideoTracks()[0].stop(),s.Utils.download(`Recording ${(new Date).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}.mkv`,e,n[0].type)},e.start()});class E extends s.ViewBase{constructor(t,e={historyEnabled:!0,isTabbed:!1,skipInit:!1}){var n,a,l,u,c;super(),this.initValue=t,this.options=e,this._type="function",this.funcCallReplaced=new r.Subject,this.isReady=new r.BehaviorSubject(!1),this.exportConfig=null,this.getMocks=null,this.getTemplates=null,this.getHelp=null,this.reportBug=null,this.requestFeature=null,this.getAbout=null,this.historyBlock=null,this.isHistorical=new r.BehaviorSubject(!1),this.historyRoot=o.div(),this.consistencyState=new r.BehaviorSubject("consistent"),this.defaultExportFilename=(t,e)=>`${this.name} - ${(new Date).toLocaleString("en-US").replaceAll(/:|\//g,"-")}.${null!=e?e:this.exportConfig.supportedExtensions[t]}`,this.defaultSupportedExportExtensions=()=>({Excel:"xlsx"}),this.defaultSupportedExportFormats=()=>["Excel"],this.box=!0,this.parentCall=i.functions.getCurrentCall(),t instanceof s.FuncCall&&(this.parentCall=t),this.parentView=null===(l=null===(a=null===(n=this.parentCall)||void 0===n?void 0:n.parentCall)||void 0===a?void 0:a.aux)||void 0===l?void 0:l.view,(null===(c=null===(u=this.parentCall)||void 0===u?void 0:u.func)||void 0===c?void 0:c.name)&&(this.basePath=`/${this.parentCall.func.name}`),e.skipInit||this.init()}onFuncCallReady(){return C(this,void 0,void 0,function*(){if(!this.options.isTabbed){this.name&&"New view"!==this.name||(this.name=this.funcCall.func.friendlyName);try{this.func.package&&(yield this.getPackageData())}catch(t){console.log(t)}}this.build();const t=this.getStartId();if(t&&!this.options.isTabbed&&(o.setUpdateIndicator(this.root,!0),this.loadRun(t),o.setUpdateIndicator(this.root,!1),this.setAsLoaded()),this.isHistoryEnabled&&this.func){const t=this.options.isTabbed?this.isHistorical.subscribe(t=>{t||(this.funcCall.id=null)}):this.isHistorical.subscribe(t=>{var e,n;if(t){this.path=`?id=${this.funcCall.id}`;const t=(0,h.eK)(this.funcCall);this.name.indexOf(" — ")<0?this.name=`${this.name} — ${null!==(e=this.funcCall.options.title)&&void 0!==e?e:t}`:this.name=`${this.name.substring(0,this.name.indexOf(" — "))} — ${null!==(n=this.funcCall.options.title)&&void 0!==n?n:t}`}else this.path="",this.funcCall.id=null,this.name=`${this.name.substring(0,this.name.indexOf(" — ")>0?this.name.indexOf(" — "):void 0)}`});this.subs.push(t)}})}getStartId(){return i.shell.getVar("isLoaded")?void 0:I.searchParams.get("id")}setAsLoaded(){return i.shell.setVar("isLoaded",!0)}get funcCall(){return this._funcCall}get func(){var t;return null===(t=this.funcCall)||void 0===t?void 0:t.func}get lastCall(){return this._lastCall}set lastCall(t){this._lastCall=t}get type(){return this._type}getPackageData(){return C(this,void 0,void 0,function*(){var t,e;const n=this.func.package;if(!n)return;const i=null===(t=yield null==n?void 0:n.getProperties())||void 0===t?void 0:t.REPORT_BUG_URL;i&&!this.reportBug&&(this.reportBug=()=>C(this,void 0,void 0,function*(){window.open(i,"_blank")}));const o=null===(e=yield null==n?void 0:n.getProperties())||void 0===e?void 0:e.REQUEST_FEATURE_URL;o&&!this.requestFeature&&(this.requestFeature=()=>C(this,void 0,void 0,function*(){window.open(o,"_blank")}));const s=`${n.friendlyName}.\nLast updated on ${c()(n.updatedOn).format("YYYY MMM D, HH:mm")}`;this.getAbout||(this.getAbout=()=>C(this,void 0,void 0,function*(){return s}))})}linkFunccall(t){this._funcCall=t,this.funcCallReplaced.next(!0)}loadFuncCallById(){return C(this,void 0,void 0,function*(){if(this.initValue instanceof s.FuncCall)return yield new Promise(t=>setTimeout(t,0)),void this.linkFunccall(this.initValue);o.setUpdateIndicator(this.root,!0);const t=this.getStartId();if(t&&!this.options.isTabbed)this.linkFunccall(yield d.W.loadRun(t));else{const t=s.Func.byName(this.initValue);this.linkFunccall(t.prepare({}))}o.setUpdateIndicator(this.root,!1)})}init(){return C(this,void 0,void 0,function*(){yield this.loadFuncCallById(),yield this.onFuncCallReady(),this.isReady.next(!0)})}build(){o.empty(this.root),this.root.appendChild(this.buildIO()),this.options.historyEnabled&&this.isHistoryEnabled&&this.buildHistoryBlock(),this.buildRibbonMenu(),this.buildRibbonPanels()}onComparisonLaunch(t){return C(this,void 0,void 0,function*(){const e=this.comparatorFunc;if(e){const n=s.Func.byName(e),o=(yield n.prepare({params:{comparedRuns:t}}).call()).outputs.comparisonView;return void i.shell.addView(o)}const n=i.shell.v.parentCall,o=[...i.shell.views].find(t=>t.type===p.sk),r=yield m.S.fromComparedRuns(t,this.func,{parentView:o,parentCall:n});i.shell.addView(r),r.defaultCustomize();const a=this.compareCustomizer;if(a){const t=s.Func.byName(a);return void(yield t.prepare({params:{defaultView:r}}).call())}})}onSaveClick(){return C(this,void 0,void 0,function*(){yield this.saveRun(this.funcCall)})}buildHistoryBlock(){const t=v.A.historyPanel(this.func);let e=!1;return this.subs.push(t.onCompactModeChanged.subscribe(t=>{const e=i.shell.dockManager.findNode(this.historyRoot);e&&(i.shell.dockManager.close(e),t?i.shell.dockManager.dock(this.historyRoot,"right",null,"History",.3):i.shell.dockManager.dock(this.historyRoot,"down",null,"History",.3))}),t.onRunChosen.subscribe(t=>C(this,void 0,void 0,function*(){o.setUpdateIndicator(this.root,!0),yield this.loadRun(t),o.setUpdateIndicator(this.root,!1)})),t.onComparison.subscribe(e=>C(this,void 0,void 0,function*(){(0,g.ZD)(t.root,!0);const n=yield Promise.all(e.map(t=>d.W.loadRun(t)));yield this.onComparisonLaunch(n),(0,g.ZD)(t.root,!1)})),t.afterRunEdited.subscribe(t=>{var e,n;if(t.id===this.funcCall.id&&t.options.title){this.path=`?id=${this.funcCall.id}`;const i=(0,h.eK)(t);this.name.indexOf(" — ")<0?this.name=`${this.name} — ${null!==(e=t.options.title)&&void 0!==e?e:i}`:this.name=`${this.name.substring(0,this.name.indexOf(" — "))} — ${null!==(n=t.options.title)&&void 0!==n?n:i}`}}),i.events.onViewRemoving.subscribe(t=>{if(t.args.view==this){const t=i.shell.dockManager.findNode(this.historyRoot);t?(i.shell.dockManager.close(t),e=!0):e=!1}}),i.events.onCurrentViewChanged.subscribe(()=>{var t;if(i.shell.v==this)e&&((null===(t=this.historyBlock)||void 0===t?void 0:t.compactMode)?i.shell.dockManager.dock(this.historyRoot,"right",null,"History",.3):i.shell.dockManager.dock(this.historyRoot,"down",null,"History",.3));else{const t=i.shell.dockManager.findNode(this.historyRoot);t?(i.shell.dockManager.close(t),e=!0):e=!1}})),o.empty(this.historyRoot),this.historyRoot.style.removeProperty("justify-content"),this.historyRoot.append(t.root),this.historyBlock=t,t.root}buildRibbonPanels(){const t=o.iconFA("history",()=>{var t;i.shell.dockManager.findNode(this.historyRoot)||((null===(t=this.historyBlock)||void 0===t?void 0:t.compactMode)?i.shell.dockManager.dock(this.historyRoot,"right",null,"History",.3):i.shell.dockManager.dock(this.historyRoot,"down",null,"History",.3),this.historyRoot.parentElement.classList.add("ui-box"),this.historyRoot.classList.add("ui-box"))}),e=o.iconFA("save",()=>C(this,void 0,void 0,function*(){yield this.onSaveClick()}),"Save current state"),n=o.comboPopup(o.iconFA("arrow-to-bottom"),this.getFormats(),this.exportRun.bind(this)),s=o.iconFA("edit",()=>{this.historyBlock&&this.lastCall&&this.historyBlock.showEditDialog(this.historyBlock.history.get(this.funcCall.id))},"Edit this run metadata"),r=this.isHistorical.subscribe(t=>{t?(o.setDisplay(n,!(0,h.Ne)(this.funcCall)),o.setDisplay(s,!0)):(l()(n).hide(),l()(s).hide())});if(this.subs.push(r),o.tooltip.bind(n,()=>"inconsistent"===this.consistencyState.value&&this.mandatoryConsistent?"Current run is inconsistent. Export feature is disabled.":null),!this.options.isTabbed&&this.mandatoryConsistent){const t=this.consistencyState.pipe((0,y.distinctUntilChanged)()).subscribe(t=>{"inconsistent"===t?(l()(n).addClass("d4-disabled"),l()(n.lastChild).css("color","unset")):(l()(n).removeClass("d4-disabled"),l()(n.lastChild).removeProp("color"))});this.subs.push(t)}const a=[[...!this.options.isTabbed&&this.isHistoryEnabled&&this.options.historyEnabled?[t]:[],...!this.options.isTabbed&&this.isHistoryEnabled?[e]:[],...!this.options.isTabbed&&this.isExportEnabled&&this.exportConfig&&this.exportConfig.supportedFormats.length>0?[n]:[],...this.options.isTabbed?[]:[s]]];return this.setRibbonPanels(a),a}buildRibbonMenu(){if(this.ribbonMenu.clear(),!(this.exportConfig||this.reportBug||this.requestFeature||this.getHelp||this.getMocks||this.getTemplates))return;const t=this.ribbonMenu.group("Model");if(this.getMocks&&this.getMocks.length>0)if(1===this.getMocks.length)t.item("Input data mock",this.getMocks[0].action);else{const e=t.group("Input data mocks");this.getMocks.forEach(t=>{e.item(t.mockName,t.action)}),t.endGroup()}if(this.getTemplates&&this.getTemplates.length>0)if(1===this.getTemplates.length)t.item("Input data template",this.getTemplates[0].action);else{const e=t.group("Input data templates");this.getTemplates.forEach(t=>{e.item(t.name,t.action)}),t.endGroup()}this.isExportEnabled&&this.exportConfig&&this.exportConfig.supportedFormats.length>0&&t.group("Export").items(this.getFormats(),this.exportRun.bind(this),{isValid:()=>this.isHistorical.value?this.mandatoryConsistent&&"inconsistent"===this.consistencyState.value?"Run should be consistent to be exported":null:"Run should be completed to be exported"}).endGroup(),this.reportBug&&t.item("Report a bug",()=>this.reportBug()),this.requestFeature&&t.item("Request a feature",()=>this.requestFeature()),this.getHelp&&t.item("Help",()=>this.getHelp()),setTimeout(()=>C(this,void 0,void 0,function*(){if((yield(yield fetch(`${window.location.origin}/api/groups/all_parents`)).json()).find(t=>"Developers"===t.friendlyName)){const e=t.group("Test runner");e.item("Run Data JSON",()=>this.importRunJsonDialog()),e.item("Execute Test JSON",()=>this.importRunJsonDialog()),e.item("Update Test JSON",()=>this.importRunJsonDialog(!0)),t.endGroup()}}),0),t.item("Record the screen",T),this.getAbout&&t.item("About",()=>C(this,void 0,void 0,function*(){const t=yield this.getAbout();if(t){const e=o.dialog("Current version");t.split("\n").forEach(t=>e.add(o.label(t))),e.onOK(()=>{}),e.getButton("CANCEL").style.display="none",e.show({center:!0})}}))}exportRun(t){return C(this,void 0,void 0,function*(){s.Utils.download(this.exportConfig.filename(t),yield this.exportConfig.export(t))})}getFormats(){var t,e;return null!==(e=null===(t=this.exportConfig)||void 0===t?void 0:t.supportedFormats)&&void 0!==e?e:[]}onBeforeSaveRun(t){return C(this,void 0,void 0,function*(){})}onAfterSaveRun(t){return C(this,void 0,void 0,function*(){})}saveRun(t){return C(this,void 0,void 0,function*(){let e=(0,h.A4)(t);yield this.onBeforeSaveRun(e),(0,h.Ne)(e)&&(e=yield(0,b.Hs)(t)),e.id&&e.newId();const n=yield d.W.saveRun(e),i=yield d.W.loadRun(n.id);return this.options.historyEnabled&&this.isHistoryEnabled&&this.historyBlock&&this.historyBlock.addRun(i),this.linkFunccall(i),this.isHistorical.next(!0),yield this.onAfterSaveRun(n),n})}onBeforeDeleteRun(t){return C(this,void 0,void 0,function*(){})}onAfterDeleteRun(t){return C(this,void 0,void 0,function*(){})}deleteRun(t){return C(this,void 0,void 0,function*(){return yield this.onBeforeDeleteRun(t),yield d.W.deleteRun(t),yield this.onAfterDeleteRun(t),t.id})}onBeforeLoadRun(){return C(this,void 0,void 0,function*(){})}onAfterLoadRun(t){return C(this,void 0,void 0,function*(){})}loadRun(t){return C(this,void 0,void 0,function*(){yield this.onBeforeLoadRun();const e=yield d.W.loadRun(t);return this.lastCall=(0,h.A4)(e),this.linkFunccall(e),this.isHistorical.next(!0),yield this.onAfterLoadRun(e),e})}onBeforeRun(t){return C(this,void 0,void 0,function*(){})}onAfterRun(t){return C(this,void 0,void 0,function*(){})}run(){return C(this,void 0,void 0,function*(){if(!this.funcCall)throw new Error("The correspoding function is not specified");yield this.onBeforeRun(this.funcCall);const t=s.TaskBarProgressIndicator.create("Calculating...");try{this.funcCall.newId(),yield this.funcCall.call(),yield this.onAfterRun(this.funcCall),this.lastCall=(0,h.A4)(this.funcCall),this.options.isTabbed||this.runningOnInput||!this.isHistoryEnabled||(yield this.saveRun(this.funcCall))}catch(t){i.shell.error(t.toString())}finally{t.close()}})}exportRunJson(){return C(this,void 0,void 0,function*(){if(this._lastCall){const t=yield(0,b.wB)(this._lastCall,this);return(0,f.lK)(t)}})}getRunJSON(){return C(this,void 0,void 0,function*(){const t=yield this.exportRunJson();t&&s.Utils.download(this.defaultExportFilename("","json"),t)})}importRunJsonDialog(){return C(this,arguments,void 0,function*(t=!1){const e=new A.z("JSON file",null,null,"application/json"),n={modal:!0,fullScreen:!0,width:500,height:200,center:!0};if(!(yield new Promise((t,i)=>{o.dialog({title:"Import Run JSON"}).add(o.div([o.inputs([e])])).onOK(()=>t(!0)).onCancel(()=>t(!1)).show(n)}))||!e.value)return;const i=(0,f.iu)(yield e.value.text());t?(yield this.executeTest(i,!0),yield this.isHistorical.pipe((0,y.filter)(t=>t),(0,y.take)(1),(0,y.delay)(0)).toPromise(),yield this.getRunJSON()):yield this.executeTest(i)})}executeTest(t){return C(this,arguments,void 0,function*(t,e=!1){yield(0,w.c)(t,this,{updateMode:e,interactive:!0})})}get compareCustomizer(){var t;return null!==(t=this.func.options.compareCustomizer)&&void 0!==t?t:null}get comparatorFunc(){var t;return null!==(t=this.func.options.comparatorFunc)&&void 0!==t?t:null}get uploadFunc(){var t;return null!==(t=this.func.options.uploadFunc)&&void 0!==t?t:null}get runningOnInput(){return(0,h.vk)(this.func)}get runningOnStart(){return"true"===this.func.options.runOnOpen}get mainParams(){return this.func.options.mainParams?JSON.parse(this.func.options.mainParams):null}get mandatoryConsistent(){var t;return"true"===(null===(t=this.parentCall)||void 0===t?void 0:t.func.options.mandatoryConsistent)}get hasContextHelp(){return!!(0,h.HP)(this.func)}getContextHelp(){return C(this,void 0,void 0,function*(){return(0,h.zF)(this.func)})}get features(){return(0,h.i)(this.func)}getFeature(t,e){return(0,h.x$)(this.features,t,e)}get isExportEnabled(){return this.getFeature("export",!0)}get isHistoryEnabled(){return this.getFeature("history",!0)}get isSaEnabled(){return this.getFeature("sens-analysis",!1)}get hasUploadMode(){return this.getFeature("upload",!1)}get isFittingEnabled(){return this.getFeature("fitting",!1)}get isOptimizationEnabled(){return this.getFeature("optimization",!1)}}},2515:(t,e,n)=>{"use strict";n(4570)},2562:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(5516),o=n.n(i),s=n(1364),r=n.n(s)()(o());r.push([t.id,".optimization-type-input {\n font-size: 14px;\n font-weight: bold;\n max-width: 90px;\n border: white;\n}\n\n.optimization-view-help-icon {\n font-size: large;\n margin-right: 8px;\n font-weight: bold;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/function-views/css/optimization-view.css"],names:[],mappings:"AAAA;IACI,eAAe;IACf,iBAAiB;IACjB,eAAe;IACf,aAAa;AACjB;;AAEA;IACI,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;AACrB",sourcesContent:[".optimization-type-input {\n font-size: 14px;\n font-weight: bold;\n max-width: 90px;\n border: white;\n}\n\n.optimization-view-help-icon {\n font-size: large;\n margin-right: 8px;\n font-weight: bold;\n}"],sourceRoot:""}]);const a=r},2650:(t,e,n)=>{"use strict";n.r(e),n.d(e,{AmbTempValidator:()=>g.ZO,CFV:()=>x,CompView:()=>E,CustomCustomizer:()=>g.Vu,CustomDataUploader:()=>g.wN,CustomStringInput:()=>g.dg,CustomUploader:()=>g.wx,DesiredTempValidator:()=>g.ze,HeatCapValidator:()=>g.b9,InitialTempValidator:()=>g.pE,ObjectCoolingSelector:()=>g.CY,OutliersSelection:()=>g.Qc,PackageFunctions:()=>$,Pipeline:()=>R,PipelineStepEditor:()=>g.u0,RFV:()=>S,RichFunctionViewEditor:()=>g.jO,SimTimeValidator:()=>g.Ln,_package:()=>C,deepCopy:()=>T,fileInput:()=>L,fitTestFunc:()=>g.yZ,historyInput:()=>P,historyInputJSON:()=>_,historyPanel:()=>k,init:()=>g.Ts,makeAdvice:()=>N,makeRevalidation:()=>F,makeValidationResult:()=>O,mergeValidationResults:()=>M,modelCatalog:()=>g.Dv,modelCatalogTreeBrowser:()=>g.bG,openModelFromFuncall:()=>g.Vb,renderPanel:()=>g.vZ,testFittingOutputs:()=>g.ge,testPipeline:()=>I});var i=n(4328),o=n(7389),s=n(6082),r=n(9713),a=n(6126),l=n(5727),u=n(3501),c=n(3143),d=n(1927),p=n(9524),h=n(9939),f=n(392),m=n(1599),v=n(3902),g=n(2961),y=function(t,e,n,i){var o,s=arguments.length,r=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(s<3?o(r):s>3?o(e,n,r):o(e,n))||r);return s>3&&r&&Object.defineProperty(e,n,r),r},b=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},A=function(t,e){return function(n,i){e(n,i,t)}},w=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const C=new s.Package,I=l.bS,T=m.A4,E=l.HJ,S=l.Ee,x=u.v,R=l.uf,O=d.ZS,N=d.B5,F=d.dQ,M=d.uD,L=c.A.fileInput,P=c.A.historyInput,_=c.A.historyInputJSON,k=c.A.historyPanel;let V=!1,D=!1;const B={_package:C,ViewClass:p.a,segment:"Modelhub",viewName:"Model Hub",funcName:"modelCatalog",setStartUriLoaded:()=>V=!0,getStartUriLoaded:()=>V};class ${static openModelFromFuncall(t){h.s.openModelFromFunccall(t)}static OutliersSelection(){return new a.A}static RichFunctionViewEditor(t){return l.Ee.fromFuncCall(t,{historyEnabled:!0,isTabbed:!1})}static PipelineStepEditor(t){return l.Ee.fromFuncCall(t,{historyEnabled:!1,isTabbed:!0})}static renderPanel(t){return w(this,void 0,void 0,function*(){return(0,f.lp)(t)})}static init(){D||((0,f.jd)(),(0,f.a8)(B),D=!0)}static modelCatalog(){return(0,f.v_)(B)}static modelCatalogTreeBrowser(t,e){(0,f.I3)(t)}static CustomDataUploader(t){return w(this,void 0,void 0,function*(){return yield new Promise(t=>setTimeout(t,1e3)),[yield t.prepare({ambTemp:22,initTemp:100,desiredTemp:30,area:.06,heatCap:4200,heatTransferCoeff:8.3,simTime:21600}).call()]})}static CustomUploader(t){return w(this,void 0,void 0,function*(){const e=(yield i.functions.eval("Compute:CustomDataUploader")).prepare({func:t.func}),n=o.bigButton("Click me to get mock calls",()=>e.call()),a=s.Widget.fromRoot(o.panel([o.divV([o.label("This part of dialog comes from my custom data uploader"),o.divH([n],{style:{justifyContent:"center"}})])])),l=i.functions.onBeforeRunAction.pipe((0,r.filter)(t=>t.id===e.id)).subscribe(()=>{o.setUpdateIndicator(n,!0)}),u=i.functions.onAfterRunAction.pipe((0,r.filter)(t=>t.id===e.id)).subscribe(()=>{o.setUpdateIndicator(n,!1)});return a.subs.push(l,u),{uploadWidget:a,uploadFuncCall:e}})}static CustomCustomizer(t){t.defaultView.scatterPlot({xColumnName:"Initial temperature",yColumnName:"Time to cool"})}static SimTimeValidator(t){const{reasonableMin:e,reasonableMax:n}=t;return t=>(0,d.ZS)({warnings:t<e||t>n?[`Minimum reasonable time is ${e}. Maximum reasonable time is ${n}`]:void 0,errors:t<0?["Time should be strictly positive"]:void 0})}static DesiredTempValidator(t){return(t,e)=>{const n=e.funcCall.inputs.ambTemp,i=e.funcCall.inputs.initTemp;return(0,d.ZS)({errors:[...t<n?[(0,d.B5)(`Desired temperature cannot be less than ambient temperature (${n}). \n`,[{actionName:"Set desired equal to ambient",action:()=>e.funcCall.inputs.desiredTemp=n}])]:[],...t>i?[`Desired temperature cannot be higher than initial temperature (${i})`]:[]]})}}static InitialTempValidator(t){return(t,e)=>{const n=e.funcCall.inputs.ambTemp;return(0,d.ZS)({errors:[...t<n?[`Initial temperature cannot be less than ambient temperature (${n}).`]:[]]})}}static AmbTempValidator(t){return(t,e)=>{const n=e.funcCall.inputs.initTemp;return(0,d.ZS)({errors:[...t>n?[`Ambient temperature cannot be higher than initial temperature (${n})`]:[]]})}}static HeatCapValidator(t){return(t,e)=>(0,d.ZS)({errors:[...t<=0?["Heat capacity must be greater than zero."]:[]],notifications:[(0,d.B5)("Heat capacity is only dependent on the object material.",[{actionName:"Google it",action:()=>{window.open("http://google.com")}}])]})}static CustomStringInput(t){const e=o.input.string("Custom input",{value:""});return e.root.style.backgroundColor="aqua",e.input.style.backgroundColor="aqua",e}static ObjectCoolingSelector(t){return c.A.historyInputJSON("Previous run","ObjectCooling")}static fitTestFunc(t,e,n,i){return{integer:Math.pow(t,3)*(t-1)*Math.pow(e,3)*(e-1),float1:Math.pow(e-1,2)+Math.pow(t-1,2),float2:Math.pow(e-1,4)+Math.pow(t-1,4),table1:s.DataFrame.fromColumns([s.Column.fromList(s.COLUMN_TYPE.FLOAT,"arg",[1,2,3,4,5]),s.Column.fromList(s.COLUMN_TYPE.FLOAT,"func",[t+e+1,4,9,16,25])]),table2:s.DataFrame.fromColumns([s.Column.fromList(s.COLUMN_TYPE.FLOAT,"arg",[1,2,3,4,5]),s.Column.fromList(s.COLUMN_TYPE.FLOAT,"func",[t+e+1,8,27,64,125])])}}static testFittingOutputs(){return w(this,void 0,void 0,function*(){const t=yield i.functions.find("Compute:fitTestFunc");if(null===t)return void i.shell.error('The function "Compute:fitTestFunc" not found!');const e=s.DataFrame.fromColumns([s.Column.fromList(s.COLUMN_TYPE.FLOAT,"arg",[1,2,3,4,5]),s.Column.fromList(s.COLUMN_TYPE.FLOAT,"func",[1,4.3,9.1,16,25])]);e.name="test-df1";const n=s.DataFrame.fromColumns([s.Column.fromList(s.COLUMN_TYPE.FLOAT,"arg",[1,2,3,4,5]),s.Column.fromList(s.COLUMN_TYPE.FLOAT,"func",[1,8.5,27.6,64.9,125])]);n.name="test-df2",yield v.v.fromEmpty(t,{targets:{integer:{default:123,enabled:!0},float1:{default:456.789,enabled:!0},table1:{default:e,enabled:!0,argumentCol:"arg"},table2:{default:n,enabled:!0,argumentCol:"arg"}}})})}}y([i.decorators.func(),b("design:type",Function),b("design:paramtypes",[s.FuncCall]),b("design:returntype",void 0)],$,"openModelFromFuncall",null),y([i.decorators.func({tags:["viewer"],name:"OutliersSelectionViewer",description:"Creates an outliers selection viewer",outputs:[{type:"viewer",name:"result"}]}),b("design:type",Function),b("design:paramtypes",[]),b("design:returntype",void 0)],$,"OutliersSelection",null),y([i.decorators.editor({outputs:[{type:"view",name:"result"}]}),b("design:type",Function),b("design:paramtypes",[s.FuncCall]),b("design:returntype",void 0)],$,"RichFunctionViewEditor",null),y([i.decorators.editor({outputs:[{type:"view",name:"result"}]}),b("design:type",Function),b("design:paramtypes",[s.FuncCall]),b("design:returntype",void 0)],$,"PipelineStepEditor",null),y([i.decorators.func({name:"renderRestPanel"}),A(0,i.decorators.param({type:"func"})),b("design:type",Function),b("design:paramtypes",[s.Func]),b("design:returntype",Promise)],$,"renderPanel",null),y([i.decorators.init(),b("design:type",Function),b("design:paramtypes",[]),b("design:returntype",void 0)],$,"init",null),y([i.decorators.app({browsePath:"Compute",name:"Model Hub",outputs:[{type:"view",name:"result"}]}),b("design:type",Function),b("design:paramtypes",[]),b("design:returntype",void 0)],$,"modelCatalog",null),y([i.decorators.func({meta:{role:" ",app:" "}}),b("design:type",Function),b("design:paramtypes",[s.TreeViewGroup,s.ViewBase]),b("design:returntype",void 0)],$,"modelCatalogTreeBrowser",null),y([i.decorators.func({outputs:[{type:"object",name:"uploadedCalls"}]}),b("design:type",Function),b("design:paramtypes",[s.Func]),b("design:returntype",Promise)],$,"CustomDataUploader",null),y([i.decorators.func({outputs:[{name:"uploadWidget",type:"widget"},{name:"uploadFuncCall",type:"funccall"}]}),A(0,i.decorators.param({type:"object"})),b("design:type",Function),b("design:paramtypes",[Object]),b("design:returntype",Promise)],$,"CustomUploader",null),y([i.decorators.func(),A(0,i.decorators.param({type:"object"})),b("design:type",Function),b("design:paramtypes",[Object]),b("design:returntype",void 0)],$,"CustomCustomizer",null),y([i.decorators.func({outputs:[{type:"object",name:"validator"}]}),A(0,i.decorators.param({type:"object"})),b("design:type",Function),b("design:paramtypes",[Object]),b("design:returntype",void 0)],$,"SimTimeValidator",null),y([i.decorators.func({outputs:[{type:"object",name:"validator"}]}),A(0,i.decorators.param({type:"object"})),b("design:type",Function),b("design:paramtypes",[Object]),b("design:returntype",void 0)],$,"DesiredTempValidator",null),y([i.decorators.func({outputs:[{type:"object",name:"validator"}]}),A(0,i.decorators.param({type:"object"})),b("design:type",Function),b("design:paramtypes",[Object]),b("design:returntype",void 0)],$,"InitialTempValidator",null),y([i.decorators.func({outputs:[{type:"object",name:"validator"}]}),A(0,i.decorators.param({type:"object"})),b("design:type",Function),b("design:paramtypes",[Object]),b("design:returntype",void 0)],$,"AmbTempValidator",null),y([i.decorators.func({outputs:[{type:"object",name:"validator"}]}),A(0,i.decorators.param({type:"object"})),b("design:type",Function),b("design:paramtypes",[Object]),b("design:returntype",void 0)],$,"HeatCapValidator",null),y([i.decorators.func({outputs:[{type:"object",name:"result"}]}),A(0,i.decorators.param({type:"object"})),b("design:type",Function),b("design:paramtypes",[Object]),b("design:returntype",void 0)],$,"CustomStringInput",null),y([i.decorators.func({outputs:[{type:"object",name:"result"}]}),A(0,i.decorators.param({type:"object"})),b("design:type",Function),b("design:paramtypes",[Object]),b("design:returntype",void 0)],$,"ObjectCoolingSelector",null),y([i.decorators.func({meta:{features:'{"fitting": true, "sens-analysis": true}',runOnOpen:"true",runOnInput:"true"},outputs:[{name:"integer",type:"int"},{name:"float1",type:"double"},{name:"float2",type:"double"},{name:"table1",type:"dataframe",options:{viewer:"Line chart(block:60) | Grid(block:40)"}},{name:"table2",type:"dataframe",options:{viewer:"Line chart(block:60) | Grid(block:40)"}}],description:"Test for optimization: multiple scalars output",editor:"Compute:RichFunctionViewEditor"}),A(0,i.decorators.param({options:{caption:"param1",min:"-3",max:"3",initialValue:"1"}})),A(1,i.decorators.param({options:{caption:"param2",min:"-3",max:"3",initialValue:"-1"}})),A(2,i.decorators.param({options:{caption:"table"}})),b("design:type",Function),b("design:paramtypes",[Number,Number,s.DataFrame,Boolean]),b("design:returntype",void 0)],$,"fitTestFunc",null),y([i.decorators.func({description:"Test for optimization: multiple scalars output"}),b("design:type",Function),b("design:paramtypes",[]),b("design:returntype",Promise)],$,"testFittingOutputs",null)},2917:(t,e,n)=>{"use strict";n.d(e,{R:()=>a});var i=n(6082),o=n(804),s=n(1005),r=n(8405);class a{constructor(t,e,n,i){if(!(0,o.xu)(e))throw new Error(`Invalid inputs dimension: ${e}. The optimizer issue`);if(!(0,o.xu)(n))throw new Error(`Invalid outputs dimension: ${n}. The optimizer issue`);const s=t.table;if(null===s)throw new Error("Null dataframe with optimization resuls. The optimizer issue");this.view=t,this.table=s,this.inputDim=e,this.outputDim=n,this.type=i,this.colNames=s.columns.names();const r=this.view.dockManager.findNode(this.view.grid.root);if(void 0===r)throw new Error("The view is corrupted: not found the grid");this.gridNode=r}visualize(){return this.setColorCoding(),this.sortResults(),this.addViewers()}setColorCoding(){const t=this.table.columns;for(let e=0;e<this.inputDim;++e){const n=t.byIndex(e);n.meta.colors.setLinear(r.VV,{min:n.stats.min,max:n.stats.max})}for(let e=this.inputDim;e<this.inputDim+this.outputDim;++e){const n=t.byIndex(e);n.meta.colors.setLinear((0,r.F4)(this.type),{min:n.stats.min,max:n.stats.max})}}sortResults(){if(1!==this.outputDim)return;const t=this.table.columns.byIndex(this.inputDim).name;this.view.grid.sort([t],[this.type===s.RF.MIN])}addViewers(){return this.outputDim>2||2===this.outputDim?this.addMultipleInputsMultipleOutputViewers():1===this.inputDim?this.addSingleInputSingleOutputViewer():this.addMultipleInputsSingeOutputViewers()}getScatter(){return i.Viewer.scatterPlot(this.table,{xColumnName:this.colNames[0],yColumnName:this.colNames[1],colorColumnName:this.colNames[this.inputDim]})}getParetoScatter(){return i.Viewer.scatterPlot(this.table,{title:r.ly.PARETO_FRONT,xColumnName:this.colNames[this.inputDim],yColumnName:this.colNames[this.inputDim+1],colorColumnName:1===this.inputDim?this.colNames[0]:this.outputDim>=3?this.colNames[this.inputDim+2]:void 0,labelColumnNames:2===this.inputDim?[this.colNames[0],this.colNames[1]]:void 0})}getPc(){return i.Viewer.pcPlot(this.table,{showColorSelector:!1})}addSingleInputSingleOutputViewer(){const t=this.getScatter();return this.view.dockManager.dock(t,i.DOCK_TYPE.LEFT,this.gridNode,void 0,r.KN.SINGLE_SINGLE_SCATTER),[t]}addMultipleInputsSingeOutputViewers(){const t=this.getScatter(),e=this.view.dockManager.dock(t,i.DOCK_TYPE.LEFT,this.gridNode,void 0,r.KN.SINGLE_SINGLE_SCATTER),n=this.getPc();return this.view.dockManager.dock(n,i.DOCK_TYPE.DOWN,e,void 0,r.KN.MULT_SINGLE_PC),[t,n]}addMultipleInputsMultipleOutputViewers(){const t=this.getParetoScatter(),e=this.view.dockManager.dock(t,i.DOCK_TYPE.LEFT,this.gridNode,void 0,r.KN.SINGLE_SINGLE_SCATTER),n=this.getPc();return this.view.dockManager.dock(n,i.DOCK_TYPE.DOWN,e,void 0,r.KN.MULT_SINGLE_PC),[t,n]}}},2961:(t,e,n)=>{"use strict";n.d(e,{CY:()=>C,Dv:()=>d,Ln:()=>v,Qc:()=>r,Ts:()=>c,Vb:()=>s,Vu:()=>m,ZO:()=>b,b9:()=>A,bG:()=>p,dg:()=>w,ge:()=>T,jO:()=>a,pE:()=>y,u0:()=>l,vZ:()=>u,wN:()=>h,wx:()=>f,yZ:()=>I,ze:()=>g});var i=n(2650),o=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};function s(t){i.PackageFunctions.openModelFromFuncall(t)}function r(){return i.PackageFunctions.OutliersSelection()}function a(t){return i.PackageFunctions.RichFunctionViewEditor(t)}function l(t){return i.PackageFunctions.PipelineStepEditor(t)}function u(t){return o(this,void 0,void 0,function*(){return yield i.PackageFunctions.renderPanel(t)})}function c(){i.PackageFunctions.init()}function d(){return i.PackageFunctions.modelCatalog()}function p(t,e){i.PackageFunctions.modelCatalogTreeBrowser(t,e)}function h(t){return o(this,void 0,void 0,function*(){return yield i.PackageFunctions.CustomDataUploader(t)})}function f(t){return o(this,void 0,void 0,function*(){return yield i.PackageFunctions.CustomUploader(t)})}function m(t){i.PackageFunctions.CustomCustomizer(t)}function v(t){return i.PackageFunctions.SimTimeValidator(t)}function g(t){return i.PackageFunctions.DesiredTempValidator(t)}function y(t){return i.PackageFunctions.InitialTempValidator(t)}function b(t){return i.PackageFunctions.AmbTempValidator(t)}function A(t){return i.PackageFunctions.HeatCapValidator(t)}function w(t){return i.PackageFunctions.CustomStringInput(t)}function C(t){return i.PackageFunctions.ObjectCoolingSelector(t)}function I(t,e,n,o){return i.PackageFunctions.fitTestFunc(t,e,n,o)}function T(){return o(this,void 0,void 0,function*(){yield i.PackageFunctions.testFittingOutputs()})}},2993:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(5516),o=n.n(i),s=n(1364),r=n.n(s)()(o());r.push([t.id,".ui-form .ui-input-root .sa-switch-input {\n max-width: 50px;\n min-width: 50px;\n}\n\n.ui-form.ui-form-condensed .ui-input-root .sa-switch-input {\n order: -3;\n top: -5px;\n position: relative;\n}\n\n.ui-form.ui-form-condensed .ui-input-root > .sa-switch-input + label.ui-input-label:not(:empty) {\n width: unset;\n}\n\n.ui-form.ui-form-condensed .ui-input-root > .sa-switch-input ~ .ui-input-editor {\n margin-left: 50px;\n}\n\n.sensitivity-analysis-svg-icon { \n height: 24px;\n width: 24px;\n}\n\n.sensitivity-analysis-help-icon {\n font-size: large;\n margin-right: 8px;\n font-weight: bold;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/function-views/css/sens-analysis.css"],names:[],mappings:"AAAA;IACI,eAAe;IACf,eAAe;AACnB;;AAEA;IACI,SAAS;IACT,SAAS;IACT,kBAAkB;AACtB;;AAEA;IACI,YAAY;AAChB;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,YAAY;IACZ,WAAW;AACf;;AAEA;IACI,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;AACrB",sourcesContent:[".ui-form .ui-input-root .sa-switch-input {\n max-width: 50px;\n min-width: 50px;\n}\n\n.ui-form.ui-form-condensed .ui-input-root .sa-switch-input {\n order: -3;\n top: -5px;\n position: relative;\n}\n\n.ui-form.ui-form-condensed .ui-input-root > .sa-switch-input + label.ui-input-label:not(:empty) {\n width: unset;\n}\n\n.ui-form.ui-form-condensed .ui-input-root > .sa-switch-input ~ .ui-input-editor {\n margin-left: 50px;\n}\n\n.sensitivity-analysis-svg-icon { \n height: 24px;\n width: 24px;\n}\n\n.sensitivity-analysis-help-icon {\n font-size: large;\n margin-right: 8px;\n font-weight: bold;\n}"],sourceRoot:""}]);const a=r},3033:(t,e,n)=>{"use strict";var i=n(9131);n(8501),i.Y},3036:(t,e,n)=>{"use strict";n.d(e,{S:()=>o});var i=n(6657);function o(t,e){const n=e.deqs.solutionNames.length,o=null!==e.params?e.params.size:0,s=null!==e.loop?i.JL:0,r=i.Zg+n+o+s,a=new Float64Array(r);i.Bm.forEach((e,n)=>{if(!(n in t))throw new Error(`Inconsistent inputs: "${n}" is missing`);a[e]=t[n]});let l=i.Zg;if(e.deqs.solutionNames.forEach(e=>{if(!(e in t))throw new Error(`Inconsistent inputs: "${e}" is missing`);a[l]=t[e],++l}),null!==e.params&&e.params.forEach((e,n)=>{if(!(n in t))throw new Error(`Inconsistent inputs: "${n}" is missing`);a[l]=t[n],++l}),null!==e.loop){if(!(i.PM in t))throw new Error(`Inconsistent inputs, loop repetitions count is not defined: "${i.PM}" is missing`);a[l]=t[i.PM],++l}return a}},3143:(t,e,n)=>{"use strict";n.d(e,{A:()=>i});var i,o=n(9879),s=n(8867),r=n(7109);!function(t){t.fileInput=function(t="Drag-n-drop here",e=null,n=null,i=o.R){return new o.z(t,e,n,i)},t.historyInput=function(t,e,n){return new s.PT(t,e,n)},t.historyInputJSON=function(t,e,n){return new s.RP(t,e,n)},t.historyPanel=function(t){return new r.b(t)}}(i||(i={}))},3188:(t,e,n)=>{"use strict";n.d(e,{AK:()=>i.A,S3:()=>o.S}),n(9688);var i=n(3763),o=(n(581),n(2228),n(559),n(1988),n(3036))},3469:(t,e,n)=>{"use strict";n.d(e,{L:()=>i});const i={name:"Robertson",arg:{name:"t",start:0,finish:1e12,step:25e6},initial:[1,0,0],func:(t,e,n)=>{n[0]=-.04*e[0]+1e4*e[1]*e[2],n[1]=.04*e[0]-1e4*e[1]*e[2]-3e7*Math.pow(e[1],2),n[2]=3e7*Math.pow(e[1],2)},tolerance:1e-7,solutionColNames:["A","B","C"]}},3501:(t,e,n)=>{"use strict";n.d(e,{v:()=>h});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=n(6910),l=n(1599),u=n(5092),c=n(9713),d=n(8804),p=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class h extends s.ViewBase{constructor(t){super(),this.funcNqName=t,this.showHistory=new r.BehaviorSubject(!1),this.isReady=new r.BehaviorSubject(!1),this.historyRoot=o.div("",{style:{height:"100%",width:"100%"}}),this.exportConfig=null,this.getMocks=null,this.getTemplates=null,this.getHelp=null,this.reportBug=null,this.requestFeature=null,this.box=!0,this.init()}onBeforeSaveRun(t){return p(this,void 0,void 0,function*(){})}onAfterSaveRun(t){return p(this,void 0,void 0,function*(){})}init(){return p(this,void 0,void 0,function*(){const t=this.getStartId();if(t){this.setAsLoaded();const e=yield u.W.loadRun(t);this.linkFunccall(e),yield this.onFuncCallReady(),yield this.onAfterLoadRun(e)}else{const t=s.Func.byName(this.funcNqName);this.linkFunccall(t.prepare({})),yield this.onFuncCallReady()}this.isReady.next(!0)})}linkFunccall(t){var e,n,i;this.funcCall=t,this.path=t.author?`?id=${t.id}`:"?";const o=null!==(n=null===(e=null==t?void 0:t.func)||void 0===e?void 0:e.friendlyName)&&void 0!==n?n:null===(i=null==t?void 0:t.func)||void 0===i?void 0:i.name;this.name=o}onFuncCallReady(){return p(this,void 0,void 0,function*(){yield this.getPackageData(),this.build()})}saveRun(t){return p(this,void 0,void 0,function*(){const e=(0,l.A4)(t);yield this.onBeforeSaveRun(e),e.id&&e.newId();const n=yield u.W.saveRun(e),i=yield u.W.loadRun(n.id);return this.linkFunccall(i),yield this.onAfterSaveRun(i),i})}saveRunWithDialog(t){return p(this,void 0,void 0,function*(){const e=d.V.forFuncCall(t);e.onMetadataEdit.pipe((0,c.take)(1)).subscribe(e=>p(this,void 0,void 0,function*(){t.options.title=e.title,t.options.description=e.description,t.options.tags=e.tags;const n=yield this.saveRun(t);yield(0,a.WM)(n,!!e.isFavorite)})),e.show({center:!0,width:500})})}loadRun(t){return p(this,void 0,void 0,function*(){const e=yield u.W.loadRun(t);return this.linkFunccall(e),yield this.onAfterLoadRun(e),e})}build(){o.empty(this.root);const t=o.div([this.buildIO(),this.historyRoot],{style:{width:"100%",height:"100%",display:"flex"}});this.root.appendChild(t),this.buildRibbonMenu(),this.buildRibbonPanels()}buildRibbonPanels(){const t=o.iconFA("history",()=>this.showHistory.next(!this.showHistory.value)),e=o.iconFA("save",()=>this.funcCall?this.saveRunWithDialog(this.funcCall):void 0),n=o.comboPopup(o.iconFA("arrow-to-bottom"),this.getFormats(),this.exportRun.bind(this)),i=[[t,e,...this.hasExport()?[n]:[]]];return this.setRibbonPanels(i),i}buildRibbonMenu(){if(this.ribbonMenu.clear(),!(this.exportConfig||this.reportBug||this.requestFeature||this.getHelp||this.getMocks||this.getTemplates))return;const t=this.ribbonMenu.group("Model");if(this.getMocks&&this.getMocks.length>0)if(1===this.getMocks.length)t.item("Input data mock",this.getMocks[0].action);else{const e=t.group("Input data mocks");this.getMocks.forEach(t=>{e.item(t.mockName,t.action)}),t.endGroup()}if(this.getTemplates&&this.getTemplates.length>0)if(1===this.getTemplates.length)t.item("Input data template",this.getTemplates[0].action);else{const e=t.group("Input data templates");this.getTemplates.forEach(t=>{e.item(t.name,t.action)}),t.endGroup()}this.hasExport()&&t.group("Export").items(this.getFormats(),this.exportRun.bind(this)).endGroup(),this.reportBug&&t.item("Report a bug",()=>this.reportBug()),this.requestFeature&&t.item("Request a feature",()=>this.requestFeature()),this.getHelp&&t.item("Help",()=>this.getHelp())}exportRun(t){return p(this,void 0,void 0,function*(){s.Utils.download(this.exportConfig.filename(t),yield this.exportConfig.export(t))})}getFormats(){var t,e;return null!==(e=null===(t=this.exportConfig)||void 0===t?void 0:t.supportedFormats)&&void 0!==e?e:[]}hasExport(){return this.exportConfig&&this.exportConfig.supportedFormats.length>0}getPackageData(){return p(this,void 0,void 0,function*(){var t,e,n;const i=null===(t=this.func)||void 0===t?void 0:t.package;if(!i)return;const o=null===(e=yield null==i?void 0:i.getProperties())||void 0===e?void 0:e.REPORT_BUG_URL;o&&!this.reportBug&&(this.reportBug=()=>p(this,void 0,void 0,function*(){window.open(o,"_blank")}));const s=null===(n=yield null==i?void 0:i.getProperties())||void 0===n?void 0:n.REQUEST_FEATURE_URL;s&&!this.requestFeature&&(this.requestFeature=()=>p(this,void 0,void 0,function*(){window.open(s,"_blank")}))})}getStartId(){const t=new URL(i.shell.startUri);return globalThis.initialURLHandled?null:t.searchParams.get("id")}setAsLoaded(){globalThis.initialURLHandled=!0}get func(){var t;return null===(t=this.funcCall)||void 0===t?void 0:t.func}}},3508:t=>{"use strict";t.exports=dayjs},3763:(t,e,n)=>{"use strict";n.d(e,{A:()=>l,b:()=>r});var i=n(4570),o=n(6657);const s=1;function r(t){return null===t.outputs?null:(function(t){if(null===t.outputs)throw new Error("Model has no outputs");if(null!==t.exprs)if(null===t.loop){if(null!==t.updates&&a(t))throw new Error("Non-supported model: expressions in output and updates")}else if(a(t))throw new Error("Non-supported model: expressions in output & loops")}(t),a(t)?function(t){const e=t.outputs;if(null===e)throw new Error("Grok Lib issue: no outputs in the initial value problem");const n=t.exprs;if(!a(t)||null===n)throw new Error("Grok Lib issue: expressions must be given");const r=t.arg.name,l=["const solution = [];"];if(t.usedMathFuncs.forEach(t=>{t!==i.nH?l.push(`const ${i.bc[t]} = (x) => Math.${i.bc[t]}(x);`):l.push("const pow = (x, y) => Math.pow(x, y);")}),t.usedMathConsts.forEach(t=>l.push(`const ${i.Yv[t]} = Math.${i.Yv[t]};`)),null!==t.consts&&t.consts.forEach((t,e)=>l.push(`const ${e} = ${t.value};`)),null!==t.params){let e=o.Zg+t.deqs.solutionNames.length;t.params.forEach((t,n)=>{l.push(`const ${n} = arguments[1][${e}];`),++e})}l.push(""),l.push("const length = arguments[0][0].length;");const u=t.deqs.solutionNames;return l.push(`let ${r} = 0;`),u.forEach(t=>l.push(`let ${t} = 0;`)),l.push(""),n.forEach((t,n)=>{l.push(`let ${n} = 0;`),e.has(n)&&l.push(`let ${n}Raw = new Float64Array(length);`)}),l.push(""),l.push("for (let k = 0; k < length; ++k) {"),l.push(` ${r} = arguments[0][0][k];`),u.forEach((t,e)=>l.push(` ${t} = arguments[0][${s+e}][k];`)),l.push(""),n.forEach((t,n)=>{l.push(` ${n} = ${t};`),e.has(n)&&l.push(` ${n}Raw[k] = ${n};`)}),l.push("}"),l.push(""),e.forEach((e,i)=>{if(i===r)l.push("solution.push(arguments[0][0]);");else{const e=t.deqs.solutionNames.indexOf(i);e>-1?l.push(`solution.push(arguments[0][${e+1}]);`):n.has(i)&&l.push(`solution.push(${i}Raw);`)}}),l.push("return solution;"),l.join("\n")}(t):function(t){const e=t.outputs;if(null===e)throw new Error("Grok Lib issue: no outputs in the initial value problem");if(a(t))throw new Error("Grok Lib issue: no expressions are allowed");const n=["const solution = [];"];return e.forEach((e,i)=>{if(i===t.arg.name)n.push("solution.push(arguments[0][0]);");else{const e=t.deqs.solutionNames.indexOf(i);e>-1&&n.push(`solution.push(arguments[0][${e+1}]);`)}}),n.push("return solution;"),n.join("\n")}(t))}function a(t){const e=t.outputs;if(null===e)return!1;const n=t.exprs;if(null===n)return!1;let i=!1;return n.forEach((t,n)=>i||(i=e.has(n))),i}function l(t){const e=t.outputs;if(null===e)return[t.arg.name].concat(t.deqs.solutionNames);const n=new Array(e.size);let i=0;return e.forEach(t=>{n[i]=t.caption,++i}),n}},3775:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(5516),o=n.n(i),s=n(1364),r=n.n(s)()(o());r.push([t.id,".fi-drop-area {\n position: relative;\n}\n\n.fi-drop-area .default {\n color: var(--grey-2);\n}\n\n.fi-drop-area .drag-n-dropping {\n background-color: var(--steel-1);\n border: 1px dashed var(--blue-1);\n color: var(--grey-3);\n}\n\n.fi-drop-area .error {\n color: var(--red-3);\n}\n\n.fi-drop-area .success {\n color: var(--grey-6);\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/old-components/css/file-input.css"],names:[],mappings:"AAAA;EACE,kBAAkB;AACpB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,gCAAgC;EAChC,gCAAgC;EAChC,oBAAoB;AACtB;;AAEA;EACE,mBAAmB;AACrB;;AAEA;EACE,oBAAoB;AACtB",sourcesContent:[".fi-drop-area {\n position: relative;\n}\n\n.fi-drop-area .default {\n color: var(--grey-2);\n}\n\n.fi-drop-area .drag-n-dropping {\n background-color: var(--steel-1);\n border: 1px dashed var(--blue-1);\n color: var(--grey-3);\n}\n\n.fi-drop-area .error {\n color: var(--red-3);\n}\n\n.fi-drop-area .success {\n color: var(--grey-6);\n}\n"],sourceRoot:""}]);const a=r},3881:(t,e,n)=>{"use strict";var i=n(6186),o=n.n(i),s=n(2155),r=n.n(s),a=n(7433),l=n.n(a),u=n(8626),c=n.n(u),d=n(8990),p=n.n(d),h=n(9827),f=n.n(h),m=n(2562),v={};v.styleTagTransform=f(),v.setAttributes=c(),v.insert=l().bind(null,"head"),v.domAPI=r(),v.insertStyleElement=p(),o()(m.A,v),m.A&&m.A.locals&&m.A.locals},3902:(t,e,n)=>{"use strict";n.d(e,{v:()=>P});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(1858),u=n(8476),c=n(9713),d=(n(8870),n(4260)),p=n(810),h=n(4204),f=n(241),m=n(7722),v=n(1159),g=n(7320),y=n(4098),b=n(7591),A=n(1599),w=n(4353),C=n(5715),I=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const T=s.Color.categoricalPalette,E=T.length,S="Misc",x="side-input",R="side-icon",O="form-title",N="form-section",F=[s.TYPE.INT,s.TYPE.BIG_INT,s.TYPE.FLOAT,s.TYPE.DATA_FRAME];function M(t){if(t.prop.propertyType!==s.TYPE.DATA_FRAME)return{isValid:!0,msg:""};const e=t.argName,n=t.funcColsInput.value;return null===n||null===n?{isValid:!1,msg:`Incomplete the "${t.input.caption}" target`}:n.map(t=>t.name).includes(e)?{isValid:!1,msg:`Invalid ${t.input.caption}: functions should not contain argument ('${e}')`}:{isValid:!0,msg:""}}const L=t=>t.propertyType===s.TYPE.INT||t.propertyType===s.TYPE.FLOAT||t.propertyType===s.TYPE.DATA_FRAME;class P{static fromEmpty(t){return I(this,arguments,void 0,function*(t,e={parentView:void 0,parentCall:void 0,inputsLookup:void 0,ranges:void 0,targets:void 0,acceptMode:!1,diffGrok:void 0}){const n=[...i.shell.views].find(t=>t.type===d.sk),o=yield u.S.fromComparedRuns([],t,{parentView:n,parentCall:e.parentCall});return i.shell.addView(o),new this(t,o,e)})}constructor(t,e,n={parentView:void 0,parentCall:void 0,configFunc:void 0,inputsLookup:void 0,ranges:void 0,targets:void 0,acceptMode:!1,diffGrok:void 0}){if(this.func=t,this.baseView=e,this.options=n,this.validationCheckRequests$=new l.Subject,this.generateInputFields=t=>{const e=(t,e)=>{var n;const i=null===(n=this.options.ranges)||void 0===n?void 0:n[t.name];if(null!=(null==i?void 0:i[e])&&("string"!=typeof(null==i?void 0:i[e])||!L(t)))return i[e];switch(e){case"min":return t.min;case"max":return t.max;default:return(0,p.Bu)(t)}},n=(t,e)=>{var n;const i=null===(n=this.options.ranges)||void 0===n?void 0:n[t.name];if(null!=(null==i?void 0:i[e])&&"string"==typeof(null==i?void 0:i[e]))return i[e]},r=(t,e)=>{var i,s;const r=null!==(i=n(t,e))&&void 0!==i?i:"",a=`${null!==(s=t.caption)&&void 0!==s?s:t.name} (${e})`,l=this,u=o.input.textArea(a,{value:r,onValueChanged(){l.updateApplicabilityState()}});return u.setTooltip(`Formula for '${a}', variable: ${t.name}`),u},u=(t,e,i,s)=>{const r=n(t,e),l=this,u=t=>{this.allowFormulas?t?(a()(i.root).hide(),a()(s.root).show()):(a()(i.root).show(),a()(s.root).hide()):(a()(c.root).hide(),a()(s.root).hide())},c=o.input.bool("Use formula",{value:!!r,onValueChanged(t){u(t),l.updateApplicabilityState()}});return u(!!r),c},c=(t,e,n=!0)=>{const i=o.input.toggle(" ",{value:t,onValueChanged:t=>e(t)});return a()(i.root).addClass("sa-switch-input"),a()(i.captionLabel).hide(),o.tooltip.bind(i.root,()=>n?i.value?"Switch OFF fitting the input":"Switch ON fitting the input":i.value?"Mark the output as not a target":"Mark the output as a target"),i};return{inputs:t.inputs.reduce((t,n)=>{var i;const d=e(n,"default");if(n.propertyType===s.TYPE.FLOAT){const s=c(!1,t=>{A.isChanging.next(t),this.updateApplicabilityState()});s.classList.add(x);const p=null!==(i=n.caption)&&void 0!==i?i:n.name,h=(()=>{const t=o.input.float(p,{value:d,onValueChanged:t=>{A.const.value=t,this.updateApplicabilityState()}});return t.addPostfix(n.options.units),t.setTooltip(`Value of '${p}', variable: ${n.name}`),t.nullable=!1,t})(),f=(()=>{const t=o.input.float(`${p} (min)`,{value:e(n,"min"),onValueChanged:t=>{A.min.value=t,this.updateApplicabilityState()}});return t.addValidator(t=>Number(t)>A.max.value?"Greater than max":null),t.addPostfix(n.options.units),t.setTooltip(`Min value '${p}', variable: ${n.name}`),t.nullable=!1,t})(),m=r(n,"min"),v=u(n,"min",f,m),g=(()=>{const t=o.input.float(`${p} (max)`,{value:e(n,"max"),onValueChanged:t=>{A.max.value=t,this.updateApplicabilityState()}});return t.addValidator(t=>Number(t)<A.min.value?"Smaller than min":null),t.addPostfix(n.options.units),t.setTooltip(`Max value of '${p}', variable: ${n.name}`),t.nullable=!1,t})(),y=r(n,"max"),b=u(n,"max",g,y),A={type:n.propertyType,prop:n,const:{input:h,value:d},min:{input:f,value:e(n,"min"),formula:m,useFormula:v},max:{input:g,value:e(n,"max"),formula:y,useFormula:b},isChanging:new l.BehaviorSubject(!1),isChangingInput:s,constForm:[h],saForm:[f,m,v,g,y,b]};t[n.name]=A,A.isChanging.subscribe(t=>{s.notify=!1,s.value=t,s.notify=!0}),(0,l.combineLatest)([A.isChanging]).subscribe(([t])=>{t?(A.constForm.forEach(t=>a()(t.root).hide()),A.saForm.forEach(t=>a()(t.root).css("display","flex")),v.fireChanged(),b.fireChanged()):(A.constForm.forEach(t=>a()(t.root).css("display","flex")),A.saForm.forEach(t=>a()(t.root).hide()))})}else{const e={input:(()=>{var t;const i=o.input.forProperty(n);return i.caption=null!==(t=n.caption)&&void 0!==t?t:n.name,i.onInput.subscribe(()=>{e.value=i.value,this.updateApplicabilityState()}),i.addPostfix(n.options.units),i.nullable=!1,i})(),value:d};e.input.value=d,t[n.name]={const:e,constForm:[e.input],saForm:[],type:n.propertyType,prop:n,isChanging:new l.BehaviorSubject(!1)}}return t},{}),outputs:t.outputs.filter(t=>F.includes(t.propertyType)).reduce((t,n)=>{var r,a,u,d,p,h,f,v;const g=null!=(null===(a=null===(r=this.options.targets)||void 0===r?void 0:r[n.name])||void 0===a?void 0:a.default)?null===(d=null===(u=this.options.targets)||void 0===u?void 0:u[n.name])||void 0===d?void 0:d.default:n.propertyType===s.TYPE.DATA_FRAME?null:e(n,"default");let y,b,A=null,w=[null];if(null!=g&&g instanceof s.DataFrame){b=g;const t=b.columns.toList().filter(t=>t.isNumerical);w=t.map(t=>t.name),A=null!==(f=null===(h=null===(p=this.options.targets)||void 0===p?void 0:p[n.name])||void 0===h?void 0:h.argumentCol)&&void 0!==f?f:w[0],y=t.filter(t=>t.name!==A)}const C=t=>{const e=M(S);return e.isValid?(S.argColInput.input.classList.remove("d4-invalid"),S.funcColsInput.input.classList.remove("d4-invalid"),o.tooltip.bind(S.argColInput.input,"Independent variable"),o.tooltip.bind(S.funcColsInput.input,"Target dependent variables"),null):(S.argColInput.input.classList.add("d4-invalid"),S.funcColsInput.input.classList.add("d4-invalid"),o.tooltip.bind(S.argColInput.input,e.msg),o.tooltip.bind(S.funcColsInput.input,e.msg),e.msg)},I=new l.BehaviorSubject(!1),T=c(I.value,t=>{S.isInterest.next(t),this.updateApplicabilityState()},!1);T.classList.add(x),I.subscribe(t=>{T.notify=!1;try{T.value=t}finally{T.notify=!0}});const E=(0,m.gw)(T.root,null!==(v=n.caption)&&void 0!==v?v:n.name);E.classList.add(R);const S={prop:n,input:(()=>{var t,e,r;const a=null!==(t=n.caption)&&void 0!==t?t:n.name,l=o.input.forProperty(n);l.addCaption(a),l.value=g;let u=null;return n.propertyType===s.TYPE.DATA_FRAME?(l.setTooltip("Target dataframe"),u=l.root.querySelector('div[class = "ui-input-options"]')):l.setTooltip("Target scalar"),I.subscribe(t=>{l.input.hidden=!t,E.hidden=!t,null!=u&&(u.hidden=!t)}),l.nullable=!1,o.tooltip.bind(l.captionLabel,n.propertyType===s.TYPE.DATA_FRAME?"Dataframe output of the model":"Scalar output of the model"),null!=(null===(r=null===(e=this.options.targets)||void 0===e?void 0:e[n.name])||void 0===r?void 0:r.default)&&setTimeout(()=>{var t,e;return l.value=null===(e=null===(t=this.options.targets)||void 0===t?void 0:t[n.name])||void 0===e?void 0:e.default},0),l.onChanged.subscribe(t=>{S.target=l.value;const e=()=>{S.argColInput.items=[null],S.argColInput.value=null,o.input.setColumnsInputTable(S.funcColsInput,i.data.demo.randomWalk(2,2),t=>!1)};if(null===l.value)e();else if(n.propertyType===s.TYPE.DATA_FRAME)if(S.target){const t=[],n=[];for(const e of l.value.columns)e.isNumerical&&(t.push(e.name),n.push(e));t.length>1?(S.argColInput.items=t,S.argColInput.value=t[0],o.input.setColumnsInputTable(S.funcColsInput,l.value,t=>t.isNumerical),S.funcColsInput.value=n.slice(1)):(i.shell.warning(`Not enough of numerical columns: ${t.length}, expected: > 1`),e())}else e();this.updateApplicabilityState()}),l})(),isInterestInput:T,showInfoWidget:E,argName:null!=A?A:"_",argColInput:(()=>{const t=o.input.choice("argument",{value:A,items:w,tooltipText:"Independent variable",onValueChanged:t=>{S.argName=null!==t?t:"_",this.updateApplicabilityState()}});return o.tooltip.bind(t.captionLabel,"Column with values of the independent variable"),o.icons.info(()=>alert("Hello!")).classList.add("sa-switch-input"),t.nullable=!1,t.addValidator(C),I.subscribe(e=>t.root.hidden=!e||n.propertyType!==s.TYPE.DATA_FRAME),t})(),isInterest:I,target:g,funcColsInput:(()=>{const t=o.input.columns("functions",{table:b,value:y,nullable:!1,tooltipText:"Target dependent variables",onValueChanged:t=>this.updateApplicabilityState()});return I.subscribe(e=>t.root.hidden=!e||n.propertyType!==s.TYPE.DATA_FRAME),o.tooltip.bind(t.captionLabel,"Columns with values of target dependent variables:"),t.addValidator(C),t})()};return t[n.name]=S,t},{})}},this.readyToRun=!1,this.isFittingRunning=!1,this.runIcon=o.iconFA("play",()=>I(this,void 0,void 0,function*(){this.readyToRun&&(this.isFittingRunning=!0,this.updateApplicabilityState(),this.updateRunIconDisabledTooltip("In progress..."),yield this.runOptimization(),this.isFittingRunning=!1,this.updateApplicabilityState())})),this.acceptIcon=o.iconFA("ballot-check",()=>I(this,void 0,void 0,function*(){const t=Array.from({length:this.currentFuncCalls.length},(t,e)=>e+1);let e=-1;const n=o.input.choice("Select fitting",{items:t,onValueChanged:t=>e=t});if(!(yield new Promise((t,e)=>{o.dialog({title:"Accept fitting"}).add(o.div([n])).onOK(()=>t(!0)).onCancel(()=>t(!1)).show({modal:!0,fullScreen:!0,width:600,height:200,center:!0})}))||e<0)return;this.acceptIcon.remove();const i=this.currentFuncCalls[e-1];this.isFittingAccepted=!0,this.acceptedFitting$.next(i),this.baseView.close()})),this.helpIcon=(0,m.VW)(),this.randInputs=(0,m.Aj)(),this.earlyStoppingInputs=(0,m.J1)(),this.showFailsBtn=o.button("Issues",()=>{if(this.method!==h.Mx.NELDER_MEAD)throw new Error(`Not implemented the '${this.method}' method`);this.showNelderMeadFails()},"Show issues"),this.gridClickSubscription=null,this.gridCellChangeSubscription=null,this.failsDF=null,this.samplesCount=h.fo.SAMPLES,this.samplesCountInput=o.input.forProperty(s.Property.fromOptions({name:h.ly.SAMPLES,inputType:"Int",defaultValue:this.samplesCount,min:1,max:1e3})),this.loss=h.YI.RMSE,this.lossInput=o.input.choice(h.ly.LOSS_LOW,{value:this.loss,items:[h.YI.MAD,h.YI.RMSE],onValueChanged:t=>{this.loss=t,this.lossInput.setTooltip(h.FM.get(this.loss))}}),this.similarity=h.fo.SIMILARITY_DEFAULT,this.similarityInput=o.input.forProperty(s.Property.fromOptions({name:h.ly.SIMILARITY,inputType:"Float",defaultValue:this.similarity,min:h.fo.SIMILARITY_MIN,max:h.fo.SIMILARITY_MAX,units:"%"})),this.allowFormulas=!1,this.helpDN=void 0,this.method=h.Mx.NELDER_MEAD,this.methodInput=o.input.choice(h.ly.METHOD,{value:this.method,items:[h.Mx.NELDER_MEAD],onValueChanged:t=>{this.method=t,this.showHideSettingInputs(),this.methodInput.setTooltip(h.h$.get(this.method))}}),this.nelderMeadSettings=new Map,this.gradDescentSettings={iterCount:10,learningRate:1e-4},this.defaultsOverrides={},this.settingsInputs=new Map,this.store=this.generateInputFields(this.func),this.fittingSettingsIcon=o.iconFA("cog",()=>{const t=this.fittingSettingsDiv.hidden;this.fittingSettingsDiv.hidden=!t},"Modify fitting settings"),this.fittingSettingsDiv=o.divV([]),this.diffGrok=void 0,this.currentFuncCalls=[],this.isFittingAccepted=!1,this.acceptedFitting$=new l.Subject,!this.isOptimizationApplicable(t))return i.shell.warning("Fitting is not applicable: the function has no scalar outputs."),void e.close();f.L.forEach((t,e)=>this.nelderMeadSettings.set(e,t.default)),this.parseDefaultsOverrides(),this.randInputs=(0,m.Aj)(this.defaultsOverrides),this.earlyStoppingInputs=(0,m.J1)(this.defaultsOverrides),this.defaultsOverrides.samplesCount&&(this.samplesCount=this.defaultsOverrides.samplesCount,this.samplesCountInput.value=this.samplesCount),this.defaultsOverrides.similarity&&(this.similarity=this.defaultsOverrides.similarity,this.similarityInput.value=this.similarity),null!=this.defaultsOverrides.allowFormulas&&(this.allowFormulas=this.defaultsOverrides.allowFormulas),i.events.onViewRemoved.pipe((0,c.filter)(t=>t.id===e.id),(0,c.take)(1)).subscribe(()=>{n.acceptMode&&!this.isFittingAccepted&&(this.acceptedFitting$.next(null),this.isFittingAccepted=!0)}),this.validationCheckRequests$.pipe((0,c.debounceTime)(0)).subscribe(()=>{this.readyToRun=this.canFittingBeRun()&&!this.isFittingRunning,this.updateRunIconStyle()}),this.buildForm(n.inputsLookup).then(t=>{this.comparisonView=e,this.comparisonView.dockManager.dock(t,s.DOCK_TYPE.LEFT,null,`${this.func.name} - Fitting`,.25),this.comparisonView.grid.columns.byName("Run name").visible=!1;const n=[[this.helpIcon,this.runIcon,...this.options.acceptMode?[this.acceptIcon]:[]]];this.comparisonView.setRibbonPanels(n),this.fittingSettingsDiv.hidden=!0,this.comparisonView.name=this.comparisonView.name.replace("comparison","fitting"),this.comparisonView.helpUrl="/help/compute/function-analysis#parameter-optimization";const i=o.markdown(h.TR);i.style.padding="10px",i.style.overflow="auto",this.helpDN=this.comparisonView.dockManager.dock(i,s.DOCK_TYPE.FILL,this.comparisonView.dockManager.findNode(this.comparisonView.grid.root),"About"),this.methodInput.setTooltip(h.h$.get(this.method)),o.tooltip.bind(this.methodInput.captionLabel,"Method for finding optimal model parameters"),this.lossInput.setTooltip(h.FM.get(this.loss)),o.tooltip.bind(this.lossInput.captionLabel,"Method for measuring the difference between model outputs and target values"),this.showFailsBtn.style.padding="0px",this.samplesCountInput.addCaption(h.ly.SAMPLES),this.samplesCountInput.onChanged.subscribe(t=>{this.samplesCount=t,this.updateApplicabilityState()}),this.samplesCountInput.setTooltip("Number of initial points used to start the optimization process. Higher value = higher chance of finding more distinct points"),this.similarityInput.onChanged.subscribe(t=>{this.similarity=t,this.updateApplicabilityState()}),this.similarityInput.addCaption(h.ly.SIMILARITY),this.similarityInput.setTooltip("Maximum relative difference between points to consider them identical. Lower = more unique results"),o.tooltip.bind(this.similarityInput.captionLabel,"Maximum relative deviation (%) between similar fitted points"),this.updateRunIconStyle(),this.updateRunIconDisabledTooltip("Select inputs for fitting"),this.runIcon.classList.add("fas"),this.updateApplicabilityState()}),this.diffGrok=n.diffGrok}parseDefaultsOverrides(){this.defaultsOverrides=JSON.parse(this.func.options.fittingSettings||"{}")}isOptimizationApplicable(t){for(const e of t.outputs)if(L(e))return!0;return!1}generateNelderMeadSettingsInputs(){const t=[];let e=!1;f.L.forEach((n,i)=>{var r;const a=o.input.forProperty(s.Property.fromOptions({name:n.caption,inputType:n.inputType,defaultValue:null!==(r=this.defaultsOverrides[i])&&void 0!==r?r:n.default,min:n.min,max:n.max}));a.setTooltip(n.tooltipText),a.addCaption(n.caption),a.nullable=!1,null!=this.defaultsOverrides[i]&&(this.nelderMeadSettings.set(i,this.defaultsOverrides[i]),e=!0),a.onChanged.subscribe(t=>{this.nelderMeadSettings.set(i,t),this.updateApplicabilityState()}),t.push(a)}),this.settingsInputs.set(h.Mx.NELDER_MEAD,t),e&&this.updateApplicabilityState()}areNelderMeadSettingsCorrect(){for(const[t,e]of this.nelderMeadSettings)if(null==e||e>f.L.get(t).max||e<f.L.get(t).min)return this.updateRunIconDisabledTooltip(`Invalid "${t}": check method settings`),!1;return!0}generateGradDescentSettingsInputs(){var t,e;const n=o.input.forProperty(s.Property.fromOptions({name:"iterations",inputType:"Int",defaultValue:null!==(t=this.defaultsOverrides.iterCount)&&void 0!==t?t:this.gradDescentSettings.iterCount,min:1,max:1e4}));n.onChanged.subscribe(t=>this.gradDescentSettings.iterCount=t);const i=o.input.forProperty(s.Property.fromOptions({name:"Learning rate",inputType:"Float",defaultValue:null!==(e=this.defaultsOverrides.learningRate)&&void 0!==e?e:this.gradDescentSettings.learningRate,min:1e-6,max:1e3}));i.onChanged.subscribe(t=>this.gradDescentSettings.learningRate=t),this.settingsInputs.set(h.Mx.GRAD_DESC,[n,i])}areGradDescentSettingsCorrect(){return!1}areMethodSettingsCorrect(){switch(this.method){case h.Mx.NELDER_MEAD:return this.areNelderMeadSettingsCorrect();case h.Mx.GRAD_DESC:return this.areGradDescentSettingsCorrect();default:return!0}}generateSettingInputs(){this.generateNelderMeadSettingsInputs(),this.generateGradDescentSettingsInputs()}showHideSettingInputs(){this.settingsInputs.forEach((t,e)=>t.forEach(t=>t.root.hidden=e!==this.method))}getLookupElement(t){return I(this,void 0,void 0,function*(){if(void 0===t)return null;const e=new Map;return Object.keys(this.store.inputs).forEach(t=>e.set(t,this.store.inputs[t].constForm[0])),yield(0,v.c)(t,e)})}addFormInputs(t,e,n,i){const o=new Map;if(e.size>1){if(null!==n){const s=e.get(n),r=(0,m.FB)(n,s,i);r.classList.add(N),o.set(n,r),t.append(r),t.append(...s)}if(e.forEach((e,s)=>{if(s!==S&&s!==n){const n=(0,m.FB)(s,e,i);n.classList.add(N),o.set(s,n),t.append(n),t.append(...e)}}),n!==S&&e.get(S).length>0){const n=e.get(S),s=(0,m.FB)(S,n,i);s.classList.add(N),o.set(S,s),t.append(s),t.append(...n)}}else t.append(...e.get(S));return o}buildForm(t){return I(this,void 0,void 0,function*(){var e,n,i,r;const a=o.h1(h.ly.FIT);a.classList.add(O),o.tooltip.bind(a,"Select inputs to be fitted");const l=o.form([],{style:{padding:"5px"}});l.append(a);const u=new Set,c=new Map([[S,[]]]),d=new Map([[S,[]]]),p=new Set,f=new Set,m=o.input.toggle("Show only primary",{value:!1,onValueChanged:t=>{if(0===u.size)return;const e=[[c,b,p],[d,w,f]];for(const[n,i,o]of e)for(const[e,s]of n.entries()){const n=t&&!s.some(t=>u.has(t)),r=i.get(e);r&&(r.hidden=n);for(const n of s)n.hidden=o.has(e)||t&&!u.has(n)}}});m.root.hidden=!0;const v=o.div("",{classes:"sa-switch-input ui-div"});m.root.prepend(v),l.append(m.root),Object.values(this.store.inputs).forEach(t=>{var e,n;const i=t.prop.category,o=t.prop.name,s=[...t.isChangingInput?[t.isChangingInput.root]:[],...t.constForm.map(t=>t.root),...t.saForm.map(t=>t.root)];(null===(n=null===(e=this.options.ranges)||void 0===e?void 0:e[o])||void 0===n?void 0:n.isPrimary)&&s.forEach(t=>u.add(t)),c.has(i)?c.get(i).push(...s):c.set(i,s)});const g=yield this.getLookupElement(t);let y=null;if(null!==g){const t=c.get(g.category);y=g.category,void 0!==t?c.set(y,[g.input.root].concat(t)):c.set(y,[g.input.root])}const b=this.addFormInputs(l,c,y,(t,e,n)=>{e?p.delete(n):p.add(n),t.hidden=!e||m.value&&!u.has(t)});for(const t of Object.keys(this.store.inputs))(null===(n=null===(e=this.options.ranges)||void 0===e?void 0:e[t])||void 0===n?void 0:n.enabled)&&this.store.inputs[t].isChanging.next(!0);const A=o.h1(h.ly.TARGET);A.classList.add(O),o.tooltip.bind(A,"Select target outputs"),l.appendChild(A),Object.values(this.store.outputs).forEach(t=>{var e,n;const i=t.prop.category,o=[t.isInterestInput.root,t.input.root];t.prop.type===s.TYPE.DATA_FRAME&&o.push(t.showInfoWidget,t.argColInput.root,t.funcColsInput.root);const r=t.prop.name;(null===(n=null===(e=this.options.targets)||void 0===e?void 0:e[r])||void 0===n?void 0:n.isPrimary)&&o.forEach(t=>u.add(t)),d.has(i)?d.get(i).push(...o):d.set(i,o)});const w=this.addFormInputs(l,d,null,(t,e,n)=>{e?f.delete(n):f.add(n),t.hidden=!e||m.value&&!u.has(t)});u.size>0&&(m.root.hidden=!1,m.value=!0);let C=!1;for(const t of Object.keys(this.store.outputs))(null===(r=null===(i=this.options.targets)||void 0===i?void 0:i[t])||void 0===r?void 0:r.enabled)&&this.store.outputs[t].isInterest.next(!0),!0===this.store.outputs[t].isInterest.value&&(C=!0);C||this.store.outputs[Object.keys(this.store.outputs)[0]].isInterest.next(!0);const I=o.h1("Using");I.classList.add(O),o.tooltip.bind(I,"Specify fitting method"),l.appendChild(I),this.fittingSettingsIcon.style.minWidth="50px",this.fittingSettingsIcon.classList.add(R),l.appendChild(this.fittingSettingsIcon),l.appendChild(this.methodInput.root),[this.lossInput,this.samplesCountInput,this.similarityInput].forEach(t=>{t.nullable=!1,this.fittingSettingsDiv.appendChild(t.root)}),this.fittingSettingsDiv.appendChild(this.randInputs.reproducibility.root),this.fittingSettingsDiv.appendChild(this.randInputs.seed.root),this.fittingSettingsDiv.appendChild(this.earlyStoppingInputs.earlyStopping.root),this.fittingSettingsDiv.appendChild(this.earlyStoppingInputs.threshold.root),this.fittingSettingsDiv.appendChild(this.earlyStoppingInputs.stopAtFirst.root),this.generateSettingInputs(),this.showHideSettingInputs(),l.appendChild(this.fittingSettingsDiv),this.settingsInputs.forEach(t=>t.forEach(t=>{this.fittingSettingsDiv.append(t.root)}));for(const t of Array.from(l.children))if(t.classList.contains(x))t.style.height="0",t.style.top="22px",t.style.position="relative";else if(t.classList.contains(R))t.style.height="0",t.style.top="14px",t.style.left="14px",t.style.position="relative";else{if(t.classList.contains(O)||t.classList.contains(N))continue;t.style.marginLeft="50px"}return this.updateApplicabilityState(),l})}updateRunIconDisabledTooltip(t){o.tooltip.bind(this.runIcon,()=>{const e=o.label(t);return e.style.color="#FF0000",e})}updateApplicabilityState(){this.validationCheckRequests$.next(!0)}updateRunIconStyle(){this.readyToRun?(this.runIcon.style.color="var(--green-2)",o.tooltip.bind(this.runIcon,"Run fitting")):this.runIcon.style.color="var(--grey-3)"}getInputValue(t){return"Choice"===t.inputType?t.stringValue:t.value}splitInputs(){return Object.entries(this.store.inputs).reduce((t,e)=>{const[,n]=e;return n.isChanging.value&&(n.min.useFormula.value||n.max.useFormula.value)?t.formulaInputs.push(e):t.nonFormulaInputs.push(e),t},{nonFormulaInputs:[],formulaInputs:[]})}getStoreInputsAndBounds(t,e,n){const i=t.min.useFormula.value?t.min.formula:t.min.input,o=t.max.useFormula.value?t.max.formula:t.max.input,s=t.min.useFormula.value?t.min.formula.value:void 0,r=t.max.useFormula.value?t.max.formula.value:void 0;return{minInp:i,maxInp:o,min:t.min.useFormula.value?(0,w.G)(s,e):t.min.input.value,max:t.max.useFormula.value?(0,w.G)(r,n):t.max.input.value,minFormula:s,maxFormula:r}}areInputsReady(){var t,e;let n=!1;const i=[],{nonFormulaInputs:o,formulaInputs:s}=this.splitInputs(),r={},a={};for(const[l,u]of[...o,...s]){const o=null!==(t=u.prop.caption)&&void 0!==t?t:u.prop.name;if(!0===u.isChanging.value){n=!0;const t=u,{minInp:e,maxInp:s,min:c,max:d}=this.getStoreInputsAndBounds(t,r,a);r[l]=c,a[l]=d,null!=c&&null!=d?c>d?(i.push(`Invalid min & max of "${o}"`),e.input.classList.add("d4-invalid"),s.input.classList.add("d4-invalid")):(e.input.classList.remove("d4-invalid"),s.input.classList.remove("d4-invalid")):i.push(`Incomplete "${o}"`)}else{const t=this.getInputValue(u.const.input);r[l]=t,a[l]=t,null!=t||JSON.parse(null!==(e=u.prop.options.optional)&&void 0!==e?e:"false")||i.push(`Incomplete "${o}"`)}}return n||i.push("No parameters for fitting selected"),i.length>0&&this.updateRunIconDisabledTooltip(i.join("\n")),0===i.length}areOutputsReady(){let t,e=!1,n=!0;for(const i of Object.keys(this.store.outputs)){const o=this.store.outputs[i];if(!0===o.isInterest.value){e=!0;if(t=null!=o.input.value,o.prop.propertyType===s.TYPE.DATA_FRAME){const e=M(o);if(!e.isValid)return this.updateRunIconDisabledTooltip(e.msg),!1;t&&(t=null!==o.funcColsInput.value),t&&t&&(t=null!==o.argColInput.value&&""!==o.argName&&o.funcColsInput.value.length>0)}t||this.updateRunIconDisabledTooltip(`Incomplete the "${o.input.caption}" target`),n=n&&t}}return e||this.updateRunIconDisabledTooltip("No targets selected"),e&&n}isSamplesCountValid(){return this.samplesCount>0||(this.updateRunIconDisabledTooltip(`Invalid "${h.ly.SAMPLES}"`),!1)}isSimilarityValid(){return this.similarity>=h.fo.SIMILARITY_MIN&&this.similarity<=h.fo.SIMILARITY_MAX||(this.updateRunIconDisabledTooltip(`Invalid "${h.ly.SIMILARITY}"`),!1)}canFittingBeRun(){return this.areInputsReady()&&this.areOutputsReady()&&this.isSamplesCountValid()&&this.areMethodSettingsCorrect()&&this.isSimilarityValid()}getFixedInputs(){return Object.keys(this.store.inputs).filter(t=>!this.store.inputs[t].isChanging.value)}getFittedInputs(){return Object.keys(this.store.inputs).filter(t=>this.store.inputs[t].type===s.TYPE.FLOAT&&this.store.inputs[t].isChanging.value)}makeOptimizerInputsConfig(){const{nonFormulaInputs:t,formulaInputs:e}=this.splitInputs(),n={},i={},o={};for(const[s,r]of[...t,...e])if(!0===r.isChanging.value){const t=r,{min:e,max:a,minFormula:l,maxFormula:u}=this.getStoreInputsAndBounds(t,i,o);i[s]=e,o[s]=a;const c=l?{name:s,type:"formula",formula:l}:{name:s,type:"value",value:e},d=u?{name:s,type:"formula",formula:u}:{name:s,type:"value",value:a};n[s]={type:"changing",top:d,bottom:c}}else{const t=this.getInputValue(r.const.input);n[s]={type:"const",value:t},i[s]=t,o[s]=t}const s={},r=this.getFittedInputs(),a=this.getFixedInputs();for(const t of[...a,...r])s[t]=n[t];return s}makeOptimizerOutputsConfig(){return this.getOutputsOfInterest().map(t=>t.prop.propertyType!==s.TYPE.DATA_FRAME?{type:t.prop.propertyType,propName:t.prop.name,target:t.target}:{type:t.prop.propertyType,propName:t.prop.name,target:t.target,argName:t.argName,cols:t.funcColsInput.value})}runOptimization(){return I(this,void 0,void 0,function*(){try{if(!this.canFittingBeRun())return;if(this.samplesCount<1)return;if(this.similarity<h.fo.SIMILARITY_MIN||this.similarity>h.fo.SIMILARITY_MAX)return;this.failsDF=null;const t={},e=this.getFixedInputs();e.forEach(e=>t[e]=this.store.inputs[e].const.value);const n=this.getFittedInputs(),r=n.length,l=[],u=new Array(r);n.forEach((t,e)=>{var n;const i=this.store.inputs[t];l.push(t),u[e]=null!==(n=i.prop.caption)&&void 0!==n?n:i.prop.name});const c=this.getOutputsOfInterest();if(c.length<1)return void i.shell.error("No output is selected for optimization.");const d=c.map(t=>t.prop.propertyType).filter(t=>t===s.TYPE.DATA_FRAME).length>1,p=(0,m.O3)(this.func,t,l),f=this.makeOptimizerInputsConfig(),v=this.makeOptimizerOutputsConfig(),w=Object.values(f).find(t=>"changing"===t.type&&("formula"===t.top.type||"formula"===t.bottom.type)),T=this.loss===h.YI.MAD?"scaled maximum absolute deviation":"scaled root mean square error";let E;if(this.method!==h.Mx.NELDER_MEAD)throw new Error(`Not implemented the '${this.method}' method`);if(void 0===this.diffGrok||w)[E]=yield(0,C.P)({lossType:this.loss,func:this.func,inputBounds:f,outputTargets:v,samplesCount:this.samplesCount,similarity:this.similarity,settings:this.nelderMeadSettings,reproSettings:this.randInputs.settings,earlyStoppingSettings:this.earlyStoppingInputs.settings});else try{const e=h.Wr.DIFF_STUDIO_OUTPUT,i=new Float64Array(r),o=new Float64Array(r);n.forEach((t,e)=>{var n,s;const r=this.store.inputs[t];i[e]=null!==(n=r.min.value)&&void 0!==n?n:0,o[e]=null!==(s=r.max.value)&&void 0!==s?s:0}),E=yield(0,g.t)(this.loss,this.diffGrok.ivp,this.diffGrok.ivpWW,this.diffGrok.pipelineCreator,this.nelderMeadSettings,l,i,o,t,c[e].argName,c[e].funcColsInput.value,c[e].target,this.samplesCount,this.randInputs.settings,this.earlyStoppingInputs.settings)}catch(t){[E]=yield(0,C.P)({lossType:this.loss,func:this.func,inputBounds:f,outputTargets:v,samplesCount:this.samplesCount,similarity:this.similarity,settings:this.nelderMeadSettings,reproSettings:this.randInputs.settings,earlyStoppingSettings:this.earlyStoppingInputs.settings})}const S=E.extremums,x=S.length;if(null!=E.fails){this.failsDF=E.fails;const t=this.failsDF.columns;u.forEach((e,n)=>t.byIndex(n).name=t.getUnusedName(e)),e.forEach(e=>{var n,i;const o=this.store.inputs[e];o.prop.propertyType!==s.TYPE.DATA_FRAME&&t.add(s.Column.fromList(o.prop.propertyType,t.getUnusedName(null!==(n=o.prop.caption)&&void 0!==n?n:o.prop.name),new Array(null===(i=this.failsDF)||void 0===i?void 0:i.rowCount).fill(o.const.value)))})}S.sort((t,e)=>t.cost-e.cost);const R=c.filter(t=>t.prop.propertyType===s.TYPE.DATA_FRAME).map(t=>({name:t.prop.name,target:t.target,argColName:t.argName})),O=yield(0,y.R9)(S,this.similarity,p,R),N=O.length;if(this.clearPrev(),null!=E.fails){if(x<1)return void i.shell.warning(o.divV([o.label(`Failed to find ${this.samplesCount} point${this.samplesCount>1?"s":""}`),o.div([this.showFailsBtn])]));i.shell.info(o.divV([o.label(`Found ${N} point${N>1?"s":""}`),o.div([this.showFailsBtn])]))}else i.shell.info(`Found ${N} point${N>1?"s":""}`);if(x<1)return this.currentFuncCalls=[],void(this.comparisonView.dataFrame=s.DataFrame.fromColumns([s.Column.fromFloat64Array(h.ly.LOSS,[])]));const F=new Float64Array(N),M=this.comparisonView.grid,L=new Map([[h.ly.LOSS,`The final loss obtained: ${T}`]]);O.forEach((t,e)=>F[e]=t.cost);const P=s.DataFrame.fromColumns([s.Column.fromFloat64Array(h.ly.LOSS,F)]);this.comparisonView.dataFrame=P;const _=P.columns;u.forEach((t,e,n)=>{t=_.getUnusedName(t),n[e]=t;const i=new Float64Array(N);for(let t=0;t<N;++t)i[t]=O[t].point[e];_.add(s.Column.fromFloat64Array(t,i)),L.set(t,`Obtained values of '${t}'`)}),M.props.rowHeight=h.VF.ROW_HEIGHT,M.props.showAddNewRowIcon=!1,M.props.allowEdit=!1;const k=new Array(N);this.currentFuncCalls=[];for(let t=0;t<N;++t){const e=new Map,n=[],i=yield p(O[t].point);if(this.currentFuncCalls.push(i),c.forEach(t=>{this.getOutputGofTable(t.prop,t.target,i,t.argName,d).forEach(t=>{t.chart!==s.VIEWER.BAR_CHART?e.set(t.caption,t):n.push(t)})}),n.length>0){const t=this.getScalarsGofTable(n),i=t.table.columns.length>2?h.o_.SCALARS:t.table.columns.byIndex(0).name;e.set(i,t)}k[t]=e}k[0].forEach((t,e)=>{_.addNew(e,s.COLUMN_TYPE.DATA_FRAME).init(t=>k[t].get(e).table),L.set(e,"Goodness of fit");const n=M.columns.byName(e);n.cellType="html",n.width=h.VF.LOSS_GRAPH_WIDTH});const V=_.getUnusedName(`${this.loss} by iterations`);L.set(V,`Minimizing ${T}`),_.addNew(V,s.COLUMN_TYPE.DATA_FRAME).init(t=>(0,m.e_)(O[t]));const D=M.columns.byName(V);D.cellType="html",D.width=h.VF.LOSS_GRAPH_WIDTH;let B=!1;k[0].forEach(t=>B||(B=(0,m.zx)(t.table)));let $=!0;M.onCellPrepare(t=>I(this,void 0,void 0,function*(){if($&&(M.columns.setOrder(_.names().filter(t=>t!==V).concat([V])),$=!1),t.isColHeader||t.isRowHeader)return;t.isTableCell&&t.gridColumn.name===V&&null!==t.cell.value&&(t.style.element=t.cell.value.plot.line(h.L7).root);const e=t.gridRow;if(t.isTableCell&&e<N){const n=k[e].get(t.gridColumn.name);if(void 0!==n)if(n.chart===s.VIEWER.SCATTER_PLOT)t.style.element=t.cell.value.plot.scatter(n.opts).root;else if(B){const e=o.divV([],{style:{height:`${h.VF.ROW_HEIGHT}px`}});o.tooltip.bind(e,()=>(0,m.QR)()),t.style.element=e,setTimeout(()=>I(this,void 0,void 0,function*(){const n=new b.N(t.cell.value),i=yield n.getRoot();i.style.marginTop="0px",i.style.marginLeft="0px",e.append(i)}),h.Q9.RADAR)}else t.style.element=(0,m.uM)(t.cell.value)}})),M.columns.byName(h.ly.LOSS).format="scientific",M.columns.byName(h.ly.LOSS).width=h.VF.LOSS_COL_WIDTH,M.onCellTooltip(function(t,e,n){if(t.isColHeader&&t.tableColumn){const i=t.tableColumn.name;if(i===h.o_.SCALARS&&B)o.tooltip.show((0,m.QR)(),e,n);else{const t=L.get(i);o.tooltip.show(null!=t?t:"",e,n)}return!0}}),P.currentCell=P.cell(0,h.ly.LOSS);const U=t=>I(this,void 0,void 0,function*(){var e;if(null==t)return;const n=null!==(e=t.tableRowIndex)&&void 0!==e?e:0,r=yield p(O[n].point),l=[...r.outputParams.values()].filter(t=>s.TYPES_SCALAR.has(t.property.propertyType)),u=s.HtmlTable.create(l,t=>{var e;return[null!==(e=t.property.caption)&&void 0!==e?e:t.property.name,r.outputs[t.property.name],t.property.options.units]}).root,c=[...r.outputParams.values()].filter(t=>t.property.propertyType===s.TYPE.DATA_FRAME).reduce((t,e)=>{var n;const i=(0,A.jJ)(e.property).config,o=r.outputs[e.name],l=null!==(n=e.property.caption)&&void 0!==n?n:e.property.name;return i.map(e=>{const n=e.type,i=s.Viewer.fromType(n,o);i.setOptions(e),a()(i.root).css({width:"100%"}),t[l]?t[l].push(i.root):t[l]=[i.root]}),t},{});let d;d=l.length>0?Object.assign({"Output scalars":[u]},c):Object.assign({},c);const h=o.accordion();if(a()(h.root).css({width:"100%"}),Object.entries(d).map(t=>{h.addPane(t[0],()=>o.divV(t[1]))}),h.panes.length-1<0)throw new Error("Function has no outputs");h.panes[h.panes.length-1].expanded=!0,i.shell.o=h.root});this.gridClickSubscription=M.onCellClick.subscribe(U),this.gridCellChangeSubscription=M.onCurrentCellChanged.subscribe(U)}catch(t){i.shell.error(t instanceof Error?t.message:"The platform issue")}})}getOutputsOfInterest(){const t=[];for(const e of Object.keys(this.store.outputs)){const n=this.store.outputs[e];n.isInterest.value&&t.push(n)}return t}getScalarsGofTable(t){const e=[];return t.forEach(t=>e.push(t.table.columns.byIndex(h.Wr.SCALAR_VALS_COL))),e.push(s.Column.fromStrings(h.o_.CATEGORY,[h.o_.SIMULATION,h.o_.TARGET])),{caption:h.o_.SCALARS,table:s.DataFrame.fromColumns(e),chart:e.length>2?s.VIEWER.RADAR_VIEWER:s.VIEWER.BAR_CHART,opts:{}}}getOutputGofTable(t,e,n,i,o){var r;const a=t.propertyType,l=t.name,u=null!==(r=t.caption)&&void 0!==r?r:l;switch(a){case s.TYPE.FLOAT:case s.TYPE.INT:case s.TYPE.BIG_INT:return[{caption:u,chart:s.VIEWER.BAR_CHART,table:s.DataFrame.fromColumns([s.Column.fromStrings(h.o_.SCALARS,[h.o_.SIMULATION,h.o_.TARGET]),s.Column.fromList(a,u,[n.getParamValue(l),e])]),opts:{}}];case s.TYPE.DATA_FRAME:const t=[],r=n.getParamValue(l),c=e,d=r.col(i),p=c.col(i);if(null===d||null===p)throw new Error("Creating viewer fails: incorrect argument column name");const f=c.columns,v=r.clone(null,f.names());v.append(s.DataFrame.fromColumns(f.toList().map(t=>{const e=v.col(t.name);if(null===e)throw new Error(`Inconsistent dataframes: no column "${t.name}" in output of of the function`);return t.convertTo(e.type)})),!0);const g=v.columns.names().filter(t=>t!==i),y=new Array(r.rowCount).fill(h.o_.SIMULATION).concat(new Array(c.rowCount).fill(h.o_.TARGET)),b=y.length;g.forEach(t=>{v.columns.add(s.Column.fromStrings(`${h.o_.CATEGORY}_${t}`,y))});const A=new Int32Array(b).fill(h.SK.SIMULATION,0,r.rowCount).fill(h.SK.TARGET,r.rowCount);v.columns.add(s.Column.fromInt32Array(h.o_.SIZE,A));const w=r.columns.names().filter(t=>t!==i);return g.forEach(e=>{const n=`${h.o_.CATEGORY}_${e}`,r=v.col(n),a=w.indexOf(e)%E,l=T[a],c=s.Color.toRgb(l);r.colors.setCategorical({Simulation:l,Target:w.length>1?(0,m.ru)(c,h.SK.LIGHTER_PERC):T[a+1]}),t.push({caption:o?`${u}: [${e}]`:`[${e}]`,table:v,chart:s.VIEWER.SCATTER_PLOT,opts:{xColumnName:i,yColumnName:e,showColorSelector:!1,showSizeSelector:!1,legendVisibility:"Always",legendPosition:"Top",linesWidth:h.SK.LINE_CHART_LINE_WIDTH,linesOrderColumnName:i,markerType:s.MARKER_TYPE.CIRCLE,markerMinSize:h.SK.MIN_MARKER,markerMaxSize:h.SK.MAX_MARKER,colorColumnName:n,sizeColumnName:h.o_.SIZE}})}),t;default:throw new Error("Unsupported output type")}}clearPrev(){void 0!==this.helpDN&&(this.comparisonView.dockManager.close(this.helpDN),this.helpDN=void 0),this.gridClickSubscription&&(this.gridClickSubscription.unsubscribe(),this.gridClickSubscription=null),this.gridCellChangeSubscription&&(this.gridCellChangeSubscription.unsubscribe(),this.gridCellChangeSubscription=null)}showNelderMeadFails(){if(null===this.failsDF)return;const t=i.shell.addTableView(this.failsDF);t.addViewer(s.Viewer.form(s.DataFrame.fromColumns(Object.entries(this.nelderMeadSettings).map(t=>{var e,n;return s.Column.fromFloat64Array(null!==(n=null===(e=f.L.get(t[0]))||void 0===e?void 0:e.caption)&&void 0!==n?n:t[0],new Float64Array([t[1]]))}))),{description:"The Nelder-Mead method settings",showNavigation:!1});const e=this.getFittedInputs().length,n=new Map;this.failsDF.columns.names().forEach((t,i)=>{i<e?n.set(t,`Initial value of "${t}" used in the Nelder-Mead method`):i>e?n.set(t,`Value of "${t}" (fixed input)`):n.set(t,"Error message raised")}),t.grid.onCellTooltip(function(t,e,i){if(t.isColHeader&&t.tableColumn){const s=t.tableColumn.name,r=n.get(s);return o.tooltip.show(null!=r?r:"",e,i),!0}})}}},4038:(t,e,n)=>{"use strict";n.d(e,{M:()=>l});var i=n(9070),o=n(7149),s=n(500),r=n(4674),a=n(237);class l{constructor(t,e,n,s,r,a){this.funcCalls=null,(0,o.C1)(r),this.func=t;const l=(0,i.N)(r,n);this.dimension=n.length,this.variedInputs=[...Array(this.dimension).keys()].map(t=>({prop:n[t].prop,min:n[t].min,max:n[t].max,column:l[t]})),this.funcInputs=[],this.diffGrok=a,this.funcCalls=void 0===a?[]:null;for(let n=0;n<r;++n){const i={};for(const t of e)i[t.name]=t.value;for(const t of this.variedInputs)i[t.prop.name]=t.column.get(n);null!==this.funcCalls&&this.funcCalls.push(t.prepare(i)),this.funcInputs.push(i)}this.outputsOfInterest=s}perform(){return t=this,e=void 0,i=function*(){const t=this.variedInputs.map(t=>t.column);let e;if(void 0!==this.diffGrok){const t=new r.D(this.diffGrok,this.funcInputs,this.outputsOfInterest[a.dV]);e=yield t.getResults()}else{if(null===this.funcCalls)throw new Error("Failed Monte-Carlo analysis: empty list of funccalls");this.funcCalls=yield(0,o.X3)(this.funcCalls),e=(0,s.ex)(this.funcCalls,this.outputsOfInterest).columns.toList()}const n=(0,s.No)(t,e);return n.name=`Sensitivity Analysis of ${this.func.friendlyName}`,{funcEvalResults:n,funcInputs:this.funcInputs}},new((n=void 0)||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())});var t,e,n,i}}},4098:(t,e,n)=>{"use strict";n.d(e,{R9:()=>l});var i,o=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};function s(t,e){let n=0;const o=t.length;if(o!==e.length)throw new Error(`Inconsistent length of found points: source - ${t.length}, updated - ${e.length}`);let s;for(let r=0;r<o;++r)s=0!==t[r]?t[r]:1,n=Math.max(n,Math.abs((t[r]-e[r])/s)*i.SCALE);return n}function r(t,e,n,o,s,r){const a=Math.max(Math.abs(e.stats.min),Math.abs(e.stats.max),Math.abs(o.stats.min),Math.abs(o.stats.max));if(a<=0)return i.MIN;const l=e.getRawData(),u=o.getRawData(),c=n.length;if(c<1)throw new Error(`Empty model output: the column "${n}" is empty`);const d=function(t,e,n){const i=t.getRawData();let o=0;for(;i[o]<e;)++o;let s=o;for(;i[s]<=n;)++s;return{start:o,finish:s}}(t,s,r),p=d.start,h=d.finish;let f=0;if(c<2){const t=u[0];for(let e=p;e<h;++e)f=Math.max(f,Math.abs((l[e]-t)/a))}else{const e=t.getRawData(),i=n.getRawData();let o=0,s=0,r=1,a=i[r-1],d=i[r],m=0;for(let t=p;t<h;++t){for(o=e[t],s=l[t];d<o&&r<c-1;)a=d,++r,d=i[r];m=d>o&&a<d?(u[r-1]*(d-o)+u[r]*(o-a))/(d-a):u[r],f=Math.max(f,Math.abs(s-m))}}return f/a}function a(t,e,n,o,s){const a=t.col(n),l=e.col(n);if(null===a)throw new Error(`Inconsistent dataframe: ${t.name}, no argument column "${n}"`);if(null===l)throw new Error(`Inconsistent dataframe: ${e.name}, no argument column "${n}"`);if(function(t,e){if(!t.isNumerical)throw new Error(`Non-numerical argument column: ${t.name}, type - ${t.type}`);if(!e.isNumerical)throw new Error(`Non-numerical argument column: ${e.name}, type - ${e.type}`);return function(t,e,n,o){if(t>o||e<n)return i.MIN;const s=Math.min(e,o)-Math.max(t,n),r=Math.max(e,o)-Math.min(t,n);return r>0?s/r:i.MAX}(t.stats.min,t.stats.max,e.stats.min,e.stats.max)}(a,l)<o)return!1;const u=Math.max(a.stats.min,l.stats.min),c=Math.max(a.stats.max,l.stats.max);let d=0;for(const i of t.columns){if(i.name===n)continue;if(!i.isNumerical)continue;const t=e.col(i.name);if(null===t)throw new Error(`Inconsistent dataframe: ${e.name}, no function column "${i.name}"`);if(!t.isNumerical)throw new Error(`Inconsistent dataframe: ${e.name}, non-numerical function column "${t.name}"`);d=Math.max(d,r(a,i,l,t,u,c))}return d<s}function l(t,e,n,r){return o(this,void 0,void 0,function*(){const o=t.length,l=new Array(o);for(let e=0;e<o;++e)l[e]=yield n(t[e].point);const u=[];let c;const d=r.length,p=e/i.SCALE;for(let n=0;n<o;++n){const o=t[n],h=l[n];c=!0;for(let t=0;t<u.length&&(c&&(c=s(u[t].point,o.point)>e),c);++t){for(let e=0;e<d&&(c&&(c=!a(l[t].getParamValue(r[e].name),h.getParamValue(r[e].name),r[e].argColName,i.MAX-p,p)),c);++e);if(!c)break}c&&u.push(o)}return u})}!function(t){t[t.MAX=1]="MAX",t[t.MIN=0]="MIN",t[t.SCALE=100]="SCALE"}(i||(i={}))},4112:function(t){t.exports=function(){"use strict";var t="minute",e=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(i,o,s){var r=o.prototype;s.utc=function(t){return new o({date:t,utc:!0,args:arguments})},r.utc=function(e){var n=s(this.toDate(),{locale:this.$L,utc:!0});return e?n.add(this.utcOffset(),t):n},r.local=function(){return s(this.toDate(),{locale:this.$L,utc:!1})};var a=r.parse;r.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),a.call(this,t)};var l=r.init;r.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else l.call(this)};var u=r.utcOffset;r.utcOffset=function(i,o){var s=this.$utils().u;if(s(i))return this.$u?0:s(this.$offset)?u.call(this):this.$offset;if("string"==typeof i&&(i=function(t){void 0===t&&(t="");var i=t.match(e);if(!i)return null;var o=(""+i[0]).match(n)||["-",0,0],s=o[0],r=60*+o[1]+ +o[2];return 0===r?0:"+"===s?r:-r}(i),null===i))return this;var r=Math.abs(i)<=16?60*i:i,a=this;if(o)return a.$offset=r,a.$u=0===i,a;if(0!==i){var l=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(a=this.local().add(r+l,t)).$offset=r,a.$x.$localOffset=l}else a=this.utc();return a};var c=r.format;r.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return c.call(this,e)},r.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},r.isUTC=function(){return!!this.$u},r.toISOString=function(){return this.toDate().toISOString()},r.toString=function(){return this.toDate().toUTCString()};var d=r.toDate;r.toDate=function(t){return"s"===t&&this.$offset?s(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():d.call(this)};var p=r.diff;r.diff=function(t,e,n){if(t&&this.$u===t.$u)return p.call(this,t,e,n);var i=this.local(),o=s(t).local();return p.call(i,o,e,n)}}}()},4160:(t,e,n)=>{"use strict";n.d(e,{I:()=>u});var i=n(6082),o=n(4204),s=n(7722),r=n(5255),a=n(7395),l=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};function u(t,e,n,u){const{variedInputNames:c,fixedInputs:d}=(0,s.CN)(n);if(t===o.YI.MAD)return function(t,e,n,u,c){const d=(0,s.O3)(t,n,u),p=(0,a.Pn)(e,u);let h;return t=>l(this,void 0,void 0,function*(){if(!p(t))return;const e=yield d(t);h=yield(0,r.nF)(19*o.Q9.MS_TO_SLEEP,o.Q9.MS_TO_SLEEP,h);let n=0;return c.forEach(t=>{if(t.type!==i.TYPE.DATA_FRAME)n=Math.max(n,Math.abs(t.target-e.getParamValue(t.propName)));else{const i=t.target;(0,s.Yl)(i.col(t.argName),t.cols,e.getParamValue(t.propName),!1).forEach(t=>n=Math.max(n,Math.abs(t)))}}),n})}(e,n,d,c,u);if(t===o.YI.RMSE)return function(t,e,n,u,c){const d=(0,s.O3)(t,n,u),p=(0,a.Pn)(e,u);let h;return t=>l(this,void 0,void 0,function*(){if(!p(t))return;const e=yield d(t);h=yield(0,r.nF)(19*o.Q9.MS_TO_SLEEP,o.Q9.MS_TO_SLEEP,h);let n=0,a=0,l=0;return c.forEach(t=>{if(t.type!==i.TYPE.DATA_FRAME)l=t.target,n+=Math.pow((l-e.getParamValue(t.propName))/(0!==l?l:1),2),++a;else{const i=t.target;(0,s.Yl)(i.col(t.argName),t.cols,e.getParamValue(t.propName),!0).forEach(t=>{n+=Math.pow(t,2),++a})}}),Math.sqrt(n/a)})}(e,n,d,c,u);throw new Error(`Unknown type ${t}`)}},4204:(t,e,n)=>{"use strict";var i;n.d(e,{FM:()=>r,Hs:()=>T,L7:()=>y,Mx:()=>i,Q9:()=>c,RW:()=>A,SK:()=>v,TR:()=>h,Uk:()=>b,VF:()=>a,Wr:()=>f,YI:()=>s,_z:()=>E,be:()=>p,eJ:()=>S,fD:()=>C,fo:()=>d,h$:()=>o,ly:()=>l,nW:()=>g,nw:()=>x,o_:()=>m,t_:()=>w,yz:()=>I}),function(t){t.NELDER_MEAD="Nelder-Mead",t.GRAD_DESC="Gradient descent"}(i||(i={}));const o=new Map([[i.NELDER_MEAD,"The Nelder-Mead method"],[i.GRAD_DESC,"The gradient descent method"]]);var s;!function(t){t.MAD="MAD",t.RMSE="RMSE"}(s||(s={}));const r=new Map([[s.MAD,"Maximum Absolute Deviation (MAD) - measures only the single largest deviation, ignoring smaller deviations"],[s.RMSE,"Root Mean Square Error (RMSE) - measures average deviation, penalizing larger deviations more heavily"]]);var a,l,u,c,d;!function(t){t[t.LOSS_COL_WIDTH=60]="LOSS_COL_WIDTH",t[t.ROW_HEIGHT=280]="ROW_HEIGHT",t[t.LOSS_GRAPH_WIDTH=320]="LOSS_GRAPH_WIDTH",t[t.GOF_VIEWER_WIDTH=320]="GOF_VIEWER_WIDTH",t[t.RADAR_WIDTH=280]="RADAR_WIDTH",t[t.BAR_HEIGHT=100]="BAR_HEIGHT"}(a||(a={})),function(t){t.ITER="Iteration",t.LOSS="Loss",t.LOSS_GRAPH="Fitting profile",t.TARGET="Target",t.FIT="Fit",t.METHOD="method",t.VALUE="Value",t.OBJECTIVE="Target",t.SAMPLES="initial points",t.ID="id",t.OBTAINED="Simulation",t.LOSS_LOW="loss",t.SIMILARITY="similarity"}(l||(l={})),function(t){t.GOAL="`Goal`",t.FIT="`Fit`",t.MIN="`min`",t.MAX="`max`",t.TARGET="`Target`",t.METHOD="`method`",t.CONTEXT="`Context Panel (F4)`",t.SAMPLES="`initial points`",t.LOSS="`loss`",t.SIMILARITY="`similarity`"}(u||(u={})),function(t){t[t.MS_TO_SLEEP=5]="MS_TO_SLEEP",t[t.STYLE_TIMEOUT=3e3]="STYLE_TIMEOUT",t[t.RADAR=200]="RADAR"}(c||(c={})),function(t){t[t.SIMILARITY_MIN=0]="SIMILARITY_MIN",t[t.SIMILARITY_MAX=100]="SIMILARITY_MAX",t[t.SIMILARITY_DEFAULT=10]="SIMILARITY_DEFAULT",t[t.SAMPLES=10]="SAMPLES"}(d||(d={}));const p="https://datagrok.ai/help/compute/function-analysis#parameter-optimization",h=`# Fitting\n\nUse fitting to solve an inverse problem: find input conditions leading to specified output constraints.\nIt computes inputs minimizing deviation measured by [loss function](https://en.wikipedia.org/wiki/Loss_function).\n\n1. In the ${u.FIT} block, use switchers to specify inputs to be found:\n * Set ${u.MIN} and ${u.MAX} values for each selected item. They define the variation range\n * Set values of all other inputs\n\n2. Set output constraints in the ${u.TARGET} block:\n * Use switchers to specify target outputs\n * Set target value for each selected item\n\n3. Choose ${u.METHOD}. Press <i class="grok-icon fal fa-cog"></i> to specify its settings.\n\n4. Press the "Run" icon <i class="fas fa-play"></i> on the top panel to perform fitting. You will get a\n[grid](https://datagrok.ai/help/visualize/viewers/grid) containing\n\n * loss function values\n * fitted inputs\n * viewers visualizing the goodness of fit:\n * [line chart](https://datagrok.ai/help/visualize/viewers/line-chart) showing the loss function minimization\n\n5. Open ${u.CONTEXT}. You will get the function run corresponding to the selected grid row.\n\n6. Press **?** on the top panel to learn more about\n[parameters optimization](${p}).\n\n# Learn more\n\n* [Parameters optimization](${p})\n* [Nelder-Mead method](https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method)`;var f,m,v;!function(t){t[t.SINGLE_VAL=0]="SINGLE_VAL",t[t.SINGLE_CAT=1]="SINGLE_CAT",t[t.DOUBLE_VAL1=0]="DOUBLE_VAL1",t[t.DOUBLE_VAL2=1]="DOUBLE_VAL2",t[t.DOUBLE_CAT=2]="DOUBLE_CAT",t[t.DIFF_STUDIO_OUTPUT=0]="DIFF_STUDIO_OUTPUT",t[t.SCALAR_VALS_COL=1]="SCALAR_VALS_COL",t[t.OLIVE=8]="OLIVE",t[t.LIGHT_OLIVE=16]="LIGHT_OLIVE",t[t.GREY=7]="GREY",t[t.LIGHT_GREY=15]="LIGHT_GREY",t[t.BLUE=0]="BLUE",t[t.ORANGE=1]="ORANGE"}(f||(f={})),function(t){t.CATEGORY="__Category__",t.SIZE="__Size__",t.SIMULATION="Simulation",t.TARGET="Target",t.SCALARS="Scalars",t.NULL="Null"}(m||(m={})),function(t){t[t.LINE_CHART_LINE_WIDTH=2]="LINE_CHART_LINE_WIDTH",t[t.SIMULATION=1]="SIMULATION",t[t.TARGET=2]="TARGET",t[t.MIN_MARKER=1]="MIN_MARKER",t[t.MAX_MARKER=7]="MAX_MARKER",t[t.LIGHTER_PERC=50]="LIGHTER_PERC"}(v||(v={}));const g="1. Set a dataframe with function(s) values\n\n2. Select a column with the independent variable in the **argument** field\n\n3. Specify one or more target columns with the dependent variable(s) in the **functions** field",y={showYAxis:!0,showXAxis:!0,showXSelector:!0,showYSelectors:!0,lineColoringType:"custom",lineColor:4288600805,markerColor:4288600805},b=4,A=2147483647,w=16807,C=!0,I=10,T=!1,E=1e-5,S=1,x=1},4214:(t,e,n)=>{"use strict";n(2515),n(9094)},4260:(t,e,n)=>{"use strict";n.d(e,{CB:()=>o,Jc:()=>p,NT:()=>l,Ts:()=>w,_W:()=>c,aQ:()=>I,bV:()=>b,d1:()=>f,eP:()=>r,eX:()=>d,ec:()=>u,iL:()=>m,l8:()=>y,lv:()=>C,pC:()=>v,qh:()=>A,r0:()=>a,sk:()=>s,t6:()=>T,vw:()=>h,zY:()=>g});var i=n(6082);const o={barchart:i.VIEWER.BAR_CHART,boxplot:i.VIEWER.BOX_PLOT,calendar:i.VIEWER.CALENDAR,corrplot:i.VIEWER.CORR_PLOT,densityplot:i.VIEWER.DENSITY_PLOT,filters:i.VIEWER.FILTERS,form:i.VIEWER.FORM,globe:i.VIEWER.GLOBE,googlemap:i.VIEWER.GOOGLE_MAP,grid:i.VIEWER.GRID,heatmap:i.VIEWER.HEAT_MAP,histogram:i.VIEWER.HISTOGRAM,linechart:i.VIEWER.LINE_CHART,markup:i.VIEWER.MARKUP,matrixplot:i.VIEWER.MATRIX_PLOT,networkdiagram:i.VIEWER.NETWORK_DIAGRAM,pcplot:i.VIEWER.PC_PLOT,piechart:i.VIEWER.PIE_CHART,scatterplot:i.VIEWER.SCATTER_PLOT,"3dscatterplot":i.VIEWER.SCATTER_PLOT_3D,shapemap:i.VIEWER.SHAPE_MAP,statistics:i.VIEWER.STATISTICS,tileviewer:i.VIEWER.TILE_VIEWER,timelines:i.VIEWER.TIMELINES,treemap:i.VIEWER.TREE_MAP,trellisplot:i.VIEWER.TRELLIS_PLOT,wordcloud:i.VIEWER.WORD_CLOUD},s="JsCardView",r="scripts",a="functions",l="viewer",u="experimental",c="Run name",d="RunId",p="ModelStorage",h="ID",f="Source",m="Is favorite",v="Is complete",g="Delete",y="Author",b="Date",A="Title",w="Desc.",C="Tags",I="Version",T=Object.values(i.COLUMN_TYPE).filter(t=>t!==i.TYPE.DATA_FRAME)},4315:(t,e,n)=>{"use strict";var i=n(6186),o=n.n(i),s=n(2155),r=n.n(s),a=n(7433),l=n.n(a),u=n(8626),c=n.n(u),d=n(8990),p=n.n(d),h=n(9827),f=n.n(h),m=n(5366),v={};v.styleTagTransform=f(),v.setAttributes=c(),v.insert=l().bind(null,"head"),v.domAPI=r(),v.insertStyleElement=p(),o()(m.A,v),m.A&&m.A.locals&&m.A.locals},4328:t=>{"use strict";t.exports=grok},4339:(t,e,n)=>{"use strict";n.d(e,{R:()=>i});const i={name:"OREGO",arg:{name:"t",start:0,finish:360,step:.01},initial:[1,2,3],func:(t,e,n)=>{const i=e[0],o=e[1],s=e[2];n[0]=77.27*(o-i*o+i-8375e-9*i*i),n[1]=1/77.27*(-o-i*o+s),n[2]=.161*(i-s)},tolerance:1e-8,solutionColNames:["y1","y2","y3"]}},4350:(t,e,n)=>{"use strict";n.d(e,{SJ:()=>l});var i=n(6082),o=n(3508),s=n.n(o);const r=[{name:"NaN",predicate:function(t,e){return Number.isNaN(t)&&Number.isNaN(e)},checker:u},{name:"Null",predicate:function(t,e){return null==t&&null==e},checker:u},{name:"Boolean",predicate:function(t,e){return"boolean"==typeof t&&"boolean"==typeof e},checker:c},{name:"String",predicate:function(t,e){return"string"==typeof t&&"string"==typeof e},checker:c},{name:"Integer",predicate:function(t,e){return Number.isInteger(t)&&Number.isInteger(e)},checker:c},{name:"BigInt",predicate:function(t,e){return"bigint"==typeof t&&"bigint"==typeof e},checker:c},{name:"Float",predicate:function(t,e){return"number"==typeof t&&"number"==typeof e},checker:function(t,e,n){if(!(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||isNaN(t)&&isNaN(e)))return Math.abs(t-e)<n.options.floatTolerance?void 0:[{msg:`Expected ${e}, got ${t} (tolerance = ${n.options.floatTolerance})`}]}},{name:"Map",predicate:function(t,e){return t instanceof Map&&e instanceof Map},checker:function(t,e,n,i){const o=[];n.options.forbidAdditionalProps&&o.push(...p([...t.keys()],[...e.keys()]));for(const n of e.keys()){const o=t.get(n),s=e.get(n);i([String(n)],o,s)}return o}},{name:"Set",predicate:function(t,e){return t instanceof Set&&e instanceof Set},checker:function(t,e,n,i){const o=[];if(t.size!==e.size){const n={msg:`Sets are of different size: actual set size is ${t.size} and expected set size is ${e.size}`};o.push(n)}for(const n of e.values()){const e=t.has(n);i([String(n)],e,!0)}return o}},{name:"ArrayBuffer",predicate:function(t,e){return t instanceof ArrayBuffer&&e instanceof ArrayBuffer},checker:function(t,e,n,i){return d(Array.from(new Uint8Array(t)),Array.from(new Uint8Array(e)),0,i)}},{name:"Array",predicate:function(t,e){return t instanceof Array&&e instanceof Array},checker:d},{name:"DataFrame",predicate:function(t,e){return t instanceof i.DataFrame&&e instanceof i.DataFrame},checker:function(t,e,n,i){const o=[];if(t.rowCount!==e.rowCount){const n={msg:`Dataframes has different row count: actual row count is ${t.rowCount} and expected row count is ${e.rowCount}`};o.push(n)}n.options.forbidAdditionalProps&&o.push(...p([...t.columns].map(t=>t.name),[...e.columns].map(t=>t.name)));for(const n of e.columns){const s=t.columns.byName(n.name);if(!s){const t={msg:`Column ${n.name} not found`};o.push(t);continue}if(s.type!==n.type){const t={msg:`Column ${n.name} type expected ${n.type} got ${s.type}`};o.push(t);continue}for(let t=0;t<e.rowCount;t++){const e=s.get(t),o=n.get(t);i([n.name,String(t)],e,o)}}return o}},{name:"DayJs",predicate:function(t,e){return s().isDayjs(t)&&s().isDayjs(e)},checker:function(t,e){if(!e.isSame(t))return[{msg:`Different date, expected ${e.toISOString()} actual ${t.toISOString()}`}]}},{name:"Object",predicate:function(t,e){return"object"==typeof t&&"object"==typeof e},checker:function(t,e,n,i){const o=[];n.options.forbidAdditionalProps&&o.push(...p([...Object.keys(t)],[...Object.keys(e)]));for(const[n,o]of Object.entries(e))i([n],t[n],o);return o}}];class a extends Error{}function l(t,e,n){new f(n).run(t,e)}function u(){}function c(t,e){if(t!==e)return[{msg:`Expected ${e}, got ${t}`}]}function d(t,e,n,i){const o=[];if(t.length!==e.length){const n={msg:`Arrays are of different length: actual array length is ${t.length} and expected array length is ${e.length}`};o.push(n)}for(let n=0;n<t.length;n++)i([String(n)],t[n],e[n]);return o}function p(t,e){const n=[],i=new Set(e);for(const e of t)if(!i.has(e)){const t={msg:`Additional key/col item in actual data found: ${e}`};n.push(t)}return n}const h={floatTolerance:.001,maxErrorsReport:5,forbidAdditionalProps:!1,maxDepth:128,checkersSeq:r,prefix:""};class f{constructor(t={}){this.options=Object.assign(Object.assign({},h),t),this.state={errors:[],currentPath:[],options:this.options}}run(t,e){this.matchChecker(t,e),this.checkErrorsLimit(0)}checkDeep(t,e,n){const i=t.length;if(this.state.currentPath.push(...t),this.state.currentPath.length>this.options.maxDepth)throw new a(`Max depth ${this.options.maxDepth} is exceeded, potentially a circular structure`);this.matchChecker(e,n),this.state.currentPath.splice(-i)}matchChecker(t,e){let n=!1;for(const{predicate:i,checker:o}of this.options.checkersSeq)if(i(t,e)){n=!0;const i=o(t,e,this.state,this.checkDeep.bind(this));i&&i.map(t=>this.addError(t));break}if(!n){const n={msg:`Type mismatch or no checker defined: expected ${e}, got ${t}`};this.addError(n)}}addError(t){var e,n;const i={path:[...null!==(e=this.state.currentPath)&&void 0!==e?e:[],...null!==(n=t.path)&&void 0!==n?n:[]],msg:t.msg};this.state.errors.push(i),this.checkErrorsLimit()}checkErrorsLimit(t=this.options.maxErrorsReport){if(this.state.errors.length>t){const t=this.makeReport();throw new a(t)}}makeReport(){return this.state.errors.map(t=>{var e;const n=(null!==(e=t.path)&&void 0!==e?e:[]).map(t=>`['${String(t)}']`).join("."),i=n?`${n}: ${t.msg}`:t.msg;return this.options.prefix?`${this.options.prefix}: ${i}`:i}).slice(0,this.options.maxErrorsReport).join("\n")}}},4353:(t,e,n)=>{"use strict";function i(t,e){try{const n=function(t,e){return new Function(`with (this) { return (${t}); }`).call(e)}(t,e);return function(t){return"number"!=typeof t||isNaN(t)?null:t}(n)}catch(t){return null}}n.d(e,{G:()=>i})},4386:(t,e,n)=>{"use strict";n.d(e,{aK:()=>c});var i=n(4328),o=n(7389),s=n(6082),r=n(4260),a=n(1599),l=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const u=(t,e,n)=>{o.setUpdateIndicator(t,e);const i=t.querySelector(".d4-update-shadow .ui-label");e&&n&&i&&(i.textContent=n)},c=(t,e,n,c)=>l(void 0,void 0,void 0,function*(){var h,f;const m={},v=(t,e)=>{if(m[t])return m[t];let n=`${t}`;n.length>31&&(n=`${n.slice(0,31)}`);let i=1;for(;e.worksheets.some(t=>t.name.toLowerCase()===n.toLowerCase());){let e=`${t}`;e.length>31-`-${i}`.length&&(e=`${t.slice(0,31-`-${i}`.length)}`),n=`${e}-${i}`,i++}return m[t]=n,n};if("Excel"===t)try{yield s.Utils.loadJsCss(["/js/common/exceljs.min.js","/js/common/html2canvas.min.js"]);const t=window.ExcelJS,m=window.html2canvas,g="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8",y=new t.Workbook;o.setDisplay(i.shell.v.root,!1),u(i.shell.v.root.parentElement,!0,"Generating report. Please do not switch the browser tab...");let b=0;const A=(t,e,n,...r)=>l(void 0,[t,e,n,...r],void 0,function*(t,e,n,r=0,l){var u,c,d,p;if(!e||!e.dataFrame)return;const h=s.Viewer.fromType(e.type,e.dataFrame.clone());h.copyViewersLook(e);const f=o.div(h.root,{style:{height:`${null!==(u=null==l?void 0:l.heightToRender)&&void 0!==u?u:800}px`,width:`${null!==(c=null==l?void 0:l.widthToRender)&&void 0!==c?c:800}px`}});f.classList.add("ui-box"),f.classList.remove("ui-div"),i.shell.v.root.insertAdjacentElement("afterend",f),yield(0,a.cb)(1e3);const v=(yield m(f)).toDataURL();f.remove();const g=y.addImage({base64:v,extension:"png"}),b=(null==l?void 0:l.heightInCells)||(null==l?void 0:l.widthInCells)?Math.min((null!==(d=null==l?void 0:l.heightInCells)&&void 0!==d?d:Number.MAX_VALUE)/40,(null!==(p=null==l?void 0:l.widthInCells)&&void 0!==p?p:Number.MAX_VALUE)/8):1;t.addImage(g,{tl:{col:n,row:r},ext:{width:800*b,height:800*b}})}),w=t=>s.TYPES_SCALAR.has(t),C=t=>t.propertyType===s.TYPE.DATA_FRAME,I=e.inputs.filter(t=>C(t)),T=e.inputs.filter(t=>w(t.propertyType)),E=e.outputs.filter(t=>C(t)),S=e.outputs.filter(t=>w(t.propertyType));if(I.forEach(t=>{var e;const i=t.options.caption||t.name,o=null!==(e=y.worksheets.find(t=>t.name===v(i,y)))&&void 0!==e?e:y.addWorksheet(v(i,y)),s=n.inputs[t.name];p(o,b,s),b++}),T.length){const t=y.addWorksheet("Input scalars");d(t,T.map(t=>{var e,i,o;return{caption:null!==(e=t.options.caption)&&void 0!==e?e:t.name,value:null!==(i=n.inputs[t.name])&&void 0!==i?i:"",units:null!==(o=t.options.units)&&void 0!==o?o:""}}))}if(E.forEach(t=>{var e;const i=t.options.caption||t.name,o=null!==(e=y.worksheets.find(t=>t.name===v(i,y)))&&void 0!==e?e:y.addWorksheet(v(i,y)),s=n.outputs[t.name];p(o,b,s),b++}),S.length){const t=y.addWorksheet("Output scalars");d(t,S.map(t=>{var e,i,o;return{caption:null!==(e=t.options.caption)&&void 0!==e?e:t.name,value:null!==(i=n.outputs[t.name])&&void 0!==i?i:"",units:null!==(o=t.options.units)&&void 0!==o?o:""}}))}for(const t of e.inputs.filter(t=>C(t))){const e=(null!==(h=c[t.name])&&void 0!==h?h:[]).filter(t=>t&&t.type!==s.VIEWER.GRID).filter(t=>Object.values(r.CB).includes(t.type));if(0===e.length)continue;const i=t.options.caption||t.name,o=n.inputs[t.name];for(const[t,n]of e.entries())yield A(y.getWorksheet(v(i,y)),n,o.columns.length+2,t>0?16*t+1:0,{heightInCells:16,heightToRender:600,widthToRender:600})}for(const t of e.outputs.filter(t=>C(t))){const e=(null!==(f=c[t.name])&&void 0!==f?f:[]).filter(t=>t&&t.type!==s.VIEWER.GRID).filter(t=>Object.values(r.CB).includes(t.type));if(0===e.length)continue;const i=t.options.caption||t.name,o=n.outputs[t.name];for(const[t,n]of e.entries())if(n)if(n.type===s.VIEWER.STATISTICS){const n=o.columns.length,r=s.DataFrame.fromColumns([s.Column.string("Name",n).init(t=>o.columns.byIndex(t).name),s.Column.int("Values",n).init(t=>o.columns.byIndex(t).stats.valueCount),s.Column.int("Nulls",n).init(t=>o.columns.byIndex(t).stats.missingValueCount),s.Column.float("Min",n).init(t=>o.columns.byIndex(t).stats.min),s.Column.float("Max",n).init(t=>o.columns.byIndex(t).stats.max),s.Column.float("Avg",n).init(t=>o.columns.byIndex(t).stats.avg),s.Column.float("Stdev",n).init(t=>o.columns.byIndex(t).stats.stdev)]);p(y.getWorksheet(v(i,y)),b,r,o.columns.length+2,t>0&&e[t-1]?Math.ceil(e[t-1].root.clientHeight/20)+1:0),b++}else yield A(y.getWorksheet(v(i,y)),n,o.columns.length+2,t>0?16*t+1:0,{heightInCells:16,heightToRender:600,widthToRender:600})}const x=yield y.xlsx.writeBuffer();return[new Blob([x],{type:g}),y]}catch(t){console.log(t)}finally{o.setDisplay(i.shell.v.root,!0),u(i.shell.v.root.parentElement,!1)}throw new Error("Format is not supported")}),d=(t,e)=>{t.addRow(["Parameter","Value","Units"]).font={bold:!0},e.forEach(e=>{t.addRow([e.caption,e.value,e.units])}),t.getColumn(1).width=1.2*Math.max(...e.map(t=>t.caption.toString().length),9),t.getColumn(2).width=1.2*Math.max(...e.map(t=>t.value.toString().length),5),t.getColumn(3).width=1.2*Math.max(...e.map(t=>t.units.toString().length),5)},p=(t,e,n,i,o)=>{if(!n)return;const s=t.getColumn(null!=i?i:1).letter,r={name:`ID_${e.toString()}`,ref:`${s}${null!=o?o:1}`,columns:n.columns.toList().map(t=>({name:t.name,filterButton:!1})),rows:new Array(n.rowCount).fill(0).map((t,e)=>[...n.row(e).cells].map(t=>t.value))};t.addTable(r),t.columns.forEach(t=>{t.width=25,t.alignment={wrapText:!0}})}},4536:(t,e,n)=>{"use strict";var i=n(9131);n(8501),i.Y},4570:(t,e,n)=>{"use strict";n.d(e,{Yv:()=>s,bc:()=>i,nH:()=>o}),n(1340),n(7423);const i=["pow","sin","cos","tan","asin","acos","atan","sqrt","exp","log","sinh","cosh","tanh"],o=i.indexOf("pow"),s=["PI","E"];var r,a,l,u,c;!function(t){t.ARG_NAME="name",t.COUNT="count",t.DURATION="duration"}(r||(r={})),function(t){t.MAIN_DOCS="/help/compute/diff-studio",t.CORE_BLOCKS="/help/compute/diff-studio#core-blocks",t.COMPS_SYNTAX="/help/compute/diff-studio#model-components-and-syntax",t.LOOP="/help/compute/diff-studio#cyclic-processes",t.UPDATE="/help/compute/diff-studio#multistage-processes",t.UI_OPTS="/help/compute/diff-studio#user-interface-options",t.LOOP_VS_UPDATE="/help/compute/diff-studio#advanced-features",t.SOLVER_CONFIG="/help/compute/diff-studio#solver-configuration",t.MODEL_PARAMS="/help/compute/diff-studio#model-parameters"}(a||(a={})),function(t){t.CTRL_EXPR='Unsupported control expression with the tag **"#"**',t.ARG="'The **#argument** block must consist of 3 lines specifying initial and final time, and solution grid step.",t.LOOP="The **#loop** block must contain at least one line.",t.COUNT="Incorrect loop count",t.LOOP_VS_UPDATE="The **#loop** and **'#update'** blocks cannot be used simultaneously.",t.UPDATE_LINES_COUNT="The **'#update'** block must contain at least one line.",t.DURATION="Incorrect update duration",t.BRACES=" Missing one of the braces (**{**, **}**).",t.COLON='Incorrect position of **":"**.',t.CASE_INSENS="Non-unique name (case-insensitive): use different caption for ",t.MISSING_INIT="Correct the **#inits** block.",t.UNDEF_NAME="Model name missing. Specify the model name in the **#name** block.",t.UNDEF_DEQS="Differential equation(s) are required for this model. Add equation(s) under the **#equations** block.",t.UNDEF_INITS="Initial conditions are required for this model. Add initial conditions under the **#inits** block.",t.UNDEF_ARG="Argument specification is required for this model. Specify an argument, its range, and a grid step in the **#argument** block.",t.CORRECT_ARG_LIM="Correct limits in the **#argument** block.",t.INTERVAL="Incorrect range for",t.NEGATIVE_STEP="Solution grid step must be positive. Correct the **#argument** block.",t.INCOR_STEP="Grid step must less than the length of solution interval. Correct the **#argument** block.",t.MISS_COLON='Missing **":"**',t.NAN="is not a valid number. Correct the line",t.SERVICE_START='Variable names must not begin with **"_"**.',t.REUSE_NAME="Variable reuse (case-insensitive): rename ",t.SOLVER="Incorrect solver options. Correct the **#meta.solver** line."}(l||(l={})),function(t){t.NAME="//name:",t.DESCR="//description:",t.TAGS="//tags:",t.LANG="//language: javascript",t.DOUBLE_INPUT="//input: double",t.INT_INPUT="//input: int",t.OUTPUT="//output: dataframe df",t.EDITOR="//editor: Compute:RichFunctionViewEditor",t.SIDEBAR="//sidebar: @compute",t.CAPTION="caption:",t.ARG_INIT="{caption: Initial; category: Argument}",t.ARG_FIN="{caption: Final; category: Argument}",t.ARG_STEP="{caption: Step; category: Argument}",t.INITS="category: Initial values",t.PARAMS="category: Parameters"}(u||(u={})),function(t){t.CONSTS="// constants",t.ODE_COM="// the problem definition",t.ODE="let odes = {",t.SOLVER_COM="// solve the problem",t.SOLVER="const solver = await grok.functions.eval('DiffStudio:solveEquations');",t.PREPARE="let call = solver.prepare({problem: odes, options: opts});",t.CALL="await call.call();",t.OUTPUT="let df = call.getParamValue('df');",t.SPACE2=" ",t.SPACE4=" ",t.SPACE6=" ",t.SPACE8=" ",t.FUNC_VALS="// extract function values",t.EVAL_EXPR="// evaluate expressions",t.COMP_OUT="// compute output",t.MATH_FUNC_COM="// used Math-functions",t.MATH_CONST_COM="// used Math-constants",t.ONE_STAGE_COM="\n// one stage solution",t.ONE_STAGE_BEGIN="let _oneStage = async (",t.ONE_STAGE_END=") => {",t.ASYNC_OUTPUT="let df = await _oneStage(",t.RETURN_OUTPUT="return call.getParamValue('df');",t.EMPTY_OUTPUT="let df = DG.DataFrame.create();",t.APPEND="df.append(",t.SOLUTION_DF_COM="// solution dataframe",t.LOOP_INTERVAL_COM="// loop interval",t.LOOP_INTERVAL="_interval",t.LAST_IDX="_lastIdx",t.UPDATE_COM="// update ",t.CUSTOM_OUTPUT_COM="// create custom output",t.CUSTOM_COLUMNS="let _columns = [",t.ONE_STAGE="await _oneStage(",t.SEGMENT_COM="// add segment category"}(c||(c={}))},4594:(t,e,n)=>{"use strict";n.d(e,{h:()=>s});var i=n(7149);class o{constructor(t=1,e=1){(0,i.C1)(t),(0,i.C1)(e),this.N=t,this.d=e,this.A=this.generateMatrix(t,e),this.B=this.generateMatrix(t,e),this.AB=this.createMixMatrax(this.A,this.B)}generateMatrix(t,e){const n=new Array(e);for(let i=0;i<e;++i){n[i]=new Float32Array(t);for(let e=0;e<t;++e)n[i][e]=Math.random()}return n}createMixMatrax(t,e){const n=this.d,i=new Array(n);for(let o=0;o<n;++o){i[o]=new Array(0);for(let s=0;s<n;++s)o!==s?i[o].push(t[s]):i[o].push(e[s])}return i}getRow(t,e){const n=new Float32Array(this.d);for(let i=0;i<this.d;++i)n[i]=t[i][e];return n}getRowOfMatrixA(t){return this.getRow(this.A,t)}getRowOfMatrixB(t){return this.getRow(this.B,t)}getRowOfMatrixAB(t,e){return this.getRow(this.AB[t],e)}getConcatenatedColumns(){const t=new Array(0),e=this.N,n=this.d;for(let i=0;i<n;++i){const o=new Float32Array(e*(n+2));o.set(this.A[i]),o.set(this.B[i],e);for(let t=0;t<n;++t)o.set(this.AB[t][i],2*e+e*t);t.push(o)}return t}}function s(t,e){return new o(t,e).getConcatenatedColumns()}},4674:(t,e,n)=>{"use strict";n.d(e,{D:()=>a});var i=n(6082),o=n(508),s=n(7011);const r=i.FLOAT_NULL;class a{constructor(t,e,n){if(this.rowIdx=s.dq,this.argColIdx=s.dq,this.argVal=s.dq,this.diffGrok=t,this.funcInputs=e,this.outputNames=o.AK(this.diffGrok.ivp),null!==n.value.row)this.rowIdx=n.value.row;else{const t=n.value.colName;if(this.argColIdx=this.outputNames.indexOf(t),this.argColIdx<0)throw new Error(`Incorrect arg column name: ${t}`);this.argVal=n.value.colValue}}getResults(){return t=this,e=void 0,a=function*(){const t=this.funcInputs.length,e=Math.min(Math.max(s.j2,navigator.hardwareConcurrency-s.fK),t),o=new Array(e).fill(null).map(t=>new Worker(new URL(n.p+n.u(377),n.b))),a=this.getTasks(t,e);let l=0,u=0;const c=i.TaskBarProgressIndicator.create(`Analyzing... (${u}%)`),d=[],p=this.outputNames.length;for(let e=0;e<p;++e)d.push(new Float64Array(t));const h=o.map((t,n)=>new Promise((i,o)=>{t.postMessage({task:a[n]}),t.onmessage=h=>{var f;if(t.terminate(),++l,u=Math.floor(100*(l+1)/e),u<99.9?c.update(u,`Analyzing... (${u}%)`):c.update(u,"Analyzing... (100%)"),h.data.callResult===s.OW.SUCCEED){{const t=h.data.rowVals;h.data.analysisRes.forEach((e,i)=>{if(e===s.Un)for(let e=0;e<p;++e)d[e][a[n].indices[i]]=t[i][e];else for(let t=0;t<p;++t)d[t][a[n].indices[i]]=r})}i()}else o(null!==(f=h.data.msg)&&void 0!==f?f:"error in webworker sensitivity analysis")},t.onerror=e=>{t.terminate(),console.error(e),o(e)}}));return yield Promise.all(h),c.close(),this.outputNames.map((t,e)=>i.Column.fromFloat64Array(t,d[e]))},new((o=void 0)||(o=Promise))(function(n,i){function s(t){try{l(a.next(t))}catch(t){i(t)}}function r(t){try{l(a.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof o?e:new o(function(t){t(e)})).then(s,r)}l((a=a.apply(t,e||[])).next())});var t,e,o,a}getTasks(t,e){const n=[];let i,s=0;const r=Math.floor(t/e);let a,l,u=t%e;for(let c=0;c<e;++c){const e=[],c=[],d=[];l=u>0?1:0,a=r+l,--u;for(let n=0;n<a&&(i=o.S3(this.funcInputs[s],this.diffGrok.ivp),c.push(i),e.push(this.diffGrok.pipelineCreator.getPipeline(i)),d.push(s),++s,!(s>=t));++n);n.push({ivp2ww:this.diffGrok.ivpWW,pipelines:e,indices:d,inputVecs:c,rowIdx:this.rowIdx,argColIdx:this.argColIdx,argVal:this.argVal})}return n}}},4778:(t,e,n)=>{"use strict";n.d(e,{fj:()=>i}),n(6082),n(5520),n(3508);const i="OUTPUT_OUTDATED"},4795:(t,e,n)=>{"use strict";n.d(e,{$X:()=>M,Fd:()=>x,Gb:()=>g,Hs:()=>C,JU:()=>T,KL:()=>v,LL:()=>b,O0:()=>I,QL:()=>S,_t:()=>O,aB:()=>A,hg:()=>E,r6:()=>w,sy:()=>y,tf:()=>R,wB:()=>N});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(4260),u=n(7375),c=n(1927),d=n(6910),p=n(1858),h=n(1599),f=n(8920),m=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};function v(t){const e=t;return e.dart&&s.toJs(e.dart)instanceof s.InputBase}function g(t){return new p.Observable(e=>{const n=t(t=>{e.next(t)});return()=>n.unsubscribe()})}const y=(t,e,n,i,o,r)=>{var a;r&&t.setOptions({showCurrentRowIndicator:!0,showCurrentCellOutline:!1,allowEdit:!1,allowBlockSelection:!1,showRowHeader:!1,showColumnLabels:!e,extendLastColumn:e}),t.sort([l.bV],[!1]);for(let e=0;e<t.columns.length;e++){const n=t.columns.byIndex(e);n&&(null===(a=n.column)||void 0===a?void 0:a.type)===s.TYPE.DATE_TIME&&(n.format="MMM d, h:mm tt")}if((0,d.eF)(t),e)t.columns.setVisible([l.vw]),t.props.rowHeight=70,t.invalidate();else{t.props.rowHeight=28;const e=t.dataFrame.getCol(l.lv);t.columns.setVisible([l.d1,l.iL,l.zY,...i?[l.bV]:[],...i?[l.l8]:[],...i&&e.stats.missingValueCount<e.length?[l.lv]:[],...i?[l.qh]:[],...i?[l.Ts]:[],...n&&o?(0,d.rs)(o).map(t=>{var e,n;const i=null!==(e=o.inputs.find(e=>e.name===t))&&void 0!==e?e:o.outputs.find(e=>e.name===t);return i?null!==(n=i.caption)&&void 0!==n?n:(0,d.Uo)(i.name):(0,d.Uo)(t)}):[]])}},b=(t,e,n,i,s)=>{var r,a;const u=t.dataFrame,c=u.getCol(l.lv),p=[...e&&u.getCol(l.d1).categories.length>1?[l.d1]:[],...e&&(null!==(a=null===(r=u.col(l.iL))||void 0===r?void 0:r.categories.length)&&void 0!==a?a:0)>1?[l.iL]:[],...e?[l.bV,l.pC]:[],...e&&u.getCol(l.l8).categories.length>1?[l.l8]:[],...e&&c.stats.missingValueCount<c.length?[l.lv]:[],...e&&u.getCol(l.qh).categories.length>1?[l.qh]:[],...e&&u.getCol(l.Ts).categories.length>1?[l.Ts]:[],...s&&n?(0,d.rs)(s).map(t=>{var e,n;const i=null!==(e=s.inputs.find(e=>e.name===t))&&void 0!==e?e:s.outputs.find(e=>e.name===t);return i?null!==(n=i.caption)&&void 0!==n?n:(0,d.Uo)(i.name):(0,d.Uo)(t)}).filter(t=>!i||u.getCol(t).categories.length>1).map(t=>t):[]];return p.length>0?(o.setDisplay(t.root,!0),t.setOptions({columnNames:p,showHeader:!1,showBoolCombinedFilter:!0})):o.setDisplay(t.root,!1),p.length>0},A=t=>m(void 0,void 0,void 0,function*(){i.shell.windows.help.visible=!0,yield new Promise(t=>setTimeout(t,100)),i.shell.windows.help.showHelp(o.markdown(t))}),w=t=>{const e={inputs:{},outputs:{}};return t.inputs.filter(t=>t.propertyType===s.TYPE.DATA_FRAME&&0!==(0,h.jJ)(t).config.length).forEach(t=>{const n="Misc"===t.category?"Input":t.category;e.inputs[n]?e.inputs[n].push(t):e.inputs[n]=[t]}),t.outputs.forEach(t=>{const n="Misc"===t.category?"Output":t.category;t.propertyType===s.TYPE.DATA_FRAME&&0===(0,h.jJ)(t).config.length||(e.outputs[n]?e.outputs[n].push(t):e.outputs[n]=[t])}),e},C=t=>m(void 0,void 0,void 0,function*(){const e=t.id,n=s.Func.byName(t.func.nqName).prepare([...t.inputs].reduce((t,[e,n])=>(t[e]=n,t),{}));return t.options.forEach(e=>n.options[e]=t.options[e]),e||(n.id=null),n}),I=t=>t.options.runLabel,T=t=>{if((0,u.gD)(t))return;const e=t;e.setDisabled=function(){t.enabled=!1,a()(t.root).removeClass("rfv-restricted-unlocked-input"),a()(t.root).removeClass("rfv-inconsistent-input"),a()(t.root).removeClass("rfv-restricted-input")},e.setRestricted=function(){t.enabled=!1,a()(t.root).addClass("rfv-restricted-input"),a()(t.root).removeClass("rfv-restricted-unlocked-input"),a()(t.root).removeClass("rfv-inconsistent-input")},e.setRestrictedUnlocked=function(){t.enabled=!0,a()(t.root).addClass("rfv-restricted-unlocked-input"),a()(t.root).removeClass("rfv-restricted-input"),a()(t.root).removeClass("rfv-inconsistent-input")},e.setInconsistent=function(){t.enabled=!0,a()(t.root).addClass("rfv-inconsistent-input"),a()(t.root).removeClass("rfv-restricted-input"),a()(t.root).removeClass("rfv-restricted-unlocked-input")},e.setUserInput=function(){t.enabled=!0,a()(t.root).removeClass("rfv-inconsistent-input"),a()(t.root).removeClass("rfv-restricted-input"),a()(t.root).removeClass("rfv-restricted-unlocked-input")}},E=(t,e)=>{var n;const i=t.property;a()(e.root).css({width:`calc(${null!==(n=i.options.block)&&void 0!==n?n:"100"}% - ${i.options.block?"2":"0"}px)`,"box-sizing":"border-box"})},S=(t,...e)=>m(void 0,[t,...e],void 0,function*(t,e=f.bZ.INPUTS){const n=[...t[f.wl[e]].values()];return(yield Promise.all(n.filter(t=>!!t.property.options.validatorFunc).map(t=>m(void 0,void 0,void 0,function*(){const e=s.Func.byName(t.property.options.validatorFunc).prepare({params:JSON.parse(t.property.options.validatorFuncOptions||"{}")});return yield e.call(),[t.name,e.outputs.validator]})))).reduce((t,[e,n])=>(t[e]=n,t),{})}),x=(t,e)=>{const n=(0,c.JC)(e);return t[0].replaceWith(n[0]),t[1].replaceWith(n[1]),n},R=(t,e,n,i,o,s)=>m(void 0,void 0,void 0,function*(){const{view:r,funcCall:a,lastCall:l}=o,u=yield Promise.all(e.map(e=>m(void 0,void 0,void 0,function*(){const o=i===f.bZ.INPUTS?a.inputs[e]:a.outputs[e],u=yield(0,c.Td)(o,{param:e,funcCall:a,lastCall:l,signal:n,isNewOutput:!!t.isNewOutput,isRevalidation:t.isRevalidation,view:r});let d;const p=s[e];p&&(d=yield p(o,{param:e,funcCall:a,lastCall:l,signal:n,isNewOutput:!!t.isNewOutput,isRevalidation:t.isRevalidation,context:t.context,view:r}));const h=i===f.bZ.INPUTS&&a.inputParams[e].property.options.nullable;return[e,(0,c.uD)(...h?[]:[u],d)]})));return Object.fromEntries(u)}),O=t=>{const e=o.element("i");t.addOptions(e),t.setValidation=function(n){for(;e.firstChild&&e.removeChild(e.firstChild););const[i,o]=(0,c.JC)(n);i&&o&&(e.appendChild(i),e.appendChild(o)),t.input.classList.remove("d4-invalid"),t.input.classList.remove("d4-partially-invalid"),(null==n?void 0:n.errors)&&n.errors.length||(null==n?void 0:n.warnings)&&n.warnings.length||(null==n?void 0:n.notifications)&&n.notifications.length||(null==n?void 0:n.pending)?a()(e).css("display","flex"):a()(e).hide(),(null==n?void 0:n.errors)&&n.errors.length?t.input.classList.add("d4-invalid"):(null==n?void 0:n.warnings)&&n.warnings.length&&t.input.classList.add("d4-partially-invalid")}};function N(t,e){return m(this,void 0,void 0,function*(){const n={};for(const[i,o]of Object.entries(t.inputs)){const{property:t}=e.funcCall.inputParams[i];n[i]=yield F(t,o,e)}return{inputs:n,outputs:t.outputs}})}function F(t,e,n){return m(this,void 0,void 0,function*(){return"file"===t.propertyType&&n.getInput?n.getInput(t.name).value.arrayBuffer():e})}function M(t,e){return m(this,void 0,void 0,function*(){return"file"===t?new File([e],""):e})}},5092:(t,e,n)=>{"use strict";n.d(e,{W:()=>p});var i=n(4328),o=n(6082),s=n(1991),r=n.n(s),a=n(1599),l=n(3508),u=n.n(l),c=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const d=t=>{switch(t){case"Today":return"started > -1d";case"Yesterday":return"started > -2d and started < -1d";case"Any time":return"";case"Last year":return"started > -2y and started < -1y";case"This year":return"started > -1y";case"Last month":return"started > -2m and started < -1m";case"This month":return"started > -1m";case"Last week":return"started > -2w and started < -1w";case"This week":return"started > -1w"}};var p;!function(t){const e=new o.LruCache;function n(t){return c(this,arguments,void 0,function*(t,e=!1,n=!0){const s=yield i.dapi.functions.calls.allPackageVersions().include("session.user,func.package, inputs, outputs").find(t);if(!n){const t=r()(s.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.FILE&&!!s.inputs[t.name]);yield Promise.all(t.map(t=>c(this,void 0,void 0,function*(){const{id:e,name:n}=JSON.parse(s.inputs[t.name]),r=yield i.dapi.files.readAsBytes(e),a=o.FileInfo.fromBytes(n,r);return a.id=e,s.inputs[t.name]=a,Promise.resolve()})))}if(!e){const t=r()(s.outputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!s.outputs[t.name]);yield Promise.all(t.map(t=>c(this,void 0,void 0,function*(){return s.outputs[t.name]=yield i.dapi.tables.getTable(s.outputs[t.name]),Promise.resolve()})));const e=r()(s.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!s.inputs[t.name]);yield Promise.all(e.map(t=>c(this,void 0,void 0,function*(){return s.inputs[t.name]=yield i.dapi.tables.getTable(s.inputs[t.name]),Promise.resolve()})))}return s})}t.loadChildRuns=function(t){return c(this,void 0,void 0,function*(){return{parentRun:yield n(t),childRuns:yield i.dapi.functions.calls.allPackageVersions().include("func, func.package").filter(`options.parentCallId="${t}"`).list()}})},t.loadRun=n,t.saveRun=function(t){return c(this,arguments,void 0,function*(t,n=!0){let s=e.get("All users");s||(s=yield i.dapi.groups.find(o.Group.defaultGroupsIds["All users"]),e.set("All users",s));const l=(0,a.A4)(t);if((0,a.Ne)(l)&&(l.options.createdOn=u()().utc(!0).unix()),!n){const t=r()(l.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.FILE&&!!l.inputs[t.name]);yield Promise.all(t.map(t=>c(this,void 0,void 0,function*(){const e=l.inputs[t.name],n=o.FileInfo.fromBytes(e.name,yield e.readAsBytes());return yield i.dapi.files.write(n),l.inputs[t.name]={id:n.id,name:n.name},Promise.resolve()})))}const d=r()(l.outputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!l.outputs[t.name]);yield Promise.all(d.map(t=>c(this,void 0,void 0,function*(){yield i.dapi.tables.uploadDataFrame(l.outputs[t.name]),yield i.dapi.permissions.grant(l.outputs[t.name].getTableInfo(),s,!1)})));const p=r()(l.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!l.inputs[t.name]);yield Promise.all(p.map(t=>c(this,void 0,void 0,function*(){yield i.dapi.tables.uploadDataFrame(l.inputs[t.name]),yield i.dapi.permissions.grant(l.inputs[t.name].getTableInfo(),s,!1)})));const h=yield i.dapi.functions.calls.allPackageVersions().save(l);return i.log.audit("@user saved run of the @model model",{user:o.User.current(),model:h.func}),h})},t.deleteRun=function(t){return c(this,void 0,void 0,function*(){t.options.isDeleted=!0,yield i.dapi.functions.calls.allPackageVersions().save(t)})},t.pullRuns=function(t){return c(this,arguments,void 0,function*(t,e={},n={}){let o=`func.id="${t}"`;return o+=e.author?` and session.user.id="${e.author.id}"`:"",o+=e.date?d(e.date):"",i.dapi.functions.calls.allPackageVersions().filter(o).include("session.user, options").list(n)})},t.pullRunsByName=function(t){return c(this,arguments,void 0,function*(t,e=[],n={},s=[],a=!1){let l="";for(const t of e){const e=[];t.author&&e.push(`session.user.id="${t.author.id}"`),t.date&&e.push(d(t.date)),t.text&&e.push(`((options.title like "${t.text}") or (options.annotation like "${t.text}"))`),t.includeDeleted||e.push('((options.isDeleted != "true") or (options.isDeleted = null))');const n=e.join(" and ");""!==n&&(l+=""===l?`(${n})`:` or (${n})`)}""!==l&&(l=` and (${l})`);const u=yield i.dapi.functions.calls.allPackageVersions().filter(`func.name="${t}"${l}`).include(`${[...s,"func.package"].join(",")}`).list(n);if((s.includes("inputs")||s.includes("func.params"))&&!a)for(const t of u){const e=r()(t.inputParams.values()).filter(e=>e.property.propertyType===o.TYPE.DATA_FRAME&&!!t.inputs[e.name]);for(const n of e)t.inputs[n.name]=yield i.dapi.tables.getTable(t.inputs[n.name])}if((s.includes("outputs")||s.includes("func.params"))&&!a)for(const t of u){const e=r()(t.outputParams.values()).filter(e=>e.property.propertyType===o.TYPE.DATA_FRAME&&!!t.outputs[e.name]);for(const n of e)t.outputs[n.name]=yield i.dapi.tables.getTable(t.outputs[n.name])}return u})}}(p||(p={}))},5167:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(5516),o=n.n(i),s=n(1364),r=n.n(s)()(o());r.push([t.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},5255:(t,e,n)=>{"use strict";n.d(e,{NZ:()=>o,nF:()=>s});var i=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class o extends Error{constructor(t){super(t)}}function s(t,e){return i(this,arguments,void 0,function*(t,e,n=performance.now()){return performance.now()-n>=t?(yield(i=e,new Promise((t,e)=>setTimeout(t,i))),performance.now()):n;var i})}},5342:(t,e,n)=>{"use strict";n.d(e,{S:()=>u});var i=n(6082),o=n(5255),s=n(241),r=n(7395),a=n(7722),l=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};function u(t){return l(this,arguments,void 0,function*({objectiveFunc:t,inputsBounds:e,samplesCount:n=1,settings:l,reproSettings:u,earlyStoppingSettings:c}){const d=u.reproducible?(0,a.Is)(u.seed):Math.random,p=(0,r.qc)(n,e,d);let h=[];const f=[],m=[];let v,g=0,y=null,b=0;const A=i.TaskBarProgressIndicator.create(`Fitting... (${b}%)`,{cancelable:!0}),w=c.useEarlyStopping,C=w?c.costFuncThreshold:void 0,I=c.stopAfter;let T=0;for(v=0;v<n;++v)try{if(A.canceled)break;const e=yield(0,s.t)(t,p[v],l);if(w){if(e.cost<=C&&(h.push(e),++T),T>=I)break}else h.push(e);b=Math.floor(100*(v+1)/n),A.update(b,`Fitting... (${b}%)`)}catch(t){if(t instanceof o.NZ)throw A.close(),new Error(`Inconsistent dataframes: ${t.message}`);++g,f.push(t instanceof Error?t.message:"Platform issue"),m.push(p[v])}if(A.close(),g>0){const t=p.length,e=new Array(t);for(let n=0;n<t;++n)e[n]=new Float64Array(g);m.forEach((t,n)=>t.forEach((t,i)=>e[i][n]=t)),y=i.DataFrame.fromColumns(e.map((t,e)=>i.Column.fromFloat64Array(`arg${e}`,t))),y.columns.add(i.Column.fromStrings("Issue",f))}return{extremums:h,fails:y}})}},5355:(t,e,n)=>{"use strict";n.d(e,{H:()=>I});var i=n(4328),o=n(7389),s=n(6082),r=n(1991),a=n.n(r),l=n(1757),u=n.n(l),c=n(1858),d=n(9713),p=n(5092),h=n(4260),f=n(3508),m=n.n(f),v=n(4112),g=n.n(v),y=n(8804),b=n(6910),A=n(4795),w=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};m().extend(g());const C=new s.LruCache;class I extends s.Widget{get type(){return"HistoricalRunsList"}get onRunsDfChanged(){return this._onRunsDfChanged.asObservable()}get onChosen(){return this._onChosen.asObservable()}get chosen(){return this._onChosen.value}set chosen(t){var e;this.chosenById=null!==(e=null==t?void 0:t.id)&&void 0!==e?e:null}set chosenById(t){if(t){for(let e=0;e<this.currentDf.rowCount;e++)if(this.currentDf.getCol(h.vw).get(e)===t){this.currentDf.currentRowIdx=e;break}}else this.currentDf.currentRowIdx=-1}get selected(){return this._onSelectedChanged.value}get runs(){return this.onRunsChanged.value}get onSelectedChanged(){return this._onSelectedChanged.asObservable()}getRunByIdx(t){return this.runs.get(this.currentDf.get(h.vw,t))}showEditDialog(t,e){const n=y.V.forFuncCall(t,e);n.onMetadataEdit.pipe((0,d.take)(1)).subscribe(n=>w(this,void 0,void 0,function*(){var o;if(null===(o=this.options)||void 0===o?void 0:o.isHistory)return(!!n.isFavorite!==e?(0,b.WM)(t,!!n.isFavorite):Promise.resolve()).then(()=>p.W.loadRun(t.id,!1)).then(t=>(n.title&&(t.options.title=n.title),n.description&&(t.options.description=n.description),n.tags&&(t.options.tags=n.tags),[p.W.saveRun(t),t])).then(([,t])=>{this.updateRun(t),this.onMetadataEdit.next(t)}).catch(t=>{i.shell.error(t)});this.updateRun(t)})),n.show({center:!0,width:500})}constructor(t,e){var n,r,l,f,m,v,g;super(o.div([],{style:{height:"100%",width:"100%"}})),this.initialRuns=t,this.options=e,this.onRunsChanged=new c.BehaviorSubject(this.initialRuns.reduce((t,e)=>(t.set(e.id,e),t),new Map)),this._onRunsDfChanged=new c.BehaviorSubject(s.DataFrame.fromColumns([s.Column.bool(h.d1,0),...(null===(n=this.options)||void 0===n?void 0:n.isHistory)?[s.Column.bool(h.iL,0)]:[],...(null===(r=this.options)||void 0===r?void 0:r.showActions)?[s.Column.string(h.zY,0)]:[],s.Column.bool(h.pC,0),s.Column.dateTime(h.bV,0),s.Column.string(h.l8,0),s.Column.string(h.lv,0),s.Column.string(h.qh,0),s.Column.string(h.Ts,0),s.Column.fromStrings(h.vw,[])])),this._historyFilters=s.Viewer.filters(this._onRunsDfChanged.value,{title:"Filters",columnNames:[]}),this._historyGrid=s.Viewer.grid(this._onRunsDfChanged.value,{showRowHeader:!1,showColumnGridlines:!1,allowEdit:!1}),this.onComparisonCalled=new c.Subject,this.onMetadataEdit=new c.Subject,this._onChosen=new c.BehaviorSubject(null),this.onDelete=new c.Subject,this._onSelectedChanged=new c.BehaviorSubject(new Set([])),this.layout=o.splitH([],null,!0),this.defaultGridText=o.divText(null!==(f=null===(l=this.options)||void 0===l?void 0:l.fallbackText)&&void 0!==f?f:"No historical runs found","hp-no-elements-label"),this.defaultFiltersText=o.divText("No filters to show","hp-no-elements-label"),this.filterWithText=o.divH([this.defaultFiltersText,this._historyFilters.root],"ui-box"),this.trashIcon=o.div(o.iconFA("trash-alt",()=>{const t=this.currentDf.selection.getSelectedIndexes(),e=new Set;t.forEach(t=>e.add(this.getRunByIdx(t)));const n=new y.C(e);n.onFuncCallDelete.pipe((0,d.take)(1)).subscribe(t=>w(this,void 0,void 0,function*(){o.setUpdateIndicator(this.root,!0);try{yield Promise.all(a()(t.values()).map(t=>w(this,void 0,void 0,function*(){return yield this.deleteRun(t.id),Promise.resolve()})))}catch(t){i.shell.error(t)}finally{o.setUpdateIndicator(this.root,!1)}})),n.show({center:!0,width:500,modal:!0})},"Delete selected runs"),{style:{paddingTop:"5px"}}),this.compareIcon=o.div(o.iconFA("exchange",()=>w(this,void 0,void 0,function*(){const t=this.currentDf.selection.getSelectedIndexes(),e=[];t.forEach(t=>{e.push(this.currentDf.getCol(h.vw).get(t))}),this.onComparisonCalled.next(e)}),"Compare selected runs"),{style:{paddingTop:"5px"}}),this._isFilterHidden=new c.BehaviorSubject(!1),this.showFiltersIcon=o.div(o.iconFA("filter",()=>{this._isFilterHidden.next(!this._isFilterHidden.value)},"Toggle filters"),{style:{paddingTop:"4px"}}),this._compactMode=new c.BehaviorSubject(null!==(v=null===(m=this.options)||void 0===m?void 0:m.isHistory)&&void 0!==v&&v),this.toggleCompactMode=o.div(o.iconFA("expand-alt",()=>{this.compactMode=!this.compactMode},"Toggle compact mode"),{style:{paddingTop:"4px"}}),this.showMetadataIcon=o.input.toggle("Metadata",{value:!0,onValueChanged:()=>{this.styleHistoryGrid(),this.styleHistoryFilters()}}),this.showInputsIcon=o.input.toggle("Params",{value:!1,onValueChanged:t=>w(this,void 0,void 0,function*(){var e;0!==this.runs.size&&(t&&(null===(e=this.options)||void 0===e?void 0:e.isHistory)?((yield Promise.all([...this.runs.values()].map(t=>w(this,void 0,void 0,function*(){if(C.has(t.id))return C.get(t.id);{const e=yield p.W.loadRun(t.id,!0);return C.set(e.id,e),e}})))).forEach(t=>{this.runs.set(t.id,t)}),this.onRunsChanged.next(this.runs)):(this.styleHistoryGrid(),this.styleHistoryFilters()))})});const A=o.divH([o.divH([...(null==e?void 0:e.isHistory)?[this.toggleCompactMode]:[],this.showFiltersIcon,this.showMetadataIcon.root,this.showInputsIcon.root],{style:{gap:"5px",padding:"5px"}}),o.divH((null===(g=this.options)||void 0===g?void 0:g.showBatchActions)?[this.trashIcon,this.compareIcon]:[],{style:{gap:"5px",padding:"5px"}})],{style:{justifyContent:"space-between",padding:"0px 5px"}});A.style.setProperty("overflow-y","hidden","important");const I=o.divV([this.defaultGridText,A,this._historyGrid.root],"ui-box");u()(I).removeClass("ui-div"),u()(I).css("width","100%"),this.root.appendChild(this.layout),o.setDisplayAll([this._historyGrid.root,this._historyFilters.root,this.toggleCompactMode,this.trashIcon,this.compareIcon,this.showFiltersIcon],!1);const T=this.onRunsChanged.subscribe(t=>w(this,void 0,void 0,function*(){if(this.setGridCellRendering(),t.size>0){const e=yield(0,b.BV)(t,t.values().next().value.func,this.options),n=t.values().next().value.func;o.setDisplayAll([this.defaultGridText,this.defaultFiltersText],!1),o.setDisplayAll([this._historyGrid.root,this._historyFilters.root,this.toggleCompactMode,this.showMetadataIcon.root,this.trashIcon,this.compareIcon,this.showFiltersIcon],!0),o.setDisplay(this.showInputsIcon.root,(0,b.rs)(n,this.options).length>0),this._onRunsDfChanged.next(e)}else o.setDisplayAll([this.defaultGridText,this.defaultFiltersText],!0),o.setDisplayAll([this._historyGrid.root,this._historyFilters.root,this.showMetadataIcon.root,this.showInputsIcon.root,this.toggleCompactMode,this.trashIcon,this.compareIcon,this.showFiltersIcon],!1)})),E=this._onRunsDfChanged.subscribe(t=>{this._historyFilters.dataFrame=t,this._historyGrid.dataFrame=t,this.currentDf.getCol(h.lv).meta.multiValueSeparator=",",this.styleHistoryGrid(),this.styleHistoryFilters();const e=t.onCurrentRowChanged.subscribe(()=>{var t;this.currentDf.rows.select(()=>!1),this._onChosen.next(null!==(t=this.getRunByIdx(this.currentDf.currentRowIdx))&&void 0!==t?t:null)}),n=t.onSelectionChanged.subscribe(()=>{const e=[...t.selection.getSelectedIndexes()].map(t=>this.getRunByIdx(t));this._onSelectedChanged.next(new Set(e)),this.redrawSelectionState()});this.redrawSelectionState(),this.subs.push(e,n)}),S=this._isFilterHidden.subscribe(t=>{t?(u()(this.showFiltersIcon.firstChild).addClass("fal"),u()(this.showFiltersIcon.firstChild).removeClass("fad"),o.setDisplay(this.filterWithText,!1)):(u()(this.showFiltersIcon.firstChild).addClass("fad"),u()(this.showFiltersIcon.firstChild).removeClass("fal"),u()(this.filterWithText).css(this.compactMode?"height":"width","320px"),u()(this.filterWithText).css(this.compactMode?"width":"height","100%"),o.setDisplay(this.filterWithText,!0))}),x=this._compactMode.subscribe(t=>{const e=[I,this.filterWithText];u()(this.filterWithText).removeClass("ui-div");const n={style:{width:"100%",height:"100%"}};u()(this.toggleCompactMode.firstChild).addClass(t?"fa-expand-alt":"fa-compress-alt"),u()(this.toggleCompactMode.firstChild).removeClass(t?"fa-compress-alt":"fa-expand-alt");const i=t?o.splitV(e,n,!0):o.splitH(e,n,!0);this.layout.replaceWith(i),this.layout=i,o.tools.waitForElementInDom(this.layout).then(t=>{u()(t).css(this.compactMode?"height":"width","100%"),u()(this._historyFilters.root).css(Object.assign({},this.compactMode?{width:"100%"}:{height:"100%"})),u()(this.filterWithText).css(Object.assign({},this.compactMode?{height:"310px",width:"100%"}:{width:"310px",height:"100%"})),u()(I).css(Object.assign({},this.compactMode?{width:"100%"}:{height:"100%"})),setTimeout(()=>{this.styleHistoryGrid(),this.styleHistoryFilters()},100)})});this.subs.push(T,x,E,S)}isFavoriteByIndex(t){return this.currentDf.get(h.iL,t)}setGridCellRendering(){var t,e;(0,b.VI)(this._historyGrid,this.runs,t=>{const e=this.getRunByIdx(t.tableRowIndex);this.showEditDialog(e,this.isFavoriteByIndex(t.tableRowIndex))},t=>{const e=new Set([this.getRunByIdx(t.tableRowIndex)]),n=new y.C(e);n.onFuncCallDelete.pipe((0,d.take)(1)).subscribe(()=>w(this,void 0,void 0,function*(){o.setUpdateIndicator(this.root,!0);try{yield Promise.all(a()(e.values()).map(t=>w(this,void 0,void 0,function*(){return yield this.deleteRun(t.id),Promise.resolve()})))}catch(t){i.shell.error(t)}finally{o.setUpdateIndicator(this.root,!1)}})),n.show({center:!0,width:500})},t=>{const e=this.getRunByIdx(t.tableRowIndex);(0,b.WM)(e,!0).then(()=>this.updateRun(e))},t=>{const e=this.getRunByIdx(t.tableRowIndex);(0,b.WM)(e,!1).then(()=>this.updateRun(e))},null!==(e=null===(t=this.options)||void 0===t?void 0:t.showActions)&&void 0!==e&&e)}deleteRun(t){return w(this,void 0,void 0,function*(){return p.W.loadRun(t,!0).then(t=>w(this,void 0,void 0,function*(){var e;return[yield(null===(e=this.options)||void 0===e?void 0:e.isHistory)?p.W.deleteRun(t):Promise.resolve(),t]})).then(([,e])=>{var n;return this.runs.delete(t),this.onRunsChanged.next(this.runs),(null===(n=this.options)||void 0===n?void 0:n.isHistory)&&this.onDelete.next(e),e}).then(t=>{(0,b.WM)(t,!1)}).catch(t=>{i.shell.error(t)})})}editRun(t){this.showEditDialog(t,!1)}updateRun(t){this.runs.set(t.id,t),this.onRunsChanged.next(this.onRunsChanged.value)}addRun(t){this.runs.set(t.id,t),this.onRunsChanged.next(this.onRunsChanged.value)}updateRuns(t){this.onRunsChanged.next(t.reduce((t,e)=>(t.set(e.id,e),t),new Map))}get isFilterHidden(){return this._isFilterHidden.value}set isFilterHidden(t){this._isFilterHidden.next(t)}get compactMode(){return this._compactMode.value}set compactMode(t){this._compactMode.next(t)}get onCompactModeChanged(){return this._compactMode.asObservable()}styleHistoryGrid(){var t;(0,A.sy)(this._historyGrid,this._compactMode.value,this.showInputsIcon.value,this.showMetadataIcon.value,null===(t=this.runs.values().next().value)||void 0===t?void 0:t.func)}get currentDf(){return this._onRunsDfChanged.value}styleHistoryFilters(){var t,e,n;const i=null===(t=this.runs.values().next().value)||void 0===t?void 0:t.func;(0,A.LL)(this._historyFilters,this.showMetadataIcon.value,this.showInputsIcon.value,null!==(n=null===(e=this.options)||void 0===e?void 0:e.isHistory)&&void 0!==n&&n,i)?(u()(this.filterWithText).css({paddingTop:"10px"}),o.setDisplay(this.defaultFiltersText,!1)):o.setDisplay(this.defaultFiltersText,!0)}redrawSelectionState(){const t=this.currentDf.selection.trueCount;t<2?this.compareIcon.firstChild.classList.add("hp-disabled"):this.compareIcon.firstChild.classList.remove("hp-disabled"),0===t?this.trashIcon.firstChild.classList.add("hp-disabled"):this.trashIcon.firstChild.classList.remove("hp-disabled")}}},5366:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(5516),o=n.n(i),s=n(1364),r=n.n(s)()(o());r.push([t.id,".pipeline-view .d4-ribbon-name.selected {\n color: var(--grey-6)\n}\n\n.pipeline-view .d4-ribbon-name {\n color: var(--blue-1);\n margin: 12px 6px;\n font-weight: normal;\n place-content: center;\n}\n\n.pipeline-view .d4-ribbon-name + .d4-ribbon-name::before {\n color: var(--grey-3);\n}\n\n.pipeline-view .d4-ribbon-name.d4-disabled {\n cursor: default;\n pointer-events: none;\n color: var(--grey-3);\n}\n\n.ui-input-editor button.ui-btn-nav.ui-btn.d4-disabled {\n color: var(--grey-3)\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/old-views/css/pipeline-view.css"],names:[],mappings:"AAAA;EACE;AACF;;AAEA;EACE,oBAAoB;EACpB,gBAAgB;EAChB,mBAAmB;EACnB,qBAAqB;AACvB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,eAAe;EACf,oBAAoB;EACpB,oBAAoB;AACtB;;AAEA;EACE;AACF",sourcesContent:[".pipeline-view .d4-ribbon-name.selected {\n color: var(--grey-6)\n}\n\n.pipeline-view .d4-ribbon-name {\n color: var(--blue-1);\n margin: 12px 6px;\n font-weight: normal;\n place-content: center;\n}\n\n.pipeline-view .d4-ribbon-name + .d4-ribbon-name::before {\n color: var(--grey-3);\n}\n\n.pipeline-view .d4-ribbon-name.d4-disabled {\n cursor: default;\n pointer-events: none;\n color: var(--grey-3);\n}\n\n.ui-input-editor button.ui-btn-nav.ui-btn.d4-disabled {\n color: var(--grey-3)\n}"],sourceRoot:""}]);const a=r},5495:(t,e,n)=>{"use strict";var i;n.d(e,{x:()=>o}),function(t){t[t.K1=.35]="K1",t[t.K2=26.6]="K2",t[t.K3=12300]="K3",t[t.K4=86e-5]="K4",t[t.K5=82e-5]="K5",t[t.K6=15e3]="K6",t[t.K7=13e-5]="K7",t[t.K8=24e3]="K8",t[t.K9=16500]="K9",t[t.K10=9e3]="K10",t[t.K11=.022]="K11",t[t.K12=12e3]="K12",t[t.K13=1.88]="K13",t[t.K14=16300]="K14",t[t.K15=48e5]="K15",t[t.K16=35e-5]="K16",t[t.K17=.0175]="K17",t[t.K18=1e8]="K18",t[t.K19=444e9]="K19",t[t.K20=1240]="K20",t[t.K21=2.1]="K21",t[t.K22=5.78]="K22",t[t.K23=.0474]="K23",t[t.K24=1780]="K24",t[t.K25=3.12]="K25"}(i||(i={}));const o={name:"Pollution",arg:{name:"t",start:0,finish:60,step:.002},initial:[0,.2,0,.04,0,0,.1,.3,.01,0,0,0,0,0,0,0,.007,0,0,0],func:(t,e,n)=>{const o=e[0],s=e[1],r=e[2],a=e[3],l=e[4],u=e[5],c=e[6],d=(e[7],e[8]),p=e[9],h=e[10],f=(e[11],e[12]),m=e[13],v=(e[14],e[15]),g=e[16],y=(e[17],e[18]),b=e[19],A=i.K1*o,w=i.K2*s*a,C=i.K3*l*s,I=i.K4*c,T=i.K5*c,E=i.K6*c*u,S=i.K7*d,x=i.K8*d*u,R=i.K9*h*s,O=i.K10*h*o,N=i.K11*f,F=i.K12*p*s,M=i.K13*m,L=i.K14*o*u,P=i.K15*r,_=i.K16*a,k=i.K17*a,V=i.K18*v,D=i.K19*v,B=i.K20*g*u,$=i.K21*y,U=i.K22*y,j=i.K23*o*a,H=i.K24*y*o,G=i.K25*b;n[0]=-(A+O+L+j+H)+(w+C+R+N+F+U+G),n[1]=-w-C-R-F+A+$,n[2]=-P+A+k+D+U,n[3]=-w-_-k-j+P,n[4]=2*I-C+E+S+M+B,n[5]=-E-x-L-B+C+2*V,n[6]=-I-T-E+M,n[7]=I+T+E+S,n[8]=-S-x,n[9]=-F+S+R,n[10]=-R-O+x+N,n[11]=R,n[12]=-N+O,n[13]=-M+F,n[14]=L,n[15]=-V-D+_,n[16]=-B,n[17]=B,n[18]=-$-U-H+j+G,n[19]=-G+H},tolerance:1e-6,solutionColNames:["y1","y2","y3","y4","y5","y6","y7","y8","y9","y10","y11","y12","y13","y14","y15","y16","y17","y18","y19","y20"]}},5516:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),s="/*# ".concat(o," */");return[e].concat([s]).join("\n")}return[e].join("\n")}},5520:(t,e,n)=>{"use strict";n.d(e,{iu:()=>u,lK:()=>l});var i=n(6082),o=n(1825),s=n(3508),r=n.n(s);const a="_DG_CUSTOM_SERIALIZED_TOKEN_";function l(t,e={}){return JSON.stringify(t,function(t,n){return n===1/0?{[a]:"Infinity",value:!0}:n===-1/0?{[a]:"-Infinity",value:!0}:Number.isNaN(n)?{[a]:"NaN",value:!0}:n instanceof i.DataFrame&&!e.useJsonDF?{[a]:"DataFrame",value:(0,o.SM)(n.toByteArray())}:n instanceof i.DataFrame&&e.useJsonDF?{[a]:"DataFrameJSON",value:n.toJson()}:n instanceof ArrayBuffer?{[a]:"ArrayBuffer",value:(0,o.SM)(new Uint8Array(n))}:n instanceof Map?{[a]:"Map",value:Array.from(n)}:n instanceof Set?{[a]:"Set",value:Array.from(n)}:r().isDayjs(this[t])?{[a]:"DayJs",value:this[t].toISOString()}:n},e.space)}function u(t){return JSON.parse(t,c)}function c(t,e){if(e&&e[a]&&e.value)switch(e[a]){case"DataFrame":return i.DataFrame.fromByteArray((0,o.Fo)(e.value));case"DataFrameJSON":return i.DataFrame.fromJson(JSON.stringify(e.value));case"ArrayBuffer":return(0,o.Fo)(e.value).buffer;case"Map":return new Map(e.value);case"DayJs":return r()(e.value);case"Set":return new Set(e.value);case"Infinity":return 1/0;case"-Infinity":return-1/0;case"NaN":return NaN}return e}},5715:(t,e,n)=>{"use strict";n.d(e,{P:()=>d});var i=n(6082),o=n(4204),s=n(4160),r=n(5342),a=n(241),l=n(7722),u=n(4098),c=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};function d(t){return c(this,arguments,void 0,function*({lossType:t=o.YI.RMSE,func:e,inputBounds:n,outputTargets:c,samplesCount:d,similarity:p,settings:h,reproSettings:f,earlyStoppingSettings:m}){var v,g;const{variedInputNames:y,fixedInputs:b}=(0,l.CN)(n),A=(0,s.I)(t,e,n,c),w=JSON.parse(e.options.fittingSettings||"{}");null!=h||(h=new Map),a.L.forEach((t,e)=>{var n;null==h.get(e)&&h.set(e,null!==(n=w[e])&&void 0!==n?n:t.default)}),d=null!==(v=null!=d?d:w.samplesCount)&&void 0!==v?v:1,p=null!==(g=null!=p?p:w.similarity)&&void 0!==g?g:10;const C=Object.assign(Object.assign(Object.assign({},l.ZY),w),null!=f?f:{}),I=Object.assign(Object.assign(Object.assign({},l.SO),w),null!=m?m:{}),T=yield(0,r.S)({objectiveFunc:A,inputsBounds:n,settings:h,samplesCount:d,reproSettings:C,earlyStoppingSettings:I}),E=T.extremums;E.sort((t,e)=>t.cost-e.cost);const S=(0,l.O3)(e,b,y),x=c.filter(t=>t.type===i.TYPE.DATA_FRAME).map(t=>({name:t.propName,target:t.target,argColName:t.argName})),R=yield(0,u.R9)(E,p,S,x),O=[];for(const t of R){const e=yield S(t.point);O.push(e)}return[T,O]})}},5727:(t,e,n)=>{"use strict";n.d(e,{Ee:()=>s.E,HJ:()=>o.H,bS:()=>r.b,uf:()=>i.u}),n(2244);var i=n(8194),o=n(1059),s=n(873),r=n(6318)},5824:(t,e,n)=>{"use strict";n.d(e,{Y:()=>i});const i={name:"van der Pol",arg:{name:"t",start:0,finish:2e3,step:.1},initial:[-1,1],func:(t,e,n)=>{n[0]=e[1],n[1]=-e[0]+1e3*(1-e[0]*e[0])*e[1]},tolerance:1e-12,solutionColNames:["x1","x2"]}},5909:(t,e,n)=>{"use strict";n.d(e,{a:()=>u});var i,o=n(7389),s=n(1005),r=n(428),a=n(9579),l=n(2917);!function(t){t[t.MIN_WEIGHTS=1]="MIN_WEIGHTS",t[t.MIN_GENS=1]="MIN_GENS",t[t.MIN_NEIG=1]="MIN_NEIG",t[t.MIN_MUT=0]="MIN_MUT",t[t.MAX_MUT=1]="MAX_MUT"}(i||(i={}));class u extends r.T{constructor(t){super(t),this.methodOpts=s.a$}areSettingsValid(){for(const[t,e]of Object.entries(this.methodOpts))if(null==e)return{res:!1,msg:`Invalid value of "${t}" of the MEOA/D method settings`};return this.methodOpts.nWeights<i.MIN_WEIGHTS?{res:!1,msg:'Invalid value of "samples" of the MEOA/D method settings'}:this.methodOpts.generations<i.MIN_GENS?{res:!1,msg:'Invalid value of "generations" of the MEOA/D method settings'}:this.methodOpts.neighbors<i.MIN_NEIG?{res:!1,msg:'Invalid value of "neighbors" of the MEOA/D method settings'}:this.methodOpts.mutationRate<i.MIN_MUT||this.methodOpts.mutationRate>i.MAX_MUT?{res:!1,msg:'Invalid value of "mutation rate" of the MEOA/D method settings'}:{res:!0,msg:""}}getInputs(){return[o.input.int("samples",{value:this.methodOpts.nWeights+1,tooltipText:"The number of points to be computed",nullable:!1,min:i.MIN_WEIGHTS+1,onValueChanged:t=>{this.methodOpts.nWeights=t-1,this.parent.updateApplicabilityState()}}),o.input.int("generations",{value:this.methodOpts.generations,tooltipText:"The total number of iterations",nullable:!1,min:i.MIN_GENS,onValueChanged:t=>{this.methodOpts.generations=t,this.parent.updateApplicabilityState()}}),o.input.int("neighbors",{value:this.methodOpts.neighbors,tooltipText:"The number of neighboring weight vectors considered for mating and replacement",nullable:!1,min:i.MIN_NEIG,onValueChanged:t=>{this.methodOpts.neighbors=t,this.parent.updateApplicabilityState()}}),o.input.float("mutation rate",{value:this.methodOpts.mutationRate,tooltipText:"The probability of mutating a variable in a solution",nullable:!1,min:i.MIN_MUT,max:i.MAX_MUT,onValueChanged:t=>{this.methodOpts.mutationRate=t,this.parent.updateApplicabilityState()}})]}perform(t,e,n,i){return o=this,s=void 0,l=function*(){const o=new a.D(t,e,n,this.methodOpts,i);return yield o.perform()},new((r=void 0)||(r=Promise))(function(t,e){function n(t){try{a(l.next(t))}catch(t){e(t)}}function i(t){try{a(l.throw(t))}catch(t){e(t)}}function a(e){var o;e.done?t(e.value):(o=e.value,o instanceof r?o:new r(function(t){t(o)})).then(n,i)}a((l=l.apply(o,s||[])).next())});var o,s,r,l}visualize(t,e,n,i){return new l.R(t,e,n,i).visualize()}}},5925:(t,e,n)=>{"use strict";function i(t,e){const n=new Array(e),i=t.length,o=Math.floor(i/e);let s=i%e,r=0;for(let i=0;i<e;i++){const e=s>0?1:0;n[i]=t.slice(r,r+o+e),r+=o+e,--s}return n}n.d(e,{d6:()=>i}),n(508)},5940:(t,e,n)=>{"use strict";var i=n(6186),o=n.n(i),s=n(2155),r=n.n(s),a=n(7433),l=n.n(a),u=n(8626),c=n.n(u),d=n(8990),p=n.n(d),h=n(9827),f=n.n(h),m=n(1179),v={};v.styleTagTransform=f(),v.setAttributes=c(),v.insert=l().bind(null,"head"),v.domAPI=r(),v.insertStyleElement=p(),o()(m.A,v),m.A&&m.A.locals&&m.A.locals},6082:t=>{"use strict";t.exports=DG},6124:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(5516),o=n.n(i),s=n(1364),r=n.n(s)()(o());r.push([t.id,".fit-view-inputs-category { \n font-size: 13px;\n font-weight: bold;\n margin-top: 18px;\n padding-right: 5px;\n}\n\n.fit-view-chevron-right {\n padding-right: 10px;\n}\n\n.fit-view-chevron-down {\n padding-right: 5px;\n}\n\n.fit-view-svg-icon { \n height: 24px;\n width: 24px;\n}\n\n.fit-view-help-icon {\n font-size: large;\n margin-right: 8px;\n font-weight: bold;\n}\n\n.fit-view-ribbon-text { \n font-weight: normal;\n margin-left: 2px;\n margin-right: 8px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/function-views/css/fitting-view.css"],names:[],mappings:"AAAA;IACI,eAAe;IACf,iBAAiB;IACjB,gBAAgB;IAChB,kBAAkB;AACtB;;AAEA;IACI,mBAAmB;AACvB;;AAEA;IACI,kBAAkB;AACtB;;AAEA;IACI,YAAY;IACZ,WAAW;AACf;;AAEA;IACI,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;AACrB;;AAEA;IACI,mBAAmB;IACnB,gBAAgB;IAChB,iBAAiB;AACrB",sourcesContent:[".fit-view-inputs-category { \n font-size: 13px;\n font-weight: bold;\n margin-top: 18px;\n padding-right: 5px;\n}\n\n.fit-view-chevron-right {\n padding-right: 10px;\n}\n\n.fit-view-chevron-down {\n padding-right: 5px;\n}\n\n.fit-view-svg-icon { \n height: 24px;\n width: 24px;\n}\n\n.fit-view-help-icon {\n font-size: large;\n margin-right: 8px;\n font-weight: bold;\n}\n\n.fit-view-ribbon-text { \n font-weight: normal;\n margin-left: 2px;\n margin-right: 8px;\n}"],sourceRoot:""}]);const a=r},6126:(t,e,n)=>{"use strict";n.d(e,{A:()=>u});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r);const l=()=>document.querySelector(".d4-balloon-container");class u extends s.JsViewer{constructor(){super()}onFrameAttached(t){this.render()}onTableAttached(){this.render()}render(){if(!this.dataFrame||this.dataFrame.rowCount<=0)return void(this.root.innerHTML="");const t=this.dataFrame,e="isOutlier",n="isOutlierSecondary",r="Rationale",u="Count",c="isConfirmed";t.columns.byName(e)||t.columns.add(s.Column.fromList(s.TYPE.STRING,e,new Array(t.rowCount).fill("Inlier"))),t.columns.byName(n)||t.columns.add(s.Column.fromList(s.TYPE.STRING,n,new Array(t.rowCount).fill("Inlier"))),t.columns.byName(r)||t.columns.add(s.Column.fromStrings(r,Array.from({length:t.rowCount},()=>"")));const d=()=>s.DataFrame.fromColumns([s.Column.fromStrings(r,[]),s.Column.fromInt32Array(u,new Int32Array([])),s.Column.fromStrings("Actions",[]),s.Column.fromBitSet(c,s.BitSet.create(0,()=>!1))]),p=s.Viewer.grid(d());p.root.style.width="100%",p.root.style.minWidth="230px",p.columns.setVisible([r,u,"Actions"]),this.root.append(o.divV([o.divV([p.root],{style:{height:"75%"}})],{style:{height:"100%"}}));const h=()=>{var i,o,u,c,d,h,f;if(!p.dataFrame)return;null===(i=t.col(e))||void 0===i||i.meta.markers.assign("Outlier",s.MARKER_TYPE.OUTLIER),null===(o=t.col(e))||void 0===o||o.meta.markers.assign("Last Inlier",s.MARKER_TYPE.STAR),null===(u=t.col(e))||void 0===u||u.meta.colors.setCategorical({Outlier:s.Color.scatterPlotMarker,Inlier:s.Color.scatterPlotMarker,"Last Inlier":s.Color.red}),null===(c=t.col(n))||void 0===c||c.meta.markers.assign("Outlier",s.MARKER_TYPE.OUTLIER),null===(d=t.col(n))||void 0===d||d.meta.markers.assign("Last Inlier",s.MARKER_TYPE.STAR),null===(h=t.col(n))||void 0===h||h.meta.colors.setCategorical({Outlier:s.Color.cyan,Inlier:s.Color.cyan,"Last Inlier":s.Color.red});const m=null===(f=p.dataFrame)||void 0===f?void 0:f.cell(p.dataFrame.rowCount-1,r).value;t.selection.getSelectedIndexes().forEach(i=>{t.col(e).set(i,"Outlier",!1),t.col(n).set(i,"Outlier",!1),t.col(r).set(i,m,!1)}),t.selection.setAll(!1),t.fireValuesChanged(),a()(l()).empty()},f=()=>{p.dataFrame&&(p.dataFrame.rows.removeAt(p.dataFrame.rowCount-1),t.selection.setAll(!1),a()(l()).empty())};p.onCellPrepare(i=>{var s,a,l;i.isTableCell&&("Actions"===i.gridColumn.name&&(i.gridColumn.cellType="html",i.style.element=o.divH([...(null===(s=i.grid.dataFrame)||void 0===s?void 0:s.get(c,i.gridRow))?[(l=null===(a=i.grid.dataFrame)||void 0===a?void 0:a.get(r,i.gridRow),o.div(o.icons.delete(()=>{for(let i=0;i<t.rowCount;i++)t.columns.byName(r).get(i)===l&&(t.columns.byName(r).set(i,"",!1),t.columns.byName(e).set(i,"Inlier",!1),t.columns.byName(n).set(i,"Inlier",!1));t.fireValuesChanged()},"Remove the outliers group"),{style:{textAlign:"center",margin:"6px"}}))]:[o.div(o.iconFA("check",h,"Confirm the outliers"),{style:{textAlign:"center",margin:"6px"}}),o.div(o.iconFA("times",f,"Cancel the outliers"),{style:{textAlign:"center",margin:"6px"}})]])))}),p.onCellValueEdited.subscribe(e=>{var n,i;if(!p.dataFrame||e.gridColumn.name!==r)return;if(!p.dataFrame.columns.byName(c).get(e.gridRow))return;const o=new Set;for(let t=0;t<(null===(n=p.dataFrame)||void 0===n?void 0:n.rowCount);t++){const e=null===(i=p.dataFrame)||void 0===i?void 0:i.columns.byName(r).get(t);o.add(e)}for(let n=0;n<t.rowCount;n++){const i=t.columns.byName(r).get(n);""==i||o.has(i)||t.columns.byName(r).set(n,e.cell.value)}});const m=()=>{if(t.columns.byName(r))for(let n=0;n<t.rowCount;n++)"Outlier"===t.columns.byName(e).get(n)?""===t.columns.byName(r).get(n)&&t.columns.byName(r).set(n,"Manual",!1):""!==t.columns.byName(r).get(n)&&t.columns.byName(r).set(n,"",!1);const n={};if(t.columns.byName(r))for(let e=0;e<t.rowCount;e++){const i=t.columns.byName(r).get(e),o=n[i];""!=i&&(o?n[i]++:n[i]=1)}p.dataFrame=d(),p.columns.setVisible([r,u,"Actions"]),Object.keys(n).map(t=>{var e;null===(e=p.dataFrame)||void 0===e||e.rows.addNew([t,n[t],"",!0])})};t.onDataChanged.subscribe(m),t.onSelectionChanged.subscribe(()=>{if(!p.dataFrame||!t.selection.trueCount)return;const e=l();if(e&&!a()(e).is(":empty")||i.shell.info(o.div([o.divText("Confirm selected points as outliers?"),o.divH([o.bigButton("Confirm",h),o.button("Cancel",f)])])),p.dataFrame.columns.byName(c).toList().some(t=>!1===t))p.dataFrame.set(u,p.dataFrame.rowCount-1,t.selection.trueCount);else{const e=p.dataFrame.rows.addNew(["Manual",t.selection.trueCount,"",!1]);p.dataFrame.currentCell=p.dataFrame.cell(e.idx,r)}}),t.selection.setAll(!1),m()}}},6186:t=>{"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var s={},r=[],a=0;a<t.length;a++){var l=t[a],u=i.base?l[0]+i.base:l[0],c=s[u]||0,d="".concat(u," ").concat(c);s[u]=c+1;var p=n(d),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)e[p].references++,e[p].updater(h);else{var f=o(h,i);i.byIndex=a,e.splice(a,0,{identifier:d,updater:f,references:1})}r.push(d)}return r}function o(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var s=i(t=t||[],o=o||{});return function(t){t=t||[];for(var r=0;r<s.length;r++){var a=n(s[r]);e[a].references--}for(var l=i(t,o),u=0;u<s.length;u++){var c=n(s[u]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}s=l}}},6267:(t,e,n)=>{"use strict";n.d(e,{L:()=>J});var i=Uint8Array,o=Uint16Array,s=Uint32Array,r=new i([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),a=new i([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),l=new i([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=function(t,e){for(var n=new o(31),i=0;i<31;++i)n[i]=e+=1<<t[i-1];var r=new s(n[30]);for(i=1;i<30;++i)for(var a=n[i];a<n[i+1];++a)r[a]=a-n[i]<<5|i;return[n,r]},c=u(r,2),d=c[0],p=c[1];d[28]=258,p[258]=28;for(var h=u(a,0),f=(h[0],h[1]),m=new o(32768),v=0;v<32768;++v){var g=(43690&v)>>>1|(21845&v)<<1;g=(61680&(g=(52428&g)>>>2|(13107&g)<<2))>>>4|(3855&g)<<4,m[v]=((65280&g)>>>8|(255&g)<<8)>>>1}var y=function(t,e,n){for(var i=t.length,s=0,r=new o(e);s<i;++s)t[s]&&++r[t[s]-1];var a,l=new o(e);for(s=0;s<e;++s)l[s]=l[s-1]+r[s-1]<<1;if(n){a=new o(1<<e);var u=15-e;for(s=0;s<i;++s)if(t[s])for(var c=s<<4|t[s],d=e-t[s],p=l[t[s]-1]++<<d,h=p|(1<<d)-1;p<=h;++p)a[m[p]>>>u]=c}else for(a=new o(i),s=0;s<i;++s)t[s]&&(a[s]=m[l[t[s]-1]++]>>>15-t[s]);return a},b=new i(288);for(v=0;v<144;++v)b[v]=8;for(v=144;v<256;++v)b[v]=9;for(v=256;v<280;++v)b[v]=7;for(v=280;v<288;++v)b[v]=8;var A=new i(32);for(v=0;v<32;++v)A[v]=5;var w=y(b,9,0),C=y(A,5,0),I=function(t){return(t+7)/8|0},T=function(t,e,n){(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length);var r=new(2==t.BYTES_PER_ELEMENT?o:4==t.BYTES_PER_ELEMENT?s:i)(n-e);return r.set(t.subarray(e,n)),r},E=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],S=function(t,e,n){var i=new Error(e||E[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,S),!n)throw i;return i},x=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>>8},R=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>>8,t[i+2]|=n>>>16},O=function(t,e){for(var n=[],s=0;s<t.length;++s)t[s]&&n.push({s,f:t[s]});var r=n.length,a=n.slice();if(!r)return[k,0];if(1==r){var l=new i(n[0].s+1);return l[n[0].s]=1,[l,1]}n.sort(function(t,e){return t.f-e.f}),n.push({s:-1,f:25001});var u=n[0],c=n[1],d=0,p=1,h=2;for(n[0]={s:-1,f:u.f+c.f,l:u,r:c};p!=r-1;)u=n[n[d].f<n[h].f?d++:h++],c=n[d!=p&&n[d].f<n[h].f?d++:h++],n[p++]={s:-1,f:u.f+c.f,l:u,r:c};var f=a[0].s;for(s=1;s<r;++s)a[s].s>f&&(f=a[s].s);var m=new o(f+1),v=N(n[p-1],m,0);if(v>e){s=0;var g=0,y=v-e,b=1<<y;for(a.sort(function(t,e){return m[e.s]-m[t.s]||t.f-e.f});s<r;++s){var A=a[s].s;if(!(m[A]>e))break;g+=b-(1<<v-m[A]),m[A]=e}for(g>>>=y;g>0;){var w=a[s].s;m[w]<e?g-=1<<e-m[w]++-1:++s}for(;s>=0&&g;--s){var C=a[s].s;m[C]==e&&(--m[C],++g)}v=e}return[new i(m),v]},N=function(t,e,n){return-1==t.s?Math.max(N(t.l,e,n+1),N(t.r,e,n+1)):e[t.s]=n},F=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new o(++e),i=0,s=t[0],r=1,a=function(t){n[i++]=t},l=1;l<=e;++l)if(t[l]==s&&l!=e)++r;else{if(!s&&r>2){for(;r>138;r-=138)a(32754);r>2&&(a(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(a(s),--r;r>6;r-=6)a(8304);r>2&&(a(r-3<<5|8208),r=0)}for(;r--;)a(s);r=1,s=t[l]}return[n.subarray(0,i),e]},M=function(t,e){for(var n=0,i=0;i<e.length;++i)n+=t[i]*e[i];return n},L=function(t,e,n){var i=n.length,o=I(e+2);t[o]=255&i,t[o+1]=i>>>8,t[o+2]=255^t[o],t[o+3]=255^t[o+1];for(var s=0;s<i;++s)t[o+s+4]=n[s];return 8*(o+4+i)},P=function(t,e,n,i,s,u,c,d,p,h,f){x(e,f++,n),++s[256];for(var m=O(s,15),v=m[0],g=m[1],I=O(u,15),T=I[0],E=I[1],S=F(v),N=S[0],P=S[1],_=F(T),k=_[0],V=_[1],D=new o(19),B=0;B<N.length;++B)D[31&N[B]]++;for(B=0;B<k.length;++B)D[31&k[B]]++;for(var $=O(D,7),U=$[0],j=$[1],H=19;H>4&&!U[l[H-1]];--H);var G,Y,W,z,q=h+5<<3,K=M(s,b)+M(u,A)+c,J=M(s,v)+M(u,T)+c+14+3*H+M(D,U)+(2*D[16]+3*D[17]+7*D[18]);if(q<=K&&q<=J)return L(e,f,t.subarray(p,p+h));if(x(e,f,1+(J<K)),f+=2,J<K){G=y(v,g,0),Y=v,W=y(T,E,0),z=T;var Z=y(U,j,0);for(x(e,f,P-257),x(e,f+5,V-1),x(e,f+10,H-4),f+=14,B=0;B<H;++B)x(e,f+3*B,U[l[B]]);f+=3*H;for(var X=[N,k],Q=0;Q<2;++Q){var tt=X[Q];for(B=0;B<tt.length;++B){var et=31&tt[B];x(e,f,Z[et]),f+=U[et],et>15&&(x(e,f,tt[B]>>>5&127),f+=tt[B]>>>12)}}}else G=w,Y=b,W=C,z=A;for(B=0;B<d;++B)if(i[B]>255){et=i[B]>>>18&31,R(e,f,G[et+257]),f+=Y[et+257],et>7&&(x(e,f,i[B]>>>23&31),f+=r[et]);var nt=31&i[B];R(e,f,W[nt]),f+=z[nt],nt>3&&(R(e,f,i[B]>>>5&8191),f+=a[nt])}else R(e,f,G[i[B]]),f+=Y[i[B]];return R(e,f,G[256]),f+Y[256]},_=new s([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),k=new i(0),V=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,i=9;--i;)n=(1&n&&-306674912)^n>>>1;t[e]=n}return t}(),D=function(){var t=-1;return{p:function(e){for(var n=t,i=0;i<e.length;++i)n=V[255&n^e[i]]^n>>>8;t=n},d:function(){return~t}}},B=function(t,e,n,l,u){return function(t,e,n,l,u,c){var d=t.length,h=new i(l+d+5*(1+Math.ceil(d/7e3))+u),m=h.subarray(l,h.length-u),v=0;if(!e||d<8)for(var g=0;g<=d;g+=65535){var y=g+65535;y>=d&&(m[v>>3]=c),v=L(m,v+1,t.subarray(g,y))}else{for(var b=_[e-1],A=b>>>13,w=8191&b,C=(1<<n)-1,E=new o(32768),S=new o(C+1),x=Math.ceil(n/3),R=2*x,O=function(e){return(t[e]^t[e+1]<<x^t[e+2]<<R)&C},N=new s(25e3),F=new o(288),M=new o(32),V=0,D=0,B=(g=0,0),$=0,U=0;g<d;++g){var j=O(g),H=32767&g,G=S[j];if(E[H]=G,S[j]=H,$<=g){var Y=d-g;if((V>7e3||B>24576)&&Y>423){v=P(t,m,0,N,F,M,D,B,U,g-U,v),B=V=D=0,U=g;for(var W=0;W<286;++W)F[W]=0;for(W=0;W<30;++W)M[W]=0}var z=2,q=0,K=w,J=H-G&32767;if(Y>2&&j==O(g-J))for(var Z=Math.min(A,Y)-1,X=Math.min(32767,g),Q=Math.min(258,Y);J<=X&&--K&&H!=G;){if(t[g+z]==t[g+z-J]){for(var tt=0;tt<Q&&t[g+tt]==t[g+tt-J];++tt);if(tt>z){if(z=tt,q=J,tt>Z)break;var et=Math.min(J,tt-2),nt=0;for(W=0;W<et;++W){var it=g-J+W+32768&32767,ot=it-E[it]+32768&32767;ot>nt&&(nt=ot,G=it)}}}J+=(H=G)-(G=E[H])+32768&32767}if(q){N[B++]=268435456|p[z]<<18|f[q];var st=31&p[z],rt=31&f[q];D+=r[st]+a[rt],++F[257+st],++M[rt],$=g+z,++V}else N[B++]=t[g],++F[t[g]]}}v=P(t,m,c,N,F,M,D,B,U,g-U,v),!c&&7&v&&(v=L(m,v+1,k))}return T(h,0,l+I(v)+u)}(t,null==e.level?6:e.level,null==e.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,n,l,!u)},$=function(t,e){var n={};for(var i in t)n[i]=t[i];for(var i in e)n[i]=e[i];return n},U=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function j(t,e){return B(t,e||{},0,0)}var H=function(t,e,n,o){for(var s in t){var r=t[s],a=e+s,l=o;Array.isArray(r)&&(l=$(o,r[1]),r=r[0]),r instanceof i?n[a]=[r,l]:(n[a+="/"]=[new i(0),l],H(r,a,n,o))}},G="undefined"!=typeof TextEncoder&&new TextEncoder,Y="undefined"!=typeof TextDecoder&&new TextDecoder;try{Y.decode(k,{stream:!0})}catch(t){}function W(t,e){if(e){for(var n=new i(t.length),o=0;o<t.length;++o)n[o]=t.charCodeAt(o);return n}if(G)return G.encode(t);var s=t.length,r=new i(t.length+(t.length>>1)),a=0,l=function(t){r[a++]=t};for(o=0;o<s;++o){if(a+5>r.length){var u=new i(a+8+(s-o<<1));u.set(r),r=u}var c=t.charCodeAt(o);c<128||e?l(c):c<2048?(l(192|c>>6),l(128|63&c)):c>55295&&c<57344?(l(240|(c=65536+(1047552&c)|1023&t.charCodeAt(++o))>>18),l(128|c>>12&63),l(128|c>>6&63),l(128|63&c)):(l(224|c>>12),l(128|c>>6&63),l(128|63&c))}return T(r,0,a)}var z=function(t){var e=0;if(t)for(var n in t){var i=t[n].length;i>65535&&S(9),e+=i+4}return e},q=function(t,e,n,i,o,s,r,a){var l=i.length,u=n.extra,c=a&&a.length,d=z(u);U(t,e,null!=r?33639248:67324752),e+=4,null!=r&&(t[e++]=20,t[e++]=n.os),t[e]=20,e+=2,t[e++]=n.flag<<1|(s<0&&8),t[e++]=o&&8,t[e++]=255&n.compression,t[e++]=n.compression>>8;var p=new Date(null==n.mtime?Date.now():n.mtime),h=p.getFullYear()-1980;if((h<0||h>119)&&S(10),U(t,e,h<<25|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>>1),e+=4,-1!=s&&(U(t,e,n.crc),U(t,e+4,s<0?-s-2:s),U(t,e+8,n.size)),U(t,e+12,l),U(t,e+14,d),e+=16,null!=r&&(U(t,e,c),U(t,e+6,n.attrs),U(t,e+10,r),e+=14),t.set(i,e),e+=l,d)for(var f in u){var m=u[f],v=m.length;U(t,e,+f),U(t,e+2,v),t.set(m,e+4),e+=4+v}return c&&(t.set(a,e),e+=c),e},K=function(t,e,n,i,o){U(t,e,101010256),U(t,e+8,n),U(t,e+10,n),U(t,e+12,i),U(t,e+16,o)};function J(t,e){e||(e={});var n={},o=[];H(t,"",n,e);var s=0,r=0;for(var a in n){var l=n[a],u=l[0],c=l[1],d=0==c.level?0:8,p=(T=W(a)).length,h=c.comment,f=h&&W(h),m=f&&f.length,v=z(c.extra);p>65535&&S(11);var g=d?j(u,c):u,y=g.length,b=D();b.p(u),o.push($(c,{size:u.length,crc:b.d(),c:g,f:T,m:f,u:p!=a.length||f&&h.length!=m,o:s,compression:d})),s+=30+p+v+y,r+=76+2*(p+v)+(m||0)+y}for(var A=new i(r+22),w=s,C=r-s,I=0;I<o.length;++I){var T=o[I];q(A,T.o,T,T.f,T.u,T.c.length);var E=30+T.f.length+z(T.extra);A.set(T.c,T.o+E),q(A,s,T,T.f,T.u,T.c.length,T.o,T.m),s+=16+E+(T.m?T.m.length:0)}return K(A,s,o.length,C,w),A}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout},6307:(t,e,n)=>{"use strict";n.d(e,{R:()=>l});var i=n(6082),o=n(7149),s=n(500),r=n(4674),a=n(237);class l{constructor(t,e,n,o,s){this.funcCalls=null,this.inputCols=[],this.func=t,this.diffGrok=s,this.funcInputs=e,this.funcCalls=void 0===s?e.map(e=>t.prepare(e)):null,n.forEach(t=>{const n=i.Column.fromList(t.type,t.caption,e.map(e=>e[t.name]));this.inputCols.push(n)}),this.outputsOfInterest=o}perform(){return t=this,e=void 0,i=function*(){let t;if(void 0!==this.diffGrok){const e=new r.D(this.diffGrok,this.funcInputs,this.outputsOfInterest[a.dV]);t=yield e.getResults()}else{if(null===this.funcCalls)throw new Error("Failed Grid analysis: empty list of funccalls");this.funcCalls=yield(0,o.X3)(this.funcCalls),t=(0,s.ex)(this.funcCalls,this.outputsOfInterest).columns.toList()}const e=(0,s.No)(this.inputCols,t);return e.name=`Sensitivity Analysis of ${this.func.friendlyName}`,e},new((n=void 0)||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())});var t,e,n,i}}},6318:(t,e,n)=>{"use strict";n.d(e,{b:()=>h,c:()=>f});var i=n(4328),o=n(5727),s=n(4350),r=n(9713),a=n(1858),l=n(4795),u=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const c=2e4,d=5e3,p=5e3;function h(t,e){return u(this,arguments,void 0,function*(t,e,n={}){var o,s,r;yield m(e,null!==(o=n.initWaitTimeout)&&void 0!==o?o:c),e.disableSetters(!0);try{for(const[i,o]of Object.entries(e.steps)){const a=t[i];if(!a)continue;const l=null!==(r=null===(s=n.stepOptions)||void 0===s?void 0:s[i])&&void 0!==r?r:{},u=l.prefix?`${l.prefix}: ${i}`:i,{updateMode:p}=n,h={validatorsWaitTimeout:d,initWaitTimeout:c,parent:e,interactive:n.interactive,updateMode:p};yield f(a,o.view,Object.assign(Object.assign(Object.assign({},h),l),{prefix:u}))}}finally{e.disableSetters(!1)}n.interactive&&i.shell.info(`${e.name} test passed`)})}function f(t,e){return u(this,arguments,void 0,function*(t,e,n={}){var h;yield m(e,null!==(h=n.initWaitTimeout)&&void 0!==h?h:c);const f=()=>u(this,void 0,void 0,function*(){var t;if(n.parent){const e=null!==(t=n.parentWaitTimeout)&&void 0!==t?t:p,o=yield n.parent.isUpdating.pipe((0,r.map)(()=>n.parent.getRunningUpdates()),(0,r.debounceTime)(100),(0,r.takeUntil)((0,a.of)(null).pipe((0,r.delay)(e))),(0,r.takeWhile)(t=>0!==t.length,!0),(0,r.last)()).toPromise();if(null==o?void 0:o.length){const t=`{options.prefix}: parent updates failed to complete in ${e}ms, updates: ${o.join(",")}`,s=new Error(t);throw n.interactive&&i.shell.error(String(s)),s}}});yield f();for(const[i,o]of Object.entries(t.inputs)){const t=e.funcCall.inputParams[i].property.propertyType;n.updateMode?null==e.funcCall.inputs[i]&&(e.funcCall.inputs[i]=yield(0,l.$X)(t,o)):e.funcCall.inputs[i]=yield(0,l.$X)(t,o)}if(yield f(),yield(()=>u(this,void 0,void 0,function*(){var t;if(e instanceof o.Ee){const o=null!==(t=n.validatorsWaitTimeout)&&void 0!==t?t:d,s=yield e.pendingInputValidations.pipe((0,r.map)(t=>Object.keys(t)),(0,r.debounceTime)(100),(0,r.takeUntil)((0,a.of)(null).pipe((0,r.delay)(o))),(0,r.takeWhile)(()=>!e.isValid(),!0),(0,r.last)()).toPromise();if(null==s?void 0:s.length){const t=`{options.prefix}: validators failed to accept input in ${o}ms, inputs: ${s.join(",")}`,e=new Error(t);throw n.interactive&&i.shell.error(String(e)),e}}}))(),console.log(`running ${e.func.nqName}`),yield e.run(),!n.updateMode){console.log(`checking ${e.func.nqName} results`);try{(0,s.SJ)(e.funcCall.outputs,t.outputs,n),!n.parent&&n.interactive&&i.shell.info(`${e.name} test passed`)}catch(t){throw n.interactive&&i.shell.error(String(t)),t}console.log(`${e.func.nqName} ok`)}})}function m(t,e){return u(this,void 0,void 0,function*(){if(!(yield t.isReady.pipe((0,r.takeUntil)((0,a.of)(null).pipe((0,r.delay)(e))),(0,r.takeWhile)(t=>!t,!0),(0,r.last)()).toPromise()))throw new Error(`Waiting for view ${t.name} timeout`)})}},6566:(t,e,n)=>{"use strict";n.d(e,{e:()=>i});const i={name:"HIRES",arg:{name:"t",start:0,finish:321.8122,step:.01},initial:[1,0,0,0,0,0,0,.0057],func:(t,e,n)=>{const i=e[0],o=e[1],s=e[2],r=e[3],a=e[4],l=e[5],u=e[6],c=e[7];n[0]=-1.71*i+.43*o+8.32*s+7e-4,n[1]=1.71*i-8.75*o,n[2]=-10.03*s+.43*r+.035*a,n[3]=8.32*o+1.71*s-1.12*r,n[4]=-1.745*a+.43*l+.43*u,n[5]=-280*l*c+.69*r+1.71*a-.43*l+.69*u,n[6]=280*l*c-1.81*u,n[7]=-280*l*c+1.81*u},tolerance:1e-10,solutionColNames:["y1","y2","y3","y4","y5","y6","y7","y8"]}},6657:(t,e,n)=>{"use strict";n.d(e,{Bm:()=>d,HU:()=>u,JL:()=>a,PM:()=>c,T$:()=>s,Wt:()=>o,Zf:()=>r,Zg:()=>i,cJ:()=>l});const i=3,o=0,s=.5,r=1e-7,a=1,l=1;var u;!function(t){t.START="_t0",t.FINISH="_t1",t.STEP="_h"}(u||(u={}));const c="_count",d=new Map([[u.START,0],[u.FINISH,1],[u.STEP,2]])},6873:(t,e,n)=>{"use strict";var i=n(3469),o=n(6566),s=n(5824),r=n(4339),a=n(1027),l=n(5495);n(9886),i.L,o.e,s.Y,r.R,a.e5,l.x},6910:(t,e,n)=>{"use strict";n.d(e,{BV:()=>A,Uo:()=>y,VI:()=>v,WM:()=>h,eF:()=>g,qg:()=>f,rs:()=>m,u8:()=>b});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(4260),u=n(3508),c=n.n(u),d=n(1599),p=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const h=(t,e)=>p(void 0,void 0,void 0,function*(){const n=`${l.Jc}_${t.func.name}_Fav`;return e?i.dapi.userDataStorage.postValue(n,t.id,""):i.dapi.userDataStorage.remove(n,t.id)}),f=t=>t.options.mainParams?JSON.parse(t.options.mainParams):null,m=(t,e)=>{var n,i;return null!==(i=null!==(n=null==e?void 0:e.visibleProps)&&void 0!==n?n:f(t))&&void 0!==i?i:t.inputs.filter(t=>l.t6.includes(t.propertyType)).map(t=>t.name)},v=(t,e,n,s,r,u,c)=>{t.onCellPrepare(h=>{var f,m,v,g,y,b,A,w,C,I;if(h.isColHeader&&(null===(f=h.tableColumn)||void 0===f?void 0:f.name)&&[l.zY,l.d1,l.iL].includes(h.tableColumn.name)&&(h.customText=""),!h.isColHeader){if((null===(m=h.tableColumn)||void 0===m?void 0:m.name)===l.zY&&(h.customText="",h.element=o.divH([o.iconFA("trash",()=>s(h),"Remove run from history"),o.iconFA("edit",()=>n(h),"Edit run metadata")],{style:{padding:"6px",gap:"6px",justifyContent:"space-between"}})),(null===(v=h.tableColumn)||void 0===v?void 0:v.name)===l.iL){h.customText="";const t=o.iconFA("star",()=>u(h),"Unfavorite");a()(t).addClass("fas"),h.element=o.div(h.cell.value?t:o.iconFA("star",()=>r(h),"Favorite"),{style:{padding:"6px"}})}if((null===(g=h.tableColumn)||void 0===g?void 0:g.name)===l.d1){h.customText="";const t=o.iconFA("flask",null,"Experimental run");a()(t).addClass("fad fa-sm"),a()(t).removeClass("fal"),h.element=h.cell.value&&"Experimental"===h.cell.value?o.div(t,{style:{padding:"6px"}}):o.div()}if((null===(y=h.tableColumn)||void 0===y?void 0:y.name)===l.lv){h.customText="";const t=h.cell.value.length>0?o.div(null===(b=h.cell.value)||void 0===b?void 0:b.split(",").map(t=>o.span([t],"d4-tag")),"d4-tag-editor"):o.div();a()(t).css({padding:"3px","background-color":"transparent"}),h.element=t}if((null===(A=h.tableColumn)||void 0===A?void 0:A.name)===l.vw){h.customText="";const f=(T=h.tableRowIndex,e.get(t.dataFrame.get(l.vw,T)));if(!f)return;const m=f.author.picture;a()(m).css({width:"25px",height:"25px",fontSize:"20px"}),o.bind(f.author,m);const v=o.iconFA("flask",null,"Experimental run");v.classList.add("fad","fa-sm"),v.classList.remove("fal"),v.style.marginLeft="3px";const g=f.options.immutable_tags,y=o.span([o.label(null!==(I=null!==(w=f.options.title)&&void 0!==w?w:null===(C=f.author)||void 0===C?void 0:C.friendlyName)&&void 0!==I?I:i.shell.user.friendlyName,{style:{color:"var(--blue-1)"}}),...g&&g.includes(l.ec)?[v]:[]]),b=o.iconFA("edit",t=>{t.stopPropagation(),n(h)},"Edit run metadata");b.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const A=o.iconFA("trash-alt",t=>p(void 0,void 0,void 0,function*(){t.stopPropagation(),s(h)}),"Delete run");A.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const E=o.iconFA("star",t=>{t.stopPropagation(),u(h)},"Unfavorite");E.classList.add("fas","hp-funccall-card-icon");const S=o.iconFA("star",t=>{t.stopPropagation(),r(h)},"Favorite");S.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon"),(e=>t.dataFrame.get(l.iL,e))(h.tableRowIndex)?(o.setDisplay(S,!1),o.setDisplay(E,!0)):(o.setDisplay(E,!1),o.setDisplay(S,!0));const x=(0,d.eK)(f),R=o.divH([o.divH([m,o.divV([y,o.span([x]),...f.options.tags&&f.options.tags.length>0?[o.div(f.options.tags.map(t=>o.span([t],"d4-tag")))]:[]],"hp-card-content")]),o.divH([...c?[E,S,b,A]:[]])],"hp-funccall-card"),O=h.tableRowIndex;R.addEventListener("mouseover",()=>{h.grid.dataFrame.mouseOverRowIdx=O}),R.addEventListener("click",t=>{t.shiftKey?h.grid.dataFrame.selection.set(O,!0):t.ctrlKey?h.grid.dataFrame.selection.set(O,!1):h.grid.dataFrame.currentRowIdx=O}),h.element=R}var T}})},g=t=>{const e=t.columns.byName(l.zY);e&&(e.cellType="html",e.width=45);const n=t.columns.byName(l.iL);n&&(n.cellType="html",n.width=30);const i=t.columns.byName(l.d1);i&&(i.cellType="html",i.width=30);const o=t.columns.byName(l.lv);o&&(o.cellType="html",o.width=90);const s=t.columns.byName(l.bV);s&&(s.width=110);const r=t.columns.byName(l.vw);r&&(r.cellType="html")},y=t=>t.replace(/([A-Z])/g,t=>` ${t.toLowerCase()}`).trim().replace(/^./,t=>t.toUpperCase()),b=(t,e)=>{var n,i,o,s,r,a,u;if(e===l.l8)return null!==(i=null===(n=t.author)||void 0===n?void 0:n.friendlyName)&&void 0!==i?i:" ";const c=null!==(a=null!==(r=null!==(s=null!==(o=t[e])&&void 0!==o?o:t.inputs[e])&&void 0!==s?s:t.outputs[e])&&void 0!==r?r:t.options[e])&&void 0!==a?a:null;return null!==(u=null==c?void 0:c.toString())&&void 0!==u?u:""},A=(t,e,n)=>p(void 0,void 0,void 0,function*(){var o;const r=[...t.values()],a=t=>t===l.bV?s.Column.dateTime(y(t),r.length).init(t=>window.grok_DayJs_To_DateTime((0,d.Yj)(r[t])?r[t].started.utc(!0):c().unix(r[t].options.createdOn))):t===l.pC?s.Column.bool(y(t),r.length).init(t=>!(0,d.Ne)(r[t])):s.Column.fromStrings(y(t),r.map(e=>{var i,o,s;return null!==(s=null===(o=null===(i=null==n?void 0:n.propFuncs)||void 0===i?void 0:i[t])||void 0===o?void 0:o.call(i,e))&&void 0!==s?s:b(e,t)})),u=null!==(o=yield i.dapi.userDataStorage.get((t=>`${l.Jc}_${t.name}_Fav`)(e)))&&void 0!==o?o:{},p=Object.keys(u),h=s.DataFrame.fromColumns([s.Column.string(l.d1,r.length).init(t=>{const e=r[t].options.immutable_tags;return e&&e.includes(l.ec)?"Experimental":"Simulated"}),...(null==n?void 0:n.isHistory)?[s.Column.bool(l.iL,r.length).init(t=>p.includes(r[t].id))]:[],...(null==n?void 0:n.showActions)?[s.Column.string(l.zY,r.length).init("")]:[],a(l.bV),a(l.pC),a(l.l8),s.Column.string(l.lv,r.length).init(t=>r[t].options.tags?r[t].options.tags.join(","):""),s.Column.string(l.qh,r.length).init(t=>r[t].options.title),s.Column.string(l.Ts,r.length).init(t=>r[t].options.description),s.Column.string(l.aQ,r.length).init(t=>r[t].options.version)]);if(m(e).map(t=>(t=>{var i;const o=null!==(i=e.inputs.find(e=>e.name===t))&&void 0!==i?i:e.outputs.find(e=>e.name===t);return o?(t=>{var e,i;return t.propertyType===s.TYPE.DATE_TIME?s.Column.dateTime(null!==(e=t.caption)&&void 0!==e?e:y(t.name),r.length).init(e=>window.grok_DayJs_To_DateTime(r[e].inputs[t.name])):s.Column.fromType(t.propertyType,null!==(i=t.caption)&&void 0!==i?i:y(t.name),r.length).init(e=>{var i,o,s;return null!==(s=null===(o=null===(i=null==n?void 0:n.propFuncs)||void 0===i?void 0:i[t.name])||void 0===o?void 0:o.call(i,r[e]))&&void 0!==s?s:b(r[e],t.name)})})(o):a(t)})(t)).forEach(t=>{t.name=h.columns.getUnusedName(t.name),h.columns.add(t,!1)}),h.columns.add(s.Column.fromStrings(l.vw,r.map(t=>t.id))),!(null==n?void 0:n.allowOtherVersions)&&(null==n?void 0:n.version)){const t=s.BitSet.create(h.rowCount,()=>!1);for(let e=0;e<h.rowCount;e++)(null==n?void 0:n.version)==h.get(l.aQ,e)&&t.set(e,!0);return h.clone(t)}return h})},6998:(t,e,n)=>{"use strict";var i=n(6186),o=n.n(i),s=n(2155),r=n.n(s),a=n(7433),l=n.n(a),u=n(8626),c=n.n(u),d=n(8990),p=n.n(d),h=n(9827),f=n.n(h),m=n(3775),v={};v.styleTagTransform=f(),v.setAttributes=c(),v.insert=l().bind(null,"head"),v.domAPI=r(),v.insertStyleElement=p(),o()(m.A,v),m.A&&m.A.locals&&m.A.locals},7011:(t,e,n)=>{"use strict";n.d(e,{OW:()=>r,Un:()=>a,dq:()=>i,fK:()=>s,j2:()=>o});const i=-10,o=1,s=2;var r;!function(t){t[t.SUCCEED=0]="SUCCEED",t[t.FAILED=1]="FAILED"}(r||(r={}));const a="Success"},7109:(t,e,n)=>{"use strict";n.d(e,{b:()=>c});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=n(5092),l=(n(8550),n(5355)),u=n(9713);class c extends s.Widget{get type(){return"HistoryPanel"}updateHistoryPane(t){this.historyList.updateRuns(t)}showEditDialog(t){this.historyList.editRun(t)}addRun(t){this.historyList.addRun(t)}get history(){return this.historyList.runs}get onCompactModeChanged(){return this.historyList.onCompactModeChanged}get compactMode(){return this.historyList.compactMode}constructor(t){super(o.box(o.divText("No historical runs loaded","hp-no-elements-label"),{style:{width:"100%",height:"100%"}})),this.func=t,this.onRunChosen=new r.Subject,this.onComparison=new r.Subject,this.afterRunEdited=new r.Subject,this.afterRunDeleted=new r.Subject,this.allRunsFetch=new r.Subject,this.historyList=new l.H([],{fallbackText:"No runs are found in history",showActions:!0,showBatchActions:!0,isHistory:!0}),this.panel=this.historyList.root;const e=this.historyList.onChosen.pipe((0,u.filter)(t=>!!t)).subscribe(t=>this.onRunChosen.next(t.id)),n=this.historyList.onComparisonCalled.subscribe(t=>this.onComparison.next(t)),s=this.allRunsFetch.subscribe(()=>{return t=this,e=void 0,s=function*(){o.setUpdateIndicator(this.root,!0),a.W.pullRunsByName(this.func.name,[{author:i.shell.user}],{},["session.user","options"]).then(t=>{o.empty(this.root),this.root.appendChild(this.panel),this.updateHistoryPane(t)}).catch(t=>i.shell.error(t)).finally(()=>o.setUpdateIndicator(this.root,!1))},new((n=void 0)||(n=Promise))(function(i,o){function r(t){try{l(s.next(t))}catch(t){o(t)}}function a(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((s=s.apply(t,e||[])).next())});var t,e,n,s}),c=this.historyList.onMetadataEdit.subscribe(t=>{this.afterRunEdited.next(t)}),d=this.historyList.onDelete.subscribe(t=>{this.afterRunDeleted.next(t)});this.subs.push(e,s,c,n,d),this.allRunsFetch.next()}}},7149:(t,e,n)=>{"use strict";n.d(e,{C1:()=>c,VW:()=>p,X3:()=>d});var i,o,s=n(7389),r=n(6082),a=n(237),l=(n(8870),function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})});!function(t){t.INCORRECT_SIZE_TYPE="Size must be an integer.",t.SIZE_MUST_BE_POSITIVE="Size must be positive."}(i||(i={})),function(t){t[t.BATCH_SIZE=100]="BATCH_SIZE",t[t.MS_TO_SLEEP=10]="MS_TO_SLEEP"}(o||(o={}));const u=t=>new Promise((e,n)=>setTimeout(e,t));function c(t){if(!Number.isInteger(t))throw new Error(i.INCORRECT_SIZE_TYPE);if(t<1)throw new Error(i.SIZE_MUST_BE_POSITIVE)}function d(t){return l(this,void 0,void 0,function*(){const e=[],n=r.TaskBarProgressIndicator.create("Analyzing...");n.cancelable=!0;let i=0;const s=t.length;let a=0;for(let r=0;r<s&&(e.push(yield t[r].call(void 0,void 0,{processed:!0,report:!1})),1===r&&(a=Math.floor(100*r/s),n.update(a,`Analyzing... (${a}%)`),yield u(10*o.MS_TO_SLEEP)),++i,!n.canceled);++r)i>=o.BATCH_SIZE&&(a=Math.floor(100*r/s),n.update(a,`Analyzing... (${a}%)`),yield u(o.MS_TO_SLEEP),i=0);return n.close(),e})}function p(){const t=s.icons.help(()=>window.open(a.be,"_blank"),"Open help in a new tab");return t.classList.add("sensitivity-analysis-help-icon"),t}},7320:(t,e,n)=>{"use strict";n.d(e,{t:()=>p});var i=n(6082),o=n(508),s=n(4204),r=n(8384),a=n(7395),l=n(5925),u=n(7722),c=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};function d(t,e){const n=t.length;if(n>0){const o=t[0].length,s=new Array(o);for(let t=0;t<o;++t)s[t]=new Float64Array(n);t.forEach((t,e)=>t.forEach((t,n)=>s[n][e]=t));const r=i.DataFrame.fromColumns(s.map((t,e)=>i.Column.fromFloat64Array(`arg${e}`,t)));return r.columns.add(i.Column.fromStrings("Issue",e)),r}return null}function p(t,e,p,h,f,m,v,g,y,b,A,w,C,I,T){return c(this,void 0,void 0,function*(){var c;const E=[...f.keys()],S=E.map(t=>{var e;return null!==(e=f.get(t))&&void 0!==e?e:r.PJ}),x=Object.keys(y),R=Object.values(y),O=w.columns,N=A.length+1,F=w.rowCount;if(N<r.Pd)throw new Error(`Not enough of target columns: ${N}. Minimum: ${r.Pd}`);const M=[b].concat(A.map(t=>t.name)),L=new Float64Array(N),P=M.map((t,e)=>{const n=O.byName(t),i=Math.max(Math.abs(n.stats.max),Math.abs(n.stats.min));L[e]=i>0?i:1;const o=new Float64Array(F),s=n.getRawData();for(let t=0;t<F;++t)o[t]=s[t];return o}),_=[`_${e.arg.name}0`,`_${e.arg.name}1`,"_h"].concat(e.deqs.solutionNames),k=I.reproducible?(0,u.Is)(I.seed):Math.random,V=(0,a.BE)(C,v,g,k),D=Math.min(Math.max(r.j2,navigator.hardwareConcurrency-r.fK),C),B=new Array(D).fill(null).map(t=>new Worker(new URL(n.p+n.u(148),n.b)));let $=[];const U=[],j=[],H=(0,l.d6)(V,D),G=function(t,e,n,i,s){const r={};return Object.entries(i).forEach(([t,e])=>r[t]=e),t.forEach((t,i)=>r[t]=(e[i]+n[i])/2),(0,o.S3)(r,s)}(m,v,g,y,e),Y=h.getPipeline(G);let W=0,z=0;const q=i.TaskBarProgressIndicator.create(`Fitting... (${z}%)`),K=B.map((n,i)=>new Promise((s,a)=>{n.postMessage({task:{settingNames:E,settingVals:S,loss:t,ivp2ww:p,pipeline:Y,nonParamNames:_,fixedInputsNames:x,fixedInputsVals:R,variedInputNames:m,variedInpMin:v,variedInpMax:g,targetNames:M,targetVals:P,scaleVals:L,samplesCount:C,outputNames:(0,o.AK)(e),earlyStoppingSettings:T},startPoints:H[i]}),n.onmessage=t=>{var e;n.terminate(),++W,z=Math.floor(100*(W+1)/D),z<99.9?q.update(z,`Fitting... (${z}%)`):q.update(z,"Fitting... (100%)"),t.data.callResult===r.OW.SUCCEED?(t.data.extremums.forEach(t=>$.push(t)),t.data.fitRes.forEach((t,e)=>{t!==r.Un&&(U.push(H[i][e]),j.push(t))}),s()):a(null!==(e=t.data.msg)&&void 0!==e?e:"error in webworker fitting")},n.onerror=t=>{n.terminate(),console.error(t),a(t)}}));if(yield Promise.all(K),q.close(),T.useEarlyStopping){const t=null!==(c=T.stopAfter)&&void 0!==c?c:s.eJ;$.length>t&&($.sort((t,e)=>t.cost-e.cost),$=$.slice(0,t))}return{extremums:$,fails:d(U,j)}})}},7375:(t,e,n)=>{"use strict";function i(t){return t&&t.root&&t.onInput}function o(t){return(null==t?void 0:t.setValidation)&&i(t)}function s(t){return(null==t?void 0:t.setDisabled)&&(null==t?void 0:t.setRestricted)&&(null==t?void 0:t.setRestrictedUnlocked)&&(null==t?void 0:t.setInconsistent)&&(null==t?void 0:t.setUserInput)&&i(t)}n.d(e,{LB:()=>o,gD:()=>s})},7376:(t,e,n)=>{"use strict";var i=n(6186),o=n.n(i),s=n(2155),r=n.n(s),a=n(7433),l=n.n(a),u=n(8626),c=n.n(u),d=n(8990),p=n.n(d),h=n(9827),f=n.n(h),m=n(847),v={};v.styleTagTransform=f(),v.setAttributes=c(),v.insert=l().bind(null,"head"),v.domAPI=r(),v.insertStyleElement=p(),o()(m.A,v),m.A&&m.A.locals&&m.A.locals},7389:t=>{"use strict";t.exports=ui},7395:(t,e,n)=>{"use strict";n.d(e,{BE:()=>s,Pn:()=>u,qc:()=>c});var i=n(4353);function o(t,e,n,i=Math.random){const o=e-n,s=new Array(t);for(let e=0;e<t;e++){const t=i();s[e]=n+t*o}return s}function s(t,e,n,i=Math.random){const s=e.length,r=new Array(t);for(let e=0;e<t;e++)r[e]=new Float64Array(s);for(let a=0;a<s;a++)if(e[a]===n[a])for(let n=0;n<t;n++)r[n][a]=e[a];else{const s=o(t,e[a],n[a],i);for(let e=0;e<t;e++)r[e][a]=s[e]}return r}function r(t){return Object.entries(t).reduce((t,[e,n])=>("const"===n.type?t.constValues.push([e,n]):"value"===n.top.type&&"value"===n.bottom.type?(t.nonFormulaBounds.push([e,t.boundsIdx,n]),t.boundsIdx++):(t.formulaBounds.push([e,t.boundsIdx,n]),t.boundsIdx++),t),{constValues:[],nonFormulaBounds:[],formulaBounds:[],boundsIdx:0})}function a(t){const e={};for(const[n,i]of t)e[n]=i.value;return e}function l(t,e){return(0,i.G)(t.formula,e)}function u(t,e){const n=new Map(e.map((t,e)=>[t,e])),{constValues:i,nonFormulaBounds:o,formulaBounds:s}=r(t),u=a(i);return function(t){const e=Object.assign({},u);for(const[i,,r]of[...o,...s]){const o=t[n.get(i)],s="value"===r.bottom.type?r.bottom.value:l(r.bottom,e),a="value"===r.top.type?r.top.value:l(r.top,e);if(null==a||null==s||null==o||s>a||o<s||o>a)return!1;e[i]=o}return!0}}function c(t,e,n=Math.random){const{constValues:i,nonFormulaBounds:o,formulaBounds:s}=r(e),u=o.length+s.length,c=new Array(t).fill(null).map(()=>new Float64Array(u)),d=a(i);for(let e=0;e<t;e++){const t=Object.assign({},d);for(const[i,r,a]of[...o,...s]){const o="value"===a.bottom.type?a.bottom.value:l(a.bottom,t),s="value"===a.top.type?a.top.value:l(a.top,t);if(null==o||null==s||o>s){const t=`Sampling staring point failed for input ${i}, min: ${o}, max: ${s}`;throw console.error(t),new Error(t)}const u=o+n()*(s-o);c[e][r]=u,t[i]=u}}return c}},7423:(t,e,n)=>{"use strict";Error},7433:t=>{"use strict";var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},7591:(t,e,n)=>{"use strict";n.d(e,{N:()=>r});var i=n(6082),o=n(4204),s=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class r{constructor(t){this.isDataValid=this.validate(t),this.isDataValid?(this.table=t.clone(),this.prepareTable()):this.table=t}getRoot(){return s(this,void 0,void 0,function*(){return yield this.getViewerRoot()})}getViewerRoot(){return s(this,void 0,void 0,function*(){return this.isDataValid?(yield this.table.plot.fromType("Radar",{colorColumnName:o.o_.CATEGORY,currentRowColor:i.Color.categoricalPalette[o.Wr.LIGHT_GREY],showValue:!0,resizeScheduled:!0})).root:i.Viewer.grid(this.table).root})}validate(t){const e=t.columns,n=e.length;if(n<o.Uk)return console.log(`Incorrect number of column for radar viewer: ${n}. Expected: > ${o.Uk-1}`),!1;const s=e.byIndex(n-1).type;if(s!==i.COLUMN_TYPE.STRING)return console.log(`Incorrect category column type of a table for radar viewer: ${s}. Expected: ${i.COLUMN_TYPE.STRING}`),!1;for(let t=0;t<n-2;++t){const n=e.byIndex(t);if(!n.isNumerical)return console.log(`Incorrect values column '${n.name}' of a table for radar viewer: ${n.type}. Expected: numerical`),!1}return!0}prepareTable(){const t=this.table.col(o.o_.CATEGORY);null!==t&&t.colors.setCategorical({Simulation:i.Color.categoricalPalette[o.Wr.BLUE],Target:i.Color.categoricalPalette[o.Wr.ORANGE]})}}},7600:(t,e,n)=>{"use strict";n.d(e,{o:()=>u});var i=n(6082),o=n(9070),s=n(7149),r=n(500),a=n(4674),l=n(237);class u{constructor(t,e,n,i,r,a){this.funcCalls=null,(0,s.C1)(r),this.samplesCount=r,this.fixedInputs=e,this.func=t;const l=(0,o.h)(r,n);this.dimension=n.length,this.variedInputs=[...Array(this.dimension).keys()].map(t=>({prop:n[t].prop,min:n[t].min,max:n[t].max,column:l[t]})),this.runsCount=r*(this.dimension+2),this.funcCalls=void 0===a?[]:null,this.funcInputs=[];for(let n=0;n<this.runsCount;++n){const i={};for(const t of e)i[t.name]=t.value;for(const t of this.variedInputs)i[t.prop.name]=t.column.get(n);null!==this.funcCalls&&this.funcCalls.push(t.prepare(i)),this.funcInputs.push(i)}this.diffGrok=a,this.outputsOfInterest=i}getSobolIndeces(t){const e=this.dimension,n=this.samplesCount,o=new Float32Array(e),s=new Float32Array(e),r=t.getRawData(),a=2*n;let l=0,u=0;for(let t=0;t<a;++t)l+=r[t],u+=r[t]*r[t];const c=l/a,d=u/a-c*c;if(0===d)o.fill(0),s.fill(0);else for(let t=0;t<e;++t){let e=0,i=0,a=0;for(let o=0;o<n;++o)a=r[(2+t)*n+o]-r[o],e+=r[n+o]*a,i+=a*a;o[t]=e/(n*d),s[t]=i/(2*n*d)}return{firstOrder:i.Column.fromFloat32Array(t.name,o),totalOrder:i.Column.fromFloat32Array(t.name,s)}}perform(){return t=this,e=void 0,o=function*(){const t=this.variedInputs.map(t=>t.column);let e;if(void 0!==this.diffGrok){const t=new a.D(this.diffGrok,this.funcInputs,this.outputsOfInterest[l.dV]);e=yield t.getResults()}else{if(null===this.funcCalls)throw new Error("Failed Sobol analysis: empty list of funccalls");this.funcCalls=yield(0,s.X3)(this.funcCalls),e=(0,r.ex)(this.funcCalls,this.outputsOfInterest).columns.toList()}const n=(0,r.No)(t,e);n.name=`Sensitivity Analysis of ${this.func.friendlyName}`;const o=e.map(t=>this.getSobolIndeces(t)),u=i.Column.fromStrings("input",t.map(t=>t.name)),c=[u],d=[u];for(const t of o)c.push(t.firstOrder),d.push(t.totalOrder);const p=i.DataFrame.fromColumns(c);p.name="First order Sobol' indices";const h=i.DataFrame.fromColumns(d);return h.name="Total order Sobol' indices",{funcEvalResults:n,funcInputs:this.funcInputs,firstOrderSobolIndices:p,totalOrderSobolIndices:h}},new((n=void 0)||(n=Promise))(function(i,s){function r(t){try{l(o.next(t))}catch(t){s(t)}}function a(t){try{l(o.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((o=o.apply(t,e||[])).next())});var t,e,n,o}}},7722:(t,e,n)=>{"use strict";n.d(e,{Aj:()=>S,CN:()=>d,FB:()=>p,Is:()=>T,J1:()=>R,LC:()=>v,MP:()=>m,O3:()=>c,QR:()=>C,SO:()=>x,VW:()=>f,Yl:()=>u,ZY:()=>E,e_:()=>y,gw:()=>h,hk:()=>g,ru:()=>A,uM:()=>w,zx:()=>I});var i=n(4328),o=n(7389),s=n(6082),r=n(5255),a=(n(9530),n(8870),n(4204)),l=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};function u(t,e,n,i){if(null===t)throw new r.NZ("no argument column in the target output dataframe");const o=t.name,s=n.col(o);if(null===s)throw new r.NZ(`no "${o}" column in the output dataframe "${n.name}"`);const a=function(t,e){const n=t.getRawData(),i=e.getRawData(),o=e.length,s=Math.min(t.length,o),r=new Uint32Array(s);let a=0,l=0,u=0;for(let t=0;t<s;++t){for(;;){if(l=Math.abs(i[a]-n[t]),++a,!(a<o)){--a;break}if(u=Math.abs(i[a]-n[t]),u>l){--a;break}l=u}r[t]=a}return r}(t,s),l=e.length,u=new Float32Array(l*a.length);let c=0;for(let t=0;t<l;++t){const o=e[t],s=n.col(o.name);if(null===s)throw new r.NZ(`no "${o.name}" column in the output dataframe "${n.name}"`);const l=s.getRawData(),d=o.getRawData();if(i){const t=Math.max(Math.abs(o.stats.max),Math.abs(o.stats.min)),e=t>0?t:1;a.forEach((t,n)=>{u[c]=(l[t]-d[n])/e,++c})}else a.forEach((t,e)=>{u[c]=l[t]-d[e],++c})}return u}function c(t,e,n){const i=t.prepare(e);return function(t){return l(this,void 0,void 0,function*(){return(()=>{for(const t of i.inputParams.values())i.inputs[t.name]=e[t.name];for(const t of i.outputParams.values())i.outputs[t.name]=void 0})(),t.forEach((t,e)=>i.inputs[n[e]]=t),i.call(void 0,void 0,{processed:!0,report:!1})})}}function d(t){const e=[],n={};for(const[i,o]of Object.entries(t))"const"===o.type?n[i]=o.value:e.push(i);return{variedInputNames:e,fixedInputs:n}}function p(t,e,n){const i=i=>{s.hidden=i,r.hidden=!i,e.forEach(e=>n?n(e,i,t):e.hidden=!i)},s=o.iconFA("chevron-right",()=>i(!0),"Open category");s.classList.add("fit-view-chevron-right"),s.hidden=!0;const r=o.iconFA("chevron-down",()=>i(!1),"Close category");return r.classList.add("fit-view-chevron-down"),o.divH([s,r,o.label(t)],"fit-view-inputs-category")}function h(t,e){let n,s,r=!1;const l=`# **${e}**\n\n${a.nW}`,u=o.icons.info(()=>{r?(r=!1,n.remove()):(r=!0,n=o.hints.addHint(t,o.markdown(l),o.hints.POSITION.RIGHT),function(t){const e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}(n)||(n.remove(),n=o.hints.addHint(t,o.markdown(l),o.hints.POSITION.TOP)),s=n.querySelector("i"),s.onclick=()=>r=!1,i.shell.v.root.appendChild(n))},"Click to see details");return u.classList.add("sa-switch-input"),u}function f(){const t=o.icons.help(()=>window.open(a.be,"_blank"),"Open help in a new tab");return t.classList.add("fit-view-help-icon"),t}function m(){const t="http://www.w3.org/2000/svg",e=document.createElementNS(t,"svg");e.setAttribute("width","24"),e.setAttribute("height","24"),e.setAttribute("viewBox","0 0 24 24");const n=(t,e)=>{e.forEach((e,n)=>{t.setAttribute(n,e)})},i=document.createElementNS(t,"path");n(i,new Map([["d","M3 4 Q12 28, 20 4"],["stroke","#40607F"],["stroke-width","1"],["fill","none"]]));const s=document.createElementNS(t,"circle");n(s,new Map([["cx","19"],["cy","6"],["r","1.5"],["fill","#40607F"]]));const r=document.createElementNS(t,"circle");n(r,new Map([["cx","3"],["cy","10"],["r","1.5"],["fill","#40607F"]]));const a=document.createElementNS(t,"circle");n(a,new Map([["cx","10"],["cy","11"],["r","1.5"],["fill","#40607F"]]));const l=document.createElementNS(t,"circle");n(l,new Map([["cx","17"],["cy","16"],["r","1.5"],["fill","#40607F"]])),[i,s,r,a,l].forEach(t=>e.appendChild(t));const u=o.span(["Fit"]);u.classList.add("fit-view-ribbon-text"),e.classList.add("fit-view-svg-icon");const c=o.div([e,u]);return o.tooltip.bind(c,"Fit parameters. Opens a separate view"),c}function v(){const t="http://www.w3.org/2000/svg",e=document.createElementNS(t,"svg");e.setAttribute("width","24"),e.setAttribute("height","24"),e.setAttribute("viewBox","0 0 24 24");const n=document.createElementNS(t,"path");n.setAttribute("d","M5 5.5L5 16.5C5 17.3438 5.65625 18 6.5 18H19.5C19.75 18 20 18.25 20 18.5C20 18.7813 19.75 19 19.5 19H6.5C5.09375 19 4 17.9063 4 16.5L4 5.5C4 5.25 4.21875 5 4.5 5C4.75 5 5 5.25 5 5.5ZM15.5 7C15.2188 7 15 6.78125 15 6.5C15 6.25 15.2188 6 15.5 6L18.5 6C18.75 6 19 6.25 19 6.5V9.5C19 9.78125 18.75 10 18.5 10C18.2188 10 18 9.78125 18 9.5V7.71875L13.3438 12.375C13.1562 12.5625 12.8125 12.5625 12.625 12.375L10.5 10.2188L7.84375 12.875C7.65625 13.0625 7.3125 13.0625 7.125 12.875C6.9375 12.6875 6.9375 12.3438 7.125 12.1563L10.125 9.15625C10.2188 9.0625 10.3438 9 10.5 9C10.625 9 10.75 9.0625 10.8438 9.15625L13 11.3125L17.2812 7L15.5 7ZM15.5 16C15.2188 16 15 15.7813 15 15.5C15 15.25 15.2188 15 15.5 15H17.2812L15.125 12.875L15.8438 12.1563L18 14.3125V12.5C18 12.25 18.2188 12 18.5 12C18.75 12 19 12.25 19 12.5V15.5C19 15.7813 18.75 16 18.5 16H15.5Z"),n.setAttribute("fill","#40607F"),e.appendChild(n);const i=o.span(["Sensitivity"]);i.classList.add("fit-view-ribbon-text"),e.classList.add("sensitivity-analysis-svg-icon");const s=o.div([e,i]);return o.tooltip.bind(s,"Run sensitivity analysis. Opens a separate view"),s}function g(){const t=o.span(["Optimize"]);t.classList.add("fit-view-ribbon-text");const e=o.iconFA("arrow-up"),n=o.div([e,t]);return o.tooltip.bind(n,"Run optimization. Opens a separate view"),n}function y(t){return s.DataFrame.fromColumns([s.Column.fromList(s.COLUMN_TYPE.INT,a.ly.ITER,[...Array(t.iterCount).keys()].map(t=>t+1)),s.Column.fromList(s.COLUMN_TYPE.FLOAT,a.ly.LOSS,t.iterCosts.slice(0,t.iterCount))])}function b(t){const e=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!e)throw new Error("Invalid RGB format. Expected format: 'rgb(r, g, b)'");const n=parseInt(e[1],10),i=parseInt(e[2],10),o=parseInt(e[3],10),s=t=>t.toString(16).padStart(2,"0");return`#${s(n)}${s(i)}${s(o)}`}function A(t,e){const n=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!n)throw new Error("Invalid RGB format. Expected format: 'rgb(r, g, b)'");const i=parseInt(n[1],10),o=parseInt(n[2],10),s=parseInt(n[3],10),r=t=>Math.min(255,Math.round(t+e/100*(255-t)));return`rgb(${r(i)}, ${r(o)}, ${r(s)})`}function w(t){const e=t.columns,n=e.length;if(n<2)throw new Error(`Incorrect scalars fit table. Columns: ${n}, expected: > 1`);switch(n){case 2:return s.Viewer.barChart(t,function(t,e){return{showValueAxis:!1,showStackSelector:!1,showCategorySelector:!1,valueColumnName:t,splitColumnName:e,colorColumnName:t,colorAggrType:s.AGG.AVG,linearColorScheme:[s.Color.categoricalPalette[a.Wr.LIGHT_OLIVE],s.Color.categoricalPalette[a.Wr.OLIVE]],valueAggrType:s.AGG.AVG,showValueSelector:!1,barSortType:"by category"}}(e.byIndex(a.Wr.SINGLE_VAL).name,e.byIndex(a.Wr.SINGLE_CAT).name)).root;case 3:const n=e.byIndex(a.Wr.DOUBLE_CAT).name,i=s.Viewer.barChart(t,function(t,e){return{showValueAxis:!1,showStackSelector:!1,showCategorySelector:!1,valueColumnName:t,splitColumnName:e,colorColumnName:t,colorAggrType:s.AGG.AVG,linearColorScheme:[s.Color.categoricalPalette[a.Wr.LIGHT_OLIVE],s.Color.categoricalPalette[a.Wr.OLIVE]],valueAggrType:s.AGG.AVG,showValueSelector:!1,description:t,descriptionVisibilityMode:"Always",maxBarHeight:a.VF.BAR_HEIGHT,barSortType:"by category"}}(e.byIndex(a.Wr.DOUBLE_VAL1).name,n)).root,r=s.Viewer.barChart(t,function(t,e){return{showValueAxis:!1,showStackSelector:!1,showCategorySelector:!1,valueColumnName:t,splitColumnName:e,colorColumnName:t,colorAggrType:s.AGG.AVG,linearColorScheme:[s.Color.categoricalPalette[a.Wr.GREY],s.Color.categoricalPalette[a.Wr.LIGHT_GREY]],valueAggrType:s.AGG.AVG,showValueSelector:!1,description:t,descriptionVisibilityMode:"Always",maxBarHeight:a.VF.BAR_HEIGHT,barSortType:"by category"}}(e.byIndex(a.Wr.DOUBLE_VAL2).name,n)).root,l=o.splitV([i,r],{style:{height:`${a.VF.ROW_HEIGHT}px`}});return setTimeout(()=>l.style.height="100%",a.Q9.STYLE_TIMEOUT),l;default:return s.Viewer.grid(t).root}}function C(){const t=s.Color.categoricalPalette,e=o.label(a.o_.SIMULATION);e.style.color=b(s.Color.toRgb(t[a.Wr.BLUE]));const n=o.label(a.o_.TARGET);return n.style.color=b(s.Color.toRgb(t[a.Wr.ORANGE])),o.divV([e,n])}function I(t){return null!=t.col(a.o_.CATEGORY)&&t.columns.length>=a.Uk}function T(t){let e=t%a.RW;return e<=0&&(e+=a.RW-1),function(){return e=e*a.t_%a.RW,(e-1)/(a.RW-1)}}const E={reproducible:a.fD,seed:a.yz};function S(t={}){const e=Object.assign(Object.assign({},E),t),n=o.input.bool("reproducible",{value:e.reproducible,onValueChanged:t=>{i.root.hidden=!t,e.reproducible=t},tooltipText:"Enable to get reproducible results"}),i=o.input.int("random seed",{value:e.seed,nullable:!1,tooltipText:"Numeric value used to initialize the initial points of the optimization method",onValueChanged:t=>{e.seed=null!=t?t:a.yz}});return i.root.hidden=!e.reproducible,{reproducibility:n,seed:i,settings:e}}const x={useEarlyStopping:a.Hs,costFuncThreshold:a._z,stopAfter:a.eJ};function R(t={}){const e=Object.assign(Object.assign({},x),t),n=o.input.int("stop after",{value:e.stopAfter,onValueChanged:t=>{e.stopAfter=t},tooltipText:"Stop the optimization once this number of valid points is found",showPlusMinus:!0,min:a.nw,nullable:!1,property:s.Property.fromOptions({units:"point(s)"})});n.root.hidden=!e.useEarlyStopping;const i=o.input.bool("early stopping",{value:e.useEarlyStopping,onValueChanged:t=>{r.root.hidden=!t,n.root.hidden=!t,e.useEarlyStopping=t},tooltipText:"Enable to stop fitting once the loss function reaches the specified threshold"}),r=o.input.float("threshold",{value:e.costFuncThreshold,nullable:!1,tooltipText:"Loss function value at which to stop fitting",onValueChanged:t=>{e.costFuncThreshold=null!=t?t:a._z}});return r.root.hidden=!e.useEarlyStopping,{stopAtFirst:n,earlyStopping:i,threshold:r,settings:e}}},8194:(t,e,n)=>{"use strict";n.d(e,{u:()=>I});var i=n(4328),o=n(7389),s=n(6082),r=n(6267),a=n(1858),l=n(9713),u=n(1757),c=n.n(u),d=n(5092),p=n(4260),h=n(2244),f=(n(4315),n(5520)),m=n(1599),v=n(8920),g=n(8476),y=n(4795),b=n(6318),A=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const w=t=>{var e,n;return null!==(n=null===(e=t.options)||void 0===e?void 0:e.friendlyName)&&void 0!==n?n:t.func.name},C=t=>{var e;return null!==(e=t.customId)&&void 0!==e?e:t.funcName};class I extends h.s{set currentTabName(t){this.stepTabs.getPane(t)&&(this.stepTabs.currentPane=this.stepTabs.getPane(t))}getStepView(t){var e;return null===(e=this.steps[t])||void 0===e?void 0:e.view}getRunningUpdates(){return[]}disableSetters(t){}constructor(t,e,n={historyEnabled:!0,isTabbed:!1,skipInit:!1}){super(t,n),this.initialConfig=e,this.steps={},this.onStepCompleted=new a.Subject,this.isUpdating=new a.BehaviorSubject(!1),this.pipelineViewExportExtensions=()=>({Archive:"zip","Single Excel":"xlsx"}),this.pipelineViewExportFormats=()=>["Archive","Single Excel"],this.pipelineViewExport=t=>A(this,void 0,void 0,function*(){if(!this.stepTabs)throw new Error("Set step tabs please for export");if("Archive"===t){const t={};for(const e of Object.values(this.steps).filter(t=>t.visibility.value===v.L_.VISIBLE)){this.stepTabs.currentPane=this.stepTabs.getPane(w(e)),yield new Promise(t=>setTimeout(t,100));const n=yield e.view.exportConfig.export("Excel");t[e.view.exportConfig.filename("Excel")]=[new Uint8Array(yield n.arrayBuffer()),{level:0}]}return new Blob([(0,r.L)(t)])}if("Single Excel"===t){yield s.Utils.loadJsCss(["/js/common/exceljs.min.js"]);const t=window.ExcelJS,e="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8",n=new t.Workbook,i=(t,e,n)=>{let i=`${w(n)}>${e}`;i.length>31&&(i=`${i.slice(0,31)}`);let o=2;for(;t.worksheets.some(t=>t.name.toLowerCase()===i.toLowerCase());){let t=`${w(n)}>${e}`;t.length>31-`-${o}`.length&&(t=`${t.slice(0,31-`-${o}`.length)}`),i=`${t}-${o}`,o++}return i};for(const e of Object.values(this.steps).filter(t=>t.visibility.value===v.L_.VISIBLE)){const o=new t.Workbook;this.stepTabs.currentPane=this.stepTabs.getPane(w(e)),yield new Promise(t=>setTimeout(t,100)),yield o.xlsx.load(yield(yield e.view.exportConfig.export("Excel")).arrayBuffer()),o.eachSheet(t=>{const s=i(n,t.name,e),r=n.addWorksheet("New sheet");r.model=t.model,r.name=s,t.getImages().forEach(t=>{const e=n.addImage(o.getImage(t.imageId));r.addImage(e,t.range)})})}return new Blob([yield n.xlsx.writeBuffer()],{type:e})}throw new Error("This format is not supported")}),this.exportConfig={supportedExtensions:this.pipelineViewExportExtensions(),supportedFormats:this.pipelineViewExportFormats(),export:this.pipelineViewExport,filename:this.defaultExportFilename},this.helpFiles={}}init(){return A(this,void 0,void 0,function*(){yield this.loadFuncCallById(),this.initialConfig.forEach((t,e)=>{var n;this.steps[C(t)]={idx:e,visibility:new a.BehaviorSubject(null!==(n=t.hiddenOnInit)&&void 0!==n?n:v.L_.VISIBLE),ability:new a.BehaviorSubject(this.isHistorical.value||0===e?v.D.ENABLED:v.D.DISABLED),options:{friendlyName:t.friendlyName,helpUrl:t.helpUrl,customId:t.customId}}}),this.subs.push(i.functions.onAfterRunAction.pipe((0,l.filter)(t=>Object.values(this.steps).some(({view:e})=>{var n;return(null===(n=null==e?void 0:e.funcCall)||void 0===n?void 0:n.id)===(null==t?void 0:t.id)&&!!t}))).subscribe(t=>{this.onStepCompleted.next(t),"true"!==t.func.options.isMain&&t.func.nqName!==this.initialConfig[this.initialConfig.length-1].funcName||this.run()}));const t=this.initialConfig.map(t=>A(this,void 0,void 0,function*(){return{stepScript:s.Func.byName(t.funcName),stepId:C(t)}})),e=yield Promise.all(t);e.forEach(t=>{this.steps[t.stepId].func=t.stepScript}),this.root.classList.remove("ui-panel");const n={},r="Compute:PipelineStepEditor",u=e.map(t=>A(this,void 0,void 0,function*(){const e=t.stepScript.script?(t=>{const e=t.script,n=e.indexOf("editor:");if(n<0)return r;const i=e.indexOf("\n",n);return e.substring(n+7,i).trim()})(t.stepScript):r;return n[e]||(n[e]=s.Func.byName(e.split(" ").join(""))),this.steps[t.stepId].editor=e,Promise.resolve()}));yield Promise.all(u);const d=e.map(t=>A(this,void 0,void 0,function*(){const e=this.steps[t.stepId],r=t.stepScript.prepare(),u=n[e.editor];yield this.onBeforeStepFuncCallApply(t.stepScript.nqName,r,u);const d=yield u.apply({call:r});yield d.isReady.pipe((0,l.filter)(t=>!!t),(0,l.take)(1)).toPromise();const p=o.button("Back",()=>{},"Go to the previous step");c()(p).addClass("ui-btn-nav");const h=o.button("Next",()=>{},"Go to the next step");c()(h).addClass("ui-btn-nav"),this.syncNavButtons(e,p,h),d.setNavigationButtons([p,h]),this.steps[t.stepId].view=d;const f=this.steps[t.stepId],m=()=>{Object.values(this.steps).forEach(t=>{t.idx>f.idx&&t.visibility.value===v.L_.VISIBLE&&t.ability.value===v.D.ENABLED&&t.ability.next(v.D.DISABLED)})},g=f.view.funcCallReplaced.pipe((0,l.switchMap)(()=>{const t=[...f.view.funcCall.inputParams.values()].map(t=>t.onChanged.pipe((0,l.mapTo)(t)));return(0,a.merge)(...t)})),y=g.subscribe(m);this.subs.push(y);const b=g.pipe((0,l.filter)(t=>t.property.propertyType===s.TYPE.DATA_FRAME&&t.value),(0,l.switchMap)(t=>t.value.onDataChanged)).subscribe(m);this.subs.push(b);const A=i.functions.onAfterRunAction.pipe((0,l.filter)(t=>f.view.funcCall&&t&&!!t.id&&f.view.funcCall.id===t.id),(0,l.withLatestFrom)(f.visibility,f.ability),(0,l.filter)(([,t,e])=>!(t===v.L_.HIDDEN||e===v.D.DISABLED))).subscribe(()=>{const t=(()=>Object.values(this.steps).find(t=>t.idx>f.idx&&t.visibility.value===v.L_.VISIBLE&&t.ability.value===v.D.ENABLED)?null:Object.values(this.steps).find(t=>t.idx>f.idx&&t.visibility.value===v.L_.VISIBLE&&t.ability.value===v.D.DISABLED))();null==t||t.ability.next(v.D.ENABLED)});return this.subs.push(A),yield this.onAfterStepFuncCallApply(t.stepScript.nqName,r,d),d})),p=yield Promise.all(d),h=(0,a.combineLatest)(p.map(t=>t.isHistorical)).subscribe(t=>{t.some((t,e)=>{var n;return!t&&(null===(n=Object.values(this.steps).find(t=>t.idx===e))||void 0===n?void 0:n.visibility.value)===v.L_.VISIBLE})&&this.isHistorical.value&&this.isHistorical.next(!1)});this.subs.push(h);const f=this.isUpdating.subscribe(t=>{for(const e of Object.values(this.steps)){const n=e.view;(null==n?void 0:n.blockRuns)&&n.blockRuns.next(t)}});this.subs.push(f),yield this.onFuncCallReady(),this.isReady.next(!0),this.loadHelp().then(()=>{this.buildRibbonPanels();const t=()=>{const t=this.findCurrentStep();t&&this.helpFiles[t.func.nqName]&&"opened"===this.getHelpState()&&this.showHelpWithDelay(t)},e=i.events.onCurrentViewChanged.pipe((0,l.filter)(()=>i.shell.v==this)).subscribe(t);t(),this.subs.push(e)})})}loadHelp(){return A(this,void 0,void 0,function*(){return Promise.all(Object.values(this.steps).map(t=>A(this,void 0,void 0,function*(){var e,n,o,s;const r=null!==(n=null===(e=t.options)||void 0===e?void 0:e.helpUrl)&&void 0!==n?n:t.func.options.help;if(r){const e=`System:AppData/${this.func.package.name}/${r}`,n=(yield i.dapi.files.exists(e))?yield i.dapi.files.readAsText(e):yield t.view.getContextHelp();n&&(this.helpFiles[null!==(s=null===(o=t.options)||void 0===o?void 0:o.customId)&&void 0!==s?s:t.func.nqName]=n)}})))})}syncNavButtons(t,e,n){let i,o;n.addEventListener("click",()=>{i&&(this.currentTabName=w(i))}),e.addEventListener("click",()=>{o&&(this.currentTabName=w(o))});const s=this.getPipelineStateChanges().pipe((0,l.startWith)(!0),(0,l.debounceTime)(0)).subscribe(()=>{i=this.getNextStep(t),o=this.getPreviousStep(t),i?(c()(n).show(),i.ability.value===v.D.DISABLED&&c()(n).addClass("d4-disabled"),i.ability.value===v.D.ENABLED&&c()(n).removeClass("d4-disabled")):c()(n).hide(),o?(c()(e).show(),o.ability.value===v.D.DISABLED&&c()(e).addClass("d4-disabled"),o.ability.value===v.D.ENABLED&&c()(e).removeClass("d4-disabled")):c()(e).hide()});this.subs.push(s)}getPreviousStep(t){return Object.values(this.steps).slice().reverse().find(e=>e.idx<t.idx&&e.visibility.value===v.L_.VISIBLE)}getNextStep(t){return Object.values(this.steps).find(e=>e.idx>t.idx&&e.visibility.value===v.L_.VISIBLE)}getPipelineStateChanges(){const t=Object.values(this.steps).flatMap(t=>[t.ability,t.visibility]);return(0,a.merge)(...t).pipe((0,l.mapTo)(!0))}onComparisonLaunch(t){return A(this,void 0,void 0,function*(){const e=i.shell.v.parentCall,n=yield Promise.all(t.map(t=>d.W.loadChildRuns(t.id))),o=yield Promise.all(n.map(t=>{var e;return null!==(e=t.childRuns.find(t=>"true"===t.func.options.isMain))&&void 0!==e?e:t.childRuns.find(t=>t.func.nqName===this.initialConfig[this.initialConfig.length-1].funcName)}).map(t=>d.W.loadRun(t.id))),s=[...i.shell.views].find(t=>t.type===p.sk),r=yield g.S.fromComparedRuns(o,o[0].func,{parentView:s,parentCall:e});i.shell.addView(r)})}onBeforeStepFuncCallApply(t,e,n){return A(this,void 0,void 0,function*(){})}onAfterStepFuncCallApply(t,e,n){return A(this,void 0,void 0,function*(){})}buildIO(){const t=Object.values(this.steps).reduce((t,e)=>Object.assign(Object.assign({},t),{[w(e)]:e.view.root}),{}),e=o.tabControl(t),n=Object.values(this.steps).map(t=>{const n=o.iconFA("exclamation-circle",null,"This step has inconsistent inputs");return c()(n).css({color:"var(--orange-2)","margin-left":"3px","padding-top":"1px"}),e.getPane(w(t)).header.appendChild(n),t.view.consistencyState.subscribe(t=>{"consistent"===t&&c()(n).hide(),"inconsistent"===t&&c()(n).show()})});this.subs.push(...n);const i=Object.values(this.steps).map(t=>t.view.consistencyState),s=(0,a.merge)(...i).subscribe(()=>{i.map(t=>t.value).some(t=>"inconsistent"===t)?this.consistencyState.next("inconsistent"):this.consistencyState.next("consistent")});this.subs.push(s);const r=e.panes[0].header.parentElement;r.classList.add("d4-ribbon","pipeline-view"),r.classList.remove("d4-tab-header-stripe"),r.firstChild.remove();for(let t=0;t<e.panes.length;t++)e.panes[t].header.classList.add("d4-ribbon-name"),e.panes[t].header.classList.remove("d4-tab-header");return e.panes[0].header.style.marginLeft="12px",e.root.style.height="100%",e.root.style.width="100%",this.stepTabs=e,this.initialConfig.forEach(t=>{const e=C(t);this.subs.push(this.steps[e].visibility.subscribe(t=>{t===v.L_.VISIBLE&&c()(this.stepTabs.getPane(w(this.steps[e])).header).css("display","inherit"),t===v.L_.HIDDEN&&c()(this.stepTabs.getPane(w(this.steps[e])).header).hide()}))}),Object.values(this.steps).forEach(t=>{this.subs.push(t.ability.subscribe(e=>{e===v.D.ENABLED&&c()(this.stepTabs.getPane(w(t)).header).removeClass("d4-disabled"),e===v.D.DISABLED&&c()(this.stepTabs.getPane(w(t)).header).addClass("d4-disabled")}))}),this.hideSteps(...this.initialConfig.filter(t=>t.hiddenOnInit===v.L_.HIDDEN).map(t=>t.funcName)),e.root}showHelpWithDelay(t){return A(this,void 0,void 0,function*(){(0,y.aB)(this.helpFiles[t.func.nqName])})}findCurrentStep(){return Object.values(this.steps).find(t=>w(t)===this.stepTabs.currentPane.name)}buildHistoryBlock(){const t=super.buildHistoryBlock(),e=this.historyBlock.afterRunDeleted.subscribe(t=>A(this,void 0,void 0,function*(){(yield i.dapi.functions.calls.allPackageVersions().filter(`options.parentCallId="${t.id}"`).list()).map(t=>A(this,void 0,void 0,function*(){return d.W.deleteRun(t)}))}));return this.subs.push(e),t}getHelpState(){return"closed"===i.userSettings.getValue(p.Jc,`${this.func.name}_help_state`)?"closed":"opened"}saveHelpState(t){i.userSettings.add(p.Jc,`${this.func.name}_help_state`,t)}buildRibbonPanels(){const t=o.iconFA("info",()=>A(this,void 0,void 0,function*(){const t=this.findCurrentStep();t&&this.helpFiles[t.func.nqName]&&(yield this.showHelpWithDelay(t),this.saveHelpState("opened"))}),"Show help for this step"),e=()=>{const e=this.findCurrentStep();o.setDisplay(t,!(!e||!this.helpFiles[e.func.nqName])),e&&this.helpFiles[e.func.nqName]&&i.shell.windows.help.visible&&this.showHelpWithDelay(e),this.setRibbonPanels([...this.getRibbonPanels().slice(0,1),...e?e.view.buildRibbonPanels():[],...this.getRibbonPanels().length>2?this.getRibbonPanels().slice(-1):[]])};if(!this.isReady.value){const t=this.stepTabs.onTabChanged.subscribe(e),n=i.events.onEvent("grok-panels-changed").pipe((0,l.filter)(()=>i.shell.v===this)).subscribe(()=>A(this,void 0,void 0,function*(){const t=yield this.getHelpState();if(i.shell.windows.help.visible&&"closed"===t)this.saveHelpState("opened");else if(!i.shell.windows.help.visible&&"opened"===t){const t=o.iconFA("info");return c()(t).css("margin","0px 3px"),i.shell.info(o.span(["You can open help panel by clicking the",t,"button on the ribbon menu"])),void this.saveHelpState("closed")}}));this.subs.push(t,n)}const n=this.findCurrentStep(),s=[[...super.buildRibbonPanels().flat(),t],...n?n.view.buildRibbonPanels():[]];return this.setRibbonPanels(s),e(),s}saveRun(t){return A(this,void 0,void 0,function*(){let e=(0,m.A4)(t);yield this.onBeforeSaveRun(e),(0,m.Ne)(e)&&(e=yield(0,y.Hs)(t)),e.newId();const n=Object.values(this.steps).filter(t=>t.visibility.value===v.L_.VISIBLE).map(t=>A(this,void 0,void 0,function*(){var n,i;const o=t.view.funcCall;return o.options.parentCallId=e.id,(null===(n=t.options)||void 0===n?void 0:n.customId)&&(o.options.customId=null===(i=t.options)||void 0===i?void 0:i.customId),yield t.view.saveRun(o),Promise.resolve()}));yield Promise.all(n),e.options.title&&(e.options.title=`${e.options.title} (copy)`);const i=yield d.W.saveRun(e),o=yield d.W.loadRun(i.id);return this.options.historyEnabled&&this.isHistoryEnabled&&this.historyBlock&&this.historyBlock.addRun(yield d.W.loadRun(i.id)),this.linkFunccall(o),this.isHistorical.next(!0),yield this.onAfterSaveRun(e),i})}loadRun(t){return A(this,void 0,void 0,function*(){const{parentRun:e,childRuns:n}=yield d.W.loadChildRuns(t),i=Object.values(this.steps).filter(t=>t.visibility.value===v.L_.VISIBLE).findIndex(t=>w(t)===this.stepTabs.currentPane.name);yield this.onBeforeLoadRun();for(const t of Object.values(this.steps)){const e=n.filter(e=>e.func.nqName===t.func.nqName);if(0===e.length&&(t.visibility.next(v.L_.HIDDEN),t.ability.next(v.D.DISABLED)),1===e.length&&(yield t.view.loadRun(e[0].id),t.visibility.next(v.L_.VISIBLE),(0,m.Ne)(e[0])?t.ability.next(v.D.DISABLED):t.ability.next(v.D.ENABLED)),e.length>1){const n=e.find(e=>{var n;return e.options.customId===(null===(n=t.options)||void 0===n?void 0:n.customId)});yield t.view.loadRun(n.id),t.visibility.next(v.L_.VISIBLE),(0,m.Ne)(n)?t.ability.next(v.D.DISABLED):t.ability.next(v.D.ENABLED)}}const o=Object.values(this.steps).find(t=>t.ability.value===v.D.DISABLED&&t.visibility.value===v.L_.VISIBLE),s=null!=o?o:Object.values(this.steps)[0];if(s.ability.next(v.D.ENABLED),o){let t=this.getNextStep(o);for(;t;)t.ability.next(v.D.DISABLED),t=this.getNextStep(t)}this.lastCall=e,this.linkFunccall(e),this.isHistorical.next(!0);const r=Object.values(this.steps).filter(t=>t.visibility.value==v.L_.VISIBLE).at(i);return r&&r.ability.value===v.D.ENABLED?this.currentTabName=w(r):this.currentTabName=w(s),yield this.onAfterLoadRun(e),e})}hideSteps(...t){return A(this,void 0,void 0,function*(){t.forEach(t=>{this.steps[t].visibility.next(v.L_.HIDDEN)})})}showSteps(...t){return A(this,void 0,void 0,function*(){t.forEach(t=>{this.steps[t].visibility.next(v.L_.VISIBLE)})})}exportRunJson(){return A(this,void 0,void 0,function*(){if(this._lastCall){const t={isPipeline:!0};for(const[e,n]of Object.entries(this.steps)){const i=n.view.lastCall;i&&(t[e]=yield(0,y.wB)(i,n.view))}return(0,f.lK)(t)}})}executeTest(t){return A(this,arguments,void 0,function*(t,e=!1){yield(0,b.b)(t,this,{updateMode:e,interactive:!0})})}getStepViewRuns(t){return this.onStepCompleted.pipe((0,l.filter)(e=>e.func.nqName===t),(0,l.map)(()=>this.getStepView(t)))}}},8384:(t,e,n)=>{"use strict";n.d(e,{OW:()=>l,PJ:()=>o,Pd:()=>s,Un:()=>i,fK:()=>a,j2:()=>r});const i="Success",o=0,s=2,r=1,a=2;var l;!function(t){t[t.SUCCEED=0]="SUCCEED",t[t.FAILED=1]="FAILED"}(l||(l={}))},8405:(t,e,n)=>{"use strict";n.d(e,{F4:()=>f,HE:()=>v,KN:()=>g,Mx:()=>d,TR:()=>l,VV:()=>h,VW:()=>m,W8:()=>r,k5:()=>p,ly:()=>c,wV:()=>u});var i=n(7389),o=n(6082),s=(n(3881),n(1005));const r="/help/compute/function-analysis#optimization",a=`https://datagrok.ai${r}`,l="# Optimization\n\nUse optimization to find ...";function u(){const t=i.input.choice("",{value:s.RF.MAX,nullable:!1,items:[s.RF.MIN,s.RF.MAX],tooltipText:"Type of optimization"});return t.input.style.border="white",t.input.classList.add("optimization-type-input"),t}var c,d;!function(t){t.CONSTR="Inputs constraints",t.METHOD="Method",t.USING="Using",t.SET="with settings",t.PARETO_FRONT="Pareto front"}(c||(c={})),function(t){t.NELDER_MEAD="Nelder-Mead",t.MOEAD="MOEA/D"}(d||(d={}));const p=new Map([[d.MOEAD,"Multi-objective evolutionary algorithm based on decomposition"],[d.NELDER_MEAD,"The Nelder-Mead method"]]),h=[o.Color.lightLightGray,o.Color.lightGray,o.Color.gray];function f(t){const e=[o.Color.darkGreen,o.Color.yellow,o.Color.darkRed];return t===s.RF.MIN?e:e.reverse()}function m(){const t=i.icons.help(()=>window.open(a,"_blank"),"Open help in a new tab");return t.classList.add("optimization-view-help-icon"),t}function v(t){const e=i.label("min"),n=i.label(". . ."),s=i.label("max"),r=f(t),a=[e,n,s].map((t,e)=>(1!==e&&(t.style.fontWeight="bold",t.style.color=o.Color.toRgb(r[e])),t.style.marginRight="5px",t));return i.divH(a)}var g;!function(t){t[t.SINGLE_SINGLE_SCATTER=.3]="SINGLE_SINGLE_SCATTER",t[t.MULT_SINGLE_PC=.5]="MULT_SINGLE_PC"}(g||(g={}))},8476:(t,e,n)=>{"use strict";n.d(e,{S:()=>d});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(4260),u=n(810),c=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class d extends s.TableView{static fromComparedRuns(t,e){return c(this,arguments,void 0,function*(t,e,n={parentView:void 0,parentCall:void 0}){const o=(0,u.fo)(t,e,n),s=[...i.shell.views].find(t=>t.type===l.sk||t.type===l.eP||t.type===l.r0);return s&&(i.shell.v=s),new this(o,n)})}constructor(t,e={}){super(window.grok_TableView(t.dart,!1)),e.parentView&&(this.parentView=e.parentView),this.parentCall=e.parentCall||i.functions.getCurrentCall()}showAllColumns(){const t=this.dataFrame.columns.names();this.grid.columns.setVisible(t)}showChangingColumns(){const t=this.dataFrame.columns.names().filter(t=>s.TYPES_SCALAR.has(this.dataFrame.getCol(t).type)&&this.dataFrame.getCol(t).categories.length>1||!s.TYPES_SCALAR.has(this.dataFrame.getCol(t).type));this.grid.columns.setVisible(t)}defaultCustomize(){var t;const e=o.iconFA("compress-alt",()=>{this.showChangingColumns(),a()(n).show(),a()(e).hide()},"Hide constant parameters"),n=o.iconFA("expand-arrows-alt",()=>{this.showAllColumns(),a()(n).hide(),a()(e).show()},"Show all parameters");a()(e).hide(),this.setRibbonPanels([...this.getRibbonPanels(),[e,n]]),this.showChangingColumns(),this.root.style.removeProperty("width"),this.root.firstChild.style.removeProperty("width"),this.root.firstChild.firstChild.style.removeProperty("width"),this.grid.props.rowHeight=180,this.grid.props.showAddNewRowIcon=!1,this.grid.props.allowEdit=!1,this.grid.columns.byName(l._W).width=70;for(let e=0;e<this.grid.columns.length;e++){const n=this.grid.columns.byIndex(e);(null===(t=n.column)||void 0===t?void 0:t.temp[l.NT])&&(n.width=350,n.cellType="html")}const r=new s.LruCache;this.grid.onCellPrepare(t=>c(this,void 0,void 0,function*(){if(!t.isColHeader&&!t.isRowHeader){if(t.tableColumn.name===l._W){t.customText="";const e=String(t.cell.value).split(" - "),n=e.length>1?[e[0],o.element("br"),e[1]]:e;return t.element=o.div(n,{style:{writingMode:"vertical-rl",textOrientation:"mixed",margin:"auto"}}),void(t.element.parentElement.style.display="flex")}if(t.tableColumn&&t.tableColumn.temp[l.NT]){const e=t.cell.value,n=t.tableColumn.temp[l.NT],i=n.type,o=()=>c(this,void 0,void 0,function*(){const o=Object.values(l.CB).includes(i)?s.Viewer.fromType(i,e):yield e.plot.fromType(i);return t.tableColumn.temp[l.NT].look?o.setOptions(t.tableColumn.temp[l.NT].look):(o.setOptions(n),t.tableColumn.temp[l.NT]=o.getOptions()),o.root}),a=`${e.id}_${i}`;if(r.get(a))t.element=r.get(a);else{const e=yield o();r.set(a,e),t.element=e}t.element.style.width="100%",t.element.style.height="100%"}}}));const u=o.box(o.div([],{style:{minHeight:"100px"}})),d=i.events.onCurrentViewChanged.subscribe(()=>{i.shell.v.id===this.id?i.shell.dockManager.dock(u,"down",null,"Comparison chart",.25):i.shell.dockManager.close(u)}),p=this.grid.onCellClick.subscribe(t=>{var e;if(i.shell.v.id===this.id&&t.isColHeader&&(null===(e=t.tableColumn)||void 0===e?void 0:e.type)===s.TYPE.DATA_FRAME&&[s.VIEWER.LINE_CHART,s.VIEWER.SCATTER_PLOT,s.VIEWER.HISTOGRAM,s.VIEWER.BOX_PLOT].includes(t.tableColumn.temp[l.NT].type)){i.shell.dockManager.findNode(u)||i.shell.dockManager.dock(u,"down",null,"Comparison chart",.25);const e=t=>{const e=s.toJs(t.get(0)).clone();e.columns.addNew(l.eX,s.TYPE.STRING).init(t.dataFrame.get(l._W,0));for(let n=1;n<t.length;n++){const i=s.toJs(t.get(n)).clone();i.columns.addNew(l.eX,s.TYPE.STRING).init(t.dataFrame.get(l._W,n));const o=[s.COLUMN_TYPE.INT,s.COLUMN_TYPE.FLOAT];for(let t=0;t<i.columns.length;t++){const n=i.columns.byIndex(t),r=e.columns.byIndex(t);n.type!==r.type&&o.includes(n.type)&&o.includes(r.type)&&(n.type!==s.COLUMN_TYPE.FLOAT&&i.columns.replace(n,n.convertTo(s.COLUMN_TYPE.FLOAT)),r.type!==s.COLUMN_TYPE.FLOAT&&e.columns.replace(r,r.convertTo(s.COLUMN_TYPE.FLOAT)))}e.append(i,!0)}return e},n=(e,n,i)=>{var o;switch(null===(o=t.tableColumn)||void 0===o?void 0:o.temp[l.NT].type){case s.VIEWER.LINE_CHART:return i.plot.line(Object.assign(Object.assign({},n),{split:l.eX})).root;case s.VIEWER.SCATTER_PLOT:return i.plot.scatter(Object.assign(Object.assign({},n),{color:l.eX})).root;case s.VIEWER.HISTOGRAM:return i.plot.histogram(Object.assign(Object.assign({},n),{split:l.eX})).root;case s.VIEWER.BOX_PLOT:return i.plot.box(Object.assign(Object.assign({},n),{category:l.eX})).root}};o.setUpdateIndicator(u,!0),setTimeout(()=>{var i;if(!t.tableColumn.temp.unitedPlot){const s=t.tableColumn.temp[l.NT].look,r=e(t.tableColumn);t.tableColumn.temp.unitedPlot=n(null===(i=t.tableColumn)||void 0===i?void 0:i.temp[l.NT].type,s,r),o.setUpdateIndicator(u,!1)}o.empty(u),u.appendChild(t.tableColumn.temp.unitedPlot)},10)}else i.shell.dockManager.close(u)});this.subs.push(p,d)}}},8501:(t,e,n)=>{"use strict";var i,o;n.d(e,{g1:()=>s}),function(t){t.MRT_FAILS="The modified Rosenbrock triple method fails",t.ROS3PRW_FAILS="The ROS3PRw method fails",t.ROS34PRW_FAILS="The ROS34PRw method fails"}(i||(i={}));class s extends Error{constructor(t){super(t)}}!function(t){t.SCRIPTING="{maxIterations: 1}",t.NO_CHECKS="{ }"}(o||(o={}))},8550:(t,e,n)=>{"use strict";var i=n(6186),o=n.n(i),s=n(2155),r=n.n(s),a=n(7433),l=n.n(a),u=n(8626),c=n.n(u),d=n(8990),p=n.n(d),h=n(9827),f=n.n(h),m=n(1261),v={};v.styleTagTransform=f(),v.setAttributes=c(),v.insert=l().bind(null,"head"),v.domAPI=r(),v.insertStyleElement=p(),o()(m.A,v),m.A&&m.A.locals&&m.A.locals},8626:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},8804:(t,e,n)=>{"use strict";n.d(e,{C:()=>u,V:()=>l});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class l extends s.Dialog{static forFuncCall(t,e=!1){var n,i,o;const s=null!==(n=t.options.title)&&void 0!==n?n:"",r=null!==(i=t.options.description)&&void 0!==i?i:"",a=null!==(o=t.options.tags)&&void 0!==o?o:[];return new l({title:s,description:r,tags:a,isFavorite:e})}constructor(t){var e,n,l,u;super(o.dialog({title:"Save model state"}).dart),this._onMetadataEdit=new r.Subject,this.onMetadataEdit=this._onMetadataEdit.asObservable();let c=null!==(e=null==t?void 0:t.title)&&void 0!==e?e:"",d=null!==(n=null==t?void 0:t.description)&&void 0!==n?n:"",p=null!==(l=null==t?void 0:t.isFavorite)&&void 0!==l&&l;const h=o.input.string("Title",{value:c,onValueChanged:t=>c=t}),f=o.input.string(" ",{value:""}),m=s.TagEditor.create();(null!==(u=null==t?void 0:t.tags)&&void 0!==u?u:[]).forEach(t=>{m.addTag(t)}),f.input.replaceWith(m.root);const v=()=>{""===g.value||m.tags.includes(g.value)||(m.addTag(g.value),g.value="")},g=o.input.string("Tag",{value:""}).addOptions(o.iconFA("plus",v,"Add this tag")),y=(0,r.fromEvent)(g.input,"onkeydown").subscribe(t=>{"Enter"==t.key&&(t.stopPropagation(),v())});this.sub(y);const b=o.input.string("Description",{value:d,onValueChanged:t=>d=t}),A=o.input.bool("Is favorite",{value:p,onValueChanged:t=>p=t});this.add(o.form([h,b,A,g,f])),this.addButton("Save",()=>a(this,void 0,void 0,function*(){if(""!==g.value)return void i.shell.info(`Dialog has unsaved tags: ${g.value}`);const t={title:""!==c?c:null,description:""!==d?d:null,isFavorite:p,tags:m.tags.map(t=>t)};this._onMetadataEdit.next(t),this.close()}))}}class u extends s.Dialog{constructor(t){super(o.dialog({title:`Delete ${t.size>1?t.size:""} ${t.size>1?"runs":"run"}`}).dart),this._onFuncCallDelete=new r.Subject,this.onFuncCallDelete=this._onFuncCallDelete.asObservable(),this.add(o.divText(`Deleted ${t.size>1?t.size:""} ${t.size>1?"runs":"run"} ${t.size>1?"are":"is"} impossible to restore. Are you sure?`)),this.onOK(()=>a(this,void 0,void 0,function*(){return this._onFuncCallDelete.next(t)}))}}},8867:(t,e,n)=>{"use strict";n.d(e,{PT:()=>g,RP:()=>y});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=n(9713),l=n(1757),u=n.n(l),c=n(5092),d=(n(9192),n(5355)),p=n(1599),h=n(6910),f=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class m{static getHistoryRuns(t,e=!0){return(0,r.from)((()=>f(this,void 0,void 0,function*(){return yield c.W.pullRunsByName(t,[{author:i.shell.user}],{order:"started"},["func.params","session.user","options"],e)}))())}}class v extends s.InputBase{constructor(t,e,n){var i,s;const l=o.input.string(t,{value:""});super(l.dart),this.label=t,this._funcName=e,this.options=n,this.onHistoricalRunChosen=new r.BehaviorSubject(null),this.experimentRunsUpdate=new r.Subject,this.store={experimentRuns:new r.Observable,isExperimentRunsLoading:new r.Subject,experimentRunData:new r.BehaviorSubject("")},this._historyList=new d.H([],{fallbackText:"No runs are found in history",showActions:!1,showBatchActions:!1,isHistory:!1,visibleProps:null===(i=this.options)||void 0===i?void 0:i.mainProps,propFuncs:null===(s=this.options)||void 0===s?void 0:s.propFuncs}),this._historyDialog=this.getHistoryDialog(),this._visibleInput=o.input.string(this.label,{value:""}),this._visibleIcon=o.iconFA("search",()=>this.showSelectionDialog()),this._chosenRun=null,this._chosenRunId=null,this._visibleInput=l,this._visibleInput.readOnly=!0,this._visibleInput.input.addEventListener("click",()=>this.showSelectionDialog()),this._visibleInput.addOptions(this._visibleIcon),this.store.experimentRuns=this.experimentRunsUpdate.pipe((0,a.tap)(()=>this.toggleLoaderExpRuns(!0)),(0,a.switchMap)(()=>{var t,e;return m.getHistoryRuns(this._funcName,null===(e=null===(t=this.options)||void 0===t?void 0:t.skipDfsOnInit)||void 0===e||e).pipe((0,a.catchError)(t=>(console.error(t),r.EMPTY)),(0,a.finalize)(()=>this.toggleLoaderExpRuns(!1)))}),(0,a.shareReplay)(1)),this.store.experimentRuns.subscribe(t=>{this._historyList.updateRuns(t.filter(t=>!(0,p.Ne)(t)))}),this.store.isExperimentRunsLoading.subscribe(t=>{o.setUpdateIndicator(this._visibleInput.root,t),o.setUpdateIndicator(this._historyList.root,t)}),this.experimentRunsUpdate.next()}setCurrentRow(){this.getValue()?this._historyList.chosen=this.getValue():this.chosenRunId&&(this._historyList.chosenById=this.chosenRunId)}showSelectionDialog(){this.renderGridAndFilters(),this._historyDialog.getButton("OK").disabled=1!==this._historyList.selected.size,this._historyDialog.show({modal:!0,fullScreen:!0,center:!0,width:window.innerWidth-50,height:window.innerHeight-50})}renderGridAndFilters(){var t,e;const n=new d.H([...this._historyList.runs.values()],Object.assign(Object.assign({},this.options),{visibleProps:null===(t=this.options)||void 0===t?void 0:t.mainProps,propFuncs:null===(e=this.options)||void 0===e?void 0:e.propFuncs}));this._historyList.root.replaceWith(n.root),this._historyList=n,this._historyList.onChosen.subscribe(t=>{this._historyDialog.getButton("OK").disabled=!t}),this._historyList.onRunsDfChanged.pipe((0,a.filter)(t=>t.rowCount>0),(0,a.take)(1)).subscribe(t=>{this.setCurrentRow()})}getHistoryDialog(){const t=o.dialog();return u()(t.root.querySelector(".d4-dialog-contents")).removeClass("ui-form"),t.onOK(()=>f(this,void 0,void 0,function*(){var t,e;let n=this._historyList.chosen;n&&((null===(e=null===(t=this.options)||void 0===t?void 0:t.skipDfsOnInit)||void 0===e||e)&&(n=yield c.W.loadRun(n.id,!1)),this.setValue(n)),this.fireInput()})),t.addButton("Refresh",()=>{this.experimentRunsUpdate.next()},2,"Reload list of runs"),t.addButton("Discard",()=>{this.setValue(null),this.fireInput(),t.close()},1,"Discard the previous choice"),u()(t.getButton("CANCEL")).hide(),t.add(this._historyList.root),t}setValue(t){var e,n,i,o,s,r,a;this._chosenRun=t,this._chosenRunId=null!==(n=null===(e=this._chosenRun)||void 0===e?void 0:e.id)&&void 0!==n?n:null,this.onHistoricalRunChosen.next(t),this.stringValue=t?(null===(i=this.options)||void 0===i?void 0:i.stringValueFunc)?null===(o=this.options)||void 0===o?void 0:o.stringValueFunc(t):[`${(0,p.eK)(t)} \\ ${t.author.name}`,(null!==(a=null!==(r=null===(s=this.options)||void 0===s?void 0:s.mainProps)&&void 0!==r?r:(0,h.qg)(t.func))&&void 0!==a?a:[]).map(e=>(0,h.u8)(t,e)).join(" \\ ")].join(" \\ "):"No run chosen",this.notify&&this.fireChanged()}getValue(){return this._chosenRun}get chosenRun(){return this._chosenRun}get chosenRunId(){return this._chosenRunId}set chosenRunId(t){this._chosenRunId=t}get root(){return this._visibleInput.root}set stringValue(t){this._visibleInput.value=t,this._visibleInput.setTooltip(this._visibleInput.value)}get stringValue(){return this._visibleInput.value}get iconRoot(){return this._visibleIcon}toggleLoaderExpRuns(t){this.store.isExperimentRunsLoading.next(t)}}class g extends v{set value(t){this.setValue(t)}get value(){return this.getValue()}}class y extends v{get value(){const t=this.getValue();return t?JSON.stringify({visualValue:this.stringValue,id:t.id.split("-")}):null}set value(t){this.setValue(null),this.stringValue=t?JSON.parse(t).visualValue:"No run is chosen",this.chosenRunId=t?JSON.parse(t).id.join("-"):""}}},8870:(t,e,n)=>{"use strict";var i=n(6186),o=n.n(i),s=n(2155),r=n.n(s),a=n(7433),l=n.n(a),u=n(8626),c=n.n(u),d=n(8990),p=n.n(d),h=n(9827),f=n.n(h),m=n(2993),v={};v.styleTagTransform=f(),v.setAttributes=c(),v.insert=l().bind(null,"head"),v.domAPI=r(),v.insertStyleElement=p(),o()(m.A,v),m.A&&m.A.locals&&m.A.locals},8920:(t,e,n)=>{"use strict";n.d(e,{AY:()=>i,D:()=>a,Jl:()=>o,L_:()=>r,bZ:()=>l,wl:()=>u});const i="restrictedValues",o="editState";var s,r,a,l;!function(t){t.INPUT="Input",t.OUTPUT="Output"}(s||(s={})),function(t){t.HIDDEN="hidden",t.VISIBLE="visible"}(r||(r={})),function(t){t.ENABLED="enabled",t.DISABLED="disabled"}(a||(a={})),function(t){t.INPUTS="inputs",t.OUTPUTS="outputs"}(l||(l={}));const u={[l.INPUTS]:"inputParams",[l.OUTPUTS]:"outputParams"}},8990:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},9070:(t,e,n)=>{"use strict";n.d(e,{N:()=>r,h:()=>s});var i=n(6082),o=n(4594);function s(t,e){const n=e.length,s=(0,o.h)(t,n);return[...Array(n).keys()].map(t=>function(t,e){var n;const o=e.length,s=i.Column.fromType(t.prop.propertyType,null!==(n=t.prop.caption)&&void 0!==n?n:t.prop.name,o),r=s.getRawData(),a=t.max-t.min;for(let n=0;n<o;++n)r[n]=t.min+a*e[n];return s}(e[t],s[t]))}function r(t,e){var n;const o=[];for(const s of e){const e=i.Column.fromType(s.prop.propertyType,null!==(n=s.prop.caption)&&void 0!==n?n:s.prop.name,t),r=e.getRawData(),a=s.max-s.min;for(let e=0;e<t;++e)r[e]=s.min+a*Math.random();o.push(e)}return o}},9094:(t,e,n)=>{"use strict";n(1511),n(2515)},9131:(t,e,n)=>{"use strict";n.d(e,{Y:()=>i});class i{constructor(){}onIterationStart(){}onComputationsCompleted(){}}},9192:(t,e,n)=>{"use strict";var i=n(6186),o=n.n(i),s=n(2155),r=n.n(s),a=n(7433),l=n.n(a),u=n(8626),c=n.n(u),d=n(8990),p=n.n(d),h=n(9827),f=n.n(h),m=n(5167),v={};v.styleTagTransform=f(),v.setAttributes=c(),v.insert=l().bind(null,"head"),v.domAPI=r(),v.insertStyleElement=p(),o()(m.A,v),m.A&&m.A.locals&&m.A.locals},9225:(t,e,n)=>{"use strict";n(8501)},9234:function(t){var e;t.exports=(e=function(t,e){var n=Array.prototype.concat,i=Array.prototype.slice,o=Object.prototype.toString;function s(e,n){var i=e>n?e:n;return t.pow(10,17-~~(t.log(i>0?i:-i)*t.LOG10E))}var r=Array.isArray||function(t){return"[object Array]"===o.call(t)};function a(t){return"[object Function]"===o.call(t)}function l(t){return"number"==typeof t&&t-t===0}function u(){return new u._init(arguments)}function c(){return 0}function d(){return 1}function p(t,e){return t===e?1:0}u.fn=u.prototype,u._init=function(t){if(r(t[0]))if(r(t[0][0])){a(t[1])&&(t[0]=u.map(t[0],t[1]));for(var e=0;e<t[0].length;e++)this[e]=t[0][e];this.length=t[0].length}else this[0]=a(t[1])?u.map(t[0],t[1]):t[0],this.length=1;else if(l(t[0]))this[0]=u.seq.apply(null,t),this.length=1;else{if(t[0]instanceof u)return u(t[0].toArray());this[0]=[],this.length=1}return this},u._init.prototype=u.prototype,u._init.constructor=u,u.utils={calcRdx:s,isArray:r,isFunction:a,isNumber:l,toVector:function(t){return n.apply([],t)}},u._random_fn=t.random,u.setRandom=function(t){if("function"!=typeof t)throw new TypeError("fn is not a function");u._random_fn=t},u.extend=function(t){var e,n;if(1===arguments.length){for(n in t)u[n]=t[n];return this}for(e=1;e<arguments.length;e++)for(n in arguments[e])t[n]=arguments[e][n];return t},u.rows=function(t){return t.length||1},u.cols=function(t){return t[0].length||1},u.dimensions=function(t){return{rows:u.rows(t),cols:u.cols(t)}},u.row=function(t,e){return r(e)?e.map(function(e){return u.row(t,e)}):t[e]},u.rowa=function(t,e){return u.row(t,e)},u.col=function(t,e){if(r(e)){var n=u.arange(t.length).map(function(){return new Array(e.length)});return e.forEach(function(e,i){u.arange(t.length).forEach(function(o){n[o][i]=t[o][e]})}),n}for(var i=new Array(t.length),o=0;o<t.length;o++)i[o]=[t[o][e]];return i},u.cola=function(t,e){return u.col(t,e).map(function(t){return t[0]})},u.diag=function(t){for(var e=u.rows(t),n=new Array(e),i=0;i<e;i++)n[i]=[t[i][i]];return n},u.antidiag=function(t){for(var e=u.rows(t)-1,n=new Array(e),i=0;e>=0;e--,i++)n[i]=[t[i][e]];return n},u.transpose=function(t){var e,n,i,o,s,a=[];for(r(t[0])||(t=[t]),n=t.length,i=t[0].length,s=0;s<i;s++){for(e=new Array(n),o=0;o<n;o++)e[o]=t[o][s];a.push(e)}return 1===a.length?a[0]:a},u.map=function(t,e,n){var i,o,s,a,l;for(r(t[0])||(t=[t]),o=t.length,s=t[0].length,a=n?t:new Array(o),i=0;i<o;i++)for(a[i]||(a[i]=new Array(s)),l=0;l<s;l++)a[i][l]=e(t[i][l],i,l);return 1===a.length?a[0]:a},u.cumreduce=function(t,e,n){var i,o,s,a,l;for(r(t[0])||(t=[t]),o=t.length,s=t[0].length,a=n?t:new Array(o),i=0;i<o;i++)for(a[i]||(a[i]=new Array(s)),s>0&&(a[i][0]=t[i][0]),l=1;l<s;l++)a[i][l]=e(a[i][l-1],t[i][l]);return 1===a.length?a[0]:a},u.alter=function(t,e){return u.map(t,e,!0)},u.create=function(t,e,n){var i,o,s=new Array(t);for(a(e)&&(n=e,e=t),i=0;i<t;i++)for(s[i]=new Array(e),o=0;o<e;o++)s[i][o]=n(i,o);return s},u.zeros=function(t,e){return l(e)||(e=t),u.create(t,e,c)},u.ones=function(t,e){return l(e)||(e=t),u.create(t,e,d)},u.rand=function(t,e){return l(e)||(e=t),u.create(t,e,u._random_fn)},u.identity=function(t,e){return l(e)||(e=t),u.create(t,e,p)},u.symmetric=function(t){var e,n,i=t.length;if(t.length!==t[0].length)return!1;for(e=0;e<i;e++)for(n=0;n<i;n++)if(t[n][e]!==t[e][n])return!1;return!0},u.clear=function(t){return u.alter(t,c)},u.seq=function(t,e,n,i){a(i)||(i=!1);var o,r=[],l=s(t,e),u=(e*l-t*l)/((n-1)*l),c=t;for(o=0;c<=e&&o<n;c=(t*l+u*l*++o)/l)r.push(i?i(c,o):c);return r},u.arange=function(t,n,i){var o,s=[];if(i=i||1,n===e&&(n=t,t=0),t===n||0===i)return[];if(t<n&&i<0)return[];if(t>n&&i>0)return[];if(i>0)for(o=t;o<n;o+=i)s.push(o);else for(o=t;o>n;o+=i)s.push(o);return s},u.slice=function(){function t(t,n,i,o){var s,r=[],a=t.length;if(n===e&&i===e&&o===e)return u.copy(t);if(o=o||1,(n=(n=n||0)>=0?n:a+n)===(i=(i=i||t.length)>=0?i:a+i)||0===o)return[];if(n<i&&o<0)return[];if(n>i&&o>0)return[];if(o>0)for(s=n;s<i;s+=o)r.push(t[s]);else for(s=n;s>i;s+=o)r.push(t[s]);return r}return function(e,n){var i,o;return l((n=n||{}).row)?l(n.col)?e[n.row][n.col]:t(u.rowa(e,n.row),(i=n.col||{}).start,i.end,i.step):l(n.col)?t(u.cola(e,n.col),(o=n.row||{}).start,o.end,o.step):(o=n.row||{},i=n.col||{},t(e,o.start,o.end,o.step).map(function(e){return t(e,i.start,i.end,i.step)}))}}(),u.sliceAssign=function(n,i,o){var s,r;if(l(i.row)){if(l(i.col))return n[i.row][i.col]=o;i.col=i.col||{},i.col.start=i.col.start||0,i.col.end=i.col.end||n[0].length,i.col.step=i.col.step||1,s=u.arange(i.col.start,t.min(n.length,i.col.end),i.col.step);var a=i.row;return s.forEach(function(t,e){n[a][t]=o[e]}),n}if(l(i.col)){i.row=i.row||{},i.row.start=i.row.start||0,i.row.end=i.row.end||n.length,i.row.step=i.row.step||1,r=u.arange(i.row.start,t.min(n[0].length,i.row.end),i.row.step);var c=i.col;return r.forEach(function(t,e){n[t][c]=o[e]}),n}return o[0].length===e&&(o=[o]),i.row.start=i.row.start||0,i.row.end=i.row.end||n.length,i.row.step=i.row.step||1,i.col.start=i.col.start||0,i.col.end=i.col.end||n[0].length,i.col.step=i.col.step||1,r=u.arange(i.row.start,t.min(n.length,i.row.end),i.row.step),s=u.arange(i.col.start,t.min(n[0].length,i.col.end),i.col.step),r.forEach(function(t,e){s.forEach(function(i,s){n[t][i]=o[e][s]})}),n},u.diagonal=function(t){var e=u.zeros(t.length,t.length);return t.forEach(function(t,n){e[n][n]=t}),e},u.copy=function(t){return t.map(function(t){return l(t)?t:t.map(function(t){return t})})};var h=u.prototype;return h.length=0,h.push=Array.prototype.push,h.sort=Array.prototype.sort,h.splice=Array.prototype.splice,h.slice=Array.prototype.slice,h.toArray=function(){return this.length>1?i.call(this):i.call(this)[0]},h.map=function(t,e){return u(u.map(this,t,e))},h.cumreduce=function(t,e){return u(u.cumreduce(this,t,e))},h.alter=function(t){return u.alter(this,t),this},function(t){for(var e=0;e<t.length;e++)(function(t){h[t]=function(e){var n,i=this;return e?(setTimeout(function(){e.call(i,h[t].call(i))}),this):(n=u[t](this),r(n)?u(n):n)}})(t[e])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(t){for(var e=0;e<t.length;e++)(function(t){h[t]=function(e,n){var i=this;return n?(setTimeout(function(){n.call(i,h[t].call(i,e))}),this):u(u[t](this,e))}})(t[e])}("row col".split(" ")),function(t){for(var e=0;e<t.length;e++)(function(t){h[t]=function(){return u(u[t].apply(null,arguments))}})(t[e])}("create zeros ones rand identity".split(" ")),u}(Math),function(t,e){var n=t.utils.isFunction;function i(t,e){return t-e}function o(t,n,i){return e.max(n,e.min(t,i))}t.sum=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.sumsqrd=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n]*t[n];return e},t.sumsqerr=function(e){for(var n,i=t.mean(e),o=0,s=e.length;--s>=0;)o+=(n=e[s]-i)*n;return o},t.sumrow=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.product=function(t){for(var e=1,n=t.length;--n>=0;)e*=t[n];return e},t.min=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]<e&&(e=t[n]);return e},t.max=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]>e&&(e=t[n]);return e},t.unique=function(t){for(var e={},n=[],i=0;i<t.length;i++)e[t[i]]||(e[t[i]]=!0,n.push(t[i]));return n},t.mean=function(e){return t.sum(e)/e.length},t.meansqerr=function(e){return t.sumsqerr(e)/e.length},t.geomean=function(n){var i=n.map(e.log),o=t.mean(i);return e.exp(o)},t.median=function(t){var e=t.length,n=t.slice().sort(i);return 1&e?n[e/2|0]:(n[e/2-1]+n[e/2])/2},t.cumsum=function(e){return t.cumreduce(e,function(t,e){return t+e})},t.cumprod=function(e){return t.cumreduce(e,function(t,e){return t*e})},t.diff=function(t){var e,n=[],i=t.length;for(e=1;e<i;e++)n.push(t[e]-t[e-1]);return n},t.rank=function(t){var e,n=[],o={};for(e=0;e<t.length;e++)o[l=t[e]]?o[l]++:(o[l]=1,n.push(l));var s=n.sort(i),r={},a=1;for(e=0;e<s.length;e++){var l,u=o[l=s[e]],c=(a+(a+u-1))/2;r[l]=c,a+=u}return t.map(function(t){return r[t]})},t.mode=function(t){var e,n=t.length,o=t.slice().sort(i),s=1,r=0,a=0,l=[];for(e=0;e<n;e++)o[e]===o[e+1]?s++:(s>r?(l=[o[e]],r=s,a=0):s===r&&(l.push(o[e]),a++),s=1);return 0===a?l[0]:l},t.range=function(e){return t.max(e)-t.min(e)},t.variance=function(e,n){return t.sumsqerr(e)/(e.length-(n?1:0))},t.pooledvariance=function(e){return e.reduce(function(e,n){return e+t.sumsqerr(n)},0)/(e.reduce(function(t,e){return t+e.length},0)-e.length)},t.deviation=function(e){for(var n=t.mean(e),i=e.length,o=new Array(i),s=0;s<i;s++)o[s]=e[s]-n;return o},t.stdev=function(n,i){return e.sqrt(t.variance(n,i))},t.pooledstdev=function(n){return e.sqrt(t.pooledvariance(n))},t.meandev=function(n){for(var i=t.mean(n),o=[],s=n.length-1;s>=0;s--)o.push(e.abs(n[s]-i));return t.mean(o)},t.meddev=function(n){for(var i=t.median(n),o=[],s=n.length-1;s>=0;s--)o.push(e.abs(n[s]-i));return t.median(o)},t.coeffvar=function(e){return t.stdev(e)/t.mean(e)},t.quartiles=function(t){var n=t.length,o=t.slice().sort(i);return[o[e.round(n/4)-1],o[e.round(n/2)-1],o[e.round(3*n/4)-1]]},t.quantiles=function(t,n,s,r){var a,l,u,c,d,p=t.slice().sort(i),h=[n.length],f=t.length;for(void 0===s&&(s=3/8),void 0===r&&(r=3/8),a=0;a<n.length;a++)u=f*(l=n[a])+(s+l*(1-s-r)),c=e.floor(o(u,1,f-1)),d=o(u-c,0,1),h[a]=(1-d)*p[c-1]+d*p[c];return h},t.percentile=function(t,e,n){var o=t.slice().sort(i),s=e*(o.length+(n?1:-1))+(n?0:1),r=parseInt(s),a=s-r;return r+1<o.length?o[r-1]+a*(o[r]-o[r-1]):o[r-1]},t.percentileOfScore=function(t,e,n){var i,o,s=0,r=t.length,a=!1;for("strict"===n&&(a=!0),o=0;o<r;o++)i=t[o],(a&&i<e||!a&&i<=e)&&s++;return s/r},t.histogram=function(n,i){i=i||4;var o,s=t.min(n),r=(t.max(n)-s)/i,a=n.length,l=[];for(o=0;o<i;o++)l[o]=0;for(o=0;o<a;o++)l[e.min(e.floor((n[o]-s)/r),i-1)]+=1;return l},t.covariance=function(e,n){var i,o=t.mean(e),s=t.mean(n),r=e.length,a=new Array(r);for(i=0;i<r;i++)a[i]=(e[i]-o)*(n[i]-s);return t.sum(a)/(r-1)},t.corrcoeff=function(e,n){return t.covariance(e,n)/t.stdev(e,1)/t.stdev(n,1)},t.spearmancoeff=function(e,n){return e=t.rank(e),n=t.rank(n),t.corrcoeff(e,n)},t.stanMoment=function(n,i){for(var o=t.mean(n),s=t.stdev(n),r=n.length,a=0,l=0;l<r;l++)a+=e.pow((n[l]-o)/s,i);return a/n.length},t.skewness=function(e){return t.stanMoment(e,3)},t.kurtosis=function(e){return t.stanMoment(e,4)-3};var s=t.prototype;!function(e){for(var i=0;i<e.length;i++)(function(e){s[e]=function(i,o){var r=[],a=0,l=this;if(n(i)&&(o=i,i=!1),o)return setTimeout(function(){o.call(l,s[e].call(l,i))}),this;if(this.length>1){for(l=!0===i?this:this.transpose();a<l.length;a++)r[a]=t[e](l[a]);return r}return t[e](this[0],i)}})(e[i])}("cumsum cumprod".split(" ")),function(e){for(var i=0;i<e.length;i++)(function(e){s[e]=function(i,o){var r=[],a=0,l=this;if(n(i)&&(o=i,i=!1),o)return setTimeout(function(){o.call(l,s[e].call(l,i))}),this;if(this.length>1){for("sumrow"!==e&&(l=!0===i?this:this.transpose());a<l.length;a++)r[a]=t[e](l[a]);return!0===i?t[e](t.utils.toVector(r)):r}return t[e](this[0],i)}})(e[i])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(e){for(var i=0;i<e.length;i++)(function(e){s[e]=function(){var i,o=[],r=0,a=this,l=Array.prototype.slice.call(arguments);if(n(l[l.length-1])){i=l[l.length-1];var u=l.slice(0,l.length-1);return setTimeout(function(){i.call(a,s[e].apply(a,u))}),this}i=void 0;var c=function(n){return t[e].apply(a,[n].concat(l))};if(this.length>1){for(a=a.transpose();r<a.length;r++)o[r]=c(a[r]);return o}return c(this[0])}})(e[i])}("quantiles percentileOfScore".split(" "))}(e,Math),function(t,e){t.gammaln=function(t){var n,i,o,s=0,r=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],a=1.000000000190015;for(o=(i=n=t)+5.5,o-=(n+.5)*e.log(o);s<6;s++)a+=r[s]/++i;return e.log(2.5066282746310007*a/n)-o},t.loggam=function(t){var n,i,o,s,r,a,l,u=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=t,l=0,1==t||2==t)return 0;for(t<=7&&(n=t+(l=e.floor(7-t))),i=1/(n*n),o=2*e.PI,r=u[9],a=8;a>=0;a--)r*=i,r+=u[a];if(s=r/n+.5*e.log(o)+(n-.5)*e.log(n)-n,t<=7)for(a=1;a<=l;a++)s-=e.log(n-1),n-=1;return s},t.gammafn=function(t){var n,i,o,s,r=[-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],l=!1,u=0,c=0,d=0,p=t;if(t>171.6243769536076)return 1/0;if(p<=0){if(!(s=p%1+36e-17))return 1/0;l=(1&p?-1:1)*e.PI/e.sin(e.PI*s),p=1-p}for(o=p,i=p<1?p++:(p-=u=(0|p)-1)-1,n=0;n<8;++n)d=(d+r[n])*i,c=c*i+a[n];if(s=d/c+1,o<p)s/=o;else if(o>p)for(n=0;n<u;++n)s*=p,p++;return l&&(s=l/s),s},t.gammap=function(e,n){return t.lowRegGamma(e,n)*t.gammafn(e)},t.lowRegGamma=function(n,i){var o,s=t.gammaln(n),r=n,a=1/n,l=a,u=i+1-n,c=1/1e-30,d=1/u,p=d,h=1,f=-~(8.5*e.log(n>=1?n:1/n)+.4*n+17);if(i<0||n<=0)return NaN;if(i<n+1){for(;h<=f;h++)a+=l*=i/++r;return a*e.exp(-i+n*e.log(i)-s)}for(;h<=f;h++)p*=(d=1/(d=(o=-h*(h-n))*d+(u+=2)))*(c=u+o/c);return 1-p*e.exp(-i+n*e.log(i)-s)},t.factorialln=function(e){return e<0?NaN:t.gammaln(e+1)},t.factorial=function(e){return e<0?NaN:t.gammafn(e+1)},t.combination=function(n,i){return n>170||i>170?e.exp(t.combinationln(n,i)):t.factorial(n)/t.factorial(i)/t.factorial(n-i)},t.combinationln=function(e,n){return t.factorialln(e)-t.factorialln(n)-t.factorialln(e-n)},t.permutation=function(e,n){return t.factorial(e)/t.factorial(e-n)},t.betafn=function(n,i){if(!(n<=0||i<=0))return n+i>170?e.exp(t.betaln(n,i)):t.gammafn(n)*t.gammafn(i)/t.gammafn(n+i)},t.betaln=function(e,n){return t.gammaln(e)+t.gammaln(n)-t.gammaln(e+n)},t.betacf=function(t,n,i){var o,s,r,a,l=1e-30,u=1,c=n+i,d=n+1,p=n-1,h=1,f=1-c*t/d;for(e.abs(f)<l&&(f=l),a=f=1/f;u<=100&&(f=1+(s=u*(i-u)*t/((p+(o=2*u))*(n+o)))*f,e.abs(f)<l&&(f=l),h=1+s/h,e.abs(h)<l&&(h=l),a*=(f=1/f)*h,f=1+(s=-(n+u)*(c+u)*t/((n+o)*(d+o)))*f,e.abs(f)<l&&(f=l),h=1+s/h,e.abs(h)<l&&(h=l),a*=r=(f=1/f)*h,!(e.abs(r-1)<3e-7));u++);return a},t.gammapinv=function(n,i){var o,s,r,a,l,u,c=0,d=i-1,p=t.gammaln(i);if(n>=1)return e.max(100,i+100*e.sqrt(i));if(n<=0)return 0;for(i>1?(l=e.log(d),u=e.exp(d*(l-1)-p),a=n<.5?n:1-n,o=(2.30753+.27061*(s=e.sqrt(-2*e.log(a))))/(1+s*(.99229+.04481*s))-s,n<.5&&(o=-o),o=e.max(.001,i*e.pow(1-1/(9*i)-o/(3*e.sqrt(i)),3))):o=n<(s=1-i*(.253+.12*i))?e.pow(n/s,1/i):1-e.log(1-(n-s)/(1-s));c<12;c++){if(o<=0)return 0;if((o-=s=(r=(t.lowRegGamma(i,o)-n)/(s=i>1?u*e.exp(-(o-d)+d*(e.log(o)-l)):e.exp(-o+d*e.log(o)-p)))/(1-.5*e.min(1,r*((i-1)/o-1))))<=0&&(o=.5*(o+s)),e.abs(s)<1e-8*o)break}return o},t.erf=function(t){var n,i,o,s,r=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],a=r.length-1,l=!1,u=0,c=0;for(t<0&&(t=-t,l=!0),i=4*(n=2/(2+t))-2;a>0;a--)o=u,u=i*u-c+r[a],c=o;return s=n*e.exp(-t*t+.5*(r[0]+i*u)-c),l?s-1:1-s},t.erfc=function(e){return 1-t.erf(e)},t.erfcinv=function(n){var i,o,s,r,a=0;if(n>=2)return-100;if(n<=0)return 100;for(r=n<1?n:2-n,i=-.70711*((2.30753+.27061*(s=e.sqrt(-2*e.log(r/2))))/(1+s*(.99229+.04481*s))-s);a<2;a++)i+=(o=t.erfc(i)-r)/(1.1283791670955126*e.exp(-i*i)-i*o);return n<1?i:-i},t.ibetainv=function(n,i,o){var s,r,a,l,u,c,d,p,h,f,m=i-1,v=o-1,g=0;if(n<=0)return 0;if(n>=1)return 1;for(i>=1&&o>=1?(a=n<.5?n:1-n,c=(2.30753+.27061*(l=e.sqrt(-2*e.log(a))))/(1+l*(.99229+.04481*l))-l,n<.5&&(c=-c),d=(c*c-3)/6,p=2/(1/(2*i-1)+1/(2*o-1)),h=c*e.sqrt(d+p)/p-(1/(2*o-1)-1/(2*i-1))*(d+5/6-2/(3*p)),c=i/(i+o*e.exp(2*h))):(s=e.log(i/(i+o)),r=e.log(o/(i+o)),c=n<(l=e.exp(i*s)/i)/(h=l+(u=e.exp(o*r)/o))?e.pow(i*h*n,1/i):1-e.pow(o*h*(1-n),1/o)),f=-t.gammaln(i)-t.gammaln(o)+t.gammaln(i+o);g<10;g++){if(0===c||1===c)return c;if((c-=l=(u=(t.ibeta(c,i,o)-n)/(l=e.exp(m*e.log(c)+v*e.log(1-c)+f)))/(1-.5*e.min(1,u*(m/c-v/(1-c)))))<=0&&(c=.5*(c+l)),c>=1&&(c=.5*(c+l+1)),e.abs(l)<1e-8*c&&g>0)break}return c},t.ibeta=function(n,i,o){var s=0===n||1===n?0:e.exp(t.gammaln(i+o)-t.gammaln(i)-t.gammaln(o)+i*e.log(n)+o*e.log(1-n));return!(n<0||n>1)&&(n<(i+1)/(i+o+2)?s*t.betacf(n,i,o)/i:1-s*t.betacf(1-n,o,i)/o)},t.randn=function(n,i){var o,s,r,a,l;if(i||(i=n),n)return t.create(n,i,function(){return t.randn()});do{o=t._random_fn(),s=1.7156*(t._random_fn()-.5),l=(r=o-.449871)*r+(a=e.abs(s)+.386595)*(.196*a-.25472*r)}while(l>.27597&&(l>.27846||s*s>-4*e.log(o)*o*o));return s/o},t.randg=function(n,i,o){var s,r,a,l,u,c,d=n;if(o||(o=i),n||(n=1),i)return(c=t.zeros(i,o)).alter(function(){return t.randg(n)}),c;n<1&&(n+=1),s=n-1/3,r=1/e.sqrt(9*s);do{do{l=1+r*(u=t.randn())}while(l<=0);l*=l*l,a=t._random_fn()}while(a>1-.331*e.pow(u,4)&&e.log(a)>.5*u*u+s*(1-l+e.log(l)));if(n==d)return s*l;do{a=t._random_fn()}while(0===a);return e.pow(a,1/d)*s*l},function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(){return t(t.map(this,function(n){return t[e](n)}))}})(e[n])}("gammaln gammafn factorial factorialln".split(" ")),function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(){return t(t[e].apply(null,arguments))}})(e[n])}("randn".split(" "))}(e,Math),function(t,e){function n(t,n,i,o){for(var s,r=0,a=1,l=1,u=1,c=0,d=0;e.abs((l-d)/l)>o;)d=l,a=u+(s=-(n+c)*(n+i+c)*t/(n+2*c)/(n+2*c+1))*a,l=(r=l+s*r)+(s=(c+=1)*(i-c)*t/(n+2*c-1)/(n+2*c))*l,r/=u=a+s*u,a/=u,l/=u,u=1;return l/n}function i(n,i,o){var s=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],r=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],a=.5*n;if(a>=8)return 1;var l,u=2*t.normal.cdf(a,0,1,1,0)-1;u=u>=e.exp(-50/o)?e.pow(u,o):0;for(var c=a,d=(8-a)/(l=n>3?2:3),p=c+d,h=0,f=o-1,m=1;m<=l;m++){for(var v=0,g=.5*(p+c),y=.5*(p-c),b=1;b<=12;b++){var A,w=g+y*(6<b?s[(A=12-b+1)-1]:-s[(A=b)-1]),C=w*w;if(C>60)break;var I=2*t.normal.cdf(w,0,1,1,0)*.5-2*t.normal.cdf(w,n,1,1,0)*.5;I>=e.exp(-30/f)&&(v+=I=r[A-1]*e.exp(-.5*C)*e.pow(I,f))}h+=v*=2*y*o/e.sqrt(2*e.PI),c=p,p+=d}return(u+=h)<=e.exp(-30/i)?0:(u=e.pow(u,i))>=1?1:u}!function(e){for(var n=0;n<e.length;n++)(function(e){t[e]=function t(e,n,i){return this instanceof t?(this._a=e,this._b=n,this._c=i,this):new t(e,n,i)},t.fn[e]=function(n,i,o){var s=t[e](n,i,o);return s.data=this,s},t[e].prototype.sample=function(n){var i=this._a,o=this._b,s=this._c;return n?t.alter(n,function(){return t[e].sample(i,o,s)}):t[e].sample(i,o,s)},function(n){for(var i=0;i<n.length;i++)(function(n){t[e].prototype[n]=function(i){var o=this._a,s=this._b,r=this._c;return i||0===i||(i=this.data),"number"!=typeof i?t.fn.map.call(i,function(i){return t[e][n](i,o,s,r)}):t[e][n](i,o,s,r)}})(n[i])}("pdf cdf inv".split(" ")),function(n){for(var i=0;i<n.length;i++)(function(n){t[e].prototype[n]=function(){return t[e][n](this._a,this._b,this._c)}})(n[i])}("mean median mode variance".split(" "))})(e[n])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),t.extend(t.beta,{pdf:function(n,i,o){return n>1||n<0?0:1==i&&1==o?1:i<512&&o<512?e.pow(n,i-1)*e.pow(1-n,o-1)/t.betafn(i,o):e.exp((i-1)*e.log(n)+(o-1)*e.log(1-n)-t.betaln(i,o))},cdf:function(e,n,i){return e>1||e<0?1*(e>1):t.ibeta(e,n,i)},inv:function(e,n,i){return t.ibetainv(e,n,i)},mean:function(t,e){return t/(t+e)},median:function(e,n){return t.ibetainv(.5,e,n)},mode:function(t,e){return(t-1)/(t+e-2)},sample:function(e,n){var i=t.randg(e);return i/(i+t.randg(n))},variance:function(t,n){return t*n/(e.pow(t+n,2)*(t+n+1))}}),t.extend(t.centralF,{pdf:function(n,i,o){var s;return n<0?0:i<=2?0===n&&i<2?1/0:0===n&&2===i?1:1/t.betafn(i/2,o/2)*e.pow(i/o,i/2)*e.pow(n,i/2-1)*e.pow(1+i/o*n,-(i+o)/2):(s=i*n/(o+n*i),i*(o/(o+n*i))/2*t.binomial.pdf((i-2)/2,(i+o-2)/2,s))},cdf:function(e,n,i){return e<0?0:t.ibeta(n*e/(n*e+i),n/2,i/2)},inv:function(e,n,i){return i/(n*(1/t.ibetainv(e,n/2,i/2)-1))},mean:function(t,e){return e>2?e/(e-2):void 0},mode:function(t,e){return t>2?e*(t-2)/(t*(e+2)):void 0},sample:function(e,n){return 2*t.randg(e/2)/e/(2*t.randg(n/2)/n)},variance:function(t,e){if(!(e<=4))return 2*e*e*(t+e-2)/(t*(e-2)*(e-2)*(e-4))}}),t.extend(t.cauchy,{pdf:function(t,n,i){return i<0?0:i/(e.pow(t-n,2)+e.pow(i,2))/e.PI},cdf:function(t,n,i){return e.atan((t-n)/i)/e.PI+.5},inv:function(t,n,i){return n+i*e.tan(e.PI*(t-.5))},median:function(t){return t},mode:function(t){return t},sample:function(n,i){return t.randn()*e.sqrt(1/(2*t.randg(.5)))*i+n}}),t.extend(t.chisquare,{pdf:function(n,i){return n<0?0:0===n&&2===i?.5:e.exp((i/2-1)*e.log(n)-n/2-i/2*e.log(2)-t.gammaln(i/2))},cdf:function(e,n){return e<0?0:t.lowRegGamma(n/2,e/2)},inv:function(e,n){return 2*t.gammapinv(e,.5*n)},mean:function(t){return t},median:function(t){return t*e.pow(1-2/(9*t),3)},mode:function(t){return t-2>0?t-2:0},sample:function(e){return 2*t.randg(e/2)},variance:function(t){return 2*t}}),t.extend(t.exponential,{pdf:function(t,n){return t<0?0:n*e.exp(-n*t)},cdf:function(t,n){return t<0?0:1-e.exp(-n*t)},inv:function(t,n){return-e.log(1-t)/n},mean:function(t){return 1/t},median:function(t){return 1/t*e.log(2)},mode:function(){return 0},sample:function(n){return-1/n*e.log(t._random_fn())},variance:function(t){return e.pow(t,-2)}}),t.extend(t.gamma,{pdf:function(n,i,o){return n<0?0:0===n&&1===i?1/o:e.exp((i-1)*e.log(n)-n/o-t.gammaln(i)-i*e.log(o))},cdf:function(e,n,i){return e<0?0:t.lowRegGamma(n,e/i)},inv:function(e,n,i){return t.gammapinv(e,n)*i},mean:function(t,e){return t*e},mode:function(t,e){if(t>1)return(t-1)*e},sample:function(e,n){return t.randg(e)*n},variance:function(t,e){return t*e*e}}),t.extend(t.invgamma,{pdf:function(n,i,o){return n<=0?0:e.exp(-(i+1)*e.log(n)-o/n-t.gammaln(i)+i*e.log(o))},cdf:function(e,n,i){return e<=0?0:1-t.lowRegGamma(n,i/e)},inv:function(e,n,i){return i/t.gammapinv(1-e,n)},mean:function(t,e){return t>1?e/(t-1):void 0},mode:function(t,e){return e/(t+1)},sample:function(e,n){return n/t.randg(e)},variance:function(t,e){if(!(t<=2))return e*e/((t-1)*(t-1)*(t-2))}}),t.extend(t.kumaraswamy,{pdf:function(t,n,i){return 0===t&&1===n?i:1===t&&1===i?n:e.exp(e.log(n)+e.log(i)+(n-1)*e.log(t)+(i-1)*e.log(1-e.pow(t,n)))},cdf:function(t,n,i){return t<0?0:t>1?1:1-e.pow(1-e.pow(t,n),i)},inv:function(t,n,i){return e.pow(1-e.pow(1-t,1/i),1/n)},mean:function(e,n){return n*t.gammafn(1+1/e)*t.gammafn(n)/t.gammafn(1+1/e+n)},median:function(t,n){return e.pow(1-e.pow(2,-1/n),1/t)},mode:function(t,n){if(t>=1&&n>=1&&1!==t&&1!==n)return e.pow((t-1)/(t*n-1),1/t)},variance:function(){throw new Error("variance not yet implemented")}}),t.extend(t.lognormal,{pdf:function(t,n,i){return t<=0?0:e.exp(-e.log(t)-.5*e.log(2*e.PI)-e.log(i)-e.pow(e.log(t)-n,2)/(2*i*i))},cdf:function(n,i,o){return n<0?0:.5+.5*t.erf((e.log(n)-i)/e.sqrt(2*o*o))},inv:function(n,i,o){return e.exp(-1.4142135623730951*o*t.erfcinv(2*n)+i)},mean:function(t,n){return e.exp(t+n*n/2)},median:function(t){return e.exp(t)},mode:function(t,n){return e.exp(t-n*n)},sample:function(n,i){return e.exp(t.randn()*i+n)},variance:function(t,n){return(e.exp(n*n)-1)*e.exp(2*t+n*n)}}),t.extend(t.noncentralt,{pdf:function(n,i,o){return e.abs(o)<1e-14?t.studentt.pdf(n,i):e.abs(n)<1e-14?e.exp(t.gammaln((i+1)/2)-o*o/2-.5*e.log(e.PI*i)-t.gammaln(i/2)):i/n*(t.noncentralt.cdf(n*e.sqrt(1+2/i),i+2,o)-t.noncentralt.cdf(n,i,o))},cdf:function(n,i,o){var s=1e-14;if(e.abs(o)<s)return t.studentt.cdf(n,i);var r=!1;n<0&&(r=!0,o=-o);for(var a=t.normal.cdf(-o,0,1),l=s+1,u=l,c=n*n/(n*n+i),d=0,p=e.exp(-o*o/2),h=e.exp(-o*o/2-.5*e.log(2)-t.gammaln(1.5))*o;d<200||u>s||l>s;)u=l,d>0&&(p*=o*o/(2*d),h*=o*o/(2*(d+.5))),a+=.5*(l=p*t.beta.cdf(c,d+.5,i/2)+h*t.beta.cdf(c,d+1,i/2)),d++;return r?1-a:a}}),t.extend(t.normal,{pdf:function(t,n,i){return e.exp(-.5*e.log(2*e.PI)-e.log(i)-e.pow(t-n,2)/(2*i*i))},cdf:function(n,i,o){return.5*(1+t.erf((n-i)/e.sqrt(2*o*o)))},inv:function(e,n,i){return-1.4142135623730951*i*t.erfcinv(2*e)+n},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},sample:function(e,n){return t.randn()*n+e},variance:function(t,e){return e*e}}),t.extend(t.pareto,{pdf:function(t,n,i){return t<n?0:i*e.pow(n,i)/e.pow(t,i+1)},cdf:function(t,n,i){return t<n?0:1-e.pow(n/t,i)},inv:function(t,n,i){return n/e.pow(1-t,1/i)},mean:function(t,n){if(!(n<=1))return n*e.pow(t,n)/(n-1)},median:function(t,n){return t*(n*e.SQRT2)},mode:function(t){return t},variance:function(t,n){if(!(n<=2))return t*t*n/(e.pow(n-1,2)*(n-2))}}),t.extend(t.studentt,{pdf:function(n,i){return i=i>1e100?1e100:i,1/(e.sqrt(i)*t.betafn(.5,i/2))*e.pow(1+n*n/i,-(i+1)/2)},cdf:function(n,i){var o=i/2;return t.ibeta((n+e.sqrt(n*n+i))/(2*e.sqrt(n*n+i)),o,o)},inv:function(n,i){var o=t.ibetainv(2*e.min(n,1-n),.5*i,.5);return o=e.sqrt(i*(1-o)/o),n>.5?o:-o},mean:function(t){return t>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(n){return t.randn()*e.sqrt(n/(2*t.randg(n/2)))},variance:function(t){return t>2?t/(t-2):t>1?1/0:void 0}}),t.extend(t.weibull,{pdf:function(t,n,i){return t<0||n<0||i<0?0:i/n*e.pow(t/n,i-1)*e.exp(-e.pow(t/n,i))},cdf:function(t,n,i){return t<0?0:1-e.exp(-e.pow(t/n,i))},inv:function(t,n,i){return n*e.pow(-e.log(1-t),1/i)},mean:function(e,n){return e*t.gammafn(1+1/n)},median:function(t,n){return t*e.pow(e.log(2),1/n)},mode:function(t,n){return n<=1?0:t*e.pow((n-1)/n,1/n)},sample:function(n,i){return n*e.pow(-e.log(t._random_fn()),1/i)},variance:function(n,i){return n*n*t.gammafn(1+2/i)-e.pow(t.weibull.mean(n,i),2)}}),t.extend(t.uniform,{pdf:function(t,e,n){return t<e||t>n?0:1/(n-e)},cdf:function(t,e,n){return t<e?0:t<n?(t-e)/(n-e):1},inv:function(t,e,n){return e+t*(n-e)},mean:function(t,e){return.5*(t+e)},median:function(e,n){return t.mean(e,n)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(e,n){return e/2+n/2+(n/2-e/2)*(2*t._random_fn()-1)},variance:function(t,n){return e.pow(n-t,2)/12}}),t.extend(t.binomial,{pdf:function(n,i,o){return 0===o||1===o?i*o===n?1:0:t.combination(i,n)*e.pow(o,n)*e.pow(1-o,i-n)},cdf:function(i,o,s){var r,a=1e-10;if(i<0)return 0;if(i>=o)return 1;if(s<0||s>1||o<=0)return NaN;var l=s,u=(i=e.floor(i))+1,c=o-i,d=u+c,p=e.exp(t.gammaln(d)-t.gammaln(c)-t.gammaln(u)+u*e.log(l)+c*e.log(1-l));return r=l<(u+1)/(d+2)?p*n(l,u,c,a):1-p*n(1-l,c,u,a),e.round(1/a*(1-r))/(1/a)}}),t.extend(t.negbin,{pdf:function(n,i,o){return n===n>>>0&&(n<0?0:t.combination(n+i-1,i-1)*e.pow(1-o,n)*e.pow(o,i))},cdf:function(e,n,i){var o=0,s=0;if(e<0)return 0;for(;s<=e;s++)o+=t.negbin.pdf(s,n,i);return o}}),t.extend(t.hypgeom,{pdf:function(n,i,o,s){if(n!=n|0)return!1;if(n<0||n<o-(i-s))return 0;if(n>s||n>o)return 0;if(2*o>i)return 2*s>i?t.hypgeom.pdf(i-o-s+n,i,i-o,i-s):t.hypgeom.pdf(s-n,i,i-o,s);if(2*s>i)return t.hypgeom.pdf(o-n,i,o,i-s);if(o<s)return t.hypgeom.pdf(n,i,s,o);for(var r=1,a=0,l=0;l<n;l++){for(;r>1&&a<s;)r*=1-o/(i-a),a++;r*=(s-l)*(o-l)/((l+1)*(i-o-s+l+1))}for(;a<s;a++)r*=1-o/(i-a);return e.min(1,e.max(0,r))},cdf:function(n,i,o,s){if(n<0||n<o-(i-s))return 0;if(n>=s||n>=o)return 1;if(2*o>i)return 2*s>i?t.hypgeom.cdf(i-o-s+n,i,i-o,i-s):1-t.hypgeom.cdf(s-n-1,i,i-o,s);if(2*s>i)return 1-t.hypgeom.cdf(o-n-1,i,o,i-s);if(o<s)return t.hypgeom.cdf(n,i,s,o);for(var r=1,a=1,l=0,u=0;u<n;u++){for(;r>1&&l<s;){var c=1-o/(i-l);a*=c,r*=c,l++}r+=a*=(s-u)*(o-u)/((u+1)*(i-o-s+u+1))}for(;l<s;l++)r*=1-o/(i-l);return e.min(1,e.max(0,r))}}),t.extend(t.poisson,{pdf:function(n,i){return i<0||n%1!=0||n<0?0:e.pow(i,n)*e.exp(-i)/t.factorial(n)},cdf:function(e,n){var i=[],o=0;if(e<0)return 0;for(;o<=e;o++)i.push(t.poisson.pdf(o,n));return t.sum(i)},mean:function(t){return t},variance:function(t){return t},sampleSmall:function(n){var i=1,o=0,s=e.exp(-n);do{o++,i*=t._random_fn()}while(i>s);return o-1},sampleLarge:function(n){var i,o,s,r,a,l,u,c,d,p,h=n;for(r=e.sqrt(h),a=e.log(h),l=.02483*(u=.931+2.53*r)-.059,c=1.1239+1.1328/(u-3.4),d=.9277-3.6224/(u-2);;){if(o=e.random()-.5,s=e.random(),p=.5-e.abs(o),i=e.floor((2*l/p+u)*o+h+.43),p>=.07&&s<=d)return i;if(!(i<0||p<.013&&s>p)&&e.log(s)+e.log(c)-e.log(l/(p*p)+u)<=i*a-h-t.loggam(i+1))return i}},sample:function(t){return t<10?this.sampleSmall(t):this.sampleLarge(t)}}),t.extend(t.triangular,{pdf:function(t,e,n,i){return n<=e||i<e||i>n?NaN:t<e||t>n?0:t<i?2*(t-e)/((n-e)*(i-e)):t===i?2/(n-e):2*(n-t)/((n-e)*(n-i))},cdf:function(t,n,i,o){return i<=n||o<n||o>i?NaN:t<=n?0:t>=i?1:t<=o?e.pow(t-n,2)/((i-n)*(o-n)):1-e.pow(i-t,2)/((i-n)*(i-o))},inv:function(t,n,i,o){return i<=n||o<n||o>i?NaN:t<=(o-n)/(i-n)?n+(i-n)*e.sqrt(t*((o-n)/(i-n))):n+(i-n)*(1-e.sqrt((1-t)*(1-(o-n)/(i-n))))},mean:function(t,e,n){return(t+e+n)/3},median:function(t,n,i){return i<=(t+n)/2?n-e.sqrt((n-t)*(n-i))/e.sqrt(2):i>(t+n)/2?t+e.sqrt((n-t)*(i-t))/e.sqrt(2):void 0},mode:function(t,e,n){return n},sample:function(n,i,o){var s=t._random_fn();return s<(o-n)/(i-n)?n+e.sqrt(s*(i-n)*(o-n)):i-e.sqrt((1-s)*(i-n)*(i-o))},variance:function(t,e,n){return(t*t+e*e+n*n-t*e-t*n-e*n)/18}}),t.extend(t.arcsine,{pdf:function(t,n,i){return i<=n?NaN:t<=n||t>=i?0:2/e.PI*e.pow(e.pow(i-n,2)-e.pow(2*t-n-i,2),-.5)},cdf:function(t,n,i){return t<n?0:t<i?2/e.PI*e.asin(e.sqrt((t-n)/(i-n))):1},inv:function(t,n,i){return n+(.5-.5*e.cos(e.PI*t))*(i-n)},mean:function(t,e){return e<=t?NaN:(t+e)/2},median:function(t,e){return e<=t?NaN:(t+e)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(n,i){return(n+i)/2+(i-n)/2*e.sin(2*e.PI*t.uniform.sample(0,1))},variance:function(t,n){return n<=t?NaN:e.pow(n-t,2)/8}}),t.extend(t.laplace,{pdf:function(t,n,i){return i<=0?0:e.exp(-e.abs(t-n)/i)/(2*i)},cdf:function(t,n,i){return i<=0?0:t<n?.5*e.exp((t-n)/i):1-.5*e.exp(-(t-n)/i)},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},variance:function(t,e){return 2*e*e},sample:function(n,i){var o,s=t._random_fn()-.5;return n-i*((o=s)/e.abs(o))*e.log(1-2*e.abs(s))}}),t.extend(t.tukey,{cdf:function(n,o,s){var r=o,a=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],l=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(n<=0)return 0;if(s<2||r<2)return NaN;if(!Number.isFinite(n))return 1;if(s>25e3)return i(n,1,r);var u,c=.5*s,d=c*e.log(s)-s*e.log(2)-t.gammaln(c),p=c-1,h=.25*s;u=s<=100?1:s<=800?.5:s<=5e3?.25:.125,d+=e.log(u);for(var f=0,m=1;m<=50;m++){for(var v=0,g=(2*m-1)*u,y=1;y<=16;y++){var b,A;8<y?(b=y-8-1,A=d+p*e.log(g+a[b]*u)-(a[b]*u+g)*h):(b=y-1,A=d+p*e.log(g-a[b]*u)+(a[b]*u-g)*h),A>=-30&&(v+=i(8<y?n*e.sqrt(.5*(a[b]*u+g)):n*e.sqrt(.5*(-a[b]*u+g)),1,r)*l[b]*e.exp(A))}if(m*u>=1&&v<=1e-14)break;f+=v}if(v>1e-14)throw new Error("tukey.cdf failed to converge");return f>1&&(f=1),f},inv:function(n,i,o){if(o<2||i<2)return NaN;if(n<0||n>1)return NaN;if(0===n)return 0;if(1===n)return 1/0;var s,r=function(t,n,i){var o=.5-.5*t,s=e.sqrt(e.log(1/(o*o))),r=s+((((-453642210148e-16*s-.204231210125)*s-.342242088547)*s-1)*s+.322232421088)/((((.0038560700634*s+.10353775285)*s+.531103462366)*s+.588581570495)*s+.099348462606);i<120&&(r+=(r*r*r+r)/i/4);var a=.8832-.2368*r;return i<120&&(a+=-1.214/i+1.208*r/i),r*(a*e.log(n-1)+1.4142)}(n,i,o),a=t.tukey.cdf(r,i,o)-n;s=a>0?e.max(0,r-1):r+1;for(var l,u=t.tukey.cdf(s,i,o)-n,c=1;c<50;c++)if(l=s-u*(s-r)/(u-a),a=u,r=s,l<0&&(l=0,u=-n),u=t.tukey.cdf(l,i,o)-n,s=l,e.abs(s-r)<1e-4)return l;throw new Error("tukey.inv failed to converge")}})}(e,Math),function(t,e){var n,i,o=Array.prototype.push,s=t.utils.isArray;function r(e){return s(e)||e instanceof t}t.extend({add:function(e,n){return r(n)?(r(n[0])||(n=[n]),t.map(e,function(t,e,i){return t+n[e][i]})):t.map(e,function(t){return t+n})},subtract:function(e,n){return r(n)?(r(n[0])||(n=[n]),t.map(e,function(t,e,i){return t-n[e][i]||0})):t.map(e,function(t){return t-n})},divide:function(e,n){return r(n)?(r(n[0])||(n=[n]),t.multiply(e,t.inv(n))):t.map(e,function(t){return t/n})},multiply:function(e,n){var i,o,s,a,l,u,c,d;if(void 0===e.length&&void 0===n.length)return e*n;if(l=e.length,u=e[0].length,c=t.zeros(l,s=r(n)?n[0].length:u),d=0,r(n)){for(;d<s;d++)for(i=0;i<l;i++){for(a=0,o=0;o<u;o++)a+=e[i][o]*n[o][d];c[i][d]=a}return 1===l&&1===d?c[0][0]:c}return t.map(e,function(t){return t*n})},outer:function(e,n){return t.multiply(e.map(function(t){return[t]}),[n])},dot:function(e,n){r(e[0])||(e=[e]),r(n[0])||(n=[n]);for(var i,o,s=1===e[0].length&&1!==e.length?t.transpose(e):e,a=1===n[0].length&&1!==n.length?t.transpose(n):n,l=[],u=0,c=s.length,d=s[0].length;u<c;u++){for(l[u]=[],i=0,o=0;o<d;o++)i+=s[u][o]*a[u][o];l[u]=i}return 1===l.length?l[0]:l},pow:function(n,i){return t.map(n,function(t){return e.pow(t,i)})},exp:function(n){return t.map(n,function(t){return e.exp(t)})},log:function(n){return t.map(n,function(t){return e.log(t)})},abs:function(n){return t.map(n,function(t){return e.abs(t)})},norm:function(t,n){var i=0,o=0;for(isNaN(n)&&(n=2),r(t[0])&&(t=t[0]);o<t.length;o++)i+=e.pow(e.abs(t[o]),n);return e.pow(i,1/n)},angle:function(n,i){return e.acos(t.dot(n,i)/(t.norm(n)*t.norm(i)))},aug:function(t,e){var n,i=[];for(n=0;n<t.length;n++)i.push(t[n].slice());for(n=0;n<i.length;n++)o.apply(i[n],e[n]);return i},inv:function(e){for(var n,i=e.length,o=e[0].length,s=t.identity(i,o),r=t.gauss_jordan(e,s),a=[],l=0;l<i;l++)for(a[l]=[],n=o;n<r[0].length;n++)a[l][n-o]=r[l][n];return a},det:function t(e){if(2===e.length)return e[0][0]*e[1][1]-e[0][1]*e[1][0];for(var n=0,i=0;i<e.length;i++){for(var o=[],s=1;s<e.length;s++){o[s-1]=[];for(var r=0;r<e.length;r++)r<i?o[s-1][r]=e[s][r]:r>i&&(o[s-1][r-1]=e[s][r])}var a=i%2?-1:1;n+=t(o)*e[0][i]*a}return n},gauss_elimination:function(n,i){var o,s,r,a,l=0,u=0,c=n.length,d=n[0].length,p=1,h=0,f=[];for(o=(n=t.aug(n,i))[0].length,l=0;l<c;l++){for(s=n[l][l],u=l,a=l+1;a<d;a++)s<e.abs(n[a][l])&&(s=n[a][l],u=a);if(u!=l)for(a=0;a<o;a++)r=n[l][a],n[l][a]=n[u][a],n[u][a]=r;for(u=l+1;u<c;u++)for(p=n[u][l]/n[l][l],a=l;a<o;a++)n[u][a]=n[u][a]-p*n[l][a]}for(l=c-1;l>=0;l--){for(h=0,u=l+1;u<=c-1;u++)h+=f[u]*n[l][u];f[l]=(n[l][o-1]-h)/n[l][l]}return f},gauss_jordan:function(n,i){var o,s,r,a=t.aug(n,i),l=a.length,u=a[0].length,c=0;for(s=0;s<l;s++){var d=s;for(r=s+1;r<l;r++)e.abs(a[r][s])>e.abs(a[d][s])&&(d=r);var p=a[s];for(a[s]=a[d],a[d]=p,r=s+1;r<l;r++)for(c=a[r][s]/a[s][s],o=s;o<u;o++)a[r][o]-=a[s][o]*c}for(s=l-1;s>=0;s--){for(c=a[s][s],r=0;r<s;r++)for(o=u-1;o>s-1;o--)a[r][o]-=a[s][o]*a[r][s]/c;for(a[s][s]/=c,o=l;o<u;o++)a[s][o]/=c}return a},triaUpSolve:function(e,n){var i,o=e[0].length,s=t.zeros(1,o)[0],r=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),r=!0),t.arange(o-1,-1,-1).forEach(function(r){i=t.arange(r+1,o).map(function(t){return s[t]*e[r][t]}),s[r]=(n[r]-t.sum(i))/e[r][r]}),r?s.map(function(t){return[t]}):s},triaLowSolve:function(e,n){var i,o=e[0].length,s=t.zeros(1,o)[0],r=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),r=!0),t.arange(o).forEach(function(o){i=t.arange(o).map(function(t){return e[o][t]*s[t]}),s[o]=(n[o]-t.sum(i))/e[o][o]}),r?s.map(function(t){return[t]}):s},lu:function(e){var n,i=e.length,o=t.identity(i),s=t.zeros(e.length,e[0].length);return t.arange(i).forEach(function(t){s[0][t]=e[0][t]}),t.arange(1,i).forEach(function(r){t.arange(r).forEach(function(i){n=t.arange(i).map(function(t){return o[r][t]*s[t][i]}),o[r][i]=(e[r][i]-t.sum(n))/s[i][i]}),t.arange(r,i).forEach(function(i){n=t.arange(r).map(function(t){return o[r][t]*s[t][i]}),s[r][i]=e[n.length][i]-t.sum(n)})}),[o,s]},cholesky:function(n){var i,o=n.length,s=t.zeros(n.length,n[0].length);return t.arange(o).forEach(function(r){i=t.arange(r).map(function(t){return e.pow(s[r][t],2)}),s[r][r]=e.sqrt(n[r][r]-t.sum(i)),t.arange(r+1,o).forEach(function(e){i=t.arange(r).map(function(t){return s[r][t]*s[e][t]}),s[e][r]=(n[r][e]-t.sum(i))/s[r][r]})}),s},gauss_jacobi:function(n,i,o,s){for(var r,a,l,u,c=0,d=0,p=n.length,h=[],f=[],m=[];c<p;c++)for(h[c]=[],f[c]=[],m[c]=[],d=0;d<p;d++)c>d?(h[c][d]=n[c][d],f[c][d]=m[c][d]=0):c<d?(f[c][d]=n[c][d],h[c][d]=m[c][d]=0):(m[c][d]=n[c][d],h[c][d]=f[c][d]=0);for(l=t.multiply(t.multiply(t.inv(m),t.add(h,f)),-1),a=t.multiply(t.inv(m),i),r=o,u=t.add(t.multiply(l,o),a),c=2;e.abs(t.norm(t.subtract(u,r)))>s;)r=u,u=t.add(t.multiply(l,r),a),c++;return u},gauss_seidel:function(n,i,o,s){for(var r,a,l,u,c,d=0,p=n.length,h=[],f=[],m=[];d<p;d++)for(h[d]=[],f[d]=[],m[d]=[],r=0;r<p;r++)d>r?(h[d][r]=n[d][r],f[d][r]=m[d][r]=0):d<r?(f[d][r]=n[d][r],h[d][r]=m[d][r]=0):(m[d][r]=n[d][r],h[d][r]=f[d][r]=0);for(u=t.multiply(t.multiply(t.inv(t.add(m,h)),f),-1),l=t.multiply(t.inv(t.add(m,h)),i),a=o,c=t.add(t.multiply(u,o),l),d=2;e.abs(t.norm(t.subtract(c,a)))>s;)a=c,c=t.add(t.multiply(u,a),l),d+=1;return c},SOR:function(n,i,o,s,r){for(var a,l,u,c,d,p=0,h=n.length,f=[],m=[],v=[];p<h;p++)for(f[p]=[],m[p]=[],v[p]=[],a=0;a<h;a++)p>a?(f[p][a]=n[p][a],m[p][a]=v[p][a]=0):p<a?(m[p][a]=n[p][a],f[p][a]=v[p][a]=0):(v[p][a]=n[p][a],f[p][a]=m[p][a]=0);for(c=t.multiply(t.inv(t.add(v,t.multiply(f,r))),t.subtract(t.multiply(v,1-r),t.multiply(m,r))),u=t.multiply(t.multiply(t.inv(t.add(v,t.multiply(f,r))),i),r),l=o,d=t.add(t.multiply(c,o),u),p=2;e.abs(t.norm(t.subtract(d,l)))>s;)l=d,d=t.add(t.multiply(c,l),u),p++;return d},householder:function(n){for(var i,o,s,r,a=n.length,l=n[0].length,u=0,c=[],d=[];u<a-1;u++){for(i=0,r=u+1;r<l;r++)i+=n[r][u]*n[r][u];for(i=(n[u+1][u]>0?-1:1)*e.sqrt(i),o=e.sqrt((i*i-n[u+1][u]*i)/2),(c=t.zeros(a,1))[u+1][0]=(n[u+1][u]-i)/(2*o),s=u+2;s<a;s++)c[s][0]=n[s][u]/(2*o);d=t.subtract(t.identity(a,l),t.multiply(t.multiply(c,t.transpose(c)),2)),n=t.multiply(d,t.multiply(n,d))}return n},QR:(n=t.sum,i=t.arange,function(o){var s,r,a,l=o.length,u=o[0].length,c=t.zeros(u,u);for(o=t.copy(o),r=0;r<u;r++){for(c[r][r]=e.sqrt(n(i(l).map(function(t){return o[t][r]*o[t][r]}))),s=0;s<l;s++)o[s][r]=o[s][r]/c[r][r];for(a=r+1;a<u;a++)for(c[r][a]=n(i(l).map(function(t){return o[t][r]*o[t][a]})),s=0;s<l;s++)o[s][a]=o[s][a]-o[s][r]*c[r][a]}return[o,c]}),lstsq:function(e,n){var i=!1;void 0===n[0].length&&(n=n.map(function(t){return[t]}),i=!0);var o=t.QR(e),s=o[0],r=o[1],a=e[0].length,l=t.slice(s,{col:{end:a}}),u=function(e){var n=(e=t.copy(e)).length,i=t.identity(n);return t.arange(n-1,-1,-1).forEach(function(n){t.sliceAssign(i,{row:n},t.divide(t.slice(i,{row:n}),e[n][n])),t.sliceAssign(e,{row:n},t.divide(t.slice(e,{row:n}),e[n][n])),t.arange(n).forEach(function(o){var s=t.multiply(e[o][n],-1),r=t.slice(e,{row:o}),a=t.multiply(t.slice(e,{row:n}),s);t.sliceAssign(e,{row:o},t.add(r,a));var l=t.slice(i,{row:o}),u=t.multiply(t.slice(i,{row:n}),s);t.sliceAssign(i,{row:o},t.add(l,u))})}),i}(t.slice(r,{row:{end:a}})),c=t.transpose(l);void 0===c[0].length&&(c=[c]);var d=t.multiply(t.multiply(u,c),n);return void 0===d.length&&(d=[[d]]),i?d.map(function(t){return t[0]}):d},jacobi:function(n){for(var i,o,s,r,a,l,u,c=1,d=n.length,p=t.identity(d,d),h=[];1===c;){for(a=n[0][1],s=0,r=1,i=0;i<d;i++)for(o=0;o<d;o++)i!=o&&a<e.abs(n[i][o])&&(a=e.abs(n[i][o]),s=i,r=o);for(l=n[s][s]===n[r][r]?n[s][r]>0?e.PI/4:-e.PI/4:e.atan(2*n[s][r]/(n[s][s]-n[r][r]))/2,(u=t.identity(d,d))[s][s]=e.cos(l),u[s][r]=-e.sin(l),u[r][s]=e.sin(l),u[r][r]=e.cos(l),p=t.multiply(p,u),n=t.multiply(t.multiply(t.inv(u),n),u),c=0,i=1;i<d;i++)for(o=1;o<d;o++)i!=o&&e.abs(n[i][o])>.001&&(c=1)}for(i=0;i<d;i++)h.push(n[i][i]);return[p,h]},rungekutta:function(t,e,n,i,o,s){var r,a,l;if(2===s)for(;i<=n;)o+=((r=e*t(i,o))+(a=e*t(i+e,o+r)))/2,i+=e;if(4===s)for(;i<=n;)o+=((r=e*t(i,o))+2*(a=e*t(i+e/2,o+r/2))+2*(l=e*t(i+e/2,o+a/2))+e*t(i+e,o+l))/6,i+=e;return o},romberg:function(t,n,i,o){for(var s,r,a,l,u,c=0,d=(i-n)/2,p=[],h=[],f=[];c<o/2;){for(u=t(n),a=n,l=0;a<=i;a+=d,l++)p[l]=a;for(s=p.length,a=1;a<s-1;a++)u+=(a%2!=0?4:2)*t(p[a]);u=d/3*(u+t(i)),f[c]=u,d/=2,c++}for(r=f.length,s=1;1!==r;){for(a=0;a<r-1;a++)h[a]=(e.pow(4,s)*f[a+1]-f[a])/(e.pow(4,s)-1);r=h.length,f=h,h=[],s++}return f},richardson:function(t,n,i,o){function s(t,e){for(var n,i=0,o=t.length;i<o;i++)t[i]===e&&(n=i);return n}for(var r,a,l,u,c,d=e.abs(i-t[s(t,i)+1]),p=0,h=[],f=[];o>=d;)r=s(t,i+o),a=s(t,i),h[p]=(n[r]-2*n[a]+n[2*a-r])/(o*o),o/=2,p++;for(u=h.length,l=1;1!=u;){for(c=0;c<u-1;c++)f[c]=(e.pow(4,l)*h[c+1]-h[c])/(e.pow(4,l)-1);u=f.length,h=f,f=[],l++}return h},simpson:function(t,e,n,i){for(var o,s=(n-e)/i,r=t(e),a=[],l=e,u=0,c=1;l<=n;l+=s,u++)a[u]=l;for(o=a.length;c<o-1;c++)r+=(c%2!=0?4:2)*t(a[c]);return s/3*(r+t(n))},hermite:function(t,e,n,i){for(var o,s=t.length,r=0,a=0,l=[],u=[],c=[],d=[];a<s;a++){for(l[a]=1,o=0;o<s;o++)a!=o&&(l[a]*=(i-t[o])/(t[a]-t[o]));for(u[a]=0,o=0;o<s;o++)a!=o&&(u[a]+=1/(t[a]-t[o]));c[a]=(1-2*(i-t[a])*u[a])*(l[a]*l[a]),d[a]=(i-t[a])*(l[a]*l[a]),r+=c[a]*e[a]+d[a]*n[a]}return r},lagrange:function(t,e,n){for(var i,o,s=0,r=0,a=t.length;r<a;r++){for(o=e[r],i=0;i<a;i++)r!=i&&(o*=(n-t[i])/(t[r]-t[i]));s+=o}return s},cubic_spline:function(e,n,i){for(var o,s,r=e.length,a=0,l=[],u=[],c=[],d=[],p=[],h=[];a<r-1;a++)d[a]=e[a+1]-e[a];for(c[0]=0,a=1;a<r-1;a++)c[a]=3/d[a]*(n[a+1]-n[a])-3/d[a-1]*(n[a]-n[a-1]);for(a=1;a<r-1;a++)l[a]=[],u[a]=[],l[a][a-1]=d[a-1],l[a][a]=2*(d[a-1]+d[a]),l[a][a+1]=d[a],u[a][0]=c[a];for(s=t.multiply(t.inv(l),u),o=0;o<r-1;o++)p[o]=(n[o+1]-n[o])/d[o]-d[o]*(s[o+1][0]+2*s[o][0])/3,h[o]=(s[o+1][0]-s[o][0])/(3*d[o]);for(o=0;o<r&&!(e[o]>i);o++);return n[o-=1]+(i-e[o])*p[o]+t.sq(i-e[o])*s[o]+(i-e[o])*t.sq(i-e[o])*h[o]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(e){var n,i,o,s,r,a=e.length,l=e[0].length,u=0,c=[],d=[],p=[],h=[],f=[],m=[],v=[];for(u=0;u<a;u++)c[u]=t.sum(e[u])/l;for(u=0;u<l;u++)for(f[u]=[],n=0;n<a;n++)f[u][n]=e[n][u]-c[n];for(f=t.transpose(f),u=0;u<a;u++)for(m[u]=[],n=0;n<a;n++)m[u][n]=t.dot([f[u]],[f[n]])/(l-1);for(r=(o=t.jacobi(m))[0],d=o[1],v=t.transpose(r),u=0;u<d.length;u++)for(n=u;n<d.length;n++)d[u]<d[n]&&(i=d[u],d[u]=d[n],d[n]=i,p=v[u],v[u]=v[n],v[n]=p);for(s=t.transpose(f),u=0;u<a;u++)for(h[u]=[],n=0;n<s.length;n++)h[u][n]=t.dot([v[u]],[s[n]]);return[e,d,v,h]}}),function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(n,i){var o=this;return i?(setTimeout(function(){i.call(o,t.fn[e].call(o,n))},15),this):"number"==typeof t[e](this,n)?t[e](this,n):t(t[e](this,n))}})(e[n])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(e,Math),function(t,e){var n=[].slice,i=t.utils.isNumber,o=t.utils.isArray;function s(t,n,i,o){if(t>1||i>1||t<=0||i<=0)throw new Error("Proportions should be greater than 0 and less than 1");var s=(t*n+i*o)/(n+o);return(t-i)/e.sqrt(s*(1-s)*(1/n+1/o))}t.extend({zscore:function(){var e=n.call(arguments);return i(e[1])?(e[0]-e[1])/e[2]:(e[0]-t.mean(e[1]))/t.stdev(e[1],e[2])},ztest:function(){var i,s=n.call(arguments);return o(s[1])?(i=t.zscore(s[0],s[1],s[3]),1===s[2]?t.normal.cdf(-e.abs(i),0,1):2*t.normal.cdf(-e.abs(i),0,1)):s.length>2?(i=t.zscore(s[0],s[1],s[2]),1===s[3]?t.normal.cdf(-e.abs(i),0,1):2*t.normal.cdf(-e.abs(i),0,1)):(i=s[0],1===s[1]?t.normal.cdf(-e.abs(i),0,1):2*t.normal.cdf(-e.abs(i),0,1))}}),t.extend(t.fn,{zscore:function(t,e){return(t-this.mean())/this.stdev(e)},ztest:function(n,i,o){var s=e.abs(this.zscore(n,o));return 1===i?t.normal.cdf(-s,0,1):2*t.normal.cdf(-s,0,1)}}),t.extend({tscore:function(){var i=n.call(arguments);return 4===i.length?(i[0]-i[1])/(i[2]/e.sqrt(i[3])):(i[0]-t.mean(i[1]))/(t.stdev(i[1],!0)/e.sqrt(i[1].length))},ttest:function(){var o,s=n.call(arguments);return 5===s.length?(o=e.abs(t.tscore(s[0],s[1],s[2],s[3])),1===s[4]?t.studentt.cdf(-o,s[3]-1):2*t.studentt.cdf(-o,s[3]-1)):i(s[1])?(o=e.abs(s[0]),1==s[2]?t.studentt.cdf(-o,s[1]-1):2*t.studentt.cdf(-o,s[1]-1)):(o=e.abs(t.tscore(s[0],s[1])),1==s[2]?t.studentt.cdf(-o,s[1].length-1):2*t.studentt.cdf(-o,s[1].length-1))}}),t.extend(t.fn,{tscore:function(t){return(t-this.mean())/(this.stdev(!0)/e.sqrt(this.cols()))},ttest:function(n,i){return 1===i?1-t.studentt.cdf(e.abs(this.tscore(n)),this.cols()-1):2*t.studentt.cdf(-e.abs(this.tscore(n)),this.cols()-1)}}),t.extend({anovafscore:function(){var i,o,s,r,a,l,u,c,d=n.call(arguments);if(1===d.length){for(a=new Array(d[0].length),u=0;u<d[0].length;u++)a[u]=d[0][u];d=a}for(o=new Array,u=0;u<d.length;u++)o=o.concat(d[u]);for(s=t.mean(o),i=0,u=0;u<d.length;u++)i+=d[u].length*e.pow(t.mean(d[u])-s,2);for(i/=d.length-1,l=0,u=0;u<d.length;u++)for(r=t.mean(d[u]),c=0;c<d[u].length;c++)l+=e.pow(d[u][c]-r,2);return i/(l/(o.length-d.length))},anovaftest:function(){var e,o,s,r,a=n.call(arguments);if(i(a[0]))return 1-t.centralF.cdf(a[0],a[1],a[2]);var l=t.anovafscore(a);for(e=a.length-1,s=0,r=0;r<a.length;r++)s+=a[r].length;return o=s-e-1,1-t.centralF.cdf(l,e,o)},ftest:function(e,n,i){return 1-t.centralF.cdf(e,n,i)}}),t.extend(t.fn,{anovafscore:function(){return t.anovafscore(this.toArray())},anovaftes:function(){var e,n=0;for(e=0;e<this.length;e++)n+=this[e].length;return t.ftest(this.anovafscore(),this.length-1,n-this.length)}}),t.extend({qscore:function(){var o,s,r,a,l,u=n.call(arguments);return i(u[0])?(o=u[0],s=u[1],r=u[2],a=u[3],l=u[4]):(o=t.mean(u[0]),s=t.mean(u[1]),r=u[0].length,a=u[1].length,l=u[2]),e.abs(o-s)/(l*e.sqrt((1/r+1/a)/2))},qtest:function(){var e,i=n.call(arguments);3===i.length?(e=i[0],i=i.slice(1)):7===i.length?(e=t.qscore(i[0],i[1],i[2],i[3],i[4]),i=i.slice(5)):(e=t.qscore(i[0],i[1],i[2]),i=i.slice(3));var o=i[0],s=i[1];return 1-t.tukey.cdf(e,s,o-s)},tukeyhsd:function(e){for(var n=t.pooledstdev(e),i=e.map(function(e){return t.mean(e)}),o=e.reduce(function(t,e){return t+e.length},0),s=[],r=0;r<e.length;++r)for(var a=r+1;a<e.length;++a){var l=t.qtest(i[r],i[a],e[r].length,e[a].length,n,o,e.length);s.push([[r,a],l])}return s}}),t.extend({normalci:function(){var i,o=n.call(arguments),s=new Array(2);return i=4===o.length?e.abs(t.normal.inv(o[1]/2,0,1)*o[2]/e.sqrt(o[3])):e.abs(t.normal.inv(o[1]/2,0,1)*t.stdev(o[2])/e.sqrt(o[2].length)),s[0]=o[0]-i,s[1]=o[0]+i,s},tci:function(){var i,o=n.call(arguments),s=new Array(2);return i=4===o.length?e.abs(t.studentt.inv(o[1]/2,o[3]-1)*o[2]/e.sqrt(o[3])):e.abs(t.studentt.inv(o[1]/2,o[2].length-1)*t.stdev(o[2],!0)/e.sqrt(o[2].length)),s[0]=o[0]-i,s[1]=o[0]+i,s},significant:function(t,e){return t<e}}),t.extend(t.fn,{normalci:function(e,n){return t.normalci(e,n,this.toArray())},tci:function(e,n){return t.tci(e,n,this.toArray())}}),t.extend(t.fn,{oneSidedDifferenceOfProportions:function(e,n,i,o){var r=s(e,n,i,o);return t.ztest(r,1)},twoSidedDifferenceOfProportions:function(e,n,i,o){var r=s(e,n,i,o);return t.ztest(r,2)}})}(e,Math),e.models=function(){function t(t,n){var i=t.length,o=n[0].length-1,s=i-o-1,r=e.lstsq(n,t),a=e.multiply(n,r.map(function(t){return[t]})).map(function(t){return t[0]}),l=e.subtract(t,a),u=e.mean(t),c=e.sum(a.map(function(t){return Math.pow(t-u,2)})),d=e.sum(t.map(function(t,e){return Math.pow(t-a[e],2)})),p=c+d;return{exog:n,endog:t,nobs:i,df_model:o,df_resid:s,coef:r,predict:a,resid:l,ybar:u,SST:p,SSE:c,SSR:d,R2:c/p}}function n(n){var i,o,s=(i=n.exog,o=i[0].length,e.arange(o).map(function(n){var s=e.arange(o).filter(function(t){return t!==n});return t(e.col(i,n).map(function(t){return t[0]}),e.col(i,s))})),r=Math.sqrt(n.SSR/n.df_resid),a=s.map(function(t){var e=t.SST,n=t.R2;return r/Math.sqrt(e*(1-n))}),l=n.coef.map(function(t,e){return(t-0)/a[e]}),u=l.map(function(t){var i=e.studentt.cdf(t,n.df_resid);return 2*(i>.5?1-i:i)}),c=e.studentt.inv(.975,n.df_resid),d=n.coef.map(function(t,e){var n=c*a[e];return[t-n,t+n]});return{se:a,t:l,p:u,sigmaHat:r,interval95:d}}return{ols:function(i,o){var s=t(i,o),r=n(s),a=function(t){var n,i,o,s=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:s,pvalue:1-(n=s,i=t.df_model,o=t.df_resid,e.beta.cdf(n/(o/i+n),i/2,o/2))}}(s),l=1-(1-s.R2)*((s.nobs-1)/s.df_resid);return s.t=r,s.f=a,s.adjust_R2=l,s}}}(),e.extend({buildxmatrix:function(){for(var t=new Array(arguments.length),n=0;n<arguments.length;n++){t[n]=[1].concat(arguments[n])}return e(t)},builddxmatrix:function(){for(var t=new Array(arguments[0].length),n=0;n<arguments[0].length;n++){t[n]=[1].concat(arguments[0][n])}return e(t)},buildjxmatrix:function(t){for(var n=new Array(t.length),i=0;i<t.length;i++)n[i]=t[i];return e.builddxmatrix(n)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(t){return t.transpose()},matrixmult:function(t,n){var i,o,s,r,a;if(t.cols()==n.rows()){if(n.rows()>1){for(r=[],i=0;i<t.rows();i++)for(r[i]=[],o=0;o<n.cols();o++){for(a=0,s=0;s<t.cols();s++)a+=t.toArray()[i][s]*n.toArray()[s][o];r[i][o]=a}return e(r)}for(r=[],i=0;i<t.rows();i++)for(r[i]=[],o=0;o<n.cols();o++){for(a=0,s=0;s<t.cols();s++)a+=t.toArray()[i][s]*n.toArray()[o];r[i][o]=a}return e(r)}},regress:function(t,n){var i=e.xtranspxinv(t),o=t.transpose(),s=e.matrixmult(e(i),o);return e.matrixmult(s,n)},regresst:function(t,n,i){var o=e.regress(t,n),s={anova:{}},r=e.jMatYBar(t,o);s.yBar=r;var a=n.mean();s.anova.residuals=e.residuals(n,r),s.anova.ssr=e.ssr(r,a),s.anova.msr=s.anova.ssr/(t[0].length-1),s.anova.sse=e.sse(n,r),s.anova.mse=s.anova.sse/(n.length-(t[0].length-1)-1),s.anova.sst=e.sst(n,a),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=new Array(t[0].length);for(var l,u,c,d=e.xtranspxinv(t),p=0;p<o.length;p++)l=Math.sqrt(s.anova.mse*Math.abs(d[p][p])),u=Math.abs(o[p]/l),c=e.ttest(u,n.length-t[0].length-1,i),s.stats[p]=[o[p],l,u,c];return s.regress=o,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 i=e.matrixmult(t,n);return new e(i)},residuals:function(t,n){return e.matrixsubtract(t,n)},ssr:function(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e,2);return n},sse:function(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return n},sst:function(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e,2);return n},matrixsubtract:function(t,n){for(var i=new Array(t.length),o=0;o<t.length;o++){i[o]=new Array(t[o].length);for(var s=0;s<t[o].length;s++)i[o][s]=t[o][s]-n[o][s]}return e(i)}}),e.jStat=e,e)},9373:(t,e,n)=>{"use strict";n(1340),n(4570),n(7423)},9524:(t,e,n)=>{"use strict";n.d(e,{a:()=>u});var i=n(4328),o=n(6082),s=n(9939),r=n(1991),a=n.n(r),l=(n(7376),function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})});class u extends o.CustomCardView{static findOrCreateCatalogView(t){var e;return null!==(e=this.findModelCatalogView(t))&&void 0!==e?e:this.createModelCatalogView(t)}static createModelCatalogView(t){return new this(t)}static findModelCatalogView(t){return a()(i.shell.views).find(e=>e.name==t)}static bindModel(t,e){e.aux.showOnTaskBar=!1;const n=t.parentCall;null!=n&&(n.aux.view=t,e.parentCall=n)}constructor(t){super({dataSource:i.dapi.functions,permanentFilter:"#model"}),this.root.classList.add("model-catalog-view"),this.meta=new s.s,this.name=t,this.permanentFilter="#model",this.renderMode=o.RENDER_MODE.BRIEF,this.objectType="Func",this.categoryFilters={"options.department":"Department","options.HL_process":"HL_process","options.process":"Process",tag:"Tags"},this.filters={All:"",Favorites:"starredBy = @current","Used by me":"usedBy = @current"},this.hierarchy=["options.department","options.HL_process","options.process"],this.hierarchyProperties={"options.department":"Department","options.HL_process":"HL_process","options.process":"Process"},this.showTree=!0,this.initRibbon(),this.initMenu(),i.shell.windows.showProperties=!1}initRibbon(){return l(this,void 0,void 0,function*(){})}initMenu(){return l(this,void 0,void 0,function*(){const t=[{name:"Developing Scripts",link:"https://datagrok.ai/help/compute/scripting"},{name:"Developing Workflows",link:"https://datagrok.ai/help/compute/workflows"}],e=yield this.getClientSpecificHelp();let n=this.ribbonMenu.group("Help");for(const i of[...t,...e])n=n.item(i.name,()=>window.open(i.link,"_blank"));n.endGroup()})}getClientSpecificHelp(){return l(this,void 0,void 0,function*(){var t,e;const n=null===(t=o.Func.find({package:"ModelHub",name:"getHelpItems"}))||void 0===t?void 0:t[0];if(!n)return[];const i=n.prepare();return yield i.call(void 0,void 0,{processed:!0,report:!1}),null!==(e=i.getOutputParamValue())&&void 0!==e?e:[]})}}},9530:(t,e,n)=>{"use strict";var i=n(6186),o=n.n(i),s=n(2155),r=n.n(s),a=n(7433),l=n.n(a),u=n(8626),c=n.n(u),d=n(8990),p=n.n(d),h=n(9827),f=n.n(h),m=n(6124),v={};v.styleTagTransform=f(),v.setAttributes=c(),v.insert=l().bind(null,"head"),v.domAPI=r(),v.insertStyleElement=p(),o()(m.A,v),m.A&&m.A.locals&&m.A.locals},9579:(t,e,n)=>{"use strict";n.d(e,{D:()=>l});var i=n(9234),o=n(1005),s=n(804),r=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};function a(t){return new Promise((e,n)=>setTimeout(e,t))}class l{constructor(t,e,n,i=o.a$,s){this.progrIndicator=void 0,this.objective=t,this.inputOpts=e,this.outputDim=n,this.methodOpts=i,this.progrIndicator=s}weightedSum(t,e){return r(this,void 0,void 0,function*(){let n=0;const i=yield this.objective(t);for(let t=0;t<this.outputDim;++t)n+=e[t]*i[t];return n})}generateWeights(){const t=this.methodOpts.nWeights,e=new Array(t+1);for(let n=0;n<=t;++n){const i=new Float32Array(this.outputDim);let o=1;for(let e=0;e<this.outputDim-1;++e)i[e]=n/t,o-=i[e];i[this.outputDim-1]=o,e[n]=i}return e}randomSolution(){const t=new Float32Array(this.inputOpts.dim);for(let e=0;e<this.inputOpts.dim;++e)t[e]=i.uniform.sample(this.inputOpts.mins[e],this.inputOpts.maxs[e]);return t}crossover(t,e){const n=Math.random(),i=new Float32Array(this.inputOpts.dim);for(let o=0;o<this.inputOpts.dim;++o)i[o]=n*t[o]+(1-n)*e[o];return i}mutate(t,e=.1){const n=new Float32Array(this.inputOpts.dim);for(let o=0;o<this.inputOpts.dim;++o)n[o]=(0,s.$Q)(t[o]+i.normal.sample(0,e),this.inputOpts.mins[o],this.inputOpts.maxs[o]);return n}perform(){return r(this,void 0,void 0,function*(){const t=this.methodOpts.nWeights,e=this.generateWeights(),n=new Array(t+1);for(let e=0;e<=t;++e)n[e]=this.randomSolution();const i=e.map(t=>e.map((e,n)=>({dist:(0,s.a4)(t,e),idx:n})).sort((t,e)=>t.dist-e.dist).slice(0,this.methodOpts.neighbors).map(t=>t.idx)),r=this.methodOpts.generations;let l=0;for(let u=0;u<r;++u){for(let o=0;o<=t;o++){const t=i[o],[r,a]=(0,s.UK)(t);let l=this.crossover(n[r],n[a]);Math.random()<this.methodOpts.mutationRate&&(l=this.mutate(l));for(const i of t)(yield this.weightedSum(l,e[i]))<(yield this.weightedSum(n[i],e[i]))&&(n[i]=l)}if(void 0!==this.progrIndicator){if(this.progrIndicator.canceled)throw new Error("Optimization interrupted by the user");l=Math.floor(100*u/r),this.progrIndicator.update(l,`Optimization... (${l}%)`),yield a(o.cp)}}return n})}}},9687:(t,e,n)=>{"use strict";n(3033),n(4536)},9688:(t,e,n)=>{"use strict";n(4214),n(2228),n(1988),n(559)},9713:t=>{"use strict";t.exports=rxjs.operators},9827:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},9879:(t,e,n)=>{"use strict";n.d(e,{R:()=>a,z:()=>l});var i=n(7389),o=n(6082),s=n(1858),r=(n(6998),function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})});const a="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class l extends o.InputBase{get value(){return this.fileValue}set value(t){this.stringValue=(null==t?void 0:t.name)||"Drag-n-drop your file",this.fileValue=t,this.notify&&this.fireInput()}constructor(t="Drag-n-drop here",e=null,n=null,o=a){super(i.input.string("Input file",{value:""}).dart),this.initialText=t,this.initialValue=e,this.onValueChanged=n,this.fileType=o,this.uploadedFile$=new s.Subject,this.onFileUploaded=this.uploadedFile$,this.fileValue=null,this.isValid=new s.BehaviorSubject(!0),this.hiddenInput=document.createElement("input"),this.icon=i.iconFA("cloud-upload",()=>this.hiddenInput.click()),this.subscribeOnEvents(),this.root.style.display="flex",this.isValid.subscribe(t=>{if(t){this.input.classList.remove("error"),this.input.classList.add("success");const t=i.iconFA("times",()=>this.reset(),"Reset uploaded file");this.icon.replaceWith(t),this.icon=t}else{this.input.classList.remove("success"),this.input.classList.add("error");const t=i.iconFA("redo",()=>this.hiddenInput.click(),"Re-upload a file");this.icon.replaceWith(t),this.icon=t}}),this.uploadedFile$.subscribe(t=>{if(this.onValueChanged&&this.onValueChanged(t),!t){const t=i.iconFA("cloud-upload",()=>this.hiddenInput.click(),"Choose a file to upload");this.icon.replaceWith(t),this.icon=t}this.value=t}),this.reset()}subscribeOnEvents(){this.input.readOnly=!0,this.input.classList.add("default");const t=t=>r(this,void 0,void 0,function*(){if(t&&t.length&&this.enabled){if(t.length>1)throw this.isValid.next(!1),new Error("Please specify single input file");if(this.fileType&&t[0].type!==this.fileType)throw this.isValid.next(!1),new Error("File type is not supported");this.isValid.value?this.uploadedFile$.next(t[0]):this.uploadedFile$.next(null)}});this.root.classList.add("fi-drop-area"),this.root.style.width="100%",this.hiddenInput.type="file",this.hiddenInput.addEventListener("change",()=>r(this,void 0,void 0,function*(){return yield t(this.hiddenInput.files)}),!1),["dragenter","dragover","dragleave","drop"].forEach(t=>{this.input.addEventListener(t,t=>{t.preventDefault(),t.stopPropagation()},!1)}),["dragenter","dragover"].forEach(t=>{this.input.addEventListener(t,()=>{this.input.classList.add("drag-n-dropping")},!1)}),["dragleave","drop"].forEach(t=>{this.input.addEventListener(t,()=>{this.input.classList.remove("drag-n-dropping")},!1)}),this.input.addEventListener("drop",e=>r(this,void 0,void 0,function*(){const n=e.dataTransfer.files;t(n)}),!1),this.input.addEventListener("click",()=>this.hiddenInput.click(),!1),this.addOptions(this.icon),["drag","dragenter"].forEach(t=>{document.getElementsByClassName("layout-workarea")[0].addEventListener(t,t=>{t.stopPropagation()},!1)})}reset(){this.input.classList.value="ui-input-editor default",this.hiddenInput.value="",this.uploadedFile$.next(null)}}},9886:(t,e,n)=>{},9939:(t,e,n)=>{"use strict";n.d(e,{s:()=>d});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=n(9713),l=n(1599),u=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};function c(){const t=o.iconFA("times");return t.style.marginRight="6px",t.classList.remove("grok-icon"),t}class d extends s.ObjectHandler{get type(){return"Model"}get helpUrl(){return null}getById(t){return u(this,void 0,void 0,function*(){return yield i.dapi.functions.find(t)})}refresh(t){return u(this,void 0,void 0,function*(){return yield this.getById(t.id)})}static openHelp(t){return u(this,void 0,void 0,function*(){const e=yield(0,l.zF)(t);i.shell.windows.showHelp=!0,i.shell.windows.help.showHelp(o.markdown(null!=e?e:""))})}static openModel(t){t.prepare().edit()}static openModelFromFunccall(t){t.edit()}static getUserGroups(){return u(this,void 0,void 0,function*(){return yield(yield fetch(`${window.location.origin}/api/groups/all_parents`)).json()})}static getMissingGroups(t,e){return JSON.parse(t.options.mandatoryUserGroups?`${t.options.mandatoryUserGroups}`:"[]").filter(t=>!e.map(t=>t.friendlyName).includes(t.name))}static openVersionSelectDialog(t){var e;const n=JSON.parse(t.options.versions?`${t.options.versions}`:"[]");if((null!==(e=null==n?void 0:n.length)&&void 0!==e?e:0)<2)return void i.shell.info("No other versions avaliable");const s=o.dialog({title:"Choose version"}),r=o.input.choice("Select version",{items:n,value:n[0]});s.add(r).onOK(()=>{const e=r.value;t.prepare({params:{version:e}}).edit()}),s.show()}isApplicable(t){const e=s.toJs(t);return e instanceof s.Func&&e.hasTag("model")}constructor(){super(),this.userGroups=new r.BehaviorSubject(void 0)}getLanguageIcon(t){return"grok"==t?o.iconSvg("project"):o.iconImage("script",`/images/entities/${t}.png`)}renderMarkup(t){const e=o.divH([],{style:{justifyContent:"space-between",width:"100%"}});return setTimeout(()=>u(this,void 0,void 0,function*(){const n=yield this.awaitUserGroups(),s=d.getMissingGroups(t,n),r=s.length>0,a=o.iconFA("exclamation-triangle",null);a.classList.remove("grok-icon");const l=this.makeMandatoryGroupsInfo(s),u=o.span([this.renderIcon(t),o.label(t.friendlyName)]);var c;e.onclick=()=>{i.shell.windows.help.visible&&d.openHelp(t)},r?u.classList.add("d4-disabled"):e.ondblclick=()=>{d.openModel(t)},r&&(function(t){t.popover="auto",t.style.cursor="default",t.style.padding="10px",t.style.background="#fdffe5",t.style.border="1px solid #E4E6CE",t.style.borderRadius="2px",t.style.boxShadow="0 0 5px #E4E6CE",t.style.maxWidth="500px",t.style.color="var(--gray-6)"}(c=l),document.body.append(c),e.addEventListener("click",()=>{!function(t,e){!function(t,e){const n=t.getBoundingClientRect().toJSON();e.style.inset="unset",e.style.top=n.y+"px",e.style.left=n.x+20+"px"}(t,e),e.showPopover()}(a,l)})),e.append(u),r&&e.append(o.span([a],{style:{paddingLeft:"10px"}}))})),e}renderIcon(t){if(null!=t.options.icon&&(t.options.icon.startsWith("http://")||t.options.icon.startsWith("https://")))return o.iconImage("model-icon",t.options.icon);if(t instanceof s.Script)return this.getLanguageIcon(t.language);let e=(t=s.Func.find({package:t.package.name,name:t.name})[0]).package.getIconUrl();if(null!=t.options.icon){const n=e.split("/");n.pop(),n.push(t.options.icon),e=n.join("/")}return o.iconImage(t.package.name,e)}renderView(t){return this.renderPreview(t).root}renderPreview(t){var e;const n=super.renderPreview(t);return n.name=(null!==(e=t.friendlyName)&&void 0!==e?e:t.name)+" description",s.View.fromViewAsync(()=>u(this,void 0,void 0,function*(){var e,i;const s=yield(0,l.zF)(t),r=yield this.awaitUserGroups(),a=d.getMissingGroups(t,r),u=a.length?o.div([this.makeMandatoryGroupsInfo(a)],{style:{border:"2px solid var(--red-3)",padding:"10px",maxWidth:"400px"}}):o.div([o.bigButton("Launch",()=>t.prepare().edit())]);return n.append(o.div([o.h1(null!==(e=t.friendlyName)&&void 0!==e?e:t.name),o.divText(null!==(i=t.description)&&void 0!==i?i:t.name,{style:{marginBottom:"10px"}}),u,o.div([],{style:{padding:"20px "}}),o.markdown(null!=s?s:"")],{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"}})),n}))}renderProperties(t){const e=o.accordion("ComputeModel");e.context=t;const n=o.div([o.span([this.renderIcon(t),o.label(t.friendlyName),o.contextActions(t),o.star(t.id)])]);return e.addTitle(n),null!=t.description&&n.appendChild(o.div([o.markdown(t.description)],"model-catalog-description")),n.appendChild(o.tags(t)),null!=t.options["dev.status"]&&n.appendChild(o.tableFromMap({Status:t.options["dev.status"]})),e.end(),e.root}renderTooltip(t){const e=o.span([this.renderIcon(t),o.label(t.friendlyName)]);return e.classList.add("d4-link-label"),o.bind(t,o.divV([o.h2(e),o.divV([o.divText(t.description,"ui-description")],{style:{lineHeight:"150%"}})]))}renderCard(t){const e=this.renderMarkup(t);return e.classList.add("d4-link-label"),o.bind(t,o.h2(e))}init(){this.registerParamFunc("Choose version",t=>{d.openVersionSelectDialog(s.toJs(t))}),this.registerParamFunc("Help",t=>{d.openHelp(s.toJs(t))});const t=new s.Functions,e=t=>t instanceof s.Entity,n=t=>i.shell.favorites.some(e=>e.id==t.id);t.registerParamFunc("Add to Favorites",this.type,t=>u(this,void 0,void 0,function*(){return yield s.Favorites.add(s.toJs(t))}),t=>{const i=s.toJs(t);return this.isApplicable(i)&&e(i)&&!n(i)}),t.registerParamFunc("Remove from Favorites",this.type,t=>u(this,void 0,void 0,function*(){return yield s.Favorites.remove(s.toJs(t))}),t=>{const i=s.toJs(t);return this.isApplicable(i)&&e(i)&&n(i)}),setTimeout(()=>u(this,void 0,void 0,function*(){const t=yield d.getUserGroups();this.userGroups.next(t)}))}makeMandatoryGroupsInfo(t){const e=o.div(o.divV([o.label("You should be a member of the following group(s):",{style:{marginLeft:"0px"}}),...t.map(t=>o.divV([o.span([c(),t.name],{style:{fontWeight:"600"}}),...t.help?[o.span([t.help],{style:{marginLeft:"16px"}})]:[],o.link("Request group membership",()=>u(this,void 0,void 0,function*(){yield function(t){return u(this,void 0,void 0,function*(){try{const e=yield i.dapi.groups.filter(`friendlyName="${t}"`).list();if(0===e.length)throw new Error("group with specified name is not found");if(e.length>1)throw new Error("found more than one group with specified name");const n=e[0];yield fetch(`${window.location.origin}/api/groups/${n.id}/requests/${i.shell.user.group.id}`,{method:"POST"}),i.shell.info(`Request to join ${t} has been initiated. Please allow some time for approval.`)}catch(t){i.shell.error(t.toString())}})}(t.name),e.hidePopover()}),void 0,{style:{marginLeft:"16px"}})]))],{style:{gap:"10px"}}));return e}awaitUserGroups(){return u(this,void 0,void 0,function*(){return this.userGroups.pipe((0,a.filter)(t=>!!t),(0,a.map)(t=>t),(0,a.take)(1)).toPromise()})}}}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var s=e[i]={id:i,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.exports}n.m=t,n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var i=e.getElementsByTagName("script");if(i.length)for(var o=i.length-1;o>-1&&(!t||!/^http(s?):/.test(t));)t=i[o--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b="undefined"!=typeof document&&document.baseURI||self.location.href,n.nc=void 0;var i=n(2650);compute=i})();
|
|
1
|
+
var compute;(()=>{var t={3775(t,e,n){"use strict";n.d(e,{A:()=>a});var i=n(5516),o=n.n(i),s=n(1364),r=n.n(s)()(o());r.push([t.id,".fi-drop-area {\n position: relative;\n}\n\n.fi-drop-area .default {\n color: var(--grey-2);\n}\n\n.fi-drop-area .drag-n-dropping {\n background-color: var(--steel-1);\n border: 1px dashed var(--blue-1);\n color: var(--grey-3);\n}\n\n.fi-drop-area .error {\n color: var(--red-3);\n}\n\n.fi-drop-area .success {\n color: var(--grey-6);\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/old-components/css/file-input.css"],names:[],mappings:"AAAA;EACE,kBAAkB;AACpB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,gCAAgC;EAChC,gCAAgC;EAChC,oBAAoB;AACtB;;AAEA;EACE,mBAAmB;AACrB;;AAEA;EACE,oBAAoB;AACtB",sourcesContent:[".fi-drop-area {\n position: relative;\n}\n\n.fi-drop-area .default {\n color: var(--grey-2);\n}\n\n.fi-drop-area .drag-n-dropping {\n background-color: var(--steel-1);\n border: 1px dashed var(--blue-1);\n color: var(--grey-3);\n}\n\n.fi-drop-area .error {\n color: var(--red-3);\n}\n\n.fi-drop-area .success {\n color: var(--grey-6);\n}\n"],sourceRoot:""}]);const a=r},5167(t,e,n){"use strict";n.d(e,{A:()=>a});var i=n(5516),o=n.n(i),s=n(1364),r=n.n(s)()(o());r.push([t.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},1261(t,e,n){"use strict";n.d(e,{A:()=>a});var i=n(5516),o=n.n(i),s=n(1364),r=n.n(s)()(o());r.push([t.id,".hp-no-elements-label {\n margin: 12px;\n}\n\n.grok-icon.hp-disabled {\n pointer-events: none;\n opacity: 0.6;\n}\n\n.hp-funccall-card-hover-icon {\n display: none;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-hover-icon {\n display: flex;\n margin: 0px 0px 0px 5px;\n}\n\n.hp-funccall-card {\n margin: 2px 1px;\n padding: 5px;\n justify-content: space-between;\n}\n\n.hp-funccall-card .hp-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.hp-funccall-card .hp-card-content * {\n margin-bottom: 3px;\n}\n\n.hp-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.hp-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/old-components/css/history-panel.css"],names:[],mappings:"AAAA;IACI,YAAY;AAChB;;AAEA;IACI,oBAAoB;IACpB,YAAY;AAChB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,aAAa;IACb,uBAAuB;AAC3B;;AAEA;IACI,eAAe;IACf,YAAY;IACZ,8BAA8B;AAClC;;AAEA;IACI,6BAA6B;IAC7B,gBAAgB;AACpB;;AAEA;IACI,kBAAkB;AACtB;;AAEA;IACI,kBAAkB;IAClB,oBAAoB;AACxB;;AAEA;IACI,oBAAoB;IACpB,gBAAgB;AACpB",sourcesContent:[".hp-no-elements-label {\n margin: 12px;\n}\n\n.grok-icon.hp-disabled {\n pointer-events: none;\n opacity: 0.6;\n}\n\n.hp-funccall-card-hover-icon {\n display: none;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-hover-icon {\n display: flex;\n margin: 0px 0px 0px 5px;\n}\n\n.hp-funccall-card {\n margin: 2px 1px;\n padding: 5px;\n justify-content: space-between;\n}\n\n.hp-funccall-card .hp-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.hp-funccall-card .hp-card-content * {\n margin-bottom: 3px;\n}\n\n.hp-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.hp-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}\n"],sourceRoot:""}]);const a=r},5366(t,e,n){"use strict";n.d(e,{A:()=>a});var i=n(5516),o=n.n(i),s=n(1364),r=n.n(s)()(o());r.push([t.id,".pipeline-view .d4-ribbon-name.selected {\n color: var(--grey-6)\n}\n\n.pipeline-view .d4-ribbon-name {\n color: var(--blue-1);\n margin: 12px 6px;\n font-weight: normal;\n place-content: center;\n}\n\n.pipeline-view .d4-ribbon-name + .d4-ribbon-name::before {\n color: var(--grey-3);\n}\n\n.pipeline-view .d4-ribbon-name.d4-disabled {\n cursor: default;\n pointer-events: none;\n color: var(--grey-3);\n}\n\n.ui-input-editor button.ui-btn-nav.ui-btn.d4-disabled {\n color: var(--grey-3)\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/old-views/css/pipeline-view.css"],names:[],mappings:"AAAA;EACE;AACF;;AAEA;EACE,oBAAoB;EACpB,gBAAgB;EAChB,mBAAmB;EACnB,qBAAqB;AACvB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,eAAe;EACf,oBAAoB;EACpB,oBAAoB;AACtB;;AAEA;EACE;AACF",sourcesContent:[".pipeline-view .d4-ribbon-name.selected {\n color: var(--grey-6)\n}\n\n.pipeline-view .d4-ribbon-name {\n color: var(--blue-1);\n margin: 12px 6px;\n font-weight: normal;\n place-content: center;\n}\n\n.pipeline-view .d4-ribbon-name + .d4-ribbon-name::before {\n color: var(--grey-3);\n}\n\n.pipeline-view .d4-ribbon-name.d4-disabled {\n cursor: default;\n pointer-events: none;\n color: var(--grey-3);\n}\n\n.ui-input-editor button.ui-btn-nav.ui-btn.d4-disabled {\n color: var(--grey-3)\n}"],sourceRoot:""}]);const a=r},1179(t,e,n){"use strict";n.d(e,{A:()=>a});var i=n(5516),o=n.n(i),s=n(1364),r=n.n(s)()(o());r.push([t.id,".ui-form .ui-input-root.ui-input-buttons.rfv-buttons {\n margin-top: 0px;\n position: sticky;\n align-items: flex-start;\n}\n\n.ui-form .ui-input-buttons.rfv-buttons .ui-input-editor {\n flex-wrap: wrap;\n}\n\n.ui-input-root.rfv-restricted-input.d4-disabled {\n pointer-events: all;\n cursor: pointer!important;\n}\n\n/* Hide all state icons by default */\n.ui-input-root > .ui-input-options .rfv-icon-lock,\n.ui-input-root > .ui-input-options .rfv-icon-unlock,\n.ui-input-root > .ui-input-options .rfv-icon-undo,\n.ui-input-root > .ui-input-options .rfv-icon-warning {\n display: none;\n}\n\n/* Show warning icon if input is on warning state */\n.ui-input-root.rfv-inconsistent-input > .ui-input-options .rfv-icon-warning {\n display: inherit;\n}\n\n/* Show undo icon if input is on inconstent state and hovered */\n.ui-input-root.rfv-restricted-unlocked-input:hover .rfv-icon-undo, .ui-input-root.rfv-inconsistent-input:hover .rfv-icon-undo {\n display: inherit;\n}\n\n/* Show/hide lock-unlock icons on input hover */\n.ui-input-root.rfv-restricted-input:hover .rfv-icon-lock {\n display: none;\n}\n.ui-input-root.rfv-restricted-input .rfv-icon-lock {\n display: inherit;\n}\n.ui-input-root.rfv-restricted-input .rfv-icon-unlock {\n display: none;\n}\n.ui-input-root.rfv-restricted-input:hover .rfv-icon-unlock {\n display: inherit;\n}\n\n.ui-form-condensed .rfv-buttons > .ui-label {\n margin-right: 0px!important;\n}\n\n.rfv-form .ui-form .rfv-buttons > .ui-input-editor {\n gap: 5px;\n justify-content: flex-end;\n}\n\ndiv.ui-box > div.ui-box.rfv-form > div.ui-div {\n overflow: visible!important;\n}\n\n.rfv-scalar-table {\n border-collapse: collapse;\n margin: 10px;\n}\n\n.rfv-scalar-table td {\n width: max-content;\n white-space: nowrap;\n}\n\n.rfv-scalar-table tr{\n min-height: 30px;\n border-bottom: 1pt solid var(--grey-12);\n}\n\n.rfv-scalar-table tr:nth-child(odd) {\n background-color: var(--grey-1);\n}\n\n.rfv-scalar-table td:last-child {\n width: 100%;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/old-views/css/rich-function-view.css"],names:[],mappings:"AAAA;IACI,eAAe;IACf,gBAAgB;IAChB,uBAAuB;AAC3B;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,mBAAmB;IACnB,yBAAyB;AAC7B;;AAEA,oCAAoC;AACpC;;;;IAII,aAAa;AACjB;;AAEA,mDAAmD;AACnD;IACI,gBAAgB;AACpB;;AAEA,+DAA+D;AAC/D;IACI,gBAAgB;AACpB;;AAEA,+CAA+C;AAC/C;IACI,aAAa;AACjB;AACA;IACI,gBAAgB;AACpB;AACA;IACI,aAAa;AACjB;AACA;IACI,gBAAgB;AACpB;;AAEA;IACI,2BAA2B;AAC/B;;AAEA;IACI,QAAQ;IACR,yBAAyB;AAC7B;;AAEA;IACI,2BAA2B;AAC/B;;AAEA;IACI,yBAAyB;IACzB,YAAY;AAChB;;AAEA;IACI,kBAAkB;IAClB,mBAAmB;AACvB;;AAEA;IACI,gBAAgB;IAChB,uCAAuC;AAC3C;;AAEA;IACI,+BAA+B;AACnC;;AAEA;IACI,WAAW;AACf",sourcesContent:[".ui-form .ui-input-root.ui-input-buttons.rfv-buttons {\n margin-top: 0px;\n position: sticky;\n align-items: flex-start;\n}\n\n.ui-form .ui-input-buttons.rfv-buttons .ui-input-editor {\n flex-wrap: wrap;\n}\n\n.ui-input-root.rfv-restricted-input.d4-disabled {\n pointer-events: all;\n cursor: pointer!important;\n}\n\n/* Hide all state icons by default */\n.ui-input-root > .ui-input-options .rfv-icon-lock,\n.ui-input-root > .ui-input-options .rfv-icon-unlock,\n.ui-input-root > .ui-input-options .rfv-icon-undo,\n.ui-input-root > .ui-input-options .rfv-icon-warning {\n display: none;\n}\n\n/* Show warning icon if input is on warning state */\n.ui-input-root.rfv-inconsistent-input > .ui-input-options .rfv-icon-warning {\n display: inherit;\n}\n\n/* Show undo icon if input is on inconstent state and hovered */\n.ui-input-root.rfv-restricted-unlocked-input:hover .rfv-icon-undo, .ui-input-root.rfv-inconsistent-input:hover .rfv-icon-undo {\n display: inherit;\n}\n\n/* Show/hide lock-unlock icons on input hover */\n.ui-input-root.rfv-restricted-input:hover .rfv-icon-lock {\n display: none;\n}\n.ui-input-root.rfv-restricted-input .rfv-icon-lock {\n display: inherit;\n}\n.ui-input-root.rfv-restricted-input .rfv-icon-unlock {\n display: none;\n}\n.ui-input-root.rfv-restricted-input:hover .rfv-icon-unlock {\n display: inherit;\n}\n\n.ui-form-condensed .rfv-buttons > .ui-label {\n margin-right: 0px!important;\n}\n\n.rfv-form .ui-form .rfv-buttons > .ui-input-editor {\n gap: 5px;\n justify-content: flex-end;\n}\n\ndiv.ui-box > div.ui-box.rfv-form > div.ui-div {\n overflow: visible!important;\n}\n\n.rfv-scalar-table {\n border-collapse: collapse;\n margin: 10px;\n}\n\n.rfv-scalar-table td {\n width: max-content;\n white-space: nowrap;\n}\n\n.rfv-scalar-table tr{\n min-height: 30px;\n border-bottom: 1pt solid var(--grey-12);\n}\n\n.rfv-scalar-table tr:nth-child(odd) {\n background-color: var(--grey-1);\n}\n\n.rfv-scalar-table td:last-child {\n width: 100%;\n}"],sourceRoot:""}]);const a=r},4350(t,e,n){"use strict";n.d(e,{SJ:()=>l});var i=n(6082),o=n(3508),s=n.n(o);const r=[{name:"NaN",predicate:function(t,e){return Number.isNaN(t)&&Number.isNaN(e)},checker:u},{name:"Null",predicate:function(t,e){return null==t&&null==e},checker:u},{name:"Boolean",predicate:function(t,e){return"boolean"==typeof t&&"boolean"==typeof e},checker:d},{name:"String",predicate:function(t,e){return"string"==typeof t&&"string"==typeof e},checker:d},{name:"Integer",predicate:function(t,e){return Number.isInteger(t)&&Number.isInteger(e)},checker:d},{name:"BigInt",predicate:function(t,e){return"bigint"==typeof t&&"bigint"==typeof e},checker:d},{name:"Float",predicate:function(t,e){return"number"==typeof t&&"number"==typeof e},checker:function(t,e,n){if(!(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||isNaN(t)&&isNaN(e)))return Math.abs(t-e)<n.options.floatTolerance?void 0:[{msg:`Expected ${e}, got ${t} (tolerance = ${n.options.floatTolerance})`}]}},{name:"Map",predicate:function(t,e){return t instanceof Map&&e instanceof Map},checker:function(t,e,n,i){const o=[];n.options.forbidAdditionalProps&&o.push(...p([...t.keys()],[...e.keys()]));for(const n of e.keys()){const o=t.get(n),s=e.get(n);i([String(n)],o,s)}return o}},{name:"Set",predicate:function(t,e){return t instanceof Set&&e instanceof Set},checker:function(t,e,n,i){const o=[];if(t.size!==e.size){const n={msg:`Sets are of different size: actual set size is ${t.size} and expected set size is ${e.size}`};o.push(n)}for(const n of e.values()){const e=t.has(n);i([String(n)],e,!0)}return o}},{name:"ArrayBuffer",predicate:function(t,e){return t instanceof ArrayBuffer&&e instanceof ArrayBuffer},checker:function(t,e,n,i){return c(Array.from(new Uint8Array(t)),Array.from(new Uint8Array(e)),0,i)}},{name:"Array",predicate:function(t,e){return t instanceof Array&&e instanceof Array},checker:c},{name:"DataFrame",predicate:function(t,e){return t instanceof i.DataFrame&&e instanceof i.DataFrame},checker:function(t,e,n,i){const o=[];if(t.rowCount!==e.rowCount){const n={msg:`Dataframes has different row count: actual row count is ${t.rowCount} and expected row count is ${e.rowCount}`};o.push(n)}n.options.forbidAdditionalProps&&o.push(...p([...t.columns].map(t=>t.name),[...e.columns].map(t=>t.name)));for(const n of e.columns){const s=t.columns.byName(n.name);if(!s){const t={msg:`Column ${n.name} not found`};o.push(t);continue}if(s.type!==n.type){const t={msg:`Column ${n.name} type expected ${n.type} got ${s.type}`};o.push(t);continue}for(let t=0;t<e.rowCount;t++){const e=s.get(t),o=n.get(t);i([n.name,String(t)],e,o)}}return o}},{name:"DayJs",predicate:function(t,e){return s().isDayjs(t)&&s().isDayjs(e)},checker:function(t,e){if(!e.isSame(t))return[{msg:`Different date, expected ${e.toISOString()} actual ${t.toISOString()}`}]}},{name:"Object",predicate:function(t,e){return"object"==typeof t&&"object"==typeof e},checker:function(t,e,n,i){const o=[];n.options.forbidAdditionalProps&&o.push(...p([...Object.keys(t)],[...Object.keys(e)]));for(const[n,o]of Object.entries(e))i([n],t[n],o);return o}}];class a extends Error{}function l(t,e,n){new f(n).run(t,e)}function u(){}function d(t,e){if(t!==e)return[{msg:`Expected ${e}, got ${t}`}]}function c(t,e,n,i){const o=[];if(t.length!==e.length){const n={msg:`Arrays are of different length: actual array length is ${t.length} and expected array length is ${e.length}`};o.push(n)}for(let n=0;n<t.length;n++)i([String(n)],t[n],e[n]);return o}function p(t,e){const n=[],i=new Set(e);for(const e of t)if(!i.has(e)){const t={msg:`Additional key/col item in actual data found: ${e}`};n.push(t)}return n}const h={floatTolerance:.001,maxErrorsReport:5,forbidAdditionalProps:!1,maxDepth:128,checkersSeq:r,prefix:""};class f{constructor(t={}){this.options=Object.assign(Object.assign({},h),t),this.state={errors:[],currentPath:[],options:this.options}}run(t,e){this.matchChecker(t,e),this.checkErrorsLimit(0)}checkDeep(t,e,n){const i=t.length;if(this.state.currentPath.push(...t),this.state.currentPath.length>this.options.maxDepth)throw new a(`Max depth ${this.options.maxDepth} is exceeded, potentially a circular structure`);this.matchChecker(e,n),this.state.currentPath.splice(-i)}matchChecker(t,e){let n=!1;for(const{predicate:i,checker:o}of this.options.checkersSeq)if(i(t,e)){n=!0;const i=o(t,e,this.state,this.checkDeep.bind(this));i&&i.map(t=>this.addError(t));break}if(!n){const n={msg:`Type mismatch or no checker defined: expected ${e}, got ${t}`};this.addError(n)}}addError(t){var e,n;const i={path:[...null!==(e=this.state.currentPath)&&void 0!==e?e:[],...null!==(n=t.path)&&void 0!==n?n:[]],msg:t.msg};this.state.errors.push(i),this.checkErrorsLimit()}checkErrorsLimit(t=this.options.maxErrorsReport){if(this.state.errors.length>t){const t=this.makeReport();throw new a(t)}}makeReport(){return this.state.errors.map(t=>{var e;const n=(null!==(e=t.path)&&void 0!==e?e:[]).map(t=>`['${String(t)}']`).join("."),i=n?`${n}: ${t.msg}`:t.msg;return this.options.prefix?`${this.options.prefix}: ${i}`:i}).slice(0,this.options.maxErrorsReport).join("\n")}}},5520(t,e,n){"use strict";n.d(e,{iu:()=>u,lK:()=>l});var i=n(6082),o=n(1825),s=n(3508),r=n.n(s);const a="_DG_CUSTOM_SERIALIZED_TOKEN_";function l(t,e={}){return JSON.stringify(t,function(t,n){return n===1/0?{[a]:"Infinity",value:!0}:n===-1/0?{[a]:"-Infinity",value:!0}:Number.isNaN(n)?{[a]:"NaN",value:!0}:n instanceof i.DataFrame&&!e.useJsonDF?{[a]:"DataFrame",value:(0,o.SM)(n.toByteArray())}:n instanceof i.DataFrame&&e.useJsonDF?{[a]:"DataFrameJSON",value:n.toJson()}:n instanceof ArrayBuffer?{[a]:"ArrayBuffer",value:(0,o.SM)(new Uint8Array(n))}:n instanceof Map?{[a]:"Map",value:Array.from(n)}:n instanceof Set?{[a]:"Set",value:Array.from(n)}:r().isDayjs(this[t])?{[a]:"DayJs",value:this[t].toISOString()}:n},e.space)}function u(t){return JSON.parse(t,d)}function d(t,e){if(e&&e[a]&&e.value)switch(e[a]){case"DataFrame":return i.DataFrame.fromByteArray((0,o.Fo)(e.value));case"DataFrameJSON":return i.DataFrame.fromJson(JSON.stringify(e.value));case"ArrayBuffer":return(0,o.Fo)(e.value).buffer;case"Map":return new Map(e.value);case"DayJs":return r()(e.value);case"Set":return new Set(e.value);case"Infinity":return 1/0;case"-Infinity":return-1/0;case"NaN":return NaN}return e}},1364(t){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n}).join("")},e.i=function(t,n,i,o,s){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var u=0;u<t.length;u++){var d=[].concat(t[u]);i&&r[d[0]]||(void 0!==s&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=s),n&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=n):d[2]=n),o&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=o):d[4]="".concat(o)),e.push(d))}},e}},5516(t){"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),s="/*# ".concat(o," */");return[e].concat([s]).join("\n")}return[e].join("\n")}},4112(t){t.exports=function(){"use strict";var t="minute",e=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(i,o,s){var r=o.prototype;s.utc=function(t){return new o({date:t,utc:!0,args:arguments})},r.utc=function(e){var n=s(this.toDate(),{locale:this.$L,utc:!0});return e?n.add(this.utcOffset(),t):n},r.local=function(){return s(this.toDate(),{locale:this.$L,utc:!1})};var a=r.parse;r.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),a.call(this,t)};var l=r.init;r.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else l.call(this)};var u=r.utcOffset;r.utcOffset=function(i,o){var s=this.$utils().u;if(s(i))return this.$u?0:s(this.$offset)?u.call(this):this.$offset;if("string"==typeof i&&(i=function(t){void 0===t&&(t="");var i=t.match(e);if(!i)return null;var o=(""+i[0]).match(n)||["-",0,0],s=o[0],r=60*+o[1]+ +o[2];return 0===r?0:"+"===s?r:-r}(i),null===i))return this;var r=Math.abs(i)<=16?60*i:i;if(0===r)return this.utc(o);var a=this.clone();if(o)return a.$offset=r,a.$u=!1,a;var l=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(a=this.local().add(r+l,t)).$offset=r,a.$x.$localOffset=l,a};var d=r.format;r.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return d.call(this,e)},r.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},r.isUTC=function(){return!!this.$u},r.toISOString=function(){return this.toDate().toISOString()},r.toString=function(){return this.toDate().toUTCString()};var c=r.toDate;r.toDate=function(t){return"s"===t&&this.$offset?s(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():c.call(this)};var p=r.diff;r.diff=function(t,e,n){if(t&&this.$u===t.$u)return p.call(this,t,e,n);var i=this.local(),o=s(t).local();return p.call(i,o,e,n)}}}()},6267(t,e,n){"use strict";n.d(e,{L:()=>z});var i=Uint8Array,o=Uint16Array,s=Uint32Array,r=new i([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),a=new i([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),l=new i([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=function(t,e){for(var n=new o(31),i=0;i<31;++i)n[i]=e+=1<<t[i-1];var r=new s(n[30]);for(i=1;i<30;++i)for(var a=n[i];a<n[i+1];++a)r[a]=a-n[i]<<5|i;return[n,r]},d=u(r,2),c=d[0],p=d[1];c[28]=258,p[258]=28;for(var h=u(a,0),f=(h[0],h[1]),v=new o(32768),m=0;m<32768;++m){var g=(43690&m)>>>1|(21845&m)<<1;g=(61680&(g=(52428&g)>>>2|(13107&g)<<2))>>>4|(3855&g)<<4,v[m]=((65280&g)>>>8|(255&g)<<8)>>>1}var y=function(t,e,n){for(var i=t.length,s=0,r=new o(e);s<i;++s)t[s]&&++r[t[s]-1];var a,l=new o(e);for(s=0;s<e;++s)l[s]=l[s-1]+r[s-1]<<1;if(n){a=new o(1<<e);var u=15-e;for(s=0;s<i;++s)if(t[s])for(var d=s<<4|t[s],c=e-t[s],p=l[t[s]-1]++<<c,h=p|(1<<c)-1;p<=h;++p)a[v[p]>>>u]=d}else for(a=new o(i),s=0;s<i;++s)t[s]&&(a[s]=v[l[t[s]-1]++]>>>15-t[s]);return a},b=new i(288);for(m=0;m<144;++m)b[m]=8;for(m=144;m<256;++m)b[m]=9;for(m=256;m<280;++m)b[m]=7;for(m=280;m<288;++m)b[m]=8;var C=new i(32);for(m=0;m<32;++m)C[m]=5;var w=y(b,9,0),A=y(C,5,0),x=function(t){return(t+7)/8|0},E=function(t,e,n){(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length);var r=new(2==t.BYTES_PER_ELEMENT?o:4==t.BYTES_PER_ELEMENT?s:i)(n-e);return r.set(t.subarray(e,n)),r},I=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],R=function(t,e,n){var i=new Error(e||I[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,R),!n)throw i;return i},T=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>>8},S=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>>8,t[i+2]|=n>>>16},F=function(t,e){for(var n=[],s=0;s<t.length;++s)t[s]&&n.push({s,f:t[s]});var r=n.length,a=n.slice();if(!r)return[D,0];if(1==r){var l=new i(n[0].s+1);return l[n[0].s]=1,[l,1]}n.sort(function(t,e){return t.f-e.f}),n.push({s:-1,f:25001});var u=n[0],d=n[1],c=0,p=1,h=2;for(n[0]={s:-1,f:u.f+d.f,l:u,r:d};p!=r-1;)u=n[n[c].f<n[h].f?c++:h++],d=n[c!=p&&n[c].f<n[h].f?c++:h++],n[p++]={s:-1,f:u.f+d.f,l:u,r:d};var f=a[0].s;for(s=1;s<r;++s)a[s].s>f&&(f=a[s].s);var v=new o(f+1),m=P(n[p-1],v,0);if(m>e){s=0;var g=0,y=m-e,b=1<<y;for(a.sort(function(t,e){return v[e.s]-v[t.s]||t.f-e.f});s<r;++s){var C=a[s].s;if(!(v[C]>e))break;g+=b-(1<<m-v[C]),v[C]=e}for(g>>>=y;g>0;){var w=a[s].s;v[w]<e?g-=1<<e-v[w]++-1:++s}for(;s>=0&&g;--s){var A=a[s].s;v[A]==e&&(--v[A],++g)}m=e}return[new i(v),m]},P=function(t,e,n){return-1==t.s?Math.max(P(t.l,e,n+1),P(t.r,e,n+1)):e[t.s]=n},k=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new o(++e),i=0,s=t[0],r=1,a=function(t){n[i++]=t},l=1;l<=e;++l)if(t[l]==s&&l!=e)++r;else{if(!s&&r>2){for(;r>138;r-=138)a(32754);r>2&&(a(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(a(s),--r;r>6;r-=6)a(8304);r>2&&(a(r-3<<5|8208),r=0)}for(;r--;)a(s);r=1,s=t[l]}return[n.subarray(0,i),e]},O=function(t,e){for(var n=0,i=0;i<e.length;++i)n+=t[i]*e[i];return n},B=function(t,e,n){var i=n.length,o=x(e+2);t[o]=255&i,t[o+1]=i>>>8,t[o+2]=255^t[o],t[o+3]=255^t[o+1];for(var s=0;s<i;++s)t[o+s+4]=n[s];return 8*(o+4+i)},L=function(t,e,n,i,s,u,d,c,p,h,f){T(e,f++,n),++s[256];for(var v=F(s,15),m=v[0],g=v[1],x=F(u,15),E=x[0],I=x[1],R=k(m),P=R[0],L=R[1],V=k(E),D=V[0],N=V[1],M=new o(19),_=0;_<P.length;++_)M[31&P[_]]++;for(_=0;_<D.length;++_)M[31&D[_]]++;for(var j=F(M,7),U=j[0],H=j[1],$=19;$>4&&!U[l[$-1]];--$);var W,Y,J,G,q=h+5<<3,z=O(s,b)+O(u,C)+d,Z=O(s,m)+O(u,E)+d+14+3*$+O(M,U)+(2*M[16]+3*M[17]+7*M[18]);if(q<=z&&q<=Z)return B(e,f,t.subarray(p,p+h));if(T(e,f,1+(Z<z)),f+=2,Z<z){W=y(m,g,0),Y=m,J=y(E,I,0),G=E;var K=y(U,H,0);for(T(e,f,L-257),T(e,f+5,N-1),T(e,f+10,$-4),f+=14,_=0;_<$;++_)T(e,f+3*_,U[l[_]]);f+=3*$;for(var X=[P,D],Q=0;Q<2;++Q){var tt=X[Q];for(_=0;_<tt.length;++_){var et=31&tt[_];T(e,f,K[et]),f+=U[et],et>15&&(T(e,f,tt[_]>>>5&127),f+=tt[_]>>>12)}}}else W=w,Y=b,J=A,G=C;for(_=0;_<c;++_)if(i[_]>255){et=i[_]>>>18&31,S(e,f,W[et+257]),f+=Y[et+257],et>7&&(T(e,f,i[_]>>>23&31),f+=r[et]);var nt=31&i[_];S(e,f,J[nt]),f+=G[nt],nt>3&&(S(e,f,i[_]>>>5&8191),f+=a[nt])}else S(e,f,W[i[_]]),f+=Y[i[_]];return S(e,f,W[256]),f+Y[256]},V=new s([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),D=new i(0),N=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,i=9;--i;)n=(1&n&&-306674912)^n>>>1;t[e]=n}return t}(),M=function(){var t=-1;return{p:function(e){for(var n=t,i=0;i<e.length;++i)n=N[255&n^e[i]]^n>>>8;t=n},d:function(){return~t}}},_=function(t,e,n,l,u){return function(t,e,n,l,u,d){var c=t.length,h=new i(l+c+5*(1+Math.ceil(c/7e3))+u),v=h.subarray(l,h.length-u),m=0;if(!e||c<8)for(var g=0;g<=c;g+=65535){var y=g+65535;y>=c&&(v[m>>3]=d),m=B(v,m+1,t.subarray(g,y))}else{for(var b=V[e-1],C=b>>>13,w=8191&b,A=(1<<n)-1,I=new o(32768),R=new o(A+1),T=Math.ceil(n/3),S=2*T,F=function(e){return(t[e]^t[e+1]<<T^t[e+2]<<S)&A},P=new s(25e3),k=new o(288),O=new o(32),N=0,M=0,_=(g=0,0),j=0,U=0;g<c;++g){var H=F(g),$=32767&g,W=R[H];if(I[$]=W,R[H]=$,j<=g){var Y=c-g;if((N>7e3||_>24576)&&Y>423){m=L(t,v,0,P,k,O,M,_,U,g-U,m),_=N=M=0,U=g;for(var J=0;J<286;++J)k[J]=0;for(J=0;J<30;++J)O[J]=0}var G=2,q=0,z=w,Z=$-W&32767;if(Y>2&&H==F(g-Z))for(var K=Math.min(C,Y)-1,X=Math.min(32767,g),Q=Math.min(258,Y);Z<=X&&--z&&$!=W;){if(t[g+G]==t[g+G-Z]){for(var tt=0;tt<Q&&t[g+tt]==t[g+tt-Z];++tt);if(tt>G){if(G=tt,q=Z,tt>K)break;var et=Math.min(Z,tt-2),nt=0;for(J=0;J<et;++J){var it=g-Z+J+32768&32767,ot=it-I[it]+32768&32767;ot>nt&&(nt=ot,W=it)}}}Z+=($=W)-(W=I[$])+32768&32767}if(q){P[_++]=268435456|p[G]<<18|f[q];var st=31&p[G],rt=31&f[q];M+=r[st]+a[rt],++k[257+st],++O[rt],j=g+G,++N}else P[_++]=t[g],++k[t[g]]}}m=L(t,v,d,P,k,O,M,_,U,g-U,m),!d&&7&m&&(m=B(v,m+1,D))}return E(h,0,l+x(m)+u)}(t,null==e.level?6:e.level,null==e.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,n,l,!u)},j=function(t,e){var n={};for(var i in t)n[i]=t[i];for(var i in e)n[i]=e[i];return n},U=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function H(t,e){return _(t,e||{},0,0)}var $=function(t,e,n,o){for(var s in t){var r=t[s],a=e+s,l=o;Array.isArray(r)&&(l=j(o,r[1]),r=r[0]),r instanceof i?n[a]=[r,l]:(n[a+="/"]=[new i(0),l],$(r,a,n,o))}},W="undefined"!=typeof TextEncoder&&new TextEncoder,Y="undefined"!=typeof TextDecoder&&new TextDecoder;try{Y.decode(D,{stream:!0})}catch(t){}function J(t,e){if(e){for(var n=new i(t.length),o=0;o<t.length;++o)n[o]=t.charCodeAt(o);return n}if(W)return W.encode(t);var s=t.length,r=new i(t.length+(t.length>>1)),a=0,l=function(t){r[a++]=t};for(o=0;o<s;++o){if(a+5>r.length){var u=new i(a+8+(s-o<<1));u.set(r),r=u}var d=t.charCodeAt(o);d<128||e?l(d):d<2048?(l(192|d>>6),l(128|63&d)):d>55295&&d<57344?(l(240|(d=65536+(1047552&d)|1023&t.charCodeAt(++o))>>18),l(128|d>>12&63),l(128|d>>6&63),l(128|63&d)):(l(224|d>>12),l(128|d>>6&63),l(128|63&d))}return E(r,0,a)}var G=function(t){var e=0;if(t)for(var n in t){var i=t[n].length;i>65535&&R(9),e+=i+4}return e},q=function(t,e,n,i,o,s,r,a){var l=i.length,u=n.extra,d=a&&a.length,c=G(u);U(t,e,null!=r?33639248:67324752),e+=4,null!=r&&(t[e++]=20,t[e++]=n.os),t[e]=20,e+=2,t[e++]=n.flag<<1|(s<0&&8),t[e++]=o&&8,t[e++]=255&n.compression,t[e++]=n.compression>>8;var p=new Date(null==n.mtime?Date.now():n.mtime),h=p.getFullYear()-1980;if((h<0||h>119)&&R(10),U(t,e,h<<25|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>>1),e+=4,-1!=s&&(U(t,e,n.crc),U(t,e+4,s<0?-s-2:s),U(t,e+8,n.size)),U(t,e+12,l),U(t,e+14,c),e+=16,null!=r&&(U(t,e,d),U(t,e+6,n.attrs),U(t,e+10,r),e+=14),t.set(i,e),e+=l,c)for(var f in u){var v=u[f],m=v.length;U(t,e,+f),U(t,e+2,m),t.set(v,e+4),e+=4+m}return d&&(t.set(a,e),e+=d),e};function z(t,e){e||(e={});var n={},o=[];$(t,"",n,e);var s=0,r=0;for(var a in n){var l=n[a],u=l[0],d=l[1],c=0==d.level?0:8,p=(E=J(a)).length,h=d.comment,f=h&&J(h),v=f&&f.length,m=G(d.extra);p>65535&&R(11);var g=c?H(u,d):u,y=g.length,b=M();b.p(u),o.push(j(d,{size:u.length,crc:b.d(),c:g,f:E,m:f,u:p!=a.length||f&&h.length!=v,o:s,compression:c})),s+=30+p+m+y,r+=76+2*(p+m)+(v||0)+y}for(var C=new i(r+22),w=s,A=r-s,x=0;x<o.length;++x){var E=o[x];q(C,E.o,E,E.f,E.u,E.c.length);var I=30+E.f.length+G(E.extra);C.set(E.c,E.o+I),q(C,s,E,E.f,E.u,E.c.length,E.o,E.m),s+=16+I+(E.m?E.m.length:0)}return function(t,e,n,i,o){U(t,e,101010256),U(t,e+8,n),U(t,e+10,n),U(t,e+12,i),U(t,e+16,o)}(C,s,o.length,A,w),C}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout},6186(t){"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var s={},r=[],a=0;a<t.length;a++){var l=t[a],u=i.base?l[0]+i.base:l[0],d=s[u]||0,c="".concat(u," ").concat(d);s[u]=d+1;var p=n(c),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)e[p].references++,e[p].updater(h);else{var f=o(h,i);i.byIndex=a,e.splice(a,0,{identifier:c,updater:f,references:1})}r.push(c)}return r}function o(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var s=i(t=t||[],o=o||{});return function(t){t=t||[];for(var r=0;r<s.length;r++){var a=n(s[r]);e[a].references--}for(var l=i(t,o),u=0;u<s.length;u++){var d=n(s[u]);0===e[d].references&&(e[d].updater(),e.splice(d,1))}s=l}}},7433(t){"use strict";var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},8990(t){"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},8626(t,e,n){"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},2155(t){"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var s=n.sourceMap;s&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},9827(t){"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},6998(t,e,n){"use strict";var i=n(6186),o=n.n(i),s=n(2155),r=n.n(s),a=n(7433),l=n.n(a),u=n(8626),d=n.n(u),c=n(8990),p=n.n(c),h=n(9827),f=n.n(h),v=n(3775),m={};m.styleTagTransform=f(),m.setAttributes=d(),m.insert=l().bind(null,"head"),m.domAPI=r(),m.insertStyleElement=p(),o()(v.A,m),v.A&&v.A.locals&&v.A.locals},9192(t,e,n){"use strict";var i=n(6186),o=n.n(i),s=n(2155),r=n.n(s),a=n(7433),l=n.n(a),u=n(8626),d=n.n(u),c=n(8990),p=n.n(c),h=n(9827),f=n.n(h),v=n(5167),m={};m.styleTagTransform=f(),m.setAttributes=d(),m.insert=l().bind(null,"head"),m.domAPI=r(),m.insertStyleElement=p(),o()(v.A,m),v.A&&v.A.locals&&v.A.locals},8550(t,e,n){"use strict";var i=n(6186),o=n.n(i),s=n(2155),r=n.n(s),a=n(7433),l=n.n(a),u=n(8626),d=n.n(u),c=n(8990),p=n.n(c),h=n(9827),f=n.n(h),v=n(1261),m={};m.styleTagTransform=f(),m.setAttributes=d(),m.insert=l().bind(null,"head"),m.domAPI=r(),m.insertStyleElement=p(),o()(v.A,m),v.A&&v.A.locals&&v.A.locals},4315(t,e,n){"use strict";var i=n(6186),o=n.n(i),s=n(2155),r=n.n(s),a=n(7433),l=n.n(a),u=n(8626),d=n.n(u),c=n(8990),p=n.n(c),h=n(9827),f=n.n(h),v=n(5366),m={};m.styleTagTransform=f(),m.setAttributes=d(),m.insert=l().bind(null,"head"),m.domAPI=r(),m.insertStyleElement=p(),o()(v.A,m),v.A&&v.A.locals&&v.A.locals},5940(t,e,n){"use strict";var i=n(6186),o=n.n(i),s=n(2155),r=n.n(s),a=n(7433),l=n.n(a),u=n(8626),d=n.n(u),c=n(8990),p=n.n(c),h=n(9827),f=n.n(h),v=n(1179),m={};m.styleTagTransform=f(),m.setAttributes=d(),m.insert=l().bind(null,"head"),m.domAPI=r(),m.insertStyleElement=p(),o()(v.A,m),v.A&&v.A.locals&&v.A.locals},3501(t,e,n){"use strict";n.d(e,{v:()=>h});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=n(6910),l=n(1599),u=n(5092),d=n(9713),c=n(8804),p=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class h extends s.ViewBase{constructor(t){super(),this.funcNqName=t,this.showHistory=new r.BehaviorSubject(!1),this.isReady=new r.BehaviorSubject(!1),this.historyRoot=o.div("",{style:{height:"100%",width:"100%"}}),this.exportConfig=null,this.getMocks=null,this.getTemplates=null,this.getHelp=null,this.reportBug=null,this.requestFeature=null,this.box=!0,this.init()}onBeforeSaveRun(t){return p(this,void 0,void 0,function*(){})}onAfterSaveRun(t){return p(this,void 0,void 0,function*(){})}init(){return p(this,void 0,void 0,function*(){const t=this.getStartId();if(t){this.setAsLoaded();const e=yield u.W.loadRun(t);this.linkFunccall(e),yield this.onFuncCallReady(),yield this.onAfterLoadRun(e)}else{const t=s.Func.byName(this.funcNqName);this.linkFunccall(t.prepare({})),yield this.onFuncCallReady()}this.isReady.next(!0)})}linkFunccall(t){var e,n,i;this.funcCall=t,this.path=t.author?`?id=${t.id}`:"?";const o=null!==(n=null===(e=null==t?void 0:t.func)||void 0===e?void 0:e.friendlyName)&&void 0!==n?n:null===(i=null==t?void 0:t.func)||void 0===i?void 0:i.name;this.name=o}onFuncCallReady(){return p(this,void 0,void 0,function*(){yield this.getPackageData(),this.build()})}saveRun(t){return p(this,void 0,void 0,function*(){const e=(0,l.A4)(t);yield this.onBeforeSaveRun(e),e.id&&e.newId();const n=yield u.W.saveRun(e),i=yield u.W.loadRun(n.id);return this.linkFunccall(i),yield this.onAfterSaveRun(i),i})}saveRunWithDialog(t){return p(this,void 0,void 0,function*(){const e=c.V.forFuncCall(t);e.onMetadataEdit.pipe((0,d.take)(1)).subscribe(e=>p(this,void 0,void 0,function*(){t.options.title=e.title,t.options.description=e.description,t.options.tags=e.tags;const n=yield this.saveRun(t);yield(0,a.WM)(n,!!e.isFavorite)})),e.show({center:!0,width:500})})}loadRun(t){return p(this,void 0,void 0,function*(){const e=yield u.W.loadRun(t);return this.linkFunccall(e),yield this.onAfterLoadRun(e),e})}build(){o.empty(this.root);const t=o.div([this.buildIO(),this.historyRoot],{style:{width:"100%",height:"100%",display:"flex"}});this.root.appendChild(t),this.buildRibbonMenu(),this.buildRibbonPanels()}buildRibbonPanels(){const t=o.iconFA("history",()=>this.showHistory.next(!this.showHistory.value)),e=o.iconFA("save",()=>this.funcCall?this.saveRunWithDialog(this.funcCall):void 0),n=o.comboPopup(o.iconFA("arrow-to-bottom"),this.getFormats(),this.exportRun.bind(this)),i=[[t,e,...this.hasExport()?[n]:[]]];return this.setRibbonPanels(i),i}buildRibbonMenu(){if(this.ribbonMenu.clear(),!(this.exportConfig||this.reportBug||this.requestFeature||this.getHelp||this.getMocks||this.getTemplates))return;const t=this.ribbonMenu.group("Model");if(this.getMocks&&this.getMocks.length>0)if(1===this.getMocks.length)t.item("Input data mock",this.getMocks[0].action);else{const e=t.group("Input data mocks");this.getMocks.forEach(t=>{e.item(t.mockName,t.action)}),t.endGroup()}if(this.getTemplates&&this.getTemplates.length>0)if(1===this.getTemplates.length)t.item("Input data template",this.getTemplates[0].action);else{const e=t.group("Input data templates");this.getTemplates.forEach(t=>{e.item(t.name,t.action)}),t.endGroup()}this.hasExport()&&t.group("Export").items(this.getFormats(),this.exportRun.bind(this)).endGroup(),this.reportBug&&t.item("Report a bug",()=>this.reportBug()),this.requestFeature&&t.item("Request a feature",()=>this.requestFeature()),this.getHelp&&t.item("Help",()=>this.getHelp())}exportRun(t){return p(this,void 0,void 0,function*(){s.Utils.download(this.exportConfig.filename(t),yield this.exportConfig.export(t))})}getFormats(){var t,e;return null!==(e=null===(t=this.exportConfig)||void 0===t?void 0:t.supportedFormats)&&void 0!==e?e:[]}hasExport(){return this.exportConfig&&this.exportConfig.supportedFormats.length>0}getPackageData(){return p(this,void 0,void 0,function*(){var t,e,n;const i=null===(t=this.func)||void 0===t?void 0:t.package;if(!i)return;const o=null===(e=yield null==i?void 0:i.getProperties())||void 0===e?void 0:e.REPORT_BUG_URL;o&&!this.reportBug&&(this.reportBug=()=>p(this,void 0,void 0,function*(){window.open(o,"_blank")}));const s=null===(n=yield null==i?void 0:i.getProperties())||void 0===n?void 0:n.REQUEST_FEATURE_URL;s&&!this.requestFeature&&(this.requestFeature=()=>p(this,void 0,void 0,function*(){window.open(s,"_blank")}))})}getStartId(){const t=new URL(i.shell.startUri);return globalThis.initialURLHandled?null:t.searchParams.get("id")}setAsLoaded(){globalThis.initialURLHandled=!0}get func(){var t;return null===(t=this.funcCall)||void 0===t?void 0:t.func}}},8476(t,e,n){"use strict";n.d(e,{S:()=>c});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(4260),u=n(810),d=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class c extends s.TableView{static fromComparedRuns(t,e){return d(this,arguments,void 0,function*(t,e,n={parentView:void 0,parentCall:void 0}){const o=(0,u.fo)(t,e,n),s=[...i.shell.views].find(t=>t.type===l.sk||t.type===l.eP||t.type===l.r0);return s&&(i.shell.v=s),new this(o,n)})}constructor(t,e={}){super(window.grok_TableView(t.dart,!1)),e.parentView&&(this.parentView=e.parentView),this.parentCall=e.parentCall||i.functions.getCurrentCall()}showAllColumns(){const t=this.dataFrame.columns.names();this.grid.columns.setVisible(t)}showChangingColumns(){const t=this.dataFrame.columns.names().filter(t=>s.TYPES_SCALAR.has(this.dataFrame.getCol(t).type)&&this.dataFrame.getCol(t).categories.length>1||!s.TYPES_SCALAR.has(this.dataFrame.getCol(t).type));this.grid.columns.setVisible(t)}defaultCustomize(){var t;const e=o.iconFA("compress-alt",()=>{this.showChangingColumns(),a()(n).show(),a()(e).hide()},"Hide constant parameters"),n=o.iconFA("expand-arrows-alt",()=>{this.showAllColumns(),a()(n).hide(),a()(e).show()},"Show all parameters");a()(e).hide(),this.setRibbonPanels([...this.getRibbonPanels(),[e,n]]),this.showChangingColumns(),this.root.style.removeProperty("width"),this.root.firstChild.style.removeProperty("width"),this.root.firstChild.firstChild.style.removeProperty("width"),this.grid.props.rowHeight=180,this.grid.props.showAddNewRowIcon=!1,this.grid.props.allowEdit=!1,this.grid.columns.byName(l._W).width=70;for(let e=0;e<this.grid.columns.length;e++){const n=this.grid.columns.byIndex(e);(null===(t=n.column)||void 0===t?void 0:t.temp[l.NT])&&(n.width=350,n.cellType="html")}const r=new s.LruCache;this.grid.onCellPrepare(t=>d(this,void 0,void 0,function*(){if(!t.isColHeader&&!t.isRowHeader){if(t.tableColumn.name===l._W){t.customText="";const e=String(t.cell.value).split(" - "),n=e.length>1?[e[0],o.element("br"),e[1]]:e;return t.element=o.div(n,{style:{writingMode:"vertical-rl",textOrientation:"mixed",margin:"auto"}}),void(t.element.parentElement.style.display="flex")}if(t.tableColumn&&t.tableColumn.temp[l.NT]){const e=t.cell.value,n=t.tableColumn.temp[l.NT],i=n.type,o=()=>d(this,void 0,void 0,function*(){const o=Object.values(l.CB).includes(i)?s.Viewer.fromType(i,e):yield e.plot.fromType(i);return t.tableColumn.temp[l.NT].look?o.setOptions(t.tableColumn.temp[l.NT].look):(o.setOptions(n),t.tableColumn.temp[l.NT]=o.getOptions()),o.root}),a=`${e.id}_${i}`;if(r.get(a))t.element=r.get(a);else{const e=yield o();r.set(a,e),t.element=e}t.element.style.width="100%",t.element.style.height="100%"}}}));const u=o.box(o.div([],{style:{minHeight:"100px"}})),c=i.events.onCurrentViewChanged.subscribe(()=>{i.shell.v.id===this.id?i.shell.dockManager.dock(u,"down",null,"Comparison chart",.25):i.shell.dockManager.close(u)}),p=this.grid.onCellClick.subscribe(t=>{var e;if(i.shell.v.id===this.id&&t.isColHeader&&(null===(e=t.tableColumn)||void 0===e?void 0:e.type)===s.TYPE.DATA_FRAME&&[s.VIEWER.LINE_CHART,s.VIEWER.SCATTER_PLOT,s.VIEWER.HISTOGRAM,s.VIEWER.BOX_PLOT].includes(t.tableColumn.temp[l.NT].type)){i.shell.dockManager.findNode(u)||i.shell.dockManager.dock(u,"down",null,"Comparison chart",.25);const e=t=>{const e=s.toJs(t.get(0)).clone();e.columns.addNew(l.eX,s.TYPE.STRING).init(t.dataFrame.get(l._W,0));for(let n=1;n<t.length;n++){const i=s.toJs(t.get(n)).clone();i.columns.addNew(l.eX,s.TYPE.STRING).init(t.dataFrame.get(l._W,n));const o=[s.COLUMN_TYPE.INT,s.COLUMN_TYPE.FLOAT];for(let t=0;t<i.columns.length;t++){const n=i.columns.byIndex(t),r=e.columns.byIndex(t);n.type!==r.type&&o.includes(n.type)&&o.includes(r.type)&&(n.type!==s.COLUMN_TYPE.FLOAT&&i.columns.replace(n,n.convertTo(s.COLUMN_TYPE.FLOAT)),r.type!==s.COLUMN_TYPE.FLOAT&&e.columns.replace(r,r.convertTo(s.COLUMN_TYPE.FLOAT)))}e.append(i,!0)}return e},n=(e,n,i)=>{var o;switch(null===(o=t.tableColumn)||void 0===o?void 0:o.temp[l.NT].type){case s.VIEWER.LINE_CHART:return i.plot.line(Object.assign(Object.assign({},n),{split:l.eX})).root;case s.VIEWER.SCATTER_PLOT:return i.plot.scatter(Object.assign(Object.assign({},n),{color:l.eX})).root;case s.VIEWER.HISTOGRAM:return i.plot.histogram(Object.assign(Object.assign({},n),{split:l.eX})).root;case s.VIEWER.BOX_PLOT:return i.plot.box(Object.assign(Object.assign({},n),{category:l.eX})).root}};o.setUpdateIndicator(u,!0),setTimeout(()=>{var i;if(!t.tableColumn.temp.unitedPlot){const s=t.tableColumn.temp[l.NT].look,r=e(t.tableColumn);t.tableColumn.temp.unitedPlot=n(null===(i=t.tableColumn)||void 0===i?void 0:i.temp[l.NT].type,s,r),o.setUpdateIndicator(u,!1)}o.empty(u),u.appendChild(t.tableColumn.temp.unitedPlot)},10)}else i.shell.dockManager.close(u)});this.subs.push(p,c)}}},810(t,e,n){"use strict";n.d(e,{Bu:()=>c,ZD:()=>p,fo:()=>h});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(4260),u=n(1599),d=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const c=t=>{var e,n;if(null===(e=t.options)||void 0===e?void 0:e.default)return JSON.parse(null===(n=t.options)||void 0===n?void 0:n.default);const i=t.defaultValue;return t.propertyType===s.TYPE.STRING&&i?i.substring(1,i.length-1):i};function p(t,e){e?(a()(t).addClass("ui-box").css({width:"auto",height:"auto"}),o.setUpdateIndicator(t,!0)):(o.setUpdateIndicator(t,!1),a()(t).removeClass("ui-box"))}const h=(t,e,n={parentView:void 0,parentCall:void 0})=>{var r,c;const p=e,h=[...p.inputs,...p.outputs].map(t=>(0,u.jJ)(t)).reduce((t,e)=>(t[e.name]?t[e.name].push(...e.config):t[e.name]=e.config,t),{}),f=e=>{var n;if(e.propertyType===s.TYPE.DATA_FRAME){const n=h[e.name].map(n=>{var i;let o=null!==(i=e.caption)&&void 0!==i?i:e.name;const r=s.Column.fromType(s.TYPE.DATA_FRAME,o,t.length);r.init(n=>{var i;return null!==(i=t[n].inputs[e.name])&&void 0!==i?i:t[n].outputs[e.name]});const a=v.columns.getUnusedName(`${r.name} (${n.type})`);return r.name=a,o=a,r.temp[l.NT]=n,v.columns.add(r),r});return n}{let i=null!==(n=e.caption)&&void 0!==n?n:e.name;const o=s.Column.fromType(e.propertyType,i,t.length);o.init(n=>{var i;return null!==(i=t[n].inputs[e.name])&&void 0!==i?i:t[n].outputs[e.name]});const r=v.columns.getUnusedName(o.name);return o.name=r,i=r,v.columns.add(o),[o]}},v=s.DataFrame.create(t.length),m=[];return t.forEach(t=>{var e;let n=null!==(e=t.options.title)&&void 0!==e?e:`${t.func.name} - ${(0,u.eK)(t)}`,i=2;for(;m.includes(n);)n=`${t.func.name} - ${(0,u.eK)(t)} - ${i}`,i++;m.push(n)}),v.columns.add(s.Column.fromStrings(l._W,m)),v.name=(null===(r=n.parentCall)||void 0===r?void 0:r.func.name)?`${null===(c=n.parentCall)||void 0===c?void 0:c.func.name} - comparison`:`${e.name} - comparison`,p.inputs.forEach(t=>f(t)),p.outputs.forEach(t=>f(t)),i.events.onCurrentObjectChanged.subscribe(({sender:t})=>{if(t instanceof s.Column&&t.type===s.TYPE.DATA_FRAME&&i.shell.tv&&i.shell.tv.temp.isComparison&&[s.VIEWER.LINE_CHART,s.VIEWER.SCATTER_PLOT,s.VIEWER.HISTOGRAM,s.VIEWER.BOX_PLOT].includes(t.temp[l.NT].type)){i.shell.windows.showProperties=!0;const e=t=>{const e=t.get(0).clone();e.columns.addNew(l.eX,s.TYPE.STRING).init(t.dataFrame.get(l._W,0));for(let n=1;n<t.length;n++){const i=t.get(n).clone();i.columns.addNew(l.eX,s.TYPE.STRING).init(t.dataFrame.get(l._W,n));const o=[s.COLUMN_TYPE.INT,s.COLUMN_TYPE.FLOAT];for(let t=0;t<i.columns.length;t++){const n=i.columns.byIndex(t),r=e.columns.byIndex(t);n.type!==r.type&&o.includes(n.type)&&o.includes(r.type)&&(n.type!==s.COLUMN_TYPE.FLOAT&&i.columns.replace(n,n.convertTo(s.COLUMN_TYPE.FLOAT)),r.type!==s.COLUMN_TYPE.FLOAT&&e.columns.replace(r,r.convertTo(s.COLUMN_TYPE.FLOAT)))}e.append(i,!0)}return e},n=t.temp[l.NT].look;setTimeout(()=>{switch(t.temp[l.NT].type){case s.VIEWER.LINE_CHART:const r=o.waitBox(()=>d(void 0,void 0,void 0,function*(){var i;const o=null!==(i=t.temp.unitedDf)&&void 0!==i?i:e(t);return t.temp.unitedDf=o,o.plot.line(Object.assign(Object.assign({},n),{split:l.eX})).root}));a()(r).css({width:"100%"}),i.shell.o=r;break;case s.VIEWER.SCATTER_PLOT:const u=o.waitBox(()=>d(void 0,void 0,void 0,function*(){var i;const o=null!==(i=t.temp.unitedDf)&&void 0!==i?i:e(t);return t.temp.unitedDf=o,o.plot.scatter(Object.assign(Object.assign({},n),{color:l.eX})).root}));i.shell.o=u,a()(u).css({width:"100%"});break;case s.VIEWER.HISTOGRAM:const c=o.waitBox(()=>d(void 0,void 0,void 0,function*(){var i;const o=null!==(i=t.temp.unitedDf)&&void 0!==i?i:e(t);return t.temp.unitedDf=o,o.plot.histogram(Object.assign(Object.assign({},n),{split:l.eX})).root}));i.shell.o=c,a()(c).css({width:"100%"});break;case s.VIEWER.BOX_PLOT:const p=o.waitBox(()=>d(void 0,void 0,void 0,function*(){var i;const o=null!==(i=t.temp.unitedDf)&&void 0!==i?i:e(t);return t.temp.unitedDf=o,o.plot.box(Object.assign(Object.assign({},n),{category:l.eX})).root}));i.shell.o=p,a()(p).css({width:"100%"})}})}}),v}},5092(t,e,n){"use strict";n.d(e,{W:()=>p});var i=n(4328),o=n(6082),s=n(1991),r=n.n(s),a=n(1599),l=n(3508),u=n.n(l),d=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const c=t=>{switch(t){case"Today":return"started > -1d";case"Yesterday":return"started > -2d and started < -1d";case"Any time":return"";case"Last year":return"started > -2y and started < -1y";case"This year":return"started > -1y";case"Last month":return"started > -2m and started < -1m";case"This month":return"started > -1m";case"Last week":return"started > -2w and started < -1w";case"This week":return"started > -1w"}};var p;!function(t){const e=new o.LruCache;function n(t){return d(this,void 0,void 0,function*(){const e=yield i.dapi.functions.calls.allPackageVersions().include("session.user,func.package, inputs, outputs").find(t),n=r()(e.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.FILE&&!!e.inputs[t.name]);yield Promise.all(n.map(t=>d(this,void 0,void 0,function*(){const{id:n,name:s}=JSON.parse(e.inputs[t.name]),r=yield i.dapi.files.readAsBytes(n),a=o.FileInfo.fromBytes(s,r);return a.id=n,e.inputs[t.name]=a,Promise.resolve()})));const s=r()(e.outputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!e.outputs[t.name]);yield Promise.all(s.map(t=>d(this,void 0,void 0,function*(){return e.outputs[t.name]=yield i.dapi.tables.getTable(e.outputs[t.name]),Promise.resolve()})));const a=r()(e.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!e.inputs[t.name]);return yield Promise.all(a.map(t=>d(this,void 0,void 0,function*(){return e.inputs[t.name]=yield i.dapi.tables.getTable(e.inputs[t.name]),Promise.resolve()}))),e})}t.loadChildRuns=function(t){return d(this,void 0,void 0,function*(){return{parentRun:yield n(t),childRuns:yield i.dapi.functions.calls.allPackageVersions().include("func, func.package").filter(`options.parentCallId="${t}"`).list()}})},t.shallowLoadRun=function(t){return d(this,void 0,void 0,function*(){return yield i.dapi.functions.calls.allPackageVersions().include("session.user,func.package, inputs, outputs").find(t)})},t.loadRun=n,t.updateRunMeta=function(t){return d(this,void 0,void 0,function*(){const e=yield i.dapi.functions.calls.allPackageVersions().save(t);i.log.audit("@user edited metadata of @model model run",{user:o.User.current(),model:e.func})})},t.saveRun=function(t){return d(this,void 0,void 0,function*(){let n=e.get("All users");n||(n=yield i.dapi.groups.find(o.Group.defaultGroupsIds["All users"]),e.set("All users",n));const s=(0,a.A4)(t);(0,a.Ne)(s)&&(s.options.createdOn=u()().utc(!0).unix());const l=r()(s.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.FILE&&!!s.inputs[t.name]);yield Promise.all(l.map(t=>d(this,void 0,void 0,function*(){const e=s.inputs[t.name],n=o.FileInfo.fromBytes(e.name,yield e.readAsBytes());return yield i.dapi.files.write(n),s.inputs[t.name]={id:n.id,name:n.name},Promise.resolve()})));const c=r()(s.outputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!s.outputs[t.name]);yield Promise.all(c.map(t=>d(this,void 0,void 0,function*(){yield i.dapi.tables.uploadDataFrame(s.outputs[t.name]),yield i.dapi.permissions.grant(s.outputs[t.name].getTableInfo(),n,!1)})));const p=r()(s.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!s.inputs[t.name]);yield Promise.all(p.map(t=>d(this,void 0,void 0,function*(){yield i.dapi.tables.uploadDataFrame(s.inputs[t.name]),yield i.dapi.permissions.grant(s.inputs[t.name].getTableInfo(),n,!1)})));const h=yield i.dapi.functions.calls.allPackageVersions().save(s);return i.log.audit("@user saved run of the @model model",{user:o.User.current(),model:h.func}),h})},t.deleteRun=function(t){return d(this,void 0,void 0,function*(){t.options.isDeleted=!0,yield i.dapi.functions.calls.allPackageVersions().save(t)})},t.pullRuns=function(t){return d(this,arguments,void 0,function*(t,e={},n={}){let o=`func.id="${t}"`;return o+=e.author?` and session.user.id="${e.author.id}"`:"",o+=e.date?c(e.date):"",i.dapi.functions.calls.allPackageVersions().filter(o).include("session.user, options").list(n)})},t.pullRunsByName=function(t){return d(this,arguments,void 0,function*(t,e=[],n={},s=[],a=!1){let l="";for(const t of e){const e=[];t.author&&e.push(`session.user.id="${t.author.id}"`),t.date&&e.push(c(t.date)),t.text&&e.push(`((options.title like "${t.text}") or (options.annotation like "${t.text}"))`),t.includeDeleted||e.push('((options.isDeleted != "true") or (options.isDeleted = null))');const n=e.join(" and ");""!==n&&(l+=""===l?`(${n})`:` or (${n})`)}""!==l&&(l=` and (${l})`);const u=yield i.dapi.functions.calls.allPackageVersions().filter(`func.name="${t}"${l}`).include(`${[...s,"func.package"].join(",")}`).list(n);if((s.includes("inputs")||s.includes("func.params"))&&!a)for(const t of u){const e=r()(t.inputParams.values()).filter(e=>e.property.propertyType===o.TYPE.DATA_FRAME&&!!t.inputs[e.name]);for(const n of e)t.inputs[n.name]=yield i.dapi.tables.getTable(t.inputs[n.name])}if((s.includes("outputs")||s.includes("func.params"))&&!a)for(const t of u){const e=r()(t.outputParams.values()).filter(e=>e.property.propertyType===o.TYPE.DATA_FRAME&&!!t.outputs[e.name]);for(const n of e)t.outputs[n.name]=yield i.dapi.tables.getTable(t.outputs[n.name])}return u})}}(p||(p={}))},9939(t,e,n){"use strict";n.d(e,{sg:()=>c});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=n(9713),l=n(1599),u=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};function d(){const t=o.iconFA("times");return t.style.marginRight="6px",t.classList.remove("grok-icon"),t}class c extends s.ObjectHandler{get type(){return"Model"}get helpUrl(){return null}getById(t){return u(this,void 0,void 0,function*(){return yield i.dapi.functions.find(t)})}refresh(t){return u(this,void 0,void 0,function*(){return yield this.getById(t.id)})}static openHelp(t){return u(this,void 0,void 0,function*(){const e=yield(0,l.zF)(t);i.shell.windows.showHelp=!0,i.shell.windows.help.showHelp(o.markdown(null!=e?e:""))})}static openModel(t){t.prepare().edit()}static openModelFromFunccall(t){t.edit()}static getUserGroups(){return u(this,void 0,void 0,function*(){return yield(yield fetch(`${window.location.origin}/api/groups/all_parents`)).json()})}static getMissingGroups(t,e){return JSON.parse(t.options.mandatoryUserGroups?`${t.options.mandatoryUserGroups}`:"[]").filter(t=>!e.map(t=>t.friendlyName).includes(t.name))}static openVersionSelectDialog(t){var e;const n=JSON.parse(t.options.versions?`${t.options.versions}`:"[]");if((null!==(e=null==n?void 0:n.length)&&void 0!==e?e:0)<2)return void i.shell.info("No other versions avaliable");const s=o.dialog({title:"Choose version"}),r=o.input.choice("Select version",{items:n,value:n[0]});s.add(r).onOK(()=>{const e=r.value;t.prepare({params:{version:e}}).edit()}),s.show()}isApplicable(t){return function(t){var e,n;if(!(t instanceof s.Func))return!1;const i=(null!==(n=null===(e=null==t?void 0:t.options)||void 0===e?void 0:e.role)&&void 0!==n?n:"").split(",").includes("model"),o=t.hasTag("model");return i||o}(s.toJs(t))}constructor(){super(),this.userGroups=new r.BehaviorSubject(void 0)}getLanguageIcon(t){return"grok"==t?o.iconSvg("project"):o.iconImage("script",`/images/entities/${t}.png`)}renderMarkup(t){const e=o.divH([],{style:{justifyContent:"space-between",width:"100%"}});return setTimeout(()=>u(this,void 0,void 0,function*(){const n=yield this.awaitUserGroups(),s=c.getMissingGroups(t,n),r=s.length>0,a=o.iconFA("exclamation-triangle",null);a.classList.remove("grok-icon");const l=this.makeMandatoryGroupsInfo(s),u=o.span([this.renderIcon(t),o.label(t.friendlyName)]);var d;e.onclick=()=>{i.shell.windows.help.visible&&c.openHelp(t)},r?u.classList.add("d4-disabled"):e.ondblclick=()=>{c.openModel(t)},r&&(function(t){t.popover="auto",t.style.cursor="default",t.style.padding="10px",t.style.background="#fdffe5",t.style.border="1px solid #E4E6CE",t.style.borderRadius="2px",t.style.boxShadow="0 0 5px #E4E6CE",t.style.maxWidth="500px",t.style.color="var(--gray-6)"}(d=l),document.body.append(d),e.addEventListener("click",()=>{!function(t,e){!function(t,e){const n=t.getBoundingClientRect().toJSON();e.style.inset="unset",e.style.top=n.y+"px",e.style.left=n.x+20+"px"}(t,e),e.showPopover()}(a,l)})),e.append(u),r&&e.append(o.span([a],{style:{paddingLeft:"10px"}}))})),e}renderIcon(t){if(null!=t.options.icon&&(t.options.icon.startsWith("http://")||t.options.icon.startsWith("https://")))return o.iconImage("model-icon",t.options.icon);let e=(0,l.bP)(t);if(t instanceof s.Script&&(null==e||null==t.options.icon))return this.getLanguageIcon(t.language);if(t=s.Func.find({package:t.package.name,name:t.name})[0],e=(0,l.bP)(t),!e)return o.iconSvg("project");let n=null==e?void 0:e.getIconUrl();if(null!=t.options.icon){const e=n.split("/");e.pop(),e.push(t.options.icon),n=e.join("/")}return o.iconImage(t.package.name,n)}renderView(t){const e=o.div();return this.renderPreview(t).then(t=>e.appendChild(t.root)),e}renderPreview(t){const e=Object.create(null,{renderPreview:{get:()=>super.renderPreview}});return u(this,void 0,void 0,function*(){return s.View.fromViewAsync(()=>u(this,void 0,void 0,function*(){var n,i,r;const a=yield(0,l.zF)(t),u=yield this.awaitUserGroups(),d=c.getMissingGroups(t,u);if(!(null==d?void 0:d.length)&&("Compute2:TreeWizardEditor"===t.options.editor||"Compute2:RichFunctionViewEditor"===t.options.editor)){const e=t.prepare();return(yield s.Func.byName(t.options.editor).prepare({call:e}).call()).getOutputParamValue()}const p=yield e.renderPreview.call(this,t);p.name=(null!==(n=t.friendlyName)&&void 0!==n?n:t.name)+" preview";const h=(null==d?void 0:d.length)?o.div([this.makeMandatoryGroupsInfo(d)],{style:{border:"2px solid var(--red-3)",padding:"10px",maxWidth:"400px"}}):o.div([o.bigButton("Launch",()=>t.prepare().edit())]);return p.append(o.div([o.h1(null!==(i=t.friendlyName)&&void 0!==i?i:t.name),o.divText(null!==(r=t.description)&&void 0!==r?r:t.name,{style:{marginBottom:"10px"}}),h,o.div([],{style:{padding:"20px "}}),o.markdown(null!=a?a:"")],{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"}})),p}))})}renderProperties(t){const e=o.accordion("ComputeModel");e.context=t;const n=o.div([o.span([this.renderIcon(t),o.label(t.friendlyName),o.contextActions(t),o.star(t.id)])]);return e.addTitle(n),null!=t.description&&n.appendChild(o.div([o.markdown(t.description)],"model-catalog-description")),n.appendChild(o.tags(t)),null!=t.options["dev.status"]&&n.appendChild(o.tableFromMap({Status:t.options["dev.status"]})),e.end(),e.root}renderTooltip(t){const e=o.span([this.renderIcon(t),o.label(t.friendlyName)]);return e.classList.add("d4-link-label"),o.bind(t,o.divV([o.h2(e),o.divV([o.divText(t.description,"ui-description")],{style:{lineHeight:"150%"}})]))}renderCard(t){const e=this.renderMarkup(t);return e.classList.add("d4-link-label"),o.bind(t,o.h2(e))}init(){this.registerParamFunc("Choose version",t=>{c.openVersionSelectDialog(s.toJs(t))}),this.registerParamFunc("Help",t=>{c.openHelp(s.toJs(t))});const t=new s.Functions,e=t=>t instanceof s.Entity,n=t=>i.shell.favorites.some(e=>e.id==t.id);t.registerParamFunc("Add to favorites",this.type,t=>u(this,void 0,void 0,function*(){return yield s.Favorites.add(s.toJs(t))}),t=>{const i=s.toJs(t);return this.isApplicable(i)&&e(i)&&!n(i)}),t.registerParamFunc("Remove from favorites",this.type,t=>u(this,void 0,void 0,function*(){return yield s.Favorites.remove(s.toJs(t))}),t=>{const i=s.toJs(t);return this.isApplicable(i)&&e(i)&&n(i)}),setTimeout(()=>u(this,void 0,void 0,function*(){const t=yield c.getUserGroups();this.userGroups.next(t)}))}makeMandatoryGroupsInfo(t){const e=o.div(o.divV([o.label("You should be a member of the following group(s):",{style:{marginLeft:"0px"}}),...t.map(t=>o.divV([o.span([d(),t.name],{style:{fontWeight:"600"}}),...t.help?[o.span([t.help],{style:{marginLeft:"16px"}})]:[],o.link("Request group membership",()=>u(this,void 0,void 0,function*(){yield function(t){return u(this,void 0,void 0,function*(){try{const e=yield i.dapi.groups.filter(`friendlyName="${t}"`).list();if(0===e.length)throw new Error("group with specified name is not found");if(e.length>1)throw new Error("found more than one group with specified name");const n=e[0];yield fetch(`${window.location.origin}/api/groups/${n.id}/requests/${i.shell.user.group.id}`,{method:"POST"}),i.shell.info(`Request to join ${t} has been initiated. Please allow some time for approval.`)}catch(t){i.shell.error(t.toString())}})}(t.name),e.hidePopover()}),void 0,{style:{marginLeft:"16px"}})]))],{style:{gap:"10px"}}));return e}awaitUserGroups(){return u(this,void 0,void 0,function*(){return this.userGroups.pipe((0,a.filter)(t=>!!t),(0,a.map)(t=>t),(0,a.take)(1)).toPromise()})}}},3143(t,e,n){"use strict";n.d(e,{A:()=>i});var i,o=n(9879),s=n(8867),r=n(7109);!function(t){t.fileInput=function(t="Drag-n-drop here",e=null,n=null,i=o.R){return new o.z(t,e,n,i)},t.historyInput=function(t,e,n){return new s.PT(t,e,n)},t.historyInputJSON=function(t,e,n){return new s.RP(t,e,n)},t.historyPanel=function(t){return new r.b(t)}}(i||(i={}))},9879(t,e,n){"use strict";n.d(e,{R:()=>a,z:()=>l});var i=n(7389),o=n(6082),s=n(1858),r=(n(6998),function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})});const a="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class l extends o.InputBase{get value(){return this.fileValue}set value(t){this.stringValue=(null==t?void 0:t.name)||"Drag-n-drop your file",this.fileValue=t,this.notify&&this.fireInput()}constructor(t="Drag-n-drop here",e=null,n=null,o=a){super(i.input.string("Input file",{value:""}).dart),this.initialText=t,this.initialValue=e,this.onValueChanged=n,this.fileType=o,this.uploadedFile$=new s.Subject,this.onFileUploaded=this.uploadedFile$,this.fileValue=null,this.isValid=new s.BehaviorSubject(!0),this.hiddenInput=document.createElement("input"),this.icon=i.iconFA("cloud-upload",()=>this.hiddenInput.click()),this.subscribeOnEvents(),this.root.style.display="flex",this.isValid.subscribe(t=>{if(t){this.input.classList.remove("error"),this.input.classList.add("success");const t=i.iconFA("times",()=>this.reset(),"Reset uploaded file");this.icon.replaceWith(t),this.icon=t}else{this.input.classList.remove("success"),this.input.classList.add("error");const t=i.iconFA("redo",()=>this.hiddenInput.click(),"Re-upload a file");this.icon.replaceWith(t),this.icon=t}}),this.uploadedFile$.subscribe(t=>{if(this.onValueChanged&&this.onValueChanged(t),!t){const t=i.iconFA("cloud-upload",()=>this.hiddenInput.click(),"Choose a file to upload");this.icon.replaceWith(t),this.icon=t}this.value=t}),this.reset()}subscribeOnEvents(){this.input.readOnly=!0,this.input.classList.add("default");const t=t=>r(this,void 0,void 0,function*(){if(t&&t.length&&this.enabled){if(t.length>1)throw this.isValid.next(!1),new Error("Please specify single input file");if(this.fileType&&t[0].type!==this.fileType)throw this.isValid.next(!1),new Error("File type is not supported");this.isValid.value?this.uploadedFile$.next(t[0]):this.uploadedFile$.next(null)}});this.root.classList.add("fi-drop-area"),this.root.style.width="100%",this.hiddenInput.type="file",this.hiddenInput.addEventListener("change",()=>r(this,void 0,void 0,function*(){return yield t(this.hiddenInput.files)}),!1),["dragenter","dragover","dragleave","drop"].forEach(t=>{this.input.addEventListener(t,t=>{t.preventDefault(),t.stopPropagation()},!1)}),["dragenter","dragover"].forEach(t=>{this.input.addEventListener(t,()=>{this.input.classList.add("drag-n-dropping")},!1)}),["dragleave","drop"].forEach(t=>{this.input.addEventListener(t,()=>{this.input.classList.remove("drag-n-dropping")},!1)}),this.input.addEventListener("drop",e=>r(this,void 0,void 0,function*(){const n=e.dataTransfer.files;t(n)}),!1),this.input.addEventListener("click",()=>this.hiddenInput.click(),!1),this.addOptions(this.icon),["drag","dragenter"].forEach(t=>{document.getElementsByClassName("layout-workarea")[0].addEventListener(t,t=>{t.stopPropagation()},!1)})}reset(){this.input.classList.value="ui-input-editor default",this.hiddenInput.value="",this.uploadedFile$.next(null)}}},8867(t,e,n){"use strict";n.d(e,{PT:()=>g,RP:()=>y});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=n(9713),l=n(1757),u=n.n(l),d=n(5092),c=(n(9192),n(5355)),p=n(1599),h=n(6910),f=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class v{static getHistoryRuns(t,e=!0){return(0,r.from)((()=>f(this,void 0,void 0,function*(){return yield d.W.pullRunsByName(t,[{author:i.shell.user}],{order:"started"},["func.params","session.user","options"],e)}))())}}class m extends s.InputBase{constructor(t,e,n){var i,s;const l=o.input.string(t,{value:""});super(l.dart),this.label=t,this._funcName=e,this.options=n,this.onHistoricalRunChosen=new r.BehaviorSubject(null),this.experimentRunsUpdate=new r.Subject,this.store={experimentRuns:new r.Observable,isExperimentRunsLoading:new r.Subject,experimentRunData:new r.BehaviorSubject("")},this._historyList=new c.H([],{fallbackText:"No runs are found in history",showActions:!1,showBatchActions:!1,isHistory:!1,visibleProps:null===(i=this.options)||void 0===i?void 0:i.mainProps,propFuncs:null===(s=this.options)||void 0===s?void 0:s.propFuncs}),this._historyDialog=this.getHistoryDialog(),this._visibleInput=o.input.string(this.label,{value:""}),this._visibleIcon=o.iconFA("search",()=>this.showSelectionDialog()),this._chosenRun=null,this._chosenRunId=null,this._visibleInput=l,this._visibleInput.readOnly=!0,this._visibleInput.input.addEventListener("click",()=>this.showSelectionDialog()),this._visibleInput.addOptions(this._visibleIcon),this.store.experimentRuns=this.experimentRunsUpdate.pipe((0,a.tap)(()=>this.toggleLoaderExpRuns(!0)),(0,a.switchMap)(()=>{var t,e;return v.getHistoryRuns(this._funcName,null===(e=null===(t=this.options)||void 0===t?void 0:t.skipDfsOnInit)||void 0===e||e).pipe((0,a.catchError)(t=>(console.error(t),r.EMPTY)),(0,a.finalize)(()=>this.toggleLoaderExpRuns(!1)))}),(0,a.shareReplay)(1)),this.store.experimentRuns.subscribe(t=>{this._historyList.updateRuns(t.filter(t=>!(0,p.Ne)(t)))}),this.store.isExperimentRunsLoading.subscribe(t=>{o.setUpdateIndicator(this._visibleInput.root,t),o.setUpdateIndicator(this._historyList.root,t)}),this.experimentRunsUpdate.next()}setCurrentRow(){this.getValue()?this._historyList.chosen=this.getValue():this.chosenRunId&&(this._historyList.chosenById=this.chosenRunId)}showSelectionDialog(){this.renderGridAndFilters(),this._historyDialog.getButton("OK").disabled=1!==this._historyList.selected.size,this._historyDialog.show({modal:!0,fullScreen:!0,center:!0,width:window.innerWidth-50,height:window.innerHeight-50})}renderGridAndFilters(){var t,e;const n=new c.H([...this._historyList.runs.values()],Object.assign(Object.assign({},this.options),{visibleProps:null===(t=this.options)||void 0===t?void 0:t.mainProps,propFuncs:null===(e=this.options)||void 0===e?void 0:e.propFuncs}));this._historyList.root.replaceWith(n.root),this._historyList=n,this._historyList.onChosen.subscribe(t=>{this._historyDialog.getButton("OK").disabled=!t}),this._historyList.onRunsDfChanged.pipe((0,a.filter)(t=>t.rowCount>0),(0,a.take)(1)).subscribe(()=>{this.setCurrentRow()})}getHistoryDialog(){const t=o.dialog();return u()(t.root.querySelector(".d4-dialog-contents")).removeClass("ui-form"),t.onOK(()=>f(this,void 0,void 0,function*(){var t,e;let n=this._historyList.chosen;n&&((null===(e=null===(t=this.options)||void 0===t?void 0:t.skipDfsOnInit)||void 0===e||e)&&(n=yield d.W.loadRun(n.id)),this.setValue(n)),this.fireInput()})),t.addButton("Refresh",()=>{this.experimentRunsUpdate.next()},2,"Reload list of runs"),t.addButton("Discard",()=>{this.setValue(null),this.fireInput(),t.close()},1,"Discard the previous choice"),u()(t.getButton("CANCEL")).hide(),t.add(this._historyList.root),t}setValue(t){var e,n,i,o,s,r,a;this._chosenRun=t,this._chosenRunId=null!==(n=null===(e=this._chosenRun)||void 0===e?void 0:e.id)&&void 0!==n?n:null,this.onHistoricalRunChosen.next(t),this.stringValue=t?(null===(i=this.options)||void 0===i?void 0:i.stringValueFunc)?null===(o=this.options)||void 0===o?void 0:o.stringValueFunc(t):[`${(0,p.eK)(t)} \\ ${t.author.name}`,(null!==(a=null!==(r=null===(s=this.options)||void 0===s?void 0:s.mainProps)&&void 0!==r?r:(0,h.qg)(t.func))&&void 0!==a?a:[]).map(e=>(0,h.u8)(t,e)).join(" \\ ")].join(" \\ "):"No run chosen",this.notify&&this.fireChanged()}getValue(){return this._chosenRun}get chosenRun(){return this._chosenRun}get chosenRunId(){return this._chosenRunId}set chosenRunId(t){this._chosenRunId=t}get root(){return this._visibleInput.root}set stringValue(t){this._visibleInput.value=t,this._visibleInput.setTooltip(this._visibleInput.value)}get stringValue(){return this._visibleInput.value}get iconRoot(){return this._visibleIcon}toggleLoaderExpRuns(t){this.store.isExperimentRunsLoading.next(t)}}class g extends m{set value(t){this.setValue(t)}get value(){return this.getValue()}}class y extends m{get value(){const t=this.getValue();return t?JSON.stringify({visualValue:this.stringValue,id:t.id.split("-")}):null}set value(t){this.setValue(null),this.stringValue=t?JSON.parse(t).visualValue:"No run is chosen",this.chosenRunId=t?JSON.parse(t).id.join("-"):""}}},5355(t,e,n){"use strict";n.d(e,{H:()=>x});var i=n(4328),o=n(7389),s=n(6082),r=n(1991),a=n.n(r),l=n(1757),u=n.n(l),d=n(1858),c=n(9713),p=n(5092),h=n(4260),f=n(3508),v=n.n(f),m=n(4112),g=n.n(m),y=n(8804),b=n(6910),C=n(4795),w=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};v().extend(g());const A=new s.LruCache;class x extends s.Widget{get type(){return"HistoricalRunsList"}get onRunsDfChanged(){return this._onRunsDfChanged.asObservable()}get onChosen(){return this._onChosen.asObservable()}get chosen(){return this._onChosen.value}set chosen(t){var e;this.chosenById=null!==(e=null==t?void 0:t.id)&&void 0!==e?e:null}set chosenById(t){if(t){for(let e=0;e<this.currentDf.rowCount;e++)if(this.currentDf.getCol(h.vw).get(e)===t){this.currentDf.currentRowIdx=e;break}}else this.currentDf.currentRowIdx=-1}get selected(){return this._onSelectedChanged.value}get runs(){return this.onRunsChanged.value}get onSelectedChanged(){return this._onSelectedChanged.asObservable()}getRunByIdx(t){return this.runs.get(this.currentDf.get(h.vw,t))}showEditDialog(t,e){const n=y.V.forFuncCall(t,e);n.onMetadataEdit.pipe((0,c.take)(1)).subscribe(n=>w(this,void 0,void 0,function*(){var o;if(null===(o=this.options)||void 0===o?void 0:o.isHistory)try{!!n.isFavorite!==e&&(yield(0,b.WM)(t,!!n.isFavorite));const i=yield p.W.shallowLoadRun(t.id);n.title&&(i.options.title=n.title),n.description&&(i.options.description=n.description),n.tags&&(i.options.tags=n.tags),yield p.W.updateRunMeta(i),this.updateRun(i),this.onMetadataEdit.next(i)}catch(t){i.shell.error(t)}else this.updateRun(t)})),n.show({center:!0,width:500})}constructor(t,e){var n,r,l,f,v,m,g;super(o.div([],{style:{height:"100%",width:"100%"}})),this.initialRuns=t,this.options=e,this.onRunsChanged=new d.BehaviorSubject(this.initialRuns.reduce((t,e)=>(t.set(e.id,e),t),new Map)),this._onRunsDfChanged=new d.BehaviorSubject(s.DataFrame.fromColumns([s.Column.bool(h.d1,0),...(null===(n=this.options)||void 0===n?void 0:n.isHistory)?[s.Column.bool(h.iL,0)]:[],...(null===(r=this.options)||void 0===r?void 0:r.showActions)?[s.Column.string(h.zY,0)]:[],s.Column.bool(h.pC,0),s.Column.dateTime(h.bV,0),s.Column.string(h.l8,0),s.Column.string(h.lv,0),s.Column.string(h.qh,0),s.Column.string(h.Ts,0),s.Column.fromStrings(h.vw,[])])),this._historyFilters=s.Viewer.filters(this._onRunsDfChanged.value,{title:"Filters",columnNames:[]}),this._historyGrid=s.Viewer.grid(this._onRunsDfChanged.value,{showRowHeader:!1,showColumnGridlines:!1,allowEdit:!1}),this.onComparisonCalled=new d.Subject,this.onMetadataEdit=new d.Subject,this._onChosen=new d.BehaviorSubject(null),this.onDelete=new d.Subject,this._onSelectedChanged=new d.BehaviorSubject(new Set([])),this.layout=o.splitH([],null,!0),this.defaultGridText=o.divText(null!==(f=null===(l=this.options)||void 0===l?void 0:l.fallbackText)&&void 0!==f?f:"No historical runs found","hp-no-elements-label"),this.defaultFiltersText=o.divText("No filters to show","hp-no-elements-label"),this.filterWithText=o.divH([this.defaultFiltersText,this._historyFilters.root],"ui-box"),this.trashIcon=o.div(o.iconFA("trash-alt",()=>{const t=this.currentDf.selection.getSelectedIndexes(),e=new Set;t.forEach(t=>e.add(this.getRunByIdx(t)));const n=new y.C(e);n.onFuncCallDelete.pipe((0,c.take)(1)).subscribe(t=>w(this,void 0,void 0,function*(){o.setUpdateIndicator(this.root,!0);try{yield Promise.all(a()(t.values()).map(t=>w(this,void 0,void 0,function*(){return yield this.deleteRun(t.id),Promise.resolve()})))}catch(t){i.shell.error(t)}finally{o.setUpdateIndicator(this.root,!1)}})),n.show({center:!0,width:500,modal:!0})},"Delete selected runs"),{style:{paddingTop:"5px"}}),this.compareIcon=o.div(o.iconFA("exchange",()=>w(this,void 0,void 0,function*(){const t=this.currentDf.selection.getSelectedIndexes(),e=[];t.forEach(t=>{e.push(this.currentDf.getCol(h.vw).get(t))}),this.onComparisonCalled.next(e)}),"Compare selected runs"),{style:{paddingTop:"5px"}}),this._isFilterHidden=new d.BehaviorSubject(!1),this.showFiltersIcon=o.div(o.iconFA("filter",()=>{this._isFilterHidden.next(!this._isFilterHidden.value)},"Toggle filters"),{style:{paddingTop:"4px"}}),this._compactMode=new d.BehaviorSubject(null!==(m=null===(v=this.options)||void 0===v?void 0:v.isHistory)&&void 0!==m&&m),this.toggleCompactMode=o.div(o.iconFA("expand-alt",()=>{this.compactMode=!this.compactMode},"Toggle compact mode"),{style:{paddingTop:"4px"}}),this.showMetadataIcon=o.input.toggle("Metadata",{value:!0,onValueChanged:()=>{this.styleHistoryGrid(),this.styleHistoryFilters()}}),this.showInputsIcon=o.input.toggle("Params",{value:!1,onValueChanged:t=>w(this,void 0,void 0,function*(){var e;0!==this.runs.size&&(t&&(null===(e=this.options)||void 0===e?void 0:e.isHistory)?((yield Promise.all([...this.runs.values()].map(t=>w(this,void 0,void 0,function*(){if(A.has(t.id))return A.get(t.id);{const e=yield p.W.shallowLoadRun(t.id);return A.set(e.id,e),e}})))).forEach(t=>{this.runs.set(t.id,t)}),this.onRunsChanged.next(this.runs)):(this.styleHistoryGrid(),this.styleHistoryFilters()))})});const C=o.divH([o.divH([...(null==e?void 0:e.isHistory)?[this.toggleCompactMode]:[],this.showFiltersIcon,this.showMetadataIcon.root,this.showInputsIcon.root],{style:{gap:"5px",padding:"5px"}}),o.divH((null===(g=this.options)||void 0===g?void 0:g.showBatchActions)?[this.trashIcon,this.compareIcon]:[],{style:{gap:"5px",padding:"5px"}})],{style:{justifyContent:"space-between",padding:"0px 5px"}});C.style.setProperty("overflow-y","hidden","important");const x=o.divV([this.defaultGridText,C,this._historyGrid.root],"ui-box");u()(x).removeClass("ui-div"),u()(x).css("width","100%"),this.root.appendChild(this.layout),o.setDisplayAll([this._historyGrid.root,this._historyFilters.root,this.toggleCompactMode,this.trashIcon,this.compareIcon,this.showFiltersIcon],!1);const E=this.onRunsChanged.subscribe(t=>w(this,void 0,void 0,function*(){if(this.setGridCellRendering(),t.size>0){const e=yield(0,b.BV)(t,t.values().next().value.func,this.options),n=t.values().next().value.func;o.setDisplayAll([this.defaultGridText,this.defaultFiltersText],!1),o.setDisplayAll([this._historyGrid.root,this._historyFilters.root,this.toggleCompactMode,this.showMetadataIcon.root,this.trashIcon,this.compareIcon,this.showFiltersIcon],!0),o.setDisplay(this.showInputsIcon.root,(0,b.rs)(n,this.options).length>0),this._onRunsDfChanged.next(e)}else o.setDisplayAll([this.defaultGridText,this.defaultFiltersText],!0),o.setDisplayAll([this._historyGrid.root,this._historyFilters.root,this.showMetadataIcon.root,this.showInputsIcon.root,this.toggleCompactMode,this.trashIcon,this.compareIcon,this.showFiltersIcon],!1)})),I=this._onRunsDfChanged.subscribe(t=>{this._historyFilters.dataFrame=t,this._historyGrid.dataFrame=t,this.currentDf.getCol(h.lv).meta.multiValueSeparator=",",this.styleHistoryGrid(),this.styleHistoryFilters();const e=t.onCurrentRowChanged.subscribe(()=>{var t;this.currentDf.rows.select(()=>!1),this._onChosen.next(null!==(t=this.getRunByIdx(this.currentDf.currentRowIdx))&&void 0!==t?t:null)}),n=t.onSelectionChanged.subscribe(()=>{const e=[...t.selection.getSelectedIndexes()].map(t=>this.getRunByIdx(t));this._onSelectedChanged.next(new Set(e)),this.redrawSelectionState()});this.redrawSelectionState(),this.subs.push(e,n)}),R=this._isFilterHidden.subscribe(t=>{t?(u()(this.showFiltersIcon.firstChild).addClass("fal"),u()(this.showFiltersIcon.firstChild).removeClass("fad"),o.setDisplay(this.filterWithText,!1)):(u()(this.showFiltersIcon.firstChild).addClass("fad"),u()(this.showFiltersIcon.firstChild).removeClass("fal"),u()(this.filterWithText).css(this.compactMode?"height":"width","320px"),u()(this.filterWithText).css(this.compactMode?"width":"height","100%"),o.setDisplay(this.filterWithText,!0))}),T=this._compactMode.subscribe(t=>{const e=[x,this.filterWithText];u()(this.filterWithText).removeClass("ui-div");const n={style:{width:"100%",height:"100%"}};u()(this.toggleCompactMode.firstChild).addClass(t?"fa-expand-alt":"fa-compress-alt"),u()(this.toggleCompactMode.firstChild).removeClass(t?"fa-compress-alt":"fa-expand-alt");const i=t?o.splitV(e,n,!0):o.splitH(e,n,!0);this.layout.replaceWith(i),this.layout=i,o.tools.waitForElementInDom(this.layout).then(t=>{u()(t).css(this.compactMode?"height":"width","100%"),u()(this._historyFilters.root).css(Object.assign({},this.compactMode?{width:"100%"}:{height:"100%"})),u()(this.filterWithText).css(Object.assign({},this.compactMode?{height:"310px",width:"100%"}:{width:"310px",height:"100%"})),u()(x).css(Object.assign({},this.compactMode?{width:"100%"}:{height:"100%"})),setTimeout(()=>{this.styleHistoryGrid(),this.styleHistoryFilters()},100)})});this.subs.push(E,T,I,R)}isFavoriteByIndex(t){return this.currentDf.get(h.iL,t)}setGridCellRendering(){var t,e;(0,b.VI)(this._historyGrid,this.runs,t=>{const e=this.getRunByIdx(t.tableRowIndex);this.showEditDialog(e,this.isFavoriteByIndex(t.tableRowIndex))},t=>{const e=new Set([this.getRunByIdx(t.tableRowIndex)]),n=new y.C(e);n.onFuncCallDelete.pipe((0,c.take)(1)).subscribe(()=>w(this,void 0,void 0,function*(){o.setUpdateIndicator(this.root,!0);try{yield Promise.all(a()(e.values()).map(t=>w(this,void 0,void 0,function*(){return yield this.deleteRun(t.id),Promise.resolve()})))}catch(t){i.shell.error(t)}finally{o.setUpdateIndicator(this.root,!1)}})),n.show({center:!0,width:500})},t=>{const e=this.getRunByIdx(t.tableRowIndex);(0,b.WM)(e,!0).then(()=>this.updateRun(e))},t=>{const e=this.getRunByIdx(t.tableRowIndex);(0,b.WM)(e,!1).then(()=>this.updateRun(e))},null!==(e=null===(t=this.options)||void 0===t?void 0:t.showActions)&&void 0!==e&&e)}deleteRun(t){return w(this,void 0,void 0,function*(){return p.W.shallowLoadRun(t).then(t=>w(this,void 0,void 0,function*(){var e;return[yield(null===(e=this.options)||void 0===e?void 0:e.isHistory)?p.W.deleteRun(t):Promise.resolve(),t]})).then(([,e])=>{var n;return this.runs.delete(t),this.onRunsChanged.next(this.runs),(null===(n=this.options)||void 0===n?void 0:n.isHistory)&&this.onDelete.next(e),e}).then(t=>{(0,b.WM)(t,!1)}).catch(t=>{i.shell.error(t)})})}editRun(t){this.showEditDialog(t,!1)}updateRun(t){this.runs.set(t.id,t),this.onRunsChanged.next(this.onRunsChanged.value)}addRun(t){this.runs.set(t.id,t),this.onRunsChanged.next(this.onRunsChanged.value)}updateRuns(t){this.onRunsChanged.next(t.reduce((t,e)=>(t.set(e.id,e),t),new Map))}get isFilterHidden(){return this._isFilterHidden.value}set isFilterHidden(t){this._isFilterHidden.next(t)}get compactMode(){return this._compactMode.value}set compactMode(t){this._compactMode.next(t)}get onCompactModeChanged(){return this._compactMode.asObservable()}styleHistoryGrid(){var t;(0,C.sy)(this._historyGrid,this._compactMode.value,this.showInputsIcon.value,this.showMetadataIcon.value,null===(t=this.runs.values().next().value)||void 0===t?void 0:t.func)}get currentDf(){return this._onRunsDfChanged.value}styleHistoryFilters(){var t,e,n;const i=null===(t=this.runs.values().next().value)||void 0===t?void 0:t.func;(0,C.LL)(this._historyFilters,this.showMetadataIcon.value,this.showInputsIcon.value,null!==(n=null===(e=this.options)||void 0===e?void 0:e.isHistory)&&void 0!==n&&n,i)?(u()(this.filterWithText).css({paddingTop:"10px"}),o.setDisplay(this.defaultFiltersText,!1)):o.setDisplay(this.defaultFiltersText,!0)}redrawSelectionState(){const t=this.currentDf.selection.trueCount;t<2?this.compareIcon.firstChild.classList.add("hp-disabled"):this.compareIcon.firstChild.classList.remove("hp-disabled"),0===t?this.trashIcon.firstChild.classList.add("hp-disabled"):this.trashIcon.firstChild.classList.remove("hp-disabled")}}},7109(t,e,n){"use strict";n.d(e,{b:()=>d});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=n(5092),l=(n(8550),n(5355)),u=n(9713);class d extends s.Widget{get type(){return"HistoryPanel"}updateHistoryPane(t){this.historyList.updateRuns(t)}showEditDialog(t){this.historyList.editRun(t)}addRun(t){this.historyList.addRun(t)}get history(){return this.historyList.runs}get onCompactModeChanged(){return this.historyList.onCompactModeChanged}get compactMode(){return this.historyList.compactMode}constructor(t){super(o.box(o.divText("No historical runs loaded","hp-no-elements-label"),{style:{width:"100%",height:"100%"}})),this.func=t,this.onRunChosen=new r.Subject,this.onComparison=new r.Subject,this.afterRunEdited=new r.Subject,this.afterRunDeleted=new r.Subject,this.allRunsFetch=new r.Subject,this.historyList=new l.H([],{fallbackText:"No runs are found in history",showActions:!0,showBatchActions:!0,isHistory:!0}),this.panel=this.historyList.root;const e=this.historyList.onChosen.pipe((0,u.filter)(t=>!!t)).subscribe(t=>this.onRunChosen.next(t.id)),n=this.historyList.onComparisonCalled.subscribe(t=>this.onComparison.next(t)),s=this.allRunsFetch.subscribe(()=>{return t=this,e=void 0,s=function*(){o.setUpdateIndicator(this.root,!0),a.W.pullRunsByName(this.func.name,[{author:i.shell.user}],{},["session.user","options"]).then(t=>{o.empty(this.root),this.root.appendChild(this.panel),this.updateHistoryPane(t)}).catch(t=>i.shell.error(t)).finally(()=>o.setUpdateIndicator(this.root,!1))},new((n=void 0)||(n=Promise))(function(i,o){function r(t){try{l(s.next(t))}catch(t){o(t)}}function a(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((s=s.apply(t,e||[])).next())});var t,e,n,s}),d=this.historyList.onMetadataEdit.subscribe(t=>{this.afterRunEdited.next(t)}),c=this.historyList.onDelete.subscribe(t=>{this.afterRunDeleted.next(t)});this.subs.push(e,s,d,n,c),this.allRunsFetch.next()}}},5727(t,e,n){"use strict";n.d(e,{Ee:()=>s.E,HJ:()=>o.H,bS:()=>r.b,uf:()=>i.u}),n(2244);var i=n(8194),o=n(1059),s=n(873),r=n(6318)},1059(t,e,n){"use strict";n.d(e,{H:()=>o});var i=n(2244);class o extends i.s{}},2244(t,e,n){"use strict";n.d(e,{s:()=>I});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=n(1757),l=n.n(a),u=n(3508),d=n.n(u),c=n(5092),p=n(4260),h=n(1599),f=n(5520),v=n(8476),m=n(3143),g=n(810),y=n(9713),b=n(4795),C=n(9879),w=n(6318),A=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const x=new URL(i.shell.startUri),E=()=>A(void 0,void 0,void 0,function*(){const t=yield navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,selfBrowserSurface:"include"}),e=new MediaRecorder(t),n=[];e.ondataavailable=t=>n.push(t.data),e.onstop=()=>{const e=new Blob(n,{type:n[0].type});t.getVideoTracks()[0].stop(),s.Utils.download(`Recording ${(new Date).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}.mkv`,e,n[0].type)},e.start()});class I extends s.ViewBase{constructor(t,e={historyEnabled:!0,isTabbed:!1,skipInit:!1}){var n,a,l,u,d;super(),this.initValue=t,this.options=e,this._type="function",this.funcCallReplaced=new r.Subject,this.isReady=new r.BehaviorSubject(!1),this.exportConfig=null,this.getMocks=null,this.getTemplates=null,this.getHelp=null,this.reportBug=null,this.requestFeature=null,this.getAbout=null,this.historyBlock=null,this.isHistorical=new r.BehaviorSubject(!1),this.historyRoot=o.div(),this.consistencyState=new r.BehaviorSubject("consistent"),this.defaultExportFilename=(t,e)=>`${this.name} - ${(new Date).toLocaleString("en-US").replaceAll(/:|\//g,"-")}.${null!=e?e:this.exportConfig.supportedExtensions[t]}`,this.defaultSupportedExportExtensions=()=>({Excel:"xlsx"}),this.defaultSupportedExportFormats=()=>["Excel"],this.box=!0,this.parentCall=i.functions.getCurrentCall(),t instanceof s.FuncCall&&(this.parentCall=t),this.parentView=null===(l=null===(a=null===(n=this.parentCall)||void 0===n?void 0:n.parentCall)||void 0===a?void 0:a.aux)||void 0===l?void 0:l.view,(null===(d=null===(u=this.parentCall)||void 0===u?void 0:u.func)||void 0===d?void 0:d.name)&&(this.basePath=`/${this.parentCall.func.name}`),e.skipInit||this.init()}onFuncCallReady(){return A(this,void 0,void 0,function*(){if(!this.options.isTabbed){this.name&&"New view"!==this.name||(this.name=this.funcCall.func.friendlyName);try{this.func.package&&(yield this.getPackageData())}catch(t){console.log(t)}}this.build();const t=this.getStartId();if(t&&!this.options.isTabbed&&(o.setUpdateIndicator(this.root,!0),this.loadRun(t),o.setUpdateIndicator(this.root,!1),this.setAsLoaded()),this.isHistoryEnabled&&this.func){const t=this.options.isTabbed?this.isHistorical.subscribe(t=>{t||(this.funcCall.id=null)}):this.isHistorical.subscribe(t=>{var e,n;if(t){this.path=`?id=${this.funcCall.id}`;const t=(0,h.eK)(this.funcCall);this.name.indexOf(" — ")<0?this.name=`${this.name} — ${null!==(e=this.funcCall.options.title)&&void 0!==e?e:t}`:this.name=`${this.name.substring(0,this.name.indexOf(" — "))} — ${null!==(n=this.funcCall.options.title)&&void 0!==n?n:t}`}else this.path="",this.funcCall.id=null,this.name=`${this.name.substring(0,this.name.indexOf(" — ")>0?this.name.indexOf(" — "):void 0)}`});this.subs.push(t)}})}getStartId(){return i.shell.getVar("isLoaded")?void 0:x.searchParams.get("id")}setAsLoaded(){return i.shell.setVar("isLoaded",!0)}get funcCall(){return this._funcCall}get func(){var t;return null===(t=this.funcCall)||void 0===t?void 0:t.func}get lastCall(){return this._lastCall}set lastCall(t){this._lastCall=t}get type(){return this._type}getPackageData(){return A(this,void 0,void 0,function*(){var t,e;const n=this.func.package;if(!n)return;const i=null===(t=yield null==n?void 0:n.getProperties())||void 0===t?void 0:t.REPORT_BUG_URL;i&&!this.reportBug&&(this.reportBug=()=>A(this,void 0,void 0,function*(){window.open(i,"_blank")}));const o=null===(e=yield null==n?void 0:n.getProperties())||void 0===e?void 0:e.REQUEST_FEATURE_URL;o&&!this.requestFeature&&(this.requestFeature=()=>A(this,void 0,void 0,function*(){window.open(o,"_blank")}));const s=`${n.friendlyName}.\nLast updated on ${d()(n.updatedOn).format("YYYY MMM D, HH:mm")}`;this.getAbout||(this.getAbout=()=>A(this,void 0,void 0,function*(){return s}))})}linkFunccall(t){this._funcCall=t,this.funcCallReplaced.next(!0)}loadFuncCallById(){return A(this,void 0,void 0,function*(){if(this.initValue instanceof s.FuncCall)return yield new Promise(t=>setTimeout(t,0)),void this.linkFunccall(this.initValue);o.setUpdateIndicator(this.root,!0);const t=this.getStartId();if(t&&!this.options.isTabbed)this.linkFunccall(yield c.W.loadRun(t));else{const t=s.Func.byName(this.initValue);this.linkFunccall(t.prepare({}))}o.setUpdateIndicator(this.root,!1)})}init(){return A(this,void 0,void 0,function*(){yield this.loadFuncCallById(),yield this.onFuncCallReady(),this.isReady.next(!0)})}build(){o.empty(this.root),this.root.appendChild(this.buildIO()),this.options.historyEnabled&&this.isHistoryEnabled&&this.buildHistoryBlock(),this.buildRibbonMenu(),this.buildRibbonPanels()}onComparisonLaunch(t){return A(this,void 0,void 0,function*(){const e=this.comparatorFunc;if(e){const n=s.Func.byName(e),o=(yield n.prepare({params:{comparedRuns:t}}).call()).outputs.comparisonView;return void i.shell.addView(o)}const n=i.shell.v.parentCall,o=[...i.shell.views].find(t=>t.type===p.sk),r=yield v.S.fromComparedRuns(t,this.func,{parentView:o,parentCall:n});i.shell.addView(r),r.defaultCustomize();const a=this.compareCustomizer;if(a){const t=s.Func.byName(a);return void(yield t.prepare({params:{defaultView:r}}).call())}})}onSaveClick(){return A(this,void 0,void 0,function*(){yield this.saveRun(this.funcCall)})}buildHistoryBlock(){const t=m.A.historyPanel(this.func);let e=!1;return this.subs.push(t.onCompactModeChanged.subscribe(t=>{const e=i.shell.dockManager.findNode(this.historyRoot);e&&(i.shell.dockManager.close(e),t?i.shell.dockManager.dock(this.historyRoot,"right",null,"History",.3):i.shell.dockManager.dock(this.historyRoot,"down",null,"History",.3))}),t.onRunChosen.subscribe(t=>A(this,void 0,void 0,function*(){o.setUpdateIndicator(this.root,!0),yield this.loadRun(t),o.setUpdateIndicator(this.root,!1)})),t.onComparison.subscribe(e=>A(this,void 0,void 0,function*(){(0,g.ZD)(t.root,!0);const n=yield Promise.all(e.map(t=>c.W.loadRun(t)));yield this.onComparisonLaunch(n),(0,g.ZD)(t.root,!1)})),t.afterRunEdited.subscribe(t=>{var e,n;if(t.id===this.funcCall.id&&t.options.title){this.path=`?id=${this.funcCall.id}`;const i=(0,h.eK)(t);this.name.indexOf(" — ")<0?this.name=`${this.name} — ${null!==(e=t.options.title)&&void 0!==e?e:i}`:this.name=`${this.name.substring(0,this.name.indexOf(" — "))} — ${null!==(n=t.options.title)&&void 0!==n?n:i}`}}),i.events.onViewRemoving.subscribe(t=>{if(t.args.view==this){const t=i.shell.dockManager.findNode(this.historyRoot);t?(i.shell.dockManager.close(t),e=!0):e=!1}}),i.events.onCurrentViewChanged.subscribe(()=>{var t;if(i.shell.v==this)e&&((null===(t=this.historyBlock)||void 0===t?void 0:t.compactMode)?i.shell.dockManager.dock(this.historyRoot,"right",null,"History",.3):i.shell.dockManager.dock(this.historyRoot,"down",null,"History",.3));else{const t=i.shell.dockManager.findNode(this.historyRoot);t?(i.shell.dockManager.close(t),e=!0):e=!1}})),o.empty(this.historyRoot),this.historyRoot.style.removeProperty("justify-content"),this.historyRoot.append(t.root),this.historyBlock=t,t.root}buildRibbonPanels(){const t=o.iconFA("history",()=>{var t;i.shell.dockManager.findNode(this.historyRoot)||((null===(t=this.historyBlock)||void 0===t?void 0:t.compactMode)?i.shell.dockManager.dock(this.historyRoot,"right",null,"History",.3):i.shell.dockManager.dock(this.historyRoot,"down",null,"History",.3),this.historyRoot.parentElement.classList.add("ui-box"),this.historyRoot.classList.add("ui-box"))}),e=o.iconFA("save",()=>A(this,void 0,void 0,function*(){yield this.onSaveClick()}),"Save current state"),n=o.comboPopup(o.iconFA("arrow-to-bottom"),this.getFormats(),this.exportRun.bind(this)),s=o.iconFA("edit",()=>{this.historyBlock&&this.lastCall&&this.historyBlock.showEditDialog(this.historyBlock.history.get(this.funcCall.id))},"Edit this run metadata"),r=this.isHistorical.subscribe(t=>{t?(o.setDisplay(n,!(0,h.Ne)(this.funcCall)),o.setDisplay(s,!0)):(l()(n).hide(),l()(s).hide())});if(this.subs.push(r),o.tooltip.bind(n,()=>"inconsistent"===this.consistencyState.value&&this.mandatoryConsistent?"Current run is inconsistent. Export feature is disabled.":null),!this.options.isTabbed&&this.mandatoryConsistent){const t=this.consistencyState.pipe((0,y.distinctUntilChanged)()).subscribe(t=>{"inconsistent"===t?(l()(n).addClass("d4-disabled"),l()(n.lastChild).css("color","unset")):(l()(n).removeClass("d4-disabled"),l()(n.lastChild).removeProp("color"))});this.subs.push(t)}const a=[[...!this.options.isTabbed&&this.isHistoryEnabled&&this.options.historyEnabled?[t]:[],...!this.options.isTabbed&&this.isHistoryEnabled?[e]:[],...!this.options.isTabbed&&this.isExportEnabled&&this.exportConfig&&this.exportConfig.supportedFormats.length>0?[n]:[],...this.options.isTabbed?[]:[s]]];return this.setRibbonPanels(a),a}buildRibbonMenu(){if(this.ribbonMenu.clear(),!(this.exportConfig||this.reportBug||this.requestFeature||this.getHelp||this.getMocks||this.getTemplates))return;const t=this.ribbonMenu.group("Model");if(this.getMocks&&this.getMocks.length>0)if(1===this.getMocks.length)t.item("Input data mock",this.getMocks[0].action);else{const e=t.group("Input data mocks");this.getMocks.forEach(t=>{e.item(t.mockName,t.action)}),t.endGroup()}if(this.getTemplates&&this.getTemplates.length>0)if(1===this.getTemplates.length)t.item("Input data template",this.getTemplates[0].action);else{const e=t.group("Input data templates");this.getTemplates.forEach(t=>{e.item(t.name,t.action)}),t.endGroup()}this.isExportEnabled&&this.exportConfig&&this.exportConfig.supportedFormats.length>0&&t.group("Export").items(this.getFormats(),this.exportRun.bind(this),{isValid:()=>this.isHistorical.value?this.mandatoryConsistent&&"inconsistent"===this.consistencyState.value?"Run should be consistent to be exported":null:"Run should be completed to be exported"}).endGroup(),this.reportBug&&t.item("Report a bug",()=>this.reportBug()),this.requestFeature&&t.item("Request a feature",()=>this.requestFeature()),this.getHelp&&t.item("Help",()=>this.getHelp()),setTimeout(()=>A(this,void 0,void 0,function*(){if((yield(yield fetch(`${window.location.origin}/api/groups/all_parents`)).json()).find(t=>"Developers"===t.friendlyName)){const e=t.group("Test runner");e.item("Run Data JSON",()=>this.importRunJsonDialog()),e.item("Execute Test JSON",()=>this.importRunJsonDialog()),e.item("Update Test JSON",()=>this.importRunJsonDialog(!0)),t.endGroup()}}),0),t.item("Record the screen",E),this.getAbout&&t.item("About",()=>A(this,void 0,void 0,function*(){const t=yield this.getAbout();if(t){const e=o.dialog("Current version");t.split("\n").forEach(t=>e.add(o.label(t))),e.onOK(()=>{}),e.getButton("CANCEL").style.display="none",e.show({center:!0})}}))}exportRun(t){return A(this,void 0,void 0,function*(){s.Utils.download(this.exportConfig.filename(t),yield this.exportConfig.export(t))})}getFormats(){var t,e;return null!==(e=null===(t=this.exportConfig)||void 0===t?void 0:t.supportedFormats)&&void 0!==e?e:[]}onBeforeSaveRun(t){return A(this,void 0,void 0,function*(){})}onAfterSaveRun(t){return A(this,void 0,void 0,function*(){})}saveRun(t){return A(this,void 0,void 0,function*(){let e=(0,h.A4)(t);yield this.onBeforeSaveRun(e),(0,h.Ne)(e)&&(e=yield(0,b.Hs)(t)),e.id&&e.newId();const n=yield c.W.saveRun(e),i=yield c.W.loadRun(n.id);return this.options.historyEnabled&&this.isHistoryEnabled&&this.historyBlock&&this.historyBlock.addRun(i),this.linkFunccall(i),this.isHistorical.next(!0),yield this.onAfterSaveRun(n),n})}onBeforeDeleteRun(t){return A(this,void 0,void 0,function*(){})}onAfterDeleteRun(t){return A(this,void 0,void 0,function*(){})}deleteRun(t){return A(this,void 0,void 0,function*(){return yield this.onBeforeDeleteRun(t),yield c.W.deleteRun(t),yield this.onAfterDeleteRun(t),t.id})}onBeforeLoadRun(){return A(this,void 0,void 0,function*(){})}onAfterLoadRun(t){return A(this,void 0,void 0,function*(){})}loadRun(t){return A(this,void 0,void 0,function*(){yield this.onBeforeLoadRun();const e=yield c.W.loadRun(t);return this.lastCall=(0,h.A4)(e),this.linkFunccall(e),this.isHistorical.next(!0),yield this.onAfterLoadRun(e),e})}onBeforeRun(t){return A(this,void 0,void 0,function*(){})}onAfterRun(t){return A(this,void 0,void 0,function*(){})}run(){return A(this,void 0,void 0,function*(){if(!this.funcCall)throw new Error("The correspoding function is not specified");yield this.onBeforeRun(this.funcCall);const t=s.TaskBarProgressIndicator.create("Calculating...");try{this.funcCall.newId(),yield this.funcCall.call(),yield this.onAfterRun(this.funcCall),this.lastCall=(0,h.A4)(this.funcCall),this.options.isTabbed||this.runningOnInput||!this.isHistoryEnabled||(yield this.saveRun(this.funcCall))}catch(t){i.shell.error(t.toString())}finally{t.close()}})}exportRunJson(){return A(this,void 0,void 0,function*(){if(this._lastCall){const t=yield(0,b.wB)(this._lastCall,this);return(0,f.lK)(t)}})}getRunJSON(){return A(this,void 0,void 0,function*(){const t=yield this.exportRunJson();t&&s.Utils.download(this.defaultExportFilename("","json"),t)})}importRunJsonDialog(){return A(this,arguments,void 0,function*(t=!1){const e=new C.z("JSON file",null,null,"application/json"),n={modal:!0,fullScreen:!0,width:500,height:200,center:!0};if(!(yield new Promise((t,i)=>{o.dialog({title:"Import Run JSON"}).add(o.div([o.inputs([e])])).onOK(()=>t(!0)).onCancel(()=>t(!1)).show(n)}))||!e.value)return;const i=(0,f.iu)(yield e.value.text());t?(yield this.executeTest(i,!0),yield this.isHistorical.pipe((0,y.filter)(t=>t),(0,y.take)(1),(0,y.delay)(0)).toPromise(),yield this.getRunJSON()):yield this.executeTest(i)})}executeTest(t){return A(this,arguments,void 0,function*(t,e=!1){yield(0,w.c)(t,this,{updateMode:e,interactive:!0})})}get compareCustomizer(){var t;return null!==(t=this.func.options.compareCustomizer)&&void 0!==t?t:null}get comparatorFunc(){var t;return null!==(t=this.func.options.comparatorFunc)&&void 0!==t?t:null}get uploadFunc(){var t;return null!==(t=this.func.options.uploadFunc)&&void 0!==t?t:null}get runningOnInput(){return(0,h.vk)(this.func)}get runningOnStart(){return"true"===this.func.options.runOnOpen}get mainParams(){return this.func.options.mainParams?JSON.parse(this.func.options.mainParams):null}get mandatoryConsistent(){var t;return"true"===(null===(t=this.parentCall)||void 0===t?void 0:t.func.options.mandatoryConsistent)}get hasContextHelp(){return!!(0,h.HP)(this.func)}getContextHelp(){return A(this,void 0,void 0,function*(){return(0,h.zF)(this.func)})}get features(){return(0,h.i)(this.func)}getFeature(t,e){return(0,h.x$)(this.features,t,e)}get isExportEnabled(){return this.getFeature("export",!0)}get isHistoryEnabled(){return this.getFeature("history",!0)}get isSaEnabled(){return this.getFeature("sens-analysis",!1)}get hasUploadMode(){return this.getFeature("upload",!1)}get isFittingEnabled(){return this.getFeature("fitting",!1)}get isOptimizationEnabled(){return this.getFeature("optimization",!1)}}},8194(t,e,n){"use strict";n.d(e,{u:()=>x});var i=n(4328),o=n(7389),s=n(6082),r=n(6267),a=n(1858),l=n(9713),u=n(1757),d=n.n(u),c=n(5092),p=n(4260),h=n(2244),f=(n(4315),n(5520)),v=n(1599),m=n(8920),g=n(8476),y=n(4795),b=n(6318),C=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const w=t=>{var e,n;return null!==(n=null===(e=t.options)||void 0===e?void 0:e.friendlyName)&&void 0!==n?n:t.func.name},A=t=>{var e;return null!==(e=t.customId)&&void 0!==e?e:t.funcName};class x extends h.s{set currentTabName(t){this.stepTabs.getPane(t)&&(this.stepTabs.currentPane=this.stepTabs.getPane(t))}getStepView(t){var e;return null===(e=this.steps[t])||void 0===e?void 0:e.view}getRunningUpdates(){return[]}disableSetters(t){}constructor(t,e,n={historyEnabled:!0,isTabbed:!1,skipInit:!1}){super(t,n),this.initialConfig=e,this.steps={},this.onStepCompleted=new a.Subject,this.isUpdating=new a.BehaviorSubject(!1),this.pipelineViewExportExtensions=()=>({Archive:"zip","Single Excel":"xlsx"}),this.pipelineViewExportFormats=()=>["Archive","Single Excel"],this.pipelineViewExport=t=>C(this,void 0,void 0,function*(){if(!this.stepTabs)throw new Error("Set step tabs please for export");if("Archive"===t){const t={};for(const e of Object.values(this.steps).filter(t=>t.visibility.value===m.L_.VISIBLE)){this.stepTabs.currentPane=this.stepTabs.getPane(w(e)),yield new Promise(t=>setTimeout(t,100));const n=yield e.view.exportConfig.export("Excel");t[e.view.exportConfig.filename("Excel")]=[new Uint8Array(yield n.arrayBuffer()),{level:0}]}return new Blob([(0,r.L)(t)])}if("Single Excel"===t){yield s.Utils.loadJsCss(["/js/common/exceljs.min.js"]);const t=window.ExcelJS,e="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8",n=new t.Workbook,i=(t,e,n)=>{let i=`${w(n)}>${e}`;i.length>31&&(i=`${i.slice(0,31)}`);let o=2;for(;t.worksheets.some(t=>t.name.toLowerCase()===i.toLowerCase());){let t=`${w(n)}>${e}`;t.length>31-`-${o}`.length&&(t=`${t.slice(0,31-`-${o}`.length)}`),i=`${t}-${o}`,o++}return i};for(const e of Object.values(this.steps).filter(t=>t.visibility.value===m.L_.VISIBLE)){const o=new t.Workbook;this.stepTabs.currentPane=this.stepTabs.getPane(w(e)),yield new Promise(t=>setTimeout(t,100)),yield o.xlsx.load(yield(yield e.view.exportConfig.export("Excel")).arrayBuffer()),o.eachSheet(t=>{const s=i(n,t.name,e),r=n.addWorksheet("New sheet");r.model=t.model,r.name=s,t.getImages().forEach(t=>{const e=n.addImage(o.getImage(t.imageId));r.addImage(e,t.range)})})}return new Blob([yield n.xlsx.writeBuffer()],{type:e})}throw new Error("This format is not supported")}),this.exportConfig={supportedExtensions:this.pipelineViewExportExtensions(),supportedFormats:this.pipelineViewExportFormats(),export:this.pipelineViewExport,filename:this.defaultExportFilename},this.helpFiles={}}init(){return C(this,void 0,void 0,function*(){yield this.loadFuncCallById(),this.initialConfig.forEach((t,e)=>{var n;this.steps[A(t)]={idx:e,visibility:new a.BehaviorSubject(null!==(n=t.hiddenOnInit)&&void 0!==n?n:m.L_.VISIBLE),ability:new a.BehaviorSubject(this.isHistorical.value||0===e?m.D.ENABLED:m.D.DISABLED),options:{friendlyName:t.friendlyName,helpUrl:t.helpUrl,customId:t.customId}}}),this.subs.push(i.functions.onAfterRunAction.pipe((0,l.filter)(t=>Object.values(this.steps).some(({view:e})=>{var n;return(null===(n=null==e?void 0:e.funcCall)||void 0===n?void 0:n.id)===(null==t?void 0:t.id)&&!!t}))).subscribe(t=>{this.onStepCompleted.next(t),"true"!==t.func.options.isMain&&t.func.nqName!==this.initialConfig[this.initialConfig.length-1].funcName||this.run()}));const t=this.initialConfig.map(t=>C(this,void 0,void 0,function*(){return{stepScript:s.Func.byName(t.funcName),stepId:A(t)}})),e=yield Promise.all(t);e.forEach(t=>{this.steps[t.stepId].func=t.stepScript}),this.root.classList.remove("ui-panel");const n={},r="Compute:PipelineStepEditor",u=e.map(t=>C(this,void 0,void 0,function*(){const e=t.stepScript.script?(t=>{const e=t.script,n=e.indexOf("editor:");if(n<0)return r;const i=e.indexOf("\n",n);return e.substring(n+7,i).trim()})(t.stepScript):r;return n[e]||(n[e]=s.Func.byName(e.split(" ").join(""))),this.steps[t.stepId].editor=e,Promise.resolve()}));yield Promise.all(u);const c=e.map(t=>C(this,void 0,void 0,function*(){const e=this.steps[t.stepId],r=t.stepScript.prepare(),u=n[e.editor];yield this.onBeforeStepFuncCallApply(t.stepScript.nqName,r,u);const c=yield u.apply({call:r});yield c.isReady.pipe((0,l.filter)(t=>!!t),(0,l.take)(1)).toPromise();const p=o.button("Back",()=>{},"Go to the previous step");d()(p).addClass("ui-btn-nav");const h=o.button("Next",()=>{},"Go to the next step");d()(h).addClass("ui-btn-nav"),this.syncNavButtons(e,p,h),c.setNavigationButtons([p,h]),this.steps[t.stepId].view=c;const f=this.steps[t.stepId],v=()=>{Object.values(this.steps).forEach(t=>{t.idx>f.idx&&t.visibility.value===m.L_.VISIBLE&&t.ability.value===m.D.ENABLED&&t.ability.next(m.D.DISABLED)})},g=f.view.funcCallReplaced.pipe((0,l.switchMap)(()=>{const t=[...f.view.funcCall.inputParams.values()].map(t=>t.onChanged.pipe((0,l.mapTo)(t)));return(0,a.merge)(...t)})),y=g.subscribe(v);this.subs.push(y);const b=g.pipe((0,l.filter)(t=>t.property.propertyType===s.TYPE.DATA_FRAME&&t.value),(0,l.switchMap)(t=>t.value.onDataChanged)).subscribe(v);this.subs.push(b);const C=i.functions.onAfterRunAction.pipe((0,l.filter)(t=>f.view.funcCall&&t&&!!t.id&&f.view.funcCall.id===t.id),(0,l.withLatestFrom)(f.visibility,f.ability),(0,l.filter)(([,t,e])=>!(t===m.L_.HIDDEN||e===m.D.DISABLED))).subscribe(()=>{const t=(()=>Object.values(this.steps).find(t=>t.idx>f.idx&&t.visibility.value===m.L_.VISIBLE&&t.ability.value===m.D.ENABLED)?null:Object.values(this.steps).find(t=>t.idx>f.idx&&t.visibility.value===m.L_.VISIBLE&&t.ability.value===m.D.DISABLED))();null==t||t.ability.next(m.D.ENABLED)});return this.subs.push(C),yield this.onAfterStepFuncCallApply(t.stepScript.nqName,r,c),c})),p=yield Promise.all(c),h=(0,a.combineLatest)(p.map(t=>t.isHistorical)).subscribe(t=>{t.some((t,e)=>{var n;return!t&&(null===(n=Object.values(this.steps).find(t=>t.idx===e))||void 0===n?void 0:n.visibility.value)===m.L_.VISIBLE})&&this.isHistorical.value&&this.isHistorical.next(!1)});this.subs.push(h);const f=this.isUpdating.subscribe(t=>{for(const e of Object.values(this.steps)){const n=e.view;(null==n?void 0:n.blockRuns)&&n.blockRuns.next(t)}});this.subs.push(f),yield this.onFuncCallReady(),this.isReady.next(!0),this.loadHelp().then(()=>{this.buildRibbonPanels();const t=()=>{const t=this.findCurrentStep();t&&this.helpFiles[t.func.nqName]&&"opened"===this.getHelpState()&&this.showHelpWithDelay(t)},e=i.events.onCurrentViewChanged.pipe((0,l.filter)(()=>i.shell.v==this)).subscribe(t);t(),this.subs.push(e)})})}loadHelp(){return C(this,void 0,void 0,function*(){return Promise.all(Object.values(this.steps).map(t=>C(this,void 0,void 0,function*(){var e,n,o,s;const r=null!==(n=null===(e=t.options)||void 0===e?void 0:e.helpUrl)&&void 0!==n?n:t.func.options.help;if(r){const e=`System:AppData/${this.func.package.name}/${r}`,n=(yield i.dapi.files.exists(e))?yield i.dapi.files.readAsText(e):yield t.view.getContextHelp();n&&(this.helpFiles[null!==(s=null===(o=t.options)||void 0===o?void 0:o.customId)&&void 0!==s?s:t.func.nqName]=n)}})))})}syncNavButtons(t,e,n){let i,o;n.addEventListener("click",()=>{i&&(this.currentTabName=w(i))}),e.addEventListener("click",()=>{o&&(this.currentTabName=w(o))});const s=this.getPipelineStateChanges().pipe((0,l.startWith)(!0),(0,l.debounceTime)(0)).subscribe(()=>{i=this.getNextStep(t),o=this.getPreviousStep(t),i?(d()(n).show(),i.ability.value===m.D.DISABLED&&d()(n).addClass("d4-disabled"),i.ability.value===m.D.ENABLED&&d()(n).removeClass("d4-disabled")):d()(n).hide(),o?(d()(e).show(),o.ability.value===m.D.DISABLED&&d()(e).addClass("d4-disabled"),o.ability.value===m.D.ENABLED&&d()(e).removeClass("d4-disabled")):d()(e).hide()});this.subs.push(s)}getPreviousStep(t){return Object.values(this.steps).slice().reverse().find(e=>e.idx<t.idx&&e.visibility.value===m.L_.VISIBLE)}getNextStep(t){return Object.values(this.steps).find(e=>e.idx>t.idx&&e.visibility.value===m.L_.VISIBLE)}getPipelineStateChanges(){const t=Object.values(this.steps).flatMap(t=>[t.ability,t.visibility]);return(0,a.merge)(...t).pipe((0,l.mapTo)(!0))}onComparisonLaunch(t){return C(this,void 0,void 0,function*(){const e=i.shell.v.parentCall,n=yield Promise.all(t.map(t=>c.W.loadChildRuns(t.id))),o=yield Promise.all(n.map(t=>{var e;return null!==(e=t.childRuns.find(t=>"true"===t.func.options.isMain))&&void 0!==e?e:t.childRuns.find(t=>t.func.nqName===this.initialConfig[this.initialConfig.length-1].funcName)}).map(t=>c.W.loadRun(t.id))),s=[...i.shell.views].find(t=>t.type===p.sk),r=yield g.S.fromComparedRuns(o,o[0].func,{parentView:s,parentCall:e});i.shell.addView(r)})}onBeforeStepFuncCallApply(t,e,n){return C(this,void 0,void 0,function*(){})}onAfterStepFuncCallApply(t,e,n){return C(this,void 0,void 0,function*(){})}buildIO(){const t=Object.values(this.steps).reduce((t,e)=>Object.assign(Object.assign({},t),{[w(e)]:e.view.root}),{}),e=o.tabControl(t),n=Object.values(this.steps).map(t=>{const n=o.iconFA("exclamation-circle",null,"This step has inconsistent inputs");return d()(n).css({color:"var(--orange-2)","margin-left":"3px","padding-top":"1px"}),e.getPane(w(t)).header.appendChild(n),t.view.consistencyState.subscribe(t=>{"consistent"===t&&d()(n).hide(),"inconsistent"===t&&d()(n).show()})});this.subs.push(...n);const i=Object.values(this.steps).map(t=>t.view.consistencyState),s=(0,a.merge)(...i).subscribe(()=>{i.map(t=>t.value).some(t=>"inconsistent"===t)?this.consistencyState.next("inconsistent"):this.consistencyState.next("consistent")});this.subs.push(s);const r=e.panes[0].header.parentElement;r.classList.add("d4-ribbon","pipeline-view"),r.classList.remove("d4-tab-header-stripe"),r.firstChild.remove();for(let t=0;t<e.panes.length;t++)e.panes[t].header.classList.add("d4-ribbon-name"),e.panes[t].header.classList.remove("d4-tab-header");return e.panes[0].header.style.marginLeft="12px",e.root.style.height="100%",e.root.style.width="100%",this.stepTabs=e,this.initialConfig.forEach(t=>{const e=A(t);this.subs.push(this.steps[e].visibility.subscribe(t=>{t===m.L_.VISIBLE&&d()(this.stepTabs.getPane(w(this.steps[e])).header).css("display","inherit"),t===m.L_.HIDDEN&&d()(this.stepTabs.getPane(w(this.steps[e])).header).hide()}))}),Object.values(this.steps).forEach(t=>{this.subs.push(t.ability.subscribe(e=>{e===m.D.ENABLED&&d()(this.stepTabs.getPane(w(t)).header).removeClass("d4-disabled"),e===m.D.DISABLED&&d()(this.stepTabs.getPane(w(t)).header).addClass("d4-disabled")}))}),this.hideSteps(...this.initialConfig.filter(t=>t.hiddenOnInit===m.L_.HIDDEN).map(t=>t.funcName)),e.root}showHelpWithDelay(t){return C(this,void 0,void 0,function*(){(0,y.aB)(this.helpFiles[t.func.nqName])})}findCurrentStep(){return Object.values(this.steps).find(t=>w(t)===this.stepTabs.currentPane.name)}buildHistoryBlock(){const t=super.buildHistoryBlock(),e=this.historyBlock.afterRunDeleted.subscribe(t=>C(this,void 0,void 0,function*(){(yield i.dapi.functions.calls.allPackageVersions().filter(`options.parentCallId="${t.id}"`).list()).map(t=>C(this,void 0,void 0,function*(){return c.W.deleteRun(t)}))}));return this.subs.push(e),t}getHelpState(){return"closed"===i.userSettings.getValue(p.Jc,`${this.func.name}_help_state`)?"closed":"opened"}saveHelpState(t){i.userSettings.add(p.Jc,`${this.func.name}_help_state`,t)}buildRibbonPanels(){const t=o.iconFA("info",()=>C(this,void 0,void 0,function*(){const t=this.findCurrentStep();t&&this.helpFiles[t.func.nqName]&&(yield this.showHelpWithDelay(t),this.saveHelpState("opened"))}),"Show help for this step"),e=()=>{const e=this.findCurrentStep();o.setDisplay(t,!(!e||!this.helpFiles[e.func.nqName])),e&&this.helpFiles[e.func.nqName]&&i.shell.windows.help.visible&&this.showHelpWithDelay(e),this.setRibbonPanels([...this.getRibbonPanels().slice(0,1),...e?e.view.buildRibbonPanels():[],...this.getRibbonPanels().length>2?this.getRibbonPanels().slice(-1):[]])};if(!this.isReady.value){const t=this.stepTabs.onTabChanged.subscribe(e),n=i.events.onEvent("grok-panels-changed").pipe((0,l.filter)(()=>i.shell.v===this)).subscribe(()=>C(this,void 0,void 0,function*(){const t=yield this.getHelpState();if(i.shell.windows.help.visible&&"closed"===t)this.saveHelpState("opened");else if(!i.shell.windows.help.visible&&"opened"===t){const t=o.iconFA("info");return d()(t).css("margin","0px 3px"),i.shell.info(o.span(["You can open help panel by clicking the",t,"button on the ribbon menu"])),void this.saveHelpState("closed")}}));this.subs.push(t,n)}const n=this.findCurrentStep(),s=[[...super.buildRibbonPanels().flat(),t],...n?n.view.buildRibbonPanels():[]];return this.setRibbonPanels(s),e(),s}saveRun(t){return C(this,void 0,void 0,function*(){let e=(0,v.A4)(t);yield this.onBeforeSaveRun(e),(0,v.Ne)(e)&&(e=yield(0,y.Hs)(t)),e.newId();const n=Object.values(this.steps).filter(t=>t.visibility.value===m.L_.VISIBLE).map(t=>C(this,void 0,void 0,function*(){var n,i;const o=t.view.funcCall;return o.options.parentCallId=e.id,(null===(n=t.options)||void 0===n?void 0:n.customId)&&(o.options.customId=null===(i=t.options)||void 0===i?void 0:i.customId),yield t.view.saveRun(o),Promise.resolve()}));yield Promise.all(n),e.options.title&&(e.options.title=`${e.options.title} (copy)`);const i=yield c.W.saveRun(e),o=yield c.W.loadRun(i.id);return this.options.historyEnabled&&this.isHistoryEnabled&&this.historyBlock&&this.historyBlock.addRun(yield c.W.loadRun(i.id)),this.linkFunccall(o),this.isHistorical.next(!0),yield this.onAfterSaveRun(e),i})}loadRun(t){return C(this,void 0,void 0,function*(){const{parentRun:e,childRuns:n}=yield c.W.loadChildRuns(t),i=Object.values(this.steps).filter(t=>t.visibility.value===m.L_.VISIBLE).findIndex(t=>w(t)===this.stepTabs.currentPane.name);yield this.onBeforeLoadRun();for(const t of Object.values(this.steps)){const e=n.filter(e=>e.func.nqName===t.func.nqName);if(0===e.length&&(t.visibility.next(m.L_.HIDDEN),t.ability.next(m.D.DISABLED)),1===e.length&&(yield t.view.loadRun(e[0].id),t.visibility.next(m.L_.VISIBLE),(0,v.Ne)(e[0])?t.ability.next(m.D.DISABLED):t.ability.next(m.D.ENABLED)),e.length>1){const n=e.find(e=>{var n;return e.options.customId===(null===(n=t.options)||void 0===n?void 0:n.customId)});yield t.view.loadRun(n.id),t.visibility.next(m.L_.VISIBLE),(0,v.Ne)(n)?t.ability.next(m.D.DISABLED):t.ability.next(m.D.ENABLED)}}const o=Object.values(this.steps).find(t=>t.ability.value===m.D.DISABLED&&t.visibility.value===m.L_.VISIBLE),s=null!=o?o:Object.values(this.steps)[0];if(s.ability.next(m.D.ENABLED),o){let t=this.getNextStep(o);for(;t;)t.ability.next(m.D.DISABLED),t=this.getNextStep(t)}this.lastCall=e,this.linkFunccall(e),this.isHistorical.next(!0);const r=Object.values(this.steps).filter(t=>t.visibility.value==m.L_.VISIBLE).at(i);return r&&r.ability.value===m.D.ENABLED?this.currentTabName=w(r):this.currentTabName=w(s),yield this.onAfterLoadRun(e),e})}hideSteps(...t){return C(this,void 0,void 0,function*(){t.forEach(t=>{this.steps[t].visibility.next(m.L_.HIDDEN)})})}showSteps(...t){return C(this,void 0,void 0,function*(){t.forEach(t=>{this.steps[t].visibility.next(m.L_.VISIBLE)})})}exportRunJson(){return C(this,void 0,void 0,function*(){if(this._lastCall){const t={isPipeline:!0};for(const[e,n]of Object.entries(this.steps)){const i=n.view.lastCall;i&&(t[e]=yield(0,y.wB)(i,n.view))}return(0,f.lK)(t)}})}executeTest(t){return C(this,arguments,void 0,function*(t,e=!1){yield(0,b.b)(t,this,{updateMode:e,interactive:!0})})}getStepViewRuns(t){return this.onStepCompleted.pipe((0,l.filter)(e=>e.func.nqName===t),(0,l.map)(()=>this.getStepView(t)))}}},873(t,e,n){"use strict";n.d(e,{E:()=>S});var i=n(4328),o=n(7389),s=n(6082),r=n(3508),a=n.n(r),l=n(1991),u=n.n(l),d=n(1757),c=n.n(d),p=n(1858),h=n(9713),f=n(1927),v=n(4260),m=n(7375),g=(n(5940),n(2244)),y=n(5092),b=n(8920),C=n(4795),w=n(5355),A=n(810),x=n(1599),E=n(3143),I=n(4386),R=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const T=()=>o.divText("[No data to display]",{style:{"text-align":"center","align-content":"center",width:"100%",height:"100%"}});class S extends g.s{static fromFuncCall(t,e={historyEnabled:!0,isTabbed:!1}){return new this(t,e)}constructor(t,e={historyEnabled:!0,isTabbed:!1}){super(t,e),this.options=e,this.inputValidationRequests=new p.Subject,this.outputValidationRequests=new p.Subject,this.inputValidationUpdates=new p.Subject,this.outputValidationUpdates=new p.Subject,this.runRequests=new p.Subject,this.isRunning=new p.BehaviorSubject(!1),this.isUploadMode=new p.BehaviorSubject(!1),this.inputsOverride={},this.inputsMap={},this.outputValidationSigns={},this.inputValidators={},this.outputValidators={},this.inputValidationState={},this.outputValidationState={},this.externalValidatorsUpdates=new p.Subject,this.externalValidatorsState={},this.pendingInputValidations=this.inputValidationUpdates.pipe((0,h.startWith)(null),(0,h.map)(()=>this.inputValidationState)),this._isOutputOutdated=new p.BehaviorSubject(!0),this.isOutputOutdated=this._isOutputOutdated.pipe((0,h.distinctUntilChanged)()),this.blockRuns=new p.BehaviorSubject(!1),this.prevOpenedTab=null,this.beforeInputPropertyRender=new p.Subject,this.afterInputPropertyRender=new p.Subject,this.afterOutputPropertyRender=new p.Subject,this.afterOutputSacalarTableRender=new p.Subject,this.formButtons=o.div(),this.additionalBtns=[],this.navBtns=[],this.tabsElem=o.tabControl(),this.dfToViewerMapping={},this.focusedInput=null,this.foldedCategoryInputs={},this.richFunctionExport=t=>R(this,void 0,void 0,function*(){if(!this.lastCall)throw new Error("Function was not called");if(!this.exportConfig.supportedFormats.includes(t))throw new Error(`Format "${t}" is not supported.`);if(!this.func)throw new Error("The correspoding function is not specified");const[e]=yield(0,I.aK)(t,this.func,this.lastCall,this.dfToViewerMapping);return e}),this.exportConfig={supportedExtensions:this.richFunctionViewExportExtensions(),supportedFormats:this.richFunctionViewSupportedFormats(),export:this.richFunctionExport,filename:this.defaultExportFilename}}onFuncCallReady(){const t=Object.create(null,{onFuncCallReady:{get:()=>super.onFuncCallReady}});return R(this,void 0,void 0,function*(){yield this.loadInputsOverrides(),yield this.loadValidators(b.bZ.INPUTS),yield this.loadValidators(b.bZ.OUTPUTS),yield t.onFuncCallReady.call(this);const e=this.funcCallReplaced.subscribe(()=>{this.inputValidationRequests.next({isRevalidation:!1}),this.outputValidationRequests.next({isRevalidation:!1})});this.subs.push(e);const n=t=>(0,h.mergeMap)(e=>e.pipe((0,h.tap)(e=>{t===b.bZ.INPUTS?this.setInputValidationPending(e.field):this.setOutputValidationPending(e.field)}),(0,h.switchMap)(e=>{const n=new AbortController,i=n.signal;let o=!1;return new p.Observable(s=>{const r=(0,p.from)(this.runValidation(Object.assign({},e),i,t)).subscribe(t=>{o=!0,s.next(t)});return()=>{o||n.abort(),r.unsubscribe()}}).pipe((0,h.tap)(n=>{t===b.bZ.INPUTS?this.setInputValidationResults(n):this.setOutputValidationResults(n),this.runRevalidations(e,n,t),t===b.bZ.INPUTS?this.inputValidationUpdates.next(null):this.outputValidationUpdates.next(null)}),(0,h.mapTo)(e))}))),s=this.inputValidationRequests.pipe((0,h.groupBy)(t=>t.field),n(b.bZ.INPUTS)).subscribe(t=>{t.field&&this.runningOnInput&&this.isRunnable()&&this.doRun()});this.subs.push(s);const r=this.outputValidationRequests.pipe((0,h.groupBy)(t=>t.field),n(b.bZ.OUTPUTS)).subscribe();this.subs.push(r);const a=this.externalValidatorsUpdates.subscribe(t=>{this.updateInputValidationResults(t)});this.subs.push(a);const l=(0,p.combineLatest)([this.runRequests.pipe((0,h.switchMap)(()=>(0,p.of)(!1).pipe((0,h.delay)(500),(0,h.startWith)(!0)))),this.inputValidationUpdates.pipe((0,h.debounceTime)(0))]).pipe((0,h.filter)(([t])=>t&&this.isRunnable())).subscribe(()=>this.doRun());this.subs.push(l);const u=this.options.isTabbed?null:yield this.loadLastInputs();if(u)i.shell.info(o.div([o.divText("Do you want to load last inputs?"),o.divH([o.bigButton("Load",()=>{for(const[t,e]of Object.entries(u)){const n=this.getInput(t);n.notify=!1,n.value=e,n.notify=!0,this.funcCall.inputs[t]=e,this.inputValidationRequests.next({field:t,isRevalidation:!1})}i.shell.info(o.divText("Change the loaded inputs to run computations"))})])]));else{const t=new AbortController,e=yield this.runValidation({isRevalidation:!1},t.signal);this.setInputValidationResults(e),this.runRevalidations({isRevalidation:!1},e),this.inputValidationUpdates.next(null),this.runningOnStart&&this.isRunnable()&&(yield this.doRun())}})}onBeforeRun(){return this.tabsElem.currentPane&&(this.prevOpenedTab=this.inputTabsLabels.includes(this.tabsElem.currentPane.name)?null:this.tabsElem.currentPane),Promise.resolve()}onAfterRun(){if(this.showOutput(),this.tabsElem.panes.forEach(t=>{c()(t.header).show()}),this.prevOpenedTab)return this.tabsElem.currentPane=this.prevOpenedTab,Promise.resolve();const t=this.tabsElem.panes.find(t=>this.outputTabsLabels.includes(t.name));return t&&(this.tabsElem.currentPane=t),Promise.resolve()}getRunButton(t="Run"){var e;const n=o.bigButton(null!==(e=(0,C.O0)(this.func))&&void 0!==e?e:t,()=>R(this,void 0,void 0,function*(){return yield this.doRun()})),i=(0,p.merge)(this.inputValidationUpdates,this.externalValidatorsUpdates,this.isRunning,this.blockRuns).subscribe(()=>{const t=this.isRunnable();n.disabled=!t});return this.subs.push(i),n}loadInputsOverrides(){return R(this,void 0,void 0,function*(){const t=[...this.funcCall.inputParams.values()];yield Promise.all(t.map(t=>R(this,void 0,void 0,function*(){if(t.property.options.input){const e=s.Func.byName(t.property.options.input).prepare({params:JSON.parse(t.property.options.inputOptions||"{}")});yield e.call(),this.inputsOverride[t.name]=e.outputs.input}})))})}loadValidators(){return R(this,arguments,void 0,function*(t=b.bZ.INPUTS){const e=yield(0,C.QL)(this.funcCall,t);t===b.bZ.INPUTS?this.inputValidators=e:this.outputValidators=e})}keepOutput(){var t;return"true"===(null===(t=this.func)||void 0===t?void 0:t.options.keepOutput)}getSaveButton(t="Save"){const e=o.bigButton(t,()=>R(this,void 0,void 0,function*(){return yield this.saveExperimentalRun(this.funcCall)}),"Save uploaded data"),n=this.isUploadMode.subscribe(t=>{this.buildRibbonPanels(),t?c()(e).show():c()(e).hide()});return this.subs.push(n),e}getStandardButtons(){const t=this.getRunButton(),e=o.div([t]);o.tooltip.bind(e,()=>t.disabled?this.isRunning.value?"Computations are in progress":this.getValidationMessage():"");const n=this.getSaveButton();return[...this.isHistoryEnabled&&!this.options.isTabbed?[n]:[],...this.runningOnInput?[]:[e]]}buildFormButtons(){var t;const e=this.getStandardButtons(),n=o.buttonsInput();return c()(n.firstChild).css({display:"none"}),null===(t=n.lastChild)||void 0===t||t.replaceWith(o.div([...this.navBtns,...this.additionalBtns,...e],"ui-input-editor")),c()(n).addClass("rfv-buttons"),c()(n).css({"max-width":"100%"}),this.formButtons.replaceWith(n),this.formButtons=n,n}setAdditionalButtons(t){this.additionalBtns=t,this.buildFormButtons()}setNavigationButtons(t){this.navBtns=t,this.buildFormButtons()}buildIO(){const{inputBlock:t,inputForm:e,outputForm:n,controlsWrapper:i}=this.buildInputBlock(),s=[...Array.from(e.childNodes),...this.isUploadMode.value?[Array.from(n.childNodes)]:[]];o.tools.handleResize(t,()=>{c()(t).width()<300?(c()(e).addClass("ui-form-condensed"),c()(n).addClass("ui-form-condensed"),c()(i).addClass("ui-form-condensed"),s.forEach(t=>c()(t).css("min-width","100px"))):(c()(e).removeClass("ui-form-condensed"),c()(n).removeClass("ui-form-condensed"),c()(i).removeClass("ui-form-condensed"),s.forEach(t=>c()(t).css("min-width","100%")))});const r=this.buildOutputBlock();r.style.height="100%",r.style.width="100%",this.hideOutput();const a=o.splitH([t,o.panel([r],{style:{paddingTop:"0px"}})],null,!0);return a.style.padding="0 12px",t.style.maxWidth="360px",a}buildInputBlock(){const t=this.renderInputForm(),e=this.renderOutputForm();this.buildFormButtons();const n=o.div(this.formButtons,"ui-form ui-form-wide");c()(n).css({"padding-left":"0px","padding-bottom":"0px","padding-right":"6px","max-width":"100%","min-height":"50px"});const i=o.input.toggle("",{value:this.isUploadMode.value,onValueChanged:t=>this.isUploadMode.next(t)}),s=this.isUploadMode.subscribe(t=>{i.notify=!1,i.value=t,i.notify=!0,t?c()(e).show():c()(e).hide()});return this.subs.push(s),{inputBlock:o.divV([t,...this.hasUploadMode&&!this.uploadFunc?[o.divH([o.h2("Experimental data"),i.root],{style:{flexGrow:"0"}}),e]:[],n],"ui-box rfv-form"),inputForm:t,outputForm:e,controlsWrapper:n}}processCustomDataUpload(){return R(this,void 0,void 0,function*(){const t=()=>{const t=s.Dialog.create({title:"Select to compare"}),e=new w.H(u.length>0?u:[...this.historyBlock.history.values()],{fallbackText:"No historical runs found",showActions:!(u.length>0),showBatchActions:!(u.length>0)}),n=new w.H(l,{fallbackText:"No runs uploaded",showActions:!1,showBatchActions:!1});t.add(o.divV([o.divV([o.label("Uploaded runs"),o.element("div","splitbar-horizontal"),n.root],{style:{height:"50%",overflowY:"hidden"}}),o.divV([o.label(u.length>0?"Simulated":"History",{style:{padding:"0px 10px 0px 9px"}}),o.element("div","splitbar-horizontal"),e.root],{style:{height:"50%",overflowY:"hidden"}})],{style:{justifyContent:"space-between",gap:"10px",overflowY:"scroll",height:"100%"}})),c()(t.root.querySelector(".d4-dialog-contents")).removeClass("ui-form");const i="Compare selected";return 0===u.length?t.addButton(i,()=>R(this,void 0,void 0,function*(){const i=yield Promise.all([...e.selected].map(t=>y.W.loadRun(t.id)));this.onComparisonLaunch([...i,...n.selected.values()]),t.close()})):t.addButton(i,()=>R(this,void 0,void 0,function*(){this.onComparisonLaunch([...e.selected.values(),...n.selected.values()]),t.close()})),t.getButton(i).disabled=!0,this.subs.push((0,p.merge)(e.onSelectedChanged,n.onSelectedChanged).subscribe(()=>{e.selected.size+n.selected.size>1?t.getButton(i).disabled=!1:t.getButton(i).disabled=!0})),this.isHistorical.value&&t.addButton(g,()=>R(this,void 0,void 0,function*(){this.onComparisonLaunch([this.funcCall,...n.selected.values()]),t.close()})),c()(t.getButton("CANCEL")).hide(),t},e=s.Func.byName(this.uploadFunc),n=yield e.prepare({params:{func:this.func}}).call(),r=n.outputs.uploadWidget,a=n.outputs.uploadFuncCall;let l=[],u=[];const d=s.Dialog.create({title:"Upload"});c()(d.root.querySelector(".d4-dialog-contents")).removeClass("ui-form");const f=s.Dialog.create({title:"Review uploaded runs"});c()(f.root.querySelector(".d4-dialog-contents")).removeClass("ui-form");const m="Save to history",g="Compare w/ current";d.add(r.root),d.addButton(m,()=>R(this,void 0,void 0,function*(){return(0,A.ZD)(d.root,!0),l.forEach(t=>{t.options.immutable_tags?t.options.immutable_tags.push(v.ec):t.options.immutable_tags=[v.ec]}),Promise.all(l.map(t=>R(this,void 0,void 0,function*(){const e=yield this.getValidExpRun(t);return y.W.saveRun(e)}))).then(t=>Promise.all(t.map(t=>y.W.loadRun(t.id)))).then(t=>{t.forEach(t=>this.historyBlock.addRun(t))}).catch(t=>{i.shell.error(t)}).finally(()=>{(0,A.ZD)(d.root,!1),d.close();const t=new w.H(l,{fallbackText:"No runs uploaded",showActions:!0,showBatchActions:!0});f.add(t),f.show({modal:!0,fullScreen:!0})})})),d.addButton("Next",()=>{d.close(),l.forEach(t=>{t.options.immutable_tags?t.options.immutable_tags.push(v.ec):t.options.immutable_tags=[v.ec]});const t=new w.H(l,{fallbackText:"No runs uploaded",showActions:!0,showBatchActions:!0});f.add(t.root),f.show({modal:!0,fullScreen:!0})}),c()(d.getButton("CANCEL")).hide(),d.getButton(m).disabled=!0,d.getButton("Next").disabled=!0,c()(f.getButton("CANCEL")).hide(),f.addButton("Simulate w/ same inputs",()=>{(0,A.ZD)(d.root,!0),Promise.all(l.map(t=>R(this,void 0,void 0,function*(){return(yield(0,C.Hs)(t)).call()}))).then(e=>{u=e,f.close(),t().show({modal:!0,fullScreen:!0})}).catch(t=>{i.shell.error(t)}).finally(()=>{(0,A.ZD)(d.root,!1)})}),f.addButton("Compare w/ history",()=>{f.close(),t().show({modal:!0,fullScreen:!0})});const b=i.functions.onAfterRunAction.pipe((0,h.filter)(t=>t.id===a.id)).subscribe(()=>{l=a.outputs.uploadedCalls,d.getButton(m).disabled=!1,d.getButton("Next").disabled=!1}),x=d.onClose.subscribe(()=>{this.isUploadMode.next(!1)});d.subs.push(x,b),d.show({modal:!0,center:!0,resizable:!0})})}onSaveClick(){return R(this,void 0,void 0,function*(){this.isUploadMode.value?yield this.saveExperimentalRun(this.funcCall):yield this.saveRun(this.funcCall)})}buildRibbonPanels(){super.buildRibbonPanels();const t=o.iconFA("play",()=>R(this,void 0,void 0,function*(){return yield this.doRun()}),"Run computations");t.classList.add("fas");const e=o.iconFA("arrow-to-top",()=>R(this,void 0,void 0,function*(){this.uploadFunc?yield this.processCustomDataUpload():(this.isUploadMode.next(!this.isUploadMode.value),e.classList.toggle("d4-current"))}),"Upload experimental data");e.classList.add("d4-toggle-button",...this.isUploadMode.value?["d4-current"]:[]);const n=o.iconFA("info",()=>R(this,void 0,void 0,function*(){this.hasContextHelp&&(i.shell.windows.help.visible=!0,yield new Promise(t=>setTimeout(t,100)),i.shell.windows.help.showHelp(o.markdown(yield this.getContextHelp())))})),s=[[...super.buildRibbonPanels().flat(),...this.runningOnInput||this.options.isTabbed?[]:[t],...this.hasUploadMode?[e]:[],...!this.options.isTabbed&&this.hasContextHelp?[n]:[]]];return this.setRibbonPanels(s),s}showOutput(){o.setDisplay(this.tabsElem.root,!0),this._isOutputOutdated.next(!1)}getViewers(t){return this.dfToViewerMapping[t]}buildOutputBlock(){this.tabsElem.root.style.width="100%",this.tabsLabels.forEach(t=>{const[e,n]=this.categoryToDfParamMap.outputs[t]?[this.categoryToDfParamMap.outputs[t],!1]:[this.categoryToDfParamMap.inputs[t],!0],r=e.filter(t=>t.propertyType===s.TYPE.DATA_FRAME||t.propertyType===s.TYPE.GRAPHICS),a=e.filter(t=>t.propertyType!==s.TYPE.DATA_FRAME&&t.propertyType!==s.TYPE.GRAPHICS),l=r.map(t=>(0,x.jJ)(t).config);let u="";const d=r.reduce((t,e,r)=>{var a,d;this.dfToViewerMapping[e.name]=[];const p=l[r].map((t,n)=>R(this,void 0,void 0,function*(){var n,r,a,l;const u=null!==(l=null!==(r=null===(n=this.funcCall.outputs[e.name])||void 0===n?void 0:n.value)&&void 0!==r?r:null===(a=this.funcCall.inputParams[e.name])||void 0===a?void 0:a.value)&&void 0!==l?l:i.data.demo.demog(0),d=t.type,c=Object.values(v.CB).includes(d)?s.Viewer.fromType(d,u):yield u.plot.fromType(d);c.setOptions(t),this.dfToViewerMapping[e.name].push(c),this.afterOutputPropertyRender.next({prop:e,output:c});const p=T();return 0===u.rowCount&&"demog 0"===u.name&&(o.setDisplay(c.root,!1),o.setDisplay(p,!0)),{viewer:c,stub:p}})),m=p.map((t,n)=>t.then(({viewer:t,stub:i})=>{const s=this.funcCallReplaced.pipe((0,h.startWith)(null),(0,h.switchMap)(()=>{var t;return(null!==(t=this.funcCall.outputParams[e.name])&&void 0!==t?t:this.funcCall.inputParams[e.name]).onChanged.pipe((0,h.startWith)(null))}),(0,h.skip)(1)).subscribe(()=>R(this,void 0,void 0,function*(){var s;const a=null!==(s=this.funcCall.outputParams[e.name])&&void 0!==s?s:this.funcCall.inputParams[e.name];if(a.value){if(o.setDisplay(t.root,!0),o.setDisplay(i,!1),Object.values(v.CB).includes(t.type))t.dataFrame=a.value;else{const e=yield a.value.plot.fromType(t.type);t.root.replaceWith(e.root),t=e}Object.keys(l[r][n]).includes("color")&&t.setOptions({color:l[r][n].color}),this.afterOutputPropertyRender.next({prop:e,output:t})}else o.setDisplay(t.root,!1),o.setDisplay(i,!0)}));return this.subs.push(s),{loadedViewer:t,stub:i}})),g=u!==(null!==(a=e.options.caption)&&void 0!==a?a:e.name)?null!==(d=e.options.caption)&&void 0!==d?d:e.name:" ";if(u=g,n){const t=this.funcCallReplaced.pipe((0,h.switchMap)(()=>{var t;return(null!==(t=this.funcCall.outputParams[e.name])&&void 0!==t?t:this.funcCall.inputParams[e.name]).onChanged})).subscribe(()=>{this.showOutput(),this.inputTabsLabels.forEach(t=>{c()(this.tabsElem.getPane(t).header).show()})});this.subs.push(t)}const y=m.map((t,n)=>{const i=l[r][n].block,s=o.wait(()=>R(this,void 0,void 0,function*(){const e=yield t;return c()(e.loadedViewer.root).css({height:"100%",width:"100%"}),o.divV([e.loadedViewer.root,e.stub],{style:{width:"100%"}})}));c()(s).css({"min-height":"300px","flex-grow":"1"});const a=(0,f.JC)();return this.outputValidationSigns[e.name]=a,o.divV([o.divH([o.h2(0===n?g:" ",{style:{whiteSpace:"pre"}}),...0===n?[o.div([this.outputValidationSigns[e.name][0],this.outputValidationSigns[e.name][1]],{style:{margin:"10.79px"}})]:[]]),s],{style:Object.assign({},i?{width:`${i}%`,"max-width":`${i}%`,"max-height":"100%"}:{"flex-grow":"1"})})});if(e.propertyType===s.TYPE.GRAPHICS){const n=e.options.block,i=T();i.classList.add("grok-scripting-image-container");const s=o.divV([o.h2(g,{style:{whiteSpace:"pre"}}),i],{style:Object.assign({},n?{width:`${n}%`,"max-width":`${n}%`,"max-height":"100%"}:{"flex-grow":"1"})}),r=()=>{var t;const n=null!==(t=this.funcCall.outputParams[e.name])&&void 0!==t?t:this.funcCall.inputParams[e.name];n.value?(i.style.backgroundImage=`url("data:image/png;base64,${n.value}")`,i.textContent=""):(i.style.removeProperty("background-image"),i.textContent="[No data to display]")},a=this.funcCallReplaced.pipe((0,h.startWith)(null),(0,h.switchMap)(()=>{var t;return(null!==(t=this.funcCall.outputParams[e.name])&&void 0!==t?t:this.funcCall.inputParams[e.name]).onChanged.pipe((0,h.startWith)(null))}),(0,h.skip)(1)).subscribe(r);this.subs.push(a),t.append(s)}return t.append(...y),t},o.divH([],{style:{flexWrap:"wrap",flexGrow:"1",maxHeight:"100%"}}));a.forEach(t=>{const e=(0,f.JC)();this.outputValidationSigns[t.name]=e});const m=()=>{const t=s.HtmlTable.create(a,t=>{var e;const n=t.options.precision,i=n&&t.propertyType===s.TYPE.FLOAT&&this.funcCall.outputs[t.name]?this.funcCall.outputs[t.name].toPrecision(n):this.funcCall.outputs[t.name],r=t.options.units?` [${t.options.units}]`:"";return[`${null!==(e=t.caption)&&void 0!==e?e:t.name}${r}`,null!=i?i:"[No value]",o.div([this.outputValidationSigns[t.name][0],this.outputValidationSigns[t.name][1]])]}).root;return c()(t).addClass("rfv-scalar-table"),this.afterOutputSacalarTableRender.next(t),t};let g=m();const y=(0,p.merge)(this.funcCallReplaced,this.isRunning.pipe((0,h.filter)(t=>!1===t),(0,h.skip)(1))).subscribe(()=>{const e=m();g.replaceWith(e),g=e,c()(this.tabsElem.getPane(t).header).show()});this.subs.push(y),this.tabsElem.addPane(t,()=>o.divV([...r.length?[d]:[],...a.length?[g]:[]]))});const t=o.box();return t.append(this.tabsElem.root),t}onAfterLoadRun(t){return R(this,void 0,void 0,function*(){this.showOutput()})}get tabsLabels(){return[...this.inputTabsLabels,...this.outputTabsLabels]}get outputTabsLabels(){return Object.keys(this.categoryToDfParamMap.outputs)}get inputTabsLabels(){return Object.keys(this.categoryToDfParamMap.inputs)}get categoryToDfParamMap(){return(0,C.r6)(this.funcCall.func)}get inputsStorage(){return`RFV_LastInputs_${this.funcCall.func.name}`}saveLastInputs(){return R(this,void 0,void 0,function*(){try{const t=u()(this.funcCall.inputParams.values()).reduce((t,e)=>{const n=e.property.propertyType!==s.TYPE.DATA_FRAME?this.funcCall.inputs[e.name]:Array.from(this.funcCall.inputs[e.name].toByteArray());return Object.assign(Object.assign({},t),{[e.name]:n})},{});return localStorage.setItem(this.inputsStorage,JSON.stringify(t))}catch(t){i.shell.error(t.toString())}})}loadLastInputs(){return R(this,void 0,void 0,function*(){var t;try{const e=JSON.parse(null!==(t=localStorage.getItem(this.inputsStorage))&&void 0!==t?t:"{}");return 0===Object.keys(e).length?null:u()(this.funcCall.inputParams.values()).reduce((t,n)=>{const i=n.property.propertyType!==s.TYPE.DATA_FRAME?e[n.name]:s.DataFrame.fromByteArray(new Uint8Array(e[n.name]));return Object.assign(Object.assign({},t),{[n.name]:i})},{})}catch(t){i.shell.error(t.toString())}})}deleteLastInputs(){return R(this,void 0,void 0,function*(){try{return localStorage.removeItem(this.inputsStorage)}catch(t){i.shell.error(t.toString())}})}doRun(){return R(this,void 0,void 0,function*(){this.isRunning.next(!0);try{this.options.isTabbed||(yield this.saveLastInputs()),yield this.run(),this.options.isTabbed||(yield this.deleteLastInputs())}catch(t){i.shell.error(t.toString()),console.log(t)}finally{this.isRunning.next(!1),this.inputValidationRequests.next({isRevalidation:!1,isNewOutput:!0}),this.outputValidationRequests.next({isRevalidation:!1})}})}setExternalValidationResults(t,e){this.externalValidatorsState[t]=e,this.externalValidatorsUpdates.next(t)}saveInputLockState(t,e,n){"restricted"===n&&(this.funcCall.options[b.AY]=Object.assign(Object.assign({},this.funcCall.options[b.AY]),{[t]:e})),n&&(this.funcCall.options[b.Jl]=Object.assign(Object.assign({},this.funcCall.options[b.Jl]),{[t]:n})),this.updateConsistencyState()}getInputLockState(t){var e;return null===(e=this.funcCall.options[b.Jl])||void 0===e?void 0:e[t]}updateConsistencyState(){const t=Object.values(this.funcCall.options[b.Jl]).some(t=>"inconsistent"===t);this.consistencyState.next(t?"inconsistent":"consistent")}getInput(t){return this.inputsMap[t]}setInput(t,e,n){const i=this.getInput(t);if(!i)throw new Error(`No input named ${t}`);if(this.funcCall.inputParams[t].property.propertyType===s.TYPE.DATA_FRAME&&"restricted"===n)throw new Error(`Param ${t} is dataframe. Restricted state is not supported for them.`);n||(n=this.funcCall.inputParams[t].property.propertyType===s.TYPE.DATA_FRAME?"disabled":"restricted"),this.funcCall.inputs[t]=e,this.setInputLockState(i,t,e,n)}getParamChanges(t){return this.funcCallReplaced.pipe((0,h.startWith)(null),(0,h.filter)(()=>!!this.funcCall),(0,h.map)(()=>this.funcCall.inputParams[t]?"inputParams":"outputParams"),(0,h.switchMap)(e=>this.funcCall[e][t].onChanged.pipe((0,h.startWith)(null),(0,h.map)(()=>this.funcCall[e][t].value))))}getParamValue(t){var e,n;const i=(null===(e=this.funcCall)||void 0===e?void 0:e.inputParams[t])?"inputParams":"outputParams";return null===(n=this.funcCall)||void 0===n?void 0:n[i][t].value}setInputLockState(t,e,n,i){i&&this.saveInputLockState(e,n,i),(0,m.gD)(t)&&("disabled"===i&&t.setDisabled(),"restricted"===i&&t.setRestricted(),"restricted unlocked"===i&&t.setRestrictedUnlocked(),"inconsistent"===i&&t.setInconsistent(),"user input"===i&&t.setUserInput())}getRestrictedValue(t){var e;return null===(e=this.funcCall.options[b.AY])||void 0===e?void 0:e[t]}renderOutputForm(){return this.renderIOForm(b.bZ.OUTPUTS)}renderInputForm(){return this.renderIOForm(b.bZ.INPUTS)}renderIOForm(t){const e=o.divH([],"ui-form ui-form-wide");c()(e).css({"flex-wrap":"wrap","flex-grow":"0","padding-right":"12px","padding-top":"0px","padding-left":"0px","max-width":"100%",gap:"4px"});let n="Misc";const i=this.funcCall[b.wl[t]].values();return u()(i).filter(t=>!!t).forEach(i=>{const o=i.property;this.beforeInputPropertyRender.next(o);const s=this.getInputForVal(i);s?(this.inputsMap[i.property.name]=s,t===b.bZ.INPUTS&&(this.syncInput(i,s,t),this.checkForMapping(i,s),this.runningOnInput||this.disableInputsOnRun(i.property.name,s),this.bindOnHotkey(s)),this.renderCategory(e,i.property.category,n),this.renderInput(e,i,s),this.afterInputPropertyRender.next({prop:o,input:s}),n=o.category):n=o.category}),Object.keys(this.foldedCategoryInputs).forEach(t=>this.foldedCategoryInputs[t].forEach(t=>c()(t.input.root).hide())),e.classList.remove("ui-panel"),e}saveFocusedElement(t){this.focusedInput=t}restoreFocusedElement(){var t;null===(t=this.focusedInput)||void 0===t||t.focus()}disableInputsOnRun(t,e){const n=this.isRunning.subscribe(n=>{"user input"!==this.getInputLockState(t)&&this.getInputLockState(t)||(n?((0,C.KL)(e)&&c()(e.input).is(":focus")&&this.saveFocusedElement(e.input),e.enabled=!1):(e.enabled=!0,(0,C.KL)(e)&&this.restoreFocusedElement()))});this.subs.push(n)}checkForMapping(t,e){if(!e.hasOwnProperty("_chosenRun"))return;const n=t.property.options.funccallMapping;if(!n)return;const i=JSON.parse(n),o=this.funcCallReplaced.pipe((0,h.startWith)(!0),(0,h.switchMap)(()=>this.funcCall.inputParams[t.property.name].onChanged)).subscribe(()=>{Object.entries(i).forEach(([t,n])=>this.setInput(t,e.chosenRun?(t=>{var n,i,o,s,r,a;return null!==(a=null!==(s=null!==(i=null===(n=e.chosenRun)||void 0===n?void 0:n.inputs[t])&&void 0!==i?i:null===(o=e.chosenRun)||void 0===o?void 0:o.outputs[t])&&void 0!==s?s:null===(r=e.chosenRun)||void 0===r?void 0:r.options[t])&&void 0!==a?a:null})(n):(0,A.Bu)(this.funcCall.inputParams[t].property),e.chosenRun?"restricted":"user input"))});this.subs.push(o)}getInputForVal(t){var e,n;const i=t.property;if(this.inputsOverride[t.property.name])return this.inputsOverride[t.property.name];if(i.propertyType===s.TYPE.STRING&&i.options.choices&&!i.options.propagateChoice)return o.input.choice(null!==(e=i.caption)&&void 0!==e?e:i.name,{value:(0,A.Bu)(i),items:JSON.parse(i.options.choices),nullable:i.nullable});switch(i.propertyType){case"file":return E.A.fileInput(null!==(n=i.caption)&&void 0!==n?n:i.name,null,null,null);case s.TYPE.FLOAT:const t=o.input.forProperty(i),e=i.options.format;return e&&(t.format=e),t;default:return o.input.forProperty(i)}}bindOnHotkey(t){(0,C.KL)(t)&&(t.input.onkeydown=t=>R(this,void 0,void 0,function*(){"Enter"==t.key&&this.runRequests.next()}))}get foldedCategories(){var t;return JSON.parse(null!==(t=this.func.options.foldedCategories)&&void 0!==t?t:"[]")}getCategoryWarningIcon(t){const e=o.iconFA("exclamation-circle",null,"This category has inconsistent inputs");c()(e).css({color:"var(--orange-2)","padding-left":"5px"}).hide();const n=this.funcCallReplaced.subscribe(()=>{this.foldedCategoryInputs[t].some(t=>"inconsistent"===this.getInputLockState(t.paramName)&&t.input.value!==this.getRestrictedValue(t.paramName))?c()(e).show():c()(e).hide()});return this.subs.push(n),e}renderCategory(t,e,n){if(e!==n)if(this.foldedCategories.includes(e)){const n=this.getCategoryWarningIcon(e),i=o.iconFA("chevron-right",()=>{var t;c()(s).show(),c()(i).hide(),c()(n).hide(),(null!==(t=this.foldedCategoryInputs[e])&&void 0!==t?t:[]).forEach(t=>c()(t.input.root).css({display:""}))},"Open category");c()(i).css("padding-right","5px");const s=o.iconFA("chevron-down",()=>{var t;c()(s).hide(),c()(i).show(),this.foldedCategoryInputs[e].some(t=>"inconsistent"===this.getInputLockState(t.paramName))?c()(n).show():c()(n).hide(),(null!==(t=this.foldedCategoryInputs[e])&&void 0!==t?t:[]).forEach(t=>c()(t.input.root).hide())},"Close category");c()(s).css("padding-right","5px"),t.append(o.h2([i,s,o.h2(e,{style:{display:"inline"}}),n],{style:{width:"100%"}})),c()(s).hide()}else t.append(o.h2(e,{style:{width:"100%"}}))}renderInput(t,e,n){var i;const o=e.property;this.foldedCategories.includes(o.category)&&(this.foldedCategoryInputs[o.category]=[...null!==(i=this.foldedCategoryInputs[o.category])&&void 0!==i?i:[],{paramName:e.property.name,input:n}]),this.injectLockIcons(e,n),(0,C.JU)(n),(0,C.KL)(n)&&((0,C.hg)(e,n),this.bindTooltips(e,n),(0,C._t)(n)),t.append(n.root)}bindTooltips(t,e){const n=t.property.name,i=()=>{var e,i;const s=`${null!==(i=null!==(e=t.property.description)&&void 0!==e?e:t.property.caption)&&void 0!==i?i:t.property.name}.`,r=(()=>"disabled"===this.getInputLockState(n)?"Input is disabled to prevent inconsistency.":"inconsistent"===this.getInputLockState(n)?"The entered value is inconsistent to the computed value.":"restricted"===this.getInputLockState(n)?"The value is dependent and computed automatically. Click to edit":null)();return s||r?o.divV([...s?[o.divText(s)]:[],...r?[o.divText(r)]:[]],{style:{maxWidth:"300px"}}):null};o.tooltip.bind(e.captionLabel,i),o.tooltip.bind(e.input,i)}injectLockIcons(t,e){const n=t.property.name;e.root.addEventListener("click",()=>{"restricted"===this.getInputLockState(n)&&this.setInputLockState(e,t.name,t.value,"restricted unlocked")});const i=o.iconFA("lock");c()(i).addClass("rfv-icon-lock"),c()(i).css({color:"var(--grey-2)"});const r=o.iconFA("lock-open");c()(r).addClass("rfv-icon-unlock"),c()(r).css({color:"var(--grey-2)"});const a=o.iconFA("undo",e=>{this.setInput(t.name,this.getRestrictedValue(n),"restricted"),e.stopPropagation()},"Reset value to computed value");c()(a).addClass("rfv-icon-undo"),c()(a).css({color:"var(--blue-2)"});const l=o.iconFA("exclamation-circle",null);o.tooltip.bind(l,()=>`Current value is incosistent. Computed value was ${s.TYPES_SCALAR.has(t.property.propertyType)?this.getRestrictedValue(n):"different"}`),c()(l).addClass("rfv-icon-warning"),c()(l).css({color:"var(--orange-2)"});const u=e;u.placeLockStateIcons||(u.placeLockStateIcons=function(t,n,i,o){(0,C.KL)(e)&&(e.addOptions(t),e.addOptions(n),e.addOptions(i),e.addOptions(o))}),u.placeLockStateIcons(i,r,a,l)}syncInput(t,e,n){const i=t.name;let o=!1;const r=this.funcCallReplaced.pipe((0,h.startWith)(!0)).subscribe(()=>{var t,o;const s=this.funcCall[b.wl[n]][i],r=null!==(o=null!==(t=this.funcCall[n][i])&&void 0!==t?t:(0,A.Bu)(s.property))&&void 0!==o?o:null;e.notify=!1,e.value=r,e.notify=!0,this.funcCall[n][i]=r,this.setInputLockState(e,i,r,this.getInputLockState(i))});this.subs.push(r);const a=this.funcCallReplaced.pipe((0,h.startWith)(!0),(0,h.switchMap)(()=>{const t=this.funcCall[b.wl[n]][i];return t.onChanged.pipe((0,h.mapTo)(t))})).subscribe(t=>{const i=this.funcCall[n][t.name];if(o||(e.notify=!1,e.value=i,e.notify=!0),n===b.bZ.INPUTS){this.isHistorical.next(!1),this.hideOutput(),this.inputValidationRequests.next({field:t.name,isRevalidation:!1});const n=this.getInputLockState(t.name);"restricted unlocked"!==n&&"inconsistent"!==n||this.setInputLockState(e,t.name,i,i===this.getRestrictedValue(t.name)?"restricted unlocked":"inconsistent")}});this.subs.push(a);const l=this.funcCallReplaced.pipe((0,h.startWith)(!0),(0,h.switchMap)(()=>{const t=this.funcCall[b.wl[n]][i];return t.onChanged.pipe((0,h.mapTo)(t),(0,h.startWith)(t))}),(0,h.filter)(t=>t.property.propertyType===s.TYPE.DATA_FRAME&&t.value),(0,h.switchMap)(t=>t.value.onDataChanged.pipe((0,h.mapTo)(t)))).subscribe(t=>{n===b.bZ.INPUTS?this.inputValidationRequests.next({field:t.name,isRevalidation:!1}):this.outputValidationRequests.next({field:t.name,isRevalidation:!1})});this.subs.push(l);const u=((0,C.KL)(e)?e.onInput:(0,C.Gb)(e.onInput.bind(e))).pipe((0,h.debounceTime)(250)).subscribe(()=>{try{o=!0,this.funcCall[n][t.name]=e.value}finally{o=!1}});this.subs.push(u)}isRunnable(){return!this.isRunning.value&&!this.blockRuns.value&&this.isValid()}isValid(){for(const[t,e]of Object.entries(this.inputValidationState))if(!(0,f.Aw)(e))return!1;for(const[t,e]of Object.entries(this.externalValidatorsState))if(!(0,f.Aw)(e))return!1;return!0}getValidationState(){return this.inputValidationState}getValidationMessage(){const t=[];for(const[e,n]of Object.entries(this.inputValidationState))(0,f.Aw)(n)||t.push(`${e}: ${(0,f.u1)(n)}`);return t.join("\n")}runValidation(t,e){return R(this,arguments,void 0,function*(t,e,n=b.bZ.INPUTS){const i=t.field,o=this.getValidatedNames(i,n);return(0,C.tf)(t,o,e,n,{view:this,funcCall:this.funcCall,lastCall:this.lastCall},n===b.bZ.INPUTS?this.inputValidators:this.outputValidators)})}setInputValidationPending(t){const e=this.getValidatedNames(t);for(const t of e){this.inputValidationState[t]=(0,f.Ur)();const e=this.inputsMap[t];(0,m.LB)(e)&&e.setValidation((0,f.Ur)())}this.inputValidationUpdates.next(null)}setOutputValidationPending(t){const e=this.getValidatedNames(t,b.bZ.OUTPUTS);for(const t of e){this.outputValidationState[t]=(0,f.Ur)();const e=this.outputValidationSigns[t];if(e){const n=(0,f.JC)((0,f.Ur)());e[0].replaceWith(n[0]),e[1].replaceWith(n[1]),this.outputValidationSigns[t]=n}}this.outputValidationUpdates.next(null)}setInputValidationResults(t){for(const[e,n]of Object.entries(t))this.inputValidationState[e]=n,this.updateInputValidationResults(e)}setOutputValidationResults(t){for(const[e,n]of Object.entries(t))this.outputValidationState[e]=n,this.updateOutputValidationResults(e)}updateOutputValidationResults(t){const e=this.outputValidationState[t],n=this.outputValidationSigns[t];n&&(this.outputValidationSigns[t]=(0,C.Fd)(n,e))}updateInputValidationResults(t){const e=(0,f.uD)(this.inputValidationState[t],this.externalValidatorsState[t]),n=this.inputsMap[t];(0,m.LB)(n)&&n.setValidation(e)}runRevalidations(t,e,n=b.bZ.INPUTS){if(!t.isRevalidation)for(const[,t]of Object.entries(e))if(null==t?void 0:t.revalidate)for(const e of t.revalidate)n===b.bZ.INPUTS?this.inputValidationRequests.next({field:e,context:t.context,isRevalidation:!0}):this.outputValidationRequests.next({field:e,context:t.context,isRevalidation:!0})}getValidatedNames(t,e=b.bZ.INPUTS){return t?[t]:[...e===b.bZ.INPUTS?this.funcCall.inputs.keys():this.funcCall.outputs.keys()]}getValidExpRun(t){return R(this,void 0,void 0,function*(){t.started=a()();const e=t.options.immutable_tags||[];return t.options.immutable_tags=e.includes(v.ec)?e:[...e,v.ec],t.newId(),t})}saveExperimentalRun(t){return R(this,void 0,void 0,function*(){const e=yield this.getValidExpRun(t);yield this.saveRun(e)})}hideOutput(){if(this._isOutputOutdated.next(!0),this.keepOutput())return;this.outputTabsLabels.forEach(t=>{var e;return c()(null===(e=this.tabsElem.getPane(t))||void 0===e?void 0:e.header).hide()});const t=this.tabsElem.panes.find(t=>this.inputTabsLabels.includes(t.name));t?this.tabsElem.currentPane=t:c()(this.tabsElem.root).hide()}richFunctionViewSupportedFormats(){return["Excel"]}richFunctionViewExportExtensions(){return{Excel:"xlsx"}}}},8920(t,e,n){"use strict";n.d(e,{AY:()=>i,D:()=>a,Jl:()=>o,L_:()=>r,bZ:()=>l,wl:()=>u});const i="restrictedValues",o="editState";var s,r,a,l;!function(t){t.INPUT="Input",t.OUTPUT="Output"}(s||(s={})),function(t){t.HIDDEN="hidden",t.VISIBLE="visible"}(r||(r={})),function(t){t.ENABLED="enabled",t.DISABLED="disabled"}(a||(a={})),function(t){t.INPUTS="inputs",t.OUTPUTS="outputs"}(l||(l={}));const u={[l.INPUTS]:"inputParams",[l.OUTPUTS]:"outputParams"}},6318(t,e,n){"use strict";n.d(e,{b:()=>c,c:()=>p});var i=n(4328),o=n(5727),s=n(4350),r=n(9713),a=n(1858),l=n(4795),u=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const d=2e4;function c(t,e){return u(this,arguments,void 0,function*(t,e,n={}){var o,s,r;yield h(e,null!==(o=n.initWaitTimeout)&&void 0!==o?o:d),e.disableSetters(!0);try{for(const[i,o]of Object.entries(e.steps)){const a=t[i];if(!a)continue;const l=null!==(r=null===(s=n.stepOptions)||void 0===s?void 0:s[i])&&void 0!==r?r:{},u=l.prefix?`${l.prefix}: ${i}`:i,{updateMode:c}=n,h={validatorsWaitTimeout:5e3,initWaitTimeout:d,parent:e,interactive:n.interactive,updateMode:c};yield p(a,o.view,Object.assign(Object.assign(Object.assign({},h),l),{prefix:u}))}}finally{e.disableSetters(!1)}n.interactive&&i.shell.info(`${e.name} test passed`)})}function p(t,e){return u(this,arguments,void 0,function*(t,e,n={}){var c;yield h(e,null!==(c=n.initWaitTimeout)&&void 0!==c?c:d);const p=()=>u(this,void 0,void 0,function*(){var t;if(n.parent){const e=null!==(t=n.parentWaitTimeout)&&void 0!==t?t:5e3,o=yield n.parent.isUpdating.pipe((0,r.map)(()=>n.parent.getRunningUpdates()),(0,r.debounceTime)(100),(0,r.takeUntil)((0,a.of)(null).pipe((0,r.delay)(e))),(0,r.takeWhile)(t=>0!==t.length,!0),(0,r.last)()).toPromise();if(null==o?void 0:o.length){const t=`{options.prefix}: parent updates failed to complete in ${e}ms, updates: ${o.join(",")}`,s=new Error(t);throw n.interactive&&i.shell.error(String(s)),s}}});yield p();for(const[i,o]of Object.entries(t.inputs)){const t=e.funcCall.inputParams[i].property.propertyType;n.updateMode?null==e.funcCall.inputs[i]&&(e.funcCall.inputs[i]=yield(0,l.$X)(t,o)):e.funcCall.inputs[i]=yield(0,l.$X)(t,o)}if(yield p(),yield(()=>u(this,void 0,void 0,function*(){var t;if(e instanceof o.Ee){const o=null!==(t=n.validatorsWaitTimeout)&&void 0!==t?t:5e3,s=yield e.pendingInputValidations.pipe((0,r.map)(t=>Object.keys(t)),(0,r.debounceTime)(100),(0,r.takeUntil)((0,a.of)(null).pipe((0,r.delay)(o))),(0,r.takeWhile)(()=>!e.isValid(),!0),(0,r.last)()).toPromise();if(null==s?void 0:s.length){const t=`{options.prefix}: validators failed to accept input in ${o}ms, inputs: ${s.join(",")}`,e=new Error(t);throw n.interactive&&i.shell.error(String(e)),e}}}))(),console.log(`running ${e.func.nqName}`),yield e.run(),!n.updateMode){console.log(`checking ${e.func.nqName} results`);try{(0,s.SJ)(e.funcCall.outputs,t.outputs,n),!n.parent&&n.interactive&&i.shell.info(`${e.name} test passed`)}catch(t){throw n.interactive&&i.shell.error(String(t)),t}console.log(`${e.func.nqName} ok`)}})}function h(t,e){return u(this,void 0,void 0,function*(){if(!(yield t.isReady.pipe((0,r.takeUntil)((0,a.of)(null).pipe((0,r.delay)(e))),(0,r.takeWhile)(t=>!t,!0),(0,r.last)()).toPromise()))throw new Error(`Waiting for view ${t.name} timeout`)})}},7375(t,e,n){"use strict";function i(t){return t&&t.root&&t.onInput}function o(t){return(null==t?void 0:t.setValidation)&&i(t)}function s(t){return(null==t?void 0:t.setDisabled)&&(null==t?void 0:t.setRestricted)&&(null==t?void 0:t.setRestrictedUnlocked)&&(null==t?void 0:t.setInconsistent)&&(null==t?void 0:t.setUserInput)&&i(t)}n.d(e,{LB:()=>o,gD:()=>s})},4795(t,e,n){"use strict";n.d(e,{$X:()=>O,Fd:()=>T,Gb:()=>g,Hs:()=>A,JU:()=>E,KL:()=>m,LL:()=>b,O0:()=>x,QL:()=>R,_t:()=>F,aB:()=>C,hg:()=>I,r6:()=>w,sy:()=>y,tf:()=>S,wB:()=>P});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(4260),u=n(7375),d=n(1927),c=n(6910),p=n(1858),h=n(1599),f=n(8920),v=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};function m(t){const e=t;return e.dart&&s.toJs(e.dart)instanceof s.InputBase}function g(t){return new p.Observable(e=>{const n=t(t=>{e.next(t)});return()=>n.unsubscribe()})}const y=(t,e,n,i,o,r)=>{var a;r&&t.setOptions({showCurrentRowIndicator:!0,showCurrentCellOutline:!1,allowEdit:!1,allowBlockSelection:!1,showRowHeader:!1,showColumnLabels:!e,extendLastColumn:e}),t.sort([l.bV],[!1]);for(let e=0;e<t.columns.length;e++){const n=t.columns.byIndex(e);n&&(null===(a=n.column)||void 0===a?void 0:a.type)===s.TYPE.DATE_TIME&&(n.format="MMM d, h:mm tt")}if((0,c.eF)(t),e)t.columns.setVisible([l.vw]),t.props.rowHeight=70,t.invalidate();else{t.props.rowHeight=28;const e=t.dataFrame.getCol(l.lv);t.columns.setVisible([l.d1,l.iL,l.zY,...i?[l.bV]:[],...i?[l.l8]:[],...i&&e.stats.missingValueCount<e.length?[l.lv]:[],...i?[l.qh]:[],...i?[l.Ts]:[],...n&&o?(0,c.rs)(o).map(t=>{var e,n;const i=null!==(e=o.inputs.find(e=>e.name===t))&&void 0!==e?e:o.outputs.find(e=>e.name===t);return i?null!==(n=i.caption)&&void 0!==n?n:(0,c.Uo)(i.name):(0,c.Uo)(t)}):[]])}},b=(t,e,n,i,s)=>{var r,a;const u=t.dataFrame,d=u.getCol(l.lv),p=[...e&&u.getCol(l.d1).categories.length>1?[l.d1]:[],...e&&(null!==(a=null===(r=u.col(l.iL))||void 0===r?void 0:r.categories.length)&&void 0!==a?a:0)>1?[l.iL]:[],...e?[l.bV,l.pC]:[],...e&&u.getCol(l.l8).categories.length>1?[l.l8]:[],...e&&d.stats.missingValueCount<d.length?[l.lv]:[],...e&&u.getCol(l.qh).categories.length>1?[l.qh]:[],...e&&u.getCol(l.Ts).categories.length>1?[l.Ts]:[],...s&&n?(0,c.rs)(s).map(t=>{var e,n;const i=null!==(e=s.inputs.find(e=>e.name===t))&&void 0!==e?e:s.outputs.find(e=>e.name===t);return i?null!==(n=i.caption)&&void 0!==n?n:(0,c.Uo)(i.name):(0,c.Uo)(t)}).filter(t=>!i||u.getCol(t).categories.length>1).map(t=>t):[]];return p.length>0?(o.setDisplay(t.root,!0),t.setOptions({columnNames:p,showHeader:!1,showBoolCombinedFilter:!0})):o.setDisplay(t.root,!1),p.length>0},C=t=>v(void 0,void 0,void 0,function*(){i.shell.windows.help.visible=!0,yield new Promise(t=>setTimeout(t,100)),i.shell.windows.help.showHelp(o.markdown(t))}),w=t=>{const e={inputs:{},outputs:{}};return t.inputs.filter(t=>t.propertyType===s.TYPE.DATA_FRAME&&0!==(0,h.jJ)(t).config.length).forEach(t=>{const n="Misc"===t.category?"Input":t.category;e.inputs[n]?e.inputs[n].push(t):e.inputs[n]=[t]}),t.outputs.forEach(t=>{const n="Misc"===t.category?"Output":t.category;t.propertyType===s.TYPE.DATA_FRAME&&0===(0,h.jJ)(t).config.length||(e.outputs[n]?e.outputs[n].push(t):e.outputs[n]=[t])}),e},A=t=>v(void 0,void 0,void 0,function*(){const e=t.id,n=s.Func.byName(t.func.nqName).prepare([...t.inputs].reduce((t,[e,n])=>(t[e]=n,t),{}));return t.options.forEach(e=>n.options[e]=t.options[e]),e||(n.id=null),n}),x=t=>t.options.runLabel,E=t=>{if((0,u.gD)(t))return;const e=t;e.setDisabled=function(){t.enabled=!1,a()(t.root).removeClass("rfv-restricted-unlocked-input"),a()(t.root).removeClass("rfv-inconsistent-input"),a()(t.root).removeClass("rfv-restricted-input")},e.setRestricted=function(){t.enabled=!1,a()(t.root).addClass("rfv-restricted-input"),a()(t.root).removeClass("rfv-restricted-unlocked-input"),a()(t.root).removeClass("rfv-inconsistent-input")},e.setRestrictedUnlocked=function(){t.enabled=!0,a()(t.root).addClass("rfv-restricted-unlocked-input"),a()(t.root).removeClass("rfv-restricted-input"),a()(t.root).removeClass("rfv-inconsistent-input")},e.setInconsistent=function(){t.enabled=!0,a()(t.root).addClass("rfv-inconsistent-input"),a()(t.root).removeClass("rfv-restricted-input"),a()(t.root).removeClass("rfv-restricted-unlocked-input")},e.setUserInput=function(){t.enabled=!0,a()(t.root).removeClass("rfv-inconsistent-input"),a()(t.root).removeClass("rfv-restricted-input"),a()(t.root).removeClass("rfv-restricted-unlocked-input")}},I=(t,e)=>{var n;const i=t.property;a()(e.root).css({width:`calc(${null!==(n=i.options.block)&&void 0!==n?n:"100"}% - ${i.options.block?"2":"0"}px)`,"box-sizing":"border-box"})},R=(t,...e)=>v(void 0,[t,...e],void 0,function*(t,e=f.bZ.INPUTS){const n=[...t[f.wl[e]].values()];return(yield Promise.all(n.filter(t=>!!t.property.options.validatorFunc).map(t=>v(void 0,void 0,void 0,function*(){const e=s.Func.byName(t.property.options.validatorFunc).prepare({params:JSON.parse(t.property.options.validatorFuncOptions||"{}")});return yield e.call(),[t.name,e.outputs.validator]})))).reduce((t,[e,n])=>(t[e]=n,t),{})}),T=(t,e)=>{const n=(0,d.JC)(e);return t[0].replaceWith(n[0]),t[1].replaceWith(n[1]),n},S=(t,e,n,i,o,s)=>v(void 0,void 0,void 0,function*(){const{view:r,funcCall:a,lastCall:l}=o,u=yield Promise.all(e.map(e=>v(void 0,void 0,void 0,function*(){const o=i===f.bZ.INPUTS?a.inputs[e]:a.outputs[e],u=yield(0,d.Td)(o,{param:e,funcCall:a,lastCall:l,signal:n,isNewOutput:!!t.isNewOutput,isRevalidation:t.isRevalidation,view:r});let c;const p=s[e];p&&(c=yield p(o,{param:e,funcCall:a,lastCall:l,signal:n,isNewOutput:!!t.isNewOutput,isRevalidation:t.isRevalidation,context:t.context,view:r}));const h=i===f.bZ.INPUTS&&a.inputParams[e].property.options.nullable;return[e,(0,d.uD)(...h?[]:[u],c)]})));return Object.fromEntries(u)}),F=t=>{const e=o.element("i");t.addOptions(e),t.setValidation=function(n){for(;e.firstChild&&e.removeChild(e.firstChild););const[i,o]=(0,d.JC)(n);i&&o&&(e.appendChild(i),e.appendChild(o)),t.input.classList.remove("d4-invalid"),t.input.classList.remove("d4-partially-invalid"),(null==n?void 0:n.errors)&&n.errors.length||(null==n?void 0:n.warnings)&&n.warnings.length||(null==n?void 0:n.notifications)&&n.notifications.length||(null==n?void 0:n.pending)?a()(e).css("display","flex"):a()(e).hide(),(null==n?void 0:n.errors)&&n.errors.length?t.input.classList.add("d4-invalid"):(null==n?void 0:n.warnings)&&n.warnings.length&&t.input.classList.add("d4-partially-invalid")}};function P(t,e){return v(this,void 0,void 0,function*(){const n={};for(const[i,o]of Object.entries(t.inputs)){const{property:t}=e.funcCall.inputParams[i];n[i]=yield k(t,o,e)}return{inputs:n,outputs:t.outputs}})}function k(t,e,n){return v(this,void 0,void 0,function*(){return"file"===t.propertyType&&n.getInput?n.getInput(t.name).value.arrayBuffer():e})}function O(t,e){return v(this,void 0,void 0,function*(){return"file"===t?new File([e],""):e})}},1927(t,e,n){"use strict";n.d(e,{Aw:()=>o,B5:()=>s,JC:()=>p,Td:()=>c,Ur:()=>u,ZS:()=>a,dQ:()=>d,u1:()=>r,uD:()=>l});var i=n(7389);function o(t){var e;return!(null===(e=null==t?void 0:t.errors)||void 0===e?void 0:e.length)&&!(null==t?void 0:t.pending)}function s(t,e){return{description:t,actions:e}}function r(t){if(null==t?void 0:t.errors)return t.errors.map(t=>t.description).join("; ")}function a(t){var e,n,i;const o=t=>"string"==typeof t?s(t):t;return{errors:null===(e=null==t?void 0:t.errors)||void 0===e?void 0:e.map(t=>o(t)),warnings:null===(n=null==t?void 0:t.warnings)||void 0===n?void 0:n.map(t=>o(t)),notifications:null===(i=null==t?void 0:t.notifications)||void 0===i?void 0:i.map(t=>o(t))}}function l(...t){var e,n,i,o,s;const r=[],a=[],l=[],u=[];let d={};for(const c of t)c&&(r.push(...null!==(e=c.errors)&&void 0!==e?e:[]),a.push(...null!==(n=c.warnings)&&void 0!==n?n:[]),l.push(...null!==(i=c.notifications)&&void 0!==i?i:[]),u.push(...null!==(o=c.revalidate)&&void 0!==o?o:[]),d=Object.assign(Object.assign({},d),null!==(s=c.context)&&void 0!==s?s:{}));return{errors:r,warnings:a,notifications:l,revalidate:u,context:d}}function u(){return{pending:!0}}function d(t,e,n){return Object.assign({revalidate:t,context:e},n)}const c=t=>{return e=void 0,n=void 0,o=function*(){if(null==t)return a({errors:["Missing value"]})},new((i=void 0)||(i=Promise))(function(t,s){function r(t){try{l(o.next(t))}catch(t){s(t)}}function a(t){try{l(o.throw(t))}catch(t){s(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i(function(t){t(n)})).then(r,a)}l((o=o.apply(e,n||[])).next())});var e,n,i,o};function p(t){let e,n;return(null==t?void 0:t.pending)&&(n=i.iconFA("spinner",()=>{h(t,n,e)}),n.classList.add("fa-spin")),(null==t?void 0:t.errors)&&t.errors.length?(n=i.iconFA("exclamation-circle",()=>{h(t,n,e)}),n.style.color="var(--red-3)"):(null==t?void 0:t.warnings)&&t.warnings.length?(n=i.iconFA("exclamation-circle",()=>{h(t,n,e)}),n.style.color="var(--orange-2)"):(null==t?void 0:t.notifications)&&t.notifications.length&&(n=i.iconFA("info-circle",()=>{h(t,n,e)}),n.style.color="var(--blue-1)"),n&&(n.classList.remove("fal"),n.classList.add("far"),e=function(t){const e=i.div([],"d4-tooltip");return function(t){t.popover="auto",t.style.fontStyle="normal",t.style.pointerEvents="all",t.style.maxWidth="300px",t.style.textWrap="pretty"}(e),t.appendChild(e),e}(n)),[null!=n?n:i.div(),null!=e?e:i.div()]}function h(t,e,n){if(n&&e){for(function(t,e){const n=t.getBoundingClientRect().toJSON();e.style.inset="unset",e.style.top=n.y+"px",e.style.left=n.x+20+"px"}(e,n);n.firstChild&&n.removeChild(n.firstChild););const o=function(t){var e;const n=i.divV([],{style:{gap:"10px"}});for(const o of["errors","warnings","notifications"]){const s=t[o];if(null==s?void 0:s.length)for(const t of s){const s=f(o);s.style.marginRight="4px",n.appendChild(i.divV([i.divH([s,i.span([t.description])]),...(null!==(e=t.actions)&&void 0!==e?e:[]).map(t=>i.link(t.actionName,t.action,void 0,{style:{paddingLeft:"20px"}}))]))}}return n}(t);n.appendChild(o),n.showPopover()}}function f(t){let e;return"errors"===t?(e=i.iconFA("exclamation-circle"),e.style.color="var(--red-3)"):"warnings"===t?(e=i.iconFA("exclamation-circle"),e.style.color="var(--orange-2)"):"notifications"===t&&(e=i.iconFA("info-circle"),e.style.color="var(--blue-1)"),e&&(e.classList.remove("fal"),e.classList.add("far")),e}},4778(t,e,n){"use strict";n.d(e,{fj:()=>i}),n(6082),n(5520),n(3508);const i="OUTPUT_OUTDATED"},8804(t,e,n){"use strict";n.d(e,{C:()=>u,V:()=>l});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class l extends s.Dialog{static forFuncCall(t,e=!1){var n,i,o;const s=null!==(n=t.options.title)&&void 0!==n?n:"",r=null!==(i=t.options.description)&&void 0!==i?i:"",a=null!==(o=t.options.tags)&&void 0!==o?o:[];return new l({title:s,description:r,tags:a,isFavorite:e})}constructor(t){var e,n,l,u;super(o.dialog({title:"Save model state"}).dart),this._onMetadataEdit=new r.Subject,this.onMetadataEdit=this._onMetadataEdit.asObservable();let d=null!==(e=null==t?void 0:t.title)&&void 0!==e?e:"",c=null!==(n=null==t?void 0:t.description)&&void 0!==n?n:"",p=null!==(l=null==t?void 0:t.isFavorite)&&void 0!==l&&l;const h=o.input.string("Title",{value:d,onValueChanged:t=>d=t}),f=o.input.string(" ",{value:""}),v=s.TagEditor.create();(null!==(u=null==t?void 0:t.tags)&&void 0!==u?u:[]).forEach(t=>{v.addTag(t)}),f.input.replaceWith(v.root);const m=()=>{""===g.value||v.tags.includes(g.value)||(v.addTag(g.value),g.value="")},g=o.input.string("Tag",{value:""}).addOptions(o.iconFA("plus",m,"Add this tag")),y=(0,r.fromEvent)(g.input,"onkeydown").subscribe(t=>{"Enter"==t.key&&(t.stopPropagation(),m())});this.sub(y);const b=o.input.string("Description",{value:c,onValueChanged:t=>c=t}),C=o.input.bool("Is favorite",{value:p,onValueChanged:t=>p=t});this.add(o.form([h,b,C,g,f])),this.addButton("Save",()=>a(this,void 0,void 0,function*(){if(""!==g.value)return void i.shell.info(`Dialog has unsaved tags: ${g.value}`);const t={title:""!==d?d:null,description:""!==c?c:null,isFavorite:p,tags:v.tags.map(t=>t)};this._onMetadataEdit.next(t),this.close()}))}}class u extends s.Dialog{constructor(t){super(o.dialog({title:`Delete ${t.size>1?t.size:""} ${t.size>1?"runs":"run"}`}).dart),this._onFuncCallDelete=new r.Subject,this.onFuncCallDelete=this._onFuncCallDelete.asObservable(),this.add(o.divText(`Deleted ${t.size>1?t.size:""} ${t.size>1?"runs":"run"} ${t.size>1?"are":"is"} impossible to restore. Are you sure?`)),this.onOK(()=>a(this,void 0,void 0,function*(){return this._onFuncCallDelete.next(t)}))}}},4260(t,e,n){"use strict";n.d(e,{CB:()=>o,Jc:()=>p,NT:()=>l,Ts:()=>w,_W:()=>d,aQ:()=>x,bV:()=>b,d1:()=>f,eP:()=>r,eX:()=>c,ec:()=>u,iL:()=>v,l8:()=>y,lv:()=>A,pC:()=>m,qh:()=>C,r0:()=>a,sk:()=>s,t6:()=>E,vw:()=>h,zY:()=>g});var i=n(6082);const o={barchart:i.VIEWER.BAR_CHART,boxplot:i.VIEWER.BOX_PLOT,calendar:i.VIEWER.CALENDAR,corrplot:i.VIEWER.CORR_PLOT,densityplot:i.VIEWER.DENSITY_PLOT,filters:i.VIEWER.FILTERS,form:i.VIEWER.FORM,globe:i.VIEWER.GLOBE,googlemap:i.VIEWER.GOOGLE_MAP,grid:i.VIEWER.GRID,heatmap:i.VIEWER.HEAT_MAP,histogram:i.VIEWER.HISTOGRAM,linechart:i.VIEWER.LINE_CHART,markup:i.VIEWER.MARKUP,matrixplot:i.VIEWER.MATRIX_PLOT,networkdiagram:i.VIEWER.NETWORK_DIAGRAM,pcplot:i.VIEWER.PC_PLOT,piechart:i.VIEWER.PIE_CHART,scatterplot:i.VIEWER.SCATTER_PLOT,"3dscatterplot":i.VIEWER.SCATTER_PLOT_3D,shapemap:i.VIEWER.SHAPE_MAP,statistics:i.VIEWER.STATISTICS,tileviewer:i.VIEWER.TILE_VIEWER,timelines:i.VIEWER.TIMELINES,treemap:i.VIEWER.TREE_MAP,trellisplot:i.VIEWER.TRELLIS_PLOT,wordcloud:i.VIEWER.WORD_CLOUD},s="JsCardView",r="scripts",a="functions",l="viewer",u="experimental",d="Run name",c="RunId",p="ModelStorage",h="ID",f="Source",v="Is favorite",m="Is complete",g="Delete",y="Author",b="Date",C="Title",w="Desc.",A="Tags",x="Version",E=Object.values(i.COLUMN_TYPE).filter(t=>t!==i.TYPE.DATA_FRAME)},4386(t,e,n){"use strict";n.d(e,{aK:()=>d});var i=n(4328),o=n(7389),s=n(6082),r=n(4260),a=n(1599),l=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const u=(t,e,n)=>{o.setUpdateIndicator(t,e);const i=t.querySelector(".d4-update-shadow .ui-label");e&&n&&i&&(i.textContent=n)},d=(t,e,n,d,c,h)=>l(void 0,void 0,void 0,function*(){var f,m;const g={},y=(t,e)=>{if(g[t])return g[t];let n=`${t}`;n.length>31&&(n=`${n.slice(0,31)}`);let i=1;for(;e.worksheets.some(t=>t.name.toLowerCase()===n.toLowerCase());){let e=`${t}`;e.length>31-`-${i}`.length&&(e=`${t.slice(0,31-`-${i}`.length)}`),n=`${e}-${i}`,i++}return g[t]=n,n};if("Excel"===t)try{yield s.Utils.loadJsCss(["/js/common/exceljs.min.js","/js/common/html2canvas.min.js"]);const t=window.ExcelJS,g=window.html2canvas,b="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8",C=new t.Workbook;o.setDisplay(i.shell.v.root,!1),u(i.shell.v.root.parentElement,!0,"Generating report. Please do not switch the browser tab...");let w=0;const A=(t,e,n,...r)=>l(void 0,[t,e,n,...r],void 0,function*(t,e,n,r=0){if(!e||!e.dataFrame)return;const l=s.Viewer.fromType(e.type,e.dataFrame.clone());l.copyViewersLook(e);const u=o.div(l.root,{style:{width:"1280px",height:"720px"}});u.classList.add("ui-box"),u.classList.remove("ui-div"),i.shell.v.root.insertAdjacentElement("afterend",u),yield(0,a.cb)(1e3);const d=(yield g(u)).toDataURL();u.remove();const c=C.addImage({base64:d,extension:"png"});t.addImage(c,{tl:{col:n,row:r},ext:{width:1280,height:720}})}),x=t=>s.TYPES_SCALAR.has(t),E=t=>t.propertyType===s.TYPE.DATA_FRAME,I=e.inputs.filter(t=>E(t)),R=e.inputs.filter(t=>x(t.propertyType)),T=e.outputs.filter(t=>E(t)),S=e.outputs.filter(t=>x(t.propertyType));if(I.forEach(t=>{var e;const i=t.options.caption||t.name,o=null!==(e=C.worksheets.find(t=>t.name===y(i,C)))&&void 0!==e?e:C.addWorksheet(y(i,C)),s=n.inputs[t.name],r=null==c?void 0:c[t.name],a=null==h?void 0:h[t.name];v({sheet:o,dfCounter:w,df:s,validation:r,consistency:a}),w++}),R.length){const t=C.addWorksheet("Input scalars");p(t,R.map(t=>{var e,i,o;return{name:t.name,caption:null!==(e=t.options.caption)&&void 0!==e?e:t.name,value:null!==(i=n.inputs[t.name])&&void 0!==i?i:"",units:null!==(o=t.options.units)&&void 0!==o?o:"",format:t.format}}),c,h)}if(T.forEach(t=>{var e;const i=t.options.caption||t.name,o=null!==(e=C.worksheets.find(t=>t.name===y(i,C)))&&void 0!==e?e:C.addWorksheet(y(i,C)),s=n.outputs[t.name],r=null==c?void 0:c[t.name],a=null==h?void 0:h[t.name];v({sheet:o,dfCounter:w,df:s,validation:r,consistency:a}),w++}),S.length){const t=C.addWorksheet("Output scalars");p(t,S.map(t=>{var e,i,o;return{name:t.name,caption:null!==(e=t.options.caption)&&void 0!==e?e:t.name,value:null!==(i=n.outputs[t.name])&&void 0!==i?i:"",units:null!==(o=t.options.units)&&void 0!==o?o:"",format:t.format}}),c,h)}for(const t of e.inputs.filter(t=>E(t))){const e=(null!==(f=d[t.name])&&void 0!==f?f:[]).filter(t=>t&&t.type!==s.VIEWER.GRID).filter(t=>Object.values(r.CB).includes(t.type));if(0===e.length)continue;const i=t.options.caption||t.name,o=n.inputs[t.name];for(const[t,n]of e.entries())yield A(C.getWorksheet(y(i,C)),n,o.columns.length+2,t>0?16*t+1:0)}for(const t of e.outputs.filter(t=>E(t))){const e=(null!==(m=d[t.name])&&void 0!==m?m:[]).filter(t=>t&&t.type!==s.VIEWER.GRID).filter(t=>Object.values(r.CB).includes(t.type));if(0===e.length)continue;const i=t.options.caption||t.name,o=n.outputs[t.name];for(const[t,n]of e.entries())if(n)if(n.type===s.VIEWER.STATISTICS){const n=o.columns.length,r=s.DataFrame.fromColumns([s.Column.string("Name",n).init(t=>o.columns.byIndex(t).name),s.Column.int("Values",n).init(t=>o.columns.byIndex(t).stats.valueCount),s.Column.int("Nulls",n).init(t=>o.columns.byIndex(t).stats.missingValueCount),s.Column.float("Min",n).init(t=>o.columns.byIndex(t).stats.min),s.Column.float("Max",n).init(t=>o.columns.byIndex(t).stats.max),s.Column.float("Avg",n).init(t=>o.columns.byIndex(t).stats.avg),s.Column.float("Stdev",n).init(t=>o.columns.byIndex(t).stats.stdev)]);v({sheet:C.getWorksheet(y(i,C)),dfCounter:w,df:r,column:o.columns.length+2,row:t>0&&e[t-1]?Math.ceil(e[t-1].root.clientHeight/20)+1:0}),w++}else yield A(C.getWorksheet(y(i,C)),n,o.columns.length+2,t>0?16*t+1:0)}const F=yield C.xlsx.writeBuffer();return[new Blob([F],{type:b}),C]}catch(t){console.log(t)}finally{o.setDisplay(i.shell.v.root,!0),u(i.shell.v.root.parentElement,!1)}throw new Error("Format is not supported")}),c=(t,e)=>{try{return Number.isFinite(t)&&e?s.format(t,e):t}catch(e){return t}},p=(t,e,n,i)=>{const o=["Parameter","Value","Units"];n&&o.push("Validation"),i&&o.push("Consistency"),t.addRow(o).font={bold:!0},e.forEach(e=>{const o=[e.caption,c(e.value,e.format),e.units];o.push(h(null==n?void 0:n[e.name])),o.push(f(null==i?void 0:i[e.name])),t.addRow(o)}),t.getColumn(1).width=1.2*Math.max(...e.map(t=>t.caption.toString().length),9),t.getColumn(2).width=1.2*Math.max(...e.map(t=>t.value.toString().length),5),t.getColumn(3).width=1.2*Math.max(...e.map(t=>t.units.toString().length),5),t.getColumn(4).width=100,t.getColumn(5).width=100},h=t=>null==t?"":["errors","warnings"].filter(e=>{var n;return!!(null===(n=null==t?void 0:t[e])||void 0===n?void 0:n.length)}).flatMap(e=>t[e].map(t=>({category:e,advice:t}))).map(({category:t,advice:e})=>`${t}: ${"string"==typeof e?e:e.description}`).join("\n"),f=t=>null==t?"":!t.inconsistent||"disabled"!==t.restriction&&"restricted"!==t.restriction?void 0:`Inconsistent: value should be ${String(t.assignedValue)}`,v=({sheet:t,dfCounter:e,df:n,column:i,row:o,validation:s,consistency:r})=>{var a,l;if(!n)return;const u=t.getColumn(null!=i?i:1).letter,d=n.columns.length,p=[];for(let t=0;t<n.rowCount;t++){const e=[];for(let i=0;i<n.columns.length;i++){const o=n.col(i),s=n.get(o.name,t);if("double"===(null==o?void 0:o.type)){const t=null!==(l=null===(a=null==o?void 0:o.tags)||void 0===a?void 0:a.format)&&void 0!==l?l:"0.00",n=c(s,t);e.push(n)}else e.push(s)}p.push(e)}const v={name:`ID_${e.toString()}`,ref:`${u}${null!=o?o:1}`,columns:n.columns.toList().map(t=>({name:t.name,filterButton:!1})),rows:p};t.addTable(v),t.columns.forEach(t=>{t.width=25,t.alignment={wrapText:!0}});const m=d+1;t.getColumn(m).width=100,t.getCell(1,m).value="Validation and Consistency",s&&(t.getCell(2,m).value=h(s)),r&&(t.getCell(3,m).value=f(r))}},6910(t,e,n){"use strict";n.d(e,{BV:()=>C,Uo:()=>y,VI:()=>m,WM:()=>h,eF:()=>g,qg:()=>f,rs:()=>v,u8:()=>b});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(4260),u=n(3508),d=n.n(u),c=n(1599),p=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const h=(t,e)=>p(void 0,void 0,void 0,function*(){const n=`${l.Jc}_${t.func.name}_Fav`;return e?i.dapi.userDataStorage.postValue(n,t.id,""):i.dapi.userDataStorage.remove(n,t.id)}),f=t=>t.options.mainParams?JSON.parse(t.options.mainParams):null,v=(t,e)=>{var n,i;return null!==(i=null!==(n=null==e?void 0:e.visibleProps)&&void 0!==n?n:f(t))&&void 0!==i?i:t.inputs.filter(t=>l.t6.includes(t.propertyType)).map(t=>t.name)},m=(t,e,n,s,r,u,d)=>{t.onCellPrepare(h=>{var f,v,m,g,y,b,C,w,A,x;if(h.isColHeader&&(null===(f=h.tableColumn)||void 0===f?void 0:f.name)&&[l.zY,l.d1,l.iL].includes(h.tableColumn.name)&&(h.customText=""),!h.isColHeader){if((null===(v=h.tableColumn)||void 0===v?void 0:v.name)===l.zY&&(h.customText="",h.element=o.divH([o.iconFA("trash",()=>s(h),"Remove run from history"),o.iconFA("edit",()=>n(h),"Edit run metadata")],{style:{padding:"6px",gap:"6px",justifyContent:"space-between"}})),(null===(m=h.tableColumn)||void 0===m?void 0:m.name)===l.iL){h.customText="";const t=o.iconFA("star",()=>u(h),"Unfavorite");a()(t).addClass("fas"),h.element=o.div(h.cell.value?t:o.iconFA("star",()=>r(h),"Favorite"),{style:{padding:"6px"}})}if((null===(g=h.tableColumn)||void 0===g?void 0:g.name)===l.d1){h.customText="";const t=o.iconFA("flask",null,"Experimental run");a()(t).addClass("fad fa-sm"),a()(t).removeClass("fal"),h.element=h.cell.value&&"Experimental"===h.cell.value?o.div(t,{style:{padding:"6px"}}):o.div()}if((null===(y=h.tableColumn)||void 0===y?void 0:y.name)===l.lv){h.customText="";const t=h.cell.value.length>0?o.div(null===(b=h.cell.value)||void 0===b?void 0:b.split(",").map(t=>o.span([t],"d4-tag")),"d4-tag-editor"):o.div();a()(t).css({padding:"3px","background-color":"transparent"}),h.element=t}if((null===(C=h.tableColumn)||void 0===C?void 0:C.name)===l.vw){h.customText="";const f=(E=h.tableRowIndex,e.get(t.dataFrame.get(l.vw,E)));if(!f)return;const v=f.author.picture;a()(v).css({width:"25px",height:"25px",fontSize:"20px"}),o.bind(f.author,v);const m=o.iconFA("flask",null,"Experimental run");m.classList.add("fad","fa-sm"),m.classList.remove("fal"),m.style.marginLeft="3px";const g=f.options.immutable_tags,y=o.span([o.label(null!==(x=null!==(w=f.options.title)&&void 0!==w?w:null===(A=f.author)||void 0===A?void 0:A.friendlyName)&&void 0!==x?x:i.shell.user.friendlyName,{style:{color:"var(--blue-1)"}}),...g&&g.includes(l.ec)?[m]:[]]),b=o.iconFA("edit",t=>{t.stopPropagation(),n(h)},"Edit run metadata");b.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const C=o.iconFA("trash-alt",t=>p(void 0,void 0,void 0,function*(){t.stopPropagation(),s(h)}),"Delete run");C.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const I=o.iconFA("star",t=>{t.stopPropagation(),u(h)},"Unfavorite");I.classList.add("fas","hp-funccall-card-icon");const R=o.iconFA("star",t=>{t.stopPropagation(),r(h)},"Favorite");R.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon"),(e=>t.dataFrame.get(l.iL,e))(h.tableRowIndex)?(o.setDisplay(R,!1),o.setDisplay(I,!0)):(o.setDisplay(I,!1),o.setDisplay(R,!0));const T=(0,c.eK)(f),S=o.divH([o.divH([v,o.divV([y,o.span([T]),...f.options.tags&&f.options.tags.length>0?[o.div(f.options.tags.map(t=>o.span([t],"d4-tag")))]:[]],"hp-card-content")]),o.divH([...d?[I,R,b,C]:[]])],"hp-funccall-card"),F=h.tableRowIndex;S.addEventListener("mouseover",()=>{h.grid.dataFrame.mouseOverRowIdx=F}),S.addEventListener("click",t=>{t.shiftKey?h.grid.dataFrame.selection.set(F,!0):t.ctrlKey?h.grid.dataFrame.selection.set(F,!1):h.grid.dataFrame.currentRowIdx=F}),h.element=S}var E}})},g=t=>{const e=t.columns.byName(l.zY);e&&(e.cellType="html",e.width=45);const n=t.columns.byName(l.iL);n&&(n.cellType="html",n.width=30);const i=t.columns.byName(l.d1);i&&(i.cellType="html",i.width=30);const o=t.columns.byName(l.lv);o&&(o.cellType="html",o.width=90);const s=t.columns.byName(l.bV);s&&(s.width=110);const r=t.columns.byName(l.vw);r&&(r.cellType="html")},y=t=>t.replace(/([A-Z])/g,t=>` ${t.toLowerCase()}`).trim().replace(/^./,t=>t.toUpperCase()),b=(t,e)=>{var n,i,o,s,r,a,u;if(e===l.l8)return null!==(i=null===(n=t.author)||void 0===n?void 0:n.friendlyName)&&void 0!==i?i:" ";const d=null!==(a=null!==(r=null!==(s=null!==(o=t[e])&&void 0!==o?o:t.inputs[e])&&void 0!==s?s:t.outputs[e])&&void 0!==r?r:t.options[e])&&void 0!==a?a:null;return null!==(u=null==d?void 0:d.toString())&&void 0!==u?u:""},C=(t,e,n)=>p(void 0,void 0,void 0,function*(){var o;const r=[...t.values()],a=t=>t===l.bV?s.Column.dateTime(y(t),r.length).init(t=>window.grok_DayJs_To_DateTime((0,c.Yj)(r[t])?r[t].started.utc(!0):d().unix(r[t].options.createdOn))):t===l.pC?s.Column.bool(y(t),r.length).init(t=>!(0,c.Ne)(r[t])):s.Column.fromStrings(y(t),r.map(e=>{var i,o,s;return null!==(s=null===(o=null===(i=null==n?void 0:n.propFuncs)||void 0===i?void 0:i[t])||void 0===o?void 0:o.call(i,e))&&void 0!==s?s:b(e,t)})),u=null!==(o=yield i.dapi.userDataStorage.get((t=>`${l.Jc}_${t.name}_Fav`)(e)))&&void 0!==o?o:{},p=Object.keys(u),h=s.DataFrame.fromColumns([s.Column.string(l.d1,r.length).init(t=>{const e=r[t].options.immutable_tags;return e&&e.includes(l.ec)?"Experimental":"Simulated"}),...(null==n?void 0:n.isHistory)?[s.Column.bool(l.iL,r.length).init(t=>p.includes(r[t].id))]:[],...(null==n?void 0:n.showActions)?[s.Column.string(l.zY,r.length).init("")]:[],a(l.bV),a(l.pC),a(l.l8),s.Column.string(l.lv,r.length).init(t=>r[t].options.tags?r[t].options.tags.join(","):""),s.Column.string(l.qh,r.length).init(t=>r[t].options.title),s.Column.string(l.Ts,r.length).init(t=>r[t].options.description),s.Column.string(l.aQ,r.length).init(t=>r[t].options.version)]);if(v(e).map(t=>(t=>{var i;const o=null!==(i=e.inputs.find(e=>e.name===t))&&void 0!==i?i:e.outputs.find(e=>e.name===t);return o?(t=>{var e,i;return t.propertyType===s.TYPE.DATE_TIME?s.Column.dateTime(null!==(e=t.caption)&&void 0!==e?e:y(t.name),r.length).init(e=>window.grok_DayJs_To_DateTime(r[e].inputs[t.name])):s.Column.fromType(t.propertyType,null!==(i=t.caption)&&void 0!==i?i:y(t.name),r.length).init(e=>{var i,o,s;return null!==(s=null===(o=null===(i=null==n?void 0:n.propFuncs)||void 0===i?void 0:i[t.name])||void 0===o?void 0:o.call(i,r[e]))&&void 0!==s?s:b(r[e],t.name)})})(o):a(t)})(t)).forEach(t=>{t.name=h.columns.getUnusedName(t.name),h.columns.add(t,!1)}),h.columns.add(s.Column.fromStrings(l.vw,r.map(t=>t.id))),!(null==n?void 0:n.allowOtherVersions)&&(null==n?void 0:n.version)){const t=s.BitSet.create(h.rowCount,()=>!1);for(let e=0;e<h.rowCount;e++)(null==n?void 0:n.version)==h.get(l.aQ,e)&&t.set(e,!0);return h.clone(t)}return h})},1599(t,e,n){"use strict";n.d(e,{A4:()=>b,HP:()=>h,Ne:()=>y,Yj:()=>g,bP:()=>p,cb:()=>A,eK:()=>w,i:()=>v,jJ:()=>C,vk:()=>f,x$:()=>m,zF:()=>c});var i=n(4328),o=n(6082),s=n(1991),r=n.n(s),a=n(4260),l=n(5520),u=n(4778);const d=new o.LruCache,c=t=>{return e=void 0,n=void 0,s=function*(){var e;const n=null!==(e=t.options.help)&&void 0!==e?e:t.options.readme;if(!n)return;if(d.get(t.id))return d.get(t.id);let o="";try{o=t.package.name}catch(t){}const s=`System:AppData/${o}/${n}`;if(o&&(yield i.dapi.files.exists(s))){const e=yield i.dapi.files.readAsText(s);return d.set(t.id,e),e}const r=`${i.shell.user.name}.home/${n}`;if(yield i.dapi.files.exists(r)){const e=yield i.dapi.files.readAsText(r);return d.set(t.id,e),e}},new((o=void 0)||(o=Promise))(function(t,i){function r(t){try{l(s.next(t))}catch(t){i(t)}}function a(t){try{l(s.throw(t))}catch(t){i(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o(function(t){t(n)})).then(r,a)}l((s=s.apply(e,n||[])).next())});var e,n,o,s},p=t=>{let e;try{e=t.package}catch(t){}return e},h=t=>{var e;return!!(null===(e=null==t?void 0:t.options)||void 0===e?void 0:e.help)},f=t=>"true"===t.options.runOnInput,v=t=>{var e;return JSON.parse(null!==(e=t.options.features)&&void 0!==e?e:"{}")},m=(t,e,n)=>{var i;return t instanceof Array?t.includes(e):t instanceof Object&&null!==(i=t[e])&&void 0!==i?i:n},g=t=>{try{return null==t?void 0:t.started}catch(t){return}},y=t=>{var e;return(0,l.iu)(null!==(e=t.options[u.fj])&&void 0!==e?e:"false")||!g(t)||!t.id},b=t=>{var e,n;const i=(null===(n=null===(e=t.func)||void 0===e?void 0:e.nqName)||void 0===n?void 0:n.includes(":"))?o.Func.byName(t.func.nqName).prepare():t.func.prepare();i.id=t.id,t.options.forEach(e=>i.options[e]=t.options[e]);const s=r()(i.outputParams.values()).filter(e=>null!=t.outputs[e.name]);for(const e of s)e.property.propertyType===o.TYPE.DATA_FRAME?i.outputs[e.name]=t.outputs[e.name].clone():i.outputs[e.name]=t.outputs[e.name];const a=r()(i.inputParams.values()).filter(e=>null!=t.inputs[e.name]);for(const e of a)e.property.propertyType===o.TYPE.DATA_FRAME?i.inputs[e.name]=t.inputs[e.name].clone():i.inputs[e.name]=t.inputs[e.name];return g(t)&&(i.started=t.started),i},C=t=>{const e=t.options[a.NT];return e?{name:t.name,config:JSON.parse(e,(t,e)=>{if("true"===e)return!0;if("false"===e)return!1;if("type"===t)return a.CB[e]||e;if(!t.toLowerCase().includes("color")){const t=Number.parseFloat(e);if(!Number.isNaN(t))return t}return e})}:{name:t.name,config:[]}},w=t=>{try{return t.started.toDate().toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}catch(t){return"Not completed"}},A=t=>new Promise(e=>setTimeout(e,t))},6126(t,e,n){"use strict";n.d(e,{A:()=>u});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r);const l=()=>document.querySelector(".d4-balloon-container");class u extends s.JsViewer{constructor(){super()}onFrameAttached(t){this.render()}onTableAttached(){this.render()}render(){if(!this.dataFrame||this.dataFrame.rowCount<=0)return void(this.root.innerHTML="");const t=this.dataFrame,e="isOutlier",n="isOutlierSecondary",r="Rationale",u="Count",d="isConfirmed";t.columns.byName(e)||t.columns.add(s.Column.fromList(s.TYPE.STRING,e,new Array(t.rowCount).fill("Inlier"))),t.columns.byName(n)||t.columns.add(s.Column.fromList(s.TYPE.STRING,n,new Array(t.rowCount).fill("Inlier"))),t.columns.byName(r)||t.columns.add(s.Column.fromStrings(r,Array.from({length:t.rowCount},()=>"")));const c=()=>s.DataFrame.fromColumns([s.Column.fromStrings(r,[]),s.Column.fromInt32Array(u,new Int32Array([])),s.Column.fromStrings("Actions",[]),s.Column.fromBitSet(d,s.BitSet.create(0,()=>!1))]),p=s.Viewer.grid(c());p.root.style.width="100%",p.root.style.minWidth="230px",p.columns.setVisible([r,u,"Actions"]),this.root.append(o.divV([o.divV([p.root],{style:{height:"75%"}})],{style:{height:"100%"}}));const h=()=>{var i,o,u,d,c,h,f;if(!p.dataFrame)return;null===(i=t.col(e))||void 0===i||i.meta.markers.assign("Outlier",s.MARKER_TYPE.OUTLIER),null===(o=t.col(e))||void 0===o||o.meta.markers.assign("Last Inlier",s.MARKER_TYPE.STAR),null===(u=t.col(e))||void 0===u||u.meta.colors.setCategorical({Outlier:s.Color.scatterPlotMarker,Inlier:s.Color.scatterPlotMarker,"Last Inlier":s.Color.red}),null===(d=t.col(n))||void 0===d||d.meta.markers.assign("Outlier",s.MARKER_TYPE.OUTLIER),null===(c=t.col(n))||void 0===c||c.meta.markers.assign("Last Inlier",s.MARKER_TYPE.STAR),null===(h=t.col(n))||void 0===h||h.meta.colors.setCategorical({Outlier:s.Color.cyan,Inlier:s.Color.cyan,"Last Inlier":s.Color.red});const v=null===(f=p.dataFrame)||void 0===f?void 0:f.cell(p.dataFrame.rowCount-1,r).value;t.selection.getSelectedIndexes().forEach(i=>{t.col(e).set(i,"Outlier",!1),t.col(n).set(i,"Outlier",!1),t.col(r).set(i,v,!1)}),t.selection.setAll(!1),t.fireValuesChanged(),a()(l()).empty()},f=()=>{p.dataFrame&&(p.dataFrame.rows.removeAt(p.dataFrame.rowCount-1),t.selection.setAll(!1),a()(l()).empty())};p.onCellPrepare(i=>{var s,a,l;i.isTableCell&&("Actions"===i.gridColumn.name&&(i.gridColumn.cellType="html",i.style.element=o.divH([...(null===(s=i.grid.dataFrame)||void 0===s?void 0:s.get(d,i.gridRow))?[(l=null===(a=i.grid.dataFrame)||void 0===a?void 0:a.get(r,i.gridRow),o.div(o.icons.delete(()=>{for(let i=0;i<t.rowCount;i++)t.columns.byName(r).get(i)===l&&(t.columns.byName(r).set(i,"",!1),t.columns.byName(e).set(i,"Inlier",!1),t.columns.byName(n).set(i,"Inlier",!1));t.fireValuesChanged()},"Remove the outliers group"),{style:{textAlign:"center",margin:"6px"}}))]:[o.div(o.iconFA("check",h,"Confirm the outliers"),{style:{textAlign:"center",margin:"6px"}}),o.div(o.iconFA("times",f,"Cancel the outliers"),{style:{textAlign:"center",margin:"6px"}})]])))}),p.onCellValueEdited.subscribe(e=>{var n,i;if(!p.dataFrame||e.gridColumn.name!==r)return;if(!p.dataFrame.columns.byName(d).get(e.gridRow))return;const o=new Set;for(let t=0;t<(null===(n=p.dataFrame)||void 0===n?void 0:n.rowCount);t++){const e=null===(i=p.dataFrame)||void 0===i?void 0:i.columns.byName(r).get(t);o.add(e)}for(let n=0;n<t.rowCount;n++){const i=t.columns.byName(r).get(n);""==i||o.has(i)||t.columns.byName(r).set(n,e.cell.value)}});const v=()=>{if(t.columns.byName(r))for(let n=0;n<t.rowCount;n++)"Outlier"===t.columns.byName(e).get(n)?""===t.columns.byName(r).get(n)&&t.columns.byName(r).set(n,"Manual",!1):""!==t.columns.byName(r).get(n)&&t.columns.byName(r).set(n,"",!1);const n={};if(t.columns.byName(r))for(let e=0;e<t.rowCount;e++){const i=t.columns.byName(r).get(e),o=n[i];""!=i&&(o?n[i]++:n[i]=1)}p.dataFrame=c(),p.columns.setVisible([r,u,"Actions"]),Object.keys(n).map(t=>{var e;null===(e=p.dataFrame)||void 0===e||e.rows.addNew([t,n[t],"",!0])})};t.onDataChanged.subscribe(v),t.onSelectionChanged.subscribe(()=>{if(!p.dataFrame||!t.selection.trueCount)return;const e=l();if(e&&!a()(e).is(":empty")||i.shell.info(o.div([o.divText("Confirm selected points as outliers?"),o.divH([o.bigButton("Confirm",h),o.button("Cancel",f)])])),p.dataFrame.columns.byName(d).toList().some(t=>!1===t))p.dataFrame.set(u,p.dataFrame.rowCount-1,t.selection.trueCount);else{const e=p.dataFrame.rows.addNew(["Manual",t.selection.trueCount,"",!1]);p.dataFrame.currentCell=p.dataFrame.cell(e.idx,r)}}),t.selection.setAll(!1),v()}}},2961(t,e,n){"use strict";n.d(e,{CY:()=>b,Ln:()=>h,Qc:()=>a,Ts:()=>s,Vb:()=>r,Vu:()=>p,ZO:()=>m,b9:()=>g,dg:()=>y,jO:()=>l,pE:()=>v,u0:()=>u,wN:()=>d,wx:()=>c,ze:()=>f});var i=n(2650),o=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};function s(){return o(this,void 0,void 0,function*(){yield i.PackageFunctions.init()})}function r(t){i.PackageFunctions.openModelFromFuncall(t)}function a(){return i.PackageFunctions.OutliersSelection()}function l(t){return i.PackageFunctions.RichFunctionViewEditor(t)}function u(t){return i.PackageFunctions.PipelineStepEditor(t)}function d(t){return o(this,void 0,void 0,function*(){return yield i.PackageFunctions.CustomDataUploader(t)})}function c(t){return o(this,void 0,void 0,function*(){return yield i.PackageFunctions.CustomUploader(t)})}function p(t){i.PackageFunctions.CustomCustomizer(t)}function h(t){return i.PackageFunctions.SimTimeValidator(t)}function f(t){return i.PackageFunctions.DesiredTempValidator(t)}function v(t){return i.PackageFunctions.InitialTempValidator(t)}function m(t){return i.PackageFunctions.AmbTempValidator(t)}function g(t){return i.PackageFunctions.HeatCapValidator(t)}function y(t){return i.PackageFunctions.CustomStringInput(t)}function b(t){return i.PackageFunctions.ObjectCoolingSelector(t)}},2650(t,e,n){"use strict";n.r(e),n.d(e,{AmbTempValidator:()=>f.ZO,CFV:()=>E,CompView:()=>A,CustomCustomizer:()=>f.Vu,CustomDataUploader:()=>f.wN,CustomStringInput:()=>f.dg,CustomUploader:()=>f.wx,DesiredTempValidator:()=>f.ze,HeatCapValidator:()=>f.b9,InitialTempValidator:()=>f.pE,ObjectCoolingSelector:()=>f.CY,OutliersSelection:()=>f.Qc,PackageFunctions:()=>L,Pipeline:()=>I,PipelineStepEditor:()=>f.u0,RFV:()=>x,RichFunctionViewEditor:()=>f.jO,SimTimeValidator:()=>f.Ln,_package:()=>b,deepCopy:()=>w,fileInput:()=>P,historyInput:()=>k,historyInputJSON:()=>O,historyPanel:()=>B,init:()=>f.Ts,makeAdvice:()=>T,makeRevalidation:()=>S,makeValidationResult:()=>R,mergeValidationResults:()=>F,openModelFromFuncall:()=>f.Vb,testPipeline:()=>C});var i=n(4328),o=n(7389),s=n(6082),r=n(9713),a=n(6126),l=n(5727),u=n(3501),d=n(3143),c=n(1927),p=n(9939),h=n(1599),f=n(2961),v=function(t,e,n,i){var o,s=arguments.length,r=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(s<3?o(r):s>3?o(e,n,r):o(e,n))||r);return s>3&&r&&Object.defineProperty(e,n,r),r},m=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},g=function(t,e){return function(n,i){e(n,i,t)}},y=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};const b=new s.Package,C=l.bS,w=h.A4,A=l.HJ,x=l.Ee,E=u.v,I=l.uf,R=c.ZS,T=c.B5,S=c.dQ,F=c.uD,P=d.A.fileInput,k=d.A.historyInput,O=d.A.historyInputJSON,B=d.A.historyPanel;class L{static init(){return y(this,void 0,void 0,function*(){})}static openModelFromFuncall(t){p.sg.openModelFromFunccall(t)}static OutliersSelection(){return new a.A}static RichFunctionViewEditor(t){return l.Ee.fromFuncCall(t,{historyEnabled:!0,isTabbed:!1})}static PipelineStepEditor(t){return l.Ee.fromFuncCall(t,{historyEnabled:!1,isTabbed:!0})}static CustomDataUploader(t){return y(this,void 0,void 0,function*(){return yield new Promise(t=>setTimeout(t,1e3)),[yield t.prepare({ambTemp:22,initTemp:100,desiredTemp:30,area:.06,heatCap:4200,heatTransferCoeff:8.3,simTime:21600}).call()]})}static CustomUploader(t){return y(this,void 0,void 0,function*(){const e=(yield i.functions.eval("Compute:CustomDataUploader")).prepare({func:t.func}),n=o.bigButton("Click me to get mock calls",()=>e.call()),a=s.Widget.fromRoot(o.panel([o.divV([o.label("This part of dialog comes from my custom data uploader"),o.divH([n],{style:{justifyContent:"center"}})])])),l=i.functions.onBeforeRunAction.pipe((0,r.filter)(t=>t.id===e.id)).subscribe(()=>{o.setUpdateIndicator(n,!0)}),u=i.functions.onAfterRunAction.pipe((0,r.filter)(t=>t.id===e.id)).subscribe(()=>{o.setUpdateIndicator(n,!1)});return a.subs.push(l,u),{uploadWidget:a,uploadFuncCall:e}})}static CustomCustomizer(t){t.defaultView.scatterPlot({xColumnName:"Initial temperature",yColumnName:"Time to cool"})}static SimTimeValidator(t){const{reasonableMin:e,reasonableMax:n}=t;return t=>(0,c.ZS)({warnings:t<e||t>n?[`Minimum reasonable time is ${e}. Maximum reasonable time is ${n}`]:void 0,errors:t<0?["Time should be strictly positive"]:void 0})}static DesiredTempValidator(t){return(t,e)=>{const n=e.funcCall.inputs.ambTemp,i=e.funcCall.inputs.initTemp;return(0,c.ZS)({errors:[...t<n?[(0,c.B5)(`Desired temperature cannot be less than ambient temperature (${n}). \n`,[{actionName:"Set desired equal to ambient",action:()=>e.funcCall.inputs.desiredTemp=n}])]:[],...t>i?[`Desired temperature cannot be higher than initial temperature (${i})`]:[]]})}}static InitialTempValidator(t){return(t,e)=>{const n=e.funcCall.inputs.ambTemp;return(0,c.ZS)({errors:[...t<n?[`Initial temperature cannot be less than ambient temperature (${n}).`]:[]]})}}static AmbTempValidator(t){return(t,e)=>{const n=e.funcCall.inputs.initTemp;return(0,c.ZS)({errors:[...t>n?[`Ambient temperature cannot be higher than initial temperature (${n})`]:[]]})}}static HeatCapValidator(t){return(t,e)=>(0,c.ZS)({errors:[...t<=0?["Heat capacity must be greater than zero."]:[]],notifications:[(0,c.B5)("Heat capacity is only dependent on the object material.",[{actionName:"Google it",action:()=>{window.open("http://google.com")}}])]})}static CustomStringInput(t){const e=o.input.string("Custom input",{value:""});return e.root.style.backgroundColor="aqua",e.input.style.backgroundColor="aqua",e}static ObjectCoolingSelector(t){return d.A.historyInputJSON("Previous run","ObjectCooling")}}v([i.decorators.init(),m("design:type",Function),m("design:paramtypes",[]),m("design:returntype",Promise)],L,"init",null),v([i.decorators.func(),m("design:type",Function),m("design:paramtypes",[s.FuncCall]),m("design:returntype",void 0)],L,"openModelFromFuncall",null),v([i.decorators.func({name:"OutliersSelectionViewer",description:"Creates an outliers selection viewer",outputs:[{type:"viewer",name:"result"}],meta:{role:"viewer"}}),m("design:type",Function),m("design:paramtypes",[]),m("design:returntype",void 0)],L,"OutliersSelection",null),v([i.decorators.editor({outputs:[{type:"view",name:"result"}]}),m("design:type",Function),m("design:paramtypes",[s.FuncCall]),m("design:returntype",void 0)],L,"RichFunctionViewEditor",null),v([i.decorators.editor({outputs:[{type:"object",name:"result"}]}),m("design:type",Function),m("design:paramtypes",[s.FuncCall]),m("design:returntype",void 0)],L,"PipelineStepEditor",null),v([i.decorators.func({outputs:[{type:"object",name:"uploadedCalls"}]}),m("design:type",Function),m("design:paramtypes",[s.Func]),m("design:returntype",Promise)],L,"CustomDataUploader",null),v([i.decorators.func({outputs:[{name:"uploadWidget",type:"widget"},{name:"uploadFuncCall",type:"funccall"}]}),g(0,i.decorators.param({type:"object"})),m("design:type",Function),m("design:paramtypes",[Object]),m("design:returntype",Promise)],L,"CustomUploader",null),v([i.decorators.func(),g(0,i.decorators.param({type:"object"})),m("design:type",Function),m("design:paramtypes",[Object]),m("design:returntype",void 0)],L,"CustomCustomizer",null),v([i.decorators.func({outputs:[{type:"object",name:"validator"}]}),g(0,i.decorators.param({type:"object"})),m("design:type",Function),m("design:paramtypes",[Object]),m("design:returntype",void 0)],L,"SimTimeValidator",null),v([i.decorators.func({outputs:[{type:"object",name:"validator"}]}),g(0,i.decorators.param({type:"object"})),m("design:type",Function),m("design:paramtypes",[Object]),m("design:returntype",void 0)],L,"DesiredTempValidator",null),v([i.decorators.func({outputs:[{type:"object",name:"validator"}]}),g(0,i.decorators.param({type:"object"})),m("design:type",Function),m("design:paramtypes",[Object]),m("design:returntype",void 0)],L,"InitialTempValidator",null),v([i.decorators.func({outputs:[{type:"object",name:"validator"}]}),g(0,i.decorators.param({type:"object"})),m("design:type",Function),m("design:paramtypes",[Object]),m("design:returntype",void 0)],L,"AmbTempValidator",null),v([i.decorators.func({outputs:[{type:"object",name:"validator"}]}),g(0,i.decorators.param({type:"object"})),m("design:type",Function),m("design:paramtypes",[Object]),m("design:returntype",void 0)],L,"HeatCapValidator",null),v([i.decorators.func({outputs:[{type:"object",name:"result"}]}),g(0,i.decorators.param({type:"object"})),m("design:type",Function),m("design:paramtypes",[Object]),m("design:returntype",void 0)],L,"CustomStringInput",null),v([i.decorators.func({outputs:[{type:"object",name:"result"}]}),g(0,i.decorators.param({type:"object"})),m("design:type",Function),m("design:paramtypes",[Object]),m("design:returntype",void 0)],L,"ObjectCoolingSelector",null)},1757(t){"use strict";t.exports=$},6082(t){"use strict";t.exports=DG},3508(t){"use strict";t.exports=dayjs},4328(t){"use strict";t.exports=grok},1858(t){"use strict";t.exports=rxjs},9713(t){"use strict";t.exports=rxjs.operators},7389(t){"use strict";t.exports=ui},1991(t){"use strict";t.exports=wu},1825(t,e,n){"use strict";n.d(e,{Fo:()=>v,SM:()=>p});const i="function"==typeof Buffer,o=("function"==typeof TextDecoder&&new TextDecoder,"function"==typeof TextEncoder&&new TextEncoder,Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")),s=(t=>{let e={};return t.forEach((t,n)=>e[t]=n),e})(o),r=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,a=String.fromCharCode.bind(String),l="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):t=>new Uint8Array(Array.prototype.slice.call(t,0)),u=t=>t.replace(/[^A-Za-z0-9\+\/]/g,""),d="function"==typeof btoa?t=>btoa(t):i?t=>Buffer.from(t,"binary").toString("base64"):t=>{let e,n,i,s,r="";const a=t.length%3;for(let a=0;a<t.length;){if((n=t.charCodeAt(a++))>255||(i=t.charCodeAt(a++))>255||(s=t.charCodeAt(a++))>255)throw new TypeError("invalid character found");e=n<<16|i<<8|s,r+=o[e>>18&63]+o[e>>12&63]+o[e>>6&63]+o[63&e]}return a?r.slice(0,a-3)+"===".substring(a):r},c=i?t=>Buffer.from(t).toString("base64"):t=>{let e=[];for(let n=0,i=t.length;n<i;n+=4096)e.push(a.apply(null,t.subarray(n,n+4096)));return d(e.join(""))},p=(t,e=!1)=>e?c(t).replace(/=/g,"").replace(/[+\/]/g,t=>"+"==t?"-":"_"):c(t),h="function"==typeof atob?t=>atob(u(t)):i?t=>Buffer.from(t,"base64").toString("binary"):t=>{if(t=t.replace(/\s+/g,""),!r.test(t))throw new TypeError("malformed base64.");let e,n,i;t+="==".slice(2-(3&t.length));let o=[];for(let r=0;r<t.length;)e=s[t.charAt(r++)]<<18|s[t.charAt(r++)]<<12|(n=s[t.charAt(r++)])<<6|(i=s[t.charAt(r++)]),64===n?o.push(a(e>>16&255)):64===i?o.push(a(e>>16&255,e>>8&255)):o.push(a(e>>16&255,e>>8&255,255&e));return o.join("")},f=i?t=>l(Buffer.from(t,"base64")):t=>l(h(t).split("").map(t=>t.charCodeAt(0))),v=t=>f(m(t)),m=t=>u(t.replace(/[-_]/g,t=>"-"==t?"+":"/"))}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var s=e[i]={id:i,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nc=void 0;var i=n(2650);compute=i})();
|
|
2
2
|
//# sourceMappingURL=package.js.map
|