@datagrok/hit-triage 1.4.2 → 1.4.3
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 +4 -0
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/files/cache_config.json +27 -0
- package/package.json +1 -1
- package/src/app/hit-app-base.ts +5 -2
- package/src/app/hit-design-app.ts +2 -16
- package/src/app/utils.ts +13 -0
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"),u=Array.isArray,d=Array.prototype,c=d.concat,p=d.filter,h=d.indexOf,m=d.map,v=d.push,f=d.slice,g=d.some,y=d.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||F(t)||_(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(E(e))return e;var o=e;if(O(e)){var a=n||t;if(!(o=w.test(e)&&F(a)?a.getElementById(e.slice(1).replace(/\\/g,"")):C.test(e)?Z(e):E(a)?a.find(e):O(a)?N(a).find(e):T(e,a)))return}else if(P(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 E(e){return e instanceof x}function I(e){return!!e&&e===e.window}function F(e){return!!e&&9===e.nodeType}function _(e){return!!e&&1===e.nodeType}function P(e){return"function"==typeof e}function O(e){return"string"==typeof e}function V(e){return void 0===e}function L(e){return null===e}function B(e){return!isNaN(parseFloat(e))&&isFinite(e)}function k(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function M(e,t,i){if(i){for(var n=e.length;n--;)if(!1===t.call(e[n],n,e[n]))return e}else if(k(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 U(){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 U(i,N,n);for(var a=0;a<o;a++){var s=e[a];for(var r in s)i&&(u(s[r])||k(s[r]))?(n[r]&&n[r].constructor===s[r].constructor||(n[r]=new s[r].constructor),U(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]=d[Symbol.iterator]),N.isWindow=I,N.isFunction=P,N.isArray=u,N.isNumeric=B,N.isPlainObject=k,N.each=M,S.each=function(e){return M(this,e)},S.empty=function(){return this.each((function(e,t){for(;t.firstChild;)t.removeChild(t.firstChild)}))},N.extend=U,S.extend=function(e){return U(S,e)};var R=/\S+/g;function j(e){return O(e)&&e.match(R)||[]}function D(e,t,n){if(_(e)){var o=i.getComputedStyle(e,null);return n?o.getPropertyValue(t)||void 0:o[t]||e.style[t]}}function $(e,t){return parseInt(D(e,t),10)||0}function H(e,t){return $(e,"border".concat(t?"Left":"Top","Width"))+$(e,"padding".concat(t?"Left":"Top"))+$(e,"padding".concat(t?"Right":"Bottom"))+$(e,"border".concat(t?"Right":"Bottom","Width"))}S.toggleClass=function(e,t){var i=j(e),n=!V(t);return this.each((function(e,o){_(o)&&M(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=j(e);return this.each((function(e,i){_(i)&&M(t,(function(e,t){i.removeAttribute(t)}))}))},S.attr=function(e,t){if(e){if(O(e)){if(arguments.length<2){if(!this[0]||!_(this[0]))return;var i=this[0].getAttribute(e);return L(i)?void 0:i}return V(t)?this:L(t)?this.removeAttr(e):this.each((function(i,n){_(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 _(t)&&t.classList.contains(e)}))},S.get=function(e){return V(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 V(e)?this.get().map((function(e){return _(e)||(t=e)&&3===t.nodeType?e.textContent:"";var t})).join(""):this.each((function(t,i){_(i)&&(i.textContent=e)}))};var q={};function Y(e){return"none"===D(e,"display")}function G(e,t){var i=e&&(e.matches||e.webkitMatchesSelector||e.msMatchesSelector);return!!i&&!!t&&i.call(e,t)}function W(e){return O(e)?function(t,i){return G(i,e)}:P(e)?e:E(e)?function(t,i){return e.is(i)}:e?function(t,i){return i===e}:function(){return!1}}function J(e,t){return t?e.filter(t):e}S.filter=function(e){var t=W(e);return N(p.call(this,(function(e,i){return t.call(e,i,e)})))},S.detach=function(e){return J(this,e).each((function(e,t){t.parentNode&&t.parentNode.removeChild(t)})),this};var z=/^\s*<(\w+)[^>]*>/,K=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,Q={"*":a,tr:r,td:l,th:l,thead:s,tbody:s,tfoot:s};function Z(e){if(!O(e))return[];if(K.test(e))return[o(RegExp.$1)];var t=z.test(e)&&RegExp.$1,i=Q[t]||Q["*"];return i.innerHTML=e,N(i.childNodes).detach().get()}function X(e,t,i,n){for(var o=[],a=P(t),s=n&&W(n),r=0,l=e.length;r<l;r++)if(a){var u=t(e[r]);u.length&&v.apply(o,u)}else for(var d=e[r][t];!(null==d||n&&s(-1,d));)o.push(d),d=i?d[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=W(e);return this.filter((function(i,n){return(!O(e)||_(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=u(e)?m.call(e,String):L(e)?[]:[String(e)];n?M(i.options,(function(e,t){t.selected=o.indexOf(t.value)>=0}),!0):i.checked=o.indexOf(i.value)>=0}else i.value=V(e)||L(e)?"":e})):this[0]&&ee(this[0])},S.is=function(e){var t=W(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 J(N(te(X(this,(function(e){return e.children})))),e)},S.parent=function(e){return J(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 J(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,u){return M(e,(function(e,r){M(N(r),(function(e,r){M(N(t),(function(t,l){var u=i?l:r,d=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,""),M(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,d?u.cloneNode(!0):u,a,s,!d)}),u)}),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(V(e))return this;var t=/<script[\s>]/.test(e);return this.each((function(i,n){_(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 J(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 J(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 J(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(c.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"===D(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"===D(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"===D(o,"position");)o=o.parentNode;if(o!==e&&_(o)){var a=N(o).offset();i.top-=a.top+$(o,"borderTopWidth"),i.left-=a.left+$(o,"borderLeftWidth")}}return{top:i.top-$(e,"marginTop"),left:i.left-$(e,"marginLeft")}}};var 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 ue=/^--/;function de(e){return ue.test(e)}var ce={},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=de(e)),i||me[e]||!B(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=de(e);return e=function(e,t){if(void 0===t&&(t=de(e)),t)return e;if(!ce[e]){var i=re(e),n="".concat(i[0].toUpperCase()).concat(i.slice(1));M("".concat(i," ").concat(he.join("".concat(n," "))).concat(n).split(" "),(function(t,i){if(i in pe)return ce[e]=i,!1}))}return ce[e]}(e,i),arguments.length<2?this[0]&&D(this[0],e,i):e?(t=ve(e,t,i),this.each((function(n,o){_(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):V(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},M([!0,!1],(function(e,t){M(["Width","Height"],(function(e,i){var n="".concat(t?"outer":"inner").concat(i);S[n]=function(n){if(this[0])return I(this[0])?t?this[0]["inner".concat(i)]:this[0].document.documentElement["client".concat(i)]:F(this[0])?we(this[0],i):this[0]["".concat(t?"offset":"client").concat(i)]+(n&&t?$(this[0],"margin".concat(e?"Top":"Left"))+$(this[0],"margin".concat(e?"Bottom":"Right")):0)}}))})),M(["Width","Height"],(function(e,t){var i=t.toLowerCase();S[i]=function(n){if(!this[0])return V(n)?void 0:this;if(!arguments.length)return I(this[0])?this[0].document.documentElement["client".concat(t)]:F(this[0])?we(this[0],t):this[0].getBoundingClientRect()[i]-H(this[0],!e);var o=parseInt(n,10);return this.each((function(t,n){if(_(n)){var a=D(n,"boxSizing");n.style[i]=ve(i,o+("border-box"===a?H(n,!e):0))}}))}}));var be="___cd";S.toggle=function(e){return this.each((function(i,n){if(_(n)){var a=Y(n);(V(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=D(i,"display");return t.body.removeChild(i),q[e]="none"!==n?n:"block"}(n.tagName))):a||(n[be]=D(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 Ee(e){return e[Ce]=e[Ce]||{}}function Ie(e,t){return!t||!g.call(t,(function(t){return e.indexOf(t)<0}))}function Fe(e,t,i,n,o){var a=Ee(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||!Ie(s,i)||n&&n!==r)return!0;e.removeEventListener(t,l)})));else for(t in a)Fe(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&&P(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(V(e))this.each((function(e,t){(_(t)||F(t)||I(t))&&Fe(t)}));else if(O(e))P(t)&&(i=t,t=""),M(j(e),(function(e,o){var a=Ne(o),s=a[0],r=a[1],l=Se(s);n.each((function(e,n){(_(n)||F(n)||I(n))&&Fe(n,l,r,t,i)}))}));else for(var o in e)this.off(o,e[o]);return this},S.remove=function(e){return J(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)||(V(t)||L(t)?t="":V(i)?(i=t,t=""):(n=i,i=t,t="")),P(n)||(n=i,i=void 0),n?(M(j(e),(function(e,s){var r=Ne(s),l=r[0],u=r[1],d=Se(l),c=l in Te,p=l in Ae;d&&a.each((function(e,a){if(_(a)||F(a)||I(a)){var s=function(e){if(e.target["___i".concat(e.type)])return e.stopImmediatePropagation();if((!e.namespace||Ie(u,e.namespace.split(".")))&&(t||!(p&&(e.target!==a||e.___ot===d)||c&&e.relatedTarget&&a.contains(e.relatedTarget)))){var r=a;if(t){for(var l=e.target;!G(l,t);){if(l===a)return;if(!(l=l.parentNode))return}r=l}Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return r}}),Object.defineProperty(e,"delegateTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(e,"data",{configurable:!0,get:function(){return i}});var h=n.call(r,e,e.___td);o&&Fe(a,d,u,t,s),!1===h&&(e.preventDefault(),e.stopPropagation())}};s.guid=n.guid=n.guid||N.guid++,function(e,t,i,n,o){var a=Ee(e);a[t]=a[t]||[],a[t].push([i,n,o]),e.addEventListener(t,o)}(a,d,u,t,s)}}))})),this):this},S.one=function(e,t,i,n){return this.on(e,t,i,n,!0)};var _e=/\r?\n/g,Pe=/file|reset|submit|button|image/i,Oe=/radio|checkbox/i;S.serialize=function(){var e="";return this.each((function(t,i){M(i.elements||[i],(function(t,i){if(!(i.disabled||!i.name||"FIELDSET"===i.tagName||Pe.test(i.type)||Oe.test(i.type)&&!i.checked)){var n=ee(i);V(n)||M(u(n)?n:[n],(function(t,n){e+=function(e,t){return"&".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t.replace(_e,"\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}\n\n.hit-design-stage-editing-dialog {\n z-index: 10000 !important;\n}\n\n.hit-design-groupped-campaigns-table .d4-accordion-pane-content.expanded {\n margin: 0 !important;\n}","",{version:3,sources:["webpack://./src/app/hit-design-views/utils.css"],names:[],mappings:"AAAA;IACI,eAAe;AACnB;;AAEA;IACI,yBAAyB;AAC7B;;AAEA;IACI,oBAAoB;AACxB",sourcesContent:["img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}\n\n.hit-design-stage-editing-dialog {\n z-index: 10000 !important;\n}\n\n.hit-design-groupped-campaigns-table .d4-accordion-pane-content.expanded {\n margin: 0 !important;\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 u=0;u<e.length;u++){var d=[].concat(e[u]);n&&s[d[0]]||(void 0!==a&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=a),i&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=i):d[2]=i),o&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=o):d[4]="".concat(o)),t.push(d))}},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],u=n.base?l[0]+n.base:l[0],d=a[u]||0,c="".concat(u," ").concat(d);a[u]=d+1;var p=i(c),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:c,updater:m,references:1})}s.push(c)}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),u=0;u<a.length;u++){var d=i(a[u]);0===t[d].references&&(t[d].updater(),t.splice(d,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,{HTPackage:()=>at,_package:()=>st,demoFileIngest:()=>mt,demoFileIngest1:()=>vt,demoFileIngest2:()=>ft,demoFileSubmit:()=>gt,gasteigerCellRenderer:()=>yt,hitDesignApp:()=>pt,hitDesignAppTreeBrowser:()=>ut,hitTriageApp:()=>ct,hitTriageAppTreeBrowser:()=>lt,htPackageSettingEditor:()=>wt,peptiHitApp:()=>ht,peptiHitAppTreeBrowser:()=>dt});const e=grok,t=ui,o=DG,a="campaignId",s="campaignId",r="enriched_table.csv",l="campaign.json",u="HitTriageDataSource",d="HitTriageSubmitFunction",c="Selected hits",p="Stage",h="Molecule",m="Helm",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 Campaign",E="New Campaign",I="No Information",F={script:"script",function:"function-package",query:"data-query"},_="HDCampaignsGrouping";var P;!function(e){e.None="None",e.Template="Template",e.Status="Status",e.Author="Author",e.LastModifiedUser="Last Modified User"}(P||(P={}));var O=i(72),V=i.n(O),L=i(825),B=i.n(L),k=i(659),M=i.n(k),U=i(56),R=i.n(U),j=i(540),D=i.n(j),$=i(113),H=i.n($),q=i(558),Y={};Y.styleTagTransform=H(),Y.setAttributes=R(),Y.insert=M().bind(null,"head"),Y.domAPI=B(),Y.insertStyleElement=D(),V()(q.A,Y),q.A&&q.A.locals&&q.A.locals;var G=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};const W=e=>`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`;function J(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 z(i,n,o,a){var s;const r=t.breadcrumbs([n,o]),l=r.onPathClick.subscribe((e=>{1===e.length&&(l.unsubscribe(),K(i),a())})),u=null===(s=e.shell.v.ribbonMenu.root.parentElement)||void 0===s?void 0:s.getElementsByClassName("d4-ribbon-name")[0];return u&&(u.textContent="",u.appendChild(r.root)),{breadcrumbs:r,sub:l}}function K(e){const t=e.getRibbonPanels();(null==t?void 0:t.length)&&(t.pop(),e.setRibbonPanels(t))}function Q(e){return e.reduce(((e,t)=>e||t.reduce(((e,t)=>e||t.classList.contains("hit-design-submit-button")||Array.from(t.children).some((e=>e.classList.contains("hit-design-submit-button")))),!1)),!1)}function Z(e,t,i){return G(this,void 0,void 0,(function*(){if(0===i.rowCount)return;if(!e.col(t))throw new Error("There is no molecule column in dataframe");let n=i.col(w);if(n||(yield i.meta.detectSemanticTypes(),n=i.columns.bySemType(o.SEMTYPE.MOLECULE)),!n)throw new Error("There is no original molecule column in query result dataframe");const a=i.columns.names().filter((e=>e!==w));e.join(i,[t],[n.name],void 0,a,void 0,!0)}))}function X(t,i){return G(this,void 0,void 0,(function*(){const n=(yield st.files.list(`${t}/campaigns`)).filter((e=>-1===i.indexOf(e.name))),o={};for(const i of n)try{const n=JSON.parse(yield st.files.readAsText(`${t}/campaigns/${i.name}/${l}`));if(n.authorUserId&&n.permissions&&!(yield ie(n.authorUserId,n.permissions)))continue;if(n.authorUserId&&!n.authorUserFriendlyName){const t=yield e.dapi.users.find(n.authorUserId);t&&(n.authorUserFriendlyName=t.friendlyName)}o[n.name]=n}catch(e){continue}return o}))}function ee(t,i){return G(this,void 0,void 0,(function*(){var n;const a=o.User.current().id,s=null===(n=o.User.current().group)||void 0===n?void 0:n.id;if(t===a)return!0;for(const t of i){const i=yield e.dapi.groups.find(t);if(i)if(i.personal){const t=yield e.dapi.groups.getUser(i);if((null==t?void 0:t.id)===a)return!0}else if(s&&i.members.length>0&&i.members.some((e=>e.id===s)))return!0}return!1}))}function te(e,t){return G(this,void 0,void 0,(function*(){return ee(e,t.edit)}))}function ie(e,t){return G(this,void 0,void 0,(function*(){return ee(e,Array.from(new Set([...t.view,...t.edit])))}))}const ne=(e,t)=>{var i,n,o,a;switch(e){case P.Template:return null!==(n=null===(i=t.template)||void 0===i?void 0:i.key)&&void 0!==n?n:t.templateName;case P.Status:return t.status;case P.Author:return null!==(o=t.authorUserFriendlyName)&&void 0!==o?o:I;case P.LastModifiedUser:return null!==(a=t.lastModifiedUserName)&&void 0!==a?a:I;default:return""}},oe={String:o.TYPE.STRING,Number:o.TYPE.FLOAT,Boolean:o.TYPE.BOOL,Date:o.TYPE.DATE_TIME,Molecule:o.SEMTYPE.MOLECULE};var ae=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())}))},se=i(233),re=i.n(se),le=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 ue(i,n,o,a,s){return le(this,void 0,void 0,(function*(){var r,l,u,d,c,p,h,m,v,f,w,b,C,A,T,x,S,N,E,I,_;const P=i.computeFunctions,O=[];P.functions.filter((({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).forEach((e=>{var t,i,n,o;O.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==a?void 0:a.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:{}})})),P.scripts.filter((({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).forEach((e=>{var t,i,n,o;O.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==a?void 0:a.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:{}})})),P.queries.filter((e=>e.inputs.length>0&&"list"===e.inputs[0].propertyType)).forEach((e=>{var t,i,n,o;O.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==a?void 0:a.compute)||void 0===t?void 0:t.queries)||void 0===i?void 0:i.find((t=>t.id===e.id)))||void 0===n?void 0:n.args)&&void 0!==o?o:{}})}));let V=!!(null===(l=null===(r=null==a?void 0:a.compute)||void 0===r?void 0:r.descriptors)||void 0===l?void 0:l.enabled)||s;const L=t.div([],{classes:"hit-triage-compute-dialog-host"}),B=[],k=t.tree();try{const q=yield e.chem.descriptorsTree();function Y(e,t){const i=t.group(e,null,!1);return i.enableCheckBox(!1),i}k.root.classList.add("hit-triage-compute-dialog-descriptors-group");const G=Object.keys(q),W=null!==(c=null===(d=null===(u=null==a?void 0:a.compute)||void 0===u?void 0:u.descriptors)||void 0===d?void 0:d.args)&&void 0!==c?c:[];for(const J of G){const z=Y(J,k);for(const K of q[J].descriptors){const Q=z.item(K.name,K);B.push(Q),Q.enableCheckBox(W.includes(K.name))}}}catch(Z){console.error(Z),V=!1}const M="Descriptors",U={[M]:M},R=V?{[M]:k.root}:{},j={},D={[M]:!1};D[M]=!!(null===(h=null===(p=null==a?void 0:a.compute)||void 0===p?void 0:p.descriptors)||void 0===h?void 0:h.enabled)&&(null===(f=null===(v=null===(m=null==a?void 0:a.compute)||void 0===m?void 0:m.descriptors)||void 0===v?void 0:v.args)||void 0===f?void 0:f.length)>0;for(const X of O)try{const ee=X.func,te=ee.prepare(X.args),ie=ee.type===F.function?`${ee.package.name}:${ee.name}`:ee.type===F.script?`${g}:${null!==(w=ee.name)&&void 0!==w?w:""}:${ee.id}`:`${y}:${null!==(b=ee.name)&&void 0!==b?b:""}:${ee.id}`;j[ie]=te;const ne=t.div(),oe=yield te.buildEditor(ne,{condensed:!1});ne.classList.add("oy-scroll"),ne.style.marginLeft="15px",ne.style.removeProperty("max-width"),R[null!==(C=ee.friendlyName)&&void 0!==C?C:ee.name]=ne,U[null!==(A=ee.friendlyName)&&void 0!==A?A:ee.name]=ie,D[ie]=null!==(_=(null===(x=null===(T=null==a?void 0:a.compute)||void 0===T?void 0:T.functions)||void 0===x?void 0:x.some((e=>{var t;return X.func.type===F.function&&e.name===X.func.name&&e.package===(null===(t=X.func.package)||void 0===t?void 0:t.name)})))||(null===(N=null===(S=null==a?void 0:a.compute)||void 0===S?void 0:S.scripts)||void 0===N?void 0:N.some((e=>e.id===ee.id)))||(null===(I=null===(E=null==a?void 0:a.compute)||void 0===E?void 0:E.queries)||void 0===I?void 0:I.some((e=>e.id===ee.id))))&&void 0!==_&&_,ne.children[0].style.display="none",ee.type!==F.query&&(ne.children[1].style.display="none"),oe.forEach((e=>{var t,i;(null===(t=e.property)||void 0===t?void 0:t.name)&&Object.keys(X.args).includes(null===(i=e.property)||void 0===i?void 0:i.name)&&(e.value=X.args[e.property.name]),e.fireChanged()}))}catch(ae){console.error(ae);continue}const $=t.tabControl(R,!0);function H(){const e={descriptors:[],externals:{},scripts:{},queries:{}};e.descriptors=D[M]?B.filter((e=>e.checked)).map((e=>e.value.name)):[];const t=Object.entries(j).filter((([e,t])=>D[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 $.onTabChanged.subscribe((()=>{try{$.currentPane.content.style.removeProperty("max-width")}catch(e){}})),$.header.style.overflow="scroll",$.root.style.width="100%",$.root.style.minWidth="350px",L.appendChild($.root),$.panes.forEach((e=>{const i=t.input.bool("",{value:D[U[e.name]],onValueChanged:t=>{D[U[e.name]]=!!t,t?re()(e.content).find("input").removeAttr("disabled"):re()(e.content).find("input").attr("disabled","true")}});i.setTooltip("Toggle calculation of this function"),e.header.appendChild(i.root),e.header.classList.add("hit-triage-compute-dialog-pane-header")})),s&&t.dialog("Compute").add(L).onOK((()=>H())).onCancel(o).show(),{root:L,okProxy:H}}))}const de=rxjs;class ce{constructor(e,i=[],n={}){this.onItemChanged=new de.Subject,this.onAddingItemChanged=new de.Subject,this.onItemAdded=new de.Subject,this.onItemRemoved=new de.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.properties=e,this.options=Object.assign(Object.assign({},this.options),n),this._root=t.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=i,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,i,n,o,a;if(t.empty(this._root),!this.options.horizontalInputNames)for(const n of this.properties){let o=null!==(e=n.caption)&&void 0!==e?e:n.name;(null===(i=this.options.customLabels)||void 0===i?void 0:i[n.name])&&(o=this.options.customLabels[n.name]);const a=t.divText(o);a.style.fontWeight="bold",this._root.appendChild(a)}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!==(a=null===(o=(n=this.options).newItemFunction)||void 0===o?void 0:o.call(n))&&void 0!==a?a:void 0,!0);for(const t of e)this._root.appendChild(t)}}getItemDiv(e={},i){var n,a;const s=[],r={};let l=null;for(const u of this.properties){void 0===e[u.name]&&(e[u.name]=null);const d=(null===(n=this.options.customInputs)||void 0===n?void 0:n[u.name])?this.options.customInputs[u.name](e):t.input.forProperty(u,e),c=null===(a=this.options.validators)||void 0===a?void 0:a[u.name];c&&d.addValidator(c),s.push(this.options.horizontalInputNames?d.root:this.hideLabel(d.root)),u.propertyType!==o.TYPE.BOOL&&"color"!==u.name.toLowerCase()&&d.input&&(d.input.style.width="100%"),r[u.name]=d,d.onChanged.subscribe((()=>{e[u.name]=d.value,i?this.onAddingItemChanged.next({item:e,fieldName:u.name}):this.onItemChanged.next({item:e,fieldName:u.name})})),d.root.style.alignItems="center",l=d}let u=null;if(i)u=t.icons.add((()=>{const e=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(r).forEach((t=>{e[t]=r[t].value})),this._items.push(e),this.onItemAdded.next(e),this.render()}),this.options.addButtonTooltip);else{if(!this.options.allowRemove)return s;u=t.icons.delete((()=>{this._items.splice(this._items.indexOf(e),1),this.onItemRemoved.next(e),this.render()}),this.options.removeButtonTooltip)}return l&&l.addOptions?l.addOptions(u):null==l||l.root.appendChild(u),u.style.color="#2083d5",s}hideLabel(e){return e.getElementsByTagName("label")[0]&&e.removeChild(e.getElementsByTagName("label")[0]),e}hasErrors(){return this._root.querySelectorAll(".d4-invalid").length>0}}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())}))};function he(){const i=o.Property.fromOptions({name:"layout",caption:"Layout",type:"file"}),n=o.InputBase.forProperty(i);let a=null,s=null,r=null,l=null;return n.onChanged.subscribe((t=>pe(this,void 0,void 0,(function*(){const t=n.value;if(t){try{const i=!!t.fullPath&&(yield e.dapi.files.exists(t.fullPath));r=i?t.fullPath:null}catch(e){r=null}try{const e=yield t.readAsString(),i=o.ViewLayout.fromJson(e);i?(a=i,s=i.viewState,l=null):(a=null,s=null,r=null,l="Invalid layout file")}catch(e){a=null,s=null,r=null,l="Invalid layout file"}n.input.classList[l?"add":"remove"]("d4-invalid")}else a=null,s=null,r=null})))),t.tooltip.bind(n.root,(()=>l||"Select a layout file")),{dataFileInput:n,getLayout:()=>a,getLayoutViewState:()=>s,getLocalFilePath:()=>r}}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())}))};function ve(i,n){return me(this,void 0,void 0,(function*(){var a,s;const r=(yield st.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5))),l=[];for(const e of r){const t=JSON.parse(yield st.files.readAsText(`Hit Triage/templates/${e}.json`));l.push(t.key)}const c=o.Func.find({tags:[d]}),p={};c.forEach((e=>{var t;p[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const h=t.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=he(),v=t.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),f=t.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),w=t.input.string("Name",{value:"",onValueChanged:e=>{""===e||r.includes(e)?(w.root.style.borderBottom="1px solid red",v.style.opacity="100%"):(w.root.style.borderBottom="none",v.style.opacity="0%")}}),C=t.input.string("Key",{value:"",onValueChanged:e=>{""===e||l.includes(e)?(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 ue(i,(e=>{A=e}),(()=>null),{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},!1);x.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(n).length&&o.Func.find({tags:[u]}).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const N=Object.keys(n),E=t.input.choice(b,{value:N[0],items:N}),I=t.input.choice("Ingest using",{value:"Query",items:["Query","File"],onValueChanged:e=>{E.root.style.display="Query"===e?"block":"none"}}),F=fe(),_=t.div([t.h2("Details"),t.div([w,v]),t.div([C,f]),I.root,E.root,m.dataFileInput,F.fieldsDiv,t.h2("Compute"),x.root,t.h2("Submit"),h.root],"ui-form"),P=t.buttonsInput([]),O=null!==(s=null===(a=P.getElementsByClassName("ui-input-editor"))||void 0===a?void 0:a[0])&&void 0!==s?s:P;_.appendChild(P);const V=new Promise((e=>{const i=t.button(S,(()=>e()));O.appendChild(i)})),L=new Promise((i=>{const n=t.bigButton(T,(()=>function(){return me(this,void 0,void 0,(function*(){var t,n,o,a,s,r,l,u;if(x.okProxy(),"100%"===v.style.opacity)return void e.shell.error("Template name is empty or already exists");const d=h.value?p[h.value]:void 0,c=Object.assign(Object.assign({name:w.value,key:C.value,campaignFields:F.getFields(),dataSourceType:null!==(t=I.value)&&void 0!==t?t:"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}}))}},d?{submit:{fName:d.name,package:d.package.name}}:{}),{queryFunctionName:"Query"===I.value&&null!==(u=E.value)&&void 0!==u?u:void 0});var f;f=c,st.files.writeAsText(`Hit Triage/templates/${f.name}.json`,JSON.stringify(f)),e.shell.info("Template created successfully"),i(c)}))}()));O.appendChild(n)}));return{root:_,template:L,cancelPromise:V}}))}function fe(e){const i=[o.Property.fromOptions({name:"Name",type:o.TYPE.STRING}),o.Property.fromOptions({name:"Type",type:o.TYPE.STRING,choices:Object.keys(oe)}),o.Property.fromOptions({name:"Required",type:o.TYPE.BOOL})],n=new ce(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=t.h2("Additional fields");t.tooltip.bind(s,"Additional fields to be filled by user for each campaign");const r=t.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:t.div([r])}}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 extends o.ViewBase{constructor(e){super(),this.deletedCampaigns=[],this.app=e}get template(){return this.app.template}onActivated(){}onReset(){}process(){return ge(this,void 0,void 0,(function*(){}))}deleteCampaign(e,t){return ge(this,void 0,void 0,(function*(){yield st.files.delete(`${e}/campaigns/${t}`)}))}}var we=i(677),be={};be.styleTagTransform=H(),be.setAttributes=R(),be.insert=M().bind(null,"head"),be.domAPI=B(),be.insertStyleElement=D(),V()(we.A,be),we.A&&we.A.locals&&we.A.locals;var Ce;!function(i){let n,o;!function(e){e.vert=function(e){return t.divV(e.map((e=>t.render(e))),{classes:"u2-panel"})},e.horz=function(e){return t.divH(e.map((e=>t.render(e))),{classes:"u2-panel"})}}(n=i.panels||(i.panels={})),i.appHeader=function(e){const i=t.iconImage("",e.iconPath);return re()(i).addClass("ui-app-header-icon").css("margin-right","20px"),n.horz([i,n.vert([t.markdown(e.description),e.learnMoreUrl?t.link("Learn more",e.learnMoreUrl):null])])},function(i){i.runAsync=function(i,n){return o=this,a=void 0,r=function*(){t.setUpdateIndicator(i,!0);try{return yield n()}catch(t){e.log.error(t)}finally{t.setUpdateIndicator(i,!1)}},new((s=void 0)||(s=Promise))((function(e,t){function i(e){try{l(r.next(e))}catch(e){t(e)}}function n(e){try{l(r.throw(e))}catch(e){t(e)}}function l(t){var o;t.done?e(t.value):(o=t.value,o instanceof s?o:new s((function(e){e(o)}))).then(i,n)}l((r=r.apply(o,a||[])).next())}));var o,a,s,r}}(o=i.tools||(i.tools={}))}(Ce||(Ce={}));var Ae=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 Te={view:[o.Group.defaultGroupsIds["All users"]],edit:[o.Group.defaultGroupsIds["All users"]]};class xe{constructor(e){this.permissions=null!=e?e:Te,this.editGroupsInput=t.input.userGroups("Can Edit"),this.editGroupsInput.root.style.marginBottom="16px",this.viewGroupsInput=t.input.userGroups("Can View")}getDialogContent(){return Ae(this,void 0,void 0,(function*(){const i=[],n=[];for(const t of this.permissions.view){const n=yield e.dapi.groups.find(t);n&&i.push(n)}for(const t of this.permissions.edit){const i=yield e.dapi.groups.find(t);i&&n.push(i)}return this.editGroupsInput.value=n,this.viewGroupsInput.value=i,t.divV([this.viewGroupsInput.root,this.editGroupsInput.root])}))}show(e){return Ae(this,void 0,void 0,(function*(){var i;const n=yield this.getDialogContent(),o=t.dialog("Edit Permissions").add(n).onOK((()=>{const t=new Set(this.editGroupsInput.value.map((e=>e.id))),i=new Set(this.viewGroupsInput.value.map((e=>e.id)));this.permissions.edit=Array.from(t),t.forEach((e=>i.add(e))),this.permissions.view=Array.from(i),0===this.permissions.view.length&&(this.permissions.view=Te.view),e(this.permissions)}));(null===(i=n.parentElement)||void 0===i?void 0:i.style)&&(n.parentElement.style.overflow="visible"),o.show()}))}}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())}))};class Ne extends ye{constructor(t){super(t),this.readmePath=st.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 Se(this,void 0,void 0,(function*(){t.setUpdateIndicator(this.root,!0);try{const i=t.h1(N),n=t.h1(E,{style:{marginLeft:"10px"}}),o=Ce.appHeader({iconPath:st.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=t.div(),s=t.div([],{classes:"ui-form"}),r=yield this.getCampaignsTable();yield this.startNewCampaign(a,s,e),re()(this.root).empty(),this.root.appendChild(t.div([t.divV([o,i],{style:{marginLeft:"10px"}}),r,n,s,a])),this.app.resetBaseUrl()}catch(e){throw t.setUpdateIndicator(this.root,!1),e}finally{t.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(e,i,n){return Se(this,void 0,void 0,(function*(){var o;const a=(yield st.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5)));n&&!a.includes(n.name)&&a.push(n.name);const s=()=>Se(this,void 0,void 0,(function*(){const t=r.value,i=n&&n.name===t?n:JSON.parse(yield st.files.readAsText("Hit Triage/templates/"+t+".json")),o=yield this.getNewCampaignAccordeon(i,e);re()(e).empty(),e.className="ui-form",e.appendChild(o)})),r=t.input.choice("Template",{value:null!==(o=null==n?void 0:n.name)&&void 0!==o?o:a[0],items:a,onValueChanged:()=>Se(this,void 0,void 0,(function*(){yield s()}))}),l=t.icons.add((()=>Se(this,void 0,void 0,(function*(){t.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),t.setUpdateIndicator(this.root,!1)}))),C);r.addOptions(l),yield s(),re()(i).empty(),i.appendChild(r.root)}))}checkCampaign(e){return Se(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 st.files.exists(`Hit Triage/campaigns/${n}/${l}`)))return;const o=JSON.parse(yield st.files.readAsText(`Hit Triage/campaigns/${n}/${l}`));if(o){if(o.authorUserId&&o.permissions&&!(yield ie(o.authorUserId,o.permissions)))return void this.app.setBaseUrl();this.app.campaign=o}const s=JSON.parse(yield st.files.readAsText(`Hit Triage/templates/${o.templateName}.json`));return this.app.setTemplate(s,o.filters,n,o.ingest),e&&J(a,e),o}))}getCampaignsTable(){return Se(this,void 0,void 0,(function*(){const e=yield X("Hit Triage",this.deletedCampaigns),i=e=>{var i,n;const a=t.icons.delete((()=>Se(this,void 0,void 0,(function*(){t.dialog("Delete campaign").add(t.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK((()=>Se(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Triage",e.name),this.deletedCampaigns.push(e.name),yield this.init()})))).show()}))),"Delete campaign");return a.style.display="none",te(null!==(i=e.authorUserId)&&void 0!==i?i:o.User.current().id,null!==(n=e.permissions)&&void 0!==n?n:Te).then((e=>{e&&(a.style.display="inline-block")})),a},n=Object.values(e),a=t.table(n,(e=>[t.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.filteredRowCount,e.status,i(e)]),["Name","Created","Total","Selected","Status",""]);return a.style.color="var(--grey-5)",a}))}setCampaign(e){return Se(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(i,n){return Se(this,void 0,void 0,(function*(){t.setUpdateIndicator(n,!0);const{root:a,promise:s,cancelPromise:r}=yield function(i,n){return ae(this,void 0,void 0,(function*(){var a,s;const r=t.divText("",{style:{color:"red"}});let l=null;const d=()=>ae(this,void 0,void 0,(function*(){try{if(l=c.value,!l)return;if(yield l.meta.detectSemanticTypes(),!l.columns.bySemType(o.SEMTYPE.MOLECULE))return void(r.innerText="No molecules column found");r.innerText=""}catch(e){r.innerText="Error parsing file"}})),c=t.input.table("Dataframe",{onValueChanged:d});yield d();const p=t.div([c,r]);0===Object.keys(n).length&&o.Func.find({tags:[u]}).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));let h=null;const m=()=>ae(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=t.div([]),f=t.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=t.div([f,v]);g.style.display="none";const y=t.div([p,g]),w=i.campaignFields.map((e=>e.type===o.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:o.SEMTYPE.MOLECULE}):e)).map((e=>o.Property.fromOptions(Object.assign({name:e.name,type:oe[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),C={},T=w.length?t.input.form(C,w):t.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=t.div([y,...w.length?[T]:[]]),N=t.buttonsInput([]);return x.appendChild(N),{promise:new Promise((o=>{const a=()=>ae(this,void 0,void 0,(function*(){if("File"===i.dataSourceType){if(!l)return void e.shell.error("No file selected");const t=l;t.name=l.name,o({df:t,type:"File",campaignProps:C})}else{const t=n[f.value];if(!t)return void e.shell.error("No function selected");const i={};Object.entries(h.inputs).forEach((([e,t])=>{i[e]=t}));const a=yield t.apply(i);o({df:a,type:"Query",campaignProps:C})}})),s=t.bigButton(A,(()=>a()));N.appendChild(s)})),root:x,cancelPromise:new Promise((e=>{t.button(S,(()=>e()))}))}}))}(i,this.dataSourceFunctionsMap);return t.setUpdateIndicator(n,!1),s.then((e=>Se(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 Se(this,void 0,void 0,(function*(){const t=yield ve(this.app,this.dataSourceFunctionsMap),i=new o.ViewBase,n=e.shell.v;i.name="New Template",i.root.appendChild(t.root),i.parentCall=this.app.parentCall,e.shell.addView(i),i.path=new URL(this.app.baseUrl).pathname+"/new-template",i.parentView=n;const{sub:a}=z(e.shell.v,"Hit Triage",C,(()=>{e.shell.v=n,i.close()}));t.template.then((t=>Se(this,void 0,void 0,(function*(){yield this.init(t),i.close(),K(i),e.shell.v=n,a.unsubscribe()})))),t.cancelPromise.then((()=>{a.unsubscribe(),i.close(),e.shell.v=n}))}))}}class Ee extends ye{constructor(e){super(e),this.name="Submit"}render(){return t.empty(this.root),t.divV([t.h1("Summary"),t.div([t.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){return t=this,i=void 0,a=function*(){var t;const i=null===(t=this.app.template)||void 0===t?void 0:t.submit;if(!i)return;const n=o.Func.find({name:i.fName,package:i.package})[0];if(!n)return void e.shell.error(`Function ${i.fName} not found.`);const a=o.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield n.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((n=void 0)||(n=Promise))((function(e,o){function s(e){try{l(a.next(e))}catch(e){o(e)}}function r(e){try{l(a.throw(e))}catch(e){o(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(s,r)}l((a=a.apply(t,i||[])).next())}));var t,i,n,a}}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 Fe{get appName(){return this._appName}constructor(e,t){this.parentCall=e,this.isJoining=!1,this.hasEditPermission=!1,this._appName=t;const i=o.Func.find({tags:["HitTriageFunction"]}),n=i.filter((e=>e.type===F.function)),a=i.filter((e=>e.type===F.script)),s=i.filter((e=>e.type===F.query));this.resetBaseUrl(),this.computeFunctions={functions:n,scripts:a,queries:s}}setCanEdit(e){return Ie(this,void 0,void 0,(function*(){e.authorUserId&&e.permissions?this.hasEditPermission=yield te(e.authorUserId,e.permissions):this.hasEditPermission=!0}))}resetBaseUrl(){const e=window.location.href,t=new URL(e);this.baseUrl=t.origin+t.pathname}getFilterType(e){const t=this.dataFrame.col(e);return(null==t?void 0:t.semType)===o.SEMTYPE.MOLECULE?o.FILTER_TYPE.SUBSTRUCTURE:(null==t?void 0:t.type)===o.COLUMN_TYPE.BOOL?o.FILTER_TYPE.BOOL_COLUMNS:(null==t?void 0:t.type)===o.COLUMN_TYPE.STRING?o.FILTER_TYPE.CATEGORICAL:o.FILTER_TYPE.HISTOGRAM}download(e,t,i=!1){const n=document.createElement("a"),a=o.DataFrame.fromColumns(e.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv({filteredRowsOnly:i});n.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),n.setAttribute("download",t+".csv"),n.click()}getNewCampaignName(e,t){return Ie(this,void 0,void 0,(function*(){const i=(yield st.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,t,i,n){var a,s,r,l;const u=i;e.col(i).name=n,i=n;const d=null===(s=null===(a=e.col(i))||void 0===a?void 0:a.toList())||void 0===s?void 0:s.filter((e=>!!e)).map((e=>o.chem.convert(e,o.chem.Notation.Unknown,o.chem.Notation.Smiles))),c=null===(l=null===(r=t.col(n))||void 0===r?void 0:r.toList())||void 0===l?void 0:l.filter((e=>!!e)).map((e=>o.chem.convert(e,o.chem.Notation.Unknown,o.chem.Notation.Smiles)));if(!d||!c)throw new Error("Molecule column not found");const p=new Map;c.forEach(((e,t)=>p.set(e,t))),this.isJoining=!0;try{const i=[];for(const n of e.columns)if(!t.columns.contains(n.name)){const e=t.columns.addNew(n.name,n.type);n.semType&&(e.semType=n.semType),i.push(n.name)}for(let n=0;n<d.length;n++)if(p.has(d[n])){if(i.length>0){const o=p.get(d[n]);for(const a of i){const i=e.col(a).get(n);t.col(a).set(o,i,!1)}}}else{t.rows.addNew(null,!0);for(const i of e.columns){const e=i.get(n);t.col(i.name).set(t.rowCount-1,e,!1)}}}finally{setTimeout((()=>{this.isJoining=!1}),500),e.col(i).name=u}return t}}Fe.molFileExtReaders=["sdf","mol","smi","mol2"].map((e=>{const t=o.Func.find({tags:["file-handler"]}).find((t=>{var i;return(null===(i=null==t?void 0:t.options)||void 0===i?void 0:i.ext)&&"string"==typeof t.options.ext&&t.options.ext.split(",").includes(e)}));return{ext:e,handlerFunc:t}})).filter((e=>e.handlerFunc));var _e=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))},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())}))};function Oe(t,i,n){return Pe(this,arguments,void 0,(function*(t,i,n,a=[],s=[]){const r=o.TaskBarProgressIndicator.create("Calculating ..."),l=t.map((e=>st.convertToSmiles(e))),u=o.Column.fromStrings(h,l),d=o.DataFrame.fromColumns([u]);d.name="HD cell values",yield d.meta.detectSemanticTypes();try{i.length&&(yield e.chem.descriptors(d,u.name,i))}catch(e){console.error("Descriptors calculation error",e)}for(const e of n)try{const t=e.args,i=o.Func.find({package:e.package,name:e.name});if(!i.length||!i[0]){console.warn(`Function ${e.name} from package ${e.package} is not found`);continue}const n=i[0],a=n.inputs[0].name,s=n.inputs[1].name;yield n.apply(Object.assign(Object.assign({},t),{[a]:d,[s]:u.name}))}catch(e){console.error(e);continue}for(const e of a){const t=e.args;try{const i=o.Func.find({name:e.name}).filter((t=>t.type===F.script&&t.id===e.id))[0];if(i){const e=i.inputs[0].name,n=i.inputs[1].name,o=yield i.apply(Object.assign(Object.assign({},t),{[e]:d,[n]:u.name}));if(o&&o.rowCount===d.rowCount&&"python"===i.language)for(const e of o.columns)e.name=d.columns.getUnusedName(e.name),d.columns.add(e)}}catch(e){console.error(e)}}for(const e of s){const t=e.args;try{const i=o.Func.find({name:e.name}).filter((t=>t.type===F.query&&t.id===e.id))[0];if(i){const e=i.inputs[0].name,n=[l],o=yield i.apply(Object.assign(Object.assign({},t),{[e]:n}));if(!o||0===o.rowCount)continue;yield Z(d,h,o)}}catch(e){console.error(e)}}r.close();const c=d.col(h);for(let e=0;e<c.length;e++)c.set(e,t[e],!1);return d}))}function Ve(e){let t=0;if(e.length>1)for(const i of e.toList()){if(!i||!i.startsWith(f[0])||i.length!==f.length)continue;const e=parseInt(i.substring(1));isNaN(e)||(t=Math.max(e,t))}return`V${"".concat(...new Array(f.length-1-(t+1).toString().length).fill("0"))}${t+1}`}function Le(t,i,n){return Pe(this,void 0,void 0,(function*(){var a,s;const r=o.TaskBarProgressIndicator.create("Calculating ..."),l=i.col(n);if(!l)throw new Error("There is no molecule column in dataframe");const u=`~${n}.canonicalSmiles`,d=i.columns.getOrCreate(u,o.TYPE.STRING);d.semType=o.SEMTYPE.MOLECULE;const c=l.toList();for(let e=0;e<c.length;e++){if(l.isNone(e))continue;const t=c[e];if(!t)continue;const i=st.convertToSmiles(t);d.set(e,i,!1)}try{t.descriptors&&t.descriptors.length>0&&(yield e.chem.descriptors(i,u,t.descriptors))}catch(e){console.error("Descriptors calculation error",e)}for(const e of Object.keys(t.externals))try{const n=t.externals[e],a=o.Func.find({package:e.split(":")[0],name:e.split(":")[1]})[0],s=a.inputs[0].name,r=a.inputs[1].name;n&&(yield a.apply(Object.assign(Object.assign({},n),{[s]:i,[r]:u})))}catch(e){console.error(e)}for(const e of Object.keys(null!==(a=t.scripts)&&void 0!==a?a:{})){const n=t.scripts[e];if(n){const t=e.split(":"),a=t[2];if(!a)continue;try{const e=t[1],s=o.Func.find({name:e}).filter((e=>e.type===F.script&&e.id===a))[0];if(!s)continue;const r=s.inputs[0].name,l=s.inputs[1].name,d=yield s.apply(Object.assign(Object.assign({},n),{[r]:i,[l]:u}));if(d&&d.rowCount===i.rowCount&&"python"===s.language)for(const e of d.columns)e.name=i.columns.getUnusedName(e.name),i.columns.add(e)}catch(e){console.error(e)}}}for(const e of Object.keys(null!==(s=t.queries)&&void 0!==s?s:{})){const n=t.queries[e];if(n){const t=e.split(":"),a=t[2];if(!a)continue;try{const e=t[1],s=o.Func.find({name:e}).filter((e=>e.type===F.query&&e.id===a))[0];if(!s)continue;const r=s.inputs[0].name,l=yield s.apply(Object.assign(Object.assign({},n),{[r]:d.toList()}));l&&(yield Z(i,u,l))}catch(e){console.error(e)}}}r.close()}))}var 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())}))};class ke extends Fe{get infoView(){return this._infoView}constructor(t){super(t,"Hit Triage"),this._filterViewName="Hit triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=new Ne(this),this.multiView=new o.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof ye&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=t,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(),J(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(t,i,n,s){return Be(this,void 0,void 0,(function*(){var r,l,u,d,c,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,n?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)):(n=yield this.getNewCampaignName("Hit Triage/campaigns",t.key),J(a,n)),!this.dataFrame)return void console.error("Dataframe is empty.");if((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&&i.semType!==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{i.convertTo(t)}catch(e){console.error(e)}})),yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(p=null===(c=this.dataFrame.columns.bySemType(o.SEMTYPE.MOLECULE))||void 0===c?void 0:c.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=n,this.template=(null===(f=this.campaign)||void 0===f?void 0:f.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:t.dataSourceType,queryFunctionName:t.queryFunctionName}):t,this._campaignFilters=i,!i){const e={},i={},n={};t.compute.functions.forEach((t=>{const i=`${t.package}:${t.name}`;e[i]=t.args})),null===(w=t.compute.scripts)||void 0===w||w.forEach((e=>{const t=`${g}:${e.name}:${e.id}`;i[t]=e.args})),null===(b=t.compute.queries)||void 0===b||b.forEach((e=>{const t=`${y}:${e.name}:${e.id}`;n[t]=e.args})),yield Le({descriptors:t.compute.descriptors.enabled?t.compute.descriptors.args:[],externals:e,scripts:i,queries:n},this.dataFrame,this._molColName)}this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0;const x=e.shell.v,S=e.shell.addView(this.pickView);this.currentPickViewId=S.name,this._submitView=new Ee(this),this.setBaseUrl(),J(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}=z(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,t,i;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null===(i=null===(t=this.dataFrame)||void 0===t?void 0:t.columns.bySemType(o.SEMTYPE.MOLECULE))||void 0===i?void 0:i.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(c)||this.dataFrame.columns.addNewBool(c).init(!1);const i=o.TableView.create(this.dataFrame,!1),n=i.getRibbonPanels(),a=t.iconFA("wrench",(()=>Be(this,void 0,void 0,(function*(){ue(this,(e=>Be(this,void 0,void 0,(function*(){var t,i,n,o,a,s,r;const l=this.template.compute.descriptors.args,u=this.template.compute.functions,d=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],c=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(!u.some((t=>t.name===e.name&&t.package===e.package)))return!0;const t=u.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(!d.some((t=>t.id===e.id)))return!0;const t=d.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),w=h.queries.filter((e=>{if(!c.some((t=>t.id===e.id)))return!0;const t=c.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 Le({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=t.bigButton("Submit",(()=>{var e;const i=null===(e=this._submitView)||void 0===e?void 0:e.render();if(i){const e=t.dialog("Submit");e.add(i),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()}})),r=t.iconFA("share",(()=>Be(this,void 0,void 0,(function*(){var e;yield new xe(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show((e=>{this.campaign.permissions=e,this.saveCampaign(void 0,!0)}))}))),"Edit permissions");s.classList.add("hit-design-submit-button");const l=Q(n);return n.push([a,...this.hasEditPermission?[r]:[],...l?[]:[s]]),i.setRibbonPanels(n),i.name=this._filterViewName,setTimeout((()=>Be(this,void 0,void 0,(function*(){var t,n,a;i._onAdded(),yield new Promise((e=>setTimeout(e,1e3)));const s=i.filters(this._campaignFilters?{filters:this._campaignFilters}:void 0),r=null!==(n=null===(t=this._campaign)||void 0===t?void 0:t.layout)&&void 0!==n?n:null===(a=this.template)||void 0===a?void 0:a.layoutViewState;if(r)try{const e=o.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,i,n,o,a,s,r;const l=null!==(i=null===(e=this.campaign)||void 0===e?void 0:e.campaignFields)&&void 0!==i?i:this.campaignProps;return Object.assign(Object.assign({Template:null!==(o=null===(n=this.template)||void 0===n?void 0:n.name)&&void 0!==o?o:"Molecules","File path":t.divH([t.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":t.divH([t.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 Be(this,arguments,void 0,(function*(i,n=!0){var a,s,u,d,c,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(e){return _e(this,void 0,void 0,(function*(){return new Promise((i=>_e(this,void 0,void 0,(function*(){const n=t.input.string("Campaign name",{value:""});t.dialog("Save Campaign").add(t.div(n.root)).onOK((function(){n.value&&""!==n.value?i(n.value):i(e)})).show()}))))}))}(g),T={};b.columns.toList().forEach((e=>T[e.name]=e.semType));const x={};b.columns.toList().forEach((e=>x[e.name]=e.type));const S=null!==(s=null===(a=this.campaign)||void 0===a?void 0:a.authorUserId)&&void 0!==s?s:e.shell.user.id,N=null!==(d=null===(u=this.campaign)||void 0===u?void 0:u.permissions)&&void 0!==d?d:Te,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===(c=this.campaign)||void 0===c?void 0:c.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:W(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:S,permissions:N};if(this.campaign=E,!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),E;const I=o.DataFrame.fromColumns(b.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield st.files.writeAsText(`Hit Triage/campaigns/${g}/${r}`,I);const F=this._pickView.saveLayout();return F?E.layout=F.viewState:e.shell.warning("Layout cound not be saved"),yield st.files.writeAsText(`Hit Triage/campaigns/${g}/${l}`,JSON.stringify(E)),n&&e.shell.info("Campaign saved successfully."),E}))}}function Me(i,n=!1){var a,s;const r=o.DataFrame.create(1);if(n){const e=r.columns.addNew(m,o.TYPE.STRING);e.semType=o.SEMTYPE.MACROMOLECULE,e.meta.units="helm",e.setTag("units","helm"),e.setTag("cell.renderer","helm"),e.setTag(".alphabetIsMultichar","true")}const l=r.columns.addNew(h,o.TYPE.STRING);l.semType=o.SEMTYPE.MOLECULE,l.meta.units=o.UNITS.Molecule.SMILES,l.set(0,null),(null===(a=null==i?void 0:i.stages)||void 0===a?void 0:a.length)>0&&r.columns.addNew(p,o.TYPE.STRING).set(0,i.stages[0]);const u=r.columns.addNew(v,o.TYPE.STRING);u.set(0,Ve(u));const d=i.campaignFields.map((e=>e.type===o.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:o.SEMTYPE.MOLECULE}):e)).map((e=>o.Property.fromOptions(Object.assign({name:e.name,type:oe[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),c={},f=t.input.string("Campaing Name",{tooltipText:"New campaign name. If empty, campaign code will be used."}),g=t.input.form(c,d);g.prepend(f.root),g.classList.remove("ui-form");const y=t.div([...(null===(s=i.campaignFields)||void 0===s||s.length,[]),g]),w=t.buttonsInput([]);return y.appendChild(w),{promise:new Promise((n=>{const o=t.bigButton(A,(()=>{for(const t of i.campaignFields)if(t.required&&(!c[t.name]||""===c[t.name]))return void e.shell.error(`Field '${t.name}' is required`);n({df:r,campaignProps:c,name:f.value})}));w.appendChild(o)})),root:y,cancelPromise:new Promise((e=>{t.button(S,(()=>e()))}))}}var Ue=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function Re(i,n){return Ue(this,void 0,void 0,(function*(){var a,s,r,l,u,c,p,h,m,v,f;const w=yield st.files.list(`${i.appName}/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 st.files.readAsText(e));x.push(t.key)}catch(e){console.error(e)}const N=o.Func.find({tags:[d]}),E={};N.forEach((e=>{var t;E[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const I=t.input.choice("Submit function",{value:null,items:[null,...Object.keys(E)]});I.nullable=!0,I.value=null!==(s=null===(a=null==n?void 0:n.submit)||void 0===a?void 0:a.fName)&&void 0!==s?s:null,I.setTooltip("Select function to be called upon submitting");const F=t.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),_=t.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),P=he();function O(){var e,t,i,n;if(""===V.value||A.includes(null!==(t=null===(e=V.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=V.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=V.input.offsetWidth)&&void 0!==n?n:0;F.style.marginLeft=`${e}px`,F.style.width=`${t}px`,F.style.opacity="100%",F.style.borderTop="1px solid red",b=!0}else F.style.borderTop="none",F.style.opacity="0%",b=!1}const V=t.input.string("Name",{value:null!==(r=null==n?void 0:n.name)&&void 0!==r?r:"",onValueChanged:O});function L(){var e,t,i,n;if(""===B.value||x.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.borderTop="1px solid red",_.style.opacity="100%",C=!0}else _.style.opacity="0%",_.style.borderTop="none",C=!1}const B=t.input.string("Key",{value:null!==(l=null==n?void 0:n.key)&&void 0!==l?l:"",onValueChanged:L});B.setTooltip("Template key used for campaign prefix"),V.setTooltip("Template name"),V.root.style.borderBottom="none",B.root.style.borderBottom="none",F.style.opacity="0%",_.style.opacity="0%";let k=null;const M={compute:{descriptors:{enabled:!0,args:null!==(p=null===(c=null===(u=null==n?void 0:n.compute)||void 0===u?void 0:u.descriptors)||void 0===c?void 0:c.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:[]}},U=yield ue(i,(e=>{k=e}),(()=>null),M,!1);U.root.classList.add("hit-triage-new-template-functions-input");const R=fe(null==n?void 0:n.campaignFields),j=je(null==n?void 0:n.stages),D=t.divV([t.divV([V,F]),t.divV([B,_]),P.dataFileInput,R.fieldsDiv]),$=t.h2("Stages");t.tooltip.bind($,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const H=t.h2("Compute");t.tooltip.bind(H,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const q=t.div([t.h2("Details"),D,$,j.fieldsDiv,H,U.root,t.h2("Submit"),I.root],"ui-form"),Y=t.buttonsInput([]);q.appendChild(Y);const G=null!==(f=null===(v=Y.getElementsByClassName("ui-input-editor"))||void 0===v?void 0:v[0])&&void 0!==f?f:Y,W=new Promise((e=>{const i=t.button(S,(()=>e()));G.appendChild(i)})),J=new Promise((n=>{const o=t.bigButton(T,(()=>function(){return Ue(this,void 0,void 0,(function*(){var t,o,a,s,r,l,u;if(O(),L(),U.okProxy(),b||!V.value||""===V.value)return void e.shell.error("Template name is empty or already exists");if(C||!B.value||""===B.value)return void e.shell.error("Template key is empty or already exists");const d=I.value?E[I.value]:void 0,c=Object.assign({name:V.value,key:B.value,campaignFields:R.getFields(),stages:j.getFields(),layoutViewState:null!==(t=P.getLayoutViewState())&&void 0!==t?t:void 0,localLayoutPath:null!==(o=P.getLocalFilePath())&&void 0!==o?o:void 0,compute:{descriptors:{enabled:!!(null===(a=null==k?void 0:k.descriptors)||void 0===a?void 0:a.length),args:null!==(s=null==k?void 0:k.descriptors)&&void 0!==s?s:[]},functions:Object.entries(null!==(r=null==k?void 0:k.externals)&&void 0!==r?r:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(l=null==k?void 0:k.scripts)&&void 0!==l?l:{}).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!==(u=null==k?void 0:k.queries)&&void 0!==u?u:{}).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}}))}},d?{submit:{fName:d.name,package:d.package.name}}:{});yield function(e,t){return Ue(this,void 0,void 0,(function*(){yield st.files.writeAsText(`${t}/templates/${e.name}.json`,JSON.stringify(e))}))}(c,i.appName),e.shell.info("Template created successfully"),n(c)}))}()));G.appendChild(o)}));return{root:q,template:J,cancelPromise:W}}))}function je(e){const t=[o.Property.fromOptions({name:"Name",type:o.TYPE.STRING})],i=new ce(t,e?e.map((e=>({Name:e}))):void 0,{horizontalInputNames:!0});let n={};return i.onItemAdded.subscribe((e=>{n={}})),i.onAddingItemChanged.subscribe((e=>{e&&(n=e.item)})),{getFields:function(){const e=i.items.filter((e=>e.Name)).map((e=>e.Name));return n.Name&&""!==n.Name&&e.push(n.Name),e},fieldsDiv:i.root,itemsGrid:i}}var De=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 $e extends ye{constructor(t){super(t),this.currentSorting="None",this.name="Hit Design",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(st.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(st.webRoot+"README_HD.md")}getAppHeader(){return Ce.appHeader({iconPath:st.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"})}init(i){return De(this,void 0,void 0,(function*(){t.setUpdateIndicator(this.root,!0);try{const n=t.h1(N),a=t.h1(E,{style:{marginLeft:"10px"}}),s=this.getAppHeader(),r=t.div(),l=t.divH([]),u=t.div([l,r],"ui-form"),d=yield this.getCampaignsTable(),c=t.div([d],{style:{position:"relative"}}),p=t.iconFA("sort",(()=>{const i=o.Menu.popup();Object.values(P).forEach((n=>{i.item(n,(()=>De(this,void 0,void 0,(function*(){(function(e,t){localStorage.setItem(e,t)})(_,n),t.setUpdateIndicator(c,!0);try{const e=yield this.getCampaignsTable();t.setUpdateIndicator(c,!1),t.empty(c),c.appendChild(e)}catch(t){e.shell.error("Failed to update campaigns table"),console.error(t)}finally{t.setUpdateIndicator(c,!1)}})))),i.show({element:h,x:100,y:h.offsetTop+30})}))}));p.style.marginBottom="12px",p.style.marginLeft="5px",p.style.fontSize="15px",t.tooltip.bind(p,(()=>`Group Campaigns. Current: ${this.currentSorting}`));const h=t.divH([n,p],{style:{alignItems:"center"}});re()(this.root).empty(),this.root.appendChild(t.div([t.divV([s,h],{style:{marginLeft:"10px"}}),c,a,u])),yield this.startNewCampaign(r,l,i),this.app.resetBaseUrl()}finally{t.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(i,n,o){return De(this,void 0,void 0,(function*(){var a;const s=(yield st.files.list(`${this.app.appName}/templates`)).filter((e=>e.name.endsWith(".json"))).map((e=>e.name.slice(0,-5)));o&&!s.includes(o.name)&&s.push(o.name);let r=null,l=!0;const u=()=>De(this,void 0,void 0,(function*(){if(!l)return;const e=d.value,t=o&&o.name===e?o:JSON.parse(yield st.files.readAsText(`${this.app.appName}/templates/${e}.json`));r=t;const n=yield this.getNewCampaignAccordeon(t);re()(i).empty(),i.appendChild(n)})),d=t.input.choice("Template",{value:null!==(a=null==o?void 0:o.name)&&void 0!==a?a:s[0],items:s,onValueChanged:()=>De(this,void 0,void 0,(function*(){yield u()}))});d.root.style.width="100%";const c=t.icons.add((()=>{this.createNewTemplate()}),C),p=t.icons.copy((()=>{r&&this.createNewTemplate(r)}),"Clone template"),h=t.icons.delete((()=>{!d.value||d.items.length<2||t.dialog("Delete template").add(t.divText(`Are you sure you want to delete template ${d.value}?`)).onOK((()=>De(this,void 0,void 0,(function*(){try{const t=d.value;yield st.files.delete(`${this.app.appName}/templates/${t}.json`),l=!1,d.items=d.items.filter((e=>e!==t)),d.value=d.items[0],l=!0,yield u(),e.shell.info("Template "+t+" was deleted successfully")}catch(t){l=!0,e.shell.error("Failed to delete template "+d.value),console.error(t)}})))).show()}),"Delete template");c.style.color="#2083d5",d.addOptions(h),d.addOptions(p),d.addOptions(c),yield u(),re()(n).empty(),n.appendChild(d.root)}))}checkCampaign(e){return De(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 st.files.exists(`${this.app.appName}/campaigns/${o}/${l}`)))return;const a=JSON.parse(yield st.files.readAsText(`${this.app.appName}/campaigns/${o}/${l}`));if(a){if(a.authorUserId&&a.permissions&&!(yield ie(a.authorUserId,a.permissions)))return void this.app.setBaseUrl();this.app.campaign=a}const r=null!==(t=a.template)&&void 0!==t?t:JSON.parse(yield st.files.readAsText(`${this.app.appName}/templates/${a.templateName}.json`));return yield this.app.setTemplate(r,o),e&&J(s,e),a.template=r,a}))}getCampaignsTable(){return De(this,void 0,void 0,(function*(){const i=yield X(this.app.appName,this.deletedCampaigns),n=null!==(r=_,s=localStorage.getItem(r))&&void 0!==s?s:P.None,a=function(e,t){if(t===P.None)return{"":e};const i={};for(const n of e){const e=ne(t,n);i[e]||(i[e]=[]),i[e].push(n)}return i}(Object.values(i),n);var s,r;this.currentSorting=n,this.app.existingStatuses=Array.from(new Set(Object.values(i).map((e=>e.status)).filter((e=>!!e))));const u=i=>{var n,a;const s=t.icons.delete((()=>De(this,void 0,void 0,(function*(){t.dialog("Delete campaign").add(t.divText(`Are you sure you want to delete campaign ${i.name}?`)).onOK((()=>De(this,void 0,void 0,(function*(){yield this.deleteCampaign(this.app.appName,i.name),this.deletedCampaigns.push(i.name),yield this.init()})))).show()}))),"Delete campaign"),r=t.iconFA("share",(()=>De(this,void 0,void 0,(function*(){yield new xe(i.permissions).show((t=>De(this,void 0,void 0,(function*(){var n;try{i.permissions=t,null!==(n=i.authorUserId)&&void 0!==n||(i.authorUserId=e.shell.user.id),yield st.files.writeAsText(`${this.app.appName}/campaigns/${i.name}/${l}`,JSON.stringify(i)),e.shell.info("Permissions updated for campaign "+i.name)}catch(t){e.shell.error("Failed to update permissions for campaign "+i.name),console.error(t)}}))))}))),"Manage campaign permissions");return s.style.display="none",r.style.display="none",te(null!==(n=i.authorUserId)&&void 0!==n?n:o.User.current().id,null!==(a=i.permissions)&&void 0!==a?a:Te).then((e=>{e&&(s.style.display="inline-block",r.style.display="inline-block")})),[r,s]},d=t.table(Object.values(a).flat(),(e=>{var i,n,o;return[t.link(null!==(i=e.friendlyName)&&void 0!==i?i:e.name,(()=>this.setCampaign(e.name)),"Continue Campaign",""),e.name,e.createDate,null!==(n=e.authorUserFriendlyName)&&void 0!==n?n:"",null!==(o=e.lastModifiedUserName)&&void 0!==o?o:"",e.rowCount,e.status,...u(e)]}),["Name","Code","Created","Author","Last Modified by","Molecules","Status","",""]);return d.style.color="var(--grey-5)",d.style.marginLeft="24px",function(e,i,n=9){e.classList.add("hit-design-groupped-campaigns-table");const o=Object.keys(i);if(o.length<2)return e;const a=e.getElementsByTagName("tbody")[0],s=Array.from(e.getElementsByTagName("tr")).filter((e=>!e.classList.contains("header")));let r=0;const l=(e,t,i)=>{var n;for(let o=t;o<i;o++)(null===(n=s[o])||void 0===n?void 0:n.style)&&(s[o].style.display=e?"table-row":"none")};for(const e of o){const o=s[r];if(!o)break;const u=i[e].length,d=r,c=r+u,p=t.accordion(`Hit-Design-campaigns-group-${e}`).addPane(e,(()=>t.div()),void 0,void 0,!1);p.root.style.marginLeft="-24px",p.root.onclick=()=>{l(p.expanded,d,c)},l(p.expanded,d,c);const h=a.insertRow(0),m=h.insertCell(0);m.appendChild(p.root),m.colSpan=n,a.insertBefore(h,o),r+=u}}(d,a),d}))}setCampaign(e){return De(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(e){return De(this,void 0,void 0,(function*(){const{root:t,promise:i,cancelPromise:n}=Me(e);return i.then((t=>De(this,void 0,void 0,(function*(){var i,n;this.app.clearCampaign(),this.app.dataFrame=t.df,yield this.app.setTemplate(e),this.app.campaignProps=t.campaignProps;const o=(null===(i=t.name)||void 0===i?void 0:i.trim())?null===(n=t.name)||void 0===n?void 0:n.trim():void 0;yield this.app.saveCampaign(!1,!0,{friendlyName:o}),e.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=e.layoutViewState)})))),n.then((()=>{this.init()})),t}))}createNewTemplate(i){return De(this,void 0,void 0,(function*(){t.setUpdateIndicator(this.root,!0);try{const t=yield Re(this.app,i),n=new o.ViewBase,a=e.shell.v;n.name="New Template",n.root.appendChild(t.root),n.parentCall=this.app.parentCall,e.shell.addView(n),n.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:s}=z(n,this.app.appName,C,(()=>De(this,void 0,void 0,(function*(){e.shell.v=a,n.close()}))));t.template.then((t=>De(this,void 0,void 0,(function*(){yield this.init(t),n.close(),K(n),e.shell.v=a,s.unsubscribe()})))),t.cancelPromise.then((()=>De(this,void 0,void 0,(function*(){s.unsubscribe(),n.close(),e.shell.v=a}))))}finally{t.setUpdateIndicator(this.root,!1)}}))}}class He extends ye{constructor(e){var i;super(e),this.name="Submit",this.statusInput=t.input.string("Status",{value:null===(i=this.app.campaign)||void 0===i?void 0:i.status,nullable:!1}),this.statusSuggestionsMenu=o.Menu.popup(),this.statusInput.root.style.marginLeft="12px",this.content=t.div(),this.statusInput.onChanged.subscribe((()=>{var e,t,i,n;this.statusSuggestionsMenu.clear();const o=(null!==(e=this.statusInput.value)&&void 0!==e?e:"").toLowerCase(),a=this.app.existingStatuses.filter((e=>{var t;return(null===(t=null==e?void 0:e.toLowerCase())||void 0===t?void 0:t.includes(o))&&(null==e?void 0:e.toLowerCase())!==o})).filter(((e,t)=>t<5));if(a.length){if(a.forEach((e=>{this.statusSuggestionsMenu.item(e,(()=>{this.statusInput.value=e,this.statusSuggestionsMenu.root.remove(),this.statusInput.root.focus()}))})),null===(t=this.content.parentElement)||void 0===t?void 0:t.parentElement){const e=this.statusInput.root.offsetLeft+(null!==(n=null===(i=this.statusInput.input)||void 0===i?void 0:i.offsetLeft)&&void 0!==n?n:0),t=this.statusInput.root.offsetTop+this.statusInput.root.offsetHeight+this.content.parentElement.offsetTop;this.statusSuggestionsMenu.show({element:this.content.parentElement.parentElement,x:e,y:t})}}else this.statusSuggestionsMenu.root.remove()}))}getStatus(){var e,t,i;return null!==(i=null!==(e=this.statusInput.value)&&void 0!==e?e:null===(t=this.app.campaign)||void 0===t?void 0:t.status)&&void 0!==i?i:"No Status"}render(){var e,i;return this.statusInput.value=null!==(i=null===(e=this.app.campaign)||void 0===e?void 0:e.status)&&void 0!==i?i:"",t.empty(this.content),this.content=t.divV([t.h1("Summary"),t.div([t.tableFromMap(this.app.getSummary())]),this.statusInput.root]),this.content}onActivated(){this.render()}submit(){return t=this,i=void 0,a=function*(){var t;const i=null===(t=this.app.template)||void 0===t?void 0:t.submit;if(!i)return;const n=o.Func.find({name:i.fName,package:i.package})[0];if(!n)return void e.shell.error(`Function ${i.fName} not found.`);const a=o.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield n.apply({df:a,molecules:this.app.molColName}),this.app.campaign.status=this.getStatus(),this.app.saveCampaign(),e.shell.info("Submitted successfully.")},new((n=void 0)||(n=Promise))((function(e,o){function s(e){try{l(a.next(e))}catch(e){o(e)}}function r(e){try{l(a.throw(e))}catch(e){o(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(s,r)}l((a=a.apply(t,i||[])).next())}));var t,i,n,a}}var qe=i(542),Ye={};Ye.styleTagTransform=H(),Ye.setAttributes=R(),Ye.insert=M().bind(null,"head"),Ye.domAPI=B(),Ye.insertStyleElement=D(),V()(qe.A,Ye),qe.A&&qe.A.locals&&qe.A.locals;function Ge(i,n){var a,s,r,l,u,d,c,h;const m=null===(a=i.campaign)||void 0===a?void 0:a.tilesViewerFormSketch;let v=null;if(m&&m.length>0)try{v=JSON.parse(m)}catch(e){console.error("Failed to parse sketch state string",e)}v&&v.elementStates&&(null!==(s=v.elementStates.length)&&void 0!==s?s:0)>0&&(v.elementStates=v.elementStates.filter((e=>{var t;return(null===(t=null==e?void 0:e.viewerSettings)||void 0===t?void 0:t.column)&&i.dataFrame.col(e.viewerSettings.column)})),v.elementStates.forEach((e=>{var t;(null===(t=null==e?void 0:e.viewerSettings)||void 0===t?void 0:t.table)&&(e.viewerSettings.table=i.dataFrame.name)})));const f=Object.assign({lanesColumnName:p,lanes:i.stages},(null!==(l=null===(r=null==v?void 0:v.elementStates)||void 0===r?void 0:r.length)&&void 0!==l?l:0)>0?{sketchState:v}:{}),g=n();if(!g)return void e.shell.error("Failed to create tiles viewer. table view is not available.");let y=null;const w=t.dialog("Progress Tracker");try{y=g.addViewer(o.VIEWER.TILE_VIEWER,f);const e=y.getOptions();e.look.sketchState=(null!==(d=null===(u=null==v?void 0:v.elementStates)||void 0===u?void 0:u.length)&&void 0!==d?d:0)>0?v:null,y.setOptions(e),y.copyViewersLook(y)}catch(t){e.shell.error("Failed to create tiles viewer with preset layout.\n Falling back to default layout."),console.error("Failed to create tiles viewer",t),y&&(y.close(),y.detach()),y=g.addViewer(o.VIEWER.TILE_VIEWER,{lanesColumnName:p,lanes:i.stages})}if(!y)return void e.shell.error("Failed to create tiles viewer. check the console for more details.");let b=null;const C=()=>{try{y.detach(),y.close()}catch(e){}};w.add(y.root),w.addButton("Modify Stages",(()=>{null==b||b.close();const o=je(i.stages);b=t.dialog("Modify Stages").add(o.fieldsDiv).onOK((()=>{return a=this,s=void 0,l=function*(){C(),t.setUpdateIndicator(w.root,!0);try{yield i.setStages(o.getFields()),t.setUpdateIndicator(w.root,!1),w.close(),yield new Promise((e=>setTimeout((()=>{e(),Ge(i,n)}),100)))}catch(t){e.shell.error("Failed to update stages. check the console for more details."),console.error("Failed to update stages",t)}finally{(null==w?void 0:w.root)&&document.contains(w.root)&&w.close()}},new((r=void 0)||(r=Promise))((function(e,t){function i(e){try{o(l.next(e))}catch(e){t(e)}}function n(e){try{o(l.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof r?o:new r((function(e){e(o)}))).then(i,n)}o((l=l.apply(a,s||[])).next())}));var a,s,r,l})).show(),b.root.classList.add("hit-design-stage-editing-dialog")}),0);const A=e.events.onCurrentViewChanged.subscribe((()=>{e.shell.v===g?w.root.style.display="flex":w.root.style.setProperty("display","none","important")})),T=w.onClose.subscribe((()=>{T.unsubscribe(),A.unsubscribe(),null==b||b.close();try{const e=y.props.sketchState;if(e&&"object"==typeof e){const t=JSON.stringify(e);i.campaign&&(i.campaign.tilesViewerFormSketch=t)}}catch(t){e.shell.error("Failed to save sketch state. check the console for more details."),console.error("Failed to save sketch state",t)}C()}));w.showModal(!0),null===(c=w.getButton("CANCEL"))||void 0===c||c.remove(),w.onOK((()=>{})),null===(h=document.querySelector(".d4-modal-background"))||void 0===h||h.remove()}const We=rxjs.operators;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 ze="DefaultUserGroupsSharing";function Ke(t){return Je(this,void 0,void 0,(function*(){if(!t)return[yield e.dapi.groups.find(o.Group.defaultGroupsIds["All users"])].filter(Boolean);try{const i=JSON.parse(t);return(yield Promise.all(i.map((t=>e.dapi.groups.find(t))))).filter(Boolean)}catch(t){return console.error(t),[yield e.dapi.groups.find(o.Group.defaultGroupsIds["All users"])].filter(Boolean)}}))}var Qe=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 Ze extends Fe{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(e,t="Hit Design",i=e=>new $e(e)){super(e,t),this._designViewName="Design",this._filePath=`System.AppData/HitTriage/${this.appName}/campaigns`,this._molColName=h,this.campaignProps={},this.existingStatuses=[],this._gridSubs=null,this._infoView=i(this),this.multiView=new o.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof ye&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=e,this.mainView=this.multiView,this._initViewSubs()}handleJoiningDataframe(t){return Qe(this,void 0,void 0,(function*(){var i,n,a,s,r,l;const u=t.columns.bySemTypeAll(o.SEMTYPE.MOLECULE);if(!u||0===u.length)return void e.shell.error("No molecule column found");const d=null!==(i=u.find((e=>{var t,i;return"smiles"===(null===(t=null==e?void 0:e.name)||void 0===t?void 0:t.toLowerCase())||"molecule"===(null===(i=null==e?void 0:e.name)||void 0===i?void 0:i.toLowerCase())})))&&void 0!==i?i:u[0];if(!d)return void e.shell.error("No molecule column found");const c=null!==(s=null===(a=null===(n=this.campaign)||void 0===n?void 0:n.template)||void 0===a?void 0:a.compute)&&void 0!==s?s:null===(r=this.template)||void 0===r?void 0:r.compute;if(!c)return void e.shell.error("No compute functions found");const m=d.toList(),v=c.descriptors.enabled&&null!==(l=c.descriptors.args)&&void 0!==l?l:[],f=yield Oe(m,v,c.functions,c.scripts,c.queries);if(this.unionDataframes(f,t,h,d.name),this.stages.length>0&&this.dataFrame.columns.contains(p)){const e=t.columns.getOrCreate(p,o.TYPE.STRING);for(let i=0;i<t.rowCount;i++)e.isNone(i)&&e.set(i,this.stages[0],!1)}this.unionDataframes(t,this.dataFrame,d.name,this.molColName),this.updateAllVids(),this.saveCampaign(!1)}))}updateAllVids(){var e;const t=this.dataFrame.col(this.molColName),i=this.dataFrame.col(v);if(!t||!i)return;const n=t.toList().map((e=>st.convertToSmiles(e))),o=new Map;for(let t=0;t<n.length;t++){const a=n[t];if(!a)continue;const s=i.isNone(t)?null:i.get(t);if(s)if(o.has(a)){if(s===o.get(a))continue;i.set(t,o.get(a),!1)}else o.set(a,s);else i.set(t,null!==(e=o.get(a))&&void 0!==e?e:Ve(i),!1)}const a=i.get(0);i.set(0,null,!1),i.set(0,a,!0)}_initViewSubs(){this.multiView.subs.push(e.events.onCurrentViewChanged.subscribe((()=>Qe(this,void 0,void 0,(function*(){var t,i,n,o,s;try{if((null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentDesignViewId){e.shell.windows.showHelp=!1,this.setBaseUrl(),J(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:"");const{sub:t}=z(e.shell.v,this.appName,null===(s=e.shell.v)||void 0===s?void 0:s.name,(()=>{var i;e.shell.v=this.mainView,null===(i=this._designView)||void 0===i||i.close(),this._infoView.init(),t.unsubscribe()}))}}catch(e){console.error(e)}}))))),this.multiView.subs.push(e.events.onFileImportRequest.subscribe((t=>{var i,n;if(!e.shell.tv||!this._designView||e.shell.tv!==this._designView)return;if(!(null===(i=null==t?void 0:t.args)||void 0===i?void 0:i.file))return;const o=t.args.file;((null===(n=o.name)||void 0===n?void 0:n.endsWith(".csv"))||Fe.molFileExtReaders.some((e=>{var t;return null===(t=o.name)||void 0===t?void 0:t.endsWith(e.ext)})))&&(t.preventDefault(),this.handleUploadingDataframe(o))})))}handleUploadingDataframe(i){return Qe(this,void 0,void 0,(function*(){var n;try{let a=null;if(i.name.endsWith(".csv"))a=o.DataFrame.fromCsv(yield i.text());else{const t=yield new Promise((e=>Qe(this,void 0,void 0,(function*(){const t=new FileReader;let n=null,o=null;t.onload=()=>{o=t.result?new Uint8Array(t.result):null,n&&clearTimeout(n),e(o)},t.readAsArrayBuffer(i),n=setTimeout((()=>{t.abort(),e(null)}),1e4)}))));if(!t)return void e.shell.error("Failed to read file");const n=Fe.molFileExtReaders.find((e=>i.name.endsWith(e.ext))).handlerFunc,o=n.inputs[0].name;a=(yield n.apply({[o]:t}))[0]}if(!a)throw new Error("Failed to read file");if(a.name=i.name.slice(0,i.name.lastIndexOf(".")),yield a.meta.detectSemanticTypes(),yield e.data.detectSemanticTypes(a),!a.columns.bySemType(o.SEMTYPE.MOLECULE))return void e.shell.addTableView(a);const s=t.dialog("Uploading table with molecules").add(t.divText("Add new table to workspace or join with existing Hit Design campaign")).addButton("Add to workspace",(()=>{s.close(),e.shell.addTableView(a)})).addButton("Add to existing campaign",(()=>{s.close(),this.handleJoiningDataframe(a)}));null===(n=s.getButton("CANCEL"))||void 0===n||n.remove(),s.show()}catch(t){e.shell.error("Hit Design Failed to read file"),console.error(t)}}))}get stages(){var e,t,i,n,o;return null!==(o=null!==(i=null===(t=null===(e=this.campaign)||void 0===e?void 0:e.template)||void 0===t?void 0:t.stages)&&void 0!==i?i:null===(n=this.template)||void 0===n?void 0:n.stages)&&void 0!==o?o:[]}setStages(t){return Qe(this,void 0,void 0,(function*(){var i;if(!this.campaign||!this.campaign.template||!this.template)return void e.shell.error("Campaign or template is not set");if(!(null==t?void 0:t.length))return void e.shell.error("Removing all stages is not allowed");const n=null===(i=this.dataFrame)||void 0===i?void 0:i.col(p);if(!n)return void e.shell.error("No stage column found");const o=[],a=new Set(t),s=[...a],r=this.dataFrame.rowCount,l=n.categories,u=n.getRawData();for(let e=0;e<r;e++){const i=l[u[e]];a.has(i)||(n.set(e,t[0],!1),o.push(i))}o.length>0&&e.shell.warning(`Some stages were removed: (${o.join(", ")}). Corresponding rows were set to stage "${t[0]}"`),this.campaign.template.stages=s,this.template.stages=s,yield this.saveCampaign(!0)}))}setTemplate(t,i){return Qe(this,void 0,void 0,(function*(){var n,l,u,d,c,p,m,v,f,g,y;if(i){const t=`System.AppData/HitTriage/${this.appName}/campaigns`;this._filePath=null!==(u=null===(l=this.campaign)||void 0===l?void 0:l.savePath)&&void 0!==u?u:`${t}/${i}/${r}`,this.dataFrame=yield e.dapi.files.readCsv(this._filePath),(null===(d=this._campaign)||void 0===d?void 0:d.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&t&&(i.semType=t)})),(null===(c=this._campaign)||void 0===c?void 0:c.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===(n=this._designView)||void 0===n?void 0:n.dataFrame)&&e.shell.closeTable(this._designView.dataFrame),this._designView=void 0,i=yield this.getNewCampaignName(`${this.appName}/campaigns`,t.key),J(s,i),this._filePath=`System.AppData/HitTriage/${this.appName}/campaigns/${i}/${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(o.SEMTYPE.MOLECULE))||void 0===p?void 0:p.name)&&void 0!==m?m:h,this._campaignId=i,this.template=t,null!==(v=this._submitView)&&void 0!==v||(this._submitView=new He(this)),e.shell.windows.showHelp=!1,this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0;const w=this.designView;this.currentDesignViewId=w.name,this.setBaseUrl(),J(a,null!==(y=null!==(f=this._campaignId)&&void 0!==f?f:null===(g=this._campaign)||void 0===g?void 0:g.name)&&void 0!==y?y:""),this.campaign&&(this.campaign.template=t)}))}get campaignId(){return this._campaignId}get designView(){return this._designView=this.getDesignView()}get designViewName(){return this._designViewName}set designViewName(e){this._designViewName=e,this._designView&&(this._designView.name=e)}get molColName(){var e,t,i,n;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null!==(n=null===(i=null===(t=this.dataFrame)||void 0===t?void 0:t.columns.bySemType(o.SEMTYPE.MOLECULE))||void 0===i?void 0:i.name)&&void 0!==n?n:h}get campaign(){return this._campaign}set campaign(e){this._campaign=e}clearCampaign(){this._campaign=void 0}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().subarray(0,t.length);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}performSingleCellCalculations(e,t){return Qe(this,void 0,void 0,(function*(){const i=this.template.compute;if(!t||""===t)return;const n=yield Oe([t],i.descriptors.args,i.functions,i.scripts,i.queries);for(const t of n.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(e,t.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(!1)}))}initDesignViewRibbons(i,n,a=!1){var s,r,l;const u=e.events.onViewRemoved.subscribe((e=>{e.id===(null==i?void 0:i.id)&&(n.forEach((e=>e.unsubscribe())),u.unsubscribe())}));let d=null==i?void 0:i.getRibbonPanels();if(d&&!Q(d)){const n=()=>Qe(this,void 0,void 0,(function*(){var e;ue(this,(e=>Qe(this,void 0,void 0,(function*(){var n,o,a,s,r,l,u,d,c,p;const h=this.template.compute.descriptors.args,m=this.template.compute.functions,v=null!==(n=this.template.compute.scripts)&&void 0!==n?n:[],f=null!==(o=this.template.compute.queries)&&void 0!==o?o:[],w=e.descriptors,b={descriptors:{enabled:!!(null===(a=null==e?void 0:e.descriptors)||void 0===a?void 0:a.length),args:null!==(s=null==e?void 0:e.descriptors)&&void 0!==s?s:[]},functions:Object.entries(null!==(r=null==e?void 0:e.externals)&&void 0!==r?r:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(l=null==e?void 0:e.scripts)&&void 0!==l?l:{}).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!==(u=null==e?void 0:e.queries)&&void 0!==u?u:{}).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!==(d=null==e?void 0:e.externals)&&void 0!==d?d:{}).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!==(c=null==e?void 0:e.scripts)&&void 0!==c?c:{}).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})),t.setUpdateIndicator(i.grid.root,!0);try{yield Le({descriptors:C,externals:A,scripts:T,queries:x},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{t.setUpdateIndicator(i.grid.root,!1),this.saveCampaign(!1)}}))),(()=>null),null===(e=this.campaign)||void 0===e?void 0:e.template,!0)})),u=t.iconFA("wrench",n,"Calculate additional properties"),c=t.icons.add((()=>{var e;null===(e=this.dataFrame)||void 0===e||e.rows.addNew(null,!0)}),"Add new row"),p=t.iconSvg("view-layout",(()=>{this.applyTemplateLayout(i)}),"Apply template layout "+((null===(s=this.template)||void 0===s?void 0:s.localLayoutPath)?"(Loaded from mounted file storage)":"(Static)")),h=t.iconFA("share",(()=>Qe(this,void 0,void 0,(function*(){var e;yield new xe(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show((e=>{this.campaign.permissions=e,this.saveCampaign(!0)}))}))),"Edit campaign permissions"),m=t.bigButton("Progress tracker",(()=>{Ge(this,(()=>{var e;return null!==(e=this._designView)&&void 0!==e?e:null}))})),v=t.bigButton("Submit...",(()=>{var e,i,n,a,s,r;const l=null===(e=this._submitView)||void 0===e?void 0:e.render();if(l){const e=t.dialog("Submit");e.add(l),e.addButton("Save",(()=>{this._campaign.status=this._submitView.getStatus(),this.saveCampaign(),e.close()})),(null===(n=null===(i=this.template)||void 0===i?void 0:i.submit)||void 0===n?void 0:n.fName)&&(null===(s=null===(a=this.template)||void 0===a?void 0:a.submit)||void 0===s?void 0:s.package)&&(null===(r=o.Func.find({name:this.template.submit.fName,package:this.template.submit.package}))||void 0===r?void 0:r.length)>0&&e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}})),f=o.Func.find({tags:["HitDesignerFunction"]}).filter((e=>1===e.outputs.length&&e.outputs[0].propertyType===o.TYPE.DATA_FRAME));v.classList.add("hit-design-submit-button");const w=[v];if(this.stages.length>0&&w.unshift(m),this.campaign&&this.template&&!this.campaign.template&&(this.campaign.template=this.template),((null===(r=this.template)||void 0===r?void 0:r.layoutViewState)||(null===(l=this.template)||void 0===l?void 0:l.localLayoutPath))&&w.unshift(p),this.hasEditPermission&&w.unshift(h),f.length>0&&a){const i=f[0],n=t.iconFA("pen-nib",(()=>Qe(this,void 0,void 0,(function*(){var n;const a={};if(i.inputs.length>0&&this.dataFrame&&this.dataFrame.currentRowIdx>=0&&i.inputs[0].semType===o.SEMTYPE.MOLECULE){const e=st.convertToSmiles(null===(n=this.dataFrame.col(this.molColName))||void 0===n?void 0:n.get(this.dataFrame.currentRowIdx));e&&(a[i.inputs[0].name]=e)}const s=i.prepare(a),r=yield s.getEditor();t.dialog(i.friendlyName).add(r).onOK((()=>Qe(this,void 0,void 0,(function*(){const t=o.TaskBarProgressIndicator.create(`Running ${i.friendlyName}`);try{yield s.call();const n=s.getOutputParamValue();if(!n||!n.rowCount)return e.shell.warning(`${i.friendlyName} returned an empty result`),void t.close();yield n.meta.detectSemanticTypes(),yield e.data.detectSemanticTypes(n),yield this.handleJoiningDataframe(n)}catch(t){e.shell.error(`Failed to run ${i.friendlyName}`),st.logger.error(t)}finally{t.close()}})))).show()}))),i.description?i.description:i.friendlyName);w.unshift(n)}w.unshift(u),w.unshift(c),d.push(w),d.some((e=>{var t;const i=null!==(t=null==e?void 0:e.findIndex((e=>{var t;return"save"===(null===(t=null==e?void 0:e.textContent)||void 0===t?void 0:t.toLowerCase())})))&&void 0!==t?t:-1;return-1!==i&&(e.splice(i,1),!0)})),d=d.filter((e=>{var t;return(null!==(t=null==e?void 0:e.length)&&void 0!==t?t:0)>0})),i.setRibbonPanels(d)}return i}applyTemplateLayout(t){return Qe(this,void 0,void 0,(function*(){var i,n;if(t){if(null===(i=this.template)||void 0===i?void 0:i.localLayoutPath)try{const i=yield e.dapi.files.readAsText(this.template.localLayoutPath),n=o.ViewLayout.fromJson(i);return void t.loadLayout(n)}catch(t){e.shell.error("Failed to apply layout from mounted file storage. Falling back to static layout"),st.logger.error(t)}if(null===(n=this.template)||void 0===n?void 0:n.layoutViewState)try{const e=o.ViewLayout.fromViewState(this.template.layoutViewState);t.loadLayout(e)}catch(t){e.shell.error("Failed to apply template layout. Check console for more details."),st.logger.error(t)}else e.shell.error("No layout found")}else e.shell.error("No view found")}))}getDesignView(){var t,i,n,a,s,r;this._designView&&this._designView.close();const l=[],u=null===(t=this.dataFrame.col(this.molColName))||void 0===t?void 0:t.toList().every((e=>!e&&""===e)),d=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(s=null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.friendlyName)&&void 0!==n?n:null===(a=this.campaign)||void 0===a?void 0:a.name)&&void 0!==s?s:this._designViewName,d.name=this._designViewName,d._onAdded();const c=null===(r=this._campaign)||void 0===r?void 0:r.layout;if(c)try{const e=o.ViewLayout.fromViewState(c);d.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}return this.checkGrid(d),u&&e.functions.call("Chem:editMoleculeCell",{cell:d.grid.cell(this._molColName,0)}),this.initGridSubs(d,l),l.push(this.dataFrame.onRowsAdded.pipe((0,We.filter)((()=>!this.isJoining))).subscribe((()=>{var t;try{if(this.stages.length>0)for(let e=0;e<this.dataFrame.rowCount;e++){const i=this.dataFrame.col(p).get(e);i&&""!==i&&!(null===(t=this.dataFrame.col(p))||void 0===t?void 0:t.isNone(e))||this.dataFrame.set(p,e,this.stages[0])}let i=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||(i=t))}i&&e.functions.call("Chem:editMoleculeCell",{cell:i})}catch(e){console.error(e)}}))),l.push(e.events.onContextMenu.subscribe((t=>{var i,n,a,s,r,l,u,c,p,h,m,v;try{const e=null===(i=null==t?void 0:t.args)||void 0===i?void 0:i.context;if(!e)return;if((null==e?void 0:e.type)!==o.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==d.id)return;if((null===(s=null===(a=null===(n=null==t?void 0:t.args)||void 0===n?void 0:n.item)||void 0===a?void 0:a.tableColumn)||void 0===s?void 0:s.name)!==this.molColName||!(null===(l=null===(r=null==t?void 0:t.args)||void 0===r?void 0:r.item)||void 0===l?void 0:l.isTableCell))return;const f=null===(u=null==t?void 0:t.args)||void 0===u?void 0:u.menu;if(!f)return;f.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),f.item("Duplicate molecule",(()=>{var e,i,n,o;try{const a=this.dataFrame.rows.addNew(null,!0);null!=a.get(this.molColName)&&a.idx>-1&&(this.dataFrame.cell(a.idx,this.molColName).value=null!==(o=null===(n=null===(i=null===(e=null==t?void 0:t.args)||void 0===e?void 0:e.item)||void 0===i?void 0:i.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}}));const g=null===(p=null===(c=null==t?void 0:t.args)||void 0===c?void 0:c.item)||void 0===p?void 0:p.tableRowIndex,y=null===(v=null===(m=null===(h=null==t?void 0:t.args)||void 0===h?void 0:h.item)||void 0===m?void 0:m.cell)||void 0===v?void 0:v.value;y&&(null!=g?g:-1)>-1&&f.item("Re-Run Calculations",(()=>Qe(this,void 0,void 0,(function*(){try{yield this.performSingleCellCalculations(g,y)}catch(e){console.error(e)}}))))}catch(t){e.log.error(t)}}))),l.push(e.events.onViewLayoutApplied.subscribe((e=>{e&&e.view===d&&this.initGridSubs(d,l)}))),this.initDesignViewRibbons(d,l,!0),d.parentCall=this.parentCall,d}checkGrid(t){t.grid||(e.shell.error("Applied layout created view without grid. Resetting layout."),t.resetLayout())}initGridSubs(t,i){this._gridSubs&&this._gridSubs.grid===t.grid||(this._gridSubs&&this._gridSubs.subs.forEach((e=>e.unsubscribe())),this.checkGrid(t),t.grid?(this._gridSubs={grid:t.grid,subs:[]},(null==t?void 0:t.grid)&&this._gridSubs.subs.push(t.grid.onCellValueEdited.subscribe((e=>Qe(this,void 0,void 0,(function*(){var t,i,n,o,a;try{if((null===(t=e.tableColumn)||void 0===t?void 0:t.name)===p)return void(yield this.saveCampaign(!1));if((null===(i=e.tableColumn)||void 0===i?void 0:i.name)!==this.molColName)return;const s=e.cell.value,r=e.tableRowIndex;let l=null===(n=this.dataFrame.col(v))||void 0===n?void 0:n.get(r),u=!1;if(s)try{const t=e.tableColumn.toList().map((e=>{try{return st.convertToSmiles(e)}catch(e){return""}})),i=st.convertToSmiles(s);if((null==t?void 0:t.length)===this.dataFrame.rowCount)for(let e=0;e<t.length;e++)if(t[e]===i&&e!==r&&(null===(o=this.dataFrame.col(v))||void 0===o?void 0:o.get(e))){l=null===(a=this.dataFrame.col(v))||void 0===a?void 0:a.get(e),u=!0;break}}catch(e){console.error(e)}this.duplicateVidCache&&!u&&this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[r]]>1&&(l=null),l&&""!==l||(l=Ve(this.dataFrame.col(v))),this.dataFrame.col(v).set(r,l,!1),this.performSingleCellCalculations(r,s)}catch(e){console.error(e)}}))))),(null==t?void 0:t.grid)&&this._gridSubs.subs.push(t.grid.onCellRender.subscribe((e=>{var t;try{const i=e.cell;if(!i||!i.isTableCell||!i.tableColumn||!this.duplicateVidCache||i.tableColumn.name!==v||(null!==(t=i.tableRowIndex)&&void 0!==t?t:-1)<0)return;this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[i.tableRowIndex]]>1&&(e.cell.style.backColor=o.Color.setAlpha(o.Color.getCategoricalColor(this.duplicateVidCache.indexes[i.tableRowIndex]),150))}catch(e){}}))),this._gridSubs.subs.forEach((e=>i.push(e)))):e.shell.error("No grid found, cannot initialize grid subscriptions"))}getSummary(){var i,n,a,s,l,u,d,c,p,h,m,v,f;const g=()=>{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)},y=Object.assign({},null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.campaignFields)&&void 0!==n?n:this.campaignProps);this.template&&this.template.campaignFields&&Object.entries(y).forEach((([t,i])=>{const n=this.template.campaignFields.find((e=>e.name===t));n&&"Date"===n.type&&i?"Invalid Date"!==new Date(i).toString()?y[t]=new Date(i).toLocaleDateString():i.date?y[t]=new Date(i.date).toLocaleDateString():y[t]=i:n&&n.type===o.SEMTYPE.MOLECULE&&i&&(y[t]=e.chem.drawMolecule(i))}));const w=null!==(u=null!==(s=null===(a=this.campaign)||void 0===a?void 0:a.friendlyName)&&void 0!==s?s:null===(l=this.campaign)||void 0===l?void 0:l.name)&&void 0!==u?u:this.campaignId,b=function(i,n){var o;const a=t.icons.edit((()=>{var o,r,l,u,d;let c=null!==(r=null!==(o=null==n?void 0:n.tooltip)&&void 0!==o?o:i.textContent)&&void 0!==r?r:"";const p=null!==(l=null==n?void 0:n.beforeEditTextContent)&&void 0!==l?l:e=>e,h=null!==(u=null==n?void 0:n.afterEditTextContent)&&void 0!==u?u:e=>e,m=t.input.string("smth",{value:p(null!==(d=i.textContent)&&void 0!==d?d:""),onValueChanged:()=>G(this,void 0,void 0,(function*(){var e;const t=yield f();setTimeout((()=>{var e,o;if(t)return m.input.classList.add("d4-invalid"),void(c=t);m.input.classList.remove("d4-invalid"),c=null!==(o=null!==(e=null==n?void 0:n.tooltip)&&void 0!==e?e:i.textContent)&&void 0!==o?o:""}),100),null===(e=null==n?void 0:n.onChange)||void 0===e||e.call(n,m.value)}))});t.tooltip.bind(m.input,(()=>c));const v=m.root.getElementsByTagName("label").item(0);v&&v.remove(),m.root.style.width="100%";const f=()=>G(this,void 0,void 0,(function*(){var e;const t=(null===(e=m.value)||void 0===e?void 0:e.trim())||(null==n?void 0:n.nullable)?null:"Field cannot be empty";return null!=t?t:(null==n?void 0:n.validator)?yield n.validator(m.value):null})),g=t.button("Save",(()=>G(this,void 0,void 0,(function*(){var o,r;const l=yield f();l?e.shell.error(l):(yield null===(o=null==n?void 0:n.onOk)||void 0===o?void 0:o.call(n,m.value),i.textContent=null!==(r=h(m.value))&&void 0!==r?r:"",t.empty(s),s.appendChild(i),s.appendChild(a))})))),y=t.button("Cancel",(()=>{var e;t.empty(s),s.appendChild(i),s.appendChild(a),null===(e=null==n?void 0:n.onCancel)||void 0===e||e.call(n)}));t.empty(s),m.addOptions(y),m.addOptions(g),s.appendChild(m.root),m.input.focus()}),null!==(o=null==n?void 0:n.tooltip)&&void 0!==o?o:"Edit"),s=t.divH([i,a],{style:{display:"flex",alignItems:"center"}});return a.style.marginLeft="5px",s}(t.divText(w),{tooltip:"Edit Campaign Name",nullable:!1,onOk:e=>Qe(this,void 0,void 0,(function*(){this.campaign.friendlyName=e,yield this.saveCampaign(!0)})),validator:e=>Qe(this,void 0,void 0,(function*(){return(null==e?void 0:e.trim())?null:"Campaign name can not be empty"}))});return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({Name:b,Code:null!==(d=this.campaignId)&&void 0!==d?d:null===(c=this._campaign)||void 0===c?void 0:c.name,Template:null!==(h=null===(p=this.template)||void 0===p?void 0:p.name)&&void 0!==h?h:"Molecules","File Path":(()=>{const i=t.icons.edit((()=>{const n=g(),s=t.input.string("Path",{value:n}),l=s.root.getElementsByTagName("label").item(0);l&&l.remove(),s.root.style.width="100%";const u=t.button("Save",(()=>Qe(this,void 0,void 0,(function*(){const n=yield function(){return Qe(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(!n)return;const l=s.value;l.endsWith("/")?this._filePath=`${l}${this.campaignId}/${r}`:this._filePath=`${l}/${this.campaignId}/${r}`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(!0),t.empty(a);const u=g();o=t.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(o),a.appendChild(i)})))),d=t.button("Cancel",(()=>{t.empty(a),a.appendChild(o),a.appendChild(i)}));t.empty(a),s.addOptions(d),s.addOptions(u),a.appendChild(s.root),s.input.focus()}),"Edit file path");i.style.marginLeft="5px";const n=g();let o=t.link(n,(()=>{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=t.divH([o,i],{style:{alignItems:"center"}});return a})()},(null===(m=this.campaign)||void 0===m?void 0:m.authorUserFriendlyName)?{Author:this.campaign.authorUserFriendlyName}:{}),(null===(v=this.campaign)||void 0===v?void 0:v.lastModifiedUserName)?{"Last Modified By":this.campaign.lastModifiedUserName}:{}),(null===(f=this.campaign)||void 0===f?void 0:f.createDate)?{"Create Date":this.campaign.createDate}:{}),y),{"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(", ")})}saveCampaign(){return Qe(this,arguments,void 0,(function*(t=!0,i=!1,n){var a,s,r,u,d,c,p,h,m,v,f,g,y,w,b,C,A,T,x,S,N;const E=this.campaignId,I=this.template.name,F=this.dataFrame,_=E,P={};F.columns.toList().forEach((e=>P[e.name]=e.semType));const O={};F.columns.toList().forEach((e=>O[e.name]=e.type));const V=null!==(s=null===(a=this.campaign)||void 0===a?void 0:a.tilesViewerFormSketch)&&void 0!==s?s:void 0,L=null!==(u=null===(r=this.campaign)||void 0===r?void 0:r.authorUserId)&&void 0!==u?u:e.shell.user.id,B=null!==(c=null===(d=this.campaign)||void 0===d?void 0:d.permissions)&&void 0!==c?c:yield(()=>Qe(this,void 0,void 0,(function*(){try{const e=yield function(){return Je(this,void 0,void 0,(function*(){var e,t,i,n;try{const o=yield st.getSettings(),a={view:[],edit:[]};return o?(o instanceof Map?(a.view=yield Ke(null!==(e=o.get("view"))&&void 0!==e?e:""),a.edit=yield Ke(null!==(t=o.get("edit"))&&void 0!==t?t:"")):(a.view=yield Ke(null!==(i=o.view)&&void 0!==i?i:""),a.edit=yield Ke(null!==(n=o.edit)&&void 0!==n?n:"")),a):a}catch(e){return console.error(e),{view:[],edit:[]}}}))}(),t={view:e.view.map((e=>e.id)),edit:e.edit.map((e=>e.id))};return 0===t.edit.length&&(t.edit=[Te.edit[0]]),0===t.view.length&&(t.view=[Te.view[0]]),t}catch(t){e.shell.error("Failed to get default permissions"),console.error(t)}return Te})))(),k=L?null!==(h=null===(p=this.campaign)||void 0===p?void 0:p.authorUserFriendlyName)&&void 0!==h?h:null===(m=yield e.dapi.users.find(L))||void 0===m?void 0:m.friendlyName:void 0,M={name:_,friendlyName:null!==(g=null!==(f=null===(v=this.campaign)||void 0===v?void 0:v.friendlyName)&&void 0!==f?f:null==n?void 0:n.friendlyName)&&void 0!==g?g:_,templateName:I,status:null!==(w=null===(y=this.campaign)||void 0===y?void 0:y.status)&&void 0!==w?w:"In Progress",createDate:null!==(C=null===(b=this.campaign)||void 0===b?void 0:b.createDate)&&void 0!==C?C:W(new Date),campaignFields:null!==(T=null===(A=this.campaign)||void 0===A?void 0:A.campaignFields)&&void 0!==T?T:this.campaignProps,columnSemTypes:P,rowCount:F.rowCount,filteredRowCount:F.filter.trueCount,savePath:this._filePath,columnTypes:O,tilesViewerFormSketch:V,version:this.version+1,authorUserId:L,authorUserFriendlyName:k,lastModifiedUserName:e.shell.user.friendlyName,permissions:B};if(!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),M;const U=`${this.appName}/campaigns/${E}/${l}`;let R=F;if(yield st.files.exists(U)){const t=JSON.parse(yield st.files.readAsText(U));if((null!==(x=t.version)&&void 0!==x?x:0)>this.version&&(M.version=Math.max(this.version,null!==(S=t.version)&&void 0!==S?S:0)+1,yield e.dapi.files.exists(this._filePath)))try{const t=yield e.dapi.files.readCsv(this._filePath);R=this.unionDataframes(t,F,this.molColName,this.molColName)}catch(e){console.error(e)}}const j=o.DataFrame.fromColumns(R.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield e.dapi.files.writeAsText(this._filePath,j);const D=this._designView.saveLayout();return D?M.layout=D.viewState:e.shell.warning("Layout cound not be saved"),M.template=this.template,yield st.files.writeAsText(U,JSON.stringify(M)),t&&e.shell.info("Campaign saved successfully."),!t&&i&&e.shell.info("Campaign created successfully."),this.campaign=M,this.designViewName=null!==(N=M.friendlyName)&&void 0!==N?N:M.name,M}))}}class Xe extends o.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 et=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 tt extends $e{constructor(t){super(t),this.name="PeptiHit",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(st.webRoot+"README_HD.md")}getNewCampaignAccordeon(e){return et(this,void 0,void 0,(function*(){const{root:t,promise:i,cancelPromise:n}=Me(e,!0);return i.then((t=>et(this,void 0,void 0,(function*(){this.app.dataFrame=t.df,yield this.app.setTemplate(e),this.app.campaignProps=t.campaignProps,yield this.app.saveCampaign(!1),e.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=e.layoutViewState)})))),n.then((()=>{this.init()})),t}))}getAppHeader(){return Ce.appHeader({iconPath:st.webRoot+"/images/icons/pepti-hit-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 Helm sequences in the spreadsheet\n- Annotate and share ideas with the team\n- Convert to molecular form and calculate different properties\n- Save campaigns and continue from where you left off\n- Submit final selection to the function of your choice"})}}var it=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 nt extends Ze{constructor(e){super(e,"PeptiHit",(e=>new tt(e))),this._helmColName=m}setTemplate(e,t){const i=Object.create(null,{setTemplate:{get:()=>super.setTemplate}});return it(this,void 0,void 0,(function*(){var n,a;yield i.setTemplate.call(this,e,t),this._helmColName=null!==(a=null===(n=this.dataFrame.columns.bySemType(o.SEMTYPE.MACROMOLECULE))||void 0===n?void 0:n.name)&&void 0!==a?a:m}))}get helmColName(){var e,t;return null!==(e=this._helmColName)&&void 0!==e?e:null===(t=this.dataFrame.columns.bySemType(o.SEMTYPE.MACROMOLECULE))||void 0===t?void 0:t.name}performSingleCellCalculations(t,i){const n=Object.create(null,{performSingleCellCalculations:{get:()=>super.performSingleCellCalculations}});return it(this,void 0,void 0,(function*(){var a;try{if(!i)throw new Error("No cell value provided");const s=o.Column.fromStrings(this.helmColName,[i]),r=o.DataFrame.fromColumns([s]);s.semType=o.SEMTYPE.MACROMOLECULE,s.setTag("units","helm"),s.setTag(".alphabetIsMultichar","true"),yield e.functions.call("Bio:toAtomicLevel",{table:r,seqCol:s,nonlinear:!0});const l=r.columns.names().find((e=>e.toLowerCase()!==this.helmColName.toLowerCase())),u=l?null===(a=r.col(l))||void 0===a?void 0:a.get(0):null;if(!u)throw new Error("Failed to convert sequence to atomic level");this.dataFrame.set(this.molColName,t,u),yield n.performSingleCellCalculations.call(this,t,u)}catch(e){console.error(e)}}))}getDesignView(){var t,i,n,a,s,r;const l=[],u=null===(t=this.dataFrame.col(this.helmColName))||void 0===t?void 0:t.toList().every((e=>!e&&""===e)),d=this.dataFrame.col(this.helmColName);if(!d)throw new Error("No helm column found");d.semType=o.SEMTYPE.MACROMOLECULE,d.setTag("units","helm"),d.setTag(".alphabetIsMultichar","true"),d.setTag("cell.renderer","helm");const c=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.name)&&void 0!==n?n:this._designViewName,c.name=this._designViewName,c._onAdded();const h=null!==(s=null===(a=this._campaign)||void 0===a?void 0:a.layout)&&void 0!==s?s:null===(r=this.template)||void 0===r?void 0:r.layoutViewState;if(h)try{const e=o.ViewLayout.fromViewState(h);c.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}return u&&e.functions.call("Helm:editMoleculeCell",{cell:c.grid.cell(this.helmColName,0)}),l.push(this.dataFrame.onRowsAdded.pipe((0,We.filter)((()=>!this.isJoining))).subscribe((()=>{var t;try{if(this.stages.length>0)for(let e=0;e<this.dataFrame.rowCount;e++){const i=this.dataFrame.col(p).get(e);i&&""!==i&&!(null===(t=this.dataFrame.col(p))||void 0===t?void 0:t.isNone(e))||this.dataFrame.set(p,e,this.stages[0])}let i=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=c.grid.cell(this.helmColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(i=t))}i&&e.functions.call("Helm:editMoleculeCell",{cell:i})}catch(e){console.error(e)}}))),l.push(e.events.onContextMenu.subscribe((t=>{var i,n,a,s,r,l,u,d,p,h,m,v;try{const e=null===(i=null==t?void 0:t.args)||void 0===i?void 0:i.context;if(!e)return;if((null==e?void 0:e.type)!==o.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==c.id)return;if((null===(s=null===(a=null===(n=null==t?void 0:t.args)||void 0===n?void 0:n.item)||void 0===a?void 0:a.tableColumn)||void 0===s?void 0:s.name)!==this.helmColName||!(null===(l=null===(r=null==t?void 0:t.args)||void 0===r?void 0:r.item)||void 0===l?void 0:l.isTableCell))return;const f=null===(u=null==t?void 0:t.args)||void 0===u?void 0:u.menu;if(!f)return;f.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),f.item("Duplicate Sequence",(()=>{var e,i,n,o;try{const a=this.dataFrame.rows.addNew(null,!0);null!=a.get(this.helmColName)&&a.idx>-1&&(this.dataFrame.cell(a.idx,this.helmColName).value=null!==(o=null===(n=null===(i=null===(e=null==t?void 0:t.args)||void 0===e?void 0:e.item)||void 0===i?void 0:i.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}}));const g=null===(p=null===(d=null==t?void 0:t.args)||void 0===d?void 0:d.item)||void 0===p?void 0:p.tableRowIndex,y=null===(v=null===(m=null===(h=null==t?void 0:t.args)||void 0===h?void 0:h.item)||void 0===m?void 0:m.cell)||void 0===v?void 0:v.value;y&&(null!=g?g:-1)>-1&&f.item("Re-Run Calculations",(()=>it(this,void 0,void 0,(function*(){try{yield this.performSingleCellCalculations(g,y)}catch(e){console.error(e)}}))))}catch(t){e.log.error(t)}}))),(null==c?void 0:c.grid)||(e.shell.error("Applied layout created view without grid. Resetting layout."),c.resetLayout()),(null==c?void 0:c.grid)&&l.push(c.grid.onCellValueEdited.subscribe((e=>it(this,void 0,void 0,(function*(){var t,i,n,o,a;try{if((null===(t=e.tableColumn)||void 0===t?void 0:t.name)===p)return void(yield this.saveCampaign(!1));if((null===(i=e.tableColumn)||void 0===i?void 0:i.name)!==this.helmColName)return;const s=e.cell.value,r=e.tableRowIndex;let l=null===(n=this.dataFrame.col(v))||void 0===n?void 0:n.get(r),u=!1;if(s)try{const t=e.tableColumn.toList(),i=s;if((null==t?void 0:t.length)===this.dataFrame.rowCount)for(let e=0;e<t.length;e++)if(t[e]===i&&e!==r&&(null===(o=this.dataFrame.col(v))||void 0===o?void 0:o.get(e))){l=null===(a=this.dataFrame.col(v))||void 0===a?void 0:a.get(e),u=!0;break}}catch(e){console.error(e)}this.duplicateVidCache&&!u&&this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[r]]>1&&(l=null),l&&""!==l||(l=Ve(this.dataFrame.col(v))),this.dataFrame.col(v).set(r,l,!1),this.performSingleCellCalculations(r,s)}catch(e){console.error(e)}}))))),(null==c?void 0:c.grid)&&l.push(c.grid.onCellRender.subscribe((e=>{var t;try{const i=e.cell;if(!i||!i.isTableCell||!i.tableColumn||!this.duplicateVidCache||i.tableColumn.name!==v||(null!==(t=i.tableRowIndex)&&void 0!==t?t:-1)<0)return;this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[i.tableRowIndex]]>1&&(e.cell.style.backColor=o.Color.setAlpha(o.Color.getCategoricalColor(this.duplicateVidCache.indexes[i.tableRowIndex]),150))}catch(e){}}))),this.initDesignViewRibbons(c,l),c.parentCall=this.parentCall,c}}var ot=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 at extends o.Package{constructor(){super(...arguments),this.molToSmilesLruCache=new o.LruCache(2e3)}convertToSmiles(t){return t?this.molToSmilesLruCache.getOrCreate(t,(t=>e.chem.convert(t,e.chem.Notation.Unknown,e.chem.Notation.Smiles))):""}}const st=new at;function rt(i,n,a){return ot(this,void 0,void 0,(function*(){var s;const r=t.div([],{style:{width:"50px",height:"24px",position:"relative"}});r.innerHTML='<div class="grok-loader"><div></div><div></div><div></div><div></div></div>';const l=i.item(r),u=yield X(a,[]);for(const[t,a]of Object.entries(u)){const t="ingest"in a?a.ingest.query:a.savePath;t&&(yield e.dapi.files.exists(t))&&i.item(null!==(s=a.friendlyName)&&void 0!==s?s:a.name).onSelected.subscribe((i=>ot(this,void 0,void 0,(function*(){try{const i=yield e.dapi.files.readCsv(t);if(!i)return;const s=a.columnSemTypes;if(s)for(const[e,t]of Object.entries(s)){const n=i.columns.byName(e);n&&(n.semType=t,t===o.SEMTYPE.MACROMOLECULE&&e===m&&(n.setTag("units","helm"),n.setTag(".alphabetIsMultichar","true"),n.setTag("cell.renderer","helm")))}const r=o.TableView.create(i,!1);n.preview=r;const l=a.layout;l&&r.loadLayout(o.ViewLayout.fromViewState(l))}catch(e){console.error(e)}}))))}l.remove()}))}function lt(e,t){return ot(this,void 0,void 0,(function*(){yield rt(e,t,"Hit Triage")}))}function ut(e,t){return ot(this,void 0,void 0,(function*(){yield rt(e,t,"Hit Design")}))}function dt(e,t){return ot(this,void 0,void 0,(function*(){yield rt(e,t,"PeptiHit")}))}function ct(){return ot(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return new ke(t).multiView}))}function pt(){return ot(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return new Ze(t).multiView}))}function ht(){return ot(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return yield e.functions.call("Bio:initBio",{}),new nt(t).multiView}))}function mt(){return ot(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(100);return t.name="100 Molecules",t}))}function vt(){return ot(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(5e3);return t.name="5000 Molecules",t}))}function ft(t){return ot(this,void 0,void 0,(function*(){const i=e.data.demo.molecules(t);return i.name="Variable Molecules number",i}))}function gt(t,i){return ot(this,void 0,void 0,(function*(){e.shell.info(t.rowCount),e.shell.info(i)}))}function yt(){return new Xe}function wt(i){return ot(this,void 0,void 0,(function*(){return function(i){return Je(this,void 0,void 0,(function*(){const n=i.filter((e=>e.category===ze)),a=[];for(const i of n){const n=`${i.name[0].toUpperCase()}${i.name.slice(1)}`,s=i.get(null),r=yield Ke(s),l=t.input.userGroups(n);yield o.delay(200),l.value=r,l.onInput.subscribe((()=>{var t;try{const e=(null===(t=l.value)||void 0===t?void 0:t.length)?JSON.stringify(l.value.map((e=>e.id))):"";i.set(null,e)}catch(t){e.shell.error("Error Setting group. Check console for more details"),console.error(t)}})),l.setTooltip(`Selected groups will be granted ${n.toLowerCase()} permissions by default on newly created campaigns`),a.push(l)}const s=o.Widget.fromRoot(t.form(a,{style:{overflow:"visible"}}));return s.root.prepend(t.h1("Default Campaign Sharing",{style:{marginBottom:"6px",marginTop:"6px"}})),setTimeout((()=>{var e;return(null===(e=s.root.parentElement)||void 0===e?void 0:e.style)&&(s.root.parentElement.style.overflow="visible")}),200),s}))}(i)}))}})(),hittriage=n})();
|
|
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"),u=Array.isArray,d=Array.prototype,c=d.concat,p=d.filter,h=d.indexOf,m=d.map,v=d.push,f=d.slice,g=d.some,y=d.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||F(t)||_(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(E(e))return e;var o=e;if(O(e)){var a=n||t;if(!(o=w.test(e)&&F(a)?a.getElementById(e.slice(1).replace(/\\/g,"")):C.test(e)?Z(e):E(a)?a.find(e):O(a)?N(a).find(e):T(e,a)))return}else if(P(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 E(e){return e instanceof x}function I(e){return!!e&&e===e.window}function F(e){return!!e&&9===e.nodeType}function _(e){return!!e&&1===e.nodeType}function P(e){return"function"==typeof e}function O(e){return"string"==typeof e}function V(e){return void 0===e}function L(e){return null===e}function B(e){return!isNaN(parseFloat(e))&&isFinite(e)}function k(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function M(e,t,i){if(i){for(var n=e.length;n--;)if(!1===t.call(e[n],n,e[n]))return e}else if(k(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 U(){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 U(i,N,n);for(var a=0;a<o;a++){var s=e[a];for(var r in s)i&&(u(s[r])||k(s[r]))?(n[r]&&n[r].constructor===s[r].constructor||(n[r]=new s[r].constructor),U(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]=d[Symbol.iterator]),N.isWindow=I,N.isFunction=P,N.isArray=u,N.isNumeric=B,N.isPlainObject=k,N.each=M,S.each=function(e){return M(this,e)},S.empty=function(){return this.each((function(e,t){for(;t.firstChild;)t.removeChild(t.firstChild)}))},N.extend=U,S.extend=function(e){return U(S,e)};var R=/\S+/g;function j(e){return O(e)&&e.match(R)||[]}function D(e,t,n){if(_(e)){var o=i.getComputedStyle(e,null);return n?o.getPropertyValue(t)||void 0:o[t]||e.style[t]}}function $(e,t){return parseInt(D(e,t),10)||0}function H(e,t){return $(e,"border".concat(t?"Left":"Top","Width"))+$(e,"padding".concat(t?"Left":"Top"))+$(e,"padding".concat(t?"Right":"Bottom"))+$(e,"border".concat(t?"Right":"Bottom","Width"))}S.toggleClass=function(e,t){var i=j(e),n=!V(t);return this.each((function(e,o){_(o)&&M(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=j(e);return this.each((function(e,i){_(i)&&M(t,(function(e,t){i.removeAttribute(t)}))}))},S.attr=function(e,t){if(e){if(O(e)){if(arguments.length<2){if(!this[0]||!_(this[0]))return;var i=this[0].getAttribute(e);return L(i)?void 0:i}return V(t)?this:L(t)?this.removeAttr(e):this.each((function(i,n){_(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 _(t)&&t.classList.contains(e)}))},S.get=function(e){return V(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 V(e)?this.get().map((function(e){return _(e)||(t=e)&&3===t.nodeType?e.textContent:"";var t})).join(""):this.each((function(t,i){_(i)&&(i.textContent=e)}))};var q={};function Y(e){return"none"===D(e,"display")}function G(e,t){var i=e&&(e.matches||e.webkitMatchesSelector||e.msMatchesSelector);return!!i&&!!t&&i.call(e,t)}function W(e){return O(e)?function(t,i){return G(i,e)}:P(e)?e:E(e)?function(t,i){return e.is(i)}:e?function(t,i){return i===e}:function(){return!1}}function J(e,t){return t?e.filter(t):e}S.filter=function(e){var t=W(e);return N(p.call(this,(function(e,i){return t.call(e,i,e)})))},S.detach=function(e){return J(this,e).each((function(e,t){t.parentNode&&t.parentNode.removeChild(t)})),this};var z=/^\s*<(\w+)[^>]*>/,K=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,Q={"*":a,tr:r,td:l,th:l,thead:s,tbody:s,tfoot:s};function Z(e){if(!O(e))return[];if(K.test(e))return[o(RegExp.$1)];var t=z.test(e)&&RegExp.$1,i=Q[t]||Q["*"];return i.innerHTML=e,N(i.childNodes).detach().get()}function X(e,t,i,n){for(var o=[],a=P(t),s=n&&W(n),r=0,l=e.length;r<l;r++)if(a){var u=t(e[r]);u.length&&v.apply(o,u)}else for(var d=e[r][t];!(null==d||n&&s(-1,d));)o.push(d),d=i?d[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=W(e);return this.filter((function(i,n){return(!O(e)||_(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=u(e)?m.call(e,String):L(e)?[]:[String(e)];n?M(i.options,(function(e,t){t.selected=o.indexOf(t.value)>=0}),!0):i.checked=o.indexOf(i.value)>=0}else i.value=V(e)||L(e)?"":e})):this[0]&&ee(this[0])},S.is=function(e){var t=W(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 J(N(te(X(this,(function(e){return e.children})))),e)},S.parent=function(e){return J(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 J(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,u){return M(e,(function(e,r){M(N(r),(function(e,r){M(N(t),(function(t,l){var u=i?l:r,d=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,""),M(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,d?u.cloneNode(!0):u,a,s,!d)}),u)}),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(V(e))return this;var t=/<script[\s>]/.test(e);return this.each((function(i,n){_(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 J(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 J(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 J(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(c.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"===D(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"===D(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"===D(o,"position");)o=o.parentNode;if(o!==e&&_(o)){var a=N(o).offset();i.top-=a.top+$(o,"borderTopWidth"),i.left-=a.left+$(o,"borderLeftWidth")}}return{top:i.top-$(e,"marginTop"),left:i.left-$(e,"marginLeft")}}};var 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 ue=/^--/;function de(e){return ue.test(e)}var ce={},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=de(e)),i||me[e]||!B(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=de(e);return e=function(e,t){if(void 0===t&&(t=de(e)),t)return e;if(!ce[e]){var i=re(e),n="".concat(i[0].toUpperCase()).concat(i.slice(1));M("".concat(i," ").concat(he.join("".concat(n," "))).concat(n).split(" "),(function(t,i){if(i in pe)return ce[e]=i,!1}))}return ce[e]}(e,i),arguments.length<2?this[0]&&D(this[0],e,i):e?(t=ve(e,t,i),this.each((function(n,o){_(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):V(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},M([!0,!1],(function(e,t){M(["Width","Height"],(function(e,i){var n="".concat(t?"outer":"inner").concat(i);S[n]=function(n){if(this[0])return I(this[0])?t?this[0]["inner".concat(i)]:this[0].document.documentElement["client".concat(i)]:F(this[0])?we(this[0],i):this[0]["".concat(t?"offset":"client").concat(i)]+(n&&t?$(this[0],"margin".concat(e?"Top":"Left"))+$(this[0],"margin".concat(e?"Bottom":"Right")):0)}}))})),M(["Width","Height"],(function(e,t){var i=t.toLowerCase();S[i]=function(n){if(!this[0])return V(n)?void 0:this;if(!arguments.length)return I(this[0])?this[0].document.documentElement["client".concat(t)]:F(this[0])?we(this[0],t):this[0].getBoundingClientRect()[i]-H(this[0],!e);var o=parseInt(n,10);return this.each((function(t,n){if(_(n)){var a=D(n,"boxSizing");n.style[i]=ve(i,o+("border-box"===a?H(n,!e):0))}}))}}));var be="___cd";S.toggle=function(e){return this.each((function(i,n){if(_(n)){var a=Y(n);(V(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=D(i,"display");return t.body.removeChild(i),q[e]="none"!==n?n:"block"}(n.tagName))):a||(n[be]=D(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 Ee(e){return e[Ce]=e[Ce]||{}}function Ie(e,t){return!t||!g.call(t,(function(t){return e.indexOf(t)<0}))}function Fe(e,t,i,n,o){var a=Ee(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||!Ie(s,i)||n&&n!==r)return!0;e.removeEventListener(t,l)})));else for(t in a)Fe(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&&P(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(V(e))this.each((function(e,t){(_(t)||F(t)||I(t))&&Fe(t)}));else if(O(e))P(t)&&(i=t,t=""),M(j(e),(function(e,o){var a=Ne(o),s=a[0],r=a[1],l=Se(s);n.each((function(e,n){(_(n)||F(n)||I(n))&&Fe(n,l,r,t,i)}))}));else for(var o in e)this.off(o,e[o]);return this},S.remove=function(e){return J(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)||(V(t)||L(t)?t="":V(i)?(i=t,t=""):(n=i,i=t,t="")),P(n)||(n=i,i=void 0),n?(M(j(e),(function(e,s){var r=Ne(s),l=r[0],u=r[1],d=Se(l),c=l in Te,p=l in Ae;d&&a.each((function(e,a){if(_(a)||F(a)||I(a)){var s=function(e){if(e.target["___i".concat(e.type)])return e.stopImmediatePropagation();if((!e.namespace||Ie(u,e.namespace.split(".")))&&(t||!(p&&(e.target!==a||e.___ot===d)||c&&e.relatedTarget&&a.contains(e.relatedTarget)))){var r=a;if(t){for(var l=e.target;!G(l,t);){if(l===a)return;if(!(l=l.parentNode))return}r=l}Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return r}}),Object.defineProperty(e,"delegateTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(e,"data",{configurable:!0,get:function(){return i}});var h=n.call(r,e,e.___td);o&&Fe(a,d,u,t,s),!1===h&&(e.preventDefault(),e.stopPropagation())}};s.guid=n.guid=n.guid||N.guid++,function(e,t,i,n,o){var a=Ee(e);a[t]=a[t]||[],a[t].push([i,n,o]),e.addEventListener(t,o)}(a,d,u,t,s)}}))})),this):this},S.one=function(e,t,i,n){return this.on(e,t,i,n,!0)};var _e=/\r?\n/g,Pe=/file|reset|submit|button|image/i,Oe=/radio|checkbox/i;S.serialize=function(){var e="";return this.each((function(t,i){M(i.elements||[i],(function(t,i){if(!(i.disabled||!i.name||"FIELDSET"===i.tagName||Pe.test(i.type)||Oe.test(i.type)&&!i.checked)){var n=ee(i);V(n)||M(u(n)?n:[n],(function(t,n){e+=function(e,t){return"&".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t.replace(_e,"\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}\n\n.hit-design-stage-editing-dialog {\n z-index: 10000 !important;\n}\n\n.hit-design-groupped-campaigns-table .d4-accordion-pane-content.expanded {\n margin: 0 !important;\n}","",{version:3,sources:["webpack://./src/app/hit-design-views/utils.css"],names:[],mappings:"AAAA;IACI,eAAe;AACnB;;AAEA;IACI,yBAAyB;AAC7B;;AAEA;IACI,oBAAoB;AACxB",sourcesContent:["img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}\n\n.hit-design-stage-editing-dialog {\n z-index: 10000 !important;\n}\n\n.hit-design-groupped-campaigns-table .d4-accordion-pane-content.expanded {\n margin: 0 !important;\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 u=0;u<e.length;u++){var d=[].concat(e[u]);n&&s[d[0]]||(void 0!==a&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=a),i&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=i):d[2]=i),o&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=o):d[4]="".concat(o)),t.push(d))}},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],u=n.base?l[0]+n.base:l[0],d=a[u]||0,c="".concat(u," ").concat(d);a[u]=d+1;var p=i(c),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:c,updater:m,references:1})}s.push(c)}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),u=0;u<a.length;u++){var d=i(a[u]);0===t[d].references&&(t[d].updater(),t.splice(d,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,{HTPackage:()=>at,_package:()=>st,demoFileIngest:()=>mt,demoFileIngest1:()=>vt,demoFileIngest2:()=>ft,demoFileSubmit:()=>gt,gasteigerCellRenderer:()=>yt,hitDesignApp:()=>pt,hitDesignAppTreeBrowser:()=>ut,hitTriageApp:()=>ct,hitTriageAppTreeBrowser:()=>lt,htPackageSettingEditor:()=>wt,peptiHitApp:()=>ht,peptiHitAppTreeBrowser:()=>dt});const e=grok,t=ui,o=DG,a="campaignId",s="campaignId",r="enriched_table.csv",l="campaign.json",u="HitTriageDataSource",d="HitTriageSubmitFunction",c="Selected hits",p="Stage",h="Molecule",m="Helm",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 Campaign",E="New Campaign",I="No Information",F={script:"script",function:"function-package",query:"data-query"},_="HDCampaignsGrouping";var P;!function(e){e.None="None",e.Template="Template",e.Status="Status",e.Author="Author",e.LastModifiedUser="Last Modified User"}(P||(P={}));var O=i(72),V=i.n(O),L=i(825),B=i.n(L),k=i(659),M=i.n(k),U=i(56),R=i.n(U),j=i(540),D=i.n(j),$=i(113),H=i.n($),q=i(558),Y={};Y.styleTagTransform=H(),Y.setAttributes=R(),Y.insert=M().bind(null,"head"),Y.domAPI=B(),Y.insertStyleElement=D(),V()(q.A,Y),q.A&&q.A.locals&&q.A.locals;var G=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};const W=e=>`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`;function J(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 z(i,n,o,a){var s;const r=t.breadcrumbs([n,o]),l=r.onPathClick.subscribe((e=>{1===e.length&&(l.unsubscribe(),K(i),a())})),u=null===(s=e.shell.v.ribbonMenu.root.parentElement)||void 0===s?void 0:s.getElementsByClassName("d4-ribbon-name")[0];return u&&(u.textContent="",u.appendChild(r.root)),{breadcrumbs:r,sub:l}}function K(e){const t=e.getRibbonPanels();(null==t?void 0:t.length)&&(t.pop(),e.setRibbonPanels(t))}function Q(e){return e.reduce(((e,t)=>e||t.reduce(((e,t)=>e||t.classList.contains("hit-design-submit-button")||Array.from(t.children).some((e=>e.classList.contains("hit-design-submit-button")))),!1)),!1)}function Z(e,t,i){return G(this,void 0,void 0,(function*(){if(0===i.rowCount)return;if(!e.col(t))throw new Error("There is no molecule column in dataframe");let n=i.col(w);if(n||(yield i.meta.detectSemanticTypes(),n=i.columns.bySemType(o.SEMTYPE.MOLECULE)),!n)throw new Error("There is no original molecule column in query result dataframe");const a=i.columns.names().filter((e=>e!==w));e.join(i,[t],[n.name],void 0,a,void 0,!0)}))}function X(t,i){return G(this,void 0,void 0,(function*(){const n=(yield st.files.list(`${t}/campaigns`)).filter((e=>-1===i.indexOf(e.name))),o={};for(const i of n)try{const n=JSON.parse(yield st.files.readAsText(`${t}/campaigns/${i.name}/${l}`));if(n.authorUserId&&n.permissions&&!(yield ie(n.authorUserId,n.permissions)))continue;if(n.authorUserId&&!n.authorUserFriendlyName){const t=yield e.dapi.users.find(n.authorUserId);t&&(n.authorUserFriendlyName=t.friendlyName)}o[n.name]=n}catch(e){continue}return o}))}function ee(t,i){return G(this,void 0,void 0,(function*(){var n;const a=o.User.current().id,s=null===(n=o.User.current().group)||void 0===n?void 0:n.id;if(t===a)return!0;for(const t of i){const i=yield e.dapi.groups.find(t);if(i)if(i.personal){const t=yield e.dapi.groups.getUser(i);if((null==t?void 0:t.id)===a)return!0}else if(s&&i.members.length>0&&i.members.some((e=>e.id===s)))return!0}return!1}))}function te(e,t){return G(this,void 0,void 0,(function*(){return ee(e,t.edit)}))}function ie(e,t){return G(this,void 0,void 0,(function*(){return ee(e,Array.from(new Set([...t.view,...t.edit])))}))}const ne=(e,t)=>{var i,n,o,a;switch(e){case P.Template:return null!==(n=null===(i=t.template)||void 0===i?void 0:i.key)&&void 0!==n?n:t.templateName;case P.Status:return t.status;case P.Author:return null!==(o=t.authorUserFriendlyName)&&void 0!==o?o:I;case P.LastModifiedUser:return null!==(a=t.lastModifiedUserName)&&void 0!==a?a:I;default:return""}},oe={String:o.TYPE.STRING,Number:o.TYPE.FLOAT,Boolean:o.TYPE.BOOL,Date:o.TYPE.DATE_TIME,Molecule:o.SEMTYPE.MOLECULE};var ae=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())}))},se=i(233),re=i.n(se),le=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 ue(i,n,o,a,s){return le(this,void 0,void 0,(function*(){var r,l,u,d,c,p,h,m,v,f,w,b,C,A,T,x,S,N,E,I,_;const P=i.computeFunctions,O=[];P.functions.filter((({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).forEach((e=>{var t,i,n,o;O.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==a?void 0:a.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:{}})})),P.scripts.filter((({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).forEach((e=>{var t,i,n,o;O.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==a?void 0:a.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:{}})})),P.queries.filter((e=>e.inputs.length>0&&"list"===e.inputs[0].propertyType)).forEach((e=>{var t,i,n,o;O.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==a?void 0:a.compute)||void 0===t?void 0:t.queries)||void 0===i?void 0:i.find((t=>t.id===e.id)))||void 0===n?void 0:n.args)&&void 0!==o?o:{}})}));let V=!!(null===(l=null===(r=null==a?void 0:a.compute)||void 0===r?void 0:r.descriptors)||void 0===l?void 0:l.enabled)||s;const L=t.div([],{classes:"hit-triage-compute-dialog-host"}),B=[],k=t.tree();try{const q=yield e.chem.descriptorsTree();function Y(e,t){const i=t.group(e,null,!1);return i.enableCheckBox(!1),i}k.root.classList.add("hit-triage-compute-dialog-descriptors-group");const G=Object.keys(q),W=null!==(c=null===(d=null===(u=null==a?void 0:a.compute)||void 0===u?void 0:u.descriptors)||void 0===d?void 0:d.args)&&void 0!==c?c:[];for(const J of G){const z=Y(J,k);for(const K of q[J].descriptors){const Q=z.item(K.name,K);B.push(Q),Q.enableCheckBox(W.includes(K.name))}}}catch(Z){console.error(Z),V=!1}const M="Descriptors",U={[M]:M},R=V?{[M]:k.root}:{},j={},D={[M]:!1};D[M]=!!(null===(h=null===(p=null==a?void 0:a.compute)||void 0===p?void 0:p.descriptors)||void 0===h?void 0:h.enabled)&&(null===(f=null===(v=null===(m=null==a?void 0:a.compute)||void 0===m?void 0:m.descriptors)||void 0===v?void 0:v.args)||void 0===f?void 0:f.length)>0;for(const X of O)try{const ee=X.func,te=ee.prepare(X.args),ie=ee.type===F.function?`${ee.package.name}:${ee.name}`:ee.type===F.script?`${g}:${null!==(w=ee.name)&&void 0!==w?w:""}:${ee.id}`:`${y}:${null!==(b=ee.name)&&void 0!==b?b:""}:${ee.id}`;j[ie]=te;const ne=t.div(),oe=yield te.buildEditor(ne,{condensed:!1});ne.classList.add("oy-scroll"),ne.style.marginLeft="15px",ne.style.removeProperty("max-width"),R[null!==(C=ee.friendlyName)&&void 0!==C?C:ee.name]=ne,U[null!==(A=ee.friendlyName)&&void 0!==A?A:ee.name]=ie,D[ie]=null!==(_=(null===(x=null===(T=null==a?void 0:a.compute)||void 0===T?void 0:T.functions)||void 0===x?void 0:x.some((e=>{var t;return X.func.type===F.function&&e.name===X.func.name&&e.package===(null===(t=X.func.package)||void 0===t?void 0:t.name)})))||(null===(N=null===(S=null==a?void 0:a.compute)||void 0===S?void 0:S.scripts)||void 0===N?void 0:N.some((e=>e.id===ee.id)))||(null===(I=null===(E=null==a?void 0:a.compute)||void 0===E?void 0:E.queries)||void 0===I?void 0:I.some((e=>e.id===ee.id))))&&void 0!==_&&_,ne.children[0].style.display="none",ee.type!==F.query&&(ne.children[1].style.display="none"),oe.forEach((e=>{var t,i;(null===(t=e.property)||void 0===t?void 0:t.name)&&Object.keys(X.args).includes(null===(i=e.property)||void 0===i?void 0:i.name)&&(e.value=X.args[e.property.name]),e.fireChanged()}))}catch(ae){console.error(ae);continue}const $=t.tabControl(R,!0);function H(){const e={descriptors:[],externals:{},scripts:{},queries:{}};e.descriptors=D[M]?B.filter((e=>e.checked)).map((e=>e.value.name)):[];const t=Object.entries(j).filter((([e,t])=>D[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 $.onTabChanged.subscribe((()=>{try{$.currentPane.content.style.removeProperty("max-width")}catch(e){}})),$.header.style.overflow="scroll",$.root.style.width="100%",$.root.style.minWidth="350px",L.appendChild($.root),$.panes.forEach((e=>{const i=t.input.bool("",{value:D[U[e.name]],onValueChanged:t=>{D[U[e.name]]=!!t,t?re()(e.content).find("input").removeAttr("disabled"):re()(e.content).find("input").attr("disabled","true")}});i.setTooltip("Toggle calculation of this function"),e.header.appendChild(i.root),e.header.classList.add("hit-triage-compute-dialog-pane-header")})),s&&t.dialog("Compute").add(L).onOK((()=>H())).onCancel(o).show(),{root:L,okProxy:H}}))}const de=rxjs;class ce{constructor(e,i=[],n={}){this.onItemChanged=new de.Subject,this.onAddingItemChanged=new de.Subject,this.onItemAdded=new de.Subject,this.onItemRemoved=new de.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.properties=e,this.options=Object.assign(Object.assign({},this.options),n),this._root=t.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=i,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,i,n,o,a;if(t.empty(this._root),!this.options.horizontalInputNames)for(const n of this.properties){let o=null!==(e=n.caption)&&void 0!==e?e:n.name;(null===(i=this.options.customLabels)||void 0===i?void 0:i[n.name])&&(o=this.options.customLabels[n.name]);const a=t.divText(o);a.style.fontWeight="bold",this._root.appendChild(a)}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!==(a=null===(o=(n=this.options).newItemFunction)||void 0===o?void 0:o.call(n))&&void 0!==a?a:void 0,!0);for(const t of e)this._root.appendChild(t)}}getItemDiv(e={},i){var n,a;const s=[],r={};let l=null;for(const u of this.properties){void 0===e[u.name]&&(e[u.name]=null);const d=(null===(n=this.options.customInputs)||void 0===n?void 0:n[u.name])?this.options.customInputs[u.name](e):t.input.forProperty(u,e),c=null===(a=this.options.validators)||void 0===a?void 0:a[u.name];c&&d.addValidator(c),s.push(this.options.horizontalInputNames?d.root:this.hideLabel(d.root)),u.propertyType!==o.TYPE.BOOL&&"color"!==u.name.toLowerCase()&&d.input&&(d.input.style.width="100%"),r[u.name]=d,d.onChanged.subscribe((()=>{e[u.name]=d.value,i?this.onAddingItemChanged.next({item:e,fieldName:u.name}):this.onItemChanged.next({item:e,fieldName:u.name})})),d.root.style.alignItems="center",l=d}let u=null;if(i)u=t.icons.add((()=>{const e=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(r).forEach((t=>{e[t]=r[t].value})),this._items.push(e),this.onItemAdded.next(e),this.render()}),this.options.addButtonTooltip);else{if(!this.options.allowRemove)return s;u=t.icons.delete((()=>{this._items.splice(this._items.indexOf(e),1),this.onItemRemoved.next(e),this.render()}),this.options.removeButtonTooltip)}return l&&l.addOptions?l.addOptions(u):null==l||l.root.appendChild(u),u.style.color="#2083d5",s}hideLabel(e){return e.getElementsByTagName("label")[0]&&e.removeChild(e.getElementsByTagName("label")[0]),e}hasErrors(){return this._root.querySelectorAll(".d4-invalid").length>0}}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())}))};function he(){const i=o.Property.fromOptions({name:"layout",caption:"Layout",type:"file"}),n=o.InputBase.forProperty(i);let a=null,s=null,r=null,l=null;return n.onChanged.subscribe((t=>pe(this,void 0,void 0,(function*(){const t=n.value;if(t){try{const i=!!t.fullPath&&(yield e.dapi.files.exists(t.fullPath));r=i?t.fullPath:null}catch(e){r=null}try{const e=yield t.readAsString(),i=o.ViewLayout.fromJson(e);i?(a=i,s=i.viewState,l=null):(a=null,s=null,r=null,l="Invalid layout file")}catch(e){a=null,s=null,r=null,l="Invalid layout file"}n.input.classList[l?"add":"remove"]("d4-invalid")}else a=null,s=null,r=null})))),t.tooltip.bind(n.root,(()=>l||"Select a layout file")),{dataFileInput:n,getLayout:()=>a,getLayoutViewState:()=>s,getLocalFilePath:()=>r}}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())}))};function ve(i,n){return me(this,void 0,void 0,(function*(){var a,s;const r=(yield st.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5))),l=[];for(const e of r){const t=JSON.parse(yield st.files.readAsText(`Hit Triage/templates/${e}.json`));l.push(t.key)}const c=o.Func.find({tags:[d]}),p={};c.forEach((e=>{var t;p[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const h=t.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=he(),v=t.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),f=t.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),w=t.input.string("Name",{value:"",onValueChanged:e=>{""===e||r.includes(e)?(w.root.style.borderBottom="1px solid red",v.style.opacity="100%"):(w.root.style.borderBottom="none",v.style.opacity="0%")}}),C=t.input.string("Key",{value:"",onValueChanged:e=>{""===e||l.includes(e)?(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 ue(i,(e=>{A=e}),(()=>null),{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},!1);x.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(n).length&&o.Func.find({tags:[u]}).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const N=Object.keys(n),E=t.input.choice(b,{value:N[0],items:N}),I=t.input.choice("Ingest using",{value:"Query",items:["Query","File"],onValueChanged:e=>{E.root.style.display="Query"===e?"block":"none"}}),F=fe(),_=t.div([t.h2("Details"),t.div([w,v]),t.div([C,f]),I.root,E.root,m.dataFileInput,F.fieldsDiv,t.h2("Compute"),x.root,t.h2("Submit"),h.root],"ui-form"),P=t.buttonsInput([]),O=null!==(s=null===(a=P.getElementsByClassName("ui-input-editor"))||void 0===a?void 0:a[0])&&void 0!==s?s:P;_.appendChild(P);const V=new Promise((e=>{const i=t.button(S,(()=>e()));O.appendChild(i)})),L=new Promise((i=>{const n=t.bigButton(T,(()=>function(){return me(this,void 0,void 0,(function*(){var t,n,o,a,s,r,l,u;if(x.okProxy(),"100%"===v.style.opacity)return void e.shell.error("Template name is empty or already exists");const d=h.value?p[h.value]:void 0,c=Object.assign(Object.assign({name:w.value,key:C.value,campaignFields:F.getFields(),dataSourceType:null!==(t=I.value)&&void 0!==t?t:"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}}))}},d?{submit:{fName:d.name,package:d.package.name}}:{}),{queryFunctionName:"Query"===I.value&&null!==(u=E.value)&&void 0!==u?u:void 0});var f;f=c,st.files.writeAsText(`Hit Triage/templates/${f.name}.json`,JSON.stringify(f)),e.shell.info("Template created successfully"),i(c)}))}()));O.appendChild(n)}));return{root:_,template:L,cancelPromise:V}}))}function fe(e){const i=[o.Property.fromOptions({name:"Name",type:o.TYPE.STRING}),o.Property.fromOptions({name:"Type",type:o.TYPE.STRING,choices:Object.keys(oe)}),o.Property.fromOptions({name:"Required",type:o.TYPE.BOOL})],n=new ce(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=t.h2("Additional fields");t.tooltip.bind(s,"Additional fields to be filled by user for each campaign");const r=t.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:t.div([r])}}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 extends o.ViewBase{constructor(e){super(),this.deletedCampaigns=[],this.app=e}get template(){return this.app.template}onActivated(){}onReset(){}process(){return ge(this,void 0,void 0,(function*(){}))}deleteCampaign(e,t){return ge(this,void 0,void 0,(function*(){yield st.files.delete(`${e}/campaigns/${t}`)}))}}var we=i(677),be={};be.styleTagTransform=H(),be.setAttributes=R(),be.insert=M().bind(null,"head"),be.domAPI=B(),be.insertStyleElement=D(),V()(we.A,be),we.A&&we.A.locals&&we.A.locals;var Ce;!function(i){let n,o;!function(e){e.vert=function(e){return t.divV(e.map((e=>t.render(e))),{classes:"u2-panel"})},e.horz=function(e){return t.divH(e.map((e=>t.render(e))),{classes:"u2-panel"})}}(n=i.panels||(i.panels={})),i.appHeader=function(e){const i=t.iconImage("",e.iconPath);return re()(i).addClass("ui-app-header-icon").css("margin-right","20px"),n.horz([i,n.vert([t.markdown(e.description),e.learnMoreUrl?t.link("Learn more",e.learnMoreUrl):null])])},function(i){i.runAsync=function(i,n){return o=this,a=void 0,r=function*(){t.setUpdateIndicator(i,!0);try{return yield n()}catch(t){e.log.error(t)}finally{t.setUpdateIndicator(i,!1)}},new((s=void 0)||(s=Promise))((function(e,t){function i(e){try{l(r.next(e))}catch(e){t(e)}}function n(e){try{l(r.throw(e))}catch(e){t(e)}}function l(t){var o;t.done?e(t.value):(o=t.value,o instanceof s?o:new s((function(e){e(o)}))).then(i,n)}l((r=r.apply(o,a||[])).next())}));var o,a,s,r}}(o=i.tools||(i.tools={}))}(Ce||(Ce={}));var Ae=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 Te={view:[o.Group.defaultGroupsIds["All users"]],edit:[o.Group.defaultGroupsIds["All users"]]};class xe{constructor(e){this.permissions=null!=e?e:Te,this.editGroupsInput=t.input.userGroups("Can Edit"),this.editGroupsInput.root.style.marginBottom="16px",this.viewGroupsInput=t.input.userGroups("Can View")}getDialogContent(){return Ae(this,void 0,void 0,(function*(){const i=[],n=[];for(const t of this.permissions.view){const n=yield e.dapi.groups.find(t);n&&i.push(n)}for(const t of this.permissions.edit){const i=yield e.dapi.groups.find(t);i&&n.push(i)}return this.editGroupsInput.value=n,this.viewGroupsInput.value=i,t.divV([this.viewGroupsInput.root,this.editGroupsInput.root])}))}show(e){return Ae(this,void 0,void 0,(function*(){var i;const n=yield this.getDialogContent(),o=t.dialog("Edit Permissions").add(n).onOK((()=>{const t=new Set(this.editGroupsInput.value.map((e=>e.id))),i=new Set(this.viewGroupsInput.value.map((e=>e.id)));this.permissions.edit=Array.from(t),t.forEach((e=>i.add(e))),this.permissions.view=Array.from(i),0===this.permissions.view.length&&(this.permissions.view=Te.view),e(this.permissions)}));(null===(i=n.parentElement)||void 0===i?void 0:i.style)&&(n.parentElement.style.overflow="visible"),o.show()}))}}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())}))};class Ne extends ye{constructor(t){super(t),this.readmePath=st.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 Se(this,void 0,void 0,(function*(){t.setUpdateIndicator(this.root,!0);try{const i=t.h1(N),n=t.h1(E,{style:{marginLeft:"10px"}}),o=Ce.appHeader({iconPath:st.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=t.div(),s=t.div([],{classes:"ui-form"}),r=yield this.getCampaignsTable();yield this.startNewCampaign(a,s,e),re()(this.root).empty(),this.root.appendChild(t.div([t.divV([o,i],{style:{marginLeft:"10px"}}),r,n,s,a])),this.app.resetBaseUrl()}catch(e){throw t.setUpdateIndicator(this.root,!1),e}finally{t.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(e,i,n){return Se(this,void 0,void 0,(function*(){var o;const a=(yield st.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5)));n&&!a.includes(n.name)&&a.push(n.name);const s=()=>Se(this,void 0,void 0,(function*(){const t=r.value,i=n&&n.name===t?n:JSON.parse(yield st.files.readAsText("Hit Triage/templates/"+t+".json")),o=yield this.getNewCampaignAccordeon(i,e);re()(e).empty(),e.className="ui-form",e.appendChild(o)})),r=t.input.choice("Template",{value:null!==(o=null==n?void 0:n.name)&&void 0!==o?o:a[0],items:a,onValueChanged:()=>Se(this,void 0,void 0,(function*(){yield s()}))}),l=t.icons.add((()=>Se(this,void 0,void 0,(function*(){t.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),t.setUpdateIndicator(this.root,!1)}))),C);r.addOptions(l),yield s(),re()(i).empty(),i.appendChild(r.root)}))}checkCampaign(e){return Se(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 st.files.exists(`Hit Triage/campaigns/${n}/${l}`)))return;const o=JSON.parse(yield st.files.readAsText(`Hit Triage/campaigns/${n}/${l}`));if(o){if(o.authorUserId&&o.permissions&&!(yield ie(o.authorUserId,o.permissions)))return void this.app.setBaseUrl();this.app.campaign=o}const s=JSON.parse(yield st.files.readAsText(`Hit Triage/templates/${o.templateName}.json`));return this.app.setTemplate(s,o.filters,n,o.ingest),e&&J(a,e),o}))}getCampaignsTable(){return Se(this,void 0,void 0,(function*(){const e=yield X("Hit Triage",this.deletedCampaigns),i=e=>{var i,n;const a=t.icons.delete((()=>Se(this,void 0,void 0,(function*(){t.dialog("Delete campaign").add(t.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK((()=>Se(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Triage",e.name),this.deletedCampaigns.push(e.name),yield this.init()})))).show()}))),"Delete campaign");return a.style.display="none",te(null!==(i=e.authorUserId)&&void 0!==i?i:o.User.current().id,null!==(n=e.permissions)&&void 0!==n?n:Te).then((e=>{e&&(a.style.display="inline-block")})),a},n=Object.values(e),a=t.table(n,(e=>[t.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.filteredRowCount,e.status,i(e)]),["Name","Created","Total","Selected","Status",""]);return a.style.color="var(--grey-5)",a}))}setCampaign(e){return Se(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(i,n){return Se(this,void 0,void 0,(function*(){t.setUpdateIndicator(n,!0);const{root:a,promise:s,cancelPromise:r}=yield function(i,n){return ae(this,void 0,void 0,(function*(){var a,s;const r=t.divText("",{style:{color:"red"}});let l=null;const d=()=>ae(this,void 0,void 0,(function*(){try{if(l=c.value,!l)return;if(yield l.meta.detectSemanticTypes(),!l.columns.bySemType(o.SEMTYPE.MOLECULE))return void(r.innerText="No molecules column found");r.innerText=""}catch(e){r.innerText="Error parsing file"}})),c=t.input.table("Dataframe",{onValueChanged:d});yield d();const p=t.div([c,r]);0===Object.keys(n).length&&o.Func.find({tags:[u]}).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));let h=null;const m=()=>ae(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=t.div([]),f=t.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=t.div([f,v]);g.style.display="none";const y=t.div([p,g]),w=i.campaignFields.map((e=>e.type===o.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:o.SEMTYPE.MOLECULE}):e)).map((e=>o.Property.fromOptions(Object.assign({name:e.name,type:oe[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),C={},T=w.length?t.input.form(C,w):t.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=t.div([y,...w.length?[T]:[]]),N=t.buttonsInput([]);return x.appendChild(N),{promise:new Promise((o=>{const a=()=>ae(this,void 0,void 0,(function*(){if("File"===i.dataSourceType){if(!l)return void e.shell.error("No file selected");const t=l;t.name=l.name,o({df:t,type:"File",campaignProps:C})}else{const t=n[f.value];if(!t)return void e.shell.error("No function selected");const i={};Object.entries(h.inputs).forEach((([e,t])=>{i[e]=t}));const a=yield t.apply(i);o({df:a,type:"Query",campaignProps:C})}})),s=t.bigButton(A,(()=>a()));N.appendChild(s)})),root:x,cancelPromise:new Promise((e=>{t.button(S,(()=>e()))}))}}))}(i,this.dataSourceFunctionsMap);return t.setUpdateIndicator(n,!1),s.then((e=>Se(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 Se(this,void 0,void 0,(function*(){const t=yield ve(this.app,this.dataSourceFunctionsMap),i=new o.ViewBase,n=e.shell.v;i.name="New Template",i.root.appendChild(t.root),i.parentCall=this.app.parentCall,e.shell.addView(i),i.path=new URL(this.app.baseUrl).pathname+"/new-template",i.parentView=n;const{sub:a}=z(e.shell.v,"Hit Triage",C,(()=>{e.shell.v=n,i.close()}));t.template.then((t=>Se(this,void 0,void 0,(function*(){yield this.init(t),i.close(),K(i),e.shell.v=n,a.unsubscribe()})))),t.cancelPromise.then((()=>{a.unsubscribe(),i.close(),e.shell.v=n}))}))}}class Ee extends ye{constructor(e){super(e),this.name="Submit"}render(){return t.empty(this.root),t.divV([t.h1("Summary"),t.div([t.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){return t=this,i=void 0,a=function*(){var t;const i=null===(t=this.app.template)||void 0===t?void 0:t.submit;if(!i)return;const n=o.Func.find({name:i.fName,package:i.package})[0];if(!n)return void e.shell.error(`Function ${i.fName} not found.`);const a=o.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield n.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((n=void 0)||(n=Promise))((function(e,o){function s(e){try{l(a.next(e))}catch(e){o(e)}}function r(e){try{l(a.throw(e))}catch(e){o(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(s,r)}l((a=a.apply(t,i||[])).next())}));var t,i,n,a}}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 Fe{get appName(){return this._appName}constructor(e,t){this.parentCall=e,this.isJoining=!1,this.hasEditPermission=!1,this._appName=t;const i=o.Func.find({tags:["HitTriageFunction"]}),n=i.filter((e=>e.type===F.function)),a=i.filter((e=>e.type===F.script)),s=i.filter((e=>e.type===F.query));this.resetBaseUrl(),this.computeFunctions={functions:n,scripts:a,queries:s}}setCanEdit(e){return Ie(this,void 0,void 0,(function*(){e.authorUserId&&e.permissions?this.hasEditPermission=yield te(e.authorUserId,e.permissions):this.hasEditPermission=!0}))}resetBaseUrl(){const e=window.location.href,t=new URL(e);this.baseUrl=t.origin+t.pathname}getFilterType(e){const t=this.dataFrame.col(e);return(null==t?void 0:t.semType)===o.SEMTYPE.MOLECULE?o.FILTER_TYPE.SUBSTRUCTURE:(null==t?void 0:t.type)===o.COLUMN_TYPE.BOOL?o.FILTER_TYPE.BOOL_COLUMNS:(null==t?void 0:t.type)===o.COLUMN_TYPE.STRING?o.FILTER_TYPE.CATEGORICAL:o.FILTER_TYPE.HISTOGRAM}download(e,t,i=!1){const n=document.createElement("a"),a=o.DataFrame.fromColumns(e.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv({filteredRowsOnly:i});n.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),n.setAttribute("download",t+".csv"),n.click()}getNewCampaignName(e,t){return Ie(this,void 0,void 0,(function*(){const i=(yield st.files.list(e)).map((e=>e.name)).filter((e=>e.startsWith(`${t}-`)&&!!parseInt(e.substring(t.length+1))));if(0===i.length)return t+"-1";const n=i.map((e=>e.substring(t.length+1))).filter(Boolean).map((e=>parseInt(e,10))).sort(((e,t)=>e-t));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,t,i,n){var a,s,r,l;const u=i;e.col(i).name=n,i=n;const d=null===(s=null===(a=e.col(i))||void 0===a?void 0:a.toList())||void 0===s?void 0:s.filter((e=>!!e)).map((e=>o.chem.convert(e,o.chem.Notation.Unknown,o.chem.Notation.Smiles))),c=null===(l=null===(r=t.col(n))||void 0===r?void 0:r.toList())||void 0===l?void 0:l.filter((e=>!!e)).map((e=>o.chem.convert(e,o.chem.Notation.Unknown,o.chem.Notation.Smiles)));if(!d||!c)throw new Error("Molecule column not found");const p=new Map;c.forEach(((e,t)=>p.set(e,t))),this.isJoining=!0;try{const i=[];for(const n of e.columns)if(!t.columns.contains(n.name)){const e=t.columns.addNew(n.name,n.type);n.semType&&(e.semType=n.semType),i.push(n.name)}for(let n=0;n<d.length;n++)if(p.has(d[n])){if(i.length>0){const o=p.get(d[n]);for(const a of i){const i=e.col(a).get(n);t.col(a).set(o,i,!1)}}}else{t.rows.addNew(null,!0);for(const i of e.columns){const e=i.get(n);t.col(i.name).set(t.rowCount-1,e,!1)}}}finally{setTimeout((()=>{this.isJoining=!1}),500),e.col(i).name=u}return t}}Fe.molFileExtReaders=["sdf","mol","smi","mol2"].map((e=>{const t=o.Func.find({tags:["file-handler"]}).find((t=>{var i;return(null===(i=null==t?void 0:t.options)||void 0===i?void 0:i.ext)&&"string"==typeof t.options.ext&&t.options.ext.split(",").includes(e)}));return{ext:e,handlerFunc:t}})).filter((e=>e.handlerFunc));var _e=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))},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())}))};function Oe(t,i,n){return Pe(this,arguments,void 0,(function*(t,i,n,a=[],s=[]){const r=o.TaskBarProgressIndicator.create("Calculating ..."),l=t.map((e=>st.convertToSmiles(e))),u=o.Column.fromStrings(h,l),d=o.DataFrame.fromColumns([u]);d.name="HD cell values",yield d.meta.detectSemanticTypes();try{i.length&&(yield e.chem.descriptors(d,u.name,i))}catch(e){console.error("Descriptors calculation error",e)}for(const e of n)try{const t=e.args,i=o.Func.find({package:e.package,name:e.name});if(!i.length||!i[0]){console.warn(`Function ${e.name} from package ${e.package} is not found`);continue}const n=i[0],a=n.inputs[0].name,s=n.inputs[1].name;yield n.apply(Object.assign(Object.assign({},t),{[a]:d,[s]:u.name}))}catch(e){console.error(e);continue}for(const e of a){const t=e.args;try{const i=o.Func.find({name:e.name}).filter((t=>t.type===F.script&&t.id===e.id))[0];if(i){const e=i.inputs[0].name,n=i.inputs[1].name,o=yield i.apply(Object.assign(Object.assign({},t),{[e]:d,[n]:u.name}));if(o&&o.rowCount===d.rowCount&&"python"===i.language)for(const e of o.columns)e.name=d.columns.getUnusedName(e.name),d.columns.add(e)}}catch(e){console.error(e)}}for(const e of s){const t=e.args;try{const i=o.Func.find({name:e.name}).filter((t=>t.type===F.query&&t.id===e.id))[0];if(i){const e=i.inputs[0].name,n=[l],o=yield i.apply(Object.assign(Object.assign({},t),{[e]:n}));if(!o||0===o.rowCount)continue;yield Z(d,h,o)}}catch(e){console.error(e)}}r.close();const c=d.col(h);for(let e=0;e<c.length;e++)c.set(e,t[e],!1);return d}))}function Ve(e){let t=0;if(e.length>1)for(const i of e.toList()){if(!i||!i.startsWith(f[0])||i.length!==f.length)continue;const e=parseInt(i.substring(1));isNaN(e)||(t=Math.max(e,t))}return`V${"".concat(...new Array(f.length-1-(t+1).toString().length).fill("0"))}${t+1}`}function Le(t,i,n){return Pe(this,void 0,void 0,(function*(){var a,s;const r=o.TaskBarProgressIndicator.create("Calculating ..."),l=i.col(n);if(!l)throw new Error("There is no molecule column in dataframe");const u=`~${n}.canonicalSmiles`,d=i.columns.getOrCreate(u,o.TYPE.STRING);d.semType=o.SEMTYPE.MOLECULE;const c=l.toList();for(let e=0;e<c.length;e++){if(l.isNone(e))continue;const t=c[e];if(!t)continue;const i=st.convertToSmiles(t);d.set(e,i,!1)}try{t.descriptors&&t.descriptors.length>0&&(yield e.chem.descriptors(i,u,t.descriptors))}catch(e){console.error("Descriptors calculation error",e)}for(const e of Object.keys(t.externals))try{const n=t.externals[e],a=o.Func.find({package:e.split(":")[0],name:e.split(":")[1]})[0],s=a.inputs[0].name,r=a.inputs[1].name;n&&(yield a.apply(Object.assign(Object.assign({},n),{[s]:i,[r]:u})))}catch(e){console.error(e)}for(const e of Object.keys(null!==(a=t.scripts)&&void 0!==a?a:{})){const n=t.scripts[e];if(n){const t=e.split(":"),a=t[2];if(!a)continue;try{const e=t[1],s=o.Func.find({name:e}).filter((e=>e.type===F.script&&e.id===a))[0];if(!s)continue;const r=s.inputs[0].name,l=s.inputs[1].name,d=yield s.apply(Object.assign(Object.assign({},n),{[r]:i,[l]:u}));if(d&&d.rowCount===i.rowCount&&"python"===s.language)for(const e of d.columns)e.name=i.columns.getUnusedName(e.name),i.columns.add(e)}catch(e){console.error(e)}}}for(const e of Object.keys(null!==(s=t.queries)&&void 0!==s?s:{})){const n=t.queries[e];if(n){const t=e.split(":"),a=t[2];if(!a)continue;try{const e=t[1],s=o.Func.find({name:e}).filter((e=>e.type===F.query&&e.id===a))[0];if(!s)continue;const r=s.inputs[0].name,l=yield s.apply(Object.assign(Object.assign({},n),{[r]:d.toList()}));l&&(yield Z(i,u,l))}catch(e){console.error(e)}}}r.close()}))}var 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())}))};class ke extends Fe{get infoView(){return this._infoView}constructor(t){super(t,"Hit Triage"),this._filterViewName="Hit triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=new Ne(this),this.multiView=new o.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof ye&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=t,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(),J(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(t,i,n,s){return Be(this,void 0,void 0,(function*(){var r,l,u,d,c,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,n?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)):(n=yield this.getNewCampaignName("Hit Triage/campaigns",t.key),J(a,n)),!this.dataFrame)return void console.error("Dataframe is empty.");if((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&&i.semType!==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{i.convertTo(t)}catch(e){console.error(e)}})),yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(p=null===(c=this.dataFrame.columns.bySemType(o.SEMTYPE.MOLECULE))||void 0===c?void 0:c.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=n,this.template=(null===(f=this.campaign)||void 0===f?void 0:f.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:t.dataSourceType,queryFunctionName:t.queryFunctionName}):t,this._campaignFilters=i,!i){const e={},i={},n={};t.compute.functions.forEach((t=>{const i=`${t.package}:${t.name}`;e[i]=t.args})),null===(w=t.compute.scripts)||void 0===w||w.forEach((e=>{const t=`${g}:${e.name}:${e.id}`;i[t]=e.args})),null===(b=t.compute.queries)||void 0===b||b.forEach((e=>{const t=`${y}:${e.name}:${e.id}`;n[t]=e.args})),yield Le({descriptors:t.compute.descriptors.enabled?t.compute.descriptors.args:[],externals:e,scripts:i,queries:n},this.dataFrame,this._molColName)}this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0;const x=e.shell.v,S=e.shell.addView(this.pickView);this.currentPickViewId=S.name,this._submitView=new Ee(this),this.setBaseUrl(),J(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}=z(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,t,i;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null===(i=null===(t=this.dataFrame)||void 0===t?void 0:t.columns.bySemType(o.SEMTYPE.MOLECULE))||void 0===i?void 0:i.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(c)||this.dataFrame.columns.addNewBool(c).init(!1);const i=o.TableView.create(this.dataFrame,!1),n=i.getRibbonPanels(),a=t.iconFA("wrench",(()=>Be(this,void 0,void 0,(function*(){ue(this,(e=>Be(this,void 0,void 0,(function*(){var t,i,n,o,a,s,r;const l=this.template.compute.descriptors.args,u=this.template.compute.functions,d=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],c=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(!u.some((t=>t.name===e.name&&t.package===e.package)))return!0;const t=u.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(!d.some((t=>t.id===e.id)))return!0;const t=d.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),w=h.queries.filter((e=>{if(!c.some((t=>t.id===e.id)))return!0;const t=c.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 Le({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=t.bigButton("Submit",(()=>{var e;const i=null===(e=this._submitView)||void 0===e?void 0:e.render();if(i){const e=t.dialog("Submit");e.add(i),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()}})),r=t.iconFA("share",(()=>Be(this,void 0,void 0,(function*(){var e;yield new xe(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show((e=>{this.campaign.permissions=e,this.saveCampaign(void 0,!0)}))}))),"Edit permissions");s.classList.add("hit-design-submit-button");const l=Q(n);return n.push([a,...this.hasEditPermission?[r]:[],...l?[]:[s]]),i.setRibbonPanels(n),i.name=this._filterViewName,setTimeout((()=>Be(this,void 0,void 0,(function*(){var t,n,a;i._onAdded(),yield new Promise((e=>setTimeout(e,1e3)));const s=i.filters(this._campaignFilters?{filters:this._campaignFilters}:void 0),r=null!==(n=null===(t=this._campaign)||void 0===t?void 0:t.layout)&&void 0!==n?n:null===(a=this.template)||void 0===a?void 0:a.layoutViewState;if(r)try{const e=o.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,i,n,o,a,s,r;const l=null!==(i=null===(e=this.campaign)||void 0===e?void 0:e.campaignFields)&&void 0!==i?i:this.campaignProps;return Object.assign(Object.assign({Template:null!==(o=null===(n=this.template)||void 0===n?void 0:n.name)&&void 0!==o?o:"Molecules","File path":t.divH([t.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":t.divH([t.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 Be(this,arguments,void 0,(function*(i,n=!0){var a,s,u,d,c,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(e){return _e(this,void 0,void 0,(function*(){return new Promise((i=>_e(this,void 0,void 0,(function*(){const n=t.input.string("Campaign name",{value:""});t.dialog("Save Campaign").add(t.div(n.root)).onOK((function(){n.value&&""!==n.value?i(n.value):i(e)})).show()}))))}))}(g),T={};b.columns.toList().forEach((e=>T[e.name]=e.semType));const x={};b.columns.toList().forEach((e=>x[e.name]=e.type));const S=null!==(s=null===(a=this.campaign)||void 0===a?void 0:a.authorUserId)&&void 0!==s?s:e.shell.user.id,N=null!==(d=null===(u=this.campaign)||void 0===u?void 0:u.permissions)&&void 0!==d?d:Te,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===(c=this.campaign)||void 0===c?void 0:c.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:W(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:S,permissions:N};if(this.campaign=E,!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),E;const I=o.DataFrame.fromColumns(b.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield st.files.writeAsText(`Hit Triage/campaigns/${g}/${r}`,I);const F=this._pickView.saveLayout();return F?E.layout=F.viewState:e.shell.warning("Layout cound not be saved"),yield st.files.writeAsText(`Hit Triage/campaigns/${g}/${l}`,JSON.stringify(E)),n&&e.shell.info("Campaign saved successfully."),E}))}}function Me(i,n=!1){var a,s;const r=o.DataFrame.create(1);if(n){const e=r.columns.addNew(m,o.TYPE.STRING);e.semType=o.SEMTYPE.MACROMOLECULE,e.meta.units="helm",e.setTag("units","helm"),e.setTag("cell.renderer","helm"),e.setTag(".alphabetIsMultichar","true")}const l=r.columns.addNew(h,o.TYPE.STRING);l.semType=o.SEMTYPE.MOLECULE,l.meta.units=o.UNITS.Molecule.SMILES,l.set(0,null),(null===(a=null==i?void 0:i.stages)||void 0===a?void 0:a.length)>0&&r.columns.addNew(p,o.TYPE.STRING).set(0,i.stages[0]);const u=r.columns.addNew(v,o.TYPE.STRING);u.set(0,Ve(u));const d=i.campaignFields.map((e=>e.type===o.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:o.SEMTYPE.MOLECULE}):e)).map((e=>o.Property.fromOptions(Object.assign({name:e.name,type:oe[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),c={},f=t.input.string("Campaing Name",{tooltipText:"New campaign name. If empty, campaign code will be used."}),g=t.input.form(c,d);g.prepend(f.root),g.classList.remove("ui-form");const y=t.div([...(null===(s=i.campaignFields)||void 0===s||s.length,[]),g]),w=t.buttonsInput([]);return y.appendChild(w),{promise:new Promise((n=>{const o=t.bigButton(A,(()=>{for(const t of i.campaignFields)if(t.required&&(!c[t.name]||""===c[t.name]))return void e.shell.error(`Field '${t.name}' is required`);n({df:r,campaignProps:c,name:f.value})}));w.appendChild(o)})),root:y,cancelPromise:new Promise((e=>{t.button(S,(()=>e()))}))}}var Ue=function(e,t,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}l((n=n.apply(e,t||[])).next())}))};function Re(i,n){return Ue(this,void 0,void 0,(function*(){var a,s,r,l,u,c,p,h,m,v,f;const w=yield st.files.list(`${i.appName}/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 st.files.readAsText(e));x.push(t.key)}catch(e){console.error(e)}const N=o.Func.find({tags:[d]}),E={};N.forEach((e=>{var t;E[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const I=t.input.choice("Submit function",{value:null,items:[null,...Object.keys(E)]});I.nullable=!0,I.value=null!==(s=null===(a=null==n?void 0:n.submit)||void 0===a?void 0:a.fName)&&void 0!==s?s:null,I.setTooltip("Select function to be called upon submitting");const F=t.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),_=t.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),P=he();function O(){var e,t,i,n;if(""===V.value||A.includes(null!==(t=null===(e=V.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=V.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=V.input.offsetWidth)&&void 0!==n?n:0;F.style.marginLeft=`${e}px`,F.style.width=`${t}px`,F.style.opacity="100%",F.style.borderTop="1px solid red",b=!0}else F.style.borderTop="none",F.style.opacity="0%",b=!1}const V=t.input.string("Name",{value:null!==(r=null==n?void 0:n.name)&&void 0!==r?r:"",onValueChanged:O});function L(){var e,t,i,n;if(""===B.value||x.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.borderTop="1px solid red",_.style.opacity="100%",C=!0}else _.style.opacity="0%",_.style.borderTop="none",C=!1}const B=t.input.string("Key",{value:null!==(l=null==n?void 0:n.key)&&void 0!==l?l:"",onValueChanged:L});B.setTooltip("Template key used for campaign prefix"),V.setTooltip("Template name"),V.root.style.borderBottom="none",B.root.style.borderBottom="none",F.style.opacity="0%",_.style.opacity="0%";let k=null;const M={compute:{descriptors:{enabled:!0,args:null!==(p=null===(c=null===(u=null==n?void 0:n.compute)||void 0===u?void 0:u.descriptors)||void 0===c?void 0:c.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:[]}},U=yield ue(i,(e=>{k=e}),(()=>null),M,!1);U.root.classList.add("hit-triage-new-template-functions-input");const R=fe(null==n?void 0:n.campaignFields),j=je(null==n?void 0:n.stages),D=t.divV([t.divV([V,F]),t.divV([B,_]),P.dataFileInput,R.fieldsDiv]),$=t.h2("Stages");t.tooltip.bind($,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const H=t.h2("Compute");t.tooltip.bind(H,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const q=t.div([t.h2("Details"),D,$,j.fieldsDiv,H,U.root,t.h2("Submit"),I.root],"ui-form"),Y=t.buttonsInput([]);q.appendChild(Y);const G=null!==(f=null===(v=Y.getElementsByClassName("ui-input-editor"))||void 0===v?void 0:v[0])&&void 0!==f?f:Y,W=new Promise((e=>{const i=t.button(S,(()=>e()));G.appendChild(i)})),J=new Promise((n=>{const o=t.bigButton(T,(()=>function(){return Ue(this,void 0,void 0,(function*(){var t,o,a,s,r,l,u;if(O(),L(),U.okProxy(),b||!V.value||""===V.value)return void e.shell.error("Template name is empty or already exists");if(C||!B.value||""===B.value)return void e.shell.error("Template key is empty or already exists");const d=I.value?E[I.value]:void 0,c=Object.assign({name:V.value,key:B.value,campaignFields:R.getFields(),stages:j.getFields(),layoutViewState:null!==(t=P.getLayoutViewState())&&void 0!==t?t:void 0,localLayoutPath:null!==(o=P.getLocalFilePath())&&void 0!==o?o:void 0,compute:{descriptors:{enabled:!!(null===(a=null==k?void 0:k.descriptors)||void 0===a?void 0:a.length),args:null!==(s=null==k?void 0:k.descriptors)&&void 0!==s?s:[]},functions:Object.entries(null!==(r=null==k?void 0:k.externals)&&void 0!==r?r:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(l=null==k?void 0:k.scripts)&&void 0!==l?l:{}).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!==(u=null==k?void 0:k.queries)&&void 0!==u?u:{}).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}}))}},d?{submit:{fName:d.name,package:d.package.name}}:{});yield function(e,t){return Ue(this,void 0,void 0,(function*(){yield st.files.writeAsText(`${t}/templates/${e.name}.json`,JSON.stringify(e))}))}(c,i.appName),e.shell.info("Template created successfully"),n(c)}))}()));G.appendChild(o)}));return{root:q,template:J,cancelPromise:W}}))}function je(e){const t=[o.Property.fromOptions({name:"Name",type:o.TYPE.STRING})],i=new ce(t,e?e.map((e=>({Name:e}))):void 0,{horizontalInputNames:!0});let n={};return i.onItemAdded.subscribe((e=>{n={}})),i.onAddingItemChanged.subscribe((e=>{e&&(n=e.item)})),{getFields:function(){const e=i.items.filter((e=>e.Name)).map((e=>e.Name));return n.Name&&""!==n.Name&&e.push(n.Name),e},fieldsDiv:i.root,itemsGrid:i}}var De=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 $e extends ye{constructor(t){super(t),this.currentSorting="None",this.name="Hit Design",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(st.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(st.webRoot+"README_HD.md")}getAppHeader(){return Ce.appHeader({iconPath:st.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"})}init(i){return De(this,void 0,void 0,(function*(){t.setUpdateIndicator(this.root,!0);try{const n=t.h1(N),a=t.h1(E,{style:{marginLeft:"10px"}}),s=this.getAppHeader(),r=t.div(),l=t.divH([]),u=t.div([l,r],"ui-form"),d=yield this.getCampaignsTable(),c=t.div([d],{style:{position:"relative"}}),p=t.iconFA("sort",(()=>{const i=o.Menu.popup();Object.values(P).forEach((n=>{i.item(n,(()=>De(this,void 0,void 0,(function*(){(function(e,t){localStorage.setItem(e,t)})(_,n),t.setUpdateIndicator(c,!0);try{const e=yield this.getCampaignsTable();t.setUpdateIndicator(c,!1),t.empty(c),c.appendChild(e)}catch(t){e.shell.error("Failed to update campaigns table"),console.error(t)}finally{t.setUpdateIndicator(c,!1)}})))),i.show({element:h,x:100,y:h.offsetTop+30})}))}));p.style.marginBottom="12px",p.style.marginLeft="5px",p.style.fontSize="15px",t.tooltip.bind(p,(()=>`Group Campaigns. Current: ${this.currentSorting}`));const h=t.divH([n,p],{style:{alignItems:"center"}});re()(this.root).empty(),this.root.appendChild(t.div([t.divV([s,h],{style:{marginLeft:"10px"}}),c,a,u])),yield this.startNewCampaign(r,l,i),this.app.resetBaseUrl()}finally{t.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(i,n,o){return De(this,void 0,void 0,(function*(){var a;const s=(yield st.files.list(`${this.app.appName}/templates`)).filter((e=>e.name.endsWith(".json"))).map((e=>e.name.slice(0,-5)));o&&!s.includes(o.name)&&s.push(o.name);let r=null,l=!0;const u=()=>De(this,void 0,void 0,(function*(){if(!l)return;const e=d.value,t=o&&o.name===e?o:JSON.parse(yield st.files.readAsText(`${this.app.appName}/templates/${e}.json`));r=t;const n=yield this.getNewCampaignAccordeon(t);re()(i).empty(),i.appendChild(n)})),d=t.input.choice("Template",{value:null!==(a=null==o?void 0:o.name)&&void 0!==a?a:s[0],items:s,onValueChanged:()=>De(this,void 0,void 0,(function*(){yield u()}))});d.root.style.width="100%";const c=t.icons.add((()=>{this.createNewTemplate()}),C),p=t.icons.copy((()=>{r&&this.createNewTemplate(r)}),"Clone template"),h=t.icons.delete((()=>{!d.value||d.items.length<2||t.dialog("Delete template").add(t.divText(`Are you sure you want to delete template ${d.value}?`)).onOK((()=>De(this,void 0,void 0,(function*(){try{const t=d.value;yield st.files.delete(`${this.app.appName}/templates/${t}.json`),l=!1,d.items=d.items.filter((e=>e!==t)),d.value=d.items[0],l=!0,yield u(),e.shell.info("Template "+t+" was deleted successfully")}catch(t){l=!0,e.shell.error("Failed to delete template "+d.value),console.error(t)}})))).show()}),"Delete template");c.style.color="#2083d5",d.addOptions(h),d.addOptions(p),d.addOptions(c),yield u(),re()(n).empty(),n.appendChild(d.root)}))}checkCampaign(e){return De(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 st.files.exists(`${this.app.appName}/campaigns/${o}/${l}`)))return;const a=JSON.parse(yield st.files.readAsText(`${this.app.appName}/campaigns/${o}/${l}`));if(a){if(a.authorUserId&&a.permissions&&!(yield ie(a.authorUserId,a.permissions)))return void this.app.setBaseUrl();this.app.campaign=a}const r=null!==(t=a.template)&&void 0!==t?t:JSON.parse(yield st.files.readAsText(`${this.app.appName}/templates/${a.templateName}.json`));return yield this.app.setTemplate(r,o),e&&J(s,e),a.template=r,a}))}getCampaignsTable(){return De(this,void 0,void 0,(function*(){const i=yield X(this.app.appName,this.deletedCampaigns),n=null!==(r=_,s=localStorage.getItem(r))&&void 0!==s?s:P.None,a=function(e,t){if(t===P.None)return{"":e};const i={};for(const n of e){const e=ne(t,n);i[e]||(i[e]=[]),i[e].push(n)}return i}(Object.values(i),n);var s,r;this.currentSorting=n,this.app.existingStatuses=Array.from(new Set(Object.values(i).map((e=>e.status)).filter((e=>!!e))));const u=i=>{var n,a;const s=t.icons.delete((()=>De(this,void 0,void 0,(function*(){t.dialog("Delete campaign").add(t.divText(`Are you sure you want to delete campaign ${i.name}?`)).onOK((()=>De(this,void 0,void 0,(function*(){yield this.deleteCampaign(this.app.appName,i.name),this.deletedCampaigns.push(i.name),yield this.init()})))).show()}))),"Delete campaign"),r=t.iconFA("share",(()=>De(this,void 0,void 0,(function*(){yield new xe(i.permissions).show((t=>De(this,void 0,void 0,(function*(){var n;try{i.permissions=t,null!==(n=i.authorUserId)&&void 0!==n||(i.authorUserId=e.shell.user.id),yield st.files.writeAsText(`${this.app.appName}/campaigns/${i.name}/${l}`,JSON.stringify(i)),e.shell.info("Permissions updated for campaign "+i.name)}catch(t){e.shell.error("Failed to update permissions for campaign "+i.name),console.error(t)}}))))}))),"Manage campaign permissions");return s.style.display="none",r.style.display="none",te(null!==(n=i.authorUserId)&&void 0!==n?n:o.User.current().id,null!==(a=i.permissions)&&void 0!==a?a:Te).then((e=>{e&&(s.style.display="inline-block",r.style.display="inline-block")})),[r,s]},d=t.table(Object.values(a).flat(),(e=>{var i,n,o;return[t.link(null!==(i=e.friendlyName)&&void 0!==i?i:e.name,(()=>this.setCampaign(e.name)),"Continue Campaign",""),e.name,e.createDate,null!==(n=e.authorUserFriendlyName)&&void 0!==n?n:"",null!==(o=e.lastModifiedUserName)&&void 0!==o?o:"",e.rowCount,e.status,...u(e)]}),["Name","Code","Created","Author","Last Modified by","Molecules","Status","",""]);return d.style.color="var(--grey-5)",d.style.marginLeft="24px",function(e,i,n=9){e.classList.add("hit-design-groupped-campaigns-table");const o=Object.keys(i);if(o.length<2)return e;const a=e.getElementsByTagName("tbody")[0],s=Array.from(e.getElementsByTagName("tr")).filter((e=>!e.classList.contains("header")));let r=0;const l=(e,t,i)=>{var n;for(let o=t;o<i;o++)(null===(n=s[o])||void 0===n?void 0:n.style)&&(s[o].style.display=e?"table-row":"none")};for(const e of o){const o=s[r];if(!o)break;const u=i[e].length,d=r,c=r+u,p=t.accordion(`Hit-Design-campaigns-group-${e}`).addPane(e,(()=>t.div()),void 0,void 0,!1);p.root.style.marginLeft="-24px",p.root.onclick=()=>{l(p.expanded,d,c)},l(p.expanded,d,c);const h=a.insertRow(0),m=h.insertCell(0);m.appendChild(p.root),m.colSpan=n,a.insertBefore(h,o),r+=u}}(d,a),d}))}setCampaign(e){return De(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(e){return De(this,void 0,void 0,(function*(){const{root:t,promise:i,cancelPromise:n}=Me(e);return i.then((t=>De(this,void 0,void 0,(function*(){var i,n;this.app.clearCampaign(),this.app.dataFrame=t.df,yield this.app.setTemplate(e),this.app.campaignProps=t.campaignProps;const o=(null===(i=t.name)||void 0===i?void 0:i.trim())?null===(n=t.name)||void 0===n?void 0:n.trim():void 0;yield this.app.saveCampaign(!1,!0,{friendlyName:o}),e.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=e.layoutViewState)})))),n.then((()=>{this.init()})),t}))}createNewTemplate(i){return De(this,void 0,void 0,(function*(){t.setUpdateIndicator(this.root,!0);try{const t=yield Re(this.app,i),n=new o.ViewBase,a=e.shell.v;n.name="New Template",n.root.appendChild(t.root),n.parentCall=this.app.parentCall,e.shell.addView(n),n.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:s}=z(n,this.app.appName,C,(()=>De(this,void 0,void 0,(function*(){e.shell.v=a,n.close()}))));t.template.then((t=>De(this,void 0,void 0,(function*(){yield this.init(t),n.close(),K(n),e.shell.v=a,s.unsubscribe()})))),t.cancelPromise.then((()=>De(this,void 0,void 0,(function*(){s.unsubscribe(),n.close(),e.shell.v=a}))))}finally{t.setUpdateIndicator(this.root,!1)}}))}}class He extends ye{constructor(e){var i;super(e),this.name="Submit",this.statusInput=t.input.string("Status",{value:null===(i=this.app.campaign)||void 0===i?void 0:i.status,nullable:!1}),this.statusSuggestionsMenu=o.Menu.popup(),this.statusInput.root.style.marginLeft="12px",this.content=t.div(),this.statusInput.onChanged.subscribe((()=>{var e,t,i,n;this.statusSuggestionsMenu.clear();const o=(null!==(e=this.statusInput.value)&&void 0!==e?e:"").toLowerCase(),a=this.app.existingStatuses.filter((e=>{var t;return(null===(t=null==e?void 0:e.toLowerCase())||void 0===t?void 0:t.includes(o))&&(null==e?void 0:e.toLowerCase())!==o})).filter(((e,t)=>t<5));if(a.length){if(a.forEach((e=>{this.statusSuggestionsMenu.item(e,(()=>{this.statusInput.value=e,this.statusSuggestionsMenu.root.remove(),this.statusInput.root.focus()}))})),null===(t=this.content.parentElement)||void 0===t?void 0:t.parentElement){const e=this.statusInput.root.offsetLeft+(null!==(n=null===(i=this.statusInput.input)||void 0===i?void 0:i.offsetLeft)&&void 0!==n?n:0),t=this.statusInput.root.offsetTop+this.statusInput.root.offsetHeight+this.content.parentElement.offsetTop;this.statusSuggestionsMenu.show({element:this.content.parentElement.parentElement,x:e,y:t})}}else this.statusSuggestionsMenu.root.remove()}))}getStatus(){var e,t,i;return null!==(i=null!==(e=this.statusInput.value)&&void 0!==e?e:null===(t=this.app.campaign)||void 0===t?void 0:t.status)&&void 0!==i?i:"No Status"}render(){var e,i;return this.statusInput.value=null!==(i=null===(e=this.app.campaign)||void 0===e?void 0:e.status)&&void 0!==i?i:"",t.empty(this.content),this.content=t.divV([t.h1("Summary"),t.div([t.tableFromMap(this.app.getSummary())]),this.statusInput.root]),this.content}onActivated(){this.render()}submit(){return t=this,i=void 0,a=function*(){var t;const i=null===(t=this.app.template)||void 0===t?void 0:t.submit;if(!i)return;const n=o.Func.find({name:i.fName,package:i.package})[0];if(!n)return void e.shell.error(`Function ${i.fName} not found.`);const a=o.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield n.apply({df:a,molecules:this.app.molColName}),this.app.campaign.status=this.getStatus(),this.app.saveCampaign(),e.shell.info("Submitted successfully.")},new((n=void 0)||(n=Promise))((function(e,o){function s(e){try{l(a.next(e))}catch(e){o(e)}}function r(e){try{l(a.throw(e))}catch(e){o(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(s,r)}l((a=a.apply(t,i||[])).next())}));var t,i,n,a}}var qe=i(542),Ye={};Ye.styleTagTransform=H(),Ye.setAttributes=R(),Ye.insert=M().bind(null,"head"),Ye.domAPI=B(),Ye.insertStyleElement=D(),V()(qe.A,Ye),qe.A&&qe.A.locals&&qe.A.locals;function Ge(i,n){var a,s,r,l,u,d,c,h;const m=null===(a=i.campaign)||void 0===a?void 0:a.tilesViewerFormSketch;let v=null;if(m&&m.length>0)try{v=JSON.parse(m)}catch(e){console.error("Failed to parse sketch state string",e)}v&&v.elementStates&&(null!==(s=v.elementStates.length)&&void 0!==s?s:0)>0&&(v.elementStates=v.elementStates.filter((e=>{var t;return(null===(t=null==e?void 0:e.viewerSettings)||void 0===t?void 0:t.column)&&i.dataFrame.col(e.viewerSettings.column)})),v.elementStates.forEach((e=>{var t;(null===(t=null==e?void 0:e.viewerSettings)||void 0===t?void 0:t.table)&&(e.viewerSettings.table=i.dataFrame.name)})));const f=Object.assign({lanesColumnName:p,lanes:i.stages},(null!==(l=null===(r=null==v?void 0:v.elementStates)||void 0===r?void 0:r.length)&&void 0!==l?l:0)>0?{sketchState:v}:{}),g=n();if(!g)return void e.shell.error("Failed to create tiles viewer. table view is not available.");let y=null;const w=t.dialog("Progress Tracker");try{y=g.addViewer(o.VIEWER.TILE_VIEWER,f);const e=y.getOptions();e.look.sketchState=(null!==(d=null===(u=null==v?void 0:v.elementStates)||void 0===u?void 0:u.length)&&void 0!==d?d:0)>0?v:null,y.setOptions(e),y.copyViewersLook(y)}catch(t){e.shell.error("Failed to create tiles viewer with preset layout.\n Falling back to default layout."),console.error("Failed to create tiles viewer",t),y&&(y.close(),y.detach()),y=g.addViewer(o.VIEWER.TILE_VIEWER,{lanesColumnName:p,lanes:i.stages})}if(!y)return void e.shell.error("Failed to create tiles viewer. check the console for more details.");let b=null;const C=()=>{try{y.detach(),y.close()}catch(e){}};w.add(y.root),w.addButton("Modify Stages",(()=>{null==b||b.close();const o=je(i.stages);b=t.dialog("Modify Stages").add(o.fieldsDiv).onOK((()=>{return a=this,s=void 0,l=function*(){C(),t.setUpdateIndicator(w.root,!0);try{yield i.setStages(o.getFields()),t.setUpdateIndicator(w.root,!1),w.close(),yield new Promise((e=>setTimeout((()=>{e(),Ge(i,n)}),100)))}catch(t){e.shell.error("Failed to update stages. check the console for more details."),console.error("Failed to update stages",t)}finally{(null==w?void 0:w.root)&&document.contains(w.root)&&w.close()}},new((r=void 0)||(r=Promise))((function(e,t){function i(e){try{o(l.next(e))}catch(e){t(e)}}function n(e){try{o(l.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof r?o:new r((function(e){e(o)}))).then(i,n)}o((l=l.apply(a,s||[])).next())}));var a,s,r,l})).show(),b.root.classList.add("hit-design-stage-editing-dialog")}),0);const A=e.events.onCurrentViewChanged.subscribe((()=>{e.shell.v===g?w.root.style.display="flex":w.root.style.setProperty("display","none","important")})),T=w.onClose.subscribe((()=>{T.unsubscribe(),A.unsubscribe(),null==b||b.close();try{const e=y.props.sketchState;if(e&&"object"==typeof e){const t=JSON.stringify(e);i.campaign&&(i.campaign.tilesViewerFormSketch=t)}}catch(t){e.shell.error("Failed to save sketch state. check the console for more details."),console.error("Failed to save sketch state",t)}C()}));w.showModal(!0),null===(c=w.getButton("CANCEL"))||void 0===c||c.remove(),w.onOK((()=>{})),null===(h=document.querySelector(".d4-modal-background"))||void 0===h||h.remove()}const We=rxjs.operators;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 ze="DefaultUserGroupsSharing";function Ke(t){return Je(this,void 0,void 0,(function*(){if(!t)return[yield e.dapi.groups.find(o.Group.defaultGroupsIds["All users"])].filter(Boolean);try{const i=JSON.parse(t);return(yield Promise.all(i.map((t=>e.dapi.groups.find(t))))).filter(Boolean)}catch(t){return console.error(t),[yield e.dapi.groups.find(o.Group.defaultGroupsIds["All users"])].filter(Boolean)}}))}var Qe=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 Ze extends Fe{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(e,t="Hit Design",i=e=>new $e(e)){super(e,t),this._designViewName="Design",this._filePath=`System.AppData/HitTriage/${this.appName}/campaigns`,this._molColName=h,this.campaignProps={},this.existingStatuses=[],this._gridSubs=null,this._infoView=i(this),this.multiView=new o.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof ye&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=e,this.mainView=this.multiView,this._initViewSubs()}handleJoiningDataframe(t){return Qe(this,void 0,void 0,(function*(){var i,n,a,s,r,l;const u=t.columns.bySemTypeAll(o.SEMTYPE.MOLECULE);if(!u||0===u.length)return void e.shell.error("No molecule column found");const d=null!==(i=u.find((e=>{var t,i;return"smiles"===(null===(t=null==e?void 0:e.name)||void 0===t?void 0:t.toLowerCase())||"molecule"===(null===(i=null==e?void 0:e.name)||void 0===i?void 0:i.toLowerCase())})))&&void 0!==i?i:u[0];if(!d)return void e.shell.error("No molecule column found");const c=null!==(s=null===(a=null===(n=this.campaign)||void 0===n?void 0:n.template)||void 0===a?void 0:a.compute)&&void 0!==s?s:null===(r=this.template)||void 0===r?void 0:r.compute;if(!c)return void e.shell.error("No compute functions found");const m=d.toList(),v=c.descriptors.enabled&&null!==(l=c.descriptors.args)&&void 0!==l?l:[],f=yield Oe(m,v,c.functions,c.scripts,c.queries);if(this.unionDataframes(f,t,h,d.name),this.stages.length>0&&this.dataFrame.columns.contains(p)){const e=t.columns.getOrCreate(p,o.TYPE.STRING);for(let i=0;i<t.rowCount;i++)e.isNone(i)&&e.set(i,this.stages[0],!1)}this.unionDataframes(t,this.dataFrame,d.name,this.molColName),this.updateAllVids(),this.saveCampaign(!1)}))}updateAllVids(){var e;const t=this.dataFrame.col(this.molColName),i=this.dataFrame.col(v);if(!t||!i)return;const n=t.toList().map((e=>st.convertToSmiles(e))),o=new Map;for(let t=0;t<n.length;t++){const a=n[t];if(!a)continue;const s=i.isNone(t)?null:i.get(t);if(s)if(o.has(a)){if(s===o.get(a))continue;i.set(t,o.get(a),!1)}else o.set(a,s);else i.set(t,null!==(e=o.get(a))&&void 0!==e?e:Ve(i),!1)}const a=i.get(0);i.set(0,null,!1),i.set(0,a,!0)}_initViewSubs(){this.multiView.subs.push(e.events.onCurrentViewChanged.subscribe((()=>Qe(this,void 0,void 0,(function*(){var t,i,n,o,s;try{if((null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentDesignViewId){e.shell.windows.showHelp=!1,this.setBaseUrl(),J(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:"");const{sub:t}=z(e.shell.v,this.appName,null===(s=e.shell.v)||void 0===s?void 0:s.name,(()=>{var i;e.shell.v=this.mainView,null===(i=this._designView)||void 0===i||i.close(),this._infoView.init(),t.unsubscribe()}))}}catch(e){console.error(e)}}))))),this.multiView.subs.push(e.events.onFileImportRequest.subscribe((t=>{var i,n;if(!e.shell.tv||!this._designView||e.shell.tv!==this._designView)return;if(!(null===(i=null==t?void 0:t.args)||void 0===i?void 0:i.file))return;const o=t.args.file;((null===(n=o.name)||void 0===n?void 0:n.endsWith(".csv"))||Fe.molFileExtReaders.some((e=>{var t;return null===(t=o.name)||void 0===t?void 0:t.endsWith(e.ext)})))&&(t.preventDefault(),this.handleUploadingDataframe(o))})))}handleUploadingDataframe(i){return Qe(this,void 0,void 0,(function*(){var n;try{let a=null;if(i.name.endsWith(".csv"))a=o.DataFrame.fromCsv(yield i.text());else{const t=yield new Promise((e=>Qe(this,void 0,void 0,(function*(){const t=new FileReader;let n=null,o=null;t.onload=()=>{o=t.result?new Uint8Array(t.result):null,n&&clearTimeout(n),e(o)},t.readAsArrayBuffer(i),n=setTimeout((()=>{t.abort(),e(null)}),1e4)}))));if(!t)return void e.shell.error("Failed to read file");const n=Fe.molFileExtReaders.find((e=>i.name.endsWith(e.ext))).handlerFunc,o=n.inputs[0].name;a=(yield n.apply({[o]:t}))[0]}if(!a)throw new Error("Failed to read file");if(a.name=i.name.slice(0,i.name.lastIndexOf(".")),yield a.meta.detectSemanticTypes(),yield e.data.detectSemanticTypes(a),!a.columns.bySemType(o.SEMTYPE.MOLECULE))return void e.shell.addTableView(a);const s=t.dialog("Uploading table with molecules").add(t.divText("Add new table to workspace or join with existing Hit Design campaign")).addButton("Add to workspace",(()=>{s.close(),e.shell.addTableView(a)})).addButton("Add to existing campaign",(()=>{s.close(),this.handleJoiningDataframe(a)}));null===(n=s.getButton("CANCEL"))||void 0===n||n.remove(),s.show()}catch(t){e.shell.error("Hit Design Failed to read file"),console.error(t)}}))}get stages(){var e,t,i,n,o;return null!==(o=null!==(i=null===(t=null===(e=this.campaign)||void 0===e?void 0:e.template)||void 0===t?void 0:t.stages)&&void 0!==i?i:null===(n=this.template)||void 0===n?void 0:n.stages)&&void 0!==o?o:[]}setStages(t){return Qe(this,void 0,void 0,(function*(){var i;if(!this.campaign||!this.campaign.template||!this.template)return void e.shell.error("Campaign or template is not set");if(!(null==t?void 0:t.length))return void e.shell.error("Removing all stages is not allowed");const n=null===(i=this.dataFrame)||void 0===i?void 0:i.col(p);if(!n)return void e.shell.error("No stage column found");const o=[],a=new Set(t),s=[...a],r=this.dataFrame.rowCount,l=n.categories,u=n.getRawData();for(let e=0;e<r;e++){const i=l[u[e]];a.has(i)||(n.set(e,t[0],!1),o.push(i))}o.length>0&&e.shell.warning(`Some stages were removed: (${o.join(", ")}). Corresponding rows were set to stage "${t[0]}"`),this.campaign.template.stages=s,this.template.stages=s,yield this.saveCampaign(!0)}))}setTemplate(t,i){return Qe(this,void 0,void 0,(function*(){var n,l,u,d,c,p,m,v,f,g,y;if(i){const t=`System.AppData/HitTriage/${this.appName}/campaigns`;this._filePath=null!==(u=null===(l=this.campaign)||void 0===l?void 0:l.savePath)&&void 0!==u?u:`${t}/${i}/${r}`,this.dataFrame=yield e.dapi.files.readCsv(this._filePath),(null===(d=this._campaign)||void 0===d?void 0:d.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&t&&(i.semType=t)})),(null===(c=this._campaign)||void 0===c?void 0:c.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===(n=this._designView)||void 0===n?void 0:n.dataFrame)&&e.shell.closeTable(this._designView.dataFrame),this._designView=void 0,i=yield this.getNewCampaignName(`${this.appName}/campaigns`,t.key),J(s,i),this._filePath=`System.AppData/HitTriage/${this.appName}/campaigns/${i}/${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(o.SEMTYPE.MOLECULE))||void 0===p?void 0:p.name)&&void 0!==m?m:h,this._campaignId=i,this.template=t,null!==(v=this._submitView)&&void 0!==v||(this._submitView=new He(this)),e.shell.windows.showHelp=!1,this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0;const w=this.designView;this.currentDesignViewId=w.name,this.setBaseUrl(),J(a,null!==(y=null!==(f=this._campaignId)&&void 0!==f?f:null===(g=this._campaign)||void 0===g?void 0:g.name)&&void 0!==y?y:""),this.campaign&&(this.campaign.template=t)}))}get campaignId(){return this._campaignId}get designView(){return this._designView=this.getDesignView()}get designViewName(){return this._designViewName}set designViewName(e){this._designViewName=e,this._designView&&(this._designView.name=e)}get molColName(){var e,t,i,n;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null!==(n=null===(i=null===(t=this.dataFrame)||void 0===t?void 0:t.columns.bySemType(o.SEMTYPE.MOLECULE))||void 0===i?void 0:i.name)&&void 0!==n?n:h}get campaign(){return this._campaign}set campaign(e){this._campaign=e}clearCampaign(){this._campaign=void 0}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().subarray(0,t.length);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}performSingleCellCalculations(e,t){return Qe(this,void 0,void 0,(function*(){const i=this.template.compute;if(!t||""===t)return;const n=yield Oe([t],i.descriptors.args,i.functions,i.scripts,i.queries);for(const t of n.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(e,t.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(!1)}))}initDesignViewRibbons(i,n,a=!1){var s,r,l;const u=e.events.onViewRemoved.subscribe((e=>{e.id===(null==i?void 0:i.id)&&(n.forEach((e=>e.unsubscribe())),u.unsubscribe())}));let d=null==i?void 0:i.getRibbonPanels();if(d&&!Q(d)){const n=()=>Qe(this,void 0,void 0,(function*(){var e;ue(this,(e=>Qe(this,void 0,void 0,(function*(){var n,o,a,s,r,l,u,d,c,p;const h=this.template.compute.descriptors.args,m=this.template.compute.functions,v=null!==(n=this.template.compute.scripts)&&void 0!==n?n:[],f=null!==(o=this.template.compute.queries)&&void 0!==o?o:[],w=e.descriptors,b={descriptors:{enabled:!!(null===(a=null==e?void 0:e.descriptors)||void 0===a?void 0:a.length),args:null!==(s=null==e?void 0:e.descriptors)&&void 0!==s?s:[]},functions:Object.entries(null!==(r=null==e?void 0:e.externals)&&void 0!==r?r:{}).map((([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}})),scripts:Object.entries(null!==(l=null==e?void 0:e.scripts)&&void 0!==l?l:{}).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!==(u=null==e?void 0:e.queries)&&void 0!==u?u:{}).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!==(d=null==e?void 0:e.externals)&&void 0!==d?d:{}).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!==(c=null==e?void 0:e.scripts)&&void 0!==c?c:{}).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})),t.setUpdateIndicator(i.grid.root,!0);try{yield Le({descriptors:C,externals:A,scripts:T,queries:x},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{t.setUpdateIndicator(i.grid.root,!1),this.saveCampaign(!1)}}))),(()=>null),null===(e=this.campaign)||void 0===e?void 0:e.template,!0)})),u=t.iconFA("wrench",n,"Calculate additional properties"),c=t.icons.add((()=>{var e;null===(e=this.dataFrame)||void 0===e||e.rows.addNew(null,!0)}),"Add new row"),p=t.iconSvg("view-layout",(()=>{this.applyTemplateLayout(i)}),"Apply template layout "+((null===(s=this.template)||void 0===s?void 0:s.localLayoutPath)?"(Loaded from mounted file storage)":"(Static)")),h=t.iconFA("share",(()=>Qe(this,void 0,void 0,(function*(){var e;yield new xe(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show((e=>{this.campaign.permissions=e,this.saveCampaign(!0)}))}))),"Edit campaign permissions"),m=t.bigButton("Progress tracker",(()=>{Ge(this,(()=>{var e;return null!==(e=this._designView)&&void 0!==e?e:null}))})),v=t.bigButton("Submit...",(()=>{var e,i,n,a,s,r;const l=null===(e=this._submitView)||void 0===e?void 0:e.render();if(l){const e=t.dialog("Submit");e.add(l),e.addButton("Save",(()=>{this._campaign.status=this._submitView.getStatus(),this.saveCampaign(),e.close()})),(null===(n=null===(i=this.template)||void 0===i?void 0:i.submit)||void 0===n?void 0:n.fName)&&(null===(s=null===(a=this.template)||void 0===a?void 0:a.submit)||void 0===s?void 0:s.package)&&(null===(r=o.Func.find({name:this.template.submit.fName,package:this.template.submit.package}))||void 0===r?void 0:r.length)>0&&e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}})),f=o.Func.find({tags:["HitDesignerFunction"]}).filter((e=>1===e.outputs.length&&e.outputs[0].propertyType===o.TYPE.DATA_FRAME));v.classList.add("hit-design-submit-button");const w=[v];if(this.stages.length>0&&w.unshift(m),this.campaign&&this.template&&!this.campaign.template&&(this.campaign.template=this.template),((null===(r=this.template)||void 0===r?void 0:r.layoutViewState)||(null===(l=this.template)||void 0===l?void 0:l.localLayoutPath))&&w.unshift(p),this.hasEditPermission&&w.unshift(h),f.length>0&&a){const i=f[0],n=t.iconFA("pen-nib",(()=>Qe(this,void 0,void 0,(function*(){var n;const a={};if(i.inputs.length>0&&this.dataFrame&&this.dataFrame.currentRowIdx>=0&&i.inputs[0].semType===o.SEMTYPE.MOLECULE){const e=st.convertToSmiles(null===(n=this.dataFrame.col(this.molColName))||void 0===n?void 0:n.get(this.dataFrame.currentRowIdx));e&&(a[i.inputs[0].name]=e)}const s=i.prepare(a),r=yield s.getEditor();t.dialog(i.friendlyName).add(r).onOK((()=>Qe(this,void 0,void 0,(function*(){const t=o.TaskBarProgressIndicator.create(`Running ${i.friendlyName}`);try{yield s.call();const n=s.getOutputParamValue();if(!n||!n.rowCount)return e.shell.warning(`${i.friendlyName} returned an empty result`),void t.close();yield n.meta.detectSemanticTypes(),yield e.data.detectSemanticTypes(n),yield this.handleJoiningDataframe(n)}catch(t){e.shell.error(`Failed to run ${i.friendlyName}`),st.logger.error(t)}finally{t.close()}})))).show()}))),i.description?i.description:i.friendlyName);w.unshift(n)}w.unshift(u),w.unshift(c),d.push(w),d.some((e=>{var t;const i=null!==(t=null==e?void 0:e.findIndex((e=>{var t;return"save"===(null===(t=null==e?void 0:e.textContent)||void 0===t?void 0:t.toLowerCase())})))&&void 0!==t?t:-1;return-1!==i&&(e.splice(i,1),!0)})),d=d.filter((e=>{var t;return(null!==(t=null==e?void 0:e.length)&&void 0!==t?t:0)>0})),i.setRibbonPanels(d)}return i}applyTemplateLayout(t){return Qe(this,void 0,void 0,(function*(){var i,n;if(t){if(null===(i=this.template)||void 0===i?void 0:i.localLayoutPath)try{const i=yield e.dapi.files.readAsText(this.template.localLayoutPath),n=o.ViewLayout.fromJson(i);return void t.loadLayout(n)}catch(t){e.shell.error("Failed to apply layout from mounted file storage. Falling back to static layout"),st.logger.error(t)}if(null===(n=this.template)||void 0===n?void 0:n.layoutViewState)try{const e=o.ViewLayout.fromViewState(this.template.layoutViewState);t.loadLayout(e)}catch(t){e.shell.error("Failed to apply template layout. Check console for more details."),st.logger.error(t)}else e.shell.error("No layout found")}else e.shell.error("No view found")}))}getDesignView(){var t,i,n,a,s,r;this._designView&&this._designView.close();const l=[],u=null===(t=this.dataFrame.col(this.molColName))||void 0===t?void 0:t.toList().every((e=>!e&&""===e)),d=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(s=null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.friendlyName)&&void 0!==n?n:null===(a=this.campaign)||void 0===a?void 0:a.name)&&void 0!==s?s:this._designViewName,d.name=this._designViewName,d._onAdded();const c=null===(r=this._campaign)||void 0===r?void 0:r.layout;if(c)try{const e=o.ViewLayout.fromViewState(c);d.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}return this.checkGrid(d),u&&e.functions.call("Chem:editMoleculeCell",{cell:d.grid.cell(this._molColName,0)}),this.initGridSubs(d,l),l.push(this.dataFrame.onRowsAdded.pipe((0,We.filter)((()=>!this.isJoining))).subscribe((()=>{var t;try{if(this.stages.length>0)for(let e=0;e<this.dataFrame.rowCount;e++){const i=this.dataFrame.col(p).get(e);i&&""!==i&&!(null===(t=this.dataFrame.col(p))||void 0===t?void 0:t.isNone(e))||this.dataFrame.set(p,e,this.stages[0])}let i=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||(i=t))}i&&e.functions.call("Chem:editMoleculeCell",{cell:i})}catch(e){console.error(e)}}))),l.push(e.events.onContextMenu.subscribe((t=>{var i,n,a,s,r,l,u,c,p,h,m,v;try{const e=null===(i=null==t?void 0:t.args)||void 0===i?void 0:i.context;if(!e)return;if((null==e?void 0:e.type)!==o.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==d.id)return;if((null===(s=null===(a=null===(n=null==t?void 0:t.args)||void 0===n?void 0:n.item)||void 0===a?void 0:a.tableColumn)||void 0===s?void 0:s.name)!==this.molColName||!(null===(l=null===(r=null==t?void 0:t.args)||void 0===r?void 0:r.item)||void 0===l?void 0:l.isTableCell))return;const f=null===(u=null==t?void 0:t.args)||void 0===u?void 0:u.menu;if(!f)return;f.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),f.item("Duplicate molecule",(()=>{var e,i,n,o;try{const a=this.dataFrame.rows.addNew(null,!0);null!=a.get(this.molColName)&&a.idx>-1&&(this.dataFrame.cell(a.idx,this.molColName).value=null!==(o=null===(n=null===(i=null===(e=null==t?void 0:t.args)||void 0===e?void 0:e.item)||void 0===i?void 0:i.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}}));const g=null===(p=null===(c=null==t?void 0:t.args)||void 0===c?void 0:c.item)||void 0===p?void 0:p.tableRowIndex,y=null===(v=null===(m=null===(h=null==t?void 0:t.args)||void 0===h?void 0:h.item)||void 0===m?void 0:m.cell)||void 0===v?void 0:v.value;y&&(null!=g?g:-1)>-1&&f.item("Re-Run Calculations",(()=>Qe(this,void 0,void 0,(function*(){try{yield this.performSingleCellCalculations(g,y)}catch(e){console.error(e)}}))))}catch(t){e.log.error(t)}}))),l.push(e.events.onViewLayoutApplied.subscribe((e=>{e&&e.view===d&&this.initGridSubs(d,l)}))),this.initDesignViewRibbons(d,l,!0),d.parentCall=this.parentCall,d}checkGrid(t){t.grid||(e.shell.error("Applied layout created view without grid. Resetting layout."),t.resetLayout())}initGridSubs(t,i){this._gridSubs&&this._gridSubs.grid===t.grid||(this._gridSubs&&this._gridSubs.subs.forEach((e=>e.unsubscribe())),this.checkGrid(t),t.grid?(this._gridSubs={grid:t.grid,subs:[]},(null==t?void 0:t.grid)&&this._gridSubs.subs.push(t.grid.onCellValueEdited.subscribe((e=>Qe(this,void 0,void 0,(function*(){var t,i,n,o,a;try{if((null===(t=e.tableColumn)||void 0===t?void 0:t.name)===p)return void(yield this.saveCampaign(!1));if((null===(i=e.tableColumn)||void 0===i?void 0:i.name)!==this.molColName)return;const s=e.cell.value,r=e.tableRowIndex;let l=null===(n=this.dataFrame.col(v))||void 0===n?void 0:n.get(r),u=!1;if(s)try{const t=e.tableColumn.toList().map((e=>{try{return st.convertToSmiles(e)}catch(e){return""}})),i=st.convertToSmiles(s);if((null==t?void 0:t.length)===this.dataFrame.rowCount)for(let e=0;e<t.length;e++)if(t[e]===i&&e!==r&&(null===(o=this.dataFrame.col(v))||void 0===o?void 0:o.get(e))){l=null===(a=this.dataFrame.col(v))||void 0===a?void 0:a.get(e),u=!0;break}}catch(e){console.error(e)}this.duplicateVidCache&&!u&&this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[r]]>1&&(l=null),l&&""!==l||(l=Ve(this.dataFrame.col(v))),this.dataFrame.col(v).set(r,l,!1),this.performSingleCellCalculations(r,s)}catch(e){console.error(e)}}))))),(null==t?void 0:t.grid)&&this._gridSubs.subs.push(t.grid.onCellRender.subscribe((e=>{var t;try{const i=e.cell;if(!i||!i.isTableCell||!i.tableColumn||!this.duplicateVidCache||i.tableColumn.name!==v||(null!==(t=i.tableRowIndex)&&void 0!==t?t:-1)<0)return;this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[i.tableRowIndex]]>1&&(e.cell.style.backColor=o.Color.setAlpha(o.Color.getCategoricalColor(this.duplicateVidCache.indexes[i.tableRowIndex]),150))}catch(e){}}))),this._gridSubs.subs.forEach((e=>i.push(e)))):e.shell.error("No grid found, cannot initialize grid subscriptions"))}getSummary(){var i,n,a,s,l,u,d,c,p,h,m,v,f;const g=()=>{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)},y=Object.assign({},null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.campaignFields)&&void 0!==n?n:this.campaignProps);this.template&&this.template.campaignFields&&Object.entries(y).forEach((([t,i])=>{const n=this.template.campaignFields.find((e=>e.name===t));n&&"Date"===n.type&&i?"Invalid Date"!==new Date(i).toString()?y[t]=new Date(i).toLocaleDateString():i.date?y[t]=new Date(i.date).toLocaleDateString():y[t]=i:n&&n.type===o.SEMTYPE.MOLECULE&&i&&(y[t]=e.chem.drawMolecule(i))}));const w=null!==(u=null!==(s=null===(a=this.campaign)||void 0===a?void 0:a.friendlyName)&&void 0!==s?s:null===(l=this.campaign)||void 0===l?void 0:l.name)&&void 0!==u?u:this.campaignId,b=function(i,n){var o;const a=t.icons.edit((()=>{var o,r,l,u,d;let c=null!==(r=null!==(o=null==n?void 0:n.tooltip)&&void 0!==o?o:i.textContent)&&void 0!==r?r:"";const p=null!==(l=null==n?void 0:n.beforeEditTextContent)&&void 0!==l?l:e=>e,h=null!==(u=null==n?void 0:n.afterEditTextContent)&&void 0!==u?u:e=>e,m=t.input.string("smth",{value:p(null!==(d=i.textContent)&&void 0!==d?d:""),onValueChanged:()=>G(this,void 0,void 0,(function*(){var e;const t=yield f();setTimeout((()=>{var e,o;if(t)return m.input.classList.add("d4-invalid"),void(c=t);m.input.classList.remove("d4-invalid"),c=null!==(o=null!==(e=null==n?void 0:n.tooltip)&&void 0!==e?e:i.textContent)&&void 0!==o?o:""}),100),null===(e=null==n?void 0:n.onChange)||void 0===e||e.call(n,m.value)}))});t.tooltip.bind(m.input,(()=>c));const v=m.root.getElementsByTagName("label").item(0);v&&v.remove(),m.root.style.width="100%";const f=()=>G(this,void 0,void 0,(function*(){var e;const t=(null===(e=m.value)||void 0===e?void 0:e.trim())||(null==n?void 0:n.nullable)?null:"Field cannot be empty";return null!=t?t:(null==n?void 0:n.validator)?yield n.validator(m.value):null})),g=t.button("Save",(()=>G(this,void 0,void 0,(function*(){var o,r;const l=yield f();l?e.shell.error(l):(yield null===(o=null==n?void 0:n.onOk)||void 0===o?void 0:o.call(n,m.value),i.textContent=null!==(r=h(m.value))&&void 0!==r?r:"",t.empty(s),s.appendChild(i),s.appendChild(a))})))),y=t.button("Cancel",(()=>{var e;t.empty(s),s.appendChild(i),s.appendChild(a),null===(e=null==n?void 0:n.onCancel)||void 0===e||e.call(n)}));t.empty(s),m.addOptions(y),m.addOptions(g),s.appendChild(m.root),m.input.focus()}),null!==(o=null==n?void 0:n.tooltip)&&void 0!==o?o:"Edit"),s=t.divH([i,a],{style:{display:"flex",alignItems:"center"}});return a.style.marginLeft="5px",s}(t.divText(w),{tooltip:"Edit Campaign Name",nullable:!1,onOk:e=>Qe(this,void 0,void 0,(function*(){this.campaign.friendlyName=e,yield this.saveCampaign(!0)})),validator:e=>Qe(this,void 0,void 0,(function*(){return(null==e?void 0:e.trim())?null:"Campaign name can not be empty"}))});return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({Name:b,Code:null!==(d=this.campaignId)&&void 0!==d?d:null===(c=this._campaign)||void 0===c?void 0:c.name,Template:null!==(h=null===(p=this.template)||void 0===p?void 0:p.name)&&void 0!==h?h:"Molecules","File Path":(()=>{const i=t.icons.edit((()=>{const n=g(),s=t.input.string("Path",{value:n}),l=s.root.getElementsByTagName("label").item(0);l&&l.remove(),s.root.style.width="100%";const u=t.button("Save",(()=>Qe(this,void 0,void 0,(function*(){if(!(yield function(t){return G(this,void 0,void 0,(function*(){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)}))}(s.value)))return;const n=s.value;n.endsWith("/")?this._filePath=`${n}${this.campaignId}/${r}`:this._filePath=`${n}/${this.campaignId}/${r}`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(!0),t.empty(a);const l=g();o=t.link(l,(()=>{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(o),a.appendChild(i)})))),d=t.button("Cancel",(()=>{t.empty(a),a.appendChild(o),a.appendChild(i)}));t.empty(a),s.addOptions(d),s.addOptions(u),a.appendChild(s.root),s.input.focus()}),"Edit file path");i.style.marginLeft="5px";const n=g();let o=t.link(n,(()=>{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=t.divH([o,i],{style:{alignItems:"center"}});return a})()},(null===(m=this.campaign)||void 0===m?void 0:m.authorUserFriendlyName)?{Author:this.campaign.authorUserFriendlyName}:{}),(null===(v=this.campaign)||void 0===v?void 0:v.lastModifiedUserName)?{"Last Modified By":this.campaign.lastModifiedUserName}:{}),(null===(f=this.campaign)||void 0===f?void 0:f.createDate)?{"Create Date":this.campaign.createDate}:{}),y),{"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(", ")})}saveCampaign(){return Qe(this,arguments,void 0,(function*(t=!0,i=!1,n){var a,s,r,u,d,c,p,h,m,v,f,g,y,w,b,C,A,T,x,S,N;const E=this.campaignId,I=this.template.name,F=this.dataFrame,_=E,P={};F.columns.toList().forEach((e=>P[e.name]=e.semType));const O={};F.columns.toList().forEach((e=>O[e.name]=e.type));const V=null!==(s=null===(a=this.campaign)||void 0===a?void 0:a.tilesViewerFormSketch)&&void 0!==s?s:void 0,L=null!==(u=null===(r=this.campaign)||void 0===r?void 0:r.authorUserId)&&void 0!==u?u:e.shell.user.id,B=null!==(c=null===(d=this.campaign)||void 0===d?void 0:d.permissions)&&void 0!==c?c:yield(()=>Qe(this,void 0,void 0,(function*(){try{const e=yield function(){return Je(this,void 0,void 0,(function*(){var e,t,i,n;try{const o=yield st.getSettings(),a={view:[],edit:[]};return o?(o instanceof Map?(a.view=yield Ke(null!==(e=o.get("view"))&&void 0!==e?e:""),a.edit=yield Ke(null!==(t=o.get("edit"))&&void 0!==t?t:"")):(a.view=yield Ke(null!==(i=o.view)&&void 0!==i?i:""),a.edit=yield Ke(null!==(n=o.edit)&&void 0!==n?n:"")),a):a}catch(e){return console.error(e),{view:[],edit:[]}}}))}(),t={view:e.view.map((e=>e.id)),edit:e.edit.map((e=>e.id))};return 0===t.edit.length&&(t.edit=[Te.edit[0]]),0===t.view.length&&(t.view=[Te.view[0]]),t}catch(t){e.shell.error("Failed to get default permissions"),console.error(t)}return Te})))(),k=L?null!==(h=null===(p=this.campaign)||void 0===p?void 0:p.authorUserFriendlyName)&&void 0!==h?h:null===(m=yield e.dapi.users.find(L))||void 0===m?void 0:m.friendlyName:void 0,M={name:_,friendlyName:null!==(g=null!==(f=null===(v=this.campaign)||void 0===v?void 0:v.friendlyName)&&void 0!==f?f:null==n?void 0:n.friendlyName)&&void 0!==g?g:_,templateName:I,status:null!==(w=null===(y=this.campaign)||void 0===y?void 0:y.status)&&void 0!==w?w:"In Progress",createDate:null!==(C=null===(b=this.campaign)||void 0===b?void 0:b.createDate)&&void 0!==C?C:W(new Date),campaignFields:null!==(T=null===(A=this.campaign)||void 0===A?void 0:A.campaignFields)&&void 0!==T?T:this.campaignProps,columnSemTypes:P,rowCount:F.rowCount,filteredRowCount:F.filter.trueCount,savePath:this._filePath,columnTypes:O,tilesViewerFormSketch:V,version:this.version+1,authorUserId:L,authorUserFriendlyName:k,lastModifiedUserName:e.shell.user.friendlyName,permissions:B};if(!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),M;const U=`${this.appName}/campaigns/${E}/${l}`;let R=F;if(yield st.files.exists(U)){const t=JSON.parse(yield st.files.readAsText(U));if((null!==(x=t.version)&&void 0!==x?x:0)>this.version&&(M.version=Math.max(this.version,null!==(S=t.version)&&void 0!==S?S:0)+1,yield e.dapi.files.exists(this._filePath)))try{const t=yield e.dapi.files.readCsv(this._filePath);R=this.unionDataframes(t,F,this.molColName,this.molColName)}catch(e){console.error(e)}}const j=o.DataFrame.fromColumns(R.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield e.dapi.files.writeAsText(this._filePath,j);const D=this._designView.saveLayout();return D?M.layout=D.viewState:e.shell.warning("Layout cound not be saved"),M.template=this.template,yield st.files.writeAsText(U,JSON.stringify(M)),t&&e.shell.info("Campaign saved successfully."),!t&&i&&e.shell.info("Campaign created successfully."),this.campaign=M,this.designViewName=null!==(N=M.friendlyName)&&void 0!==N?N:M.name,M}))}}class Xe extends o.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 et=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 tt extends $e{constructor(t){super(t),this.name="PeptiHit",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(st.webRoot+"README_HD.md")}getNewCampaignAccordeon(e){return et(this,void 0,void 0,(function*(){const{root:t,promise:i,cancelPromise:n}=Me(e,!0);return i.then((t=>et(this,void 0,void 0,(function*(){this.app.dataFrame=t.df,yield this.app.setTemplate(e),this.app.campaignProps=t.campaignProps,yield this.app.saveCampaign(!1),e.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=e.layoutViewState)})))),n.then((()=>{this.init()})),t}))}getAppHeader(){return Ce.appHeader({iconPath:st.webRoot+"/images/icons/pepti-hit-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 Helm sequences in the spreadsheet\n- Annotate and share ideas with the team\n- Convert to molecular form and calculate different properties\n- Save campaigns and continue from where you left off\n- Submit final selection to the function of your choice"})}}var it=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 nt extends Ze{constructor(e){super(e,"PeptiHit",(e=>new tt(e))),this._helmColName=m}setTemplate(e,t){const i=Object.create(null,{setTemplate:{get:()=>super.setTemplate}});return it(this,void 0,void 0,(function*(){var n,a;yield i.setTemplate.call(this,e,t),this._helmColName=null!==(a=null===(n=this.dataFrame.columns.bySemType(o.SEMTYPE.MACROMOLECULE))||void 0===n?void 0:n.name)&&void 0!==a?a:m}))}get helmColName(){var e,t;return null!==(e=this._helmColName)&&void 0!==e?e:null===(t=this.dataFrame.columns.bySemType(o.SEMTYPE.MACROMOLECULE))||void 0===t?void 0:t.name}performSingleCellCalculations(t,i){const n=Object.create(null,{performSingleCellCalculations:{get:()=>super.performSingleCellCalculations}});return it(this,void 0,void 0,(function*(){var a;try{if(!i)throw new Error("No cell value provided");const s=o.Column.fromStrings(this.helmColName,[i]),r=o.DataFrame.fromColumns([s]);s.semType=o.SEMTYPE.MACROMOLECULE,s.setTag("units","helm"),s.setTag(".alphabetIsMultichar","true"),yield e.functions.call("Bio:toAtomicLevel",{table:r,seqCol:s,nonlinear:!0});const l=r.columns.names().find((e=>e.toLowerCase()!==this.helmColName.toLowerCase())),u=l?null===(a=r.col(l))||void 0===a?void 0:a.get(0):null;if(!u)throw new Error("Failed to convert sequence to atomic level");this.dataFrame.set(this.molColName,t,u),yield n.performSingleCellCalculations.call(this,t,u)}catch(e){console.error(e)}}))}getDesignView(){var t,i,n,a,s,r;const l=[],u=null===(t=this.dataFrame.col(this.helmColName))||void 0===t?void 0:t.toList().every((e=>!e&&""===e)),d=this.dataFrame.col(this.helmColName);if(!d)throw new Error("No helm column found");d.semType=o.SEMTYPE.MACROMOLECULE,d.setTag("units","helm"),d.setTag(".alphabetIsMultichar","true"),d.setTag("cell.renderer","helm");const c=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.name)&&void 0!==n?n:this._designViewName,c.name=this._designViewName,c._onAdded();const h=null!==(s=null===(a=this._campaign)||void 0===a?void 0:a.layout)&&void 0!==s?s:null===(r=this.template)||void 0===r?void 0:r.layoutViewState;if(h)try{const e=o.ViewLayout.fromViewState(h);c.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}return u&&e.functions.call("Helm:editMoleculeCell",{cell:c.grid.cell(this.helmColName,0)}),l.push(this.dataFrame.onRowsAdded.pipe((0,We.filter)((()=>!this.isJoining))).subscribe((()=>{var t;try{if(this.stages.length>0)for(let e=0;e<this.dataFrame.rowCount;e++){const i=this.dataFrame.col(p).get(e);i&&""!==i&&!(null===(t=this.dataFrame.col(p))||void 0===t?void 0:t.isNone(e))||this.dataFrame.set(p,e,this.stages[0])}let i=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=c.grid.cell(this.helmColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(i=t))}i&&e.functions.call("Helm:editMoleculeCell",{cell:i})}catch(e){console.error(e)}}))),l.push(e.events.onContextMenu.subscribe((t=>{var i,n,a,s,r,l,u,d,p,h,m,v;try{const e=null===(i=null==t?void 0:t.args)||void 0===i?void 0:i.context;if(!e)return;if((null==e?void 0:e.type)!==o.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==c.id)return;if((null===(s=null===(a=null===(n=null==t?void 0:t.args)||void 0===n?void 0:n.item)||void 0===a?void 0:a.tableColumn)||void 0===s?void 0:s.name)!==this.helmColName||!(null===(l=null===(r=null==t?void 0:t.args)||void 0===r?void 0:r.item)||void 0===l?void 0:l.isTableCell))return;const f=null===(u=null==t?void 0:t.args)||void 0===u?void 0:u.menu;if(!f)return;f.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),f.item("Duplicate Sequence",(()=>{var e,i,n,o;try{const a=this.dataFrame.rows.addNew(null,!0);null!=a.get(this.helmColName)&&a.idx>-1&&(this.dataFrame.cell(a.idx,this.helmColName).value=null!==(o=null===(n=null===(i=null===(e=null==t?void 0:t.args)||void 0===e?void 0:e.item)||void 0===i?void 0:i.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}}));const g=null===(p=null===(d=null==t?void 0:t.args)||void 0===d?void 0:d.item)||void 0===p?void 0:p.tableRowIndex,y=null===(v=null===(m=null===(h=null==t?void 0:t.args)||void 0===h?void 0:h.item)||void 0===m?void 0:m.cell)||void 0===v?void 0:v.value;y&&(null!=g?g:-1)>-1&&f.item("Re-Run Calculations",(()=>it(this,void 0,void 0,(function*(){try{yield this.performSingleCellCalculations(g,y)}catch(e){console.error(e)}}))))}catch(t){e.log.error(t)}}))),(null==c?void 0:c.grid)||(e.shell.error("Applied layout created view without grid. Resetting layout."),c.resetLayout()),(null==c?void 0:c.grid)&&l.push(c.grid.onCellValueEdited.subscribe((e=>it(this,void 0,void 0,(function*(){var t,i,n,o,a;try{if((null===(t=e.tableColumn)||void 0===t?void 0:t.name)===p)return void(yield this.saveCampaign(!1));if((null===(i=e.tableColumn)||void 0===i?void 0:i.name)!==this.helmColName)return;const s=e.cell.value,r=e.tableRowIndex;let l=null===(n=this.dataFrame.col(v))||void 0===n?void 0:n.get(r),u=!1;if(s)try{const t=e.tableColumn.toList(),i=s;if((null==t?void 0:t.length)===this.dataFrame.rowCount)for(let e=0;e<t.length;e++)if(t[e]===i&&e!==r&&(null===(o=this.dataFrame.col(v))||void 0===o?void 0:o.get(e))){l=null===(a=this.dataFrame.col(v))||void 0===a?void 0:a.get(e),u=!0;break}}catch(e){console.error(e)}this.duplicateVidCache&&!u&&this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[r]]>1&&(l=null),l&&""!==l||(l=Ve(this.dataFrame.col(v))),this.dataFrame.col(v).set(r,l,!1),this.performSingleCellCalculations(r,s)}catch(e){console.error(e)}}))))),(null==c?void 0:c.grid)&&l.push(c.grid.onCellRender.subscribe((e=>{var t;try{const i=e.cell;if(!i||!i.isTableCell||!i.tableColumn||!this.duplicateVidCache||i.tableColumn.name!==v||(null!==(t=i.tableRowIndex)&&void 0!==t?t:-1)<0)return;this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[i.tableRowIndex]]>1&&(e.cell.style.backColor=o.Color.setAlpha(o.Color.getCategoricalColor(this.duplicateVidCache.indexes[i.tableRowIndex]),150))}catch(e){}}))),this.initDesignViewRibbons(c,l),c.parentCall=this.parentCall,c}}var ot=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 at extends o.Package{constructor(){super(...arguments),this.molToSmilesLruCache=new o.LruCache(2e3)}convertToSmiles(t){return t?this.molToSmilesLruCache.getOrCreate(t,(t=>e.chem.convert(t,e.chem.Notation.Unknown,e.chem.Notation.Smiles))):""}}const st=new at;function rt(i,n,a){return ot(this,void 0,void 0,(function*(){var s;const r=t.div([],{style:{width:"50px",height:"24px",position:"relative"}});r.innerHTML='<div class="grok-loader"><div></div><div></div><div></div><div></div></div>';const l=i.item(r),u=yield X(a,[]);for(const[t,a]of Object.entries(u)){const t="ingest"in a?a.ingest.query:a.savePath;t&&(yield e.dapi.files.exists(t))&&i.item(null!==(s=a.friendlyName)&&void 0!==s?s:a.name).onSelected.subscribe((i=>ot(this,void 0,void 0,(function*(){try{const i=yield e.dapi.files.readCsv(t);if(!i)return;const s=a.columnSemTypes;if(s)for(const[e,t]of Object.entries(s)){const n=i.columns.byName(e);n&&(n.semType=t,t===o.SEMTYPE.MACROMOLECULE&&e===m&&(n.setTag("units","helm"),n.setTag(".alphabetIsMultichar","true"),n.setTag("cell.renderer","helm")))}const r=o.TableView.create(i,!1);n.preview=r;const l=a.layout;l&&r.loadLayout(o.ViewLayout.fromViewState(l))}catch(e){console.error(e)}}))))}l.remove()}))}function lt(e,t){return ot(this,void 0,void 0,(function*(){yield rt(e,t,"Hit Triage")}))}function ut(e,t){return ot(this,void 0,void 0,(function*(){yield rt(e,t,"Hit Design")}))}function dt(e,t){return ot(this,void 0,void 0,(function*(){yield rt(e,t,"PeptiHit")}))}function ct(){return ot(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return new ke(t).multiView}))}function pt(){return ot(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return new Ze(t).multiView}))}function ht(){return ot(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return yield e.functions.call("Bio:initBio",{}),new nt(t).multiView}))}function mt(){return ot(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(100);return t.name="100 Molecules",t}))}function vt(){return ot(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(5e3);return t.name="5000 Molecules",t}))}function ft(t){return ot(this,void 0,void 0,(function*(){const i=e.data.demo.molecules(t);return i.name="Variable Molecules number",i}))}function gt(t,i){return ot(this,void 0,void 0,(function*(){e.shell.info(t.rowCount),e.shell.info(i)}))}function yt(){return new Xe}function wt(i){return ot(this,void 0,void 0,(function*(){return function(i){return Je(this,void 0,void 0,(function*(){const n=i.filter((e=>e.category===ze)),a=[];for(const i of n){const n=`${i.name[0].toUpperCase()}${i.name.slice(1)}`,s=i.get(null),r=yield Ke(s),l=t.input.userGroups(n);yield o.delay(200),l.value=r,l.onInput.subscribe((()=>{var t;try{const e=(null===(t=l.value)||void 0===t?void 0:t.length)?JSON.stringify(l.value.map((e=>e.id))):"";i.set(null,e)}catch(t){e.shell.error("Error Setting group. Check console for more details"),console.error(t)}})),l.setTooltip(`Selected groups will be granted ${n.toLowerCase()} permissions by default on newly created campaigns`),a.push(l)}const s=o.Widget.fromRoot(t.form(a,{style:{overflow:"visible"}}));return s.root.prepend(t.h1("Default Campaign Sharing",{style:{marginBottom:"6px",marginTop:"6px"}})),setTimeout((()=>{var e;return(null===(e=s.root.parentElement)||void 0===e?void 0:e.style)&&(s.root.parentElement.style.overflow="visible")}),200),s}))}(i)}))}})(),hittriage=n})();
|
|
2
2
|
//# sourceMappingURL=package.js.map
|