@datagrok/hit-triage 1.1.10 → 1.1.11
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/CHANGELOG.md +5 -0
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/files/Hit Triage/campaigns/demo-1/campaign.json +1 -0
- package/files/Hit Triage/campaigns/demo-1/enriched_table.csv +101 -0
- package/files/Hit Triage/campaigns/demo-2/campaign.json +1 -0
- package/files/Hit Triage/campaigns/demo-2/enriched_table.csv +101 -0
- package/package.json +1 -1
- package/src/app/accordeons/layout-input.ts +38 -0
- package/src/app/accordeons/new-hit-design-template-accordeon.ts +6 -2
- package/src/app/accordeons/new-template-accordeon.ts +4 -0
- package/src/app/hit-app-base.ts +40 -0
- package/src/app/hit-design-app.ts +50 -26
- package/src/app/hit-design-views/info-view.ts +3 -1
- package/src/app/hit-design-views/tiles-view.ts +11 -2
- package/src/app/hit-triage-app.ts +3 -3
- package/src/app/hit-triage-views/info-view.ts +3 -1
- package/src/app/types.ts +4 -2
- package/src/package.ts +43 -20
- package/webpack.config.js +3 -0
- package/files/Hit Triage/campaigns/DMT-1/campaign.json +0 -1
- package/files/Hit Triage/campaigns/DMT-1/enriched_table.csv +0 -101
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# HitTriage changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.11 (2024-06-03)
|
|
4
|
+
|
|
5
|
+
* Add ability for collaboration on same campaign.
|
|
6
|
+
* Fixed bugs with tiles viewer forms crashing in case of removing columns.
|
|
7
|
+
|
|
3
8
|
## 1.1.10 (2024-04-09)
|
|
4
9
|
|
|
5
10
|
Fixed bugs with tiles viewer forms and functions loading.
|
package/dist/package.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var hittriage;(()=>{var t={553:t=>{!function(){"use strict";var e=document,i=window,n=e.documentElement,o=e.createElement.bind(e),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(t,e){var i,n=!!(i=e)&&11===i.nodeType;return t&&(n||_(e)||F(e))?!n&&w.test(t)?e.getElementsByClassName(t.slice(1).replace(/\\/g,"")):!n&&A.test(t)?e.getElementsByTagName(t):e.querySelectorAll(t):[]}var x=function(){function t(t,n){if(t){if(E(t))return t;var o=t;if(P(t)){var a=n||e;if(!(o=b.test(t)&&_(a)?a.getElementById(t.slice(1).replace(/\\/g,"")):C.test(t)?X(t):E(a)?a.find(t):P(a)?S(a).find(t):T(t,a)))return}else if(O(t))return this.ready(t);(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 t.prototype.init=function(e,i){return new t(e,i)},t}(),I=x.prototype,S=I.init;function E(t){return t instanceof x}function N(t){return!!t&&t===t.window}function _(t){return!!t&&9===t.nodeType}function F(t){return!!t&&1===t.nodeType}function B(t){return"boolean"==typeof t}function O(t){return"function"==typeof t}function P(t){return"string"==typeof t}function k(t){return void 0===t}function V(t){return null===t}function L(t){return!isNaN(parseFloat(t))&&isFinite(t)}function j(t){if("object"!=typeof t||null===t)return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function D(t,e,i){if(i){for(var n=t.length;n--;)if(!1===e.call(t[n],n,t[n]))return t}else if(j(t))for(var o=Object.keys(t),a=(n=0,o.length);n<a;n++){var s=o[n];if(!1===e.call(t[s],s,t[s]))return t}else for(n=0,a=t.length;n<a;n++)if(!1===e.call(t[n],n,t[n]))return t;return t}function H(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=!!B(t[0])&&t.shift(),n=t.shift(),o=t.length;if(!n)return{};if(!o)return H(i,S,n);for(var a=0;a<o;a++){var s=t[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}S.fn=S.prototype=I,I.length=0,I.splice=y,"function"==typeof Symbol&&(I[Symbol.iterator]=u[Symbol.iterator]),S.isWindow=N,S.isFunction=O,S.isArray=c,S.isNumeric=L,S.isPlainObject=j,S.each=D,I.each=function(t){return D(this,t)},I.empty=function(){return this.each((function(t,e){for(;e.firstChild;)e.removeChild(e.firstChild)}))},S.extend=H,I.extend=function(t){return H(I,t)};var M=/\S+/g;function R(t){return P(t)&&t.match(M)||[]}function U(t,e,n){if(F(t)){var o=i.getComputedStyle(t,null);return n?o.getPropertyValue(e)||void 0:o[e]||t.style[e]}}function $(t,e){return parseInt(U(t,e),10)||0}function q(t,e){return $(t,"border".concat(e?"Left":"Top","Width"))+$(t,"padding".concat(e?"Left":"Top"))+$(t,"padding".concat(e?"Right":"Bottom"))+$(t,"border".concat(e?"Right":"Bottom","Width"))}I.toggleClass=function(t,e){var i=R(t),n=!k(e);return this.each((function(t,o){F(o)&&D(i,(function(t,i){n?e?o.classList.add(i):o.classList.remove(i):o.classList.toggle(i)}))}))},I.addClass=function(t){return this.toggleClass(t,!0)},I.removeAttr=function(t){var e=R(t);return this.each((function(t,i){F(i)&&D(e,(function(t,e){i.removeAttribute(e)}))}))},I.attr=function(t,e){if(t){if(P(t)){if(arguments.length<2){if(!this[0]||!F(this[0]))return;var i=this[0].getAttribute(t);return V(i)?void 0:i}return k(e)?this:V(e)?this.removeAttr(t):this.each((function(i,n){F(n)&&n.setAttribute(t,e)}))}for(var n in t)this.attr(n,t[n]);return this}},I.removeClass=function(t){return arguments.length?this.toggleClass(t,!1):this.attr("class","")},I.hasClass=function(t){return!!t&&g.call(this,(function(e){return F(e)&&e.classList.contains(t)}))},I.get=function(t){return k(t)?v.call(this):this[(t=Number(t))<0?t+this.length:t]},I.eq=function(t){return S(this.get(t))},I.first=function(){return this.eq(0)},I.last=function(){return this.eq(-1)},I.text=function(t){return k(t)?this.get().map((function(t){return F(t)||(e=t)&&3===e.nodeType?t.textContent:"";var e})).join(""):this.each((function(e,i){F(i)&&(i.textContent=t)}))};var Y={};function W(t){return"none"===U(t,"display")}function G(t,e){var i=t&&(t.matches||t.webkitMatchesSelector||t.msMatchesSelector);return!!i&&!!e&&i.call(t,e)}function J(t){return P(t)?function(e,i){return G(i,t)}:O(t)?t:E(t)?function(e,i){return t.is(i)}:t?function(e,i){return i===t}:function(){return!1}}function Z(t,e){return e?t.filter(e):t}I.filter=function(t){var e=J(t);return S(p.call(this,(function(t,i){return e.call(t,i,t)})))},I.detach=function(t){return Z(this,t).each((function(t,e){e.parentNode&&e.parentNode.removeChild(e)})),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(t){if(!P(t))return[];if(Q.test(t))return[o(RegExp.$1)];var e=z.test(t)&&RegExp.$1,i=K[e]||K["*"];return i.innerHTML=t,S(i.childNodes).detach().get()}function tt(t,e,i,n){for(var o=[],a=O(e),s=n&&J(n),r=0,l=t.length;r<l;r++)if(a){var c=e(t[r]);c.length&&f.apply(o,c)}else for(var u=t[r][e];!(null==u||n&&s(-1,u));)o.push(u),u=i?u[e]:null;return o}function et(t){return t.multiple&&t.options?tt(p.call(t.options,(function(t){return t.selected&&!t.disabled&&!t.parentNode.disabled})),"value"):t.value||""}function it(t){return t.length>1?p.call(t,(function(t,e,i){return m.call(i,t)===e})):t}S.parseHTML=X,I.has=function(t){var e=P(t)?function(e,i){return T(t,i).length}:function(e,i){return i.contains(t)};return this.filter(e)},I.not=function(t){var e=J(t);return this.filter((function(i,n){return(!P(t)||F(n))&&!e.call(n,i,n)}))},I.val=function(t){return arguments.length?this.each((function(e,i){var n=i.multiple&&i.options;if(n||Pt.test(i.type)){var o=c(t)?h.call(t,String):V(t)?[]:[String(t)];n?D(i.options,(function(t,e){e.selected=o.indexOf(e.value)>=0}),!0):i.checked=o.indexOf(i.value)>=0}else i.value=k(t)||V(t)?"":t})):this[0]&&et(this[0])},I.is=function(t){var e=J(t);return g.call(this,(function(t,i){return e.call(t,i,t)}))},S.guid=1,S.unique=it,I.add=function(t,e){return S(it(this.get().concat(S(t,e).get())))},I.children=function(t){return Z(S(it(tt(this,(function(t){return t.children})))),t)},I.parent=function(t){return Z(S(it(tt(this,"parentNode"))),t)},I.index=function(t){var e=t?S(t)[0]:this[0],i=t?this:S(e).parent().children();return m.call(i,e)},I.closest=function(t){var e=this.filter(t);if(e.length)return e;var i=this.parent();return i.length?i.closest(t):e},I.siblings=function(t){return Z(S(it(tt(this,(function(t){return S(t).parent().children().not(t)})))),t)},I.find=function(t){return S(it(tt(this,(function(e){return T(t,e)}))))};var nt=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ot=/^$|^module$|\/(java|ecma)script/i,at=["type","src","nonce","noModule"];function st(t,e,i,a,s,r,l,c){return D(t,(function(t,r){D(S(r),(function(t,r){D(S(e),(function(e,l){var c=i?l:r,u=i?t:e;!function(t,e,i,a,s){a?t.insertBefore(e,i?t.firstChild:null):"HTML"===t.nodeName?t.parentNode.replaceChild(e,t):t.parentNode.insertBefore(e,i?t:t.nextSibling),s&&function(t,e){var i=S(t);i.filter("script").add(i.find("script")).each((function(t,i){if(ot.test(i.type)&&n.contains(i)){var a=o("script");a.text=i.textContent.replace(nt,""),D(at,(function(t,e){i[e]&&(a[e]=i[e])})),e.head.insertBefore(a,null),e.head.removeChild(a)}}))}(e,t.ownerDocument)}(i?r:l,u?c.cloneNode(!0):c,a,s,!u)}),c)}),l)}),r),e}I.after=function(){return st(arguments,this,!1,!1,!1,!0,!0)},I.append=function(){return st(arguments,this,!1,!1,!0)},I.html=function(t){if(!arguments.length)return this[0]&&this[0].innerHTML;if(k(t))return this;var e=/<script[\s>]/.test(t);return this.each((function(i,n){F(n)&&(e?S(n).empty().append(t):n.innerHTML=t)}))},I.appendTo=function(t){return st(arguments,this,!0,!1,!0)},I.wrapInner=function(t){return this.each((function(e,i){var n=S(i),o=n.contents();o.length?o.wrapAll(t):n.append(t)}))},I.before=function(){return st(arguments,this,!1,!0)},I.wrapAll=function(t){for(var e=S(t),i=e[0];i.children.length;)i=i.firstElementChild;return this.first().before(e),this.appendTo(i)},I.wrap=function(t){return this.each((function(e,i){var n=S(t)[0];S(i).wrapAll(e?n.cloneNode(!0):n)}))},I.insertAfter=function(t){return st(arguments,this,!0,!1,!1,!1,!1,!0)},I.insertBefore=function(t){return st(arguments,this,!0,!0)},I.prepend=function(){return st(arguments,this,!1,!0,!0,!0,!0)},I.prependTo=function(t){return st(arguments,this,!0,!0,!0,!1,!1,!0)},I.contents=function(){return S(it(tt(this,(function(t){return"IFRAME"===t.tagName?[t.contentDocument]:"TEMPLATE"===t.tagName?t.content.childNodes:t.childNodes}))))},I.next=function(t,e,i){return Z(S(it(tt(this,"nextElementSibling",e,i))),t)},I.nextAll=function(t){return this.next(t,!0)},I.nextUntil=function(t,e){return this.next(e,!0,t)},I.parents=function(t,e){return Z(S(it(tt(this,"parentElement",!0,e))),t)},I.parentsUntil=function(t,e){return this.parents(e,t)},I.prev=function(t,e,i){return Z(S(it(tt(this,"previousElementSibling",e,i))),t)},I.prevAll=function(t){return this.prev(t,!0)},I.prevUntil=function(t,e){return this.prev(e,!0,t)},I.map=function(t){return S(d.apply([],h.call(this,(function(e,i){return t.call(e,i,e)}))))},I.clone=function(){return this.map((function(t,e){return e.cloneNode(!0)}))},I.offsetParent=function(){return this.map((function(t,e){for(var i=e.offsetParent;i&&"static"===U(i,"position");)i=i.offsetParent;return i||n}))},I.slice=function(t,e){return S(v.call(this,t,e))};var rt=/-([a-z])/g;function lt(t){return t.replace(rt,(function(t,e){return e.toUpperCase()}))}I.ready=function(t){var i=function(){return setTimeout(t,0,S)};return"loading"!==e.readyState?i():e.addEventListener("DOMContentLoaded",i),this},I.unwrap=function(){return this.parent().each((function(t,e){if("BODY"!==e.tagName){var i=S(e);i.replaceWith(i.children())}})),this},I.offset=function(){var t=this[0];if(t){var e=t.getBoundingClientRect();return{top:e.top+i.pageYOffset,left:e.left+i.pageXOffset}}},I.position=function(){var t=this[0];if(t){var e="fixed"===U(t,"position"),i=e?t.getBoundingClientRect():this.offset();if(!e){for(var n=t.ownerDocument,o=t.offsetParent||n.documentElement;(o===n.body||o===n.documentElement)&&"static"===U(o,"position");)o=o.parentNode;if(o!==t&&F(o)){var a=S(o).offset();i.top-=a.top+$(o,"borderTopWidth"),i.left-=a.left+$(o,"borderLeftWidth")}}return{top:i.top-$(t,"marginTop"),left:i.left-$(t,"marginLeft")}}};var ct={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};I.prop=function(t,e){if(t){if(P(t))return t=ct[t]||t,arguments.length<2?this[0]&&this[0][t]:this.each((function(i,n){n[t]=e}));for(var i in t)this.prop(i,t[i]);return this}},I.removeProp=function(t){return this.each((function(e,i){delete i[ct[t]||t]}))};var ut=/^--/;function dt(t){return ut.test(t)}var pt={},mt=a.style,ht=["webkit","moz","ms"];function ft(t,e){if(void 0===e&&(e=dt(t)),e)return t;if(!pt[t]){var i=lt(t),n="".concat(i[0].toUpperCase()).concat(i.slice(1));D("".concat(i," ").concat(ht.join("".concat(n," "))).concat(n).split(" "),(function(e,i){if(i in mt)return pt[t]=i,!1}))}return pt[t]}var vt={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 gt(t,e,i){return void 0===i&&(i=dt(t)),i||vt[t]||!L(e)?e:"".concat(e,"px")}function yt(t,e){try{return t(e)}catch(t){return e}}I.css=function(t,e){if(P(t)){var i=dt(t);return t=ft(t,i),arguments.length<2?this[0]&&U(this[0],t,i):t?(e=gt(t,e,i),this.each((function(n,o){F(o)&&(i?o.style.setProperty(t,e):o.style[t]=e)}))):this}for(var n in t)this.css(n,t[n]);return this};var bt=/^\s+|\s+$/;function wt(t,e){var i=t.dataset[e]||t.dataset[lt(e)];return bt.test(i)?i:yt(JSON.parse,i)}function Ct(t,e,i){i=yt(JSON.stringify,i),t.dataset[lt(e)]=i}function At(t,e){var i=t.documentElement;return Math.max(t.body["scroll".concat(e)],i["scroll".concat(e)],t.body["offset".concat(e)],i["offset".concat(e)],i["client".concat(e)])}I.data=function(t,e){if(!t){if(!this[0])return;var i={};for(var n in this[0].dataset)i[n]=wt(this[0],n);return i}if(P(t))return arguments.length<2?this[0]&&wt(this[0],t):k(e)?this:this.each((function(i,n){Ct(n,t,e)}));for(var n in t)this.data(n,t[n]);return this},D([!0,!1],(function(t,e){D(["Width","Height"],(function(t,i){var n="".concat(e?"outer":"inner").concat(i);I[n]=function(n){if(this[0])return N(this[0])?e?this[0]["inner".concat(i)]:this[0].document.documentElement["client".concat(i)]:_(this[0])?At(this[0],i):this[0]["".concat(e?"offset":"client").concat(i)]+(n&&e?$(this[0],"margin".concat(t?"Top":"Left"))+$(this[0],"margin".concat(t?"Bottom":"Right")):0)}}))})),D(["Width","Height"],(function(t,e){var i=e.toLowerCase();I[i]=function(n){if(!this[0])return k(n)?void 0:this;if(!arguments.length)return N(this[0])?this[0].document.documentElement["client".concat(e)]:_(this[0])?At(this[0],e):this[0].getBoundingClientRect()[i]-q(this[0],!t);var o=parseInt(n,10);return this.each((function(e,n){if(F(n)){var a=U(n,"boxSizing");n.style[i]=gt(i,o+("border-box"===a?q(n,!t):0))}}))}})),I.toggle=function(t){return this.each((function(i,n){if(F(n)){var a=W(n);(k(t)?a:t)?(n.style.display=n.___cd||"",W(n)&&(n.style.display=function(t){if(Y[t])return Y[t];var i=o(t);e.body.insertBefore(i,null);var n=U(i,"display");return e.body.removeChild(i),Y[t]="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 Tt={focus:"focusin",blur:"focusout"},xt={mouseenter:"mouseover",mouseleave:"mouseout"},It=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function St(t){return xt[t]||Tt[t]||t}function Et(t){var e=t.split(".");return[e[0],e.slice(1).sort()]}function Nt(t){return t.___ce=t.___ce||{}}function _t(t,e){return!e||!g.call(e,(function(e){return t.indexOf(e)<0}))}function Ft(t,e,i,n,o){var a=Nt(t);if(e)a[e]&&(a[e]=a[e].filter((function(a){var s=a[0],r=a[1],l=a[2];if(o&&l.guid!==o.guid||!_t(s,i)||n&&n!==r)return!0;t.removeEventListener(e,l)})));else for(e in a)Ft(t,e,i,n,o)}I.trigger=function(t,i){if(P(t)){var n=Et(t),o=n[0],a=n[1],s=St(o);if(!s)return this;var r=It.test(s)?"MouseEvents":"HTMLEvents";(t=e.createEvent(r)).initEvent(s,!0,!0),t.namespace=a.join("."),t.___ot=o}t.___td=i;var l=t.___ot in Tt;return this.each((function(e,i){l&&O(i[t.___ot])&&(i["___i".concat(t.type)]=!0,i[t.___ot](),i["___i".concat(t.type)]=!1),i.dispatchEvent(t)}))},I.off=function(t,e,i){var n=this;if(k(t))this.each((function(t,e){(F(e)||_(e)||N(e))&&Ft(e)}));else if(P(t))O(e)&&(i=e,e=""),D(R(t),(function(t,o){var a=Et(o),s=a[0],r=a[1],l=St(s);n.each((function(t,n){(F(n)||_(n)||N(n))&&Ft(n,l,r,e,i)}))}));else for(var o in t)this.off(o,t[o]);return this},I.remove=function(t){return Z(this,t).detach().off(),this},I.replaceWith=function(t){return this.before(t).remove()},I.replaceAll=function(t){return S(t).replaceWith(this),this},I.on=function(t,e,i,n,o){var a=this;if(!P(t)){for(var s in t)this.on(s,e,i,t[s],o);return this}return P(e)||(k(e)||V(e)?e="":k(i)?(i=e,e=""):(n=i,i=e,e="")),O(n)||(n=i,i=void 0),n?(D(R(t),(function(t,s){var r=Et(s),l=r[0],c=r[1],u=St(l),d=l in xt,p=l in Tt;u&&a.each((function(t,a){if(F(a)||_(a)||N(a)){var s=function(t){if(t.target["___i".concat(t.type)])return t.stopImmediatePropagation();if((!t.namespace||_t(c,t.namespace.split(".")))&&(e||!(p&&(t.target!==a||t.___ot===u)||d&&t.relatedTarget&&a.contains(t.relatedTarget)))){var r=a;if(e){for(var l=t.target;!G(l,e);){if(l===a)return;if(!(l=l.parentNode))return}r=l}Object.defineProperty(t,"currentTarget",{configurable:!0,get:function(){return r}}),Object.defineProperty(t,"delegateTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(t,"data",{configurable:!0,get:function(){return i}});var m=n.call(r,t,t.___td);o&&Ft(a,u,c,e,s),!1===m&&(t.preventDefault(),t.stopPropagation())}};s.guid=n.guid=n.guid||S.guid++,function(t,e,i,n,o){var a=Nt(t);a[e]=a[e]||[],a[e].push([i,n,o]),t.addEventListener(e,o)}(a,u,c,e,s)}}))})),this):this},I.one=function(t,e,i,n){return this.on(t,e,i,n,!0)};var Bt=/\r?\n/g,Ot=/file|reset|submit|button|image/i,Pt=/radio|checkbox/i;I.serialize=function(){var t="";return this.each((function(e,i){D(i.elements||[i],(function(e,i){if(!(i.disabled||!i.name||"FIELDSET"===i.tagName||Ot.test(i.type)||Pt.test(i.type)&&!i.checked)){var n=et(i);k(n)||D(c(n)?n:[n],(function(e,n){t+=function(t,e){return"&".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(e.replace(Bt,"\r\n")))}(i.name,n)}))}}))})),t.slice(1)},t.exports=S}()},631:(t,e,i)=>{"use strict";i.d(e,{Z:()=>r});var n=i(537),o=i.n(n),a=i(645),s=i.n(a)()(o());s.push([t.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: 800px;\n min-width: 550px;\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;IAChB,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: 800px;\n min-width: 550px;\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:(t,e,i)=>{"use strict";i.d(e,{Z:()=>r});var n=i(537),o=i.n(n),a=i(645),s=i.n(a)()(o());s.push([t.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:(t,e,i)=>{"use strict";i.d(e,{Z:()=>r});var n=i(537),o=i.n(n),a=i(645),s=i.n(a)()(o());s.push([t.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:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var i="",n=void 0!==e[5];return e[4]&&(i+="@supports (".concat(e[4],") {")),e[2]&&(i+="@media ".concat(e[2]," {")),n&&(i+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),i+=t(e),n&&(i+="}"),e[2]&&(i+="}"),e[4]&&(i+="}"),i})).join("")},e.i=function(t,i,n,o,a){"string"==typeof t&&(t=[[null,t,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<t.length;c++){var u=[].concat(t[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)),e.push(u))}},e}},537:t=>{"use strict";t.exports=function(t){var e=t[1],i=t[3];if(!i)return e;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[e].concat([a]).join("\n")}return[e].join("\n")}},379:t=>{"use strict";var e=[];function i(t){for(var i=-1,n=0;n<e.length;n++)if(e[n].identifier===t){i=n;break}return i}function n(t,n){for(var a={},s=[],r=0;r<t.length;r++){var l=t[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)e[p].references++,e[p].updater(m);else{var h=o(m,n);n.byIndex=r,e.splice(r,0,{identifier:d,updater:h,references:1})}s.push(d)}return s}function o(t,e){var i=e.domAPI(e);return i.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;i.update(t=e)}else i.remove()}}t.exports=function(t,o){var a=n(t=t||[],o=o||{});return function(t){t=t||[];for(var s=0;s<a.length;s++){var r=i(a[s]);e[r].references--}for(var l=n(t,o),c=0;c<a.length;c++){var u=i(a[c]);0===e[u].references&&(e[u].updater(),e.splice(u,1))}a=l}}},569:t=>{"use strict";var e={};t.exports=function(t,i){var n=function(t){if(void 0===e[t]){var i=document.querySelector(t);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(t){i=null}e[t]=i}return e[t]}(t);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:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},565:(t,e,i)=>{"use strict";t.exports=function(t){var e=i.nc;e&&t.setAttribute("nonce",e)}},795:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(i){!function(t,e,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))))," */")),e.styleTagTransform(n,t,e.options)}(e,t,i)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},589:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}}},e={};function i(n){var o=e[n];if(void 0!==o)return o.exports;var a=e[n]={id:n,exports:{}};return t[n](a,a.exports,i),a.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.nc=void 0;var n={};(()=>{"use strict";i.r(n),i.d(n,{_package:()=>Bt,demoFileIngest:()=>kt,demoFileIngest1:()=>Vt,demoFileIngest2:()=>Lt,demoFileSubmit:()=>jt,gasteigerCellRenderer:()=>Dt,hitDesignApp:()=>Pt,hitTriageApp:()=>Ot});const t=grok,e=DG,o=ui,a="campaignId",s="campaignId",r="HitTriageDataSource",l="HitTriageSubmitFunction",c="Selected hits",u="Stage",d="Molecule",p="V-iD",m="V######",h="HTScript",f="HTQuery",v="molecules",g="Source",y="New template",b="Start",w="Create",C="Download",A="Cancel",T="Continue a campaign",x="New campaign";var I=i(379),S=i.n(I),E=i(795),N=i.n(E),_=i(569),F=i.n(_),B=i(565),O=i.n(B),P=i(216),k=i.n(P),V=i(589),L=i.n(V),j=i(631),D={};D.styleTagTransform=L(),D.setAttributes=O(),D.insert=F().bind(null,"head"),D.domAPI=N(),D.insertStyleElement=k(),S()(j.Z,D),j.Z&&j.Z.locals&&j.Z.locals;var H=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};const M=t=>`${t.getFullYear()}/${t.getMonth()+1}/${t.getDate()}`;function R(t,e){const i=document.title,n=window.location.href.split("?")[0]+"?"+t+"="+e;if(history.replaceState){const t={Title:i,Url:n};history.replaceState(t,t.Title,t.Url)}}function U(e,i,n,a){var s;const r=o.breadcrumbs([i,n]),l=r.onPathClick.subscribe((t=>{1===t.length&&(l.unsubscribe(),$(e),a())})),c=null===(s=t.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 $(t){const e=t.getRibbonPanels();(null==e?void 0:e.length)&&(e.pop(),t.setRibbonPanels(e))}function q(t){return t.reduce(((t,e)=>t||e.reduce(((t,e)=>t||e.classList.contains("hit-design-submit-button")||Array.from(e.children).some((t=>t.classList.contains("hit-design-submit-button")))),!1)),!1)}function Y(t,i,n){return H(this,void 0,void 0,(function*(){if(0===n.rowCount)return;if(!t.col(i))throw new Error("There is no molecule column in dataframe");let o=n.col(v);if(o||(yield n.meta.detectSemanticTypes(),o=n.columns.bySemType(e.SEMTYPE.MOLECULE)),!o)throw new Error("There is no original molecule column in query result dataframe");const a=n.columns.names().filter((t=>t!==v));t.join(n,[i],[o.name],void 0,a,void 0,!0)}))}function W(t,e){return H(this,void 0,void 0,(function*(){const i=(yield Bt.files.list(`${t}/campaigns`)).filter((t=>-1===e.indexOf(t.name))),n={};for(const e of i)try{const i=JSON.parse(yield Bt.files.readAsText(`${t}/campaigns/${e.name}/campaign.json`));n[i.name]=i}catch(t){continue}return n}))}const G={String:e.TYPE.STRING,Number:e.TYPE.FLOAT,Boolean:e.TYPE.BOOL,Date:e.TYPE.DATE_TIME,Molecule:e.SEMTYPE.MOLECULE};var J=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))},Z=i(553),z=i.n(Z);function Q(i,n,a,s,r){var l,c,u,d,p,m,v,g,y,b,w,C,A,T,x,I,S,E,N,_,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:t})=>t.length>2&&"dataframe"===t[0].propertyType&&"column"===t[1].propertyType)).map((t=>{var e,i,n,o;return{package:t.package.name,name:t.name,args:null!==(o=null===(n=null===(i=null===(e=null==s?void 0:s.compute)||void 0===e?void 0:e.functions)||void 0===i?void 0:i.find((e=>e.name===t.name&&e.package===t.package.name)))||void 0===n?void 0:n.args)&&void 0!==o?o:{}}})),H=j.scripts.filter((({inputs:t})=>t.length>=2&&"dataframe"===t[0].propertyType&&"column"===t[1].propertyType)).map((t=>{var e,i,n,o;return{name:t.name,id:t.id,args:null!==(o=null===(n=null===(i=null===(e=null==s?void 0:s.compute)||void 0===e?void 0:e.scripts)||void 0===i?void 0:i.find((e=>e.id===t.id)))||void 0===n?void 0:n.args)&&void 0!==o?o:{}}})),M=j.queries.filter((t=>t.inputs.length>0&&"list"===t.inputs[0].propertyType)).map((t=>{var e,i,n,o,a;return{name:null!==(e=t.friendlyName)&&void 0!==e?e:t.name,id:t.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((e=>e.id===t.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 t.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(t,e){const i=e.group(t,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 t of G){const e=W(t,$);for(const i of U[t].descriptors){const t=e.item(i.name,i);Y.push(t),t.enableCheckBox(J.includes(i.name))}}const Z="Descriptors",Q={[Z]:Z},K=R?{[Z]:$.root}:{},X={},tt={[Z]:!1};tt.Descriptors=!!(null===(v=null===(m=null==s?void 0:s.compute)||void 0===m?void 0:m.descriptors)||void 0===v?void 0:v.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 t of D)try{const i=e.Func.find({package:t.package,name:t.name})[0],n=i.prepare(t.args),a=`${t.package}:${t.name}`;X[a]=n;const r=o.div(),l=yield n.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",r.style.removeProperty("max-width"),K[null!==(w=i.friendlyName)&&void 0!==w?w:i.name]=r,Q[null!==(C=i.friendlyName)&&void 0!==C?C:i.name]=a,tt[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((e=>e.name===t.name&&e.package===t.package)))&&void 0!==x&&x,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(t){console.error(t);continue}for(const e of H)try{const i=yield t.dapi.scripts.find(e.id),n=i.prepare(e.args),a=`HTScript:${null!==(I=e.name)&&void 0!==I?I:""}:${e.id}`;X[a]=n;const r=o.div(),l=yield n.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",r.style.removeProperty("max-width"),K[null!==(S=i.friendlyName)&&void 0!==S?S:i.name]=r,Q[null!==(E=i.friendlyName)&&void 0!==E?E:i.name]=a,tt[a]=null!==(F=null===(_=null===(N=null==s?void 0:s.compute)||void 0===N?void 0:N.scripts)||void 0===_?void 0:_.some((t=>t.id===e.id)))&&void 0!==F&&F,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(t){console.error(t);continue}for(const e of M)try{const i=yield t.dapi.queries.find(e.id),n=i.prepare(e.args),a=`HTQuery:${null!==(B=e.name)&&void 0!==B?B:""}:${e.id}`;X[a]=n;const r=o.div(),l=yield n.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",r.style.removeProperty("max-width"),K[null!==(O=i.friendlyName)&&void 0!==O?O:i.name]=r,Q[null!==(P=i.friendlyName)&&void 0!==P?P:i.name]=a,tt[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((t=>t.id===e.id)))&&void 0!==L&&L,r.children[0].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(t){console.error(t);continue}const et=o.tabControl(K,!0);function it(){const t={descriptors:[],externals:{},scripts:{},queries:{}};t.descriptors=tt.Descriptors?Y.filter((t=>t.checked)).map((t=>t.value.name)):[];const e=Object.entries(X).filter((([t,e])=>tt[t]));e.filter((([t,e])=>!t.startsWith(h)&&!t.startsWith(f))).forEach((([e,i])=>{t.externals[e]={};const n=i.inputs;Object.entries(n).slice(2).forEach((([i,n])=>{t.externals[e][i]=n}))})),e.filter((([t,e])=>t.startsWith(h))).forEach((([e,i])=>{t.scripts[e]={};const n=i.inputs;Object.entries(n).slice(2).forEach((([i,n])=>{t.scripts[e][i]=n}))})),e.filter((([t,e])=>t.startsWith(f))).forEach((([e,i])=>{t.queries[e]={};const n=i.inputs;Object.entries(n).slice(1).forEach((([i,n])=>{t.queries[e][i]=n}))})),console.log(t),n(t)}return et.onTabChanged.subscribe((()=>{try{et.currentPane.content.style.removeProperty("max-width")}catch(t){}})),et.header.style.overflow="scroll",et.root.style.width="100%",et.root.style.minWidth="350px",q.appendChild(et.root),et.panes.forEach((t=>{const e=o.boolInput("",tt[Q[t.name]],(i=>{tt[Q[t.name]]=!!e.value,i?z()(t.content).find("input").removeAttr("disabled"):z()(t.content).find("input").attr("disabled","true")}));e.setTooltip("Toggle calculation of this function"),t.header.appendChild(e.root),t.header.classList.add("hit-triage-compute-dialog-pane-header")})),r&&o.dialog("Compute").add(q).onOK((()=>it())).onCancel(a).show(),{root:q,okProxy:it}},new((H=void 0)||(H=Promise))((function(t,e){function i(t){try{o(M.next(t))}catch(t){e(t)}}function n(t){try{o(M.throw(t))}catch(t){e(t)}}function o(e){var o;e.done?t(e.value):(o=e.value,o instanceof H?o:new H((function(t){t(o)}))).then(i,n)}o((M=M.apply(j,D||[])).next())}))}const K=rxjs;class X{constructor(t,e=[],i={}){this.onItemChanged=new K.Subject,this.onAddingItemChanged=new K.Subject,this.onItemAdded=new K.Subject,this.onItemRemoved=new K.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.properties=t,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=e,this.render()}get root(){return this._root}get items(){return this._items}render(){var t,e,i,n;if(o.empty(this._root),!this.options.horizontalInputNames)for(const e of this.properties){const i=o.divText(null!==(t=e.caption)&&void 0!==t?t:e.name);i.style.fontWeight="bold",this._root.appendChild(i)}for(const t of this._items){const e=this.getItemDiv(t);for(const t of e)this._root.appendChild(t)}if(this.options.allowAdd){const t=this.getItemDiv(null!==(n=null===(i=(e=this.options).newItemFunction)||void 0===i?void 0:i.call(e))&&void 0!==n?n:void 0,!0);for(const e of t)this._root.appendChild(e)}}getItemDiv(t={},i){var n;const a=[],s={};let r=null;for(const l of this.properties){void 0===t[l.name]&&(t[l.name]=null);const c=(null===(n=this.options.customInputs)||void 0===n?void 0:n[l.name])?this.options.customInputs[l.name](t):o.input.forProperty(l,t);a.push(this.options.horizontalInputNames?c.root:this.hideLabel(c.root)),l.propertyType!==e.TYPE.BOOL&&"color"!==l.name.toLowerCase()&&c.input&&(c.input.style.width="100%"),s[l.name]=c,c.onChanged((()=>{t[l.name]=c.value,i?this.onAddingItemChanged.next({item:t,fieldName:l.name}):this.onItemChanged.next({item:t,fieldName:l.name})})),c.root.style.alignItems="center",r=c}let l=null;if(i)l=o.icons.add((()=>{const t=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(s).forEach((e=>{t[e]=s[e].value})),this._items.push(t),this.onItemAdded.next(t),this.render()}),this.options.addButtonTooltip);else{if(!this.options.allowRemove)return a;l=o.icons.delete((()=>{this._items.splice(this._items.indexOf(t),1),this.onItemRemoved.next(t),this.render()}),this.options.removeButtonTooltip)}return r&&r.addOptions?r.addOptions(l):null==r||r.root.appendChild(l),l.style.color="#2083d5",a}hideLabel(t){return t.getElementsByTagName("label")[0]&&t.removeChild(t.getElementsByTagName("label")[0]),t}}var tt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};function et(i,n){var a,s;return tt(this,void 0,void 0,(function*(){const c=(yield Bt.files.list("Hit Triage/templates")).map((t=>t.name.slice(0,-5))),u=[];for(const t of c){const e=JSON.parse(yield Bt.files.readAsText(`Hit Triage/templates/${t}.json`));u.push(e.key)}const d=e.Func.find({tags:[l]}),p={};d.forEach((t=>{var e;p[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t}));const m=o.choiceInput("Submit function",null,[null,...Object.keys(p)]);m.value=null,m.nullable=!0,m.fireChanged(),m.setTooltip("Select function to be called upon submitting");const v=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),y=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),b=o.stringInput("Name","",(()=>{""===b.value||c.includes(b.value)?(b.root.style.borderBottom="1px solid red",v.style.opacity="100%"):(b.root.style.borderBottom="none",v.style.opacity="0%")})),C=o.stringInput("Key","",(()=>{""===C.value||u.includes(C.value)?(C.root.style.borderBottom="1px solid red",y.style.opacity="100%"):(C.root.style.borderBottom="none",y.style.opacity="0%")}));C.setTooltip("Template key used for campaign prefix"),b.setTooltip("Template name"),b.root.style.borderBottom="none",C.root.style.borderBottom="none",v.style.opacity="0%",y.style.opacity="0%";let T=null;const x=yield Q(i,(t=>{T=t}),(()=>null),{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},!1);if(x.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(n).length){const i=e.Func.find({tags:[r]}),o=yield t.dapi.queries.include("params,connection").filter("#HitTriageDataSource").list();i.forEach((t=>{var e;n[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t})),o.forEach((t=>{var e;n[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t}))}const I=Object.keys(n),S=o.choiceInput(g,I[0],I),E=o.choiceInput("Ingest using","Query",["Query","File"],(()=>{"Query"!==E.value?S.root.style.display="none":S.root.style.display="block"})),N=it(),_=o.div([o.h2("Details"),o.div([b,v]),o.div([C,y]),E.root,S.root,N.fieldsDiv,o.h2("Compute"),x.root,o.h2("Submit"),m.root],"ui-form"),F=o.buttonsInput([]),B=null!==(s=null===(a=F.getElementsByClassName("ui-input-editor"))||void 0===a?void 0:a[0])&&void 0!==s?s:F;_.appendChild(F);const O=new Promise((t=>{const e=o.button(A,(()=>t()));B.appendChild(e)})),P=new Promise((e=>{const i=o.bigButton(w,(()=>function(){var i,n,o,a,s,r,l;return tt(this,void 0,void 0,(function*(){if(x.okProxy(),"100%"===v.style.opacity)return void t.shell.error("Template name is empty or already exists");const c=m.value?p[m.value]:void 0,u=Object.assign(Object.assign({name:b.value,key:C.value,campaignFields:N.getFields(),dataSourceType:null!==(i=E.value)&&void 0!==i?i:"Query",compute:{descriptors:{enabled:!!(null===(n=null==T?void 0:T.descriptors)||void 0===n?void 0:n.length),args:null!==(o=null==T?void 0:T.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(a=null==T?void 0:T.externals)&&void 0!==a?a:{}).map((([t,e])=>{const i=t.split(":");return{name:i[1],package:i[0],args:e}})),scripts:Object.entries(null!==(s=null==T?void 0:T.scripts)&&void 0!==s?s:{}).filter((([t,e])=>t.startsWith(h)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}})),queries:Object.entries(null!==(r=null==T?void 0:T.queries)&&void 0!==r?r:{}).filter((([t,e])=>t.startsWith(f)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}}))}},c?{submit:{fName:c.name,package:c.package.name}}:{}),{queryFunctionName:"Query"===E.value&&null!==(l=S.value)&&void 0!==l?l:void 0});var d;d=u,Bt.files.writeAsText(`Hit Triage/templates/${d.name}.json`,JSON.stringify(d)),t.shell.info("Template created successfully"),e(u)}))}()));B.appendChild(i)}));return{root:_,template:P,cancelPromise:O}}))}function it(t){const i=[e.Property.fromOptions({name:"Name",type:e.TYPE.STRING}),e.Property.fromOptions({name:"Type",type:e.TYPE.STRING,choices:Object.keys(G)}),e.Property.fromOptions({name:"Required",type:e.TYPE.BOOL})],n=new X(i,t?t.map((t=>({Name:t.name,Type:t.type,Required:t.required}))):void 0,{horizontalInputNames:!1});n.root.style.maxWidth="750px";let a={};n.onItemAdded.subscribe((t=>{a={}})),n.onAddingItemChanged.subscribe((t=>{t&&(a=t.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 t;const e=n.items.filter((t=>t.Name)).map((t=>{var e;return{name:t.Name,type:t.Type,required:null!==(e=t.Required)&&void 0!==e&&e}}));return a.Name&&""!==a.Name&&a.Type&&(null!==(t=a.Required)&&void 0!==t||(a.Required=!1),e.push({name:a.Name,type:a.Type,required:a.Required})),e},fieldsDiv:o.div([r])}}var nt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class ot extends e.ViewBase{constructor(t){super(),this.deletedCampaigns=[],this.app=t}get template(){return this.app.template}onActivated(){}onReset(){}process(){return nt(this,void 0,void 0,(function*(){}))}deleteCampaign(t,e){return nt(this,void 0,void 0,(function*(){yield Bt.files.delete(`${t}/campaigns/${e}`)}))}}var at=i(290),st={};st.styleTagTransform=L(),st.setAttributes=O(),st.insert=F().bind(null,"head"),st.domAPI=N(),st.insertStyleElement=k(),S()(at.Z,st),at.Z&&at.Z.locals&&at.Z.locals;var rt;!function(e){let i,n;!function(t){t.vert=function(t){return o.divV(t.map((t=>o.render(t))),{classes:"u2-panel"})},t.horz=function(t){return o.divH(t.map((t=>o.render(t))),{classes:"u2-panel"})}}(i=e.panels||(e.panels={})),e.appHeader=function(t){const e=o.iconImage("",t.iconPath);return z()(e).addClass("ui-app-header-icon").css("margin-right","20px"),i.horz([e,i.vert([o.markdown(t.description),t.learnMoreUrl?o.link("Learn more",t.learnMoreUrl):null])])},function(e){e.runAsync=function(e,i){return n=this,a=void 0,r=function*(){o.setUpdateIndicator(e,!0);try{return yield i()}catch(e){t.log.error(e)}finally{o.setUpdateIndicator(e,!1)}},new((s=void 0)||(s=Promise))((function(t,e){function i(t){try{l(r.next(t))}catch(t){e(t)}}function o(t){try{l(r.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof s?n:new s((function(t){t(n)}))).then(i,o)}l((r=r.apply(n,a||[])).next())}));var n,a,s,r}}(n=e.tools||(e.tools={}))}(rt||(rt={}));var lt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class ct extends ot{constructor(e){super(e),this.readmePath=Bt.webRoot+"README_HT.md",this.dataSourceFunctionsMap={},this.name="Hit Triage",t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(this.readmePath),this.checkCampaign().then((t=>{this.app.campaign=t,this.init()}))}onActivated(){t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(this.readmePath)}init(t){return lt(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const e=o.h1(T),i=o.h1(x,{style:{marginLeft:"10px"}}),n=rt.appHeader({iconPath:Bt.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,t),z()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,e],{style:{marginLeft:"10px"}}),r,i,s,a])),this.app.resetBaseUrl()}catch(t){throw o.setUpdateIndicator(this.root,!1),t}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(t,e,i){var n;return lt(this,void 0,void 0,(function*(){const a=(yield Bt.files.list("Hit Triage/templates")).map((t=>t.name.slice(0,-5)));i&&!a.includes(i.name)&&a.push(i.name);const s=()=>lt(this,void 0,void 0,(function*(){const e=r.value,n=i&&i.name===e?i:JSON.parse(yield Bt.files.readAsText("Hit Triage/templates/"+e+".json")),o=yield this.getNewCampaignAccordeon(n,t);z()(t).empty(),t.className="ui-form",t.appendChild(o)})),r=o.choiceInput("Template",null!==(n=null==i?void 0:i.name)&&void 0!==n?n:a[0],a,(()=>lt(this,void 0,void 0,(function*(){yield s()})))),l=o.icons.add((()=>lt(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),o.setUpdateIndicator(this.root,!1)}))),y);r.addOptions(l),yield s(),z()(e).empty(),e.appendChild(r.root)}))}checkCampaign(t){return lt(this,void 0,void 0,(function*(){const e=location.search,i=new URLSearchParams(e);if(!i.has(a)&&!t)return;const n=null!=t?t:i.get(a);if(!(yield Bt.files.exists(`Hit Triage/campaigns/${n}/campaign.json`)))return;const o=JSON.parse(yield Bt.files.readAsText(`Hit Triage/campaigns/${n}/campaign.json`)),s=JSON.parse(yield Bt.files.readAsText(`Hit Triage/templates/${o.templateName}.json`));return this.app.setTemplate(s,o.filters,n,o.ingest),t&&R(a,t),o}))}getCampaignsTable(){return lt(this,void 0,void 0,(function*(){const t=yield W("Hit Triage",this.deletedCampaigns),e=Object.values(t).map((t=>({name:t.name,createDate:t.createDate,rowCount:t.rowCount,filtered:t.filteredRowCount,status:t.status}))),i=o.table(e,(t=>[o.link(t.name,(()=>this.setCampaign(t.name)),"",""),t.createDate,t.rowCount,t.filtered,t.status,o.icons.delete((()=>lt(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${t.name}?`)).onOK((()=>lt(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Triage",t.name),this.deletedCampaigns.push(t.name),yield this.init()})))).show()}))),"Delete campaign")]),["Name","Created","Total","Selected","Status",""]);return i.style.color="var(--grey-5)",i}))}setCampaign(t){return lt(this,void 0,void 0,(function*(){const e=yield this.checkCampaign(t);this.app.campaign=e}))}getNewCampaignAccordeon(i,n){return lt(this,void 0,void 0,(function*(){o.setUpdateIndicator(n,!0);const{root:a,promise:s,cancelPromise:l}=yield function(i,n){var a,s;return J(this,void 0,void 0,(function*(){const l=o.divText("",{style:{color:"red"}});let c=null;const u=()=>J(this,void 0,void 0,(function*(){try{if(c=d.value,!c)return;if(yield c.meta.detectSemanticTypes(),!c.columns.bySemType(e.SEMTYPE.MOLECULE))return void(l.innerText="No molecules column found");l.innerText=""}catch(t){l.innerText="Error parsing file"}})),d=o.tableInput("Dataframe",null,void 0,u);yield u();const p=o.div([d,l]);0===Object.keys(n).length&&(e.Func.find({tags:[r]}).forEach((t=>{var e;n[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t})),(yield t.dapi.queries.include("params,connection").filter("#HitTriageDataSource").list()).forEach((t=>{var e;n[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t})));let m=null;const h=()=>J(this,void 0,void 0,(function*(){const t=n[v.value];m=t.prepare();const e=yield m.getEditor();e.classList.remove("ui-form"),f.innerHTML="",f.appendChild(e)})),f=o.div([]),v=o.choiceInput(g,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 y=o.div([v,f]);y.style.display="none";const w=o.div([p,y]),C=i.campaignFields.map((t=>t.type===e.SEMTYPE.MOLECULE?Object.assign(Object.assign({},t),{type:"String",semtype:e.SEMTYPE.MOLECULE}):t)).map((t=>e.Property.fromOptions(Object.assign({name:t.name,type:G[t.type],nullable:!t.required},t.semtype?{semType:t.semtype}:{})))),T={},x=C.length?o.input.form(T,C):o.div();x.classList.remove("ui-form"),"File"===i.dataSourceType?(p.style.display="inherit",y.style.display="none"):(p.style.display="none",y.style.display="inherit");const I=o.div([w,...C.length?[x]:[]]),S=o.buttonsInput([]);return I.appendChild(S),{promise:new Promise((e=>{const a=()=>J(this,void 0,void 0,(function*(){if("File"===i.dataSourceType){if(!c)return void t.shell.error("No file selected");const i=c;i.name=c.name,e({df:i,type:"File",campaignProps:T})}else{const i=n[v.value];if(!i)return void t.shell.error("No function selected");const o={};Object.entries(m.inputs).forEach((([t,e])=>{o[t]=e}));const a=yield i.apply(o);e({df:a,type:"Query",campaignProps:T})}})),s=o.bigButton(b,(()=>a()));S.appendChild(s)})),root:I,cancelPromise:new Promise((t=>{o.button(A,(()=>t()))}))}}))}(i,this.dataSourceFunctionsMap);return o.setUpdateIndicator(n,!1),s.then((t=>lt(this,void 0,void 0,(function*(){this.app.dataFrame=t.df,this.app._fileInputType=t.type,yield this.app.setTemplate(i),this.app.campaignProps=t.campaignProps,this.app.saveCampaign(void 0,!1)})))),l.then((()=>{this.init()})),a}))}createNewTemplate(){return lt(this,void 0,void 0,(function*(){const i=yield et(this.app,this.dataSourceFunctionsMap),n=new e.ViewBase,o=t.shell.v;n.name="New Template",n.root.appendChild(i.root),n.parentCall=this.app.parentCall,t.shell.addView(n),n.path=new URL(this.app.baseUrl).pathname+"/new-template",n.parentView=o;const{sub:a}=U(t.shell.v,"Hit Triage",y,(()=>{t.shell.v=o,n.close()}));i.template.then((e=>lt(this,void 0,void 0,(function*(){yield this.init(e),n.close(),$(n),t.shell.v=o,a.unsubscribe()})))),i.cancelPromise.then((()=>{a.unsubscribe(),n.close(),t.shell.v=o}))}))}}class ut extends ot{constructor(t){super(t),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=e.Func.find({name:n.fName,package:n.package})[0];if(!o)return void t.shell.error(`Function ${n.fName} not found.`);const a=e.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"),t.shell.info("Submitted successfully.")},new((a=void 0)||(a=Promise))((function(t,e){function i(t){try{l(s.next(t))}catch(t){e(t)}}function r(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof a?n:new a((function(t){t(n)}))).then(i,r)}l((s=s.apply(n,o||[])).next())}))}}var dt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class pt{constructor(i){this.parentCall=i,this.resetBaseUrl(),this.computeFunctions=new Promise((i=>dt(this,void 0,void 0,(function*(){const n=e.Func.find({tags:["HitTriageFunction"]}).filter((t=>"function-package"===t.type)),o=yield t.dapi.scripts.include("params").filter("#HitTriageFunction").list(),a=yield t.dapi.queries.include("params,connection").filter("#HitTriageFunction").list();i({functions:n,scripts:o,queries:a})}))))}resetBaseUrl(){const t=window.location.href,e=new URL(t);this.baseUrl=e.origin+e.pathname}getFilterType(t){const i=this.dataFrame.col(t);return(null==i?void 0:i.semType)===e.SEMTYPE.MOLECULE?e.FILTER_TYPE.SUBSTRUCTURE:(null==i?void 0:i.type)===e.COLUMN_TYPE.BOOL?e.FILTER_TYPE.BOOL_COLUMNS:(null==i?void 0:i.type)===e.COLUMN_TYPE.STRING?e.FILTER_TYPE.CATEGORICAL:e.FILTER_TYPE.HISTOGRAM}download(t,i,n=!1){const o=document.createElement("a"),a=e.DataFrame.fromColumns(t.columns.toList().filter((t=>!t.name.startsWith("~")))).toCsv({filteredRowsOnly:n});o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),o.setAttribute("download",i+".csv"),o.click()}getNewCampaignName(t,e){return dt(this,void 0,void 0,(function*(){const i=(yield Bt.files.list(t)).map((t=>t.name)).filter((t=>t.startsWith(e)));if(0===i.length)return e+"-1";const n=i.map((t=>t.split("-")[1])).filter(Boolean).map((t=>parseInt(t,10))).sort();return e+"-"+(n[n.length-1]+1).toString()}))}setBaseUrl(){const t=document.title;if(history.replaceState){const e={Title:t,Url:this.baseUrl};history.replaceState(e,e.Title,e.Url)}}}var mt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))},ht=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};function ft(t){let e=0;if(t.length>1)for(const i of t.toList()){if(!i||!i.startsWith(m[0])||i.length!==m.length)continue;const t=parseInt(i.substring(1));isNaN(t)||(e=Math.max(t,e))}return`V${"".concat(...new Array(m.length-1-(e+1).toString().length).fill("0"))}${e+1}`}function vt(i,n,o){var a,s;return ht(this,void 0,void 0,(function*(){const r=e.TaskBarProgressIndicator.create("Calculating ..."),l=n.col(o);if(!l)throw new Error("There is no molecule column in dataframe");for(let e=0;e<l.length;e++){if(l.isNone(e))continue;const i=l.get(e);if(!i)continue;const n=t.chem.convert(i,t.chem.Notation.Unknown,t.chem.Notation.Smiles);l.set(e,n,!1)}i.descriptors&&i.descriptors.length>0&&(yield t.chem.descriptors(n,o,i.descriptors));for(const t of Object.keys(i.externals))try{const a=i.externals[t],s=e.Func.find({package:t.split(":")[0],name:t.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})))}catch(t){console.error(t)}for(const e of Object.keys(null!==(a=i.scripts)&&void 0!==a?a:{})){const a=i.scripts[e];if(a){const i=e.split(":")[2];if(!i)continue;try{const e=yield t.dapi.scripts.find(i);if(!e)continue;const s=e.inputs[0].name,r=e.inputs[1].name,l=yield e.apply(Object.assign(Object.assign({},a),{[s]:n,[r]:o}));if(l&&l.rowCount===n.rowCount&&"python"===e.language)for(const t of l.columns)t.name=n.columns.getUnusedName(t.name),n.columns.add(t)}catch(t){console.error(t)}}}for(const e of Object.keys(null!==(s=i.queries)&&void 0!==s?s:{})){const a=i.queries[e];if(a){const i=e.split(":")[2];if(!i)continue;try{const e=yield t.dapi.queries.find(i);if(!e)continue;const s=e.inputs[0].name,r=n.col(o).toList(),l=yield e.apply(Object.assign(Object.assign({},a),{[s]:r}));l&&(yield Y(n,o,l))}catch(t){console.error(t)}}}r.close()}))}var gt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class yt extends pt{constructor(i){super(i),this._filterViewName="Hit triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=new ct(this),this.multiView=new e.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((t=>{this.multiView.currentView instanceof ot&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,t.events.onCurrentViewChanged.subscribe((()=>{var e,i,n,o;try{(null===(e=t.shell.v)||void 0===e?void 0:e.name)===this.currentPickViewId&&(t.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(t){console.error(t)}}))}get infoView(){return this._infoView}setTemplate(i,n,o,s){var r,l,c,u,d,p,m,h,f,v,g,y,b,w,C;return gt(this,void 0,void 0,(function*(){if((null===(r=this._pickView)||void 0===r?void 0:r.dataFrame)&&t.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 t.dapi.files.readCsv(s.query):this.dataFrame=yield t.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((([t,e])=>{const i=this.dataFrame.columns.byName(t);i&&i.semType!==e&&(i.semType=e)})),(null===(u=this._campaign)||void 0===u?void 0:u.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach((([t,e])=>{const i=this.dataFrame.columns.byName(t);if(i&&i.type!==e)try{i.convertTo(e)}catch(t){console.error(t)}})),yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(p=null===(d=this.dataFrame.columns.bySemType(e.SEMTYPE.MOLECULE))||void 0===d?void 0:d.name)&&void 0!==p?p:void 0,this._dfName=null!==(m=this.dataFrame.name)&&void 0!==m?m:null==s?void 0:s.query,this.dataFrame.name=null!==(f=null!==(h=this._dfName)&&void 0!==h?h:this.dataFrame.name)&&void 0!==f?f:"Molecules",this._campaignId=o,this.template=(null===(v=this.campaign)||void 0===v?void 0:v.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:i.dataSourceType,queryFunctionName:i.queryFunctionName}):i,this._campaignFilters=n,!n){const t={},e={},n={};i.compute.functions.forEach((e=>{const i=`${e.package}:${e.name}`;t[i]=e.args})),null===(g=i.compute.scripts)||void 0===g||g.forEach((t=>{const i=`HTScript:${t.name}:${t.id}`;e[i]=t.args})),null===(y=i.compute.queries)||void 0===y||y.forEach((t=>{const e=`HTQuery:${t.name}:${t.id}`;n[e]=t.args})),yield vt({descriptors:i.compute.descriptors.enabled?i.compute.descriptors.args:[],externals:t,scripts:e,queries:n},this.dataFrame,this._molColName)}const A=t.shell.v,T=t.shell.addView(this.pickView);this.currentPickViewId=T.name,this._submitView=new ut(this),this.setBaseUrl(),R(a,null!==(C=null!==(b=this._campaignId)&&void 0!==b?b:null===(w=this._campaign)||void 0===w?void 0:w.name)&&void 0!==C?C:"");const x=T;setTimeout((()=>{this._pickViewPromise&&this._pickViewPromise.then((()=>{const{sub:e}=U(x,"Hit Triage","Pick",(()=>{t.shell.v=A,x.close(),e.unsubscribe()}))}))}),300),t.shell.windows.showHelp=!1}))}get filterSettings(){return this._campaignFilters}get campaignId(){return this._campaignId}get pickView(){return this._pickView=this.getFilterView()}get molColName(){var t,i,n;return null!==(t=this._molColName)&&void 0!==t?t:this._molColName=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(e.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name}get fileInputType(){return this._fileInputType}get campaign(){return this._campaign}set campaign(t){this._campaign=t}getFilterView(){let t=null;this._pickViewPromise=new Promise((e=>{t=e})),this.dataFrame.col(c)||this.dataFrame.columns.addNewBool(c).init(!1);const i=e.TableView.create(this.dataFrame,!1),n=i.getRibbonPanels(),a=o.iconFA("wrench",(()=>gt(this,void 0,void 0,(function*(){Q(this,(t=>gt(this,void 0,void 0,(function*(){var e,i,n,o,a,s,r;const l=this.template.compute.descriptors.args,c=this.template.compute.functions,u=null!==(e=this.template.compute.scripts)&&void 0!==e?e:[],d=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],p=t.descriptors,m={descriptors:{enabled:!!(null===(n=null==t?void 0:t.descriptors)||void 0===n?void 0:n.length),args:null!==(o=null==t?void 0:t.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(a=null==t?void 0:t.externals)&&void 0!==a?a:{}).map((([t,e])=>{const i=t.split(":");return{name:i[1],package:i[0],args:e}})),scripts:Object.entries(null!==(s=null==t?void 0:t.scripts)&&void 0!==s?s:{}).filter((([t,e])=>t.startsWith(h)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}})),queries:Object.entries(null!==(r=null==t?void 0:t.queries)&&void 0!==r?r:{}).filter((([t,e])=>t.startsWith(f)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}}))};this.template.compute=m;const v=p.filter((t=>!l.includes(t))),g=m.functions.filter((t=>{if(!c.some((e=>e.name===t.name&&e.package===t.package)))return!0;const e=c.find((e=>e.name===t.name&&e.package===t.package));return!Object.entries(t.args).every((([t,i])=>e.args[t]===i))})),y=m.scripts.filter((t=>{if(!u.some((e=>e.id===t.id)))return!0;const e=u.find((e=>e.id===t.id));return!Object.entries(t.args).every((([t,i])=>e.args[t]===i))})),b=m.queries.filter((t=>{if(!d.some((e=>e.id===t.id)))return!0;const e=d.find((e=>e.id===t.id));return!Object.entries(t.args).every((([t,i])=>e.args[t]===i))})),w={};g.forEach((t=>{const e=`${t.package}:${t.name}`;w[e]=t.args}));const C={};y.forEach((t=>{const e=`HTScript:${t.name}:${t.id}`;C[e]=t.args}));const A={};b.forEach((t=>{const e=`HTQuery:${t.name}:${t.id}`;A[e]=t.args})),yield vt({descriptors:v,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 t;const e=null===(t=this._submitView)||void 0===t?void 0:t.render();if(e){const t=o.dialog("Submit");t.add(e),t.addButton("Save",(()=>{this.saveCampaign(),t.close()})),t.addButton("Submit",(()=>{var e;null===(e=this._submitView)||void 0===e||e.submit(),t.close()})),t.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((()=>gt(this,void 0,void 0,(function*(){var n;i._onAdded(),yield new Promise((t=>setTimeout(t,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 t=e.ViewLayout.fromViewState(this._campaign.layout);i.loadLayout(t)}catch(t){console.error(t)}i.dataFrame.onFilterChanged.subscribe((t=>{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),t&&t()}))),300),i.parentCall=this.parentCall,i}getSummary(){var t,e,i,n,a,s,r;const l=null!==(e=null===(t=this.campaign)||void 0===t?void 0:t.campaignFields)&&void 0!==e?e: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")),C)],{style:{alignItems:"center"}})},l),{"Number of molecules":this.dataFrame.rowCount.toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((t=>t.name))].filter((t=>t&&""!==t.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)}),C)],{style:{alignItems:"center"}})})}saveCampaign(i,n=!0){var a,s,r,l,c,u;return gt(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(t){return mt(this,void 0,void 0,(function*(){return new Promise((e=>mt(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?e(i.value):e(t)})).show()}))))}))}(d),g={};h.columns.toList().forEach((t=>g[t.name]=t.semType));const y={};h.columns.toList().forEach((t=>y[t.name]=t.type));const b={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,columnTypes:y};this.campaign=b;const w=e.DataFrame.fromColumns(h.columns.toList().filter((t=>!t.name.startsWith("~")))).toCsv();yield Bt.files.writeAsText(`Hit Triage/campaigns/${d}/enriched_table.csv`,w);const C=this._pickView.saveLayout();C?b.layout=C.viewState:t.shell.warning("Layout cound not be saved"),yield Bt.files.writeAsText(`Hit Triage/campaigns/${d}/campaign.json`,JSON.stringify(b)),n&&t.shell.info("Campaign saved successfully.")}))}}var bt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};function wt(i,n){var a,s,r,c,u,d,p,m,v,g,y;return bt(this,void 0,void 0,(function*(){const b=yield Bt.files.list("Hit Design/templates");let C=!1,T=!1;const x=b.map((t=>t.name.slice(0,-5))),I=[];for(const t of b)try{const e=JSON.parse(yield Bt.files.readAsText(t));I.push(e.key)}catch(t){console.error(t)}const S=e.Func.find({tags:[l]}),E={};S.forEach((t=>{var e;E[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t}));const N=o.choiceInput("Submit function",null,[null,...Object.keys(E)]);N.nullable=!0,N.value=null!==(s=null===(a=null==n?void 0:n.submit)||void 0===a?void 0:a.fName)&&void 0!==s?s:null,N.setTooltip("Select function to be called upon submitting");const _=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),F=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"});function B(){var t,e,i,n;if(""===O.value||x.includes(null!==(e=null===(t=O.value)||void 0===t?void 0:t.trim())&&void 0!==e?e:"")){const t=null!==(i=O.input.offsetLeft)&&void 0!==i?i:0,e=null!==(n=O.input.offsetWidth)&&void 0!==n?n:0;_.style.marginLeft=`${t}px`,_.style.width=`${e}px`,_.style.opacity="100%",_.style.borderTop="1px solid red",C=!0}else _.style.borderTop="none",_.style.opacity="0%",C=!1}const O=o.stringInput("Name",null!==(r=null==n?void 0:n.name)&&void 0!==r?r:"",B);function P(){var t,e,i,n;if(""===k.value||I.includes(null!==(e=null===(t=k.value)||void 0===t?void 0:t.trim())&&void 0!==e?e:"")){const t=null!==(i=k.input.offsetLeft)&&void 0!==i?i:0,e=null!==(n=k.input.offsetWidth)&&void 0!==n?n:0;F.style.marginLeft=`${t}px`,F.style.width=`${e}px`,F.style.borderTop="1px solid red",F.style.opacity="100%",T=!0}else F.style.opacity="0%",F.style.borderTop="none",T=!1}const k=o.stringInput("Key",null!==(c=null==n?void 0:n.key)&&void 0!==c?c:"",P);k.setTooltip("Template key used for campaign prefix"),O.setTooltip("Template name"),O.root.style.borderBottom="none",k.root.style.borderBottom="none",_.style.opacity="0%",F.style.opacity="0%";let V=null;const L={compute:{descriptors:{enabled:!0,args:null!==(p=null===(d=null===(u=null==n?void 0:n.compute)||void 0===u?void 0:u.descriptors)||void 0===d?void 0:d.args)&&void 0!==p?p:[]},functions:null!==(v=null===(m=null==n?void 0:n.compute)||void 0===m?void 0:m.functions)&&void 0!==v?v:[]}},j=yield Q(i,(t=>{V=t}),(()=>null),L,!1);j.root.classList.add("hit-triage-new-template-functions-input");const D=it(null==n?void 0:n.campaignFields),H=function(t){const i=[e.Property.fromOptions({name:"Name",type:e.TYPE.STRING})],n=new X(i,t?t.map((t=>({Name:t}))):void 0,{horizontalInputNames:!0});let o={};return n.onItemAdded.subscribe((t=>{o={}})),n.onAddingItemChanged.subscribe((t=>{t&&(o=t.item)})),{getFields:function(){const t=n.items.filter((t=>t.Name)).map((t=>t.Name));return o.Name&&""!==o.Name&&t.push(o.Name),t},fieldsDiv:n.root}}(null==n?void 0:n.stages),M=o.divV([o.divV([O,_]),o.divV([k,F]),D.fieldsDiv]),R=o.h2("Stages");o.tooltip.bind(R,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const U=o.h2("Compute");o.tooltip.bind(U,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const $=o.div([o.h2("Details"),M,R,H.fieldsDiv,U,j.root,o.h2("Submit"),N.root],"ui-form"),q=o.buttonsInput([]);$.appendChild(q);const Y=null!==(y=null===(g=q.getElementsByClassName("ui-input-editor"))||void 0===g?void 0:g[0])&&void 0!==y?y:q,W=new Promise((t=>{const e=o.button(A,(()=>t()));Y.appendChild(e)})),G=new Promise((e=>{const i=o.bigButton(w,(()=>function(){var i,n,o,a,s;return bt(this,void 0,void 0,(function*(){if(B(),P(),j.okProxy(),C||!O.value||""===O.value)return void t.shell.error("Template name is empty or already exists");if(T||!k.value||""===k.value)return void t.shell.error("Template key is empty or already exists");const r=N.value?E[N.value]:void 0,l=Object.assign({name:O.value,key:k.value,campaignFields:D.getFields(),stages:H.getFields(),compute:{descriptors:{enabled:!!(null===(i=null==V?void 0:V.descriptors)||void 0===i?void 0:i.length),args:null!==(n=null==V?void 0:V.descriptors)&&void 0!==n?n:[]},functions:Object.entries(null!==(o=null==V?void 0:V.externals)&&void 0!==o?o:{}).map((([t,e])=>{const i=t.split(":");return{name:i[1],package:i[0],args:e}})),scripts:Object.entries(null!==(a=null==V?void 0:V.scripts)&&void 0!==a?a:{}).filter((([t,e])=>t.startsWith(h)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}})),queries:Object.entries(null!==(s=null==V?void 0:V.queries)&&void 0!==s?s:{}).filter((([t,e])=>t.startsWith(f)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}}))}},r?{submit:{fName:r.name,package:r.package.name}}:{});var c;c=l,Bt.files.writeAsText(`Hit Design/templates/${c.name}.json`,JSON.stringify(c)),t.shell.info("Template created successfully"),e(l)}))}()));Y.appendChild(i)}));return{root:$,template:G,cancelPromise:W}}))}var Ct=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class At extends ot{constructor(e){super(e),this.name="Hit Design",t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(Bt.webRoot+"README_HD.md"),this.checkCampaign().then((t=>{this.app.campaign=t,this.init()}))}onActivated(){t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(Bt.webRoot+"README_HD.md")}init(t){return Ct(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const e=o.h1(T),i=o.h1(x,{style:{marginLeft:"10px"}}),n=rt.appHeader({iconPath:Bt.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,e],{style:{marginLeft:"10px"}}),l,i,r])),yield this.startNewCampaign(a,s,t),this.app.resetBaseUrl()}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(t,e,i){var n;return Ct(this,void 0,void 0,(function*(){const a=(yield Bt.files.list("Hit Design/templates")).filter((t=>t.name.endsWith(".json"))).map((t=>t.name.slice(0,-5)));i&&!a.includes(i.name)&&a.push(i.name);let s=null;const r=()=>Ct(this,void 0,void 0,(function*(){const e=l.value,n=i&&i.name===e?i:JSON.parse(yield Bt.files.readAsText("Hit Design/templates/"+e+".json"));s=n;const o=yield this.getNewCampaignAccordeon(n);z()(t).empty(),t.appendChild(o)})),l=o.choiceInput("Template",null!==(n=null==i?void 0:i.name)&&void 0!==n?n:a[0],a,(()=>Ct(this,void 0,void 0,(function*(){yield r()}))));l.root.style.width="100%";const c=o.icons.add((()=>{this.createNewTemplate()}),y),u=o.icons.copy((()=>{s&&this.createNewTemplate(s)}),"Clone template");c.style.color="#2083d5",l.addOptions(u),l.addOptions(c),yield r(),z()(e).empty(),e.appendChild(l.root)}))}checkCampaign(t){var e;return Ct(this,void 0,void 0,(function*(){const i=location.search,n=new URLSearchParams(i);if(!n.has(s)&&!t)return;const o=null!=t?t:n.get(s);if(!(yield Bt.files.exists(`Hit Design/campaigns/${o}/campaign.json`)))return;const a=JSON.parse(yield Bt.files.readAsText(`Hit Design/campaigns/${o}/campaign.json`));a&&(this.app.campaign=a);const r=null!==(e=a.template)&&void 0!==e?e:JSON.parse(yield Bt.files.readAsText(`Hit Design/templates/${a.templateName}.json`));return yield this.app.setTemplate(r,o),t&&R(s,t),a.template=r,a}))}getCampaignsTable(){return Ct(this,void 0,void 0,(function*(){const t=yield W("Hit Design",this.deletedCampaigns),e=o.table(Object.values(t),(t=>[o.link(t.name,(()=>this.setCampaign(t.name)),"",""),t.createDate,t.rowCount,t.status,o.icons.delete((()=>Ct(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${t.name}?`)).onOK((()=>Ct(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Design",t.name),this.deletedCampaigns.push(t.name),yield this.init()})))).show()}))),"Delete campaign")]),["Name","Created","Molecules","Status",""]);return e.style.color="var(--grey-5)",e.style.marginLeft="24px",e}))}setCampaign(t){return Ct(this,void 0,void 0,(function*(){const e=yield this.checkCampaign(t);this.app.campaign=e}))}getNewCampaignAccordeon(i){return Ct(this,void 0,void 0,(function*(){const{root:n,promise:a,cancelPromise:s}=function(i){var n,a;const s=e.DataFrame.create(1),r=s.columns.addNew(d,e.TYPE.STRING);r.semType=e.SEMTYPE.MOLECULE,r.setTag(e.TAGS.UNITS,e.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(u,e.TYPE.STRING).set(0,i.stages[0]);const l=s.columns.addNew(p,e.TYPE.STRING);l.set(0,ft(l));const c=i.campaignFields.map((t=>t.type===e.SEMTYPE.MOLECULE?Object.assign(Object.assign({},t),{type:"String",semtype:e.SEMTYPE.MOLECULE}):t)).map((t=>e.Property.fromOptions(Object.assign({name:t.name,type:G[t.type],nullable:!t.required},t.semtype?{semType:t.semtype}:{})))),m={},h=o.input.form(m,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((e=>{const n=o.bigButton(b,(()=>{for(const e of i.campaignFields)if(e.required&&(!m[e.name]||""===m[e.name]))return void t.shell.error(`Field '${e.name}' is required`);e({df:s,campaignProps:m})}));v.appendChild(n)})),root:f,cancelPromise:new Promise((t=>{o.button(A,(()=>t()))}))}}(i);return a.then((t=>Ct(this,void 0,void 0,(function*(){this.app.dataFrame=t.df,yield this.app.setTemplate(i),this.app.campaignProps=t.campaignProps,this.app.saveCampaign(void 0,!1)})))),s.then((()=>{this.init()})),n}))}createNewTemplate(i){return Ct(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const n=yield wt(this.app,i),a=new e.ViewBase,s=t.shell.v;a.name="New Template",a.root.appendChild(n.root),a.parentCall=this.app.parentCall,t.shell.addView(a),a.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:r}=U(a,"Hit Design",y,(()=>Ct(this,void 0,void 0,(function*(){t.shell.v=s,a.close()}))));n.template.then((e=>Ct(this,void 0,void 0,(function*(){yield this.init(e),a.close(),$(a),t.shell.v=s,r.unsubscribe()})))),n.cancelPromise.then((()=>Ct(this,void 0,void 0,(function*(){r.unsubscribe(),a.close(),t.shell.v=s}))))}finally{o.setUpdateIndicator(this.root,!1)}}))}}class Tt extends ot{constructor(t){super(t),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=e.Func.find({name:n.fName,package:n.package})[0];if(!o)return void t.shell.error(`Function ${n.fName} not found.`);const a=e.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"),t.shell.info("Submitted successfully.")},new((a=void 0)||(a=Promise))((function(t,e){function i(t){try{l(s.next(t))}catch(t){e(t)}}function r(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof a?n:new a((function(t){t(n)}))).then(i,r)}l((s=s.apply(n,o||[])).next())}))}}var xt=i(143),It={};It.styleTagTransform=L(),It.setAttributes=O(),It.insert=F().bind(null,"head"),It.domAPI=N(),It.insertStyleElement=k(),S()(xt.Z,It),xt.Z&&xt.Z.locals&&xt.Z.locals;class St extends ot{constructor(t){super(t),this.v=null,this.name="Progress Tracker"}render(){return i=this,n=void 0,s=function*(){return new Promise((i=>{var n,a,s;this.app.dataFrame.columns.names().forEach((t=>{t.startsWith("~")&&this.app.dataFrame.columns.remove(t)}));const r=null===(n=this.app.campaign)||void 0===n?void 0:n.tilesViewerFormSketch;let l=null;if(r&&r.length>0)try{l=JSON.parse(r)}catch(t){console.error("Failed to parse sketch state string",t)}let c=!0;if(!this.v||this.v.isDetached){c=!1,this.v=e.Viewer.fromType(e.VIEWER.TILE_VIEWER,this.app.dataFrame,Object.assign({lanesColumnName:u,lanes:null!==(s=null===(a=this.app.template)||void 0===a?void 0:a.stages)&&void 0!==s?s:[]},l?{sketchState:l}:{}));const t=this.v.getOptions();l&&(t.look.sketchState=l),this.v.setOptions(t),this.v.copyViewersLook(this.v)}c?i():(o.empty(this.root),this.root.appendChild(this.v.root),this.v.root.style.height="100%",this.v.root.style.width="100%",setTimeout((()=>{var e,n,a;null===(n=null===(e=this.v)||void 0===e?void 0:e.view)||void 0===n||n._onAdded();const s=null===(a=t.shell.v)||void 0===a?void 0:a.getRibbonPanels();if(s){if(q(s))return void i();const e=o.bigButton("Design view",(()=>{const e=t.shell.view(this.app.designViewName);e&&(t.shell.v=e)})),n=o.bigButton("Submit",(()=>{var t;const e=null===(t=this.app._submitView)||void 0===t?void 0:t.render();if(e){const t=o.dialog("Submit");t.add(e),t.addButton("Save",(()=>{this.app.saveCampaign(),t.close()})),t.addButton("Submit",(()=>{var e;null===(e=this.app._submitView)||void 0===e||e.submit(),t.close()})),t.show()}}));n.classList.add("hit-design-submit-button"),s.push([e,n]),t.shell.v.setRibbonPanels(s)}i()}),5))}))},new((a=void 0)||(a=Promise))((function(t,e){function o(t){try{l(s.next(t))}catch(t){e(t)}}function r(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var i;e.done?t(e.value):(i=e.value,i instanceof a?i:new a((function(t){t(i)}))).then(o,r)}l((s=s.apply(i,n||[])).next())}));var i,n,a,s}onActivated(){this.render()}get sketchStateString(){if(!this.v)return null;const t=this.v.props.sketchState;return t&&"object"==typeof t?JSON.stringify(t):null}}var Et=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class Nt extends pt{constructor(i){super(i),this._tilesViewTab=null,this._designViewName="Design",this._filePath="System.AppData/HitTriage/Hit Design/campaigns",this._molColName=d,this.campaignProps={},this.processedValues=[],this._extraStageColsCount=0,this._infoView=new At(this),this.multiView=new e.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((t=>{this.multiView.currentView instanceof ot&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,this.mainView=this.multiView,t.events.onCurrentViewChanged.subscribe((()=>Et(this,void 0,void 0,(function*(){var e,i,n,o,s,r,l,c,u;try{if((null===(e=t.shell.v)||void 0===e?void 0:e.name)===this.currentDesignViewId||(null===(i=t.shell.v)||void 0===i?void 0:i.name)===this.currentTilesViewId){if(t.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:""),this.currentTilesViewId&&(null===(r=t.shell.v)||void 0===r?void 0:r.name)===this.currentTilesViewId)yield null===(l=this._tilesView)||void 0===l?void 0:l.render();else{const t=null===(c=this._tilesView)||void 0===c?void 0:c.sketchStateString;t&&""!=t&&this.campaign&&(this.campaign.tilesViewerFormSketch=t)}const{sub:e}=U(t.shell.v,"Hit Design",null===(u=t.shell.v)||void 0===u?void 0:u.name,(()=>{var i,n;t.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(),e.unsubscribe()}))}}catch(t){console.error(t)}}))))}get infoView(){return this._infoView}setTemplate(i,n){var o,r,l,c,u,p,m,h,f,v,g,y,b;return Et(this,void 0,void 0,(function*(){if(n){const e="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:`${e}/${n}/enriched_table.csv`,this.dataFrame=yield t.dapi.files.readCsv(this._filePath),(null===(c=this._campaign)||void 0===c?void 0:c.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([t,e])=>{const i=this.dataFrame.columns.byName(t);i&&e&&(i.semType=e)})),(null===(u=this._campaign)||void 0===u?void 0:u.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach((([t,e])=>{const i=this.dataFrame.columns.byName(t);if(i&&i.type!==e)try{this.dataFrame.changeColumnType(t,e)}catch(t){console.error(t)}}))}else(null===(o=this._designView)||void 0===o?void 0:o.dataFrame)&&t.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!==(m=null===(p=this.dataFrame.columns.bySemType(e.SEMTYPE.MOLECULE))||void 0===p?void 0:p.name)&&void 0!==m?m:d,this._dfName=null!==(h=(b=this.dataFrame).name)&&void 0!==h?h:b.name=n,this._campaignId=n,this.template=i,null!==(f=this._submitView)&&void 0!==f||(this._submitView=new Tt(this)),t.shell.windows.showHelp=!1,this._extraStageColsCount=this.dataFrame.rowCount-this.dataFrame.filter.trueCount;const w=this.designView;this.currentDesignViewId=w.name,this.setBaseUrl(),R(a,null!==(y=null!==(v=this._campaignId)&&void 0!==v?v:null===(g=this._campaign)||void 0===g?void 0:g.name)&&void 0!==y?y:""),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 t,i,n,o;return null!==(t=this._molColName)&&void 0!==t?t:this._molColName=null!==(o=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(e.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name)&&void 0!==o?o:d}get campaign(){return this._campaign}set campaign(t){this._campaign=t}getDesignView(){var i,n,a,s,r,l;const c=[],m=null===(i=this.dataFrame.col(this.molColName))||void 0===i?void 0:i.toList().every((t=>!t&&""===t)),v=t.shell.addTableView(this.dataFrame);this._designViewName=null!==(a=null===(n=this.campaign)||void 0===n?void 0:n.name)&&void 0!==a?a:this._designViewName,v.name=this._designViewName,this.processedValues=this.dataFrame.getCol(this.molColName).toList(),setTimeout((()=>Et(this,void 0,void 0,(function*(){var i,n;if(v._onAdded(),yield new Promise((t=>setTimeout(t,1e3))),null===(i=this._campaign)||void 0===i?void 0:i.layout)try{const t=e.ViewLayout.fromViewState(this._campaign.layout);v.loadLayout(t)}catch(t){console.error(t)}m&&t.functions.call("Chem:editMoleculeCell",{cell:v.grid.cell(this._molColName,0)}),c.push(this.dataFrame.onRowsAdded.subscribe((()=>{var e,i;try{if(this.processedValues=this.dataFrame.getCol(this.molColName).toList(),(null===(e=this.template.stages)||void 0===e?void 0:e.length)>0)for(let t=0;t<this.dataFrame.rowCount;t++){const e=this.dataFrame.col(u).get(t);e&&""!==e&&!(null===(i=this.dataFrame.col(u))||void 0===i?void 0:i.isNone(t))||this.dataFrame.set(u,t,this.template.stages[0])}let n=null;for(let t=0;t<this.dataFrame.rowCount;t++){const e=v.grid.cell(this.molColName,t);e&&(""!==e.cell.value&&null!==e.cell.value||(n=e))}n&&t.functions.call("Chem:editMoleculeCell",{cell:n})}catch(t){console.error(t)}}))),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(t){console.error(t)}}))),c.push(t.events.onContextMenu.subscribe((i=>{var n,o,a,s,r;try{const t=null===(n=null==i?void 0:i.args)||void 0===n?void 0:n.context;if(!t)return;if((null==t?void 0:t.type)!==e.VIEWER.GRID)return;if(!t.tableView||t.tableView.id!==v.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 t,e,n,o;try{this.dataFrame.rows.addNew(null,!0);let a=null;for(let t=0;t<this.dataFrame.rowCount;t++){const e=v.grid.cell(this.molColName,t);e&&(""!==e.cell.value&&null!==e.cell.value||(a=e))}a&&(a.cell.value=null!==(o=null===(n=null===(e=null===(t=null==i?void 0:i.args)||void 0===t?void 0:t.item)||void 0===e?void 0:e.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(t){console.error(t)}}))}catch(e){t.log.error(e)}}))),c.push(v.grid.onCellValueEdited.subscribe((i=>Et(this,void 0,void 0,(function*(){var n,o,a,s;try{if((null===(n=i.tableColumn)||void 0===n?void 0:n.name)===u)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(p))||void 0===a?void 0:a.get(l))&&""!==(null===(s=this.dataFrame.col(p))||void 0===s?void 0:s.get(l))||this.dataFrame.col(p).set(l,ft(this.dataFrame.col(p)),!1);const c=this.template.compute;if(!r||""===r)return;const m=yield function(i,n,o,a=[],s=[]){return ht(this,void 0,void 0,(function*(){const r=e.TaskBarProgressIndicator.create("Calculating ..."),l=t.chem.convert(i,t.chem.Notation.Unknown,t.chem.Notation.Smiles),c=e.Column.fromStrings(d,[l]),u=e.DataFrame.fromColumns([c]);u.name="HD Single cell values",yield u.meta.detectSemanticTypes(),n.length&&(yield t.chem.descriptors(u,c.name,n));for(const t of o)try{const i=t.args,n=e.Func.find({package:t.package,name:t.name});if(!n.length||!n[0]){console.warn(`Function ${t.name} from package ${t.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]:u,[s]:c.name}))}catch(t){console.error(t);continue}for(const e of a){const i=e.args;try{const n=yield t.dapi.scripts.find(e.id);if(n){const t=n.inputs[0].name,e=n.inputs[1].name,o=yield n.apply(Object.assign(Object.assign({},i),{[t]:u,[e]:c.name}));if(o&&o.rowCount===u.rowCount&&"python"===n.language)for(const t of o.columns)t.name=u.columns.getUnusedName(t.name),u.columns.add(t)}}catch(t){console.error(t)}}for(const e of s){const i=e.args;try{const n=yield t.dapi.queries.find(e.id);if(n){const t=n.inputs[0].name,e=[l],o=yield n.apply(Object.assign(Object.assign({},i),{[t]:e}));if(!o||0===o.rowCount)continue;yield Y(u,d,o)}}catch(t){console.error(t)}}return r.close(),u}))}(r,c.descriptors.args,c.functions,c.scripts,c.queries);for(const t of m.columns.toList())t.name!==d&&(this.dataFrame.columns.contains(t.name)||(this.dataFrame.columns.addNew(t.name,t.type).semType=t.semType),this.dataFrame.col(t.name).set(l,t.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(void 0,!1)}catch(t){console.error(t)}})))));const o=t.events.onViewRemoved.subscribe((t=>{t.id===v.id&&(c.forEach((t=>t.unsubscribe())),o.unsubscribe())}))}))),300);const g=null==v?void 0:v.getRibbonPanels();if(g&&!q(g)){const e=()=>Et(this,void 0,void 0,(function*(){var t;Q(this,(t=>Et(this,void 0,void 0,(function*(){var e,i,n,a,s,r,l,c,u,d;const p=this.template.compute.descriptors.args,m=this.template.compute.functions,g=null!==(e=this.template.compute.scripts)&&void 0!==e?e:[],y=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],b=t.descriptors,w={descriptors:{enabled:!!(null===(n=null==t?void 0:t.descriptors)||void 0===n?void 0:n.length),args:null!==(a=null==t?void 0:t.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(s=null==t?void 0:t.externals)&&void 0!==s?s:{}).map((([t,e])=>{const i=t.split(":");return{name:i[1],package:i[0],args:e}})),scripts:Object.entries(null!==(r=null==t?void 0:t.scripts)&&void 0!==r?r:{}).filter((([t,e])=>t.startsWith(h)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}})),queries:Object.entries(null!==(l=null==t?void 0:t.queries)&&void 0!==l?l:{}).filter((([t,e])=>t.startsWith(f)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}}))};this.template.compute=w,this.campaign.template=this.template;const C=b.filter((t=>!p.includes(t))),A={};Object.entries(null!==(c=null==t?void 0:t.externals)&&void 0!==c?c:{}).filter((([t,e])=>{const i=m.find((e=>`${e.package}:${e.name}`===t));return!i||!Object.entries(e).every((([t,e])=>i.args[t]===e))})).forEach((([t,e])=>{A[t]=e}));const T={};Object.entries(null!==(u=null==t?void 0:t.scripts)&&void 0!==u?u:{}).filter((([t,e])=>{const i=g.find((e=>`HTScript:${e.name}:${e.id}`===t));return!i||!Object.entries(e).every((([t,e])=>i.args[t]===e))})).forEach((([t,e])=>{T[t]=e}));const x={};Object.entries(null!==(d=null==t?void 0:t.queries)&&void 0!==d?d:{}).filter((([t,e])=>{const i=y.find((e=>`HTQuery:${e.name}:${e.id}`===t));return!i||!Object.entries(e).every((([t,e])=>i.args[t]===e))})).forEach((([t,e])=>{x[t]=e})),o.setUpdateIndicator(v.grid.root,!0);try{yield vt({descriptors:C,externals:A,scripts:T,queries:x},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{o.setUpdateIndicator(v.grid.root,!1),this.saveCampaign(void 0,!1)}}))),(()=>null),null===(t=this.campaign)||void 0===t?void 0:t.template,!0)})),i=o.iconFA("wrench",e,"Calculate additional properties"),n=o.icons.add((()=>{var t;null===(t=this.dataFrame)||void 0===t||t.rows.addNew(null,!0)}),"Add new row"),a=o.bigButton("Progress tracker",(()=>{var e;this.currentTilesViewId&&t.shell.view(this.currentTilesViewId)&&(null===(e=t.shell.view(this.currentTilesViewId))||void 0===e||e.close()),this._tilesView=new St(this),this._tilesView.parentCall=this.parentCall,this._tilesViewTab=t.shell.addView(this._tilesView),this.currentTilesViewId=this._tilesViewTab.name,this._tilesView.onActivated(),t.shell.v=t.shell.view(this.currentTilesViewId)})),c=o.bigButton("Submit",(()=>{var t;const e=null===(t=this._submitView)||void 0===t?void 0:t.render();if(e){const t=o.dialog("Submit");t.add(e),t.addButton("Save",(()=>{this.saveCampaign(),t.close()})),t.addButton("Submit",(()=>{var e;null===(e=this._submitView)||void 0===e||e.submit(),t.close()})),t.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),v.setRibbonPanels(g)}return v.parentCall=this.parentCall,v}getSummary(){var i,n,a,s;const r=()=>{var t,e;const i=this._filePath.indexOf(null!==(t=this.campaignId)&&void 0!==t?t:null===(e=this._campaign)||void 0===e?void 0:e.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((t=>t.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===e.SEMTYPE.MOLECULE&&n&&(l[i]=t.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 e=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",(()=>Et(this,void 0,void 0,(function*(){const i=yield function(){return Et(this,void 0,void 0,(function*(){const e=s.value;return e&&""!==e.trim()?!!(yield t.dapi.files.exists(e))||(t.shell.error("Given folder does not exist"),!1):(t.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 t,e,i;return this.download(this.dataFrame,null!==(i=null!==(t=this.campaignId)&&void 0!==t?t:null===(e=this._campaign)||void 0===e?void 0:e.name)&&void 0!==i?i:"Molecules")}),C),a.appendChild(n),a.appendChild(e)})))),u=o.button("Cancel",(()=>{o.empty(a),a.appendChild(n),a.appendChild(e)}));o.empty(a),s.addOptions(u),s.addOptions(c),a.appendChild(s.root)}),"Edit file path");e.style.marginLeft="5px";const i=r();let n=o.link(i,(()=>{var t,e,i;return this.download(this.dataFrame,null!==(i=null!==(t=this.campaignId)&&void 0!==t?t:null===(e=this._campaign)||void 0===e?void 0:e.name)&&void 0!==i?i:"Molecules")}),C);const a=o.divH([n,e],{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((t=>t.name))].filter((t=>t&&""!==t.trim())).join(", ")})}saveCampaign(i,n=!0){var o,a,s,r,l,c,u,d,m,h,f,v;return Et(this,void 0,void 0,(function*(){const g=this.campaignId,y=this.template.name,b=this.dataFrame,w=g,C={};b.columns.toList().forEach((t=>C[t.name]=t.semType));const A={};b.columns.toList().forEach((t=>A[t.name]=t.type));const T=null!==(r=null!==(a=null===(o=this._tilesView)||void 0===o?void 0:o.sketchStateString)&&void 0!==a?a:null===(s=this.campaign)||void 0===s?void 0:s.tilesViewerFormSketch)&&void 0!==r?r:void 0,x={name:w,templateName:y,status:null!==(c=null!=i?i:null===(l=this.campaign)||void 0===l?void 0:l.status)&&void 0!==c?c:"In Progress",createDate:null!==(d=null===(u=this.campaign)||void 0===u?void 0:u.createDate)&&void 0!==d?d:M(new Date),campaignFields:null!==(h=null===(m=this.campaign)||void 0===m?void 0:m.campaignFields)&&void 0!==h?h:this.campaignProps,columnSemTypes:C,rowCount:null!==(v=null===(f=b.col(p))||void 0===f?void 0:f.toList().filter((t=>"StageDefiningRow"!==t)).length)&&void 0!==v?v:0,filteredRowCount:b.filter.trueCount,savePath:this._filePath,columnTypes:A,tilesViewerFormSketch:T};console.log(this._filePath);const I=e.DataFrame.fromColumns(b.columns.toList().filter((t=>!t.name.startsWith("~")))).toCsv();yield t.dapi.files.writeAsText(this._filePath,I);const S=this._designView.saveLayout();return S?x.layout=S.viewState:t.shell.warning("Layout cound not be saved"),x.template=this.template,yield Bt.files.writeAsText(`Hit Design/campaigns/${g}/campaign.json`,JSON.stringify(x)),n&&t.shell.info("Campaign saved successfully."),this.campaign=x,x}))}}class _t extends e.GridCellRenderer{get name(){return"customGasteigerPNG"}get cellType(){return"customGasteigerPNG"}get defaultHeight(){return 200}get defaultWidth(){return 200}render(t,e,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(){t.drawImage(l,e+2,i+2,n-2,o-2)}}}var Ft=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};const Bt=new e.Package;function Ot(){return Ft(this,void 0,void 0,(function*(){const e=t.functions.getCurrentCall();return new yt(e).multiView}))}function Pt(){return Ft(this,void 0,void 0,(function*(){const e=t.functions.getCurrentCall();return new Nt(e).multiView}))}function kt(){return Ft(this,void 0,void 0,(function*(){const e=t.data.demo.molecules(100);return e.name="100 Molecules",e}))}function Vt(){return Ft(this,void 0,void 0,(function*(){const e=t.data.demo.molecules(5e3);return e.name="5000 Molecules",e}))}function Lt(e){return Ft(this,void 0,void 0,(function*(){const i=t.data.demo.molecules(e);return i.name="Variable Molecules number",i}))}function jt(e,i){return Ft(this,void 0,void 0,(function*(){t.shell.info(e.rowCount),t.shell.info(i)}))}function Dt(){return new _t}})(),hittriage=n})();
|
|
1
|
+
var hittriage;(()=>{var t={553:t=>{!function(){"use strict";var e=document,i=window,n=e.documentElement,o=e.createElement.bind(e),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,w=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,b=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,C=/<.+>/,A=/^\w+$/;function T(t,e){var i,n=!!(i=e)&&11===i.nodeType;return t&&(n||_(e)||F(e))?!n&&b.test(t)?e.getElementsByClassName(t.slice(1).replace(/\\/g,"")):!n&&A.test(t)?e.getElementsByTagName(t):e.querySelectorAll(t):[]}var x=function(){function t(t,n){if(t){if(N(t))return t;var o=t;if(P(t)){var a=n||e;if(!(o=w.test(t)&&_(a)?a.getElementById(t.slice(1).replace(/\\/g,"")):C.test(t)?X(t):N(a)?a.find(t):P(a)?I(a).find(t):T(t,a)))return}else if(O(t))return this.ready(t);(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 t.prototype.init=function(e,i){return new t(e,i)},t}(),S=x.prototype,I=S.init;function N(t){return t instanceof x}function E(t){return!!t&&t===t.window}function _(t){return!!t&&9===t.nodeType}function F(t){return!!t&&1===t.nodeType}function B(t){return"boolean"==typeof t}function O(t){return"function"==typeof t}function P(t){return"string"==typeof t}function k(t){return void 0===t}function V(t){return null===t}function L(t){return!isNaN(parseFloat(t))&&isFinite(t)}function j(t){if("object"!=typeof t||null===t)return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function D(t,e,i){if(i){for(var n=t.length;n--;)if(!1===e.call(t[n],n,t[n]))return t}else if(j(t))for(var o=Object.keys(t),a=(n=0,o.length);n<a;n++){var s=o[n];if(!1===e.call(t[s],s,t[s]))return t}else for(n=0,a=t.length;n<a;n++)if(!1===e.call(t[n],n,t[n]))return t;return t}function H(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=!!B(t[0])&&t.shift(),n=t.shift(),o=t.length;if(!n)return{};if(!o)return H(i,I,n);for(var a=0;a<o;a++){var s=t[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}I.fn=I.prototype=S,S.length=0,S.splice=y,"function"==typeof Symbol&&(S[Symbol.iterator]=u[Symbol.iterator]),I.isWindow=E,I.isFunction=O,I.isArray=c,I.isNumeric=L,I.isPlainObject=j,I.each=D,S.each=function(t){return D(this,t)},S.empty=function(){return this.each((function(t,e){for(;e.firstChild;)e.removeChild(e.firstChild)}))},I.extend=H,S.extend=function(t){return H(S,t)};var M=/\S+/g;function R(t){return P(t)&&t.match(M)||[]}function U(t,e,n){if(F(t)){var o=i.getComputedStyle(t,null);return n?o.getPropertyValue(e)||void 0:o[e]||t.style[e]}}function $(t,e){return parseInt(U(t,e),10)||0}function q(t,e){return $(t,"border".concat(e?"Left":"Top","Width"))+$(t,"padding".concat(e?"Left":"Top"))+$(t,"padding".concat(e?"Right":"Bottom"))+$(t,"border".concat(e?"Right":"Bottom","Width"))}S.toggleClass=function(t,e){var i=R(t),n=!k(e);return this.each((function(t,o){F(o)&&D(i,(function(t,i){n?e?o.classList.add(i):o.classList.remove(i):o.classList.toggle(i)}))}))},S.addClass=function(t){return this.toggleClass(t,!0)},S.removeAttr=function(t){var e=R(t);return this.each((function(t,i){F(i)&&D(e,(function(t,e){i.removeAttribute(e)}))}))},S.attr=function(t,e){if(t){if(P(t)){if(arguments.length<2){if(!this[0]||!F(this[0]))return;var i=this[0].getAttribute(t);return V(i)?void 0:i}return k(e)?this:V(e)?this.removeAttr(t):this.each((function(i,n){F(n)&&n.setAttribute(t,e)}))}for(var n in t)this.attr(n,t[n]);return this}},S.removeClass=function(t){return arguments.length?this.toggleClass(t,!1):this.attr("class","")},S.hasClass=function(t){return!!t&&g.call(this,(function(e){return F(e)&&e.classList.contains(t)}))},S.get=function(t){return k(t)?v.call(this):this[(t=Number(t))<0?t+this.length:t]},S.eq=function(t){return I(this.get(t))},S.first=function(){return this.eq(0)},S.last=function(){return this.eq(-1)},S.text=function(t){return k(t)?this.get().map((function(t){return F(t)||(e=t)&&3===e.nodeType?t.textContent:"";var e})).join(""):this.each((function(e,i){F(i)&&(i.textContent=t)}))};var Y={};function W(t){return"none"===U(t,"display")}function J(t,e){var i=t&&(t.matches||t.webkitMatchesSelector||t.msMatchesSelector);return!!i&&!!e&&i.call(t,e)}function G(t){return P(t)?function(e,i){return J(i,t)}:O(t)?t:N(t)?function(e,i){return t.is(i)}:t?function(e,i){return i===t}:function(){return!1}}function Z(t,e){return e?t.filter(e):t}S.filter=function(t){var e=G(t);return I(p.call(this,(function(t,i){return e.call(t,i,t)})))},S.detach=function(t){return Z(this,t).each((function(t,e){e.parentNode&&e.parentNode.removeChild(e)})),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(t){if(!P(t))return[];if(Q.test(t))return[o(RegExp.$1)];var e=z.test(t)&&RegExp.$1,i=K[e]||K["*"];return i.innerHTML=t,I(i.childNodes).detach().get()}function tt(t,e,i,n){for(var o=[],a=O(e),s=n&&G(n),r=0,l=t.length;r<l;r++)if(a){var c=e(t[r]);c.length&&f.apply(o,c)}else for(var u=t[r][e];!(null==u||n&&s(-1,u));)o.push(u),u=i?u[e]:null;return o}function et(t){return t.multiple&&t.options?tt(p.call(t.options,(function(t){return t.selected&&!t.disabled&&!t.parentNode.disabled})),"value"):t.value||""}function it(t){return t.length>1?p.call(t,(function(t,e,i){return m.call(i,t)===e})):t}I.parseHTML=X,S.has=function(t){var e=P(t)?function(e,i){return T(t,i).length}:function(e,i){return i.contains(t)};return this.filter(e)},S.not=function(t){var e=G(t);return this.filter((function(i,n){return(!P(t)||F(n))&&!e.call(n,i,n)}))},S.val=function(t){return arguments.length?this.each((function(e,i){var n=i.multiple&&i.options;if(n||Pt.test(i.type)){var o=c(t)?h.call(t,String):V(t)?[]:[String(t)];n?D(i.options,(function(t,e){e.selected=o.indexOf(e.value)>=0}),!0):i.checked=o.indexOf(i.value)>=0}else i.value=k(t)||V(t)?"":t})):this[0]&&et(this[0])},S.is=function(t){var e=G(t);return g.call(this,(function(t,i){return e.call(t,i,t)}))},I.guid=1,I.unique=it,S.add=function(t,e){return I(it(this.get().concat(I(t,e).get())))},S.children=function(t){return Z(I(it(tt(this,(function(t){return t.children})))),t)},S.parent=function(t){return Z(I(it(tt(this,"parentNode"))),t)},S.index=function(t){var e=t?I(t)[0]:this[0],i=t?this:I(e).parent().children();return m.call(i,e)},S.closest=function(t){var e=this.filter(t);if(e.length)return e;var i=this.parent();return i.length?i.closest(t):e},S.siblings=function(t){return Z(I(it(tt(this,(function(t){return I(t).parent().children().not(t)})))),t)},S.find=function(t){return I(it(tt(this,(function(e){return T(t,e)}))))};var nt=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ot=/^$|^module$|\/(java|ecma)script/i,at=["type","src","nonce","noModule"];function st(t,e,i,a,s,r,l,c){return D(t,(function(t,r){D(I(r),(function(t,r){D(I(e),(function(e,l){var c=i?l:r,u=i?t:e;!function(t,e,i,a,s){a?t.insertBefore(e,i?t.firstChild:null):"HTML"===t.nodeName?t.parentNode.replaceChild(e,t):t.parentNode.insertBefore(e,i?t:t.nextSibling),s&&function(t,e){var i=I(t);i.filter("script").add(i.find("script")).each((function(t,i){if(ot.test(i.type)&&n.contains(i)){var a=o("script");a.text=i.textContent.replace(nt,""),D(at,(function(t,e){i[e]&&(a[e]=i[e])})),e.head.insertBefore(a,null),e.head.removeChild(a)}}))}(e,t.ownerDocument)}(i?r:l,u?c.cloneNode(!0):c,a,s,!u)}),c)}),l)}),r),e}S.after=function(){return st(arguments,this,!1,!1,!1,!0,!0)},S.append=function(){return st(arguments,this,!1,!1,!0)},S.html=function(t){if(!arguments.length)return this[0]&&this[0].innerHTML;if(k(t))return this;var e=/<script[\s>]/.test(t);return this.each((function(i,n){F(n)&&(e?I(n).empty().append(t):n.innerHTML=t)}))},S.appendTo=function(t){return st(arguments,this,!0,!1,!0)},S.wrapInner=function(t){return this.each((function(e,i){var n=I(i),o=n.contents();o.length?o.wrapAll(t):n.append(t)}))},S.before=function(){return st(arguments,this,!1,!0)},S.wrapAll=function(t){for(var e=I(t),i=e[0];i.children.length;)i=i.firstElementChild;return this.first().before(e),this.appendTo(i)},S.wrap=function(t){return this.each((function(e,i){var n=I(t)[0];I(i).wrapAll(e?n.cloneNode(!0):n)}))},S.insertAfter=function(t){return st(arguments,this,!0,!1,!1,!1,!1,!0)},S.insertBefore=function(t){return st(arguments,this,!0,!0)},S.prepend=function(){return st(arguments,this,!1,!0,!0,!0,!0)},S.prependTo=function(t){return st(arguments,this,!0,!0,!0,!1,!1,!0)},S.contents=function(){return I(it(tt(this,(function(t){return"IFRAME"===t.tagName?[t.contentDocument]:"TEMPLATE"===t.tagName?t.content.childNodes:t.childNodes}))))},S.next=function(t,e,i){return Z(I(it(tt(this,"nextElementSibling",e,i))),t)},S.nextAll=function(t){return this.next(t,!0)},S.nextUntil=function(t,e){return this.next(e,!0,t)},S.parents=function(t,e){return Z(I(it(tt(this,"parentElement",!0,e))),t)},S.parentsUntil=function(t,e){return this.parents(e,t)},S.prev=function(t,e,i){return Z(I(it(tt(this,"previousElementSibling",e,i))),t)},S.prevAll=function(t){return this.prev(t,!0)},S.prevUntil=function(t,e){return this.prev(e,!0,t)},S.map=function(t){return I(d.apply([],h.call(this,(function(e,i){return t.call(e,i,e)}))))},S.clone=function(){return this.map((function(t,e){return e.cloneNode(!0)}))},S.offsetParent=function(){return this.map((function(t,e){for(var i=e.offsetParent;i&&"static"===U(i,"position");)i=i.offsetParent;return i||n}))},S.slice=function(t,e){return I(v.call(this,t,e))};var rt=/-([a-z])/g;function lt(t){return t.replace(rt,(function(t,e){return e.toUpperCase()}))}S.ready=function(t){var i=function(){return setTimeout(t,0,I)};return"loading"!==e.readyState?i():e.addEventListener("DOMContentLoaded",i),this},S.unwrap=function(){return this.parent().each((function(t,e){if("BODY"!==e.tagName){var i=I(e);i.replaceWith(i.children())}})),this},S.offset=function(){var t=this[0];if(t){var e=t.getBoundingClientRect();return{top:e.top+i.pageYOffset,left:e.left+i.pageXOffset}}},S.position=function(){var t=this[0];if(t){var e="fixed"===U(t,"position"),i=e?t.getBoundingClientRect():this.offset();if(!e){for(var n=t.ownerDocument,o=t.offsetParent||n.documentElement;(o===n.body||o===n.documentElement)&&"static"===U(o,"position");)o=o.parentNode;if(o!==t&&F(o)){var a=I(o).offset();i.top-=a.top+$(o,"borderTopWidth"),i.left-=a.left+$(o,"borderLeftWidth")}}return{top:i.top-$(t,"marginTop"),left:i.left-$(t,"marginLeft")}}};var ct={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};S.prop=function(t,e){if(t){if(P(t))return t=ct[t]||t,arguments.length<2?this[0]&&this[0][t]:this.each((function(i,n){n[t]=e}));for(var i in t)this.prop(i,t[i]);return this}},S.removeProp=function(t){return this.each((function(e,i){delete i[ct[t]||t]}))};var ut=/^--/;function dt(t){return ut.test(t)}var pt={},mt=a.style,ht=["webkit","moz","ms"];function ft(t,e){if(void 0===e&&(e=dt(t)),e)return t;if(!pt[t]){var i=lt(t),n="".concat(i[0].toUpperCase()).concat(i.slice(1));D("".concat(i," ").concat(ht.join("".concat(n," "))).concat(n).split(" "),(function(e,i){if(i in mt)return pt[t]=i,!1}))}return pt[t]}var vt={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 gt(t,e,i){return void 0===i&&(i=dt(t)),i||vt[t]||!L(e)?e:"".concat(e,"px")}function yt(t,e){try{return t(e)}catch(t){return e}}S.css=function(t,e){if(P(t)){var i=dt(t);return t=ft(t,i),arguments.length<2?this[0]&&U(this[0],t,i):t?(e=gt(t,e,i),this.each((function(n,o){F(o)&&(i?o.style.setProperty(t,e):o.style[t]=e)}))):this}for(var n in t)this.css(n,t[n]);return this};var wt=/^\s+|\s+$/;function bt(t,e){var i=t.dataset[e]||t.dataset[lt(e)];return wt.test(i)?i:yt(JSON.parse,i)}function Ct(t,e,i){i=yt(JSON.stringify,i),t.dataset[lt(e)]=i}function At(t,e){var i=t.documentElement;return Math.max(t.body["scroll".concat(e)],i["scroll".concat(e)],t.body["offset".concat(e)],i["offset".concat(e)],i["client".concat(e)])}S.data=function(t,e){if(!t){if(!this[0])return;var i={};for(var n in this[0].dataset)i[n]=bt(this[0],n);return i}if(P(t))return arguments.length<2?this[0]&&bt(this[0],t):k(e)?this:this.each((function(i,n){Ct(n,t,e)}));for(var n in t)this.data(n,t[n]);return this},D([!0,!1],(function(t,e){D(["Width","Height"],(function(t,i){var n="".concat(e?"outer":"inner").concat(i);S[n]=function(n){if(this[0])return E(this[0])?e?this[0]["inner".concat(i)]:this[0].document.documentElement["client".concat(i)]:_(this[0])?At(this[0],i):this[0]["".concat(e?"offset":"client").concat(i)]+(n&&e?$(this[0],"margin".concat(t?"Top":"Left"))+$(this[0],"margin".concat(t?"Bottom":"Right")):0)}}))})),D(["Width","Height"],(function(t,e){var i=e.toLowerCase();S[i]=function(n){if(!this[0])return k(n)?void 0:this;if(!arguments.length)return E(this[0])?this[0].document.documentElement["client".concat(e)]:_(this[0])?At(this[0],e):this[0].getBoundingClientRect()[i]-q(this[0],!t);var o=parseInt(n,10);return this.each((function(e,n){if(F(n)){var a=U(n,"boxSizing");n.style[i]=gt(i,o+("border-box"===a?q(n,!t):0))}}))}})),S.toggle=function(t){return this.each((function(i,n){if(F(n)){var a=W(n);(k(t)?a:t)?(n.style.display=n.___cd||"",W(n)&&(n.style.display=function(t){if(Y[t])return Y[t];var i=o(t);e.body.insertBefore(i,null);var n=U(i,"display");return e.body.removeChild(i),Y[t]="none"!==n?n:"block"}(n.tagName))):a||(n.___cd=U(n,"display"),n.style.display="none")}}))},S.hide=function(){return this.toggle(!1)},S.show=function(){return this.toggle(!0)};var Tt={focus:"focusin",blur:"focusout"},xt={mouseenter:"mouseover",mouseleave:"mouseout"},St=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function It(t){return xt[t]||Tt[t]||t}function Nt(t){var e=t.split(".");return[e[0],e.slice(1).sort()]}function Et(t){return t.___ce=t.___ce||{}}function _t(t,e){return!e||!g.call(e,(function(e){return t.indexOf(e)<0}))}function Ft(t,e,i,n,o){var a=Et(t);if(e)a[e]&&(a[e]=a[e].filter((function(a){var s=a[0],r=a[1],l=a[2];if(o&&l.guid!==o.guid||!_t(s,i)||n&&n!==r)return!0;t.removeEventListener(e,l)})));else for(e in a)Ft(t,e,i,n,o)}S.trigger=function(t,i){if(P(t)){var n=Nt(t),o=n[0],a=n[1],s=It(o);if(!s)return this;var r=St.test(s)?"MouseEvents":"HTMLEvents";(t=e.createEvent(r)).initEvent(s,!0,!0),t.namespace=a.join("."),t.___ot=o}t.___td=i;var l=t.___ot in Tt;return this.each((function(e,i){l&&O(i[t.___ot])&&(i["___i".concat(t.type)]=!0,i[t.___ot](),i["___i".concat(t.type)]=!1),i.dispatchEvent(t)}))},S.off=function(t,e,i){var n=this;if(k(t))this.each((function(t,e){(F(e)||_(e)||E(e))&&Ft(e)}));else if(P(t))O(e)&&(i=e,e=""),D(R(t),(function(t,o){var a=Nt(o),s=a[0],r=a[1],l=It(s);n.each((function(t,n){(F(n)||_(n)||E(n))&&Ft(n,l,r,e,i)}))}));else for(var o in t)this.off(o,t[o]);return this},S.remove=function(t){return Z(this,t).detach().off(),this},S.replaceWith=function(t){return this.before(t).remove()},S.replaceAll=function(t){return I(t).replaceWith(this),this},S.on=function(t,e,i,n,o){var a=this;if(!P(t)){for(var s in t)this.on(s,e,i,t[s],o);return this}return P(e)||(k(e)||V(e)?e="":k(i)?(i=e,e=""):(n=i,i=e,e="")),O(n)||(n=i,i=void 0),n?(D(R(t),(function(t,s){var r=Nt(s),l=r[0],c=r[1],u=It(l),d=l in xt,p=l in Tt;u&&a.each((function(t,a){if(F(a)||_(a)||E(a)){var s=function(t){if(t.target["___i".concat(t.type)])return t.stopImmediatePropagation();if((!t.namespace||_t(c,t.namespace.split(".")))&&(e||!(p&&(t.target!==a||t.___ot===u)||d&&t.relatedTarget&&a.contains(t.relatedTarget)))){var r=a;if(e){for(var l=t.target;!J(l,e);){if(l===a)return;if(!(l=l.parentNode))return}r=l}Object.defineProperty(t,"currentTarget",{configurable:!0,get:function(){return r}}),Object.defineProperty(t,"delegateTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(t,"data",{configurable:!0,get:function(){return i}});var m=n.call(r,t,t.___td);o&&Ft(a,u,c,e,s),!1===m&&(t.preventDefault(),t.stopPropagation())}};s.guid=n.guid=n.guid||I.guid++,function(t,e,i,n,o){var a=Et(t);a[e]=a[e]||[],a[e].push([i,n,o]),t.addEventListener(e,o)}(a,u,c,e,s)}}))})),this):this},S.one=function(t,e,i,n){return this.on(t,e,i,n,!0)};var Bt=/\r?\n/g,Ot=/file|reset|submit|button|image/i,Pt=/radio|checkbox/i;S.serialize=function(){var t="";return this.each((function(e,i){D(i.elements||[i],(function(e,i){if(!(i.disabled||!i.name||"FIELDSET"===i.tagName||Ot.test(i.type)||Pt.test(i.type)&&!i.checked)){var n=et(i);k(n)||D(c(n)?n:[n],(function(e,n){t+=function(t,e){return"&".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(e.replace(Bt,"\r\n")))}(i.name,n)}))}}))})),t.slice(1)},t.exports=I}()},631:(t,e,i)=>{"use strict";i.d(e,{Z:()=>r});var n=i(537),o=i.n(n),a=i(645),s=i.n(a)()(o());s.push([t.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: 800px;\n min-width: 550px;\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;IAChB,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: 800px;\n min-width: 550px;\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:(t,e,i)=>{"use strict";i.d(e,{Z:()=>r});var n=i(537),o=i.n(n),a=i(645),s=i.n(a)()(o());s.push([t.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:(t,e,i)=>{"use strict";i.d(e,{Z:()=>r});var n=i(537),o=i.n(n),a=i(645),s=i.n(a)()(o());s.push([t.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:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var i="",n=void 0!==e[5];return e[4]&&(i+="@supports (".concat(e[4],") {")),e[2]&&(i+="@media ".concat(e[2]," {")),n&&(i+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),i+=t(e),n&&(i+="}"),e[2]&&(i+="}"),e[4]&&(i+="}"),i})).join("")},e.i=function(t,i,n,o,a){"string"==typeof t&&(t=[[null,t,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<t.length;c++){var u=[].concat(t[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)),e.push(u))}},e}},537:t=>{"use strict";t.exports=function(t){var e=t[1],i=t[3];if(!i)return e;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[e].concat([a]).join("\n")}return[e].join("\n")}},379:t=>{"use strict";var e=[];function i(t){for(var i=-1,n=0;n<e.length;n++)if(e[n].identifier===t){i=n;break}return i}function n(t,n){for(var a={},s=[],r=0;r<t.length;r++){var l=t[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)e[p].references++,e[p].updater(m);else{var h=o(m,n);n.byIndex=r,e.splice(r,0,{identifier:d,updater:h,references:1})}s.push(d)}return s}function o(t,e){var i=e.domAPI(e);return i.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;i.update(t=e)}else i.remove()}}t.exports=function(t,o){var a=n(t=t||[],o=o||{});return function(t){t=t||[];for(var s=0;s<a.length;s++){var r=i(a[s]);e[r].references--}for(var l=n(t,o),c=0;c<a.length;c++){var u=i(a[c]);0===e[u].references&&(e[u].updater(),e.splice(u,1))}a=l}}},569:t=>{"use strict";var e={};t.exports=function(t,i){var n=function(t){if(void 0===e[t]){var i=document.querySelector(t);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(t){i=null}e[t]=i}return e[t]}(t);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:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},565:(t,e,i)=>{"use strict";t.exports=function(t){var e=i.nc;e&&t.setAttribute("nonce",e)}},795:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(i){!function(t,e,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))))," */")),e.styleTagTransform(n,t,e.options)}(e,t,i)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},589:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}}},e={};function i(n){var o=e[n];if(void 0!==o)return o.exports;var a=e[n]={id:n,exports:{}};return t[n](a,a.exports,i),a.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.nc=void 0;var n={};(()=>{"use strict";i.r(n),i.d(n,{_package:()=>Pt,demoFileIngest:()=>Ht,demoFileIngest1:()=>Mt,demoFileIngest2:()=>Rt,demoFileSubmit:()=>Ut,gasteigerCellRenderer:()=>$t,hitDesignApp:()=>Dt,hitDesignAppTreeBrowser:()=>Lt,hitTriageApp:()=>Vt,hitTriageAppTreeBrowser:()=>kt});const t=grok,e=DG,o=ui,a="campaignId",s="campaignId",r="HitTriageDataSource",l="HitTriageSubmitFunction",c="Selected hits",u="Stage",d="Molecule",p="V-iD",m="V######",h="HTScript",f="HTQuery",v="molecules",g="Source",y="New template",w="Start",b="Create",C="Download",A="Cancel",T="Continue a campaign",x="New campaign";var S=i(379),I=i.n(S),N=i(795),E=i.n(N),_=i(569),F=i.n(_),B=i(565),O=i.n(B),P=i(216),k=i.n(P),V=i(589),L=i.n(V),j=i(631),D={};D.styleTagTransform=L(),D.setAttributes=O(),D.insert=F().bind(null,"head"),D.domAPI=E(),D.insertStyleElement=k(),I()(j.Z,D),j.Z&&j.Z.locals&&j.Z.locals;var H=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};const M=t=>`${t.getFullYear()}/${t.getMonth()+1}/${t.getDate()}`;function R(t,e){const i=document.title,n=window.location.href.split("?")[0]+"?"+t+"="+e;if(history.replaceState){const t={Title:i,Url:n};history.replaceState(t,t.Title,t.Url)}}function U(e,i,n,a){var s;const r=o.breadcrumbs([i,n]),l=r.onPathClick.subscribe((t=>{1===t.length&&(l.unsubscribe(),$(e),a())})),c=null===(s=t.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 $(t){const e=t.getRibbonPanels();(null==e?void 0:e.length)&&(e.pop(),t.setRibbonPanels(e))}function q(t){return t.reduce(((t,e)=>t||e.reduce(((t,e)=>t||e.classList.contains("hit-design-submit-button")||Array.from(e.children).some((t=>t.classList.contains("hit-design-submit-button")))),!1)),!1)}function Y(t,i,n){return H(this,void 0,void 0,(function*(){if(0===n.rowCount)return;if(!t.col(i))throw new Error("There is no molecule column in dataframe");let o=n.col(v);if(o||(yield n.meta.detectSemanticTypes(),o=n.columns.bySemType(e.SEMTYPE.MOLECULE)),!o)throw new Error("There is no original molecule column in query result dataframe");const a=n.columns.names().filter((t=>t!==v));t.join(n,[i],[o.name],void 0,a,void 0,!0)}))}function W(t,e){return H(this,void 0,void 0,(function*(){const i=(yield Pt.files.list(`${t}/campaigns`)).filter((t=>-1===e.indexOf(t.name))),n={};for(const e of i)try{const i=JSON.parse(yield Pt.files.readAsText(`${t}/campaigns/${e.name}/campaign.json`));n[i.name]=i}catch(t){continue}return n}))}const J={String:e.TYPE.STRING,Number:e.TYPE.FLOAT,Boolean:e.TYPE.BOOL,Date:e.TYPE.DATE_TIME,Molecule:e.SEMTYPE.MOLECULE};var G=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))},Z=i(553),z=i.n(Z);function Q(i,n,a,s,r){var l,c,u,d,p,m,v,g,y,w,b,C,A,T,x,S,I,N,E,_,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:t})=>t.length>2&&"dataframe"===t[0].propertyType&&"column"===t[1].propertyType)).map((t=>{var e,i,n,o;return{package:t.package.name,name:t.name,args:null!==(o=null===(n=null===(i=null===(e=null==s?void 0:s.compute)||void 0===e?void 0:e.functions)||void 0===i?void 0:i.find((e=>e.name===t.name&&e.package===t.package.name)))||void 0===n?void 0:n.args)&&void 0!==o?o:{}}})),H=j.scripts.filter((({inputs:t})=>t.length>=2&&"dataframe"===t[0].propertyType&&"column"===t[1].propertyType)).map((t=>{var e,i,n,o;return{name:t.name,id:t.id,args:null!==(o=null===(n=null===(i=null===(e=null==s?void 0:s.compute)||void 0===e?void 0:e.scripts)||void 0===i?void 0:i.find((e=>e.id===t.id)))||void 0===n?void 0:n.args)&&void 0!==o?o:{}}})),M=j.queries.filter((t=>t.inputs.length>0&&"list"===t.inputs[0].propertyType)).map((t=>{var e,i,n,o,a;return{name:null!==(e=t.friendlyName)&&void 0!==e?e:t.name,id:t.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((e=>e.id===t.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 t.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(t,e){const i=e.group(t,null,!1);return i.enableCheckBox(!1),i}const J=Object.keys(U),G=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 t of J){const e=W(t,$);for(const i of U[t].descriptors){const t=e.item(i.name,i);Y.push(t),t.enableCheckBox(G.includes(i.name))}}const Z="Descriptors",Q={[Z]:Z},K=R?{[Z]:$.root}:{},X={},tt={[Z]:!1};tt.Descriptors=!!(null===(v=null===(m=null==s?void 0:s.compute)||void 0===m?void 0:m.descriptors)||void 0===v?void 0:v.enabled)&&(null===(w=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===w?void 0:w.length)>0;for(const t of D)try{const i=e.Func.find({package:t.package,name:t.name})[0],n=i.prepare(t.args),a=`${t.package}:${t.name}`;X[a]=n;const r=o.div(),l=yield n.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",r.style.removeProperty("max-width"),K[null!==(b=i.friendlyName)&&void 0!==b?b:i.name]=r,Q[null!==(C=i.friendlyName)&&void 0!==C?C:i.name]=a,tt[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((e=>e.name===t.name&&e.package===t.package)))&&void 0!==x&&x,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(t){console.error(t);continue}for(const e of H)try{const i=yield t.dapi.scripts.find(e.id),n=i.prepare(e.args),a=`HTScript:${null!==(S=e.name)&&void 0!==S?S:""}:${e.id}`;X[a]=n;const r=o.div(),l=yield n.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",r.style.removeProperty("max-width"),K[null!==(I=i.friendlyName)&&void 0!==I?I:i.name]=r,Q[null!==(N=i.friendlyName)&&void 0!==N?N:i.name]=a,tt[a]=null!==(F=null===(_=null===(E=null==s?void 0:s.compute)||void 0===E?void 0:E.scripts)||void 0===_?void 0:_.some((t=>t.id===e.id)))&&void 0!==F&&F,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(t){console.error(t);continue}for(const e of M)try{const i=yield t.dapi.queries.find(e.id),n=i.prepare(e.args),a=`HTQuery:${null!==(B=e.name)&&void 0!==B?B:""}:${e.id}`;X[a]=n;const r=o.div(),l=yield n.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",r.style.removeProperty("max-width"),K[null!==(O=i.friendlyName)&&void 0!==O?O:i.name]=r,Q[null!==(P=i.friendlyName)&&void 0!==P?P:i.name]=a,tt[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((t=>t.id===e.id)))&&void 0!==L&&L,r.children[0].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(t){console.error(t);continue}const et=o.tabControl(K,!0);function it(){const t={descriptors:[],externals:{},scripts:{},queries:{}};t.descriptors=tt.Descriptors?Y.filter((t=>t.checked)).map((t=>t.value.name)):[];const e=Object.entries(X).filter((([t,e])=>tt[t]));e.filter((([t,e])=>!t.startsWith(h)&&!t.startsWith(f))).forEach((([e,i])=>{t.externals[e]={};const n=i.inputs;Object.entries(n).slice(2).forEach((([i,n])=>{t.externals[e][i]=n}))})),e.filter((([t,e])=>t.startsWith(h))).forEach((([e,i])=>{t.scripts[e]={};const n=i.inputs;Object.entries(n).slice(2).forEach((([i,n])=>{t.scripts[e][i]=n}))})),e.filter((([t,e])=>t.startsWith(f))).forEach((([e,i])=>{t.queries[e]={};const n=i.inputs;Object.entries(n).slice(1).forEach((([i,n])=>{t.queries[e][i]=n}))})),console.log(t),n(t)}return et.onTabChanged.subscribe((()=>{try{et.currentPane.content.style.removeProperty("max-width")}catch(t){}})),et.header.style.overflow="scroll",et.root.style.width="100%",et.root.style.minWidth="350px",q.appendChild(et.root),et.panes.forEach((t=>{const e=o.boolInput("",tt[Q[t.name]],(i=>{tt[Q[t.name]]=!!e.value,i?z()(t.content).find("input").removeAttr("disabled"):z()(t.content).find("input").attr("disabled","true")}));e.setTooltip("Toggle calculation of this function"),t.header.appendChild(e.root),t.header.classList.add("hit-triage-compute-dialog-pane-header")})),r&&o.dialog("Compute").add(q).onOK((()=>it())).onCancel(a).show(),{root:q,okProxy:it}},new((H=void 0)||(H=Promise))((function(t,e){function i(t){try{o(M.next(t))}catch(t){e(t)}}function n(t){try{o(M.throw(t))}catch(t){e(t)}}function o(e){var o;e.done?t(e.value):(o=e.value,o instanceof H?o:new H((function(t){t(o)}))).then(i,n)}o((M=M.apply(j,D||[])).next())}))}const K=rxjs;class X{constructor(t,e=[],i={}){this.onItemChanged=new K.Subject,this.onAddingItemChanged=new K.Subject,this.onItemAdded=new K.Subject,this.onItemRemoved=new K.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.properties=t,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=e,this.render()}get root(){return this._root}get items(){return this._items}render(){var t,e,i,n;if(o.empty(this._root),!this.options.horizontalInputNames)for(const e of this.properties){const i=o.divText(null!==(t=e.caption)&&void 0!==t?t:e.name);i.style.fontWeight="bold",this._root.appendChild(i)}for(const t of this._items){const e=this.getItemDiv(t);for(const t of e)this._root.appendChild(t)}if(this.options.allowAdd){const t=this.getItemDiv(null!==(n=null===(i=(e=this.options).newItemFunction)||void 0===i?void 0:i.call(e))&&void 0!==n?n:void 0,!0);for(const e of t)this._root.appendChild(e)}}getItemDiv(t={},i){var n;const a=[],s={};let r=null;for(const l of this.properties){void 0===t[l.name]&&(t[l.name]=null);const c=(null===(n=this.options.customInputs)||void 0===n?void 0:n[l.name])?this.options.customInputs[l.name](t):o.input.forProperty(l,t);a.push(this.options.horizontalInputNames?c.root:this.hideLabel(c.root)),l.propertyType!==e.TYPE.BOOL&&"color"!==l.name.toLowerCase()&&c.input&&(c.input.style.width="100%"),s[l.name]=c,c.onChanged((()=>{t[l.name]=c.value,i?this.onAddingItemChanged.next({item:t,fieldName:l.name}):this.onItemChanged.next({item:t,fieldName:l.name})})),c.root.style.alignItems="center",r=c}let l=null;if(i)l=o.icons.add((()=>{const t=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(s).forEach((e=>{t[e]=s[e].value})),this._items.push(t),this.onItemAdded.next(t),this.render()}),this.options.addButtonTooltip);else{if(!this.options.allowRemove)return a;l=o.icons.delete((()=>{this._items.splice(this._items.indexOf(t),1),this.onItemRemoved.next(t),this.render()}),this.options.removeButtonTooltip)}return r&&r.addOptions?r.addOptions(l):null==r||r.root.appendChild(l),l.style.color="#2083d5",a}hideLabel(t){return t.getElementsByTagName("label")[0]&&t.removeChild(t.getElementsByTagName("label")[0]),t}}function tt(){const t=e.Property.fromOptions({name:"layout",caption:"Layout",type:"file"}),i=e.InputBase.forProperty(t);let n=null,o=null,a=null;return i.addValidator((t=>a)),i.onChanged((()=>{return t=this,s=void 0,l=function*(){const t=i.value;if(t)try{const i=yield t.readAsString(),s=e.ViewLayout.fromJson(i);s?(n=s,o=s.viewState,a=null):(n=null,o=null,a="Invalid layout file")}catch(t){n=null,o=null,a="Invalid layout file"}i.setTooltip("Select a layout file")},new((r=void 0)||(r=Promise))((function(e,i){function n(t){try{a(l.next(t))}catch(t){i(t)}}function o(t){try{a(l.throw(t))}catch(t){i(t)}}function a(t){var i;t.done?e(t.value):(i=t.value,i instanceof r?i:new r((function(t){t(i)}))).then(n,o)}a((l=l.apply(t,s||[])).next())}));var t,s,r,l})),{dataFileInput:i,getLayout:()=>n,getLayoutViewState:()=>o}}var et=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};function it(i,n){var a,s;return et(this,void 0,void 0,(function*(){const c=(yield Pt.files.list("Hit Triage/templates")).map((t=>t.name.slice(0,-5))),u=[];for(const t of c){const e=JSON.parse(yield Pt.files.readAsText(`Hit Triage/templates/${t}.json`));u.push(e.key)}const d=e.Func.find({tags:[l]}),p={};d.forEach((t=>{var e;p[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t}));const m=o.choiceInput("Submit function",null,[null,...Object.keys(p)]);m.value=null,m.nullable=!0,m.fireChanged(),m.setTooltip("Select function to be called upon submitting");const v=tt(),y=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"}),C=o.stringInput("Name","",(()=>{""===C.value||c.includes(C.value)?(C.root.style.borderBottom="1px solid red",y.style.opacity="100%"):(C.root.style.borderBottom="none",y.style.opacity="0%")})),T=o.stringInput("Key","",(()=>{""===T.value||u.includes(T.value)?(T.root.style.borderBottom="1px solid red",w.style.opacity="100%"):(T.root.style.borderBottom="none",w.style.opacity="0%")}));T.setTooltip("Template key used for campaign prefix"),C.setTooltip("Template name"),C.root.style.borderBottom="none",T.root.style.borderBottom="none",y.style.opacity="0%",w.style.opacity="0%";let x=null;const S=yield Q(i,(t=>{x=t}),(()=>null),{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},!1);if(S.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(n).length){const i=e.Func.find({tags:[r]}),o=yield t.dapi.queries.include("params,connection").filter("#HitTriageDataSource").list();i.forEach((t=>{var e;n[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t})),o.forEach((t=>{var e;n[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t}))}const I=Object.keys(n),N=o.choiceInput(g,I[0],I),E=o.choiceInput("Ingest using","Query",["Query","File"],(()=>{"Query"!==E.value?N.root.style.display="none":N.root.style.display="block"})),_=nt(),F=o.div([o.h2("Details"),o.div([C,y]),o.div([T,w]),E.root,N.root,v.dataFileInput,_.fieldsDiv,o.h2("Compute"),S.root,o.h2("Submit"),m.root],"ui-form"),B=o.buttonsInput([]),O=null!==(s=null===(a=B.getElementsByClassName("ui-input-editor"))||void 0===a?void 0:a[0])&&void 0!==s?s:B;F.appendChild(B);const P=new Promise((t=>{const e=o.button(A,(()=>t()));O.appendChild(e)})),k=new Promise((e=>{const i=o.bigButton(b,(()=>function(){var i,n,o,a,s,r,l,c;return et(this,void 0,void 0,(function*(){if(S.okProxy(),"100%"===y.style.opacity)return void t.shell.error("Template name is empty or already exists");const u=m.value?p[m.value]:void 0,d=Object.assign(Object.assign({name:C.value,key:T.value,campaignFields:_.getFields(),dataSourceType:null!==(i=E.value)&&void 0!==i?i:"Query",layoutViewState:null!==(n=v.getLayoutViewState())&&void 0!==n?n:void 0,compute:{descriptors:{enabled:!!(null===(o=null==x?void 0:x.descriptors)||void 0===o?void 0:o.length),args:null!==(a=null==x?void 0:x.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(s=null==x?void 0:x.externals)&&void 0!==s?s:{}).map((([t,e])=>{const i=t.split(":");return{name:i[1],package:i[0],args:e}})),scripts:Object.entries(null!==(r=null==x?void 0:x.scripts)&&void 0!==r?r:{}).filter((([t,e])=>t.startsWith(h)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}})),queries:Object.entries(null!==(l=null==x?void 0:x.queries)&&void 0!==l?l:{}).filter((([t,e])=>t.startsWith(f)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}}))}},u?{submit:{fName:u.name,package:u.package.name}}:{}),{queryFunctionName:"Query"===E.value&&null!==(c=N.value)&&void 0!==c?c:void 0});var g;g=d,Pt.files.writeAsText(`Hit Triage/templates/${g.name}.json`,JSON.stringify(g)),t.shell.info("Template created successfully"),e(d)}))}()));O.appendChild(i)}));return{root:F,template:k,cancelPromise:P}}))}function nt(t){const i=[e.Property.fromOptions({name:"Name",type:e.TYPE.STRING}),e.Property.fromOptions({name:"Type",type:e.TYPE.STRING,choices:Object.keys(J)}),e.Property.fromOptions({name:"Required",type:e.TYPE.BOOL})],n=new X(i,t?t.map((t=>({Name:t.name,Type:t.type,Required:t.required}))):void 0,{horizontalInputNames:!1});n.root.style.maxWidth="750px";let a={};n.onItemAdded.subscribe((t=>{a={}})),n.onAddingItemChanged.subscribe((t=>{t&&(a=t.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 t;const e=n.items.filter((t=>t.Name)).map((t=>{var e;return{name:t.Name,type:t.Type,required:null!==(e=t.Required)&&void 0!==e&&e}}));return a.Name&&""!==a.Name&&a.Type&&(null!==(t=a.Required)&&void 0!==t||(a.Required=!1),e.push({name:a.Name,type:a.Type,required:a.Required})),e},fieldsDiv:o.div([r])}}var ot=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class at extends e.ViewBase{constructor(t){super(),this.deletedCampaigns=[],this.app=t}get template(){return this.app.template}onActivated(){}onReset(){}process(){return ot(this,void 0,void 0,(function*(){}))}deleteCampaign(t,e){return ot(this,void 0,void 0,(function*(){yield Pt.files.delete(`${t}/campaigns/${e}`)}))}}var st=i(290),rt={};rt.styleTagTransform=L(),rt.setAttributes=O(),rt.insert=F().bind(null,"head"),rt.domAPI=E(),rt.insertStyleElement=k(),I()(st.Z,rt),st.Z&&st.Z.locals&&st.Z.locals;var lt;!function(e){let i,n;!function(t){t.vert=function(t){return o.divV(t.map((t=>o.render(t))),{classes:"u2-panel"})},t.horz=function(t){return o.divH(t.map((t=>o.render(t))),{classes:"u2-panel"})}}(i=e.panels||(e.panels={})),e.appHeader=function(t){const e=o.iconImage("",t.iconPath);return z()(e).addClass("ui-app-header-icon").css("margin-right","20px"),i.horz([e,i.vert([o.markdown(t.description),t.learnMoreUrl?o.link("Learn more",t.learnMoreUrl):null])])},function(e){e.runAsync=function(e,i){return n=this,a=void 0,r=function*(){o.setUpdateIndicator(e,!0);try{return yield i()}catch(e){t.log.error(e)}finally{o.setUpdateIndicator(e,!1)}},new((s=void 0)||(s=Promise))((function(t,e){function i(t){try{l(r.next(t))}catch(t){e(t)}}function o(t){try{l(r.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof s?n:new s((function(t){t(n)}))).then(i,o)}l((r=r.apply(n,a||[])).next())}));var n,a,s,r}}(n=e.tools||(e.tools={}))}(lt||(lt={}));var ct=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class ut extends at{constructor(e){super(e),this.readmePath=Pt.webRoot+"README_HT.md",this.dataSourceFunctionsMap={},this.name="Hit Triage",t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(this.readmePath),this.checkCampaign().then((t=>{this.app.campaign=t,this.init()}))}onActivated(){t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(this.readmePath)}init(t){return ct(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const e=o.h1(T),i=o.h1(x,{style:{marginLeft:"10px"}}),n=lt.appHeader({iconPath:Pt.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,t),z()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,e],{style:{marginLeft:"10px"}}),r,i,s,a])),this.app.resetBaseUrl()}catch(t){throw o.setUpdateIndicator(this.root,!1),t}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(t,e,i){var n;return ct(this,void 0,void 0,(function*(){const a=(yield Pt.files.list("Hit Triage/templates")).map((t=>t.name.slice(0,-5)));i&&!a.includes(i.name)&&a.push(i.name);const s=()=>ct(this,void 0,void 0,(function*(){const e=r.value,n=i&&i.name===e?i:JSON.parse(yield Pt.files.readAsText("Hit Triage/templates/"+e+".json")),o=yield this.getNewCampaignAccordeon(n,t);z()(t).empty(),t.className="ui-form",t.appendChild(o)})),r=o.choiceInput("Template",null!==(n=null==i?void 0:i.name)&&void 0!==n?n:a[0],a,(()=>ct(this,void 0,void 0,(function*(){yield s()})))),l=o.icons.add((()=>ct(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),o.setUpdateIndicator(this.root,!1)}))),y);r.addOptions(l),yield s(),z()(e).empty(),e.appendChild(r.root)}))}checkCampaign(t){return ct(this,void 0,void 0,(function*(){const e=location.search,i=new URLSearchParams(e);if(!i.has(a)&&!t)return;const n=null!=t?t:i.get(a);if(!(yield Pt.files.exists(`Hit Triage/campaigns/${n}/campaign.json`)))return;const o=JSON.parse(yield Pt.files.readAsText(`Hit Triage/campaigns/${n}/campaign.json`)),s=JSON.parse(yield Pt.files.readAsText(`Hit Triage/templates/${o.templateName}.json`));return this.app.setTemplate(s,o.filters,n,o.ingest),t&&R(a,t),o}))}getCampaignsTable(){return ct(this,void 0,void 0,(function*(){const t=yield W("Hit Triage",this.deletedCampaigns),e=Object.values(t).map((t=>({name:t.name,createDate:t.createDate,rowCount:t.rowCount,filtered:t.filteredRowCount,status:t.status}))),i=o.table(e,(t=>[o.link(t.name,(()=>this.setCampaign(t.name)),"",""),t.createDate,t.rowCount,t.filtered,t.status,o.icons.delete((()=>ct(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${t.name}?`)).onOK((()=>ct(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Triage",t.name),this.deletedCampaigns.push(t.name),yield this.init()})))).show()}))),"Delete campaign")]),["Name","Created","Total","Selected","Status",""]);return i.style.color="var(--grey-5)",i}))}setCampaign(t){return ct(this,void 0,void 0,(function*(){const e=yield this.checkCampaign(t);this.app.campaign=e}))}getNewCampaignAccordeon(i,n){return ct(this,void 0,void 0,(function*(){o.setUpdateIndicator(n,!0);const{root:a,promise:s,cancelPromise:l}=yield function(i,n){var a,s;return G(this,void 0,void 0,(function*(){const l=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(e.SEMTYPE.MOLECULE))return void(l.innerText="No molecules column found");l.innerText=""}catch(t){l.innerText="Error parsing file"}})),d=o.tableInput("Dataframe",null,void 0,u);yield u();const p=o.div([d,l]);0===Object.keys(n).length&&(e.Func.find({tags:[r]}).forEach((t=>{var e;n[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t})),(yield t.dapi.queries.include("params,connection").filter("#HitTriageDataSource").list()).forEach((t=>{var e;n[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t})));let m=null;const h=()=>G(this,void 0,void 0,(function*(){const t=n[v.value];m=t.prepare();const e=yield m.getEditor();e.classList.remove("ui-form"),f.innerHTML="",f.appendChild(e)})),f=o.div([]),v=o.choiceInput(g,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 y=o.div([v,f]);y.style.display="none";const b=o.div([p,y]),C=i.campaignFields.map((t=>t.type===e.SEMTYPE.MOLECULE?Object.assign(Object.assign({},t),{type:"String",semtype:e.SEMTYPE.MOLECULE}):t)).map((t=>e.Property.fromOptions(Object.assign({name:t.name,type:J[t.type],nullable:!t.required},t.semtype?{semType:t.semtype}:{})))),T={},x=C.length?o.input.form(T,C):o.div();x.classList.remove("ui-form"),"File"===i.dataSourceType?(p.style.display="inherit",y.style.display="none"):(p.style.display="none",y.style.display="inherit");const S=o.div([b,...C.length?[x]:[]]),I=o.buttonsInput([]);return S.appendChild(I),{promise:new Promise((e=>{const a=()=>G(this,void 0,void 0,(function*(){if("File"===i.dataSourceType){if(!c)return void t.shell.error("No file selected");const i=c;i.name=c.name,e({df:i,type:"File",campaignProps:T})}else{const i=n[v.value];if(!i)return void t.shell.error("No function selected");const o={};Object.entries(m.inputs).forEach((([t,e])=>{o[t]=e}));const a=yield i.apply(o);e({df:a,type:"Query",campaignProps:T})}})),s=o.bigButton(w,(()=>a()));I.appendChild(s)})),root:S,cancelPromise:new Promise((t=>{o.button(A,(()=>t()))}))}}))}(i,this.dataSourceFunctionsMap);return o.setUpdateIndicator(n,!1),s.then((t=>ct(this,void 0,void 0,(function*(){this.app.dataFrame=t.df,this.app._fileInputType=t.type,yield this.app.setTemplate(i),this.app.campaignProps=t.campaignProps,yield this.app.saveCampaign(void 0,!1),i.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=i.layoutViewState)})))),l.then((()=>{this.init()})),a}))}createNewTemplate(){return ct(this,void 0,void 0,(function*(){const i=yield it(this.app,this.dataSourceFunctionsMap),n=new e.ViewBase,o=t.shell.v;n.name="New Template",n.root.appendChild(i.root),n.parentCall=this.app.parentCall,t.shell.addView(n),n.path=new URL(this.app.baseUrl).pathname+"/new-template",n.parentView=o;const{sub:a}=U(t.shell.v,"Hit Triage",y,(()=>{t.shell.v=o,n.close()}));i.template.then((e=>ct(this,void 0,void 0,(function*(){yield this.init(e),n.close(),$(n),t.shell.v=o,a.unsubscribe()})))),i.cancelPromise.then((()=>{a.unsubscribe(),n.close(),t.shell.v=o}))}))}}class dt extends at{constructor(t){super(t),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=e.Func.find({name:n.fName,package:n.package})[0];if(!o)return void t.shell.error(`Function ${n.fName} not found.`);const a=e.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"),t.shell.info("Submitted successfully.")},new((a=void 0)||(a=Promise))((function(t,e){function i(t){try{l(s.next(t))}catch(t){e(t)}}function r(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof a?n:new a((function(t){t(n)}))).then(i,r)}l((s=s.apply(n,o||[])).next())}))}}var pt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class mt{constructor(i){this.parentCall=i,this.isJoining=!1,this.resetBaseUrl(),this.computeFunctions=new Promise((i=>pt(this,void 0,void 0,(function*(){const n=e.Func.find({tags:["HitTriageFunction"]}).filter((t=>"function-package"===t.type)),o=yield t.dapi.scripts.include("params").filter("#HitTriageFunction").list(),a=yield t.dapi.queries.include("params,connection").filter("#HitTriageFunction").list();i({functions:n,scripts:o,queries:a})}))))}resetBaseUrl(){const t=window.location.href,e=new URL(t);this.baseUrl=e.origin+e.pathname}getFilterType(t){const i=this.dataFrame.col(t);return(null==i?void 0:i.semType)===e.SEMTYPE.MOLECULE?e.FILTER_TYPE.SUBSTRUCTURE:(null==i?void 0:i.type)===e.COLUMN_TYPE.BOOL?e.FILTER_TYPE.BOOL_COLUMNS:(null==i?void 0:i.type)===e.COLUMN_TYPE.STRING?e.FILTER_TYPE.CATEGORICAL:e.FILTER_TYPE.HISTOGRAM}download(t,i,n=!1){const o=document.createElement("a"),a=e.DataFrame.fromColumns(t.columns.toList().filter((t=>!t.name.startsWith("~")))).toCsv({filteredRowsOnly:n});o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),o.setAttribute("download",i+".csv"),o.click()}getNewCampaignName(t,e){return pt(this,void 0,void 0,(function*(){const i=(yield Pt.files.list(t)).map((t=>t.name)).filter((t=>t.startsWith(e)));if(0===i.length)return e+"-1";const n=i.map((t=>t.split("-")[1])).filter(Boolean).map((t=>parseInt(t,10))).sort();return e+"-"+(n[n.length-1]+1).toString()}))}setBaseUrl(){const t=document.title;if(history.replaceState){const e={Title:t,Url:this.baseUrl};history.replaceState(e,e.Title,e.Url)}}unionDataframes(t,i,n){var o,a,s,r,l;const c=null===(a=null===(o=t.col(n))||void 0===o?void 0:o.toList())||void 0===a?void 0:a.filter((t=>!!t)).map((t=>e.chem.convert(t,e.chem.Notation.Unknown,e.chem.Notation.Smiles))),u=null===(r=null===(s=i.col(n))||void 0===s?void 0:s.toList())||void 0===r?void 0:r.filter((t=>!!t)).map((t=>e.chem.convert(t,e.chem.Notation.Unknown,e.chem.Notation.Smiles)));if(!c||!u)throw new Error("Molecule column not found");this.isJoining=!0;try{for(const e of t.columns)i.columns.contains(e.name)||i.columns.addNew(e.name,e.type);for(let e=0;e<c.length;e++)if(!u.includes(c[e])){i.rows.addNew(null,!0);for(const n of t.columns){const t=n.get(e);null===(l=i.col(n.name))||void 0===l||l.set(i.rowCount-1,t,!1)}}}finally{setTimeout((()=>{this.isJoining=!1}),500)}return i}}var ht=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))},ft=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};function vt(t){let e=0;if(t.length>1)for(const i of t.toList()){if(!i||!i.startsWith(m[0])||i.length!==m.length)continue;const t=parseInt(i.substring(1));isNaN(t)||(e=Math.max(t,e))}return`V${"".concat(...new Array(m.length-1-(e+1).toString().length).fill("0"))}${e+1}`}function gt(i,n,o){var a,s;return ft(this,void 0,void 0,(function*(){const r=e.TaskBarProgressIndicator.create("Calculating ..."),l=n.col(o);if(!l)throw new Error("There is no molecule column in dataframe");for(let e=0;e<l.length;e++){if(l.isNone(e))continue;const i=l.get(e);if(!i)continue;const n=t.chem.convert(i,t.chem.Notation.Unknown,t.chem.Notation.Smiles);l.set(e,n,!1)}i.descriptors&&i.descriptors.length>0&&(yield t.chem.descriptors(n,o,i.descriptors));for(const t of Object.keys(i.externals))try{const a=i.externals[t],s=e.Func.find({package:t.split(":")[0],name:t.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})))}catch(t){console.error(t)}for(const e of Object.keys(null!==(a=i.scripts)&&void 0!==a?a:{})){const a=i.scripts[e];if(a){const i=e.split(":")[2];if(!i)continue;try{const e=yield t.dapi.scripts.find(i);if(!e)continue;const s=e.inputs[0].name,r=e.inputs[1].name,l=yield e.apply(Object.assign(Object.assign({},a),{[s]:n,[r]:o}));if(l&&l.rowCount===n.rowCount&&"python"===e.language)for(const t of l.columns)t.name=n.columns.getUnusedName(t.name),n.columns.add(t)}catch(t){console.error(t)}}}for(const e of Object.keys(null!==(s=i.queries)&&void 0!==s?s:{})){const a=i.queries[e];if(a){const i=e.split(":")[2];if(!i)continue;try{const e=yield t.dapi.queries.find(i);if(!e)continue;const s=e.inputs[0].name,r=n.col(o).toList(),l=yield e.apply(Object.assign(Object.assign({},a),{[s]:r}));l&&(yield Y(n,o,l))}catch(t){console.error(t)}}}r.close()}))}var yt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class wt extends mt{constructor(i){super(i),this._filterViewName="Hit triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=new ut(this),this.multiView=new e.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((t=>{this.multiView.currentView instanceof at&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,t.events.onCurrentViewChanged.subscribe((()=>{var e,i,n,o;try{(null===(e=t.shell.v)||void 0===e?void 0:e.name)===this.currentPickViewId&&(t.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(t){console.error(t)}}))}get infoView(){return this._infoView}setTemplate(i,n,o,s){var r,l,c,u,d,p,m,h,f,v,g,y,w,b,C;return yt(this,void 0,void 0,(function*(){if((null===(r=this._pickView)||void 0===r?void 0:r.dataFrame)&&t.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 t.dapi.files.readCsv(s.query):this.dataFrame=yield t.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((([t,e])=>{const i=this.dataFrame.columns.byName(t);i&&i.semType!==e&&(i.semType=e)})),(null===(u=this._campaign)||void 0===u?void 0:u.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach((([t,e])=>{const i=this.dataFrame.columns.byName(t);if(i&&i.type!==e)try{i.convertTo(e)}catch(t){console.error(t)}})),yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(p=null===(d=this.dataFrame.columns.bySemType(e.SEMTYPE.MOLECULE))||void 0===d?void 0:d.name)&&void 0!==p?p:void 0,this._dfName=null!==(m=this.dataFrame.name)&&void 0!==m?m:null==s?void 0:s.query,this.dataFrame.name=null!==(f=null!==(h=this._dfName)&&void 0!==h?h:this.dataFrame.name)&&void 0!==f?f:"Molecules",this._campaignId=o,this.template=(null===(v=this.campaign)||void 0===v?void 0:v.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:i.dataSourceType,queryFunctionName:i.queryFunctionName}):i,this._campaignFilters=n,!n){const t={},e={},n={};i.compute.functions.forEach((e=>{const i=`${e.package}:${e.name}`;t[i]=e.args})),null===(g=i.compute.scripts)||void 0===g||g.forEach((t=>{const i=`HTScript:${t.name}:${t.id}`;e[i]=t.args})),null===(y=i.compute.queries)||void 0===y||y.forEach((t=>{const e=`HTQuery:${t.name}:${t.id}`;n[e]=t.args})),yield gt({descriptors:i.compute.descriptors.enabled?i.compute.descriptors.args:[],externals:t,scripts:e,queries:n},this.dataFrame,this._molColName)}const A=t.shell.v,T=t.shell.addView(this.pickView);this.currentPickViewId=T.name,this._submitView=new dt(this),this.setBaseUrl(),R(a,null!==(C=null!==(w=this._campaignId)&&void 0!==w?w:null===(b=this._campaign)||void 0===b?void 0:b.name)&&void 0!==C?C:"");const x=T;setTimeout((()=>{this._pickViewPromise&&this._pickViewPromise.then((()=>{const{sub:e}=U(x,"Hit Triage","Pick",(()=>{t.shell.v=A,x.close(),e.unsubscribe()}))}))}),300),t.shell.windows.showHelp=!1}))}get filterSettings(){return this._campaignFilters}get campaignId(){return this._campaignId}get pickView(){return this._pickView=this.getFilterView()}get molColName(){var t,i,n;return null!==(t=this._molColName)&&void 0!==t?t:this._molColName=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(e.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name}get fileInputType(){return this._fileInputType}get campaign(){return this._campaign}set campaign(t){this._campaign=t}getFilterView(){let t=null;this._pickViewPromise=new Promise((e=>{t=e})),this.dataFrame.col(c)||this.dataFrame.columns.addNewBool(c).init(!1);const i=e.TableView.create(this.dataFrame,!1),n=i.getRibbonPanels(),a=o.iconFA("wrench",(()=>yt(this,void 0,void 0,(function*(){Q(this,(t=>yt(this,void 0,void 0,(function*(){var e,i,n,o,a,s,r;const l=this.template.compute.descriptors.args,c=this.template.compute.functions,u=null!==(e=this.template.compute.scripts)&&void 0!==e?e:[],d=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],p=t.descriptors,m={descriptors:{enabled:!!(null===(n=null==t?void 0:t.descriptors)||void 0===n?void 0:n.length),args:null!==(o=null==t?void 0:t.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(a=null==t?void 0:t.externals)&&void 0!==a?a:{}).map((([t,e])=>{const i=t.split(":");return{name:i[1],package:i[0],args:e}})),scripts:Object.entries(null!==(s=null==t?void 0:t.scripts)&&void 0!==s?s:{}).filter((([t,e])=>t.startsWith(h)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}})),queries:Object.entries(null!==(r=null==t?void 0:t.queries)&&void 0!==r?r:{}).filter((([t,e])=>t.startsWith(f)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}}))};this.template.compute=m;const v=p.filter((t=>!l.includes(t))),g=m.functions.filter((t=>{if(!c.some((e=>e.name===t.name&&e.package===t.package)))return!0;const e=c.find((e=>e.name===t.name&&e.package===t.package));return!Object.entries(t.args).every((([t,i])=>e.args[t]===i))})),y=m.scripts.filter((t=>{if(!u.some((e=>e.id===t.id)))return!0;const e=u.find((e=>e.id===t.id));return!Object.entries(t.args).every((([t,i])=>e.args[t]===i))})),w=m.queries.filter((t=>{if(!d.some((e=>e.id===t.id)))return!0;const e=d.find((e=>e.id===t.id));return!Object.entries(t.args).every((([t,i])=>e.args[t]===i))})),b={};g.forEach((t=>{const e=`${t.package}:${t.name}`;b[e]=t.args}));const C={};y.forEach((t=>{const e=`HTScript:${t.name}:${t.id}`;C[e]=t.args}));const A={};w.forEach((t=>{const e=`HTQuery:${t.name}:${t.id}`;A[e]=t.args})),yield gt({descriptors:v,externals:b,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 t;const e=null===(t=this._submitView)||void 0===t?void 0:t.render();if(e){const t=o.dialog("Submit");t.add(e),t.addButton("Save",(()=>{this.saveCampaign(),t.close()})),t.addButton("Submit",(()=>{var e;null===(e=this._submitView)||void 0===e||e.submit(),t.close()})),t.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((()=>yt(this,void 0,void 0,(function*(){var n,o,a;i._onAdded(),yield new Promise((t=>setTimeout(t,1e3)));const s=i.filters(this._campaignFilters?{filters:this._campaignFilters}:void 0),r=null!==(o=null===(n=this._campaign)||void 0===n?void 0:n.layout)&&void 0!==o?o:null===(a=this.template)||void 0===a?void 0:a.layoutViewState;if(r)try{const t=e.ViewLayout.fromViewState(r);i.loadLayout(t)}catch(t){console.error(t)}i.dataFrame.onFilterChanged.subscribe((t=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=s.getOptions().look.filters})),setTimeout((()=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=s.getOptions().look.filters}),300),t&&t()}))),300),i.parentCall=this.parentCall,i}getSummary(){var t,e,i,n,a,s,r;const l=null!==(e=null===(t=this.campaign)||void 0===t?void 0:t.campaignFields)&&void 0!==e?e: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")),C)],{style:{alignItems:"center"}})},l),{"Number of molecules":this.dataFrame.rowCount.toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((t=>t.name))].filter((t=>t&&""!==t.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)}),C)],{style:{alignItems:"center"}})})}saveCampaign(i,n=!0){var a,s,r,l,c,u;return yt(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(t){return ht(this,void 0,void 0,(function*(){return new Promise((e=>ht(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?e(i.value):e(t)})).show()}))))}))}(d),g={};h.columns.toList().forEach((t=>g[t.name]=t.semType));const y={};h.columns.toList().forEach((t=>y[t.name]=t.type));const w={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,columnTypes:y};this.campaign=w;const b=e.DataFrame.fromColumns(h.columns.toList().filter((t=>!t.name.startsWith("~")))).toCsv();yield Pt.files.writeAsText(`Hit Triage/campaigns/${d}/enriched_table.csv`,b);const C=this._pickView.saveLayout();C?w.layout=C.viewState:t.shell.warning("Layout cound not be saved"),yield Pt.files.writeAsText(`Hit Triage/campaigns/${d}/campaign.json`,JSON.stringify(w)),n&&t.shell.info("Campaign saved successfully.")}))}}var bt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};function Ct(i,n){var a,s,r,c,u,d,p,m,v,g,y;return bt(this,void 0,void 0,(function*(){const w=yield Pt.files.list("Hit Design/templates");let C=!1,T=!1;const x=w.map((t=>t.name.slice(0,-5))),S=[];for(const t of w)try{const e=JSON.parse(yield Pt.files.readAsText(t));S.push(e.key)}catch(t){console.error(t)}const I=e.Func.find({tags:[l]}),N={};I.forEach((t=>{var e;N[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t}));const E=o.choiceInput("Submit function",null,[null,...Object.keys(N)]);E.nullable=!0,E.value=null!==(s=null===(a=null==n?void 0:n.submit)||void 0===a?void 0:a.fName)&&void 0!==s?s:null,E.setTooltip("Select function to be called upon submitting");const _=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),F=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),B=tt();function O(){var t,e,i,n;if(""===P.value||x.includes(null!==(e=null===(t=P.value)||void 0===t?void 0:t.trim())&&void 0!==e?e:"")){const t=null!==(i=P.input.offsetLeft)&&void 0!==i?i:0,e=null!==(n=P.input.offsetWidth)&&void 0!==n?n:0;_.style.marginLeft=`${t}px`,_.style.width=`${e}px`,_.style.opacity="100%",_.style.borderTop="1px solid red",C=!0}else _.style.borderTop="none",_.style.opacity="0%",C=!1}const P=o.stringInput("Name",null!==(r=null==n?void 0:n.name)&&void 0!==r?r:"",O);function k(){var t,e,i,n;if(""===V.value||S.includes(null!==(e=null===(t=V.value)||void 0===t?void 0:t.trim())&&void 0!==e?e:"")){const t=null!==(i=V.input.offsetLeft)&&void 0!==i?i:0,e=null!==(n=V.input.offsetWidth)&&void 0!==n?n:0;F.style.marginLeft=`${t}px`,F.style.width=`${e}px`,F.style.borderTop="1px solid red",F.style.opacity="100%",T=!0}else F.style.opacity="0%",F.style.borderTop="none",T=!1}const V=o.stringInput("Key",null!==(c=null==n?void 0:n.key)&&void 0!==c?c:"",k);V.setTooltip("Template key used for campaign prefix"),P.setTooltip("Template name"),P.root.style.borderBottom="none",V.root.style.borderBottom="none",_.style.opacity="0%",F.style.opacity="0%";let L=null;const j={compute:{descriptors:{enabled:!0,args:null!==(p=null===(d=null===(u=null==n?void 0:n.compute)||void 0===u?void 0:u.descriptors)||void 0===d?void 0:d.args)&&void 0!==p?p:[]},functions:null!==(v=null===(m=null==n?void 0:n.compute)||void 0===m?void 0:m.functions)&&void 0!==v?v:[]}},D=yield Q(i,(t=>{L=t}),(()=>null),j,!1);D.root.classList.add("hit-triage-new-template-functions-input");const H=nt(null==n?void 0:n.campaignFields),M=function(t){const i=[e.Property.fromOptions({name:"Name",type:e.TYPE.STRING})],n=new X(i,t?t.map((t=>({Name:t}))):void 0,{horizontalInputNames:!0});let o={};return n.onItemAdded.subscribe((t=>{o={}})),n.onAddingItemChanged.subscribe((t=>{t&&(o=t.item)})),{getFields:function(){const t=n.items.filter((t=>t.Name)).map((t=>t.Name));return o.Name&&""!==o.Name&&t.push(o.Name),t},fieldsDiv:n.root}}(null==n?void 0:n.stages),R=o.divV([o.divV([P,_]),o.divV([V,F]),B.dataFileInput,H.fieldsDiv]),U=o.h2("Stages");o.tooltip.bind(U,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const $=o.h2("Compute");o.tooltip.bind($,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const q=o.div([o.h2("Details"),R,U,M.fieldsDiv,$,D.root,o.h2("Submit"),E.root],"ui-form"),Y=o.buttonsInput([]);q.appendChild(Y);const W=null!==(y=null===(g=Y.getElementsByClassName("ui-input-editor"))||void 0===g?void 0:g[0])&&void 0!==y?y:Y,J=new Promise((t=>{const e=o.button(A,(()=>t()));W.appendChild(e)})),G=new Promise((e=>{const i=o.bigButton(b,(()=>function(){var i,n,o,a,s,r;return bt(this,void 0,void 0,(function*(){if(O(),k(),D.okProxy(),C||!P.value||""===P.value)return void t.shell.error("Template name is empty or already exists");if(T||!V.value||""===V.value)return void t.shell.error("Template key is empty or already exists");const l=E.value?N[E.value]:void 0,c=Object.assign({name:P.value,key:V.value,campaignFields:H.getFields(),stages:M.getFields(),layoutViewState:null!==(i=B.getLayoutViewState())&&void 0!==i?i:void 0,compute:{descriptors:{enabled:!!(null===(n=null==L?void 0:L.descriptors)||void 0===n?void 0:n.length),args:null!==(o=null==L?void 0:L.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(a=null==L?void 0:L.externals)&&void 0!==a?a:{}).map((([t,e])=>{const i=t.split(":");return{name:i[1],package:i[0],args:e}})),scripts:Object.entries(null!==(s=null==L?void 0:L.scripts)&&void 0!==s?s:{}).filter((([t,e])=>t.startsWith(h)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}})),queries:Object.entries(null!==(r=null==L?void 0:L.queries)&&void 0!==r?r:{}).filter((([t,e])=>t.startsWith(f)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}}))}},l?{submit:{fName:l.name,package:l.package.name}}:{});var u;u=c,Pt.files.writeAsText(`Hit Design/templates/${u.name}.json`,JSON.stringify(u)),t.shell.info("Template created successfully"),e(c)}))}()));W.appendChild(i)}));return{root:q,template:G,cancelPromise:J}}))}var At=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class Tt extends at{constructor(e){super(e),this.name="Hit Design",t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(Pt.webRoot+"README_HD.md"),this.checkCampaign().then((t=>{this.app.campaign=t,this.init()}))}onActivated(){t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(Pt.webRoot+"README_HD.md")}init(t){return At(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const e=o.h1(T),i=o.h1(x,{style:{marginLeft:"10px"}}),n=lt.appHeader({iconPath:Pt.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,e],{style:{marginLeft:"10px"}}),l,i,r])),yield this.startNewCampaign(a,s,t),this.app.resetBaseUrl()}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(t,e,i){var n;return At(this,void 0,void 0,(function*(){const a=(yield Pt.files.list("Hit Design/templates")).filter((t=>t.name.endsWith(".json"))).map((t=>t.name.slice(0,-5)));i&&!a.includes(i.name)&&a.push(i.name);let s=null;const r=()=>At(this,void 0,void 0,(function*(){const e=l.value,n=i&&i.name===e?i:JSON.parse(yield Pt.files.readAsText("Hit Design/templates/"+e+".json"));s=n;const o=yield this.getNewCampaignAccordeon(n);z()(t).empty(),t.appendChild(o)})),l=o.choiceInput("Template",null!==(n=null==i?void 0:i.name)&&void 0!==n?n:a[0],a,(()=>At(this,void 0,void 0,(function*(){yield r()}))));l.root.style.width="100%";const c=o.icons.add((()=>{this.createNewTemplate()}),y),u=o.icons.copy((()=>{s&&this.createNewTemplate(s)}),"Clone template");c.style.color="#2083d5",l.addOptions(u),l.addOptions(c),yield r(),z()(e).empty(),e.appendChild(l.root)}))}checkCampaign(t){var e;return At(this,void 0,void 0,(function*(){const i=location.search,n=new URLSearchParams(i);if(!n.has(s)&&!t)return;const o=null!=t?t:n.get(s);if(!(yield Pt.files.exists(`Hit Design/campaigns/${o}/campaign.json`)))return;const a=JSON.parse(yield Pt.files.readAsText(`Hit Design/campaigns/${o}/campaign.json`));a&&(this.app.campaign=a);const r=null!==(e=a.template)&&void 0!==e?e:JSON.parse(yield Pt.files.readAsText(`Hit Design/templates/${a.templateName}.json`));return yield this.app.setTemplate(r,o),t&&R(s,t),a.template=r,a}))}getCampaignsTable(){return At(this,void 0,void 0,(function*(){const t=yield W("Hit Design",this.deletedCampaigns),e=o.table(Object.values(t),(t=>[o.link(t.name,(()=>this.setCampaign(t.name)),"",""),t.createDate,t.rowCount,t.status,o.icons.delete((()=>At(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${t.name}?`)).onOK((()=>At(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Design",t.name),this.deletedCampaigns.push(t.name),yield this.init()})))).show()}))),"Delete campaign")]),["Name","Created","Molecules","Status",""]);return e.style.color="var(--grey-5)",e.style.marginLeft="24px",e}))}setCampaign(t){return At(this,void 0,void 0,(function*(){const e=yield this.checkCampaign(t);this.app.campaign=e}))}getNewCampaignAccordeon(i){return At(this,void 0,void 0,(function*(){const{root:n,promise:a,cancelPromise:s}=function(i){var n,a;const s=e.DataFrame.create(1),r=s.columns.addNew(d,e.TYPE.STRING);r.semType=e.SEMTYPE.MOLECULE,r.setTag(e.TAGS.UNITS,e.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(u,e.TYPE.STRING).set(0,i.stages[0]);const l=s.columns.addNew(p,e.TYPE.STRING);l.set(0,vt(l));const c=i.campaignFields.map((t=>t.type===e.SEMTYPE.MOLECULE?Object.assign(Object.assign({},t),{type:"String",semtype:e.SEMTYPE.MOLECULE}):t)).map((t=>e.Property.fromOptions(Object.assign({name:t.name,type:J[t.type],nullable:!t.required},t.semtype?{semType:t.semtype}:{})))),m={},h=o.input.form(m,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((e=>{const n=o.bigButton(w,(()=>{for(const e of i.campaignFields)if(e.required&&(!m[e.name]||""===m[e.name]))return void t.shell.error(`Field '${e.name}' is required`);e({df:s,campaignProps:m})}));v.appendChild(n)})),root:f,cancelPromise:new Promise((t=>{o.button(A,(()=>t()))}))}}(i);return a.then((t=>At(this,void 0,void 0,(function*(){this.app.dataFrame=t.df,yield this.app.setTemplate(i),this.app.campaignProps=t.campaignProps,yield this.app.saveCampaign(void 0,!1),i.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=i.layoutViewState)})))),s.then((()=>{this.init()})),n}))}createNewTemplate(i){return At(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const n=yield Ct(this.app,i),a=new e.ViewBase,s=t.shell.v;a.name="New Template",a.root.appendChild(n.root),a.parentCall=this.app.parentCall,t.shell.addView(a),a.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:r}=U(a,"Hit Design",y,(()=>At(this,void 0,void 0,(function*(){t.shell.v=s,a.close()}))));n.template.then((e=>At(this,void 0,void 0,(function*(){yield this.init(e),a.close(),$(a),t.shell.v=s,r.unsubscribe()})))),n.cancelPromise.then((()=>At(this,void 0,void 0,(function*(){r.unsubscribe(),a.close(),t.shell.v=s}))))}finally{o.setUpdateIndicator(this.root,!1)}}))}}class xt extends at{constructor(t){super(t),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=e.Func.find({name:n.fName,package:n.package})[0];if(!o)return void t.shell.error(`Function ${n.fName} not found.`);const a=e.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"),t.shell.info("Submitted successfully.")},new((a=void 0)||(a=Promise))((function(t,e){function i(t){try{l(s.next(t))}catch(t){e(t)}}function r(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof a?n:new a((function(t){t(n)}))).then(i,r)}l((s=s.apply(n,o||[])).next())}))}}var St=i(143),It={};It.styleTagTransform=L(),It.setAttributes=O(),It.insert=F().bind(null,"head"),It.domAPI=E(),It.insertStyleElement=k(),I()(St.Z,It),St.Z&&St.Z.locals&&St.Z.locals;class Nt extends at{constructor(t){super(t),this.v=null,this.name="Progress Tracker"}render(){return i=this,n=void 0,s=function*(){return new Promise((i=>{var n,a,s,r,l,c,d,p;this.app.dataFrame.columns.names().forEach((t=>{t.startsWith("~")&&this.app.dataFrame.columns.remove(t)}));const m=null===(n=this.app.campaign)||void 0===n?void 0:n.tilesViewerFormSketch;let h=null;if(m&&m.length>0)try{h=JSON.parse(m)}catch(t){console.error("Failed to parse sketch state string",t)}let f=!0;if(!this.v||this.v.isDetached){f=!1,h&&h.elementStates&&(null!==(a=h.elementStates.length)&&void 0!==a?a:0)>0&&(h.elementStates=h.elementStates.filter((t=>{var e;return(null===(e=null==t?void 0:t.viewerSettings)||void 0===e?void 0:e.column)&&this.app.dataFrame.col(t.viewerSettings.column)}))),this.v=e.Viewer.fromType(e.VIEWER.TILE_VIEWER,this.app.dataFrame,Object.assign({lanesColumnName:u,lanes:null!==(r=null===(s=this.app.template)||void 0===s?void 0:s.stages)&&void 0!==r?r:[]},(null!==(c=null===(l=null==h?void 0:h.elementStates)||void 0===l?void 0:l.length)&&void 0!==c?c:0)>0?{sketchState:h}:{}));const t=this.v.getOptions();t.look.sketchState=(null!==(p=null===(d=null==h?void 0:h.elementStates)||void 0===d?void 0:d.length)&&void 0!==p?p:0)>0?h:null,this.v.setOptions(t),this.v.copyViewersLook(this.v)}f?i():(o.empty(this.root),this.root.appendChild(this.v.root),this.v.root.style.height="100%",this.v.root.style.width="100%",setTimeout((()=>{var e,n,a;null===(n=null===(e=this.v)||void 0===e?void 0:e.view)||void 0===n||n._onAdded();const s=null===(a=t.shell.v)||void 0===a?void 0:a.getRibbonPanels();if(s){if(q(s))return void i();const e=o.bigButton("Design view",(()=>{const e=t.shell.view(this.app.designViewName);e&&(t.shell.v=e)})),n=o.bigButton("Submit",(()=>{var t;const e=null===(t=this.app._submitView)||void 0===t?void 0:t.render();if(e){const t=o.dialog("Submit");t.add(e),t.addButton("Save",(()=>{this.app.saveCampaign(),t.close()})),t.addButton("Submit",(()=>{var e;null===(e=this.app._submitView)||void 0===e||e.submit(),t.close()})),t.show()}}));n.classList.add("hit-design-submit-button"),s.push([e,n]),t.shell.v.setRibbonPanels(s)}i()}),5))}))},new((a=void 0)||(a=Promise))((function(t,e){function o(t){try{l(s.next(t))}catch(t){e(t)}}function r(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var i;e.done?t(e.value):(i=e.value,i instanceof a?i:new a((function(t){t(i)}))).then(o,r)}l((s=s.apply(i,n||[])).next())}));var i,n,a,s}onActivated(){this.render()}get sketchStateString(){if(!this.v)return null;const t=this.v.props.sketchState;return t&&"object"==typeof t?JSON.stringify(t):null}}const Et=rxjs.operators;var _t=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class Ft extends mt{constructor(i){super(i),this._tilesViewTab=null,this._designViewName="Design",this._filePath="System.AppData/HitTriage/Hit Design/campaigns",this._molColName=d,this.campaignProps={},this.processedValues=[],this._extraStageColsCount=0,this._infoView=new Tt(this),this.multiView=new e.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((t=>{this.multiView.currentView instanceof at&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,this.mainView=this.multiView,t.events.onCurrentViewChanged.subscribe((()=>_t(this,void 0,void 0,(function*(){var e,i,n,o,s,r,l,c,u;try{if((null===(e=t.shell.v)||void 0===e?void 0:e.name)===this.currentDesignViewId||(null===(i=t.shell.v)||void 0===i?void 0:i.name)===this.currentTilesViewId){if(t.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:""),this.currentTilesViewId&&(null===(r=t.shell.v)||void 0===r?void 0:r.name)===this.currentTilesViewId)yield null===(l=this._tilesView)||void 0===l?void 0:l.render();else{const t=null===(c=this._tilesView)||void 0===c?void 0:c.sketchStateString;t&&""!=t&&this.campaign&&(this.campaign.tilesViewerFormSketch=t)}const{sub:e}=U(t.shell.v,"Hit Design",null===(u=t.shell.v)||void 0===u?void 0:u.name,(()=>{var i,n;t.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(),e.unsubscribe()}))}}catch(t){console.error(t)}}))))}get infoView(){return this._infoView}get version(){var t,e;return null!==(e=null===(t=this._campaign)||void 0===t?void 0:t.version)&&void 0!==e?e:0}setTemplate(i,n){var o,r,l,c,u,p,m,h,f,v,g,y,w;return _t(this,void 0,void 0,(function*(){if(n){const e="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:`${e}/${n}/enriched_table.csv`,this.dataFrame=yield t.dapi.files.readCsv(this._filePath),(null===(c=this._campaign)||void 0===c?void 0:c.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([t,e])=>{const i=this.dataFrame.columns.byName(t);i&&e&&(i.semType=e)})),(null===(u=this._campaign)||void 0===u?void 0:u.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach((([t,e])=>{const i=this.dataFrame.columns.byName(t);if(i&&i.type!==e)try{this.dataFrame.changeColumnType(t,e)}catch(t){console.error(t)}}))}else(null===(o=this._designView)||void 0===o?void 0:o.dataFrame)&&t.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!==(m=null===(p=this.dataFrame.columns.bySemType(e.SEMTYPE.MOLECULE))||void 0===p?void 0:p.name)&&void 0!==m?m:d,this._dfName=null!==(h=(w=this.dataFrame).name)&&void 0!==h?h:w.name=n,this._campaignId=n,this.template=i,null!==(f=this._submitView)&&void 0!==f||(this._submitView=new xt(this)),t.shell.windows.showHelp=!1,this._extraStageColsCount=this.dataFrame.rowCount-this.dataFrame.filter.trueCount;const b=this.designView;this.currentDesignViewId=b.name,this.setBaseUrl(),R(a,null!==(y=null!==(v=this._campaignId)&&void 0!==v?v:null===(g=this._campaign)||void 0===g?void 0:g.name)&&void 0!==y?y:""),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 t,i,n,o;return null!==(t=this._molColName)&&void 0!==t?t:this._molColName=null!==(o=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(e.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name)&&void 0!==o?o:d}get campaign(){return this._campaign}set campaign(t){this._campaign=t}getDesignView(){var i,n,a,s,r,l;const c=[],m=null===(i=this.dataFrame.col(this.molColName))||void 0===i?void 0:i.toList().every((t=>!t&&""===t)),v=t.shell.addTableView(this.dataFrame);this._designViewName=null!==(a=null===(n=this.campaign)||void 0===n?void 0:n.name)&&void 0!==a?a:this._designViewName,v.name=this._designViewName,this.processedValues=this.dataFrame.getCol(this.molColName).toList(),setTimeout((()=>_t(this,void 0,void 0,(function*(){var i,n,o,a;v._onAdded(),yield new Promise((t=>setTimeout(t,1e3)));const s=null!==(n=null===(i=this._campaign)||void 0===i?void 0:i.layout)&&void 0!==n?n:null===(o=this.template)||void 0===o?void 0:o.layoutViewState;if(s)try{const t=e.ViewLayout.fromViewState(s);v.loadLayout(t)}catch(t){console.error(t)}m&&t.functions.call("Chem:editMoleculeCell",{cell:v.grid.cell(this._molColName,0)}),c.push(this.dataFrame.onRowsAdded.pipe((0,Et.filter)((()=>!this.isJoining))).subscribe((()=>{var e,i;try{if(this.processedValues=this.dataFrame.getCol(this.molColName).toList(),(null===(e=this.template.stages)||void 0===e?void 0:e.length)>0)for(let t=0;t<this.dataFrame.rowCount;t++){const e=this.dataFrame.col(u).get(t);e&&""!==e&&!(null===(i=this.dataFrame.col(u))||void 0===i?void 0:i.isNone(t))||this.dataFrame.set(u,t,this.template.stages[0])}let n=null;for(let t=0;t<this.dataFrame.rowCount;t++){const e=v.grid.cell(this.molColName,t);e&&(""!==e.cell.value&&null!==e.cell.value||(n=e))}n&&t.functions.call("Chem:editMoleculeCell",{cell:n})}catch(t){console.error(t)}}))),this.dataFrame&&c.push(null===(a=this.dataFrame)||void 0===a?void 0:a.onRowsRemoved.subscribe((()=>{try{this.processedValues=this.dataFrame.getCol(this.molColName).toList()}catch(t){console.error(t)}}))),c.push(t.events.onContextMenu.subscribe((i=>{var n,o,a,s,r;try{const t=null===(n=null==i?void 0:i.args)||void 0===n?void 0:n.context;if(!t)return;if((null==t?void 0:t.type)!==e.VIEWER.GRID)return;if(!t.tableView||t.tableView.id!==v.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 t,e,n,o;try{this.dataFrame.rows.addNew(null,!0);let a=null;for(let t=0;t<this.dataFrame.rowCount;t++){const e=v.grid.cell(this.molColName,t);e&&(""!==e.cell.value&&null!==e.cell.value||(a=e))}a&&(a.cell.value=null!==(o=null===(n=null===(e=null===(t=null==i?void 0:i.args)||void 0===t?void 0:t.item)||void 0===e?void 0:e.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(t){console.error(t)}}))}catch(e){t.log.error(e)}}))),c.push(v.grid.onCellValueEdited.subscribe((i=>_t(this,void 0,void 0,(function*(){var n,o,a,s;try{if((null===(n=i.tableColumn)||void 0===n?void 0:n.name)===u)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(p))||void 0===a?void 0:a.get(l))&&""!==(null===(s=this.dataFrame.col(p))||void 0===s?void 0:s.get(l))||this.dataFrame.col(p).set(l,vt(this.dataFrame.col(p)),!1);const c=this.template.compute;if(!r||""===r)return;const m=yield function(i,n,o,a=[],s=[]){return ft(this,void 0,void 0,(function*(){const r=e.TaskBarProgressIndicator.create("Calculating ..."),l=t.chem.convert(i,t.chem.Notation.Unknown,t.chem.Notation.Smiles),c=e.Column.fromStrings(d,[l]),u=e.DataFrame.fromColumns([c]);u.name="HD Single cell values",yield u.meta.detectSemanticTypes(),n.length&&(yield t.chem.descriptors(u,c.name,n));for(const t of o)try{const i=t.args,n=e.Func.find({package:t.package,name:t.name});if(!n.length||!n[0]){console.warn(`Function ${t.name} from package ${t.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]:u,[s]:c.name}))}catch(t){console.error(t);continue}for(const e of a){const i=e.args;try{const n=yield t.dapi.scripts.find(e.id);if(n){const t=n.inputs[0].name,e=n.inputs[1].name,o=yield n.apply(Object.assign(Object.assign({},i),{[t]:u,[e]:c.name}));if(o&&o.rowCount===u.rowCount&&"python"===n.language)for(const t of o.columns)t.name=u.columns.getUnusedName(t.name),u.columns.add(t)}}catch(t){console.error(t)}}for(const e of s){const i=e.args;try{const n=yield t.dapi.queries.find(e.id);if(n){const t=n.inputs[0].name,e=[l],o=yield n.apply(Object.assign(Object.assign({},i),{[t]:e}));if(!o||0===o.rowCount)continue;yield Y(u,d,o)}}catch(t){console.error(t)}}return r.close(),u}))}(r,c.descriptors.args,c.functions,c.scripts,c.queries);for(const t of m.columns.toList())t.name!==d&&(this.dataFrame.columns.contains(t.name)||(this.dataFrame.columns.addNew(t.name,t.type).semType=t.semType),this.dataFrame.col(t.name).set(l,t.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(void 0,!1)}catch(t){console.error(t)}})))));const r=t.events.onViewRemoved.subscribe((t=>{t.id===v.id&&(c.forEach((t=>t.unsubscribe())),r.unsubscribe())}))}))),300);const g=null==v?void 0:v.getRibbonPanels();if(g&&!q(g)){const e=()=>_t(this,void 0,void 0,(function*(){var t;Q(this,(t=>_t(this,void 0,void 0,(function*(){var e,i,n,a,s,r,l,c,u,d;const p=this.template.compute.descriptors.args,m=this.template.compute.functions,g=null!==(e=this.template.compute.scripts)&&void 0!==e?e:[],y=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],w=t.descriptors,b={descriptors:{enabled:!!(null===(n=null==t?void 0:t.descriptors)||void 0===n?void 0:n.length),args:null!==(a=null==t?void 0:t.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(s=null==t?void 0:t.externals)&&void 0!==s?s:{}).map((([t,e])=>{const i=t.split(":");return{name:i[1],package:i[0],args:e}})),scripts:Object.entries(null!==(r=null==t?void 0:t.scripts)&&void 0!==r?r:{}).filter((([t,e])=>t.startsWith(h)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}})),queries:Object.entries(null!==(l=null==t?void 0:t.queries)&&void 0!==l?l:{}).filter((([t,e])=>t.startsWith(f)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}}))};this.template.compute=b,this.campaign.template=this.template;const C=w.filter((t=>!p.includes(t))),A={};Object.entries(null!==(c=null==t?void 0:t.externals)&&void 0!==c?c:{}).filter((([t,e])=>{const i=m.find((e=>`${e.package}:${e.name}`===t));return!i||!Object.entries(e).every((([t,e])=>i.args[t]===e))})).forEach((([t,e])=>{A[t]=e}));const T={};Object.entries(null!==(u=null==t?void 0:t.scripts)&&void 0!==u?u:{}).filter((([t,e])=>{const i=g.find((e=>`HTScript:${e.name}:${e.id}`===t));return!i||!Object.entries(e).every((([t,e])=>i.args[t]===e))})).forEach((([t,e])=>{T[t]=e}));const x={};Object.entries(null!==(d=null==t?void 0:t.queries)&&void 0!==d?d:{}).filter((([t,e])=>{const i=y.find((e=>`HTQuery:${e.name}:${e.id}`===t));return!i||!Object.entries(e).every((([t,e])=>i.args[t]===e))})).forEach((([t,e])=>{x[t]=e})),o.setUpdateIndicator(v.grid.root,!0);try{yield gt({descriptors:C,externals:A,scripts:T,queries:x},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{o.setUpdateIndicator(v.grid.root,!1),this.saveCampaign(void 0,!1)}}))),(()=>null),null===(t=this.campaign)||void 0===t?void 0:t.template,!0)})),i=o.iconFA("wrench",e,"Calculate additional properties"),n=o.icons.add((()=>{var t;null===(t=this.dataFrame)||void 0===t||t.rows.addNew(null,!0)}),"Add new row"),a=o.bigButton("Progress tracker",(()=>{var e;this.currentTilesViewId&&t.shell.view(this.currentTilesViewId)&&(null===(e=t.shell.view(this.currentTilesViewId))||void 0===e||e.close()),this._tilesView=new Nt(this),this._tilesView.parentCall=this.parentCall,this._tilesViewTab=t.shell.addView(this._tilesView),this.currentTilesViewId=this._tilesViewTab.name,this._tilesView.onActivated(),t.shell.v=t.shell.view(this.currentTilesViewId)})),c=o.bigButton("Submit",(()=>{var t;const e=null===(t=this._submitView)||void 0===t?void 0:t.render();if(e){const t=o.dialog("Submit");t.add(e),t.addButton("Save",(()=>{this.saveCampaign(),t.close()})),t.addButton("Submit",(()=>{var e;null===(e=this._submitView)||void 0===e||e.submit(),t.close()})),t.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),v.setRibbonPanels(g)}return v.parentCall=this.parentCall,v}getSummary(){var i,n,a,s;const r=()=>{var t,e;const i=this._filePath.indexOf(null!==(t=this.campaignId)&&void 0!==t?t:null===(e=this._campaign)||void 0===e?void 0:e.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((t=>t.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===e.SEMTYPE.MOLECULE&&n&&(l[i]=t.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 e=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",(()=>_t(this,void 0,void 0,(function*(){const i=yield function(){return _t(this,void 0,void 0,(function*(){const e=s.value;return e&&""!==e.trim()?!!(yield t.dapi.files.exists(e))||(t.shell.error("Given folder does not exist"),!1):(t.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 t,e,i;return this.download(this.dataFrame,null!==(i=null!==(t=this.campaignId)&&void 0!==t?t:null===(e=this._campaign)||void 0===e?void 0:e.name)&&void 0!==i?i:"Molecules")}),C),a.appendChild(n),a.appendChild(e)})))),u=o.button("Cancel",(()=>{o.empty(a),a.appendChild(n),a.appendChild(e)}));o.empty(a),s.addOptions(u),s.addOptions(c),a.appendChild(s.root)}),"Edit file path");e.style.marginLeft="5px";const i=r();let n=o.link(i,(()=>{var t,e,i;return this.download(this.dataFrame,null!==(i=null!==(t=this.campaignId)&&void 0!==t?t:null===(e=this._campaign)||void 0===e?void 0:e.name)&&void 0!==i?i:"Molecules")}),C);const a=o.divH([n,e],{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((t=>t.name))].filter((t=>t&&""!==t.trim())).join(", ")})}saveCampaign(i,n=!0){var o,a,s,r,l,c,u,d,m,h,f,v,g,y;return _t(this,void 0,void 0,(function*(){const w=this.campaignId,b=this.template.name,C=this.dataFrame,A=w,T={};C.columns.toList().forEach((t=>T[t.name]=t.semType));const x={};C.columns.toList().forEach((t=>x[t.name]=t.type));const S=null!==(r=null!==(a=null===(o=this._tilesView)||void 0===o?void 0:o.sketchStateString)&&void 0!==a?a:null===(s=this.campaign)||void 0===s?void 0:s.tilesViewerFormSketch)&&void 0!==r?r:void 0,I={name:A,templateName:b,status:null!==(c=null!=i?i:null===(l=this.campaign)||void 0===l?void 0:l.status)&&void 0!==c?c:"In Progress",createDate:null!==(d=null===(u=this.campaign)||void 0===u?void 0:u.createDate)&&void 0!==d?d:M(new Date),campaignFields:null!==(h=null===(m=this.campaign)||void 0===m?void 0:m.campaignFields)&&void 0!==h?h:this.campaignProps,columnSemTypes:T,rowCount:null!==(v=null===(f=C.col(p))||void 0===f?void 0:f.toList().filter((t=>"StageDefiningRow"!==t)).length)&&void 0!==v?v:0,filteredRowCount:C.filter.trueCount,savePath:this._filePath,columnTypes:x,tilesViewerFormSketch:S,version:this.version+1},N=`Hit Design/campaigns/${w}/campaign.json`;let E=C;if(yield Pt.files.exists(N)){const e=JSON.parse(yield Pt.files.readAsText(N));if((null!==(g=e.version)&&void 0!==g?g:0)>this.version&&(I.version=Math.max(this.version,null!==(y=e.version)&&void 0!==y?y:0)+1,yield t.dapi.files.exists(this._filePath)))try{const e=yield t.dapi.files.readCsv(this._filePath);E=this.unionDataframes(e,C,this.molColName)}catch(t){console.error(t)}}const _=e.DataFrame.fromColumns(E.columns.toList().filter((t=>!t.name.startsWith("~")))).toCsv();yield t.dapi.files.writeAsText(this._filePath,_);const F=this._designView.saveLayout();return F?I.layout=F.viewState:t.shell.warning("Layout cound not be saved"),I.template=this.template,yield Pt.files.writeAsText(N,JSON.stringify(I)),n&&t.shell.info("Campaign saved successfully."),this.campaign=I,I}))}}class Bt extends e.GridCellRenderer{get name(){return"customGasteigerPNG"}get cellType(){return"customGasteigerPNG"}get defaultHeight(){return 200}get defaultWidth(){return 200}render(t,e,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(){t.drawImage(l,e+2,i+2,n-2,o-2)}}}var Ot=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};const Pt=new e.Package;function kt(t,e){return Ot(this,void 0,void 0,(function*(){yield jt(t,e,"Hit Triage")}))}function Vt(){return Ot(this,void 0,void 0,(function*(){const e=t.functions.getCurrentCall();return new wt(e).multiView}))}function Lt(t,e){return Ot(this,void 0,void 0,(function*(){yield jt(t,e,"Hit Design")}))}function jt(i,n,o){return Ot(this,void 0,void 0,(function*(){const a=yield W(o,[]);for(const[o,s]of Object.entries(a)){const o="ingest"in s?s.ingest.query:s.savePath;o&&!1!==(yield t.dapi.files.exists(o))&&i.item(s.name).onSelected.subscribe((i=>Ot(this,void 0,void 0,(function*(){try{const i=yield t.dapi.files.readCsv(o);if(!i)return;const a=s.columnSemTypes;if(a)for(const[t,e]of Object.entries(a)){const n=i.columns.byName(t);n&&(n.semType=e)}const r=e.TableView.create(i,!1);n.preview=r;const l=s.layout;l&&r.loadLayout(e.ViewLayout.fromViewState(l))}catch(t){console.error(t)}}))))}}))}function Dt(){return Ot(this,void 0,void 0,(function*(){const e=t.functions.getCurrentCall();return new Ft(e).multiView}))}function Ht(){return Ot(this,void 0,void 0,(function*(){const e=t.data.demo.molecules(100);return e.name="100 Molecules",e}))}function Mt(){return Ot(this,void 0,void 0,(function*(){const e=t.data.demo.molecules(5e3);return e.name="5000 Molecules",e}))}function Rt(e){return Ot(this,void 0,void 0,(function*(){const i=t.data.demo.molecules(e);return i.name="Variable Molecules number",i}))}function Ut(e,i){return Ot(this,void 0,void 0,(function*(){t.shell.info(e.rowCount),t.shell.info(i)}))}function $t(){return new Bt}})(),hittriage=n})();
|
|
2
2
|
//# sourceMappingURL=package.js.map
|