@datagrok/compute 1.45.4 → 1.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +8 -0
- package/dist/package-test.js +8 -8
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +3 -3
- package/dist/package.js.map +1 -1
- package/package.json +8 -8
- package/src/tests/rich-function-view-direct-tests.ts +24 -33
- package/src/tests/rich-function-view-tests.ts +24 -33
- package/src/tests/utils.ts +33 -0
- package/test-console-output-1.log +120 -120
- package/test-record-1.mp4 +0 -0
package/dist/package.js
CHANGED
|
@@ -165,7 +165,7 @@ div.ui-box > div.ui-box.rfv-form > div.ui-div {
|
|
|
165
165
|
|
|
166
166
|
.rfv-scalar-table td:last-child {
|
|
167
167
|
width: 100%;
|
|
168
|
-
}`,"",{version:3,sources:["webpack://./../../libraries/compute-utils/dist/old-views/css/rich-function-view.css"],names:[],mappings:"AAAA;IACI,eAAe;IACf,gBAAgB;IAChB,uBAAuB;AAC3B;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,mBAAmB;IACnB,yBAAyB;AAC7B;;AAEA,oCAAoC;AACpC;;;;IAII,aAAa;AACjB;;AAEA,mDAAmD;AACnD;IACI,gBAAgB;AACpB;;AAEA,+DAA+D;AAC/D;IACI,gBAAgB;AACpB;;AAEA,+CAA+C;AAC/C;IACI,aAAa;AACjB;AACA;IACI,gBAAgB;AACpB;AACA;IACI,aAAa;AACjB;AACA;IACI,gBAAgB;AACpB;;AAEA;IACI,2BAA2B;AAC/B;;AAEA;IACI,QAAQ;IACR,yBAAyB;AAC7B;;AAEA;IACI,2BAA2B;AAC/B;;AAEA;IACI,yBAAyB;IACzB,YAAY;AAChB;;AAEA;IACI,kBAAkB;IAClB,mBAAmB;AACvB;;AAEA;IACI,gBAAgB;IAChB,uCAAuC;AAC3C;;AAEA;IACI,+BAA+B;AACnC;;AAEA;IACI,WAAW;AACf",sourcesContent:[".ui-form .ui-input-root.ui-input-buttons.rfv-buttons {\n margin-top: 0px;\n position: sticky;\n align-items: flex-start;\n}\n\n.ui-form .ui-input-buttons.rfv-buttons .ui-input-editor {\n flex-wrap: wrap;\n}\n\n.ui-input-root.rfv-restricted-input.d4-disabled {\n pointer-events: all;\n cursor: pointer!important;\n}\n\n/* Hide all state icons by default */\n.ui-input-root > .ui-input-options .rfv-icon-lock,\n.ui-input-root > .ui-input-options .rfv-icon-unlock,\n.ui-input-root > .ui-input-options .rfv-icon-undo,\n.ui-input-root > .ui-input-options .rfv-icon-warning {\n display: none;\n}\n\n/* Show warning icon if input is on warning state */\n.ui-input-root.rfv-inconsistent-input > .ui-input-options .rfv-icon-warning {\n display: inherit;\n}\n\n/* Show undo icon if input is on inconstent state and hovered */\n.ui-input-root.rfv-restricted-unlocked-input:hover .rfv-icon-undo, .ui-input-root.rfv-inconsistent-input:hover .rfv-icon-undo {\n display: inherit;\n}\n\n/* Show/hide lock-unlock icons on input hover */\n.ui-input-root.rfv-restricted-input:hover .rfv-icon-lock {\n display: none;\n}\n.ui-input-root.rfv-restricted-input .rfv-icon-lock {\n display: inherit;\n}\n.ui-input-root.rfv-restricted-input .rfv-icon-unlock {\n display: none;\n}\n.ui-input-root.rfv-restricted-input:hover .rfv-icon-unlock {\n display: inherit;\n}\n\n.ui-form-condensed .rfv-buttons > .ui-label {\n margin-right: 0px!important;\n}\n\n.rfv-form .ui-form .rfv-buttons > .ui-input-editor {\n gap: 5px;\n justify-content: flex-end;\n}\n\ndiv.ui-box > div.ui-box.rfv-form > div.ui-div {\n overflow: visible!important;\n}\n\n.rfv-scalar-table {\n border-collapse: collapse;\n margin: 10px;\n}\n\n.rfv-scalar-table td {\n width: max-content;\n white-space: nowrap;\n}\n\n.rfv-scalar-table tr{\n min-height: 30px;\n border-bottom: 1pt solid var(--grey-12);\n}\n\n.rfv-scalar-table tr:nth-child(odd) {\n background-color: var(--grey-1);\n}\n\n.rfv-scalar-table td:last-child {\n width: 100%;\n}"],sourceRoot:""}]);let l=s},454(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,r,o){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(i)for(var l=0;l<this.length;l++){var a=this[l][0];null!=a&&(s[a]=!0)}for(var u=0;u<t.length;u++){var c=[].concat(t[u]);i&&s[c[0]]||(void 0!==o&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=o),n&&(c[2]&&(c[1]="@media ".concat(c[2]," {").concat(c[1],"}")),c[2]=n),r&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=r):c[4]="".concat(r)),e.push(c))}},e}},126(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))));return[e].concat(["/*# ".concat("sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i)," */")]).join("\n")}return[e].join("\n")}},474(t){t.exports=function(){"use strict";var t="minute",e=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(i,r,o){var s=r.prototype;o.utc=function(t){var e={date:t,utc:!0,args:arguments};return new r(e)},s.utc=function(e){var n=o(this.toDate(),{locale:this.$L,utc:!0});return e?n.add(this.utcOffset(),t):n},s.local=function(){return o(this.toDate(),{locale:this.$L,utc:!1})};var l=s.parse;s.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),l.call(this,t)};var a=s.init;s.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 a.call(this)};var u=s.utcOffset;s.utcOffset=function(i,r){var o=this.$utils().u;if(o(i))return this.$u?0:o(this.$offset)?u.call(this):this.$offset;if("string"==typeof i&&null===(i=function(t){void 0===t&&(t="");var i=t.match(e);if(!i)return null;var r=(""+i[0]).match(n)||["-",0,0],o=r[0],s=60*r[1]+ +r[2];return 0===s?0:"+"===o?s:-s}(i)))return this;var s=16>=Math.abs(i)?60*i:i;if(0===s)return this.utc(r);var l=this.clone();if(r)return l.$offset=s,l.$u=!1,l;var a=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(l=this.local().add(s+a,t)).$offset=s,l.$x.$localOffset=a,l};var c=s.format;s.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return c.call(this,e)},s.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},s.isUTC=function(){return!!this.$u},s.toISOString=function(){return this.toDate().toISOString()},s.toString=function(){return this.toDate().toUTCString()};var d=s.toDate;s.toDate=function(t){return"s"===t&&this.$offset?o(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():d.call(this)};var p=s.diff;s.diff=function(t,e,n){if(t&&this.$u===t.$u)return p.call(this,t,e,n);var i=this.local(),r=o(t).local();return p.call(i,r,e,n)}}}()},2(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 r={},o=[],s=0;s<t.length;s++){var l=t[s],a=i.base?l[0]+i.base:l[0],u=r[a]||0,c="".concat(a," ").concat(u);r[a]=u+1;var d=n(c),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(p);else{var h=function(t,e){var n=e.domAPI(e);return n.update(t),function(e){e?(e.css!==t.css||e.media!==t.media||e.sourceMap!==t.sourceMap||e.supports!==t.supports||e.layer!==t.layer)&&n.update(t=e):n.remove()}}(p,i);i.byIndex=s,e.splice(s,0,{identifier:c,updater:h,references:1})}o.push(c)}return o}t.exports=function(t,r){var o=i(t=t||[],r=r||{});return function(t){t=t||[];for(var s=0;s<o.length;s++){var l=n(o[s]);e[l].references--}for(var a=i(t,r),u=0;u<o.length;u++){var c=n(o[u]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}o=a}}},129(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 Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},838(t){"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},986(t,e,n){"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},611(t){"use strict";t.exports=function(t){if("u"<typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){var i,r,o;i="",n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {")),(r=void 0!==n.layer)&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,r&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}"),(o=n.sourceMap)&&"u">typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),t.styleTagTransform(i,e,t.options)},remove:function(){var t;null===(t=e).parentNode||t.parentNode.removeChild(t)}}}},515(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))}}}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={id:i,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nc=void 0;var i={};(()=>{"use strict";let t;n.r(i),n.d(i,{ObjectCoolingSelector:()=>iv,CustomInputMock:()=>iy,RichFunctionViewEditor:()=>ir,makeValidationResult:()=>iV,mergeValidationResults:()=>iD,CompView:()=>iO,PipelineStepEditor:()=>io,GlobalValidatorDemoFactory:()=>iC,historyPanel:()=>iN,CustomCustomizer:()=>ia,init:()=>it,makeAdvice:()=>iB,HeatCapValidator:()=>ih,CustomStringInput:()=>im,RangeValidatorFactory:()=>ig,deepCopy:()=>iT,DesiredTempValidator:()=>ic,CustomUploader:()=>il,fileInput:()=>iL,openModelFromFuncall:()=>ie,CustomDataUploader:()=>is,AsyncValidatorDemoFactory:()=>ib,AmbTempValidator:()=>ip,SimTimeValidator:()=>iu,RFV:()=>iP,OutliersSelection:()=>ii,Pipeline:()=>iF,historyInputJSON:()=>iM,InitialTempValidator:()=>id,historyInput:()=>ij,_package:()=>iR,PackageFunctions:()=>i_,makeRevalidation:()=>ik});let e=grok,r=ui,o=DG,s=rxjs,l=rxjs.operators,a=$;var u,c,d,p,h,f,m,v,y,g,b,C=n.n(a);class w extends o.JsViewer{onFrameAttached(t){this.render()}onTableAttached(){this.render()}render(){if(!this.dataFrame||this.dataFrame.rowCount<=0){this.root.innerHTML="";return}let t=this.dataFrame,n="isOutlier",i="isOutlierSecondary",s="Rationale",l="Count",a="isConfirmed";t.columns.byName(n)||t.columns.add(o.Column.fromList(o.TYPE.STRING,n,Array(t.rowCount).fill("Inlier"))),t.columns.byName(i)||t.columns.add(o.Column.fromList(o.TYPE.STRING,i,Array(t.rowCount).fill("Inlier"))),t.columns.byName(s)||t.columns.add(o.Column.fromStrings(s,Array.from({length:t.rowCount},()=>"")));let u=()=>o.DataFrame.fromColumns([o.Column.fromStrings(s,[]),o.Column.fromInt32Array(l,new Int32Array([])),o.Column.fromStrings("Actions",[]),o.Column.fromBitSet(a,o.BitSet.create(0,()=>!1))]),c=o.Viewer.grid(u());c.root.style.width="100%",c.root.style.minWidth="230px",c.columns.setVisible([s,l,"Actions"]),this.root.append(r.divV([r.divV([c.root],{style:{height:"75%"}})],{style:{height:"100%"}}));let d=()=>{var e,r,l,a,u,d,p;if(!c.dataFrame)return;null==(e=t.col(n))||e.meta.markers.assign("Outlier",o.MARKER_TYPE.OUTLIER),null==(r=t.col(n))||r.meta.markers.assign("Last Inlier",o.MARKER_TYPE.STAR),null==(l=t.col(n))||l.meta.colors.setCategorical({Outlier:o.Color.scatterPlotMarker,Inlier:o.Color.scatterPlotMarker,"Last Inlier":o.Color.red}),null==(a=t.col(i))||a.meta.markers.assign("Outlier",o.MARKER_TYPE.OUTLIER),null==(u=t.col(i))||u.meta.markers.assign("Last Inlier",o.MARKER_TYPE.STAR),null==(d=t.col(i))||d.meta.colors.setCategorical({Outlier:o.Color.cyan,Inlier:o.Color.cyan,"Last Inlier":o.Color.red});let h=null==(p=c.dataFrame)?void 0:p.cell(c.dataFrame.rowCount-1,s).value;t.selection.getSelectedIndexes().forEach(e=>{t.col(n).set(e,"Outlier",!1),t.col(i).set(e,"Outlier",!1),t.col(s).set(e,h,!1)}),t.selection.setAll(!1),t.fireValuesChanged(),C()(document.querySelector(".d4-balloon-container")).empty()},p=()=>{c.dataFrame&&(c.dataFrame.rows.removeAt(c.dataFrame.rowCount-1),t.selection.setAll(!1),C()(document.querySelector(".d4-balloon-container")).empty())};c.onCellPrepare(e=>{if(e.isTableCell&&"Actions"===e.gridColumn.name){var o,l;let u;e.gridColumn.cellType="html",e.style.element=r.divH([...(null==(o=e.grid.dataFrame)?void 0:o.get(a,e.gridRow))?[(u=null==(l=e.grid.dataFrame)?void 0:l.get(s,e.gridRow),r.div(r.icons.delete(()=>{for(let e=0;e<t.rowCount;e++)t.columns.byName(s).get(e)===u&&(t.columns.byName(s).set(e,"",!1),t.columns.byName(n).set(e,"Inlier",!1),t.columns.byName(i).set(e,"Inlier",!1));t.fireValuesChanged()},"Remove the outliers group"),{style:{textAlign:"center",margin:"6px"}}))]:[r.div(r.iconFA("check",d,"Confirm the outliers"),{style:{textAlign:"center",margin:"6px"}}),r.div(r.iconFA("times",p,"Cancel the outliers"),{style:{textAlign:"center",margin:"6px"}})]])}}),c.onCellValueEdited.subscribe(e=>{var n,i;if(!c.dataFrame||e.gridColumn.name!==s||!c.dataFrame.columns.byName(a).get(e.gridRow))return;let r=new Set;for(let t=0;t<(null==(n=c.dataFrame)?void 0:n.rowCount);t++){let e=null==(i=c.dataFrame)?void 0:i.columns.byName(s).get(t);r.add(e)}for(let n=0;n<t.rowCount;n++){let i=t.columns.byName(s).get(n);""==i||r.has(i)||t.columns.byName(s).set(n,e.cell.value)}});let h=()=>{if(t.columns.byName(s))for(let e=0;e<t.rowCount;e++)"Outlier"===t.columns.byName(n).get(e)?""===t.columns.byName(s).get(e)&&t.columns.byName(s).set(e,"Manual",!1):""!==t.columns.byName(s).get(e)&&t.columns.byName(s).set(e,"",!1);let e={};if(t.columns.byName(s))for(let n=0;n<t.rowCount;n++){let i=t.columns.byName(s).get(n),r=e[i];""!=i&&(r?e[i]++:e[i]=1)}c.dataFrame=u(),c.columns.setVisible([s,l,"Actions"]),Object.keys(e).map(t=>{var n;null==(n=c.dataFrame)||n.rows.addNew([t,e[t],"",!0])})};t.onDataChanged.subscribe(h),t.onSelectionChanged.subscribe(()=>{if(!c.dataFrame||!t.selection.trueCount)return;let n=document.querySelector(".d4-balloon-container");if((!n||C()(n).is(":empty"))&&e.shell.info(r.div([r.divText("Confirm selected points as outliers?"),r.divH([r.bigButton("Confirm",d),r.button("Cancel",p)])])),c.dataFrame.columns.byName(a).toList().some(t=>!1===t))c.dataFrame.set(l,c.dataFrame.rowCount-1,t.selection.trueCount);else{let e=c.dataFrame.rows.addNew(["Manual",t.selection.trueCount,"",!1]);c.dataFrame.currentCell=c.dataFrame.cell(e.idx,s)}}),t.selection.setAll(!1),h()}constructor(){super()}}let A=dayjs;var x=n.n(A);let I=wu;var E=n.n(I);let R="#0.###",S={barchart:o.VIEWER.BAR_CHART,boxplot:o.VIEWER.BOX_PLOT,calendar:o.VIEWER.CALENDAR,corrplot:o.VIEWER.CORR_PLOT,densityplot:o.VIEWER.DENSITY_PLOT,filters:o.VIEWER.FILTERS,form:o.VIEWER.FORM,globe:o.VIEWER.GLOBE,googlemap:o.VIEWER.GOOGLE_MAP,grid:o.VIEWER.GRID,heatmap:o.VIEWER.HEAT_MAP,histogram:o.VIEWER.HISTOGRAM,linechart:o.VIEWER.LINE_CHART,markup:o.VIEWER.MARKUP,matrixplot:o.VIEWER.MATRIX_PLOT,networkdiagram:o.VIEWER.NETWORK_DIAGRAM,pcplot:o.VIEWER.PC_PLOT,piechart:o.VIEWER.PIE_CHART,scatterplot:o.VIEWER.SCATTER_PLOT,"3dscatterplot":o.VIEWER.SCATTER_PLOT_3D,shapemap:o.VIEWER.SHAPE_MAP,statistics:o.VIEWER.STATISTICS,tileviewer:o.VIEWER.TILE_VIEWER,timelines:o.VIEWER.TIMELINES,treemap:o.VIEWER.TREE_MAP,trellisplot:o.VIEWER.TRELLIS_PLOT,wordcloud:o.VIEWER.WORD_CLOUD,diffstudiofacet:"DiffStudio Facet"},T="JsCardView",O="viewer",P="experimental",F="Run name",V="RunId",B="ModelStorage",k="Source",D="Is favorite",L="Is complete",j="Delete",M="Author",N="Date",_="Title",U="Desc.",H="Tags",W="Version",Y=Object.values(o.COLUMN_TYPE).filter(t=>t!==o.TYPE.DATA_FRAME);"function"==typeof TextDecoder&&new TextDecoder("utf-8",{ignoreBOM:!0}),"function"==typeof TextEncoder&&new TextEncoder;let G=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),q=(t={},G.forEach((e,n)=>t[e]=n),t),J=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,z=String.fromCharCode.bind(String),K="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):t=>new Uint8Array(Array.prototype.slice.call(t,0)),Z="function"==typeof btoa?t=>btoa(t):t=>{let e,n,i,r,o="",s=t.length%3;for(let s=0;s<t.length;){if((n=t.charCodeAt(s++))>255||(i=t.charCodeAt(s++))>255||(r=t.charCodeAt(s++))>255)throw TypeError("invalid character found");o+=G[(e=n<<16|i<<8|r)>>18&63]+G[e>>12&63]+G[e>>6&63]+G[63&e]}return s?o.slice(0,s-3)+"===".substring(s):o},X="function"==typeof Uint8Array.prototype.toBase64?t=>t.toBase64():t=>{let e=[];for(let n=0,i=t.length;n<i;n+=4096)e.push(z.apply(null,t.subarray(n,n+4096)));return Z(e.join(""))},Q=(t,e=!1)=>e?X(t).replace(/=/g,"").replace(/[+\/]/g,t=>"+"==t?"-":"_"):X(t),tt="function"==typeof atob?t=>atob(t.replace(/[^A-Za-z0-9\+\/]/g,"")):t=>{let e,n,i;if(t=t.replace(/\s+/g,""),!J.test(t))throw TypeError("malformed base64.");t+="==".slice(2-(3&t.length));let r=[];for(let o=0;o<t.length;)e=q[t.charAt(o++)]<<18|q[t.charAt(o++)]<<12|(n=q[t.charAt(o++)])<<6|(i=q[t.charAt(o++)]),64===n?r.push(z(e>>16&255)):64===i?r.push(z(e>>16&255,e>>8&255)):r.push(z(e>>16&255,e>>8&255,255&e));return r.join("")},te="function"==typeof Uint8Array.fromBase64?t=>Uint8Array.fromBase64(t):t=>K(tt(t).split("").map(t=>t.charCodeAt(0))),tn=t=>t.replace(/[-_]/g,t=>"-"==t?"+":"/").replace(/[^A-Za-z0-9\+\/]/g,""),ti="_DG_CUSTOM_SERIALIZED_TOKEN_";function tr(t,e){let n=void 0===e?{}:e;return JSON.stringify(t,function(t,e){return e===1/0?{[ti]:"Infinity",value:!0}:e===-1/0?{[ti]:"-Infinity",value:!0}:Number.isNaN(e)?{[ti]:"NaN",value:!0}:e instanceof o.DataFrame&&!n.useJsonDF?{[ti]:"DataFrame",value:Q(e.toByteArray())}:e instanceof o.DataFrame&&n.useJsonDF?{[ti]:"DataFrameJSON",value:e.toJson()}:e instanceof ArrayBuffer?{[ti]:"ArrayBuffer",value:Q(new Uint8Array(e))}:e instanceof Map?{[ti]:"Map",value:Array.from(e)}:e instanceof Set?{[ti]:"Set",value:Array.from(e)}:x().isDayjs(this[t])?{[ti]:"DayJs",value:this[t].toISOString()}:e},n.space)}function to(t,e){if(e&&e[ti]&&e.value)switch(e[ti]){case"DataFrame":return o.DataFrame.fromByteArray(te(tn(e.value)));case"DataFrameJSON":return o.DataFrame.fromJson(JSON.stringify(e.value));case"ArrayBuffer":return te(tn(e.value)).buffer;case"Map":return new Map(e.value);case"DayJs":return x()(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}function ts(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function tl(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){ts(o,i,r,s,l,"next",t)}function l(t){ts(o,i,r,s,l,"throw",t)}s(void 0)})}}let ta=new o.LruCache,tu=t=>tl(function*(){var n;let i=null!=(n=t.options.help)?n:t.options.readme;if(!i)return;if(ta.get(t.id))return ta.get(t.id);let r="";try{r=t.package.name}catch(t){}let o=`System:AppData/${r}/${i}`;if(r&&(yield e.dapi.files.exists(o))){let n=yield e.dapi.files.readAsText(o);return ta.set(t.id,n),n}let s=`${e.shell.user.name}.home/${i}`;if(yield e.dapi.files.exists(s)){let n=yield e.dapi.files.readAsText(s);return ta.set(t.id,n),n}})(),tc=t=>{let e;try{e=t.package}catch(t){}return e},td=t=>{try{return null==t?void 0:t.started}catch(t){return}},tp=t=>{var e;return JSON.parse(null!=(e=t.options.OUTPUT_OUTDATED)?e:"false",to)||!td(t)||!t.id},th=t=>{let e=(null==(a=t.func)||null==(l=a.nqName)?void 0:l.includes(":"))?o.Func.byName(t.func.nqName).prepare():t.func.prepare();e.id=t.id,t.options.forEach(n=>e.options[n]=t.options[n]);let n=E()(e.outputParams.values()).filter(e=>null!=t.outputs[e.name]);var i=!0,r=!1,s=void 0;try{for(var l,a,u,c=n[Symbol.iterator]();!(i=(u=c.next()).done);i=!0){let n=u.value;n.property.propertyType===o.TYPE.DATA_FRAME?e.outputs[n.name]=t.outputs[n.name].clone():e.outputs[n.name]=t.outputs[n.name]}}catch(t){r=!0,s=t}finally{try{i||null==c.return||c.return()}finally{if(r)throw s}}let d=E()(e.inputParams.values()).filter(e=>null!=t.inputs[e.name]);var p=!0,h=!1,f=void 0;try{for(var m,v=d[Symbol.iterator]();!(p=(m=v.next()).done);p=!0){let n=m.value;n.property.propertyType===o.TYPE.DATA_FRAME?e.inputs[n.name]=t.inputs[n.name].clone():e.inputs[n.name]=t.inputs[n.name]}}catch(t){h=!0,f=t}finally{try{p||null==v.return||v.return()}finally{if(h)throw f}}return td(t)&&(e.started=t.started),e},tf=t=>{let e=t.options[O];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 S[e]||e;if(!t.toLowerCase().includes("color")){let t=Number.parseFloat(e);if(!Number.isNaN(t))return t}return e})}:{name:t.name,config:[]}},tm=t=>{try{return t.started.toDate().toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}catch(t){return"Not completed"}};function tv(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function ty(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){tv(o,i,r,s,l,"next",t)}function l(t){tv(o,i,r,s,l,"throw",t)}s(void 0)})}}let tg=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 tb=f||(f={});let tC=new o.LruCache;function tw(t){return ty(function*(){let n=yield e.dapi.functions.calls.allPackageVersions().include("session.user,func.package, inputs, outputs").find(t),i=E()(n.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.FILE&&!!n.inputs[t.name]);yield Promise.all(i.map(t=>ty(function*(){let i=JSON.parse(n.inputs[t.name]),r=i.id,s=i.name,l=yield e.dapi.files.readAsBytes(r),a=o.FileInfo.fromBytes(s,l);return a.id=r,n.inputs[t.name]=a,Promise.resolve()})()));let r=E()(n.outputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!n.outputs[t.name]);yield Promise.all(r.map(t=>ty(function*(){return n.outputs[t.name]=yield e.dapi.tables.getTable(n.outputs[t.name]),Promise.resolve()})()));let s=E()(n.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!n.inputs[t.name]);return yield Promise.all(s.map(t=>ty(function*(){return n.inputs[t.name]=yield e.dapi.tables.getTable(n.inputs[t.name]),Promise.resolve()})())),n})()}function tA(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function tx(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){tA(o,i,r,s,l,"next",t)}function l(t){tA(o,i,r,s,l,"throw",t)}s(void 0)})}}function tI(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}function tE(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}tb.loadChildRuns=function(t){return ty(function*(){return{parentRun:yield tw(t),childRuns:yield e.dapi.functions.calls.allPackageVersions().include("func, func.package").filter(`options.parentCallId="${t}"`).list()}})()},tb.shallowLoadRun=function(t){return ty(function*(){return yield e.dapi.functions.calls.allPackageVersions().include("session.user,func.package, inputs, outputs").find(t)})()},tb.loadRun=tw,tb.updateRunMeta=function(t){return ty(function*(){let n=yield e.dapi.functions.calls.allPackageVersions().save(t);e.log.audit("@user edited metadata of @model model run",{user:o.User.current(),model:n.func})})()},tb.saveRun=function(t,n){return ty(function*(){var i;let r=tC.get("All users");r||(r=yield e.dapi.groups.find(o.Group.defaultGroupsIds["All users"]),tC.set("All users",r));let s=null!=(i=null==n?void 0:n.audience)?i:r;(null==n?void 0:n.newId)&&t.newId();let l=th(t);tp(l)&&(l.options.createdOn=x()().utc(!0).unix());let a=E()(l.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.FILE&&!!l.inputs[t.name]);yield Promise.all(a.map(t=>ty(function*(){var n;let i=l.inputs[t.name],r=i instanceof o.FileInfo?yield i.readAsBytes():new Uint8Array((yield i.arrayBuffer())),s=i instanceof o.FileInfo&&null!=(n=i.fileName)?n:i.name,a=o.FileInfo.fromBytes(s,r);return yield e.dapi.files.write(a),l.inputs[t.name]={id:a.id,name:a.name},Promise.resolve()})()));let u=E()(l.outputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!l.outputs[t.name]);yield Promise.all(u.map(t=>ty(function*(){yield e.dapi.tables.uploadDataFrame(l.outputs[t.name]),yield e.dapi.permissions.grant(l.outputs[t.name].getTableInfo(),s,!1)})()));let c=E()(l.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!l.inputs[t.name]);yield Promise.all(c.map(t=>ty(function*(){yield e.dapi.tables.uploadDataFrame(l.inputs[t.name]),yield e.dapi.permissions.grant(l.inputs[t.name].getTableInfo(),s,!1)})()));let d=yield e.dapi.functions.calls.allPackageVersions().save(l);return e.log.audit("@user saved run of the @model model",{user:o.User.current(),model:d.func}),d})()},tb.deleteRun=function(t){return ty(function*(){t.options.isDeleted=!0,yield e.dapi.functions.calls.allPackageVersions().save(t)})()},tb.pullRuns=function(t){return ty(function*(t,n,i){let r=void 0===n?{}:n,o=`func.id="${t}"`;return o+=r.author?` and session.user.id="${r.author.id}"`:"",o+=r.date?tg(r.date):"",e.dapi.functions.calls.allPackageVersions().filter(o).include("session.user, options").list(void 0===i?{}:i)}).apply(this,arguments)},tb.pullRunsByName=function(t){return ty(function*(t,n,i,r,s){let l=void 0===r?[]:r,a=void 0!==s&&s,u="";var c=!0,d=!1,p=void 0;try{for(var h,f=(void 0===n?[]:n)[Symbol.iterator]();!(c=(h=f.next()).done);c=!0){let t=h.value,e=[];t.author&&e.push(`session.user.id="${t.author.id}"`),t.date&&e.push(tg(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))');let n=e.join(" and ");""!==n&&(""===u?u+=`(${n})`:u+=` or (${n})`)}}catch(t){d=!0,p=t}finally{try{c||null==f.return||f.return()}finally{if(d)throw p}}""!==u&&(u=` and (${u})`);let m=yield e.dapi.functions.calls.allPackageVersions().filter(`func.name="${t}"${u}`).include(`${[...l,"func.package"].join(",")}`).list(void 0===i?{}:i);if((l.includes("inputs")||l.includes("func.params"))&&!a){var v=!0,y=!1,g=void 0;try{for(var b,C=m[Symbol.iterator]();!(v=(b=C.next()).done);v=!0){let t=b.value,n=E()(t.inputParams.values()).filter(e=>e.property.propertyType===o.TYPE.DATA_FRAME&&!!t.inputs[e.name]);var w=!0,A=!1,x=void 0;try{for(var I,R=n[Symbol.iterator]();!(w=(I=R.next()).done);w=!0){let n=I.value;t.inputs[n.name]=yield e.dapi.tables.getTable(t.inputs[n.name])}}catch(t){A=!0,x=t}finally{try{w||null==R.return||R.return()}finally{if(A)throw x}}}}catch(t){y=!0,g=t}finally{try{v||null==C.return||C.return()}finally{if(y)throw g}}}if((l.includes("outputs")||l.includes("func.params"))&&!a){var S=!0,T=!1,O=void 0;try{for(var P,F=m[Symbol.iterator]();!(S=(P=F.next()).done);S=!0){let t=P.value,n=E()(t.outputParams.values()).filter(e=>e.property.propertyType===o.TYPE.DATA_FRAME&&!!t.outputs[e.name]);var V=!0,B=!1,k=void 0;try{for(var D,L=n[Symbol.iterator]();!(V=(D=L.next()).done);V=!0){let n=D.value;t.outputs[n.name]=yield e.dapi.tables.getTable(t.outputs[n.name])}}catch(t){B=!0,k=t}finally{try{V||null==L.return||L.return()}finally{if(B)throw k}}}}catch(t){T=!0,O=t}finally{try{S||null==F.return||F.return()}finally{if(T)throw O}}}return m}).apply(this,arguments)};let tR=t=>{var e,n;if(null==(e=t.options)?void 0:e.default)return JSON.parse(null==(n=t.options)?void 0:n.default);let i=t.defaultValue;return t.propertyType===o.TYPE.STRING&&i?i.substring(1,i.length-1):i};function tS(t,e){e?(C()(t).addClass("ui-box").css({width:"auto",height:"auto"}),r.setUpdateIndicator(t,!0)):(r.setUpdateIndicator(t,!1),C()(t).removeClass("ui-box"))}function tT(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function tO(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){tT(o,i,r,s,l,"next",t)}function l(t){tT(o,i,r,s,l,"throw",t)}s(void 0)})}}function tP(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}function tF(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}class tV extends o.TableView{static fromComparedRuns(t,n){return tO(function*(t,n,i){var s,l;let a,u,c,d,p,h=void 0===i?{parentView:void 0,parentCall:void 0}:i,f=(a=void 0===h?{parentView:void 0,parentCall:void 0}:h,u=[...n.inputs,...n.outputs].map(t=>tf(t)).reduce((t,e)=>(t[e.name]?t[e.name].push(...e.config):t[e.name]=e.config,t),{}),c=e=>{if(e.propertyType===o.TYPE.DATA_FRAME)return u[e.name].map(n=>{var i;let r=null!=(i=e.caption)?i:e.name,s=o.Column.fromType(o.TYPE.DATA_FRAME,r,t.length);s.init(n=>{var i;return null!=(i=t[n].inputs[e.name])?i:t[n].outputs[e.name]});let l=d.columns.getUnusedName(`${s.name} (${n.type})`);return s.name=l,r=l,s.temp[O]=n,d.columns.add(s),s});{var n;let i=null!=(n=e.caption)?n:e.name,r=o.Column.fromType(e.propertyType,i,t.length);r.init(n=>{var i;return null!=(i=t[n].inputs[e.name])?i:t[n].outputs[e.name]});let s=d.columns.getUnusedName(r.name);return r.name=s,i=s,d.columns.add(r),[r]}},d=o.DataFrame.create(t.length),p=[],t.forEach(t=>{var e;let n=null!=(e=t.options.title)?e:`${t.func.name} - ${tm(t)}`,i=2;for(;p.includes(n);)n=`${t.func.name} - ${tm(t)} - ${i}`,i++;p.push(n)}),d.columns.add(o.Column.fromStrings(F,p)),d.name=(null==(s=a.parentCall)?void 0:s.func.name)?`${null==(l=a.parentCall)?void 0:l.func.name} - comparison`:`${n.name} - comparison`,n.inputs.forEach(t=>c(t)),n.outputs.forEach(t=>c(t)),e.events.onCurrentObjectChanged.subscribe(t=>{let n=t.sender;if(n instanceof o.Column&&n.type===o.TYPE.DATA_FRAME&&e.shell.tv&&e.shell.tv.temp.isComparison&&[o.VIEWER.LINE_CHART,o.VIEWER.SCATTER_PLOT,o.VIEWER.HISTOGRAM,o.VIEWER.BOX_PLOT].includes(n.temp[O].type)){e.shell.windows.showContextPanel=!0;let t=t=>{let e=t.get(0).clone();e.columns.addNew(V,o.TYPE.STRING).init(t.dataFrame.get(F,0));for(let n=1;n<t.length;n++){let i=t.get(n).clone();i.columns.addNew(V,o.TYPE.STRING).init(t.dataFrame.get(F,n));let r=[o.COLUMN_TYPE.INT,o.COLUMN_TYPE.FLOAT];for(let t=0;t<i.columns.length;t++){let n=i.columns.byIndex(t),s=e.columns.byIndex(t);n.type!==s.type&&r.includes(n.type)&&r.includes(s.type)&&(n.type!==o.COLUMN_TYPE.FLOAT&&i.columns.replace(n,n.convertTo(o.COLUMN_TYPE.FLOAT)),s.type!==o.COLUMN_TYPE.FLOAT&&e.columns.replace(s,s.convertTo(o.COLUMN_TYPE.FLOAT)))}e.append(i,!0)}return e},i=n.temp[O].look;setTimeout(()=>{switch(n.temp[O].type){case o.VIEWER.LINE_CHART:let s=r.waitBox(()=>tx(function*(){var e;let r=null!=(e=n.temp.unitedDf)?e:t(n);return n.temp.unitedDf=r,r.plot.line(tE(tI({},i),{split:V})).root})());C()(s).css({width:"100%"}),e.shell.o=s;break;case o.VIEWER.SCATTER_PLOT:let l=r.waitBox(()=>tx(function*(){var e;let r=null!=(e=n.temp.unitedDf)?e:t(n);return n.temp.unitedDf=r,r.plot.scatter(tE(tI({},i),{color:V})).root})());e.shell.o=l,C()(l).css({width:"100%"});break;case o.VIEWER.HISTOGRAM:let a=r.waitBox(()=>tx(function*(){var e;let r=null!=(e=n.temp.unitedDf)?e:t(n);return n.temp.unitedDf=r,r.plot.histogram(tE(tI({},i),{split:V})).root})());e.shell.o=a,C()(a).css({width:"100%"});break;case o.VIEWER.BOX_PLOT:let u=r.waitBox(()=>tx(function*(){var e;let r=null!=(e=n.temp.unitedDf)?e:t(n);return n.temp.unitedDf=r,r.plot.box(tE(tI({},i),{category:V})).root})());e.shell.o=u,C()(u).css({width:"100%"})}})}}),d),m=[...e.shell.views].find(t=>t.type===T||"scripts"===t.type||"functions"===t.type);return m&&(e.shell.v=m),new this(f,h)}).apply(this,arguments)}showAllColumns(){let t=this.dataFrame.columns.names();this.grid.columns.setVisible(t)}showChangingColumns(){let t=this.dataFrame.columns.names().filter(t=>o.TYPES_SCALAR.has(this.dataFrame.getCol(t).type)&&this.dataFrame.getCol(t).categories.length>1||!o.TYPES_SCALAR.has(this.dataFrame.getCol(t).type));this.grid.columns.setVisible(t)}defaultCustomize(){let t=r.iconFA("compress-alt",()=>{this.showChangingColumns(),C()(n).show(),C()(t).hide()},"Hide constant parameters"),n=r.iconFA("expand-arrows-alt",()=>{this.showAllColumns(),C()(n).hide(),C()(t).show()},"Show all parameters");C()(t).hide(),this.setRibbonPanels([...this.getRibbonPanels(),[t,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(F).width=70;for(let t=0;t<this.grid.columns.length;t++){var i;let e=this.grid.columns.byIndex(t);(null==(i=e.column)?void 0:i.temp[O])&&(e.width=350,e.cellType="html")}let s=new o.LruCache;this.grid.onCellPrepare(t=>tO(function*(){if(!t.isColHeader&&!t.isRowHeader){if(t.tableColumn.name===F){t.customText="";let e=String(t.cell.value).split(" - "),n=e.length>1?[e[0],r.element("br"),e[1]]:e;t.element=r.div(n,{style:{writingMode:"vertical-rl",textOrientation:"mixed",margin:"auto"}}),t.element.parentElement.style.display="flex";return}if(t.tableColumn&&t.tableColumn.temp[O]){let e=t.cell.value,n=t.tableColumn.temp[O],i=n.type,r=`${e.id}_${i}`;if(s.get(r))t.element=s.get(r);else{let l=yield tO(function*(){let r=Object.values(S).includes(i)?o.Viewer.fromType(i,e):yield e.plot.fromType(i);return t.tableColumn.temp[O].look?r.setOptions(t.tableColumn.temp[O].look):(r.setOptions(n),t.tableColumn.temp[O]=r.getOptions()),r.root})();s.set(r,l),t.element=l}t.element.style.width="100%",t.element.style.height="100%"}}})());let l=r.box(r.div([],{style:{minHeight:"100px"}})),a=e.events.onCurrentViewChanged.subscribe(()=>{e.shell.v.id===this.id?e.shell.dockManager.dock(l,"down",null,"Comparison chart",.25):e.shell.dockManager.close(l)}),u=this.grid.onCellClick.subscribe(t=>{var n;e.shell.v.id===this.id&&t.isColHeader&&(null==(n=t.tableColumn)?void 0:n.type)===o.TYPE.DATA_FRAME&&[o.VIEWER.LINE_CHART,o.VIEWER.SCATTER_PLOT,o.VIEWER.HISTOGRAM,o.VIEWER.BOX_PLOT].includes(t.tableColumn.temp[O].type)?(e.shell.dockManager.findNode(l)||e.shell.dockManager.dock(l,"down",null,"Comparison chart",.25),r.setUpdateIndicator(l,!0),setTimeout(()=>{if(!t.tableColumn.temp.unitedPlot){var e;let n=t.tableColumn.temp[O].look,i=(t=>{let e=o.toJs(t.get(0)).clone();e.columns.addNew(V,o.TYPE.STRING).init(t.dataFrame.get(F,0));for(let n=1;n<t.length;n++){let i=o.toJs(t.get(n)).clone();i.columns.addNew(V,o.TYPE.STRING).init(t.dataFrame.get(F,n));let r=[o.COLUMN_TYPE.INT,o.COLUMN_TYPE.FLOAT];for(let t=0;t<i.columns.length;t++){let n=i.columns.byIndex(t),s=e.columns.byIndex(t);n.type!==s.type&&r.includes(n.type)&&r.includes(s.type)&&(n.type!==o.COLUMN_TYPE.FLOAT&&i.columns.replace(n,n.convertTo(o.COLUMN_TYPE.FLOAT)),s.type!==o.COLUMN_TYPE.FLOAT&&e.columns.replace(s,s.convertTo(o.COLUMN_TYPE.FLOAT)))}e.append(i,!0)}return e})(t.tableColumn);t.tableColumn.temp.unitedPlot=((e,n,i)=>{var r;switch(null==(r=t.tableColumn)?void 0:r.temp[O].type){case o.VIEWER.LINE_CHART:return i.plot.line(tF(tP({},n),{split:V})).root;case o.VIEWER.SCATTER_PLOT:return i.plot.scatter(tF(tP({},n),{color:V})).root;case o.VIEWER.HISTOGRAM:return i.plot.histogram(tF(tP({},n),{split:V})).root;case o.VIEWER.BOX_PLOT:return i.plot.box(tF(tP({},n),{category:V})).root}})(null==(e=t.tableColumn)||e.temp[O].type,n,i),r.setUpdateIndicator(l,!1)}r.empty(l),l.appendChild(t.tableColumn.temp.unitedPlot)},10)):e.shell.dockManager.close(l)});this.subs.push(u,a)}constructor(t,n){let i=void 0===n?{}:n;super(window.grok_TableView(t.dart,!1)),i.parentView&&(this.parentView=i.parentView),this.parentCall=i.parentCall||e.functions.getCurrentCall()}}var tB=n(2),tk=n.n(tB),tD=n(611),tL=n.n(tD),tj=n(129),tM=n.n(tj),tN=n(986),t_=n.n(tN),tU=n(838),tH=n.n(tU),t$=n(515),tW=n.n(t$),tY=n(76),tG={};function tq(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function tJ(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){tq(o,i,r,s,l,"next",t)}function l(t){tq(o,i,r,s,l,"throw",t)}s(void 0)})}}tG.styleTagTransform=tW(),tG.setAttributes=t_(),tG.insert=tM().bind(null,"head"),tG.domAPI=tL(),tG.insertStyleElement=tH(),tk()(tY.A,tG),tY.A&&tY.A.locals&&tY.A.locals;let tz="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class tK 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()}subscribeOnEvents(){this.input.readOnly=!0,this.input.classList.add("default");let t=t=>tJ(function*(){if(t&&t.length&&this.enabled){if(t.length>1)throw this.isValid.next(!1),Error("Please specify single input file");if(this.fileType&&t[0].type!==this.fileType)throw this.isValid.next(!1),Error("File type is not supported");this.isValid.value?this.uploadedFile$.next(t[0]):this.uploadedFile$.next(null)}}).call(this);this.root.classList.add("fi-drop-area"),this.root.style.width="100%",this.hiddenInput.type="file",this.hiddenInput.addEventListener("change",()=>tJ(function*(){return yield t(this.hiddenInput.files)}).call(this),!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=>tJ(function*(){t(e.dataTransfer.files)})(),!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)}constructor(t,e,n,i){let o=void 0===i?tz:i;super(r.input.string("Input file",{value:""}).dart),this.initialText=void 0===t?"Drag-n-drop here":t,this.initialValue=void 0===e?null:e,this.onValueChanged=void 0===n?null: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=r.iconFA("cloud-upload",()=>this.hiddenInput.click(),"Upload"),this.subscribeOnEvents(),this.root.style.display="flex",this.isValid.subscribe(t=>{if(t){this.input.classList.remove("error"),this.input.classList.add("success");let t=r.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");let t=r.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){let t=r.iconFA("cloud-upload",()=>this.hiddenInput.click(),"Choose a file to upload");this.icon.replaceWith(t),this.icon=t}this.value=t}),this.reset()}}var tZ=n(602),tX={};tX.styleTagTransform=tW(),tX.setAttributes=t_(),tX.insert=tM().bind(null,"head"),tX.domAPI=tL(),tX.insertStyleElement=tH(),tk()(tZ.A,tX),tZ.A&&tZ.A.locals&&tZ.A.locals;var tQ=n(474),t0=n.n(tQ);function t1(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function t2(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){t1(o,i,r,s,l,"next",t)}function l(t){t1(o,i,r,s,l,"throw",t)}s(void 0)})}}function t5(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}class t3 extends o.Dialog{static forFuncCall(t,e){var n,i,r;let o=null!=(n=t.options.title)?n:"";return new t3({title:o,description:null!=(i=t.options.description)?i:"",tags:null!=(r=t.options.tags)?r:[],isFavorite:void 0!==e&&e})}awaitMetadata(t){let e=(0,s.race)(this.onMetadataEdit,this.onClose.pipe((0,l.map)(()=>null))).pipe((0,l.take)(1));return this.show(t5({center:!0,width:500},t)),e.toPromise()}constructor(t){var n,i,l,a,u;super(r.dialog({title:"Save model state"}).dart),n=this,this._onMetadataEdit=new s.Subject,this.onMetadataEdit=this._onMetadataEdit.asObservable();let c=null!=(i=null==t?void 0:t.title)?i:"",d=null!=(l=null==t?void 0:t.description)?l:"",p=null!=(a=null==t?void 0:t.isFavorite)&&a;const h=r.input.string("Title",{value:c,onValueChanged:t=>c=t}),f=r.input.string(" ",{value:""}),m=o.TagEditor.create();(null!=(u=null==t?void 0:t.tags)?u:[]).forEach(t=>{m.addTag(t)}),f.input.replaceWith(m.root);const v=()=>{""===y.value||m.tags.includes(y.value)||(m.addTag(y.value),y.value="")},y=r.input.string("Tag",{value:""}).addOptions(r.iconFA("plus",v,"Add this tag")),g=(0,s.fromEvent)(y.input,"onkeydown").subscribe(t=>{"Enter"==t.key&&(t.stopPropagation(),v())});this.sub(g);const b=r.input.string("Description",{value:d,onValueChanged:t=>d=t}),C=r.input.bool("Is favorite",{value:p,onValueChanged:t=>p=t});this.add(r.form([h,b,C,y,f])),this.addButton("Save",()=>t2(function*(){if(""!==y.value)return void e.shell.info(`Dialog has unsaved tags: ${y.value}`);let t={title:""!==c?c:null,description:""!==d?d:null,isFavorite:p,tags:m.tags.map(t=>t)};n._onMetadataEdit.next(t),n.close()})())}}class t4 extends o.Dialog{awaitDelete(t){let e=(0,s.race)(this.onFuncCallDelete,this.onClose.pipe((0,l.map)(()=>null))).pipe((0,l.take)(1));return this.show(t5({center:!0,width:500},t)),e.toPromise()}constructor(t){var e;super(r.dialog({title:`Delete ${t.size>1?t.size:""} ${t.size>1?"runs":"run"}`}).dart),e=this,this._onFuncCallDelete=new s.Subject,this.onFuncCallDelete=this._onFuncCallDelete.asObservable(),this.add(r.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(()=>t2(function*(){return e._onFuncCallDelete.next(t)})())}}function t6(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function t8(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){t6(o,i,r,s,l,"next",t)}function l(t){t6(o,i,r,s,l,"throw",t)}s(void 0)})}}let t7=(t,n)=>t8(function*(){let i=`${B}_${t.func.name}_Fav`;return n?e.dapi.userDataStorage.postValue(i,t.id,""):e.dapi.userDataStorage.remove(i,t.id)})(),t9=t=>t.options.mainParams?JSON.parse(t.options.mainParams):null,et=(t,e)=>{var n,i;return null!=(n=null!=(i=null==e?void 0:e.visibleProps)?i:t9(t))?n:t.inputs.filter(t=>Y.includes(t.propertyType)).map(t=>t.name)},ee=t=>t.replace(/([A-Z])/g,t=>` ${t.toLowerCase()}`).trim().replace(/^./,t=>t.toUpperCase()),en=(t,e)=>{var n,i,r,o,s,l,a;if(e===M)return null!=(n=null==(a=t.author)?void 0:a.friendlyName)?n:" ";let u=null!=(i=null!=(r=null!=(o=null!=(s=t[e])?s:t.inputs[e])?o:t.outputs[e])?r:t.options[e])?i:null;return null!=(l=null==u?void 0:u.toString())?l:""};function ei(t){return t&&t.root&&t.onInput}function er(t){return(null==t?void 0:t.setValidation)&&ei(t)}function eo(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)&&ei(t)}function es(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function el(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}function ea(t){var e;return!(null==t||null==(e=t.errors)?void 0:e.length)&&!(null==t?void 0:t.pending)}function eu(t,e){return{description:t,actions:e}}function ec(t){var e,n,i;let r=t=>"string"==typeof t?eu(t):t;return{errors:null==t||null==(e=t.errors)?void 0:e.map(t=>r(t)),warnings:null==t||null==(n=t.warnings)?void 0:n.map(t=>r(t)),notifications:null==t||null==(i=t.notifications)?void 0:i.map(t=>r(t))}}function ed(...t){let e=[],n=[],i=[],r=[],o={};var s=!0,l=!1,a=void 0;try{for(var u,c,d,p,h,f,m=t[Symbol.iterator]();!(s=(f=m.next()).done);s=!0){let t=f.value;t&&(e.push(...null!=(u=t.errors)?u:[]),n.push(...null!=(c=t.warnings)?c:[]),i.push(...null!=(d=t.notifications)?d:[]),r.push(...null!=(p=t.revalidate)?p:[]),o=el({},o,null!=(h=t.context)?h:{}))}}catch(t){l=!0,a=t}finally{try{s||null==m.return||m.return()}finally{if(l)throw a}}return{errors:e,warnings:n,notifications:i,revalidate:r,context:o}}function ep(){return{pending:!0}}function eh(t,e,n){return el({revalidate:t,context:e},n)}function ef(t){var e,n;let i,o,s;return(null==t?void 0:t.pending)&&(o=r.iconFA("spinner",()=>{em(t,o,i)},"Validating")).classList.add("fa-spin"),(null==t?void 0:t.errors)&&t.errors.length?(o=r.iconFA("exclamation-circle",()=>{em(t,o,i)},"Validation")).style.color="var(--red-3)":(null==t?void 0:t.warnings)&&t.warnings.length?(o=r.iconFA("exclamation-circle",()=>{em(t,o,i)},"Validation")).style.color="var(--orange-2)":(null==t?void 0:t.notifications)&&t.notifications.length&&((o=r.iconFA("info-circle",()=>{em(t,o,i)},"Info")).style.color="var(--blue-1)"),o&&(o.classList.remove("fal"),o.classList.add("far"),e=o,(n=s=r.div([],"d4-tooltip")).popover="auto",n.style.fontStyle="normal",n.style.pointerEvents="all",n.style.maxWidth="300px",n.style.textWrap="pretty",e.appendChild(s),i=s),[null!=o?o:r.div(),null!=i?i:r.div()]}function em(t,e,n){if(n&&e){var i,o;let s;for(i=e,o=n,s=i.getBoundingClientRect().toJSON(),o.style.inset="unset",o.style.top=s.y+"px",o.style.left=s.x+20+"px";n.firstChild&&n.removeChild(n.firstChild););let l=function(t){let e=r.divV([],{style:{gap:"10px"}});for(let u=0,c=["errors","warnings","notifications"];u<c.length;u++){let d=c[u],p=t[d];if(null==p?void 0:p.length){var n=!0,i=!1,o=void 0;try{for(var s,l,a=p[Symbol.iterator]();!(n=(l=a.next()).done);n=!0){let t=l.value,n=function(t){let e;return"errors"===t?(e=r.iconFA("exclamation-circle")).style.color="var(--red-3)":"warnings"===t?(e=r.iconFA("exclamation-circle")).style.color="var(--orange-2)":"notifications"===t&&((e=r.iconFA("info-circle")).style.color="var(--blue-1)"),e&&(e.classList.remove("fal"),e.classList.add("far")),e}(d);n.style.marginRight="4px",e.appendChild(r.divV([r.divH([n,r.span([t.description])]),...(null!=(s=t.actions)?s:[]).map(t=>r.link(t.actionName,t.action,void 0,{style:{paddingLeft:"20px"}}))]))}}catch(t){i=!0,o=t}finally{try{n||null==a.return||a.return()}finally{if(i)throw o}}}}return e}(t);n.appendChild(l),n.showPopover()}}let ev="restrictedValues",ey="editState";(u=m||(m={})).INPUT="Input",u.OUTPUT="Output",(c=v||(v={})).HIDDEN="hidden",c.VISIBLE="visible",(d=y||(y={})).ENABLED="enabled",d.DISABLED="disabled",(p=g||(g={})).INPUTS="inputs",p.OUTPUTS="outputs";let eg={[g.INPUTS]:"inputParams",[g.OUTPUTS]:"outputParams"};function eb(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function eC(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function ew(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){eC(o,i,r,s,l,"next",t)}function l(t){eC(o,i,r,s,l,"throw",t)}s(void 0)})}}function eA(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n,i,r=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var o=[],s=!0,l=!1;try{for(r=r.call(t);!(s=(n=r.next()).done)&&(o.push(n.value),!e||o.length!==e);s=!0);}catch(t){l=!0,i=t}finally{try{s||null==r.return||r.return()}finally{if(l)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return eb(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eb(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ex(t){return t.dart&&o.toJs(t.dart)instanceof o.InputBase}let eI=t=>ew(function*(){let e=t.id,n=o.Func.byName(t.func.nqName).prepare([...t.inputs].reduce((t,e)=>{let n=eA(e,2),i=n[0],r=n[1];return t[i]=r,t},{}));return t.options.forEach(e=>n.options[e]=t.options[e]),e||(n.id=null),n})();function eE(t,e){return ew(function*(){let n={};var i=!0,r=!1,s=void 0;try{for(var l,a=Object.entries(t.inputs)[Symbol.iterator]();!(i=(l=a.next()).done);i=!0){let t=eA(l.value,2),i=t[0],r=t[1],s=e.funcCall.inputParams[i].property;n[i]=yield function(t,e,n){return ew(function*(){if("file"===t.propertyType&&n.getInput){let e=n.getInput(t.name).value;return e instanceof o.FileInfo?(yield e.readAsBytes()).buffer:yield e.arrayBuffer()}return e})()}(s,r,e)}}catch(t){r=!0,s=t}finally{try{i||null==a.return||a.return()}finally{if(r)throw s}}return{inputs:n,outputs:t.outputs}})()}function eR(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function eS(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function eT(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){eS(o,i,r,s,l,"next",t)}function l(t){eS(o,i,r,s,l,"throw",t)}s(void 0)})}}function eO(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}x().extend(t0());let eP=new o.LruCache;class eF extends o.Widget{get type(){return"HistoricalRunsList"}get onRunsDfChanged(){return this._onRunsDfChanged.asObservable()}get onChosen(){return this._onChosen.asObservable()}get chosen(){return this._onChosen.value}set chosen(t){var e;this.chosenById=null!=(e=null==t?void 0:t.id)?e:null}set chosenById(t){if(!t){this.currentDf.currentRowIdx=-1;return}for(let e=0;e<this.currentDf.rowCount;e++)if(this.currentDf.getCol("ID").get(e)===t){this.currentDf.currentRowIdx=e;break}}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("ID",t))}showEditDialog(t,n){let i=t3.forFuncCall(t,n);i.onMetadataEdit.pipe((0,l.take)(1)).subscribe(i=>eT(function*(){var r;if(null==(r=this.options)?void 0:r.isHistory)try{!!i.isFavorite!==n&&(yield t7(t,!!i.isFavorite));let e=yield f.shallowLoadRun(t.id);i.title&&(e.options.title=i.title),i.description&&(e.options.description=i.description),i.tags&&(e.options.tags=i.tags),yield f.updateRunMeta(e),this.updateRun(e),this.onMetadataEdit.next(e)}catch(t){e.shell.error(t)}else this.updateRun(t)}).call(this)),i.show({center:!0,width:500})}isFavoriteByIndex(t){return this.currentDf.get(D,t)}setGridCellRendering(){var t,n,i,o,s;let a=t=>{let e=this.getRunByIdx(t.tableRowIndex);this.showEditDialog(e,this.isFavoriteByIndex(t.tableRowIndex))},u=t=>{let n=new Set([this.getRunByIdx(t.tableRowIndex)]),i=new t4(n);i.onFuncCallDelete.pipe((0,l.take)(1)).subscribe(()=>eT(function*(){r.setUpdateIndicator(this.root,!0);try{yield Promise.all(E()(n.values()).map(t=>eT(function*(){return yield this.deleteRun(t.id),Promise.resolve()}).call(this)))}catch(t){e.shell.error(t)}finally{r.setUpdateIndicator(this.root,!1)}}).call(this)),i.show({center:!0,width:500})},c=t=>{let e=this.getRunByIdx(t.tableRowIndex);t7(e,!0).then(()=>this.updateRun(e))},d=t=>{let e=this.getRunByIdx(t.tableRowIndex);t7(e,!1).then(()=>this.updateRun(e))};i=this._historyGrid,o=this.runs,s=null!=(t=null==(n=this.options)?void 0:n.showActions)&&t,i.onCellPrepare(t=>{var n,l,p,h,f,m,v,y,g,b;if(t.isColHeader&&(null==(n=t.tableColumn)?void 0:n.name)&&[j,k,D].includes(t.tableColumn.name)&&(t.customText=""),!t.isColHeader){if((null==(l=t.tableColumn)?void 0:l.name)===j&&(t.customText="",t.element=r.divH([r.iconFA("trash",()=>u(t),"Remove run from history"),r.iconFA("edit",()=>a(t),"Edit run metadata")],{style:{padding:"6px",gap:"6px",justifyContent:"space-between"}})),(null==(p=t.tableColumn)?void 0:p.name)===D){t.customText="";let e=r.iconFA("star",()=>d(t),"Unfavorite");C()(e).addClass("fas"),t.element=r.div(t.cell.value?e:r.iconFA("star",()=>c(t),"Favorite"),{style:{padding:"6px"}})}if((null==(h=t.tableColumn)?void 0:h.name)===k){t.customText="";let e=r.iconFA("flask",null,"Experimental run");C()(e).addClass("fad fa-sm"),C()(e).removeClass("fal"),t.element=t.cell.value&&"Experimental"===t.cell.value?r.div(e,{style:{padding:"6px"}}):r.div()}if((null==(f=t.tableColumn)?void 0:f.name)===H){t.customText="";let e=t.cell.value.length>0?r.div(null==(v=t.cell.value)?void 0:v.split(",").map(t=>r.span([t],"d4-tag")),"d4-tag-editor"):r.div();C()(e).css({padding:"3px","background-color":"transparent"}),t.element=e}if((null==(m=t.tableColumn)?void 0:m.name)==="ID"){let n,l;t.customText="";let p=(n=t.tableRowIndex,o.get(i.dataFrame.get("ID",n)));if(!p)return;let h=p.author.picture;C()(h).css({width:"25px",height:"25px",fontSize:"20px"}),r.bind(p.author,h);let f=r.iconFA("flask",null,"Experimental run");f.classList.add("fad","fa-sm"),f.classList.remove("fal"),f.style.marginLeft="3px";let m=p.options.immutable_tags,v=r.span([r.label(null!=(y=null!=(g=p.options.title)?g:null==(b=p.author)?void 0:b.friendlyName)?y:e.shell.user.friendlyName,{style:{color:"var(--blue-1)"}}),...m&&m.includes(P)?[f]:[]]),w=r.iconFA("edit",e=>{e.stopPropagation(),a(t)},"Edit run metadata");w.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");let A=r.iconFA("trash-alt",e=>t8(function*(){e.stopPropagation(),u(t)})(),"Delete run");A.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");let x=r.iconFA("star",e=>{e.stopPropagation(),d(t)},"Unfavorite");x.classList.add("fas","hp-funccall-card-icon");let I=r.iconFA("star",e=>{e.stopPropagation(),c(t)},"Favorite");I.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon"),(l=t.tableRowIndex,i.dataFrame.get(D,l))?(r.setDisplay(I,!1),r.setDisplay(x,!0)):(r.setDisplay(x,!1),r.setDisplay(I,!0));let E=tm(p),R=r.divH([r.divH([h,r.divV([v,r.span([E]),...p.options.tags&&p.options.tags.length>0?[r.div(p.options.tags.map(t=>r.span([t],"d4-tag")))]:[]],"hp-card-content")]),r.divH([...s?[x,I,w,A]:[]])],"hp-funccall-card"),S=t.tableRowIndex;R.addEventListener("mouseover",()=>{t.grid.dataFrame.mouseOverRowIdx=S}),R.addEventListener("click",e=>{e.shiftKey?t.grid.dataFrame.selection.set(S,!0):e.ctrlKey?t.grid.dataFrame.selection.set(S,!1):t.grid.dataFrame.currentRowIdx=S}),t.element=R}}})}deleteRun(t){return eT(function*(){return f.shallowLoadRun(t).then(t=>eT(function*(){var e;return[(yield(null==(e=this.options)?void 0:e.isHistory)?f.deleteRun(t):Promise.resolve()),t]}).call(this)).then(e=>{var n;let i=(function(t){if(Array.isArray(t))return t}(e)||function(t){var e,n,i=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(t);!(o=(e=i.next()).done)&&(r.push(e.value),2!==r.length);o=!0);}catch(t){s=!0,n=t}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(e)||function(t){if(t){if("string"==typeof t)return eR(t,2);var e=Object.prototype.toString.call(t).slice(8,-1);if("Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e)return Array.from(e);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return eR(t,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[1];return this.runs.delete(t),this.onRunsChanged.next(this.runs),(null==(n=this.options)?void 0:n.isHistory)&&this.onDelete.next(i),i}).then(t=>{t7(t,!1)}).catch(t=>{e.shell.error(t)})}).call(this)}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;((t,e,n,i,r,s)=>{var l;let a,u,c,d,p,h;s&&t.setOptions({showCurrentRowIndicator:!0,showCurrentCellOutline:!1,allowEdit:!1,allowBlockSelection:!1,showRowHeader:!1,showColumnLabels:!e,extendLastColumn:e}),t.sort([N],[!1]);for(let e=0;e<t.columns.length;e++){let n=t.columns.byIndex(e);n&&(null==(l=n.column)?void 0:l.type)===o.TYPE.DATE_TIME&&(n.format="MMM d, h:mm tt")}if((a=t.columns.byName(j))&&(a.cellType="html",a.width=45),(u=t.columns.byName(D))&&(u.cellType="html",u.width=30),(c=t.columns.byName(k))&&(c.cellType="html",c.width=30),(d=t.columns.byName(H))&&(d.cellType="html",d.width=90),(p=t.columns.byName(N))&&(p.width=110),(h=t.columns.byName("ID"))&&(h.cellType="html"),e)t.columns.setVisible(["ID"]),t.props.rowHeight=70,t.invalidate();else{t.props.rowHeight=28;let e=t.dataFrame.getCol(H);t.columns.setVisible([k,D,j,...i?[N]:[],...i?[M]:[],...i&&e.stats.missingValueCount<e.length?[H]:[],...i?[_]:[],...i?[U]:[],...n&&r?et(r).map(t=>{var e,n;let i=null!=(e=r.inputs.find(e=>e.name===t))?e:r.outputs.find(e=>e.name===t);return i?null!=(n=i.caption)?n:ee(i.name):ee(t)}):[]])}})(this._historyGrid,this._compactMode.value,this.showInputsIcon.value,this.showMetadataIcon.value,null==(t=this.runs.values().next().value)?void 0:t.func)}get currentDf(){return this._onRunsDfChanged.value}styleHistoryFilters(){var t,e,n,i,o,s,l,a,u;let c,d,p,h=null==(e=this.runs.values().next().value)?void 0:e.func;(i=this._historyFilters,o=this.showMetadataIcon.value,s=this.showInputsIcon.value,l=null!=(t=null==(n=this.options)?void 0:n.isHistory)&&t,d=(c=i.dataFrame).getCol(H),(p=[...o&&c.getCol(k).categories.length>1?[k]:[],...o&&(null!=(a=null==(u=c.col(D))?void 0:u.categories.length)?a:0)>1?[D]:[],...o?[N,L]:[],...o&&c.getCol(M).categories.length>1?[M]:[],...o&&d.stats.missingValueCount<d.length?[H]:[],...o&&c.getCol(_).categories.length>1?[_]:[],...o&&c.getCol(U).categories.length>1?[U]:[],...h&&s?et(h).map(t=>{var e,n;let i=null!=(e=h.inputs.find(e=>e.name===t))?e:h.outputs.find(e=>e.name===t);return i?null!=(n=i.caption)?n:ee(i.name):ee(t)}).filter(t=>!l||c.getCol(t).categories.length>1).map(t=>t):[]]).length>0?(r.setDisplay(i.root,!0),i.setOptions({columnNames:p,showHeader:!1,showBoolCombinedFilter:!0})):r.setDisplay(i.root,!1),p.length>0)?(C()(this.filterWithText).css({paddingTop:"10px"}),r.setDisplay(this.defaultFiltersText,!1)):r.setDisplay(this.defaultFiltersText,!0)}redrawSelectionState(){let 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")}constructor(t,n){var i,a,u,c,d,p,h,m;super(r.div([],{style:{height:"100%",width:"100%"}})),i=this,this.initialRuns=t,this.options=n,this.onRunsChanged=new s.BehaviorSubject(this.initialRuns.reduce((t,e)=>(t.set(e.id,e),t),new Map)),this._onRunsDfChanged=new s.BehaviorSubject(o.DataFrame.fromColumns([o.Column.bool(k,0),...(null==(c=this.options)?void 0:c.isHistory)?[o.Column.bool(D,0)]:[],...(null==(d=this.options)?void 0:d.showActions)?[o.Column.string(j,0)]:[],o.Column.bool(L,0),o.Column.dateTime(N,0),o.Column.string(M,0),o.Column.string(H,0),o.Column.string(_,0),o.Column.string(U,0),o.Column.fromStrings("ID",[])])),this._historyFilters=o.Viewer.filters(this._onRunsDfChanged.value,{title:"Filters",columnNames:[]}),this._historyGrid=o.Viewer.grid(this._onRunsDfChanged.value,{showRowHeader:!1,showColumnGridlines:!1,allowEdit:!1}),this.onComparisonCalled=new s.Subject,this.onMetadataEdit=new s.Subject,this._onChosen=new s.BehaviorSubject(null),this.onDelete=new s.Subject,this._onSelectedChanged=new s.BehaviorSubject(new Set([])),this.layout=r.splitH([],null,!0),this.defaultGridText=r.divText(null!=(a=null==(p=this.options)?void 0:p.fallbackText)?a:"No historical runs found","hp-no-elements-label"),this.defaultFiltersText=r.divText("No filters to show","hp-no-elements-label"),this.filterWithText=r.divH([this.defaultFiltersText,this._historyFilters.root],"ui-box"),this.trashIcon=r.div(r.iconFA("trash-alt",()=>{let t=this.currentDf.selection.getSelectedIndexes(),n=new Set;t.forEach(t=>n.add(this.getRunByIdx(t)));let o=new t4(n);o.onFuncCallDelete.pipe((0,l.take)(1)).subscribe(t=>eT(function*(){r.setUpdateIndicator(i.root,!0);try{yield Promise.all(E()(t.values()).map(t=>eT(function*(){return yield i.deleteRun(t.id),Promise.resolve()})()))}catch(t){e.shell.error(t)}finally{r.setUpdateIndicator(i.root,!1)}})()),o.show({center:!0,width:500,modal:!0})},"Delete selected runs"),{style:{paddingTop:"5px"}}),this.compareIcon=r.div(r.iconFA("exchange",()=>eT(function*(){let t=i.currentDf.selection.getSelectedIndexes(),e=[];t.forEach(t=>{e.push(i.currentDf.getCol("ID").get(t))}),i.onComparisonCalled.next(e)})(),"Compare selected runs"),{style:{paddingTop:"5px"}}),this._isFilterHidden=new s.BehaviorSubject(!1),this.showFiltersIcon=r.div(r.iconFA("filter",()=>{this._isFilterHidden.next(!this._isFilterHidden.value)},"Toggle filters"),{style:{paddingTop:"4px"}}),this._compactMode=new s.BehaviorSubject(null!=(u=null==(h=this.options)?void 0:h.isHistory)&&u),this.toggleCompactMode=r.div(r.iconFA("expand-alt",()=>{this.compactMode=!this.compactMode},"Toggle compact mode"),{style:{paddingTop:"4px"}}),this.showMetadataIcon=r.input.toggle("Metadata",{value:!0,onValueChanged:()=>{this.styleHistoryGrid(),this.styleHistoryFilters()}}),this.showInputsIcon=r.input.toggle("Params",{value:!1,onValueChanged:t=>eT(function*(){var e;0!==i.runs.size&&(t&&(null==(e=i.options)?void 0:e.isHistory)?((yield Promise.all([...i.runs.values()].map(t=>eT(function*(){if(eP.has(t.id))return eP.get(t.id);{let e=yield f.shallowLoadRun(t.id);return eP.set(e.id,e),e}})()))).forEach(t=>{i.runs.set(t.id,t)}),i.onRunsChanged.next(i.runs)):(i.styleHistoryGrid(),i.styleHistoryFilters()))})()});const v=r.divH([r.divH([...(null==n?void 0:n.isHistory)?[this.toggleCompactMode]:[],this.showFiltersIcon,this.showMetadataIcon.root,this.showInputsIcon.root],{style:{gap:"5px",padding:"5px"}}),r.divH((null==(m=this.options)?void 0:m.showBatchActions)?[this.trashIcon,this.compareIcon]:[],{style:{gap:"5px",padding:"5px"}})],{style:{justifyContent:"space-between",padding:"0px 5px"}});v.style.setProperty("overflow-y","hidden","important");const y=r.divV([this.defaultGridText,v,this._historyGrid.root],"ui-box");C()(y).removeClass("ui-div"),C()(y).css("width","100%"),this.root.appendChild(this.layout),r.setDisplayAll([this._historyGrid.root,this._historyFilters.root,this.toggleCompactMode,this.trashIcon,this.compareIcon,this.showFiltersIcon],!1);const g=this.onRunsChanged.subscribe(t=>eT(function*(){if(i.setGridCellRendering(),t.size>0){let n,s,l=yield(n=t.values().next().value.func,s=i.options,t8(function*(){var i;let r=[...t.values()],l=t=>t===N?o.Column.dateTime(ee(t),r.length).init(t=>window.grok_DayJs_To_DateTime(td(r[t])?r[t].started.utc(!0):x().unix(r[t].options.createdOn))):t===L?o.Column.bool(ee(t),r.length).init(t=>!tp(r[t])):o.Column.fromStrings(ee(t),r.map(e=>{var n,i,r;return null!=(n=null==s||null==(r=s.propFuncs)||null==(i=r[t])?void 0:i.call(r,e))?n:en(e,t)})),a=Object.keys(null!=(i=yield e.dapi.userDataStorage.get(`${B}_${n.name}_Fav`))?i:{}),u=o.DataFrame.fromColumns([o.Column.string(k,r.length).init(t=>{let e=r[t].options.immutable_tags;return e&&e.includes(P)?"Experimental":"Simulated"}),...(null==s?void 0:s.isHistory)?[o.Column.bool(D,r.length).init(t=>a.includes(r[t].id))]:[],...(null==s?void 0:s.showActions)?[o.Column.string(j,r.length).init("")]:[],l(N),l(L),l(M),o.Column.string(H,r.length).init(t=>r[t].options.tags?r[t].options.tags.join(","):""),o.Column.string(_,r.length).init(t=>r[t].options.title),o.Column.string(U,r.length).init(t=>r[t].options.description),o.Column.string(W,r.length).init(t=>r[t].options.version)]);if(et(n).map(t=>(t=>{var e,i,a;let u=null!=(e=n.inputs.find(e=>e.name===t))?e:n.outputs.find(e=>e.name===t);return u?u.propertyType===o.TYPE.DATE_TIME?o.Column.dateTime(null!=(a=u.caption)?a:ee(u.name),r.length).init(t=>window.grok_DayJs_To_DateTime(r[t].inputs[u.name])):o.Column.fromType(u.propertyType,null!=(i=u.caption)?i:ee(u.name),r.length).init(t=>{var e,n,i;return null!=(e=null==s||null==(i=s.propFuncs)||null==(n=i[u.name])?void 0:n.call(i,r[t]))?e:en(r[t],u.name)}):l(t)})(t)).forEach(t=>{t.name=u.columns.getUnusedName(t.name),u.columns.add(t,!1)}),u.columns.add(o.Column.fromStrings("ID",r.map(t=>t.id))),!(null==s?void 0:s.allowOtherVersions)&&(null==s?void 0:s.version)){let t=o.BitSet.create(u.rowCount,()=>!1);for(let e=0;e<u.rowCount;e++)(null==s?void 0:s.version)==u.get(W,e)&&t.set(e,!0);return u.clone(t)}return u})()),a=t.values().next().value.func;r.setDisplayAll([i.defaultGridText,i.defaultFiltersText],!1),r.setDisplayAll([i._historyGrid.root,i._historyFilters.root,i.toggleCompactMode,i.showMetadataIcon.root,i.trashIcon,i.compareIcon,i.showFiltersIcon],!0),r.setDisplay(i.showInputsIcon.root,et(a,i.options).length>0),i._onRunsDfChanged.next(l)}else r.setDisplayAll([i.defaultGridText,i.defaultFiltersText],!0),r.setDisplayAll([i._historyGrid.root,i._historyFilters.root,i.showMetadataIcon.root,i.showInputsIcon.root,i.toggleCompactMode,i.trashIcon,i.compareIcon,i.showFiltersIcon],!1)})()),b=this._onRunsDfChanged.subscribe(t=>{this._historyFilters.dataFrame=t,this._historyGrid.dataFrame=t,this.currentDf.getCol(H).meta.multiValueSeparator=",",this.styleHistoryGrid(),this.styleHistoryFilters();let e=t.onCurrentRowChanged.subscribe(()=>{var t;this.currentDf.rows.select(()=>!1),this._onChosen.next(null!=(t=this.getRunByIdx(this.currentDf.currentRowIdx))?t:null)}),n=t.onSelectionChanged.subscribe(()=>{let e=[...t.selection.getSelectedIndexes()].map(t=>this.getRunByIdx(t));this._onSelectedChanged.next(new Set(e)),this.redrawSelectionState()});this.redrawSelectionState(),this.subs.push(e,n)}),w=this._isFilterHidden.subscribe(t=>{t?(C()(this.showFiltersIcon.firstChild).addClass("fal"),C()(this.showFiltersIcon.firstChild).removeClass("fad"),r.setDisplay(this.filterWithText,!1)):(C()(this.showFiltersIcon.firstChild).addClass("fad"),C()(this.showFiltersIcon.firstChild).removeClass("fal"),C()(this.filterWithText).css(this.compactMode?"height":"width","320px"),C()(this.filterWithText).css(this.compactMode?"width":"height","100%"),r.setDisplay(this.filterWithText,!0))}),A=this._compactMode.subscribe(t=>{let e=[y,this.filterWithText];C()(this.filterWithText).removeClass("ui-div");let n={style:{width:"100%",height:"100%"}};C()(this.toggleCompactMode.firstChild).addClass(t?"fa-expand-alt":"fa-compress-alt"),C()(this.toggleCompactMode.firstChild).removeClass(t?"fa-compress-alt":"fa-expand-alt");let i=t?r.splitV(e,n,!0):r.splitH(e,n,!0);this.layout.replaceWith(i),this.layout=i,r.tools.waitForElementInDom(this.layout).then(t=>{C()(t).css(this.compactMode?"height":"width","100%"),C()(this._historyFilters.root).css(eO({},this.compactMode?{width:"100%"}:{height:"100%"})),C()(this.filterWithText).css(eO({},this.compactMode?{height:"310px",width:"100%"}:{width:"310px",height:"100%"})),C()(y).css(eO({},this.compactMode?{width:"100%"}:{height:"100%"})),setTimeout(()=>{this.styleHistoryGrid(),this.styleHistoryFilters()},100)})});this.subs.push(g,A,b,w)}}function eV(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function eB(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){eV(o,i,r,s,l,"next",t)}function l(t){eV(o,i,r,s,l,"throw",t)}s(void 0)})}}class ek{static getHistoryRuns(t,n){let i=void 0===n||n;return(0,s.from)(eB(function*(){return yield f.pullRunsByName(t,[{author:e.shell.user}],{order:"started"},["func.params","session.user","options"],i)})())}}class eD extends o.InputBase{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,n,i;let r=new eF([...this._historyList.runs.values()],(n=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}({},this.options),i=i={visibleProps:null==(t=this.options)?void 0:t.mainProps,propFuncs:null==(e=this.options)?void 0:e.propFuncs},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(i)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(i,t))}),n));this._historyList.root.replaceWith(r.root),this._historyList=r,this._historyList.onChosen.subscribe(t=>{this._historyDialog.getButton("OK").disabled=!t}),this._historyList.onRunsDfChanged.pipe((0,l.filter)(t=>t.rowCount>0),(0,l.take)(1)).subscribe(()=>{this.setCurrentRow()})}getHistoryDialog(){let t=r.dialog();return C()(t.root.querySelector(".d4-dialog-contents")).removeClass("ui-form"),t.onOK(()=>eB(function*(){let t=this._historyList.chosen;if(t){var e,n;(null==(e=null==(n=this.options)?void 0:n.skipDfsOnInit)||e)&&(t=yield f.loadRun(t.id)),this.setValue(t)}this.fireInput()}).call(this)),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"),C()(t.getButton("CANCEL")).hide(),t.add(this._historyList.root),t}setValue(t){var e,n,i,r,o,s,l;this._chosenRun=t,this._chosenRunId=null!=(e=null==(n=this._chosenRun)?void 0:n.id)?e:null,this.onHistoricalRunChosen.next(t),t?this.stringValue=(null==(o=this.options)?void 0:o.stringValueFunc)?null==(s=this.options)?void 0:s.stringValueFunc(t):[`${tm(t)} \\ ${t.author.name}`,(null!=(i=null!=(r=null==(l=this.options)?void 0:l.mainProps)?r:t9(t.func))?i:[]).map(e=>en(t,e)).join(" \\ ")].join(" \\ "):this.stringValue="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)}constructor(t,e,n){var i,o;const a=r.input.string(t,{value:""});super(a.dart),this.label=t,this._funcName=e,this.options=n,this.onHistoricalRunChosen=new s.BehaviorSubject(null),this.experimentRunsUpdate=new s.Subject,this.store={experimentRuns:new s.Observable,isExperimentRunsLoading:new s.Subject,experimentRunData:new s.BehaviorSubject("")},this._historyList=new eF([],{fallbackText:"No runs are found in history",showActions:!1,showBatchActions:!1,isHistory:!1,visibleProps:null==(i=this.options)?void 0:i.mainProps,propFuncs:null==(o=this.options)?void 0:o.propFuncs}),this._historyDialog=this.getHistoryDialog(),this._visibleInput=r.input.string(this.label,{value:""}),this._visibleIcon=r.iconFA("search",()=>this.showSelectionDialog(),"Search"),this._chosenRun=null,this._chosenRunId=null,this._visibleInput=a,this._visibleInput.readOnly=!0,this._visibleInput.input.addEventListener("click",()=>this.showSelectionDialog()),this._visibleInput.addOptions(this._visibleIcon),this.store.experimentRuns=this.experimentRunsUpdate.pipe((0,l.tap)(()=>this.toggleLoaderExpRuns(!0)),(0,l.switchMap)(()=>{var t,e;return ek.getHistoryRuns(this._funcName,null==(t=null==(e=this.options)?void 0:e.skipDfsOnInit)||t).pipe((0,l.catchError)(t=>(console.error(t),s.EMPTY)),(0,l.finalize)(()=>this.toggleLoaderExpRuns(!1)))}),(0,l.shareReplay)(1)),this.store.experimentRuns.subscribe(t=>{this._historyList.updateRuns(t.filter(t=>!tp(t)))}),this.store.isExperimentRunsLoading.subscribe(t=>{r.setUpdateIndicator(this._visibleInput.root,t),r.setUpdateIndicator(this._historyList.root,t)}),this.experimentRunsUpdate.next()}}class eL extends eD{set value(t){this.setValue(t)}get value(){return this.getValue()}}class ej extends eD{get value(){let 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("-"):""}}var eM=n(128),eN={};function e_(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}eN.styleTagTransform=tW(),eN.setAttributes=t_(),eN.insert=tM().bind(null,"head"),eN.domAPI=tL(),eN.insertStyleElement=tH(),tk()(eM.A,eN),eM.A&&eM.A.locals&&eM.A.locals;class eU extends o.Widget{get type(){return"HistoryPanel"}updateHistoryPane(t){this.historyList.updateRuns(t)}showEditDialog(t){this.historyList.editRun(t)}addRun(t){this.historyList.addRun(t)}get history(){return this.historyList.runs}get onCompactModeChanged(){return this.historyList.onCompactModeChanged}get compactMode(){return this.historyList.compactMode}constructor(t){var n;super(r.box(r.divText("No historical runs loaded","hp-no-elements-label"),{style:{width:"100%",height:"100%"}})),n=this,this.func=t,this.onRunChosen=new s.Subject,this.onComparison=new s.Subject,this.afterRunEdited=new s.Subject,this.afterRunDeleted=new s.Subject,this.allRunsFetch=new s.Subject,this.historyList=new eF([],{fallbackText:"No runs are found in history",showActions:!0,showBatchActions:!0,isHistory:!0}),this.panel=this.historyList.root;const i=this.historyList.onChosen.pipe((0,l.filter)(t=>!!t)).subscribe(t=>this.onRunChosen.next(t.id)),o=this.historyList.onComparisonCalled.subscribe(t=>this.onComparison.next(t)),a=this.allRunsFetch.subscribe(()=>{var t;return(t=function*(){r.setUpdateIndicator(n.root,!0),f.pullRunsByName(n.func.name,[{author:e.shell.user}],{},["session.user","options"]).then(t=>{r.empty(n.root),n.root.appendChild(n.panel),n.updateHistoryPane(t)}).catch(t=>e.shell.error(t)).finally(()=>r.setUpdateIndicator(n.root,!1))},function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){e_(o,i,r,s,l,"next",t)}function l(t){e_(o,i,r,s,l,"throw",t)}s(void 0)})})()}),u=this.historyList.onMetadataEdit.subscribe(t=>{this.afterRunEdited.next(t)}),c=this.historyList.onDelete.subscribe(t=>{this.afterRunDeleted.next(t)});this.subs.push(i,a,u,o,c),this.allRunsFetch.next()}}function eH(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function e$(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){eH(o,i,r,s,l,"next",t)}function l(t){eH(o,i,r,s,l,"throw",t)}s(void 0)})}}(h=b||(b={})).fileInput=function(t,e,n,i){return new tK(void 0===t?"Drag-n-drop here":t,void 0===e?null:e,void 0===n?null:n,void 0===i?tz:i)},h.historyInput=function(t,e,n){return new eL(t,e,n)},h.historyInputJSON=function(t,e,n){return new ej(t,e,n)},h.historyPanel=function(t){return new eU(t)};let eW=new URL(e.shell.startUri),eY=()=>e$(function*(){let 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=()=>{let e=new Blob(n,{type:n[0].type});t.getVideoTracks()[0].stop(),o.Utils.download(`Recording ${new Date().toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}.mkv`,e,n[0].type)},e.start()})();class eG extends o.ViewBase{onFuncCallReady(){return e$(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();let t=this.getStartId();if(t&&!this.options.isTabbed&&(r.setUpdateIndicator(this.root,!0),this.loadRun(t),r.setUpdateIndicator(this.root,!1),this.setAsLoaded()),this.isHistoryEnabled&&this.func){let t=this.options.isTabbed?this.isHistorical.subscribe(t=>{t||(this.funcCall.id=null)}):this.isHistorical.subscribe(t=>{if(t){var e,n;this.path=`?id=${this.funcCall.id}`;let t=tm(this.funcCall);0>this.name.indexOf(" — ")?this.name=`${this.name} — ${null!=(e=this.funcCall.options.title)?e:t}`:this.name=`${this.name.substring(0,this.name.indexOf(" — "))} — ${null!=(n=this.funcCall.options.title)?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)}}).call(this)}getStartId(){return e.shell.getVar("isLoaded")?void 0:eW.searchParams.get("id")}setAsLoaded(){return e.shell.setVar("isLoaded",!0)}get funcCall(){return this._funcCall}get func(){var t;return null==(t=this.funcCall)?void 0:t.func}get lastCall(){return this._lastCall}set lastCall(t){this._lastCall=t}get type(){return this._type}getPackageData(){return e$(function*(){var t,e;let n=this.func.package;if(!n)return;let i=null==(t=yield null==n?void 0:n.getProperties())?void 0:t.REPORT_BUG_URL;i&&!this.reportBug&&(this.reportBug=()=>e$(function*(){window.open(i,"_blank")})());let r=null==(e=yield null==n?void 0:n.getProperties())?void 0:e.REQUEST_FEATURE_URL;r&&!this.requestFeature&&(this.requestFeature=()=>e$(function*(){window.open(r,"_blank")})());let o=`${n.friendlyName}.
|
|
169
|
-
Last updated on ${x()(n.updatedOn).format("YYYY MMM D, HH:mm")}`;this.getAbout||(this.getAbout=()=>e$(function*(){return o})())}).call(this)}linkFunccall(t){this._funcCall=t,this.funcCallReplaced.next(!0)}loadFuncCallById(){return e$(function*(){if(this.initValue instanceof o.FuncCall){yield new Promise(t=>setTimeout(t,0)),this.linkFunccall(this.initValue);return}r.setUpdateIndicator(this.root,!0);let t=this.getStartId();if(t&&!this.options.isTabbed)this.linkFunccall((yield f.loadRun(t)));else{let t=o.Func.byName(this.initValue);this.linkFunccall(t.prepare({}))}r.setUpdateIndicator(this.root,!1)}).call(this)}init(){return e$(function*(){yield this.loadFuncCallById(),yield this.onFuncCallReady(),this.isReady.next(!0)}).call(this)}build(){r.empty(this.root),this.root.appendChild(this.buildIO()),this.options.historyEnabled&&this.isHistoryEnabled&&this.buildHistoryBlock(),this.buildRibbonMenu(),this.buildRibbonPanels()}onComparisonLaunch(t){return e$(function*(){let n=this.comparatorFunc;if(n){let i=o.Func.byName(n),r=(yield i.prepare({params:{comparedRuns:t}}).call()).outputs.comparisonView;e.shell.addView(r);return}let i=e.shell.v.parentCall,r=[...e.shell.views].find(t=>t.type===T),s=yield tV.fromComparedRuns(t,this.func,{parentView:r,parentCall:i});e.shell.addView(s),s.defaultCustomize();let l=this.compareCustomizer;if(l){let t=o.Func.byName(l);yield t.prepare({params:{defaultView:s}}).call();return}}).call(this)}onSaveClick(){return e$(function*(){yield this.saveRun(this.funcCall)}).call(this)}buildHistoryBlock(){let t=b.historyPanel(this.func),n=!1;return this.subs.push(t.onCompactModeChanged.subscribe(t=>{let n=e.shell.dockManager.findNode(this.historyRoot);n&&(e.shell.dockManager.close(n),t?e.shell.dockManager.dock(this.historyRoot,"right",null,"History",.3):e.shell.dockManager.dock(this.historyRoot,"down",null,"History",.3))}),t.onRunChosen.subscribe(t=>e$(function*(){r.setUpdateIndicator(this.root,!0),yield this.loadRun(t),r.setUpdateIndicator(this.root,!1)}).call(this)),t.onComparison.subscribe(e=>e$(function*(){tS(t.root,!0);let n=yield Promise.all(e.map(t=>f.loadRun(t)));yield this.onComparisonLaunch(n),tS(t.root,!1)}).call(this)),t.afterRunEdited.subscribe(t=>{if(t.id===this.funcCall.id&&t.options.title){var e,n;this.path=`?id=${this.funcCall.id}`;let i=tm(t);0>this.name.indexOf(" — ")?this.name=`${this.name} — ${null!=(e=t.options.title)?e:i}`:this.name=`${this.name.substring(0,this.name.indexOf(" — "))} — ${null!=(n=t.options.title)?n:i}`}}),e.events.onViewRemoving.subscribe(t=>{if(t.args.view==this){let t=e.shell.dockManager.findNode(this.historyRoot);t?(e.shell.dockManager.close(t),n=!0):n=!1}}),e.events.onCurrentViewChanged.subscribe(()=>{if(e.shell.v==this){if(n){var t;(null==(t=this.historyBlock)?void 0:t.compactMode)?e.shell.dockManager.dock(this.historyRoot,"right",null,"History",.3):e.shell.dockManager.dock(this.historyRoot,"down",null,"History",.3)}}else{let t=e.shell.dockManager.findNode(this.historyRoot);t?(e.shell.dockManager.close(t),n=!0):n=!1}})),r.empty(this.historyRoot),this.historyRoot.style.removeProperty("justify-content"),this.historyRoot.append(t.root),this.historyBlock=t,t.root}buildRibbonPanels(){let t=r.iconFA("history",()=>{if(!e.shell.dockManager.findNode(this.historyRoot)){var t;(null==(t=this.historyBlock)?void 0:t.compactMode)?e.shell.dockManager.dock(this.historyRoot,"right",null,"History",.3):e.shell.dockManager.dock(this.historyRoot,"down",null,"History",.3),this.historyRoot.parentElement.classList.add("ui-box"),this.historyRoot.classList.add("ui-box")}},"History"),n=r.iconFA("save",()=>e$(function*(){yield this.onSaveClick()}).call(this),"Save current state"),i=r.comboPopup(r.iconFA("arrow-to-bottom"),this.getFormats(),this.exportRun.bind(this)),o=r.iconFA("edit",()=>{this.historyBlock&&this.lastCall&&this.historyBlock.showEditDialog(this.historyBlock.history.get(this.funcCall.id))},"Edit this run metadata"),s=this.isHistorical.subscribe(t=>{t?(r.setDisplay(i,!tp(this.funcCall)),r.setDisplay(o,!0)):(C()(i).hide(),C()(o).hide())});if(this.subs.push(s),r.tooltip.bind(i,()=>"inconsistent"===this.consistencyState.value&&this.mandatoryConsistent?"Current run is inconsistent. Export feature is disabled.":null),!this.options.isTabbed&&this.mandatoryConsistent){let t=this.consistencyState.pipe((0,l.distinctUntilChanged)()).subscribe(t=>{"inconsistent"===t?(C()(i).addClass("d4-disabled"),C()(i.lastChild).css("color","unset")):(C()(i).removeClass("d4-disabled"),C()(i.lastChild).removeProp("color"))});this.subs.push(t)}let a=[[...!this.options.isTabbed&&this.isHistoryEnabled&&this.options.historyEnabled?[t]:[],...!this.options.isTabbed&&this.isHistoryEnabled?[n]:[],...!this.options.isTabbed&&this.isExportEnabled&&this.exportConfig&&this.exportConfig.supportedFormats.length>0?[i]:[],...this.options.isTabbed?[]:[o]]];return this.setRibbonPanels(a),a}buildRibbonMenu(){if(this.ribbonMenu.clear(),!this.exportConfig&&!this.reportBug&&!this.requestFeature&&!this.getHelp&&!this.getMocks&&!this.getTemplates)return;let 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{let 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{let 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()),t.item("Record the screen",eY),this.getAbout&&t.item("About",()=>e$(function*(){let t=yield this.getAbout();if(t){let e=r.dialog("Current version");t.split("\n").forEach(t=>e.add(r.label(t))),e.onOK(()=>{}),e.getButton("CANCEL").style.display="none",e.show({center:!0})}}).call(this))}exportRun(t){return e$(function*(){o.Utils.download(this.exportConfig.filename(t),(yield this.exportConfig.export(t)))}).call(this)}getFormats(){var t,e;return null!=(t=null==(e=this.exportConfig)?void 0:e.supportedFormats)?t:[]}onBeforeSaveRun(t){return e$(function*(){})()}onAfterSaveRun(t){return e$(function*(){})()}saveRun(t){return e$(function*(){let e=th(t);yield this.onBeforeSaveRun(e),tp(e)&&(e=yield eI(t)),e.id&&e.newId();let n=yield f.saveRun(e),i=yield f.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}).call(this)}onBeforeDeleteRun(t){return e$(function*(){})()}onAfterDeleteRun(t){return e$(function*(){})()}deleteRun(t){return e$(function*(){return yield this.onBeforeDeleteRun(t),yield f.deleteRun(t),yield this.onAfterDeleteRun(t),t.id}).call(this)}onBeforeLoadRun(){return e$(function*(){})()}onAfterLoadRun(t){return e$(function*(){})()}loadRun(t){return e$(function*(){yield this.onBeforeLoadRun();let e=yield f.loadRun(t);return this.lastCall=th(e),this.linkFunccall(e),this.isHistorical.next(!0),yield this.onAfterLoadRun(e),e}).call(this)}onBeforeRun(t){return e$(function*(){})()}onAfterRun(t){return e$(function*(){})()}run(){return e$(function*(){if(!this.funcCall)throw Error("The correspoding function is not specified");yield this.onBeforeRun(this.funcCall);let t=o.TaskBarProgressIndicator.create("Calculating...");try{this.funcCall.newId(),yield this.funcCall.call(),yield this.onAfterRun(this.funcCall),this.lastCall=th(this.funcCall),!(this.options.isTabbed||this.runningOnInput)&&this.isHistoryEnabled&&(yield this.saveRun(this.funcCall))}catch(t){e.shell.error(t.toString())}finally{t.close()}}).call(this)}exportRunJson(){return e$(function*(){if(this._lastCall)return tr((yield eE(this._lastCall,this)))}).call(this)}getRunJSON(){return e$(function*(){let t=yield this.exportRunJson();t&&o.Utils.download(this.defaultExportFilename("","json"),t)}).call(this)}get compareCustomizer(){var t;return null!=(t=this.func.options.compareCustomizer)?t:null}get comparatorFunc(){var t;return null!=(t=this.func.options.comparatorFunc)?t:null}get uploadFunc(){var t;return null!=(t=this.func.options.uploadFunc)?t:null}get runningOnInput(){return"true"===this.func.options.runOnInput}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(null==(t=this.parentCall)?void 0:t.func.options.mandatoryConsistent)==="true"}get hasContextHelp(){var t,e,n,i;return!!(null!=(e=null==(t=this.func)||null==(n=t.options)?void 0:n.help)?e:null==t||null==(i=t.options)?void 0:i.readme)}getContextHelp(){return e$(function*(){return tu(this.func)}).call(this)}get features(){var t;return JSON.parse(null!=(t=this.func.options.features)?t:"{}")}getFeature(t,e){var n,i;return n=this.features,n instanceof Array?n.includes(t):n instanceof Object&&null!=(i=n[t])?i:e}get isExportEnabled(){return this.getFeature("export",!0)}get isHistoryEnabled(){return this.getFeature("history",!0)}get isSaEnabled(){return this.getFeature("sens-analysis",!1)}get hasUploadMode(){return this.getFeature("upload",!1)}get isFittingEnabled(){return this.getFeature("fitting",!1)}get isOptimizationEnabled(){return this.getFeature("optimization",!1)}constructor(t,n){var i,l,a,u,c;let d=void 0===n?{historyEnabled:!0,isTabbed:!1,skipInit:!1}:n;super(),this.initValue=t,this.options=d,this._type="function",this.funcCallReplaced=new s.Subject,this.isReady=new s.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 s.BehaviorSubject(!1),this.historyRoot=r.div(),this.consistencyState=new s.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=e.functions.getCurrentCall(),t instanceof o.FuncCall&&(this.parentCall=t),this.parentView=null==(a=this.parentCall)||null==(l=a.parentCall)||null==(i=l.aux)?void 0:i.view,(null==(c=this.parentCall)||null==(u=c.func)?void 0:u.name)&&(this.basePath=`/${this.parentCall.func.name}`),d.skipInit||this.init()}}var eq=n(902),eJ={};function ez(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function eK(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function eZ(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){eK(o,i,r,s,l,"next",t)}function l(t){eK(o,i,r,s,l,"throw",t)}s(void 0)})}}function eX(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n,i,r=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var o=[],s=!0,l=!1;try{for(r=r.call(t);!(s=(n=r.next()).done)&&(o.push(n.value),!e||o.length!==e);s=!0);}catch(t){l=!0,i=t}finally{try{s||null==r.return||r.return()}finally{if(l)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return ez(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ez(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}eJ.styleTagTransform=tW(),eJ.setAttributes=t_(),eJ.insert=tM().bind(null,"head"),eJ.domAPI=tL(),eJ.insertStyleElement=tH(),tk()(eq.A,eJ),eq.A&&eq.A.locals&&eq.A.locals;let eQ=Math.ceil(36)+1,e0=(t,e,n)=>{r.setUpdateIndicator(t,e);let i=t.querySelector(".d4-update-shadow .ui-label");e&&n&&i&&(i.textContent=n)},e1=(t,e)=>{try{return Number.isFinite(t)&&e?o.format(t,e):t}catch(e){return t}},e2=(t,e,n,i)=>{let r=["Parameter","Value","Units"];n&&r.push("Validation"),i&&r.push("Consistency"),t.addRow(r).font={bold:!0},e.forEach(e=>{let r=[e.caption,e1(e.value,e.format),e.units];r.push(e5(null==n?void 0:n[e.name])),r.push(e3(null==i?void 0:i[e.name])),t.addRow(r)}),t.getColumn(1).width=1.2*Math.max(...e.map(t=>t.caption.toString().length),9),t.getColumn(2).width=1.2*Math.max(...e.map(t=>t.value.toString().length),5),t.getColumn(3).width=1.2*Math.max(...e.map(t=>t.units.toString().length),5),t.getColumn(4).width=100,t.getColumn(5).width=100},e5=t=>null==t?"":["errors","warnings"].filter(e=>{var n;return!!(null==t||null==(n=t[e])?void 0:n.length)}).flatMap(e=>t[e].map(t=>({category:e,advice:t}))).map(t=>{let e=t.category,n=t.advice;return`${e}: ${"string"==typeof n?n:n.description}`}).join("\n"),e3=t=>{if(null==t)return"";if(t.inconsistent&&("disabled"===t.restriction||"restricted"===t.restriction)){let e=t.assignedValue,n="number"==typeof e&&Number.isFinite(e)?o.format(e,R):String(e);return`Inconsistent: value should be ${n}`}},e4=t=>{let e=t.sheet,n=t.dfCounter,i=t.df,r=t.column,o=t.row,s=t.validation,l=t.consistency;if(!i)return;let a=e.getColumn(null!=r?r:1).letter,u=i.columns.length,c=[];for(let t=0;t<i.rowCount;t++){let e=[];for(let n=0;n<i.columns.length;n++){let r=i.col(n),o=i.get(r.name,t);if((null==r?void 0:r.type)==="double"){var d,p;let t=e1(o,null!=(d=null==r||null==(p=r.tags)?void 0:p.format)?d:R);e.push(t)}else e.push(o)}c.push(e)}let h={name:`ID_${n.toString()}`,ref:`${a}${null!=o?o:1}`,columns:i.columns.toList().map(t=>({name:t.name,filterButton:!1})),rows:c};e.addTable(h),e.columns.forEach(t=>{t.width=25,t.alignment={wrapText:!0}});let f=u+1;e.getColumn(f).width=100,e.getCell(1,f).value="Validation and Consistency",s&&(e.getCell(2,f).value=e5(s)),l&&(e.getCell(3,f).value=e3(l))},e6=t=>!t||0===t.rowCount;function e8(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function e7(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function e9(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){e7(o,i,r,s,l,"next",t)}function l(t){e7(o,i,r,s,l,"throw",t)}s(void 0)})}}function nt(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}function ne(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}function nn(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n,i,r=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var o=[],s=!0,l=!1;try{for(r=r.call(t);!(s=(n=r.next()).done)&&(o.push(n.value),!e||o.length!==e);s=!0);}catch(t){l=!0,i=t}finally{try{s||null==r.return||r.return()}finally{if(l)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return e8(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e8(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}let ni=()=>r.divText("[No data to display]",{style:{"text-align":"center","align-content":"center",width:"100%",height:"100%"}});class nr extends eG{static fromFuncCall(t,e){return new this(t,void 0===e?{historyEnabled:!0,isTabbed:!1}:e)}onFuncCallReady(){var t=this,n=()=>super.onFuncCallReady;return e9(function*(){yield this.loadInputsOverrides(),yield this.loadValidators(g.INPUTS),yield this.loadValidators(g.OUTPUTS),yield n().call(t);let i=this.funcCallReplaced.subscribe(()=>{this.inputValidationRequests.next({isRevalidation:!1}),this.outputValidationRequests.next({isRevalidation:!1})});this.subs.push(i);let o=t=>(0,l.mergeMap)(e=>e.pipe((0,l.tap)(e=>{t===g.INPUTS?this.setInputValidationPending(e.field):this.setOutputValidationPending(e.field)}),(0,l.switchMap)(e=>{let n=new AbortController,i=n.signal,r=!1;return new s.Observable(o=>{let l=(0,s.from)(this.runValidation(nt({},e),i,t)).subscribe(t=>{r=!0,o.next(t)});return()=>{r||n.abort(),l.unsubscribe()}}).pipe((0,l.tap)(n=>{t===g.INPUTS?this.setInputValidationResults(n):this.setOutputValidationResults(n),this.runRevalidations(e,n,t),t===g.INPUTS?this.inputValidationUpdates.next(null):this.outputValidationUpdates.next(null)}),(0,l.mapTo)(e))}))),a=this.inputValidationRequests.pipe((0,l.groupBy)(t=>t.field),o(g.INPUTS)).subscribe(t=>{t.field&&this.runningOnInput&&this.isRunnable()&&this.doRun()});this.subs.push(a);let u=this.outputValidationRequests.pipe((0,l.groupBy)(t=>t.field),o(g.OUTPUTS)).subscribe();this.subs.push(u);let c=this.externalValidatorsUpdates.subscribe(t=>{this.updateInputValidationResults(t)});this.subs.push(c);let d=(0,s.combineLatest)([this.runRequests.pipe((0,l.switchMap)(()=>(0,s.of)(!1).pipe((0,l.delay)(500),(0,l.startWith)(!0)))),this.inputValidationUpdates.pipe((0,l.debounceTime)(0))]).pipe((0,l.filter)(t=>nn(t,1)[0]&&this.isRunnable())).subscribe(()=>this.doRun());this.subs.push(d);let p=this.options.isTabbed?null:yield this.loadLastInputs();if(p)e.shell.info(r.div([r.divText("Do you want to load last inputs?"),r.divH([r.bigButton("Load",()=>{var t=!0,n=!1,i=void 0;try{for(var o,s=Object.entries(p)[Symbol.iterator]();!(t=(o=s.next()).done);t=!0){let t=nn(o.value,2),e=t[0],n=t[1],i=this.getInput(e);i.notify=!1,i.value=n,i.notify=!0,this.funcCall.inputs[e]=n,this.inputValidationRequests.next({field:e,isRevalidation:!1})}}catch(t){n=!0,i=t}finally{try{t||null==s.return||s.return()}finally{if(n)throw i}}e.shell.info(r.divText("Change the loaded inputs to run computations"))})])]));else{let 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())}}).call(this)}onBeforeRun(){return this.tabsElem.currentPane&&(this.prevOpenedTab=this.inputTabsLabels.includes(this.tabsElem.currentPane.name)?null:this.tabsElem.currentPane),Promise.resolve()}onAfterRun(){if(this.showOutput(),this.tabsElem.panes.forEach(t=>{C()(t.header).show()}),this.prevOpenedTab)return this.tabsElem.currentPane=this.prevOpenedTab,Promise.resolve();let t=this.tabsElem.panes.find(t=>this.outputTabsLabels.includes(t.name));return t&&(this.tabsElem.currentPane=t),Promise.resolve()}getRunButton(t){var e;let n=r.bigButton(null!=(e=this.func.options.runLabel)?e:void 0===t?"Run":t,()=>e9(function*(){return yield this.doRun()}).call(this)),i=(0,s.merge)(this.inputValidationUpdates,this.externalValidatorsUpdates,this.isRunning,this.blockRuns).subscribe(()=>{n.disabled=!this.isRunnable()});return this.subs.push(i),n}loadInputsOverrides(){return e9(function*(){let t=[...this.funcCall.inputParams.values()];yield Promise.all(t.map(t=>e9(function*(){if(t.property.options.input){let e=o.Func.byName(t.property.options.input).prepare({params:JSON.parse(t.property.options.inputOptions||"{}")});yield e.call(),this.inputsOverride[t.name]=e.outputs.input}}).call(this)))}).call(this)}loadValidators(){return e9(function*(t){var e;let n,i=void 0===t?g.INPUTS:t,r=yield(e=this.funcCall,n=void 0===i?g.INPUTS:i,ew(function*(){let t=[...e[eg[n]].values()];return(yield Promise.all(t.filter(t=>!!t.property.options.validatorFunc).map(t=>ew(function*(){let e=o.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)=>{let n=eA(e,2),i=n[0],r=n[1];return t[i]=r,t},{})})());i===g.INPUTS?this.inputValidators=r:this.outputValidators=r}).apply(this,arguments)}keepOutput(){var t;return(null==(t=this.func)?void 0:t.options.keepOutput)==="true"}getSaveButton(t){let e=r.bigButton(void 0===t?"Save":t,()=>e9(function*(){return yield this.saveExperimentalRun(this.funcCall)}).call(this),"Save uploaded data"),n=this.isUploadMode.subscribe(t=>{this.buildRibbonPanels(),t?C()(e).show():C()(e).hide()});return this.subs.push(n),e}getStandardButtons(){let t=this.getRunButton(),e=r.div([t]);r.tooltip.bind(e,()=>t.disabled?this.isRunning.value?"Computations are in progress":this.getValidationMessage():"");let n=this.getSaveButton();return[...this.isHistoryEnabled&&!this.options.isTabbed?[n]:[],...this.runningOnInput?[]:[e]]}buildFormButtons(){var t;let e=this.getStandardButtons(),n=r.buttonsInput();return C()(n.firstChild).css({display:"none"}),null==(t=n.lastChild)||t.replaceWith(r.div([...this.navBtns,...this.additionalBtns,...e],"ui-input-editor")),C()(n).addClass("rfv-buttons"),C()(n).css({"max-width":"100%"}),this.formButtons.replaceWith(n),this.formButtons=n,n}setAdditionalButtons(t){this.additionalBtns=t,this.buildFormButtons()}setNavigationButtons(t){this.navBtns=t,this.buildFormButtons()}buildIO(){let t=this.buildInputBlock(),e=t.inputBlock,n=t.inputForm,i=t.outputForm,o=t.controlsWrapper,s=[...Array.from(n.childNodes),...this.isUploadMode.value?[Array.from(i.childNodes)]:[]];r.tools.handleResize(e,()=>{300>C()(e).width()?(C()(n).addClass("ui-form-condensed"),C()(i).addClass("ui-form-condensed"),C()(o).addClass("ui-form-condensed"),s.forEach(t=>C()(t).css("min-width","100px"))):(C()(n).removeClass("ui-form-condensed"),C()(i).removeClass("ui-form-condensed"),C()(o).removeClass("ui-form-condensed"),s.forEach(t=>C()(t).css("min-width","100%")))});let l=this.buildOutputBlock();l.style.height="100%",l.style.width="100%",this.hideOutput();let a=r.splitH([e,r.panel([l],{style:{paddingTop:"0px"}})],null,!0);return a.style.padding="0 12px",e.style.maxWidth="360px",a}buildInputBlock(){let t=this.renderInputForm(),e=this.renderOutputForm();this.buildFormButtons();let n=r.div(this.formButtons,"ui-form ui-form-wide");C()(n).css({"padding-left":"0px","padding-bottom":"0px","padding-right":"6px","max-width":"100%","min-height":"50px"});let i=r.input.toggle("",{value:this.isUploadMode.value,onValueChanged:t=>this.isUploadMode.next(t)}),o=this.isUploadMode.subscribe(t=>{i.notify=!1,i.value=t,i.notify=!0,t?C()(e).show():C()(e).hide()});return this.subs.push(o),{inputBlock:r.divV([t,...this.hasUploadMode&&!this.uploadFunc?[r.divH([r.h2("Experimental data"),i.root],{style:{flexGrow:"0"}}),e]:[],n],"ui-box rfv-form"),inputForm:t,outputForm:e,controlsWrapper:n}}processCustomDataUpload(){return e9(function*(){let t=()=>{let t=o.Dialog.create({title:"Select to compare"}),e=new eF(d.length>0?d:[...this.historyBlock.history.values()],{fallbackText:"No historical runs found",showActions:!(d.length>0),showBatchActions:!(d.length>0)}),n=new eF(c,{fallbackText:"No runs uploaded",showActions:!1,showBatchActions:!1});t.add(r.divV([r.divV([r.label("Uploaded runs"),r.element("div","splitbar-horizontal"),n.root],{style:{height:"50%",overflowY:"hidden"}}),r.divV([r.label(d.length>0?"Simulated":"History",{style:{padding:"0px 10px 0px 9px"}}),r.element("div","splitbar-horizontal"),e.root],{style:{height:"50%",overflowY:"hidden"}})],{style:{justifyContent:"space-between",gap:"10px",overflowY:"scroll",height:"100%"}})),C()(t.root.querySelector(".d4-dialog-contents")).removeClass("ui-form");let i="Compare selected";return 0===d.length?t.addButton(i,()=>e9(function*(){let i=yield Promise.all([...e.selected].map(t=>f.loadRun(t.id)));this.onComparisonLaunch([...i,...n.selected.values()]),t.close()}).call(this)):t.addButton(i,()=>e9(function*(){this.onComparisonLaunch([...e.selected.values(),...n.selected.values()]),t.close()}).call(this)),t.getButton(i).disabled=!0,this.subs.push((0,s.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(v,()=>e9(function*(){this.onComparisonLaunch([this.funcCall,...n.selected.values()]),t.close()}).call(this)),C()(t.getButton("CANCEL")).hide(),t},n=o.Func.byName(this.uploadFunc),i=yield n.prepare({params:{func:this.func}}).call(),a=i.outputs.uploadWidget,u=i.outputs.uploadFuncCall,c=[],d=[],p=o.Dialog.create({title:"Upload"});C()(p.root.querySelector(".d4-dialog-contents")).removeClass("ui-form");let h=o.Dialog.create({title:"Review uploaded runs"});C()(h.root.querySelector(".d4-dialog-contents")).removeClass("ui-form");let m="Save to history",v="Compare w/ current";p.add(a.root),p.addButton(m,()=>e9(function*(){return tS(p.root,!0),c.forEach(t=>{t.options.immutable_tags?t.options.immutable_tags.push(P):t.options.immutable_tags=[P]}),Promise.all(c.map(t=>e9(function*(){let e=yield this.getValidExpRun(t);return f.saveRun(e)}).call(this))).then(t=>Promise.all(t.map(t=>f.loadRun(t.id)))).then(t=>{t.forEach(t=>this.historyBlock.addRun(t))}).catch(t=>{e.shell.error(t)}).finally(()=>{tS(p.root,!1),p.close();let t=new eF(c,{fallbackText:"No runs uploaded",showActions:!0,showBatchActions:!0});h.add(t),h.show({modal:!0,fullScreen:!0})})}).call(this)),p.addButton("Next",()=>{p.close(),c.forEach(t=>{t.options.immutable_tags?t.options.immutable_tags.push(P):t.options.immutable_tags=[P]});let t=new eF(c,{fallbackText:"No runs uploaded",showActions:!0,showBatchActions:!0});h.add(t.root),h.show({modal:!0,fullScreen:!0})}),C()(p.getButton("CANCEL")).hide(),p.getButton(m).disabled=!0,p.getButton("Next").disabled=!0,C()(h.getButton("CANCEL")).hide(),h.addButton("Simulate w/ same inputs",()=>{tS(p.root,!0),Promise.all(c.map(t=>e9(function*(){return(yield eI(t)).call()})())).then(e=>{d=e,h.close(),t().show({modal:!0,fullScreen:!0})}).catch(t=>{e.shell.error(t)}).finally(()=>{tS(p.root,!1)})}),h.addButton("Compare w/ history",()=>{h.close(),t().show({modal:!0,fullScreen:!0})});let y=e.functions.onAfterRunAction.pipe((0,l.filter)(t=>t.id===u.id)).subscribe(()=>{c=u.outputs.uploadedCalls,p.getButton(m).disabled=!1,p.getButton("Next").disabled=!1}),g=p.onClose.subscribe(()=>{this.isUploadMode.next(!1)});p.subs.push(g,y),p.show({modal:!0,center:!0,resizable:!0})}).call(this)}onSaveClick(){return e9(function*(){this.isUploadMode.value?yield this.saveExperimentalRun(this.funcCall):yield this.saveRun(this.funcCall)}).call(this)}buildRibbonPanels(){super.buildRibbonPanels();let t=r.iconFA("play",()=>e9(function*(){return yield this.doRun()}).call(this),"Run computations");t.classList.add("fas");let n=r.iconFA("arrow-to-top",()=>e9(function*(){this.uploadFunc?yield this.processCustomDataUpload():(this.isUploadMode.next(!this.isUploadMode.value),n.classList.toggle("d4-current"))}).call(this),"Upload experimental data");n.classList.add("d4-toggle-button",...this.isUploadMode.value?["d4-current"]:[]);let i=r.iconFA("info",()=>e9(function*(){this.hasContextHelp&&(e.shell.windows.help.visible=!0,yield new Promise(t=>setTimeout(t,100)),e.shell.windows.help.showHelp(r.markdown((yield this.getContextHelp()))))}).call(this),"Info"),o=[[...super.buildRibbonPanels().flat(),...this.runningOnInput||this.options.isTabbed?[]:[t],...this.hasUploadMode?[n]:[],...!this.options.isTabbed&&this.hasContextHelp?[i]:[]]];return this.setRibbonPanels(o),o}showOutput(){r.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=>{let n=nn(this.categoryToDfParamMap.outputs[t]?[this.categoryToDfParamMap.outputs[t],!1]:[this.categoryToDfParamMap.inputs[t],!0],2),i=n[0],a=n[1],u=i.filter(t=>t.propertyType===o.TYPE.DATA_FRAME||t.propertyType===o.TYPE.GRAPHICS),c=i.filter(t=>t.propertyType!==o.TYPE.DATA_FRAME&&t.propertyType!==o.TYPE.GRAPHICS),d=u.map(t=>tf(t).config),p="",h=u.reduce((t,n,i)=>{var s,u;this.dfToViewerMapping[n.name]=[];let c=d[i].map((t,i)=>e9(function*(){var i,s,l,a;let u=null!=(i=null!=(s=null==(l=this.funcCall.outputs[n.name])?void 0:l.value)?s:null==(a=this.funcCall.inputParams[n.name])?void 0:a.value)?i:e.data.demo.demog(0),c=t.type,d=Object.values(S).includes(c)?o.Viewer.fromType(c,u):yield u.plot.fromType(c);d.setOptions(t),this.dfToViewerMapping[n.name].push(d),this.afterOutputPropertyRender.next({prop:n,output:d});let p=ni();return 0===u.rowCount&&"demog 0"===u.name&&(r.setDisplay(d.root,!1),r.setDisplay(p,!0)),{viewer:d,stub:p}}).call(this)).map((t,e)=>t.then(t=>{let o=t.viewer,s=t.stub,a=()=>e9(function*(){var t;let l=null!=(t=this.funcCall.outputParams[n.name])?t:this.funcCall.inputParams[n.name];if(l.value){if(r.setDisplay(o.root,!0),r.setDisplay(s,!1),Object.values(S).includes(o.type))o.dataFrame=l.value;else{let t=yield l.value.plot.fromType(o.type);o.root.replaceWith(t.root),o=t}try{d[i][e]&&o.setOptions(d[i][e])}catch(t){console.error("Error setting viewer properties: ",t)}Object.keys(d[i][e]).includes("color")&&o.setOptions({color:d[i][e].color}),this.afterOutputPropertyRender.next({prop:n,output:o})}else r.setDisplay(o.root,!1),r.setDisplay(s,!0)}).call(this),u=this.funcCallReplaced.pipe((0,l.startWith)(null),(0,l.switchMap)(()=>{var t;return(null!=(t=this.funcCall.outputParams[n.name])?t:this.funcCall.inputParams[n.name]).onChanged.pipe((0,l.startWith)(null))}),(0,l.skip)(1)).subscribe(a);return this.subs.push(u),{loadedViewer:o,stub:s}})),h=p!==(null!=(s=n.options.caption)?s:n.name)?null!=(u=n.options.caption)?u:n.name:" ";if(p=h,a){let t=this.funcCallReplaced.pipe((0,l.switchMap)(()=>{var t;return(null!=(t=this.funcCall.outputParams[n.name])?t:this.funcCall.inputParams[n.name]).onChanged})).subscribe(()=>{this.showOutput(),this.inputTabsLabels.forEach(t=>{C()(this.tabsElem.getPane(t).header).show()})});this.subs.push(t)}let f=c.map((t,e)=>{let o=d[i][e].block,s=r.wait(()=>e9(function*(){let e=yield t;return C()(e.loadedViewer.root).css({height:"100%",width:"100%"}),r.divV([e.loadedViewer.root,e.stub],{style:{width:"100%"}})})());C()(s).css({"min-height":"300px","flex-grow":"1"});let l=ef();return this.outputValidationSigns[n.name]=l,r.divV([r.divH([r.h2(0===e?h:" ",{style:{whiteSpace:"pre"}}),...0===e?[r.div([this.outputValidationSigns[n.name][0],this.outputValidationSigns[n.name][1]],{style:{margin:"10.79px"}})]:[]]),s],{style:nt({},o?{width:`${o}%`,"max-width":`${o}%`,"max-height":"100%"}:{"flex-grow":"1"})})});if(n.propertyType===o.TYPE.GRAPHICS){let e=n.options.block,i=ni();i.classList.add("grok-scripting-image-container");let o=r.divV([r.h2(h,{style:{whiteSpace:"pre"}}),i],{style:nt({},e?{width:`${e}%`,"max-width":`${e}%`,"max-height":"100%"}:{"flex-grow":"1"})}),s=()=>{var t;let e=null!=(t=this.funcCall.outputParams[n.name])?t:this.funcCall.inputParams[n.name];e.value?(i.style.backgroundImage=`url("data:image/png;base64,${e.value}")`,i.textContent=""):(i.style.removeProperty("background-image"),i.textContent="[No data to display]")},a=this.funcCallReplaced.pipe((0,l.startWith)(null),(0,l.switchMap)(()=>{var t;return(null!=(t=this.funcCall.outputParams[n.name])?t:this.funcCall.inputParams[n.name]).onChanged.pipe((0,l.startWith)(null))}),(0,l.skip)(1)).subscribe(s);this.subs.push(a),t.append(o)}return t.append(...f),t},r.divH([],{style:{flexWrap:"wrap",flexGrow:"1",maxHeight:"100%"}}));c.forEach(t=>{let e=ef();this.outputValidationSigns[t.name]=e});let f=()=>{let t=o.HtmlTable.create(c,t=>{var e;let n=t.options.precision,i=n&&t.propertyType===o.TYPE.FLOAT&&this.funcCall.outputs[t.name]?this.funcCall.outputs[t.name].toPrecision(n):this.funcCall.outputs[t.name],s=t.options.units?` [${t.options.units}]`:"";return[`${null!=(e=t.caption)?e:t.name}${s}`,null!=i?i:"[No value]",r.div([this.outputValidationSigns[t.name][0],this.outputValidationSigns[t.name][1]])]}).root;return C()(t).addClass("rfv-scalar-table"),this.afterOutputSacalarTableRender.next(t),t},m=f(),v=(0,s.merge)(this.funcCallReplaced,this.isRunning.pipe((0,l.filter)(t=>!1===t),(0,l.skip)(1))).subscribe(()=>{let e=f();m.replaceWith(e),m=e,C()(this.tabsElem.getPane(t).header).show()});this.subs.push(v),this.tabsElem.addPane(t,()=>r.divV([...u.length?[h]:[],...c.length?[m]:[]]))});let t=r.box();return t.append(this.tabsElem.root),t}onAfterLoadRun(t){return e9(function*(){this.showOutput()}).call(this)}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(){var t;let e;return t=this.funcCall.func,e={inputs:{},outputs:{}},t.inputs.filter(t=>t.propertyType===o.TYPE.DATA_FRAME&&0!==tf(t).config.length).forEach(t=>{let n="Misc"===t.category?"Input":t.category;e.inputs[n]?e.inputs[n].push(t):e.inputs[n]=[t]}),t.outputs.forEach(t=>{let n="Misc"===t.category?"Output":t.category;(t.propertyType!==o.TYPE.DATA_FRAME||0!==tf(t).config.length)&&(e.outputs[n]?e.outputs[n].push(t):e.outputs[n]=[t])}),e}get inputsStorage(){return`RFV_LastInputs_${this.funcCall.func.name}`}saveLastInputs(){return e9(function*(){try{let t=E()(this.funcCall.inputParams.values()).reduce((t,e)=>{let n=e.property.propertyType!==o.TYPE.DATA_FRAME?this.funcCall.inputs[e.name]:Array.from(this.funcCall.inputs[e.name].toByteArray());return ne(nt({},t),{[e.name]:n})},{});return localStorage.setItem(this.inputsStorage,JSON.stringify(t))}catch(t){e.shell.error(t.toString())}}).call(this)}loadLastInputs(){return e9(function*(){try{var t;let e=JSON.parse(null!=(t=localStorage.getItem(this.inputsStorage))?t:"{}");if(0===Object.keys(e).length)return null;return E()(this.funcCall.inputParams.values()).reduce((t,n)=>{let i=n.property.propertyType!==o.TYPE.DATA_FRAME?e[n.name]:o.DataFrame.fromByteArray(new Uint8Array(e[n.name]));return ne(nt({},t),{[n.name]:i})},{})}catch(t){e.shell.error(t.toString())}}).call(this)}deleteLastInputs(){return e9(function*(){try{return localStorage.removeItem(this.inputsStorage)}catch(t){e.shell.error(t.toString())}}).call(this)}doRun(){return e9(function*(){this.isRunning.next(!0);try{this.options.isTabbed||(yield this.saveLastInputs()),yield this.run(),this.options.isTabbed||(yield this.deleteLastInputs())}catch(t){e.shell.error(t.toString()),console.log(t)}finally{this.isRunning.next(!1),this.inputValidationRequests.next({isRevalidation:!1,isNewOutput:!0}),this.outputValidationRequests.next({isRevalidation:!1})}}).call(this)}setExternalValidationResults(t,e){this.externalValidatorsState[t]=e,this.externalValidatorsUpdates.next(t)}saveInputLockState(t,e,n){"restricted"===n&&(this.funcCall.options[ev]=ne(nt({},this.funcCall.options[ev]),{[t]:e})),n&&(this.funcCall.options[ey]=ne(nt({},this.funcCall.options[ey]),{[t]:n})),this.updateConsistencyState()}getInputLockState(t){var e;return null==(e=this.funcCall.options[ey])?void 0:e[t]}updateConsistencyState(){let t=Object.values(this.funcCall.options[ey]).some(t=>"inconsistent"===t);this.consistencyState.next(t?"inconsistent":"consistent")}getInput(t){return this.inputsMap[t]}setInput(t,e,n){let i=this.getInput(t);if(!i)throw Error(`No input named ${t}`);if(this.funcCall.inputParams[t].property.propertyType===o.TYPE.DATA_FRAME&&"restricted"===n)throw Error(`Param ${t} is dataframe. Restricted state is not supported for them.`);n||(n=this.funcCall.inputParams[t].property.propertyType===o.TYPE.DATA_FRAME?"disabled":"restricted"),this.funcCall.inputs[t]=e,this.setInputLockState(i,t,e,n)}getParamChanges(t){return this.funcCallReplaced.pipe((0,l.startWith)(null),(0,l.filter)(()=>!!this.funcCall),(0,l.map)(()=>this.funcCall.inputParams[t]?"inputParams":"outputParams"),(0,l.switchMap)(e=>this.funcCall[e][t].onChanged.pipe((0,l.startWith)(null),(0,l.map)(()=>this.funcCall[e][t].value))))}getParamValue(t){var e,n;let i=(null==(e=this.funcCall)?void 0:e.inputParams[t])?"inputParams":"outputParams";return null==(n=this.funcCall)?void 0:n[i][t].value}setInputLockState(t,e,n,i){i&&this.saveInputLockState(e,n,i),eo(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[ev])?void 0:e[t]}renderOutputForm(){return this.renderIOForm(g.OUTPUTS)}renderInputForm(){return this.renderIOForm(g.INPUTS)}renderIOForm(t){let e=r.divH([],"ui-form ui-form-wide");C()(e).css({"flex-wrap":"wrap","flex-grow":"0","padding-right":"12px","padding-top":"0px","padding-left":"0px","max-width":"100%",gap:"4px"});let n="Misc",i=this.funcCall[eg[t]].values();return E()(i).filter(t=>!!t).forEach(i=>{let r=i.property;this.beforeInputPropertyRender.next(r);let o=this.getInputForVal(i);if(!o){n=r.category;return}this.inputsMap[i.property.name]=o,t===g.INPUTS&&(this.syncInput(i,o,t),this.checkForMapping(i,o),this.runningOnInput||this.disableInputsOnRun(i.property.name,o),this.bindOnHotkey(o)),this.renderCategory(e,i.property.category,n),this.renderInput(e,i,o),this.afterInputPropertyRender.next({prop:r,input:o}),n=r.category}),Object.keys(this.foldedCategoryInputs).forEach(t=>this.foldedCategoryInputs[t].forEach(t=>C()(t.input.root).hide())),e.classList.remove("ui-panel"),e}saveFocusedElement(t){this.focusedInput=t}restoreFocusedElement(){var t;null==(t=this.focusedInput)||t.focus()}disableInputsOnRun(t,e){let n=this.isRunning.subscribe(n=>{!("user input"!==this.getInputLockState(t)&&this.getInputLockState(t))&&(n?(ex(e)&&C()(e.input).is(":focus")&&this.saveFocusedElement(e.input),e.enabled=!1):(e.enabled=!0,ex(e)&&this.restoreFocusedElement()))});this.subs.push(n)}checkForMapping(t,e){if(!e.hasOwnProperty("_chosenRun"))return;let n=t.property.options.funccallMapping;if(!n)return;let i=JSON.parse(n),r=this.funcCallReplaced.pipe((0,l.startWith)(!0),(0,l.switchMap)(()=>this.funcCall.inputParams[t.property.name].onChanged)).subscribe(()=>{Object.entries(i).forEach(t=>{var n,i,r,o,s,l;let a=nn(t,2),u=a[0],c=a[1];return this.setInput(u,e.chosenRun?null!=(n=null!=(i=null!=(r=null==(o=e.chosenRun)?void 0:o.inputs[c])?r:null==(s=e.chosenRun)?void 0:s.outputs[c])?i:null==(l=e.chosenRun)?void 0:l.options[c])?n:null:tR(this.funcCall.inputParams[u].property),e.chosenRun?"restricted":"user input")})});this.subs.push(r)}getInputForVal(t){var e,n;let i=t.property;if(this.inputsOverride[t.property.name])return this.inputsOverride[t.property.name];if(i.propertyType===o.TYPE.STRING&&i.options.choices&&!i.options.propagateChoice)return r.input.choice(null!=(e=i.caption)?e:i.name,{value:tR(i),items:JSON.parse(i.options.choices),nullable:i.nullable});switch(i.propertyType){case"file":return b.fileInput(null!=(n=i.caption)?n:i.name,null,null,null);case o.TYPE.FLOAT:let s=r.input.forProperty(i),l=i.options.format;return l&&(s.format=l),s;default:return r.input.forProperty(i)}}bindOnHotkey(t){ex(t)&&(t.input.onkeydown=t=>e9(function*(){"Enter"==t.key&&this.runRequests.next()}).call(this))}get foldedCategories(){var t;return JSON.parse(null!=(t=this.func.options.foldedCategories)?t:"[]")}getCategoryWarningIcon(t){let e=r.iconFA("exclamation-circle",null,"This category has inconsistent inputs");C()(e).css({color:"var(--orange-2)","padding-left":"5px"}).hide();let n=this.funcCallReplaced.subscribe(()=>{this.foldedCategoryInputs[t].some(t=>"inconsistent"===this.getInputLockState(t.paramName)&&t.input.value!==this.getRestrictedValue(t.paramName))?C()(e).show():C()(e).hide()});return this.subs.push(n),e}renderCategory(t,e,n){if(e!==n)if(this.foldedCategories.includes(e)){let n=this.getCategoryWarningIcon(e),i=r.iconFA("chevron-right",()=>{var t;C()(o).show(),C()(i).hide(),C()(n).hide(),(null!=(t=this.foldedCategoryInputs[e])?t:[]).forEach(t=>C()(t.input.root).css({display:""}))},"Open category");C()(i).css("padding-right","5px");let o=r.iconFA("chevron-down",()=>{var t;C()(o).hide(),C()(i).show(),this.foldedCategoryInputs[e].some(t=>"inconsistent"===this.getInputLockState(t.paramName))?C()(n).show():C()(n).hide(),(null!=(t=this.foldedCategoryInputs[e])?t:[]).forEach(t=>C()(t.input.root).hide())},"Close category");C()(o).css("padding-right","5px"),t.append(r.h2([i,o,r.h2(e,{style:{display:"inline"}}),n],{style:{width:"100%"}})),C()(o).hide()}else t.append(r.h2(e,{style:{width:"100%"}}))}renderInput(t,e,n){var i,o;let s=e.property;if(this.foldedCategories.includes(s.category)&&(this.foldedCategoryInputs[s.category]=[...null!=(i=this.foldedCategoryInputs[s.category])?i:[],{paramName:e.property.name,input:n}]),this.injectLockIcons(e,n),eo(n)||(n.setDisabled=function(){n.enabled=!1,C()(n.root).removeClass("rfv-restricted-unlocked-input"),C()(n.root).removeClass("rfv-inconsistent-input"),C()(n.root).removeClass("rfv-restricted-input")},n.setRestricted=function(){n.enabled=!1,C()(n.root).addClass("rfv-restricted-input"),C()(n.root).removeClass("rfv-restricted-unlocked-input"),C()(n.root).removeClass("rfv-inconsistent-input")},n.setRestrictedUnlocked=function(){n.enabled=!0,C()(n.root).addClass("rfv-restricted-unlocked-input"),C()(n.root).removeClass("rfv-restricted-input"),C()(n.root).removeClass("rfv-inconsistent-input")},n.setInconsistent=function(){n.enabled=!0,C()(n.root).addClass("rfv-inconsistent-input"),C()(n.root).removeClass("rfv-restricted-input"),C()(n.root).removeClass("rfv-restricted-unlocked-input")},n.setUserInput=function(){n.enabled=!0,C()(n.root).removeClass("rfv-inconsistent-input"),C()(n.root).removeClass("rfv-restricted-input"),C()(n.root).removeClass("rfv-restricted-unlocked-input")}),ex(n)){let t,i;t=e.property,C()(n.root).css({width:`calc(${null!=(o=t.options.block)?o:"100"}% - ${t.options.block?"2":"0"}px)`,"box-sizing":"border-box"}),this.bindTooltips(e,n),i=r.element("i"),n.addOptions(i),n.setValidation=function(t){for(;i.firstChild&&i.removeChild(i.firstChild););let e=eA(ef(t),2),r=e[0],o=e[1];r&&o&&(i.appendChild(r),i.appendChild(o)),n.input.classList.remove("d4-invalid"),n.input.classList.remove("d4-partially-invalid"),(null==t?void 0:t.errors)&&t.errors.length||(null==t?void 0:t.warnings)&&t.warnings.length||(null==t?void 0:t.notifications)&&t.notifications.length||(null==t?void 0:t.pending)?C()(i).css("display","flex"):C()(i).hide(),(null==t?void 0:t.errors)&&t.errors.length?n.input.classList.add("d4-invalid"):(null==t?void 0:t.warnings)&&t.warnings.length&&n.input.classList.add("d4-partially-invalid")}}t.append(n.root)}bindTooltips(t,e){let n=t.property.name,i=()=>{var e,i;let o=`${null!=(e=null!=(i=t.property.description)?i:t.property.caption)?e:t.property.name}.`,s="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 o||s?r.divV([...o?[r.divText(o)]:[],...s?[r.divText(s)]:[]],{style:{maxWidth:"300px"}}):null};r.tooltip.bind(e.captionLabel,i),r.tooltip.bind(e.input,i)}injectLockIcons(t,e){let n=t.property.name;e.root.addEventListener("click",()=>{"restricted"===this.getInputLockState(n)&&this.setInputLockState(e,t.name,t.value,"restricted unlocked")});let i=r.iconFA("lock");C()(i).addClass("rfv-icon-lock"),C()(i).css({color:"var(--grey-2)"});let s=r.iconFA("lock-open");C()(s).addClass("rfv-icon-unlock"),C()(s).css({color:"var(--grey-2)"});let l=r.iconFA("undo",e=>{this.setInput(t.name,this.getRestrictedValue(n),"restricted"),e.stopPropagation()},"Reset value to computed value");C()(l).addClass("rfv-icon-undo"),C()(l).css({color:"var(--blue-2)"});let a=r.iconFA("exclamation-circle",null,"Validation");r.tooltip.bind(a,()=>`Current value is incosistent. Computed value was ${o.TYPES_SCALAR.has(t.property.propertyType)?this.getRestrictedValue(n):"different"}`),C()(a).addClass("rfv-icon-warning"),C()(a).css({color:"var(--orange-2)"}),e.placeLockStateIcons||(e.placeLockStateIcons=function(t,n,i,r){ex(e)&&(e.addOptions(t),e.addOptions(n),e.addOptions(i),e.addOptions(r))}),e.placeLockStateIcons(i,s,l,a)}syncInput(t,e,n){var i;let r=t.name,a=!1,u=this.funcCallReplaced.pipe((0,l.startWith)(!0)).subscribe(()=>{var t,i;let o=this.funcCall[eg[n]][r],s=null!=(t=null!=(i=this.funcCall[n][r])?i:tR(o.property))?t:null;e.notify=!1,e.value=s,e.notify=!0,this.funcCall[n][r]=s,this.setInputLockState(e,r,s,this.getInputLockState(r))});this.subs.push(u);let c=this.funcCallReplaced.pipe((0,l.startWith)(!0),(0,l.switchMap)(()=>{let t=this.funcCall[eg[n]][r];return t.onChanged.pipe((0,l.mapTo)(t))})).subscribe(t=>{let i=this.funcCall[n][t.name];if(a||(e.notify=!1,e.value=i,e.notify=!0),n===g.INPUTS){this.isHistorical.next(!1),this.hideOutput(),this.inputValidationRequests.next({field:t.name,isRevalidation:!1});let 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(c);let d=this.funcCallReplaced.pipe((0,l.startWith)(!0),(0,l.switchMap)(()=>{let t=this.funcCall[eg[n]][r];return t.onChanged.pipe((0,l.mapTo)(t),(0,l.startWith)(t))}),(0,l.filter)(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&t.value),(0,l.switchMap)(t=>t.value.onDataChanged.pipe((0,l.mapTo)(t)))).subscribe(t=>{n===g.INPUTS?this.inputValidationRequests.next({field:t.name,isRevalidation:!1}):this.outputValidationRequests.next({field:t.name,isRevalidation:!1})});this.subs.push(d);let p=(ex(e)?e.onInput:(i=e.onInput.bind(e),new s.Observable(t=>{let e=i(e=>{t.next(e)});return()=>e.unsubscribe()}))).pipe((0,l.debounceTime)(250)).subscribe(()=>{try{a=!0,this.funcCall[n][t.name]=e.value}finally{a=!1}});this.subs.push(p)}isRunnable(){return!this.isRunning.value&&!this.blockRuns.value&&this.isValid()}isValid(){var t=!0,e=!1,n=void 0;try{for(var i,r=Object.entries(this.inputValidationState)[Symbol.iterator]();!(t=(i=r.next()).done);t=!0){let t=nn(i.value,2),e=(t[0],t[1]);if(!ea(e))return!1}}catch(t){e=!0,n=t}finally{try{t||null==r.return||r.return()}finally{if(e)throw n}}var o=!0,s=!1,l=void 0;try{for(var a,u=Object.entries(this.externalValidatorsState)[Symbol.iterator]();!(o=(a=u.next()).done);o=!0){let t=nn(a.value,2),e=(t[0],t[1]);if(!ea(e))return!1}}catch(t){s=!0,l=t}finally{try{o||null==u.return||u.return()}finally{if(s)throw l}}return!0}getValidationState(){return this.inputValidationState}getValidationMessage(){let t=[];var e=!0,n=!1,i=void 0;try{for(var r,o=Object.entries(this.inputValidationState)[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){let e=nn(r.value,2),n=e[0],i=e[1];ea(i)||t.push(`${n}: ${function(t){if(null==t?void 0:t.errors)return t.errors.map(t=>t.description).join("; ")}(i)}`)}}catch(t){n=!0,i=t}finally{try{e||null==o.return||o.return()}finally{if(n)throw i}}return t.join("\n")}runValidation(t,e){return e9(function*(t,e,n){let i,r,o=void 0===n?g.INPUTS:n,s=t.field,l=this.getValidatedNames(s,o);return i={view:this,funcCall:this.funcCall,lastCall:this.lastCall},r=o===g.INPUTS?this.inputValidators:this.outputValidators,ew(function*(){let n=i.view,s=i.funcCall,a=i.lastCall;return Object.fromEntries((yield Promise.all(l.map(i=>ew(function*(){var l;let u,c=o===g.INPUTS?s.inputs[i]:s.outputs[i],d=yield(t.isNewOutput,t.isRevalidation,(l=function*(){if(null==c)return ec({errors:["Missing value"]})},function(){var t=this,e=arguments;return new Promise(function(n,i){var r=l.apply(t,e);function o(t){es(r,n,i,o,s,"next",t)}function s(t){es(r,n,i,o,s,"throw",t)}o(void 0)})})()),p=r[i];p&&(u=yield p(c,{param:i,funcCall:s,lastCall:a,signal:e,isNewOutput:!!t.isNewOutput,isRevalidation:t.isRevalidation,context:t.context,view:n}));let h=o===g.INPUTS&&s.inputParams[i].property.options.nullable;return[i,ed(...h?[]:[d],u)]})()))))})()}).apply(this,arguments)}setInputValidationPending(t){let e=this.getValidatedNames(t);var n=!0,i=!1,r=void 0;try{for(var o,s=e[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let t=o.value;this.inputValidationState[t]=ep();let e=this.inputsMap[t];er(e)&&e.setValidation(ep())}}catch(t){i=!0,r=t}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}this.inputValidationUpdates.next(null)}setOutputValidationPending(t){let e=this.getValidatedNames(t,g.OUTPUTS);var n=!0,i=!1,r=void 0;try{for(var o,s=e[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let t=o.value;this.outputValidationState[t]=ep();let e=this.outputValidationSigns[t];if(e){let n=ef(ep());e[0].replaceWith(n[0]),e[1].replaceWith(n[1]),this.outputValidationSigns[t]=n}}}catch(t){i=!0,r=t}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}this.outputValidationUpdates.next(null)}setInputValidationResults(t){var e=!0,n=!1,i=void 0;try{for(var r,o=Object.entries(t)[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){let t=nn(r.value,2),e=t[0],n=t[1];this.inputValidationState[e]=n,this.updateInputValidationResults(e)}}catch(t){n=!0,i=t}finally{try{e||null==o.return||o.return()}finally{if(n)throw i}}}setOutputValidationResults(t){var e=!0,n=!1,i=void 0;try{for(var r,o=Object.entries(t)[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){let t=nn(r.value,2),e=t[0],n=t[1];this.outputValidationState[e]=n,this.updateOutputValidationResults(e)}}catch(t){n=!0,i=t}finally{try{e||null==o.return||o.return()}finally{if(n)throw i}}}updateOutputValidationResults(t){let e,n=this.outputValidationState[t],i=this.outputValidationSigns[t];i&&(this.outputValidationSigns[t]=(e=ef(n),i[0].replaceWith(e[0]),i[1].replaceWith(e[1]),e))}updateInputValidationResults(t){let e=ed(this.inputValidationState[t],this.externalValidatorsState[t]),n=this.inputsMap[t];er(n)&&n.setValidation(e)}runRevalidations(t,e,n){let i=void 0===n?g.INPUTS:n;if(!t.isRevalidation){var r=!0,o=!1,s=void 0;try{for(var l,a=Object.entries(e)[Symbol.iterator]();!(r=(l=a.next()).done);r=!0){let t=nn(l.value,2)[1];if(null==t?void 0:t.revalidate){var u=!0,c=!1,d=void 0;try{for(var p,h=t.revalidate[Symbol.iterator]();!(u=(p=h.next()).done);u=!0){let e=p.value;i===g.INPUTS?this.inputValidationRequests.next({field:e,context:t.context,isRevalidation:!0}):this.outputValidationRequests.next({field:e,context:t.context,isRevalidation:!0})}}catch(t){c=!0,d=t}finally{try{u||null==h.return||h.return()}finally{if(c)throw d}}}}}catch(t){o=!0,s=t}finally{try{r||null==a.return||a.return()}finally{if(o)throw s}}}}getValidatedNames(t,e){let n=void 0===e?g.INPUTS:e;return t?[t]:[...n===g.INPUTS?this.funcCall.inputs.keys():this.funcCall.outputs.keys()]}getValidExpRun(t){return e9(function*(){t.started=x()();let e=t.options.immutable_tags||[];return t.options.immutable_tags=e.includes(P)?e:[...e,P],t.newId(),t})()}saveExperimentalRun(t){return e9(function*(){let e=yield this.getValidExpRun(t);yield this.saveRun(e)}).call(this)}hideOutput(){if(this._isOutputOutdated.next(!0),this.keepOutput())return;this.outputTabsLabels.forEach(t=>{var e;return C()(null==(e=this.tabsElem.getPane(t))?void 0:e.header).hide()});let t=this.tabsElem.panes.find(t=>this.inputTabsLabels.includes(t.name));t?this.tabsElem.currentPane=t:C()(this.tabsElem.root).hide()}richFunctionViewSupportedFormats(){return["Excel"]}richFunctionViewExportExtensions(){return{Excel:"xlsx"}}constructor(t,n){var i;let a=void 0===n?{historyEnabled:!0,isTabbed:!1}:n;super(t,a),i=this,this.options=a,this.inputValidationRequests=new s.Subject,this.outputValidationRequests=new s.Subject,this.inputValidationUpdates=new s.Subject,this.outputValidationUpdates=new s.Subject,this.runRequests=new s.Subject,this.isRunning=new s.BehaviorSubject(!1),this.isUploadMode=new s.BehaviorSubject(!1),this.inputsOverride={},this.inputsMap={},this.outputValidationSigns={},this.inputValidators={},this.outputValidators={},this.inputValidationState={},this.outputValidationState={},this.externalValidatorsUpdates=new s.Subject,this.externalValidatorsState={},this.pendingInputValidations=this.inputValidationUpdates.pipe((0,l.startWith)(null),(0,l.map)(()=>this.inputValidationState)),this._isOutputOutdated=new s.BehaviorSubject(!0),this.isOutputOutdated=this._isOutputOutdated.pipe((0,l.distinctUntilChanged)()),this.blockRuns=new s.BehaviorSubject(!1),this.prevOpenedTab=null,this.beforeInputPropertyRender=new s.Subject,this.afterInputPropertyRender=new s.Subject,this.afterOutputPropertyRender=new s.Subject,this.afterOutputSacalarTableRender=new s.Subject,this.formButtons=r.div(),this.additionalBtns=[],this.navBtns=[],this.tabsElem=r.tabControl(),this.dfToViewerMapping={},this.focusedInput=null,this.foldedCategoryInputs={},this.richFunctionExport=t=>e9(function*(){let n,s,l,a,u;if(!i.lastCall)throw Error("Function was not called");if(!i.exportConfig.supportedFormats.includes(t))throw Error(`Format "${t}" is not supported.`);if(!i.func)throw Error("The correspoding function is not specified");return nn((yield(n=i.func,s=i.lastCall,l=i.dfToViewerMapping,eZ(function*(){let i={},c=(t,e)=>{if(i[t])return i[t];let n=`${t}`;n.length>31&&(n=`${n.slice(0,31)}`);let r=1;for(;e.worksheets.some(t=>t.name.toLowerCase()===n.toLowerCase());){let e=`${t}`;e.length>31-`-${r}`.length&&(e=`${t.slice(0,31-`-${r}`.length)}`),n=`${e}-${r}`,r++}return i[t]=n,n};if("Excel"===t)try{yield o.Utils.loadJsCss(["/js/common/exceljs.min.js","/js/common/html2canvas.min.js"]);let t=window.ExcelJS,i=window.html2canvas,D=new t.Workbook;r.setDisplay(e.shell.v.root,!1),e0(e.shell.v.root.parentElement,!0,"Generating report. Please do not switch the browser tab...");let L=0,j=(t,n,s,l)=>{let a=void 0===l?0:l;return eZ(function*(){if(!n||!n.dataFrame)return;let l=o.Viewer.fromType(n.type,n.dataFrame.clone());l.copyViewersLook(n);let u=r.div(l.root,{style:{width:"1280px",height:"720px"}});u.classList.add("ui-box"),u.classList.remove("ui-div"),e.shell.v.root.insertAdjacentElement("afterend",u),yield new Promise(t=>setTimeout(t,1e3));let c=(yield i(u)).toDataURL();u.remove(),l.detach();let d=D.addImage({base64:c,extension:"png"});t.addImage(d,{tl:{col:s,row:a},ext:{width:1280,height:720}})})()},M=t=>t.propertyType===o.TYPE.DATA_FRAME,N=n.inputs.filter(t=>M(t)),_=n.inputs.filter(t=>{let e;return e=t.propertyType,o.TYPES_SCALAR.has(e)}),U=n.outputs.filter(t=>M(t)),H=n.outputs.filter(t=>{let e;return e=t.propertyType,o.TYPES_SCALAR.has(e)});if(N.forEach(t=>{var e;let n=s.inputs[t.name];if(e6(n))return;let i=t.options.caption||t.name,r=null!=(e=D.worksheets.find(t=>t.name===c(i,D)))?e:D.addWorksheet(c(i,D)),o=null==a?void 0:a[t.name],l=null==u?void 0:u[t.name];e4({sheet:r,dfCounter:L,df:n,validation:o,consistency:l}),L++}),_.length){let t=D.addWorksheet("Input scalars");e2(t,_.map(t=>{var e,n,i;return{name:t.name,caption:null!=(e=t.options.caption)?e:t.name,value:null!=(n=s.inputs[t.name])?n:"",units:null!=(i=t.options.units)?i:"",format:t.format||R}}),a,u)}if(U.forEach(t=>{var e;let n=s.outputs[t.name];if(e6(n))return;let i=t.options.caption||t.name,r=null!=(e=D.worksheets.find(t=>t.name===c(i,D)))?e:D.addWorksheet(c(i,D)),o=null==a?void 0:a[t.name],l=null==u?void 0:u[t.name];e4({sheet:r,dfCounter:L,df:n,validation:o,consistency:l}),L++}),H.length){let t=D.addWorksheet("Output scalars");e2(t,H.map(t=>{var e,n,i;return{name:t.name,caption:null!=(e=t.options.caption)?e:t.name,value:null!=(n=s.outputs[t.name])?n:"",units:null!=(i=t.options.units)?i:"",format:t.format||R}}),a,u)}var d=!0,p=!1,h=void 0;try{for(var f,m=n.inputs.filter(t=>M(t))[Symbol.iterator]();!(d=(f=m.next()).done);d=!0){let t=f.value,e=s.inputs[t.name];if(e6(e))continue;let n=(null!=(b=l[t.name])?b:[]).filter(t=>t&&t.type!==o.VIEWER.GRID).filter(t=>Object.values(S).includes(t.type));if(0===n.length)continue;let i=t.options.caption||t.name;var v=!0,y=!1,g=void 0;try{for(var b,C,w=n.entries()[Symbol.iterator]();!(v=(C=w.next()).done);v=!0){let t=eX(C.value,2),n=t[0],r=t[1];yield j(D.getWorksheet(c(i,D)),r,e.columns.length+2,n*eQ)}}catch(t){y=!0,g=t}finally{try{v||null==w.return||w.return()}finally{if(y)throw g}}}}catch(t){p=!0,h=t}finally{try{d||null==m.return||m.return()}finally{if(p)throw h}}var A=!0,x=!1,I=void 0;try{for(var E,T=n.outputs.filter(t=>M(t))[Symbol.iterator]();!(A=(E=T.next()).done);A=!0){let t=E.value,e=s.outputs[t.name];if(e6(e))continue;let n=(null!=(V=l[t.name])?V:[]).filter(t=>t&&t.type!==o.VIEWER.GRID).filter(t=>Object.values(S).includes(t.type));if(0===n.length)continue;let i=t.options.caption||t.name;var O=!0,P=!1,F=void 0;try{for(var V,B,k=n.entries()[Symbol.iterator]();!(O=(B=k.next()).done);O=!0){let t=eX(B.value,2),n=t[0],r=t[1];if(r)if(r.type===o.VIEWER.STATISTICS){let t=e.columns.length,r=o.DataFrame.fromColumns([o.Column.string("Name",t).init(t=>e.columns.byIndex(t).name),o.Column.int("Values",t).init(t=>e.columns.byIndex(t).stats.valueCount),o.Column.int("Nulls",t).init(t=>e.columns.byIndex(t).stats.missingValueCount),o.Column.float("Min",t).init(t=>e.columns.byIndex(t).stats.min),o.Column.float("Max",t).init(t=>e.columns.byIndex(t).stats.max),o.Column.float("Avg",t).init(t=>e.columns.byIndex(t).stats.avg),o.Column.float("Stdev",t).init(t=>e.columns.byIndex(t).stats.stdev)]);e4({sheet:D.getWorksheet(c(i,D)),dfCounter:L,df:r,column:e.columns.length+2,row:n*eQ}),L++}else yield j(D.getWorksheet(c(i,D)),r,e.columns.length+2,n*eQ)}}catch(t){P=!0,F=t}finally{try{O||null==k.return||k.return()}finally{if(P)throw F}}}}catch(t){x=!0,I=t}finally{try{A||null==T.return||T.return()}finally{if(x)throw I}}let W=yield D.xlsx.writeBuffer();return[new Blob([W],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"}),D]}catch(t){console.log(t)}finally{r.setDisplay(e.shell.v.root,!0),e0(e.shell.v.root.parentElement,!1)}throw Error("Format is not supported")})())),1)[0]})(),this.exportConfig={supportedExtensions:this.richFunctionViewExportExtensions(),supportedFormats:this.richFunctionViewSupportedFormats(),export:this.richFunctionExport,filename:this.defaultExportFilename}}}var no=Uint8Array,ns=Uint16Array,nl=Uint32Array,na=new no([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]),nu=new no([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]),nc=new no([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),nd=function(t,e){for(var n=new ns(31),i=0;i<31;++i)n[i]=e+=1<<t[i-1];for(var r=new nl(n[30]),i=1;i<30;++i)for(var o=n[i];o<n[i+1];++o)r[o]=o-n[i]<<5|i;return[n,r]},np=nd(na,2),nh=np[0],nf=np[1];nh[28]=258,nf[258]=28;for(var nm=nd(nu,0),nv=(nm[0],nm[1]),ny=new ns(32768),ng=0;ng<32768;++ng){var nb=(43690&ng)>>>1|(21845&ng)<<1;nb=(61680&(nb=(52428&nb)>>>2|(13107&nb)<<2))>>>4|(3855&nb)<<4,ny[ng]=((65280&nb)>>>8|(255&nb)<<8)>>>1}for(var nC=function(t,e,n){for(var i,r=t.length,o=0,s=new ns(e);o<r;++o)t[o]&&++s[t[o]-1];var l=new ns(e);for(o=0;o<e;++o)l[o]=l[o-1]+s[o-1]<<1;if(n){i=new ns(1<<e);var a=15-e;for(o=0;o<r;++o)if(t[o])for(var u=o<<4|t[o],c=e-t[o],d=l[t[o]-1]++<<c,p=d|(1<<c)-1;d<=p;++d)i[ny[d]>>>a]=u}else for(o=0,i=new ns(r);o<r;++o)t[o]&&(i[o]=ny[l[t[o]-1]++]>>>15-t[o]);return i},nw=new no(288),ng=0;ng<144;++ng)nw[ng]=8;for(var ng=144;ng<256;++ng)nw[ng]=9;for(var ng=256;ng<280;++ng)nw[ng]=7;for(var ng=280;ng<288;++ng)nw[ng]=8;for(var nA=new no(32),ng=0;ng<32;++ng)nA[ng]=5;var nx=nC(nw,9,0),nI=nC(nA,5,0),nE=function(t){return(t+7)/8|0},nR=function(t,e,n){(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length);var i=new(2==t.BYTES_PER_ELEMENT?ns:4==t.BYTES_PER_ELEMENT?nl:no)(n-e);return i.set(t.subarray(e,n)),i},nS=["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"],nT=function(t,e,n){var i=Error(e||nS[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,nT),!n)throw i;return i},nO=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>>8},nP=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},nF=function(t,e){for(var n=[],i=0;i<t.length;++i)t[i]&&n.push({s:i,f:t[i]});var r=n.length,o=n.slice();if(!r)return[nM,0];if(1==r){var s=new no(n[0].s+1);return s[n[0].s]=1,[s,1]}n.sort(function(t,e){return t.f-e.f}),n.push({s:-1,f:25001});var l=n[0],a=n[1],u=0,c=1,d=2;for(n[0]={s:-1,f:l.f+a.f,l:l,r:a};c!=r-1;)l=n[n[u].f<n[d].f?u++:d++],a=n[u!=c&&n[u].f<n[d].f?u++:d++],n[c++]={s:-1,f:l.f+a.f,l:l,r:a};for(var p=o[0].s,i=1;i<r;++i)o[i].s>p&&(p=o[i].s);var h=new ns(p+1),f=nV(n[c-1],h,0);if(f>e){var i=0,m=0,v=f-e,y=1<<v;for(o.sort(function(t,e){return h[e.s]-h[t.s]||t.f-e.f});i<r;++i){var g=o[i].s;if(h[g]>e)m+=y-(1<<f-h[g]),h[g]=e;else break}for(m>>>=v;m>0;){var b=o[i].s;h[b]<e?m-=1<<e-h[b]++-1:++i}for(;i>=0&&m;--i){var C=o[i].s;h[C]==e&&(--h[C],++m)}f=e}return[new no(h),f]},nV=function(t,e,n){return -1==t.s?Math.max(nV(t.l,e,n+1),nV(t.r,e,n+1)):e[t.s]=n},nB=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new ns(++e),i=0,r=t[0],o=1,s=function(t){n[i++]=t},l=1;l<=e;++l)if(t[l]==r&&l!=e)++o;else{if(!r&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(r),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(r);o=1,r=t[l]}return[n.subarray(0,i),e]},nk=function(t,e){for(var n=0,i=0;i<e.length;++i)n+=t[i]*e[i];return n},nD=function(t,e,n){var i=n.length,r=nE(e+2);t[r]=255&i,t[r+1]=i>>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var o=0;o<i;++o)t[r+o+4]=n[o];return(r+4+i)*8},nL=function(t,e,n,i,r,o,s,l,a,u,c){nO(e,c++,n),++r[256];for(var d,p,h,f,m=nF(r,15),v=m[0],y=m[1],g=nF(o,15),b=g[0],C=g[1],w=nB(v),A=w[0],x=w[1],I=nB(b),E=I[0],R=I[1],S=new ns(19),T=0;T<A.length;++T)S[31&A[T]]++;for(var T=0;T<E.length;++T)S[31&E[T]]++;for(var O=nF(S,7),P=O[0],F=O[1],V=19;V>4&&!P[nc[V-1]];--V);var B=u+5<<3,k=nk(r,nw)+nk(o,nA)+s,D=nk(r,v)+nk(o,b)+s+14+3*V+nk(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(B<=k&&B<=D)return nD(e,c,t.subarray(a,a+u));if(nO(e,c,1+(D<k)),c+=2,D<k){d=nC(v,y,0),p=v,h=nC(b,C,0),f=b;var L=nC(P,F,0);nO(e,c,x-257),nO(e,c+5,R-1),nO(e,c+10,V-4),c+=14;for(var T=0;T<V;++T)nO(e,c+3*T,P[nc[T]]);c+=3*V;for(var j=[A,E],M=0;M<2;++M)for(var N=j[M],T=0;T<N.length;++T){var _=31&N[T];nO(e,c,L[_]),c+=P[_],_>15&&(nO(e,c,N[T]>>>5&127),c+=N[T]>>>12)}}else d=nx,p=nw,h=nI,f=nA;for(var T=0;T<l;++T)if(i[T]>255){var _=i[T]>>>18&31;nP(e,c,d[_+257]),c+=p[_+257],_>7&&(nO(e,c,i[T]>>>23&31),c+=na[_]);var U=31&i[T];nP(e,c,h[U]),c+=f[U],U>3&&(nP(e,c,i[T]>>>5&8191),c+=nu[U])}else nP(e,c,d[i[T]]),c+=p[i[T]];return nP(e,c,d[256]),c+p[256]},nj=new nl([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),nM=new no(0),nN=function(t,e,n,i,r,o){var s=t.length,l=new no(i+s+5*(1+Math.ceil(s/7e3))+r),a=l.subarray(i,l.length-r),u=0;if(!e||s<8)for(var c=0;c<=s;c+=65535){var d=c+65535;d>=s&&(a[u>>3]=o),u=nD(a,u+1,t.subarray(c,d))}else{for(var p=nj[e-1],h=p>>>13,f=8191&p,m=(1<<n)-1,v=new ns(32768),y=new ns(m+1),g=Math.ceil(n/3),b=2*g,C=function(e){return(t[e]^t[e+1]<<g^t[e+2]<<b)&m},w=new nl(25e3),A=new ns(288),x=new ns(32),I=0,E=0,c=0,R=0,S=0,T=0;c<s;++c){var O=C(c),P=32767&c,F=y[O];if(v[P]=F,y[O]=P,S<=c){var V=s-c;if((I>7e3||R>24576)&&V>423){u=nL(t,a,0,w,A,x,E,R,T,c-T,u),R=I=E=0,T=c;for(var B=0;B<286;++B)A[B]=0;for(var B=0;B<30;++B)x[B]=0}var k=2,D=0,L=f,j=P-F&32767;if(V>2&&O==C(c-j))for(var M=Math.min(h,V)-1,N=Math.min(32767,c),_=Math.min(258,V);j<=N&&--L&&P!=F;){if(t[c+k]==t[c+k-j]){for(var U=0;U<_&&t[c+U]==t[c+U-j];++U);if(U>k){if(k=U,D=j,U>M)break;for(var H=Math.min(j,U-2),W=0,B=0;B<H;++B){var Y=c-j+B+32768&32767,G=v[Y],q=Y-G+32768&32767;q>W&&(W=q,F=Y)}}}F=v[P=F],j+=P-F+32768&32767}if(D){w[R++]=0x10000000|nf[k]<<18|nv[D];var J=31&nf[k],z=31&nv[D];E+=na[J]+nu[z],++A[257+J],++x[z],S=c+k,++I}else w[R++]=t[c],++A[t[c]]}}u=nL(t,a,o,w,A,x,E,R,T,c-T,u),!o&&7&u&&(u=nD(a,u+1,nM))}return nR(l,0,i+nE(u)+r)},n_=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,i=9;--i;)n=(1&n&&-0x12477ce0)^n>>>1;t[e]=n}return t}(),nU=function(){var t=-1;return{p:function(e){for(var n=t,i=0;i<e.length;++i)n=n_[255&n^e[i]]^n>>>8;t=n},d:function(){return~t}}},nH=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},n$=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},nW=function(t,e,n,i){for(var r in t){var o=t[r],s=e+r,l=i;Array.isArray(o)&&(l=nH(i,o[1]),o=o[0]),o instanceof no?n[s]=[o,l]:(n[s+="/"]=[new no(0),l],nW(o,s,n,i))}},nY="u">typeof TextEncoder&&new TextEncoder,nG="u">typeof TextDecoder&&new TextDecoder;try{nG.decode(nM,{stream:!0})}catch(t){}function nq(t,e){if(e){for(var n=new no(t.length),i=0;i<t.length;++i)n[i]=t.charCodeAt(i);return n}if(nY)return nY.encode(t);for(var r=t.length,o=new no(t.length+(t.length>>1)),s=0,l=function(t){o[s++]=t},i=0;i<r;++i){if(s+5>o.length){var a=new no(s+8+(r-i<<1));a.set(o),o=a}var u=t.charCodeAt(i);u<128||e?l(u):(u<2048?l(192|u>>6):(u>55295&&u<57344?(l(240|(u=65536+(1047552&u)|1023&t.charCodeAt(++i))>>18),l(128|u>>12&63)):l(224|u>>12),l(128|u>>6&63)),l(128|63&u))}return nR(o,0,s)}var nJ=function(t){var e=0;if(t)for(var n in t){var i=t[n].length;i>65535&&nT(9),e+=i+4}return e},nz=function(t,e,n,i,r,o,s,l){var a=i.length,u=n.extra,c=l&&l.length,d=nJ(u);n$(t,e,null!=s?0x2014b50:0x4034b50),e+=4,null!=s&&(t[e++]=20,t[e++]=n.os),t[e]=20,e+=2,t[e++]=n.flag<<1|(o<0&&8),t[e++]=r&&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)&&nT(10),n$(t,e,h<<25|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>>1),e+=4,-1!=o&&(n$(t,e,n.crc),n$(t,e+4,o<0?-o-2:o),n$(t,e+8,n.size)),n$(t,e+12,a),n$(t,e+14,d),e+=16,null!=s&&(n$(t,e,c),n$(t,e+6,n.attrs),n$(t,e+10,s),e+=14),t.set(i,e),e+=a,d)for(var f in u){var m=u[f],v=m.length;n$(t,e,+f),n$(t,e+2,v),t.set(m,e+4),e+=4+v}return c&&(t.set(l,e),e+=c),e},nK=function(t,e,n,i,r){n$(t,e,0x6054b50),n$(t,e+8,n),n$(t,e+10,n),n$(t,e+12,i),n$(t,e+16,r)};"function"==typeof queueMicrotask&&queueMicrotask;var nZ=n(510),nX={};function nQ(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function n0(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function n1(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){n0(o,i,r,s,l,"next",t)}function l(t){n0(o,i,r,s,l,"throw",t)}s(void 0)})}}function n2(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n,i,r=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var o=[],s=!0,l=!1;try{for(r=r.call(t);!(s=(n=r.next()).done)&&(o.push(n.value),!e||o.length!==e);s=!0);}catch(t){l=!0,i=t}finally{try{s||null==r.return||r.return()}finally{if(l)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return nQ(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nQ(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}nX.styleTagTransform=tW(),nX.setAttributes=t_(),nX.insert=tM().bind(null,"head"),nX.domAPI=tL(),nX.insertStyleElement=tH(),tk()(nZ.A,nX),nZ.A&&nZ.A.locals&&nZ.A.locals;let n5=t=>{var e,n;return null!=(e=null==(n=t.options)?void 0:n.friendlyName)?e:t.func.name},n3=t=>{var e;return null!=(e=t.customId)?e:t.funcName};function n4(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function n6(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){n4(o,i,r,s,l,"next",t)}function l(t){n4(o,i,r,s,l,"throw",t)}s(void 0)})}}class n8 extends o.ObjectHandler{get type(){return"Model"}get helpUrl(){return null}getById(t){return n6(function*(){return yield e.dapi.functions.find(t)})()}refresh(t){return n6(function*(){return yield this.getById(t.id)}).call(this)}static openHelp(t){return n6(function*(){let n=yield tu(t);e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(r.markdown(null!=n?n:""))})()}static openModel(t){t.prepare().edit()}static openModelFromFunccall(t){t.edit()}static getUserGroups(){return n6(function*(){return yield tl(function*(){let t=e.dapi.groups;return"function"==typeof t.currentUserGroups?yield t.currentUserGroups():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 n;let i=JSON.parse(t.options.versions?`${t.options.versions}`:"[]");if((null!=(n=null==i?void 0:i.length)?n:0)<2)return void e.shell.info("No other versions avaliable");let o=r.dialog({title:"Choose version"}),s=r.input.choice("Select version",{items:i,value:i[0]});o.add(s).onOK(()=>{let e=s.value;t.prepare({params:{version:e}}).edit()}),o.show()}isApplicable(t){var e,n,i=o.toJs(t);if(!(i instanceof o.Func))return!1;let r=(null!=(e=null==i||null==(n=i.options)?void 0:n.role)?e:"").split(",").includes("model"),s=i.hasTag("model");return r||s}getLanguageIcon(t){return"grok"==t?r.iconSvg("project"):r.iconImage("script",`/images/entities/${t}.png`)}renderMarkup(t){let n=r.divH([],{style:{justifyContent:"space-between",width:"100%"}});return setTimeout(()=>n6(function*(){let i=yield this.awaitUserGroups(),o=n8.getMissingGroups(t,i),s=o.length>0,l=r.iconFA("exclamation-triangle",null);l.classList.remove("grok-icon");let a=this.makeMandatoryGroupsInfo(o),u=r.span([this.renderIcon(t),r.label(t.friendlyName)]);if(n.onclick=()=>{e.shell.windows.help.visible&&n8.openHelp(t)},s?u.classList.add("d4-disabled"):n.ondblclick=()=>{n8.openModel(t)},s){var c;(c=a).popover="auto",c.style.cursor="default",c.style.padding="10px",c.style.background="#fdffe5",c.style.border="1px solid #E4E6CE",c.style.borderRadius="2px",c.style.boxShadow="0 0 5px #E4E6CE",c.style.maxWidth="500px",c.style.color="var(--gray-6)",document.body.append(a),n.addEventListener("click",()=>{var t,e;let n;t=l,e=a,n=t.getBoundingClientRect().toJSON(),e.style.inset="unset",e.style.top=n.y+"px",e.style.left=n.x+20+"px",a.showPopover()})}n.append(u),s&&n.append(r.span([l],{style:{paddingLeft:"10px"}}))}).call(this)),n}renderIcon(t){if(null!=t.options.icon&&(t.options.icon.startsWith("http://")||t.options.icon.startsWith("https://")))return r.iconImage("model-icon",t.options.icon);let e=tc(t);if(t instanceof o.Script&&(null==e||null==t.options.icon))return this.getLanguageIcon(t.language);if(!(e=tc(t=o.Func.find({package:t.package.name,name:t.name})[0])))return r.iconSvg("project");let n=null==e?void 0:e.getIconUrl();if(null!=t.options.icon){let e=n.split("/");e.pop(),e.push(t.options.icon),n=e.join("/")}return r.iconImage(t.package.name,n)}renderView(t){let e=r.div();return this.renderPreview(t).then(t=>e.appendChild(t.root)),e}renderPreview(t){var e=()=>super.renderPreview;return n6(function*(){let n=yield this.awaitUserGroups(),i=n8.getMissingGroups(t,n);if(!(null==i?void 0:i.length)&&("Compute2:TreeWizardEditor"===t.options.editor||"Compute2:RichFunctionViewEditor"===t.options.editor)){let e=t.prepare();return(yield o.Func.byName(t.options.editor).prepare({call:e}).call()).getOutputParamValue()}return o.View.fromViewAsync(()=>{var n=this;n6(function*(){var o,s,l;let a=yield tu(t),u=yield e().call(n,t);u.name=(null!=(o=t.friendlyName)?o:t.name)+" preview";let c=(null==i?void 0:i.length)?r.div([this.makeMandatoryGroupsInfo(i)],{style:{border:"2px solid var(--red-3)",padding:"10px",maxWidth:"400px"}}):r.div([r.bigButton("Launch",()=>t.prepare().edit())]);return u.append(r.div([r.h1(null!=(s=t.friendlyName)?s:t.name),r.divText(null!=(l=t.description)?l:t.name,{style:{marginBottom:"10px"}}),c,r.div([],{style:{padding:"20px "}}),r.markdown(null!=a?a:"")],{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"}})),u}).call(this)})}).call(this)}renderProperties(t){let e=r.accordion("ComputeModel");e.context=t;let n=r.div([r.span([this.renderIcon(t),r.label(t.friendlyName),r.contextActions(t),r.star(t.id)])]);return e.addTitle(n),null!=t.description&&n.appendChild(r.div([r.markdown(t.description)],"model-catalog-description")),n.appendChild(r.tags(t)),null!=t.options["dev.status"]&&n.appendChild(r.tableFromMap({Status:t.options["dev.status"]})),e.end(),e.root}renderTooltip(t){let e=r.span([this.renderIcon(t),r.label(t.friendlyName)]);return e.classList.add("d4-link-label"),r.bind(t,r.divV([r.h2(e),r.divV([r.divText(t.description,"ui-description")],{style:{lineHeight:"150%"}})]))}renderCard(t){let e=this.renderMarkup(t);return e.classList.add("d4-link-label"),r.bind(t,r.h2(e))}init(){this.registerParamFunc("Choose version",t=>{n8.openVersionSelectDialog(o.toJs(t))}),this.registerParamFunc("Help",t=>{n8.openHelp(o.toJs(t))});let t=new o.Functions,n=t=>e.shell.favorites.some(e=>e.id==t.id);t.registerParamFunc("Add to favorites",this.type,t=>n6(function*(){return yield o.Favorites.add(o.toJs(t))})(),t=>{let e=o.toJs(t);return this.isApplicable(e)&&e instanceof o.Entity&&!n(e)}),t.registerParamFunc("Remove from favorites",this.type,t=>n6(function*(){return yield o.Favorites.remove(o.toJs(t))})(),t=>{let e=o.toJs(t);return this.isApplicable(e)&&e instanceof o.Entity&&n(e)}),setTimeout(()=>n6(function*(){let t=yield n8.getUserGroups();this.userGroups.next(t)}).call(this))}makeMandatoryGroupsInfo(t){let n=r.div(r.divV([r.label("You should be a member of the following group(s):",{style:{marginLeft:"0px"}}),...t.map(t=>{let i;return r.divV([r.span([((i=r.iconFA("times")).style.marginRight="6px",i.classList.remove("grok-icon"),i),t.name],{style:{fontWeight:"600"}}),...t.help?[r.span([t.help],{style:{marginLeft:"16px"}})]:[],r.link("Request group membership",()=>n6(function*(){var i;yield(i=t.name,n6(function*(){try{var t;let n=yield e.dapi.groups.filter(`friendlyName="${i}"`).list();if(0===n.length)throw Error("group with specified name is not found");if(n.length>1)throw Error("found more than one group with specified name");let r=n[0];yield(t=e.shell.user.group,tl(function*(){let n=e.dapi.groups;if("function"==typeof n.requestMembership)return yield n.requestMembership(r,t);yield fetch(`${window.location.origin}/api/groups/${r.id}/requests/${t.id}`,{method:"POST"})})()),e.shell.info(`Request to join ${i} has been initiated. Please allow some time for approval.`)}catch(t){e.shell.error(t.toString())}})()),n.hidePopover()})(),void 0,{style:{marginLeft:"16px"}})])})],{style:{gap:"10px"}}));return n}awaitUserGroups(){return n6(function*(){return this.userGroups.pipe((0,l.filter)(t=>!!t),(0,l.map)(t=>t),(0,l.take)(1)).toPromise()}).call(this)}constructor(){super(),this.userGroups=new s.BehaviorSubject(void 0)}}function n7(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function n9(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){n7(o,i,r,s,l,"next",t)}function l(t){n7(o,i,r,s,l,"throw",t)}s(void 0)})}}function it(){return n9(function*(){yield i_.init()})()}function ie(t){i_.openModelFromFuncall(t)}function ii(){return i_.OutliersSelection()}function ir(t){return i_.RichFunctionViewEditor(t)}function io(t){return i_.PipelineStepEditor(t)}function is(t){return n9(function*(){return yield i_.CustomDataUploader(t)})()}function il(t){return n9(function*(){return yield i_.CustomUploader(t)})()}function ia(t){i_.CustomCustomizer(t)}function iu(t){return i_.SimTimeValidator(t)}function ic(t){return i_.DesiredTempValidator(t)}function id(t){return i_.InitialTempValidator(t)}function ip(t){return i_.AmbTempValidator(t)}function ih(t){return i_.HeatCapValidator(t)}function im(t){return i_.CustomStringInput(t)}function iv(t){return i_.ObjectCoolingSelector(t)}function iy(t){return n9(function*(){return yield i_.CustomInputMock(t)})()}function ig(t){return i_.RangeValidatorFactory(t)}function ib(t){return i_.AsyncValidatorDemoFactory(t)}function iC(t){return i_.GlobalValidatorDemoFactory(t)}function iw(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function iA(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){iw(o,i,r,s,l,"next",t)}function l(t){iw(o,i,r,s,l,"throw",t)}s(void 0)})}}function ix(t,e,n,i){var r,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var l=t.length-1;l>=0;l--)(r=t[l])&&(s=(o<3?r(s):o>3?r(e,n,s):r(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s}function iI(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function iE(t,e){return function(n,i){e(n,i,t)}}let iR=new o.Package;class iS{set value(t){let e=t?JSON.parse(t):"";this._value.next(e)}get value(){return this._value.value?JSON.stringify(this._value.value):""}onInput(t){return this._value.subscribe(()=>{this.notify&&t(this.value)})}constructor(){this._value=new s.BehaviorSubject(null),this.notify=!0,this.enabled=!0,this.root=r.div("",{style:{width:"100%"}}),this.input=r.input.toggle("test",{value:!0}),this.root.append(this.input.root)}}let iT=th,iO=class extends eG{},iP=nr,iF=class extends eG{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.view}getRunningUpdates(){return[]}disableSetters(t){}init(){return n1(function*(){yield this.loadFuncCallById(),this.initialConfig.forEach((t,e)=>{var n;this.steps[n3(t)]={idx:e,visibility:new s.BehaviorSubject(null!=(n=t.hiddenOnInit)?n:v.VISIBLE),ability:new s.BehaviorSubject(this.isHistorical.value||0===e?y.ENABLED:y.DISABLED),options:{friendlyName:t.friendlyName,helpUrl:t.helpUrl,customId:t.customId}}}),this.subs.push(e.functions.onAfterRunAction.pipe((0,l.filter)(t=>Object.values(this.steps).some(e=>{var n;let i=e.view;return(null==i||null==(n=i.funcCall)?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()}));let t=this.initialConfig.map(t=>n1(function*(){return{stepScript:o.Func.byName(t.funcName),stepId:n3(t)}})()),n=yield Promise.all(t);n.forEach(t=>{this.steps[t.stepId].func=t.stepScript}),this.root.classList.remove("ui-panel");let i={},a="editor:",u="Compute:PipelineStepEditor",c=n.map(t=>n1(function*(){let e=t.stepScript.script?(t=>{let e=t.script,n=e.indexOf(a);if(n<0)return u;let i=e.indexOf("\n",n);return e.substring(n+a.length,i).trim()})(t.stepScript):u;return i[e]||(i[e]=o.Func.byName(e.split(" ").join(""))),this.steps[t.stepId].editor=e,Promise.resolve()}).call(this));yield Promise.all(c);let d=n.map(t=>n1(function*(){let n=this.steps[t.stepId],a=t.stepScript.prepare(),u=i[n.editor];yield this.onBeforeStepFuncCallApply(t.stepScript.nqName,a,u);let c=yield u.apply({call:a});yield c.isReady.pipe((0,l.filter)(t=>!!t),(0,l.take)(1)).toPromise();let d=r.button("Back",()=>{},"Go to the previous step");C()(d).addClass("ui-btn-nav");let p=r.button("Next",()=>{},"Go to the next step");C()(p).addClass("ui-btn-nav"),this.syncNavButtons(n,d,p),c.setNavigationButtons([d,p]),this.steps[t.stepId].view=c;let h=this.steps[t.stepId],f=()=>{Object.values(this.steps).forEach(t=>{t.idx>h.idx&&t.visibility.value===v.VISIBLE&&t.ability.value===y.ENABLED&&t.ability.next(y.DISABLED)})},m=h.view.funcCallReplaced.pipe((0,l.switchMap)(()=>{let t=[...h.view.funcCall.inputParams.values()].map(t=>t.onChanged.pipe((0,l.mapTo)(t)));return(0,s.merge)(...t)})),g=m.subscribe(f);this.subs.push(g);let b=m.pipe((0,l.filter)(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&t.value),(0,l.switchMap)(t=>t.value.onDataChanged)).subscribe(f);this.subs.push(b);let w=e.functions.onAfterRunAction.pipe((0,l.filter)(t=>h.view.funcCall&&t&&!!t.id&&h.view.funcCall.id===t.id),(0,l.withLatestFrom)(h.visibility,h.ability),(0,l.filter)(t=>{let e=n2(t,3),n=e[1],i=e[2];return n!==v.HIDDEN&&i!==y.DISABLED})).subscribe(()=>{let t=Object.values(this.steps).find(t=>t.idx>h.idx&&t.visibility.value===v.VISIBLE&&t.ability.value===y.ENABLED)?null:Object.values(this.steps).find(t=>t.idx>h.idx&&t.visibility.value===v.VISIBLE&&t.ability.value===y.DISABLED);null==t||t.ability.next(y.ENABLED)});return this.subs.push(w),yield this.onAfterStepFuncCallApply(t.stepScript.nqName,a,c),c}).call(this)),p=yield Promise.all(d),h=(0,s.combineLatest)(p.map(t=>t.isHistorical)).subscribe(t=>{t.some((t,e)=>{var n;return!t&&(null==(n=Object.values(this.steps).find(t=>t.idx===e))?void 0:n.visibility.value)===v.VISIBLE})&&this.isHistorical.value&&this.isHistorical.next(!1)});this.subs.push(h);let f=this.isUpdating.subscribe(t=>{var e=!0,n=!1,i=void 0;try{for(var r,o=Object.values(this.steps)[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){let e=r.value.view;(null==e?void 0:e.blockRuns)&&e.blockRuns.next(t)}}catch(t){n=!0,i=t}finally{try{e||null==o.return||o.return()}finally{if(n)throw i}}});this.subs.push(f),yield this.onFuncCallReady(),this.isReady.next(!0),this.loadHelp().then(()=>{this.buildRibbonPanels();let t=()=>{let t=this.findCurrentStep();t&&this.helpFiles[t.func.nqName]&&"opened"===this.getHelpState()&&this.showHelpWithDelay(t)},n=e.events.onCurrentViewChanged.pipe((0,l.filter)(()=>e.shell.v==this)).subscribe(t);t(),this.subs.push(n)})}).call(this)}loadHelp(){return n1(function*(){return Promise.all(Object.values(this.steps).map(t=>n1(function*(){var n,i,r,o;let s=null!=(n=null==(i=t.options)?void 0:i.helpUrl)?n:t.func.options.help;if(s){let n=`System:AppData/${this.func.package.name}/${s}`,i=(yield e.dapi.files.exists(n))?yield e.dapi.files.readAsText(n):yield t.view.getContextHelp();i&&(this.helpFiles[null!=(r=null==(o=t.options)?void 0:o.customId)?r:t.func.nqName]=i)}}).call(this)))}).call(this)}syncNavButtons(t,e,n){let i,r;n.addEventListener("click",()=>{i&&(this.currentTabName=n5(i))}),e.addEventListener("click",()=>{r&&(this.currentTabName=n5(r))});let o=this.getPipelineStateChanges().pipe((0,l.startWith)(!0),(0,l.debounceTime)(0)).subscribe(()=>{i=this.getNextStep(t),r=this.getPreviousStep(t),i?(C()(n).show(),i.ability.value===y.DISABLED&&C()(n).addClass("d4-disabled"),i.ability.value===y.ENABLED&&C()(n).removeClass("d4-disabled")):C()(n).hide(),r?(C()(e).show(),r.ability.value===y.DISABLED&&C()(e).addClass("d4-disabled"),r.ability.value===y.ENABLED&&C()(e).removeClass("d4-disabled")):C()(e).hide()});this.subs.push(o)}getPreviousStep(t){return Object.values(this.steps).slice().reverse().find(e=>e.idx<t.idx&&e.visibility.value===v.VISIBLE)}getNextStep(t){return Object.values(this.steps).find(e=>e.idx>t.idx&&e.visibility.value===v.VISIBLE)}getPipelineStateChanges(){let t=Object.values(this.steps).flatMap(t=>[t.ability,t.visibility]);return(0,s.merge)(...t).pipe((0,l.mapTo)(!0))}onComparisonLaunch(t){return n1(function*(){let n=e.shell.v.parentCall,i=yield Promise.all(t.map(t=>f.loadChildRuns(t.id))),r=yield Promise.all(i.map(t=>{var e;return null!=(e=t.childRuns.find(t=>"true"===t.func.options.isMain))?e:t.childRuns.find(t=>t.func.nqName===this.initialConfig[this.initialConfig.length-1].funcName)}).map(t=>f.loadRun(t.id))),o=[...e.shell.views].find(t=>t.type===T),s=yield tV.fromComparedRuns(r,r[0].func,{parentView:o,parentCall:n});e.shell.addView(s)}).call(this)}onBeforeStepFuncCallApply(t,e,n){return n1(function*(){})()}onAfterStepFuncCallApply(t,e,n){return n1(function*(){})()}buildIO(){let t=Object.values(this.steps).reduce((t,e)=>{var n,i;return n=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}({},t),i=i={[n5(e)]:e.view.root},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(i)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(i,t))}),n},{}),e=r.tabControl(t),n=Object.values(this.steps).map(t=>{let n=r.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(n5(t)).header.appendChild(n),t.view.consistencyState.subscribe(t=>{"consistent"===t&&C()(n).hide(),"inconsistent"===t&&C()(n).show()})});this.subs.push(...n);let i=Object.values(this.steps).map(t=>t.view.consistencyState),o=(0,s.merge)(...i).subscribe(()=>{i.map(t=>t.value).some(t=>"inconsistent"===t)?this.consistencyState.next("inconsistent"):this.consistencyState.next("consistent")});this.subs.push(o);let l=e.panes[0].header.parentElement;l.classList.add("d4-ribbon","pipeline-view"),l.classList.remove("d4-tab-header-stripe"),l.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=>{let e=n3(t);this.subs.push(this.steps[e].visibility.subscribe(t=>{t===v.VISIBLE&&C()(this.stepTabs.getPane(n5(this.steps[e])).header).css("display","inherit"),t===v.HIDDEN&&C()(this.stepTabs.getPane(n5(this.steps[e])).header).hide()}))}),Object.values(this.steps).forEach(t=>{this.subs.push(t.ability.subscribe(e=>{e===y.ENABLED&&C()(this.stepTabs.getPane(n5(t)).header).removeClass("d4-disabled"),e===y.DISABLED&&C()(this.stepTabs.getPane(n5(t)).header).addClass("d4-disabled")}))}),this.hideSteps(...this.initialConfig.filter(t=>t.hiddenOnInit===v.HIDDEN).map(t=>t.funcName)),e.root}showHelpWithDelay(t){return n1(function*(){let n;n=this.helpFiles[t.func.nqName],ew(function*(){e.shell.windows.help.visible=!0,yield new Promise(t=>setTimeout(t,100)),e.shell.windows.help.showHelp(r.markdown(n))})()}).call(this)}findCurrentStep(){return Object.values(this.steps).find(t=>n5(t)===this.stepTabs.currentPane.name)}buildHistoryBlock(){let t=super.buildHistoryBlock(),n=this.historyBlock.afterRunDeleted.subscribe(t=>n1(function*(){(yield e.dapi.functions.calls.allPackageVersions().filter(`options.parentCallId="${t.id}"`).list()).map(t=>n1(function*(){return f.deleteRun(t)})())})());return this.subs.push(n),t}getHelpState(){return"closed"===e.userSettings.getValue(B,`${this.func.name}_help_state`)?"closed":"opened"}saveHelpState(t){e.userSettings.add(B,`${this.func.name}_help_state`,t)}buildRibbonPanels(){let t=r.iconFA("info",()=>n1(function*(){let t=this.findCurrentStep();t&&this.helpFiles[t.func.nqName]&&(yield this.showHelpWithDelay(t),this.saveHelpState("opened"))}).call(this),"Show help for this step"),n=()=>{let n=this.findCurrentStep();r.setDisplay(t,!!(n&&this.helpFiles[n.func.nqName])),n&&this.helpFiles[n.func.nqName]&&e.shell.windows.help.visible&&this.showHelpWithDelay(n),this.setRibbonPanels([...this.getRibbonPanels().slice(0,1),...n?n.view.buildRibbonPanels():[],...this.getRibbonPanels().length>2?this.getRibbonPanels().slice(-1):[]])};if(!this.isReady.value){let t=this.stepTabs.onTabChanged.subscribe(n),i=e.events.onEvent("grok-panels-changed").pipe((0,l.filter)(()=>e.shell.v===this)).subscribe(()=>n1(function*(){let t=yield this.getHelpState();if(e.shell.windows.help.visible&&"closed"===t)return void this.saveHelpState("opened");if(!e.shell.windows.help.visible&&"opened"===t){let t=r.iconFA("info");C()(t).css("margin","0px 3px"),e.shell.info(r.span(["You can open help panel by clicking the",t,"button on the ribbon menu"])),this.saveHelpState("closed");return}}).call(this));this.subs.push(t,i)}let i=this.findCurrentStep(),o=[[...super.buildRibbonPanels().flat(),t],...i?i.view.buildRibbonPanels():[]];return this.setRibbonPanels(o),n(),o}saveRun(t){return n1(function*(){let e=th(t);yield this.onBeforeSaveRun(e),tp(e)&&(e=yield eI(t)),e.newId();let n=Object.values(this.steps).filter(t=>t.visibility.value===v.VISIBLE).map(t=>n1(function*(){var n,i;let r=t.view.funcCall;return r.options.parentCallId=e.id,(null==(n=t.options)?void 0:n.customId)&&(r.options.customId=null==(i=t.options)?void 0:i.customId),yield t.view.saveRun(r),Promise.resolve()})());yield Promise.all(n),e.options.title&&(e.options.title=`${e.options.title} (copy)`);let i=yield f.saveRun(e),r=yield f.loadRun(i.id);return this.options.historyEnabled&&this.isHistoryEnabled&&this.historyBlock&&this.historyBlock.addRun((yield f.loadRun(i.id))),this.linkFunccall(r),this.isHistorical.next(!0),yield this.onAfterSaveRun(e),i}).call(this)}loadRun(t){return n1(function*(){let e=yield f.loadChildRuns(t),n=e.parentRun,i=e.childRuns,r=Object.values(this.steps).filter(t=>t.visibility.value===v.VISIBLE).findIndex(t=>n5(t)===this.stepTabs.currentPane.name);yield this.onBeforeLoadRun();var o=!0,s=!1,l=void 0;try{for(var a,u=Object.values(this.steps)[Symbol.iterator]();!(o=(a=u.next()).done);o=!0){let t=a.value,e=i.filter(e=>e.func.nqName===t.func.nqName);if(0===e.length&&(t.visibility.next(v.HIDDEN),t.ability.next(y.DISABLED)),1===e.length&&(yield t.view.loadRun(e[0].id),t.visibility.next(v.VISIBLE),tp(e[0])?t.ability.next(y.DISABLED):t.ability.next(y.ENABLED)),e.length>1){let n=e.find(e=>{var n;return e.options.customId===(null==(n=t.options)?void 0:n.customId)});yield t.view.loadRun(n.id),t.visibility.next(v.VISIBLE),tp(n)?t.ability.next(y.DISABLED):t.ability.next(y.ENABLED)}}}catch(t){s=!0,l=t}finally{try{o||null==u.return||u.return()}finally{if(s)throw l}}let c=Object.values(this.steps).find(t=>t.ability.value===y.DISABLED&&t.visibility.value===v.VISIBLE),d=null!=c?c:Object.values(this.steps)[0];if(d.ability.next(y.ENABLED),c){let t=this.getNextStep(c);for(;t;)t.ability.next(y.DISABLED),t=this.getNextStep(t)}this.lastCall=n,this.linkFunccall(n),this.isHistorical.next(!0);let p=Object.values(this.steps).filter(t=>t.visibility.value==v.VISIBLE).at(r);return p&&p.ability.value===y.ENABLED?this.currentTabName=n5(p):this.currentTabName=n5(d),yield this.onAfterLoadRun(n),n}).call(this)}hideSteps(...t){return n1(function*(){t.forEach(t=>{this.steps[t].visibility.next(v.HIDDEN)})}).call(this)}showSteps(...t){return n1(function*(){t.forEach(t=>{this.steps[t].visibility.next(v.VISIBLE)})}).call(this)}exportRunJson(){return n1(function*(){if(this._lastCall){let o={isPipeline:!0};var t=!0,e=!1,n=void 0;try{for(var i,r=Object.entries(this.steps)[Symbol.iterator]();!(t=(i=r.next()).done);t=!0){let t=n2(i.value,2),e=t[0],n=t[1],r=n.view.lastCall;r&&(o[e]=yield eE(r,n.view))}}catch(t){e=!0,n=t}finally{try{t||null==r.return||r.return()}finally{if(e)throw n}}return tr(o)}}).call(this)}getStepViewRuns(t){return this.onStepCompleted.pipe((0,l.filter)(e=>e.func.nqName===t),(0,l.map)(()=>this.getStepView(t)))}constructor(t,e,n){var i;super(t,void 0===n?{historyEnabled:!0,isTabbed:!1,skipInit:!1}:n),i=this,this.initialConfig=e,this.steps={},this.onStepCompleted=new s.Subject,this.isUpdating=new s.BehaviorSubject(!1),this.pipelineViewExportExtensions=()=>({Archive:"zip","Single Excel":"xlsx"}),this.pipelineViewExportFormats=()=>["Archive","Single Excel"],this.pipelineViewExport=t=>n1(function*(){if(!i.stepTabs)throw Error("Set step tabs please for export");if("Archive"===t){let t={};var e=!0,n=!1,r=void 0;try{for(var s,l=Object.values(i.steps).filter(t=>t.visibility.value===v.VISIBLE)[Symbol.iterator]();!(e=(s=l.next()).done);e=!0){let e=s.value;i.stepTabs.currentPane=i.stepTabs.getPane(n5(e)),yield new Promise(t=>setTimeout(t,100));let n=yield e.view.exportConfig.export("Excel");t[e.view.exportConfig.filename("Excel")]=[new Uint8Array((yield n.arrayBuffer())),{level:0}]}}catch(t){n=!0,r=t}finally{try{e||null==l.return||l.return()}finally{if(n)throw r}}return new Blob([function(t,e){e||(e={});var n={},i=[];nW(t,"",n,e);var r=0,o=0;for(var s in n){var l=n[s],a=l[0],u=l[1],c=8*(0!=u.level),d=nq(s),p=d.length,h=u.comment,f=h&&nq(h),m=f&&f.length,v=nJ(u.extra);p>65535&&nT(11);var y=c?function(t,e){var n;return nN(t,null==(n=e||{}).level?6:n.level,null==n.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+n.mem,0,0,!0)}(a,u):a,g=y.length,b=nU();b.p(a),i.push(nH(u,{size:a.length,crc:b.d(),c:y,f:d,m:f,u:p!=s.length||f&&h.length!=m,o:r,compression:c})),r+=30+p+v+g,o+=76+2*(p+v)+(m||0)+g}for(var C=new no(o+22),w=r,A=o-r,x=0;x<i.length;++x){var d=i[x];nz(C,d.o,d,d.f,d.u,d.c.length);var I=30+d.f.length+nJ(d.extra);C.set(d.c,d.o+I),nz(C,r,d,d.f,d.u,d.c.length,d.o,d.m),r+=16+I+(d.m?d.m.length:0)}return nK(C,r,i.length,A,w),C}(t)])}if("Single Excel"===t){yield o.Utils.loadJsCss(["/js/common/exceljs.min.js"]);let t=window.ExcelJS,e=new t.Workbook,n=(t,e,n)=>{let i=`${n5(n)}>${e}`;i.length>31&&(i=`${i.slice(0,31)}`);let r=2;for(;t.worksheets.some(t=>t.name.toLowerCase()===i.toLowerCase());){let t=`${n5(n)}>${e}`;t.length>31-`-${r}`.length&&(t=`${t.slice(0,31-`-${r}`.length)}`),i=`${t}-${r}`,r++}return i};var a=!0,u=!1,c=void 0;try{for(var d,p=Object.values(i.steps).filter(t=>t.visibility.value===v.VISIBLE)[Symbol.iterator]();!(a=(d=p.next()).done);a=!0){let r=d.value,o=new t.Workbook;i.stepTabs.currentPane=i.stepTabs.getPane(n5(r)),yield new Promise(t=>setTimeout(t,100)),yield o.xlsx.load((yield(yield r.view.exportConfig.export("Excel")).arrayBuffer())),o.eachSheet(t=>{let i=n(e,t.name,r),s=e.addWorksheet("New sheet");s.model=t.model,s.name=i,t.getImages().forEach(t=>{let n=e.addImage(o.getImage(t.imageId));s.addImage(n,t.range)})})}}catch(t){u=!0,c=t}finally{try{a||null==p.return||p.return()}finally{if(u)throw c}}return new Blob([(yield e.xlsx.writeBuffer())],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"})}throw Error("This format is not supported")})(),this.exportConfig={supportedExtensions:this.pipelineViewExportExtensions(),supportedFormats:this.pipelineViewExportFormats(),export:this.pipelineViewExport,filename:this.defaultExportFilename},this.helpFiles={}}},iV=ec,iB=eu,ik=eh,iD=ed,iL=b.fileInput,ij=b.historyInput,iM=b.historyInputJSON,iN=b.historyPanel;class i_{static init(){return iA(function*(){})()}static openModelFromFuncall(t){n8.openModelFromFunccall(t)}static OutliersSelection(){return new w}static RichFunctionViewEditor(t){return nr.fromFuncCall(t,{historyEnabled:!0,isTabbed:!1})}static PipelineStepEditor(t){return nr.fromFuncCall(t,{historyEnabled:!1,isTabbed:!0})}static CustomDataUploader(t){return iA(function*(){return yield new Promise(t=>setTimeout(t,1e3)),[(yield t.prepare({ambTemp:22,initTemp:100,desiredTemp:30,area:.06,heatCap:4200,heatTransferCoeff:8.3,simTime:21600}).call())]})()}static CustomUploader(t){return iA(function*(){let n=(yield e.functions.eval("Compute:CustomDataUploader")).prepare({func:t.func}),i=r.bigButton("Click me to get mock calls",()=>n.call()),s=o.Widget.fromRoot(r.panel([r.divV([r.label("This part of dialog comes from my custom data uploader"),r.divH([i],{style:{justifyContent:"center"}})])])),a=e.functions.onBeforeRunAction.pipe((0,l.filter)(t=>t.id===n.id)).subscribe(()=>{r.setUpdateIndicator(i,!0)}),u=e.functions.onAfterRunAction.pipe((0,l.filter)(t=>t.id===n.id)).subscribe(()=>{r.setUpdateIndicator(i,!1)});return s.subs.push(a,u),{uploadWidget:s,uploadFuncCall:n}})()}static CustomCustomizer(t){t.defaultView.scatterPlot({xColumnName:"Initial temperature",yColumnName:"Time to cool"})}static SimTimeValidator(t){let{reasonableMin:e,reasonableMax:n}=t;return t=>ec({warnings:t<e||t>n?[`Minimum reasonable time is ${e}. Maximum reasonable time is ${n}`]:void 0,errors:t<0?["Time should be strictly positive"]:void 0})}static DesiredTempValidator(t){return(t,e)=>{let n=e.funcCall.inputs.ambTemp,i=e.funcCall.inputs.initTemp;return ec({errors:[...t<n?[eu(`Desired temperature cannot be less than ambient temperature (${n}).
|
|
170
|
-
`,[{actionName:"Set desired equal to ambient",action:()=>e.funcCall.inputs.desiredTemp=n}])]:[],...t>i?[`Desired temperature cannot be higher than initial temperature (${i})`]:[]]})}}static InitialTempValidator(t){return(t,e)=>{let n=e.funcCall.inputs.ambTemp;return
|
|
168
|
+
}`,"",{version:3,sources:["webpack://./../../libraries/compute-utils/dist/old-views/css/rich-function-view.css"],names:[],mappings:"AAAA;IACI,eAAe;IACf,gBAAgB;IAChB,uBAAuB;AAC3B;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,mBAAmB;IACnB,yBAAyB;AAC7B;;AAEA,oCAAoC;AACpC;;;;IAII,aAAa;AACjB;;AAEA,mDAAmD;AACnD;IACI,gBAAgB;AACpB;;AAEA,+DAA+D;AAC/D;IACI,gBAAgB;AACpB;;AAEA,+CAA+C;AAC/C;IACI,aAAa;AACjB;AACA;IACI,gBAAgB;AACpB;AACA;IACI,aAAa;AACjB;AACA;IACI,gBAAgB;AACpB;;AAEA;IACI,2BAA2B;AAC/B;;AAEA;IACI,QAAQ;IACR,yBAAyB;AAC7B;;AAEA;IACI,2BAA2B;AAC/B;;AAEA;IACI,yBAAyB;IACzB,YAAY;AAChB;;AAEA;IACI,kBAAkB;IAClB,mBAAmB;AACvB;;AAEA;IACI,gBAAgB;IAChB,uCAAuC;AAC3C;;AAEA;IACI,+BAA+B;AACnC;;AAEA;IACI,WAAW;AACf",sourcesContent:[".ui-form .ui-input-root.ui-input-buttons.rfv-buttons {\n margin-top: 0px;\n position: sticky;\n align-items: flex-start;\n}\n\n.ui-form .ui-input-buttons.rfv-buttons .ui-input-editor {\n flex-wrap: wrap;\n}\n\n.ui-input-root.rfv-restricted-input.d4-disabled {\n pointer-events: all;\n cursor: pointer!important;\n}\n\n/* Hide all state icons by default */\n.ui-input-root > .ui-input-options .rfv-icon-lock,\n.ui-input-root > .ui-input-options .rfv-icon-unlock,\n.ui-input-root > .ui-input-options .rfv-icon-undo,\n.ui-input-root > .ui-input-options .rfv-icon-warning {\n display: none;\n}\n\n/* Show warning icon if input is on warning state */\n.ui-input-root.rfv-inconsistent-input > .ui-input-options .rfv-icon-warning {\n display: inherit;\n}\n\n/* Show undo icon if input is on inconstent state and hovered */\n.ui-input-root.rfv-restricted-unlocked-input:hover .rfv-icon-undo, .ui-input-root.rfv-inconsistent-input:hover .rfv-icon-undo {\n display: inherit;\n}\n\n/* Show/hide lock-unlock icons on input hover */\n.ui-input-root.rfv-restricted-input:hover .rfv-icon-lock {\n display: none;\n}\n.ui-input-root.rfv-restricted-input .rfv-icon-lock {\n display: inherit;\n}\n.ui-input-root.rfv-restricted-input .rfv-icon-unlock {\n display: none;\n}\n.ui-input-root.rfv-restricted-input:hover .rfv-icon-unlock {\n display: inherit;\n}\n\n.ui-form-condensed .rfv-buttons > .ui-label {\n margin-right: 0px!important;\n}\n\n.rfv-form .ui-form .rfv-buttons > .ui-input-editor {\n gap: 5px;\n justify-content: flex-end;\n}\n\ndiv.ui-box > div.ui-box.rfv-form > div.ui-div {\n overflow: visible!important;\n}\n\n.rfv-scalar-table {\n border-collapse: collapse;\n margin: 10px;\n}\n\n.rfv-scalar-table td {\n width: max-content;\n white-space: nowrap;\n}\n\n.rfv-scalar-table tr{\n min-height: 30px;\n border-bottom: 1pt solid var(--grey-12);\n}\n\n.rfv-scalar-table tr:nth-child(odd) {\n background-color: var(--grey-1);\n}\n\n.rfv-scalar-table td:last-child {\n width: 100%;\n}"],sourceRoot:""}]);let l=s},454(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,r,o){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(i)for(var l=0;l<this.length;l++){var a=this[l][0];null!=a&&(s[a]=!0)}for(var u=0;u<t.length;u++){var c=[].concat(t[u]);i&&s[c[0]]||(void 0!==o&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=o),n&&(c[2]&&(c[1]="@media ".concat(c[2]," {").concat(c[1],"}")),c[2]=n),r&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=r):c[4]="".concat(r)),e.push(c))}},e}},126(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))));return[e].concat(["/*# ".concat("sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i)," */")]).join("\n")}return[e].join("\n")}},474(t){t.exports=function(){"use strict";var t="minute",e=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(i,r,o){var s=r.prototype;o.utc=function(t){var e={date:t,utc:!0,args:arguments};return new r(e)},s.utc=function(e){var n=o(this.toDate(),{locale:this.$L,utc:!0});return e?n.add(this.utcOffset(),t):n},s.local=function(){return o(this.toDate(),{locale:this.$L,utc:!1})};var l=s.parse;s.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),l.call(this,t)};var a=s.init;s.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 a.call(this)};var u=s.utcOffset;s.utcOffset=function(i,r){var o=this.$utils().u;if(o(i))return this.$u?0:o(this.$offset)?u.call(this):this.$offset;if("string"==typeof i&&null===(i=function(t){void 0===t&&(t="");var i=t.match(e);if(!i)return null;var r=(""+i[0]).match(n)||["-",0,0],o=r[0],s=60*r[1]+ +r[2];return 0===s?0:"+"===o?s:-s}(i)))return this;var s=16>=Math.abs(i)?60*i:i;if(0===s)return this.utc(r);var l=this.clone();if(r)return l.$offset=s,l.$u=!1,l;var a=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(l=this.local().add(s+a,t)).$offset=s,l.$x.$localOffset=a,l};var c=s.format;s.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return c.call(this,e)},s.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},s.isUTC=function(){return!!this.$u},s.toISOString=function(){return this.toDate().toISOString()},s.toString=function(){return this.toDate().toUTCString()};var d=s.toDate;s.toDate=function(t){return"s"===t&&this.$offset?o(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():d.call(this)};var p=s.diff;s.diff=function(t,e,n){if(t&&this.$u===t.$u)return p.call(this,t,e,n);var i=this.local(),r=o(t).local();return p.call(i,r,e,n)}}}()},2(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 r={},o=[],s=0;s<t.length;s++){var l=t[s],a=i.base?l[0]+i.base:l[0],u=r[a]||0,c="".concat(a," ").concat(u);r[a]=u+1;var d=n(c),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(p);else{var h=function(t,e){var n=e.domAPI(e);return n.update(t),function(e){e?(e.css!==t.css||e.media!==t.media||e.sourceMap!==t.sourceMap||e.supports!==t.supports||e.layer!==t.layer)&&n.update(t=e):n.remove()}}(p,i);i.byIndex=s,e.splice(s,0,{identifier:c,updater:h,references:1})}o.push(c)}return o}t.exports=function(t,r){var o=i(t=t||[],r=r||{});return function(t){t=t||[];for(var s=0;s<o.length;s++){var l=n(o[s]);e[l].references--}for(var a=i(t,r),u=0;u<o.length;u++){var c=n(o[u]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}o=a}}},129(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 Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},838(t){"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},986(t,e,n){"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},611(t){"use strict";t.exports=function(t){if("u"<typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){var i,r,o;i="",n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {")),(r=void 0!==n.layer)&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,r&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}"),(o=n.sourceMap)&&"u">typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),t.styleTagTransform(i,e,t.options)},remove:function(){var t;null===(t=e).parentNode||t.parentNode.removeChild(t)}}}},515(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))}}}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={id:i,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(t){if("object"==typeof window)return window}})(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nc=void 0;var i={};(()=>{"use strict";let t;n.r(i),n.d(i,{ObjectCoolingSelector:()=>iR,CustomInputMock:()=>iT,RichFunctionViewEditor:()=>iv,makeValidationResult:()=>i$,mergeValidationResults:()=>iG,CompView:()=>i_,PipelineStepEditor:()=>iy,GlobalValidatorDemoFactory:()=>iF,historyPanel:()=>iK,CustomCustomizer:()=>iw,init:()=>ip,makeAdvice:()=>iW,HeatCapValidator:()=>iE,CustomStringInput:()=>iS,RangeValidatorFactory:()=>iO,deepCopy:()=>iN,DesiredTempValidator:()=>iA,CustomUploader:()=>ib,fileInput:()=>iq,openModelFromFuncall:()=>ih,CustomDataUploader:()=>ig,AsyncValidatorDemoFactory:()=>iP,AmbTempValidator:()=>iI,SimTimeValidator:()=>iC,RFV:()=>iU,OutliersSelection:()=>im,Pipeline:()=>iH,historyInputJSON:()=>iz,InitialTempValidator:()=>ix,historyInput:()=>iJ,_package:()=>iL,PackageFunctions:()=>iZ,makeRevalidation:()=>iY});let e=grok,r=ui,o=DG,s=rxjs,l=rxjs.operators,a=$;var u,c,d,p,h,f,m,v,y,g,b,w=n.n(a);class C extends o.JsViewer{onFrameAttached(t){this.render()}onTableAttached(){this.render()}render(){if(!this.dataFrame||this.dataFrame.rowCount<=0){this.root.innerHTML="";return}let t=this.dataFrame,n="isOutlier",i="isOutlierSecondary",s="Rationale",l="Count",a="isConfirmed";t.columns.byName(n)||t.columns.add(o.Column.fromList(o.TYPE.STRING,n,Array(t.rowCount).fill("Inlier"))),t.columns.byName(i)||t.columns.add(o.Column.fromList(o.TYPE.STRING,i,Array(t.rowCount).fill("Inlier"))),t.columns.byName(s)||t.columns.add(o.Column.fromStrings(s,Array.from({length:t.rowCount},()=>"")));let u=()=>o.DataFrame.fromColumns([o.Column.fromStrings(s,[]),o.Column.fromInt32Array(l,new Int32Array([])),o.Column.fromStrings("Actions",[]),o.Column.fromBitSet(a,o.BitSet.create(0,()=>!1))]),c=o.Viewer.grid(u());c.root.style.width="100%",c.root.style.minWidth="230px",c.columns.setVisible([s,l,"Actions"]),this.root.append(r.divV([r.divV([c.root],{style:{height:"75%"}})],{style:{height:"100%"}}));let d=()=>{var e,r,l,a,u,d,p;if(!c.dataFrame)return;null==(e=t.col(n))||e.meta.markers.assign("Outlier",o.MARKER_TYPE.OUTLIER),null==(r=t.col(n))||r.meta.markers.assign("Last Inlier",o.MARKER_TYPE.STAR),null==(l=t.col(n))||l.meta.colors.setCategorical({Outlier:o.Color.scatterPlotMarker,Inlier:o.Color.scatterPlotMarker,"Last Inlier":o.Color.red}),null==(a=t.col(i))||a.meta.markers.assign("Outlier",o.MARKER_TYPE.OUTLIER),null==(u=t.col(i))||u.meta.markers.assign("Last Inlier",o.MARKER_TYPE.STAR),null==(d=t.col(i))||d.meta.colors.setCategorical({Outlier:o.Color.cyan,Inlier:o.Color.cyan,"Last Inlier":o.Color.red});let h=null==(p=c.dataFrame)?void 0:p.cell(c.dataFrame.rowCount-1,s).value;t.selection.getSelectedIndexes().forEach(e=>{t.col(n).set(e,"Outlier",!1),t.col(i).set(e,"Outlier",!1),t.col(s).set(e,h,!1)}),t.selection.setAll(!1),t.fireValuesChanged(),w()(document.querySelector(".d4-balloon-container")).empty()},p=()=>{c.dataFrame&&(c.dataFrame.rows.removeAt(c.dataFrame.rowCount-1),t.selection.setAll(!1),w()(document.querySelector(".d4-balloon-container")).empty())};c.onCellPrepare(e=>{if(e.isTableCell&&"Actions"===e.gridColumn.name){var o,l;let u;e.gridColumn.cellType="html",e.style.element=r.divH([...(null==(o=e.grid.dataFrame)?void 0:o.get(a,e.gridRow))?[(u=null==(l=e.grid.dataFrame)?void 0:l.get(s,e.gridRow),r.div(r.icons.delete(()=>{for(let e=0;e<t.rowCount;e++)t.columns.byName(s).get(e)===u&&(t.columns.byName(s).set(e,"",!1),t.columns.byName(n).set(e,"Inlier",!1),t.columns.byName(i).set(e,"Inlier",!1));t.fireValuesChanged()},"Remove the outliers group"),{style:{textAlign:"center",margin:"6px"}}))]:[r.div(r.iconFA("check",d,"Confirm the outliers"),{style:{textAlign:"center",margin:"6px"}}),r.div(r.iconFA("times",p,"Cancel the outliers"),{style:{textAlign:"center",margin:"6px"}})]])}}),c.onCellValueEdited.subscribe(e=>{var n,i;if(!c.dataFrame||e.gridColumn.name!==s||!c.dataFrame.columns.byName(a).get(e.gridRow))return;let r=new Set;for(let t=0;t<(null==(n=c.dataFrame)?void 0:n.rowCount);t++){let e=null==(i=c.dataFrame)?void 0:i.columns.byName(s).get(t);r.add(e)}for(let n=0;n<t.rowCount;n++){let i=t.columns.byName(s).get(n);""==i||r.has(i)||t.columns.byName(s).set(n,e.cell.value)}});let h=()=>{if(t.columns.byName(s))for(let e=0;e<t.rowCount;e++)"Outlier"===t.columns.byName(n).get(e)?""===t.columns.byName(s).get(e)&&t.columns.byName(s).set(e,"Manual",!1):""!==t.columns.byName(s).get(e)&&t.columns.byName(s).set(e,"",!1);let e={};if(t.columns.byName(s))for(let n=0;n<t.rowCount;n++){let i=t.columns.byName(s).get(n),r=e[i];""!=i&&(r?e[i]++:e[i]=1)}c.dataFrame=u(),c.columns.setVisible([s,l,"Actions"]),Object.keys(e).map(t=>{var n;null==(n=c.dataFrame)||n.rows.addNew([t,e[t],"",!0])})};t.onDataChanged.subscribe(h),t.onSelectionChanged.subscribe(()=>{if(!c.dataFrame||!t.selection.trueCount)return;let n=document.querySelector(".d4-balloon-container");if((!n||w()(n).is(":empty"))&&e.shell.info(r.div([r.divText("Confirm selected points as outliers?"),r.divH([r.bigButton("Confirm",d),r.button("Cancel",p)])])),c.dataFrame.columns.byName(a).toList().some(t=>!1===t))c.dataFrame.set(l,c.dataFrame.rowCount-1,t.selection.trueCount);else{let e=c.dataFrame.rows.addNew(["Manual",t.selection.trueCount,"",!1]);c.dataFrame.currentCell=c.dataFrame.cell(e.idx,s)}}),t.selection.setAll(!1),h()}constructor(){super()}}let A=dayjs;var x=n.n(A);let I=wu;var E=n.n(I);let S={barchart:o.VIEWER.BAR_CHART,boxplot:o.VIEWER.BOX_PLOT,calendar:o.VIEWER.CALENDAR,corrplot:o.VIEWER.CORR_PLOT,densityplot:o.VIEWER.DENSITY_PLOT,filters:o.VIEWER.FILTERS,form:o.VIEWER.FORM,globe:o.VIEWER.GLOBE,googlemap:o.VIEWER.GOOGLE_MAP,grid:o.VIEWER.GRID,heatmap:o.VIEWER.HEAT_MAP,histogram:o.VIEWER.HISTOGRAM,linechart:o.VIEWER.LINE_CHART,markup:o.VIEWER.MARKUP,matrixplot:o.VIEWER.MATRIX_PLOT,networkdiagram:o.VIEWER.NETWORK_DIAGRAM,pcplot:o.VIEWER.PC_PLOT,piechart:o.VIEWER.PIE_CHART,scatterplot:o.VIEWER.SCATTER_PLOT,"3dscatterplot":o.VIEWER.SCATTER_PLOT_3D,shapemap:o.VIEWER.SHAPE_MAP,statistics:o.VIEWER.STATISTICS,tileviewer:o.VIEWER.TILE_VIEWER,timelines:o.VIEWER.TIMELINES,treemap:o.VIEWER.TREE_MAP,trellisplot:o.VIEWER.TRELLIS_PLOT,wordcloud:o.VIEWER.WORD_CLOUD,diffstudiofacet:"DiffStudio Facet"},R="JsCardView",T="viewer",O="Run name",P="RunId";function F(t,e){try{return JSON.parse(t,null==e?void 0:e.reviver)}catch(n){return(null==e?void 0:e.warning)&&console.warn(`${e.warning}: malformed JSON: ${t}`,n),null}}"u">typeof window?window:n.g.window,new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),"function"==typeof TextDecoder&&new TextDecoder("utf-8",{ignoreBOM:!0}),"function"==typeof TextEncoder&&new TextEncoder;let V=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),B=(t={},V.forEach((e,n)=>t[e]=n),t),D=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,k=String.fromCharCode.bind(String),j="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):t=>new Uint8Array(Array.prototype.slice.call(t,0)),L="function"==typeof btoa?t=>btoa(t):t=>{let e,n,i,r,o="",s=t.length%3;for(let s=0;s<t.length;){if((n=t.charCodeAt(s++))>255||(i=t.charCodeAt(s++))>255||(r=t.charCodeAt(s++))>255)throw TypeError("invalid character found");o+=V[(e=n<<16|i<<8|r)>>18&63]+V[e>>12&63]+V[e>>6&63]+V[63&e]}return s?o.slice(0,s-3)+"===".substring(s):o},M="function"==typeof Uint8Array.prototype.toBase64?t=>t.toBase64():t=>{let e=[];for(let n=0,i=t.length;n<i;n+=4096)e.push(k.apply(null,t.subarray(n,n+4096)));return L(e.join(""))},N=(t,e=!1)=>e?M(t).replace(/=/g,"").replace(/[+\/]/g,t=>"+"==t?"-":"_"):M(t),_="function"==typeof atob?t=>atob(t.replace(/[^A-Za-z0-9\+\/]/g,"")):t=>{let e,n,i;if(t=t.replace(/\s+/g,""),!D.test(t))throw TypeError("malformed base64.");t+="==".slice(2-(3&t.length));let r=[];for(let o=0;o<t.length;)e=B[t.charAt(o++)]<<18|B[t.charAt(o++)]<<12|(n=B[t.charAt(o++)])<<6|(i=B[t.charAt(o++)]),64===n?r.push(k(e>>16&255)):64===i?r.push(k(e>>16&255,e>>8&255)):r.push(k(e>>16&255,e>>8&255,255&e));return r.join("")},U="function"==typeof Uint8Array.fromBase64?t=>Uint8Array.fromBase64(t):t=>j(_(t).split("").map(t=>t.charCodeAt(0))),H=t=>t.replace(/[-_]/g,t=>"-"==t?"+":"/").replace(/[^A-Za-z0-9\+\/]/g,""),W="_DG_CUSTOM_SERIALIZED_TOKEN_";function Y(t,e){let n=void 0===e?{}:e;return JSON.stringify(t,function(t,e){return e===1/0?{[W]:"Infinity",value:!0}:e===-1/0?{[W]:"-Infinity",value:!0}:Number.isNaN(e)?{[W]:"NaN",value:!0}:e instanceof o.DataFrame&&!n.useJsonDF?{[W]:"DataFrame",value:N(e.toByteArray())}:e instanceof o.DataFrame&&n.useJsonDF?{[W]:"DataFrameJSON",value:e.toJson()}:e instanceof ArrayBuffer?{[W]:"ArrayBuffer",value:N(new Uint8Array(e))}:e instanceof Map?{[W]:"Map",value:Array.from(e)}:e instanceof Set?{[W]:"Set",value:Array.from(e)}:x().isDayjs(this[t])?{[W]:"DayJs",value:this[t].toISOString()}:e},n.space)}function G(t,e){if(e&&e[W]&&e.value)switch(e[W]){case"DataFrame":return o.DataFrame.fromByteArray(U(H(e.value)));case"DataFrameJSON":return o.DataFrame.fromJson(JSON.stringify(e.value));case"ArrayBuffer":return U(H(e.value)).buffer;case"Map":return new Map(e.value);case"DayJs":return x()(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}function q(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}let J=new o.LruCache,z=t=>{var n;return(n=function*(){var n;let i=null!=(n=t.options.help)?n:t.options.readme;if(!i)return;if(J.get(t.id))return J.get(t.id);let r="";try{r=t.package.name}catch(t){}let o=`System:AppData/${r}/${i}`;if(r&&(yield e.dapi.files.exists(o))){let n=yield e.dapi.files.readAsText(o);return J.set(t.id,n),n}let s=`${e.shell.user.name}.home/${i}`;if(yield e.dapi.files.exists(s)){let n=yield e.dapi.files.readAsText(s);return J.set(t.id,n),n}},function(){var t=this,e=arguments;return new Promise(function(i,r){var o=n.apply(t,e);function s(t){q(o,i,r,s,l,"next",t)}function l(t){q(o,i,r,s,l,"throw",t)}s(void 0)})})()},K=t=>{let e;try{e=t.package}catch(t){}return e},Z=(t,e)=>{let n=t[e];return n?F(n,{warning:e}):null},X=t=>{try{return null==t?void 0:t.started}catch(t){return}},Q=t=>{var e;return JSON.parse(null!=(e=t.options.OUTPUT_OUTDATED)?e:"false",G)||!X(t)||!t.id},tt=t=>{let e=(null==(a=t.func)||null==(l=a.nqName)?void 0:l.includes(":"))?o.Func.byName(t.func.nqName).prepare():t.func.prepare();e.id=t.id,t.options.forEach(n=>e.options[n]=t.options[n]);let n=E()(e.outputParams.values()).filter(e=>null!=t.outputs[e.name]);var i=!0,r=!1,s=void 0;try{for(var l,a,u,c=n[Symbol.iterator]();!(i=(u=c.next()).done);i=!0){let n=u.value;n.property.propertyType===o.TYPE.DATA_FRAME?e.outputs[n.name]=t.outputs[n.name].clone():e.outputs[n.name]=t.outputs[n.name]}}catch(t){r=!0,s=t}finally{try{i||null==c.return||c.return()}finally{if(r)throw s}}let d=E()(e.inputParams.values()).filter(e=>null!=t.inputs[e.name]);var p=!0,h=!1,f=void 0;try{for(var m,v=d[Symbol.iterator]();!(p=(m=v.next()).done);p=!0){let n=m.value;n.property.propertyType===o.TYPE.DATA_FRAME?e.inputs[n.name]=t.inputs[n.name].clone():e.inputs[n.name]=t.inputs[n.name]}}catch(t){h=!0,f=t}finally{try{p||null==v.return||v.return()}finally{if(h)throw f}}return X(t)&&(e.started=t.started),e},te=t=>{var e;let n=t.options[T];return n?{name:t.name,config:null!=(e=F(n,{warning:`${t.name} viewer`,reviver:(t,e)=>{if("true"===e)return!0;if("false"===e)return!1;if("type"===t)return S[e]||e;if(!t.toLowerCase().includes("color")){let t=Number.parseFloat(e);if(!Number.isNaN(t))return t}return e}}))?e:[]}:{name:t.name,config:[]}},tn=t=>t.trimStart().startsWith("<"),ti=t=>{try{return t.started.toDate().toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}catch(t){return"Not completed"}},tr="createdById",to="createdAt",ts="customView",tl="nestedEntity",ta=t=>{var e,n;if(null==(e=t.options)?void 0:e[tr])return t.options[tr];try{return null==(n=t.author)?void 0:n.id}catch(t){return}},tu=t=>{var e;return(null==(e=t.options)?void 0:e.title)||t.friendlyName||""};function tc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function td(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function tp(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){td(o,i,r,s,l,"next",t)}function l(t){td(o,i,r,s,l,"throw",t)}s(void 0)})}}function th(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n,i,r=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var o=[],s=!0,l=!1;try{for(r=r.call(t);!(s=(n=r.next()).done)&&(o.push(n.value),!e||o.length!==e);s=!0);}catch(t){l=!0,i=t}finally{try{s||null==r.return||r.return()}finally{if(l)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return tc(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return tc(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}let tf='((options.isDeleted != "true") or (options.isDeleted = null))',tm=t=>t.trim().toLowerCase();function tv(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function ty(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){tv(o,i,r,s,l,"next",t)}function l(t){tv(o,i,r,s,l,"throw",t)}s(void 0)})}}function tg(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}function tb(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}!function(t){let n=new o.LruCache;function i(t,e){var n,i;t.friendlyName=e.name.trim(),t.options.title=t.friendlyName;let o=r(t);t.options.description=null!=(n=e.description)?n:o.description,t.options.tags=null!=(i=e.tags)?i:o.tags}function r(t){var e,n,i;let r=null==(n=t.options)?void 0:n.tags;return{name:tu(t),description:null!=(e=null==(i=t.options)?void 0:i.description)?e:"",tags:Array.isArray(r)?r:[]}}function s(t){return tp(function*(){var e,n,i;let r,o;if(t.options[tr])return;let s=ta(t)?t:yield l(t.id);t.options[tr]=ta(s),t.options[to]=null==(e=(null==(o=(r=(null==(n=s.options)?void 0:n[tr])?null==(i=s.options)?void 0:i[to]:void 0)?x()(r):X(s))?void 0:o.isValid())?o:void 0)?void 0:e.toISOString()})()}function l(t){return tp(function*(){return yield e.dapi.functions.calls.allPackageVersions().include("session.user,func.package, inputs, outputs").find(t)})()}function a(t,n){return tp(function*(t,n,i){let r=e.dapi.spaces.id(n);yield r.addEntity(t,!0);var o=!0,s=!1,l=void 0;try{for(var a,u=(void 0===i?[]:i)[Symbol.iterator]();!(o=(a=u.next()).done);o=!0){let e=a.value;e.id!==t&&(yield r.removeEntity(e.id))}}catch(t){s=!0,l=t}finally{try{o||null==u.return||u.return()}finally{if(s)throw l}}}).apply(this,arguments)}function u(t){return tp(function*(){let n=th((yield Promise.all([e.dapi.spaces.id(t).children.list(),c(t)])),2);return{items:n[0],runs:n[1]}})()}function c(t){return tp(function*(){return yield e.dapi.spaces.id(t).children.ofTypes("FuncCall",!0).list()})()}function d(e,n){let i=tm(n),r=e.items.find(e=>t.isNamedSpaceItem(e)&&tm(e.friendlyName||e.name||"")===i);return{runs:e.runs.filter(t=>tm(tu(t))===i),other:r}}t.setRunMetadata=i,t.getRunMetadata=r,t.canEditRunDetails=function(t,e){return!!t&&t===o.User.current().id||e},t.shallowLoadRun=l,t.loadRun=function(t){return tp(function*(){let n=yield e.dapi.functions.calls.allPackageVersions().include("session.user,func.package, inputs, outputs").find(t),i=E()(n.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.FILE&&!!n.inputs[t.name]);yield Promise.all(i.map(t=>tp(function*(){let i=JSON.parse(n.inputs[t.name]),r=i.id,s=i.name,l=yield e.dapi.files.readAsBytes(r),a=o.FileInfo.fromBytes(s,l);return a.id=r,n.inputs[t.name]=a,Promise.resolve()})()));let r=E()(n.outputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!n.outputs[t.name]);yield Promise.all(r.map(t=>tp(function*(){return n.outputs[t.name]=yield e.dapi.tables.getTable(n.outputs[t.name]),Promise.resolve()})()));let s=E()(n.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!n.inputs[t.name]);return yield Promise.all(s.map(t=>tp(function*(){return n.inputs[t.name]=yield e.dapi.tables.getTable(n.inputs[t.name]),Promise.resolve()})())),n})()},t.updateRunMeta=function(t){return tp(function*(){yield s(t);let n=yield e.dapi.functions.calls.allPackageVersions().save(t);e.log.audit("@user edited metadata of @model model run",{user:o.User.current(),model:n.func})})()},t.saveRun=function(t,r){return tp(function*(){var s,l,u,c;let d=n.get("All users");d||(d=yield e.dapi.groups.find(o.Group.defaultGroupsIds["All users"]),n.set("All users",d));let p=null!=(s=null==r?void 0:r.audience)?s:d;(null==r?void 0:r.newId)&&t.newId(),(null==r?void 0:r.metadata)&&i(t,r.metadata),t.options[tr]=o.User.current().id,t.options[to]=x()().toISOString(),(null==r?void 0:r.nested)?t.options[tl]="true":delete t.options[tl];let h=tt(t);delete h.options.isDeleted,(null==r?void 0:r.metadata)&&(h.friendlyName=t.friendlyName),Q(h)&&(h.options.createdOn=x()().utc(!0).unix());let f=E()(h.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.FILE&&!!h.inputs[t.name]);yield Promise.all(f.map(t=>tp(function*(){var n;let i=h.inputs[t.name],r=i instanceof o.FileInfo?yield i.readAsBytes():new Uint8Array((yield i.arrayBuffer())),s=i instanceof o.FileInfo&&null!=(n=i.fileName)?n:i.name,l=o.FileInfo.fromBytes(s,r);return yield e.dapi.files.write(l),h.inputs[t.name]={id:l.id,name:l.name},Promise.resolve()})()));let m=E()(h.outputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!h.outputs[t.name]);yield Promise.all(m.map(t=>tp(function*(){yield e.dapi.tables.uploadDataFrame(h.outputs[t.name]),yield e.dapi.permissions.grant(h.outputs[t.name].getTableInfo(),p,!1)})()));let v=E()(h.inputParams.values()).filter(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&!!h.inputs[t.name]);yield Promise.all(v.map(t=>tp(function*(){yield e.dapi.tables.uploadDataFrame(h.inputs[t.name]),yield e.dapi.permissions.grant(h.inputs[t.name].getTableInfo(),p,!1)})()));let y=yield e.dapi.functions.calls.allPackageVersions().save(h);if(e.log.audit("@user saved run of the @model model",{user:o.User.current(),model:y.func}),null==r||null==(l=r.target)?void 0:l.spaceId)try{yield a(y.id,r.target.spaceId,r.target.replace)}catch(t){e.shell.error(`Saved the run, but couldn't add it to the space: ${null!=(c=null==t?void 0:t.message)?c:t}`)}return r&&!r.nested&&e.events.fireCustomEvent("compute-run-saved",{spaceIds:(null==(u=r.target)?void 0:u.spaceId)?[r.target.spaceId]:[]}),y})()},t.linkRun=a,t.unlinkRun=function(t,n){return tp(function*(){yield e.dapi.spaces.id(n).removeEntity(t)})()},t.listMyRuns=function(n){return tp(function*(){let i=Array.isArray(n)?n:[n];if(0===i.length)return[];let r=o.User.current().id,s=`(options.${tr} = "${r}") or ((session.user.id="${r}") and (options.${tr} = null))`,l=[...new Set(i.map(t=>t.name))],a=i.map(t=>`(options.${ts} = "${t.nqName}")`),u=t=>e.dapi.functions.calls.allPackageVersions().filter(`(${s}) and (${tf}) and (options.${tl} = null) and (${t})`).include("session,options,func.package").list(),c=th((yield Promise.all([u(`func.name in (${l.map(t=>`"${t}"`).join(",")})`),u(a.join(" or "))])),2);return[...new Map([...c[0],...c[1]].map(t=>[t.id,t])).values()].filter(e=>i.some(n=>{var i,r,o,s;return t.isRunOf(n,e)&&((null==(i=e.options)?void 0:i[ts])===n.nqName||(null==(r=n.package)?void 0:r.name)===(null==(s=e.func)||null==(o=s.package)?void 0:o.name))}))})()},t.listSpace=u,t.listSpaceRuns=c,t.findNameConflict=function(t,e){return tp(function*(){return d((yield u(e)),t)})()},t.isRunOf=(t,e)=>{var n,i;return t.name===(null==(n=e.func)?void 0:n.name)||t.nqName===(null==(i=e.options)?void 0:i[ts])},t.sameRunName=(t,e)=>tm(t)===tm(e),t.isNamedSpaceItem=t=>"FuncCall"!==t.entityType&&"DataConnection"!==t.entityType,t.nameConflictIn=d,t.deleteRun=function(t){return tp(function*(){yield s(t),t.options.isDeleted=!0,yield e.dapi.functions.calls.allPackageVersions().save(t)})()}}(f||(f={}));let tw=t=>{var e,n;if(null==(e=t.options)?void 0:e.default)return JSON.parse(null==(n=t.options)?void 0:n.default);let i=t.defaultValue;return t.propertyType===o.TYPE.STRING&&i?i.substring(1,i.length-1):i};function tC(t,e){e?(w()(t).addClass("ui-box").css({width:"auto",height:"auto"}),r.setUpdateIndicator(t,!0)):(r.setUpdateIndicator(t,!1),w()(t).removeClass("ui-box"))}function tA(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function tx(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){tA(o,i,r,s,l,"next",t)}function l(t){tA(o,i,r,s,l,"throw",t)}s(void 0)})}}function tI(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}function tE(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}class tS extends o.TableView{static fromComparedRuns(t,n){return tx(function*(t,n,i){var s,l;let a,u,c,d,p,h=void 0===i?{parentView:void 0,parentCall:void 0}:i,f=(a=void 0===h?{parentView:void 0,parentCall:void 0}:h,u=[...n.inputs,...n.outputs].map(t=>te(t)).reduce((t,e)=>(t[e.name]?t[e.name].push(...e.config):t[e.name]=e.config,t),{}),c=e=>{if(e.propertyType===o.TYPE.DATA_FRAME)return u[e.name].map(n=>{var i;let r=null!=(i=e.caption)?i:e.name,s=o.Column.fromType(o.TYPE.DATA_FRAME,r,t.length);s.init(n=>{var i;return null!=(i=t[n].inputs[e.name])?i:t[n].outputs[e.name]});let l=d.columns.getUnusedName(`${s.name} (${n.type})`);return s.name=l,r=l,s.temp[T]=n,d.columns.add(s),s});{var n;let i=null!=(n=e.caption)?n:e.name,r=o.Column.fromType(e.propertyType,i,t.length);r.init(n=>{var i;return null!=(i=t[n].inputs[e.name])?i:t[n].outputs[e.name]});let s=d.columns.getUnusedName(r.name);return r.name=s,i=s,d.columns.add(r),[r]}},d=o.DataFrame.create(t.length),p=[],t.forEach(t=>{let e=tu(t)||`${t.func.name} - ${ti(t)}`,n=2;for(;p.includes(e);)e=`${t.func.name} - ${ti(t)} - ${n}`,n++;p.push(e)}),d.columns.add(o.Column.fromStrings(O,p)),d.name=(null==(s=a.parentCall)?void 0:s.func.name)?`${null==(l=a.parentCall)?void 0:l.func.name} - comparison`:`${n.name} - comparison`,n.inputs.forEach(t=>c(t)),n.outputs.forEach(t=>c(t)),e.events.onCurrentObjectChanged.subscribe(t=>{let n=t.sender;if(n instanceof o.Column&&n.type===o.TYPE.DATA_FRAME&&e.shell.tv&&e.shell.tv.temp.isComparison&&[o.VIEWER.LINE_CHART,o.VIEWER.SCATTER_PLOT,o.VIEWER.HISTOGRAM,o.VIEWER.BOX_PLOT].includes(n.temp[T].type)){e.shell.windows.showContextPanel=!0;let t=t=>{let e=t.get(0).clone();e.columns.addNew(P,o.TYPE.STRING).init(t.dataFrame.get(O,0));for(let n=1;n<t.length;n++){let i=t.get(n).clone();i.columns.addNew(P,o.TYPE.STRING).init(t.dataFrame.get(O,n));let r=[o.COLUMN_TYPE.INT,o.COLUMN_TYPE.FLOAT];for(let t=0;t<i.columns.length;t++){let n=i.columns.byIndex(t),s=e.columns.byIndex(t);n.type!==s.type&&r.includes(n.type)&&r.includes(s.type)&&(n.type!==o.COLUMN_TYPE.FLOAT&&i.columns.replace(n,n.convertTo(o.COLUMN_TYPE.FLOAT)),s.type!==o.COLUMN_TYPE.FLOAT&&e.columns.replace(s,s.convertTo(o.COLUMN_TYPE.FLOAT)))}e.append(i,!0)}return e},i=n.temp[T].look;setTimeout(()=>{switch(n.temp[T].type){case o.VIEWER.LINE_CHART:let s=r.waitBox(()=>ty(function*(){var e;let r=null!=(e=n.temp.unitedDf)?e:t(n);return n.temp.unitedDf=r,r.plot.line(tb(tg({},i),{split:P})).root})());w()(s).css({width:"100%"}),e.shell.o=s;break;case o.VIEWER.SCATTER_PLOT:let l=r.waitBox(()=>ty(function*(){var e;let r=null!=(e=n.temp.unitedDf)?e:t(n);return n.temp.unitedDf=r,r.plot.scatter(tb(tg({},i),{color:P})).root})());e.shell.o=l,w()(l).css({width:"100%"});break;case o.VIEWER.HISTOGRAM:let a=r.waitBox(()=>ty(function*(){var e;let r=null!=(e=n.temp.unitedDf)?e:t(n);return n.temp.unitedDf=r,r.plot.histogram(tb(tg({},i),{split:P})).root})());e.shell.o=a,w()(a).css({width:"100%"});break;case o.VIEWER.BOX_PLOT:let u=r.waitBox(()=>ty(function*(){var e;let r=null!=(e=n.temp.unitedDf)?e:t(n);return n.temp.unitedDf=r,r.plot.box(tb(tg({},i),{category:P})).root})());e.shell.o=u,w()(u).css({width:"100%"})}})}}),d),m=[...e.shell.views].find(t=>t.type===R||"scripts"===t.type||"functions"===t.type);return m&&(e.shell.v=m),new this(f,h)}).apply(this,arguments)}showAllColumns(){let t=this.dataFrame.columns.names();this.grid.columns.setVisible(t)}showChangingColumns(){let t=this.dataFrame.columns.names().filter(t=>o.TYPES_SCALAR.has(this.dataFrame.getCol(t).type)&&this.dataFrame.getCol(t).categories.length>1||!o.TYPES_SCALAR.has(this.dataFrame.getCol(t).type));this.grid.columns.setVisible(t)}defaultCustomize(){let t=r.iconFA("compress-alt",()=>{this.showChangingColumns(),w()(n).show(),w()(t).hide()},"Hide constant parameters"),n=r.iconFA("expand-arrows-alt",()=>{this.showAllColumns(),w()(n).hide(),w()(t).show()},"Show all parameters");w()(t).hide(),this.setRibbonPanels([...this.getRibbonPanels(),[t,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(O).width=70;for(let t=0;t<this.grid.columns.length;t++){var i;let e=this.grid.columns.byIndex(t);(null==(i=e.column)?void 0:i.temp[T])&&(e.width=350,e.cellType="html")}let s=new o.LruCache;this.grid.onCellPrepare(t=>tx(function*(){if(!t.isColHeader&&!t.isRowHeader){if(t.tableColumn.name===O){t.customText="";let e=String(t.cell.value).split(" - "),n=e.length>1?[e[0],r.element("br"),e[1]]:e;t.element=r.div(n,{style:{writingMode:"vertical-rl",textOrientation:"mixed",margin:"auto"}}),t.element.parentElement.style.display="flex";return}if(t.tableColumn&&t.tableColumn.temp[T]){let e=t.cell.value,n=t.tableColumn.temp[T],i=n.type,r=`${e.id}_${i}`;if(s.get(r))t.element=s.get(r);else{let l=yield tx(function*(){let r=Object.values(S).includes(i)?o.Viewer.fromType(i,e):yield e.plot.fromType(i);return t.tableColumn.temp[T].look?r.setOptions(t.tableColumn.temp[T].look):(r.setOptions(n),t.tableColumn.temp[T]=r.getOptions()),r.root})();s.set(r,l),t.element=l}t.element.style.width="100%",t.element.style.height="100%"}}})());let l=r.box(r.div([],{style:{minHeight:"100px"}})),a=e.events.onCurrentViewChanged.subscribe(()=>{e.shell.v.id===this.id?e.shell.dockManager.dock(l,"down",null,"Comparison chart",.25):e.shell.dockManager.close(l)}),u=this.grid.onCellClick.subscribe(t=>{var n;e.shell.v.id===this.id&&t.isColHeader&&(null==(n=t.tableColumn)?void 0:n.type)===o.TYPE.DATA_FRAME&&[o.VIEWER.LINE_CHART,o.VIEWER.SCATTER_PLOT,o.VIEWER.HISTOGRAM,o.VIEWER.BOX_PLOT].includes(t.tableColumn.temp[T].type)?(e.shell.dockManager.findNode(l)||e.shell.dockManager.dock(l,"down",null,"Comparison chart",.25),r.setUpdateIndicator(l,!0),setTimeout(()=>{if(!t.tableColumn.temp.unitedPlot){var e;let n=t.tableColumn.temp[T].look,i=(t=>{let e=o.toJs(t.get(0)).clone();e.columns.addNew(P,o.TYPE.STRING).init(t.dataFrame.get(O,0));for(let n=1;n<t.length;n++){let i=o.toJs(t.get(n)).clone();i.columns.addNew(P,o.TYPE.STRING).init(t.dataFrame.get(O,n));let r=[o.COLUMN_TYPE.INT,o.COLUMN_TYPE.FLOAT];for(let t=0;t<i.columns.length;t++){let n=i.columns.byIndex(t),s=e.columns.byIndex(t);n.type!==s.type&&r.includes(n.type)&&r.includes(s.type)&&(n.type!==o.COLUMN_TYPE.FLOAT&&i.columns.replace(n,n.convertTo(o.COLUMN_TYPE.FLOAT)),s.type!==o.COLUMN_TYPE.FLOAT&&e.columns.replace(s,s.convertTo(o.COLUMN_TYPE.FLOAT)))}e.append(i,!0)}return e})(t.tableColumn);t.tableColumn.temp.unitedPlot=((e,n,i)=>{var r;switch(null==(r=t.tableColumn)?void 0:r.temp[T].type){case o.VIEWER.LINE_CHART:return i.plot.line(tE(tI({},n),{split:P})).root;case o.VIEWER.SCATTER_PLOT:return i.plot.scatter(tE(tI({},n),{color:P})).root;case o.VIEWER.HISTOGRAM:return i.plot.histogram(tE(tI({},n),{split:P})).root;case o.VIEWER.BOX_PLOT:return i.plot.box(tE(tI({},n),{category:P})).root}})(null==(e=t.tableColumn)||e.temp[T].type,n,i),r.setUpdateIndicator(l,!1)}r.empty(l),l.appendChild(t.tableColumn.temp.unitedPlot)},10)):e.shell.dockManager.close(l)});this.subs.push(u,a)}constructor(t,n){let i=void 0===n?{}:n;super(window.grok_TableView(t.dart,!1)),i.parentView&&(this.parentView=i.parentView),this.parentCall=i.parentCall||e.functions.getCurrentCall()}}var tR=n(2),tT=n.n(tR),tO=n(611),tP=n.n(tO),tF=n(129),tV=n.n(tF),tB=n(986),tD=n.n(tB),tk=n(838),tj=n.n(tk),tL=n(515),tM=n.n(tL),tN=n(76),t_={};function tU(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function tH(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){tU(o,i,r,s,l,"next",t)}function l(t){tU(o,i,r,s,l,"throw",t)}s(void 0)})}}t_.styleTagTransform=tM(),t_.setAttributes=tD(),t_.insert=tV().bind(null,"head"),t_.domAPI=tP(),t_.insertStyleElement=tj(),tT()(tN.A,t_),tN.A&&tN.A.locals&&tN.A.locals;let t$="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class tW 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()}subscribeOnEvents(){this.input.readOnly=!0,this.input.classList.add("default");let t=t=>tH(function*(){if(t&&t.length&&this.enabled){if(t.length>1)throw this.isValid.next(!1),Error("Please specify single input file");if(this.fileType&&t[0].type!==this.fileType)throw this.isValid.next(!1),Error("File type is not supported");this.isValid.value?this.uploadedFile$.next(t[0]):this.uploadedFile$.next(null)}}).call(this);this.root.classList.add("fi-drop-area"),this.root.style.width="100%",this.hiddenInput.type="file",this.hiddenInput.addEventListener("change",()=>tH(function*(){return yield t(this.hiddenInput.files)}).call(this),!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=>tH(function*(){t(e.dataTransfer.files)})(),!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)}constructor(t,e,n,i){let o=void 0===i?t$:i;super(r.input.string("Input file",{value:""}).dart),this.initialText=void 0===t?"Drag-n-drop here":t,this.initialValue=void 0===e?null:e,this.onValueChanged=void 0===n?null: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=r.iconFA("cloud-upload",()=>this.hiddenInput.click(),"Upload"),this.subscribeOnEvents(),this.root.style.display="flex",this.isValid.subscribe(t=>{if(t){this.input.classList.remove("error"),this.input.classList.add("success");let t=r.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");let t=r.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){let t=r.iconFA("cloud-upload",()=>this.hiddenInput.click(),"Choose a file to upload");this.icon.replaceWith(t),this.icon=t}this.value=t}),this.reset()}}function tY(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}let tG=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"}};function tq(t){var n;return(n=function*(t,n,i,r,s){let l=void 0===r?[]:r,a=void 0!==s&&s,u="";var c=!0,d=!1,p=void 0;try{for(var h,f=(void 0===n?[]:n)[Symbol.iterator]();!(c=(h=f.next()).done);c=!0){let t=h.value,e=[];t.author&&e.push(`session.user.id="${t.author.id}"`),t.date&&e.push(tG(t.date)),t.text&&e.push(`((options.title like "${t.text}") or (options.annotation like "${t.text}"))`),t.includeDeleted||e.push(tf);let n=e.join(" and ");""!==n&&(""===u?u+=`(${n})`:u+=` or (${n})`)}}catch(t){d=!0,p=t}finally{try{c||null==f.return||f.return()}finally{if(d)throw p}}""!==u&&(u=` and (${u})`);let m=yield e.dapi.functions.calls.allPackageVersions().filter(`func.name="${t}"${u}`).include(`${[...l,"func.package"].join(",")}`).list(void 0===i?{}:i);if((l.includes("inputs")||l.includes("func.params"))&&!a){var v=!0,y=!1,g=void 0;try{for(var b,w=m[Symbol.iterator]();!(v=(b=w.next()).done);v=!0){let t=b.value,n=E()(t.inputParams.values()).filter(e=>e.property.propertyType===o.TYPE.DATA_FRAME&&!!t.inputs[e.name]);var C=!0,A=!1,x=void 0;try{for(var I,S=n[Symbol.iterator]();!(C=(I=S.next()).done);C=!0){let n=I.value;t.inputs[n.name]=yield e.dapi.tables.getTable(t.inputs[n.name])}}catch(t){A=!0,x=t}finally{try{C||null==S.return||S.return()}finally{if(A)throw x}}}}catch(t){y=!0,g=t}finally{try{v||null==w.return||w.return()}finally{if(y)throw g}}}if((l.includes("outputs")||l.includes("func.params"))&&!a){var R=!0,T=!1,O=void 0;try{for(var P,F=m[Symbol.iterator]();!(R=(P=F.next()).done);R=!0){let t=P.value,n=E()(t.outputParams.values()).filter(e=>e.property.propertyType===o.TYPE.DATA_FRAME&&!!t.outputs[e.name]);var V=!0,B=!1,D=void 0;try{for(var k,j=n[Symbol.iterator]();!(V=(k=j.next()).done);V=!0){let n=k.value;t.outputs[n.name]=yield e.dapi.tables.getTable(t.outputs[n.name])}}catch(t){B=!0,D=t}finally{try{V||null==j.return||j.return()}finally{if(B)throw D}}}}catch(t){T=!0,O=t}finally{try{R||null==F.return||F.return()}finally{if(T)throw O}}}return m},function(){var t=this,e=arguments;return new Promise(function(i,r){var o=n.apply(t,e);function s(t){tY(o,i,r,s,l,"next",t)}function l(t){tY(o,i,r,s,l,"throw",t)}s(void 0)})}).apply(this,arguments)}var tJ=n(602),tz={};tz.styleTagTransform=tM(),tz.setAttributes=tD(),tz.insert=tV().bind(null,"head"),tz.domAPI=tP(),tz.insertStyleElement=tj(),tT()(tJ.A,tz),tJ.A&&tJ.A.locals&&tJ.A.locals;let tK="experimental",tZ="ModelStorage",tX="Source",tQ="Is favorite",t0="Is complete",t1="Delete",t2="Author",t3="Date",t5="Title",t4="Desc.",t6="Tags",t8="Version",t7=Object.values(o.COLUMN_TYPE).filter(t=>t!==o.TYPE.DATA_FRAME);var t9=n(474),et=n.n(t9);function ee(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function en(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){ee(o,i,r,s,l,"next",t)}function l(t){ee(o,i,r,s,l,"throw",t)}s(void 0)})}}function ei(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}class er extends o.Dialog{static forFuncCall(t,e){var n,i,r;let o=null!=(n=t.options.title)?n:"";return new er({title:o,description:null!=(i=t.options.description)?i:"",tags:null!=(r=t.options.tags)?r:[],isFavorite:void 0!==e&&e})}awaitMetadata(t){let e=(0,s.race)(this.onMetadataEdit,this.onClose.pipe((0,l.map)(()=>null))).pipe((0,l.take)(1));return this.show(ei({center:!0,width:500},t)),e.toPromise()}constructor(t){var n,i,l,a,u;super(r.dialog({title:"Save model state"}).dart),n=this,this._onMetadataEdit=new s.Subject,this.onMetadataEdit=this._onMetadataEdit.asObservable();let c=null!=(i=null==t?void 0:t.title)?i:"",d=null!=(l=null==t?void 0:t.description)?l:"",p=null!=(a=null==t?void 0:t.isFavorite)&&a;const h=r.input.string("Title",{value:c,onValueChanged:t=>c=t}),f=r.input.string(" ",{value:""}),m=o.TagEditor.create();(null!=(u=null==t?void 0:t.tags)?u:[]).forEach(t=>{m.addTag(t)}),f.input.replaceWith(m.root);const v=()=>{""===y.value||m.tags.includes(y.value)||(m.addTag(y.value),y.value="")},y=r.input.string("Tag",{value:""}).addOptions(r.iconFA("plus",v,"Add this tag")),g=(0,s.fromEvent)(y.input,"onkeydown").subscribe(t=>{"Enter"==t.key&&(t.stopPropagation(),v())});this.sub(g);const b=r.input.string("Description",{value:d,onValueChanged:t=>d=t}),w=r.input.bool("Is favorite",{value:p,onValueChanged:t=>p=t});this.add(r.form([h,b,w,y,f])),this.addButton("Save",()=>en(function*(){if(""!==y.value)return void e.shell.info(`Dialog has unsaved tags: ${y.value}`);let t={title:""!==c?c:null,description:""!==d?d:null,isFavorite:p,tags:m.tags.map(t=>t)};n._onMetadataEdit.next(t),n.close()})())}}class eo extends o.Dialog{awaitDelete(t){let e=(0,s.race)(this.onFuncCallDelete,this.onClose.pipe((0,l.map)(()=>null))).pipe((0,l.take)(1));return this.show(ei({center:!0,width:500},t)),e.toPromise()}constructor(t){var e;super(r.dialog({title:`Delete ${t.size>1?t.size:""} ${t.size>1?"runs":"run"}`}).dart),e=this,this._onFuncCallDelete=new s.Subject,this.onFuncCallDelete=this._onFuncCallDelete.asObservable(),this.add(r.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(()=>en(function*(){return e._onFuncCallDelete.next(t)})())}}function es(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function el(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){es(o,i,r,s,l,"next",t)}function l(t){es(o,i,r,s,l,"throw",t)}s(void 0)})}}let ea=(t,n)=>el(function*(){let i=`${tZ}_${t.func.name}_Fav`;return n?e.dapi.userDataStorage.postValue(i,t.id,""):e.dapi.userDataStorage.remove(i,t.id)})(),eu=(t,e)=>{var n,i;return null!=(n=null!=(i=null==e?void 0:e.visibleProps)?i:Z(t.options,"mainParams"))?n:t.inputs.filter(t=>t7.includes(t.propertyType)).map(t=>t.name)},ec=t=>t.replace(/([A-Z])/g,t=>` ${t.toLowerCase()}`).trim().replace(/^./,t=>t.toUpperCase()),ed=(t,e)=>{var n,i,r,o,s,l,a;if(e===t2)return null!=(n=null==(a=t.author)?void 0:a.friendlyName)?n:" ";let u=null!=(i=null!=(r=null!=(o=null!=(s=t[e])?s:t.inputs[e])?o:t.outputs[e])?r:t.options[e])?i:null;return null!=(l=null==u?void 0:u.toString())?l:""};function ep(t){return t&&t.root&&t.onInput}function eh(t){return(null==t?void 0:t.setValidation)&&ep(t)}function ef(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)&&ep(t)}function em(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function ev(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}function ey(t){var e;return!(null==t||null==(e=t.errors)?void 0:e.length)&&!(null==t?void 0:t.pending)}function eg(t,e){return{description:t,actions:e}}function eb(t){var e,n,i;let r=t=>"string"==typeof t?eg(t):t;return{errors:null==t||null==(e=t.errors)?void 0:e.map(t=>r(t)),warnings:null==t||null==(n=t.warnings)?void 0:n.map(t=>r(t)),notifications:null==t||null==(i=t.notifications)?void 0:i.map(t=>r(t))}}function ew(...t){let e=[],n=[],i=[],r=[],o={};var s=!0,l=!1,a=void 0;try{for(var u,c,d,p,h,f,m=t[Symbol.iterator]();!(s=(f=m.next()).done);s=!0){let t=f.value;t&&(e.push(...null!=(u=t.errors)?u:[]),n.push(...null!=(c=t.warnings)?c:[]),i.push(...null!=(d=t.notifications)?d:[]),r.push(...null!=(p=t.revalidate)?p:[]),o=ev({},o,null!=(h=t.context)?h:{}))}}catch(t){l=!0,a=t}finally{try{s||null==m.return||m.return()}finally{if(l)throw a}}return{errors:e,warnings:n,notifications:i,revalidate:r,context:o}}function eC(){return{pending:!0}}function eA(t,e,n){return ev({revalidate:t,context:e},n)}function ex(t){var e,n;let i,o,s;return(null==t?void 0:t.pending)&&(o=r.iconFA("spinner",()=>{eI(t,o,i)},"Validating")).classList.add("fa-spin"),(null==t?void 0:t.errors)&&t.errors.length?(o=r.iconFA("exclamation-circle",()=>{eI(t,o,i)},"Validation")).style.color="var(--red-3)":(null==t?void 0:t.warnings)&&t.warnings.length?(o=r.iconFA("exclamation-circle",()=>{eI(t,o,i)},"Validation")).style.color="var(--orange-2)":(null==t?void 0:t.notifications)&&t.notifications.length&&((o=r.iconFA("info-circle",()=>{eI(t,o,i)},"Info")).style.color="var(--blue-1)"),o&&(o.classList.remove("fal"),o.classList.add("far"),e=o,(n=s=r.div([],"d4-tooltip")).popover="auto",n.style.fontStyle="normal",n.style.pointerEvents="all",n.style.maxWidth="300px",n.style.textWrap="pretty",e.appendChild(s),i=s),[null!=o?o:r.div(),null!=i?i:r.div()]}function eI(t,e,n){if(n&&e){var i,o;let s;for(i=e,o=n,s=i.getBoundingClientRect().toJSON(),o.style.inset="unset",o.style.top=s.y+"px",o.style.left=s.x+20+"px";n.firstChild&&n.removeChild(n.firstChild););let l=function(t){let e=r.divV([],{style:{gap:"10px"}});for(let u=0,c=["errors","warnings","notifications"];u<c.length;u++){let d=c[u],p=t[d];if(null==p?void 0:p.length){var n=!0,i=!1,o=void 0;try{for(var s,l,a=p[Symbol.iterator]();!(n=(l=a.next()).done);n=!0){let t=l.value,n=function(t){let e;return"errors"===t?(e=r.iconFA("exclamation-circle")).style.color="var(--red-3)":"warnings"===t?(e=r.iconFA("exclamation-circle")).style.color="var(--orange-2)":"notifications"===t&&((e=r.iconFA("info-circle")).style.color="var(--blue-1)"),e&&(e.classList.remove("fal"),e.classList.add("far")),e}(d);n.style.marginRight="4px",e.appendChild(r.divV([r.divH([n,r.span([t.description])]),...(null!=(s=t.actions)?s:[]).map(t=>r.link(t.actionName,t.action,void 0,{style:{paddingLeft:"20px"}}))]))}}catch(t){i=!0,o=t}finally{try{n||null==a.return||a.return()}finally{if(i)throw o}}}}return e}(t);n.appendChild(l),n.showPopover()}}let eE="restrictedValues",eS="editState";(u=m||(m={})).INPUT="Input",u.OUTPUT="Output",(c=v||(v={})).HIDDEN="hidden",c.VISIBLE="visible",(d=y||(y={})).ENABLED="enabled",d.DISABLED="disabled",(p=g||(g={})).INPUTS="inputs",p.OUTPUTS="outputs";let eR={[g.INPUTS]:"inputParams",[g.OUTPUTS]:"outputParams"};function eT(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function eO(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function eP(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){eO(o,i,r,s,l,"next",t)}function l(t){eO(o,i,r,s,l,"throw",t)}s(void 0)})}}function eF(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n,i,r=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var o=[],s=!0,l=!1;try{for(r=r.call(t);!(s=(n=r.next()).done)&&(o.push(n.value),!e||o.length!==e);s=!0);}catch(t){l=!0,i=t}finally{try{s||null==r.return||r.return()}finally{if(l)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return eT(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eT(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eV(t){return t.dart&&o.toJs(t.dart)instanceof o.InputBase}let eB=t=>eP(function*(){let e=t.id,n=o.Func.byName(t.func.nqName).prepare([...t.inputs].reduce((t,e)=>{let n=eF(e,2),i=n[0],r=n[1];return t[i]=r,t},{}));return t.options.forEach(e=>n.options[e]=t.options[e]),e||(n.id=null),n})();function eD(t,e){return eP(function*(){let n={};var i=!0,r=!1,s=void 0;try{for(var l,a=Object.entries(t.inputs)[Symbol.iterator]();!(i=(l=a.next()).done);i=!0){let t=eF(l.value,2),i=t[0],r=t[1],s=e.funcCall.inputParams[i].property;n[i]=yield function(t,e,n){return eP(function*(){if("file"===t.propertyType&&n.getInput){let e=n.getInput(t.name).value;return e instanceof o.FileInfo?(yield e.readAsBytes()).buffer:yield e.arrayBuffer()}return e})()}(s,r,e)}}catch(t){r=!0,s=t}finally{try{i||null==a.return||a.return()}finally{if(r)throw s}}return{inputs:n,outputs:t.outputs}})()}function ek(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function ej(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function eL(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){ej(o,i,r,s,l,"next",t)}function l(t){ej(o,i,r,s,l,"throw",t)}s(void 0)})}}function eM(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}x().extend(et());let eN=new o.LruCache;class e_ extends o.Widget{get type(){return"HistoricalRunsList"}get onRunsDfChanged(){return this._onRunsDfChanged.asObservable()}get onChosen(){return this._onChosen.asObservable()}get chosen(){return this._onChosen.value}set chosen(t){var e;this.chosenById=null!=(e=null==t?void 0:t.id)?e:null}set chosenById(t){if(!t){this.currentDf.currentRowIdx=-1;return}for(let e=0;e<this.currentDf.rowCount;e++)if(this.currentDf.getCol("ID").get(e)===t){this.currentDf.currentRowIdx=e;break}}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("ID",t))}showEditDialog(t,n){let i=er.forFuncCall(t,n);i.onMetadataEdit.pipe((0,l.take)(1)).subscribe(i=>eL(function*(){var r;if(null==(r=this.options)?void 0:r.isHistory)try{!!i.isFavorite!==n&&(yield ea(t,!!i.isFavorite));let e=yield f.shallowLoadRun(t.id);i.title&&(e.options.title=i.title),i.description&&(e.options.description=i.description),i.tags&&(e.options.tags=i.tags),yield f.updateRunMeta(e),this.updateRun(e),this.onMetadataEdit.next(e)}catch(t){e.shell.error(t)}else this.updateRun(t)}).call(this)),i.show({center:!0,width:500})}isFavoriteByIndex(t){return this.currentDf.get(tQ,t)}setGridCellRendering(){var t,n,i,o,s;let a=t=>{let e=this.getRunByIdx(t.tableRowIndex);this.showEditDialog(e,this.isFavoriteByIndex(t.tableRowIndex))},u=t=>{let n=new Set([this.getRunByIdx(t.tableRowIndex)]),i=new eo(n);i.onFuncCallDelete.pipe((0,l.take)(1)).subscribe(()=>eL(function*(){r.setUpdateIndicator(this.root,!0);try{yield Promise.all(E()(n.values()).map(t=>eL(function*(){return yield this.deleteRun(t.id),Promise.resolve()}).call(this)))}catch(t){e.shell.error(t)}finally{r.setUpdateIndicator(this.root,!1)}}).call(this)),i.show({center:!0,width:500})},c=t=>{let e=this.getRunByIdx(t.tableRowIndex);ea(e,!0).then(()=>this.updateRun(e))},d=t=>{let e=this.getRunByIdx(t.tableRowIndex);ea(e,!1).then(()=>this.updateRun(e))};i=this._historyGrid,o=this.runs,s=null!=(t=null==(n=this.options)?void 0:n.showActions)&&t,i.onCellPrepare(t=>{var n,l,p,h,f,m,v,y,g,b;if(t.isColHeader&&(null==(n=t.tableColumn)?void 0:n.name)&&[t1,tX,tQ].includes(t.tableColumn.name)&&(t.customText=""),!t.isColHeader){if((null==(l=t.tableColumn)?void 0:l.name)===t1&&(t.customText="",t.element=r.divH([r.iconFA("trash",()=>u(t),"Remove run from history"),r.iconFA("edit",()=>a(t),"Edit run metadata")],{style:{padding:"6px",gap:"6px",justifyContent:"space-between"}})),(null==(p=t.tableColumn)?void 0:p.name)===tQ){t.customText="";let e=r.iconFA("star",()=>d(t),"Unfavorite");w()(e).addClass("fas"),t.element=r.div(t.cell.value?e:r.iconFA("star",()=>c(t),"Favorite"),{style:{padding:"6px"}})}if((null==(h=t.tableColumn)?void 0:h.name)===tX){t.customText="";let e=r.iconFA("flask",null,"Experimental run");w()(e).addClass("fad fa-sm"),w()(e).removeClass("fal"),t.element=t.cell.value&&"Experimental"===t.cell.value?r.div(e,{style:{padding:"6px"}}):r.div()}if((null==(f=t.tableColumn)?void 0:f.name)===t6){t.customText="";let e=t.cell.value.length>0?r.div(null==(v=t.cell.value)?void 0:v.split(",").map(t=>r.span([t],"d4-tag")),"d4-tag-editor"):r.div();w()(e).css({padding:"3px","background-color":"transparent"}),t.element=e}if((null==(m=t.tableColumn)?void 0:m.name)==="ID"){let n,l;t.customText="";let p=(n=t.tableRowIndex,o.get(i.dataFrame.get("ID",n)));if(!p)return;let h=p.author.picture;w()(h).css({width:"25px",height:"25px",fontSize:"20px"}),r.bind(p.author,h);let f=r.iconFA("flask",null,"Experimental run");f.classList.add("fad","fa-sm"),f.classList.remove("fal"),f.style.marginLeft="3px";let m=p.options.immutable_tags,v=r.span([r.label(null!=(y=null!=(g=p.options.title)?g:null==(b=p.author)?void 0:b.friendlyName)?y:e.shell.user.friendlyName,{style:{color:"var(--blue-1)"}}),...m&&m.includes(tK)?[f]:[]]),C=r.iconFA("edit",e=>{e.stopPropagation(),a(t)},"Edit run metadata");C.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");let A=r.iconFA("trash-alt",e=>el(function*(){e.stopPropagation(),u(t)})(),"Delete run");A.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");let x=r.iconFA("star",e=>{e.stopPropagation(),d(t)},"Unfavorite");x.classList.add("fas","hp-funccall-card-icon");let I=r.iconFA("star",e=>{e.stopPropagation(),c(t)},"Favorite");I.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon"),(l=t.tableRowIndex,i.dataFrame.get(tQ,l))?(r.setDisplay(I,!1),r.setDisplay(x,!0)):(r.setDisplay(x,!1),r.setDisplay(I,!0));let E=ti(p),S=r.divH([r.divH([h,r.divV([v,r.span([E]),...p.options.tags&&p.options.tags.length>0?[r.div(p.options.tags.map(t=>r.span([t],"d4-tag")))]:[]],"hp-card-content")]),r.divH([...s?[x,I,C,A]:[]])],"hp-funccall-card"),R=t.tableRowIndex;S.addEventListener("mouseover",()=>{t.grid.dataFrame.mouseOverRowIdx=R}),S.addEventListener("click",e=>{e.shiftKey?t.grid.dataFrame.selection.set(R,!0):e.ctrlKey?t.grid.dataFrame.selection.set(R,!1):t.grid.dataFrame.currentRowIdx=R}),t.element=S}}})}deleteRun(t){return eL(function*(){return f.shallowLoadRun(t).then(t=>eL(function*(){var e;return[(yield(null==(e=this.options)?void 0:e.isHistory)?f.deleteRun(t):Promise.resolve()),t]}).call(this)).then(e=>{var n;let i=(function(t){if(Array.isArray(t))return t}(e)||function(t){var e,n,i=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(t);!(o=(e=i.next()).done)&&(r.push(e.value),2!==r.length);o=!0);}catch(t){s=!0,n=t}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(e)||function(t){if(t){if("string"==typeof t)return ek(t,2);var e=Object.prototype.toString.call(t).slice(8,-1);if("Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e)return Array.from(e);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return ek(t,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[1];return this.runs.delete(t),this.onRunsChanged.next(this.runs),(null==(n=this.options)?void 0:n.isHistory)&&this.onDelete.next(i),i}).then(t=>{ea(t,!1)}).catch(t=>{e.shell.error(t)})}).call(this)}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;((t,e,n,i,r,s)=>{var l;let a,u,c,d,p,h;s&&t.setOptions({showCurrentRowIndicator:!0,showCurrentCellOutline:!1,allowEdit:!1,allowBlockSelection:!1,showRowHeader:!1,showColumnLabels:!e,extendLastColumn:e}),t.sort([t3],[!1]);for(let e=0;e<t.columns.length;e++){let n=t.columns.byIndex(e);n&&(null==(l=n.column)?void 0:l.type)===o.TYPE.DATE_TIME&&(n.format="MMM d, h:mm tt")}if((a=t.columns.byName(t1))&&(a.cellType="html",a.width=45),(u=t.columns.byName(tQ))&&(u.cellType="html",u.width=30),(c=t.columns.byName(tX))&&(c.cellType="html",c.width=30),(d=t.columns.byName(t6))&&(d.cellType="html",d.width=90),(p=t.columns.byName(t3))&&(p.width=110),(h=t.columns.byName("ID"))&&(h.cellType="html"),e)t.columns.setVisible(["ID"]),t.props.rowHeight=70,t.invalidate();else{t.props.rowHeight=28;let e=t.dataFrame.getCol(t6);t.columns.setVisible([tX,tQ,t1,...i?[t3]:[],...i?[t2]:[],...i&&e.stats.missingValueCount<e.length?[t6]:[],...i?[t5]:[],...i?[t4]:[],...n&&r?eu(r).map(t=>{var e,n;let i=null!=(e=r.inputs.find(e=>e.name===t))?e:r.outputs.find(e=>e.name===t);return i?null!=(n=i.caption)?n:ec(i.name):ec(t)}):[]])}})(this._historyGrid,this._compactMode.value,this.showInputsIcon.value,this.showMetadataIcon.value,null==(t=this.runs.values().next().value)?void 0:t.func)}get currentDf(){return this._onRunsDfChanged.value}styleHistoryFilters(){var t,e,n,i,o,s,l,a,u;let c,d,p,h=null==(e=this.runs.values().next().value)?void 0:e.func;(i=this._historyFilters,o=this.showMetadataIcon.value,s=this.showInputsIcon.value,l=null!=(t=null==(n=this.options)?void 0:n.isHistory)&&t,d=(c=i.dataFrame).getCol(t6),(p=[...o&&c.getCol(tX).categories.length>1?[tX]:[],...o&&(null!=(a=null==(u=c.col(tQ))?void 0:u.categories.length)?a:0)>1?[tQ]:[],...o?[t3,t0]:[],...o&&c.getCol(t2).categories.length>1?[t2]:[],...o&&d.stats.missingValueCount<d.length?[t6]:[],...o&&c.getCol(t5).categories.length>1?[t5]:[],...o&&c.getCol(t4).categories.length>1?[t4]:[],...h&&s?eu(h).map(t=>{var e,n;let i=null!=(e=h.inputs.find(e=>e.name===t))?e:h.outputs.find(e=>e.name===t);return i?null!=(n=i.caption)?n:ec(i.name):ec(t)}).filter(t=>!l||c.getCol(t).categories.length>1).map(t=>t):[]]).length>0?(r.setDisplay(i.root,!0),i.setOptions({columnNames:p,showHeader:!1,showBoolCombinedFilter:!0})):r.setDisplay(i.root,!1),p.length>0)?(w()(this.filterWithText).css({paddingTop:"10px"}),r.setDisplay(this.defaultFiltersText,!1)):r.setDisplay(this.defaultFiltersText,!0)}redrawSelectionState(){let 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")}constructor(t,n){var i,a,u,c,d,p,h,m;super(r.div([],{style:{height:"100%",width:"100%"}})),i=this,this.initialRuns=t,this.options=n,this.onRunsChanged=new s.BehaviorSubject(this.initialRuns.reduce((t,e)=>(t.set(e.id,e),t),new Map)),this._onRunsDfChanged=new s.BehaviorSubject(o.DataFrame.fromColumns([o.Column.bool(tX,0),...(null==(c=this.options)?void 0:c.isHistory)?[o.Column.bool(tQ,0)]:[],...(null==(d=this.options)?void 0:d.showActions)?[o.Column.string(t1,0)]:[],o.Column.bool(t0,0),o.Column.dateTime(t3,0),o.Column.string(t2,0),o.Column.string(t6,0),o.Column.string(t5,0),o.Column.string(t4,0),o.Column.fromStrings("ID",[])])),this._historyFilters=o.Viewer.filters(this._onRunsDfChanged.value,{title:"Filters",columnNames:[]}),this._historyGrid=o.Viewer.grid(this._onRunsDfChanged.value,{showRowHeader:!1,showColumnGridlines:!1,allowEdit:!1}),this.onComparisonCalled=new s.Subject,this.onMetadataEdit=new s.Subject,this._onChosen=new s.BehaviorSubject(null),this.onDelete=new s.Subject,this._onSelectedChanged=new s.BehaviorSubject(new Set([])),this.layout=r.splitH([],null,!0),this.defaultGridText=r.divText(null!=(a=null==(p=this.options)?void 0:p.fallbackText)?a:"No historical runs found","hp-no-elements-label"),this.defaultFiltersText=r.divText("No filters to show","hp-no-elements-label"),this.filterWithText=r.divH([this.defaultFiltersText,this._historyFilters.root],"ui-box"),this.trashIcon=r.div(r.iconFA("trash-alt",()=>{let t=this.currentDf.selection.getSelectedIndexes(),n=new Set;t.forEach(t=>n.add(this.getRunByIdx(t)));let o=new eo(n);o.onFuncCallDelete.pipe((0,l.take)(1)).subscribe(t=>eL(function*(){r.setUpdateIndicator(i.root,!0);try{yield Promise.all(E()(t.values()).map(t=>eL(function*(){return yield i.deleteRun(t.id),Promise.resolve()})()))}catch(t){e.shell.error(t)}finally{r.setUpdateIndicator(i.root,!1)}})()),o.show({center:!0,width:500,modal:!0})},"Delete selected runs"),{style:{paddingTop:"5px"}}),this.compareIcon=r.div(r.iconFA("exchange",()=>eL(function*(){let t=i.currentDf.selection.getSelectedIndexes(),e=[];t.forEach(t=>{e.push(i.currentDf.getCol("ID").get(t))}),i.onComparisonCalled.next(e)})(),"Compare selected runs"),{style:{paddingTop:"5px"}}),this._isFilterHidden=new s.BehaviorSubject(!1),this.showFiltersIcon=r.div(r.iconFA("filter",()=>{this._isFilterHidden.next(!this._isFilterHidden.value)},"Toggle filters"),{style:{paddingTop:"4px"}}),this._compactMode=new s.BehaviorSubject(null!=(u=null==(h=this.options)?void 0:h.isHistory)&&u),this.toggleCompactMode=r.div(r.iconFA("expand-alt",()=>{this.compactMode=!this.compactMode},"Toggle compact mode"),{style:{paddingTop:"4px"}}),this.showMetadataIcon=r.input.toggle("Metadata",{value:!0,onValueChanged:()=>{this.styleHistoryGrid(),this.styleHistoryFilters()}}),this.showInputsIcon=r.input.toggle("Params",{value:!1,onValueChanged:t=>eL(function*(){var e;0!==i.runs.size&&(t&&(null==(e=i.options)?void 0:e.isHistory)?((yield Promise.all([...i.runs.values()].map(t=>eL(function*(){if(eN.has(t.id))return eN.get(t.id);{let e=yield f.shallowLoadRun(t.id);return eN.set(e.id,e),e}})()))).forEach(t=>{i.runs.set(t.id,t)}),i.onRunsChanged.next(i.runs)):(i.styleHistoryGrid(),i.styleHistoryFilters()))})()});const v=r.divH([r.divH([...(null==n?void 0:n.isHistory)?[this.toggleCompactMode]:[],this.showFiltersIcon,this.showMetadataIcon.root,this.showInputsIcon.root],{style:{gap:"5px",padding:"5px"}}),r.divH((null==(m=this.options)?void 0:m.showBatchActions)?[this.trashIcon,this.compareIcon]:[],{style:{gap:"5px",padding:"5px"}})],{style:{justifyContent:"space-between",padding:"0px 5px"}});v.style.setProperty("overflow-y","hidden","important");const y=r.divV([this.defaultGridText,v,this._historyGrid.root],"ui-box");w()(y).removeClass("ui-div"),w()(y).css("width","100%"),this.root.appendChild(this.layout),r.setDisplayAll([this._historyGrid.root,this._historyFilters.root,this.toggleCompactMode,this.trashIcon,this.compareIcon,this.showFiltersIcon],!1);const g=this.onRunsChanged.subscribe(t=>eL(function*(){if(i.setGridCellRendering(),t.size>0){let n,s,l=yield(n=t.values().next().value.func,s=i.options,el(function*(){var i;let r=[...t.values()],l=t=>t===t3?o.Column.dateTime(ec(t),r.length).init(t=>window.grok_DayJs_To_DateTime(X(r[t])?r[t].started.utc(!0):x().unix(r[t].options.createdOn))):t===t0?o.Column.bool(ec(t),r.length).init(t=>!Q(r[t])):o.Column.fromStrings(ec(t),r.map(e=>{var n,i,r;return null!=(n=null==s||null==(r=s.propFuncs)||null==(i=r[t])?void 0:i.call(r,e))?n:ed(e,t)})),a=Object.keys(null!=(i=yield e.dapi.userDataStorage.get(`${tZ}_${n.name}_Fav`))?i:{}),u=o.DataFrame.fromColumns([o.Column.string(tX,r.length).init(t=>{let e=r[t].options.immutable_tags;return e&&e.includes(tK)?"Experimental":"Simulated"}),...(null==s?void 0:s.isHistory)?[o.Column.bool(tQ,r.length).init(t=>a.includes(r[t].id))]:[],...(null==s?void 0:s.showActions)?[o.Column.string(t1,r.length).init("")]:[],l(t3),l(t0),l(t2),o.Column.string(t6,r.length).init(t=>r[t].options.tags?r[t].options.tags.join(","):""),o.Column.string(t5,r.length).init(t=>r[t].options.title),o.Column.string(t4,r.length).init(t=>r[t].options.description),o.Column.string(t8,r.length).init(t=>r[t].options.version)]);if(eu(n).map(t=>(t=>{var e,i,a;let u=null!=(e=n.inputs.find(e=>e.name===t))?e:n.outputs.find(e=>e.name===t);return u?u.propertyType===o.TYPE.DATE_TIME?o.Column.dateTime(null!=(a=u.caption)?a:ec(u.name),r.length).init(t=>window.grok_DayJs_To_DateTime(r[t].inputs[u.name])):o.Column.fromType(u.propertyType,null!=(i=u.caption)?i:ec(u.name),r.length).init(t=>{var e,n,i;return null!=(e=null==s||null==(i=s.propFuncs)||null==(n=i[u.name])?void 0:n.call(i,r[t]))?e:ed(r[t],u.name)}):l(t)})(t)).forEach(t=>{t.name=u.columns.getUnusedName(t.name),u.columns.add(t,!1)}),u.columns.add(o.Column.fromStrings("ID",r.map(t=>t.id))),!(null==s?void 0:s.allowOtherVersions)&&(null==s?void 0:s.version)){let t=o.BitSet.create(u.rowCount,()=>!1);for(let e=0;e<u.rowCount;e++)(null==s?void 0:s.version)==u.get(t8,e)&&t.set(e,!0);return u.clone(t)}return u})()),a=t.values().next().value.func;r.setDisplayAll([i.defaultGridText,i.defaultFiltersText],!1),r.setDisplayAll([i._historyGrid.root,i._historyFilters.root,i.toggleCompactMode,i.showMetadataIcon.root,i.trashIcon,i.compareIcon,i.showFiltersIcon],!0),r.setDisplay(i.showInputsIcon.root,eu(a,i.options).length>0),i._onRunsDfChanged.next(l)}else r.setDisplayAll([i.defaultGridText,i.defaultFiltersText],!0),r.setDisplayAll([i._historyGrid.root,i._historyFilters.root,i.showMetadataIcon.root,i.showInputsIcon.root,i.toggleCompactMode,i.trashIcon,i.compareIcon,i.showFiltersIcon],!1)})()),b=this._onRunsDfChanged.subscribe(t=>{this._historyFilters.dataFrame=t,this._historyGrid.dataFrame=t,this.currentDf.getCol(t6).meta.multiValueSeparator=",",this.styleHistoryGrid(),this.styleHistoryFilters();let e=t.onCurrentRowChanged.subscribe(()=>{var t;this.currentDf.rows.select(()=>!1),this._onChosen.next(null!=(t=this.getRunByIdx(this.currentDf.currentRowIdx))?t:null)}),n=t.onSelectionChanged.subscribe(()=>{let e=[...t.selection.getSelectedIndexes()].map(t=>this.getRunByIdx(t));this._onSelectedChanged.next(new Set(e)),this.redrawSelectionState()});this.redrawSelectionState(),this.subs.push(e,n)}),C=this._isFilterHidden.subscribe(t=>{t?(w()(this.showFiltersIcon.firstChild).addClass("fal"),w()(this.showFiltersIcon.firstChild).removeClass("fad"),r.setDisplay(this.filterWithText,!1)):(w()(this.showFiltersIcon.firstChild).addClass("fad"),w()(this.showFiltersIcon.firstChild).removeClass("fal"),w()(this.filterWithText).css(this.compactMode?"height":"width","320px"),w()(this.filterWithText).css(this.compactMode?"width":"height","100%"),r.setDisplay(this.filterWithText,!0))}),A=this._compactMode.subscribe(t=>{let e=[y,this.filterWithText];w()(this.filterWithText).removeClass("ui-div");let n={style:{width:"100%",height:"100%"}};w()(this.toggleCompactMode.firstChild).addClass(t?"fa-expand-alt":"fa-compress-alt"),w()(this.toggleCompactMode.firstChild).removeClass(t?"fa-compress-alt":"fa-expand-alt");let i=t?r.splitV(e,n,!0):r.splitH(e,n,!0);this.layout.replaceWith(i),this.layout=i,r.tools.waitForElementInDom(this.layout).then(t=>{w()(t).css(this.compactMode?"height":"width","100%"),w()(this._historyFilters.root).css(eM({},this.compactMode?{width:"100%"}:{height:"100%"})),w()(this.filterWithText).css(eM({},this.compactMode?{height:"310px",width:"100%"}:{width:"310px",height:"100%"})),w()(y).css(eM({},this.compactMode?{width:"100%"}:{height:"100%"})),setTimeout(()=>{this.styleHistoryGrid(),this.styleHistoryFilters()},100)})});this.subs.push(g,A,b,C)}}function eU(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function eH(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){eU(o,i,r,s,l,"next",t)}function l(t){eU(o,i,r,s,l,"throw",t)}s(void 0)})}}class e${static getHistoryRuns(t,n){let i=void 0===n||n;return(0,s.from)(eH(function*(){return yield tq(t,[{author:e.shell.user}],{order:"started"},["func.params","session.user","options"],i)})())}}class eW extends o.InputBase{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,n,i;let r=new e_([...this._historyList.runs.values()],(n=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}({},this.options),i=i={visibleProps:null==(t=this.options)?void 0:t.mainProps,propFuncs:null==(e=this.options)?void 0:e.propFuncs},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(i)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(i,t))}),n));this._historyList.root.replaceWith(r.root),this._historyList=r,this._historyList.onChosen.subscribe(t=>{this._historyDialog.getButton("OK").disabled=!t}),this._historyList.onRunsDfChanged.pipe((0,l.filter)(t=>t.rowCount>0),(0,l.take)(1)).subscribe(()=>{this.setCurrentRow()})}getHistoryDialog(){let t=r.dialog();return w()(t.root.querySelector(".d4-dialog-contents")).removeClass("ui-form"),t.onOK(()=>eH(function*(){let t=this._historyList.chosen;if(t){var e,n;(null==(e=null==(n=this.options)?void 0:n.skipDfsOnInit)||e)&&(t=yield f.loadRun(t.id)),this.setValue(t)}this.fireInput()}).call(this)),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"),w()(t.getButton("CANCEL")).hide(),t.add(this._historyList.root),t}setValue(t){var e,n,i,r,o,s,l;(this._chosenRun=t,this._chosenRunId=null!=(e=null==(n=this._chosenRun)?void 0:n.id)?e:null,this.onHistoricalRunChosen.next(t),t)?this.stringValue=(null==(o=this.options)?void 0:o.stringValueFunc)?null==(s=this.options)?void 0:s.stringValueFunc(t):[`${ti(t)} \\ ${t.author.name}`,(null!=(i=null!=(r=null==(l=this.options)?void 0:l.mainProps)?r:Z(t.func.options,"mainParams"))?i:[]).map(e=>ed(t,e)).join(" \\ ")].join(" \\ "):this.stringValue="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)}constructor(t,e,n){var i,o;const a=r.input.string(t,{value:""});super(a.dart),this.label=t,this._funcName=e,this.options=n,this.onHistoricalRunChosen=new s.BehaviorSubject(null),this.experimentRunsUpdate=new s.Subject,this.store={experimentRuns:new s.Observable,isExperimentRunsLoading:new s.Subject,experimentRunData:new s.BehaviorSubject("")},this._historyList=new e_([],{fallbackText:"No runs are found in history",showActions:!1,showBatchActions:!1,isHistory:!1,visibleProps:null==(i=this.options)?void 0:i.mainProps,propFuncs:null==(o=this.options)?void 0:o.propFuncs}),this._historyDialog=this.getHistoryDialog(),this._visibleInput=r.input.string(this.label,{value:""}),this._visibleIcon=r.iconFA("search",()=>this.showSelectionDialog(),"Search"),this._chosenRun=null,this._chosenRunId=null,this._visibleInput=a,this._visibleInput.readOnly=!0,this._visibleInput.input.addEventListener("click",()=>this.showSelectionDialog()),this._visibleInput.addOptions(this._visibleIcon),this.store.experimentRuns=this.experimentRunsUpdate.pipe((0,l.tap)(()=>this.toggleLoaderExpRuns(!0)),(0,l.switchMap)(()=>{var t,e;return e$.getHistoryRuns(this._funcName,null==(t=null==(e=this.options)?void 0:e.skipDfsOnInit)||t).pipe((0,l.catchError)(t=>(console.error(t),s.EMPTY)),(0,l.finalize)(()=>this.toggleLoaderExpRuns(!1)))}),(0,l.shareReplay)(1)),this.store.experimentRuns.subscribe(t=>{this._historyList.updateRuns(t.filter(t=>!Q(t)))}),this.store.isExperimentRunsLoading.subscribe(t=>{r.setUpdateIndicator(this._visibleInput.root,t),r.setUpdateIndicator(this._historyList.root,t)}),this.experimentRunsUpdate.next()}}class eY extends eW{set value(t){this.setValue(t)}get value(){return this.getValue()}}class eG extends eW{get value(){let 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("-"):""}}var eq=n(128),eJ={};function ez(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}eJ.styleTagTransform=tM(),eJ.setAttributes=tD(),eJ.insert=tV().bind(null,"head"),eJ.domAPI=tP(),eJ.insertStyleElement=tj(),tT()(eq.A,eJ),eq.A&&eq.A.locals&&eq.A.locals;class eK extends o.Widget{get type(){return"HistoryPanel"}updateHistoryPane(t){this.historyList.updateRuns(t)}showEditDialog(t){this.historyList.editRun(t)}addRun(t){this.historyList.addRun(t)}get history(){return this.historyList.runs}get onCompactModeChanged(){return this.historyList.onCompactModeChanged}get compactMode(){return this.historyList.compactMode}constructor(t){var n;super(r.box(r.divText("No historical runs loaded","hp-no-elements-label"),{style:{width:"100%",height:"100%"}})),n=this,this.func=t,this.onRunChosen=new s.Subject,this.onComparison=new s.Subject,this.afterRunEdited=new s.Subject,this.afterRunDeleted=new s.Subject,this.allRunsFetch=new s.Subject,this.historyList=new e_([],{fallbackText:"No runs are found in history",showActions:!0,showBatchActions:!0,isHistory:!0}),this.panel=this.historyList.root;const i=this.historyList.onChosen.pipe((0,l.filter)(t=>!!t)).subscribe(t=>this.onRunChosen.next(t.id)),o=this.historyList.onComparisonCalled.subscribe(t=>this.onComparison.next(t)),a=this.allRunsFetch.subscribe(()=>{var t;return(t=function*(){r.setUpdateIndicator(n.root,!0),tq(n.func.name,[{author:e.shell.user}],{},["session.user","options"]).then(t=>{r.empty(n.root),n.root.appendChild(n.panel),n.updateHistoryPane(t)}).catch(t=>e.shell.error(t)).finally(()=>r.setUpdateIndicator(n.root,!1))},function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){ez(o,i,r,s,l,"next",t)}function l(t){ez(o,i,r,s,l,"throw",t)}s(void 0)})})()}),u=this.historyList.onMetadataEdit.subscribe(t=>{this.afterRunEdited.next(t)}),c=this.historyList.onDelete.subscribe(t=>{this.afterRunDeleted.next(t)});this.subs.push(i,a,u,o,c),this.allRunsFetch.next()}}function eZ(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function eX(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){eZ(o,i,r,s,l,"next",t)}function l(t){eZ(o,i,r,s,l,"throw",t)}s(void 0)})}}(h=b||(b={})).fileInput=function(t,e,n,i){return new tW(void 0===t?"Drag-n-drop here":t,void 0===e?null:e,void 0===n?null:n,void 0===i?t$:i)},h.historyInput=function(t,e,n){return new eY(t,e,n)},h.historyInputJSON=function(t,e,n){return new eG(t,e,n)},h.historyPanel=function(t){return new eK(t)};let eQ=new URL(e.shell.startUri),e0=()=>eX(function*(){let 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=()=>{let e=new Blob(n,{type:n[0].type});t.getVideoTracks()[0].stop(),o.Utils.download(`Recording ${new Date().toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}.mkv`,e,n[0].type)},e.start()})();class e1 extends o.ViewBase{onFuncCallReady(){return eX(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();let t=this.getStartId();if(t&&!this.options.isTabbed&&(r.setUpdateIndicator(this.root,!0),this.loadRun(t),r.setUpdateIndicator(this.root,!1),this.setAsLoaded()),this.isHistoryEnabled&&this.func){let t=this.options.isTabbed?this.isHistorical.subscribe(t=>{t||(this.funcCall.id=null)}):this.isHistorical.subscribe(t=>{if(t){var e,n;this.path=`?id=${this.funcCall.id}`;let t=ti(this.funcCall);0>this.name.indexOf(" — ")?this.name=`${this.name} — ${null!=(e=this.funcCall.options.title)?e:t}`:this.name=`${this.name.substring(0,this.name.indexOf(" — "))} — ${null!=(n=this.funcCall.options.title)?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)}}).call(this)}getStartId(){return e.shell.getVar("isLoaded")?void 0:eQ.searchParams.get("id")}setAsLoaded(){return e.shell.setVar("isLoaded",!0)}get funcCall(){return this._funcCall}get func(){var t;return null==(t=this.funcCall)?void 0:t.func}get lastCall(){return this._lastCall}set lastCall(t){this._lastCall=t}get type(){return this._type}getPackageData(){return eX(function*(){var t,e;let n=this.func.package;if(!n)return;let i=null==(t=yield null==n?void 0:n.getProperties())?void 0:t.REPORT_BUG_URL;i&&!this.reportBug&&(this.reportBug=()=>eX(function*(){window.open(i,"_blank")})());let r=null==(e=yield null==n?void 0:n.getProperties())?void 0:e.REQUEST_FEATURE_URL;r&&!this.requestFeature&&(this.requestFeature=()=>eX(function*(){window.open(r,"_blank")})());let o=`${n.friendlyName}.
|
|
169
|
+
Last updated on ${x()(n.updatedOn).format("YYYY MMM D, HH:mm")}`;this.getAbout||(this.getAbout=()=>eX(function*(){return o})())}).call(this)}linkFunccall(t){this._funcCall=t,this.funcCallReplaced.next(!0)}loadFuncCallById(){return eX(function*(){if(this.initValue instanceof o.FuncCall){yield new Promise(t=>setTimeout(t,0)),this.linkFunccall(this.initValue);return}r.setUpdateIndicator(this.root,!0);let t=this.getStartId();if(t&&!this.options.isTabbed)this.linkFunccall((yield f.loadRun(t)));else{let t=o.Func.byName(this.initValue);this.linkFunccall(t.prepare({}))}r.setUpdateIndicator(this.root,!1)}).call(this)}init(){return eX(function*(){yield this.loadFuncCallById(),yield this.onFuncCallReady(),this.isReady.next(!0)}).call(this)}build(){r.empty(this.root),this.root.appendChild(this.buildIO()),this.options.historyEnabled&&this.isHistoryEnabled&&this.buildHistoryBlock(),this.buildRibbonMenu(),this.buildRibbonPanels()}onComparisonLaunch(t){return eX(function*(){let n=this.comparatorFunc;if(n){let i=o.Func.byName(n),r=(yield i.prepare({params:{comparedRuns:t}}).call()).outputs.comparisonView;e.shell.addView(r);return}let i=e.shell.v.parentCall,r=[...e.shell.views].find(t=>t.type===R),s=yield tS.fromComparedRuns(t,this.func,{parentView:r,parentCall:i});e.shell.addView(s),s.defaultCustomize();let l=this.compareCustomizer;if(l){let t=o.Func.byName(l);yield t.prepare({params:{defaultView:s}}).call();return}}).call(this)}onSaveClick(){return eX(function*(){yield this.saveRun(this.funcCall)}).call(this)}buildHistoryBlock(){let t=b.historyPanel(this.func),n=!1;return this.subs.push(t.onCompactModeChanged.subscribe(t=>{let n=e.shell.dockManager.findNode(this.historyRoot);n&&(e.shell.dockManager.close(n),t?e.shell.dockManager.dock(this.historyRoot,"right",null,"History",.3):e.shell.dockManager.dock(this.historyRoot,"down",null,"History",.3))}),t.onRunChosen.subscribe(t=>eX(function*(){r.setUpdateIndicator(this.root,!0),yield this.loadRun(t),r.setUpdateIndicator(this.root,!1)}).call(this)),t.onComparison.subscribe(e=>eX(function*(){tC(t.root,!0);let n=yield Promise.all(e.map(t=>f.loadRun(t)));yield this.onComparisonLaunch(n),tC(t.root,!1)}).call(this)),t.afterRunEdited.subscribe(t=>{if(t.id===this.funcCall.id&&t.options.title){var e,n;this.path=`?id=${this.funcCall.id}`;let i=ti(t);0>this.name.indexOf(" — ")?this.name=`${this.name} — ${null!=(e=t.options.title)?e:i}`:this.name=`${this.name.substring(0,this.name.indexOf(" — "))} — ${null!=(n=t.options.title)?n:i}`}}),e.events.onViewRemoving.subscribe(t=>{if(t.args.view==this){let t=e.shell.dockManager.findNode(this.historyRoot);t?(e.shell.dockManager.close(t),n=!0):n=!1}}),e.events.onCurrentViewChanged.subscribe(()=>{if(e.shell.v==this){if(n){var t;(null==(t=this.historyBlock)?void 0:t.compactMode)?e.shell.dockManager.dock(this.historyRoot,"right",null,"History",.3):e.shell.dockManager.dock(this.historyRoot,"down",null,"History",.3)}}else{let t=e.shell.dockManager.findNode(this.historyRoot);t?(e.shell.dockManager.close(t),n=!0):n=!1}})),r.empty(this.historyRoot),this.historyRoot.style.removeProperty("justify-content"),this.historyRoot.append(t.root),this.historyBlock=t,t.root}buildRibbonPanels(){let t=r.iconFA("history",()=>{if(!e.shell.dockManager.findNode(this.historyRoot)){var t;(null==(t=this.historyBlock)?void 0:t.compactMode)?e.shell.dockManager.dock(this.historyRoot,"right",null,"History",.3):e.shell.dockManager.dock(this.historyRoot,"down",null,"History",.3),this.historyRoot.parentElement.classList.add("ui-box"),this.historyRoot.classList.add("ui-box")}},"History"),n=r.iconFA("save",()=>eX(function*(){yield this.onSaveClick()}).call(this),"Save current state"),i=r.comboPopup(r.iconFA("arrow-to-bottom"),this.getFormats(),this.exportRun.bind(this)),o=r.iconFA("edit",()=>{this.historyBlock&&this.lastCall&&this.historyBlock.showEditDialog(this.historyBlock.history.get(this.funcCall.id))},"Edit this run metadata"),s=this.isHistorical.subscribe(t=>{t?(r.setDisplay(i,!Q(this.funcCall)),r.setDisplay(o,!0)):(w()(i).hide(),w()(o).hide())});if(this.subs.push(s),r.tooltip.bind(i,()=>"inconsistent"===this.consistencyState.value&&this.mandatoryConsistent?"Current run is inconsistent. Export feature is disabled.":null),!this.options.isTabbed&&this.mandatoryConsistent){let t=this.consistencyState.pipe((0,l.distinctUntilChanged)()).subscribe(t=>{"inconsistent"===t?(w()(i).addClass("d4-disabled"),w()(i.lastChild).css("color","unset")):(w()(i).removeClass("d4-disabled"),w()(i.lastChild).removeProp("color"))});this.subs.push(t)}let a=[[...!this.options.isTabbed&&this.isHistoryEnabled&&this.options.historyEnabled?[t]:[],...!this.options.isTabbed&&this.isHistoryEnabled?[n]:[],...!this.options.isTabbed&&this.isExportEnabled&&this.exportConfig&&this.exportConfig.supportedFormats.length>0?[i]:[],...this.options.isTabbed?[]:[o]]];return this.setRibbonPanels(a),a}buildRibbonMenu(){if(this.ribbonMenu.clear(),!this.exportConfig&&!this.reportBug&&!this.requestFeature&&!this.getHelp&&!this.getMocks&&!this.getTemplates)return;let 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{let 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{let 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()),t.item("Record the screen",e0),this.getAbout&&t.item("About",()=>eX(function*(){let t=yield this.getAbout();if(t){let e=r.dialog("Current version");t.split("\n").forEach(t=>e.add(r.label(t))),e.onOK(()=>{}),e.getButton("CANCEL").style.display="none",e.show({center:!0})}}).call(this))}exportRun(t){return eX(function*(){o.Utils.download(this.exportConfig.filename(t),(yield this.exportConfig.export(t)))}).call(this)}getFormats(){var t,e;return null!=(t=null==(e=this.exportConfig)?void 0:e.supportedFormats)?t:[]}onBeforeSaveRun(t){return eX(function*(){})()}onAfterSaveRun(t){return eX(function*(){})()}saveRun(t){return eX(function*(){let e=tt(t);yield this.onBeforeSaveRun(e),Q(e)&&(e=yield eB(t)),e.id&&e.newId();let n=yield f.saveRun(e),i=yield f.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}).call(this)}onBeforeDeleteRun(t){return eX(function*(){})()}onAfterDeleteRun(t){return eX(function*(){})()}deleteRun(t){return eX(function*(){return yield this.onBeforeDeleteRun(t),yield f.deleteRun(t),yield this.onAfterDeleteRun(t),t.id}).call(this)}onBeforeLoadRun(){return eX(function*(){})()}onAfterLoadRun(t){return eX(function*(){})()}loadRun(t){return eX(function*(){yield this.onBeforeLoadRun();let e=yield f.loadRun(t);return this.lastCall=tt(e),this.linkFunccall(e),this.isHistorical.next(!0),yield this.onAfterLoadRun(e),e}).call(this)}onBeforeRun(t){return eX(function*(){})()}onAfterRun(t){return eX(function*(){})()}run(){return eX(function*(){if(!this.funcCall)throw Error("The correspoding function is not specified");yield this.onBeforeRun(this.funcCall);let t=o.TaskBarProgressIndicator.create("Calculating...");try{this.funcCall.newId(),yield this.funcCall.call(),yield this.onAfterRun(this.funcCall),this.lastCall=tt(this.funcCall),!(this.options.isTabbed||this.runningOnInput)&&this.isHistoryEnabled&&(yield this.saveRun(this.funcCall))}catch(t){e.shell.error(t.toString())}finally{t.close()}}).call(this)}exportRunJson(){return eX(function*(){if(this._lastCall)return Y((yield eD(this._lastCall,this)))}).call(this)}getRunJSON(){return eX(function*(){let t=yield this.exportRunJson();t&&o.Utils.download(this.defaultExportFilename("","json"),t)}).call(this)}get compareCustomizer(){var t;return null!=(t=this.func.options.compareCustomizer)?t:null}get comparatorFunc(){var t;return null!=(t=this.func.options.comparatorFunc)?t:null}get uploadFunc(){var t;return null!=(t=this.func.options.uploadFunc)?t:null}get runningOnInput(){return"true"===this.func.options.runOnInput}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(null==(t=this.parentCall)?void 0:t.func.options.mandatoryConsistent)==="true"}get hasContextHelp(){var t,e,n,i;return!!(null!=(e=null==(t=this.func)||null==(n=t.options)?void 0:n.help)?e:null==t||null==(i=t.options)?void 0:i.readme)}getContextHelp(){return eX(function*(){return z(this.func)}).call(this)}get features(){var t;return null!=(t=Z(this.func.options,"features"))?t:{}}getFeature(t,e){var n,i;return n=this.features,n instanceof Array?n.includes(t):n instanceof Object&&null!=(i=n[t])?i:e}get isExportEnabled(){return this.getFeature("export",!0)}get isHistoryEnabled(){return this.getFeature("history",!0)}get isSaEnabled(){return this.getFeature("sens-analysis",!1)}get hasUploadMode(){return this.getFeature("upload",!1)}get isFittingEnabled(){return this.getFeature("fitting",!1)}get isOptimizationEnabled(){return this.getFeature("optimization",!1)}constructor(t,n){var i,l,a,u,c;let d=void 0===n?{historyEnabled:!0,isTabbed:!1,skipInit:!1}:n;super(),this.initValue=t,this.options=d,this._type="function",this.funcCallReplaced=new s.Subject,this.isReady=new s.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 s.BehaviorSubject(!1),this.historyRoot=r.div(),this.consistencyState=new s.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=e.functions.getCurrentCall(),t instanceof o.FuncCall&&(this.parentCall=t),this.parentView=null==(a=this.parentCall)||null==(l=a.parentCall)||null==(i=l.aux)?void 0:i.view,(null==(c=this.parentCall)||null==(u=c.func)?void 0:u.name)&&(this.basePath=`/${this.parentCall.func.name}`),d.skipInit||this.init()}}var e2=n(902),e3={};function e5(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function e4(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function e6(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){e4(o,i,r,s,l,"next",t)}function l(t){e4(o,i,r,s,l,"throw",t)}s(void 0)})}}function e8(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n,i,r=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var o=[],s=!0,l=!1;try{for(r=r.call(t);!(s=(n=r.next()).done)&&(o.push(n.value),!e||o.length!==e);s=!0);}catch(t){l=!0,i=t}finally{try{s||null==r.return||r.return()}finally{if(l)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return e5(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e5(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}e3.styleTagTransform=tM(),e3.setAttributes=tD(),e3.insert=tV().bind(null,"head"),e3.domAPI=tP(),e3.insertStyleElement=tj(),tT()(e2.A,e3),e2.A&&e2.A.locals&&e2.A.locals;let e7=Math.ceil(36)+1,e9=(t,e,n)=>{r.setUpdateIndicator(t,e);let i=t.querySelector(".d4-update-shadow .ui-label");e&&n&&i&&(i.textContent=n)},nt=(t,e)=>{try{return Number.isFinite(t)&&e?o.format(t,e):t}catch(e){return t}},ne=(t,e,n,i)=>{let r=["Parameter","Value","Units"];n&&r.push("Validation"),i&&r.push("Consistency"),t.addRow(r).font={bold:!0},e.forEach(e=>{let r=[e.caption,nt(e.value,e.format),e.units];r.push(nn(null==n?void 0:n[e.name])),r.push(ni(null==i?void 0:i[e.name])),t.addRow(r)}),t.getColumn(1).width=1.2*Math.max(...e.map(t=>t.caption.toString().length),9),t.getColumn(2).width=1.2*Math.max(...e.map(t=>t.value.toString().length),5),t.getColumn(3).width=1.2*Math.max(...e.map(t=>t.units.toString().length),5),t.getColumn(4).width=100,t.getColumn(5).width=100},nn=t=>null==t?"":["errors","warnings"].filter(e=>{var n;return!!(null==t||null==(n=t[e])?void 0:n.length)}).flatMap(e=>t[e].map(t=>({category:e,advice:t}))).map(t=>{let e=t.category,n=t.advice;return`${e}: ${"string"==typeof n?n:n.description}`}).join("\n"),ni=t=>{if(null==t)return"";if(t.inconsistent&&("disabled"===t.restriction||"restricted"===t.restriction)){let e=t.assignedValue,n="number"==typeof e&&Number.isFinite(e)?o.format(e,"#0.###"):String(e);return`Inconsistent: value should be ${n}`}},nr=t=>{let e=t.sheet,n=t.df,i=t.column,r=t.row,o=t.validation,s=t.consistency;if(!n)return;let l=e.getColumn(null!=i?i:1).letter,a=n.columns.length,u=n.columns.toList(),c=u.map(t=>{var e,n;return"double"===t.type?null!=(e=null==(n=t.tags)?void 0:n.format)?e:"#0.###":void 0}),d=[];for(let t=0;t<n.rowCount;t++)d.push(u.map((e,n)=>c[n]?nt(e.get(t),c[n]):e.get(t)));let p={name:`ID_${e.workbook.worksheets.reduce((t,e)=>t+e.getTables().length,0)}`,ref:`${l}${null!=r?r:1}`,columns:u.map(t=>({name:t.name,filterButton:!1})),rows:d};a>0&&(e.addTable(p),e.columns.forEach(t=>{t.width=25,t.alignment={wrapText:!0}}));let h=a+1;e.getColumn(h).width=100,e.getCell(1,h).value="Validation and Consistency",o&&(e.getCell(2,h).value=nn(o)),s&&(e.getCell(3,h).value=ni(s))},no=t=>e6(function*(){let e=tn(t)?`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`:`data:image/png;base64,${t}`,n=yield new Promise((t,n)=>{let i=new Image;i.onload=()=>t(i),i.onerror=()=>n(Error("Failed to load a graphics output")),i.src=e});if(!tn(t))return{dataUrl:e,width:n.naturalWidth,height:n.naturalHeight};let i=(t=>{var e;let n=new DOMParser().parseFromString(t,"image/svg+xml").documentElement,i=t=>{var e;return/^\s*[\d.]+(px)?\s*$/.test(null!=(e=n.getAttribute(t))?e:"")?parseFloat(n.getAttribute(t)):NaN},r=[i("width"),i("height")],o=r[0],s=r[1];if(o>0&&s>0)return{width:o,height:s};let l=e8((null!=(e=n.getAttribute("viewBox"))?e:"").trim().split(/[\s,]+/).map(Number),4),a=l[2],u=l[3];return a>0&&u>0?{width:a,height:u}:{width:1,height:1}})(t),r=Math.min(1280/i.width,720/i.height),o=Math.round(i.width*r),s=Math.round(i.height*r),l=document.createElement("canvas");return l.width=o,l.height=s,l.getContext("2d").drawImage(n,0,0,o,s),{dataUrl:l.toDataURL("image/png"),width:o,height:s}})(),ns=t=>!t||0===t.rowCount;function nl(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function na(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function nu(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){na(o,i,r,s,l,"next",t)}function l(t){na(o,i,r,s,l,"throw",t)}s(void 0)})}}function nc(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}function nd(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}function np(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n,i,r=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var o=[],s=!0,l=!1;try{for(r=r.call(t);!(s=(n=r.next()).done)&&(o.push(n.value),!e||o.length!==e);s=!0);}catch(t){l=!0,i=t}finally{try{s||null==r.return||r.return()}finally{if(l)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return nl(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nl(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}let nh=()=>r.divText("[No data to display]",{style:{"text-align":"center","align-content":"center",width:"100%",height:"100%"}});class nf extends e1{static fromFuncCall(t,e){return new this(t,void 0===e?{historyEnabled:!0,isTabbed:!1}:e)}onFuncCallReady(){var t=this,n=()=>super.onFuncCallReady;return nu(function*(){yield this.loadInputsOverrides(),yield this.loadValidators(g.INPUTS),yield this.loadValidators(g.OUTPUTS),yield n().call(t);let i=this.funcCallReplaced.subscribe(()=>{this.inputValidationRequests.next({isRevalidation:!1}),this.outputValidationRequests.next({isRevalidation:!1})});this.subs.push(i);let o=t=>(0,l.mergeMap)(e=>e.pipe((0,l.tap)(e=>{t===g.INPUTS?this.setInputValidationPending(e.field):this.setOutputValidationPending(e.field)}),(0,l.switchMap)(e=>{let n=new AbortController,i=n.signal,r=!1;return new s.Observable(o=>{let l=(0,s.from)(this.runValidation(nc({},e),i,t)).subscribe(t=>{r=!0,o.next(t)});return()=>{r||n.abort(),l.unsubscribe()}}).pipe((0,l.tap)(n=>{t===g.INPUTS?this.setInputValidationResults(n):this.setOutputValidationResults(n),this.runRevalidations(e,n,t),t===g.INPUTS?this.inputValidationUpdates.next(null):this.outputValidationUpdates.next(null)}),(0,l.mapTo)(e))}))),a=this.inputValidationRequests.pipe((0,l.groupBy)(t=>t.field),o(g.INPUTS)).subscribe(t=>{t.field&&this.runningOnInput&&this.isRunnable()&&this.doRun()});this.subs.push(a);let u=this.outputValidationRequests.pipe((0,l.groupBy)(t=>t.field),o(g.OUTPUTS)).subscribe();this.subs.push(u);let c=this.externalValidatorsUpdates.subscribe(t=>{this.updateInputValidationResults(t)});this.subs.push(c);let d=(0,s.combineLatest)([this.runRequests.pipe((0,l.switchMap)(()=>(0,s.of)(!1).pipe((0,l.delay)(500),(0,l.startWith)(!0)))),this.inputValidationUpdates.pipe((0,l.debounceTime)(0))]).pipe((0,l.filter)(t=>np(t,1)[0]&&this.isRunnable())).subscribe(()=>this.doRun());this.subs.push(d);let p=this.options.isTabbed?null:yield this.loadLastInputs();if(p)e.shell.info(r.div([r.divText("Do you want to load last inputs?"),r.divH([r.bigButton("Load",()=>{var t=!0,n=!1,i=void 0;try{for(var o,s=Object.entries(p)[Symbol.iterator]();!(t=(o=s.next()).done);t=!0){let t=np(o.value,2),e=t[0],n=t[1],i=this.getInput(e);i.notify=!1,i.value=n,i.notify=!0,this.funcCall.inputs[e]=n,this.inputValidationRequests.next({field:e,isRevalidation:!1})}}catch(t){n=!0,i=t}finally{try{t||null==s.return||s.return()}finally{if(n)throw i}}e.shell.info(r.divText("Change the loaded inputs to run computations"))})])]));else{let 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())}}).call(this)}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=>{w()(t.header).show()}),this.prevOpenedTab)return this.tabsElem.currentPane=this.prevOpenedTab,Promise.resolve();let t=this.tabsElem.panes.find(t=>this.outputTabsLabels.includes(t.name));return t&&(this.tabsElem.currentPane=t),Promise.resolve()}getRunButton(t){var e;let n=r.bigButton(null!=(e=this.func.options.runLabel)?e:void 0===t?"Run":t,()=>nu(function*(){return yield this.doRun()}).call(this)),i=(0,s.merge)(this.inputValidationUpdates,this.externalValidatorsUpdates,this.isRunning,this.blockRuns).subscribe(()=>{n.disabled=!this.isRunnable()});return this.subs.push(i),n}loadInputsOverrides(){return nu(function*(){let t=[...this.funcCall.inputParams.values()];yield Promise.all(t.map(t=>nu(function*(){if(t.property.options.input){let e=o.Func.byName(t.property.options.input).prepare({params:JSON.parse(t.property.options.inputOptions||"{}")});yield e.call(),this.inputsOverride[t.name]=e.outputs.input}}).call(this)))}).call(this)}loadValidators(){return nu(function*(t){var e;let n,i=void 0===t?g.INPUTS:t,r=yield(e=this.funcCall,n=void 0===i?g.INPUTS:i,eP(function*(){let t=[...e[eR[n]].values()];return(yield Promise.all(t.filter(t=>!!t.property.options.validatorFunc).map(t=>eP(function*(){let e=o.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)=>{let n=eF(e,2),i=n[0],r=n[1];return t[i]=r,t},{})})());i===g.INPUTS?this.inputValidators=r:this.outputValidators=r}).apply(this,arguments)}keepOutput(){var t;return(null==(t=this.func)?void 0:t.options.keepOutput)==="true"}getSaveButton(t){let e=r.bigButton(void 0===t?"Save":t,()=>nu(function*(){return yield this.saveExperimentalRun(this.funcCall)}).call(this),"Save uploaded data"),n=this.isUploadMode.subscribe(t=>{this.buildRibbonPanels(),t?w()(e).show():w()(e).hide()});return this.subs.push(n),e}getStandardButtons(){let t=this.getRunButton(),e=r.div([t]);r.tooltip.bind(e,()=>t.disabled?this.isRunning.value?"Computations are in progress":this.getValidationMessage():"");let n=this.getSaveButton();return[...this.isHistoryEnabled&&!this.options.isTabbed?[n]:[],...this.runningOnInput?[]:[e]]}buildFormButtons(){var t;let e=this.getStandardButtons(),n=r.buttonsInput();return w()(n.firstChild).css({display:"none"}),null==(t=n.lastChild)||t.replaceWith(r.div([...this.navBtns,...this.additionalBtns,...e],"ui-input-editor")),w()(n).addClass("rfv-buttons"),w()(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(){let t=this.buildInputBlock(),e=t.inputBlock,n=t.inputForm,i=t.outputForm,o=t.controlsWrapper,s=[...Array.from(n.childNodes),...this.isUploadMode.value?[Array.from(i.childNodes)]:[]];r.tools.handleResize(e,()=>{300>w()(e).width()?(w()(n).addClass("ui-form-condensed"),w()(i).addClass("ui-form-condensed"),w()(o).addClass("ui-form-condensed"),s.forEach(t=>w()(t).css("min-width","100px"))):(w()(n).removeClass("ui-form-condensed"),w()(i).removeClass("ui-form-condensed"),w()(o).removeClass("ui-form-condensed"),s.forEach(t=>w()(t).css("min-width","100%")))});let l=this.buildOutputBlock();l.style.height="100%",l.style.width="100%",this.hideOutput();let a=r.splitH([e,r.panel([l],{style:{paddingTop:"0px"}})],null,!0);return a.style.padding="0 12px",e.style.maxWidth="360px",a}buildInputBlock(){let t=this.renderInputForm(),e=this.renderOutputForm();this.buildFormButtons();let n=r.div(this.formButtons,"ui-form ui-form-wide");w()(n).css({"padding-left":"0px","padding-bottom":"0px","padding-right":"6px","max-width":"100%","min-height":"50px"});let i=r.input.toggle("",{value:this.isUploadMode.value,onValueChanged:t=>this.isUploadMode.next(t)}),o=this.isUploadMode.subscribe(t=>{i.notify=!1,i.value=t,i.notify=!0,t?w()(e).show():w()(e).hide()});return this.subs.push(o),{inputBlock:r.divV([t,...this.hasUploadMode&&!this.uploadFunc?[r.divH([r.h2("Experimental data"),i.root],{style:{flexGrow:"0"}}),e]:[],n],"ui-box rfv-form"),inputForm:t,outputForm:e,controlsWrapper:n}}processCustomDataUpload(){return nu(function*(){let t=()=>{let t=o.Dialog.create({title:"Select to compare"}),e=new e_(d.length>0?d:[...this.historyBlock.history.values()],{fallbackText:"No historical runs found",showActions:!(d.length>0),showBatchActions:!(d.length>0)}),n=new e_(c,{fallbackText:"No runs uploaded",showActions:!1,showBatchActions:!1});t.add(r.divV([r.divV([r.label("Uploaded runs"),r.element("div","splitbar-horizontal"),n.root],{style:{height:"50%",overflowY:"hidden"}}),r.divV([r.label(d.length>0?"Simulated":"History",{style:{padding:"0px 10px 0px 9px"}}),r.element("div","splitbar-horizontal"),e.root],{style:{height:"50%",overflowY:"hidden"}})],{style:{justifyContent:"space-between",gap:"10px",overflowY:"scroll",height:"100%"}})),w()(t.root.querySelector(".d4-dialog-contents")).removeClass("ui-form");let i="Compare selected";return 0===d.length?t.addButton(i,()=>nu(function*(){let i=yield Promise.all([...e.selected].map(t=>f.loadRun(t.id)));this.onComparisonLaunch([...i,...n.selected.values()]),t.close()}).call(this)):t.addButton(i,()=>nu(function*(){this.onComparisonLaunch([...e.selected.values(),...n.selected.values()]),t.close()}).call(this)),t.getButton(i).disabled=!0,this.subs.push((0,s.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(v,()=>nu(function*(){this.onComparisonLaunch([this.funcCall,...n.selected.values()]),t.close()}).call(this)),w()(t.getButton("CANCEL")).hide(),t},n=o.Func.byName(this.uploadFunc),i=yield n.prepare({params:{func:this.func}}).call(),a=i.outputs.uploadWidget,u=i.outputs.uploadFuncCall,c=[],d=[],p=o.Dialog.create({title:"Upload"});w()(p.root.querySelector(".d4-dialog-contents")).removeClass("ui-form");let h=o.Dialog.create({title:"Review uploaded runs"});w()(h.root.querySelector(".d4-dialog-contents")).removeClass("ui-form");let m="Save to history",v="Compare w/ current";p.add(a.root),p.addButton(m,()=>nu(function*(){return tC(p.root,!0),c.forEach(t=>{t.options.immutable_tags?t.options.immutable_tags.push(tK):t.options.immutable_tags=[tK]}),Promise.all(c.map(t=>nu(function*(){let e=yield this.getValidExpRun(t);return f.saveRun(e)}).call(this))).then(t=>Promise.all(t.map(t=>f.loadRun(t.id)))).then(t=>{t.forEach(t=>this.historyBlock.addRun(t))}).catch(t=>{e.shell.error(t)}).finally(()=>{tC(p.root,!1),p.close();let t=new e_(c,{fallbackText:"No runs uploaded",showActions:!0,showBatchActions:!0});h.add(t),h.show({modal:!0,fullScreen:!0})})}).call(this)),p.addButton("Next",()=>{p.close(),c.forEach(t=>{t.options.immutable_tags?t.options.immutable_tags.push(tK):t.options.immutable_tags=[tK]});let t=new e_(c,{fallbackText:"No runs uploaded",showActions:!0,showBatchActions:!0});h.add(t.root),h.show({modal:!0,fullScreen:!0})}),w()(p.getButton("CANCEL")).hide(),p.getButton(m).disabled=!0,p.getButton("Next").disabled=!0,w()(h.getButton("CANCEL")).hide(),h.addButton("Simulate w/ same inputs",()=>{tC(p.root,!0),Promise.all(c.map(t=>nu(function*(){return(yield eB(t)).call()})())).then(e=>{d=e,h.close(),t().show({modal:!0,fullScreen:!0})}).catch(t=>{e.shell.error(t)}).finally(()=>{tC(p.root,!1)})}),h.addButton("Compare w/ history",()=>{h.close(),t().show({modal:!0,fullScreen:!0})});let y=e.functions.onAfterRunAction.pipe((0,l.filter)(t=>t.id===u.id)).subscribe(()=>{c=u.outputs.uploadedCalls,p.getButton(m).disabled=!1,p.getButton("Next").disabled=!1}),g=p.onClose.subscribe(()=>{this.isUploadMode.next(!1)});p.subs.push(g,y),p.show({modal:!0,center:!0,resizable:!0})}).call(this)}onSaveClick(){return nu(function*(){this.isUploadMode.value?yield this.saveExperimentalRun(this.funcCall):yield this.saveRun(this.funcCall)}).call(this)}buildRibbonPanels(){super.buildRibbonPanels();let t=r.iconFA("play",()=>nu(function*(){return yield this.doRun()}).call(this),"Run computations");t.classList.add("fas");let n=r.iconFA("arrow-to-top",()=>nu(function*(){this.uploadFunc?yield this.processCustomDataUpload():(this.isUploadMode.next(!this.isUploadMode.value),n.classList.toggle("d4-current"))}).call(this),"Upload experimental data");n.classList.add("d4-toggle-button",...this.isUploadMode.value?["d4-current"]:[]);let i=r.iconFA("info",()=>nu(function*(){this.hasContextHelp&&(e.shell.windows.help.visible=!0,yield new Promise(t=>setTimeout(t,100)),e.shell.windows.help.showHelp(r.markdown((yield this.getContextHelp()))))}).call(this),"Info"),o=[[...super.buildRibbonPanels().flat(),...this.runningOnInput||this.options.isTabbed?[]:[t],...this.hasUploadMode?[n]:[],...!this.options.isTabbed&&this.hasContextHelp?[i]:[]]];return this.setRibbonPanels(o),o}showOutput(){r.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=>{let n=np(this.categoryToDfParamMap.outputs[t]?[this.categoryToDfParamMap.outputs[t],!1]:[this.categoryToDfParamMap.inputs[t],!0],2),i=n[0],a=n[1],u=i.filter(t=>t.propertyType===o.TYPE.DATA_FRAME||t.propertyType===o.TYPE.GRAPHICS),c=i.filter(t=>t.propertyType!==o.TYPE.DATA_FRAME&&t.propertyType!==o.TYPE.GRAPHICS),d=u.map(t=>te(t).config),p="",h=u.reduce((t,n,i)=>{var s,u;this.dfToViewerMapping[n.name]=[];let c=d[i].map((t,i)=>nu(function*(){var i,s,l,a;let u=null!=(i=null!=(s=null==(l=this.funcCall.outputs[n.name])?void 0:l.value)?s:null==(a=this.funcCall.inputParams[n.name])?void 0:a.value)?i:e.data.demo.demog(0),c=t.type,d=Object.values(S).includes(c)?o.Viewer.fromType(c,u):yield u.plot.fromType(c);d.setOptions(t),this.dfToViewerMapping[n.name].push(d),this.afterOutputPropertyRender.next({prop:n,output:d});let p=nh();return 0===u.rowCount&&"demog 0"===u.name&&(r.setDisplay(d.root,!1),r.setDisplay(p,!0)),{viewer:d,stub:p}}).call(this)).map((t,e)=>t.then(t=>{let o=t.viewer,s=t.stub,a=()=>nu(function*(){var t;let l=null!=(t=this.funcCall.outputParams[n.name])?t:this.funcCall.inputParams[n.name];if(l.value){if(r.setDisplay(o.root,!0),r.setDisplay(s,!1),Object.values(S).includes(o.type))o.dataFrame=l.value;else{let t=yield l.value.plot.fromType(o.type);o.root.replaceWith(t.root),o=t}try{d[i][e]&&o.setOptions(d[i][e])}catch(t){console.error("Error setting viewer properties: ",t)}Object.keys(d[i][e]).includes("color")&&o.setOptions({color:d[i][e].color}),this.afterOutputPropertyRender.next({prop:n,output:o})}else r.setDisplay(o.root,!1),r.setDisplay(s,!0)}).call(this),u=this.funcCallReplaced.pipe((0,l.startWith)(null),(0,l.switchMap)(()=>{var t;return(null!=(t=this.funcCall.outputParams[n.name])?t:this.funcCall.inputParams[n.name]).onChanged.pipe((0,l.startWith)(null))}),(0,l.skip)(1)).subscribe(a);return this.subs.push(u),{loadedViewer:o,stub:s}})),h=p!==(null!=(s=n.options.caption)?s:n.name)?null!=(u=n.options.caption)?u:n.name:" ";if(p=h,a){let t=this.funcCallReplaced.pipe((0,l.switchMap)(()=>{var t;return(null!=(t=this.funcCall.outputParams[n.name])?t:this.funcCall.inputParams[n.name]).onChanged})).subscribe(()=>{this.showOutput(),this.inputTabsLabels.forEach(t=>{w()(this.tabsElem.getPane(t).header).show()})});this.subs.push(t)}let f=c.map((t,e)=>{let o=d[i][e].block,s=r.wait(()=>nu(function*(){let e=yield t;return w()(e.loadedViewer.root).css({height:"100%",width:"100%"}),r.divV([e.loadedViewer.root,e.stub],{style:{width:"100%"}})})());w()(s).css({"min-height":"300px","flex-grow":"1"});let l=ex();return this.outputValidationSigns[n.name]=l,r.divV([r.divH([r.h2(0===e?h:" ",{style:{whiteSpace:"pre"}}),...0===e?[r.div([this.outputValidationSigns[n.name][0],this.outputValidationSigns[n.name][1]],{style:{margin:"10.79px"}})]:[]]),s],{style:nc({},o?{width:`${o}%`,"max-width":`${o}%`,"max-height":"100%"}:{"flex-grow":"1"})})});if(n.propertyType===o.TYPE.GRAPHICS){let e=n.options.block,i=nh();i.classList.add("grok-scripting-image-container");let o=r.divV([r.h2(h,{style:{whiteSpace:"pre"}}),i],{style:nc({},e?{width:`${e}%`,"max-width":`${e}%`,"max-height":"100%"}:{"flex-grow":"1"})}),s=()=>{var t;let e=null!=(t=this.funcCall.outputParams[n.name])?t:this.funcCall.inputParams[n.name];e.value?(i.style.backgroundImage=`url("data:image/png;base64,${e.value}")`,i.textContent=""):(i.style.removeProperty("background-image"),i.textContent="[No data to display]")},a=this.funcCallReplaced.pipe((0,l.startWith)(null),(0,l.switchMap)(()=>{var t;return(null!=(t=this.funcCall.outputParams[n.name])?t:this.funcCall.inputParams[n.name]).onChanged.pipe((0,l.startWith)(null))}),(0,l.skip)(1)).subscribe(s);this.subs.push(a),t.append(o)}return t.append(...f),t},r.divH([],{style:{flexWrap:"wrap",flexGrow:"1",maxHeight:"100%"}}));c.forEach(t=>{let e=ex();this.outputValidationSigns[t.name]=e});let f=()=>{let t=o.HtmlTable.create(c,t=>{var e;let n=t.options.precision,i=n&&t.propertyType===o.TYPE.FLOAT&&this.funcCall.outputs[t.name]?this.funcCall.outputs[t.name].toPrecision(n):this.funcCall.outputs[t.name],s=t.options.units?` [${t.options.units}]`:"";return[`${null!=(e=t.caption)?e:t.name}${s}`,null!=i?i:"[No value]",r.div([this.outputValidationSigns[t.name][0],this.outputValidationSigns[t.name][1]])]}).root;return w()(t).addClass("rfv-scalar-table"),this.afterOutputSacalarTableRender.next(t),t},m=f(),v=(0,s.merge)(this.funcCallReplaced,this.isRunning.pipe((0,l.filter)(t=>!1===t),(0,l.skip)(1))).subscribe(()=>{let e=f();m.replaceWith(e),m=e,w()(this.tabsElem.getPane(t).header).show()});this.subs.push(v),this.tabsElem.addPane(t,()=>r.divV([...u.length?[h]:[],...c.length?[m]:[]]))});let t=r.box();return t.append(this.tabsElem.root),t}onAfterLoadRun(t){return nu(function*(){this.showOutput()}).call(this)}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(){var t;let e;return t=this.funcCall.func,e={inputs:{},outputs:{}},t.inputs.filter(t=>t.propertyType===o.TYPE.DATA_FRAME&&0!==te(t).config.length).forEach(t=>{let n="Misc"===t.category?"Input":t.category;e.inputs[n]?e.inputs[n].push(t):e.inputs[n]=[t]}),t.outputs.forEach(t=>{let n="Misc"===t.category?"Output":t.category;(t.propertyType!==o.TYPE.DATA_FRAME||0!==te(t).config.length)&&(e.outputs[n]?e.outputs[n].push(t):e.outputs[n]=[t])}),e}get inputsStorage(){return`RFV_LastInputs_${this.funcCall.func.name}`}saveLastInputs(){return nu(function*(){try{let t=E()(this.funcCall.inputParams.values()).reduce((t,e)=>{let n=e.property.propertyType!==o.TYPE.DATA_FRAME?this.funcCall.inputs[e.name]:Array.from(this.funcCall.inputs[e.name].toByteArray());return nd(nc({},t),{[e.name]:n})},{});return localStorage.setItem(this.inputsStorage,JSON.stringify(t))}catch(t){e.shell.error(t.toString())}}).call(this)}loadLastInputs(){return nu(function*(){try{var t;let e=JSON.parse(null!=(t=localStorage.getItem(this.inputsStorage))?t:"{}");if(0===Object.keys(e).length)return null;return E()(this.funcCall.inputParams.values()).reduce((t,n)=>{let i=n.property.propertyType!==o.TYPE.DATA_FRAME?e[n.name]:o.DataFrame.fromByteArray(new Uint8Array(e[n.name]));return nd(nc({},t),{[n.name]:i})},{})}catch(t){e.shell.error(t.toString())}}).call(this)}deleteLastInputs(){return nu(function*(){try{return localStorage.removeItem(this.inputsStorage)}catch(t){e.shell.error(t.toString())}}).call(this)}doRun(){return nu(function*(){this.isRunning.next(!0);try{this.options.isTabbed||(yield this.saveLastInputs()),yield this.run(),this.options.isTabbed||(yield this.deleteLastInputs())}catch(t){e.shell.error(t.toString()),console.log(t)}finally{this.isRunning.next(!1),this.inputValidationRequests.next({isRevalidation:!1,isNewOutput:!0}),this.outputValidationRequests.next({isRevalidation:!1})}}).call(this)}setExternalValidationResults(t,e){this.externalValidatorsState[t]=e,this.externalValidatorsUpdates.next(t)}saveInputLockState(t,e,n){"restricted"===n&&(this.funcCall.options[eE]=nd(nc({},this.funcCall.options[eE]),{[t]:e})),n&&(this.funcCall.options[eS]=nd(nc({},this.funcCall.options[eS]),{[t]:n})),this.updateConsistencyState()}getInputLockState(t){var e;return null==(e=this.funcCall.options[eS])?void 0:e[t]}updateConsistencyState(){let t=Object.values(this.funcCall.options[eS]).some(t=>"inconsistent"===t);this.consistencyState.next(t?"inconsistent":"consistent")}getInput(t){return this.inputsMap[t]}setInput(t,e,n){let i=this.getInput(t);if(!i)throw Error(`No input named ${t}`);if(this.funcCall.inputParams[t].property.propertyType===o.TYPE.DATA_FRAME&&"restricted"===n)throw Error(`Param ${t} is dataframe. Restricted state is not supported for them.`);n||(n=this.funcCall.inputParams[t].property.propertyType===o.TYPE.DATA_FRAME?"disabled":"restricted"),this.funcCall.inputs[t]=e,this.setInputLockState(i,t,e,n)}getParamChanges(t){return this.funcCallReplaced.pipe((0,l.startWith)(null),(0,l.filter)(()=>!!this.funcCall),(0,l.map)(()=>this.funcCall.inputParams[t]?"inputParams":"outputParams"),(0,l.switchMap)(e=>this.funcCall[e][t].onChanged.pipe((0,l.startWith)(null),(0,l.map)(()=>this.funcCall[e][t].value))))}getParamValue(t){var e,n;let i=(null==(e=this.funcCall)?void 0:e.inputParams[t])?"inputParams":"outputParams";return null==(n=this.funcCall)?void 0:n[i][t].value}setInputLockState(t,e,n,i){i&&this.saveInputLockState(e,n,i),ef(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[eE])?void 0:e[t]}renderOutputForm(){return this.renderIOForm(g.OUTPUTS)}renderInputForm(){return this.renderIOForm(g.INPUTS)}renderIOForm(t){let e=r.divH([],"ui-form ui-form-wide");w()(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",i=this.funcCall[eR[t]].values();return E()(i).filter(t=>!!t).forEach(i=>{let r=i.property;this.beforeInputPropertyRender.next(r);let o=this.getInputForVal(i);if(!o){n=r.category;return}this.inputsMap[i.property.name]=o,t===g.INPUTS&&(this.syncInput(i,o,t),this.checkForMapping(i,o),this.runningOnInput||this.disableInputsOnRun(i.property.name,o),this.bindOnHotkey(o)),this.renderCategory(e,i.property.category,n),this.renderInput(e,i,o),this.afterInputPropertyRender.next({prop:r,input:o}),n=r.category}),Object.keys(this.foldedCategoryInputs).forEach(t=>this.foldedCategoryInputs[t].forEach(t=>w()(t.input.root).hide())),e.classList.remove("ui-panel"),e}saveFocusedElement(t){this.focusedInput=t}restoreFocusedElement(){var t;null==(t=this.focusedInput)||t.focus()}disableInputsOnRun(t,e){let n=this.isRunning.subscribe(n=>{!("user input"!==this.getInputLockState(t)&&this.getInputLockState(t))&&(n?(eV(e)&&w()(e.input).is(":focus")&&this.saveFocusedElement(e.input),e.enabled=!1):(e.enabled=!0,eV(e)&&this.restoreFocusedElement()))});this.subs.push(n)}checkForMapping(t,e){if(!e.hasOwnProperty("_chosenRun"))return;let n=t.property.options.funccallMapping;if(!n)return;let i=JSON.parse(n),r=this.funcCallReplaced.pipe((0,l.startWith)(!0),(0,l.switchMap)(()=>this.funcCall.inputParams[t.property.name].onChanged)).subscribe(()=>{Object.entries(i).forEach(t=>{var n,i,r,o,s,l;let a=np(t,2),u=a[0],c=a[1];return this.setInput(u,e.chosenRun?null!=(n=null!=(i=null!=(r=null==(o=e.chosenRun)?void 0:o.inputs[c])?r:null==(s=e.chosenRun)?void 0:s.outputs[c])?i:null==(l=e.chosenRun)?void 0:l.options[c])?n:null:tw(this.funcCall.inputParams[u].property),e.chosenRun?"restricted":"user input")})});this.subs.push(r)}getInputForVal(t){var e,n;let i=t.property;if(this.inputsOverride[t.property.name])return this.inputsOverride[t.property.name];if(i.propertyType===o.TYPE.STRING&&i.options.choices&&!i.options.propagateChoice)return r.input.choice(null!=(e=i.caption)?e:i.name,{value:tw(i),items:JSON.parse(i.options.choices),nullable:i.nullable});switch(i.propertyType){case"file":return b.fileInput(null!=(n=i.caption)?n:i.name,null,null,null);case o.TYPE.FLOAT:let s=r.input.forProperty(i),l=i.options.format;return l&&(s.format=l),s;default:return r.input.forProperty(i)}}bindOnHotkey(t){eV(t)&&(t.input.onkeydown=t=>nu(function*(){"Enter"==t.key&&this.runRequests.next()}).call(this))}get foldedCategories(){var t;return JSON.parse(null!=(t=this.func.options.foldedCategories)?t:"[]")}getCategoryWarningIcon(t){let e=r.iconFA("exclamation-circle",null,"This category has inconsistent inputs");w()(e).css({color:"var(--orange-2)","padding-left":"5px"}).hide();let n=this.funcCallReplaced.subscribe(()=>{this.foldedCategoryInputs[t].some(t=>"inconsistent"===this.getInputLockState(t.paramName)&&t.input.value!==this.getRestrictedValue(t.paramName))?w()(e).show():w()(e).hide()});return this.subs.push(n),e}renderCategory(t,e,n){if(e!==n)if(this.foldedCategories.includes(e)){let n=this.getCategoryWarningIcon(e),i=r.iconFA("chevron-right",()=>{var t;w()(o).show(),w()(i).hide(),w()(n).hide(),(null!=(t=this.foldedCategoryInputs[e])?t:[]).forEach(t=>w()(t.input.root).css({display:""}))},"Open category");w()(i).css("padding-right","5px");let o=r.iconFA("chevron-down",()=>{var t;w()(o).hide(),w()(i).show(),this.foldedCategoryInputs[e].some(t=>"inconsistent"===this.getInputLockState(t.paramName))?w()(n).show():w()(n).hide(),(null!=(t=this.foldedCategoryInputs[e])?t:[]).forEach(t=>w()(t.input.root).hide())},"Close category");w()(o).css("padding-right","5px"),t.append(r.h2([i,o,r.h2(e,{style:{display:"inline"}}),n],{style:{width:"100%"}})),w()(o).hide()}else t.append(r.h2(e,{style:{width:"100%"}}))}renderInput(t,e,n){var i,o;let s=e.property;if(this.foldedCategories.includes(s.category)&&(this.foldedCategoryInputs[s.category]=[...null!=(i=this.foldedCategoryInputs[s.category])?i:[],{paramName:e.property.name,input:n}]),this.injectLockIcons(e,n),ef(n)||(n.setDisabled=function(){n.enabled=!1,w()(n.root).removeClass("rfv-restricted-unlocked-input"),w()(n.root).removeClass("rfv-inconsistent-input"),w()(n.root).removeClass("rfv-restricted-input")},n.setRestricted=function(){n.enabled=!1,w()(n.root).addClass("rfv-restricted-input"),w()(n.root).removeClass("rfv-restricted-unlocked-input"),w()(n.root).removeClass("rfv-inconsistent-input")},n.setRestrictedUnlocked=function(){n.enabled=!0,w()(n.root).addClass("rfv-restricted-unlocked-input"),w()(n.root).removeClass("rfv-restricted-input"),w()(n.root).removeClass("rfv-inconsistent-input")},n.setInconsistent=function(){n.enabled=!0,w()(n.root).addClass("rfv-inconsistent-input"),w()(n.root).removeClass("rfv-restricted-input"),w()(n.root).removeClass("rfv-restricted-unlocked-input")},n.setUserInput=function(){n.enabled=!0,w()(n.root).removeClass("rfv-inconsistent-input"),w()(n.root).removeClass("rfv-restricted-input"),w()(n.root).removeClass("rfv-restricted-unlocked-input")}),eV(n)){let t,i;t=e.property,w()(n.root).css({width:`calc(${null!=(o=t.options.block)?o:"100"}% - ${t.options.block?"2":"0"}px)`,"box-sizing":"border-box"}),this.bindTooltips(e,n),i=r.element("i"),n.addOptions(i),n.setValidation=function(t){for(;i.firstChild&&i.removeChild(i.firstChild););let e=eF(ex(t),2),r=e[0],o=e[1];r&&o&&(i.appendChild(r),i.appendChild(o)),n.input.classList.remove("d4-invalid"),n.input.classList.remove("d4-partially-invalid"),(null==t?void 0:t.errors)&&t.errors.length||(null==t?void 0:t.warnings)&&t.warnings.length||(null==t?void 0:t.notifications)&&t.notifications.length||(null==t?void 0:t.pending)?w()(i).css("display","flex"):w()(i).hide(),(null==t?void 0:t.errors)&&t.errors.length?n.input.classList.add("d4-invalid"):(null==t?void 0:t.warnings)&&t.warnings.length&&n.input.classList.add("d4-partially-invalid")}}t.append(n.root)}bindTooltips(t,e){let n=t.property.name,i=()=>{var e,i;let o=`${null!=(e=null!=(i=t.property.description)?i:t.property.caption)?e:t.property.name}.`,s="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 o||s?r.divV([...o?[r.divText(o)]:[],...s?[r.divText(s)]:[]],{style:{maxWidth:"300px"}}):null};r.tooltip.bind(e.captionLabel,i),r.tooltip.bind(e.input,i)}injectLockIcons(t,e){let n=t.property.name;e.root.addEventListener("click",()=>{"restricted"===this.getInputLockState(n)&&this.setInputLockState(e,t.name,t.value,"restricted unlocked")});let i=r.iconFA("lock");w()(i).addClass("rfv-icon-lock"),w()(i).css({color:"var(--grey-2)"});let s=r.iconFA("lock-open");w()(s).addClass("rfv-icon-unlock"),w()(s).css({color:"var(--grey-2)"});let l=r.iconFA("undo",e=>{this.setInput(t.name,this.getRestrictedValue(n),"restricted"),e.stopPropagation()},"Reset value to computed value");w()(l).addClass("rfv-icon-undo"),w()(l).css({color:"var(--blue-2)"});let a=r.iconFA("exclamation-circle",null,"Validation");r.tooltip.bind(a,()=>`Current value is incosistent. Computed value was ${o.TYPES_SCALAR.has(t.property.propertyType)?this.getRestrictedValue(n):"different"}`),w()(a).addClass("rfv-icon-warning"),w()(a).css({color:"var(--orange-2)"}),e.placeLockStateIcons||(e.placeLockStateIcons=function(t,n,i,r){eV(e)&&(e.addOptions(t),e.addOptions(n),e.addOptions(i),e.addOptions(r))}),e.placeLockStateIcons(i,s,l,a)}syncInput(t,e,n){var i;let r=t.name,a=!1,u=this.funcCallReplaced.pipe((0,l.startWith)(!0)).subscribe(()=>{var t,i;let o=this.funcCall[eR[n]][r],s=null!=(t=null!=(i=this.funcCall[n][r])?i:tw(o.property))?t:null;e.notify=!1,e.value=s,e.notify=!0,this.funcCall[n][r]=s,this.setInputLockState(e,r,s,this.getInputLockState(r))});this.subs.push(u);let c=this.funcCallReplaced.pipe((0,l.startWith)(!0),(0,l.switchMap)(()=>{let t=this.funcCall[eR[n]][r];return t.onChanged.pipe((0,l.mapTo)(t))})).subscribe(t=>{let i=this.funcCall[n][t.name];if(a||(e.notify=!1,e.value=i,e.notify=!0),n===g.INPUTS){this.isHistorical.next(!1),this.hideOutput(),this.inputValidationRequests.next({field:t.name,isRevalidation:!1});let 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(c);let d=this.funcCallReplaced.pipe((0,l.startWith)(!0),(0,l.switchMap)(()=>{let t=this.funcCall[eR[n]][r];return t.onChanged.pipe((0,l.mapTo)(t),(0,l.startWith)(t))}),(0,l.filter)(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&t.value),(0,l.switchMap)(t=>t.value.onDataChanged.pipe((0,l.mapTo)(t)))).subscribe(t=>{n===g.INPUTS?this.inputValidationRequests.next({field:t.name,isRevalidation:!1}):this.outputValidationRequests.next({field:t.name,isRevalidation:!1})});this.subs.push(d);let p=(eV(e)?e.onInput:(i=e.onInput.bind(e),new s.Observable(t=>{let e=i(e=>{t.next(e)});return()=>e.unsubscribe()}))).pipe((0,l.debounceTime)(250)).subscribe(()=>{try{a=!0,this.funcCall[n][t.name]=e.value}finally{a=!1}});this.subs.push(p)}isRunnable(){return!this.isRunning.value&&!this.blockRuns.value&&this.isValid()}isValid(){var t=!0,e=!1,n=void 0;try{for(var i,r=Object.entries(this.inputValidationState)[Symbol.iterator]();!(t=(i=r.next()).done);t=!0){let t=np(i.value,2),e=(t[0],t[1]);if(!ey(e))return!1}}catch(t){e=!0,n=t}finally{try{t||null==r.return||r.return()}finally{if(e)throw n}}var o=!0,s=!1,l=void 0;try{for(var a,u=Object.entries(this.externalValidatorsState)[Symbol.iterator]();!(o=(a=u.next()).done);o=!0){let t=np(a.value,2),e=(t[0],t[1]);if(!ey(e))return!1}}catch(t){s=!0,l=t}finally{try{o||null==u.return||u.return()}finally{if(s)throw l}}return!0}getValidationState(){return this.inputValidationState}getValidationMessage(){let t=[];var e=!0,n=!1,i=void 0;try{for(var r,o=Object.entries(this.inputValidationState)[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){let e=np(r.value,2),n=e[0],i=e[1];ey(i)||t.push(`${n}: ${function(t){if(null==t?void 0:t.errors)return t.errors.map(t=>t.description).join("; ")}(i)}`)}}catch(t){n=!0,i=t}finally{try{e||null==o.return||o.return()}finally{if(n)throw i}}return t.join("\n")}runValidation(t,e){return nu(function*(t,e,n){let i,r,o=void 0===n?g.INPUTS:n,s=t.field,l=this.getValidatedNames(s,o);return i={view:this,funcCall:this.funcCall,lastCall:this.lastCall},r=o===g.INPUTS?this.inputValidators:this.outputValidators,eP(function*(){let n=i.view,s=i.funcCall,a=i.lastCall;return Object.fromEntries((yield Promise.all(l.map(i=>eP(function*(){var l;let u,c=o===g.INPUTS?s.inputs[i]:s.outputs[i],d=yield(t.isNewOutput,t.isRevalidation,(l=function*(){if(null==c)return eb({errors:["Missing value"]})},function(){var t=this,e=arguments;return new Promise(function(n,i){var r=l.apply(t,e);function o(t){em(r,n,i,o,s,"next",t)}function s(t){em(r,n,i,o,s,"throw",t)}o(void 0)})})()),p=r[i];p&&(u=yield p(c,{param:i,funcCall:s,lastCall:a,signal:e,isNewOutput:!!t.isNewOutput,isRevalidation:t.isRevalidation,context:t.context,view:n}));let h=o===g.INPUTS&&s.inputParams[i].property.options.nullable;return[i,ew(...h?[]:[d],u)]})()))))})()}).apply(this,arguments)}setInputValidationPending(t){let e=this.getValidatedNames(t);var n=!0,i=!1,r=void 0;try{for(var o,s=e[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let t=o.value;this.inputValidationState[t]=eC();let e=this.inputsMap[t];eh(e)&&e.setValidation(eC())}}catch(t){i=!0,r=t}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}this.inputValidationUpdates.next(null)}setOutputValidationPending(t){let e=this.getValidatedNames(t,g.OUTPUTS);var n=!0,i=!1,r=void 0;try{for(var o,s=e[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let t=o.value;this.outputValidationState[t]=eC();let e=this.outputValidationSigns[t];if(e){let n=ex(eC());e[0].replaceWith(n[0]),e[1].replaceWith(n[1]),this.outputValidationSigns[t]=n}}}catch(t){i=!0,r=t}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}this.outputValidationUpdates.next(null)}setInputValidationResults(t){var e=!0,n=!1,i=void 0;try{for(var r,o=Object.entries(t)[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){let t=np(r.value,2),e=t[0],n=t[1];this.inputValidationState[e]=n,this.updateInputValidationResults(e)}}catch(t){n=!0,i=t}finally{try{e||null==o.return||o.return()}finally{if(n)throw i}}}setOutputValidationResults(t){var e=!0,n=!1,i=void 0;try{for(var r,o=Object.entries(t)[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){let t=np(r.value,2),e=t[0],n=t[1];this.outputValidationState[e]=n,this.updateOutputValidationResults(e)}}catch(t){n=!0,i=t}finally{try{e||null==o.return||o.return()}finally{if(n)throw i}}}updateOutputValidationResults(t){let e,n=this.outputValidationState[t],i=this.outputValidationSigns[t];i&&(this.outputValidationSigns[t]=(e=ex(n),i[0].replaceWith(e[0]),i[1].replaceWith(e[1]),e))}updateInputValidationResults(t){let e=ew(this.inputValidationState[t],this.externalValidatorsState[t]),n=this.inputsMap[t];eh(n)&&n.setValidation(e)}runRevalidations(t,e,n){let i=void 0===n?g.INPUTS:n;if(!t.isRevalidation){var r=!0,o=!1,s=void 0;try{for(var l,a=Object.entries(e)[Symbol.iterator]();!(r=(l=a.next()).done);r=!0){let t=np(l.value,2)[1];if(null==t?void 0:t.revalidate){var u=!0,c=!1,d=void 0;try{for(var p,h=t.revalidate[Symbol.iterator]();!(u=(p=h.next()).done);u=!0){let e=p.value;i===g.INPUTS?this.inputValidationRequests.next({field:e,context:t.context,isRevalidation:!0}):this.outputValidationRequests.next({field:e,context:t.context,isRevalidation:!0})}}catch(t){c=!0,d=t}finally{try{u||null==h.return||h.return()}finally{if(c)throw d}}}}}catch(t){o=!0,s=t}finally{try{r||null==a.return||a.return()}finally{if(o)throw s}}}}getValidatedNames(t,e){let n=void 0===e?g.INPUTS:e;return t?[t]:[...n===g.INPUTS?this.funcCall.inputs.keys():this.funcCall.outputs.keys()]}getValidExpRun(t){return nu(function*(){t.started=x()();let e=t.options.immutable_tags||[];return t.options.immutable_tags=e.includes(tK)?e:[...e,tK],t.newId(),t})()}saveExperimentalRun(t){return nu(function*(){let e=yield this.getValidExpRun(t);yield this.saveRun(e)}).call(this)}hideOutput(){if(this._isOutputOutdated.next(!0),this.keepOutput())return;this.outputTabsLabels.forEach(t=>{var e;return w()(null==(e=this.tabsElem.getPane(t))?void 0:e.header).hide()});let t=this.tabsElem.panes.find(t=>this.inputTabsLabels.includes(t.name));t?this.tabsElem.currentPane=t:w()(this.tabsElem.root).hide()}richFunctionViewSupportedFormats(){return["Excel"]}richFunctionViewExportExtensions(){return{Excel:"xlsx"}}constructor(t,n){var i;let a=void 0===n?{historyEnabled:!0,isTabbed:!1}:n;super(t,a),i=this,this.options=a,this.inputValidationRequests=new s.Subject,this.outputValidationRequests=new s.Subject,this.inputValidationUpdates=new s.Subject,this.outputValidationUpdates=new s.Subject,this.runRequests=new s.Subject,this.isRunning=new s.BehaviorSubject(!1),this.isUploadMode=new s.BehaviorSubject(!1),this.inputsOverride={},this.inputsMap={},this.outputValidationSigns={},this.inputValidators={},this.outputValidators={},this.inputValidationState={},this.outputValidationState={},this.externalValidatorsUpdates=new s.Subject,this.externalValidatorsState={},this.pendingInputValidations=this.inputValidationUpdates.pipe((0,l.startWith)(null),(0,l.map)(()=>this.inputValidationState)),this._isOutputOutdated=new s.BehaviorSubject(!0),this.isOutputOutdated=this._isOutputOutdated.pipe((0,l.distinctUntilChanged)()),this.blockRuns=new s.BehaviorSubject(!1),this.prevOpenedTab=null,this.beforeInputPropertyRender=new s.Subject,this.afterInputPropertyRender=new s.Subject,this.afterOutputPropertyRender=new s.Subject,this.afterOutputSacalarTableRender=new s.Subject,this.formButtons=r.div(),this.additionalBtns=[],this.navBtns=[],this.tabsElem=r.tabControl(),this.dfToViewerMapping={},this.focusedInput=null,this.foldedCategoryInputs={},this.richFunctionExport=t=>nu(function*(){let n,a,u,c,d;if(!i.lastCall)throw Error("Function was not called");if(!i.exportConfig.supportedFormats.includes(t))throw Error(`Format "${t}" is not supported.`);if(!i.func)throw Error("The correspoding function is not specified");return np((yield(n=i.func,a=i.lastCall,u=i.dfToViewerMapping,e6(function*(){let i={},p=(t,e)=>{if(i[t])return i[t];let n=`${t}`;n.length>31&&(n=`${n.slice(0,31)}`);let r=1;for(;e.worksheets.some(t=>t.name.toLowerCase()===n.toLowerCase());){let e=`${t}`;e.length>31-`-${r}`.length&&(e=`${t.slice(0,31-`-${r}`.length)}`),n=`${e}-${r}`,r++}return i[t]=n,n};if("Excel"===t)try{yield o.Utils.loadJsCss(["/js/common/exceljs.min.js","/js/common/html2canvas.min.js"]);let t=window.ExcelJS,i=window.html2canvas,U=new t.Workbook;r.setDisplay(e.shell.v.root,!1),e9(e.shell.v.root.parentElement,!0,"Generating report. Please do not switch the browser tab...");let H=[],W=t=>t.propertyType===o.TYPE.DATA_FRAME,Y=n.inputs.filter(t=>W(t)),G=n.inputs.filter(t=>{let e;return e=t.propertyType,o.TYPES_SCALAR.has(e)}),q=n.outputs.filter(t=>W(t)),J=n.outputs.filter(t=>{let e;return e=t.propertyType,o.TYPES_SCALAR.has(e)});if(Y.forEach(t=>{var e;let n=a.inputs[t.name];if(ns(n))return;let i=t.options.caption||t.name,r=null!=(e=U.worksheets.find(t=>t.name===p(i,U)))?e:U.addWorksheet(p(i,U)),o=null==c?void 0:c[t.name],s=null==d?void 0:d[t.name];nr({sheet:r,df:n,validation:o,consistency:s})}),G.length){let t=U.addWorksheet("Input scalars");ne(t,G.map(t=>{var e,n,i;return{name:t.name,caption:null!=(e=t.options.caption)?e:t.name,value:null!=(n=a.inputs[t.name])?n:"",units:null!=(i=t.options.units)?i:"",format:t.format||(t.propertyType===o.TYPE.FLOAT?"G7":"#0.###")}}),c,d)}if(q.forEach(t=>{var e;let n=a.outputs[t.name];if(ns(n))return;let i=t.options.caption||t.name,r=null!=(e=U.worksheets.find(t=>t.name===p(i,U)))?e:U.addWorksheet(p(i,U)),o=null==c?void 0:c[t.name],s=null==d?void 0:d[t.name];nr({sheet:r,df:n,validation:o,consistency:s})}),J.length){let t=U.addWorksheet("Output scalars");ne(t,J.map(t=>{var e,n,i;return{name:t.name,caption:null!=(e=t.options.caption)?e:t.name,value:null!=(n=a.outputs[t.name])?n:"",units:null!=(i=t.options.units)?i:"",format:t.format||"#0.###"}}),c,d)}var h=!0,f=!1,m=void 0;try{for(var v,y=n.outputs.filter(t=>t.propertyType===o.TYPE.GRAPHICS)[Symbol.iterator]();!(h=(v=y.next()).done);h=!0){let t=v.value,e=a.outputs[t.name];if(null==e||""===e)continue;let n=t.options.caption||t.name,i=U.addWorksheet(p(n,U)),r=yield no(e),o=r.dataUrl,s=r.width,l=r.height;i.addImage(U.addImage({base64:o,extension:"png"}),{tl:{col:0,row:0},ext:{width:s,height:l}})}}catch(t){f=!0,m=t}finally{try{h||null==y.return||y.return()}finally{if(f)throw m}}var g=!0,b=!1,w=void 0;try{for(var C,A=n.inputs.filter(t=>W(t))[Symbol.iterator]();!(g=(C=A.next()).done);g=!0){let t=C.value,e=a.inputs[t.name];if(ns(e))continue;let n=(null!=(R=u[t.name])?R:[]).filter(t=>t&&t.type!==o.VIEWER.GRID).filter(t=>Object.values(S).includes(t.type));if(0===n.length)continue;let i=t.options.caption||t.name;var x=!0,I=!1,E=void 0;try{for(var R,T,O=n.entries()[Symbol.iterator]();!(x=(T=O.next()).done);x=!0){let t=e8(T.value,2),n=t[0],r=t[1];H.push({sheet:U.getWorksheet(p(i,U)),viewer:r,col:e.columns.length+2,row:n*e7})}}catch(t){I=!0,E=t}finally{try{x||null==O.return||O.return()}finally{if(I)throw E}}}}catch(t){b=!0,w=t}finally{try{g||null==A.return||A.return()}finally{if(b)throw w}}var P=!0,F=!1,V=void 0;try{for(var B,D=n.outputs.filter(t=>W(t))[Symbol.iterator]();!(P=(B=D.next()).done);P=!0){let t=B.value,e=a.outputs[t.name];if(ns(e))continue;let n=(null!=(M=u[t.name])?M:[]).filter(t=>t&&t.type!==o.VIEWER.GRID).filter(t=>Object.values(S).includes(t.type));if(0===n.length)continue;let i=t.options.caption||t.name;var k=!0,j=!1,L=void 0;try{for(var M,N,_=n.entries()[Symbol.iterator]();!(k=(N=_.next()).done);k=!0){let t=e8(N.value,2),n=t[0],r=t[1];if(r)if(r.type===o.VIEWER.STATISTICS){let t=e.columns.length,r=o.DataFrame.fromColumns([o.Column.string("Name",t).init(t=>e.columns.byIndex(t).name),o.Column.int("Values",t).init(t=>e.columns.byIndex(t).stats.valueCount),o.Column.int("Nulls",t).init(t=>e.columns.byIndex(t).stats.missingValueCount),o.Column.float("Min",t).init(t=>e.columns.byIndex(t).stats.min),o.Column.float("Max",t).init(t=>e.columns.byIndex(t).stats.max),o.Column.float("Avg",t).init(t=>e.columns.byIndex(t).stats.avg),o.Column.float("Stdev",t).init(t=>e.columns.byIndex(t).stats.stdev)]);nr({sheet:U.getWorksheet(p(i,U)),df:r,column:e.columns.length+2,row:n*e7})}else H.push({sheet:U.getWorksheet(p(i,U)),viewer:r,col:e.columns.length+2,row:n*e7})}}catch(t){j=!0,L=t}finally{try{k||null==_.return||_.return()}finally{if(j)throw L}}}}catch(t){F=!0,V=t}finally{try{P||null==D.return||D.return()}finally{if(F)throw V}}yield e6(function*(){let t=H.filter(t=>{let e=t.viewer;return null==e?void 0:e.dataFrame}).map(t=>{var e,n;let i=o.Viewer.fromType(t.viewer.type,t.viewer.dataFrame.clone());i.copyViewersLook(t.viewer);let a=r.div(i.root,{style:{width:"1280px",height:"720px",flex:"none"}});return a.classList.add("ui-box"),a.classList.remove("ui-div"),e=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}({},t),n={newViewer:i,box:a,rendered:(0,s.race)(i.onViewerRendered.pipe((0,l.take)(1),(0,l.switchMap)(()=>(0,s.interval)(10)),(0,l.filter)(()=>!i.isRenderPending)),(0,s.timer)(2e3)).pipe((0,l.take)(1)).toPromise()},n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e});try{e.shell.v.root.after(...t.map(t=>t.box)),yield Promise.all(t.map(t=>t.rendered));var n=!0,a=!1,u=void 0;try{for(var c,d=t[Symbol.iterator]();!(n=(c=d.next()).done);n=!0){let t=c.value,e=t.sheet,n=t.box,r=t.col,o=t.row,s=yield i(n,{logging:!1,ignoreElements:t=>!t.contains(n)&&!n.contains(t)&&!document.head.contains(t)});e.addImage(U.addImage({base64:s.toDataURL(),extension:"png"}),{tl:{col:r,row:o},ext:{width:1280,height:720}})}}catch(t){a=!0,u=t}finally{try{n||null==d.return||d.return()}finally{if(a)throw u}}}finally{var p=!0,h=!1,f=void 0;try{for(var m,v=t[Symbol.iterator]();!(p=(m=v.next()).done);p=!0){let t=m.value,e=t.box,n=t.newViewer;e.remove(),n.detach()}}catch(t){h=!0,f=t}finally{try{p||null==v.return||v.return()}finally{if(h)throw f}}}})();let z=yield U.xlsx.writeBuffer();return[new Blob([z],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"}),U]}finally{r.setDisplay(e.shell.v.root,!0),e9(e.shell.v.root.parentElement,!1)}throw Error("Format is not supported")})())),1)[0]})(),this.exportConfig={supportedExtensions:this.richFunctionViewExportExtensions(),supportedFormats:this.richFunctionViewSupportedFormats(),export:this.richFunctionExport,filename:this.defaultExportFilename}}}var nm=Uint8Array,nv=Uint16Array,ny=Uint32Array,ng=new nm([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]),nb=new nm([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]),nw=new nm([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),nC=function(t,e){for(var n=new nv(31),i=0;i<31;++i)n[i]=e+=1<<t[i-1];for(var r=new ny(n[30]),i=1;i<30;++i)for(var o=n[i];o<n[i+1];++o)r[o]=o-n[i]<<5|i;return[n,r]},nA=nC(ng,2),nx=nA[0],nI=nA[1];nx[28]=258,nI[258]=28;for(var nE=nC(nb,0),nS=(nE[0],nE[1]),nR=new nv(32768),nT=0;nT<32768;++nT){var nO=(43690&nT)>>>1|(21845&nT)<<1;nO=(61680&(nO=(52428&nO)>>>2|(13107&nO)<<2))>>>4|(3855&nO)<<4,nR[nT]=((65280&nO)>>>8|(255&nO)<<8)>>>1}for(var nP=function(t,e,n){for(var i,r=t.length,o=0,s=new nv(e);o<r;++o)t[o]&&++s[t[o]-1];var l=new nv(e);for(o=0;o<e;++o)l[o]=l[o-1]+s[o-1]<<1;if(n){i=new nv(1<<e);var a=15-e;for(o=0;o<r;++o)if(t[o])for(var u=o<<4|t[o],c=e-t[o],d=l[t[o]-1]++<<c,p=d|(1<<c)-1;d<=p;++d)i[nR[d]>>>a]=u}else for(o=0,i=new nv(r);o<r;++o)t[o]&&(i[o]=nR[l[t[o]-1]++]>>>15-t[o]);return i},nF=new nm(288),nT=0;nT<144;++nT)nF[nT]=8;for(var nT=144;nT<256;++nT)nF[nT]=9;for(var nT=256;nT<280;++nT)nF[nT]=7;for(var nT=280;nT<288;++nT)nF[nT]=8;for(var nV=new nm(32),nT=0;nT<32;++nT)nV[nT]=5;var nB=nP(nF,9,0),nD=nP(nV,5,0),nk=function(t){return(t+7)/8|0},nj=function(t,e,n){(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length);var i=new(2==t.BYTES_PER_ELEMENT?nv:4==t.BYTES_PER_ELEMENT?ny:nm)(n-e);return i.set(t.subarray(e,n)),i},nL=["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"],nM=function(t,e,n){var i=Error(e||nL[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,nM),!n)throw i;return i},nN=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>>8},n_=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},nU=function(t,e){for(var n=[],i=0;i<t.length;++i)t[i]&&n.push({s:i,f:t[i]});var r=n.length,o=n.slice();if(!r)return[nJ,0];if(1==r){var s=new nm(n[0].s+1);return s[n[0].s]=1,[s,1]}n.sort(function(t,e){return t.f-e.f}),n.push({s:-1,f:25001});var l=n[0],a=n[1],u=0,c=1,d=2;for(n[0]={s:-1,f:l.f+a.f,l:l,r:a};c!=r-1;)l=n[n[u].f<n[d].f?u++:d++],a=n[u!=c&&n[u].f<n[d].f?u++:d++],n[c++]={s:-1,f:l.f+a.f,l:l,r:a};for(var p=o[0].s,i=1;i<r;++i)o[i].s>p&&(p=o[i].s);var h=new nv(p+1),f=nH(n[c-1],h,0);if(f>e){var i=0,m=0,v=f-e,y=1<<v;for(o.sort(function(t,e){return h[e.s]-h[t.s]||t.f-e.f});i<r;++i){var g=o[i].s;if(h[g]>e)m+=y-(1<<f-h[g]),h[g]=e;else break}for(m>>>=v;m>0;){var b=o[i].s;h[b]<e?m-=1<<e-h[b]++-1:++i}for(;i>=0&&m;--i){var w=o[i].s;h[w]==e&&(--h[w],++m)}f=e}return[new nm(h),f]},nH=function(t,e,n){return -1==t.s?Math.max(nH(t.l,e,n+1),nH(t.r,e,n+1)):e[t.s]=n},n$=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new nv(++e),i=0,r=t[0],o=1,s=function(t){n[i++]=t},l=1;l<=e;++l)if(t[l]==r&&l!=e)++o;else{if(!r&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(r),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(r);o=1,r=t[l]}return[n.subarray(0,i),e]},nW=function(t,e){for(var n=0,i=0;i<e.length;++i)n+=t[i]*e[i];return n},nY=function(t,e,n){var i=n.length,r=nk(e+2);t[r]=255&i,t[r+1]=i>>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var o=0;o<i;++o)t[r+o+4]=n[o];return(r+4+i)*8},nG=function(t,e,n,i,r,o,s,l,a,u,c){nN(e,c++,n),++r[256];for(var d,p,h,f,m=nU(r,15),v=m[0],y=m[1],g=nU(o,15),b=g[0],w=g[1],C=n$(v),A=C[0],x=C[1],I=n$(b),E=I[0],S=I[1],R=new nv(19),T=0;T<A.length;++T)R[31&A[T]]++;for(var T=0;T<E.length;++T)R[31&E[T]]++;for(var O=nU(R,7),P=O[0],F=O[1],V=19;V>4&&!P[nw[V-1]];--V);var B=u+5<<3,D=nW(r,nF)+nW(o,nV)+s,k=nW(r,v)+nW(o,b)+s+14+3*V+nW(R,P)+(2*R[16]+3*R[17]+7*R[18]);if(B<=D&&B<=k)return nY(e,c,t.subarray(a,a+u));if(nN(e,c,1+(k<D)),c+=2,k<D){d=nP(v,y,0),p=v,h=nP(b,w,0),f=b;var j=nP(P,F,0);nN(e,c,x-257),nN(e,c+5,S-1),nN(e,c+10,V-4),c+=14;for(var T=0;T<V;++T)nN(e,c+3*T,P[nw[T]]);c+=3*V;for(var L=[A,E],M=0;M<2;++M)for(var N=L[M],T=0;T<N.length;++T){var _=31&N[T];nN(e,c,j[_]),c+=P[_],_>15&&(nN(e,c,N[T]>>>5&127),c+=N[T]>>>12)}}else d=nB,p=nF,h=nD,f=nV;for(var T=0;T<l;++T)if(i[T]>255){var _=i[T]>>>18&31;n_(e,c,d[_+257]),c+=p[_+257],_>7&&(nN(e,c,i[T]>>>23&31),c+=ng[_]);var U=31&i[T];n_(e,c,h[U]),c+=f[U],U>3&&(n_(e,c,i[T]>>>5&8191),c+=nb[U])}else n_(e,c,d[i[T]]),c+=p[i[T]];return n_(e,c,d[256]),c+p[256]},nq=new ny([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),nJ=new nm(0),nz=function(t,e,n,i,r,o){var s=t.length,l=new nm(i+s+5*(1+Math.ceil(s/7e3))+r),a=l.subarray(i,l.length-r),u=0;if(!e||s<8)for(var c=0;c<=s;c+=65535){var d=c+65535;d>=s&&(a[u>>3]=o),u=nY(a,u+1,t.subarray(c,d))}else{for(var p=nq[e-1],h=p>>>13,f=8191&p,m=(1<<n)-1,v=new nv(32768),y=new nv(m+1),g=Math.ceil(n/3),b=2*g,w=function(e){return(t[e]^t[e+1]<<g^t[e+2]<<b)&m},C=new ny(25e3),A=new nv(288),x=new nv(32),I=0,E=0,c=0,S=0,R=0,T=0;c<s;++c){var O=w(c),P=32767&c,F=y[O];if(v[P]=F,y[O]=P,R<=c){var V=s-c;if((I>7e3||S>24576)&&V>423){u=nG(t,a,0,C,A,x,E,S,T,c-T,u),S=I=E=0,T=c;for(var B=0;B<286;++B)A[B]=0;for(var B=0;B<30;++B)x[B]=0}var D=2,k=0,j=f,L=P-F&32767;if(V>2&&O==w(c-L))for(var M=Math.min(h,V)-1,N=Math.min(32767,c),_=Math.min(258,V);L<=N&&--j&&P!=F;){if(t[c+D]==t[c+D-L]){for(var U=0;U<_&&t[c+U]==t[c+U-L];++U);if(U>D){if(D=U,k=L,U>M)break;for(var H=Math.min(L,U-2),W=0,B=0;B<H;++B){var Y=c-L+B+32768&32767,G=v[Y],q=Y-G+32768&32767;q>W&&(W=q,F=Y)}}}F=v[P=F],L+=P-F+32768&32767}if(k){C[S++]=0x10000000|nI[D]<<18|nS[k];var J=31&nI[D],z=31&nS[k];E+=ng[J]+nb[z],++A[257+J],++x[z],R=c+D,++I}else C[S++]=t[c],++A[t[c]]}}u=nG(t,a,o,C,A,x,E,S,T,c-T,u),!o&&7&u&&(u=nY(a,u+1,nJ))}return nj(l,0,i+nk(u)+r)},nK=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,i=9;--i;)n=(1&n&&-0x12477ce0)^n>>>1;t[e]=n}return t}(),nZ=function(){var t=-1;return{p:function(e){for(var n=t,i=0;i<e.length;++i)n=nK[255&n^e[i]]^n>>>8;t=n},d:function(){return~t}}},nX=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},nQ=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},n0=function(t,e,n,i){for(var r in t){var o=t[r],s=e+r,l=i;Array.isArray(o)&&(l=nX(i,o[1]),o=o[0]),o instanceof nm?n[s]=[o,l]:(n[s+="/"]=[new nm(0),l],n0(o,s,n,i))}},n1="u">typeof TextEncoder&&new TextEncoder,n2="u">typeof TextDecoder&&new TextDecoder;try{n2.decode(nJ,{stream:!0})}catch(t){}function n3(t,e){if(e){for(var n=new nm(t.length),i=0;i<t.length;++i)n[i]=t.charCodeAt(i);return n}if(n1)return n1.encode(t);for(var r=t.length,o=new nm(t.length+(t.length>>1)),s=0,l=function(t){o[s++]=t},i=0;i<r;++i){if(s+5>o.length){var a=new nm(s+8+(r-i<<1));a.set(o),o=a}var u=t.charCodeAt(i);u<128||e?l(u):(u<2048?l(192|u>>6):(u>55295&&u<57344?(l(240|(u=65536+(1047552&u)|1023&t.charCodeAt(++i))>>18),l(128|u>>12&63)):l(224|u>>12),l(128|u>>6&63)),l(128|63&u))}return nj(o,0,s)}var n5=function(t){var e=0;if(t)for(var n in t){var i=t[n].length;i>65535&&nM(9),e+=i+4}return e},n4=function(t,e,n,i,r,o,s,l){var a=i.length,u=n.extra,c=l&&l.length,d=n5(u);nQ(t,e,null!=s?0x2014b50:0x4034b50),e+=4,null!=s&&(t[e++]=20,t[e++]=n.os),t[e]=20,e+=2,t[e++]=n.flag<<1|(o<0&&8),t[e++]=r&&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)&&nM(10),nQ(t,e,h<<25|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>>1),e+=4,-1!=o&&(nQ(t,e,n.crc),nQ(t,e+4,o<0?-o-2:o),nQ(t,e+8,n.size)),nQ(t,e+12,a),nQ(t,e+14,d),e+=16,null!=s&&(nQ(t,e,c),nQ(t,e+6,n.attrs),nQ(t,e+10,s),e+=14),t.set(i,e),e+=a,d)for(var f in u){var m=u[f],v=m.length;nQ(t,e,+f),nQ(t,e+2,v),t.set(m,e+4),e+=4+v}return c&&(t.set(l,e),e+=c),e},n6=function(t,e,n,i,r){nQ(t,e,0x6054b50),nQ(t,e+8,n),nQ(t,e+10,n),nQ(t,e+12,i),nQ(t,e+16,r)};"function"==typeof queueMicrotask&&queueMicrotask;var n8=n(510),n7={};function n9(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function it(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function ie(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){it(o,i,r,s,l,"next",t)}function l(t){it(o,i,r,s,l,"throw",t)}s(void 0)})}}function ii(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n,i,r=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var o=[],s=!0,l=!1;try{for(r=r.call(t);!(s=(n=r.next()).done)&&(o.push(n.value),!e||o.length!==e);s=!0);}catch(t){l=!0,i=t}finally{try{s||null==r.return||r.return()}finally{if(l)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return n9(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return n9(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}n7.styleTagTransform=tM(),n7.setAttributes=tD(),n7.insert=tV().bind(null,"head"),n7.domAPI=tP(),n7.insertStyleElement=tj(),tT()(n8.A,n7),n8.A&&n8.A.locals&&n8.A.locals;let ir=t=>{var e,n;return null!=(e=null==(n=t.options)?void 0:n.friendlyName)?e:t.func.name},io=t=>{var e;return null!=(e=t.customId)?e:t.funcName};function is(t){return ie(function*(){return{parentRun:yield f.loadRun(t),childRuns:yield e.dapi.functions.calls.allPackageVersions().include("func, func.package").filter(`options.parentCallId="${t}"`).list()}})()}function il(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function ia(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){il(o,i,r,s,l,"next",t)}function l(t){il(o,i,r,s,l,"throw",t)}s(void 0)})}}class iu extends o.ObjectHandler{get type(){return"Model"}get helpUrl(){return null}getById(t){return ia(function*(){return yield e.dapi.functions.find(t)})()}refresh(t){return ia(function*(){return yield this.getById(t.id)}).call(this)}static openHelp(t){return ia(function*(){let n=yield z(t);e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(r.markdown(null!=n?n:""))})()}static openModel(t){t.prepare().edit()}static openModelFromFunccall(t){t.edit()}static getUserGroups(){return ia(function*(){return yield e.dapi.groups.currentUserGroups()})()}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 n;let i=JSON.parse(t.options.versions?`${t.options.versions}`:"[]");if((null!=(n=null==i?void 0:i.length)?n:0)<2)return void e.shell.info("No other versions avaliable");let o=r.dialog({title:"Choose version"}),s=r.input.choice("Select version",{items:i,value:i[0]});o.add(s).onOK(()=>{let e=s.value;t.prepare({params:{version:e}}).edit()}),o.show()}isApplicable(t){var e,n,i=o.toJs(t);if(!(i instanceof o.Func))return!1;let r=(null!=(e=null==i||null==(n=i.options)?void 0:n.role)?e:"").split(",").includes("model"),s=i.hasTag("model");return r||s}getLanguageIcon(t){return"grok"==t?r.iconSvg("project"):r.iconImage("script",`/images/entities/${t}.png`)}renderMarkup(t){let n=r.divH([],{style:{justifyContent:"space-between",width:"100%"}});return setTimeout(()=>ia(function*(){let i=yield this.awaitUserGroups(),o=iu.getMissingGroups(t,i),s=o.length>0,l=r.iconFA("exclamation-triangle",null);l.classList.remove("grok-icon");let a=this.makeMandatoryGroupsInfo(o),u=r.span([this.renderIcon(t),r.label(t.friendlyName)]);if(n.onclick=()=>{e.shell.windows.help.visible&&iu.openHelp(t)},s?u.classList.add("d4-disabled"):n.ondblclick=()=>{iu.openModel(t)},s){var c;(c=a).popover="auto",c.style.cursor="default",c.style.padding="10px",c.style.background="#fdffe5",c.style.border="1px solid #E4E6CE",c.style.borderRadius="2px",c.style.boxShadow="0 0 5px #E4E6CE",c.style.maxWidth="500px",c.style.color="var(--gray-6)",document.body.append(a),n.addEventListener("click",()=>{var t,e;let n;t=l,e=a,n=t.getBoundingClientRect().toJSON(),e.style.inset="unset",e.style.top=n.y+"px",e.style.left=n.x+20+"px",a.showPopover()})}n.append(u),s&&n.append(r.span([l],{style:{paddingLeft:"10px"}}))}).call(this)),n}renderIcon(t){if(null!=t.options.icon&&(t.options.icon.startsWith("http://")||t.options.icon.startsWith("https://")))return r.iconImage("model-icon",t.options.icon);let e=K(t);if(t instanceof o.Script&&(null==e||null==t.options.icon))return this.getLanguageIcon(t.language);if(null==e||!(e=K(t=o.Func.find({package:e.name,name:t.name})[0])))return r.iconSvg("project");let n=e.getIconUrl();if(null!=t.options.icon){let e=n.split("/");e.pop(),e.push(t.options.icon),n=e.join("/")}return r.iconImage(e.name,n)}renderView(t){let e=r.div();return this.renderPreview(t).then(t=>e.appendChild(t.root)),e}renderPreview(t){var e=()=>super.renderPreview;return ia(function*(){let n=yield this.awaitUserGroups(),i=iu.getMissingGroups(t,n);if(!(null==i?void 0:i.length)&&("Compute2:TreeWizardEditor"===t.options.editor||"Compute2:RichFunctionViewEditor"===t.options.editor)){let e=t.prepare();return(yield o.Func.byName(t.options.editor).prepare({call:e}).call()).getOutputParamValue()}return o.View.fromViewAsync(()=>{var n=this;ia(function*(){var o,s,l;let a=yield z(t),u=yield e().call(n,t);u.name=(null!=(o=t.friendlyName)?o:t.name)+" preview";let c=(null==i?void 0:i.length)?this.makeMandatoryGroupsInfo(i):r.div([r.bigButton("Launch",()=>t.prepare().edit())]);return u.append(r.div([r.h1(null!=(s=t.friendlyName)?s:t.name),r.divText(null!=(l=t.description)?l:t.name,{style:{marginBottom:"10px"}}),c,r.div([],{style:{padding:"20px "}}),r.markdown(null!=a?a:"")],{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto"}})),u}).call(this)})}).call(this)}renderTooltip(t){let e=r.span([this.renderIcon(t),r.label(t.friendlyName)]);return e.classList.add("d4-link-label"),r.bind(t,r.divV([r.h2(e),r.divV([r.divText(t.description,"ui-description")],{style:{lineHeight:"150%"}})]))}renderCard(t){let e=this.renderMarkup(t);return e.classList.add("d4-link-label"),r.bind(t,r.h2(e))}init(){this.registerParamFunc("Choose version",t=>{iu.openVersionSelectDialog(o.toJs(t))}),this.registerParamFunc("Help",t=>{iu.openHelp(o.toJs(t))}),setTimeout(()=>ia(function*(){let t=yield iu.getUserGroups();this.userGroups.next(t)}).call(this))}makeMandatoryGroupsInfo(t){let n=r.div(r.divV([r.divText("You should be a member of the following group(s):","model-catalog-groups-title"),...t.map(t=>{let i;return r.divV([r.divH([((i=r.iconFA("user-friends")).classList.remove("grok-icon"),i),r.span([t.name],"model-catalog-group-name"),r.link("Request membership",()=>ia(function*(){var i;yield(i=t.name,ia(function*(){try{let t=yield e.dapi.groups.filter(`friendlyName="${i}"`).list();if(0===t.length)throw Error("group with specified name is not found");if(t.length>1)throw Error("found more than one group with specified name");let n=t[0];yield e.dapi.groups.requestMembership(n,e.shell.user.group),e.shell.info(`Request to join ${i} has been initiated. Please allow some time for approval.`)}catch(t){e.shell.error(t.toString())}})()),n.popover&&n.hidePopover()})())],"model-catalog-group"),...t.help?[r.divText(t.help,"model-catalog-group-help")]:[]])})],"model-catalog-groups"));return n}awaitUserGroups(){return ia(function*(){return this.userGroups.pipe((0,l.filter)(t=>!!t),(0,l.map)(t=>t),(0,l.take)(1)).toPromise()}).call(this)}constructor(){super(),this.userGroups=new s.BehaviorSubject(void 0)}}function ic(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function id(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){ic(o,i,r,s,l,"next",t)}function l(t){ic(o,i,r,s,l,"throw",t)}s(void 0)})}}function ip(){return id(function*(){yield iZ.init()})()}function ih(t){iZ.openModelFromFuncall(t)}function im(){return iZ.OutliersSelection()}function iv(t){return iZ.RichFunctionViewEditor(t)}function iy(t){return iZ.PipelineStepEditor(t)}function ig(t){return id(function*(){return yield iZ.CustomDataUploader(t)})()}function ib(t){return id(function*(){return yield iZ.CustomUploader(t)})()}function iw(t){iZ.CustomCustomizer(t)}function iC(t){return iZ.SimTimeValidator(t)}function iA(t){return iZ.DesiredTempValidator(t)}function ix(t){return iZ.InitialTempValidator(t)}function iI(t){return iZ.AmbTempValidator(t)}function iE(t){return iZ.HeatCapValidator(t)}function iS(t){return iZ.CustomStringInput(t)}function iR(t){return iZ.ObjectCoolingSelector(t)}function iT(t){return id(function*(){return yield iZ.CustomInputMock(t)})()}function iO(t){return iZ.RangeValidatorFactory(t)}function iP(t){return iZ.AsyncValidatorDemoFactory(t)}function iF(t){return iZ.GlobalValidatorDemoFactory(t)}function iV(t,e,n,i,r,o,s){try{var l=t[o](s),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function iB(t){return function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){iV(o,i,r,s,l,"next",t)}function l(t){iV(o,i,r,s,l,"throw",t)}s(void 0)})}}function iD(t,e,n,i){var r,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var l=t.length-1;l>=0;l--)(r=t[l])&&(s=(o<3?r(s):o>3?r(e,n,s):r(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s}function ik(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function ij(t,e){return function(n,i){e(n,i,t)}}let iL=new o.Package;class iM{set value(t){let e=t?JSON.parse(t):"";this._value.next(e)}get value(){return this._value.value?JSON.stringify(this._value.value):""}onInput(t){return this._value.subscribe(()=>{this.notify&&t(this.value)})}constructor(){this._value=new s.BehaviorSubject(null),this.notify=!0,this.enabled=!0,this.root=r.div("",{style:{width:"100%"}}),this.input=r.input.toggle("test",{value:!0}),this.root.append(this.input.root)}}let iN=tt,i_=class extends e1{},iU=nf,iH=class extends e1{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.view}getRunningUpdates(){return[]}disableSetters(t){}init(){return ie(function*(){yield this.loadFuncCallById(),this.initialConfig.forEach((t,e)=>{var n;this.steps[io(t)]={idx:e,visibility:new s.BehaviorSubject(null!=(n=t.hiddenOnInit)?n:v.VISIBLE),ability:new s.BehaviorSubject(this.isHistorical.value||0===e?y.ENABLED:y.DISABLED),options:{friendlyName:t.friendlyName,helpUrl:t.helpUrl,customId:t.customId}}}),this.subs.push(e.functions.onAfterRunAction.pipe((0,l.filter)(t=>Object.values(this.steps).some(e=>{var n;let i=e.view;return(null==i||null==(n=i.funcCall)?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()}));let t=this.initialConfig.map(t=>ie(function*(){return{stepScript:o.Func.byName(t.funcName),stepId:io(t)}})()),n=yield Promise.all(t);n.forEach(t=>{this.steps[t.stepId].func=t.stepScript}),this.root.classList.remove("ui-panel");let i={},a="editor:",u="Compute:PipelineStepEditor",c=n.map(t=>ie(function*(){let e=t.stepScript.script?(t=>{let e=t.script,n=e.indexOf(a);if(n<0)return u;let i=e.indexOf("\n",n);return e.substring(n+a.length,i).trim()})(t.stepScript):u;return i[e]||(i[e]=o.Func.byName(e.split(" ").join(""))),this.steps[t.stepId].editor=e,Promise.resolve()}).call(this));yield Promise.all(c);let d=n.map(t=>ie(function*(){let n=this.steps[t.stepId],a=t.stepScript.prepare(),u=i[n.editor];yield this.onBeforeStepFuncCallApply(t.stepScript.nqName,a,u);let c=yield u.apply({call:a});yield c.isReady.pipe((0,l.filter)(t=>!!t),(0,l.take)(1)).toPromise();let d=r.button("Back",()=>{},"Go to the previous step");w()(d).addClass("ui-btn-nav");let p=r.button("Next",()=>{},"Go to the next step");w()(p).addClass("ui-btn-nav"),this.syncNavButtons(n,d,p),c.setNavigationButtons([d,p]),this.steps[t.stepId].view=c;let h=this.steps[t.stepId],f=()=>{Object.values(this.steps).forEach(t=>{t.idx>h.idx&&t.visibility.value===v.VISIBLE&&t.ability.value===y.ENABLED&&t.ability.next(y.DISABLED)})},m=h.view.funcCallReplaced.pipe((0,l.switchMap)(()=>{let t=[...h.view.funcCall.inputParams.values()].map(t=>t.onChanged.pipe((0,l.mapTo)(t)));return(0,s.merge)(...t)})),g=m.subscribe(f);this.subs.push(g);let b=m.pipe((0,l.filter)(t=>t.property.propertyType===o.TYPE.DATA_FRAME&&t.value),(0,l.switchMap)(t=>t.value.onDataChanged)).subscribe(f);this.subs.push(b);let C=e.functions.onAfterRunAction.pipe((0,l.filter)(t=>h.view.funcCall&&t&&!!t.id&&h.view.funcCall.id===t.id),(0,l.withLatestFrom)(h.visibility,h.ability),(0,l.filter)(t=>{let e=ii(t,3),n=e[1],i=e[2];return n!==v.HIDDEN&&i!==y.DISABLED})).subscribe(()=>{let t=Object.values(this.steps).find(t=>t.idx>h.idx&&t.visibility.value===v.VISIBLE&&t.ability.value===y.ENABLED)?null:Object.values(this.steps).find(t=>t.idx>h.idx&&t.visibility.value===v.VISIBLE&&t.ability.value===y.DISABLED);null==t||t.ability.next(y.ENABLED)});return this.subs.push(C),yield this.onAfterStepFuncCallApply(t.stepScript.nqName,a,c),c}).call(this)),p=yield Promise.all(d),h=(0,s.combineLatest)(p.map(t=>t.isHistorical)).subscribe(t=>{t.some((t,e)=>{var n;return!t&&(null==(n=Object.values(this.steps).find(t=>t.idx===e))?void 0:n.visibility.value)===v.VISIBLE})&&this.isHistorical.value&&this.isHistorical.next(!1)});this.subs.push(h);let f=this.isUpdating.subscribe(t=>{var e=!0,n=!1,i=void 0;try{for(var r,o=Object.values(this.steps)[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){let e=r.value.view;(null==e?void 0:e.blockRuns)&&e.blockRuns.next(t)}}catch(t){n=!0,i=t}finally{try{e||null==o.return||o.return()}finally{if(n)throw i}}});this.subs.push(f),yield this.onFuncCallReady(),this.isReady.next(!0),this.loadHelp().then(()=>{this.buildRibbonPanels();let t=()=>{let t=this.findCurrentStep();t&&this.helpFiles[t.func.nqName]&&"opened"===this.getHelpState()&&this.showHelpWithDelay(t)},n=e.events.onCurrentViewChanged.pipe((0,l.filter)(()=>e.shell.v==this)).subscribe(t);t(),this.subs.push(n)})}).call(this)}loadHelp(){return ie(function*(){return Promise.all(Object.values(this.steps).map(t=>ie(function*(){var n,i,r,o;let s=null!=(n=null==(i=t.options)?void 0:i.helpUrl)?n:t.func.options.help;if(s){let n=`System:AppData/${this.func.package.name}/${s}`,i=(yield e.dapi.files.exists(n))?yield e.dapi.files.readAsText(n):yield t.view.getContextHelp();i&&(this.helpFiles[null!=(r=null==(o=t.options)?void 0:o.customId)?r:t.func.nqName]=i)}}).call(this)))}).call(this)}syncNavButtons(t,e,n){let i,r;n.addEventListener("click",()=>{i&&(this.currentTabName=ir(i))}),e.addEventListener("click",()=>{r&&(this.currentTabName=ir(r))});let o=this.getPipelineStateChanges().pipe((0,l.startWith)(!0),(0,l.debounceTime)(0)).subscribe(()=>{i=this.getNextStep(t),r=this.getPreviousStep(t),i?(w()(n).show(),i.ability.value===y.DISABLED&&w()(n).addClass("d4-disabled"),i.ability.value===y.ENABLED&&w()(n).removeClass("d4-disabled")):w()(n).hide(),r?(w()(e).show(),r.ability.value===y.DISABLED&&w()(e).addClass("d4-disabled"),r.ability.value===y.ENABLED&&w()(e).removeClass("d4-disabled")):w()(e).hide()});this.subs.push(o)}getPreviousStep(t){return Object.values(this.steps).slice().reverse().find(e=>e.idx<t.idx&&e.visibility.value===v.VISIBLE)}getNextStep(t){return Object.values(this.steps).find(e=>e.idx>t.idx&&e.visibility.value===v.VISIBLE)}getPipelineStateChanges(){let t=Object.values(this.steps).flatMap(t=>[t.ability,t.visibility]);return(0,s.merge)(...t).pipe((0,l.mapTo)(!0))}onComparisonLaunch(t){return ie(function*(){let n=e.shell.v.parentCall,i=yield Promise.all(t.map(t=>is(t.id))),r=yield Promise.all(i.map(t=>{var e;return null!=(e=t.childRuns.find(t=>"true"===t.func.options.isMain))?e:t.childRuns.find(t=>t.func.nqName===this.initialConfig[this.initialConfig.length-1].funcName)}).map(t=>f.loadRun(t.id))),o=[...e.shell.views].find(t=>t.type===R),s=yield tS.fromComparedRuns(r,r[0].func,{parentView:o,parentCall:n});e.shell.addView(s)}).call(this)}onBeforeStepFuncCallApply(t,e,n){return ie(function*(){})()}onAfterStepFuncCallApply(t,e,n){return ie(function*(){})()}buildIO(){let t=Object.values(this.steps).reduce((t,e)=>{var n,i;return n=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}({},t),i=i={[ir(e)]:e.view.root},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(i)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(i,t))}),n},{}),e=r.tabControl(t),n=Object.values(this.steps).map(t=>{let n=r.iconFA("exclamation-circle",null,"This step has inconsistent inputs");return w()(n).css({color:"var(--orange-2)","margin-left":"3px","padding-top":"1px"}),e.getPane(ir(t)).header.appendChild(n),t.view.consistencyState.subscribe(t=>{"consistent"===t&&w()(n).hide(),"inconsistent"===t&&w()(n).show()})});this.subs.push(...n);let i=Object.values(this.steps).map(t=>t.view.consistencyState),o=(0,s.merge)(...i).subscribe(()=>{i.map(t=>t.value).some(t=>"inconsistent"===t)?this.consistencyState.next("inconsistent"):this.consistencyState.next("consistent")});this.subs.push(o);let l=e.panes[0].header.parentElement;l.classList.add("d4-ribbon","pipeline-view"),l.classList.remove("d4-tab-header-stripe"),l.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=>{let e=io(t);this.subs.push(this.steps[e].visibility.subscribe(t=>{t===v.VISIBLE&&w()(this.stepTabs.getPane(ir(this.steps[e])).header).css("display","inherit"),t===v.HIDDEN&&w()(this.stepTabs.getPane(ir(this.steps[e])).header).hide()}))}),Object.values(this.steps).forEach(t=>{this.subs.push(t.ability.subscribe(e=>{e===y.ENABLED&&w()(this.stepTabs.getPane(ir(t)).header).removeClass("d4-disabled"),e===y.DISABLED&&w()(this.stepTabs.getPane(ir(t)).header).addClass("d4-disabled")}))}),this.hideSteps(...this.initialConfig.filter(t=>t.hiddenOnInit===v.HIDDEN).map(t=>t.funcName)),e.root}showHelpWithDelay(t){return ie(function*(){let n;n=this.helpFiles[t.func.nqName],eP(function*(){e.shell.windows.help.visible=!0,yield new Promise(t=>setTimeout(t,100)),e.shell.windows.help.showHelp(r.markdown(n))})()}).call(this)}findCurrentStep(){return Object.values(this.steps).find(t=>ir(t)===this.stepTabs.currentPane.name)}buildHistoryBlock(){let t=super.buildHistoryBlock(),n=this.historyBlock.afterRunDeleted.subscribe(t=>ie(function*(){(yield e.dapi.functions.calls.allPackageVersions().filter(`options.parentCallId="${t.id}"`).list()).map(t=>ie(function*(){return f.deleteRun(t)})())})());return this.subs.push(n),t}getHelpState(){return"closed"===e.userSettings.getValue(tZ,`${this.func.name}_help_state`)?"closed":"opened"}saveHelpState(t){e.userSettings.add(tZ,`${this.func.name}_help_state`,t)}buildRibbonPanels(){let t=r.iconFA("info",()=>ie(function*(){let t=this.findCurrentStep();t&&this.helpFiles[t.func.nqName]&&(yield this.showHelpWithDelay(t),this.saveHelpState("opened"))}).call(this),"Show help for this step"),n=()=>{let n=this.findCurrentStep();r.setDisplay(t,!!(n&&this.helpFiles[n.func.nqName])),n&&this.helpFiles[n.func.nqName]&&e.shell.windows.help.visible&&this.showHelpWithDelay(n),this.setRibbonPanels([...this.getRibbonPanels().slice(0,1),...n?n.view.buildRibbonPanels():[],...this.getRibbonPanels().length>2?this.getRibbonPanels().slice(-1):[]])};if(!this.isReady.value){let t=this.stepTabs.onTabChanged.subscribe(n),i=e.events.onEvent("grok-panels-changed").pipe((0,l.filter)(()=>e.shell.v===this)).subscribe(()=>ie(function*(){let t=yield this.getHelpState();if(e.shell.windows.help.visible&&"closed"===t)return void this.saveHelpState("opened");if(!e.shell.windows.help.visible&&"opened"===t){let t=r.iconFA("info");w()(t).css("margin","0px 3px"),e.shell.info(r.span(["You can open help panel by clicking the",t,"button on the ribbon menu"])),this.saveHelpState("closed");return}}).call(this));this.subs.push(t,i)}let i=this.findCurrentStep(),o=[[...super.buildRibbonPanels().flat(),t],...i?i.view.buildRibbonPanels():[]];return this.setRibbonPanels(o),n(),o}saveRun(t){return ie(function*(){let e=tt(t);yield this.onBeforeSaveRun(e),Q(e)&&(e=yield eB(t)),e.newId();let n=Object.values(this.steps).filter(t=>t.visibility.value===v.VISIBLE).map(t=>ie(function*(){var n,i;let r=t.view.funcCall;return r.options.parentCallId=e.id,(null==(n=t.options)?void 0:n.customId)&&(r.options.customId=null==(i=t.options)?void 0:i.customId),yield t.view.saveRun(r),Promise.resolve()})());yield Promise.all(n),e.options.title&&(e.options.title=`${e.options.title} (copy)`);let i=yield f.saveRun(e),r=yield f.loadRun(i.id);return this.options.historyEnabled&&this.isHistoryEnabled&&this.historyBlock&&this.historyBlock.addRun((yield f.loadRun(i.id))),this.linkFunccall(r),this.isHistorical.next(!0),yield this.onAfterSaveRun(e),i}).call(this)}loadRun(t){return ie(function*(){let e=yield is(t),n=e.parentRun,i=e.childRuns,r=Object.values(this.steps).filter(t=>t.visibility.value===v.VISIBLE).findIndex(t=>ir(t)===this.stepTabs.currentPane.name);yield this.onBeforeLoadRun();var o=!0,s=!1,l=void 0;try{for(var a,u=Object.values(this.steps)[Symbol.iterator]();!(o=(a=u.next()).done);o=!0){let t=a.value,e=i.filter(e=>e.func.nqName===t.func.nqName);if(0===e.length&&(t.visibility.next(v.HIDDEN),t.ability.next(y.DISABLED)),1===e.length&&(yield t.view.loadRun(e[0].id),t.visibility.next(v.VISIBLE),Q(e[0])?t.ability.next(y.DISABLED):t.ability.next(y.ENABLED)),e.length>1){let n=e.find(e=>{var n;return e.options.customId===(null==(n=t.options)?void 0:n.customId)});yield t.view.loadRun(n.id),t.visibility.next(v.VISIBLE),Q(n)?t.ability.next(y.DISABLED):t.ability.next(y.ENABLED)}}}catch(t){s=!0,l=t}finally{try{o||null==u.return||u.return()}finally{if(s)throw l}}let c=Object.values(this.steps).find(t=>t.ability.value===y.DISABLED&&t.visibility.value===v.VISIBLE),d=null!=c?c:Object.values(this.steps)[0];if(d.ability.next(y.ENABLED),c){let t=this.getNextStep(c);for(;t;)t.ability.next(y.DISABLED),t=this.getNextStep(t)}this.lastCall=n,this.linkFunccall(n),this.isHistorical.next(!0);let p=Object.values(this.steps).filter(t=>t.visibility.value==v.VISIBLE).at(r);return p&&p.ability.value===y.ENABLED?this.currentTabName=ir(p):this.currentTabName=ir(d),yield this.onAfterLoadRun(n),n}).call(this)}hideSteps(...t){return ie(function*(){t.forEach(t=>{this.steps[t].visibility.next(v.HIDDEN)})}).call(this)}showSteps(...t){return ie(function*(){t.forEach(t=>{this.steps[t].visibility.next(v.VISIBLE)})}).call(this)}exportRunJson(){return ie(function*(){if(this._lastCall){let o={isPipeline:!0};var t=!0,e=!1,n=void 0;try{for(var i,r=Object.entries(this.steps)[Symbol.iterator]();!(t=(i=r.next()).done);t=!0){let t=ii(i.value,2),e=t[0],n=t[1],r=n.view.lastCall;r&&(o[e]=yield eD(r,n.view))}}catch(t){e=!0,n=t}finally{try{t||null==r.return||r.return()}finally{if(e)throw n}}return Y(o)}}).call(this)}getStepViewRuns(t){return this.onStepCompleted.pipe((0,l.filter)(e=>e.func.nqName===t),(0,l.map)(()=>this.getStepView(t)))}constructor(t,e,n){var i;super(t,void 0===n?{historyEnabled:!0,isTabbed:!1,skipInit:!1}:n),i=this,this.initialConfig=e,this.steps={},this.onStepCompleted=new s.Subject,this.isUpdating=new s.BehaviorSubject(!1),this.pipelineViewExportExtensions=()=>({Archive:"zip","Single Excel":"xlsx"}),this.pipelineViewExportFormats=()=>["Archive","Single Excel"],this.pipelineViewExport=t=>ie(function*(){if(!i.stepTabs)throw Error("Set step tabs please for export");if("Archive"===t){let t={};var e=!0,n=!1,r=void 0;try{for(var s,l=Object.values(i.steps).filter(t=>t.visibility.value===v.VISIBLE)[Symbol.iterator]();!(e=(s=l.next()).done);e=!0){let e=s.value;i.stepTabs.currentPane=i.stepTabs.getPane(ir(e)),yield new Promise(t=>setTimeout(t,100));let n=yield e.view.exportConfig.export("Excel");t[e.view.exportConfig.filename("Excel")]=[new Uint8Array((yield n.arrayBuffer())),{level:0}]}}catch(t){n=!0,r=t}finally{try{e||null==l.return||l.return()}finally{if(n)throw r}}return new Blob([function(t,e){e||(e={});var n={},i=[];n0(t,"",n,e);var r=0,o=0;for(var s in n){var l=n[s],a=l[0],u=l[1],c=8*(0!=u.level),d=n3(s),p=d.length,h=u.comment,f=h&&n3(h),m=f&&f.length,v=n5(u.extra);p>65535&&nM(11);var y=c?function(t,e){var n;return nz(t,null==(n=e||{}).level?6:n.level,null==n.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+n.mem,0,0,!0)}(a,u):a,g=y.length,b=nZ();b.p(a),i.push(nX(u,{size:a.length,crc:b.d(),c:y,f:d,m:f,u:p!=s.length||f&&h.length!=m,o:r,compression:c})),r+=30+p+v+g,o+=76+2*(p+v)+(m||0)+g}for(var w=new nm(o+22),C=r,A=o-r,x=0;x<i.length;++x){var d=i[x];n4(w,d.o,d,d.f,d.u,d.c.length);var I=30+d.f.length+n5(d.extra);w.set(d.c,d.o+I),n4(w,r,d,d.f,d.u,d.c.length,d.o,d.m),r+=16+I+(d.m?d.m.length:0)}return n6(w,r,i.length,A,C),w}(t)])}if("Single Excel"===t){yield o.Utils.loadJsCss(["/js/common/exceljs.min.js"]);let t=window.ExcelJS,e=new t.Workbook,n=(t,e,n)=>{let i=`${ir(n)}>${e}`;i.length>31&&(i=`${i.slice(0,31)}`);let r=2;for(;t.worksheets.some(t=>t.name.toLowerCase()===i.toLowerCase());){let t=`${ir(n)}>${e}`;t.length>31-`-${r}`.length&&(t=`${t.slice(0,31-`-${r}`.length)}`),i=`${t}-${r}`,r++}return i};var a=!0,u=!1,c=void 0;try{for(var d,p=Object.values(i.steps).filter(t=>t.visibility.value===v.VISIBLE)[Symbol.iterator]();!(a=(d=p.next()).done);a=!0){let r=d.value,o=new t.Workbook;i.stepTabs.currentPane=i.stepTabs.getPane(ir(r)),yield new Promise(t=>setTimeout(t,100)),yield o.xlsx.load((yield(yield r.view.exportConfig.export("Excel")).arrayBuffer())),o.eachSheet(t=>{let i=n(e,t.name,r),s=e.addWorksheet("New sheet");s.model=t.model,s.name=i,t.getImages().forEach(t=>{let n=e.addImage(o.getImage(t.imageId));s.addImage(n,t.range)})})}}catch(t){u=!0,c=t}finally{try{a||null==p.return||p.return()}finally{if(u)throw c}}return new Blob([(yield e.xlsx.writeBuffer())],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"})}throw Error("This format is not supported")})(),this.exportConfig={supportedExtensions:this.pipelineViewExportExtensions(),supportedFormats:this.pipelineViewExportFormats(),export:this.pipelineViewExport,filename:this.defaultExportFilename},this.helpFiles={}}},i$=eb,iW=eg,iY=eA,iG=ew,iq=b.fileInput,iJ=b.historyInput,iz=b.historyInputJSON,iK=b.historyPanel;class iZ{static init(){return iB(function*(){})()}static openModelFromFuncall(t){iu.openModelFromFunccall(t)}static OutliersSelection(){return new C}static RichFunctionViewEditor(t){return nf.fromFuncCall(t,{historyEnabled:!0,isTabbed:!1})}static PipelineStepEditor(t){return nf.fromFuncCall(t,{historyEnabled:!1,isTabbed:!0})}static CustomDataUploader(t){return iB(function*(){return yield new Promise(t=>setTimeout(t,1e3)),[(yield t.prepare({ambTemp:22,initTemp:100,desiredTemp:30,area:.06,heatCap:4200,heatTransferCoeff:8.3,simTime:21600}).call())]})()}static CustomUploader(t){return iB(function*(){let n=(yield e.functions.eval("Compute:CustomDataUploader")).prepare({func:t.func}),i=r.bigButton("Click me to get mock calls",()=>n.call()),s=o.Widget.fromRoot(r.panel([r.divV([r.label("This part of dialog comes from my custom data uploader"),r.divH([i],{style:{justifyContent:"center"}})])])),a=e.functions.onBeforeRunAction.pipe((0,l.filter)(t=>t.id===n.id)).subscribe(()=>{r.setUpdateIndicator(i,!0)}),u=e.functions.onAfterRunAction.pipe((0,l.filter)(t=>t.id===n.id)).subscribe(()=>{r.setUpdateIndicator(i,!1)});return s.subs.push(a,u),{uploadWidget:s,uploadFuncCall:n}})()}static CustomCustomizer(t){t.defaultView.scatterPlot({xColumnName:"Initial temperature",yColumnName:"Time to cool"})}static SimTimeValidator(t){let{reasonableMin:e,reasonableMax:n}=t;return t=>eb({warnings:t<e||t>n?[`Minimum reasonable time is ${e}. Maximum reasonable time is ${n}`]:void 0,errors:t<0?["Time should be strictly positive"]:void 0})}static DesiredTempValidator(t){return(t,e)=>{let n=e.funcCall.inputs.ambTemp,i=e.funcCall.inputs.initTemp;return eb({errors:[...t<n?[eg(`Desired temperature cannot be less than ambient temperature (${n}).
|
|
170
|
+
`,[{actionName:"Set desired equal to ambient",action:()=>e.funcCall.inputs.desiredTemp=n}])]:[],...t>i?[`Desired temperature cannot be higher than initial temperature (${i})`]:[]]})}}static InitialTempValidator(t){return(t,e)=>{let n=e.funcCall.inputs.ambTemp;return eb({errors:[...t<n?[`Initial temperature cannot be less than ambient temperature (${n}).`]:[]]})}}static AmbTempValidator(t){return(t,e)=>{let n=e.funcCall.inputs.initTemp;return eb({errors:[...t>n?[`Ambient temperature cannot be higher than initial temperature (${n})`]:[]]})}}static HeatCapValidator(t){return(t,e)=>eb({errors:[...t<=0?["Heat capacity must be greater than zero."]:[]],notifications:[eg("Heat capacity is only dependent on the object material.",[{actionName:"Google it",action:()=>{window.open("http://google.com")}}])]})}static CustomStringInput(t){let e=r.input.string("Custom input",{value:""});return e.root.style.backgroundColor="aqua",e.input.style.backgroundColor="aqua",e}static ObjectCoolingSelector(t){return b.historyInputJSON("Previous run","ObjectCooling")}static CustomInputMock(t){return iB(function*(){return new iM})()}static RangeValidatorFactory(t){let{min:e,max:n}=t;return t=>{if(t<e||t>n)return eb({errors:[`Out of range [${e}, ${n}] value: ${t}`]})}}static AsyncValidatorDemoFactory(t){return t=>iB(function*(){if(yield new Promise(t=>setTimeout(t,100)),0===t)return eb({warnings:["Try non-null value"]})})()}static GlobalValidatorDemoFactory(t){let{max:e}=t;return(t,n)=>iB(function*(){if(n.isRevalidation){var t;return(null==(t=n.context)?void 0:t.isOk)?eb():eb({warnings:["Try lowering a value as well"]})}yield new Promise(t=>setTimeout(t,100));let{a:i,b:r,c:o}=n.funcCall.inputs,s=i+r+o<=e,l=s?eb():eb({warnings:["Try lowering a value"]});return eA(["a","b","c"].filter(t=>t!==n.param),{isOk:s},l)})()}}iD([e.decorators.init(),ik("design:type",Function),ik("design:paramtypes",[]),ik("design:returntype",Promise)],iZ,"init",null),iD([e.decorators.func(),ik("design:type",Function),ik("design:paramtypes",[void 0===o||void 0===o.FuncCall?Object:o.FuncCall]),ik("design:returntype",void 0)],iZ,"openModelFromFuncall",null),iD([e.decorators.func({name:"OutliersSelectionViewer",description:"Creates an outliers selection viewer",outputs:[{type:"viewer",name:"result"}],meta:{role:"viewer"}}),ik("design:type",Function),ik("design:paramtypes",[]),ik("design:returntype",void 0)],iZ,"OutliersSelection",null),iD([e.decorators.editor({outputs:[{type:"view",name:"result"}]}),ik("design:type",Function),ik("design:paramtypes",[void 0===o||void 0===o.FuncCall?Object:o.FuncCall]),ik("design:returntype",void 0)],iZ,"RichFunctionViewEditor",null),iD([e.decorators.editor({outputs:[{type:"object",name:"result"}]}),ik("design:type",Function),ik("design:paramtypes",[void 0===o||void 0===o.FuncCall?Object:o.FuncCall]),ik("design:returntype",void 0)],iZ,"PipelineStepEditor",null),iD([e.decorators.func({outputs:[{type:"object",name:"uploadedCalls"}]}),ik("design:type",Function),ik("design:paramtypes",[void 0===o||void 0===o.Func?Object:o.Func]),ik("design:returntype",Promise)],iZ,"CustomDataUploader",null),iD([e.decorators.func({outputs:[{name:"uploadWidget",type:"widget"},{name:"uploadFuncCall",type:"funccall"}]}),ij(0,e.decorators.param({type:"object"})),ik("design:type",Function),ik("design:paramtypes",[Object]),ik("design:returntype",Promise)],iZ,"CustomUploader",null),iD([e.decorators.func(),ij(0,e.decorators.param({type:"object"})),ik("design:type",Function),ik("design:paramtypes",[Object]),ik("design:returntype",void 0)],iZ,"CustomCustomizer",null),iD([e.decorators.func({outputs:[{type:"object",name:"validator"}]}),ij(0,e.decorators.param({type:"object"})),ik("design:type",Function),ik("design:paramtypes",[Object]),ik("design:returntype",void 0)],iZ,"SimTimeValidator",null),iD([e.decorators.func({outputs:[{type:"object",name:"validator"}]}),ij(0,e.decorators.param({type:"object"})),ik("design:type",Function),ik("design:paramtypes",[Object]),ik("design:returntype",void 0)],iZ,"DesiredTempValidator",null),iD([e.decorators.func({outputs:[{type:"object",name:"validator"}]}),ij(0,e.decorators.param({type:"object"})),ik("design:type",Function),ik("design:paramtypes",[Object]),ik("design:returntype",void 0)],iZ,"InitialTempValidator",null),iD([e.decorators.func({outputs:[{type:"object",name:"validator"}]}),ij(0,e.decorators.param({type:"object"})),ik("design:type",Function),ik("design:paramtypes",[Object]),ik("design:returntype",void 0)],iZ,"AmbTempValidator",null),iD([e.decorators.func({outputs:[{type:"object",name:"validator"}]}),ij(0,e.decorators.param({type:"object"})),ik("design:type",Function),ik("design:paramtypes",[Object]),ik("design:returntype",void 0)],iZ,"HeatCapValidator",null),iD([e.decorators.func({outputs:[{type:"object",name:"result"}]}),ij(0,e.decorators.param({type:"object"})),ik("design:type",Function),ik("design:paramtypes",[Object]),ik("design:returntype",void 0)],iZ,"CustomStringInput",null),iD([e.decorators.func({outputs:[{type:"object",name:"result"}]}),ij(0,e.decorators.param({type:"object"})),ik("design:type",Function),ik("design:paramtypes",[Object]),ik("design:returntype",void 0)],iZ,"ObjectCoolingSelector",null),iD([e.decorators.func({outputs:[{type:"object",name:"input"}]}),ij(0,e.decorators.param({type:"object"})),ik("design:type",Function),ik("design:paramtypes",[Object]),ik("design:returntype",Promise)],iZ,"CustomInputMock",null),iD([e.decorators.func({outputs:[{type:"object",name:"validator"}]}),ij(0,e.decorators.param({type:"object"})),ik("design:type",Function),ik("design:paramtypes",[Object]),ik("design:returntype",void 0)],iZ,"RangeValidatorFactory",null),iD([e.decorators.func({outputs:[{type:"object",name:"validator"}]}),ij(0,e.decorators.param({type:"object"})),ik("design:type",Function),ik("design:paramtypes",[Object]),ik("design:returntype",void 0)],iZ,"AsyncValidatorDemoFactory",null),iD([e.decorators.func({outputs:[{type:"object",name:"validator"}]}),ij(0,e.decorators.param({type:"object"})),ik("design:type",Function),ik("design:paramtypes",[Object]),ik("design:returntype",void 0)],iZ,"GlobalValidatorDemoFactory",null)})(),compute=i})();
|
|
171
171
|
//# sourceMappingURL=package.js.map
|