@datagrok/compute 1.0.1 → 1.1.1

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={556:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(537),o=n.n(i),s=n(645),r=n.n(s)()(o());r.push([t.id,".cv-drop-area {\n position: relative;\n}\n\n.ui-form .cv-drop-area .icon {\n\tpadding-top: 10px;\n}\n\n.ui-form-condensed .cv-drop-area .icon {\n\tpadding-top: 0px;\n position: absolute;\n top: 35px;\n right: 10px;\n}\n\n.cv-drop-area .default {\n color: var(--grey-2);\n}\n\n.cv-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.cv-drop-area .error {\n color: var(--red-3);\n}\n\n.cv-drop-area .success {\n color: var(--grey-6);\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/css/file-input.css"],names:[],mappings:"AAAA;EACE,kBAAkB;AACpB;;AAEA;CACC,iBAAiB;AAClB;;AAEA;CACC,gBAAgB;EACf,kBAAkB;EAClB,SAAS;EACT,WAAW;AACb;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,gCAAgC;EAChC,gCAAgC;EAChC,oBAAoB;AACtB;;AAEA;EACE,mBAAmB;AACrB;;AAEA;EACE,oBAAoB;AACtB",sourcesContent:[".cv-drop-area {\n position: relative;\n}\n\n.ui-form .cv-drop-area .icon {\n\tpadding-top: 10px;\n}\n\n.ui-form-condensed .cv-drop-area .icon {\n\tpadding-top: 0px;\n position: absolute;\n top: 35px;\n right: 10px;\n}\n\n.cv-drop-area .default {\n color: var(--grey-2);\n}\n\n.cv-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.cv-drop-area .error {\n color: var(--red-3);\n}\n\n.cv-drop-area .success {\n color: var(--grey-6);\n}"],sourceRoot:""}]);const a=r},400:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(537),o=n.n(i),s=n(645),r=n.n(s)()(o());r.push([t.id,'.no-elements-label {\n margin: 8px;\n}\n\n.arrow-box {\n position: relative;\n}\n\n.arrow-box:before {\n left: -6px;\n top: 55px;\n content: "";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n background-color: white;\n\n transform-origin: center;\n transform: rotate(-135deg);\n box-shadow: -4px 4px 0px 4.5px white, #4d5261 0px 0px 5px;;\n\n border: 5px solid black;\n border-color: transparent transparent #FFFFFF #FFFFFF;\n\n margin-top: -21px;\n}',"",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/css/history-input.css"],names:[],mappings:"AAAA;IACI,WAAW;AACf;;AAEA;IACI,kBAAkB;AACtB;;AAEA;IACI,UAAU;IACV,SAAS;IACT,WAAW;IACX,SAAS;IACT,QAAQ;IACR,kBAAkB;IAClB,oBAAoB;IACpB,uBAAuB;;IAEvB,wBAAwB;IACxB,0BAA0B;IAC1B,yDAAyD;;IAEzD,uBAAuB;IACvB,qDAAqD;;IAErD,iBAAiB;AACrB",sourcesContent:['.no-elements-label {\n margin: 8px;\n}\n\n.arrow-box {\n position: relative;\n}\n\n.arrow-box:before {\n left: -6px;\n top: 55px;\n content: "";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n background-color: white;\n\n transform-origin: center;\n transform: rotate(-135deg);\n box-shadow: -4px 4px 0px 4.5px white, #4d5261 0px 0px 5px;;\n\n border: 5px solid black;\n border-color: transparent transparent #FFFFFF #FFFFFF;\n\n margin-top: -21px;\n}'],sourceRoot:""}]);const a=r},276:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(537),o=n.n(i),s=n(645),r=n.n(s)()(o());r.push([t.id,".cv-funccall-card:hover {\n box-shadow: 0px 0px 3px #b8bac0;\n cursor: pointer;\n}\n\n.cv-funccall-card {\n margin: 2px 1px;\n padding: 5px;\n justify-content: space-between;\n}\n\n.cv-funccall-card.clicked {\n border: 1px solid var(--blue-1);\n}\n\n.cv-funccall-card-hover-icon {\n display: none;\n}\n\n.cv-funccall-card:hover .cv-funccall-card-hover-icon {\n display: flex;\n}\n\n.cv-funccall-card-def-icon {\n display: flex;\n}\n\n.cv-funccall-card:hover .cv-funccall-card-def-icon {\n display: none;\n}\n\n.cv-funccall-card .cv-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.cv-funccall-card-def-icon {\n margin: 5px;\n}\n\n.cv-funccall-card-hover-icon {\n margin: 5px;\n}\n\n.cv-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.cv-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/css/history-panel.css"],names:[],mappings:"AAAA;IACI,+BAA+B;IAC/B,eAAe;AACnB;;AAEA;IACI,eAAe;IACf,YAAY;IACZ,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,WAAW;AACf;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,kBAAkB;IAClB,oBAAoB;AACxB;;AAEA;IACI,oBAAoB;IACpB,gBAAgB;AACpB",sourcesContent:[".cv-funccall-card:hover {\n box-shadow: 0px 0px 3px #b8bac0;\n cursor: pointer;\n}\n\n.cv-funccall-card {\n margin: 2px 1px;\n padding: 5px;\n justify-content: space-between;\n}\n\n.cv-funccall-card.clicked {\n border: 1px solid var(--blue-1);\n}\n\n.cv-funccall-card-hover-icon {\n display: none;\n}\n\n.cv-funccall-card:hover .cv-funccall-card-hover-icon {\n display: flex;\n}\n\n.cv-funccall-card-def-icon {\n display: flex;\n}\n\n.cv-funccall-card:hover .cv-funccall-card-def-icon {\n display: none;\n}\n\n.cv-funccall-card .cv-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.cv-funccall-card-def-icon {\n margin: 5px;\n}\n\n.cv-funccall-card-hover-icon {\n margin: 5px;\n}\n\n.cv-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.cv-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}"],sourceRoot:""}]);const a=r},410:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(537),o=n.n(i),s=n(645),r=n.n(s)()(o());r.push([t.id,".ui-input-root > input.ui-input-editor.disabled:focus {\n outline: none;\n border-bottom: 1px solid var(--grey-2)!important;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/css/rich-function-view.css"],names:[],mappings:"AAAA;IACI,aAAa;IACb,gDAAgD;AACpD",sourcesContent:[".ui-input-root > input.ui-input-editor.disabled:focus {\n outline: none;\n border-bottom: 1px solid var(--grey-2)!important;\n}\n"],sourceRoot:""}]);const a=r},433:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(537),o=n.n(i),s=n(645),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},645: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 c=[].concat(t[d]);i&&r[c[0]]||(void 0!==s&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=s),n&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=n):c[2]=n),o&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=o):c[4]="".concat(o)),e.push(c))}},e}},537: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," */"),r=n.sources.map((function(t){return"/*# sourceURL=".concat(n.sourceRoot||"").concat(t," */")}));return[e].concat(r).concat([s]).join("\n")}return[e].join("\n")}},379: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],c=s[d]||0,u="".concat(d," ").concat(c);s[d]=c+1;var p=n(u),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)e[p].references++,e[p].updater(h);else{var f=o(h,i);i.byIndex=a,e.splice(a,0,{identifier:u,updater:f,references:1})}r.push(u)}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 c=n(s[d]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}s=l}}},569: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)}},216:t=>{t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},565:(t,e,n)=>{t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},795:t=>{t.exports=function(t){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)}}}},589: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:()=>Rt,PipelineStepEditor:()=>Tt,RichFunctionViewEditor:()=>Et,_package:()=>wt,autostart:()=>Vt,computationTest:()=>Ot,functionParametersGrid:()=>Ft,hof:()=>St,hof2:()=>Bt,importScriptGenerator:()=>It,init:()=>_t,modelCatalog:()=>Mt,renderRestPanel:()=>kt,testComputationView:()=>Dt});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 c,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 c).isApplicable(e.sender)&&(t.shell.windows.showProperties=!0,window.localStorage.setItem("ModelCatalogShowProperties","false"),a.unsubscribe())})))}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 c 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")}getVideoBackgroundUrl(t){let e=t.options["video-preview"];if(null==e)return"";if(e.startsWith("http://")||e.startsWith("https://"))return e;if(t instanceof o.Script)return null!=t.options.icon?`${t.options.icon.substring(0,t.options.icon.lastIndexOf("/"))}/${e}`:"";let n=t.package.getIconUrl();return n=n.substring(0,n.lastIndexOf("/")),`${n}/${e}`}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(n){let i=e.span([this.renderIcon(n),e.label(n.friendlyName)]),o=t.functions.getCurrentCall();return i.ondblclick=t=>{c.openModel(n,o)},i}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)])]);if(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"]})),null!=t.options.video||null!=t.options.education){let i=e.link("Education materials",t.options.education);e.setDisplay(i,null!=t.options.education);let o=e.div(e.icons.play((()=>{window.open(t.options.video,"_blank")})),"model-catalog-video");e.setDisplay(o,null!=t.options.video),o.style.backgroundImage=`url('${this.getVideoBackgroundUrl(t)}')`,n.addPane("Documentation",(()=>e.divV([i,o],{style:{lineHeight:"150%"}})),!0)}return n.end(),n.root}renderDetails(t){let n=e.markdown(`**Status:** ${t.options["dev.status"]}`);return e.setDisplay(n,null!=t.options["dev.status"]),e.divV([e.markdown(`**Description: ** ${t.description}`),n,e.markdown("**Tags:**"),e.tags(t),e.markdown("**Documentation:**")],{style:{lineHeight:"150%"}})}renderTooltip(n){let i=this.renderMarkup(n);i.classList.add("d4-link-label");let o=e.bind(n,e.divV([e.h2(i),e.divV([e.divText(n.description,"ui-description")],{style:{lineHeight:"150%"}})])),s=t.functions.getCurrentCall();return o.ondblclick=t=>{c.openModel(n,s)},o}renderCard(n,i){let o=this.renderMarkup(n);o.classList.add("d4-link-label");let s=e.bind(n,e.h2(o)),r=t.functions.getCurrentCall();return s.ondblclick=t=>{c.openModel(n,r)},s}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,e){t.prepare().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)}))}))}}class u extends o.JsViewer{constructor(){super()}onFrameAttached(t){this.dataFrame=t,this.render()}onTableAttached(){this.render()}render(){if(!this.dataFrame||this.dataFrame.rowCount<=0)return void(this.root.innerHTML="");const t=this.dataFrame,n="isOutlier",i="Rationale",s="Count",r="isConfirmed";t.columns.byName(n)||t.columns.add(o.Column.fromBitSet(n,o.BitSet.create(t.rowCount,(()=>!1)))),t.columns.byName(i)||t.columns.add(o.Column.fromStrings(i,Array.from({length:t.rowCount},(()=>""))));const a=()=>o.DataFrame.fromColumns([o.Column.fromStrings(i,[]),o.Column.fromInt32Array(s,new Int32Array([])),o.Column.fromStrings("Actions",[]),o.Column.fromBitSet(r,o.BitSet.create(0,(()=>!1)))]),l=o.Viewer.grid(a());l.root.style.width="100%",l.root.style.minWidth="230px",l.columns.setVisible([i,s,"Actions"]),l.onCellPrepare((s=>{var a,d,c;s.isTableCell&&("Actions"===s.gridColumn.name&&(s.gridColumn.cellType="html",s.style.element=e.divH([...(null===(a=s.grid.dataFrame)||void 0===a?void 0:a.get(r,s.gridRow))?[(c=null===(d=s.grid.dataFrame)||void 0===d?void 0:d.get(i,s.gridRow),e.div(e.icons.delete((()=>{for(let e=0;e<t.rowCount;e++)t.columns.byName(i).get(e)===c&&(t.columns.byName(i).set(e,"",!1),t.columns.byName(n).set(e,!1,!1));t.fireValuesChanged()}),"Remove the outliers group"),{style:{"text-align":"center",margin:"6px"}}))]:[e.div(e.iconFA("check",(()=>{var e,s;if(!l.dataFrame)return;null===(e=t.col(n))||void 0===e||e.markers.assign("true",o.MARKER_TYPE.OUTLIER);const r=null===(s=l.dataFrame)||void 0===s?void 0:s.cell(l.dataFrame.rowCount-1,i).value;t.selection.getSelectedIndexes().forEach((e=>{t.col(n).set(e,!0,!1),t.col(i).set(e,r,!1)})),t.selection.setAll(!1),t.fireValuesChanged()}),"Confirm the outliers"),{style:{"text-align":"center",margin:"6px"}}),e.div(e.iconFA("times",(()=>{l.dataFrame&&(l.dataFrame.rows.removeAt(l.dataFrame.rowCount-1),t.selection.setAll(!1))}),"Cancel the outliers"),{style:{"text-align":"center",margin:"6px"}})]])))})),l.onCellValueEdited.subscribe((e=>{var n,o;if(!l.dataFrame||e.gridColumn.name!==i)return;if(!l.dataFrame.columns.byName(r).get(e.gridRow))return;const s=new Set;for(let t=0;t<(null===(n=l.dataFrame)||void 0===n?void 0:n.rowCount);t++){const e=null===(o=l.dataFrame)||void 0===o?void 0:o.columns.byName(i).get(t);s.add(e)}for(let n=0;n<t.rowCount;n++){const o=t.columns.byName(i).get(n);""==o||s.has(o)||t.columns.byName(i).set(n,e.cell.value)}}));const d=()=>{if(t.columns.byName(i))for(let e=0;e<t.rowCount;e++)t.columns.byName(n).get(e)?""===t.columns.byName(i).get(e)&&t.columns.byName(i).set(e,"Manual",!1):""!==t.columns.byName(i).get(e)&&t.columns.byName(i).set(e,"",!1);const e={};if(t.columns.byName(i))for(let n=0;n<t.rowCount;n++){const o=t.columns.byName(i).get(n),s=e[o];""!=o&&(s?e[o]++:e[o]=1)}l.dataFrame=a(),l.columns.setVisible([i,s,"Actions"]),Object.keys(e).map((t=>{var n;null===(n=l.dataFrame)||void 0===n||n.rows.addNew([t,e[t],"",!0])}))};t.onDataChanged.subscribe(d),t.onSelectionChanged.subscribe((()=>{if(l.dataFrame&&t.selection.trueCount)if(l.dataFrame.columns.byName(r).toList().some((t=>!1===t)))l.dataFrame.set(s,l.dataFrame.rowCount-1,t.selection.trueCount);else{const e=l.dataFrame.rows.addNew(["Manual",t.selection.trueCount,"",!1]);l.dataFrame.currentCell=l.dataFrame.cell(e.idx,i)}})),t.selection.setAll(!1),d(),this.root.innerHTML="",this.root.appendChild(e.divV([e.divV([l.root],{style:{height:"75%"}})],{style:{height:"100%"}}))}}var p;function h(t){return e=this,n=void 0,o=function*(){yield new Promise((e=>setTimeout(e,t)))},new((i=void 0)||(i=Promise))((function(t,s){function r(t){try{l(o.next(t))}catch(t){s(t)}}function a(t){try{l(o.throw(t))}catch(t){s(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(r,a)}l((o=o.apply(e,n||[])).next())}));var e,n,i,o}!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(p||(p={}));const f=rxjs;var m=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const v=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 g;!function(e){const n={};e.loadChildRuns=function(e){return m(this,void 0,void 0,(function*(){const i=yield t.dapi.functions.calls.allPackageVersions().find(e);i.options.isHistorical=!0;const o=yield t.dapi.functions.calls.allPackageVersions().filter(`options.parentCallId="${e}"`).list();return yield Promise.all(o.map((e=>m(this,void 0,void 0,(function*(){var i;const o=e.func.id,s=null!==(i=n[o])&&void 0!==i?i:yield t.dapi.functions.allPackageVersions().find(o);n[o]||(n[o]=s),e.func=s}))))),{parentRun:i,childRuns:o}}))},e.loadRun=function(e,i=!1){var s;return m(this,void 0,void 0,(function*(){const a=yield t.dapi.functions.calls.allPackageVersions().include("inputs, outputs, session.user").find(e),l=a.func.id,d=null!==(s=n[l])&&void 0!==s?s:yield t.dapi.functions.allPackageVersions().find(l);if(n[l]||(n[l]=d),a.func=d,a.options.isHistorical=!0,!i){const e=r()(a.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const n of e)a.outputs[n.name]=yield t.dapi.tables.getTable(a.outputs[n.name]);const n=r()(a.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const e of n)a.inputs[e.name]=yield t.dapi.tables.getTable(a.inputs[e.name])}return a}))},e.saveRun=function(e){return m(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)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)yield t.dapi.tables.uploadDataFrame(e.inputs[n.name]);return yield t.dapi.functions.calls.allPackageVersions().save(e)}))},e.deleteRun=function(e){return m(this,void 0,void 0,(function*(){yield t.dapi.functions.calls.allPackageVersions().delete(e)}))},e.pullRuns=function(e,n={},i={}){return m(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?v(n.date):"",t.dapi.functions.calls.allPackageVersions().filter(o).include("session.user, options").list(i)}))},e.pullRunsByName=function(e,i=[],s={},a=[]){var l;return m(this,void 0,void 0,(function*(){let d="";for(const t of i){const e=[];t.author&&e.push(`session.user.id="${t.author.id}"`),t.date&&e.push(v(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&&(d+=""===d?`(${n})`:` or (${n})`)}""!==d&&(d=` and (${d})`);const c=yield t.dapi.functions.calls.allPackageVersions().filter(`func.name="${e}"${d}`).include(`${a.join(",")}`).list(s);for(const e of c){const i=e.func.id,o=null!==(l=n[i])&&void 0!==l?l:yield t.dapi.functions.allPackageVersions().find(i);n[i]||(n[i]=o),e.func=o}if(a.includes("inputs")||a.includes("func.params"))for(const e of c){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 c){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 c}))}}(g||(g={}));const y=$;var A=n.n(y);const b=ExcelJS;var C,x=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(x().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 "})))}))}(C||(C={}));var I=n(379),R=n.n(I),E=n(795),T=n.n(E),F=n(569),S=n.n(F),B=n(565),k=n.n(B),P=n(216),V=n.n(P),_=n(589),M=n.n(_),O=n(556),D={};D.styleTagTransform=M(),D.setAttributes=k(),D.insert=S().bind(null,"head"),D.domAPI=T(),D.insertStyleElement=V(),R()(O.Z,D),O.Z&&O.Z.locals&&O.Z.locals;var L=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const N="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class j{constructor(t="Drag-n-drop here",n=null,i=null,s=N){this.initialText=t,this.initialValue=n,this.onValueChanged=i,this.fileType=s,this.uploadedFile$=new f.Subject,this.onFileUploaded=new f.Subject,this.root=e.div(),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"),c=s.pages.length,u=e.divText("1/"+c);return u.style.position="absolute",u.style.left="12px",u.style.color="var(--grey-5)",s.captionHost.style.fontSize="20px",s.captionHost.style.fontWeight="400",s.captionHost.style.margin="6px 0",A()(s.root).find(".d4-command-bar").append(u),A()(a).html("BACK"),A()(l).html("NEXT"),A()(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||A()(d).addClass("disabled"),u.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&&A()(d).removeClass("disabled"),u.textContent=t+"/"+e})),s.show(),!1}))}},this.visibleInput=e.stringInput("Input file",this.initialText,null),this.hiddenInput=document.createElement("input"),this.icon=e.iconFA("cloud-upload",(()=>this.hiddenInput.click())),this.isValid=new f.BehaviorSubject(!0),this.draw(),this.isValid.subscribe((t=>{if(t){this.visibleInput.input.classList.remove("error"),this.visibleInput.input.classList.add("success");const t=e.iconFA("times",(()=>this.reset()));this.icon.replaceWith(t),this.icon=t}else{this.visibleInput.input.classList.remove("success"),this.visibleInput.input.classList.add("error");const t=e.iconFA("redo",(()=>this.hiddenInput.click()));this.icon.replaceWith(t),this.icon=t}})),this.uploadedFile$.subscribe((t=>this.onFileUploaded.next(t))),i&&this.uploadedFile$.subscribe((t=>i(t)))}draw(){this.clear(),["drag","dragenter"].forEach((t=>{document.getElementsByClassName("layout-workarea")[0].addEventListener(t,(t=>{t.stopPropagation()}),!1)})),this.root.style.display="flex",this.root.append((()=>{this.visibleInput.input.readOnly=!0,this.visibleInput.input.classList.add("default");const t=t=>L(this,void 0,void 0,(function*(){if(t&&t.length){if(t.length>1)throw this.isValid.next(!1),new Error("Please specify single input file");if(this.visibleInput.value=t[0].name,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)}else this.uploadedFile$.next(null)}));return this.visibleInput.root.classList.add("cv-drop-area"),this.visibleInput.root.style.width="100%",this.hiddenInput.type="file",this.hiddenInput.addEventListener("change",(()=>L(this,void 0,void 0,(function*(){return yield t(this.hiddenInput.files)}))),!1),["dragenter","dragover","dragleave","drop"].forEach((t=>{this.visibleInput.input.addEventListener(t,(t=>{t.preventDefault(),t.stopPropagation()}),!1)})),["dragenter","dragover"].forEach((t=>{this.visibleInput.input.addEventListener(t,(()=>{this.visibleInput.input.classList.add("drag-n-dropping")}),!1)})),["dragleave","drop"].forEach((t=>{this.visibleInput.input.addEventListener(t,(()=>{this.visibleInput.input.classList.remove("drag-n-dropping")}),!1)})),this.visibleInput.input.addEventListener("drop",(e=>L(this,void 0,void 0,(function*(){const n=e.dataTransfer.files;t(n)}))),!1),this.visibleInput.input.addEventListener("click",(()=>this.hiddenInput.click()),!1),this.visibleInput.root.append(e.div(this.icon,"icon")),this.visibleInput})().root)}reset(){this.visibleInput.input.classList.value="ui-input-editor default";const t=e.iconFA("cloud-upload",(()=>this.hiddenInput.click()));this.icon.replaceWith(t),this.icon=t,this.visibleInput.value="Drag-n-drop here",this.hiddenInput.value="",this.uploadedFile$.next(null)}clear(){e.empty(this.root)}}const W=rxjs.operators;var H=n(400),U={};U.styleTagTransform=M(),U.setAttributes=k(),U.insert=S().bind(null,"head"),U.domAPI=T(),U.insertStyleElement=V(),R()(H.Z,U),H.Z&&H.Z.locals&&H.Z.locals;class G{constructor(n,i,s,r,a=[]){var l;this.label=n,this._funcName=i,this._stringValueFunc=s,this._visibleColumnsForGrid=r,this._visibleColumnsForFilter=a,this.onHistoricalRunChosen=new f.BehaviorSubject(null),this.experimentRunsUpdate=new f.Subject,this.store={experimentRuns:new f.Observable,experimentRunsDf:new f.BehaviorSubject(o.DataFrame.fromColumns([o.Column.fromStrings("Pick",[]),...Object.keys(this._visibleColumnsForGrid).map((t=>o.Column.fromStrings(t,[])))])),isExperimentRunsLoading:new f.Subject,experimentRunData:new f.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._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",(()=>{var t;const n=e.dialog();A()(n.root).addClass("arrow-box"),n.onOK((()=>{})),n.onCancel((()=>{this.onHistoricalRunChosen.next(null)})),A()(n.root).find(".d4-dialog-header").hide(),n.root.style.boxShadow="",A()(n.root).removeClass("ui-form");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",this._historyGrid.columns.byIndex(e).width=100)}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")],{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%",A()(this._historyFilters.root).find(".d4-filter-group-header").hide(),this._visibleColumnsForFilter.length||A()(this._historyFilters.root.parentElement).hide(),n.add(e.divH([e.block([this._historyGrid.root]),e.block([this._historyFilters.root],{style:{"margin-left":"10px",width:"225px",height:"100%"}})])),n.show({x:this._visibleInput.input.getBoundingClientRect().x+this._visibleInput.input.clientWidth+10,y:this._visibleInput.input.getBoundingClientRect().y-30,width:Math.max(this._historyGrid.root.clientWidth+this._historyFilters.root.clientWidth+30,600)})})),this._visibleInput.readOnly=!0,this.store.experimentRuns=this.experimentRunsUpdate.pipe((0,W.tap)((()=>this.toggleLoaderExpRuns(!0))),(0,W.switchMap)((()=>class{static getHistoryRuns(e){return(0,f.from)((()=>{return n=this,i=void 0,s=function*(){return yield g.pullRunsByName(e,[{isShared:!0},{author:t.shell.user}],{order:"started"},["func.params","session.user","options"])},new((o=void 0)||(o=Promise))((function(t,e){function r(t){try{l(s.next(t))}catch(t){e(t)}}function a(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(r,a)}l((s=s.apply(n,i||[])).next())}));var n,i,o,s})())}}.getHistoryRuns(this._funcName).pipe((0,W.catchError)((()=>f.EMPTY)),(0,W.finalize)((()=>this.toggleLoaderExpRuns(!1)))))),(0,W.shareReplay)(1)),this.store.experimentRuns.pipe((0,W.takeUntil)((0,f.from)(new f.Subject))).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),i=t.find((t=>t.id===n));i&&this.onHistoricalRunChosen.next(i)})),this.store.experimentRunsDf.next(e)})),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)}))}get historyGrid(){return this._historyGrid}get historyFilters(){return this._historyFilters}get root(){return this._visibleInput.root}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 Y=dayjs;var Z=n.n(Y),z=n(276),q={};q.styleTagTransform=M(),q.setAttributes=k(),q.insert=S().bind(null,"head"),q.domAPI=T(),q.insertStyleElement=V(),R()(z.Z,q),z.Z&&z.Z.locals&&z.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())}))};const J={Test:"ca1e672e-e3be-40e0-b79b-d2c68e68d380",Admin:"878c42b0-9a50-11e6-c537-6bf8e9ab02ee",System:"3e32c5fa-ac9c-4d39-8b4b-4db3e576b3c3"};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);return(n||i)&&e}))}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);return(n||i)&&e}))}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);return(i||o)&&n&&e}))}}class Q{constructor(t){this.func=t,this.onRunChosen=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.allRunsFetch=new f.Subject,this.historyTab=e.div(),this.favTab=e.div(),this.sharedTab=e.div(),this.tabs=e.tabControl({HISTORY:e.box(this.historyTab),FAVORITES:e.box(this.favTab),SHARED:e.box(this.sharedTab)}),this.filterPane=e.div(),this._root=e.divV([e.panel([e.h2("History"),this.filterPane]),e.element("div","splitbar-horizontal"),this.tabs.root],{style:{width:"100%",height:"100%"}}),this.myCards=[],this.favoriteCards=[],this.sharedCards=[],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 g.pullRunsByName(this.func.name,[],{order:"started"},["session.user","options"])).reverse();this.store.allRuns.next(t),e.setUpdateIndicator(this.root,!1)}))));const n=t=>{t.options.isFavorite||t.options.isShared||(t.options.title=null,t.options.description=null)};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.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.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.isFavorite=!1,n(e),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.isShared=!1,n(e),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.allRunsFetch.next(),this.updateFilterPane()}updateFilterPane(){const n=(()=>e.wait((()=>X(this,void 0,void 0,(function*(){const n=new f.Subject,i=e.stringInput("Search","",(t=>n.next(t)));o.debounce(n.asObservable(),600).subscribe((()=>{this.store.filteringOptions.text=i.stringValue,this.myRunsFilter.next(),this.favRunsFilter.next(),this.sharedRunsFilter.next()}));const s=e.dateInput("Started after",Z()().subtract(1,"week"),(t=>{this.store.filteringOptions.startedAfter=t,this.myRunsFilter.next(),this.favRunsFilter.next(),this.sharedRunsFilter.next()})),r=Object.values(J),a=(yield t.dapi.users.list()).filter((t=>!r.includes(t.id))),l=e.choiceInput("Author","Anyone",["Anyone",...a],(t=>{this.store.filteringOptions.author="Anyone"===t?void 0:t,this.sharedRunsFilter.next()}));l.root.style.display="none",s.addPatternMenu("datetime");const d=e.divV([i,s,l],"ui-form ui-form-wide ui-form-left");return d.style.padding="0px",this.tabs.onTabChanged.subscribe((()=>{const t=this.tabs.currentPane.name;"HISTORY"===t&&(s.root.style.removeProperty("display"),l.root.style.display="none"),"FAVORITES"===t&&(s.root.style.removeProperty("display"),l.root.style.display="none"),"SHARED"===t&&(s.root.style.removeProperty("display"),l.root.style.removeProperty("display"))})),d})))))();this.filterPane.replaceWith(n),this.filterPane=n}showDeleteRunDialog(t){e.dialog({title:"Delete run"}).add(e.divText("The deleted run is impossible to restore. Are you sure?")).onOK((()=>X(this,void 0,void 0,(function*(){this.beforeRunDeleted.next(t.id),yield g.deleteRun(t),this.afterRunDeleted.next(t.id)})))).show({center:!0})}updateSharedPane(t){const n=t.length>0?this.renderSharedCards(t):e.divText("No runs are marked as shared","no-elements-label");this.sharedTab.replaceWith(n),this.sharedTab=n}updateFavoritesPane(t){const n=t.length>0?this.renderFavoriteCards(t):e.divText("No runs are marked as favorites","no-elements-label");this.favTab.replaceWith(n),this.favTab=n}updateMyPane(t){const n=t.length>0?this.renderHistoryCards(t):e.divText("No runs are found in history","no-elements-label");this.historyTab.replaceWith(n),this.historyTab=n}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("edit",(t=>{t.stopPropagation(),this.showEditDialog(n)}));r.classList.add("cv-funccall-card-hover-icon");const a=e.iconFA("trash-alt",(t=>X(this,void 0,void 0,(function*(){t.stopPropagation(),this.showDeleteRunDialog(n)}))),"Delete the run");a.classList.add("cv-funccall-card-hover-icon");const l=e.iconFA("star",null,"Unfavorite the run");l.classList.add("fas","cv-funccall-card-def-icon");const d=e.iconFA("share-alt",null,"Add to shared");d.classList.add("fas","cv-funccall-card-def-icon"),d.style.color="var(--blue-1)";const c=new Date(n.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"}),u=e.divH([e.divH([o,e.divV([s,e.span([c]),...n.options.description?[e.divText(n.options.description,"description")]:[]],"cv-card-content")]),e.divH([r,a,...n.options.isFavorite?[l]:[],...n.options.isShared?[d]:[]])],"cv-funccall-card");return u.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"))),u.classList.add("clicked")})))),e.tooltip.bind(u,(()=>e.tableFromMap(Object.assign(Object.assign({Author:t.shell.user.toMarkup(),Date:c},n.options.title?{Title:n.options.title}:{}),n.options.description?{Description:n.options.description}:{})))),u}showEditDialog(t){var n,i,o,s;const r=e.dialog({title:"Edit run"});let a=null!==(n=t.options.title)&&void 0!==n?n:"",l=null!==(i=t.options.description)&&void 0!==i?i:"";const d=e.stringInput("Title",a,(t=>{a=t,0===t.length?(d.setTooltip("Title cannot be empty"),setTimeout((()=>d.input.classList.add("d4-invalid")),100),r.getButton("OK").disabled=!0):(d.setTooltip(""),setTimeout((()=>d.input.classList.remove("d4-invalid")),100),r.getButton("OK").disabled=!1)}));let c=null!==(o=t.options.isShared)&&void 0!==o&&o,u=null!==(s=t.options.isFavorite)&&void 0!==s&&s;r.add(e.form([d,e.stringInput("Description",l,(t=>{l=t})),e.boolInput("Favorites",u,(t=>u=t)),e.boolInput("Share",c,(t=>c=t))])).onOK((()=>X(this,void 0,void 0,(function*(){if((t=yield g.loadRun(t.id)).options.title=a,t.options.description=l,c===t.options.isShared&&u===t.options.isFavorite){yield g.saveRun(t);const e=this.store.allRuns.value.find((e=>e.id===t.id));return e.options.title=t.options.title,e.options.description=t.options.description,void this.store.allRuns.next(this.store.allRuns.value)}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)),u&&!t.options.isFavorite&&(t.options.isFavorite=u,e.setUpdateIndicator(this.tabs.root,!0),yield this.addRunToFavorites(t),e.setUpdateIndicator(this.tabs.root,!1)),!u&&t.options.isFavorite&&(t.options.isFavorite=u,e.setUpdateIndicator(this.tabs.root,!0),yield this.removeRunFromFavorites(t),e.setUpdateIndicator(this.tabs.root,!1))})))).show({center:!0}),d.fireChanged()}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%"}})}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.title=null,e.options.description=null,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("a4b45840-9a50-11e6-9cc9-8546b8bf62e6"),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.title=null,e.options.description=null,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 tt;!function(t){t.fileInput=function(t="Drag-n-drop here",e=null,n=null,i=N){return new j(t,e,n,i)},t.historyInput=function(t,e,n,i,o=[]){return new G(t,e,n,i,o)},t.historyPanel=function(t){return new Q(t)}}(tt||(tt={}));var et=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 nt=new URL(t.shell.startUri);class it extends o.ViewBase{constructor(n,i={historyEnabled:!0,isTabbed:!1}){super(),this.funcName=n,this.options=i,this._type="function",this.funcCallReplaced=new f.Subject,this.onFuncCallReady=new f.BehaviorSubject(!1),this.exportConfig=null,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.onFuncCallReady.subscribe({complete:()=>{this.changeViewName(this.funcCall.func.friendlyName),this.build()}}),this.linkFunccall(t.functions.getCurrentCall()),this.init()}changeViewName(t){var n;this.name=t,null===(n=document.querySelector("div.d4-ribbon-name"))||void 0===n||n.replaceChildren(e.span([t]))}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){var e,n,i;const o=null===(e=this._funcCall)||void 0===e?void 0:e.options.isHistorical;this._funcCall=t,this.options.isTabbed||(t.options.isHistorical?(o?this.changeViewName(`${this.name.substring(0,this.name.indexOf(" — ")>0?this.name.indexOf(" — "):void 0)} — ${null!==(i=t.options.title)&&void 0!==i?i:new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}`):this.changeViewName(`${this.name} — ${null!==(n=t.options.title)&&void 0!==n?n:new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}`),this.path=`?id=${this._funcCall.id}`):(this.path="",this.changeViewName(`${this.name.substring(0,this.name.indexOf(" — ")>0?this.name.indexOf(" — "):void 0)}`))),this.funcCallReplaced.next(!0)}loadFuncCallById(){return et(this,void 0,void 0,(function*(){const n=nt.searchParams.get("id");if(e.setUpdateIndicator(this.root,!0),n&&!this.options.isTabbed)this.linkFunccall(yield this.loadRun(n)),nt.searchParams.delete("id");else{const e=yield t.functions.eval(this.funcName);this.linkFunccall(e.prepare({}))}e.setUpdateIndicator(this.root,!1)}))}init(){return et(this,void 0,void 0,(function*(){yield this.loadFuncCallById(),this.onFuncCallReady.complete()}))}build(){e.empty(this.root),this.root.appendChild(this.buildIO()),this.options.historyEnabled&&this.buildHistoryBlock(),this.buildRibbonMenu(),this.buildRibbonPanels()}buildHistoryBlock(){const t=tt.historyPanel(this.func);return t.onRunChosen.subscribe((t=>et(this,void 0,void 0,(function*(){return this.linkFunccall(yield this.loadRun(t))})))),e.empty(this.historyRoot),this.historyRoot.style.removeProperty("justify-content"),this.historyRoot.style.width="100%",this.historyRoot.append(t.root),t.root}buildRibbonPanels(){var n;const i=[[...this.exportConfig&&this.exportConfig.supportedFormats.length>0?[e.divH([e.comboPopup(e.iconFA("arrow-to-bottom"),this.exportConfig.supportedFormats,(t=>et(this,void 0,void 0,(function*(){return o.Utils.download(this.exportConfig.filename(t),yield this.exportConfig.export(t))}))))])]:[]]];if(null===(n=this.func)||void 0===n?void 0:n.id){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"),i.push([n])}return this.setRibbonPanels(i),i}buildRibbonMenu(){}onBeforeSaveRun(t){return et(this,void 0,void 0,(function*(){}))}onAfterSaveRun(t){return et(this,void 0,void 0,(function*(){}))}saveRun(t){return et(this,void 0,void 0,(function*(){yield this.onBeforeSaveRun(t);const e=yield g.saveRun(t);return e.options.isHistorical=!1,this.linkFunccall(e),this.options.historyEnabled&&this.buildHistoryBlock(),this.options.isTabbed||(this.path=`?id=${e.id}`),yield this.onAfterSaveRun(e),e}))}onBeforeDeleteRun(t){return et(this,void 0,void 0,(function*(){}))}onAfterDeleteRun(t){return et(this,void 0,void 0,(function*(){}))}deleteRun(t){return et(this,void 0,void 0,(function*(){return yield this.onBeforeDeleteRun(t),yield g.deleteRun(t),yield this.onAfterDeleteRun(t),t.id}))}onBeforeLoadRun(){return et(this,void 0,void 0,(function*(){}))}onAfterLoadRun(t){return et(this,void 0,void 0,(function*(){}))}loadRun(t){return et(this,void 0,void 0,(function*(){yield this.onBeforeLoadRun();const e=yield g.loadRun(t);return this.lastCall=e,yield this.onAfterLoadRun(e),e}))}onBeforeRun(t){return et(this,void 0,void 0,(function*(){}))}onAfterRun(t){return et(this,void 0,void 0,(function*(){}))}run(){return et(this,void 0,void 0,(function*(){if(!this.funcCall)throw new Error("The correspoding function is not specified");yield this.onBeforeRun(this.funcCall);const t=o.TaskBarProgressIndicator.create("Calculating...");this.funcCall.newId(),yield this.funcCall.call(),t.close(),yield this.onAfterRun(this.funcCall),this.options.isTabbed||(this.lastCall=yield this.saveRun(this.funcCall))}))}}const ot=html2canvas;var st=n.n(ot),rt=n(410),at={};at.styleTagTransform=M(),at.setAttributes=k(),at.insert=S().bind(null,"head"),at.domAPI=T(),at.insertStyleElement=V(),R()(rt.Z,at),rt.Z&&rt.Z.locals&&rt.Z.locals;var lt=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 dt={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,scatterplot3d: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};class ct extends it{constructor(t,n={historyEnabled:!0,isTabbed:!1}){super(t,n),this.options=n,this.checkDisability=new f.Subject,this.isRunning=!1,this.tabsElem=e.tabControl(),this.dfToViewerMapping={},this.defaultExport=t=>lt(this,void 0,void 0,(function*(){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=new(x().Workbook),i=t=>o.TYPES_SCALAR.has(t),s=t=>t===o.TYPE.DATA_FRAME,r=this.func.inputs.filter((t=>s(t.propertyType))),a=this.func.inputs.filter((t=>i(t.propertyType))),l=this.func.outputs.filter((t=>s(t.propertyType))),d=this.func.outputs.filter((t=>i(t.propertyType))),c=[...e.inputParams.values()],u=[...e.outputParams.values()];if(r.forEach((t=>{const i=t.options.caption||t.name,o=n.addWorksheet(ut(i,pt.INPUT)),s=e.inputs[t.name];ft(o,s)})),a.length){const t=n.addWorksheet("Input scalars");ht(t,a.map((t=>({caption:t.options.caption||t.name,value:e.inputs[t.name],units:t.options.units||""}))))}if(l.forEach((t=>{const i=t.options.caption||t.name,o=n.addWorksheet(ut(i,pt.OUTPUT)),s=e.outputs[t.name];ft(o,s)})),d.length){const t=n.addWorksheet("Output scalars");ht(t,d.map((t=>({caption:t.options.caption||t.name,value:e.outputs[t.name],units:t.options.units||""}))))}const p=this.tabsElem;for(const t of this.tabsLabels)if(p.currentPane=p.getPane(t),yield new Promise((t=>setTimeout(t,100))),"Input"===t)for(const t of c.filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME))){const i=this.dfToViewerMapping[t.name].filter((t=>t.type!==o.VIEWER.GRID)).filter((t=>Object.values(dt).includes(t.type))),s=r.find((e=>e.name===t.name)),a=s.options.caption||t.name,l=e.inputs[s.name];for(const[t,e]of i.entries())yield mt(n,n.getWorksheet(ut(a,pt.INPUT)),e.root,l.columns.length+2,t>0?Math.ceil(i[t-1].root.clientHeight/20)+1:0)}else for(const i of u.filter((e=>e.property.propertyType===o.TYPE.DATA_FRAME&&("Output"===t&&"Misc"===e.property.category||"Output"===e.property.category||"Output"!==t&&e.property.category===t)))){const t=this.dfToViewerMapping[i.property.name].filter((t=>t.type!==o.VIEWER.GRID)).filter((t=>Object.values(dt).includes(t.type))),s=l.find((t=>t.name===i.property.name)),r=s.options.caption||i.property.name,a=e.outputs[s.name];for(const[e,i]of t.entries())if(i.type===o.VIEWER.STATISTICS){const i=a.columns.length,s=o.DataFrame.fromColumns([o.Column.string("Name",i).init((t=>a.columns.byIndex(t).name)),o.Column.int("Values",i).init((t=>a.columns.byIndex(t).stats.valueCount)),o.Column.int("Nulls",i).init((t=>a.columns.byIndex(t).stats.missingValueCount)),o.Column.float("Min",i).init((t=>a.columns.byIndex(t).stats.min)),o.Column.float("Max",i).init((t=>a.columns.byIndex(t).stats.max)),o.Column.float("Avg",i).init((t=>a.columns.byIndex(t).stats.avg)),o.Column.float("Stdev",i).init((t=>a.columns.byIndex(t).stats.stdev))]);ft(n.getWorksheet(ut(r,pt.OUTPUT)),s,a.columns.length+2,e>0?Math.ceil(t[e-1].root.clientHeight/20)+1:0)}else yield mt(n,n.getWorksheet(ut(r,pt.OUTPUT)),i.root,a.columns.length+2,e>0?Math.ceil(t[e-1].root.clientHeight/20)+1:0)}const h=yield n.xlsx.writeBuffer();return new Blob([h],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"})})),this.exportConfig={supportedExtensions:this.defaultSupportedExportExtensions(),supportedFormats:this.defaultSupportedExportFormats(),export:this.defaultExport,filename:this.defaultExportFilename},this.basePath=`scripts/${this.funcCall.func.id}/view`}static fromFuncCall(t,e={historyEnabled:!0,isTabbed:!1}){return new this(t.func.nqName,e)}onAfterRun(t){this.tabsElem.root.style.removeProperty("display"),this.tabsElem.panes.forEach((t=>{t.header.style.removeProperty("display")}));const e=this.tabsElem.panes.find((t=>"Input"!==t.name));return e&&(this.tabsElem.currentPane=e),Promise.resolve()}buildIO(){const t=this.buildInputBlock();e.tools.handleResize(t,(e=>{e<350?A()(t.firstChild).addClass("ui-form-condensed"):A()(t.firstChild).removeClass("ui-form-condensed")}));const n=this.buildOutputBlock();n.style.height="100%",n.style.width="100%",this.tabsElem.root.style.display="none",this.tabsElem.getPane("Input")&&this.tabsElem.panes.forEach((t=>{t.header.style.display="none"}));const i=e.splitH([t,e.panel([n],{style:{"padding-top":"0px"}})],null,!0);return i.style.padding="0 12px",t.parentElement.style.maxWidth="450px",i}buildInputBlock(){return this.renderRunSection()}buildOutputBlock(){this.tabsElem.root.style.width="100%",this.tabsLabels.forEach((n=>{const i=this.categoryToParamMap[n].filter((t=>t.propertyType===o.TYPE.DATA_FRAME)),s=this.categoryToParamMap[n].filter((t=>t.propertyType!==o.TYPE.DATA_FRAME)),r=i.map((t=>void 0!==t.options.viewer?JSON.parse(t.options.viewer,((t,e)=>"true"===e||"false"===e?JSON.parse(e):e)):[])),a=i.map(((i,s)=>{var a;let l=0;r[s].forEach(((t,e)=>{const n=r[s][e].block;l+=n?parseInt(n):0}));const d=Promise.all(r[s].map((e=>lt(this,void 0,void 0,(function*(){var n,s,r,a,l;const d=null!==(l=null!==(r=null===(s=null===(n=this.funcCall)||void 0===n?void 0:n.outputs[i.name])||void 0===s?void 0:s.value)&&void 0!==r?r:null===(a=this.funcCall.inputParams[i.name])||void 0===a?void 0:a.value)&&void 0!==l?l:t.data.demo.demog(1),c=dt[e.type]?o.Viewer.fromType(dt[e.type],d):yield d.plot.fromType(e.type);return c.setOptions(e),this.dfToViewerMapping[i.name]?this.dfToViewerMapping[i.name].push(c):this.dfToViewerMapping[i.name]=[c],c})))));d.then((t=>{const e=()=>{var e;const n=null!==(e=this.funcCall.outputParams[i.name])&&void 0!==e?e:this.funcCall.inputParams[i.name];n.onChanged.subscribe((()=>{t.forEach((t=>lt(this,void 0,void 0,(function*(){if(Object.values(dt).includes(t.type))t.dataFrame=n.value;else{const e=yield n.value.plot.fromType(t.type);t.root.replaceWith(e.root),t=e}}))))}))};e(),this.funcCallReplaced.subscribe(e)}));const c=null!==(a=i.options.caption)&&void 0!==a?a:i.name,u=e.wait((()=>lt(this,void 0,void 0,(function*(){const t=yield d;return e.divH(yield Promise.all(t.map((t=>t.root),{style:{"flex-wrap":"wrap"}})))}))));if("Input"===n){const t=()=>{var t;(null!==(t=this.funcCall.outputParams[i.name])&&void 0!==t?t:this.funcCall.inputParams[i.name]).onChanged.subscribe((()=>{this.tabsElem.root.style.removeProperty("display")}))};t(),this.funcCallReplaced.subscribe(t)}return e.divV([e.h2(c,Object.assign({},s>0?{style:{"margin-top":"0px"}}:{})),u],{style:Object.assign({},l>0?{width:`${l}%`}:{width:"100%"})})})),l=()=>{const t=o.HtmlTable.create(s,(t=>{var e;return[t.name,null===(e=this.funcCall)||void 0===e?void 0:e.outputs[t.name],t.options.units]})).root;return t.style.maxWidth="400px",t};let d=l();s.forEach((t=>{const e=()=>{this.funcCall.outputParams[t.name].onChanged.subscribe((()=>{const t=l();d.replaceWith(t),d=t}))};e(),this.funcCallReplaced.subscribe(e)}));const c=[];let u=0,p=e.divH([],{style:{"margin-bottom":"25px"}});a.forEach(((t,n)=>{const i=parseInt(t.style.width);u+i===100?(p.append(t),c.push(p),p=e.divH([]),u=0):u+i<100?(p.append(t),u+=i):(c.push(p),p=e.divH([]),p.append(t),u=i),n===a.length-1&&c.push(p)})),this.tabsElem.addPane(n,(()=>e.divV([...c,...s.length?[e.h2("Scalar values")]:[],d])))}));const n=e.box();return n.append(this.tabsElem.root),n}onAfterLoadRun(t){return lt(this,void 0,void 0,(function*(){r()(this.funcCall.outputParams.values()).forEach((e=>{this.funcCall.setParamValue(e.name,t.outputs[e.name])})),r()(this.funcCall.inputParams.values()).forEach((e=>{this.funcCall.setParamValue(e.name,t.inputs[e.name])})),this.tabsElem.root.style.removeProperty("display"),this.tabsElem.panes.forEach((t=>{t.header.style.removeProperty("display")}))}))}get dfParams(){return[...this.func.inputs.filter((t=>t.propertyType==o.TYPE.DATA_FRAME)),...this.func.outputs.filter((t=>t.propertyType==o.TYPE.DATA_FRAME))]}get dfOutputParams(){return this.func.outputs.filter((t=>t.propertyType==o.TYPE.DATA_FRAME))}get isInputPanelRequired(){var t;return(null===(t=this.func)||void 0===t?void 0:t.inputs.some((t=>t.propertyType==o.TYPE.DATA_FRAME&&null!=t.options.viewer)))||!1}get outUniqueParamCategories(){return[...new Set(this.func.outputs.map((t=>t.category)))]}get outputTabsLabels(){return[...this.outUniqueParamCategories,...this.outUniqueParamCategories.find((t=>"Misc"===t||"Output"===t))?["Output"]:[]]}get tabsLabels(){return Object.keys(this.categoryToParamMap)}get categoryToParamMap(){const t={};return this.isInputPanelRequired&&this.func.inputs.filter((t=>t.propertyType==o.TYPE.DATA_FRAME&&null!=t.options.viewer)).forEach((e=>t.Input?t.Input.push(e):t.Input=[e])),this.func.outputs.forEach((e=>{const n="Misc"===e.category?"Output":e.category;t[n]?t[n].push(e):t[n]=[e]})),t}run(){return lt(this,void 0,void 0,(function*(){if(!this.funcCall)throw new Error("The correspoding function is not specified");yield this.onBeforeRun(this.funcCall);const t=o.TaskBarProgressIndicator.create("Calculating...");this.funcCall.newId(),yield this.funcCall.call(),t.close(),yield this.onAfterRun(this.funcCall),this.lastCall=this.options.isTabbed?this.funcCall.clone():yield this.saveRun(this.funcCall)}))}doRun(){return lt(this,void 0,void 0,(function*(){this.isRunning=!0,this.checkDisability.next();try{yield this.run()}catch(e){t.shell.error(e)}finally{this.isRunning=!1,this.checkDisability.next()}}))}renderRunSection(){const n=e.bigButton("Run",(()=>lt(this,void 0,void 0,(function*(){return yield this.doRun()})))),i=(e.button("Open script",(()=>lt(this,void 0,void 0,(function*(){window.open(`${window.location.origin}/script/${this.func.id}`,"_blank")})))),e.div([n]));e.tooltip.bind(i,(()=>n.disabled?this.isRunning?"Computations are in progress":"Some inputs are invalid":"")),this.checkDisability.subscribe((()=>{const t=r()(this.funcCall.inputs.values()).every((t=>null!=t))&&!this.isRunning;n.disabled=!t}));const s=e.divV([],"ui-form");let a="Misc";r()(this.funcCall.inputParams.values()).filter((t=>!!t)).forEach((i=>{var r,l,d;const c=i.property;if("file"===c.propertyType.toString()){const t=tt.fileInput(null!==(r=c.caption)&&void 0!==r?r:c.name,null,(t=>{this.funcCall.inputs[c.name]=t,this.checkDisability.next()}));c.category!==a&&s.append(e.h2(c.category)),this.checkDisability.next(),s.append(t.root)}else{let r=c.propertyType===o.TYPE.DATA_FRAME?e.tableInput(null!==(l=c.caption)&&void 0!==l?l:c.name,null,t.shell.tables):e.input.forProperty(c);r.input.onkeydown=t=>lt(this,void 0,void 0,(function*(){"Enter"==t.key&&(yield this.doRun())})),r.captionLabel.firstChild.replaceWith(e.span([null!==(d=c.caption)&&void 0!==d?d:c.name])),c.options.units&&r.addPostfix(c.options.units);const u=()=>{var t,e,n,o;r.value=null!==(e=null!==(t=this.funcCall.inputs[i.name])&&void 0!==t?t:c.defaultValue)&&void 0!==e?e:null,this.funcCall.inputs[i.name]=null!==(o=null!==(n=this.funcCall.inputs[i.name])&&void 0!==n?n:c.defaultValue)&&void 0!==o?o:null};u(),this.funcCallReplaced.subscribe(u),r.onChanged((()=>{r.property||(this.funcCall.inputs[i.name]=r.value)})),r.onInput((()=>{this.funcCall.inputs[i.name]=r.value,null===r.value?setTimeout((()=>r.input.classList.add("d4-invalid")),100):r.input.classList.remove("d4-invalid"),this.checkDisability.next()})),i.onChanged.subscribe((()=>{var n;const s=this.funcCall.inputs[i.name];if(i.property.propertyType===o.TYPE.DATA_FRAME){const o=e.tableInput(null!==(n=c.caption)&&void 0!==n?n:c.name,s,[...t.shell.tables,s]);r.root.replaceWith(o.root),r=o,r.onInput((()=>{this.funcCall.inputs[i.name]=r.value,null===r.value?setTimeout((()=>r.input.classList.add("d4-invalid")),100):r.input.classList.remove("d4-invalid"),this.checkDisability.next()}))}else r.notify=!1,r.value=s,r.notify=!0;this.checkDisability.next()})),c.category!==a&&s.append(e.h2(c.category)),null===r.value&&(n.disabled=!0),s.append(r.root)}a=c.category}));const l=e.buttonsInput([i]);return s.append(l),s.classList.remove("ui-panel"),s.style.paddingTop="0px",s.style.paddingLeft="0px",e.div([s])}}const ut=(t,e)=>{const n=`${e} - ${t}`;return n.length>31?t.substring(0,32):n};var pt;!function(t){t.INPUT="Input",t.OUTPUT="Output"}(pt||(pt={}));const ht=(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)),"Parameter".length),t.getColumn(2).width=1.2*Math.max(...e.map((t=>t.value.toString().length)),"Value".length),t.getColumn(3).width=1.2*Math.max(...e.map((t=>t.units.toString().length)),"Units".length)},ft=(t,e,n=0,i=0)=>{for(let o=0;o<e.columns.names().length;o++)t.getCell(1+i,1+o+n).value=e.columns.byIndex(o).name,t.getColumn(1+o+n).width=1.2*Math.max(...e.columns.byIndex(o).categories.map((t=>t.toString().length)),e.columns.byIndex(o).name.length);for(let o=0;o<e.columns.length;o++)for(let s=0;s<e.rowCount;s++)t.getCell(s+2+i,1+n+o).value=e.columns.byIndex(o).get(s)},mt=(t,e,n,i,o=0)=>lt(void 0,void 0,void 0,(function*(){const s=yield st()(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 vt=n(433),gt={};gt.styleTagTransform=M(),gt.setAttributes=k(),gt.insert=S().bind(null,"head"),gt.domAPI=T(),gt.insertStyleElement=V(),R()(vt.Z,gt),vt.Z&&vt.Z.locals&&vt.Z.locals;class yt{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 At=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 bt extends o.ViewBase{constructor(){super(),this.store=new yt,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",(()=>At(this,void 0,void 0,(function*(){return yield this.generate()})))),n=e.bigButton("Save",(()=>At(this,void 0,void 0,(function*(){return yield this.save()})))),i=e.bigButton("Open",(()=>At(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))})),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,d,e.divH([t],{style:{"justify-content":"flex-end"}})],"ui-form");let u=e.divText(this.store.scriptText.value),p=e.info(this.store.infoText.value);const h=e.panel([e.h3("Script text"),u,p,e.divH([n,i],{style:{"justify-content":"flex-end"}})],{style:{display:"none"}});this.store.scriptText.subscribe((t=>{const n=e.divText(t);u.replaceWith(n),u=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 At(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 At(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 Ct=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 xt=!1;const wt=new o.Package;function It(){const e=new bt;e.name="Import Script Gen",t.shell.addView(e),e.root.classList.remove("ui-panel")}function Rt(){return new u}function Et(t){return ct.fromFuncCall(t,{historyEnabled:!0,isTabbed:!1})}function Tt(t){return ct.fromFuncCall(t,{historyEnabled:!1,isTabbed:!0})}function Ft(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 St(){console.log("hof");let e=Ft(o.Func.byName("Sin"));e.parentCall=t.functions.getCurrentCall(),t.shell.addView(e)}function Bt(){var n,i,s;console.log("hof2");let r=Ft(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 kt(n){return Ct(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: ${Pt("auth")}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '${JSON.stringify(i)}'`,r=`\nvar myHeaders = new Headers();\nmyHeaders.append("Authorization", "${Pt("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 Pt(t){let e=document.cookie.match(new RegExp("(?:^|; )"+t.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):void 0}function Vt(){}function _t(){xt||(o.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((()=>Ct(this,void 0,void 0,(function*(){return(yield kt(n)).root})))))))})),xt=!0)}function Mt(){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("/");if(t.shell.addView(e),i.length>3){let e=t.functions.getCurrentCall();t.dapi.functions.filter(`shortName = "${i[3]}" and #model`).list().then((t=>{1==t.length&&c.openModel(t[0],e)}))}}else t.shell.v=e}function Ot(e,n){return Ct(this,void 0,void 0,(function*(){if(yield h(e),null!=n||""!=n)throw n;return t.data.demo.demog()}))}function Dt(){o.Func.find({name:"computationTest"})[0]}})(),compute=i})();
1
+ var compute;(()=>{"use strict";var t={556:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(537),o=n.n(i),s=n(645),r=n.n(s)()(o());r.push([t.id,".cv-drop-area {\n position: relative;\n}\n\n.ui-form .cv-drop-area .icon {\n\tpadding-top: 10px;\n}\n\n.ui-form-condensed .cv-drop-area .icon {\n\tpadding-top: 0px;\n position: absolute;\n top: 35px;\n right: 10px;\n}\n\n.cv-drop-area .default {\n color: var(--grey-2);\n}\n\n.cv-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.cv-drop-area .error {\n color: var(--red-3);\n}\n\n.cv-drop-area .success {\n color: var(--grey-6);\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/css/file-input.css"],names:[],mappings:"AAAA;EACE,kBAAkB;AACpB;;AAEA;CACC,iBAAiB;AAClB;;AAEA;CACC,gBAAgB;EACf,kBAAkB;EAClB,SAAS;EACT,WAAW;AACb;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,gCAAgC;EAChC,gCAAgC;EAChC,oBAAoB;AACtB;;AAEA;EACE,mBAAmB;AACrB;;AAEA;EACE,oBAAoB;AACtB",sourcesContent:[".cv-drop-area {\n position: relative;\n}\n\n.ui-form .cv-drop-area .icon {\n\tpadding-top: 10px;\n}\n\n.ui-form-condensed .cv-drop-area .icon {\n\tpadding-top: 0px;\n position: absolute;\n top: 35px;\n right: 10px;\n}\n\n.cv-drop-area .default {\n color: var(--grey-2);\n}\n\n.cv-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.cv-drop-area .error {\n color: var(--red-3);\n}\n\n.cv-drop-area .success {\n color: var(--grey-6);\n}"],sourceRoot:""}]);const a=r},400:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(537),o=n.n(i),s=n(645),r=n.n(s)()(o());r.push([t.id,'.no-elements-label {\n margin: 8px;\n}\n\n.arrow-box {\n position: relative;\n}\n\n.arrow-box:before {\n left: -6px;\n top: 55px;\n content: "";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n background-color: white;\n\n transform-origin: center;\n transform: rotate(-135deg);\n box-shadow: -4px 4px 0px 4.5px white, #4d5261 0px 0px 5px;;\n\n border: 5px solid black;\n border-color: transparent transparent #FFFFFF #FFFFFF;\n\n margin-top: -21px;\n}',"",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/css/history-input.css"],names:[],mappings:"AAAA;IACI,WAAW;AACf;;AAEA;IACI,kBAAkB;AACtB;;AAEA;IACI,UAAU;IACV,SAAS;IACT,WAAW;IACX,SAAS;IACT,QAAQ;IACR,kBAAkB;IAClB,oBAAoB;IACpB,uBAAuB;;IAEvB,wBAAwB;IACxB,0BAA0B;IAC1B,yDAAyD;;IAEzD,uBAAuB;IACvB,qDAAqD;;IAErD,iBAAiB;AACrB",sourcesContent:['.no-elements-label {\n margin: 8px;\n}\n\n.arrow-box {\n position: relative;\n}\n\n.arrow-box:before {\n left: -6px;\n top: 55px;\n content: "";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n background-color: white;\n\n transform-origin: center;\n transform: rotate(-135deg);\n box-shadow: -4px 4px 0px 4.5px white, #4d5261 0px 0px 5px;;\n\n border: 5px solid black;\n border-color: transparent transparent #FFFFFF #FFFFFF;\n\n margin-top: -21px;\n}'],sourceRoot:""}]);const a=r},276:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(537),o=n.n(i),s=n(645),r=n.n(s)()(o());r.push([t.id,".cv-funccall-card:hover {\n box-shadow: 0px 0px 3px #b8bac0;\n cursor: pointer;\n}\n\n.cv-funccall-card {\n margin: 2px 1px;\n padding: 5px;\n justify-content: space-between;\n}\n\n.cv-funccall-card.clicked {\n border: 1px solid var(--blue-1);\n}\n\n.cv-funccall-card-hover-icon {\n display: none;\n}\n\n.cv-funccall-card:hover .cv-funccall-card-hover-icon {\n display: flex;\n}\n\n.cv-funccall-card-def-icon {\n display: flex;\n}\n\n.cv-funccall-card:hover .cv-funccall-card-def-icon {\n display: none;\n}\n\n.cv-funccall-card .cv-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.cv-funccall-card-def-icon {\n margin: 5px;\n}\n\n.cv-funccall-card-hover-icon {\n margin: 5px;\n}\n\n.cv-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.cv-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/css/history-panel.css"],names:[],mappings:"AAAA;IACI,+BAA+B;IAC/B,eAAe;AACnB;;AAEA;IACI,eAAe;IACf,YAAY;IACZ,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,WAAW;AACf;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,kBAAkB;IAClB,oBAAoB;AACxB;;AAEA;IACI,oBAAoB;IACpB,gBAAgB;AACpB",sourcesContent:[".cv-funccall-card:hover {\n box-shadow: 0px 0px 3px #b8bac0;\n cursor: pointer;\n}\n\n.cv-funccall-card {\n margin: 2px 1px;\n padding: 5px;\n justify-content: space-between;\n}\n\n.cv-funccall-card.clicked {\n border: 1px solid var(--blue-1);\n}\n\n.cv-funccall-card-hover-icon {\n display: none;\n}\n\n.cv-funccall-card:hover .cv-funccall-card-hover-icon {\n display: flex;\n}\n\n.cv-funccall-card-def-icon {\n display: flex;\n}\n\n.cv-funccall-card:hover .cv-funccall-card-def-icon {\n display: none;\n}\n\n.cv-funccall-card .cv-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.cv-funccall-card-def-icon {\n margin: 5px;\n}\n\n.cv-funccall-card-hover-icon {\n margin: 5px;\n}\n\n.cv-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.cv-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}"],sourceRoot:""}]);const a=r},410:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(537),o=n.n(i),s=n(645),r=n.n(s)()(o());r.push([t.id,".ui-input-root > input.ui-input-editor.disabled:focus {\n outline: none;\n border-bottom: 1px solid var(--grey-2)!important;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/css/rich-function-view.css"],names:[],mappings:"AAAA;IACI,aAAa;IACb,gDAAgD;AACpD",sourcesContent:[".ui-input-root > input.ui-input-editor.disabled:focus {\n outline: none;\n border-bottom: 1px solid var(--grey-2)!important;\n}\n"],sourceRoot:""}]);const a=r},433:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(537),o=n.n(i),s=n(645),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},645: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 c=[].concat(t[d]);i&&r[c[0]]||(void 0!==s&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=s),n&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=n):c[2]=n),o&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=o):c[4]="".concat(o)),e.push(c))}},e}},537: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," */"),r=n.sources.map((function(t){return"/*# sourceURL=".concat(n.sourceRoot||"").concat(t," */")}));return[e].concat(r).concat([s]).join("\n")}return[e].join("\n")}},379: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],c=s[d]||0,u="".concat(d," ").concat(c);s[d]=c+1;var p=n(u),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)e[p].references++,e[p].updater(h);else{var f=o(h,i);i.byIndex=a,e.splice(a,0,{identifier:u,updater:f,references:1})}r.push(u)}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 c=n(s[d]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}s=l}}},569: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)}},216:t=>{t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},565:(t,e,n)=>{t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},795:t=>{t.exports=function(t){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)}}}},589: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:()=>St,PipelineStepEditor:()=>kt,RichFunctionViewEditor:()=>Bt,_package:()=>Et,autostart:()=>Dt,computationTest:()=>jt,functionParametersGrid:()=>Pt,hof:()=>Vt,hof2:()=>_t,importScriptGenerator:()=>Ft,init:()=>Lt,modelCatalog:()=>Nt,openModelFromFuncall:()=>Tt,renderRestPanel:()=>Mt,testComputationView:()=>$t});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 c,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 c).isApplicable(e.sender)&&(t.shell.windows.showProperties=!0,window.localStorage.setItem("ModelCatalogShowProperties","false"),a.unsubscribe())})))}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 c 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")}getVideoBackgroundUrl(t){let e=t.options["video-preview"];if(null==e)return"";if(e.startsWith("http://")||e.startsWith("https://"))return e;if(t instanceof o.Script)return null!=t.options.icon?`${t.options.icon.substring(0,t.options.icon.lastIndexOf("/"))}/${e}`:"";let n=t.package.getIconUrl();return n=n.substring(0,n.lastIndexOf("/")),`${n}/${e}`}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=>{c.openModel(t)},n}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)])]);if(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"]})),null!=t.options.video||null!=t.options.education){let i=e.link("Education materials",t.options.education);e.setDisplay(i,null!=t.options.education);let o=e.div(e.icons.play((()=>{window.open(t.options.video,"_blank")})),"model-catalog-video");e.setDisplay(o,null!=t.options.video),o.style.backgroundImage=`url('${this.getVideoBackgroundUrl(t)}')`,n.addPane("Documentation",(()=>e.divV([i,o],{style:{lineHeight:"150%"}})),!0)}return n.end(),n.root}renderDetails(t){let n=e.markdown(`**Status:** ${t.options["dev.status"]}`);return e.setDisplay(n,null!=t.options["dev.status"]),e.divV([e.markdown(`**Description: ** ${t.description}`),n,e.markdown("**Tags:**"),e.tags(t),e.markdown("**Documentation:**")],{style:{lineHeight:"150%"}})}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 o=e.bind(t,e.h2(i));return o.ondblclick=e=>{c.openModel(t)},o}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=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)}))}))}}class u extends o.JsViewer{constructor(){super()}onFrameAttached(t){this.dataFrame=t,this.render()}onTableAttached(){this.render()}render(){if(!this.dataFrame||this.dataFrame.rowCount<=0)return void(this.root.innerHTML="");const t=this.dataFrame,n="isOutlier",i="Rationale",s="Count",r="isConfirmed";t.columns.byName(n)||t.columns.add(o.Column.fromBitSet(n,o.BitSet.create(t.rowCount,(()=>!1)))),t.columns.byName(i)||t.columns.add(o.Column.fromStrings(i,Array.from({length:t.rowCount},(()=>""))));const a=()=>o.DataFrame.fromColumns([o.Column.fromStrings(i,[]),o.Column.fromInt32Array(s,new Int32Array([])),o.Column.fromStrings("Actions",[]),o.Column.fromBitSet(r,o.BitSet.create(0,(()=>!1)))]),l=o.Viewer.grid(a());l.root.style.width="100%",l.root.style.minWidth="230px",l.columns.setVisible([i,s,"Actions"]),l.onCellPrepare((s=>{var a,d,c;s.isTableCell&&("Actions"===s.gridColumn.name&&(s.gridColumn.cellType="html",s.style.element=e.divH([...(null===(a=s.grid.dataFrame)||void 0===a?void 0:a.get(r,s.gridRow))?[(c=null===(d=s.grid.dataFrame)||void 0===d?void 0:d.get(i,s.gridRow),e.div(e.icons.delete((()=>{for(let e=0;e<t.rowCount;e++)t.columns.byName(i).get(e)===c&&(t.columns.byName(i).set(e,"",!1),t.columns.byName(n).set(e,!1,!1));t.fireValuesChanged()}),"Remove the outliers group"),{style:{"text-align":"center",margin:"6px"}}))]:[e.div(e.iconFA("check",(()=>{var e,s;if(!l.dataFrame)return;null===(e=t.col(n))||void 0===e||e.markers.assign("true",o.MARKER_TYPE.OUTLIER);const r=null===(s=l.dataFrame)||void 0===s?void 0:s.cell(l.dataFrame.rowCount-1,i).value;t.selection.getSelectedIndexes().forEach((e=>{t.col(n).set(e,!0,!1),t.col(i).set(e,r,!1)})),t.selection.setAll(!1),t.fireValuesChanged()}),"Confirm the outliers"),{style:{"text-align":"center",margin:"6px"}}),e.div(e.iconFA("times",(()=>{l.dataFrame&&(l.dataFrame.rows.removeAt(l.dataFrame.rowCount-1),t.selection.setAll(!1))}),"Cancel the outliers"),{style:{"text-align":"center",margin:"6px"}})]])))})),l.onCellValueEdited.subscribe((e=>{var n,o;if(!l.dataFrame||e.gridColumn.name!==i)return;if(!l.dataFrame.columns.byName(r).get(e.gridRow))return;const s=new Set;for(let t=0;t<(null===(n=l.dataFrame)||void 0===n?void 0:n.rowCount);t++){const e=null===(o=l.dataFrame)||void 0===o?void 0:o.columns.byName(i).get(t);s.add(e)}for(let n=0;n<t.rowCount;n++){const o=t.columns.byName(i).get(n);""==o||s.has(o)||t.columns.byName(i).set(n,e.cell.value)}}));const d=()=>{if(t.columns.byName(i))for(let e=0;e<t.rowCount;e++)t.columns.byName(n).get(e)?""===t.columns.byName(i).get(e)&&t.columns.byName(i).set(e,"Manual",!1):""!==t.columns.byName(i).get(e)&&t.columns.byName(i).set(e,"",!1);const e={};if(t.columns.byName(i))for(let n=0;n<t.rowCount;n++){const o=t.columns.byName(i).get(n),s=e[o];""!=o&&(s?e[o]++:e[o]=1)}l.dataFrame=a(),l.columns.setVisible([i,s,"Actions"]),Object.keys(e).map((t=>{var n;null===(n=l.dataFrame)||void 0===n||n.rows.addNew([t,e[t],"",!0])}))};t.onDataChanged.subscribe(d),t.onSelectionChanged.subscribe((()=>{if(l.dataFrame&&t.selection.trueCount)if(l.dataFrame.columns.byName(r).toList().some((t=>!1===t)))l.dataFrame.set(s,l.dataFrame.rowCount-1,t.selection.trueCount);else{const e=l.dataFrame.rows.addNew(["Manual",t.selection.trueCount,"",!1]);l.dataFrame.currentCell=l.dataFrame.cell(e.idx,i)}})),t.selection.setAll(!1),d(),this.root.innerHTML="",this.root.appendChild(e.divV([e.divV([l.root],{style:{height:"75%"}})],{style:{height:"100%"}}))}}var p;function h(t){return e=this,n=void 0,o=function*(){yield new Promise((e=>setTimeout(e,t)))},new((i=void 0)||(i=Promise))((function(t,s){function r(t){try{l(o.next(t))}catch(t){s(t)}}function a(t){try{l(o.throw(t))}catch(t){s(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(r,a)}l((o=o.apply(e,n||[])).next())}));var e,n,i,o}!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(p||(p={}));const f=rxjs;var m=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const v=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 g;!function(e){const n={};e.loadChildRuns=function(e){return m(this,void 0,void 0,(function*(){const i=yield t.dapi.functions.calls.allPackageVersions().find(e);i.options.isHistorical=!0;const o=yield t.dapi.functions.calls.allPackageVersions().filter(`options.parentCallId="${e}"`).list();return yield Promise.all(o.map((e=>m(this,void 0,void 0,(function*(){var i;const o=e.func.id,s=null!==(i=n[o])&&void 0!==i?i:yield t.dapi.functions.allPackageVersions().find(o);n[o]||(n[o]=s),e.func=s}))))),{parentRun:i,childRuns:o}}))},e.loadRun=function(e,i=!1){var s;return m(this,void 0,void 0,(function*(){const a=yield t.dapi.functions.calls.allPackageVersions().include("inputs, outputs, session.user").find(e),l=a.func.id,d=null!==(s=n[l])&&void 0!==s?s:yield t.dapi.functions.allPackageVersions().find(l);if(n[l]||(n[l]=d),a.func=d,a.options.isHistorical=!0,!i){const e=r()(a.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const n of e)a.outputs[n.name]=yield t.dapi.tables.getTable(a.outputs[n.name]);const n=r()(a.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const e of n)a.inputs[e.name]=yield t.dapi.tables.getTable(a.inputs[e.name])}return a}))},e.saveRun=function(e){return m(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)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)yield t.dapi.tables.uploadDataFrame(e.inputs[n.name]);return yield t.dapi.functions.calls.allPackageVersions().save(e)}))},e.deleteRun=function(e){return m(this,void 0,void 0,(function*(){yield t.dapi.functions.calls.allPackageVersions().delete(e)}))},e.pullRuns=function(e,n={},i={}){return m(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?v(n.date):"",t.dapi.functions.calls.allPackageVersions().filter(o).include("session.user, options").list(i)}))},e.pullRunsByName=function(e,i=[],s={},a=[]){var l;return m(this,void 0,void 0,(function*(){let d="";for(const t of i){const e=[];t.author&&e.push(`session.user.id="${t.author.id}"`),t.date&&e.push(v(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&&(d+=""===d?`(${n})`:` or (${n})`)}""!==d&&(d=` and (${d})`);const c=yield t.dapi.functions.calls.allPackageVersions().filter(`func.name="${e}"${d}`).include(`${a.join(",")}`).list(s);for(const e of c){const i=e.func.id,o=null!==(l=n[i])&&void 0!==l?l:yield t.dapi.functions.allPackageVersions().find(i);n[i]||(n[i]=o),e.func=o}if(a.includes("inputs")||a.includes("func.params"))for(const e of c){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 c){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 c}))}}(g||(g={}));const y=$;var A=n.n(y);const b=ExcelJS;var C,x=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(x().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 "})))}))}(C||(C={}));var I=n(379),R=n.n(I),E=n(795),T=n.n(E),F=n(569),S=n.n(F),B=n(565),k=n.n(B),P=n(216),V=n.n(P),_=n(589),M=n.n(_),O=n(556),D={};D.styleTagTransform=M(),D.setAttributes=k(),D.insert=S().bind(null,"head"),D.domAPI=T(),D.insertStyleElement=V(),R()(O.Z,D),O.Z&&O.Z.locals&&O.Z.locals;var L=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const N="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class j{constructor(t="Drag-n-drop here",n=null,i=null,s=N){this.initialText=t,this.initialValue=n,this.onValueChanged=i,this.fileType=s,this.uploadedFile$=new f.Subject,this.onFileUploaded=new f.Subject,this.root=e.div(),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"),c=s.pages.length,u=e.divText("1/"+c);return u.style.position="absolute",u.style.left="12px",u.style.color="var(--grey-5)",s.captionHost.style.fontSize="20px",s.captionHost.style.fontWeight="400",s.captionHost.style.margin="6px 0",A()(s.root).find(".d4-command-bar").append(u),A()(a).html("BACK"),A()(l).html("NEXT"),A()(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||A()(d).addClass("disabled"),u.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&&A()(d).removeClass("disabled"),u.textContent=t+"/"+e})),s.show(),!1}))}},this.visibleInput=e.stringInput("Input file",this.initialText,null),this.hiddenInput=document.createElement("input"),this.icon=e.iconFA("cloud-upload",(()=>this.hiddenInput.click())),this.isValid=new f.BehaviorSubject(!0),this.draw(),this.isValid.subscribe((t=>{if(t){this.visibleInput.input.classList.remove("error"),this.visibleInput.input.classList.add("success");const t=e.iconFA("times",(()=>this.reset()));this.icon.replaceWith(t),this.icon=t}else{this.visibleInput.input.classList.remove("success"),this.visibleInput.input.classList.add("error");const t=e.iconFA("redo",(()=>this.hiddenInput.click()));this.icon.replaceWith(t),this.icon=t}})),this.uploadedFile$.subscribe((t=>this.onFileUploaded.next(t))),i&&this.uploadedFile$.subscribe((t=>i(t)))}draw(){this.clear(),["drag","dragenter"].forEach((t=>{document.getElementsByClassName("layout-workarea")[0].addEventListener(t,(t=>{t.stopPropagation()}),!1)})),this.root.style.display="flex",this.root.append((()=>{this.visibleInput.input.readOnly=!0,this.visibleInput.input.classList.add("default");const t=t=>L(this,void 0,void 0,(function*(){if(t&&t.length){if(t.length>1)throw this.isValid.next(!1),new Error("Please specify single input file");if(this.visibleInput.value=t[0].name,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)}else this.uploadedFile$.next(null)}));return this.visibleInput.root.classList.add("cv-drop-area"),this.visibleInput.root.style.width="100%",this.hiddenInput.type="file",this.hiddenInput.addEventListener("change",(()=>L(this,void 0,void 0,(function*(){return yield t(this.hiddenInput.files)}))),!1),["dragenter","dragover","dragleave","drop"].forEach((t=>{this.visibleInput.input.addEventListener(t,(t=>{t.preventDefault(),t.stopPropagation()}),!1)})),["dragenter","dragover"].forEach((t=>{this.visibleInput.input.addEventListener(t,(()=>{this.visibleInput.input.classList.add("drag-n-dropping")}),!1)})),["dragleave","drop"].forEach((t=>{this.visibleInput.input.addEventListener(t,(()=>{this.visibleInput.input.classList.remove("drag-n-dropping")}),!1)})),this.visibleInput.input.addEventListener("drop",(e=>L(this,void 0,void 0,(function*(){const n=e.dataTransfer.files;t(n)}))),!1),this.visibleInput.input.addEventListener("click",(()=>this.hiddenInput.click()),!1),this.visibleInput.root.append(e.div(this.icon,"icon")),this.visibleInput})().root)}reset(){this.visibleInput.input.classList.value="ui-input-editor default";const t=e.iconFA("cloud-upload",(()=>this.hiddenInput.click()));this.icon.replaceWith(t),this.icon=t,this.visibleInput.value="Drag-n-drop here",this.hiddenInput.value="",this.uploadedFile$.next(null)}clear(){e.empty(this.root)}}const W=rxjs.operators;var H=n(400),U={};U.styleTagTransform=M(),U.setAttributes=k(),U.insert=S().bind(null,"head"),U.domAPI=T(),U.insertStyleElement=V(),R()(H.Z,U),H.Z&&H.Z.locals&&H.Z.locals;class G{constructor(n,i,s,r,a=[]){var l;this.label=n,this._funcName=i,this._stringValueFunc=s,this._visibleColumnsForGrid=r,this._visibleColumnsForFilter=a,this.onHistoricalRunChosen=new f.BehaviorSubject(null),this.experimentRunsUpdate=new f.Subject,this.store={experimentRuns:new f.Observable,experimentRunsDf:new f.BehaviorSubject(o.DataFrame.fromColumns([o.Column.fromStrings("Pick",[]),...Object.keys(this._visibleColumnsForGrid).map((t=>o.Column.fromStrings(t,[])))])),isExperimentRunsLoading:new f.Subject,experimentRunData:new f.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._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",(()=>{var t;const n=e.dialog();A()(n.root).addClass("arrow-box"),n.onOK((()=>{})),n.onCancel((()=>{this.onHistoricalRunChosen.next(null)})),A()(n.root).find(".d4-dialog-header").hide(),n.root.style.boxShadow="",A()(n.root).removeClass("ui-form");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",this._historyGrid.columns.byIndex(e).width=100)}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")],{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%",A()(this._historyFilters.root).find(".d4-filter-group-header").hide(),this._visibleColumnsForFilter.length||A()(this._historyFilters.root.parentElement).hide(),n.add(e.divH([e.block([this._historyGrid.root]),e.block([this._historyFilters.root],{style:{"margin-left":"10px",width:"225px",height:"100%"}})])),n.show({x:this._visibleInput.input.getBoundingClientRect().x+this._visibleInput.input.clientWidth+10,y:this._visibleInput.input.getBoundingClientRect().y-30,width:Math.max(this._historyGrid.root.clientWidth+this._historyFilters.root.clientWidth+30,600)})})),this._visibleInput.readOnly=!0,this.store.experimentRuns=this.experimentRunsUpdate.pipe((0,W.tap)((()=>this.toggleLoaderExpRuns(!0))),(0,W.switchMap)((()=>class{static getHistoryRuns(e){return(0,f.from)((()=>{return n=this,i=void 0,s=function*(){return yield g.pullRunsByName(e,[{isShared:!0},{author:t.shell.user}],{order:"started"},["func.params","session.user","options"])},new((o=void 0)||(o=Promise))((function(t,e){function r(t){try{l(s.next(t))}catch(t){e(t)}}function a(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(r,a)}l((s=s.apply(n,i||[])).next())}));var n,i,o,s})())}}.getHistoryRuns(this._funcName).pipe((0,W.catchError)((()=>f.EMPTY)),(0,W.finalize)((()=>this.toggleLoaderExpRuns(!1)))))),(0,W.shareReplay)(1)),this.store.experimentRuns.pipe((0,W.takeUntil)((0,f.from)(new f.Subject))).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),i=t.find((t=>t.id===n));i&&this.onHistoricalRunChosen.next(i)})),this.store.experimentRunsDf.next(e)})),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)}))}get historyGrid(){return this._historyGrid}get historyFilters(){return this._historyFilters}get root(){return this._visibleInput.root}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 Y=dayjs;var Z=n.n(Y),z=n(276),q={};q.styleTagTransform=M(),q.setAttributes=k(),q.insert=S().bind(null,"head"),q.domAPI=T(),q.insertStyleElement=V(),R()(z.Z,q),z.Z&&z.Z.locals&&z.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())}))};const J={Test:"ca1e672e-e3be-40e0-b79b-d2c68e68d380",Admin:"878c42b0-9a50-11e6-c537-6bf8e9ab02ee",System:"3e32c5fa-ac9c-4d39-8b4b-4db3e576b3c3"};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);return(n||i)&&e}))}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);return(n||i)&&e}))}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);return(i||o)&&n&&e}))}}const Q="HISTORY",tt="FAVORITES",et="SHARED";class nt{constructor(t){this.func=t,this.onRunChosen=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.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._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 g.pullRunsByName(this.func.name,[],{order:"started"},["session.user","options"])).reverse();this.store.allRuns.next(t),e.setUpdateIndicator(this.root,!1)}))));const n=t=>{t.options.isFavorite||t.options.isShared||(t.options.title=null,t.options.description=null)};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.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.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.isFavorite=!1,n(e),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.isShared=!1,n(e),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.allRunsFetch.next()}buildFilterPane(n){return e.wait((()=>X(this,void 0,void 0,(function*(){const i=new f.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(J),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",r.addPatternMenu("datetime");const c=e.divV([s,r,d],"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")),c}))))}showDeleteRunDialog(t){e.dialog({title:"Delete run"}).add(e.divText("The deleted run is impossible to restore. Are you sure?")).onOK((()=>X(this,void 0,void 0,(function*(){this.beforeRunDeleted.next(t.id),yield g.deleteRun(t),this.afterRunDeleted.next(t.id)})))).show({center:!0})}updateSharedPane(t){const n=t.length>0?this.renderSharedCards(t):e.divText("No runs are marked as shared","no-elements-label");this.sharedTab.replaceWith(e.divV([this.sharedPaneFilter,e.element("div","splitbar-horizontal"),n])),this.sharedTab=n}updateFavoritesPane(t){const n=t.length>0?this.renderFavoriteCards(t):e.divText("No runs are marked as favorites","no-elements-label");this.favTab.replaceWith(e.divV([this.favoritesPaneFilter,e.element("div","splitbar-horizontal"),n])),this.favTab=n}updateMyPane(t){const n=t.length>0?this.renderHistoryCards(t):e.divText("No runs are found in history","no-elements-label");this.historyTab.replaceWith(e.divV([this.myPaneFilter,e.element("div","splitbar-horizontal"),n])),this.historyTab=n}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("edit",(t=>{t.stopPropagation(),this.showEditDialog(n)}));r.classList.add("cv-funccall-card-hover-icon");const a=e.iconFA("trash-alt",(t=>X(this,void 0,void 0,(function*(){t.stopPropagation(),this.showDeleteRunDialog(n)}))),"Delete the run");a.classList.add("cv-funccall-card-hover-icon");const l=e.iconFA("star",null,"Unfavorite the run");l.classList.add("fas","cv-funccall-card-def-icon");const d=e.iconFA("share-alt",null,"Add to shared");d.classList.add("fas","cv-funccall-card-def-icon"),d.style.color="var(--blue-1)";const c=new Date(n.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"}),u=e.divH([e.divH([o,e.divV([s,e.span([c]),...n.options.description?[e.divText(n.options.description,"description")]:[]],"cv-card-content")]),e.divH([r,a,...n.options.isFavorite?[l]:[],...n.options.isShared?[d]:[]])],"cv-funccall-card");return u.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"))),u.classList.add("clicked")})))),e.tooltip.bind(u,(()=>e.tableFromMap(Object.assign(Object.assign({Author:t.shell.user.toMarkup(),Date:c},n.options.title?{Title:n.options.title}:{}),n.options.description?{Description:n.options.description}:{})))),u}showEditDialog(t){var n,i,o,s;const r=e.dialog({title:"Edit run"});let a=null!==(n=t.options.title)&&void 0!==n?n:"",l=null!==(i=t.options.description)&&void 0!==i?i:"";const d=e.stringInput("Title",a,(t=>{a=t,0===t.length?(d.setTooltip("Title cannot be empty"),setTimeout((()=>d.input.classList.add("d4-invalid")),100),r.getButton("OK").disabled=!0):(d.setTooltip(""),setTimeout((()=>d.input.classList.remove("d4-invalid")),100),r.getButton("OK").disabled=!1)}));let c=null!==(o=t.options.isShared)&&void 0!==o&&o,u=null!==(s=t.options.isFavorite)&&void 0!==s&&s;r.add(e.form([d,e.stringInput("Description",l,(t=>{l=t})),e.boolInput("Favorites",u,(t=>u=t)),e.boolInput("Share",c,(t=>c=t))])).onOK((()=>X(this,void 0,void 0,(function*(){if((t=yield g.loadRun(t.id)).options.title=a,t.options.description=l,!!c==!!t.options.isShared&&!!u==!!t.options.isFavorite){yield g.saveRun(t);const e=this.store.allRuns.value.find((e=>e.id===t.id));return e.options.title=t.options.title,e.options.description=t.options.description,void this.store.allRuns.next(this.store.allRuns.value)}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)),u&&!t.options.isFavorite&&(t.options.isFavorite=u,e.setUpdateIndicator(this.tabs.root,!0),yield this.addRunToFavorites(t),e.setUpdateIndicator(this.tabs.root,!1)),!u&&t.options.isFavorite&&(t.options.isFavorite=u,e.setUpdateIndicator(this.tabs.root,!0),yield this.removeRunFromFavorites(t),e.setUpdateIndicator(this.tabs.root,!1))})))).show({center:!0}),d.fireChanged()}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%"}})}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.title=null,e.options.description=null,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("a4b45840-9a50-11e6-9cc9-8546b8bf62e6"),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.title=null,e.options.description=null,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 j(t,e,n,i)},t.historyInput=function(t,e,n,i,o=[]){return new G(t,e,n,i,o)},t.historyPanel=function(t){return new nt(t)}}(it||(it={}));var ot=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 st=new URL(t.shell.startUri);class rt extends o.ViewBase{constructor(t,n={historyEnabled:!0,isTabbed:!1}){super(),this.funcName=t,this.options=n,this._type="function",this.funcCallReplaced=new f.Subject,this.onFuncCallReady=new f.BehaviorSubject(!1),this.exportConfig=null,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.onFuncCallReady.subscribe({complete:()=>{this.changeViewName(this.funcCall.func.friendlyName),this.build()}}),this.init()}changeViewName(t){var n;this.name=t,null===(n=document.querySelector("div.d4-ribbon-name"))||void 0===n||n.replaceChildren(e.span([t]))}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){var e,n,i;const o=null===(e=this._funcCall)||void 0===e?void 0:e.options.isHistorical;this._funcCall=t,this.options.isTabbed||(t.options.isHistorical?(o?this.changeViewName(`${this.name.substring(0,this.name.indexOf(" — ")>0?this.name.indexOf(" — "):void 0)} — ${null!==(i=t.options.title)&&void 0!==i?i:new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}`):this.changeViewName(`${this.name} — ${null!==(n=t.options.title)&&void 0!==n?n:new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}`),this.path=`?id=${this._funcCall.id}`):(this.path="",this.changeViewName(`${this.name.substring(0,this.name.indexOf(" — ")>0?this.name.indexOf(" — "):void 0)}`))),this.funcCallReplaced.next(!0)}loadFuncCallById(){return ot(this,void 0,void 0,(function*(){const n=st.searchParams.get("id");if(e.setUpdateIndicator(this.root,!0),n&&!this.options.isTabbed)this.linkFunccall(yield this.loadRun(n)),st.searchParams.delete("id");else{const e=yield t.functions.eval(this.funcName);this.linkFunccall(e.prepare({}))}e.setUpdateIndicator(this.root,!1)}))}init(){return ot(this,void 0,void 0,(function*(){yield this.loadFuncCallById(),this.onFuncCallReady.complete()}))}build(){e.empty(this.root),this.root.appendChild(this.buildIO()),this.options.historyEnabled&&this.buildHistoryBlock(),this.buildRibbonMenu(),this.buildRibbonPanels()}buildHistoryBlock(){const t=it.historyPanel(this.func);return t.onRunChosen.subscribe((t=>ot(this,void 0,void 0,(function*(){return this.linkFunccall(yield this.loadRun(t))})))),e.empty(this.historyRoot),this.historyRoot.style.removeProperty("justify-content"),this.historyRoot.style.width="100%",this.historyRoot.append(t.root),t.root}buildRibbonPanels(){var n;const i=[[...this.exportConfig&&this.exportConfig.supportedFormats.length>0?[e.divH([e.comboPopup(e.iconFA("arrow-to-bottom"),this.exportConfig.supportedFormats,(t=>ot(this,void 0,void 0,(function*(){return o.Utils.download(this.exportConfig.filename(t),yield this.exportConfig.export(t))}))))])]:[]]];if(null===(n=this.func)||void 0===n?void 0:n.id){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"),i.push([n])}return this.setRibbonPanels(i),i}buildRibbonMenu(){}onBeforeSaveRun(t){return ot(this,void 0,void 0,(function*(){}))}onAfterSaveRun(t){return ot(this,void 0,void 0,(function*(){}))}saveRun(t){return ot(this,void 0,void 0,(function*(){yield this.onBeforeSaveRun(t);const e=yield g.saveRun(t);return e.options.isHistorical=!1,this.linkFunccall(e),this.options.historyEnabled&&this.buildHistoryBlock(),this.options.isTabbed||(this.path=`?id=${e.id}`),yield this.onAfterSaveRun(e),e}))}onBeforeDeleteRun(t){return ot(this,void 0,void 0,(function*(){}))}onAfterDeleteRun(t){return ot(this,void 0,void 0,(function*(){}))}deleteRun(t){return ot(this,void 0,void 0,(function*(){return yield this.onBeforeDeleteRun(t),yield g.deleteRun(t),yield this.onAfterDeleteRun(t),t.id}))}onBeforeLoadRun(){return ot(this,void 0,void 0,(function*(){}))}onAfterLoadRun(t){return ot(this,void 0,void 0,(function*(){}))}loadRun(t){return ot(this,void 0,void 0,(function*(){yield this.onBeforeLoadRun();const e=yield g.loadRun(t);return this.lastCall=e,yield this.onAfterLoadRun(e),e}))}onBeforeRun(t){return ot(this,void 0,void 0,(function*(){}))}onAfterRun(t){return ot(this,void 0,void 0,(function*(){}))}run(){return ot(this,void 0,void 0,(function*(){if(!this.funcCall)throw new Error("The correspoding function is not specified");yield this.onBeforeRun(this.funcCall);const t=o.TaskBarProgressIndicator.create("Calculating...");this.funcCall.newId(),yield this.funcCall.call(),t.close(),yield this.onAfterRun(this.funcCall),this.lastCall=this.options.isTabbed?this.funcCall.clone():yield this.saveRun(this.funcCall)}))}}const at=html2canvas;var lt=n.n(at),dt=n(410),ct={};ct.styleTagTransform=M(),ct.setAttributes=k(),ct.insert=S().bind(null,"head"),ct.domAPI=T(),ct.insertStyleElement=V(),R()(dt.Z,ct),dt.Z&&dt.Z.locals&&dt.Z.locals;var ut=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 pt={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,scatterplot3d: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};class ht extends rt{constructor(t,n={historyEnabled:!0,isTabbed:!1}){super(t,n),this.options=n,this.checkDisability=new f.Subject,this.isRunning=!1,this.tabsElem=e.tabControl(),this.dfToViewerMapping={},this.defaultExport=t=>ut(this,void 0,void 0,(function*(){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=new(x().Workbook),i=t=>o.TYPES_SCALAR.has(t),s=t=>t===o.TYPE.DATA_FRAME,r=this.func.inputs.filter((t=>s(t.propertyType))),a=this.func.inputs.filter((t=>i(t.propertyType))),l=this.func.outputs.filter((t=>s(t.propertyType))),d=this.func.outputs.filter((t=>i(t.propertyType))),c=[...e.inputParams.values()],u=[...e.outputParams.values()];if(r.forEach((t=>{const i=t.options.caption||t.name,o=n.addWorksheet(ft(i,mt.INPUT)),s=e.inputs[t.name];gt(o,s)})),a.length){const t=n.addWorksheet("Input scalars");vt(t,a.map((t=>({caption:t.options.caption||t.name,value:e.inputs[t.name],units:t.options.units||""}))))}if(l.forEach((t=>{const i=t.options.caption||t.name,o=n.addWorksheet(ft(i,mt.OUTPUT)),s=e.outputs[t.name];gt(o,s)})),d.length){const t=n.addWorksheet("Output scalars");vt(t,d.map((t=>({caption:t.options.caption||t.name,value:e.outputs[t.name],units:t.options.units||""}))))}const p=this.tabsElem;for(const t of this.tabsLabels)if(p.currentPane=p.getPane(t),yield new Promise((t=>setTimeout(t,100))),"Input"===t)for(const t of c.filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME))){const i=this.dfToViewerMapping[t.name].filter((t=>t.type!==o.VIEWER.GRID)).filter((t=>Object.values(pt).includes(t.type))),s=r.find((e=>e.name===t.name)),a=s.options.caption||t.name,l=e.inputs[s.name];for(const[t,e]of i.entries())yield yt(n,n.getWorksheet(ft(a,mt.INPUT)),e.root,l.columns.length+2,t>0?Math.ceil(i[t-1].root.clientHeight/20)+1:0)}else for(const i of u.filter((e=>e.property.propertyType===o.TYPE.DATA_FRAME&&("Output"===t&&"Misc"===e.property.category||"Output"===e.property.category||"Output"!==t&&e.property.category===t)))){const t=this.dfToViewerMapping[i.property.name].filter((t=>t.type!==o.VIEWER.GRID)).filter((t=>Object.values(pt).includes(t.type))),s=l.find((t=>t.name===i.property.name)),r=s.options.caption||i.property.name,a=e.outputs[s.name];for(const[e,i]of t.entries())if(i.type===o.VIEWER.STATISTICS){const i=a.columns.length,s=o.DataFrame.fromColumns([o.Column.string("Name",i).init((t=>a.columns.byIndex(t).name)),o.Column.int("Values",i).init((t=>a.columns.byIndex(t).stats.valueCount)),o.Column.int("Nulls",i).init((t=>a.columns.byIndex(t).stats.missingValueCount)),o.Column.float("Min",i).init((t=>a.columns.byIndex(t).stats.min)),o.Column.float("Max",i).init((t=>a.columns.byIndex(t).stats.max)),o.Column.float("Avg",i).init((t=>a.columns.byIndex(t).stats.avg)),o.Column.float("Stdev",i).init((t=>a.columns.byIndex(t).stats.stdev))]);gt(n.getWorksheet(ft(r,mt.OUTPUT)),s,a.columns.length+2,e>0?Math.ceil(t[e-1].root.clientHeight/20)+1:0)}else yield yt(n,n.getWorksheet(ft(r,mt.OUTPUT)),i.root,a.columns.length+2,e>0?Math.ceil(t[e-1].root.clientHeight/20)+1:0)}const h=yield n.xlsx.writeBuffer();return new Blob([h],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"})})),this.exportConfig={supportedExtensions:this.defaultSupportedExportExtensions(),supportedFormats:this.defaultSupportedExportFormats(),export:this.defaultExport,filename:this.defaultExportFilename},this.onFuncCallReady.subscribe({complete:()=>{this.basePath=`scripts/${this.funcCall.func.id}/view`}})}static fromFuncCall(t,e={historyEnabled:!0,isTabbed:!1}){return new this(t.func.nqName,e)}onAfterRun(t){this.tabsElem.root.style.removeProperty("display"),this.tabsElem.panes.forEach((t=>{t.header.style.removeProperty("display")}));const e=this.tabsElem.panes.find((t=>"Input"!==t.name));return e&&(this.tabsElem.currentPane=e),Promise.resolve()}buildIO(){const t=this.buildInputBlock();e.tools.handleResize(t,(e=>{e<350?A()(t.firstChild).addClass("ui-form-condensed"):A()(t.firstChild).removeClass("ui-form-condensed")}));const n=this.buildOutputBlock();n.style.height="100%",n.style.width="100%",this.tabsElem.root.style.display="none",this.tabsElem.getPane("Input")&&this.tabsElem.panes.forEach((t=>{t.header.style.display="none"}));const i=e.splitH([t,e.panel([n],{style:{"padding-top":"0px"}})],null,!0);return i.style.padding="0 12px",t.parentElement.style.maxWidth="450px",i}buildInputBlock(){return this.renderRunSection()}buildOutputBlock(){this.tabsElem.root.style.width="100%",this.tabsLabels.forEach((n=>{const i=this.categoryToParamMap[n].filter((t=>t.propertyType===o.TYPE.DATA_FRAME)),s=this.categoryToParamMap[n].filter((t=>t.propertyType!==o.TYPE.DATA_FRAME)),r=i.map((t=>void 0!==t.options.viewer?JSON.parse(t.options.viewer,((t,e)=>"true"===e||"false"===e?JSON.parse(e):e)):[])),a=i.map(((i,s)=>{var a;let l=0;r[s].forEach(((t,e)=>{const n=r[s][e].block;l+=n?parseInt(n):0}));const d=Promise.all(r[s].map((e=>ut(this,void 0,void 0,(function*(){var n,s,r,a,l;const d=null!==(l=null!==(r=null===(s=null===(n=this.funcCall)||void 0===n?void 0:n.outputs[i.name])||void 0===s?void 0:s.value)&&void 0!==r?r:null===(a=this.funcCall.inputParams[i.name])||void 0===a?void 0:a.value)&&void 0!==l?l:t.data.demo.demog(1),c=pt[e.type]?o.Viewer.fromType(pt[e.type],d):yield d.plot.fromType(e.type);return c.setOptions(e),this.dfToViewerMapping[i.name]?this.dfToViewerMapping[i.name].push(c):this.dfToViewerMapping[i.name]=[c],c})))));d.then((t=>{const e=()=>{var e;const n=null!==(e=this.funcCall.outputParams[i.name])&&void 0!==e?e:this.funcCall.inputParams[i.name];n.onChanged.subscribe((()=>{t.forEach((t=>ut(this,void 0,void 0,(function*(){if(Object.values(pt).includes(t.type))t.dataFrame=n.value;else{const e=yield n.value.plot.fromType(t.type);t.root.replaceWith(e.root),t=e}}))))}))};e(),this.funcCallReplaced.subscribe(e)}));const c=null!==(a=i.options.caption)&&void 0!==a?a:i.name,u=e.wait((()=>ut(this,void 0,void 0,(function*(){const t=yield d;return e.divH(yield Promise.all(t.map((t=>t.root),{style:{"flex-wrap":"wrap"}})))}))));if("Input"===n){const t=()=>{var t;(null!==(t=this.funcCall.outputParams[i.name])&&void 0!==t?t:this.funcCall.inputParams[i.name]).onChanged.subscribe((()=>{this.tabsElem.root.style.removeProperty("display")}))};t(),this.funcCallReplaced.subscribe(t)}return e.divV([e.h2(c,Object.assign({},s>0?{style:{"margin-top":"0px"}}:{})),u],{style:Object.assign({},l>0?{width:`${l}%`}:{width:"100%"})})})),l=()=>{const t=o.HtmlTable.create(s,(t=>{var e;return[t.name,null===(e=this.funcCall)||void 0===e?void 0:e.outputs[t.name],t.options.units]})).root;return t.style.maxWidth="400px",t};let d=l();s.forEach((t=>{const e=()=>{this.funcCall.outputParams[t.name].onChanged.subscribe((()=>{const t=l();d.replaceWith(t),d=t}))};e(),this.funcCallReplaced.subscribe(e)}));const c=[];let u=0,p=e.divH([],{style:{"margin-bottom":"25px"}});a.forEach(((t,n)=>{const i=parseInt(t.style.width);u+i===100?(p.append(t),c.push(p),p=e.divH([]),u=0):u+i<100?(p.append(t),u+=i):(c.push(p),p=e.divH([]),p.append(t),u=i),n===a.length-1&&c.push(p)})),this.tabsElem.addPane(n,(()=>e.divV([...c,...s.length?[e.h2("Scalar values")]:[],d])))}));const n=e.box();return n.append(this.tabsElem.root),n}onAfterLoadRun(t){return ut(this,void 0,void 0,(function*(){r()(this.funcCall.outputParams.values()).forEach((e=>{this.funcCall.setParamValue(e.name,t.outputs[e.name])})),r()(this.funcCall.inputParams.values()).forEach((e=>{this.funcCall.setParamValue(e.name,t.inputs[e.name])})),this.tabsElem.root.style.removeProperty("display"),this.tabsElem.panes.forEach((t=>{t.header.style.removeProperty("display")}))}))}get isInputPanelRequired(){var t;return(null===(t=this.func)||void 0===t?void 0:t.inputs.some((t=>t.propertyType==o.TYPE.DATA_FRAME&&null!=t.options.viewer)))||!1}get tabsLabels(){return Object.keys(this.categoryToParamMap)}get categoryToParamMap(){const t={};return this.isInputPanelRequired&&this.func.inputs.filter((t=>t.propertyType==o.TYPE.DATA_FRAME&&null!=t.options.viewer)).forEach((e=>t.Input?t.Input.push(e):t.Input=[e])),this.func.outputs.forEach((e=>{const n="Misc"===e.category?"Output":e.category;t[n]?t[n].push(e):t[n]=[e]})),t}doRun(){return ut(this,void 0,void 0,(function*(){this.isRunning=!0,this.checkDisability.next();try{yield this.run()}catch(e){t.shell.error(e)}finally{this.isRunning=!1,this.checkDisability.next()}}))}renderRunSection(){const n=e.bigButton("Run",(()=>ut(this,void 0,void 0,(function*(){return yield this.doRun()})))),i=(e.button("Open script",(()=>ut(this,void 0,void 0,(function*(){window.open(`${window.location.origin}/script/${this.func.id}`,"_blank")})))),e.div([n]));e.tooltip.bind(i,(()=>n.disabled?this.isRunning?"Computations are in progress":"Some inputs are invalid":"")),this.checkDisability.subscribe((()=>{const t=r()(this.funcCall.inputs.values()).every((t=>null!=t))&&!this.isRunning;n.disabled=!t}));const s=e.divV([],"ui-form");let a="Misc";r()(this.funcCall.inputParams.values()).filter((t=>!!t)).forEach((i=>{var r,l,d;const c=i.property;if("file"===c.propertyType.toString()){const t=it.fileInput(null!==(r=c.caption)&&void 0!==r?r:c.name,null,(t=>{this.funcCall.inputs[c.name]=t,this.checkDisability.next()}));c.category!==a&&s.append(e.h2(c.category)),this.checkDisability.next(),s.append(t.root)}else{let r=c.propertyType===o.TYPE.DATA_FRAME?e.tableInput(null!==(l=c.caption)&&void 0!==l?l:c.name,null,t.shell.tables):e.input.forProperty(c);r.input.onkeydown=t=>ut(this,void 0,void 0,(function*(){"Enter"==t.key&&(yield this.doRun())})),r.captionLabel.firstChild.replaceWith(e.span([null!==(d=c.caption)&&void 0!==d?d:c.name])),c.options.units&&r.addPostfix(c.options.units);const u=()=>{var t,e,n,o;r.value=null!==(e=null!==(t=this.funcCall.inputs[i.name])&&void 0!==t?t:c.defaultValue)&&void 0!==e?e:null,this.funcCall.inputs[i.name]=null!==(o=null!==(n=this.funcCall.inputs[i.name])&&void 0!==n?n:c.defaultValue)&&void 0!==o?o:null};u(),this.funcCallReplaced.subscribe(u),r.onChanged((()=>{r.property||(this.funcCall.inputs[i.name]=r.value)})),r.onInput((()=>{this.funcCall.inputs[i.name]=r.value,null===r.value?setTimeout((()=>r.input.classList.add("d4-invalid")),100):r.input.classList.remove("d4-invalid"),this.checkDisability.next()})),i.onChanged.subscribe((()=>{var n;const s=this.funcCall.inputs[i.name];if(i.property.propertyType===o.TYPE.DATA_FRAME){const o=e.tableInput(null!==(n=c.caption)&&void 0!==n?n:c.name,s,[...t.shell.tables,s]);r.root.replaceWith(o.root),r=o,r.onInput((()=>{this.funcCall.inputs[i.name]=r.value,null===r.value?setTimeout((()=>r.input.classList.add("d4-invalid")),100):r.input.classList.remove("d4-invalid"),this.checkDisability.next()}))}else r.notify=!1,r.value=s,r.notify=!0;this.checkDisability.next()})),c.category!==a&&s.append(e.h2(c.category)),null===r.value&&(n.disabled=!0),s.append(r.root)}a=c.category}));const l=e.buttonsInput([i]);return s.append(l),s.classList.remove("ui-panel"),s.style.paddingTop="0px",s.style.paddingLeft="0px",e.div([s])}}const ft=(t,e)=>{const n=`${e} - ${t}`;return n.length>31?t.substring(0,32):n};var mt;!function(t){t.INPUT="Input",t.OUTPUT="Output"}(mt||(mt={}));const vt=(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)),"Parameter".length),t.getColumn(2).width=1.2*Math.max(...e.map((t=>t.value.toString().length)),"Value".length),t.getColumn(3).width=1.2*Math.max(...e.map((t=>t.units.toString().length)),"Units".length)},gt=(t,e,n=0,i=0)=>{for(let o=0;o<e.columns.names().length;o++)t.getCell(1+i,1+o+n).value=e.columns.byIndex(o).name,t.getColumn(1+o+n).width=1.2*Math.max(...e.columns.byIndex(o).categories.map((t=>t.toString().length)),e.columns.byIndex(o).name.length);for(let o=0;o<e.columns.length;o++)for(let s=0;s<e.rowCount;s++)t.getCell(s+2+i,1+n+o).value=e.columns.byIndex(o).get(s)},yt=(t,e,n,i,o=0)=>ut(void 0,void 0,void 0,(function*(){const s=yield lt()(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 At=n(433),bt={};bt.styleTagTransform=M(),bt.setAttributes=k(),bt.insert=S().bind(null,"head"),bt.domAPI=T(),bt.insertStyleElement=V(),R()(At.Z,bt),At.Z&&At.Z.locals&&At.Z.locals;class Ct{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 xt=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 Ct,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",(()=>xt(this,void 0,void 0,(function*(){return yield this.generate()})))),n=e.bigButton("Save",(()=>xt(this,void 0,void 0,(function*(){return yield this.save()})))),i=e.bigButton("Open",(()=>xt(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))})),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,d,e.divH([t],{style:{"justify-content":"flex-end"}})],"ui-form");let u=e.divText(this.store.scriptText.value),p=e.info(this.store.infoText.value);const h=e.panel([e.h3("Script text"),u,p,e.divH([n,i],{style:{"justify-content":"flex-end"}})],{style:{display:"none"}});this.store.scriptText.subscribe((t=>{const n=e.divText(t);u.replaceWith(n),u=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 xt(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 xt(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 It=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 Rt=!1;const Et=new o.Package;function Tt(t){c.openModelFromFunccall(t)}function Ft(){const e=new wt;e.name="Import Script Gen",t.shell.addView(e),e.root.classList.remove("ui-panel")}function St(){return new u}function Bt(t){return ht.fromFuncCall(t,{historyEnabled:!0,isTabbed:!1})}function kt(t){return ht.fromFuncCall(t,{historyEnabled:!1,isTabbed:!0})}function Pt(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 Vt(){console.log("hof");let e=Pt(o.Func.byName("Sin"));e.parentCall=t.functions.getCurrentCall(),t.shell.addView(e)}function _t(){var n,i,s;console.log("hof2");let r=Pt(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 Mt(n){return It(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: ${Ot("auth")}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '${JSON.stringify(i)}'`,r=`\nvar myHeaders = new Headers();\nmyHeaders.append("Authorization", "${Ot("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 Ot(t){let e=document.cookie.match(new RegExp("(?:^|; )"+t.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):void 0}function Dt(){}function Lt(){Rt||(o.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((()=>It(this,void 0,void 0,(function*(){return(yield Mt(n)).root})))))))})),Rt=!0)}function Nt(){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}function jt(e,n){return It(this,void 0,void 0,(function*(){if(yield h(e),null!=n||""!=n)throw n;return t.data.demo.demog()}))}function $t(){o.Func.find({name:"computationTest"})[0]}})(),compute=i})();
2
2
  //# sourceMappingURL=package.js.map