@datagrok/compute 1.43.5 → 1.43.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.js CHANGED
@@ -1,2 +1,2 @@
1
- var compute;(()=>{var t={32:(t,e,n)=>{"use strict";n.d(e,{Ee:()=>s.E,HJ:()=>o.H,uf:()=>i.u,vs:()=>r.v}),n(4451);var i=n(8117),o=n(4822),s=n(5104),r=(n(8476),n(1491),n(3501))},237:(t,e,n)=>{"use strict";var i;n.d(e,{FL:()=>o,KN:()=>i,TR:()=>r}),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=`# 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](https://datagrok.ai/help/compute/function-analysis#monte-carlo) explores a function \nat randomly taken points\n\n* [Sobol](https://datagrok.ai/help/compute/function-analysis#sobol)\ndecomposes output variance into fractions, which can be attributed to inputs\n\n* [Grid](https://datagrok.ai/help/compute/function-analysis#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 <i class="grok-icon fal fa-question"></i> on the top panel to learn more about \n[Sensitivity Analysis](https://datagrok.ai/help/compute/function-analysis#sensitivity-analysis)\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.`},241:(t,e,n)=>{"use strict";n.d(e,{bj:()=>o,df:()=>s,tB:()=>l});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}],["maxIter",{default:50,min:1,max:1e4}],["nonZeroParam",{default:1e-4,min:1e-20,max:.1}],["initialScale",{default:.02,min:1e-20,max:.1}],["scaleReflaction",{default:1,min:1,max:2}],["scaleExpansion",{default:2,min:1,max:2}],["scaleContraction",{default:-.5,min:-.5,max:0}]]),s=new Map([["tolerance","tolerance"],["maxIter","max iterations"],["nonZeroParam","non-zero param"],["initialScale","initial scale"],["scaleReflaction","scale reflection"],["scaleExpansion","scale expansion"],["scaleContraction","scale contraction"]]);function r(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 a(t,e,n,i,o,s,r,a){for(let l=0;l<s;l++)e[l]=t[l],e[l]+=o*(t[l]-i[n][l]),e[l]<r[l]?e[l]=r[l]:e[l]>a[l]&&(e[l]=a[l])}const l=function(t,e,n,o,s){return i(this,void 0,void 0,(function*(){const l=n.get("tolerance"),u=n.get("maxIter"),c=n.get("scaleReflaction"),d=n.get("scaleExpansion"),p=n.get("scaleContraction"),h=e.length+1,f=e.length,[m,v]=yield function(t,e,n,o,s){return i(this,void 0,void 0,(function*(){const i=n.length+1,r=n.length,a=e.get("nonZeroParam"),l=e.get("initialScale"),u=new Array(i),c=new Array(i);for(let e=0;e<i;e++){u[e]=new Float32Array(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],u[e][t]<o[t]?u[e][t]=o[t]:u[e][t]>s[t]&&(u[e][t]=s[t]));c[e]=yield t(u[e])}return[u,c]}))}(t,n,e,o,s),g=new Array(h);for(let t=0;t<h;t++)g[t]=t;const y=g.length-1;let b=0,A=0,C=0,w=0;const I=new Float32Array(f),T=new Float32Array(f),E=new Float32Array(f),S=new Float32Array(f),x=new Array(u);if(h>1){for(;g.sort(((t,e)=>v[t]-v[e])),!(b>u);){if(0==b&&(A=v[0],C=2*v[g[0]]),x[b]=A,++b,A=v[g[0]],C-A>l)w=0;else if(++w,w>2*h)break;C=A,r(I,f,g[y],m),a(I,T,g[y],m,c,f,o,s);const e=yield t(T);if(e<v[g[y]]){a(I,E,g[y],m,d,f,o,s);const n=yield t(E);if(n<e){v[g[y]]=n;for(let t=0;t<f;t++)m[g[y]][t]=E[t];continue}v[g[y]]=e;for(let t=0;t<f;t++)m[g[y]][t]=T[t];continue}a(I,S,g[y],m,p,f,o,s);const n=yield t(S);if(!(n<v[g[y]]))break;v[g[y]]=n;for(let t=0;t<f;t++)m[g[y]][t]=S[t]}for(let t=b;t<u;t++)x[t]=v[g[0]]}return{point:m[g[0]],cost:v[g[0]],iterCosts:x,iterCount:b-1}}))}},265:(t,e,n)=>{"use strict";var i=n(9467);n(5669),i.Y},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:o,ViewClass:r}=t;let a=r.findModelCatalogView(e);if(!a){const t=s.Func.find({package:o.name,name:n})[0].prepare();t.callSync({processed:!0,report:!1}),a=t.outputs.v}return[...i.shell.views].find((t=>t===a))||i.shell.add(a),a}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))}))}}}}))}},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}},567:(t,e,n)=>{"use strict";n(5669)},810:(t,e,n)=>{"use strict";n.d(e,{Bu:()=>p,Gb:()=>f,ZD:()=>h,cb:()=>d,eK:()=>g,fo:()=>v,jJ:()=>m});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(4260),u=n(1858),c=(n(1599),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=>new Promise((e=>setTimeout(e,t))),p=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 h(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"))}function f(t){return new u.Observable((e=>{const n=t((t=>{e.next(t)}));return()=>n.unsubscribe()}))}const m=t=>{const e=t.options[l.NT];return void 0!==e?{name:t.name,config:JSON.parse(e,((t,e)=>{if("true"===e)return!0;if("false"===e)return!1;if("type"===t)return l.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:[]}},v=(t,e,n={parentView:void 0,parentCall:void 0})=>{var r,u;const d=e,p=[...d.inputs,...d.outputs].map((t=>m(t))).reduce(((t,e)=>(t[e.name]?t[e.name].push(...e.config):t[e.name]=e.config,t)),{}),h=e=>{var n;if(e.propertyType===s.TYPE.DATA_FRAME){const n=p[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=f.columns.getUnusedName(`${r.name} (${n.type})`);return r.name=a,o=a,r.temp[l.NT]=n,f.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=f.columns.getUnusedName(o.name);return o.name=r,i=r,f.columns.add(o),[o]}},f=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} - ${g(t)}`,i=2;for(;v.includes(n);)n=`${t.func.name} - ${g(t)})\n .toLocaleString('en-us', {month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric'})} - ${i}`,i++;v.push(n)})),f.columns.add(s.Column.fromStrings(l._W,v)),f.name=(null===(r=n.parentCall)||void 0===r?void 0:r.func.name)?`${null===(u=n.parentCall)||void 0===u?void 0:u.func.name} - comparison`:`${e.name} - comparison`,d.inputs.forEach((t=>h(t))),d.outputs.forEach((t=>h(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%"})}}))}})),f},g=t=>{try{return t.started.toDate().toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}catch(t){return"Not completed"}}},844:(t,e,n)=>{"use strict";n.d(e,{S:()=>o});var i=n(3313);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}},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},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()).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={}))},1294:(t,e,n)=>{"use strict";n(5669),Math.sqrt(2),Math.sqrt(2)},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:()=>E});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(500),h=n(7149),f=n(8476),m=(n(8870),n(4260)),v=n(237),g=n(1159),y=n(7722),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.BOOL,s.TYPE.DATA_FRAME],C=[s.TYPE.INT,s.TYPE.BIG_INT,s.TYPE.FLOAT,s.TYPE.BOOL,s.TYPE.DATA_FRAME];var w,I;!function(t){t.GRID_ANALYSIS="Grid",t.RANDOM_ANALYSIS="Monte Carlo",t.SOBOL_ANALYSIS="Sobol"}(w||(w={})),function(t){t.LAST_ROW="Last row",t.FIRST_ROW="First row",t.ALL_COLUMNS="",t.BY_COL_VAL="By value in column"}(I||(I={}));const T=()=>o.div([],"sa-switch-input");class E{static fromEmpty(t){return b(this,arguments,void 0,(function*(t,e={parentView:void 0,parentCall:void 0,inputsLookup:void 0,ranges:void 0}){const n=[...i.shell.views].find((t=>t.type===m.sk)),o=yield f.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}){this.func=t,this.options=n,this.generateInputFields=t=>{const e={analysisType:{input:o.input.choice("Method",{value:w.RANDOM_ANALYSIS,items:[w.RANDOM_ANALYSIS,w.SOBOL_ANALYSIS,w.GRID_ANALYSIS],onValueChanged:t=>{e.analysisType.value.next(t),this.updateRunWidgetsState(),this.setAnalysisInputTooltip(),this.store.analysisInputs.samplesCount.input.setTooltip(this.samplesCountTooltip())}}),value:new l.BehaviorSubject(w.RANDOM_ANALYSIS)},samplesCount:{input:o.input.int("Samples",{value:10,onValueChanged:t=>{e.samplesCount.value=t,this.updateRunWidgetsState()}}),value:10}};e.analysisType.input.root.insertBefore(T(),e.analysisType.input.captionLabel),e.samplesCount.input.root.insertBefore(T(),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.updateRunWidgetsState()})),p=r(!1,(t=>{m.isChanging.next(t),this.updateRunWidgetsState()})),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.updateRunWidgetsState()}}),value:3},isChanging:new l.BehaviorSubject(!1)};[h.max.input,h.lvl.input].forEach((t=>{t.root.insertBefore(T(),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===w.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.updateRunWidgetsState()})),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=T(),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:I.LAST_ROW,items:[I.LAST_ROW,I.FIRST_ROW,I.BY_COL_VAL],onValueChanged:t=>{n.value.returning=t,n.analysisInputs.forEach((e=>{e.root.hidden=t!==I.BY_COL_VAL})),a.setTooltip(this.getOutputTooltip(i,t))}}),a.setTooltip(this.getOutputTooltip(i,I.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!==I.BY_COL_VAL})),this.updateRunWidgetsState(),e.propertyType===s.TYPE.DATA_FRAME&&a.setTooltip(t?this.getOutputTooltip(i,I.LAST_ROW):"Dataframe")}),!1).root:T();return a.root.insertBefore(l,a.captionLabel),a})(),analysisInputs:e.propertyType===s.TYPE.DATA_FRAME?[(()=>{var t;const i=o.input.string("Column",{value:I.ALL_COLUMNS,onValueChanged:t=>{n.value.colName=t}});return i.root.insertBefore(T(),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(T(),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:I.LAST_ROW,colName:I.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.gridSubscription=null,this.store=this.generateInputFields(this.func),this.runButton=o.bigButton("Run",(()=>b(this,void 0,void 0,(function*(){return yield this.runAnalysis()})))),this.runIcon=o.iconFA("play",(()=>b(this,void 0,void 0,(function*(){return yield this.runAnalysis()})))),this.runIcon.style.color="var(--green-2)",this.runIcon.classList.add("fas"),this.helpIcon=o.iconFA("question",(()=>{window.open("https://datagrok.ai/help/compute/function-analysis#sensitivity-analysis","_blank")}),"Open help in a new tab"),this.buildFormWithBtn(n.inputsLookup).then((t=>{this.runButton.disabled=!this.canEvaluationBeRun(),this.runIcon.hidden=this.runButton.disabled,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;const n=this.comparisonView.getRibbonPanels();n.push([this.helpIcon,this.runIcon]),this.comparisonView.setRibbonPanels(n),this.comparisonView.helpUrl="/help/function-analysis.md#sensitivity-analysis",this.tableDockNode=this.comparisonView.dockManager.findNode(this.comparisonView.grid.root);const i=o.markdown(v.TR);i.style.padding="10px",i.style.overflow="auto",this.helpMdNode=this.comparisonView.dockManager.dock(i,s.DOCK_TYPE.FILL,this.tableDockNode,"About")}))}closeOpenedViewers(){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.gridSubscription&&(this.gridSubscription.unsubscribe(),this.gridSubscription=null)}getFuncCallCount(t,e){let n=0;switch(t.analysisType.value.value){case w.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 w.RANDOM_ANALYSIS:return t.samplesCount.value;case w.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 t<1e3?String(t):t<1e6?String(Math.ceil(t/10)/100)+"k":t<1e9?String(Math.ceil(t/1e4)/100)+"m":String(Math.ceil(t/1e7)/100)+"b"}updateRunWidgetsState(){this.runButton.textContent=`Run (${this.getFuncCallCountAsString()})`,this.runButton.disabled=!this.canEvaluationBeRun(),this.runIcon.hidden=this.runButton.disabled}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,g.c)(t,e);return null!==n&&n.input.root.insertBefore(T(),n.input.captionLabel),n}))}buildFormWithBtn(t){return b(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,y.FB)(s,t)),n.append(...t)}if(e.forEach(((t,e)=>{"Misc"!==e&&e!==s&&(n.append((0,y.FB)(e,t)),n.append(...t))})),"Misc"!==s){const t=e.get("Misc");t.length>0&&(n.append((0,y.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===w.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}c||this.store.outputs[Object.keys(this.store.outputs)[0]].isInterest.next(!0),this.updateRunWidgetsState();const d=o.buttonsInput([this.runButton]);return n.appendChild(d),a()(n).css({"padding-left":"12px","overflow-y":"scroll","padding-right":"4px"}),n}))}setAnalysisInputTooltip(){let t;switch(this.store.analysisInputs.analysisType.value.value){case w.GRID_ANALYSIS:t="Grid analysis: the function is evaluated with respect to the selected inputs varying within the specified ranges";break;case w.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 w.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 I.FIRST_ROW:return`To analyze first row of the '${t}' dataframe`;case I.LAST_ROW:return`To analyze last row of the '${t}' dataframe`;case I.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 w.RANDOM_ANALYSIS:return"Input sets count";case w.SOBOL_ANALYSIS:return"Sample size for the Sobol' indices computation";default:return"Unknown method!"}}addTooltips(){var t;this.setAnalysisInputTooltip(),o.tooltip.bind(this.runButton,(()=>`Run sensitivity analysis: the function is evaluated ${this.getFuncCallCount(this.store.analysisInputs,this.store.inputs)} times`)),o.tooltip.bind(this.runIcon,(()=>`Run sensitivity analysis: the function is evaluated ${this.getFuncCallCount(this.store.analysisInputs,this.store.inputs)} times`)),this.store.analysisInputs.samplesCount.input.setTooltip(this.samplesCountTooltip());for(const e of Object.keys(this.store.inputs)){const n=this.store.inputs[e].prop.propertyType;if(n===s.TYPE.BOOL||n===s.TYPE.STRING)continue;const i=this.store.inputs[e],o=null!==(t=i.prop.caption)&&void 0!==t?t:i.prop.name;i.const.input.setTooltip(`'${o}' value`),i.min.input.setTooltip(`Min value of '${o}'`),i.max.input.setTooltip(`Max value of '${o}'`),i.lvl.input.setTooltip(`Number of samples along the axis '${o}'`)}}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}canEvaluationBeRun(){return this.isAnyInputSelected()&&this.isAnyOutputSelected()}runAnalysis(){return b(this,void 0,void 0,(function*(){if(this.canEvaluationBeRun())switch(this.store.analysisInputs.analysisType.value.value){case w.GRID_ANALYSIS:yield this.runGridAnalysis();break;case w.RANDOM_ANALYSIS:yield this.runRandomAnalysis();break;case w.SOBOL_ANALYSIS:yield this.runSobolAnalysis()}}))}getFixedInputColumns(t){return Object.values(this.store.inputs).filter((t=>!A.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 b(this,void 0,void 0,(function*(){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),r=yield n.perform();this.closeOpenedViewers();const l=r.funcEvalResults,d=r.funcCalls,p=r.firstOrderSobolIndices,h=r.totalOrderSobolIndices,f=p.columns.names();this.comparisonView.dataFrame=l;const m=l.columns.names(),g=this.getFixedInputColumns(l.rowCount);for(const t of g)t.name=l.columns.getUnusedName(`${t.name} (fixed)`),l.columns.add(t);this.comparisonView.grid.columns.setVisible([m[0]]),this.comparisonView.grid.columns.setVisible(m),this.comparisonView.grid.props.rowHeight=v.FL;const y=s.Viewer.correlationPlot(l,{xColumnNames:m,yColumnNames:m}),b=this.comparisonView.dockManager.dock(y,s.DOCK_TYPE.LEFT,this.tableDockNode,"",v.KN.COR_PLOT);this.openedViewers.push(y);const A=s.Viewer.pcPlot(l,{columnNames:m});this.comparisonView.dockManager.dock(A,s.DOCK_TYPE.DOWN,b,"",v.KN.PC_PLOT),this.openedViewers.push(A);const C=this.getOutputNameForScatterPlot(m,l,t.variedInputs.length),w=1===t.variedInputs.length?s.Viewer.lineChart(l,this.getLineChartOpt(m)):s.Viewer.scatterPlot(l,this.getScatterOpt(m,C));this.openedViewers.push(w),this.comparisonView.dockManager.dock(w,s.DOCK_TYPE.DOWN,this.tableDockNode,"",v.KN.GRAPH);const I=s.Viewer.barChart(p,this.getBarChartOpt(p.name,f[0],C)),T=this.comparisonView.dockManager.dock(I,s.DOCK_TYPE.RIGHT,void 0,"",v.KN.BAR_CHART),E=s.Viewer.barChart(h,this.getBarChartOpt(h.name,f[0],C));this.comparisonView.dockManager.dock(E,s.DOCK_TYPE.DOWN,T),this.openedViewers=this.openedViewers.concat([I,E]),this.gridSubscription=this.comparisonView.grid.onCellClick.subscribe((t=>{var e;const n=d[null!==(e=t.tableRowIndex)&&void 0!==e?e:0],r=[...n.outputParams.values()].filter((t=>s.TYPES_SCALAR.has(t.property.propertyType))),l=s.HtmlTable.create(r,(t=>{var e;return[null!==(e=t.property.caption)&&void 0!==e?e:t.property.name,n.outputs[t.property.name],t.property.options.units]})).root,c=[...n.outputParams.values()].filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME)).reduce(((t,e)=>{var i;const o=(0,u.jJ)(e.property).config,r=n.outputs[e.name],l=null!==(i=e.property.caption)&&void 0!==i?i:e.property.name;return o.map((e=>{const n=e.type,i=s.Viewer.fromType(n,r);i.setOptions(e),a()(i.root).css({width:"100%"}),t[l]?t[l].push(i.root):t[l]=[i.root]})),t}),{});let p,h;r.length>0?(h=1,p=Object.assign({"Output scalars":[l]},c)):(h=0,p=Object.assign({},c));const f=o.accordion();a()(f.root).css({width:"100%"}),Object.entries(p).map((t=>{f.addPane(t[0],(()=>o.divV(t[1])))})),f.panes[h].expanded=!0,i.shell.o=f.root}))}))}getFixedInputs(){return Object.keys(this.store.inputs).filter((t=>!A.includes(this.store.inputs[t].type)||!this.store.inputs[t].isChanging.value))}getVariedInputs(){return Object.keys(this.store.inputs).filter((t=>!!A.includes(this.store.inputs[t].type)&&this.store.inputs[t].isChanging.value))}runRandomAnalysis(){return b(this,void 0,void 0,(function*(){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),r=yield n.perform(),l=r.funcEvalResults,c=r.funcCalls;this.closeOpenedViewers(),this.comparisonView.dataFrame=l;const p=l.columns.names(),h=this.getFixedInputColumns(l.rowCount);for(const t of h)t.name=l.columns.getUnusedName(`${t.name} (fixed)`),l.columns.add(t);this.comparisonView.grid.columns.setVisible([p[0]]),this.comparisonView.grid.columns.setVisible(p),this.comparisonView.grid.props.rowHeight=v.FL;const f=s.Viewer.correlationPlot(l,{xColumnNames:p,yColumnNames:p}),m=this.comparisonView.dockManager.dock(f,s.DOCK_TYPE.LEFT,this.tableDockNode,"",v.KN.COR_PLOT);this.openedViewers.push(f);const g=s.Viewer.pcPlot(l,{columnNames:p});this.comparisonView.dockManager.dock(g,s.DOCK_TYPE.DOWN,m,"",v.KN.PC_PLOT),this.openedViewers.push(g);const y=this.getOutputNameForScatterPlot(p,l,t.variedInputs.length),b=1===t.variedInputs.length?s.Viewer.lineChart(l,this.getLineChartOpt(p)):s.Viewer.scatterPlot(l,this.getScatterOpt(p,y));this.openedViewers.push(b),this.comparisonView.dockManager.dock(b,s.DOCK_TYPE.DOWN,this.tableDockNode,"",v.KN.GRAPH),this.gridSubscription=this.comparisonView.grid.onCellClick.subscribe((t=>{var e;const n=c[null!==(e=t.tableRowIndex)&&void 0!==e?e:0],r=[...n.outputParams.values()].filter((t=>s.TYPES_SCALAR.has(t.property.propertyType))),l=s.HtmlTable.create(r,(t=>{var e;return[null!==(e=t.property.caption)&&void 0!==e?e:t.property.name,n.outputs[t.property.name],t.property.options.units]})).root,d=[...n.outputParams.values()].filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME)).reduce(((t,e)=>{var i;const o=(0,u.jJ)(e.property).config,r=n.outputs[e.name],l=null!==(i=e.property.caption)&&void 0!==i?i:e.property.name;return o.map((e=>{const n=e.type,i=s.Viewer.fromType(n,r);i.setOptions(e),a()(i.root).css({width:"100%"}),t[l]?t[l].push(i.root):t[l]=[i.root]})),t}),{});let p,h;r.length>0?(h=1,p=Object.assign({"Output scalars":[l]},d)):(h=0,p=Object.assign({},d));const f=o.accordion();a()(f.root).css({width:"100%"}),Object.entries(p).map((t=>{f.addPane(t[0],(()=>o.divV(t[1])))})),f.panes[h].expanded=!0,i.shell.o=f.root}))}))}runGridAnalysis(){return b(this,void 0,void 0,(function*(){var t,e;const n=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 r=Object.values(n)[0].map((t=>[t]));for(let t=1;t<Object.values(n).length;t++){const e=Object.values(n)[t],i=[];for(const t of r)for(const n of e)i.push([...t,n]);r=i}const l=r.map((t=>this.func.prepare(this.func.inputs.map(((t,e)=>({name:t.name,idx:e}))).reduce(((e,{name:n,idx:i})=>(e[n]=t[i],e)),{})))),c=yield(0,h.X)(l);this.closeOpenedViewers();const d=[],f=c.length,m=this.getFixedInputColumns(f);for(const e of Object.keys(this.store.inputs)){const n=this.store.inputs[e],i=n.prop;n.isChanging.value&&d.push(s.Column.fromType(i.propertyType,null!==(t=i.caption)&&void 0!==t?t:i.name,f))}const g=[...d],y=g.length,b=s.DataFrame.fromColumns([g[0]]);for(let t=1;t<y;++t)g[t].name=b.columns.getUnusedName(g[t].name),b.columns.add(g[t]);for(let t=0;t<f;++t)for(const n of Object.keys(this.store.inputs)){const i=this.store.inputs[n],o=i.prop;i.isChanging.value&&b.set(null!==(e=o.caption)&&void 0!==e?e:o.name,t,c[t].inputs[n])}const A=this.getOutputsOfInterest(),C=(0,p.ex)(c,A).columns;for(const t of C)g.forEach((e=>{e.name===t.name&&(e.name=`${e.name} (input)`,t.name=`${t.name} (output)`)})),t.name=b.columns.getUnusedName(t.name),b.columns.add(t);const w=b.columns.names();for(const t of m)t.name=b.columns.getUnusedName(`${t.name} (fixed)`),b.columns.add(t);this.comparisonView.dataFrame=b,this.gridSubscription=this.comparisonView.grid.onCellClick.subscribe((t=>{var e;const n=c[null!==(e=t.tableRowIndex)&&void 0!==e?e:0],r=[...n.outputParams.values()].filter((t=>s.TYPES_SCALAR.has(t.property.propertyType))),l=s.HtmlTable.create(r,(t=>{var e;return[null!==(e=t.property.caption)&&void 0!==e?e:t.property.name,n.outputs[t.property.name],t.property.options.units]})).root,d=[...n.outputParams.values()].filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME)).reduce(((t,e)=>{var i;const o=(0,u.jJ)(e.property).config,r=n.outputs[e.name],l=null!==(i=e.property.caption)&&void 0!==i?i:e.property.name;return o.map((e=>{const n=e.type,i=s.Viewer.fromType(n,r);i.setOptions(e),a()(i.root).css({width:"100%"}),t[l]?t[l].push(i.root):t[l]=[i.root]})),t}),{});let p,h;r.length>0?(h=1,p=Object.assign({"Output scalars":[l]},d)):(h=0,p=Object.assign({},d));const f=o.accordion();a()(f.root).css({width:"100%"}),Object.entries(p).map((t=>{f.addPane(t[0],(()=>o.divV(t[1])))})),f.panes[h].expanded=!0,i.shell.o=f.root})),this.comparisonView.grid.columns.setVisible([w[0]]),this.comparisonView.grid.columns.setVisible(w),this.comparisonView.grid.props.rowHeight=v.FL;const I=s.Viewer.correlationPlot(b,{xColumnNames:w,yColumnNames:w}),T=this.comparisonView.dockManager.dock(I,s.DOCK_TYPE.LEFT,this.tableDockNode,"",v.KN.COR_PLOT);this.openedViewers.push(I);const E=s.Viewer.pcPlot(b,{columnNames:w});this.comparisonView.dockManager.dock(E,s.DOCK_TYPE.DOWN,T,"",v.KN.PC_PLOT),this.openedViewers.push(E);const S=this.getOutputNameForScatterPlot(w,b,d.length),x=1===d.length?s.Viewer.lineChart(b,this.getLineChartOpt(w)):s.Viewer.scatterPlot(b,this.getScatterOpt(w,S));this.openedViewers.push(x),this.comparisonView.dockManager.dock(x,s.DOCK_TYPE.DOWN,this.tableDockNode,"",v.KN.GRAPH)}))}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 I.LAST_ROW:e=-1;break;case I.FIRST_ROW:e=0;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}}}},1521:(t,e,n)=>{"use strict";n.d(e,{PT:()=>y,RP:()=>b,vw:()=>v});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(3061),d=(n(8586),n(7973)),p=n(1599),h=n(810),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)})))())}}const v="ID";class g 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,h.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,p.qg)(t.func))&&void 0!==a?a:[]).map((e=>(0,p.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 y extends g{set value(t){this.setValue(t)}get value(){return this.getValue()}}class b extends g{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("-"):""}}},1599:(t,e,n)=>{"use strict";n.d(e,{$X:()=>ot,A4:()=>Y,BV:()=>S,Fd:()=>J,HP:()=>L,Hs:()=>M,JU:()=>K,KL:()=>j,LL:()=>T,Ne:()=>k,O0:()=>G,QL:()=>q,VI:()=>w,WM:()=>C,_t:()=>X,aB:()=>x,aK:()=>A,hg:()=>z,i:()=>_,jJ:()=>W,qg:()=>$,r6:()=>N,rs:()=>U,sy:()=>I,tf:()=>Z,u8:()=>V,vk:()=>F,wB:()=>nt,x$:()=>B,zF:()=>O});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(1991),u=n.n(l),c=n(4260),d=n(9171),p=n(1899),h=n(3508),f=n.n(h),m=n(1521),v=n(810),g=n(5520),y=n(4778),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=(t,e,n,r)=>b(void 0,void 0,void 0,(function*(){var a,l;const u={},d=(t,e)=>{if(u[t])return u[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 u[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,u=window.html2canvas,p="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8",h=new t.Workbook;o.setDisplay(i.shell.v.root,!1),P(i.shell.v.root.parentElement,!0,"Generating report. Please do not switch the browser tab...");const f=(t,e,n,...r)=>b(void 0,[t,e,n,...r],void 0,(function*(t,e,n,r=0,a){var l,c,d,p;if(!e||!e.dataFrame)return;const f=s.Viewer.fromType(e.type,e.dataFrame.clone());f.copyViewersLook(e);const m=o.div(f.root,{style:{height:`${null!==(l=null==a?void 0:a.heightToRender)&&void 0!==l?l:800}px`,width:`${null!==(c=null==a?void 0:a.widthToRender)&&void 0!==c?c:800}px`}});m.classList.add("ui-box"),m.classList.remove("ui-div"),i.shell.v.root.insertAdjacentElement("afterend",m),yield(0,v.cb)(1e3);const g=(yield u(m)).toDataURL();m.remove();const y=h.addImage({base64:g,extension:"png"}),b=(null==a?void 0:a.heightInCells)||(null==a?void 0:a.widthInCells)?Math.min((null!==(d=null==a?void 0:a.heightInCells)&&void 0!==d?d:Number.MAX_VALUE)/40,(null!==(p=null==a?void 0:a.widthInCells)&&void 0!==p?p:Number.MAX_VALUE)/8):1;t.addImage(y,{tl:{col:n,row:r},ext:{width:800*b,height:800*b}})})),m=t=>s.TYPES_SCALAR.has(t),g=t=>t.propertyType===s.TYPE.DATA_FRAME,y=e.inputs.filter((t=>g(t))),A=e.inputs.filter((t=>m(t.propertyType))),C=e.outputs.filter((t=>g(t))),w=e.outputs.filter((t=>m(t.propertyType)));if(y.forEach((t=>{var e;const i=t.options.caption||t.name,o=null!==(e=h.worksheets.find((t=>t.name===d(i,h))))&&void 0!==e?e:h.addWorksheet(d(i,h)),s=n.inputs[t.name];et(o,s)})),A.length){const t=h.addWorksheet("Input scalars");Q(t,A.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(C.forEach((t=>{var e;const i=t.options.caption||t.name,o=null!==(e=h.worksheets.find((t=>t.name===d(i,h))))&&void 0!==e?e:h.addWorksheet(d(i,h)),s=n.outputs[t.name];et(o,s)})),w.length){const t=h.addWorksheet("Output scalars");Q(t,w.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=>g(t)))){const e=(null!==(a=r[t.name])&&void 0!==a?a:[]).filter((t=>t&&t.type!==s.VIEWER.GRID)).filter((t=>Object.values(c.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 f(h.getWorksheet(d(i,h)),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=>g(t)))){const e=(null!==(l=r[t.name])&&void 0!==l?l:[]).filter((t=>t&&t.type!==s.VIEWER.GRID)).filter((t=>Object.values(c.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))]);et(h.getWorksheet(d(i,h)),r,o.columns.length+2,t>0&&e[t-1]?Math.ceil(e[t-1].root.clientHeight/20)+1:0)}else yield f(h.getWorksheet(d(i,h)),n,o.columns.length+2,t>0?16*t+1:0,{heightInCells:16,heightToRender:600,widthToRender:600})}const I=yield h.xlsx.writeBuffer();return[new Blob([I],{type:p}),h]}catch(t){console.log(t)}finally{o.setDisplay(i.shell.v.root,!0),P(i.shell.v.root.parentElement,!1)}throw new Error("Format is not supported")})),C=(t,e)=>b(void 0,void 0,void 0,(function*(){const n=`${c.Jc}_${t.func.name}_Fav`;return e?i.dapi.userDataStorage.postValue(n,t.id,""):i.dapi.userDataStorage.remove(n,t.id)})),w=(t,e,n,s,r,l,u)=>{t.onCellPrepare((d=>{var p,h,f,g,y,A,C,w,I,T;if(d.isColHeader&&(null===(p=d.tableColumn)||void 0===p?void 0:p.name)&&[c.zY,c.d1,c.iL].includes(d.tableColumn.name)&&(d.customText=""),!d.isColHeader){if((null===(h=d.tableColumn)||void 0===h?void 0:h.name)===c.zY&&(d.customText="",d.element=o.divH([o.iconFA("trash",(()=>s(d)),"Remove run from history"),o.iconFA("edit",(()=>n(d)),"Edit run metadata")],{style:{padding:"6px",gap:"6px",justifyContent:"space-between"}})),(null===(f=d.tableColumn)||void 0===f?void 0:f.name)===c.iL){d.customText="";const t=o.iconFA("star",(()=>l(d)),"Unfavorite");a()(t).addClass("fas"),d.element=o.div(d.cell.value?t:o.iconFA("star",(()=>r(d)),"Favorite"),{style:{padding:"6px"}})}if((null===(g=d.tableColumn)||void 0===g?void 0:g.name)===c.d1){d.customText="";const t=o.iconFA("flask",null,"Experimental run");a()(t).addClass("fad fa-sm"),a()(t).removeClass("fal"),d.element=d.cell.value&&"Experimental"===d.cell.value?o.div(t,{style:{padding:"6px"}}):o.div()}if((null===(y=d.tableColumn)||void 0===y?void 0:y.name)===c.lv){d.customText="";const t=d.cell.value.length>0?o.div(null===(A=d.cell.value)||void 0===A?void 0:A.split(",").map((t=>o.span([t],"d4-tag"))),"d4-tag-editor"):o.div();a()(t).css({padding:"3px","background-color":"transparent"}),d.element=t}if((null===(C=d.tableColumn)||void 0===C?void 0:C.name)===m.vw){d.customText="";const p=(E=d.tableRowIndex,e.get(t.dataFrame.get(m.vw,E)));if(!p)return;const h=p.author.picture;a()(h).css({width:"25px",height:"25px",fontSize:"20px"}),o.bind(p.author,h);const f=o.iconFA("flask",null,"Experimental run");f.classList.add("fad","fa-sm"),f.classList.remove("fal"),f.style.marginLeft="3px";const g=p.options.immutable_tags,y=o.span([o.label(null!==(T=null!==(w=p.options.title)&&void 0!==w?w:null===(I=p.author)||void 0===I?void 0:I.friendlyName)&&void 0!==T?T:i.shell.user.friendlyName,{style:{color:"var(--blue-1)"}}),...g&&g.includes(c.ec)?[f]:[]]),A=o.iconFA("edit",(t=>{t.stopPropagation(),n(d)}),"Edit run metadata");A.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const C=o.iconFA("trash-alt",(t=>b(void 0,void 0,void 0,(function*(){t.stopPropagation(),s(d)}))),"Delete run");C.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const S=o.iconFA("star",(t=>{t.stopPropagation(),l(d)}),"Unfavorite");S.classList.add("fas","hp-funccall-card-icon");const x=o.iconFA("star",(t=>{t.stopPropagation(),r(d)}),"Favorite");x.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon"),(e=>t.dataFrame.get(c.iL,e))(d.tableRowIndex)?(o.setDisplay(x,!1),o.setDisplay(S,!0)):(o.setDisplay(S,!1),o.setDisplay(x,!0));const R=(0,v.eK)(p),O=o.divH([o.divH([h,o.divV([y,o.span([R]),...p.options.tags&&p.options.tags.length>0?[o.div(p.options.tags.map((t=>o.span([t],"d4-tag"))))]:[]],"hp-card-content")]),o.divH([...u?[S,x,A,C]:[]])],"hp-funccall-card"),L=d.tableRowIndex;O.addEventListener("mouseover",(()=>{d.grid.dataFrame.mouseOverRowIdx=L})),O.addEventListener("click",(t=>{t.shiftKey?d.grid.dataFrame.selection.set(L,!0):t.ctrlKey?d.grid.dataFrame.selection.set(L,!1):d.grid.dataFrame.currentRowIdx=L})),d.element=O}var E}}))},I=(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([c.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((t=>{const e=t.columns.byName(c.zY);e&&(e.cellType="html",e.width=45);const n=t.columns.byName(c.iL);n&&(n.cellType="html",n.width=30);const i=t.columns.byName(c.d1);i&&(i.cellType="html",i.width=30);const o=t.columns.byName(c.lv);o&&(o.cellType="html",o.width=90);const s=t.columns.byName(c.bV);s&&(s.width=110);const r=t.columns.byName(m.vw);r&&(r.cellType="html")})(t),e)t.columns.setVisible([m.vw]),t.props.rowHeight=70,t.invalidate();else{t.props.rowHeight=28;const e=t.dataFrame.getCol(c.lv);t.columns.setVisible([c.d1,c.iL,c.zY,...i?[c.bV]:[],...i?[c.l8]:[],...i&&e.stats.missingValueCount<e.length?[c.lv]:[],...i?[c.qh]:[],...i?[c.Ts]:[],...n&&o?U(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:E(i.name):E(t)})):[]])}},T=(t,e,n,i,s)=>{var r,a;const l=t.dataFrame,u=l.getCol(c.lv),d=[...e&&l.getCol(c.d1).categories.length>1?[c.d1]:[],...e&&(null!==(a=null===(r=l.col(c.iL))||void 0===r?void 0:r.categories.length)&&void 0!==a?a:0)>1?[c.iL]:[],...e?[c.bV,c.pC]:[],...e&&l.getCol(c.l8).categories.length>1?[c.l8]:[],...e&&u.stats.missingValueCount<u.length?[c.lv]:[],...e&&l.getCol(c.qh).categories.length>1?[c.qh]:[],...e&&l.getCol(c.Ts).categories.length>1?[c.Ts]:[],...s&&n?U(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:E(i.name):E(t)})).filter((t=>!i||l.getCol(t).categories.length>1)).map((t=>t)):[]];return d.length>0?(o.setDisplay(t.root,!0),t.setOptions({columnNames:d,showHeader:!1,showBoolCombinedFilter:!0})):o.setDisplay(t.root,!1),d.length>0},E=t=>H(t),S=(t,e,n)=>b(void 0,void 0,void 0,(function*(){var o;const r=[...t.values()],a=t=>t===c.bV?s.Column.dateTime(E(t),r.length).init((t=>window.grok_DayJs_To_DateTime(D(r[t])?r[t].started.utc(!0):f().unix(r[t].options.createdOn)))):t===c.pC?s.Column.bool(E(t),r.length).init((t=>!k(r[t]))):s.Column.fromStrings(E(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:V(e,t)}))),l=null!==(o=yield i.dapi.userDataStorage.get((t=>`${c.Jc}_${t.name}_Fav`)(e)))&&void 0!==o?o:{},u=Object.keys(l),d=s.DataFrame.fromColumns([s.Column.string(c.d1,r.length).init((t=>{const e=r[t].options.immutable_tags;return e&&e.includes(c.ec)?"Experimental":"Simulated"})),...(null==n?void 0:n.isHistory)?[s.Column.bool(c.iL,r.length).init((t=>u.includes(r[t].id)))]:[],...(null==n?void 0:n.showActions)?[s.Column.string(c.zY,r.length).init("")]:[],a(c.bV),a(c.pC),a(c.l8),s.Column.string(c.lv,r.length).init((t=>r[t].options.tags?r[t].options.tags.join(","):"")),s.Column.string(c.qh,r.length).init((t=>r[t].options.title)),s.Column.string(c.Ts,r.length).init((t=>r[t].options.description)),s.Column.string(c.aQ,r.length).init((t=>r[t].options.version))]);if(U(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:E(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:E(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:V(r[e],t.name)}))})(o):a(t)})(t))).forEach((t=>{t.name=d.columns.getUnusedName(t.name),d.columns.add(t,!1)})),d.columns.add(s.Column.fromStrings(m.vw,r.map((t=>t.id)))),!(null==n?void 0:n.allowOtherVersions)&&(null==n?void 0:n.version)){const t=s.BitSet.create(d.rowCount,(()=>!1));for(let e=0;e<d.rowCount;e++)(null==n?void 0:n.version)==d.get(c.aQ,e)&&t.set(e,!0);return d.clone(t)}return d})),x=t=>b(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))})),R=new s.LruCache,O=t=>b(void 0,void 0,void 0,(function*(){const e=t.options.help;if(!e)return null;if(R.get(t.id))return R.get(t.id);const n=`System:AppData/${e}`;if(yield i.dapi.files.exists(n)){const e=yield i.dapi.files.readAsText(n);return R.set(t.id,e),e}const o=`${i.shell.user.name}.home/${e}`;if(yield i.dapi.files.exists(o)){const e=yield i.dapi.files.readAsText(o);return R.set(t.id,e),e}return null})),L=t=>!!t.options.help,N=t=>{const e={inputs:{},outputs:{}};return t.inputs.filter((t=>t.propertyType===s.TYPE.DATA_FRAME&&0!==W(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===W(t).config.length||(e.outputs[n]?e.outputs[n].push(t):e.outputs[n]=[t])})),e},P=(t,e,n)=>{o.setUpdateIndicator(t,e);const i=t.querySelector(".d4-update-shadow .ui-label");e&&n&&i&&(i.textContent=n)},M=t=>b(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})),F=t=>"true"===t.options.runOnInput,_=t=>{var e;return JSON.parse(null!==(e=t.options.features)&&void 0!==e?e:"{}")},B=(t,e,n)=>{var i;return t instanceof Array?t.includes(e):t instanceof Object&&null!==(i=t[e])&&void 0!==i?i:n},k=t=>{var e;return(0,g.iu)(null!==(e=t.options[y.fj])&&void 0!==e?e:"false")||!D(t)||!t.id},D=t=>{try{return t.started}catch(t){return null}},V=(t,e)=>{var n,o,s,r,a,l,u;if(e===c.l8)return null!==(o=null===(n=t.author)||void 0===n?void 0:n.friendlyName)&&void 0!==o?o:i.shell.user.friendlyName;const d=null!==(l=null!==(a=null!==(r=null!==(s=t[e])&&void 0!==s?s:t.inputs[e])&&void 0!==r?r:t.outputs[e])&&void 0!==a?a:t.options[e])&&void 0!==l?l:null;return null!==(u=null==d?void 0:d.toString())&&void 0!==u?u:""},$=t=>t.options.mainParams?JSON.parse(t.options.mainParams):null,U=(t,e)=>{var n,i;return null!==(i=null!==(n=null==e?void 0:e.visibleProps)&&void 0!==n?n:$(t))&&void 0!==i?i:t.inputs.filter((t=>c.t6.includes(t.propertyType))).map((t=>t.name))},H=t=>t.replace(/([A-Z])/g,(t=>` ${t.toLowerCase()}`)).trim().replace(/^./,(t=>t.toUpperCase()));function j(t){const e=t;return e.dart&&s.toJs(e.dart)instanceof s.InputBase}const Y=t=>{const e=s.Func.byName(t.func.nqName).prepare();e.id=t.id,t.options.forEach((n=>e.options[n]=t.options[n]));const n=u()(e.outputParams.values()).filter((e=>null!=t.outputs[e.name]));for(const i of n)i.property.propertyType===s.TYPE.DATA_FRAME?e.outputs[i.name]=t.outputs[i.name].clone():e.outputs[i.name]=t.outputs[i.name];const i=u()(e.inputParams.values()).filter((e=>null!=t.inputs[e.name]));for(const n of i)n.property.propertyType===s.TYPE.DATA_FRAME?e.inputs[n.name]=t.inputs[n.name].clone():e.inputs[n.name]=t.inputs[n.name];return D(t)&&(e.started=t.started),e},W=t=>{const e=t.options[c.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 c.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:[]}},G=t=>t.options.runLabel,K=t=>{if((0,d.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")}},z=(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"})},q=(t,...e)=>b(void 0,[t,...e],void 0,(function*(t,e=c.bZ.INPUTS){const n=[...t[c.wl[e]].values()];return(yield Promise.all(n.filter((t=>!!t.property.options.validatorFunc)).map((t=>b(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)),{})})),J=(t,e)=>{const n=(0,p.JC)(e);return t[0].replaceWith(n[0]),t[1].replaceWith(n[1]),n},Z=(t,e,n,i,o,s)=>b(void 0,void 0,void 0,(function*(){const{view:r,funcCall:a,lastCall:l}=o,u=yield Promise.all(e.map((e=>b(void 0,void 0,void 0,(function*(){const o=i===c.bZ.INPUTS?a.inputs[e]:a.outputs[e],u=yield(0,p.Td)(o,{param:e,funcCall:a,lastCall:l,signal:n,isNewOutput:!!t.isNewOutput,isRevalidation:t.isRevalidation,view:r});let d;const h=s[e];h&&(d=yield h(o,{param:e,funcCall:a,lastCall:l,signal:n,isNewOutput:!!t.isNewOutput,isRevalidation:t.isRevalidation,context:t.context,view:r}));const f=i===c.bZ.INPUTS&&a.inputParams[e].property.options.nullable;return[e,(0,p.uD)(...f?[]:[u],d)]})))));return Object.fromEntries(u)})),X=t=>{const e=o.element("i");t.addOptions(e),t.setValidation=function(n){for(;e.firstChild&&e.removeChild(e.firstChild););const[i,o]=(0,p.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")}},Q=(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)};let tt=0;const et=(t,e,n,i)=>{if(!e)return;const o=t.getColumn(null!=n?n:1).letter,s={name:`ID_${tt.toString()}`,ref:`${o}${null!=i?i:1}`,columns:e.columns.toList().map((t=>({name:t.name,filterButton:!1}))),rows:new Array(e.rowCount).fill(0).map(((t,n)=>[...e.row(n).cells].map((t=>t.value))))};t.addTable(s),t.columns.forEach((t=>{t.width=25,t.alignment={wrapText:!0}})),tt++};function nt(t,e){return b(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 it(t,o,e)}return{inputs:n,outputs:t.outputs}}))}function it(t,e,n){return b(this,void 0,void 0,(function*(){return"file"===t.propertyType&&n.getInput?n.getInput(t.name).value.arrayBuffer():e}))}function ot(t,e){return b(this,void 0,void 0,(function*(){return"file"===t?new File([e],""):e}))}},1661:(t,e,n)=>{"use strict";n.d(e,{A:()=>i});const i={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)}},1757:t=>{"use strict";t.exports=$},1813:(t,e,n)=>{"use strict";n.d(e,{H:()=>o});var i=n(6067);class o{constructor(t){this.ivp=t,this.outputNames=(0,i.A)(t)}}},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.");t+="==".slice(2-(3&t.length));let e,n,i,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++)]),o+=64===n?a(e>>16&255):64===i?a(e>>16&255,e>>8&255):a(e>>16&255,e>>8&255,255&e);return o},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},1899:(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}},1927:(t,e,n)=>{"use strict";n(1294),n(3209),n(567),n(5669),n(5271)},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)}}}},2284:(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(9911),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},2610:(t,e,n)=>{"use strict";n.d(e,{b:()=>h,c:()=>f});var i=n(4328),o=n(32),s=n(4350),r=n(9713),a=n(1858),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())}))};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`)}))}},2797:(t,e,n)=>{"use strict";var i;n.d(e,{A:()=>s});var o=new Uint8Array(16);function s(){if(!i&&!(i="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(o)}},2947:(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"]}},2991:(t,e,n)=>{"use strict";Error},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}","",{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",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}"],sourceRoot:""}]);const a=r},3014:(t,e,n)=>{"use strict";n(8387),n(6950)},3031:(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(6362),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},3061:(t,e,n)=>{"use strict";n.d(e,{W:()=>i.W});var i=n(5092)},3209:(t,e,n)=>{"use strict";n(5669)},3296:(t,e,n)=>{"use strict";n(6082),n(1858)},3313:(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]])},3398:(t,e,n)=>{"use strict";n.d(e,{I3:()=>s.I3,a8:()=>s.a8,ak:()=>i.a,jd:()=>s.jd,lp:()=>s.lp,sg:()=>o.s,v_:()=>s.v_});var i=n(9524),o=n(9939),s=n(392)},3501:(t,e,n)=>{"use strict";n.d(e,{v:()=>p});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=n(1599),l=n(3061),u=n(9713),c=n(8804),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 p 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 d(this,void 0,void 0,(function*(){}))}onAfterSaveRun(t){return d(this,void 0,void 0,(function*(){}))}init(){return d(this,void 0,void 0,(function*(){const t=this.getStartId();if(t){this.setAsLoaded();const e=yield l.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 d(this,void 0,void 0,(function*(){yield this.getPackageData(),this.build()}))}saveRun(t){return d(this,void 0,void 0,(function*(){const e=(0,a.A4)(t);yield this.onBeforeSaveRun(e),e.id&&e.newId();const n=yield l.W.saveRun(e),i=yield l.W.loadRun(n.id);return this.linkFunccall(i),yield this.onAfterSaveRun(i),i}))}saveRunWithDialog(t){return d(this,void 0,void 0,(function*(){const e=c.V.forFuncCall(t);e.onMetadataEdit.pipe((0,u.take)(1)).subscribe((e=>d(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 d(this,void 0,void 0,(function*(){const e=yield l.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 d(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 d(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=()=>d(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=()=>d(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},3703:(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},3793:(t,e,n)=>{"use strict";n.d(e,{A:()=>i});var i,o=n(7745),s=n(1521),r=n(7747);!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={}))},3902:(t,e,n)=>{"use strict";n.d(e,{v:()=>x});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(5342),m=n(241),v=n(7722),g=n(1159),y=n(7320),b=n(4098),A=n(7591),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=s.Color.categoricalPalette,I=w.length,T=[s.TYPE.INT,s.TYPE.BIG_INT,s.TYPE.FLOAT,s.TYPE.DATA_FRAME];function E(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 S=()=>o.div([],"sa-switch-input");class x{static fromEmpty(t){return C(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.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?"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,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(S(),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=S(),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=>T.includes(t.propertyType))).reduce(((t,e)=>{const r=t=>{const e=E(a);return e.isValid?(a.argColInput.input.classList.remove("d4-invalid"),a.funcColsInput.input.classList.remove("d4-invalid"),o.tooltip.bind(a.argColInput.input,"Independent variable"),o.tooltip.bind(a.funcColsInput.input,"Target dependent variables"),null):(a.argColInput.input.classList.add("d4-invalid"),a.funcColsInput.input.classList.add("d4-invalid"),o.tooltip.bind(a.argColInput.input,e.msg),o.tooltip.bind(a.funcColsInput.input,e.msg),e.msg)},a={prop:e,input:(()=>{var t,r,l;const u=null!==(t=e.caption)&&void 0!==t?t:e.name,c=o.input.forProperty(e);c.addCaption(u),c.value=e.propertyType===s.TYPE.DATA_FRAME?null:0,c.setTooltip(e.propertyType===s.TYPE.DATA_FRAME?"Target dataframe":"Target scalar"),c.input.hidden=!this.toSetSwitched,c.nullable=!1,o.tooltip.bind(c.captionLabel,e.propertyType===s.TYPE.DATA_FRAME?"Dataframe":"Scalar"),null!=(null===(l=null===(r=this.options.targets)||void 0===r?void 0:r[e.name])||void 0===l?void 0:l.default)&&setTimeout((()=>{var t,n;return c.value=null===(n=null===(t=this.options.targets)||void 0===t?void 0:t[e.name])||void 0===n?void 0:n.default}),0),c.onChanged.subscribe((t=>{a.target=c.value;const n=()=>{a.argColInput.items=[null],a.argColInput.value=null,o.input.setColumnsInputTable(a.funcColsInput,i.data.demo.randomWalk(2,2),(t=>!1))};if(null===c.value)n();else if(e.propertyType===s.TYPE.DATA_FRAME)if(a.target){const t=[],e=[];for(const n of c.value.columns)n.isNumerical&&(t.push(n.name),e.push(n));t.length>1?(a.argColInput.items=t,a.argColInput.value=t[0],o.input.setColumnsInputTable(a.funcColsInput,c.value,(t=>t.isNumerical)),a.funcColsInput.value=e.slice(1)):(i.shell.warning(`Not enough of numerical columns: ${t.length}, expected: > 1`),n())}else n();this.updateApplicabilityState()})),e.propertyType===s.TYPE.DATA_FRAME&&(c.root.lastElementChild.hidden=!this.toSetSwitched);const d=n(this.toSetSwitched,(t=>{a.isInterest.next(t),this.updateApplicabilityState(),c.input.hidden=!t,e.propertyType===s.TYPE.DATA_FRAME&&(c.root.lastElementChild.hidden=!t,a.argColInput.root.hidden=!t,a.funcColsInput.root.hidden=!t)}),!1).root;return c.root.insertBefore(d,c.captionLabel),c})(),argName:"_",argColInput:(()=>{const t=o.input.choice("argument",{value:null,items:[null],tooltipText:"Independent variable",onValueChanged:t=>{a.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.root.hidden=e.propertyType!==s.TYPE.DATA_FRAME||!this.toSetSwitched,t.nullable=!1,t.addValidator(r),t})(),isInterest:new l.BehaviorSubject(this.toSetSwitched),target:e.propertyType!==s.TYPE.DATA_FRAME?0:null,funcColsInput:(()=>{const t=o.input.columns("functions",{nullable:!1,tooltipText:"Target dependent variables",onValueChanged:t=>this.updateApplicabilityState()});return t.root.insertBefore(S(),t.captionLabel),t.root.hidden=e.propertyType!==s.TYPE.DATA_FRAME||!this.toSetSwitched,this.toSetSwitched=!1,o.tooltip.bind(t.captionLabel,"Columns with values of target dependent variables:"),t.addValidator(r),t})()};return t[e.name]=a,t}),{})}},this.readyToRun=!1,this.isFittingRunning=!1,this.runIcon=o.iconFA("play",(()=>C(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",(()=>C(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.helpIcon=(0,v.VW)(),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.toSetSwitched=!0,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.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.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();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} - Fitting`,.25),this.comparisonView.grid.columns.byName("Run name").visible=!1,m.bj.forEach(((t,e)=>this.nelderMeadSettings.set(e,t.default)));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 minimizing the loss function"),this.lossInput.setTooltip(h.FM.get(this.loss)),o.tooltip.bind(this.lossInput.captionLabel,"Loss function type"),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 points to be found"),this.similarityInput.onChanged.subscribe((t=>{this.similarity=t,this.updateApplicabilityState()})),this.similarityInput.addCaption(h.ly.SIMILARITY),this.similarityInput.setTooltip("The higher the value, the fewer points will be found"),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}isOptimizationApplicable(t){for(const n of t.outputs)if((e=n).propertyType===s.TYPE.INT||e.propertyType===s.TYPE.FLOAT||e.propertyType===s.TYPE.DATA_FRAME)return!0;var e;return!1}generateNelderMeadSettingsInputs(){const t=[];m.bj.forEach(((e,n)=>{const i=o.input.forProperty(s.Property.fromOptions({name:m.df.get(n),inputType:"maxIter"!==n?"Float":"Int",defaultValue:e.default,min:e.min,max:e.max}));i.addCaption(m.df.get(n)),i.nullable=!1,i.onChanged.subscribe((t=>{this.nelderMeadSettings.set(n,t),this.updateApplicabilityState()})),t.push(i)})),this.settingsInputs.set(h.Mx.NELDER_MEAD,t)}areNelderMeadSettingsCorrect(){for(const[t,e]of this.nelderMeadSettings)if(null==e||e>m.bj.get(t).max||e<m.bj.get(t).min)return this.updateRunIconDisabledTooltip(`Invalid "${t}": check method settings`),!1;return!0}generateGradDescentSettingsInputs(){const t=o.input.forProperty(s.Property.fromOptions({name:"iterations",inputType:"Int",defaultValue:this.gradDescentSettings.iterCount,min:1,max:1e4}));t.onChanged.subscribe((t=>this.gradDescentSettings.iterCount=t));const e=o.input.forProperty(s.Property.fromOptions({name:"Learning rate",inputType:"Float",defaultValue:this.gradDescentSettings.learningRate,min:1e-6,max:1e3}));e.onChanged.subscribe((t=>this.gradDescentSettings.learningRate=t)),this.settingsInputs.set(h.Mx.GRAD_DESC,[t,e])}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 C(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,g.c)(t,e);return null!==n&&n.input.root.insertBefore(S(),n.input.captionLabel),n}))}buildForm(t){return C(this,void 0,void 0,(function*(){const e=o.h1(h.ly.FIT);o.tooltip.bind(e,"Select inputs to be fitted");const n=new Map([["Misc",[]]]);Object.values(this.store.inputs).forEach((t=>{const e=t.prop.category,i=[...t.constForm.map((t=>t.root)),...t.saForm.map((t=>t.root))];n.has(e)?n.get(e).push(...i):n.set(e,i)}));const i=o.div([e],{style:{overflowY:"scroll",width:"100%"}}),s=yield this.getLookupElement(t);let r=null;if(null!==s){const t=n.get(s.category);r=s.category,void 0!==t?n.set(r,[s.input.root].concat(t)):n.set(r,[s.input.root])}if(n.size>1){if(null!==r){const t=n.get(r);i.append((0,v.FB)(r,t)),i.append(...t)}if(n.forEach(((t,e)=>{"Misc"!==e&&e!==r&&(i.append((0,v.FB)(e,t)),i.append(...t))})),"Misc"!==r&&n.get("Misc").length>0){const t=n.get("Misc");i.append((0,v.FB)("Misc",t)),i.append(...t)}}else i.append(...n.get("Misc"));const l=o.h1(h.ly.TARGET);o.tooltip.bind(l,"Select target outputs"),i.appendChild(l);let u="Misc";Object.values(this.store.outputs).reduce(((t,e)=>{var n;const i=e.prop;return i.category!==u&&(t.append(o.h3(i.category)),u=i.category),t.append(e.input.root),e.argColInput.root.insertBefore((0,v.gw)(e.input.root,null!==(n=e.prop.caption)&&void 0!==n?n:e.prop.name),e.argColInput.captionLabel),t.append(e.argColInput.root),t.append(e.funcColsInput.root),t}),i);let c=!1;for(const t of Object.keys(this.store.outputs))if(!0===this.store.outputs[t].isInterest.value){c=!0;break}c||this.store.outputs[Object.keys(this.store.outputs)[0]].isInterest.next(!0);const d=o.h1("Using");o.tooltip.bind(d,"Specify fitting method"),i.appendChild(d),this.methodInput.root.insertBefore(this.fittingSettingsIcon,this.methodInput.captionLabel),this.fittingSettingsIcon.style.minWidth="50px",i.appendChild(this.methodInput.root);const p=o.h2("with settings");return o.tooltip.bind(p,(()=>`Settings of the ${this.method} method`)),this.fittingSettingsDiv.appendChild(p),this.generateSettingInputs(),this.showHideSettingInputs(),i.appendChild(this.fittingSettingsDiv),this.settingsInputs.forEach((t=>t.forEach((t=>{t.root.insertBefore(S(),t.captionLabel),this.fittingSettingsDiv.append(t.root)})))),[this.lossInput,this.samplesCountInput,this.similarityInput].forEach((t=>{t.root.insertBefore(S(),t.captionLabel),t.nullable=!1,i.appendChild(t.root)})),a()(i).addClass("ui-form"),this.updateApplicabilityState(),a()(i).css({"padding-left":"12px","overflow-y":"scroll","padding-right":"4px",position:"relative","z-index":"2","background-color":"white"}),i}))}updateRunIconDisabledTooltip(t){o.tooltip.bind(this.runIcon,(()=>{const e=o.label(t);return e.style.color="#FF0000",e}))}updateApplicabilityState(){this.readyToRun=this.canFittingBeRun()&&!this.isFittingRunning,this.updateRunIconStyle()}updateRunIconStyle(){this.readyToRun?(this.runIcon.style.color="var(--green-2)",o.tooltip.bind(this.runIcon,"Run fitting")):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 parameters for fitting selected"),n&&i}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=E(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))}runOptimization(){return C(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 Float32Array(r),c=new Float32Array(r),d=new Array(r);n.forEach(((t,e)=>{var n,i,o;const s=this.store.inputs[t];u[e]=null!==(n=s.min.value)&&void 0!==n?n:0,c[e]=null!==(i=s.max.value)&&void 0!==i?i:0,l.push(t),d[e]=null!==(o=s.prop.caption)&&void 0!==o?o:s.prop.name}));const m=this.getOutputsOfInterest();if(m.length<1)return void i.shell.error("No output is selected for optimization.");const g=m.map((t=>t.prop.propertyType)).filter((t=>t===s.TYPE.DATA_FRAME)).length>1,w=e=>C(this,void 0,void 0,(function*(){e.forEach(((e,n)=>t[l[n]]=e));const n=this.func.prepare(t);return yield n.call()})),I=e=>C(this,void 0,void 0,(function*(){e.forEach(((e,n)=>t[l[n]]=e));const n=this.func.prepare(t),i=yield n.call();let o=0,r=0,a=0;return m.forEach((t=>{if(t.prop.propertyType!==s.TYPE.DATA_FRAME)a=t.target,o+=Math.pow((a-i.getParamValue(t.prop.name))/(0!==a?a:1),2),++r;else{const e=t.target;(0,v.Yl)(e.col(t.argName),t.funcColsInput.value,i.getParamValue(t.prop.name),!0).forEach((t=>{o+=Math.pow(t,2),++r}))}})),Math.sqrt(o/r)})),T=e=>C(this,void 0,void 0,(function*(){e.forEach(((e,n)=>t[l[n]]=e));const n=this.func.prepare(t),i=yield n.call();let o=0;return m.forEach((t=>{if(t.prop.propertyType!==s.TYPE.DATA_FRAME)o=Math.max(o,Math.abs(t.target-i.getParamValue(t.prop.name)));else{const e=t.target;(0,v.Yl)(e.col(t.argName),t.funcColsInput.value,i.getParamValue(t.prop.name),!1).forEach((t=>o=Math.max(o,Math.abs(t))))}})),o}));let E,S,x;if(this.loss===h.YI.MAD?(E=T,S="scaled maximum absolute deviation"):(E=I,S="scaled root mean square error"),this.method!==h.Mx.NELDER_MEAD)throw new Error(`Not implemented the '${this.method}' method`);if(void 0!==this.diffGrok)try{const e=h.Wr.DIFF_STUDIO_OUTPUT;x=yield(0,y.t)(this.loss,this.diffGrok.ivp,this.diffGrok.ivpWW,this.diffGrok.pipelineCreator,this.nelderMeadSettings,l,u,c,t,m[e].argName,m[e].funcColsInput.value,m[e].target,this.samplesCount)}catch(t){x=yield(0,f.S)(E,u,c,this.nelderMeadSettings,this.samplesCount)}else x=yield(0,f.S)(E,u,c,this.nelderMeadSettings,this.samplesCount);const R=x.extremums,O=R.length;if(O<this.samplesCount){this.failsDF=x.fails;const t=this.failsDF.columns;d.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)))}))}R.sort(((t,e)=>t.cost-e.cost));const L=m.filter((t=>t.prop.propertyType===s.TYPE.DATA_FRAME)).map((t=>({name:t.prop.name,target:t.target,argColName:t.argName}))),N=yield(0,b.R9)(R,this.similarity,w,L),P=N.length;if(O<this.samplesCount){if(O<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 ${P} point${P>1?"s":""}`),o.div([this.showFailsBtn])]))}else i.shell.info(`Found ${P} point${P>1?"s":""}`);this.clearPrev();const M=new Float32Array(P),F=this.comparisonView.grid,_=new Map([[h.ly.LOSS,`The final loss obtained: ${S}`]]);N.forEach(((t,e)=>M[e]=t.cost));const B=s.DataFrame.fromColumns([s.Column.fromFloat32Array(h.ly.LOSS,M)]);this.comparisonView.dataFrame=B;const k=B.columns;d.forEach(((t,e,n)=>{t=k.getUnusedName(t),n[e]=t;const i=new Float32Array(P);for(let t=0;t<P;++t)i[t]=N[t].point[e];k.add(s.Column.fromFloat32Array(t,i)),_.set(t,`Obtained values of '${t}'`)})),F.props.rowHeight=h.VF.ROW_HEIGHT,F.props.showAddNewRowIcon=!1,F.props.allowEdit=!1;const D=new Array(P);for(let t=0;t<P;++t){const e=new Map,n=[],i=yield w(N[t].point);if(m.forEach((t=>{this.getOutputGofTable(t.prop,t.target,i,t.argName,g).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)}D[t]=e}D[0].forEach(((t,e)=>{k.addNew(e,s.COLUMN_TYPE.DATA_FRAME).init((t=>D[t].get(e).table)),_.set(e,"Goodness of fit");const n=F.columns.byName(e);n.cellType="html",n.width=h.VF.LOSS_GRAPH_WIDTH}));const V=k.getUnusedName(`${this.loss} by iterations`);_.set(V,`Minimizing ${S}`),k.addNew(V,s.COLUMN_TYPE.DATA_FRAME).init((t=>(0,v.e_)(N[t])));const $=F.columns.byName(V);$.cellType="html",$.width=h.VF.LOSS_GRAPH_WIDTH;let U=!1;D[0].forEach((t=>U||(U=t.table.columns.length>=h.Uk)));let H=!0;F.onCellPrepare((t=>C(this,void 0,void 0,(function*(){if(H&&(F.columns.setOrder(k.names().filter((t=>t!==V)).concat([V])),H=!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<P){const n=D[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(U){const e=o.divV([],{style:{height:`${h.VF.ROW_HEIGHT}px`}});o.tooltip.bind(e,(()=>(0,v.QR)())),t.style.element=e,setTimeout((()=>C(this,void 0,void 0,(function*(){const n=new A.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,v.uM)(t.cell.value)}})))),F.columns.byName(h.ly.LOSS).format="scientific",F.columns.byName(h.ly.LOSS).width=h.VF.LOSS_COL_WIDTH,F.onCellTooltip((function(t,e,n){if(t.isColHeader&&t.tableColumn){const i=t.tableColumn.name;if(i===h.o_.SCALARS&&U)o.tooltip.show((0,v.QR)(),e,n);else{const t=_.get(i);o.tooltip.show(null!=t?t:"",e,n)}return!0}})),B.currentCell=B.cell(0,h.ly.LOSS);const j=t=>C(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 w(N[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,p.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=F.onCellClick.subscribe(j),this.gridCellChangeSubscription=F.onCurrentCellChanged.subscribe(j)}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,m=r.clone(null,f.names());m.append(s.DataFrame.fromColumns(f.toList().map((t=>{const e=m.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=m.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=>{m.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);m.columns.add(s.Column.fromInt32Array(h.o_.SIZE,A));const C=r.columns.names().filter((t=>t!==i));return g.forEach((e=>{const n=`${h.o_.CATEGORY}_${e}`,r=m.col(n),a=C.indexOf(e)%I,l=w[a],c=s.Color.toRgb(l);r.colors.setCategorical({Simulation:l,Target:C.length>1?(0,v.ru)(c,h.SK.LIGHTER_PERC):w[a+1]}),t.push({caption:o?`${u}: [${e}]`:`[${e}]`,table:m,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;return s.Column.fromFloat32Array(null!==(e=m.df.get(t[0]))&&void 0!==e?e:t[0],new Float32Array([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:()=>r});var i=n(9070),o=n(7149),s=n(500);class r{constructor(t,e,n,s,r){(0,o.C)(r),this.func=t;const a=(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:a[t]}))),this.funcCalls=[];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);this.funcCalls.push(t.prepare(i))}this.outputsOfInterest=s}perform(){return t=this,e=void 0,i=function*(){this.funcCalls=yield(0,o.X)(this.funcCalls);const t=this.variedInputs.map((t=>t.column)),e=(0,s.ex)(this.funcCalls,this.outputsOfInterest).columns.toList(),n=(0,s.No)(t,e);return n.name=`Sensitivity Analysis of ${this.func.friendlyName}`,{funcEvalResults:n,funcCalls:this.funcCalls}},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}}},4044:(t,e,n)=>{"use strict";n.d(e,{AK:()=>i.AK,S3:()=>i.S3}),n(1927),n(9865),n(9421),n(3014);var i=n(8948)},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)}}}()},4204:(t,e,n)=>{"use strict";var i;n.d(e,{FM:()=>r,L7:()=>y,Mx:()=>i,Q9:()=>c,SK:()=>v,TR:()=>h,Uk:()=>b,VF:()=>a,Wr:()=>f,YI:()=>s,be:()=>p,fo:()=>d,h$:()=>o,ly:()=>l,nW:()=>g,o_:()=>m}),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"],[s.RMSE,"Root mean square error"]]);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="samples",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="`samples`",t.LOSS="`loss`",t.SIMILARITY="`similarity`"}(u||(u={})),function(t){t[t.MS_TO_SLEEP=10]="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. Specify the loss function type (in the ${u.LOSS} field).\n\n5. Enter the number of points to be found (in the ${u.SAMPLES} field).\n\n6. Set the maximum relative deviation (%) in the ${u.SIMILARITY} field. It defines the threshold for determining whether fitted points are similar.\n\n7. 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\n8. Open ${u.CONTEXT}. You will get the function run corresponding to the selected grid row.\n\n9. 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},4260:(t,e,n)=>{"use strict";n.d(e,{AY:()=>u,CB:()=>o,D:()=>v,Jc:()=>b,Jl:()=>c,L_:()=>m,NT:()=>l,Ts:()=>x,_W:()=>h,aQ:()=>O,bV:()=>E,bZ:()=>g,d1:()=>A,eP:()=>r,eX:()=>f,ec:()=>p,iL:()=>C,l8:()=>T,lv:()=>R,pC:()=>w,qh:()=>S,r0:()=>a,sk:()=>s,t6:()=>L,wl:()=>y,zY:()=>I});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="restrictedValues",c="editState";var d;!function(t){t.INPUT="Input",t.OUTPUT="Output"}(d||(d={}));const p="experimental",h="Run name",f="RunId";var m,v,g;!function(t){t.HIDDEN="hidden",t.VISIBLE="visible"}(m||(m={})),function(t){t.ENABLED="enabled",t.DISABLED="disabled"}(v||(v={})),function(t){t.INPUTS="inputs",t.OUTPUTS="outputs"}(g||(g={}));const y={[g.INPUTS]:"inputParams",[g.OUTPUTS]:"outputParams"},b="ModelStorage",A="Source",C="Is favorite",w="Is complete",I="Delete",T="Author",E="Date",S="Title",x="Desc.",R="Tags",O="Version",L=Object.values(i.COLUMN_TYPE).filter((t=>t!==i.TYPE.DATA_FRAME))},4328:t=>{"use strict";t.exports=grok},4350:(t,e,n)=>{"use strict";n.d(e,{SJ:()=>r});var i=n(6082);const o=[{name:"NaN",predicate:function(t,e){return Number.isNaN(t)&&Number.isNaN(e)},checker:a},{name:"Null",predicate:function(t,e){return null==t&&null==e},checker:a},{name:"Boolean",predicate:function(t,e){return"boolean"==typeof t&&"boolean"==typeof e},checker:l},{name:"String",predicate:function(t,e){return"string"==typeof t&&"string"==typeof e},checker:l},{name:"Integer",predicate:function(t,e){return Number.isInteger(t)&&Number.isInteger(e)},checker:l},{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=[];if(t.size!==e.size){const n={msg:`Maps are of different size: actual map size is ${t.size} and expected map size is ${e.size}`};o.push(n)}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 u(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:u},{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)}for(const n of e.columns){const s=t.columns.byName(n.name);if(s)if(s.type===n.type)for(let t=0;t<e.rowCount;t++){const e=s.get(t),o=n.get(t);i([n.name,String(t)],e,o)}else{const t={msg:`Column ${n.name} type expected ${n.type} got ${s.type}`};o.push(t)}else{const t={msg:`Column ${n.name} not found`};o.push(t)}}return o}},{name:"Object",predicate:function(t,e){return"object"==typeof t&&"object"==typeof e},checker:function(t,e,n,i){for(const[n,o]of Object.entries(e))i([n],t[n],o);return[]}}];class s extends Error{}function r(t,e,n){new d(n).run(t,e)}function a(){}function l(t,e){if(t!==e)return[{msg:`Expected ${e}, got ${t}`}]}function u(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}const c={floatTolerance:.001,maxErrorsReport:5,maxDepth:128,checkersSeq:o,prefix:""};class d{constructor(t={}){this.options=Object.assign(Object.assign({},c),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 s(`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 s(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")}}},4451:(t,e,n)=>{"use strict";n.d(e,{s:()=>T});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(3061),p=n(3793),h=n(4260),f=n(1599),m=n(8476),v=n(9713),g=n(5520),y=n(7745),b=n(2610),A=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())}))};const w=new URL(i.shell.startUri),I=()=>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 T 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,A.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:w.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===h.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);yield t.prepare({params:{defaultView:r}}).call()}}))}onSaveClick(){return C(this,void 0,void 0,(function*(){yield this.saveRun(this.funcCall)}))}buildHistoryBlock(){const t=p.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,A.ZD)(t.root,!0);const n=yield Promise.all(e.map((t=>d.W.loadRun(t))));yield this.onComparisonLaunch(n),(0,A.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,A.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,f.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,v.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",I),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,f.A4)(t);yield this.onBeforeSaveRun(e),(0,f.Ne)(e)&&(e=yield(0,f.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,f.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,f.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,f.wB)(this._lastCall,this);return(0,g.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 y.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,g.iu)(yield e.value.text());t?(yield this.executeTest(i,!0),yield this.isHistorical.pipe((0,v.filter)((t=>t)),(0,v.take)(1),(0,v.delay)(0)).toPromise(),yield this.getRunJSON()):yield this.executeTest(i)}))}executeTest(t){return C(this,arguments,void 0,(function*(t,e=!1){yield(0,b.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,f.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,f.HP)(this.func)}getContextHelp(){return C(this,void 0,void 0,(function*(){return(0,f.zF)(this.func)}))}get features(){return(0,f.i)(this.func)}getFeature(t,e){return(0,f.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)}}},4594:(t,e,n)=>{"use strict";n.d(e,{h:()=>s});var i=n(7149);class o{constructor(t=1,e=1){(0,i.C)(t),(0,i.C)(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()}},4778:(t,e,n)=>{"use strict";n.d(e,{fj:()=>i}),n(6082),n(3061),n(9046),n(5520),n(1599);const i="OUTPUT_OUTDATED"},4822:(t,e,n)=>{"use strict";n.d(e,{H:()=>o});var i=n(4451);class o extends i.s{}},4980:(t,e,n)=>{"use strict";n(6067),n(1813).H},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]));return 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)}))))),yield i.dapi.functions.calls.allPackageVersions().save(l)}))},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={}))},5104:(t,e,n)=>{"use strict";n.d(e,{E:()=>R});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(3793),m=n(1899),v=n(1599),g=n(4260),y=n(9171),b=(n(3031),n(4451)),A=n(1491),C=n(3902),w=n(810),I=n(3061),T=n(7973),E=n(7722),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())}))};const x=()=>o.divText("[No data to display]",{style:{"text-align":"center","align-content":"center",width:"100%",height:"100%"}});class R extends b.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=>S(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,v.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 S(this,void 0,void 0,(function*(){yield this.loadInputsOverrides(),yield this.loadValidators(g.bZ.INPUTS),yield this.loadValidators(g.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===g.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===g.bZ.INPUTS?this.setInputValidationResults(n):this.setOutputValidationResults(n),this.runRevalidations(e,n,t),t===g.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(g.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(g.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,v.O0)(this.func))&&void 0!==e?e:t,(()=>S(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 S(this,void 0,void 0,(function*(){const t=[...this.funcCall.inputParams.values()];yield Promise.all(t.map((t=>S(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 S(this,arguments,void 0,(function*(t=g.bZ.INPUTS){const e=yield(0,v.QL)(this.funcCall,t);t===g.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,(()=>S(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 S(this,void 0,void 0,(function*(){const t=()=>{const t=s.Dialog.create({title:"Select to compare"}),e=new T.H(u.length>0?u:[...this.historyBlock.history.values()],{fallbackText:"No historical runs found",showActions:!(u.length>0),showBatchActions:!(u.length>0)}),n=new T.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,(()=>S(this,void 0,void 0,(function*(){const i=yield Promise.all([...e.selected].map((t=>I.W.loadRun(t.id))));this.onComparisonLaunch([...i,...n.selected.values()]),t.close()})))):t.addButton(i,(()=>S(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(y,(()=>S(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 m="Save to history",y="Compare w/ current";c.add(r.root),c.addButton(m,(()=>S(this,void 0,void 0,(function*(){return(0,w.ZD)(c.root,!0),l.forEach((t=>{t.options.immutable_tags?t.options.immutable_tags.push(g.ec):t.options.immutable_tags=[g.ec]})),Promise.all(l.map((t=>S(this,void 0,void 0,(function*(){const e=yield this.getValidExpRun(t);return I.W.saveRun(e)}))))).then((t=>Promise.all(t.map((t=>I.W.loadRun(t.id)))))).then((t=>{t.forEach((t=>this.historyBlock.addRun(t)))})).catch((t=>{i.shell.error(t)})).finally((()=>{(0,w.ZD)(c.root,!1),c.close();const t=new T.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(g.ec):t.options.immutable_tags=[g.ec]}));const t=new T.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(m).disabled=!0,c.getButton("Next").disabled=!0,d()(f.getButton("CANCEL")).hide(),f.addButton("Simulate w/ same inputs",(()=>{(0,w.ZD)(c.root,!0),Promise.all(l.map((t=>S(this,void 0,void 0,(function*(){return(yield(0,v.Hs)(t)).call()}))))).then((e=>{u=e,f.close(),t().show({modal:!0,fullScreen:!0})})).catch((t=>{i.shell.error(t)})).finally((()=>{(0,w.ZD)(c.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,c.getButton(m).disabled=!1,c.getButton("Next").disabled=!1})),A=c.onClose.subscribe((()=>{this.isUploadMode.next(!1)}));c.subs.push(A,b),c.show({modal:!0,center:!0,resizable:!0})}))}onSaveClick(){return S(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",(()=>S(this,void 0,void 0,(function*(){return yield this.doRun()}))),"Run computations");t.classList.add("fas");const e=o.iconFA("arrow-to-top",(()=>S(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,E.LC)();n.onclick=()=>S(this,void 0,void 0,(function*(){return yield this.onSALaunch()}));const s=(0,E.MP)();s.onclick=()=>S(this,void 0,void 0,(function*(){return yield this.onFittingLaunch()}));const r=o.iconFA("info",(()=>S(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())))})))),a=[[...super.buildRibbonPanels().flat(),...this.runningOnInput||this.options.isTabbed?[]:[t],...this.hasUploadMode?[e]:[],...this.isFittingEnabled?[s]:[],...this.isSaEnabled?[n]:[],...!this.options.isTabbed&&this.hasContextHelp?[r]:[]]];return this.setRibbonPanels(a),a}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,v.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)=>S(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(g.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=x();return 0===u.rowCount&&"demog 0"===u.name&&(o.setDisplay(d.root,!1),o.setDisplay(p,!0)),{viewer:d,stub:p}})))),f=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((()=>S(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(g.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}})))),v=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=v,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=f.map(((t,n)=>{const i=l[r][n].block,s=o.wait((()=>S(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,m.JC)();return this.outputValidationSigns[e.name]=a,o.divV([o.divH([o.h2(0===n?v:" ",{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=x();i.classList.add("grok-scripting-image-container");const s=o.divV([o.h2(v,{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,m.JC)();this.outputValidationSigns[t.name]=e}));const f=()=>{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 y=f();const b=(0,p.merge)(this.funcCallReplaced,this.isRunning.pipe((0,h.filter)((t=>!1===t)),(0,h.skip)(1))).subscribe((()=>{const e=f();y.replaceWith(e),y=e,d()(this.tabsElem.getPane(t).header).show()}));this.subs.push(b),this.tabsElem.addPane(t,(()=>o.divV([...r.length?[c]:[],...a.length?[y]:[]])))}));const t=o.box();return t.append(this.tabsElem.root),t}onAfterLoadRun(t){return S(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,v.r6)(this.funcCall.func)}get inputsStorage(){return`RFV_LastInputs_${this.funcCall.func.name}`}saveLastInputs(){return S(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 S(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 S(this,void 0,void 0,(function*(){try{return localStorage.removeItem(this.inputsStorage)}catch(t){i.shell.error(t.toString())}}))}doRun(){return S(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[g.AY]=Object.assign(Object.assign({},this.funcCall.options[g.AY]),{[t]:e})),n&&(this.funcCall.options[g.Jl]=Object.assign(Object.assign({},this.funcCall.options[g.Jl]),{[t]:n})),this.updateConsistencyState()}getInputLockState(t){var e;return null===(e=this.funcCall.options[g.Jl])||void 0===e?void 0:e[t]}updateConsistencyState(){const t=Object.values(this.funcCall.options[g.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,y.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[g.AY])||void 0===e?void 0:e[t]}renderOutputForm(){return this.renderIOForm(g.bZ.OUTPUTS)}onSALaunch(){return S(this,void 0,void 0,(function*(){yield A.n.fromEmpty(this.func)}))}onFittingLaunch(){return S(this,void 0,void 0,(function*(){yield C.v.fromEmpty(this.func)}))}renderInputForm(){return this.renderIOForm(g.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[g.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===g.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,v.KL)(e)&&d()(e.input).is(":focus")&&this.saveFocusedElement(e.input),e.enabled=!1):(e.enabled=!0,(0,v.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,w.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,w.Bu)(i),items:JSON.parse(i.options.choices),nullable:i.nullable});switch(i.propertyType){case"file":return f.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,v.KL)(t)&&(t.input.onkeydown=t=>S(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,v.JU)(n),(0,v.KL)(n)&&((0,v.hg)(e,n),this.bindTooltips(e,n),(0,v._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,v.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[g.wl[n]][i],r=null!==(o=null!==(t=this.funcCall[n][i])&&void 0!==t?t:(0,w.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[g.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===g.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[g.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===g.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,v.KL)(e)?e.onInput:(0,w.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,m.Aw)(e))return!1;for(const[t,e]of Object.entries(this.externalValidatorsState))if(!(0,m.Aw)(e))return!1;return!0}getValidationState(){return this.inputValidationState}getValidationMessage(){const t=[];for(const[e,n]of Object.entries(this.inputValidationState))(0,m.Aw)(n)||t.push(`${e}: ${(0,m.u1)(n)}`);return t.join("\n")}runValidation(t,e){return S(this,arguments,void 0,(function*(t,e,n=g.bZ.INPUTS){const i=t.field,o=this.getValidatedNames(i,n);return(0,v.tf)(t,o,e,n,{view:this,funcCall:this.funcCall,lastCall:this.lastCall},n===g.bZ.INPUTS?this.inputValidators:this.outputValidators)}))}setInputValidationPending(t){const e=this.getValidatedNames(t);for(const t of e){this.inputValidationState[t]=(0,m.Ur)();const e=this.inputsMap[t];(0,y.LB)(e)&&e.setValidation((0,m.Ur)())}this.inputValidationUpdates.next(null)}setOutputValidationPending(t){const e=this.getValidatedNames(t,g.bZ.OUTPUTS);for(const t of e){this.outputValidationState[t]=(0,m.Ur)();const e=this.outputValidationSigns[t];if(e){const n=(0,m.JC)((0,m.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,v.Fd)(n,e))}updateInputValidationResults(t){const e=(0,m.uD)(this.inputValidationState[t],this.externalValidatorsState[t]),n=this.inputsMap[t];(0,y.LB)(n)&&n.setValidation(e)}runRevalidations(t,e,n=g.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===g.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=g.bZ.INPUTS){return t?[t]:[...e===g.bZ.INPUTS?this.funcCall.inputs.keys():this.funcCall.outputs.keys()]}getValidExpRun(t){return S(this,void 0,void 0,(function*(){t.started=a()();const e=t.options.immutable_tags||[];return t.options.immutable_tags=e.includes(g.ec)?e:[...e,g.ec],t.newId(),t}))}saveExperimentalRun(t){return S(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"}}}},5174:(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"]}},5255:(t,e,n)=>{"use strict";n.d(e,{N:()=>i,y:()=>o});class i extends Error{constructor(t){super(t)}}function o(t){return new Promise(((e,n)=>setTimeout(e,t)))}},5271:(t,e,n)=>{"use strict";n(265),n(6296)},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(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,u){return l(this,arguments,void 0,(function*(t,e,n,l,u=1){const c=(0,r.B)(u,n,e),d=[],p=[],h=[];let f,m=0,v=null,g=0;const y=i.TaskBarProgressIndicator.create(`Fitting... (${g}%)`);for(f=0;f<u;++f)try{if(d.push(yield(0,s.tB)(t,c[f],l,e,n)),y.update(100*(f+1)/u,"Fitting..."),g=Math.floor(100*(f+1)/u),y.update(g,`Fitting... (${g}%)`),yield(0,o.y)(a.Q9.MS_TO_SLEEP),y.canceled)break}catch(t){if(y.close(),t instanceof o.N)throw new Error(`Inconsistent dataframes: ${t.message}`);++m,p.push(t instanceof Error?t.message:"Platform issue"),h.push(c[f])}if(y.close(),m>0){const t=n.length,e=new Array(t);for(let n=0;n<t;++n)e[n]=new Float32Array(m);h.forEach(((t,n)=>t.forEach(((t,i)=>e[i][n]=t)))),v=i.DataFrame.fromColumns(e.map(((t,e)=>i.Column.fromFloat32Array(`arg${e}`,t)))),v.columns.add(i.Column.fromStrings("Issue",p))}return{extremums:d,fails:v}}))}},5460:(t,e,n)=>{"use strict";n.d(e,{A:()=>r});var i=n(1661),o=n(2797),s=n(8333);const r=function(t,e,n){if(i.A.randomUUID&&!e&&!t)return i.A.randomUUID();var r=(t=t||{}).random||(t.rng||o.A)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){n=n||0;for(var a=0;a<16;++a)e[n+a]=r[a];return e}return(0,s.k)(r)}},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:()=>a,lK:()=>r});var i=n(6082),o=n(1825);const s="_DG_CUSTOM_SERIALIZED_TOKEN_";function r(t,e={}){return JSON.stringify(t,((t,n)=>n===1/0?{[s]:"Infinity",value:!0}:n===-1/0?{[s]:"-Infinity",value:!0}:Number.isNaN(n)?{[s]:"NaN",value:!0}:n instanceof i.DataFrame&&!e.useJsonDF?{[s]:"DataFrame",value:(0,o.SM)(n.toByteArray())}:n instanceof i.DataFrame&&e.useJsonDF?{[s]:"DataFrameJSON",value:n.toJson()}:n instanceof ArrayBuffer?{[s]:"ArrayBuffer",value:(0,o.SM)(new Uint8Array(n))}:n instanceof Map?{[s]:"Map",value:Array.from(n)}:n instanceof Set?{[s]:"Set",value:Array.from(n)}:n),e.space)}function a(t){return JSON.parse(t,l)}function l(t,e){if(e&&e[s]&&e.value)switch(e[s]){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"Set":return new Set(e.value);case"Infinity":return 1/0;case"-Infinity":return-1/0;case"NaN":return NaN}return e}},5565:(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"]}},5587:(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"]}},5669:(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={}))},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(4044),n(241),n(8384),n(4204)},5933:(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/function-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},6067:(t,e,n)=>{"use strict";n.d(e,{A:()=>l,b:()=>r});var i=n(6314),o=n(3313);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}},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="Rationale",r="Count",u="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.fromStrings(n,Array.from({length:t.rowCount},(()=>""))));const c=()=>s.DataFrame.fromColumns([s.Column.fromStrings(n,[]),s.Column.fromInt32Array(r,new Int32Array([])),s.Column.fromStrings("Actions",[]),s.Column.fromBitSet(u,s.BitSet.create(0,(()=>!1)))]),d=s.Viewer.grid(c());d.root.style.width="100%",d.root.style.minWidth="230px",d.columns.setVisible([n,r,"Actions"]),this.root.append(o.divV([o.divV([d.root],{style:{height:"75%"}})],{style:{height:"100%"}}));const p=()=>{var i,o,r,u;if(!d.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===(r=t.col(e))||void 0===r||r.meta.colors.setCategorical({Outlier:s.Color.scatterPlotMarker,Inlier:s.Color.scatterPlotMarker,"Last Inlier":s.Color.red});const c=null===(u=d.dataFrame)||void 0===u?void 0:u.cell(d.dataFrame.rowCount-1,n).value;t.selection.getSelectedIndexes().forEach((i=>{t.col(e).set(i,"Outlier",!1),t.col(n).set(i,c,!1)})),t.selection.setAll(!1),t.fireValuesChanged(),a()(l()).empty()},h=()=>{d.dataFrame&&(d.dataFrame.rows.removeAt(d.dataFrame.rowCount-1),t.selection.setAll(!1),a()(l()).empty())};d.onCellPrepare((i=>{var s,r,a;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(u,i.gridRow))?[(a=null===(r=i.grid.dataFrame)||void 0===r?void 0:r.get(n,i.gridRow),o.div(o.icons.delete((()=>{for(let i=0;i<t.rowCount;i++)t.columns.byName(n).get(i)===a&&(t.columns.byName(n).set(i,"",!1),t.columns.byName(e).set(i,"Inlier",!1));t.fireValuesChanged()}),"Remove the outliers group"),{style:{textAlign:"center",margin:"6px"}}))]:[o.div(o.iconFA("check",p,"Confirm the outliers"),{style:{textAlign:"center",margin:"6px"}}),o.div(o.iconFA("times",h,"Cancel the outliers"),{style:{textAlign:"center",margin:"6px"}})]])))})),d.onCellValueEdited.subscribe((e=>{var i,o;if(!d.dataFrame||e.gridColumn.name!==n)return;if(!d.dataFrame.columns.byName(u).get(e.gridRow))return;const s=new Set;for(let t=0;t<(null===(i=d.dataFrame)||void 0===i?void 0:i.rowCount);t++){const e=null===(o=d.dataFrame)||void 0===o?void 0:o.columns.byName(n).get(t);s.add(e)}for(let i=0;i<t.rowCount;i++){const o=t.columns.byName(n).get(i);""==o||s.has(o)||t.columns.byName(n).set(i,e.cell.value)}}));const f=()=>{if(t.columns.byName(n))for(let i=0;i<t.rowCount;i++)"Outlier"===t.columns.byName(e).get(i)?""===t.columns.byName(n).get(i)&&t.columns.byName(n).set(i,"Manual",!1):""!==t.columns.byName(n).get(i)&&t.columns.byName(n).set(i,"",!1);const i={};if(t.columns.byName(n))for(let e=0;e<t.rowCount;e++){const o=t.columns.byName(n).get(e),s=i[o];""!=o&&(s?i[o]++:i[o]=1)}d.dataFrame=c(),d.columns.setVisible([n,r,"Actions"]),Object.keys(i).map((t=>{var e;null===(e=d.dataFrame)||void 0===e||e.rows.addNew([t,i[t],"",!0])}))};t.onDataChanged.subscribe(f),t.onSelectionChanged.subscribe((()=>{if(!d.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",p),o.button("Cancel",h)])])),d.dataFrame.columns.byName(u).toList().some((t=>!1===t)))d.dataFrame.set(r,d.dataFrame.rowCount-1,t.selection.trueCount);else{const e=d.dataFrame.rows.addNew(["Manual",t.selection.trueCount,"",!1]);d.dataFrame.currentCell=d.dataFrame.cell(e.idx,n)}})),t.selection.setAll(!1),f()}}},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 C=y(b,9,0),w=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[B,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=L(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 C=a[s].s;m[C]<e?g-=1<<e-m[C]++-1:++s}for(;s>=0&&g;--s){var w=a[s].s;m[w]==e&&(--m[w],++g)}v=e}return[new i(m),v]},L=function(t,e,n){return-1==t.s?Math.max(L(t.l,e,n+1),L(t.r,e,n+1)):e[t.s]=n},N=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]},P=function(t,e){for(var n=0,i=0;i<e.length;++i)n+=t[i]*e[i];return n},M=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)},F=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=N(v),L=S[0],F=S[1],_=N(T),B=_[0],k=_[1],D=new o(19),V=0;V<L.length;++V)D[31&L[V]]++;for(V=0;V<B.length;++V)D[31&B[V]]++;for(var $=O(D,7),U=$[0],H=$[1],j=19;j>4&&!U[l[j-1]];--j);var Y,W,G,K,z=h+5<<3,q=P(s,b)+P(u,A)+c,J=P(s,v)+P(u,T)+c+14+3*j+P(D,U)+(2*D[16]+3*D[17]+7*D[18]);if(z<=q&&z<=J)return M(e,f,t.subarray(p,p+h));if(x(e,f,1+(J<q)),f+=2,J<q){Y=y(v,g,0),W=v,G=y(T,E,0),K=T;var Z=y(U,H,0);for(x(e,f,F-257),x(e,f+5,k-1),x(e,f+10,j-4),f+=14,V=0;V<j;++V)x(e,f+3*V,U[l[V]]);f+=3*j;for(var X=[L,B],Q=0;Q<2;++Q){var tt=X[Q];for(V=0;V<tt.length;++V){var et=31&tt[V];x(e,f,Z[et]),f+=U[et],et>15&&(x(e,f,tt[V]>>>5&127),f+=tt[V]>>>12)}}}else Y=C,W=b,G=w,K=A;for(V=0;V<d;++V)if(i[V]>255){et=i[V]>>>18&31,R(e,f,Y[et+257]),f+=W[et+257],et>7&&(x(e,f,i[V]>>>23&31),f+=r[et]);var nt=31&i[V];R(e,f,G[nt]),f+=K[nt],nt>3&&(R(e,f,i[V]>>>5&8191),f+=a[nt])}else R(e,f,Y[i[V]]),f+=W[i[V]];return R(e,f,Y[256]),f+W[256]},_=new s([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),B=new i(0),k=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=k[255&n^e[i]]^n>>>8;t=n},d:function(){return~t}}},V=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=M(m,v+1,t.subarray(g,y))}else{for(var b=_[e-1],A=b>>>13,C=8191&b,w=(1<<n)-1,E=new o(32768),S=new o(w+1),x=Math.ceil(n/3),R=2*x,O=function(e){return(t[e]^t[e+1]<<x^t[e+2]<<R)&w},L=new s(25e3),N=new o(288),P=new o(32),k=0,D=0,V=(g=0,0),$=0,U=0;g<d;++g){var H=O(g),j=32767&g,Y=S[H];if(E[j]=Y,S[H]=j,$<=g){var W=d-g;if((k>7e3||V>24576)&&W>423){v=F(t,m,0,L,N,P,D,V,U,g-U,v),V=k=D=0,U=g;for(var G=0;G<286;++G)N[G]=0;for(G=0;G<30;++G)P[G]=0}var K=2,z=0,q=C,J=j-Y&32767;if(W>2&&H==O(g-J))for(var Z=Math.min(A,W)-1,X=Math.min(32767,g),Q=Math.min(258,W);J<=X&&--q&&j!=Y;){if(t[g+K]==t[g+K-J]){for(var tt=0;tt<Q&&t[g+tt]==t[g+tt-J];++tt);if(tt>K){if(K=tt,z=J,tt>Z)break;var et=Math.min(J,tt-2),nt=0;for(G=0;G<et;++G){var it=g-J+G+32768&32767,ot=it-E[it]+32768&32767;ot>nt&&(nt=ot,Y=it)}}}J+=(j=Y)-(Y=E[j])+32768&32767}if(z){L[V++]=268435456|p[K]<<18|f[z];var st=31&p[K],rt=31&f[z];D+=r[st]+a[rt],++N[257+st],++P[rt],$=g+K,++k}else L[V++]=t[g],++N[t[g]]}}v=F(t,m,c,L,N,P,D,V,U,g-U,v),!c&&7&v&&(v=M(m,v+1,B))}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 H(t,e){return V(t,e||{},0,0)}var j=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],j(r,a,n,o))}},Y="undefined"!=typeof TextEncoder&&new TextEncoder,W="undefined"!=typeof TextDecoder&&new TextDecoder;try{W.decode(B,{stream:!0})}catch(t){}function G(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(Y)return Y.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 K=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},z=function(t,e,n,i,o,s,r,a){var l=i.length,u=n.extra,c=a&&a.length,d=K(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},q=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=[];j(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=G(a)).length,h=c.comment,f=h&&G(h),m=f&&f.length,v=K(c.extra);p>65535&&S(11);var g=d?H(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),C=s,w=r-s,I=0;I<o.length;++I){var T=o[I];z(A,T.o,T,T.f,T.u,T.c.length);var E=30+T.f.length+K(T.extra);A.set(T.c,T.o+E),z(A,s,T,T.f,T.u,T.c.length,T.o,T.m),s+=16+E+(T.m?T.m.length:0)}return q(A,s,o.length,w,C),A}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout},6296:(t,e,n)=>{"use strict";var i=n(9467);n(5669),i.Y},6314:(t,e,n)=>{"use strict";n.d(e,{Yv:()=>s,bc:()=>i,nH:()=>o}),n(7788),n(2991);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={}))},6362:(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/function-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},6950:(t,e,n)=>{"use strict";n(1927),n(8387)},7031:(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,C=i.K2*s*a,w=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,L=i.K11*f,N=i.K12*p*s,P=i.K13*m,M=i.K14*o*u,F=i.K15*r,_=i.K16*a,B=i.K17*a,k=i.K18*v,D=i.K19*v,V=i.K20*g*u,$=i.K21*y,U=i.K22*y,H=i.K23*o*a,j=i.K24*y*o,Y=i.K25*b;n[0]=-(A+O+M+H+j)+(C+w+R+L+N+U+Y),n[1]=-C-w-R-N+A+$,n[2]=-F+A+B+D+U,n[3]=-C-_-B-H+F,n[4]=2*I-w+E+S+P+V,n[5]=-E-x-M-V+w+2*k,n[6]=-I-T-E+P,n[7]=I+T+E+S,n[8]=-S-x,n[9]=-N+S+R,n[10]=-R-O+x+L,n[11]=R,n[12]=-L+O,n[13]=-P+N,n[14]=M,n[15]=-k-D+_,n[16]=-V,n[17]=V,n[18]=-$-U-j+H+Y,n[19]=-Y+j},tolerance:1e-6,solutionColNames:["y1","y2","y3","y4","y5","y6","y7","y8","y9","y10","y11","y12","y13","y14","y15","y16","y17","y18","y19","y20"]}},7134:(t,e,n)=>{},7149:(t,e,n)=>{"use strict";n.d(e,{C:()=>l,X:()=>u});var i,o,s=n(6082),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(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 a=t=>new Promise(((e,n)=>setTimeout(e,t)));function l(t){if(!Number.isInteger(t))throw new Error(i.INCORRECT_SIZE_TYPE);if(t<1)throw new Error(i.SIZE_MUST_BE_POSITIVE)}function u(t){return r(this,void 0,void 0,(function*(){const e=[],n=s.TaskBarProgressIndicator.create("Running sensitivity analysis...");n.cancelable=!0;let i=0;const r=t.length;for(let s=0;s<r&&(e.push(yield t[s].call()),1===s&&(n.update(100*s/r,"Running sensitivity analysis..."),yield a(10*o.MS_TO_SLEEP)),++i,!n.canceled);++s)i>=o.BATCH_SIZE&&(n.update(100*s/r,"Running sensitivity analysis..."),yield a(o.MS_TO_SLEEP),i=0);return n.close(),e}))}},7160:(t,e,n)=>{"use strict";n(3014),n(4980),n(8084),n(8511)},7294:(t,e,n)=>{"use strict";n.d(e,{Ad:()=>o.A,Ee:()=>i.Ee,HJ:()=>i.HJ,uf:()=>i.uf,vs:()=>i.vs});var i=n(32),o=(n(5092),n(3793));n(1899),n(9732)},7320:(t,e,n)=>{"use strict";n.d(e,{t:()=>c});var i=n(6082),o=n(4044),s=n(8384),r=n(7395),a=n(5925),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){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 Float32Array(n);t.forEach(((t,e)=>t.forEach(((t,n)=>s[n][e]=t))));const r=i.DataFrame.fromColumns(s.map(((t,e)=>i.Column.fromFloat32Array(`arg${e}`,t))));return r.columns.add(i.Column.fromStrings("Issue",e)),r}return null}function c(t,e,c,d,p,h,f,m,v,g,y,b,A){return l(this,void 0,void 0,(function*(){const l=[...p.keys()],C=l.map((t=>{var e;return null!==(e=p.get(t))&&void 0!==e?e:s.PJ})),w=Object.keys(v),I=Object.values(v),T=b.columns,E=y.length+1,S=b.rowCount;if(E<s.Pd)throw new Error(`Not enough of target columns: ${E}. Minimum: ${s.Pd}`);const x=[g].concat(y.map((t=>t.name))),R=new Float64Array(E),O=x.map(((t,e)=>{const n=T.byName(t),i=Math.max(Math.abs(n.stats.max),Math.abs(n.stats.min));R[e]=i>0?i:1;const o=new Float64Array(S),s=n.getRawData();for(let t=0;t<S;++t)o[t]=s[t];return o})),L=[`_${e.arg.name}0`,`_${e.arg.name}1`,"_h"].concat(e.deqs.solutionNames),N=(0,r.B)(A,f,m),P=Math.min(Math.max(s.j2,navigator.hardwareConcurrency-s.fK),A),M=new Array(P).fill(null).map((t=>new Worker(new URL(n.p+n.u(148),n.b)))),F=[],_=[],B=[],k=(0,a.d6)(N,P),D=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)}(h,f,m,v,e),V=d.getPipeline(D);let $=0,U=0;const H=i.TaskBarProgressIndicator.create(`Fitting... (${U}%)`),j=M.map(((n,i)=>new Promise(((r,a)=>{n.postMessage({task:{settingNames:l,settingVals:C,loss:t,ivp2ww:c,pipeline:V,nonParamNames:L,fixedInputsNames:w,fixedInputsVals:I,variedInputNames:h,variedInpMin:f,variedInpMax:m,targetNames:x,targetVals:O,scaleVals:R,samplesCount:A,outputNames:(0,o.AK)(e)},startPoints:k[i]}),n.onmessage=t=>{var e;n.terminate(),++$,U=Math.floor(100*($+1)/P),U<99.9?H.update(U,`Fitting... (${U}%)`):H.update(U,"Fitting... (100%)"),t.data.callResult===s.OW.SUCCEED?(t.data.extremums.forEach((t=>F.push(t))),t.data.fitRes.forEach(((t,e)=>{t!==s.Un&&(_.push(k[i][e]),B.push(t))})),r()):a(null!==(e=t.data.msg)&&void 0!==e?e:"error in webworker fitting")},n.onerror=t=>{n.terminate(),console.error(t),a(t)}}))));return yield Promise.all(j),H.close(),{extremums:F,fails:u(_,B)}}))}},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";function i(t,e,n){const i=e-n,o=new Array(t);for(let e=0;e<t;e++){const t=Math.random();o[e]=n+t*i}return o}function o(t,e,n){const o=e.length,s=new Array(t);for(let e=0;e<t;e++)s[e]=new Float32Array(o);for(let r=0;r<o;r++)if(e[r]===n[r])for(let n=0;n<t;n++)s[n][r]=e[r];else{const o=i(t,e[r],n[r]);for(let e=0;e<t;e++)s[e][r]=o[e]}return s}n.d(e,{B:()=>o})},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:()=>a});var i=n(6082),o=n(9070),s=n(7149),r=n(500);class a{constructor(t,e,n,i,r){(0,s.C)(r),this.samplesCount=r,this.fixedInputs=e,this.func=t;const a=(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:a[t]}))),this.runsCount=r*(this.dimension+2),this.funcCalls=[];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);this.funcCalls.push(t.prepare(i))}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*(){this.funcCalls=yield(0,s.X)(this.funcCalls);const t=this.variedInputs.map((t=>t.column)),e=(0,r.ex)(this.funcCalls,this.outputsOfInterest).columns.toList(),n=(0,r.No)(t,e);n.name=`Sensitivity Analysis of ${this.func.friendlyName}`;const o=e.map((t=>this.getSobolIndeces(t))),a=i.Column.fromStrings("input",t.map((t=>t.name))),l=[a],u=[a];for(const t of o)l.push(t.firstOrder),u.push(t.totalOrder);const c=i.DataFrame.fromColumns(l);c.name="First order Sobol' indices";const d=i.DataFrame.fromColumns(u);return d.name="Total order Sobol' indices",{funcEvalResults:n,funcCalls:this.funcCalls,firstOrderSobolIndices:c,totalOrderSobolIndices:d}},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,{FB:()=>u,LC:()=>h,MP:()=>p,QR:()=>y,VW:()=>d,Yl:()=>l,e_:()=>f,gw:()=>c,ru:()=>v,uM:()=>g});var i=n(4328),o=n(7389),s=n(6082),r=n(5255),a=(n(9530),n(8870),n(4204));function l(t,e,n,i){if(null===t)throw new r.N("no argument column in the target output dataframe");const o=t.name,s=n.col(o);if(null===s)throw new r.N(`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.N(`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 u(t,e){const n=t=>{i.hidden=t,s.hidden=!t,e.forEach((e=>e.hidden=!t))},i=o.iconFA("chevron-right",(()=>n(!0)),"Open category");i.classList.add("fit-view-chevron-right"),i.hidden=!0;const s=o.iconFA("chevron-down",(()=>n(!1)),"Close category");return s.classList.add("fit-view-chevron-down"),o.divH([i,s,o.label(t)],"fit-view-inputs-category")}function c(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 d(){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 p(){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 h(){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 f(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 m(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 v(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 g(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 y(){const t=s.Color.categoricalPalette,e=o.label(a.o_.SIMULATION);e.style.color=m(s.Color.toRgb(t[a.Wr.BLUE]));const n=o.label(a.o_.TARGET);return n.style.color=m(s.Color.toRgb(t[a.Wr.ORANGE])),o.divV([e,n])}},7745:(t,e,n)=>{"use strict";n.d(e,{R:()=>a,z:()=>l});var i=n(7389),o=n(6082),s=n(1858),r=(n(2284),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)}}},7747:(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(3061),l=(n(8480),n(7973)),u=n(9713);class c extends s.Widget{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()}}},7778:(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(5933),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},7788:(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}]])},7973:(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(3061),h=n(8804),f=n(4260),m=n(1521),v=n(1599),g=n(3508),y=n.n(g),b=n(4112),A=n.n(b),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())}))};y().extend(A());const w=new s.LruCache;class I extends s.Widget{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(m.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(m.vw,t))}showEditDialog(t,e){const n=h.V.forFuncCall(t,e);n.onMetadataEdit.pipe((0,d.take)(1)).subscribe((n=>C(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,v.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,g,y,b,A;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(f.d1,0),...(null===(n=this.options)||void 0===n?void 0:n.isHistory)?[s.Column.bool(f.iL,0)]:[],...(null===(r=this.options)||void 0===r?void 0:r.showActions)?[s.Column.string(f.zY,0)]:[],s.Column.bool(f.pC,0),s.Column.dateTime(f.bV,0),s.Column.string(f.l8,0),s.Column.string(f.lv,0),s.Column.string(f.qh,0),s.Column.string(f.Ts,0),s.Column.fromStrings(m.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!==(g=null===(l=this.options)||void 0===l?void 0:l.fallbackText)&&void 0!==g?g:"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 h.C(e);n.onFuncCallDelete.pipe((0,d.take)(1)).subscribe((t=>C(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{yield Promise.all(a()(t.values()).map((t=>C(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",(()=>C(this,void 0,void 0,(function*(){const t=this.currentDf.selection.getSelectedIndexes(),e=[];t.forEach((t=>{e.push(this.currentDf.getCol(m.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!==(b=null===(y=this.options)||void 0===y?void 0:y.isHistory)&&void 0!==b&&b),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=>C(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=>C(this,void 0,void 0,(function*(){if(w.has(t.id))return w.get(t.id);{const e=yield p.W.loadRun(t.id,!0);return w.set(e.id,e),e}})))))).forEach((t=>{this.runs.set(t.id,t)})),this.onRunsChanged.next(this.runs)):(this.styleHistoryGrid(),this.styleHistoryFilters()))}))});const I=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===(A=this.options)||void 0===A?void 0:A.showBatchActions)?[this.trashIcon,this.compareIcon]:[],{style:{gap:"5px",padding:"5px"}})],{style:{justifyContent:"space-between",padding:"0px 5px"}});I.style.setProperty("overflow-y","hidden","important");const T=o.divV([this.defaultGridText,I,this._historyGrid.root],"ui-box");u()(T).removeClass("ui-div"),u()(T).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=>C(this,void 0,void 0,(function*(){if(this.setGridCellRendering(),t.size>0){const e=yield(0,v.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,v.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)})))),S=this._onRunsDfChanged.subscribe((t=>{this._historyFilters.dataFrame=t,this._historyGrid.dataFrame=t,this.currentDf.getCol(f.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)})),x=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))})),R=this._compactMode.subscribe((t=>{const e=[T,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()(T).css(Object.assign({},this.compactMode?{width:"100%"}:{height:"100%"})),setTimeout((()=>{this.styleHistoryGrid(),this.styleHistoryFilters()}),100)}))}));this.subs.push(E,R,S,x)}isFavoriteByIndex(t){return this.currentDf.get(f.iL,t)}setGridCellRendering(){var t,e;(0,v.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 h.C(e);n.onFuncCallDelete.pipe((0,d.take)(1)).subscribe((()=>C(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{yield Promise.all(a()(e.values()).map((t=>C(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,v.WM)(e,!0).then((()=>this.updateRun(e)))}),(t=>{const e=this.getRunByIdx(t.tableRowIndex);(0,v.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 C(this,void 0,void 0,(function*(){return p.W.loadRun(t,!0).then((t=>C(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,v.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,v.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,v.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")}}},8084:(t,e,n)=>{"use strict";n(6314),n(6067);var i=n(1813);n(3313),i.H},8117:(t,e,n)=>{"use strict";n.d(e,{u:()=>C});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(3061),p=n(4260),h=n(4451),f=n(8476),m=(n(7778),n(5520)),v=n(1599),g=n(2610),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=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 C 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=>y(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===p.L_.VISIBLE))){this.stepTabs.currentPane=this.stepTabs.getPane(b(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=`${b(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=`${b(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===p.L_.VISIBLE))){const o=new t.Workbook;this.stepTabs.currentPane=this.stepTabs.getPane(b(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 y(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:p.L_.VISIBLE),ability:new a.BehaviorSubject(this.isHistorical.value||0===e?p.D.ENABLED:p.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=>y(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=>y(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=>y(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 h=o.button("Back",(()=>{}),"Go to the previous step");c()(h).addClass("ui-btn-nav");const f=o.button("Next",(()=>{}),"Go to the next step");c()(f).addClass("ui-btn-nav"),this.syncNavButtons(e,h,f),d.setNavigationButtons([h,f]),this.steps[t.stepId].view=d;const m=this.steps[t.stepId],v=()=>{Object.values(this.steps).forEach((t=>{t.idx>m.idx&&t.visibility.value===p.L_.VISIBLE&&t.ability.value===p.D.ENABLED&&t.ability.next(p.D.DISABLED)}))},g=m.view.funcCallReplaced.pipe((0,l.switchMap)((()=>{const t=[...m.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 A=i.functions.onAfterRunAction.pipe((0,l.filter)((t=>m.view.funcCall&&t&&!!t.id&&m.view.funcCall.id===t.id)),(0,l.withLatestFrom)(m.visibility,m.ability),(0,l.filter)((([,t,e])=>!(t===p.L_.HIDDEN||e===p.D.DISABLED)))).subscribe((()=>{const t=(()=>Object.values(this.steps).find((t=>t.idx>m.idx&&t.visibility.value===p.L_.VISIBLE&&t.ability.value===p.D.ENABLED))?null:Object.values(this.steps).find((t=>t.idx>m.idx&&t.visibility.value===p.L_.VISIBLE&&t.ability.value===p.D.DISABLED)))();null==t||t.ability.next(p.D.ENABLED)}));return this.subs.push(A),yield this.onAfterStepFuncCallApply(t.stepScript.nqName,r,d),d})))),h=yield Promise.all(d),f=(0,a.combineLatest)(h.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)===p.L_.VISIBLE}))&&this.isHistorical.value&&this.isHistorical.next(!1)}));this.subs.push(f);const m=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(m),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 y(this,void 0,void 0,(function*(){return Promise.all(Object.values(this.steps).map((t=>y(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=b(i))})),e.addEventListener("click",(()=>{o&&(this.currentTabName=b(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===p.D.DISABLED&&c()(n).addClass("d4-disabled"),i.ability.value===p.D.ENABLED&&c()(n).removeClass("d4-disabled")):c()(n).hide(),o?(c()(e).show(),o.ability.value===p.D.DISABLED&&c()(e).addClass("d4-disabled"),o.ability.value===p.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===p.L_.VISIBLE))}getNextStep(t){return Object.values(this.steps).find((e=>e.idx>t.idx&&e.visibility.value===p.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 y(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 f.S.fromComparedRuns(o,o[0].func,{parentView:s,parentCall:e});i.shell.addView(r)}))}onBeforeStepFuncCallApply(t,e,n){return y(this,void 0,void 0,(function*(){}))}onAfterStepFuncCallApply(t,e,n){return y(this,void 0,void 0,(function*(){}))}buildIO(){const t=Object.values(this.steps).reduce(((t,e)=>Object.assign(Object.assign({},t),{[b(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(b(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=A(t);this.subs.push(this.steps[e].visibility.subscribe((t=>{t===p.L_.VISIBLE&&c()(this.stepTabs.getPane(b(this.steps[e])).header).css("display","inherit"),t===p.L_.HIDDEN&&c()(this.stepTabs.getPane(b(this.steps[e])).header).hide()})))})),Object.values(this.steps).forEach((t=>{this.subs.push(t.ability.subscribe((e=>{e===p.D.ENABLED&&c()(this.stepTabs.getPane(b(t)).header).removeClass("d4-disabled"),e===p.D.DISABLED&&c()(this.stepTabs.getPane(b(t)).header).addClass("d4-disabled")})))})),this.hideSteps(...this.initialConfig.filter((t=>t.hiddenOnInit===p.L_.HIDDEN)).map((t=>t.funcName))),e.root}showHelpWithDelay(t){return y(this,void 0,void 0,(function*(){(0,v.aB)(this.helpFiles[t.func.nqName])}))}findCurrentStep(){return Object.values(this.steps).find((t=>b(t)===this.stepTabs.currentPane.name))}buildHistoryBlock(){const t=super.buildHistoryBlock(),e=this.historyBlock.afterRunDeleted.subscribe((t=>y(this,void 0,void 0,(function*(){(yield i.dapi.functions.calls.allPackageVersions().filter(`options.parentCallId="${t.id}"`).list()).map((t=>y(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",(()=>y(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((()=>y(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 y(this,void 0,void 0,(function*(){let e=(0,v.A4)(t);yield this.onBeforeSaveRun(e),(0,v.Ne)(e)&&(e=yield(0,v.Hs)(t)),e.newId();const n=Object.values(this.steps).filter((t=>t.visibility.value===p.L_.VISIBLE)).map((t=>y(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 y(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===p.L_.VISIBLE)).findIndex((t=>b(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(p.L_.HIDDEN),t.ability.next(p.D.DISABLED)),1===e.length&&(yield t.view.loadRun(e[0].id),t.visibility.next(p.L_.VISIBLE),(0,v.Ne)(e[0])?t.ability.next(p.D.DISABLED):t.ability.next(p.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(p.L_.VISIBLE),(0,v.Ne)(n)?t.ability.next(p.D.DISABLED):t.ability.next(p.D.ENABLED)}}const o=Object.values(this.steps).find((t=>t.ability.value===p.D.DISABLED&&t.visibility.value===p.L_.VISIBLE)),s=null!=o?o:Object.values(this.steps)[0];if(s.ability.next(p.D.ENABLED),o){let t=this.getNextStep(o);for(;t;)t.ability.next(p.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==p.L_.VISIBLE)).at(i);return r&&r.ability.value===p.D.ENABLED?this.currentTabName=b(r):this.currentTabName=b(s),yield this.onAfterLoadRun(e),e}))}hideSteps(...t){return y(this,void 0,void 0,(function*(){t.forEach((t=>{this.steps[t].visibility.next(p.L_.HIDDEN)}))}))}showSteps(...t){return y(this,void 0,void 0,(function*(){t.forEach((t=>{this.steps[t].visibility.next(p.L_.VISIBLE)}))}))}exportRunJson(){return y(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,v.wB)(i,n.view))}return(0,m.lK)(t)}}))}executeTest(t){return y(this,arguments,void 0,(function*(t,e=!1){yield(0,g.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))))}}},8333:(t,e,n)=>{"use strict";n.d(e,{k:()=>s});for(var i=[],o=0;o<256;++o)i.push((o+256).toString(16).slice(1));function s(t,e=0){return(i[t[e+0]]+i[t[e+1]]+i[t[e+2]]+i[t[e+3]]+"-"+i[t[e+4]]+i[t[e+5]]+"-"+i[t[e+6]]+i[t[e+7]]+"-"+i[t[e+8]]+i[t[e+9]]+"-"+i[t[e+10]]+i[t[e+11]]+i[t[e+12]]+i[t[e+13]]+i[t[e+14]]+i[t[e+15]]).toLowerCase()}},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={}))},8387:(t,e,n)=>{"use strict";n(6314)},8476:(t,e,n)=>{"use strict";n.d(e,{S:()=>p});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())}))};const d=window;class p 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(d.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)}}},8480:(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(8565),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},8511:(t,e,n)=>{"use strict";n(6314),n(6067);var i=n(1813);n(3313),i.H},8565:(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/shared-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},8586:(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(3703),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;let 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)}))))}}},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},8948:(t,e,n)=>{"use strict";n.d(e,{AK:()=>i.A,S3:()=>o.S}),n(7160);var i=n(6067),o=(n(1813),n(4980),n(8511),n(8084),n(844))},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}},9046:(t,e,n)=>{"use strict";n(6082),n(5460),n(1858),n(9713)},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}},9171:(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})},9312:(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"]}},9421:(t,e,n)=>{"use strict";n(7788),n(6314),n(2991)},9467:(t,e,n)=>{"use strict";n.d(e,{Y:()=>i});class i{constructor(){}onIterationStart(){}onComputationsCompleted(){}}},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:"Compute Engine",link:"https://github.com/datagrok-ai/public/tree/master/packages/Compute"},{name:"Developing Models",link:"https://datagrok.ai/help/compute/scripting"}],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(),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},9713:t=>{"use strict";t.exports=rxjs.operators},9732:(t,e,n)=>{"use strict";n(3296)},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))}}},9865:(t,e,n)=>{"use strict";var i=n(5565),o=n(5174),s=n(9312),r=n(2947),a=n(5587),l=n(7031);n(7134),i.L,o.e,s.Y,r.R,a.e5,l.x},9911:(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/shared-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},9939:(t,e,n)=>{"use strict";n.d(e,{s:()=>c});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=n(9713),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(){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"}getById(t){return l(this,void 0,void 0,(function*(){return yield i.dapi.functions.find(t)}))}refresh(t){return l(this,void 0,void 0,(function*(){return yield this.getById(t.id)}))}static getHelp(t){return l(this,void 0,void 0,(function*(){if(!t.options.readme)return;const e=`System:AppData/${t.package.name}/${t.options.readme}`;return(yield i.dapi.files.exists(e))?yield i.dapi.files.readAsText(e):void 0}))}static openHelp(t){return l(this,void 0,void 0,(function*(){if(!t.options.readme)return;const e=`System:AppData/${t.package.name}/${t.options.readme}`,n=(yield i.dapi.files.exists(e))?yield i.dapi.files.readAsText(e):"No help file";i.shell.windows.help.showHelp(o.markdown(n))}))}static openModel(t){t.prepare().edit()}static openModelFromFunccall(t){t.edit()}static getUserGroups(){return l(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((()=>l(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);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((()=>l(this,void 0,void 0,(function*(){var e,i;const s=yield c.getHelp(t),r=yield this.awaitUserGroups(),a=c.getMissingGroups(t,r),l=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"}}),l,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=>{c.openVersionSelectDialog(s.toJs(t))})),this.registerParamFunc("Help",(t=>{c.openHelp(s.toJs(t))})),setTimeout((()=>l(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([u(),t.name],{style:{fontWeight:"600"}}),...t.help?[o.span([t.help],{style:{marginLeft:"16px"}})]:[],o.link("Request group membership",(()=>l(this,void 0,void 0,(function*(){yield function(t){return l(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 l(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=document.baseURI||self.location.href,n.nc=void 0;var i={};(()=>{"use strict";n.r(i),n.d(i,{AmbTempValidator:()=>W,CFV:()=>x,CompView:()=>E,CustomCustomizer:()=>U,CustomDataUploader:()=>V,CustomStringInput:()=>K,CustomUploader:()=>$,DesiredTempValidator:()=>j,HeatCapValidator:()=>G,InitialTempValidator:()=>Y,ObjectCoolingSelector:()=>z,OutliersSelection:()=>f,Pipeline:()=>R,PipelineStepEditor:()=>v,RFV:()=>S,RichFunctionViewEditor:()=>m,SimTimeValidator:()=>H,_package:()=>p,fileInput:()=>M,historyInput:()=>F,historyInputJSON:()=>_,historyPanel:()=>B,init:()=>C,makeAdvice:()=>L,makeAdvice2:()=>k,makeRevalidation:()=>N,makeValidationResult:()=>O,makeValidationResult2:()=>D,mergeValidationResults:()=>P,modelCatalog:()=>w,modelCatalogTreeBrowser:()=>I,openModelFromFuncall:()=>h,renderPanel:()=>g,testPipeline:()=>T});var t=n(4328),e=n(7389),o=n(6082),s=n(9713),r=n(6126),a=n(7294),l=n(1899),u=n(3398),c=n(2610),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 p=new o.Package;function h(t){u.sg.openModelFromFunccall(t)}function f(){return new r.A}function m(t){return a.Ee.fromFuncCall(t,{historyEnabled:!0,isTabbed:!1})}function v(t){return a.Ee.fromFuncCall(t,{historyEnabled:!1,isTabbed:!0})}function g(t){return d(this,void 0,void 0,(function*(){return(0,u.lp)(t)}))}let y=!1,b=!1;const A={_package:p,ViewClass:u.ak,segment:"Modelhub",viewName:"Model Hub",funcName:"modelCatalog",setStartUriLoaded:()=>y=!0,getStartUriLoaded:()=>y};function C(){b||((0,u.jd)(),(0,u.a8)(A),b=!0)}function w(){return(0,u.v_)(A)}function I(t){(0,u.I3)(t)}const T=c.b,E=a.HJ,S=a.Ee,x=a.vs,R=a.uf,O=l.ZS,L=l.B5,N=l.dQ,P=l.uD,M=a.Ad.fileInput,F=a.Ad.historyInput,_=a.Ad.historyInputJSON,B=a.Ad.historyPanel,k=l.B5,D=l.ZS;function V(t){return d(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()]}))}function $(n){return d(this,void 0,void 0,(function*(){const i=(yield t.functions.eval("Compute:CustomDataUploader")).prepare({func:n.func}),r=e.bigButton("Click me to get mock calls",(()=>i.call())),a=o.Widget.fromRoot(e.panel([e.divV([e.label("This part of dialog comes from my custom data uploader"),e.divH([r],{style:{justifyContent:"center"}})])])),l=t.functions.onBeforeRunAction.pipe((0,s.filter)((t=>t.id===i.id))).subscribe((()=>{e.setUpdateIndicator(r,!0)})),u=t.functions.onAfterRunAction.pipe((0,s.filter)((t=>t.id===i.id))).subscribe((()=>{e.setUpdateIndicator(r,!1)}));return a.subs.push(l,u),{uploadWidget:a,uploadFuncCall:i}}))}function U(t){t.defaultView.scatterPlot({xColumnName:"Initial temperature",yColumnName:"Time to cool"})}function H(t){const{reasonableMin:e,reasonableMax:n}=t;return t=>(0,l.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})}function j(t){return(t,e)=>{const n=e.funcCall.inputs.ambTemp,i=e.funcCall.inputs.initTemp;return(0,l.ZS)({errors:[...t<n?[(0,l.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})`]:[]]})}}function Y(t){return(t,e)=>{const n=e.funcCall.inputs.ambTemp;return(0,l.ZS)({errors:[...t<n?[`Initial temperature cannot be less than ambient temperature (${n}).`]:[]]})}}function W(t){return(t,e)=>{const n=e.funcCall.inputs.initTemp;return(0,l.ZS)({errors:[...t>n?[`Ambient temperature cannot be higher than initial temperature (${n})`]:[]]})}}function G(t){return(t,e)=>(0,l.ZS)({errors:[...t<=0?["Heat capacity must be greater than zero."]:[]],notifications:[(0,l.B5)("Heat capacity is only dependent on the object material.",[{actionName:"Google it",action:()=>{window.open("http://google.com")}}])]})}function K(t){const n=e.input.string("Custom input",{value:""});return n.root.style.backgroundColor="aqua",n.input.style.backgroundColor="aqua",n}function z(t){return a.Ad.historyInputJSON("Previous run","ObjectCooling")}})(),compute=i})();
1
+ var compute;(()=>{var t={32:(t,e,n)=>{"use strict";n.d(e,{Ee:()=>s.E,HJ:()=>o.H,uf:()=>i.u,vs:()=>r.v}),n(4451);var i=n(8117),o=n(4822),s=n(5104),r=(n(8476),n(1491),n(3501))},237:(t,e,n)=>{"use strict";var i;n.d(e,{FL:()=>o,KN:()=>i,Q2:()=>u,TR:()=>r,YU:()=>l,dV:()=>a}),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=`# 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](https://datagrok.ai/help/compute/function-analysis#monte-carlo) explores a function \nat randomly taken points\n\n* [Sobol](https://datagrok.ai/help/compute/function-analysis#sobol)\ndecomposes output variance into fractions, which can be attributed to inputs\n\n* [Grid](https://datagrok.ai/help/compute/function-analysis#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 <i class="grok-icon fal fa-question"></i> on the top panel to learn more about \n[Sensitivity Analysis](https://datagrok.ai/help/compute/function-analysis#sensitivity-analysis)\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.`,a=0,l=-1,u=0},241:(t,e,n)=>{"use strict";n.d(e,{bj:()=>o,df:()=>s,tB:()=>l});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}],["maxIter",{default:50,min:1,max:1e4}],["nonZeroParam",{default:1e-4,min:1e-20,max:.1}],["initialScale",{default:.02,min:1e-20,max:.1}],["scaleReflaction",{default:1,min:1,max:2}],["scaleExpansion",{default:2,min:1,max:2}],["scaleContraction",{default:-.5,min:-.5,max:0}]]),s=new Map([["tolerance","tolerance"],["maxIter","max iterations"],["nonZeroParam","non-zero param"],["initialScale","initial scale"],["scaleReflaction","scale reflection"],["scaleExpansion","scale expansion"],["scaleContraction","scale contraction"]]);function r(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 a(t,e,n,i,o,s,r,a){for(let l=0;l<s;l++)e[l]=t[l],e[l]+=o*(t[l]-i[n][l]),e[l]<r[l]?e[l]=r[l]:e[l]>a[l]&&(e[l]=a[l])}const l=function(t,e,n,o,s){return i(this,void 0,void 0,(function*(){const l=n.get("tolerance"),u=n.get("maxIter"),c=n.get("scaleReflaction"),d=n.get("scaleExpansion"),p=n.get("scaleContraction"),h=e.length+1,f=e.length,[m,v]=yield function(t,e,n,o,s){return i(this,void 0,void 0,(function*(){const i=n.length+1,r=n.length,a=e.get("nonZeroParam"),l=e.get("initialScale"),u=new Array(i),c=new Array(i);for(let e=0;e<i;e++){u[e]=new Float32Array(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],u[e][t]<o[t]?u[e][t]=o[t]:u[e][t]>s[t]&&(u[e][t]=s[t]));c[e]=yield t(u[e])}return[u,c]}))}(t,n,e,o,s),g=new Array(h);for(let t=0;t<h;t++)g[t]=t;const y=g.length-1;let b=0,A=0,C=0,w=0;const I=new Float32Array(f),T=new Float32Array(f),E=new Float32Array(f),S=new Float32Array(f),x=new Array(u);if(h>1){for(;g.sort(((t,e)=>v[t]-v[e])),!(b>u);){if(0==b&&(A=v[0],C=2*v[g[0]]),x[b]=A,++b,A=v[g[0]],C-A>l)w=0;else if(++w,w>2*h)break;C=A,r(I,f,g[y],m),a(I,T,g[y],m,c,f,o,s);const e=yield t(T);if(e<v[g[y]]){a(I,E,g[y],m,d,f,o,s);const n=yield t(E);if(n<e){v[g[y]]=n;for(let t=0;t<f;t++)m[g[y]][t]=E[t];continue}v[g[y]]=e;for(let t=0;t<f;t++)m[g[y]][t]=T[t];continue}a(I,S,g[y],m,p,f,o,s);const n=yield t(S);if(!(n<v[g[y]]))break;v[g[y]]=n;for(let t=0;t<f;t++)m[g[y]][t]=S[t]}for(let t=b;t<u;t++)x[t]=v[g[0]]}return{point:m[g[0]],cost:v[g[0]],iterCosts:x,iterCount:b-1}}))}},265:(t,e,n)=>{"use strict";var i=n(9467);n(5669),i.Y},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:o,ViewClass:r}=t;let a=r.findModelCatalogView(e);if(!a){const t=s.Func.find({package:o.name,name:n})[0].prepare();t.callSync({processed:!0,report:!1}),a=t.outputs.v}return[...i.shell.views].find((t=>t===a))||i.shell.add(a),a}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))}))}}}}))}},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}},567:(t,e,n)=>{"use strict";n(5669)},810:(t,e,n)=>{"use strict";n.d(e,{Bu:()=>p,Gb:()=>f,ZD:()=>h,cb:()=>d,eK:()=>g,fo:()=>v,jJ:()=>m});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(4260),u=n(1858),c=(n(1599),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=>new Promise((e=>setTimeout(e,t))),p=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 h(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"))}function f(t){return new u.Observable((e=>{const n=t((t=>{e.next(t)}));return()=>n.unsubscribe()}))}const m=t=>{const e=t.options[l.NT];return void 0!==e?{name:t.name,config:JSON.parse(e,((t,e)=>{if("true"===e)return!0;if("false"===e)return!1;if("type"===t)return l.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:[]}},v=(t,e,n={parentView:void 0,parentCall:void 0})=>{var r,u;const d=e,p=[...d.inputs,...d.outputs].map((t=>m(t))).reduce(((t,e)=>(t[e.name]?t[e.name].push(...e.config):t[e.name]=e.config,t)),{}),h=e=>{var n;if(e.propertyType===s.TYPE.DATA_FRAME){const n=p[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=f.columns.getUnusedName(`${r.name} (${n.type})`);return r.name=a,o=a,r.temp[l.NT]=n,f.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=f.columns.getUnusedName(o.name);return o.name=r,i=r,f.columns.add(o),[o]}},f=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} - ${g(t)}`,i=2;for(;v.includes(n);)n=`${t.func.name} - ${g(t)})\n .toLocaleString('en-us', {month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric'})} - ${i}`,i++;v.push(n)})),f.columns.add(s.Column.fromStrings(l._W,v)),f.name=(null===(r=n.parentCall)||void 0===r?void 0:r.func.name)?`${null===(u=n.parentCall)||void 0===u?void 0:u.func.name} - comparison`:`${e.name} - comparison`,d.inputs.forEach((t=>h(t))),d.outputs.forEach((t=>h(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%"})}}))}})),f},g=t=>{try{return t.started.toDate().toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}catch(t){return"Not completed"}}},844:(t,e,n)=>{"use strict";n.d(e,{S:()=>o});var i=n(3313);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}},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},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()).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={}))},1294:(t,e,n)=>{"use strict";n(5669),Math.sqrt(2),Math.sqrt(2)},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:()=>T});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(8476),h=(n(8870),n(4260)),f=n(237),m=n(1159),v=n(7722),g=n(6307),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=[s.TYPE.INT,s.TYPE.BIG_INT,s.TYPE.FLOAT,s.TYPE.BOOL,s.TYPE.DATA_FRAME],A=[s.TYPE.INT,s.TYPE.BIG_INT,s.TYPE.FLOAT,s.TYPE.BOOL,s.TYPE.DATA_FRAME];var C,w;!function(t){t.GRID_ANALYSIS="Grid",t.RANDOM_ANALYSIS="Monte Carlo",t.SOBOL_ANALYSIS="Sobol"}(C||(C={})),function(t){t.LAST_ROW="Last row",t.FIRST_ROW="First row",t.ALL_COLUMNS="",t.BY_COL_VAL="By value in column"}(w||(w={}));const I=()=>o.div([],"sa-switch-input");class T{static fromEmpty(t){return y(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===h.sk)),o=yield p.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:C.RANDOM_ANALYSIS,items:[C.RANDOM_ANALYSIS,C.SOBOL_ANALYSIS,C.GRID_ANALYSIS],onValueChanged:t=>{e.analysisType.value.next(t),this.updateRunWidgetsState(),this.setAnalysisInputTooltip(),this.store.analysisInputs.samplesCount.input.setTooltip(this.samplesCountTooltip())}}),value:new l.BehaviorSubject(C.RANDOM_ANALYSIS)},samplesCount:{input:o.input.int("Samples",{value:10,onValueChanged:t=>{e.samplesCount.value=t,this.updateRunWidgetsState()}}),value:10}};e.analysisType.input.root.insertBefore(I(),e.analysisType.input.captionLabel),e.samplesCount.input.root.insertBefore(I(),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.updateRunWidgetsState()})),p=r(!1,(t=>{m.isChanging.next(t),this.updateRunWidgetsState()})),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.updateRunWidgetsState()}}),value:3},isChanging:new l.BehaviorSubject(!1)};[h.max.input,h.lvl.input].forEach((t=>{t.root.insertBefore(I(),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===C.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.updateRunWidgetsState()})),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=I(),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:w.LAST_ROW,items:[w.LAST_ROW,w.FIRST_ROW,w.BY_COL_VAL],onValueChanged:t=>{n.value.returning=t,n.analysisInputs.forEach((e=>{e.root.hidden=t!==w.BY_COL_VAL})),a.setTooltip(this.getOutputTooltip(i,t))}}),a.setTooltip(this.getOutputTooltip(i,w.LAST_ROW))):(a=o.input.forProperty(e),a.setTooltip("Scalar")),a.addCaption(i);const l=A.includes(e.propertyType)?r(!0,(t=>{n.isInterest.next(t),n.analysisInputs.forEach((t=>{t.root.hidden=n.value.returning!==w.BY_COL_VAL})),this.updateRunWidgetsState(),e.propertyType===s.TYPE.DATA_FRAME&&a.setTooltip(t?this.getOutputTooltip(i,w.LAST_ROW):"Dataframe")}),!1).root:I();return a.root.insertBefore(l,a.captionLabel),a})(),analysisInputs:e.propertyType===s.TYPE.DATA_FRAME?[(()=>{var t;const i=o.input.string("Column",{value:w.ALL_COLUMNS,onValueChanged:t=>{n.value.colName=t}});return i.root.insertBefore(I(),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(I(),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:w.LAST_ROW,colName:w.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.gridClickSubscription=null,this.gridCellChangeSubscription=null,this.store=this.generateInputFields(this.func),this.diffGrok=void 0,this.runButton=o.bigButton("Run",(()=>y(this,void 0,void 0,(function*(){return yield this.runAnalysis()})))),this.runIcon=o.iconFA("play",(()=>y(this,void 0,void 0,(function*(){return yield this.runAnalysis()})))),this.runIcon.style.color="var(--green-2)",this.runIcon.classList.add("fas"),this.helpIcon=o.iconFA("question",(()=>{window.open("https://datagrok.ai/help/compute/function-analysis#sensitivity-analysis","_blank")}),"Open help in a new tab"),this.buildFormWithBtn(n.inputsLookup).then((t=>{this.runButton.disabled=!this.canEvaluationBeRun(),this.runIcon.hidden=this.runButton.disabled,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;const n=this.comparisonView.getRibbonPanels();n.push([this.helpIcon,this.runIcon]),this.comparisonView.setRibbonPanels(n),this.comparisonView.helpUrl="/help/function-analysis.md#sensitivity-analysis",this.tableDockNode=this.comparisonView.dockManager.findNode(this.comparisonView.grid.root);const i=o.markdown(f.TR);i.style.padding="10px",i.style.overflow="auto",this.helpMdNode=this.comparisonView.dockManager.dock(i,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)}getFuncCallCount(t,e){let n=0;switch(t.analysisType.value.value){case C.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 C.RANDOM_ANALYSIS:return t.samplesCount.value;case C.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 t<1e3?String(t):t<1e6?String(Math.ceil(t/10)/100)+"k":t<1e9?String(Math.ceil(t/1e4)/100)+"m":String(Math.ceil(t/1e7)/100)+"b"}updateRunWidgetsState(){this.runButton.textContent=`Run (${this.getFuncCallCountAsString()})`,this.runButton.disabled=!this.canEvaluationBeRun(),this.runIcon.hidden=this.runButton.disabled}getLookupElement(t){return y(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,m.c)(t,e);return null!==n&&n.input.root.insertBefore(I(),n.input.captionLabel),n}))}buildFormWithBtn(t){return y(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,v.FB)(s,t)),n.append(...t)}if(e.forEach(((t,e)=>{"Misc"!==e&&e!==s&&(n.append((0,v.FB)(e,t)),n.append(...t))})),"Misc"!==s){const t=e.get("Misc");t.length>0&&(n.append((0,v.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===C.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}c||this.store.outputs[Object.keys(this.store.outputs)[0]].isInterest.next(!0),this.updateRunWidgetsState();const d=o.buttonsInput([this.runButton]);return n.appendChild(d),a()(n).css({"padding-left":"12px","overflow-y":"scroll","padding-right":"4px"}),n}))}setAnalysisInputTooltip(){let t;switch(this.store.analysisInputs.analysisType.value.value){case C.GRID_ANALYSIS:t="Grid analysis: the function is evaluated with respect to the selected inputs varying within the specified ranges";break;case C.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 C.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 w.FIRST_ROW:return`To analyze first row of the '${t}' dataframe`;case w.LAST_ROW:return`To analyze last row of the '${t}' dataframe`;case w.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 C.RANDOM_ANALYSIS:return"Input sets count";case C.SOBOL_ANALYSIS:return"Sample size for the Sobol' indices computation";default:return"Unknown method!"}}addTooltips(){var t;this.setAnalysisInputTooltip(),o.tooltip.bind(this.runButton,(()=>`Run sensitivity analysis: the function is evaluated ${this.getFuncCallCount(this.store.analysisInputs,this.store.inputs)} times`)),o.tooltip.bind(this.runIcon,(()=>`Run sensitivity analysis: the function is evaluated ${this.getFuncCallCount(this.store.analysisInputs,this.store.inputs)} times`)),this.store.analysisInputs.samplesCount.input.setTooltip(this.samplesCountTooltip());for(const e of Object.keys(this.store.inputs)){const n=this.store.inputs[e].prop.propertyType;if(n===s.TYPE.BOOL||n===s.TYPE.STRING)continue;const i=this.store.inputs[e],o=null!==(t=i.prop.caption)&&void 0!==t?t:i.prop.name;i.const.input.setTooltip(`'${o}' value`),i.min.input.setTooltip(`Min value of '${o}'`),i.max.input.setTooltip(`Max value of '${o}'`),i.lvl.input.setTooltip(`Number of samples along the axis '${o}'`)}}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}canEvaluationBeRun(){return this.isAnyInputSelected()&&this.isAnyOutputSelected()}runAnalysis(){return y(this,void 0,void 0,(function*(){if(this.canEvaluationBeRun())switch(this.store.analysisInputs.analysisType.value.value){case C.GRID_ANALYSIS:yield this.runGridAnalysis();break;case C.RANDOM_ANALYSIS:yield this.runRandomAnalysis();break;case C.SOBOL_ANALYSIS:yield this.runSobolAnalysis()}}))}getFixedInputColumns(t){return Object.values(this.store.inputs).filter((t=>!b.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 y(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,d=r.funcInputs,p=r.firstOrderSobolIndices,h=r.totalOrderSobolIndices,m=p.columns.names();this.comparisonView.dataFrame=l;const v=l.columns.names(),g=this.getFixedInputColumns(l.rowCount);for(const t of g)t.name=l.columns.getUnusedName(`${t.name} (fixed)`),l.columns.add(t);this.comparisonView.grid.columns.setVisible([v[0]]),this.comparisonView.grid.columns.setVisible(v),this.comparisonView.grid.props.rowHeight=f.FL;const b=s.Viewer.correlationPlot(l,{xColumnNames:v,yColumnNames:v}),A=this.comparisonView.dockManager.dock(b,s.DOCK_TYPE.LEFT,this.tableDockNode,"",f.KN.COR_PLOT);this.openedViewers.push(b);const C=s.Viewer.pcPlot(l,{columnNames:v});this.comparisonView.dockManager.dock(C,s.DOCK_TYPE.DOWN,A,"",f.KN.PC_PLOT),this.openedViewers.push(C);const w=this.getOutputNameForScatterPlot(v,l,t.variedInputs.length),I=1===t.variedInputs.length?s.Viewer.lineChart(l,this.getLineChartOpt(v)):s.Viewer.scatterPlot(l,this.getScatterOpt(v,w));this.openedViewers.push(I),this.comparisonView.dockManager.dock(I,s.DOCK_TYPE.DOWN,this.tableDockNode,"",f.KN.GRAPH);const T=s.Viewer.barChart(p,this.getBarChartOpt(p.name,m[0],w)),E=this.comparisonView.dockManager.dock(T,s.DOCK_TYPE.RIGHT,void 0,"",f.KN.BAR_CHART),S=s.Viewer.barChart(h,this.getBarChartOpt(h.name,m[0],w));this.comparisonView.dockManager.dock(S,s.DOCK_TYPE.DOWN,E),this.openedViewers=this.openedViewers.concat([T,S]);const x=t=>y(this,void 0,void 0,(function*(){var e;if(null==t||void 0===d)return;const n=d[null!==(e=t.tableRowIndex)&&void 0!==e?e:0],r=this.func.prepare(n),l=yield r.call(),c=[...l.outputParams.values()].filter((t=>s.TYPES_SCALAR.has(t.property.propertyType))),p=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,h=[...l.outputParams.values()].filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME)).reduce(((t,e)=>{var n;const i=(0,u.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 f,m;c.length>0?(m=1,f=Object.assign({"Output scalars":[p]},h)):(m=0,f=Object.assign({},h));const v=o.accordion();a()(v.root).css({width:"100%"}),Object.entries(f).map((t=>{v.addPane(t[0],(()=>o.divV(t[1])))})),v.panes[m].expanded=!0,i.shell.o=v.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=>!b.includes(this.store.inputs[t].type)||!this.store.inputs[t].isChanging.value))}getVariedInputs(){return Object.keys(this.store.inputs).filter((t=>!!b.includes(this.store.inputs[t].type)&&this.store.inputs[t].isChanging.value))}runRandomAnalysis(){return y(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,c=r.funcInputs;this.clearPrev(),this.comparisonView.dataFrame=l;const p=l.columns.names(),h=this.getFixedInputColumns(l.rowCount);for(const t of h)t.name=l.columns.getUnusedName(`${t.name} (fixed)`),l.columns.add(t);this.comparisonView.grid.columns.setVisible([p[0]]),this.comparisonView.grid.columns.setVisible(p),this.comparisonView.grid.props.rowHeight=f.FL;const m=s.Viewer.correlationPlot(l,{xColumnNames:p,yColumnNames:p}),v=this.comparisonView.dockManager.dock(m,s.DOCK_TYPE.LEFT,this.tableDockNode,"",f.KN.COR_PLOT);this.openedViewers.push(m);const g=s.Viewer.pcPlot(l,{columnNames:p});this.comparisonView.dockManager.dock(g,s.DOCK_TYPE.DOWN,v,"",f.KN.PC_PLOT),this.openedViewers.push(g);const b=this.getOutputNameForScatterPlot(p,l,t.variedInputs.length),A=1===t.variedInputs.length?s.Viewer.lineChart(l,this.getLineChartOpt(p)):s.Viewer.scatterPlot(l,this.getScatterOpt(p,b));this.openedViewers.push(A),this.comparisonView.dockManager.dock(A,s.DOCK_TYPE.DOWN,this.tableDockNode,"",f.KN.GRAPH);const C=t=>y(this,void 0,void 0,(function*(){var e;if(null==t||void 0===c)return;const n=c[null!==(e=t.tableRowIndex)&&void 0!==e?e:0],r=this.func.prepare(n),l=yield r.call(),d=[...l.outputParams.values()].filter((t=>s.TYPES_SCALAR.has(t.property.propertyType))),p=s.HtmlTable.create(d,(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,h=[...l.outputParams.values()].filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME)).reduce(((t,e)=>{var n;const i=(0,u.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 f,m;d.length>0?(m=1,f=Object.assign({"Output scalars":[p]},h)):(m=0,f=Object.assign({},h));const v=o.accordion();a()(v.root).css({width:"100%"}),Object.entries(f).map((t=>{v.addPane(t[0],(()=>o.divV(t[1])))})),v.panes[m].expanded=!0,i.shell.o=v.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")}}))}runGridAnalysis(){return y(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(),c=new g.R(this.func,n,r,l,this.diffGrok),d=yield c.perform();this.clearPrev(),this.comparisonView.dataFrame=d;const p=d.columns.names(),h=this.getFixedInputColumns(d.rowCount);for(const t of h)t.name=d.columns.getUnusedName(`${t.name} (fixed)`),d.columns.add(t);this.comparisonView.grid.columns.setVisible([p[0]]),this.comparisonView.grid.columns.setVisible(p),this.comparisonView.grid.props.rowHeight=f.FL;const m=s.Viewer.correlationPlot(d,{xColumnNames:p,yColumnNames:p}),v=this.comparisonView.dockManager.dock(m,s.DOCK_TYPE.LEFT,this.tableDockNode,"",f.KN.COR_PLOT);this.openedViewers.push(m);const b=s.Viewer.pcPlot(d,{columnNames:p});this.comparisonView.dockManager.dock(b,s.DOCK_TYPE.DOWN,v,"",f.KN.PC_PLOT),this.openedViewers.push(b);const A=this.getOutputNameForScatterPlot(p,d,r.length),C=1===r.length?s.Viewer.lineChart(d,this.getLineChartOpt(p)):s.Viewer.scatterPlot(d,this.getScatterOpt(p,A));this.openedViewers.push(C),this.comparisonView.dockManager.dock(C,s.DOCK_TYPE.DOWN,this.tableDockNode,"",f.KN.GRAPH);const w=t=>y(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),c=yield l.call(),d=[...c.outputParams.values()].filter((t=>s.TYPES_SCALAR.has(t.property.propertyType))),p=s.HtmlTable.create(d,(t=>{var e;return[null!==(e=t.property.caption)&&void 0!==e?e:t.property.name,c.outputs[t.property.name],t.property.options.units]})).root,h=[...c.outputParams.values()].filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME)).reduce(((t,e)=>{var n;const i=(0,u.jJ)(e.property).config,o=c.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 f,m;d.length>0?(m=1,f=Object.assign({"Output scalars":[p]},h)):(m=0,f=Object.assign({},h));const v=o.accordion();a()(v.root).css({width:"100%"}),Object.entries(f).map((t=>{v.addPane(t[0],(()=>o.divV(t[1])))})),v.panes[m].expanded=!0,i.shell.o=v.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")}}))}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 w.LAST_ROW:e=f.YU;break;case w.FIRST_ROW:e=f.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}}}},1521:(t,e,n)=>{"use strict";n.d(e,{PT:()=>y,RP:()=>b,vw:()=>v});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(3061),d=(n(8586),n(7973)),p=n(1599),h=n(810),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)})))())}}const v="ID";class g 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,h.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,p.qg)(t.func))&&void 0!==a?a:[]).map((e=>(0,p.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 y extends g{set value(t){this.setValue(t)}get value(){return this.getValue()}}class b extends g{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("-"):""}}},1599:(t,e,n)=>{"use strict";n.d(e,{$X:()=>ot,A4:()=>Y,BV:()=>S,Fd:()=>J,HP:()=>L,Hs:()=>M,JU:()=>K,KL:()=>j,LL:()=>T,Ne:()=>B,O0:()=>G,QL:()=>q,VI:()=>w,WM:()=>C,_t:()=>X,aB:()=>x,aK:()=>A,hg:()=>z,i:()=>_,jJ:()=>W,qg:()=>$,r6:()=>N,rs:()=>U,sy:()=>I,tf:()=>Z,u8:()=>V,vk:()=>F,wB:()=>nt,x$:()=>k,zF:()=>O});var i=n(4328),o=n(7389),s=n(6082),r=n(1757),a=n.n(r),l=n(1991),u=n.n(l),c=n(4260),d=n(9171),p=n(1899),h=n(3508),f=n.n(h),m=n(1521),v=n(810),g=n(5520),y=n(4778),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=(t,e,n,r)=>b(void 0,void 0,void 0,(function*(){var a,l;const u={},d=(t,e)=>{if(u[t])return u[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 u[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,u=window.html2canvas,p="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8",h=new t.Workbook;o.setDisplay(i.shell.v.root,!1),P(i.shell.v.root.parentElement,!0,"Generating report. Please do not switch the browser tab...");const f=(t,e,n,...r)=>b(void 0,[t,e,n,...r],void 0,(function*(t,e,n,r=0,a){var l,c,d,p;if(!e||!e.dataFrame)return;const f=s.Viewer.fromType(e.type,e.dataFrame.clone());f.copyViewersLook(e);const m=o.div(f.root,{style:{height:`${null!==(l=null==a?void 0:a.heightToRender)&&void 0!==l?l:800}px`,width:`${null!==(c=null==a?void 0:a.widthToRender)&&void 0!==c?c:800}px`}});m.classList.add("ui-box"),m.classList.remove("ui-div"),i.shell.v.root.insertAdjacentElement("afterend",m),yield(0,v.cb)(1e3);const g=(yield u(m)).toDataURL();m.remove();const y=h.addImage({base64:g,extension:"png"}),b=(null==a?void 0:a.heightInCells)||(null==a?void 0:a.widthInCells)?Math.min((null!==(d=null==a?void 0:a.heightInCells)&&void 0!==d?d:Number.MAX_VALUE)/40,(null!==(p=null==a?void 0:a.widthInCells)&&void 0!==p?p:Number.MAX_VALUE)/8):1;t.addImage(y,{tl:{col:n,row:r},ext:{width:800*b,height:800*b}})})),m=t=>s.TYPES_SCALAR.has(t),g=t=>t.propertyType===s.TYPE.DATA_FRAME,y=e.inputs.filter((t=>g(t))),A=e.inputs.filter((t=>m(t.propertyType))),C=e.outputs.filter((t=>g(t))),w=e.outputs.filter((t=>m(t.propertyType)));if(y.forEach((t=>{var e;const i=t.options.caption||t.name,o=null!==(e=h.worksheets.find((t=>t.name===d(i,h))))&&void 0!==e?e:h.addWorksheet(d(i,h)),s=n.inputs[t.name];et(o,s)})),A.length){const t=h.addWorksheet("Input scalars");Q(t,A.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(C.forEach((t=>{var e;const i=t.options.caption||t.name,o=null!==(e=h.worksheets.find((t=>t.name===d(i,h))))&&void 0!==e?e:h.addWorksheet(d(i,h)),s=n.outputs[t.name];et(o,s)})),w.length){const t=h.addWorksheet("Output scalars");Q(t,w.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=>g(t)))){const e=(null!==(a=r[t.name])&&void 0!==a?a:[]).filter((t=>t&&t.type!==s.VIEWER.GRID)).filter((t=>Object.values(c.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 f(h.getWorksheet(d(i,h)),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=>g(t)))){const e=(null!==(l=r[t.name])&&void 0!==l?l:[]).filter((t=>t&&t.type!==s.VIEWER.GRID)).filter((t=>Object.values(c.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))]);et(h.getWorksheet(d(i,h)),r,o.columns.length+2,t>0&&e[t-1]?Math.ceil(e[t-1].root.clientHeight/20)+1:0)}else yield f(h.getWorksheet(d(i,h)),n,o.columns.length+2,t>0?16*t+1:0,{heightInCells:16,heightToRender:600,widthToRender:600})}const I=yield h.xlsx.writeBuffer();return[new Blob([I],{type:p}),h]}catch(t){console.log(t)}finally{o.setDisplay(i.shell.v.root,!0),P(i.shell.v.root.parentElement,!1)}throw new Error("Format is not supported")})),C=(t,e)=>b(void 0,void 0,void 0,(function*(){const n=`${c.Jc}_${t.func.name}_Fav`;return e?i.dapi.userDataStorage.postValue(n,t.id,""):i.dapi.userDataStorage.remove(n,t.id)})),w=(t,e,n,s,r,l,u)=>{t.onCellPrepare((d=>{var p,h,f,g,y,A,C,w,I,T;if(d.isColHeader&&(null===(p=d.tableColumn)||void 0===p?void 0:p.name)&&[c.zY,c.d1,c.iL].includes(d.tableColumn.name)&&(d.customText=""),!d.isColHeader){if((null===(h=d.tableColumn)||void 0===h?void 0:h.name)===c.zY&&(d.customText="",d.element=o.divH([o.iconFA("trash",(()=>s(d)),"Remove run from history"),o.iconFA("edit",(()=>n(d)),"Edit run metadata")],{style:{padding:"6px",gap:"6px",justifyContent:"space-between"}})),(null===(f=d.tableColumn)||void 0===f?void 0:f.name)===c.iL){d.customText="";const t=o.iconFA("star",(()=>l(d)),"Unfavorite");a()(t).addClass("fas"),d.element=o.div(d.cell.value?t:o.iconFA("star",(()=>r(d)),"Favorite"),{style:{padding:"6px"}})}if((null===(g=d.tableColumn)||void 0===g?void 0:g.name)===c.d1){d.customText="";const t=o.iconFA("flask",null,"Experimental run");a()(t).addClass("fad fa-sm"),a()(t).removeClass("fal"),d.element=d.cell.value&&"Experimental"===d.cell.value?o.div(t,{style:{padding:"6px"}}):o.div()}if((null===(y=d.tableColumn)||void 0===y?void 0:y.name)===c.lv){d.customText="";const t=d.cell.value.length>0?o.div(null===(A=d.cell.value)||void 0===A?void 0:A.split(",").map((t=>o.span([t],"d4-tag"))),"d4-tag-editor"):o.div();a()(t).css({padding:"3px","background-color":"transparent"}),d.element=t}if((null===(C=d.tableColumn)||void 0===C?void 0:C.name)===m.vw){d.customText="";const p=(E=d.tableRowIndex,e.get(t.dataFrame.get(m.vw,E)));if(!p)return;const h=p.author.picture;a()(h).css({width:"25px",height:"25px",fontSize:"20px"}),o.bind(p.author,h);const f=o.iconFA("flask",null,"Experimental run");f.classList.add("fad","fa-sm"),f.classList.remove("fal"),f.style.marginLeft="3px";const g=p.options.immutable_tags,y=o.span([o.label(null!==(T=null!==(w=p.options.title)&&void 0!==w?w:null===(I=p.author)||void 0===I?void 0:I.friendlyName)&&void 0!==T?T:i.shell.user.friendlyName,{style:{color:"var(--blue-1)"}}),...g&&g.includes(c.ec)?[f]:[]]),A=o.iconFA("edit",(t=>{t.stopPropagation(),n(d)}),"Edit run metadata");A.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const C=o.iconFA("trash-alt",(t=>b(void 0,void 0,void 0,(function*(){t.stopPropagation(),s(d)}))),"Delete run");C.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const S=o.iconFA("star",(t=>{t.stopPropagation(),l(d)}),"Unfavorite");S.classList.add("fas","hp-funccall-card-icon");const x=o.iconFA("star",(t=>{t.stopPropagation(),r(d)}),"Favorite");x.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon"),(e=>t.dataFrame.get(c.iL,e))(d.tableRowIndex)?(o.setDisplay(x,!1),o.setDisplay(S,!0)):(o.setDisplay(S,!1),o.setDisplay(x,!0));const R=(0,v.eK)(p),O=o.divH([o.divH([h,o.divV([y,o.span([R]),...p.options.tags&&p.options.tags.length>0?[o.div(p.options.tags.map((t=>o.span([t],"d4-tag"))))]:[]],"hp-card-content")]),o.divH([...u?[S,x,A,C]:[]])],"hp-funccall-card"),L=d.tableRowIndex;O.addEventListener("mouseover",(()=>{d.grid.dataFrame.mouseOverRowIdx=L})),O.addEventListener("click",(t=>{t.shiftKey?d.grid.dataFrame.selection.set(L,!0):t.ctrlKey?d.grid.dataFrame.selection.set(L,!1):d.grid.dataFrame.currentRowIdx=L})),d.element=O}var E}}))},I=(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([c.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((t=>{const e=t.columns.byName(c.zY);e&&(e.cellType="html",e.width=45);const n=t.columns.byName(c.iL);n&&(n.cellType="html",n.width=30);const i=t.columns.byName(c.d1);i&&(i.cellType="html",i.width=30);const o=t.columns.byName(c.lv);o&&(o.cellType="html",o.width=90);const s=t.columns.byName(c.bV);s&&(s.width=110);const r=t.columns.byName(m.vw);r&&(r.cellType="html")})(t),e)t.columns.setVisible([m.vw]),t.props.rowHeight=70,t.invalidate();else{t.props.rowHeight=28;const e=t.dataFrame.getCol(c.lv);t.columns.setVisible([c.d1,c.iL,c.zY,...i?[c.bV]:[],...i?[c.l8]:[],...i&&e.stats.missingValueCount<e.length?[c.lv]:[],...i?[c.qh]:[],...i?[c.Ts]:[],...n&&o?U(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:E(i.name):E(t)})):[]])}},T=(t,e,n,i,s)=>{var r,a;const l=t.dataFrame,u=l.getCol(c.lv),d=[...e&&l.getCol(c.d1).categories.length>1?[c.d1]:[],...e&&(null!==(a=null===(r=l.col(c.iL))||void 0===r?void 0:r.categories.length)&&void 0!==a?a:0)>1?[c.iL]:[],...e?[c.bV,c.pC]:[],...e&&l.getCol(c.l8).categories.length>1?[c.l8]:[],...e&&u.stats.missingValueCount<u.length?[c.lv]:[],...e&&l.getCol(c.qh).categories.length>1?[c.qh]:[],...e&&l.getCol(c.Ts).categories.length>1?[c.Ts]:[],...s&&n?U(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:E(i.name):E(t)})).filter((t=>!i||l.getCol(t).categories.length>1)).map((t=>t)):[]];return d.length>0?(o.setDisplay(t.root,!0),t.setOptions({columnNames:d,showHeader:!1,showBoolCombinedFilter:!0})):o.setDisplay(t.root,!1),d.length>0},E=t=>H(t),S=(t,e,n)=>b(void 0,void 0,void 0,(function*(){var o;const r=[...t.values()],a=t=>t===c.bV?s.Column.dateTime(E(t),r.length).init((t=>window.grok_DayJs_To_DateTime(D(r[t])?r[t].started.utc(!0):f().unix(r[t].options.createdOn)))):t===c.pC?s.Column.bool(E(t),r.length).init((t=>!B(r[t]))):s.Column.fromStrings(E(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:V(e,t)}))),l=null!==(o=yield i.dapi.userDataStorage.get((t=>`${c.Jc}_${t.name}_Fav`)(e)))&&void 0!==o?o:{},u=Object.keys(l),d=s.DataFrame.fromColumns([s.Column.string(c.d1,r.length).init((t=>{const e=r[t].options.immutable_tags;return e&&e.includes(c.ec)?"Experimental":"Simulated"})),...(null==n?void 0:n.isHistory)?[s.Column.bool(c.iL,r.length).init((t=>u.includes(r[t].id)))]:[],...(null==n?void 0:n.showActions)?[s.Column.string(c.zY,r.length).init("")]:[],a(c.bV),a(c.pC),a(c.l8),s.Column.string(c.lv,r.length).init((t=>r[t].options.tags?r[t].options.tags.join(","):"")),s.Column.string(c.qh,r.length).init((t=>r[t].options.title)),s.Column.string(c.Ts,r.length).init((t=>r[t].options.description)),s.Column.string(c.aQ,r.length).init((t=>r[t].options.version))]);if(U(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:E(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:E(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:V(r[e],t.name)}))})(o):a(t)})(t))).forEach((t=>{t.name=d.columns.getUnusedName(t.name),d.columns.add(t,!1)})),d.columns.add(s.Column.fromStrings(m.vw,r.map((t=>t.id)))),!(null==n?void 0:n.allowOtherVersions)&&(null==n?void 0:n.version)){const t=s.BitSet.create(d.rowCount,(()=>!1));for(let e=0;e<d.rowCount;e++)(null==n?void 0:n.version)==d.get(c.aQ,e)&&t.set(e,!0);return d.clone(t)}return d})),x=t=>b(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))})),R=new s.LruCache,O=t=>b(void 0,void 0,void 0,(function*(){const e=t.options.help;if(!e)return null;if(R.get(t.id))return R.get(t.id);const n=`System:AppData/${e}`;if(yield i.dapi.files.exists(n)){const e=yield i.dapi.files.readAsText(n);return R.set(t.id,e),e}const o=`${i.shell.user.name}.home/${e}`;if(yield i.dapi.files.exists(o)){const e=yield i.dapi.files.readAsText(o);return R.set(t.id,e),e}return null})),L=t=>!!t.options.help,N=t=>{const e={inputs:{},outputs:{}};return t.inputs.filter((t=>t.propertyType===s.TYPE.DATA_FRAME&&0!==W(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===W(t).config.length||(e.outputs[n]?e.outputs[n].push(t):e.outputs[n]=[t])})),e},P=(t,e,n)=>{o.setUpdateIndicator(t,e);const i=t.querySelector(".d4-update-shadow .ui-label");e&&n&&i&&(i.textContent=n)},M=t=>b(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})),F=t=>"true"===t.options.runOnInput,_=t=>{var e;return JSON.parse(null!==(e=t.options.features)&&void 0!==e?e:"{}")},k=(t,e,n)=>{var i;return t instanceof Array?t.includes(e):t instanceof Object&&null!==(i=t[e])&&void 0!==i?i:n},B=t=>{var e;return(0,g.iu)(null!==(e=t.options[y.fj])&&void 0!==e?e:"false")||!D(t)||!t.id},D=t=>{try{return t.started}catch(t){return null}},V=(t,e)=>{var n,o,s,r,a,l,u;if(e===c.l8)return null!==(o=null===(n=t.author)||void 0===n?void 0:n.friendlyName)&&void 0!==o?o:i.shell.user.friendlyName;const d=null!==(l=null!==(a=null!==(r=null!==(s=t[e])&&void 0!==s?s:t.inputs[e])&&void 0!==r?r:t.outputs[e])&&void 0!==a?a:t.options[e])&&void 0!==l?l:null;return null!==(u=null==d?void 0:d.toString())&&void 0!==u?u:""},$=t=>t.options.mainParams?JSON.parse(t.options.mainParams):null,U=(t,e)=>{var n,i;return null!==(i=null!==(n=null==e?void 0:e.visibleProps)&&void 0!==n?n:$(t))&&void 0!==i?i:t.inputs.filter((t=>c.t6.includes(t.propertyType))).map((t=>t.name))},H=t=>t.replace(/([A-Z])/g,(t=>` ${t.toLowerCase()}`)).trim().replace(/^./,(t=>t.toUpperCase()));function j(t){const e=t;return e.dart&&s.toJs(e.dart)instanceof s.InputBase}const Y=t=>{const e=s.Func.byName(t.func.nqName).prepare();e.id=t.id,t.options.forEach((n=>e.options[n]=t.options[n]));const n=u()(e.outputParams.values()).filter((e=>null!=t.outputs[e.name]));for(const i of n)i.property.propertyType===s.TYPE.DATA_FRAME?e.outputs[i.name]=t.outputs[i.name].clone():e.outputs[i.name]=t.outputs[i.name];const i=u()(e.inputParams.values()).filter((e=>null!=t.inputs[e.name]));for(const n of i)n.property.propertyType===s.TYPE.DATA_FRAME?e.inputs[n.name]=t.inputs[n.name].clone():e.inputs[n.name]=t.inputs[n.name];return D(t)&&(e.started=t.started),e},W=t=>{const e=t.options[c.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 c.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:[]}},G=t=>t.options.runLabel,K=t=>{if((0,d.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")}},z=(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"})},q=(t,...e)=>b(void 0,[t,...e],void 0,(function*(t,e=c.bZ.INPUTS){const n=[...t[c.wl[e]].values()];return(yield Promise.all(n.filter((t=>!!t.property.options.validatorFunc)).map((t=>b(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)),{})})),J=(t,e)=>{const n=(0,p.JC)(e);return t[0].replaceWith(n[0]),t[1].replaceWith(n[1]),n},Z=(t,e,n,i,o,s)=>b(void 0,void 0,void 0,(function*(){const{view:r,funcCall:a,lastCall:l}=o,u=yield Promise.all(e.map((e=>b(void 0,void 0,void 0,(function*(){const o=i===c.bZ.INPUTS?a.inputs[e]:a.outputs[e],u=yield(0,p.Td)(o,{param:e,funcCall:a,lastCall:l,signal:n,isNewOutput:!!t.isNewOutput,isRevalidation:t.isRevalidation,view:r});let d;const h=s[e];h&&(d=yield h(o,{param:e,funcCall:a,lastCall:l,signal:n,isNewOutput:!!t.isNewOutput,isRevalidation:t.isRevalidation,context:t.context,view:r}));const f=i===c.bZ.INPUTS&&a.inputParams[e].property.options.nullable;return[e,(0,p.uD)(...f?[]:[u],d)]})))));return Object.fromEntries(u)})),X=t=>{const e=o.element("i");t.addOptions(e),t.setValidation=function(n){for(;e.firstChild&&e.removeChild(e.firstChild););const[i,o]=(0,p.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")}},Q=(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)};let tt=0;const et=(t,e,n,i)=>{if(!e)return;const o=t.getColumn(null!=n?n:1).letter,s={name:`ID_${tt.toString()}`,ref:`${o}${null!=i?i:1}`,columns:e.columns.toList().map((t=>({name:t.name,filterButton:!1}))),rows:new Array(e.rowCount).fill(0).map(((t,n)=>[...e.row(n).cells].map((t=>t.value))))};t.addTable(s),t.columns.forEach((t=>{t.width=25,t.alignment={wrapText:!0}})),tt++};function nt(t,e){return b(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 it(t,o,e)}return{inputs:n,outputs:t.outputs}}))}function it(t,e,n){return b(this,void 0,void 0,(function*(){return"file"===t.propertyType&&n.getInput?n.getInput(t.name).value.arrayBuffer():e}))}function ot(t,e){return b(this,void 0,void 0,(function*(){return"file"===t?new File([e],""):e}))}},1661:(t,e,n)=>{"use strict";n.d(e,{A:()=>i});const i={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)}},1757:t=>{"use strict";t.exports=$},1813:(t,e,n)=>{"use strict";n.d(e,{H:()=>o});var i=n(6067);class o{constructor(t){this.ivp=t,this.outputNames=(0,i.A)(t)}}},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.");t+="==".slice(2-(3&t.length));let e,n,i,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++)]),o+=64===n?a(e>>16&255):64===i?a(e>>16&255,e>>8&255):a(e>>16&255,e>>8&255,255&e);return o},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},1899:(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}},1927:(t,e,n)=>{"use strict";n(1294),n(3209),n(567),n(5669),n(5271)},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)}}}},2284:(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(9911),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},2610:(t,e,n)=>{"use strict";n.d(e,{b:()=>h,c:()=>f});var i=n(4328),o=n(32),s=n(4350),r=n(9713),a=n(1858),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())}))};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`)}))}},2797:(t,e,n)=>{"use strict";var i;n.d(e,{A:()=>s});var o=new Uint8Array(16);function s(){if(!i&&!(i="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(o)}},2947:(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"]}},2991:(t,e,n)=>{"use strict";Error},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}","",{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",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}"],sourceRoot:""}]);const a=r},3014:(t,e,n)=>{"use strict";n(8387),n(6950)},3031:(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(6362),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},3061:(t,e,n)=>{"use strict";n.d(e,{W:()=>i.W});var i=n(5092)},3209:(t,e,n)=>{"use strict";n(5669)},3296:(t,e,n)=>{"use strict";n(6082),n(1858)},3313:(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]])},3398:(t,e,n)=>{"use strict";n.d(e,{I3:()=>s.I3,a8:()=>s.a8,ak:()=>i.a,jd:()=>s.jd,lp:()=>s.lp,sg:()=>o.s,v_:()=>s.v_});var i=n(9524),o=n(9939),s=n(392)},3501:(t,e,n)=>{"use strict";n.d(e,{v:()=>p});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=n(1599),l=n(3061),u=n(9713),c=n(8804),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 p 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 d(this,void 0,void 0,(function*(){}))}onAfterSaveRun(t){return d(this,void 0,void 0,(function*(){}))}init(){return d(this,void 0,void 0,(function*(){const t=this.getStartId();if(t){this.setAsLoaded();const e=yield l.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 d(this,void 0,void 0,(function*(){yield this.getPackageData(),this.build()}))}saveRun(t){return d(this,void 0,void 0,(function*(){const e=(0,a.A4)(t);yield this.onBeforeSaveRun(e),e.id&&e.newId();const n=yield l.W.saveRun(e),i=yield l.W.loadRun(n.id);return this.linkFunccall(i),yield this.onAfterSaveRun(i),i}))}saveRunWithDialog(t){return d(this,void 0,void 0,(function*(){const e=c.V.forFuncCall(t);e.onMetadataEdit.pipe((0,u.take)(1)).subscribe((e=>d(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 d(this,void 0,void 0,(function*(){const e=yield l.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 d(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 d(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=()=>d(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=()=>d(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},3703:(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},3793:(t,e,n)=>{"use strict";n.d(e,{A:()=>i});var i,o=n(7745),s=n(1521),r=n(7747);!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={}))},3902:(t,e,n)=>{"use strict";n.d(e,{v:()=>x});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(5342),m=n(241),v=n(7722),g=n(1159),y=n(7320),b=n(4098),A=n(7591),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=s.Color.categoricalPalette,I=w.length,T=[s.TYPE.INT,s.TYPE.BIG_INT,s.TYPE.FLOAT,s.TYPE.DATA_FRAME];function E(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 S=()=>o.div([],"sa-switch-input");class x{static fromEmpty(t){return C(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.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?"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,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(S(),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=S(),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=>T.includes(t.propertyType))).reduce(((t,e)=>{const r=t=>{const e=E(a);return e.isValid?(a.argColInput.input.classList.remove("d4-invalid"),a.funcColsInput.input.classList.remove("d4-invalid"),o.tooltip.bind(a.argColInput.input,"Independent variable"),o.tooltip.bind(a.funcColsInput.input,"Target dependent variables"),null):(a.argColInput.input.classList.add("d4-invalid"),a.funcColsInput.input.classList.add("d4-invalid"),o.tooltip.bind(a.argColInput.input,e.msg),o.tooltip.bind(a.funcColsInput.input,e.msg),e.msg)},a={prop:e,input:(()=>{var t,r,l;const u=null!==(t=e.caption)&&void 0!==t?t:e.name,c=o.input.forProperty(e);c.addCaption(u),c.value=e.propertyType===s.TYPE.DATA_FRAME?null:0,c.setTooltip(e.propertyType===s.TYPE.DATA_FRAME?"Target dataframe":"Target scalar"),c.input.hidden=!this.toSetSwitched,c.nullable=!1,o.tooltip.bind(c.captionLabel,e.propertyType===s.TYPE.DATA_FRAME?"Dataframe":"Scalar"),null!=(null===(l=null===(r=this.options.targets)||void 0===r?void 0:r[e.name])||void 0===l?void 0:l.default)&&setTimeout((()=>{var t,n;return c.value=null===(n=null===(t=this.options.targets)||void 0===t?void 0:t[e.name])||void 0===n?void 0:n.default}),0),c.onChanged.subscribe((t=>{a.target=c.value;const n=()=>{a.argColInput.items=[null],a.argColInput.value=null,o.input.setColumnsInputTable(a.funcColsInput,i.data.demo.randomWalk(2,2),(t=>!1))};if(null===c.value)n();else if(e.propertyType===s.TYPE.DATA_FRAME)if(a.target){const t=[],e=[];for(const n of c.value.columns)n.isNumerical&&(t.push(n.name),e.push(n));t.length>1?(a.argColInput.items=t,a.argColInput.value=t[0],o.input.setColumnsInputTable(a.funcColsInput,c.value,(t=>t.isNumerical)),a.funcColsInput.value=e.slice(1)):(i.shell.warning(`Not enough of numerical columns: ${t.length}, expected: > 1`),n())}else n();this.updateApplicabilityState()})),e.propertyType===s.TYPE.DATA_FRAME&&(c.root.lastElementChild.hidden=!this.toSetSwitched);const d=n(this.toSetSwitched,(t=>{a.isInterest.next(t),this.updateApplicabilityState(),c.input.hidden=!t,e.propertyType===s.TYPE.DATA_FRAME&&(c.root.lastElementChild.hidden=!t,a.argColInput.root.hidden=!t,a.funcColsInput.root.hidden=!t)}),!1).root;return c.root.insertBefore(d,c.captionLabel),c})(),argName:"_",argColInput:(()=>{const t=o.input.choice("argument",{value:null,items:[null],tooltipText:"Independent variable",onValueChanged:t=>{a.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.root.hidden=e.propertyType!==s.TYPE.DATA_FRAME||!this.toSetSwitched,t.nullable=!1,t.addValidator(r),t})(),isInterest:new l.BehaviorSubject(this.toSetSwitched),target:e.propertyType!==s.TYPE.DATA_FRAME?0:null,funcColsInput:(()=>{const t=o.input.columns("functions",{nullable:!1,tooltipText:"Target dependent variables",onValueChanged:t=>this.updateApplicabilityState()});return t.root.insertBefore(S(),t.captionLabel),t.root.hidden=e.propertyType!==s.TYPE.DATA_FRAME||!this.toSetSwitched,this.toSetSwitched=!1,o.tooltip.bind(t.captionLabel,"Columns with values of target dependent variables:"),t.addValidator(r),t})()};return t[e.name]=a,t}),{})}},this.readyToRun=!1,this.isFittingRunning=!1,this.runIcon=o.iconFA("play",(()=>C(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",(()=>C(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.helpIcon=(0,v.VW)(),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.toSetSwitched=!0,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.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.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();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} - Fitting`,.25),this.comparisonView.grid.columns.byName("Run name").visible=!1,m.bj.forEach(((t,e)=>this.nelderMeadSettings.set(e,t.default)));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 minimizing the loss function"),this.lossInput.setTooltip(h.FM.get(this.loss)),o.tooltip.bind(this.lossInput.captionLabel,"Loss function type"),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 points to be found"),this.similarityInput.onChanged.subscribe((t=>{this.similarity=t,this.updateApplicabilityState()})),this.similarityInput.addCaption(h.ly.SIMILARITY),this.similarityInput.setTooltip("The higher the value, the fewer points will be found"),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}isOptimizationApplicable(t){for(const n of t.outputs)if((e=n).propertyType===s.TYPE.INT||e.propertyType===s.TYPE.FLOAT||e.propertyType===s.TYPE.DATA_FRAME)return!0;var e;return!1}generateNelderMeadSettingsInputs(){const t=[];m.bj.forEach(((e,n)=>{const i=o.input.forProperty(s.Property.fromOptions({name:m.df.get(n),inputType:"maxIter"!==n?"Float":"Int",defaultValue:e.default,min:e.min,max:e.max}));i.addCaption(m.df.get(n)),i.nullable=!1,i.onChanged.subscribe((t=>{this.nelderMeadSettings.set(n,t),this.updateApplicabilityState()})),t.push(i)})),this.settingsInputs.set(h.Mx.NELDER_MEAD,t)}areNelderMeadSettingsCorrect(){for(const[t,e]of this.nelderMeadSettings)if(null==e||e>m.bj.get(t).max||e<m.bj.get(t).min)return this.updateRunIconDisabledTooltip(`Invalid "${t}": check method settings`),!1;return!0}generateGradDescentSettingsInputs(){const t=o.input.forProperty(s.Property.fromOptions({name:"iterations",inputType:"Int",defaultValue:this.gradDescentSettings.iterCount,min:1,max:1e4}));t.onChanged.subscribe((t=>this.gradDescentSettings.iterCount=t));const e=o.input.forProperty(s.Property.fromOptions({name:"Learning rate",inputType:"Float",defaultValue:this.gradDescentSettings.learningRate,min:1e-6,max:1e3}));e.onChanged.subscribe((t=>this.gradDescentSettings.learningRate=t)),this.settingsInputs.set(h.Mx.GRAD_DESC,[t,e])}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 C(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,g.c)(t,e);return null!==n&&n.input.root.insertBefore(S(),n.input.captionLabel),n}))}buildForm(t){return C(this,void 0,void 0,(function*(){const e=o.h1(h.ly.FIT);o.tooltip.bind(e,"Select inputs to be fitted");const n=new Map([["Misc",[]]]);Object.values(this.store.inputs).forEach((t=>{const e=t.prop.category,i=[...t.constForm.map((t=>t.root)),...t.saForm.map((t=>t.root))];n.has(e)?n.get(e).push(...i):n.set(e,i)}));const i=o.div([e],{style:{overflowY:"scroll",width:"100%"}}),s=yield this.getLookupElement(t);let r=null;if(null!==s){const t=n.get(s.category);r=s.category,void 0!==t?n.set(r,[s.input.root].concat(t)):n.set(r,[s.input.root])}if(n.size>1){if(null!==r){const t=n.get(r);i.append((0,v.FB)(r,t)),i.append(...t)}if(n.forEach(((t,e)=>{"Misc"!==e&&e!==r&&(i.append((0,v.FB)(e,t)),i.append(...t))})),"Misc"!==r&&n.get("Misc").length>0){const t=n.get("Misc");i.append((0,v.FB)("Misc",t)),i.append(...t)}}else i.append(...n.get("Misc"));const l=o.h1(h.ly.TARGET);o.tooltip.bind(l,"Select target outputs"),i.appendChild(l);let u="Misc";Object.values(this.store.outputs).reduce(((t,e)=>{var n;const i=e.prop;return i.category!==u&&(t.append(o.h3(i.category)),u=i.category),t.append(e.input.root),e.argColInput.root.insertBefore((0,v.gw)(e.input.root,null!==(n=e.prop.caption)&&void 0!==n?n:e.prop.name),e.argColInput.captionLabel),t.append(e.argColInput.root),t.append(e.funcColsInput.root),t}),i);let c=!1;for(const t of Object.keys(this.store.outputs))if(!0===this.store.outputs[t].isInterest.value){c=!0;break}c||this.store.outputs[Object.keys(this.store.outputs)[0]].isInterest.next(!0);const d=o.h1("Using");o.tooltip.bind(d,"Specify fitting method"),i.appendChild(d),this.methodInput.root.insertBefore(this.fittingSettingsIcon,this.methodInput.captionLabel),this.fittingSettingsIcon.style.minWidth="50px",i.appendChild(this.methodInput.root);const p=o.h2("with settings");return o.tooltip.bind(p,(()=>`Settings of the ${this.method} method`)),this.fittingSettingsDiv.appendChild(p),this.generateSettingInputs(),this.showHideSettingInputs(),i.appendChild(this.fittingSettingsDiv),this.settingsInputs.forEach((t=>t.forEach((t=>{t.root.insertBefore(S(),t.captionLabel),this.fittingSettingsDiv.append(t.root)})))),[this.lossInput,this.samplesCountInput,this.similarityInput].forEach((t=>{t.root.insertBefore(S(),t.captionLabel),t.nullable=!1,i.appendChild(t.root)})),a()(i).addClass("ui-form"),this.updateApplicabilityState(),a()(i).css({"padding-left":"12px","overflow-y":"scroll","padding-right":"4px",position:"relative","z-index":"2","background-color":"white"}),i}))}updateRunIconDisabledTooltip(t){o.tooltip.bind(this.runIcon,(()=>{const e=o.label(t);return e.style.color="#FF0000",e}))}updateApplicabilityState(){this.readyToRun=this.canFittingBeRun()&&!this.isFittingRunning,this.updateRunIconStyle()}updateRunIconStyle(){this.readyToRun?(this.runIcon.style.color="var(--green-2)",o.tooltip.bind(this.runIcon,"Run fitting")):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 parameters for fitting selected"),n&&i}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=E(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))}runOptimization(){return C(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 Float32Array(r),c=new Float32Array(r),d=new Array(r);n.forEach(((t,e)=>{var n,i,o;const s=this.store.inputs[t];u[e]=null!==(n=s.min.value)&&void 0!==n?n:0,c[e]=null!==(i=s.max.value)&&void 0!==i?i:0,l.push(t),d[e]=null!==(o=s.prop.caption)&&void 0!==o?o:s.prop.name}));const m=this.getOutputsOfInterest();if(m.length<1)return void i.shell.error("No output is selected for optimization.");const g=m.map((t=>t.prop.propertyType)).filter((t=>t===s.TYPE.DATA_FRAME)).length>1,w=e=>C(this,void 0,void 0,(function*(){e.forEach(((e,n)=>t[l[n]]=e));const n=this.func.prepare(t);return yield n.call()})),I=e=>C(this,void 0,void 0,(function*(){e.forEach(((e,n)=>t[l[n]]=e));const n=this.func.prepare(t),i=yield n.call();let o=0,r=0,a=0;return m.forEach((t=>{if(t.prop.propertyType!==s.TYPE.DATA_FRAME)a=t.target,o+=Math.pow((a-i.getParamValue(t.prop.name))/(0!==a?a:1),2),++r;else{const e=t.target;(0,v.Yl)(e.col(t.argName),t.funcColsInput.value,i.getParamValue(t.prop.name),!0).forEach((t=>{o+=Math.pow(t,2),++r}))}})),Math.sqrt(o/r)})),T=e=>C(this,void 0,void 0,(function*(){e.forEach(((e,n)=>t[l[n]]=e));const n=this.func.prepare(t),i=yield n.call();let o=0;return m.forEach((t=>{if(t.prop.propertyType!==s.TYPE.DATA_FRAME)o=Math.max(o,Math.abs(t.target-i.getParamValue(t.prop.name)));else{const e=t.target;(0,v.Yl)(e.col(t.argName),t.funcColsInput.value,i.getParamValue(t.prop.name),!1).forEach((t=>o=Math.max(o,Math.abs(t))))}})),o}));let E,S,x;if(this.loss===h.YI.MAD?(E=T,S="scaled maximum absolute deviation"):(E=I,S="scaled root mean square error"),this.method!==h.Mx.NELDER_MEAD)throw new Error(`Not implemented the '${this.method}' method`);if(void 0!==this.diffGrok)try{const e=h.Wr.DIFF_STUDIO_OUTPUT;x=yield(0,y.t)(this.loss,this.diffGrok.ivp,this.diffGrok.ivpWW,this.diffGrok.pipelineCreator,this.nelderMeadSettings,l,u,c,t,m[e].argName,m[e].funcColsInput.value,m[e].target,this.samplesCount)}catch(t){x=yield(0,f.S)(E,u,c,this.nelderMeadSettings,this.samplesCount)}else x=yield(0,f.S)(E,u,c,this.nelderMeadSettings,this.samplesCount);const R=x.extremums,O=R.length;if(O<this.samplesCount){this.failsDF=x.fails;const t=this.failsDF.columns;d.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)))}))}R.sort(((t,e)=>t.cost-e.cost));const L=m.filter((t=>t.prop.propertyType===s.TYPE.DATA_FRAME)).map((t=>({name:t.prop.name,target:t.target,argColName:t.argName}))),N=yield(0,b.R9)(R,this.similarity,w,L),P=N.length;if(O<this.samplesCount){if(O<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 ${P} point${P>1?"s":""}`),o.div([this.showFailsBtn])]))}else i.shell.info(`Found ${P} point${P>1?"s":""}`);this.clearPrev();const M=new Float32Array(P),F=this.comparisonView.grid,_=new Map([[h.ly.LOSS,`The final loss obtained: ${S}`]]);N.forEach(((t,e)=>M[e]=t.cost));const k=s.DataFrame.fromColumns([s.Column.fromFloat32Array(h.ly.LOSS,M)]);this.comparisonView.dataFrame=k;const B=k.columns;d.forEach(((t,e,n)=>{t=B.getUnusedName(t),n[e]=t;const i=new Float32Array(P);for(let t=0;t<P;++t)i[t]=N[t].point[e];B.add(s.Column.fromFloat32Array(t,i)),_.set(t,`Obtained values of '${t}'`)})),F.props.rowHeight=h.VF.ROW_HEIGHT,F.props.showAddNewRowIcon=!1,F.props.allowEdit=!1;const D=new Array(P);for(let t=0;t<P;++t){const e=new Map,n=[],i=yield w(N[t].point);if(m.forEach((t=>{this.getOutputGofTable(t.prop,t.target,i,t.argName,g).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)}D[t]=e}D[0].forEach(((t,e)=>{B.addNew(e,s.COLUMN_TYPE.DATA_FRAME).init((t=>D[t].get(e).table)),_.set(e,"Goodness of fit");const n=F.columns.byName(e);n.cellType="html",n.width=h.VF.LOSS_GRAPH_WIDTH}));const V=B.getUnusedName(`${this.loss} by iterations`);_.set(V,`Minimizing ${S}`),B.addNew(V,s.COLUMN_TYPE.DATA_FRAME).init((t=>(0,v.e_)(N[t])));const $=F.columns.byName(V);$.cellType="html",$.width=h.VF.LOSS_GRAPH_WIDTH;let U=!1;D[0].forEach((t=>U||(U=t.table.columns.length>=h.Uk)));let H=!0;F.onCellPrepare((t=>C(this,void 0,void 0,(function*(){if(H&&(F.columns.setOrder(B.names().filter((t=>t!==V)).concat([V])),H=!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<P){const n=D[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(U){const e=o.divV([],{style:{height:`${h.VF.ROW_HEIGHT}px`}});o.tooltip.bind(e,(()=>(0,v.QR)())),t.style.element=e,setTimeout((()=>C(this,void 0,void 0,(function*(){const n=new A.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,v.uM)(t.cell.value)}})))),F.columns.byName(h.ly.LOSS).format="scientific",F.columns.byName(h.ly.LOSS).width=h.VF.LOSS_COL_WIDTH,F.onCellTooltip((function(t,e,n){if(t.isColHeader&&t.tableColumn){const i=t.tableColumn.name;if(i===h.o_.SCALARS&&U)o.tooltip.show((0,v.QR)(),e,n);else{const t=_.get(i);o.tooltip.show(null!=t?t:"",e,n)}return!0}})),k.currentCell=k.cell(0,h.ly.LOSS);const j=t=>C(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 w(N[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,p.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=F.onCellClick.subscribe(j),this.gridCellChangeSubscription=F.onCurrentCellChanged.subscribe(j)}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,m=r.clone(null,f.names());m.append(s.DataFrame.fromColumns(f.toList().map((t=>{const e=m.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=m.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=>{m.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);m.columns.add(s.Column.fromInt32Array(h.o_.SIZE,A));const C=r.columns.names().filter((t=>t!==i));return g.forEach((e=>{const n=`${h.o_.CATEGORY}_${e}`,r=m.col(n),a=C.indexOf(e)%I,l=w[a],c=s.Color.toRgb(l);r.colors.setCategorical({Simulation:l,Target:C.length>1?(0,v.ru)(c,h.SK.LIGHTER_PERC):w[a+1]}),t.push({caption:o?`${u}: [${e}]`:`[${e}]`,table:m,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;return s.Column.fromFloat32Array(null!==(e=m.df.get(t[0]))&&void 0!==e?e:t[0],new Float32Array([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.C)(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.X)(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}}},4044:(t,e,n)=>{"use strict";n.d(e,{AK:()=>i.AK,S3:()=>i.S3}),n(1927),n(9865),n(9421),n(3014);var i=n(8948)},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)}}}()},4204:(t,e,n)=>{"use strict";var i;n.d(e,{FM:()=>r,L7:()=>y,Mx:()=>i,Q9:()=>c,SK:()=>v,TR:()=>h,Uk:()=>b,VF:()=>a,Wr:()=>f,YI:()=>s,be:()=>p,fo:()=>d,h$:()=>o,ly:()=>l,nW:()=>g,o_:()=>m}),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"],[s.RMSE,"Root mean square error"]]);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="samples",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="`samples`",t.LOSS="`loss`",t.SIMILARITY="`similarity`"}(u||(u={})),function(t){t[t.MS_TO_SLEEP=10]="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. Specify the loss function type (in the ${u.LOSS} field).\n\n5. Enter the number of points to be found (in the ${u.SAMPLES} field).\n\n6. Set the maximum relative deviation (%) in the ${u.SIMILARITY} field. It defines the threshold for determining whether fitted points are similar.\n\n7. 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\n8. Open ${u.CONTEXT}. You will get the function run corresponding to the selected grid row.\n\n9. 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},4260:(t,e,n)=>{"use strict";n.d(e,{AY:()=>u,CB:()=>o,D:()=>v,Jc:()=>b,Jl:()=>c,L_:()=>m,NT:()=>l,Ts:()=>x,_W:()=>h,aQ:()=>O,bV:()=>E,bZ:()=>g,d1:()=>A,eP:()=>r,eX:()=>f,ec:()=>p,iL:()=>C,l8:()=>T,lv:()=>R,pC:()=>w,qh:()=>S,r0:()=>a,sk:()=>s,t6:()=>L,wl:()=>y,zY:()=>I});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="restrictedValues",c="editState";var d;!function(t){t.INPUT="Input",t.OUTPUT="Output"}(d||(d={}));const p="experimental",h="Run name",f="RunId";var m,v,g;!function(t){t.HIDDEN="hidden",t.VISIBLE="visible"}(m||(m={})),function(t){t.ENABLED="enabled",t.DISABLED="disabled"}(v||(v={})),function(t){t.INPUTS="inputs",t.OUTPUTS="outputs"}(g||(g={}));const y={[g.INPUTS]:"inputParams",[g.OUTPUTS]:"outputParams"},b="ModelStorage",A="Source",C="Is favorite",w="Is complete",I="Delete",T="Author",E="Date",S="Title",x="Desc.",R="Tags",O="Version",L=Object.values(i.COLUMN_TYPE).filter((t=>t!==i.TYPE.DATA_FRAME))},4328:t=>{"use strict";t.exports=grok},4350:(t,e,n)=>{"use strict";n.d(e,{SJ:()=>r});var i=n(6082);const o=[{name:"NaN",predicate:function(t,e){return Number.isNaN(t)&&Number.isNaN(e)},checker:a},{name:"Null",predicate:function(t,e){return null==t&&null==e},checker:a},{name:"Boolean",predicate:function(t,e){return"boolean"==typeof t&&"boolean"==typeof e},checker:l},{name:"String",predicate:function(t,e){return"string"==typeof t&&"string"==typeof e},checker:l},{name:"Integer",predicate:function(t,e){return Number.isInteger(t)&&Number.isInteger(e)},checker:l},{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=[];if(t.size!==e.size){const n={msg:`Maps are of different size: actual map size is ${t.size} and expected map size is ${e.size}`};o.push(n)}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 u(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:u},{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)}for(const n of e.columns){const s=t.columns.byName(n.name);if(s)if(s.type===n.type)for(let t=0;t<e.rowCount;t++){const e=s.get(t),o=n.get(t);i([n.name,String(t)],e,o)}else{const t={msg:`Column ${n.name} type expected ${n.type} got ${s.type}`};o.push(t)}else{const t={msg:`Column ${n.name} not found`};o.push(t)}}return o}},{name:"Object",predicate:function(t,e){return"object"==typeof t&&"object"==typeof e},checker:function(t,e,n,i){for(const[n,o]of Object.entries(e))i([n],t[n],o);return[]}}];class s extends Error{}function r(t,e,n){new d(n).run(t,e)}function a(){}function l(t,e){if(t!==e)return[{msg:`Expected ${e}, got ${t}`}]}function u(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}const c={floatTolerance:.001,maxErrorsReport:5,maxDepth:128,checkersSeq:o,prefix:""};class d{constructor(t={}){this.options=Object.assign(Object.assign({},c),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 s(`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 s(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")}}},4451:(t,e,n)=>{"use strict";n.d(e,{s:()=>T});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(3061),p=n(3793),h=n(4260),f=n(1599),m=n(8476),v=n(9713),g=n(5520),y=n(7745),b=n(2610),A=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())}))};const w=new URL(i.shell.startUri),I=()=>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 T 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,A.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:w.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===h.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);yield t.prepare({params:{defaultView:r}}).call()}}))}onSaveClick(){return C(this,void 0,void 0,(function*(){yield this.saveRun(this.funcCall)}))}buildHistoryBlock(){const t=p.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,A.ZD)(t.root,!0);const n=yield Promise.all(e.map((t=>d.W.loadRun(t))));yield this.onComparisonLaunch(n),(0,A.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,A.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,f.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,v.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",I),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,f.A4)(t);yield this.onBeforeSaveRun(e),(0,f.Ne)(e)&&(e=yield(0,f.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,f.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,f.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,f.wB)(this._lastCall,this);return(0,g.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 y.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,g.iu)(yield e.value.text());t?(yield this.executeTest(i,!0),yield this.isHistorical.pipe((0,v.filter)((t=>t)),(0,v.take)(1),(0,v.delay)(0)).toPromise(),yield this.getRunJSON()):yield this.executeTest(i)}))}executeTest(t){return C(this,arguments,void 0,(function*(t,e=!1){yield(0,b.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,f.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,f.HP)(this.func)}getContextHelp(){return C(this,void 0,void 0,(function*(){return(0,f.zF)(this.func)}))}get features(){return(0,f.i)(this.func)}getFeature(t,e){return(0,f.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)}}},4594:(t,e,n)=>{"use strict";n.d(e,{h:()=>s});var i=n(7149);class o{constructor(t=1,e=1){(0,i.C)(t),(0,i.C)(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(4044),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(3061),n(9046),n(5520),n(1599);const i="OUTPUT_OUTDATED"},4822:(t,e,n)=>{"use strict";n.d(e,{H:()=>o});var i=n(4451);class o extends i.s{}},4980:(t,e,n)=>{"use strict";n(6067),n(1813).H},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]));return 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)}))))),yield i.dapi.functions.calls.allPackageVersions().save(l)}))},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={}))},5104:(t,e,n)=>{"use strict";n.d(e,{E:()=>R});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(3793),m=n(1899),v=n(1599),g=n(4260),y=n(9171),b=(n(3031),n(4451)),A=n(1491),C=n(3902),w=n(810),I=n(3061),T=n(7973),E=n(7722),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())}))};const x=()=>o.divText("[No data to display]",{style:{"text-align":"center","align-content":"center",width:"100%",height:"100%"}});class R extends b.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=>S(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,v.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 S(this,void 0,void 0,(function*(){yield this.loadInputsOverrides(),yield this.loadValidators(g.bZ.INPUTS),yield this.loadValidators(g.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===g.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===g.bZ.INPUTS?this.setInputValidationResults(n):this.setOutputValidationResults(n),this.runRevalidations(e,n,t),t===g.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(g.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(g.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,v.O0)(this.func))&&void 0!==e?e:t,(()=>S(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 S(this,void 0,void 0,(function*(){const t=[...this.funcCall.inputParams.values()];yield Promise.all(t.map((t=>S(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 S(this,arguments,void 0,(function*(t=g.bZ.INPUTS){const e=yield(0,v.QL)(this.funcCall,t);t===g.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,(()=>S(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 S(this,void 0,void 0,(function*(){const t=()=>{const t=s.Dialog.create({title:"Select to compare"}),e=new T.H(u.length>0?u:[...this.historyBlock.history.values()],{fallbackText:"No historical runs found",showActions:!(u.length>0),showBatchActions:!(u.length>0)}),n=new T.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,(()=>S(this,void 0,void 0,(function*(){const i=yield Promise.all([...e.selected].map((t=>I.W.loadRun(t.id))));this.onComparisonLaunch([...i,...n.selected.values()]),t.close()})))):t.addButton(i,(()=>S(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(y,(()=>S(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 m="Save to history",y="Compare w/ current";c.add(r.root),c.addButton(m,(()=>S(this,void 0,void 0,(function*(){return(0,w.ZD)(c.root,!0),l.forEach((t=>{t.options.immutable_tags?t.options.immutable_tags.push(g.ec):t.options.immutable_tags=[g.ec]})),Promise.all(l.map((t=>S(this,void 0,void 0,(function*(){const e=yield this.getValidExpRun(t);return I.W.saveRun(e)}))))).then((t=>Promise.all(t.map((t=>I.W.loadRun(t.id)))))).then((t=>{t.forEach((t=>this.historyBlock.addRun(t)))})).catch((t=>{i.shell.error(t)})).finally((()=>{(0,w.ZD)(c.root,!1),c.close();const t=new T.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(g.ec):t.options.immutable_tags=[g.ec]}));const t=new T.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(m).disabled=!0,c.getButton("Next").disabled=!0,d()(f.getButton("CANCEL")).hide(),f.addButton("Simulate w/ same inputs",(()=>{(0,w.ZD)(c.root,!0),Promise.all(l.map((t=>S(this,void 0,void 0,(function*(){return(yield(0,v.Hs)(t)).call()}))))).then((e=>{u=e,f.close(),t().show({modal:!0,fullScreen:!0})})).catch((t=>{i.shell.error(t)})).finally((()=>{(0,w.ZD)(c.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,c.getButton(m).disabled=!1,c.getButton("Next").disabled=!1})),A=c.onClose.subscribe((()=>{this.isUploadMode.next(!1)}));c.subs.push(A,b),c.show({modal:!0,center:!0,resizable:!0})}))}onSaveClick(){return S(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",(()=>S(this,void 0,void 0,(function*(){return yield this.doRun()}))),"Run computations");t.classList.add("fas");const e=o.iconFA("arrow-to-top",(()=>S(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,E.LC)();n.onclick=()=>S(this,void 0,void 0,(function*(){return yield this.onSALaunch()}));const s=(0,E.MP)();s.onclick=()=>S(this,void 0,void 0,(function*(){return yield this.onFittingLaunch()}));const r=o.iconFA("info",(()=>S(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())))})))),a=[[...super.buildRibbonPanels().flat(),...this.runningOnInput||this.options.isTabbed?[]:[t],...this.hasUploadMode?[e]:[],...this.isFittingEnabled?[s]:[],...this.isSaEnabled?[n]:[],...!this.options.isTabbed&&this.hasContextHelp?[r]:[]]];return this.setRibbonPanels(a),a}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,v.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)=>S(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(g.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=x();return 0===u.rowCount&&"demog 0"===u.name&&(o.setDisplay(d.root,!1),o.setDisplay(p,!0)),{viewer:d,stub:p}})))),f=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((()=>S(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(g.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}})))),v=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=v,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=f.map(((t,n)=>{const i=l[r][n].block,s=o.wait((()=>S(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,m.JC)();return this.outputValidationSigns[e.name]=a,o.divV([o.divH([o.h2(0===n?v:" ",{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=x();i.classList.add("grok-scripting-image-container");const s=o.divV([o.h2(v,{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,m.JC)();this.outputValidationSigns[t.name]=e}));const f=()=>{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 y=f();const b=(0,p.merge)(this.funcCallReplaced,this.isRunning.pipe((0,h.filter)((t=>!1===t)),(0,h.skip)(1))).subscribe((()=>{const e=f();y.replaceWith(e),y=e,d()(this.tabsElem.getPane(t).header).show()}));this.subs.push(b),this.tabsElem.addPane(t,(()=>o.divV([...r.length?[c]:[],...a.length?[y]:[]])))}));const t=o.box();return t.append(this.tabsElem.root),t}onAfterLoadRun(t){return S(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,v.r6)(this.funcCall.func)}get inputsStorage(){return`RFV_LastInputs_${this.funcCall.func.name}`}saveLastInputs(){return S(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 S(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 S(this,void 0,void 0,(function*(){try{return localStorage.removeItem(this.inputsStorage)}catch(t){i.shell.error(t.toString())}}))}doRun(){return S(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[g.AY]=Object.assign(Object.assign({},this.funcCall.options[g.AY]),{[t]:e})),n&&(this.funcCall.options[g.Jl]=Object.assign(Object.assign({},this.funcCall.options[g.Jl]),{[t]:n})),this.updateConsistencyState()}getInputLockState(t){var e;return null===(e=this.funcCall.options[g.Jl])||void 0===e?void 0:e[t]}updateConsistencyState(){const t=Object.values(this.funcCall.options[g.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,y.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[g.AY])||void 0===e?void 0:e[t]}renderOutputForm(){return this.renderIOForm(g.bZ.OUTPUTS)}onSALaunch(){return S(this,void 0,void 0,(function*(){yield A.n.fromEmpty(this.func)}))}onFittingLaunch(){return S(this,void 0,void 0,(function*(){yield C.v.fromEmpty(this.func)}))}renderInputForm(){return this.renderIOForm(g.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[g.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===g.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,v.KL)(e)&&d()(e.input).is(":focus")&&this.saveFocusedElement(e.input),e.enabled=!1):(e.enabled=!0,(0,v.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,w.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,w.Bu)(i),items:JSON.parse(i.options.choices),nullable:i.nullable});switch(i.propertyType){case"file":return f.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,v.KL)(t)&&(t.input.onkeydown=t=>S(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,v.JU)(n),(0,v.KL)(n)&&((0,v.hg)(e,n),this.bindTooltips(e,n),(0,v._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,v.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[g.wl[n]][i],r=null!==(o=null!==(t=this.funcCall[n][i])&&void 0!==t?t:(0,w.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[g.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===g.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[g.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===g.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,v.KL)(e)?e.onInput:(0,w.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,m.Aw)(e))return!1;for(const[t,e]of Object.entries(this.externalValidatorsState))if(!(0,m.Aw)(e))return!1;return!0}getValidationState(){return this.inputValidationState}getValidationMessage(){const t=[];for(const[e,n]of Object.entries(this.inputValidationState))(0,m.Aw)(n)||t.push(`${e}: ${(0,m.u1)(n)}`);return t.join("\n")}runValidation(t,e){return S(this,arguments,void 0,(function*(t,e,n=g.bZ.INPUTS){const i=t.field,o=this.getValidatedNames(i,n);return(0,v.tf)(t,o,e,n,{view:this,funcCall:this.funcCall,lastCall:this.lastCall},n===g.bZ.INPUTS?this.inputValidators:this.outputValidators)}))}setInputValidationPending(t){const e=this.getValidatedNames(t);for(const t of e){this.inputValidationState[t]=(0,m.Ur)();const e=this.inputsMap[t];(0,y.LB)(e)&&e.setValidation((0,m.Ur)())}this.inputValidationUpdates.next(null)}setOutputValidationPending(t){const e=this.getValidatedNames(t,g.bZ.OUTPUTS);for(const t of e){this.outputValidationState[t]=(0,m.Ur)();const e=this.outputValidationSigns[t];if(e){const n=(0,m.JC)((0,m.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,v.Fd)(n,e))}updateInputValidationResults(t){const e=(0,m.uD)(this.inputValidationState[t],this.externalValidatorsState[t]),n=this.inputsMap[t];(0,y.LB)(n)&&n.setValidation(e)}runRevalidations(t,e,n=g.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===g.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=g.bZ.INPUTS){return t?[t]:[...e===g.bZ.INPUTS?this.funcCall.inputs.keys():this.funcCall.outputs.keys()]}getValidExpRun(t){return S(this,void 0,void 0,(function*(){t.started=a()();const e=t.options.immutable_tags||[];return t.options.immutable_tags=e.includes(g.ec)?e:[...e,g.ec],t.newId(),t}))}saveExperimentalRun(t){return S(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"}}}},5174:(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"]}},5255:(t,e,n)=>{"use strict";n.d(e,{N:()=>i,y:()=>o});class i extends Error{constructor(t){super(t)}}function o(t){return new Promise(((e,n)=>setTimeout(e,t)))}},5271:(t,e,n)=>{"use strict";n(265),n(6296)},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(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,u){return l(this,arguments,void 0,(function*(t,e,n,l,u=1){const c=(0,r.B)(u,n,e),d=[],p=[],h=[];let f,m=0,v=null,g=0;const y=i.TaskBarProgressIndicator.create(`Fitting... (${g}%)`);for(f=0;f<u;++f)try{if(d.push(yield(0,s.tB)(t,c[f],l,e,n)),y.update(100*(f+1)/u,"Fitting..."),g=Math.floor(100*(f+1)/u),y.update(g,`Fitting... (${g}%)`),yield(0,o.y)(a.Q9.MS_TO_SLEEP),y.canceled)break}catch(t){if(y.close(),t instanceof o.N)throw new Error(`Inconsistent dataframes: ${t.message}`);++m,p.push(t instanceof Error?t.message:"Platform issue"),h.push(c[f])}if(y.close(),m>0){const t=n.length,e=new Array(t);for(let n=0;n<t;++n)e[n]=new Float32Array(m);h.forEach(((t,n)=>t.forEach(((t,i)=>e[i][n]=t)))),v=i.DataFrame.fromColumns(e.map(((t,e)=>i.Column.fromFloat32Array(`arg${e}`,t)))),v.columns.add(i.Column.fromStrings("Issue",p))}return{extremums:d,fails:v}}))}},5460:(t,e,n)=>{"use strict";n.d(e,{A:()=>r});var i=n(1661),o=n(2797),s=n(8333);const r=function(t,e,n){if(i.A.randomUUID&&!e&&!t)return i.A.randomUUID();var r=(t=t||{}).random||(t.rng||o.A)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){n=n||0;for(var a=0;a<16;++a)e[n+a]=r[a];return e}return(0,s.k)(r)}},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:()=>a,lK:()=>r});var i=n(6082),o=n(1825);const s="_DG_CUSTOM_SERIALIZED_TOKEN_";function r(t,e={}){return JSON.stringify(t,((t,n)=>n===1/0?{[s]:"Infinity",value:!0}:n===-1/0?{[s]:"-Infinity",value:!0}:Number.isNaN(n)?{[s]:"NaN",value:!0}:n instanceof i.DataFrame&&!e.useJsonDF?{[s]:"DataFrame",value:(0,o.SM)(n.toByteArray())}:n instanceof i.DataFrame&&e.useJsonDF?{[s]:"DataFrameJSON",value:n.toJson()}:n instanceof ArrayBuffer?{[s]:"ArrayBuffer",value:(0,o.SM)(new Uint8Array(n))}:n instanceof Map?{[s]:"Map",value:Array.from(n)}:n instanceof Set?{[s]:"Set",value:Array.from(n)}:n),e.space)}function a(t){return JSON.parse(t,l)}function l(t,e){if(e&&e[s]&&e.value)switch(e[s]){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"Set":return new Set(e.value);case"Infinity":return 1/0;case"-Infinity":return-1/0;case"NaN":return NaN}return e}},5565:(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"]}},5587:(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"]}},5669:(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={}))},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(4044),n(241),n(8384),n(4204)},5933:(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/function-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},6067:(t,e,n)=>{"use strict";n.d(e,{A:()=>l,b:()=>r});var i=n(6314),o=n(3313);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}},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="Rationale",r="Count",u="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.fromStrings(n,Array.from({length:t.rowCount},(()=>""))));const c=()=>s.DataFrame.fromColumns([s.Column.fromStrings(n,[]),s.Column.fromInt32Array(r,new Int32Array([])),s.Column.fromStrings("Actions",[]),s.Column.fromBitSet(u,s.BitSet.create(0,(()=>!1)))]),d=s.Viewer.grid(c());d.root.style.width="100%",d.root.style.minWidth="230px",d.columns.setVisible([n,r,"Actions"]),this.root.append(o.divV([o.divV([d.root],{style:{height:"75%"}})],{style:{height:"100%"}}));const p=()=>{var i,o,r,u;if(!d.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===(r=t.col(e))||void 0===r||r.meta.colors.setCategorical({Outlier:s.Color.scatterPlotMarker,Inlier:s.Color.scatterPlotMarker,"Last Inlier":s.Color.red});const c=null===(u=d.dataFrame)||void 0===u?void 0:u.cell(d.dataFrame.rowCount-1,n).value;t.selection.getSelectedIndexes().forEach((i=>{t.col(e).set(i,"Outlier",!1),t.col(n).set(i,c,!1)})),t.selection.setAll(!1),t.fireValuesChanged(),a()(l()).empty()},h=()=>{d.dataFrame&&(d.dataFrame.rows.removeAt(d.dataFrame.rowCount-1),t.selection.setAll(!1),a()(l()).empty())};d.onCellPrepare((i=>{var s,r,a;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(u,i.gridRow))?[(a=null===(r=i.grid.dataFrame)||void 0===r?void 0:r.get(n,i.gridRow),o.div(o.icons.delete((()=>{for(let i=0;i<t.rowCount;i++)t.columns.byName(n).get(i)===a&&(t.columns.byName(n).set(i,"",!1),t.columns.byName(e).set(i,"Inlier",!1));t.fireValuesChanged()}),"Remove the outliers group"),{style:{textAlign:"center",margin:"6px"}}))]:[o.div(o.iconFA("check",p,"Confirm the outliers"),{style:{textAlign:"center",margin:"6px"}}),o.div(o.iconFA("times",h,"Cancel the outliers"),{style:{textAlign:"center",margin:"6px"}})]])))})),d.onCellValueEdited.subscribe((e=>{var i,o;if(!d.dataFrame||e.gridColumn.name!==n)return;if(!d.dataFrame.columns.byName(u).get(e.gridRow))return;const s=new Set;for(let t=0;t<(null===(i=d.dataFrame)||void 0===i?void 0:i.rowCount);t++){const e=null===(o=d.dataFrame)||void 0===o?void 0:o.columns.byName(n).get(t);s.add(e)}for(let i=0;i<t.rowCount;i++){const o=t.columns.byName(n).get(i);""==o||s.has(o)||t.columns.byName(n).set(i,e.cell.value)}}));const f=()=>{if(t.columns.byName(n))for(let i=0;i<t.rowCount;i++)"Outlier"===t.columns.byName(e).get(i)?""===t.columns.byName(n).get(i)&&t.columns.byName(n).set(i,"Manual",!1):""!==t.columns.byName(n).get(i)&&t.columns.byName(n).set(i,"",!1);const i={};if(t.columns.byName(n))for(let e=0;e<t.rowCount;e++){const o=t.columns.byName(n).get(e),s=i[o];""!=o&&(s?i[o]++:i[o]=1)}d.dataFrame=c(),d.columns.setVisible([n,r,"Actions"]),Object.keys(i).map((t=>{var e;null===(e=d.dataFrame)||void 0===e||e.rows.addNew([t,i[t],"",!0])}))};t.onDataChanged.subscribe(f),t.onSelectionChanged.subscribe((()=>{if(!d.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",p),o.button("Cancel",h)])])),d.dataFrame.columns.byName(u).toList().some((t=>!1===t)))d.dataFrame.set(r,d.dataFrame.rowCount-1,t.selection.trueCount);else{const e=d.dataFrame.rows.addNew(["Manual",t.selection.trueCount,"",!1]);d.dataFrame.currentCell=d.dataFrame.cell(e.idx,n)}})),t.selection.setAll(!1),f()}}},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 C=y(b,9,0),w=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=L(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 C=a[s].s;m[C]<e?g-=1<<e-m[C]++-1:++s}for(;s>=0&&g;--s){var w=a[s].s;m[w]==e&&(--m[w],++g)}v=e}return[new i(m),v]},L=function(t,e,n){return-1==t.s?Math.max(L(t.l,e,n+1),L(t.r,e,n+1)):e[t.s]=n},N=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]},P=function(t,e){for(var n=0,i=0;i<e.length;++i)n+=t[i]*e[i];return n},M=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)},F=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=N(v),L=S[0],F=S[1],_=N(T),k=_[0],B=_[1],D=new o(19),V=0;V<L.length;++V)D[31&L[V]]++;for(V=0;V<k.length;++V)D[31&k[V]]++;for(var $=O(D,7),U=$[0],H=$[1],j=19;j>4&&!U[l[j-1]];--j);var Y,W,G,K,z=h+5<<3,q=P(s,b)+P(u,A)+c,J=P(s,v)+P(u,T)+c+14+3*j+P(D,U)+(2*D[16]+3*D[17]+7*D[18]);if(z<=q&&z<=J)return M(e,f,t.subarray(p,p+h));if(x(e,f,1+(J<q)),f+=2,J<q){Y=y(v,g,0),W=v,G=y(T,E,0),K=T;var Z=y(U,H,0);for(x(e,f,F-257),x(e,f+5,B-1),x(e,f+10,j-4),f+=14,V=0;V<j;++V)x(e,f+3*V,U[l[V]]);f+=3*j;for(var X=[L,k],Q=0;Q<2;++Q){var tt=X[Q];for(V=0;V<tt.length;++V){var et=31&tt[V];x(e,f,Z[et]),f+=U[et],et>15&&(x(e,f,tt[V]>>>5&127),f+=tt[V]>>>12)}}}else Y=C,W=b,G=w,K=A;for(V=0;V<d;++V)if(i[V]>255){et=i[V]>>>18&31,R(e,f,Y[et+257]),f+=W[et+257],et>7&&(x(e,f,i[V]>>>23&31),f+=r[et]);var nt=31&i[V];R(e,f,G[nt]),f+=K[nt],nt>3&&(R(e,f,i[V]>>>5&8191),f+=a[nt])}else R(e,f,Y[i[V]]),f+=W[i[V]];return R(e,f,Y[256]),f+W[256]},_=new s([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),k=new i(0),B=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=B[255&n^e[i]]^n>>>8;t=n},d:function(){return~t}}},V=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=M(m,v+1,t.subarray(g,y))}else{for(var b=_[e-1],A=b>>>13,C=8191&b,w=(1<<n)-1,E=new o(32768),S=new o(w+1),x=Math.ceil(n/3),R=2*x,O=function(e){return(t[e]^t[e+1]<<x^t[e+2]<<R)&w},L=new s(25e3),N=new o(288),P=new o(32),B=0,D=0,V=(g=0,0),$=0,U=0;g<d;++g){var H=O(g),j=32767&g,Y=S[H];if(E[j]=Y,S[H]=j,$<=g){var W=d-g;if((B>7e3||V>24576)&&W>423){v=F(t,m,0,L,N,P,D,V,U,g-U,v),V=B=D=0,U=g;for(var G=0;G<286;++G)N[G]=0;for(G=0;G<30;++G)P[G]=0}var K=2,z=0,q=C,J=j-Y&32767;if(W>2&&H==O(g-J))for(var Z=Math.min(A,W)-1,X=Math.min(32767,g),Q=Math.min(258,W);J<=X&&--q&&j!=Y;){if(t[g+K]==t[g+K-J]){for(var tt=0;tt<Q&&t[g+tt]==t[g+tt-J];++tt);if(tt>K){if(K=tt,z=J,tt>Z)break;var et=Math.min(J,tt-2),nt=0;for(G=0;G<et;++G){var it=g-J+G+32768&32767,ot=it-E[it]+32768&32767;ot>nt&&(nt=ot,Y=it)}}}J+=(j=Y)-(Y=E[j])+32768&32767}if(z){L[V++]=268435456|p[K]<<18|f[z];var st=31&p[K],rt=31&f[z];D+=r[st]+a[rt],++N[257+st],++P[rt],$=g+K,++B}else L[V++]=t[g],++N[t[g]]}}v=F(t,m,c,L,N,P,D,V,U,g-U,v),!c&&7&v&&(v=M(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 H(t,e){return V(t,e||{},0,0)}var j=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],j(r,a,n,o))}},Y="undefined"!=typeof TextEncoder&&new TextEncoder,W="undefined"!=typeof TextDecoder&&new TextDecoder;try{W.decode(k,{stream:!0})}catch(t){}function G(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(Y)return Y.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 K=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},z=function(t,e,n,i,o,s,r,a){var l=i.length,u=n.extra,c=a&&a.length,d=K(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},q=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=[];j(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=G(a)).length,h=c.comment,f=h&&G(h),m=f&&f.length,v=K(c.extra);p>65535&&S(11);var g=d?H(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),C=s,w=r-s,I=0;I<o.length;++I){var T=o[I];z(A,T.o,T,T.f,T.u,T.c.length);var E=30+T.f.length+K(T.extra);A.set(T.c,T.o+E),z(A,s,T,T.f,T.u,T.c.length,T.o,T.m),s+=16+E+(T.m?T.m.length:0)}return q(A,s,o.length,w,C),A}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout},6296:(t,e,n)=>{"use strict";var i=n(9467);n(5669),i.Y},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.X)(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}}},6314:(t,e,n)=>{"use strict";n.d(e,{Yv:()=>s,bc:()=>i,nH:()=>o}),n(7788),n(2991);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={}))},6362:(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/function-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},6950:(t,e,n)=>{"use strict";n(1927),n(8387)},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"},7031:(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,C=i.K2*s*a,w=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,L=i.K11*f,N=i.K12*p*s,P=i.K13*m,M=i.K14*o*u,F=i.K15*r,_=i.K16*a,k=i.K17*a,B=i.K18*v,D=i.K19*v,V=i.K20*g*u,$=i.K21*y,U=i.K22*y,H=i.K23*o*a,j=i.K24*y*o,Y=i.K25*b;n[0]=-(A+O+M+H+j)+(C+w+R+L+N+U+Y),n[1]=-C-w-R-N+A+$,n[2]=-F+A+k+D+U,n[3]=-C-_-k-H+F,n[4]=2*I-w+E+S+P+V,n[5]=-E-x-M-V+w+2*B,n[6]=-I-T-E+P,n[7]=I+T+E+S,n[8]=-S-x,n[9]=-N+S+R,n[10]=-R-O+x+L,n[11]=R,n[12]=-L+O,n[13]=-P+N,n[14]=M,n[15]=-B-D+_,n[16]=-V,n[17]=V,n[18]=-$-U-j+H+Y,n[19]=-Y+j},tolerance:1e-6,solutionColNames:["y1","y2","y3","y4","y5","y6","y7","y8","y9","y10","y11","y12","y13","y14","y15","y16","y17","y18","y19","y20"]}},7134:(t,e,n)=>{},7149:(t,e,n)=>{"use strict";n.d(e,{C:()=>l,X:()=>u});var i,o,s=n(6082),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(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 a=t=>new Promise(((e,n)=>setTimeout(e,t)));function l(t){if(!Number.isInteger(t))throw new Error(i.INCORRECT_SIZE_TYPE);if(t<1)throw new Error(i.SIZE_MUST_BE_POSITIVE)}function u(t){return r(this,void 0,void 0,(function*(){const e=[],n=s.TaskBarProgressIndicator.create("Analyzing...");n.cancelable=!0;let i=0;const r=t.length;let l=0;for(let s=0;s<r&&(e.push(yield t[s].call()),1===s&&(l=Math.floor(100*s/r),n.update(l,`Analyzing... (${l}%)`),yield a(10*o.MS_TO_SLEEP)),++i,!n.canceled);++s)i>=o.BATCH_SIZE&&(l=Math.floor(100*s/r),n.update(l,`Analyzing... (${l}%)`),yield a(o.MS_TO_SLEEP),i=0);return n.close(),e}))}},7160:(t,e,n)=>{"use strict";n(3014),n(4980),n(8084),n(8511)},7294:(t,e,n)=>{"use strict";n.d(e,{Ad:()=>o.A,Ee:()=>i.Ee,HJ:()=>i.HJ,uf:()=>i.uf,vs:()=>i.vs});var i=n(32),o=(n(5092),n(3793));n(1899),n(9732)},7320:(t,e,n)=>{"use strict";n.d(e,{t:()=>c});var i=n(6082),o=n(4044),s=n(8384),r=n(7395),a=n(5925),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){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 Float32Array(n);t.forEach(((t,e)=>t.forEach(((t,n)=>s[n][e]=t))));const r=i.DataFrame.fromColumns(s.map(((t,e)=>i.Column.fromFloat32Array(`arg${e}`,t))));return r.columns.add(i.Column.fromStrings("Issue",e)),r}return null}function c(t,e,c,d,p,h,f,m,v,g,y,b,A){return l(this,void 0,void 0,(function*(){const l=[...p.keys()],C=l.map((t=>{var e;return null!==(e=p.get(t))&&void 0!==e?e:s.PJ})),w=Object.keys(v),I=Object.values(v),T=b.columns,E=y.length+1,S=b.rowCount;if(E<s.Pd)throw new Error(`Not enough of target columns: ${E}. Minimum: ${s.Pd}`);const x=[g].concat(y.map((t=>t.name))),R=new Float64Array(E),O=x.map(((t,e)=>{const n=T.byName(t),i=Math.max(Math.abs(n.stats.max),Math.abs(n.stats.min));R[e]=i>0?i:1;const o=new Float64Array(S),s=n.getRawData();for(let t=0;t<S;++t)o[t]=s[t];return o})),L=[`_${e.arg.name}0`,`_${e.arg.name}1`,"_h"].concat(e.deqs.solutionNames),N=(0,r.B)(A,f,m),P=Math.min(Math.max(s.j2,navigator.hardwareConcurrency-s.fK),A),M=new Array(P).fill(null).map((t=>new Worker(new URL(n.p+n.u(148),n.b)))),F=[],_=[],k=[],B=(0,a.d6)(N,P),D=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)}(h,f,m,v,e),V=d.getPipeline(D);let $=0,U=0;const H=i.TaskBarProgressIndicator.create(`Fitting... (${U}%)`),j=M.map(((n,i)=>new Promise(((r,a)=>{n.postMessage({task:{settingNames:l,settingVals:C,loss:t,ivp2ww:c,pipeline:V,nonParamNames:L,fixedInputsNames:w,fixedInputsVals:I,variedInputNames:h,variedInpMin:f,variedInpMax:m,targetNames:x,targetVals:O,scaleVals:R,samplesCount:A,outputNames:(0,o.AK)(e)},startPoints:B[i]}),n.onmessage=t=>{var e;n.terminate(),++$,U=Math.floor(100*($+1)/P),U<99.9?H.update(U,`Fitting... (${U}%)`):H.update(U,"Fitting... (100%)"),t.data.callResult===s.OW.SUCCEED?(t.data.extremums.forEach((t=>F.push(t))),t.data.fitRes.forEach(((t,e)=>{t!==s.Un&&(_.push(B[i][e]),k.push(t))})),r()):a(null!==(e=t.data.msg)&&void 0!==e?e:"error in webworker fitting")},n.onerror=t=>{n.terminate(),console.error(t),a(t)}}))));return yield Promise.all(j),H.close(),{extremums:F,fails:u(_,k)}}))}},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";function i(t,e,n){const i=e-n,o=new Array(t);for(let e=0;e<t;e++){const t=Math.random();o[e]=n+t*i}return o}function o(t,e,n){const o=e.length,s=new Array(t);for(let e=0;e<t;e++)s[e]=new Float32Array(o);for(let r=0;r<o;r++)if(e[r]===n[r])for(let n=0;n<t;n++)s[n][r]=e[r];else{const o=i(t,e[r],n[r]);for(let e=0;e<t;e++)s[e][r]=o[e]}return s}n.d(e,{B:()=>o})},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.C)(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.X)(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,{FB:()=>u,LC:()=>h,MP:()=>p,QR:()=>y,VW:()=>d,Yl:()=>l,e_:()=>f,gw:()=>c,ru:()=>v,uM:()=>g});var i=n(4328),o=n(7389),s=n(6082),r=n(5255),a=(n(9530),n(8870),n(4204));function l(t,e,n,i){if(null===t)throw new r.N("no argument column in the target output dataframe");const o=t.name,s=n.col(o);if(null===s)throw new r.N(`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.N(`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 u(t,e){const n=t=>{i.hidden=t,s.hidden=!t,e.forEach((e=>e.hidden=!t))},i=o.iconFA("chevron-right",(()=>n(!0)),"Open category");i.classList.add("fit-view-chevron-right"),i.hidden=!0;const s=o.iconFA("chevron-down",(()=>n(!1)),"Close category");return s.classList.add("fit-view-chevron-down"),o.divH([i,s,o.label(t)],"fit-view-inputs-category")}function c(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 d(){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 p(){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 h(){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 f(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 m(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 v(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 g(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 y(){const t=s.Color.categoricalPalette,e=o.label(a.o_.SIMULATION);e.style.color=m(s.Color.toRgb(t[a.Wr.BLUE]));const n=o.label(a.o_.TARGET);return n.style.color=m(s.Color.toRgb(t[a.Wr.ORANGE])),o.divV([e,n])}},7745:(t,e,n)=>{"use strict";n.d(e,{R:()=>a,z:()=>l});var i=n(7389),o=n(6082),s=n(1858),r=(n(2284),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)}}},7747:(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(3061),l=(n(8480),n(7973)),u=n(9713);class c extends s.Widget{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()}}},7778:(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(5933),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},7788:(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}]])},7973:(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(3061),h=n(8804),f=n(4260),m=n(1521),v=n(1599),g=n(3508),y=n.n(g),b=n(4112),A=n.n(b),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())}))};y().extend(A());const w=new s.LruCache;class I extends s.Widget{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(m.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(m.vw,t))}showEditDialog(t,e){const n=h.V.forFuncCall(t,e);n.onMetadataEdit.pipe((0,d.take)(1)).subscribe((n=>C(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,v.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,g,y,b,A;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(f.d1,0),...(null===(n=this.options)||void 0===n?void 0:n.isHistory)?[s.Column.bool(f.iL,0)]:[],...(null===(r=this.options)||void 0===r?void 0:r.showActions)?[s.Column.string(f.zY,0)]:[],s.Column.bool(f.pC,0),s.Column.dateTime(f.bV,0),s.Column.string(f.l8,0),s.Column.string(f.lv,0),s.Column.string(f.qh,0),s.Column.string(f.Ts,0),s.Column.fromStrings(m.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!==(g=null===(l=this.options)||void 0===l?void 0:l.fallbackText)&&void 0!==g?g:"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 h.C(e);n.onFuncCallDelete.pipe((0,d.take)(1)).subscribe((t=>C(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{yield Promise.all(a()(t.values()).map((t=>C(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",(()=>C(this,void 0,void 0,(function*(){const t=this.currentDf.selection.getSelectedIndexes(),e=[];t.forEach((t=>{e.push(this.currentDf.getCol(m.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!==(b=null===(y=this.options)||void 0===y?void 0:y.isHistory)&&void 0!==b&&b),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=>C(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=>C(this,void 0,void 0,(function*(){if(w.has(t.id))return w.get(t.id);{const e=yield p.W.loadRun(t.id,!0);return w.set(e.id,e),e}})))))).forEach((t=>{this.runs.set(t.id,t)})),this.onRunsChanged.next(this.runs)):(this.styleHistoryGrid(),this.styleHistoryFilters()))}))});const I=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===(A=this.options)||void 0===A?void 0:A.showBatchActions)?[this.trashIcon,this.compareIcon]:[],{style:{gap:"5px",padding:"5px"}})],{style:{justifyContent:"space-between",padding:"0px 5px"}});I.style.setProperty("overflow-y","hidden","important");const T=o.divV([this.defaultGridText,I,this._historyGrid.root],"ui-box");u()(T).removeClass("ui-div"),u()(T).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=>C(this,void 0,void 0,(function*(){if(this.setGridCellRendering(),t.size>0){const e=yield(0,v.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,v.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)})))),S=this._onRunsDfChanged.subscribe((t=>{this._historyFilters.dataFrame=t,this._historyGrid.dataFrame=t,this.currentDf.getCol(f.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)})),x=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))})),R=this._compactMode.subscribe((t=>{const e=[T,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()(T).css(Object.assign({},this.compactMode?{width:"100%"}:{height:"100%"})),setTimeout((()=>{this.styleHistoryGrid(),this.styleHistoryFilters()}),100)}))}));this.subs.push(E,R,S,x)}isFavoriteByIndex(t){return this.currentDf.get(f.iL,t)}setGridCellRendering(){var t,e;(0,v.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 h.C(e);n.onFuncCallDelete.pipe((0,d.take)(1)).subscribe((()=>C(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{yield Promise.all(a()(e.values()).map((t=>C(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,v.WM)(e,!0).then((()=>this.updateRun(e)))}),(t=>{const e=this.getRunByIdx(t.tableRowIndex);(0,v.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 C(this,void 0,void 0,(function*(){return p.W.loadRun(t,!0).then((t=>C(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,v.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,v.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,v.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")}}},8084:(t,e,n)=>{"use strict";n(6314),n(6067);var i=n(1813);n(3313),i.H},8117:(t,e,n)=>{"use strict";n.d(e,{u:()=>C});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(3061),p=n(4260),h=n(4451),f=n(8476),m=(n(7778),n(5520)),v=n(1599),g=n(2610),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=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 C 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=>y(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===p.L_.VISIBLE))){this.stepTabs.currentPane=this.stepTabs.getPane(b(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=`${b(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=`${b(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===p.L_.VISIBLE))){const o=new t.Workbook;this.stepTabs.currentPane=this.stepTabs.getPane(b(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 y(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:p.L_.VISIBLE),ability:new a.BehaviorSubject(this.isHistorical.value||0===e?p.D.ENABLED:p.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=>y(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=>y(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=>y(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 h=o.button("Back",(()=>{}),"Go to the previous step");c()(h).addClass("ui-btn-nav");const f=o.button("Next",(()=>{}),"Go to the next step");c()(f).addClass("ui-btn-nav"),this.syncNavButtons(e,h,f),d.setNavigationButtons([h,f]),this.steps[t.stepId].view=d;const m=this.steps[t.stepId],v=()=>{Object.values(this.steps).forEach((t=>{t.idx>m.idx&&t.visibility.value===p.L_.VISIBLE&&t.ability.value===p.D.ENABLED&&t.ability.next(p.D.DISABLED)}))},g=m.view.funcCallReplaced.pipe((0,l.switchMap)((()=>{const t=[...m.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 A=i.functions.onAfterRunAction.pipe((0,l.filter)((t=>m.view.funcCall&&t&&!!t.id&&m.view.funcCall.id===t.id)),(0,l.withLatestFrom)(m.visibility,m.ability),(0,l.filter)((([,t,e])=>!(t===p.L_.HIDDEN||e===p.D.DISABLED)))).subscribe((()=>{const t=(()=>Object.values(this.steps).find((t=>t.idx>m.idx&&t.visibility.value===p.L_.VISIBLE&&t.ability.value===p.D.ENABLED))?null:Object.values(this.steps).find((t=>t.idx>m.idx&&t.visibility.value===p.L_.VISIBLE&&t.ability.value===p.D.DISABLED)))();null==t||t.ability.next(p.D.ENABLED)}));return this.subs.push(A),yield this.onAfterStepFuncCallApply(t.stepScript.nqName,r,d),d})))),h=yield Promise.all(d),f=(0,a.combineLatest)(h.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)===p.L_.VISIBLE}))&&this.isHistorical.value&&this.isHistorical.next(!1)}));this.subs.push(f);const m=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(m),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 y(this,void 0,void 0,(function*(){return Promise.all(Object.values(this.steps).map((t=>y(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=b(i))})),e.addEventListener("click",(()=>{o&&(this.currentTabName=b(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===p.D.DISABLED&&c()(n).addClass("d4-disabled"),i.ability.value===p.D.ENABLED&&c()(n).removeClass("d4-disabled")):c()(n).hide(),o?(c()(e).show(),o.ability.value===p.D.DISABLED&&c()(e).addClass("d4-disabled"),o.ability.value===p.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===p.L_.VISIBLE))}getNextStep(t){return Object.values(this.steps).find((e=>e.idx>t.idx&&e.visibility.value===p.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 y(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 f.S.fromComparedRuns(o,o[0].func,{parentView:s,parentCall:e});i.shell.addView(r)}))}onBeforeStepFuncCallApply(t,e,n){return y(this,void 0,void 0,(function*(){}))}onAfterStepFuncCallApply(t,e,n){return y(this,void 0,void 0,(function*(){}))}buildIO(){const t=Object.values(this.steps).reduce(((t,e)=>Object.assign(Object.assign({},t),{[b(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(b(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=A(t);this.subs.push(this.steps[e].visibility.subscribe((t=>{t===p.L_.VISIBLE&&c()(this.stepTabs.getPane(b(this.steps[e])).header).css("display","inherit"),t===p.L_.HIDDEN&&c()(this.stepTabs.getPane(b(this.steps[e])).header).hide()})))})),Object.values(this.steps).forEach((t=>{this.subs.push(t.ability.subscribe((e=>{e===p.D.ENABLED&&c()(this.stepTabs.getPane(b(t)).header).removeClass("d4-disabled"),e===p.D.DISABLED&&c()(this.stepTabs.getPane(b(t)).header).addClass("d4-disabled")})))})),this.hideSteps(...this.initialConfig.filter((t=>t.hiddenOnInit===p.L_.HIDDEN)).map((t=>t.funcName))),e.root}showHelpWithDelay(t){return y(this,void 0,void 0,(function*(){(0,v.aB)(this.helpFiles[t.func.nqName])}))}findCurrentStep(){return Object.values(this.steps).find((t=>b(t)===this.stepTabs.currentPane.name))}buildHistoryBlock(){const t=super.buildHistoryBlock(),e=this.historyBlock.afterRunDeleted.subscribe((t=>y(this,void 0,void 0,(function*(){(yield i.dapi.functions.calls.allPackageVersions().filter(`options.parentCallId="${t.id}"`).list()).map((t=>y(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",(()=>y(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((()=>y(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 y(this,void 0,void 0,(function*(){let e=(0,v.A4)(t);yield this.onBeforeSaveRun(e),(0,v.Ne)(e)&&(e=yield(0,v.Hs)(t)),e.newId();const n=Object.values(this.steps).filter((t=>t.visibility.value===p.L_.VISIBLE)).map((t=>y(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 y(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===p.L_.VISIBLE)).findIndex((t=>b(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(p.L_.HIDDEN),t.ability.next(p.D.DISABLED)),1===e.length&&(yield t.view.loadRun(e[0].id),t.visibility.next(p.L_.VISIBLE),(0,v.Ne)(e[0])?t.ability.next(p.D.DISABLED):t.ability.next(p.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(p.L_.VISIBLE),(0,v.Ne)(n)?t.ability.next(p.D.DISABLED):t.ability.next(p.D.ENABLED)}}const o=Object.values(this.steps).find((t=>t.ability.value===p.D.DISABLED&&t.visibility.value===p.L_.VISIBLE)),s=null!=o?o:Object.values(this.steps)[0];if(s.ability.next(p.D.ENABLED),o){let t=this.getNextStep(o);for(;t;)t.ability.next(p.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==p.L_.VISIBLE)).at(i);return r&&r.ability.value===p.D.ENABLED?this.currentTabName=b(r):this.currentTabName=b(s),yield this.onAfterLoadRun(e),e}))}hideSteps(...t){return y(this,void 0,void 0,(function*(){t.forEach((t=>{this.steps[t].visibility.next(p.L_.HIDDEN)}))}))}showSteps(...t){return y(this,void 0,void 0,(function*(){t.forEach((t=>{this.steps[t].visibility.next(p.L_.VISIBLE)}))}))}exportRunJson(){return y(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,v.wB)(i,n.view))}return(0,m.lK)(t)}}))}executeTest(t){return y(this,arguments,void 0,(function*(t,e=!1){yield(0,g.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))))}}},8333:(t,e,n)=>{"use strict";n.d(e,{k:()=>s});for(var i=[],o=0;o<256;++o)i.push((o+256).toString(16).slice(1));function s(t,e=0){return(i[t[e+0]]+i[t[e+1]]+i[t[e+2]]+i[t[e+3]]+"-"+i[t[e+4]]+i[t[e+5]]+"-"+i[t[e+6]]+i[t[e+7]]+"-"+i[t[e+8]]+i[t[e+9]]+"-"+i[t[e+10]]+i[t[e+11]]+i[t[e+12]]+i[t[e+13]]+i[t[e+14]]+i[t[e+15]]).toLowerCase()}},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={}))},8387:(t,e,n)=>{"use strict";n(6314)},8476:(t,e,n)=>{"use strict";n.d(e,{S:()=>p});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())}))};const d=window;class p 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(d.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)}}},8480:(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(8565),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},8511:(t,e,n)=>{"use strict";n(6314),n(6067);var i=n(1813);n(3313),i.H},8565:(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/shared-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},8586:(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(3703),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)}))))}}},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},8948:(t,e,n)=>{"use strict";n.d(e,{AK:()=>i.A,S3:()=>o.S}),n(7160);var i=n(6067),o=(n(1813),n(4980),n(8511),n(8084),n(844))},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}},9046:(t,e,n)=>{"use strict";n(6082),n(5460),n(1858),n(9713)},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}},9171:(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})},9312:(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"]}},9421:(t,e,n)=>{"use strict";n(7788),n(6314),n(2991)},9467:(t,e,n)=>{"use strict";n.d(e,{Y:()=>i});class i{constructor(){}onIterationStart(){}onComputationsCompleted(){}}},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:"Compute Engine",link:"https://github.com/datagrok-ai/public/tree/master/packages/Compute"},{name:"Developing Models",link:"https://datagrok.ai/help/compute/scripting"}],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(),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},9713:t=>{"use strict";t.exports=rxjs.operators},9732:(t,e,n)=>{"use strict";n(3296)},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))}}},9865:(t,e,n)=>{"use strict";var i=n(5565),o=n(5174),s=n(9312),r=n(2947),a=n(5587),l=n(7031);n(7134),i.L,o.e,s.Y,r.R,a.e5,l.x},9911:(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/shared-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},9939:(t,e,n)=>{"use strict";n.d(e,{s:()=>c});var i=n(4328),o=n(7389),s=n(6082),r=n(1858),a=n(9713),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(){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"}getById(t){return l(this,void 0,void 0,(function*(){return yield i.dapi.functions.find(t)}))}refresh(t){return l(this,void 0,void 0,(function*(){return yield this.getById(t.id)}))}static getHelp(t){return l(this,void 0,void 0,(function*(){if(!t.options.readme)return;const e=`System:AppData/${t.package.name}/${t.options.readme}`;return(yield i.dapi.files.exists(e))?yield i.dapi.files.readAsText(e):void 0}))}static openHelp(t){return l(this,void 0,void 0,(function*(){if(!t.options.readme)return;const e=`System:AppData/${t.package.name}/${t.options.readme}`,n=(yield i.dapi.files.exists(e))?yield i.dapi.files.readAsText(e):"No help file";i.shell.windows.help.showHelp(o.markdown(n))}))}static openModel(t){t.prepare().edit()}static openModelFromFunccall(t){t.edit()}static getUserGroups(){return l(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((()=>l(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);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((()=>l(this,void 0,void 0,(function*(){var e,i;const s=yield c.getHelp(t),r=yield this.awaitUserGroups(),a=c.getMissingGroups(t,r),l=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"}}),l,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=>{c.openVersionSelectDialog(s.toJs(t))})),this.registerParamFunc("Help",(t=>{c.openHelp(s.toJs(t))})),setTimeout((()=>l(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([u(),t.name],{style:{fontWeight:"600"}}),...t.help?[o.span([t.help],{style:{marginLeft:"16px"}})]:[],o.link("Request group membership",(()=>l(this,void 0,void 0,(function*(){yield function(t){return l(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 l(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=document.baseURI||self.location.href,n.nc=void 0;var i={};(()=>{"use strict";n.r(i),n.d(i,{AmbTempValidator:()=>W,CFV:()=>x,CompView:()=>E,CustomCustomizer:()=>U,CustomDataUploader:()=>V,CustomStringInput:()=>K,CustomUploader:()=>$,DesiredTempValidator:()=>j,HeatCapValidator:()=>G,InitialTempValidator:()=>Y,ObjectCoolingSelector:()=>z,OutliersSelection:()=>f,Pipeline:()=>R,PipelineStepEditor:()=>v,RFV:()=>S,RichFunctionViewEditor:()=>m,SimTimeValidator:()=>H,_package:()=>p,fileInput:()=>M,historyInput:()=>F,historyInputJSON:()=>_,historyPanel:()=>k,init:()=>C,makeAdvice:()=>L,makeAdvice2:()=>B,makeRevalidation:()=>N,makeValidationResult:()=>O,makeValidationResult2:()=>D,mergeValidationResults:()=>P,modelCatalog:()=>w,modelCatalogTreeBrowser:()=>I,openModelFromFuncall:()=>h,renderPanel:()=>g,testPipeline:()=>T});var t=n(4328),e=n(7389),o=n(6082),s=n(9713),r=n(6126),a=n(7294),l=n(1899),u=n(3398),c=n(2610),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 p=new o.Package;function h(t){u.sg.openModelFromFunccall(t)}function f(){return new r.A}function m(t){return a.Ee.fromFuncCall(t,{historyEnabled:!0,isTabbed:!1})}function v(t){return a.Ee.fromFuncCall(t,{historyEnabled:!1,isTabbed:!0})}function g(t){return d(this,void 0,void 0,(function*(){return(0,u.lp)(t)}))}let y=!1,b=!1;const A={_package:p,ViewClass:u.ak,segment:"Modelhub",viewName:"Model Hub",funcName:"modelCatalog",setStartUriLoaded:()=>y=!0,getStartUriLoaded:()=>y};function C(){b||((0,u.jd)(),(0,u.a8)(A),b=!0)}function w(){return(0,u.v_)(A)}function I(t){(0,u.I3)(t)}const T=c.b,E=a.HJ,S=a.Ee,x=a.vs,R=a.uf,O=l.ZS,L=l.B5,N=l.dQ,P=l.uD,M=a.Ad.fileInput,F=a.Ad.historyInput,_=a.Ad.historyInputJSON,k=a.Ad.historyPanel,B=l.B5,D=l.ZS;function V(t){return d(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()]}))}function $(n){return d(this,void 0,void 0,(function*(){const i=(yield t.functions.eval("Compute:CustomDataUploader")).prepare({func:n.func}),r=e.bigButton("Click me to get mock calls",(()=>i.call())),a=o.Widget.fromRoot(e.panel([e.divV([e.label("This part of dialog comes from my custom data uploader"),e.divH([r],{style:{justifyContent:"center"}})])])),l=t.functions.onBeforeRunAction.pipe((0,s.filter)((t=>t.id===i.id))).subscribe((()=>{e.setUpdateIndicator(r,!0)})),u=t.functions.onAfterRunAction.pipe((0,s.filter)((t=>t.id===i.id))).subscribe((()=>{e.setUpdateIndicator(r,!1)}));return a.subs.push(l,u),{uploadWidget:a,uploadFuncCall:i}}))}function U(t){t.defaultView.scatterPlot({xColumnName:"Initial temperature",yColumnName:"Time to cool"})}function H(t){const{reasonableMin:e,reasonableMax:n}=t;return t=>(0,l.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})}function j(t){return(t,e)=>{const n=e.funcCall.inputs.ambTemp,i=e.funcCall.inputs.initTemp;return(0,l.ZS)({errors:[...t<n?[(0,l.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})`]:[]]})}}function Y(t){return(t,e)=>{const n=e.funcCall.inputs.ambTemp;return(0,l.ZS)({errors:[...t<n?[`Initial temperature cannot be less than ambient temperature (${n}).`]:[]]})}}function W(t){return(t,e)=>{const n=e.funcCall.inputs.initTemp;return(0,l.ZS)({errors:[...t>n?[`Ambient temperature cannot be higher than initial temperature (${n})`]:[]]})}}function G(t){return(t,e)=>(0,l.ZS)({errors:[...t<=0?["Heat capacity must be greater than zero."]:[]],notifications:[(0,l.B5)("Heat capacity is only dependent on the object material.",[{actionName:"Google it",action:()=>{window.open("http://google.com")}}])]})}function K(t){const n=e.input.string("Custom input",{value:""});return n.root.style.backgroundColor="aqua",n.input.style.backgroundColor="aqua",n}function z(t){return a.Ad.historyInputJSON("Previous run","ObjectCooling")}})(),compute=i})();
2
2
  //# sourceMappingURL=package.js.map