@datagrok/hit-triage 1.1.6 → 1.1.7

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 hittriage;(()=>{var e={553:e=>{!function(){"use strict";var t=document,i=window,n=t.documentElement,o=t.createElement.bind(t),a=o("div"),s=o("table"),r=o("tbody"),l=o("tr"),c=Array.isArray,u=Array.prototype,d=u.concat,p=u.filter,m=u.indexOf,h=u.map,f=u.push,v=u.slice,g=u.some,y=u.splice,b=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,w=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,C=/<.+>/,A=/^\w+$/;function T(e,t){var i,n=!!(i=t)&&11===i.nodeType;return e&&(n||_(t)||F(t))?!n&&w.test(e)?t.getElementsByClassName(e.slice(1).replace(/\\/g,"")):!n&&A.test(e)?t.getElementsByTagName(e):t.querySelectorAll(e):[]}var x=function(){function e(e,n){if(e){if(N(e))return e;var o=e;if(P(e)){var a=n||t;if(!(o=b.test(e)&&_(a)?a.getElementById(e.slice(1).replace(/\\/g,"")):C.test(e)?X(e):N(a)?a.find(e):P(a)?E(a).find(e):T(e,a)))return}else if(O(e))return this.ready(e);(o.nodeType||o===i)&&(o=[o]),this.length=o.length;for(var s=0,r=this.length;s<r;s++)this[s]=o[s]}}return e.prototype.init=function(t,i){return new e(t,i)},e}(),I=x.prototype,E=I.init;function N(e){return e instanceof x}function S(e){return!!e&&e===e.window}function _(e){return!!e&&9===e.nodeType}function F(e){return!!e&&1===e.nodeType}function B(e){return"boolean"==typeof e}function O(e){return"function"==typeof e}function P(e){return"string"==typeof e}function k(e){return void 0===e}function V(e){return null===e}function L(e){return!isNaN(parseFloat(e))&&isFinite(e)}function j(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function D(e,t,i){if(i){for(var n=e.length;n--;)if(!1===t.call(e[n],n,e[n]))return e}else if(j(e))for(var o=Object.keys(e),a=(n=0,o.length);n<a;n++){var s=o[n];if(!1===t.call(e[s],s,e[s]))return e}else for(n=0,a=e.length;n<a;n++)if(!1===t.call(e[n],n,e[n]))return e;return e}function H(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=!!B(e[0])&&e.shift(),n=e.shift(),o=e.length;if(!n)return{};if(!o)return H(i,E,n);for(var a=0;a<o;a++){var s=e[a];for(var r in s)i&&(c(s[r])||j(s[r]))?(n[r]&&n[r].constructor===s[r].constructor||(n[r]=new s[r].constructor),H(i,n[r],s[r])):n[r]=s[r]}return n}E.fn=E.prototype=I,I.length=0,I.splice=y,"function"==typeof Symbol&&(I[Symbol.iterator]=u[Symbol.iterator]),E.isWindow=S,E.isFunction=O,E.isArray=c,E.isNumeric=L,E.isPlainObject=j,E.each=D,I.each=function(e){return D(this,e)},I.empty=function(){return this.each((function(e,t){for(;t.firstChild;)t.removeChild(t.firstChild)}))},E.extend=H,I.extend=function(e){return H(I,e)};var M=/\S+/g;function R(e){return P(e)&&e.match(M)||[]}function U(e,t,n){if(F(e)){var o=i.getComputedStyle(e,null);return n?o.getPropertyValue(t)||void 0:o[t]||e.style[t]}}function $(e,t){return parseInt(U(e,t),10)||0}function q(e,t){return $(e,"border".concat(t?"Left":"Top","Width"))+$(e,"padding".concat(t?"Left":"Top"))+$(e,"padding".concat(t?"Right":"Bottom"))+$(e,"border".concat(t?"Right":"Bottom","Width"))}I.toggleClass=function(e,t){var i=R(e),n=!k(t);return this.each((function(e,o){F(o)&&D(i,(function(e,i){n?t?o.classList.add(i):o.classList.remove(i):o.classList.toggle(i)}))}))},I.addClass=function(e){return this.toggleClass(e,!0)},I.removeAttr=function(e){var t=R(e);return this.each((function(e,i){F(i)&&D(t,(function(e,t){i.removeAttribute(t)}))}))},I.attr=function(e,t){if(e){if(P(e)){if(arguments.length<2){if(!this[0]||!F(this[0]))return;var i=this[0].getAttribute(e);return V(i)?void 0:i}return k(t)?this:V(t)?this.removeAttr(e):this.each((function(i,n){F(n)&&n.setAttribute(e,t)}))}for(var n in e)this.attr(n,e[n]);return this}},I.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},I.hasClass=function(e){return!!e&&g.call(this,(function(t){return F(t)&&t.classList.contains(e)}))},I.get=function(e){return k(e)?v.call(this):this[(e=Number(e))<0?e+this.length:e]},I.eq=function(e){return E(this.get(e))},I.first=function(){return this.eq(0)},I.last=function(){return this.eq(-1)},I.text=function(e){return k(e)?this.get().map((function(e){return F(e)||(t=e)&&3===t.nodeType?e.textContent:"";var t})).join(""):this.each((function(t,i){F(i)&&(i.textContent=e)}))};var Y={};function W(e){return"none"===U(e,"display")}function G(e,t){var i=e&&(e.matches||e.webkitMatchesSelector||e.msMatchesSelector);return!!i&&!!t&&i.call(e,t)}function J(e){return P(e)?function(t,i){return G(i,e)}:O(e)?e:N(e)?function(t,i){return e.is(i)}:e?function(t,i){return i===e}:function(){return!1}}function Z(e,t){return t?e.filter(t):e}I.filter=function(e){var t=J(e);return E(p.call(this,(function(e,i){return t.call(e,i,e)})))},I.detach=function(e){return Z(this,e).each((function(e,t){t.parentNode&&t.parentNode.removeChild(t)})),this};var z=/^\s*<(\w+)[^>]*>/,Q=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,K={"*":a,tr:r,td:l,th:l,thead:s,tbody:s,tfoot:s};function X(e){if(!P(e))return[];if(Q.test(e))return[o(RegExp.$1)];var t=z.test(e)&&RegExp.$1,i=K[t]||K["*"];return i.innerHTML=e,E(i.childNodes).detach().get()}function ee(e,t,i,n){for(var o=[],a=O(t),s=n&&J(n),r=0,l=e.length;r<l;r++)if(a){var c=t(e[r]);c.length&&f.apply(o,c)}else for(var u=e[r][t];!(null==u||n&&s(-1,u));)o.push(u),u=i?u[t]:null;return o}function te(e){return e.multiple&&e.options?ee(p.call(e.options,(function(e){return e.selected&&!e.disabled&&!e.parentNode.disabled})),"value"):e.value||""}function ie(e){return e.length>1?p.call(e,(function(e,t,i){return m.call(i,e)===t})):e}E.parseHTML=X,I.has=function(e){var t=P(e)?function(t,i){return T(e,i).length}:function(t,i){return i.contains(e)};return this.filter(t)},I.not=function(e){var t=J(e);return this.filter((function(i,n){return(!P(e)||F(n))&&!t.call(n,i,n)}))},I.val=function(e){return arguments.length?this.each((function(t,i){var n=i.multiple&&i.options;if(n||Pe.test(i.type)){var o=c(e)?h.call(e,String):V(e)?[]:[String(e)];n?D(i.options,(function(e,t){t.selected=o.indexOf(t.value)>=0}),!0):i.checked=o.indexOf(i.value)>=0}else i.value=k(e)||V(e)?"":e})):this[0]&&te(this[0])},I.is=function(e){var t=J(e);return g.call(this,(function(e,i){return t.call(e,i,e)}))},E.guid=1,E.unique=ie,I.add=function(e,t){return E(ie(this.get().concat(E(e,t).get())))},I.children=function(e){return Z(E(ie(ee(this,(function(e){return e.children})))),e)},I.parent=function(e){return Z(E(ie(ee(this,"parentNode"))),e)},I.index=function(e){var t=e?E(e)[0]:this[0],i=e?this:E(t).parent().children();return m.call(i,t)},I.closest=function(e){var t=this.filter(e);if(t.length)return t;var i=this.parent();return i.length?i.closest(e):t},I.siblings=function(e){return Z(E(ie(ee(this,(function(e){return E(e).parent().children().not(e)})))),e)},I.find=function(e){return E(ie(ee(this,(function(t){return T(e,t)}))))};var ne=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,oe=/^$|^module$|\/(java|ecma)script/i,ae=["type","src","nonce","noModule"];function se(e,t,i,a,s,r,l,c){return D(e,(function(e,r){D(E(r),(function(e,r){D(E(t),(function(t,l){var c=i?l:r,u=i?e:t;!function(e,t,i,a,s){a?e.insertBefore(t,i?e.firstChild:null):"HTML"===e.nodeName?e.parentNode.replaceChild(t,e):e.parentNode.insertBefore(t,i?e:e.nextSibling),s&&function(e,t){var i=E(e);i.filter("script").add(i.find("script")).each((function(e,i){if(oe.test(i.type)&&n.contains(i)){var a=o("script");a.text=i.textContent.replace(ne,""),D(ae,(function(e,t){i[t]&&(a[t]=i[t])})),t.head.insertBefore(a,null),t.head.removeChild(a)}}))}(t,e.ownerDocument)}(i?r:l,u?c.cloneNode(!0):c,a,s,!u)}),c)}),l)}),r),t}I.after=function(){return se(arguments,this,!1,!1,!1,!0,!0)},I.append=function(){return se(arguments,this,!1,!1,!0)},I.html=function(e){if(!arguments.length)return this[0]&&this[0].innerHTML;if(k(e))return this;var t=/<script[\s>]/.test(e);return this.each((function(i,n){F(n)&&(t?E(n).empty().append(e):n.innerHTML=e)}))},I.appendTo=function(e){return se(arguments,this,!0,!1,!0)},I.wrapInner=function(e){return this.each((function(t,i){var n=E(i),o=n.contents();o.length?o.wrapAll(e):n.append(e)}))},I.before=function(){return se(arguments,this,!1,!0)},I.wrapAll=function(e){for(var t=E(e),i=t[0];i.children.length;)i=i.firstElementChild;return this.first().before(t),this.appendTo(i)},I.wrap=function(e){return this.each((function(t,i){var n=E(e)[0];E(i).wrapAll(t?n.cloneNode(!0):n)}))},I.insertAfter=function(e){return se(arguments,this,!0,!1,!1,!1,!1,!0)},I.insertBefore=function(e){return se(arguments,this,!0,!0)},I.prepend=function(){return se(arguments,this,!1,!0,!0,!0,!0)},I.prependTo=function(e){return se(arguments,this,!0,!0,!0,!1,!1,!0)},I.contents=function(){return E(ie(ee(this,(function(e){return"IFRAME"===e.tagName?[e.contentDocument]:"TEMPLATE"===e.tagName?e.content.childNodes:e.childNodes}))))},I.next=function(e,t,i){return Z(E(ie(ee(this,"nextElementSibling",t,i))),e)},I.nextAll=function(e){return this.next(e,!0)},I.nextUntil=function(e,t){return this.next(t,!0,e)},I.parents=function(e,t){return Z(E(ie(ee(this,"parentElement",!0,t))),e)},I.parentsUntil=function(e,t){return this.parents(t,e)},I.prev=function(e,t,i){return Z(E(ie(ee(this,"previousElementSibling",t,i))),e)},I.prevAll=function(e){return this.prev(e,!0)},I.prevUntil=function(e,t){return this.prev(t,!0,e)},I.map=function(e){return E(d.apply([],h.call(this,(function(t,i){return e.call(t,i,t)}))))},I.clone=function(){return this.map((function(e,t){return t.cloneNode(!0)}))},I.offsetParent=function(){return this.map((function(e,t){for(var i=t.offsetParent;i&&"static"===U(i,"position");)i=i.offsetParent;return i||n}))},I.slice=function(e,t){return E(v.call(this,e,t))};var re=/-([a-z])/g;function le(e){return e.replace(re,(function(e,t){return t.toUpperCase()}))}I.ready=function(e){var i=function(){return setTimeout(e,0,E)};return"loading"!==t.readyState?i():t.addEventListener("DOMContentLoaded",i),this},I.unwrap=function(){return this.parent().each((function(e,t){if("BODY"!==t.tagName){var i=E(t);i.replaceWith(i.children())}})),this},I.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+i.pageYOffset,left:t.left+i.pageXOffset}}},I.position=function(){var e=this[0];if(e){var t="fixed"===U(e,"position"),i=t?e.getBoundingClientRect():this.offset();if(!t){for(var n=e.ownerDocument,o=e.offsetParent||n.documentElement;(o===n.body||o===n.documentElement)&&"static"===U(o,"position");)o=o.parentNode;if(o!==e&&F(o)){var a=E(o).offset();i.top-=a.top+$(o,"borderTopWidth"),i.left-=a.left+$(o,"borderLeftWidth")}}return{top:i.top-$(e,"marginTop"),left:i.left-$(e,"marginLeft")}}};var ce={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};I.prop=function(e,t){if(e){if(P(e))return e=ce[e]||e,arguments.length<2?this[0]&&this[0][e]:this.each((function(i,n){n[e]=t}));for(var i in e)this.prop(i,e[i]);return this}},I.removeProp=function(e){return this.each((function(t,i){delete i[ce[e]||e]}))};var ue=/^--/;function de(e){return ue.test(e)}var pe={},me=a.style,he=["webkit","moz","ms"];function fe(e,t){if(void 0===t&&(t=de(e)),t)return e;if(!pe[e]){var i=le(e),n="".concat(i[0].toUpperCase()).concat(i.slice(1));D("".concat(i," ").concat(he.join("".concat(n," "))).concat(n).split(" "),(function(t,i){if(i in me)return pe[e]=i,!1}))}return pe[e]}var ve={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function ge(e,t,i){return void 0===i&&(i=de(e)),i||ve[e]||!L(t)?t:"".concat(t,"px")}function ye(e,t){try{return e(t)}catch(e){return t}}I.css=function(e,t){if(P(e)){var i=de(e);return e=fe(e,i),arguments.length<2?this[0]&&U(this[0],e,i):e?(t=ge(e,t,i),this.each((function(n,o){F(o)&&(i?o.style.setProperty(e,t):o.style[e]=t)}))):this}for(var n in e)this.css(n,e[n]);return this};var be=/^\s+|\s+$/;function we(e,t){var i=e.dataset[t]||e.dataset[le(t)];return be.test(i)?i:ye(JSON.parse,i)}function Ce(e,t,i){i=ye(JSON.stringify,i),e.dataset[le(t)]=i}function Ae(e,t){var i=e.documentElement;return Math.max(e.body["scroll".concat(t)],i["scroll".concat(t)],e.body["offset".concat(t)],i["offset".concat(t)],i["client".concat(t)])}I.data=function(e,t){if(!e){if(!this[0])return;var i={};for(var n in this[0].dataset)i[n]=we(this[0],n);return i}if(P(e))return arguments.length<2?this[0]&&we(this[0],e):k(t)?this:this.each((function(i,n){Ce(n,e,t)}));for(var n in e)this.data(n,e[n]);return this},D([!0,!1],(function(e,t){D(["Width","Height"],(function(e,i){var n="".concat(t?"outer":"inner").concat(i);I[n]=function(n){if(this[0])return S(this[0])?t?this[0]["inner".concat(i)]:this[0].document.documentElement["client".concat(i)]:_(this[0])?Ae(this[0],i):this[0]["".concat(t?"offset":"client").concat(i)]+(n&&t?$(this[0],"margin".concat(e?"Top":"Left"))+$(this[0],"margin".concat(e?"Bottom":"Right")):0)}}))})),D(["Width","Height"],(function(e,t){var i=t.toLowerCase();I[i]=function(n){if(!this[0])return k(n)?void 0:this;if(!arguments.length)return S(this[0])?this[0].document.documentElement["client".concat(t)]:_(this[0])?Ae(this[0],t):this[0].getBoundingClientRect()[i]-q(this[0],!e);var o=parseInt(n,10);return this.each((function(t,n){if(F(n)){var a=U(n,"boxSizing");n.style[i]=ge(i,o+("border-box"===a?q(n,!e):0))}}))}})),I.toggle=function(e){return this.each((function(i,n){if(F(n)){var a=W(n);(k(e)?a:e)?(n.style.display=n.___cd||"",W(n)&&(n.style.display=function(e){if(Y[e])return Y[e];var i=o(e);t.body.insertBefore(i,null);var n=U(i,"display");return t.body.removeChild(i),Y[e]="none"!==n?n:"block"}(n.tagName))):a||(n.___cd=U(n,"display"),n.style.display="none")}}))},I.hide=function(){return this.toggle(!1)},I.show=function(){return this.toggle(!0)};var Te={focus:"focusin",blur:"focusout"},xe={mouseenter:"mouseover",mouseleave:"mouseout"},Ie=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function Ee(e){return xe[e]||Te[e]||e}function Ne(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Se(e){return e.___ce=e.___ce||{}}function _e(e,t){return!t||!g.call(t,(function(t){return e.indexOf(t)<0}))}function Fe(e,t,i,n,o){var a=Se(e);if(t)a[t]&&(a[t]=a[t].filter((function(a){var s=a[0],r=a[1],l=a[2];if(o&&l.guid!==o.guid||!_e(s,i)||n&&n!==r)return!0;e.removeEventListener(t,l)})));else for(t in a)Fe(e,t,i,n,o)}I.trigger=function(e,i){if(P(e)){var n=Ne(e),o=n[0],a=n[1],s=Ee(o);if(!s)return this;var r=Ie.test(s)?"MouseEvents":"HTMLEvents";(e=t.createEvent(r)).initEvent(s,!0,!0),e.namespace=a.join("."),e.___ot=o}e.___td=i;var l=e.___ot in Te;return this.each((function(t,i){l&&O(i[e.___ot])&&(i["___i".concat(e.type)]=!0,i[e.___ot](),i["___i".concat(e.type)]=!1),i.dispatchEvent(e)}))},I.off=function(e,t,i){var n=this;if(k(e))this.each((function(e,t){(F(t)||_(t)||S(t))&&Fe(t)}));else if(P(e))O(t)&&(i=t,t=""),D(R(e),(function(e,o){var a=Ne(o),s=a[0],r=a[1],l=Ee(s);n.each((function(e,n){(F(n)||_(n)||S(n))&&Fe(n,l,r,t,i)}))}));else for(var o in e)this.off(o,e[o]);return this},I.remove=function(e){return Z(this,e).detach().off(),this},I.replaceWith=function(e){return this.before(e).remove()},I.replaceAll=function(e){return E(e).replaceWith(this),this},I.on=function(e,t,i,n,o){var a=this;if(!P(e)){for(var s in e)this.on(s,t,i,e[s],o);return this}return P(t)||(k(t)||V(t)?t="":k(i)?(i=t,t=""):(n=i,i=t,t="")),O(n)||(n=i,i=void 0),n?(D(R(e),(function(e,s){var r=Ne(s),l=r[0],c=r[1],u=Ee(l),d=l in xe,p=l in Te;u&&a.each((function(e,a){if(F(a)||_(a)||S(a)){var s=function(e){if(e.target["___i".concat(e.type)])return e.stopImmediatePropagation();if((!e.namespace||_e(c,e.namespace.split(".")))&&(t||!(p&&(e.target!==a||e.___ot===u)||d&&e.relatedTarget&&a.contains(e.relatedTarget)))){var r=a;if(t){for(var l=e.target;!G(l,t);){if(l===a)return;if(!(l=l.parentNode))return}r=l}Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return r}}),Object.defineProperty(e,"delegateTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(e,"data",{configurable:!0,get:function(){return i}});var m=n.call(r,e,e.___td);o&&Fe(a,u,c,t,s),!1===m&&(e.preventDefault(),e.stopPropagation())}};s.guid=n.guid=n.guid||E.guid++,function(e,t,i,n,o){var a=Se(e);a[t]=a[t]||[],a[t].push([i,n,o]),e.addEventListener(t,o)}(a,u,c,t,s)}}))})),this):this},I.one=function(e,t,i,n){return this.on(e,t,i,n,!0)};var Be=/\r?\n/g,Oe=/file|reset|submit|button|image/i,Pe=/radio|checkbox/i;I.serialize=function(){var e="";return this.each((function(t,i){D(i.elements||[i],(function(t,i){if(!(i.disabled||!i.name||"FIELDSET"===i.tagName||Oe.test(i.type)||Pe.test(i.type)&&!i.checked)){var n=te(i);k(n)||D(c(n)?n:[n],(function(t,n){e+=function(e,t){return"&".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t.replace(Be,"\r\n")))}(i.name,n)}))}}))})),e.slice(1)},e.exports=E}()},631:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var n=i(537),o=i.n(n),a=i(645),s=i.n(a)()(o());s.push([e.id,".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\n}\n\n.hit-triage-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header {\n border: none;\n border-left: 4px solid transparent;\n border-radius: 1px;\n padding: 4px 8px;\n min-height: 28px;\n justify-content: flex-end;\n flex-direction: row-reverse;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\ntable.hit-triage-table {\n margin: 10px;\n width: calc(100% - 20px);\n}\n\n.hit-triage-table-container {\n max-width: 600px;\n max-height: 500px;\n overflow-y: scroll;\n}\n\n.hit-triage-error-div {\n color: red;\n text-align: start;\n}\n\n.mx-5 {\n margin-left: 5px;\n margin-right: 5px;\n}\n\n.hit-triage-new-template-functions-input > .ui-box {\n height: 300px;\n}\n\n.hit-triage-new-template-functions-input {\n max-height: 200px;\n max-width: unset !important;\n overflow-y: scroll;\n}\n\n\n.hit-triage-new-template-functions-input > .d4-tab-host {\n width: 100% !important;\n}\n\n.hit-triage-compute-dialog-host {\n max-height: 550px;\n max-width: 700px;\n}\n\n.hit-triage-compute-dialog-descriptors-group {\n margin-left: 16px;\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.d4-ribbon-name .ui-breadcrumbs {\n\toverflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\tflex-wrap: nowrap;\n padding: 0;\n}\n\n.d4-ribbon-name .ui-breadcrumbs i {\n\tpadding: 0 6px;\n\tfont-size: 10px;\n\tfont-weight: bold;\n}\n\n.d4-ribbon-name .ui-breadcrumbs-element:first-child {\n\twhite-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}","",{version:3,sources:["webpack://./css/hit-triage.css"],names:[],mappings:"AAAA;IACI,yBAAyB;IACzB,0BAA0B;AAC9B;;AAEA;IACI,aAAa;IACb,mBAAmB;IACnB,oBAAoB;AACxB;;AAEA;IACI,YAAY;IACZ,kCAAkC;IAClC,kBAAkB;IAClB,gBAAgB;IAChB,gBAAgB;IAChB,yBAAyB;IACzB,2BAA2B;AAC/B;;AAEA;IACI,oCAAoC;IACpC,yBAAyB;AAC7B;;AAEA;IACI,cAAc;AAClB;;AAEA;IACI,YAAY;IACZ,wBAAwB;AAC5B;;AAEA;IACI,gBAAgB;IAChB,iBAAiB;IACjB,kBAAkB;AACtB;;AAEA;IACI,UAAU;IACV,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;IAChB,iBAAiB;AACrB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,iBAAiB;IACjB,2BAA2B;IAC3B,kBAAkB;AACtB;;;AAGA;IACI,sBAAsB;AAC1B;;AAEA;IACI,iBAAiB;IACjB,gBAAgB;AACpB;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,kBAAkB;AACtB;;AAEA;CACC,gBAAgB;IACb,mBAAmB;IACnB,uBAAuB;CAC1B,iBAAiB;IACd,UAAU;AACd;;AAEA;CACC,cAAc;CACd,eAAe;CACf,iBAAiB;AAClB;;AAEA;CACC,mBAAmB;IAChB,gBAAgB;IAChB,uBAAuB;AAC3B",sourcesContent:[".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\n}\n\n.hit-triage-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header {\n border: none;\n border-left: 4px solid transparent;\n border-radius: 1px;\n padding: 4px 8px;\n min-height: 28px;\n justify-content: flex-end;\n flex-direction: row-reverse;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\ntable.hit-triage-table {\n margin: 10px;\n width: calc(100% - 20px);\n}\n\n.hit-triage-table-container {\n max-width: 600px;\n max-height: 500px;\n overflow-y: scroll;\n}\n\n.hit-triage-error-div {\n color: red;\n text-align: start;\n}\n\n.mx-5 {\n margin-left: 5px;\n margin-right: 5px;\n}\n\n.hit-triage-new-template-functions-input > .ui-box {\n height: 300px;\n}\n\n.hit-triage-new-template-functions-input {\n max-height: 200px;\n max-width: unset !important;\n overflow-y: scroll;\n}\n\n\n.hit-triage-new-template-functions-input > .d4-tab-host {\n width: 100% !important;\n}\n\n.hit-triage-compute-dialog-host {\n max-height: 550px;\n max-width: 700px;\n}\n\n.hit-triage-compute-dialog-descriptors-group {\n margin-left: 16px;\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.d4-ribbon-name .ui-breadcrumbs {\n\toverflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\tflex-wrap: nowrap;\n padding: 0;\n}\n\n.d4-ribbon-name .ui-breadcrumbs i {\n\tpadding: 0 6px;\n\tfont-size: 10px;\n\tfont-weight: bold;\n}\n\n.d4-ribbon-name .ui-breadcrumbs-element:first-child {\n\twhite-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}"],sourceRoot:""}]);const r=s},290:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var n=i(537),o=i.n(n),a=i(645),s=i.n(a)()(o());s.push([e.id,".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/src/u2.css"],names:[],mappings:"AAAA;;AAEA;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,kBAAkB;AACtB;;AAEA;IACI,SAAS;AACb",sourcesContent:[".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}"],sourceRoot:""}]);const r=s},143:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var n=i(537),o=i.n(n),a=i(645),s=i.n(a)()(o());s.push([e.id,"img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}","",{version:3,sources:["webpack://./src/app/hit-design-views/utils.css"],names:[],mappings:"AAAA;IACI,eAAe;AACnB",sourcesContent:["img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}"],sourceRoot:""}]);const r=s},645:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var i="",n=void 0!==t[5];return t[4]&&(i+="@supports (".concat(t[4],") {")),t[2]&&(i+="@media ".concat(t[2]," {")),n&&(i+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),i+=e(t),n&&(i+="}"),t[2]&&(i+="}"),t[4]&&(i+="}"),i})).join("")},t.i=function(e,i,n,o,a){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(n)for(var r=0;r<this.length;r++){var l=this[r][0];null!=l&&(s[l]=!0)}for(var c=0;c<e.length;c++){var u=[].concat(e[c]);n&&s[u[0]]||(void 0!==a&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=a),i&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=i):u[2]=i),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),t.push(u))}},t}},537:e=>{"use strict";e.exports=function(e){var t=e[1],i=e[3];if(!i)return t;if("function"==typeof btoa){var n=btoa(unescape(encodeURIComponent(JSON.stringify(i)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),a="/*# ".concat(o," */");return[t].concat([a]).join("\n")}return[t].join("\n")}},379:e=>{"use strict";var t=[];function i(e){for(var i=-1,n=0;n<t.length;n++)if(t[n].identifier===e){i=n;break}return i}function n(e,n){for(var a={},s=[],r=0;r<e.length;r++){var l=e[r],c=n.base?l[0]+n.base:l[0],u=a[c]||0,d="".concat(c," ").concat(u);a[c]=u+1;var p=i(d),m={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)t[p].references++,t[p].updater(m);else{var h=o(m,n);n.byIndex=r,t.splice(r,0,{identifier:d,updater:h,references:1})}s.push(d)}return s}function o(e,t){var i=t.domAPI(t);return i.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;i.update(e=t)}else i.remove()}}e.exports=function(e,o){var a=n(e=e||[],o=o||{});return function(e){e=e||[];for(var s=0;s<a.length;s++){var r=i(a[s]);t[r].references--}for(var l=n(e,o),c=0;c<a.length;c++){var u=i(a[c]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}a=l}}},569:e=>{"use strict";var t={};e.exports=function(e,i){var n=function(e){if(void 0===t[e]){var i=document.querySelector(e);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}t[e]=i}return t[e]}(e);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(i)}},216:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},565:(e,t,i)=>{"use strict";e.exports=function(e){var t=i.nc;t&&e.setAttribute("nonce",t)}},795:e=>{"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(i){!function(e,t,i){var n="";i.supports&&(n+="@supports (".concat(i.supports,") {")),i.media&&(n+="@media ".concat(i.media," {"));var o=void 0!==i.layer;o&&(n+="@layer".concat(i.layer.length>0?" ".concat(i.layer):""," {")),n+=i.css,o&&(n+="}"),i.media&&(n+="}"),i.supports&&(n+="}");var a=i.sourceMap;a&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),t.styleTagTransform(n,e,t.options)}(t,e,i)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},589:e=>{"use strict";e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function i(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={id:n,exports:{}};return e[n](a,a.exports,i),a.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.nc=void 0;var n={};(()=>{"use strict";i.r(n),i.d(n,{_package:()=>Fe,demoFileIngest:()=>Pe,demoFileIngest1:()=>ke,demoFileIngest2:()=>Ve,demoFileSubmit:()=>Le,gasteigerCellRenderer:()=>je,hitDesignApp:()=>Oe,hitTriageApp:()=>Be});const e=grok,t=DG,o=ui,a="campaignId",s="campaignId",r="HitTriageFunction",l="HitTriageDataSource",c="HitTriageSubmitFunction",u="Selected hits",d="Stage",p="Molecule",m="V-iD",h="V######",f="HTScript",v="HTQuery",g="molecules",y="Source",b="New template",w="Start",C="Create",A="Download",T="Cancel",x="Continue a campaign",I="New campaign";var E=i(379),N=i.n(E),S=i(795),_=i.n(S),F=i(569),B=i.n(F),O=i(565),P=i.n(O),k=i(216),V=i.n(k),L=i(589),j=i.n(L),D=i(631),H={};H.styleTagTransform=j(),H.setAttributes=P(),H.insert=B().bind(null,"head"),H.domAPI=_(),H.insertStyleElement=V(),N()(D.Z,H),D.Z&&D.Z.locals&&D.Z.locals;const M=e=>`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`;function R(e,t){const i=document.title,n=window.location.href.split("?")[0]+"?"+e+"="+t;if(history.replaceState){const e={Title:i,Url:n};history.replaceState(e,e.Title,e.Url)}}function U(t,i,n,a){var s;const r=o.breadcrumbs([i,n]),l=r.onPathClick.subscribe((e=>{1===e.length&&(l.unsubscribe(),$(t),a())})),c=null===(s=e.shell.v.ribbonMenu.root.parentElement)||void 0===s?void 0:s.getElementsByClassName("d4-ribbon-name")[0];return c&&(c.textContent="",c.appendChild(r.root)),{breadcrumbs:r,sub:l}}function $(e){const t=e.getRibbonPanels();(null==t?void 0:t.length)&&(t.pop(),e.setRibbonPanels(t))}function q(e){return e.reduce(((e,t)=>e||t.reduce(((e,t)=>e||t.classList.contains("hit-design-submit-button")||Array.from(t.children).some((e=>e.classList.contains("hit-design-submit-button")))),!1)),!1)}function Y(e,i,n){return o=this,a=void 0,r=function*(){if(0===n.rowCount)return;if(!e.col(i))throw new Error("There is no molecule column in dataframe");let o=n.col(g);if(o||(yield n.meta.detectSemanticTypes(),o=n.columns.bySemType(t.SEMTYPE.MOLECULE)),!o)throw new Error("There is no original molecule column in query result dataframe");const a=n.columns.names().filter((e=>e!==g));e.join(n,[i],[o.name],void 0,a,void 0,!0)},new((s=void 0)||(s=Promise))((function(e,t){function i(e){try{l(r.next(e))}catch(e){t(e)}}function n(e){try{l(r.throw(e))}catch(e){t(e)}}function l(t){var o;t.done?e(t.value):(o=t.value,o instanceof s?o:new s((function(e){e(o)}))).then(i,n)}l((r=r.apply(o,a||[])).next())}));var o,a,s,r}const W={String:t.TYPE.STRING,Number:t.TYPE.FLOAT,Boolean:t.TYPE.BOOL,Date:t.TYPE.DATE_TIME,Molecule:t.SEMTYPE.MOLECULE};var G=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))},J=i(553),Z=i.n(J);function z(i,n,a,s,r){var l,c,u,d,p,m,h,g,y,b,w,C,A,T,x,I,E,N,S,_,F,B,O,P,k,V,L,j,D,H,M;return j=this,D=void 0,M=function*(){const j=yield i.computeFunctions,D=j.functions.filter((({inputs:e})=>e.length>2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).map((e=>{var t,i,n,o;return{package:e.package.name,name:e.name,args:null!==(o=null===(n=null===(i=null===(t=null==s?void 0:s.compute)||void 0===t?void 0:t.functions)||void 0===i?void 0:i.find((t=>t.name===e.name&&t.package===e.package.name)))||void 0===n?void 0:n.args)&&void 0!==o?o:{}}})),H=j.scripts.filter((({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).map((e=>{var t,i,n,o;return{name:e.name,id:e.id,args:null!==(o=null===(n=null===(i=null===(t=null==s?void 0:s.compute)||void 0===t?void 0:t.scripts)||void 0===i?void 0:i.find((t=>t.id===e.id)))||void 0===n?void 0:n.args)&&void 0!==o?o:{}}})),M=j.queries.filter((e=>e.inputs.length>0&&"list"===e.inputs[0].propertyType)).map((e=>{var t,i,n,o,a;return{name:null!==(t=e.friendlyName)&&void 0!==t?t:e.name,id:e.id,args:null!==(a=null===(o=null===(n=null===(i=null==s?void 0:s.compute)||void 0===i?void 0:i.queries)||void 0===n?void 0:n.find((t=>t.id===e.id)))||void 0===o?void 0:o.args)&&void 0!==a?a:{}}})),R=!!(null===(c=null===(l=null==s?void 0:s.compute)||void 0===l?void 0:l.descriptors)||void 0===c?void 0:c.enabled)||r,U=yield e.chem.descriptorsTree(),$=o.tree();$.root.classList.add("hit-triage-compute-dialog-descriptors-group");const q=o.div([],{classes:"hit-triage-compute-dialog-host"}),Y=[];function W(e,t){const i=t.group(e,null,!1);return i.enableCheckBox(!1),i}const G=Object.keys(U),J=null!==(p=null===(d=null===(u=null==s?void 0:s.compute)||void 0===u?void 0:u.descriptors)||void 0===d?void 0:d.args)&&void 0!==p?p:[];for(const e of G){const t=W(e,$);for(const i of U[e].descriptors){const e=t.item(i.name,i);Y.push(e),e.enableCheckBox(J.includes(i.name))}}const z="Descriptors",Q={[z]:z},K=R?{[z]:$.root}:{},X={},ee={[z]:!1};ee.Descriptors=!!(null===(h=null===(m=null==s?void 0:s.compute)||void 0===m?void 0:m.descriptors)||void 0===h?void 0:h.enabled)&&(null===(b=null===(y=null===(g=null==s?void 0:s.compute)||void 0===g?void 0:g.descriptors)||void 0===y?void 0:y.args)||void 0===b?void 0:b.length)>0;for(const e of D){const i=t.Func.find({package:e.package,name:e.name})[0],n=i.prepare(e.args),a=`${e.package}:${e.name}`;X[a]=n;const r=o.div(),l=yield n.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",K[null!==(w=i.friendlyName)&&void 0!==w?w:i.name]=r,Q[null!==(C=i.friendlyName)&&void 0!==C?C:i.name]=a,ee[a]=null!==(x=null===(T=null===(A=null==s?void 0:s.compute)||void 0===A?void 0:A.functions)||void 0===T?void 0:T.some((t=>t.name===e.name&&t.package===e.package)))&&void 0!==x&&x,r.children[0].style.display="none",r.children[1].style.display="none",l.forEach((t=>{var i,n;(null===(i=t.property)||void 0===i?void 0:i.name)&&Object.keys(e.args).includes(null===(n=t.property)||void 0===n?void 0:n.name)&&(t.value=e.args[t.property.name]),t.fireChanged()}))}for(const t of H)try{const i=yield e.dapi.scripts.find(t.id),n=i.prepare(t.args),a=`HTScript:${null!==(I=t.name)&&void 0!==I?I:""}:${t.id}`;X[a]=n;const r=o.div(),l=yield n.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",K[null!==(E=i.friendlyName)&&void 0!==E?E:i.name]=r,Q[null!==(N=i.friendlyName)&&void 0!==N?N:i.name]=a,ee[a]=null!==(F=null===(_=null===(S=null==s?void 0:s.compute)||void 0===S?void 0:S.scripts)||void 0===_?void 0:_.some((e=>e.id===t.id)))&&void 0!==F&&F,r.children[0].style.display="none",r.children[1].style.display="none",l.forEach((e=>{var i,n;(null===(i=e.property)||void 0===i?void 0:i.name)&&Object.keys(t.args).includes(null===(n=e.property)||void 0===n?void 0:n.name)&&(e.value=t.args[e.property.name]),e.fireChanged()}))}catch(e){console.error(e);continue}for(const t of M)try{const i=yield e.dapi.queries.find(t.id),n=i.prepare(t.args),a=`HTQuery:${null!==(B=t.name)&&void 0!==B?B:""}:${t.id}`;X[a]=n;const r=o.div(),l=yield n.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",K[null!==(O=i.friendlyName)&&void 0!==O?O:i.name]=r,Q[null!==(P=i.friendlyName)&&void 0!==P?P:i.name]=a,ee[a]=null!==(L=null===(V=null===(k=null==s?void 0:s.compute)||void 0===k?void 0:k.queries)||void 0===V?void 0:V.some((e=>e.id===t.id)))&&void 0!==L&&L,r.children[0].style.display="none",l.forEach((e=>{var i,n;(null===(i=e.property)||void 0===i?void 0:i.name)&&Object.keys(t.args).includes(null===(n=e.property)||void 0===n?void 0:n.name)&&(e.value=t.args[e.property.name]),e.fireChanged()}))}catch(e){console.error(e);continue}const te=o.tabControl(K,!0);function ie(){const e={descriptors:[],externals:{},scripts:{},queries:{}};e.descriptors=ee.Descriptors?Y.filter((e=>e.checked)).map((e=>e.value.name)):[];const t=Object.entries(X).filter((([e,t])=>ee[e]));t.filter((([e,t])=>!e.startsWith(f)&&!e.startsWith(v))).forEach((([t,i])=>{e.externals[t]={};const n=i.inputs;Object.entries(n).slice(2).forEach((([i,n])=>{e.externals[t][i]=n}))})),t.filter((([e,t])=>e.startsWith(f))).forEach((([t,i])=>{e.scripts[t]={};const n=i.inputs;Object.entries(n).slice(2).forEach((([i,n])=>{e.scripts[t][i]=n}))})),t.filter((([e,t])=>e.startsWith(v))).forEach((([t,i])=>{e.queries[t]={};const n=i.inputs;Object.entries(n).slice(1).forEach((([i,n])=>{e.queries[t][i]=n}))})),console.log(e),n(e)}return te.root.style.width="100%",te.root.style.minWidth="350px",q.appendChild(te.root),te.panes.forEach((e=>{const t=o.boolInput("",ee[Q[e.name]],(i=>{ee[Q[e.name]]=!!t.value,i?Z()(e.content).find("input").removeAttr("disabled"):Z()(e.content).find("input").attr("disabled","true")}));t.setTooltip("Toggle calculation of this function"),e.header.appendChild(t.root),e.header.classList.add("hit-triage-compute-dialog-pane-header")})),r&&o.dialog("Compute").add(q).onOK((()=>ie())).onCancel(a).show(),{root:q,okProxy:ie}},new((H=void 0)||(H=Promise))((function(e,t){function i(e){try{o(M.next(e))}catch(e){t(e)}}function n(e){try{o(M.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof H?o:new H((function(e){e(o)}))).then(i,n)}o((M=M.apply(j,D||[])).next())}))}const Q=rxjs;class K{constructor(e,t=[],i={}){this.onItemChanged=new Q.Subject,this.onAddingItemChanged=new Q.Subject,this.onItemAdded=new Q.Subject,this.onItemRemoved=new Q.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.properties=e,this.options=Object.assign(Object.assign({},this.options),i),this._root=o.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=t,this.render()}get root(){return this._root}get items(){return this._items}render(){var e,t,i,n;if(o.empty(this._root),!this.options.horizontalInputNames)for(const t of this.properties){const i=o.divText(null!==(e=t.caption)&&void 0!==e?e:t.name);i.style.fontWeight="bold",this._root.appendChild(i)}for(const e of this._items){const t=this.getItemDiv(e);for(const e of t)this._root.appendChild(e)}if(this.options.allowAdd){const e=this.getItemDiv(null!==(n=null===(i=(t=this.options).newItemFunction)||void 0===i?void 0:i.call(t))&&void 0!==n?n:void 0,!0);for(const t of e)this._root.appendChild(t)}}getItemDiv(e={},i){var n;const a=[],s={};let r=null;for(const l of this.properties){void 0===e[l.name]&&(e[l.name]=null);const c=(null===(n=this.options.customInputs)||void 0===n?void 0:n[l.name])?this.options.customInputs[l.name](e):o.input.forProperty(l,e);a.push(this.options.horizontalInputNames?c.root:this.hideLabel(c.root)),l.propertyType!==t.TYPE.BOOL&&"color"!==l.name.toLowerCase()&&c.input&&(c.input.style.width="100%"),s[l.name]=c,c.onChanged((()=>{e[l.name]=c.value,i?this.onAddingItemChanged.next({item:e,fieldName:l.name}):this.onItemChanged.next({item:e,fieldName:l.name})})),c.root.style.alignItems="center",r=c}let l=null;if(i)l=o.icons.add((()=>{const e=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(s).forEach((t=>{e[t]=s[t].value})),this._items.push(e),this.onItemAdded.next(e),this.render()}),this.options.addButtonTooltip);else{if(!this.options.allowRemove)return a;l=o.icons.delete((()=>{this._items.splice(this._items.indexOf(e),1),this.onItemRemoved.next(e),this.render()}),this.options.removeButtonTooltip)}return r&&r.addOptions?r.addOptions(l):null==r||r.root.appendChild(l),l.style.color="#2083d5",a}hideLabel(e){return e.getElementsByTagName("label")[0]&&e.removeChild(e.getElementsByTagName("label")[0]),e}}var X=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function ee(i,n){var a,s;return X(this,void 0,void 0,(function*(){const u=t.Func.find({tags:[r]}),d=(yield Fe.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5))),p=[];for(const e of d){const t=JSON.parse(yield Fe.files.readAsText(`Hit Triage/templates/${e}.json`));p.push(t.key)}const m=t.Func.find({tags:[c]}),h={};m.forEach((e=>{var t;h[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const g=o.choiceInput("Submit function",null,[null,...Object.keys(h)]);g.value=null,g.nullable=!0,g.fireChanged(),g.setTooltip("Select function to be called upon submitting");const b=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),w=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),A=o.stringInput("Name","",(()=>{""===A.value||d.includes(A.value)?(A.root.style.borderBottom="1px solid red",b.style.opacity="100%"):(A.root.style.borderBottom="none",b.style.opacity="0%")})),x=o.stringInput("Key","",(()=>{""===x.value||p.includes(x.value)?(x.root.style.borderBottom="1px solid red",w.style.opacity="100%"):(x.root.style.borderBottom="none",w.style.opacity="0%")}));x.setTooltip("Template key used for campaign prefix"),A.setTooltip("Template name"),A.root.style.borderBottom="none",x.root.style.borderBottom="none",b.style.opacity="0%",w.style.opacity="0%";const I={Descriptors:"Descriptors"};u.forEach((e=>{var t;I[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=`${e.package.name}:${e.name}`}));let E=null;const N=yield z(i,(e=>{E=e}),(()=>null),{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},!1);if(N.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(n).length){const i=t.Func.find({tags:[l]}),o=yield e.dapi.queries.include("params,connection").filter("#HitTriageDataSource").list();i.forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e})),o.forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}))}const S=Object.keys(n),_=o.choiceInput(y,S[0],S),F=o.choiceInput("Ingest using","Query",["Query","File"],(()=>{"Query"!==F.value?_.root.style.display="none":_.root.style.display="block"})),B=te(),O=o.div([o.h2("Details"),o.div([A,b]),o.div([x,w]),F.root,_.root,B.fieldsDiv,o.h2("Compute"),N.root,o.h2("Submit"),g.root],"ui-form"),P=o.buttonsInput([]),k=null!==(s=null===(a=P.getElementsByClassName("ui-input-editor"))||void 0===a?void 0:a[0])&&void 0!==s?s:P;O.appendChild(P);const V=new Promise((e=>{const t=o.button(T,(()=>e()));k.appendChild(t)})),L=new Promise((t=>{const i=o.bigButton(C,(()=>function(){var i,n,o,a,s,r,l;return X(this,void 0,void 0,(function*(){if(N.okProxy(),"100%"===b.style.opacity)return void e.shell.error("Template name is empty or already exists");const c=g.value?h[g.value]:void 0,u=Object.assign(Object.assign({name:A.value,key:x.value,campaignFields:B.getFields(),dataSourceType:null!==(i=F.value)&&void 0!==i?i:"Query",compute:{descriptors:{enabled:!!(null===(n=null==E?void 0:E.descriptors)||void 0===n?void 0:n.length),args:null!==(o=null==E?void 0:E.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(a=null==E?void 0:E.externals)&&void 0!==a?a:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(s=null==E?void 0:E.scripts)&&void 0!==s?s:{}).filter((([e,t])=>e.startsWith(f)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(r=null==E?void 0:E.queries)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(v)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))}},c?{submit:{fName:c.name,package:c.package.name}}:{}),{queryFunctionName:"Query"===F.value&&null!==(l=_.value)&&void 0!==l?l:void 0});var d;d=u,Fe.files.writeAsText(`Hit Triage/templates/${d.name}.json`,JSON.stringify(d)),e.shell.info("Template created successfully"),t(u)}))}()));k.appendChild(i)}));return{root:O,template:L,cancelPromise:V}}))}function te(e){const i=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING}),t.Property.fromOptions({name:"Type",type:t.TYPE.STRING,choices:Object.keys(W)}),t.Property.fromOptions({name:"Required",type:t.TYPE.BOOL})],n=new K(i,e?e.map((e=>({Name:e.name,Type:e.type,Required:e.required}))):void 0,{horizontalInputNames:!1});n.root.style.maxWidth="750px";let a={};n.onItemAdded.subscribe((e=>{a=null!=e?e:{}})),n.onAddingItemChanged.subscribe((e=>{e&&(a=e.item)}));const s=o.h2("Additional fields");o.tooltip.bind(s,"Additional fields to be filled by user for each campaign");const r=o.div([s,n.root]);return{getFields:function(){var e;const t=n.items.filter((e=>e.Name)).map((e=>{var t;return{name:e.Name,type:e.Type,required:null!==(t=e.Required)&&void 0!==t&&t}}));return a.Name&&""!==a.Name&&a.Type&&(null!==(e=a.Required)&&void 0!==e||(a.Required=!1),t.push({name:a.Name,type:a.Type,required:a.Required})),t},fieldsDiv:o.div([r])}}var ie=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class ne extends t.ViewBase{constructor(e){super(),this.app=e}get template(){return this.app.template}onActivated(){}onReset(){}process(){return ie(this,void 0,void 0,(function*(){}))}deleteCampaign(e,t){return ie(this,void 0,void 0,(function*(){yield Fe.files.delete(`${e}/campaigns/${t}`)}))}}var oe=i(290),ae={};ae.styleTagTransform=j(),ae.setAttributes=P(),ae.insert=B().bind(null,"head"),ae.domAPI=_(),ae.insertStyleElement=V(),N()(oe.Z,ae),oe.Z&&oe.Z.locals&&oe.Z.locals;var se;!function(t){let i,n;!function(e){e.vert=function(e){return o.divV(e.map((e=>o.render(e))),{classes:"u2-panel"})},e.horz=function(e){return o.divH(e.map((e=>o.render(e))),{classes:"u2-panel"})}}(i=t.panels||(t.panels={})),t.appHeader=function(e){const t=o.iconImage("",e.iconPath);return Z()(t).addClass("ui-app-header-icon").css("margin-right","20px"),i.horz([t,i.vert([o.markdown(e.description),e.learnMoreUrl?o.link("Learn more",e.learnMoreUrl):null])])},function(t){t.runAsync=function(t,i){return n=this,a=void 0,r=function*(){o.setUpdateIndicator(t,!0);try{return yield i()}catch(t){e.log.error(t)}finally{o.setUpdateIndicator(t,!1)}},new((s=void 0)||(s=Promise))((function(e,t){function i(e){try{l(r.next(e))}catch(e){t(e)}}function o(e){try{l(r.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof s?n:new s((function(e){e(n)}))).then(i,o)}l((r=r.apply(n,a||[])).next())}));var n,a,s,r}}(n=t.tools||(t.tools={}))}(se||(se={}));var re=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class le extends ne{constructor(t){super(t),this.readmePath=Fe.webRoot+"README_HT.md",this.deletedCampaigns=[],this.dataSourceFunctionsMap={},this.name="Hit Triage",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(this.readmePath),this.checkCampaign().then((e=>{this.app.campaign=e,this.init()}))}onActivated(){e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(this.readmePath)}init(e){return re(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const t=o.h1(x),i=o.h1(I,{style:{marginLeft:"10px"}}),n=se.appHeader({iconPath:Fe.webRoot+"/images/icons/hit-triage-icon.png",learnMoreUrl:"https://github.com/datagrok-ai/public/blob/master/packages/HitTriage/README_HT.md",description:"- Configure your own workflow using the template editor.\n- Calculate different molecular properties.\n- Filter molecules using different criteria.\n- Submit processed dataframe to the function of your choice.\n- Save campaigns and continue any time from where you left off.\n "}),a=o.div(),s=o.div([],{classes:"ui-form"}),r=yield this.getCampaignsTable();yield this.startNewCampaign(a,s,e),Z()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,t],{style:{marginLeft:"10px"}}),r,i,s,a])),this.app.resetBaseUrl()}catch(e){throw o.setUpdateIndicator(this.root,!1),e}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(e,t,i){var n;return re(this,void 0,void 0,(function*(){const a=(yield Fe.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5)));i&&!a.includes(i.name)&&a.push(i.name);const s=()=>re(this,void 0,void 0,(function*(){const t=r.value,n=i&&i.name===t?i:JSON.parse(yield Fe.files.readAsText("Hit Triage/templates/"+t+".json")),o=yield this.getNewCampaignAccordeon(n,e);Z()(e).empty(),e.className="ui-form",e.appendChild(o)})),r=o.choiceInput("Template",null!==(n=null==i?void 0:i.name)&&void 0!==n?n:a[0],a,(()=>re(this,void 0,void 0,(function*(){yield s()})))),l=o.icons.add((()=>re(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),o.setUpdateIndicator(this.root,!1)}))),b);r.addOptions(l),yield s(),Z()(t).empty(),t.appendChild(r.root)}))}checkCampaign(e){return re(this,void 0,void 0,(function*(){const t=location.search,i=new URLSearchParams(t);if(!i.has(a)&&!e)return;const n=null!=e?e:i.get(a);if(!(yield Fe.files.exists(`Hit Triage/campaigns/${n}/campaign.json`)))return;const o=JSON.parse(yield Fe.files.readAsText(`Hit Triage/campaigns/${n}/campaign.json`)),s=JSON.parse(yield Fe.files.readAsText(`Hit Triage/templates/${o.templateName}.json`));return this.app.setTemplate(s,o.filters,n,o.ingest),e&&R(a,e),o}))}getCampaignsTable(){return re(this,void 0,void 0,(function*(){const e=(yield Fe.files.list("Hit Triage/campaigns")).filter((e=>-1===this.deletedCampaigns.indexOf(e.name))),t={};for(const i of e){const e=JSON.parse(yield Fe.files.readAsText(`Hit Triage/campaigns/${i.name}/campaign.json`));t[e.name]=e}const i=Object.values(t).map((e=>({name:e.name,createDate:e.createDate,rowCount:e.rowCount,filtered:e.filteredRowCount,status:e.status}))),n=o.table(i,(e=>[o.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.filtered,e.status,o.icons.delete((()=>re(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK((()=>re(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Triage",e.name),this.deletedCampaigns.push(e.name),yield this.init()})))).show()}))),"Delete campaign")]),["Name","Created","Total","Selected","Status",""]);return n.style.color="var(--grey-5)",n}))}setCampaign(e){return re(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(i,n){return re(this,void 0,void 0,(function*(){o.setUpdateIndicator(n,!0);const{root:a,promise:s,cancelPromise:r}=yield function(i,n){var a,s;return G(this,void 0,void 0,(function*(){const r=o.divText("",{style:{color:"red"}});let c=null;const u=()=>G(this,void 0,void 0,(function*(){try{if(c=d.value,!c)return;if(yield c.meta.detectSemanticTypes(),!c.columns.bySemType(t.SEMTYPE.MOLECULE))return void(r.innerText="No molecules column found");r.innerText=""}catch(e){r.innerText="Error parsing file"}})),d=o.tableInput("Dataframe",null,void 0,u);yield u();const p=o.div([d,r]);0===Object.keys(n).length&&(t.Func.find({tags:[l]}).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e})),(yield e.dapi.queries.include("params,connection").filter("#HitTriageDataSource").list()).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e})));let m=null;const h=()=>G(this,void 0,void 0,(function*(){const e=n[v.value];m=e.prepare();const t=yield m.getEditor();t.classList.remove("ui-form"),f.innerHTML="",f.appendChild(t)})),f=o.div([]),v=o.choiceInput(y,null!==(a=i.queryFunctionName)&&void 0!==a?a:Object.keys(n)[0],Object.keys(n),h);yield h(),i.queryFunctionName&&(null===(s=v.root.getElementsByTagName("select").item(0))||void 0===s||s.setAttribute("disabled","true"));const g=o.div([v,f]);g.style.display="none";const b=o.div([p,g]),C=i.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:W[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),A={},x=C.length?o.input.form(A,C):o.div();x.classList.remove("ui-form"),"File"===i.dataSourceType?(p.style.display="inherit",g.style.display="none"):(p.style.display="none",g.style.display="inherit");const I=o.div([b,...C.length?[x]:[]]),E=o.buttonsInput([]);return I.appendChild(E),{promise:new Promise((t=>{const a=()=>G(this,void 0,void 0,(function*(){if("File"===i.dataSourceType){if(!c)return void e.shell.error("No file selected");const i=c;i.name=c.name,t({df:i,type:"File",campaignProps:A})}else{const i=n[v.value];if(!i)return void e.shell.error("No function selected");const o={};Object.entries(m.inputs).forEach((([e,t])=>{o[e]=t}));const a=yield i.apply(o);t({df:a,type:"Query",campaignProps:A})}})),s=o.bigButton(w,(()=>a()));E.appendChild(s)})),root:I,cancelPromise:new Promise((e=>{o.button(T,(()=>e()))}))}}))}(i,this.dataSourceFunctionsMap);return o.setUpdateIndicator(n,!1),s.then((e=>re(this,void 0,void 0,(function*(){this.app.dataFrame=e.df,this.app._fileInputType=e.type,yield this.app.setTemplate(i),this.app.campaignProps=e.campaignProps,this.app.saveCampaign(void 0,!1)})))),r.then((()=>{this.init()})),a}))}createNewTemplate(){return re(this,void 0,void 0,(function*(){const i=yield ee(this.app,this.dataSourceFunctionsMap),n=new t.ViewBase,o=e.shell.v;n.name="New Template",n.root.appendChild(i.root),n.parentCall=this.app.parentCall,e.shell.addView(n),n.path=new URL(this.app.baseUrl).pathname+"/new-template",n.parentView=o;const{sub:a}=U(e.shell.v,"Hit Triage",b,(()=>{e.shell.v=o,n.close()}));i.template.then((t=>re(this,void 0,void 0,(function*(){yield this.init(t),n.close(),$(n),e.shell.v=o,a.unsubscribe()})))),i.cancelPromise.then((()=>{a.unsubscribe(),n.close(),e.shell.v=o}))}))}}class ce extends ne{constructor(e){super(e),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){var i,n,o,a,s;return n=this,o=void 0,s=function*(){const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=t.Func.find({name:n.fName,package:n.package})[0];if(!o)return void e.shell.error(`Function ${n.fName} not found.`);const a=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:a,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((a=void 0)||(a=Promise))((function(e,t){function i(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a((function(e){e(n)}))).then(i,r)}l((s=s.apply(n,o||[])).next())}))}}var ue=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class de{constructor(i){this.parentCall=i,this.resetBaseUrl(),this.computeFunctions=new Promise((i=>ue(this,void 0,void 0,(function*(){const n=t.Func.find({tags:[r]}),o=yield e.dapi.scripts.include("params").filter("#HitTriageFunction").list(),a=yield e.dapi.queries.include("params,connection").filter("#HitTriageFunction").list();i({functions:n,scripts:o,queries:a})}))))}resetBaseUrl(){const e=window.location.href,t=new URL(e);this.baseUrl=t.origin+t.pathname}getFilterType(e){const i=this.dataFrame.col(e);return(null==i?void 0:i.semType)===t.SEMTYPE.MOLECULE?t.FILTER_TYPE.SUBSTRUCTURE:(null==i?void 0:i.type)===t.COLUMN_TYPE.BOOL?t.FILTER_TYPE.BOOL_COLUMNS:(null==i?void 0:i.type)===t.COLUMN_TYPE.STRING?t.FILTER_TYPE.CATEGORICAL:t.FILTER_TYPE.HISTOGRAM}download(e,i,n=!1){const o=document.createElement("a"),a=t.DataFrame.fromColumns(e.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv({filteredRowsOnly:n});o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),o.setAttribute("download",i+".csv"),o.click()}getNewCampaignName(e,t){return ue(this,void 0,void 0,(function*(){const i=(yield Fe.files.list(e)).map((e=>e.name)).filter((e=>e.startsWith(t)));if(0===i.length)return t+"-1";const n=i.map((e=>e.split("-")[1])).filter(Boolean).map((e=>parseInt(e,10))).sort();return t+"-"+(n[n.length-1]+1).toString()}))}setBaseUrl(){const e=document.title;if(history.replaceState){const t={Title:e,Url:this.baseUrl};history.replaceState(t,t.Title,t.Url)}}}var pe=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))},me=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function he(e){let t=0;if(e.length>1)for(const i of e.toList()){if(!i||!i.startsWith(h[0])||i.length!==h.length)continue;const e=parseInt(i.substring(1));isNaN(e)||(t=Math.max(e,t))}return`V${"".concat(...new Array(h.length-1-(t+1).toString().length).fill("0"))}${t+1}`}function fe(i,n,o){var a,s;return me(this,void 0,void 0,(function*(){const r=n.col(o);if(!r)throw new Error("There is no molecule column in dataframe");for(let t=0;t<r.length;t++){if(r.isNone(t))continue;const i=r.get(t);if(!i)continue;const n=e.chem.convert(i,e.chem.Notation.Unknown,e.chem.Notation.Smiles);r.set(t,n,!1)}i.descriptors&&i.descriptors.length>0&&(yield e.chem.descriptors(n,o,i.descriptors));for(const e of Object.keys(i.externals)){const a=i.externals[e],s=t.Func.find({package:e.split(":")[0],name:e.split(":")[1]})[0],r=s.inputs[0].name,l=s.inputs[1].name;a&&(yield s.apply(Object.assign(Object.assign({},a),{[r]:n,[l]:o})))}for(const t of Object.keys(null!==(a=i.scripts)&&void 0!==a?a:{})){const a=i.scripts[t];if(a){const i=t.split(":")[2];if(!i)continue;try{const t=yield e.dapi.scripts.find(i);if(!t)continue;const s=t.inputs[0].name,r=t.inputs[1].name;yield t.apply(Object.assign(Object.assign({},a),{[s]:n,[r]:o}))}catch(e){console.error(e)}}}for(const t of Object.keys(null!==(s=i.queries)&&void 0!==s?s:{})){const a=i.queries[t];if(a){const i=t.split(":")[2];if(!i)continue;try{const t=yield e.dapi.queries.find(i);if(!t)continue;const s=t.inputs[0].name,r=n.col(o).toList(),l=yield t.apply(Object.assign(Object.assign({},a),{[s]:r}));l&&(yield Y(n,o,l))}catch(e){console.error(e)}}}}))}var ve=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class ge extends de{constructor(i){super(i),this._filterViewName="Hit triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=new le(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof ne&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,e.shell.addView(this.multiView),e.events.onCurrentViewChanged.subscribe((()=>{var t,i,n,o;try{(null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentPickViewId&&(e.shell.windows.showHelp=!1,this.setBaseUrl(),R(a,null!==(o=null!==(i=this._campaignId)&&void 0!==i?i:null===(n=this._campaign)||void 0===n?void 0:n.name)&&void 0!==o?o:""))}catch(e){console.error(e)}}))}setTemplate(i,n,o,s){var r,l,c,u,d,p,m,h,f,v,g,y,b,w;return ve(this,void 0,void 0,(function*(){if((null===(r=this._pickView)||void 0===r?void 0:r.dataFrame)&&e.shell.closeTable(null===(l=this._pickView)||void 0===l?void 0:l.dataFrame),this._pickView=void 0,o?s&&(this._fileInputType=s.type,"File"===s.type?this.dataFrame=yield e.dapi.files.readCsv(s.query):this.dataFrame=yield e.functions.call(s.query)):(o=yield this.getNewCampaignName("Hit Triage/campaigns",i.key),R(a,o)),!this.dataFrame)return void console.error("Dataframe is empty.");if((null===(c=this._campaign)||void 0===c?void 0:c.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&(i.semType=t)})),yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(d=null===(u=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===u?void 0:u.name)&&void 0!==d?d:void 0,this._dfName=null!==(p=this.dataFrame.name)&&void 0!==p?p:null==s?void 0:s.query,this.dataFrame.name=null!==(h=null!==(m=this._dfName)&&void 0!==m?m:this.dataFrame.name)&&void 0!==h?h:"Molecules",this._campaignId=o,this.template=(null===(f=this.campaign)||void 0===f?void 0:f.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:i.dataSourceType,queryFunctionName:i.queryFunctionName}):i,this._campaignFilters=n,!n){const e={},t={},n={};i.compute.functions.forEach((t=>{const i=`${t.package}:${t.name}`;e[i]=t.args})),null===(v=i.compute.scripts)||void 0===v||v.forEach((e=>{const i=`HTScript:${e.name}:${e.id}`;t[i]=e.args})),null===(g=i.compute.queries)||void 0===g||g.forEach((e=>{const t=`HTQuery:${e.name}:${e.id}`;n[t]=e.args})),yield fe({descriptors:i.compute.descriptors.enabled?i.compute.descriptors.args:[],externals:e,scripts:t,queries:n},this.dataFrame,this._molColName)}const C=e.shell.v,A=e.shell.addView(this.pickView);this.currentPickViewId=A.name,this._submitView=new ce(this),this.setBaseUrl(),R(a,null!==(w=null!==(y=this._campaignId)&&void 0!==y?y:null===(b=this._campaign)||void 0===b?void 0:b.name)&&void 0!==w?w:"");const T=A;setTimeout((()=>{this._pickViewPromise&&this._pickViewPromise.then((()=>{const{sub:t}=U(T,"Hit Triage","Pick",(()=>{e.shell.v=C,T.close(),t.unsubscribe()}))}))}),300),e.shell.windows.showHelp=!1}))}get filterSettings(){return this._campaignFilters}get campaignId(){return this._campaignId}get pickView(){return this._pickView=this.getFilterView()}get molColName(){var e,i,n;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name}get fileInputType(){return this._fileInputType}get campaign(){return this._campaign}set campaign(e){this._campaign=e}getFilterView(){let e=null;this._pickViewPromise=new Promise((t=>{e=t})),this.dataFrame.col(u)||this.dataFrame.columns.addNewBool(u).init(!1);const i=t.TableView.create(this.dataFrame,!1),n=i.getRibbonPanels(),a=o.iconFA("wrench",(()=>ve(this,void 0,void 0,(function*(){z(this,(e=>ve(this,void 0,void 0,(function*(){var t,i,n,o,a,s,r;const l=this.template.compute.descriptors.args,c=this.template.compute.functions,u=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],d=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],p=e.descriptors,m={descriptors:{enabled:!!(null===(n=null==e?void 0:e.descriptors)||void 0===n?void 0:n.length),args:null!==(o=null==e?void 0:e.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(a=null==e?void 0:e.externals)&&void 0!==a?a:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(s=null==e?void 0:e.scripts)&&void 0!==s?s:{}).filter((([e,t])=>e.startsWith(f)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(r=null==e?void 0:e.queries)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(v)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))};this.template.compute=m;const h=p.filter((e=>!l.includes(e))),g=m.functions.filter((e=>{if(!c.some((t=>t.name===e.name&&t.package===e.package)))return!0;const t=c.find((t=>t.name===e.name&&t.package===e.package));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),y=m.scripts.filter((e=>{if(!u.some((t=>t.id===e.id)))return!0;const t=u.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),b=m.queries.filter((e=>{if(!d.some((t=>t.id===e.id)))return!0;const t=d.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),w={};g.forEach((e=>{const t=`${e.package}:${e.name}`;w[t]=e.args}));const C={};y.forEach((e=>{const t=`HTScript:${e.name}:${e.id}`;C[t]=e.args}));const A={};b.forEach((e=>{const t=`HTQuery:${e.name}:${e.id}`;A[t]=e.args})),yield fe({descriptors:h,externals:w,scripts:C,queries:A},this.dataFrame,this._molColName),this.saveCampaign("In Progress",!1)}))),(()=>null),this.template,!0)}))),"Calculate additional properties"),s=o.bigButton("Submit",(()=>{var e;const t=null===(e=this._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}}));s.classList.add("hit-design-submit-button");const r=q(n);return n.push([a,...r?[]:[s]]),i.setRibbonPanels(n),i.name=this._filterViewName,setTimeout((()=>ve(this,void 0,void 0,(function*(){var n;i._onAdded(),yield new Promise((e=>setTimeout(e,1e3)));const o=i.filters(this._campaignFilters?{filters:this._campaignFilters}:void 0);if(null===(n=this._campaign)||void 0===n?void 0:n.layout)try{const e=t.ViewLayout.fromViewState(this._campaign.layout);i.loadLayout(e)}catch(e){console.error(e)}i.dataFrame.onFilterChanged.subscribe((e=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=o.getOptions().look.filters})),setTimeout((()=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=o.getOptions().look.filters}),300),e&&e()}))),300),i.parentCall=this.parentCall,i}getSummary(){var e,t,i,n,a,s,r;const l=null!==(t=null===(e=this.campaign)||void 0===e?void 0:e.campaignFields)&&void 0!==t?t:this.campaignProps;return Object.assign(Object.assign({Template:null!==(n=null===(i=this.template)||void 0===i?void 0:i.name)&&void 0!==n?n:"Molecules","File path":o.divH([o.link(null!==(a=this._dfName)&&void 0!==a?a:"-",(()=>this.download(this.dataFrame,"molecules")),A)],{style:{alignItems:"center"}})},l),{"Number of molecules":this.dataFrame.rowCount.toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((e=>e.name))].filter((e=>e&&""!==e.trim())).join(", "),Filters:this._filterDescriptions.join(", "),"Result Molecules":o.divH([o.link(null!==(r=null===(s=this.dataFrame)||void 0===s?void 0:s.filter.trueCount.toString())&&void 0!==r?r:"0",(()=>{this.download(this.dataFrame,"hits",!0)}),A)],{style:{alignItems:"center"}})})}saveCampaign(i,n=!0){var a,s,r,l,c,u;return ve(this,void 0,void 0,(function*(){const d=this.campaignId,p=this.filterSettings,m=this.template.name,h=this.dataFrame,f=`System:AppData/HitTriage/Hit Triage/campaigns/${d}/`,v=null!=d?d:yield function(e){return pe(this,void 0,void 0,(function*(){return new Promise((t=>pe(this,void 0,void 0,(function*(){const i=o.stringInput("Campaign name","");o.dialog("Save Campaign").add(o.div(i.root)).onOK((function(){i.value&&""!==i.value?t(i.value):t(e)})).show()}))))}))}(d),g={};h.columns.toList().forEach((e=>g[e.name]=e.semType));const y={name:v,templateName:m,filters:null!=p?p:{},ingest:{type:"File",query:`${f}enriched_table.csv`,molColName:this.molColName},status:null!==(s=null!=i?i:null===(a=this.campaign)||void 0===a?void 0:a.status)&&void 0!==s?s:"In Progress",createDate:null!==(l=null===(r=this.campaign)||void 0===r?void 0:r.createDate)&&void 0!==l?l:M(new Date),campaignFields:null!==(u=null===(c=this.campaign)||void 0===c?void 0:c.campaignFields)&&void 0!==u?u:this.campaignProps,columnSemTypes:g,rowCount:h.rowCount,filteredRowCount:h.filter.trueCount,template:this.template};this.campaign=y;const b=t.DataFrame.fromColumns(h.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield Fe.files.writeAsText(`Hit Triage/campaigns/${d}/enriched_table.csv`,b);const w=this._pickView.saveLayout();w?y.layout=w.viewState:e.shell.warning("Layout cound not be saved"),yield Fe.files.writeAsText(`Hit Triage/campaigns/${d}/campaign.json`,JSON.stringify(y)),n&&e.shell.info("Campaign saved successfully.")}))}}var ye=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function be(i,n){var a,s,l,u,d,p,m,h,g,y,b;return ye(this,void 0,void 0,(function*(){const w=t.Func.find({tags:[r]}),A=yield Fe.files.list("Hit Design/templates");let x=!1,I=!1;const E=A.map((e=>e.name.slice(0,-5))),N=[];for(const e of A)try{const t=JSON.parse(yield Fe.files.readAsText(e));N.push(t.key)}catch(e){console.error(e)}const S=t.Func.find({tags:[c]}),_={};S.forEach((e=>{var t;_[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const F=o.choiceInput("Submit function",null,[null,...Object.keys(_)]);F.nullable=!0,F.value=null!==(s=null===(a=null==n?void 0:n.submit)||void 0===a?void 0:a.fName)&&void 0!==s?s:null,F.setTooltip("Select function to be called upon submitting");const B=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),O=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"});function P(){var e,t,i,n;if(""===k.value||E.includes(null!==(t=null===(e=k.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=k.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=k.input.offsetWidth)&&void 0!==n?n:0;B.style.marginLeft=`${e}px`,B.style.width=`${t}px`,B.style.opacity="100%",B.style.borderTop="1px solid red",x=!0}else B.style.borderTop="none",B.style.opacity="0%",x=!1}const k=o.stringInput("Name",null!==(l=null==n?void 0:n.name)&&void 0!==l?l:"",P);function V(){var e,t,i,n;if(""===L.value||N.includes(null!==(t=null===(e=L.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=L.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=L.input.offsetWidth)&&void 0!==n?n:0;O.style.marginLeft=`${e}px`,O.style.width=`${t}px`,O.style.borderTop="1px solid red",O.style.opacity="100%",I=!0}else O.style.opacity="0%",O.style.borderTop="none",I=!1}const L=o.stringInput("Key",null!==(u=null==n?void 0:n.key)&&void 0!==u?u:"",V);L.setTooltip("Template key used for campaign prefix"),k.setTooltip("Template name"),k.root.style.borderBottom="none",L.root.style.borderBottom="none",B.style.opacity="0%",O.style.opacity="0%";const j={Descriptors:"Descriptors"};w.forEach((e=>{var t;j[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=`${e.package.name}:${e.name}`}));let D=null;const H={compute:{descriptors:{enabled:!0,args:null!==(m=null===(p=null===(d=null==n?void 0:n.compute)||void 0===d?void 0:d.descriptors)||void 0===p?void 0:p.args)&&void 0!==m?m:[]},functions:null!==(g=null===(h=null==n?void 0:n.compute)||void 0===h?void 0:h.functions)&&void 0!==g?g:[]}},M=yield z(i,(e=>{D=e}),(()=>null),H,!1);M.root.classList.add("hit-triage-new-template-functions-input");const R=te(null==n?void 0:n.campaignFields),U=function(e){const i=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING})],n=new K(i,e?e.map((e=>({Name:e}))):void 0,{horizontalInputNames:!0});let o={};return n.onItemAdded.subscribe((e=>{o=null!=e?e:{}})),n.onAddingItemChanged.subscribe((e=>{e&&(o=e.item)})),{getFields:function(){const e=n.items.filter((e=>e.Name)).map((e=>e.Name));return o.Name&&""!==o.Name&&e.push(o.Name),e},fieldsDiv:n.root}}(null==n?void 0:n.stages),$=o.divV([o.divV([k,B]),o.divV([L,O]),R.fieldsDiv]),q=o.h2("Stages");o.tooltip.bind(q,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const Y=o.h2("Compute");o.tooltip.bind(Y,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const W=o.div([o.h2("Details"),$,q,U.fieldsDiv,Y,M.root,o.h2("Submit"),F.root],"ui-form"),G=o.buttonsInput([]);W.appendChild(G);const J=null!==(b=null===(y=G.getElementsByClassName("ui-input-editor"))||void 0===y?void 0:y[0])&&void 0!==b?b:G,Z=new Promise((e=>{const t=o.button(T,(()=>e()));J.appendChild(t)})),Q=new Promise((t=>{const i=o.bigButton(C,(()=>function(){var i,n,o,a,s;return ye(this,void 0,void 0,(function*(){if(P(),V(),M.okProxy(),x||!k.value||""===k.value)return void e.shell.error("Template name is empty or already exists");if(I||!L.value||""===L.value)return void e.shell.error("Template key is empty or already exists");const r=F.value?_[F.value]:void 0,l=Object.assign({name:k.value,key:L.value,campaignFields:R.getFields(),stages:U.getFields(),compute:{descriptors:{enabled:!!(null===(i=null==D?void 0:D.descriptors)||void 0===i?void 0:i.length),args:null!==(n=null==D?void 0:D.descriptors)&&void 0!==n?n:[]},functions:Object.entries(null!==(o=null==D?void 0:D.externals)&&void 0!==o?o:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(a=null==D?void 0:D.scripts)&&void 0!==a?a:{}).filter((([e,t])=>e.startsWith(f)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(s=null==D?void 0:D.queries)&&void 0!==s?s:{}).filter((([e,t])=>e.startsWith(v)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))}},r?{submit:{fName:r.name,package:r.package.name}}:{});var c;c=l,Fe.files.writeAsText(`Hit Design/templates/${c.name}.json`,JSON.stringify(c)),e.shell.info("Template created successfully"),t(l)}))}()));J.appendChild(i)}));return{root:W,template:Q,cancelPromise:Z}}))}var we=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class Ce extends ne{constructor(t){super(t),this.deletedCampaigns=[],this.name="Hit Design",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(Fe.webRoot+"README_HD.md"),this.checkCampaign().then((e=>{this.app.campaign=e,this.init()}))}onActivated(){e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(Fe.webRoot+"README_HD.md")}init(e){return we(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const t=o.h1(x),i=o.h1(I,{style:{marginLeft:"10px"}}),n=se.appHeader({iconPath:Fe.webRoot+"/images/icons/hit-design-icon.png",learnMoreUrl:"https://github.com/datagrok-ai/public/blob/master/packages/HitTriage/README_HD.md",description:"- Configure your own workflow using the template editor\n- Sketch molecules in the molecular spreadsheet\n- Annotate and share ideas with the team\n- Calculate different molecular properties\n- Save campaigns and continue from where you left off\n- Submit final selection to the function of your choice"}),a=o.div(),s=o.divH([]),r=o.div([s,a],"ui-form"),l=yield this.getCampaignsTable();Z()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,t],{style:{marginLeft:"10px"}}),l,i,r])),yield this.startNewCampaign(a,s,e),this.app.resetBaseUrl()}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(e,t,i){var n;return we(this,void 0,void 0,(function*(){const a=(yield Fe.files.list("Hit Design/templates")).filter((e=>e.name.endsWith(".json"))).map((e=>e.name.slice(0,-5)));i&&!a.includes(i.name)&&a.push(i.name);let s=null;const r=()=>we(this,void 0,void 0,(function*(){const t=l.value,n=i&&i.name===t?i:JSON.parse(yield Fe.files.readAsText("Hit Design/templates/"+t+".json"));s=n;const o=yield this.getNewCampaignAccordeon(n);Z()(e).empty(),e.appendChild(o)})),l=o.choiceInput("Template",null!==(n=null==i?void 0:i.name)&&void 0!==n?n:a[0],a,(()=>we(this,void 0,void 0,(function*(){yield r()}))));l.root.style.width="100%";const c=o.icons.add((()=>{this.createNewTemplate()}),b),u=o.icons.copy((()=>{s&&this.createNewTemplate(s)}),"Clone template");c.style.color="#2083d5",l.addOptions(u),l.addOptions(c),yield r(),Z()(t).empty(),t.appendChild(l.root)}))}checkCampaign(e){var t;return we(this,void 0,void 0,(function*(){const i=location.search,n=new URLSearchParams(i);if(!n.has(s)&&!e)return;const o=null!=e?e:n.get(s);if(!(yield Fe.files.exists(`Hit Design/campaigns/${o}/campaign.json`)))return;const a=JSON.parse(yield Fe.files.readAsText(`Hit Design/campaigns/${o}/campaign.json`));a&&(this.app.campaign=a);const r=null!==(t=a.template)&&void 0!==t?t:JSON.parse(yield Fe.files.readAsText(`Hit Design/templates/${a.templateName}.json`));return yield this.app.setTemplate(r,o),e&&R(s,e),a.template=r,a}))}getCampaignsTable(){return we(this,void 0,void 0,(function*(){const e=(yield Fe.files.list("Hit Design/campaigns")).filter((e=>-1===this.deletedCampaigns.indexOf(e.name))),t={};for(const i of e){const e=JSON.parse(yield Fe.files.readAsText(`Hit Design/campaigns/${i.name}/campaign.json`));t[e.name]=e}const i=o.table(Object.values(t),(e=>[o.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.status,o.icons.delete((()=>we(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK((()=>we(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Design",e.name),this.deletedCampaigns.push(e.name),yield this.init()})))).show()}))),"Delete campaign")]),["Name","Created","Molecules","Status",""]);return i.style.color="var(--grey-5)",i.style.marginLeft="24px",i}))}setCampaign(e){return we(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(i){return we(this,void 0,void 0,(function*(){const{root:n,promise:a,cancelPromise:s}=function(i){var n,a;const s=t.DataFrame.create(1),r=s.columns.addNew(p,t.TYPE.STRING);r.semType=t.SEMTYPE.MOLECULE,r.setTag(t.TAGS.UNITS,t.UNITS.Molecule.SMILES),r.set(0,null),(null===(n=null==i?void 0:i.stages)||void 0===n?void 0:n.length)>0&&s.columns.addNew(d,t.TYPE.STRING).set(0,i.stages[0]);const l=s.columns.addNew(m,t.TYPE.STRING);l.set(0,he(l));const c=i.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:W[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),u={},h=o.input.form(u,c);h.classList.remove("ui-form");const f=o.div([...(null===(a=i.campaignFields)||void 0===a||a.length,[]),h]),v=o.buttonsInput([]);return f.appendChild(v),{promise:new Promise((t=>{const n=o.bigButton(w,(()=>{for(const t of i.campaignFields)if(t.required&&(!u[t.name]||""===u[t.name]))return void e.shell.error(`Field '${t.name}' is required`);t({df:s,campaignProps:u})}));v.appendChild(n)})),root:f,cancelPromise:new Promise((e=>{o.button(T,(()=>e()))}))}}(i);return a.then((e=>we(this,void 0,void 0,(function*(){this.app.dataFrame=e.df,yield this.app.setTemplate(i),this.app.campaignProps=e.campaignProps,this.app.saveCampaign(void 0,!1)})))),s.then((()=>{this.init()})),n}))}createNewTemplate(i){return we(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const n=yield be(this.app,i),a=new t.ViewBase,s=e.shell.v;a.name="New Template",a.root.appendChild(n.root),a.parentCall=this.app.parentCall,e.shell.addView(a),a.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:r}=U(a,"Hit Design",b,(()=>we(this,void 0,void 0,(function*(){e.shell.v=s,a.close()}))));n.template.then((t=>we(this,void 0,void 0,(function*(){yield this.init(t),a.close(),$(a),e.shell.v=s,r.unsubscribe()})))),n.cancelPromise.then((()=>we(this,void 0,void 0,(function*(){r.unsubscribe(),a.close(),e.shell.v=s}))))}finally{o.setUpdateIndicator(this.root,!1)}}))}}class Ae extends ne{constructor(e){super(e),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){var i,n,o,a,s;return n=this,o=void 0,s=function*(){const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=t.Func.find({name:n.fName,package:n.package})[0];if(!o)return void e.shell.error(`Function ${n.fName} not found.`);const a=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:a,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((a=void 0)||(a=Promise))((function(e,t){function i(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a((function(e){e(n)}))).then(i,r)}l((s=s.apply(n,o||[])).next())}))}}var Te=i(143),xe={};xe.styleTagTransform=j(),xe.setAttributes=P(),xe.insert=B().bind(null,"head"),xe.domAPI=_(),xe.insertStyleElement=V(),N()(Te.Z,xe),Te.Z&&Te.Z.locals&&Te.Z.locals;class Ie extends ne{constructor(e){super(e),this.v=null,this.name="Progress Tracker"}render(){return i=this,n=void 0,s=function*(){return new Promise((i=>{var n,a;o.empty(this.root),this.app.dataFrame.columns.names().forEach((e=>{e.startsWith("~")&&this.app.dataFrame.columns.remove(e)})),this.v=t.Viewer.fromType(t.VIEWER.TILE_VIEWER,this.app.dataFrame,{lanesColumnName:d,lanes:null!==(a=null===(n=this.app.template)||void 0===n?void 0:n.stages)&&void 0!==a?a:[]}),this.root.appendChild(this.v.root),this.v.root.style.height="100%",this.v.root.style.width="100%",setTimeout((()=>{var t,n,a;null===(n=null===(t=this.v)||void 0===t?void 0:t.view)||void 0===n||n._onAdded();const s=null===(a=e.shell.v)||void 0===a?void 0:a.getRibbonPanels();if(s){if(q(s))return void i();const t=o.bigButton("Design view",(()=>{const t=e.shell.view(this.app.designViewName);t&&(e.shell.v=t)})),n=o.bigButton("Submit",(()=>{var e;const t=null===(e=this.app._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.app.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this.app._submitView)||void 0===t||t.submit(),e.close()})),e.show()}}));n.classList.add("hit-design-submit-button"),s.push([t,n]),e.shell.v.setRibbonPanels(s)}i()}),5)}))},new((a=void 0)||(a=Promise))((function(e,t){function o(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a((function(e){e(i)}))).then(o,r)}l((s=s.apply(i,n||[])).next())}));var i,n,a,s}onActivated(){this.render()}destroy(){var e;null===(e=this.v)||void 0===e||e.detach()}}var Ee=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class Ne extends de{constructor(i){super(i),this._tilesViewTab=null,this._designViewName="Design",this._filePath="System.AppData/HitTriage/Hit Design/campaigns",this._molColName=p,this.campaignProps={},this.processedValues=[],this._extraStageColsCount=0,this._infoView=new Ce(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof ne&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,this.mainView=e.shell.addView(this.multiView),e.events.onCurrentViewChanged.subscribe((()=>Ee(this,void 0,void 0,(function*(){var t,i,n,o,s,r,l,c,u;try{if((null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentDesignViewId||(null===(i=e.shell.v)||void 0===i?void 0:i.name)===this.currentTilesViewId){e.shell.windows.showHelp=!1,this.setBaseUrl(),R(a,null!==(s=null!==(n=this._campaignId)&&void 0!==n?n:null===(o=this._campaign)||void 0===o?void 0:o.name)&&void 0!==s?s:""),(null===(r=e.shell.v)||void 0===r?void 0:r.name)===this.currentTilesViewId?yield null===(l=this._tilesView)||void 0===l?void 0:l.render():null===(c=this._tilesView)||void 0===c||c.destroy();const{sub:t}=U(e.shell.v,"Hit Design",null===(u=e.shell.v)||void 0===u?void 0:u.name,(()=>{var i,n;e.shell.v=this.mainView,null===(i=this._tilesView)||void 0===i||i.close(),null===(n=this._designView)||void 0===n||n.close(),this._infoView.init(),t.unsubscribe()}))}}catch(e){console.error(e)}}))))}setTemplate(i,n){var o,r,l,c,u,d,m,h,f,v,g,y;return Ee(this,void 0,void 0,(function*(){if(n){const t="System.AppData/HitTriage/Hit Design/campaigns";this._filePath=null!==(l=null===(r=this.campaign)||void 0===r?void 0:r.savePath)&&void 0!==l?l:`${t}/${n}/enriched_table.csv`,this.dataFrame=yield e.dapi.files.readCsv(this._filePath),(null===(c=this._campaign)||void 0===c?void 0:c.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&t&&(i.semType=t)}))}else(null===(o=this._designView)||void 0===o?void 0:o.dataFrame)&&e.shell.closeTable(this._designView.dataFrame),this._designView=void 0,n=yield this.getNewCampaignName("Hit Design/campaigns",i.key),R(s,n),this._filePath=`System.AppData/HitTriage/Hit Design/campaigns/${n}/enriched_table.csv`;if(!this.dataFrame)return void console.error("DataFrame is empty");yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(d=null===(u=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===u?void 0:u.name)&&void 0!==d?d:p,this._dfName=null!==(m=(y=this.dataFrame).name)&&void 0!==m?m:y.name=n,this._campaignId=n,this.template=i,null!==(h=this._submitView)&&void 0!==h||(this._submitView=new Ae(this)),e.shell.windows.showHelp=!1,this._extraStageColsCount=this.dataFrame.rowCount-this.dataFrame.filter.trueCount;const b=e.shell.addView(this.designView);this.currentDesignViewId=b.name,this.setBaseUrl(),R(a,null!==(g=null!==(f=this._campaignId)&&void 0!==f?f:null===(v=this._campaign)||void 0===v?void 0:v.name)&&void 0!==g?g:""),this.campaign&&(this.campaign.template=i)}))}get campaignId(){return this._campaignId}get designView(){return this._designView=this.getDesignView()}get designViewName(){return this._designViewName}get molColName(){var e,i,n,o;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null!==(o=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name)&&void 0!==o?o:p}get campaign(){return this._campaign}set campaign(e){this._campaign=e}getDesignView(){var i,n,a,s,r,l;const c=[],u=null===(i=this.dataFrame.col(this.molColName))||void 0===i?void 0:i.toList().every((e=>!e&&""===e)),h=t.TableView.create(this.dataFrame,!1);this._designViewName=null!==(a=null===(n=this.campaign)||void 0===n?void 0:n.name)&&void 0!==a?a:this._designViewName,h.name=this._designViewName,this.processedValues=this.dataFrame.getCol(this.molColName).toList(),setTimeout((()=>Ee(this,void 0,void 0,(function*(){var i,n;if(h._onAdded(),yield new Promise((e=>setTimeout(e,1e3))),null===(i=this._campaign)||void 0===i?void 0:i.layout)try{const e=t.ViewLayout.fromViewState(this._campaign.layout);h.loadLayout(e)}catch(e){console.error(e)}u&&e.functions.call("Chem:editMoleculeCell",{cell:h.grid.cell(this._molColName,0)}),c.push(this.dataFrame.onRowsAdded.subscribe((()=>{var t,i;try{if(this.processedValues=this.dataFrame.getCol(this.molColName).toList(),(null===(t=this.template.stages)||void 0===t?void 0:t.length)>0)for(let e=0;e<this.dataFrame.rowCount;e++){const t=this.dataFrame.col(d).get(e);t&&""!==t&&!(null===(i=this.dataFrame.col(d))||void 0===i?void 0:i.isNone(e))||this.dataFrame.set(d,e,this.template.stages[0])}let n=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=h.grid.cell(this.molColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(n=t))}n&&e.functions.call("Chem:editMoleculeCell",{cell:n})}catch(e){console.error(e)}}))),this.dataFrame&&c.push(null===(n=this.dataFrame)||void 0===n?void 0:n.onRowsRemoved.subscribe((()=>{try{this.processedValues=this.dataFrame.getCol(this.molColName).toList()}catch(e){console.error(e)}}))),c.push(e.events.onContextMenu.subscribe((i=>{var n,o,a,s,r;try{const e=null===(n=null==i?void 0:i.args)||void 0===n?void 0:n.context;if(!e)return;if((null==e?void 0:e.type)!==t.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==h.id)return;if((null===(s=null===(a=null===(o=null==i?void 0:i.args)||void 0===o?void 0:o.item)||void 0===a?void 0:a.tableColumn)||void 0===s?void 0:s.name)!==this.molColName)return;const l=null===(r=null==i?void 0:i.args)||void 0===r?void 0:r.menu;if(!l)return;l.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),l.item("Duplicate molecule",(()=>{var e,t,n,o;try{this.dataFrame.rows.addNew(null,!0);let a=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=h.grid.cell(this.molColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(a=t))}a&&(a.cell.value=null!==(o=null===(n=null===(t=null===(e=null==i?void 0:i.args)||void 0===e?void 0:e.item)||void 0===t?void 0:t.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}}))}catch(t){e.log.error(t)}}))),c.push(h.grid.onCellValueEdited.subscribe((i=>Ee(this,void 0,void 0,(function*(){var n,o,a,s;try{if((null===(n=i.tableColumn)||void 0===n?void 0:n.name)===d)return void(yield this.saveCampaign(void 0,!1));if((null===(o=i.tableColumn)||void 0===o?void 0:o.name)!==this.molColName)return;const r=i.cell.value,l=i.tableRowIndex;(null===(a=this.dataFrame.col(m))||void 0===a?void 0:a.get(l))&&""!==(null===(s=this.dataFrame.col(m))||void 0===s?void 0:s.get(l))||this.dataFrame.col(m).set(l,he(this.dataFrame.col(m)),!1);const c=this.template.compute;if(!r||""===r)return;const u=yield function(i,n,o,a=[],s=[]){return me(this,void 0,void 0,(function*(){const r=e.chem.convert(i,e.chem.Notation.Unknown,e.chem.Notation.Smiles),l=t.Column.fromStrings(p,[r]),c=t.DataFrame.fromColumns([l]);c.name="HD Single cell values",yield c.meta.detectSemanticTypes(),n.length&&(yield e.chem.descriptors(c,l.name,n));for(const e of o){const i=e.args,n=t.Func.find({package:e.package,name:e.name});if(!n.length||!n[0]){console.warn(`Function ${e.name} from package ${e.package} is not found`);continue}const o=n[0],a=o.inputs[0].name,s=o.inputs[1].name;yield o.apply(Object.assign(Object.assign({},i),{[a]:c,[s]:l.name}))}for(const t of a){const i=t.args;try{const n=yield e.dapi.scripts.find(t.id);if(n){const e=n.inputs[0].name,t=n.inputs[1].name;yield n.apply(Object.assign(Object.assign({},i),{[e]:c,[t]:l.name}))}}catch(e){console.error(e)}}for(const t of s){const i=t.args;try{const n=yield e.dapi.queries.find(t.id);if(n){const e=n.inputs[0].name,t=[r],o=yield n.apply(Object.assign(Object.assign({},i),{[e]:t}));if(!o||0===o.rowCount)continue;yield Y(c,p,o)}}catch(e){console.error(e)}}return c}))}(r,c.descriptors.args,c.functions,c.scripts,c.queries);for(const e of u.columns.toList())e.name!==p&&(this.dataFrame.columns.contains(e.name)||(this.dataFrame.columns.addNew(e.name,e.type).semType=e.semType),this.dataFrame.col(e.name).set(l,e.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(void 0,!1)}catch(e){console.error(e)}})))));const o=e.events.onViewRemoved.subscribe((e=>{e.id===h.id&&(c.forEach((e=>e.unsubscribe())),o.unsubscribe())}))}))),300);const g=null==h?void 0:h.getRibbonPanels();if(g&&!q(g)){const t=()=>Ee(this,void 0,void 0,(function*(){var e;z(this,(e=>Ee(this,void 0,void 0,(function*(){var t,i,n,a,s,r,l,c,u,d;const p=this.template.compute.descriptors.args,m=this.template.compute.functions,g=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],y=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],b=e.descriptors,w={descriptors:{enabled:!!(null===(n=null==e?void 0:e.descriptors)||void 0===n?void 0:n.length),args:null!==(a=null==e?void 0:e.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(s=null==e?void 0:e.externals)&&void 0!==s?s:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(r=null==e?void 0:e.scripts)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(f)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(l=null==e?void 0:e.queries)&&void 0!==l?l:{}).filter((([e,t])=>e.startsWith(v)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))};this.template.compute=w,this.campaign.template=this.template;const C=b.filter((e=>!p.includes(e))),A={};Object.entries(null!==(c=null==e?void 0:e.externals)&&void 0!==c?c:{}).filter((([e,t])=>{const i=m.find((t=>`${t.package}:${t.name}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{A[e]=t}));const T={};Object.entries(null!==(u=null==e?void 0:e.scripts)&&void 0!==u?u:{}).filter((([e,t])=>{const i=g.find((t=>`HTScript:${t.name}:${t.id}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{T[e]=t}));const x={};Object.entries(null!==(d=null==e?void 0:e.queries)&&void 0!==d?d:{}).filter((([e,t])=>{const i=y.find((t=>`HTQuery:${t.name}:${t.id}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{x[e]=t})),o.setUpdateIndicator(h.grid.root,!0);try{yield fe({descriptors:C,externals:A,scripts:T,queries:x},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{o.setUpdateIndicator(h.grid.root,!1),this.saveCampaign(void 0,!1)}}))),(()=>null),null===(e=this.campaign)||void 0===e?void 0:e.template,!0)})),i=o.iconFA("wrench",t,"Calculate additional properties"),n=o.icons.add((()=>{var e;null===(e=this.dataFrame)||void 0===e||e.rows.addNew(null,!0)}),"Add new row"),a=o.bigButton("Progress tracker",(()=>{this.currentTilesViewId&&e.shell.view(this.currentTilesViewId)?e.shell.v=e.shell.view(this.currentTilesViewId):(this._tilesView=new Ie(this),this._tilesView.parentCall=this.parentCall,this._tilesViewTab=e.shell.addView(this._tilesView),this.currentTilesViewId=this._tilesViewTab.name,this._tilesView.onActivated())})),c=o.bigButton("Submit",(()=>{var e;const t=null===(e=this._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}}));c.classList.add("hit-design-submit-button");const u=[c];null!==(l=null===(r=null===(s=this.template)||void 0===s?void 0:s.stages)||void 0===r?void 0:r.length)&&void 0!==l&&l&&u.unshift(a),this.campaign&&this.template&&(this.campaign.template||(this.campaign.template=this.template),u.unshift(i)),u.unshift(n),g.push(u),h.setRibbonPanels(g)}return h.parentCall=this.parentCall,h}getSummary(){var i,n,a,s;const r=()=>{var e,t;const i=this._filePath.indexOf(null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name);return-1===i?this._filePath:this._filePath.substring(0,i-1)},l=Object.assign({},null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.campaignFields)&&void 0!==n?n:this.campaignProps);return this.template&&this.template.campaignFields&&Object.entries(l).forEach((([i,n])=>{const o=this.template.campaignFields.find((e=>e.name===i));o&&"Date"===o.type&&n?"Invalid Date"!==new Date(n).toString()?l[i]=new Date(n).toLocaleDateString():n.date?l[i]=new Date(n.date).toLocaleDateString():l[i]=n:o&&o.type===t.SEMTYPE.MOLECULE&&n&&(l[i]=e.chem.drawMolecule(n))})),Object.assign(Object.assign({Template:null!==(s=null===(a=this.template)||void 0===a?void 0:a.name)&&void 0!==s?s:"Molecules","File path":(()=>{const t=o.icons.edit((()=>{const i=r(),s=o.stringInput("Path",i),l=s.root.getElementsByTagName("label").item(0);l&&l.remove(),s.root.style.width="100%";const c=o.button("Save",(()=>Ee(this,void 0,void 0,(function*(){const i=yield function(){return Ee(this,void 0,void 0,(function*(){const t=s.value;return t&&""!==t.trim()?!!(yield e.dapi.files.exists(t))||(e.shell.error("Given folder does not exist"),!1):(e.shell.error("Path can not be empty"),!1)}))}();if(!i)return;const l=s.value;l.endsWith("/")?this._filePath=`${l}${this.campaignId}/enriched_table.csv`:this._filePath=`${l}/${this.campaignId}/enriched_table.csv`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(void 0,!0),o.empty(a);const c=r();n=o.link(c,(()=>{var e,t,i;return this.download(this.dataFrame,null!==(i=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==i?i:"Molecules")}),A),a.appendChild(n),a.appendChild(t)})))),u=o.button("Cancel",(()=>{o.empty(a),a.appendChild(n),a.appendChild(t)}));o.empty(a),s.addOptions(u),s.addOptions(c),a.appendChild(s.root)}),"Edit file path");t.style.marginLeft="5px";const i=r();let n=o.link(i,(()=>{var e,t,i;return this.download(this.dataFrame,null!==(i=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==i?i:"Molecules")}),A);const a=o.divH([n,t],{style:{alignItems:"center"}});return a})()},l),{"Number of molecules":(this.dataFrame.rowCount-this._extraStageColsCount).toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((e=>e.name))].filter((e=>e&&""!==e.trim())).join(", ")})}saveCampaign(i,n=!0){var o,a,s,r,l,c,u,d;return Ee(this,void 0,void 0,(function*(){const p=this.campaignId,h=this.template.name,f=this.dataFrame,v=p,g={};f.columns.toList().forEach((e=>g[e.name]=e.semType));const y={name:v,templateName:h,status:null!==(a=null!=i?i:null===(o=this.campaign)||void 0===o?void 0:o.status)&&void 0!==a?a:"In Progress",createDate:null!==(r=null===(s=this.campaign)||void 0===s?void 0:s.createDate)&&void 0!==r?r:M(new Date),campaignFields:null!==(c=null===(l=this.campaign)||void 0===l?void 0:l.campaignFields)&&void 0!==c?c:this.campaignProps,columnSemTypes:g,rowCount:null!==(d=null===(u=f.col(m))||void 0===u?void 0:u.toList().filter((e=>"StageDefiningRow"!==e)).length)&&void 0!==d?d:0,filteredRowCount:f.filter.trueCount,savePath:this._filePath};console.log(this._filePath);const b=t.DataFrame.fromColumns(f.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield e.dapi.files.writeAsText(this._filePath,b);const w=this._designView.saveLayout();return w?y.layout=w.viewState:e.shell.warning("Layout cound not be saved"),y.template=this.template,yield Fe.files.writeAsText(`Hit Design/campaigns/${p}/campaign.json`,JSON.stringify(y)),n&&e.shell.info("Campaign saved successfully."),this.campaign=y,y}))}}class Se extends t.GridCellRenderer{get name(){return"customGasteigerPNG"}get cellType(){return"customGasteigerPNG"}get defaultHeight(){return 200}get defaultWidth(){return 200}render(e,t,i,n,o,a,s){if(a.gridRow<0||!a.cell.value)return;const r=a.cell.value,l=new Image(n-2,o-2);l.src="data:image/png;base64,"+r,l.onload=function(){e.drawImage(l,t+2,i+2,n-2,o-2)}}}var _e=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};const Fe=new t.Package;function Be(){return _e(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();new ge(t)}))}function Oe(){return _e(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();new Ne(t)}))}function Pe(){return _e(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(100);return t.name="100 Molecules",t}))}function ke(){return _e(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(5e3);return t.name="5000 Molecules",t}))}function Ve(t){return _e(this,void 0,void 0,(function*(){const i=e.data.demo.molecules(t);return i.name="Variable Molecules number",i}))}function Le(t,i){return _e(this,void 0,void 0,(function*(){e.shell.info(t.rowCount),e.shell.info(i)}))}function je(){return new Se}})(),hittriage=n})();
1
+ var hittriage;(()=>{var e={553:e=>{!function(){"use strict";var t=document,i=window,n=t.documentElement,o=t.createElement.bind(t),a=o("div"),s=o("table"),r=o("tbody"),l=o("tr"),c=Array.isArray,u=Array.prototype,d=u.concat,p=u.filter,m=u.indexOf,h=u.map,f=u.push,v=u.slice,g=u.some,y=u.splice,b=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,w=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,C=/<.+>/,A=/^\w+$/;function T(e,t){var i,n=!!(i=t)&&11===i.nodeType;return e&&(n||_(t)||F(t))?!n&&w.test(e)?t.getElementsByClassName(e.slice(1).replace(/\\/g,"")):!n&&A.test(e)?t.getElementsByTagName(e):t.querySelectorAll(e):[]}var x=function(){function e(e,n){if(e){if(N(e))return e;var o=e;if(P(e)){var a=n||t;if(!(o=b.test(e)&&_(a)?a.getElementById(e.slice(1).replace(/\\/g,"")):C.test(e)?X(e):N(a)?a.find(e):P(a)?E(a).find(e):T(e,a)))return}else if(O(e))return this.ready(e);(o.nodeType||o===i)&&(o=[o]),this.length=o.length;for(var s=0,r=this.length;s<r;s++)this[s]=o[s]}}return e.prototype.init=function(t,i){return new e(t,i)},e}(),I=x.prototype,E=I.init;function N(e){return e instanceof x}function S(e){return!!e&&e===e.window}function _(e){return!!e&&9===e.nodeType}function F(e){return!!e&&1===e.nodeType}function B(e){return"boolean"==typeof e}function O(e){return"function"==typeof e}function P(e){return"string"==typeof e}function k(e){return void 0===e}function V(e){return null===e}function L(e){return!isNaN(parseFloat(e))&&isFinite(e)}function j(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function D(e,t,i){if(i){for(var n=e.length;n--;)if(!1===t.call(e[n],n,e[n]))return e}else if(j(e))for(var o=Object.keys(e),a=(n=0,o.length);n<a;n++){var s=o[n];if(!1===t.call(e[s],s,e[s]))return e}else for(n=0,a=e.length;n<a;n++)if(!1===t.call(e[n],n,e[n]))return e;return e}function H(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=!!B(e[0])&&e.shift(),n=e.shift(),o=e.length;if(!n)return{};if(!o)return H(i,E,n);for(var a=0;a<o;a++){var s=e[a];for(var r in s)i&&(c(s[r])||j(s[r]))?(n[r]&&n[r].constructor===s[r].constructor||(n[r]=new s[r].constructor),H(i,n[r],s[r])):n[r]=s[r]}return n}E.fn=E.prototype=I,I.length=0,I.splice=y,"function"==typeof Symbol&&(I[Symbol.iterator]=u[Symbol.iterator]),E.isWindow=S,E.isFunction=O,E.isArray=c,E.isNumeric=L,E.isPlainObject=j,E.each=D,I.each=function(e){return D(this,e)},I.empty=function(){return this.each((function(e,t){for(;t.firstChild;)t.removeChild(t.firstChild)}))},E.extend=H,I.extend=function(e){return H(I,e)};var M=/\S+/g;function R(e){return P(e)&&e.match(M)||[]}function U(e,t,n){if(F(e)){var o=i.getComputedStyle(e,null);return n?o.getPropertyValue(t)||void 0:o[t]||e.style[t]}}function $(e,t){return parseInt(U(e,t),10)||0}function q(e,t){return $(e,"border".concat(t?"Left":"Top","Width"))+$(e,"padding".concat(t?"Left":"Top"))+$(e,"padding".concat(t?"Right":"Bottom"))+$(e,"border".concat(t?"Right":"Bottom","Width"))}I.toggleClass=function(e,t){var i=R(e),n=!k(t);return this.each((function(e,o){F(o)&&D(i,(function(e,i){n?t?o.classList.add(i):o.classList.remove(i):o.classList.toggle(i)}))}))},I.addClass=function(e){return this.toggleClass(e,!0)},I.removeAttr=function(e){var t=R(e);return this.each((function(e,i){F(i)&&D(t,(function(e,t){i.removeAttribute(t)}))}))},I.attr=function(e,t){if(e){if(P(e)){if(arguments.length<2){if(!this[0]||!F(this[0]))return;var i=this[0].getAttribute(e);return V(i)?void 0:i}return k(t)?this:V(t)?this.removeAttr(e):this.each((function(i,n){F(n)&&n.setAttribute(e,t)}))}for(var n in e)this.attr(n,e[n]);return this}},I.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},I.hasClass=function(e){return!!e&&g.call(this,(function(t){return F(t)&&t.classList.contains(e)}))},I.get=function(e){return k(e)?v.call(this):this[(e=Number(e))<0?e+this.length:e]},I.eq=function(e){return E(this.get(e))},I.first=function(){return this.eq(0)},I.last=function(){return this.eq(-1)},I.text=function(e){return k(e)?this.get().map((function(e){return F(e)||(t=e)&&3===t.nodeType?e.textContent:"";var t})).join(""):this.each((function(t,i){F(i)&&(i.textContent=e)}))};var Y={};function W(e){return"none"===U(e,"display")}function G(e,t){var i=e&&(e.matches||e.webkitMatchesSelector||e.msMatchesSelector);return!!i&&!!t&&i.call(e,t)}function J(e){return P(e)?function(t,i){return G(i,e)}:O(e)?e:N(e)?function(t,i){return e.is(i)}:e?function(t,i){return i===e}:function(){return!1}}function Z(e,t){return t?e.filter(t):e}I.filter=function(e){var t=J(e);return E(p.call(this,(function(e,i){return t.call(e,i,e)})))},I.detach=function(e){return Z(this,e).each((function(e,t){t.parentNode&&t.parentNode.removeChild(t)})),this};var z=/^\s*<(\w+)[^>]*>/,Q=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,K={"*":a,tr:r,td:l,th:l,thead:s,tbody:s,tfoot:s};function X(e){if(!P(e))return[];if(Q.test(e))return[o(RegExp.$1)];var t=z.test(e)&&RegExp.$1,i=K[t]||K["*"];return i.innerHTML=e,E(i.childNodes).detach().get()}function ee(e,t,i,n){for(var o=[],a=O(t),s=n&&J(n),r=0,l=e.length;r<l;r++)if(a){var c=t(e[r]);c.length&&f.apply(o,c)}else for(var u=e[r][t];!(null==u||n&&s(-1,u));)o.push(u),u=i?u[t]:null;return o}function te(e){return e.multiple&&e.options?ee(p.call(e.options,(function(e){return e.selected&&!e.disabled&&!e.parentNode.disabled})),"value"):e.value||""}function ie(e){return e.length>1?p.call(e,(function(e,t,i){return m.call(i,e)===t})):e}E.parseHTML=X,I.has=function(e){var t=P(e)?function(t,i){return T(e,i).length}:function(t,i){return i.contains(e)};return this.filter(t)},I.not=function(e){var t=J(e);return this.filter((function(i,n){return(!P(e)||F(n))&&!t.call(n,i,n)}))},I.val=function(e){return arguments.length?this.each((function(t,i){var n=i.multiple&&i.options;if(n||Pe.test(i.type)){var o=c(e)?h.call(e,String):V(e)?[]:[String(e)];n?D(i.options,(function(e,t){t.selected=o.indexOf(t.value)>=0}),!0):i.checked=o.indexOf(i.value)>=0}else i.value=k(e)||V(e)?"":e})):this[0]&&te(this[0])},I.is=function(e){var t=J(e);return g.call(this,(function(e,i){return t.call(e,i,e)}))},E.guid=1,E.unique=ie,I.add=function(e,t){return E(ie(this.get().concat(E(e,t).get())))},I.children=function(e){return Z(E(ie(ee(this,(function(e){return e.children})))),e)},I.parent=function(e){return Z(E(ie(ee(this,"parentNode"))),e)},I.index=function(e){var t=e?E(e)[0]:this[0],i=e?this:E(t).parent().children();return m.call(i,t)},I.closest=function(e){var t=this.filter(e);if(t.length)return t;var i=this.parent();return i.length?i.closest(e):t},I.siblings=function(e){return Z(E(ie(ee(this,(function(e){return E(e).parent().children().not(e)})))),e)},I.find=function(e){return E(ie(ee(this,(function(t){return T(e,t)}))))};var ne=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,oe=/^$|^module$|\/(java|ecma)script/i,ae=["type","src","nonce","noModule"];function se(e,t,i,a,s,r,l,c){return D(e,(function(e,r){D(E(r),(function(e,r){D(E(t),(function(t,l){var c=i?l:r,u=i?e:t;!function(e,t,i,a,s){a?e.insertBefore(t,i?e.firstChild:null):"HTML"===e.nodeName?e.parentNode.replaceChild(t,e):e.parentNode.insertBefore(t,i?e:e.nextSibling),s&&function(e,t){var i=E(e);i.filter("script").add(i.find("script")).each((function(e,i){if(oe.test(i.type)&&n.contains(i)){var a=o("script");a.text=i.textContent.replace(ne,""),D(ae,(function(e,t){i[t]&&(a[t]=i[t])})),t.head.insertBefore(a,null),t.head.removeChild(a)}}))}(t,e.ownerDocument)}(i?r:l,u?c.cloneNode(!0):c,a,s,!u)}),c)}),l)}),r),t}I.after=function(){return se(arguments,this,!1,!1,!1,!0,!0)},I.append=function(){return se(arguments,this,!1,!1,!0)},I.html=function(e){if(!arguments.length)return this[0]&&this[0].innerHTML;if(k(e))return this;var t=/<script[\s>]/.test(e);return this.each((function(i,n){F(n)&&(t?E(n).empty().append(e):n.innerHTML=e)}))},I.appendTo=function(e){return se(arguments,this,!0,!1,!0)},I.wrapInner=function(e){return this.each((function(t,i){var n=E(i),o=n.contents();o.length?o.wrapAll(e):n.append(e)}))},I.before=function(){return se(arguments,this,!1,!0)},I.wrapAll=function(e){for(var t=E(e),i=t[0];i.children.length;)i=i.firstElementChild;return this.first().before(t),this.appendTo(i)},I.wrap=function(e){return this.each((function(t,i){var n=E(e)[0];E(i).wrapAll(t?n.cloneNode(!0):n)}))},I.insertAfter=function(e){return se(arguments,this,!0,!1,!1,!1,!1,!0)},I.insertBefore=function(e){return se(arguments,this,!0,!0)},I.prepend=function(){return se(arguments,this,!1,!0,!0,!0,!0)},I.prependTo=function(e){return se(arguments,this,!0,!0,!0,!1,!1,!0)},I.contents=function(){return E(ie(ee(this,(function(e){return"IFRAME"===e.tagName?[e.contentDocument]:"TEMPLATE"===e.tagName?e.content.childNodes:e.childNodes}))))},I.next=function(e,t,i){return Z(E(ie(ee(this,"nextElementSibling",t,i))),e)},I.nextAll=function(e){return this.next(e,!0)},I.nextUntil=function(e,t){return this.next(t,!0,e)},I.parents=function(e,t){return Z(E(ie(ee(this,"parentElement",!0,t))),e)},I.parentsUntil=function(e,t){return this.parents(t,e)},I.prev=function(e,t,i){return Z(E(ie(ee(this,"previousElementSibling",t,i))),e)},I.prevAll=function(e){return this.prev(e,!0)},I.prevUntil=function(e,t){return this.prev(t,!0,e)},I.map=function(e){return E(d.apply([],h.call(this,(function(t,i){return e.call(t,i,t)}))))},I.clone=function(){return this.map((function(e,t){return t.cloneNode(!0)}))},I.offsetParent=function(){return this.map((function(e,t){for(var i=t.offsetParent;i&&"static"===U(i,"position");)i=i.offsetParent;return i||n}))},I.slice=function(e,t){return E(v.call(this,e,t))};var re=/-([a-z])/g;function le(e){return e.replace(re,(function(e,t){return t.toUpperCase()}))}I.ready=function(e){var i=function(){return setTimeout(e,0,E)};return"loading"!==t.readyState?i():t.addEventListener("DOMContentLoaded",i),this},I.unwrap=function(){return this.parent().each((function(e,t){if("BODY"!==t.tagName){var i=E(t);i.replaceWith(i.children())}})),this},I.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+i.pageYOffset,left:t.left+i.pageXOffset}}},I.position=function(){var e=this[0];if(e){var t="fixed"===U(e,"position"),i=t?e.getBoundingClientRect():this.offset();if(!t){for(var n=e.ownerDocument,o=e.offsetParent||n.documentElement;(o===n.body||o===n.documentElement)&&"static"===U(o,"position");)o=o.parentNode;if(o!==e&&F(o)){var a=E(o).offset();i.top-=a.top+$(o,"borderTopWidth"),i.left-=a.left+$(o,"borderLeftWidth")}}return{top:i.top-$(e,"marginTop"),left:i.left-$(e,"marginLeft")}}};var ce={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};I.prop=function(e,t){if(e){if(P(e))return e=ce[e]||e,arguments.length<2?this[0]&&this[0][e]:this.each((function(i,n){n[e]=t}));for(var i in e)this.prop(i,e[i]);return this}},I.removeProp=function(e){return this.each((function(t,i){delete i[ce[e]||e]}))};var ue=/^--/;function de(e){return ue.test(e)}var pe={},me=a.style,he=["webkit","moz","ms"];function fe(e,t){if(void 0===t&&(t=de(e)),t)return e;if(!pe[e]){var i=le(e),n="".concat(i[0].toUpperCase()).concat(i.slice(1));D("".concat(i," ").concat(he.join("".concat(n," "))).concat(n).split(" "),(function(t,i){if(i in me)return pe[e]=i,!1}))}return pe[e]}var ve={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function ge(e,t,i){return void 0===i&&(i=de(e)),i||ve[e]||!L(t)?t:"".concat(t,"px")}function ye(e,t){try{return e(t)}catch(e){return t}}I.css=function(e,t){if(P(e)){var i=de(e);return e=fe(e,i),arguments.length<2?this[0]&&U(this[0],e,i):e?(t=ge(e,t,i),this.each((function(n,o){F(o)&&(i?o.style.setProperty(e,t):o.style[e]=t)}))):this}for(var n in e)this.css(n,e[n]);return this};var be=/^\s+|\s+$/;function we(e,t){var i=e.dataset[t]||e.dataset[le(t)];return be.test(i)?i:ye(JSON.parse,i)}function Ce(e,t,i){i=ye(JSON.stringify,i),e.dataset[le(t)]=i}function Ae(e,t){var i=e.documentElement;return Math.max(e.body["scroll".concat(t)],i["scroll".concat(t)],e.body["offset".concat(t)],i["offset".concat(t)],i["client".concat(t)])}I.data=function(e,t){if(!e){if(!this[0])return;var i={};for(var n in this[0].dataset)i[n]=we(this[0],n);return i}if(P(e))return arguments.length<2?this[0]&&we(this[0],e):k(t)?this:this.each((function(i,n){Ce(n,e,t)}));for(var n in e)this.data(n,e[n]);return this},D([!0,!1],(function(e,t){D(["Width","Height"],(function(e,i){var n="".concat(t?"outer":"inner").concat(i);I[n]=function(n){if(this[0])return S(this[0])?t?this[0]["inner".concat(i)]:this[0].document.documentElement["client".concat(i)]:_(this[0])?Ae(this[0],i):this[0]["".concat(t?"offset":"client").concat(i)]+(n&&t?$(this[0],"margin".concat(e?"Top":"Left"))+$(this[0],"margin".concat(e?"Bottom":"Right")):0)}}))})),D(["Width","Height"],(function(e,t){var i=t.toLowerCase();I[i]=function(n){if(!this[0])return k(n)?void 0:this;if(!arguments.length)return S(this[0])?this[0].document.documentElement["client".concat(t)]:_(this[0])?Ae(this[0],t):this[0].getBoundingClientRect()[i]-q(this[0],!e);var o=parseInt(n,10);return this.each((function(t,n){if(F(n)){var a=U(n,"boxSizing");n.style[i]=ge(i,o+("border-box"===a?q(n,!e):0))}}))}})),I.toggle=function(e){return this.each((function(i,n){if(F(n)){var a=W(n);(k(e)?a:e)?(n.style.display=n.___cd||"",W(n)&&(n.style.display=function(e){if(Y[e])return Y[e];var i=o(e);t.body.insertBefore(i,null);var n=U(i,"display");return t.body.removeChild(i),Y[e]="none"!==n?n:"block"}(n.tagName))):a||(n.___cd=U(n,"display"),n.style.display="none")}}))},I.hide=function(){return this.toggle(!1)},I.show=function(){return this.toggle(!0)};var Te={focus:"focusin",blur:"focusout"},xe={mouseenter:"mouseover",mouseleave:"mouseout"},Ie=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function Ee(e){return xe[e]||Te[e]||e}function Ne(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Se(e){return e.___ce=e.___ce||{}}function _e(e,t){return!t||!g.call(t,(function(t){return e.indexOf(t)<0}))}function Fe(e,t,i,n,o){var a=Se(e);if(t)a[t]&&(a[t]=a[t].filter((function(a){var s=a[0],r=a[1],l=a[2];if(o&&l.guid!==o.guid||!_e(s,i)||n&&n!==r)return!0;e.removeEventListener(t,l)})));else for(t in a)Fe(e,t,i,n,o)}I.trigger=function(e,i){if(P(e)){var n=Ne(e),o=n[0],a=n[1],s=Ee(o);if(!s)return this;var r=Ie.test(s)?"MouseEvents":"HTMLEvents";(e=t.createEvent(r)).initEvent(s,!0,!0),e.namespace=a.join("."),e.___ot=o}e.___td=i;var l=e.___ot in Te;return this.each((function(t,i){l&&O(i[e.___ot])&&(i["___i".concat(e.type)]=!0,i[e.___ot](),i["___i".concat(e.type)]=!1),i.dispatchEvent(e)}))},I.off=function(e,t,i){var n=this;if(k(e))this.each((function(e,t){(F(t)||_(t)||S(t))&&Fe(t)}));else if(P(e))O(t)&&(i=t,t=""),D(R(e),(function(e,o){var a=Ne(o),s=a[0],r=a[1],l=Ee(s);n.each((function(e,n){(F(n)||_(n)||S(n))&&Fe(n,l,r,t,i)}))}));else for(var o in e)this.off(o,e[o]);return this},I.remove=function(e){return Z(this,e).detach().off(),this},I.replaceWith=function(e){return this.before(e).remove()},I.replaceAll=function(e){return E(e).replaceWith(this),this},I.on=function(e,t,i,n,o){var a=this;if(!P(e)){for(var s in e)this.on(s,t,i,e[s],o);return this}return P(t)||(k(t)||V(t)?t="":k(i)?(i=t,t=""):(n=i,i=t,t="")),O(n)||(n=i,i=void 0),n?(D(R(e),(function(e,s){var r=Ne(s),l=r[0],c=r[1],u=Ee(l),d=l in xe,p=l in Te;u&&a.each((function(e,a){if(F(a)||_(a)||S(a)){var s=function(e){if(e.target["___i".concat(e.type)])return e.stopImmediatePropagation();if((!e.namespace||_e(c,e.namespace.split(".")))&&(t||!(p&&(e.target!==a||e.___ot===u)||d&&e.relatedTarget&&a.contains(e.relatedTarget)))){var r=a;if(t){for(var l=e.target;!G(l,t);){if(l===a)return;if(!(l=l.parentNode))return}r=l}Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return r}}),Object.defineProperty(e,"delegateTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(e,"data",{configurable:!0,get:function(){return i}});var m=n.call(r,e,e.___td);o&&Fe(a,u,c,t,s),!1===m&&(e.preventDefault(),e.stopPropagation())}};s.guid=n.guid=n.guid||E.guid++,function(e,t,i,n,o){var a=Se(e);a[t]=a[t]||[],a[t].push([i,n,o]),e.addEventListener(t,o)}(a,u,c,t,s)}}))})),this):this},I.one=function(e,t,i,n){return this.on(e,t,i,n,!0)};var Be=/\r?\n/g,Oe=/file|reset|submit|button|image/i,Pe=/radio|checkbox/i;I.serialize=function(){var e="";return this.each((function(t,i){D(i.elements||[i],(function(t,i){if(!(i.disabled||!i.name||"FIELDSET"===i.tagName||Oe.test(i.type)||Pe.test(i.type)&&!i.checked)){var n=te(i);k(n)||D(c(n)?n:[n],(function(t,n){e+=function(e,t){return"&".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t.replace(Be,"\r\n")))}(i.name,n)}))}}))})),e.slice(1)},e.exports=E}()},631:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var n=i(537),o=i.n(n),a=i(645),s=i.n(a)()(o());s.push([e.id,".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\n}\n\n.hit-triage-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header {\n border: none;\n border-left: 4px solid transparent;\n border-radius: 1px;\n padding: 4px 8px;\n min-height: 28px;\n justify-content: flex-end;\n flex-direction: row-reverse;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\ntable.hit-triage-table {\n margin: 10px;\n width: calc(100% - 20px);\n}\n\n.hit-triage-table-container {\n max-width: 600px;\n max-height: 500px;\n overflow-y: scroll;\n}\n\n.hit-triage-error-div {\n color: red;\n text-align: start;\n}\n\n.mx-5 {\n margin-left: 5px;\n margin-right: 5px;\n}\n\n.hit-triage-new-template-functions-input > .ui-box {\n height: 300px;\n}\n\n.hit-triage-new-template-functions-input {\n max-height: 200px;\n max-width: unset !important;\n overflow-y: scroll;\n}\n\n\n.hit-triage-new-template-functions-input > .d4-tab-host {\n width: 100% !important;\n}\n\n.hit-triage-compute-dialog-host {\n max-height: 550px;\n max-width: 700px;\n}\n\n.hit-triage-compute-dialog-descriptors-group {\n margin-left: 16px;\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.d4-ribbon-name .ui-breadcrumbs {\n\toverflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\tflex-wrap: nowrap;\n padding: 0;\n}\n\n.d4-ribbon-name .ui-breadcrumbs i {\n\tpadding: 0 6px;\n\tfont-size: 10px;\n\tfont-weight: bold;\n}\n\n.d4-ribbon-name .ui-breadcrumbs-element:first-child {\n\twhite-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}","",{version:3,sources:["webpack://./css/hit-triage.css"],names:[],mappings:"AAAA;IACI,yBAAyB;IACzB,0BAA0B;AAC9B;;AAEA;IACI,aAAa;IACb,mBAAmB;IACnB,oBAAoB;AACxB;;AAEA;IACI,YAAY;IACZ,kCAAkC;IAClC,kBAAkB;IAClB,gBAAgB;IAChB,gBAAgB;IAChB,yBAAyB;IACzB,2BAA2B;AAC/B;;AAEA;IACI,oCAAoC;IACpC,yBAAyB;AAC7B;;AAEA;IACI,cAAc;AAClB;;AAEA;IACI,YAAY;IACZ,wBAAwB;AAC5B;;AAEA;IACI,gBAAgB;IAChB,iBAAiB;IACjB,kBAAkB;AACtB;;AAEA;IACI,UAAU;IACV,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;IAChB,iBAAiB;AACrB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,iBAAiB;IACjB,2BAA2B;IAC3B,kBAAkB;AACtB;;;AAGA;IACI,sBAAsB;AAC1B;;AAEA;IACI,iBAAiB;IACjB,gBAAgB;AACpB;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,kBAAkB;AACtB;;AAEA;CACC,gBAAgB;IACb,mBAAmB;IACnB,uBAAuB;CAC1B,iBAAiB;IACd,UAAU;AACd;;AAEA;CACC,cAAc;CACd,eAAe;CACf,iBAAiB;AAClB;;AAEA;CACC,mBAAmB;IAChB,gBAAgB;IAChB,uBAAuB;AAC3B",sourcesContent:[".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\n}\n\n.hit-triage-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header {\n border: none;\n border-left: 4px solid transparent;\n border-radius: 1px;\n padding: 4px 8px;\n min-height: 28px;\n justify-content: flex-end;\n flex-direction: row-reverse;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\ntable.hit-triage-table {\n margin: 10px;\n width: calc(100% - 20px);\n}\n\n.hit-triage-table-container {\n max-width: 600px;\n max-height: 500px;\n overflow-y: scroll;\n}\n\n.hit-triage-error-div {\n color: red;\n text-align: start;\n}\n\n.mx-5 {\n margin-left: 5px;\n margin-right: 5px;\n}\n\n.hit-triage-new-template-functions-input > .ui-box {\n height: 300px;\n}\n\n.hit-triage-new-template-functions-input {\n max-height: 200px;\n max-width: unset !important;\n overflow-y: scroll;\n}\n\n\n.hit-triage-new-template-functions-input > .d4-tab-host {\n width: 100% !important;\n}\n\n.hit-triage-compute-dialog-host {\n max-height: 550px;\n max-width: 700px;\n}\n\n.hit-triage-compute-dialog-descriptors-group {\n margin-left: 16px;\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.d4-ribbon-name .ui-breadcrumbs {\n\toverflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\tflex-wrap: nowrap;\n padding: 0;\n}\n\n.d4-ribbon-name .ui-breadcrumbs i {\n\tpadding: 0 6px;\n\tfont-size: 10px;\n\tfont-weight: bold;\n}\n\n.d4-ribbon-name .ui-breadcrumbs-element:first-child {\n\twhite-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}"],sourceRoot:""}]);const r=s},290:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var n=i(537),o=i.n(n),a=i(645),s=i.n(a)()(o());s.push([e.id,".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/src/u2.css"],names:[],mappings:"AAAA;;AAEA;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,kBAAkB;AACtB;;AAEA;IACI,SAAS;AACb",sourcesContent:[".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}"],sourceRoot:""}]);const r=s},143:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var n=i(537),o=i.n(n),a=i(645),s=i.n(a)()(o());s.push([e.id,"img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}","",{version:3,sources:["webpack://./src/app/hit-design-views/utils.css"],names:[],mappings:"AAAA;IACI,eAAe;AACnB",sourcesContent:["img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}"],sourceRoot:""}]);const r=s},645:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var i="",n=void 0!==t[5];return t[4]&&(i+="@supports (".concat(t[4],") {")),t[2]&&(i+="@media ".concat(t[2]," {")),n&&(i+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),i+=e(t),n&&(i+="}"),t[2]&&(i+="}"),t[4]&&(i+="}"),i})).join("")},t.i=function(e,i,n,o,a){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(n)for(var r=0;r<this.length;r++){var l=this[r][0];null!=l&&(s[l]=!0)}for(var c=0;c<e.length;c++){var u=[].concat(e[c]);n&&s[u[0]]||(void 0!==a&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=a),i&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=i):u[2]=i),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),t.push(u))}},t}},537:e=>{"use strict";e.exports=function(e){var t=e[1],i=e[3];if(!i)return t;if("function"==typeof btoa){var n=btoa(unescape(encodeURIComponent(JSON.stringify(i)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),a="/*# ".concat(o," */");return[t].concat([a]).join("\n")}return[t].join("\n")}},379:e=>{"use strict";var t=[];function i(e){for(var i=-1,n=0;n<t.length;n++)if(t[n].identifier===e){i=n;break}return i}function n(e,n){for(var a={},s=[],r=0;r<e.length;r++){var l=e[r],c=n.base?l[0]+n.base:l[0],u=a[c]||0,d="".concat(c," ").concat(u);a[c]=u+1;var p=i(d),m={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)t[p].references++,t[p].updater(m);else{var h=o(m,n);n.byIndex=r,t.splice(r,0,{identifier:d,updater:h,references:1})}s.push(d)}return s}function o(e,t){var i=t.domAPI(t);return i.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;i.update(e=t)}else i.remove()}}e.exports=function(e,o){var a=n(e=e||[],o=o||{});return function(e){e=e||[];for(var s=0;s<a.length;s++){var r=i(a[s]);t[r].references--}for(var l=n(e,o),c=0;c<a.length;c++){var u=i(a[c]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}a=l}}},569:e=>{"use strict";var t={};e.exports=function(e,i){var n=function(e){if(void 0===t[e]){var i=document.querySelector(e);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}t[e]=i}return t[e]}(e);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(i)}},216:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},565:(e,t,i)=>{"use strict";e.exports=function(e){var t=i.nc;t&&e.setAttribute("nonce",t)}},795:e=>{"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(i){!function(e,t,i){var n="";i.supports&&(n+="@supports (".concat(i.supports,") {")),i.media&&(n+="@media ".concat(i.media," {"));var o=void 0!==i.layer;o&&(n+="@layer".concat(i.layer.length>0?" ".concat(i.layer):""," {")),n+=i.css,o&&(n+="}"),i.media&&(n+="}"),i.supports&&(n+="}");var a=i.sourceMap;a&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),t.styleTagTransform(n,e,t.options)}(t,e,i)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},589:e=>{"use strict";e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function i(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={id:n,exports:{}};return e[n](a,a.exports,i),a.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.nc=void 0;var n={};(()=>{"use strict";i.r(n),i.d(n,{_package:()=>Fe,demoFileIngest:()=>Pe,demoFileIngest1:()=>ke,demoFileIngest2:()=>Ve,demoFileSubmit:()=>Le,gasteigerCellRenderer:()=>je,hitDesignApp:()=>Oe,hitTriageApp:()=>Be});const e=grok,t=DG,o=ui,a="campaignId",s="campaignId",r="HitTriageFunction",l="HitTriageDataSource",c="HitTriageSubmitFunction",u="Selected hits",d="Stage",p="Molecule",m="V-iD",h="V######",f="HTScript",v="HTQuery",g="molecules",y="Source",b="New template",w="Start",C="Create",A="Download",T="Cancel",x="Continue a campaign",I="New campaign";var E=i(379),N=i.n(E),S=i(795),_=i.n(S),F=i(569),B=i.n(F),O=i(565),P=i.n(O),k=i(216),V=i.n(k),L=i(589),j=i.n(L),D=i(631),H={};H.styleTagTransform=j(),H.setAttributes=P(),H.insert=B().bind(null,"head"),H.domAPI=_(),H.insertStyleElement=V(),N()(D.Z,H),D.Z&&D.Z.locals&&D.Z.locals;const M=e=>`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`;function R(e,t){const i=document.title,n=window.location.href.split("?")[0]+"?"+e+"="+t;if(history.replaceState){const e={Title:i,Url:n};history.replaceState(e,e.Title,e.Url)}}function U(t,i,n,a){var s;const r=o.breadcrumbs([i,n]),l=r.onPathClick.subscribe((e=>{1===e.length&&(l.unsubscribe(),$(t),a())})),c=null===(s=e.shell.v.ribbonMenu.root.parentElement)||void 0===s?void 0:s.getElementsByClassName("d4-ribbon-name")[0];return c&&(c.textContent="",c.appendChild(r.root)),{breadcrumbs:r,sub:l}}function $(e){const t=e.getRibbonPanels();(null==t?void 0:t.length)&&(t.pop(),e.setRibbonPanels(t))}function q(e){return e.reduce(((e,t)=>e||t.reduce(((e,t)=>e||t.classList.contains("hit-design-submit-button")||Array.from(t.children).some((e=>e.classList.contains("hit-design-submit-button")))),!1)),!1)}function Y(e,i,n){return o=this,a=void 0,r=function*(){if(0===n.rowCount)return;if(!e.col(i))throw new Error("There is no molecule column in dataframe");let o=n.col(g);if(o||(yield n.meta.detectSemanticTypes(),o=n.columns.bySemType(t.SEMTYPE.MOLECULE)),!o)throw new Error("There is no original molecule column in query result dataframe");const a=n.columns.names().filter((e=>e!==g));e.join(n,[i],[o.name],void 0,a,void 0,!0)},new((s=void 0)||(s=Promise))((function(e,t){function i(e){try{l(r.next(e))}catch(e){t(e)}}function n(e){try{l(r.throw(e))}catch(e){t(e)}}function l(t){var o;t.done?e(t.value):(o=t.value,o instanceof s?o:new s((function(e){e(o)}))).then(i,n)}l((r=r.apply(o,a||[])).next())}));var o,a,s,r}const W={String:t.TYPE.STRING,Number:t.TYPE.FLOAT,Boolean:t.TYPE.BOOL,Date:t.TYPE.DATE_TIME,Molecule:t.SEMTYPE.MOLECULE};var G=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))},J=i(553),Z=i.n(J);function z(i,n,a,s,r){var l,c,u,d,p,m,h,g,y,b,w,C,A,T,x,I,E,N,S,_,F,B,O,P,k,V,L,j,D,H,M;return j=this,D=void 0,M=function*(){const j=yield i.computeFunctions,D=j.functions.filter((({inputs:e})=>e.length>2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).map((e=>{var t,i,n,o;return{package:e.package.name,name:e.name,args:null!==(o=null===(n=null===(i=null===(t=null==s?void 0:s.compute)||void 0===t?void 0:t.functions)||void 0===i?void 0:i.find((t=>t.name===e.name&&t.package===e.package.name)))||void 0===n?void 0:n.args)&&void 0!==o?o:{}}})),H=j.scripts.filter((({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).map((e=>{var t,i,n,o;return{name:e.name,id:e.id,args:null!==(o=null===(n=null===(i=null===(t=null==s?void 0:s.compute)||void 0===t?void 0:t.scripts)||void 0===i?void 0:i.find((t=>t.id===e.id)))||void 0===n?void 0:n.args)&&void 0!==o?o:{}}})),M=j.queries.filter((e=>e.inputs.length>0&&"list"===e.inputs[0].propertyType)).map((e=>{var t,i,n,o,a;return{name:null!==(t=e.friendlyName)&&void 0!==t?t:e.name,id:e.id,args:null!==(a=null===(o=null===(n=null===(i=null==s?void 0:s.compute)||void 0===i?void 0:i.queries)||void 0===n?void 0:n.find((t=>t.id===e.id)))||void 0===o?void 0:o.args)&&void 0!==a?a:{}}})),R=!!(null===(c=null===(l=null==s?void 0:s.compute)||void 0===l?void 0:l.descriptors)||void 0===c?void 0:c.enabled)||r,U=yield e.chem.descriptorsTree(),$=o.tree();$.root.classList.add("hit-triage-compute-dialog-descriptors-group");const q=o.div([],{classes:"hit-triage-compute-dialog-host"}),Y=[];function W(e,t){const i=t.group(e,null,!1);return i.enableCheckBox(!1),i}const G=Object.keys(U),J=null!==(p=null===(d=null===(u=null==s?void 0:s.compute)||void 0===u?void 0:u.descriptors)||void 0===d?void 0:d.args)&&void 0!==p?p:[];for(const e of G){const t=W(e,$);for(const i of U[e].descriptors){const e=t.item(i.name,i);Y.push(e),e.enableCheckBox(J.includes(i.name))}}const z="Descriptors",Q={[z]:z},K=R?{[z]:$.root}:{},X={},ee={[z]:!1};ee.Descriptors=!!(null===(h=null===(m=null==s?void 0:s.compute)||void 0===m?void 0:m.descriptors)||void 0===h?void 0:h.enabled)&&(null===(b=null===(y=null===(g=null==s?void 0:s.compute)||void 0===g?void 0:g.descriptors)||void 0===y?void 0:y.args)||void 0===b?void 0:b.length)>0;for(const e of D)try{const i=t.Func.find({package:e.package,name:e.name})[0],n=i.prepare(e.args),a=`${e.package}:${e.name}`;X[a]=n;const r=o.div(),l=yield n.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",K[null!==(w=i.friendlyName)&&void 0!==w?w:i.name]=r,Q[null!==(C=i.friendlyName)&&void 0!==C?C:i.name]=a,ee[a]=null!==(x=null===(T=null===(A=null==s?void 0:s.compute)||void 0===A?void 0:A.functions)||void 0===T?void 0:T.some((t=>t.name===e.name&&t.package===e.package)))&&void 0!==x&&x,r.children[0].style.display="none",r.children[1].style.display="none",l.forEach((t=>{var i,n;(null===(i=t.property)||void 0===i?void 0:i.name)&&Object.keys(e.args).includes(null===(n=t.property)||void 0===n?void 0:n.name)&&(t.value=e.args[t.property.name]),t.fireChanged()}))}catch(e){console.error(e);continue}for(const t of H)try{const i=yield e.dapi.scripts.find(t.id),n=i.prepare(t.args),a=`HTScript:${null!==(I=t.name)&&void 0!==I?I:""}:${t.id}`;X[a]=n;const r=o.div(),l=yield n.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",K[null!==(E=i.friendlyName)&&void 0!==E?E:i.name]=r,Q[null!==(N=i.friendlyName)&&void 0!==N?N:i.name]=a,ee[a]=null!==(F=null===(_=null===(S=null==s?void 0:s.compute)||void 0===S?void 0:S.scripts)||void 0===_?void 0:_.some((e=>e.id===t.id)))&&void 0!==F&&F,r.children[0].style.display="none",r.children[1].style.display="none",l.forEach((e=>{var i,n;(null===(i=e.property)||void 0===i?void 0:i.name)&&Object.keys(t.args).includes(null===(n=e.property)||void 0===n?void 0:n.name)&&(e.value=t.args[e.property.name]),e.fireChanged()}))}catch(e){console.error(e);continue}for(const t of M)try{const i=yield e.dapi.queries.find(t.id),n=i.prepare(t.args),a=`HTQuery:${null!==(B=t.name)&&void 0!==B?B:""}:${t.id}`;X[a]=n;const r=o.div(),l=yield n.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",K[null!==(O=i.friendlyName)&&void 0!==O?O:i.name]=r,Q[null!==(P=i.friendlyName)&&void 0!==P?P:i.name]=a,ee[a]=null!==(L=null===(V=null===(k=null==s?void 0:s.compute)||void 0===k?void 0:k.queries)||void 0===V?void 0:V.some((e=>e.id===t.id)))&&void 0!==L&&L,r.children[0].style.display="none",l.forEach((e=>{var i,n;(null===(i=e.property)||void 0===i?void 0:i.name)&&Object.keys(t.args).includes(null===(n=e.property)||void 0===n?void 0:n.name)&&(e.value=t.args[e.property.name]),e.fireChanged()}))}catch(e){console.error(e);continue}const te=o.tabControl(K,!0);function ie(){const e={descriptors:[],externals:{},scripts:{},queries:{}};e.descriptors=ee.Descriptors?Y.filter((e=>e.checked)).map((e=>e.value.name)):[];const t=Object.entries(X).filter((([e,t])=>ee[e]));t.filter((([e,t])=>!e.startsWith(f)&&!e.startsWith(v))).forEach((([t,i])=>{e.externals[t]={};const n=i.inputs;Object.entries(n).slice(2).forEach((([i,n])=>{e.externals[t][i]=n}))})),t.filter((([e,t])=>e.startsWith(f))).forEach((([t,i])=>{e.scripts[t]={};const n=i.inputs;Object.entries(n).slice(2).forEach((([i,n])=>{e.scripts[t][i]=n}))})),t.filter((([e,t])=>e.startsWith(v))).forEach((([t,i])=>{e.queries[t]={};const n=i.inputs;Object.entries(n).slice(1).forEach((([i,n])=>{e.queries[t][i]=n}))})),console.log(e),n(e)}return te.root.style.width="100%",te.root.style.minWidth="350px",q.appendChild(te.root),te.panes.forEach((e=>{const t=o.boolInput("",ee[Q[e.name]],(i=>{ee[Q[e.name]]=!!t.value,i?Z()(e.content).find("input").removeAttr("disabled"):Z()(e.content).find("input").attr("disabled","true")}));t.setTooltip("Toggle calculation of this function"),e.header.appendChild(t.root),e.header.classList.add("hit-triage-compute-dialog-pane-header")})),r&&o.dialog("Compute").add(q).onOK((()=>ie())).onCancel(a).show(),{root:q,okProxy:ie}},new((H=void 0)||(H=Promise))((function(e,t){function i(e){try{o(M.next(e))}catch(e){t(e)}}function n(e){try{o(M.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof H?o:new H((function(e){e(o)}))).then(i,n)}o((M=M.apply(j,D||[])).next())}))}const Q=rxjs;class K{constructor(e,t=[],i={}){this.onItemChanged=new Q.Subject,this.onAddingItemChanged=new Q.Subject,this.onItemAdded=new Q.Subject,this.onItemRemoved=new Q.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.properties=e,this.options=Object.assign(Object.assign({},this.options),i),this._root=o.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=t,this.render()}get root(){return this._root}get items(){return this._items}render(){var e,t,i,n;if(o.empty(this._root),!this.options.horizontalInputNames)for(const t of this.properties){const i=o.divText(null!==(e=t.caption)&&void 0!==e?e:t.name);i.style.fontWeight="bold",this._root.appendChild(i)}for(const e of this._items){const t=this.getItemDiv(e);for(const e of t)this._root.appendChild(e)}if(this.options.allowAdd){const e=this.getItemDiv(null!==(n=null===(i=(t=this.options).newItemFunction)||void 0===i?void 0:i.call(t))&&void 0!==n?n:void 0,!0);for(const t of e)this._root.appendChild(t)}}getItemDiv(e={},i){var n;const a=[],s={};let r=null;for(const l of this.properties){void 0===e[l.name]&&(e[l.name]=null);const c=(null===(n=this.options.customInputs)||void 0===n?void 0:n[l.name])?this.options.customInputs[l.name](e):o.input.forProperty(l,e);a.push(this.options.horizontalInputNames?c.root:this.hideLabel(c.root)),l.propertyType!==t.TYPE.BOOL&&"color"!==l.name.toLowerCase()&&c.input&&(c.input.style.width="100%"),s[l.name]=c,c.onChanged((()=>{e[l.name]=c.value,i?this.onAddingItemChanged.next({item:e,fieldName:l.name}):this.onItemChanged.next({item:e,fieldName:l.name})})),c.root.style.alignItems="center",r=c}let l=null;if(i)l=o.icons.add((()=>{const e=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(s).forEach((t=>{e[t]=s[t].value})),this._items.push(e),this.onItemAdded.next(e),this.render()}),this.options.addButtonTooltip);else{if(!this.options.allowRemove)return a;l=o.icons.delete((()=>{this._items.splice(this._items.indexOf(e),1),this.onItemRemoved.next(e),this.render()}),this.options.removeButtonTooltip)}return r&&r.addOptions?r.addOptions(l):null==r||r.root.appendChild(l),l.style.color="#2083d5",a}hideLabel(e){return e.getElementsByTagName("label")[0]&&e.removeChild(e.getElementsByTagName("label")[0]),e}}var X=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function ee(i,n){var a,s;return X(this,void 0,void 0,(function*(){const u=t.Func.find({tags:[r]}),d=(yield Fe.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5))),p=[];for(const e of d){const t=JSON.parse(yield Fe.files.readAsText(`Hit Triage/templates/${e}.json`));p.push(t.key)}const m=t.Func.find({tags:[c]}),h={};m.forEach((e=>{var t;h[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const g=o.choiceInput("Submit function",null,[null,...Object.keys(h)]);g.value=null,g.nullable=!0,g.fireChanged(),g.setTooltip("Select function to be called upon submitting");const b=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),w=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),A=o.stringInput("Name","",(()=>{""===A.value||d.includes(A.value)?(A.root.style.borderBottom="1px solid red",b.style.opacity="100%"):(A.root.style.borderBottom="none",b.style.opacity="0%")})),x=o.stringInput("Key","",(()=>{""===x.value||p.includes(x.value)?(x.root.style.borderBottom="1px solid red",w.style.opacity="100%"):(x.root.style.borderBottom="none",w.style.opacity="0%")}));x.setTooltip("Template key used for campaign prefix"),A.setTooltip("Template name"),A.root.style.borderBottom="none",x.root.style.borderBottom="none",b.style.opacity="0%",w.style.opacity="0%";const I={Descriptors:"Descriptors"};u.forEach((e=>{var t;I[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=`${e.package.name}:${e.name}`}));let E=null;const N=yield z(i,(e=>{E=e}),(()=>null),{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},!1);if(N.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(n).length){const i=t.Func.find({tags:[l]}),o=yield e.dapi.queries.include("params,connection").filter("#HitTriageDataSource").list();i.forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e})),o.forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}))}const S=Object.keys(n),_=o.choiceInput(y,S[0],S),F=o.choiceInput("Ingest using","Query",["Query","File"],(()=>{"Query"!==F.value?_.root.style.display="none":_.root.style.display="block"})),B=te(),O=o.div([o.h2("Details"),o.div([A,b]),o.div([x,w]),F.root,_.root,B.fieldsDiv,o.h2("Compute"),N.root,o.h2("Submit"),g.root],"ui-form"),P=o.buttonsInput([]),k=null!==(s=null===(a=P.getElementsByClassName("ui-input-editor"))||void 0===a?void 0:a[0])&&void 0!==s?s:P;O.appendChild(P);const V=new Promise((e=>{const t=o.button(T,(()=>e()));k.appendChild(t)})),L=new Promise((t=>{const i=o.bigButton(C,(()=>function(){var i,n,o,a,s,r,l;return X(this,void 0,void 0,(function*(){if(N.okProxy(),"100%"===b.style.opacity)return void e.shell.error("Template name is empty or already exists");const c=g.value?h[g.value]:void 0,u=Object.assign(Object.assign({name:A.value,key:x.value,campaignFields:B.getFields(),dataSourceType:null!==(i=F.value)&&void 0!==i?i:"Query",compute:{descriptors:{enabled:!!(null===(n=null==E?void 0:E.descriptors)||void 0===n?void 0:n.length),args:null!==(o=null==E?void 0:E.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(a=null==E?void 0:E.externals)&&void 0!==a?a:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(s=null==E?void 0:E.scripts)&&void 0!==s?s:{}).filter((([e,t])=>e.startsWith(f)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(r=null==E?void 0:E.queries)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(v)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))}},c?{submit:{fName:c.name,package:c.package.name}}:{}),{queryFunctionName:"Query"===F.value&&null!==(l=_.value)&&void 0!==l?l:void 0});var d;d=u,Fe.files.writeAsText(`Hit Triage/templates/${d.name}.json`,JSON.stringify(d)),e.shell.info("Template created successfully"),t(u)}))}()));k.appendChild(i)}));return{root:O,template:L,cancelPromise:V}}))}function te(e){const i=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING}),t.Property.fromOptions({name:"Type",type:t.TYPE.STRING,choices:Object.keys(W)}),t.Property.fromOptions({name:"Required",type:t.TYPE.BOOL})],n=new K(i,e?e.map((e=>({Name:e.name,Type:e.type,Required:e.required}))):void 0,{horizontalInputNames:!1});n.root.style.maxWidth="750px";let a={};n.onItemAdded.subscribe((e=>{a=null!=e?e:{}})),n.onAddingItemChanged.subscribe((e=>{e&&(a=e.item)}));const s=o.h2("Additional fields");o.tooltip.bind(s,"Additional fields to be filled by user for each campaign");const r=o.div([s,n.root]);return{getFields:function(){var e;const t=n.items.filter((e=>e.Name)).map((e=>{var t;return{name:e.Name,type:e.Type,required:null!==(t=e.Required)&&void 0!==t&&t}}));return a.Name&&""!==a.Name&&a.Type&&(null!==(e=a.Required)&&void 0!==e||(a.Required=!1),t.push({name:a.Name,type:a.Type,required:a.Required})),t},fieldsDiv:o.div([r])}}var ie=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class ne extends t.ViewBase{constructor(e){super(),this.app=e}get template(){return this.app.template}onActivated(){}onReset(){}process(){return ie(this,void 0,void 0,(function*(){}))}deleteCampaign(e,t){return ie(this,void 0,void 0,(function*(){yield Fe.files.delete(`${e}/campaigns/${t}`)}))}}var oe=i(290),ae={};ae.styleTagTransform=j(),ae.setAttributes=P(),ae.insert=B().bind(null,"head"),ae.domAPI=_(),ae.insertStyleElement=V(),N()(oe.Z,ae),oe.Z&&oe.Z.locals&&oe.Z.locals;var se;!function(t){let i,n;!function(e){e.vert=function(e){return o.divV(e.map((e=>o.render(e))),{classes:"u2-panel"})},e.horz=function(e){return o.divH(e.map((e=>o.render(e))),{classes:"u2-panel"})}}(i=t.panels||(t.panels={})),t.appHeader=function(e){const t=o.iconImage("",e.iconPath);return Z()(t).addClass("ui-app-header-icon").css("margin-right","20px"),i.horz([t,i.vert([o.markdown(e.description),e.learnMoreUrl?o.link("Learn more",e.learnMoreUrl):null])])},function(t){t.runAsync=function(t,i){return n=this,a=void 0,r=function*(){o.setUpdateIndicator(t,!0);try{return yield i()}catch(t){e.log.error(t)}finally{o.setUpdateIndicator(t,!1)}},new((s=void 0)||(s=Promise))((function(e,t){function i(e){try{l(r.next(e))}catch(e){t(e)}}function o(e){try{l(r.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof s?n:new s((function(e){e(n)}))).then(i,o)}l((r=r.apply(n,a||[])).next())}));var n,a,s,r}}(n=t.tools||(t.tools={}))}(se||(se={}));var re=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class le extends ne{constructor(t){super(t),this.readmePath=Fe.webRoot+"README_HT.md",this.deletedCampaigns=[],this.dataSourceFunctionsMap={},this.name="Hit Triage",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(this.readmePath),this.checkCampaign().then((e=>{this.app.campaign=e,this.init()}))}onActivated(){e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(this.readmePath)}init(e){return re(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const t=o.h1(x),i=o.h1(I,{style:{marginLeft:"10px"}}),n=se.appHeader({iconPath:Fe.webRoot+"/images/icons/hit-triage-icon.png",learnMoreUrl:"https://github.com/datagrok-ai/public/blob/master/packages/HitTriage/README_HT.md",description:"- Configure your own workflow using the template editor.\n- Calculate different molecular properties.\n- Filter molecules using different criteria.\n- Submit processed dataframe to the function of your choice.\n- Save campaigns and continue any time from where you left off.\n "}),a=o.div(),s=o.div([],{classes:"ui-form"}),r=yield this.getCampaignsTable();yield this.startNewCampaign(a,s,e),Z()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,t],{style:{marginLeft:"10px"}}),r,i,s,a])),this.app.resetBaseUrl()}catch(e){throw o.setUpdateIndicator(this.root,!1),e}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(e,t,i){var n;return re(this,void 0,void 0,(function*(){const a=(yield Fe.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5)));i&&!a.includes(i.name)&&a.push(i.name);const s=()=>re(this,void 0,void 0,(function*(){const t=r.value,n=i&&i.name===t?i:JSON.parse(yield Fe.files.readAsText("Hit Triage/templates/"+t+".json")),o=yield this.getNewCampaignAccordeon(n,e);Z()(e).empty(),e.className="ui-form",e.appendChild(o)})),r=o.choiceInput("Template",null!==(n=null==i?void 0:i.name)&&void 0!==n?n:a[0],a,(()=>re(this,void 0,void 0,(function*(){yield s()})))),l=o.icons.add((()=>re(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),o.setUpdateIndicator(this.root,!1)}))),b);r.addOptions(l),yield s(),Z()(t).empty(),t.appendChild(r.root)}))}checkCampaign(e){return re(this,void 0,void 0,(function*(){const t=location.search,i=new URLSearchParams(t);if(!i.has(a)&&!e)return;const n=null!=e?e:i.get(a);if(!(yield Fe.files.exists(`Hit Triage/campaigns/${n}/campaign.json`)))return;const o=JSON.parse(yield Fe.files.readAsText(`Hit Triage/campaigns/${n}/campaign.json`)),s=JSON.parse(yield Fe.files.readAsText(`Hit Triage/templates/${o.templateName}.json`));return this.app.setTemplate(s,o.filters,n,o.ingest),e&&R(a,e),o}))}getCampaignsTable(){return re(this,void 0,void 0,(function*(){const e=(yield Fe.files.list("Hit Triage/campaigns")).filter((e=>-1===this.deletedCampaigns.indexOf(e.name))),t={};for(const i of e){const e=JSON.parse(yield Fe.files.readAsText(`Hit Triage/campaigns/${i.name}/campaign.json`));t[e.name]=e}const i=Object.values(t).map((e=>({name:e.name,createDate:e.createDate,rowCount:e.rowCount,filtered:e.filteredRowCount,status:e.status}))),n=o.table(i,(e=>[o.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.filtered,e.status,o.icons.delete((()=>re(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK((()=>re(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Triage",e.name),this.deletedCampaigns.push(e.name),yield this.init()})))).show()}))),"Delete campaign")]),["Name","Created","Total","Selected","Status",""]);return n.style.color="var(--grey-5)",n}))}setCampaign(e){return re(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(i,n){return re(this,void 0,void 0,(function*(){o.setUpdateIndicator(n,!0);const{root:a,promise:s,cancelPromise:r}=yield function(i,n){var a,s;return G(this,void 0,void 0,(function*(){const r=o.divText("",{style:{color:"red"}});let c=null;const u=()=>G(this,void 0,void 0,(function*(){try{if(c=d.value,!c)return;if(yield c.meta.detectSemanticTypes(),!c.columns.bySemType(t.SEMTYPE.MOLECULE))return void(r.innerText="No molecules column found");r.innerText=""}catch(e){r.innerText="Error parsing file"}})),d=o.tableInput("Dataframe",null,void 0,u);yield u();const p=o.div([d,r]);0===Object.keys(n).length&&(t.Func.find({tags:[l]}).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e})),(yield e.dapi.queries.include("params,connection").filter("#HitTriageDataSource").list()).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e})));let m=null;const h=()=>G(this,void 0,void 0,(function*(){const e=n[v.value];m=e.prepare();const t=yield m.getEditor();t.classList.remove("ui-form"),f.innerHTML="",f.appendChild(t)})),f=o.div([]),v=o.choiceInput(y,null!==(a=i.queryFunctionName)&&void 0!==a?a:Object.keys(n)[0],Object.keys(n),h);yield h(),i.queryFunctionName&&(null===(s=v.root.getElementsByTagName("select").item(0))||void 0===s||s.setAttribute("disabled","true"));const g=o.div([v,f]);g.style.display="none";const b=o.div([p,g]),C=i.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:W[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),A={},x=C.length?o.input.form(A,C):o.div();x.classList.remove("ui-form"),"File"===i.dataSourceType?(p.style.display="inherit",g.style.display="none"):(p.style.display="none",g.style.display="inherit");const I=o.div([b,...C.length?[x]:[]]),E=o.buttonsInput([]);return I.appendChild(E),{promise:new Promise((t=>{const a=()=>G(this,void 0,void 0,(function*(){if("File"===i.dataSourceType){if(!c)return void e.shell.error("No file selected");const i=c;i.name=c.name,t({df:i,type:"File",campaignProps:A})}else{const i=n[v.value];if(!i)return void e.shell.error("No function selected");const o={};Object.entries(m.inputs).forEach((([e,t])=>{o[e]=t}));const a=yield i.apply(o);t({df:a,type:"Query",campaignProps:A})}})),s=o.bigButton(w,(()=>a()));E.appendChild(s)})),root:I,cancelPromise:new Promise((e=>{o.button(T,(()=>e()))}))}}))}(i,this.dataSourceFunctionsMap);return o.setUpdateIndicator(n,!1),s.then((e=>re(this,void 0,void 0,(function*(){this.app.dataFrame=e.df,this.app._fileInputType=e.type,yield this.app.setTemplate(i),this.app.campaignProps=e.campaignProps,this.app.saveCampaign(void 0,!1)})))),r.then((()=>{this.init()})),a}))}createNewTemplate(){return re(this,void 0,void 0,(function*(){const i=yield ee(this.app,this.dataSourceFunctionsMap),n=new t.ViewBase,o=e.shell.v;n.name="New Template",n.root.appendChild(i.root),n.parentCall=this.app.parentCall,e.shell.addView(n),n.path=new URL(this.app.baseUrl).pathname+"/new-template",n.parentView=o;const{sub:a}=U(e.shell.v,"Hit Triage",b,(()=>{e.shell.v=o,n.close()}));i.template.then((t=>re(this,void 0,void 0,(function*(){yield this.init(t),n.close(),$(n),e.shell.v=o,a.unsubscribe()})))),i.cancelPromise.then((()=>{a.unsubscribe(),n.close(),e.shell.v=o}))}))}}class ce extends ne{constructor(e){super(e),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){var i,n,o,a,s;return n=this,o=void 0,s=function*(){const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=t.Func.find({name:n.fName,package:n.package})[0];if(!o)return void e.shell.error(`Function ${n.fName} not found.`);const a=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:a,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((a=void 0)||(a=Promise))((function(e,t){function i(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a((function(e){e(n)}))).then(i,r)}l((s=s.apply(n,o||[])).next())}))}}var ue=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class de{constructor(i){this.parentCall=i,this.resetBaseUrl(),this.computeFunctions=new Promise((i=>ue(this,void 0,void 0,(function*(){const n=t.Func.find({tags:[r]}),o=yield e.dapi.scripts.include("params").filter("#HitTriageFunction").list(),a=yield e.dapi.queries.include("params,connection").filter("#HitTriageFunction").list();i({functions:n,scripts:o,queries:a})}))))}resetBaseUrl(){const e=window.location.href,t=new URL(e);this.baseUrl=t.origin+t.pathname}getFilterType(e){const i=this.dataFrame.col(e);return(null==i?void 0:i.semType)===t.SEMTYPE.MOLECULE?t.FILTER_TYPE.SUBSTRUCTURE:(null==i?void 0:i.type)===t.COLUMN_TYPE.BOOL?t.FILTER_TYPE.BOOL_COLUMNS:(null==i?void 0:i.type)===t.COLUMN_TYPE.STRING?t.FILTER_TYPE.CATEGORICAL:t.FILTER_TYPE.HISTOGRAM}download(e,i,n=!1){const o=document.createElement("a"),a=t.DataFrame.fromColumns(e.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv({filteredRowsOnly:n});o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),o.setAttribute("download",i+".csv"),o.click()}getNewCampaignName(e,t){return ue(this,void 0,void 0,(function*(){const i=(yield Fe.files.list(e)).map((e=>e.name)).filter((e=>e.startsWith(t)));if(0===i.length)return t+"-1";const n=i.map((e=>e.split("-")[1])).filter(Boolean).map((e=>parseInt(e,10))).sort();return t+"-"+(n[n.length-1]+1).toString()}))}setBaseUrl(){const e=document.title;if(history.replaceState){const t={Title:e,Url:this.baseUrl};history.replaceState(t,t.Title,t.Url)}}}var pe=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))},me=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function he(e){let t=0;if(e.length>1)for(const i of e.toList()){if(!i||!i.startsWith(h[0])||i.length!==h.length)continue;const e=parseInt(i.substring(1));isNaN(e)||(t=Math.max(e,t))}return`V${"".concat(...new Array(h.length-1-(t+1).toString().length).fill("0"))}${t+1}`}function fe(i,n,o){var a,s;return me(this,void 0,void 0,(function*(){const r=n.col(o);if(!r)throw new Error("There is no molecule column in dataframe");for(let t=0;t<r.length;t++){if(r.isNone(t))continue;const i=r.get(t);if(!i)continue;const n=e.chem.convert(i,e.chem.Notation.Unknown,e.chem.Notation.Smiles);r.set(t,n,!1)}i.descriptors&&i.descriptors.length>0&&(yield e.chem.descriptors(n,o,i.descriptors));for(const e of Object.keys(i.externals)){const a=i.externals[e],s=t.Func.find({package:e.split(":")[0],name:e.split(":")[1]})[0],r=s.inputs[0].name,l=s.inputs[1].name;a&&(yield s.apply(Object.assign(Object.assign({},a),{[r]:n,[l]:o})))}for(const t of Object.keys(null!==(a=i.scripts)&&void 0!==a?a:{})){const a=i.scripts[t];if(a){const i=t.split(":")[2];if(!i)continue;try{const t=yield e.dapi.scripts.find(i);if(!t)continue;const s=t.inputs[0].name,r=t.inputs[1].name;yield t.apply(Object.assign(Object.assign({},a),{[s]:n,[r]:o}))}catch(e){console.error(e)}}}for(const t of Object.keys(null!==(s=i.queries)&&void 0!==s?s:{})){const a=i.queries[t];if(a){const i=t.split(":")[2];if(!i)continue;try{const t=yield e.dapi.queries.find(i);if(!t)continue;const s=t.inputs[0].name,r=n.col(o).toList(),l=yield t.apply(Object.assign(Object.assign({},a),{[s]:r}));l&&(yield Y(n,o,l))}catch(e){console.error(e)}}}}))}var ve=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class ge extends de{constructor(i){super(i),this._filterViewName="Hit triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=new le(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof ne&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,e.shell.addView(this.multiView),e.events.onCurrentViewChanged.subscribe((()=>{var t,i,n,o;try{(null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentPickViewId&&(e.shell.windows.showHelp=!1,this.setBaseUrl(),R(a,null!==(o=null!==(i=this._campaignId)&&void 0!==i?i:null===(n=this._campaign)||void 0===n?void 0:n.name)&&void 0!==o?o:""))}catch(e){console.error(e)}}))}setTemplate(i,n,o,s){var r,l,c,u,d,p,m,h,f,v,g,y,b,w;return ve(this,void 0,void 0,(function*(){if((null===(r=this._pickView)||void 0===r?void 0:r.dataFrame)&&e.shell.closeTable(null===(l=this._pickView)||void 0===l?void 0:l.dataFrame),this._pickView=void 0,o?s&&(this._fileInputType=s.type,"File"===s.type?this.dataFrame=yield e.dapi.files.readCsv(s.query):this.dataFrame=yield e.functions.call(s.query)):(o=yield this.getNewCampaignName("Hit Triage/campaigns",i.key),R(a,o)),!this.dataFrame)return void console.error("Dataframe is empty.");if((null===(c=this._campaign)||void 0===c?void 0:c.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&(i.semType=t)})),yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(d=null===(u=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===u?void 0:u.name)&&void 0!==d?d:void 0,this._dfName=null!==(p=this.dataFrame.name)&&void 0!==p?p:null==s?void 0:s.query,this.dataFrame.name=null!==(h=null!==(m=this._dfName)&&void 0!==m?m:this.dataFrame.name)&&void 0!==h?h:"Molecules",this._campaignId=o,this.template=(null===(f=this.campaign)||void 0===f?void 0:f.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:i.dataSourceType,queryFunctionName:i.queryFunctionName}):i,this._campaignFilters=n,!n){const e={},t={},n={};i.compute.functions.forEach((t=>{const i=`${t.package}:${t.name}`;e[i]=t.args})),null===(v=i.compute.scripts)||void 0===v||v.forEach((e=>{const i=`HTScript:${e.name}:${e.id}`;t[i]=e.args})),null===(g=i.compute.queries)||void 0===g||g.forEach((e=>{const t=`HTQuery:${e.name}:${e.id}`;n[t]=e.args})),yield fe({descriptors:i.compute.descriptors.enabled?i.compute.descriptors.args:[],externals:e,scripts:t,queries:n},this.dataFrame,this._molColName)}const C=e.shell.v,A=e.shell.addView(this.pickView);this.currentPickViewId=A.name,this._submitView=new ce(this),this.setBaseUrl(),R(a,null!==(w=null!==(y=this._campaignId)&&void 0!==y?y:null===(b=this._campaign)||void 0===b?void 0:b.name)&&void 0!==w?w:"");const T=A;setTimeout((()=>{this._pickViewPromise&&this._pickViewPromise.then((()=>{const{sub:t}=U(T,"Hit Triage","Pick",(()=>{e.shell.v=C,T.close(),t.unsubscribe()}))}))}),300),e.shell.windows.showHelp=!1}))}get filterSettings(){return this._campaignFilters}get campaignId(){return this._campaignId}get pickView(){return this._pickView=this.getFilterView()}get molColName(){var e,i,n;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name}get fileInputType(){return this._fileInputType}get campaign(){return this._campaign}set campaign(e){this._campaign=e}getFilterView(){let e=null;this._pickViewPromise=new Promise((t=>{e=t})),this.dataFrame.col(u)||this.dataFrame.columns.addNewBool(u).init(!1);const i=t.TableView.create(this.dataFrame,!1),n=i.getRibbonPanels(),a=o.iconFA("wrench",(()=>ve(this,void 0,void 0,(function*(){z(this,(e=>ve(this,void 0,void 0,(function*(){var t,i,n,o,a,s,r;const l=this.template.compute.descriptors.args,c=this.template.compute.functions,u=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],d=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],p=e.descriptors,m={descriptors:{enabled:!!(null===(n=null==e?void 0:e.descriptors)||void 0===n?void 0:n.length),args:null!==(o=null==e?void 0:e.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(a=null==e?void 0:e.externals)&&void 0!==a?a:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(s=null==e?void 0:e.scripts)&&void 0!==s?s:{}).filter((([e,t])=>e.startsWith(f)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(r=null==e?void 0:e.queries)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(v)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))};this.template.compute=m;const h=p.filter((e=>!l.includes(e))),g=m.functions.filter((e=>{if(!c.some((t=>t.name===e.name&&t.package===e.package)))return!0;const t=c.find((t=>t.name===e.name&&t.package===e.package));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),y=m.scripts.filter((e=>{if(!u.some((t=>t.id===e.id)))return!0;const t=u.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),b=m.queries.filter((e=>{if(!d.some((t=>t.id===e.id)))return!0;const t=d.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),w={};g.forEach((e=>{const t=`${e.package}:${e.name}`;w[t]=e.args}));const C={};y.forEach((e=>{const t=`HTScript:${e.name}:${e.id}`;C[t]=e.args}));const A={};b.forEach((e=>{const t=`HTQuery:${e.name}:${e.id}`;A[t]=e.args})),yield fe({descriptors:h,externals:w,scripts:C,queries:A},this.dataFrame,this._molColName),this.saveCampaign("In Progress",!1)}))),(()=>null),this.template,!0)}))),"Calculate additional properties"),s=o.bigButton("Submit",(()=>{var e;const t=null===(e=this._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}}));s.classList.add("hit-design-submit-button");const r=q(n);return n.push([a,...r?[]:[s]]),i.setRibbonPanels(n),i.name=this._filterViewName,setTimeout((()=>ve(this,void 0,void 0,(function*(){var n;i._onAdded(),yield new Promise((e=>setTimeout(e,1e3)));const o=i.filters(this._campaignFilters?{filters:this._campaignFilters}:void 0);if(null===(n=this._campaign)||void 0===n?void 0:n.layout)try{const e=t.ViewLayout.fromViewState(this._campaign.layout);i.loadLayout(e)}catch(e){console.error(e)}i.dataFrame.onFilterChanged.subscribe((e=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=o.getOptions().look.filters})),setTimeout((()=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=o.getOptions().look.filters}),300),e&&e()}))),300),i.parentCall=this.parentCall,i}getSummary(){var e,t,i,n,a,s,r;const l=null!==(t=null===(e=this.campaign)||void 0===e?void 0:e.campaignFields)&&void 0!==t?t:this.campaignProps;return Object.assign(Object.assign({Template:null!==(n=null===(i=this.template)||void 0===i?void 0:i.name)&&void 0!==n?n:"Molecules","File path":o.divH([o.link(null!==(a=this._dfName)&&void 0!==a?a:"-",(()=>this.download(this.dataFrame,"molecules")),A)],{style:{alignItems:"center"}})},l),{"Number of molecules":this.dataFrame.rowCount.toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((e=>e.name))].filter((e=>e&&""!==e.trim())).join(", "),Filters:this._filterDescriptions.join(", "),"Result Molecules":o.divH([o.link(null!==(r=null===(s=this.dataFrame)||void 0===s?void 0:s.filter.trueCount.toString())&&void 0!==r?r:"0",(()=>{this.download(this.dataFrame,"hits",!0)}),A)],{style:{alignItems:"center"}})})}saveCampaign(i,n=!0){var a,s,r,l,c,u;return ve(this,void 0,void 0,(function*(){const d=this.campaignId,p=this.filterSettings,m=this.template.name,h=this.dataFrame,f=`System:AppData/HitTriage/Hit Triage/campaigns/${d}/`,v=null!=d?d:yield function(e){return pe(this,void 0,void 0,(function*(){return new Promise((t=>pe(this,void 0,void 0,(function*(){const i=o.stringInput("Campaign name","");o.dialog("Save Campaign").add(o.div(i.root)).onOK((function(){i.value&&""!==i.value?t(i.value):t(e)})).show()}))))}))}(d),g={};h.columns.toList().forEach((e=>g[e.name]=e.semType));const y={name:v,templateName:m,filters:null!=p?p:{},ingest:{type:"File",query:`${f}enriched_table.csv`,molColName:this.molColName},status:null!==(s=null!=i?i:null===(a=this.campaign)||void 0===a?void 0:a.status)&&void 0!==s?s:"In Progress",createDate:null!==(l=null===(r=this.campaign)||void 0===r?void 0:r.createDate)&&void 0!==l?l:M(new Date),campaignFields:null!==(u=null===(c=this.campaign)||void 0===c?void 0:c.campaignFields)&&void 0!==u?u:this.campaignProps,columnSemTypes:g,rowCount:h.rowCount,filteredRowCount:h.filter.trueCount,template:this.template};this.campaign=y;const b=t.DataFrame.fromColumns(h.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield Fe.files.writeAsText(`Hit Triage/campaigns/${d}/enriched_table.csv`,b);const w=this._pickView.saveLayout();w?y.layout=w.viewState:e.shell.warning("Layout cound not be saved"),yield Fe.files.writeAsText(`Hit Triage/campaigns/${d}/campaign.json`,JSON.stringify(y)),n&&e.shell.info("Campaign saved successfully.")}))}}var ye=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function be(i,n){var a,s,l,u,d,p,m,h,g,y,b;return ye(this,void 0,void 0,(function*(){const w=t.Func.find({tags:[r]}),A=yield Fe.files.list("Hit Design/templates");let x=!1,I=!1;const E=A.map((e=>e.name.slice(0,-5))),N=[];for(const e of A)try{const t=JSON.parse(yield Fe.files.readAsText(e));N.push(t.key)}catch(e){console.error(e)}const S=t.Func.find({tags:[c]}),_={};S.forEach((e=>{var t;_[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const F=o.choiceInput("Submit function",null,[null,...Object.keys(_)]);F.nullable=!0,F.value=null!==(s=null===(a=null==n?void 0:n.submit)||void 0===a?void 0:a.fName)&&void 0!==s?s:null,F.setTooltip("Select function to be called upon submitting");const B=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),O=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"});function P(){var e,t,i,n;if(""===k.value||E.includes(null!==(t=null===(e=k.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=k.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=k.input.offsetWidth)&&void 0!==n?n:0;B.style.marginLeft=`${e}px`,B.style.width=`${t}px`,B.style.opacity="100%",B.style.borderTop="1px solid red",x=!0}else B.style.borderTop="none",B.style.opacity="0%",x=!1}const k=o.stringInput("Name",null!==(l=null==n?void 0:n.name)&&void 0!==l?l:"",P);function V(){var e,t,i,n;if(""===L.value||N.includes(null!==(t=null===(e=L.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=L.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=L.input.offsetWidth)&&void 0!==n?n:0;O.style.marginLeft=`${e}px`,O.style.width=`${t}px`,O.style.borderTop="1px solid red",O.style.opacity="100%",I=!0}else O.style.opacity="0%",O.style.borderTop="none",I=!1}const L=o.stringInput("Key",null!==(u=null==n?void 0:n.key)&&void 0!==u?u:"",V);L.setTooltip("Template key used for campaign prefix"),k.setTooltip("Template name"),k.root.style.borderBottom="none",L.root.style.borderBottom="none",B.style.opacity="0%",O.style.opacity="0%";const j={Descriptors:"Descriptors"};w.forEach((e=>{var t;j[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=`${e.package.name}:${e.name}`}));let D=null;const H={compute:{descriptors:{enabled:!0,args:null!==(m=null===(p=null===(d=null==n?void 0:n.compute)||void 0===d?void 0:d.descriptors)||void 0===p?void 0:p.args)&&void 0!==m?m:[]},functions:null!==(g=null===(h=null==n?void 0:n.compute)||void 0===h?void 0:h.functions)&&void 0!==g?g:[]}},M=yield z(i,(e=>{D=e}),(()=>null),H,!1);M.root.classList.add("hit-triage-new-template-functions-input");const R=te(null==n?void 0:n.campaignFields),U=function(e){const i=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING})],n=new K(i,e?e.map((e=>({Name:e}))):void 0,{horizontalInputNames:!0});let o={};return n.onItemAdded.subscribe((e=>{o=null!=e?e:{}})),n.onAddingItemChanged.subscribe((e=>{e&&(o=e.item)})),{getFields:function(){const e=n.items.filter((e=>e.Name)).map((e=>e.Name));return o.Name&&""!==o.Name&&e.push(o.Name),e},fieldsDiv:n.root}}(null==n?void 0:n.stages),$=o.divV([o.divV([k,B]),o.divV([L,O]),R.fieldsDiv]),q=o.h2("Stages");o.tooltip.bind(q,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const Y=o.h2("Compute");o.tooltip.bind(Y,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const W=o.div([o.h2("Details"),$,q,U.fieldsDiv,Y,M.root,o.h2("Submit"),F.root],"ui-form"),G=o.buttonsInput([]);W.appendChild(G);const J=null!==(b=null===(y=G.getElementsByClassName("ui-input-editor"))||void 0===y?void 0:y[0])&&void 0!==b?b:G,Z=new Promise((e=>{const t=o.button(T,(()=>e()));J.appendChild(t)})),Q=new Promise((t=>{const i=o.bigButton(C,(()=>function(){var i,n,o,a,s;return ye(this,void 0,void 0,(function*(){if(P(),V(),M.okProxy(),x||!k.value||""===k.value)return void e.shell.error("Template name is empty or already exists");if(I||!L.value||""===L.value)return void e.shell.error("Template key is empty or already exists");const r=F.value?_[F.value]:void 0,l=Object.assign({name:k.value,key:L.value,campaignFields:R.getFields(),stages:U.getFields(),compute:{descriptors:{enabled:!!(null===(i=null==D?void 0:D.descriptors)||void 0===i?void 0:i.length),args:null!==(n=null==D?void 0:D.descriptors)&&void 0!==n?n:[]},functions:Object.entries(null!==(o=null==D?void 0:D.externals)&&void 0!==o?o:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(a=null==D?void 0:D.scripts)&&void 0!==a?a:{}).filter((([e,t])=>e.startsWith(f)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(s=null==D?void 0:D.queries)&&void 0!==s?s:{}).filter((([e,t])=>e.startsWith(v)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))}},r?{submit:{fName:r.name,package:r.package.name}}:{});var c;c=l,Fe.files.writeAsText(`Hit Design/templates/${c.name}.json`,JSON.stringify(c)),e.shell.info("Template created successfully"),t(l)}))}()));J.appendChild(i)}));return{root:W,template:Q,cancelPromise:Z}}))}var we=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class Ce extends ne{constructor(t){super(t),this.deletedCampaigns=[],this.name="Hit Design",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(Fe.webRoot+"README_HD.md"),this.checkCampaign().then((e=>{this.app.campaign=e,this.init()}))}onActivated(){e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(Fe.webRoot+"README_HD.md")}init(e){return we(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const t=o.h1(x),i=o.h1(I,{style:{marginLeft:"10px"}}),n=se.appHeader({iconPath:Fe.webRoot+"/images/icons/hit-design-icon.png",learnMoreUrl:"https://github.com/datagrok-ai/public/blob/master/packages/HitTriage/README_HD.md",description:"- Configure your own workflow using the template editor\n- Sketch molecules in the molecular spreadsheet\n- Annotate and share ideas with the team\n- Calculate different molecular properties\n- Save campaigns and continue from where you left off\n- Submit final selection to the function of your choice"}),a=o.div(),s=o.divH([]),r=o.div([s,a],"ui-form"),l=yield this.getCampaignsTable();Z()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,t],{style:{marginLeft:"10px"}}),l,i,r])),yield this.startNewCampaign(a,s,e),this.app.resetBaseUrl()}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(e,t,i){var n;return we(this,void 0,void 0,(function*(){const a=(yield Fe.files.list("Hit Design/templates")).filter((e=>e.name.endsWith(".json"))).map((e=>e.name.slice(0,-5)));i&&!a.includes(i.name)&&a.push(i.name);let s=null;const r=()=>we(this,void 0,void 0,(function*(){const t=l.value,n=i&&i.name===t?i:JSON.parse(yield Fe.files.readAsText("Hit Design/templates/"+t+".json"));s=n;const o=yield this.getNewCampaignAccordeon(n);Z()(e).empty(),e.appendChild(o)})),l=o.choiceInput("Template",null!==(n=null==i?void 0:i.name)&&void 0!==n?n:a[0],a,(()=>we(this,void 0,void 0,(function*(){yield r()}))));l.root.style.width="100%";const c=o.icons.add((()=>{this.createNewTemplate()}),b),u=o.icons.copy((()=>{s&&this.createNewTemplate(s)}),"Clone template");c.style.color="#2083d5",l.addOptions(u),l.addOptions(c),yield r(),Z()(t).empty(),t.appendChild(l.root)}))}checkCampaign(e){var t;return we(this,void 0,void 0,(function*(){const i=location.search,n=new URLSearchParams(i);if(!n.has(s)&&!e)return;const o=null!=e?e:n.get(s);if(!(yield Fe.files.exists(`Hit Design/campaigns/${o}/campaign.json`)))return;const a=JSON.parse(yield Fe.files.readAsText(`Hit Design/campaigns/${o}/campaign.json`));a&&(this.app.campaign=a);const r=null!==(t=a.template)&&void 0!==t?t:JSON.parse(yield Fe.files.readAsText(`Hit Design/templates/${a.templateName}.json`));return yield this.app.setTemplate(r,o),e&&R(s,e),a.template=r,a}))}getCampaignsTable(){return we(this,void 0,void 0,(function*(){const e=(yield Fe.files.list("Hit Design/campaigns")).filter((e=>-1===this.deletedCampaigns.indexOf(e.name))),t={};for(const i of e){const e=JSON.parse(yield Fe.files.readAsText(`Hit Design/campaigns/${i.name}/campaign.json`));t[e.name]=e}const i=o.table(Object.values(t),(e=>[o.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.status,o.icons.delete((()=>we(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK((()=>we(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Design",e.name),this.deletedCampaigns.push(e.name),yield this.init()})))).show()}))),"Delete campaign")]),["Name","Created","Molecules","Status",""]);return i.style.color="var(--grey-5)",i.style.marginLeft="24px",i}))}setCampaign(e){return we(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(i){return we(this,void 0,void 0,(function*(){const{root:n,promise:a,cancelPromise:s}=function(i){var n,a;const s=t.DataFrame.create(1),r=s.columns.addNew(p,t.TYPE.STRING);r.semType=t.SEMTYPE.MOLECULE,r.setTag(t.TAGS.UNITS,t.UNITS.Molecule.SMILES),r.set(0,null),(null===(n=null==i?void 0:i.stages)||void 0===n?void 0:n.length)>0&&s.columns.addNew(d,t.TYPE.STRING).set(0,i.stages[0]);const l=s.columns.addNew(m,t.TYPE.STRING);l.set(0,he(l));const c=i.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:W[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),u={},h=o.input.form(u,c);h.classList.remove("ui-form");const f=o.div([...(null===(a=i.campaignFields)||void 0===a||a.length,[]),h]),v=o.buttonsInput([]);return f.appendChild(v),{promise:new Promise((t=>{const n=o.bigButton(w,(()=>{for(const t of i.campaignFields)if(t.required&&(!u[t.name]||""===u[t.name]))return void e.shell.error(`Field '${t.name}' is required`);t({df:s,campaignProps:u})}));v.appendChild(n)})),root:f,cancelPromise:new Promise((e=>{o.button(T,(()=>e()))}))}}(i);return a.then((e=>we(this,void 0,void 0,(function*(){this.app.dataFrame=e.df,yield this.app.setTemplate(i),this.app.campaignProps=e.campaignProps,this.app.saveCampaign(void 0,!1)})))),s.then((()=>{this.init()})),n}))}createNewTemplate(i){return we(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const n=yield be(this.app,i),a=new t.ViewBase,s=e.shell.v;a.name="New Template",a.root.appendChild(n.root),a.parentCall=this.app.parentCall,e.shell.addView(a),a.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:r}=U(a,"Hit Design",b,(()=>we(this,void 0,void 0,(function*(){e.shell.v=s,a.close()}))));n.template.then((t=>we(this,void 0,void 0,(function*(){yield this.init(t),a.close(),$(a),e.shell.v=s,r.unsubscribe()})))),n.cancelPromise.then((()=>we(this,void 0,void 0,(function*(){r.unsubscribe(),a.close(),e.shell.v=s}))))}finally{o.setUpdateIndicator(this.root,!1)}}))}}class Ae extends ne{constructor(e){super(e),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){var i,n,o,a,s;return n=this,o=void 0,s=function*(){const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=t.Func.find({name:n.fName,package:n.package})[0];if(!o)return void e.shell.error(`Function ${n.fName} not found.`);const a=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:a,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((a=void 0)||(a=Promise))((function(e,t){function i(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a((function(e){e(n)}))).then(i,r)}l((s=s.apply(n,o||[])).next())}))}}var Te=i(143),xe={};xe.styleTagTransform=j(),xe.setAttributes=P(),xe.insert=B().bind(null,"head"),xe.domAPI=_(),xe.insertStyleElement=V(),N()(Te.Z,xe),Te.Z&&Te.Z.locals&&Te.Z.locals;class Ie extends ne{constructor(e){super(e),this.v=null,this.name="Progress Tracker"}render(){return i=this,n=void 0,s=function*(){return new Promise((i=>{var n,a;o.empty(this.root),this.app.dataFrame.columns.names().forEach((e=>{e.startsWith("~")&&this.app.dataFrame.columns.remove(e)})),this.v=t.Viewer.fromType(t.VIEWER.TILE_VIEWER,this.app.dataFrame,{lanesColumnName:d,lanes:null!==(a=null===(n=this.app.template)||void 0===n?void 0:n.stages)&&void 0!==a?a:[]}),this.root.appendChild(this.v.root),this.v.root.style.height="100%",this.v.root.style.width="100%",setTimeout((()=>{var t,n,a;null===(n=null===(t=this.v)||void 0===t?void 0:t.view)||void 0===n||n._onAdded();const s=null===(a=e.shell.v)||void 0===a?void 0:a.getRibbonPanels();if(s){if(q(s))return void i();const t=o.bigButton("Design view",(()=>{const t=e.shell.view(this.app.designViewName);t&&(e.shell.v=t)})),n=o.bigButton("Submit",(()=>{var e;const t=null===(e=this.app._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.app.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this.app._submitView)||void 0===t||t.submit(),e.close()})),e.show()}}));n.classList.add("hit-design-submit-button"),s.push([t,n]),e.shell.v.setRibbonPanels(s)}i()}),5)}))},new((a=void 0)||(a=Promise))((function(e,t){function o(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a((function(e){e(i)}))).then(o,r)}l((s=s.apply(i,n||[])).next())}));var i,n,a,s}onActivated(){this.render()}destroy(){var e;null===(e=this.v)||void 0===e||e.detach()}}var Ee=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class Ne extends de{constructor(i){super(i),this._tilesViewTab=null,this._designViewName="Design",this._filePath="System.AppData/HitTriage/Hit Design/campaigns",this._molColName=p,this.campaignProps={},this.processedValues=[],this._extraStageColsCount=0,this._infoView=new Ce(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof ne&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,this.mainView=e.shell.addView(this.multiView),e.events.onCurrentViewChanged.subscribe((()=>Ee(this,void 0,void 0,(function*(){var t,i,n,o,s,r,l,c,u;try{if((null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentDesignViewId||(null===(i=e.shell.v)||void 0===i?void 0:i.name)===this.currentTilesViewId){e.shell.windows.showHelp=!1,this.setBaseUrl(),R(a,null!==(s=null!==(n=this._campaignId)&&void 0!==n?n:null===(o=this._campaign)||void 0===o?void 0:o.name)&&void 0!==s?s:""),(null===(r=e.shell.v)||void 0===r?void 0:r.name)===this.currentTilesViewId?yield null===(l=this._tilesView)||void 0===l?void 0:l.render():null===(c=this._tilesView)||void 0===c||c.destroy();const{sub:t}=U(e.shell.v,"Hit Design",null===(u=e.shell.v)||void 0===u?void 0:u.name,(()=>{var i,n;e.shell.v=this.mainView,null===(i=this._tilesView)||void 0===i||i.close(),null===(n=this._designView)||void 0===n||n.close(),this._infoView.init(),t.unsubscribe()}))}}catch(e){console.error(e)}}))))}setTemplate(i,n){var o,r,l,c,u,d,m,h,f,v,g,y;return Ee(this,void 0,void 0,(function*(){if(n){const t="System.AppData/HitTriage/Hit Design/campaigns";this._filePath=null!==(l=null===(r=this.campaign)||void 0===r?void 0:r.savePath)&&void 0!==l?l:`${t}/${n}/enriched_table.csv`,this.dataFrame=yield e.dapi.files.readCsv(this._filePath),(null===(c=this._campaign)||void 0===c?void 0:c.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&t&&(i.semType=t)}))}else(null===(o=this._designView)||void 0===o?void 0:o.dataFrame)&&e.shell.closeTable(this._designView.dataFrame),this._designView=void 0,n=yield this.getNewCampaignName("Hit Design/campaigns",i.key),R(s,n),this._filePath=`System.AppData/HitTriage/Hit Design/campaigns/${n}/enriched_table.csv`;if(!this.dataFrame)return void console.error("DataFrame is empty");yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(d=null===(u=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===u?void 0:u.name)&&void 0!==d?d:p,this._dfName=null!==(m=(y=this.dataFrame).name)&&void 0!==m?m:y.name=n,this._campaignId=n,this.template=i,null!==(h=this._submitView)&&void 0!==h||(this._submitView=new Ae(this)),e.shell.windows.showHelp=!1,this._extraStageColsCount=this.dataFrame.rowCount-this.dataFrame.filter.trueCount;const b=e.shell.addView(this.designView);this.currentDesignViewId=b.name,this.setBaseUrl(),R(a,null!==(g=null!==(f=this._campaignId)&&void 0!==f?f:null===(v=this._campaign)||void 0===v?void 0:v.name)&&void 0!==g?g:""),this.campaign&&(this.campaign.template=i)}))}get campaignId(){return this._campaignId}get designView(){return this._designView=this.getDesignView()}get designViewName(){return this._designViewName}get molColName(){var e,i,n,o;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null!==(o=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name)&&void 0!==o?o:p}get campaign(){return this._campaign}set campaign(e){this._campaign=e}getDesignView(){var i,n,a,s,r,l;const c=[],u=null===(i=this.dataFrame.col(this.molColName))||void 0===i?void 0:i.toList().every((e=>!e&&""===e)),h=t.TableView.create(this.dataFrame,!1);this._designViewName=null!==(a=null===(n=this.campaign)||void 0===n?void 0:n.name)&&void 0!==a?a:this._designViewName,h.name=this._designViewName,this.processedValues=this.dataFrame.getCol(this.molColName).toList(),setTimeout((()=>Ee(this,void 0,void 0,(function*(){var i,n;if(h._onAdded(),yield new Promise((e=>setTimeout(e,1e3))),null===(i=this._campaign)||void 0===i?void 0:i.layout)try{const e=t.ViewLayout.fromViewState(this._campaign.layout);h.loadLayout(e)}catch(e){console.error(e)}u&&e.functions.call("Chem:editMoleculeCell",{cell:h.grid.cell(this._molColName,0)}),c.push(this.dataFrame.onRowsAdded.subscribe((()=>{var t,i;try{if(this.processedValues=this.dataFrame.getCol(this.molColName).toList(),(null===(t=this.template.stages)||void 0===t?void 0:t.length)>0)for(let e=0;e<this.dataFrame.rowCount;e++){const t=this.dataFrame.col(d).get(e);t&&""!==t&&!(null===(i=this.dataFrame.col(d))||void 0===i?void 0:i.isNone(e))||this.dataFrame.set(d,e,this.template.stages[0])}let n=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=h.grid.cell(this.molColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(n=t))}n&&e.functions.call("Chem:editMoleculeCell",{cell:n})}catch(e){console.error(e)}}))),this.dataFrame&&c.push(null===(n=this.dataFrame)||void 0===n?void 0:n.onRowsRemoved.subscribe((()=>{try{this.processedValues=this.dataFrame.getCol(this.molColName).toList()}catch(e){console.error(e)}}))),c.push(e.events.onContextMenu.subscribe((i=>{var n,o,a,s,r;try{const e=null===(n=null==i?void 0:i.args)||void 0===n?void 0:n.context;if(!e)return;if((null==e?void 0:e.type)!==t.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==h.id)return;if((null===(s=null===(a=null===(o=null==i?void 0:i.args)||void 0===o?void 0:o.item)||void 0===a?void 0:a.tableColumn)||void 0===s?void 0:s.name)!==this.molColName)return;const l=null===(r=null==i?void 0:i.args)||void 0===r?void 0:r.menu;if(!l)return;l.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),l.item("Duplicate molecule",(()=>{var e,t,n,o;try{this.dataFrame.rows.addNew(null,!0);let a=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=h.grid.cell(this.molColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(a=t))}a&&(a.cell.value=null!==(o=null===(n=null===(t=null===(e=null==i?void 0:i.args)||void 0===e?void 0:e.item)||void 0===t?void 0:t.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}}))}catch(t){e.log.error(t)}}))),c.push(h.grid.onCellValueEdited.subscribe((i=>Ee(this,void 0,void 0,(function*(){var n,o,a,s;try{if((null===(n=i.tableColumn)||void 0===n?void 0:n.name)===d)return void(yield this.saveCampaign(void 0,!1));if((null===(o=i.tableColumn)||void 0===o?void 0:o.name)!==this.molColName)return;const r=i.cell.value,l=i.tableRowIndex;(null===(a=this.dataFrame.col(m))||void 0===a?void 0:a.get(l))&&""!==(null===(s=this.dataFrame.col(m))||void 0===s?void 0:s.get(l))||this.dataFrame.col(m).set(l,he(this.dataFrame.col(m)),!1);const c=this.template.compute;if(!r||""===r)return;const u=yield function(i,n,o,a=[],s=[]){return me(this,void 0,void 0,(function*(){const r=e.chem.convert(i,e.chem.Notation.Unknown,e.chem.Notation.Smiles),l=t.Column.fromStrings(p,[r]),c=t.DataFrame.fromColumns([l]);c.name="HD Single cell values",yield c.meta.detectSemanticTypes(),n.length&&(yield e.chem.descriptors(c,l.name,n));for(const e of o){const i=e.args,n=t.Func.find({package:e.package,name:e.name});if(!n.length||!n[0]){console.warn(`Function ${e.name} from package ${e.package} is not found`);continue}const o=n[0],a=o.inputs[0].name,s=o.inputs[1].name;yield o.apply(Object.assign(Object.assign({},i),{[a]:c,[s]:l.name}))}for(const t of a){const i=t.args;try{const n=yield e.dapi.scripts.find(t.id);if(n){const e=n.inputs[0].name,t=n.inputs[1].name;yield n.apply(Object.assign(Object.assign({},i),{[e]:c,[t]:l.name}))}}catch(e){console.error(e)}}for(const t of s){const i=t.args;try{const n=yield e.dapi.queries.find(t.id);if(n){const e=n.inputs[0].name,t=[r],o=yield n.apply(Object.assign(Object.assign({},i),{[e]:t}));if(!o||0===o.rowCount)continue;yield Y(c,p,o)}}catch(e){console.error(e)}}return c}))}(r,c.descriptors.args,c.functions,c.scripts,c.queries);for(const e of u.columns.toList())e.name!==p&&(this.dataFrame.columns.contains(e.name)||(this.dataFrame.columns.addNew(e.name,e.type).semType=e.semType),this.dataFrame.col(e.name).set(l,e.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(void 0,!1)}catch(e){console.error(e)}})))));const o=e.events.onViewRemoved.subscribe((e=>{e.id===h.id&&(c.forEach((e=>e.unsubscribe())),o.unsubscribe())}))}))),300);const g=null==h?void 0:h.getRibbonPanels();if(g&&!q(g)){const t=()=>Ee(this,void 0,void 0,(function*(){var e;z(this,(e=>Ee(this,void 0,void 0,(function*(){var t,i,n,a,s,r,l,c,u,d;const p=this.template.compute.descriptors.args,m=this.template.compute.functions,g=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],y=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],b=e.descriptors,w={descriptors:{enabled:!!(null===(n=null==e?void 0:e.descriptors)||void 0===n?void 0:n.length),args:null!==(a=null==e?void 0:e.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(s=null==e?void 0:e.externals)&&void 0!==s?s:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(r=null==e?void 0:e.scripts)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(f)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(l=null==e?void 0:e.queries)&&void 0!==l?l:{}).filter((([e,t])=>e.startsWith(v)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))};this.template.compute=w,this.campaign.template=this.template;const C=b.filter((e=>!p.includes(e))),A={};Object.entries(null!==(c=null==e?void 0:e.externals)&&void 0!==c?c:{}).filter((([e,t])=>{const i=m.find((t=>`${t.package}:${t.name}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{A[e]=t}));const T={};Object.entries(null!==(u=null==e?void 0:e.scripts)&&void 0!==u?u:{}).filter((([e,t])=>{const i=g.find((t=>`HTScript:${t.name}:${t.id}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{T[e]=t}));const x={};Object.entries(null!==(d=null==e?void 0:e.queries)&&void 0!==d?d:{}).filter((([e,t])=>{const i=y.find((t=>`HTQuery:${t.name}:${t.id}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{x[e]=t})),o.setUpdateIndicator(h.grid.root,!0);try{yield fe({descriptors:C,externals:A,scripts:T,queries:x},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{o.setUpdateIndicator(h.grid.root,!1),this.saveCampaign(void 0,!1)}}))),(()=>null),null===(e=this.campaign)||void 0===e?void 0:e.template,!0)})),i=o.iconFA("wrench",t,"Calculate additional properties"),n=o.icons.add((()=>{var e;null===(e=this.dataFrame)||void 0===e||e.rows.addNew(null,!0)}),"Add new row"),a=o.bigButton("Progress tracker",(()=>{this.currentTilesViewId&&e.shell.view(this.currentTilesViewId)?e.shell.v=e.shell.view(this.currentTilesViewId):(this._tilesView=new Ie(this),this._tilesView.parentCall=this.parentCall,this._tilesViewTab=e.shell.addView(this._tilesView),this.currentTilesViewId=this._tilesViewTab.name,this._tilesView.onActivated())})),c=o.bigButton("Submit",(()=>{var e;const t=null===(e=this._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}}));c.classList.add("hit-design-submit-button");const u=[c];null!==(l=null===(r=null===(s=this.template)||void 0===s?void 0:s.stages)||void 0===r?void 0:r.length)&&void 0!==l&&l&&u.unshift(a),this.campaign&&this.template&&!this.campaign.template&&(this.campaign.template=this.template),u.unshift(i),u.unshift(n),g.push(u),h.setRibbonPanels(g)}return h.parentCall=this.parentCall,h}getSummary(){var i,n,a,s;const r=()=>{var e,t;const i=this._filePath.indexOf(null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name);return-1===i?this._filePath:this._filePath.substring(0,i-1)},l=Object.assign({},null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.campaignFields)&&void 0!==n?n:this.campaignProps);return this.template&&this.template.campaignFields&&Object.entries(l).forEach((([i,n])=>{const o=this.template.campaignFields.find((e=>e.name===i));o&&"Date"===o.type&&n?"Invalid Date"!==new Date(n).toString()?l[i]=new Date(n).toLocaleDateString():n.date?l[i]=new Date(n.date).toLocaleDateString():l[i]=n:o&&o.type===t.SEMTYPE.MOLECULE&&n&&(l[i]=e.chem.drawMolecule(n))})),Object.assign(Object.assign({Template:null!==(s=null===(a=this.template)||void 0===a?void 0:a.name)&&void 0!==s?s:"Molecules","File path":(()=>{const t=o.icons.edit((()=>{const i=r(),s=o.stringInput("Path",i),l=s.root.getElementsByTagName("label").item(0);l&&l.remove(),s.root.style.width="100%";const c=o.button("Save",(()=>Ee(this,void 0,void 0,(function*(){const i=yield function(){return Ee(this,void 0,void 0,(function*(){const t=s.value;return t&&""!==t.trim()?!!(yield e.dapi.files.exists(t))||(e.shell.error("Given folder does not exist"),!1):(e.shell.error("Path can not be empty"),!1)}))}();if(!i)return;const l=s.value;l.endsWith("/")?this._filePath=`${l}${this.campaignId}/enriched_table.csv`:this._filePath=`${l}/${this.campaignId}/enriched_table.csv`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(void 0,!0),o.empty(a);const c=r();n=o.link(c,(()=>{var e,t,i;return this.download(this.dataFrame,null!==(i=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==i?i:"Molecules")}),A),a.appendChild(n),a.appendChild(t)})))),u=o.button("Cancel",(()=>{o.empty(a),a.appendChild(n),a.appendChild(t)}));o.empty(a),s.addOptions(u),s.addOptions(c),a.appendChild(s.root)}),"Edit file path");t.style.marginLeft="5px";const i=r();let n=o.link(i,(()=>{var e,t,i;return this.download(this.dataFrame,null!==(i=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==i?i:"Molecules")}),A);const a=o.divH([n,t],{style:{alignItems:"center"}});return a})()},l),{"Number of molecules":(this.dataFrame.rowCount-this._extraStageColsCount).toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((e=>e.name))].filter((e=>e&&""!==e.trim())).join(", ")})}saveCampaign(i,n=!0){var o,a,s,r,l,c,u,d;return Ee(this,void 0,void 0,(function*(){const p=this.campaignId,h=this.template.name,f=this.dataFrame,v=p,g={};f.columns.toList().forEach((e=>g[e.name]=e.semType));const y={name:v,templateName:h,status:null!==(a=null!=i?i:null===(o=this.campaign)||void 0===o?void 0:o.status)&&void 0!==a?a:"In Progress",createDate:null!==(r=null===(s=this.campaign)||void 0===s?void 0:s.createDate)&&void 0!==r?r:M(new Date),campaignFields:null!==(c=null===(l=this.campaign)||void 0===l?void 0:l.campaignFields)&&void 0!==c?c:this.campaignProps,columnSemTypes:g,rowCount:null!==(d=null===(u=f.col(m))||void 0===u?void 0:u.toList().filter((e=>"StageDefiningRow"!==e)).length)&&void 0!==d?d:0,filteredRowCount:f.filter.trueCount,savePath:this._filePath};console.log(this._filePath);const b=t.DataFrame.fromColumns(f.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield e.dapi.files.writeAsText(this._filePath,b);const w=this._designView.saveLayout();return w?y.layout=w.viewState:e.shell.warning("Layout cound not be saved"),y.template=this.template,yield Fe.files.writeAsText(`Hit Design/campaigns/${p}/campaign.json`,JSON.stringify(y)),n&&e.shell.info("Campaign saved successfully."),this.campaign=y,y}))}}class Se extends t.GridCellRenderer{get name(){return"customGasteigerPNG"}get cellType(){return"customGasteigerPNG"}get defaultHeight(){return 200}get defaultWidth(){return 200}render(e,t,i,n,o,a,s){if(a.gridRow<0||!a.cell.value)return;const r=a.cell.value,l=new Image(n-2,o-2);l.src="data:image/png;base64,"+r,l.onload=function(){e.drawImage(l,t+2,i+2,n-2,o-2)}}}var _e=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};const Fe=new t.Package;function Be(){return _e(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();new ge(t)}))}function Oe(){return _e(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();new Ne(t)}))}function Pe(){return _e(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(100);return t.name="100 Molecules",t}))}function ke(){return _e(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(5e3);return t.name="5000 Molecules",t}))}function Ve(t){return _e(this,void 0,void 0,(function*(){const i=e.data.demo.molecules(t);return i.name="Variable Molecules number",i}))}function Le(t,i){return _e(this,void 0,void 0,(function*(){e.shell.info(t.rowCount),e.shell.info(i)}))}function je(){return new Se}})(),hittriage=n})();
2
2
  //# sourceMappingURL=package.js.map