@datagrok/compute 1.14.2 → 1.15.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/dist/package.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var compute;(()=>{"use strict";var t={903:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,".pipeline-view .d4-ribbon-name.selected {\n color: var(--grey-6)\n}\n\n.pipeline-view .d4-ribbon-name {\n color: var(--blue-1);\n margin: 12px 6px;\n font-weight: normal;\n place-content: center;\n}\n\n.pipeline-view .d4-ribbon-name + .d4-ribbon-name::before {\n color: var(--grey-3);\n}\n\n.pipeline-view .d4-ribbon-name.d4-disabled {\n cursor: default;\n pointer-events: none;\n color: var(--grey-3);\n}\n\n.ui-input-editor button.ui-btn-nav.ui-btn {\n background-color: rgb(80 169 197 / 25%);\n color: #50A9C5;\n float: left;\n margin-right: 5px;\n padding: 0 12px;\n}\n\n.ui-input-editor button.ui-btn-nav.ui-btn.d4-disabled {\n color: var(--grey-3)\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/function-views/css/pipeline-view.css"],names:[],mappings:"AAAA;EACE;AACF;;AAEA;EACE,oBAAoB;EACpB,gBAAgB;EAChB,mBAAmB;EACnB,qBAAqB;AACvB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,eAAe;EACf,oBAAoB;EACpB,oBAAoB;AACtB;;AAEA;EACE,uCAAuC;EACvC,cAAc;EACd,WAAW;EACX,iBAAiB;EACjB,eAAe;AACjB;;AAEA;EACE;AACF",sourcesContent:[".pipeline-view .d4-ribbon-name.selected {\n color: var(--grey-6)\n}\n\n.pipeline-view .d4-ribbon-name {\n color: var(--blue-1);\n margin: 12px 6px;\n font-weight: normal;\n place-content: center;\n}\n\n.pipeline-view .d4-ribbon-name + .d4-ribbon-name::before {\n color: var(--grey-3);\n}\n\n.pipeline-view .d4-ribbon-name.d4-disabled {\n cursor: default;\n pointer-events: none;\n color: var(--grey-3);\n}\n\n.ui-input-editor button.ui-btn-nav.ui-btn {\n background-color: rgb(80 169 197 / 25%);\n color: #50A9C5;\n float: left;\n margin-right: 5px;\n padding: 0 12px;\n}\n\n.ui-input-editor button.ui-btn-nav.ui-btn.d4-disabled {\n color: var(--grey-3)\n}"],sourceRoot:""}]);const a=r},751:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,".rfv-buttons {\n margin-top: 0px;\n position: sticky;\n}\n\n.ui-form-condensed .rfv-buttons > .ui-label {\n margin-right: 0px!important;\n}\n\n.ui-form .rfv-buttons > .ui-input-editor {\n justify-content: space-between\n}\n\ndiv.ui-box > div.ui-box.rfv-form > div.ui-div {\n overflow: visible!important;\n}\n\n.rfv-scalar-table {\n border-collapse: collapse;\n margin: 10px;\n}\n\n.rfv-scalar-table td {\n width: max-content;\n white-space: nowrap;\n}\n\n.rfv-scalar-table tr{\n min-height: 30px;\n border-bottom: 1pt solid var(--grey-12);\n}\n\n.rfv-scalar-table tr:nth-child(odd) {\n background-color: var(--grey-1);\n}\n\n.rfv-scalar-table td:last-child {\n width: 100%;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/function-views/css/rich-function-view.css"],names:[],mappings:"AAAA;IACI,eAAe;IACf,gBAAgB;AACpB;;AAEA;IACI,2BAA2B;AAC/B;;AAEA;IACI;AACJ;;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:[".rfv-buttons {\n margin-top: 0px;\n position: sticky;\n}\n\n.ui-form-condensed .rfv-buttons > .ui-label {\n margin-right: 0px!important;\n}\n\n.ui-form .rfv-buttons > .ui-input-editor {\n justify-content: space-between\n}\n\ndiv.ui-box > div.ui-box.rfv-form > div.ui-div {\n overflow: visible!important;\n}\n\n.rfv-scalar-table {\n border-collapse: collapse;\n margin: 10px;\n}\n\n.rfv-scalar-table td {\n width: max-content;\n white-space: nowrap;\n}\n\n.rfv-scalar-table tr{\n min-height: 30px;\n border-bottom: 1pt solid var(--grey-12);\n}\n\n.rfv-scalar-table tr:nth-child(odd) {\n background-color: var(--grey-1);\n}\n\n.rfv-scalar-table td:last-child {\n width: 100%;\n}"],sourceRoot:""}]);const a=r},669:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,".fi-drop-area {\n position: relative;\n}\n\n.fi-drop-area .default {\n color: var(--grey-2);\n}\n\n.fi-drop-area .drag-n-dropping {\n background-color: var(--steel-1);\n border: 1px dashed var(--blue-1);\n color: var(--grey-3);\n}\n\n.fi-drop-area .error {\n color: var(--red-3);\n}\n\n.fi-drop-area .success {\n color: var(--grey-6);\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/shared-components/css/file-input.css"],names:[],mappings:"AAAA;EACE,kBAAkB;AACpB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,gCAAgC;EAChC,gCAAgC;EAChC,oBAAoB;AACtB;;AAEA;EACE,mBAAmB;AACrB;;AAEA;EACE,oBAAoB;AACtB",sourcesContent:[".fi-drop-area {\n position: relative;\n}\n\n.fi-drop-area .default {\n color: var(--grey-2);\n}\n\n.fi-drop-area .drag-n-dropping {\n background-color: var(--steel-1);\n border: 1px dashed var(--blue-1);\n color: var(--grey-3);\n}\n\n.fi-drop-area .error {\n color: var(--red-3);\n}\n\n.fi-drop-area .success {\n color: var(--grey-6);\n}\n"],sourceRoot:""}]);const a=r},380:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},778:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,".hp-funccall-card:hover {\n box-shadow: 0px 0px 3px #b8bac0;\n cursor: pointer;\n}\n\n.hp-funccall-card {\n margin: 2px 1px;\n padding: 5px 12px 5px 5px;\n justify-content: space-between;\n}\n\n.hp-funccall-card.clicked {\n border: 1px solid var(--blue-1);\n}\n\n.hp-funccall-card-hover-icon {\n display: none;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-hover-icon {\n display: flex;\n}\n\n.hp-funccall-card-def-icon {\n display: flex;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-def-icon {\n display: none;\n}\n\n.hp-funccall-card .hp-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.hp-funccall-card .hp-card-content * {\n margin-bottom: 3px;\n}\n\n.hp-funccall-card-def-icon {\n margin: 5px;\n}\n\n.hp-funccall-card-icon {\n margin: 5px;\n}\n\n.hp-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.hp-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}\n\n.grok-icon.hp-disabled {\n pointer-events: none;\n opacity: 0.6;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/shared-components/css/history-panel.css"],names:[],mappings:"AAAA;IACI,+BAA+B;IAC/B,eAAe;AACnB;;AAEA;IACI,eAAe;IACf,yBAAyB;IACzB,8BAA8B;AAClC;;AAEA;IACI,+BAA+B;AACnC;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,6BAA6B;IAC7B,gBAAgB;AACpB;;AAEA;IACI,kBAAkB;AACtB;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,kBAAkB;IAClB,oBAAoB;AACxB;;AAEA;IACI,oBAAoB;IACpB,gBAAgB;AACpB;;AAEA;IACI,oBAAoB;IACpB,YAAY;AAChB",sourcesContent:[".hp-funccall-card:hover {\n box-shadow: 0px 0px 3px #b8bac0;\n cursor: pointer;\n}\n\n.hp-funccall-card {\n margin: 2px 1px;\n padding: 5px 12px 5px 5px;\n justify-content: space-between;\n}\n\n.hp-funccall-card.clicked {\n border: 1px solid var(--blue-1);\n}\n\n.hp-funccall-card-hover-icon {\n display: none;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-hover-icon {\n display: flex;\n}\n\n.hp-funccall-card-def-icon {\n display: flex;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-def-icon {\n display: none;\n}\n\n.hp-funccall-card .hp-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.hp-funccall-card .hp-card-content * {\n margin-bottom: 3px;\n}\n\n.hp-funccall-card-def-icon {\n margin: 5px;\n}\n\n.hp-funccall-card-icon {\n margin: 5px;\n}\n\n.hp-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.hp-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}\n\n.grok-icon.hp-disabled {\n pointer-events: none;\n opacity: 0.6;\n}\n"],sourceRoot:""}]);const a=r},433:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,'.model-catalog-view .d4-gallery-card.entity-model i {\n height: 64px;\n width: 64px;\n position: initial;\n flex-shrink: 0;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model .d4-link-label i.grok-icon + label {\n margin-left: 6px;\n align-items: center;\n display: inline-flex;\n white-space: normal;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model {\n padding: 0 8px;\n align-items: center;\n display: flex;\n margin: 0;\n height: 94px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid {\n flex-direction: row!important;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label i.grok-icon {\n width: 32px;\n height: 32px;\n position: initial;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label label {\n margin-left: 8px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid .d4-link-label {\n min-width: 250px;\n margin-bottom: 9px;\n color: var(--grey-6);\n padding: 10px;\n width: initial;\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 20px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 16px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group .d4-tree-view-node {\n font-size: 14px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-video {\n width: 80%;\n height: 0;\n padding-bottom: 50%;\n margin: 10px 10px 0 0;\n border: 1px solid var(--grey-2);\n position: relative;\n background-size: cover;\n background-repeat: no-repeat;\n}\n\n.model-catalog-video i {\n position: absolute;\n right: 0;\n left: 0;\n bottom: 0;\n top: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-weight: 600;\n color: var(--grey-2);\n font-size: 42px;\n}\n\n.model-catalog-video i:hover {\n color: var(--grey-1);\n}\n\n.model-catalog-description {\n padding: 10px 0 0 0;\n}',"",{version:3,sources:["webpack://./src/css/model-card.css"],names:[],mappings:"AAAA;IACI,YAAY;IACZ,WAAW;IACX,iBAAiB;IACjB,cAAc;AAClB;;AAEA;IACI,gBAAgB;IAChB,mBAAmB;IACnB,oBAAoB;IACpB,mBAAmB;AACvB;;AAEA;IACI,cAAc;IACd,mBAAmB;IACnB,aAAa;IACb,SAAS;IACT,YAAY;AAChB;;AAEA;IACI,6BAA6B;AACjC;;AAEA;IACI,WAAW;IACX,YAAY;IACZ,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;AACpB;;AAEA;IACI,gBAAgB;IAChB,kBAAkB;IAClB,oBAAoB;IACpB,aAAa;IACb,cAAc;AAClB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,oBAAoB;AACxB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,oBAAoB;AACxB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,oBAAoB;AACxB;;AAEA;IACI,UAAU;IACV,SAAS;IACT,mBAAmB;IACnB,qBAAqB;IACrB,+BAA+B;IAC/B,kBAAkB;IAClB,sBAAsB;IACtB,4BAA4B;AAChC;;AAEA;IACI,kBAAkB;IAClB,QAAQ;IACR,OAAO;IACP,SAAS;IACT,MAAM;IACN,aAAa;IACb,mBAAmB;IACnB,uBAAuB;IACvB,gBAAgB;IAChB,oBAAoB;IACpB,eAAe;AACnB;;AAEA;IACI,oBAAoB;AACxB;;AAEA;IACI,mBAAmB;AACvB",sourcesContent:['.model-catalog-view .d4-gallery-card.entity-model i {\n height: 64px;\n width: 64px;\n position: initial;\n flex-shrink: 0;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model .d4-link-label i.grok-icon + label {\n margin-left: 6px;\n align-items: center;\n display: inline-flex;\n white-space: normal;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model {\n padding: 0 8px;\n align-items: center;\n display: flex;\n margin: 0;\n height: 94px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid {\n flex-direction: row!important;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label i.grok-icon {\n width: 32px;\n height: 32px;\n position: initial;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label label {\n margin-left: 8px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid .d4-link-label {\n min-width: 250px;\n margin-bottom: 9px;\n color: var(--grey-6);\n padding: 10px;\n width: initial;\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 20px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 16px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group .d4-tree-view-node {\n font-size: 14px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-video {\n width: 80%;\n height: 0;\n padding-bottom: 50%;\n margin: 10px 10px 0 0;\n border: 1px solid var(--grey-2);\n position: relative;\n background-size: cover;\n background-repeat: no-repeat;\n}\n\n.model-catalog-video i {\n position: absolute;\n right: 0;\n left: 0;\n bottom: 0;\n top: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-weight: 600;\n color: var(--grey-2);\n font-size: 42px;\n}\n\n.model-catalog-video i:hover {\n color: var(--grey-1);\n}\n\n.model-catalog-description {\n padding: 10px 0 0 0;\n}'],sourceRoot:""}]);const a=r},352:t=>{t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,o,s){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var d=0;d<t.length;d++){var u=[].concat(t[d]);i&&r[u[0]]||(void 0!==s&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=s),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),e.push(u))}},e}},864:t=>{t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),s="/*# ".concat(o," */");return[e].concat([s]).join("\n")}return[e].join("\n")}},701:t=>{var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var s={},r=[],a=0;a<t.length;a++){var l=t[a],d=i.base?l[0]+i.base:l[0],u=s[d]||0,c="".concat(d," ").concat(u);s[d]=u+1;var h=n(c),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==h)e[h].references++,e[h].updater(p);else{var f=o(p,i);i.byIndex=a,e.splice(a,0,{identifier:c,updater:f,references:1})}r.push(c)}return r}function o(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var s=i(t=t||[],o=o||{});return function(t){t=t||[];for(var r=0;r<s.length;r++){var a=n(s[r]);e[a].references--}for(var l=i(t,o),d=0;d<s.length;d++){var u=n(s[d]);0===e[u].references&&(e[u].updater(),e.splice(u,1))}s=l}}},80:t=>{var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},182:t=>{t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},850:(t,e,n)=>{t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},236:t=>{t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var s=n.sourceMap;s&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},213:t=>{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 o=e[i];if(void 0!==o)return o.exports;var s=e[i]={id:i,exports:{}};return t[i](s,s.exports,n),s.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nc=void 0;var i={};(()=>{n.r(i),n.d(i,{OutliersSelection:()=>zt,PipelineStepEditor:()=>qt,RichFunctionViewEditor:()=>Zt,_package:()=>Ut,autostart:()=>ee,functionParametersGrid:()=>Jt,hof:()=>Xt,hof2:()=>Kt,importScriptGenerator:()=>Yt,init:()=>ne,modelCatalog:()=>ie,openModelFromFuncall:()=>Gt,renderRestPanel:()=>Qt});const t=grok,e=ui,o=DG,s=wu;var r=n.n(s);let a;class l extends o.CustomCardView{constructor(){super({dataSource:t.dapi.functions,permanentFilter:"#model"}),this.root.classList.add("model-catalog-view"),this.meta=new u,this.name="Models",this.permanentFilter="#model",this.renderMode=o.RENDER_MODE.BRIEF,this.objectType="Func",this.categoryFilters={"options.department":"Department","options.HL_process":"HL_process","options.process":"Process",tag:"Tags"},this.filters={All:"",Favorites:"starredBy = @current","Used by me":"usedBy = @current"},this.hierarchy=["options.department","options.HL_process","options.process"],this.hierarchyProperties={"options.department":"Department","options.HL_process":"HL_process","options.process":"Process"},this.showTree=!0,this.initRibbon(),this.initMenu(),this.currentCall=t.functions.getCurrentCall(),null==a&&null==window.localStorage.getItem("ModelCatalogShowProperties")&&(a=t.events.onCurrentObjectChanged.subscribe((e=>{(new u).isApplicable(e.sender)&&(t.shell.windows.showProperties=!0,window.localStorage.setItem("ModelCatalogShowProperties","false"),a.unsubscribe())}))),t.shell.windows.showHelp=!1}initRibbon(){this.setRibbonPanels([[e.icons.sync((()=>this.refresh()))]])}initMenu(){this.ribbonMenu.group("Help").item("Compute Engine",(()=>window.open("https://github.com/datagrok-ai/public/tree/master/packages/Compute","_blank"))).item("Developing Models",(()=>window.open("https://datagrok.ai/help/compute/scripting","_blank"))).endGroup()}setCurrentModel(t){let n=o.View.forObject(t),i=this.root.querySelector(".grok-gallery-grid");e.empty(i),i.appendChild(n.root)}}var d=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class u extends o.ObjectHandler{get type(){return"Model"}getById(e){return d(this,void 0,void 0,(function*(){return yield t.dapi.functions.find(e)}))}refresh(t){return d(this,void 0,void 0,(function*(){return yield this.getById(t.id)}))}getLanguageIcon(t){return"grok"==t?e.iconSvg("project"):e.iconImage("script",`/images/entities/${t}.png`)}isApplicable(t){return t instanceof o.Func&&t.hasTag("model")}renderIcon(t,n=null){if(null!=t.options.icon&&(t.options.icon.startsWith("http://")||t.options.icon.startsWith("https://")))return e.iconImage("model-icon",t.options.icon);if(t instanceof o.Script)return this.getLanguageIcon(t.language);let i=(t=o.Func.find({package:t.package.name,name:t.name})[0]).package.getIconUrl();if(null!=t.options.icon){let e=i.split("/");e.pop(),e.push(t.options.icon),i=e.join("/")}return e.iconImage(t.package.name,i)}renderMarkup(t){let n=e.span([this.renderIcon(t),e.label(t.friendlyName)]);return n.ondblclick=e=>{u.openModel(t)},n.onclick=e=>{u.openHelp(t)},n}renderPreview(e){const n=Object.create(null,{renderPreview:{get:()=>super.renderPreview}});var i;return d(this,void 0,void 0,(function*(){const s=null!==(i=e.options.editor)&&void 0!==i?i:"Compute:RichFunctionViewEditor",r=yield t.functions.find(s);if(null!==r&&r instanceof o.Func){const t=r.prepare({call:e.prepare()});yield t.call(!1,void 0,{processed:!0});const n=t.getOutputParamValue();if(n instanceof o.View)return n}return n.renderPreview.call(this,e)}))}renderProperties(t){const n=e.accordion("ComputeModel");n.context=t;let i=e.div([e.span([this.renderIcon(t),e.label(t.friendlyName),e.contextActions(t),e.star(t.id)])]);return n.addTitle(i),null!=t.description&&i.appendChild(e.div([e.markdown(t.description)],"model-catalog-description")),i.appendChild(e.tags(t)),null!=t.options["dev.status"]&&i.appendChild(e.tableFromMap({Status:t.options["dev.status"]})),n.end(),n.root}renderTooltip(t){let n=this.renderMarkup(t);n.classList.add("d4-link-label");let i=e.bind(t,e.divV([e.h2(n),e.divV([e.divText(t.description,"ui-description")],{style:{lineHeight:"150%"}})]));return i.ondblclick=e=>{u.openModel(t)},i}renderCard(t,n){let i=this.renderMarkup(t);i.classList.add("d4-link-label");let o=e.bind(t,e.h2(i));return o.ondblclick=e=>{u.openModel(t)},o.onclick=e=>{u.openHelp(t)},o}static openHelp(n){return d(this,void 0,void 0,(function*(){if(null!=n.options.readme){const i=`System:AppData/${n.package.name}/${n.options.readme}`,o=yield t.dapi.files.readAsText(i);t.shell.windows.help.showHelp(e.markdown(o)),t.shell.windows.showHelp=!0}}))}static getModelCatalogView(){let e=this.findModelCatalogView();if(null==e){let e=o.Func.find({package:"Compute",name:"ModelCatalog"})[0].prepare(),n=new l;n.name="Models",n.parentCall=e,t.shell.addView(n)}return e=this.findModelCatalogView(),e}static findModelCatalogView(){return r()(t.shell.views).find((t=>{var e;return"modelCatalog"==(null===(e=t.parentCall)||void 0===e?void 0:e.func.name)}))}static openModel(t){t.prepare().edit()}static openModelFromFunccall(t){t.edit()}static bindModel(t){let e=u.getModelCatalogView();if(t.aux.showOnTaskBar=!1,null!=e){let n=e.parentCall;null!=n&&(n.aux.view=e,t.parentCall=n)}}init(){setTimeout((()=>{t.functions.onBeforeRunAction.subscribe((t=>{(t.func.hasTag("model")||t.func.hasTag("model-editor"))&&u.bindModel(t)}))}))}}const c=$;var h=n.n(c);const p=()=>document.querySelector(".d4-balloon-container");class f extends o.JsViewer{constructor(){super()}onFrameAttached(t){this.render()}onTableAttached(){this.render()}render(){if(!this.dataFrame||this.dataFrame.rowCount<=0)return void(this.root.innerHTML="");const n=this.dataFrame,i="isOutlier",s="Rationale",r="Count",a="isConfirmed";n.columns.byName(i)||n.columns.add(o.Column.fromBitSet(i,o.BitSet.create(n.rowCount,(()=>!1)))),n.columns.byName(s)||n.columns.add(o.Column.fromStrings(s,Array.from({length:n.rowCount},(()=>""))));const l=()=>o.DataFrame.fromColumns([o.Column.fromStrings(s,[]),o.Column.fromInt32Array(r,new Int32Array([])),o.Column.fromStrings("Actions",[]),o.Column.fromBitSet(a,o.BitSet.create(0,(()=>!1)))]),d=o.Viewer.grid(l());d.root.style.width="100%",d.root.style.minWidth="230px",d.columns.setVisible([s,r,"Actions"]),this.root.append(e.divV([e.divV([d.root],{style:{height:"75%"}})],{style:{height:"100%"}}));const u=()=>{var t,e;if(!d.dataFrame)return;null===(t=n.col(i))||void 0===t||t.markers.assign("true",o.MARKER_TYPE.OUTLIER);const r=null===(e=d.dataFrame)||void 0===e?void 0:e.cell(d.dataFrame.rowCount-1,s).value;n.selection.getSelectedIndexes().forEach((t=>{n.col(i).set(t,!0,!1),n.col(s).set(t,r,!1)})),n.selection.setAll(!1),n.fireValuesChanged(),h()(p()).empty()},c=()=>{d.dataFrame&&(d.dataFrame.rows.removeAt(d.dataFrame.rowCount-1),n.selection.setAll(!1),h()(p()).empty())};d.onCellPrepare((t=>{var o,r,l;t.isTableCell&&("Actions"===t.gridColumn.name&&(t.gridColumn.cellType="html",t.style.element=e.divH([...(null===(o=t.grid.dataFrame)||void 0===o?void 0:o.get(a,t.gridRow))?[(l=null===(r=t.grid.dataFrame)||void 0===r?void 0:r.get(s,t.gridRow),e.div(e.icons.delete((()=>{for(let t=0;t<n.rowCount;t++)n.columns.byName(s).get(t)===l&&(n.columns.byName(s).set(t,"",!1),n.columns.byName(i).set(t,!1,!1));n.fireValuesChanged()}),"Remove the outliers group"),{style:{"text-align":"center",margin:"6px"}}))]:[e.div(e.iconFA("check",u,"Confirm the outliers"),{style:{"text-align":"center",margin:"6px"}}),e.div(e.iconFA("times",c,"Cancel the outliers"),{style:{"text-align":"center",margin:"6px"}})]])))})),d.onCellValueEdited.subscribe((t=>{var e,i;if(!d.dataFrame||t.gridColumn.name!==s)return;if(!d.dataFrame.columns.byName(a).get(t.gridRow))return;const o=new Set;for(let t=0;t<(null===(e=d.dataFrame)||void 0===e?void 0:e.rowCount);t++){const e=null===(i=d.dataFrame)||void 0===i?void 0:i.columns.byName(s).get(t);o.add(e)}for(let e=0;e<n.rowCount;e++){const i=n.columns.byName(s).get(e);""==i||o.has(i)||n.columns.byName(s).set(e,t.cell.value)}}));const f=()=>{if(n.columns.byName(s))for(let t=0;t<n.rowCount;t++)n.columns.byName(i).get(t)?""===n.columns.byName(s).get(t)&&n.columns.byName(s).set(t,"Manual",!1):""!==n.columns.byName(s).get(t)&&n.columns.byName(s).set(t,"",!1);const t={};if(n.columns.byName(s))for(let e=0;e<n.rowCount;e++){const i=n.columns.byName(s).get(e),o=t[i];""!=i&&(o?t[i]++:t[i]=1)}d.dataFrame=l(),d.columns.setVisible([s,r,"Actions"]),Object.keys(t).map((e=>{var n;null===(n=d.dataFrame)||void 0===n||n.rows.addNew([e,t[e],"",!0])}))};n.onDataChanged.subscribe(f),n.onSelectionChanged.subscribe((()=>{if(!d.dataFrame||!n.selection.trueCount)return;const i=p();if(i&&!h()(i).is(":empty")||t.shell.info(e.div([e.divText("Confirm selected points as outliers?"),e.divH([e.button("Confirm",u),e.button("Cancel",c)])])),d.dataFrame.columns.byName(a).toList().some((t=>!1===t)))d.dataFrame.set(r,d.dataFrame.rowCount-1,n.selection.trueCount);else{const t=d.dataFrame.rows.addNew(["Manual",n.selection.trueCount,"",!1]);d.dataFrame.currentCell=d.dataFrame.cell(t.idx,s)}})),n.selection.setAll(!1),f()}}const m=rxjs;var v=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const g=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 y;!function(e){const n={};function i(e){var i;return v(this,void 0,void 0,(function*(){const o=e.func.id,s=null!==(i=n[o])&&void 0!==i?i:yield t.dapi.functions.include("package").allPackageVersions().find(o);n[o]||(n[o]=s),e.func=s}))}e.augmentCallWithFunc=i,e.loadChildRuns=function(e){return v(this,void 0,void 0,(function*(){const n=yield t.dapi.functions.calls.allPackageVersions().find(e);yield i(n);const o=yield t.dapi.functions.calls.allPackageVersions().include("func").filter(`options.parentCallId="${e}"`).list();return yield Promise.all(o.map((t=>v(this,void 0,void 0,(function*(){return i(t)}))))),{parentRun:n,childRuns:o}}))},e.loadRun=function(e,n=!1){return v(this,void 0,void 0,(function*(){const s=yield t.dapi.functions.calls.allPackageVersions().include("inputs, outputs, session.user").find(e);if(yield i(s),!n){const e=r()(s.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const n of e)s.outputs[n.name]=yield t.dapi.tables.getTable(s.outputs[n.name]);const n=r()(s.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const e of n)s.inputs[e.name]=yield t.dapi.tables.getTable(s.inputs[e.name])}return s}))},e.saveRun=function(e){return v(this,void 0,void 0,(function*(){const n=r()(e.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const i of n)e.outputs[i.name]=e.outputs[i.name].clone(),yield t.dapi.tables.uploadDataFrame(e.outputs[i.name]);const i=r()(e.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const n of i)e.inputs[n.name]=e.inputs[n.name].clone(),yield t.dapi.tables.uploadDataFrame(e.inputs[n.name]);return yield t.dapi.functions.calls.allPackageVersions().save(e)}))},e.deleteRun=function(e){return v(this,void 0,void 0,(function*(){yield t.dapi.functions.calls.allPackageVersions().delete(e)}))},e.pullRuns=function(e,n={},i={}){return v(this,void 0,void 0,(function*(){let o=`func.id="${e}"`;return o+=n.author?` and session.user.id="${n.author.id}"`:"",o+=n.date?g(n.date):"",t.dapi.functions.calls.allPackageVersions().filter(o).include("session.user, options").list(i)}))},e.pullRunsByName=function(e,n=[],s={},a=[]){return v(this,void 0,void 0,(function*(){let l="";for(const t of n){const e=[];t.author&&e.push(`session.user.id="${t.author.id}"`),t.date&&e.push(g(t.date)),t.isShared&&e.push('options.isShared="true"'),t.text&&e.push(`((options.title like "${t.text}") or (options.annotation like "${t.text}"))`);const n=e.join(" and ");""!==n&&(l+=""===l?`(${n})`:` or (${n})`)}""!==l&&(l=` and (${l})`);const d=yield t.dapi.functions.calls.allPackageVersions().filter(`func.name="${e}"${l}`).include(`${a.join(",")}`).list(s);for(const t of d)yield i(t);if(a.includes("inputs")||a.includes("func.params"))for(const e of d){const n=r()(e.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const i of n)e.inputs[i.name]=yield t.dapi.tables.getTable(e.inputs[i.name])}if(a.includes("outputs")||a.includes("func.params"))for(const e of d){const n=r()(e.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const i of n)e.outputs[i.name]=yield t.dapi.tables.getTable(e.outputs[i.name])}return d}))}}(y||(y={}));const b=ExcelJS;var A,C=n.n(b),w=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};!function(t){t.isSheetExist=(t,e)=>n=>w(this,void 0,void 0,(function*(){const i=n.worksheets.find((e=>e.name===t));return i?{isValid:!0,chainedFuncs:e,result:i}:{isValid:!1,caption:`Sheet named '${t}' is not found`,content:`Sheet name should be exactly \`${t}\` to be parsed.\n\n\nPlease double-check:\n- No extra spaces are in the sheet name\n- Capitalization is the same as in the template\n\n\n${n.worksheets.length>0?`Found sheets: \`${n.worksheets.map((t=>t.name)).join("`,`")}\``:"No columns have found."}\n `}})),t.isColumnExist=(t,e)=>n=>w(this,void 0,void 0,(function*(){const i=n.getRow(1).values;return i.includes(t)?{isValid:!0,chainedFuncs:e}:{isValid:!1,caption:`No column "${t}" in "${n.name}" sheet`,content:`Column name should be exactly \`${t}\` to be parsed.\n\n\nPlease double-check:\n- Column names are in the first row of the sheet\n- No extra spaces are in the cell\n- Capitalization is the same as in the template\n\n\n${i.length>0?`Found columns: \`${i.filter((t=>""!==t)).join("`,`")}\``:"No columns have found."}\n `}})),t.isExcelParsed=t=>e=>w(this,void 0,void 0,(function*(){return(new(C().Workbook)).xlsx.load(yield e.arrayBuffer()).then((e=>w(this,void 0,void 0,(function*(){return{isValid:!0,chainedFuncs:t,result:e}})))).catch((()=>({isValid:!1,caption:"File is failed to parse",content:"Please make sure:\n- XLSX format is used (not XLS or XLSM)\n- File should not be corrupted\n\n\nXLS could be converted to XLSX using Excel's export functionality. \n\nIf the file is corrupted, it will not open in Excel.\n "})))}))}(A||(A={}));var x=n(701),E=n.n(x),R=n(236),I=n.n(R),T=n(80),S=n.n(T),F=n(850),P=n.n(F),B=n(182),k=n.n(B),O=n(213),V=n.n(O),M=n(669),L={};L.styleTagTransform=V(),L.setAttributes=P(),L.insert=S().bind(null,"head"),L.domAPI=I(),L.insertStyleElement=k(),E()(M.Z,L),M.Z&&M.Z.locals&&M.Z.locals;var D=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const _="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class N extends o.InputBase{get value(){return this.fileValue}set value(t){this.stringValue=(null==t?void 0:t.name)||"Drag-n-drop your file",this.fileValue=t,this.notify&&this.fireInput()}constructor(t="Drag-n-drop here",n=null,i=null,s=_){super(e.stringInput("Input file","",null).dart),this.initialText=t,this.initialValue=n,this.onValueChanged=i,this.fileType=s,this.uploadedFile$=new m.Subject,this.onFileUploaded=this.uploadedFile$,this.fileValue=null,this.validation=new class{constructor(t=[]){this.validators=t}validate(t){return w(this,void 0,void 0,(function*(){const n=[],i=(t,e)=>w(this,void 0,void 0,(function*(){for(const o of t){const t=yield o(e);t.isValid?t.chainedFuncs&&(yield i(t.chainedFuncs,t.result)):n.push(t)}}));for(const e of this.validators){const o=yield e(t);o.isValid?o.chainedFuncs&&(yield i(o.chainedFuncs,o.result)):n.push(o)}if(0==n.length)return!0;const s=new o.Wizard({title:"Data validation failed"});n.forEach((t=>{s.page({caption:t.caption,root:t.content instanceof HTMLElement?t.content:e.markdown(t.content)})})),s.onOK((()=>{}));const r=s.getButton("CANCEL"),a=s.getButton("<<"),l=s.getButton(">>"),d=s.getButton("OK"),u=s.pages.length,c=e.divText("1/"+u);return c.style.position="absolute",c.style.left="12px",c.style.color="var(--grey-5)",s.captionHost.style.fontSize="20px",s.captionHost.style.fontWeight="400",s.captionHost.style.margin="6px 0",h()(s.root).find(".d4-command-bar").append(c),h()(a).html("BACK"),h()(l).html("NEXT"),h()(d).addClass("disabled"),r.style.display="none",a.addEventListener("click",(()=>{const t=s.pageIndex+1,e=s.pages.length;s.captionHost.style.fontSize="20px",s.captionHost.style.fontWeight="400",s.captionHost.style.margin="6px 0",s.completable||h()(d).addClass("disabled"),c.textContent=t+"/"+e})),l.addEventListener("click",(()=>{const t=s.pageIndex+1,e=s.pages.length;s.captionHost.style.fontSize="20px",s.captionHost.style.fontWeight="400",s.captionHost.style.margin="6px 0",s.completable&&h()(d).removeClass("disabled"),c.textContent=t+"/"+e})),s.show(),!1}))}},this.isValid=new m.BehaviorSubject(!0),this.hiddenInput=document.createElement("input"),this.icon=e.iconFA("cloud-upload",(()=>this.hiddenInput.click())),this.subscribeOnEvents(),this.root.style.display="flex",this.isValid.subscribe((t=>{if(t){this.input.classList.remove("error"),this.input.classList.add("success");const t=e.iconFA("times",(()=>this.reset()),"Reset uploaded file");this.icon.replaceWith(t),this.icon=t}else{this.input.classList.remove("success"),this.input.classList.add("error");const t=e.iconFA("redo",(()=>this.hiddenInput.click()),"Re-upload a file");this.icon.replaceWith(t),this.icon=t}})),this.uploadedFile$.subscribe((t=>{if(this.onValueChanged&&this.onValueChanged(t),!t){const t=e.iconFA("cloud-upload",(()=>this.hiddenInput.click()),"Choose a file to upload");this.icon.replaceWith(t),this.icon=t}this.value=t})),this.reset()}subscribeOnEvents(){this.input.readOnly=!0,this.input.classList.add("default");const t=t=>D(this,void 0,void 0,(function*(){if(t&&t.length&&this.enabled){if(t.length>1)throw this.isValid.next(!1),new Error("Please specify single input file");if(this.fileType&&t[0].type!==this.fileType)throw this.isValid.next(!1),new Error("File type is not supported");this.isValid.next(yield this.validation.validate(t[0])),this.isValid.value?this.uploadedFile$.next(t[0]):this.uploadedFile$.next(null)}}));this.root.classList.add("fi-drop-area"),this.root.style.width="100%",this.hiddenInput.type="file",this.hiddenInput.addEventListener("change",(()=>D(this,void 0,void 0,(function*(){return yield t(this.hiddenInput.files)}))),!1),["dragenter","dragover","dragleave","drop"].forEach((t=>{this.input.addEventListener(t,(t=>{t.preventDefault(),t.stopPropagation()}),!1)})),["dragenter","dragover"].forEach((t=>{this.input.addEventListener(t,(()=>{this.input.classList.add("drag-n-dropping")}),!1)})),["dragleave","drop"].forEach((t=>{this.input.addEventListener(t,(()=>{this.input.classList.remove("drag-n-dropping")}),!1)})),this.input.addEventListener("drop",(e=>D(this,void 0,void 0,(function*(){const n=e.dataTransfer.files;t(n)}))),!1),this.input.addEventListener("click",(()=>this.hiddenInput.click()),!1),this.addOptions(this.icon),["drag","dragenter"].forEach((t=>{document.getElementsByClassName("layout-workarea")[0].addEventListener(t,(t=>{t.stopPropagation()}),!1)}))}reset(){this.input.classList.value="ui-input-editor default",this.hiddenInput.value="",this.uploadedFile$.next(null)}}const j=rxjs.operators;var W=n(380),H={};H.styleTagTransform=V(),H.setAttributes=P(),H.insert=S().bind(null,"head"),H.domAPI=I(),H.insertStyleElement=k(),E()(W.Z,H),W.Z&&W.Z.locals&&W.Z.locals;var U=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class G{static getHistoryRuns(e,n=!0){return(0,m.from)((()=>U(this,void 0,void 0,(function*(){return yield y.pullRunsByName(e,[{isShared:!0},{author:t.shell.user}],{order:"started"},[...n?["func.params"]:[],"session.user","options"])})))())}}class Y{constructor(t,n,i,s,r=[],a=!0){var l;this.label=t,this._funcName=n,this._stringValueFunc=i,this._visibleColumnsForGrid=s,this._visibleColumnsForFilter=r,this.includeParams=a,this.onHistoricalRunChosen=new m.BehaviorSubject(null),this.experimentRunsUpdate=new m.Subject,this.store={experimentRuns:new m.Observable,experimentRunsDf:new m.BehaviorSubject(o.DataFrame.fromColumns([o.Column.fromStrings("Pick",[]),...Object.keys(this._visibleColumnsForGrid).map((t=>o.Column.fromStrings(t,[])))])),isExperimentRunsLoading:new m.Subject,experimentRunData:new m.BehaviorSubject("")},this._historyGrid=o.Viewer.grid(this.store.experimentRunsDf.value,{showRowHeader:!1,showColumnGridlines:!1,allowEdit:!1}),this._historyFilters=o.Viewer.filters(this.store.experimentRunsDf.value,{title:"Filters"}),this._visibleInput=e.stringInput(this.label,"",null),this._visibleIcon=e.iconFA("bars",(()=>this.showSelectionDialog()),this.label),this._historyGrid.columns.byName("Pick").cellType="html",this._historyGrid.columns.byName("Pick").width=30,this._historyGrid.root.style.height="100%";for(let t=0;t<this._historyGrid.columns.length;t++){const e=null===(l=this._historyGrid.columns.byIndex(t))||void 0===l?void 0:l.column;e&&e.type===o.TYPE.DATE_TIME&&(this._historyGrid.columns.byIndex(t).format="MMM d, yyyy",this._historyGrid.columns.byIndex(t).width=100)}this._visibleInput.input.addEventListener("click",(()=>this.showSelectionDialog())),this._visibleInput.readOnly=!0,this._visibleIcon.style.display="none",this.store.experimentRuns=this.experimentRunsUpdate.pipe((0,j.tap)((()=>this.toggleLoaderExpRuns(!0))),(0,j.switchMap)((()=>G.getHistoryRuns(this._funcName,this.includeParams).pipe((0,j.catchError)((t=>(console.error(t),m.EMPTY))),(0,j.finalize)((()=>this.toggleLoaderExpRuns(!1)))))),(0,j.shareReplay)(1)),this.store.experimentRuns.subscribe((t=>{const e=o.DataFrame.fromColumns([o.Column.bool("Pick",t.length).init(!1),...Object.entries(this._visibleColumnsForGrid).map((e=>o.Column.fromStrings(e[0],t.map(e[1])))),o.Column.fromStrings("ID",t.map((t=>t.id)))]);e.onCurrentRowChanged.subscribe((()=>{e.getCol("Pick").init(!1),e.set("Pick",e.currentRow.idx,!0);const n=e.getCol("ID").get(e.currentRow.idx);this._chosenRun=t.find((t=>t.id===n))})),this.store.experimentRunsDf.next(e),this._visibleIcon.style.display="inherit"})),this.store.experimentRunsDf.subscribe((t=>{this.historyGrid.dataFrame=t,this.historyFilters.dataFrame=t})),this.onHistoricalRunChosen.subscribe((t=>{this._visibleInput.value=t?this._stringValueFunc(t):""})),this.store.isExperimentRunsLoading.subscribe((t=>{e.setUpdateIndicator(this._visibleInput.root,t)}))}showSelectionDialog(){var t;const n=e.dialog();n.onOK((()=>U(this,void 0,void 0,(function*(){if(this._chosenRun){let t=this._chosenRun;this.includeParams||(t=yield y.loadRun(t.id)),this.onHistoricalRunChosen.next(t)}})))),n.onCancel((()=>{this.onHistoricalRunChosen.next(null),this.historyGrid.dataFrame.currentRowIdx=-1}));const i=o.Viewer.filters(this.store.experimentRunsDf.value,{title:"Filters"});this._historyFilters.root.replaceWith(i.root),this._historyFilters=i;const s=o.Viewer.grid(this.store.experimentRunsDf.value,{showRowHeader:!1,showColumnGridlines:!1,allowEdit:!1});this._historyGrid.root.replaceWith(s.root),this._historyGrid=s,this._historyGrid.columns.byName("Pick").cellType="html",this._historyGrid.columns.byName("Pick").width=30,this._historyGrid.root.style.height="100%";for(let e=0;e<this._historyGrid.columns.length;e++){const n=null===(t=this._historyGrid.columns.byIndex(e))||void 0===t?void 0:t.column;n&&n.type===o.TYPE.DATE_TIME&&(this._historyGrid.columns.byIndex(e).format="MMM d yyyy HH:mm")}this._historyGrid.onCellPrepare((t=>{var n;"Pick"===(null===(n=t.tableColumn)||void 0===n?void 0:n.name)&&(t.isColHeader&&(t.customText=""),!0===t.cell.value?t.element=e.div([e.iconFA("check",null,"Selected")],{style:{"text-align":"center",margin:"6px"}}):t.element=e.div())})),this._historyGrid.columns.setVisible(["Pick",...Object.keys(this._visibleColumnsForGrid).map((t=>t))]),this._historyFilters.setOptions({columnNames:this._visibleColumnsForFilter}),this._historyFilters.root.style.height="100%",h()(this._historyFilters.root).find(".d4-filter-group-header").hide(),this._visibleColumnsForFilter.length||h()(this._historyFilters.root.parentElement).hide(),n.add(e.divH([e.block([this._historyGrid.root]),e.block([this._historyFilters.root],{style:{"margin-left":"10px",width:"300px",height:"100%"}})],{style:{height:"100%"}})),n.show({modal:!0,fullScreen:!0,center:!0,width:Math.max(400,window.screen.width-200),height:Math.max(200,window.screen.height-200)})}get historyGrid(){return this._historyGrid}get historyFilters(){return this._historyFilters}get root(){return this._visibleInput.root}get iconRoot(){return this._visibleIcon}set value(t){this._visibleInput.value=t?this._stringValueFunc(t):""}get value(){return this.onHistoricalRunChosen.value}set stringValue(t){this._visibleInput.value=t}get stringValue(){return this._visibleInput.value}toggleLoaderExpRuns(t){this.store.isExperimentRunsLoading.next(t)}}const z=dayjs;var Z=n.n(z),q=n(778),J={};J.styleTagTransform=V(),J.setAttributes=P(),J.insert=S().bind(null,"head"),J.domAPI=I(),J.insertStyleElement=k(),E()(q.Z,J),q.Z&&q.Z.locals&&q.Z.locals;var X=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class K{constructor(){this.filteringOptions={text:""},this.allRuns=new m.BehaviorSubject([])}get myRuns(){return this.allRuns.value.filter((e=>e.author.id===t.shell.user.id))}get favoriteRuns(){return this.allRuns.value.filter((t=>t.options.isFavorite&&!t.options.isImported))}get sharedRuns(){return this.allRuns.value.filter((t=>t.options.isShared))}get filteredMyRuns(){return this.myRuns.filter((t=>{const e=!this.filteringOptions.startedAfter||t.started>this.filteringOptions.startedAfter,n=!this.filteringOptions.text.length||!!t.options.title&&t.options.title.includes(this.filteringOptions.text),i=!this.filteringOptions.text.length||!!t.options.description&&t.options.description.includes(this.filteringOptions.text),o=!this.filteringOptions.tags||0===this.filteringOptions.tags.length||!!t.options.tags&&this.filteringOptions.tags.every((e=>t.options.tags.includes(e)));return(n||i)&&e&&o}))}get filteredFavoriteRuns(){return this.favoriteRuns.filter((t=>{const e=!this.filteringOptions.startedAfter||t.started>this.filteringOptions.startedAfter,n=!this.filteringOptions.text.length||!!t.options.title&&t.options.title.includes(this.filteringOptions.text),i=!this.filteringOptions.text.length||!!t.options.description&&t.options.description.includes(this.filteringOptions.text),o=!this.filteringOptions.tags||0===this.filteringOptions.tags.length||!!t.options.tags&&this.filteringOptions.tags.every((e=>t.options.tags.includes(e)));return(n||i)&&e&&o}))}get filteredSharedRuns(){return this.sharedRuns.filter((t=>{const e=!this.filteringOptions.author||t.author.id===this.filteringOptions.author.id,n=!this.filteringOptions.startedAfter||t.started>this.filteringOptions.startedAfter,i=!this.filteringOptions.text.length||!!t.options.title&&t.options.title.includes(this.filteringOptions.text),o=!this.filteringOptions.text.length||!!t.options.description&&t.options.description.includes(this.filteringOptions.text),s=!this.filteringOptions.tags||0===this.filteringOptions.tags.length||!!t.options.tags&&this.filteringOptions.tags.every((e=>t.options.tags.includes(e)));return(i||o)&&n&&e&&s}))}}const Q="HISTORY",tt="FAVORITES",et="SHARED";class nt{get selectedCallsSet(){const t=this.tabs.currentPane.name;if(t===Q)return this.mySelectedCallsSet;if(t===tt)return this.favoritesSelectedCallsSet;if(t===et)return this.sharedSelectedCallsSet;throw new Error("Unknown tab is selected")}buildActionsSection(t){const n=(()=>{if(t===Q)return this.mySelectedCallsSet;if(t===tt)return this.favoritesSelectedCallsSet;if(t===et)return this.sharedSelectedCallsSet;throw new Error("Unknown tab is selected")})();return e.divH([e.span([`Selected: ${n.size}`],{style:{"align-self":"center"}}),e.divH([(()=>{const t=e.iconFA("exchange",(()=>X(this,void 0,void 0,(function*(){this.onComparison.next([...r()(n.keys()).map((t=>t.id))])}))),"Compare selected runs");return t.style.margin="5px",n.size<2&&t.classList.add("hp-disabled"),t})(),(()=>{const t=e.iconFA("trash-alt",(()=>this.showDeleteRunDialog(n)),"Delete selected runs");return t.style.margin="5px",0===n.size&&t.classList.add("hp-disabled"),t})(),...0===n.size?[(()=>{const t=e.iconFA("square",(()=>{switch(this.tabs.currentPane.name){case Q:this.store.myRuns.forEach((t=>n.add(t))),this.myRunsFilter.next();break;case tt:this.store.favoriteRuns.forEach((t=>n.add(t))),this.favRunsFilter.next();break;case et:this.store.sharedRuns.forEach((t=>n.add(t))),this.sharedRunsFilter.next()}this.updateActionsSection(this.tabs.currentPane.name)}),"Select all");return t.style.margin="5px",t})()]:[(()=>{let t=0;switch(this.tabs.currentPane.name){case Q:t=this.store.myRuns.length;break;case tt:t=this.store.favoriteRuns.length;break;case et:t=this.store.sharedRuns.length}const i=n.size===t?"check-square":"minus-square",o=e.iconFA(i,(()=>{switch(this.tabs.currentPane.name){case Q:this.store.myRuns.forEach((t=>n.delete(t))),this.myRunsFilter.next();break;case tt:this.store.favoriteRuns.forEach((t=>n.delete(t))),this.favRunsFilter.next();break;case et:this.store.sharedRuns.forEach((t=>n.delete(t))),this.sharedRunsFilter.next()}this.updateActionsSection(this.tabs.currentPane.name)}),"Unselect all");return o.style.margin="5px",o})()]])],{style:{"justify-content":"space-between",padding:"0 12px"}})}buildFilterPane(n){return e.wait((()=>X(this,void 0,void 0,(function*(){const i=new m.Subject,s=e.stringInput("Search","",(t=>i.next(t)));o.debounce(i.asObservable(),600).subscribe((()=>{this.store.filteringOptions.text=s.stringValue,this.myRunsFilter.next(),this.favRunsFilter.next(),this.sharedRunsFilter.next()}));const r=e.dateInput("Started after",Z()().subtract(1,"week"),(t=>{this.store.filteringOptions.startedAfter=t,this.myRunsFilter.next(),this.favRunsFilter.next(),this.sharedRunsFilter.next()})),a=Object.values(o.User.defaultUsersIds),l=(yield t.dapi.users.list()).filter((t=>!a.includes(t.id))),d=e.choiceInput("Author","Anyone",["Anyone",...l],(t=>{this.store.filteringOptions.author="Anyone"===t?void 0:t,this.sharedRunsFilter.next()}));d.root.style.display="none";let u=e.choiceInput("Tag","Choose tag to filter",["Choose tag to filter"]);const c=o.TagEditor.create(),h=e.stringInput(" ","");h.input.replaceWith(c.root),h.root.style.display="none",c.onChanged((()=>{this.store.filteringOptions.tags=c.tags.filter((t=>!!t)),0===this.store.filteringOptions.tags.length?h.root.style.display="none":h.root.style.removeProperty("display"),this.myRunsFilter.next(),this.favRunsFilter.next(),this.sharedRunsFilter.next()})),this.store.allRuns.subscribe((()=>{const t=this.store.allRuns.value.map((t=>t.options.tags)).reduce(((t,e)=>(e&&e.forEach((e=>{t.includes(e)||t.push(e)})),t)),[]),n=e.choiceInput("Tag","Choose tag to filter",["Choose tag to filter",...t]);u.root.replaceWith(n.root),u=n,u.onChanged((()=>{u.value&&"Choose tag to filter"!==u.value&&!c.tags.includes(u.value)&&c.addTag(u.value)}))})),r.addPatternMenu("datetime");const p=e.divV([s,r,d,u,h],"ui-form ui-form-wide ui-form-left");return n===Q&&(r.root.style.removeProperty("display"),d.root.style.display="none"),n===tt&&(r.root.style.removeProperty("display"),d.root.style.display="none"),n===et&&(r.root.style.removeProperty("display"),d.root.style.removeProperty("display")),p}))))}showDeleteRunDialog(t){e.dialog({title:`Delete ${t.size} ${t.size>1?"runs":"run"}`}).add(e.divText(`Deleted ${t.size} ${t.size>1?"runs":"run"} ${t.size>1?"are":"is"} impossible to restore. Are you sure?`)).onOK((()=>X(this,void 0,void 0,(function*(){t.forEach((t=>X(this,void 0,void 0,(function*(){this.beforeRunDeleted.next(t.id),this.selectedCallsSet.delete(t),yield y.deleteRun(t),this.afterRunDeleted.next(t.id)}))))})))).show({center:!0})}updateActionsSection(t){const e=this.buildActionsSection(t);(()=>{t===Q&&(this.myActionsSection.replaceWith(e),this.myActionsSection=e),t===tt&&(this.favActionsSection.replaceWith(e),this.favActionsSection=e),t===et&&(this.sharedActionsSection.replaceWith(e),this.sharedActionsSection=e)})()}updateSharedPane(t){const n=t.length>0?this.renderSharedCards(t):e.divText("No runs are marked as shared","hi-no-elements-label"),i=e.divV([this.sharedPaneFilter,this.sharedActionsSection,e.element("div","splitbar-horizontal"),n]);this.sharedTab.replaceWith(i),this.sharedTab=i}updateFavoritesPane(t){const n=t.length>0?this.renderFavoriteCards(t):e.divText("No runs are marked as favorites","hi-no-elements-label"),i=e.divV([this.favoritesPaneFilter,this.favActionsSection,e.element("div","splitbar-horizontal"),n]);this.favTab.replaceWith(i),this.favTab=i}updateMyPane(t){const n=t.length>0?this.renderHistoryCards(t):e.divText("No runs are found in history","hi-no-elements-label"),i=e.divV([this.myPaneFilter,this.myActionsSection,e.element("div","splitbar-horizontal"),n]);this.historyTab.replaceWith(i),this.historyTab=i}renderCard(n){var i;const o=n.author.picture;o.style.width="25px",o.style.height="25px",o.style.fontSize="20px";const s=e.label(null!==(i=n.options.title)&&void 0!==i?i:n.author.friendlyName,{style:{color:"var(--blue-1)"}});e.bind(n.author,o);const r=e.iconFA("square",(t=>{t.stopPropagation(),this.selectedCallsSet.add(n),r.style.display="none",a.style.removeProperty("display"),this.updateActionsSection(this.tabs.currentPane.name)}),"Select this run");r.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const a=e.iconFA("check-square",(t=>{t.stopPropagation(),this.selectedCallsSet.delete(n),a.style.display="none",this.updateActionsSection(this.tabs.currentPane.name),r.style.removeProperty("display")}),"Unselect this run");a.classList.add("hp-funccall-card-icon"),this.selectedCallsSet.has(n)?(r.style.display="none",a.style.removeProperty("display")):(r.style.removeProperty("display"),a.style.display="none");const l=e.iconFA("edit",(t=>{t.stopPropagation(),this.showEditDialog(n)}),"Edit selected run");l.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const d=e.iconFA("trash-alt",(t=>X(this,void 0,void 0,(function*(){t.stopPropagation();const e=new Set;e.add(n),this.showDeleteRunDialog(e)}))),"Delete selected runs");d.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const u=e.iconFA("star",null,"Unfavorite the run");u.classList.add("fas","hp-funccall-card-def-icon");const c=e.iconFA("share-alt",null,"Add to shared");c.classList.add("fas","hp-funccall-card-def-icon"),c.style.color="var(--blue-1)";const h=new Date(n.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"}),p=e.divH([e.divH([o,e.divV([s,e.span([h]),...n.options.description?[e.divText(n.options.description,"description")]:[],...n.options.tags&&n.options.tags.length>0?[e.div(n.options.tags.map((t=>e.span([t],"d4-tag"))))]:[]],"hp-card-content")]),e.divH([l,d,...n.options.isFavorite?[u]:[],...n.options.isShared?[c]:[],r,a])],"hp-funccall-card");return p.addEventListener("click",(()=>X(this,void 0,void 0,(function*(){this.onRunChosen.next(n.id),[...this.myCards,...this.favoriteCards,...this.sharedCards].forEach((t=>t.classList.remove("clicked"))),p.classList.add("clicked")})))),e.tooltip.bind(p,(()=>e.tableFromMap(Object.assign(Object.assign(Object.assign({Author:t.shell.user.toMarkup(),Date:h},n.options.title?{Title:n.options.title}:{}),n.options.description?{Description:n.options.description}:{}),n.options.tags&&n.options.tags.length>0?{Tags:e.div(n.options.tags.map((t=>e.span([t],"d4-tag"))),"d4-tag-editor")}:{})))),p}showEditDialog(t){var n,i,s,r;const a=e.dialog({title:"Edit run"});let l=null!==(n=t.options.title)&&void 0!==n?n:"",d=null!==(i=t.options.description)&&void 0!==i?i:"";const u=e.stringInput("Title",l,(t=>l=t));let c=null!==(s=t.options.isShared)&&void 0!==s&&s,h=null!==(r=t.options.isFavorite)&&void 0!==r&&r;const p=o.TagEditor.create();(t.options.tags||[]).forEach((t=>{p.addTag(t)}));const f=e.stringInput(" ","");f.input.replaceWith(p.root);const m=e.stringInput("Tag",""),v=()=>{""===m.value||p.tags.includes(m.value)||(p.addTag(m.value),m.value="")};m.addOptions(e.iconFA("plus",v,"Add this tag")),m.input.onkeydown=t=>X(this,void 0,void 0,(function*(){"Enter"==t.key&&(t.stopPropagation(),v())})),a.add(e.form([u,e.stringInput("Description",d,(t=>{d=t})),e.boolInput("Favorites",h,(t=>h=t)),e.boolInput("Share",c,(t=>c=t)),m,f])).onOK((()=>X(this,void 0,void 0,(function*(){if((t=yield y.loadRun(t.id)).options.title=""!==l?l:null,t.options.description=""!==d?d:null,t.options.tags=[...p.tags],!!c==!!t.options.isShared&&!!h==!!t.options.isFavorite){e.setUpdateIndicator(this.tabs.root,!0),yield y.saveRun(t);const n=this.store.allRuns.value.find((e=>e.id===t.id));return n.options.title=""!==l?l:null,n.options.description=""!==d?d:null,n.options.tags=[...t.options.tags],this.store.allRuns.next(this.store.allRuns.value),void e.setUpdateIndicator(this.tabs.root,!1)}c&&!t.options.isShared&&(t.options.isShared=c,e.setUpdateIndicator(this.tabs.root,!0),yield this.addRunToShared(t),e.setUpdateIndicator(this.tabs.root,!1)),!c&&t.options.isShared&&(t.options.isShared=c,e.setUpdateIndicator(this.tabs.root,!0),yield this.removeRunFromShared(t),e.setUpdateIndicator(this.tabs.root,!1)),h&&!t.options.isFavorite&&(t.options.isFavorite=h,e.setUpdateIndicator(this.tabs.root,!0),yield this.addRunToFavorites(t),e.setUpdateIndicator(this.tabs.root,!1)),!h&&t.options.isFavorite&&(t.options.isFavorite=h,e.setUpdateIndicator(this.tabs.root,!0),yield this.removeRunFromFavorites(t),e.setUpdateIndicator(this.tabs.root,!1))})))).show({center:!0,width:500})}renderFavoriteCards(t){return this.favoriteCards=t.map((t=>this.renderCard(t))),e.divV(this.favoriteCards)}renderSharedCards(t){return this.sharedCards=t.map((t=>this.renderCard(t))),e.divV(this.sharedCards)}renderHistoryCards(t){return this.myCards=t.map((t=>this.renderCard(t))),e.divV(this.myCards,{style:{height:"100%"}})}constructor(t){this.func=t,this.onRunChosen=new m.Subject,this.onComparison=new m.Subject,this.beforeRunAddToFavorites=new m.Subject,this.beforeRunAddToShared=new m.Subject,this.beforeRunRemoveFromFavorites=new m.Subject,this.beforeRunRemoveFromShared=new m.Subject,this.beforeRunDeleted=new m.Subject,this.afterRunAddToFavorites=new m.Subject,this.afterRunAddToShared=new m.Subject,this.afterRunRemoveFromFavorites=new m.Subject,this.afterRunRemoveFromShared=new m.Subject,this.afterRunDeleted=new m.Subject,this.store=new K,this.myRunsFilter=new m.Subject,this.favRunsFilter=new m.Subject,this.sharedRunsFilter=new m.Subject,this.mySelectedCallsSet=new Set,this.favoritesSelectedCallsSet=new Set,this.sharedSelectedCallsSet=new Set,this.allRunsFetch=new m.Subject,this.historyTab=e.div(),this.favTab=e.div(),this.sharedTab=e.div(),this.filterPane=e.div(),this.tabs=e.tabControl({[Q]:e.box(this.historyTab),[tt]:e.box(this.favTab),[et]:e.box(this.sharedTab)}),this.myActionsSection=this.buildActionsSection(Q),this.favActionsSection=this.buildActionsSection(tt),this.sharedActionsSection=this.buildActionsSection(et),this._root=e.divV([this.tabs.root],{style:{width:"100%",height:"100%"}}),this.myCards=[],this.favoriteCards=[],this.sharedCards=[],this.myPaneFilter=this.buildFilterPane(Q),this.favoritesPaneFilter=this.buildFilterPane(tt),this.sharedPaneFilter=this.buildFilterPane(et),this.tabs.root.style.width="100%",this.tabs.root.style.height="100%",this.myRunsFilter.subscribe((()=>this.updateMyPane(this.store.filteredMyRuns))),this.favRunsFilter.subscribe((()=>this.updateFavoritesPane(this.store.filteredFavoriteRuns))),this.sharedRunsFilter.subscribe((()=>this.updateSharedPane(this.store.filteredSharedRuns))),this.store.allRuns.subscribe((()=>{this.updateMyPane(this.store.filteredMyRuns),this.updateFavoritesPane(this.store.filteredFavoriteRuns),this.updateSharedPane(this.store.filteredSharedRuns)})),this.allRunsFetch.subscribe((()=>X(this,void 0,void 0,(function*(){e.setUpdateIndicator(this.root,!0);const t=(yield y.pullRunsByName(this.func.name,[],{order:"started"},["session.user","options"])).reverse();this.store.allRuns.next(t),e.setUpdateIndicator(this.root,!1)})))),this.afterRunAddToFavorites.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.tags=t.options.tags,e.options.isFavorite=!0,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunAddToShared.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.tags=t.options.tags,e.options.isShared=!0,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunRemoveFromFavorites.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.tags=t.options.tags,e.options.isFavorite=!1,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunRemoveFromShared.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.tags=t.options.tags,e.options.isShared=!1,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunDeleted.subscribe((t=>{this.store.allRuns.next(this.store.allRuns.value.filter((e=>e.id!==t))),this.updateActionsSection(this.tabs.currentPane.name)})),this.allRunsFetch.next()}addRunToFavorites(e){return X(this,void 0,void 0,(function*(){e.options.isFavorite=!0,this.beforeRunAddToFavorites.next(e);const n=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunAddToFavorites.next(n),n}))}removeRunFromFavorites(e){return X(this,void 0,void 0,(function*(){e.options.isFavorite=!1,this.beforeRunRemoveFromFavorites.next(e);const n=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunRemoveFromFavorites.next(n),n}))}addRunToShared(e){return X(this,void 0,void 0,(function*(){e.options.isShared=!0,this.beforeRunAddToShared.next(e);const n=yield t.dapi.groups.find(o.Group.defaultGroupsIds["All users"]),i=r()(e.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const o of i){const i=e.outputs[o.name];yield t.dapi.permissions.grant(i.getTableInfo(),n,!1)}const s=r()(e.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const i of s){const o=e.inputs[i.name];yield t.dapi.permissions.grant(o.getTableInfo(),n,!1)}const a=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunAddToShared.next(a),a}))}removeRunFromShared(e){return X(this,void 0,void 0,(function*(){e.options.isShared=!1,this.beforeRunRemoveFromShared.next(e);const n=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunRemoveFromShared.next(n),n}))}get root(){return this._root}}var it;!function(t){t.fileInput=function(t="Drag-n-drop here",e=null,n=null,i=_){return new N(t,e,n,i)},t.historyInput=function(t,e,n,i,o=[],s=!0){return new Y(t,e,n,i,o,s)},t.historyPanel=function(t){return new nt(t)}}(it||(it={}));const ot={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},st="JsCardView",rt="viewer";var at;!function(t){t.INPUT="Input",t.OUTPUT="Output"}(at||(at={}));const lt="experimental";var dt,ut,ct,ht;(ht=dt||(dt={})).HIDDEN="hidden",ht.VISIBLE="visible",(ct=ut||(ut={})).ENABLED="enabled",ct.DISABLED="disabled";const pt=t=>t.options.getRealData,ft=t=>{const e=t.options[rt];return void 0!==e?{name:t.name,config:JSON.parse(e,((t,e)=>{if("true"===e)return!0;if("false"===e)return!1;if("type"===t)return ot[e]||e;if(!t.toLowerCase().includes("color")){const t=Number.parseFloat(e);if(!Number.isNaN(t))return t}return e}))}:{name:t.name,config:[]}};var mt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const vt="Run name",gt="RunId";class yt extends o.TableView{static fromComparedRuns(e,n){var i,s,r;return mt(this,void 0,void 0,(function*(){const a=null!==(i=n.configFunc)&&void 0!==i?i:e[0].func,l=[...a.inputs,...a.outputs].map((t=>ft(t))).reduce(((t,e)=>(t[e.name]?t[e.name].push(...e.config):t[e.name]=e.config,t)),{}),d=t=>{var n;if(t.propertyType===o.TYPE.DATA_FRAME){const n=l[t.name].map((n=>{var i;let s=null!==(i=t.caption)&&void 0!==i?i:t.name;const r=o.Column.fromType(o.TYPE.DATA_FRAME,s,e.length);r.init((n=>{var i;return null!==(i=e[n].inputs[t.name])&&void 0!==i?i:e[n].outputs[t.name]}));const a=u.columns.getUnusedName(r.name);return r.name=a,s=a,r.temp[rt]=n,u.columns.add(r),r}));return n}{let i=null!==(n=t.caption)&&void 0!==n?n:t.name;const s=o.Column.fromType(t.propertyType,i,e.length);s.init((n=>{var i;return null!==(i=e[n].inputs[t.name])&&void 0!==i?i:e[n].outputs[t.name]}));const r=u.columns.getUnusedName(s.name);return s.name=r,i=r,u.columns.add(s),[s]}},u=o.DataFrame.create(e.length),c=[];e.forEach((t=>{var e;let n=null!==(e=t.options.title)&&void 0!==e?e:`${t.func.name} - ${new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}`,i=2;for(;c.includes(n);)n=`${t.func.name} - ${new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})} - ${i}`,i++;c.push(n)})),u.columns.add(o.Column.fromStrings(vt,c)),u.name=(null===(s=n.parentCall)||void 0===s?void 0:s.func.name)?`${null===(r=n.parentCall)||void 0===r?void 0:r.func.name} - comparison`:`${e[0].func.name} - comparison`,a.inputs.forEach((t=>d(t))),a.outputs.forEach((t=>d(t)));const h=[...t.shell.views].find((t=>t.type===st||"scripts"===t.type||"functions"===t.type));h&&(t.shell.v=h);const p=t.shell.addTableView(u);p.temp={isComparison:!0},p.close();const f=new this(p.dart,n),m=a.options.comparator;return setTimeout((()=>mt(this,void 0,void 0,(function*(){f.defaultCustomize(),m&&(yield t.functions.call(m,{comparisonView:f}))}))),0),f}))}constructor(e,n={}){super(e),n.parentView&&(this.parentView=n.parentView),this.parentCall=n.parentCall||t.functions.getCurrentCall()}defaultCustomize(){var n;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(vt).width=70;for(let t=0;t<this.grid.columns.length;t++){const e=this.grid.columns.byIndex(t);(null===(n=e.column)||void 0===n?void 0:n.temp[rt])&&(e.width=350,e.cellType="html")}this.grid.onCellPrepare((t=>{if(!t.isColHeader&&!t.isRowHeader&&(t.tableColumn.name===vt&&(t.style.textVertical=!0),t.tableColumn&&t.tableColumn.temp[rt])){const n=t.cell.value,i=t.tableColumn.temp[rt],s=i.type;t.element=e.waitBox((()=>mt(this,void 0,void 0,(function*(){const e=Object.values(ot).includes(s)?o.Viewer.fromType(s,n):yield n.plot.fromType(s);return t.tableColumn.temp[rt].look?e.setOptions(t.tableColumn.temp[rt].look):(e.setOptions(i),t.tableColumn.temp[rt]=e.getOptions()),e.root})))),t.element.style.width="100%",t.element.style.height="100%"}})),t.events.onCurrentObjectChanged.subscribe((({sender:n})=>{var i;if(n instanceof o.Column&&n.type===o.TYPE.DATA_FRAME&&t.shell.tv&&t.shell.tv.temp.isComparison&&[o.VIEWER.LINE_CHART,o.VIEWER.SCATTER_PLOT,o.VIEWER.HISTOGRAM,o.VIEWER.BOX_PLOT].includes(n.temp[rt].type)){t.shell.windows.showProperties=!0;const s=t=>{const e=t.get(0).clone();e.columns.addNew(gt,o.TYPE.STRING).init(t.dataFrame.get(vt,0));for(let n=1;n<t.length;n++){const i=t.get(n).clone();i.columns.addNew(gt,o.TYPE.STRING).init(t.dataFrame.get(vt,n));const s=[o.COLUMN_TYPE.INT,o.COLUMN_TYPE.FLOAT];for(let t=0;t<i.columns.length;t++){const n=i.columns.byIndex(t),r=e.columns.byIndex(t);n.type!==r.type&&s.includes(n.type)&&s.includes(r.type)&&(n.type!==o.COLUMN_TYPE.FLOAT&&i.columns.replace(n,n.convertTo(o.COLUMN_TYPE.FLOAT)),r.type!==o.COLUMN_TYPE.FLOAT&&e.columns.replace(r,r.convertTo(o.COLUMN_TYPE.FLOAT)))}e.append(i,!0)}return e},r=null!==(i=n.temp.unitedDf)&&void 0!==i?i:s(n);n.temp.unitedDf=r;const a=n.temp[rt].look;setTimeout((()=>{switch(n.temp[rt].type){case o.VIEWER.LINE_CHART:t.shell.o=e.box(r.plot.line(Object.assign(Object.assign({},a),{split:gt})).root);break;case o.VIEWER.SCATTER_PLOT:t.shell.o=e.box(r.plot.scatter(Object.assign(Object.assign({},a),{color:gt})).root);break;case o.VIEWER.HISTOGRAM:t.shell.o=e.box(r.plot.histogram(Object.assign(Object.assign({},a),{split:gt})).root);break;case o.VIEWER.BOX_PLOT:t.shell.o=e.box(r.plot.box(Object.assign(Object.assign({},a),{category:gt})).root)}}))}}))}}var bt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const At=new URL(t.shell.startUri);class Ct extends o.ViewBase{constructor(t,n={historyEnabled:!0,isTabbed:!1}){super(),this.initValue=t,this.options=n,this._type="function",this.funcCallReplaced=new m.Subject,this.exportConfig=null,this.historyBlock=null,this.isHistorical=new m.BehaviorSubject(!1),this.historyRoot=e.divV([],{style:{"justify-content":"center"}}),this.defaultExportFilename=t=>`${this.name} - ${(new Date).toLocaleString("en-US").replaceAll(/:|\//g,"-")}.${this.exportConfig.supportedExtensions[t]}`,this.defaultSupportedExportExtensions=()=>({Excel:"xlsx"}),this.defaultSupportedExportFormats=()=>["Excel"],this.box=!0,this.init()}onFuncCallReady(){return bt(this,void 0,void 0,(function*(){this.options.isTabbed||this.changeViewName(this.funcCall.func.friendlyName),yield y.augmentCallWithFunc(this.funcCall),this.build(),this.getStartId()&&!this.options.isTabbed&&(e.setUpdateIndicator(this.root,!0),this.loadRun(this.funcCall.id),e.setUpdateIndicator(this.root,!1),this.setAsLoaded());const t=this.isHistorical.subscribe((t=>{var e,n;if(!this.options.isTabbed&&this.func)if(t){this.path=`?id=${this.funcCall.id}`;const t=new Date(this.funcCall.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"});this.name.indexOf(" — ")<0?this.changeViewName(`${this.name} — ${null!==(e=this.funcCall.options.title)&&void 0!==e?e:t}`):this.changeViewName(`${this.name.substring(0,this.name.indexOf(" — "))} — ${null!==(n=this.funcCall.options.title)&&void 0!==n?n:t}`)}else this.path="",this.changeViewName(`${this.name.substring(0,this.name.indexOf(" — ")>0?this.name.indexOf(" — "):void 0)}`)}));this.subs.push(t)}))}changeViewName(t){var n;this.name=t,null===(n=document.querySelector("div.d4-ribbon-name"))||void 0===n||n.replaceChildren(e.span([t]))}getStartId(){return t.shell.getVar("isLoaded")?void 0:At.searchParams.get("id")}setAsLoaded(){return t.shell.setVar("isLoaded",!0)}get funcCall(){return this._funcCall}get func(){var t;return null===(t=this.funcCall)||void 0===t?void 0:t.func}get lastCall(){return this._lastCall}set lastCall(t){this._lastCall=t}get type(){return this._type}linkFunccall(t){this._funcCall=t,this.funcCallReplaced.next(!0)}loadFuncCallById(){return bt(this,void 0,void 0,(function*(){if(this.initValue instanceof o.FuncCall)return yield new Promise((t=>setTimeout(t,0))),void this.linkFunccall(this.initValue);e.setUpdateIndicator(this.root,!0);const n=this.getStartId();if(n&&!this.options.isTabbed)this.linkFunccall(yield y.loadRun(n));else{const e=yield t.functions.eval(this.initValue);this.linkFunccall(e.prepare({}))}e.setUpdateIndicator(this.root,!1)}))}init(){return bt(this,void 0,void 0,(function*(){yield this.loadFuncCallById(),yield this.onFuncCallReady()}))}build(){e.empty(this.root),this.root.appendChild(this.buildIO()),this.options.historyEnabled&&this.buildHistoryBlock(),this.buildRibbonMenu(),this.buildRibbonPanels()}onComparisonLaunch(e){return bt(this,void 0,void 0,(function*(){const n=t.shell.v.parentCall,i=yield Promise.all(e.map((t=>y.loadRun(t)))),o=[...t.shell.views].find((t=>t.type===st)),s=yield yt.fromComparedRuns(i,{parentView:o,parentCall:n,configFunc:this.func});t.shell.addView(s)}))}buildHistoryBlock(){const n=it.historyPanel(this.func);return this.subs.push(n.onRunChosen.subscribe((t=>bt(this,void 0,void 0,(function*(){e.setUpdateIndicator(this.root,!0),yield this.loadRun(t),e.setUpdateIndicator(this.root,!1)})))),n.onComparison.subscribe((t=>bt(this,void 0,void 0,(function*(){return this.onComparisonLaunch(t)})))),t.events.onCurrentViewChanged.subscribe((()=>{t.shell.v===this&&setTimeout((()=>{t.shell.o=this.historyRoot}))}))),e.empty(this.historyRoot),this.historyRoot.style.removeProperty("justify-content"),this.historyRoot.style.width="100%",this.historyRoot.append(n.root),t.shell.o=this.historyRoot,this.historyBlock=n,n.root}buildRibbonPanels(){const n=e.iconFA("history",(()=>{t.shell.windows.showProperties=!t.shell.windows.showProperties,n.classList.toggle("d4-current"),t.shell.o=this.historyRoot}));n.classList.add("d4-toggle-button"),t.shell.windows.showProperties&&n.classList.add("d4-current");const i=e.comboPopup(e.iconFA("arrow-to-bottom"),this.exportConfig.supportedFormats,(t=>bt(this,void 0,void 0,(function*(){return o.Utils.download(this.exportConfig.filename(t),yield this.exportConfig.export(t))})))),s=e.iconFA("edit",(()=>{this.historyBlock&&this.lastCall&&this.historyBlock.showEditDialog(this.lastCall)}),"Edit this run"),r=this.isHistorical.subscribe((t=>{t?(h()(i).show(),h()(s).show()):(h()(i).hide(),h()(s).hide())}));this.subs.push(r);const a=[[...this.options.historyEnabled?[n]:[],...this.exportConfig&&this.exportConfig.supportedFormats.length>0?[i]:[],s]];return this.setRibbonPanels(a),a}buildRibbonMenu(){}onBeforeSaveRun(t){return bt(this,void 0,void 0,(function*(){}))}onAfterSaveRun(t){return bt(this,void 0,void 0,(function*(){}))}saveRun(t){return bt(this,void 0,void 0,(function*(){yield this.onBeforeSaveRun(t);const e=yield y.saveRun(t);return this.linkFunccall(e),this.options.historyEnabled&&this.buildHistoryBlock(),this.isHistorical.next(!0),yield this.onAfterSaveRun(e),e}))}onBeforeDeleteRun(t){return bt(this,void 0,void 0,(function*(){}))}onAfterDeleteRun(t){return bt(this,void 0,void 0,(function*(){}))}deleteRun(t){return bt(this,void 0,void 0,(function*(){return yield this.onBeforeDeleteRun(t),yield y.deleteRun(t),yield this.onAfterDeleteRun(t),t.id}))}onBeforeLoadRun(){return bt(this,void 0,void 0,(function*(){}))}onAfterLoadRun(t){return bt(this,void 0,void 0,(function*(){}))}loadRun(t){return bt(this,void 0,void 0,(function*(){yield this.onBeforeLoadRun();const e=yield y.loadRun(t);return this.lastCall=e,this.linkFunccall(e),this.isHistorical.next(!0),yield this.onAfterLoadRun(e),e}))}onBeforeRun(t){return bt(this,void 0,void 0,(function*(){}))}onAfterRun(t){return bt(this,void 0,void 0,(function*(){}))}run(){return bt(this,void 0,void 0,(function*(){if(!this.funcCall)throw new Error("The correspoding function is not specified");yield this.onBeforeRun(this.funcCall);const e=o.TaskBarProgressIndicator.create("Calculating...");this.funcCall.newId();try{yield this.funcCall.call(),yield this.onAfterRun(this.funcCall),this.lastCall=this.options.isTabbed||this.runningOnInput||this.runningOnStart?(t=>{const e=t.clone(),n=r()(t.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const i of n)e.outputs[i.name]=t.outputs[i.name].clone();const i=r()(t.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const n of i)e.inputs[n.name]=t.inputs[n.name].clone();return e})(this.funcCall):yield this.saveRun(this.funcCall)}catch(e){t.shell.error(e.toString())}finally{e.close()}}))}get hasUploadMode(){return"true"===this.func.options.uploadMode}get runningOnInput(){return"true"===this.func.options.runOnInput}get runningOnStart(){return"true"===this.func.options.runOnOpen}}var wt=n(903),xt={};xt.styleTagTransform=V(),xt.setAttributes=P(),xt.insert=S().bind(null,"head"),xt.domAPI=I(),xt.insertStyleElement=k(),E()(wt.Z,xt),wt.Z&&wt.Z.locals&&wt.Z.locals;const Et=html2canvas;var Rt=n.n(Et),It=n(751),Tt={};Tt.styleTagTransform=V(),Tt.setAttributes=P(),Tt.insert=S().bind(null,"head"),Tt.domAPI=I(),Tt.insertStyleElement=k(),E()(It.Z,Tt),It.Z&&It.Z.locals&&It.Z.locals;var St,Ft=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function Pt(t){const e=t;return e.dart&&o.toJs(e.dart)instanceof o.InputBase}!function(t){t.INPUTS="inputs",t.OUTPUTS="outputs"}(St||(St={}));const Bt={[St.INPUTS]:"inputParams",[St.OUTPUTS]:"outputParams"};class kt extends Ct{static fromFuncCall(t,e={historyEnabled:!0,isTabbed:!1}){return new this(t,e)}constructor(t,n={historyEnabled:!0,isTabbed:!1}){super(t,n),this.options=n,this.checkDisability=new m.Subject,this.isRunning=new m.BehaviorSubject(!1),this.isUploadMode=new m.BehaviorSubject(!1),this.inputsOverride={},this.inputsMap={},this.prevOpenedTab=null,this.beforeInputPropertyRender=new m.Subject,this.afterInputPropertyRender=new m.Subject,this.afterOutputPropertyRender=new m.Subject,this.afterOutputSacalarTableRender=new m.Subject,this.additionalBtns=e.divH([]),this.navBtns=e.divH([]),this.outputsTabsElem=e.tabControl(),this.dfToViewerMapping={},this.foldedCategoryInputs={},this.sheetNamesCache={},this.richFunctionExport=t=>Ft(this,void 0,void 0,(function*(){if("Excel"===t)try{const e=this.lastCall;if(!e)throw new Error("Function was not called");if(!this.exportConfig.supportedFormats.includes(t))throw new Error(`Format "${t}" is not supported.`);if(!this.func)throw new Error("The correspoding function is not specified");const n="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8",i=new(C().Workbook),s=t=>o.TYPES_SCALAR.has(t),r=t=>t.propertyType===o.TYPE.DATA_FRAME,a=this.func.inputs.filter((t=>r(t))),l=this.func.inputs.filter((t=>s(t.propertyType))),d=this.func.outputs.filter((t=>r(t))),u=this.func.outputs.filter((t=>s(t.propertyType)));if(a.forEach((t=>{var n;const o=t.options.caption||t.name,s=null!==(n=i.worksheets.find((t=>t.name===this.getSheetName(o,i))))&&void 0!==n?n:i.addWorksheet(this.getSheetName(o,i)),r=e.inputs[t.name];Mt(s,r)})),l.length){const t=i.addWorksheet("Input scalars");Ot(t,l.map((t=>({caption:t.options.caption||t.name,value:e.inputs[t.name],units:t.options.units||""}))))}if(d.forEach((t=>{var n;const o=t.options.caption||t.name,s=null!==(n=i.worksheets.find((t=>t.name===this.getSheetName(o,i))))&&void 0!==n?n:i.addWorksheet(this.getSheetName(o,i)),r=e.outputs[t.name];Mt(s,r)})),u.length){const t=i.addWorksheet("Output scalars");Ot(t,u.map((t=>({caption:t.options.caption||t.name,value:e.outputs[t.name],units:t.options.units||""}))))}const c=this.outputsTabsElem;for(const t of this.tabsLabels.filter((t=>Object.keys(this.categoryToDfParamMap.inputs).includes(t))))for(const n of this.categoryToDfParamMap.inputs[t].filter((t=>r(t)))){const s=this.dfToViewerMapping[n.name].filter((t=>t.type!==o.VIEWER.GRID)).filter((t=>Object.values(ot).includes(t.type)));if(0===s.length)continue;c.currentPane=c.getPane(t),yield new Promise((t=>setTimeout(t,100)));const r=n.options.caption||n.name,a=e.inputs[n.name];for(const[t,e]of s.entries())yield Lt(i,i.getWorksheet(this.getSheetName(r,i)),e.root,a.columns.length+2,t>0?Math.ceil(s[t-1].root.clientHeight/20)+1:0)}for(const t of this.tabsLabels.filter((t=>Object.keys(this.categoryToDfParamMap.outputs).includes(t))))for(const n of this.categoryToDfParamMap.outputs[t].filter((t=>r(t)))){const s=this.dfToViewerMapping[n.name].filter((t=>t.type!==o.VIEWER.GRID)).filter((t=>Object.values(ot).includes(t.type)));if(0===s.length)continue;c.currentPane=c.getPane(t),yield new Promise((t=>setTimeout(t,100)));const r=n.options.caption||n.name,a=e.outputs[n.name];for(const[t,e]of s.entries())if(e.type===o.VIEWER.STATISTICS){const e=a.columns.length,n=o.DataFrame.fromColumns([o.Column.string("Name",e).init((t=>a.columns.byIndex(t).name)),o.Column.int("Values",e).init((t=>a.columns.byIndex(t).stats.valueCount)),o.Column.int("Nulls",e).init((t=>a.columns.byIndex(t).stats.missingValueCount)),o.Column.float("Min",e).init((t=>a.columns.byIndex(t).stats.min)),o.Column.float("Max",e).init((t=>a.columns.byIndex(t).stats.max)),o.Column.float("Avg",e).init((t=>a.columns.byIndex(t).stats.avg)),o.Column.float("Stdev",e).init((t=>a.columns.byIndex(t).stats.stdev))]);Mt(i.getWorksheet(this.getSheetName(r,i)),n,a.columns.length+2,t>0?Math.ceil(s[t-1].root.clientHeight/20)+1:0)}else yield Lt(i,i.getWorksheet(this.getSheetName(r,i)),e.root,a.columns.length+2,t>0?Math.ceil(s[t-1].root.clientHeight/20)+1:0)}const h=yield i.xlsx.writeBuffer();return new Blob([h],{type:n})}catch(t){console.log(t)}if("DataUrl images"===t){const t={},e=t=>t.propertyType===o.TYPE.DATA_FRAME,n=this.outputsTabsElem;for(const i of this.tabsLabels.filter((t=>Object.keys(this.categoryToDfParamMap.inputs).includes(t))))for(const s of this.categoryToDfParamMap.inputs[i].filter((t=>e(t)))){const e=this.dfToViewerMapping[s.name].filter((t=>t.type!==o.VIEWER.GRID&&t.type!==o.VIEWER.STATISTICS)).filter((t=>Object.values(ot).includes(t.type)));if(0!==e.length){n.currentPane=n.getPane(i),yield new Promise((t=>setTimeout(t,100)));for(const[n,i]of e.entries()){const e=(yield Rt()(i.root,{logging:!1})).toDataURL();t[s.name]||(t[s.name]={}),t[s.name][n]={dataUrl:e,width:i.root.clientWidth,height:i.root.clientHeight}}}}for(const i of this.tabsLabels.filter((t=>Object.keys(this.categoryToDfParamMap.outputs).includes(t))))for(const s of this.categoryToDfParamMap.outputs[i].filter((t=>e(t)))){const e=this.dfToViewerMapping[s.name].filter((t=>t.type!==o.VIEWER.GRID&&t.type!==o.VIEWER.STATISTICS)).filter((t=>Object.values(ot).includes(t.type)));if(0!==e.length){n.currentPane=n.getPane(i),yield new Promise((t=>setTimeout(t,100)));for(const[n,i]of e.entries()){const e=(yield Rt()(i.root,{logging:!1})).toDataURL();t[s.name]||(t[s.name]={}),t[s.name][n]={dataUrl:e,width:i.root.clientWidth,height:i.root.clientHeight}}}}return new Blob([JSON.stringify(t)],{type:"text/plain"})}throw new Error("Format is not supported")})),this.exportConfig={supportedExtensions:this.richFunctionViewExportExtensions(),supportedFormats:this.richFunctionViewSupportedFormats(),export:this.richFunctionExport,filename:this.defaultExportFilename}}onFuncCallReady(){const t=Object.create(null,{onFuncCallReady:{get:()=>super.onFuncCallReady}});return Ft(this,void 0,void 0,(function*(){yield this.loadInputsOverrides(),yield t.onFuncCallReady.call(this),this.basePath=`scripts/${this.funcCall.func.id}/view`,this.runningOnStart&&this.isRunnable()&&(yield this.doRun())}))}onBeforeRun(){return this.prevOpenedTab=Object.keys(this.categoryToDfParamMap.inputs).includes(this.outputsTabsElem.currentPane.name)?null:this.outputsTabsElem.currentPane,Promise.resolve()}onAfterRun(){if(this.showOutputTabsElem(),this.outputsTabsElem.panes.forEach((t=>{h()(t.header).show()})),this.prevOpenedTab)return this.outputsTabsElem.currentPane=this.prevOpenedTab,Promise.resolve();const t=this.outputsTabsElem.panes.find((t=>Object.keys(this.categoryToDfParamMap.outputs).includes(t.name)));return t&&(this.outputsTabsElem.currentPane=t),Promise.resolve()}getRunButton(t="Run"){var n;const i=e.bigButton(null!==(n=this.func.options.runLabel)&&void 0!==n?n:t,(()=>Ft(this,void 0,void 0,(function*(){return yield this.doRun()})))),o=this.checkDisability.subscribe((()=>{const t=this.isRunnable();i.disabled=!t}));return this.subs.push(o),i}loadInputsOverrides(){return Ft(this,void 0,void 0,(function*(){const e=[...this.funcCall.inputParams.values()];yield Promise.all(e.map((e=>Ft(this,void 0,void 0,(function*(){if(e.property.options.input){const n=(yield t.functions.eval(e.property.options.input)).prepare({params:JSON.parse(e.property.options.inputOptions||"{}")});yield n.call(),this.inputsOverride[e.name]=n.outputs.input}})))))}))}getSaveButton(t="Save"){const n=e.bigButton(t,(()=>Ft(this,void 0,void 0,(function*(){return yield this.saveExperimentalRun(this.funcCall)}))),"Save uploaded data");return this.isUploadMode.subscribe((t=>{this.buildRibbonPanels(),this.runningOnInput||(t?h()(n).show():h()(n).hide())})),this.runningOnInput&&!this.options.isTabbed||h()(n).hide(),n}getStandardButtons(){const t=this.getRunButton(),n=e.div([t]);e.tooltip.bind(n,(()=>t.disabled?this.isRunning.value?"Computations are in progress":"Some inputs are invalid":""));const i=this.getSaveButton();return this.runningOnInput&&h()(n).hide(),[i,n]}setAdditionalButtons(t){const n=e.divH(t);this.additionalBtns.replaceWith(n),this.additionalBtns=n}setNavigationButtons(t){const n=e.divH(t);this.navBtns.replaceWith(n),this.navBtns=n}buildIO(){const{inputBlock:t,inputForm:n,outputForm:i,controlsWrapper:o}=this.buildInputBlock();e.tools.handleResize(t,(()=>{[...Array.from(n.childNodes),...this.isUploadMode.value?[Array.from(i.childNodes)]:[]].some((t=>h()(t).width()<250))||h()(t).width()<350?(h()(n).addClass("ui-form-condensed"),h()(i).addClass("ui-form-condensed"),h()(o).addClass("ui-form-condensed")):(h()(n).removeClass("ui-form-condensed"),h()(i).removeClass("ui-form-condensed"),h()(o).removeClass("ui-form-condensed"))}));const s=this.buildOutputBlock();s.style.height="100%",s.style.width="100%",h()(this.outputsTabsElem.root).hide(),Object.keys(this.categoryToDfParamMap.inputs).length>0&&this.outputsTabsElem.panes.forEach((t=>{h()(t.header).hide()}));const r=e.splitH([t,e.panel([s],{style:{"padding-top":"0px"}})],null,!0);return r.style.padding="0 12px",t.style.maxWidth="450px",r}buildInputBlock(){const t=this.renderInputForm(),n=this.renderOutputForm(),i=this.getStandardButtons(),o=e.buttonsInput([this.navBtns,e.divH([this.additionalBtns,...i],{style:{gap:"5px"}})]);h()(o).addClass("rfv-buttons");const s=e.div(o,"ui-form ui-form-wide");h()(s).css({"padding-left":"0px","padding-bottom":"0px","max-width":"100%","min-height":"50px"});const r=e.switchInput("",this.isUploadMode.value,(t=>this.isUploadMode.next(t)));this.isUploadMode.subscribe((t=>{r.notify=!1,r.value=t,r.notify=!0}));const a=e.divV([t,...this.hasUploadMode?[e.divH([e.h2("Experimental data"),r.root],{style:{"flex-grow":"0"}}),n]:[],s],"ui-box rfv-form");return this.isUploadMode.subscribe((t=>{t?h()(n).show():h()(n).hide()})),{inputBlock:a,inputForm:t,outputForm:n,controlsWrapper:s}}buildRibbonPanels(){super.buildRibbonPanels();const n=e.iconFA("play",(()=>Ft(this,void 0,void 0,(function*(){return yield this.doRun()}))),"Run computations");n.classList.add("fas");const i=e.iconFA("save",(()=>Ft(this,void 0,void 0,(function*(){this.isUploadMode.value?yield this.saveExperimentalRun(this.funcCall):this.lastCall?yield this.saveRun(this.lastCall):t.shell.warning("Function was not called. Call it before saving")}))),this.isUploadMode.value?"Save uploaded data":"Save the last run"),o=e.iconFA("arrow-to-top",(()=>Ft(this,void 0,void 0,(function*(){this.isUploadMode.next(!this.isUploadMode.value),pt(this.func)?(yield t.functions.eval(pt(this.func))).prepare().edit():o.classList.toggle("d4-current")}))),"Upload experimental data");o.classList.add("d4-toggle-button",...this.isUploadMode.value?["d4-current"]:[]);const s=[...this.getRibbonPanels(),[...this.runningOnInput||this.options.isTabbed?[]:[n],...this.hasUploadMode&&this.isUploadMode.value||this.runningOnInput?[i]:[],...this.hasUploadMode?[o]:[]]];return this.setRibbonPanels(s),s}showOutputTabsElem(){h()(this.outputsTabsElem.root).show(),h()(this.outputsTabsElem.root).css("display","flex")}buildOutputBlock(){this.outputsTabsElem.root.style.width="100%",this.tabsLabels.forEach((n=>{const[i,s]=this.categoryToDfParamMap.outputs[n]?[this.categoryToDfParamMap.outputs[n],!1]:[this.categoryToDfParamMap.inputs[n],!0],r=i.filter((t=>t.propertyType===o.TYPE.DATA_FRAME)),a=i.filter((t=>t.propertyType!==o.TYPE.DATA_FRAME)),l=r.map((t=>ft(t).config));let d="";const u=r.reduce(((n,i,r)=>{var a,u;this.dfToViewerMapping[i.name]=[];const c=l[r].map(((e,n)=>Ft(this,void 0,void 0,(function*(){var n,s,r,a;const l=null!==(a=null!==(s=null===(n=this.funcCall.outputs[i.name])||void 0===n?void 0:n.value)&&void 0!==s?s:null===(r=this.funcCall.inputParams[i.name])||void 0===r?void 0:r.value)&&void 0!==a?a:t.data.demo.demog(1),d=e.type,u=Object.values(ot).includes(d)?o.Viewer.fromType(d,l):yield l.plot.fromType(d);return u.setOptions(e),this.dfToViewerMapping[i.name].push(u),this.afterOutputPropertyRender.next({prop:i,output:u}),u})))).map(((t,e)=>t.then((t=>{const n=()=>{var n;const o=null!==(n=this.funcCall.outputParams[i.name])&&void 0!==n?n:this.funcCall.inputParams[i.name],s=()=>Ft(this,void 0,void 0,(function*(){var n;const o=null!==(n=this.funcCall.outputParams[i.name])&&void 0!==n?n:this.funcCall.inputParams[i.name];if(this.showOutputTabsElem(),Object.values(ot).includes(t.type))t.dataFrame=o.value,t.setOptions(l[r][e]);else{const n=yield o.value.plot.fromType(t.type);n.setOptions(l[r][e]),t.root.replaceWith(n.root),t=n}this.afterOutputPropertyRender.next({prop:i,output:t})})),a=o.onChanged.subscribe((()=>Ft(this,void 0,void 0,(function*(){yield s()}))));this.funcCallReplaced.subscribe((()=>Ft(this,void 0,void 0,(function*(){yield s()})))),this.subs.push(a)};return n(),this.subs.push(this.funcCallReplaced.subscribe(n)),t})))),p=d!==(null!==(a=i.options.caption)&&void 0!==a?a:i.name)?null!==(u=i.options.caption)&&void 0!==u?u:i.name:" ";if(d=p,s){const t=()=>{var t;const e=(null!==(t=this.funcCall.outputParams[i.name])&&void 0!==t?t:this.funcCall.inputParams[i.name]).onChanged.subscribe((()=>{this.showOutputTabsElem(),Object.keys(this.categoryToDfParamMap.inputs).forEach((t=>{h()(this.outputsTabsElem.getPane(t).header).show()}))}));this.subs.push(e)};t(),this.subs.push(this.funcCallReplaced.subscribe(t))}const f=c.map(((t,n)=>{const i=l[r][n].block,o=e.wait((()=>Ft(this,void 0,void 0,(function*(){return(yield t).root}))));return h()(o).css({"min-height":"300px","flex-grow":"1"}),e.divV([e.h2(0===n?p:" ",{style:{"white-space":"pre"}}),o],{style:Object.assign({},i?{width:`${i}%`,"max-width":`${i}%`}:{"flex-grow":"1"})})}));return n.append(...f),n}),e.divH([],{style:{"flex-wrap":"wrap","flex-grow":"1"}})),c=()=>{const t=o.HtmlTable.create(a,(t=>{var e;const n=t.options.precision;return[null!==(e=t.caption)&&void 0!==e?e:t.name,n&&t.propertyType===o.TYPE.FLOAT&&this.funcCall.outputs[t.name]?this.funcCall.outputs[t.name].toPrecision(n):this.funcCall.outputs[t.name],t.options.units]})).root;return h()(t).addClass("rfv-scalar-table"),this.afterOutputSacalarTableRender.next(t),t};let p=c();a.forEach((t=>{const e=()=>{const e=this.funcCall.outputParams[t.name].onChanged.subscribe((()=>{const t=c();p.replaceWith(t),p=t,h()(this.outputsTabsElem.getPane(n).header).show()}));this.funcCallReplaced.subscribe((()=>{const t=c();p.replaceWith(t),p=t})),this.subs.push(e)};e(),this.subs.push(this.funcCallReplaced.subscribe(e))})),this.outputsTabsElem.addPane(n,(()=>e.divV([...r.length?[u]:[],...a.length?[p]:[]])))}));const n=e.box();return n.append(this.outputsTabsElem.root),n}onAfterLoadRun(t){return Ft(this,void 0,void 0,(function*(){this.showOutputTabsElem(),this.outputsTabsElem.panes.forEach((t=>{h()(t.header).show()}))}))}get tabsLabels(){return[...Object.keys(this.categoryToDfParamMap.inputs),...Object.keys(this.categoryToDfParamMap.outputs)]}get categoryToDfParamMap(){const t={inputs:{},outputs:{}};return this.func.inputs.filter((t=>t.propertyType===o.TYPE.DATA_FRAME&&0!==ft(t).config.length)).forEach((e=>{const n="Misc"===e.category?"Input":e.category;t.inputs[n]?t.inputs[n].push(e):t.inputs[n]=[e]})),this.func.outputs.forEach((e=>{const n="Misc"===e.category?"Output":e.category;e.propertyType===o.TYPE.DATA_FRAME&&0===ft(e).config.length||(t.outputs[n]?t.outputs[n].push(e):t.outputs[n]=[e])})),t}doRun(){return Ft(this,void 0,void 0,(function*(){this.isRunning.next(!0),this.checkDisability.next();try{yield this.run()}catch(e){t.shell.error(e.toString()),console.log(e)}finally{this.isRunning.next(!1),this.checkDisability.next()}}))}getInput(t){return this.inputsMap[t]}setInput(t,e,n="disabled"){const i=this.getInput(t);if(!i)throw new Error(`No input named ${t}`);this.funcCall.inputs[t]=e,this.setInputState(i,n),"default"!==n&&(this.funcCall.options.editState=Object.assign(Object.assign({},this.funcCall.options.editState),{[t]:n}))}setInputState(t,e){"disabled"===e&&(t.enabled=!1),"default"!==e&&e||(t.enabled=!0)}renderOutputForm(){return this.renderIOForm(St.OUTPUTS)}renderInputForm(){return this.renderIOForm(St.INPUTS)}renderIOForm(t){const n=e.divH([],"ui-form ui-form-wide");h()(n).css({"flex-wrap":"wrap","flex-grow":"0"});let i="Misc";const o=this.funcCall[Bt[t]].values();return r()(o).filter((t=>!!t)).forEach((e=>{const o=e.property;this.beforeInputPropertyRender.next(o);const s=this.getInputForVal(e);s?(this.inputsMap[e.property.name]=s,this.syncInput(e,s,t),this.disableInputsOnRun(s),t===St.INPUTS&&this.bindOnHotkey(s),this.renderInput(n,e,s,i),this.afterInputPropertyRender.next({prop:o,input:s}),i=o.category):i=o.category})),Object.keys(this.foldedCategoryInputs).forEach((t=>this.foldedCategoryInputs[t].forEach((t=>h()(t.root).hide())))),n.classList.remove("ui-panel"),n.style.paddingTop="0px",n.style.paddingLeft="0px",n.style.maxWidth="100%",this.checkDisability.next(),n}disableInputsOnRun(t){const e=this.isRunning.subscribe((e=>{t.enabled=!e}));this.subs.push(e)}getInputForVal(n){var i,s,r;const a=n.property;if(this.inputsOverride[n.property.name])return this.inputsOverride[n.property.name];if(a.propertyType===o.TYPE.STRING&&a.options.choices)return e.choiceInput(null!==(i=a.caption)&&void 0!==i?i:a.name,a.defaultValue,JSON.parse(a.options.choices));switch(a.propertyType){case o.TYPE.DATA_FRAME:return e.tableInput(null!==(s=a.caption)&&void 0!==s?s:a.name,null,t.shell.tables);case"file":return it.fileInput(null!==(r=a.caption)&&void 0!==r?r:a.name,null,null,null);case o.TYPE.FLOAT:const n=e.input.forProperty(a),i=a.options.format;return i&&(n.format=i),n;default:return e.input.forProperty(a)}}bindOnHotkey(t){Pt(t)&&(t.input.onkeydown=t=>Ft(this,void 0,void 0,(function*(){"Enter"==t.key&&this.isRunnable()&&this.doRun()})))}get foldedCategories(){var t;return JSON.parse(null!==(t=this.func.options.foldedCategories)&&void 0!==t?t:"[]")}renderInput(t,n,i,o){var s;const r=n.property;if(r.category!==o)if(this.foldedCategories.includes(r.category)){const n=e.iconFA("chevron-right",(()=>{var t;h()(i).show(),h()(n).hide(),(null!==(t=this.foldedCategoryInputs[r.category])&&void 0!==t?t:[]).forEach((t=>h()(t.root).show()))}),"Open category");h()(n).css("padding-right","5px");const i=e.iconFA("chevron-down",(()=>{var t;h()(i).hide(),h()(n).show(),(null!==(t=this.foldedCategoryInputs[r.category])&&void 0!==t?t:[]).forEach((t=>h()(t.root).hide()))}),"Close category");h()(i).css("padding-right","5px"),t.append(e.h2([n,i,e.h2(r.category,{style:{display:"inline"}})],{style:{width:"100%"}})),h()(i).hide()}else t.append(e.h2(r.category,{style:{width:"100%"}}));this.foldedCategories.includes(r.category)&&(this.foldedCategoryInputs[r.category]=[...null!==(s=this.foldedCategoryInputs[r.category])&&void 0!==s?s:[],i]),Pt(i)&&this.inputBaseAdditionalRenderHandler(n,i),t.append(i.root)}inputBaseAdditionalRenderHandler(t,n){var i,o;const s=t.property;h()(n.root).css({width:`${null!==(i=s.options.block)&&void 0!==i?i:"100"}%`,"box-sizing":"border-box","padding-right":"5px"}),n.captionLabel.firstChild.replaceWith(e.span([null!==(o=s.caption)&&void 0!==o?o:s.name])),s.options.units&&n.addPostfix(s.options.units)}syncInput(t,e,n){this.syncFuncCallReplaced(e,t,n),this.syncOnInput(e,t,n)}syncFuncCallReplaced(t,e,n){const i=e.property,o=e.name,s=this.funcCallReplaced.pipe((0,j.startWith)(!0)).subscribe((()=>{var e,s,r;const a=null!==(s=null!==(e=this.funcCall[n][o])&&void 0!==e?e:i.defaultValue)&&void 0!==s?s:null;t.notify=!1,t.value=a,t.notify=!0,this.funcCall[n][o]=a;const l=this.funcCall[Bt[n]][o];this.syncValOnChanged(t,l,n),this.setInputState(t,null===(r=this.funcCall.options.editState)||void 0===r?void 0:r[o])}));this.subs.push(s)}syncValOnChanged(t,e,n){const i=e.onChanged.subscribe((()=>{const i=this.funcCall[n][e.name];(e.property.propertyType===o.TYPE.FLOAT&&new Float32Array([t.value])[0]!==new Float32Array([i])[0]||e.property.propertyType!==o.TYPE.FLOAT)&&(t.notify=!1,t.value=i,t.notify=!0),n===St.INPUTS&&(this.hideOutdatedOutput(),this.checkDisability.next(),this.runningOnInput&&this.isRunnable()&&this.doRun())}));if(this.subs.push(i),e.property.propertyType===o.TYPE.DATA_FRAME){const t=()=>{if(!e.value)return;const t=e.value.onDataChanged.subscribe((()=>Ft(this,void 0,void 0,(function*(){this.runningOnInput&&this.isRunnable()&&this.doRun()}))));this.subs.push(t)};e.onChanged.subscribe((()=>{t()})),t()}}syncOnInput(t,e,n){var i;o.debounce((i=t.onInput.bind(t),new m.Observable((t=>{const e=i((e=>{t.next(e)}));return()=>e.unsubscribe()}))),350).subscribe((()=>{this.isHistorical.value&&this.isHistorical.next(!1),this.funcCall[n][e.name]=t.value,Pt(t)&&(null===t.value?setTimeout((()=>t.input.classList.add("d4-invalid")),100):t.input.classList.remove("d4-invalid")),this.checkDisability.next(),this.hideOutdatedOutput()}))}isRunnable(){return r()(this.funcCall.inputs.values()).every((t=>null!=t))&&!this.isRunning.value}saveExperimentalRun(e){return Ft(this,void 0,void 0,(function*(){const n=yield(yield t.functions.eval("Sin")).prepare({x:1}).call();e.dart.r2=n.dart.r2;const i=e.options.tags||[];e.options.tags=i.includes(lt)?i:[...i,lt],e.newId(),yield this.saveRun(e)}))}hideOutdatedOutput(){this.outputsTabsElem.panes.filter((t=>Object.keys(this.categoryToDfParamMap.outputs).includes(t.name))).forEach((t=>h()(t.header).hide()));const t=this.outputsTabsElem.panes.find((t=>Object.keys(this.categoryToDfParamMap.inputs).includes(t.name)));t?this.outputsTabsElem.currentPane=t:h()(this.outputsTabsElem.root).hide()}getSheetName(t,e){if(this.sheetNamesCache[t])return this.sheetNamesCache[t];let n=`${t}`;n.length>31&&(n=`${n.slice(0,31)}`);let i=1;for(;e.worksheets.some((t=>t.name===n));){let e=`${t}`;e.length>31-`-${i}`.length&&(e=`${t.slice(0,31-`-${i}`.length)}`),n=`${e}-${i}`,i++}return this.sheetNamesCache[t]=n,n}richFunctionViewSupportedFormats(){return["Excel","DataUrl images"]}richFunctionViewExportExtensions(){return{Excel:"xlsx","DataUrl images":"txt"}}}const Ot=(t,e)=>{t.addRow(["Parameter","Value","Units"]).font={bold:!0},e.forEach((e=>{t.addRow([e.caption,e.value,e.units])})),t.getColumn(1).width=1.2*Math.max(...e.map((t=>t.caption.toString().length)),9),t.getColumn(2).width=1.2*Math.max(...e.map((t=>t.value.toString().length)),5),t.getColumn(3).width=1.2*Math.max(...e.map((t=>t.units.toString().length)),5)};let Vt=0;const Mt=(t,e,n,i)=>{const o=t.getColumn(null!=n?n:1).letter,s={name:`ID_${Vt.toString()}`,ref:`${o}${null!=i?i:1}`,columns:e.columns.toList().map((t=>({name:t.name,filterButton:!1}))),rows:new Array(e.rowCount).fill(0).map(((t,n)=>[...e.row(n).cells].map((t=>t.value))))};t.addTable(s),t.columns.forEach((t=>{t.width=25,t.alignment={wrapText:!0}})),Vt++},Lt=(t,e,n,i,o=0)=>Ft(void 0,void 0,void 0,(function*(){const s=yield Rt()(n,{logging:!1}),r=s.toDataURL("image/png"),a=t.addImage({base64:r,extension:"png"});e.addImage(a,{tl:{col:i,row:o},ext:{width:s.width,height:s.height}})}));var Dt=n(433),_t={};_t.styleTagTransform=V(),_t.setAttributes=P(),_t.insert=S().bind(null,"head"),_t.domAPI=I(),_t.insertStyleElement=k(),E()(Dt.Z,_t),Dt.Z&&Dt.Z.locals&&Dt.Z.locals;class Nt{constructor(){this.scriptName="",this.description="",this.dfSheetsToSeek=[],this.scalarsToSeek=[],this.scriptText=new m.BehaviorSubject(""),this.infoText=new m.BehaviorSubject(""),this.lastSavedScriptId=new m.BehaviorSubject("")}}var jt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class Wt extends o.ViewBase{constructor(){super(),this.store=new Nt,this.scriptNameInput=e.stringInput("Script name","",(t=>this.store.scriptName=t)),this.descriptionInput=e.stringInput("Description","",(t=>this.store.description=t));const t=e.bigButton("Generate script",(()=>jt(this,void 0,void 0,(function*(){return yield this.generate()})))),n=e.bigButton("Save",(()=>jt(this,void 0,void 0,(function*(){return yield this.save()})))),i=e.bigButton("Open",(()=>jt(this,void 0,void 0,(function*(){return this.open()}))));i.style.display="none",this.store.lastSavedScriptId.subscribe((t=>{""!==t&&i.style.removeProperty("display")}));const o=t=>{const n=e.button("Remove",(()=>{}));n.style.width=n.style.height,n.style.alignSelf="center",this.store.dfSheetsToSeek.push("");const i=e.divH([e.stringInput(`Sheet name #${t}`,"",(e=>this.store.dfSheetsToSeek[t]=e)).root,n],{style:{"justify-content":"space-between"}});return n.addEventListener("click",(()=>{this.store.dfSheetsToSeek.splice(t,1),i.remove()})),i},s=t=>{const n=e.button("Remove",(()=>{}));n.style.width=n.style.height,n.style.alignSelf="center",this.store.scalarsToSeek.push("");const i=e.divH([e.stringInput(`Scalar name #${t}`,"",(e=>this.store.scalarsToSeek[t]=e)).root,n],{style:{"justify-content":"space-between"}});return n.addEventListener("click",(()=>{this.store.scalarsToSeek.splice(t,1),i.remove()})),i},r=e.divV([]),a=e.button("Add DF to search",(()=>{r.append(o(this.store.dfSheetsToSeek.length))})),l=e.divV([]),d=e.button("Add scalar to search",(()=>{l.append(s(this.store.scalarsToSeek.length))})),u=e.divV([e.h3("Script properties"),this.scriptNameInput.root,this.descriptionInput.root,e.h3("Dataframes to search"),r,a,e.h3("Scalars to search"),l,d,e.divH([t],{style:{"justify-content":"flex-end"}})],"ui-form");let c=e.divText(this.store.scriptText.value),h=e.info(this.store.infoText.value);const p=e.panel([e.h3("Script text"),c,h,e.divH([n,i],{style:{"justify-content":"flex-end"}})],{style:{display:"none"}});this.store.scriptText.subscribe((t=>{const n=e.divText(t);c.replaceWith(n),c=n,""!==t&&p.style.removeProperty("display")})),this.store.infoText.subscribe((t=>{const n=""===t?e.div([]):e.info(t);h.replaceWith(n),h=n})),this.root.appendChild(e.splitH([u,p],{style:{height:"100%",width:"100%"}},!0)),e.tools.handleResize(u.parentElement,(t=>{t<350?u.classList.add("ui-form-condensed"):u.classList.remove("ui-form-condensed")})),u.parentElement.style.maxWidth="340px"}generate(){return jt(this,void 0,void 0,(function*(){const e=this.store.dfSheetsToSeek.map((t=>`//output: dataframe ${t.trim()} { viewer: Grid(); }`)).join("\n"),n=this.store.scalarsToSeek.map((t=>`//output: string ${t.trim()}`)).join("\n"),i=`\nconst wb = new ExcelJS.Workbook();\nawait wb.xlsx.load(await uploadedFile.arrayBuffer());\nconst dfSheetsToSeek = ["${this.store.dfSheetsToSeek.join('","')}"];`;let o=`//name: ${this.store.scriptName}\n`;o+=`//description: ${this.store.description}\n`,o+="//language: javascript\n",o+="//input: file uploadedFile\n",o+=n+"\n",o+=e+"\n",o+="//editor: Compute:FunctionViewEditor\n",o+=i+"\n",this.store.dfSheetsToSeek.forEach((t=>{o+=(t=>`\nconst ${t}_ws = wb.getWorksheet("${t}");\nlet ${t}_data = await ${t}_ws.workbook.csv.writeBuffer();\n${t} = grok.data.parseCsv(${t}_data.toString());`)(t.trim())+"\n"})),o+="\nconst scalarSheets = wb.worksheets.filter(ws => !dfSheetsToSeek.includes(ws.name));\nconst scalarNames = scalarSheets.flatMap((sheet) => sheet.getColumn(1).values);\nconst scalarValues = scalarSheets.flatMap((sheet) => sheet.getColumn(2).values);",this.store.scalarsToSeek.forEach((t=>{var e;o+=`\nconst ${e=t}_index = scalarNames.findIndex((scalarName) => scalarName === "${e}");\n${e} = (${e}_index >= 0) ? scalarValues[${e}_index] : '';\n`})),this.store.scriptText.next(o),(yield t.dapi.scripts.filter(`name="${this.store.scriptName}"`).list()).length>0?this.store.infoText.next(`Script named "${this.store.scriptName}" already exists`):this.store.infoText.next("")}))}save(){return jt(this,void 0,void 0,(function*(){const e=o.Script.create(this.store.scriptText.value),n=yield t.dapi.scripts.save(e);this.store.lastSavedScriptId.next(n.id),t.shell.info(`Script "${this.store.scriptName}" has been saved successfully`)}))}open(){window.open(`${window.location.origin}/script/${this.store.lastSavedScriptId.value}`)}}var Ht=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};let $t=!1;const Ut=new o.Package;function Gt(t){u.openModelFromFunccall(t)}function Yt(){const e=new Wt;e.name="Import Script Gen",t.shell.addView(e),e.root.classList.remove("ui-panel")}function zt(){return new f}function Zt(t){return kt.fromFuncCall(t,{historyEnabled:!0,isTabbed:!1})}function qt(t){return kt.fromFuncCall(t,{historyEnabled:!1,isTabbed:!0})}function Jt(t){return function(t){let n=o.View.create(),i=e.div(),s=e.stringInput("Function",t.name);function r(){n.name=t.name,e.empty(i);let s=o.DataFrame.fromProperties(t.inputs.concat(t.outputs),5),r=o.Grid.create(s),a=!1;r.onCellValueEdited.subscribe((e=>{var n;return function(e){for(let n=0;n<t.inputs.length;n++)if(s.columns.byIndex(n).isNone(e))return;let n={};for(let i of t.inputs)n[i.name]=s.col(i.name).get(e);a=!0;let i=t.prepare(n);i.call().then((n=>{for(let n of t.outputs)s.col(n.name).set(e,i.outputs[n.name]);a=!1}))}(null===(n=e.tableRow)||void 0===n?void 0:n.idx)})),i.appendChild(r.root)}return n.root.appendChild(s.root),n.root.appendChild(i),r(),s.onChanged((()=>{o.Func.findAll({name:s.value}).then((e=>{1==e.length&&(t=e[0],r())}))})),n}(t)}function Xt(){console.log("hof");let e=Jt(o.Func.byName("Sin"));e.parentCall=t.functions.getCurrentCall(),t.shell.addView(e)}function Kt(){var n,i,s;console.log("hof2");let r=Jt(o.Func.byName("Sin"));r.root.appendChild(e.narrowForm([e.switchInput("test",!0),e.boolInput("test",!0)])),r.root.appendChild(e.form([e.switchInput("test",!0),e.boolInput("test",!0)])),r.parentCall=t.functions.getCurrentCall(),r.parentView=null===(n=r.parentCall.parentCall)||void 0===n?void 0:n.aux.view,null===(i=r.parentCall.parentCall)||void 0===i||i.aux.url,null===(s=r.parentCall)||void 0===s||s.aux.url,r.basePath="/"+r.parentCall.func.name,r.path="/",t.shell.addView(r)}function Qt(n){return Ht(this,void 0,void 0,(function*(){let i={};n.inputs.forEach((t=>i[t.name]=null));let s=`\ncurl --location --request POST '${t.settings.apiUrl}/v1/func/${n.nqName}/run' \\\n--header 'Authorization: ${te("auth")}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '${JSON.stringify(i)}'`,r=`\nvar myHeaders = new Headers();\nmyHeaders.append("Authorization", "${te("auth")}");\nmyHeaders.append("Content-Type", "application/json");\n\nvar raw = JSON.stringify(${JSON.stringify(i)});\n\nvar requestOptions = {\n method: 'POST',\n headers: myHeaders,\n body: raw,\n redirect: 'follow'\n};\n\nfetch("${t.settings.apiUrl}/v1/func/${n.nqName}/run", requestOptions)\n .then(response => response.text())\n .then(result => console.log(result))\n .catch(error => console.log('error', error));`,a=e.tabControl({CURL:e.div([e.divText(s)]),JS:e.div([e.divText(r)])});return o.Widget.fromRoot(a.root)}))}function te(t){let e=document.cookie.match(new RegExp("(?:^|; )"+t.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):void 0}function ee(){}function ne(){$t||(o.ObjectHandler.register(new u),t.events.onAccordionConstructed.subscribe((t=>{const n=t.context;null!=n&&"script"==n.type&&(t.getPane("REST")||t.addPane("REST",(()=>e.wait((()=>Ht(this,void 0,void 0,(function*(){return(yield Qt(n)).root})))))))})),$t=!0)}function ie(){let e=u.findModelCatalogView();if(null==e){let e=new l;e.name="ModelHub";let n=document.createElement("a");n.href=window.location.href;let i=n.pathname.split("/");t.shell.addView(e),i.length>3&&t.dapi.functions.filter(`shortName = "${i[3]}" and #model`).list().then((t=>{1==t.length&&u.openModel(t[0])}))}else t.shell.v=e}})(),compute=i})();
|
|
1
|
+
var compute;(()=>{"use strict";var t={903:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),s=n.n(i),o=n(352),r=n.n(o)()(s());r.push([t.id,".pipeline-view .d4-ribbon-name.selected {\n color: var(--grey-6)\n}\n\n.pipeline-view .d4-ribbon-name {\n color: var(--blue-1);\n margin: 12px 6px;\n font-weight: normal;\n place-content: center;\n}\n\n.pipeline-view .d4-ribbon-name + .d4-ribbon-name::before {\n color: var(--grey-3);\n}\n\n.pipeline-view .d4-ribbon-name.d4-disabled {\n cursor: default;\n pointer-events: none;\n color: var(--grey-3);\n}\n\n.ui-input-editor button.ui-btn-nav.ui-btn {\n background-color: rgb(80 169 197 / 25%);\n color: #50A9C5;\n float: left;\n margin-right: 5px;\n padding: 0 12px;\n}\n\n.ui-input-editor button.ui-btn-nav.ui-btn.d4-disabled {\n color: var(--grey-3)\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/function-views/css/pipeline-view.css"],names:[],mappings:"AAAA;EACE;AACF;;AAEA;EACE,oBAAoB;EACpB,gBAAgB;EAChB,mBAAmB;EACnB,qBAAqB;AACvB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,eAAe;EACf,oBAAoB;EACpB,oBAAoB;AACtB;;AAEA;EACE,uCAAuC;EACvC,cAAc;EACd,WAAW;EACX,iBAAiB;EACjB,eAAe;AACjB;;AAEA;EACE;AACF",sourcesContent:[".pipeline-view .d4-ribbon-name.selected {\n color: var(--grey-6)\n}\n\n.pipeline-view .d4-ribbon-name {\n color: var(--blue-1);\n margin: 12px 6px;\n font-weight: normal;\n place-content: center;\n}\n\n.pipeline-view .d4-ribbon-name + .d4-ribbon-name::before {\n color: var(--grey-3);\n}\n\n.pipeline-view .d4-ribbon-name.d4-disabled {\n cursor: default;\n pointer-events: none;\n color: var(--grey-3);\n}\n\n.ui-input-editor button.ui-btn-nav.ui-btn {\n background-color: rgb(80 169 197 / 25%);\n color: #50A9C5;\n float: left;\n margin-right: 5px;\n padding: 0 12px;\n}\n\n.ui-input-editor button.ui-btn-nav.ui-btn.d4-disabled {\n color: var(--grey-3)\n}"],sourceRoot:""}]);const a=r},751:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),s=n.n(i),o=n(352),r=n.n(o)()(s());r.push([t.id,".rfv-buttons {\n margin-top: 0px;\n position: sticky;\n}\n\n.ui-form-condensed .rfv-buttons > .ui-label {\n margin-right: 0px!important;\n}\n\n.ui-form .rfv-buttons > .ui-input-editor {\n justify-content: space-between\n}\n\ndiv.ui-box > div.ui-box.rfv-form > div.ui-div {\n overflow: visible!important;\n}\n\n.rfv-scalar-table {\n border-collapse: collapse;\n margin: 10px;\n}\n\n.rfv-scalar-table td {\n width: max-content;\n white-space: nowrap;\n}\n\n.rfv-scalar-table tr{\n min-height: 30px;\n border-bottom: 1pt solid var(--grey-12);\n}\n\n.rfv-scalar-table tr:nth-child(odd) {\n background-color: var(--grey-1);\n}\n\n.rfv-scalar-table td:last-child {\n width: 100%;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/function-views/css/rich-function-view.css"],names:[],mappings:"AAAA;IACI,eAAe;IACf,gBAAgB;AACpB;;AAEA;IACI,2BAA2B;AAC/B;;AAEA;IACI;AACJ;;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:[".rfv-buttons {\n margin-top: 0px;\n position: sticky;\n}\n\n.ui-form-condensed .rfv-buttons > .ui-label {\n margin-right: 0px!important;\n}\n\n.ui-form .rfv-buttons > .ui-input-editor {\n justify-content: space-between\n}\n\ndiv.ui-box > div.ui-box.rfv-form > div.ui-div {\n overflow: visible!important;\n}\n\n.rfv-scalar-table {\n border-collapse: collapse;\n margin: 10px;\n}\n\n.rfv-scalar-table td {\n width: max-content;\n white-space: nowrap;\n}\n\n.rfv-scalar-table tr{\n min-height: 30px;\n border-bottom: 1pt solid var(--grey-12);\n}\n\n.rfv-scalar-table tr:nth-child(odd) {\n background-color: var(--grey-1);\n}\n\n.rfv-scalar-table td:last-child {\n width: 100%;\n}"],sourceRoot:""}]);const a=r},669:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),s=n.n(i),o=n(352),r=n.n(o)()(s());r.push([t.id,".fi-drop-area {\n position: relative;\n}\n\n.fi-drop-area .default {\n color: var(--grey-2);\n}\n\n.fi-drop-area .drag-n-dropping {\n background-color: var(--steel-1);\n border: 1px dashed var(--blue-1);\n color: var(--grey-3);\n}\n\n.fi-drop-area .error {\n color: var(--red-3);\n}\n\n.fi-drop-area .success {\n color: var(--grey-6);\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/shared-components/css/file-input.css"],names:[],mappings:"AAAA;EACE,kBAAkB;AACpB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,gCAAgC;EAChC,gCAAgC;EAChC,oBAAoB;AACtB;;AAEA;EACE,mBAAmB;AACrB;;AAEA;EACE,oBAAoB;AACtB",sourcesContent:[".fi-drop-area {\n position: relative;\n}\n\n.fi-drop-area .default {\n color: var(--grey-2);\n}\n\n.fi-drop-area .drag-n-dropping {\n background-color: var(--steel-1);\n border: 1px dashed var(--blue-1);\n color: var(--grey-3);\n}\n\n.fi-drop-area .error {\n color: var(--red-3);\n}\n\n.fi-drop-area .success {\n color: var(--grey-6);\n}\n"],sourceRoot:""}]);const a=r},380:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),s=n.n(i),o=n(352),r=n.n(o)()(s());r.push([t.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},778:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),s=n.n(i),o=n(352),r=n.n(o)()(s());r.push([t.id,".hp-funccall-card:hover {\n box-shadow: 0px 0px 3px #b8bac0;\n cursor: pointer;\n}\n\n.hp-funccall-card {\n margin: 2px 1px;\n padding: 5px 12px 5px 5px;\n justify-content: space-between;\n}\n\n.hp-funccall-card.clicked {\n border: 1px solid var(--blue-1);\n}\n\n.hp-funccall-card-hover-icon {\n display: none;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-hover-icon {\n display: flex;\n}\n\n.hp-funccall-card-def-icon {\n display: flex;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-def-icon {\n display: none;\n}\n\n.hp-funccall-card .hp-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.hp-funccall-card .hp-card-content * {\n margin-bottom: 3px;\n}\n\n.hp-funccall-card-def-icon {\n margin: 5px;\n}\n\n.hp-funccall-card-icon {\n margin: 5px;\n}\n\n.hp-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.hp-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}\n\n.grok-icon.hp-disabled {\n pointer-events: none;\n opacity: 0.6;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/shared-components/css/history-panel.css"],names:[],mappings:"AAAA;IACI,+BAA+B;IAC/B,eAAe;AACnB;;AAEA;IACI,eAAe;IACf,yBAAyB;IACzB,8BAA8B;AAClC;;AAEA;IACI,+BAA+B;AACnC;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,6BAA6B;IAC7B,gBAAgB;AACpB;;AAEA;IACI,kBAAkB;AACtB;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,kBAAkB;IAClB,oBAAoB;AACxB;;AAEA;IACI,oBAAoB;IACpB,gBAAgB;AACpB;;AAEA;IACI,oBAAoB;IACpB,YAAY;AAChB",sourcesContent:[".hp-funccall-card:hover {\n box-shadow: 0px 0px 3px #b8bac0;\n cursor: pointer;\n}\n\n.hp-funccall-card {\n margin: 2px 1px;\n padding: 5px 12px 5px 5px;\n justify-content: space-between;\n}\n\n.hp-funccall-card.clicked {\n border: 1px solid var(--blue-1);\n}\n\n.hp-funccall-card-hover-icon {\n display: none;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-hover-icon {\n display: flex;\n}\n\n.hp-funccall-card-def-icon {\n display: flex;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-def-icon {\n display: none;\n}\n\n.hp-funccall-card .hp-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.hp-funccall-card .hp-card-content * {\n margin-bottom: 3px;\n}\n\n.hp-funccall-card-def-icon {\n margin: 5px;\n}\n\n.hp-funccall-card-icon {\n margin: 5px;\n}\n\n.hp-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.hp-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}\n\n.grok-icon.hp-disabled {\n pointer-events: none;\n opacity: 0.6;\n}\n"],sourceRoot:""}]);const a=r},433:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),s=n.n(i),o=n(352),r=n.n(o)()(s());r.push([t.id,'.model-catalog-view .d4-gallery-card.entity-model i {\n height: 64px;\n width: 64px;\n position: initial;\n flex-shrink: 0;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model .d4-link-label i.grok-icon + label {\n margin-left: 6px;\n align-items: center;\n display: inline-flex;\n white-space: normal;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model {\n padding: 0 8px;\n align-items: center;\n display: flex;\n margin: 0;\n height: 94px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid {\n flex-direction: row!important;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label i.grok-icon {\n width: 32px;\n height: 32px;\n position: initial;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label label {\n margin-left: 8px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid .d4-link-label {\n min-width: 250px;\n margin-bottom: 9px;\n color: var(--grey-6);\n padding: 10px;\n width: initial;\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 20px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 16px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group .d4-tree-view-node {\n font-size: 14px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-video {\n width: 80%;\n height: 0;\n padding-bottom: 50%;\n margin: 10px 10px 0 0;\n border: 1px solid var(--grey-2);\n position: relative;\n background-size: cover;\n background-repeat: no-repeat;\n}\n\n.model-catalog-video i {\n position: absolute;\n right: 0;\n left: 0;\n bottom: 0;\n top: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-weight: 600;\n color: var(--grey-2);\n font-size: 42px;\n}\n\n.model-catalog-video i:hover {\n color: var(--grey-1);\n}\n\n.model-catalog-description {\n padding: 10px 0 0 0;\n}',"",{version:3,sources:["webpack://./src/css/model-card.css"],names:[],mappings:"AAAA;IACI,YAAY;IACZ,WAAW;IACX,iBAAiB;IACjB,cAAc;AAClB;;AAEA;IACI,gBAAgB;IAChB,mBAAmB;IACnB,oBAAoB;IACpB,mBAAmB;AACvB;;AAEA;IACI,cAAc;IACd,mBAAmB;IACnB,aAAa;IACb,SAAS;IACT,YAAY;AAChB;;AAEA;IACI,6BAA6B;AACjC;;AAEA;IACI,WAAW;IACX,YAAY;IACZ,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;AACpB;;AAEA;IACI,gBAAgB;IAChB,kBAAkB;IAClB,oBAAoB;IACpB,aAAa;IACb,cAAc;AAClB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,oBAAoB;AACxB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,oBAAoB;AACxB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,oBAAoB;AACxB;;AAEA;IACI,UAAU;IACV,SAAS;IACT,mBAAmB;IACnB,qBAAqB;IACrB,+BAA+B;IAC/B,kBAAkB;IAClB,sBAAsB;IACtB,4BAA4B;AAChC;;AAEA;IACI,kBAAkB;IAClB,QAAQ;IACR,OAAO;IACP,SAAS;IACT,MAAM;IACN,aAAa;IACb,mBAAmB;IACnB,uBAAuB;IACvB,gBAAgB;IAChB,oBAAoB;IACpB,eAAe;AACnB;;AAEA;IACI,oBAAoB;AACxB;;AAEA;IACI,mBAAmB;AACvB",sourcesContent:['.model-catalog-view .d4-gallery-card.entity-model i {\n height: 64px;\n width: 64px;\n position: initial;\n flex-shrink: 0;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model .d4-link-label i.grok-icon + label {\n margin-left: 6px;\n align-items: center;\n display: inline-flex;\n white-space: normal;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model {\n padding: 0 8px;\n align-items: center;\n display: flex;\n margin: 0;\n height: 94px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid {\n flex-direction: row!important;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label i.grok-icon {\n width: 32px;\n height: 32px;\n position: initial;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label label {\n margin-left: 8px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid .d4-link-label {\n min-width: 250px;\n margin-bottom: 9px;\n color: var(--grey-6);\n padding: 10px;\n width: initial;\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 20px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 16px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group .d4-tree-view-node {\n font-size: 14px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-video {\n width: 80%;\n height: 0;\n padding-bottom: 50%;\n margin: 10px 10px 0 0;\n border: 1px solid var(--grey-2);\n position: relative;\n background-size: cover;\n background-repeat: no-repeat;\n}\n\n.model-catalog-video i {\n position: absolute;\n right: 0;\n left: 0;\n bottom: 0;\n top: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-weight: 600;\n color: var(--grey-2);\n font-size: 42px;\n}\n\n.model-catalog-video i:hover {\n color: var(--grey-1);\n}\n\n.model-catalog-description {\n padding: 10px 0 0 0;\n}'],sourceRoot:""}]);const a=r},352:t=>{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,s,o){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var u=0;u<t.length;u++){var c=[].concat(t[u]);i&&r[c[0]]||(void 0!==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):c[2]=n),s&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=s):c[4]="".concat(s)),e.push(c))}},e}},864:t=>{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)))),s="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),o="/*# ".concat(s," */");return[e].concat([o]).join("\n")}return[e].join("\n")}},701:t=>{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 o={},r=[],a=0;a<t.length;a++){var l=t[a],u=i.base?l[0]+i.base:l[0],c=o[u]||0,d="".concat(u," ").concat(c);o[u]=c+1;var p=n(d),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)e[p].references++,e[p].updater(h);else{var m=s(h,i);i.byIndex=a,e.splice(a,0,{identifier:d,updater:m,references:1})}r.push(d)}return r}function s(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,s){var o=i(t=t||[],s=s||{});return function(t){t=t||[];for(var r=0;r<o.length;r++){var a=n(o[r]);e[a].references--}for(var l=i(t,s),u=0;u<o.length;u++){var c=n(o[u]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}o=l}}},80:t=>{var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},182:t=>{t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},850:(t,e,n)=>{t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},236:t=>{t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var s=void 0!==n.layer;s&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,s&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var o=n.sourceMap;o&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},213:t=>{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 s=e[i];if(void 0!==s)return s.exports;var o=e[i]={id:i,exports:{}};return t[i](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=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nc=void 0;var i={};(()=>{n.r(i),n.d(i,{OutliersSelection:()=>ge,PipelineStepEditor:()=>Ae,RichFunctionViewEditor:()=>ye,_package:()=>me,autostart:()=>xe,functionParametersGrid:()=>be,hof:()=>we,hof2:()=>Ce,importScriptGenerator:()=>ve,init:()=>Ee,modelCatalog:()=>Re,openModelFromFuncall:()=>fe,renderRestPanel:()=>Te});const t=grok,e=ui,s=DG,o=wu;var r=n.n(o);let a;class l extends s.CustomCardView{constructor(){super({dataSource:t.dapi.functions,permanentFilter:"#model"}),this.root.classList.add("model-catalog-view"),this.meta=new c,this.name="Models",this.permanentFilter="#model",this.renderMode=s.RENDER_MODE.BRIEF,this.objectType="Func",this.categoryFilters={"options.department":"Department","options.HL_process":"HL_process","options.process":"Process",tag:"Tags"},this.filters={All:"",Favorites:"starredBy = @current","Used by me":"usedBy = @current"},this.hierarchy=["options.department","options.HL_process","options.process"],this.hierarchyProperties={"options.department":"Department","options.HL_process":"HL_process","options.process":"Process"},this.showTree=!0,this.initRibbon(),this.initMenu(),this.currentCall=t.functions.getCurrentCall(),null==a&&null==window.localStorage.getItem("ModelCatalogShowProperties")&&(a=t.events.onCurrentObjectChanged.subscribe((e=>{(new c).isApplicable(e.sender)&&(t.shell.windows.showProperties=!0,window.localStorage.setItem("ModelCatalogShowProperties","false"),a.unsubscribe())}))),t.shell.windows.showHelp=!1}initRibbon(){this.setRibbonPanels([[e.icons.sync((()=>this.refresh()))]])}initMenu(){this.ribbonMenu.group("Help").item("Compute Engine",(()=>window.open("https://github.com/datagrok-ai/public/tree/master/packages/Compute","_blank"))).item("Developing Models",(()=>window.open("https://datagrok.ai/help/compute/scripting","_blank"))).endGroup()}setCurrentModel(t){let n=s.View.forObject(t),i=this.root.querySelector(".grok-gallery-grid");e.empty(i),i.appendChild(n.root)}}var u=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class c extends s.ObjectHandler{get type(){return"Model"}getById(e){return u(this,void 0,void 0,(function*(){return yield t.dapi.functions.find(e)}))}refresh(t){return u(this,void 0,void 0,(function*(){return yield this.getById(t.id)}))}getLanguageIcon(t){return"grok"==t?e.iconSvg("project"):e.iconImage("script",`/images/entities/${t}.png`)}isApplicable(t){return t instanceof s.Func&&t.hasTag("model")}renderIcon(t,n=null){if(null!=t.options.icon&&(t.options.icon.startsWith("http://")||t.options.icon.startsWith("https://")))return e.iconImage("model-icon",t.options.icon);if(t instanceof s.Script)return this.getLanguageIcon(t.language);let i=(t=s.Func.find({package:t.package.name,name:t.name})[0]).package.getIconUrl();if(null!=t.options.icon){let e=i.split("/");e.pop(),e.push(t.options.icon),i=e.join("/")}return e.iconImage(t.package.name,i)}renderMarkup(t){let n=e.span([this.renderIcon(t),e.label(t.friendlyName)]);return n.ondblclick=e=>{c.openModel(t)},n.onclick=e=>{c.openHelp(t)},n}renderPreview(e){const n=Object.create(null,{renderPreview:{get:()=>super.renderPreview}});var i;return u(this,void 0,void 0,(function*(){const o=null!==(i=e.options.editor)&&void 0!==i?i:"Compute:RichFunctionViewEditor",r=yield t.functions.find(o);if(null!==r&&r instanceof s.Func){const t=r.prepare({call:e.prepare()});yield t.call(!1,void 0,{processed:!0});const n=t.getOutputParamValue();if(n instanceof s.View)return n}return n.renderPreview.call(this,e)}))}renderProperties(t){const n=e.accordion("ComputeModel");n.context=t;let i=e.div([e.span([this.renderIcon(t),e.label(t.friendlyName),e.contextActions(t),e.star(t.id)])]);return n.addTitle(i),null!=t.description&&i.appendChild(e.div([e.markdown(t.description)],"model-catalog-description")),i.appendChild(e.tags(t)),null!=t.options["dev.status"]&&i.appendChild(e.tableFromMap({Status:t.options["dev.status"]})),n.end(),n.root}renderTooltip(t){let n=this.renderMarkup(t);n.classList.add("d4-link-label");let i=e.bind(t,e.divV([e.h2(n),e.divV([e.divText(t.description,"ui-description")],{style:{lineHeight:"150%"}})]));return i.ondblclick=e=>{c.openModel(t)},i}renderCard(t,n){let i=this.renderMarkup(t);i.classList.add("d4-link-label");let s=e.bind(t,e.h2(i));return s.ondblclick=e=>{c.openModel(t)},s.onclick=e=>{c.openHelp(t)},s}static openHelp(n){return u(this,void 0,void 0,(function*(){if(null!=n.options.readme){const i=`System:AppData/${n.package.name}/${n.options.readme}`,s=yield t.dapi.files.readAsText(i);t.shell.windows.help.showHelp(e.markdown(s)),t.shell.windows.showHelp=!0}}))}static getModelCatalogView(){let e=this.findModelCatalogView();if(null==e){let e=s.Func.find({package:"Compute",name:"ModelCatalog"})[0].prepare(),n=new l;n.name="Models",n.parentCall=e,t.shell.addView(n)}return e=this.findModelCatalogView(),e}static findModelCatalogView(){return r()(t.shell.views).find((t=>{var e;return"modelCatalog"==(null===(e=t.parentCall)||void 0===e?void 0:e.func.name)}))}static openModel(t){t.prepare().edit()}static openModelFromFunccall(t){t.edit()}static bindModel(t){let e=c.getModelCatalogView();if(t.aux.showOnTaskBar=!1,null!=e){let n=e.parentCall;null!=n&&(n.aux.view=e,t.parentCall=n)}}init(){setTimeout((()=>{t.functions.onBeforeRunAction.subscribe((t=>{(t.func.hasTag("model")||t.func.hasTag("model-editor"))&&c.bindModel(t)}))}))}}const d=$;var p=n.n(d);const h=()=>document.querySelector(".d4-balloon-container");class m extends s.JsViewer{constructor(){super()}onFrameAttached(t){this.render()}onTableAttached(){this.render()}render(){if(!this.dataFrame||this.dataFrame.rowCount<=0)return void(this.root.innerHTML="");const n=this.dataFrame,i="isOutlier",o="Rationale",r="Count",a="isConfirmed";n.columns.byName(i)||n.columns.add(s.Column.fromBitSet(i,s.BitSet.create(n.rowCount,(()=>!1)))),n.columns.byName(o)||n.columns.add(s.Column.fromStrings(o,Array.from({length:n.rowCount},(()=>""))));const l=()=>s.DataFrame.fromColumns([s.Column.fromStrings(o,[]),s.Column.fromInt32Array(r,new Int32Array([])),s.Column.fromStrings("Actions",[]),s.Column.fromBitSet(a,s.BitSet.create(0,(()=>!1)))]),u=s.Viewer.grid(l());u.root.style.width="100%",u.root.style.minWidth="230px",u.columns.setVisible([o,r,"Actions"]),this.root.append(e.divV([e.divV([u.root],{style:{height:"75%"}})],{style:{height:"100%"}}));const c=()=>{var t,e;if(!u.dataFrame)return;null===(t=n.col(i))||void 0===t||t.markers.assign("true",s.MARKER_TYPE.OUTLIER);const r=null===(e=u.dataFrame)||void 0===e?void 0:e.cell(u.dataFrame.rowCount-1,o).value;n.selection.getSelectedIndexes().forEach((t=>{n.col(i).set(t,!0,!1),n.col(o).set(t,r,!1)})),n.selection.setAll(!1),n.fireValuesChanged(),p()(h()).empty()},d=()=>{u.dataFrame&&(u.dataFrame.rows.removeAt(u.dataFrame.rowCount-1),n.selection.setAll(!1),p()(h()).empty())};u.onCellPrepare((t=>{var s,r,l;t.isTableCell&&("Actions"===t.gridColumn.name&&(t.gridColumn.cellType="html",t.style.element=e.divH([...(null===(s=t.grid.dataFrame)||void 0===s?void 0:s.get(a,t.gridRow))?[(l=null===(r=t.grid.dataFrame)||void 0===r?void 0:r.get(o,t.gridRow),e.div(e.icons.delete((()=>{for(let t=0;t<n.rowCount;t++)n.columns.byName(o).get(t)===l&&(n.columns.byName(o).set(t,"",!1),n.columns.byName(i).set(t,!1,!1));n.fireValuesChanged()}),"Remove the outliers group"),{style:{"text-align":"center",margin:"6px"}}))]:[e.div(e.iconFA("check",c,"Confirm the outliers"),{style:{"text-align":"center",margin:"6px"}}),e.div(e.iconFA("times",d,"Cancel the outliers"),{style:{"text-align":"center",margin:"6px"}})]])))})),u.onCellValueEdited.subscribe((t=>{var e,i;if(!u.dataFrame||t.gridColumn.name!==o)return;if(!u.dataFrame.columns.byName(a).get(t.gridRow))return;const s=new Set;for(let t=0;t<(null===(e=u.dataFrame)||void 0===e?void 0:e.rowCount);t++){const e=null===(i=u.dataFrame)||void 0===i?void 0:i.columns.byName(o).get(t);s.add(e)}for(let e=0;e<n.rowCount;e++){const i=n.columns.byName(o).get(e);""==i||s.has(i)||n.columns.byName(o).set(e,t.cell.value)}}));const m=()=>{if(n.columns.byName(o))for(let t=0;t<n.rowCount;t++)n.columns.byName(i).get(t)?""===n.columns.byName(o).get(t)&&n.columns.byName(o).set(t,"Manual",!1):""!==n.columns.byName(o).get(t)&&n.columns.byName(o).set(t,"",!1);const t={};if(n.columns.byName(o))for(let e=0;e<n.rowCount;e++){const i=n.columns.byName(o).get(e),s=t[i];""!=i&&(s?t[i]++:t[i]=1)}u.dataFrame=l(),u.columns.setVisible([o,r,"Actions"]),Object.keys(t).map((e=>{var n;null===(n=u.dataFrame)||void 0===n||n.rows.addNew([e,t[e],"",!0])}))};n.onDataChanged.subscribe(m),n.onSelectionChanged.subscribe((()=>{if(!u.dataFrame||!n.selection.trueCount)return;const i=h();if(i&&!p()(i).is(":empty")||t.shell.info(e.div([e.divText("Confirm selected points as outliers?"),e.divH([e.bigButton("Confirm",c),e.button("Cancel",d)])])),u.dataFrame.columns.byName(a).toList().some((t=>!1===t)))u.dataFrame.set(r,u.dataFrame.rowCount-1,n.selection.trueCount);else{const t=u.dataFrame.rows.addNew(["Manual",n.selection.trueCount,"",!1]);u.dataFrame.currentCell=u.dataFrame.cell(t.idx,o)}})),n.selection.setAll(!1),m()}}const f=rxjs;var v=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const g=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 y;!function(e){const n={};function i(e){var i;return v(this,void 0,void 0,(function*(){const s=e.func.id,o=null!==(i=n[s])&&void 0!==i?i:yield t.dapi.functions.include("package").allPackageVersions().find(s);n[s]||(n[s]=o),e.func=o}))}e.augmentCallWithFunc=i,e.loadChildRuns=function(e){return v(this,void 0,void 0,(function*(){const n=yield t.dapi.functions.calls.allPackageVersions().find(e);yield i(n);const s=yield t.dapi.functions.calls.allPackageVersions().include("func").filter(`options.parentCallId="${e}"`).list();return yield Promise.all(s.map((t=>v(this,void 0,void 0,(function*(){return i(t)}))))),{parentRun:n,childRuns:s}}))},e.loadRun=function(e,n=!1){return v(this,void 0,void 0,(function*(){const o=yield t.dapi.functions.calls.allPackageVersions().include("inputs, outputs, session.user").find(e);if(yield i(o),!n){const e=r()(o.outputParams.values()).filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME));for(const n of e)o.outputs[n.name]=yield t.dapi.tables.getTable(o.outputs[n.name]);const n=r()(o.inputParams.values()).filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME));for(const e of n)o.inputs[e.name]=yield t.dapi.tables.getTable(o.inputs[e.name])}return o}))},e.saveRun=function(e){return v(this,void 0,void 0,(function*(){const n=r()(e.outputParams.values()).filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME));for(const i of n)e.outputs[i.name]=e.outputs[i.name].clone(),yield t.dapi.tables.uploadDataFrame(e.outputs[i.name]);const i=r()(e.inputParams.values()).filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME));for(const n of i)e.inputs[n.name]=e.inputs[n.name].clone(),yield t.dapi.tables.uploadDataFrame(e.inputs[n.name]);return yield t.dapi.functions.calls.allPackageVersions().save(e)}))},e.deleteRun=function(e){return v(this,void 0,void 0,(function*(){yield t.dapi.functions.calls.allPackageVersions().delete(e)}))},e.pullRuns=function(e,n={},i={}){return v(this,void 0,void 0,(function*(){let s=`func.id="${e}"`;return s+=n.author?` and session.user.id="${n.author.id}"`:"",s+=n.date?g(n.date):"",t.dapi.functions.calls.allPackageVersions().filter(s).include("session.user, options").list(i)}))},e.pullRunsByName=function(e,n=[],o={},a=[]){return v(this,void 0,void 0,(function*(){let l="";for(const t of n){const e=[];t.author&&e.push(`session.user.id="${t.author.id}"`),t.date&&e.push(g(t.date)),t.isShared&&e.push('options.isShared="true"'),t.text&&e.push(`((options.title like "${t.text}") or (options.annotation like "${t.text}"))`);const n=e.join(" and ");""!==n&&(l+=""===l?`(${n})`:` or (${n})`)}""!==l&&(l=` and (${l})`);const u=yield t.dapi.functions.calls.allPackageVersions().filter(`func.name="${e}"${l}`).include(`${a.join(",")}`).list(o);for(const t of u)yield i(t);if(a.includes("inputs")||a.includes("func.params"))for(const e of u){const n=r()(e.inputParams.values()).filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME));for(const i of n)e.inputs[i.name]=yield t.dapi.tables.getTable(e.inputs[i.name])}if(a.includes("outputs")||a.includes("func.params"))for(const e of u){const n=r()(e.outputParams.values()).filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME));for(const i of n)e.outputs[i.name]=yield t.dapi.tables.getTable(e.outputs[i.name])}return u}))}}(y||(y={}));const A=ExcelJS;var b,w=n.n(A),C=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};!function(t){t.isSheetExist=(t,e)=>n=>C(this,void 0,void 0,(function*(){const i=n.worksheets.find((e=>e.name===t));return i?{isValid:!0,chainedFuncs:e,result:i}:{isValid:!1,caption:`Sheet named '${t}' is not found`,content:`Sheet name should be exactly \`${t}\` to be parsed.\n\n\nPlease double-check:\n- No extra spaces are in the sheet name\n- Capitalization is the same as in the template\n\n\n${n.worksheets.length>0?`Found sheets: \`${n.worksheets.map((t=>t.name)).join("`,`")}\``:"No columns have found."}\n `}})),t.isColumnExist=(t,e)=>n=>C(this,void 0,void 0,(function*(){const i=n.getRow(1).values;return i.includes(t)?{isValid:!0,chainedFuncs:e}:{isValid:!1,caption:`No column "${t}" in "${n.name}" sheet`,content:`Column name should be exactly \`${t}\` to be parsed.\n\n\nPlease double-check:\n- Column names are in the first row of the sheet\n- No extra spaces are in the cell\n- Capitalization is the same as in the template\n\n\n${i.length>0?`Found columns: \`${i.filter((t=>""!==t)).join("`,`")}\``:"No columns have found."}\n `}})),t.isExcelParsed=t=>e=>C(this,void 0,void 0,(function*(){return(new(w().Workbook)).xlsx.load(yield e.arrayBuffer()).then((e=>C(this,void 0,void 0,(function*(){return{isValid:!0,chainedFuncs:t,result:e}})))).catch((()=>({isValid:!1,caption:"File is failed to parse",content:"Please make sure:\n- XLSX format is used (not XLS or XLSM)\n- File should not be corrupted\n\n\nXLS could be converted to XLSX using Excel's export functionality. \n\nIf the file is corrupted, it will not open in Excel.\n "})))}))}(b||(b={}));var T=n(701),I=n.n(T),x=n(236),E=n.n(x),R=n(80),S=n.n(R),F=n(850),P=n.n(F),O=n(182),B=n.n(O),k=n(213),V=n.n(k),M=n(669),L={};L.styleTagTransform=V(),L.setAttributes=P(),L.insert=S().bind(null,"head"),L.domAPI=E(),L.insertStyleElement=B(),I()(M.Z,L),M.Z&&M.Z.locals&&M.Z.locals;var _=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const N="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class D extends s.InputBase{get value(){return this.fileValue}set value(t){this.stringValue=(null==t?void 0:t.name)||"Drag-n-drop your file",this.fileValue=t,this.notify&&this.fireInput()}constructor(t="Drag-n-drop here",n=null,i=null,o=N){super(e.stringInput("Input file","",null).dart),this.initialText=t,this.initialValue=n,this.onValueChanged=i,this.fileType=o,this.uploadedFile$=new f.Subject,this.onFileUploaded=this.uploadedFile$,this.fileValue=null,this.validation=new class{constructor(t=[]){this.validators=t}validate(t){return C(this,void 0,void 0,(function*(){const n=[],i=(t,e)=>C(this,void 0,void 0,(function*(){for(const s of t){const t=yield s(e);t.isValid?t.chainedFuncs&&(yield i(t.chainedFuncs,t.result)):n.push(t)}}));for(const e of this.validators){const s=yield e(t);s.isValid?s.chainedFuncs&&(yield i(s.chainedFuncs,s.result)):n.push(s)}if(0==n.length)return!0;const o=new s.Wizard({title:"Data validation failed"});n.forEach((t=>{o.page({caption:t.caption,root:t.content instanceof HTMLElement?t.content:e.markdown(t.content)})})),o.onOK((()=>{}));const r=o.getButton("CANCEL"),a=o.getButton("<<"),l=o.getButton(">>"),u=o.getButton("OK"),c=o.pages.length,d=e.divText("1/"+c);return d.style.position="absolute",d.style.left="12px",d.style.color="var(--grey-5)",o.captionHost.style.fontSize="20px",o.captionHost.style.fontWeight="400",o.captionHost.style.margin="6px 0",p()(o.root).find(".d4-command-bar").append(d),p()(a).html("BACK"),p()(l).html("NEXT"),p()(u).addClass("disabled"),r.style.display="none",a.addEventListener("click",(()=>{const t=o.pageIndex+1,e=o.pages.length;o.captionHost.style.fontSize="20px",o.captionHost.style.fontWeight="400",o.captionHost.style.margin="6px 0",o.completable||p()(u).addClass("disabled"),d.textContent=t+"/"+e})),l.addEventListener("click",(()=>{const t=o.pageIndex+1,e=o.pages.length;o.captionHost.style.fontSize="20px",o.captionHost.style.fontWeight="400",o.captionHost.style.margin="6px 0",o.completable&&p()(u).removeClass("disabled"),d.textContent=t+"/"+e})),o.show(),!1}))}},this.isValid=new f.BehaviorSubject(!0),this.hiddenInput=document.createElement("input"),this.icon=e.iconFA("cloud-upload",(()=>this.hiddenInput.click())),this.subscribeOnEvents(),this.root.style.display="flex",this.isValid.subscribe((t=>{if(t){this.input.classList.remove("error"),this.input.classList.add("success");const t=e.iconFA("times",(()=>this.reset()),"Reset uploaded file");this.icon.replaceWith(t),this.icon=t}else{this.input.classList.remove("success"),this.input.classList.add("error");const t=e.iconFA("redo",(()=>this.hiddenInput.click()),"Re-upload a file");this.icon.replaceWith(t),this.icon=t}})),this.uploadedFile$.subscribe((t=>{if(this.onValueChanged&&this.onValueChanged(t),!t){const t=e.iconFA("cloud-upload",(()=>this.hiddenInput.click()),"Choose a file to upload");this.icon.replaceWith(t),this.icon=t}this.value=t})),this.reset()}subscribeOnEvents(){this.input.readOnly=!0,this.input.classList.add("default");const t=t=>_(this,void 0,void 0,(function*(){if(t&&t.length&&this.enabled){if(t.length>1)throw this.isValid.next(!1),new Error("Please specify single input file");if(this.fileType&&t[0].type!==this.fileType)throw this.isValid.next(!1),new Error("File type is not supported");this.isValid.next(yield this.validation.validate(t[0])),this.isValid.value?this.uploadedFile$.next(t[0]):this.uploadedFile$.next(null)}}));this.root.classList.add("fi-drop-area"),this.root.style.width="100%",this.hiddenInput.type="file",this.hiddenInput.addEventListener("change",(()=>_(this,void 0,void 0,(function*(){return yield t(this.hiddenInput.files)}))),!1),["dragenter","dragover","dragleave","drop"].forEach((t=>{this.input.addEventListener(t,(t=>{t.preventDefault(),t.stopPropagation()}),!1)})),["dragenter","dragover"].forEach((t=>{this.input.addEventListener(t,(()=>{this.input.classList.add("drag-n-dropping")}),!1)})),["dragleave","drop"].forEach((t=>{this.input.addEventListener(t,(()=>{this.input.classList.remove("drag-n-dropping")}),!1)})),this.input.addEventListener("drop",(e=>_(this,void 0,void 0,(function*(){const n=e.dataTransfer.files;t(n)}))),!1),this.input.addEventListener("click",(()=>this.hiddenInput.click()),!1),this.addOptions(this.icon),["drag","dragenter"].forEach((t=>{document.getElementsByClassName("layout-workarea")[0].addEventListener(t,(t=>{t.stopPropagation()}),!1)}))}reset(){this.input.classList.value="ui-input-editor default",this.hiddenInput.value="",this.uploadedFile$.next(null)}}const j=rxjs.operators;var Y=n(380),H={};H.styleTagTransform=V(),H.setAttributes=P(),H.insert=S().bind(null,"head"),H.domAPI=E(),H.insertStyleElement=B(),I()(Y.Z,H),Y.Z&&Y.Z.locals&&Y.Z.locals;var W=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class U{static getHistoryRuns(e,n=!0){return(0,f.from)((()=>W(this,void 0,void 0,(function*(){return yield y.pullRunsByName(e,[{isShared:!0},{author:t.shell.user}],{order:"started"},[...n?["func.params"]:[],"session.user","options"])})))())}}class G{constructor(t,n,i,o,r=[],a=!0){var l;this.label=t,this._funcName=n,this._stringValueFunc=i,this._visibleColumnsForGrid=o,this._visibleColumnsForFilter=r,this.includeParams=a,this.onHistoricalRunChosen=new f.BehaviorSubject(null),this.experimentRunsUpdate=new f.Subject,this.store={experimentRuns:new f.Observable,experimentRunsDf:new f.BehaviorSubject(s.DataFrame.fromColumns([s.Column.fromStrings("Pick",[]),...Object.keys(this._visibleColumnsForGrid).map((t=>s.Column.fromStrings(t,[])))])),isExperimentRunsLoading:new f.Subject,experimentRunData:new f.BehaviorSubject("")},this._historyGrid=s.Viewer.grid(this.store.experimentRunsDf.value,{showRowHeader:!1,showColumnGridlines:!1,allowEdit:!1}),this._historyFilters=s.Viewer.filters(this.store.experimentRunsDf.value,{title:"Filters"}),this._visibleInput=e.stringInput(this.label,"",null),this._visibleIcon=e.iconFA("bars",(()=>this.showSelectionDialog()),this.label),this._historyGrid.columns.byName("Pick").cellType="html",this._historyGrid.columns.byName("Pick").width=30,this._historyGrid.root.style.height="100%";for(let t=0;t<this._historyGrid.columns.length;t++){const e=null===(l=this._historyGrid.columns.byIndex(t))||void 0===l?void 0:l.column;e&&e.type===s.TYPE.DATE_TIME&&(this._historyGrid.columns.byIndex(t).format="MMM d, yyyy",this._historyGrid.columns.byIndex(t).width=100)}this._visibleInput.input.addEventListener("click",(()=>this.showSelectionDialog())),this._visibleInput.readOnly=!0,this._visibleIcon.style.display="none",this.store.experimentRuns=this.experimentRunsUpdate.pipe((0,j.tap)((()=>this.toggleLoaderExpRuns(!0))),(0,j.switchMap)((()=>U.getHistoryRuns(this._funcName,this.includeParams).pipe((0,j.catchError)((t=>(console.error(t),f.EMPTY))),(0,j.finalize)((()=>this.toggleLoaderExpRuns(!1)))))),(0,j.shareReplay)(1)),this.store.experimentRuns.subscribe((t=>{const e=s.DataFrame.fromColumns([s.Column.bool("Pick",t.length).init(!1),...Object.entries(this._visibleColumnsForGrid).map((e=>s.Column.fromStrings(e[0],t.map(e[1])))),s.Column.fromStrings("ID",t.map((t=>t.id)))]);e.onCurrentRowChanged.subscribe((()=>{e.getCol("Pick").init(!1),e.set("Pick",e.currentRow.idx,!0);const n=e.getCol("ID").get(e.currentRow.idx);this._chosenRun=t.find((t=>t.id===n))})),this.store.experimentRunsDf.next(e),this._visibleIcon.style.display="inherit"})),this.store.experimentRunsDf.subscribe((t=>{this.historyGrid.dataFrame=t,this.historyFilters.dataFrame=t})),this.onHistoricalRunChosen.subscribe((t=>{this._visibleInput.value=t?this._stringValueFunc(t):""})),this.store.isExperimentRunsLoading.subscribe((t=>{e.setUpdateIndicator(this._visibleInput.root,t)}))}showSelectionDialog(){var t;const n=e.dialog();n.onOK((()=>W(this,void 0,void 0,(function*(){if(this._chosenRun){let t=this._chosenRun;this.includeParams||(t=yield y.loadRun(t.id)),this.onHistoricalRunChosen.next(t)}})))),n.onCancel((()=>{this.onHistoricalRunChosen.next(null),this.historyGrid.dataFrame.currentRowIdx=-1}));const i=s.Viewer.filters(this.store.experimentRunsDf.value,{title:"Filters"});this._historyFilters.root.replaceWith(i.root),this._historyFilters=i;const o=s.Viewer.grid(this.store.experimentRunsDf.value,{showRowHeader:!1,showColumnGridlines:!1,allowEdit:!1});this._historyGrid.root.replaceWith(o.root),this._historyGrid=o,this._historyGrid.columns.byName("Pick").cellType="html",this._historyGrid.columns.byName("Pick").width=30,this._historyGrid.root.style.height="100%";for(let e=0;e<this._historyGrid.columns.length;e++){const n=null===(t=this._historyGrid.columns.byIndex(e))||void 0===t?void 0:t.column;n&&n.type===s.TYPE.DATE_TIME&&(this._historyGrid.columns.byIndex(e).format="MMM d yyyy HH:mm")}this._historyGrid.onCellPrepare((t=>{var n;"Pick"===(null===(n=t.tableColumn)||void 0===n?void 0:n.name)&&(t.isColHeader&&(t.customText=""),!0===t.cell.value?t.element=e.div([e.iconFA("check",null,"Selected")],{style:{"text-align":"center",margin:"6px"}}):t.element=e.div())})),this._historyGrid.columns.setVisible(["Pick",...Object.keys(this._visibleColumnsForGrid).map((t=>t))]),this._historyFilters.setOptions({columnNames:this._visibleColumnsForFilter}),this._historyFilters.root.style.height="100%",p()(this._historyFilters.root).find(".d4-filter-group-header").hide(),this._visibleColumnsForFilter.length||p()(this._historyFilters.root.parentElement).hide(),n.add(e.divH([e.block([this._historyGrid.root]),e.block([this._historyFilters.root],{style:{"margin-left":"10px",width:"300px",height:"100%"}})],{style:{height:"100%"}})),n.show({modal:!0,fullScreen:!0,center:!0,width:Math.max(400,window.screen.width-200),height:Math.max(200,window.screen.height-200)})}get historyGrid(){return this._historyGrid}get historyFilters(){return this._historyFilters}get root(){return this._visibleInput.root}get iconRoot(){return this._visibleIcon}set value(t){this._visibleInput.value=t?this._stringValueFunc(t):""}get value(){return this.onHistoricalRunChosen.value}set stringValue(t){this._visibleInput.value=t}get stringValue(){return this._visibleInput.value}toggleLoaderExpRuns(t){this.store.isExperimentRunsLoading.next(t)}}const z=dayjs;var Z=n.n(z),q=n(778),J={};J.styleTagTransform=V(),J.setAttributes=P(),J.insert=S().bind(null,"head"),J.domAPI=E(),J.insertStyleElement=B(),I()(q.Z,J),q.Z&&q.Z.locals&&q.Z.locals;var X=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class K{constructor(){this.filteringOptions={text:""},this.allRuns=new f.BehaviorSubject([])}get myRuns(){return this.allRuns.value.filter((e=>e.author.id===t.shell.user.id))}get favoriteRuns(){return this.allRuns.value.filter((t=>t.options.isFavorite&&!t.options.isImported))}get sharedRuns(){return this.allRuns.value.filter((t=>t.options.isShared))}get filteredMyRuns(){return this.myRuns.filter((t=>{const e=!this.filteringOptions.startedAfter||t.started>this.filteringOptions.startedAfter,n=!this.filteringOptions.text.length||!!t.options.title&&t.options.title.includes(this.filteringOptions.text),i=!this.filteringOptions.text.length||!!t.options.description&&t.options.description.includes(this.filteringOptions.text),s=!this.filteringOptions.tags||0===this.filteringOptions.tags.length||!!t.options.tags&&this.filteringOptions.tags.every((e=>t.options.tags.includes(e)));return(n||i)&&e&&s}))}get filteredFavoriteRuns(){return this.favoriteRuns.filter((t=>{const e=!this.filteringOptions.startedAfter||t.started>this.filteringOptions.startedAfter,n=!this.filteringOptions.text.length||!!t.options.title&&t.options.title.includes(this.filteringOptions.text),i=!this.filteringOptions.text.length||!!t.options.description&&t.options.description.includes(this.filteringOptions.text),s=!this.filteringOptions.tags||0===this.filteringOptions.tags.length||!!t.options.tags&&this.filteringOptions.tags.every((e=>t.options.tags.includes(e)));return(n||i)&&e&&s}))}get filteredSharedRuns(){return this.sharedRuns.filter((t=>{const e=!this.filteringOptions.author||t.author.id===this.filteringOptions.author.id,n=!this.filteringOptions.startedAfter||t.started>this.filteringOptions.startedAfter,i=!this.filteringOptions.text.length||!!t.options.title&&t.options.title.includes(this.filteringOptions.text),s=!this.filteringOptions.text.length||!!t.options.description&&t.options.description.includes(this.filteringOptions.text),o=!this.filteringOptions.tags||0===this.filteringOptions.tags.length||!!t.options.tags&&this.filteringOptions.tags.every((e=>t.options.tags.includes(e)));return(i||s)&&n&&e&&o}))}}const Q="HISTORY",tt="FAVORITES",et="SHARED";class nt{get selectedCallsSet(){const t=this.tabs.currentPane.name;if(t===Q)return this.mySelectedCallsSet;if(t===tt)return this.favoritesSelectedCallsSet;if(t===et)return this.sharedSelectedCallsSet;throw new Error("Unknown tab is selected")}buildActionsSection(t){const n=(()=>{if(t===Q)return this.mySelectedCallsSet;if(t===tt)return this.favoritesSelectedCallsSet;if(t===et)return this.sharedSelectedCallsSet;throw new Error("Unknown tab is selected")})();return e.divH([e.span([`Selected: ${n.size}`],{style:{"align-self":"center"}}),e.divH([(()=>{const t=e.iconFA("exchange",(()=>X(this,void 0,void 0,(function*(){this.onComparison.next([...r()(n.keys()).map((t=>t.id))])}))),"Compare selected runs");return t.style.margin="5px",n.size<2&&t.classList.add("hp-disabled"),t})(),(()=>{const t=e.iconFA("trash-alt",(()=>this.showDeleteRunDialog(n)),"Delete selected runs");return t.style.margin="5px",0===n.size&&t.classList.add("hp-disabled"),t})(),...0===n.size?[(()=>{const t=e.iconFA("square",(()=>{switch(this.tabs.currentPane.name){case Q:this.store.myRuns.forEach((t=>n.add(t))),this.myRunsFilter.next();break;case tt:this.store.favoriteRuns.forEach((t=>n.add(t))),this.favRunsFilter.next();break;case et:this.store.sharedRuns.forEach((t=>n.add(t))),this.sharedRunsFilter.next()}this.updateActionsSection(this.tabs.currentPane.name)}),"Select all");return t.style.margin="5px",t})()]:[(()=>{let t=0;switch(this.tabs.currentPane.name){case Q:t=this.store.myRuns.length;break;case tt:t=this.store.favoriteRuns.length;break;case et:t=this.store.sharedRuns.length}const i=n.size===t?"check-square":"minus-square",s=e.iconFA(i,(()=>{switch(this.tabs.currentPane.name){case Q:this.store.myRuns.forEach((t=>n.delete(t))),this.myRunsFilter.next();break;case tt:this.store.favoriteRuns.forEach((t=>n.delete(t))),this.favRunsFilter.next();break;case et:this.store.sharedRuns.forEach((t=>n.delete(t))),this.sharedRunsFilter.next()}this.updateActionsSection(this.tabs.currentPane.name)}),"Unselect all");return s.style.margin="5px",s})()]])],{style:{"justify-content":"space-between",padding:"0 12px"}})}buildFilterPane(n){return e.wait((()=>X(this,void 0,void 0,(function*(){const i=new f.Subject,o=e.stringInput("Search","",(t=>i.next(t)));s.debounce(i.asObservable(),600).subscribe((()=>{this.store.filteringOptions.text=o.stringValue,this.myRunsFilter.next(),this.favRunsFilter.next(),this.sharedRunsFilter.next()}));const r=e.dateInput("Started after",Z()().subtract(1,"week"),(t=>{this.store.filteringOptions.startedAfter=t,this.myRunsFilter.next(),this.favRunsFilter.next(),this.sharedRunsFilter.next()})),a=Object.values(s.User.defaultUsersIds),l=(yield t.dapi.users.list()).filter((t=>!a.includes(t.id))),u=e.choiceInput("Author","Anyone",["Anyone",...l],(t=>{this.store.filteringOptions.author="Anyone"===t?void 0:t,this.sharedRunsFilter.next()}));u.root.style.display="none";let c=e.choiceInput("Tag","Choose tag to filter",["Choose tag to filter"]);const d=s.TagEditor.create(),p=e.stringInput(" ","");p.input.replaceWith(d.root),p.root.style.display="none",d.onChanged((()=>{this.store.filteringOptions.tags=d.tags.filter((t=>!!t)),0===this.store.filteringOptions.tags.length?p.root.style.display="none":p.root.style.removeProperty("display"),this.myRunsFilter.next(),this.favRunsFilter.next(),this.sharedRunsFilter.next()})),this.store.allRuns.subscribe((()=>{const t=this.store.allRuns.value.map((t=>t.options.tags)).reduce(((t,e)=>(e&&e.forEach((e=>{t.includes(e)||t.push(e)})),t)),[]),n=e.choiceInput("Tag","Choose tag to filter",["Choose tag to filter",...t]);c.root.replaceWith(n.root),c=n,c.onChanged((()=>{c.value&&"Choose tag to filter"!==c.value&&!d.tags.includes(c.value)&&d.addTag(c.value)}))})),r.addPatternMenu("datetime");const h=e.divV([o,r,u,c,p],"ui-form ui-form-wide ui-form-left");return n===Q&&(r.root.style.removeProperty("display"),u.root.style.display="none"),n===tt&&(r.root.style.removeProperty("display"),u.root.style.display="none"),n===et&&(r.root.style.removeProperty("display"),u.root.style.removeProperty("display")),h}))))}showDeleteRunDialog(t){e.dialog({title:`Delete ${t.size} ${t.size>1?"runs":"run"}`}).add(e.divText(`Deleted ${t.size} ${t.size>1?"runs":"run"} ${t.size>1?"are":"is"} impossible to restore. Are you sure?`)).onOK((()=>X(this,void 0,void 0,(function*(){t.forEach((t=>X(this,void 0,void 0,(function*(){this.beforeRunDeleted.next(t.id),this.selectedCallsSet.delete(t),yield y.deleteRun(t),this.afterRunDeleted.next(t.id)}))))})))).show({center:!0})}updateActionsSection(t){const e=this.buildActionsSection(t);(()=>{t===Q&&(this.myActionsSection.replaceWith(e),this.myActionsSection=e),t===tt&&(this.favActionsSection.replaceWith(e),this.favActionsSection=e),t===et&&(this.sharedActionsSection.replaceWith(e),this.sharedActionsSection=e)})()}updateSharedPane(t){const n=t.length>0?this.renderSharedCards(t):e.divText("No runs are marked as shared","hi-no-elements-label"),i=e.divV([this.sharedPaneFilter,this.sharedActionsSection,e.element("div","splitbar-horizontal"),n]);this.sharedTab.replaceWith(i),this.sharedTab=i}updateFavoritesPane(t){const n=t.length>0?this.renderFavoriteCards(t):e.divText("No runs are marked as favorites","hi-no-elements-label"),i=e.divV([this.favoritesPaneFilter,this.favActionsSection,e.element("div","splitbar-horizontal"),n]);this.favTab.replaceWith(i),this.favTab=i}updateMyPane(t){const n=t.length>0?this.renderHistoryCards(t):e.divText("No runs are found in history","hi-no-elements-label"),i=e.divV([this.myPaneFilter,this.myActionsSection,e.element("div","splitbar-horizontal"),n]);this.historyTab.replaceWith(i),this.historyTab=i}renderCard(n){var i;const s=n.author.picture;s.style.width="25px",s.style.height="25px",s.style.fontSize="20px";const o=e.label(null!==(i=n.options.title)&&void 0!==i?i:n.author.friendlyName,{style:{color:"var(--blue-1)"}});e.bind(n.author,s);const r=e.iconFA("square",(t=>{t.stopPropagation(),this.selectedCallsSet.add(n),r.style.display="none",a.style.removeProperty("display"),this.updateActionsSection(this.tabs.currentPane.name)}),"Select this run");r.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const a=e.iconFA("check-square",(t=>{t.stopPropagation(),this.selectedCallsSet.delete(n),a.style.display="none",this.updateActionsSection(this.tabs.currentPane.name),r.style.removeProperty("display")}),"Unselect this run");a.classList.add("hp-funccall-card-icon"),this.selectedCallsSet.has(n)?(r.style.display="none",a.style.removeProperty("display")):(r.style.removeProperty("display"),a.style.display="none");const l=e.iconFA("edit",(t=>{t.stopPropagation(),this.showEditDialog(n)}),"Edit selected run");l.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const u=e.iconFA("trash-alt",(t=>X(this,void 0,void 0,(function*(){t.stopPropagation();const e=new Set;e.add(n),this.showDeleteRunDialog(e)}))),"Delete selected runs");u.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const c=e.iconFA("star",null,"Unfavorite the run");c.classList.add("fas","hp-funccall-card-def-icon");const d=e.iconFA("share-alt",null,"Add to shared");d.classList.add("fas","hp-funccall-card-def-icon"),d.style.color="var(--blue-1)";const p=new Date(n.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"}),h=e.divH([e.divH([s,e.divV([o,e.span([p]),...n.options.description?[e.divText(n.options.description,"description")]:[],...n.options.tags&&n.options.tags.length>0?[e.div(n.options.tags.map((t=>e.span([t],"d4-tag"))))]:[]],"hp-card-content")]),e.divH([l,u,...n.options.isFavorite?[c]:[],...n.options.isShared?[d]:[],r,a])],"hp-funccall-card");return h.addEventListener("click",(()=>X(this,void 0,void 0,(function*(){this.onRunChosen.next(n.id),[...this.myCards,...this.favoriteCards,...this.sharedCards].forEach((t=>t.classList.remove("clicked"))),h.classList.add("clicked")})))),e.tooltip.bind(h,(()=>e.tableFromMap(Object.assign(Object.assign(Object.assign({Author:t.shell.user.toMarkup(),Date:p},n.options.title?{Title:n.options.title}:{}),n.options.description?{Description:n.options.description}:{}),n.options.tags&&n.options.tags.length>0?{Tags:e.div(n.options.tags.map((t=>e.span([t],"d4-tag"))),"d4-tag-editor")}:{})))),h}showEditDialog(t){var n,i,o,r;const a=e.dialog({title:"Edit run"});let l=null!==(n=t.options.title)&&void 0!==n?n:"",u=null!==(i=t.options.description)&&void 0!==i?i:"";const c=e.stringInput("Title",l,(t=>l=t));let d=null!==(o=t.options.isShared)&&void 0!==o&&o,p=null!==(r=t.options.isFavorite)&&void 0!==r&&r;const h=s.TagEditor.create();(t.options.tags||[]).forEach((t=>{h.addTag(t)}));const m=e.stringInput(" ","");m.input.replaceWith(h.root);const f=e.stringInput("Tag",""),v=()=>{""===f.value||h.tags.includes(f.value)||(h.addTag(f.value),f.value="")};f.addOptions(e.iconFA("plus",v,"Add this tag")),f.input.onkeydown=t=>X(this,void 0,void 0,(function*(){"Enter"==t.key&&(t.stopPropagation(),v())})),a.add(e.form([c,e.stringInput("Description",u,(t=>{u=t})),e.boolInput("Favorites",p,(t=>p=t)),e.boolInput("Share",d,(t=>d=t)),f,m])).onOK((()=>X(this,void 0,void 0,(function*(){if((t=yield y.loadRun(t.id)).options.title=""!==l?l:null,t.options.description=""!==u?u:null,t.options.tags=[...h.tags],!!d==!!t.options.isShared&&!!p==!!t.options.isFavorite){e.setUpdateIndicator(this.tabs.root,!0),yield y.saveRun(t);const n=this.store.allRuns.value.find((e=>e.id===t.id));return n.options.title=""!==l?l:null,n.options.description=""!==u?u:null,n.options.tags=[...t.options.tags],this.store.allRuns.next(this.store.allRuns.value),void e.setUpdateIndicator(this.tabs.root,!1)}d&&!t.options.isShared&&(t.options.isShared=d,e.setUpdateIndicator(this.tabs.root,!0),yield this.addRunToShared(t),e.setUpdateIndicator(this.tabs.root,!1)),!d&&t.options.isShared&&(t.options.isShared=d,e.setUpdateIndicator(this.tabs.root,!0),yield this.removeRunFromShared(t),e.setUpdateIndicator(this.tabs.root,!1)),p&&!t.options.isFavorite&&(t.options.isFavorite=p,e.setUpdateIndicator(this.tabs.root,!0),yield this.addRunToFavorites(t),e.setUpdateIndicator(this.tabs.root,!1)),!p&&t.options.isFavorite&&(t.options.isFavorite=p,e.setUpdateIndicator(this.tabs.root,!0),yield this.removeRunFromFavorites(t),e.setUpdateIndicator(this.tabs.root,!1))})))).show({center:!0,width:500})}renderFavoriteCards(t){return this.favoriteCards=t.map((t=>this.renderCard(t))),e.divV(this.favoriteCards)}renderSharedCards(t){return this.sharedCards=t.map((t=>this.renderCard(t))),e.divV(this.sharedCards)}renderHistoryCards(t){return this.myCards=t.map((t=>this.renderCard(t))),e.divV(this.myCards,{style:{height:"100%"}})}constructor(t){this.func=t,this.onRunChosen=new f.Subject,this.onComparison=new f.Subject,this.beforeRunAddToFavorites=new f.Subject,this.beforeRunAddToShared=new f.Subject,this.beforeRunRemoveFromFavorites=new f.Subject,this.beforeRunRemoveFromShared=new f.Subject,this.beforeRunDeleted=new f.Subject,this.afterRunAddToFavorites=new f.Subject,this.afterRunAddToShared=new f.Subject,this.afterRunRemoveFromFavorites=new f.Subject,this.afterRunRemoveFromShared=new f.Subject,this.afterRunDeleted=new f.Subject,this.store=new K,this.myRunsFilter=new f.Subject,this.favRunsFilter=new f.Subject,this.sharedRunsFilter=new f.Subject,this.mySelectedCallsSet=new Set,this.favoritesSelectedCallsSet=new Set,this.sharedSelectedCallsSet=new Set,this.allRunsFetch=new f.Subject,this.historyTab=e.div(),this.favTab=e.div(),this.sharedTab=e.div(),this.filterPane=e.div(),this.tabs=e.tabControl({[Q]:e.box(this.historyTab),[tt]:e.box(this.favTab),[et]:e.box(this.sharedTab)}),this.myActionsSection=this.buildActionsSection(Q),this.favActionsSection=this.buildActionsSection(tt),this.sharedActionsSection=this.buildActionsSection(et),this._root=e.divV([this.tabs.root],{style:{width:"100%",height:"100%"}}),this.myCards=[],this.favoriteCards=[],this.sharedCards=[],this.myPaneFilter=this.buildFilterPane(Q),this.favoritesPaneFilter=this.buildFilterPane(tt),this.sharedPaneFilter=this.buildFilterPane(et),this.tabs.root.style.width="100%",this.tabs.root.style.height="100%",this.myRunsFilter.subscribe((()=>this.updateMyPane(this.store.filteredMyRuns))),this.favRunsFilter.subscribe((()=>this.updateFavoritesPane(this.store.filteredFavoriteRuns))),this.sharedRunsFilter.subscribe((()=>this.updateSharedPane(this.store.filteredSharedRuns))),this.store.allRuns.subscribe((()=>{this.updateMyPane(this.store.filteredMyRuns),this.updateFavoritesPane(this.store.filteredFavoriteRuns),this.updateSharedPane(this.store.filteredSharedRuns)})),this.allRunsFetch.subscribe((()=>X(this,void 0,void 0,(function*(){e.setUpdateIndicator(this.root,!0);const t=(yield y.pullRunsByName(this.func.name,[],{order:"started"},["session.user","options"])).reverse();this.store.allRuns.next(t),e.setUpdateIndicator(this.root,!1)})))),this.afterRunAddToFavorites.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.tags=t.options.tags,e.options.isFavorite=!0,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunAddToShared.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.tags=t.options.tags,e.options.isShared=!0,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunRemoveFromFavorites.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.tags=t.options.tags,e.options.isFavorite=!1,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunRemoveFromShared.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.tags=t.options.tags,e.options.isShared=!1,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunDeleted.subscribe((t=>{this.store.allRuns.next(this.store.allRuns.value.filter((e=>e.id!==t))),this.updateActionsSection(this.tabs.currentPane.name)})),this.allRunsFetch.next()}addRunToFavorites(e){return X(this,void 0,void 0,(function*(){e.options.isFavorite=!0,this.beforeRunAddToFavorites.next(e);const n=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunAddToFavorites.next(n),n}))}removeRunFromFavorites(e){return X(this,void 0,void 0,(function*(){e.options.isFavorite=!1,this.beforeRunRemoveFromFavorites.next(e);const n=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunRemoveFromFavorites.next(n),n}))}addRunToShared(e){return X(this,void 0,void 0,(function*(){e.options.isShared=!0,this.beforeRunAddToShared.next(e);const n=yield t.dapi.groups.find(s.Group.defaultGroupsIds["All users"]),i=r()(e.outputParams.values()).filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME));for(const s of i){const i=e.outputs[s.name];yield t.dapi.permissions.grant(i.getTableInfo(),n,!1)}const o=r()(e.inputParams.values()).filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME));for(const i of o){const s=e.inputs[i.name];yield t.dapi.permissions.grant(s.getTableInfo(),n,!1)}const a=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunAddToShared.next(a),a}))}removeRunFromShared(e){return X(this,void 0,void 0,(function*(){e.options.isShared=!1,this.beforeRunRemoveFromShared.next(e);const n=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunRemoveFromShared.next(n),n}))}get root(){return this._root}}var it;!function(t){t.fileInput=function(t="Drag-n-drop here",e=null,n=null,i=N){return new D(t,e,n,i)},t.historyInput=function(t,e,n,i,s=[],o=!0){return new G(t,e,n,i,s,o)},t.historyPanel=function(t){return new nt(t)}}(it||(it={}));const st={barchart:s.VIEWER.BAR_CHART,boxplot:s.VIEWER.BOX_PLOT,calendar:s.VIEWER.CALENDAR,corrplot:s.VIEWER.CORR_PLOT,densityplot:s.VIEWER.DENSITY_PLOT,filters:s.VIEWER.FILTERS,form:s.VIEWER.FORM,globe:s.VIEWER.GLOBE,googlemap:s.VIEWER.GOOGLE_MAP,grid:s.VIEWER.GRID,heatmap:s.VIEWER.HEAT_MAP,histogram:s.VIEWER.HISTOGRAM,linechart:s.VIEWER.LINE_CHART,markup:s.VIEWER.MARKUP,matrixplot:s.VIEWER.MATRIX_PLOT,networkdiagram:s.VIEWER.NETWORK_DIAGRAM,pcplot:s.VIEWER.PC_PLOT,piechart:s.VIEWER.PIE_CHART,scatterplot:s.VIEWER.SCATTER_PLOT,"3dscatterplot":s.VIEWER.SCATTER_PLOT_3D,shapemap:s.VIEWER.SHAPE_MAP,statistics:s.VIEWER.STATISTICS,tileviewer:s.VIEWER.TILE_VIEWER,timelines:s.VIEWER.TIMELINES,treemap:s.VIEWER.TREE_MAP,trellisplot:s.VIEWER.TRELLIS_PLOT,wordcloud:s.VIEWER.WORD_CLOUD},ot="JsCardView",rt="viewer";var at;!function(t){t.INPUT="Input",t.OUTPUT="Output"}(at||(at={}));const lt="experimental",ut="Run name",ct="RunId";var dt,pt,ht,mt;(mt=dt||(dt={})).HIDDEN="hidden",mt.VISIBLE="visible",(ht=pt||(pt={})).ENABLED="enabled",ht.DISABLED="disabled";var ft=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const vt=t=>t.options.getRealData,gt=t=>{const e=t.options[rt];return void 0!==e?{name:t.name,config:JSON.parse(e,((t,e)=>{if("true"===e)return!0;if("false"===e)return!1;if("type"===t)return st[e]||e;if(!t.toLowerCase().includes("color")){const t=Number.parseFloat(e);if(!Number.isNaN(t))return t}return e}))}:{name:t.name,config:[]}},yt=(n,i,o={parentView:void 0,parentCall:void 0})=>{var r,a;const l=i,u=[...l.inputs,...l.outputs].map((t=>gt(t))).reduce(((t,e)=>(t[e.name]?t[e.name].push(...e.config):t[e.name]=e.config,t)),{}),c=t=>{var e;if(t.propertyType===s.TYPE.DATA_FRAME){const e=u[t.name].map((e=>{var i;let o=null!==(i=t.caption)&&void 0!==i?i:t.name;const r=s.Column.fromType(s.TYPE.DATA_FRAME,o,n.length);r.init((e=>{var i;return null!==(i=n[e].inputs[t.name])&&void 0!==i?i:n[e].outputs[t.name]}));const a=d.columns.getUnusedName(r.name);return r.name=a,o=a,r.temp[rt]=e,d.columns.add(r),r}));return e}{let i=null!==(e=t.caption)&&void 0!==e?e:t.name;const o=s.Column.fromType(t.propertyType,i,n.length);o.init((e=>{var i;return null!==(i=n[e].inputs[t.name])&&void 0!==i?i:n[e].outputs[t.name]}));const r=d.columns.getUnusedName(o.name);return o.name=r,i=r,d.columns.add(o),[o]}},d=s.DataFrame.create(n.length),h=[];return n.forEach((t=>{var e;let n=null!==(e=t.options.title)&&void 0!==e?e:`${t.func.name} - ${new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}`,i=2;for(;h.includes(n);)n=`${t.func.name} - ${new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})} - ${i}`,i++;h.push(n)})),d.columns.add(s.Column.fromStrings(ut,h)),d.name=(null===(r=o.parentCall)||void 0===r?void 0:r.func.name)?`${null===(a=o.parentCall)||void 0===a?void 0:a.func.name} - comparison`:`${i.name} - comparison`,l.inputs.forEach((t=>c(t))),l.outputs.forEach((t=>c(t))),t.events.onCurrentObjectChanged.subscribe((({sender:n})=>{if(n instanceof s.Column&&n.type===s.TYPE.DATA_FRAME&&t.shell.tv&&t.shell.tv.temp.isComparison&&[s.VIEWER.LINE_CHART,s.VIEWER.SCATTER_PLOT,s.VIEWER.HISTOGRAM,s.VIEWER.BOX_PLOT].includes(n.temp[rt].type)){t.shell.windows.showProperties=!0;const i=t=>{const e=t.get(0).clone();e.columns.addNew(ct,s.TYPE.STRING).init(t.dataFrame.get(ut,0));for(let n=1;n<t.length;n++){const i=t.get(n).clone();i.columns.addNew(ct,s.TYPE.STRING).init(t.dataFrame.get(ut,n));const o=[s.COLUMN_TYPE.INT,s.COLUMN_TYPE.FLOAT];for(let t=0;t<i.columns.length;t++){const n=i.columns.byIndex(t),r=e.columns.byIndex(t);n.type!==r.type&&o.includes(n.type)&&o.includes(r.type)&&(n.type!==s.COLUMN_TYPE.FLOAT&&i.columns.replace(n,n.convertTo(s.COLUMN_TYPE.FLOAT)),r.type!==s.COLUMN_TYPE.FLOAT&&e.columns.replace(r,r.convertTo(s.COLUMN_TYPE.FLOAT)))}e.append(i,!0)}return e},o=n.temp[rt].look;setTimeout((()=>{switch(n.temp[rt].type){case s.VIEWER.LINE_CHART:const r=e.waitBox((()=>ft(void 0,void 0,void 0,(function*(){var t;const e=null!==(t=n.temp.unitedDf)&&void 0!==t?t:i(n);return n.temp.unitedDf=e,e.plot.line(Object.assign(Object.assign({},o),{split:ct})).root}))));p()(r).css({width:"100%"}),t.shell.o=r;break;case s.VIEWER.SCATTER_PLOT:const a=e.waitBox((()=>ft(void 0,void 0,void 0,(function*(){var t;const e=null!==(t=n.temp.unitedDf)&&void 0!==t?t:i(n);return n.temp.unitedDf=e,e.plot.scatter(Object.assign(Object.assign({},o),{color:ct})).root}))));t.shell.o=a,p()(a).css({width:"100%"});break;case s.VIEWER.HISTOGRAM:const l=e.waitBox((()=>ft(void 0,void 0,void 0,(function*(){var t;const e=null!==(t=n.temp.unitedDf)&&void 0!==t?t:i(n);return n.temp.unitedDf=e,e.plot.histogram(Object.assign(Object.assign({},o),{split:ct})).root}))));t.shell.o=l,p()(l).css({width:"100%"});break;case s.VIEWER.BOX_PLOT:const u=e.waitBox((()=>ft(void 0,void 0,void 0,(function*(){var t;const e=null!==(t=n.temp.unitedDf)&&void 0!==t?t:i(n);return n.temp.unitedDf=e,e.plot.box(Object.assign(Object.assign({},o),{category:ct})).root}))));t.shell.o=u,p()(u).css({width:"100%"})}}))}})),d};var At=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const bt=window;class wt extends s.TableView{static fromComparedRuns(e,n,i={parentView:void 0,parentCall:void 0}){return At(this,void 0,void 0,(function*(){const s=yt(e,n,i),o=[...t.shell.views].find((t=>t.type===ot||"scripts"===t.type||"functions"===t.type));o&&(t.shell.v=o);const r=new this(s,i),a=n.options.comparator;return setTimeout((()=>At(this,void 0,void 0,(function*(){r.defaultCustomize(),a&&(yield t.functions.call(a,{comparisonView:r}))}))),0),r}))}constructor(e,n={}){super(bt.grok_TableView(e.dart,!1)),n.parentView&&(this.parentView=n.parentView),this.parentCall=n.parentCall||t.functions.getCurrentCall()}defaultCustomize(){var t;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(ut).width=70;for(let e=0;e<this.grid.columns.length;e++){const n=this.grid.columns.byIndex(e);(null===(t=n.column)||void 0===t?void 0:t.temp[rt])&&(n.width=350,n.cellType="html")}this.grid.onCellPrepare((t=>{if(!t.isColHeader&&!t.isRowHeader&&(t.tableColumn.name===ut&&(t.style.textVertical=!0),t.tableColumn&&t.tableColumn.temp[rt])){const n=t.cell.value,i=t.tableColumn.temp[rt],o=i.type;t.element=e.waitBox((()=>At(this,void 0,void 0,(function*(){const e=Object.values(st).includes(o)?s.Viewer.fromType(o,n):yield n.plot.fromType(o);return t.tableColumn.temp[rt].look?e.setOptions(t.tableColumn.temp[rt].look):(e.setOptions(i),t.tableColumn.temp[rt]=e.getOptions()),e.root})))),t.element.style.width="100%",t.element.style.height="100%"}}))}}var Ct=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const Tt=new URL(t.shell.startUri);class It extends s.ViewBase{constructor(t,n={historyEnabled:!0,isTabbed:!1}){super(),this.initValue=t,this.options=n,this._type="function",this.funcCallReplaced=new f.Subject,this.exportConfig=null,this.historyBlock=null,this.isHistorical=new f.BehaviorSubject(!1),this.historyRoot=e.divV([],{style:{"justify-content":"center"}}),this.defaultExportFilename=t=>`${this.name} - ${(new Date).toLocaleString("en-US").replaceAll(/:|\//g,"-")}.${this.exportConfig.supportedExtensions[t]}`,this.defaultSupportedExportExtensions=()=>({Excel:"xlsx"}),this.defaultSupportedExportFormats=()=>["Excel"],this.box=!0,this.init()}onFuncCallReady(){return Ct(this,void 0,void 0,(function*(){this.options.isTabbed||this.changeViewName(this.funcCall.func.friendlyName),yield y.augmentCallWithFunc(this.funcCall),this.build(),this.getStartId()&&!this.options.isTabbed&&(e.setUpdateIndicator(this.root,!0),this.loadRun(this.funcCall.id),e.setUpdateIndicator(this.root,!1),this.setAsLoaded());const t=this.isHistorical.subscribe((t=>{var e,n;if(!this.options.isTabbed&&this.func)if(t){this.path=`?id=${this.funcCall.id}`;const t=new Date(this.funcCall.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"});this.name.indexOf(" — ")<0?this.changeViewName(`${this.name} — ${null!==(e=this.funcCall.options.title)&&void 0!==e?e:t}`):this.changeViewName(`${this.name.substring(0,this.name.indexOf(" — "))} — ${null!==(n=this.funcCall.options.title)&&void 0!==n?n:t}`)}else this.path="",this.changeViewName(`${this.name.substring(0,this.name.indexOf(" — ")>0?this.name.indexOf(" — "):void 0)}`)}));this.subs.push(t)}))}changeViewName(t){var n;this.name=t,null===(n=document.querySelector("div.d4-ribbon-name"))||void 0===n||n.replaceChildren(e.span([t]))}getStartId(){return t.shell.getVar("isLoaded")?void 0:Tt.searchParams.get("id")}setAsLoaded(){return t.shell.setVar("isLoaded",!0)}get funcCall(){return this._funcCall}get func(){var t;return null===(t=this.funcCall)||void 0===t?void 0:t.func}get lastCall(){return this._lastCall}set lastCall(t){this._lastCall=t}get type(){return this._type}linkFunccall(t){this._funcCall=t,this.funcCallReplaced.next(!0)}loadFuncCallById(){return Ct(this,void 0,void 0,(function*(){if(this.initValue instanceof s.FuncCall)return yield new Promise((t=>setTimeout(t,0))),void this.linkFunccall(this.initValue);e.setUpdateIndicator(this.root,!0);const n=this.getStartId();if(n&&!this.options.isTabbed)this.linkFunccall(yield y.loadRun(n));else{const e=yield t.functions.eval(this.initValue);this.linkFunccall(e.prepare({}))}e.setUpdateIndicator(this.root,!1)}))}init(){return Ct(this,void 0,void 0,(function*(){yield this.loadFuncCallById(),yield this.onFuncCallReady()}))}build(){e.empty(this.root),this.root.appendChild(this.buildIO()),this.options.historyEnabled&&this.buildHistoryBlock(),this.buildRibbonMenu(),this.buildRibbonPanels()}onComparisonLaunch(e){return Ct(this,void 0,void 0,(function*(){const n=t.shell.v.parentCall,i=yield Promise.all(e.map((t=>y.loadRun(t)))),s=[...t.shell.views].find((t=>t.type===ot)),o=yield wt.fromComparedRuns(i,this.func,{parentView:s,parentCall:n});t.shell.addView(o)}))}buildHistoryBlock(){const n=it.historyPanel(this.func);return this.subs.push(n.onRunChosen.subscribe((t=>Ct(this,void 0,void 0,(function*(){e.setUpdateIndicator(this.root,!0),yield this.loadRun(t),e.setUpdateIndicator(this.root,!1)})))),n.onComparison.subscribe((t=>Ct(this,void 0,void 0,(function*(){return this.onComparisonLaunch(t)})))),t.events.onCurrentViewChanged.subscribe((()=>{t.shell.v===this&&setTimeout((()=>{t.shell.o=this.historyRoot}))}))),e.empty(this.historyRoot),this.historyRoot.style.removeProperty("justify-content"),this.historyRoot.style.width="100%",this.historyRoot.append(n.root),t.shell.o=this.historyRoot,this.historyBlock=n,n.root}buildRibbonPanels(){const n=e.iconFA("history",(()=>{t.shell.windows.showProperties=!t.shell.windows.showProperties,n.classList.toggle("d4-current"),t.shell.o=this.historyRoot}));n.classList.add("d4-toggle-button"),t.shell.windows.showProperties&&n.classList.add("d4-current");const i=e.comboPopup(e.iconFA("arrow-to-bottom"),this.exportConfig.supportedFormats,(t=>Ct(this,void 0,void 0,(function*(){return s.Utils.download(this.exportConfig.filename(t),yield this.exportConfig.export(t))})))),o=e.iconFA("edit",(()=>{this.historyBlock&&this.lastCall&&this.historyBlock.showEditDialog(this.lastCall)}),"Edit this run"),r=this.isHistorical.subscribe((t=>{t?(p()(i).show(),p()(o).show()):(p()(i).hide(),p()(o).hide())}));this.subs.push(r);const a=[[...this.options.historyEnabled?[n]:[],...this.exportConfig&&this.exportConfig.supportedFormats.length>0?[i]:[],o]];return this.setRibbonPanels(a),a}buildRibbonMenu(){}onBeforeSaveRun(t){return Ct(this,void 0,void 0,(function*(){}))}onAfterSaveRun(t){return Ct(this,void 0,void 0,(function*(){}))}saveRun(t){return Ct(this,void 0,void 0,(function*(){yield this.onBeforeSaveRun(t);const e=yield y.saveRun(t);return this.linkFunccall(e),this.options.historyEnabled&&this.buildHistoryBlock(),this.isHistorical.next(!0),yield this.onAfterSaveRun(e),e}))}onBeforeDeleteRun(t){return Ct(this,void 0,void 0,(function*(){}))}onAfterDeleteRun(t){return Ct(this,void 0,void 0,(function*(){}))}deleteRun(t){return Ct(this,void 0,void 0,(function*(){return yield this.onBeforeDeleteRun(t),yield y.deleteRun(t),yield this.onAfterDeleteRun(t),t.id}))}onBeforeLoadRun(){return Ct(this,void 0,void 0,(function*(){}))}onAfterLoadRun(t){return Ct(this,void 0,void 0,(function*(){}))}loadRun(t){return Ct(this,void 0,void 0,(function*(){yield this.onBeforeLoadRun();const e=yield y.loadRun(t);return this.lastCall=e,this.linkFunccall(e),this.isHistorical.next(!0),yield this.onAfterLoadRun(e),e}))}onBeforeRun(t){return Ct(this,void 0,void 0,(function*(){}))}onAfterRun(t){return Ct(this,void 0,void 0,(function*(){}))}run(){return Ct(this,void 0,void 0,(function*(){if(!this.funcCall)throw new Error("The correspoding function is not specified");yield this.onBeforeRun(this.funcCall);const e=s.TaskBarProgressIndicator.create("Calculating...");this.funcCall.newId();try{yield this.funcCall.call(),yield this.onAfterRun(this.funcCall),this.lastCall=this.options.isTabbed||this.runningOnInput||this.runningOnStart?(t=>{const e=t.clone(),n=r()(t.outputParams.values()).filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME));for(const i of n)e.outputs[i.name]=t.outputs[i.name].clone();const i=r()(t.inputParams.values()).filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME));for(const n of i)e.inputs[n.name]=t.inputs[n.name].clone();return e})(this.funcCall):yield this.saveRun(this.funcCall)}catch(e){t.shell.error(e.toString())}finally{e.close()}}))}get hasUploadMode(){return"true"===this.func.options.uploadMode}get runningOnInput(){return"true"===this.func.options.runOnInput}get runningOnStart(){return"true"===this.func.options.runOnOpen}}var xt=n(903),Et={};Et.styleTagTransform=V(),Et.setAttributes=P(),Et.insert=S().bind(null,"head"),Et.domAPI=E(),Et.insertStyleElement=B(),I()(xt.Z,Et),xt.Z&&xt.Z.locals&&xt.Z.locals;const Rt=html2canvas;var St=n.n(Rt),Ft=n(751),Pt={};Pt.styleTagTransform=V(),Pt.setAttributes=P(),Pt.insert=S().bind(null,"head"),Pt.domAPI=E(),Pt.insertStyleElement=B(),I()(Ft.Z,Pt),Ft.Z&&Ft.Z.locals&&Ft.Z.locals;var Ot,Bt;!function(t){t.INCORRECT_SIZE_TYPE="Size must be an integer.",t.SIZE_MUST_BE_POSITIVE="Size must be positive."}(Ot||(Ot={})),function(t){t[t.BATCH_SIZE=100]="BATCH_SIZE",t[t.MS_TO_SLEEP=10]="MS_TO_SLEEP"}(Bt||(Bt={}));const kt=t=>new Promise(((e,n)=>setTimeout(e,t)));function Vt(t){if(!Number.isInteger(t))throw new Error(Ot.INCORRECT_SIZE_TYPE);if(t<1)throw new Error(Ot.SIZE_MUST_BE_POSITIVE)}function Mt(t){return e=this,n=void 0,o=function*(){const e=[],n=s.TaskBarProgressIndicator.create("Running sensitivity analysis...");n.cancelable=!0;let i=0;const o=t.length;for(let s=0;s<o&&(e.push(yield t[s].call()),1===s&&(n.update(100*s/o,"Running sensitivity analysis..."),yield kt(10*Bt.MS_TO_SLEEP)),++i,!n.canceled);++s)i>=Bt.BATCH_SIZE&&(n.update(100*s/o,"Running sensitivity analysis..."),yield kt(Bt.MS_TO_SLEEP),i=0);return n.close(),e},new((i=void 0)||(i=Promise))((function(t,s){function r(t){try{l(o.next(t))}catch(t){s(t)}}function a(t){try{l(o.throw(t))}catch(t){s(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(r,a)}l((o=o.apply(e,n||[])).next())}));var e,n,i,o}class Lt{constructor(t=1,e=1){Vt(t),Vt(e),this.N=t,this.d=e,this.A=this.generateMatrix(t,e),this.B=this.generateMatrix(t,e),this.AB=this.createMixMatrax(this.A,this.B)}generateMatrix(t,e){const n=new Array(e);for(let i=0;i<e;++i){n[i]=new Float32Array(t);for(let e=0;e<t;++e)n[i][e]=Math.random()}return n}createMixMatrax(t,e){const n=this.d,i=new Array(n);for(let s=0;s<n;++s){i[s]=new Array(0);for(let o=0;o<n;++o)s!==o?i[s].push(t[o]):i[s].push(e[o])}return i}getRow(t,e){const n=new Float32Array(this.d);for(let i=0;i<this.d;++i)n[i]=t[i][e];return n}getRowOfMatrixA(t){return this.getRow(this.A,t)}getRowOfMatrixB(t){return this.getRow(this.B,t)}getRowOfMatrixAB(t,e){return this.getRow(this.AB[t],e)}getConcatenatedColumns(){const t=new Array(0),e=this.N,n=this.d;for(let i=0;i<n;++i){const s=new Float32Array(e*(n+2));s.set(this.A[i]),s.set(this.B[i],e);for(let t=0;t<n;++t)s.set(this.AB[t][i],2*e+e*t);t.push(s)}return t}}const _t="Unsupported output type.",Nt="Incorrect row number.";function Dt(t,e){const n=t.rowCount;let i=0;if(e>=1&&e<=n)i=e-1;else{if(-1!=e)throw new Error(Nt);i=n-1}return t.columns.names().map((t=>({idx:i,columnName:t})))}function jt(t,e){var n,i,o;if(t.length<1)throw new Error("Funccall array is empty.");const r=t.length,a=function(t,e){const n=[];for(const i of e)i.prop.propertyType==s.TYPE.DATA_FRAME?n.push({prop:i.prop,elements:Dt(t.outputs[i.prop.name],i.row),row:i.row}):n.push(i);return n}(t[0],e),l=function(t,e,n){var i;const o=[];for(const r of e){const e=r.prop,a=e.name;switch(e.propertyType){case s.TYPE.BIG_INT:case s.TYPE.INT:case s.TYPE.FLOAT:o.push(s.Column.fromType(e.propertyType,a,n));break;case s.TYPE.DATA_FRAME:const l=t.outputs[a];if(r.elements)for(const t of r.elements)o.push(s.Column.fromType(null===(i=l.col(t.columnName))||void 0===i?void 0:i.type,t.columnName,n));break;default:throw new Error(_t)}}return s.DataFrame.fromColumns(o)}(t[0],a,r);for(let e=0;e<r;++e)for(const r of a){const a=r.prop,u=a.name,c=t[e];switch(a.propertyType){case s.TYPE.BIG_INT:case s.TYPE.INT:case s.TYPE.FLOAT:null===(n=l.col(u))||void 0===n||n.set(e,c.outputs[u]);break;case s.TYPE.DATA_FRAME:const t=c.outputs[u];if(r.elements)for(const n of r.elements)null===(i=l.col(n.columnName))||void 0===i||i.set(e,null===(o=t.col(n.columnName))||void 0===o?void 0:o.get(n.idx));break;default:throw new Error(_t)}}return l}var Yt=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class Ht{constructor(t,e,n,i,o){Vt(o),this.samplesCount=o,this.fixedInputs=e,this.func=t;const r=function(t,e){const n=e.length,i=function(t,e){return new Lt(t,e).getConcatenatedColumns()}(t,n);return[...Array(n).keys()].map((t=>function(t,e){var n;const i=e.length,o=s.Column.fromType(t.prop.propertyType,null!==(n=t.prop.caption)&&void 0!==n?n:t.prop.name,i),r=o.getRawData(),a=t.max-t.min;for(let n=0;n<i;++n)r[n]=t.min+a*e[n];return o}(e[t],i[t])))}(o,n);this.dimension=n.length,this.variedInputs=[...Array(this.dimension).keys()].map((t=>({prop:n[t].prop,min:n[t].min,max:n[t].max,column:r[t]}))),this.runsCount=o*(this.dimension+2),this.funcCalls=[];for(let n=0;n<this.runsCount;++n){const i={};for(const t of e)i[t.name]=t.value;for(const t of this.variedInputs)i[t.prop.name]=t.column.get(n);this.funcCalls.push(t.prepare(i))}this.outputInfo=i.map((t=>({prop:t.prop,elements:[],row:t.value.row})))}run(){return Yt(this,void 0,void 0,(function*(){yield Promise.all(this.funcCalls.map((t=>t.call())))}))}getSobolIndeces(t){const e=this.dimension,n=this.samplesCount,i=new Float32Array(e),o=new Float32Array(e),r=t.getRawData(),a=2*n;let l=0,u=0;for(let t=0;t<a;++t)l+=r[t],u+=r[t]*r[t];const c=l/a,d=u/a-c*c;if(0===d)i.fill(0),o.fill(0);else for(let t=0;t<e;++t){let e=0,s=0,a=0;for(let i=0;i<n;++i)a=r[(2+t)*n+i]-r[i],e+=r[n+i]*a,s+=a*a;i[t]=e/(n*d),o[t]=s/(2*n*d)}return{firstOrder:s.Column.fromFloat32Array(t.name,i),totalOrder:s.Column.fromFloat32Array(t.name,o)}}perform(){return Yt(this,void 0,void 0,(function*(){this.funcCalls=yield Mt(this.funcCalls);const t=this.variedInputs.map((t=>t.column)),e=s.DataFrame.fromColumns(t);e.name=`Sensitivity Analysis of ${this.func.friendlyName}`;const n=jt(this.funcCalls,this.outputInfo).columns.toList();for(const t of n)e.columns.add(t);const i=n.map((t=>this.getSobolIndeces(t))),o=s.Column.fromStrings("input",t.map((t=>t.name))),r=[o],a=[o];for(const t of i)r.push(t.firstOrder),a.push(t.totalOrder);const l=s.DataFrame.fromColumns(r);l.name="First order Sobol' indices";const u=s.DataFrame.fromColumns(a);return u.name="Total order Sobol' indices",{funcEvalResults:e,funcCalls:this.funcCalls,firstOrderSobolIndices:l,totalOrderSobolIndices:u}}))}}var Wt=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class $t{constructor(t,e,n,i,o){Vt(o),this.func=t;const r=function(t,e){var n;const i=[];for(const o of e){const e=s.Column.fromType(o.prop.propertyType,null!==(n=o.prop.caption)&&void 0!==n?n:o.prop.name,t),r=e.getRawData(),a=o.max-o.min;for(let e=0;e<t;++e)r[e]=o.min+a*Math.random();i.push(e)}return i}(o,n);this.dimension=n.length,this.variedInputs=[...Array(this.dimension).keys()].map((t=>({prop:n[t].prop,min:n[t].min,max:n[t].max,column:r[t]}))),this.funcCalls=[];for(let n=0;n<o;++n){const i={};for(const t of e)i[t.name]=t.value;for(const t of this.variedInputs)i[t.prop.name]=t.column.get(n);this.funcCalls.push(t.prepare(i))}this.outputInfo=i.map((t=>({prop:t.prop,elements:[],row:t.value.row})))}run(){return Wt(this,void 0,void 0,(function*(){yield Promise.all(this.funcCalls.map((t=>t.call())))}))}perform(){return Wt(this,void 0,void 0,(function*(){this.funcCalls=yield Mt(this.funcCalls);const t=this.variedInputs.map((t=>t.column)),e=s.DataFrame.fromColumns(t);e.name=`Sensitivity Analysis of ${this.func.friendlyName}`;const n=jt(this.funcCalls,this.outputInfo).columns.toList();for(const t of n)e.columns.add(t);return{funcEvalResults:e,funcCalls:this.funcCalls}}))}}var Ut=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const Gt="Run name";var zt;!function(t){t.UNIFORM="Uniform",t.NORMAL="Normal",t.RANDOM="Random"}(zt||(zt={}));const Zt=[zt.UNIFORM];var qt,Jt;!function(t){t.GRID_ANALYSIS="Grid",t.RANDOM_ANALYSIS="Monte Carlo",t.SOBOL_ANALYSIS="Sobol"}(qt||(qt={})),function(t){t.LAST_ROW="Last row",t.FIRST_ROW="First row",t.ALL_COLUMNS="All"}(Jt||(Jt={}));class Xt{static fromEmpty(e,n={parentView:void 0,parentCall:void 0}){return Ut(this,void 0,void 0,(function*(){const i=[...t.shell.views].find((t=>t.type===ot)),s=yield wt.fromComparedRuns([],e,{parentView:i,parentCall:n.parentCall});t.shell.addView(s),new this(e,s,n)}))}constructor(t,n,i={parentView:void 0,parentCall:void 0,configFunc:void 0}){this.func=t,this.options=i,this.generateInputFields=t=>{const n={analysisType:{input:e.choiceInput("Method",qt.GRID_ANALYSIS,[qt.GRID_ANALYSIS,qt.RANDOM_ANALYSIS,qt.SOBOL_ANALYSIS],(t=>{n.analysisType.value.next(t),this.updateRunButtonText()})),value:new f.BehaviorSubject(qt.GRID_ANALYSIS)},samplesCount:{input:e.intInput("Samples",100,(t=>{n.samplesCount.value=t,this.updateRunButtonText()})),value:100}},i=(t,e)=>void 0===t.options[e]?t.defaultValue:Number(t.options[e]),o=t.inputs.reduce(((t,o)=>{var r,a;switch(o.propertyType){case s.TYPE.INT:case s.TYPE.BIG_INT:case s.TYPE.FLOAT:const l={type:o.propertyType,prop:o,const:{input:o.propertyType===s.TYPE.FLOAT?e.floatInput(`${null!==(r=o.caption)&&void 0!==r?r:o.name}`,o.defaultValue,(t=>c.const.value=t)):e.intInput(`${null!==(a=o.caption)&&void 0!==a?a:o.name}`,o.defaultValue,(t=>c.const.value=t)),value:o.defaultValue},min:{input:(()=>{var t,n;const r=o.propertyType===s.TYPE.FLOAT?e.floatInput(`${null!==(t=o.caption)&&void 0!==t?t:o.name}`,i(o,"min"),(t=>c.min.value=t)):e.intInput(`${null!==(n=o.caption)&&void 0!==n?n:o.name}`,i(o,"min"),(t=>c.min.value=t));return r.input.placeholder="Min",p()(r.input).css({"padding-right":"0px","margin-right":"4px"}),r})(),value:i(o,"min")},max:{input:(()=>{const t=o.propertyType===s.TYPE.FLOAT?e.floatInput(" ",i(o,"max"),(t=>c.max.value=t)):e.intInput(" ",i(o,"max"),(t=>c.max.value=t));return t.input.placeholder="Max",p()(t.input).css({"padding-left":"0px","margin-left":"4px"}),t})(),value:i(o,"max")},lvl:{input:e.intInput("Samples",3,(t=>{c.lvl.value=t,this.updateRunButtonText()})),value:3},distrib:{input:e.choiceInput("Grid",Zt[0],Zt,(t=>c.distrib.value=t)),value:o.defaultValue},isChanging:{input:(()=>{const t=e.switchInput(" ",!1,(t=>{c.isChanging.value.next(t),this.updateRunButtonText()}));return p()(t.root).css({"min-width":"50px",width:"50px"}),p()(t.captionLabel).css({"min-width":"0px","max-width":"0px"}),t})(),value:new f.BehaviorSubject(!1)}};l.min.input.root.append(l.max.input.input);const u=[l.lvl.input,l.distrib.input];t[o.name]=Object.assign(Object.assign({},l),{constForm:e.form([l.const.input],{style:{flexGrow:"1"}}),saForm:e.form([l.min.input,...u],{style:{flexGrow:"1"}})});const c=t[o.name];(0,f.combineLatest)([l.isChanging.value,n.analysisType.value]).subscribe((([t,e])=>{t?(p()(c.constForm).hide(),e===qt.GRID_ANALYSIS?(p()(c.saForm).show(),u.forEach((t=>p()(t.root).show()))):(p()(c.saForm).show(),u.forEach((t=>p()(t.root).hide())))):(p()(c.constForm).show(),p()(c.saForm).hide())}));break;case s.TYPE.BOOL:const d={type:o.propertyType,prop:o,const:{input:e.boolInput(" ",!1,(t=>c.const.value=t)),value:!1},isChanging:{input:e.switchInput("Is changing",!1,(t=>c.isChanging.value.next(t))),value:new f.BehaviorSubject(!1)}};t[o.name]=Object.assign(Object.assign({},d),{constForm:e.form([d.const.input],{style:{flexGrow:"1"}}),saForm:e.form([d.const.input],{style:{flexGrow:"1"}})});break;default:t[o.name]={const:{input:e.input.forProperty(o,void 0,{onValueChanged:t=>c.const.value=t}),value:o.defaultValue},type:o.propertyType,prop:o}}return t}),{}),r=t.outputs.reduce(((t,n)=>{const i={prop:n,input:(()=>{var t,o;const r=n.propertyType===s.TYPE.DATA_FRAME?e.choiceInput(null!==(t=n.caption)&&void 0!==t?t:n.name,Jt.LAST_ROW,[Jt.LAST_ROW,Jt.FIRST_ROW],(t=>{i.value.returning=t})):e.input.forProperty(n);return r.captionLabel.firstChild.replaceWith(e.span([null!==(o=n.caption)&&void 0!==o?o:n.name])),r})(),analysisInputs:n.propertyType===s.TYPE.DATA_FRAME?[e.stringInput("Column",Jt.ALL_COLUMNS,(t=>{i.value.colName=t}))]:[],value:{returning:Jt.LAST_ROW,colName:Jt.ALL_COLUMNS},isInterest:{input:(()=>{const t=e.switchInput(" ",n.propertyType!==s.TYPE.DATA_FRAME,(t=>{i.isInterest.value.next(t),this.updateRunButtonText()}));return p()(t.root).css({"min-width":"50px",width:"50px"}),p()(t.captionLabel).css({"min-width":"0px","max-width":"0px"}),t})(),value:new f.BehaviorSubject(n.propertyType!==s.TYPE.DATA_FRAME)}};switch(p()(i.input.input).hide(),i.prop.propertyType===s.TYPE.DATA_FRAME&&i.isInterest.value.subscribe((t=>{t?(i.analysisInputs.forEach((t=>p()(t.root).show())),p()(i.input.input).show()):(i.analysisInputs.forEach((t=>p()(t.root).hide())),p()(i.input.input).hide())})),n.propertyType){case s.TYPE.INT:case s.TYPE.BIG_INT:case s.TYPE.FLOAT:case s.TYPE.BOOL:case s.TYPE.DATA_FRAME:break;default:p()(i.isInterest.input.root).css({visibility:"hidden"})}return t[n.name]=i,t}),{});return{analysisInputs:n,inputs:o,outputs:r}},this.openedViewers=[],this.store=this.generateInputFields(this.func),this.runButton=this.buildRunButton();const o=this.buildFormWithBtn();this.addTooltips(),this.comparisonView=n,this.comparisonView.dockManager.dock(o,s.DOCK_TYPE.LEFT,null,`${this.func.name} - Sensitivity Analysis`,.25),this.comparisonView.grid.columns.byName(Gt).visible=!1}closeOpenedViewers(){for(const t of this.openedViewers)t.close();this.openedViewers.splice(0)}getFuncCallCount(t,e){let n=0;switch(t.analysisType.value.value){case qt.GRID_ANALYSIS:let i=1;for(const t of Object.keys(e))e[t].isChanging.value.value&&(i*=e[t].lvl.value,++n);return 0===n?0:i;case qt.RANDOM_ANALYSIS:return t.samplesCount.value;case qt.SOBOL_ANALYSIS:for(const t of Object.keys(e))e[t].isChanging.value.value&&++n;return 0===n?0:(n+2)*t.samplesCount.value;default:return 0}}getFuncCallCountAsString(){if(!this.canEvaluationBeRun())return"0";const t=this.getFuncCallCount(this.store.analysisInputs,this.store.inputs);return t<1e3?String(t):t<1e6?String(Math.ceil(t/10)/100)+"k":t<1e9?String(Math.ceil(t/1e4)/100)+"m":String(Math.ceil(t/1e7)/100)+"b"}updateRunButtonText(){this.runButton.textContent=`Run (${this.getFuncCallCountAsString()})`}buildFormWithBtn(){let t="Misc";const n=Object.values(this.store.inputs).reduce((({container:n,switches:i},s)=>{const o=s.prop;o.category!==t&&(n.append(e.h2(o.category)),t=o.category);const r=e.divH([e.form([s.isChanging.input]),s.constForm,s.saForm],"ui-form ui-form-wide");return p()(r).removeClass("ui-div"),n.appendChild(r),{container:n,switches:i}}),{container:e.form([this.store.analysisInputs.analysisType.input,this.store.analysisInputs.samplesCount.input],"ui-form-wide"),switches:[]}),i=e.h2("Outputs");n.container.appendChild(i),t="Misc";const s=Object.values(this.store.outputs).reduce((({container:n,switches:i},s)=>{const o=s.prop;o.category!==t&&(n.append(e.h2(o.category)),t=o.category);const r=e.divH([e.form([s.isInterest.input]),e.form([s.input,...s.analysisInputs],{style:{flexGrow:"1"}})],"ui-form ui-form-wide");return p()(r).removeClass("ui-div"),n.appendChild(r),{container:n,switches:i}}),{container:e.form([]),switches:[]});this.store.analysisInputs.analysisType.value.subscribe((t=>{t===qt.GRID_ANALYSIS?p()(this.store.analysisInputs.samplesCount.input.root).hide():(p()(i).show(),p()(s.container).show(),p()(this.store.analysisInputs.samplesCount.input.root).show())}));let o=!1;for(const t of Object.keys(this.store.outputs))if(!0===this.store.outputs[t].isInterest.value.value){o=!0;break}if(!o){const t=this.store.outputs[Object.keys(this.store.outputs)[0]];t.isInterest.value.next(!0),t.isInterest.input.value=!0}this.updateRunButtonText();const r=e.buttonsInput([this.runButton]);return p()(r).css({"align-items":"start"}),n.container.appendChild(s.container),n.container.appendChild(r),p()(n.container).css({"overflow-y":"scroll"}),n.container}addTooltips(){var t;e.tooltip.bind(this.store.analysisInputs.analysisType.input.root,(()=>{switch(this.store.analysisInputs.analysisType.value.value){case qt.GRID_ANALYSIS:return"Grid analysis: the function is evaluated with respect to the selected inputs varying within the specified ranges";case qt.RANDOM_ANALYSIS:return"Monte Carlo simulation: the function is evaluated with respect to random variation of the selected inputs within the specified ranges";case qt.SOBOL_ANALYSIS:return"Variance-based sensitivity analysis: the Sobol' indices are computed";default:return"Unknown method!"}})),e.tooltip.bind(this.runButton,(()=>this.isAnyInputSelected()?this.isAnyOutputSelected()?`Run sensitivity analysis: the function is evaluated ${this.getFuncCallCount(this.store.analysisInputs,this.store.inputs)} times`:"Select output(s) requiring analysis":"Select mutable input(s) to run sensitivity analysis")),e.tooltip.bind(this.store.analysisInputs.samplesCount.input.root,(()=>{switch(this.store.analysisInputs.analysisType.value.value){case qt.RANDOM_ANALYSIS:return"Input parameters sets count";case qt.SOBOL_ANALYSIS:return"Sample size for the Sobol' indices computation";default:return"Unknown method!"}}));for(const n of Object.keys(this.store.inputs)){const i=this.store.inputs[n];e.tooltip.bind(i.isChanging.input.root,(()=>!1===i.isChanging.value.value?"Switch to mark input as mutable":"Switch to mark input as immutable"));const s=null!==(t=i.prop.caption)&&void 0!==t?t:i.prop.name;e.tooltip.bind(i.const.input.root,"Input value"),e.tooltip.bind(i.min.input.root,`Min & Max values of ${s}`),e.tooltip.bind(i.max.input.root,`Min & Max values of ${s}`),e.tooltip.bind(i.lvl.input.root,`Number of samples along the axis ${s}`),e.tooltip.bind(i.distrib.input.root,"Type of grid")}for(const t of Object.keys(this.store.outputs)){const n=this.store.outputs[t];switch(e.tooltip.bind(n.isInterest.input.root,(()=>!1===n.isInterest.value.value?"Switch to mark output as requiring analysis":"Switch to mark output as not requiring analysis")),n.prop.propertyType){case s.TYPE.DATA_FRAME:e.tooltip.bind(n.input.root,(()=>!1===n.isInterest.value.value?"Dataframe":"Specify dataframe part that requires analysis"));break;case s.TYPE.INT:case s.TYPE.FLOAT:case s.TYPE.BIG_INT:e.tooltip.bind(n.input.root,"Scalar")}}}isAnyInputSelected(){for(const t of Object.keys(this.store.inputs))if(!0===this.store.inputs[t].isChanging.value.value)return!0;return!1}isAnyOutputSelected(){for(const t of Object.keys(this.store.outputs))if(!0===this.store.outputs[t].isInterest.value.value)return!0;return!1}canEvaluationBeRun(){return this.isAnyInputSelected()&&this.isAnyOutputSelected()}buildRunButton(){return e.bigButton("Run",(()=>Ut(this,void 0,void 0,(function*(){if(this.canEvaluationBeRun())switch(this.store.analysisInputs.analysisType.value.value){case qt.GRID_ANALYSIS:this.runElementaryAnalysis();break;case qt.RANDOM_ANALYSIS:this.runRandomAnalysis();break;case qt.SOBOL_ANALYSIS:this.runSobolAnalysis()}}))))}getFixedInputColumns(t){return Object.keys(this.store.inputs).filter((t=>{switch(this.store.inputs[t].type){case s.TYPE.INT:case s.TYPE.BIG_INT:case s.TYPE.FLOAT:return!1===this.store.inputs[t].isChanging.value.value;default:return!0}})).map((e=>{var n;return s.Column.fromList(this.store.inputs[e].type,null!==(n=this.store.inputs[e].prop.caption)&&void 0!==n?n:e,Array(t).fill(this.store.inputs[e].const.value))}))}runSobolAnalysis(){return Ut(this,void 0,void 0,(function*(){const n={func:this.func,fixedInputs:Object.keys(this.store.inputs).filter((t=>{switch(this.store.inputs[t].type){case s.TYPE.INT:case s.TYPE.BIG_INT:case s.TYPE.FLOAT:return!1===this.store.inputs[t].isChanging.value.value;default:return!0}})).map((t=>({name:t,value:this.store.inputs[t].const.value}))),variedInputs:Object.keys(this.store.inputs).filter((t=>{switch(this.store.inputs[t].type){case s.TYPE.INT:case s.TYPE.BIG_INT:case s.TYPE.FLOAT:return!0===this.store.inputs[t].isChanging.value.value;default:return!1}})).map((t=>{const e=this.store.inputs[t];return{prop:e.prop,min:e.min.value,max:e.max.value}})),samplesCount:this.store.analysisInputs.samplesCount.value||1},i=[];for(const t of Object.keys(this.store.outputs)){const e=this.store.outputs[t];e.isInterest.value.value&&i.push({prop:e.prop,value:{row:e.value.returning===Jt.LAST_ROW?-1:1,columns:e.value.colName}})}const o=new Ht(n.func,n.fixedInputs,n.variedInputs,i,n.samplesCount),r=yield o.perform();this.closeOpenedViewers();const a=r.funcEvalResults,l=r.funcCalls,u=r.firstOrderSobolIndices,c=r.totalOrderSobolIndices,d=u.columns.names();this.comparisonView.dataFrame=a;const h=a.columns.names(),m=this.getFixedInputColumns(a.rowCount);for(const t of m)a.columns.add(t);a.columns.add(s.Column.fromStrings("ID",l.map((t=>t.id)))),this.comparisonView.grid.columns.setVisible([h[0]]),this.comparisonView.grid.columns.setVisible(h);const f=this.comparisonView.addViewer(s.Viewer.correlationPlot(a));this.comparisonView.dockManager.dock(f,"right",void 0,"",.4),this.openedViewers.push(f);const v=this.getOutputNameForScatterPlot(h,a,n.variedInputs.length);if(1===n.variedInputs.length){const t=this.comparisonView.addViewer(s.Viewer.lineChart(s.DataFrame.fromColumns(a.columns.byNames(h)),{x:h[0],markerSize:1,markerType:"gradient",sharex:!0,multiAxis:!0,multiAxisLegendPosition:"RightCenter"}));this.openedViewers.push(t)}else{const t=this.comparisonView.addViewer(s.Viewer.scatterPlot(a,{x:h[0],y:h[1],color:v,size:v,markerMaxSize:12,jitterSize:5}));this.openedViewers.push(t)}const g=this.comparisonView.addViewer(s.Viewer.barChart(u,{title:u.name,split:d[0],value:v,valueAggrType:"avg"}));this.comparisonView.dockManager.dock(g,"right",void 0,"",.2);const y=this.comparisonView.addViewer(s.Viewer.barChart(c,{title:c.name,split:d[0],value:v,valueAggrType:"avg"}));this.openedViewers=this.openedViewers.concat([g,y]),this.comparisonView.grid.onCellClick.subscribe((n=>{var i;const o=null===(i=n.tableRow)||void 0===i?void 0:i.get("ID"),r=l.find((t=>t.id===o));if(!r)return;const a=[...r.outputParams.values()].filter((t=>s.TYPES_SCALAR.has(t.property.propertyType))),u=s.HtmlTable.create(a,(t=>{var e;return[null!==(e=t.property.caption)&&void 0!==e?e:t.property.name,r.outputs[t.property.name],t.property.options.units]})).root,c=[...r.outputParams.values()].filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME)).reduce(((t,e)=>{var n;const i=gt(e.property).config,o=r.outputs[e.name],a=null!==(n=e.property.caption)&&void 0!==n?n:e.property.name;return i.map((e=>{const n=e.type,i=s.Viewer.fromType(n,o);i.setOptions(e),p()(i.root).css({width:"100%"}),t[a]?t[a].push(i.root):t[a]=[i.root]})),t}),{}),d=Object.assign({"Output scalars":[u]},c),h=e.accordion();p()(h.root).css({width:"100%"}),Object.entries(d).map((t=>{h.addPane(t[0],(()=>e.divV(t[1])))})),this.comparisonView.grid.props.rowHeight=25,t.shell.o=h.root}))}))}runRandomAnalysis(){return Ut(this,void 0,void 0,(function*(){const n={func:this.func,fixedInputs:Object.keys(this.store.inputs).filter((t=>{switch(this.store.inputs[t].type){case s.TYPE.INT:case s.TYPE.BIG_INT:case s.TYPE.FLOAT:return!1===this.store.inputs[t].isChanging.value.value;default:return!0}})).map((t=>({name:t,value:this.store.inputs[t].const.value}))),variedInputs:Object.keys(this.store.inputs).filter((t=>{switch(this.store.inputs[t].type){case s.TYPE.INT:case s.TYPE.BIG_INT:case s.TYPE.FLOAT:return!0===this.store.inputs[t].isChanging.value.value;default:return!1}})).map((t=>{const e=this.store.inputs[t];return{prop:e.prop,min:e.min.value,max:e.max.value}})),samplesCount:this.store.analysisInputs.samplesCount.value||1},i=[];for(const t of Object.keys(this.store.outputs)){const e=this.store.outputs[t];e.isInterest.value.value&&i.push({prop:e.prop,value:{row:e.value.returning===Jt.LAST_ROW?-1:1,columns:e.value.colName}})}const o=new $t(n.func,n.fixedInputs,n.variedInputs,i,n.samplesCount),r=yield o.perform(),a=r.funcEvalResults,l=r.funcCalls;this.closeOpenedViewers(),this.comparisonView.dataFrame=a;const u=a.columns.names(),c=this.getFixedInputColumns(a.rowCount);for(const t of c)a.columns.add(t);a.columns.add(s.Column.fromStrings("ID",l.map((t=>t.id)))),this.comparisonView.grid.columns.setVisible([u[0]]),this.comparisonView.grid.columns.setVisible(u);const d=this.comparisonView.addViewer(s.Viewer.correlationPlot(a));this.comparisonView.dockManager.dock(d,"right",void 0,"",.4),this.openedViewers.push(d),this.comparisonView.grid.props.rowHeight=25;const h=this.getOutputNameForScatterPlot(u,a,n.variedInputs.length);if(1===n.variedInputs.length){const t=this.comparisonView.addViewer(s.Viewer.lineChart(s.DataFrame.fromColumns(a.columns.byNames(u)),{x:u[0],markerSize:1,markerType:"gradient",sharex:!0,multiAxis:!0,multiAxisLegendPosition:"RightCenter"}));this.openedViewers.push(t)}else{const t=this.comparisonView.addViewer(s.Viewer.scatterPlot(a,{x:u[0],y:u[1],color:h,size:h,markerMaxSize:12,jitterSize:5}));this.openedViewers.push(t)}this.comparisonView.grid.onCellClick.subscribe((n=>{var i;const o=null===(i=n.tableRow)||void 0===i?void 0:i.get("ID"),r=l.find((t=>t.id===o));if(!r)return;const a=[...r.outputParams.values()].filter((t=>s.TYPES_SCALAR.has(t.property.propertyType))),u=s.HtmlTable.create(a,(t=>{var e;return[null!==(e=t.property.caption)&&void 0!==e?e:t.property.name,r.outputs[t.property.name],t.property.options.units]})).root,c=[...r.outputParams.values()].filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME)).reduce(((t,e)=>{var n;const i=gt(e.property).config,o=r.outputs[e.name],a=null!==(n=e.property.caption)&&void 0!==n?n:e.property.name;return i.map((e=>{const n=e.type,i=s.Viewer.fromType(n,o);i.setOptions(e),p()(i.root).css({width:"100%"}),t[a]?t[a].push(i.root):t[a]=[i.root]})),t}),{}),d=Object.assign({"Output scalars":[u]},c),h=e.accordion();p()(h.root).css({width:"100%"}),Object.entries(d).map((t=>{h.addPane(t[0],(()=>e.divV(t[1])))})),t.shell.o=h.root}))}))}runSimpleAnalysis(){var t;return Ut(this,void 0,void 0,(function*(){const n=Object.keys(this.store.inputs).reduce(((t,e)=>{switch(this.store.inputs[e].type){case s.TYPE.INT:case s.TYPE.BIG_INT:const n=this.store.inputs[e],i=(n.max.value-n.min.value)/(n.lvl.value-1);t[e]=n.isChanging.value.value?Array.from({length:n.lvl.value},((t,e)=>Math.round(n.min.value+e*i))):[n.const.value];break;case s.TYPE.FLOAT:const o=this.store.inputs[e],r=(o.max.value-o.min.value)/(o.lvl.value-1);t[e]=o.isChanging.value.value?Array.from({length:o.lvl.value},((t,e)=>o.min.value+e*r)):[o.const.value];break;case s.TYPE.BOOL:const a=this.store.inputs[e];t[e]=a.isChanging.value.value?[a.const.value,!a.const.value]:[a.const.value];break;default:const l=this.store.inputs[e];t[e]=[l.const.value]}return t}),{});let i=Object.values(n)[0].map((t=>[t]));for(let t=1;t<Object.values(n).length;t++){const e=Object.values(n)[t],s=[];for(const t of i)for(const n of e)s.push([...t,n]);i=s}const o=i.map((t=>this.func.prepare(this.func.inputs.map(((t,e)=>({name:t.name,idx:e}))).reduce(((e,{name:n,idx:i})=>(e[n]=t[i],e)),{})))),r=s.TaskBarProgressIndicator.create(`Running ${o.length} function calls...`),a=yield Promise.all(o.map((t=>Ut(this,void 0,void 0,(function*(){return yield t.call()})))));r.close();const l=yt(a,this.func,this.options);this.comparisonView.dataFrame=l,this.comparisonView.grid.props.rowHeight=25,this.comparisonView.grid.props.showAddNewRowIcon=!1,this.comparisonView.grid.props.allowEdit=!1,this.comparisonView.grid.columns.byName(Gt).width=70,this.comparisonView.grid.columns.byName(Gt).visible=!1;for(let e=0;e<this.comparisonView.grid.columns.length;e++){const n=this.comparisonView.grid.columns.byIndex(e);(null===(t=n.column)||void 0===t?void 0:t.temp[rt])&&(n.width=350,n.cellType="html")}this.comparisonView.grid.onCellPrepare((t=>{if(!t.isColHeader&&!t.isRowHeader&&(t.tableColumn.name===Gt&&(t.style.textVertical=!0),t.tableColumn&&t.tableColumn.temp[rt])){const n=t.cell.value,i=t.tableColumn.temp[rt],o=i.type;t.element=e.waitBox((()=>Ut(this,void 0,void 0,(function*(){const e=Object.values(st).includes(o)?s.Viewer.fromType(o,n):yield n.plot.fromType(o);return t.tableColumn.temp[rt].look?e.setOptions(t.tableColumn.temp[rt].look):(e.setOptions(i),t.tableColumn.temp[rt]=e.getOptions()),e.root})))),t.element.style.width="100%",t.element.style.height="100%"}})),this.comparisonView.grid.props.rowHeight=25}))}runElementaryAnalysis(){var n,i,o;return Ut(this,void 0,void 0,(function*(){const r=Object.keys(this.store.inputs).reduce(((t,e)=>{switch(this.store.inputs[e].type){case s.TYPE.INT:case s.TYPE.BIG_INT:const n=this.store.inputs[e],i=(n.max.value-n.min.value)/(n.lvl.value-1);t[e]=n.isChanging.value.value?Array.from({length:n.lvl.value},((t,e)=>Math.round(n.min.value+e*i))):[n.const.value];break;case s.TYPE.FLOAT:const o=this.store.inputs[e],r=(o.max.value-o.min.value)/(o.lvl.value-1);t[e]=o.isChanging.value.value?Array.from({length:o.lvl.value},((t,e)=>o.min.value+e*r)):[o.const.value];break;case s.TYPE.BOOL:const a=this.store.inputs[e];t[e]=a.isChanging.value.value?[a.const.value,!a.const.value]:[a.const.value];break;default:const l=this.store.inputs[e];t[e]=[l.const.value]}return t}),{});let a=Object.values(r)[0].map((t=>[t]));for(let t=1;t<Object.values(r).length;t++){const e=Object.values(r)[t],n=[];for(const t of a)for(const i of e)n.push([...t,i]);a=n}const l=a.map((t=>this.func.prepare(this.func.inputs.map(((t,e)=>({name:t.name,idx:e}))).reduce(((e,{name:n,idx:i})=>(e[n]=t[i],e)),{})))),u=yield Mt(l);this.closeOpenedViewers();const c=[],d=u.length,h=this.getFixedInputColumns(d),m=[];for(const t of Object.keys(this.store.inputs)){const e=this.store.inputs[t],o=e.prop;e.isChanging.value.value&&(m.push(null!==(n=o.caption)&&void 0!==n?n:o.name),c.push(s.Column.fromType(o.propertyType,null!==(i=o.caption)&&void 0!==i?i:o.name,d)))}const f="ID",v=s.DataFrame.fromColumns([s.Column.fromStrings(f,u.map((t=>t.id))),...c]);for(let t=0;t<d;++t)for(const e of Object.keys(this.store.inputs)){const n=this.store.inputs[e],i=n.prop;n.isChanging.value.value&&v.set(null!==(o=i.caption)&&void 0!==o?o:i.name,t,u[t].inputs[e])}const g=[];for(const t of Object.keys(this.store.outputs)){const e=this.store.outputs[t];e.isInterest.value.value&&g.push({prop:e.prop,elements:[],row:e.value.returning===Jt.LAST_ROW?-1:1})}const y=jt(u,g).columns;for(const t of y)v.columns.add(t),m.push(t.name);for(const t of h)v.columns.add(t);this.comparisonView.dataFrame=v,this.comparisonView.grid.col(f).visible=!1,this.comparisonView.grid.onCellClick.subscribe((n=>{var i;const o=null===(i=n.tableRow)||void 0===i?void 0:i.get(f),r=u.find((t=>t.id===o));if(!r)return;const a=[...r.outputParams.values()].filter((t=>s.TYPES_SCALAR.has(t.property.propertyType))),l=s.HtmlTable.create(a,(t=>{var e;return[null!==(e=t.property.caption)&&void 0!==e?e:t.property.name,r.outputs[t.property.name],t.property.options.units]})).root,c=[...r.outputParams.values()].filter((t=>t.property.propertyType===s.TYPE.DATA_FRAME)).reduce(((t,e)=>{var n;const i=gt(e.property).config,o=r.outputs[e.name],a=null!==(n=e.property.caption)&&void 0!==n?n:e.property.name;return i.map((e=>{const n=e.type,i=s.Viewer.fromType(n,o);i.setOptions(e),p()(i.root).css({width:"100%"}),t[a]?t[a].push(i.root):t[a]=[i.root]})),t}),{}),d=Object.assign({"Output scalars":[l]},c),h=e.accordion();p()(h.root).css({width:"100%"}),Object.entries(d).map((t=>{h.addPane(t[0],(()=>e.divV(t[1])))})),t.shell.o=h.root})),this.comparisonView.grid.columns.setVisible([m[0]]),this.comparisonView.grid.columns.setVisible(m);const A=this.comparisonView.addViewer(s.Viewer.correlationPlot(v));this.comparisonView.dockManager.dock(A,"right",void 0,"",.4),this.openedViewers.push(A),this.comparisonView.grid.props.rowHeight=25;const b=this.getOutputNameForScatterPlot(m,v,c.length);switch(console.log(b),c.length){case 1:const t=this.comparisonView.addViewer(s.Viewer.lineChart(s.DataFrame.fromColumns(v.columns.byNames(m)),{x:m[0],markerSize:1,markerType:"gradient",sharex:!0,multiAxis:!0,multiAxisLegendPosition:"RightCenter"}));this.openedViewers.push(t);break;case 2:const e=this.comparisonView.addViewer(s.VIEWER.SURFACE_PLOT,{X:m[0],Y:m[1],Z:b});this.openedViewers.push(e);break;default:const n=this.comparisonView.addViewer(s.Viewer.scatterPlot(v,{x:m[0],y:m[1],color:b,size:b,markerMaxSize:12,jitterSize:5}));this.openedViewers.push(n)}}))}getOutputNameForScatterPlot(t,e,n){var i,s,o,r;for(let a=n;a<t.length;++a)if((null!==(s=null===(i=e.col(t[a]))||void 0===i?void 0:i.min)&&void 0!==s?s:0)<(null!==(r=null===(o=e.col(t[a]))||void 0===o?void 0:o.max)&&void 0!==r?r:0))return t[a];return t[n]}}var Kt,Qt=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function te(t){const e=t;return e.dart&&s.toJs(e.dart)instanceof s.InputBase}!function(t){t.INPUTS="inputs",t.OUTPUTS="outputs"}(Kt||(Kt={}));const ee={[Kt.INPUTS]:"inputParams",[Kt.OUTPUTS]:"outputParams"};class ne extends It{static fromFuncCall(t,e={historyEnabled:!0,isTabbed:!1}){return new this(t,e)}constructor(t,n={historyEnabled:!0,isTabbed:!1}){super(t,n),this.options=n,this.checkDisability=new f.Subject,this.isRunning=new f.BehaviorSubject(!1),this.isUploadMode=new f.BehaviorSubject(!1),this.inputsOverride={},this.inputsMap={},this.prevOpenedTab=null,this.beforeInputPropertyRender=new f.Subject,this.afterInputPropertyRender=new f.Subject,this.afterOutputPropertyRender=new f.Subject,this.afterOutputSacalarTableRender=new f.Subject,this.additionalBtns=e.divH([]),this.navBtns=e.divH([]),this.outputsTabsElem=e.tabControl(),this.dfToViewerMapping={},this.foldedCategoryInputs={},this.sheetNamesCache={},this.richFunctionExport=t=>Qt(this,void 0,void 0,(function*(){if("Excel"===t)try{const e=this.lastCall;if(!e)throw new Error("Function was not called");if(!this.exportConfig.supportedFormats.includes(t))throw new Error(`Format "${t}" is not supported.`);if(!this.func)throw new Error("The correspoding function is not specified");const n="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8",i=new(w().Workbook),o=t=>s.TYPES_SCALAR.has(t),r=t=>t.propertyType===s.TYPE.DATA_FRAME,a=this.func.inputs.filter((t=>r(t))),l=this.func.inputs.filter((t=>o(t.propertyType))),u=this.func.outputs.filter((t=>r(t))),c=this.func.outputs.filter((t=>o(t.propertyType)));if(a.forEach((t=>{var n;const s=t.options.caption||t.name,o=null!==(n=i.worksheets.find((t=>t.name===this.getSheetName(s,i))))&&void 0!==n?n:i.addWorksheet(this.getSheetName(s,i)),r=e.inputs[t.name];oe(o,r)})),l.length){const t=i.addWorksheet("Input scalars");ie(t,l.map((t=>({caption:t.options.caption||t.name,value:e.inputs[t.name],units:t.options.units||""}))))}if(u.forEach((t=>{var n;const s=t.options.caption||t.name,o=null!==(n=i.worksheets.find((t=>t.name===this.getSheetName(s,i))))&&void 0!==n?n:i.addWorksheet(this.getSheetName(s,i)),r=e.outputs[t.name];oe(o,r)})),c.length){const t=i.addWorksheet("Output scalars");ie(t,c.map((t=>({caption:t.options.caption||t.name,value:e.outputs[t.name],units:t.options.units||""}))))}const d=this.outputsTabsElem;for(const t of this.tabsLabels.filter((t=>Object.keys(this.categoryToDfParamMap.inputs).includes(t))))for(const n of this.categoryToDfParamMap.inputs[t].filter((t=>r(t)))){const o=this.dfToViewerMapping[n.name].filter((t=>t.type!==s.VIEWER.GRID)).filter((t=>Object.values(st).includes(t.type)));if(0===o.length)continue;d.currentPane=d.getPane(t),yield new Promise((t=>setTimeout(t,100)));const r=n.options.caption||n.name,a=e.inputs[n.name];for(const[t,e]of o.entries())yield re(i,i.getWorksheet(this.getSheetName(r,i)),e.root,a.columns.length+2,t>0?Math.ceil(o[t-1].root.clientHeight/20)+1:0)}for(const t of this.tabsLabels.filter((t=>Object.keys(this.categoryToDfParamMap.outputs).includes(t))))for(const n of this.categoryToDfParamMap.outputs[t].filter((t=>r(t)))){const o=this.dfToViewerMapping[n.name].filter((t=>t.type!==s.VIEWER.GRID)).filter((t=>Object.values(st).includes(t.type)));if(0===o.length)continue;d.currentPane=d.getPane(t),yield new Promise((t=>setTimeout(t,100)));const r=n.options.caption||n.name,a=e.outputs[n.name];for(const[t,e]of o.entries())if(e.type===s.VIEWER.STATISTICS){const e=a.columns.length,n=s.DataFrame.fromColumns([s.Column.string("Name",e).init((t=>a.columns.byIndex(t).name)),s.Column.int("Values",e).init((t=>a.columns.byIndex(t).stats.valueCount)),s.Column.int("Nulls",e).init((t=>a.columns.byIndex(t).stats.missingValueCount)),s.Column.float("Min",e).init((t=>a.columns.byIndex(t).stats.min)),s.Column.float("Max",e).init((t=>a.columns.byIndex(t).stats.max)),s.Column.float("Avg",e).init((t=>a.columns.byIndex(t).stats.avg)),s.Column.float("Stdev",e).init((t=>a.columns.byIndex(t).stats.stdev))]);oe(i.getWorksheet(this.getSheetName(r,i)),n,a.columns.length+2,t>0?Math.ceil(o[t-1].root.clientHeight/20)+1:0)}else yield re(i,i.getWorksheet(this.getSheetName(r,i)),e.root,a.columns.length+2,t>0?Math.ceil(o[t-1].root.clientHeight/20)+1:0)}const p=yield i.xlsx.writeBuffer();return new Blob([p],{type:n})}catch(t){console.log(t)}if("DataUrl images"===t){const t={},e=t=>t.propertyType===s.TYPE.DATA_FRAME,n=this.outputsTabsElem;for(const i of this.tabsLabels.filter((t=>Object.keys(this.categoryToDfParamMap.inputs).includes(t))))for(const o of this.categoryToDfParamMap.inputs[i].filter((t=>e(t)))){const e=this.dfToViewerMapping[o.name].filter((t=>t.type!==s.VIEWER.GRID&&t.type!==s.VIEWER.STATISTICS)).filter((t=>Object.values(st).includes(t.type)));if(0!==e.length){n.currentPane=n.getPane(i),yield new Promise((t=>setTimeout(t,100)));for(const[n,i]of e.entries()){const e=(yield St()(i.root,{logging:!1})).toDataURL();t[o.name]||(t[o.name]={}),t[o.name][n]={dataUrl:e,width:i.root.clientWidth,height:i.root.clientHeight}}}}for(const i of this.tabsLabels.filter((t=>Object.keys(this.categoryToDfParamMap.outputs).includes(t))))for(const o of this.categoryToDfParamMap.outputs[i].filter((t=>e(t)))){const e=this.dfToViewerMapping[o.name].filter((t=>t.type!==s.VIEWER.GRID&&t.type!==s.VIEWER.STATISTICS)).filter((t=>Object.values(st).includes(t.type)));if(0!==e.length){n.currentPane=n.getPane(i),yield new Promise((t=>setTimeout(t,100)));for(const[n,i]of e.entries()){const e=(yield St()(i.root,{logging:!1})).toDataURL();t[o.name]||(t[o.name]={}),t[o.name][n]={dataUrl:e,width:i.root.clientWidth,height:i.root.clientHeight}}}}return new Blob([JSON.stringify(t)],{type:"text/plain"})}throw new Error("Format is not supported")})),this.exportConfig={supportedExtensions:this.richFunctionViewExportExtensions(),supportedFormats:this.richFunctionViewSupportedFormats(),export:this.richFunctionExport,filename:this.defaultExportFilename}}onFuncCallReady(){const t=Object.create(null,{onFuncCallReady:{get:()=>super.onFuncCallReady}});return Qt(this,void 0,void 0,(function*(){yield this.loadInputsOverrides(),yield t.onFuncCallReady.call(this),this.basePath=`scripts/${this.funcCall.func.id}/view`,this.runningOnStart&&this.isRunnable()&&(yield this.doRun())}))}onBeforeRun(){return this.prevOpenedTab=Object.keys(this.categoryToDfParamMap.inputs).includes(this.outputsTabsElem.currentPane.name)?null:this.outputsTabsElem.currentPane,Promise.resolve()}onAfterRun(){if(this.showOutputTabsElem(),this.outputsTabsElem.panes.forEach((t=>{p()(t.header).show()})),this.prevOpenedTab)return this.outputsTabsElem.currentPane=this.prevOpenedTab,Promise.resolve();const t=this.outputsTabsElem.panes.find((t=>Object.keys(this.categoryToDfParamMap.outputs).includes(t.name)));return t&&(this.outputsTabsElem.currentPane=t),Promise.resolve()}getRunButton(t="Run"){var n;const i=e.bigButton(null!==(n=this.func.options.runLabel)&&void 0!==n?n:t,(()=>Qt(this,void 0,void 0,(function*(){return yield this.doRun()})))),s=this.checkDisability.subscribe((()=>{const t=this.isRunnable();i.disabled=!t}));return this.subs.push(s),i}loadInputsOverrides(){return Qt(this,void 0,void 0,(function*(){const e=[...this.funcCall.inputParams.values()];yield Promise.all(e.map((e=>Qt(this,void 0,void 0,(function*(){if(e.property.options.input){const n=(yield t.functions.eval(e.property.options.input)).prepare({params:JSON.parse(e.property.options.inputOptions||"{}")});yield n.call(),this.inputsOverride[e.name]=n.outputs.input}})))))}))}getSaveButton(t="Save"){const n=e.bigButton(t,(()=>Qt(this,void 0,void 0,(function*(){return yield this.saveExperimentalRun(this.funcCall)}))),"Save uploaded data");return this.isUploadMode.subscribe((t=>{this.buildRibbonPanels(),this.runningOnInput||(t?p()(n).show():p()(n).hide())})),this.runningOnInput&&!this.options.isTabbed||p()(n).hide(),n}getStandardButtons(){const t=this.getRunButton(),n=e.div([t]);e.tooltip.bind(n,(()=>t.disabled?this.isRunning.value?"Computations are in progress":"Some inputs are invalid":""));const i=this.getSaveButton();return this.runningOnInput&&p()(n).hide(),[i,n]}setAdditionalButtons(t){const n=e.divH(t);this.additionalBtns.replaceWith(n),this.additionalBtns=n}setNavigationButtons(t){const n=e.divH(t);this.navBtns.replaceWith(n),this.navBtns=n}buildIO(){const{inputBlock:t,inputForm:n,outputForm:i,controlsWrapper:s}=this.buildInputBlock();e.tools.handleResize(t,(()=>{[...Array.from(n.childNodes).filter((t=>"none"!==p()(t).css("display"))),...this.isUploadMode.value?[Array.from(i.childNodes)]:[]].some((t=>p()(t).width()<250))||p()(t).width()<350?(p()(n).addClass("ui-form-condensed"),p()(i).addClass("ui-form-condensed"),p()(s).addClass("ui-form-condensed")):(p()(n).removeClass("ui-form-condensed"),p()(i).removeClass("ui-form-condensed"),p()(s).removeClass("ui-form-condensed"))}));const o=this.buildOutputBlock();o.style.height="100%",o.style.width="100%",p()(this.outputsTabsElem.root).hide(),Object.keys(this.categoryToDfParamMap.inputs).length>0&&this.outputsTabsElem.panes.forEach((t=>{p()(t.header).hide()}));const r=e.splitH([t,e.panel([o],{style:{"padding-top":"0px"}})],null,!0);return r.style.padding="0 12px",t.style.maxWidth="450px",r}buildInputBlock(){const t=this.renderInputForm(),n=this.renderOutputForm(),i=this.getStandardButtons(),s=e.buttonsInput([this.navBtns,e.divH([this.additionalBtns,...i],{style:{gap:"5px"}})]);p()(s).addClass("rfv-buttons");const o=e.div(s,"ui-form ui-form-wide");p()(o).css({"padding-left":"0px","padding-bottom":"0px","max-width":"100%","min-height":"50px"});const r=e.switchInput("",this.isUploadMode.value,(t=>this.isUploadMode.next(t)));this.isUploadMode.subscribe((t=>{r.notify=!1,r.value=t,r.notify=!0}));const a=e.divV([t,...this.hasUploadMode?[e.divH([e.h2("Experimental data"),r.root],{style:{"flex-grow":"0"}}),n]:[],o],"ui-box rfv-form");return this.isUploadMode.subscribe((t=>{t?p()(n).show():p()(n).hide()})),{inputBlock:a,inputForm:t,outputForm:n,controlsWrapper:o}}buildRibbonPanels(){super.buildRibbonPanels();const n=e.iconFA("play",(()=>Qt(this,void 0,void 0,(function*(){return yield this.doRun()}))),"Run computations");n.classList.add("fas");const i=e.iconFA("save",(()=>Qt(this,void 0,void 0,(function*(){this.isUploadMode.value?yield this.saveExperimentalRun(this.funcCall):this.lastCall?yield this.saveRun(this.lastCall):t.shell.warning("Function was not called. Call it before saving")}))),this.isUploadMode.value?"Save uploaded data":"Save the last run"),s=e.iconFA("arrow-to-top",(()=>Qt(this,void 0,void 0,(function*(){this.isUploadMode.next(!this.isUploadMode.value),vt(this.func)?(yield t.functions.eval(vt(this.func))).prepare().edit():s.classList.toggle("d4-current")}))),"Upload experimental data");s.classList.add("d4-toggle-button",...this.isUploadMode.value?["d4-current"]:[]);const o=e.iconFA("analytics",(()=>Qt(this,void 0,void 0,(function*(){return yield this.onSALaunch()}))),"Run sensitivity analysis"),r=[...this.getRibbonPanels(),[...this.runningOnInput||this.options.isTabbed?[]:[n],...this.hasUploadMode&&this.isUploadMode.value||this.runningOnInput?[i]:[],...this.hasUploadMode?[s]:[],o]];return this.setRibbonPanels(r),r}showOutputTabsElem(){p()(this.outputsTabsElem.root).show(),p()(this.outputsTabsElem.root).css("display","flex")}buildOutputBlock(){this.outputsTabsElem.root.style.width="100%",this.tabsLabels.forEach((n=>{const[i,o]=this.categoryToDfParamMap.outputs[n]?[this.categoryToDfParamMap.outputs[n],!1]:[this.categoryToDfParamMap.inputs[n],!0],r=i.filter((t=>t.propertyType===s.TYPE.DATA_FRAME)),a=i.filter((t=>t.propertyType!==s.TYPE.DATA_FRAME)),l=r.map((t=>gt(t).config));let u="";const c=r.reduce(((n,i,r)=>{var a,c;this.dfToViewerMapping[i.name]=[];const d=l[r].map(((e,n)=>Qt(this,void 0,void 0,(function*(){var n,o,r,a;const l=null!==(a=null!==(o=null===(n=this.funcCall.outputs[i.name])||void 0===n?void 0:n.value)&&void 0!==o?o:null===(r=this.funcCall.inputParams[i.name])||void 0===r?void 0:r.value)&&void 0!==a?a:t.data.demo.demog(1),u=e.type,c=Object.values(st).includes(u)?s.Viewer.fromType(u,l):yield l.plot.fromType(u);return c.setOptions(e),this.dfToViewerMapping[i.name].push(c),this.afterOutputPropertyRender.next({prop:i,output:c}),c})))).map(((t,e)=>t.then((t=>{const n=()=>{var n;const s=null!==(n=this.funcCall.outputParams[i.name])&&void 0!==n?n:this.funcCall.inputParams[i.name],o=()=>Qt(this,void 0,void 0,(function*(){var n;const s=null!==(n=this.funcCall.outputParams[i.name])&&void 0!==n?n:this.funcCall.inputParams[i.name];if(this.showOutputTabsElem(),Object.values(st).includes(t.type))t.dataFrame=s.value,t.setOptions(l[r][e]);else{const n=yield s.value.plot.fromType(t.type);n.setOptions(l[r][e]),t.root.replaceWith(n.root),t=n}this.afterOutputPropertyRender.next({prop:i,output:t})})),a=s.onChanged.subscribe((()=>Qt(this,void 0,void 0,(function*(){yield o()}))));this.funcCallReplaced.subscribe((()=>Qt(this,void 0,void 0,(function*(){yield o()})))),this.subs.push(a)};return n(),this.subs.push(this.funcCallReplaced.subscribe(n)),t})))),h=u!==(null!==(a=i.options.caption)&&void 0!==a?a:i.name)?null!==(c=i.options.caption)&&void 0!==c?c:i.name:" ";if(u=h,o){const t=()=>{var t;const e=(null!==(t=this.funcCall.outputParams[i.name])&&void 0!==t?t:this.funcCall.inputParams[i.name]).onChanged.subscribe((()=>{this.showOutputTabsElem(),Object.keys(this.categoryToDfParamMap.inputs).forEach((t=>{p()(this.outputsTabsElem.getPane(t).header).show()}))}));this.subs.push(e)};t(),this.subs.push(this.funcCallReplaced.subscribe(t))}const m=d.map(((t,n)=>{const i=l[r][n].block,s=e.wait((()=>Qt(this,void 0,void 0,(function*(){return(yield t).root}))));return p()(s).css({"min-height":"300px","flex-grow":"1"}),e.divV([e.h2(0===n?h:" ",{style:{"white-space":"pre"}}),s],{style:Object.assign({},i?{width:`${i}%`,"max-width":`${i}%`}:{"flex-grow":"1"})})}));return n.append(...m),n}),e.divH([],{style:{"flex-wrap":"wrap","flex-grow":"1"}})),d=()=>{const t=s.HtmlTable.create(a,(t=>{var e;const n=t.options.precision;return[null!==(e=t.caption)&&void 0!==e?e:t.name,n&&t.propertyType===s.TYPE.FLOAT&&this.funcCall.outputs[t.name]?this.funcCall.outputs[t.name].toPrecision(n):this.funcCall.outputs[t.name],t.options.units]})).root;return p()(t).addClass("rfv-scalar-table"),this.afterOutputSacalarTableRender.next(t),t};let h=d();a.forEach((t=>{const e=()=>{const e=this.funcCall.outputParams[t.name].onChanged.subscribe((()=>{const t=d();h.replaceWith(t),h=t,p()(this.outputsTabsElem.getPane(n).header).show()}));this.funcCallReplaced.subscribe((()=>{const t=d();h.replaceWith(t),h=t})),this.subs.push(e)};e(),this.subs.push(this.funcCallReplaced.subscribe(e))})),this.outputsTabsElem.addPane(n,(()=>e.divV([...r.length?[c]:[],...a.length?[h]:[]])))}));const n=e.box();return n.append(this.outputsTabsElem.root),n}onAfterLoadRun(t){return Qt(this,void 0,void 0,(function*(){this.showOutputTabsElem(),this.outputsTabsElem.panes.forEach((t=>{p()(t.header).show()}))}))}get tabsLabels(){return[...Object.keys(this.categoryToDfParamMap.inputs),...Object.keys(this.categoryToDfParamMap.outputs)]}get categoryToDfParamMap(){const t={inputs:{},outputs:{}};return this.func.inputs.filter((t=>t.propertyType===s.TYPE.DATA_FRAME&&0!==gt(t).config.length)).forEach((e=>{const n="Misc"===e.category?"Input":e.category;t.inputs[n]?t.inputs[n].push(e):t.inputs[n]=[e]})),this.func.outputs.forEach((e=>{const n="Misc"===e.category?"Output":e.category;e.propertyType===s.TYPE.DATA_FRAME&&0===gt(e).config.length||(t.outputs[n]?t.outputs[n].push(e):t.outputs[n]=[e])})),t}doRun(){return Qt(this,void 0,void 0,(function*(){this.isRunning.next(!0),this.checkDisability.next();try{yield this.run()}catch(e){t.shell.error(e.toString()),console.log(e)}finally{this.isRunning.next(!1),this.checkDisability.next()}}))}getInput(t){return this.inputsMap[t]}setInput(t,e,n="disabled"){const i=this.getInput(t);if(!i)throw new Error(`No input named ${t}`);this.funcCall.inputs[t]=e,this.setInputState(i,n),"default"!==n&&(this.funcCall.options.editState=Object.assign(Object.assign({},this.funcCall.options.editState),{[t]:n}))}setInputState(t,e){"disabled"===e&&(t.enabled=!1),"default"!==e&&e||(t.enabled=!0)}renderOutputForm(){return this.renderIOForm(Kt.OUTPUTS)}onSALaunch(){return Qt(this,void 0,void 0,(function*(){yield Xt.fromEmpty(this.func)}))}renderInputForm(){return this.renderIOForm(Kt.INPUTS)}renderIOForm(t){const n=e.divH([],"ui-form ui-form-wide");p()(n).css({"flex-wrap":"wrap","flex-grow":"0"});let i="Misc";const s=this.funcCall[ee[t]].values();return r()(s).filter((t=>!!t)).forEach((e=>{const s=e.property;this.beforeInputPropertyRender.next(s);const o=this.getInputForVal(e);o?(this.inputsMap[e.property.name]=o,this.syncInput(e,o,t),this.disableInputsOnRun(o),t===Kt.INPUTS&&this.bindOnHotkey(o),this.renderInput(n,e,o,i),this.afterInputPropertyRender.next({prop:s,input:o}),i=s.category):i=s.category})),Object.keys(this.foldedCategoryInputs).forEach((t=>this.foldedCategoryInputs[t].forEach((t=>p()(t.root).hide())))),n.classList.remove("ui-panel"),n.style.paddingTop="0px",n.style.paddingLeft="0px",n.style.maxWidth="100%",this.checkDisability.next(),n}disableInputsOnRun(t){const e=this.isRunning.subscribe((e=>{t.enabled=!e}));this.subs.push(e)}getInputForVal(n){var i,o,r;const a=n.property;if(this.inputsOverride[n.property.name])return this.inputsOverride[n.property.name];if(a.propertyType===s.TYPE.STRING&&a.options.choices)return e.choiceInput(null!==(i=a.caption)&&void 0!==i?i:a.name,a.defaultValue,JSON.parse(a.options.choices));switch(a.propertyType){case s.TYPE.DATA_FRAME:return e.tableInput(null!==(o=a.caption)&&void 0!==o?o:a.name,null,t.shell.tables);case"file":return it.fileInput(null!==(r=a.caption)&&void 0!==r?r:a.name,null,null,null);case s.TYPE.FLOAT:const n=e.input.forProperty(a),i=a.options.format;return i&&(n.format=i),n;default:return e.input.forProperty(a)}}bindOnHotkey(t){te(t)&&(t.input.onkeydown=t=>Qt(this,void 0,void 0,(function*(){"Enter"==t.key&&this.isRunnable()&&this.doRun()})))}get foldedCategories(){var t;return JSON.parse(null!==(t=this.func.options.foldedCategories)&&void 0!==t?t:"[]")}renderInput(t,n,i,s){var o;const r=n.property;if(r.category!==s)if(this.foldedCategories.includes(r.category)){const n=e.iconFA("chevron-right",(()=>{var t;p()(i).show(),p()(n).hide(),(null!==(t=this.foldedCategoryInputs[r.category])&&void 0!==t?t:[]).forEach((t=>p()(t.root).css({display:"inherit"})))}),"Open category");p()(n).css("padding-right","5px");const i=e.iconFA("chevron-down",(()=>{var t;p()(i).hide(),p()(n).show(),(null!==(t=this.foldedCategoryInputs[r.category])&&void 0!==t?t:[]).forEach((t=>p()(t.root).hide()))}),"Close category");p()(i).css("padding-right","5px"),t.append(e.h2([n,i,e.h2(r.category,{style:{display:"inline"}})],{style:{width:"100%"}})),p()(i).hide()}else t.append(e.h2(r.category,{style:{width:"100%"}}));this.foldedCategories.includes(r.category)&&(this.foldedCategoryInputs[r.category]=[...null!==(o=this.foldedCategoryInputs[r.category])&&void 0!==o?o:[],i]),te(i)&&this.inputBaseAdditionalRenderHandler(n,i),t.append(i.root)}inputBaseAdditionalRenderHandler(t,n){var i,s;const o=t.property;p()(n.root).css({width:`${null!==(i=o.options.block)&&void 0!==i?i:"100"}%`,"box-sizing":"border-box","padding-right":"5px"}),n.captionLabel.firstChild.replaceWith(e.span([null!==(s=o.caption)&&void 0!==s?s:o.name])),o.options.units&&n.addPostfix(o.options.units)}syncInput(t,e,n){this.syncFuncCallReplaced(e,t,n),this.syncOnInput(e,t,n)}syncFuncCallReplaced(t,e,n){const i=e.property,s=e.name,o=this.funcCallReplaced.pipe((0,j.startWith)(!0)).subscribe((()=>{var e,o,r;const a=null!==(o=null!==(e=this.funcCall[n][s])&&void 0!==e?e:i.defaultValue)&&void 0!==o?o:null;t.notify=!1,t.value=a,t.notify=!0,this.funcCall[n][s]=a;const l=this.funcCall[ee[n]][s];this.syncValOnChanged(t,l,n),this.setInputState(t,null===(r=this.funcCall.options.editState)||void 0===r?void 0:r[s])}));this.subs.push(o)}syncValOnChanged(t,e,n){const i=e.onChanged.subscribe((()=>{const i=this.funcCall[n][e.name];(e.property.propertyType===s.TYPE.FLOAT&&new Float32Array([t.value])[0]!==new Float32Array([i])[0]||e.property.propertyType!==s.TYPE.FLOAT)&&(t.notify=!1,t.value=i,t.notify=!0),n===Kt.INPUTS&&(this.hideOutdatedOutput(),this.checkDisability.next(),this.runningOnInput&&this.isRunnable()&&this.doRun())}));if(this.subs.push(i),e.property.propertyType===s.TYPE.DATA_FRAME){const t=()=>{if(!e.value)return;const t=e.value.onDataChanged.subscribe((()=>Qt(this,void 0,void 0,(function*(){this.runningOnInput&&this.isRunnable()&&this.doRun()}))));this.subs.push(t)};e.onChanged.subscribe((()=>{t()})),t()}}syncOnInput(t,e,n){var i;s.debounce((i=t.onInput.bind(t),new f.Observable((t=>{const e=i((e=>{t.next(e)}));return()=>e.unsubscribe()}))),350).subscribe((()=>{this.isHistorical.value&&this.isHistorical.next(!1),this.funcCall[n][e.name]=t.value,te(t)&&(null===t.value?setTimeout((()=>t.input.classList.add("d4-invalid")),100):t.input.classList.remove("d4-invalid")),this.checkDisability.next(),this.hideOutdatedOutput()}))}isRunnable(){return r()(this.funcCall.inputs.values()).every((t=>null!=t))&&!this.isRunning.value}saveExperimentalRun(e){return Qt(this,void 0,void 0,(function*(){const n=yield(yield t.functions.eval("Sin")).prepare({x:1}).call();e.dart.r2=n.dart.r2;const i=e.options.tags||[];e.options.tags=i.includes(lt)?i:[...i,lt],e.newId(),yield this.saveRun(e)}))}hideOutdatedOutput(){this.outputsTabsElem.panes.filter((t=>Object.keys(this.categoryToDfParamMap.outputs).includes(t.name))).forEach((t=>p()(t.header).hide()));const t=this.outputsTabsElem.panes.find((t=>Object.keys(this.categoryToDfParamMap.inputs).includes(t.name)));t?this.outputsTabsElem.currentPane=t:p()(this.outputsTabsElem.root).hide()}getSheetName(t,e){if(this.sheetNamesCache[t])return this.sheetNamesCache[t];let n=`${t}`;n.length>31&&(n=`${n.slice(0,31)}`);let i=1;for(;e.worksheets.some((t=>t.name===n));){let e=`${t}`;e.length>31-`-${i}`.length&&(e=`${t.slice(0,31-`-${i}`.length)}`),n=`${e}-${i}`,i++}return this.sheetNamesCache[t]=n,n}richFunctionViewSupportedFormats(){return["Excel","DataUrl images"]}richFunctionViewExportExtensions(){return{Excel:"xlsx","DataUrl images":"txt"}}}const ie=(t,e)=>{t.addRow(["Parameter","Value","Units"]).font={bold:!0},e.forEach((e=>{t.addRow([e.caption,e.value,e.units])})),t.getColumn(1).width=1.2*Math.max(...e.map((t=>t.caption.toString().length)),9),t.getColumn(2).width=1.2*Math.max(...e.map((t=>t.value.toString().length)),5),t.getColumn(3).width=1.2*Math.max(...e.map((t=>t.units.toString().length)),5)};let se=0;const oe=(t,e,n,i)=>{const s=t.getColumn(null!=n?n:1).letter,o={name:`ID_${se.toString()}`,ref:`${s}${null!=i?i:1}`,columns:e.columns.toList().map((t=>({name:t.name,filterButton:!1}))),rows:new Array(e.rowCount).fill(0).map(((t,n)=>[...e.row(n).cells].map((t=>t.value))))};t.addTable(o),t.columns.forEach((t=>{t.width=25,t.alignment={wrapText:!0}})),se++},re=(t,e,n,i,s=0)=>Qt(void 0,void 0,void 0,(function*(){const o=yield St()(n,{logging:!1}),r=o.toDataURL("image/png"),a=t.addImage({base64:r,extension:"png"});e.addImage(a,{tl:{col:i,row:s},ext:{width:o.width,height:o.height}})}));var ae=n(433),le={};le.styleTagTransform=V(),le.setAttributes=P(),le.insert=S().bind(null,"head"),le.domAPI=E(),le.insertStyleElement=B(),I()(ae.Z,le),ae.Z&&ae.Z.locals&&ae.Z.locals;class ue{constructor(){this.scriptName="",this.description="",this.dfSheetsToSeek=[],this.scalarsToSeek=[],this.scriptText=new f.BehaviorSubject(""),this.infoText=new f.BehaviorSubject(""),this.lastSavedScriptId=new f.BehaviorSubject("")}}var ce=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class de extends s.ViewBase{constructor(){super(),this.store=new ue,this.scriptNameInput=e.stringInput("Script name","",(t=>this.store.scriptName=t)),this.descriptionInput=e.stringInput("Description","",(t=>this.store.description=t));const t=e.bigButton("Generate script",(()=>ce(this,void 0,void 0,(function*(){return yield this.generate()})))),n=e.bigButton("Save",(()=>ce(this,void 0,void 0,(function*(){return yield this.save()})))),i=e.bigButton("Open",(()=>ce(this,void 0,void 0,(function*(){return this.open()}))));i.style.display="none",this.store.lastSavedScriptId.subscribe((t=>{""!==t&&i.style.removeProperty("display")}));const s=t=>{const n=e.button("Remove",(()=>{}));n.style.width=n.style.height,n.style.alignSelf="center",this.store.dfSheetsToSeek.push("");const i=e.divH([e.stringInput(`Sheet name #${t}`,"",(e=>this.store.dfSheetsToSeek[t]=e)).root,n],{style:{"justify-content":"space-between"}});return n.addEventListener("click",(()=>{this.store.dfSheetsToSeek.splice(t,1),i.remove()})),i},o=t=>{const n=e.button("Remove",(()=>{}));n.style.width=n.style.height,n.style.alignSelf="center",this.store.scalarsToSeek.push("");const i=e.divH([e.stringInput(`Scalar name #${t}`,"",(e=>this.store.scalarsToSeek[t]=e)).root,n],{style:{"justify-content":"space-between"}});return n.addEventListener("click",(()=>{this.store.scalarsToSeek.splice(t,1),i.remove()})),i},r=e.divV([]),a=e.button("Add DF to search",(()=>{r.append(s(this.store.dfSheetsToSeek.length))})),l=e.divV([]),u=e.button("Add scalar to search",(()=>{l.append(o(this.store.scalarsToSeek.length))})),c=e.divV([e.h3("Script properties"),this.scriptNameInput.root,this.descriptionInput.root,e.h3("Dataframes to search"),r,a,e.h3("Scalars to search"),l,u,e.divH([t],{style:{"justify-content":"flex-end"}})],"ui-form");let d=e.divText(this.store.scriptText.value),p=e.info(this.store.infoText.value);const h=e.panel([e.h3("Script text"),d,p,e.divH([n,i],{style:{"justify-content":"flex-end"}})],{style:{display:"none"}});this.store.scriptText.subscribe((t=>{const n=e.divText(t);d.replaceWith(n),d=n,""!==t&&h.style.removeProperty("display")})),this.store.infoText.subscribe((t=>{const n=""===t?e.div([]):e.info(t);p.replaceWith(n),p=n})),this.root.appendChild(e.splitH([c,h],{style:{height:"100%",width:"100%"}},!0)),e.tools.handleResize(c.parentElement,(t=>{t<350?c.classList.add("ui-form-condensed"):c.classList.remove("ui-form-condensed")})),c.parentElement.style.maxWidth="340px"}generate(){return ce(this,void 0,void 0,(function*(){const e=this.store.dfSheetsToSeek.map((t=>`//output: dataframe ${t.trim()} { viewer: Grid(); }`)).join("\n"),n=this.store.scalarsToSeek.map((t=>`//output: string ${t.trim()}`)).join("\n"),i=`\nconst wb = new ExcelJS.Workbook();\nawait wb.xlsx.load(await uploadedFile.arrayBuffer());\nconst dfSheetsToSeek = ["${this.store.dfSheetsToSeek.join('","')}"];`;let s=`//name: ${this.store.scriptName}\n`;s+=`//description: ${this.store.description}\n`,s+="//language: javascript\n",s+="//input: file uploadedFile\n",s+=n+"\n",s+=e+"\n",s+="//editor: Compute:FunctionViewEditor\n",s+=i+"\n",this.store.dfSheetsToSeek.forEach((t=>{s+=(t=>`\nconst ${t}_ws = wb.getWorksheet("${t}");\nlet ${t}_data = await ${t}_ws.workbook.csv.writeBuffer();\n${t} = grok.data.parseCsv(${t}_data.toString());`)(t.trim())+"\n"})),s+="\nconst scalarSheets = wb.worksheets.filter(ws => !dfSheetsToSeek.includes(ws.name));\nconst scalarNames = scalarSheets.flatMap((sheet) => sheet.getColumn(1).values);\nconst scalarValues = scalarSheets.flatMap((sheet) => sheet.getColumn(2).values);",this.store.scalarsToSeek.forEach((t=>{var e;s+=`\nconst ${e=t}_index = scalarNames.findIndex((scalarName) => scalarName === "${e}");\n${e} = (${e}_index >= 0) ? scalarValues[${e}_index] : '';\n`})),this.store.scriptText.next(s),(yield t.dapi.scripts.filter(`name="${this.store.scriptName}"`).list()).length>0?this.store.infoText.next(`Script named "${this.store.scriptName}" already exists`):this.store.infoText.next("")}))}save(){return ce(this,void 0,void 0,(function*(){const e=s.Script.create(this.store.scriptText.value),n=yield t.dapi.scripts.save(e);this.store.lastSavedScriptId.next(n.id),t.shell.info(`Script "${this.store.scriptName}" has been saved successfully`)}))}open(){window.open(`${window.location.origin}/script/${this.store.lastSavedScriptId.value}`)}}var pe=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};let he=!1;const me=new s.Package;function fe(t){c.openModelFromFunccall(t)}function ve(){const e=new de;e.name="Import Script Gen",t.shell.addView(e),e.root.classList.remove("ui-panel")}function ge(){return new m}function ye(t){return ne.fromFuncCall(t,{historyEnabled:!0,isTabbed:!1})}function Ae(t){return ne.fromFuncCall(t,{historyEnabled:!1,isTabbed:!0})}function be(t){return function(t){let n=s.View.create(),i=e.div(),o=e.stringInput("Function",t.name);function r(){n.name=t.name,e.empty(i);let o=s.DataFrame.fromProperties(t.inputs.concat(t.outputs),5),r=s.Grid.create(o),a=!1;r.onCellValueEdited.subscribe((e=>{var n;return function(e){for(let n=0;n<t.inputs.length;n++)if(o.columns.byIndex(n).isNone(e))return;let n={};for(let i of t.inputs)n[i.name]=o.col(i.name).get(e);a=!0;let i=t.prepare(n);i.call().then((n=>{for(let n of t.outputs)o.col(n.name).set(e,i.outputs[n.name]);a=!1}))}(null===(n=e.tableRow)||void 0===n?void 0:n.idx)})),i.appendChild(r.root)}return n.root.appendChild(o.root),n.root.appendChild(i),r(),o.onChanged((()=>{s.Func.findAll({name:o.value}).then((e=>{1==e.length&&(t=e[0],r())}))})),n}(t)}function we(){console.log("hof");let e=be(s.Func.byName("Sin"));e.parentCall=t.functions.getCurrentCall(),t.shell.addView(e)}function Ce(){var n,i,o;console.log("hof2");let r=be(s.Func.byName("Sin"));r.root.appendChild(e.narrowForm([e.switchInput("test",!0),e.boolInput("test",!0)])),r.root.appendChild(e.form([e.switchInput("test",!0),e.boolInput("test",!0)])),r.parentCall=t.functions.getCurrentCall(),r.parentView=null===(n=r.parentCall.parentCall)||void 0===n?void 0:n.aux.view,null===(i=r.parentCall.parentCall)||void 0===i||i.aux.url,null===(o=r.parentCall)||void 0===o||o.aux.url,r.basePath="/"+r.parentCall.func.name,r.path="/",t.shell.addView(r)}function Te(n){return pe(this,void 0,void 0,(function*(){let i={};n.inputs.forEach((t=>i[t.name]=null));let o=`\ncurl --location --request POST '${t.settings.apiUrl}/v1/func/${n.nqName}/run' \\\n--header 'Authorization: ${Ie("auth")}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '${JSON.stringify(i)}'`,r=`\nvar myHeaders = new Headers();\nmyHeaders.append("Authorization", "${Ie("auth")}");\nmyHeaders.append("Content-Type", "application/json");\n\nvar raw = JSON.stringify(${JSON.stringify(i)});\n\nvar requestOptions = {\n method: 'POST',\n headers: myHeaders,\n body: raw,\n redirect: 'follow'\n};\n\nfetch("${t.settings.apiUrl}/v1/func/${n.nqName}/run", requestOptions)\n .then(response => response.text())\n .then(result => console.log(result))\n .catch(error => console.log('error', error));`,a=e.tabControl({CURL:e.div([e.divText(o)]),JS:e.div([e.divText(r)])});return s.Widget.fromRoot(a.root)}))}function Ie(t){let e=document.cookie.match(new RegExp("(?:^|; )"+t.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):void 0}function xe(){}function Ee(){he||(s.ObjectHandler.register(new c),t.events.onAccordionConstructed.subscribe((t=>{const n=t.context;null!=n&&"script"==n.type&&(t.getPane("REST")||t.addPane("REST",(()=>e.wait((()=>pe(this,void 0,void 0,(function*(){return(yield Te(n)).root})))))))})),he=!0)}function Re(){let e=c.findModelCatalogView();if(null==e){let e=new l;e.name="ModelHub";let n=document.createElement("a");n.href=window.location.href;let i=n.pathname.split("/");t.shell.addView(e),i.length>3&&t.dapi.functions.filter(`shortName = "${i[3]}" and #model`).list().then((t=>{1==t.length&&c.openModel(t[0])}))}else t.shell.v=e}})(),compute=i})();
|
|
2
2
|
//# sourceMappingURL=package.js.map
|