@datagrok/hit-triage 1.1.15 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # HitTriage changelog
2
2
 
3
+ ## 1.2.0 (2024-07-30)
4
+
5
+ Permission management and sharing of campaigns. Deleting templates. optimization of function loading
6
+
7
+ ## 1.1.16 (2024-07-29)
8
+
9
+ Fix re-running calculations on the first index.
10
+
3
11
  ## 1.1.15 (2024-07-29)
4
12
 
5
13
  Fixed duplicate detection on fingerprints. added rerunning calculations
package/dist/package.js CHANGED
@@ -1,2 +1,2 @@
1
- var hittriage;(()=>{var e={233:e=>{!function(){"use strict";var t=document,i=window,n=t.documentElement,o=t.createElement.bind(t),a=o("div"),s=o("table"),r=o("tbody"),l=o("tr"),c=Array.isArray,u=Array.prototype,d=u.concat,p=u.filter,h=u.indexOf,m=u.map,v=u.push,f=u.slice,g=u.some,y=u.splice,w=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,b=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,C=/<.+>/,A=/^\w+$/;function T(e,t){var i,n=!!(i=t)&&11===i.nodeType;return e&&(n||_(t)||F(t))?!n&&b.test(e)?t.getElementsByClassName(e.slice(1).replace(/\\/g,"")):!n&&A.test(e)?t.getElementsByTagName(e):t.querySelectorAll(e):[]}var x=function(){function e(e,n){if(e){if(I(e))return e;var o=e;if(O(e)){var a=n||t;if(!(o=w.test(e)&&_(a)?a.getElementById(e.slice(1).replace(/\\/g,"")):C.test(e)?Z(e):I(a)?a.find(e):O(a)?N(a).find(e):T(e,a)))return}else if(V(e))return this.ready(e);(o.nodeType||o===i)&&(o=[o]),this.length=o.length;for(var s=0,r=this.length;s<r;s++)this[s]=o[s]}}return e.prototype.init=function(t,i){return new e(t,i)},e}(),S=x.prototype,N=S.init;function I(e){return e instanceof x}function E(e){return!!e&&e===e.window}function _(e){return!!e&&9===e.nodeType}function F(e){return!!e&&1===e.nodeType}function V(e){return"function"==typeof e}function O(e){return"string"==typeof e}function B(e){return void 0===e}function P(e){return null===e}function k(e){return!isNaN(parseFloat(e))&&isFinite(e)}function L(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function j(e,t,i){if(i){for(var n=e.length;n--;)if(!1===t.call(e[n],n,e[n]))return e}else if(L(e))for(var o=Object.keys(e),a=(n=0,o.length);n<a;n++){var s=o[n];if(!1===t.call(e[s],s,e[s]))return e}else for(n=0,a=e.length;n<a;n++)if(!1===t.call(e[n],n,e[n]))return e;return e}function D(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i="boolean"==typeof e[0]&&e.shift(),n=e.shift(),o=e.length;if(!n)return{};if(!o)return D(i,N,n);for(var a=0;a<o;a++){var s=e[a];for(var r in s)i&&(c(s[r])||L(s[r]))?(n[r]&&n[r].constructor===s[r].constructor||(n[r]=new s[r].constructor),D(i,n[r],s[r])):n[r]=s[r]}return n}N.fn=N.prototype=S,S.length=0,S.splice=y,"function"==typeof Symbol&&(S[Symbol.iterator]=u[Symbol.iterator]),N.isWindow=E,N.isFunction=V,N.isArray=c,N.isNumeric=k,N.isPlainObject=L,N.each=j,S.each=function(e){return j(this,e)},S.empty=function(){return this.each((function(e,t){for(;t.firstChild;)t.removeChild(t.firstChild)}))},N.extend=D,S.extend=function(e){return D(S,e)};var R=/\S+/g;function $(e){return O(e)&&e.match(R)||[]}function M(e,t,n){if(F(e)){var o=i.getComputedStyle(e,null);return n?o.getPropertyValue(t)||void 0:o[t]||e.style[t]}}function H(e,t){return parseInt(M(e,t),10)||0}function U(e,t){return H(e,"border".concat(t?"Left":"Top","Width"))+H(e,"padding".concat(t?"Left":"Top"))+H(e,"padding".concat(t?"Right":"Bottom"))+H(e,"border".concat(t?"Right":"Bottom","Width"))}S.toggleClass=function(e,t){var i=$(e),n=!B(t);return this.each((function(e,o){F(o)&&j(i,(function(e,i){n?t?o.classList.add(i):o.classList.remove(i):o.classList.toggle(i)}))}))},S.addClass=function(e){return this.toggleClass(e,!0)},S.removeAttr=function(e){var t=$(e);return this.each((function(e,i){F(i)&&j(t,(function(e,t){i.removeAttribute(t)}))}))},S.attr=function(e,t){if(e){if(O(e)){if(arguments.length<2){if(!this[0]||!F(this[0]))return;var i=this[0].getAttribute(e);return P(i)?void 0:i}return B(t)?this:P(t)?this.removeAttr(e):this.each((function(i,n){F(n)&&n.setAttribute(e,t)}))}for(var n in e)this.attr(n,e[n]);return this}},S.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},S.hasClass=function(e){return!!e&&g.call(this,(function(t){return F(t)&&t.classList.contains(e)}))},S.get=function(e){return B(e)?f.call(this):this[(e=Number(e))<0?e+this.length:e]},S.eq=function(e){return N(this.get(e))},S.first=function(){return this.eq(0)},S.last=function(){return this.eq(-1)},S.text=function(e){return B(e)?this.get().map((function(e){return F(e)||(t=e)&&3===t.nodeType?e.textContent:"";var t})).join(""):this.each((function(t,i){F(i)&&(i.textContent=e)}))};var q={};function Y(e){return"none"===M(e,"display")}function W(e,t){var i=e&&(e.matches||e.webkitMatchesSelector||e.msMatchesSelector);return!!i&&!!t&&i.call(e,t)}function J(e){return O(e)?function(t,i){return W(i,e)}:V(e)?e:I(e)?function(t,i){return e.is(i)}:e?function(t,i){return i===e}:function(){return!1}}function G(e,t){return t?e.filter(t):e}S.filter=function(e){var t=J(e);return N(p.call(this,(function(e,i){return t.call(e,i,e)})))},S.detach=function(e){return G(this,e).each((function(e,t){t.parentNode&&t.parentNode.removeChild(t)})),this};var z=/^\s*<(\w+)[^>]*>/,Q=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,K={"*":a,tr:r,td:l,th:l,thead:s,tbody:s,tfoot:s};function Z(e){if(!O(e))return[];if(Q.test(e))return[o(RegExp.$1)];var t=z.test(e)&&RegExp.$1,i=K[t]||K["*"];return i.innerHTML=e,N(i.childNodes).detach().get()}function X(e,t,i,n){for(var o=[],a=V(t),s=n&&J(n),r=0,l=e.length;r<l;r++)if(a){var c=t(e[r]);c.length&&v.apply(o,c)}else for(var u=e[r][t];!(null==u||n&&s(-1,u));)o.push(u),u=i?u[t]:null;return o}function ee(e){return e.multiple&&e.options?X(p.call(e.options,(function(e){return e.selected&&!e.disabled&&!e.parentNode.disabled})),"value"):e.value||""}function te(e){return e.length>1?p.call(e,(function(e,t,i){return h.call(i,e)===t})):e}N.parseHTML=Z,S.has=function(e){var t=O(e)?function(t,i){return T(e,i).length}:function(t,i){return i.contains(e)};return this.filter(t)},S.not=function(e){var t=J(e);return this.filter((function(i,n){return(!O(e)||F(n))&&!t.call(n,i,n)}))},S.val=function(e){return arguments.length?this.each((function(t,i){var n=i.multiple&&i.options;if(n||Oe.test(i.type)){var o=c(e)?m.call(e,String):P(e)?[]:[String(e)];n?j(i.options,(function(e,t){t.selected=o.indexOf(t.value)>=0}),!0):i.checked=o.indexOf(i.value)>=0}else i.value=B(e)||P(e)?"":e})):this[0]&&ee(this[0])},S.is=function(e){var t=J(e);return g.call(this,(function(e,i){return t.call(e,i,e)}))},N.guid=1,N.unique=te,S.add=function(e,t){return N(te(this.get().concat(N(e,t).get())))},S.children=function(e){return G(N(te(X(this,(function(e){return e.children})))),e)},S.parent=function(e){return G(N(te(X(this,"parentNode"))),e)},S.index=function(e){var t=e?N(e)[0]:this[0],i=e?this:N(t).parent().children();return h.call(i,t)},S.closest=function(e){var t=this.filter(e);if(t.length)return t;var i=this.parent();return i.length?i.closest(e):t},S.siblings=function(e){return G(N(te(X(this,(function(e){return N(e).parent().children().not(e)})))),e)},S.find=function(e){return N(te(X(this,(function(t){return T(e,t)}))))};var ie=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ne=/^$|^module$|\/(java|ecma)script/i,oe=["type","src","nonce","noModule"];function ae(e,t,i,a,s,r,l,c){return j(e,(function(e,r){j(N(r),(function(e,r){j(N(t),(function(t,l){var c=i?l:r,u=i?e:t;!function(e,t,i,a,s){a?e.insertBefore(t,i?e.firstChild:null):"HTML"===e.nodeName?e.parentNode.replaceChild(t,e):e.parentNode.insertBefore(t,i?e:e.nextSibling),s&&function(e,t){var i=N(e);i.filter("script").add(i.find("script")).each((function(e,i){if(ne.test(i.type)&&n.contains(i)){var a=o("script");a.text=i.textContent.replace(ie,""),j(oe,(function(e,t){i[t]&&(a[t]=i[t])})),t.head.insertBefore(a,null),t.head.removeChild(a)}}))}(t,e.ownerDocument)}(i?r:l,u?c.cloneNode(!0):c,a,s,!u)}),c)}),l)}),r),t}S.after=function(){return ae(arguments,this,!1,!1,!1,!0,!0)},S.append=function(){return ae(arguments,this,!1,!1,!0)},S.html=function(e){if(!arguments.length)return this[0]&&this[0].innerHTML;if(B(e))return this;var t=/<script[\s>]/.test(e);return this.each((function(i,n){F(n)&&(t?N(n).empty().append(e):n.innerHTML=e)}))},S.appendTo=function(e){return ae(arguments,this,!0,!1,!0)},S.wrapInner=function(e){return this.each((function(t,i){var n=N(i),o=n.contents();o.length?o.wrapAll(e):n.append(e)}))},S.before=function(){return ae(arguments,this,!1,!0)},S.wrapAll=function(e){for(var t=N(e),i=t[0];i.children.length;)i=i.firstElementChild;return this.first().before(t),this.appendTo(i)},S.wrap=function(e){return this.each((function(t,i){var n=N(e)[0];N(i).wrapAll(t?n.cloneNode(!0):n)}))},S.insertAfter=function(e){return ae(arguments,this,!0,!1,!1,!1,!1,!0)},S.insertBefore=function(e){return ae(arguments,this,!0,!0)},S.prepend=function(){return ae(arguments,this,!1,!0,!0,!0,!0)},S.prependTo=function(e){return ae(arguments,this,!0,!0,!0,!1,!1,!0)},S.contents=function(){return N(te(X(this,(function(e){return"IFRAME"===e.tagName?[e.contentDocument]:"TEMPLATE"===e.tagName?e.content.childNodes:e.childNodes}))))},S.next=function(e,t,i){return G(N(te(X(this,"nextElementSibling",t,i))),e)},S.nextAll=function(e){return this.next(e,!0)},S.nextUntil=function(e,t){return this.next(t,!0,e)},S.parents=function(e,t){return G(N(te(X(this,"parentElement",!0,t))),e)},S.parentsUntil=function(e,t){return this.parents(t,e)},S.prev=function(e,t,i){return G(N(te(X(this,"previousElementSibling",t,i))),e)},S.prevAll=function(e){return this.prev(e,!0)},S.prevUntil=function(e,t){return this.prev(t,!0,e)},S.map=function(e){return N(d.apply([],m.call(this,(function(t,i){return e.call(t,i,t)}))))},S.clone=function(){return this.map((function(e,t){return t.cloneNode(!0)}))},S.offsetParent=function(){return this.map((function(e,t){for(var i=t.offsetParent;i&&"static"===M(i,"position");)i=i.offsetParent;return i||n}))},S.slice=function(e,t){return N(f.call(this,e,t))};var se=/-([a-z])/g;function re(e){return e.replace(se,(function(e,t){return t.toUpperCase()}))}S.ready=function(e){var i=function(){return setTimeout(e,0,N)};return"loading"!==t.readyState?i():t.addEventListener("DOMContentLoaded",i),this},S.unwrap=function(){return this.parent().each((function(e,t){if("BODY"!==t.tagName){var i=N(t);i.replaceWith(i.children())}})),this},S.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+i.pageYOffset,left:t.left+i.pageXOffset}}},S.position=function(){var e=this[0];if(e){var t="fixed"===M(e,"position"),i=t?e.getBoundingClientRect():this.offset();if(!t){for(var n=e.ownerDocument,o=e.offsetParent||n.documentElement;(o===n.body||o===n.documentElement)&&"static"===M(o,"position");)o=o.parentNode;if(o!==e&&F(o)){var a=N(o).offset();i.top-=a.top+H(o,"borderTopWidth"),i.left-=a.left+H(o,"borderLeftWidth")}}return{top:i.top-H(e,"marginTop"),left:i.left-H(e,"marginLeft")}}};var le={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};S.prop=function(e,t){if(e){if(O(e))return e=le[e]||e,arguments.length<2?this[0]&&this[0][e]:this.each((function(i,n){n[e]=t}));for(var i in e)this.prop(i,e[i]);return this}},S.removeProp=function(e){return this.each((function(t,i){delete i[le[e]||e]}))};var ce=/^--/;function ue(e){return ce.test(e)}var de={},pe=a.style,he=["webkit","moz","ms"],me={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 ve(e,t,i){return void 0===i&&(i=ue(e)),i||me[e]||!k(t)?t:"".concat(t,"px")}function fe(e,t){try{return e(t)}catch(e){return t}}S.css=function(e,t){if(O(e)){var i=ue(e);return e=function(e,t){if(void 0===t&&(t=ue(e)),t)return e;if(!de[e]){var i=re(e),n="".concat(i[0].toUpperCase()).concat(i.slice(1));j("".concat(i," ").concat(he.join("".concat(n," "))).concat(n).split(" "),(function(t,i){if(i in pe)return de[e]=i,!1}))}return de[e]}(e,i),arguments.length<2?this[0]&&M(this[0],e,i):e?(t=ve(e,t,i),this.each((function(n,o){F(o)&&(i?o.style.setProperty(e,t):o.style[e]=t)}))):this}for(var n in e)this.css(n,e[n]);return this};var ge=/^\s+|\s+$/;function ye(e,t){var i=e.dataset[t]||e.dataset[re(t)];return ge.test(i)?i:fe(JSON.parse,i)}function we(e,t){var i=e.documentElement;return Math.max(e.body["scroll".concat(t)],i["scroll".concat(t)],e.body["offset".concat(t)],i["offset".concat(t)],i["client".concat(t)])}S.data=function(e,t){if(!e){if(!this[0])return;var i={};for(var n in this[0].dataset)i[n]=ye(this[0],n);return i}if(O(e))return arguments.length<2?this[0]&&ye(this[0],e):B(t)?this:this.each((function(i,n){!function(e,t,i){i=fe(JSON.stringify,i),e.dataset[re(t)]=i}(n,e,t)}));for(var n in e)this.data(n,e[n]);return this},j([!0,!1],(function(e,t){j(["Width","Height"],(function(e,i){var n="".concat(t?"outer":"inner").concat(i);S[n]=function(n){if(this[0])return E(this[0])?t?this[0]["inner".concat(i)]:this[0].document.documentElement["client".concat(i)]:_(this[0])?we(this[0],i):this[0]["".concat(t?"offset":"client").concat(i)]+(n&&t?H(this[0],"margin".concat(e?"Top":"Left"))+H(this[0],"margin".concat(e?"Bottom":"Right")):0)}}))})),j(["Width","Height"],(function(e,t){var i=t.toLowerCase();S[i]=function(n){if(!this[0])return B(n)?void 0:this;if(!arguments.length)return E(this[0])?this[0].document.documentElement["client".concat(t)]:_(this[0])?we(this[0],t):this[0].getBoundingClientRect()[i]-U(this[0],!e);var o=parseInt(n,10);return this.each((function(t,n){if(F(n)){var a=M(n,"boxSizing");n.style[i]=ve(i,o+("border-box"===a?U(n,!e):0))}}))}}));var be="___cd";S.toggle=function(e){return this.each((function(i,n){if(F(n)){var a=Y(n);(B(e)?a:e)?(n.style.display=n[be]||"",Y(n)&&(n.style.display=function(e){if(q[e])return q[e];var i=o(e);t.body.insertBefore(i,null);var n=M(i,"display");return t.body.removeChild(i),q[e]="none"!==n?n:"block"}(n.tagName))):a||(n[be]=M(n,"display"),n.style.display="none")}}))},S.hide=function(){return this.toggle(!1)},S.show=function(){return this.toggle(!0)};var Ce="___ce",Ae={focus:"focusin",blur:"focusout"},Te={mouseenter:"mouseover",mouseleave:"mouseout"},xe=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function Se(e){return Te[e]||Ae[e]||e}function Ne(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Ie(e){return e[Ce]=e[Ce]||{}}function Ee(e,t){return!t||!g.call(t,(function(t){return e.indexOf(t)<0}))}function _e(e,t,i,n,o){var a=Ie(e);if(t)a[t]&&(a[t]=a[t].filter((function(a){var s=a[0],r=a[1],l=a[2];if(o&&l.guid!==o.guid||!Ee(s,i)||n&&n!==r)return!0;e.removeEventListener(t,l)})));else for(t in a)_e(e,t,i,n,o)}S.trigger=function(e,i){if(O(e)){var n=Ne(e),o=n[0],a=n[1],s=Se(o);if(!s)return this;var r=xe.test(s)?"MouseEvents":"HTMLEvents";(e=t.createEvent(r)).initEvent(s,!0,!0),e.namespace=a.join("."),e.___ot=o}e.___td=i;var l=e.___ot in Ae;return this.each((function(t,i){l&&V(i[e.___ot])&&(i["___i".concat(e.type)]=!0,i[e.___ot](),i["___i".concat(e.type)]=!1),i.dispatchEvent(e)}))},S.off=function(e,t,i){var n=this;if(B(e))this.each((function(e,t){(F(t)||_(t)||E(t))&&_e(t)}));else if(O(e))V(t)&&(i=t,t=""),j($(e),(function(e,o){var a=Ne(o),s=a[0],r=a[1],l=Se(s);n.each((function(e,n){(F(n)||_(n)||E(n))&&_e(n,l,r,t,i)}))}));else for(var o in e)this.off(o,e[o]);return this},S.remove=function(e){return G(this,e).detach().off(),this},S.replaceWith=function(e){return this.before(e).remove()},S.replaceAll=function(e){return N(e).replaceWith(this),this},S.on=function(e,t,i,n,o){var a=this;if(!O(e)){for(var s in e)this.on(s,t,i,e[s],o);return this}return O(t)||(B(t)||P(t)?t="":B(i)?(i=t,t=""):(n=i,i=t,t="")),V(n)||(n=i,i=void 0),n?(j($(e),(function(e,s){var r=Ne(s),l=r[0],c=r[1],u=Se(l),d=l in Te,p=l in Ae;u&&a.each((function(e,a){if(F(a)||_(a)||E(a)){var s=function(e){if(e.target["___i".concat(e.type)])return e.stopImmediatePropagation();if((!e.namespace||Ee(c,e.namespace.split(".")))&&(t||!(p&&(e.target!==a||e.___ot===u)||d&&e.relatedTarget&&a.contains(e.relatedTarget)))){var r=a;if(t){for(var l=e.target;!W(l,t);){if(l===a)return;if(!(l=l.parentNode))return}r=l}Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return r}}),Object.defineProperty(e,"delegateTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(e,"data",{configurable:!0,get:function(){return i}});var h=n.call(r,e,e.___td);o&&_e(a,u,c,t,s),!1===h&&(e.preventDefault(),e.stopPropagation())}};s.guid=n.guid=n.guid||N.guid++,function(e,t,i,n,o){var a=Ie(e);a[t]=a[t]||[],a[t].push([i,n,o]),e.addEventListener(t,o)}(a,u,c,t,s)}}))})),this):this},S.one=function(e,t,i,n){return this.on(e,t,i,n,!0)};var Fe=/\r?\n/g,Ve=/file|reset|submit|button|image/i,Oe=/radio|checkbox/i;S.serialize=function(){var e="";return this.each((function(t,i){j(i.elements||[i],(function(t,i){if(!(i.disabled||!i.name||"FIELDSET"===i.tagName||Ve.test(i.type)||Oe.test(i.type)&&!i.checked)){var n=ee(i);B(n)||j(c(n)?n:[n],(function(t,n){e+=function(e,t){return"&".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t.replace(Fe,"\r\n")))}(i.name,n)}))}}))})),e.slice(1)},e.exports=N}()},558:(e,t,i)=>{"use strict";i.d(t,{A:()=>r});var n=i(354),o=i.n(n),a=i(314),s=i.n(a)()(o());s.push([e.id,".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\n}\n\n.hit-triage-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header {\n border: none;\n border-left: 4px solid transparent;\n border-radius: 1px;\n padding: 4px 8px;\n min-height: 28px;\n justify-content: flex-end;\n flex-direction: row-reverse;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\ntable.hit-triage-table {\n margin: 10px;\n width: calc(100% - 20px);\n}\n\n.hit-triage-table-container {\n max-width: 600px;\n max-height: 500px;\n overflow-y: scroll;\n}\n\n.hit-triage-error-div {\n color: red;\n text-align: start;\n}\n\n.mx-5 {\n margin-left: 5px;\n margin-right: 5px;\n}\n\n.hit-triage-new-template-functions-input > .ui-box {\n height: 300px;\n}\n\n.hit-triage-new-template-functions-input {\n max-height: 200px;\n max-width: unset !important;\n overflow-y: scroll;\n}\n\n\n.hit-triage-new-template-functions-input > .d4-tab-host {\n width: 100% !important;\n}\n\n.hit-triage-compute-dialog-host {\n max-height: 550px;\n max-width: 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},677:(e,t,i)=>{"use strict";i.d(t,{A:()=>r});var n=i(354),o=i.n(n),a=i(314),s=i.n(a)()(o());s.push([e.id,".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/src/u2.css"],names:[],mappings:"AAAA;;AAEA;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,kBAAkB;AACtB;;AAEA;IACI,SAAS;AACb",sourcesContent:[".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}"],sourceRoot:""}]);const r=s},542:(e,t,i)=>{"use strict";i.d(t,{A:()=>r});var n=i(354),o=i.n(n),a=i(314),s=i.n(a)()(o());s.push([e.id,"img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}","",{version:3,sources:["webpack://./src/app/hit-design-views/utils.css"],names:[],mappings:"AAAA;IACI,eAAe;AACnB",sourcesContent:["img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}"],sourceRoot:""}]);const r=s},314:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var i="",n=void 0!==t[5];return t[4]&&(i+="@supports (".concat(t[4],") {")),t[2]&&(i+="@media ".concat(t[2]," {")),n&&(i+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),i+=e(t),n&&(i+="}"),t[2]&&(i+="}"),t[4]&&(i+="}"),i})).join("")},t.i=function(e,i,n,o,a){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(n)for(var r=0;r<this.length;r++){var l=this[r][0];null!=l&&(s[l]=!0)}for(var c=0;c<e.length;c++){var u=[].concat(e[c]);n&&s[u[0]]||(void 0!==a&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=a),i&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=i):u[2]=i),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),t.push(u))}},t}},354:e=>{"use strict";e.exports=function(e){var t=e[1],i=e[3];if(!i)return t;if("function"==typeof btoa){var n=btoa(unescape(encodeURIComponent(JSON.stringify(i)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),a="/*# ".concat(o," */");return[t].concat([a]).join("\n")}return[t].join("\n")}},72:e=>{"use strict";var t=[];function i(e){for(var i=-1,n=0;n<t.length;n++)if(t[n].identifier===e){i=n;break}return i}function n(e,n){for(var a={},s=[],r=0;r<e.length;r++){var l=e[r],c=n.base?l[0]+n.base:l[0],u=a[c]||0,d="".concat(c," ").concat(u);a[c]=u+1;var p=i(d),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)t[p].references++,t[p].updater(h);else{var m=o(h,n);n.byIndex=r,t.splice(r,0,{identifier:d,updater:m,references:1})}s.push(d)}return s}function o(e,t){var i=t.domAPI(t);return i.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;i.update(e=t)}else i.remove()}}e.exports=function(e,o){var a=n(e=e||[],o=o||{});return function(e){e=e||[];for(var s=0;s<a.length;s++){var r=i(a[s]);t[r].references--}for(var l=n(e,o),c=0;c<a.length;c++){var u=i(a[c]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}a=l}}},659:e=>{"use strict";var t={};e.exports=function(e,i){var n=function(e){if(void 0===t[e]){var i=document.querySelector(e);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}t[e]=i}return t[e]}(e);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(i)}},540:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},56:(e,t,i)=>{"use strict";e.exports=function(e){var t=i.nc;t&&e.setAttribute("nonce",t)}},825:e=>{"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(i){!function(e,t,i){var n="";i.supports&&(n+="@supports (".concat(i.supports,") {")),i.media&&(n+="@media ".concat(i.media," {"));var o=void 0!==i.layer;o&&(n+="@layer".concat(i.layer.length>0?" ".concat(i.layer):""," {")),n+=i.css,o&&(n+="}"),i.media&&(n+="}"),i.supports&&(n+="}");var a=i.sourceMap;a&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),t.styleTagTransform(n,e,t.options)}(t,e,i)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},113:e=>{"use strict";e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function i(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={id:n,exports:{}};return e[n](a,a.exports,i),a.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.nc=void 0;var n={};(()=>{"use strict";i.r(n),i.d(n,{_package:()=>De,demoFileIngest:()=>qe,demoFileIngest1:()=>Ye,demoFileIngest2:()=>We,demoFileSubmit:()=>Je,gasteigerCellRenderer:()=>Ge,hitDesignApp:()=>Ue,hitDesignAppTreeBrowser:()=>Me,hitTriageApp:()=>$e,hitTriageAppTreeBrowser:()=>Re});const e=grok,t=DG,o=ui,a="campaignId",s="campaignId",r="enriched_table.csv",l="campaign.json",c="HitTriageFunction",u="HitTriageDataSource",d="HitTriageSubmitFunction",p="Selected hits",h="Stage",m="Molecule",v="V-iD",f="V######",g="HTScript",y="HTQuery",w="molecules",b="Source",C="New template",A="Start",T="Create",x="Download",S="Cancel",N="Continue a campaign",I="New campaign";var E=i(72),_=i.n(E),F=i(825),V=i.n(F),O=i(659),B=i.n(O),P=i(56),k=i.n(P),L=i(540),j=i.n(L),D=i(113),R=i.n(D),$=i(558),M={};M.styleTagTransform=R(),M.setAttributes=k(),M.insert=B().bind(null,"head"),M.domAPI=V(),M.insertStyleElement=j(),_()($.A,M),$.A&&$.A.locals&&$.A.locals;var H=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};const U=e=>`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`;function q(e,t){const i=document.title,n=window.location.href.split("?")[0]+"?"+e+"="+t;if(history.replaceState){const e={Title:i,Url:n};history.replaceState(e,e.Title,e.Url)}}function Y(t,i,n,a){var s;const r=o.breadcrumbs([i,n]),l=r.onPathClick.subscribe((e=>{1===e.length&&(l.unsubscribe(),W(t),a())})),c=null===(s=e.shell.v.ribbonMenu.root.parentElement)||void 0===s?void 0:s.getElementsByClassName("d4-ribbon-name")[0];return c&&(c.textContent="",c.appendChild(r.root)),{breadcrumbs:r,sub:l}}function W(e){const t=e.getRibbonPanels();(null==t?void 0:t.length)&&(t.pop(),e.setRibbonPanels(t))}function J(e){return e.reduce(((e,t)=>e||t.reduce(((e,t)=>e||t.classList.contains("hit-design-submit-button")||Array.from(t.children).some((e=>e.classList.contains("hit-design-submit-button")))),!1)),!1)}function G(e,i,n){return H(this,void 0,void 0,(function*(){if(0===n.rowCount)return;if(!e.col(i))throw new Error("There is no molecule column in dataframe");let o=n.col(w);if(o||(yield n.meta.detectSemanticTypes(),o=n.columns.bySemType(t.SEMTYPE.MOLECULE)),!o)throw new Error("There is no original molecule column in query result dataframe");const a=n.columns.names().filter((e=>e!==w));e.join(n,[i],[o.name],void 0,a,void 0,!0)}))}function z(e,t){return H(this,void 0,void 0,(function*(){const i=(yield De.files.list(`${e}/campaigns`)).filter((e=>-1===t.indexOf(e.name))),n={};for(const t of i)try{const i=JSON.parse(yield De.files.readAsText(`${e}/campaigns/${t.name}/${l}`));n[i.name]=i}catch(e){continue}return n}))}const Q={String:t.TYPE.STRING,Number:t.TYPE.FLOAT,Boolean:t.TYPE.BOOL,Date:t.TYPE.DATE_TIME,Molecule:t.SEMTYPE.MOLECULE};var K=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))},Z=i(233),X=i.n(Z),ee=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function te(i,n,a,s,r){return ee(this,void 0,void 0,(function*(){var l,c,u,d,p,h,m,v,f,w,b,C,A,T,x,S,N,I,E,_,F,V,O,B,P,k,L;const j=yield i.computeFunctions,D=j.functions.filter((({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).map((e=>{var t,i,n,o;return{package:e.package.name,name:e.name,args:null!==(o=null===(n=null===(i=null===(t=null==s?void 0:s.compute)||void 0===t?void 0:t.functions)||void 0===i?void 0:i.find((t=>t.name===e.name&&t.package===e.package.name)))||void 0===n?void 0:n.args)&&void 0!==o?o:{}}})),R=j.scripts.filter((({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).map((e=>{var t,i,n,o;return{name:e.name,id:e.id,args:null!==(o=null===(n=null===(i=null===(t=null==s?void 0:s.compute)||void 0===t?void 0:t.scripts)||void 0===i?void 0:i.find((t=>t.id===e.id)))||void 0===n?void 0:n.args)&&void 0!==o?o:{}}})),$=j.queries.filter((e=>e.inputs.length>0&&"list"===e.inputs[0].propertyType)).map((e=>{var t,i,n,o,a;return{name:null!==(t=e.friendlyName)&&void 0!==t?t:e.name,id:e.id,args:null!==(a=null===(o=null===(n=null===(i=null==s?void 0:s.compute)||void 0===i?void 0:i.queries)||void 0===n?void 0:n.find((t=>t.id===e.id)))||void 0===o?void 0:o.args)&&void 0!==a?a:{}}}));let M=!!(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;const H=o.div([],{classes:"hit-triage-compute-dialog-host"}),U=[],q=o.tree();try{const Z=yield e.chem.descriptorsTree();function ee(e,t){const i=t.group(e,null,!1);return i.enableCheckBox(!1),i}q.root.classList.add("hit-triage-compute-dialog-descriptors-group");const te=Object.keys(Z),ie=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 ne of te){const oe=ee(ne,q);for(const ae of Z[ne].descriptors){const se=oe.item(ae.name,ae);U.push(se),se.enableCheckBox(ie.includes(ae.name))}}}catch(re){console.error(re),M=!1}const Y="Descriptors",W={[Y]:Y},J=M?{[Y]:q.root}:{},G={},z={[Y]:!1};z[Y]=!!(null===(m=null===(h=null==s?void 0:s.compute)||void 0===h?void 0:h.descriptors)||void 0===m?void 0:m.enabled)&&(null===(w=null===(f=null===(v=null==s?void 0:s.compute)||void 0===v?void 0:v.descriptors)||void 0===f?void 0:f.args)||void 0===w?void 0:w.length)>0;for(const le of D)try{const ce=t.Func.find({package:le.package,name:le.name})[0],ue=ce.prepare(le.args),de=`${le.package}:${le.name}`;G[de]=ue;const pe=o.div(),he=yield ue.buildEditor(pe,{condensed:!1});pe.classList.add("oy-scroll"),pe.style.marginLeft="15px",pe.style.removeProperty("max-width"),J[null!==(b=ce.friendlyName)&&void 0!==b?b:ce.name]=pe,W[null!==(C=ce.friendlyName)&&void 0!==C?C:ce.name]=de,z[de]=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===le.name&&e.package===le.package)))&&void 0!==x&&x,pe.children[0].style.display="none",pe.children[1].style.display="none",he.forEach((e=>{var t,i;(null===(t=e.property)||void 0===t?void 0:t.name)&&Object.keys(le.args).includes(null===(i=e.property)||void 0===i?void 0:i.name)&&(e.value=le.args[e.property.name]),e.fireChanged()}))}catch(me){console.error(me);continue}for(const ve of R)try{const fe=yield e.dapi.scripts.find(ve.id),ge=fe.prepare(ve.args),ye=`${g}:${null!==(S=ve.name)&&void 0!==S?S:""}:${ve.id}`;G[ye]=ge;const we=o.div(),be=yield ge.buildEditor(we,{condensed:!1});we.classList.add("oy-scroll"),we.style.marginLeft="15px",we.style.removeProperty("max-width"),J[null!==(N=fe.friendlyName)&&void 0!==N?N:fe.name]=we,W[null!==(I=fe.friendlyName)&&void 0!==I?I:fe.name]=ye,z[ye]=null!==(F=null===(_=null===(E=null==s?void 0:s.compute)||void 0===E?void 0:E.scripts)||void 0===_?void 0:_.some((e=>e.id===ve.id)))&&void 0!==F&&F,we.children[0].style.display="none",we.children[1].style.display="none",be.forEach((e=>{var t,i;(null===(t=e.property)||void 0===t?void 0:t.name)&&Object.keys(ve.args).includes(null===(i=e.property)||void 0===i?void 0:i.name)&&(e.value=ve.args[e.property.name]),e.fireChanged()}))}catch(Ce){console.error(Ce);continue}for(const Ae of $)try{const Te=yield e.dapi.queries.find(Ae.id),xe=Te.prepare(Ae.args),Se=`${y}:${null!==(V=Ae.name)&&void 0!==V?V:""}:${Ae.id}`;G[Se]=xe;const Ne=o.div(),Ie=yield xe.buildEditor(Ne,{condensed:!1});Ne.classList.add("oy-scroll"),Ne.style.marginLeft="15px",Ne.style.removeProperty("max-width"),J[null!==(O=Te.friendlyName)&&void 0!==O?O:Te.name]=Ne,W[null!==(B=Te.friendlyName)&&void 0!==B?B:Te.name]=Se,z[Se]=null!==(L=null===(k=null===(P=null==s?void 0:s.compute)||void 0===P?void 0:P.queries)||void 0===k?void 0:k.some((e=>e.id===Ae.id)))&&void 0!==L&&L,Ne.children[0].style.display="none",Ie.forEach((e=>{var t,i;(null===(t=e.property)||void 0===t?void 0:t.name)&&Object.keys(Ae.args).includes(null===(i=e.property)||void 0===i?void 0:i.name)&&(e.value=Ae.args[e.property.name]),e.fireChanged()}))}catch(Ee){console.error(Ee);continue}const Q=o.tabControl(J,!0);function K(){const e={descriptors:[],externals:{},scripts:{},queries:{}};e.descriptors=z[Y]?U.filter((e=>e.checked)).map((e=>e.value.name)):[];const t=Object.entries(G).filter((([e,t])=>z[e]));t.filter((([e,t])=>!e.startsWith(g)&&!e.startsWith(y))).forEach((([t,i])=>{e.externals[t]={};const n=i.inputs;Object.entries(n).slice(2).forEach((([i,n])=>{e.externals[t][i]=n}))})),t.filter((([e,t])=>e.startsWith(g))).forEach((([t,i])=>{e.scripts[t]={};const n=i.inputs;Object.entries(n).slice(2).forEach((([i,n])=>{e.scripts[t][i]=n}))})),t.filter((([e,t])=>e.startsWith(y))).forEach((([t,i])=>{e.queries[t]={};const n=i.inputs;Object.entries(n).slice(1).forEach((([i,n])=>{e.queries[t][i]=n}))})),console.log(e),n(e)}return Q.onTabChanged.subscribe((()=>{try{Q.currentPane.content.style.removeProperty("max-width")}catch(e){}})),Q.header.style.overflow="scroll",Q.root.style.width="100%",Q.root.style.minWidth="350px",H.appendChild(Q.root),Q.panes.forEach((e=>{const t=o.input.bool("",{value:z[W[e.name]],onValueChanged:i=>{z[W[e.name]]=!!t.value,i.value?X()(e.content).find("input").removeAttr("disabled"):X()(e.content).find("input").attr("disabled","true")}});t.setTooltip("Toggle calculation of this function"),e.header.appendChild(t.root),e.header.classList.add("hit-triage-compute-dialog-pane-header")})),r&&o.dialog("Compute").add(H).onOK((()=>K())).onCancel(a).show(),{root:H,okProxy:K}}))}const ie=rxjs;class ne{constructor(e,t=[],i={}){this.onItemChanged=new ie.Subject,this.onAddingItemChanged=new ie.Subject,this.onItemAdded=new ie.Subject,this.onItemRemoved=new ie.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.properties=e,this.options=Object.assign(Object.assign({},this.options),i),this._root=o.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=t,this.render()}get root(){return this._root}get items(){return this._items}set items(e){this._items=e,this.render()}addItem(e,t=!0){this._items.push(e),this.render(),t&&this.onItemAdded.next(e)}removeItem(e,t=!0){-1!==this._items.indexOf(e)&&(this._items.splice(this._items.indexOf(e),1),this.render(),t&&this.onItemRemoved.next(e))}removeAtIndex(e,t=!0){if(e<0||e>=this._items.length)return;const i=this._items.splice(e,1);this.render(),t&&this.onItemRemoved.next(i[0])}removeAllItems(){this._items=[],this.render()}render(){var e,t,i,n;if(o.empty(this._root),!this.options.horizontalInputNames)for(const t of this.properties){const i=o.divText(null!==(e=t.caption)&&void 0!==e?e:t.name);i.style.fontWeight="bold",this._root.appendChild(i)}for(const e of this._items){const t=this.getItemDiv(e);for(const e of t)this._root.appendChild(e)}if(this.options.allowAdd){const e=this.getItemDiv(null!==(n=null===(i=(t=this.options).newItemFunction)||void 0===i?void 0:i.call(t))&&void 0!==n?n:void 0,!0);for(const t of e)this._root.appendChild(t)}}getItemDiv(e={},i){var n;const a=[],s={};let r=null;for(const l of this.properties){void 0===e[l.name]&&(e[l.name]=null);const c=(null===(n=this.options.customInputs)||void 0===n?void 0:n[l.name])?this.options.customInputs[l.name](e):o.input.forProperty(l,e);a.push(this.options.horizontalInputNames?c.root:this.hideLabel(c.root)),l.propertyType!==t.TYPE.BOOL&&"color"!==l.name.toLowerCase()&&c.input&&(c.input.style.width="100%"),s[l.name]=c,c.onChanged((()=>{e[l.name]=c.value,i?this.onAddingItemChanged.next({item:e,fieldName:l.name}):this.onItemChanged.next({item:e,fieldName:l.name})})),c.root.style.alignItems="center",r=c}let l=null;if(i)l=o.icons.add((()=>{const e=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(s).forEach((t=>{e[t]=s[t].value})),this._items.push(e),this.onItemAdded.next(e),this.render()}),this.options.addButtonTooltip);else{if(!this.options.allowRemove)return a;l=o.icons.delete((()=>{this._items.splice(this._items.indexOf(e),1),this.onItemRemoved.next(e),this.render()}),this.options.removeButtonTooltip)}return r&&r.addOptions?r.addOptions(l):null==r||r.root.appendChild(l),l.style.color="#2083d5",a}hideLabel(e){return e.getElementsByTagName("label")[0]&&e.removeChild(e.getElementsByTagName("label")[0]),e}}var oe=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function ae(){const e=t.Property.fromOptions({name:"layout",caption:"Layout",type:"file"}),i=t.InputBase.forProperty(e);let n=null,o=null,a=null;return i.addValidator((e=>a)),i.onChanged((()=>oe(this,void 0,void 0,(function*(){const e=i.value;if(e)try{const i=yield e.readAsString(),s=t.ViewLayout.fromJson(i);s?(n=s,o=s.viewState,a=null):(n=null,o=null,a="Invalid layout file")}catch(e){n=null,o=null,a="Invalid layout file"}i.setTooltip("Select a layout file")})))),{dataFileInput:i,getLayout:()=>n,getLayoutViewState:()=>o}}var se=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function re(i,n){return se(this,void 0,void 0,(function*(){var a,s;const r=(yield De.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5))),l=[];for(const e of r){const t=JSON.parse(yield De.files.readAsText(`Hit Triage/templates/${e}.json`));l.push(t.key)}const c=t.Func.find({tags:[d]}),p={};c.forEach((e=>{var t;p[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const h=o.input.choice("Submit function",{value:null,items:[null,...Object.keys(p)]});h.value=null,h.nullable=!0,h.fireChanged(),h.setTooltip("Select function to be called upon submitting");const m=ae(),v=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"}),w=o.input.string("Name",{value:"",onValueChanged:()=>{""===w.value||r.includes(w.value)?(w.root.style.borderBottom="1px solid red",v.style.opacity="100%"):(w.root.style.borderBottom="none",v.style.opacity="0%")}}),C=o.input.string("Key",{value:"",onValueChanged:()=>{""===C.value||l.includes(C.value)?(C.root.style.borderBottom="1px solid red",f.style.opacity="100%"):(C.root.style.borderBottom="none",f.style.opacity="0%")}});C.setTooltip("Template key used for campaign prefix"),w.setTooltip("Template name"),w.root.style.borderBottom="none",C.root.style.borderBottom="none",v.style.opacity="0%",f.style.opacity="0%";let A=null;const x=yield te(i,(e=>{A=e}),(()=>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=t.Func.find({tags:[u]}),o=yield e.dapi.queries.include("params,connection").filter(`#${u}`).list();i.forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e})),o.forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}))}const N=Object.keys(n),I=o.input.choice(b,{value:N[0],items:N}),E=o.input.choice("Ingest using",{value:"Query",items:["Query","File"],onValueChanged:()=>{"Query"!==E.value?I.root.style.display="none":I.root.style.display="block"}}),_=le(),F=o.div([o.h2("Details"),o.div([w,v]),o.div([C,f]),E.root,I.root,m.dataFileInput,_.fieldsDiv,o.h2("Compute"),x.root,o.h2("Submit"),h.root],"ui-form"),V=o.buttonsInput([]),O=null!==(s=null===(a=V.getElementsByClassName("ui-input-editor"))||void 0===a?void 0:a[0])&&void 0!==s?s:V;F.appendChild(V);const B=new Promise((e=>{const t=o.button(S,(()=>e()));O.appendChild(t)})),P=new Promise((t=>{const i=o.bigButton(T,(()=>function(){return se(this,void 0,void 0,(function*(){var i,n,o,a,s,r,l,c;if(x.okProxy(),"100%"===v.style.opacity)return void e.shell.error("Template name is empty or already exists");const u=h.value?p[h.value]:void 0,d=Object.assign(Object.assign({name:w.value,key:C.value,campaignFields:_.getFields(),dataSourceType:null!==(i=E.value)&&void 0!==i?i:"Query",layoutViewState:null!==(n=m.getLayoutViewState())&&void 0!==n?n:void 0,compute:{descriptors:{enabled:!!(null===(o=null==A?void 0:A.descriptors)||void 0===o?void 0:o.length),args:null!==(a=null==A?void 0:A.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(s=null==A?void 0:A.externals)&&void 0!==s?s:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(r=null==A?void 0:A.scripts)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(g)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(l=null==A?void 0:A.queries)&&void 0!==l?l:{}).filter((([e,t])=>e.startsWith(y)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))}},u?{submit:{fName:u.name,package:u.package.name}}:{}),{queryFunctionName:"Query"===E.value&&null!==(c=I.value)&&void 0!==c?c:void 0});var f;f=d,De.files.writeAsText(`Hit Triage/templates/${f.name}.json`,JSON.stringify(f)),e.shell.info("Template created successfully"),t(d)}))}()));O.appendChild(i)}));return{root:F,template:P,cancelPromise:B}}))}function le(e){const i=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING}),t.Property.fromOptions({name:"Type",type:t.TYPE.STRING,choices:Object.keys(Q)}),t.Property.fromOptions({name:"Required",type:t.TYPE.BOOL})],n=new ne(i,e?e.map((e=>({Name:e.name,Type:e.type,Required:e.required}))):void 0,{horizontalInputNames:!1});n.root.style.maxWidth="750px";let a={};n.onItemAdded.subscribe((e=>{a={}})),n.onAddingItemChanged.subscribe((e=>{e&&(a=e.item)}));const s=o.h2("Additional fields");o.tooltip.bind(s,"Additional fields to be filled by user for each campaign");const r=o.div([s,n.root]);return{getFields:function(){var e;const t=n.items.filter((e=>e.Name)).map((e=>{var t;return{name:e.Name,type:e.Type,required:null!==(t=e.Required)&&void 0!==t&&t}}));return a.Name&&""!==a.Name&&a.Type&&(null!==(e=a.Required)&&void 0!==e||(a.Required=!1),t.push({name:a.Name,type:a.Type,required:a.Required})),t},fieldsDiv:o.div([r])}}var ce=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class ue extends t.ViewBase{constructor(e){super(),this.deletedCampaigns=[],this.app=e}get template(){return this.app.template}onActivated(){}onReset(){}process(){return ce(this,void 0,void 0,(function*(){}))}deleteCampaign(e,t){return ce(this,void 0,void 0,(function*(){yield De.files.delete(`${e}/campaigns/${t}`)}))}}var de=i(677),pe={};pe.styleTagTransform=R(),pe.setAttributes=k(),pe.insert=B().bind(null,"head"),pe.domAPI=V(),pe.insertStyleElement=j(),_()(de.A,pe),de.A&&de.A.locals&&de.A.locals;var he;!function(t){let i,n;!function(e){e.vert=function(e){return o.divV(e.map((e=>o.render(e))),{classes:"u2-panel"})},e.horz=function(e){return o.divH(e.map((e=>o.render(e))),{classes:"u2-panel"})}}(i=t.panels||(t.panels={})),t.appHeader=function(e){const t=o.iconImage("",e.iconPath);return X()(t).addClass("ui-app-header-icon").css("margin-right","20px"),i.horz([t,i.vert([o.markdown(e.description),e.learnMoreUrl?o.link("Learn more",e.learnMoreUrl):null])])},function(t){t.runAsync=function(t,i){return n=this,a=void 0,r=function*(){o.setUpdateIndicator(t,!0);try{return yield i()}catch(t){e.log.error(t)}finally{o.setUpdateIndicator(t,!1)}},new((s=void 0)||(s=Promise))((function(e,t){function i(e){try{l(r.next(e))}catch(e){t(e)}}function o(e){try{l(r.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof s?n:new s((function(e){e(n)}))).then(i,o)}l((r=r.apply(n,a||[])).next())}));var n,a,s,r}}(n=t.tools||(t.tools={}))}(he||(he={}));var me=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class ve extends ue{constructor(t){super(t),this.readmePath=De.webRoot+"README_HT.md",this.dataSourceFunctionsMap={},this.name="Hit Triage",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(this.readmePath),this.checkCampaign().then((e=>{this.app.campaign=e,this.init()}))}onActivated(){e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(this.readmePath)}init(e){return me(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const t=o.h1(N),i=o.h1(I,{style:{marginLeft:"10px"}}),n=he.appHeader({iconPath:De.webRoot+"/images/icons/hit-triage-icon.png",learnMoreUrl:"https://github.com/datagrok-ai/public/blob/master/packages/HitTriage/README_HT.md",description:"- Configure your own workflow using the template editor.\n- Calculate different molecular properties.\n- Filter molecules using different criteria.\n- Submit processed dataframe to the function of your choice.\n- Save campaigns and continue any time from where you left off.\n "}),a=o.div(),s=o.div([],{classes:"ui-form"}),r=yield this.getCampaignsTable();yield this.startNewCampaign(a,s,e),X()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,t],{style:{marginLeft:"10px"}}),r,i,s,a])),this.app.resetBaseUrl()}catch(e){throw o.setUpdateIndicator(this.root,!1),e}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(e,t,i){return me(this,void 0,void 0,(function*(){var n;const a=(yield De.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5)));i&&!a.includes(i.name)&&a.push(i.name);const s=()=>me(this,void 0,void 0,(function*(){const t=r.value,n=i&&i.name===t?i:JSON.parse(yield De.files.readAsText("Hit Triage/templates/"+t+".json")),o=yield this.getNewCampaignAccordeon(n,e);X()(e).empty(),e.className="ui-form",e.appendChild(o)})),r=o.input.choice("Template",{value:null!==(n=null==i?void 0:i.name)&&void 0!==n?n:a[0],items:a,onValueChanged:()=>me(this,void 0,void 0,(function*(){yield s()}))}),l=o.icons.add((()=>me(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),o.setUpdateIndicator(this.root,!1)}))),C);r.addOptions(l),yield s(),X()(t).empty(),t.appendChild(r.root)}))}checkCampaign(e){return me(this,void 0,void 0,(function*(){const t=location.search,i=new URLSearchParams(t);if(!i.has(a)&&!e)return;const n=null!=e?e:i.get(a);if(!(yield De.files.exists(`Hit Triage/campaigns/${n}/${l}`)))return;const o=JSON.parse(yield De.files.readAsText(`Hit Triage/campaigns/${n}/${l}`)),s=JSON.parse(yield De.files.readAsText(`Hit Triage/templates/${o.templateName}.json`));return this.app.setTemplate(s,o.filters,n,o.ingest),e&&q(a,e),o}))}getCampaignsTable(){return me(this,void 0,void 0,(function*(){const e=yield z("Hit Triage",this.deletedCampaigns),t=Object.values(e).map((e=>({name:e.name,createDate:e.createDate,rowCount:e.rowCount,filtered:e.filteredRowCount,status:e.status}))),i=o.table(t,(e=>[o.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.filtered,e.status,o.icons.delete((()=>me(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK((()=>me(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Triage",e.name),this.deletedCampaigns.push(e.name),yield this.init()})))).show()}))),"Delete campaign")]),["Name","Created","Total","Selected","Status",""]);return i.style.color="var(--grey-5)",i}))}setCampaign(e){return me(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(i,n){return me(this,void 0,void 0,(function*(){o.setUpdateIndicator(n,!0);const{root:a,promise:s,cancelPromise:r}=yield function(i,n){return K(this,void 0,void 0,(function*(){var a,s;const r=o.divText("",{style:{color:"red"}});let l=null;const c=()=>K(this,void 0,void 0,(function*(){try{if(l=d.value,!l)return;if(yield l.meta.detectSemanticTypes(),!l.columns.bySemType(t.SEMTYPE.MOLECULE))return void(r.innerText="No molecules column found");r.innerText=""}catch(e){r.innerText="Error parsing file"}})),d=o.input.table("Dataframe",{onValueChanged:c});yield c();const p=o.div([d,r]);0===Object.keys(n).length&&(t.Func.find({tags:[u]}).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e})),(yield e.dapi.queries.include("params,connection").filter(`#${u}`).list()).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e})));let h=null;const m=()=>K(this,void 0,void 0,(function*(){const e=n[f.value];h=e.prepare();const t=yield h.getEditor();t.classList.remove("ui-form"),v.innerHTML="",v.appendChild(t)})),v=o.div([]),f=o.input.choice(b,{value:null!==(a=i.queryFunctionName)&&void 0!==a?a:Object.keys(n)[0],items:Object.keys(n),onValueChanged:m});yield m(),i.queryFunctionName&&(null===(s=f.root.getElementsByTagName("select").item(0))||void 0===s||s.setAttribute("disabled","true"));const g=o.div([f,v]);g.style.display="none";const y=o.div([p,g]),w=i.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:Q[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),C={},T=w.length?o.input.form(C,w):o.div();T.classList.remove("ui-form"),"File"===i.dataSourceType?(p.style.display="inherit",g.style.display="none"):(p.style.display="none",g.style.display="inherit");const x=o.div([y,...w.length?[T]:[]]),N=o.buttonsInput([]);return x.appendChild(N),{promise:new Promise((t=>{const a=()=>K(this,void 0,void 0,(function*(){if("File"===i.dataSourceType){if(!l)return void e.shell.error("No file selected");const i=l;i.name=l.name,t({df:i,type:"File",campaignProps:C})}else{const i=n[f.value];if(!i)return void e.shell.error("No function selected");const o={};Object.entries(h.inputs).forEach((([e,t])=>{o[e]=t}));const a=yield i.apply(o);t({df:a,type:"Query",campaignProps:C})}})),s=o.bigButton(A,(()=>a()));N.appendChild(s)})),root:x,cancelPromise:new Promise((e=>{o.button(S,(()=>e()))}))}}))}(i,this.dataSourceFunctionsMap);return o.setUpdateIndicator(n,!1),s.then((e=>me(this,void 0,void 0,(function*(){this.app.dataFrame=e.df,this.app._fileInputType=e.type,yield this.app.setTemplate(i),this.app.campaignProps=e.campaignProps,yield this.app.saveCampaign(void 0,!1),i.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=i.layoutViewState)})))),r.then((()=>{this.init()})),a}))}createNewTemplate(){return me(this,void 0,void 0,(function*(){const i=yield re(this.app,this.dataSourceFunctionsMap),n=new t.ViewBase,o=e.shell.v;n.name="New Template",n.root.appendChild(i.root),n.parentCall=this.app.parentCall,e.shell.addView(n),n.path=new URL(this.app.baseUrl).pathname+"/new-template",n.parentView=o;const{sub:a}=Y(e.shell.v,"Hit Triage",C,(()=>{e.shell.v=o,n.close()}));i.template.then((t=>me(this,void 0,void 0,(function*(){yield this.init(t),n.close(),W(n),e.shell.v=o,a.unsubscribe()})))),i.cancelPromise.then((()=>{a.unsubscribe(),n.close(),e.shell.v=o}))}))}}class fe extends ue{constructor(e){super(e),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){return i=this,n=void 0,a=function*(){var i;const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=t.Func.find({name:n.fName,package:n.package})[0];if(!o)return void e.shell.error(`Function ${n.fName} not found.`);const a=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:a,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((o=void 0)||(o=Promise))((function(e,t){function s(e){try{l(a.next(e))}catch(e){t(e)}}function r(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof o?i:new o((function(e){e(i)}))).then(s,r)}l((a=a.apply(i,n||[])).next())}));var i,n,o,a}}var ge=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class ye{constructor(i){this.parentCall=i,this.isJoining=!1,this.resetBaseUrl(),this.computeFunctions=new Promise((i=>ge(this,void 0,void 0,(function*(){const n=t.Func.find({tags:[c]}).filter((e=>"function-package"===e.type)),o=yield e.dapi.scripts.include("params").filter(`#${c}`).list(),a=yield e.dapi.queries.include("params,connection").filter(`#${c}`).list();i({functions:n,scripts:o,queries:a})}))))}resetBaseUrl(){const e=window.location.href,t=new URL(e);this.baseUrl=t.origin+t.pathname}getFilterType(e){const i=this.dataFrame.col(e);return(null==i?void 0:i.semType)===t.SEMTYPE.MOLECULE?t.FILTER_TYPE.SUBSTRUCTURE:(null==i?void 0:i.type)===t.COLUMN_TYPE.BOOL?t.FILTER_TYPE.BOOL_COLUMNS:(null==i?void 0:i.type)===t.COLUMN_TYPE.STRING?t.FILTER_TYPE.CATEGORICAL:t.FILTER_TYPE.HISTOGRAM}download(e,i,n=!1){const o=document.createElement("a"),a=t.DataFrame.fromColumns(e.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv({filteredRowsOnly:n});o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),o.setAttribute("download",i+".csv"),o.click()}getNewCampaignName(e,t){return ge(this,void 0,void 0,(function*(){const i=(yield De.files.list(e)).map((e=>e.name)).filter((e=>e.startsWith(t)));if(0===i.length)return t+"-1";const n=i.map((e=>e.split("-")[1])).filter(Boolean).map((e=>parseInt(e,10))).sort();return t+"-"+(n[n.length-1]+1).toString()}))}setBaseUrl(){const e=document.title;if(history.replaceState){const t={Title:e,Url:this.baseUrl};history.replaceState(t,t.Title,t.Url)}}unionDataframes(e,i,n){var o,a,s,r,l;const c=null===(a=null===(o=e.col(n))||void 0===o?void 0:o.toList())||void 0===a?void 0:a.filter((e=>!!e)).map((e=>t.chem.convert(e,t.chem.Notation.Unknown,t.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((e=>!!e)).map((e=>t.chem.convert(e,t.chem.Notation.Unknown,t.chem.Notation.Smiles)));if(!c||!u)throw new Error("Molecule column not found");this.isJoining=!0;try{for(const t of e.columns)i.columns.contains(t.name)||i.columns.addNew(t.name,t.type);for(let t=0;t<c.length;t++)if(!u.includes(c[t])){i.rows.addNew(null,!0);for(const n of e.columns){const e=n.get(t);null===(l=i.col(n.name))||void 0===l||l.set(i.rowCount-1,e,!1)}}}finally{setTimeout((()=>{this.isJoining=!1}),500)}return i}}var we=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))},be=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function Ce(e){let t=0;if(e.length>1)for(const i of e.toList()){if(!i||!i.startsWith(f[0])||7!==i.length)continue;const e=parseInt(i.substring(1));isNaN(e)||(t=Math.max(e,t))}return`V${"".concat(...new Array(6-(t+1).toString().length).fill("0"))}${t+1}`}function Ae(i,n,o){return be(this,void 0,void 0,(function*(){var a,s;const r=t.TaskBarProgressIndicator.create("Calculating ..."),l=n.col(o);if(!l)throw new Error("There is no molecule column in dataframe");for(let t=0;t<l.length;t++){if(l.isNone(t))continue;const i=l.get(t);if(!i)continue;const n=e.chem.convert(i,e.chem.Notation.Unknown,e.chem.Notation.Smiles);l.set(t,n,!1)}try{i.descriptors&&i.descriptors.length>0&&(yield e.chem.descriptors(n,o,i.descriptors))}catch(e){console.error("Descriptors calculation error",e)}for(const e of Object.keys(i.externals))try{const a=i.externals[e],s=t.Func.find({package:e.split(":")[0],name:e.split(":")[1]})[0],r=s.inputs[0].name,l=s.inputs[1].name;a&&(yield s.apply(Object.assign(Object.assign({},a),{[r]:n,[l]:o})))}catch(e){console.error(e)}for(const t of Object.keys(null!==(a=i.scripts)&&void 0!==a?a:{})){const a=i.scripts[t];if(a){const i=t.split(":")[2];if(!i)continue;try{const t=yield e.dapi.scripts.find(i);if(!t)continue;const s=t.inputs[0].name,r=t.inputs[1].name,l=yield t.apply(Object.assign(Object.assign({},a),{[s]:n,[r]:o}));if(l&&l.rowCount===n.rowCount&&"python"===t.language)for(const e of l.columns)e.name=n.columns.getUnusedName(e.name),n.columns.add(e)}catch(e){console.error(e)}}}for(const t of Object.keys(null!==(s=i.queries)&&void 0!==s?s:{})){const a=i.queries[t];if(a){const i=t.split(":")[2];if(!i)continue;try{const t=yield e.dapi.queries.find(i);if(!t)continue;const s=t.inputs[0].name,r=n.col(o).toList(),l=yield t.apply(Object.assign(Object.assign({},a),{[s]:r}));l&&(yield G(n,o,l))}catch(e){console.error(e)}}}r.close()}))}var Te=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class xe extends ye{get infoView(){return this._infoView}constructor(i){super(i),this._filterViewName="Hit triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=new ve(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof ue&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,e.events.onCurrentViewChanged.subscribe((()=>{var t,i,n,o;try{(null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentPickViewId&&(e.shell.windows.showHelp=!1,this.setBaseUrl(),q(a,null!==(o=null!==(i=this._campaignId)&&void 0!==i?i:null===(n=this._campaign)||void 0===n?void 0:n.name)&&void 0!==o?o:""))}catch(e){console.error(e)}}))}setTemplate(i,n,o,s){return Te(this,void 0,void 0,(function*(){var r,l,c,u,d,p,h,m,v,f,w,b,C,A,T;if((null===(r=this._pickView)||void 0===r?void 0:r.dataFrame)&&e.shell.closeTable(null===(l=this._pickView)||void 0===l?void 0:l.dataFrame),this._pickView=void 0,o?s&&(this._fileInputType=s.type,"File"===s.type?this.dataFrame=yield e.dapi.files.readCsv(s.query):this.dataFrame=yield e.functions.call(s.query)):(o=yield this.getNewCampaignName("Hit Triage/campaigns",i.key),q(a,o)),!this.dataFrame)return void console.error("Dataframe is empty.");if((null===(c=this._campaign)||void 0===c?void 0:c.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&i.semType!==t&&(i.semType=t)})),(null===(u=this._campaign)||void 0===u?void 0:u.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);if(i&&i.type!==t)try{i.convertTo(t)}catch(e){console.error(e)}})),yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(p=null===(d=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===d?void 0:d.name)&&void 0!==p?p:void 0,this._dfName=null!==(h=this.dataFrame.name)&&void 0!==h?h:null==s?void 0:s.query,this.dataFrame.name=null!==(v=null!==(m=this._dfName)&&void 0!==m?m:this.dataFrame.name)&&void 0!==v?v:"Molecules",this._campaignId=o,this.template=(null===(f=this.campaign)||void 0===f?void 0:f.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:i.dataSourceType,queryFunctionName:i.queryFunctionName}):i,this._campaignFilters=n,!n){const e={},t={},n={};i.compute.functions.forEach((t=>{const i=`${t.package}:${t.name}`;e[i]=t.args})),null===(w=i.compute.scripts)||void 0===w||w.forEach((e=>{const i=`${g}:${e.name}:${e.id}`;t[i]=e.args})),null===(b=i.compute.queries)||void 0===b||b.forEach((e=>{const t=`${y}:${e.name}:${e.id}`;n[t]=e.args})),yield Ae({descriptors:i.compute.descriptors.enabled?i.compute.descriptors.args:[],externals:e,scripts:t,queries:n},this.dataFrame,this._molColName)}const x=e.shell.v,S=e.shell.addView(this.pickView);this.currentPickViewId=S.name,this._submitView=new fe(this),this.setBaseUrl(),q(a,null!==(T=null!==(C=this._campaignId)&&void 0!==C?C:null===(A=this._campaign)||void 0===A?void 0:A.name)&&void 0!==T?T:"");const N=S;setTimeout((()=>{this._pickViewPromise&&this._pickViewPromise.then((()=>{const{sub:t}=Y(N,"Hit Triage","Pick",(()=>{e.shell.v=x,N.close(),t.unsubscribe()}))}))}),300),e.shell.windows.showHelp=!1}))}get filterSettings(){return this._campaignFilters}get campaignId(){return this._campaignId}get pickView(){return this._pickView=this.getFilterView()}get molColName(){var e,i,n;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name}get fileInputType(){return this._fileInputType}get campaign(){return this._campaign}set campaign(e){this._campaign=e}getFilterView(){let e=null;this._pickViewPromise=new Promise((t=>{e=t})),this.dataFrame.col(p)||this.dataFrame.columns.addNewBool(p).init(!1);const i=t.TableView.create(this.dataFrame,!1),n=i.getRibbonPanels(),a=o.iconFA("wrench",(()=>Te(this,void 0,void 0,(function*(){te(this,(e=>Te(this,void 0,void 0,(function*(){var t,i,n,o,a,s,r;const l=this.template.compute.descriptors.args,c=this.template.compute.functions,u=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],d=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],p=e.descriptors,h={descriptors:{enabled:!!(null===(n=null==e?void 0:e.descriptors)||void 0===n?void 0:n.length),args:null!==(o=null==e?void 0:e.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(a=null==e?void 0:e.externals)&&void 0!==a?a:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(s=null==e?void 0:e.scripts)&&void 0!==s?s:{}).filter((([e,t])=>e.startsWith(g)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(r=null==e?void 0:e.queries)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(y)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))};this.template.compute=h;const m=p.filter((e=>!l.includes(e))),v=h.functions.filter((e=>{if(!c.some((t=>t.name===e.name&&t.package===e.package)))return!0;const t=c.find((t=>t.name===e.name&&t.package===e.package));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),f=h.scripts.filter((e=>{if(!u.some((t=>t.id===e.id)))return!0;const t=u.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),w=h.queries.filter((e=>{if(!d.some((t=>t.id===e.id)))return!0;const t=d.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),b={};v.forEach((e=>{const t=`${e.package}:${e.name}`;b[t]=e.args}));const C={};f.forEach((e=>{const t=`${g}:${e.name}:${e.id}`;C[t]=e.args}));const A={};w.forEach((e=>{const t=`${y}:${e.name}:${e.id}`;A[t]=e.args})),yield Ae({descriptors:m,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 e;const t=null===(e=this._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}}));s.classList.add("hit-design-submit-button");const r=J(n);return n.push([a,...r?[]:[s]]),i.setRibbonPanels(n),i.name=this._filterViewName,setTimeout((()=>Te(this,void 0,void 0,(function*(){var n,o,a;i._onAdded(),yield new Promise((e=>setTimeout(e,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 e=t.ViewLayout.fromViewState(r);i.loadLayout(e)}catch(e){console.error(e)}i.dataFrame.onFilterChanged.subscribe((e=>{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),e&&e()}))),300),i.parentCall=this.parentCall,i}getSummary(){var e,t,i,n,a,s,r;const l=null!==(t=null===(e=this.campaign)||void 0===e?void 0:e.campaignFields)&&void 0!==t?t:this.campaignProps;return Object.assign(Object.assign({Template:null!==(n=null===(i=this.template)||void 0===i?void 0:i.name)&&void 0!==n?n:"Molecules","File path":o.divH([o.link(null!==(a=this._dfName)&&void 0!==a?a:"-",(()=>this.download(this.dataFrame,"molecules")),x)],{style:{alignItems:"center"}})},l),{"Number of molecules":this.dataFrame.rowCount.toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((e=>e.name))].filter((e=>e&&""!==e.trim())).join(", "),Filters:this._filterDescriptions.join(", "),"Result Molecules":o.divH([o.link(null!==(r=null===(s=this.dataFrame)||void 0===s?void 0:s.filter.trueCount.toString())&&void 0!==r?r:"0",(()=>{this.download(this.dataFrame,"hits",!0)}),x)],{style:{alignItems:"center"}})})}saveCampaign(i){return Te(this,arguments,void 0,(function*(i,n=!0){var a,s,c,u,d,p;const h=this.campaignId,m=this.filterSettings,v=this.template.name,f=this.dataFrame,g=`System:AppData/HitTriage/Hit Triage/campaigns/${h}/`,y=null!=h?h:yield function(e){return we(this,void 0,void 0,(function*(){return new Promise((t=>we(this,void 0,void 0,(function*(){const i=o.input.string("Campaign name",{value:""});o.dialog("Save Campaign").add(o.div(i.root)).onOK((function(){i.value&&""!==i.value?t(i.value):t(e)})).show()}))))}))}(h),w={};f.columns.toList().forEach((e=>w[e.name]=e.semType));const b={};f.columns.toList().forEach((e=>b[e.name]=e.type));const C={name:y,templateName:v,filters:null!=m?m:{},ingest:{type:"File",query:`${g}${r}`,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!==(u=null===(c=this.campaign)||void 0===c?void 0:c.createDate)&&void 0!==u?u:U(new Date),campaignFields:null!==(p=null===(d=this.campaign)||void 0===d?void 0:d.campaignFields)&&void 0!==p?p:this.campaignProps,columnSemTypes:w,rowCount:f.rowCount,filteredRowCount:f.filter.trueCount,template:this.template,columnTypes:b};this.campaign=C;const A=t.DataFrame.fromColumns(f.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield De.files.writeAsText(`Hit Triage/campaigns/${h}/${r}`,A);const T=this._pickView.saveLayout();T?C.layout=T.viewState:e.shell.warning("Layout cound not be saved"),yield De.files.writeAsText(`Hit Triage/campaigns/${h}/${l}`,JSON.stringify(C)),n&&e.shell.info("Campaign saved successfully.")}))}}var Se=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function Ne(i,n){return Se(this,void 0,void 0,(function*(){var a,s,r,l,c,u,p,h,m,v,f;const w=yield De.files.list("Hit Design/templates");let b=!1,C=!1;const A=w.map((e=>e.name.slice(0,-5))),x=[];for(const e of w)try{const t=JSON.parse(yield De.files.readAsText(e));x.push(t.key)}catch(e){console.error(e)}const N=t.Func.find({tags:[d]}),I={};N.forEach((e=>{var t;I[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const E=o.input.choice("Submit function",{value:null,items:[null,...Object.keys(I)]});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"}),V=ae();function O(){var e,t,i,n;if(""===B.value||A.includes(null!==(t=null===(e=B.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=B.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=B.input.offsetWidth)&&void 0!==n?n:0;_.style.marginLeft=`${e}px`,_.style.width=`${t}px`,_.style.opacity="100%",_.style.borderTop="1px solid red",b=!0}else _.style.borderTop="none",_.style.opacity="0%",b=!1}const B=o.input.string("Name",{value:null!==(r=null==n?void 0:n.name)&&void 0!==r?r:"",onValueChanged:O});function P(){var e,t,i,n;if(""===k.value||x.includes(null!==(t=null===(e=k.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=k.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=k.input.offsetWidth)&&void 0!==n?n:0;F.style.marginLeft=`${e}px`,F.style.width=`${t}px`,F.style.borderTop="1px solid red",F.style.opacity="100%",C=!0}else F.style.opacity="0%",F.style.borderTop="none",C=!1}const k=o.input.string("Key",{value:null!==(l=null==n?void 0:n.key)&&void 0!==l?l:"",onValueChanged:P});k.setTooltip("Template key used for campaign prefix"),B.setTooltip("Template name"),B.root.style.borderBottom="none",k.root.style.borderBottom="none",_.style.opacity="0%",F.style.opacity="0%";let L=null;const j={compute:{descriptors:{enabled:!0,args:null!==(p=null===(u=null===(c=null==n?void 0:n.compute)||void 0===c?void 0:c.descriptors)||void 0===u?void 0:u.args)&&void 0!==p?p:[]},functions:null!==(m=null===(h=null==n?void 0:n.compute)||void 0===h?void 0:h.functions)&&void 0!==m?m:[]}},D=yield te(i,(e=>{L=e}),(()=>null),j,!1);D.root.classList.add("hit-triage-new-template-functions-input");const R=le(null==n?void 0:n.campaignFields),$=function(e){const i=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING})],n=new ne(i,e?e.map((e=>({Name:e}))):void 0,{horizontalInputNames:!0});let o={};return n.onItemAdded.subscribe((e=>{o={}})),n.onAddingItemChanged.subscribe((e=>{e&&(o=e.item)})),{getFields:function(){const e=n.items.filter((e=>e.Name)).map((e=>e.Name));return o.Name&&""!==o.Name&&e.push(o.Name),e},fieldsDiv:n.root}}(null==n?void 0:n.stages),M=o.divV([o.divV([B,_]),o.divV([k,F]),V.dataFileInput,R.fieldsDiv]),H=o.h2("Stages");o.tooltip.bind(H,'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 q=o.div([o.h2("Details"),M,H,$.fieldsDiv,U,D.root,o.h2("Submit"),E.root],"ui-form"),Y=o.buttonsInput([]);q.appendChild(Y);const W=null!==(f=null===(v=Y.getElementsByClassName("ui-input-editor"))||void 0===v?void 0:v[0])&&void 0!==f?f:Y,J=new Promise((e=>{const t=o.button(S,(()=>e()));W.appendChild(t)})),G=new Promise((t=>{const i=o.bigButton(T,(()=>function(){return Se(this,void 0,void 0,(function*(){var i,n,o,a,s,r;if(O(),P(),D.okProxy(),b||!B.value||""===B.value)return void e.shell.error("Template name is empty or already exists");if(C||!k.value||""===k.value)return void e.shell.error("Template key is empty or already exists");const l=E.value?I[E.value]:void 0,c=Object.assign({name:B.value,key:k.value,campaignFields:R.getFields(),stages:$.getFields(),layoutViewState:null!==(i=V.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((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(s=null==L?void 0:L.scripts)&&void 0!==s?s:{}).filter((([e,t])=>e.startsWith(g)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(r=null==L?void 0:L.queries)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(y)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))}},l?{submit:{fName:l.name,package:l.package.name}}:{});var u;u=c,De.files.writeAsText(`Hit Design/templates/${u.name}.json`,JSON.stringify(u)),e.shell.info("Template created successfully"),t(c)}))}()));W.appendChild(i)}));return{root:q,template:G,cancelPromise:J}}))}var Ie=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class Ee extends ue{constructor(t){super(t),this.name="Hit Design",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(De.webRoot+"README_HD.md"),this.checkCampaign().then((e=>{this.app.campaign=e,this.init()}))}onActivated(){e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(De.webRoot+"README_HD.md")}init(e){return Ie(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const t=o.h1(N),i=o.h1(I,{style:{marginLeft:"10px"}}),n=he.appHeader({iconPath:De.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();X()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,t],{style:{marginLeft:"10px"}}),l,i,r])),yield this.startNewCampaign(a,s,e),this.app.resetBaseUrl()}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(e,t,i){return Ie(this,void 0,void 0,(function*(){var n;const a=(yield De.files.list("Hit Design/templates")).filter((e=>e.name.endsWith(".json"))).map((e=>e.name.slice(0,-5)));i&&!a.includes(i.name)&&a.push(i.name);let s=null;const r=()=>Ie(this,void 0,void 0,(function*(){const t=l.value,n=i&&i.name===t?i:JSON.parse(yield De.files.readAsText("Hit Design/templates/"+t+".json"));s=n;const o=yield this.getNewCampaignAccordeon(n);X()(e).empty(),e.appendChild(o)})),l=o.input.choice("Template",{value:null!==(n=null==i?void 0:i.name)&&void 0!==n?n:a[0],items:a,onValueChanged:()=>Ie(this,void 0,void 0,(function*(){yield r()}))});l.root.style.width="100%";const c=o.icons.add((()=>{this.createNewTemplate()}),C),u=o.icons.copy((()=>{s&&this.createNewTemplate(s)}),"Clone template");c.style.color="#2083d5",l.addOptions(u),l.addOptions(c),yield r(),X()(t).empty(),t.appendChild(l.root)}))}checkCampaign(e){return Ie(this,void 0,void 0,(function*(){var t;const i=location.search,n=new URLSearchParams(i);if(!n.has(s)&&!e)return;const o=null!=e?e:n.get(s);if(!(yield De.files.exists(`Hit Design/campaigns/${o}/${l}`)))return;const a=JSON.parse(yield De.files.readAsText(`Hit Design/campaigns/${o}/${l}`));a&&(this.app.campaign=a);const r=null!==(t=a.template)&&void 0!==t?t:JSON.parse(yield De.files.readAsText(`Hit Design/templates/${a.templateName}.json`));return yield this.app.setTemplate(r,o),e&&q(s,e),a.template=r,a}))}getCampaignsTable(){return Ie(this,void 0,void 0,(function*(){const e=yield z("Hit Design",this.deletedCampaigns),t=o.table(Object.values(e),(e=>[o.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.status,o.icons.delete((()=>Ie(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK((()=>Ie(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Design",e.name),this.deletedCampaigns.push(e.name),yield this.init()})))).show()}))),"Delete campaign")]),["Name","Created","Molecules","Status",""]);return t.style.color="var(--grey-5)",t.style.marginLeft="24px",t}))}setCampaign(e){return Ie(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(i){return Ie(this,void 0,void 0,(function*(){const{root:n,promise:a,cancelPromise:s}=function(i){var n,a;const s=t.DataFrame.create(1),r=s.columns.addNew(m,t.TYPE.STRING);r.semType=t.SEMTYPE.MOLECULE,r.meta.units=t.UNITS.Molecule.SMILES,r.set(0,null),(null===(n=null==i?void 0:i.stages)||void 0===n?void 0:n.length)>0&&s.columns.addNew(h,t.TYPE.STRING).set(0,i.stages[0]);const l=s.columns.addNew(v,t.TYPE.STRING);l.set(0,Ce(l));const c=i.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:Q[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),u={},d=o.input.form(u,c);d.classList.remove("ui-form");const p=o.div([...(null===(a=i.campaignFields)||void 0===a||a.length,[]),d]),f=o.buttonsInput([]);return p.appendChild(f),{promise:new Promise((t=>{const n=o.bigButton(A,(()=>{for(const t of i.campaignFields)if(t.required&&(!u[t.name]||""===u[t.name]))return void e.shell.error(`Field '${t.name}' is required`);t({df:s,campaignProps:u})}));f.appendChild(n)})),root:p,cancelPromise:new Promise((e=>{o.button(S,(()=>e()))}))}}(i);return a.then((e=>Ie(this,void 0,void 0,(function*(){this.app.dataFrame=e.df,yield this.app.setTemplate(i),this.app.campaignProps=e.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 Ie(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const n=yield Ne(this.app,i),o=new t.ViewBase,a=e.shell.v;o.name="New Template",o.root.appendChild(n.root),o.parentCall=this.app.parentCall,e.shell.addView(o),o.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:s}=Y(o,"Hit Design",C,(()=>Ie(this,void 0,void 0,(function*(){e.shell.v=a,o.close()}))));n.template.then((t=>Ie(this,void 0,void 0,(function*(){yield this.init(t),o.close(),W(o),e.shell.v=a,s.unsubscribe()})))),n.cancelPromise.then((()=>Ie(this,void 0,void 0,(function*(){s.unsubscribe(),o.close(),e.shell.v=a}))))}finally{o.setUpdateIndicator(this.root,!1)}}))}}class _e extends ue{constructor(e){super(e),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){return i=this,n=void 0,a=function*(){var i;const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=t.Func.find({name:n.fName,package:n.package})[0];if(!o)return void e.shell.error(`Function ${n.fName} not found.`);const a=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:a,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((o=void 0)||(o=Promise))((function(e,t){function s(e){try{l(a.next(e))}catch(e){t(e)}}function r(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof o?i:new o((function(e){e(i)}))).then(s,r)}l((a=a.apply(i,n||[])).next())}));var i,n,o,a}}var Fe=i(542),Ve={};Ve.styleTagTransform=R(),Ve.setAttributes=k(),Ve.insert=B().bind(null,"head"),Ve.domAPI=V(),Ve.insertStyleElement=j(),_()(Fe.A,Ve),Fe.A&&Fe.A.locals&&Fe.A.locals;class Oe extends ue{constructor(e){super(e),this.v=null,this.name="Progress Tracker"}render(){return i=this,n=void 0,s=function*(){return new Promise((i=>{var n,a,s,r,l,c,u,d;this.app.dataFrame.columns.names().forEach((e=>{e.startsWith("~")&&this.app.dataFrame.columns.remove(e)}));const p=null===(n=this.app.campaign)||void 0===n?void 0:n.tilesViewerFormSketch;let m=null;if(p&&p.length>0)try{m=JSON.parse(p)}catch(e){console.error("Failed to parse sketch state string",e)}let v=!0;if(!this.v||this.v.isDetached){v=!1,m&&m.elementStates&&(null!==(a=m.elementStates.length)&&void 0!==a?a:0)>0&&(m.elementStates=m.elementStates.filter((e=>{var t;return(null===(t=null==e?void 0:e.viewerSettings)||void 0===t?void 0:t.column)&&this.app.dataFrame.col(e.viewerSettings.column)}))),this.v=t.Viewer.fromType(t.VIEWER.TILE_VIEWER,this.app.dataFrame,Object.assign({lanesColumnName:h,lanes:null!==(r=null===(s=this.app.template)||void 0===s?void 0:s.stages)&&void 0!==r?r:[]},(null!==(c=null===(l=null==m?void 0:m.elementStates)||void 0===l?void 0:l.length)&&void 0!==c?c:0)>0?{sketchState:m}:{}));const e=this.v.getOptions();e.look.sketchState=(null!==(d=null===(u=null==m?void 0:m.elementStates)||void 0===u?void 0:u.length)&&void 0!==d?d:0)>0?m:null,this.v.setOptions(e),this.v.copyViewersLook(this.v)}v?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 t,n,a;null===(n=null===(t=this.v)||void 0===t?void 0:t.view)||void 0===n||n._onAdded();const s=null===(a=e.shell.v)||void 0===a?void 0:a.getRibbonPanels();if(s){if(J(s))return void i();const t=o.bigButton("Design view",(()=>{const t=e.shell.view(this.app.designViewName);t&&(e.shell.v=t)})),n=o.bigButton("Submit",(()=>{var e;const t=null===(e=this.app._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.app.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this.app._submitView)||void 0===t||t.submit(),e.close()})),e.show()}}));n.classList.add("hit-design-submit-button"),s.push([t,n]),e.shell.v.setRibbonPanels(s)}i()}),5))}))},new((a=void 0)||(a=Promise))((function(e,t){function o(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a((function(e){e(i)}))).then(o,r)}l((s=s.apply(i,n||[])).next())}));var i,n,a,s}onActivated(){this.render()}get sketchStateString(){if(!this.v)return null;const e=this.v.props.sketchState;return e&&"object"==typeof e?JSON.stringify(e):null}}const Be=rxjs.operators;var Pe=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};class ke extends ye{get infoView(){return this._infoView}get version(){var e,t;return null!==(t=null===(e=this._campaign)||void 0===e?void 0:e.version)&&void 0!==t?t:0}constructor(i){super(i),this._tilesViewTab=null,this._designViewName="Design",this._filePath="System.AppData/HitTriage/Hit Design/campaigns",this._molColName=m,this.campaignProps={},this.processedValues=[],this._extraStageColsCount=0,this._infoView=new Ee(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof ue&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,this.mainView=this.multiView,e.events.onCurrentViewChanged.subscribe((()=>Pe(this,void 0,void 0,(function*(){var t,i,n,o,s,r,l,c,u;try{if((null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentDesignViewId||(null===(i=e.shell.v)||void 0===i?void 0:i.name)===this.currentTilesViewId){if(e.shell.windows.showHelp=!1,this.setBaseUrl(),q(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=e.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 e=null===(c=this._tilesView)||void 0===c?void 0:c.sketchStateString;e&&""!=e&&this.campaign&&(this.campaign.tilesViewerFormSketch=e)}const{sub:t}=Y(e.shell.v,"Hit Design",null===(u=e.shell.v)||void 0===u?void 0:u.name,(()=>{var i,n;e.shell.v=this.mainView,null===(i=this._tilesView)||void 0===i||i.close(),null===(n=this._designView)||void 0===n||n.close(),this._infoView.init(),t.unsubscribe()}))}}catch(e){console.error(e)}}))))}setTemplate(i,n){return Pe(this,void 0,void 0,(function*(){var o,l,c,u,d,p,h,v,f,g,y,w,b;if(n){const t="System.AppData/HitTriage/Hit Design/campaigns";this._filePath=null!==(c=null===(l=this.campaign)||void 0===l?void 0:l.savePath)&&void 0!==c?c:`${t}/${n}/${r}`,this.dataFrame=yield e.dapi.files.readCsv(this._filePath),(null===(u=this._campaign)||void 0===u?void 0:u.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&t&&(i.semType=t)})),(null===(d=this._campaign)||void 0===d?void 0:d.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);if(i&&i.type!==t)try{this.dataFrame.changeColumnType(e,t)}catch(e){console.error(e)}}))}else(null===(o=this._designView)||void 0===o?void 0:o.dataFrame)&&e.shell.closeTable(this._designView.dataFrame),this._designView=void 0,n=yield this.getNewCampaignName("Hit Design/campaigns",i.key),q(s,n),this._filePath=`System.AppData/HitTriage/Hit Design/campaigns/${n}/${r}`;if(!this.dataFrame)return void console.error("DataFrame is empty");yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(h=null===(p=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===p?void 0:p.name)&&void 0!==h?h:m,this._dfName=null!==(v=(b=this.dataFrame).name)&&void 0!==v?v:b.name=n,this._campaignId=n,this.template=i,null!==(f=this._submitView)&&void 0!==f||(this._submitView=new _e(this)),e.shell.windows.showHelp=!1,this._extraStageColsCount=this.dataFrame.rowCount-this.dataFrame.filter.trueCount;const C=this.designView;this.currentDesignViewId=C.name,this.setBaseUrl(),q(a,null!==(w=null!==(g=this._campaignId)&&void 0!==g?g:null===(y=this._campaign)||void 0===y?void 0:y.name)&&void 0!==w?w:""),this.campaign&&(this.campaign.template=i)}))}get campaignId(){return this._campaignId}get designView(){return this._designView=this.getDesignView()}get designViewName(){return this._designViewName}get molColName(){var e,i,n,o;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null!==(o=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name)&&void 0!==o?o:m}get campaign(){return this._campaign}set campaign(e){this._campaign=e}cacheDuplicateVIDs(){var e;const t=null===(e=this.dataFrame)||void 0===e?void 0:e.col(v);if(!t)return void(this._duplicateVidCache=void 0);const i=t.version,n=new Uint32Array(t.categories.length).fill(0),o=t.getRawData();o.forEach((e=>n[e]++)),this._duplicateVidCache={colVersion:i,valueCounts:n,indexes:o}}get duplicateVidCache(){var e;const t=null===(e=this.dataFrame)||void 0===e?void 0:e.col(v);if(t)return this._duplicateVidCache&&t.version===this._duplicateVidCache.colVersion||this.cacheDuplicateVIDs(),this._duplicateVidCache}getDesignView(){var i,n,a,s,r,l;const c=[],u=null===(i=this.dataFrame.col(this.molColName))||void 0===i?void 0:i.toList().every((e=>!e&&""===e)),d=e.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,d.name=this._designViewName,this.processedValues=this.dataFrame.getCol(this.molColName).toList();const p=(i,n)=>Pe(this,void 0,void 0,(function*(){const o=this.template.compute;if(!n||""===n)return;const a=yield function(i,n,o){return be(this,arguments,void 0,(function*(i,n,o,a=[],s=[]){const r=t.TaskBarProgressIndicator.create("Calculating ..."),l=e.chem.convert(i,e.chem.Notation.Unknown,e.chem.Notation.Smiles),c=t.Column.fromStrings(m,[l]),u=t.DataFrame.fromColumns([c]);u.name="HD Single cell values",yield u.meta.detectSemanticTypes();try{n.length&&(yield e.chem.descriptors(u,c.name,n))}catch(e){console.error("Descriptors calculation error",e)}for(const e of o)try{const i=e.args,n=t.Func.find({package:e.package,name:e.name});if(!n.length||!n[0]){console.warn(`Function ${e.name} from package ${e.package} is not found`);continue}const o=n[0],a=o.inputs[0].name,s=o.inputs[1].name;yield o.apply(Object.assign(Object.assign({},i),{[a]:u,[s]:c.name}))}catch(e){console.error(e);continue}for(const t of a){const i=t.args;try{const n=yield e.dapi.scripts.find(t.id);if(n){const e=n.inputs[0].name,t=n.inputs[1].name,o=yield n.apply(Object.assign(Object.assign({},i),{[e]:u,[t]:c.name}));if(o&&o.rowCount===u.rowCount&&"python"===n.language)for(const e of o.columns)e.name=u.columns.getUnusedName(e.name),u.columns.add(e)}}catch(e){console.error(e)}}for(const t of s){const i=t.args;try{const n=yield e.dapi.queries.find(t.id);if(n){const e=n.inputs[0].name,t=[l],o=yield n.apply(Object.assign(Object.assign({},i),{[e]:t}));if(!o||0===o.rowCount)continue;yield G(u,m,o)}}catch(e){console.error(e)}}return r.close(),u}))}(n,o.descriptors.args,o.functions,o.scripts,o.queries);for(const e of a.columns.toList())e.name!==m&&(this.dataFrame.columns.contains(e.name)||(this.dataFrame.columns.addNew(e.name,e.type).semType=e.semType),this.dataFrame.col(e.name).set(i,e.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(void 0,!1)}));setTimeout((()=>Pe(this,void 0,void 0,(function*(){var i,n,o,a;d._onAdded(),yield new Promise((e=>setTimeout(e,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 e=t.ViewLayout.fromViewState(s);d.loadLayout(e)}catch(e){console.error(e)}u&&e.functions.call("Chem:editMoleculeCell",{cell:d.grid.cell(this._molColName,0)}),c.push(this.dataFrame.onRowsAdded.pipe((0,Be.filter)((()=>!this.isJoining))).subscribe((()=>{var t,i;try{if(this.processedValues=this.dataFrame.getCol(this.molColName).toList(),(null===(t=this.template.stages)||void 0===t?void 0:t.length)>0)for(let e=0;e<this.dataFrame.rowCount;e++){const t=this.dataFrame.col(h).get(e);t&&""!==t&&!(null===(i=this.dataFrame.col(h))||void 0===i?void 0:i.isNone(e))||this.dataFrame.set(h,e,this.template.stages[0])}let n=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=d.grid.cell(this.molColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(n=t))}n&&e.functions.call("Chem:editMoleculeCell",{cell:n})}catch(e){console.error(e)}}))),this.dataFrame&&c.push(null===(a=this.dataFrame)||void 0===a?void 0:a.onRowsRemoved.subscribe((()=>{try{this.processedValues=this.dataFrame.getCol(this.molColName).toList()}catch(e){console.error(e)}}))),c.push(e.events.onContextMenu.subscribe((i=>{var n,o,a,s,r,l,c,u,h,m,v,f;try{const e=null===(n=null==i?void 0:i.args)||void 0===n?void 0:n.context;if(!e)return;if((null==e?void 0:e.type)!==t.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==d.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||!(null===(l=null===(r=null==i?void 0:i.args)||void 0===r?void 0:r.item)||void 0===l?void 0:l.isTableCell))return;const g=null===(c=null==i?void 0:i.args)||void 0===c?void 0:c.menu;if(!g)return;g.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),g.item("Duplicate molecule",(()=>{var e,t,n,o;try{this.dataFrame.rows.addNew(null,!0);let a=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=d.grid.cell(this.molColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(a=t))}a&&(a.cell.value=null!==(o=null===(n=null===(t=null===(e=null==i?void 0:i.args)||void 0===e?void 0:e.item)||void 0===t?void 0:t.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}}));const y=null===(h=null===(u=null==i?void 0:i.args)||void 0===u?void 0:u.item)||void 0===h?void 0:h.tableRowIndex,w=null===(f=null===(v=null===(m=null==i?void 0:i.args)||void 0===m?void 0:m.item)||void 0===v?void 0:v.cell)||void 0===f?void 0:f.value;y&&w&&y>-1&&g.item("Re-Run Calculations",(()=>Pe(this,void 0,void 0,(function*(){try{yield p(y,w)}catch(e){console.error(e)}}))))}catch(t){e.log.error(t)}}))),c.push(d.grid.onCellValueEdited.subscribe((t=>Pe(this,void 0,void 0,(function*(){var i,n,o,a,s;try{if((null===(i=t.tableColumn)||void 0===i?void 0:i.name)===h)return void(yield this.saveCampaign(void 0,!1));if((null===(n=t.tableColumn)||void 0===n?void 0:n.name)!==this.molColName)return;const r=t.cell.value,l=t.tableRowIndex;let c=null===(o=this.dataFrame.col(v))||void 0===o?void 0:o.get(l),u=!1;if(r)try{const i=t.tableColumn.toList().map((t=>{try{return e.chem.convert(t,e.chem.Notation.Unknown,e.chem.Notation.Smiles)}catch(e){return""}})),n=e.chem.convert(r,e.chem.Notation.Unknown,e.chem.Notation.Smiles);if((null==i?void 0:i.length)===this.dataFrame.rowCount)for(let e=0;e<i.length;e++)if(i[e]===n&&e!==l&&(null===(a=this.dataFrame.col(v))||void 0===a?void 0:a.get(e))){c=null===(s=this.dataFrame.col(v))||void 0===s?void 0:s.get(e),u=!0;break}}catch(e){console.error(e)}this.duplicateVidCache&&!u&&this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[l]]>1&&(c=null),c&&""!==c||(c=Ce(this.dataFrame.col(v))),this.dataFrame.col(v).set(l,c,!1),p(l,r)}catch(e){console.error(e)}}))))),c.push(d.grid.onCellRender.subscribe((e=>{var i;try{const n=e.cell;if(!n||!n.isTableCell||!n.tableColumn||!this.duplicateVidCache||n.tableColumn.name!==v||(null!==(i=n.tableRowIndex)&&void 0!==i?i:-1)<0)return;this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[n.tableRowIndex]]>1&&(e.cell.style.backColor=t.Color.setAlpha(t.Color.getCategoricalColor(this.duplicateVidCache.indexes[n.tableRowIndex]),150))}catch(e){}})));const r=e.events.onViewRemoved.subscribe((e=>{e.id===d.id&&(c.forEach((e=>e.unsubscribe())),r.unsubscribe())}))}))),300);const f=null==d?void 0:d.getRibbonPanels();if(f&&!J(f)){const t=()=>Pe(this,void 0,void 0,(function*(){var e;te(this,(e=>Pe(this,void 0,void 0,(function*(){var t,i,n,a,s,r,l,c,u,p;const h=this.template.compute.descriptors.args,m=this.template.compute.functions,v=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],f=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],w=e.descriptors,b={descriptors:{enabled:!!(null===(n=null==e?void 0:e.descriptors)||void 0===n?void 0:n.length),args:null!==(a=null==e?void 0:e.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(s=null==e?void 0:e.externals)&&void 0!==s?s:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(r=null==e?void 0:e.scripts)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(g)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})),queries:Object.entries(null!==(l=null==e?void 0:e.queries)&&void 0!==l?l:{}).filter((([e,t])=>e.startsWith(y)&&3===e.split(":").length)).map((([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}))};this.template.compute=b,this.campaign.template=this.template;const C=w.filter((e=>!h.includes(e))),A={};Object.entries(null!==(c=null==e?void 0:e.externals)&&void 0!==c?c:{}).filter((([e,t])=>{const i=m.find((t=>`${t.package}:${t.name}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{A[e]=t}));const T={};Object.entries(null!==(u=null==e?void 0:e.scripts)&&void 0!==u?u:{}).filter((([e,t])=>{const i=v.find((t=>`${g}:${t.name}:${t.id}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{T[e]=t}));const x={};Object.entries(null!==(p=null==e?void 0:e.queries)&&void 0!==p?p:{}).filter((([e,t])=>{const i=f.find((t=>`${y}:${t.name}:${t.id}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{x[e]=t})),o.setUpdateIndicator(d.grid.root,!0);try{yield Ae({descriptors:C,externals:A,scripts:T,queries:x},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{o.setUpdateIndicator(d.grid.root,!1),this.saveCampaign(void 0,!1)}}))),(()=>null),null===(e=this.campaign)||void 0===e?void 0:e.template,!0)})),i=o.iconFA("wrench",t,"Calculate additional properties"),n=o.icons.add((()=>{var e;null===(e=this.dataFrame)||void 0===e||e.rows.addNew(null,!0)}),"Add new row"),a=o.bigButton("Progress tracker",(()=>{var t;this.currentTilesViewId&&e.shell.view(this.currentTilesViewId)&&(null===(t=e.shell.view(this.currentTilesViewId))||void 0===t||t.close()),this._tilesView=new Oe(this),this._tilesView.parentCall=this.parentCall,this._tilesViewTab=e.shell.addView(this._tilesView),this.currentTilesViewId=this._tilesViewTab.name,this._tilesView.onActivated(),e.shell.v=e.shell.view(this.currentTilesViewId)})),c=o.bigButton("Submit",(()=>{var e;const t=null===(e=this._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}}));c.classList.add("hit-design-submit-button");const u=[c];null!==(l=null===(r=null===(s=this.template)||void 0===s?void 0:s.stages)||void 0===r?void 0:r.length)&&void 0!==l&&l&&u.unshift(a),this.campaign&&this.template&&!this.campaign.template&&(this.campaign.template=this.template),u.unshift(i),u.unshift(n),f.push(u),d.setRibbonPanels(f)}return d.parentCall=this.parentCall,d}getSummary(){var i,n,a,s;const l=()=>{var e,t;const i=this._filePath.indexOf(null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name);return-1===i?this._filePath:this._filePath.substring(0,i-1)},c=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(c).forEach((([i,n])=>{const o=this.template.campaignFields.find((e=>e.name===i));o&&"Date"===o.type&&n?"Invalid Date"!==new Date(n).toString()?c[i]=new Date(n).toLocaleDateString():n.date?c[i]=new Date(n.date).toLocaleDateString():c[i]=n:o&&o.type===t.SEMTYPE.MOLECULE&&n&&(c[i]=e.chem.drawMolecule(n))})),Object.assign(Object.assign({Template:null!==(s=null===(a=this.template)||void 0===a?void 0:a.name)&&void 0!==s?s:"Molecules","File path":(()=>{const t=o.icons.edit((()=>{const i=l(),s=o.input.string("Path",{value:i}),c=s.root.getElementsByTagName("label").item(0);c&&c.remove(),s.root.style.width="100%";const u=o.button("Save",(()=>Pe(this,void 0,void 0,(function*(){const i=yield function(){return Pe(this,void 0,void 0,(function*(){const t=s.value;return t&&""!==t.trim()?!!(yield e.dapi.files.exists(t))||(e.shell.error("Given folder does not exist"),!1):(e.shell.error("Path can not be empty"),!1)}))}();if(!i)return;const c=s.value;c.endsWith("/")?this._filePath=`${c}${this.campaignId}/${r}`:this._filePath=`${c}/${this.campaignId}/${r}`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(void 0,!0),o.empty(a);const u=l();n=o.link(u,(()=>{var e,t,i;return this.download(this.dataFrame,null!==(i=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==i?i:"Molecules")}),x),a.appendChild(n),a.appendChild(t)})))),d=o.button("Cancel",(()=>{o.empty(a),a.appendChild(n),a.appendChild(t)}));o.empty(a),s.addOptions(d),s.addOptions(u),a.appendChild(s.root)}),"Edit file path");t.style.marginLeft="5px";const i=l();let n=o.link(i,(()=>{var e,t,i;return this.download(this.dataFrame,null!==(i=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==i?i:"Molecules")}),x);const a=o.divH([n,t],{style:{alignItems:"center"}});return a})()},c),{"Number of molecules":(this.dataFrame.rowCount-this._extraStageColsCount).toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((e=>e.name))].filter((e=>e&&""!==e.trim())).join(", ")})}saveCampaign(i){return Pe(this,arguments,void 0,(function*(i,n=!0){var o,a,s,r,c,u,d,p,h,m,f,g,y,w;const b=this.campaignId,C=this.template.name,A=this.dataFrame,T=b,x={};A.columns.toList().forEach((e=>x[e.name]=e.semType));const S={};A.columns.toList().forEach((e=>S[e.name]=e.type));const N=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:T,templateName:C,status:null!==(u=null!=i?i:null===(c=this.campaign)||void 0===c?void 0:c.status)&&void 0!==u?u:"In Progress",createDate:null!==(p=null===(d=this.campaign)||void 0===d?void 0:d.createDate)&&void 0!==p?p:U(new Date),campaignFields:null!==(m=null===(h=this.campaign)||void 0===h?void 0:h.campaignFields)&&void 0!==m?m:this.campaignProps,columnSemTypes:x,rowCount:null!==(g=null===(f=A.col(v))||void 0===f?void 0:f.toList().filter((e=>"StageDefiningRow"!==e)).length)&&void 0!==g?g:0,filteredRowCount:A.filter.trueCount,savePath:this._filePath,columnTypes:S,tilesViewerFormSketch:N,version:this.version+1},E=`Hit Design/campaigns/${b}/${l}`;let _=A;if(yield De.files.exists(E)){const t=JSON.parse(yield De.files.readAsText(E));if((null!==(y=t.version)&&void 0!==y?y:0)>this.version&&(I.version=Math.max(this.version,null!==(w=t.version)&&void 0!==w?w:0)+1,yield e.dapi.files.exists(this._filePath)))try{const t=yield e.dapi.files.readCsv(this._filePath);_=this.unionDataframes(t,A,this.molColName)}catch(e){console.error(e)}}const F=t.DataFrame.fromColumns(_.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield e.dapi.files.writeAsText(this._filePath,F);const V=this._designView.saveLayout();return V?I.layout=V.viewState:e.shell.warning("Layout cound not be saved"),I.template=this.template,yield De.files.writeAsText(E,JSON.stringify(I)),n&&e.shell.info("Campaign saved successfully."),this.campaign=I,I}))}}class Le extends t.GridCellRenderer{get name(){return"customGasteigerPNG"}get cellType(){return"customGasteigerPNG"}get defaultHeight(){return 200}get defaultWidth(){return 200}render(e,t,i,n,o,a,s){if(a.gridRow<0||!a.cell.value)return;const r=a.cell.value,l=new Image(n-2,o-2);l.src="data:image/png;base64,"+r,l.onload=function(){e.drawImage(l,t+2,i+2,n-2,o-2)}}}var je=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};const De=new t.Package;function Re(e,t){return je(this,void 0,void 0,(function*(){yield He(e,t,"Hit Triage")}))}function $e(){return je(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return new xe(t).multiView}))}function Me(e,t){return je(this,void 0,void 0,(function*(){yield He(e,t,"Hit Design")}))}function He(i,n,o){return je(this,void 0,void 0,(function*(){const a=yield z(o,[]);for(const[o,s]of Object.entries(a)){const o="ingest"in s?s.ingest.query:s.savePath;o&&!1!==(yield e.dapi.files.exists(o))&&i.item(s.name).onSelected.subscribe((i=>je(this,void 0,void 0,(function*(){try{const i=yield e.dapi.files.readCsv(o);if(!i)return;const a=s.columnSemTypes;if(a)for(const[e,t]of Object.entries(a)){const n=i.columns.byName(e);n&&(n.semType=t)}const r=t.TableView.create(i,!1);n.preview=r;const l=s.layout;l&&r.loadLayout(t.ViewLayout.fromViewState(l))}catch(e){console.error(e)}}))))}}))}function Ue(){return je(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return new ke(t).multiView}))}function qe(){return je(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(100);return t.name="100 Molecules",t}))}function Ye(){return je(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(5e3);return t.name="5000 Molecules",t}))}function We(t){return je(this,void 0,void 0,(function*(){const i=e.data.demo.molecules(t);return i.name="Variable Molecules number",i}))}function Je(t,i){return je(this,void 0,void 0,(function*(){e.shell.info(t.rowCount),e.shell.info(i)}))}function Ge(){return new Le}})(),hittriage=n})();
1
+ var hittriage;(()=>{var t={233:t=>{!function(){"use strict";var e=document,i=window,n=e.documentElement,o=e.createElement.bind(e),s=o("div"),a=o("table"),r=o("tbody"),l=o("tr"),c=Array.isArray,u=Array.prototype,d=u.concat,p=u.filter,h=u.indexOf,m=u.map,v=u.push,f=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(E(t))return t;var o=t;if(V(t)){var s=n||e;if(!(o=w.test(t)&&_(s)?s.getElementById(t.slice(1).replace(/\\/g,"")):C.test(t)?Z(t):E(s)?s.find(t):V(s)?S(s).find(t):T(t,s)))return}else if(P(t))return this.ready(t);(o.nodeType||o===i)&&(o=[o]),this.length=o.length;for(var a=0,r=this.length;a<r;a++)this[a]=o[a]}}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 P(t){return"function"==typeof t}function V(t){return"string"==typeof t}function B(t){return void 0===t}function O(t){return null===t}function k(t){return!isNaN(parseFloat(t))&&isFinite(t)}function L(t){if("object"!=typeof t||null===t)return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function j(t,e,i){if(i){for(var n=t.length;n--;)if(!1===e.call(t[n],n,t[n]))return t}else if(L(t))for(var o=Object.keys(t),s=(n=0,o.length);n<s;n++){var a=o[n];if(!1===e.call(t[a],a,t[a]))return t}else for(n=0,s=t.length;n<s;n++)if(!1===e.call(t[n],n,t[n]))return t;return t}function D(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i="boolean"==typeof t[0]&&t.shift(),n=t.shift(),o=t.length;if(!n)return{};if(!o)return D(i,S,n);for(var s=0;s<o;s++){var a=t[s];for(var r in a)i&&(c(a[r])||L(a[r]))?(n[r]&&n[r].constructor===a[r].constructor||(n[r]=new a[r].constructor),D(i,n[r],a[r])):n[r]=a[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=P,S.isArray=c,S.isNumeric=k,S.isPlainObject=L,S.each=j,I.each=function(t){return j(this,t)},I.empty=function(){return this.each((function(t,e){for(;e.firstChild;)e.removeChild(e.firstChild)}))},S.extend=D,I.extend=function(t){return D(I,t)};var U=/\S+/g;function R(t){return V(t)&&t.match(U)||[]}function $(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 M(t,e){return parseInt($(t,e),10)||0}function H(t,e){return M(t,"border".concat(e?"Left":"Top","Width"))+M(t,"padding".concat(e?"Left":"Top"))+M(t,"padding".concat(e?"Right":"Bottom"))+M(t,"border".concat(e?"Right":"Bottom","Width"))}I.toggleClass=function(t,e){var i=R(t),n=!B(e);return this.each((function(t,o){F(o)&&j(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)&&j(e,(function(t,e){i.removeAttribute(e)}))}))},I.attr=function(t,e){if(t){if(V(t)){if(arguments.length<2){if(!this[0]||!F(this[0]))return;var i=this[0].getAttribute(t);return O(i)?void 0:i}return B(e)?this:O(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 B(t)?f.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 B(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 q={};function Y(t){return"none"===$(t,"display")}function W(t,e){var i=t&&(t.matches||t.webkitMatchesSelector||t.msMatchesSelector);return!!i&&!!e&&i.call(t,e)}function G(t){return V(t)?function(e,i){return W(i,t)}:P(t)?t:E(t)?function(e,i){return t.is(i)}:t?function(e,i){return i===t}:function(){return!1}}function J(t,e){return e?t.filter(e):t}I.filter=function(t){var e=G(t);return S(p.call(this,(function(t,i){return e.call(t,i,t)})))},I.detach=function(t){return J(this,t).each((function(t,e){e.parentNode&&e.parentNode.removeChild(e)})),this};var z=/^\s*<(\w+)[^>]*>/,K=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,Q={"*":s,tr:r,td:l,th:l,thead:a,tbody:a,tfoot:a};function Z(t){if(!V(t))return[];if(K.test(t))return[o(RegExp.$1)];var e=z.test(t)&&RegExp.$1,i=Q[e]||Q["*"];return i.innerHTML=t,S(i.childNodes).detach().get()}function X(t,e,i,n){for(var o=[],s=P(e),a=n&&G(n),r=0,l=t.length;r<l;r++)if(s){var c=e(t[r]);c.length&&v.apply(o,c)}else for(var u=t[r][e];!(null==u||n&&a(-1,u));)o.push(u),u=i?u[e]:null;return o}function tt(t){return t.multiple&&t.options?X(p.call(t.options,(function(t){return t.selected&&!t.disabled&&!t.parentNode.disabled})),"value"):t.value||""}function et(t){return t.length>1?p.call(t,(function(t,e,i){return h.call(i,t)===e})):t}S.parseHTML=Z,I.has=function(t){var e=V(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=G(t);return this.filter((function(i,n){return(!V(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||Vt.test(i.type)){var o=c(t)?m.call(t,String):O(t)?[]:[String(t)];n?j(i.options,(function(t,e){e.selected=o.indexOf(e.value)>=0}),!0):i.checked=o.indexOf(i.value)>=0}else i.value=B(t)||O(t)?"":t})):this[0]&&tt(this[0])},I.is=function(t){var e=G(t);return g.call(this,(function(t,i){return e.call(t,i,t)}))},S.guid=1,S.unique=et,I.add=function(t,e){return S(et(this.get().concat(S(t,e).get())))},I.children=function(t){return J(S(et(X(this,(function(t){return t.children})))),t)},I.parent=function(t){return J(S(et(X(this,"parentNode"))),t)},I.index=function(t){var e=t?S(t)[0]:this[0],i=t?this:S(e).parent().children();return h.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 J(S(et(X(this,(function(t){return S(t).parent().children().not(t)})))),t)},I.find=function(t){return S(et(X(this,(function(e){return T(t,e)}))))};var it=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,nt=/^$|^module$|\/(java|ecma)script/i,ot=["type","src","nonce","noModule"];function st(t,e,i,s,a,r,l,c){return j(t,(function(t,r){j(S(r),(function(t,r){j(S(e),(function(e,l){var c=i?l:r,u=i?t:e;!function(t,e,i,s,a){s?t.insertBefore(e,i?t.firstChild:null):"HTML"===t.nodeName?t.parentNode.replaceChild(e,t):t.parentNode.insertBefore(e,i?t:t.nextSibling),a&&function(t,e){var i=S(t);i.filter("script").add(i.find("script")).each((function(t,i){if(nt.test(i.type)&&n.contains(i)){var s=o("script");s.text=i.textContent.replace(it,""),j(ot,(function(t,e){i[e]&&(s[e]=i[e])})),e.head.insertBefore(s,null),e.head.removeChild(s)}}))}(e,t.ownerDocument)}(i?r:l,u?c.cloneNode(!0):c,s,a,!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(B(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(et(X(this,(function(t){return"IFRAME"===t.tagName?[t.contentDocument]:"TEMPLATE"===t.tagName?t.content.childNodes:t.childNodes}))))},I.next=function(t,e,i){return J(S(et(X(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 J(S(et(X(this,"parentElement",!0,e))),t)},I.parentsUntil=function(t,e){return this.parents(e,t)},I.prev=function(t,e,i){return J(S(et(X(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([],m.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"===$(i,"position");)i=i.offsetParent;return i||n}))},I.slice=function(t,e){return S(f.call(this,t,e))};var at=/-([a-z])/g;function rt(t){return t.replace(at,(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"===$(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"===$(o,"position");)o=o.parentNode;if(o!==t&&F(o)){var s=S(o).offset();i.top-=s.top+M(o,"borderTopWidth"),i.left-=s.left+M(o,"borderLeftWidth")}}return{top:i.top-M(t,"marginTop"),left:i.left-M(t,"marginLeft")}}};var lt={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(V(t))return t=lt[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[lt[t]||t]}))};var ct=/^--/;function ut(t){return ct.test(t)}var dt={},pt=s.style,ht=["webkit","moz","ms"],mt={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 vt(t,e,i){return void 0===i&&(i=ut(t)),i||mt[t]||!k(e)?e:"".concat(e,"px")}function ft(t,e){try{return t(e)}catch(t){return e}}I.css=function(t,e){if(V(t)){var i=ut(t);return t=function(t,e){if(void 0===e&&(e=ut(t)),e)return t;if(!dt[t]){var i=rt(t),n="".concat(i[0].toUpperCase()).concat(i.slice(1));j("".concat(i," ").concat(ht.join("".concat(n," "))).concat(n).split(" "),(function(e,i){if(i in pt)return dt[t]=i,!1}))}return dt[t]}(t,i),arguments.length<2?this[0]&&$(this[0],t,i):t?(e=vt(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 gt=/^\s+|\s+$/;function yt(t,e){var i=t.dataset[e]||t.dataset[rt(e)];return gt.test(i)?i:ft(JSON.parse,i)}function wt(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]=yt(this[0],n);return i}if(V(t))return arguments.length<2?this[0]&&yt(this[0],t):B(e)?this:this.each((function(i,n){!function(t,e,i){i=ft(JSON.stringify,i),t.dataset[rt(e)]=i}(n,t,e)}));for(var n in t)this.data(n,t[n]);return this},j([!0,!1],(function(t,e){j(["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])?wt(this[0],i):this[0]["".concat(e?"offset":"client").concat(i)]+(n&&e?M(this[0],"margin".concat(t?"Top":"Left"))+M(this[0],"margin".concat(t?"Bottom":"Right")):0)}}))})),j(["Width","Height"],(function(t,e){var i=e.toLowerCase();I[i]=function(n){if(!this[0])return B(n)?void 0:this;if(!arguments.length)return N(this[0])?this[0].document.documentElement["client".concat(e)]:_(this[0])?wt(this[0],e):this[0].getBoundingClientRect()[i]-H(this[0],!t);var o=parseInt(n,10);return this.each((function(e,n){if(F(n)){var s=$(n,"boxSizing");n.style[i]=vt(i,o+("border-box"===s?H(n,!t):0))}}))}}));var bt="___cd";I.toggle=function(t){return this.each((function(i,n){if(F(n)){var s=Y(n);(B(t)?s:t)?(n.style.display=n[bt]||"",Y(n)&&(n.style.display=function(t){if(q[t])return q[t];var i=o(t);e.body.insertBefore(i,null);var n=$(i,"display");return e.body.removeChild(i),q[t]="none"!==n?n:"block"}(n.tagName))):s||(n[bt]=$(n,"display"),n.style.display="none")}}))},I.hide=function(){return this.toggle(!1)},I.show=function(){return this.toggle(!0)};var Ct="___ce",At={focus:"focusin",blur:"focusout"},Tt={mouseenter:"mouseover",mouseleave:"mouseout"},xt=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function It(t){return Tt[t]||At[t]||t}function St(t){var e=t.split(".");return[e[0],e.slice(1).sort()]}function Et(t){return t[Ct]=t[Ct]||{}}function Nt(t,e){return!e||!g.call(e,(function(e){return t.indexOf(e)<0}))}function _t(t,e,i,n,o){var s=Et(t);if(e)s[e]&&(s[e]=s[e].filter((function(s){var a=s[0],r=s[1],l=s[2];if(o&&l.guid!==o.guid||!Nt(a,i)||n&&n!==r)return!0;t.removeEventListener(e,l)})));else for(e in s)_t(t,e,i,n,o)}I.trigger=function(t,i){if(V(t)){var n=St(t),o=n[0],s=n[1],a=It(o);if(!a)return this;var r=xt.test(a)?"MouseEvents":"HTMLEvents";(t=e.createEvent(r)).initEvent(a,!0,!0),t.namespace=s.join("."),t.___ot=o}t.___td=i;var l=t.___ot in At;return this.each((function(e,i){l&&P(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(B(t))this.each((function(t,e){(F(e)||_(e)||N(e))&&_t(e)}));else if(V(t))P(e)&&(i=e,e=""),j(R(t),(function(t,o){var s=St(o),a=s[0],r=s[1],l=It(a);n.each((function(t,n){(F(n)||_(n)||N(n))&&_t(n,l,r,e,i)}))}));else for(var o in t)this.off(o,t[o]);return this},I.remove=function(t){return J(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 s=this;if(!V(t)){for(var a in t)this.on(a,e,i,t[a],o);return this}return V(e)||(B(e)||O(e)?e="":B(i)?(i=e,e=""):(n=i,i=e,e="")),P(n)||(n=i,i=void 0),n?(j(R(t),(function(t,a){var r=St(a),l=r[0],c=r[1],u=It(l),d=l in Tt,p=l in At;u&&s.each((function(t,s){if(F(s)||_(s)||N(s)){var a=function(t){if(t.target["___i".concat(t.type)])return t.stopImmediatePropagation();if((!t.namespace||Nt(c,t.namespace.split(".")))&&(e||!(p&&(t.target!==s||t.___ot===u)||d&&t.relatedTarget&&s.contains(t.relatedTarget)))){var r=s;if(e){for(var l=t.target;!W(l,e);){if(l===s)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 s}}),Object.defineProperty(t,"data",{configurable:!0,get:function(){return i}});var h=n.call(r,t,t.___td);o&&_t(s,u,c,e,a),!1===h&&(t.preventDefault(),t.stopPropagation())}};a.guid=n.guid=n.guid||S.guid++,function(t,e,i,n,o){var s=Et(t);s[e]=s[e]||[],s[e].push([i,n,o]),t.addEventListener(e,o)}(s,u,c,e,a)}}))})),this):this},I.one=function(t,e,i,n){return this.on(t,e,i,n,!0)};var Ft=/\r?\n/g,Pt=/file|reset|submit|button|image/i,Vt=/radio|checkbox/i;I.serialize=function(){var t="";return this.each((function(e,i){j(i.elements||[i],(function(e,i){if(!(i.disabled||!i.name||"FIELDSET"===i.tagName||Pt.test(i.type)||Vt.test(i.type)&&!i.checked)){var n=tt(i);B(n)||j(c(n)?n:[n],(function(e,n){t+=function(t,e){return"&".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(e.replace(Ft,"\r\n")))}(i.name,n)}))}}))})),t.slice(1)},t.exports=S}()},558:(t,e,i)=>{"use strict";i.d(e,{A:()=>r});var n=i(354),o=i.n(n),s=i(314),a=i.n(s)()(o());a.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=a},677:(t,e,i)=>{"use strict";i.d(e,{A:()=>r});var n=i(354),o=i.n(n),s=i(314),a=i.n(s)()(o());a.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=a},542:(t,e,i)=>{"use strict";i.d(e,{A:()=>r});var n=i(354),o=i.n(n),s=i(314),a=i.n(s)()(o());a.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=a},314: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,s){"string"==typeof t&&(t=[[null,t,void 0]]);var a={};if(n)for(var r=0;r<this.length;r++){var l=this[r][0];null!=l&&(a[l]=!0)}for(var c=0;c<t.length;c++){var u=[].concat(t[c]);n&&a[u[0]]||(void 0!==s&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=s),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}},354: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),s="/*# ".concat(o," */");return[e].concat([s]).join("\n")}return[e].join("\n")}},72: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 s={},a=[],r=0;r<t.length;r++){var l=t[r],c=n.base?l[0]+n.base:l[0],u=s[c]||0,d="".concat(c," ").concat(u);s[c]=u+1;var p=i(d),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)e[p].references++,e[p].updater(h);else{var m=o(h,n);n.byIndex=r,e.splice(r,0,{identifier:d,updater:m,references:1})}a.push(d)}return a}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 s=n(t=t||[],o=o||{});return function(t){t=t||[];for(var a=0;a<s.length;a++){var r=i(s[a]);e[r].references--}for(var l=n(t,o),c=0;c<s.length;c++){var u=i(s[c]);0===e[u].references&&(e[u].updater(),e.splice(u,1))}s=l}}},659: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)}},540:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},56:(t,e,i)=>{"use strict";t.exports=function(t){var e=i.nc;e&&t.setAttribute("nonce",e)}},825: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 s=i.sourceMap;s&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),e.styleTagTransform(n,t,e.options)}(e,t,i)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},113: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 s=e[n]={id:n,exports:{}};return t[n](s,s.exports,i),s.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:()=>qt,demoFileIngest:()=>Kt,demoFileIngest1:()=>Qt,demoFileIngest2:()=>Zt,demoFileSubmit:()=>Xt,gasteigerCellRenderer:()=>te,hitDesignApp:()=>zt,hitDesignAppTreeBrowser:()=>Gt,hitTriageApp:()=>Wt,hitTriageAppTreeBrowser:()=>Yt});const t=grok,e=DG,o=ui,s="campaignId",a="campaignId",r="enriched_table.csv",l="campaign.json",c="HitTriageDataSource",u="HitTriageSubmitFunction",d="Selected hits",p="Stage",h="Molecule",m="V-iD",v="V######",f="HTScript",g="HTQuery",y="molecules",w="Source",b="New template",C="Start",A="Create",T="Download",x="Cancel",I="Continue a campaign",S="New campaign",E={script:"script",function:"function-package",query:"data-query"};var N=i(72),_=i.n(N),F=i(825),P=i.n(F),V=i(659),B=i.n(V),O=i(56),k=i.n(O),L=i(540),j=i.n(L),D=i(113),U=i.n(D),R=i(558),$={};$.styleTagTransform=U(),$.setAttributes=k(),$.insert=B().bind(null,"head"),$.domAPI=P(),$.insertStyleElement=j(),_()(R.A,$),R.A&&R.A.locals&&R.A.locals;var M=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))};const H=t=>`${t.getFullYear()}/${t.getMonth()+1}/${t.getDate()}`;function q(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 Y(e,i,n,s){var a;const r=o.breadcrumbs([i,n]),l=r.onPathClick.subscribe((t=>{1===t.length&&(l.unsubscribe(),W(e),s())})),c=null===(a=t.shell.v.ribbonMenu.root.parentElement)||void 0===a?void 0:a.getElementsByClassName("d4-ribbon-name")[0];return c&&(c.textContent="",c.appendChild(r.root)),{breadcrumbs:r,sub:l}}function W(t){const e=t.getRibbonPanels();(null==e?void 0:e.length)&&(e.pop(),t.setRibbonPanels(e))}function G(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 J(t,i,n){return M(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(y);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 s=n.columns.names().filter((t=>t!==y));t.join(n,[i],[o.name],void 0,s,void 0,!0)}))}function z(t,e){return M(this,void 0,void 0,(function*(){const i=(yield qt.files.list(`${t}/campaigns`)).filter((t=>-1===e.indexOf(t.name))),n={};for(const e of i)try{const i=JSON.parse(yield qt.files.readAsText(`${t}/campaigns/${e.name}/${l}`));if(i.authorUserId&&i.permissions&&!(yield Z(i.authorUserId,i.permissions)))continue;n[i.name]=i}catch(t){continue}return n}))}function K(i,n){return M(this,void 0,void 0,(function*(){var o;const s=e.User.current().id,a=null===(o=e.User.current().group)||void 0===o?void 0:o.id;if(i===s)return!0;const r=t.dapi.groups;for(const t of n){const e=yield r.find(t);if(e)if(e.personal){const t=yield r.getUser(e);if((null==t?void 0:t.id)===s)return!0}else if(a&&e.members.length>0&&e.members.some((t=>t.id===a)))return!0}return!1}))}function Q(t,e){return M(this,void 0,void 0,(function*(){return K(t,e.edit)}))}function Z(t,e){return M(this,void 0,void 0,(function*(){return K(t,Array.from(new Set([...e.view,...e.edit])))}))}const X={String:e.TYPE.STRING,Number:e.TYPE.FLOAT,Boolean:e.TYPE.BOOL,Date:e.TYPE.DATE_TIME,Molecule:e.SEMTYPE.MOLECULE};var tt=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))},et=i(233),it=i.n(et),nt=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))};function ot(e,i,n,s,a){return nt(this,void 0,void 0,(function*(){var r,l,c,u,d,p,h,m,v,y,w,b,C,A,T,x,I,S,N,_,F;const P=yield e.computeFunctions,V=[];P.functions.filter((({inputs:t})=>t.length>=2&&"dataframe"===t[0].propertyType&&"column"===t[1].propertyType)).forEach((t=>{var e,i,n,o;V.push({func:t,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:{}})})),P.scripts.filter((({inputs:t})=>t.length>=2&&"dataframe"===t[0].propertyType&&"column"===t[1].propertyType)).forEach((t=>{var e,i,n,o;V.push({func:t,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:{}})})),P.queries.filter((t=>t.inputs.length>0&&"list"===t.inputs[0].propertyType)).forEach((t=>{var e,i,n,o;V.push({func:t,args:null!==(o=null===(n=null===(i=null===(e=null==s?void 0:s.compute)||void 0===e?void 0:e.queries)||void 0===i?void 0:i.find((e=>e.id===t.id)))||void 0===n?void 0:n.args)&&void 0!==o?o:{}})}));let B=!!(null===(l=null===(r=null==s?void 0:s.compute)||void 0===r?void 0:r.descriptors)||void 0===l?void 0:l.enabled)||a;const O=o.div([],{classes:"hit-triage-compute-dialog-host"}),k=[],L=o.tree();try{const q=yield t.chem.descriptorsTree();function Y(t,e){const i=e.group(t,null,!1);return i.enableCheckBox(!1),i}L.root.classList.add("hit-triage-compute-dialog-descriptors-group");const W=Object.keys(q),G=null!==(d=null===(u=null===(c=null==s?void 0:s.compute)||void 0===c?void 0:c.descriptors)||void 0===u?void 0:u.args)&&void 0!==d?d:[];for(const J of W){const z=Y(J,L);for(const K of q[J].descriptors){const Q=z.item(K.name,K);k.push(Q),Q.enableCheckBox(G.includes(K.name))}}}catch(Z){console.error(Z),B=!1}const j="Descriptors",D={[j]:j},U=B?{[j]:L.root}:{},R={},$={[j]:!1};$[j]=!!(null===(h=null===(p=null==s?void 0:s.compute)||void 0===p?void 0:p.descriptors)||void 0===h?void 0:h.enabled)&&(null===(y=null===(v=null===(m=null==s?void 0:s.compute)||void 0===m?void 0:m.descriptors)||void 0===v?void 0:v.args)||void 0===y?void 0:y.length)>0;for(const X of V)try{const tt=X.func,et=tt.prepare(X.args),nt=tt.type===E.function?`${tt.package.name}:${tt.name}`:tt.type===E.script?`${f}:${null!==(w=tt.name)&&void 0!==w?w:""}:${tt.id}`:`${g}:${null!==(b=tt.name)&&void 0!==b?b:""}:${tt.id}`;R[nt]=et;const ot=o.div(),st=yield et.buildEditor(ot,{condensed:!1});ot.classList.add("oy-scroll"),ot.style.marginLeft="15px",ot.style.removeProperty("max-width"),U[null!==(C=tt.friendlyName)&&void 0!==C?C:tt.name]=ot,D[null!==(A=tt.friendlyName)&&void 0!==A?A:tt.name]=nt,$[nt]=null!==(F=(null===(x=null===(T=null==s?void 0:s.compute)||void 0===T?void 0:T.functions)||void 0===x?void 0:x.some((t=>{var e;return X.func.type===E.function&&t.name===X.func.name&&t.package===(null===(e=X.func.package)||void 0===e?void 0:e.name)})))||(null===(S=null===(I=null==s?void 0:s.compute)||void 0===I?void 0:I.scripts)||void 0===S?void 0:S.some((t=>t.id===tt.id)))||(null===(_=null===(N=null==s?void 0:s.compute)||void 0===N?void 0:N.queries)||void 0===_?void 0:_.some((t=>t.id===tt.id))))&&void 0!==F&&F,ot.children[0].style.display="none",tt.type!==E.query&&(ot.children[1].style.display="none"),st.forEach((t=>{var e,i;(null===(e=t.property)||void 0===e?void 0:e.name)&&Object.keys(X.args).includes(null===(i=t.property)||void 0===i?void 0:i.name)&&(t.value=X.args[t.property.name]),t.fireChanged()}))}catch(at){console.error(at);continue}const M=o.tabControl(U,!0);function H(){const t={descriptors:[],externals:{},scripts:{},queries:{}};t.descriptors=$[j]?k.filter((t=>t.checked)).map((t=>t.value.name)):[];const e=Object.entries(R).filter((([t,e])=>$[t]));e.filter((([t,e])=>!t.startsWith(f)&&!t.startsWith(g))).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(f))).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(g))).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),i(t)}return M.onTabChanged.subscribe((()=>{try{M.currentPane.content.style.removeProperty("max-width")}catch(t){}})),M.header.style.overflow="scroll",M.root.style.width="100%",M.root.style.minWidth="350px",O.appendChild(M.root),M.panes.forEach((t=>{const e=o.input.bool("",{value:$[D[t.name]],onValueChanged:i=>{$[D[t.name]]=!!e.value,i.value?it()(t.content).find("input").removeAttr("disabled"):it()(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")})),a&&o.dialog("Compute").add(O).onOK((()=>H())).onCancel(n).show(),{root:O,okProxy:H}}))}const st=rxjs;class at{constructor(t,e=[],i={}){this.onItemChanged=new st.Subject,this.onAddingItemChanged=new st.Subject,this.onItemAdded=new st.Subject,this.onItemRemoved=new st.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}set items(t){this._items=t,this.render()}addItem(t,e=!0){this._items.push(t),this.render(),e&&this.onItemAdded.next(t)}removeItem(t,e=!0){-1!==this._items.indexOf(t)&&(this._items.splice(this._items.indexOf(t),1),this.render(),e&&this.onItemRemoved.next(t))}removeAtIndex(t,e=!0){if(t<0||t>=this._items.length)return;const i=this._items.splice(t,1);this.render(),e&&this.onItemRemoved.next(i[0])}removeAllItems(){this._items=[],this.render()}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 s=[],a={};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);s.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%"),a[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(a).forEach((e=>{t[e]=a[e].value})),this._items.push(t),this.onItemAdded.next(t),this.render()}),this.options.addButtonTooltip);else{if(!this.options.allowRemove)return s;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",s}hideLabel(t){return t.getElementsByTagName("label")[0]&&t.removeChild(t.getElementsByTagName("label")[0]),t}}var rt=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))};function lt(){const t=e.Property.fromOptions({name:"layout",caption:"Layout",type:"file"}),i=e.InputBase.forProperty(t);let n=null,o=null,s=null;return i.addValidator((t=>s)),i.onChanged((()=>rt(this,void 0,void 0,(function*(){const t=i.value;if(t)try{const i=yield t.readAsString(),a=e.ViewLayout.fromJson(i);a?(n=a,o=a.viewState,s=null):(n=null,o=null,s="Invalid layout file")}catch(t){n=null,o=null,s="Invalid layout file"}i.setTooltip("Select a layout file")})))),{dataFileInput:i,getLayout:()=>n,getLayoutViewState:()=>o}}var ct=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))};function ut(i,n){return ct(this,void 0,void 0,(function*(){var s,a;const r=(yield qt.files.list("Hit Triage/templates")).map((t=>t.name.slice(0,-5))),l=[];for(const t of r){const e=JSON.parse(yield qt.files.readAsText(`Hit Triage/templates/${t}.json`));l.push(e.key)}const d=e.Func.find({tags:[u]}),p={};d.forEach((t=>{var e;p[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t}));const h=o.input.choice("Submit function",{value:null,items:[null,...Object.keys(p)]});h.value=null,h.nullable=!0,h.fireChanged(),h.setTooltip("Select function to be called upon submitting");const m=lt(),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.input.string("Name",{value:"",onValueChanged:()=>{""===b.value||r.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.input.string("Key",{value:"",onValueChanged:()=>{""===C.value||l.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 I=yield ot(i,(t=>{T=t}),(()=>null),{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},!1);I.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(n).length&&e.Func.find({tags:[c]}).forEach((t=>{var e;n[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t}));const S=Object.keys(n),E=o.input.choice(w,{value:S[0],items:S}),N=o.input.choice("Ingest using",{value:"Query",items:["Query","File"],onValueChanged:()=>{"Query"!==N.value?E.root.style.display="none":E.root.style.display="block"}}),_=dt(),F=o.div([o.h2("Details"),o.div([b,v]),o.div([C,y]),N.root,E.root,m.dataFileInput,_.fieldsDiv,o.h2("Compute"),I.root,o.h2("Submit"),h.root],"ui-form"),P=o.buttonsInput([]),V=null!==(a=null===(s=P.getElementsByClassName("ui-input-editor"))||void 0===s?void 0:s[0])&&void 0!==a?a:P;F.appendChild(P);const B=new Promise((t=>{const e=o.button(x,(()=>t()));V.appendChild(e)})),O=new Promise((e=>{const i=o.bigButton(A,(()=>function(){return ct(this,void 0,void 0,(function*(){var i,n,o,s,a,r,l,c;if(I.okProxy(),"100%"===v.style.opacity)return void t.shell.error("Template name is empty or already exists");const u=h.value?p[h.value]:void 0,d=Object.assign(Object.assign({name:b.value,key:C.value,campaignFields:_.getFields(),dataSourceType:null!==(i=N.value)&&void 0!==i?i:"Query",layoutViewState:null!==(n=m.getLayoutViewState())&&void 0!==n?n:void 0,compute:{descriptors:{enabled:!!(null===(o=null==T?void 0:T.descriptors)||void 0===o?void 0:o.length),args:null!==(s=null==T?void 0:T.descriptors)&&void 0!==s?s:[]},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!==(r=null==T?void 0:T.scripts)&&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}})),queries:Object.entries(null!==(l=null==T?void 0:T.queries)&&void 0!==l?l:{}).filter((([t,e])=>t.startsWith(g)&&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"===N.value&&null!==(c=E.value)&&void 0!==c?c:void 0});var y;y=d,qt.files.writeAsText(`Hit Triage/templates/${y.name}.json`,JSON.stringify(y)),t.shell.info("Template created successfully"),e(d)}))}()));V.appendChild(i)}));return{root:F,template:O,cancelPromise:B}}))}function dt(t){const i=[e.Property.fromOptions({name:"Name",type:e.TYPE.STRING}),e.Property.fromOptions({name:"Type",type:e.TYPE.STRING,choices:Object.keys(X)}),e.Property.fromOptions({name:"Required",type:e.TYPE.BOOL})],n=new at(i,t?t.map((t=>({Name:t.name,Type:t.type,Required:t.required}))):void 0,{horizontalInputNames:!1});n.root.style.maxWidth="750px";let s={};n.onItemAdded.subscribe((t=>{s={}})),n.onAddingItemChanged.subscribe((t=>{t&&(s=t.item)}));const a=o.h2("Additional fields");o.tooltip.bind(a,"Additional fields to be filled by user for each campaign");const r=o.div([a,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 s.Name&&""!==s.Name&&s.Type&&(null!==(t=s.Required)&&void 0!==t||(s.Required=!1),e.push({name:s.Name,type:s.Type,required:s.Required})),e},fieldsDiv:o.div([r])}}var pt=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))};class ht extends e.ViewBase{constructor(t){super(),this.deletedCampaigns=[],this.app=t}get template(){return this.app.template}onActivated(){}onReset(){}process(){return pt(this,void 0,void 0,(function*(){}))}deleteCampaign(t,e){return pt(this,void 0,void 0,(function*(){yield qt.files.delete(`${t}/campaigns/${e}`)}))}}var mt=i(677),vt={};vt.styleTagTransform=U(),vt.setAttributes=k(),vt.insert=B().bind(null,"head"),vt.domAPI=P(),vt.insertStyleElement=j(),_()(mt.A,vt),mt.A&&mt.A.locals&&mt.A.locals;var ft;!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 it()(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,s=void 0,r=function*(){o.setUpdateIndicator(e,!0);try{return yield i()}catch(e){t.log.error(e)}finally{o.setUpdateIndicator(e,!1)}},new((a=void 0)||(a=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 a?n:new a((function(t){t(n)}))).then(i,o)}l((r=r.apply(n,s||[])).next())}));var n,s,a,r}}(n=e.tools||(e.tools={}))}(ft||(ft={}));var gt=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))};const yt={view:[e.Group.defaultGroupsIds["All users"]],edit:[e.Group.defaultGroupsIds["All users"]]};class wt{constructor(t){this.permissions=null!=t?t:yt,this.editGroupsInput=o.input.userGroups("Can Edit"),this.editGroupsInput.root.style.marginBottom="16px",this.viewGroupsInput=o.input.userGroups("Can View")}getDialogContent(){return gt(this,void 0,void 0,(function*(){const e=[],i=[];for(const i of this.permissions.view){const n=yield t.dapi.groups.find(i);n&&e.push(n)}for(const e of this.permissions.edit){const n=yield t.dapi.groups.find(e);n&&i.push(n)}return this.editGroupsInput.value=i,this.viewGroupsInput.value=e,o.divV([this.editGroupsInput.root,this.viewGroupsInput.root])}))}show(t){return gt(this,void 0,void 0,(function*(){var e;const i=yield this.getDialogContent(),n=o.dialog("Edit Permissions").add(i).onOK((()=>{const e=new Set(this.editGroupsInput.value.map((t=>t.id))),i=new Set(this.viewGroupsInput.value.map((t=>t.id)));this.permissions.edit=Array.from(e),e.forEach((t=>i.add(t))),this.permissions.view=Array.from(i),0===this.permissions.view.length&&(this.permissions.view=yt.view),t(this.permissions)}));(null===(e=i.parentElement)||void 0===e?void 0:e.style)&&(i.parentElement.style.overflow="visible"),n.show()}))}}var bt=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))};class Ct extends ht{constructor(e){super(e),this.readmePath=qt.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 bt(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const e=o.h1(I),i=o.h1(S,{style:{marginLeft:"10px"}}),n=ft.appHeader({iconPath:qt.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 "}),s=o.div(),a=o.div([],{classes:"ui-form"}),r=yield this.getCampaignsTable();yield this.startNewCampaign(s,a,t),it()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,e],{style:{marginLeft:"10px"}}),r,i,a,s])),this.app.resetBaseUrl()}catch(t){throw o.setUpdateIndicator(this.root,!1),t}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(t,e,i){return bt(this,void 0,void 0,(function*(){var n;const s=(yield qt.files.list("Hit Triage/templates")).map((t=>t.name.slice(0,-5)));i&&!s.includes(i.name)&&s.push(i.name);const a=()=>bt(this,void 0,void 0,(function*(){const e=r.value,n=i&&i.name===e?i:JSON.parse(yield qt.files.readAsText("Hit Triage/templates/"+e+".json")),o=yield this.getNewCampaignAccordeon(n,t);it()(t).empty(),t.className="ui-form",t.appendChild(o)})),r=o.input.choice("Template",{value:null!==(n=null==i?void 0:i.name)&&void 0!==n?n:s[0],items:s,onValueChanged:()=>bt(this,void 0,void 0,(function*(){yield a()}))}),l=o.icons.add((()=>bt(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),o.setUpdateIndicator(this.root,!1)}))),b);r.addOptions(l),yield a(),it()(e).empty(),e.appendChild(r.root)}))}checkCampaign(t){return bt(this,void 0,void 0,(function*(){const e=location.search,i=new URLSearchParams(e);if(!i.has(s)&&!t)return;const n=null!=t?t:i.get(s);if(!(yield qt.files.exists(`Hit Triage/campaigns/${n}/${l}`)))return;const o=JSON.parse(yield qt.files.readAsText(`Hit Triage/campaigns/${n}/${l}`));if(o){if(o.authorUserId&&o.permissions&&!(yield Z(o.authorUserId,o.permissions)))return void this.app.setBaseUrl();this.app.campaign=o}const a=JSON.parse(yield qt.files.readAsText(`Hit Triage/templates/${o.templateName}.json`));return this.app.setTemplate(a,o.filters,n,o.ingest),t&&q(s,t),o}))}getCampaignsTable(){return bt(this,void 0,void 0,(function*(){const t=yield z("Hit Triage",this.deletedCampaigns),i=t=>{var i,n;const s=o.icons.delete((()=>bt(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${t.name}?`)).onOK((()=>bt(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Triage",t.name),this.deletedCampaigns.push(t.name),yield this.init()})))).show()}))),"Delete campaign");return s.style.display="none",Q(null!==(i=t.authorUserId)&&void 0!==i?i:e.User.current().id,null!==(n=t.permissions)&&void 0!==n?n:yt).then((t=>{t&&(s.style.display="inline-block")})),s},n=Object.values(t),s=o.table(n,(t=>[o.link(t.name,(()=>this.setCampaign(t.name)),"",""),t.createDate,t.rowCount,t.filteredRowCount,t.status,i(t)]),["Name","Created","Total","Selected","Status",""]);return s.style.color="var(--grey-5)",s}))}setCampaign(t){return bt(this,void 0,void 0,(function*(){const e=yield this.checkCampaign(t);this.app.campaign=e}))}getNewCampaignAccordeon(i,n){return bt(this,void 0,void 0,(function*(){o.setUpdateIndicator(n,!0);const{root:s,promise:a,cancelPromise:r}=yield function(i,n){return tt(this,void 0,void 0,(function*(){var s,a;const r=o.divText("",{style:{color:"red"}});let l=null;const u=()=>tt(this,void 0,void 0,(function*(){try{if(l=d.value,!l)return;if(yield l.meta.detectSemanticTypes(),!l.columns.bySemType(e.SEMTYPE.MOLECULE))return void(r.innerText="No molecules column found");r.innerText=""}catch(t){r.innerText="Error parsing file"}})),d=o.input.table("Dataframe",{onValueChanged:u});yield u();const p=o.div([d,r]);0===Object.keys(n).length&&e.Func.find({tags:[c]}).forEach((t=>{var e;n[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t}));let h=null;const m=()=>tt(this,void 0,void 0,(function*(){const t=n[f.value];h=t.prepare();const e=yield h.getEditor();e.classList.remove("ui-form"),v.innerHTML="",v.appendChild(e)})),v=o.div([]),f=o.input.choice(w,{value:null!==(s=i.queryFunctionName)&&void 0!==s?s:Object.keys(n)[0],items:Object.keys(n),onValueChanged:m});yield m(),i.queryFunctionName&&(null===(a=f.root.getElementsByTagName("select").item(0))||void 0===a||a.setAttribute("disabled","true"));const g=o.div([f,v]);g.style.display="none";const y=o.div([p,g]),b=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:X[t.type],nullable:!t.required},t.semtype?{semType:t.semtype}:{})))),A={},T=b.length?o.input.form(A,b):o.div();T.classList.remove("ui-form"),"File"===i.dataSourceType?(p.style.display="inherit",g.style.display="none"):(p.style.display="none",g.style.display="inherit");const I=o.div([y,...b.length?[T]:[]]),S=o.buttonsInput([]);return I.appendChild(S),{promise:new Promise((e=>{const s=()=>tt(this,void 0,void 0,(function*(){if("File"===i.dataSourceType){if(!l)return void t.shell.error("No file selected");const i=l;i.name=l.name,e({df:i,type:"File",campaignProps:A})}else{const i=n[f.value];if(!i)return void t.shell.error("No function selected");const o={};Object.entries(h.inputs).forEach((([t,e])=>{o[t]=e}));const s=yield i.apply(o);e({df:s,type:"Query",campaignProps:A})}})),a=o.bigButton(C,(()=>s()));S.appendChild(a)})),root:I,cancelPromise:new Promise((t=>{o.button(x,(()=>t()))}))}}))}(i,this.dataSourceFunctionsMap);return o.setUpdateIndicator(n,!1),a.then((t=>bt(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)})))),r.then((()=>{this.init()})),s}))}createNewTemplate(){return bt(this,void 0,void 0,(function*(){const i=yield ut(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:s}=Y(t.shell.v,"Hit Triage",b,(()=>{t.shell.v=o,n.close()}));i.template.then((e=>bt(this,void 0,void 0,(function*(){yield this.init(e),n.close(),W(n),t.shell.v=o,s.unsubscribe()})))),i.cancelPromise.then((()=>{s.unsubscribe(),n.close(),t.shell.v=o}))}))}}class At extends ht{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(){return i=this,n=void 0,s=function*(){var i;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 s=e.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:s,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),t.shell.info("Submitted successfully.")},new((o=void 0)||(o=Promise))((function(t,e){function a(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 o?i:new o((function(t){t(i)}))).then(a,r)}l((s=s.apply(i,n||[])).next())}));var i,n,o,s}}var Tt=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))};class xt{constructor(t){this.parentCall=t,this.isJoining=!1,this.hasEditPermission=!1,this.resetBaseUrl(),this.computeFunctions=new Promise((t=>Tt(this,void 0,void 0,(function*(){const i=e.Func.find({tags:["HitTriageFunction"]}),n=i.filter((t=>t.type===E.function)),o=i.filter((t=>t.type===E.script)),s=i.filter((t=>t.type===E.query));t({functions:n,scripts:o,queries:s})}))))}setCanEdit(t){return Tt(this,void 0,void 0,(function*(){t.authorUserId&&t.permissions?this.hasEditPermission=yield Q(t.authorUserId,t.permissions):this.hasEditPermission=!0}))}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"),s=e.DataFrame.fromColumns(t.columns.toList().filter((t=>!t.name.startsWith("~")))).toCsv({filteredRowsOnly:n});o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(s)),o.setAttribute("download",i+".csv"),o.click()}getNewCampaignName(t,e){return Tt(this,void 0,void 0,(function*(){const i=(yield qt.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,s,a,r,l;const c=null===(s=null===(o=t.col(n))||void 0===o?void 0:o.toList())||void 0===s?void 0:s.filter((t=>!!t)).map((t=>e.chem.convert(t,e.chem.Notation.Unknown,e.chem.Notation.Smiles))),u=null===(r=null===(a=i.col(n))||void 0===a?void 0:a.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 It=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))},St=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))};function Et(t){let e=0;if(t.length>1)for(const i of t.toList()){if(!i||!i.startsWith(v[0])||7!==i.length)continue;const t=parseInt(i.substring(1));isNaN(t)||(e=Math.max(t,e))}return`V${"".concat(...new Array(6-(e+1).toString().length).fill("0"))}${e+1}`}function Nt(i,n,o){return St(this,void 0,void 0,(function*(){var s,a;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)}try{i.descriptors&&i.descriptors.length>0&&(yield t.chem.descriptors(n,o,i.descriptors))}catch(t){console.error("Descriptors calculation error",t)}for(const t of Object.keys(i.externals))try{const s=i.externals[t],a=e.Func.find({package:t.split(":")[0],name:t.split(":")[1]})[0],r=a.inputs[0].name,l=a.inputs[1].name;s&&(yield a.apply(Object.assign(Object.assign({},s),{[r]:n,[l]:o})))}catch(t){console.error(t)}for(const t of Object.keys(null!==(s=i.scripts)&&void 0!==s?s:{})){const s=i.scripts[t];if(s){const i=t.split(":"),a=i[2];if(!a)continue;try{const t=i[1],r=e.Func.find({name:t}).filter((t=>t.type===E.script&&t.id===a))[0];if(!r)continue;const l=r.inputs[0].name,c=r.inputs[1].name,u=yield r.apply(Object.assign(Object.assign({},s),{[l]:n,[c]:o}));if(u&&u.rowCount===n.rowCount&&"python"===r.language)for(const t of u.columns)t.name=n.columns.getUnusedName(t.name),n.columns.add(t)}catch(t){console.error(t)}}}for(const t of Object.keys(null!==(a=i.queries)&&void 0!==a?a:{})){const s=i.queries[t];if(s){const i=t.split(":"),a=i[2];if(!a)continue;try{const t=i[1],r=e.Func.find({name:t}).filter((t=>t.type===E.query&&t.id===a))[0];if(!r)continue;const l=r.inputs[0].name,c=n.col(o).toList(),u=yield r.apply(Object.assign(Object.assign({},s),{[l]:c}));u&&(yield J(n,o,u))}catch(t){console.error(t)}}}r.close()}))}var _t=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))};class Ft extends xt{get infoView(){return this._infoView}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 ht&&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(),q(s,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)}}))}setTemplate(i,n,o,a){return _t(this,void 0,void 0,(function*(){var r,l,c,u,d,p,h,m,v,y,w,b,C,A,T;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?a&&(this._fileInputType=a.type,"File"===a.type?this.dataFrame=yield t.dapi.files.readCsv(a.query):this.dataFrame=yield t.functions.call(a.query)):(o=yield this.getNewCampaignName("Hit Triage/campaigns",i.key),q(s,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!==(h=this.dataFrame.name)&&void 0!==h?h:null==a?void 0:a.query,this.dataFrame.name=null!==(v=null!==(m=this._dfName)&&void 0!==m?m:this.dataFrame.name)&&void 0!==v?v:"Molecules",this._campaignId=o,this.template=(null===(y=this.campaign)||void 0===y?void 0:y.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===(w=i.compute.scripts)||void 0===w||w.forEach((t=>{const i=`${f}:${t.name}:${t.id}`;e[i]=t.args})),null===(b=i.compute.queries)||void 0===b||b.forEach((t=>{const e=`${g}:${t.name}:${t.id}`;n[e]=t.args})),yield Nt({descriptors:i.compute.descriptors.enabled?i.compute.descriptors.args:[],externals:t,scripts:e,queries:n},this.dataFrame,this._molColName)}this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0;const x=t.shell.v,I=t.shell.addView(this.pickView);this.currentPickViewId=I.name,this._submitView=new At(this),this.setBaseUrl(),q(s,null!==(T=null!==(C=this._campaignId)&&void 0!==C?C:null===(A=this._campaign)||void 0===A?void 0:A.name)&&void 0!==T?T:"");const S=I;setTimeout((()=>{this._pickViewPromise&&this._pickViewPromise.then((()=>{const{sub:e}=Y(S,"Hit Triage","Pick",(()=>{t.shell.v=x,S.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(d)||this.dataFrame.columns.addNewBool(d).init(!1);const i=e.TableView.create(this.dataFrame,!1),n=i.getRibbonPanels(),s=o.iconFA("wrench",(()=>_t(this,void 0,void 0,(function*(){ot(this,(t=>_t(this,void 0,void 0,(function*(){var e,i,n,o,s,a,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,h={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!==(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!==(a=null==t?void 0:t.scripts)&&void 0!==a?a:{}).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}})),queries:Object.entries(null!==(r=null==t?void 0:t.queries)&&void 0!==r?r:{}).filter((([t,e])=>t.startsWith(g)&&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=h;const m=p.filter((t=>!l.includes(t))),v=h.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=h.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=h.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={};v.forEach((t=>{const e=`${t.package}:${t.name}`;b[e]=t.args}));const C={};y.forEach((t=>{const e=`${f}:${t.name}:${t.id}`;C[e]=t.args}));const A={};w.forEach((t=>{const e=`${g}:${t.name}:${t.id}`;A[e]=t.args})),yield Nt({descriptors:m,externals:b,scripts:C,queries:A},this.dataFrame,this._molColName),this.saveCampaign("In Progress",!1)}))),(()=>null),this.template,!0)}))),"Calculate additional properties"),a=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()}})),r=o.iconFA("share",(()=>_t(this,void 0,void 0,(function*(){var t;yield new wt(null===(t=this.campaign)||void 0===t?void 0:t.permissions).show((t=>{this.campaign.permissions=t,this.saveCampaign(void 0,!0)}))}))),"Edit permissions");a.classList.add("hit-design-submit-button");const l=G(n);return n.push([s,...this.hasEditPermission?[r]:[],...l?[]:[a]]),i.setRibbonPanels(n),i.name=this._filterViewName,setTimeout((()=>_t(this,void 0,void 0,(function*(){var n,o,s;i._onAdded(),yield new Promise((t=>setTimeout(t,1e3)));const a=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===(s=this.template)||void 0===s?void 0:s.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=a.getOptions().look.filters})),setTimeout((()=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=a.getOptions().look.filters}),300),t&&t()}))),300),i.parentCall=this.parentCall,i}getSummary(){var t,e,i,n,s,a,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!==(s=this._dfName)&&void 0!==s?s:"-",(()=>this.download(this.dataFrame,"molecules")),T)],{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===(a=this.dataFrame)||void 0===a?void 0:a.filter.trueCount.toString())&&void 0!==r?r:"0",(()=>{this.download(this.dataFrame,"hits",!0)}),T)],{style:{alignItems:"center"}})})}saveCampaign(i){return _t(this,arguments,void 0,(function*(i,n=!0){var s,a,c,u,d,p,h,m,v,f;const g=this.campaignId,y=this.filterSettings,w=this.template.name,b=this.dataFrame,C=`System:AppData/HitTriage/Hit Triage/campaigns/${g}/`,A=null!=g?g:yield function(t){return It(this,void 0,void 0,(function*(){return new Promise((e=>It(this,void 0,void 0,(function*(){const i=o.input.string("Campaign name",{value:""});o.dialog("Save Campaign").add(o.div(i.root)).onOK((function(){i.value&&""!==i.value?e(i.value):e(t)})).show()}))))}))}(g),T={};b.columns.toList().forEach((t=>T[t.name]=t.semType));const x={};b.columns.toList().forEach((t=>x[t.name]=t.type));const I=null!==(a=null===(s=this.campaign)||void 0===s?void 0:s.authorUserId)&&void 0!==a?a:t.shell.user.id,S=null!==(u=null===(c=this.campaign)||void 0===c?void 0:c.permissions)&&void 0!==u?u:yt,E={name:A,templateName:w,filters:null!=y?y:{},ingest:{type:"File",query:`${C}${r}`,molColName:this.molColName},status:null!==(p=null!=i?i:null===(d=this.campaign)||void 0===d?void 0:d.status)&&void 0!==p?p:"In Progress",createDate:null!==(m=null===(h=this.campaign)||void 0===h?void 0:h.createDate)&&void 0!==m?m:H(new Date),campaignFields:null!==(f=null===(v=this.campaign)||void 0===v?void 0:v.campaignFields)&&void 0!==f?f:this.campaignProps,columnSemTypes:T,rowCount:b.rowCount,filteredRowCount:b.filter.trueCount,template:this.template,columnTypes:x,authorUserId:I,permissions:S};if(this.campaign=E,!this.hasEditPermission)return t.shell.error("You do not have permission to modify this campaign"),E;const N=e.DataFrame.fromColumns(b.columns.toList().filter((t=>!t.name.startsWith("~")))).toCsv();yield qt.files.writeAsText(`Hit Triage/campaigns/${g}/${r}`,N);const _=this._pickView.saveLayout();return _?E.layout=_.viewState:t.shell.warning("Layout cound not be saved"),yield qt.files.writeAsText(`Hit Triage/campaigns/${g}/${l}`,JSON.stringify(E)),n&&t.shell.info("Campaign saved successfully."),E}))}}var Pt=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))};function Vt(i,n){return Pt(this,void 0,void 0,(function*(){var s,a,r,l,c,d,p,h,m,v,y;const w=yield qt.files.list("Hit Design/templates");let b=!1,C=!1;const T=w.map((t=>t.name.slice(0,-5))),I=[];for(const t of w)try{const e=JSON.parse(yield qt.files.readAsText(t));I.push(e.key)}catch(t){console.error(t)}const S=e.Func.find({tags:[u]}),E={};S.forEach((t=>{var e;E[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t}));const N=o.input.choice("Submit function",{value:null,items:[null,...Object.keys(E)]});N.nullable=!0,N.value=null!==(a=null===(s=null==n?void 0:n.submit)||void 0===s?void 0:s.fName)&&void 0!==a?a: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"}),P=lt();function V(){var t,e,i,n;if(""===B.value||T.includes(null!==(e=null===(t=B.value)||void 0===t?void 0:t.trim())&&void 0!==e?e:"")){const t=null!==(i=B.input.offsetLeft)&&void 0!==i?i:0,e=null!==(n=B.input.offsetWidth)&&void 0!==n?n:0;_.style.marginLeft=`${t}px`,_.style.width=`${e}px`,_.style.opacity="100%",_.style.borderTop="1px solid red",b=!0}else _.style.borderTop="none",_.style.opacity="0%",b=!1}const B=o.input.string("Name",{value:null!==(r=null==n?void 0:n.name)&&void 0!==r?r:"",onValueChanged:V});function O(){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%",C=!0}else F.style.opacity="0%",F.style.borderTop="none",C=!1}const k=o.input.string("Key",{value:null!==(l=null==n?void 0:n.key)&&void 0!==l?l:"",onValueChanged:O});k.setTooltip("Template key used for campaign prefix"),B.setTooltip("Template name"),B.root.style.borderBottom="none",k.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===(c=null==n?void 0:n.compute)||void 0===c?void 0:c.descriptors)||void 0===d?void 0:d.args)&&void 0!==p?p:[]},functions:null!==(m=null===(h=null==n?void 0:n.compute)||void 0===h?void 0:h.functions)&&void 0!==m?m:[]}},D=yield ot(i,(t=>{L=t}),(()=>null),j,!1);D.root.classList.add("hit-triage-new-template-functions-input");const U=dt(null==n?void 0:n.campaignFields),R=function(t){const i=[e.Property.fromOptions({name:"Name",type:e.TYPE.STRING})],n=new at(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),$=o.divV([o.divV([B,_]),o.divV([k,F]),P.dataFileInput,U.fieldsDiv]),M=o.h2("Stages");o.tooltip.bind(M,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const H=o.h2("Compute");o.tooltip.bind(H,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const q=o.div([o.h2("Details"),$,M,R.fieldsDiv,H,D.root,o.h2("Submit"),N.root],"ui-form"),Y=o.buttonsInput([]);q.appendChild(Y);const W=null!==(y=null===(v=Y.getElementsByClassName("ui-input-editor"))||void 0===v?void 0:v[0])&&void 0!==y?y:Y,G=new Promise((t=>{const e=o.button(x,(()=>t()));W.appendChild(e)})),J=new Promise((e=>{const i=o.bigButton(A,(()=>function(){return Pt(this,void 0,void 0,(function*(){var i,n,o,s,a,r;if(V(),O(),D.okProxy(),b||!B.value||""===B.value)return void t.shell.error("Template name is empty or already exists");if(C||!k.value||""===k.value)return void t.shell.error("Template key is empty or already exists");const l=N.value?E[N.value]:void 0,c=Object.assign({name:B.value,key:k.value,campaignFields:U.getFields(),stages:R.getFields(),layoutViewState:null!==(i=P.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!==(s=null==L?void 0:L.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!==(a=null==L?void 0:L.scripts)&&void 0!==a?a:{}).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}})),queries:Object.entries(null!==(r=null==L?void 0:L.queries)&&void 0!==r?r:{}).filter((([t,e])=>t.startsWith(g)&&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,qt.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:J,cancelPromise:G}}))}var Bt=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))};class Ot extends ht{constructor(e){super(e),this.name="Hit Design",t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(qt.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(qt.webRoot+"README_HD.md")}init(t){return Bt(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const e=o.h1(I),i=o.h1(S,{style:{marginLeft:"10px"}}),n=ft.appHeader({iconPath:qt.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"}),s=o.div(),a=o.divH([]),r=o.div([a,s],"ui-form"),l=yield this.getCampaignsTable();it()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,e],{style:{marginLeft:"10px"}}),l,i,r])),yield this.startNewCampaign(s,a,t),this.app.resetBaseUrl()}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(e,i,n){return Bt(this,void 0,void 0,(function*(){var s;const a=(yield qt.files.list("Hit Design/templates")).filter((t=>t.name.endsWith(".json"))).map((t=>t.name.slice(0,-5)));n&&!a.includes(n.name)&&a.push(n.name);let r=null,l=!0;const c=()=>Bt(this,void 0,void 0,(function*(){if(!l)return;const t=u.value,i=n&&n.name===t?n:JSON.parse(yield qt.files.readAsText("Hit Design/templates/"+t+".json"));r=i;const o=yield this.getNewCampaignAccordeon(i);it()(e).empty(),e.appendChild(o)})),u=o.input.choice("Template",{value:null!==(s=null==n?void 0:n.name)&&void 0!==s?s:a[0],items:a,onValueChanged:()=>Bt(this,void 0,void 0,(function*(){yield c()}))});u.root.style.width="100%";const d=o.icons.add((()=>{this.createNewTemplate()}),b),p=o.icons.copy((()=>{r&&this.createNewTemplate(r)}),"Clone template"),h=o.icons.delete((()=>{!u.value||u.items.length<2||o.dialog("Delete template").add(o.divText(`Are you sure you want to delete template ${u.value}?`)).onOK((()=>Bt(this,void 0,void 0,(function*(){try{const e=u.value;yield qt.files.delete(`Hit Design/templates/${e}.json`),l=!1,u.items=u.items.filter((t=>t!==e)),u.value=u.items[0],l=!0,yield c(),t.shell.info("Template "+e+" was deleted successfully")}catch(e){l=!0,t.shell.error("Failed to delete template "+u.value),console.error(e)}})))).show()}),"Delete template");d.style.color="#2083d5",u.addOptions(h),u.addOptions(p),u.addOptions(d),yield c(),it()(i).empty(),i.appendChild(u.root)}))}checkCampaign(t){return Bt(this,void 0,void 0,(function*(){var e;const i=location.search,n=new URLSearchParams(i);if(!n.has(a)&&!t)return;const o=null!=t?t:n.get(a);if(!(yield qt.files.exists(`Hit Design/campaigns/${o}/${l}`)))return;const s=JSON.parse(yield qt.files.readAsText(`Hit Design/campaigns/${o}/${l}`));if(s){if(s.authorUserId&&s.permissions&&!(yield Z(s.authorUserId,s.permissions)))return void this.app.setBaseUrl();this.app.campaign=s}const r=null!==(e=s.template)&&void 0!==e?e:JSON.parse(yield qt.files.readAsText(`Hit Design/templates/${s.templateName}.json`));return yield this.app.setTemplate(r,o),t&&q(a,t),s.template=r,s}))}getCampaignsTable(){return Bt(this,void 0,void 0,(function*(){const i=yield z("Hit Design",this.deletedCampaigns),n=i=>{var n,s;const a=o.icons.delete((()=>Bt(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${i.name}?`)).onOK((()=>Bt(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Design",i.name),this.deletedCampaigns.push(i.name),yield this.init()})))).show()}))),"Delete campaign"),r=o.iconFA("share",(()=>Bt(this,void 0,void 0,(function*(){yield new wt(i.permissions).show((e=>Bt(this,void 0,void 0,(function*(){var n;try{i.permissions=e,null!==(n=i.authorUserId)&&void 0!==n||(i.authorUserId=t.shell.user.id),yield qt.files.writeAsText(`Hit Design/campaigns/${i.name}/${l}`,JSON.stringify(i)),t.shell.info("Permissions updated for campaign "+i.name)}catch(e){t.shell.error("Failed to update permissions for campaign "+i.name),console.error(e)}}))))}))),"Manage campaign permissions");return a.style.display="none",r.style.display="none",Q(null!==(n=i.authorUserId)&&void 0!==n?n:e.User.current().id,null!==(s=i.permissions)&&void 0!==s?s:yt).then((t=>{t&&(a.style.display="inline-block",r.style.display="inline-block")})),[r,a]},s=o.table(Object.values(i),(t=>[o.link(t.name,(()=>this.setCampaign(t.name)),"",""),t.createDate,t.rowCount,t.status,...n(t)]),["Name","Created","Molecules","Status",""]);return s.style.color="var(--grey-5)",s.style.marginLeft="24px",s}))}setCampaign(t){return Bt(this,void 0,void 0,(function*(){const e=yield this.checkCampaign(t);this.app.campaign=e}))}getNewCampaignAccordeon(i){return Bt(this,void 0,void 0,(function*(){const{root:n,promise:s,cancelPromise:a}=function(i){var n,s;const a=e.DataFrame.create(1),r=a.columns.addNew(h,e.TYPE.STRING);r.semType=e.SEMTYPE.MOLECULE,r.meta.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&&a.columns.addNew(p,e.TYPE.STRING).set(0,i.stages[0]);const l=a.columns.addNew(m,e.TYPE.STRING);l.set(0,Et(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:X[t.type],nullable:!t.required},t.semtype?{semType:t.semtype}:{})))),u={},d=o.input.form(u,c);d.classList.remove("ui-form");const v=o.div([...(null===(s=i.campaignFields)||void 0===s||s.length,[]),d]),f=o.buttonsInput([]);return v.appendChild(f),{promise:new Promise((e=>{const n=o.bigButton(C,(()=>{for(const e of i.campaignFields)if(e.required&&(!u[e.name]||""===u[e.name]))return void t.shell.error(`Field '${e.name}' is required`);e({df:a,campaignProps:u})}));f.appendChild(n)})),root:v,cancelPromise:new Promise((t=>{o.button(x,(()=>t()))}))}}(i);return s.then((t=>Bt(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)})))),a.then((()=>{this.init()})),n}))}createNewTemplate(i){return Bt(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const n=yield Vt(this.app,i),o=new e.ViewBase,s=t.shell.v;o.name="New Template",o.root.appendChild(n.root),o.parentCall=this.app.parentCall,t.shell.addView(o),o.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:a}=Y(o,"Hit Design",b,(()=>Bt(this,void 0,void 0,(function*(){t.shell.v=s,o.close()}))));n.template.then((e=>Bt(this,void 0,void 0,(function*(){yield this.init(e),o.close(),W(o),t.shell.v=s,a.unsubscribe()})))),n.cancelPromise.then((()=>Bt(this,void 0,void 0,(function*(){a.unsubscribe(),o.close(),t.shell.v=s}))))}finally{o.setUpdateIndicator(this.root,!1)}}))}}class kt extends ht{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(){return i=this,n=void 0,s=function*(){var i;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 s=e.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:s,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),t.shell.info("Submitted successfully.")},new((o=void 0)||(o=Promise))((function(t,e){function a(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 o?i:new o((function(t){t(i)}))).then(a,r)}l((s=s.apply(i,n||[])).next())}));var i,n,o,s}}var Lt=i(542),jt={};jt.styleTagTransform=U(),jt.setAttributes=k(),jt.insert=B().bind(null,"head"),jt.domAPI=P(),jt.insertStyleElement=j(),_()(Lt.A,jt),Lt.A&&Lt.A.locals&&Lt.A.locals;class Dt extends ht{constructor(t){super(t),this.v=null,this.name="Progress Tracker"}render(){return i=this,n=void 0,a=function*(){return new Promise((i=>{var n,s,a,r,l,c,u,d;this.app.dataFrame.columns.names().forEach((t=>{t.startsWith("~")&&this.app.dataFrame.columns.remove(t)}));const h=null===(n=this.app.campaign)||void 0===n?void 0:n.tilesViewerFormSketch;let m=null;if(h&&h.length>0)try{m=JSON.parse(h)}catch(t){console.error("Failed to parse sketch state string",t)}let v=!0;if(!this.v||this.v.isDetached){v=!1,m&&m.elementStates&&(null!==(s=m.elementStates.length)&&void 0!==s?s:0)>0&&(m.elementStates=m.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:p,lanes:null!==(r=null===(a=this.app.template)||void 0===a?void 0:a.stages)&&void 0!==r?r:[]},(null!==(c=null===(l=null==m?void 0:m.elementStates)||void 0===l?void 0:l.length)&&void 0!==c?c:0)>0?{sketchState:m}:{}));const t=this.v.getOptions();t.look.sketchState=(null!==(d=null===(u=null==m?void 0:m.elementStates)||void 0===u?void 0:u.length)&&void 0!==d?d:0)>0?m:null,this.v.setOptions(t),this.v.copyViewersLook(this.v)}v?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,s;null===(n=null===(e=this.v)||void 0===e?void 0:e.view)||void 0===n||n._onAdded();const a=null===(s=t.shell.v)||void 0===s?void 0:s.getRibbonPanels();if(a){if(G(a))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"),a.push([e,n]),t.shell.v.setRibbonPanels(a)}i()}),5))}))},new((s=void 0)||(s=Promise))((function(t,e){function o(t){try{l(a.next(t))}catch(t){e(t)}}function r(t){try{l(a.throw(t))}catch(t){e(t)}}function l(e){var i;e.done?t(e.value):(i=e.value,i instanceof s?i:new s((function(t){t(i)}))).then(o,r)}l((a=a.apply(i,n||[])).next())}));var i,n,s,a}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 Ut=rxjs.operators;var Rt=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))};class $t extends xt{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}constructor(i){super(i),this._tilesViewTab=null,this._designViewName="Design",this._filePath="System.AppData/HitTriage/Hit Design/campaigns",this._molColName=h,this.campaignProps={},this.processedValues=[],this._extraStageColsCount=0,this._infoView=new Ot(this),this.multiView=new e.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((t=>{this.multiView.currentView instanceof ht&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,this.mainView=this.multiView,t.events.onCurrentViewChanged.subscribe((()=>Rt(this,void 0,void 0,(function*(){var e,i,n,o,a,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(),q(s,null!==(a=null!==(n=this._campaignId)&&void 0!==n?n:null===(o=this._campaign)||void 0===o?void 0:o.name)&&void 0!==a?a:""),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}=Y(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)}}))))}setTemplate(i,n){return Rt(this,void 0,void 0,(function*(){var o,l,c,u,d,p,m,v,f,g,y,w,b;if(n){const e="System.AppData/HitTriage/Hit Design/campaigns";this._filePath=null!==(c=null===(l=this.campaign)||void 0===l?void 0:l.savePath)&&void 0!==c?c:`${e}/${n}/${r}`,this.dataFrame=yield t.dapi.files.readCsv(this._filePath),(null===(u=this._campaign)||void 0===u?void 0:u.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([t,e])=>{const i=this.dataFrame.columns.byName(t);i&&e&&(i.semType=e)})),(null===(d=this._campaign)||void 0===d?void 0:d.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),q(a,n),this._filePath=`System.AppData/HitTriage/Hit Design/campaigns/${n}/${r}`;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:h,this._dfName=null!==(v=(b=this.dataFrame).name)&&void 0!==v?v:b.name=n,this._campaignId=n,this.template=i,null!==(f=this._submitView)&&void 0!==f||(this._submitView=new kt(this)),t.shell.windows.showHelp=!1,this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0,this._extraStageColsCount=this.dataFrame.rowCount-this.dataFrame.filter.trueCount;const C=this.designView;this.currentDesignViewId=C.name,this.setBaseUrl(),q(s,null!==(w=null!==(g=this._campaignId)&&void 0!==g?g:null===(y=this._campaign)||void 0===y?void 0:y.name)&&void 0!==w?w:""),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:h}get campaign(){return this._campaign}set campaign(t){this._campaign=t}cacheDuplicateVIDs(){var t;const e=null===(t=this.dataFrame)||void 0===t?void 0:t.col(m);if(!e)return void(this._duplicateVidCache=void 0);const i=e.version,n=new Uint32Array(e.categories.length).fill(0),o=e.getRawData().subarray(0,e.length);o.forEach((t=>n[t]++)),this._duplicateVidCache={colVersion:i,valueCounts:n,indexes:o}}get duplicateVidCache(){var t;const e=null===(t=this.dataFrame)||void 0===t?void 0:t.col(m);if(e)return this._duplicateVidCache&&e.version===this._duplicateVidCache.colVersion||this.cacheDuplicateVIDs(),this._duplicateVidCache}getDesignView(){var i,n,s,a,r,l;const c=[],u=null===(i=this.dataFrame.col(this.molColName))||void 0===i?void 0:i.toList().every((t=>!t&&""===t)),d=t.shell.addTableView(this.dataFrame);this._designViewName=null!==(s=null===(n=this.campaign)||void 0===n?void 0:n.name)&&void 0!==s?s:this._designViewName,d.name=this._designViewName,this.processedValues=this.dataFrame.getCol(this.molColName).toList();const v=(i,n)=>Rt(this,void 0,void 0,(function*(){const o=this.template.compute;if(!n||""===n)return;const s=yield function(i,n,o){return St(this,arguments,void 0,(function*(i,n,o,s=[],a=[]){const r=e.TaskBarProgressIndicator.create("Calculating ..."),l=t.chem.convert(i,t.chem.Notation.Unknown,t.chem.Notation.Smiles),c=e.Column.fromStrings(h,[l]),u=e.DataFrame.fromColumns([c]);u.name="HD Single cell values",yield u.meta.detectSemanticTypes();try{n.length&&(yield t.chem.descriptors(u,c.name,n))}catch(t){console.error("Descriptors calculation error",t)}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],s=o.inputs[0].name,a=o.inputs[1].name;yield o.apply(Object.assign(Object.assign({},i),{[s]:u,[a]:c.name}))}catch(t){console.error(t);continue}for(const t of s){const i=t.args;try{const n=e.Func.find({name:t.name}).filter((e=>e.type===E.script&&e.id===t.id))[0];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 t of a){const i=t.args;try{const n=e.Func.find({name:t.name}).filter((e=>e.type===E.query&&e.id===t.id))[0];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 J(u,h,o)}}catch(t){console.error(t)}}return r.close(),u}))}(n,o.descriptors.args,o.functions,o.scripts,o.queries);for(const t of s.columns.toList())t.name!==h&&(this.dataFrame.columns.contains(t.name)||(this.dataFrame.columns.addNew(t.name,t.type).semType=t.semType),this.dataFrame.col(t.name).set(i,t.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(void 0,!1)}));setTimeout((()=>Rt(this,void 0,void 0,(function*(){var i,n,o,s;d._onAdded(),yield new Promise((t=>setTimeout(t,1e3)));const a=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(a)try{const t=e.ViewLayout.fromViewState(a);d.loadLayout(t)}catch(t){console.error(t)}u&&t.functions.call("Chem:editMoleculeCell",{cell:d.grid.cell(this._molColName,0)}),c.push(this.dataFrame.onRowsAdded.pipe((0,Ut.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(p).get(t);e&&""!==e&&!(null===(i=this.dataFrame.col(p))||void 0===i?void 0:i.isNone(t))||this.dataFrame.set(p,t,this.template.stages[0])}let n=null;for(let t=0;t<this.dataFrame.rowCount;t++){const e=d.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===(s=this.dataFrame)||void 0===s?void 0:s.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,s,a,r,l,c,u,p,h,m,f;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!==d.id)return;if((null===(a=null===(s=null===(o=null==i?void 0:i.args)||void 0===o?void 0:o.item)||void 0===s?void 0:s.tableColumn)||void 0===a?void 0:a.name)!==this.molColName||!(null===(l=null===(r=null==i?void 0:i.args)||void 0===r?void 0:r.item)||void 0===l?void 0:l.isTableCell))return;const g=null===(c=null==i?void 0:i.args)||void 0===c?void 0:c.menu;if(!g)return;g.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),g.item("Duplicate molecule",(()=>{var t,e,n,o;try{this.dataFrame.rows.addNew(null,!0);let s=null;for(let t=0;t<this.dataFrame.rowCount;t++){const e=d.grid.cell(this.molColName,t);e&&(""!==e.cell.value&&null!==e.cell.value||(s=e))}s&&(s.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)}}));const y=null===(p=null===(u=null==i?void 0:i.args)||void 0===u?void 0:u.item)||void 0===p?void 0:p.tableRowIndex,w=null===(f=null===(m=null===(h=null==i?void 0:i.args)||void 0===h?void 0:h.item)||void 0===m?void 0:m.cell)||void 0===f?void 0:f.value;w&&(null!=y?y:-1)>-1&&g.item("Re-Run Calculations",(()=>Rt(this,void 0,void 0,(function*(){try{yield v(y,w)}catch(t){console.error(t)}}))))}catch(e){t.log.error(e)}}))),c.push(d.grid.onCellValueEdited.subscribe((e=>Rt(this,void 0,void 0,(function*(){var i,n,o,s,a;try{if((null===(i=e.tableColumn)||void 0===i?void 0:i.name)===p)return void(yield this.saveCampaign(void 0,!1));if((null===(n=e.tableColumn)||void 0===n?void 0:n.name)!==this.molColName)return;const r=e.cell.value,l=e.tableRowIndex;let c=null===(o=this.dataFrame.col(m))||void 0===o?void 0:o.get(l),u=!1;if(r)try{const i=e.tableColumn.toList().map((e=>{try{return t.chem.convert(e,t.chem.Notation.Unknown,t.chem.Notation.Smiles)}catch(t){return""}})),n=t.chem.convert(r,t.chem.Notation.Unknown,t.chem.Notation.Smiles);if((null==i?void 0:i.length)===this.dataFrame.rowCount)for(let t=0;t<i.length;t++)if(i[t]===n&&t!==l&&(null===(s=this.dataFrame.col(m))||void 0===s?void 0:s.get(t))){c=null===(a=this.dataFrame.col(m))||void 0===a?void 0:a.get(t),u=!0;break}}catch(t){console.error(t)}this.duplicateVidCache&&!u&&this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[l]]>1&&(c=null),c&&""!==c||(c=Et(this.dataFrame.col(m))),this.dataFrame.col(m).set(l,c,!1),v(l,r)}catch(t){console.error(t)}}))))),c.push(d.grid.onCellRender.subscribe((t=>{var i;try{const n=t.cell;if(!n||!n.isTableCell||!n.tableColumn||!this.duplicateVidCache||n.tableColumn.name!==m||(null!==(i=n.tableRowIndex)&&void 0!==i?i:-1)<0)return;this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[n.tableRowIndex]]>1&&(t.cell.style.backColor=e.Color.setAlpha(e.Color.getCategoricalColor(this.duplicateVidCache.indexes[n.tableRowIndex]),150))}catch(t){}})));const r=t.events.onViewRemoved.subscribe((t=>{t.id===d.id&&(c.forEach((t=>t.unsubscribe())),r.unsubscribe())}))}))),300);const y=null==d?void 0:d.getRibbonPanels();if(y&&!G(y)){const e=()=>Rt(this,void 0,void 0,(function*(){var t;ot(this,(t=>Rt(this,void 0,void 0,(function*(){var e,i,n,s,a,r,l,c,u,p;const h=this.template.compute.descriptors.args,m=this.template.compute.functions,v=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!==(s=null==t?void 0:t.descriptors)&&void 0!==s?s:[]},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!==(r=null==t?void 0:t.scripts)&&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}})),queries:Object.entries(null!==(l=null==t?void 0:t.queries)&&void 0!==l?l:{}).filter((([t,e])=>t.startsWith(g)&&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=>!h.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=v.find((e=>`${f}:${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!==(p=null==t?void 0:t.queries)&&void 0!==p?p:{}).filter((([t,e])=>{const i=y.find((e=>`${g}:${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(d.grid.root,!0);try{yield Nt({descriptors:C,externals:A,scripts:T,queries:x},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{o.setUpdateIndicator(d.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"),s=o.iconFA("share",(()=>Rt(this,void 0,void 0,(function*(){var t;yield new wt(null===(t=this.campaign)||void 0===t?void 0:t.permissions).show((t=>{this.campaign.permissions=t,this.saveCampaign(void 0,!0)}))}))),"Edit campaign permissions"),c=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 Dt(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)})),u=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()}}));u.classList.add("hit-design-submit-button");const p=[u];null!==(l=null===(r=null===(a=this.template)||void 0===a?void 0:a.stages)||void 0===r?void 0:r.length)&&void 0!==l&&l&&p.unshift(c),this.campaign&&this.template&&!this.campaign.template&&(this.campaign.template=this.template),this.hasEditPermission&&p.unshift(s),p.unshift(i),p.unshift(n),y.push(p),d.setRibbonPanels(y)}return d.parentCall=this.parentCall,d}getSummary(){var i,n,s,a;const l=()=>{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)},c=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(c).forEach((([i,n])=>{const o=this.template.campaignFields.find((t=>t.name===i));o&&"Date"===o.type&&n?"Invalid Date"!==new Date(n).toString()?c[i]=new Date(n).toLocaleDateString():n.date?c[i]=new Date(n.date).toLocaleDateString():c[i]=n:o&&o.type===e.SEMTYPE.MOLECULE&&n&&(c[i]=t.chem.drawMolecule(n))})),Object.assign(Object.assign({Template:null!==(a=null===(s=this.template)||void 0===s?void 0:s.name)&&void 0!==a?a:"Molecules","File path":(()=>{const e=o.icons.edit((()=>{const i=l(),a=o.input.string("Path",{value:i}),c=a.root.getElementsByTagName("label").item(0);c&&c.remove(),a.root.style.width="100%";const u=o.button("Save",(()=>Rt(this,void 0,void 0,(function*(){const i=yield function(){return Rt(this,void 0,void 0,(function*(){const e=a.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 c=a.value;c.endsWith("/")?this._filePath=`${c}${this.campaignId}/${r}`:this._filePath=`${c}/${this.campaignId}/${r}`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(void 0,!0),o.empty(s);const u=l();n=o.link(u,(()=>{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")}),T),s.appendChild(n),s.appendChild(e)})))),d=o.button("Cancel",(()=>{o.empty(s),s.appendChild(n),s.appendChild(e)}));o.empty(s),a.addOptions(d),a.addOptions(u),s.appendChild(a.root)}),"Edit file path");e.style.marginLeft="5px";const i=l();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")}),T);const s=o.divH([n,e],{style:{alignItems:"center"}});return s})()},c),{"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){return Rt(this,arguments,void 0,(function*(i,n=!0){var o,s,a,r,c,u,d,p,h,v,f,g,y,w,b,C,A,T;const x=this.campaignId,I=this.template.name,S=this.dataFrame,E=x,N={};S.columns.toList().forEach((t=>N[t.name]=t.semType));const _={};S.columns.toList().forEach((t=>_[t.name]=t.type));const F=null!==(r=null!==(s=null===(o=this._tilesView)||void 0===o?void 0:o.sketchStateString)&&void 0!==s?s:null===(a=this.campaign)||void 0===a?void 0:a.tilesViewerFormSketch)&&void 0!==r?r:void 0,P=null!==(u=null===(c=this.campaign)||void 0===c?void 0:c.authorUserId)&&void 0!==u?u:t.shell.user.id,V=null!==(p=null===(d=this.campaign)||void 0===d?void 0:d.permissions)&&void 0!==p?p:yt,B={name:E,templateName:I,status:null!==(v=null!=i?i:null===(h=this.campaign)||void 0===h?void 0:h.status)&&void 0!==v?v:"In Progress",createDate:null!==(g=null===(f=this.campaign)||void 0===f?void 0:f.createDate)&&void 0!==g?g:H(new Date),campaignFields:null!==(w=null===(y=this.campaign)||void 0===y?void 0:y.campaignFields)&&void 0!==w?w:this.campaignProps,columnSemTypes:N,rowCount:null!==(C=null===(b=S.col(m))||void 0===b?void 0:b.toList().filter((t=>"StageDefiningRow"!==t)).length)&&void 0!==C?C:0,filteredRowCount:S.filter.trueCount,savePath:this._filePath,columnTypes:_,tilesViewerFormSketch:F,version:this.version+1,authorUserId:P,permissions:V};if(!this.hasEditPermission)return t.shell.error("You do not have permission to modify this campaign"),B;const O=`Hit Design/campaigns/${x}/${l}`;let k=S;if(yield qt.files.exists(O)){const e=JSON.parse(yield qt.files.readAsText(O));if((null!==(A=e.version)&&void 0!==A?A:0)>this.version&&(B.version=Math.max(this.version,null!==(T=e.version)&&void 0!==T?T:0)+1,yield t.dapi.files.exists(this._filePath)))try{const e=yield t.dapi.files.readCsv(this._filePath);k=this.unionDataframes(e,S,this.molColName)}catch(t){console.error(t)}}const L=e.DataFrame.fromColumns(k.columns.toList().filter((t=>!t.name.startsWith("~")))).toCsv();yield t.dapi.files.writeAsText(this._filePath,L);const j=this._designView.saveLayout();return j?B.layout=j.viewState:t.shell.warning("Layout cound not be saved"),B.template=this.template,yield qt.files.writeAsText(O,JSON.stringify(B)),n&&t.shell.info("Campaign saved successfully."),this.campaign=B,B}))}}class Mt 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,s,a){if(s.gridRow<0||!s.cell.value)return;const r=s.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 Ht=function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function a(t){try{l(n.next(t))}catch(t){s(t)}}function r(t){try{l(n.throw(t))}catch(t){s(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(a,r)}l((n=n.apply(t,e||[])).next())}))};const qt=new e.Package;function Yt(t,e){return Ht(this,void 0,void 0,(function*(){yield Jt(t,e,"Hit Triage")}))}function Wt(){return Ht(this,void 0,void 0,(function*(){const e=t.functions.getCurrentCall();return new Ft(e).multiView}))}function Gt(t,e){return Ht(this,void 0,void 0,(function*(){yield Jt(t,e,"Hit Design")}))}function Jt(i,n,o){return Ht(this,void 0,void 0,(function*(){const s=yield z(o,[]);for(const[o,a]of Object.entries(s)){const o="ingest"in a?a.ingest.query:a.savePath;o&&!1!==(yield t.dapi.files.exists(o))&&i.item(a.name).onSelected.subscribe((i=>Ht(this,void 0,void 0,(function*(){try{const i=yield t.dapi.files.readCsv(o);if(!i)return;const s=a.columnSemTypes;if(s)for(const[t,e]of Object.entries(s)){const n=i.columns.byName(t);n&&(n.semType=e)}const r=e.TableView.create(i,!1);n.preview=r;const l=a.layout;l&&r.loadLayout(e.ViewLayout.fromViewState(l))}catch(t){console.error(t)}}))))}}))}function zt(){return Ht(this,void 0,void 0,(function*(){const e=t.functions.getCurrentCall();return new $t(e).multiView}))}function Kt(){return Ht(this,void 0,void 0,(function*(){const e=t.data.demo.molecules(100);return e.name="100 Molecules",e}))}function Qt(){return Ht(this,void 0,void 0,(function*(){const e=t.data.demo.molecules(5e3);return e.name="5000 Molecules",e}))}function Zt(e){return Ht(this,void 0,void 0,(function*(){const i=t.data.demo.molecules(e);return i.name="Variable Molecules number",i}))}function Xt(e,i){return Ht(this,void 0,void 0,(function*(){t.shell.info(e.rowCount),t.shell.info(i)}))}function te(){return new Mt}})(),hittriage=n})();
2
2
  //# sourceMappingURL=package.js.map